@sema-agent/core 7.60.0 → 7.61.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 (482) hide show
  1. package/CHANGELOG.md +605 -0
  2. package/README.md +2 -2
  3. package/dist/agents/agent-transcript-tool.d.ts +2 -2
  4. package/dist/agents/agent-transcript-tool.js +1 -1
  5. package/dist/agents/cascade.d.ts +61 -10
  6. package/dist/agents/cascade.js +60 -20
  7. package/dist/agents/composition-allowance.d.ts +53 -0
  8. package/dist/agents/composition-allowance.js +49 -0
  9. package/dist/agents/composition-placement.d.ts +29 -0
  10. package/dist/agents/composition-placement.js +24 -0
  11. package/dist/agents/cumulative-stats.d.ts +4 -0
  12. package/dist/agents/cumulative-stats.js +3 -0
  13. package/dist/agents/inherited-tool-pool.d.ts +5 -3
  14. package/dist/agents/inherited-tool-pool.js +2 -2
  15. package/dist/agents/list-agents-tool.d.ts +1 -1
  16. package/dist/agents/peer-notice-route.d.ts +1 -1
  17. package/dist/agents/peer-notice-route.js +4 -3
  18. package/dist/agents/peer-notices.d.ts +4 -4
  19. package/dist/agents/peer-notices.js +8 -4
  20. package/dist/agents/peer-session-drain.d.ts +8 -1
  21. package/dist/agents/peer-session-drain.js +36 -7
  22. package/dist/agents/repair-loop.js +16 -6
  23. package/dist/agents/retain-ledger.js +3 -1
  24. package/dist/agents/roster-store.d.ts +1 -1
  25. package/dist/agents/roster-store.js +7 -4
  26. package/dist/agents/send-message-tool.d.ts +8 -10
  27. package/dist/agents/send-message-tool.js +43 -23
  28. package/dist/agents/subagent-completion-gate.d.ts +35 -0
  29. package/dist/agents/subagent-completion-gate.js +62 -0
  30. package/dist/agents/subagent-steps.d.ts +7 -6
  31. package/dist/agents/subagent.d.ts +30 -40
  32. package/dist/agents/subagent.js +187 -196
  33. package/dist/agents/suspend-guard.d.ts +9 -0
  34. package/dist/agents/suspend-guard.js +4 -0
  35. package/dist/agents/verify.d.ts +41 -14
  36. package/dist/agents/verify.js +37 -27
  37. package/dist/brain/anthropic.js +1 -0
  38. package/dist/brain/errors.d.ts +7 -1
  39. package/dist/brain/errors.js +6 -0
  40. package/dist/brain/failover.js +2 -1
  41. package/dist/brain/open-responses.js +1 -0
  42. package/dist/brain/openai.js +1 -0
  43. package/dist/brain/provider-dialect.d.ts +10 -0
  44. package/dist/brain/provider-dialect.js +13 -2
  45. package/dist/brain/stream-engine.d.ts +3 -0
  46. package/dist/brain/stream-engine.js +4 -0
  47. package/dist/core/agent-state.d.ts +1 -1
  48. package/dist/core/allow-entry.d.ts +59 -23
  49. package/dist/core/allow-entry.js +131 -38
  50. package/dist/core/ask-origin.d.ts +79 -0
  51. package/dist/core/ask-origin.js +76 -0
  52. package/dist/core/ask-question.d.ts +19 -13
  53. package/dist/core/ask-question.js +8 -2
  54. package/dist/core/auto-compaction.d.ts +2 -0
  55. package/dist/core/auto-compaction.js +2 -1
  56. package/dist/core/auto-mode.js +3 -5
  57. package/dist/core/background-agent-store.d.ts +7 -5
  58. package/dist/core/background-agent-store.js +12 -11
  59. package/dist/core/checkpoint-requirements.d.ts +24 -3
  60. package/dist/core/checkpoint-requirements.js +9 -1
  61. package/dist/core/checkpoint-store.d.ts +78 -19
  62. package/dist/core/checkpoint-store.js +8 -4
  63. package/dist/core/child-clamp-seats.d.ts +3 -2
  64. package/dist/core/child-clamp-seats.js +4 -3
  65. package/dist/core/closest-name.d.ts +13 -0
  66. package/dist/core/closest-name.js +35 -0
  67. package/dist/core/context-settings.js +3 -5
  68. package/dist/core/cross-boundary-taint.d.ts +1 -1
  69. package/dist/core/decision-receipt.d.ts +14 -1
  70. package/dist/core/decision-receipt.js +6 -3
  71. package/dist/core/delegation-frames.d.ts +13 -9
  72. package/dist/core/effective-path-target.js +2 -3
  73. package/dist/core/engine-attestation.d.ts +11 -1
  74. package/dist/core/engine-attestation.js +2 -0
  75. package/dist/core/engine-notice.d.ts +49 -18
  76. package/dist/core/file-history-retention.d.ts +8 -0
  77. package/dist/core/file-history-retention.js +14 -11
  78. package/dist/core/file-history-store.d.ts +31 -1
  79. package/dist/core/file-history-store.js +31 -2
  80. package/dist/core/frame-settlement.d.ts +10 -0
  81. package/dist/core/frame-settlement.js +6 -1
  82. package/dist/core/fs-write-gate-policy.d.ts +3 -3
  83. package/dist/core/fs-write-gate-policy.js +8 -7
  84. package/dist/core/gate-fold.js +2 -1
  85. package/dist/core/gate-lanes.js +7 -4
  86. package/dist/core/gate-outcome.d.ts +40 -1
  87. package/dist/core/gate-outcome.js +10 -0
  88. package/dist/core/git-worktree-env.d.ts +7 -3
  89. package/dist/core/git-worktree-env.js +16 -13
  90. package/dist/core/governance-codes.d.ts +12 -4
  91. package/dist/core/governance-codes.js +16 -4
  92. package/dist/core/hooks.d.ts +12 -4
  93. package/dist/core/hooks.js +11 -4
  94. package/dist/core/host-floor.js +3 -5
  95. package/dist/core/image-admission.d.ts +48 -8
  96. package/dist/core/image-admission.js +35 -4
  97. package/dist/core/input-author.d.ts +36 -0
  98. package/dist/core/input-author.js +39 -0
  99. package/dist/core/leg-identity.d.ts +62 -0
  100. package/dist/core/leg-identity.js +18 -0
  101. package/dist/core/locked-config.d.ts +2 -1
  102. package/dist/core/locked-config.js +5 -3
  103. package/dist/core/lsp.d.ts +5 -3
  104. package/dist/core/lsp.js +3 -2
  105. package/dist/core/mailbox-store.d.ts +85 -10
  106. package/dist/core/mailbox-store.js +31 -10
  107. package/dist/core/mcp-connection-pool.d.ts +6 -20
  108. package/dist/core/mcp-connection-pool.js +10 -28
  109. package/dist/core/mcp-failure.d.ts +76 -15
  110. package/dist/core/mcp-failure.js +60 -33
  111. package/dist/core/mcp-host-seat.d.ts +92 -53
  112. package/dist/core/mcp-host-seat.js +220 -46
  113. package/dist/core/mcp-probe.js +2 -2
  114. package/dist/core/mcp-server-link.d.ts +18 -6
  115. package/dist/core/mcp-server-link.js +19 -4
  116. package/dist/core/mcp-server-spec.d.ts +2 -1
  117. package/dist/core/mcp-session-end.d.ts +1 -2
  118. package/dist/core/mcp-session-end.js +1 -1
  119. package/dist/core/mcp.d.ts +6 -49
  120. package/dist/core/mcp.js +115 -111
  121. package/dist/core/media-byte-cap.d.ts +21 -46
  122. package/dist/core/media-byte-cap.js +55 -55
  123. package/dist/core/member-group.d.ts +7 -0
  124. package/dist/core/member-group.js +35 -0
  125. package/dist/core/memory-engine/consolidation.d.ts +1 -1
  126. package/dist/core/memory-engine/consolidation.js +7 -1
  127. package/dist/core/memory-engine/dual-root.d.ts +31 -0
  128. package/dist/core/memory-engine/dual-root.js +59 -11
  129. package/dist/core/memory-engine/engine.js +27 -24
  130. package/dist/core/memory-engine/file-backend.d.ts +13 -0
  131. package/dist/core/memory-engine/file-backend.js +35 -15
  132. package/dist/core/memory-engine/layout.d.ts +3 -0
  133. package/dist/core/memory-engine/layout.js +13 -3
  134. package/dist/core/memory-engine/memory-deployment.d.ts +110 -0
  135. package/dist/core/memory-engine/memory-deployment.js +182 -0
  136. package/dist/core/memory-engine/sync-client.d.ts +39 -18
  137. package/dist/core/memory-engine/sync-client.js +72 -14
  138. package/dist/core/memory-engine/sync-report.d.ts +7 -4
  139. package/dist/core/memory-engine/sync.d.ts +9 -1
  140. package/dist/core/mode-policy.d.ts +8 -8
  141. package/dist/core/mode-policy.js +7 -5
  142. package/dist/core/mods/agent-stations.d.ts +39 -4
  143. package/dist/core/mods/agent-stations.js +59 -10
  144. package/dist/core/mods/dollar.d.ts +62 -0
  145. package/dist/core/mods/extension-call.d.ts +15 -1
  146. package/dist/core/mods/extension-call.js +7 -2
  147. package/dist/core/mods/kernel/dispatch.d.ts +4 -3
  148. package/dist/core/mods/kernel/dispatch.js +4 -4
  149. package/dist/core/mods/kernel/events.d.ts +4 -1
  150. package/dist/core/mods/kernel/events.js +6 -6
  151. package/dist/core/mods/kernel/registration.d.ts +3 -0
  152. package/dist/core/mods/kernel/registration.js +5 -0
  153. package/dist/core/mods/kernel/site-rules.d.ts +6 -3
  154. package/dist/core/mods/kernel/site-rules.js +10 -2
  155. package/dist/core/mods/session-append.d.ts +115 -0
  156. package/dist/core/mods/session-append.js +311 -0
  157. package/dist/core/mods/session-compact.d.ts +48 -0
  158. package/dist/core/mods/session-compact.js +194 -0
  159. package/dist/core/mods/session-receive.d.ts +93 -0
  160. package/dist/core/mods/session-receive.js +141 -0
  161. package/dist/core/mods/session-send.d.ts +72 -0
  162. package/dist/core/mods/session-send.js +88 -0
  163. package/dist/core/mods/stations.d.ts +38 -16
  164. package/dist/core/mods/stations.js +25 -11
  165. package/dist/core/mods/tool-call.d.ts +2 -0
  166. package/dist/core/mods/tool-call.js +4 -4
  167. package/dist/core/output-style.js +3 -4
  168. package/dist/core/own-property-receipt.d.ts +61 -2
  169. package/dist/core/own-property-receipt.js +42 -2
  170. package/dist/core/park-selfcheck.js +4 -2
  171. package/dist/core/path-identity.d.ts +11 -0
  172. package/dist/core/path-identity.js +4 -0
  173. package/dist/core/path-rule-binding.d.ts +3 -1
  174. package/dist/core/path-rule-binding.js +3 -1
  175. package/dist/core/peer-seat.d.ts +3 -3
  176. package/dist/core/peer-seat.js +20 -8
  177. package/dist/core/permission-rule-consent.d.ts +21 -5
  178. package/dist/core/permission-rule-consent.js +21 -1
  179. package/dist/core/permission-rule-model.d.ts +34 -11
  180. package/dist/core/permission-rule-model.js +47 -10
  181. package/dist/core/permission-rule-org.d.ts +1 -1
  182. package/dist/core/permission-rule-provider.js +4 -1
  183. package/dist/core/permission-rules.d.ts +4 -0
  184. package/dist/core/permission-rules.js +11 -16
  185. package/dist/core/remote-env.d.ts +74 -26
  186. package/dist/core/remote-env.js +20 -0
  187. package/dist/core/retention-policy.d.ts +24 -23
  188. package/dist/core/retention-policy.js +36 -2
  189. package/dist/core/retention.d.ts +4 -1
  190. package/dist/core/retired-keys.d.ts +4 -4
  191. package/dist/core/row-admission.d.ts +10 -0
  192. package/dist/core/row-admission.js +5 -0
  193. package/dist/core/runner/advisor-instructions.d.ts +2 -1
  194. package/dist/core/runner/advisor-instructions.js +2 -1
  195. package/dist/core/runner/announce-once-ledger.d.ts +4 -4
  196. package/dist/core/runner/assemble-result.d.ts +13 -3
  197. package/dist/core/runner/assemble-result.js +12 -7
  198. package/dist/core/runner/caller-roster.d.ts +12 -9
  199. package/dist/core/runner/caller-roster.js +5 -2
  200. package/dist/core/runner/checkpoint-scope.d.ts +16 -1
  201. package/dist/core/runner/checkpoint-scope.js +21 -0
  202. package/dist/core/runner/compact-session.js +14 -2
  203. package/dist/core/runner/compaction-call-options.d.ts +1 -1
  204. package/dist/core/runner/compaction-restate.d.ts +2 -2
  205. package/dist/core/runner/compaction-restate.js +4 -3
  206. package/dist/core/runner/construction-doors.d.ts +2 -2
  207. package/dist/core/runner/construction-doors.js +2 -2
  208. package/dist/core/runner/contracts.d.ts +98 -26
  209. package/dist/core/runner/cross-boundary-lane.d.ts +1 -1
  210. package/dist/core/runner/decide-continuation.d.ts +4 -2
  211. package/dist/core/runner/decide-continuation.js +7 -4
  212. package/dist/core/runner/denial-limit-arms.d.ts +15 -21
  213. package/dist/core/runner/denial-limit-arms.js +17 -10
  214. package/dist/core/runner/expire-settle.d.ts +44 -0
  215. package/dist/core/runner/expire-settle.js +55 -0
  216. package/dist/core/runner/git-status-frame.d.ts +3 -3
  217. package/dist/core/runner/git-status-frame.js +2 -1
  218. package/dist/core/runner/halt-attribution.d.ts +2 -1
  219. package/dist/core/runner/halt-attribution.js +2 -1
  220. package/dist/core/runner/local-claims.d.ts +17 -0
  221. package/dist/core/runner/local-claims.js +18 -0
  222. package/dist/core/runner/media-removed-seat.d.ts +46 -0
  223. package/dist/core/runner/media-removed-seat.js +88 -0
  224. package/dist/core/runner/park-commit.d.ts +2 -2
  225. package/dist/core/runner/permission-rule-lanes.d.ts +5 -1
  226. package/dist/core/runner/permission-rule-lanes.js +28 -9
  227. package/dist/core/runner/person-path-rows.js +1 -1
  228. package/dist/core/runner/placement-fence.d.ts +26 -0
  229. package/dist/core/runner/placement-fence.js +38 -0
  230. package/dist/core/runner/prepare-ask-lane.d.ts +6 -12
  231. package/dist/core/runner/prepare-ask-lane.js +4 -4
  232. package/dist/core/runner/prepare-boundary-parks.d.ts +4 -1
  233. package/dist/core/runner/prepare-boundary-parks.js +2 -2
  234. package/dist/core/runner/prepare-caps-and-workflow.d.ts +2 -0
  235. package/dist/core/runner/prepare-caps-and-workflow.js +1 -0
  236. package/dist/core/runner/prepare-config-doors.js +16 -17
  237. package/dist/core/runner/prepare-context-lane.d.ts +6 -2
  238. package/dist/core/runner/prepare-context-lane.js +13 -13
  239. package/dist/core/runner/prepare-delegation-surface.d.ts +9 -9
  240. package/dist/core/runner/prepare-delegation-surface.js +4 -5
  241. package/dist/core/runner/prepare-execution-env.d.ts +5 -2
  242. package/dist/core/runner/prepare-execution-env.js +7 -4
  243. package/dist/core/runner/prepare-gate-stations.d.ts +19 -14
  244. package/dist/core/runner/prepare-gate-stations.js +6 -4
  245. package/dist/core/runner/prepare-hands-readface.d.ts +5 -5
  246. package/dist/core/runner/prepare-hands-readface.js +4 -4
  247. package/dist/core/runner/prepare-inherited-gate.d.ts +6 -0
  248. package/dist/core/runner/prepare-inherited-gate.js +3 -0
  249. package/dist/core/runner/prepare-lsp.d.ts +3 -0
  250. package/dist/core/runner/prepare-lsp.js +2 -2
  251. package/dist/core/runner/prepare-park-ask.d.ts +5 -2
  252. package/dist/core/runner/prepare-park-ask.js +4 -5
  253. package/dist/core/runner/prepare-policy-chain.d.ts +10 -21
  254. package/dist/core/runner/prepare-policy-chain.js +16 -25
  255. package/dist/core/runner/prepare-project-context.d.ts +2 -2
  256. package/dist/core/runner/prepare-prompt-inputs.d.ts +5 -4
  257. package/dist/core/runner/prepare-prompt-inputs.js +3 -2
  258. package/dist/core/runner/prepare-question-face.d.ts +6 -4
  259. package/dist/core/runner/prepare-question-face.js +2 -2
  260. package/dist/core/runner/prepare-run-refs.d.ts +3 -0
  261. package/dist/core/runner/prepare-run-refs.js +2 -2
  262. package/dist/core/runner/prepare-suspend-saga.d.ts +11 -7
  263. package/dist/core/runner/prepare-suspend-saga.js +17 -7
  264. package/dist/core/runner/prepare-task.d.ts +1 -1
  265. package/dist/core/runner/prepare-task.js +56 -28
  266. package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +6 -0
  267. package/dist/core/runner/prepare-tool-disclosure-mount.js +3 -1
  268. package/dist/core/runner/prepare-wiring-manifest.d.ts +3 -0
  269. package/dist/core/runner/prepare-wiring-manifest.js +2 -1
  270. package/dist/core/runner/prepare-workspace-restore.d.ts +5 -0
  271. package/dist/core/runner/prepare-workspace-restore.js +10 -6
  272. package/dist/core/runner/read-root-grant.d.ts +1 -1
  273. package/dist/core/runner/read-root-grant.js +2 -1
  274. package/dist/core/runner/resume-admission.d.ts +5 -3
  275. package/dist/core/runner/resume-admission.js +17 -3
  276. package/dist/core/runner/resume-apply.js +3 -1
  277. package/dist/core/runner/resume-claim.d.ts +8 -3
  278. package/dist/core/runner/resume-claim.js +28 -12
  279. package/dist/core/runner/resume-internals-and-config.d.ts +2 -2
  280. package/dist/core/runner/resume-internals-and-config.js +10 -1
  281. package/dist/core/runner/resume-preflight.d.ts +3 -2
  282. package/dist/core/runner/resume-preflight.js +13 -26
  283. package/dist/core/runner/retired-runner-deps.js +2 -0
  284. package/dist/core/runner/run-git-lane.js +2 -1
  285. package/dist/core/runner/run-harness-handlers.js +2 -2
  286. package/dist/core/runner/run-identity-wiring.d.ts +2 -2
  287. package/dist/core/runner/run-identity-wiring.js +14 -5
  288. package/dist/core/runner/run-leg.d.ts +3 -3
  289. package/dist/core/runner/run-leg.js +40 -29
  290. package/dist/core/runner/run-notification-lane.js +20 -2
  291. package/dist/core/runner/run-recovery-lanes.js +3 -2
  292. package/dist/core/runner/run-settle-and-teardown.js +9 -7
  293. package/dist/core/runner/run-telemetry-and-budget-seats.d.ts +1 -1
  294. package/dist/core/runner/run-terminal-adoption.d.ts +1 -1
  295. package/dist/core/runner/run-terminal-adoption.js +26 -17
  296. package/dist/core/runner/run-turn-boundary.js +27 -14
  297. package/dist/core/runner/runtask.d.ts +18 -3
  298. package/dist/core/runner/runtask.js +27 -11
  299. package/dist/core/runner/session-rule-policy.d.ts +1 -1
  300. package/dist/core/runner/session-rule-policy.js +6 -1
  301. package/dist/core/runner/shell-env-withheld.d.ts +1 -1
  302. package/dist/core/runner/stream-halt-verbs.d.ts +1 -14
  303. package/dist/core/runner/stream-halt-verbs.js +4 -3
  304. package/dist/core/runner/stream-reap.d.ts +7 -6
  305. package/dist/core/runner/stream-reap.js +13 -16
  306. package/dist/core/runner/stream-settle-backstop.d.ts +3 -2
  307. package/dist/core/runner/stream-settle-backstop.js +5 -3
  308. package/dist/core/runner/stream-steer-verb.d.ts +5 -2
  309. package/dist/core/runner/stream-steer-verb.js +8 -7
  310. package/dist/core/runner/terminal-account.d.ts +11 -1
  311. package/dist/core/runner/terminal-account.js +20 -0
  312. package/dist/core/runner/terminal-projection.d.ts +8 -2
  313. package/dist/core/runner/terminal-projection.js +2 -2
  314. package/dist/core/runner/tool-disclosure.d.ts +3 -0
  315. package/dist/core/runner/tool-disclosure.js +5 -2
  316. package/dist/core/runner/tool-end-body.d.ts +3 -3
  317. package/dist/core/runner/tool-end-body.js +1 -1
  318. package/dist/core/runner/tool-output-projection.d.ts +3 -3
  319. package/dist/core/runner/tool-output-projection.js +7 -6
  320. package/dist/core/runner/tool-table-view.d.ts +56 -0
  321. package/dist/core/runner/tool-table-view.js +51 -0
  322. package/dist/core/runner/turn-attachments.d.ts +3 -2
  323. package/dist/core/runner/turn-attachments.js +1 -1
  324. package/dist/core/runner/void-verifier-pause.d.ts +33 -0
  325. package/dist/core/runner/void-verifier-pause.js +41 -0
  326. package/dist/core/runner-deps.d.ts +24 -25
  327. package/dist/core/secret-env.d.ts +11 -11
  328. package/dist/core/secret-env.js +8 -9
  329. package/dist/core/session-log-transfer.js +9 -10
  330. package/dist/core/session-policy-store.d.ts +1 -1
  331. package/dist/core/session-policy-store.js +5 -2
  332. package/dist/core/session-reconcile.d.ts +3 -2
  333. package/dist/core/session-reconcile.js +7 -4
  334. package/dist/core/session-store.d.ts +2 -0
  335. package/dist/core/session-store.js +5 -7
  336. package/dist/core/session.d.ts +2 -1
  337. package/dist/core/shell-confinement.d.ts +37 -0
  338. package/dist/core/shell-confinement.js +56 -0
  339. package/dist/core/skill-grant.js +1 -1
  340. package/dist/core/store-contracts/checkpoint-store-contract.d.ts +2 -2
  341. package/dist/core/store-contracts/checkpoint-store-contract.js +15 -2
  342. package/dist/core/store-contracts/file-history-store-contract.d.ts +5 -2
  343. package/dist/core/store-contracts/file-history-store-contract.js +25 -1
  344. package/dist/core/store-contracts/mailbox-store-contract.d.ts +12 -5
  345. package/dist/core/store-contracts/mailbox-store-contract.js +156 -9
  346. package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
  347. package/dist/core/store-contracts/tool-result-store-contract.js +30 -0
  348. package/dist/core/task-event.d.ts +17 -8
  349. package/dist/core/task-limits.d.ts +5 -0
  350. package/dist/core/task-notification.d.ts +89 -12
  351. package/dist/core/task-notification.js +87 -13
  352. package/dist/core/task-registry-agent.d.ts +5 -43
  353. package/dist/core/task-registry-agent.js +24 -51
  354. package/dist/core/task-registry-monitor.d.ts +1 -1
  355. package/dist/core/task-registry-monitor.js +15 -60
  356. package/dist/core/task-registry-shared.d.ts +15 -112
  357. package/dist/core/task-registry-shared.js +3 -41
  358. package/dist/core/task-registry-workflow.js +4 -21
  359. package/dist/core/task-registry.d.ts +19 -60
  360. package/dist/core/task-registry.js +19 -106
  361. package/dist/core/task-result.d.ts +24 -7
  362. package/dist/core/task-spec-members.d.ts +39 -0
  363. package/dist/core/task-spec-members.js +92 -0
  364. package/dist/core/task-spec.d.ts +10 -10
  365. package/dist/core/task-tool-shape.d.ts +7 -57
  366. package/dist/core/task-tool-shape.js +7 -66
  367. package/dist/core/terminal-cause.d.ts +30 -0
  368. package/dist/core/terminal-cause.js +1 -0
  369. package/dist/core/tool-catalog-entries.js +2 -5
  370. package/dist/core/tool-check-reading.js +16 -10
  371. package/dist/core/tool-conformance.js +1 -2
  372. package/dist/core/tool-errors.d.ts +6 -3
  373. package/dist/core/tool-errors.js +2 -0
  374. package/dist/core/tool-face-reader.js +3 -2
  375. package/dist/core/tool-face.d.ts +2 -3
  376. package/dist/core/tool-name-aliases.d.ts +5 -29
  377. package/dist/core/tool-name-aliases.js +9 -5
  378. package/dist/core/tool-name-readings.d.ts +14 -3
  379. package/dist/core/tool-name-readings.js +2 -0
  380. package/dist/core/tool-policy.d.ts +108 -18
  381. package/dist/core/tool-policy.js +84 -14
  382. package/dist/core/tool-result-store.d.ts +23 -0
  383. package/dist/core/tool-result-store.js +3 -2
  384. package/dist/core/tool-spec.d.ts +19 -6
  385. package/dist/core/trace.d.ts +18 -1
  386. package/dist/core/user-attachment.js +26 -21
  387. package/dist/core/workflow-journal-store.d.ts +1 -1
  388. package/dist/core/workflow-run-store.d.ts +2 -0
  389. package/dist/core/workflow-run-store.js +6 -5
  390. package/dist/core/workflow-settled-run.d.ts +5 -0
  391. package/dist/core/workflow-settled-run.js +7 -0
  392. package/dist/engine/execution-env/node-execution-env.d.ts +34 -9
  393. package/dist/engine/execution-env/node-execution-env.js +213 -21
  394. package/dist/engine/harness/agent-harness.d.ts +65 -18
  395. package/dist/engine/harness/agent-harness.js +90 -23
  396. package/dist/engine/harness/messages.d.ts +4 -3
  397. package/dist/engine/harness/messages.js +2 -2
  398. package/dist/engine/harness/types.d.ts +41 -7
  399. package/dist/engine/llm/media-removed.d.ts +14 -0
  400. package/dist/engine/llm/media-removed.js +9 -0
  401. package/dist/engine/llm/rejected-images.d.ts +35 -25
  402. package/dist/engine/llm/rejected-images.js +59 -10
  403. package/dist/engine/llm/types.d.ts +24 -3
  404. package/dist/engine/llm/types.js +7 -3
  405. package/dist/engine/loop/agent-loop.d.ts +6 -1
  406. package/dist/engine/loop/agent-loop.js +20 -11
  407. package/dist/engine/loop/types.d.ts +12 -3
  408. package/dist/engine/session/import-validate.js +7 -0
  409. package/dist/fixtures/index.d.ts +7 -5
  410. package/dist/fixtures/index.js +5 -3
  411. package/dist/index.d.ts +21 -11
  412. package/dist/index.js +15 -7
  413. package/dist/internal/harness-types.d.ts +2 -0
  414. package/dist/internal/llm.d.ts +2 -1
  415. package/dist/internal/llm.js +1 -0
  416. package/dist/orchestration/goal.d.ts +6 -2
  417. package/dist/orchestration/goal.js +6 -3
  418. package/dist/orchestration/run-workflow-tool.d.ts +11 -17
  419. package/dist/orchestration/run-workflow-tool.js +19 -42
  420. package/dist/orchestration/workflow-governance.d.ts +1 -1
  421. package/dist/orchestration/workflow-types.d.ts +2 -2
  422. package/dist/orchestration/workflow.d.ts +4 -0
  423. package/dist/orchestration/workflow.js +8 -5
  424. package/dist/stores/file/background-agent-store.js +18 -15
  425. package/dist/stores/file/checkpoint-store.js +7 -4
  426. package/dist/stores/file/file-history-store.js +3 -2
  427. package/dist/stores/file/index.d.ts +5 -3
  428. package/dist/stores/file/index.js +23 -8
  429. package/dist/stores/file/ledger-tuning.d.ts +23 -0
  430. package/dist/stores/file/ledger-tuning.js +21 -0
  431. package/dist/stores/file/mailbox-store.js +42 -22
  432. package/dist/stores/file/memory-store.js +3 -2
  433. package/dist/stores/file/permission-rule-adopt.js +24 -21
  434. package/dist/stores/file/permission-rule-store.js +6 -3
  435. package/dist/stores/file/session-policy-store.js +3 -2
  436. package/dist/stores/file/session-store.d.ts +16 -3
  437. package/dist/stores/file/session-store.js +21 -20
  438. package/dist/stores/file/tool-result-store.d.ts +11 -0
  439. package/dist/stores/file/tool-result-store.js +57 -3
  440. package/dist/stores/file/usage-window-store.js +3 -2
  441. package/dist/stores/file/workflow-journal-store.d.ts +0 -2
  442. package/dist/stores/file/workflow-journal-store.js +3 -18
  443. package/dist/stores/file/workflow-run-store.d.ts +1 -1
  444. package/dist/stores/file/workflow-run-store.js +15 -10
  445. package/dist/tools/fs/dead-cwd.d.ts +5 -5
  446. package/dist/tools/fs/dead-cwd.js +4 -11
  447. package/dist/tools/fs/fs-bash-background-text.d.ts +6 -0
  448. package/dist/tools/fs/fs-bash-background-text.js +6 -0
  449. package/dist/tools/fs/fs-bash.d.ts +3 -18
  450. package/dist/tools/fs/fs-bash.js +37 -124
  451. package/dist/tools/fs/fs-pdf.js +8 -6
  452. package/dist/tools/fs/fs-read.js +2 -2
  453. package/dist/tools/fs/fs-shared.d.ts +28 -3
  454. package/dist/tools/fs/fs-shared.js +15 -0
  455. package/dist/tools/fs/index.d.ts +1 -1
  456. package/dist/tools/fs/index.js +4 -14
  457. package/dist/tools/fs/pdf.d.ts +4 -4
  458. package/dist/tools/fs/pdf.js +6 -6
  459. package/dist/tools/fs/read-deny-home.js +8 -1
  460. package/dist/tools/fs/read-deny.d.ts +26 -2
  461. package/dist/tools/fs/read-deny.js +9 -2
  462. package/dist/tools/fs/read-floor.d.ts +13 -5
  463. package/dist/tools/fs/read-floor.js +206 -2
  464. package/dist/tools/fs/search.d.ts +3 -2
  465. package/dist/tools/fs/search.js +6 -6
  466. package/dist/tools/fs/shell-read-establish.js +3 -1
  467. package/dist/tools/fs/shell-read-identity.d.ts +3 -1
  468. package/dist/tools/fs/shell-read-identity.js +4 -2
  469. package/dist/tools/fs/shell-read-judge.d.ts +7 -1
  470. package/dist/tools/fs/shell-read-judge.js +1 -1
  471. package/dist/tools/monitor.d.ts +8 -7
  472. package/dist/tools/monitor.js +12 -10
  473. package/dist/tools/worktree.d.ts +5 -1
  474. package/dist/tools/worktree.js +20 -17
  475. package/package.json +6 -3
  476. package/test/export-surface.snapshot.json +92 -10
  477. package/wire-changes/core-stores-sql@7.61.0.json +480 -0
  478. package/wire-changes/core@7.61.0.json +4405 -0
  479. package/wire-changes/mods-kernel@7.61.0.json +65 -0
  480. package/wire-changes/primitives@7.61.0.json +30 -0
  481. package/dist/core/runner/image-removed-seat.d.ts +0 -12
  482. package/dist/core/runner/image-removed-seat.js +0 -19
