@code-yeongyu/senpi-agent-core 2026.9.29 → 2026.9.30

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 (222) hide show
  1. package/dist/harness/utils/read-folders/index.d.ts +2 -2
  2. package/dist/harness/utils/read-folders/index.js +2 -2
  3. package/dist/harness/utils/read-folders/tree-sitter/grammar-assets.js +1 -1
  4. package/package.json +4 -3
  5. package/dist/agent-loop.d.ts.map +0 -1
  6. package/dist/agent-loop.js.map +0 -1
  7. package/dist/agent.d.ts.map +0 -1
  8. package/dist/agent.js.map +0 -1
  9. package/dist/assistant-terminal-state.d.ts.map +0 -1
  10. package/dist/assistant-terminal-state.js.map +0 -1
  11. package/dist/empty-assistant-recovery.d.ts.map +0 -1
  12. package/dist/empty-assistant-recovery.js.map +0 -1
  13. package/dist/harness/agent-harness.d.ts.map +0 -1
  14. package/dist/harness/agent-harness.js.map +0 -1
  15. package/dist/harness/compaction/branch-summarization.d.ts.map +0 -1
  16. package/dist/harness/compaction/branch-summarization.js.map +0 -1
  17. package/dist/harness/compaction/compaction.d.ts.map +0 -1
  18. package/dist/harness/compaction/compaction.js.map +0 -1
  19. package/dist/harness/compaction/utils.d.ts.map +0 -1
  20. package/dist/harness/compaction/utils.js.map +0 -1
  21. package/dist/harness/config.d.ts.map +0 -1
  22. package/dist/harness/config.js.map +0 -1
  23. package/dist/harness/context.d.ts.map +0 -1
  24. package/dist/harness/context.js.map +0 -1
  25. package/dist/harness/env/nodejs.d.ts.map +0 -1
  26. package/dist/harness/env/nodejs.js.map +0 -1
  27. package/dist/harness/events.d.ts.map +0 -1
  28. package/dist/harness/events.js.map +0 -1
  29. package/dist/harness/execution/assistant.d.ts.map +0 -1
  30. package/dist/harness/execution/assistant.js.map +0 -1
  31. package/dist/harness/execution/effect-gate.d.ts.map +0 -1
  32. package/dist/harness/execution/effect-gate.js.map +0 -1
  33. package/dist/harness/execution/tools.d.ts.map +0 -1
  34. package/dist/harness/execution/tools.js.map +0 -1
  35. package/dist/harness/hooks.d.ts.map +0 -1
  36. package/dist/harness/hooks.js.map +0 -1
  37. package/dist/harness/messages.d.ts.map +0 -1
  38. package/dist/harness/messages.js.map +0 -1
  39. package/dist/harness/prompt-templates.d.ts.map +0 -1
  40. package/dist/harness/prompt-templates.js.map +0 -1
  41. package/dist/harness/result.d.ts.map +0 -1
  42. package/dist/harness/result.js.map +0 -1
  43. package/dist/harness/runtime/drive/boundary.d.ts.map +0 -1
  44. package/dist/harness/runtime/drive/boundary.js.map +0 -1
  45. package/dist/harness/runtime/drive/checkpoint.d.ts.map +0 -1
  46. package/dist/harness/runtime/drive/checkpoint.js.map +0 -1
  47. package/dist/harness/runtime/drive/deferred.d.ts.map +0 -1
  48. package/dist/harness/runtime/drive/deferred.js.map +0 -1
  49. package/dist/harness/runtime/drive/generation.d.ts.map +0 -1
  50. package/dist/harness/runtime/drive/generation.js.map +0 -1
  51. package/dist/harness/runtime/drive/reconcile.d.ts.map +0 -1
  52. package/dist/harness/runtime/drive/reconcile.js.map +0 -1
  53. package/dist/harness/runtime/drive/recovery.d.ts.map +0 -1
  54. package/dist/harness/runtime/drive/recovery.js.map +0 -1
  55. package/dist/harness/runtime/drive/response.d.ts.map +0 -1
  56. package/dist/harness/runtime/drive/response.js.map +0 -1
  57. package/dist/harness/runtime/drive/retry.d.ts.map +0 -1
  58. package/dist/harness/runtime/drive/retry.js.map +0 -1
  59. package/dist/harness/runtime/drive/structural.d.ts.map +0 -1
  60. package/dist/harness/runtime/drive/structural.js.map +0 -1
  61. package/dist/harness/runtime/drive/terminal.d.ts.map +0 -1
  62. package/dist/harness/runtime/drive/terminal.js.map +0 -1
  63. package/dist/harness/runtime/drive/tool-placement.d.ts.map +0 -1
  64. package/dist/harness/runtime/drive/tool-placement.js.map +0 -1
  65. package/dist/harness/runtime/drive/tools.d.ts.map +0 -1
  66. package/dist/harness/runtime/drive/tools.js.map +0 -1
  67. package/dist/harness/runtime/drive.d.ts.map +0 -1
  68. package/dist/harness/runtime/drive.js.map +0 -1
  69. package/dist/harness/runtime/harness.d.ts.map +0 -1
  70. package/dist/harness/runtime/harness.js.map +0 -1
  71. package/dist/harness/runtime/index.d.ts.map +0 -1
  72. package/dist/harness/runtime/index.js.map +0 -1
  73. package/dist/harness/runtime/lane.d.ts.map +0 -1
  74. package/dist/harness/runtime/lane.js.map +0 -1
  75. package/dist/harness/runtime/progress.d.ts.map +0 -1
  76. package/dist/harness/runtime/progress.js.map +0 -1
  77. package/dist/harness/runtime/reducer.d.ts.map +0 -1
  78. package/dist/harness/runtime/reducer.js.map +0 -1
  79. package/dist/harness/runtime/restore.d.ts.map +0 -1
  80. package/dist/harness/runtime/restore.js.map +0 -1
  81. package/dist/harness/runtime/transcript.d.ts.map +0 -1
  82. package/dist/harness/runtime/transcript.js.map +0 -1
  83. package/dist/harness/runtime/types.d.ts.map +0 -1
  84. package/dist/harness/runtime/types.js.map +0 -1
  85. package/dist/harness/session/commit.d.ts.map +0 -1
  86. package/dist/harness/session/commit.js.map +0 -1
  87. package/dist/harness/session/context.d.ts.map +0 -1
  88. package/dist/harness/session/context.js.map +0 -1
  89. package/dist/harness/session/fork-policy.d.ts.map +0 -1
  90. package/dist/harness/session/fork-policy.js.map +0 -1
  91. package/dist/harness/session/fork.d.ts.map +0 -1
  92. package/dist/harness/session/fork.js.map +0 -1
  93. package/dist/harness/session/in-memory-storage-state.d.ts.map +0 -1
  94. package/dist/harness/session/in-memory-storage-state.js.map +0 -1
  95. package/dist/harness/session/index.d.ts.map +0 -1
  96. package/dist/harness/session/index.js.map +0 -1
  97. package/dist/harness/session/jsonl/codec.d.ts.map +0 -1
  98. package/dist/harness/session/jsonl/codec.js.map +0 -1
  99. package/dist/harness/session/jsonl/fork.d.ts.map +0 -1
  100. package/dist/harness/session/jsonl/fork.js.map +0 -1
  101. package/dist/harness/session/jsonl/index.d.ts.map +0 -1
  102. package/dist/harness/session/jsonl/index.js.map +0 -1
  103. package/dist/harness/session/jsonl/io.d.ts.map +0 -1
  104. package/dist/harness/session/jsonl/io.js.map +0 -1
  105. package/dist/harness/session/jsonl/legacy-v3.d.ts.map +0 -1
  106. package/dist/harness/session/jsonl/legacy-v3.js.map +0 -1
  107. package/dist/harness/session/jsonl/repo.d.ts.map +0 -1
  108. package/dist/harness/session/jsonl/repo.js.map +0 -1
  109. package/dist/harness/session/jsonl/storage.d.ts.map +0 -1
  110. package/dist/harness/session/jsonl/storage.js.map +0 -1
  111. package/dist/harness/session/jsonl/types.d.ts.map +0 -1
  112. package/dist/harness/session/jsonl/types.js.map +0 -1
  113. package/dist/harness/session/memory.d.ts.map +0 -1
  114. package/dist/harness/session/memory.js.map +0 -1
  115. package/dist/harness/session/mutation-line.d.ts.map +0 -1
  116. package/dist/harness/session/mutation-line.js.map +0 -1
  117. package/dist/harness/session/session.d.ts.map +0 -1
  118. package/dist/harness/session/session.js.map +0 -1
  119. package/dist/harness/session/testing/benchmark/datasets.d.ts.map +0 -1
  120. package/dist/harness/session/testing/benchmark/datasets.js.map +0 -1
  121. package/dist/harness/session/testing/benchmark/session-repo.d.ts.map +0 -1
  122. package/dist/harness/session/testing/benchmark/session-repo.js.map +0 -1
  123. package/dist/harness/session/testing/benchmark/storage.d.ts.map +0 -1
  124. package/dist/harness/session/testing/benchmark/storage.js.map +0 -1
  125. package/dist/harness/session/testing/conformance/session-repo.d.ts.map +0 -1
  126. package/dist/harness/session/testing/conformance/session-repo.js.map +0 -1
  127. package/dist/harness/session/testing/conformance/storage.d.ts.map +0 -1
  128. package/dist/harness/session/testing/conformance/storage.js.map +0 -1
  129. package/dist/harness/session/testing/gating-storage.d.ts.map +0 -1
  130. package/dist/harness/session/testing/gating-storage.js.map +0 -1
  131. package/dist/harness/session/testing/index.d.ts.map +0 -1
  132. package/dist/harness/session/testing/index.js.map +0 -1
  133. package/dist/harness/session/testing/instrumented-storage.d.ts.map +0 -1
  134. package/dist/harness/session/testing/instrumented-storage.js.map +0 -1
  135. package/dist/harness/session/testing/storage-decorator.d.ts.map +0 -1
  136. package/dist/harness/session/testing/storage-decorator.js.map +0 -1
  137. package/dist/harness/session/testing/types.d.ts.map +0 -1
  138. package/dist/harness/session/testing/types.js.map +0 -1
  139. package/dist/harness/session/types.d.ts.map +0 -1
  140. package/dist/harness/session/types.js.map +0 -1
  141. package/dist/harness/session/values.d.ts.map +0 -1
  142. package/dist/harness/session/values.js.map +0 -1
  143. package/dist/harness/skills.d.ts.map +0 -1
  144. package/dist/harness/skills.js.map +0 -1
  145. package/dist/harness/system-prompt.d.ts.map +0 -1
  146. package/dist/harness/system-prompt.js.map +0 -1
  147. package/dist/harness/telemetry.d.ts.map +0 -1
  148. package/dist/harness/telemetry.js.map +0 -1
  149. package/dist/harness/tools/bash.d.ts.map +0 -1
  150. package/dist/harness/tools/bash.js.map +0 -1
  151. package/dist/harness/tools/edit-diff.d.ts.map +0 -1
  152. package/dist/harness/tools/edit-diff.js.map +0 -1
  153. package/dist/harness/tools/edit.d.ts.map +0 -1
  154. package/dist/harness/tools/edit.js.map +0 -1
  155. package/dist/harness/tools/file-mutation-queue.d.ts.map +0 -1
  156. package/dist/harness/tools/file-mutation-queue.js.map +0 -1
  157. package/dist/harness/tools/image.d.ts.map +0 -1
  158. package/dist/harness/tools/image.js.map +0 -1
  159. package/dist/harness/tools/index.d.ts.map +0 -1
  160. package/dist/harness/tools/index.js.map +0 -1
  161. package/dist/harness/tools/path-utils.d.ts.map +0 -1
  162. package/dist/harness/tools/path-utils.js.map +0 -1
  163. package/dist/harness/tools/post-mutate.d.ts.map +0 -1
  164. package/dist/harness/tools/post-mutate.js.map +0 -1
  165. package/dist/harness/tools/read.d.ts.map +0 -1
  166. package/dist/harness/tools/read.js.map +0 -1
  167. package/dist/harness/tools/tool-context.d.ts.map +0 -1
  168. package/dist/harness/tools/tool-context.js.map +0 -1
  169. package/dist/harness/tools/write.d.ts.map +0 -1
  170. package/dist/harness/tools/write.js.map +0 -1
  171. package/dist/harness/types.d.ts.map +0 -1
  172. package/dist/harness/types.js.map +0 -1
  173. package/dist/harness/utils/adaptive-publisher.d.ts.map +0 -1
  174. package/dist/harness/utils/adaptive-publisher.js.map +0 -1
  175. package/dist/harness/utils/output-capture.d.ts.map +0 -1
  176. package/dist/harness/utils/output-capture.js.map +0 -1
  177. package/dist/harness/utils/read-folders/brace-scanner.d.ts.map +0 -1
  178. package/dist/harness/utils/read-folders/brace-scanner.js.map +0 -1
  179. package/dist/harness/utils/read-folders/compose.d.ts.map +0 -1
  180. package/dist/harness/utils/read-folders/compose.js.map +0 -1
  181. package/dist/harness/utils/read-folders/header-protection.d.ts.map +0 -1
  182. package/dist/harness/utils/read-folders/header-protection.js.map +0 -1
  183. package/dist/harness/utils/read-folders/index.d.ts.map +0 -1
  184. package/dist/harness/utils/read-folders/index.js.map +0 -1
  185. package/dist/harness/utils/read-folders/lexical-context.d.ts.map +0 -1
  186. package/dist/harness/utils/read-folders/lexical-context.js.map +0 -1
  187. package/dist/harness/utils/read-folders/lexical-spans.d.ts.map +0 -1
  188. package/dist/harness/utils/read-folders/lexical-spans.js.map +0 -1
  189. package/dist/harness/utils/read-folders/prepare.d.ts.map +0 -1
  190. package/dist/harness/utils/read-folders/prepare.js.map +0 -1
  191. package/dist/harness/utils/read-folders/tree-sitter/engine.d.ts.map +0 -1
  192. package/dist/harness/utils/read-folders/tree-sitter/engine.js.map +0 -1
  193. package/dist/harness/utils/read-folders/tree-sitter/grammar-assets.d.ts.map +0 -1
  194. package/dist/harness/utils/read-folders/tree-sitter/grammar-assets.js.map +0 -1
  195. package/dist/harness/utils/read-folders/tree-sitter/syntax.d.ts.map +0 -1
  196. package/dist/harness/utils/read-folders/tree-sitter/syntax.js.map +0 -1
  197. package/dist/harness/utils/read-folders/types.d.ts.map +0 -1
  198. package/dist/harness/utils/read-folders/types.js.map +0 -1
  199. package/dist/harness/utils/segmented-read-view.d.ts.map +0 -1
  200. package/dist/harness/utils/segmented-read-view.js.map +0 -1
  201. package/dist/harness/utils/shell-output.d.ts.map +0 -1
  202. package/dist/harness/utils/shell-output.js.map +0 -1
  203. package/dist/harness/utils/truncate.d.ts.map +0 -1
  204. package/dist/harness/utils/truncate.js.map +0 -1
  205. package/dist/harness/utils/usage.d.ts.map +0 -1
  206. package/dist/harness/utils/usage.js.map +0 -1
  207. package/dist/index.d.ts.map +0 -1
  208. package/dist/index.js.map +0 -1
  209. package/dist/node.d.ts.map +0 -1
  210. package/dist/node.js.map +0 -1
  211. package/dist/proxy.d.ts.map +0 -1
  212. package/dist/proxy.js.map +0 -1
  213. package/dist/search/index.d.ts.map +0 -1
  214. package/dist/search/index.js.map +0 -1
  215. package/dist/stream-fn.d.ts.map +0 -1
  216. package/dist/stream-fn.js.map +0 -1
  217. package/dist/tool-arguments.d.ts.map +0 -1
  218. package/dist/tool-arguments.js.map +0 -1
  219. package/dist/tool-name-alias.d.ts.map +0 -1
  220. package/dist/tool-name-alias.js.map +0 -1
  221. package/dist/types.d.ts.map +0 -1
  222. package/dist/types.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"syntax.js","sourceRoot":"","sources":["../../../../../src/harness/utils/read-folders/tree-sitter/syntax.ts"],"names":[],"mappings":"AAiBA,6GAA6G;AAC7G,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,iBAAiB,EAAE,QAAQ,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC;AACjF,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC;IAC7B,sBAAsB;IACtB,qBAAqB;IACrB,UAAU;IACV,oBAAoB;IACpB,gCAAgC;IAChC,gBAAgB;IAChB,mBAAmB;IACnB,oBAAoB;IACpB,kBAAkB;IAClB,2BAA2B;CAC3B,CAAC,CAAC;AACH,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,mBAAmB,EAAE,4BAA4B,CAAC,CAAC,CAAC;AACzF,4GAA4G;AAC5G,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC;IAC3B,iBAAi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AO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AACrC,CAAC","sourcesContent":["import type { ReadBraceScan, ReadFoldSettings, ReadLineRange } from \"../types.ts\";\n\n/** Structural subset of a web-tree-sitter node: the fold rule stays pure and grammar-runtime free. */\nexport interface SyntaxNode {\n\treadonly id: number;\n\treadonly type: string;\n\treadonly text: string;\n\treadonly startPosition: { readonly row: number };\n\treadonly endPosition: { readonly row: number };\n\treadonly children: readonly (SyntaxNode | null)[];\n\treadonly hasError: boolean;\n\treadonly isMissing: boolean;\n\tchildForFieldName(field: string): SyntaxNode | null;\n}\n\nexport type TreeSitterLanguage = \"ts\" | \"tsx\" | \"js\";\n\n/** Implementation/value containers, mirroring the compiler oracle's whitelist. Class bodies are excluded. */\nconst bodyKinds = new Set([\"statement_block\", \"object\", \"array\", \"switch_body\"]);\nconst functionKinds = new Set([\n\t\"function_declaration\",\n\t\"function_expression\",\n\t\"function\",\n\t\"generator_function\",\n\t\"generator_function_declaration\",\n\t\"arrow_function\",\n\t\"method_definition\",\n\t\"function_signature\",\n\t\"method_signature\",\n\t\"abstract_method_signature\",\n]);\nconst classKinds = new Set([\"class\", \"class_declaration\", \"abstract_class_declaration\"]);\n/** Header material: a fold overlapping any of these lines is rejected, exactly as the oracle rejects it. */\nconst opaqueKinds = new Set([\n\t\"type_annotation\",\n\t\"type_arguments\",\n\t\"type_parameters\",\n\t\"type_alias_declaration\",\n\t\"interface_declaration\",\n\t\"type_predicate_annotation\",\n\t\"omitting_type_annotation\",\n\t\"opting_type_annotation\",\n\t\"asserts_annotation\",\n\t\"type_identifier\",\n\t\"predefined_type\",\n\t\"nested_type_identifier\",\n\t\"formal_parameters\",\n\t\"class_heritage\",\n\t\"extends_clause\",\n\t\"extends_type_clause\",\n\t\"implements_clause\",\n\t\"decorator\",\n\t\"import_statement\",\n\t\"object_pattern\",\n\t\"array_pattern\",\n\t\"computed_property_name\",\n\t\"ambient_declaration\",\n]);\n\nfunction isOpaque(node: SyntaxNode): boolean {\n\treturn opaqueKinds.has(node.type) || node.type.endsWith(\"_type\") || node.type.endsWith(\"_type_annotation\");\n}\n\nfunction childNodes(node: SyntaxNode): SyntaxNode[] {\n\tconst children: SyntaxNode[] = [];\n\tfor (const child of node.children) if (child) children.push(child);\n\treturn children;\n}\n\nfunction openBrace(node: SyntaxNode): SyntaxNode | undefined {\n\tfor (const child of childNodes(node)) if (child.type === \"{\" || child.type === \"[\") return child;\n\treturn undefined;\n}\n\nfunction closeBrace(node: SyntaxNode): SyntaxNode | undefined {\n\tconst children = childNodes(node);\n\tfor (let index = children.length - 1; index >= 0; index--) {\n\t\tconst child = children[index];\n\t\tif (child.type === \"}\" || child.type === \"]\") return child;\n\t}\n\treturn undefined;\n}\n\nfunction exportsOnlyBindings(node: SyntaxNode): boolean {\n\t// `export { a } from \"b\"` / `export * from \"b\"` is a declaration header; `export const x = {}` is not.\n\tfor (const child of childNodes(node))\n\t\tif (child.type === \"export_clause\" || child.type === \"*\" || child.type === \"namespace_export\") return true;\n\treturn false;\n}\n\n/** `x as const` / `x satisfies T`: everything from the operator on is type material. */\nfunction typeOperator(node: SyntaxNode): SyntaxNode | undefined {\n\tif (node.type !== \"as_expression\" && node.type !== \"satisfies_expression\") return undefined;\n\treturn childNodes(node).find((child) => child.type === \"as\" || child.type === \"satisfies\");\n}\n\nfunction assignmentTarget(node: SyntaxNode): SyntaxNode | undefined {\n\tif (node.type !== \"assignment_expression\" && node.type !== \"for_in_statement\") return undefined;\n\tconst left = node.childForFieldName(\"left\");\n\tif (!left) return undefined;\n\tlet target = left;\n\twhile (target.type === \"parenthesized_expression\") {\n\t\tconst inner = childNodes(target).find((child) => child.type !== \"(\" && child.type !== \")\");\n\t\tif (!inner) break;\n\t\ttarget = inner;\n\t}\n\treturn target.type === \"object\" || target.type === \"array\" ? left : undefined;\n}\n\n/**\n * Fold boundaries from a parsed syntax tree, produced under the same rules the compiler oracle\n * uses to annotate safe interiors: value containers only, never a line of a declaration header.\n */\nexport function foldRangesFromSyntax(root: SyntaxNode, settings: ReadFoldSettings): ReadBraceScan {\n\tif (root.hasError || root.isMissing) return { status: \"parse_failure\", reason: \"tree_sitter_parse_error\" };\n\tconst candidates: ReadLineRange[] = [];\n\tconst guarded: ReadLineRange[] = [];\n\tconst protect = (startLine: number, endLine: number) => {\n\t\tif (endLine >= startLine) guarded.push({ startLine, endLine });\n\t};\n\tconst line = (row: number) => row + 1;\n\tconst visit = (node: SyntaxNode): void => {\n\t\tif (isOpaque(node) || (node.type === \"export_statement\" && exportsOnlyBindings(node))) {\n\t\t\tprotect(line(node.startPosition.row), line(node.endPosition.row));\n\t\t\treturn;\n\t\t}\n\t\tif (node.type === \"comment\") {\n\t\t\tconst lines = node.endPosition.row - node.startPosition.row + 1;\n\t\t\tif (node.text.startsWith(\"/**\") || node.text.startsWith(\"/*!\"))\n\t\t\t\tprotect(line(node.startPosition.row), line(node.endPosition.row));\n\t\t\telse if (lines >= settings.minCommentLines)\n\t\t\t\tcandidates.push({ startLine: line(node.startPosition.row) + 1, endLine: line(node.endPosition.row) - 1 });\n\t\t\treturn;\n\t\t}\n\t\tconst operator = typeOperator(node);\n\t\tif (operator) {\n\t\t\tprotect(line(operator.startPosition.row), line(node.endPosition.row));\n\t\t\tfor (const child of childNodes(node)) {\n\t\t\t\tif (child.id === operator.id) break;\n\t\t\t\tvisit(child);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tconst target = assignmentTarget(node);\n\t\tif (target) {\n\t\t\tprotect(line(target.startPosition.row), line(target.endPosition.row));\n\t\t\tfor (const child of childNodes(node)) if (child.id !== target.id) visit(child);\n\t\t\treturn;\n\t\t}\n\t\tif (functionKinds.has(node.type)) {\n\t\t\tconst body = node.childForFieldName(\"body\");\n\t\t\tif (!body) {\n\t\t\t\tprotect(line(node.startPosition.row), line(node.endPosition.row));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// The header owns every line through the line that opens the body.\n\t\t\tprotect(line(node.startPosition.row), line(body.startPosition.row));\n\t\t\tvisit(body);\n\t\t\treturn;\n\t\t}\n\t\tif (classKinds.has(node.type)) {\n\t\t\tconst body = node.childForFieldName(\"body\");\n\t\t\tconst open = body ? openBrace(body) : undefined;\n\t\t\tif (!body || !open) {\n\t\t\t\tprotect(line(node.startPosition.row), line(node.endPosition.row));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tprotect(line(node.startPosition.row), line(open.startPosition.row));\n\t\t\tfor (const member of childNodes(body)) visit(member);\n\t\t\treturn;\n\t\t}\n\t\tif (bodyKinds.has(node.type)) {\n\t\t\tconst open = openBrace(node);\n\t\t\tconst close = closeBrace(node);\n\t\t\tif (open && close) {\n\t\t\t\tconst startLine = line(open.startPosition.row) + 1;\n\t\t\t\tconst endLine = line(close.startPosition.row) - 1;\n\t\t\t\tif (endLine - startLine + 1 >= settings.minBodyLines) candidates.push({ startLine, endLine });\n\t\t\t}\n\t\t}\n\t\tfor (const child of childNodes(node)) visit(child);\n\t};\n\tvisit(root);\n\tconst ranges = candidates.filter(\n\t\t(range) =>\n\t\t\t!guarded.some((header) => range.startLine <= header.endLine && range.endLine >= header.startLine) &&\n\t\t\trange.endLine >= range.startLine,\n\t);\n\treturn { status: \"parsed\", ranges };\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/harness/utils/read-folders/types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB;2BAChB,CAAC;8BACE,CAAC;4BACH,GAAG;0BACL,EAAE;0BACF,GAAG;EACN,CAAC;AAEZ,2EAA2E;AAC3E,MAAM,MAAM,gBAAgB,GAAG,OAAO,kBAAkB,CAAC;AACzD,MAAM,MAAM,aAAa,GAAG;IAAE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AACrF,MAAM,MAAM,aAAa,GACtB;IAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ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C/C,YAAY,EAAE,CAAC;IACf,eAAe,EAAE,CAAC;IAClB,aAAa,EAAE,GAAG;IAClB,WAAW,EAAE,EAAE;IACf,WAAW,EAAE,GAAG;CACP,CAAC,CAAC","sourcesContent":["export const READ_FOLD_SETTINGS = Object.freeze({\n\tminBodyLines: 4,\n\tminCommentLines: 6,\n\tminTotalLines: 100,\n\tunfoldUntil: 50,\n\tunfoldLimit: 100,\n} as const);\n\n/** Internal policy constants, not a user-configurable settings surface. */\nexport type ReadFoldSettings = typeof READ_FOLD_SETTINGS;\nexport type ReadLineRange = { readonly startLine: number; readonly endLine: number };\nexport type ReadBraceScan =\n\t| { readonly status: \"parsed\"; readonly ranges: readonly ReadLineRange[] }\n\t| { readonly status: \"parse_failure\"; readonly reason: string };\n/** Inclusive, 1-based omitted interiors. Children exclude their parent's boundary lines. */\nexport type ReadFoldRange = ReadLineRange & { readonly children: readonly ReadFoldRange[] };\nexport type ReadFolderInput = {\n\treadonly path: string;\n\treadonly text: string;\n\treadonly settings: ReadFoldSettings;\n};\nexport type ReadFolderResult =\n\t| { readonly status: \"parsed\"; readonly text: string; readonly ranges: readonly ReadFoldRange[] }\n\t| { readonly status: \"unsupported\"; readonly reason: \"unsupported_language\" | \"prose_exempt\" }\n\t| { readonly status: \"parse_failure\"; readonly reason: string };\n\n/** Synchronous and pure. I/O, cancellation and unexpected exceptions belong to the caller. */\nexport interface ReadFolder {\n\treadonly id: string;\n\treadonly version: string;\n\tfold(input: ReadFolderInput): ReadFolderResult;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"segmented-read-view.d.ts","sourceRoot":"","sources":["../../../src/harness/utils/segmented-read-view.ts"],"names":[],"mappings":"AACA,OAAO,EAEN,KAAK,UAAU,EACf,KAAK,gBAAgB,EAErB,KAAK,aAAa,EAClB,MAAM,yBAAyB,CAAC;AAEjC,MAAM,MAAM,WAAW,GACpB,CAAC,aAAa,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;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AO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,kBAAkB,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;AAC/E,CAAC","sourcesContent":["import { isReadSummaryPath } from \"./read-folders/index.ts\";\nimport {\n\tREAD_FOLD_SETTINGS,\n\ttype ReadFolder,\n\ttype ReadFolderResult,\n\ttype ReadFoldRange,\n\ttype ReadLineRange,\n} from \"./read-folders/types.ts\";\n\nexport type ReadSegment =\n\t| (ReadLineRange & { readonly kind: \"kept\"; readonly text: string })\n\t| (ReadLineRange & { readonly kind: \"elided\" });\nexport type RenderedReadView = {\n\treadonly text: string;\n\treadonly elidedRanges: readonly ReadLineRange[];\n\treadonly footer: {\n\t\treadonly text: string;\n\t\treadonly rereads: readonly { readonly offset: number; readonly limit: number }[];\n\t};\n};\nexport type ReadSummaryFallback =\n\t| \"unsupported_language\"\n\t| \"prose_exempt\"\n\t| \"parse_failure\"\n\t| \"stale_source\"\n\t| \"invalid_ranges\"\n\t| \"too_short\"\n\t| \"no_elision\"\n\t| \"skeleton_exceeds_budget\"\n\t| \"visible_budget_unreachable\"\n\t| \"no_output_saving\";\nexport type SegmentedReadView =\n\t| {\n\t\t\treadonly status: \"summary\";\n\t\t\treadonly segments: readonly ReadSegment[];\n\t\t\treadonly visibleSourceLines: number;\n\t\t\treadonly rendered: RenderedReadView;\n\t }\n\t| { readonly status: \"no_summary\"; readonly reason: ReadSummaryFallback };\n\n/** Compose only untruncated default text reads; each reader owns its existing raw path. */\nexport function createDefaultReadSummary(input: {\n\treadonly path: string;\n\treadonly text: string;\n\treadonly offset?: number;\n\treadonly limit?: number;\n\treadonly folder?: ReadFolder;\n\treadonly truncated: boolean;\n}): RenderedReadView | undefined {\n\tconst { path, text, offset, limit, folder, truncated } = input;\n\tif (!folder || offset !== undefined || limit !== undefined || truncated || !isReadSummaryPath(path))\n\t\treturn undefined;\n\tif (text.includes(\"\\0\") || text.split(\"\\n\").length < READ_FOLD_SETTINGS.minTotalLines) return undefined;\n\tconst view = createSegmentedReadView({ text, parsed: folder.fold({ path, text, settings: READ_FOLD_SETTINGS }) });\n\tswitch (view.status) {\n\t\tcase \"summary\":\n\t\t\treturn view.rendered;\n\t\tcase \"no_summary\":\n\t\t\treturn undefined;\n\t\tdefault:\n\t\t\treturn view satisfies never;\n\t}\n}\n\nexport class InvalidReadSegmentsError extends Error {\n\treadonly code = \"invalid_segments\";\n\tconstructor() {\n\t\tsuper(\"Read segments must cover the source exactly, in order, without altering kept lines\");\n\t}\n}\n\nfunction validRange(range: ReadLineRange, total: number): boolean {\n\treturn (\n\t\tNumber.isSafeInteger(range.startLine) &&\n\t\tNumber.isSafeInteger(range.endLine) &&\n\t\trange.startLine >= 1 &&\n\t\trange.endLine >= range.startLine &&\n\t\trange.endLine <= total\n\t);\n}\n\n/** The sole validator/renderer/footer implementation. Synthetic lines are never source slices. */\nexport function renderSegmentedReadView({\n\ttext,\n\tsegments,\n}: {\n\treadonly text: string;\n\treadonly segments: readonly ReadSegment[];\n}): RenderedReadView {\n\tconst lines = text.split(\"\\n\");\n\tconst parts: string[] = [];\n\tconst elidedRanges: ReadLineRange[] = [];\n\tlet cursor = 1;\n\tfor (const segment of segments) {\n\t\tif (!validRange(segment, lines.length) || segment.startLine !== cursor) throw new InvalidReadSegmentsError();\n\t\tswitch (segment.kind) {\n\t\t\tcase \"kept\":\n\t\t\t\tif (segment.text !== lines.slice(segment.startLine - 1, segment.endLine).join(\"\\n\"))\n\t\t\t\t\tthrow new InvalidReadSegmentsError();\n\t\t\t\tparts.push(segment.text);\n\t\t\t\tbreak;\n\t\t\tcase \"elided\":\n\t\t\t\tparts.push(\"…\");\n\t\t\t\telidedRanges.push({ startLine: segment.startLine, endLine: segment.endLine });\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tsegment satisfies never;\n\t\t\t\tthrow new InvalidReadSegmentsError();\n\t\t}\n\t\tcursor = segment.endLine + 1;\n\t}\n\tif (cursor !== lines.length + 1) throw new InvalidReadSegmentsError();\n\tconst rereads = elidedRanges.map((range) => ({\n\t\toffset: range.startLine,\n\t\tlimit: range.endLine - range.startLine + 1,\n\t}));\n\tconst footerText = rereads.length\n\t\t? `[Elided source: ${rereads.map((r) => `offset=${r.offset} limit=${r.limit}`).join(\"; \")}. Reread source before editing; markers are not source.]`\n\t\t: \"\";\n\tif (footerText) parts.push(\"\", footerText);\n\treturn { text: parts.join(\"\\n\"), elidedRanges, footer: { text: footerText, rereads } };\n}\n\nfunction validHierarchy(ranges: readonly ReadFoldRange[], total: number): boolean {\n\tconst queue = [{ ranges, startLine: 0, endLine: total + 1 }];\n\tfor (let i = 0; i < queue.length; i++) {\n\t\tconst parent = queue[i];\n\t\tlet previous = parent.startLine;\n\t\tfor (const range of parent.ranges) {\n\t\t\tif (!validRange(range, total) || range.startLine <= previous || range.endLine >= parent.endLine) return false;\n\t\t\tprevious = range.endLine;\n\t\t\tqueue.push({ ranges: range.children, startLine: range.startLine, endLine: range.endLine });\n\t\t}\n\t}\n\treturn true;\n}\n\nconst lengthOf = (range: ReadLineRange) => range.endLine - range.startLine + 1;\n\n/** Breadth-first refinement counts only retained source lines, never sentinels/footer lines. */\nexport function createSegmentedReadView({\n\ttext,\n\tparsed,\n}: {\n\treadonly text: string;\n\treadonly parsed: ReadFolderResult;\n}): SegmentedReadView {\n\tconst raw = (reason: ReadSummaryFallback): SegmentedReadView => ({ status: \"no_summary\", reason });\n\tswitch (parsed.status) {\n\t\tcase \"unsupported\":\n\t\t\treturn raw(parsed.reason);\n\t\tcase \"parse_failure\":\n\t\t\treturn raw(\"parse_failure\");\n\t\tcase \"parsed\":\n\t\t\tbreak;\n\t\tdefault:\n\t\t\treturn parsed satisfies never;\n\t}\n\tif (parsed.text !== text) return raw(\"stale_source\");\n\tconst lines = text.split(\"\\n\");\n\tif (!validHierarchy(parsed.ranges, lines.length)) return raw(\"invalid_ranges\");\n\tif (lines.length < READ_FOLD_SETTINGS.minTotalLines) return raw(\"too_short\");\n\tif (!parsed.ranges.length) return raw(\"no_elision\");\n\tlet visible = lines.length - parsed.ranges.reduce((sum, r) => sum + lengthOf(r), 0);\n\tif (visible > READ_FOLD_SETTINGS.unfoldLimit) return raw(\"skeleton_exceeds_budget\");\n\tconst selected = new Set(parsed.ranges);\n\tconst queue = [...parsed.ranges];\n\tfor (let i = 0; visible < READ_FOLD_SETTINGS.unfoldUntil && i < queue.length; i++) {\n\t\tconst parent = queue[i];\n\t\tconst nextVisible = visible + lengthOf(parent) - parent.children.reduce((sum, r) => sum + lengthOf(r), 0);\n\t\t// Later steps only increase visibility, so an oversized step cannot become safe later.\n\t\tif (nextVisible > READ_FOLD_SETTINGS.unfoldLimit) continue;\n\t\tselected.delete(parent);\n\t\tfor (const child of parent.children) selected.add(child);\n\t\tqueue.push(...parent.children);\n\t\tvisible = nextVisible;\n\t}\n\tif (visible < READ_FOLD_SETTINGS.unfoldUntil) return raw(\"visible_budget_unreachable\");\n\tif (!selected.size) return raw(\"no_elision\");\n\tconst segments: ReadSegment[] = [];\n\tlet cursor = 1;\n\tfor (const range of [...selected].sort((a, b) => a.startLine - b.startLine)) {\n\t\tif (cursor < range.startLine)\n\t\t\tsegments.push({\n\t\t\t\tkind: \"kept\",\n\t\t\t\tstartLine: cursor,\n\t\t\t\tendLine: range.startLine - 1,\n\t\t\t\ttext: lines.slice(cursor - 1, range.startLine - 1).join(\"\\n\"),\n\t\t\t});\n\t\tsegments.push({ kind: \"elided\", startLine: range.startLine, endLine: range.endLine });\n\t\tcursor = range.endLine + 1;\n\t}\n\tif (cursor <= lines.length)\n\t\tsegments.push({\n\t\t\tkind: \"kept\",\n\t\t\tstartLine: cursor,\n\t\t\tendLine: lines.length,\n\t\t\ttext: lines.slice(cursor - 1).join(\"\\n\"),\n\t\t});\n\tconst rendered = renderSegmentedReadView({ text, segments });\n\tconst encoder = new TextEncoder();\n\tif (encoder.encode(rendered.text).length >= encoder.encode(text).length) return raw(\"no_output_saving\");\n\treturn { status: \"summary\", segments, visibleSourceLines: visible, rendered };\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"shell-output.d.ts","sourceRoot":"","sources":["../../../src/harness/utils/shell-output.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,cAAc,EAGnB,KAAK,MAAM,EACX,KAAK,gBAAgB,EAErB,MAAM,aAAa,CAAC;AACrB,OAAO,EAA0B,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAClF,OAAO,EAAwC,KAAK,gBAAgB,EAAgB,MAAM,eAAe,CAAC;AAE1G,MAAM,WAAW,oBAAoB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,gBAAgB,CAAC;IAC7B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAAC,gBAAgB,EAAE,SAAS,GAAG,UAAU,CAAC;IAC1F;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,oBAAoB,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IACjH,0FAA0F;IAC1F,qBAAqB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,WAAW,kBAAmB,SAAQ,oBAAoB;IAC/D,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,cAAc,CAAC;CAChC;AAWD;;;;GAIG;AACH,wBAAsB,uBAAuB,CAC5C,GAAG,EAAE,YAAY,EACjB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,mBAAmB,GAAG,SAAS,EACxC,OAAO,EAAE,OAAO,GACd,OAAO,CAAC,MAAM,C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AS,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC,CAAC;QAC5G,CAAC;QACD,IAAI,OAAO,EAAE,qBAAqB,EAAE,CAAC;YACpC,OAAO,EAAE,CAAC;gBACT,GAAG,QAAQ;gBACX,QAAQ,EAAE,SAAS;gBACnB,SAAS,EAAE,KAAK;gBAChB,SAAS,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS;gBACxC,cAAc,EAAE,MAAM,CAAC,KAAK;aAC5B,CAAC,CAAC;QACJ,CAAC;QACD,OAAO,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;IACD,OAAO,EAAE,CAAC;QACT,GAAG,QAAQ;QACX,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,QAAQ;QAC/B,SAAS,EAAE,KAAK;QAChB,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,SAAS;KAC5C,CAAC,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,mBAAmB,IAAI,oBAAoB,EAAE,CAAC","sourcesContent":["import type { Context } from \"../context.ts\";\nimport {\n\ttype ExecutionEnv,\n\ttype ExecutionError,\n\terr,\n\tok,\n\ttype Result,\n\ttype ShellExecOptions,\n\ttype ShellOutputView,\n} from \"../types.ts\";\nimport { applyShellOutputUpdate, sanitizeShellOutput } from \"./output-capture.ts\";\nimport { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, type TruncationResult, truncateTail } from \"./truncate.ts\";\n\nexport interface ShellCaptureProgress {\n\toutput: string;\n\ttruncation: TruncationResult;\n\tfullOutputPath?: string;\n\tlastLineBytes: number;\n}\n\nexport interface ShellCaptureOptions extends Omit<ShellExecOptions, \"capture\" | \"onUpdate\"> {\n\t/**\n\t * Called with each incremental output chunk.\n\t *\n\t * A returned promise is awaited by the execution environment before the result settles, so an\n\t * observer that rejects fails the execution with a `callback_error` carrying the rejected value\n\t * as its `cause` instead of escaping as an unhandled rejection.\n\t */\n\tonChunk?: (chunk: string, getProgress: () => ShellCaptureProgress, context: Context) => void | PromiseLike<void>;\n\t/** Return shell execution failures with captured output instead of as a failed Result. */\n\treturnExecutionErrors?: boolean;\n}\n\nexport interface ShellCaptureResult extends ShellCaptureProgress {\n\texitCode: number | undefined;\n\tcancelled: boolean;\n\ttruncated: boolean;\n\texecutionError?: ExecutionError;\n}\n\nfunction progressFrom(output: ShellOutputView): ShellCaptureProgress {\n\treturn {\n\t\toutput: output.text,\n\t\ttruncation: { content: output.text, ...output.truncation },\n\t\t...(output.spillPath === undefined ? {} : { fullOutputPath: output.spillPath }),\n\t\tlastLineBytes: output.lastLineBytes ?? 0,\n\t};\n}\n\n/**\n * Compatibility collector for callers that need one bounded final view.\n * Source-side capture, adaptive publication, and spilling remain owned by the\n * execution environment.\n */\nexport async function executeShellWithCapture(\n\tenv: ExecutionEnv,\n\tcommand: string,\n\toptions: ShellCaptureOptions | undefined,\n\tcontext: Context,\n): Promise<Result<ShellCaptureResult, ExecutionError>> {\n\tlet output: ShellOutputView | undefined;\n\tconst result = await env.exec(\n\t\tcommand,\n\t\t{\n\t\t\tcwd: options?.cwd,\n\t\t\tenv: options?.env,\n\t\t\tinheritEnv: options?.inheritEnv,\n\t\t\ttimeout: options?.timeout,\n\t\t\tcapture: {\n\t\t\t\tlimits: { maxBytes: DEFAULT_MAX_BYTES, maxLines: DEFAULT_MAX_LINES, retain: \"tail\" },\n\t\t\t\tspill: true,\n\t\t\t},\n\t\t\tonUpdate: (update, updateContext) => {\n\t\t\t\tconst previous = output;\n\t\t\t\toutput = applyShellOutputUpdate(output, update);\n\t\t\t\tconst chunk =\n\t\t\t\t\tupdate.kind === \"append\" || update.kind === \"slide\"\n\t\t\t\t\t\t? update.text\n\t\t\t\t\t\t: update.kind === \"replace\" && previous === undefined\n\t\t\t\t\t\t\t? output.text\n\t\t\t\t\t\t\t: undefined;\n\t\t\t\t// A metadata-only update and a post-cap replacement contain no new\n\t\t\t\t// incremental chunk. Reporting their complete view would duplicate bytes\n\t\t\t\t// for callers that accumulate this compatibility callback.\n\t\t\t\t// The observer's settlement is returned so the environment can await it.\n\t\t\t\tif (chunk) return options?.onChunk?.(chunk, () => progressFrom(output!), updateContext);\n\t\t\t\treturn undefined;\n\t\t\t},\n\t\t},\n\t\tcontext,\n\t);\n\n\tif (output === undefined) {\n\t\tconst { content, ...truncation } = truncateTail(\"\");\n\t\toutput = { text: content, truncation };\n\t}\n\tconst progress = progressFrom(output);\n\tif (!result.ok) {\n\t\tif (result.error.code === \"aborted\" || context.abortSignal?.aborted) {\n\t\t\treturn ok({ ...progress, exitCode: undefined, cancelled: true, truncated: progress.truncation.truncated });\n\t\t}\n\t\tif (options?.returnExecutionErrors) {\n\t\t\treturn ok({\n\t\t\t\t...progress,\n\t\t\t\texitCode: undefined,\n\t\t\t\tcancelled: false,\n\t\t\t\ttruncated: progress.truncation.truncated,\n\t\t\t\texecutionError: result.error,\n\t\t\t});\n\t\t}\n\t\treturn err(result.error);\n\t}\n\treturn ok({\n\t\t...progress,\n\t\texitCode: result.value.exitCode,\n\t\tcancelled: false,\n\t\ttruncated: result.value.truncation.truncated,\n\t});\n}\n\nexport { sanitizeShellOutput as sanitizeBinaryOutput };\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"truncate.d.ts","sourceRoot":"","sources":["../../../src/harness/utils/truncate.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,eAAO,MAAM,iBAAiB,OAAO,CAAC;AACtC,eAAO,MAAM,iBAAiB,QAAY,CAAC;AAC3C,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAExC,MAAM,WAAW,gBAAgB;IAChC,4BAA4B;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,kCAAkC;IAClC,SAAS,EAAE,OAAO,CAAC;IACnB,sEAAsE;IACtE,WAAW,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI,CAAC;IACtC,oDAAoD;IACpD,UAAU,EAAE,MAAM,CAAC;IACnB,oDAAoD;IACpD,U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3D,CAAC;QACD,IAAI,WAAW,GAAG,cAAc,GAAG,QAAQ;YAAE,MAAM;QACnD,WAAW,IAAI,cAAc,CAAC;QAC9B,KAAK,GAAG,cAAc,CAAC;QACvB,gBAAgB,KAAK,iBAAiB,CAAC;QACvC,CAAC,GAAG,cAAc,CAAC;IACpB,CAAC;IAED,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAChC,OAAO,gBAAgB,CAAC,CAAC,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;AACtE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAC3B,IAAY,EACZ,QAAQ,GAAW,oBAAoB;IAEvC,IAAI,IAAI,CAAC,MAAM,IAAI,QAAQ,EAAE,CAAC;QAC7B,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;IAC5C,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,iBAAiB,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;AAClF,CAAC","sourcesContent":["/**\n * Shared truncation utilities for tool outputs.\n *\n * Truncation is based on two independent limits - whichever is hit first wins:\n * - Line limit (default: 2000 lines)\n * - Byte limit (default: 50KB)\n *\n * Never returns partial lines (except bash tail truncation edge case).\n */\n\nexport const DEFAULT_MAX_LINES = 2000;\nexport const DEFAULT_MAX_BYTES = 50 * 1024; // 50KB\nexport const GREP_MAX_LINE_LENGTH = 500; // Max chars per grep match line\n\nexport interface TruncationResult {\n\t/** The truncated content */\n\tcontent: string;\n\t/** Whether truncation occurred */\n\ttruncated: boolean;\n\t/** Which limit was hit: \"lines\", \"bytes\", or null if not truncated */\n\ttruncatedBy: \"lines\" | \"bytes\" | null;\n\t/** Total number of lines in the original content */\n\ttotalLines: number;\n\t/** Total number of bytes in the original content */\n\ttotalBytes: number;\n\t/** Number of complete lines in the truncated output */\n\toutputLines: number;\n\t/** Number of bytes in the truncated output */\n\toutputBytes: number;\n\t/** Whether the last line was partially truncated (only for tail truncation edge case) */\n\tlastLinePartial: boolean;\n\t/** Whether the first line exceeded the byte limit (for head truncation) */\n\tfirstLineExceedsLimit: boolean;\n\t/** The max lines limit that was applied */\n\tmaxLines: number;\n\t/** The max bytes limit that was applied */\n\tmaxBytes: number;\n}\n\nexport interface TruncationOptions {\n\t/** Maximum number of lines (default: 2000) */\n\tmaxLines?: number;\n\t/** Maximum number of bytes (default: 50KB) */\n\tmaxBytes?: number;\n}\n\ninterface RuntimeBuffer {\n\tbyteLength(content: string, encoding: \"utf8\"): number;\n}\n\nconst runtimeBuffer = (globalThis as { Buffer?: RuntimeBuffer }).Buffer;\nconst nonAsciiPattern = /[^\\x00-\\x7f]/;\n\nexport function utf8ByteLength(content: string): number {\n\tif (runtimeBuffer) return runtimeBuffer.byteLength(content, \"utf8\");\n\n\tconst firstNonAscii = content.search(nonAsciiPattern);\n\tif (firstNonAscii === -1) return content.length;\n\n\tlet bytes = firstNonAscii;\n\tfor (let i = firstNonAscii; i < content.length; i++) {\n\t\tconst code = content.charCodeAt(i);\n\t\tif (code <= 0x7f) {\n\t\t\tbytes += 1;\n\t\t} else if (code <= 0x7ff) {\n\t\t\tbytes += 2;\n\t\t} else if (code >= 0xd800 && code <= 0xdbff && i + 1 < content.length) {\n\t\t\tconst next = content.charCodeAt(i + 1);\n\t\t\tif (next >= 0xdc00 && next <= 0xdfff) {\n\t\t\t\tbytes += 4;\n\t\t\t\ti++;\n\t\t\t} else {\n\t\t\t\tbytes += 3;\n\t\t\t}\n\t\t} else {\n\t\t\tbytes += 3;\n\t\t}\n\t}\n\treturn bytes;\n}\n\nfunction splitLinesForCounting(content: string): string[] {\n\tif (content.length === 0) return [];\n\tconst lines = content.split(\"\\n\");\n\tif (content.endsWith(\"\\n\")) lines.pop();\n\treturn lines;\n}\n\nfunction replaceUnpairedSurrogates(content: string): string {\n\tlet output = \"\";\n\tfor (let i = 0; i < content.length; i++) {\n\t\tconst code = content.charCodeAt(i);\n\t\tif (code >= 0xd800 && code <= 0xdbff) {\n\t\t\tif (i + 1 < content.length) {\n\t\t\t\tconst next = content.charCodeAt(i + 1);\n\t\t\t\tif (next >= 0xdc00 && next <= 0xdfff) {\n\t\t\t\t\toutput += content[i] + content[i + 1];\n\t\t\t\t\ti++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\toutput += \"�\";\n\t\t} else if (code >= 0xdc00 && code <= 0xdfff) {\n\t\t\toutput += \"�\";\n\t\t} else {\n\t\t\toutput += content[i];\n\t\t}\n\t}\n\treturn output;\n}\n\n/**\n * Format bytes as human-readable size.\n */\nexport function formatSize(bytes: number): string {\n\tif (bytes < 1024) {\n\t\treturn `${bytes}B`;\n\t} else if (bytes < 1024 * 1024) {\n\t\treturn `${(bytes / 1024).toFixed(1)}KB`;\n\t} else {\n\t\treturn `${(bytes / (1024 * 1024)).toFixed(1)}MB`;\n\t}\n}\n\n/**\n * Truncate content from the head (keep first N lines/bytes).\n * Suitable for file reads where you want to see the beginning.\n *\n * Never returns partial lines. If first line exceeds byte limit,\n * returns empty content with firstLineExceedsLimit=true.\n */\nexport function truncateHead(content: string, options: TruncationOptions = {}): TruncationResult {\n\tconst maxLines = options.maxLines ?? DEFAULT_MAX_LINES;\n\tconst maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;\n\n\tconst totalBytes = utf8ByteLength(content);\n\tconst lines = splitLinesForCounting(content);\n\tconst totalLines = lines.length;\n\n\t// Check if no truncation needed\n\tif (totalLines <= maxLines && totalBytes <= maxBytes) {\n\t\treturn {\n\t\t\tcontent,\n\t\t\ttruncated: false,\n\t\t\ttruncatedBy: null,\n\t\t\ttotalLines,\n\t\t\ttotalBytes,\n\t\t\toutputLines: totalLines,\n\t\t\toutputBytes: totalBytes,\n\t\t\tlastLinePartial: false,\n\t\t\tfirstLineExceedsLimit: false,\n\t\t\tmaxLines,\n\t\t\tmaxBytes,\n\t\t};\n\t}\n\n\t// Check if first line alone exceeds byte limit\n\tconst firstLineBytes = utf8ByteLength(lines[0]);\n\tif (firstLineBytes > maxBytes) {\n\t\treturn {\n\t\t\tcontent: \"\",\n\t\t\ttruncated: true,\n\t\t\ttruncatedBy: \"bytes\",\n\t\t\ttotalLines,\n\t\t\ttotalBytes,\n\t\t\toutputLines: 0,\n\t\t\toutputBytes: 0,\n\t\t\tlastLinePartial: false,\n\t\t\tfirstLineExceedsLimit: true,\n\t\t\tmaxLines,\n\t\t\tmaxBytes,\n\t\t};\n\t}\n\n\t// Collect complete lines that fit\n\tconst outputLinesArr: string[] = [];\n\tlet outputBytesCount = 0;\n\tlet truncatedBy: \"lines\" | \"bytes\" = \"lines\";\n\n\tfor (let i = 0; i < lines.length && i < maxLines; i++) {\n\t\tconst line = lines[i];\n\t\tconst lineBytes = utf8ByteLength(line) + (i > 0 ? 1 : 0); // +1 for newline\n\n\t\tif (outputBytesCount + lineBytes > maxBytes) {\n\t\t\ttruncatedBy = \"bytes\";\n\t\t\tbreak;\n\t\t}\n\n\t\toutputLinesArr.push(line);\n\t\toutputBytesCount += lineBytes;\n\t}\n\n\t// If we exited due to line limit\n\tif (outputLinesArr.length >= maxLines && outputBytesCount <= maxBytes) {\n\t\ttruncatedBy = \"lines\";\n\t}\n\n\tconst outputContent = outputLinesArr.join(\"\\n\");\n\tconst finalOutputBytes = utf8ByteLength(outputContent);\n\n\treturn {\n\t\tcontent: outputContent,\n\t\ttruncated: true,\n\t\ttruncatedBy,\n\t\ttotalLines,\n\t\ttotalBytes,\n\t\toutputLines: outputLinesArr.length,\n\t\toutputBytes: finalOutputBytes,\n\t\tlastLinePartial: false,\n\t\tfirstLineExceedsLimit: false,\n\t\tmaxLines,\n\t\tmaxBytes,\n\t};\n}\n\n/**\n * Truncate content from the tail (keep last N lines/bytes).\n * Suitable for bash output where you want to see the end (errors, final results).\n *\n * May return partial first line if the last line of original content exceeds byte limit.\n */\nexport function truncateTail(content: string, options: TruncationOptions = {}): TruncationResult {\n\tconst maxLines = options.maxLines ?? DEFAULT_MAX_LINES;\n\tconst maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;\n\n\tconst totalBytes = utf8ByteLength(content);\n\tconst lines = splitLinesForCounting(content);\n\tconst totalLines = lines.length;\n\n\t// Check if no truncation needed\n\tif (totalLines <= maxLines && totalBytes <= maxBytes) {\n\t\treturn {\n\t\t\tcontent,\n\t\t\ttruncated: false,\n\t\t\ttruncatedBy: null,\n\t\t\ttotalLines,\n\t\t\ttotalBytes,\n\t\t\toutputLines: totalLines,\n\t\t\toutputBytes: totalBytes,\n\t\t\tlastLinePartial: false,\n\t\t\tfirstLineExceedsLimit: false,\n\t\t\tmaxLines,\n\t\t\tmaxBytes,\n\t\t};\n\t}\n\n\t// Work backwards from the end\n\tconst outputLinesArr: string[] = [];\n\tlet outputBytesCount = 0;\n\tlet truncatedBy: \"lines\" | \"bytes\" = \"lines\";\n\tlet lastLinePartial = false;\n\n\tfor (let i = lines.length - 1; i >= 0 && outputLinesArr.length < maxLines; i--) {\n\t\tconst line = lines[i];\n\t\tconst lineBytes = utf8ByteLength(line) + (outputLinesArr.length > 0 ? 1 : 0); // +1 for newline\n\n\t\tif (outputBytesCount + lineBytes > maxBytes) {\n\t\t\ttruncatedBy = \"bytes\";\n\t\t\t// Edge case: if we haven't added ANY lines yet and this line exceeds maxBytes,\n\t\t\t// take the end of the line (partial)\n\t\t\tif (outputLinesArr.length === 0) {\n\t\t\t\tconst truncatedLine = truncateStringToBytesFromEnd(line, maxBytes);\n\t\t\t\toutputLinesArr.unshift(truncatedLine);\n\t\t\t\toutputBytesCount = utf8ByteLength(truncatedLine);\n\t\t\t\tlastLinePartial = true;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t\toutputLinesArr.unshift(line);\n\t\toutputBytesCount += lineBytes;\n\t}\n\n\t// If we exited due to line limit\n\tif (outputLinesArr.length >= maxLines && outputBytesCount <= maxBytes) {\n\t\ttruncatedBy = \"lines\";\n\t}\n\n\tconst outputContent = outputLinesArr.join(\"\\n\");\n\tconst finalOutputBytes = utf8ByteLength(outputContent);\n\n\treturn {\n\t\tcontent: outputContent,\n\t\ttruncated: true,\n\t\ttruncatedBy,\n\t\ttotalLines,\n\t\ttotalBytes,\n\t\toutputLines: outputLinesArr.length,\n\t\toutputBytes: finalOutputBytes,\n\t\tlastLinePartial,\n\t\tfirstLineExceedsLimit: false,\n\t\tmaxLines,\n\t\tmaxBytes,\n\t};\n}\n\n/**\n * Truncate a string to fit within a byte limit (from the end).\n * Handles multi-byte UTF-8 characters correctly.\n */\nfunction truncateStringToBytesFromEnd(str: string, maxBytes: number): string {\n\tif (maxBytes <= 0) return \"\";\n\n\tlet outputBytes = 0;\n\tlet start = str.length;\n\tlet needsReplacement = false;\n\tfor (let i = str.length; i > 0; ) {\n\t\tlet characterStart = i - 1;\n\t\tconst code = str.charCodeAt(characterStart);\n\t\tlet characterBytes: number;\n\t\tlet unpairedSurrogate = false;\n\t\tif (code >= 0xdc00 && code <= 0xdfff && characterStart > 0) {\n\t\t\tconst previous = str.charCodeAt(characterStart - 1);\n\t\t\tif (previous >= 0xd800 && previous <= 0xdbff) {\n\t\t\t\tcharacterStart--;\n\t\t\t\tcharacterBytes = 4;\n\t\t\t} else {\n\t\t\t\tcharacterBytes = 3;\n\t\t\t\tunpairedSurrogate = true;\n\t\t\t}\n\t\t} else if (code >= 0xd800 && code <= 0xdfff) {\n\t\t\tcharacterBytes = 3;\n\t\t\tunpairedSurrogate = true;\n\t\t} else {\n\t\t\tcharacterBytes = code <= 0x7f ? 1 : code <= 0x7ff ? 2 : 3;\n\t\t}\n\t\tif (outputBytes + characterBytes > maxBytes) break;\n\t\toutputBytes += characterBytes;\n\t\tstart = characterStart;\n\t\tneedsReplacement ||= unpairedSurrogate;\n\t\ti = characterStart;\n\t}\n\n\tconst output = str.slice(start);\n\treturn needsReplacement ? replaceUnpairedSurrogates(output) : output;\n}\n\n/**\n * Truncate a single line to max characters, adding [truncated] suffix.\n * Used for grep match lines.\n */\nexport function truncateLine(\n\tline: string,\n\tmaxChars: number = GREP_MAX_LINE_LENGTH,\n): { text: string; wasTruncated: boolean } {\n\tif (line.length <= maxChars) {\n\t\treturn { text: line, wasTruncated: false };\n\t}\n\treturn { text: `${line.slice(0, maxChars)}... [truncated]`, wasTruncated: true };\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../../src/harness/utils/usage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,wBAAgB,UAAU,IAAI,KAAK,CASlC;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK,CAqBzD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"usage.js","sourceRoot":"","sources":["../../../src/harness/utils/usage.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,UAAU;IACzB,OAAO;QACN,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,CAAC;QACT,SAAS,EAAE,CAAC;QACZ,UAAU,EAAE,CAAC;QACb,WAAW,EAAE,CAAC;QACd,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE;KACpE,CAAC;AACH,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,IAAW,EAAE,KAAY;IACjD,OAAO;QACN,KAAK,EAAE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK;QAC/B,MAAM,EAAE,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM;QAClC,SAAS,EAAE,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS;QAC3C,UAAU,EAAE,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU;QAC9C,GAAG,CAAC,IAAI,CAAC,YAAY,KAAK,SAAS,IAAI,KAAK,CAAC,YAAY,KAAK,SAAS;YACtE,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,IAAI,CAAC,CAAC,EAAE,CAAC;QAC1E,GAAG,CAAC,IAAI,CAAC,SAAS,KAAK,SAAS,IAAI,KAAK,CAAC,SAAS,KAAK,SAAS;YAChE,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,IAAI,CAAC,CAAC,EAAE,CAAC;QACjE,WAAW,EAAE,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW;QACjD,IAAI,EAAE;YACL,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK;YACzC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM;YAC5C,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS;YACrD,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU;YACxD,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK;SACzC;KACD,CAAC;AACH,CAAC","sourcesContent":["import type { Usage } from \"@earendil-works/pi-ai\";\n\nexport function emptyUsage(): Usage {\n\treturn {\n\t\tinput: 0,\n\t\toutput: 0,\n\t\tcacheRead: 0,\n\t\tcacheWrite: 0,\n\t\ttotalTokens: 0,\n\t\tcost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },\n\t};\n}\n\nexport function addUsage(left: Usage, right: Usage): Usage {\n\treturn {\n\t\tinput: left.input + right.input,\n\t\toutput: left.output + right.output,\n\t\tcacheRead: left.cacheRead + right.cacheRead,\n\t\tcacheWrite: left.cacheWrite + right.cacheWrite,\n\t\t...(left.cacheWrite1h === undefined && right.cacheWrite1h === undefined\n\t\t\t? {}\n\t\t\t: { cacheWrite1h: (left.cacheWrite1h ?? 0) + (right.cacheWrite1h ?? 0) }),\n\t\t...(left.reasoning === undefined && right.reasoning === undefined\n\t\t\t? {}\n\t\t\t: { reasoning: (left.reasoning ?? 0) + (right.reasoning ?? 0) }),\n\t\ttotalTokens: left.totalTokens + right.totalTokens,\n\t\tcost: {\n\t\t\tinput: left.cost.input + right.cost.input,\n\t\t\toutput: left.cost.output + right.cost.output,\n\t\t\tcacheRead: left.cost.cacheRead + right.cost.cacheRead,\n\t\t\tcacheWrite: left.cost.cacheWrite + right.cost.cacheWrite,\n\t\t\ttotal: left.cost.total + right.cost.total,\n\t\t},\n\t};\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,YAAY,EACX,cAAc,EACd,wBAAwB,EACxB,oBAAoB,EACpB,uBAAuB,EACvB,kCAAkC,EAClC,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,EACd,cAAc,IAAI,uBAAuB,EACzC,WAAW,EACX,UAAU,EACV,4BAA4B,EAC5B,0BAA0B,EAC1B,sBAAsB,EACtB,gBAAgB,EAChB,iCAAiC,EACjC,wBAAwB,EACxB,yBAAyB,EACzB,yBAAyB,EACzB,gCAAgC,EAChC,kCAAkC,EAClC,4BAA4B,EAC5B,uBAAuB,EACvB,kCAAkC,EAClC,wBAAwB,EACxB,aAAa,EACb,uBAAuB,EACvB,iCAAi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oB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,cAAc,YAAY,CAAC"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAkC/C,OAAO,EACN,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,EACxB,sBAAsB,GACtB,MAAM,8BAA8B,CAAC;AACtC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,kCAAkC,EAAE,+BAA+B,EAAE,MAAM,+BAA+B,CAAC;AACpH,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EAKN,8BAA8B,EAG9B,qBAAqB,EACrB,oBAAoB,GACpB,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAIN,sBAAsB,EACtB,OAAO,EACP,2BAA2B,EAC3B,qBAAqB,EACrB,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,eAAe,EACf,wBAAwB,EACxB,qBAAqB,EACrB,iBAAiB,EACjB,qBAAqB,EACrB,aAAa,GACb,MAAM,oCAAoC,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAA8B,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAC9F,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAmB3C,OAAO,EACN,uBAAuB,EACvB,mBAAmB,EACnB,wBAAwB,EACxB,WAAW,EACX,gBAAgB,GAChB,MAAM,wBAAwB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,OAAO,EASN,kBAAkB,EAElB,eAAe,EAGf,cAAc,EAEd,GAAG,EACH,SAAS,EAKT,UAAU,EACV,cAAc,EACd,EAAE,EAaF,OAAO,GACP,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,cAAc,uCAAuC,CAAC;AACtD,cAAc,yCAAyC,CAAC;AACxD,cAAc,wCAAwC,CAAC;AACvD,cAAc,iCAAiC,CAAC;AAChD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,cAAc,YAAY,CAAC","sourcesContent":["export { uuidv7 } from \"@earendil-works/pi-ai\";\nexport type {\n\tAttributeValue,\n\tExactTelemetryAttributes,\n\tInferEventAttributes,\n\tInferOptionalAttributes,\n\tInferRequiredAndOptionalAttributes,\n\tInferStartAttributes,\n\tRecordedTelemetryEvent,\n\tRecordedTelemetrySpan,\n\tSchemaTelemetrySpan,\n\tSpanAttributes,\n\tSpanAttributes as TelemetrySpanAttributes,\n\tSpanOptions,\n\tSpanStatus,\n\tTelemetryAttributeDefinition,\n\tTelemetryAttributeMetadata,\n\tTelemetryAttributeType,\n\tTelemetryContext,\n\tTelemetryEventAttributeDefinition,\n\tTelemetryEventDefinition,\n\tTelemetryParentDefinition,\n\tTelemetrySchemaDefinition,\n\tTelemetrySchemaSpanEndAttributes,\n\tTelemetrySchemaSpanEventAttributes,\n\tTelemetrySchemaSpanEventName,\n\tTelemetrySchemaSpanName,\n\tTelemetrySchemaSpanStartAttributes,\n\tTelemetrySchemaSpanUnion,\n\tTelemetrySpan,\n\tTelemetrySpanDefinition,\n\tTelemetryStartAttributeDefinition,\n\tTypedSpanStarter,\n} from \"@earendil-works/pi-telemetry\";\nexport {\n\tcreateTypedSpanStarter,\n\tdefineTelemetrySchema,\n\tInMemoryTelemetryContext,\n\tNOOP_TELEMETRY_CONTEXT,\n} from \"@earendil-works/pi-telemetry\";\nexport * from \"./agent.ts\";\nexport * from \"./agent-loop.ts\";\nexport { EMPTY_TOOL_USE_DEMOTION_DIAGNOSTIC, ProviderRetryWatchdogAbortError } from \"./assistant-terminal-state.ts\";\nexport * from \"./harness/agent-harness.ts\";\nexport {\n\ttype BranchPreparation,\n\ttype BranchSummaryDetails,\n\ttype BranchSummaryResult,\n\ttype CollectEntriesResult,\n\tcollectEntriesForBranchSummary,\n\ttype FileOperations,\n\ttype GenerateBranchSummaryOptions,\n\tgenerateBranchSummary,\n\tprepareBranchEntries,\n} from \"./harness/compaction/branch-summarization.ts\";\nexport {\n\ttype CompactionPreparation,\n\ttype CompactionSettings,\n\ttype CompactResult,\n\tcalculateContextTokens,\n\tcompact,\n\tDEFAULT_COMPACTION_SETTINGS,\n\testimateContextTokens,\n\testimateTokens,\n\tfindCutPoint,\n\tfindTurnStartIndex,\n\tgenerateSummary,\n\tgenerateSummaryWithUsage,\n\tgetLastAssistantUsage,\n\tprepareCompaction,\n\tserializeConversation,\n\tshouldCompact,\n} from \"./harness/compaction/compaction.ts\";\nexport * from \"./harness/context.ts\";\nexport * from \"./harness/messages.ts\";\nexport * from \"./harness/prompt-templates.ts\";\nexport * from \"./harness/result.ts\";\nexport { type LaneSnapshotReduction, reduceLaneSnapshot } from \"./harness/runtime/reducer.ts\";\nexport * from \"./harness/session/index.ts\";\nexport * from \"./harness/skills.ts\";\nexport * from \"./harness/system-prompt.ts\";\nexport type {\n\tAiSpan,\n\tAiSpanAttributes,\n\tAiSpanEndAttributes,\n\tAiSpanEventAttributes,\n\tAiSpanEventName,\n\tAiSpanName,\n\tAiSpanStartAttributes,\n\tAiTelemetrySpan,\n\tHarnessSpan,\n\tHarnessSpanAttributes,\n\tHarnessSpanEndAttributes,\n\tHarnessSpanEventAttributes,\n\tHarnessSpanEventName,\n\tHarnessSpanName,\n\tHarnessSpanStartAttributes,\n\tHarnessTelemetrySpan,\n} from \"./harness/telemetry.ts\";\nexport {\n\tAGENT_TELEMETRY_SCHEMAS,\n\tAI_TELEMETRY_SCHEMA,\n\tHARNESS_TELEMETRY_SCHEMA,\n\tstartAiSpan,\n\tstartHarnessSpan,\n} from \"./harness/telemetry.ts\";\nexport * from \"./harness/tools/index.ts\";\nexport {\n\ttype AgentHarnessResources,\n\ttype AgentHarnessStreamOptions,\n\ttype AgentHarnessStreamOptionsPatch,\n\ttype AgentHarnessTool,\n\ttype AgentHarnessToolContextSource,\n\ttype AgentHarnessToolInvocation,\n\ttype AgentHarnessToolUpdateCallback,\n\ttype AgentHarnessToolUpdateOptions,\n\tBranchSummaryError,\n\ttype BranchSummaryErrorCode,\n\tCompactionError,\n\ttype CompactionErrorCode,\n\ttype ExecutionEnv,\n\tExecutionError,\n\ttype ExecutionErrorCode,\n\terr,\n\tFileError,\n\ttype FileErrorCode,\n\ttype FileInfo,\n\ttype FileKind,\n\ttype FileSystem,\n\tgetOrThrow,\n\tgetOrUndefined,\n\tok,\n\ttype PromptTemplate,\n\ttype Shell,\n\ttype ShellExecOptions,\n\ttype ShellExecResult,\n\ttype ShellOutputCaptureOptions,\n\ttype ShellOutputLimits,\n\ttype ShellOutputMetadata,\n\ttype ShellOutputRetention,\n\ttype ShellOutputTruncation,\n\ttype ShellOutputUpdate,\n\ttype ShellOutputView,\n\ttype Skill,\n\ttoError,\n} from \"./harness/types.ts\";\nexport { applyShellOutputUpdate } from \"./harness/utils/output-capture.ts\";\nexport * from \"./harness/utils/read-folders/index.ts\";\nexport * from \"./harness/utils/read-folders/prepare.ts\";\nexport * from \"./harness/utils/segmented-read-view.ts\";\nexport * from \"./harness/utils/shell-output.ts\";\nexport * from \"./harness/utils/truncate.ts\";\nexport * from \"./proxy.ts\";\nexport * from \"./search/index.ts\";\nexport { setDefaultStreamFn } from \"./stream-fn.ts\";\nexport { prepareToolArguments } from \"./tool-arguments.ts\";\nexport { resolveToolNameAlias } from \"./tool-name-alias.ts\";\nexport * from \"./types.ts\";\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,cAAc,YAAY,CAAC"}
package/dist/node.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,cAAc,YAAY,CAAC","sourcesContent":["export { NodeExecutionEnv } from \"./harness/env/nodejs.ts\";\nexport * from \"./index.ts\";\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../src/proxy.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,OAAO,EACZ,WAAW,EACX,KAAK,KAAK,EAEV,KAAK,mBAAmB,EACxB,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,MAAM,uBAAuB,CAAC;AAG/B,cAAM,uBAAwB,SAAQ,WAAW,CAAC,qBAAqB,EAAE,gBAAgB,CAAC;IACzF,cASC;CACD;AAED;;GAEG;AACH,MAAM,MAAM,0BAA0B,GACnC;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GACjB;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,GAC5C;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC3D;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAAE,GACrE;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,GAChD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server.\n * The server manages auth and proxies requests to LLM providers.\n */\n\n// Internal import for JSON parsing utility\nimport {\n\ttype AssistantMessage,\n\ttype AssistantMessageEvent,\n\ttype Context,\n\tEventStream,\n\ttype Model,\n\tparseStreamingJson,\n\ttype SimpleStreamOptions,\n\ttype StopReason,\n\ttype ToolCall,\n} from \"@earendil-works/pi-ai\";\n\n// Create stream class matching ProxyMessageEventStream\nclass ProxyMessageEventStream extends EventStream<AssistantMessageEvent, AssistantMessage> {\n\tconstructor() {\n\t\tsuper(\n\t\t\t(event) => event.type === \"done\" || event.type === \"error\",\n\t\t\t(event) => {\n\t\t\t\tif (event.type === \"done\") return event.message;\n\t\t\t\tif (event.type === \"error\") return event.error;\n\t\t\t\tthrow new Error(\"Unexpected event type\");\n\t\t\t},\n\t\t);\n\t}\n}\n\n/**\n * Proxy event types - server sends these with partial field stripped to reduce bandwidth.\n */\nexport type ProxyAssistantMessageEvent =\n\t| { type: \"start\" }\n\t| { type: \"text_start\"; contentIndex: number }\n\t| { type: \"text_delta\"; contentIndex: number; delta: string }\n\t| { type: \"text_end\"; contentIndex: number; contentSignature?: string }\n\t| { type: \"thinking_start\"; contentIndex: number }\n\t| { type: \"thinking_delta\"; contentIndex: number; delta: string }\n\t| { type: \"thinking_end\"; contentIndex: number; contentSignature?: string }\n\t| { type: \"toolcall_start\"; contentIndex: number; id: string; toolName: string }\n\t| { type: \"toolcall_delta\"; contentIndex: number; delta: string }\n\t| {\n\t\t\t/**\n\t\t\t * Servers SHOULD send the final ToolCall; flagged incomplete calls emit no argument deltas, so delta\n\t\t\t * reconstruction alone cannot represent them, and metadata such as `namespace` only exists on the final call.\n\t\t\t */\n\t\t\ttype: \"toolcall_end\";\n\t\t\tcontentIndex: number;\n\t\t\ttoolCall?: ToolCall;\n\t }\n\t| {\n\t\t\ttype: \"done\";\n\t\t\treason: Extract<StopReason, \"stop\" | \"length\" | \"toolUse\">;\n\t\t\tusage: AssistantMessage[\"usage\"];\n\t\t\tproviderThinkingLevel?: string;\n\t }\n\t| {\n\t\t\ttype: \"error\";\n\t\t\treason: Extract<StopReason, \"aborted\" | \"error\">;\n\t\t\terrorMessage?: string;\n\t\t\tusage: AssistantMessage[\"usage\"];\n\t\t\tproviderThinkingLevel?: string;\n\t };\n\ntype ProxySerializableStreamOptions = Pick<\n\tSimpleStreamOptions,\n\t| \"temperature\"\n\t| \"samplingParams\"\n\t| \"maxTokens\"\n\t| \"reasoning\"\n\t| \"thinkingSelection\"\n\t| \"cacheRetention\"\n\t| \"sessionId\"\n\t| \"headers\"\n\t| \"metadata\"\n\t| \"transport\"\n\t| \"thinkingBudgets\"\n\t| \"maxRetryDelayMs\"\n>;\n\nexport interface ProxyStreamOptions extends ProxySerializableStreamOptions {\n\t/** Local abort signal for the proxy request */\n\tsignal?: AbortSignal;\n\t/** Auth token for the proxy server */\n\tauthToken: string;\n\t/** Proxy server URL (e.g., \"https://genai.example.com\") */\n\tproxyUrl: string;\n}\n\n/**\n * Stream function that proxies through a server instead of calling LLM providers directly.\n * The server strips the partial field from delta events to reduce bandwidth.\n * We reconstruct the partial message client-side.\n *\n * Use this as the `streamFn` option when creating an Agent that needs to go through a proxy.\n *\n * @example\n * ```typescript\n * const agent = new Agent({\n * streamFn: (model, context, options) =>\n * streamProxy(model, context, {\n * ...options,\n * authToken: await getAuthToken(),\n * proxyUrl: \"https://genai.example.com\",\n * }),\n * });\n * ```\n */\nfunction buildProxyRequestOptions(options: ProxyStreamOptions): ProxySerializableStreamOptions {\n\treturn {\n\t\ttemperature: options.temperature,\n\t\tsamplingParams: options.samplingParams,\n\t\tmaxTokens: options.maxTokens,\n\t\treasoning: options.reasoning,\n\t\tthinkingSelection: options.thinkingSelection,\n\t\tcacheRetention: options.cacheRetention,\n\t\tsessionId: options.sessionId,\n\t\theaders: options.headers,\n\t\tmetadata: options.metadata,\n\t\ttransport: options.transport,\n\t\tthinkingBudgets: options.thinkingBudgets,\n\t\tmaxRetryDelayMs: options.maxRetryDelayMs,\n\t};\n}\n\nexport function streamProxy(model: Model<any>, context: Context, options: ProxyStreamOptions): ProxyMessageEventStream {\n\tconst stream = new ProxyMessageEventStream();\n\n\t(async () => {\n\t\t// Initialize the partial message that we'll build up from events\n\t\tconst partial: AssistantMessage = {\n\t\t\trole: \"assistant\",\n\t\t\tstopReason: \"pending\",\n\t\t\tcontent: [],\n\t\t\tapi: model.api,\n\t\t\tprovider: model.provider,\n\t\t\tmodel: model.id,\n\t\t\tusage: {\n\t\t\t\tinput: 0,\n\t\t\t\toutput: 0,\n\t\t\t\tcacheRead: 0,\n\t\t\t\tcacheWrite: 0,\n\t\t\t\ttotalTokens: 0,\n\t\t\t\tcost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },\n\t\t\t},\n\t\t\ttimestamp: Date.now(),\n\t\t};\n\n\t\tlet reader: ReadableStreamDefaultReader<Uint8Array> | undefined;\n\n\t\tconst abortHandler = () => {\n\t\t\tif (reader) {\n\t\t\t\treader.cancel(\"Request aborted by user\").catch(() => {});\n\t\t\t}\n\t\t};\n\n\t\tif (options.signal) {\n\t\t\toptions.signal.addEventListener(\"abort\", abortHandler);\n\t\t}\n\n\t\ttry {\n\t\t\tconst response = await fetch(`${options.proxyUrl}/api/stream`, {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: {\n\t\t\t\t\tAuthorization: `Bearer ${options.authToken}`,\n\t\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\t},\n\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\tmodel,\n\t\t\t\t\tcontext,\n\t\t\t\t\toptions: buildProxyRequestOptions(options),\n\t\t\t\t}),\n\t\t\t\tsignal: options.signal,\n\t\t\t});\n\n\t\t\tif (!response.ok) {\n\t\t\t\tlet errorMessage = `Proxy error: ${response.status} ${response.statusText}`;\n\t\t\t\ttry {\n\t\t\t\t\tconst errorData = (await response.json()) as { error?: string };\n\t\t\t\t\tif (errorData.error) {\n\t\t\t\t\t\terrorMessage = `Proxy error: ${errorData.error}`;\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// Couldn't parse error response\n\t\t\t\t}\n\t\t\t\tthrow new Error(errorMessage);\n\t\t\t}\n\n\t\t\treader = response.body!.getReader();\n\t\t\tconst decoder = new TextDecoder();\n\t\t\tlet buffer = \"\";\n\t\t\tlet sawTerminalEvent = false;\n\n\t\t\tconst processLine = (line: string): void => {\n\t\t\t\tif (!line.startsWith(\"data: \")) return;\n\t\t\t\tconst data = line.slice(6).trim();\n\t\t\t\tif (!data) return;\n\t\t\t\tconst proxyEvent = JSON.parse(data) as ProxyAssistantMessageEvent;\n\t\t\t\tconst event = processProxyEvent(proxyEvent, partial);\n\t\t\t\tif (event) {\n\t\t\t\t\tif (event.type === \"done\" || event.type === \"error\") sawTerminalEvent = true;\n\t\t\t\t\tstream.push(event);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\twhile (true) {\n\t\t\t\tconst { done, value } = await reader.read();\n\t\t\t\tif (done) break;\n\n\t\t\t\tif (options.signal?.aborted) {\n\t\t\t\t\tthrow new Error(\"Request aborted by user\");\n\t\t\t\t}\n\n\t\t\t\tbuffer += decoder.decode(value, { stream: true });\n\t\t\t\tconst lines = buffer.split(\"\\n\");\n\t\t\t\tbuffer = lines.pop() || \"\";\n\n\t\t\t\tfor (const line of lines) {\n\t\t\t\t\tprocessLine(line);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (options.signal?.aborted) {\n\t\t\t\tthrow new Error(\"Request aborted by user\");\n\t\t\t}\n\n\t\t\t// The final event may not be newline-terminated; flush the decoder and\n\t\t\t// process whatever is left in the buffer.\n\t\t\tbuffer += decoder.decode();\n\t\t\tif (buffer) {\n\t\t\t\tprocessLine(buffer);\n\t\t\t}\n\n\t\t\tif (!sawTerminalEvent) {\n\t\t\t\t// A clean EOF without a done/error event means the server dropped the\n\t\t\t\t// response mid-stream. Surface it as an error instead of leaving\n\t\t\t\t// consumers waiting on a result that never arrives.\n\t\t\t\tpartial.stopReason = \"error\";\n\t\t\t\tpartial.errorMessage = \"Connection closed by proxy server before the response completed\";\n\t\t\t\tstream.push({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\treason: \"error\",\n\t\t\t\t\terror: partial,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tstream.end();\n\t\t} catch (error) {\n\t\t\tconst errorMessage = error instanceof Error ? error.message : String(error);\n\t\t\tconst reason = options.signal?.aborted ? \"aborted\" : \"error\";\n\t\t\tpartial.stopReason = reason;\n\t\t\tpartial.errorMessage = errorMessage;\n\t\t\tstream.push({\n\t\t\t\ttype: \"error\",\n\t\t\t\treason,\n\t\t\t\terror: partial,\n\t\t\t});\n\t\t\tstream.end();\n\t\t} finally {\n\t\t\tif (options.signal) {\n\t\t\t\toptions.signal.removeEventListener(\"abort\", abortHandler);\n\t\t\t}\n\t\t}\n\t})();\n\n\treturn stream;\n}\n\n/**\n * Process a proxy event and update the partial message.\n */\nfunction processProxyEvent(\n\tproxyEvent: ProxyAssistantMessageEvent,\n\tpartial: AssistantMessage,\n): AssistantMessageEvent | undefined {\n\tswitch (proxyEvent.type) {\n\t\tcase \"start\":\n\t\t\treturn { type: \"start\", partial };\n\n\t\tcase \"text_start\":\n\t\t\tpartial.content[proxyEvent.contentIndex] = { type: \"text\", text: \"\" };\n\t\t\treturn { type: \"text_start\", contentIndex: proxyEvent.contentIndex, partial };\n\n\t\tcase \"text_delta\": {\n\t\t\tconst content = partial.content[proxyEvent.contentIndex];\n\t\t\tif (content?.type === \"text\") {\n\t\t\t\tcontent.text += proxyEvent.delta;\n\t\t\t\treturn {\n\t\t\t\t\ttype: \"text_delta\",\n\t\t\t\t\tcontentIndex: proxyEvent.contentIndex,\n\t\t\t\t\tdelta: proxyEvent.delta,\n\t\t\t\t\tpartial,\n\t\t\t\t};\n\t\t\t}\n\t\t\tthrow new Error(\"Received text_delta for non-text content\");\n\t\t}\n\n\t\tcase \"text_end\": {\n\t\t\tconst content = partial.content[proxyEvent.contentIndex];\n\t\t\tif (content?.type === \"text\") {\n\t\t\t\tcontent.textSignature = proxyEvent.contentSignature;\n\t\t\t\treturn {\n\t\t\t\t\ttype: \"text_end\",\n\t\t\t\t\tcontentIndex: proxyEvent.contentIndex,\n\t\t\t\t\tcontent: content.text,\n\t\t\t\t\tpartial,\n\t\t\t\t};\n\t\t\t}\n\t\t\tthrow new Error(\"Received text_end for non-text content\");\n\t\t}\n\n\t\tcase \"thinking_start\":\n\t\t\tpartial.content[proxyEvent.contentIndex] = { type: \"thinking\", thinking: \"\" };\n\t\t\treturn { type: \"thinking_start\", contentIndex: proxyEvent.contentIndex, partial };\n\n\t\tcase \"thinking_delta\": {\n\t\t\tconst content = partial.content[proxyEvent.contentIndex];\n\t\t\tif (content?.type === \"thinking\") {\n\t\t\t\tcontent.thinking += proxyEvent.delta;\n\t\t\t\treturn {\n\t\t\t\t\ttype: \"thinking_delta\",\n\t\t\t\t\tcontentIndex: proxyEvent.contentIndex,\n\t\t\t\t\tdelta: proxyEvent.delta,\n\t\t\t\t\tpartial,\n\t\t\t\t};\n\t\t\t}\n\t\t\tthrow new Error(\"Received thinking_delta for non-thinking content\");\n\t\t}\n\n\t\tcase \"thinking_end\": {\n\t\t\tconst content = partial.content[proxyEvent.contentIndex];\n\t\t\tif (content?.type === \"thinking\") {\n\t\t\t\tcontent.thinkingSignature = proxyEvent.contentSignature;\n\t\t\t\treturn {\n\t\t\t\t\ttype: \"thinking_end\",\n\t\t\t\t\tcontentIndex: proxyEvent.contentIndex,\n\t\t\t\t\tcontent: content.thinking,\n\t\t\t\t\tpartial,\n\t\t\t\t};\n\t\t\t}\n\t\t\tthrow new Error(\"Received thinking_end for non-thinking content\");\n\t\t}\n\n\t\tcase \"toolcall_start\":\n\t\t\tpartial.content[proxyEvent.contentIndex] = {\n\t\t\t\ttype: \"toolCall\",\n\t\t\t\tid: proxyEvent.id,\n\t\t\t\tname: proxyEvent.toolName,\n\t\t\t\targuments: {},\n\t\t\t\tpartialJson: \"\",\n\t\t\t} satisfies ToolCall & { partialJson: string } as ToolCall;\n\t\t\treturn { type: \"toolcall_start\", contentIndex: proxyEvent.contentIndex, partial };\n\n\t\tcase \"toolcall_delta\": {\n\t\t\tconst content = partial.content[proxyEvent.contentIndex];\n\t\t\tif (content?.type === \"toolCall\") {\n\t\t\t\t(content as any).partialJson += proxyEvent.delta;\n\t\t\t\tcontent.arguments = parseStreamingJson((content as any).partialJson) || {};\n\t\t\t\tpartial.content[proxyEvent.contentIndex] = { ...content }; // Trigger reactivity\n\t\t\t\treturn {\n\t\t\t\t\ttype: \"toolcall_delta\",\n\t\t\t\t\tcontentIndex: proxyEvent.contentIndex,\n\t\t\t\t\tdelta: proxyEvent.delta,\n\t\t\t\t\tpartial,\n\t\t\t\t};\n\t\t\t}\n\t\t\tthrow new Error(\"Received toolcall_delta for non-toolCall content\");\n\t\t}\n\n\t\tcase \"toolcall_end\": {\n\t\t\tconst content = partial.content[proxyEvent.contentIndex];\n\t\t\tif (content?.type === \"toolCall\") {\n\t\t\t\tconst toolCall = proxyEvent.toolCall ?? content;\n\t\t\t\tdelete (toolCall as ToolCall & { partialJson?: string }).partialJson;\n\t\t\t\tpartial.content[proxyEvent.contentIndex] = toolCall;\n\t\t\t\treturn {\n\t\t\t\t\ttype: \"toolcall_end\",\n\t\t\t\t\tcontentIndex: proxyEvent.contentIndex,\n\t\t\t\t\ttoolCall,\n\t\t\t\t\tpartial,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\n\t\tcase \"done\":\n\t\t\tpartial.stopReason = proxyEvent.reason;\n\t\t\tpartial.usage = proxyEvent.usage;\n\t\t\tif (proxyEvent.providerThinkingLevel !== undefined) {\n\t\t\t\tpartial.providerThinkingLevel = proxyEvent.providerThinkingLevel;\n\t\t\t}\n\t\t\treturn { type: \"done\", reason: proxyEvent.reason, message: partial };\n\n\t\tcase \"error\":\n\t\t\tpartial.stopReason = proxyEvent.reason;\n\t\t\tpartial.errorMessage = proxyEvent.errorMessage;\n\t\t\tpartial.usage = proxyEvent.usage;\n\t\t\tif (proxyEvent.providerThinkingLevel !== undefined) {\n\t\t\t\tpartial.providerThinkingLevel = proxyEvent.providerThinkingLevel;\n\t\t\t}\n\t\t\treturn { type: \"error\", reason: proxyEvent.reason, error: partial };\n\n\t\tdefault: {\n\t\t\tconst _exhaustiveCheck: never = proxyEvent;\n\t\t\tconsole.warn(`Unhandled proxy event type: ${(proxyEvent as any).type}`);\n\t\t\treturn undefined;\n\t\t}\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/search/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;CAC/D;AAED,MAAM,WAAW,cAAc;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,oBAAoB;IACpC,cAAc,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAChE,aAAa,CAAC,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IAC9D,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/search/index.ts"],"names":[],"mappings":"","sourcesContent":["export interface SearchQuery {\n\ttext: string;\n\tlimit?: number;\n}\n\nexport interface SessionSearchHit {\n\tsessionId: string;\n\tscore?: number;\n\ttop?: { entryId: string; snippet?: string; timestamp: number };\n}\n\nexport interface EntrySearchHit {\n\tsessionId: string;\n\tentryId: string;\n\ttimestamp: number;\n\tsnippet?: string;\n\tscore?: number;\n}\n\nexport interface SessionSearchService {\n\tsearchSessions(query: SearchQuery): Promise<SessionSearchHit[]>;\n\tsearchEntries?(query: SearchQuery): Promise<EntrySearchHit[]>;\n\tsync(): Promise<void>;\n\tnotify(sessionId: string): void;\n\tremove(sessionId: string): Promise<void>;\n\tclose(): Promise<void>;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"stream-fn.d.ts","sourceRoot":"","sources":["../src/stream-fn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAI3C;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,GAAG,SAAS,GAAG,IAAI,CAEvE;AAED,wBAAgB,kBAAkB,IAAI,QAAQ,CAK7C;AAED,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"stream-fn.js","sourceRoot":"","sources":["../src/stream-fn.ts"],"names":[],"mappings":"AAEA,IAAI,eAAqC,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAA8B;IAChE,eAAe,GAAG,QAAQ,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,kBAAkB;IACjC,IAAI,CAAC,eAAe,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,+FAA+F,CAAC,CAAC;IAClH,CAAC;IACD,OAAO,eAAe,CAAC;AACxB,CAAC;AAED,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC","sourcesContent":["import type { StreamFn } from \"./types.ts\";\n\nlet defaultStreamFn: StreamFn | undefined;\n\n/**\n * Configure the fallback used by Agent and low-level loops when callers omit streamFn.\n *\n * Hosts that provide a default model runtime can install its stream function here\n * without making pi-agent-core depend on a provider catalog or compatibility layer.\n */\nexport function setDefaultStreamFn(streamFn: StreamFn | undefined): void {\n\tdefaultStreamFn = streamFn;\n}\n\nexport function getDefaultStreamFn(): StreamFn {\n\tif (!defaultStreamFn) {\n\t\tthrow new Error(\"No default stream function configured. Pass streamFn explicitly or call setDefaultStreamFn().\");\n\t}\n\treturn defaultStreamFn;\n}\n\nexport { withEmptyAssistantRecovery } from \"./empty-assistant-recovery.ts\";\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"tool-arguments.d.ts","sourceRoot":"","sources":["../src/tool-arguments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3D,MAAM,MAAM,gBAAgB,GAAG,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC;AAQ1D,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,gBAAgB,GAAG,SAAS,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAG/F;AAED,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,GAAG,aAAa,CAMrG"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"tool-arguments.js","sourceRoot":"","sources":["../src/tool-arguments.ts"],"names":[],"mappings":"AAIA,+FAA+F;AAC/F,+FAA+F;AAC/F,0FAA0F;AAC1F,8FAA8F;AAC9F,sFAAsF;AACtF,2FAA2F;AAC3F,MAAM,UAAU,oBAAoB,CAAC,IAAkC,EAAE,IAAa;IACrF,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvB,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,6BAA6B,CAAC,IAAe,EAAE,QAAuB;IACrF,IAAI,CAAC,IAAI,CAAC,gBAAgB;QAAE,OAAO,QAAQ,CAAC;IAC5C,OAAO;QACN,GAAG,QAAQ;QACX,SAAS,EAAE,oBAAoB,CAAC,IAAI,CAAC,gBAAgB,EAAE,QAAQ,CAAC,SAAS,CAA4B;KACrG,CAAC;AACH,CAAC","sourcesContent":["import type { AgentTool, AgentToolCall } from \"./types.ts\";\n\nexport type ToolArgumentShim = (args: unknown) => unknown;\n\n// The shim runs against a detached copy because several shims normalize by mutating the object\n// they were handed (eval's summary clamp, the harness edit shim's `edits` coercion) and return\n// that same reference. That object is the one the assistant message holds, so an in-place\n// normalization rewrites the answer the provider actually produced: the Claude SDK continuity\n// fingerprint then reports `assistant_rewritten` and the next turn re-sends the whole\n// conversation (senpi#1472). `validateToolArguments` already detaches for the same reason.\nexport function prepareToolArguments(shim: ToolArgumentShim | undefined, args: unknown): unknown {\n\tif (!shim) return args;\n\treturn shim(structuredClone(args));\n}\n\nexport function prepareAgentToolCallArguments(tool: AgentTool, toolCall: AgentToolCall): AgentToolCall {\n\tif (!tool.prepareArguments) return toolCall;\n\treturn {\n\t\t...toolCall,\n\t\targuments: prepareToolArguments(tool.prepareArguments, toolCall.arguments) as Record<string, unknown>,\n\t};\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"tool-name-alias.d.ts","sourceRoot":"","sources":["../src/tool-name-alias.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,SAAS,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE3G;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,SAA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,GAAG,MAAM,MAAM,CAAC,sBAAsB,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;IACtF,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAC9B,MAAM,WAAW,GAAG,oBAAoB,CACvC,QAAQ,CAAC,IAAI,EACb,CAAC,cAAc,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAC/D,CAAC;IACF,OAAO,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC;AAClF,CAAC;AAED,MAAM,UAAU,sBAAsB,CACrC,MAAgC,EAChC,aAAqB,EACrB,YAAoB;IAEpB,OAAO;QACN,GAAG,MAAM;QACT,8GAA8G;QAC9G,OAAO,EAAE;YACR,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,wBAAwB,CAAC,aAAa,EAAE,YAAY,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE;YAChG,GAAG,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC;SACzB;KACD,CAAC;AACH,CAAC","sourcesContent":["import { resolveToolNameMatch } from \"@earendil-works/pi-ai/utils/tool-name-match\";\nimport type { AgentContext, AgentLoopConfig, AgentTool, AgentToolCall, AgentToolResult } from \"./types.ts\";\n\n/**\n * A model can call a tool by a name it was never registered under: recased,\n * under a gateway namespace (`mcp__<id>__<Name>`, any case), or without the\n * namespace a registered tool carries. The shared matcher resolves such a name\n * only when exactly one available tool matches; it never guesses.\n */\nexport function resolveToolNameAlias(requested: string, available: Iterable<string>): string | undefined {\n\treturn resolveToolNameMatch(requested, available);\n}\n\nexport function toolNameCorrectionNotice(requested: string, resolved: string): string {\n\treturn `[auto-corrected] no tool is named \"${requested}\"; ran \"${resolved}\". Call tools by their exact listed name.`;\n}\n\n/**\n * Find the tool a call will run, resolving an unknown name through the host\n * resolver and then the alias rule. Runs before `tool_execution_start` so every\n * event names the tool that executes, never the name the model mistyped.\n */\nexport async function resolveCallTool(\n\tcurrentContext: AgentContext,\n\ttoolCall: AgentToolCall,\n\tconfig: AgentLoopConfig,\n): Promise<AgentTool | undefined> {\n\tif (toolCall.incomplete === true) return undefined;\n\tconst exact = currentContext.tools?.find((candidate) => candidate.name === toolCall.name);\n\tif (exact) return exact;\n\tconst resolved = await config.resolveUnknownToolCall?.(toolCall.name, currentContext);\n\tif (resolved) return resolved;\n\tconst aliasedName = resolveToolNameAlias(\n\t\ttoolCall.name,\n\t\t(currentContext.tools ?? []).map((candidate) => candidate.name),\n\t);\n\treturn currentContext.tools?.find((candidate) => candidate.name === aliasedName);\n}\n\nexport function withToolNameCorrection(\n\tresult: AgentToolResult<unknown>,\n\trequestedName: string,\n\tresolvedName: string,\n): AgentToolResult<unknown> {\n\treturn {\n\t\t...result,\n\t\t// Model-only: it steers the model back to exact names; the user sees the resolved tool as if called directly.\n\t\tcontent: [\n\t\t\t{ type: \"text\", text: toolNameCorrectionNotice(requestedName, resolvedName), audience: \"model\" },\n\t\t\t...(result.content ?? []),\n\t\t],\n\t};\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,GAAG,EACH,gBAAgB,EAChB,qBAAqB,EACrB,2BAA2B,EAC3B,OAAO,EACP,kBAAkB,EAClB,YAAY,EACZ,OAAO,EACP,KAAK,EACL,kBAAkB,EAClB,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EACjB,IAAI,EACJ,iBAAiB,EACjB,KAAK,EACL,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAE/C;;;;;;;;;GASG;AACH,MAAM,MAAM,QAAQ,GAAG,CACtB,KAAK,EAAE,KAA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AC/F;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,OAAO,EAAE,YAAY,CAAA;CAAE,GAE9C;IAAE,IAAI,EAAE,sBAAsB,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,GAAG,CAAA;CAAE,GACjF;IAAE,IAAI,EAAE,uBAAuB,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,GAAG,CAAC;IAAC,aAAa,EAAE,GAAG,CAAA;CAAE,GACtG;IAAE,IAAI,EAAE,oBAAoB,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,GAAG,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC"}
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n\tApi,\n\tAssistantMessage,\n\tAssistantMessageEvent,\n\tAssistantMessageEventStream,\n\tContext,\n\tCursorExecHandlers,\n\tImageContent,\n\tMessage,\n\tModel,\n\tProviderDiagnostic,\n\tSimpleStreamOptions,\n\tTextContent,\n\tThinkingSelection,\n\tTool,\n\tToolResultMessage,\n\tUsage,\n} from \"@earendil-works/pi-ai\";\nimport type { Static, TSchema } from \"typebox\";\n\n/**\n * Stream function used by the agent loop. `Models.streamSimple` satisfies\n * this shape.\n *\n * Contract:\n * - Must not throw or return a rejected promise for request/model/runtime failures.\n * - Must return an AssistantMessageEventStream.\n * - Failures must be encoded in the returned stream via protocol events and a\n * final AssistantMessage with stopReason \"error\" or \"aborted\" and errorMessage.\n */\nexport type StreamFn = (\n\tmodel: Model<Api>,\n\tcontext: Context,\n\toptions?: SimpleStreamOptions,\n) => AssistantMessageEventStream | Promise<AssistantMessageEventStream>;\n\n/**\n * Configuration for how tool calls from a single assistant message are executed.\n *\n * - \"sequential\": each tool call is prepared, executed, and finalized before the next one starts.\n * - \"parallel\": tool calls are prepared sequentially, then scheduled in concurrent waves.\n * Tools with `executionMode: \"sequential\"` run as exclusive barriers; parallel tools before\n * or after the barrier can still execute concurrently with each other.\n * `tool_execution_end` is emitted in tool completion order after each tool is finalized,\n * while tool-result message artifacts are emitted later in assistant source order.\n */\nexport type ToolExecutionMode = \"sequential\" | \"parallel\";\n\n/**\n * Controls how many queued user messages are injected when the agent loop reaches a queue drain point.\n *\n * - \"all\": drain and inject every queued message at that point.\n * - \"one-at-a-time\": drain and inject only the oldest queued message, leaving the rest queued for later drain points.\n */\nexport type QueueMode = \"all\" | \"one-at-a-time\";\n\n/** A single tool call content block emitted by an assistant message. */\nexport type AgentToolCall = Extract<AssistantMessage[\"content\"][number], { type: \"toolCall\" }>;\n\n/**\n * Result returned from `beforeToolCall`.\n *\n * Returning `{ block: true }` prevents the tool from executing. The loop emits an error tool result instead.\n * `reason` becomes the text shown in that error result. If omitted, a default blocked message is used.\n */\nexport interface BeforeToolCallResult {\n\tblock?: boolean;\n\treason?: string;\n\t/**\n\t * Hint that the agent should stop after the current tool batch when this call is blocked.\n\t * Early termination only happens when every finalized tool result in the batch sets this to true.\n\t */\n\tterminate?: boolean;\n}\n\n/**\n * Partial override returned from `afterToolCall`.\n *\n * Merge semantics are field-by-field:\n * - `content`: if provided, replaces the tool result content array in full\n * - `details`: if provided, replaces the tool result details value in full\n * - `isError`: if provided, replaces the tool result error flag\n * - `usage`: if provided, replaces the tool result usage\n * - `terminate`: if provided, replaces the early-termination hint\n *\n * Omitted fields keep the original executed tool result values.\n * There is no deep merge for `content`, `details`, or `usage`.\n */\nexport interface AfterToolCallResult {\n\tcontent?: (TextContent | ImageContent)[];\n\tdetails?: unknown;\n\tisError?: boolean;\n\t/** Usage from the final tool execution itself, if available. Not used for main LLM context accounting. */\n\tusage?: Usage;\n\t/**\n\t * Hint that the agent should stop after the current tool batch.\n\t * Early termination only happens when every finalized tool result in the batch sets this to true.\n\t */\n\tterminate?: boolean;\n}\n\n/** Context passed to `beforeToolCall`. */\nexport interface BeforeToolCallContext {\n\t/** The assistant message that requested the tool call. */\n\tassistantMessage: AssistantMessage;\n\t/** The raw tool call block from `assistantMessage.content`. */\n\ttoolCall: AgentToolCall;\n\t/** Validated tool arguments for the target tool schema. */\n\targs: unknown;\n\t/** Current agent context at the time the tool call is prepared. */\n\tcontext: AgentContext;\n}\n\n/** Context passed to `afterToolCall`. */\nexport interface AfterToolCallContext {\n\t/** The assistant message that requested the tool call. */\n\tassistantMessage: AssistantMessage;\n\t/** The raw tool call block from `assistantMessage.content`. */\n\ttoolCall: AgentToolCall;\n\t/** Validated tool arguments for the target tool schema. */\n\targs: unknown;\n\t/** The executed tool result before any `afterToolCall` overrides are applied. */\n\tresult: AgentToolResult<any>;\n\t/** Whether the executed tool result is currently treated as an error. */\n\tisError: boolean;\n\t/** Current agent context at the time the tool call is finalized. */\n\tcontext: AgentContext;\n}\n\n/** Context passed to `shouldStopAfterTurn`. */\nexport interface ShouldStopAfterTurnContext {\n\t/** The assistant message that completed the turn. */\n\tmessage: AssistantMessage;\n\t/** Tool result messages passed to the preceding `turn_end` event. */\n\ttoolResults: ToolResultMessage[];\n\t/** Current agent context after the turn's assistant message and tool results have been appended. */\n\tcontext: AgentContext;\n\t/** Messages that this loop invocation will return if it exits at this point. Prompt runs include the initial prompt messages; continuation runs do not include pre-existing context messages. */\n\tnewMessages: AgentMessage[];\n}\n\n/** Replacement runtime state used by the agent loop before starting another provider request. */\nexport interface AgentLoopTurnUpdate {\n\t/** Context for the next provider request. */\n\tcontext?: AgentContext;\n\t/** Model for the next provider request. */\n\tmodel?: Model<any>;\n\t/** Thinking level for the next provider request. */\n\tthinkingLevel?: ThinkingLevel;\n\t/** Thinking selection for the next provider request: undefined leaves it unchanged, null clears it. */\n\tthinkingSelection?: ThinkingSelection | null;\n\t/** Whether the next provider request should abort a server-selected fallback. */\n\tabortServerSideFallback?: boolean;\n}\n\nexport interface PrepareNextTurnContext extends ShouldStopAfterTurnContext {}\n\nexport interface AgentLoopConfig extends SimpleStreamOptions {\n\tmodel: Model<any>;\n\n\t/**\n\t * Cursor exec-channel tool handlers (cursor-agent models only).\n\t *\n\t * Cursor's server-driven protocol executes tools MID-STREAM: the server\n\t * blocks on an in-band reply, so the provider runs these handlers while\n\t * the Run stream is open, synthesizes already-resolved `toolCall` blocks\n\t * (marked `kCursorExecResolved`, which this loop skips), and buffers each\n\t * paired `ToolResultMessage` for emission right after the assistant\n\t * message. Other providers ignore this field.\n\t */\n\tcursorExecHandlers?: CursorExecHandlers | ((runSignal: AbortSignal) => CursorExecHandlers);\n\n\t/**\n\t * Maximum time in milliseconds to wait for the FIRST provider stream event.\n\t * Providers emit their first event only once the HTTP response begins, so a\n\t * dead upstream that accepts the request but never answers is otherwise only\n\t * bounded by `timeoutMs` (the idle timeout, default 5 minutes). After the\n\t * first event arrives, `timeoutMs` governs inter-event idleness as before.\n\t * Unset or non-positive values disable the start bound.\n\t */\n\tstreamStartTimeoutMs?: number;\n\n\t/** Provider/SDK timeout override for only the first request in this loop invocation. */\n\tinitialRequestTimeoutMs?: number;\n\n\t/** Stream-start timeout override for only the first request in this loop invocation. */\n\tinitialRequestStreamStartTimeoutMs?: number;\n\n\t/**\n\t * Converts AgentMessage[] to LLM-compatible Message[] before each LLM call.\n\t *\n\t * Each AgentMessage must be converted to a UserMessage, AssistantMessage, or ToolResultMessage\n\t * that the LLM can understand. AgentMessages that cannot be converted (e.g., UI-only notifications,\n\t * status messages) should be filtered out.\n\t *\n\t * Contract: must not throw or reject. Return a safe fallback value instead.\n\t * Throwing interrupts the low-level agent loop without producing a normal event sequence.\n\t *\n\t * @example\n\t * ```typescript\n\t * convertToLlm: (messages) => messages.flatMap(m => {\n\t * if (m.role === \"custom\") {\n\t * // Convert custom message to user message\n\t * return [{ role: \"user\", content: m.content, timestamp: m.timestamp }];\n\t * }\n\t * if (m.role === \"notification\") {\n\t * // Filter out UI-only messages\n\t * return [];\n\t * }\n\t * // Pass through standard LLM messages\n\t * return [m];\n\t * })\n\t * ```\n\t */\n\tconvertToLlm: (messages: AgentMessage[]) => Message[] | Promise<Message[]>;\n\n\t/**\n\t * Optional transform applied to the context before `convertToLlm`.\n\t *\n\t * Use this for operations that work at the AgentMessage level:\n\t * - Context window management (pruning old messages)\n\t * - Injecting context from external sources\n\t *\n\t * Contract: must not throw or reject. Return the original messages or another\n\t * safe fallback value instead.\n\t *\n\t * @example\n\t * ```typescript\n\t * transformContext: async (messages) => {\n\t * if (estimateTokens(messages) > MAX_TOKENS) {\n\t * return pruneOldMessages(messages);\n\t * }\n\t * return messages;\n\t * }\n\t * ```\n\t */\n\ttransformContext?: (messages: AgentMessage[], signal?: AbortSignal) => Promise<AgentMessage[]>;\n\n\t/**\n\t * Resolves an API key dynamically for each LLM call.\n\t *\n\t * Useful for short-lived OAuth tokens (e.g., GitHub Copilot) that may expire\n\t * during long-running tool execution phases.\n\t *\n\t * Contract: must not throw or reject. Return undefined when no key is available.\n\t */\n\tgetApiKey?: (provider: string) => Promise<string | undefined> | string | undefined;\n\n\t/**\n\t * Called after each turn fully completes and `turn_end` has been emitted.\n\t *\n\t * If it returns true, the loop emits `agent_end` and exits before polling steering or follow-up queues,\n\t * without starting another LLM call. The current assistant response and any tool executions finish normally.\n\t * This callback sees the completed-turn context and runs before `prepareNextTurn`.\n\t *\n\t * Use this to request a graceful stop after the current turn, e.g. before context gets too full.\n\t *\n\t * Contract: must not throw or reject. Throwing interrupts the low-level agent loop without producing a normal event sequence.\n\t */\n\tshouldStopAfterTurn?: (context: ShouldStopAfterTurnContext) => boolean | Promise<boolean>;\n\n\t/**\n\t * Called after each completed assistant turn, including a normal stop response, before the loop decides whether another provider request starts.\n\t * A terminating-tool continuation emits its `turn_start` boundary first so queue owners can clear\n\t * or replace pending input before preparation finishes and the continuation is admitted.\n\t * `shouldStopAfterTurn` and an empty terminating tool batch can end the run before preparation.\n\t * Return replacement context/model/thinking state to affect the next turn.\n\t * Return undefined to keep using the current context/config.\n\t */\n\tprepareNextTurn?: (\n\t\tcontext: PrepareNextTurnContext,\n\t) => AgentLoopTurnUpdate | undefined | Promise<AgentLoopTurnUpdate | undefined>;\n\n\t/**\n\t * Returns steering messages to inject into the conversation mid-run.\n\t *\n\t * Called after the current assistant turn finishes executing its tool calls, unless `shouldStopAfterTurn` exits first.\n\t * If messages are returned, they are added to the context before the next LLM call.\n\t * Tool calls from the current assistant message are not skipped.\n\t *\n\t * Use this for \"steering\" the agent while it's working.\n\t *\n\t * Contract: must not throw or reject. Return [] when no steering messages are available.\n\t */\n\tgetSteeringMessages?: () => Promise<AgentMessage[]>;\n\n\t/**\n\t * Returns follow-up messages to process after the agent would otherwise stop.\n\t *\n\t * Called when the agent has no more tool calls and no steering messages.\n\t * If messages are returned, they're added to the context and the agent\n\t * continues with another turn.\n\t *\n\t * Use this for follow-up messages that should wait until the agent finishes.\n\t *\n\t * Contract: must not throw or reject. Return [] when no follow-up messages are available.\n\t */\n\tgetFollowUpMessages?: () => Promise<AgentMessage[]>;\n\n\t/**\n\t * Restores messages previously returned by a queue callback when next-turn preparation cannot continue.\n\t * Restored messages must be placed before messages queued after the drain.\n\t */\n\trestorePendingMessages?: (queue: \"steering\" | \"followUp\", messages: AgentMessage[]) => Promise<void> | void;\n\n\t/**\n\t * Tool execution mode.\n\t * - \"sequential\": execute tool calls one by one\n\t * - \"parallel\": preflight tool calls sequentially, then execute allowed tools in concurrent waves;\n\t * per-tool `executionMode: \"sequential\"` calls act as exclusive barriers,\n\t * emit `tool_execution_end` in tool completion order after each tool is finalized,\n\t * then emit tool-result message artifacts later in assistant source order\n\t *\n\t * Default: \"parallel\"\n\t */\n\ttoolExecution?: ToolExecutionMode;\n\n\t/**\n\t * Optional migration guidance for tool names intentionally removed by an extension.\n\t * The matching hint is appended to the normal unknown-tool error before hooks run.\n\t */\n\tremovedToolHints?: Record<string, string>;\n\n\t/**\n\t * Called when a model names a tool absent from the current context snapshot.\n\t * Return a newly available tool to continue normal validation and execution, or\n\t * undefined to emit the existing unknown-tool result. Hosts may use this to\n\t * activate a registered lazy tool at call time.\n\t */\n\tresolveUnknownToolCall?: (\n\t\ttoolName: string,\n\t\tcontext: AgentContext,\n\t) => AgentTool | undefined | Promise<AgentTool | undefined>;\n\n\t/**\n\t * Called before a tool is executed, after arguments have been validated.\n\t *\n\t * Return `{ block: true }` to prevent execution. The loop emits an error tool result instead.\n\t * A blocked result can also set `terminate: true` to participate in the batch early-termination rule.\n\t * The hook receives the agent abort signal and is responsible for honoring it.\n\t */\n\tbeforeToolCall?: (context: BeforeToolCallContext, signal?: AbortSignal) => Promise<BeforeToolCallResult | undefined>;\n\n\t/**\n\t * Called after a tool finishes executing, before `tool_execution_end` and tool-result message events are emitted.\n\t *\n\t * Return an `AfterToolCallResult` to override parts of the executed tool result:\n\t * - `content` replaces the full content array\n\t * - `details` replaces the full details payload\n\t * - `isError` replaces the error flag\n\t * - `usage` replaces the tool result usage\n\t * - `terminate` replaces the early-termination hint\n\t *\n\t * Any omitted fields keep their original values. No deep merge is performed.\n\t * The hook receives the agent abort signal and is responsible for honoring it.\n\t */\n\tafterToolCall?: (context: AfterToolCallContext, signal?: AbortSignal) => Promise<AfterToolCallResult | undefined>;\n}\n\n/**\n * Thinking/reasoning level for models that support it.\n * Note: \"xhigh\" and \"max\" are only supported by selected model families. Use model\n * thinking-level metadata from @earendil-works/pi-ai to detect support for a concrete model.\n */\nexport type ThinkingLevel = \"off\" | \"minimal\" | \"low\" | \"medium\" | \"high\" | \"xhigh\" | \"max\";\n\n/**\n * Extensible interface for custom app messages.\n * Apps can extend via declaration merging:\n *\n * @example\n * ```typescript\n * declare module \"@earendil-works/pi-agent-core\" {\n * interface CustomAgentMessages {\n * artifact: ArtifactMessage;\n * notification: NotificationMessage;\n * }\n * }\n * ```\n */\nexport interface CustomAgentMessages {\n\t// Empty by default - apps extend via declaration merging\n}\n\n/**\n * AgentMessage: Union of LLM messages + custom messages.\n * This abstraction allows apps to add custom message types while maintaining\n * type safety and compatibility with the base LLM messages.\n */\nexport type AgentMessage = Message | CustomAgentMessages[keyof CustomAgentMessages];\n\n/**\n * Public agent state.\n *\n * `tools` and `messages` use accessor properties so implementations can copy\n * assigned arrays before storing them.\n */\nexport interface AgentState {\n\t/** System prompt sent with each model request. */\n\tsystemPrompt: string;\n\t/** Active model used for future turns. */\n\tmodel: Model<any>;\n\t/** Requested reasoning level for future turns. */\n\tthinkingLevel: ThinkingLevel;\n\t/**\n\t * Provenance-bearing thinking selection, when the user or a legacy variant\n\t * alias explicitly chose a level. Absent for defaulted effective levels.\n\t */\n\tthinkingSelection?: ThinkingSelection;\n\t/** First reasoning effort on the branch, used to preserve Responses cache prefixes. */\n\treasoningBaseline?: string;\n\t/** Available tools. Assigning a new array copies the top-level array. */\n\tset tools(tools: AgentTool<any>[]);\n\tget tools(): AgentTool<any>[];\n\t/** Tool list the provider receives when it differs from `tools`; see {@link AgentContext.declaredTools}. */\n\tdeclaredTools?: AgentTool<any>[];\n\t/** Conversation transcript. Assigning a new array copies the top-level array. */\n\tset messages(messages: AgentMessage[]);\n\tget messages(): AgentMessage[];\n\t/**\n\t * True while the agent is processing a prompt or continuation.\n\t *\n\t * This remains true until awaited `agent_end` listeners settle.\n\t */\n\treadonly isStreaming: boolean;\n\t/** Partial assistant message for the current streamed response, if any. */\n\treadonly streamingMessage?: AgentMessage;\n\t/** Tool call ids currently executing. */\n\treadonly pendingToolCalls: ReadonlySet<string>;\n\t/** Error message from the most recent failed or aborted assistant turn, if any. */\n\treadonly errorMessage?: string;\n\t/** Structured provider failure family of the turn that set `errorMessage`, when its provider adapter supplied one. */\n\treadonly providerDiagnostic?: ProviderDiagnostic;\n}\n\n/** Final or partial result produced by a tool. */\nexport interface AgentToolResult<T> {\n\t/** Text or image content returned to the model. */\n\tcontent: (TextContent | ImageContent)[];\n\t/** Arbitrary structured details for logs or UI rendering. */\n\tdetails: T;\n\t/** Usage from the final tool execution itself, if available. Not used for main LLM context accounting. */\n\tusage?: Usage;\n\t/** Names of tools introduced by this result and available from this transcript point onward. */\n\taddedToolNames?: string[];\n\t/**\n\t * Hint that the agent should stop after the current tool batch.\n\t * Early termination only happens when every finalized tool result in the batch sets this to true.\n\t */\n\tterminate?: boolean;\n\t/**\n\t * Report a failure without throwing: `true` marks this result as a tool error while keeping\n\t * `content` and `details` intact for the model and renderers. Omitted or `false` means success.\n\t */\n\tisError?: boolean;\n}\n\n/**\n * Callback used by tools to stream partial execution updates.\n *\n * The callback is scoped to the current `execute()` invocation. Calls made after\n * the tool promise settles are ignored.\n */\nexport type AgentToolUpdateCallback<T = any> = (partialResult: AgentToolResult<T>) => void;\n\n/** Tool definition used by the agent runtime. */\nexport interface AgentTool<TParameters extends TSchema = TSchema, TDetails = any> extends Tool<TParameters> {\n\t/** Human-readable label for UI display. */\n\tlabel: string;\n\t/**\n\t * Optional compatibility shim for raw tool-call arguments before schema validation.\n\t * Must return an object that matches `TParameters`.\n\t */\n\tprepareArguments?: (args: unknown) => Static<TParameters>;\n\t/** Execute the tool call. Throw on failure instead of encoding errors in `content`. */\n\texecute: (\n\t\ttoolCallId: string,\n\t\tparams: Static<TParameters>,\n\t\tsignal?: AbortSignal,\n\t\tonUpdate?: AgentToolUpdateCallback<TDetails>,\n\t) => Promise<AgentToolResult<TDetails>>;\n\t/** Recovery policy for an effect whose durable intent exists but whose outcome is unknown. */\n\treplay?: \"never\" | \"safe\";\n\t/**\n\t * Per-tool execution mode override.\n\t * - \"sequential\": this tool acts as an exclusive barrier in parallel batches.\n\t * - \"parallel\": this tool can execute concurrently with other tool calls.\n\t *\n\t * If omitted, the default execution mode applies.\n\t */\n\texecutionMode?: ToolExecutionMode;\n}\n\n/** Context snapshot passed into the low-level agent loop. */\nexport interface AgentContext {\n\t/** System prompt included with the request. */\n\tsystemPrompt: string;\n\t/** Transcript visible to the model. */\n\tmessages: AgentMessage[];\n\t/** Tools available for this run. */\n\ttools?: AgentTool<any>[];\n\t/**\n\t * Superset of `tools` to declare to the provider, keeping the tool prefix byte-stable while the\n\t * callable set changes (senpi#2095). Honored only for models that accept an allowed-tools\n\t * restriction; tool calls still resolve against `tools` alone.\n\t */\n\tdeclaredTools?: AgentTool<any>[];\n}\n\n/**\n * Events emitted by the Agent for UI updates.\n *\n * `agent_end` is the last event emitted for a run, but awaited `Agent.subscribe()`\n * listeners for that event are still part of run settlement. The agent becomes\n * idle only after those listeners finish.\n */\nexport type AgentEvent =\n\t// Agent lifecycle\n\t| { type: \"agent_start\" }\n\t| { type: \"agent_end\"; messages: AgentMessage[] }\n\t// Turn lifecycle - a turn is one assistant response + any tool calls/results\n\t| { type: \"turn_start\" }\n\t| { type: \"turn_end\"; message: AgentMessage; toolResults: ToolResultMessage[] }\n\t// Message lifecycle - emitted for user, assistant, and toolResult messages\n\t| { type: \"message_start\"; message: AgentMessage }\n\t// Only emitted for assistant messages during streaming\n\t| { type: \"message_update\"; message: AgentMessage; assistantMessageEvent: AssistantMessageEvent }\n\t| { type: \"message_end\"; message: AgentMessage }\n\t// Tool execution lifecycle\n\t| { type: \"tool_execution_start\"; toolCallId: string; toolName: string; args: any }\n\t| { type: \"tool_execution_update\"; toolCallId: string; toolName: string; args: any; partialResult: any }\n\t| { type: \"tool_execution_end\"; toolCallId: string; toolName: string; result: any; isError: boolean };\n"]}