@sema-agent/core 7.58.0 → 7.60.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 (519) hide show
  1. package/CHANGELOG.md +1340 -0
  2. package/README.md +6 -4
  3. package/dist/agents/agent-definition.d.ts +7 -0
  4. package/dist/agents/agent-definition.js +12 -0
  5. package/dist/agents/agent-transcript-tool.d.ts +2 -1
  6. package/dist/agents/agent-transcript-tool.js +3 -1
  7. package/dist/agents/cc-peer-directory.js +8 -8
  8. package/dist/agents/child-model-seat.d.ts +4 -2
  9. package/dist/agents/child-model-seat.js +9 -4
  10. package/dist/agents/cumulative-stats.js +0 -1
  11. package/dist/agents/inherited-tool-pool.d.ts +26 -1
  12. package/dist/agents/inherited-tool-pool.js +22 -0
  13. package/dist/agents/peer-directory.d.ts +9 -0
  14. package/dist/agents/peer-directory.js +6 -2
  15. package/dist/agents/retain-ledger.d.ts +11 -1
  16. package/dist/agents/retain-ledger.js +13 -2
  17. package/dist/agents/roster-store.d.ts +1 -1
  18. package/dist/agents/roster-store.js +3 -1
  19. package/dist/agents/send-message-tool.d.ts +8 -19
  20. package/dist/agents/send-message-tool.js +32 -50
  21. package/dist/agents/subagent.d.ts +51 -17
  22. package/dist/agents/subagent.js +150 -112
  23. package/dist/agents/tool-filter.d.ts +1 -3
  24. package/dist/agents/tool-filter.js +4 -12
  25. package/dist/bench/metrics.d.ts +3 -5
  26. package/dist/bench/metrics.js +0 -1
  27. package/dist/brain/anthropic.js +161 -45
  28. package/dist/brain/degrading.js +3 -1
  29. package/dist/brain/errors.d.ts +9 -3
  30. package/dist/brain/errors.js +7 -1
  31. package/dist/brain/failover.js +2 -1
  32. package/dist/brain/open-responses.js +3 -3
  33. package/dist/brain/openai.js +103 -53
  34. package/dist/brain/provider-dialect.d.ts +11 -0
  35. package/dist/brain/provider-dialect.js +5 -2
  36. package/dist/brain/reasoning-request.js +5 -4
  37. package/dist/brain/reasoning.d.ts +19 -0
  38. package/dist/brain/reasoning.js +17 -2
  39. package/dist/brain/request-route.d.ts +4 -1
  40. package/dist/brain/request-route.js +4 -1
  41. package/dist/brain/route-adjudicator.d.ts +84 -18
  42. package/dist/brain/route-adjudicator.js +90 -22
  43. package/dist/brain/route-conformance.js +1 -1
  44. package/dist/brain/status-sink.d.ts +7 -1
  45. package/dist/brain/status-sink.js +6 -0
  46. package/dist/brain/stream-engine.js +84 -49
  47. package/dist/brain/stream-shared.d.ts +30 -0
  48. package/dist/brain/stream-shared.js +34 -1
  49. package/dist/brain/timeout.d.ts +65 -6
  50. package/dist/brain/timeout.js +111 -11
  51. package/dist/core/a2a.d.ts +15 -5
  52. package/dist/core/a2a.js +34 -19
  53. package/dist/core/account-row.d.ts +61 -0
  54. package/dist/core/account-row.js +51 -0
  55. package/dist/core/advisor-verdict.d.ts +2 -1
  56. package/dist/core/advisor-verdict.js +1 -1
  57. package/dist/core/agent-definition.d.ts +20 -0
  58. package/dist/core/allow-entry.d.ts +20 -6
  59. package/dist/core/allow-entry.js +17 -7
  60. package/dist/core/approval-object.d.ts +29 -15
  61. package/dist/core/approval-object.js +47 -19
  62. package/dist/core/artifact-host.d.ts +0 -2
  63. package/dist/core/artifact-host.js +0 -1
  64. package/dist/core/auto-compaction.js +1 -1
  65. package/dist/core/auto-mode-defaults.d.ts +8 -0
  66. package/dist/core/auto-mode-defaults.js +1 -0
  67. package/dist/core/auto-mode-rebuild.d.ts +2 -1
  68. package/dist/core/auto-mode.d.ts +39 -4
  69. package/dist/core/auto-mode.js +63 -12
  70. package/dist/core/background-agent-store.d.ts +26 -4
  71. package/dist/core/background-agent-store.js +3 -2
  72. package/dist/core/background-shell.d.ts +12 -1
  73. package/dist/core/background-shell.js +12 -0
  74. package/dist/core/checkpoint-requirements.d.ts +13 -1
  75. package/dist/core/checkpoint-requirements.js +3 -1
  76. package/dist/core/checkpoint-store.d.ts +66 -25
  77. package/dist/core/checkpoint-store.js +22 -9
  78. package/dist/core/child-clamp-seats.d.ts +29 -0
  79. package/dist/core/child-clamp-seats.js +56 -1
  80. package/dist/core/compliance.d.ts +3 -3
  81. package/dist/core/compliance.js +1 -1
  82. package/dist/core/credential-echo.d.ts +52 -0
  83. package/dist/core/credential-echo.js +65 -0
  84. package/dist/core/credential-vocabulary.d.ts +13 -3
  85. package/dist/core/credential-vocabulary.js +12 -4
  86. package/dist/core/cross-boundary-taint.d.ts +4 -5
  87. package/dist/core/effective-path-target.d.ts +8 -2
  88. package/dist/core/effective-path-target.js +8 -3
  89. package/dist/core/engine-notice.d.ts +156 -23
  90. package/dist/core/engine-notice.js +19 -5
  91. package/dist/core/frame-settlement.d.ts +5 -0
  92. package/dist/core/frame-settlement.js +4 -0
  93. package/dist/core/gate-fold.js +8 -6
  94. package/dist/core/gate-lanes.js +47 -12
  95. package/dist/core/gate-outcome.d.ts +32 -3
  96. package/dist/core/gate-outcome.js +19 -1
  97. package/dist/core/governance-codes.d.ts +17 -1
  98. package/dist/core/governance-codes.js +25 -0
  99. package/dist/core/hands-band-screen.js +0 -1
  100. package/dist/core/hands-band.d.ts +0 -3
  101. package/dist/core/hooks.d.ts +70 -59
  102. package/dist/core/hooks.js +125 -80
  103. package/dist/core/image-admission.d.ts +106 -52
  104. package/dist/core/image-admission.js +184 -56
  105. package/dist/core/image-downsample.d.ts +36 -69
  106. package/dist/core/image-downsample.js +111 -73
  107. package/dist/core/integer-option.d.ts +21 -0
  108. package/dist/core/integer-option.js +13 -0
  109. package/dist/core/locked-config.d.ts +59 -5
  110. package/dist/core/locked-config.js +82 -50
  111. package/dist/core/mailbox-store.d.ts +45 -1
  112. package/dist/core/mailbox-store.js +53 -9
  113. package/dist/core/mcp-call-meta.d.ts +2 -2
  114. package/dist/core/mcp-call-meta.js +9 -10
  115. package/dist/core/mcp-failure.d.ts +122 -20
  116. package/dist/core/mcp-failure.js +73 -5
  117. package/dist/core/mcp-host-seat.d.ts +92 -0
  118. package/dist/core/mcp-host-seat.js +131 -0
  119. package/dist/core/mcp-probe.d.ts +7 -2
  120. package/dist/core/mcp-probe.js +7 -2
  121. package/dist/core/mcp-server-link.d.ts +22 -1
  122. package/dist/core/mcp-server-link.js +25 -1
  123. package/dist/core/mcp-server-spec.d.ts +38 -9
  124. package/dist/core/mcp-server-spec.js +55 -21
  125. package/dist/core/mcp.d.ts +27 -12
  126. package/dist/core/mcp.js +105 -76
  127. package/dist/core/memory-admission.d.ts +23 -6
  128. package/dist/core/memory-admission.js +19 -9
  129. package/dist/core/memory-engine/consolidation-driver.d.ts +2 -4
  130. package/dist/core/memory-engine/consolidation-driver.js +3 -3
  131. package/dist/core/memory-engine/consolidation.d.ts +4 -0
  132. package/dist/core/memory-engine/consolidation.js +1 -0
  133. package/dist/core/memory-engine/content-origin.d.ts +13 -0
  134. package/dist/core/memory-engine/content-origin.js +21 -3
  135. package/dist/core/memory-engine/delegation-settlement.js +5 -12
  136. package/dist/core/memory-engine/distiller.js +2 -2
  137. package/dist/core/memory-engine/dual-root.d.ts +50 -1
  138. package/dist/core/memory-engine/dual-root.js +44 -1
  139. package/dist/core/memory-engine/engine.d.ts +67 -14
  140. package/dist/core/memory-engine/engine.js +384 -212
  141. package/dist/core/memory-engine/export-bundle.d.ts +23 -0
  142. package/dist/core/memory-engine/export-bundle.js +23 -4
  143. package/dist/core/memory-engine/file-backend.d.ts +128 -55
  144. package/dist/core/memory-engine/file-backend.js +290 -117
  145. package/dist/core/memory-engine/index.d.ts +3 -2
  146. package/dist/core/memory-engine/index.js +2 -1
  147. package/dist/core/memory-engine/layout.d.ts +59 -11
  148. package/dist/core/memory-engine/layout.js +190 -40
  149. package/dist/core/memory-engine/memory-backend-contract.d.ts +1 -1
  150. package/dist/core/memory-engine/memory-backend-contract.js +39 -2
  151. package/dist/core/memory-engine/scope-contract.d.ts +13 -3
  152. package/dist/core/memory-engine/scope-contract.js +2 -2
  153. package/dist/core/memory-engine/sync-client.d.ts +51 -9
  154. package/dist/core/memory-engine/sync-client.js +107 -13
  155. package/dist/core/memory-engine/sync-report.d.ts +103 -0
  156. package/dist/core/memory-engine/sync-report.js +119 -0
  157. package/dist/core/memory-engine/sync.d.ts +8 -1
  158. package/dist/core/memory-engine/types.d.ts +6 -0
  159. package/dist/core/mode-policy.d.ts +9 -1
  160. package/dist/core/mode-policy.js +11 -1
  161. package/dist/core/model-receipt.d.ts +39 -0
  162. package/dist/core/model-receipt.js +139 -0
  163. package/dist/core/mods/agent-stations.d.ts +65 -0
  164. package/dist/core/mods/agent-stations.js +105 -0
  165. package/dist/core/mods/classic-events.d.ts +5 -1
  166. package/dist/core/mods/kernel/dispatch.d.ts +5 -1
  167. package/dist/core/mods/kernel/dispatch.js +6 -5
  168. package/dist/core/mods/kernel/events.d.ts +11 -4
  169. package/dist/core/mods/kernel/events.js +11 -7
  170. package/dist/core/mods/kernel/receive.d.ts +5 -0
  171. package/dist/core/mods/kernel/receive.js +10 -0
  172. package/dist/core/mods/kernel/registration.d.ts +4 -0
  173. package/dist/core/mods/kernel/registration.js +3 -0
  174. package/dist/core/mods/lifecycle-stations.d.ts +41 -0
  175. package/dist/core/mods/lifecycle-stations.js +35 -0
  176. package/dist/core/mods/stations.d.ts +73 -60
  177. package/dist/core/mods/stations.js +64 -40
  178. package/dist/core/mods/tool-call.d.ts +10 -4
  179. package/dist/core/mods/tool-call.js +28 -12
  180. package/dist/core/mounted-mcp.d.ts +5 -0
  181. package/dist/core/mounted-mcp.js +2 -2
  182. package/dist/core/namespaced-rule-name.d.ts +7 -1
  183. package/dist/core/namespaced-rule-name.js +13 -2
  184. package/dist/core/oracle-isolation.js +1 -1
  185. package/dist/core/own-property-receipt.d.ts +3 -0
  186. package/dist/core/own-property-receipt.js +3 -0
  187. package/dist/core/parent-spec-seat.d.ts +8 -3
  188. package/dist/core/parent-spec-seat.js +2 -0
  189. package/dist/core/park-selfcheck.js +14 -8
  190. package/dist/core/peer-seat.d.ts +133 -16
  191. package/dist/core/peer-seat.js +319 -42
  192. package/dist/core/permission-rule-consent.d.ts +0 -21
  193. package/dist/core/permission-rule-consent.js +11 -6
  194. package/dist/core/permission-rule-model.d.ts +20 -2
  195. package/dist/core/permission-rule-model.js +8 -7
  196. package/dist/core/present-plan-tool.d.ts +11 -3
  197. package/dist/core/present-plan-tool.js +2 -2
  198. package/dist/core/protocol-http-auth.d.ts +14 -2
  199. package/dist/core/protocol-http-auth.js +16 -7
  200. package/dist/core/read-face-seats.d.ts +7 -5
  201. package/dist/core/read-face-seats.js +4 -1
  202. package/dist/core/redaction-marks.d.ts +4 -3
  203. package/dist/core/redaction-marks.js +2 -2
  204. package/dist/core/remote-env.d.ts +146 -98
  205. package/dist/core/remote-env.js +113 -14
  206. package/dist/core/resume-startup-cause.js +1 -0
  207. package/dist/core/retention.js +37 -12
  208. package/dist/core/retired-keys.d.ts +6 -1
  209. package/dist/core/retired-keys.js +4 -1
  210. package/dist/core/rewrite-rejudge.d.ts +13 -5
  211. package/dist/core/rewrite-rejudge.js +9 -5
  212. package/dist/core/roles.d.ts +69 -3
  213. package/dist/core/roles.js +167 -80
  214. package/dist/core/rule-owner.d.ts +3 -0
  215. package/dist/core/runner/announce-once-ledger.d.ts +5 -4
  216. package/dist/core/runner/announce-once-ledger.js +4 -2
  217. package/dist/core/runner/assemble-result.d.ts +0 -5
  218. package/dist/core/runner/assemble-result.js +0 -1
  219. package/dist/core/runner/call-hook-stations.d.ts +17 -10
  220. package/dist/core/runner/call-hook-stations.js +23 -12
  221. package/dist/core/runner/child-tree.d.ts +7 -8
  222. package/dist/core/runner/child-tree.js +6 -6
  223. package/dist/core/runner/classifier-ladder.d.ts +10 -2
  224. package/dist/core/runner/classifier-ladder.js +39 -8
  225. package/dist/core/runner/construction-doors.js +5 -0
  226. package/dist/core/runner/contracts.d.ts +82 -57
  227. package/dist/core/runner/credential-origin-seat.js +4 -3
  228. package/dist/core/runner/cross-boundary-lane.d.ts +3 -5
  229. package/dist/core/runner/cross-boundary-lane.js +11 -2
  230. package/dist/core/runner/cwd-alignment-probe.d.ts +20 -0
  231. package/dist/core/runner/cwd-alignment-probe.js +21 -0
  232. package/dist/core/runner/decide-continuation.d.ts +2 -2
  233. package/dist/core/runner/env-capability-census.d.ts +15 -20
  234. package/dist/core/runner/env-capability-census.js +25 -34
  235. package/dist/core/runner/file-history-request.d.ts +2 -2
  236. package/dist/core/runner/file-history-request.js +0 -8
  237. package/dist/core/runner/gate-exit.d.ts +87 -11
  238. package/dist/core/runner/gate-exit.js +30 -8
  239. package/dist/core/runner/git-status-frame.d.ts +5 -2
  240. package/dist/core/runner/git-status-frame.js +3 -4
  241. package/dist/core/runner/image-removed-seat.d.ts +12 -0
  242. package/dist/core/runner/image-removed-seat.js +19 -0
  243. package/dist/core/runner/image.d.ts +7 -2
  244. package/dist/core/runner/image.js +14 -8
  245. package/dist/core/runner/inline-image.d.ts +10 -8
  246. package/dist/core/runner/inline-image.js +11 -9
  247. package/dist/core/runner/memory-consolidation-driver.js +5 -5
  248. package/dist/core/runner/park-commit.d.ts +1 -1
  249. package/dist/core/runner/park-commit.js +3 -0
  250. package/dist/core/runner/permission-rule-lanes.js +1 -1
  251. package/dist/core/runner/prepare-ask-lane.d.ts +1 -1
  252. package/dist/core/runner/prepare-ask-lane.js +2 -1
  253. package/dist/core/runner/prepare-boundary-parks.d.ts +2 -2
  254. package/dist/core/runner/prepare-boundary-parks.js +5 -5
  255. package/dist/core/runner/prepare-caps-and-workflow.d.ts +7 -5
  256. package/dist/core/runner/prepare-caps-and-workflow.js +6 -3
  257. package/dist/core/runner/prepare-config-doors.d.ts +6 -1
  258. package/dist/core/runner/prepare-config-doors.js +16 -9
  259. package/dist/core/runner/prepare-context-lane.js +2 -0
  260. package/dist/core/runner/prepare-delegation-surface.d.ts +9 -3
  261. package/dist/core/runner/prepare-delegation-surface.js +5 -4
  262. package/dist/core/runner/prepare-file-history.d.ts +10 -12
  263. package/dist/core/runner/prepare-file-history.js +3 -12
  264. package/dist/core/runner/prepare-gate-stations.d.ts +4 -3
  265. package/dist/core/runner/prepare-gate-stations.js +4 -3
  266. package/dist/core/runner/prepare-hands-readface.d.ts +7 -1
  267. package/dist/core/runner/prepare-hands-readface.js +19 -6
  268. package/dist/core/runner/prepare-inherited-gate.d.ts +6 -7
  269. package/dist/core/runner/prepare-inherited-gate.js +22 -31
  270. package/dist/core/runner/prepare-memory-engine-session.js +1 -1
  271. package/dist/core/runner/prepare-memory.d.ts +2 -2
  272. package/dist/core/runner/prepare-memory.js +12 -19
  273. package/dist/core/runner/prepare-park-ask.d.ts +4 -6
  274. package/dist/core/runner/prepare-park-ask.js +5 -9
  275. package/dist/core/runner/prepare-policy-chain.d.ts +8 -7
  276. package/dist/core/runner/prepare-policy-chain.js +136 -121
  277. package/dist/core/runner/prepare-project-context.d.ts +2 -2
  278. package/dist/core/runner/prepare-project-context.js +10 -7
  279. package/dist/core/runner/prepare-prompt-inputs.d.ts +5 -2
  280. package/dist/core/runner/prepare-prompt-inputs.js +10 -20
  281. package/dist/core/runner/prepare-protocol-tools.d.ts +5 -3
  282. package/dist/core/runner/prepare-protocol-tools.js +17 -2
  283. package/dist/core/runner/prepare-run-refs.d.ts +2 -3
  284. package/dist/core/runner/prepare-run-refs.js +4 -1
  285. package/dist/core/runner/prepare-suspend-saga.d.ts +0 -2
  286. package/dist/core/runner/prepare-suspend-saga.js +5 -7
  287. package/dist/core/runner/prepare-task.js +44 -28
  288. package/dist/core/runner/prepare-turn-wiring.d.ts +2 -0
  289. package/dist/core/runner/prepare-turn-wiring.js +7 -2
  290. package/dist/core/runner/prepare-wiring-manifest.d.ts +5 -4
  291. package/dist/core/runner/prepare-wiring-manifest.js +34 -19
  292. package/dist/core/runner/prepare-workspace-restore.js +3 -3
  293. package/dist/core/runner/reply-pricing.d.ts +30 -0
  294. package/dist/core/runner/reply-pricing.js +19 -0
  295. package/dist/core/runner/resume-admission.js +4 -2
  296. package/dist/core/runner/resume-apply.js +6 -1
  297. package/dist/core/runner/resume-checkpoint-screen.js +4 -4
  298. package/dist/core/runner/resume-policy-outcome.js +5 -5
  299. package/dist/core/runner/retired-runner-deps.js +4 -1
  300. package/dist/core/runner/role-seat-defaulted.d.ts +44 -0
  301. package/dist/core/runner/role-seat-defaulted.js +40 -0
  302. package/dist/core/runner/run-attachment-seats.js +3 -3
  303. package/dist/core/runner/run-brain-sinks.js +3 -0
  304. package/dist/core/runner/run-git-lane.d.ts +3 -1
  305. package/dist/core/runner/run-git-lane.js +1 -1
  306. package/dist/core/runner/run-harness-handlers.d.ts +3 -1
  307. package/dist/core/runner/run-harness-handlers.js +3 -1
  308. package/dist/core/runner/run-identity-wiring.d.ts +2 -5
  309. package/dist/core/runner/run-identity-wiring.js +6 -5
  310. package/dist/core/runner/run-leg.d.ts +2 -0
  311. package/dist/core/runner/run-leg.js +63 -56
  312. package/dist/core/runner/run-notification-lane.d.ts +3 -1
  313. package/dist/core/runner/run-notification-lane.js +16 -10
  314. package/dist/core/runner/run-settle-and-teardown.js +5 -1
  315. package/dist/core/runner/run-stop-and-final-verify.d.ts +4 -0
  316. package/dist/core/runner/run-stop-and-final-verify.js +14 -6
  317. package/dist/core/runner/run-terminal-adoption.d.ts +2 -5
  318. package/dist/core/runner/run-terminal-adoption.js +9 -3
  319. package/dist/core/runner/run-turn-boundary.js +89 -77
  320. package/dist/core/runner/runtask.d.ts +8 -5
  321. package/dist/core/runner/runtask.js +21 -13
  322. package/dist/core/runner/side-call-account.d.ts +1 -1
  323. package/dist/core/runner/side-call-account.js +3 -18
  324. package/dist/core/runner/skills-seat.js +2 -2
  325. package/dist/core/runner/sub-agent-deny-lists.d.ts +24 -0
  326. package/dist/core/runner/sub-agent-deny-lists.js +20 -7
  327. package/dist/core/runner/synthetic-tools.js +2 -2
  328. package/dist/core/runner/tool-disclosure.js +0 -2
  329. package/dist/core/runner/tool-end-body.js +2 -2
  330. package/dist/core/runner/tool-face-overlay.d.ts +1 -1
  331. package/dist/core/runner/tool-face-overlay.js +26 -19
  332. package/dist/core/runner/tool-occurrence.d.ts +1 -1
  333. package/dist/core/runner/tool-occurrence.js +2 -2
  334. package/dist/core/runner/tool-result-media-seat.d.ts +9 -1
  335. package/dist/core/runner/tool-result-media-seat.js +17 -1
  336. package/dist/core/runner/turn-attachments.d.ts +29 -27
  337. package/dist/core/runner/turn-attachments.js +27 -42
  338. package/dist/core/runner-deps.d.ts +32 -19
  339. package/dist/core/secret-env.d.ts +35 -4
  340. package/dist/core/secret-env.js +65 -3
  341. package/dist/core/sensitive-path-policy.js +3 -3
  342. package/dist/core/session-policy-store.d.ts +12 -3
  343. package/dist/core/session-policy-store.js +29 -10
  344. package/dist/core/session-store.d.ts +5 -7
  345. package/dist/core/session-store.js +50 -11
  346. package/dist/core/side-query.d.ts +11 -1
  347. package/dist/core/side-query.js +9 -0
  348. package/dist/core/skill-grant-binding.d.ts +31 -2
  349. package/dist/core/skill-grant-binding.js +31 -1
  350. package/dist/core/skill-grant.d.ts +17 -5
  351. package/dist/core/skill-grant.js +24 -6
  352. package/dist/core/store-contracts/background-agent-store-contract.js +27 -0
  353. package/dist/core/store-contracts/checkpoint-store-contract.js +3 -2
  354. package/dist/core/store-contracts/mailbox-store-contract.js +31 -1
  355. package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
  356. package/dist/core/store-contracts/tool-result-store-contract.js +37 -0
  357. package/dist/core/stub-env.d.ts +5 -5
  358. package/dist/core/stub-env.js +11 -1
  359. package/dist/core/swappable-deps.d.ts +17 -43
  360. package/dist/core/swappable-deps.js +15 -5
  361. package/dist/core/synthetic-read-verdict.d.ts +1 -1
  362. package/dist/core/synthetic-read-verdict.js +2 -1
  363. package/dist/core/task-event.d.ts +50 -10
  364. package/dist/core/task-notification.d.ts +88 -5
  365. package/dist/core/task-notification.js +146 -17
  366. package/dist/core/task-registry-agent.d.ts +18 -12
  367. package/dist/core/task-registry-agent.js +19 -6
  368. package/dist/core/task-registry-monitor.d.ts +7 -0
  369. package/dist/core/task-registry-monitor.js +28 -1
  370. package/dist/core/task-registry-shared.d.ts +43 -3
  371. package/dist/core/task-registry-shared.js +21 -7
  372. package/dist/core/task-registry-workflow.js +1 -1
  373. package/dist/core/task-registry.d.ts +50 -35
  374. package/dist/core/task-registry.js +64 -23
  375. package/dist/core/task-result.d.ts +3 -12
  376. package/dist/core/task-spec.d.ts +15 -7
  377. package/dist/core/task-stream.d.ts +1 -1
  378. package/dist/core/terminal-cause.d.ts +10 -0
  379. package/dist/core/tool-catalog-entries.js +1 -1
  380. package/dist/core/tool-check-reading.d.ts +1 -0
  381. package/dist/core/tool-check-reading.js +3 -3
  382. package/dist/core/tool-face-reader.d.ts +7 -6
  383. package/dist/core/tool-face-reader.js +4 -3
  384. package/dist/core/tool-name-aliases.d.ts +19 -0
  385. package/dist/core/tool-name-aliases.js +54 -2
  386. package/dist/core/tool-policy.d.ts +21 -4
  387. package/dist/core/tool-policy.js +1 -1
  388. package/dist/core/tool-registry.d.ts +5 -5
  389. package/dist/core/tool-registry.js +2 -2
  390. package/dist/core/tool-result-store.d.ts +88 -5
  391. package/dist/core/tool-result-store.js +51 -12
  392. package/dist/core/tool-roster.d.ts +112 -5
  393. package/dist/core/tool-roster.js +42 -1
  394. package/dist/core/tool-spec.d.ts +23 -5
  395. package/dist/core/trace.d.ts +0 -1
  396. package/dist/core/types.d.ts +5 -5
  397. package/dist/core/types.js +2 -2
  398. package/dist/core/untrusted-text.js +1 -1
  399. package/dist/core/user-attachment.d.ts +10 -5
  400. package/dist/core/user-attachment.js +15 -7
  401. package/dist/core/wiring-manifest.d.ts +6 -3
  402. package/dist/engine/compaction/compaction.js +29 -3
  403. package/dist/engine/execution-env/node-execution-env.d.ts +11 -5
  404. package/dist/engine/execution-env/node-execution-env.js +21 -13
  405. package/dist/engine/harness/agent-harness.d.ts +26 -3
  406. package/dist/engine/harness/agent-harness.js +49 -16
  407. package/dist/engine/harness/messages.d.ts +3 -1
  408. package/dist/engine/harness/messages.js +3 -2
  409. package/dist/engine/harness/types.d.ts +119 -28
  410. package/dist/engine/llm/rejected-images.d.ts +46 -0
  411. package/dist/engine/llm/rejected-images.js +54 -0
  412. package/dist/engine/llm/tool-turns.d.ts +2 -1
  413. package/dist/engine/llm/types.d.ts +18 -7
  414. package/dist/engine/loop/agent-loop.d.ts +20 -12
  415. package/dist/engine/loop/agent-loop.js +205 -36
  416. package/dist/engine/loop/types.d.ts +12 -3
  417. package/dist/engine/lsp/node-lsp-manager.d.ts +3 -3
  418. package/dist/engine/lsp/node-lsp-manager.js +32 -13
  419. package/dist/engine/session/path-to-root.d.ts +38 -0
  420. package/dist/engine/session/path-to-root.js +39 -0
  421. package/dist/engine/session/storage-base.js +4 -21
  422. package/dist/index.d.ts +35 -21
  423. package/dist/index.js +26 -17
  424. package/dist/internal/harness-types.d.ts +1 -1
  425. package/dist/internal/harness.d.ts +1 -0
  426. package/dist/internal/llm.d.ts +1 -0
  427. package/dist/orchestration/run-workflow-tool.d.ts +9 -3
  428. package/dist/orchestration/run-workflow-tool.js +59 -29
  429. package/dist/orchestration/workflow-governance.d.ts +1 -1
  430. package/dist/orchestration/workflow-governance.js +2 -1
  431. package/dist/orchestration/workflow-observe.d.ts +17 -1
  432. package/dist/orchestration/workflow-observe.js +20 -0
  433. package/dist/orchestration/workflow-types.d.ts +32 -7
  434. package/dist/orchestration/workflow.d.ts +4 -0
  435. package/dist/orchestration/workflow.js +762 -491
  436. package/dist/prompts/default.d.ts +1 -10
  437. package/dist/prompts/default.js +0 -2
  438. package/dist/shell/counting-pass.d.ts +50 -0
  439. package/dist/shell/counting-pass.js +502 -0
  440. package/dist/shell/lex.d.ts +4 -2
  441. package/dist/shell/lex.js +93 -34
  442. package/dist/shell/shell-words.d.ts +1 -1
  443. package/dist/shell/shell-words.js +7 -6
  444. package/dist/stores/file/background-agent-store.d.ts +1 -1
  445. package/dist/stores/file/background-agent-store.js +3 -1
  446. package/dist/stores/file/checkpoint-store.d.ts +127 -2
  447. package/dist/stores/file/checkpoint-store.js +19 -14
  448. package/dist/stores/file/file-history-store.d.ts +1 -1
  449. package/dist/stores/file/file-history-store.js +3 -1
  450. package/dist/stores/file/index.d.ts +4 -3
  451. package/dist/stores/file/index.js +17 -8
  452. package/dist/stores/file/mailbox-store.d.ts +1 -1
  453. package/dist/stores/file/mailbox-store.js +9 -11
  454. package/dist/stores/file/memory-store.d.ts +1 -1
  455. package/dist/stores/file/memory-store.js +3 -1
  456. package/dist/stores/file/session-policy-store.d.ts +1 -1
  457. package/dist/stores/file/session-policy-store.js +3 -1
  458. package/dist/stores/file/session-store.d.ts +1 -1
  459. package/dist/stores/file/session-store.js +3 -1
  460. package/dist/stores/file/shared-ledger.d.ts +26 -0
  461. package/dist/stores/file/shared-ledger.js +38 -9
  462. package/dist/stores/file/tool-result-store.d.ts +20 -2
  463. package/dist/stores/file/tool-result-store.js +74 -6
  464. package/dist/stores/file/usage-window-store.d.ts +1 -1
  465. package/dist/stores/file/usage-window-store.js +3 -1
  466. package/dist/stores/file/workflow-journal-store.d.ts +1 -11
  467. package/dist/stores/file/workflow-journal-store.js +3 -2
  468. package/dist/tools/fs/containment-face.d.ts +5 -0
  469. package/dist/tools/fs/encoding.d.ts +13 -4
  470. package/dist/tools/fs/encoding.js +17 -2
  471. package/dist/tools/fs/fs-bash-background-text.d.ts +7 -0
  472. package/dist/tools/fs/fs-bash-background-text.js +1 -0
  473. package/dist/tools/fs/fs-bash.d.ts +14 -4
  474. package/dist/tools/fs/fs-bash.js +29 -35
  475. package/dist/tools/fs/fs-pdf.d.ts +2 -2
  476. package/dist/tools/fs/fs-pdf.js +26 -21
  477. package/dist/tools/fs/fs-read.d.ts +5 -4
  478. package/dist/tools/fs/fs-read.js +35 -18
  479. package/dist/tools/fs/fs-search-tools.js +4 -1
  480. package/dist/tools/fs/fs-shared.d.ts +11 -13
  481. package/dist/tools/fs/fs-shared.js +11 -7
  482. package/dist/tools/fs/fs-write.js +5 -5
  483. package/dist/tools/fs/index.d.ts +14 -8
  484. package/dist/tools/fs/index.js +13 -5
  485. package/dist/tools/fs/program-read-model.d.ts +13 -0
  486. package/dist/tools/fs/program-read-model.js +15 -0
  487. package/dist/tools/fs/program-read-model.rows.js +1 -1
  488. package/dist/tools/fs/read-deny.d.ts +13 -10
  489. package/dist/tools/fs/read-deny.js +25 -5
  490. package/dist/tools/fs/read-floor.d.ts +62 -0
  491. package/dist/tools/fs/read-floor.js +58 -0
  492. package/dist/tools/fs/removal-targets.d.ts +9 -4
  493. package/dist/tools/fs/removal-targets.js +17 -9
  494. package/dist/tools/fs/search.d.ts +3 -3
  495. package/dist/tools/fs/search.js +4 -4
  496. package/dist/tools/fs/shell-read-check.d.ts +1 -1
  497. package/dist/tools/fs/shell-read-check.js +2 -1
  498. package/dist/tools/fs/shell-read-judge.d.ts +16 -8
  499. package/dist/tools/fs/shell-read-judge.js +10 -6
  500. package/dist/tools/fs/shell-read-plan.d.ts +6 -1
  501. package/dist/tools/fs/shell-read-plan.js +22 -15
  502. package/dist/tools/fs/shell-read-start.js +1 -0
  503. package/dist/tools/fs/shell-reentry-text.d.ts +15 -1
  504. package/dist/tools/fs/shell-reentry-text.js +25 -3
  505. package/dist/tools/monitor.d.ts +9 -4
  506. package/dist/tools/monitor.js +17 -8
  507. package/dist/tools/scheduler-tools.js +42 -4
  508. package/dist/tools/web.d.ts +0 -10
  509. package/dist/tools/web.js +1 -4
  510. package/package.json +5 -2
  511. package/test/export-surface.snapshot.json +161 -21
  512. package/wire-changes/core-stores-sql@7.59.0.json +29 -0
  513. package/wire-changes/core-stores-sql@7.60.0.json +30 -0
  514. package/wire-changes/core@7.59.0.json +2459 -0
  515. package/wire-changes/core@7.60.0.json +3274 -0
  516. package/wire-changes/mods-kernel@7.59.0.json +29 -0
  517. package/wire-changes/mods-kernel@7.60.0.json +62 -0
  518. package/wire-changes/primitives@7.59.0.json +29 -0
  519. package/wire-changes/primitives@7.60.0.json +30 -0