@@ -32,6 +32,11 @@ export declare function isDurablePause(terminal: TerminalCause): terminal is Pau
32
32
  export type PausedResult = TaskResult & {
33
33
  terminal: PausedCause;
34
34
  };
35
+ /** A resumed leg that ended before its approved action started — read off the row's outcome the leg states
36
+ * (`failed.unstartedRow`), never off its code (that still names what ended the leg) or its sentence. Its checkpoint is
37
+ * pending again, or the store declined, or its state is unprovable: in none of them was the approved work done, so an
38
+ * orchestrator stops there as at a durable pause — no re-run, no escalation, no session release. */
39
+ export declare function resumeNeverStarted(result: TaskResult): boolean;
35
40
  /**
36
41
  * Which family a pause belongs to — its gate kind's registry row: `"suspended"` (an approval gate, a
37
42
  * resource slice, a platform park) or `"needs_review"` (a dry-run or plan review). The same row the
@@ -42,5 +47,9 @@ export declare function pauseFamily(t: PausedCause): "suspended" | "needs_review
42
47
  * If `result` durably paused, return it mapped to a `failed` result whose terminal carries the pause on
43
48
  * `nestedPause`; otherwise return it unchanged. The orchestrator should also **stop** (not escalate/re-run)
44
49
  * and **not release** the session when this maps a pause — the checkpoint still references that session.
50
+ *
51
+ * The mapped result keeps the parked leg's `sessionId` — the parked row's own `Checkpoint.sessionId`. A composition's legs do
52
+ * not run in the caller's session, so a host links the row to its run by the row's `CheckpointState.compositionLeg`, never by
53
+ * assuming the row sits in the session it submitted.
45
54
  */
