@earendil-works/pi-durable 1.1.0 → 1.2.0

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 (184) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/README.md +147 -11
  3. package/dist/codemode/codemode.d.ts +173 -0
  4. package/dist/codemode/codemode.d.ts.map +1 -0
  5. package/dist/codemode/codemode.js +886 -0
  6. package/dist/codemode/codemode.js.map +1 -0
  7. package/dist/codemode/describe.d.ts +38 -0
  8. package/dist/codemode/describe.d.ts.map +1 -0
  9. package/dist/codemode/describe.js +119 -0
  10. package/dist/codemode/describe.js.map +1 -0
  11. package/dist/codemode/index.d.ts +3 -0
  12. package/dist/codemode/index.d.ts.map +1 -0
  13. package/dist/codemode/index.js +3 -0
  14. package/dist/codemode/index.js.map +1 -0
  15. package/dist/codemode/models.d.ts +28 -0
  16. package/dist/codemode/models.d.ts.map +1 -0
  17. package/dist/codemode/models.js +231 -0
  18. package/dist/codemode/models.js.map +1 -0
  19. package/dist/codemode/output.d.ts +41 -0
  20. package/dist/codemode/output.d.ts.map +1 -0
  21. package/dist/codemode/output.js +167 -0
  22. package/dist/codemode/output.js.map +1 -0
  23. package/dist/env/index.d.ts +42 -0
  24. package/dist/env/index.d.ts.map +1 -1
  25. package/dist/env/index.js.map +1 -1
  26. package/dist/errors.d.ts +20 -3
  27. package/dist/errors.d.ts.map +1 -1
  28. package/dist/errors.js +34 -5
  29. package/dist/errors.js.map +1 -1
  30. package/dist/harness/agent.d.ts +5 -2
  31. package/dist/harness/agent.d.ts.map +1 -1
  32. package/dist/harness/agent.js +69 -25
  33. package/dist/harness/agent.js.map +1 -1
  34. package/dist/harness/compaction.d.ts +6 -1
  35. package/dist/harness/compaction.d.ts.map +1 -1
  36. package/dist/harness/compaction.js +10 -7
  37. package/dist/harness/compaction.js.map +1 -1
  38. package/dist/harness/events.d.ts +35 -15
  39. package/dist/harness/events.d.ts.map +1 -1
  40. package/dist/harness/events.js +77 -23
  41. package/dist/harness/events.js.map +1 -1
  42. package/dist/harness/generation.d.ts +2 -0
  43. package/dist/harness/generation.d.ts.map +1 -1
  44. package/dist/harness/generation.js +31 -8
  45. package/dist/harness/generation.js.map +1 -1
  46. package/dist/harness/harness.d.ts +7 -0
  47. package/dist/harness/harness.d.ts.map +1 -1
  48. package/dist/harness/harness.js +53 -26
  49. package/dist/harness/harness.js.map +1 -1
  50. package/dist/harness/inbox.d.ts +16 -4
  51. package/dist/harness/inbox.d.ts.map +1 -1
  52. package/dist/harness/inbox.js +26 -3
  53. package/dist/harness/inbox.js.map +1 -1
  54. package/dist/harness/live.d.ts +74 -17
  55. package/dist/harness/live.d.ts.map +1 -1
  56. package/dist/harness/live.js +66 -14
  57. package/dist/harness/live.js.map +1 -1
  58. package/dist/harness/scheduler.d.ts +18 -5
  59. package/dist/harness/scheduler.d.ts.map +1 -1
  60. package/dist/harness/scheduler.js +696 -163
  61. package/dist/harness/scheduler.js.map +1 -1
  62. package/dist/harness/submissions.d.ts +7 -4
  63. package/dist/harness/submissions.d.ts.map +1 -1
  64. package/dist/harness/submissions.js +32 -13
  65. package/dist/harness/submissions.js.map +1 -1
  66. package/dist/harness/task-graph.d.ts +1 -1
  67. package/dist/harness/task-graph.d.ts.map +1 -1
  68. package/dist/harness/task-graph.js +15 -10
  69. package/dist/harness/task-graph.js.map +1 -1
  70. package/dist/harness/tool.d.ts +45 -5
  71. package/dist/harness/tool.d.ts.map +1 -1
  72. package/dist/harness/tool.js +377 -62
  73. package/dist/harness/tool.js.map +1 -1
  74. package/dist/harness/types.d.ts +153 -13
  75. package/dist/harness/types.d.ts.map +1 -1
  76. package/dist/harness/types.js.map +1 -1
  77. package/dist/harness/util.d.ts +6 -1
  78. package/dist/harness/util.d.ts.map +1 -1
  79. package/dist/harness/util.js +5 -2
  80. package/dist/harness/util.js.map +1 -1
  81. package/dist/harness/view.d.ts +6 -2
  82. package/dist/harness/view.d.ts.map +1 -1
  83. package/dist/harness/view.js +22 -12
  84. package/dist/harness/view.js.map +1 -1
  85. package/dist/images/cloudflare.d.ts +4 -0
  86. package/dist/images/cloudflare.d.ts.map +1 -0
  87. package/dist/images/cloudflare.js +9 -0
  88. package/dist/images/cloudflare.js.map +1 -0
  89. package/dist/images/exif.d.ts +3 -0
  90. package/dist/images/exif.d.ts.map +1 -0
  91. package/dist/images/exif.js +71 -0
  92. package/dist/images/exif.js.map +1 -0
  93. package/dist/images/index.d.ts +18 -0
  94. package/dist/images/index.d.ts.map +1 -0
  95. package/dist/images/index.js +125 -0
  96. package/dist/images/index.js.map +1 -0
  97. package/dist/images/node-worker.d.ts +17 -0
  98. package/dist/images/node-worker.d.ts.map +1 -0
  99. package/dist/images/node-worker.js +16 -0
  100. package/dist/images/node-worker.js.map +1 -0
  101. package/dist/images/node.d.ts +21 -0
  102. package/dist/images/node.d.ts.map +1 -0
  103. package/dist/images/node.js +121 -0
  104. package/dist/images/node.js.map +1 -0
  105. package/dist/index.d.ts +6 -6
  106. package/dist/index.d.ts.map +1 -1
  107. package/dist/index.js +3 -3
  108. package/dist/index.js.map +1 -1
  109. package/dist/search.d.ts +13 -0
  110. package/dist/search.d.ts.map +1 -0
  111. package/dist/search.js +85 -0
  112. package/dist/search.js.map +1 -0
  113. package/dist/session/observation.d.ts +10 -3
  114. package/dist/session/observation.d.ts.map +1 -1
  115. package/dist/session/observation.js +24 -34
  116. package/dist/session/observation.js.map +1 -1
  117. package/dist/session/session.d.ts +68 -5
  118. package/dist/session/session.d.ts.map +1 -1
  119. package/dist/session/session.js +461 -49
  120. package/dist/session/session.js.map +1 -1
  121. package/dist/session/transaction.d.ts.map +1 -1
  122. package/dist/session/transaction.js +1 -0
  123. package/dist/session/transaction.js.map +1 -1
  124. package/dist/storage/jsonl/storage.d.ts +4 -0
  125. package/dist/storage/jsonl/storage.d.ts.map +1 -1
  126. package/dist/storage/jsonl/storage.js +2 -1
  127. package/dist/storage/jsonl/storage.js.map +1 -1
  128. package/dist/storage/memory.d.ts.map +1 -1
  129. package/dist/storage/memory.js +8 -10
  130. package/dist/storage/memory.js.map +1 -1
  131. package/dist/storage/scan.d.ts.map +1 -1
  132. package/dist/storage/scan.js +5 -4
  133. package/dist/storage/scan.js.map +1 -1
  134. package/dist/storage/sqlite/storage.d.ts.map +1 -1
  135. package/dist/storage/sqlite/storage.js +10 -12
  136. package/dist/storage/sqlite/storage.js.map +1 -1
  137. package/dist/testing/env-conformance.d.ts.map +1 -1
  138. package/dist/testing/env-conformance.js +100 -0
  139. package/dist/testing/env-conformance.js.map +1 -1
  140. package/dist/testing/runner.d.ts +1 -1
  141. package/dist/testing/runner.d.ts.map +1 -1
  142. package/dist/testing/runner.js.map +1 -1
  143. package/dist/testing/storage-conformance.d.ts.map +1 -1
  144. package/dist/testing/storage-conformance.js +3 -2
  145. package/dist/testing/storage-conformance.js.map +1 -1
  146. package/dist/testing/types.d.ts +2 -0
  147. package/dist/testing/types.d.ts.map +1 -1
  148. package/dist/testing/types.js.map +1 -1
  149. package/dist/tool-search/index.d.ts +2 -0
  150. package/dist/tool-search/index.d.ts.map +1 -0
  151. package/dist/tool-search/index.js +2 -0
  152. package/dist/tool-search/index.js.map +1 -0
  153. package/dist/tool-search/tool-search.d.ts +23 -0
  154. package/dist/tool-search/tool-search.d.ts.map +1 -0
  155. package/dist/tool-search/tool-search.js +84 -0
  156. package/dist/tool-search/tool-search.js.map +1 -0
  157. package/dist/tools/bash.d.ts +10 -2
  158. package/dist/tools/bash.d.ts.map +1 -1
  159. package/dist/tools/bash.js +27 -9
  160. package/dist/tools/bash.js.map +1 -1
  161. package/dist/tools/edit.js +1 -1
  162. package/dist/tools/edit.js.map +1 -1
  163. package/dist/tools/image-processor.d.ts +47 -0
  164. package/dist/tools/image-processor.d.ts.map +1 -0
  165. package/dist/tools/image-processor.js +30 -0
  166. package/dist/tools/image-processor.js.map +1 -0
  167. package/dist/tools/image.d.ts +8 -0
  168. package/dist/tools/image.d.ts.map +1 -1
  169. package/dist/tools/image.js +47 -0
  170. package/dist/tools/image.js.map +1 -1
  171. package/dist/tools/index.d.ts +25 -2
  172. package/dist/tools/index.d.ts.map +1 -1
  173. package/dist/tools/index.js +13 -5
  174. package/dist/tools/index.js.map +1 -1
  175. package/dist/tools/read.d.ts +10 -2
  176. package/dist/tools/read.d.ts.map +1 -1
  177. package/dist/tools/read.js +87 -28
  178. package/dist/tools/read.js.map +1 -1
  179. package/dist/tools/write.js +1 -1
  180. package/dist/tools/write.js.map +1 -1
  181. package/dist/types.d.ts +59 -5
  182. package/dist/types.d.ts.map +1 -1
  183. package/dist/types.js.map +1 -1
  184. package/package.json +43 -4
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/env/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAErD,wFAAwF;AACxF,MAAM,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,IAAI;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhG,wBAAgB,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAExE;AAED,wBAAgB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAEzE;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAGjF;AAED,wBAAgB,cAAc,CAAC,MAAM,SAAS,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,GAAG,SAAS,CAEhH;A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,CAAC,CAAC,CAAC;IACjC,CAAC;AACF,CAAC;AAcD,MAAM,OAAO,SAAU,SAAQ,KAAK;IAC5B,IAAI,CAAgB;IACpB,IAAI,CAAU;IAErB,YAAY,IAAmB,EAAE,OAAe,EAAE,IAAa,EAAE,KAAa;QAC7E,KAAK,CAAC,OAAO,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAClB,CAAC;CACD;AAUD,MAAM,OAAO,cAAe,SAAQ,KAAK;IACjC,IAAI,CAAqB;IAChC,2GAA2G;IACpG,SAAS,CAAU;IAE1B,YAAY,IAAwB,EAAE,OAAe,EAAE,KAAa;QACnE,KAAK,CAAC,OAAO,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAClB,CAAC;CACD;AA2PD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["import type { Context } from \"@earendil-works/chord\";\n\n/** Result of a fallible operation. Expected failures are returned instead of thrown. */\nexport type Result<TValue, TError> = { ok: true; value: TValue } | { ok: false; error: TError };\n\nexport function ok<TValue, TError>(value: TValue): Result<TValue, TError> {\n\treturn { ok: true, value };\n}\n\nexport function err<TValue, TError>(error: TError): Result<TValue, TError> {\n\treturn { ok: false, error };\n}\n\nexport function getOrThrow<TValue, TError>(result: Result<TValue, TError>): TValue {\n\tif (!result.ok) throw result.error;\n\treturn result.value;\n}\n\nexport function getOrUndefined<TValue extends object, TError>(result: Result<TValue, TError>): TValue | undefined {\n\treturn result.ok ? result.value : undefined;\n}\n\nexport function toError(error: unknown): Error {\n\tif (error instanceof Error) return error;\n\tif (typeof error === \"string\") return new Error(error);\n\ttry {\n\t\treturn new Error(JSON.stringify(error));\n\t} catch {\n\t\treturn new Error(String(error));\n\t}\n}\n\nexport type FileKind = \"file\" | \"directory\" | \"symlink\";\n\nexport type FileErrorCode =\n\t| \"aborted\"\n\t| \"not_found\"\n\t| \"permission_denied\"\n\t| \"not_directory\"\n\t| \"is_directory\"\n\t| \"invalid\"\n\t| \"not_supported\"\n\t| \"unknown\";\n\nexport class FileError extends Error {\n\tpublic code: FileErrorCode;\n\tpublic path?: string;\n\n\tconstructor(code: FileErrorCode, message: string, path?: string, cause?: Error) {\n\t\tsuper(message, cause === undefined ? undefined : { cause });\n\t\tthis.name = \"FileError\";\n\t\tthis.code = code;\n\t\tthis.path = path;\n\t}\n}\n\nexport type ExecutionErrorCode =\n\t| \"aborted\"\n\t| \"timeout\"\n\t| \"shell_unavailable\"\n\t| \"spawn_error\"\n\t| \"callback_error\"\n\t| \"unknown\";\n\nexport class ExecutionError extends Error {\n\tpublic code: ExecutionErrorCode;\n\t/** Spill file of a command that timed out or was aborted after its output crossed the spill thresholds. */\n\tpublic spillPath?: string;\n\n\tconstructor(code: ExecutionErrorCode, message: string, cause?: Error) {\n\t\tsuper(message, cause === undefined ? undefined : { cause });\n\t\tthis.name = \"ExecutionError\";\n\t\tthis.code = code;\n\t}\n}\n\nexport interface FileInfo {\n\tname: string;\n\tpath: string;\n\tkind: FileKind;\n\tsize: number;\n\tmtimeMs: number;\n}\n\nexport interface TextLine {\n\ttext: string;\n\tterminated: boolean;\n}\n\nexport interface TextLineReader {\n\treadLine(context: Context): Promise<Result<TextLine | undefined, FileError>>;\n\tclose(context: Context): Promise<void>;\n}\n\n/** Positional reads from one opened regular file; all calls see the same file even if its path is renamed. */\nexport interface BinaryReader {\n\t/** Metadata of the opened file, not of whatever its path names now. */\n\tinfo(context: Context): Promise<Result<FileInfo, FileError>>;\n\t/** Up to `length` bytes at `offset`; fewer only at end of file. */\n\tread(offset: number, length: number, context: Context): Promise<Result<Uint8Array, FileError>>;\n\t/**\n\t * One pass over the file that locates lines `[startLine, endLine)` (`endLine` absent: to the end), 0-based, where line\n\t * `k` starts after the `k`-th newline byte. Decoded sizes are those of the text `new TextDecoder().decode(file)` would\n\t * produce for that range, so a byte-order mark at the start of the file is not counted.\n\t */\n\tscanLines(options: { startLine: number; endLine?: number }, context: Context): Promise<Result<LineScan, FileError>>;\n\tclose(context: Context): Promise<void>;\n}\n\n/** A file or directory to watch. It may be missing; creating it is a change. */\nexport interface WatchTarget {\n\tpath: string;\n\t/** Watch everything below a directory, not only its entries. Symbolic links below it are not followed. */\n\trecursive?: boolean;\n\t/** Entries below `path` that are neither watched nor reported: names starting with `.`, or these names. */\n\texclude?: { hidden?: boolean; names?: readonly string[] };\n}\n\n/**\n * What changed:\n * - `paths`: something at or below each path may have changed (a directory path covers its whole subtree). Calls may be\n * spurious; a change is never missed while the watcher is healthy.\n * - `overflow`: coverage was uncertain for a while (lost events, reconnect); rescan everything that is watched.\n * - `error`: the watcher stopped, for example because the watched tree grew past the environment's limit; no calls\n * follow.\n */\nexport type WatchChange = { paths: string[] } | { overflow: true } | { error: FileError };\n\nexport interface FileWatcher {\n\t/**\n\t * `native`: changes are reported within about two seconds. `polling`: the environment compares snapshots, because\n\t * the file system does not report changes reliably (network and FUSE file systems); a change undone between two\n\t * snapshots can be missed.\n\t */\n\treadonly mode: \"native\" | \"polling\";\n\t/** Stop watching; no `onChange` call starts after this resolves. Idempotent. */\n\tclose(context: Context): Promise<void>;\n}\n\n/** Where lines of a file are, as `BinaryReader.scanLines` found them. */\nexport interface LineScan {\n\t/** Newline bytes in the whole file; it has `newlines + 1` lines. */\n\tnewlines: number;\n\t/**\n\t * Byte range of the selected lines: from the start of the first to the end of the last, without the newline that\n\t * ends it. A selection past the last line is empty at the end of the file.\n\t */\n\tstart: number;\n\tend: number;\n\t/** Where the first selected line ends: its newline, or the end of the file. */\n\tfirstLineEnd: number;\n\t/** Where the last selected line starts. */\n\tlastLineStart: number;\n\t/** UTF-8 byte length of the decoded selection and of its first line. */\n\tselectedBytes: number;\n\tfirstLineBytes: number;\n}\n\n/** Pages of one directory's entries. */\nexport interface DirReader {\n\t/**\n\t * Up to `maxEntries` entries in the order the file system returns them, continuing where the previous call stopped.\n\t * `done` marks the end; it may come with the last entries or with an empty page. An entry that disappears before its\n\t * metadata is read is skipped, as are entries of unsupported kinds. After a failed or aborted call, close the reader.\n\t */\n\tnext(maxEntries: number, context: Context): Promise<Result<{ entries: FileInfo[]; done: boolean }, FileError>>;\n\tclose(context: Context): Promise<void>;\n}\n\n/** Portable filesystem capability. Operations return failures rather than throwing. */\nexport interface FileSystem {\n\t/**\n\t * The file namespace: equal ids see the same files at the same paths, whatever their `cwd`. Every local Node\n\t * environment shares one id; each container or remote host has its own.\n\t */\n\treadonly id: string;\n\tcwd: string;\n\tabsolutePath(path: string, context: Context): Promise<Result<string, FileError>>;\n\tjoinPath(parts: string[], context: Context): Promise<Result<string, FileError>>;\n\treadTextFile(path: string, context: Context): Promise<Result<string, FileError>>;\n\topenTextLineReader(path: string, context: Context): Promise<Result<TextLineReader, FileError>>;\n\treadTextLines(\n\t\tpath: string,\n\t\toptions: { maxLines?: number } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<string[], FileError>>;\n\treadBinaryFile(path: string, context: Context): Promise<Result<Uint8Array, FileError>>;\n\t/**\n\t * Open a regular file for bounded positional reads. A directory fails with `is_directory`, other non-regular files\n\t * with `invalid`. With `noFollow`, a symbolic link as the final path component fails with `invalid` instead of being\n\t * followed; earlier components are still resolved.\n\t */\n\topenBinaryReader(\n\t\tpath: string,\n\t\toptions: { noFollow?: boolean } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<BinaryReader, FileError>>;\n\twriteFile(path: string, content: string | Uint8Array, context: Context): Promise<Result<void, FileError>>;\n\tappendFile(path: string, content: string | Uint8Array, context: Context): Promise<Result<void, FileError>>;\n\t/** Truncate or extend a file to exactly `size` bytes. */\n\ttruncateFile(path: string, size: number, context: Context): Promise<Result<void, FileError>>;\n\t/** Flush file contents and metadata needed to retrieve them from an open file handle. */\n\tflushFile(path: string, context: Context): Promise<Result<void, FileError>>;\n\trenameFile(sourcePath: string, destinationPath: string, context: Context): Promise<Result<void, FileError>>;\n\tfileInfo(path: string, context: Context): Promise<Result<FileInfo, FileError>>;\n\tlistDir(path: string, context: Context): Promise<Result<FileInfo[], FileError>>;\n\topenDirReader(path: string, context: Context): Promise<Result<DirReader, FileError>>;\n\t/**\n\t * Report changes to files and directories, for hosts that load resources from the environment. When the returned\n\t * watcher exists, coverage is established: a host that watches before it loads cannot miss a change made during the\n\t * load. See `WatchChange` for what is reported and `FileWatcher.mode` for how reliably.\n\t */\n\twatch(\n\t\ttargets: readonly WatchTarget[],\n\t\tonChange: (change: WatchChange) => void,\n\t\tcontext: Context,\n\t): Promise<Result<FileWatcher, FileError>>;\n\tcanonicalPath(path: string, context: Context): Promise<Result<string, FileError>>;\n\texists(path: string, context: Context): Promise<Result<boolean, FileError>>;\n\tcreateDir(\n\t\tpath: string,\n\t\toptions: { recursive?: boolean } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<void, FileError>>;\n\tremove(\n\t\tpath: string,\n\t\toptions: { recursive?: boolean; force?: boolean } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<void, FileError>>;\n\tcreateTempDir(prefix: string | undefined, context: Context): Promise<Result<string, FileError>>;\n\tcreateTempFile(\n\t\toptions: { prefix?: string; suffix?: string } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<string, FileError>>;\n\tcleanup(context: Context): Promise<void>;\n}\n\n/** Spill the complete output to a temporary file once it exceeds either threshold. */\nexport interface ShellSpillOptions {\n\tafterBytes: number;\n\t/** Complete or partial lines. */\n\tafterLines: number;\n}\n\nexport interface ShellExecResult {\n\texitCode: number;\n\t/** Temporary file holding the complete raw output, when the spill thresholds were exceeded. */\n\tspillPath?: string;\n}\n\nexport interface ShellExecOptions {\n\tcwd?: string;\n\tenv?: Record<string, string>;\n\tinheritEnv?: boolean;\n\ttimeout?: number;\n\t/**\n\t * Every decoded chunk of stdout and stderr as it arrives, in arrival order, with the stream it came from: raw,\n\t * unbounded, and unthrottled. Each stream is decoded separately, so a character split across chunks survives.\n\t */\n\tonOutput?: (text: string, context: Context, info: ShellOutputInfo) => void;\n\tspill?: ShellSpillOptions;\n\t/**\n\t * The caller keeps only this tail of the output, so the environment may omit output outside it and report the omission\n\t * as `info.skipped`. Without it, every chunk is delivered.\n\t */\n\twindow?: ShellOutputWindow;\n}\n\n/**\n * The tail of the combined output a caller keeps, and how often it samples it. An environment that transfers output\n * over a slow link uses it to omit what the caller would drop anyway and to send no faster than the caller commits.\n */\nexport interface ShellOutputWindow {\n\t/** UTF-8 bytes of decoded text kept at the end of the output. */\n\tmaxBytes: number;\n\t/** Lines kept at the end of the output. */\n\tmaxLines: number;\n\t/** Minimum pause between the caller's samples of the output. */\n\tminIntervalMs: number;\n\t/** Each sample also pauses the caller in proportion to its size at this rate. */\n\tbytesPerSecond: number;\n}\n\n/**\n * Output an environment omitted, measured on the decoded text `onOutput` would have received: every U+FFFD counts as\n * three bytes, and no sanitizing is applied.\n */\nexport interface ShellOutputSkip {\n\t/** UTF-8 byte length of the omitted text. */\n\tbytes: number;\n\t/** Newlines (U+000A) in the omitted text. */\n\tnewlines: number;\n\t/** Whether the omitted text ends with a newline. */\n\tendsWithNewline: boolean;\n}\n\nexport interface ShellOutputInfo {\n\tstream: \"stdout\" | \"stderr\";\n\t/**\n\t * Output omitted immediately before this chunk, only with `window`. The chunk then holds all output after the\n\t * omission up to its end, and that is more than the window by at least one byte or one line: more than\n\t * `window.maxBytes` bytes or more than `window.maxLines` newlines. So the omitted text can never be in the kept tail.\n\t * The omission and such a chunk may span both streams in arrival order; `stream` then names the chunk's last stream.\n\t * Callers that need the streams apart do not pass `window`.\n\t */\n\tskipped?: ShellOutputSkip;\n}\n\nexport interface Shell {\n\t/**\n\t * Run a command. A string runs through the environment's shell. An array runs `command[0]` directly with the rest\n\t * as its arguments, without a shell, so they reach the program unparsed. Aborting the context or a timeout kills\n\t * only this command's processes.\n\t */\n\texec(\n\t\tcommand: string | readonly string[],\n\t\toptions: ShellExecOptions | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<ShellExecResult, ExecutionError>>;\n\t/** Kill every command this environment still runs; for its owner's shutdown, never for one request. */\n\tcleanup(context: Context): Promise<void>;\n}\n\nexport interface ExecutionEnv extends FileSystem, Shell {}\n\nexport { rangeDecoder, StreamDecoder, startsWithBom } from \"./decode.ts\";\nexport { LineScanner } from \"./line-scan.ts\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/env/index.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,EAAE,CAAiB,KAAa;IAC/C,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,GAAG,CAAiB,KAAa;IAChD,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,UAAU,CAAiB,MAA8B;IACxE,IAAI,CAAC,MAAM,CAAC,EAAE;QAAE,MAAM,MAAM,CAAC,KAAK,CAAC;IACnC,OAAO,MAAM,CAAC,KAAK,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,cAAc,CAAgC,MAA8B;IAC3F,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,KAAc;IACrC,IAAI,KAAK,YAAY,KAAK;QAAE,OAAO,KAAK,CAAC;IACzC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;IACvD,IAAI,CAAC;QACJ,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;IACzC,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACjC,CAAC;AACF,CAAC;AAcD,MAAM,OAAO,SAAU,SAAQ,KAAK;IAC5B,IAAI,CAAgB;IACpB,IAAI,CAAU;IAErB,YAAY,IAAmB,EAAE,OAAe,EAAE,IAAa,EAAE,KAAa;QAC7E,KAAK,CAAC,OAAO,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAClB,CAAC;CACD;AAUD,MAAM,OAAO,cAAe,SAAQ,KAAK;IACjC,IAAI,CAAqB;IAChC,2GAA2G;IACpG,SAAS,CAAU;IAE1B,YAAY,IAAwB,EAAE,OAAe,EAAE,KAAa;QACnE,KAAK,CAAC,OAAO,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAClB,CAAC;CACD;AA4SD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["import type { Context } from \"@earendil-works/chord\";\n\n/** Result of a fallible operation. Expected failures are returned instead of thrown. */\nexport type Result<TValue, TError> = { ok: true; value: TValue } | { ok: false; error: TError };\n\nexport function ok<TValue, TError>(value: TValue): Result<TValue, TError> {\n\treturn { ok: true, value };\n}\n\nexport function err<TValue, TError>(error: TError): Result<TValue, TError> {\n\treturn { ok: false, error };\n}\n\nexport function getOrThrow<TValue, TError>(result: Result<TValue, TError>): TValue {\n\tif (!result.ok) throw result.error;\n\treturn result.value;\n}\n\nexport function getOrUndefined<TValue extends object, TError>(result: Result<TValue, TError>): TValue | undefined {\n\treturn result.ok ? result.value : undefined;\n}\n\nexport function toError(error: unknown): Error {\n\tif (error instanceof Error) return error;\n\tif (typeof error === \"string\") return new Error(error);\n\ttry {\n\t\treturn new Error(JSON.stringify(error));\n\t} catch {\n\t\treturn new Error(String(error));\n\t}\n}\n\nexport type FileKind = \"file\" | \"directory\" | \"symlink\";\n\nexport type FileErrorCode =\n\t| \"aborted\"\n\t| \"not_found\"\n\t| \"permission_denied\"\n\t| \"not_directory\"\n\t| \"is_directory\"\n\t| \"invalid\"\n\t| \"not_supported\"\n\t| \"unknown\";\n\nexport class FileError extends Error {\n\tpublic code: FileErrorCode;\n\tpublic path?: string;\n\n\tconstructor(code: FileErrorCode, message: string, path?: string, cause?: Error) {\n\t\tsuper(message, cause === undefined ? undefined : { cause });\n\t\tthis.name = \"FileError\";\n\t\tthis.code = code;\n\t\tthis.path = path;\n\t}\n}\n\nexport type ExecutionErrorCode =\n\t| \"aborted\"\n\t| \"timeout\"\n\t| \"shell_unavailable\"\n\t| \"spawn_error\"\n\t| \"callback_error\"\n\t| \"unknown\";\n\nexport class ExecutionError extends Error {\n\tpublic code: ExecutionErrorCode;\n\t/** Spill file of a command that timed out or was aborted after its output crossed the spill thresholds. */\n\tpublic spillPath?: string;\n\n\tconstructor(code: ExecutionErrorCode, message: string, cause?: Error) {\n\t\tsuper(message, cause === undefined ? undefined : { cause });\n\t\tthis.name = \"ExecutionError\";\n\t\tthis.code = code;\n\t}\n}\n\nexport interface FileInfo {\n\tname: string;\n\tpath: string;\n\tkind: FileKind;\n\tsize: number;\n\tmtimeMs: number;\n}\n\nexport interface TextLine {\n\ttext: string;\n\tterminated: boolean;\n}\n\nexport interface TextLineReader {\n\treadLine(context: Context): Promise<Result<TextLine | undefined, FileError>>;\n\tclose(context: Context): Promise<void>;\n}\n\n/** Positional reads from one opened regular file; all calls see the same file even if its path is renamed. */\nexport interface BinaryReader {\n\t/** Metadata of the opened file, not of whatever its path names now. */\n\tinfo(context: Context): Promise<Result<FileInfo, FileError>>;\n\t/** Up to `length` bytes at `offset`; fewer only at end of file. */\n\tread(offset: number, length: number, context: Context): Promise<Result<Uint8Array, FileError>>;\n\t/**\n\t * One pass over the file that locates lines `[startLine, endLine)` (`endLine` absent: to the end), 0-based, where line\n\t * `k` starts after the `k`-th newline byte. Decoded sizes are those of the text `new TextDecoder().decode(file)` would\n\t * produce for that range, so a byte-order mark at the start of the file is not counted.\n\t */\n\tscanLines(options: { startLine: number; endLine?: number }, context: Context): Promise<Result<LineScan, FileError>>;\n\tclose(context: Context): Promise<void>;\n}\n\n/** A file or directory to watch. It may be missing; creating it is a change. */\nexport interface WatchTarget {\n\tpath: string;\n\t/** Watch everything below a directory, not only its entries. Symbolic links below it are not followed. */\n\trecursive?: boolean;\n\t/** Entries below `path` that are neither watched nor reported: names starting with `.`, or these names. */\n\texclude?: { hidden?: boolean; names?: readonly string[] };\n}\n\n/**\n * What changed:\n * - `paths`: something at or below each path may have changed (a directory path covers its whole subtree). Calls may be\n * spurious; a change is never missed while the watcher is healthy.\n * - `overflow`: coverage was uncertain for a while (lost events, reconnect); rescan everything that is watched.\n * - `error`: the watcher stopped, for example because the watched tree grew past the environment's limit; no calls\n * follow.\n */\nexport type WatchChange = { paths: string[] } | { overflow: true } | { error: FileError };\n\nexport interface FileWatcher {\n\t/**\n\t * `native`: changes are reported within about two seconds. `polling`: the environment compares snapshots, because\n\t * the file system does not report changes reliably (network and FUSE file systems); a change undone between two\n\t * snapshots can be missed.\n\t */\n\treadonly mode: \"native\" | \"polling\";\n\t/** Stop watching; no `onChange` call starts after this resolves. Idempotent. */\n\tclose(context: Context): Promise<void>;\n}\n\n/** Where lines of a file are, as `BinaryReader.scanLines` found them. */\nexport interface LineScan {\n\t/** Newline bytes in the whole file; it has `newlines + 1` lines. */\n\tnewlines: number;\n\t/**\n\t * Byte range of the selected lines: from the start of the first to the end of the last, without the newline that\n\t * ends it. A selection past the last line is empty at the end of the file.\n\t */\n\tstart: number;\n\tend: number;\n\t/** Where the first selected line ends: its newline, or the end of the file. */\n\tfirstLineEnd: number;\n\t/** Where the last selected line starts. */\n\tlastLineStart: number;\n\t/** UTF-8 byte length of the decoded selection and of its first line. */\n\tselectedBytes: number;\n\tfirstLineBytes: number;\n}\n\n/** Pages of one directory's entries. */\nexport interface DirReader {\n\t/**\n\t * Up to `maxEntries` entries in the order the file system returns them, continuing where the previous call stopped.\n\t * `done` marks the end; it may come with the last entries or with an empty page. An entry that disappears before its\n\t * metadata is read is skipped, as are entries of unsupported kinds. After a failed or aborted call, close the reader.\n\t */\n\tnext(maxEntries: number, context: Context): Promise<Result<{ entries: FileInfo[]; done: boolean }, FileError>>;\n\tclose(context: Context): Promise<void>;\n}\n\n/** What `FileSystem.listFiles` lists. */\nexport interface ListFilesOptions {\n\t/**\n\t * Include names starting with `.` (on Windows also files with the hidden attribute); default true. Entries named\n\t * `.git` are never listed.\n\t */\n\thidden?: boolean;\n\t/**\n\t * Inside a git work tree, skip what git ignores: the `.gitignore` files of the directory, its subdirectories and its\n\t * parents, `.git/info/exclude`, and the global excludes file; default true. Unlike `git ls-files`, a tracked file that\n\t * matches an ignore rule is skipped too. Outside work trees, `.gitignore` files have no effect.\n\t */\n\tgitignore?: boolean;\n\t/** Names of entries to skip with everything below them, such as `node_modules`. */\n\texclude?: readonly string[];\n\t/** Most entries to list; default 50 000. */\n\tmaxEntries?: number;\n\t/** Most bytes of the listing: each entry's UTF-8 path plus two; default 4 MiB, at most 15.9 MiB. */\n\tmaxBytes?: number;\n\t/** Time after which the listing stops; default 10 000 ms. */\n\ttimeoutMs?: number;\n}\n\n/** One entry of a `FileListing`. */\nexport interface FileListEntry {\n\t/** Relative to the listed directory, with `/` separators on every system. */\n\tpath: string;\n\t/** A symbolic link is listed as such and not followed. */\n\tkind: FileKind;\n}\n\nexport interface FileListing {\n\t/** Depth first, parents before their entries, siblings in byte order of their names. */\n\tentries: FileListEntry[];\n\t/** A bound in `ListFilesOptions` ended the listing early. */\n\ttruncated: boolean;\n}\n\n/** Portable filesystem capability. Operations return failures rather than throwing. */\nexport interface FileSystem {\n\t/**\n\t * The file namespace: equal ids see the same files at the same paths, whatever their `cwd`. Every local Node\n\t * environment shares one id; each container or remote host has its own.\n\t */\n\treadonly id: string;\n\tcwd: string;\n\tabsolutePath(path: string, context: Context): Promise<Result<string, FileError>>;\n\tjoinPath(parts: string[], context: Context): Promise<Result<string, FileError>>;\n\treadTextFile(path: string, context: Context): Promise<Result<string, FileError>>;\n\topenTextLineReader(path: string, context: Context): Promise<Result<TextLineReader, FileError>>;\n\treadTextLines(\n\t\tpath: string,\n\t\toptions: { maxLines?: number } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<string[], FileError>>;\n\treadBinaryFile(path: string, context: Context): Promise<Result<Uint8Array, FileError>>;\n\t/**\n\t * Open a regular file for bounded positional reads. A directory fails with `is_directory`, other non-regular files\n\t * with `invalid`. With `noFollow`, a symbolic link as the final path component fails with `invalid` instead of being\n\t * followed; earlier components are still resolved.\n\t */\n\topenBinaryReader(\n\t\tpath: string,\n\t\toptions: { noFollow?: boolean } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<BinaryReader, FileError>>;\n\twriteFile(path: string, content: string | Uint8Array, context: Context): Promise<Result<void, FileError>>;\n\tappendFile(path: string, content: string | Uint8Array, context: Context): Promise<Result<void, FileError>>;\n\t/** Truncate or extend a file to exactly `size` bytes. */\n\ttruncateFile(path: string, size: number, context: Context): Promise<Result<void, FileError>>;\n\t/** Flush file contents and metadata needed to retrieve them from an open file handle. */\n\tflushFile(path: string, context: Context): Promise<Result<void, FileError>>;\n\trenameFile(sourcePath: string, destinationPath: string, context: Context): Promise<Result<void, FileError>>;\n\tfileInfo(path: string, context: Context): Promise<Result<FileInfo, FileError>>;\n\tlistDir(path: string, context: Context): Promise<Result<FileInfo[], FileError>>;\n\t/**\n\t * Optional: the files, directories and symbolic links below a directory, at any depth, for indexes such as file\n\t * completion. Symbolic links are not followed; other kinds of files are not listed; entries that cannot be read are\n\t * skipped. See `ListFilesOptions` for hidden and ignored files and for the bounds. Fails with `not_supported` when\n\t * the environment cannot list right now (an older remote daemon), so callers fall back to their own walk.\n\t */\n\tlistFiles?(\n\t\tpath: string,\n\t\toptions: ListFilesOptions | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<FileListing, FileError>>;\n\topenDirReader(path: string, context: Context): Promise<Result<DirReader, FileError>>;\n\t/**\n\t * Report changes to files and directories, for hosts that load resources from the environment. When the returned\n\t * watcher exists, coverage is established: a host that watches before it loads cannot miss a change made during the\n\t * load. See `WatchChange` for what is reported and `FileWatcher.mode` for how reliably.\n\t */\n\twatch(\n\t\ttargets: readonly WatchTarget[],\n\t\tonChange: (change: WatchChange) => void,\n\t\tcontext: Context,\n\t): Promise<Result<FileWatcher, FileError>>;\n\tcanonicalPath(path: string, context: Context): Promise<Result<string, FileError>>;\n\texists(path: string, context: Context): Promise<Result<boolean, FileError>>;\n\tcreateDir(\n\t\tpath: string,\n\t\toptions: { recursive?: boolean } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<void, FileError>>;\n\tremove(\n\t\tpath: string,\n\t\toptions: { recursive?: boolean; force?: boolean } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<void, FileError>>;\n\tcreateTempDir(prefix: string | undefined, context: Context): Promise<Result<string, FileError>>;\n\tcreateTempFile(\n\t\toptions: { prefix?: string; suffix?: string } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<string, FileError>>;\n\tcleanup(context: Context): Promise<void>;\n}\n\n/** Spill the complete output to a temporary file once it exceeds either threshold. */\nexport interface ShellSpillOptions {\n\tafterBytes: number;\n\t/** Complete or partial lines. */\n\tafterLines: number;\n}\n\nexport interface ShellExecResult {\n\texitCode: number;\n\t/** Temporary file holding the complete raw output, when the spill thresholds were exceeded. */\n\tspillPath?: string;\n}\n\nexport interface ShellExecOptions {\n\tcwd?: string;\n\tenv?: Record<string, string>;\n\tinheritEnv?: boolean;\n\ttimeout?: number;\n\t/**\n\t * Every decoded chunk of stdout and stderr as it arrives, in arrival order, with the stream it came from: raw,\n\t * unbounded, and unthrottled. Each stream is decoded separately, so a character split across chunks survives.\n\t */\n\tonOutput?: (text: string, context: Context, info: ShellOutputInfo) => void;\n\tspill?: ShellSpillOptions;\n\t/**\n\t * The caller keeps only this tail of the output, so the environment may omit output outside it and report the omission\n\t * as `info.skipped`. Without it, every chunk is delivered.\n\t */\n\twindow?: ShellOutputWindow;\n}\n\n/**\n * The tail of the combined output a caller keeps, and how often it samples it. An environment that transfers output\n * over a slow link uses it to omit what the caller would drop anyway and to send no faster than the caller commits.\n */\nexport interface ShellOutputWindow {\n\t/** UTF-8 bytes of decoded text kept at the end of the output. */\n\tmaxBytes: number;\n\t/** Lines kept at the end of the output. */\n\tmaxLines: number;\n\t/** Minimum pause between the caller's samples of the output. */\n\tminIntervalMs: number;\n\t/** Each sample also pauses the caller in proportion to its size at this rate. */\n\tbytesPerSecond: number;\n}\n\n/**\n * Output an environment omitted, measured on the decoded text `onOutput` would have received: every U+FFFD counts as\n * three bytes, and no sanitizing is applied.\n */\nexport interface ShellOutputSkip {\n\t/** UTF-8 byte length of the omitted text. */\n\tbytes: number;\n\t/** Newlines (U+000A) in the omitted text. */\n\tnewlines: number;\n\t/** Whether the omitted text ends with a newline. */\n\tendsWithNewline: boolean;\n}\n\nexport interface ShellOutputInfo {\n\tstream: \"stdout\" | \"stderr\";\n\t/**\n\t * Output omitted immediately before this chunk, only with `window`. The chunk then holds all output after the\n\t * omission up to its end, and that is more than the window by at least one byte or one line: more than\n\t * `window.maxBytes` bytes or more than `window.maxLines` newlines. So the omitted text can never be in the kept tail.\n\t * The omission and such a chunk may span both streams in arrival order; `stream` then names the chunk's last stream.\n\t * Callers that need the streams apart do not pass `window`.\n\t */\n\tskipped?: ShellOutputSkip;\n}\n\nexport interface Shell {\n\t/**\n\t * Run a command. A string runs through the environment's shell. An array runs `command[0]` directly with the rest\n\t * as its arguments, without a shell, so they reach the program unparsed. Aborting the context or a timeout kills\n\t * only this command's processes.\n\t */\n\texec(\n\t\tcommand: string | readonly string[],\n\t\toptions: ShellExecOptions | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<ShellExecResult, ExecutionError>>;\n\t/** Kill every command this environment still runs; for its owner's shutdown, never for one request. */\n\tcleanup(context: Context): Promise<void>;\n}\n\nexport interface ExecutionEnv extends FileSystem, Shell {}\n\nexport { rangeDecoder, StreamDecoder, startsWithBom } from \"./decode.ts\";\nexport { LineScanner } from \"./line-scan.ts\";\n"]}
package/dist/errors.d.ts CHANGED
@@ -1,11 +1,28 @@
1
1
  import type { ConversationId } from "./types.ts";
