@sema-agent/core 5.19.0 → 5.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (329) hide show
  1. package/CHANGELOG.md +102 -4
  2. package/dist/agents/agent-definition.d.ts +7 -0
  3. package/dist/agents/agent-transcript-tool.d.ts +30 -0
  4. package/dist/agents/builtin-agents.d.ts +60 -0
  5. package/dist/agents/cascade.d.ts +107 -0
  6. package/dist/agents/cumulative-stats.d.ts +56 -0
  7. package/dist/agents/observer.d.ts +162 -0
  8. package/dist/agents/peer-admission.d.ts +95 -0
  9. package/dist/agents/repair-loop.d.ts +226 -0
  10. package/dist/agents/retain-ledger.d.ts +141 -0
  11. package/dist/agents/roster-store.d.ts +105 -0
  12. package/dist/agents/roster-store.js +3 -0
  13. package/dist/agents/send-message-tool.d.ts +92 -0
  14. package/dist/agents/session-util.d.ts +5 -0
  15. package/dist/agents/subagent-steps.d.ts +66 -0
  16. package/dist/agents/subagent.d.ts +600 -0
  17. package/dist/agents/suspend-guard.d.ts +29 -0
  18. package/dist/agents/teacher.d.ts +75 -0
  19. package/dist/agents/team.d.ts +120 -1
  20. package/dist/agents/tool-filter.d.ts +34 -0
  21. package/dist/agents/verify.d.ts +198 -0
  22. package/dist/bench/metrics.d.ts +455 -0
  23. package/dist/brain/anthropic.d.ts +30 -0
  24. package/dist/brain/circuit-breaker.d.ts +33 -0
  25. package/dist/brain/circuit-breaker.js +14 -3
  26. package/dist/brain/context-overflow.d.ts +60 -3
  27. package/dist/brain/degrading.d.ts +67 -0
  28. package/dist/brain/errors.d.ts +42 -0
  29. package/dist/brain/failover.d.ts +15 -0
  30. package/dist/brain/media-degrade.d.ts +39 -0
  31. package/dist/brain/model-presets.d.ts +31 -0
  32. package/dist/brain/open-responses.d.ts +19 -0
  33. package/dist/brain/openai.d.ts +46 -0
  34. package/dist/brain/reasoning.d.ts +106 -1
  35. package/dist/brain/repetition.d.ts +83 -0
  36. package/dist/brain/request-params.d.ts +56 -0
  37. package/dist/brain/retry.d.ts +46 -0
  38. package/dist/brain/routing.d.ts +12 -0
  39. package/dist/brain/status-sink.d.ts +30 -1
  40. package/dist/brain/stream-engine.d.ts +147 -0
  41. package/dist/brain/stream-shared.d.ts +34 -0
  42. package/dist/brain/terminal-cause.d.ts +31 -0
  43. package/dist/brain/timeout.d.ts +108 -0
  44. package/dist/brain/timeout.js +11 -0
  45. package/dist/brain/tool-call-id.d.ts +20 -0
  46. package/dist/brain/tool-call-repair.d.ts +13 -0
  47. package/dist/config/catalog.d.ts +47 -0
  48. package/dist/config/defaults.d.ts +33 -0
  49. package/dist/core/a2a-task-state.d.ts +53 -0
  50. package/dist/core/a2a.d.ts +51 -0
  51. package/dist/core/arg-summary.d.ts +62 -0
  52. package/dist/core/ask-question.d.ts +272 -2
  53. package/dist/core/auto-compaction.d.ts +467 -0
  54. package/dist/core/auto-compaction.js +20 -6
  55. package/dist/core/auto-mode-prompt-assets.d.ts +8 -0
  56. package/dist/core/auto-mode-prompt.d.ts +27 -0
  57. package/dist/core/auto-mode.d.ts +54 -3
  58. package/dist/core/auto-promote.d.ts +100 -0
  59. package/dist/core/background-agent-store.d.ts +293 -0
  60. package/dist/core/background-agent-store.js +5 -0
  61. package/dist/core/background-shell.d.ts +110 -0
  62. package/dist/core/cache-break-detector.d.ts +34 -0
  63. package/dist/core/canonical-json.d.ts +57 -0
  64. package/dist/core/checkpoint-store.d.ts +1574 -16
  65. package/dist/core/compliance.d.ts +30 -0
  66. package/dist/core/consolidate-scope.d.ts +75 -0
  67. package/dist/core/context-edit.d.ts +99 -0
  68. package/dist/core/context-guard.d.ts +46 -0
  69. package/dist/core/exec-gate.d.ts +44 -0
  70. package/dist/core/exec-output-tail.d.ts +61 -0
  71. package/dist/core/file-snapshot-store.d.ts +104 -0
  72. package/dist/core/fs-write-gate-policy.d.ts +36 -0
  73. package/dist/core/git-worktree-env.d.ts +31 -0
  74. package/dist/core/governance-codes.d.ts +19 -0
  75. package/dist/core/hooks.d.ts +609 -1
  76. package/dist/core/human-input-projection.d.ts +37 -0
  77. package/dist/core/human-input-projection.js +13 -0
  78. package/dist/core/image-downsample.d.ts +74 -0
  79. package/dist/core/locked-config.d.ts +37 -0
  80. package/dist/core/lsp-diagnostics.d.ts +77 -0
  81. package/dist/core/lsp-protocol.d.ts +29 -0
  82. package/dist/core/lsp-session.d.ts +60 -1
  83. package/dist/core/lsp.d.ts +150 -1
  84. package/dist/core/mailbox-store.d.ts +57 -0
  85. package/dist/core/mailbox-store.js +2 -0
  86. package/dist/core/mcp.d.ts +385 -0
  87. package/dist/core/mcp.js +58 -11
  88. package/dist/core/media-byte-cap.d.ts +21 -0
  89. package/dist/core/memory-admission.d.ts +71 -0
  90. package/dist/core/memory-engine/content-origin.d.ts +64 -0
  91. package/dist/core/memory-engine/data-plane.d.ts +43 -0
  92. package/dist/core/memory-engine/dual-root.d.ts +24 -0
  93. package/dist/core/memory-engine/engine.d.ts +230 -0
  94. package/dist/core/memory-engine/engine.js +103 -35
  95. package/dist/core/memory-engine/file-backend.d.ts +155 -0
  96. package/dist/core/memory-engine/frontmatter.d.ts +16 -0
  97. package/dist/core/memory-engine/layout.d.ts +217 -0
  98. package/dist/core/memory-engine/memory-backend-contract.d.ts +12 -0
  99. package/dist/core/memory-engine/migrate.d.ts +9 -0
  100. package/dist/core/memory-engine/scan.d.ts +12 -0
  101. package/dist/core/memory-engine/scope-contract.d.ts +61 -1
  102. package/dist/core/memory-engine/sync-client.d.ts +87 -0
  103. package/dist/core/memory-engine/sync.d.ts +60 -0
  104. package/dist/core/memory-engine/tools.d.ts +41 -0
  105. package/dist/core/memory-engine/types.d.ts +188 -0
  106. package/dist/core/memory-recall.d.ts +141 -0
  107. package/dist/core/memory-vector.d.ts +20 -0
  108. package/dist/core/memory.d.ts +458 -0
  109. package/dist/core/message-utils.d.ts +6 -0
  110. package/dist/core/oracle-isolation.d.ts +69 -0
  111. package/dist/core/permission-rule-consent.d.ts +138 -0
  112. package/dist/core/permission-rule-model.d.ts +122 -0
  113. package/dist/core/permission-rule-store.d.ts +119 -3
  114. package/dist/core/permission-rules.d.ts +87 -1
  115. package/dist/core/present-plan-tool.d.ts +20 -0
  116. package/dist/core/pricing.d.ts +26 -0
  117. package/dist/core/property-harness.d.ts +86 -0
  118. package/dist/core/protocol-naming.d.ts +38 -0
  119. package/dist/core/protocol-table.d.ts +61 -0
  120. package/dist/core/push-queue.d.ts +1 -0
  121. package/dist/core/remote-env.d.ts +383 -1
  122. package/dist/core/retention-policy.d.ts +40 -0
  123. package/dist/core/retention-policy.js +21 -0
  124. package/dist/core/retention.d.ts +51 -0
  125. package/dist/core/roles.d.ts +59 -0
  126. package/dist/core/runner/active-skill-scope.d.ts +34 -0
  127. package/dist/core/runner/assemble-result.d.ts +134 -0
  128. package/dist/core/runner/compaction-call-options.d.ts +97 -1
  129. package/dist/core/runner/grounding-signal.d.ts +10 -0
  130. package/dist/core/runner/image.d.ts +17 -0
  131. package/dist/core/runner/image.js +29 -15
  132. package/dist/core/runner/memory-consolidation.d.ts +60 -0
  133. package/dist/core/runner/prepare-memory.d.ts +59 -0
  134. package/dist/core/runner/prepare-task.d.ts +1011 -2
  135. package/dist/core/runner/prepare-task.js +51 -14
  136. package/dist/core/runner/prompt-suggestions.d.ts +7 -0
  137. package/dist/core/runner/runtask.d.ts +304 -3
  138. package/dist/core/runner/runtask.js +17 -2
  139. package/dist/core/runner/session-file-state-replay.d.ts +49 -0
  140. package/dist/core/runner/session-rule-policy.d.ts +58 -0
  141. package/dist/core/runner/strict-output-schema.d.ts +18 -3
  142. package/dist/core/runner/synthetic-tools.d.ts +113 -0
  143. package/dist/core/runner/teardown-bounded.d.ts +34 -0
  144. package/dist/core/runner/tool-disclosure.d.ts +227 -0
  145. package/dist/core/runner/tool-output-projection.d.ts +6 -0
  146. package/dist/core/runner/turn-attachments.d.ts +634 -0
  147. package/dist/core/runner/usage-accounting.d.ts +32 -0
  148. package/dist/core/runtime.d.ts +9 -0
  149. package/dist/core/safe-notify.d.ts +64 -0
  150. package/dist/core/safety-axis-vocab.d.ts +23 -0
  151. package/dist/core/safety-merge-corpus.d.ts +37 -0
  152. package/dist/core/scheduler.d.ts +121 -0
  153. package/dist/core/secret-env.d.ts +32 -0
  154. package/dist/core/select-model.d.ts +15 -0
  155. package/dist/core/sensitive-path-policy.d.ts +42 -0
  156. package/dist/core/session-policy-store.d.ts +94 -0
  157. package/dist/core/session-reconcile.d.ts +80 -0
  158. package/dist/core/session-store.d.ts +85 -0
  159. package/dist/core/session.d.ts +153 -0
  160. package/dist/core/shared-memory/contract.d.ts +22 -0
  161. package/dist/core/shared-memory/normalize.d.ts +123 -2
  162. package/dist/core/shared-memory/tools.d.ts +14 -0
  163. package/dist/core/shared-memory/types.d.ts +105 -0
  164. package/dist/core/shutdown-debug.d.ts +6 -0
  165. package/dist/core/side-query.d.ts +38 -0
  166. package/dist/core/side-query.js +6 -1
  167. package/dist/core/skill-tool-specifier.d.ts +72 -0
  168. package/dist/core/skills-directory.d.ts +100 -1
  169. package/dist/core/spec-contract.d.ts +89 -0
  170. package/dist/core/store-contracts/background-agent-store-contract.d.ts +31 -0
  171. package/dist/core/store-contracts/checkpoint-store-contract.d.ts +26 -0
  172. package/dist/core/store-contracts/contract-harness.d.ts +20 -0
  173. package/dist/core/store-contracts/contract-kit-version.d.ts +27 -0
  174. package/dist/core/store-contracts/file-snapshot-store-contract.d.ts +8 -0
  175. package/dist/core/store-contracts/mailbox-store-contract.d.ts +42 -0
  176. package/dist/core/store-contracts/tool-result-store-contract.d.ts +13 -0
  177. package/dist/core/strategy-store.d.ts +37 -0
  178. package/dist/core/stub-env.d.ts +7 -0
  179. package/dist/core/surrogate-safe-slice.d.ts +35 -0
  180. package/dist/core/task-notification.d.ts +202 -0
  181. package/dist/core/task-outcome.d.ts +53 -0
  182. package/dist/core/task-registry-agent.d.ts +337 -1
  183. package/dist/core/task-registry-agent.js +2 -0
  184. package/dist/core/task-registry-monitor.d.ts +12 -0
  185. package/dist/core/task-registry-shared.d.ts +540 -0
  186. package/dist/core/task-registry.d.ts +343 -0
  187. package/dist/core/task-registry.js +13 -2
  188. package/dist/core/task-tool-shape.d.ts +44 -0
  189. package/dist/core/tighten-task-spec.d.ts +21 -0
  190. package/dist/core/tool-detach.d.ts +21 -0
  191. package/dist/core/tool-errors.d.ts +131 -0
  192. package/dist/core/tool-errors.js +4 -0
  193. package/dist/core/tool-name-aliases.d.ts +27 -0
  194. package/dist/core/tool-policy.d.ts +555 -0
  195. package/dist/core/tool-policy.js +3 -0
  196. package/dist/core/tool-result-budget.d.ts +32 -0
  197. package/dist/core/tool-result-store.d.ts +174 -1
  198. package/dist/core/tools.d.ts +45 -0
  199. package/dist/core/trace.d.ts +323 -0
  200. package/dist/core/types.d.ts +3859 -2
  201. package/dist/core/untrusted-egress.d.ts +8 -0
  202. package/dist/core/untrusted-text.d.ts +156 -0
  203. package/dist/core/usage-window-store.d.ts +95 -0
  204. package/dist/core/version.d.ts +1 -0
  205. package/dist/core/warm-resume.d.ts +17 -0
  206. package/dist/core/wiring-manifest.d.ts +169 -0
  207. package/dist/core/with-retry.d.ts +24 -0
  208. package/dist/core/workflow-journal-store.d.ts +160 -0
  209. package/dist/core/workflow-run-store-contract.d.ts +25 -0
  210. package/dist/core/workflow-run-store.d.ts +119 -0
  211. package/dist/core/workflow-run-store.js +2 -0
  212. package/dist/engine/compaction/compaction.d.ts +256 -1
  213. package/dist/engine/compaction/utils.d.ts +94 -0
  214. package/dist/engine/execution-env/kill-tree.d.ts +29 -0
  215. package/dist/engine/execution-env/node-execution-env.d.ts +94 -0
  216. package/dist/engine/harness/agent-harness.d.ts +116 -0
  217. package/dist/engine/harness/agent-harness.js +3 -14
  218. package/dist/engine/harness/messages.d.ts +15 -0
  219. package/dist/engine/harness/types.d.ts +464 -2
  220. package/dist/engine/llm/diagnostics.d.ts +4 -0
  221. package/dist/engine/llm/event-stream.d.ts +3 -0
  222. package/dist/engine/llm/index.d.ts +7 -0
  223. package/dist/engine/llm/types.d.ts +500 -3
  224. package/dist/engine/llm/validation.d.ts +3 -0
  225. package/dist/engine/loop/agent-loop.d.ts +87 -2
  226. package/dist/engine/loop/runtime-deps.d.ts +7 -0
  227. package/dist/engine/loop/types.d.ts +424 -0
  228. package/dist/engine/lsp/frame-decoder.d.ts +13 -0
  229. package/dist/engine/lsp/node-lsp-manager.d.ts +107 -0
  230. package/dist/engine/lsp/stdio-lsp-transport.d.ts +7 -0
  231. package/dist/engine/session/import-validate.d.ts +27 -0
  232. package/dist/engine/session/log-digest.d.ts +93 -0
  233. package/dist/engine/session/memory-repo.d.ts +6 -0
  234. package/dist/engine/session/memory-storage.d.ts +2 -0
  235. package/dist/engine/session/session.d.ts +75 -0
  236. package/dist/engine/session/storage-base.d.ts +8 -0
  237. package/dist/fixtures/index.d.ts +36 -0
  238. package/dist/index.d.ts +17 -2
  239. package/dist/index.js +1 -2
  240. package/dist/internal/harness-types.d.ts +6 -0
  241. package/dist/internal/harness.d.ts +11 -0
  242. package/dist/internal/llm.d.ts +6 -0
  243. package/dist/orchestration/builtin-workflows.d.ts +53 -0
  244. package/dist/orchestration/dev-vm-script-runner.d.ts +19 -0
  245. package/dist/orchestration/goal.d.ts +57 -0
  246. package/dist/orchestration/goal.js +3 -0
  247. package/dist/orchestration/run-spec.d.ts +42 -0
  248. package/dist/orchestration/run-spec.js +4 -0
  249. package/dist/orchestration/run-workflow-tool.d.ts +169 -0
  250. package/dist/orchestration/workflow-governance.d.ts +61 -0
  251. package/dist/orchestration/workflow-meta.d.ts +28 -0
  252. package/dist/orchestration/workflow-observe.d.ts +60 -0
  253. package/dist/orchestration/workflow-primitives.d.ts +23 -1
  254. package/dist/orchestration/workflow-sandbox-conformance.d.ts +38 -0
  255. package/dist/orchestration/workflow-script-runner.d.ts +88 -0
  256. package/dist/orchestration/workflow-script-store.d.ts +98 -0
  257. package/dist/orchestration/workflow-size-guideline.d.ts +67 -0
  258. package/dist/orchestration/workflow-types.d.ts +169 -2
  259. package/dist/orchestration/workflow.d.ts +358 -0
  260. package/dist/orchestration/workflow.js +13 -2
  261. package/dist/prompt-assembly/artifact-store.d.ts +33 -0
  262. package/dist/prompt-assembly/artifact.d.ts +25 -0
  263. package/dist/prompt-assembly/assemble.d.ts +20 -0
  264. package/dist/prompt-assembly/composer.d.ts +29 -0
  265. package/dist/prompt-assembly/epoch.d.ts +55 -1
  266. package/dist/prompt-assembly/event-registry.d.ts +35 -0
  267. package/dist/prompt-assembly/explain.d.ts +12 -0
  268. package/dist/prompt-assembly/tool-catalog.d.ts +38 -0
  269. package/dist/prompt-assembly/turn-snapshot.d.ts +40 -0
  270. package/dist/prompt-assembly/types.d.ts +115 -0
  271. package/dist/prompts/coordinator.d.ts +27 -0
  272. package/dist/prompts/default.d.ts +539 -0
  273. package/dist/prompts/simple-sections.d.ts +45 -0
  274. package/dist/prompts/supervisor.d.ts +66 -0
  275. package/dist/scenarios/env.d.ts +28 -0
  276. package/dist/scenarios/full-body.d.ts +50 -0
  277. package/dist/scenarios/scenario-registry.d.ts +60 -0
  278. package/dist/scenarios/teacher-quickstart.d.ts +27 -0
  279. package/dist/server/http.d.ts +17 -0
  280. package/dist/stores/cc/lockfile.d.ts +6 -0
  281. package/dist/stores/cc/mailbox-store.d.ts +8 -0
  282. package/dist/stores/cc/roster-adapter.d.ts +4 -0
  283. package/dist/stores/cc/sidecar-transcript.d.ts +66 -0
  284. package/dist/stores/file/background-agent-store.d.ts +24 -0
  285. package/dist/stores/file/background-agent-store.js +2 -1
  286. package/dist/stores/file/checkpoint-store.d.ts +38 -0
  287. package/dist/stores/file/file-snapshot-store.d.ts +25 -0
  288. package/dist/stores/file/fs-atomic.d.ts +155 -0
  289. package/dist/stores/file/index.d.ts +89 -0
  290. package/dist/stores/file/mailbox-store.d.ts +36 -0
  291. package/dist/stores/file/mailbox-store.js +2 -0
  292. package/dist/stores/file/memory-store.d.ts +82 -0
  293. package/dist/stores/file/permission-rule-store.d.ts +79 -0
  294. package/dist/stores/file/session-policy-store.d.ts +28 -0
  295. package/dist/stores/file/session-store.d.ts +40 -0
  296. package/dist/stores/file/shared-ledger.d.ts +83 -0
  297. package/dist/stores/file/tool-result-store.d.ts +11 -0
  298. package/dist/stores/file/usage-window-store.d.ts +18 -0
  299. package/dist/stores/file/workflow-journal-store.d.ts +100 -0
  300. package/dist/stores/file/workflow-run-store.d.ts +11 -0
  301. package/dist/stores/file/workflow-run-store.js +2 -0
  302. package/dist/tools/fs/bash-readonly-classifier.d.ts +282 -0
  303. package/dist/tools/fs/encoding.d.ts +60 -0
  304. package/dist/tools/fs/fs-bash.d.ts +133 -0
  305. package/dist/tools/fs/fs-pdf.d.ts +28 -0
  306. package/dist/tools/fs/fs-search-tools.d.ts +5 -0
  307. package/dist/tools/fs/fs-shared.d.ts +360 -0
  308. package/dist/tools/fs/fs-write.d.ts +16 -0
  309. package/dist/tools/fs/gh-rate-limit.d.ts +22 -0
  310. package/dist/tools/fs/index.d.ts +79 -0
  311. package/dist/tools/fs/notebook.d.ts +56 -0
  312. package/dist/tools/fs/pdf.d.ts +70 -0
  313. package/dist/tools/fs/pdf.js +8 -2
  314. package/dist/tools/fs/repo-map.d.ts +10 -0
  315. package/dist/tools/fs/safety.d.ts +376 -0
  316. package/dist/tools/fs/search.d.ts +131 -0
  317. package/dist/tools/loop-tick.d.ts +24 -0
  318. package/dist/tools/monitor.d.ts +55 -0
  319. package/dist/tools/scheduler-tools.d.ts +51 -0
  320. package/dist/tools/sql-adapters.d.ts +18 -0
  321. package/dist/tools/sql.d.ts +25 -0
  322. package/dist/tools/task-list.d.ts +77 -0
  323. package/dist/tools/todo.d.ts +8 -0
  324. package/dist/tools/web.d.ts +184 -0
  325. package/dist/tools/web.js +32 -5
  326. package/dist/tools/worktree.d.ts +81 -0
  327. package/package.json +2 -2
  328. package/dist/tools/gitea-issue.d.ts +0 -13
  329. package/dist/tools/gitea-issue.js +0 -75