46
55
  export declare function mapNestedSuspend(result: TaskResult): TaskResult;
@@ -4,6 +4,10 @@ export const UNEXPECTED_NEEDS_REVIEW = "unexpected.needs_review";
4
4
  export function isDurablePause(terminal) {
5
5
  return terminal.kind === "paused";
6
6
  }
7
+ export function resumeNeverStarted(result) {
8
+ const t = result.terminal;
9
+ return t.kind === "failed" && t.unstartedRow !== undefined;
10
+ }
7
11
  export function pauseFamily(t) {
8
12
  return PAUSE_REGISTRY[t.gate.kind].taskStatus;
9
13
  }
@@ -2,6 +2,7 @@ import { Type, type Static } from "typebox";
2
2
  import type { ResumeTaskConfig, RunInternals, RunnerSelfSeat } from "../core/runner/contracts.js";
3
3
  import type { CheckpointGate, CheckpointToken, ResumeOutcome } from "../core/checkpoint-store.js";
4
4
  import type { ModelRef, TaskResult, TaskSpec, TaskStatus, ToolSpec } from "../core/types.js";
5
+ import { type AllowanceExhausted } from "./composition-allowance.js";
5
6
  /**
6
7
  * Verification gate (developer mode, design/28 §4). An **independent falsification-style verifier** runs after
7
8
  * an implementation task and tries to BREAK it — read-only, evidence-required, returning a structured
@@ -118,9 +119,10 @@ export interface VerifyConfig {
118
119
  /**
119
120
  * HRD-AGO-3 — fired when the VERIFIER's own run durably paused (`suspended`/`needs_review`), carrying the
120
121
  * resume capability for the checkpoint it minted. The pause is ALWAYS reported on
121
- * {@link VerificationOutcome.verifierPause} as well; this callback exists so a deployment that owns the
122
- * checkpoint lifecycle can act at once (decide it, or cancel + release the pinned verifier session) instead
123
- * of waiting for the reaper. A throwing handler cannot strand the gate (it is swallowed, like `onRound`).
122
+ * {@link VerificationOutcome.verifierPause} as well — this callback hands the same members, plus the iteration number; it
123
+ * exists so a deployment that owns the checkpoint lifecycle can act at once instead of waiting for the reaper:
124
+ * decide the card (`runner.resume` with the token), or void it with `Runner.voidVerifierPause(token)`, which
125
+ * expires the card and unpins the verifier session. A throwing handler cannot strand the gate (it is swallowed, like `onRound`).
124
126
  *
125
127
  * ⚠️ `checkpointToken` is the resume CAPABILITY — never log it or put it in a URL (types.ts §6).
126
128
  */
