@sema-agent/core 7.47.0 → 7.49.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 (431) hide show
  1. package/CHANGELOG.md +472 -0
  2. package/README.md +2 -2
  3. package/dist/agents/cascade.d.ts +2 -5
  4. package/dist/agents/child-failure.d.ts +20 -0
  5. package/dist/agents/child-failure.js +28 -0
  6. package/dist/agents/cross-session-ref.d.ts +11 -3
  7. package/dist/agents/cross-session-ref.js +6 -0
  8. package/dist/agents/cumulative-stats.d.ts +12 -15
  9. package/dist/agents/cumulative-stats.js +1 -1
  10. package/dist/agents/extra-tool-names.js +1 -1
  11. package/dist/agents/inherited-tool-pool.d.ts +17 -13
  12. package/dist/agents/inherited-tool-pool.js +4 -3
  13. package/dist/agents/peer-session-drain.d.ts +3 -2
  14. package/dist/agents/peer-session-drain.js +5 -4
  15. package/dist/agents/send-message-tool.js +2 -9
  16. package/dist/agents/subagent.d.ts +10 -29
  17. package/dist/agents/subagent.js +65 -53
  18. package/dist/agents/suspend-guard.d.ts +1 -1
  19. package/dist/agents/tool-filter.d.ts +76 -65
  20. package/dist/agents/tool-filter.js +122 -92
  21. package/dist/agents/verify.d.ts +4 -7
  22. package/dist/agents/verify.js +6 -7
  23. package/dist/bench/metrics.d.ts +1 -2
  24. package/dist/brain/anthropic.js +133 -79
  25. package/dist/brain/errors.d.ts +53 -6
  26. package/dist/brain/errors.js +22 -2
  27. package/dist/brain/input-too-long.d.ts +40 -19
  28. package/dist/brain/input-too-long.js +3 -16
  29. package/dist/brain/open-responses.js +19 -10
  30. package/dist/brain/openai.js +123 -32
  31. package/dist/brain/provider-dialect.d.ts +214 -0
  32. package/dist/brain/provider-dialect.js +186 -0
  33. package/dist/brain/request-params.d.ts +27 -8
  34. package/dist/brain/request-params.js +7 -12
  35. package/dist/brain/request-route.d.ts +84 -0
  36. package/dist/brain/request-route.js +41 -0
  37. package/dist/brain/retry.d.ts +8 -0
  38. package/dist/brain/retry.js +10 -4
  39. package/dist/brain/route-adjudicator.d.ts +7 -0
  40. package/dist/brain/route-adjudicator.js +5 -1
  41. package/dist/brain/status-sink.d.ts +20 -0
  42. package/dist/brain/status-sink.js +11 -0
  43. package/dist/brain/stream-engine.d.ts +52 -1
  44. package/dist/brain/stream-engine.js +81 -24
  45. package/dist/brain/stream-shared.d.ts +57 -11
  46. package/dist/brain/stream-shared.js +28 -2
  47. package/dist/core/a2a.d.ts +1 -0
  48. package/dist/core/agent-config-dir.js +3 -2
  49. package/dist/core/allow-entry.d.ts +21 -12
  50. package/dist/core/allow-entry.js +39 -32
  51. package/dist/core/arg-summary.d.ts +17 -24
  52. package/dist/core/arg-summary.js +169 -68
  53. package/dist/core/ask-origin.d.ts +42 -24
  54. package/dist/core/ask-origin.js +18 -13
  55. package/dist/core/auto-mode-prompt-assets.d.ts +2 -2
  56. package/dist/core/auto-mode-prompt-assets.js +1 -1
  57. package/dist/core/auto-mode-prompt.d.ts +11 -1
  58. package/dist/core/auto-mode-prompt.js +13 -10
  59. package/dist/core/auto-mode-rebuild.d.ts +7 -0
  60. package/dist/core/auto-mode-rebuild.js +4 -1
  61. package/dist/core/canonical-json.d.ts +3 -0
  62. package/dist/core/canonical-json.js +2 -1
  63. package/dist/core/checkpoint-requirements.d.ts +892 -0
  64. package/dist/core/checkpoint-requirements.js +333 -0
  65. package/dist/core/checkpoint-store.d.ts +95 -66
  66. package/dist/core/checkpoint-store.js +14 -26
  67. package/dist/core/child-clamp-seats.d.ts +228 -69
  68. package/dist/core/child-clamp-seats.js +211 -17
  69. package/dist/core/classifier-unavailable-arm.d.ts +5 -1
  70. package/dist/core/classifier-unavailable-arm.js +3 -3
  71. package/dist/core/compliance.d.ts +3 -0
  72. package/dist/core/compliance.js +9 -4
  73. package/dist/core/credential-vocabulary.d.ts +140 -0
  74. package/dist/core/credential-vocabulary.js +131 -0
  75. package/dist/core/decision-receipt.js +1 -1
  76. package/dist/core/effective-path-target.d.ts +73 -16
  77. package/dist/core/effective-path-target.js +63 -33
  78. package/dist/core/engine-notice.d.ts +32 -7
  79. package/dist/core/file-history-store.js +2 -2
  80. package/dist/core/fs-write-gate-policy.d.ts +4 -0
  81. package/dist/core/fs-write-gate-policy.js +22 -5
  82. package/dist/core/gate-bounded-await.d.ts +28 -13
  83. package/dist/core/gate-bounded-await.js +41 -4
  84. package/dist/core/gate-fold.d.ts +1 -1
  85. package/dist/core/gate-fold.js +24 -25
  86. package/dist/core/gate-lanes.js +16 -15
  87. package/dist/core/gate-outcome.d.ts +20 -5
  88. package/dist/core/gate-outcome.js +5 -0
  89. package/dist/core/governance-codes.d.ts +11 -4
  90. package/dist/core/governance-codes.js +14 -3
  91. package/dist/core/hooks.d.ts +4 -0
  92. package/dist/core/locked-config.d.ts +8 -0
  93. package/dist/core/locked-config.js +14 -2
  94. package/dist/core/lsp.js +3 -5
  95. package/dist/core/mailbox-store.d.ts +3 -4
  96. package/dist/core/mcp-connection-pool.d.ts +75 -0
  97. package/dist/core/mcp-connection-pool.js +128 -0
  98. package/dist/core/mcp-failure.d.ts +2 -1
  99. package/dist/core/mcp-failure.js +13 -2
  100. package/dist/core/mcp-server-spec.d.ts +1 -1
  101. package/dist/core/mcp.d.ts +4 -0
  102. package/dist/core/mcp.js +70 -43
  103. package/dist/core/memory-engine/content-origin.js +2 -14
  104. package/dist/core/memory-engine/engine.d.ts +32 -22
  105. package/dist/core/memory-engine/engine.js +103 -55
  106. package/dist/core/memory-engine/file-backend.d.ts +13 -30
  107. package/dist/core/memory-engine/file-backend.js +37 -252
  108. package/dist/core/memory-engine/index.d.ts +1 -1
  109. package/dist/core/memory-engine/index.js +1 -1
  110. package/dist/core/memory-engine/layout.d.ts +139 -9
  111. package/dist/core/memory-engine/layout.js +350 -7
  112. package/dist/core/memory-engine/scope-contract.d.ts +10 -0
  113. package/dist/core/memory-engine/scope-contract.js +8 -0
  114. package/dist/core/memory-engine/session-incarnation.d.ts +14 -4
  115. package/dist/core/memory-engine/session-incarnation.js +5 -2
  116. package/dist/core/memory-engine/types.d.ts +10 -1
  117. package/dist/core/memory.js +5 -17
  118. package/dist/core/model-seat.d.ts +4 -4
  119. package/dist/core/model-seat.js +1 -1
  120. package/dist/core/mounted-mcp.d.ts +57 -0
  121. package/dist/core/mounted-mcp.js +19 -0
  122. package/dist/core/namespaced-rule-name.d.ts +29 -0
  123. package/dist/core/namespaced-rule-name.js +52 -0
  124. package/dist/core/park-selfcheck.d.ts +1 -1
  125. package/dist/core/park-selfcheck.js +16 -6
  126. package/dist/core/path-guard-rows.d.ts +99 -0
  127. package/dist/core/path-guard-rows.js +45 -0
  128. package/dist/core/path-identity.d.ts +22 -16
  129. package/dist/core/path-identity.js +10 -10
  130. package/dist/core/path-rule-binding.d.ts +2 -1
  131. package/dist/core/path-rule-binding.js +3 -1
  132. package/dist/core/pause-registry.d.ts +16 -2
  133. package/dist/core/pause-registry.js +6 -0
  134. package/dist/core/permission-rule-consent.js +0 -7
  135. package/dist/core/permission-rule-model.d.ts +68 -24
  136. package/dist/core/permission-rule-model.js +105 -24
  137. package/dist/core/permission-rule-store.js +2 -2
  138. package/dist/core/permission-rules.d.ts +3 -30
  139. package/dist/core/permission-rules.js +4 -54
  140. package/dist/core/read-root-candidate.d.ts +1 -3
  141. package/dist/core/read-root-candidate.js +4 -15
  142. package/dist/core/real-approval.d.ts +4 -3
  143. package/dist/core/retired-keys.d.ts +13 -0
  144. package/dist/core/retired-keys.js +14 -0
  145. package/dist/core/roles.d.ts +2 -3
  146. package/dist/core/roles.js +15 -6
  147. package/dist/core/runner/assemble-result.d.ts +0 -7
  148. package/dist/core/runner/assemble-result.js +19 -31
  149. package/dist/core/runner/caller-roster.d.ts +78 -0
  150. package/dist/core/runner/caller-roster.js +219 -0
  151. package/dist/core/runner/checkpoint-scope.d.ts +16 -16
  152. package/dist/core/runner/checkpoint-scope.js +2 -2
  153. package/dist/core/runner/child-tree.js +2 -2
  154. package/dist/core/runner/contracts.d.ts +68 -35
  155. package/dist/core/runner/decide-continuation.d.ts +51 -3
  156. package/dist/core/runner/decide-continuation.js +76 -21
  157. package/dist/core/runner/denial-limit-arms.d.ts +17 -5
  158. package/dist/core/runner/denial-limit-arms.js +11 -9
  159. package/dist/core/runner/extra-body-dropped-seat.d.ts +8 -0
  160. package/dist/core/runner/extra-body-dropped-seat.js +22 -0
  161. package/dist/core/runner/finish-reason-seat.d.ts +9 -0
  162. package/dist/core/runner/finish-reason-seat.js +40 -0
  163. package/dist/core/runner/gate-exit.d.ts +44 -32
  164. package/dist/core/runner/gate-exit.js +112 -25
  165. package/dist/core/runner/inherited-ask-grants.js +6 -4
  166. package/dist/core/runner/mcp-redial.d.ts +3 -3
  167. package/dist/core/runner/mcp-redial.js +3 -4
  168. package/dist/core/runner/park-commit.d.ts +1 -1
  169. package/dist/core/runner/permission-rule-lanes.d.ts +1 -2
  170. package/dist/core/runner/permission-rule-lanes.js +5 -4
  171. package/dist/core/runner/prepare-artifact.d.ts +4 -0
  172. package/dist/core/runner/prepare-artifact.js +2 -1
  173. package/dist/core/runner/prepare-ask-lane.d.ts +2 -0
  174. package/dist/core/runner/prepare-ask-lane.js +12 -6
  175. package/dist/core/runner/prepare-boundary-parks.d.ts +5 -8
  176. package/dist/core/runner/prepare-boundary-parks.js +4 -7
  177. package/dist/core/runner/prepare-caps-and-workflow.d.ts +11 -15
  178. package/dist/core/runner/prepare-caps-and-workflow.js +19 -27
  179. package/dist/core/runner/prepare-config-doors.d.ts +9 -9
  180. package/dist/core/runner/prepare-config-doors.js +10 -5
  181. package/dist/core/runner/prepare-defer-classify.d.ts +2 -2
  182. package/dist/core/runner/prepare-defer-classify.js +5 -3
  183. package/dist/core/runner/prepare-delegation-surface.d.ts +1 -1
  184. package/dist/core/runner/prepare-delegation-surface.js +3 -3
  185. package/dist/core/runner/prepare-gate-stations.d.ts +4 -4
  186. package/dist/core/runner/prepare-gate-stations.js +9 -7
  187. package/dist/core/runner/prepare-hands-readface.d.ts +7 -7
  188. package/dist/core/runner/prepare-hands-readface.js +7 -7
  189. package/dist/core/runner/prepare-inherited-gate.d.ts +7 -6
  190. package/dist/core/runner/prepare-inherited-gate.js +14 -15
  191. package/dist/core/runner/prepare-listings.d.ts +7 -24
  192. package/dist/core/runner/prepare-listings.js +4 -5
  193. package/dist/core/runner/prepare-memory-engine-session.d.ts +2 -0
  194. package/dist/core/runner/prepare-memory-engine-session.js +4 -3
  195. package/dist/core/runner/prepare-memory.d.ts +6 -0
  196. package/dist/core/runner/prepare-memory.js +13 -13
  197. package/dist/core/runner/prepare-offload-wrappers.d.ts +5 -0
  198. package/dist/core/runner/prepare-offload-wrappers.js +3 -3
  199. package/dist/core/runner/prepare-park-ask.d.ts +7 -8
  200. package/dist/core/runner/prepare-park-ask.js +17 -10
  201. package/dist/core/runner/prepare-policy-chain.js +24 -44
  202. package/dist/core/runner/prepare-project-context.d.ts +1 -1
  203. package/dist/core/runner/prepare-project-context.js +3 -4
  204. package/dist/core/runner/prepare-protocol-tools.d.ts +9 -3
  205. package/dist/core/runner/prepare-protocol-tools.js +3 -4
  206. package/dist/core/runner/prepare-run-refs.d.ts +3 -0
  207. package/dist/core/runner/prepare-run-refs.js +2 -1
  208. package/dist/core/runner/prepare-safety-scan.d.ts +4 -8
  209. package/dist/core/runner/prepare-safety-scan.js +1 -2
  210. package/dist/core/runner/prepare-suspend-saga.d.ts +7 -1
  211. package/dist/core/runner/prepare-suspend-saga.js +28 -12
  212. package/dist/core/runner/prepare-task.d.ts +1 -1
  213. package/dist/core/runner/prepare-task.js +67 -56
  214. package/dist/core/runner/prepare-wiring-manifest.d.ts +11 -10
  215. package/dist/core/runner/prepare-wiring-manifest.js +5 -8
  216. package/dist/core/runner/resume-apply.js +7 -14
  217. package/dist/core/runner/resume-checkpoint-screen.js +11 -4
  218. package/dist/core/runner/resume-internals-and-config.js +2 -2
  219. package/dist/core/runner/resume-policy-outcome.js +5 -32
  220. package/dist/core/runner/resume-review-outcome.js +4 -1
  221. package/dist/core/runner/retired-runner-deps.d.ts +6 -0
  222. package/dist/core/runner/retired-runner-deps.js +10 -1
  223. package/dist/core/runner/run-brain-sinks.d.ts +4 -0
  224. package/dist/core/runner/run-brain-sinks.js +5 -2
  225. package/dist/core/runner/run-harness-handlers.js +27 -34
  226. package/dist/core/runner/run-leg.d.ts +0 -2
  227. package/dist/core/runner/run-leg.js +32 -33
  228. package/dist/core/runner/run-terminal-adoption.js +4 -3
  229. package/dist/core/runner/runtask.js +8 -8
  230. package/dist/core/runner/session-rule-policy.js +5 -5
  231. package/dist/core/runner/stream-settle-backstop.js +7 -4
  232. package/dist/core/runner/sub-agent-deny-lists.d.ts +51 -12
  233. package/dist/core/runner/sub-agent-deny-lists.js +111 -80
  234. package/dist/core/runner/terminal-account.d.ts +48 -0
  235. package/dist/core/runner/terminal-account.js +186 -0
  236. package/dist/core/runner/tool-end-body.d.ts +54 -17
  237. package/dist/core/runner/tool-end-body.js +27 -2
  238. package/dist/core/runner/tool-face-overlay.d.ts +3 -1
  239. package/dist/core/runner/tool-face-overlay.js +6 -4
  240. package/dist/core/runner/tool-occurrence.d.ts +106 -0
  241. package/dist/core/runner/tool-occurrence.js +123 -0
  242. package/dist/core/runner/tool-progress-lane.d.ts +16 -8
  243. package/dist/core/runner/tool-progress-lane.js +25 -34
  244. package/dist/core/runner/turn-attachments.d.ts +1 -1
  245. package/dist/core/runner/write-protection-station.d.ts +21 -9
  246. package/dist/core/runner/write-protection-station.js +20 -17
  247. package/dist/core/runner-deps.d.ts +12 -22
  248. package/dist/core/safety-axis-vocab.d.ts +1 -1
  249. package/dist/core/safety-merge-corpus.d.ts +1 -1
  250. package/dist/core/secret-env.d.ts +16 -5
  251. package/dist/core/secret-env.js +23 -63
  252. package/dist/core/sensitive-path-policy.d.ts +19 -18
  253. package/dist/core/sensitive-path-policy.js +73 -49
  254. package/dist/core/session-policy-store.d.ts +6 -3
  255. package/dist/core/session-policy-store.js +28 -10
  256. package/dist/core/session-reconcile.d.ts +3 -0
  257. package/dist/core/session-reconcile.js +5 -4
  258. package/dist/core/session-store.d.ts +5 -0
  259. package/dist/core/session-store.js +12 -0
  260. package/dist/core/session.d.ts +13 -0
  261. package/dist/core/shared-memory/normalize.d.ts +17 -4
  262. package/dist/core/shared-memory/normalize.js +7 -7
  263. package/dist/core/shell-lexer.js +5 -4
  264. package/dist/core/shell-wrapper-table.d.ts +2 -2
  265. package/dist/core/shell-wrapper-table.js +1 -1
  266. package/dist/core/skill-grant.js +1 -1
  267. package/dist/core/store-contracts/checkpoint-store-contract.js +13 -0
  268. package/dist/core/store-contracts/mailbox-store-contract.d.ts +7 -14
  269. package/dist/core/store-contracts/session-store-incarnation-contract.d.ts +27 -0
  270. package/dist/core/store-contracts/session-store-incarnation-contract.js +92 -0
  271. package/dist/core/stub-env.d.ts +2 -0
  272. package/dist/core/stub-env.js +1 -0
  273. package/dist/core/synthetic-read-verdict.js +2 -2
  274. package/dist/core/task-event.d.ts +59 -5
  275. package/dist/core/task-result.d.ts +1 -1
  276. package/dist/core/task-spec.d.ts +42 -9
  277. package/dist/core/terminal-cause.d.ts +94 -11
  278. package/dist/core/tighten-task-spec.d.ts +5 -4
  279. package/dist/core/tighten-task-spec.js +20 -25
  280. package/dist/core/tool-catalog-entries.d.ts +5 -7
  281. package/dist/core/tool-catalog-entries.js +14 -15
  282. package/dist/core/tool-face.d.ts +47 -0
  283. package/dist/core/tool-face.js +5 -0
  284. package/dist/core/tool-model-gate.d.ts +5 -5
  285. package/dist/core/tool-name-aliases.d.ts +35 -10
  286. package/dist/core/tool-name-aliases.js +15 -0
  287. package/dist/core/tool-name-list.d.ts +30 -0
  288. package/dist/core/tool-name-list.js +55 -0
  289. package/dist/core/tool-name-readings.d.ts +1 -9
  290. package/dist/core/tool-name-readings.js +1 -3
  291. package/dist/core/tool-policy.d.ts +195 -85
  292. package/dist/core/tool-policy.js +165 -381
  293. package/dist/core/tool-registry.d.ts +44 -1
  294. package/dist/core/tool-registry.js +26 -0
  295. package/dist/core/tool-roster.d.ts +19 -1
  296. package/dist/core/tool-roster.js +21 -2
  297. package/dist/core/tool-spec-members.d.ts +45 -0
  298. package/dist/core/tool-spec-members.js +169 -0
  299. package/dist/core/tool-spec.d.ts +46 -8
  300. package/dist/core/tools.d.ts +6 -2
  301. package/dist/core/tools.js +8 -4
  302. package/dist/core/untrusted-egress.js +29 -26
  303. package/dist/core/untrusted-text.d.ts +13 -10
  304. package/dist/core/untrusted-text.js +6 -44
  305. package/dist/core/workflow-journal-store.d.ts +4 -1
  306. package/dist/core/write-protect.d.ts +65 -29
  307. package/dist/core/write-protect.js +235 -177
  308. package/dist/engine/compaction/compaction.d.ts +2 -2
  309. package/dist/engine/execution-env/node-execution-env.d.ts +5 -23
  310. package/dist/engine/execution-env/node-execution-env.js +16 -38
  311. package/dist/engine/execution-env/symlink-chain.d.ts +23 -0
  312. package/dist/engine/execution-env/symlink-chain.js +32 -0
  313. package/dist/engine/harness/types.d.ts +7 -0
  314. package/dist/engine/llm/tool-turns.d.ts +3 -0
  315. package/dist/engine/llm/tool-turns.js +1 -0
  316. package/dist/engine/llm/types.d.ts +59 -23
  317. package/dist/engine/loop/agent-loop.js +16 -2
  318. package/dist/engine/session/memory-repo.js +11 -3
  319. package/dist/engine/session/repo-utils.d.ts +8 -0
  320. package/dist/engine/session/repo-utils.js +13 -0
  321. package/dist/index.d.ts +20 -23
  322. package/dist/index.js +17 -20
  323. package/dist/internal/harness.d.ts +1 -1
  324. package/dist/internal/harness.js +1 -1
  325. package/dist/internal/llm.d.ts +2 -2
  326. package/dist/internal/llm.js +1 -1
  327. package/dist/orchestration/governance-baseline-validity.js +1 -1
  328. package/dist/orchestration/run-spec.js +3 -3
  329. package/dist/orchestration/run-workflow-tool.d.ts +16 -35
  330. package/dist/orchestration/run-workflow-tool.js +38 -78
  331. package/dist/orchestration/workflow-governance.d.ts +21 -25
  332. package/dist/orchestration/workflow-governance.js +38 -78
  333. package/dist/orchestration/workflow-primitives.d.ts +7 -22
  334. package/dist/orchestration/workflow-primitives.js +5 -12
  335. package/dist/orchestration/workflow-types.d.ts +1 -1
  336. package/dist/orchestration/workflow.d.ts +61 -11
  337. package/dist/orchestration/workflow.js +191 -119
  338. package/dist/prompt-assembly/types.d.ts +1 -1
  339. package/dist/scenarios/full-body.d.ts +1 -1
  340. package/dist/shell/lex.d.ts +0 -21
  341. package/dist/shell/lex.js +278 -70
  342. package/dist/shell/shell-words.d.ts +35 -0
  343. package/dist/shell/shell-words.js +65 -0
  344. package/dist/stores/file/checkpoint-store.d.ts +5 -5
  345. package/dist/stores/file/checkpoint-store.js +5 -2
  346. package/dist/stores/file/index.d.ts +0 -8
  347. package/dist/stores/file/index.js +0 -12
  348. package/dist/stores/file/session-store.d.ts +3 -0
  349. package/dist/stores/file/session-store.js +44 -19
  350. package/dist/tools/artifact/artifact-tool.js +2 -0
  351. package/dist/tools/fs/bash-program-position.d.ts +17 -3
  352. package/dist/tools/fs/bash-program-position.js +25 -10
  353. package/dist/tools/fs/bash-readonly-classifier.d.ts +1 -1
  354. package/dist/tools/fs/bash-readonly-classifier.js +8 -7
  355. package/dist/tools/fs/containment-face.d.ts +4 -0
  356. package/dist/tools/fs/containment-face.js +3 -0
  357. package/dist/tools/fs/fs-shared.d.ts +10 -0
  358. package/dist/tools/fs/fs-shared.js +18 -0
  359. package/dist/tools/fs/fs-write.js +4 -2
  360. package/dist/tools/fs/index.d.ts +3 -2
  361. package/dist/tools/fs/index.js +2 -2
  362. package/dist/tools/fs/program-read-model.d.ts +99 -23
  363. package/dist/tools/fs/program-read-model.js +129 -55
  364. package/dist/tools/fs/program-read-model.rows.d.ts +0 -14
  365. package/dist/tools/fs/program-read-model.rows.js +18 -10
  366. package/dist/tools/fs/read-deny-home.d.ts +35 -30
  367. package/dist/tools/fs/read-deny-home.js +45 -38
  368. package/dist/tools/fs/read-deny.d.ts +35 -27
  369. package/dist/tools/fs/read-deny.js +126 -92
  370. package/dist/tools/fs/removal-targets.d.ts +56 -23
  371. package/dist/tools/fs/removal-targets.js +74 -87
  372. package/dist/tools/fs/safety.d.ts +29 -22
  373. package/dist/tools/fs/safety.js +17 -11
  374. package/dist/tools/fs/search.js +10 -8
  375. package/dist/tools/fs/shell-read-argv.d.ts +4 -7
  376. package/dist/tools/fs/shell-read-argv.js +6 -8
  377. package/dist/tools/fs/shell-read-bindings.d.ts +203 -46
  378. package/dist/tools/fs/shell-read-bindings.js +488 -144
  379. package/dist/tools/fs/shell-read-builtins.d.ts +35 -0
  380. package/dist/tools/fs/shell-read-builtins.js +43 -0
  381. package/dist/tools/fs/shell-read-check.d.ts +15 -1
  382. package/dist/tools/fs/shell-read-check.js +51 -42
  383. package/dist/tools/fs/shell-read-establish.js +9 -10
  384. package/dist/tools/fs/shell-read-functions.d.ts +22 -0
  385. package/dist/tools/fs/shell-read-functions.js +29 -0
  386. package/dist/tools/fs/shell-read-judge.d.ts +48 -18
  387. package/dist/tools/fs/shell-read-judge.js +33 -4
  388. package/dist/tools/fs/shell-read-plan.d.ts +13 -20
  389. package/dist/tools/fs/shell-read-plan.js +200 -194
  390. package/dist/tools/fs/shell-read-start.d.ts +80 -0
  391. package/dist/tools/fs/shell-read-start.js +99 -0
  392. package/dist/tools/fs/shell-read-word.d.ts +35 -6
  393. package/dist/tools/fs/shell-read-word.js +89 -9
  394. package/dist/tools/fs/shell-read-workdir.d.ts +156 -0
  395. package/dist/tools/fs/shell-read-workdir.js +281 -0
  396. package/dist/tools/fs/shell-read-write-targets.d.ts +5 -2
  397. package/dist/tools/fs/shell-read-write-targets.js +14 -5
  398. package/dist/tools/fs/shell-reentry-text.d.ts +26 -26
  399. package/dist/tools/fs/shell-reentry-text.js +31 -34
  400. package/dist/tools/task-list.d.ts +1 -2
  401. package/dist/tools/web.js +1 -1
  402. package/package.json +4 -1
  403. package/test/export-surface.snapshot.json +107 -143
  404. package/wire-changes/core@7.48.0.json +252 -0
  405. package/wire-changes/core@7.49.0.json +4765 -0
  406. package/dist/agents/teacher.d.ts +0 -159
  407. package/dist/agents/teacher.js +0 -577
  408. package/dist/agents/team.d.ts +0 -226
  409. package/dist/agents/team.js +0 -257
  410. package/dist/core/strategy-store.d.ts +0 -238
  411. package/dist/core/strategy-store.js +0 -253
  412. package/dist/orchestration/builtin-workflows.d.ts +0 -133
  413. package/dist/orchestration/builtin-workflows.js +0 -159
  414. package/dist/scenarios/env.d.ts +0 -40
  415. package/dist/scenarios/env.js +0 -39
  416. package/dist/scenarios/scenario-registry.d.ts +0 -110
  417. package/dist/scenarios/scenario-registry.js +0 -140
  418. package/dist/scenarios/teacher-quickstart.d.ts +0 -40
  419. package/dist/scenarios/teacher-quickstart.js +0 -12
  420. package/dist/stores/cc/lockfile.d.ts +0 -10
  421. package/dist/stores/cc/lockfile.js +0 -98
  422. package/dist/stores/cc/mailbox-store.d.ts +0 -20
  423. package/dist/stores/cc/mailbox-store.js +0 -255
  424. package/dist/stores/cc/roster-adapter.d.ts +0 -12
  425. package/dist/stores/cc/roster-adapter.js +0 -117
  426. package/dist/stores/cc/sidecar-transcript.d.ts +0 -97
  427. package/dist/stores/cc/sidecar-transcript.js +0 -264
  428. package/dist/stores/cc/task-list-store.d.ts +0 -2
  429. package/dist/stores/cc/task-list-store.js +0 -125
  430. package/dist/stores/file/strategy-store.d.ts +0 -97
  431. package/dist/stores/file/strategy-store.js +0 -341