@@ -1,9 +1,30 @@
1
+ /**
2
+ * design/116 detach(飞轮 [C] gap ②)— per-tool-call detach 信号毂。
3
+ *
4
+ * The missing middle of mid-flight ctrl+b: `TaskStream.detach(toolCallId)` fires the controller here; a
5
+ * detach-capable tool (Bash) picks the signal up BY toolCallId from its mount closure and threads it into
6
+ * `env.exec({ detachSignal })`, where the env adopts the running child as a background shell. Run-local
7
+ * (one hub per task, created in prepare-task) — never cross-task. Zero vendored surface: the loop's
8
+ * tool-call plumbing is untouched; the hub rides the existing closure path like taskRegistry does.
9
+ *
10
+ * `request()` uses create-then-abort so ordering races are safe: a detach that lands BEFORE the tool
11
+ * reads its signal still detaches (the tool receives an already-aborted signal and adopts immediately).
12
+ */
1
13
  export declare class ToolDetachHub {
2
14
  private readonly controllers;
15
+ /** service [371]③: the detach verb is caller-exposed — an unknown/never-started toolCallId would otherwise
16
+ * strand its controller until run end (gc only fires on the real tool-completion path), a per-run memory
17
+ * growth vector. Bound the map: on overflow, evict the OLDEST entry (Map preserves insertion order); a
18
+ * live tool re-materializes its controller on the next signalFor() and an aborted one stays aborted via
19
+ * the tombstone set below. */
3
20
  private static readonly MAX_CONTROLLERS;
21
+ /** Fired-but-evicted ids (bounded): keeps create-then-abort race safety across an eviction. */
4
22
  private readonly firedTombstones;
5
23
  private controllerFor;
24
+ /** The signal a detach-capable tool threads into its env call. */
6
25
  signalFor(toolCallId: string): AbortSignal;
26
+ /** Fire a detach request for a (possibly not-yet-started) tool call. Idempotent. */
7
27
  request(toolCallId: string): void;
28
+ /** Drop a finished call's controller (bounded memory; called from the tool's completion path). */
8
29
  gc(toolCallId: string): void;
9
30
  }