@@ -130,6 +132,7 @@ export interface VerifyConfig {
130
132
  sessionId: string;
131
133
  checkpointToken?: CheckpointToken;
132
134
  checkpointGate?: CheckpointGate;
135
+ checkpointId?: string;
133
136
  }) => void;
134
137
  }
135
138
  /**
@@ -147,8 +150,8 @@ export interface VerifyConfig {
147
150
  * - `"opted_out"` — verification was explicitly disabled (`runDeveloperTask({ verify: false })`); not gated by design.
148
151
  * - `"verifier_paused"` (HRD-AGO-3) — the VERIFIER's own run durably paused (suspended/needs_review) and minted
149
152
  * a checkpoint of its own. DISJOINT from `"suspended"` (which is about the IMPLEMENTATION): the work IS done,
150
- * it simply was not gated, and there is an outstanding verifier checkpoint the caller must decide or cancel —
151
- * see {@link VerificationOutcome.verifierPause} for the token. Previously reported as `"no_verdict"`, which
153
+ * it simply was not gated, and there is an outstanding verifier checkpoint the caller must decide or void
154
+ * (`Runner.voidVerifierPause`) — see {@link VerificationOutcome.verifierPause} for the token. Previously reported as `"no_verdict"`, which
152
155
  * reads like a broken verifier and hid the fact that a live checkpoint was left pinned.
153
156
  */
