feat(harness): manage Pi agent sessions

This commit is contained in:
Wenxin Duan
2026-09-07 16:20:44 +08:00
parent 1eaa85c09a
commit 64ca126047
10 changed files with 760 additions and 4 deletions
@@ -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;
}