@@ -1,8 +1,139 @@
1
1
  import type { TSchema } from "typebox";
2
+ /**
3
+ * Truncate a long error to head + "[N characters truncated]" + tail (design/64 §11.2, CC parity).
4
+ *
5
+ * Anchored on CC 2.1.220 `A7e` (the current authority; the previous anchor was CC 88's `toolErrors.ts`,
6
+ * which cut at raw code-unit indices): head and tail are cut on a code-POINT boundary — an astral character
7
+ * straddling either cut is dropped whole rather than emitted as a lone surrogate — and the reported count is
8
+ * `len − head − tail`, i.e. derived from what was actually KEPT, so a rollback is not under-reported.
9
+ *
10
+ * DELIBERATE DIVERGENCE from the sibling truncators in this repo (mcp.ts `truncateMcpErrorText`,
11
+ * engine/compaction `truncateForSummary`, untrusted-egress `boundedString`), which iterate the kept length
12
+ * down so the marker fits INSIDE the budget (RB-152): here the marker is NOT budgeted — a barely-over input
13
+ * comes back ~36 chars LONGER than the budget. That is CC-verbatim behaviour (`A7e` keeps 5000+marker+5000),
14
+ * it is pinned as a contract in test/core-toolgate-coverage.test.ts, and changing it would be a divergence
15
+ * FROM the anchor, not a fix. Recorded as an intentional divergence in the cc-parity divergence registry
16
+ * (internal assets repo, `cc-parity/`), not as an open defect.
17
+ */
2
18
  export declare function truncateError(s: string): string;