@@ -1,11 +1,10 @@
1
1
  import { MCP_NAMESPACE, protocolOf } from "./protocol-table.js";
2
- import { splitNamespacedName } from "./tool-name-aliases.js";
3
2
  import { catalogRuleFaceOf, isShellFaceToolName, pathTargetOf } from "./tool-registry.js";
4
3
  import { indexOfUnescaped, lastIndexOfUnescaped, parsePermissionRule } from "./permission-rule-syntax.js";
5
4
  import { COMMAND_RULE_TOOL, NAME_RULE_FACES, PATH_RULE_BASE_LABEL, PATH_RULE_FACES, callPathFaceOf, isUsablePathBase, laneToolNamesOf, nameRuleAdmits, nameRuleSubjectOf, parseRuleText, programRunReachOf, ruleBasesNeeded, ruleToolGrammarOf } from "./permission-rule-model.js";
6
5
  import { pathFamilyOf } from "../tools/fs/safety.js";
7
6
  import { callTargetReadingOf, callTargetViewsOf } from "./effective-path-target.js";
8
- import { bindPathRules, pathRowsReach, policyAnchors, rowsWhereTheyLead } from "./path-rule-binding.js";
7
+ import { bindPathRules, judgeRuleRows, policyAnchors, rowsWhereTheyLead } from "./path-rule-binding.js";
9
8
  import { ruleDenialSentence } from "./rule-denial-sentence.js";