2
+ /**
3
+ * The message of a thrown value, without throwing itself: `String()` throws for values such as `Object.create(null)`,
4
+ * and code that formats an error must not fail for the value it formats.
5
+ */
6
+ export declare function errorMessage(error: unknown): string;
2
7
  /** A transaction read a table after its first table write. Read every required row before writing. */
3
8
  export declare class ReadAfterWrite extends Error {
4
9
  constructor(method: string);
5
10
  }
6
- /** Storage rejected a batch before any durable effect; the owning Session may continue safely. */
7
- export declare class StorageRejected extends Error {
8
- constructor(message: string, options?: ErrorOptions);
11
+ /**
12
+ * A Storage read rejected an invalid request, such as an unknown conversation or a cursor from another scan, with no
13
+ * durable effect. Unlike any other error a Storage throws, it fails only that read, not the Session; from `commit()` it is
14
+ * fatal like any other.
15
+ */
16
+ export declare class StorageRequestError extends Error {
17
+ constructor(message: string);
18
+ }
19
+ /**
20
+ * The Session failed, so nothing runs or commits any more. It fails when a Storage method throws, a commit cannot be
21
+ * adopted, or the Harness's own bookkeeping throws (a scheduler commit, an internal commit listener, a registry whose
22
+ * `snapshot()` throws). `cause` is that first error. Reopen the Session; reopening recovers from what was committed.
23
+ */
24
+ export declare class SessionFailed extends Error {
25
+ constructor(cause: unknown);
9
26
  }
10
27
  /** A submission reached a busy conversation and was not admitted. */
11
28
  export declare class ConversationBusy extends Error {
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,sGAAsG;AACtG,qBAAa,cAAe,SAAQ,KAAK;IACxC,YAAY,MAAM,EAAE,MAAM,EAGzB;CACD;AAED,kGAAkG;AAClG,qBAAa,eAAgB,SAAQ,KAAK;IACzC,YAAY,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,EAGlD;CACD;AAED,qEAAqE;AACrE,qBAAa,gBAAiB,SAAQ,KAAK;IAC1C,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IAExC,YAAY,cAAc,EAAE,cAAc,EAIzC;CACD"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAOnD;AAED,sGAAsG;AACtG,qBAAa,cAAe,SAAQ,KAAK;IACxC,YAAY,MAAM,EAAE,MAAM,EAGzB;CACD;AAED;;;;GAIG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;IAC7C,YAAY,OAAO,EAAE,MAAM,EAG1B;CACD;AAED;;;;GAIG;AACH,qBAAa,aAAc,SAAQ,KAAK;IACvC,YAAY,KAAK,EAAE,OAAO,EAGzB;CACD;AAED,qEAAqE;AACrE,qBAAa,gBAAiB,SAAQ,KAAK;IAC1C,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IAExC,YAAY,cAAc,EAAE,cAAc,EAIzC;CACD"}
package/dist/errors.js CHANGED
@@ -1,3 +1,17 @@
1
+ /**
2
+ * The message of a thrown value, without throwing itself: `String()` throws for values such as `Object.create(null)`,
3
+ * and code that formats an error must not fail for the value it formats.
4
+ */
5
+ export function errorMessage(error) {
6
+ if (error instanceof Error)
7
+ return error.message;
8
+ try {
9
+ return String(error);
10
+ }
11
+ catch {
12
+ return Object.prototype.toString.call(error);
13
+ }
14
+ }
1
15
  /** A transaction read a table after its first table write. Read every required row before writing. */
2
16
  export class ReadAfterWrite extends Error {
3
17
  constructor(method) {
@@ -5,11 +19,26 @@ export class ReadAfterWrite extends Error {
5
19
  this.name = "ReadAfterWrite";
6
20
  }
7
21
  }
8
- /** Storage rejected a batch before any durable effect; the owning Session may continue safely. */
9
- export class StorageRejected extends Error {
10
- constructor(message, options) {
11
- super(message, options);
12
- this.name = "StorageRejected";
22
+ /**
23
+ * A Storage read rejected an invalid request, such as an unknown conversation or a cursor from another scan, with no
24
+ * durable effect. Unlike any other error a Storage throws, it fails only that read, not the Session; from `commit()` it is
25
+ * fatal like any other.
26
+ */
27
+ export class StorageRequestError extends Error {
28
+ constructor(message) {
29
+ super(message);
30
+ this.name = "StorageRequestError";
31
+ }
32
+ }
33
+ /**
34
+ * The Session failed, so nothing runs or commits any more. It fails when a Storage method throws, a commit cannot be
35
+ * adopted, or the Harness's own bookkeeping throws (a scheduler commit, an internal commit listener, a registry whose
36
+ * `snapshot()` throws). `cause` is that first error. Reopen the Session; reopening recovers from what was committed.
37
+ */
38
+ export class SessionFailed extends Error {
39
+ constructor(cause) {
40
+ super("Session failed after a storage error; close and reopen it", { cause });
41
+ this.name = "SessionFailed";
13
42
  }
14
43
  }
15
44
  /** A submission reached a busy conversation and was not admitted. */
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA,sGAAsG;AACtG,MAAM,OAAO,cAAe,SAAQ,KAAK;IACxC,YAAY,MAAc;QACzB,KAAK,CAAC,MAAM,MAAM,mDAAmD,CAAC,CAAC;QACvE,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC9B,CAAC;CACD;AAED,kGAAkG;AAClG,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACzC,YAAY,OAAe,EAAE,OAAsB;QAClD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAC/B,CAAC;CACD;AAED,qEAAqE;AACrE,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACjC,cAAc,CAAiB;IAExC,YAAY,cAA8B;QACzC,KAAK,CAAC,gBAAgB,cAAc,UAAU,CAAC,CAAC;QAChD,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACtC,CAAC;CACD","sourcesContent":["import type { ConversationId } from \"./types.ts\";\n\n/** A transaction read a table after its first table write. Read every required row before writing. */\nexport class ReadAfterWrite extends Error {\n\tconstructor(method: string) {\n\t\tsuper(`Tx.${method}() cannot read tables after the first table write`);\n\t\tthis.name = \"ReadAfterWrite\";\n\t}\n}\n\n/** Storage rejected a batch before any durable effect; the owning Session may continue safely. */\nexport class StorageRejected extends Error {\n\tconstructor(message: string, options?: ErrorOptions) {\n\t\tsuper(message, options);\n\t\tthis.name = \"StorageRejected\";\n\t}\n}\n\n/** A submission reached a busy conversation and was not admitted. */\nexport class ConversationBusy extends Error {\n\treadonly conversationId: ConversationId;\n\n\tconstructor(conversationId: ConversationId) {\n\t\tsuper(`Conversation ${conversationId} is busy`);\n\t\tthis.name = \"ConversationBusy\";\n\t\tthis.conversationId = conversationId;\n\t}\n}\n"]}
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc;IAC1C,IAAI,KAAK,YAAY,KAAK;QAAE,OAAO,KAAK,CAAC,OAAO,CAAC;IACjD,IAAI,CAAC;QACJ,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC;AACF,CAAC;AAED,sGAAsG;AACtG,MAAM,OAAO,cAAe,SAAQ,KAAK;IACxC,YAAY,MAAc;QACzB,KAAK,CAAC,MAAM,MAAM,mDAAmD,CAAC,CAAC;QACvE,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC9B,CAAC;CACD;AAED;;;;GAIG;AACH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAC7C,YAAY,OAAe;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACnC,CAAC;CACD;AAED;;;;GAIG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IACvC,YAAY,KAAc;QACzB,KAAK,CAAC,2DAA2D,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAC9E,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC7B,CAAC;CACD;AAED,qEAAqE;AACrE,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACjC,cAAc,CAAiB;IAExC,YAAY,cAA8B;QACzC,KAAK,CAAC,gBAAgB,cAAc,UAAU,CAAC,CAAC;QAChD,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACtC,CAAC;CACD","sourcesContent":["import type { ConversationId } from \"./types.ts\";\n\n/**\n * The message of a thrown value, without throwing itself: `String()` throws for values such as `Object.create(null)`,\n * and code that formats an error must not fail for the value it formats.\n */\nexport function errorMessage(error: unknown): string {\n\tif (error instanceof Error) return error.message;\n\ttry {\n\t\treturn String(error);\n\t} catch {\n\t\treturn Object.prototype.toString.call(error);\n\t}\n}\n\n/** A transaction read a table after its first table write. Read every required row before writing. */\nexport class ReadAfterWrite extends Error {\n\tconstructor(method: string) {\n\t\tsuper(`Tx.${method}() cannot read tables after the first table write`);\n\t\tthis.name = \"ReadAfterWrite\";\n\t}\n}\n\n/**\n * A Storage read rejected an invalid request, such as an unknown conversation or a cursor from another scan, with no\n * durable effect. Unlike any other error a Storage throws, it fails only that read, not the Session; from `commit()` it is\n * fatal like any other.\n */\nexport class StorageRequestError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"StorageRequestError\";\n\t}\n}\n\n/**\n * The Session failed, so nothing runs or commits any more. It fails when a Storage method throws, a commit cannot be\n * adopted, or the Harness's own bookkeeping throws (a scheduler commit, an internal commit listener, a registry whose\n * `snapshot()` throws). `cause` is that first error. Reopen the Session; reopening recovers from what was committed.\n */\nexport class SessionFailed extends Error {\n\tconstructor(cause: unknown) {\n\t\tsuper(\"Session failed after a storage error; close and reopen it\", { cause });\n\t\tthis.name = \"SessionFailed\";\n\t}\n}\n\n/** A submission reached a busy conversation and was not admitted. */\nexport class ConversationBusy extends Error {\n\treadonly conversationId: ConversationId;\n\n\tconstructor(conversationId: ConversationId) {\n\t\tsuper(`Conversation ${conversationId} is busy`);\n\t\tthis.name = \"ConversationBusy\";\n\t\tthis.conversationId = conversationId;\n\t}\n}\n"]}
@@ -12,8 +12,11 @@ export declare function resolveSettings(settings: HarnessSettings | undefined):
12
12
  /** Apply one change to `pi.agent`: a given field replaces the stored one, `null` clears it, `undefined` changes nothing. */