19
+ /**
20
+ * RB-198 F4: shared clip primitive originally grown inside task-registry's `clipTaskOutput` (CC `FHl`
21
+ * shape, pretty.js:458012-458016) and extracted here so a SECOND caller (the foreground Bash tool) gets
22
+ * the SAME already-hardened arithmetic instead of a parallel reimplementation — RB-85 (pointer-fit at the
23
+ * boundary), RB-112 (pointer-only fallback bound), and RB-122 (surrogate-pair-safe split) were each a real
24
+ * bug found by a red probe against THIS algorithm; a second copy would start over with none of them fixed.
25
+ * TAIL-keep behind a `[Truncated. Full output: <path>]` pointer when a full-output file is available (the
26
+ * tail is the part a long-running command's caller most needs — errors/summaries land at the end); without
27
+ * a file, legacy head+tail middle-omission (there is no path to point at, and the head often carries
28
+ * status a bare tail-keep would drop).
29
+ */
3
30
  export declare function clipWithFilePointer(s: string, limit: number, fullOutputPath?: string): string;
31
+ /**
32
+ * Format a thrown tool error into model-facing text (design/64 §11.1/§11.2): a shell/exec error becomes
33
+ * `Exit code N` + stderr + stdout; a plain Error becomes its message (+ any captured streams); anything
34
+ * else is stringified. The result is truncated to {@link MAX_ERROR_CHARS}. An AbortError is reported as an
35
+ * interruption.
36
+ */
4
37
  export declare function formatToolError(error: unknown): string;
