feat(harness): manage Pi agent sessions
This commit is contained in:
@@ -32,16 +32,21 @@ export class SafeWorkspace {
|
||||
}
|
||||
|
||||
public async resolveReadable(inputPath: string): Promise<string> {
|
||||
const canonical = await this.resolveExisting(inputPath);
|
||||
const metadata = await lstat(canonical);
|
||||
if (!metadata.isFile()) {
|
||||
throw new HarnessError("NOT_A_REGULAR_FILE", "Only regular files may be read");
|
||||
}
|
||||
return canonical;
|
||||
}
|
||||
|
||||
public async resolveExisting(inputPath: string): Promise<string> {
|
||||
const candidate = isAbsolute(inputPath) ? resolve(inputPath) : resolve(this.root, inputPath);
|
||||
this.#assertContained(candidate);
|
||||
this.#assertUnprotected(candidate);
|
||||
await this.#assertNoSymlinkSegments(candidate);
|
||||
const canonical = await realpath(candidate);
|
||||
this.#assertContained(canonical);
|
||||
const metadata = await lstat(canonical);
|
||||
if (!metadata.isFile()) {
|
||||
throw new HarnessError("NOT_A_REGULAR_FILE", "Only regular files may be read");
|
||||
}
|
||||
return canonical;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user