13
13
  export declare function configure(tx: Tx, conversationId: ConversationId, change: AgentChange): Promise<void>;
14
14
  /**
15
- * `addTools` of a tool round: an array gets each name it lacks appended, `{ remove }` loses the names, and unset tools
16
- * already offer every tool, so nothing is written.
15
+ * `addTools` of a tool round, applied to `tools` and `modelTools`, so the next request offers the tools: an array gets
16
+ * each name it lacks appended, and `{ remove }` loses the names. An unset `tools` already enables every tool, so nothing
17
+ * is written for it. An unset or object `modelTools` also gets each name appended to its `add`, which loads deferred
18
+ * tools and has no effect for others. By name, without the registry: a tool that is not registered now, such as one of
19
+ * an MCP server that is reconnecting, is offered once it is again.
17
20
  */
18
21
  export declare function addTools(tx: Tx, conversationId: ConversationId, added: readonly string[]): Promise<void>;
19
22
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/harness/agent.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,KAAK,EACX,KAAK,EACL,WAAW,EACX,UAAU,EACV,gBAAgB,EAChB,uBAAuB,EAEvB,eAAe,EACf,cAAc,EAEd,gBAAgB,EAChB,QAAQ,EACR,gBAAgB,EAChB,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,oBAAoB,EAAE,uBAKlC,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,gBAKvC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,cAGrC,CAAC;AAEF,8DAA8D;AAC9D,eAAO,MAAM,gBAAgB,iBAAiB,CAAC;AAE/C,6FAA6F;AAC7F,eAAO,MAAM,QAAQ,kEAQnB,CAAC;AAKH,8FAA8F;AAC9F,wBAAgB,eAAe,CAAC,QAAQ,EAAE,eAAe,GAAG,SAAS,GAAG,QAAQ,CAiB/E;AAED,4HAA4H;AAC5H,wBAAsB,SAAS,CAAC,EAAE,EAAE,EAAE,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAG1G;AAED;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,cAAc,EAAE,cAAc,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAY9G;AAuCD;;;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,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAG1G;AAED;;;;;;GAMG;AACH,wBAAsB,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,cAAc,EAAE,cAAc,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAkB9G;AAmDD;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,EAAE,EAAE,EAAE,EAAE,YAAY,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAMzF;AAED,sFAAsF;AACtF,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAMnE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,SAAS,gBAAgB,EACzD,KAAK,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,SAAS,EACvC,QAAQ,EAAE,gBAAgB,CAAC,IAAI,CAAC,EAChC,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GAC9B,KAAK,CAAC,IAAI,CAAC,CAuDb"}
@@ -1,5 +1,6 @@
1
1
  import { copyJson } from "@earendil-works/chord";