38
+ /**
39
+ * A typed, read-side fold of a `TaskResult.errorCode` into the failure CLASS it belongs to (design/80
40
+ * D-G data contract; the WorkerReport "errorClass" small-slice). A terminal `errorCode` (1.37+) is a
41
+ * **dotted namespace** (`limits.max_tokens_exceeded` / `limits.max_cost_exceeded` / `output.invalid` …)
42
+ * so a consumer can prefix-match a whole CLASS — but every aggregator/consumer hand-rolls
43
+ * `errorCode.startsWith("budget.")` (types.ts:707 documents this very pattern), which silently
44
+ * mis-classifies any code that does NOT follow the convention and drifts as new prefixes are added.
45
+ * This is the single shared folder.
46
+ *
47
+ * - `budget` — the cost/token budget gate fired (`limits.max_tokens_exceeded` / `limits.max_cost_exceeded`).
48
+ * - `limit` — a hard run limit fired (`limits.max_turns_exceeded` / `limits.max_walltime_exceeded`).
49
+ * - `output` — the structured/answer output was rejected (`output.invalid` / `output.degenerate`).
50
+ * - `suspend` — the suspend-loop cap fired (`suspend.loop`); a TERMINAL failure, distinct from a
51
+ * resumable `suspended` status (which carries no errorCode).
52
+ * - `review` — a review-pause terminal (`review.pending`).
53
+ * - `unexpected` — a nested orchestrator mapped an unexpected durable pause to failed
54
+ * (`unexpected.suspended` / `unexpected.needs_review`, design/45 §11 Q6 / design/80 D-B).
55
+ * - `oracle` — a verifier/oracle invariant breach (`oracle.unprotected`).
56
+ * - `resume` — a post-CAS resume/restore infrastructure failure (`resume.env_failed` /
57
+ * `resume.tool_unavailable`, design/45/49); a RETRYABLE basis (the work is still pending,
58
+ * the checkpoint is reopenable) — distinct from a logical failure, so consumers can retry.
59
+ * - `config` — a task-spec / assembly rejection raised in `prepare()` (`config.egress_requires_write_effect`
60
+ * / `config.reserved_tool_name`); a deterministic configuration error (re-running the same
61
+ * spec re-fails). ALSO the deployment governance-plane terminals that share the SAME
62
+ * registry (governance-codes.ts `GOVERNANCE_CODES` mixes them with `config.*` in one
63
+ * table): `memory.admission_required` / `memory.admission_denied` (org-memory admission,
64
+ * genuinely `prepare()`-raised, same shape as the config.* codes above) plus the two
65
+ * EXTERNAL/platform-cause terminals `usage.window_exhausted` (a deployment usage-governance
66
+ * window is full — mid-run or at entry, design/164 件五) and `env.lifetime_expired` (the
67
+ * execution environment's platform lifetime ran out — an engine-detected MID-RUN stop at a
68
+ * clean turn boundary, design/164 件四; NOT a `prepare()`-time rejection like its
69
+ * `config.env_lifetime_invalid` config-time sibling). The two platform-cause codes are
70
+ * DEFERRED-retryable (a usage window frees, a fresh environment can be provisioned) —
71
+ * genuinely NOT "never retryable, malformed request" in the literal sense of the codes
72
+ * above; they are grouped into this class as the SAME deployment-governance DOMAIN (per
73
+ * governance-codes.ts's own table membership and the calling convention's explicit
74
+ * direction), not as a retry verdict. This class NEVER carries the retry answer for
75
+ * ANY of its members — a caller that needs it reads the PER-CODE source of truth:
76
+ * `TaskResult.retryAfterMs` (set ONLY for `usage.window_exhausted`, per its own
77
+ * in-presence condition) for that one code, or the errorCode's own doc for every other
78
+ * member (`env.lifetime_expired`'s doc says "retrying needs a NEW environment, not a
79
+ * smaller budget" — there is no `retryAfterMs` for it, by design: an expiring
80
+ * environment has no return time to give). Codex adversarial review (rounds 2 and 4)
81
+ * twice suggested a distinct governance/platform class or leaving these `unknown`
82
+ * instead — rejected both times: (a) explicit calling-convention direction; (b)
83
+ * `WorkerErrorClass` is a small CLOSED public exported union — adding a member is an
84
+ * API-surface/release-tier decision outside a mechanical fix batch's mandate, and
85
+ * `unknown` would UNDO the very audit finding this folder exists to fix (these ARE real
86
+ * terminal codes, not foreign ones); (c) pre-existing precedent (`config.compliance_required`,
87
+ * NOT part of this diff) already folds a transient/retryable governance code into `config`.
88
+ * `memory.admission_required`/`_denied`/`env.lifetime_expired` are EXACT codes, not broad
89
+ * `memory.`/`env.` prefixes — codex adversarial review (A-005.3 follow-up) caught an
90
+ * earlier draft folding EVERY `memory.*`/`env.*` code here, which misclassified the
91
+ * memory-engine's non-governance incident codes (`memory.secret_detected` et al.,
92
+ * explicitly listed as NON-governance in `NON_GOVERNANCE_MEMORY_CODES` — a content-safety
93
+ * tool-call refusal, not a task-spec rejection) as configuration failures. `usage.*` STAYS
94
+ * a broad prefix: governance-codes.ts's own `governanceRetryClass` already treats every
95
+ * `usage.*` code (registered or not) as governance by prefix — a deliberate legacy-family
96
+ * rule this folder mirrors rather than re-deciding (codex round 2 questioned whether that
97
+ * mirroring is appropriate across the two taxonomies; kept as-is per the calling
98
+ * convention's explicit direction — see the function's SCOPE note for the boundary this
99
+ * folder does and does not draw).
100
+ * - `conflict` — a cross-instance optimistic-lock loss (flat `"conflict"`, unchanged 1.36 code).
101
+ * - `brain` — a model/transport failure lifted from the brain (flat `auth` / `rate_limit` /
102
+ * `invalid_request` / `server` / `network` / `http`; see brain/errors.ts).
103
+ * - `aborted` — a step was aborted (flat `"aborted"`).
104
+ * - `unknown` — no code, or a code outside every known class (the safe catch-all).
105
+ */
5
106
  export type WorkerErrorClass = "budget" | "limit" | "output" | "suspend" | "review" | "unexpected" | "oracle" | "resume" | "config" | "conflict" | "brain" | "aborted" | "unknown";