@@ -5,20 +5,22 @@ import { CheckpointError, readPendingSteerQueue, realApprovalOrgFact, remainingB
5
5
  import { normalizePersistedRuleHit } from "../rule-lane-reads.js";
6
6
  import { decidersNote, SETTLEMENT_NOBODY_JUDGED } from "../gate-outcome.js";
7
7
  import { formatHookFeedback } from "../hooks.js";
8
- import { classicEventBase, failedHandlerClause, screenUserPrompt } from "../mods/stations.js";
8
+ import { classicEventBase, failedHandlerClause, legEventsOf, openSubagent, screenUserPrompt } from "../mods/stations.js";
9
+ import { offeredAgentListing } from "../mods/agent-stations.js";
9
10
  import { buildAppliedHumanInputEvent, buildHumanInputEvent, projectHumanInput } from "../human-input-projection.js";
10
11
  import { humanInputAttachmentsOf, readObjectiveAttachments, userAttachmentDeclarations } from "../user-attachment.js";
11
12
  import { readToolCallArguments, uuidv7 } from "../../internal/harness.js";
12
13
  import { ORG_ADJUDICATION_TIMEOUT_MS, settleOrgVerdictWithin } from "../permission-rule-org.js";
13
14
  import { applyPersistedTightening, disclosedRuleSet } from "../persisted-rule-arms.js";
14
- import { argsReadBy, stampArgsReading } from "../effective-path-target.js";
15
- import { skillRowRefusal } from "../skill-grant.js";
15
+ import { argsReadBy, carryArgsReadFrom, stampArgsReading } from "../effective-path-target.js";
16
+ import { skillGrantBindingMembers, skillRowRefusal } from "../skill-grant.js";
17
+ import { requestGrantBinding } from "../skill-grant-binding.js";
16
18
  import { judgeApprovalObject } from "../approval-object.js";
17
19
  import { SKILL_TOOL_NAME } from "./synthetic-tools.js";
18
20
  import { computeCostMicroUsd } from "../pricing.js";
19
21
  import { mintSystemReminder } from "../reminder-mint.js";
20
22
  import { hasDestroy } from "../remote-env.js";
21
- import { advertisedWritableRootsSeat, attestationOf, exemptRootsSeat, humanRefusalSentence, licenseCovers, ownedReading, policyCannotAnswer, policyRefusalMessage, refuseOutOfContractDecision } from "../tool-policy.js";
23
+ import { advertisedWritableRootsSeat, attestationOf, exemptRootsSeat, humanRefusalSentence, licenseCovers, ownArgs, ownedReading, policyCannotAnswer, policyRefusalMessage, refuseOutOfContractDecision } from "../tool-policy.js";
22
24
  import { failedJudgmentDeny } from "./policy-throw.js";
23
25
  import { pathDenialCardOf } from "../../tools/fs/safety.js";
24
26
  import { callFaceSeat, parkedRowLiveFace, rosterEntryNamed, rowMember } from "../tool-roster.js";
@@ -30,7 +32,7 @@ import { legContextOverlayOption } from "./compaction-call-options.js";
30
32
  import { mintOutputStyleReminder, owedPostureText } from "./compaction-restate.js";
31
33
  import { advisorFrameText, registerAdvisorReceipt } from "./advisor-instructions.js";
32
34
  import { resumeContinuation } from "./decide-continuation.js";
33
- import { editRewrittenSentence, sameBytes } from "../rewrite-rejudge.js";
35
+ import { sameBytes } from "../rewrite-rejudge.js";
34
36
  import { approvalWordsOf, owedApprovalWords, withApprovalWords } from "./approval-feedback.js";
35
37
  import { chainCannotJudge } from "./call-hook-stations.js";
36
38
  import { settleExecutionRecord } from "./execution-record.js";
@@ -40,7 +42,7 @@ import { withGateTimeout } from "../gate-bounded-await.js";
40
42
  import { readStationAnswer } from "../shell-read-silence.js";
41
43
  import { resolveGitLegDelivery, wrapGitFrame } from "./git-leg-delivery.js";
42
44
  import { GIT_STATUS_ECHO_PREVIEW } from "./git-status-frame.js";
43
- import { toImageContent } from "./image.js";
45
+ import { toImageContents } from "./image.js";
44
46
  import { maybeHumanRejectionHalt } from "./prepare-gate-stations.js";
45
47
  import { nextHumanInputSeq } from "./steer-admission.js";
46
48
  import { settleTeardownLeg } from "./teardown-bounded.js";
@@ -53,7 +55,7 @@ import { thrownMarksOf } from "../thrown-value.js";
53
55
  import { egressThrownText, egressValue } from "../untrusted-egress.js";
54
56
  import { ruleSourcePhrase } from "../rule-denial-sentence.js";
55
57
  export async function runLeg(input) {
56
- const { spec, queue, prepared, resume, rs, entryActor, effectiveTimeoutMs, timeout, pushContent, ident, emitCommitted, writeFamilyOf, startedToolCallIds, announceWorkspaceMove, withBrainSinks, flushGitMirror, loopLatch, notificationLane, unsubscribeTaskNotifications, unsubGitRetry, unsubBoundary, unsub, runner, next } = input;
58
+ const { spec, queue, prepared, resume, rs, entryActor, operatorObjective, effectiveTimeoutMs, timeout, pushContent, ident, emitCommitted, writeFamilyOf, startedToolCallIds, announceWorkspaceMove, withBrainSinks, flushGitMirror, loopLatch, notificationLane, unsubscribeTaskNotifications, unsubGitRetry, unsubBoundary, unsub, runner, next } = input;
57
59
  let final;
58
60
  let threw;
59
61
  let abortedLive = false;
@@ -305,31 +307,39 @@ export async function runLeg(input) {
305
307
  const projectedObjective = projectHumanInput({ text: spec.objective, actor: objectiveActor, source: "objective" });
306
308
  let effectiveObjective = projectedObjective;
307
309
  let promptBlocked = false;
308
- const screen = await screenUserPrompt(prepared.modBus, {
309
- ...classicEventBase(prepared.hookIdentity, prepared.permissionMode.observed),
310
- prompt: spec.objective,
311
- source: "objective",
312
- ...(objectiveActor !== undefined ? { actor: snapshotActorAssertion(objectiveActor) } : {}),
313
- ...(prepared.userAttachments !== undefined ? { userAttachments: userAttachmentDeclarations(prepared.userAttachments) } : {}),
314
- }, prepared.abortController.signal);
315
- if (screen?.kind === "aborted") {
316
- holdPrompt(prepared.blockedRef, prepared.reminderMark, "cancelled", `the task was cancelled while the deployment's userPromptSubmit hook was still screening this prompt; ` +
317
- `the prompt was NOT submitted (fail-closed)`);
318
- promptBlocked = true;
319
- }
320
- else if (screen?.kind === "failed") {
321
- holdPrompt(prepared.blockedRef, prepared.reminderMark, screen.cause === "timeout" ? "timeout" : "crashed", `the deployment's userPromptSubmit hook ${failedHandlerClause(screen)} while screening this prompt; the prompt was NOT submitted (fail-closed)`);
322
- promptBlocked = true;
323
- }
324
- else if (screen?.block) {
325
- holdPrompt(prepared.blockedRef, prepared.reminderMark, "block", screen.block);
326
- promptBlocked = true;
310
+ const objectiveEvents = legEventsOf(prepared.hookIdentity, operatorObjective);
311
+ if (objectiveEvents.screen !== undefined) {
312
+ const screen = await screenUserPrompt(prepared.modBus, {
313
+ ...classicEventBase(prepared.hookIdentity, prepared.permissionMode.observed),
314
+ prompt: spec.objective,
315
+ source: "objective",
316
+ ...(objectiveActor !== undefined ? { actor: snapshotActorAssertion(objectiveActor) } : {}),
317
+ ...(prepared.userAttachments !== undefined ? { userAttachments: userAttachmentDeclarations(prepared.userAttachments) } : {}),
318
+ }, prepared.abortController.signal);
319
+ if (screen?.kind === "aborted") {
320
+ holdPrompt(prepared.blockedRef, prepared.reminderMark, "cancelled", `the task was cancelled while the deployment's userPromptSubmit hook was still screening this prompt; ` +
321
+ `the prompt was NOT submitted (fail-closed)`);
322
+ promptBlocked = true;
323
+ }
324
+ else if (screen?.kind === "failed") {
325
+ holdPrompt(prepared.blockedRef, prepared.reminderMark, screen.cause === "timeout" ? "timeout" : "crashed", `the deployment's userPromptSubmit hook ${failedHandlerClause(screen)} while screening this prompt; the prompt was NOT submitted (fail-closed)`);
326
+ promptBlocked = true;
327
+ }
328
+ else if (screen?.block) {
329
+ holdPrompt(prepared.blockedRef, prepared.reminderMark, "block", screen.block);
330
+ promptBlocked = true;
331
+ }
332
+ else if (screen?.additionalContext) {
333
+ effectiveObjective = `${formatHookFeedback(screen.additionalContext, prepared.reminderMark)}\n\n${projectedObjective}`;
334
+ }
327
335
  }
328
- else if (screen?.additionalContext) {
329
- effectiveObjective = `${formatHookFeedback(screen.additionalContext, prepared.reminderMark)}\n\n${projectedObjective}`;
336
+ if (objectiveEvents.start !== undefined && !promptBlocked) {
337
+ const start = await openSubagent(prepared.modBus, prepared.hookIdentity, prepared.permissionMode.observed, prepared.abortController.signal);
338
+ if (start?.additionalContext)
339
+ effectiveObjective = `${formatHookFeedback(start.additionalContext, prepared.reminderMark)}\n\n${effectiveObjective}`;
330
340
  }
331
341
  const objectiveInputId = uuidv7();
332
- const { frames: attachmentFrames, chars: attachmentChars } = await readObjectiveAttachments(prepared, objectiveInputId, promptBlocked, { overlay: () => legContextOverlayOption(prepared, runner).contextOverlay, objectiveChars: effectiveObjective.length });
342
+ const { frames: attachmentFrames, chars: attachmentChars } = await readObjectiveAttachments(prepared, objectiveInputId, promptBlocked, { overlay: () => legContextOverlayOption(prepared, runner).contextOverlay, objectiveChars: effectiveObjective.length }, runner.deps.imageProcessor);
333
343
  let gitLegDelivered;
334
344
  if (!promptBlocked) {
335
345
  const gitBody = await resolveGitLegDelivery(prepared, undefined, (err) => {
@@ -361,8 +371,9 @@ export async function runLeg(input) {
361
371
  firstFrames.push({ source: "mcp_unavailable", body: unavailable.body, commit: () => settleMcpUnavailable(prepared, unavailable.entries), disclose: () => undefined });
362
372
  if (rs.attach.attachState !== undefined) {
363
373
  const attach = rs.attach.attachState;
364
- if (rs.attach.agentListingOn && prepared.agentListing !== undefined) {
365
- const listing = prepared.agentListing;
374
+ const offeredListing = !rs.attach.agentListingOn ? undefined : prepared.modBus.hasHandlers("agent.offer") ? await offeredAgentListing(prepared.modBus, prepared.agentListing, prepared.abortController.signal) : prepared.agentListing;
375
+ if (offeredListing !== undefined) {
376
+ const listing = offeredListing;
366
377
  const frame = renderAgentListingFrame(attach, listing.entries, listing.toolName, listing.models, listing.budget);
367
378
  if (frame !== undefined) {
368
379
  firstFrames.push({
@@ -447,9 +458,7 @@ export async function runLeg(input) {
447
458
  prepared.abortController.abort();
448
459
  }
449
460
  else {
450
- const images = spec.images
451
- ? await Promise.all(spec.images.map((img) => toImageContent(img, prepared.hostFloor)))
452
- : undefined;
461
+ const images = spec.images ? await toImageContents(spec.images, prepared.hostFloor, runner.deps.imageProcessor, prepared.imageUnprocessed) : undefined;
453
462
  if (gitLegDelivered !== undefined) {
454
463
  const delivered = gitLegDelivered;
455
464
  if (delivered.standalone)
@@ -584,12 +593,18 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
584
593
  const reading = liveTool === undefined ? undefined : ownedReading((a) => readToolCallArguments(liveTool, { type: "toolCall", id: pendingAction.toolCallId, name: pendingAction.toolName, arguments: {} }, a));
585
594
  const beltFace = () => { const f = parkedRowLiveFace(prepared.toolRosterDeltas.current, pendingAction); if (f !== undefined && reading !== undefined)
586
595
  stampArgsReading(f, reading); return f; };
587
- const tryRead = (v) => { try {
588
- return { args: reading === undefined ? v : argsReadBy(reading, v) };
589
- }
590
- catch (error) {
591
- return { args: v, unread: { error } };
592
- } };
596
+ const tryRead = (v) => {
597
+ try {
598
+ const read = reading === undefined ? v : argsReadBy(reading, v);
599
+ const owned = ownArgs(read);
600
+ if (owned.ok && owned.value !== read)
601
+ carryArgsReadFrom(read, owned.value);
602
+ return { args: owned.ok ? owned.value : read };
603
+ }
604
+ catch (error) {
605
+ return { args: v, unread: { error } };
606
+ }
607
+ };
593
608
  const decided = outcome.decision === "allow" ? tryRead(humanRewrite !== undefined ? humanRewrite : pendingAction.args) : { args: humanRewrite !== undefined ? humanRewrite : pendingAction.args };
594
609
  const resolvedArgs = decided.args;
595
610
  const pendingLabel = (() => { const l = liveTool?.label; return l !== undefined && l !== pendingAction.toolName ? { label: l } : {}; })();
@@ -600,9 +615,9 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
600
615
  occurrences.gateRound(pendingAction.toolCallId, decidedGate, frozenInputSnapshot(resolvedArgs));
601
616
  let notExecuted = false;
602
617
  const resultRow = (text, isError) => withRowNotExecuted(toolResultMsg(pendingAction.toolCallId, pendingAction.toolName, text, isError), notExecuted);
603
- const settleEnd = async (isError, result, refusedBy, neverRan) => {
618
+ const settleEnd = async (isError, result, refusedBy, neverRan, extension) => {
604
619
  if (refusedBy !== undefined)
605
- occurrences.refuse(pendingAction.toolCallId, refusedBy);
620
+ occurrences.refuse(pendingAction.toolCallId, refusedBy, extension);
606
621
  const settled = emitSettled(occurrences, callStart, { result, isError, ...(neverRan ? { notExecuted: true } : {}) }, { push: emit, structured: prepared.structuredProjector, mediaByteCapBytes: runner.deps.mediaByteCapBytes });
607
622
  notExecuted = settled.notExecuted === true;
608
623
  const gate = settled.gate ?? decidedGate;
@@ -648,22 +663,14 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
648
663
  const screened = await prepared.approvedCallScreen?.({ toolCallId: pendingAction.toolCallId, toolName: pendingAction.toolName, args: structuredClone(resolvedArgs), decidedBy: outcome.hostDecision.decidedBy });
649
664
  if (screened !== undefined && "refused" in screened) {
650
665
  const hookDenial = formatHookFeedback(screened.refused, prepared.reminderMark);
651
- await settleEnd(true, { content: hookDenial }, "hook");
666
+ await settleEnd(true, { content: hookDenial }, "hook", undefined, screened.extension);
652
667
  emitCommitted(await prepared.session.appendMessage(resultRow(hookDenial, true)), "toolResult", pendingAction.toolCallId);
653
668
  return;
654
669
  }
655
- const rescreened = screened !== undefined ? tryRead(screened.args) : undefined;
656
- if (rescreened?.unread !== undefined)
657
- return settleUnreadable(rescreened.unread.error, "the arguments a PreToolUse hook rewrote it to");
658
- if (humanRewrite !== undefined && rescreened !== undefined && !sameBytes({}, resolvedArgs, rescreened.args)) {
659
- const text = formatHookFeedback(`${editRewrittenSentence(pendingAction.toolName)}, which a PreToolUse hook wrote — this approval is spent; the call has to be re-issued.`, prepared.reminderMark);
660
- await settleEnd(true, { content: text, details: { editRewritten: { acceptableForm: rescreened.args } } }, "hook");
661
- return emitCommitted(await prepared.session.appendMessage(resultRow(text, true)), "toolResult", pendingAction.toolCallId);
662
- }
663
- const executedArgs = rescreened !== undefined ? rescreened.args : resolvedArgs;
670
+ const executedArgs = resolvedArgs;
664
671
  const unseen = !licenseCovers(pendingAction.boundInputHash, executedArgs);
665
672
  let beltReading;
666
- const beltReq = () => ({ toolName: pendingAction.toolName, args: executedArgs, toolCallId: pendingAction.toolCallId, ...callFaceSeat(beltFace()), budget: beltBudget, ...(prepared.cwdRef !== undefined ? { cwd: prepared.cwdRef.current } : {}), ...(prepared.handsRoot !== undefined ? { root: prepared.handsRoot } : {}), ...advertisedWritableRootsSeat(prepared.advertisedWritableDirs), ...exemptRootsSeat(prepared.exemptRoots), ...(beltReading !== undefined ? { targetReading: beltReading } : {}) });
673
+ const beltReq = () => ({ toolName: pendingAction.toolName, args: executedArgs, toolCallId: pendingAction.toolCallId, ...callFaceSeat(beltFace()), budget: beltBudget, ...(prepared.cwdRef !== undefined ? { cwd: prepared.cwdRef.current } : {}), ...(prepared.handsRoot !== undefined ? { root: prepared.handsRoot } : {}), ...advertisedWritableRootsSeat(prepared.advertisedWritableDirs), ...exemptRootsSeat(prepared.exemptRoots), ...(beltReading !== undefined ? { targetReading: beltReading } : {}), ...requestGrantBinding((call, args) => skillGrantBindingMembers(call, args, prepared.skillSpecs, SKILL_TOOL_NAME), pendingAction, executedArgs) });
667
674
  const unjudgeable = unseen ? chainCannotJudge(resume.cp.state.inheritedGate) : undefined;
668
675
  if (unjudgeable !== undefined) {
669
676
  const chainDenial = formatHookFeedback(`The approved tool call "${pendingAction.toolName}" was not executed: its input changed after the approval and the inherited ancestor chain cannot judge the changed input (${unjudgeable}). This approval is spent — the call has to be re-issued.`, prepared.reminderMark);
@@ -700,8 +707,8 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
700
707
  : personUnanswered
701
708
  ? " (the call as it would run requires a person's approval, and this decision was the deployment's policy)"
702
709
  : " (the policy rewrote these bytes to a value that was not approved)";
703
- const editedDenial = formatHookFeedback(`${outcome.updatedInput !== undefined ? "The approver EDITED this call's input; the edited call" : "A PreToolUse hook REWROTE this approved call's input; the rewritten call"} is refused by the deployment's tool policy and was not executed${why}.`, prepared.reminderMark);
704
- const outlet = rechecked.action !== "deny" && !personUnanswered && humanRewrite !== undefined && rewrite?.unread === undefined && rewrite !== undefined ? { details: { editRewritten: { acceptableForm: rewrite.args } } } : denialCard(rechecked);
710
+ const editedDenial = formatHookFeedback(`The approver EDITED this call's input; the edited call is refused by the deployment's tool policy and was not executed${why}.`, prepared.reminderMark);
711
+ const outlet = rechecked.action !== "deny" && !personUnanswered && rewrite?.unread === undefined && rewrite !== undefined ? { details: { editRewritten: { acceptableForm: rewrite.args } } } : denialCard(rechecked);
705
712
  await settleEnd(true, { content: editedDenial, ...outlet }, "policy");
706
713
  emitCommitted(await prepared.session.appendMessage(resultRow(editedDenial, true)), "toolResult", pendingAction.toolCallId);
707
714
  return;
@@ -838,7 +845,7 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
838
845
  if ((prepared.crossBoundary?.storeWaits() ?? 0) === waited)
839
846
  break;
840
847
  }
841
- const args = executedArgs;
848
+ const args = structuredClone(executedArgs);
842
849
  screened?.admit();
843
850
  onExecuteStart?.(pendingAction.toolCallId);
844
851
  occurrences.release(pendingAction.toolCallId);
@@ -1,7 +1,7 @@
1
1
  import { type PeerInboundChainRef } from "../../agents/peer-admission.js";
2
2
  import type { PushQueue } from "../push-queue.js";
3
3
  import type { SessionStore } from "../session.js";
4
- import { type NotificationInjectionOutcome, type PendingSessionNotifications, type SystemInjectionPriority, type TaskNotificationPayload } from "../task-notification.js";
4
+ import { DeliveryObligations, type NotificationInjectionOutcome, type PendingSessionNotifications, type SystemInjectionPriority, type TaskNotificationPayload } from "../task-notification.js";
5
5
  import type { RunnerDeps, TaskEvent, TaskSpec } from "../types.js";
6
6
  import type { SessionReadFileStates } from "./session-read-file-states.js";
7
7
  import type { SessionModeSeats } from "./session-mode-seats.js";
@@ -59,5 +59,7 @@ export interface RunNotificationLaneResult {
59
59
  notificationLane: NotificationLaneBindings;
60
60
  /** The queue subscription's release; the leg lane's finally calls it right after flipping `live`. */
61
61
  unsubscribeTaskNotifications: () => void;
62
+ /** The terminal frames this lane is still owed by loop-type tasks admitted onto its sink — what a one-shot ending waits on. */
63
+ deliveryObligations: DeliveryObligations;
62
64
  }
63
65
  export declare function runNotificationLane<R>(input: RunNotificationLaneInput<R>): Promise<R>;
@@ -2,7 +2,7 @@ import { createPeerInboundChainRef, createPeerSelfRef } from "../../agents/peer-
2
2
  import { boundInputHashOf } from "../canonical-json.js";
3
3
  import { readPendingSteerQueue } from "../checkpoint-store.js";
4
4
  import { wakeOpening } from "../run-origin.js";
5
- import { createLiveNotificationLane, DurableAppendObligations, injectionLaneOf, isDelegatedAgentTerminal, isTerminalTaskNotification, renderTaskNotificationXml, routeOrParkNotification, SystemInjectionQueue, taskNotificationDedupKey } from "../task-notification.js";
5
+ import { bindDeliveryObligations, createLiveNotificationLane, DeliveryObligations, DurableAppendObligations, injectionLaneOf, isDelegatedAgentTerminal, isTerminalTaskNotification, renderTaskNotificationXml, routeOrParkNotification, SystemInjectionQueue, taskNotificationDedupKey } from "../task-notification.js";
6
6
  import { ToolDetachHub } from "../tool-detach.js";
7
7
  import { pendingContentAskCallId } from "./decide-continuation.js";
8
8
  export function runNotificationLane(input) {
@@ -116,6 +116,19 @@ async function runNotificationLaneAs(input, obligations) {
116
116
  const peerSelfRef = internals?.peerSelfRef ?? createPeerSelfRef(internals?.registryScope ?? spec.principal ?? "default");
117
117
  const peerInboundChainRef = internals?.peerInboundChainRef ?? createPeerInboundChainRef();
118
118
  const modelCatalog = runner.deps.models;
119
+ const deliveryObligations = new DeliveryObligations();
120
+ const laneSink = (notification, opts) => {
121
+ try {
122
+ upstreamTaskNotification?.(notification, opts);
123
+ }
124
+ catch {
125
+ }
126
+ const outcome = injectTaskNotification(notification, opts);
127
+ if (isTerminalTaskNotification(notification))
128
+ deliveryObligations.discharge(notification);
129
+ return outcome;
130
+ };
131
+ bindDeliveryObligations(laneSink, deliveryObligations);
119
132
  const prepared = await prepareTask(spec, runner.deps, sessions, prepareResume, {
120
133
  ...(internals ?? {}),
121
134
  peerSelfRef,
@@ -123,14 +136,7 @@ async function runNotificationLaneAs(input, obligations) {
123
136
  detachHub,
124
137
  sessionReadStates,
125
138
  sessionModeSeats,
126
- onTaskNotification: (notification, opts) => {
127
- try {
128
- upstreamTaskNotification?.(notification, opts);
129
- }
130
- catch {
131
- }
132
- return injectTaskNotification(notification, opts);
133
- },
139
+ onTaskNotification: laneSink,
134
140
  }, self, taskIdRef, holdSessionLock, legWrites);
135
141
  pendingSessionNotifications.bindSessionBox(prepared.sessionId, prepared.sessionBox);
136
142
  const notificationLane = {
@@ -159,7 +165,7 @@ async function runNotificationLaneAs(input, obligations) {
159
165
  },
160
166
  };
161
167
  try {
162
- return await next({ prepared, injectTaskNotification, deliveredAtTurnOpen, peerInboundChainRef, modelCatalog, notificationLane, unsubscribeTaskNotifications });
168
+ return await next({ prepared, injectTaskNotification, deliveredAtTurnOpen, peerInboundChainRef, modelCatalog, notificationLane, unsubscribeTaskNotifications, deliveryObligations });
163
169
  }
164
170
  finally {
165
171
  if (notificationSessionId !== undefined)
@@ -7,6 +7,7 @@ import { hasBackgroundShell, sweepRunBoundaryBackgroundShells } from "../backgro
7
7
  import { resolveCheckpointStore } from "../checkpoint-store.js";
8
8
  import { compensateUnstarted, reopenReasonOf, resumeStartupCauseOf, unstartedRowSentence } from "../resume-startup-cause.js";
9
9
  import { classicEventBase, observeClassic } from "../mods/stations.js";
10
+ import { raiseCompletedTurn, raiseSessionEnd } from "../mods/lifecycle-stations.js";
10
11
  import { modelCostToPricing } from "../pricing.js";
11
12
  import { hasDestroy, isIsolated } from "../remote-env.js";
12
13
  import { resolveTaskModel } from "../roles.js";
@@ -77,7 +78,6 @@ export async function runSettleAndTeardown(input) {
77
78
  const reminderDisclosuresActive = Object.keys(prepared.reminderDisclosureCounts).length > 0;
78
79
  if (rs.counters.finalVerifyInjections > 0 || rs.attach.attachmentsInjected > 0 || rs.counters.repetitionCuts > 0 || rs.counters.repetitionSpared > 0 || rs.counters.approachNoticesSent > 0 || reminderDisclosuresActive) {
79
80
  stats.mechanisms = {
80
- ...(rs.counters.finalVerifyInjections > 0 ? { finalVerifyInjected: true } : {}),
81
81
  ...(rs.counters.finalVerifyInjections > 0 ? { finalVerifyInjections: rs.counters.finalVerifyInjections } : {}),
82
82
  ...(rs.attach.attachmentsInjected > 0 ? { attachmentsInjected: rs.attach.attachmentsInjected } : {}),
83
83
  ...(rs.counters.approachNoticesSent > 0 ? { approachNoticesSent: rs.counters.approachNoticesSent } : {}),
@@ -190,6 +190,10 @@ export async function runSettleAndTeardown(input) {
190
190
  });
191
191
  if (taskIdRef !== undefined)
192
192
  taskIdRef.delegationTerminalOwed = undefined;
193
+ if (rs.turn.completed !== undefined)
194
+ await raiseCompletedTurn(prepared.modBus, rs.turn, prepared.hookIdentity, undefined);
195
+ if (prepared.modBus.hasHandlers("session.end"))
196
+ await raiseSessionEnd(prepared.modBus, prepared.hookIdentity, { reason: terminalFace.status, sessionId: prepared.sessionId });
193
197
  if (rs.degrade.degraded)
194
198
  result.degraded = rs.degrade.degraded;
195
199
  if (prepared.outputRef.set)
@@ -1,4 +1,5 @@
1
1
  import type { PushQueue } from "../push-queue.js";
2
+ import type { DeliveryObligations } from "../task-notification.js";
2
3
  import type { TaskEvent, TaskSpec } from "../types.js";
3
4
  import type { Stats } from "./assemble-result.js";
4
5
  import type { InstallingPhaseResult, Prepared, RunnerDepsSeat, RunState } from "./contracts.js";
@@ -23,6 +24,9 @@ export interface RunStopAndFinalVerifyInput {
23
24
  };
24
25
  /** borrowed-readonly — the monotonic walltime deadline (the clock lane's), read by the budget fill. */
25
26
  walltimeMonotonicDeadline: number | undefined;
27
+ /** borrowed-readonly — the terminal frames this leg's lane is still owed (the notification lane's book): a one-shot
28
+ * submission's ending waits on it. */
29
+ deliveryObligations: DeliveryObligations;
26
30
  /** borrowed-readonly — the Runner's deployment deps, read LIVE (`hooks` at resolution, `onError` in the gate). */
27
31
  runner: RunnerDepsSeat;
28
32
  }
@@ -1,11 +1,11 @@
1
1
  import { openSystemReminder } from "../reminder-mint.js";
2
2
  import { formatHookFeedback } from "../hooks.js";
3
- import { classicEventBase, dispatchClassic, stopEventOf, stringMembersAnswer, stringMembersOf } from "../mods/stations.js";
3
+ import { classicEventBase, dispatchClassic, legEventsOf, stringMembersAnswer, stringMembersOf } from "../mods/stations.js";
4
4
  import { asThrownError } from "../thrown-value.js";
5
5
  const STOP_HOOK_BLOCK_CAP = 8;
6
6
  export function runStopAndFinalVerify(input) {
7
- const { spec, prepared, queue, rs, stats, ident, walltimeMonotonicDeadline, runner } = input;
8
- const stopEvent = stopEventOf(prepared.hookIdentity);
7
+ const { spec, prepared, queue, rs, stats, ident, walltimeMonotonicDeadline, deliveryObligations, runner } = input;
8
+ const stopEvent = legEventsOf(prepared.hookIdentity).stop;
9
9
  const stopArmed = prepared.modBus.hasHandlers(stopEvent);
10
10
  const finalVerificationOn = spec.finalVerification === true;
11
11
  const finalVerifyBudgetFill = () => {
@@ -24,11 +24,19 @@ export function runStopAndFinalVerify(input) {
24
24
  const emitFinalVerifyEcho = (body) => {
25
25
  queue.push({ type: "steering_injected", source: "final_verification", preview: body.slice(0, 220), ...ident() });
26
26
  };
27
- if (stopArmed || finalVerificationOn) {
27
+ const owed = spec.oneShot === true ? deliveryObligations : undefined;
28
+ if (stopArmed || finalVerificationOn || owed !== undefined) {
28
29
  let consecutiveBlocks = 0;
30
+ const ending = () => prepared.abortController.signal.aborted || prepared.pausedRef.current !== undefined || prepared.batchHaltRef.current !== undefined;
29
31
  prepared.harness.setStopGate(async () => {
30
- if (prepared.abortController.signal.aborted || prepared.pausedRef.current !== undefined || prepared.batchHaltRef.current !== undefined)
32
+ if (ending())
31
33
  return [];
34
+ const pushedBack = stopArmed || finalVerificationOn ? await pushBack() : [];
35
+ if (pushedBack.length === 0)
36
+ await owed?.waitOut(prepared.abortController.signal, () => !ending() && prepared.harness.pendingInjectionCount() === 0, (wake) => prepared.harness.subscribe((e) => void (e.type === "queue_update" && wake())));
37
+ return pushedBack;
38
+ });
39
+ async function pushBack() {
32
40
  if (finalVerificationOn &&
33
41
  (rs.counters.finalVerifyInjections === 0 || (rs.counters.finalVerifyInjections === 1 && rs.counters.groundingSignalPreR9 && !rs.counters.groundingSignalPostR9)) &&
34
42
  rs.counters.wroteThisRun &&
@@ -149,7 +157,7 @@ export function runStopAndFinalVerify(input) {
149
157
  });
150
158
  }
151
159
  return messages;
152
- });
160
+ }
153
161
  }
154
162
  return {};
155
163
  }
@@ -19,7 +19,7 @@ import type { Model } from "../../internal/llm.js";
19
19
  import { type MaybeCompactOptions } from "../auto-compaction.js";
20
20
  import type { SessionStore } from "../session.js";
21
21
  import type { PushQueue } from "../push-queue.js";
22
- import type { Brain, OwedUserInputAccount, TaskEvent, TaskSpec } from "../types.js";
22
+ import { type Brain, type HeldUserInputs, type OwedUserInputAccount, type TaskEvent, type TaskSpec } from "../types.js";
23
23
  import { type Stats } from "./assemble-result.js";
24
24
  import type { EndOfTaskCompaction, Prepared, RunnerDepsSeat, RunState } from "./contracts.js";
25
25
  import type { CallerStopGate } from "./caller-stop-gate.js";
@@ -61,10 +61,7 @@ export interface RunTerminalAdoptionInput<R> {
61
61
  windowSafetyOptions: (mainModel: Model) => Pick<MaybeCompactOptions, "fallbackBudget" | "onWindowSafety">;
62
62
  /** borrowed-readonly — the held agent_end account, as the read face on the identity lane's Result. */
63
63
  undrainedUserAtEnd: {
64
- readonly current: {
65
- steer: number;
66
- followUp: number;
67
- } | undefined;
64
+ readonly current: HeldUserInputs | undefined;
68
65
  };
69
66
  /** borrowed-readonly — did the run end with a person's steer / follow-up still pending (the identity lane's read face)? Folded
70
67
  * into the answer-settled verdict this lane evaluates once. */
@@ -2,6 +2,7 @@ import { compactionFailureReason, compactionPassReport, DEFAULT_COMPACTION_INSTR
2
2
  import { eventDefaultOn } from "../../prompt-assembly/event-registry.js";
3
3
  import { appendInterruptionMarker, reconcileInterruptedSession } from "../session-reconcile.js";
4
4
  import { emitTrace } from "../trace.js";
5
+ import { parkedInputIdsOf } from "../types.js";
5
6
  import { answerSettled } from "./assemble-result.js";
6
7
  import { errorCodeOf } from "./terminal-account.js";
7
8
  import { awaitChargeWithSlowDisclosure, discloseUnevaluableWindow } from "./clock-and-limits.js";
@@ -79,6 +80,7 @@ export async function runTerminalAdoption(input) {
79
80
  }
80
81
  let migratedParked = { steer: 0, followUp: 0 };
81
82
  let carriedContinuation = 0;
83
+ const carriedContinuationInputIds = [];
82
84
  let carriedApproval = 0;
83
85
  let approvalRefusal;
84
86
  if (committedPause !== undefined && runner.deps.checkpointStore !== undefined) {
@@ -101,8 +103,11 @@ export async function runTerminalAdoption(input) {
101
103
  carried.push(live);
102
104
  else if (approval)
103
105
  carriedApproval += 1;
104
- else
106
+ else {
105
107
  carriedContinuation += 1;
108
+ if (typeof input.inputId === "string")
109
+ carriedContinuationInputIds.push(input.inputId);
110
+ }
106
111
  }
107
112
  catch (parkErr) {
108
113
  runner.deps.onError?.(asThrownError(parkErr), {
@@ -118,9 +123,10 @@ export async function runTerminalAdoption(input) {
118
123
  break;
119
124
  }
120
125
  }
121
- migratedParked = prepared.harness.dropParkedUserInputs(carried);
126
+ const dropped = prepared.harness.dropParkedUserInputs(carried);
127
+ migratedParked = { steer: dropped.steer, followUp: dropped.followUp, inputIds: parkedInputIdsOf(dropped.records) };
122
128
  }
123
- const owedUserInput = { held: undrainedUserAtEnd.current, migrated: migratedParked, continuation: { frames: prepared.undeliveredContinuationRef.current.parkedSteers.filter((f) => !isApprovalWordsFrame(f)), carried: carriedContinuation, approval: { owed: prepared.undeliveredContinuationRef.current.parkedSteers.filter(isApprovalWordsFrame).length, carried: carriedApproval, ...(approvalRefusal !== undefined ? { refusal: approvalRefusal } : {}) } } };
129
+ const owedUserInput = { held: undrainedUserAtEnd.current, migrated: migratedParked, continuation: { frames: prepared.undeliveredContinuationRef.current.parkedSteers.filter((f) => !isApprovalWordsFrame(f)), carried: carriedContinuation, carriedInputIds: carriedContinuationInputIds, approval: { owed: prepared.undeliveredContinuationRef.current.parkedSteers.filter(isApprovalWordsFrame).length, carried: carriedApproval, ...(approvalRefusal !== undefined ? { refusal: approvalRefusal } : {}) } } };
124
130
  if (rs.attach.attachState?.postCompactPending === true && (rs.attach.attachmentsCfg?.backgroundTasks ?? eventDefaultOn("background_tasks")) === true) {
125
131
  emitTrace(rs.telemetry.tracer, () => ({ kind: "compaction.announce_dropped", version: 1, taskId: rs.telemetry.taskId, ts: Date.now() }));
126
132
  }