2
2
  import { defineDoc } from "../documents.js";
3
+ import { documentRetention } from "../session/session.js";
3
4
  export const DEFAULT_RETRY_POLICY = {
4
5
  enabled: true,
5
6
  maxRetries: 3,
@@ -47,6 +48,7 @@ export function resolveSettings(settings) {
47
48
  steeringMode: settings?.steeringMode ?? "one-at-a-time",
48
49
  followUpMode: settings?.followUpMode ?? "one-at-a-time",
49
50
  contextRetentionMs: settings?.contextRetentionMs ?? DEFAULT_CONTEXT_RETENTION_MS,
51
+ documentRetentionMs: documentRetention(settings?.documentRetentionMs),
50
52
  };
51
53
  }
52
54
  /** Apply one change to `pi.agent`: a given field replaces the stored one, `null` clears it, `undefined` changes nothing. */
@@ -55,25 +57,37 @@ export async function configure(tx, conversationId, change) {
55
57
  applyChange(state, change);
56
58
  }
57
59
  /**
58
- * `addTools` of a tool round: an array gets each name it lacks appended, `{ remove }` loses the names, and unset tools
59
- * already offer every tool, so nothing is written.
60
+ * `addTools` of a tool round, applied to `tools` and `modelTools`, so the next request offers the tools: an array gets
61
+ * each name it lacks appended, and `{ remove }` loses the names. An unset `tools` already enables every tool, so nothing
62
+ * is written for it. An unset or object `modelTools` also gets each name appended to its `add`, which loads deferred
63
+ * tools and has no effect for others. By name, without the registry: a tool that is not registered now, such as one of
64
+ * an MCP server that is reconnecting, is offered once it is again.
60
65
  */