107
+ /**
108
+ * Fold a {@link "../core/types.js".TaskResult}.`errorCode` into its typed {@link WorkerErrorClass} (design/80
109
+ * D-G). PURE and DERIVED — it reads an existing code, never produces or changes one; an unknown / missing
110
+ * code folds to `"unknown"` (never throws). Replaces scattered `errorCode.startsWith("budget.")` consumer
111
+ * code with one tested folder so the class taxonomy lives in exactly one place.
112
+ *
113
+ * SCOPE: this folds a TERMINAL `TaskResult.errorCode` only — i.e. every OUR dotted prefix that the runner can
114
+ * assemble into a failed task outcome (`limits.`/`output.`/`suspend.`/`review.`/`unexpected.`/
115
+ * `oracle.`/`resume.`/`config.`/`usage.`) as a broad PREFIX, plus `memory.admission_required` /
116
+ * `memory.admission_denied` / `env.lifetime_expired` as EXACT codes (their sibling `memory.*`/`env.*` strings
117
+ * are NOT all terminal-errorCode-shaped — see {@link EXACT_CODE_CLASS}'s comment), plus the flat 1.36 codes.
118
+ * The `limits.` namespace splits into the `budget` and `limit` classes by exact code — see
119
+ * {@link EXACT_CODE_CLASS}. Operation-level dotted codes that are surfaced to a *caller* and never become a
120
+ * task outcome are deliberately OUT of scope: `steering.*` (`steering.not_running`/`steering.invalid_content`,
121
+ * rejected to the `steer()` caller) and `mcp.*` (`mcp.server_unavailable`, an `onWarn` warning code) — neither
122
+ * reaches `TaskResult.errorCode`, so a caller will never pass them here. A genuinely unmapped code → `"unknown"` (which therefore means
123
+ * "known-but-foreign or no code", e.g. a leaked fs/Node code, NOT "an OUR terminal class we forgot to add").
124
+ */
6
125
  export declare function errorClassOf(errorCode: string | undefined): WorkerErrorClass;