154
157
  export type UnverifiedReason = "suspended" | "needs_review" | "no_verdict" | "opted_out" | "impl_incomplete" | "could_not_verify" | "verifier_paused";
@@ -184,12 +187,25 @@ export interface VerificationOutcome {
184
187
  * (undefined) when no verifier ran (e.g. an impl that suspended/was opted out before verification).
185
188
  */
186
189
  verifierCost?: number;
190
+ /**
191
+ * Set when the loop stopped before a fix leg because the TASK's own ceilings had nothing left on an axis. The task's
192
+ * `limits` (or, on a task that opted into resource suspension, its `resourceSuspend` totals) bound the implementation
193
+ * side as one task — every fix leg runs on what the implementation legs before it left — so the loop returns the current
194
+ * FAIL with its findings, at the same exit as {@link VerifyConfig.costCeilingMicroUsd}, and names the axis and what was
195
+ * left (`0`; absent when the spend could not be known). Absent on every other stop.
196
+ */
197
+ allowanceExhausted?: AllowanceExhausted;
187
198
  /**
188
199
  * HRD-AGO-3 — set iff `unverifiedReason === "verifier_paused"`: the VERIFIER's own durable pause. The
189
200
  * verifier's session stays PINNED by its checkpoint (releasing it here would orphan the checkpoint), so the
190
- * pause is handed back instead of being swallowed: resume/cancel the checkpoint with this token, and the
191
- * session is reclaimed on that terminal. Without it the token died inside the gate and the checkpoint +
192
- * pinned session survived only until the deadline reaper collected them, with nothing in the result saying so.
201
+ * pause is handed back instead of being swallowed. Its card records the leg it is
202
+ * (`CheckpointState.compositionLeg`, entry `verify`: the iteration and the implementation's session), so a host
203
+ * tells it from a card its own run's resume reaches. Settle it with this token, either way unpinning the
204
+ * verifier session: `runner.resume` decides it (the resumed run's terminal unpins), and
205
+ * `Runner.voidVerifierPause(token)` voids it — the card ends `expired`, exactly as an expiry leaves it, and the
206
+ * session is unpinned (not released: its transcript stays the session store's to evict). Without it the token
207
+ * died inside the gate and the checkpoint + pinned session survived only until the deadline reaper collected
208
+ * them, with nothing in the result saying so.
193
209
  *
194
210
  * ⚠️ `checkpointToken` is the resume CAPABILITY — never log it or put it in a URL (types.ts §6).
195
211
  */
@@ -202,6 +218,9 @@ export interface VerificationOutcome {
202
218
  checkpointToken?: CheckpointToken;
203
219
  /** What the verifier's checkpoint is waiting on (which resume outcome it takes). */
204
220
  checkpointGate?: CheckpointGate;
221
+ /** The card's NON-SECRET stable identity (`Checkpoint.checkpointId`, the pause's own `checkpointId`) — the key a host
222
+ * may log or render where the token must not travel. Present whenever the pause minted a card that carries one. */
223
+ checkpointId?: string;
205
224
  };
206
225
  }
