@greppleai/grip-agent-core 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/agent-loop.d.ts.map +1 -1
  2. package/dist/agent-loop.js.map +1 -1
  3. package/dist/agent.d.ts +7 -0
  4. package/dist/agent.d.ts.map +1 -1
  5. package/dist/agent.js +2 -27
  6. package/dist/agent.js.map +1 -1
  7. package/dist/harness/agent-harness.d.ts.map +1 -1
  8. package/dist/harness/agent-harness.js +7 -20
  9. package/dist/harness/agent-harness.js.map +1 -1
  10. package/dist/harness/compaction/branch-summarization.d.ts.map +1 -1
  11. package/dist/harness/compaction/branch-summarization.js.map +1 -1
  12. package/dist/harness/compaction/compaction.d.ts.map +1 -1
  13. package/dist/harness/compaction/compaction.js.map +1 -1
  14. package/dist/harness/compaction/utils.d.ts.map +1 -1
  15. package/dist/harness/compaction/utils.js.map +1 -1
  16. package/dist/harness/env/nodejs.d.ts.map +1 -1
  17. package/dist/harness/env/nodejs.js +0 -3
  18. package/dist/harness/env/nodejs.js.map +1 -1
  19. package/dist/harness/messages.d.ts.map +1 -1
  20. package/dist/harness/messages.js.map +1 -1
  21. package/dist/harness/prompt-templates.d.ts.map +1 -1
  22. package/dist/harness/prompt-templates.js.map +1 -1
  23. package/dist/harness/session/jsonl-errors.d.ts.map +1 -1
  24. package/dist/harness/session/jsonl-errors.js +0 -10
  25. package/dist/harness/session/jsonl-errors.js.map +1 -1
  26. package/dist/harness/session/jsonl-repo.d.ts.map +1 -1
  27. package/dist/harness/session/jsonl-repo.js +1 -4
  28. package/dist/harness/session/jsonl-repo.js.map +1 -1
  29. package/dist/harness/session/jsonl-storage.d.ts.map +1 -1
  30. package/dist/harness/session/jsonl-storage.js +1 -11
  31. package/dist/harness/session/jsonl-storage.js.map +1 -1
  32. package/dist/harness/session/memory-repo.d.ts.map +1 -1
  33. package/dist/harness/session/memory-repo.js +3 -1
  34. package/dist/harness/session/memory-repo.js.map +1 -1
  35. package/dist/harness/session/memory-storage.d.ts.map +1 -1
  36. package/dist/harness/session/memory-storage.js +0 -5
  37. package/dist/harness/session/memory-storage.js.map +1 -1
  38. package/dist/harness/session/repo-utils.d.ts.map +1 -1
  39. package/dist/harness/session/repo-utils.js.map +1 -1
  40. package/dist/harness/session/session.d.ts.map +1 -1
  41. package/dist/harness/session/session.js +0 -1
  42. package/dist/harness/session/session.js.map +1 -1
  43. package/dist/harness/session/uuid.d.ts.map +1 -1
  44. package/dist/harness/session/uuid.js.map +1 -1
  45. package/dist/harness/skills.d.ts.map +1 -1
  46. package/dist/harness/skills.js.map +1 -1
  47. package/dist/harness/system-prompt.d.ts.map +1 -1
  48. package/dist/harness/system-prompt.js.map +1 -1
  49. package/dist/harness/types.d.ts.map +1 -1
  50. package/dist/harness/types.js +0 -13
  51. package/dist/harness/types.js.map +1 -1
  52. package/dist/harness/utils/shell-output.d.ts.map +1 -1
  53. package/dist/harness/utils/shell-output.js.map +1 -1
  54. package/dist/harness/utils/truncate.d.ts.map +1 -1
  55. package/dist/harness/utils/truncate.js.map +1 -1
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/node.d.ts.map +1 -1
  58. package/dist/proxy.d.ts.map +1 -1
  59. package/dist/proxy.js.map +1 -1
  60. package/dist/types.d.ts.map +1 -1
  61. package/package.json +10 -10