126
+ /**
127
+ * Convert a TypeBox/JSON-Schema error path (`/todos/0/activeForm`) into a readable accessor
128
+ * (`todos[0].activeForm`), CC `formatValidationPath` parity. Numeric segments become `[i]`, named
129
+ * segments become `.name`. Empty path → "" (the root object).
130
+ */
7
131
  export declare function formatValidationPath(path: string): string;
132
+ /**
133
+ * Turn a schema-validation failure into a human-readable message (design/64 §11.3 / §16.4). Reports the
134
+ * parameter NAME + the expected type only — never an absolute path, stack trace, or filesystem context, so
135
+ * a validation message can't leak internals (§16.4). Examples:
136
+ * - "The required parameter `todos` is missing."
137
+ * - "The parameter `questions[0].options` is invalid: Expected array."
138
+ */
8
139
  export declare function formatZodValidationError(schema: TSchema, value: unknown): string;
@@ -70,6 +70,9 @@ const EXACT_CODE_CLASS = new Map([
70
70
  ["limits.max_cost_exceeded", "budget"],
71
71
  ["limits.max_turns_exceeded", "limit"],
72
72
  ["limits.max_walltime_exceeded", "limit"],
73
+ ["memory.admission_required", "config"],
74
+ ["memory.admission_denied", "config"],
75
+ ["env.lifetime_expired", "config"],
73
76
  ]);