207
226
  export interface VerificationResult extends TaskResult {
@@ -241,7 +260,7 @@ export declare function verifyCompleted(runner: RunnerSelfSeat, result: TaskResu
241
260
  /**
242
261
  * The TRUSTED, run-scoped internals channel — the same object `Runner.runTask` takes as its second
243
262
  * argument — forwarded to EVERY leg this gate drives under the composition forward contract
244
- * (identity, with the one placement-axis exception stated where the shape is named in
263
+ * (identity, with the placement and continuation-author exceptions stated where the shape is named in
245
264
  * `src/index.ts`): each round's verifier run and each fix continuation, plus (from
246
265
  * {@link runWithVerification} / {@link resumeWithVerification} / {@link runDeveloperTask}) the
247
266
  * implementation leg. This doc is the contract for the family; the siblings point here.
@@ -289,11 +308,19 @@ export declare function verifyCompleted(runner: RunnerSelfSeat, result: TaskResu
289
308
  * (`refuseUnhonorableInternals`) carries the reasoning, the re-check rule, and what a mid-gate
290
309
  * refusal does and does not undo.
291
310
  *
292
- * Absent ⇒ every leg is dispatched with `undefined`, with ONE design/380 O1② placement delta either
293
- * way: when neither `placementRoot` nor `rootSessionId` is present, the verifier and fix legs get a
294
- * fresh shallow copy carrying `placementRoot` = the entry implementation leg's sessionId (the
295
- * gate's placement fixed point); every other field still rides by the same reference, and an
296
- * internals object that already carries a fixed point is forwarded verbatim.
311
+ * The design/380 O1② PLACEMENT delta, either way (present or absent): the verifier and fix legs land
312
+ * where the implementation leg landed — a fresh shallow copy carrying `placementRoot` = the fixed point
313
+ * that leg's result reports (`TaskResult.placementRoot`) unless the caller's object already resolves
314
+ * there (`placementRoot`, else `rootSessionId`: the gate's fixed point; a result that reports none mints
315
+ * none), and — on the entries that
316
+ * dispatch the implementation leg themselves ({@link runWithVerification}, {@link resumeWithVerification},
317
+ * which hand it a shallow copy whose `onWorkspaceResolved` first records the target its env reported,
318
+ * then calls the caller's own sink) — `placementTarget` = that leg's target when it reported one (a
319
+ * verifier or fix leg minted on another device is refused `config.placement_not_honored`). This entry
320
+ * did not dispatch the implementation, so its legs carry whatever `placementTarget` the caller's object
321
+ * does. The verifier and fix objectives are the gate's words, so each of those legs also carries
322
+ * `objectiveAuthor: "engine"` — always a fresh copy (absent ⇒ exactly the gains). Every other field
323
+ * still rides by the same reference.
297
324
  */
298
325
  internals?: RunInternals): Promise<VerificationResult>;
299
326
  /**
@@ -6,6 +6,9 @@ import { mapNestedSuspend, isDurablePause, pauseFamily } from "./suspend-guard.j
6
6
  import { delimitUntrusted, sanitizeUntrustedText } from "../core/untrusted-text.js";
7
7
  import { createSafeNotifier } from "../core/safe-notify.js";
8
8
  import { createCumulativeStatsTracker } from "./cumulative-stats.js";
9
+ import { compositionPlacement } from "./composition-placement.js";
10
+ import { laterLegAllowance } from "./composition-allowance.js";
11
+ import { recipeContinuationLeg } from "../core/input-author.js";
9
12
  export const VERIFICATION_PROMPT = `You are a verification specialist. Your job is NOT to confirm the implementation works — it is to try to BREAK it.
10
13
 
11
14
  You have two documented failure patterns. First, verification avoidance: faced with a check, you find reasons not to run it — you read code, narrate what you would test, declare "PASS," and move on. Second, being seduced by the first 80%: a polished result or a passing test suite makes you inclined to pass it, not noticing the edge that crashes, the state that vanishes, the bad input that is unhandled. The first 80% is the easy part. Your entire value is in finding the last 20%.
@@ -81,11 +84,11 @@ function refuseUnhonorableInternals(internals, phase) {
81
84
  `implementation leg keeps whatever it did (a consumed checkpoint stays consumed, its session stays the caller's to reclaim).`));
82
85
  }
83
86
  }
84
- function withLegIdentity(internals, leg) {
87
+ function withLegIdentity(internals, leg, caller) {
85
88
  if (internals?.onWiringManifest === undefined)
86
89
  return internals;
87
90
  const identity = Object.freeze({ ...leg });
88
- return { ...internals, onWiringManifest: (manifest) => internals.onWiringManifest?.(manifest, identity) };
91
+ return { ...internals, onWiringManifest: (manifest) => (caller ?? internals).onWiringManifest?.(manifest, identity) };
89
92
  }
90
93
  const IMPL_LEG = { kind: "impl", round: 0 };
91
94
  function fixObjective(findings) {
@@ -109,6 +112,9 @@ function verifierObjective(originalObjective, impl, evidence) {
109
112
  return parts.join("\n\n");
110
113
  }
111
114
  export async function verifyCompleted(runner, result, specBase, objective, config, internals) {
115
+ return verifyCompletedPlaced(runner, result, specBase, objective, config, internals, compositionPlacement(internals));
116
+ }
117
+ async function verifyCompletedPlaced(runner, result, specBase, objective, config, internals, placement) {
112
118
  refuseUnhonorableInternals(internals, "door");
113
119
  if (result.terminal.kind !== "completed") {
114
120
  return { ...result, verification: { verdict: "unverified", unverifiedReason: "impl_incomplete", rounds: 0, findings: [] } };
@@ -138,9 +144,11 @@ export async function verifyCompleted(runner, result, specBase, objective, confi
138
144
  };
139
145
  const evidenceMode = config.evidence != null && config.evidence.trim() !== "";
140
146
  const verifierPrompt = config.verifierPrompt ?? (evidenceMode ? STATIC_VERIFICATION_PROMPT : VERIFICATION_PROMPT);
141
- const legInternals = () => internals?.placementRoot !== undefined || internals?.rootSessionId !== undefined
142
- ? internals
143
- : { ...internals, placementRoot: result.sessionId };
147
+ const legInternals = () => recipeContinuationLeg(placement.laterLeg(result));
148
+ const verifierLegInternals = (round) => {
149
+ const { compositionLeg: _notThisLeg, ...leg } = legInternals();
150
+ return result.sessionId === "" ? leg : { ...leg, compositionLeg: { entry: "verify", leg: round, hostSessionId: result.sessionId } };
151
+ };
144
152
  const runVerifier = async (impl, round) => {
145
153
  refuseUnhonorableInternals(internals, "before_leg");
146
154
  const roundEvidence = round === 1 ? config.evidence : undefined;
@@ -182,7 +190,7 @@ export async function verifyCompleted(runner, result, specBase, objective, confi
182
190
  ...(specBase.promptLean !== undefined ? { promptLean: specBase.promptLean } : {}),
183
191
  signal: specBase.signal,
184
192
  };
185
- const v = await runner.runTask(verifierSpec, withLegIdentity(legInternals(), { kind: "verifier", round }));
193
+ const v = await runner.runTask(verifierSpec, withLegIdentity(verifierLegInternals(round), { kind: "verifier", round }, internals));
186
194
  try {
187
195
  const cost = (v.stats.costMicroUsd ?? 0) + (v.stats.nested?.costMicroUsd ?? 0);
188
196
  return { verdict: v.structuredOutput, cost, ...(isDurablePause(v.terminal) ? { paused: { ...v, terminal: v.terminal } } : {}) };
@@ -211,27 +219,22 @@ export async function verifyCompleted(runner, result, specBase, objective, confi
211
219
  spend += v.cost;
212
220
  verifierSpend += v.cost;
213
221
  if (v.paused) {
214
- const paused = v.paused;
222
+ const verifierPause = {
223
+ status: pauseFamily(v.paused.terminal),
224
+ sessionId: v.paused.sessionId,
225
+ checkpointToken: v.paused.terminal.token,
226
+ checkpointGate: v.paused.terminal.gate,
227
+ ...(v.paused.terminal.checkpointId !== undefined ? { checkpointId: v.paused.terminal.checkpointId } : {}),
228
+ };
215
229
  outcome = {
216
230
  verdict: "unverified",
217
231
  unverifiedReason: "verifier_paused",
218
232
  rounds: round,
219
233
  findings: [],
220
234
  verifierCost: verifierSpend,
221
- verifierPause: {
222
- status: pauseFamily(paused.terminal),
223
- sessionId: paused.sessionId,
224
- checkpointToken: paused.terminal.token,
225
- checkpointGate: paused.terminal.gate,
226
- },
235
+ verifierPause,
227
236
  };
228
- notifier.notify(() => config.onVerifierPause?.({
229
- round,
230
- status: pauseFamily(paused.terminal),
231
- sessionId: paused.sessionId,
232
- checkpointToken: paused.terminal.token,
233
- checkpointGate: paused.terminal.gate,
234
- }), VERIFY_ON_VERIFIER_PAUSE_SITE);
237
+ notifier.notify(() => config.onVerifierPause?.({ round, ...verifierPause }), VERIFY_ON_VERIFIER_PAUSE_SITE);
235
238
  notifier.notify(() => config.onRound?.({ round, verdict: outcome.verdict, findings: outcome.findings }), VERIFY_ON_ROUND_SITE);
236
239
  break;
237
240
  }
@@ -255,9 +258,14 @@ export async function verifyCompleted(runner, result, specBase, objective, confi
255
258
  break;
256
259
  if (config.costCeilingMicroUsd != null && spend >= config.costCeilingMicroUsd)
257
260
  break;
261
+ const allowance = laterLegAllowance(specBase, implAccount.spend());
262
+ if (allowance.exhausted !== undefined) {
263
+ outcome = { ...outcome, allowanceExhausted: allowance.exhausted };
264
+ break;
265
+ }
258
266
  refuseUnhonorableInternals(internals, "before_leg");
259
267
  const fixLegSpec = {
260
- ...specBase,
268
+ ...allowance.spec,
261
269
  sessionId: current.sessionId,
262
270
  objective: fixObjective(outcome.findings),
263
271
  ...childClampSeats({
@@ -267,7 +275,7 @@ export async function verifyCompleted(runner, result, specBase, objective, confi
267
275
  readDenyPatterns: foldedReadDeny,
268
276
  }),
269
277
  };
270
- current = await runner.runTask(fixLegSpec, withLegIdentity(legInternals(), { kind: "fix", round }));
278
+ current = await runner.runTask(fixLegSpec, withLegIdentity(legInternals(), { kind: "fix", round }, internals));
271
279
  spend += (current.stats.costMicroUsd ?? 0) + (current.stats.nested?.costMicroUsd ?? 0);
272
280
  implAccount.add(current.stats);
273
281
  if (isDurablePause(current.terminal)) {
@@ -280,26 +288,28 @@ export async function verifyCompleted(runner, result, specBase, objective, confi
280
288
  }
281
289
  export async function runWithVerification(runner, implSpec, config = {}, internals) {
282
290
  refuseUnhonorableInternals(internals, "door");
283
- const result = await runner.runTask(implSpec, withLegIdentity(internals, IMPL_LEG));
291
+ const placement = compositionPlacement(internals);
292
+ const result = await runner.runTask(implSpec, withLegIdentity(placement.firstLeg, IMPL_LEG, internals));
284
293
  if (isDurablePause(result.terminal)) {
285
294
  return { ...mapNestedSuspend(result), verification: { verdict: "unverified", unverifiedReason: pauseFamily(result.terminal), rounds: 0, findings: [] } };
286
295
  }
287
296
  refuseUnhonorableInternals(internals, "before_leg");
288
- return verifyCompleted(runner, result, implSpec, implSpec.objective, config, internals);
297
+ return verifyCompletedPlaced(runner, result, implSpec, implSpec.objective, config, internals, placement);
289
298
  }
290
299
  export async function resumeWithVerification(runner, token, outcome, taskConfig, objective, config = {}, internals) {
291
300
  refuseUnhonorableInternals(internals, "door");
292
- const result = await runner.resume(token, outcome, taskConfig, withLegIdentity(internals, IMPL_LEG));
301
+ const placement = compositionPlacement(internals);
302
+ const result = await runner.resume(token, outcome, taskConfig, withLegIdentity(placement.firstLeg, IMPL_LEG, internals));
293
303
  if (isDurablePause(result.terminal)) {
294
304
  return { ...mapNestedSuspend(result), verification: { verdict: "unverified", unverifiedReason: pauseFamily(result.terminal), rounds: 0, findings: [] } };
295
305
  }
296
306
  refuseUnhonorableInternals(internals, "before_leg");
297
- return verifyCompleted(runner, result, taskConfig, objective, config, internals);
307
+ return verifyCompletedPlaced(runner, result, taskConfig, objective, config, internals, placement);
298
308
  }
299
309
  export async function runDeveloperTask(runner, spec, config = {}, internals) {
300
310
  const implSpec = namesRoleBase(spec) ? spec : { ...spec, promptRole: "code" };
301
311
  if (config.verify === false) {
302
- const result = await runner.runTask(implSpec, withLegIdentity(internals, IMPL_LEG));
312
+ const result = await runner.runTask(implSpec, withLegIdentity(internals, IMPL_LEG, internals));
303
313
  return { ...result, verification: { verdict: "unverified", unverifiedReason: "opted_out", rounds: 0, findings: [] } };
304
314
  }
305
315
  return runWithVerification(runner, implSpec, config, internals);
@@ -410,6 +410,7 @@ export function createAnthropicBrain(given = {}) {
410
410
  headers,
411
411
  declared,
412
412
  body: JSON.stringify(wire),
413
+ ...((context.tools?.length ?? 0) > 0 ? { toolNames: context.tools.map((t) => t.name) } : {}),
413
414
  extraBodyDropped,
414
415
  route: requestRouteOf(routeCredential, rootOrigin),
415
416
  outputCapTokens: effectiveOutputCap(wire, OUTPUT_CAP_KEYS.anthropic),
@@ -85,6 +85,9 @@ export declare class BrainError extends Error {
85
85
  * dialect table's image row, `provider-dialect.ts`). Lifted onto `AssistantMessage.errorKind: "image_unprocessable"`
86
86
  * at the terminal-shell mint. Never inferred from `detail` prose after construction. */
87
87
  readonly imageUnprocessable?: true;
88
+ /** The tool whose input schema the provider stated it refused, located by the dialect table's tool-schema rows; lifted onto
89
+ * `AssistantMessage.errorKind: "tool_schema_refused"` with `refusedTool` at the terminal-shell mint. */
90
+ readonly toolSchemaRefused?: string;
88
91
  constructor(code: BrainErrorCode, detail: string, status?: number, opts?: {
89
92
  inputTooLong?: boolean;
90
93
  inputTooLongRuledOut?: boolean;
@@ -97,6 +100,7 @@ export declare class BrainError extends Error {
97
100
  };
98
101
  errorBodyIncomplete?: boolean;
99
102
  imageUnprocessable?: boolean;
103
+ toolSchemaRefused?: string;
100
104
  });
101
105
  }