61
66
  export async function addTools(tx, conversationId, added) {
62
67
  const state = await tx.doc(AgentDoc, conversationId);
63
68
  const tools = state.tools;
64
- if (tools === undefined)
65
- return;
66
69
  if (Array.isArray(tools)) {
67
70
  for (const name of added)
68
71
  if (!tools.includes(name))
69
72
  tools.push(name);
70
73
  }
71
- else {
72
- const remove = tools.remove;
73
- if (remove.some((name) => added.includes(name))) {
74
- state.tools = { remove: remove.filter((name) => !added.includes(name)) };
75
- }
74
+ else if (tools?.remove.some((name) => added.includes(name))) {
75
+ state.tools = { remove: tools.remove.filter((name) => !added.includes(name)) };
76
76
  }
77
+ const modelTools = state.modelTools;
78
+ if (Array.isArray(modelTools)) {
79
+ for (const name of added)
80
+ if (!modelTools.includes(name))
81
+ modelTools.push(name);
82
+ return;
83
+ }
84
+ // Assigned whole; a document write of an equal value records no change.
85
+ const remove = (modelTools?.remove ?? []).filter((name) => !added.includes(name));
86
+ const add = [...(modelTools?.add ?? [])];
87
+ for (const name of added)
88
+ if (!add.includes(name))
89
+ add.push(name);
90
+ state.modelTools = { ...(remove.length === 0 ? {} : { remove }), add };
77
91
  }
78
92
  function applyChange(state, change) {
79
93
  const set = (key, value) => {
@@ -97,6 +111,15 @@ function applyChange(state, change) {
97
111
  });
98
112
  const tools = change.tools;
99
113
  set("tools", tools === undefined || tools === null ? tools : isList(tools) ? names(tools) : { remove: names(tools.remove) });
114
+ const modelTools = change.modelTools;
115
+ set("modelTools", modelTools === undefined || modelTools === null
116
+ ? modelTools
117
+ : isList(modelTools)
118
+ ? names(modelTools)
119
+ : {
120
+ ...(modelTools.remove === undefined ? {} : { remove: names(modelTools.remove) }),
121
+ ...(modelTools.add === undefined ? {} : { add: names(modelTools.add) }),
122
+ });
100
123
  set("instructions", change.instructions);
101
124
  set("cwd", change.cwd);
102
125
  }
@@ -153,22 +176,13 @@ export function resolveAgent(state, snapshot, settings, report) {
153
176
  applyWrap(sections, wrap.section, (section) => wrap.wrap(section), (section) => section.key, report);
154
177
  }
155
178
  }
156
- const filter = state?.tools;
157
- let tools;
158
- if (filter === undefined)
159
- tools = [...composed.values()];
160
- else if (Array.isArray(filter)) {
161
- tools = [];
162
- for (const name of new Set(filter)) {
163
- const tool = composed.get(name);
164
- if (tool !== undefined)
165
- tools.push(tool);
166
- }
167
- }
168
- else {
169
- const removed = new Set(filter.remove);
170
- tools = [...composed.values()].filter((tool) => !removed.has(tool.name));
171
- }
179
+ const enabled = filterTools([...composed.values()], state?.tools);
180
+ const callableBy = (caller) => (tool) => tool.callers === undefined || tool.callers.includes(caller);
181
+ const modelCallable = enabled.filter(callableBy("model"));
182
+ const tools = offeredTools(modelCallable, state?.modelTools);
183
+ const offered = new Set(tools);
184
+ const deferred = modelCallable.filter((tool) => tool.deferred === true && !offered.has(tool));
185
+ const callable = enabled.filter(callableBy("tools"));
172
186
  const instructions = state?.instructions;
173
187
  const agentSections = [...sections.values()];
174
188
  if (instructions !== undefined)
@@ -178,12 +192,42 @@ export function resolveAgent(state, snapshot, settings, report) {
178
192
  thinkingLevel: state?.thinkingLevel ?? "off",
179
193
  extensions,
180
194
  tools,
195
+ callable,
196
+ deferred,
181
197
  sections: agentSections,
182
198
  ...(instructions === undefined ? {} : { instructions }),
183
199
  ...(state?.cwd === undefined ? {} : { cwd: state.cwd }),
184
200
  };