74
77
  const DOTTED_PREFIX_CLASS = [
75
78
  ["limits.", "limit"],
@@ -80,6 +83,7 @@ const DOTTED_PREFIX_CLASS = [
80
83
  ["oracle.", "oracle"],
81
84
  ["resume.", "resume"],
82
85
  ["config.", "config"],
86
+ ["usage.", "config"],
83
87
  ];
84
88
  export function errorClassOf(errorCode) {
85
89
  if (!errorCode)
@@ -1 +1,28 @@
1
+ /**
2
+ * RB-476-A stage 2 (ruling 2026-08-02, RB-476 "no compatibility surface survives", replay
3
+ * resolution included) — the durable-name machinery this module used to hold is RETIRED:
4
+ *
5
+ * - `OLD_TO_NEW` (the Q6/design-108/design-115 persisted-name normalization) and the MCP `mcp__`
6
+ * prefix arm are gone: a persisted checkpoint/orphan/policy entry carrying a pre-rename name no
7
+ * longer resolves to the live roster. Old durable state misses LOUDLY (`resume.tool_unavailable`
8
+ * on a resumed checkpoint, a roster miss on replay) — by ruling, old sessions are sacrificed
9
+ * rather than carried.
10
+ * - `canonicalToolName` is gone with it: with the mapping cleared it was the identity function, and
11
+ * keeping an identity shim invites the next mapping to grow back silently.
12
+ * - `TOMBSTONED_TOOLS` (per-name re-education messages) is gone: a retired name now gets the same
13
+ * loud generic roster miss as any unknown tool.
14
+ *
15
+ * What REMAINS is validation data only: {@link RETIRED_TOOL_NAMES} maps every name the engine ever
16
+ * retired to a one-line guidance string. It exists because deleting the mapping flips stale POLICY
17
+ * entries from "silently matched" to "silently matches nothing" — and for a deny/requireApproval
18
+ * entry that direction WIDENS the surface. The prepare-time policy-name audit (runner/prepare-task.ts)
19
+ * escalates a retired name that matches nothing in the run's roster from advisory to a HARD,
20
+ * coordinates-carrying failure (`config.legacy_tool_name`) — `validatePermissionRules`
21
+ * (permission-rules.ts) does NOT classify retired names itself; a retired-name entry is a raw,
22
+ * ordinary-looking tool name to its compile pass by design (RB-476-A: that classification is the
23
+ * roster-aware prepare-time audit's job, not the compile pass's, since compile time cannot know
24
+ * which names a deployment mounts its OWN tool under). A deployment that mounts its OWN tool under
25
+ * one of these names is unaffected either way: the name is then in the roster, matches, and is never
26
+ * audited as stale.
27
+ */
1
28
  export declare const RETIRED_TOOL_NAMES: ReadonlyMap<string, string>;