102
106
  /** The provider's diagnostic object out of a JSON error body, or undefined when the body establishes no provenance
@@ -266,7 +270,9 @@ export declare function brainErrorCodeOf(e: unknown): BrainErrorCode | undefined
266
270
  * brain code. */
267
271
  export interface ThrownBrainFailure {
268
272
  readonly code?: BrainErrorCode;
269
- readonly errorKind?: "input_too_long" | "image_unprocessable";
273
+ readonly errorKind?: "input_too_long" | "image_unprocessable" | "tool_schema_refused";
274
+ /** With `tool_schema_refused`: the tool whose input schema the provider refused. */
275
+ readonly refusedTool?: string;
270
276
  readonly inputTooLongRuledOut?: true;
271
277
  }
272
278
  /**
@@ -24,6 +24,7 @@ export class BrainError extends Error {
24
24
  providerResetAtMs;
25
25
  errorBodyIncomplete;
26
26
  imageUnprocessable;
27
+ toolSchemaRefused;
27
28
  constructor(code, detail, status, opts) {
28
29
  super(`[${code}] ${detail}`);
29
30
  this.name = "BrainError";
@@ -47,6 +48,8 @@ export class BrainError extends Error {
47
48
  this.errorBodyIncomplete = true;
48
49
  if (opts?.imageUnprocessable === true)
49
50
  this.imageUnprocessable = true;
51
+ if (typeof opts?.toolSchemaRefused === "string")
52
+ this.toolSchemaRefused = opts.toolSchemaRefused;
50
53
  }
51
54
  }
52
55
  export function providerErrorObject(body) {
@@ -259,6 +262,9 @@ export function thrownBrainFailure(e) {
259
262
  const ruledOut = readMember(e, "inputTooLongRuledOut") === true;
260
263
  if (readMember(e, "imageUnprocessable") === true)
261
264
  return { code, errorKind: "image_unprocessable", ...(ruledOut ? { inputTooLongRuledOut: true } : {}) };
265
+ const refusedTool = readMember(e, "toolSchemaRefused");
266
+ if (typeof refusedTool === "string")
267
+ return { code, errorKind: "tool_schema_refused", refusedTool, ...(ruledOut ? { inputTooLongRuledOut: true } : {}) };
262
268
  if (ruledOut)
263
269
  return { code, inputTooLongRuledOut: true };
264
270
  return { code };
@@ -42,7 +42,8 @@ export function createFailoverBrain(brains) {
42
42
  options?.signal?.aborted !== true &&
43
43
  !sawContent &&
44
44
  message.errorKind !== "length_empty" &&
45
- message.errorKind !== "image_unprocessable";
45
+ message.errorKind !== "image_unprocessable" &&
46
+ message.errorKind !== "tool_schema_refused";
46
47
  if (cleanUpfrontFailure && !isLast) {
47
48
  lastFailedCode = extractErrorCode(message.errorMessage);
48
49
  continue;
@@ -291,6 +291,7 @@ export function createOpenResponsesBrain(given = {}) {
291
291
  headers,
292
292
  declared,
293
293
  body: JSON.stringify(wire),
294
+ ...((context.tools?.length ?? 0) > 0 ? { toolNames: context.tools.map((t) => t.name) } : {}),
294
295
  extraBodyDropped,
295
296
  route: requestRouteOf(routeCredential, rootOrigin),
296
297
  outputCapTokens: effectiveOutputCap(wire, OUTPUT_CAP_KEYS.responses),
@@ -371,6 +371,7 @@ export function createOpenAIBrain(given = {}) {
371
371
  headers,
372
372
  declared: declaredValues,
373
373
  body: JSON.stringify(wire),
374
+ ...((context.tools?.length ?? 0) > 0 ? { toolNames: context.tools.map((t) => t.name) } : {}),
374
375
  extraBodyDropped,
375
376
  route: requestRouteOf(routeCredential, rootOrigin),
376
377
  outputCapTokens: effectiveOutputCap(wire, OUTPUT_CAP_KEYS.openai),
@@ -133,6 +133,10 @@ export type InputTooLongVerdict = "yes" | "no" | "unknown";
133
133
  * reference's image phrases less "exceeds api limit" (it names no image), and DeepSeek's "unsupported image".
134
134
  */
135
135
  export declare const IMAGE_UNPROCESSABLE_RE: RegExp;
136
+ /** "The provider refused the input schema of the tool at this position of the request's tool list", located in `error.message`
137
+ * (`tools.3.custom.input_schema: …` — the reference's own pattern, `X4e` (cli309.js:264190)) or in the envelope's `param`
138
+ * (`tools[3].function.parameters`, the OpenAI-family form, read by its documented shape). */
139
+ export declare const TOOL_INPUT_SCHEMA_SENTENCE_RE: RegExp;
136
140
  /** One row of the failure column. A row with no `status` applies to every status. */