185
201
  return agent;
186
202
  }
203
+ /** The tools offered to the model, as `AgentState.modelTools` describes. */
204
+ function offeredTools(tools, filter) {
205
+ if (Array.isArray(filter))
206
+ return filterTools(tools, filter);
207
+ const removed = new Set(filter?.remove ?? []);
208
+ const kept = tools.filter((tool) => tool.deferred !== true && !removed.has(tool.name));
209
+ // Loaded deferred tools follow in load order, so loading one appends to the declared tools.
210
+ const byName = new Map(tools.map((tool) => [tool.name, tool]));
211
+ const loaded = [...new Set(filter?.add ?? [])].flatMap((name) => {
212
+ const tool = byName.get(name);
213
+ return tool?.deferred === true && !removed.has(name) ? [tool] : [];
214
+ });
215
+ return [...kept, ...loaded];
216
+ }
217
+ /** `tools` through a stored filter: an array selects exactly its names, in its order; `{ remove }` drops names. */
218
+ function filterTools(tools, filter) {
219
+ if (filter === undefined)
220
+ return tools;
221
+ if (Array.isArray(filter)) {
222
+ const byName = new Map(tools.map((tool) => [tool.name, tool]));
223
+ return [...new Set(filter)].flatMap((name) => {
224
+ const tool = byName.get(name);
225
+ return tool === undefined ? [] : [tool];
226
+ });
227
+ }
228
+ const removed = new Set(filter.remove);
229
+ return tools.filter((tool) => !removed.has(tool.name));
230
+ }
187
231
  /** Selected installed extensions: the stored array, or the default selection edited by `{ add, remove }`. */