10
9
  import { heldValues } from "./tool-name-readings.js";
11
10
  export { parsePermissionRule };
@@ -31,57 +30,8 @@ const DEFAULT_CAPS = {
31
30
  maxStars: 16,
32
31
  maxScalarValueChars: 16_384,
33
32
  };
34
- export function wildcardMatch(pattern, value) {
35
- let p = 0;
36
- let v = 0;
37
- let star = -1;
38
- let mark = 0;
39
- while (v < value.length) {
40
- if (p < pattern.length && pattern[p] === value[v] && pattern[p] !== "*") {
41
- p++;
42
- v++;
43
- }
44
- else if (p < pattern.length && pattern[p] === "*") {
45
- star = p++;
46
- mark = v;
47
- }
48
- else if (star >= 0) {
49
- p = star + 1;
50
- v = ++mark;
51
- }
52
- else {
53
- return false;
54
- }
55
- }
56
- while (p < pattern.length && pattern[p] === "*")
57
- p++;
58
- return p === pattern.length;
59
- }
60
- function parseNamespacedRuleName(name) {
61
- const split = splitNamespacedName(name);
62
- if (split === undefined || split.peer === "")
63
- return undefined;
64
- return split.tool !== undefined ? { protocol: split.ns.id, peer: split.peer, tool: split.tool } : { protocol: split.ns.id, peer: split.peer };
65
- }
66
- export function namespacedRuleNameCovers(ruleName, toolName) {
67
- const rule = parseNamespacedRuleName(ruleName);
68
- if (rule === undefined)
69
- return false;
70
- const target = parseNamespacedRuleName(toolName);
71
- if (target === undefined)
72
- return false;
73
- if (rule.protocol !== target.protocol)
74
- return false;
75
- if (rule.peer !== target.peer)
76
- return false;
77
- if (rule.tool === undefined || rule.tool === "*")
78
- return true;
79
- return target.tool !== undefined && rule.tool.includes("*") && wildcardMatch(rule.tool, target.tool);
80
- }
81
- export function isNamespacedCoveringRuleName(name) {
82
- const parsed = parseNamespacedRuleName(name);
83
- return parsed !== undefined && (parsed.tool === undefined || parsed.tool.includes("*"));
84
- }
33
+ import { isNamespacedCoveringRuleName, namespacedRuleNameCovers, wildcardMatch } from "./namespaced-rule-name.js";
34
+ export { isNamespacedCoveringRuleName, namespacedRuleNameCovers, wildcardMatch };
85
35
  export function catalogRuleFaceView(toolName) {
86
36
  const face = catalogRuleFaceOf(toolName);
87
37
  if (face === undefined)
@@ -395,7 +345,7 @@ export function createPermissionRulePolicy(rules, opts) {
395
345
  if (views !== undefined) {
396
346
  const { of } = boundAt(policyAnchors(pathBases, req.pathRuleAnchors));
397
347
  const rows = rowsWhereTheyLead(pathLane.map((r) => of.get(r)), callTargetReadingOf(req)?.leads ?? NO_LEADS);
398
- const hit = pathRowsReach(rows, views, "tighten");
348
+ const hit = judgeRuleRows(rows, views, "tighten");
399
349
  const rule = hit === undefined ? undefined : pathLane.find((r) => of.get(r).spec === hit.row.spec);
400
350
  if (hit !== undefined && hit.unreadable === undefined)
401
351
  return { rule: rule };
@@ -1,6 +1,4 @@
1
- /** The display bound on a grant candidate's directory: generous next to a real `PATH_MAX`, tight enough
2
- * that the seat cannot become an unbounded prose channel onto an approval card. */
3
- export declare const READ_ROOT_CANDIDATE_DIR_MAX = 1024;
1
+ export { READ_ROOT_CANDIDATE_DIR_MAX } from "./effective-path-target.js";
4
2
  /**
5
3
  * The validator for a probe's {@link import("./tool-spec.js").ReversibilityVerdict.readRootCandidate}: the
6
4
  * errand `normalizeProbeCause` does for the cause, fail-closed on the disclosure alone — a malformed value
@@ -1,24 +1,13 @@
1
1
  import { isPlainRecord, safeDataValue } from "./checkpoint-store.js";
2
- import { hasWin32AliasedComponent, isAbsolutePathForm, normalizeAbsPathLexically, pathFamilyOf, win32NamespaceScreen } from "../tools/fs/safety.js";
3
- export const READ_ROOT_CANDIDATE_DIR_MAX = 1024;
2
+ import { validatePath } from "./effective-path-target.js";
3
+ export { READ_ROOT_CANDIDATE_DIR_MAX } from "./effective-path-target.js";
4
4
  export function normalizeReadRootCandidate(value) {
5
5
  if (!isPlainRecord(value))
6
6
  return undefined;
7
7
  if (safeDataValue(value, "clearsThisAsk") !== true)
8
8
  return undefined;
9
- const dir = safeDataValue(value, "dir");
10
- if (typeof dir !== "string" || dir.length === 0 || dir.length > READ_ROOT_CANDIDATE_DIR_MAX)
11
- return undefined;
12
- if (/[\u0000-\u001f\u007f\u2028\u2029]/.test(dir))
13
- return undefined;
14
- if (!isAbsolutePathForm(dir))
15
- return undefined;
16
- const folded = normalizeAbsPathLexically(dir);
17
- if (folded !== dir || normalizeAbsPathLexically(`${dir}/..`) === dir)
18
- return undefined;
19
- if (hasWin32AliasedComponent(dir))
20
- return undefined;
21
- if (!win32NamespaceScreen(dir, pathFamilyOf({ root: dir })).ok)
9
+ const dir = validatePath(safeDataValue(value, "dir"), { intent: "validate-grant" });
10
+ if (dir === undefined)
22
11
  return undefined;
23
12
  let covers;
24
13
  try {
@@ -8,14 +8,15 @@
8
8
  import type { Checkpoint } from "./checkpoint-store.js";
9
9
  import type { HostDecider } from "./gate-outcome.js";
10
10
  import type { OrgGateVerdict } from "./hooks.js";
11
- import type { AskRequest, PermissionResult, ResolvedAsk } from "./tool-policy.js";
11
+ import type { AskRequest, PermissionResult, ResolverArmResult } from "./tool-policy.js";
12
12
  /** The synchronous seat's refusal of a configuration's allow: one settlement word for both forms
13
13
  * (`blanket_allow_refused`, nobody's — no person decided), a sentence that says which configuration it was. */
14
- export declare function unjudgedAllowRefused(req: AskRequest, by: "blanket" | "policy"): Extract<ResolvedAsk, {
14
+ export declare function unjudgedAllowRefused(req: AskRequest, by: "blanket" | "policy"): Extract<ResolverArmResult, {
15
15
  action: "deny";
16
16
  }>;
17
17
  /** A durable row demands a person when its gate carries the real-approval bit (the gate's own, which every resume
18
- * check reads; the pending action's `requiresRealApproval` is its display twin). */
18
+ * check reads; the pending action's `requiresRealApproval` is its display twin). A plan-pause gate carries no bit, so
19
+ * the same predicate lets the deployment's policy decide a plan pause — and would refuse it the day a gate stamps one. */
19
20
  export declare function rowDemandsAPerson(cp: Checkpoint): boolean;
20
21
  /** A question a decide is held against, in each form a station holds one: the parked row, a policy's re-check of an
21
22
  * approver's edit, the organization's CURRENT verdict about the call, and the request an approver was handed (the card a
@@ -25,3 +25,16 @@ export declare function assertNoRetiredKeys(bag: object, table: Readonly<Record<
25
25
  * (`config.spec_retired_key`), never read as absence: a mode a caller believes it declared must not silently run
26
26
  * as another. */
27
27
  export declare const RETIRED_TASK_SPEC_KEYS: Readonly<Record<string, string>>;
28
+ /** The RETIRED `ToolPolicy` members — a policy still carrying one is refused by name (`config.deps_retired_key`) wherever
29
+ * the engine reads a policy's members: the intake of the caller's policy (prepare, and a resume before its claim), the
30
+ * by-name member reader the wrap and the path-rule installation share, and `combinePolicies`. A member the policy no
31
+ * longer declares is dropped by every one of them, so a guard stated in it would read as stated while guarding nothing. */
32
+ export declare const RETIRED_TOOL_POLICY_KEYS: Readonly<Record<string, string>>;
33
+ /** The RETIRED `ShellReadBoundary` members — a boundary a consumer hands to `judgeShellRead` that still carries one is
34
+ * refused by name (`config.deps_retired_key`); the station reads one write seat, so a retired one would leave every write
35
+ * target unjudged by its rows. (The engine's own station builds its boundaries itself.) */
36
+ export declare const RETIRED_SHELL_READ_BOUNDARY_KEYS: Readonly<Record<string, string>>;
37
+ /** The `ToolPolicy` door ({@link RETIRED_TOOL_POLICY_KEYS}); `undefined` is no policy. */
38
+ export declare function assertNoRetiredToolPolicyKeys(policy: object | undefined): void;
39
+ /** The `ShellReadBoundary` door ({@link RETIRED_SHELL_READ_BOUNDARY_KEYS}). */
40
+ export declare function assertNoRetiredShellReadBoundaryKeys(boundary: object): void;
@@ -30,3 +30,17 @@ export const RETIRED_TASK_SPEC_KEYS = Object.freeze({
30
30
  "attachments.planModeReminder": "the read-only planning posture is stated whenever the leg's mode is `plan` (first turn, every 5 turns, and an exit frame when it ends) — drop the key",
31
31
  "skills[].manifest": "a skill's tools are its `allowedTools` / `disallowedTools` now — an allow-rule and a deny-rule source for the run the skill is activated in, never a fence; move `manifest.allowTools` to `allowedTools`. To fence tools write deny rules (or a delegated agent definition's `allowTools`); to fence write paths use session `allowDirs`",
32
32
  });
33
+ export const RETIRED_TOOL_POLICY_KEYS = Object.freeze({
34
+ writeTargetGuard: "the guarded write targets are stated as rows now — `ToolPolicy.writeGuardRows`, an async provider of the one path table's `PathGuardRow`s the leg's ONE write judgment reads for every writer the policy cannot see as a call (the shell's file commands). A wrapper carries it through `wrapToolPolicy`, which reads every member a policy declares",
35
+ });
36
+ export const RETIRED_SHELL_READ_BOUNDARY_KEYS = Object.freeze({
37
+ writeProtectionJudge: 'the station asks ONE write judgment, `ShellReadBoundary.writeTargetJudge`, over the write-protection table and the deployment\'s guarded write rows together — it answers `"protected"`, `"guarded"` or `undefined`, not a boolean',
38
+ writeTargetGuard: 'the deployment\'s guarded write rows join the same one judgment, `ShellReadBoundary.writeTargetJudge` (`"guarded"` for a target a `ToolPolicy.writeGuardRows` row covers) — the boundary has no second write seat',
39
+ });
40
+ export function assertNoRetiredToolPolicyKeys(policy) {
41
+ if (policy !== undefined)
42
+ assertNoRetiredKeys(policy, RETIRED_TOOL_POLICY_KEYS, "ToolPolicy");
43
+ }
44
+ export function assertNoRetiredShellReadBoundaryKeys(boundary) {
45
+ assertNoRetiredKeys(boundary, RETIRED_SHELL_READ_BOUNDARY_KEYS, "ShellReadBoundary");
46
+ }
@@ -1,6 +1,6 @@
1
1
  import type { ThinkingLevel } from "../internal/harness-types.js";
2
2
  import type { Model } from "../internal/llm.js";
3
- import type { ModelRef, ModelRole, ModelRoles, RoleSpec } from "./types.js";
3
+ import { type ModelRef, type ModelRole, type ModelRoles, type RoleSpec } from "./types.js";
4
4
  export type { ModelRole, RoleSpec, ModelRoles } from "./types.js";
5
5
  export { MODEL_ROLES } from "./types.js";
6
6
  /** Resolve a string ModelRef against the catalog (a Model object passes through). */
@@ -85,10 +85,9 @@ export declare function parseModelMention(text: string, allowedNames: Iterable<s
85
85
  * 各 role 未显式配置时自动落到语义档位——用户/壳只感知档位,roles 降级为内部路由层:
86
86
  * - `default` → `pro`(主力档兜底;用户/部署 roles.default / TaskSpec.model 恒可覆盖);
87
87
  * - `summarize` → `flash`(压缩本该便宜;flash 未绑沿降档链到 lite);
88
- * - `advisor` → 第一档(`ultra` 起,未绑降档到 max/pro——teacher 用最强的);
89
88
  * - `verifier` → `pro`;
90
89
  * - `classifier` → `flash`(design/143 批2b:auto-mode 权限分类腿是便宜档;flash 未绑沿降档链到 lite);
91
- * - `subagent`/`team`/`synthesize` 无档位默认 = 走 FALLBACK 继承主模型(LLM 可经 model 参数自选档);
90
+ * - `subagent` 无档位默认 = 走 FALLBACK 继承主模型(LLM 可经 model 参数自选档);
92
91
  * - `consolidate` 同样无档位默认,但它的 FALLBACK 刻意只有 `summarize` 一站(design/376,见
93
92
  * {@link FALLBACK} 的注):未配即响亮拒,不静默骑主模型。
94
93
  * 未配 tiers 的部署:catalog 无 TIERS_ACTIVE 标记 → 表整体 INERT,行为与从前逐字节一致
@@ -1,4 +1,5 @@
1
1
  import { selectModel } from "./select-model.js";
2
+ import { MODEL_ROLES } from "./types.js";
2
3
  export { MODEL_ROLES } from "./types.js";
3
4
  export function resolveModel(ref, models) {
4
5
  if (typeof ref !== "string") {
@@ -113,7 +114,6 @@ export function parseModelMention(text, allowedNames) {
113
114
  export const ROLE_TIER_DEFAULTS = {
114
115
  default: "pro",
115
116
  summarize: "flash",
116
- advisor: DEFAULT_TIER_ORDER[0],
117
117
  verifier: "pro",
118
118
  classifier: "flash",
119
119
  };
@@ -127,9 +127,6 @@ const FALLBACK = {
127
127
  default: [],
128
128
  summarize: ["default"],
129
129
  subagent: ["default"],
130
- team: ["default"],
131
- synthesize: ["team", "default"],
132
- advisor: ["default"],
133
130
  verifier: ["default"],
134
131
  classifier: ["summarize", "default"],
135
132
  consolidate: ["summarize"],
@@ -175,7 +172,19 @@ function mergeRoleSpec(base, over) {
175
172
  systemPrompt: o.systemPrompt ?? b.systemPrompt,
176
173
  };
177
174
  }
175
+ function assertKnownRole(word, seat) {
176
+ if (typeof word === "string" && MODEL_ROLES.includes(word))
177
+ return;
178
+ const shown = typeof word === "string" ? JSON.stringify(word).slice(0, 80) : `<${word === null ? "null" : typeof word}>`;
179
+ const e = new Error(`${seat} names the model role ${shown}, which is not one of ${MODEL_ROLES.join(" / ")} — a word outside the vocabulary binds nothing and resolves nothing; bind the model on one of these roles, or name it on TaskSpec.model`);
180
+ e.code = "config.unknown_role";
181
+ throw e;
182
+ }
178
183
  function mergeRoles(base, over) {
184
+ for (const key of Object.keys(base ?? {}))
185
+ assertKnownRole(key, "RunnerDeps.roles key");
186
+ for (const key of Object.keys(over ?? {}))
187
+ assertKnownRole(key, "TaskSpec.roles key");
179
188
  const out = { ...base };
180
189
  for (const role of Object.keys(over ?? {})) {
181
190
  out[role] = mergeRoleSpec(base?.[role], over?.[role]);
@@ -192,8 +201,9 @@ function partsModel(parts, models) {
192
201
  return undefined;
193
202
  }
194
203
  export function resolveTaskModel(spec, deps) {
204
+ const start = spec.modelRole ?? "default";
205
+ assertKnownRole(start, "modelRole");
195
206
  if (spec.model) {
196
- const start = spec.modelRole ?? "default";
197
207
  const startParts = specParts(mergeRoles(deps.roles, spec.roles)[start]);
198
208
  return {
199
209
  model: resolveModel(spec.model, deps.models),
@@ -202,7 +212,6 @@ export function resolveTaskModel(spec, deps) {
202
212
  systemPrompt: startParts.systemPrompt,
203
213
  };
204
214
  }
205
- const start = spec.modelRole ?? "default";
206
215
  const merged = mergeRoles(deps.roles, spec.roles);
207
216
  const startSystemPrompt = specParts(merged[start]).systemPrompt;
208
217
  for (const role of [start, ...FALLBACK[start]]) {
@@ -214,13 +214,6 @@ export interface ResultFlags {
214
214
  * somehow set — are gone with the commit-side routing that fed them. */
215
215
  paused?: PausedCause;
216
216
  }
217
- /**
218
- * Extract a machine-readable code from a thrown error (e.g. `SessionError.code`, a Node error code).
219
- * Walks the `cause` chain because the harness wraps lower-level errors (e.g. a `SessionError("conflict")`
220
- * append failure surfaces as an `AgentHarnessError("unknown")` whose cause is the real one) — so we
221
- * prefer the first specific code over a generic `"unknown"` wrapper.
222
- */
223
- export declare function errorCodeOf(err: unknown): string | undefined;
224
217
  /**
225
218
  * WHY the run ended — the ONE terminal arbitration ({@link TerminalCause}). First match wins, in the
226
219
  * slot order documented on {@link assembleResult} (a public contract: do not reorder). Every plane
@@ -1,5 +1,6 @@
1
1
  import { isDegenerateCutMessage } from "../../brain/terminal-cause.js";
2
2
  import { extractErrorCode, isProviderEchoShape, refusedTheRequest, stripErrorCodePrefix } from "../../brain/errors.js";
3
+ import { completedTerminalOf, modelOutputInvalidOfMessage, providerVerdictOf, requestRouteOfMessage, thrownFailureOf } from "./terminal-account.js";
3
4
  import { terminalProjection } from "./terminal-projection.js";
4
5
  import { haltConsumed } from "./halt-attribution.js";
5
6
  import { providerReportedModel } from "../message-utils.js";
@@ -22,21 +23,6 @@ function thrownMessage(threw) {
22
23
  }
23
24
  return describeRejectedValue(threw);
24
25
  }
25
- export function errorCodeOf(err) {
26
- let cur = err;
27
- let fallback;
28
- for (let depth = 0; cur !== null && cur !== undefined && typeof cur === "object" && depth < 8; depth++) {
29
- const code = readMember(cur, "code");
30
- if (typeof code === "string" && code) {
31
- if (code !== "unknown") {
32
- return code;
33
- }
34
- fallback ??= code;
35
- }
36
- cur = readMember(cur, "cause");
37
- }
38
- return fallback;
39
- }
40
26
  function stripThinkTags(text) {
41
27
  let t = text.replace(/<think>[\s\S]*?<\/think>/gi, "");
42
28
  const lower = t.toLowerCase();
@@ -95,15 +81,11 @@ export function terminalCauseOf(final, stats, flags) {
95
81
  terminal = { kind: "failed", code: "suspend.loop", message };
96
82
  }
97
83
  else if (flags.threw) {
98
- const message = thrownMessage(flags.threw);
99
- const code = flags.abortedForTimeout
100
- ? "limits.max_walltime_exceeded"
101
- : flags.abortedForTurns
102
- ? "limits.max_turns_exceeded"
103
- : flags.conflict
104
- ? "conflict"
105
- : errorCodeOf(flags.threw);
106
- terminal = { kind: "failed", ...(code !== undefined ? { code } : {}), message };
84
+ const thrown = thrownFailureOf(flags.threw, thrownMessage(flags.threw));
85
+ const axisCode = flags.abortedForTimeout ? "limits.max_walltime_exceeded" : flags.abortedForTurns ? "limits.max_turns_exceeded" : flags.conflict ? "conflict" : undefined;
86
+ const code = axisCode ?? thrown.code;
87
+ const detail = axisCode === undefined ? thrown.detail : undefined;
88
+ terminal = { kind: "failed", ...(code !== undefined ? { code } : {}), message: thrown.message, ...(detail !== undefined ? { detail } : {}) };
107
89
  }
108
90
  else if (flags.blockedReason) {
109
91
  terminal = { kind: "blocked", reason: flags.blockedReason, ...(flags.blockedDetail !== undefined ? { detail: flags.blockedDetail } : {}) };
@@ -134,7 +116,7 @@ export function terminalCauseOf(final, stats, flags) {
134
116
  ...(typeof apiRequestId === "string" && isProviderEchoShape(apiRequestId) ? { requestId: apiRequestId } : {}),
135
117
  };
136
118
  }
137
- let providerNamed = true;
119
+ let messageNamed = true;
138
120
  const lifted = extractErrorCode(message);
139
121
  if (lifted) {
140
122
  code = lifted;
@@ -142,22 +124,28 @@ export function terminalCauseOf(final, stats, flags) {
142
124
  }
143
125
  else if (flags.gitCoreOverBudget) {
144
126
  code = "irreducible_core_over_budget";
145
- providerNamed = false;
127
+ messageNamed = false;
146
128
  }
147
129
  else if (flags.conflict) {
148
130
  code = "conflict";
149
- providerNamed = false;
131
+ messageNamed = false;
150
132
  }
151
133
  else {
152
134
  code = "provider.error";
153
135
  }
154
- const detail = apiError && providerNamed && typeof apiStatus === "number" && refusedTheRequest(apiStatus)
155
- ? { kind: "provider_rejected", status: apiStatus, ...(typeof apiCode === "string" && isProviderEchoShape(apiCode) ? { code: apiCode } : {}) }
156
- : undefined;
136
+ const outputInvalid = apiError ? undefined : modelOutputInvalidOfMessage(final);
137
+ let detail;
138
+ if (messageNamed && apiError && typeof apiStatus === "number" && refusedTheRequest(apiStatus)) {
139
+ const route = requestRouteOfMessage(final);
140
+ detail = { kind: "provider_rejected", status: apiStatus, ...(typeof apiCode === "string" && isProviderEchoShape(apiCode) ? { code: apiCode } : {}), ...providerVerdictOf(final), ...(route !== undefined ? { route } : {}) };
141
+ }
142
+ else if (messageNamed && outputInvalid !== undefined) {
143
+ detail = { kind: "model_output_invalid", ...outputInvalid };
144
+ }
157
145
  terminal = { kind: "failed", code, message, ...(detail !== undefined ? { detail } : {}) };
158
146
  }
159
147
  else {
160
- terminal = { kind: "completed" };
148
+ terminal = completedTerminalOf(final);
161
149
  }
162
150
  return { terminal, apiFailure };
163
151
  }
@@ -0,0 +1,78 @@
1
+ /**
2
+ * The caller roster's ONE snapshot (#1167). A run's tool roster is the caller's `spec.tools` as it stands when prepare
3
+ * starts reading the request — before its first await — and nothing later, down to each entry's members: the driver
4
+ * rebinds onto a private copy of the spec whose `tools` is an own, fixed data property — a frozen array of frozen entry
5
+ * FACES, each member read once (an omitted roster stays omitted, a value that is no array stays as read), never the
6
+ * caller's accessor or an inherited one. The safety scan, the mount, the listings and every other phase read those faces,
7
+ * so no phase can read the caller's objects a second time after a caller microtask had the chance to change them —
8
+ * not the array (a push, a reassignment of `spec.tools`) and not an entry (a name, an effect or egress mark, a schema,
9
+ * the `execute` function swapped in place, a getter or a Proxy answering differently on a later read).
10
+ *
11
+ * The snapshot holds no live entry. Every object entry (a function included) becomes a face: its own enumerable members
12
+ * (string and symbol keys — what the mount's spread carries) plus every ToolSpec member name read through an ordinary
13
+ * property read (how the phases read a declaration — non-enumerable, inherited or Proxy-answered included), each read once;
14
+ * every declaration value is deep-copied and frozen by the one copier. A primitive is immutable and stays as read. A
15
+ * read that throws refuses the run at the snapshot. Whether the ToolSpec arm can build the entry ({@link specArmCanConstruct})
16
+ * is asked of the entry once, there, and recorded on its face ({@link specArmCanBuild}); the mount refuses an entry it
17
+ * cannot build from that record, so an `execute` that grows on the caller's object later is never read. The mount calls a
18
+ * spec face's `execute` with the caller's own object as `this` ({@link callerEntryOrigin}). A `defineTool` product's face is
19
+ * what every phase reads in its place, and the mount keeps the one authenticated rebind of the product object itself
20
+ * ({@link rebindProductEntry}; the factory's seal refuses a product whose `execute` was replaced or which is not the object
21
+ * it stamped): the factory rebuilds the product from its own members at the mount, and the run is refused when the rebuilt
22
+ * product no longer answers as its face did. The tool a product mounts as is built from that face around the rebound
23
+ * `execute`, never the rebuilt object itself (it shares list members and accessors with the caller's product): the
24
+ * brand is asked once, here at the snapshot, and no object the caller can reach is ever a mounted tool.
25
+ *
26
+ * An array the caller changes after that instant is refused instead of run without the change:
27
+ * {@link refuseLateRosterChanges}, called once at the end of prepare, re-reads the caller's `spec.tools` and refuses
28
+ * the run with the declaration door's code (`config.tool_mount_denied`) naming every entry that is not, in order, the
29
+ * object the snapshot read (a getter that hands back a fresh array of the same objects is not a change). A change to an
30
+ * entry's members is not compared — the run never reads them again. A change after prepare returned is read by nothing.
31
+ */
32
+ import type { AgentTool } from "../../internal/harness.js";
33
+ import type { TaskSpec } from "../types.js";
34
+ import type { ToolSpec } from "../tool-spec.js";
35
+ import { type ToolCtxEnricher } from "../tools.js";
36
+ declare const ROSTER_FACE: unique symbol;
37
+ /** A roster entry as the snapshot minted it. The brand is private to this module and {@link rosterFaceOf} is the only
38
+ * function that returns one, so a phase that takes `RosterFace`s cannot be handed a live caller object: code that tries
39
+ * to put one into the roster does not compile. */
40
+ export type RosterFace = ToolSpec & {
41
+ readonly [ROSTER_FACE]: true;
42
+ };
43
+ /** A task spec whose tool roster is faces — what the driver and every phase that reads the roster hold after the snapshot. */
44
+ export type RosterSpec = Omit<TaskSpec, "tools"> & {
45
+ tools?: RosterFace[];
46
+ };
47
+ /** What the refusal compares: the caller's own spec (re-read, never mutated here) and the objects the snapshot read
48
+ * (`undefined` when the roster was not an array — an omitted roster snapshots as no entries, a non-array value is the
49
+ * doors' to judge and is not compared). */
50
+ export interface CallerRosterSnapshot {
51
+ readonly caller: TaskSpec;
52
+ readonly handed: readonly unknown[] | undefined;
53
+ }
54
+ /** The object a snapshot face was read from (the entry itself when it was held as handed). */
55
+ export declare function callerEntryOrigin(entry: object): object;
56
+ /** Can the mount's ToolSpec arm build this roster entry? Only the verdict recorded at the snapshot answers: an object that
57
+ * is no face of this snapshot, a primitive, a product's face, is not built from. */
58
+ export declare function specArmCanBuild(entry: RosterFace): boolean;
59
+ /** One entry of the roster, and the ONLY place a {@link RosterFace} is minted. Every object entry (a function included) becomes a frozen face, so no entry the snapshot holds is a
60
+ * live object: a primitive is immutable and stays as read; a `defineTool` product's face names the product for its sealed
61
+ * rebind; an entry the ToolSpec arm cannot build gets a face too, and the mount refuses it from the verdict recorded here —
62
+ * an `execute` or a mark that grows on the caller's object afterwards is never read. A read that throws refuses the run. */
63
+ export declare function rosterFaceOf(t: unknown, index: number): RosterFace;
64
+ /** The mount's arm for a roster entry that is the face of a `defineTool` product: the exact product object is rebound to
65
+ * the run's ctx through the factory's sealed seat, compared with its face ({@link refuseProductDrift}), and the tool the
66
+ * run mounts is built from the face around the rebound `execute` ({@link mountedProduct}). `undefined` when the entry is
67
+ * not a product's face (the mount's ToolSpec arm takes it). */
68
+ export declare function rebindProductEntry(entry: object, enrich: ToolCtxEnricher): AgentTool | undefined;
69
+ /** Take the snapshot and rebind onto a private spec copy carrying it. The copy keeps the caller's prototype and every own
70
+ * property descriptor (an inherited or non-enumerable request field reads exactly as it did on the caller's spec); only
71
+ * `tools` becomes the copy's own frozen array of faces when the request carried one. */
72
+ export declare function snapshotCallerRoster(spec: TaskSpec): {
73
+ spec: RosterSpec;
74
+ roster: CallerRosterSnapshot;
75
+ };
76
+ /** Refuse the run when the caller's `spec.tools` no longer holds exactly the objects the snapshot read, in order. */
77
+ export declare function refuseLateRosterChanges(roster: CallerRosterSnapshot): void;
78
+ export {};