137
141
  export interface FailureRow {
138
142
  readonly status?: readonly number[];
@@ -145,6 +149,9 @@ export interface FailureRow {
145
149
  readonly inputTooLong?: true;
146
150
  /** This row's statement is the provider refusing an image in the request (`errorKind: "image_unprocessable"`). */
147
151
  readonly imageUnprocessable?: true;
152
+ /** This row's statement is the provider refusing one tool's input schema (`errorKind: "tool_schema_refused"`), at the
153
+ * position the envelope locates ({@link ProviderVerdict.toolSchemaAt}). */
154
+ readonly toolSchemaRefused?: true;
148
155
  }
149
156
  /** Where a dialect applies: the wire families it was evidenced for, its host suffixes, an optional path prefix. */
150
157
  export interface DialectKey {
@@ -226,6 +233,9 @@ export interface ProviderVerdict {
226
233
  readonly inputTooLong: InputTooLongVerdict;
227
234
  /** The row the failure read off states an image in the request could not be processed. */
228
235
  readonly imageUnprocessable: boolean;
236
+ /** The row the failure read off states the provider refused one tool's input schema, and the envelope located it: the
237
+ * tool's position in the request's tool list. Absent when no row says so, or the envelope locates no position. */
238
+ readonly toolSchemaAt?: number;
229
239
  }
230
240
  type HeaderBag = {
231
241
  get?: (name: string) => string | null;
@@ -22,6 +22,8 @@ export function startsWithInputTooLongAnchor(diagnostic) {
22
22
  }
23
23
  const INPUT_TOO_LONG_STATUSES = new Set([400, 413, 422]);
24
24
  export const IMAGE_UNPROCESSABLE_RE = /could not process image|image exceeds|image dimensions exceed|image does not match the provided media type|image cannot be empty|images exceed the api limit|unable to resize image|unable to compress image|image file is empty|unsupported image/i;
25
+ export const TOOL_INPUT_SCHEMA_SENTENCE_RE = /\btools\.(\d+)\.(?:custom\.)?input_schema\b/;
26
+ const TOOL_INPUT_SCHEMA_PARAM_RE = /^tools\[(\d+)\](?:\.function)?\.parameters$/;
25
27
  const OPENAI_CHAT = "openai-completions";
26
28
  const OPENAI_RESPONSES = "openai-responses";
27
29
  const ANTHROPIC = "anthropic-messages";
@@ -109,6 +111,8 @@ export const GENERIC_FAILURES = Object.freeze([
109
111
  { status: [400, 422], sentence: INPUT_TOO_LONG_ANCHORED_RE, condition: "stop_other", inputTooLong: true },
110
112
  { status: [413], condition: "stop_other", inputTooLong: true },
111
113
  { status: [400, 422], sentence: IMAGE_UNPROCESSABLE_RE, condition: "stop_other", imageUnprocessable: true },
114
+ { status: [400], sentence: TOOL_INPUT_SCHEMA_SENTENCE_RE, condition: "stop_other", toolSchemaRefused: true },
115
+ { status: [400], word: ["invalid_function_parameters"], condition: "stop_other", toolSchemaRefused: true },
112
116
  ]);
113
117
  export function isTransientStatus(status) {
114
118
  return status >= 500 || status === 408 || status === 409;
@@ -155,7 +159,13 @@ function statementOf(err) {
155
159
  return undefined;
156
160
  const word = providerErrorWord(err);
157
161
  const sentence = typeof err.message === "string" ? err.message.trimStart() : undefined;
158
- return { ...(word !== undefined ? { word } : {}), ...(sentence !== undefined ? { sentence } : {}) };
162
+ const param = typeof err.param === "string" ? err.param : undefined;
163
+ return { ...(word !== undefined ? { word } : {}), ...(sentence !== undefined ? { sentence } : {}), ...(param !== undefined ? { param } : {}) };
164
+ }
165
+ function refusedToolSchemaPosition(stated) {
166
+ const at = (stated?.param !== undefined ? TOOL_INPUT_SCHEMA_PARAM_RE.exec(stated.param) : null)?.[1] ?? (stated?.sentence !== undefined ? TOOL_INPUT_SCHEMA_SENTENCE_RE.exec(stated.sentence) : null)?.[1];
167
+ const n = at !== undefined ? Number(at) : Number.NaN;
168
+ return Number.isSafeInteger(n) ? n : undefined;
159
169
  }
160
170
  function bestRow(rows, status, stated) {
161
171
  let best;
@@ -180,7 +190,8 @@ function verdictOf(dialect, status, stated, enveloped) {
180
190
  const condition = row?.condition ?? (status === undefined || status === 429 || isTransientStatus(status) ? "unknown" : "stop_other");
181
191
  const source = row !== undefined && (row.word !== undefined || row.sentence !== undefined) ? "provider_code" : "status";
182
192
  const inputTooLong = status !== undefined && !INPUT_TOO_LONG_STATUSES.has(status) ? "no" : row?.inputTooLong === true ? "yes" : enveloped ? "no" : "unknown";
183
- return { condition, source, inputTooLong, imageUnprocessable: row?.imageUnprocessable === true };
193
+ const toolSchemaAt = row?.toolSchemaRefused === true ? refusedToolSchemaPosition(stated) : undefined;
194
+ return { condition, source, inputTooLong, imageUnprocessable: row?.imageUnprocessable === true, ...(toolSchemaAt !== undefined ? { toolSchemaAt } : {}) };
184
195
  }
185
196
  const UNIFIED_QUOTA_HEADERS = [
186
197
  "anthropic-ratelimit-unified-representative-claim",
@@ -116,6 +116,9 @@ export interface SSERequest {
116
116
  */
117
117
  declared: readonly string[];
118
118
  body: string;
119
+ /** The engine name of each tool the body's tool list carries, in its order: a tool-schema refusal located by position
120
+ * ({@link ProviderVerdict.toolSchemaAt}) names the tool at it (`BrainError.toolSchemaRefused`). Absent = no tool list. */
121
+ toolNames?: readonly string[];
119
122
  /**
120
123
  * The per-request output cap this request ACTUALLY carries on the wire, when the adapter sets one
121
124
  * (the adapters disagree on the body key, so the engine cannot read it off `body`). Absent means
@@ -337,6 +337,8 @@ export function runStreamingBrain(args) {
337
337
  if (failure.code !== undefined) {
338
338
  if (failure.errorKind !== undefined)
339
339
  errorMsg.errorKind = failure.errorKind;
340
+ if (failure.refusedTool !== undefined)
341
+ errorMsg.refusedTool = failure.refusedTool;
340
342
  if (failure.inputTooLongRuledOut === true)
341
343
  errorMsg.inputTooLongRuledOut = true;
342
344
  if (readMember(err, "errorBodyIncomplete") === true)
@@ -692,10 +694,12 @@ export function runStreamingBrain(args) {
692
694
  const status = r?.status ?? 0;
693
695
  const itl = terminalVerdict?.inputTooLong ?? "no";
694
696
  const providerCode = refusedTheRequest(status) ? readProviderErrorCode(errorBody) : undefined;
697
+ const refusedTool = terminalVerdict?.toolSchemaAt !== undefined ? req.toolNames?.[terminalVerdict.toolSchemaAt] : undefined;
695
698
  throw new BrainError(classifyHttp(status), `${httpLabel} HTTP ${status || "ERR"}: ${detail.slice(0, 500)}${overflowDeclineNote}`, status, {
696
699
  apiError: true,
697
700
  ...(itl === "yes" ? { inputTooLong: true } : itl === "no" ? { inputTooLongRuledOut: true } : {}),
698
701
  ...(terminalVerdict?.imageUnprocessable === true ? { imageUnprocessable: true } : {}),
702
+ ...(refusedTool !== undefined ? { toolSchemaRefused: refusedTool } : {}),
699
703
  ...(providerCode !== undefined ? { providerCode } : {}),
700
704
  ...(terminalVerdict !== undefined ? { verdict: { condition: terminalVerdict.condition, source: terminalVerdict.source, ...(terminalVerdict.resetAtMs !== undefined ? { resetAtMs: terminalVerdict.resetAtMs } : {}) } } : {}),
701
705
  ...(errorBody !== undefined && !errorBody.endedNormally ? { errorBodyIncomplete: true } : {}),
@@ -2,7 +2,7 @@
2
2
  * A background agent's CURRENT state — the one reading every read face renders.
3
3
  *
4
4
  * A parent model answers "how far along is it?" from what its read faces show. Three faces read a
5
- * background agent: AgentTranscript (its recent steps), ListAgents (the roster) and TaskOutput (the poll).
5
+ * background agent: AgentTranscript (its recent steps), ListAgents (the roster) and the host task poll.
6
6
  * Each one projects {@link readAgentState}'s result and renders it with {@link agentStateSummary} /
7
7
  * {@link agentActivityClause} / {@link agentApprovalClause}; none derives status, activity time or approval
8
8
  * facts on its own, so the three cannot disagree about one agent at one instant.