188
232
  function selectExtensions(stored, snapshot, settings) {
189
233
  let selected;
@@ -1 +1 @@
1
- {"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/harness/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAc,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAiB5C,MAAM,CAAC,MAAM,oBAAoB,GAA4B;IAC5D,OAAO,EAAE,IAAI;IACb,UAAU,EAAE,CAAC;IACb,WAAW,EAAE,IAAI;IACjB,eAAe,EAAE,KAAK;CACtB,CAAC;AAEF,MAAM,CAAC,MAAM,yBAAyB,GAAqB;IAC1D,OAAO,EAAE,IAAI;IACb,aAAa,EAAE,KAAK;IACpB,gBAAgB,EAAE,KAAK;I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AI,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IACjF,CAAC;IACD,MAAM,UAAU,GAAsB,EAAE,CAAC;IACzC,KAAK,MAAM,IAAI,IAAI,IAAI,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;QACtC,MAAM,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAC3C,IAAI,SAAS,KAAK,SAAS;YAAE,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,UAAU,CAAC;AACnB,CAAC;AAED,SAAS,SAAS,CACjB,KAAqB,EACrB,MAAc,EACd,IAAoB,EACpB,MAA2B,EAC3B,MAAgC;IAEhC,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC/B,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO;IAC/B,IAAI,CAAC;QACJ,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3B,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,MAAM;YAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,MAAM,OAAO,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACnG,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACrB,MAAM,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;AACF,CAAC","sourcesContent":["import { copyJson, type Draft } from \"@earendil-works/chord\";\nimport { defineDoc } from \"../documents.ts\";\nimport type { ConversationId, ConversationRecord, Tx } from \"../types.ts\";\nimport type {\n\tAgent,\n\tAgentChange,\n\tAgentState,\n\tCompactionPolicy,\n\tConversationRetryPolicy,\n\tExtension,\n\tHarnessSettings,\n\tProgressPolicy,\n\tPromptSection,\n\tRegistrySnapshot,\n\tSettings,\n\tToolRegistration,\n} from \"./types.ts\";\n\nexport const DEFAULT_RETRY_POLICY: ConversationRetryPolicy = {\n\tenabled: true,\n\tmaxRetries: 3,\n\tbaseDelayMs: 2000,\n\tmaxAgentDelayMs: 60000,\n};\n\nexport const DEFAULT_COMPACTION_POLICY: CompactionPolicy = {\n\tenabled: true,\n\treserveTokens: 16384,\n\tkeepRecentTokens: 20000,\n\tbackgroundTokens: 32768,\n};\n\nexport const DEFAULT_PROGRESS_POLICY: ProgressPolicy = {\n\tpartialIntervalMs: 100,\n\toutputIntervalMs: 100,\n};\n\n/** The reserved section key of the agent's `instructions`. */\nexport const INSTRUCTIONS_KEY = \"instructions\";\n\n/** Built-in agent document; rewindable so forks start from the agent at their fork entry. */\nexport const AgentDoc = defineDoc<AgentState>({\n\tkind: \"pi.agent\",\n\tversion: 1,\n\tscope: \"conversation\",\n\thistory: \"rewindable\",\n\tfork: \"asOf\",\n\tinitial: () => ({}),\n\tcheckpointWhen: () => true,\n});\n\n/** Default `settings.contextRetentionMs`: ten minutes. */\nconst DEFAULT_CONTEXT_RETENTION_MS = 600_000;\n\n/** Resolve the host settings: every field over its built-in default, object fields merged. */\nexport function resolveSettings(settings: HarnessSettings | undefined): Settings {\n\tconst extensions = settings?.extensions;\n\treturn {\n\t\t...(extensions === undefined ? {} : { extensions }),\n\t\tstream: { ...settings?.stream },\n\t\tretry: { ...DEFAULT_RETRY_POLICY, ...settings?.retry },\n\t\tcompaction: { ...DEFAULT_COMPACTION_POLICY, ...settings?.compaction },\n\t\t// Field by field, so an explicitly undefined interval keeps its default.\n\t\tprogress: {\n\t\t\tpartialIntervalMs: settings?.progress?.partialIntervalMs ?? DEFAULT_PROGRESS_POLICY.partialIntervalMs,\n\t\t\toutputIntervalMs: settings?.progress?.outputIntervalMs ?? DEFAULT_PROGRESS_POLICY.outputIntervalMs,\n\t\t},\n\t\ttoolExecution: settings?.toolExecution ?? \"parallel\",\n\t\tsteeringMode: settings?.steeringMode ?? \"one-at-a-time\",\n\t\tfollowUpMode: settings?.followUpMode ?? \"one-at-a-time\",\n\t\tcontextRetentionMs: settings?.contextRetentionMs ?? DEFAULT_CONTEXT_RETENTION_MS,\n\t};\n}\n\n/** Apply one change to `pi.agent`: a given field replaces the stored one, `null` clears it, `undefined` changes nothing. */\nexport async function configure(tx: Tx, conversationId: ConversationId, change: AgentChange): Promise<void> {\n\tconst state = await tx.doc(AgentDoc, conversationId);\n\tapplyChange(state, change);\n}\n\n/**\n * `addTools` of a tool round: an array gets each name it lacks appended, `{ remove }` loses the names, and unset tools\n * already offer every tool, so nothing is written.\n */\nexport async function addTools(tx: Tx, conversationId: ConversationId, added: readonly string[]): Promise<void> {\n\tconst state = await tx.doc(AgentDoc, conversationId);\n\tconst tools = state.tools;\n\tif (tools === undefined) return;\n\tif (Array.isArray(tools)) {\n\t\tfor (const name of added) if (!tools.includes(name)) tools.push(name);\n\t} else {\n\t\tconst remove = (tools as { remove: string[] }).remove;\n\t\tif (remove.some((name) => added.includes(name))) {\n\t\t\tstate.tools = { remove: remove.filter((name) => !added.includes(name)) };\n\t\t}\n\t}\n}\n\nfunction applyChange(state: Draft<AgentState>, change: AgentChange): void {\n\tconst set = <K extends keyof AgentState>(key: K, value: AgentState[K] | null | undefined) => {\n\t\tif (value === undefined) return;\n\t\tif (value === null) delete state[key];\n\t\telse state[key] = value as Draft<AgentState>[K];\n\t};\n\tset(\"model\", change.model === undefined || change.model === null ? change.model : { ...change.model });\n\tset(\"thinkingLevel\", change.thinkingLevel);\n\tconst extensions = change.extensions;\n\tset(\n\t\t\"extensions\",\n\t\textensions === undefined || extensions === null\n\t\t\t? extensions\n\t\t\t: isList(extensions)\n\t\t\t\t? names(extensions)\n\t\t\t\t: {\n\t\t\t\t\t\t...(extensions.add === undefined ? {} : { add: names(extensions.add) }),\n\t\t\t\t\t\t...(extensions.remove === undefined ? {} : { remove: names(extensions.remove) }),\n\t\t\t\t\t},\n\t);\n\tconst tools = change.tools;\n\tset(\n\t\t\"tools\",\n\t\ttools === undefined || tools === null ? tools : isList(tools) ? names(tools) : { remove: names(tools.remove) },\n\t);\n\tset(\"instructions\", change.instructions);\n\tset(\"cwd\", change.cwd);\n}\n\nfunction isList<T>(value: readonly T[] | object): value is readonly T[] {\n\treturn Array.isArray(value);\n}\n\nfunction names(items: readonly { readonly name: string }[]): string[] {\n\treturn items.map((item) => item.name);\n}\n\n/**\n * Built-in part of every Harness commit that creates or forks a conversation, for `pi.agent`: a fork keeps its `asOf`\n * copy; a new task-owned conversation copies the stored agent of its owner task's conversation; a new ownerless one\n * starts empty.\n */\nexport async function createAgent(tx: Tx, conversation: ConversationRecord): Promise<void> {\n\tif (conversation.parent !== undefined) return;\n\tconst agent = await tx.doc(AgentDoc, conversation.id);\n\tif (conversation.owner === undefined) return;\n\tconst owner = await tx.doc(AgentDoc, conversation.owner.conversationId);\n\tObject.assign(agent, copyJson(owner) as AgentState);\n}\n\n/** Handlers of the selected extensions' hooks for a task name, in extension order. */\nexport function agentHooks(agent: Agent, taskName: string): object[] {\n\tconst handlers: object[] = [];\n\tfor (const extension of agent.extensions) {\n\t\tfor (const hook of extension.hooks ?? []) if (hook.task === taskName) handlers.push(hook.handlers);\n\t}\n\treturn handlers;\n}\n\n/**\n * Resolve an agent from its stored state (absent: every field unset), a registry snapshot, and resolved settings. A\n * wrapper that throws or renames drops its target and is reported; a wrapper without a target does nothing.\n */\nexport function resolveAgent<Tool extends ToolRegistration>(\n\tstate: Readonly<AgentState> | undefined,\n\tsnapshot: RegistrySnapshot<Tool>,\n\tsettings: Settings,\n\treport: (error: unknown) => void,\n): Agent<Tool> {\n\tconst extensions = selectExtensions(state?.extensions, snapshot, settings);\n\n\tconst composed = new Map<string, Tool>();\n\tfor (const extension of extensions) for (const tool of extension.tools ?? []) composed.set(tool.name, tool);\n\tconst sections = new Map<string, PromptSection<Tool>>();\n\tfor (const extension of extensions) {\n\t\tfor (const section of extension.sections ?? []) sections.set(section.key, section);\n\t}\n\tfor (const extension of extensions) {\n\t\tfor (const wrap of extension.wraps ?? []) {\n\t\t\tif (\"tool\" in wrap)\n\t\t\t\tapplyWrap(\n\t\t\t\t\tcomposed,\n\t\t\t\t\twrap.tool,\n\t\t\t\t\t(tool) => wrap.wrap(tool),\n\t\t\t\t\t(tool) => tool.name,\n\t\t\t\t\treport,\n\t\t\t\t);\n\t\t\telse\n\t\t\t\tapplyWrap(\n\t\t\t\t\tsections,\n\t\t\t\t\twrap.section,\n\t\t\t\t\t(section) => wrap.wrap(section),\n\t\t\t\t\t(section) => section.key,\n\t\t\t\t\treport,\n\t\t\t\t);\n\t\t}\n\t}\n\n\tconst filter = state?.tools;\n\tlet tools: Tool[];\n\tif (filter === undefined) tools = [...composed.values()];\n\telse if (Array.isArray(filter)) {\n\t\ttools = [];\n\t\tfor (const name of new Set(filter)) {\n\t\t\tconst tool = composed.get(name);\n\t\t\tif (tool !== undefined) tools.push(tool);\n\t\t}\n\t} else {\n\t\tconst removed = new Set((filter as { remove: string[] }).remove);\n\t\ttools = [...composed.values()].filter((tool) => !removed.has(tool.name));\n\t}\n\n\tconst instructions = state?.instructions;\n\tconst agentSections = [...sections.values()];\n\tif (instructions !== undefined) agentSections.push({ key: INSTRUCTIONS_KEY, render: () => instructions });\n\n\tconst agent: Agent<Tool> = {\n\t\t...(state?.model === undefined ? {} : { model: state.model }),\n\t\tthinkingLevel: state?.thinkingLevel ?? \"off\",\n\t\textensions,\n\t\ttools,\n\t\tsections: agentSections,\n\t\t...(instructions === undefined ? {} : { instructions }),\n\t\t...(state?.cwd === undefined ? {} : { cwd: state.cwd }),\n\t};\n\treturn agent;\n}\n\n/** Selected installed extensions: the stored array, or the default selection edited by `{ add, remove }`. */\nfunction selectExtensions<Tool extends ToolRegistration>(\n\tstored: AgentState[\"extensions\"],\n\tsnapshot: RegistrySnapshot<Tool>,\n\tsettings: Settings,\n): Extension<Tool>[] {\n\tlet selected: string[];\n\tif (Array.isArray(stored)) selected = stored;\n\telse {\n\t\tconst base = settings.extensions?.map((extension) => extension.name) ?? snapshot.installed().map((e) => e.name);\n\t\tconst edit = stored as { add?: string[]; remove?: string[] } | undefined;\n\t\tconst removed = new Set(edit?.remove ?? []);\n\t\tselected = [...base, ...(edit?.add ?? [])].filter((name) => !removed.has(name));\n\t}\n\tconst extensions: Extension<Tool>[] = [];\n\tfor (const name of new Set(selected)) {\n\t\tconst extension = snapshot.extension(name);\n\t\tif (extension !== undefined) extensions.push(extension);\n\t}\n\treturn extensions;\n}\n\nfunction applyWrap<T>(\n\titems: Map<string, T>,\n\ttarget: string,\n\twrap: (item: T) => T,\n\tnameOf: (item: T) => string,\n\treport: (error: unknown) => void,\n): void {\n\tconst item = items.get(target);\n\tif (item === undefined) return;\n\ttry {\n\t\tconst wrapped = wrap(item);\n\t\tif (nameOf(wrapped) !== target) throw new Error(`Wrapper renamed ${target} to ${nameOf(wrapped)}`);\n\t\titems.set(target, wrapped);\n\t} catch (error) {\n\t\titems.delete(target);\n\t\treport(error);\n\t}\n}\n"]}
1
+ {"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/harness/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAc,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAiB1D,MAAM,CAAC,MAAM,oBAAoB,GAA4B;IAC5D,OAAO,EAAE,IAAI;IACb,UAAU,EAAE,CAAC;IACb,WAAW,EAAE,IAAI;IACjB,eAAe,EAAE,KAAK;CACtB,CAAC;AAEF,MAAM,CAAC,MAAM,yBAAyB,GAAqB;IAC1D,OAAO,EAAE,IAAI;IACb,aAAa,EAAE,KAAK;IACpB,gBAAgB,EAAE,KAAK;IACvB,gBAAgB,EAAE,KAAK;CACvB,CAAC;AAEF,MA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;IACzD,CAAC;IACD,OAAO,UAAU,CAAC;AACnB,CAAC;AAED,SAAS,SAAS,CACjB,KAAqB,EACrB,MAAc,EACd,IAAoB,EACpB,MAA2B,EAC3B,MAAgC;IAEhC,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC/B,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO;IAC/B,IAAI,CAAC;QACJ,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3B,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,MAAM;YAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,MAAM,OAAO,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACnG,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACrB,MAAM,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;AACF,CAAC","sourcesContent":["import { copyJson, type Draft } from \"@earendil-works/chord\";\nimport { defineDoc } from \"../documents.ts\";\nimport { documentRetention } from \"../session/session.ts\";\nimport type { ConversationId, ConversationRecord, Tx } from \"../types.ts\";\nimport type {\n\tAgent,\n\tAgentChange,\n\tAgentState,\n\tCompactionPolicy,\n\tConversationRetryPolicy,\n\tExtension,\n\tHarnessSettings,\n\tProgressPolicy,\n\tPromptSection,\n\tRegistrySnapshot,\n\tSettings,\n\tToolRegistration,\n} from \"./types.ts\";\n\nexport const DEFAULT_RETRY_POLICY: ConversationRetryPolicy = {\n\tenabled: true,\n\tmaxRetries: 3,\n\tbaseDelayMs: 2000,\n\tmaxAgentDelayMs: 60000,\n};\n\nexport const DEFAULT_COMPACTION_POLICY: CompactionPolicy = {\n\tenabled: true,\n\treserveTokens: 16384,\n\tkeepRecentTokens: 20000,\n\tbackgroundTokens: 32768,\n};\n\nexport const DEFAULT_PROGRESS_POLICY: ProgressPolicy = {\n\tpartialIntervalMs: 100,\n\toutputIntervalMs: 100,\n};\n\n/** The reserved section key of the agent's `instructions`. */\nexport const INSTRUCTIONS_KEY = \"instructions\";\n\n/** Built-in agent document; rewindable so forks start from the agent at their fork entry. */\nexport const AgentDoc = defineDoc<AgentState>({\n\tkind: \"pi.agent\",\n\tversion: 1,\n\tscope: \"conversation\",\n\thistory: \"rewindable\",\n\tfork: \"asOf\",\n\tinitial: () => ({}),\n\tcheckpointWhen: () => true,\n});\n\n/** Default `settings.contextRetentionMs`: ten minutes. */\nconst DEFAULT_CONTEXT_RETENTION_MS = 600_000;\n\n/** Resolve the host settings: every field over its built-in default, object fields merged. */\nexport function resolveSettings(settings: HarnessSettings | undefined): Settings {\n\tconst extensions = settings?.extensions;\n\treturn {\n\t\t...(extensions === undefined ? {} : { extensions }),\n\t\tstream: { ...settings?.stream },\n\t\tretry: { ...DEFAULT_RETRY_POLICY, ...settings?.retry },\n\t\tcompaction: { ...DEFAULT_COMPACTION_POLICY, ...settings?.compaction },\n\t\t// Field by field, so an explicitly undefined interval keeps its default.\n\t\tprogress: {\n\t\t\tpartialIntervalMs: settings?.progress?.partialIntervalMs ?? DEFAULT_PROGRESS_POLICY.partialIntervalMs,\n\t\t\toutputIntervalMs: settings?.progress?.outputIntervalMs ?? DEFAULT_PROGRESS_POLICY.outputIntervalMs,\n\t\t},\n\t\ttoolExecution: settings?.toolExecution ?? \"parallel\",\n\t\tsteeringMode: settings?.steeringMode ?? \"one-at-a-time\",\n\t\tfollowUpMode: settings?.followUpMode ?? \"one-at-a-time\",\n\t\tcontextRetentionMs: settings?.contextRetentionMs ?? DEFAULT_CONTEXT_RETENTION_MS,\n\t\tdocumentRetentionMs: documentRetention(settings?.documentRetentionMs),\n\t};\n}\n\n/** Apply one change to `pi.agent`: a given field replaces the stored one, `null` clears it, `undefined` changes nothing. */\nexport async function configure(tx: Tx, conversationId: ConversationId, change: AgentChange): Promise<void> {\n\tconst state = await tx.doc(AgentDoc, conversationId);\n\tapplyChange(state, change);\n}\n\n/**\n * `addTools` of a tool round, applied to `tools` and `modelTools`, so the next request offers the tools: an array gets\n * each name it lacks appended, and `{ remove }` loses the names. An unset `tools` already enables every tool, so nothing\n * is written for it. An unset or object `modelTools` also gets each name appended to its `add`, which loads deferred\n * tools and has no effect for others. By name, without the registry: a tool that is not registered now, such as one of\n * an MCP server that is reconnecting, is offered once it is again.\n */\nexport async function addTools(tx: Tx, conversationId: ConversationId, added: readonly string[]): Promise<void> {\n\tconst state = await tx.doc(AgentDoc, conversationId);\n\tconst tools = state.tools;\n\tif (Array.isArray(tools)) {\n\t\tfor (const name of added) if (!tools.includes(name)) tools.push(name);\n\t} else if (tools?.remove.some((name) => added.includes(name))) {\n\t\tstate.tools = { remove: tools.remove.filter((name) => !added.includes(name)) };\n\t}\n\tconst modelTools = state.modelTools;\n\tif (Array.isArray(modelTools)) {\n\t\tfor (const name of added) if (!modelTools.includes(name)) modelTools.push(name);\n\t\treturn;\n\t}\n\t// Assigned whole; a document write of an equal value records no change.\n\tconst remove = (modelTools?.remove ?? []).filter((name) => !added.includes(name));\n\tconst add = [...(modelTools?.add ?? [])];\n\tfor (const name of added) if (!add.includes(name)) add.push(name);\n\tstate.modelTools = { ...(remove.length === 0 ? {} : { remove }), add };\n}\n\nfunction applyChange(state: Draft<AgentState>, change: AgentChange): void {\n\tconst set = <K extends keyof AgentState>(key: K, value: AgentState[K] | null | undefined) => {\n\t\tif (value === undefined) return;\n\t\tif (value === null) delete state[key];\n\t\telse state[key] = value as Draft<AgentState>[K];\n\t};\n\tset(\"model\", change.model === undefined || change.model === null ? change.model : { ...change.model });\n\tset(\"thinkingLevel\", change.thinkingLevel);\n\tconst extensions = change.extensions;\n\tset(\n\t\t\"extensions\",\n\t\textensions === undefined || extensions === null\n\t\t\t? extensions\n\t\t\t: isList(extensions)\n\t\t\t\t? names(extensions)\n\t\t\t\t: {\n\t\t\t\t\t\t...(extensions.add === undefined ? {} : { add: names(extensions.add) }),\n\t\t\t\t\t\t...(extensions.remove === undefined ? {} : { remove: names(extensions.remove) }),\n\t\t\t\t\t},\n\t);\n\tconst tools = change.tools;\n\tset(\n\t\t\"tools\",\n\t\ttools === undefined || tools === null ? tools : isList(tools) ? names(tools) : { remove: names(tools.remove) },\n\t);\n\tconst modelTools = change.modelTools;\n\tset(\n\t\t\"modelTools\",\n\t\tmodelTools === undefined || modelTools === null\n\t\t\t? modelTools\n\t\t\t: isList(modelTools)\n\t\t\t\t? names(modelTools)\n\t\t\t\t: {\n\t\t\t\t\t\t...(modelTools.remove === undefined ? {} : { remove: names(modelTools.remove) }),\n\t\t\t\t\t\t...(modelTools.add === undefined ? {} : { add: names(modelTools.add) }),\n\t\t\t\t\t},\n\t);\n\tset(\"instructions\", change.instructions);\n\tset(\"cwd\", change.cwd);\n}\n\nfunction isList<T>(value: readonly T[] | object): value is readonly T[] {\n\treturn Array.isArray(value);\n}\n\nfunction names(items: readonly { readonly name: string }[]): string[] {\n\treturn items.map((item) => item.name);\n}\n\n/**\n * Built-in part of every Harness commit that creates or forks a conversation, for `pi.agent`: a fork keeps its `asOf`\n * copy; a new task-owned conversation copies the stored agent of its owner task's conversation; a new ownerless one\n * starts empty.\n */\nexport async function createAgent(tx: Tx, conversation: ConversationRecord): Promise<void> {\n\tif (conversation.parent !== undefined) return;\n\tconst agent = await tx.doc(AgentDoc, conversation.id);\n\tif (conversation.owner === undefined) return;\n\tconst owner = await tx.doc(AgentDoc, conversation.owner.conversationId);\n\tObject.assign(agent, copyJson(owner) as AgentState);\n}\n\n/** Handlers of the selected extensions' hooks for a task name, in extension order. */\nexport function agentHooks(agent: Agent, taskName: string): object[] {\n\tconst handlers: object[] = [];\n\tfor (const extension of agent.extensions) {\n\t\tfor (const hook of extension.hooks ?? []) if (hook.task === taskName) handlers.push(hook.handlers);\n\t}\n\treturn handlers;\n}\n\n/**\n * Resolve an agent from its stored state (absent: every field unset), a registry snapshot, and resolved settings. A\n * wrapper that throws or renames drops its target and is reported; a wrapper without a target does nothing.\n */\nexport function resolveAgent<Tool extends ToolRegistration>(\n\tstate: Readonly<AgentState> | undefined,\n\tsnapshot: RegistrySnapshot<Tool>,\n\tsettings: Settings,\n\treport: (error: unknown) => void,\n): Agent<Tool> {\n\tconst extensions = selectExtensions(state?.extensions, snapshot, settings);\n\n\tconst composed = new Map<string, Tool>();\n\tfor (const extension of extensions) for (const tool of extension.tools ?? []) composed.set(tool.name, tool);\n\tconst sections = new Map<string, PromptSection<Tool>>();\n\tfor (const extension of extensions) {\n\t\tfor (const section of extension.sections ?? []) sections.set(section.key, section);\n\t}\n\tfor (const extension of extensions) {\n\t\tfor (const wrap of extension.wraps ?? []) {\n\t\t\tif (\"tool\" in wrap)\n\t\t\t\tapplyWrap(\n\t\t\t\t\tcomposed,\n\t\t\t\t\twrap.tool,\n\t\t\t\t\t(tool) => wrap.wrap(tool),\n\t\t\t\t\t(tool) => tool.name,\n\t\t\t\t\treport,\n\t\t\t\t);\n\t\t\telse\n\t\t\t\tapplyWrap(\n\t\t\t\t\tsections,\n\t\t\t\t\twrap.section,\n\t\t\t\t\t(section) => wrap.wrap(section),\n\t\t\t\t\t(section) => section.key,\n\t\t\t\t\treport,\n\t\t\t\t);\n\t\t}\n\t}\n\n\tconst enabled = filterTools([...composed.values()], state?.tools);\n\tconst callableBy = (caller: \"model\" | \"tools\") => (tool: Tool) =>\n\t\ttool.callers === undefined || tool.callers.includes(caller);\n\tconst modelCallable = enabled.filter(callableBy(\"model\"));\n\tconst tools = offeredTools(modelCallable, state?.modelTools);\n\tconst offered = new Set(tools);\n\tconst deferred = modelCallable.filter((tool) => tool.deferred === true && !offered.has(tool));\n\tconst callable = enabled.filter(callableBy(\"tools\"));\n\n\tconst instructions = state?.instructions;\n\tconst agentSections = [...sections.values()];\n\tif (instructions !== undefined) agentSections.push({ key: INSTRUCTIONS_KEY, render: () => instructions });\n\n\tconst agent: Agent<Tool> = {\n\t\t...(state?.model === undefined ? {} : { model: state.model }),\n\t\tthinkingLevel: state?.thinkingLevel ?? \"off\",\n\t\textensions,\n\t\ttools,\n\t\tcallable,\n\t\tdeferred,\n\t\tsections: agentSections,\n\t\t...(instructions === undefined ? {} : { instructions }),\n\t\t...(state?.cwd === undefined ? {} : { cwd: state.cwd }),\n\t};\n\treturn agent;\n}\n\n/** The tools offered to the model, as `AgentState.modelTools` describes. */\nfunction offeredTools<Tool extends ToolRegistration>(tools: Tool[], filter: AgentState[\"modelTools\"]): Tool[] {\n\tif (Array.isArray(filter)) return filterTools(tools, filter);\n\tconst removed = new Set(filter?.remove ?? []);\n\tconst kept = tools.filter((tool) => tool.deferred !== true && !removed.has(tool.name));\n\t// Loaded deferred tools follow in load order, so loading one appends to the declared tools.\n\tconst byName = new Map(tools.map((tool) => [tool.name, tool]));\n\tconst loaded = [...new Set(filter?.add ?? [])].flatMap((name) => {\n\t\tconst tool = byName.get(name);\n\t\treturn tool?.deferred === true && !removed.has(name) ? [tool] : [];\n\t});\n\treturn [...kept, ...loaded];\n}\n\n/** `tools` through a stored filter: an array selects exactly its names, in its order; `{ remove }` drops names. */\nfunction filterTools<Tool extends ToolRegistration>(tools: Tool[], filter: AgentState[\"tools\"]): Tool[] {\n\tif (filter === undefined) return tools;\n\tif (Array.isArray(filter)) {\n\t\tconst byName = new Map(tools.map((tool) => [tool.name, tool]));\n\t\treturn [...new Set(filter)].flatMap((name) => {\n\t\t\tconst tool = byName.get(name);\n\t\t\treturn tool === undefined ? [] : [tool];\n\t\t});\n\t}\n\tconst removed = new Set((filter as { remove: string[] }).remove);\n\treturn tools.filter((tool) => !removed.has(tool.name));\n}\n\n/** Selected installed extensions: the stored array, or the default selection edited by `{ add, remove }`. */\nfunction selectExtensions<Tool extends ToolRegistration>(\n\tstored: AgentState[\"extensions\"],\n\tsnapshot: RegistrySnapshot<Tool>,\n\tsettings: Settings,\n): Extension<Tool>[] {\n\tlet selected: string[];\n\tif (Array.isArray(stored)) selected = stored;\n\telse {\n\t\tconst base = settings.extensions?.map((extension) => extension.name) ?? snapshot.installed().map((e) => e.name);\n\t\tconst edit = stored as { add?: string[]; remove?: string[] } | undefined;\n\t\tconst removed = new Set(edit?.remove ?? []);\n\t\tselected = [...base, ...(edit?.add ?? [])].filter((name) => !removed.has(name));\n\t}\n\tconst extensions: Extension<Tool>[] = [];\n\tfor (const name of new Set(selected)) {\n\t\tconst extension = snapshot.extension(name);\n\t\tif (extension !== undefined) extensions.push(extension);\n\t}\n\treturn extensions;\n}\n\nfunction applyWrap<T>(\n\titems: Map<string, T>,\n\ttarget: string,\n\twrap: (item: T) => T,\n\tnameOf: (item: T) => string,\n\treport: (error: unknown) => void,\n): void {\n\tconst item = items.get(target);\n\tif (item === undefined) return;\n\ttry {\n\t\tconst wrapped = wrap(item);\n\t\tif (nameOf(wrapped) !== target) throw new Error(`Wrapper renamed ${target} to ${nameOf(wrapped)}`);\n\t\titems.set(target, wrapped);\n\t} catch (error) {\n\t\titems.delete(target);\n\t\treport(error);\n\t}\n}\n"]}
@@ -51,6 +51,11 @@ export declare function summarizedMessages(view: ContextView, cut: number): Mess
51
51
  * every message.
52
52
  */
53
53
  export declare function estimateContext(view: ContextView, extra: readonly Message[]): number;
54
- /** Messages as plain text, so the summarizer reads a transcript instead of continuing it. System messages are omitted. */
54
+ /**
55
+ * Messages as plain text, so the summarizer reads a transcript instead of continuing it. System messages are omitted.
56
+ * Thinking is omitted too: providers return summaries of the real reasoning, and replayed thinking is often not part of
57
+ * the live context (a block that does not match its request is dropped), so including it can make the request larger
58
+ * than the context it summarizes. Visible text, tool calls, and tool results record what happened.
59
+ */
55
60
  export declare function serializeConversation(messages: readonly Message[]): string;
56
61
  //# sourceMappingURL=compaction.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"compaction.d.ts","sourceRoot":"","sources":["../../src/harness/compaction.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAoB,OAAO,EAAE,kBAAkB,EAAuB,MAAM,uBAAuB,CAAC;AAKhH,OAA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;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,cAAc,CAAC,CAAC;AAiDxD;;;;GAIG;AACH,eAAO,MAAM,cAAc,sGA6HzB,CAAC;AAEH;;;GAGG;AACH,wBAAsB,gBAAgB,CACrC,EAAE,EAAE,EAAE,EACN,cAAc,EAAE,cAAc,EAC9B,KAAK,EAAE,eAAe,EACtB,KAAK,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAQnC;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAkBzF;AAwBD,iHAAiH;AACjH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,EAAE,CAE5E;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,CAepF;AA4BD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,CAyB1E"}
@@ -3,7 +3,7 @@ import { isRetryableAssistantError, retryDelayMs } from "@earendil-works/pi-ai/u
3
3
  import { CompactionEntry } from "../entries.js";
4
4
  import { defineTask } from "../tasks.js";
5
5
  import { orderToolResults } from "./context.js";
6
- import { addCompactionStatus, compactionStatus, LiveDoc, removeCompactionStatus } from "./live.js";
6
+ import { addCompactionStatus, compactionStatus, failCompactionStatus, LiveDoc, removeCompactionStatus, } from "./live.js";
7
7
  import { ensureProviderSessionId } from "./provider.js";
8
8
  import { admitSubmission } from "./submissions.js";
9
9
  import { recordUsage } from "./usage.js";
@@ -146,8 +146,8 @@ export const CompactionTask = defineTask({
146
146
  status.retry = { at: until, error: message.errorMessage ?? "" };
147
147
  return { status: "running", checkpoint: { phase: "retry", ...request, until } };
148
148
  }
149
- removeCompactionStatus(live, runtime.taskId);
150
149
  const text = summaryFailure(message);
150
+ failCompactionStatus(live, runtime.taskId, text);
151
151
  return {
152
152
  status: "terminal",
153
153
  outcome: { status: "failed", error: { message: text, detail: { reason: "model_error" } } },
@@ -295,7 +295,12 @@ function summaryPrompt(messages, instructions) {
295
295
  const focus = instructions === undefined ? "" : `\n\nAdditional focus: ${instructions}`;
296
296
  return `<conversation>\n${serializeConversation(messages)}\n</conversation>\n\n${SUMMARIZATION_PROMPT}${focus}`;
297
297
  }
298
- /** Messages as plain text, so the summarizer reads a transcript instead of continuing it. System messages are omitted. */
298
+ /**
299
+ * Messages as plain text, so the summarizer reads a transcript instead of continuing it. System messages are omitted.
300
+ * Thinking is omitted too: providers return summaries of the real reasoning, and replayed thinking is often not part of
301
+ * the live context (a block that does not match its request is dropped), so including it can make the request larger
302
+ * than the context it summarizes. Visible text, tool calls, and tool results record what happened.
303
+ */
299
304
  export function serializeConversation(messages) {
300
305
  const parts = [];
301
306
  for (const message of messages) {
@@ -305,7 +310,6 @@ export function serializeConversation(messages) {
305
310
  parts.push(`[User]: ${text}`);
306
311
  }
307
312
  else if (message.role === "assistant") {
308
- const thinking = message.content.flatMap((content) => (content.type === "thinking" ? [content.thinking] : []));
309
313
  const text = message.content.flatMap((content) => (content.type === "text" ? [content.text] : []));
310
314
  const calls = message.content.flatMap((content) => content.type === "toolCall"
311
315
  ? [
@@ -314,8 +318,6 @@ export function serializeConversation(messages) {
314
318
  .join(", ")})`,
315
319
  ]
316
320
  : []);
317
- if (thinking.length > 0)
318
- parts.push(`[Assistant thinking]: ${thinking.join("\n")}`);
319
321
  if (text.length > 0)
320
322
  parts.push(`[Assistant]: ${text.join("\n")}`);
321
323
  if (calls.length > 0)
@@ -353,6 +355,7 @@ async function place(runtime, firstKept, summary, context) {
353
355
  */
354
356
  async function placeSummary(tx, runtime, current, live, firstKept, summary) {
355
357
  removeCompactionStatus(live, runtime.taskId);
358
+ delete live.compactionFailure;
356
359
  const text = `${SUMMARY_PREFIX}${summary}${SUMMARY_SUFFIX}`;
357
360
  const entry = {
358
361
  kind: CompactionEntry.kind,
@@ -377,7 +380,7 @@ async function complete(runtime, context) {
377
380
  async function failNoModel(runtime, ref, context) {
378
381
  const message = ref === undefined ? "No model is configured" : `Model ${ref.provider}/${ref.modelId} is not available`;
379
382
  await runtime.commit(async (tx) => {
380
- removeCompactionStatus(await tx.doc(LiveDoc, runtime.conversationId), runtime.taskId);
383
+ failCompactionStatus(await tx.doc(LiveDoc, runtime.conversationId), runtime.taskId, message);
381
384
  return { status: "terminal", outcome: { status: "failed", error: { message, detail: { reason: "no_model" } } } };
382
385
  }, context);
383
386
  }