@@ -1 +1 @@
1
- {"version":3,"file":"nodejs.js","sourceRoot":"","sources":["../../../src/harness/env/nodejs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EACN,MAAM,EACN,UAAU,EACV,KAAK,EACL,KAAK,EACL,OAAO,EACP,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,EAAE,EACF,SAA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KAAK,EAAE,GAAG,OAAO,EAAE,MAAM,IAAI,EAAE,GAAG,UAAU,EAAE,GAAG,OAAO,EAAE,MAAM,IAAI,EAAE,EAAE,CAAC,CAAC;QACpG,IAAI,CAAC;YACJ,MAAM,SAAS,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YAC9B,OAAO,EAAE,CAAC,QAAQ,CAAC,CAAC;QACrB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,GAAG,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;QAC1C,CAAC;IAAA,CACD;IAED,KAAK,CAAC,OAAO,GAAkB;QAC9B,wDAAwD;IADzB,CAE/B;CACD","sourcesContent":["import { spawn } from \"node:child_process\";\nimport { randomUUID } from \"node:crypto\";\nimport { constants, createReadStream } from \"node:fs\";\nimport {\n\taccess,\n\tappendFile,\n\tlstat,\n\tmkdir,\n\tmkdtemp,\n\treaddir,\n\treadFile,\n\trealpath,\n\trename,\n\trm,\n\twriteFile,\n} from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { isAbsolute, join, resolve } from \"node:path\";\nimport { createInterface } from \"node:readline\";\nimport {\n\ttype CreateDirOptions,\n\ttype CreateTempFileOptions,\n\ttype ExecutionEnv,\n\ttype ExecutionEnvExecOptions,\n\ttype ExecutionEnvExecResult,\n\tExecutionError,\n\terr,\n\tFileError,\n\ttype FileInfo,\n\ttype FileKind,\n\tok,\n\ttype ReadTextLinesOptions,\n\ttype RemovePathOptions,\n\ttype Result,\n\ttoError,\n} from \"../types.ts\";\n\nconst MAX_TIMEOUT_MS = 2_147_483_647;\nconst MAX_TIMEOUT_SECONDS = MAX_TIMEOUT_MS / 1000;\nexport const MAX_EXEC_OUTPUT_CHARS = 1_000_000;\nconst OUTPUT_TRUNCATION_MARKER = \"[... earlier output truncated ...]\\n\";\n\nfunction appendBoundedOutput(current: string, chunk: string): string {\n\tif (current.length + chunk.length <= MAX_EXEC_OUTPUT_CHARS) return current + chunk;\n\tconst retainedChars = MAX_EXEC_OUTPUT_CHARS - OUTPUT_TRUNCATION_MARKER.length;\n\tconst tail = chunk.length >= retainedChars ? chunk.slice(-retainedChars) : (current + chunk).slice(-retainedChars);\n\treturn OUTPUT_TRUNCATION_MARKER + tail;\n}\nfunction resolveTimeoutMs(timeout: number | undefined): Result<number | undefined, ExecutionError> {\n\tif (timeout === undefined) return ok(undefined);\n\tif (!Number.isFinite(timeout) || timeout <= 0) {\n\t\treturn err(new ExecutionError(\"timeout\", \"Invalid timeout: must be a finite number of seconds\"));\n\t}\n\n\tconst timeoutMs = timeout * 1000;\n\tif (timeoutMs > MAX_TIMEOUT_MS) {\n\t\treturn err(new ExecutionError(\"timeout\", `Invalid timeout: maximum is ${MAX_TIMEOUT_SECONDS} seconds`));\n\t}\n\treturn ok(timeoutMs);\n}\n\nfunction resolvePath(cwd: string, path: string): string {\n\treturn isAbsolute(path) ? path : resolve(cwd, path);\n}\n\ninterface FileKindStats {\n\tisFile(): boolean;\n\tisDirectory(): boolean;\n\tisSymbolicLink(): boolean;\n}\n\ninterface FileInfoStats extends FileKindStats {\n\tsize: number;\n\tmtimeMs: number;\n}\n\nfunction fileKindFromStats(stats: FileKindStats): FileKind | undefined {\n\tif (stats.isFile()) return \"file\";\n\tif (stats.isDirectory()) return \"directory\";\n\tif (stats.isSymbolicLink()) return \"symlink\";\n\treturn undefined;\n}\n\nfunction fileInfoFromStats(path: string, stats: FileInfoStats): Result<FileInfo, FileError> {\n\tconst kind = fileKindFromStats(stats);\n\tif (!kind) return err(new FileError(\"invalid\", \"Unsupported file type\", path));\n\treturn ok({\n\t\tname: path.replace(/\\/+$/, \"\").split(\"/\").pop() ?? path,\n\t\tpath,\n\t\tkind,\n\t\tsize: stats.size,\n\t\tmtimeMs: stats.mtimeMs,\n\t});\n}\n\nfunction isNodeError(error: unknown): error is NodeJS.ErrnoException {\n\treturn error instanceof Error && \"code\" in error;\n}\n\nfunction toFileError(error: unknown, path?: string): FileError {\n\tif (error instanceof FileError) return error;\n\tconst cause = toError(error);\n\tif (isNodeError(error)) {\n\t\tconst message = error.message;\n\t\tswitch (error.code) {\n\t\t\tcase \"ABORT_ERR\":\n\t\t\t\treturn new FileError(\"aborted\", message, path, cause);\n\t\t\tcase \"ENOENT\":\n\t\t\t\treturn new FileError(\"not_found\", message, path, cause);\n\t\t\tcase \"EACCES\":\n\t\t\tcase \"EPERM\":\n\t\t\t\treturn new FileError(\"permission_denied\", message, path, cause);\n\t\t\tcase \"ENOTDIR\":\n\t\t\t\treturn new FileError(\"not_directory\", message, path, cause);\n\t\t\tcase \"EISDIR\":\n\t\t\t\treturn new FileError(\"is_directory\", message, path, cause);\n\t\t\tcase \"EINVAL\":\n\t\t\t\treturn new FileError(\"invalid\", message, path, cause);\n\t\t}\n\t}\n\treturn new FileError(\"unknown\", cause.message, path, cause);\n}\n\nfunction nodeErrorPath(error: unknown, fallback: string): string {\n\tif (isNodeError(error) && typeof error.path === \"string\") return error.path;\n\treturn fallback;\n}\n\nfunction isWindowsRenameSharingError(error: unknown): boolean {\n\treturn isNodeError(error) && (error.code === \"EPERM\" || error.code === \"EACCES\" || error.code === \"EBUSY\");\n}\n\nasync function waitForRenameRetry(delayMs: number, signal?: AbortSignal): Promise<boolean> {\n\tif (signal?.aborted) return false;\n\treturn await new Promise((resolvePromise) => {\n\t\tconst onAbort = () => {\n\t\t\tclearTimeout(timeout);\n\t\t\tresolvePromise(false);\n\t\t};\n\t\tconst timeout = setTimeout(() => {\n\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\tresolvePromise(true);\n\t\t}, delayMs);\n\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\t});\n}\n\nfunction abortResult<TValue>(signal: AbortSignal | undefined, path?: string): Result<TValue, FileError> | undefined {\n\treturn signal?.aborted ? err(new FileError(\"aborted\", \"aborted\", path)) : undefined;\n}\n\nasync function pathExists(path: string): Promise<boolean> {\n\ttry {\n\t\tawait access(path, constants.F_OK);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\ninterface CommandProbeResult {\n\tstdout: string;\n\tstatus: number | null;\n}\n\nasync function runCommand(command: string, args: string[], timeoutMs: number): Promise<CommandProbeResult> {\n\treturn await new Promise((resolve) => {\n\t\tlet stdout = \"\";\n\t\tlet child: ReturnType<typeof spawn>;\n\t\ttry {\n\t\t\tchild = spawn(command, args, {\n\t\t\t\tstdio: [\"ignore\", \"pipe\", \"ignore\"],\n\t\t\t\twindowsHide: true,\n\t\t\t});\n\t\t} catch {\n\t\t\tresolve({ stdout: \"\", status: null });\n\t\t\treturn;\n\t\t}\n\t\tconst timeout = setTimeout(() => {\n\t\t\tif (child.pid) killProcessTree(child.pid);\n\t\t}, timeoutMs);\n\t\tchild.stdout?.setEncoding(\"utf8\");\n\t\tchild.stdout?.on(\"data\", (chunk: string) => {\n\t\t\tstdout = appendBoundedOutput(stdout, chunk);\n\t\t});\n\t\tchild.on(\"error\", () => {\n\t\t\tclearTimeout(timeout);\n\t\t\tresolve({ stdout: \"\", status: null });\n\t\t});\n\t\tchild.on(\"close\", (status) => {\n\t\t\tclearTimeout(timeout);\n\t\t\tresolve({ stdout, status });\n\t\t});\n\t});\n}\n\nasync function findBashOnPath(): Promise<string | null> {\n\tconst result =\n\t\tprocess.platform === \"win32\"\n\t\t\t? await runCommand(\"where\", [\"bash.exe\"], 5000)\n\t\t\t: await runCommand(\"which\", [\"bash\"], 5000);\n\tif (result.status !== 0 || !result.stdout) return null;\n\tconst firstMatch = result.stdout.trim().split(/\\r?\\n/)[0];\n\treturn firstMatch && (await pathExists(firstMatch)) ? firstMatch : null;\n}\n\nexport interface ShellConfig {\n\tshell: string;\n\targs: string[];\n}\n\nasync function getWindowsShellConfig(): Promise<Result<ShellConfig, ExecutionError>> {\n\tconst candidates: string[] = [];\n\tconst programFiles = process.env.ProgramFiles;\n\tif (programFiles) candidates.push(`${programFiles}\\\\Git\\\\bin\\\\bash.exe`);\n\tconst programFilesX86 = process.env[\"ProgramFiles(x86)\"];\n\tif (programFilesX86) candidates.push(`${programFilesX86}\\\\Git\\\\bin\\\\bash.exe`);\n\tfor (const candidate of candidates) {\n\t\tif (await pathExists(candidate)) return ok({ shell: candidate, args: [\"-c\"] });\n\t}\n\tconst bashOnPath = await findBashOnPath();\n\tif (bashOnPath) return ok({ shell: bashOnPath, args: [\"-c\"] });\n\treturn err(new ExecutionError(\"shell_unavailable\", \"No bash shell found\"));\n}\n\nasync function getPosixShellConfig(): Promise<Result<ShellConfig, ExecutionError>> {\n\tif (await pathExists(\"/bin/bash\")) return ok({ shell: \"/bin/bash\", args: [\"-c\"] });\n\tconst bashOnPath = await findBashOnPath();\n\treturn ok({ shell: bashOnPath ?? \"sh\", args: [\"-c\"] });\n}\n\nasync function getShellConfig(customShellPath?: string): Promise<Result<ShellConfig, ExecutionError>> {\n\tif (customShellPath) {\n\t\tif (await pathExists(customShellPath)) return ok({ shell: customShellPath, args: [\"-c\"] });\n\t\treturn err(new ExecutionError(\"shell_unavailable\", `Custom shell path not found: ${customShellPath}`));\n\t}\n\treturn process.platform === \"win32\" ? getWindowsShellConfig() : getPosixShellConfig();\n}\n\nfunction getShellEnv(baseEnv?: NodeJS.ProcessEnv, extraEnv?: Record<string, string>): NodeJS.ProcessEnv {\n\treturn {\n\t\t...process.env,\n\t\t...baseEnv,\n\t\t...extraEnv,\n\t};\n}\n\nfunction killProcessTree(pid: number): void {\n\tif (process.platform === \"win32\") {\n\t\ttry {\n\t\t\tspawn(\"taskkill\", [\"/F\", \"/T\", \"/PID\", String(pid)], {\n\t\t\t\tstdio: \"ignore\",\n\t\t\t\tdetached: true,\n\t\t\t\twindowsHide: true,\n\t\t\t});\n\t\t} catch {\n\t\t\t// Ignore errors.\n\t\t}\n\t\treturn;\n\t}\n\n\ttry {\n\t\tprocess.kill(-pid, \"SIGKILL\");\n\t} catch {\n\t\ttry {\n\t\t\tprocess.kill(pid, \"SIGKILL\");\n\t\t} catch {\n\t\t\t// Process already dead.\n\t\t}\n\t}\n}\n\nexport interface NodeExecutionEnvOptions {\n\tcwd: string;\n\tshellPath?: string;\n\tshellEnv?: NodeJS.ProcessEnv;\n}\n\nexport class NodeExecutionEnv implements ExecutionEnv {\n\tcwd: string;\n\tprivate shellPath?: string;\n\tprivate shellEnv?: NodeJS.ProcessEnv;\n\n\tconstructor(options: NodeExecutionEnvOptions) {\n\t\tthis.cwd = options.cwd;\n\t\tthis.shellPath = options.shellPath;\n\t\tthis.shellEnv = options.shellEnv;\n\t}\n\n\tasync absolutePath(path: string): Promise<Result<string, FileError>> {\n\t\treturn ok(resolvePath(this.cwd, path));\n\t}\n\n\tasync joinPath(parts: string[]): Promise<Result<string, FileError>> {\n\t\treturn ok(join(...parts));\n\t}\n\n\tasync exec(\n\t\tcommand: string,\n\t\toptions?: ExecutionEnvExecOptions,\n\t): Promise<Result<ExecutionEnvExecResult, ExecutionError>> {\n\t\tif (options?.abortSignal?.aborted) return err(new ExecutionError(\"aborted\", \"aborted\"));\n\t\tconst timeoutMsResult = resolveTimeoutMs(options?.timeout);\n\t\tif (!timeoutMsResult.ok) return err(timeoutMsResult.error);\n\t\tconst timeoutMs = timeoutMsResult.value;\n\n\t\tconst cwd = options?.cwd ? resolvePath(this.cwd, options.cwd) : this.cwd;\n\t\tconst shellConfig = await getShellConfig(this.shellPath);\n\t\tif (!shellConfig.ok) return shellConfig;\n\n\t\treturn await new Promise((resolvePromise) => {\n\t\t\tlet stdout = \"\";\n\t\t\tlet stderr = \"\";\n\t\t\tlet settled = false;\n\t\t\tlet timedOut = false;\n\t\t\tlet callbackError: ExecutionError | undefined;\n\t\t\tlet child: ReturnType<typeof spawn> | undefined;\n\t\t\tlet timeoutId: ReturnType<typeof setTimeout> | undefined;\n\n\t\t\tconst onAbort = () => {\n\t\t\t\tif (child?.pid) {\n\t\t\t\t\tkillProcessTree(child.pid);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst settle = (result: Result<ExecutionEnvExecResult, ExecutionError>) => {\n\t\t\t\tif (timeoutId) clearTimeout(timeoutId);\n\t\t\t\tif (options?.abortSignal) options.abortSignal.removeEventListener(\"abort\", onAbort);\n\t\t\t\tif (settled) return;\n\t\t\t\tsettled = true;\n\t\t\t\tresolvePromise(result);\n\t\t\t};\n\n\t\t\ttry {\n\t\t\t\tchild = spawn(shellConfig.value.shell, [...shellConfig.value.args, command], {\n\t\t\t\t\tcwd,\n\t\t\t\t\tdetached: process.platform !== \"win32\",\n\t\t\t\t\tenv: getShellEnv(this.shellEnv, options?.env),\n\t\t\t\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t\t\t\t\twindowsHide: true,\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tconst cause = toError(error);\n\t\t\t\tsettle(err(new ExecutionError(\"spawn_error\", cause.message, cause)));\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\ttimeoutId =\n\t\t\t\ttimeoutMs !== undefined\n\t\t\t\t\t? setTimeout(() => {\n\t\t\t\t\t\t\ttimedOut = true;\n\t\t\t\t\t\t\tif (child?.pid) {\n\t\t\t\t\t\t\t\tkillProcessTree(child.pid);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}, timeoutMs)\n\t\t\t\t\t: undefined;\n\n\t\t\tif (options?.abortSignal) {\n\t\t\t\tif (options.abortSignal.aborted) {\n\t\t\t\t\tonAbort();\n\t\t\t\t} else {\n\t\t\t\t\toptions.abortSignal.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tchild.stdout?.setEncoding(\"utf8\");\n\t\t\tchild.stderr?.setEncoding(\"utf8\");\n\t\t\tchild.stdout?.on(\"data\", (chunk: string) => {\n\t\t\t\tstdout = appendBoundedOutput(stdout, chunk);\n\t\t\t\ttry {\n\t\t\t\t\toptions?.onStdout?.(chunk);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst cause = toError(error);\n\t\t\t\t\tcallbackError = new ExecutionError(\"callback_error\", cause.message, cause);\n\t\t\t\t\tonAbort();\n\t\t\t\t}\n\t\t\t});\n\t\t\tchild.stderr?.on(\"data\", (chunk: string) => {\n\t\t\t\tstderr = appendBoundedOutput(stderr, chunk);\n\t\t\t\ttry {\n\t\t\t\t\toptions?.onStderr?.(chunk);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst cause = toError(error);\n\t\t\t\t\tcallbackError = new ExecutionError(\"callback_error\", cause.message, cause);\n\t\t\t\t\tonAbort();\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tchild.on(\"error\", (error) => {\n\t\t\t\tsettle(err(new ExecutionError(\"spawn_error\", error.message, error)));\n\t\t\t});\n\n\t\t\tchild.on(\"close\", (code) => {\n\t\t\t\tif (callbackError) {\n\t\t\t\t\tsettle(err(callbackError));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (timedOut) {\n\t\t\t\t\tsettle(err(new ExecutionError(\"timeout\", `timeout:${options?.timeout}`)));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (options?.abortSignal?.aborted) {\n\t\t\t\t\tsettle(err(new ExecutionError(\"aborted\", \"aborted\")));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tsettle(ok({ stdout, stderr, exitCode: code ?? 0 }));\n\t\t\t});\n\t\t});\n\t}\n\n\tasync readTextFile(path: string, abortSignal?: AbortSignal): Promise<Result<string, FileError>> {\n\t\tconst resolved = resolvePath(this.cwd, path);\n\t\tconst aborted = abortResult<string>(abortSignal, resolved);\n\t\tif (aborted) return aborted;\n\t\ttry {\n\t\t\treturn ok(await readFile(resolved, { encoding: \"utf8\", signal: abortSignal }));\n\t\t} catch (error) {\n\t\t\treturn err(toFileError(error, resolved));\n\t\t}\n\t}\n\n\tasync readTextLines(path: string, options?: ReadTextLinesOptions): Promise<Result<string[], FileError>> {\n\t\tconst resolved = resolvePath(this.cwd, path);\n\t\tconst aborted = abortResult<string[]>(options?.abortSignal, resolved);\n\t\tif (aborted) return aborted;\n\t\tif (options?.maxLines !== undefined && options.maxLines <= 0) return ok([]);\n\t\tlet stream: ReturnType<typeof createReadStream> | undefined;\n\t\tlet lineReader: ReturnType<typeof createInterface> | undefined;\n\t\ttry {\n\t\t\tstream = createReadStream(resolved, { encoding: \"utf8\", signal: options?.abortSignal });\n\t\t\tlineReader = createInterface({ input: stream, crlfDelay: Infinity });\n\t\t\tconst lines: string[] = [];\n\t\t\tfor await (const line of lineReader) {\n\t\t\t\tconst loopAbort = abortResult<string[]>(options?.abortSignal, resolved);\n\t\t\t\tif (loopAbort) return loopAbort;\n\t\t\t\tlines.push(line);\n\t\t\t\tif (options?.maxLines !== undefined && lines.length >= options.maxLines) break;\n\t\t\t}\n\t\t\tconst afterReadAbort = abortResult<string[]>(options?.abortSignal, resolved);\n\t\t\tif (afterReadAbort) return afterReadAbort;\n\t\t\treturn ok(lines);\n\t\t} catch (error) {\n\t\t\treturn err(toFileError(error, resolved));\n\t\t} finally {\n\t\t\tlineReader?.close();\n\t\t\tstream?.destroy();\n\t\t}\n\t}\n\n\tasync readBinaryFile(path: string, abortSignal?: AbortSignal): Promise<Result<Uint8Array, FileError>> {\n\t\tconst resolved = resolvePath(this.cwd, path);\n\t\tconst aborted = abortResult<Uint8Array>(abortSignal, resolved);\n\t\tif (aborted) return aborted;\n\t\ttry {\n\t\t\treturn ok(await readFile(resolved, { signal: abortSignal }));\n\t\t} catch (error) {\n\t\t\treturn err(toFileError(error, resolved));\n\t\t}\n\t}\n\n\tasync writeFile(\n\t\tpath: string,\n\t\tcontent: string | Uint8Array,\n\t\tabortSignal?: AbortSignal,\n\t): Promise<Result<void, FileError>> {\n\t\tconst resolved = resolvePath(this.cwd, path);\n\t\tconst aborted = abortResult<void>(abortSignal, resolved);\n\t\tif (aborted) return aborted;\n\t\ttry {\n\t\t\tawait mkdir(resolve(resolved, \"..\"), { recursive: true });\n\t\t\tconst afterMkdirAbort = abortResult<void>(abortSignal, resolved);\n\t\t\tif (afterMkdirAbort) return afterMkdirAbort;\n\t\t\tawait writeFile(resolved, content, { signal: abortSignal });\n\t\t\treturn ok(undefined);\n\t\t} catch (error) {\n\t\t\treturn err(toFileError(error, resolved));\n\t\t}\n\t}\n\n\tasync appendFile(path: string, content: string | Uint8Array): Promise<Result<void, FileError>> {\n\t\tconst resolved = resolvePath(this.cwd, path);\n\t\ttry {\n\t\t\tawait mkdir(resolve(resolved, \"..\"), { recursive: true });\n\t\t\tawait appendFile(resolved, content);\n\t\t\treturn ok(undefined);\n\t\t} catch (error) {\n\t\t\treturn err(toFileError(error, resolved));\n\t\t}\n\t}\n\n\tasync renameFile(source: string, destination: string, abortSignal?: AbortSignal): Promise<Result<void, FileError>> {\n\t\tconst resolvedSource = resolvePath(this.cwd, source);\n\t\tconst resolvedDestination = resolvePath(this.cwd, destination);\n\t\tfor (let attempt = 0; attempt < 5; attempt++) {\n\t\t\tconst aborted = abortResult<void>(abortSignal, resolvedDestination);\n\t\t\tif (aborted) return aborted;\n\t\t\ttry {\n\t\t\t\tawait rename(resolvedSource, resolvedDestination);\n\t\t\t\treturn ok(undefined);\n\t\t\t} catch (error) {\n\t\t\t\tif (process.platform !== \"win32\" || !isWindowsRenameSharingError(error) || attempt === 4) {\n\t\t\t\t\treturn err(toFileError(error, nodeErrorPath(error, resolvedDestination)));\n\t\t\t\t}\n\t\t\t\tif (!(await waitForRenameRetry(10 * 2 ** attempt, abortSignal))) {\n\t\t\t\t\treturn err(new FileError(\"aborted\", \"aborted\", resolvedDestination));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn err(new FileError(\"unknown\", \"rename failed\", resolvedDestination));\n\t}\n\n\tasync fileInfo(path: string): Promise<Result<FileInfo, FileError>> {\n\t\tconst resolved = resolvePath(this.cwd, path);\n\t\ttry {\n\t\t\treturn fileInfoFromStats(resolved, await lstat(resolved));\n\t\t} catch (error) {\n\t\t\treturn err(toFileError(error, resolved));\n\t\t}\n\t}\n\n\tasync listDir(path: string, abortSignal?: AbortSignal): Promise<Result<FileInfo[], FileError>> {\n\t\tconst resolved = resolvePath(this.cwd, path);\n\t\tconst aborted = abortResult<FileInfo[]>(abortSignal, resolved);\n\t\tif (aborted) return aborted;\n\t\ttry {\n\t\t\tconst entries = await readdir(resolved, { withFileTypes: true });\n\t\t\tconst infos: FileInfo[] = [];\n\t\t\tfor (const entry of entries) {\n\t\t\t\tconst loopAbort = abortResult<FileInfo[]>(abortSignal, resolved);\n\t\t\t\tif (loopAbort) return loopAbort;\n\t\t\t\tconst entryPath = resolve(resolved, entry.name);\n\t\t\t\ttry {\n\t\t\t\t\tconst info = fileInfoFromStats(entryPath, await lstat(entryPath));\n\t\t\t\t\tif (info.ok) infos.push(info.value);\n\t\t\t\t} catch (error) {\n\t\t\t\t\treturn err(toFileError(error, entryPath));\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn ok(infos);\n\t\t} catch (error) {\n\t\t\treturn err(toFileError(error, resolved));\n\t\t}\n\t}\n\n\tasync canonicalPath(path: string): Promise<Result<string, FileError>> {\n\t\tconst resolved = resolvePath(this.cwd, path);\n\t\ttry {\n\t\t\treturn ok(await realpath(resolved));\n\t\t} catch (error) {\n\t\t\treturn err(toFileError(error, resolved));\n\t\t}\n\t}\n\n\tasync exists(path: string): Promise<Result<boolean, FileError>> {\n\t\tconst result = await this.fileInfo(path);\n\t\tif (result.ok) return ok(true);\n\t\tif (result.error.code === \"not_found\") return ok(false);\n\t\treturn err(result.error);\n\t}\n\n\tasync createDir(path: string, options?: CreateDirOptions): Promise<Result<void, FileError>> {\n\t\tconst resolved = resolvePath(this.cwd, path);\n\t\ttry {\n\t\t\tawait mkdir(resolved, { recursive: options?.recursive ?? true });\n\t\t\treturn ok(undefined);\n\t\t} catch (error) {\n\t\t\treturn err(toFileError(error, resolved));\n\t\t}\n\t}\n\n\tasync remove(path: string, options?: RemovePathOptions): Promise<Result<void, FileError>> {\n\t\tconst resolved = resolvePath(this.cwd, path);\n\t\ttry {\n\t\t\tawait rm(resolved, { recursive: options?.recursive ?? false, force: options?.force ?? false });\n\t\t\treturn ok(undefined);\n\t\t} catch (error) {\n\t\t\treturn err(toFileError(error, resolved));\n\t\t}\n\t}\n\n\tasync createTempDir(prefix: string = \"tmp-\"): Promise<Result<string, FileError>> {\n\t\ttry {\n\t\t\treturn ok(await mkdtemp(join(tmpdir(), prefix)));\n\t\t} catch (error) {\n\t\t\treturn err(toFileError(error));\n\t\t}\n\t}\n\n\tasync createTempFile(options?: CreateTempFileOptions): Promise<Result<string, FileError>> {\n\t\tconst dir = await this.createTempDir(\"tmp-\");\n\t\tif (!dir.ok) return dir;\n\t\tconst filePath = join(dir.value, `${options?.prefix ?? \"\"}${randomUUID()}${options?.suffix ?? \"\"}`);\n\t\ttry {\n\t\t\tawait writeFile(filePath, \"\");\n\t\t\treturn ok(filePath);\n\t\t} catch (error) {\n\t\t\treturn err(toFileError(error, filePath));\n\t\t}\n\t}\n\n\tasync cleanup(): Promise<void> {\n\t\t// nothing to clean up for the local node implementation\n\t}\n}\n"]}
1
+ {"version":3,"file":"nodejs.js","sourceRoot":"","sources":["../../../src/harness/env/nodejs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EACN,MAAM,EACN,UAAU,EACV,KAAK,EACL,KAAK,EACL,OAAO,EACP,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,EAAE,EACF,SAAS,GACT,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAMN,cAAc,EACd,GAAG,EACH,S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AO,GAAG,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;QAC1C,CAAC;IACF,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,MAAM,GAAW,MAAM;QAC1C,IAAI,CAAC;YACJ,OAAO,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;QAClD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;QAChC,CAAC;IACF,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,OAA+B;QACnD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAC7C,IAAI,CAAC,GAAG,CAAC,EAAE;YAAE,OAAO,GAAG,CAAC;QACxB,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,OAAO,EAAE,MAAM,IAAI,EAAE,GAAG,UAAU,EAAE,GAAG,OAAO,EAAE,MAAM,IAAI,EAAE,EAAE,CAAC,CAAC;QACpG,IAAI,CAAC;YACJ,MAAM,SAAS,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YAC9B,OAAO,EAAE,CAAC,QAAQ,CAAC,CAAC;QACrB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,GAAG,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;QAC1C,CAAC;IACF,CAAC;IAED,KAAK,CAAC,OAAO;QACZ,wDAAwD;IACzD,CAAC;CACD","sourcesContent":["import { spawn } from \"node:child_process\";\nimport { randomUUID } from \"node:crypto\";\nimport { constants, createReadStream } from \"node:fs\";\nimport {\n\taccess,\n\tappendFile,\n\tlstat,\n\tmkdir,\n\tmkdtemp,\n\treaddir,\n\treadFile,\n\trealpath,\n\trename,\n\trm,\n\twriteFile,\n} from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { isAbsolute, join, resolve } from \"node:path\";\nimport { createInterface } from \"node:readline\";\nimport {\n\ttype CreateDirOptions,\n\ttype CreateTempFileOptions,\n\ttype ExecutionEnv,\n\ttype ExecutionEnvExecOptions,\n\ttype ExecutionEnvExecResult,\n\tExecutionError,\n\terr,\n\tFileError,\n\ttype FileInfo,\n\ttype FileKind,\n\tok,\n\ttype ReadTextLinesOptions,\n\ttype RemovePathOptions,\n\ttype Result,\n\ttoError,\n} from \"../types.ts\";\n\nconst MAX_TIMEOUT_MS = 2_147_483_647;\nconst MAX_TIMEOUT_SECONDS = MAX_TIMEOUT_MS / 1000;\nexport const MAX_EXEC_OUTPUT_CHARS = 1_000_000;\nconst OUTPUT_TRUNCATION_MARKER = \"[... earlier output truncated ...]\\n\";\n\nfunction appendBoundedOutput(current: string, chunk: string): string {\n\tif (current.length + chunk.length <= MAX_EXEC_OUTPUT_CHARS) return current + chunk;\n\tconst retainedChars = MAX_EXEC_OUTPUT_CHARS - OUTPUT_TRUNCATION_MARKER.length;\n\tconst tail = chunk.length >= retainedChars ? chunk.slice(-retainedChars) : (current + chunk).slice(-retainedChars);\n\treturn OUTPUT_TRUNCATION_MARKER + tail;\n}\nfunction resolveTimeoutMs(timeout: number | undefined): Result<number | undefined, ExecutionError> {\n\tif (timeout === undefined) return ok(undefined);\n\tif (!Number.isFinite(timeout) || timeout <= 0) {\n\t\treturn err(new ExecutionError(\"timeout\", \"Invalid timeout: must be a finite number of seconds\"));\n\t}\n\n\tconst timeoutMs = timeout * 1000;\n\tif (timeoutMs > MAX_TIMEOUT_MS) {\n\t\treturn err(new ExecutionError(\"timeout\", `Invalid timeout: maximum is ${MAX_TIMEOUT_SECONDS} seconds`));\n\t}\n\treturn ok(timeoutMs);\n}\n\nfunction resolvePath(cwd: string, path: string): string {\n\treturn isAbsolute(path) ? path : resolve(cwd, path);\n}\n\ninterface FileKindStats {\n\tisFile(): boolean;\n\tisDirectory(): boolean;\n\tisSymbolicLink(): boolean;\n}\n\ninterface FileInfoStats extends FileKindStats {\n\tsize: number;\n\tmtimeMs: number;\n}\n\nfunction fileKindFromStats(stats: FileKindStats): FileKind | undefined {\n\tif (stats.isFile()) return \"file\";\n\tif (stats.isDirectory()) return \"directory\";\n\tif (stats.isSymbolicLink()) return \"symlink\";\n\treturn undefined;\n}\n\nfunction fileInfoFromStats(path: string, stats: FileInfoStats): Result<FileInfo, FileError> {\n\tconst kind = fileKindFromStats(stats);\n\tif (!kind) return err(new FileError(\"invalid\", \"Unsupported file type\", path));\n\treturn ok({\n\t\tname: path.replace(/\\/+$/, \"\").split(\"/\").pop() ?? path,\n\t\tpath,\n\t\tkind,\n\t\tsize: stats.size,\n\t\tmtimeMs: stats.mtimeMs,\n\t});\n}\n\nfunction isNodeError(error: unknown): error is NodeJS.ErrnoException {\n\treturn error instanceof Error && \"code\" in error;\n}\n\nfunction toFileError(error: unknown, path?: string): FileError {\n\tif (error instanceof FileError) return error;\n\tconst cause = toError(error);\n\tif (isNodeError(error)) {\n\t\tconst message = error.message;\n\t\tswitch (error.code) {\n\t\t\tcase \"ABORT_ERR\":\n\t\t\t\treturn new FileError(\"aborted\", message, path, cause);\n\t\t\tcase \"ENOENT\":\n\t\t\t\treturn new FileError(\"not_found\", message, path, cause);\n\t\t\tcase \"EACCES\":\n\t\t\tcase \"EPERM\":\n\t\t\t\treturn new FileError(\"permission_denied\", message, path, cause);\n\t\t\tcase \"ENOTDIR\":\n\t\t\t\treturn new FileError(\"not_directory\", message, path, cause);\n\t\t\tcase \"EISDIR\":\n\t\t\t\treturn new FileError(\"is_directory\", message, path, cause);\n\t\t\tcase \"EINVAL\":\n\t\t\t\treturn new FileError(\"invalid\", message, path, cause);\n\t\t}\n\t}\n\treturn new FileError(\"unknown\", cause.message, path, cause);\n}\n\nfunction nodeErrorPath(error: unknown, fallback: string): string {\n\tif (isNodeError(error) && typeof error.path === \"string\") return error.path;\n\treturn fallback;\n}\n\nfunction isWindowsRenameSharingError(error: unknown): boolean {\n\treturn isNodeError(error) && (error.code === \"EPERM\" || error.code === \"EACCES\" || error.code === \"EBUSY\");\n}\n\nasync function waitForRenameRetry(delayMs: number, signal?: AbortSignal): Promise<boolean> {\n\tif (signal?.aborted) return false;\n\treturn await new Promise((resolvePromise) => {\n\t\tconst onAbort = () => {\n\t\t\tclearTimeout(timeout);\n\t\t\tresolvePromise(false);\n\t\t};\n\t\tconst timeout = setTimeout(() => {\n\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\tresolvePromise(true);\n\t\t}, delayMs);\n\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\t});\n}\n\nfunction abortResult<TValue>(signal: AbortSignal | undefined, path?: string): Result<TValue, FileError> | undefined {\n\treturn signal?.aborted ? err(new FileError(\"aborted\", \"aborted\", path)) : undefined;\n}\n\nasync function pathExists(path: string): Promise<boolean> {\n\ttry {\n\t\tawait access(path, constants.F_OK);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\ninterface CommandProbeResult {\n\tstdout: string;\n\tstatus: number | null;\n}\n\nasync function runCommand(command: string, args: string[], timeoutMs: number): Promise<CommandProbeResult> {\n\treturn await new Promise((resolve) => {\n\t\tlet stdout = \"\";\n\t\tlet child: ReturnType<typeof spawn>;\n\t\ttry {\n\t\t\tchild = spawn(command, args, {\n\t\t\t\tstdio: [\"ignore\", \"pipe\", \"ignore\"],\n\t\t\t\twindowsHide: true,\n\t\t\t});\n\t\t} catch {\n\t\t\tresolve({ stdout: \"\", status: null });\n\t\t\treturn;\n\t\t}\n\t\tconst timeout = setTimeout(() => {\n\t\t\tif (child.pid) killProcessTree(child.pid);\n\t\t}, timeoutMs);\n\t\tchild.stdout?.setEncoding(\"utf8\");\n\t\tchild.stdout?.on(\"data\", (chunk: string) => {\n\t\t\tstdout = appendBoundedOutput(stdout, chunk);\n\t\t});\n\t\tchild.on(\"error\", () => {\n\t\t\tclearTimeout(timeout);\n\t\t\tresolve({ stdout: \"\", status: null });\n\t\t});\n\t\tchild.on(\"close\", (status) => {\n\t\t\tclearTimeout(timeout);\n\t\t\tresolve({ stdout, status });\n\t\t});\n\t});\n}\n\nasync function findBashOnPath(): Promise<string | null> {\n\tconst result =\n\t\tprocess.platform === \"win32\"\n\t\t\t? await runCommand(\"where\", [\"bash.exe\"], 5000)\n\t\t\t: await runCommand(\"which\", [\"bash\"], 5000);\n\tif (result.status !== 0 || !result.stdout) return null;\n\tconst firstMatch = result.stdout.trim().split(/\\r?\\n/)[0];\n\treturn firstMatch && (await pathExists(firstMatch)) ? firstMatch : null;\n}\n\nexport interface ShellConfig {\n\tshell: string;\n\targs: string[];\n}\n\nasync function getWindowsShellConfig(): Promise<Result<ShellConfig, ExecutionError>> {\n\tconst candidates: string[] = [];\n\tconst programFiles = process.env.ProgramFiles;\n\tif (programFiles) candidates.push(`${programFiles}\\\\Git\\\\bin\\\\bash.exe`);\n\tconst programFilesX86 = process.env[\"ProgramFiles(x86)\"];\n\tif (programFilesX86) candidates.push(`${programFilesX86}\\\\Git\\\\bin\\\\bash.exe`);\n\tfor (const candidate of candidates) {\n\t\tif (await pathExists(candidate)) return ok({ shell: candidate, args: [\"-c\"] });\n\t}\n\tconst bashOnPath = await findBashOnPath();\n\tif (bashOnPath) return ok({ shell: bashOnPath, args: [\"-c\"] });\n\treturn err(new ExecutionError(\"shell_unavailable\", \"No bash shell found\"));\n}\n\nasync function getPosixShellConfig(): Promise<Result<ShellConfig, ExecutionError>> {\n\tif (await pathExists(\"/bin/bash\")) return ok({ shell: \"/bin/bash\", args: [\"-c\"] });\n\tconst bashOnPath = await findBashOnPath();\n\treturn ok({ shell: bashOnPath ?? \"sh\", args: [\"-c\"] });\n}\n\nasync function getShellConfig(customShellPath?: string): Promise<Result<ShellConfig, ExecutionError>> {\n\tif (customShellPath) {\n\t\tif (await pathExists(customShellPath)) return ok({ shell: customShellPath, args: [\"-c\"] });\n\t\treturn err(new ExecutionError(\"shell_unavailable\", `Custom shell path not found: ${customShellPath}`));\n\t}\n\treturn process.platform === \"win32\" ? getWindowsShellConfig() : getPosixShellConfig();\n}\n\nfunction getShellEnv(baseEnv?: NodeJS.ProcessEnv, extraEnv?: Record<string, string>): NodeJS.ProcessEnv {\n\treturn {\n\t\t...process.env,\n\t\t...baseEnv,\n\t\t...extraEnv,\n\t};\n}\n\nfunction killProcessTree(pid: number): void {\n\tif (process.platform === \"win32\") {\n\t\ttry {\n\t\t\tspawn(\"taskkill\", [\"/F\", \"/T\", \"/PID\", String(pid)], {\n\t\t\t\tstdio: \"ignore\",\n\t\t\t\tdetached: true,\n\t\t\t\twindowsHide: true,\n\t\t\t});\n\t\t} catch {\n\t\t\t// Ignore errors.\n\t\t}\n\t\treturn;\n\t}\n\n\ttry {\n\t\tprocess.kill(-pid, \"SIGKILL\");\n\t} catch {\n\t\ttry {\n\t\t\tprocess.kill(pid, \"SIGKILL\");\n\t\t} catch {\n\t\t\t// Process already dead.\n\t\t}\n\t}\n}\n\nexport interface NodeExecutionEnvOptions {\n\tcwd: string;\n\tshellPath?: string;\n\tshellEnv?: NodeJS.ProcessEnv;\n}\n\nexport class NodeExecutionEnv implements ExecutionEnv {\n\tcwd: string;\n\tprivate shellPath?: string;\n\tprivate shellEnv?: NodeJS.ProcessEnv;\n\n\tconstructor(options: NodeExecutionEnvOptions) {\n\t\tthis.cwd = options.cwd;\n\t\tthis.shellPath = options.shellPath;\n\t\tthis.shellEnv = options.shellEnv;\n\t}\n\n\tasync absolutePath(path: string): Promise<Result<string, FileError>> {\n\t\treturn ok(resolvePath(this.cwd, path));\n\t}\n\n\tasync joinPath(parts: string[]): Promise<Result<string, FileError>> {\n\t\treturn ok(join(...parts));\n\t}\n\n\tasync exec(\n\t\tcommand: string,\n\t\toptions?: ExecutionEnvExecOptions,\n\t): Promise<Result<ExecutionEnvExecResult, ExecutionError>> {\n\t\tif (options?.abortSignal?.aborted) return err(new ExecutionError(\"aborted\", \"aborted\"));\n\t\tconst timeoutMsResult = resolveTimeoutMs(options?.timeout);\n\t\tif (!timeoutMsResult.ok) return err(timeoutMsResult.error);\n\t\tconst timeoutMs = timeoutMsResult.value;\n\n\t\tconst cwd = options?.cwd ? resolvePath(this.cwd, options.cwd) : this.cwd;\n\t\tconst shellConfig = await getShellConfig(this.shellPath);\n\t\tif (!shellConfig.ok) return shellConfig;\n\n\t\treturn await new Promise((resolvePromise) => {\n\t\t\tlet stdout = \"\";\n\t\t\tlet stderr = \"\";\n\t\t\tlet settled = false;\n\t\t\tlet timedOut = false;\n\t\t\tlet callbackError: ExecutionError | undefined;\n\t\t\tlet child: ReturnType<typeof spawn> | undefined;\n\t\t\tlet timeoutId: ReturnType<typeof setTimeout> | undefined;\n\n\t\t\tconst onAbort = () => {\n\t\t\t\tif (child?.pid) {\n\t\t\t\t\tkillProcessTree(child.pid);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst settle = (result: Result<ExecutionEnvExecResult, ExecutionError>) => {\n\t\t\t\tif (timeoutId) clearTimeout(timeoutId);\n\t\t\t\tif (options?.abortSignal) options.abortSignal.removeEventListener(\"abort\", onAbort);\n\t\t\t\tif (settled) return;\n\t\t\t\tsettled = true;\n\t\t\t\tresolvePromise(result);\n\t\t\t};\n\n\t\t\ttry {\n\t\t\t\tchild = spawn(shellConfig.value.shell, [...shellConfig.value.args, command], {\n\t\t\t\t\tcwd,\n\t\t\t\t\tdetached: process.platform !== \"win32\",\n\t\t\t\t\tenv: getShellEnv(this.shellEnv, options?.env),\n\t\t\t\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t\t\t\t\twindowsHide: true,\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tconst cause = toError(error);\n\t\t\t\tsettle(err(new ExecutionError(\"spawn_error\", cause.message, cause)));\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\ttimeoutId =\n\t\t\t\ttimeoutMs !== undefined\n\t\t\t\t\t? setTimeout(() => {\n\t\t\t\t\t\t\ttimedOut = true;\n\t\t\t\t\t\t\tif (child?.pid) {\n\t\t\t\t\t\t\t\tkillProcessTree(child.pid);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}, timeoutMs)\n\t\t\t\t\t: undefined;\n\n\t\t\tif (options?.abortSignal) {\n\t\t\t\tif (options.abortSignal.aborted) {\n\t\t\t\t\tonAbort();\n\t\t\t\t} else {\n\t\t\t\t\toptions.abortSignal.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tchild.stdout?.setEncoding(\"utf8\");\n\t\t\tchild.stderr?.setEncoding(\"utf8\");\n\t\t\tchild.stdout?.on(\"data\", (chunk: string) => {\n\t\t\t\tstdout = appendBoundedOutput(stdout, chunk);\n\t\t\t\ttry {\n\t\t\t\t\toptions?.onStdout?.(chunk);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst cause = toError(error);\n\t\t\t\t\tcallbackError = new ExecutionError(\"callback_error\", cause.message, cause);\n\t\t\t\t\tonAbort();\n\t\t\t\t}\n\t\t\t});\n\t\t\tchild.stderr?.on(\"data\", (chunk: string) => {\n\t\t\t\tstderr = appendBoundedOutput(stderr, chunk);\n\t\t\t\ttry {\n\t\t\t\t\toptions?.onStderr?.(chunk);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst cause = toError(error);\n\t\t\t\t\tcallbackError = new ExecutionError(\"callback_error\", cause.message, cause);\n\t\t\t\t\tonAbort();\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tchild.on(\"error\", (error) => {\n\t\t\t\tsettle(err(new ExecutionError(\"spawn_error\", error.message, error)));\n\t\t\t});\n\n\t\t\tchild.on(\"close\", (code) => {\n\t\t\t\tif (callbackError) {\n\t\t\t\t\tsettle(err(callbackError));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (timedOut) {\n\t\t\t\t\tsettle(err(new ExecutionError(\"timeout\", `timeout:${options?.timeout}`)));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (options?.abortSignal?.aborted) {\n\t\t\t\t\tsettle(err(new ExecutionError(\"aborted\", \"aborted\")));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tsettle(ok({ stdout, stderr, exitCode: code ?? 0 }));\n\t\t\t});\n\t\t});\n\t}\n\n\tasync readTextFile(path: string, abortSignal?: AbortSignal): Promise<Result<string, FileError>> {\n\t\tconst resolved = resolvePath(this.cwd, path);\n\t\tconst aborted = abortResult<string>(abortSignal, resolved);\n\t\tif (aborted) return aborted;\n\t\ttry {\n\t\t\treturn ok(await readFile(resolved, { encoding: \"utf8\", signal: abortSignal }));\n\t\t} catch (error) {\n\t\t\treturn err(toFileError(error, resolved));\n\t\t}\n\t}\n\n\tasync readTextLines(path: string, options?: ReadTextLinesOptions): Promise<Result<string[], FileError>> {\n\t\tconst resolved = resolvePath(this.cwd, path);\n\t\tconst aborted = abortResult<string[]>(options?.abortSignal, resolved);\n\t\tif (aborted) return aborted;\n\t\tif (options?.maxLines !== undefined && options.maxLines <= 0) return ok([]);\n\t\tlet stream: ReturnType<typeof createReadStream> | undefined;\n\t\tlet lineReader: ReturnType<typeof createInterface> | undefined;\n\t\ttry {\n\t\t\tstream = createReadStream(resolved, { encoding: \"utf8\", signal: options?.abortSignal });\n\t\t\tlineReader = createInterface({ input: stream, crlfDelay: Infinity });\n\t\t\tconst lines: string[] = [];\n\t\t\tfor await (const line of lineReader) {\n\t\t\t\tconst loopAbort = abortResult<string[]>(options?.abortSignal, resolved);\n\t\t\t\tif (loopAbort) return loopAbort;\n\t\t\t\tlines.push(line);\n\t\t\t\tif (options?.maxLines !== undefined && lines.length >= options.maxLines) break;\n\t\t\t}\n\t\t\tconst afterReadAbort = abortResult<string[]>(options?.abortSignal, resolved);\n\t\t\tif (afterReadAbort) return afterReadAbort;\n\t\t\treturn ok(lines);\n\t\t} catch (error) {\n\t\t\treturn err(toFileError(error, resolved));\n\t\t} finally {\n\t\t\tlineReader?.close();\n\t\t\tstream?.destroy();\n\t\t}\n\t}\n\n\tasync readBinaryFile(path: string, abortSignal?: AbortSignal): Promise<Result<Uint8Array, FileError>> {\n\t\tconst resolved = resolvePath(this.cwd, path);\n\t\tconst aborted = abortResult<Uint8Array>(abortSignal, resolved);\n\t\tif (aborted) return aborted;\n\t\ttry {\n\t\t\treturn ok(await readFile(resolved, { signal: abortSignal }));\n\t\t} catch (error) {\n\t\t\treturn err(toFileError(error, resolved));\n\t\t}\n\t}\n\n\tasync writeFile(\n\t\tpath: string,\n\t\tcontent: string | Uint8Array,\n\t\tabortSignal?: AbortSignal,\n\t): Promise<Result<void, FileError>> {\n\t\tconst resolved = resolvePath(this.cwd, path);\n\t\tconst aborted = abortResult<void>(abortSignal, resolved);\n\t\tif (aborted) return aborted;\n\t\ttry {\n\t\t\tawait mkdir(resolve(resolved, \"..\"), { recursive: true });\n\t\t\tconst afterMkdirAbort = abortResult<void>(abortSignal, resolved);\n\t\t\tif (afterMkdirAbort) return afterMkdirAbort;\n\t\t\tawait writeFile(resolved, content, { signal: abortSignal });\n\t\t\treturn ok(undefined);\n\t\t} catch (error) {\n\t\t\treturn err(toFileError(error, resolved));\n\t\t}\n\t}\n\n\tasync appendFile(path: string, content: string | Uint8Array): Promise<Result<void, FileError>> {\n\t\tconst resolved = resolvePath(this.cwd, path);\n\t\ttry {\n\t\t\tawait mkdir(resolve(resolved, \"..\"), { recursive: true });\n\t\t\tawait appendFile(resolved, content);\n\t\t\treturn ok(undefined);\n\t\t} catch (error) {\n\t\t\treturn err(toFileError(error, resolved));\n\t\t}\n\t}\n\n\tasync renameFile(source: string, destination: string, abortSignal?: AbortSignal): Promise<Result<void, FileError>> {\n\t\tconst resolvedSource = resolvePath(this.cwd, source);\n\t\tconst resolvedDestination = resolvePath(this.cwd, destination);\n\t\tfor (let attempt = 0; attempt < 5; attempt++) {\n\t\t\tconst aborted = abortResult<void>(abortSignal, resolvedDestination);\n\t\t\tif (aborted) return aborted;\n\t\t\ttry {\n\t\t\t\tawait rename(resolvedSource, resolvedDestination);\n\t\t\t\treturn ok(undefined);\n\t\t\t} catch (error) {\n\t\t\t\tif (process.platform !== \"win32\" || !isWindowsRenameSharingError(error) || attempt === 4) {\n\t\t\t\t\treturn err(toFileError(error, nodeErrorPath(error, resolvedDestination)));\n\t\t\t\t}\n\t\t\t\tif (!(await waitForRenameRetry(10 * 2 ** attempt, abortSignal))) {\n\t\t\t\t\treturn err(new FileError(\"aborted\", \"aborted\", resolvedDestination));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn err(new FileError(\"unknown\", \"rename failed\", resolvedDestination));\n\t}\n\n\tasync fileInfo(path: string): Promise<Result<FileInfo, FileError>> {\n\t\tconst resolved = resolvePath(this.cwd, path);\n\t\ttry {\n\t\t\treturn fileInfoFromStats(resolved, await lstat(resolved));\n\t\t} catch (error) {\n\t\t\treturn err(toFileError(error, resolved));\n\t\t}\n\t}\n\n\tasync listDir(path: string, abortSignal?: AbortSignal): Promise<Result<FileInfo[], FileError>> {\n\t\tconst resolved = resolvePath(this.cwd, path);\n\t\tconst aborted = abortResult<FileInfo[]>(abortSignal, resolved);\n\t\tif (aborted) return aborted;\n\t\ttry {\n\t\t\tconst entries = await readdir(resolved, { withFileTypes: true });\n\t\t\tconst infos: FileInfo[] = [];\n\t\t\tfor (const entry of entries) {\n\t\t\t\tconst loopAbort = abortResult<FileInfo[]>(abortSignal, resolved);\n\t\t\t\tif (loopAbort) return loopAbort;\n\t\t\t\tconst entryPath = resolve(resolved, entry.name);\n\t\t\t\ttry {\n\t\t\t\t\tconst info = fileInfoFromStats(entryPath, await lstat(entryPath));\n\t\t\t\t\tif (info.ok) infos.push(info.value);\n\t\t\t\t} catch (error) {\n\t\t\t\t\treturn err(toFileError(error, entryPath));\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn ok(infos);\n\t\t} catch (error) {\n\t\t\treturn err(toFileError(error, resolved));\n\t\t}\n\t}\n\n\tasync canonicalPath(path: string): Promise<Result<string, FileError>> {\n\t\tconst resolved = resolvePath(this.cwd, path);\n\t\ttry {\n\t\t\treturn ok(await realpath(resolved));\n\t\t} catch (error) {\n\t\t\treturn err(toFileError(error, resolved));\n\t\t}\n\t}\n\n\tasync exists(path: string): Promise<Result<boolean, FileError>> {\n\t\tconst result = await this.fileInfo(path);\n\t\tif (result.ok) return ok(true);\n\t\tif (result.error.code === \"not_found\") return ok(false);\n\t\treturn err(result.error);\n\t}\n\n\tasync createDir(path: string, options?: CreateDirOptions): Promise<Result<void, FileError>> {\n\t\tconst resolved = resolvePath(this.cwd, path);\n\t\ttry {\n\t\t\tawait mkdir(resolved, { recursive: options?.recursive ?? true });\n\t\t\treturn ok(undefined);\n\t\t} catch (error) {\n\t\t\treturn err(toFileError(error, resolved));\n\t\t}\n\t}\n\n\tasync remove(path: string, options?: RemovePathOptions): Promise<Result<void, FileError>> {\n\t\tconst resolved = resolvePath(this.cwd, path);\n\t\ttry {\n\t\t\tawait rm(resolved, { recursive: options?.recursive ?? false, force: options?.force ?? false });\n\t\t\treturn ok(undefined);\n\t\t} catch (error) {\n\t\t\treturn err(toFileError(error, resolved));\n\t\t}\n\t}\n\n\tasync createTempDir(prefix: string = \"tmp-\"): Promise<Result<string, FileError>> {\n\t\ttry {\n\t\t\treturn ok(await mkdtemp(join(tmpdir(), prefix)));\n\t\t} catch (error) {\n\t\t\treturn err(toFileError(error));\n\t\t}\n\t}\n\n\tasync createTempFile(options?: CreateTempFileOptions): Promise<Result<string, FileError>> {\n\t\tconst dir = await this.createTempDir(\"tmp-\");\n\t\tif (!dir.ok) return dir;\n\t\tconst filePath = join(dir.value, `${options?.prefix ?? \"\"}${randomUUID()}${options?.suffix ?? \"\"}`);\n\t\ttry {\n\t\t\tawait writeFile(filePath, \"\");\n\t\t\treturn ok(filePath);\n\t\t} catch (error) {\n\t\t\treturn err(toFileError(error, filePath));\n\t\t}\n\t}\n\n\tasync cleanup(): Promise<void> {\n\t\t// nothing to clean up for the local node implementation\n\t}\n}\n"]}
@@ -1 +1 @@
1
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,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CAClB;AAED,OAAO,QAAQ,aAAa,CAAC,CAAC;IAC7B,UAAU,mBAAmB;QAC5B,aAAa,EAAE,oBAAoB,CAAC;QACpC,MAAM,EAAE,aAAa,CAAC;QACtB,aAAa,EAAE,oBAAoB,CAAC;QACpC,iBAAiB,EAAE,wBAAwB,CAAC;KAC5C;CACD;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,oBAAoB,GAAG,MAAM,CAgBrE;AAED,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,oBAAoB,CAOnH;AAED,wBAAgB,8BAA8B,CAC7C,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,GACf,wBAAwB,CAO1B;AAED,wBAAgB,mBAAmB,CAClC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,GAAG,CAAC,WAAW,GAAG,YAAY,CAAC,EAAE,EAChD,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,GAAG,SAAS,EAC5B,SAAS,EAAE,MAAM,GACf,aAAa,CASf;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,YAAY,EAAE,GAAG,OAAO,EAAE,CA4ChE","sourcesContent":["import type { ImageContent, Message, TextContent } from \"@greppleai/grip-ai\";\nimport type { AgentMessage } from \"../types.ts\";\n\nexport const COMPACTION_SUMMARY_PREFIX = `The conversation history before this point was compacted into the following summary:\n\n<summary>\n`;\n\nexport const COMPACTION_SUMMARY_SUFFIX = `\n</summary>`;\n\nexport const BRANCH_SUMMARY_PREFIX = `The following is a summary of a branch that this conversation came back from:\n\n<summary>\n`;\n\nexport const BRANCH_SUMMARY_SUFFIX = `</summary>`;\n\nexport interface BashExecutionMessage {\n\trole: \"bashExecution\";\n\tcommand: string;\n\toutput: string;\n\texitCode: number | undefined;\n\tcancelled: boolean;\n\ttruncated: boolean;\n\tfullOutputPath?: string;\n\ttimestamp: number;\n\texcludeFromContext?: boolean;\n}\n\nexport interface CustomMessage<T = unknown> {\n\trole: \"custom\";\n\tcustomType: string;\n\tcontent: string | (TextContent | ImageContent)[];\n\tdisplay: boolean;\n\tdetails?: T;\n\ttimestamp: number;\n}\n\nexport interface BranchSummaryMessage {\n\trole: \"branchSummary\";\n\tsummary: string;\n\tfromId: string;\n\ttimestamp: number;\n}\n\nexport interface CompactionSummaryMessage {\n\trole: \"compactionSummary\";\n\tsummary: string;\n\ttokensBefore: number;\n\ttimestamp: number;\n}\n\ndeclare module \"../types.ts\" {\n\tinterface CustomAgentMessages {\n\t\tbashExecution: BashExecutionMessage;\n\t\tcustom: CustomMessage;\n\t\tbranchSummary: BranchSummaryMessage;\n\t\tcompactionSummary: CompactionSummaryMessage;\n\t}\n}\n\nexport function bashExecutionToText(msg: BashExecutionMessage): string {\n\tlet text = `Ran \\`${msg.command}\\`\\n`;\n\tif (msg.output) {\n\t\ttext += `\\`\\`\\`\\n${msg.output}\\n\\`\\`\\``;\n\t} else {\n\t\ttext += \"(no output)\";\n\t}\n\tif (msg.cancelled) {\n\t\ttext += \"\\n\\n(command cancelled)\";\n\t} else if (msg.exitCode !== null && msg.exitCode !== undefined && msg.exitCode !== 0) {\n\t\ttext += `\\n\\nCommand exited with code ${msg.exitCode}`;\n\t}\n\tif (msg.truncated && msg.fullOutputPath) {\n\t\ttext += `\\n\\n[Output truncated. Full output: ${msg.fullOutputPath}]`;\n\t}\n\treturn text;\n}\n\nexport function createBranchSummaryMessage(summary: string, fromId: string, timestamp: string): BranchSummaryMessage {\n\treturn {\n\t\trole: \"branchSummary\",\n\t\tsummary,\n\t\tfromId,\n\t\ttimestamp: new Date(timestamp).getTime(),\n\t};\n}\n\nexport function createCompactionSummaryMessage(\n\tsummary: string,\n\ttokensBefore: number,\n\ttimestamp: string,\n): CompactionSummaryMessage {\n\treturn {\n\t\trole: \"compactionSummary\",\n\t\tsummary,\n\t\ttokensBefore,\n\t\ttimestamp: new Date(timestamp).getTime(),\n\t};\n}\n\nexport function createCustomMessage(\n\tcustomType: string,\n\tcontent: string | (TextContent | ImageContent)[],\n\tdisplay: boolean,\n\tdetails: unknown | undefined,\n\ttimestamp: string,\n): CustomMessage {\n\treturn {\n\t\trole: \"custom\",\n\t\tcustomType,\n\t\tcontent,\n\t\tdisplay,\n\t\tdetails,\n\t\ttimestamp: new Date(timestamp).getTime(),\n\t};\n}\n\nexport function convertToLlm(messages: AgentMessage[]): Message[] {\n\treturn messages\n\t\t.map((m): Message | undefined => {\n\t\t\tswitch (m.role) {\n\t\t\t\tcase \"bashExecution\":\n\t\t\t\t\tif (m.excludeFromContext) {\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\trole: \"user\",\n\t\t\t\t\t\tcontent: [{ type: \"text\", text: bashExecutionToText(m) }],\n\t\t\t\t\t\ttimestamp: m.timestamp,\n\t\t\t\t\t};\n\t\t\t\tcase \"custom\": {\n\t\t\t\t\tconst content = typeof m.content === \"string\" ? [{ type: \"text\" as const, text: m.content }] : m.content;\n\t\t\t\t\treturn {\n\t\t\t\t\t\trole: \"user\",\n\t\t\t\t\t\tcontent,\n\t\t\t\t\t\ttimestamp: m.timestamp,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tcase \"branchSummary\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\trole: \"user\",\n\t\t\t\t\t\tcontent: [{ type: \"text\" as const, text: BRANCH_SUMMARY_PREFIX + m.summary + BRANCH_SUMMARY_SUFFIX }],\n\t\t\t\t\t\ttimestamp: m.timestamp,\n\t\t\t\t\t};\n\t\t\t\tcase \"compactionSummary\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\trole: \"user\",\n\t\t\t\t\t\tcontent: [\n\t\t\t\t\t\t\t{ type: \"text\" as const, text: COMPACTION_SUMMARY_PREFIX + m.summary + COMPACTION_SUMMARY_SUFFIX },\n\t\t\t\t\t\t],\n\t\t\t\t\t\ttimestamp: m.timestamp,\n\t\t\t\t\t};\n\t\t\t\tcase \"user\":\n\t\t\t\tcase \"assistant\":\n\t\t\t\tcase \"toolResult\":\n\t\t\t\t\treturn m;\n\t\t\t\tdefault:\n\t\t\t\t\treturn undefined;\n\t\t\t}\n\t\t})\n\t\t.filter((m): m is Message => m !== undefined);\n}\n"]}
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/harness/messages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,eAAO,MAAM,yBAAyB,wGAGrC,CAAC;AAEF,eAAO,MAAM,yBAAyB,iBAC3B,CAAC;AAEZ,eAAO,MAAM,qBAAqB,iGAGjC,CAAC;AAEF,eAAO,MAAM,qBAAqB,eAAe,CAAC;AAElD,MAAM,WAAW,oBAAoB;IACpC,IAAI,EAAE,eAAe,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,WAAW,aAAa,CAAC,CAAC,GAAG,OAAO;IACzC,IAAI,EAAE,QAAQ,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,GAAG,CAAC,WAAW,GAAG,YAAY,CAAC,EAAE,CAAC;IACjD,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,CAAC,CAAC;IACZ,SAAS,EAAE,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AE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,qBAAqB,GAAG,CAAC,CAAC,OAAO,GAAG,qBAAqB,EAAE,CAAC;oBACrG,SAAS,EAAE,CAAC,CAAC,SAAS;iBACtB,CAAC;YACH,KAAK,mBAAmB;gBACvB,OAAO;oBACN,IAAI,EAAE,MAAM;oBACZ,OAAO,EAAE;wBACR,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,yBAAyB,GAAG,CAAC,CAAC,OAAO,GAAG,yBAAyB,EAAE;qBAClG;oBACD,SAAS,EAAE,CAAC,CAAC,SAAS;iBACtB,CAAC;YACH,KAAK,MAAM,CAAC;YACZ,KAAK,WAAW,CAAC;YACjB,KAAK,YAAY;gBAChB,OAAO,CAAC,CAAC;YACV;gBACC,OAAO,SAAS,CAAC;QACnB,CAAC;IAAA,CACD,CAAC;SACD,MAAM,CAAC,CAAC,CAAC,EAAgB,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC;AAAA,CAC/C","sourcesContent":["import type { ImageContent, Message, TextContent } from \"@greppleai/grip-ai\";\nimport type { AgentMessage } from \"../types.ts\";\n\nexport const COMPACTION_SUMMARY_PREFIX = `The conversation history before this point was compacted into the following summary:\n\n<summary>\n`;\n\nexport const COMPACTION_SUMMARY_SUFFIX = `\n</summary>`;\n\nexport const BRANCH_SUMMARY_PREFIX = `The following is a summary of a branch that this conversation came back from:\n\n<summary>\n`;\n\nexport const BRANCH_SUMMARY_SUFFIX = `</summary>`;\n\nexport interface BashExecutionMessage {\n\trole: \"bashExecution\";\n\tcommand: string;\n\toutput: string;\n\texitCode: number | undefined;\n\tcancelled: boolean;\n\ttruncated: boolean;\n\tfullOutputPath?: string;\n\ttimestamp: number;\n\texcludeFromContext?: boolean;\n}\n\nexport interface CustomMessage<T = unknown> {\n\trole: \"custom\";\n\tcustomType: string;\n\tcontent: string | (TextContent | ImageContent)[];\n\tdisplay: boolean;\n\tdetails?: T;\n\ttimestamp: number;\n}\n\nexport interface BranchSummaryMessage {\n\trole: \"branchSummary\";\n\tsummary: string;\n\tfromId: string;\n\ttimestamp: number;\n}\n\nexport interface CompactionSummaryMessage {\n\trole: \"compactionSummary\";\n\tsummary: string;\n\ttokensBefore: number;\n\ttimestamp: number;\n}\n\ndeclare module \"../types.ts\" {\n\tinterface CustomAgentMessages {\n\t\tbashExecution: BashExecutionMessage;\n\t\tcustom: CustomMessage;\n\t\tbranchSummary: BranchSummaryMessage;\n\t\tcompactionSummary: CompactionSummaryMessage;\n\t}\n}\n\nexport function bashExecutionToText(msg: BashExecutionMessage): string {\n\tlet text = `Ran \\`${msg.command}\\`\\n`;\n\tif (msg.output) {\n\t\ttext += `\\`\\`\\`\\n${msg.output}\\n\\`\\`\\``;\n\t} else {\n\t\ttext += \"(no output)\";\n\t}\n\tif (msg.cancelled) {\n\t\ttext += \"\\n\\n(command cancelled)\";\n\t} else if (msg.exitCode !== null && msg.exitCode !== undefined && msg.exitCode !== 0) {\n\t\ttext += `\\n\\nCommand exited with code ${msg.exitCode}`;\n\t}\n\tif (msg.truncated && msg.fullOutputPath) {\n\t\ttext += `\\n\\n[Output truncated. Full output: ${msg.fullOutputPath}]`;\n\t}\n\treturn text;\n}\n\nexport function createBranchSummaryMessage(summary: string, fromId: string, timestamp: string): BranchSummaryMessage {\n\treturn {\n\t\trole: \"branchSummary\",\n\t\tsummary,\n\t\tfromId,\n\t\ttimestamp: new Date(timestamp).getTime(),\n\t};\n}\n\nexport function createCompactionSummaryMessage(\n\tsummary: string,\n\ttokensBefore: number,\n\ttimestamp: string,\n): CompactionSummaryMessage {\n\treturn {\n\t\trole: \"compactionSummary\",\n\t\tsummary,\n\t\ttokensBefore,\n\t\ttimestamp: new Date(timestamp).getTime(),\n\t};\n}\n\nexport function createCustomMessage(\n\tcustomType: string,\n\tcontent: string | (TextContent | ImageContent)[],\n\tdisplay: boolean,\n\tdetails: unknown | undefined,\n\ttimestamp: string,\n): CustomMessage {\n\treturn {\n\t\trole: \"custom\",\n\t\tcustomType,\n\t\tcontent,\n\t\tdisplay,\n\t\tdetails,\n\t\ttimestamp: new Date(timestamp).getTime(),\n\t};\n}\n\nexport function convertToLlm(messages: AgentMessage[]): Message[] {\n\treturn messages\n\t\t.map((m): Message | undefined => {\n\t\t\tswitch (m.role) {\n\t\t\t\tcase \"bashExecution\":\n\t\t\t\t\tif (m.excludeFromContext) {\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\trole: \"user\",\n\t\t\t\t\t\tcontent: [{ type: \"text\", text: bashExecutionToText(m) }],\n\t\t\t\t\t\ttimestamp: m.timestamp,\n\t\t\t\t\t};\n\t\t\t\tcase \"custom\": {\n\t\t\t\t\tconst content = typeof m.content === \"string\" ? [{ type: \"text\" as const, text: m.content }] : m.content;\n\t\t\t\t\treturn {\n\t\t\t\t\t\trole: \"user\",\n\t\t\t\t\t\tcontent,\n\t\t\t\t\t\ttimestamp: m.timestamp,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tcase \"branchSummary\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\trole: \"user\",\n\t\t\t\t\t\tcontent: [{ type: \"text\" as const, text: BRANCH_SUMMARY_PREFIX + m.summary + BRANCH_SUMMARY_SUFFIX }],\n\t\t\t\t\t\ttimestamp: m.timestamp,\n\t\t\t\t\t};\n\t\t\t\tcase \"compactionSummary\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\trole: \"user\",\n\t\t\t\t\t\tcontent: [\n\t\t\t\t\t\t\t{ type: \"text\" as const, text: COMPACTION_SUMMARY_PREFIX + m.summary + COMPACTION_SUMMARY_SUFFIX },\n\t\t\t\t\t\t],\n\t\t\t\t\t\ttimestamp: m.timestamp,\n\t\t\t\t\t};\n\t\t\t\tcase \"user\":\n\t\t\t\tcase \"assistant\":\n\t\t\t\tcase \"toolResult\":\n\t\t\t\t\treturn m;\n\t\t\t\tdefault:\n\t\t\t\t\treturn undefined;\n\t\t\t}\n\t\t})\n\t\t.filter((m): m is Message => m !== undefined);\n}\n"]}
1
+ {"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/harness/messages.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,yBAAyB,GAAG;;;CAGxC,CAAC;AAEF,MAAM,CAAC,MAAM,yBAAyB,GAAG;WAC9B,CAAC;AAEZ,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;CAGpC,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,YAAY,CAAC;AA8ClD,MAAM,UAAU,mBAAmB,CAAC,GAAyB;IAC5D,IAAI,IAAI,GAAG,SAAS,GAAG,CAAC,OAAO,MAAM,CAAC;IACtC,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC;QAChB,IAAI,IAAI,WAAW,GAAG,CAAC,MAAM,UAAU,CAAC;IACzC,CAAC;SAAM,CAAC;QACP,IAAI,IAAI,aAAa,CAAC;IACvB,CAAC;IACD,IAAI,GAAG,CAAC,SAAS,EAAE,CAAC;QACnB,IAAI,IAAI,yBAAyB,CAAC;IACnC,CAAC;SAAM,IAAI,GAAG,CAAC,QAAQ,KAAK,IAAI,IAAI,GAAG,CAAC,QAAQ,KAAK,SAAS,IAAI,GAAG,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;QACtF,IAAI,IAAI,gCAAgC,GAAG,CAAC,QAAQ,EAAE,CAAC;IACxD,CAAC;IACD,IAAI,GAAG,CAAC,SAAS,IAAI,GAAG,CAAC,cAAc,EAAE,CAAC;QACzC,IAAI,IAAI,uCAAuC,GAAG,CAAC,cAAc,GAAG,CAAC;IACtE,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,OAAe,EAAE,MAAc,EAAE,SAAiB;IAC5F,OAAO;QACN,IAAI,EAAE,eAAe;QACrB,OAAO;QACP,MAAM;QACN,SAAS,EAAE,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE;KACxC,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C,CAAC,SAAS;iBACtB,CAAC;YACH,CAAC;YACD,KAAK,eAAe;gBACnB,OAAO;oBACN,IAAI,EAAE,MAAM;oBACZ,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,qBAAqB,GAAG,CAAC,CAAC,OAAO,GAAG,qBAAqB,EAAE,CAAC;oBACrG,SAAS,EAAE,CAAC,CAAC,SAAS;iBACtB,CAAC;YACH,KAAK,mBAAmB;gBACvB,OAAO;oBACN,IAAI,EAAE,MAAM;oBACZ,OAAO,EAAE;wBACR,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,yBAAyB,GAAG,CAAC,CAAC,OAAO,GAAG,yBAAyB,EAAE;qBAClG;oBACD,SAAS,EAAE,CAAC,CAAC,SAAS;iBACtB,CAAC;YACH,KAAK,MAAM,CAAC;YACZ,KAAK,WAAW,CAAC;YACjB,KAAK,YAAY;gBAChB,OAAO,CAAC,CAAC;YACV;gBACC,OAAO,SAAS,CAAC;QACnB,CAAC;IACF,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,CAAC,EAAgB,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC;AAChD,CAAC","sourcesContent":["import type { ImageContent, Message, TextContent } from \"@greppleai/grip-ai\";\nimport type { AgentMessage } from \"../types.ts\";\n\nexport const COMPACTION_SUMMARY_PREFIX = `The conversation history before this point was compacted into the following summary:\n\n<summary>\n`;\n\nexport const COMPACTION_SUMMARY_SUFFIX = `\n</summary>`;\n\nexport const BRANCH_SUMMARY_PREFIX = `The following is a summary of a branch that this conversation came back from:\n\n<summary>\n`;\n\nexport const BRANCH_SUMMARY_SUFFIX = `</summary>`;\n\nexport interface BashExecutionMessage {\n\trole: \"bashExecution\";\n\tcommand: string;\n\toutput: string;\n\texitCode: number | undefined;\n\tcancelled: boolean;\n\ttruncated: boolean;\n\tfullOutputPath?: string;\n\ttimestamp: number;\n\texcludeFromContext?: boolean;\n}\n\nexport interface CustomMessage<T = unknown> {\n\trole: \"custom\";\n\tcustomType: string;\n\tcontent: string | (TextContent | ImageContent)[];\n\tdisplay: boolean;\n\tdetails?: T;\n\ttimestamp: number;\n}\n\nexport interface BranchSummaryMessage {\n\trole: \"branchSummary\";\n\tsummary: string;\n\tfromId: string;\n\ttimestamp: number;\n}\n\nexport interface CompactionSummaryMessage {\n\trole: \"compactionSummary\";\n\tsummary: string;\n\ttokensBefore: number;\n\ttimestamp: number;\n}\n\ndeclare module \"../types.ts\" {\n\tinterface CustomAgentMessages {\n\t\tbashExecution: BashExecutionMessage;\n\t\tcustom: CustomMessage;\n\t\tbranchSummary: BranchSummaryMessage;\n\t\tcompactionSummary: CompactionSummaryMessage;\n\t}\n}\n\nexport function bashExecutionToText(msg: BashExecutionMessage): string {\n\tlet text = `Ran \\`${msg.command}\\`\\n`;\n\tif (msg.output) {\n\t\ttext += `\\`\\`\\`\\n${msg.output}\\n\\`\\`\\``;\n\t} else {\n\t\ttext += \"(no output)\";\n\t}\n\tif (msg.cancelled) {\n\t\ttext += \"\\n\\n(command cancelled)\";\n\t} else if (msg.exitCode !== null && msg.exitCode !== undefined && msg.exitCode !== 0) {\n\t\ttext += `\\n\\nCommand exited with code ${msg.exitCode}`;\n\t}\n\tif (msg.truncated && msg.fullOutputPath) {\n\t\ttext += `\\n\\n[Output truncated. Full output: ${msg.fullOutputPath}]`;\n\t}\n\treturn text;\n}\n\nexport function createBranchSummaryMessage(summary: string, fromId: string, timestamp: string): BranchSummaryMessage {\n\treturn {\n\t\trole: \"branchSummary\",\n\t\tsummary,\n\t\tfromId,\n\t\ttimestamp: new Date(timestamp).getTime(),\n\t};\n}\n\nexport function createCompactionSummaryMessage(\n\tsummary: string,\n\ttokensBefore: number,\n\ttimestamp: string,\n): CompactionSummaryMessage {\n\treturn {\n\t\trole: \"compactionSummary\",\n\t\tsummary,\n\t\ttokensBefore,\n\t\ttimestamp: new Date(timestamp).getTime(),\n\t};\n}\n\nexport function createCustomMessage(\n\tcustomType: string,\n\tcontent: string | (TextContent | ImageContent)[],\n\tdisplay: boolean,\n\tdetails: unknown | undefined,\n\ttimestamp: string,\n): CustomMessage {\n\treturn {\n\t\trole: \"custom\",\n\t\tcustomType,\n\t\tcontent,\n\t\tdisplay,\n\t\tdetails,\n\t\ttimestamp: new Date(timestamp).getTime(),\n\t};\n}\n\nexport function convertToLlm(messages: AgentMessage[]): Message[] {\n\treturn messages\n\t\t.map((m): Message | undefined => {\n\t\t\tswitch (m.role) {\n\t\t\t\tcase \"bashExecution\":\n\t\t\t\t\tif (m.excludeFromContext) {\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\trole: \"user\",\n\t\t\t\t\t\tcontent: [{ type: \"text\", text: bashExecutionToText(m) }],\n\t\t\t\t\t\ttimestamp: m.timestamp,\n\t\t\t\t\t};\n\t\t\t\tcase \"custom\": {\n\t\t\t\t\tconst content = typeof m.content === \"string\" ? [{ type: \"text\" as const, text: m.content }] : m.content;\n\t\t\t\t\treturn {\n\t\t\t\t\t\trole: \"user\",\n\t\t\t\t\t\tcontent,\n\t\t\t\t\t\ttimestamp: m.timestamp,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tcase \"branchSummary\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\trole: \"user\",\n\t\t\t\t\t\tcontent: [{ type: \"text\" as const, text: BRANCH_SUMMARY_PREFIX + m.summary + BRANCH_SUMMARY_SUFFIX }],\n\t\t\t\t\t\ttimestamp: m.timestamp,\n\t\t\t\t\t};\n\t\t\t\tcase \"compactionSummary\":\n\t\t\t\t\treturn {\n\t\t\t\t\t\trole: \"user\",\n\t\t\t\t\t\tcontent: [\n\t\t\t\t\t\t\t{ type: \"text\" as const, text: COMPACTION_SUMMARY_PREFIX + m.summary + COMPACTION_SUMMARY_SUFFIX },\n\t\t\t\t\t\t],\n\t\t\t\t\t\ttimestamp: m.timestamp,\n\t\t\t\t\t};\n\t\t\t\tcase \"user\":\n\t\t\t\tcase \"assistant\":\n\t\t\t\tcase \"toolResult\":\n\t\t\t\t\treturn m;\n\t\t\t\tdefault:\n\t\t\t\t\treturn undefined;\n\t\t\t}\n\t\t})\n\t\t.filter((m): m is Message => m !== undefined);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"prompt-templates.d.ts","sourceRoot":"","sources":["../../src/harness/prompt-templates.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,YAAY,EAGjB,KAAK,cAAc,EAGnB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,4BAA4B,GAAG,kBAAkB,GAAG,aAAa,GAAG,aAAa,GAAG,cAAc,CAAC;AAG/G,uDAAuD;AACvD,MAAM,WAAW,wBAAwB;IACxC,gEAAgE;IAChE,IAAI,EAAE,SAAS,CAAC;IAChB,8BAA8B;IAC9B,IAAI,EAAE,4BAA4B,CAAC;IACnC,yCAAyC;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;CACb;AAED,+EAA+E;AAC/E,MAAM,WAAW,wBAAwB;IACxC,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,WAAW,EAAE,wBAAwB,EAAE,CAAC;CACxC;AAED,iEAAiE;AACjE,MAAM,WAAW,yBAAyB,CAAC,OAAO;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;CAChB;AAiBD,MAAM,WAAW,qBAAqB,CAAC,OAAO,EAAE,eAAe,SAAS,cAAc;IACrF,cAAc,EAAE,eAAe,CAAC;IAChC,MAAM,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,MAAM,+BAA+B,CAAC,OAAO,IAAI,wBAAwB,GAAG;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC;AAEtG,yEAAyE;AACzE,MAAM,WAAW,+BAA+B,CAAC,OAAO,EAAE,eAAe,SAAS,cAAc;IAC/F,eAAe,EAAE,qBAAqB,CAAC,OAAO,EAAE,eAAe,CAAC,EAAE,CAAC;IACnE,WAAW,EAAE,+BAA+B,CAAC,OAAO,CAAC,EAAE,CAAC;CACxD;AAaD;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACxC,GAAG,EAAE,YAAY,EACjB,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GACtB,OAAO,CAAC,wBAAwB,CAAC,CAsBnC;AAED;;;;;GAKG;AACH,wBAAsB,0BAA0B,CAAC,OAAO,EAAE,eAAe,SAAS,cAAc,GAAG,cAAc,EAChH,GAAG,EAAE,YAAY,EACjB,MAAM,EAAE,KAAK,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC,EACjD,iBAAiB,CAAC,EAAE,CAAC,cAAc,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,KAAK,eAAe,GACtF,OAAO,CAAC,+BAA+B,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC,CAgBpE;AA2GD,kFAAkF;AAClF,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAuB7D;AAED,uHAAuH;AACvH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAatE;AAED,qEAAqE;AACrE,wBAAgB,8BAA8B,CAAC,QAAQ,EAAE,cAAc,EAAE,IAAI,GAAE,MAAM,EAAO,GAAG,MAAM,CAEpG","sourcesContent":["import { parse } from \"yaml\";\nimport {\n\ttype ExecutionEnv,\n\ttype FileError,\n\ttype FileInfo,\n\ttype PromptTemplate,\n\ttype Result,\n\ttoError,\n} from \"./types.ts\";\n\nexport type PromptTemplateDiagnosticCode = \"file_info_failed\" | \"list_failed\" | \"read_failed\" | \"parse_failed\";\ntype PromptTemplatePathKind = \"file\" | \"directory\";\n\n/** Warning produced while loading prompt templates. */\nexport interface PromptTemplateDiagnostic {\n\t/** Diagnostic severity. Currently only warnings are emitted. */\n\ttype: \"warning\";\n\t/** Stable diagnostic code. */\n\tcode: PromptTemplateDiagnosticCode;\n\t/** Human-readable diagnostic message. */\n\tmessage: string;\n\t/** Path associated with the diagnostic. */\n\tpath: string;\n}\n\n/** Prompt templates loaded from a path together with non-fatal diagnostics. */\nexport interface PromptTemplateLoadResult {\n\tpromptTemplates: PromptTemplate[];\n\tdiagnostics: PromptTemplateDiagnostic[];\n}\n\n/** Path and provenance used to load sourced prompt templates. */\nexport interface SourcedPromptTemplatePath<TSource> {\n\tpath: string;\n\tsource: TSource;\n}\n\ninterface PromptTemplateFileLoadResult {\n\tpromptTemplate: PromptTemplate | null;\n\tdiagnostics: PromptTemplateDiagnostic[];\n}\n\nfunction appendFileInfoDiagnostic(diagnostics: PromptTemplateDiagnostic[], error: FileError, path: string): void {\n\tif (error.code === \"not_found\") return;\n\tdiagnostics.push({\n\t\ttype: \"warning\",\n\t\tcode: \"file_info_failed\",\n\t\tmessage: error.message,\n\t\tpath,\n\t});\n}\n\nexport interface SourcedPromptTemplate<TSource, TPromptTemplate extends PromptTemplate> {\n\tpromptTemplate: TPromptTemplate;\n\tsource: TSource;\n}\n\nexport type SourcedPromptTemplateDiagnostic<TSource> = PromptTemplateDiagnostic & { source: TSource };\n\n/** Source-tagged prompt templates and diagnostics produced by a load. */\nexport interface SourcedPromptTemplateLoadResult<TSource, TPromptTemplate extends PromptTemplate> {\n\tpromptTemplates: SourcedPromptTemplate<TSource, TPromptTemplate>[];\n\tdiagnostics: SourcedPromptTemplateDiagnostic<TSource>[];\n}\n\ninterface PromptTemplateFrontmatter {\n\tdescription?: string;\n\t\"argument-hint\"?: string;\n\t[key: string]: unknown;\n}\n\ninterface ParsedFrontmatter<T> {\n\tfrontmatter: T;\n\tbody: string;\n}\n\n/**\n * Load prompt templates from one or more paths.\n *\n * Directory inputs load direct `.md` children non-recursively. File inputs load explicit `.md` files. Missing paths and\n * non-markdown files are skipped. Read and parse failures are returned as diagnostics.\n */\nexport async function loadPromptTemplates(\n\tenv: ExecutionEnv,\n\tpaths: string | string[],\n): Promise<PromptTemplateLoadResult> {\n\tconst promptTemplates: PromptTemplate[] = [];\n\tconst diagnostics: PromptTemplateDiagnostic[] = [];\n\tfor (const path of Array.isArray(paths) ? paths : [paths]) {\n\t\tconst infoResult = await env.fileInfo(path);\n\t\tif (!infoResult.ok) {\n\t\t\tappendFileInfoDiagnostic(diagnostics, infoResult.error, path);\n\t\t\tcontinue;\n\t\t}\n\t\tconst info = infoResult.value;\n\t\tconst kind = await resolveKind(env, info, diagnostics);\n\t\tif (kind === \"directory\") {\n\t\t\tconst result = await loadTemplatesFromDir(env, info.path);\n\t\t\tpromptTemplates.push(...result.promptTemplates);\n\t\t\tdiagnostics.push(...result.diagnostics);\n\t\t} else if (kind === \"file\" && info.name.endsWith(\".md\")) {\n\t\t\tconst result = await loadTemplateFromFile(env, info.path);\n\t\t\tif (result.promptTemplate) promptTemplates.push(result.promptTemplate);\n\t\t\tdiagnostics.push(...result.diagnostics);\n\t\t}\n\t}\n\treturn { promptTemplates, diagnostics };\n}\n\n/**\n * Load prompt templates from source-tagged paths.\n *\n * Source values are preserved exactly and attached to every loaded prompt template and diagnostic. The agent package does\n * not interpret source values; applications define their own provenance shape.\n */\nexport async function loadSourcedPromptTemplates<TSource, TPromptTemplate extends PromptTemplate = PromptTemplate>(\n\tenv: ExecutionEnv,\n\tinputs: Array<SourcedPromptTemplatePath<TSource>>,\n\tmapPromptTemplate?: (promptTemplate: PromptTemplate, source: TSource) => TPromptTemplate,\n): Promise<SourcedPromptTemplateLoadResult<TSource, TPromptTemplate>> {\n\tconst promptTemplates: SourcedPromptTemplate<TSource, TPromptTemplate>[] = [];\n\tconst diagnostics: SourcedPromptTemplateDiagnostic<TSource>[] = [];\n\tfor (const input of inputs) {\n\t\tconst result = await loadPromptTemplates(env, input.path);\n\t\tfor (const promptTemplate of result.promptTemplates) {\n\t\t\tpromptTemplates.push({\n\t\t\t\tpromptTemplate: mapPromptTemplate\n\t\t\t\t\t? mapPromptTemplate(promptTemplate, input.source)\n\t\t\t\t\t: (promptTemplate as TPromptTemplate),\n\t\t\t\tsource: input.source,\n\t\t\t});\n\t\t}\n\t\tfor (const diagnostic of result.diagnostics) diagnostics.push({ ...diagnostic, source: input.source });\n\t}\n\treturn { promptTemplates, diagnostics };\n}\n\nasync function loadTemplatesFromDir(env: ExecutionEnv, dir: string): Promise<PromptTemplateLoadResult> {\n\tconst promptTemplates: PromptTemplate[] = [];\n\tconst diagnostics: PromptTemplateDiagnostic[] = [];\n\tconst entriesResult = await env.listDir(dir);\n\tif (!entriesResult.ok) {\n\t\tdiagnostics.push({\n\t\t\ttype: \"warning\",\n\t\t\tcode: \"list_failed\",\n\t\t\tmessage: entriesResult.error.message,\n\t\t\tpath: dir,\n\t\t});\n\t\treturn { promptTemplates, diagnostics };\n\t}\n\tconst entries = entriesResult.value;\n\n\tfor (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {\n\t\tconst kind = await resolveKind(env, entry, diagnostics);\n\t\tif (kind !== \"file\" || !entry.name.endsWith(\".md\")) continue;\n\t\tconst result = await loadTemplateFromFile(env, entry.path);\n\t\tif (result.promptTemplate) promptTemplates.push(result.promptTemplate);\n\t\tdiagnostics.push(...result.diagnostics);\n\t}\n\treturn { promptTemplates, diagnostics };\n}\n\nasync function loadTemplateFromFile(env: ExecutionEnv, filePath: string): Promise<PromptTemplateFileLoadResult> {\n\tconst diagnostics: PromptTemplateDiagnostic[] = [];\n\tconst rawContent = await env.readTextFile(filePath);\n\tif (!rawContent.ok) {\n\t\tdiagnostics.push({\n\t\t\ttype: \"warning\",\n\t\t\tcode: \"read_failed\",\n\t\t\tmessage: rawContent.error.message,\n\t\t\tpath: filePath,\n\t\t});\n\t\treturn { promptTemplate: null, diagnostics };\n\t}\n\n\tconst parsed = parseFrontmatter<PromptTemplateFrontmatter>(rawContent.value);\n\tif (!parsed.ok) {\n\t\tdiagnostics.push({\n\t\t\ttype: \"warning\",\n\t\t\tcode: \"parse_failed\",\n\t\t\tmessage: parsed.error.message,\n\t\t\tpath: filePath,\n\t\t});\n\t\treturn { promptTemplate: null, diagnostics };\n\t}\n\n\tconst { frontmatter, body } = parsed.value;\n\tconst firstLine = body.split(\"\\n\").find((line) => line.trim());\n\tlet description = typeof frontmatter.description === \"string\" ? frontmatter.description : \"\";\n\tif (!description && firstLine) {\n\t\tdescription = firstLine.slice(0, 60);\n\t\tif (firstLine.length > 60) description += \"...\";\n\t}\n\treturn {\n\t\tpromptTemplate: {\n\t\t\tname: basenameEnvPath(filePath).replace(/\\.md$/i, \"\"),\n\t\t\tdescription,\n\t\t\tcontent: body,\n\t\t},\n\t\tdiagnostics,\n\t};\n}\n\nasync function resolveKind(\n\tenv: ExecutionEnv,\n\tinfo: FileInfo,\n\tdiagnostics: PromptTemplateDiagnostic[],\n): Promise<PromptTemplatePathKind | undefined> {\n\tif (info.kind === \"file\" || info.kind === \"directory\") return info.kind;\n\tconst canonicalPath = await env.canonicalPath(info.path);\n\tif (!canonicalPath.ok) {\n\t\tappendFileInfoDiagnostic(diagnostics, canonicalPath.error, info.path);\n\t\treturn undefined;\n\t}\n\tconst target = await env.fileInfo(canonicalPath.value);\n\tif (!target.ok) {\n\t\tappendFileInfoDiagnostic(diagnostics, target.error, info.path);\n\t\treturn undefined;\n\t}\n\treturn target.value.kind === \"file\" || target.value.kind === \"directory\" ? target.value.kind : undefined;\n}\n\nfunction parseFrontmatter<T extends Record<string, unknown>>(content: string): Result<ParsedFrontmatter<T>, Error> {\n\ttry {\n\t\tconst normalized = content.replace(/\\r\\n/g, \"\\n\").replace(/\\r/g, \"\\n\");\n\t\tif (!normalized.startsWith(\"---\")) return { ok: true, value: { frontmatter: {} as T, body: normalized } };\n\t\tconst endIndex = normalized.indexOf(\"\\n---\", 3);\n\t\tif (endIndex === -1) return { ok: true, value: { frontmatter: {} as T, body: normalized } };\n\t\tconst yamlString = normalized.slice(4, endIndex);\n\t\tconst body = normalized.slice(endIndex + 4).trim();\n\t\treturn { ok: true, value: { frontmatter: (parse(yamlString) ?? {}) as T, body } };\n\t} catch (error) {\n\t\treturn { ok: false, error: toError(error) };\n\t}\n}\n\nfunction basenameEnvPath(path: string): string {\n\tconst normalized = path.replace(/\\/+$/, \"\");\n\tconst slashIndex = normalized.lastIndexOf(\"/\");\n\treturn slashIndex === -1 ? normalized : normalized.slice(slashIndex + 1);\n}\n\n/** Parse an argument string using simple shell-style single and double quotes. */\nexport function parseCommandArgs(argsString: string): string[] {\n\tconst args: string[] = [];\n\tlet current = \"\";\n\tlet inQuote: string | null = null;\n\n\tfor (let i = 0; i < argsString.length; i++) {\n\t\tconst char = argsString[i]!;\n\t\tif (inQuote) {\n\t\t\tif (char === inQuote) inQuote = null;\n\t\t\telse current += char;\n\t\t} else if (char === '\"' || char === \"'\") {\n\t\t\tinQuote = char;\n\t\t} else if (char === \" \" || char === \"\\t\") {\n\t\t\tif (current) {\n\t\t\t\targs.push(current);\n\t\t\t\tcurrent = \"\";\n\t\t\t}\n\t\t} else {\n\t\t\tcurrent += char;\n\t\t}\n\t}\n\tif (current) args.push(current);\n\treturn args;\n}\n\n/** Substitute prompt template placeholders (`$1`, `$@`, `$ARGUMENTS`, `${@:N}`, `${@:N:L}`) with command arguments. */\nexport function substituteArgs(content: string, args: string[]): string {\n\tlet result = content;\n\tresult = result.replace(/\\$(\\d+)/g, (_, num: string) => args[parseInt(num, 10) - 1] ?? \"\");\n\tresult = result.replace(/\\$\\{@:(\\d+)(?::(\\d+))?\\}/g, (_, startStr: string, lengthStr?: string) => {\n\t\tlet start = parseInt(startStr, 10) - 1;\n\t\tif (start < 0) start = 0;\n\t\tif (lengthStr) return args.slice(start, start + parseInt(lengthStr, 10)).join(\" \");\n\t\treturn args.slice(start).join(\" \");\n\t});\n\tconst allArgs = args.join(\" \");\n\tresult = result.replace(/\\$ARGUMENTS/g, allArgs);\n\tresult = result.replace(/\\$@/g, allArgs);\n\treturn result;\n}\n\n/** Format a prompt template invocation with positional arguments. */\nexport function formatPromptTemplateInvocation(template: PromptTemplate, args: string[] = []): string {\n\treturn substituteArgs(template.content, args);\n}\n"]}
1
+ {"version":3,"file":"prompt-templates.d.ts","sourceRoot":"","sources":["../../src/harness/prompt-templates.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,YAAY,EAGjB,KAAK,cAAc,EAGnB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,4BAA4B,GAAG,kBAAkB,GAAG,aAAa,GAAG,aAAa,GAAG,cAAc,CAAC;AAG/G,uDAAuD;AACvD,MAAM,WAAW,wBAAwB;IACxC,gEAAgE;IAChE,IAAI,EAAE,SAAS,CAAC;IAChB,8BAA8B;IAC9B,IAAI,EAAE,4BAA4B,CAAC;IACnC,yCAAyC;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;CACb;AAED,+EAA+E;AAC/E,MAAM,WAAW,wBAAwB;IACxC,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,WAAW,EAAE,wBAAwB,EAAE,CAAC;CACxC;AAED,iEAAiE;AACjE,MAAM,WAAW,yBAAyB,CAAC,OAAO;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;CAChB;AAiBD,MAAM,WAAW,qBAAqB,CAAC,OAAO,EAAE,eAAe,SAAS,cAAc;IACrF,cAAc,EAAE,eAAe,CAAC;IAChC,MAAM,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,MAAM,+BAA+B,CAAC,OAAO,IAAI,wBAAwB,GAAG;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC;AAEtG,yEAAyE;AACzE,MAAM,WAAW,+BAA+B,CAAC,OAAO,EAAE,eAAe,SAAS,cAAc;IAC/F,eAAe,EAAE,qBAAqB,CAAC,OAAO,EAAE,eAAe,CAAC,EAAE,CAAC;IACnE,WAAW,EAAE,+BAA+B,CAAC,OAAO,CAAC,EAAE,CAAC;CACxD;AAaD;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACxC,GAAG,EAAE,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AG,CAAC;YAAE,KAAK,GAAG,CAAC,CAAC;QACzB,IAAI,SAAS;YAAE,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACnF,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAAA,CACnC,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/B,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IACjD,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC,OAAO,MAAM,CAAC;AAAA,CACd;AAED,qEAAqE;AACrE,MAAM,UAAU,8BAA8B,CAAC,QAAwB,EAAE,IAAI,GAAa,EAAE,EAAU;IACrG,OAAO,cAAc,CAAC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AAAA,CAC9C","sourcesContent":["import { parse } from \"yaml\";\nimport {\n\ttype ExecutionEnv,\n\ttype FileError,\n\ttype FileInfo,\n\ttype PromptTemplate,\n\ttype Result,\n\ttoError,\n} from \"./types.ts\";\n\nexport type PromptTemplateDiagnosticCode = \"file_info_failed\" | \"list_failed\" | \"read_failed\" | \"parse_failed\";\ntype PromptTemplatePathKind = \"file\" | \"directory\";\n\n/** Warning produced while loading prompt templates. */\nexport interface PromptTemplateDiagnostic {\n\t/** Diagnostic severity. Currently only warnings are emitted. */\n\ttype: \"warning\";\n\t/** Stable diagnostic code. */\n\tcode: PromptTemplateDiagnosticCode;\n\t/** Human-readable diagnostic message. */\n\tmessage: string;\n\t/** Path associated with the diagnostic. */\n\tpath: string;\n}\n\n/** Prompt templates loaded from a path together with non-fatal diagnostics. */\nexport interface PromptTemplateLoadResult {\n\tpromptTemplates: PromptTemplate[];\n\tdiagnostics: PromptTemplateDiagnostic[];\n}\n\n/** Path and provenance used to load sourced prompt templates. */\nexport interface SourcedPromptTemplatePath<TSource> {\n\tpath: string;\n\tsource: TSource;\n}\n\ninterface PromptTemplateFileLoadResult {\n\tpromptTemplate: PromptTemplate | null;\n\tdiagnostics: PromptTemplateDiagnostic[];\n}\n\nfunction appendFileInfoDiagnostic(diagnostics: PromptTemplateDiagnostic[], error: FileError, path: string): void {\n\tif (error.code === \"not_found\") return;\n\tdiagnostics.push({\n\t\ttype: \"warning\",\n\t\tcode: \"file_info_failed\",\n\t\tmessage: error.message,\n\t\tpath,\n\t});\n}\n\nexport interface SourcedPromptTemplate<TSource, TPromptTemplate extends PromptTemplate> {\n\tpromptTemplate: TPromptTemplate;\n\tsource: TSource;\n}\n\nexport type SourcedPromptTemplateDiagnostic<TSource> = PromptTemplateDiagnostic & { source: TSource };\n\n/** Source-tagged prompt templates and diagnostics produced by a load. */\nexport interface SourcedPromptTemplateLoadResult<TSource, TPromptTemplate extends PromptTemplate> {\n\tpromptTemplates: SourcedPromptTemplate<TSource, TPromptTemplate>[];\n\tdiagnostics: SourcedPromptTemplateDiagnostic<TSource>[];\n}\n\ninterface PromptTemplateFrontmatter {\n\tdescription?: string;\n\t\"argument-hint\"?: string;\n\t[key: string]: unknown;\n}\n\ninterface ParsedFrontmatter<T> {\n\tfrontmatter: T;\n\tbody: string;\n}\n\n/**\n * Load prompt templates from one or more paths.\n *\n * Directory inputs load direct `.md` children non-recursively. File inputs load explicit `.md` files. Missing paths and\n * non-markdown files are skipped. Read and parse failures are returned as diagnostics.\n */\nexport async function loadPromptTemplates(\n\tenv: ExecutionEnv,\n\tpaths: string | string[],\n): Promise<PromptTemplateLoadResult> {\n\tconst promptTemplates: PromptTemplate[] = [];\n\tconst diagnostics: PromptTemplateDiagnostic[] = [];\n\tfor (const path of Array.isArray(paths) ? paths : [paths]) {\n\t\tconst infoResult = await env.fileInfo(path);\n\t\tif (!infoResult.ok) {\n\t\t\tappendFileInfoDiagnostic(diagnostics, infoResult.error, path);\n\t\t\tcontinue;\n\t\t}\n\t\tconst info = infoResult.value;\n\t\tconst kind = await resolveKind(env, info, diagnostics);\n\t\tif (kind === \"directory\") {\n\t\t\tconst result = await loadTemplatesFromDir(env, info.path);\n\t\t\tpromptTemplates.push(...result.promptTemplates);\n\t\t\tdiagnostics.push(...result.diagnostics);\n\t\t} else if (kind === \"file\" && info.name.endsWith(\".md\")) {\n\t\t\tconst result = await loadTemplateFromFile(env, info.path);\n\t\t\tif (result.promptTemplate) promptTemplates.push(result.promptTemplate);\n\t\t\tdiagnostics.push(...result.diagnostics);\n\t\t}\n\t}\n\treturn { promptTemplates, diagnostics };\n}\n\n/**\n * Load prompt templates from source-tagged paths.\n *\n * Source values are preserved exactly and attached to every loaded prompt template and diagnostic. The agent package does\n * not interpret source values; applications define their own provenance shape.\n */\nexport async function loadSourcedPromptTemplates<TSource, TPromptTemplate extends PromptTemplate = PromptTemplate>(\n\tenv: ExecutionEnv,\n\tinputs: Array<SourcedPromptTemplatePath<TSource>>,\n\tmapPromptTemplate?: (promptTemplate: PromptTemplate, source: TSource) => TPromptTemplate,\n): Promise<SourcedPromptTemplateLoadResult<TSource, TPromptTemplate>> {\n\tconst promptTemplates: SourcedPromptTemplate<TSource, TPromptTemplate>[] = [];\n\tconst diagnostics: SourcedPromptTemplateDiagnostic<TSource>[] = [];\n\tfor (const input of inputs) {\n\t\tconst result = await loadPromptTemplates(env, input.path);\n\t\tfor (const promptTemplate of result.promptTemplates) {\n\t\t\tpromptTemplates.push({\n\t\t\t\tpromptTemplate: mapPromptTemplate\n\t\t\t\t\t? mapPromptTemplate(promptTemplate, input.source)\n\t\t\t\t\t: (promptTemplate as TPromptTemplate),\n\t\t\t\tsource: input.source,\n\t\t\t});\n\t\t}\n\t\tfor (const diagnostic of result.diagnostics) diagnostics.push({ ...diagnostic, source: input.source });\n\t}\n\treturn { promptTemplates, diagnostics };\n}\n\nasync function loadTemplatesFromDir(env: ExecutionEnv, dir: string): Promise<PromptTemplateLoadResult> {\n\tconst promptTemplates: PromptTemplate[] = [];\n\tconst diagnostics: PromptTemplateDiagnostic[] = [];\n\tconst entriesResult = await env.listDir(dir);\n\tif (!entriesResult.ok) {\n\t\tdiagnostics.push({\n\t\t\ttype: \"warning\",\n\t\t\tcode: \"list_failed\",\n\t\t\tmessage: entriesResult.error.message,\n\t\t\tpath: dir,\n\t\t});\n\t\treturn { promptTemplates, diagnostics };\n\t}\n\tconst entries = entriesResult.value;\n\n\tfor (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {\n\t\tconst kind = await resolveKind(env, entry, diagnostics);\n\t\tif (kind !== \"file\" || !entry.name.endsWith(\".md\")) continue;\n\t\tconst result = await loadTemplateFromFile(env, entry.path);\n\t\tif (result.promptTemplate) promptTemplates.push(result.promptTemplate);\n\t\tdiagnostics.push(...result.diagnostics);\n\t}\n\treturn { promptTemplates, diagnostics };\n}\n\nasync function loadTemplateFromFile(env: ExecutionEnv, filePath: string): Promise<PromptTemplateFileLoadResult> {\n\tconst diagnostics: PromptTemplateDiagnostic[] = [];\n\tconst rawContent = await env.readTextFile(filePath);\n\tif (!rawContent.ok) {\n\t\tdiagnostics.push({\n\t\t\ttype: \"warning\",\n\t\t\tcode: \"read_failed\",\n\t\t\tmessage: rawContent.error.message,\n\t\t\tpath: filePath,\n\t\t});\n\t\treturn { promptTemplate: null, diagnostics };\n\t}\n\n\tconst parsed = parseFrontmatter<PromptTemplateFrontmatter>(rawContent.value);\n\tif (!parsed.ok) {\n\t\tdiagnostics.push({\n\t\t\ttype: \"warning\",\n\t\t\tcode: \"parse_failed\",\n\t\t\tmessage: parsed.error.message,\n\t\t\tpath: filePath,\n\t\t});\n\t\treturn { promptTemplate: null, diagnostics };\n\t}\n\n\tconst { frontmatter, body } = parsed.value;\n\tconst firstLine = body.split(\"\\n\").find((line) => line.trim());\n\tlet description = typeof frontmatter.description === \"string\" ? frontmatter.description : \"\";\n\tif (!description && firstLine) {\n\t\tdescription = firstLine.slice(0, 60);\n\t\tif (firstLine.length > 60) description += \"...\";\n\t}\n\treturn {\n\t\tpromptTemplate: {\n\t\t\tname: basenameEnvPath(filePath).replace(/\\.md$/i, \"\"),\n\t\t\tdescription,\n\t\t\tcontent: body,\n\t\t},\n\t\tdiagnostics,\n\t};\n}\n\nasync function resolveKind(\n\tenv: ExecutionEnv,\n\tinfo: FileInfo,\n\tdiagnostics: PromptTemplateDiagnostic[],\n): Promise<PromptTemplatePathKind | undefined> {\n\tif (info.kind === \"file\" || info.kind === \"directory\") return info.kind;\n\tconst canonicalPath = await env.canonicalPath(info.path);\n\tif (!canonicalPath.ok) {\n\t\tappendFileInfoDiagnostic(diagnostics, canonicalPath.error, info.path);\n\t\treturn undefined;\n\t}\n\tconst target = await env.fileInfo(canonicalPath.value);\n\tif (!target.ok) {\n\t\tappendFileInfoDiagnostic(diagnostics, target.error, info.path);\n\t\treturn undefined;\n\t}\n\treturn target.value.kind === \"file\" || target.value.kind === \"directory\" ? target.value.kind : undefined;\n}\n\nfunction parseFrontmatter<T extends Record<string, unknown>>(content: string): Result<ParsedFrontmatter<T>, Error> {\n\ttry {\n\t\tconst normalized = content.replace(/\\r\\n/g, \"\\n\").replace(/\\r/g, \"\\n\");\n\t\tif (!normalized.startsWith(\"---\")) return { ok: true, value: { frontmatter: {} as T, body: normalized } };\n\t\tconst endIndex = normalized.indexOf(\"\\n---\", 3);\n\t\tif (endIndex === -1) return { ok: true, value: { frontmatter: {} as T, body: normalized } };\n\t\tconst yamlString = normalized.slice(4, endIndex);\n\t\tconst body = normalized.slice(endIndex + 4).trim();\n\t\treturn { ok: true, value: { frontmatter: (parse(yamlString) ?? {}) as T, body } };\n\t} catch (error) {\n\t\treturn { ok: false, error: toError(error) };\n\t}\n}\n\nfunction basenameEnvPath(path: string): string {\n\tconst normalized = path.replace(/\\/+$/, \"\");\n\tconst slashIndex = normalized.lastIndexOf(\"/\");\n\treturn slashIndex === -1 ? normalized : normalized.slice(slashIndex + 1);\n}\n\n/** Parse an argument string using simple shell-style single and double quotes. */\nexport function parseCommandArgs(argsString: string): string[] {\n\tconst args: string[] = [];\n\tlet current = \"\";\n\tlet inQuote: string | null = null;\n\n\tfor (let i = 0; i < argsString.length; i++) {\n\t\tconst char = argsString[i]!;\n\t\tif (inQuote) {\n\t\t\tif (char === inQuote) inQuote = null;\n\t\t\telse current += char;\n\t\t} else if (char === '\"' || char === \"'\") {\n\t\t\tinQuote = char;\n\t\t} else if (char === \" \" || char === \"\\t\") {\n\t\t\tif (current) {\n\t\t\t\targs.push(current);\n\t\t\t\tcurrent = \"\";\n\t\t\t}\n\t\t} else {\n\t\t\tcurrent += char;\n\t\t}\n\t}\n\tif (current) args.push(current);\n\treturn args;\n}\n\n/** Substitute prompt template placeholders (`$1`, `$@`, `$ARGUMENTS`, `${@:N}`, `${@:N:L}`) with command arguments. */\nexport function substituteArgs(content: string, args: string[]): string {\n\tlet result = content;\n\tresult = result.replace(/\\$(\\d+)/g, (_, num: string) => args[parseInt(num, 10) - 1] ?? \"\");\n\tresult = result.replace(/\\$\\{@:(\\d+)(?::(\\d+))?\\}/g, (_, startStr: string, lengthStr?: string) => {\n\t\tlet start = parseInt(startStr, 10) - 1;\n\t\tif (start < 0) start = 0;\n\t\tif (lengthStr) return args.slice(start, start + parseInt(lengthStr, 10)).join(\" \");\n\t\treturn args.slice(start).join(\" \");\n\t});\n\tconst allArgs = args.join(\" \");\n\tresult = result.replace(/\\$ARGUMENTS/g, allArgs);\n\tresult = result.replace(/\\$@/g, allArgs);\n\treturn result;\n}\n\n/** Format a prompt template invocation with positional arguments. */\nexport function formatPromptTemplateInvocation(template: PromptTemplate, args: string[] = []): string {\n\treturn substituteArgs(template.content, args);\n}\n"]}
1
+ {"version":3,"file":"prompt-templates.js","sourceRoot":"","sources":["../../src/harness/prompt-templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;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AI,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC3F,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,2BAA2B,EAAE,CAAC,CAAC,EAAE,QAAgB,EAAE,SAAkB,EAAE,EAAE;QAChG,IAAI,KAAK,GAAG,QAAQ,CAAC,QAAQ,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC;QACvC,IAAI,KAAK,GAAG,CAAC;YAAE,KAAK,GAAG,CAAC,CAAC;QACzB,IAAI,SAAS;YAAE,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACnF,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/B,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IACjD,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC,OAAO,MAAM,CAAC;AACf,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,8BAA8B,CAAC,QAAwB,EAAE,IAAI,GAAa,EAAE;IAC3F,OAAO,cAAc,CAAC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["import { parse } from \"yaml\";\nimport {\n\ttype ExecutionEnv,\n\ttype FileError,\n\ttype FileInfo,\n\ttype PromptTemplate,\n\ttype Result,\n\ttoError,\n} from \"./types.ts\";\n\nexport type PromptTemplateDiagnosticCode = \"file_info_failed\" | \"list_failed\" | \"read_failed\" | \"parse_failed\";\ntype PromptTemplatePathKind = \"file\" | \"directory\";\n\n/** Warning produced while loading prompt templates. */\nexport interface PromptTemplateDiagnostic {\n\t/** Diagnostic severity. Currently only warnings are emitted. */\n\ttype: \"warning\";\n\t/** Stable diagnostic code. */\n\tcode: PromptTemplateDiagnosticCode;\n\t/** Human-readable diagnostic message. */\n\tmessage: string;\n\t/** Path associated with the diagnostic. */\n\tpath: string;\n}\n\n/** Prompt templates loaded from a path together with non-fatal diagnostics. */\nexport interface PromptTemplateLoadResult {\n\tpromptTemplates: PromptTemplate[];\n\tdiagnostics: PromptTemplateDiagnostic[];\n}\n\n/** Path and provenance used to load sourced prompt templates. */\nexport interface SourcedPromptTemplatePath<TSource> {\n\tpath: string;\n\tsource: TSource;\n}\n\ninterface PromptTemplateFileLoadResult {\n\tpromptTemplate: PromptTemplate | null;\n\tdiagnostics: PromptTemplateDiagnostic[];\n}\n\nfunction appendFileInfoDiagnostic(diagnostics: PromptTemplateDiagnostic[], error: FileError, path: string): void {\n\tif (error.code === \"not_found\") return;\n\tdiagnostics.push({\n\t\ttype: \"warning\",\n\t\tcode: \"file_info_failed\",\n\t\tmessage: error.message,\n\t\tpath,\n\t});\n}\n\nexport interface SourcedPromptTemplate<TSource, TPromptTemplate extends PromptTemplate> {\n\tpromptTemplate: TPromptTemplate;\n\tsource: TSource;\n}\n\nexport type SourcedPromptTemplateDiagnostic<TSource> = PromptTemplateDiagnostic & { source: TSource };\n\n/** Source-tagged prompt templates and diagnostics produced by a load. */\nexport interface SourcedPromptTemplateLoadResult<TSource, TPromptTemplate extends PromptTemplate> {\n\tpromptTemplates: SourcedPromptTemplate<TSource, TPromptTemplate>[];\n\tdiagnostics: SourcedPromptTemplateDiagnostic<TSource>[];\n}\n\ninterface PromptTemplateFrontmatter {\n\tdescription?: string;\n\t\"argument-hint\"?: string;\n\t[key: string]: unknown;\n}\n\ninterface ParsedFrontmatter<T> {\n\tfrontmatter: T;\n\tbody: string;\n}\n\n/**\n * Load prompt templates from one or more paths.\n *\n * Directory inputs load direct `.md` children non-recursively. File inputs load explicit `.md` files. Missing paths and\n * non-markdown files are skipped. Read and parse failures are returned as diagnostics.\n */\nexport async function loadPromptTemplates(\n\tenv: ExecutionEnv,\n\tpaths: string | string[],\n): Promise<PromptTemplateLoadResult> {\n\tconst promptTemplates: PromptTemplate[] = [];\n\tconst diagnostics: PromptTemplateDiagnostic[] = [];\n\tfor (const path of Array.isArray(paths) ? paths : [paths]) {\n\t\tconst infoResult = await env.fileInfo(path);\n\t\tif (!infoResult.ok) {\n\t\t\tappendFileInfoDiagnostic(diagnostics, infoResult.error, path);\n\t\t\tcontinue;\n\t\t}\n\t\tconst info = infoResult.value;\n\t\tconst kind = await resolveKind(env, info, diagnostics);\n\t\tif (kind === \"directory\") {\n\t\t\tconst result = await loadTemplatesFromDir(env, info.path);\n\t\t\tpromptTemplates.push(...result.promptTemplates);\n\t\t\tdiagnostics.push(...result.diagnostics);\n\t\t} else if (kind === \"file\" && info.name.endsWith(\".md\")) {\n\t\t\tconst result = await loadTemplateFromFile(env, info.path);\n\t\t\tif (result.promptTemplate) promptTemplates.push(result.promptTemplate);\n\t\t\tdiagnostics.push(...result.diagnostics);\n\t\t}\n\t}\n\treturn { promptTemplates, diagnostics };\n}\n\n/**\n * Load prompt templates from source-tagged paths.\n *\n * Source values are preserved exactly and attached to every loaded prompt template and diagnostic. The agent package does\n * not interpret source values; applications define their own provenance shape.\n */\nexport async function loadSourcedPromptTemplates<TSource, TPromptTemplate extends PromptTemplate = PromptTemplate>(\n\tenv: ExecutionEnv,\n\tinputs: Array<SourcedPromptTemplatePath<TSource>>,\n\tmapPromptTemplate?: (promptTemplate: PromptTemplate, source: TSource) => TPromptTemplate,\n): Promise<SourcedPromptTemplateLoadResult<TSource, TPromptTemplate>> {\n\tconst promptTemplates: SourcedPromptTemplate<TSource, TPromptTemplate>[] = [];\n\tconst diagnostics: SourcedPromptTemplateDiagnostic<TSource>[] = [];\n\tfor (const input of inputs) {\n\t\tconst result = await loadPromptTemplates(env, input.path);\n\t\tfor (const promptTemplate of result.promptTemplates) {\n\t\t\tpromptTemplates.push({\n\t\t\t\tpromptTemplate: mapPromptTemplate\n\t\t\t\t\t? mapPromptTemplate(promptTemplate, input.source)\n\t\t\t\t\t: (promptTemplate as TPromptTemplate),\n\t\t\t\tsource: input.source,\n\t\t\t});\n\t\t}\n\t\tfor (const diagnostic of result.diagnostics) diagnostics.push({ ...diagnostic, source: input.source });\n\t}\n\treturn { promptTemplates, diagnostics };\n}\n\nasync function loadTemplatesFromDir(env: ExecutionEnv, dir: string): Promise<PromptTemplateLoadResult> {\n\tconst promptTemplates: PromptTemplate[] = [];\n\tconst diagnostics: PromptTemplateDiagnostic[] = [];\n\tconst entriesResult = await env.listDir(dir);\n\tif (!entriesResult.ok) {\n\t\tdiagnostics.push({\n\t\t\ttype: \"warning\",\n\t\t\tcode: \"list_failed\",\n\t\t\tmessage: entriesResult.error.message,\n\t\t\tpath: dir,\n\t\t});\n\t\treturn { promptTemplates, diagnostics };\n\t}\n\tconst entries = entriesResult.value;\n\n\tfor (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {\n\t\tconst kind = await resolveKind(env, entry, diagnostics);\n\t\tif (kind !== \"file\" || !entry.name.endsWith(\".md\")) continue;\n\t\tconst result = await loadTemplateFromFile(env, entry.path);\n\t\tif (result.promptTemplate) promptTemplates.push(result.promptTemplate);\n\t\tdiagnostics.push(...result.diagnostics);\n\t}\n\treturn { promptTemplates, diagnostics };\n}\n\nasync function loadTemplateFromFile(env: ExecutionEnv, filePath: string): Promise<PromptTemplateFileLoadResult> {\n\tconst diagnostics: PromptTemplateDiagnostic[] = [];\n\tconst rawContent = await env.readTextFile(filePath);\n\tif (!rawContent.ok) {\n\t\tdiagnostics.push({\n\t\t\ttype: \"warning\",\n\t\t\tcode: \"read_failed\",\n\t\t\tmessage: rawContent.error.message,\n\t\t\tpath: filePath,\n\t\t});\n\t\treturn { promptTemplate: null, diagnostics };\n\t}\n\n\tconst parsed = parseFrontmatter<PromptTemplateFrontmatter>(rawContent.value);\n\tif (!parsed.ok) {\n\t\tdiagnostics.push({\n\t\t\ttype: \"warning\",\n\t\t\tcode: \"parse_failed\",\n\t\t\tmessage: parsed.error.message,\n\t\t\tpath: filePath,\n\t\t});\n\t\treturn { promptTemplate: null, diagnostics };\n\t}\n\n\tconst { frontmatter, body } = parsed.value;\n\tconst firstLine = body.split(\"\\n\").find((line) => line.trim());\n\tlet description = typeof frontmatter.description === \"string\" ? frontmatter.description : \"\";\n\tif (!description && firstLine) {\n\t\tdescription = firstLine.slice(0, 60);\n\t\tif (firstLine.length > 60) description += \"...\";\n\t}\n\treturn {\n\t\tpromptTemplate: {\n\t\t\tname: basenameEnvPath(filePath).replace(/\\.md$/i, \"\"),\n\t\t\tdescription,\n\t\t\tcontent: body,\n\t\t},\n\t\tdiagnostics,\n\t};\n}\n\nasync function resolveKind(\n\tenv: ExecutionEnv,\n\tinfo: FileInfo,\n\tdiagnostics: PromptTemplateDiagnostic[],\n): Promise<PromptTemplatePathKind | undefined> {\n\tif (info.kind === \"file\" || info.kind === \"directory\") return info.kind;\n\tconst canonicalPath = await env.canonicalPath(info.path);\n\tif (!canonicalPath.ok) {\n\t\tappendFileInfoDiagnostic(diagnostics, canonicalPath.error, info.path);\n\t\treturn undefined;\n\t}\n\tconst target = await env.fileInfo(canonicalPath.value);\n\tif (!target.ok) {\n\t\tappendFileInfoDiagnostic(diagnostics, target.error, info.path);\n\t\treturn undefined;\n\t}\n\treturn target.value.kind === \"file\" || target.value.kind === \"directory\" ? target.value.kind : undefined;\n}\n\nfunction parseFrontmatter<T extends Record<string, unknown>>(content: string): Result<ParsedFrontmatter<T>, Error> {\n\ttry {\n\t\tconst normalized = content.replace(/\\r\\n/g, \"\\n\").replace(/\\r/g, \"\\n\");\n\t\tif (!normalized.startsWith(\"---\")) return { ok: true, value: { frontmatter: {} as T, body: normalized } };\n\t\tconst endIndex = normalized.indexOf(\"\\n---\", 3);\n\t\tif (endIndex === -1) return { ok: true, value: { frontmatter: {} as T, body: normalized } };\n\t\tconst yamlString = normalized.slice(4, endIndex);\n\t\tconst body = normalized.slice(endIndex + 4).trim();\n\t\treturn { ok: true, value: { frontmatter: (parse(yamlString) ?? {}) as T, body } };\n\t} catch (error) {\n\t\treturn { ok: false, error: toError(error) };\n\t}\n}\n\nfunction basenameEnvPath(path: string): string {\n\tconst normalized = path.replace(/\\/+$/, \"\");\n\tconst slashIndex = normalized.lastIndexOf(\"/\");\n\treturn slashIndex === -1 ? normalized : normalized.slice(slashIndex + 1);\n}\n\n/** Parse an argument string using simple shell-style single and double quotes. */\nexport function parseCommandArgs(argsString: string): string[] {\n\tconst args: string[] = [];\n\tlet current = \"\";\n\tlet inQuote: string | null = null;\n\n\tfor (let i = 0; i < argsString.length; i++) {\n\t\tconst char = argsString[i]!;\n\t\tif (inQuote) {\n\t\t\tif (char === inQuote) inQuote = null;\n\t\t\telse current += char;\n\t\t} else if (char === '\"' || char === \"'\") {\n\t\t\tinQuote = char;\n\t\t} else if (char === \" \" || char === \"\\t\") {\n\t\t\tif (current) {\n\t\t\t\targs.push(current);\n\t\t\t\tcurrent = \"\";\n\t\t\t}\n\t\t} else {\n\t\t\tcurrent += char;\n\t\t}\n\t}\n\tif (current) args.push(current);\n\treturn args;\n}\n\n/** Substitute prompt template placeholders (`$1`, `$@`, `$ARGUMENTS`, `${@:N}`, `${@:N:L}`) with command arguments. */\nexport function substituteArgs(content: string, args: string[]): string {\n\tlet result = content;\n\tresult = result.replace(/\\$(\\d+)/g, (_, num: string) => args[parseInt(num, 10) - 1] ?? \"\");\n\tresult = result.replace(/\\$\\{@:(\\d+)(?::(\\d+))?\\}/g, (_, startStr: string, lengthStr?: string) => {\n\t\tlet start = parseInt(startStr, 10) - 1;\n\t\tif (start < 0) start = 0;\n\t\tif (lengthStr) return args.slice(start, start + parseInt(lengthStr, 10)).join(\" \");\n\t\treturn args.slice(start).join(\" \");\n\t});\n\tconst allArgs = args.join(\" \");\n\tresult = result.replace(/\\$ARGUMENTS/g, allArgs);\n\tresult = result.replace(/\\$@/g, allArgs);\n\treturn result;\n}\n\n/** Format a prompt template invocation with positional arguments. */\nexport function formatPromptTemplateInvocation(template: PromptTemplate, args: string[] = []): string {\n\treturn substituteArgs(template.content, args);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"jsonl-errors.d.ts","sourceRoot":"","sources":["../../../src/harness/session/jsonl-errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAElE,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;AAErE,MAAM,MAAM,eAAe,GACxB,QAAQ,GACR,QAAQ,GACR,MAAM,GACN,MAAM,GACN,QAAQ,GACR,SAAS,GACT,MAAM,GACN,QAAQ,GACR,SAAS,GACT,MAAM,CAAC;AAEV,MAAM,MAAM,iBAAiB,GAAG,aAAa,GAAG,SAAS,GAAG,WAAW,CAAC;AAExE,yGAAyG;AACzG,qBAAa,gBAAiB,SAAQ,KAAK;IAC1C,QAAQ,CAAC,UAAU,EAAE,eAAe,CAAC;IACrC,gEAAgE;IAChE,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAE/B,YAAY,UAAU,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,EAKtE;CACD;AAED,MAAM,WAAW,wBAAwB;IACxC,IAAI,EAAE,gBAAgB,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,eAAe,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,eAAe,CAAC;IAC7B,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,KAAK,CAAC,EAAE,KAAK,CAAC;CACd;AAED,+FAA+F;AAC/F,qBAAa,iBAAkB,SAAQ,YAAY;IAClD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC;IAChC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,CAAC,EAAE,eAAe,CAAC;IACtC,QAAQ,CAAC,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAErC,YAAY,OAAO,EAAE,wBAAwB,EAU5C;CACD","sourcesContent":["import { SessionError, type SessionErrorCode } from \"../types.ts\";\n\nexport type JsonlDecodeKind = \"utf8\" | \"syntax\" | \"schema\" | \"state\";\n\nexport type JsonlErrorPhase =\n\t| \"create\"\n\t| \"append\"\n\t| \"fork\"\n\t| \"open\"\n\t| \"repair\"\n\t| \"migrate\"\n\t| \"list\"\n\t| \"import\"\n\t| \"replace\"\n\t| \"sync\";\n\nexport type JsonlWriteOutcome = \"not_written\" | \"unknown\" | \"published\";\n\n/** Path-independent JSONL decoding failure. Storage boundaries attach location and operation context. */\nexport class JsonlDecodeError extends Error {\n\treadonly decodeKind: JsonlDecodeKind;\n\t/** Compatibility alias for path-independent codec consumers. */\n\treadonly kind: JsonlDecodeKind;\n\n\tconstructor(decodeKind: JsonlDecodeKind, message: string, cause?: Error) {\n\t\tsuper(message, cause === undefined ? undefined : { cause });\n\t\tthis.name = \"JsonlDecodeError\";\n\t\tthis.decodeKind = decodeKind;\n\t\tthis.kind = decodeKind;\n\t}\n}\n\nexport interface JsonlSessionErrorOptions {\n\tcode: SessionErrorCode;\n\treference: string;\n\tphase: JsonlErrorPhase;\n\tmessage: string;\n\tline?: number;\n\tbyteOffset?: number;\n\tdecodeKind?: JsonlDecodeKind;\n\toutcome?: JsonlWriteOutcome;\n\tcause?: Error;\n}\n\n/** SessionError with actionable JSONL location, phase, decoding, and write-outcome context. */\nexport class JsonlSessionError extends SessionError {\n\treadonly reference: string;\n\treadonly path: string;\n\treadonly phase: JsonlErrorPhase;\n\treadonly line?: number;\n\treadonly byteOffset?: number;\n\treadonly decodeKind?: JsonlDecodeKind;\n\treadonly outcome?: JsonlWriteOutcome;\n\n\tconstructor(options: JsonlSessionErrorOptions) {\n\t\tsuper(options.code, options.message, options.cause);\n\t\tthis.name = \"JsonlSessionError\";\n\t\tthis.reference = options.reference;\n\t\tthis.path = options.reference;\n\t\tthis.phase = options.phase;\n\t\tthis.line = options.line;\n\t\tthis.byteOffset = options.byteOffset;\n\t\tthis.decodeKind = options.decodeKind;\n\t\tthis.outcome = options.outcome;\n\t}\n}\n"]}
1
+ {"version":3,"file":"jsonl-errors.d.ts","sourceRoot":"","sources":["../../../src/harness/session/jsonl-errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAElE,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;AAErE,MAAM,MAAM,eAAe,GACxB,QAAQ,GACR,QAAQ,GACR,MAAM,GACN,MAAM,GACN,QAAQ,GACR,SAAS,GACT,MAAM,GACN,QAAQ,GACR,SAAS,GACT,MAAM,CAAC;AAEV,MAAM,MAAM,iBAAiB,GAAG,aAAa,GAAG,SAAS,GAAG,WAAW,CAAC;AAExE,yGAAyG;AACzG,qBAAa,gBAAiB,SAAQ,KAAK;IAC1C,QAAQ,CAAC,UAAU,EAAE,eAAe,CAAC;IACrC,gEAAgE;IAChE,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAE/B,YAAY,UAAU,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,EAKtE;CACD;AAED,MAAM,WAAW,wBAAwB;IACxC,IAAI,EAAE,gBAAgB,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,eAAe,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,eAAe,CAAC;IAC7B,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,KAAK,CAAC,EAAE,KAAK,CAAC;CACd;AAED,+FAA+F;AAC/F,qBAAa,iBAAkB,SAAQ,YAAY;IAClD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC;IAChC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,CAAC,EAAE,eAAe,CAAC;IACtC,QAAQ,CAAC,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAErC,YAAY,OAAO,EAAE,wBAAwB,EAU5C;CACD"}
@@ -1,9 +1,6 @@
1
1
  import { SessionError } from "../types.js";
2
2
  /** Path-independent JSONL decoding failure. Storage boundaries attach location and operation context. */
3
3
  export class JsonlDecodeError extends Error {
4
- decodeKind;
5
- /** Compatibility alias for path-independent codec consumers. */
6
- kind;
7
4
  constructor(decodeKind, message, cause) {
8
5
  super(message, cause === undefined ? undefined : { cause });
9
6
  this.name = "JsonlDecodeError";
@@ -13,13 +10,6 @@ export class JsonlDecodeError extends Error {
13
10
  }
14
11
  /** SessionError with actionable JSONL location, phase, decoding, and write-outcome context. */
15
12
  export class JsonlSessionError extends SessionError {
16
- reference;
17
- path;
18
- phase;
19
- line;
20
- byteOffset;
21
- decodeKind;
22
- outcome;
23
13
  constructor(options) {
24
14
  super(options.code, options.message, options.cause);
25
15
  this.name = "JsonlSessionError";
@@ -1 +1 @@
1
- {"version":3,"file":"jsonl-errors.js","sour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O,GAAG,OAAO,CAAC,OAAO,CAAC;IAAA,CAC/B;CACD","sourcesContent":["import { SessionError, type SessionErrorCode } from \"../types.ts\";\n\nexport type JsonlDecodeKind = \"utf8\" | \"syntax\" | \"schema\" | \"state\";\n\nexport type JsonlErrorPhase =\n\t| \"create\"\n\t| \"append\"\n\t| \"fork\"\n\t| \"open\"\n\t| \"repair\"\n\t| \"migrate\"\n\t| \"list\"\n\t| \"import\"\n\t| \"replace\"\n\t| \"sync\";\n\nexport type JsonlWriteOutcome = \"not_written\" | \"unknown\" | \"published\";\n\n/** Path-independent JSONL decoding failure. Storage boundaries attach location and operation context. */\nexport class JsonlDecodeError extends Error {\n\treadonly decodeKind: JsonlDecodeKind;\n\t/** Compatibility alias for path-independent codec consumers. */\n\treadonly kind: JsonlDecodeKind;\n\n\tconstructor(decodeKind: JsonlDecodeKind, message: string, cause?: Error) {\n\t\tsuper(message, cause === undefined ? undefined : { cause });\n\t\tthis.name = \"JsonlDecodeError\";\n\t\tthis.decodeKind = decodeKind;\n\t\tthis.kind = decodeKind;\n\t}\n}\n\nexport interface JsonlSessionErrorOptions {\n\tcode: SessionErrorCode;\n\treference: string;\n\tphase: JsonlErrorPhase;\n\tmessage: string;\n\tline?: number;\n\tbyteOffset?: number;\n\tdecodeKind?: JsonlDecodeKind;\n\toutcome?: JsonlWriteOutcome;\n\tcause?: Error;\n}\n\n/** SessionError with actionable JSONL location, phase, decoding, and write-outcome context. */\nexport class JsonlSessionError extends SessionError {\n\treadonly reference: string;\n\treadonly path: string;\n\treadonly phase: JsonlErrorPhase;\n\treadonly line?: number;\n\treadonly byteOffset?: number;\n\treadonly decodeKind?: JsonlDecodeKind;\n\treadonly outcome?: JsonlWriteOutcome;\n\n\tconstructor(options: JsonlSessionErrorOptions) {\n\t\tsuper(options.code, options.message, options.cause);\n\t\tthis.name = \"JsonlSessionError\";\n\t\tthis.reference = options.reference;\n\t\tthis.path = options.reference;\n\t\tthis.phase = options.phase;\n\t\tthis.line = options.line;\n\t\tthis.byteOffset = options.byteOffset;\n\t\tthis.decodeKind = options.decodeKind;\n\t\tthis.outcome = options.outcome;\n\t}\n}\n"]}
1
+ {"version":3,"file":"jsonl-errors.js","sourceRoot":"","sources":["../../../src/harness/session/jsonl-errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAyB,MAAM,aAAa,CAAC;AAkBlE,yGAAyG;AACzG,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAK1C,YAAY,UAA2B,EAAE,OAAe,EAAE,KAAa;QACtE,KAAK,CAAC,OAAO,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACxB,CAAC;CACD;AAcD,+FAA+F;AAC/F,MAAM,OAAO,iBAAkB,SAAQ,YAAY;IASlD,YAAY,OAAiC;QAC5C,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;QACpD,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;QAChC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,SAAS,CAAC;QAC9B,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAChC,CAAC;CACD","sourcesContent":["import { SessionError, type SessionErrorCode } from \"../types.ts\";\n\nexport type JsonlDecodeKind = \"utf8\" | \"syntax\" | \"schema\" | \"state\";\n\nexport type JsonlErrorPhase =\n\t| \"create\"\n\t| \"append\"\n\t| \"fork\"\n\t| \"open\"\n\t| \"repair\"\n\t| \"migrate\"\n\t| \"list\"\n\t| \"import\"\n\t| \"replace\"\n\t| \"sync\";\n\nexport type JsonlWriteOutcome = \"not_written\" | \"unknown\" | \"published\";\n\n/** Path-independent JSONL decoding failure. Storage boundaries attach location and operation context. */\nexport class JsonlDecodeError extends Error {\n\treadonly decodeKind: JsonlDecodeKind;\n\t/** Compatibility alias for path-independent codec consumers. */\n\treadonly kind: JsonlDecodeKind;\n\n\tconstructor(decodeKind: JsonlDecodeKind, message: string, cause?: Error) {\n\t\tsuper(message, cause === undefined ? undefined : { cause });\n\t\tthis.name = \"JsonlDecodeError\";\n\t\tthis.decodeKind = decodeKind;\n\t\tthis.kind = decodeKind;\n\t}\n}\n\nexport interface JsonlSessionErrorOptions {\n\tcode: SessionErrorCode;\n\treference: string;\n\tphase: JsonlErrorPhase;\n\tmessage: string;\n\tline?: number;\n\tbyteOffset?: number;\n\tdecodeKind?: JsonlDecodeKind;\n\toutcome?: JsonlWriteOutcome;\n\tcause?: Error;\n}\n\n/** SessionError with actionable JSONL location, phase, decoding, and write-outcome context. */\nexport class JsonlSessionError extends SessionError {\n\treadonly reference: string;\n\treadonly path: string;\n\treadonly phase: JsonlErrorPhase;\n\treadonly line?: number;\n\treadonly byteOffset?: number;\n\treadonly decodeKind?: JsonlDecodeKind;\n\treadonly outcome?: JsonlWriteOutcome;\n\n\tconstructor(options: JsonlSessionErrorOptions) {\n\t\tsuper(options.code, options.message, options.cause);\n\t\tthis.name = \"JsonlSessionError\";\n\t\tthis.reference = options.reference;\n\t\tthis.path = options.reference;\n\t\tthis.phase = options.phase;\n\t\tthis.line = options.line;\n\t\tthis.byteOffset = options.byteOffset;\n\t\tthis.decodeKind = options.decodeKind;\n\t\tthis.outcome =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AAG,OAAO,CAAC,IAAI,CAAC,CAK1D;IAEK,IAAI,CACT,cAAc,EAAE,oBAAoB,EACpC,OAAO,EAAE,yBAAyB,GAAG,kBAAkB,GACrD,OAAO,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAqCxC;YAEa,wBAAwB;YAUxB,sBAAsB;YAuBtB,uBAAuB;YAmBvB,eAAe;CAgB7B","sourcesContent":["import type {\n\tFileSystem,\n\tJsonlSessionCreateOptions,\n\tJsonlSessionListOptions,\n\tJsonlSessionMetadata,\n\tJsonlSessionRepoApi,\n\tSession,\n\tSessionForkOptions,\n\tSessionTreeEntry,\n} from \"../types.ts\";\nimport { SessionError, toError } from \"../types.ts\";\nimport { JsonlDecodeError, JsonlSessionError } from \"./jsonl-errors.ts\";\nimport {\n\ttype JsonlSessionCreationPhase,\n\ttype JsonlSessionLoadPhase,\n\tJsonlSessionStorage,\n\tloadJsonlSessionMetadata,\n} from \"./jsonl-storage.ts\";\nimport {\n\tcreateSessionId,\n\tcreateTimestamp,\n\tgetEntriesToFork,\n\tgetFileSystemResultOrThrow,\n\ttoSession,\n} from \"./repo-utils.ts\";\n\ntype JsonlSessionRepoFileSystem = Pick<\n\tFileSystem,\n\t| \"cwd\"\n\t| \"absolutePath\"\n\t| \"joinPath\"\n\t| \"readBinaryFile\"\n\t| \"readTextLines\"\n\t| \"writeFile\"\n\t| \"appendFile\"\n\t| \"renameFile\"\n\t| \"fileInfo\"\n\t| \"listDir\"\n\t| \"exists\"\n\t| \"createDir\"\n\t| \"remove\"\n>;\n\n/** Options for constructing a JSONL-backed session repository. */\nexport interface JsonlSessionRepoOptions {\n\tfs: JsonlSessionRepoFileSystem;\n\tsessionsRoot: string;\n}\n\ninterface JsonlSessionCreateDestination {\n\tid: string;\n\tcwd: string;\n}\n\nfunction canonicalClaimCwd(cwd: string): string {\n\tif (!/^[A-Za-z]:[/\\\\]/.test(cwd)) return cwd;\n\treturn `${cwd[0]!.toLowerCase()}:${cwd.slice(2).replaceAll(\"\\\\\", \"/\")}`;\n}\n\nconst SESSION_ID_PATTERN = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;\n\nfunction validateSessionId(id: string): void {\n\tif (!SESSION_ID_PATTERN.test(id)) {\n\t\tthrow new SessionError(\n\t\t\t\"invalid_session\",\n\t\t\t\"Session id must be non-empty, contain only alphanumeric characters, '-', '_', and '.', and start and end with an alphanumeric character\",\n\t\t);\n\t}\n}\n\nfunction encodeCwd(cwd: string): string {\n\treturn `--${cwd.replace(/^[/\\\\]/, \"\").replace(/[/\\\\:]/g, \"-\")}--`;\n}\n\nexport class JsonlSessionRepo implements JsonlSessionRepoApi {\n\tprivate readonly fs: JsonlSessionRepoFileSystem;\n\tprivate readonly sessionsRootInput: string;\n\tprivate readonly activeCreateDestinations = new Set<string>();\n\tprivate sessionsRoot: string | undefined;\n\n\tconstructor(options: JsonlSessionRepoOptions) {\n\t\tthis.fs = options.fs;\n\t\tthis.sessionsRootInput = options.sessionsRoot;\n\t}\n\n\tprivate async getSessionsRoot(): Promise<string> {\n\t\tif (!this.sessionsRoot) {\n\t\t\tthis.sessionsRoot = getFileSystemResultOrThrow(\n\t\t\t\tawait this.fs.absolutePath(this.sessionsRootInput),\n\t\t\t\t`Failed to resolve sessions root ${this.sessionsRootInput}`,\n\t\t\t);\n\t\t}\n\t\treturn this.sessionsRoot;\n\t}\n\n\tprivate async getSessionDir(cwd: string): Promise<string> {\n\t\treturn getFileSystemResultOrThrow(\n\t\t\tawait this.fs.joinPath([await this.getSessionsRoot(), encodeCwd(cwd)]),\n\t\t\t`Failed to resolve session directory for ${cwd}`,\n\t\t);\n\t}\n\n\tprivate async createSessionFilePath(cwd: string, sessionId: string, timestamp: string): Promise<string> {\n\t\treturn getFileSystemResultOrThrow(\n\t\t\tawait this.fs.joinPath([\n\t\t\t\tawait this.getSessionDir(cwd),\n\t\t\t\t`${timestamp.replace(/[:.]/g, \"-\")}_${sessionId}.jsonl`,\n\t\t\t]),\n\t\t\t`Failed to resolve session file path for ${sessionId}`,\n\t\t);\n\t}\n\n\tasync create(options: JsonlSessionCreateOptions): Promise<Session<JsonlSessionMetadata>> {\n\t\tconst destination = await this.resolveCreateDestination(options);\n\t\treturn this.claimCreateDestination(destination, \"create\", async () => {\n\t\t\tconst createdAt = createTimestamp();\n\t\t\tconst sessionDir = await this.getSessionDir(destination.cwd);\n\t\t\tgetFileSystemResultOrThrow(\n\t\t\t\tawait this.fs.createDir(sessionDir, { recursive: true }),\n\t\t\t\t`Failed to create session directory ${sessionDir}`,\n\t\t\t);\n\t\t\tawait this.rejectExistingSessionId(destination);\n\t\t\tconst filePath = await this.createSessionFilePath(destination.cwd, destination.id, createdAt);\n\t\t\tconst storage = await JsonlSessionStorage.create(this.fs, filePath, {\n\t\t\t\tcwd: destination.cwd,\n\t\t\t\tsessionId: destination.id,\n\t\t\t\tparentSessionPath: options.parentSessionPath,\n\t\t\t});\n\t\t\treturn toSession(storage);\n\t\t});\n\t}\n\n\tasync open(metadata: JsonlSessionMetadata): Promise<Session<JsonlSessionMetadata>> {\n\t\treturn this.openWithPhase(metadata, \"open\");\n\t}\n\n\tprivate async openWithPhase(\n\t\tmetadata: JsonlSessionMetadata,\n\t\tphase: JsonlSessionLoadPhase,\n\t): Promise<Session<JsonlSessionMetadata>> {\n\t\tif (\n\t\t\t!getFileSystemResultOrThrow(await this.fs.exists(metadata.path), `Failed to check session ${metadata.path}`)\n\t\t) {\n\t\t\tthrow new SessionError(\"not_found\", `Session not found: ${metadata.path}`);\n\t\t}\n\t\tconst storage = await JsonlSessionStorage.open(this.fs, metadata.path, phase);\n\t\tconst loadedMetadata = await storage.getMetadata();\n\t\tif (loadedMetadata.id !== metadata.id) {\n\t\t\tconst cause = new JsonlDecodeError(\n\t\t\t\t\"state\",\n\t\t\t\t`metadata id ${metadata.id} does not match file header ${loadedMetadata.id}`,\n\t\t\t);\n\t\t\tthrow new JsonlSessionError({\n\t\t\t\tcode: \"invalid_session\",\n\t\t\t\treference: metadata.path,\n\t\t\t\tphase,\n\t\t\t\tline: 1,\n\t\t\t\tbyteOffset: 0,\n\t\t\t\tdecodeKind: cause.decodeKind,\n\t\t\t\tmessage: `Session metadata id ${metadata.id} does not match file header ${loadedMetadata.id}`,\n\t\t\t\tcause,\n\t\t\t});\n\t\t}\n\t\treturn toSession(storage);\n\t}\n\n\tasync list(options: JsonlSessionListOptions = {}): Promise<JsonlSessionMetadata[]> {\n\t\tconst cwd = options.cwd\n\t\t\t? getFileSystemResultOrThrow(\n\t\t\t\t\tawait this.fs.absolutePath(options.cwd),\n\t\t\t\t\t`Failed to resolve session cwd ${options.cwd}`,\n\t\t\t\t)\n\t\t\t: undefined;\n\t\tconst dirs = cwd ? [await this.getSessionDir(cwd)] : await this.listSessionDirs();\n\t\tconst sessions: JsonlSessionMetadata[] = [];\n\t\tfor (const dir of dirs) sessions.push(...(await this.listSessionsInDir(dir, cwd)));\n\t\tsessions.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());\n\t\treturn sessions;\n\t}\n\n\tprivate async listSessionsInDir(dir: string, cwd: string | undefined): Promise<JsonlSessionMetadata[]> {\n\t\tif (!getFileSystemResultOrThrow(await this.fs.exists(dir), `Failed to check session directory ${dir}`)) {\n\t\t\treturn [];\n\t\t}\n\t\tconst files = getFileSystemResultOrThrow(await this.fs.listDir(dir), `Failed to list sessions in ${dir}`).filter(\n\t\t\t(file) => file.kind !== \"directory\" && file.name.endsWith(\".jsonl\"),\n\t\t);\n\t\tconst sessions: JsonlSessionMetadata[] = [];\n\t\tfor (const file of files) {\n\t\t\tconst metadata = await this.loadListableSessionMetadata(file.path);\n\t\t\tif (metadata && (!cwd || canonicalClaimCwd(metadata.cwd) === canonicalClaimCwd(cwd))) sessions.push(metadata);\n\t\t}\n\t\treturn sessions;\n\t}\n\n\tprivate async loadListableSessionMetadata(path: string): Promise<JsonlSessionMetadata | undefined> {\n\t\ttry {\n\t\t\treturn await loadJsonlSessionMetadata(this.fs, path);\n\t\t} catch (error) {\n\t\t\tconst cause = toError(error);\n\t\t\tif (!(cause instanceof SessionError) || cause.code !== \"invalid_session\") throw cause;\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tasync delete(metadata: JsonlSessionMetadata): Promise<void> {\n\t\tgetFileSystemResultOrThrow(\n\t\t\tawait this.fs.remove(metadata.path, { force: true }),\n\t\t\t`Failed to delete session ${metadata.path}`,\n\t\t);\n\t}\n\n\tasync fork(\n\t\tsourceMetadata: JsonlSessionMetadata,\n\t\toptions: JsonlSessionCreateOptions & SessionForkOptions,\n\t): Promise<Session<JsonlSessionMetadata>> {\n\t\tconst source = await this.openWithPhase(sourceMetadata, \"fork\");\n\t\tlet forkedEntries: SessionTreeEntry[];\n\t\ttry {\n\t\t\tforkedEntries = await getEntriesToFork(source.getStorage(), options);\n\t\t} catch (error) {\n\t\t\tconst cause = toError(error);\n\t\t\tthrow new JsonlSessionError({\n\t\t\t\tcode: cause instanceof SessionError ? cause.code : \"invalid_fork_target\",\n\t\t\t\treference: sourceMetadata.path,\n\t\t\t\tphase: \"fork\",\n\t\t\t\tmessage: cause.message,\n\t\t\t\tcause,\n\t\t\t});\n\t\t}\n\t\tconst destination = await this.resolveCreateDestination(options);\n\t\treturn this.claimCreateDestination(destination, \"fork\", async () => {\n\t\t\tconst createdAt = createTimestamp();\n\t\t\tconst sessionDir = await this.getSessionDir(destination.cwd);\n\t\t\tgetFileSystemResultOrThrow(\n\t\t\t\tawait this.fs.createDir(sessionDir, { recursive: true }),\n\t\t\t\t`Failed to create session directory ${sessionDir}`,\n\t\t\t);\n\t\t\tawait this.rejectExistingSessionId(destination, \"fork\");\n\t\t\tconst storage = await JsonlSessionStorage.create(\n\t\t\t\tthis.fs,\n\t\t\t\tawait this.createSessionFilePath(destination.cwd, destination.id, createdAt),\n\t\t\t\t{\n\t\t\t\t\tcwd: destination.cwd,\n\t\t\t\t\tsessionId: destination.id,\n\t\t\t\t\tparentSessionPath: options.parentSessionPath ?? sourceMetadata.path,\n\t\t\t\t\tentries: forkedEntries,\n\t\t\t\t\tphase: \"fork\",\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn toSession(storage);\n\t\t});\n\t}\n\n\tprivate async resolveCreateDestination(options: JsonlSessionCreateOptions): Promise<JsonlSessionCreateDestination> {\n\t\tconst id = options.id ?? createSessionId();\n\t\tvalidateSessionId(id);\n\t\tconst cwd = getFileSystemResultOrThrow(\n\t\t\tawait this.fs.absolutePath(options.cwd),\n\t\t\t`Failed to resolve session cwd ${options.cwd}`,\n\t\t);\n\t\treturn { id, cwd };\n\t}\n\n\tprivate async claimCreateDestination<T>(\n\t\tdestination: JsonlSessionCreateDestination,\n\t\tphase: JsonlSessionCreationPhase,\n\t\toperation: () => Promise<T>,\n\t): Promise<T> {\n\t\tconst key = `${canonicalClaimCwd(destination.cwd)}\\0${destination.id}`;\n\t\tif (this.activeCreateDestinations.has(key)) {\n\t\t\tthrow new JsonlSessionError({\n\t\t\t\tcode: \"already_exists\",\n\t\t\t\treference: `${destination.cwd}#${destination.id}`,\n\t\t\t\tphase,\n\t\t\t\tmessage: `Session already exists: ${destination.id}`,\n\t\t\t\toutcome: \"not_written\",\n\t\t\t});\n\t\t}\n\t\tthis.activeCreateDestinations.add(key);\n\t\ttry {\n\t\t\treturn await operation();\n\t\t} finally {\n\t\t\tthis.activeCreateDestinations.delete(key);\n\t\t}\n\t}\n\n\tprivate async rejectExistingSessionId(\n\t\tdestination: JsonlSessionCreateDestination,\n\t\tphase: JsonlSessionCreationPhase = \"create\",\n\t): Promise<void> {\n\t\tconst existing = (await this.list({ cwd: destination.cwd })).find(\n\t\t\t(session) =>\n\t\t\t\tsession.id === destination.id && canonicalClaimCwd(session.cwd) === canonicalClaimCwd(destination.cwd),\n\t\t);\n\t\tif (existing) {\n\t\t\tthrow new JsonlSessionError({\n\t\t\t\tcode: \"already_exists\",\n\t\t\t\treference: existing.path,\n\t\t\t\tphase,\n\t\t\t\tmessage: `Session already exists: ${destination.id}`,\n\t\t\t\toutcome: \"not_written\",\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate async listSessionDirs(): Promise<string[]> {\n\t\tconst sessionsRoot = await this.getSessionsRoot();\n\t\tif (\n\t\t\t!getFileSystemResultOrThrow(\n\t\t\t\tawait this.fs.exists(sessionsRoot),\n\t\t\t\t`Failed to check sessions root ${sessionsRoot}`,\n\t\t\t)\n\t\t) {\n\t\t\treturn [];\n\t\t}\n\t\tconst entries = getFileSystemResultOrThrow(\n\t\t\tawait this.fs.listDir(sessionsRoot),\n\t\t\t`Failed to list sessions root ${sessionsRoot}`,\n\t\t);\n\t\treturn entries.filter((entry) => entry.kind === \"directory\").map((entry) => entry.path);\n\t}\n}\n"]}
1
+ {"version":3,"file":"jsonl-repo.d.ts","sourceRoot":"","sources":["../../../src/harness/session/jsonl-repo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,UAAU,EACV,yBAAyB,EACzB,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,EACnB,OAAO,EACP,kBAAkB,EAElB,MAAM,aAAa,CAAC;AAiBrB,KAAK,0BAA0B,GAAG,IAAI,CACrC,UAAU,EACR,KAAK,GACL,cAAc,GACd,UAAU,GACV,gBAAgB,GAChB,eAAe,GACf,WAAW,GACX,YAAY,GACZ,YAAY,GACZ,UAAU,GACV,SAAS,GACT,QAAQ,GACR,WAAW,GACX,QAAQ,CACV,CAAC;AAEF,kEAAkE;AAClE,MAAM,WAAW,uBAAuB;IACvC,EAAE,EAAE,0BAA0B,CAAC;IAC/B,YAAY,EAAE,MAAM,CAAC;CACrB;AA2BD,qBAAa,gBAAiB,YAAW,mBAAmB;IAC3D,OAAO,CAAC,QAAQ,CAAC,EAAE,CAA6B;IAChD,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAS;IAC3C,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAqB;IAC9D,OAAO,CAAC,YAAY,CAAqB;IAEzC,YAAY,OAAO,EAAE,uBAAuB,EAG3C;YAEa,eAAe;YAUf,aAAa;YAOb,qBAAqB;IAU7B,MAAM,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAkBvF;IAEK,IAAI,CAAC,QAAQ,EAAE,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAEjF;YAEa,aAAa;IA8BrB,IAAI,CAAC,OAAO,GAAE,uBAA4B,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAYjF;YAEa,iBAAiB;YAejB,2BAA2B;IAUnC,MAAM,CAAC,QAAQ,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAK1D;IAEK,IAAI,CACT,cAAc,EAAE,oBAAoB,EACpC,OAAO,EAAE,yBAAyB,GAAG,kBAAkB,GACrD,OAAO,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAqCxC;YAEa,wBAAwB;YAUxB,sBAAsB;YAuBtB,uBAAuB;YAmBvB,eAAe;CAgB7B"}
@@ -17,11 +17,8 @@ function encodeCwd(cwd) {
17
17
  return `--${cwd.replace(/^[/\\]/, "").replace(/[/\\:]/g, "-")}--`;
18
18
  }
19
19
  export class JsonlSessionRepo {
20
- fs;
21
- sessionsRootInput;
22
- activeCreateDestinations = new Set();
23
- sessionsRoot;
24
20
  constructor(options) {
21
+ this.activeCreateDestinations = new Set();
25
22
  this.fs = options.fs;
26
23
  this.sessionsRootInput = options.sessionsRoot;
27
24
  }