@sema-agent/core 7.60.0 → 7.62.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 (560) hide show
  1. package/CHANGELOG.md +917 -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 +71 -12
  6. package/dist/agents/cascade.js +61 -21
  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-held-queue.d.ts +27 -4
  17. package/dist/agents/peer-held-queue.js +81 -36
  18. package/dist/agents/peer-notice-route.d.ts +1 -1
  19. package/dist/agents/peer-notice-route.js +4 -3
  20. package/dist/agents/peer-notices.d.ts +4 -4
  21. package/dist/agents/peer-notices.js +8 -4
  22. package/dist/agents/peer-session-drain.d.ts +8 -1
  23. package/dist/agents/peer-session-drain.js +49 -10
  24. package/dist/agents/repair-loop.js +16 -6
  25. package/dist/agents/retain-ledger.js +3 -1
  26. package/dist/agents/roster-store.d.ts +1 -1
  27. package/dist/agents/roster-store.js +7 -4
  28. package/dist/agents/send-message-tool.d.ts +8 -10
  29. package/dist/agents/send-message-tool.js +43 -23
  30. package/dist/agents/subagent-completion-gate.d.ts +35 -0
  31. package/dist/agents/subagent-completion-gate.js +62 -0
  32. package/dist/agents/subagent-steps.d.ts +7 -6
  33. package/dist/agents/subagent.d.ts +36 -41
  34. package/dist/agents/subagent.js +245 -200
  35. package/dist/agents/suspend-guard.d.ts +47 -16
  36. package/dist/agents/suspend-guard.js +13 -4
  37. package/dist/agents/verify.d.ts +41 -14
  38. package/dist/agents/verify.js +41 -30
  39. package/dist/brain/anthropic.js +1 -0
  40. package/dist/brain/errors.d.ts +7 -1
  41. package/dist/brain/errors.js +6 -0
  42. package/dist/brain/failover.js +2 -1
  43. package/dist/brain/open-responses.js +1 -0
  44. package/dist/brain/openai.js +1 -0
  45. package/dist/brain/provider-dialect.d.ts +10 -0
  46. package/dist/brain/provider-dialect.js +13 -2
  47. package/dist/brain/stream-engine.d.ts +3 -0
  48. package/dist/brain/stream-engine.js +4 -0
  49. package/dist/core/agent-state.d.ts +1 -1
  50. package/dist/core/allow-entry.d.ts +59 -23
  51. package/dist/core/allow-entry.js +131 -38
  52. package/dist/core/ask-origin.d.ts +79 -0
  53. package/dist/core/ask-origin.js +76 -0
  54. package/dist/core/ask-question.d.ts +19 -13
  55. package/dist/core/ask-question.js +8 -2
  56. package/dist/core/auto-compaction.d.ts +2 -0
  57. package/dist/core/auto-compaction.js +2 -1
  58. package/dist/core/auto-mode.js +3 -5
  59. package/dist/core/background-agent-store.d.ts +7 -5
  60. package/dist/core/background-agent-store.js +12 -11
  61. package/dist/core/checkpoint-features.d.ts +722 -0
  62. package/dist/core/checkpoint-features.js +98 -0
  63. package/dist/core/checkpoint-requirements.d.ts +33 -5
  64. package/dist/core/checkpoint-requirements.js +18 -5
  65. package/dist/core/checkpoint-row-verdict.d.ts +99 -0
  66. package/dist/core/checkpoint-row-verdict.js +225 -0
  67. package/dist/core/checkpoint-store.d.ts +107 -738
  68. package/dist/core/checkpoint-store.js +45 -143
  69. package/dist/core/child-clamp-seats.d.ts +3 -2
  70. package/dist/core/child-clamp-seats.js +4 -3
  71. package/dist/core/closest-name.d.ts +13 -0
  72. package/dist/core/closest-name.js +35 -0
  73. package/dist/core/context-settings.js +3 -5
  74. package/dist/core/cross-boundary-taint.d.ts +1 -1
  75. package/dist/core/decision-receipt.d.ts +14 -1
  76. package/dist/core/decision-receipt.js +6 -3
  77. package/dist/core/delegation-frames.d.ts +13 -9
  78. package/dist/core/effective-path-target.js +2 -3
  79. package/dist/core/engine-attestation.d.ts +11 -1
  80. package/dist/core/engine-attestation.js +2 -0
  81. package/dist/core/engine-notice.d.ts +68 -21
  82. package/dist/core/engine-notice.js +9 -2
  83. package/dist/core/file-history-retention.d.ts +8 -0
  84. package/dist/core/file-history-retention.js +14 -11
  85. package/dist/core/file-history-store.d.ts +31 -1
  86. package/dist/core/file-history-store.js +31 -2
  87. package/dist/core/frame-settlement.d.ts +10 -0
  88. package/dist/core/frame-settlement.js +6 -1
  89. package/dist/core/fs-write-gate-policy.d.ts +3 -3
  90. package/dist/core/fs-write-gate-policy.js +8 -7
  91. package/dist/core/gate-fold.js +4 -3
  92. package/dist/core/gate-lanes.js +7 -4
  93. package/dist/core/gate-outcome.d.ts +40 -1
  94. package/dist/core/gate-outcome.js +10 -0
  95. package/dist/core/git-worktree-env.d.ts +7 -3
  96. package/dist/core/git-worktree-env.js +16 -13
  97. package/dist/core/governance-codes.d.ts +14 -4
  98. package/dist/core/governance-codes.js +19 -4
  99. package/dist/core/hooks.d.ts +25 -4
  100. package/dist/core/hooks.js +11 -4
  101. package/dist/core/host-floor.js +3 -5
  102. package/dist/core/human-input-projection.d.ts +1 -0
  103. package/dist/core/human-input-projection.js +3 -0
  104. package/dist/core/image-admission.d.ts +47 -7
  105. package/dist/core/image-admission.js +35 -4
  106. package/dist/core/input-author.d.ts +36 -0
  107. package/dist/core/input-author.js +39 -0
  108. package/dist/core/leg-identity.d.ts +62 -0
  109. package/dist/core/leg-identity.js +18 -0
  110. package/dist/core/locked-config.d.ts +4 -3
  111. package/dist/core/locked-config.js +5 -3
  112. package/dist/core/lsp.d.ts +5 -3
  113. package/dist/core/lsp.js +3 -2
  114. package/dist/core/mailbox-store.d.ts +85 -10
  115. package/dist/core/mailbox-store.js +31 -10
  116. package/dist/core/mcp-connection-pool.d.ts +6 -20
  117. package/dist/core/mcp-connection-pool.js +10 -28
  118. package/dist/core/mcp-failure.d.ts +76 -15
  119. package/dist/core/mcp-failure.js +60 -33
  120. package/dist/core/mcp-host-seat.d.ts +92 -53
  121. package/dist/core/mcp-host-seat.js +225 -46
  122. package/dist/core/mcp-probe.js +2 -2
  123. package/dist/core/mcp-server-link.d.ts +18 -6
  124. package/dist/core/mcp-server-link.js +19 -4
  125. package/dist/core/mcp-server-spec.d.ts +2 -1
  126. package/dist/core/mcp-session-end.d.ts +1 -2
  127. package/dist/core/mcp-session-end.js +1 -1
  128. package/dist/core/mcp.d.ts +6 -49
  129. package/dist/core/mcp.js +115 -111
  130. package/dist/core/media-byte-cap.d.ts +21 -46
  131. package/dist/core/media-byte-cap.js +55 -55
  132. package/dist/core/member-group.d.ts +7 -0
  133. package/dist/core/member-group.js +35 -0
  134. package/dist/core/memory-engine/consolidation-driver.d.ts +1 -1
  135. package/dist/core/memory-engine/consolidation.d.ts +1 -1
  136. package/dist/core/memory-engine/consolidation.js +7 -1
  137. package/dist/core/memory-engine/dual-root.d.ts +31 -0
  138. package/dist/core/memory-engine/dual-root.js +59 -11
  139. package/dist/core/memory-engine/engine.js +27 -24
  140. package/dist/core/memory-engine/file-backend.d.ts +13 -0
  141. package/dist/core/memory-engine/file-backend.js +35 -15
  142. package/dist/core/memory-engine/layout.d.ts +3 -0
  143. package/dist/core/memory-engine/layout.js +13 -3
  144. package/dist/core/memory-engine/memory-deployment.d.ts +110 -0
  145. package/dist/core/memory-engine/memory-deployment.js +182 -0
  146. package/dist/core/memory-engine/sync-client.d.ts +39 -18
  147. package/dist/core/memory-engine/sync-client.js +72 -14
  148. package/dist/core/memory-engine/sync-report.d.ts +7 -4
  149. package/dist/core/memory-engine/sync.d.ts +9 -1
  150. package/dist/core/memory-vector.d.ts +1 -1
  151. package/dist/core/memory.d.ts +10 -10
  152. package/dist/core/mode-policy.d.ts +8 -8
  153. package/dist/core/mode-policy.js +8 -6
  154. package/dist/core/mods/agent-stations.d.ts +39 -4
  155. package/dist/core/mods/agent-stations.js +59 -10
  156. package/dist/core/mods/classic-events.d.ts +9 -1
  157. package/dist/core/mods/dollar.d.ts +94 -1
  158. package/dist/core/mods/dollar.js +13 -1
  159. package/dist/core/mods/extension-call.d.ts +15 -1
  160. package/dist/core/mods/extension-call.js +7 -2
  161. package/dist/core/mods/kernel/dispatch.d.ts +4 -3
  162. package/dist/core/mods/kernel/dispatch.js +4 -4
  163. package/dist/core/mods/kernel/events.d.ts +14 -3
  164. package/dist/core/mods/kernel/events.js +18 -15
  165. package/dist/core/mods/kernel/registration.d.ts +3 -0
  166. package/dist/core/mods/kernel/registration.js +5 -0
  167. package/dist/core/mods/kernel/site-rules.d.ts +6 -3
  168. package/dist/core/mods/kernel/site-rules.js +10 -2
  169. package/dist/core/mods/lifecycle-stations.d.ts +36 -4
  170. package/dist/core/mods/lifecycle-stations.js +44 -9
  171. package/dist/core/mods/session-append.d.ts +118 -0
  172. package/dist/core/mods/session-append.js +318 -0
  173. package/dist/core/mods/session-compact.d.ts +48 -0
  174. package/dist/core/mods/session-compact.js +194 -0
  175. package/dist/core/mods/session-receive.d.ts +93 -0
  176. package/dist/core/mods/session-receive.js +138 -0
  177. package/dist/core/mods/session-send.d.ts +72 -0
  178. package/dist/core/mods/session-send.js +88 -0
  179. package/dist/core/mods/stations.d.ts +88 -21
  180. package/dist/core/mods/stations.js +149 -11
  181. package/dist/core/mods/tool-call.d.ts +2 -0
  182. package/dist/core/mods/tool-call.js +4 -4
  183. package/dist/core/output-style.js +3 -4
  184. package/dist/core/own-property-receipt.d.ts +68 -2
  185. package/dist/core/own-property-receipt.js +45 -2
  186. package/dist/core/park-selfcheck.js +4 -2
  187. package/dist/core/path-identity.d.ts +11 -0
  188. package/dist/core/path-identity.js +4 -0
  189. package/dist/core/path-rule-binding.d.ts +3 -1
  190. package/dist/core/path-rule-binding.js +3 -1
  191. package/dist/core/peer-seat.d.ts +3 -3
  192. package/dist/core/peer-seat.js +20 -8
  193. package/dist/core/permission-rule-consent.d.ts +21 -5
  194. package/dist/core/permission-rule-consent.js +21 -1
  195. package/dist/core/permission-rule-model.d.ts +34 -11
  196. package/dist/core/permission-rule-model.js +47 -10
  197. package/dist/core/permission-rule-org.d.ts +1 -1
  198. package/dist/core/permission-rule-provider.js +4 -1
  199. package/dist/core/permission-rules.d.ts +4 -0
  200. package/dist/core/permission-rules.js +11 -16
  201. package/dist/core/read-root-candidate.js +1 -1
  202. package/dist/core/remote-env.d.ts +74 -26
  203. package/dist/core/remote-env.js +20 -0
  204. package/dist/core/resume-startup-cause.d.ts +5 -4
  205. package/dist/core/retention-policy.d.ts +24 -23
  206. package/dist/core/retention-policy.js +36 -2
  207. package/dist/core/retention.d.ts +4 -1
  208. package/dist/core/retired-keys.d.ts +4 -4
  209. package/dist/core/row-admission.d.ts +10 -0
  210. package/dist/core/row-admission.js +5 -0
  211. package/dist/core/runner/advisor-instructions.d.ts +2 -1
  212. package/dist/core/runner/advisor-instructions.js +2 -1
  213. package/dist/core/runner/announce-once-ledger.d.ts +4 -4
  214. package/dist/core/runner/assemble-result.d.ts +13 -3
  215. package/dist/core/runner/assemble-result.js +12 -7
  216. package/dist/core/runner/caller-roster.d.ts +12 -9
  217. package/dist/core/runner/caller-roster.js +5 -2
  218. package/dist/core/runner/checkpoint-scope.d.ts +16 -1
  219. package/dist/core/runner/checkpoint-scope.js +21 -0
  220. package/dist/core/runner/compact-session.js +18 -3
  221. package/dist/core/runner/compaction-call-options.d.ts +1 -1
  222. package/dist/core/runner/compaction-restate.d.ts +2 -2
  223. package/dist/core/runner/compaction-restate.js +4 -3
  224. package/dist/core/runner/construction-doors.d.ts +2 -2
  225. package/dist/core/runner/construction-doors.js +2 -2
  226. package/dist/core/runner/contracts.d.ts +116 -34
  227. package/dist/core/runner/cross-boundary-lane.d.ts +1 -1
  228. package/dist/core/runner/decide-continuation.d.ts +4 -2
  229. package/dist/core/runner/decide-continuation.js +7 -4
  230. package/dist/core/runner/delegation-owner.d.ts +43 -0
  231. package/dist/core/runner/delegation-owner.js +59 -0
  232. package/dist/core/runner/denial-limit-arms.d.ts +15 -21
  233. package/dist/core/runner/denial-limit-arms.js +17 -10
  234. package/dist/core/runner/expire-settle.d.ts +44 -0
  235. package/dist/core/runner/expire-settle.js +55 -0
  236. package/dist/core/runner/git-status-frame.d.ts +3 -3
  237. package/dist/core/runner/git-status-frame.js +2 -1
  238. package/dist/core/runner/halt-attribution.d.ts +2 -1
  239. package/dist/core/runner/halt-attribution.js +2 -1
  240. package/dist/core/runner/lineage-reroot-view.d.ts +56 -0
  241. package/dist/core/runner/lineage-reroot-view.js +108 -0
  242. package/dist/core/runner/local-claims.d.ts +17 -0
  243. package/dist/core/runner/local-claims.js +18 -0
  244. package/dist/core/runner/media-removed-seat.d.ts +46 -0
  245. package/dist/core/runner/media-removed-seat.js +88 -0
  246. package/dist/core/runner/park-commit.d.ts +2 -2
  247. package/dist/core/runner/permission-rule-lanes.d.ts +7 -2
  248. package/dist/core/runner/permission-rule-lanes.js +28 -9
  249. package/dist/core/runner/person-path-rows.d.ts +15 -0
  250. package/dist/core/runner/person-path-rows.js +27 -4
  251. package/dist/core/runner/placement-fence.d.ts +26 -0
  252. package/dist/core/runner/placement-fence.js +38 -0
  253. package/dist/core/runner/prepare-acquire-reconcile.d.ts +4 -1
  254. package/dist/core/runner/prepare-acquire-reconcile.js +7 -2
  255. package/dist/core/runner/prepare-ask-lane.d.ts +6 -12
  256. package/dist/core/runner/prepare-ask-lane.js +4 -4
  257. package/dist/core/runner/prepare-boundary-parks.d.ts +4 -1
  258. package/dist/core/runner/prepare-boundary-parks.js +2 -2
  259. package/dist/core/runner/prepare-caps-and-workflow.d.ts +3 -0
  260. package/dist/core/runner/prepare-caps-and-workflow.js +2 -1
  261. package/dist/core/runner/prepare-config-doors.d.ts +6 -6
  262. package/dist/core/runner/prepare-config-doors.js +19 -21
  263. package/dist/core/runner/prepare-context-lane.d.ts +6 -2
  264. package/dist/core/runner/prepare-context-lane.js +13 -13
  265. package/dist/core/runner/prepare-delegation-surface.d.ts +9 -9
  266. package/dist/core/runner/prepare-delegation-surface.js +4 -5
  267. package/dist/core/runner/prepare-execution-env.d.ts +5 -2
  268. package/dist/core/runner/prepare-execution-env.js +7 -4
  269. package/dist/core/runner/prepare-gate-stations.d.ts +19 -14
  270. package/dist/core/runner/prepare-gate-stations.js +6 -4
  271. package/dist/core/runner/prepare-hands-readface.d.ts +6 -6
  272. package/dist/core/runner/prepare-hands-readface.js +32 -11
  273. package/dist/core/runner/prepare-inherited-gate.d.ts +8 -0
  274. package/dist/core/runner/prepare-inherited-gate.js +10 -3
  275. package/dist/core/runner/prepare-lsp.d.ts +3 -0
  276. package/dist/core/runner/prepare-lsp.js +2 -2
  277. package/dist/core/runner/prepare-park-ask.d.ts +5 -2
  278. package/dist/core/runner/prepare-park-ask.js +4 -5
  279. package/dist/core/runner/prepare-policy-chain.d.ts +10 -21
  280. package/dist/core/runner/prepare-policy-chain.js +16 -25
  281. package/dist/core/runner/prepare-project-context.d.ts +2 -2
  282. package/dist/core/runner/prepare-prompt-inputs.d.ts +5 -4
  283. package/dist/core/runner/prepare-prompt-inputs.js +3 -2
  284. package/dist/core/runner/prepare-question-face.d.ts +6 -4
  285. package/dist/core/runner/prepare-question-face.js +2 -2
  286. package/dist/core/runner/prepare-run-refs.d.ts +3 -0
  287. package/dist/core/runner/prepare-run-refs.js +2 -2
  288. package/dist/core/runner/prepare-suspend-saga.d.ts +11 -7
  289. package/dist/core/runner/prepare-suspend-saga.js +17 -7
  290. package/dist/core/runner/prepare-task.d.ts +1 -1
  291. package/dist/core/runner/prepare-task.js +61 -30
  292. package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +6 -0
  293. package/dist/core/runner/prepare-tool-disclosure-mount.js +3 -1
  294. package/dist/core/runner/prepare-wiring-manifest.d.ts +3 -0
  295. package/dist/core/runner/prepare-wiring-manifest.js +2 -1
  296. package/dist/core/runner/prepare-workspace-restore.d.ts +5 -0
  297. package/dist/core/runner/prepare-workspace-restore.js +10 -6
  298. package/dist/core/runner/read-root-grant.d.ts +1 -1
  299. package/dist/core/runner/read-root-grant.js +2 -1
  300. package/dist/core/runner/resume-admission.d.ts +8 -6
  301. package/dist/core/runner/resume-admission.js +23 -6
  302. package/dist/core/runner/resume-apply.d.ts +4 -0
  303. package/dist/core/runner/resume-apply.js +14 -5
  304. package/dist/core/runner/resume-checkpoint-screen.d.ts +9 -0
  305. package/dist/core/runner/resume-checkpoint-screen.js +4 -84
  306. package/dist/core/runner/resume-claim.d.ts +8 -3
  307. package/dist/core/runner/resume-claim.js +28 -12
  308. package/dist/core/runner/resume-internals-and-config.d.ts +2 -2
  309. package/dist/core/runner/resume-internals-and-config.js +10 -1
  310. package/dist/core/runner/resume-preflight.d.ts +3 -2
  311. package/dist/core/runner/resume-preflight.js +13 -26
  312. package/dist/core/runner/retired-runner-deps.js +2 -0
  313. package/dist/core/runner/run-git-lane.d.ts +2 -0
  314. package/dist/core/runner/run-git-lane.js +6 -2
  315. package/dist/core/runner/run-harness-handlers.d.ts +2 -0
  316. package/dist/core/runner/run-harness-handlers.js +5 -4
  317. package/dist/core/runner/run-identity-wiring.d.ts +2 -2
  318. package/dist/core/runner/run-identity-wiring.js +14 -5
  319. package/dist/core/runner/run-leg.d.ts +3 -3
  320. package/dist/core/runner/run-leg.js +64 -36
  321. package/dist/core/runner/run-notification-lane.js +20 -2
  322. package/dist/core/runner/run-recovery-lanes.js +3 -2
  323. package/dist/core/runner/run-settle-and-teardown.js +12 -9
  324. package/dist/core/runner/run-stop-and-final-verify.js +2 -1
  325. package/dist/core/runner/run-telemetry-and-budget-seats.d.ts +1 -1
  326. package/dist/core/runner/run-terminal-adoption.d.ts +1 -1
  327. package/dist/core/runner/run-terminal-adoption.js +26 -17
  328. package/dist/core/runner/run-turn-boundary.js +34 -18
  329. package/dist/core/runner/runtask.d.ts +18 -3
  330. package/dist/core/runner/runtask.js +33 -17
  331. package/dist/core/runner/session-rule-policy.d.ts +1 -1
  332. package/dist/core/runner/session-rule-policy.js +6 -1
  333. package/dist/core/runner/shell-env-withheld.d.ts +1 -1
  334. package/dist/core/runner/steering-preview.d.ts +9 -0
  335. package/dist/core/runner/steering-preview.js +5 -0
  336. package/dist/core/runner/stream-halt-verbs.d.ts +1 -14
  337. package/dist/core/runner/stream-halt-verbs.js +4 -3
  338. package/dist/core/runner/stream-reap.d.ts +7 -6
  339. package/dist/core/runner/stream-reap.js +13 -16
  340. package/dist/core/runner/stream-settle-backstop.d.ts +3 -2
  341. package/dist/core/runner/stream-settle-backstop.js +5 -3
  342. package/dist/core/runner/stream-steer-verb.d.ts +5 -2
  343. package/dist/core/runner/stream-steer-verb.js +16 -7
  344. package/dist/core/runner/terminal-account.d.ts +11 -1
  345. package/dist/core/runner/terminal-account.js +20 -0
  346. package/dist/core/runner/terminal-projection.d.ts +8 -2
  347. package/dist/core/runner/terminal-projection.js +2 -2
  348. package/dist/core/runner/tool-disclosure.d.ts +3 -0
  349. package/dist/core/runner/tool-disclosure.js +5 -2
  350. package/dist/core/runner/tool-end-body.d.ts +3 -3
  351. package/dist/core/runner/tool-end-body.js +1 -1
  352. package/dist/core/runner/tool-face-overlay.js +2 -0
  353. package/dist/core/runner/tool-output-projection.d.ts +3 -3
  354. package/dist/core/runner/tool-output-projection.js +7 -6
  355. package/dist/core/runner/tool-table-view.d.ts +56 -0
  356. package/dist/core/runner/tool-table-view.js +51 -0
  357. package/dist/core/runner/turn-attachments.d.ts +8 -2
  358. package/dist/core/runner/turn-attachments.js +2 -2
  359. package/dist/core/runner/void-verifier-pause.d.ts +33 -0
  360. package/dist/core/runner/void-verifier-pause.js +41 -0
  361. package/dist/core/runner-deps.d.ts +26 -27
  362. package/dist/core/secret-env.d.ts +19 -16
  363. package/dist/core/secret-env.js +45 -27
  364. package/dist/core/session-log-transfer.js +9 -10
  365. package/dist/core/session-policy-store.d.ts +1 -1
  366. package/dist/core/session-policy-store.js +5 -2
  367. package/dist/core/session-reconcile.d.ts +3 -2
  368. package/dist/core/session-reconcile.js +7 -4
  369. package/dist/core/session-store.d.ts +3 -1
  370. package/dist/core/session-store.js +10 -8
  371. package/dist/core/session.d.ts +16 -5
  372. package/dist/core/shell-confinement.d.ts +37 -0
  373. package/dist/core/shell-confinement.js +56 -0
  374. package/dist/core/skill-grant.js +1 -1
  375. package/dist/core/store-contracts/checkpoint-store-contract.d.ts +8 -2
  376. package/dist/core/store-contracts/checkpoint-store-contract.js +83 -2
  377. package/dist/core/store-contracts/file-history-store-contract.d.ts +5 -2
  378. package/dist/core/store-contracts/file-history-store-contract.js +25 -1
  379. package/dist/core/store-contracts/mailbox-store-contract.d.ts +12 -5
  380. package/dist/core/store-contracts/mailbox-store-contract.js +156 -9
  381. package/dist/core/store-contracts/session-store-contract.js +22 -8
  382. package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
  383. package/dist/core/store-contracts/tool-result-store-contract.js +30 -0
  384. package/dist/core/task-event.d.ts +24 -9
  385. package/dist/core/task-limits.d.ts +5 -0
  386. package/dist/core/task-notification.d.ts +89 -12
  387. package/dist/core/task-notification.js +89 -14
  388. package/dist/core/task-registry-agent.d.ts +32 -50
  389. package/dist/core/task-registry-agent.js +36 -56
  390. package/dist/core/task-registry-monitor.d.ts +1 -1
  391. package/dist/core/task-registry-monitor.js +15 -60
  392. package/dist/core/task-registry-shared.d.ts +22 -112
  393. package/dist/core/task-registry-shared.js +3 -41
  394. package/dist/core/task-registry-workflow.js +5 -21
  395. package/dist/core/task-registry.d.ts +32 -62
  396. package/dist/core/task-registry.js +30 -110
  397. package/dist/core/task-result.d.ts +29 -12
  398. package/dist/core/task-spec-members.d.ts +39 -0
  399. package/dist/core/task-spec-members.js +92 -0
  400. package/dist/core/task-spec.d.ts +11 -11
  401. package/dist/core/task-tool-shape.d.ts +7 -57
  402. package/dist/core/task-tool-shape.js +7 -66
  403. package/dist/core/terminal-cause.d.ts +36 -6
  404. package/dist/core/terminal-cause.js +1 -0
  405. package/dist/core/tool-catalog-entries.js +2 -5
  406. package/dist/core/tool-check-reading.js +16 -10
  407. package/dist/core/tool-conformance.js +1 -2
  408. package/dist/core/tool-errors.d.ts +6 -3
  409. package/dist/core/tool-errors.js +2 -0
  410. package/dist/core/tool-face-reader.js +3 -2
  411. package/dist/core/tool-face.d.ts +8 -5
  412. package/dist/core/tool-face.js +1 -1
  413. package/dist/core/tool-name-aliases.d.ts +5 -29
  414. package/dist/core/tool-name-aliases.js +9 -5
  415. package/dist/core/tool-name-readings.d.ts +14 -3
  416. package/dist/core/tool-name-readings.js +2 -0
  417. package/dist/core/tool-policy.d.ts +109 -18
  418. package/dist/core/tool-policy.js +84 -14
  419. package/dist/core/tool-result-store.d.ts +23 -0
  420. package/dist/core/tool-result-store.js +3 -2
  421. package/dist/core/tool-roster.d.ts +4 -4
  422. package/dist/core/tool-spec.d.ts +23 -6
  423. package/dist/core/trace.d.ts +18 -1
  424. package/dist/core/types.d.ts +1 -1
  425. package/dist/core/types.js +1 -1
  426. package/dist/core/user-attachment.js +26 -21
  427. package/dist/core/workflow-journal-store.d.ts +1 -1
  428. package/dist/core/workflow-run-store.d.ts +2 -0
  429. package/dist/core/workflow-run-store.js +6 -5
  430. package/dist/core/workflow-settled-run.d.ts +5 -0
  431. package/dist/core/workflow-settled-run.js +7 -0
  432. package/dist/engine/execution-env/node-execution-env.d.ts +37 -9
  433. package/dist/engine/execution-env/node-execution-env.js +221 -22
  434. package/dist/engine/harness/agent-harness.d.ts +65 -18
  435. package/dist/engine/harness/agent-harness.js +90 -23
  436. package/dist/engine/harness/messages.d.ts +4 -3
  437. package/dist/engine/harness/messages.js +2 -2
  438. package/dist/engine/harness/types.d.ts +52 -7
  439. package/dist/engine/llm/media-removed.d.ts +14 -0
  440. package/dist/engine/llm/media-removed.js +9 -0
  441. package/dist/engine/llm/rejected-images.d.ts +35 -25
  442. package/dist/engine/llm/rejected-images.js +59 -10
  443. package/dist/engine/llm/types.d.ts +24 -3
  444. package/dist/engine/llm/types.js +7 -3
  445. package/dist/engine/loop/agent-loop.d.ts +6 -1
  446. package/dist/engine/loop/agent-loop.js +20 -11
  447. package/dist/engine/loop/types.d.ts +12 -3
  448. package/dist/engine/session/import-validate.js +7 -0
  449. package/dist/engine/session/parent-chain-guard.d.ts +3 -3
  450. package/dist/engine/session/parent-chain-guard.js +1 -1
  451. package/dist/engine/session/path-to-root.d.ts +18 -3
  452. package/dist/engine/session/path-to-root.js +15 -1
  453. package/dist/engine/session/repo-utils.d.ts +12 -1
  454. package/dist/engine/session/repo-utils.js +41 -0
  455. package/dist/engine/session/session.js +1 -1
  456. package/dist/engine/session/storage-base.d.ts +20 -0
  457. package/dist/engine/session/storage-base.js +28 -9
  458. package/dist/fixtures/index.d.ts +7 -5
  459. package/dist/fixtures/index.js +5 -3
  460. package/dist/index.d.ts +29 -18
  461. package/dist/index.js +19 -11
  462. package/dist/internal/harness-types.d.ts +2 -0
  463. package/dist/internal/harness.d.ts +4 -3
  464. package/dist/internal/harness.js +3 -2
  465. package/dist/internal/llm.d.ts +2 -1
  466. package/dist/internal/llm.js +1 -0
  467. package/dist/orchestration/goal.d.ts +6 -2
  468. package/dist/orchestration/goal.js +6 -3
  469. package/dist/orchestration/run-workflow-tool.d.ts +14 -17
  470. package/dist/orchestration/run-workflow-tool.js +43 -50
  471. package/dist/orchestration/workflow-types.d.ts +2 -2
  472. package/dist/orchestration/workflow.d.ts +7 -0
  473. package/dist/orchestration/workflow.js +10 -12
  474. package/dist/stores/file/background-agent-store.js +18 -15
  475. package/dist/stores/file/checkpoint-store.d.ts +2 -0
  476. package/dist/stores/file/checkpoint-store.js +13 -9
  477. package/dist/stores/file/file-history-store.js +3 -2
  478. package/dist/stores/file/fs-atomic.d.ts +0 -22
  479. package/dist/stores/file/fs-atomic.js +0 -17
  480. package/dist/stores/file/index.d.ts +7 -12
  481. package/dist/stores/file/index.js +25 -12
  482. package/dist/stores/file/ledger-tuning.d.ts +23 -0
  483. package/dist/stores/file/ledger-tuning.js +21 -0
  484. package/dist/stores/file/mailbox-store.js +42 -22
  485. package/dist/stores/file/memory-store.js +3 -2
  486. package/dist/stores/file/permission-rule-adopt.js +24 -21
  487. package/dist/stores/file/permission-rule-store.js +6 -3
  488. package/dist/stores/file/session-policy-store.js +3 -2
  489. package/dist/stores/file/session-store.d.ts +26 -7
  490. package/dist/stores/file/session-store.js +59 -35
  491. package/dist/stores/file/tool-result-store.d.ts +11 -0
  492. package/dist/stores/file/tool-result-store.js +57 -3
  493. package/dist/stores/file/usage-window-store.js +3 -2
  494. package/dist/stores/file/workflow-journal-store.d.ts +0 -2
  495. package/dist/stores/file/workflow-journal-store.js +3 -18
  496. package/dist/stores/file/workflow-run-store.d.ts +1 -1
  497. package/dist/stores/file/workflow-run-store.js +15 -10
  498. package/dist/tools/fs/bash-program-position.d.ts +3 -2
  499. package/dist/tools/fs/bash-program-position.js +7 -7
  500. package/dist/tools/fs/dead-cwd.d.ts +5 -5
  501. package/dist/tools/fs/dead-cwd.js +4 -11
  502. package/dist/tools/fs/fs-bash-background-text.d.ts +6 -0
  503. package/dist/tools/fs/fs-bash-background-text.js +6 -0
  504. package/dist/tools/fs/fs-bash.d.ts +3 -18
  505. package/dist/tools/fs/fs-bash.js +37 -124
  506. package/dist/tools/fs/fs-pdf.js +8 -6
  507. package/dist/tools/fs/fs-read.js +2 -2
  508. package/dist/tools/fs/fs-shared.d.ts +28 -3
  509. package/dist/tools/fs/fs-shared.js +15 -0
  510. package/dist/tools/fs/index.d.ts +1 -1
  511. package/dist/tools/fs/index.js +4 -14
  512. package/dist/tools/fs/pdf.d.ts +4 -4
  513. package/dist/tools/fs/pdf.js +6 -6
  514. package/dist/tools/fs/read-deny-home.js +8 -1
  515. package/dist/tools/fs/read-deny.d.ts +26 -2
  516. package/dist/tools/fs/read-deny.js +9 -2
  517. package/dist/tools/fs/read-floor.d.ts +13 -5
  518. package/dist/tools/fs/read-floor.js +206 -2
  519. package/dist/tools/fs/removal-targets.js +2 -2
  520. package/dist/tools/fs/search.d.ts +3 -2
  521. package/dist/tools/fs/search.js +6 -6
  522. package/dist/tools/fs/shell-read-argv.d.ts +4 -2
  523. package/dist/tools/fs/shell-read-argv.js +14 -3
  524. package/dist/tools/fs/shell-read-bindings.d.ts +18 -2
  525. package/dist/tools/fs/shell-read-bindings.js +148 -68
  526. package/dist/tools/fs/shell-read-check.js +20 -4
  527. package/dist/tools/fs/shell-read-establish.js +25 -9
  528. package/dist/tools/fs/shell-read-functions.js +2 -2
  529. package/dist/tools/fs/shell-read-identity.d.ts +3 -1
  530. package/dist/tools/fs/shell-read-identity.js +4 -2
  531. package/dist/tools/fs/shell-read-judge.d.ts +7 -1
  532. package/dist/tools/fs/shell-read-judge.js +1 -1
  533. package/dist/tools/fs/shell-read-object-path.d.ts +59 -0
  534. package/dist/tools/fs/shell-read-object-path.js +119 -0
  535. package/dist/tools/fs/shell-read-plan.d.ts +8 -0
  536. package/dist/tools/fs/shell-read-plan.js +47 -30
  537. package/dist/tools/fs/shell-read-start.d.ts +66 -13
  538. package/dist/tools/fs/shell-read-start.js +89 -17
  539. package/dist/tools/fs/shell-read-workdir.d.ts +29 -8
  540. package/dist/tools/fs/shell-read-workdir.js +31 -8
  541. package/dist/tools/monitor.d.ts +8 -7
  542. package/dist/tools/monitor.js +12 -10
  543. package/dist/tools/worktree.d.ts +5 -1
  544. package/dist/tools/worktree.js +20 -17
  545. package/package.json +6 -3
  546. package/test/export-surface.snapshot.json +112 -42
  547. package/wire-changes/core-stores-sql@7.61.0.json +480 -0
  548. package/wire-changes/core-stores-sql@7.62.0.json +30 -0
  549. package/wire-changes/core@7.61.0.json +4405 -0
  550. package/wire-changes/core@7.62.0.json +2181 -0
  551. package/wire-changes/mods-kernel@7.61.0.json +65 -0
  552. package/wire-changes/mods-kernel@7.62.0.json +42 -0
  553. package/wire-changes/primitives@7.61.0.json +30 -0
  554. package/wire-changes/primitives@7.62.0.json +30 -0
  555. package/dist/core/consolidate-scope.d.ts +0 -93
  556. package/dist/core/consolidate-scope.js +0 -98
  557. package/dist/core/runner/image-removed-seat.d.ts +0 -12
  558. package/dist/core/runner/image-removed-seat.js +0 -19
  559. package/dist/core/runner/memory-consolidation.d.ts +0 -109
  560. package/dist/core/runner/memory-consolidation.js +0 -251
@@ -3,16 +3,17 @@ import { homedir } from "node:os";
3
3
  import { argsReadFrom, carryArgsReadFrom, withArgsReading } from "./effective-path-target.js";
4
4
  import { editRewrittenSentence, readRejudge, rewriteChasedSentence } from "./rewrite-rejudge.js";
5
5
  import { brandPolicyAskClass } from "./ask-class.js";
6
- import { decisionAskClassesOf, headlessDenialMessage } from "./ask-origin.js";
6
+ import { decisionAskClassesOf, headlessDenialMessage, joinAskReasons } from "./ask-origin.js";
7
7
  import { attest, attestationOf, isEngineAttestation, mergeAttestation, mintAttestation, withAttestation } from "./engine-attestation.js";
8
8
  import { ownReadRootCandidate, readRootGrantSeat } from "./read-root-grant-screen.js";
9
- import { decidersNote, settledByDecider } from "./gate-outcome.js";
9
+ import { DECIDED_VIA, decidersNote, isDecidedVia, policyDeciderOf, settledByDecider } from "./gate-outcome.js";
10
10
  import { unjudgedAllowRefused } from "./real-approval.js";
11
11
  export { policyCannotAnswer, rowDemandsAPerson } from "./real-approval.js";
12
12
  import { sanitizeAutoModeArmingRecipe } from "./auto-mode-arming.js";
13
13
  import { join, normalize as normalizePath, sep } from "node:path";
14
14
  import { BASH_READONLY_DEFAULT_ALLOW, parseLeadingCommandName } from "../tools/fs/index.js";
15
15
  import { readOnlyShellVerdict } from "./read-only-shell.js";
16
+ import { DEFAULT_GATE_AWAIT_TIMEOUT_MS, withGateTimeout } from "./gate-bounded-await.js";
16
17
  import { protectivePathTargetOf, shellFaceToolNames } from "./tool-registry.js";
17
18
  import { heldBy } from "./tool-name-readings.js";
18
19
  import { bindableValueOf, boundInputHashOf, describeBindingFault, exactBoundInputHashOf } from "./canonical-json.js";
@@ -20,7 +21,7 @@ import { delimitUntrusted, inlineUntrusted, REVIEWER_NOTE_MAX_BODY } from "./unt
20
21
  import { describeRejectedValue } from "./tool-search-setting.js";
21
22
  import { egressText, egressThrownText } from "./untrusted-egress.js";
22
23
  import { assertNoRetiredKeys, assertNoRetiredToolPolicyKeys, RETIRED_DECISION_MEMBERS, RETIRED_TOOL_POLICY_KEYS } from "./retired-keys.js";
23
- import { DECISION_MEMBER_ARMS, isEngineRefusal, nestedRecordsOf, receiveContract, receiveNestedRecords, refusedOutOfContract, screenContractValues } from "./decision-receipt.js";
24
+ import { DECISION_MEMBER_ARMS, HOOK_SEAT_MEMBER_ARMS, isEngineRefusal, nestedRecordsOf, receiveContract, receiveNestedRecords, refusedOutOfContract, screenContractValues } from "./decision-receipt.js";
24
25
  export { isEngineRefusal } from "./decision-receipt.js";
25
26
  import { isCoveringRuleName, ruleNameCovers } from "./namespaced-rule-name.js";
26
27
  import { ruleContentOf } from "./permission-rule-model.js";
@@ -80,6 +81,19 @@ export function screenApproverAttribution(v) {
80
81
  }
81
82
  return { approver: v };
82
83
  }
84
+ export function screenDecidedVia(v, word) {
85
+ if (v === undefined)
86
+ return {};
87
+ if (!isDecidedVia(v)) {
88
+ return {
89
+ defect: `decidedVia is outside the closed set (got ${v === null ? "null" : typeof v === "string" ? "a string that is not a member" : typeof v}) — it is exactly ${DECIDED_VIA.map((w) => `"${w}"`).join(" or ")}, or omitted`,
90
+ };
91
+ }
92
+ if (word !== "policy") {
93
+ return { defect: `decidedVia names which machine seat answered for the deployment's policy, and this decision reports "${word}" — the member rides a "policy" decision only` };
94
+ }
95
+ return { decidedVia: v };
96
+ }
83
97
  export const ASK_EVIDENCE_ABSENCE_VALUES = ["not_wired", "not_adjudicated", "unavailable", "no_match", "not_reported"];
84
98
  export function decisionText(d) {
85
99
  return d.message;
@@ -106,7 +120,9 @@ export function answeredFor(d, call, runs) {
106
120
  const record = attestationOf(d, call);
107
121
  return record?.settlement !== undefined && licenseCovers(record.inputDigest, runs);
108
122
  }
109
- const TOOL_POLICY_CARRIED_MEMBERS = ["projection", "pathRules", "writeGuardRows", "nameSets"];
123
+ export const REFUSES_NO_WHOLE_TOOL = () => false;
124
+ export const TOOL_TABLE_VIEW_READ = "tool-table-view";
125
+ const TOOL_POLICY_CARRIED_MEMBERS = ["projection", "pathRules", "writeGuardRows", "nameSets", "wholeToolRefusals"];
110
126
  export function carriedMembersOf(p) {
111
127
  assertNoRetiredKeys(p, RETIRED_TOOL_POLICY_KEYS, "ToolPolicy");
112
128
  const out = {};
@@ -131,6 +147,31 @@ export function toolPolicyWriteGuardRows(policies) {
131
147
  return undefined;
132
148
  return async (at) => (await Promise.all(sources.map((rowsOf) => rowsOf(at)))).flat();
133
149
  }
150
+ const FOLDED_WHOLE_TOOL_READS = new WeakMap();
151
+ function settledWholeToolRead(read, signal) {
152
+ return withGateTimeout(Promise.resolve().then(() => read(signal)), DEFAULT_GATE_AWAIT_TIMEOUT_MS, signal, "a whole-tool reading").then((judge) => (tool) => {
153
+ try {
154
+ return judge(tool) === true;
155
+ }
156
+ catch {
157
+ return false;
158
+ }
159
+ }, () => REFUSES_NO_WHOLE_TOOL);
160
+ }
161
+ export function toolPolicyWholeToolRefusals(holders) {
162
+ const sources = [...new Set(holders.flatMap((h) => {
163
+ const read = h?.wholeToolRefusals;
164
+ return typeof read === "function" ? (FOLDED_WHOLE_TOOL_READS.get(read) ?? [read]) : [];
165
+ }))];
166
+ if (sources.length === 0)
167
+ return undefined;
168
+ const combined = async (signal) => {
169
+ const judges = await Promise.all(sources.map((read) => settledWholeToolRead(read, signal)));
170
+ return (tool) => judges.some((refuses) => refuses(tool));
171
+ };
172
+ FOLDED_WHOLE_TOOL_READS.set(combined, sources);
173
+ return combined;
174
+ }
134
175
  export function coveringRuleEntries(entries, behavior) {
135
176
  return (entries ?? []).filter((entry) => isCoveringRuleName(entry, behavior));
136
177
  }
@@ -220,7 +261,7 @@ export function constraintChainDigest(chain) {
220
261
  }
221
262
  const ALLOW = Object.freeze({ action: "allow" });
222
263
  export const DECISION_MEMBERS = Object.keys(DECISION_MEMBER_ARMS);
223
- const HOOK_RESULT_MEMBERS = [...DECISION_MEMBERS, "additionalContext"];
264
+ const HOOK_RESULT_MEMBERS = [...DECISION_MEMBERS, ...Object.keys(HOOK_SEAT_MEMBER_ARMS)];
224
265
  const HOOK_SEAM_UNREAD = new Set(["decisionReason"]);
225
266
  const HOOK_SEAM_OPTIONAL = new Set(["action"]);
226
267
  const HOOK_RECEIPTS = new WeakSet();
@@ -383,7 +424,9 @@ export function createAllowDenyPolicy(opts) {
383
424
  const deny = new Set(opts.deny ?? []);
384
425
  const denyCovering = coveringRuleEntries(opts.deny, "deny");
385
426
  const allowCovering = coveringRuleEntries(opts.allow, "allow");
427
+ const refusesWhole = (tool) => nameListHolds(deny, tool) || coveringRuleHit(denyCovering, tool);
386
428
  return {
429
+ ...(deny.size > 0 ? { wholeToolRefusals: () => Promise.resolve(refusesWhole) } : {}),
387
430
  projection: {
388
431
  components: [
389
432
  ...(opts.deny && opts.deny.length > 0 ? [{ kind: "tool_deny", names: [...opts.deny] }] : []),
@@ -393,9 +436,8 @@ export function createAllowDenyPolicy(opts) {
393
436
  },
394
437
  nameSets: [{ ...(opts.allow ? { allow: [...opts.allow] } : {}), ...(opts.deny ? { deny: [...opts.deny] } : {}) }],
395
438
  check(req) {
396
- if (nameListHolds(deny, req) || coveringRuleHit(denyCovering, req)) {
439
+ if (refusesWhole(req))
397
440
  return { action: "deny", message: `tool "${req.toolName}" is denied by policy` };
398
- }
399
441
  if (allow && !nameListHolds(allow, req) && !coveringRuleHit(allowCovering, req)) {
400
442
  return { action: "deny", message: `tool "${req.toolName}" is not in the allowlist` };
401
443
  }
@@ -428,7 +470,9 @@ export function createApprovalPolicy(opts) {
428
470
  const needCovering = coveringRuleEntries(opts.requireApproval, "ask");
429
471
  const denyCovering = coveringRuleEntries(opts.deny, "deny");
430
472
  const autoCovering = coveringRuleEntries(opts.autoAllow, "allow");
473
+ const refusesWhole = (tool) => nameListHolds(deny, tool) || coveringRuleHit(denyCovering, tool);
431
474
  return {
475
+ ...(deny.size > 0 ? { wholeToolRefusals: () => Promise.resolve(refusesWhole) } : {}),
432
476
  projection: {
433
477
  components: [
434
478
  ...(opts.deny && opts.deny.length > 0 ? [{ kind: "tool_deny", names: [...opts.deny] }] : []),
@@ -444,9 +488,8 @@ export function createApprovalPolicy(opts) {
444
488
  },
445
489
  ],
446
490
  async check(req, signal) {
447
- if (nameListHolds(deny, req) || coveringRuleHit(denyCovering, req)) {
491
+ if (refusesWhole(req))
448
492
  return { action: "deny", message: `tool "${req.toolName}" is denied by policy` };
449
- }
450
493
  if (nameListHolds(need, req) || coveringRuleHit(needCovering, req)) {
451
494
  const attestOver = (inputDigest) => (d, settlement, bindingRefusal) => ({ ...d, attestation: mintAttestation(req, { settlement, origin: "policy", ...(inputDigest !== undefined ? { inputDigest } : {}), ...(bindingRefusal !== undefined ? { bindingRefusal } : {}) }) });
452
495
  const unasked = unaskedSeatAnswer(req, signal, { aborted: `approval aborted for "${req.toolName}" (run or turn interrupted)`, unreachable: `approval for "${req.toolName}" was not requested: nobody can be asked about this call` }, "policy");
@@ -488,7 +531,7 @@ export function createApprovalPolicy(opts) {
488
531
  return attest({
489
532
  action: "deny",
490
533
  message: reading.word === "policy"
491
- ? policyRefusalMessage(req.toolName, undefined, reading.note)
534
+ ? policyRefusalMessage(req.toolName, undefined, reading.note, reading.via)
492
535
  : reading.word === "timeout"
493
536
  ? `no one answered the approval request for "${req.toolName}" — the approver reported its own window elapsed with no answer; denied fail-closed${reading.note !== undefined ? `\nReviewer note:\n${delimitUntrusted("reviewer note", reading.note, REVIEWER_NOTE_MAX_BODY)}` : ""}`
494
537
  : `approval denied for "${req.toolName}"${reading.note !== undefined ? `\nReviewer note:\n${delimitUntrusted("reviewer note", reading.note, REVIEWER_NOTE_MAX_BODY)}` : ""}`,
@@ -547,6 +590,7 @@ export function combinePolicies(...policies) {
547
590
  nameSets: nameSets.length > 0 ? nameSets : undefined,
548
591
  pathRules: pathRuled.length > 0 ? (anchors) => toolPolicyPathRules(pathRuled, anchors) : undefined,
549
592
  writeGuardRows,
593
+ wholeToolRefusals: toolPolicyWholeToolRefusals(policies),
550
594
  };
551
595
  return {
552
596
  ...carriedMembersOf(folded),
@@ -887,16 +931,28 @@ export function tryCloneArgs(v) {
887
931
  export function refusalOf(deny, judged) {
888
932
  return deny.action !== "deny" || deny.updatedInput !== undefined ? deny : { ...deny, updatedInput: judged };
889
933
  }
934
+ export function extensionSpeaker(by, reason) {
935
+ return { who: by !== undefined ? extensionNamed(by) : "an extension", why: reason !== undefined ? `: ${inlineUntrusted(reason, 500)}` : "" };
936
+ }
937
+ export function extensionNamed(registration) {
938
+ return `extension ${JSON.stringify(inlineUntrusted(registration, 80))}`;
939
+ }
940
+ export function extensionQuestionText(toolName, entry) {
941
+ const who = entry.registration !== undefined ? extensionNamed(entry.registration) : "an extension";
942
+ const why = entry.cause === "verdict_unreadable" ? ": the hook's verdict could not be read" : entry.cause === "verdict_unfinished" ? ": the hook did not finish with a verdict" : entry.words !== undefined ? `: ${entry.words}` : "";
943
+ return `tool "${toolName}" needs approval (asked by ${who}${why})`;
944
+ }
890
945
  export function foldHookAsk(verdict, hookAsk) {
891
946
  if (verdict.action === "deny")
892
947
  return verdict;
893
948
  const mandate = { ...(hookAsk.requiresRealApproval === true ? { requiresRealApproval: true } : {}), ...(hookAsk.crossBoundaryMandated === true ? { crossBoundaryMandated: true } : {}) };
894
949
  if (verdict.action === "allow") {
895
- return { action: "ask", ...(hookAsk.message !== undefined ? { message: hookAsk.message } : {}), decisionReason: "hook", ...mandate, ...(hookAsk.updatedInput !== undefined ? { updatedInput: hookAsk.updatedInput } : {}) };
950
+ return { action: "ask", ...(hookAsk.message !== undefined ? { message: hookAsk.message } : {}), decisionReason: "hook", ...mandate, ...(hookAsk.updatedInput !== undefined ? { updatedInput: hookAsk.updatedInput } : {}), ...(hookAsk.askReasons !== undefined ? { askReasons: hookAsk.askReasons } : {}) };
896
951
  }
897
952
  const hookMessage = hookAsk.message;
898
953
  const message = hookMessage !== undefined && hookMessage !== verdict.message ? `${verdict.message !== undefined ? `${verdict.message} ` : ""}(a PreToolUse hook also asks: ${hookMessage})` : verdict.message;
899
- return { ...verdict, decisionReason: "hook", ...(message !== undefined ? { message } : {}), ...mandate };
954
+ const askReasons = joinAskReasons(verdict.askReasons, hookAsk.askReasons);
955
+ return { ...verdict, decisionReason: "hook", ...(message !== undefined ? { message } : {}), ...mandate, ...(askReasons !== undefined ? { askReasons } : {}) };
900
956
  }
901
957
  const OWNED_ARGS = new WeakSet();
902
958
  export function ownArgs(v, root = "args") {
@@ -987,7 +1043,14 @@ export function humanRefusalSentence(subject, reason, delegatedChild) {
987
1043
  function humanRefusalMessage(req, reason) {
988
1044
  return `approval denied for "${req.toolName}": ${req.message}\n${humanRefusalSentence("tool use", reason, req.isDelegatedChild === true)}`;
989
1045
  }
990
- export function policyRefusalMessage(toolName, askMessage, note) {
1046
+ export function policyRefusalMessage(toolName, askMessage, note, decidedVia) {
1047
+ const decider = policyDeciderOf(decidedVia);
1048
+ if (decider.seat !== "policy") {
1049
+ const declined = `${decider.name} denied this call to "${toolName}"${askMessage !== undefined ? `: ${askMessage}` : ""}\nThe call did NOT run. Do not claim it ` +
1050
+ `succeeded and do not retry it unchanged; report what was blocked and why you needed it, then continue with the parts of ` +
1051
+ `the task it does not block.`;
1052
+ return note === undefined ? declined : `${declined}\nHook reason:\n${delimitUntrusted("hook reason", note, REVIEWER_NOTE_MAX_BODY)}`;
1053
+ }
991
1054
  const head = `approval required for "${toolName}" but this run has no interactive approval channel${askMessage !== undefined ? `: ${askMessage}` : ""}`;
992
1055
  const body = `${head}\nThe deployment's policy declined this tool use; the call did NOT run. Action requires interactive approval and ` +
993
1056
  `permission prompts are not available in this context. Do not claim it succeeded and do not retry it here; report what ` +
@@ -1126,12 +1189,14 @@ function readApproverOutcomeObject(ok, toolName, editLane) {
1126
1189
  let allowed;
1127
1190
  let suppliedEdit;
1128
1191
  let suppliedApprover;
1192
+ let suppliedVia;
1129
1193
  let grant;
1130
1194
  try {
1131
1195
  supplied = ok.settledBy;
1132
1196
  allowed = ok.allow;
1133
1197
  suppliedEdit = ok.updatedInput;
1134
1198
  suppliedApprover = ok.approver;
1199
+ suppliedVia = ok.decidedVia;
1135
1200
  grant = ok.readRootGrant;
1136
1201
  }
1137
1202
  catch (err) {
@@ -1150,6 +1215,10 @@ function readApproverOutcomeObject(ok, toolName, editLane) {
1150
1215
  if (attribution.defect !== undefined) {
1151
1216
  return refused(`the approver for "${toolName}" reported an attribution this seam refuses: ${attribution.defect}; denied fail-closed`, settledByNobody("approver_contract"));
1152
1217
  }
1218
+ const via = screenDecidedVia(suppliedVia, settledWord);
1219
+ if (via.defect !== undefined) {
1220
+ return refused(`the approver for "${toolName}" reported a decidedVia this seam refuses: ${via.defect}; denied fail-closed`, settledByNobody("approver_contract"));
1221
+ }
1153
1222
  if (editLane === "none" && grant !== undefined) {
1154
1223
  return refused(`the approver for "${toolName}" attached a readRootGrant on a seat that offers no directory — denied fail-closed (a grant answers an approval card's readRootCandidate)`, settledByNobody("approver_contract"));
1155
1224
  }
@@ -1172,6 +1241,7 @@ function readApproverOutcomeObject(ok, toolName, editLane) {
1172
1241
  kind: "deny",
1173
1242
  word: settledWord,
1174
1243
  note,
1244
+ via: via.decidedVia,
1175
1245
  grant,
1176
1246
  settlement: decider === undefined ? { kind: "approval_window_expired", who: { party: "host" }, when: Date.now() } : settledByDecider(decider, "refused", attribution.approver, note),
1177
1247
  };
@@ -1284,7 +1354,7 @@ async function resolveAskArms(req, onAsk, signal, onLateSettlement) {
1284
1354
  message: reading.word === "timeout"
1285
1355
  ? `approval for "${req.toolName}" was not answered before the approver's own window elapsed: ${req.message}${reading.note !== undefined ? `\nReviewer note:\n${delimitUntrusted("reviewer note", reading.note, REVIEWER_NOTE_MAX_BODY)}` : ""}`
1286
1356
  : reading.word === "policy"
1287
- ? policyRefusalMessage(req.toolName, req.message, reading.note)
1357
+ ? policyRefusalMessage(req.toolName, req.message, reading.note, reading.via)
1288
1358
  : humanRefusalMessage(req, reading.note),
1289
1359
  decisionReason: "mode",
1290
1360
  settlement: reading.settlement,
@@ -118,6 +118,29 @@ export interface ToolResultStore {
118
118
  * audit receipts, scheduled execution), of which this is one caller-driven erase.
119
119
  */
120
120
  deleteBySession?(sessionId: string): Promise<ToolResultDeletionReport> | ToolResultDeletionReport;
121
+ /**
122
+ * Age out the entries stored more than `opts.maxAgeMs` before `now` (epoch ms): the age bound a deployment states for
123
+ * offloaded results, read the same way by every backend — a SQL backend's sweep leg reads the same bound. An entry's
124
+ * age is the time its winning write stored it; the content and its owner record go together. Answers how many
125
+ * entries it removed.
126
+ *
127
+ * Rules every implementation follows:
128
+ * - **no bound, no deletion**: `opts` or `opts.maxAgeMs` absent ⇒ nothing is removed — the default keeps every
129
+ * entry, as a transcript is kept;
130
+ * - **a bound that cannot be evaluated is refused** before any entry is touched (`config.retention_policy_invalid`:
131
+ * a `maxAgeMs` that is not a finite number of milliseconds of 0 or more, a `now` that is not a finite number) —
132
+ * never read as "no bound";
133
+ * - **age only**: ownership is not consulted, and an entry still reachable from a transcript is removed when it
134
+ * is old enough — the model's read of it then says it may have expired (the honest degradation the read
135
+ * already has);
136
+ * - **idempotent**, and an entry that disappears between enumeration and removal is honest absence.
137
+ *
138
+ * Optional: absent ⇒ this store keeps entries until their session is deleted. An OPTIONAL leg of the contract kit
139
+ * (`toolResultStoreContract`), reported through its `onOptionalMember` callback.
140
+ */
141
+ reap?(now: number, opts?: {
142
+ maxAgeMs?: number;
143
+ }): Promise<number> | number;
121
144
  /**
122
145
  * The READ half of the same ownership coordinate {@link deleteBySession} erases by: every entry this store recorded as belonging to
123
146
  * `sessionId`, as the ref and the owner recorded at its winning write. Without it the offloaded results a session's transcript
@@ -8,7 +8,7 @@ import { mountRuleFace, toolFace } from "./tool-catalog-entries.js";
8
8
  import { thrownText } from "./thrown-value.js";
9
9
  import { readRetentionDeclaration } from "./retention.js";
10
10
  import { carryNotStartedReceipt } from "./delegation-not-started.js";
11
- import { receiveOptions } from "./own-property-receipt.js";
11
+ import { optionKeys, receiveOptions } from "./own-property-receipt.js";
12
12
  import { NON_NEGATIVE_SAFE_INTEGER, readIntegerOption } from "./integer-option.js";
13
13
  export const TOOL_RESULT_REF_CONFLICT_CODE = "tool_result.ref_conflict";
14
14
  export class ToolResultRefConflictError extends Error {
@@ -79,13 +79,14 @@ export function toolResultContentSegment(text) {
79
79
  function digestOfString(s) {
80
80
  return createHash("sha256").update(Buffer.from(s, "utf16le")).digest("hex");
81
81
  }
82
+ const IN_MEMORY_TOOL_RESULT_STORE_OPTION_KEYS = optionKeys()({ maxTotalChars: 0, retention: 0 });
82
83
  export class InMemoryToolResultStore {
83
84
  retention;
84
85
  map = new Map();
85
86
  totalChars = 0;
86
87
  maxTotalChars;
87
88
  constructor(options) {
88
- const opts = receiveOptions(options, "InMemoryToolResultStore");
89
+ const opts = receiveOptions(options, "InMemoryToolResultStore", IN_MEMORY_TOOL_RESULT_STORE_OPTION_KEYS);
89
90
  this.retention = readRetentionDeclaration("InMemoryToolResultStore.retention", opts.retention);
90
91
  this.maxTotalChars = readIntegerOption("InMemoryToolResultStore.maxTotalChars", opts.maxTotalChars, NON_NEGATIVE_SAFE_INTEGER, "characters", "an unbounded store");
91
92
  }
@@ -9,7 +9,7 @@ export declare const ToolRosterRenderHints: Type.TObject<{
9
9
  activity: Type.TOptional<Type.TString>;
10
10
  summaryParams: Type.TOptional<Type.TArray<Type.TString>>;
11
11
  resultCards: Type.TOptional<Type.TArray<Type.TString>>;
12
- approvalCard: Type.TOptional<Type.TUnion<[Type.TLiteral<"file-edit">, Type.TLiteral<"file-write">, Type.TLiteral<"notebook-edit">, Type.TLiteral<"shell">, Type.TLiteral<"fetch">, Type.TLiteral<"skill">, Type.TLiteral<"workflow">, Type.TLiteral<"plan">, Type.TLiteral<"question">, Type.TLiteral<"generic">]>>;
12
+ approvalCard: Type.TOptional<Type.TUnion<[Type.TLiteral<"file-edit">, Type.TLiteral<"file-write">, Type.TLiteral<"notebook-edit">, Type.TLiteral<"shell">, Type.TLiteral<"fetch">, Type.TLiteral<"skill">, Type.TLiteral<"workflow">, Type.TLiteral<"plan">, Type.TLiteral<"question">, Type.TLiteral<"generic">, Type.TLiteral<"computer-access">, Type.TLiteral<"computer-control">]>>;
13
13
  }>;
14
14
  export declare const ToolRosterEntry: Type.TObject<{
15
15
  name: Type.TString;
@@ -85,7 +85,7 @@ export declare const ToolRosterEntry: Type.TObject<{
85
85
  activity: Type.TOptional<Type.TString>;
86
86
  summaryParams: Type.TOptional<Type.TArray<Type.TString>>;
87
87
  resultCards: Type.TOptional<Type.TArray<Type.TString>>;
88
- approvalCard: Type.TOptional<Type.TUnion<[Type.TLiteral<"file-edit">, Type.TLiteral<"file-write">, Type.TLiteral<"notebook-edit">, Type.TLiteral<"shell">, Type.TLiteral<"fetch">, Type.TLiteral<"skill">, Type.TLiteral<"workflow">, Type.TLiteral<"plan">, Type.TLiteral<"question">, Type.TLiteral<"generic">]>>;
88
+ approvalCard: Type.TOptional<Type.TUnion<[Type.TLiteral<"file-edit">, Type.TLiteral<"file-write">, Type.TLiteral<"notebook-edit">, Type.TLiteral<"shell">, Type.TLiteral<"fetch">, Type.TLiteral<"skill">, Type.TLiteral<"workflow">, Type.TLiteral<"plan">, Type.TLiteral<"question">, Type.TLiteral<"generic">, Type.TLiteral<"computer-access">, Type.TLiteral<"computer-control">]>>;
89
89
  }>>;
90
90
  /** The ONE mount condition that fired for this instance. */
91
91
  mountedBy: Type.TUnion<[Type.TLiteral<"hands">, Type.TLiteral<"backgroundTasks">, Type.TLiteral<"workflow">, Type.TLiteral<"delegation">, Type.TLiteral<"hostInternals">, Type.TLiteral<"peerLane">, Type.TLiteral<"scheduler">, Type.TLiteral<"memory">, Type.TLiteral<"scenario">, Type.TLiteral<"always">, Type.TLiteral<"optional">]>;
@@ -170,7 +170,7 @@ export declare const ToolRoster: Type.TObject<{
170
170
  activity: Type.TOptional<Type.TString>;
171
171
  summaryParams: Type.TOptional<Type.TArray<Type.TString>>;
172
172
  resultCards: Type.TOptional<Type.TArray<Type.TString>>;
173
- approvalCard: Type.TOptional<Type.TUnion<[Type.TLiteral<"file-edit">, Type.TLiteral<"file-write">, Type.TLiteral<"notebook-edit">, Type.TLiteral<"shell">, Type.TLiteral<"fetch">, Type.TLiteral<"skill">, Type.TLiteral<"workflow">, Type.TLiteral<"plan">, Type.TLiteral<"question">, Type.TLiteral<"generic">]>>;
173
+ approvalCard: Type.TOptional<Type.TUnion<[Type.TLiteral<"file-edit">, Type.TLiteral<"file-write">, Type.TLiteral<"notebook-edit">, Type.TLiteral<"shell">, Type.TLiteral<"fetch">, Type.TLiteral<"skill">, Type.TLiteral<"workflow">, Type.TLiteral<"plan">, Type.TLiteral<"question">, Type.TLiteral<"generic">, Type.TLiteral<"computer-access">, Type.TLiteral<"computer-control">]>>;
174
174
  }>>;
175
175
  /** The ONE mount condition that fired for this instance. */
176
176
  mountedBy: Type.TUnion<[Type.TLiteral<"hands">, Type.TLiteral<"backgroundTasks">, Type.TLiteral<"workflow">, Type.TLiteral<"delegation">, Type.TLiteral<"hostInternals">, Type.TLiteral<"peerLane">, Type.TLiteral<"scheduler">, Type.TLiteral<"memory">, Type.TLiteral<"scenario">, Type.TLiteral<"always">, Type.TLiteral<"optional">]>;
@@ -263,7 +263,7 @@ export declare const ToolRosterDelta: Type.TObject<{
263
263
  activity: Type.TOptional<Type.TString>;
264
264
  summaryParams: Type.TOptional<Type.TArray<Type.TString>>;
265
265
  resultCards: Type.TOptional<Type.TArray<Type.TString>>;
266
- approvalCard: Type.TOptional<Type.TUnion<[Type.TLiteral<"file-edit">, Type.TLiteral<"file-write">, Type.TLiteral<"notebook-edit">, Type.TLiteral<"shell">, Type.TLiteral<"fetch">, Type.TLiteral<"skill">, Type.TLiteral<"workflow">, Type.TLiteral<"plan">, Type.TLiteral<"question">, Type.TLiteral<"generic">]>>;
266
+ approvalCard: Type.TOptional<Type.TUnion<[Type.TLiteral<"file-edit">, Type.TLiteral<"file-write">, Type.TLiteral<"notebook-edit">, Type.TLiteral<"shell">, Type.TLiteral<"fetch">, Type.TLiteral<"skill">, Type.TLiteral<"workflow">, Type.TLiteral<"plan">, Type.TLiteral<"question">, Type.TLiteral<"generic">, Type.TLiteral<"computer-access">, Type.TLiteral<"computer-control">]>>;
267
267
  }>>;
268
268
  /** The ONE mount condition that fired for this instance. */
269
269
  mountedBy: Type.TUnion<[Type.TLiteral<"hands">, Type.TLiteral<"backgroundTasks">, Type.TLiteral<"workflow">, Type.TLiteral<"delegation">, Type.TLiteral<"hostInternals">, Type.TLiteral<"peerLane">, Type.TLiteral<"scheduler">, Type.TLiteral<"memory">, Type.TLiteral<"scenario">, Type.TLiteral<"always">, Type.TLiteral<"optional">]>;
@@ -700,6 +700,10 @@ export interface ToolExecuteContext {
700
700
  * fixed point `ctx.rootSessionId ?? ctx.sessionId` at every spawn). Absent for a top-level run
701
701
  * (its OWN sessionId is the root). */
702
702
  rootSessionId?: string;
703
+ /** The run's delegation tree owner seat (`RunInternals.delegationOwner`, Runner-filled): a delegation tool reads the tree's owner
704
+ * through it for the rows it creates for a child (a placed transcript, a fork, a park's durable row) and threads it into a spawned
705
+ * child's internals by reference — never into a revival's. */
706
+ delegationOwner?: import("./runner/delegation-owner.js").DelegationOwnerSeat;
703
707
  /** design/380 O1② (C12) — the spawning run's EXPLICIT placement fixed point
704
708
  * (`RunInternals.placementRoot`), present only when its internals carried one (cascade rungs /
705
709
  * verification legs after the first, or a caller-declared root). A delegation tool threads it
@@ -825,6 +829,13 @@ export interface ToolExecuteContext {
825
829
  * the tool runs outside a Runner task.
826
830
  */
827
831
  parentCwd?: string;
832
+ /**
833
+ * The RUNNING task's own placement target (Runner-filled, read-only, never a model argument): what its execution
834
+ * environment reported as its workspace settled. A delegation tool hands it, as is, to every agent it spawns or wakes
835
+ * (`RunInternals.placementTarget` — the fence that agent's env is minted under). Absent outside a Runner task, and when
836
+ * the environment reported none (not remote, or its handle could not answer yet).
837
+ */
838
+ placementTarget?: import("./remote-env.js").PlacementTarget;
828
839
  /** The deployment's compiled host floor (`RunnerDeps.hostFloor`; Runner-filled, read-only, never a model argument): an engine executor
829
840
  * that connects — the fetch tool on every hop, WebSearch's SearXNG backend (handed it in the backend's `opts.hostFloor`) — judges each URL
830
841
  * by it before the request. Absent outside a Runner, or when none is declared. */
@@ -964,8 +975,8 @@ export interface ToolExecuteContext {
964
975
  * from its roster, so a question it needed to ask silently became a guess.
965
976
  *
966
977
  * Forwarded VERBATIM, unlike `onAsk`'s provenance-stamped wrapper: a content ask carries its issuing
967
- * identity in the request itself (`AskQuestionRequest.principal` + `sourceTaskId`, which the child's
968
- * own prepare fills from the child's inherited principal and its Runner-minted session id), and
978
+ * identity in the request itself (`AskQuestionRequest.principal` + `sourceSessionId` + `agentId`, which the
979
+ * child's own prepare fills from the child's inherited principal, its Runner-minted session id and its task id), and
969
980
  * nothing in the question path does approver-identity collapse (the reason the permission wrapper
970
981
  * exists). Wrapping here would add a field no consumer reads and a second function identity for one
971
982
  * decision-maker.
@@ -1180,10 +1191,11 @@ export interface ToolExecuteContext {
1180
1191
  /**
1181
1192
  * A read-only CAPTURE of this (parent) task's request allow entries for the run ({@link import("./task-spec.js").TaskSpec.allowedTools},
1182
1193
  * its own and any it inherited), filled by the Runner beside {@link activeSkillGrants}: a delegation tool reads it AT SPAWN
1183
- * TIME and threads it into the child, which holds them as its own request rows until it ends. A copy; the model can
1184
- * neither read nor set it. Undefined when the tool runs outside a Runner task.
1194
+ * TIME and threads it into the child, which holds them as its own request rows until it ends — an anchored member with its
1195
+ * set's anchors, so the child reads its path rule where the parent did. A copy; the model can neither read nor set it.
1196
+ * Undefined when the tool runs outside a Runner task.
1185
1197
  */
1186
- activeRequestAllowedTools?: () => readonly string[];
1198
+ activeRequestAllowedTools?: () => readonly import("./allow-entry.js").AllowListEntry[];
1187
1199
  /**
1188
1200
  * Parent effective-policy inheritance (tighten-only) — the Runner-filled chain accessor a delegation tool
1189
1201
  * (`createSubagentTool` / the `run_workflow` spawn legs) calls AT SPAWN TIME and threads verbatim into the
@@ -1291,7 +1303,7 @@ export interface ToolExecuteContext {
1291
1303
  */
1292
1304
  checkpointScopeForChildren?: string;
1293
1305
  /**
1294
- * design/99 (nested-subagent live observability): the host run's stable taskId (`spec.taskId ?? sessionId`),
1306
+ * design/99 (nested-subagent live observability): the host run's stable taskId (the leg's single mint),
1295
1307
  * filled by the Runner. A delegation tool (`createSubagentTool`) reads it AT SPAWN TIME and threads it into the
1296
1308
  * child as the child's `parentTaskId`, so a UI can build the live nested-agent tree (child.parentTaskId === this
1297
1309
  * taskId). Undefined when the tool runs outside a Runner task.
@@ -1400,6 +1412,11 @@ export interface ToolExecuteContext {
1400
1412
  * outside a Runner: no station is raised and every type is offered.
1401
1413
  */
1402
1414
  agentStations?: import("./mods/agent-stations.js").AgentStations;
1415
+ /**
1416
+ * The sending leg's `session.send` station over its mods bus — raised by SendMessage before it delivers a message.
1417
+ * Runner-filled; never a model argument. Absent outside a Runner: no station is raised.
1418
+ */
1419
+ sendStation?: import("./mods/session-send.js").SendStation;
1403
1420
  /**
1404
1421
  * design/80 D-B — the general "a tool yields to a HUMAN review gate" primitive. A tool calls this to request
1405
1422
  * that, at the next SAFE turn boundary, the engine pause with a durable `plan_review` checkpoint
@@ -96,7 +96,8 @@ export type TraceEvent = {
96
96
  version: 1;
97
97
  taskId: string;
98
98
  /** The ENGINE-minted identity of THIS run (`TaskResult.runId`). `taskId` is
99
- * `spec.taskId ?? sessionId`, so two runs of one session that declare no host task id emit two
99
+ * the leg's task id (a background row's id, else the declared one, else the session id), so two
100
+ * runs of one session that declare no host task id emit two
100
101
  * task.start frames under ONE id and a consumer pairing start↔end has no way to say which end
101
102
  * closes which start. Present on every `task.start` (the frame is emitted after prepare, which
102
103
  * is where the id is minted).
@@ -924,6 +925,22 @@ export type TraceEvent = {
924
925
  /** True = store.put failed (or no store): the model lost read-back for this result. */
925
926
  storeFallback: boolean;
926
927
  ts: number;
928
+ } | {
929
+ /** A request's media trim (`media-byte-cap.ts`) left blocks out of a request that was sent: one frame per such
930
+ * request (the person hears each block once per session, `context.media_removed`). `items` / `base64Chars` are the
931
+ * request's media before the trim; `budgetBase64Chars` is absent when the deployment set no budget. */
932
+ kind: "context.media_removed";
933
+ version: 1;
934
+ taskId: string;
935
+ reason: "media_budget";
936
+ images: number;
937
+ documents: number;
938
+ removedBase64Chars: number;
939
+ items: number;
940
+ base64Chars: number;
941
+ maxItems: number;
942
+ budgetBase64Chars?: number;
943
+ ts: number;
927
944
  } | {
928
945
  /** C4 — image blocks were replaced with text placeholders because the served model declares no
929
946
  * vision input (`ModelSpec.input` without "image"). Silent quality loss without this. */
@@ -31,5 +31,5 @@ export type { BackgroundChildEvent, BackgroundChildRow, DelegationLifecycleEvent
31
31
  export { __resetMalformedDelegationSeatAnnouncement, backgroundChildTerminal, deliverDelegationLifecycle, emitsChildRowFrames, taskStartedFrame } from "./delegation-frames.js";
32
32
  export type { ProjectMemoryLoad, ResumePreflightInfo, ResumePreflightVerdict, RunnerDeps } from "./runner-deps.js";
33
33
  export type { ApprovalCarryRefusal, EngineNotice, HeldUserInputs, OwedInputIds, OwedUserInputAccount, UserInputUndrainedCause } from "./engine-notice.js";
34
- export { __resetMalformedNoticeSeatAnnouncement, deliverEngineNotice, owedUserInputCounts, owedUserInputIds, parentLegIds, parkedInputIdsOf, settleOwedUserInput, undrainedUserInputNotices, USER_INPUT_UNDRAINED_CAUSES, USER_INPUT_UNDRAINED_FAMILIES } from "./engine-notice.js";
34
+ export { __resetMalformedNoticeSeatAnnouncement, deliverEngineNotice, owedUserInputCounts, owedUserInputIds, parentLegIds, parkedInputIdsOf, setDefaultEngineNoticeSeat, settleOwedUserInput, undrainedUserInputNotices, USER_INPUT_UNDRAINED_CAUSES, USER_INPUT_UNDRAINED_FAMILIES } from "./engine-notice.js";
35
35
  export type { AgentTool, Model, StreamFn, ThinkingLevel, ToolInputValidationContext, ToolInputVerdict };
@@ -2,4 +2,4 @@ export { MODEL_ROLES } from "./model-seat.js";
2
2
  export { DECLARATION_ENTRY_WORDS, DECLARATION_PATH_RULES, MCP_TRANSPORT_KINDS, NO_DECLARATION_PATH_RULES, TOOL_AXIS_WORDS, callerText, dataKind, declarationFaultOf, declarationPath, declarerWord, perToolEmptyName, perToolEntryRefusal, readMcpToolAxes, readToolAxes, receiveDeclaration, receivePerToolDeclaration, toolAxesRefusal, transportKindOf } from "./mcp-server-spec.js";
3
3
  export { AUTO_MODE_DENY_SOURCES, isAutoModeDenySource } from "./runtime-caps.js";
4
4
  export { __resetMalformedDelegationSeatAnnouncement, backgroundChildTerminal, deliverDelegationLifecycle, emitsChildRowFrames, taskStartedFrame } from "./delegation-frames.js";
5
- export { __resetMalformedNoticeSeatAnnouncement, deliverEngineNotice, owedUserInputCounts, owedUserInputIds, parentLegIds, parkedInputIdsOf, settleOwedUserInput, undrainedUserInputNotices, USER_INPUT_UNDRAINED_CAUSES, USER_INPUT_UNDRAINED_FAMILIES } from "./engine-notice.js";
5
+ export { __resetMalformedNoticeSeatAnnouncement, deliverEngineNotice, owedUserInputCounts, owedUserInputIds, parentLegIds, parkedInputIdsOf, setDefaultEngineNoticeSeat, settleOwedUserInput, undrainedUserInputNotices, USER_INPUT_UNDRAINED_CAUSES, USER_INPUT_UNDRAINED_FAMILIES } from "./engine-notice.js";
@@ -10,8 +10,10 @@ import { MARKED_BLOCK_AFTER_DATA, mintSystemReminder } from "./reminder-mint.js"
10
10
  import { commitReminderDisclosureEffects, planReminderDisclosure } from "./reminder-disclosure.js";
11
11
  import { DEFAULT_CHARS_PER_TOKEN, estimateTokens, uuidv7 } from "../internal/harness.js";
12
12
  import { thrownText } from "./thrown-value.js";
13
+ import { optionKeys, receiveMembers } from "./own-property-receipt.js";
13
14
  import { guardBudget } from "./context-guard.js";
14
- import { agentIdOf, failedHandlerClause } from "./mods/stations.js";
15
+ import { failedHandlerClause } from "./mods/stations.js";
16
+ import { agentIdOf } from "./leg-identity.js";
15
17
  import { extensionWords } from "./untrusted-egress.js";
16
18
  export const USER_ATTACHMENTS_MAX = 20;
17
19
  export const USER_ATTACHMENT_LABEL_MAX = 4096;
@@ -75,10 +77,13 @@ function screenPositiveInt(v, at) {
75
77
  throw userAttachmentRefusal(at, "must be an integer of at least 1.");
76
78
  return v;
77
79
  }
78
- function onlyMembers(o, allowed, at) {
79
- for (const k of Object.keys(o))
80
- if (!allowed.includes(k))
81
- throw userAttachmentRefusal(memberRef(at, k), `is not a member of this attachment (allowed: ${allowed.join(", ")}).`);
80
+ const PATH_KEYS = optionKeys()({ path: 0, lines: 0 });
81
+ const LINES_KEYS = optionKeys()({ start: 0, end: 0 });
82
+ const TEXT_KEYS = optionKeys()({ name: 0, text: 0, startLine: 0 });
83
+ const IMAGE_KEYS = optionKeys()({ name: 0, image: 0 });
84
+ const IMAGE_BYTES_KEYS = optionKeys()({ data: 0, mimeType: 0 });
85
+ function onlyMembers(o, keys, at) {
86
+ return receiveMembers(o, { subject: at.path, unit: "member", moment: "when the attachment is screened" }, keys, (_, [k]) => userAttachmentRefusal(memberRef(at, String(k)), `is not a member of this attachment (allowed: ${keys.join(", ")}).`));
82
87
  }
83
88
  function screenEntry(raw, at) {
84
89
  if (!isPlainObject(raw))
@@ -90,17 +95,17 @@ function screenEntry(raw, at) {
90
95
  }
91
96
  switch (arm) {
92
97
  case "path": {
93
- onlyMembers(raw, ["path", "lines"], at);
94
- const path = screenLabel(raw.path, memberRef(at, "path"));
95
- const linesRaw = raw.lines;
98
+ const entry = onlyMembers(raw, PATH_KEYS, at);
99
+ const path = screenLabel(entry.path, memberRef(at, "path"));
100
+ const linesRaw = entry.lines;
96
101
  if (linesRaw === undefined)
97
102
  return { supply: "path", path };
98
103
  const linesAt = memberRef(at, "lines");
99
104
  if (!isPlainObject(linesRaw))
100
105
  throw userAttachmentRefusal(linesAt, "must be { start, end? }.");
101
- onlyMembers(linesRaw, ["start", "end"], linesAt);
102
- const start = screenPositiveInt(linesRaw.start, memberRef(linesAt, "start"));
103
- const endRaw = linesRaw.end;
106
+ const lines = onlyMembers(linesRaw, LINES_KEYS, linesAt);
107
+ const start = screenPositiveInt(lines.start, memberRef(linesAt, "start"));
108
+ const endRaw = lines.end;
104
109
  if (endRaw === undefined)
105
110
  return { supply: "path", path, lines: { start } };
106
111
  const end = screenPositiveInt(endRaw, memberRef(linesAt, "end"));
@@ -109,27 +114,27 @@ function screenEntry(raw, at) {
109
114
  return { supply: "path", path, lines: { start, end } };
110
115
  }
111
116
  case "text": {
112
- onlyMembers(raw, ["name", "text", "startLine"], at);
113
- const name = screenLabel(raw.name, memberRef(at, "name"));
114
- const text = raw.text;
117
+ const entry = onlyMembers(raw, TEXT_KEYS, at);
118
+ const name = screenLabel(entry.name, memberRef(at, "name"));
119
+ const text = entry.text;
115
120
  if (typeof text !== "string" || text.length === 0)
116
121
  throw userAttachmentRefusal(memberRef(at, "text"), "must be a non-empty string.");
117
- const startLine = raw.startLine === undefined ? 1 : screenPositiveInt(raw.startLine, memberRef(at, "startLine"));
122
+ const startLine = entry.startLine === undefined ? 1 : screenPositiveInt(entry.startLine, memberRef(at, "startLine"));
118
123
  const rendered = renderNumbered(text, startLine);
119
124
  if (rendered.length > MAX_READ_OUTPUT_CHARS)
120
125
  throw userAttachmentRefusal(memberRef(at, "text"), `renders to ${rendered.length} characters with line numbers, over the ${MAX_READ_OUTPUT_CHARS}-character limit a read may deliver — send a part of it.`);
121
126
  return { supply: "content_text", name, text, startLine, rendered };
122
127
  }
123
128
  case "image": {
124
- onlyMembers(raw, ["name", "image"], at);
125
- const name = screenLabel(raw.name, memberRef(at, "name"));
126
- const img = raw.image;
129
+ const entry = onlyMembers(raw, IMAGE_KEYS, at);
130
+ const name = screenLabel(entry.name, memberRef(at, "name"));
131
+ const img = entry.image;
127
132
  const imageAt = memberRef(at, "image");
128
133
  if (!isPlainObject(img))
129
134
  throw userAttachmentRefusal(imageAt, "must be { data, mimeType } (base64 bytes and the image's type).");
130
- onlyMembers(img, ["data", "mimeType"], imageAt);
131
- const data = img.data;
132
- const mimeType = img.mimeType;
135
+ const bytes = onlyMembers(img, IMAGE_BYTES_KEYS, imageAt);
136
+ const data = bytes.data;
137
+ const mimeType = bytes.mimeType;
133
138
  if (typeof data !== "string" || data.length === 0)
134
139
  throw userAttachmentRefusal(memberRef(imageAt, "data"), "must be a non-empty base64 string.");
135
140
  if (typeof mimeType !== "string" || !ADMITTED_IMAGE_MIME_TYPES.includes(mimeType)) {
@@ -135,7 +135,7 @@ export interface WorkflowJournalStore {
135
135
  /** (CC diagnostics parity, additive): a HUMAN/MODEL-readable coordinate for this run's journal —
136
136
  * the file store returns the on-disk jsonl path (CC "Read journal.jsonl" local form); a service store
137
137
  * returns its API route (cloud form). `undefined`/absent ⇒ the completion notification's diagnostics
138
- * line teaches only the TaskOutput route (which is always live). Engine-facing string, never parsed. */
138
+ * line names no journal (the record behind its ref still carries every agent's row). Engine-facing string, never parsed. */
139
139
  locator?(runId: string, scope: string): string | undefined;
140
140
  /**
141
141
  * ADMISSION for a resume, so two concurrent
@@ -222,6 +222,8 @@ export declare function queryWorkflowRuns(runs: Iterable<WorkflowRun>, scope: st
222
222
  * `WorkflowRun` the workflow keeps mutating — must not corrupt the stored row, and a returned run must not
223
223
  * be a live reference the caller can mutate back into the store).
224
224
  */
225
+ /** The retention knobs a workflow-run `reap` takes: an age bound and a keep-newest-N bound over the terminal runs. */
226
+ export declare const WORKFLOW_RUN_REAP_KNOBS: readonly ["maxAgeMs", "keep"];
225
227
  export declare class InMemoryWorkflowRunStore implements WorkflowRunStore {
226
228
  private runs;
227
229
  put(id: string, run: WorkflowRun): Promise<void>;
@@ -1,5 +1,5 @@
1
1
  import { runParkedOf } from "../orchestration/workflow-types.js";
2
- import { assertRetentionPolicy } from "./retention-policy.js";
2
+ import { receiveRetentionPolicy } from "./retention-policy.js";
3
3
  export function summarizeWorkflowRun(run) {
4
4
  const latestPhase = run.phases.at(-1);
5
5
  return {
@@ -53,6 +53,7 @@ export function queryWorkflowRuns(runs, scope, opts) {
53
53
  const limited = opts?.limit !== undefined ? rows.slice(0, Math.max(0, opts.limit)) : rows;
54
54
  return limited.map(summarizeWorkflowRun);
55
55
  }
56
+ export const WORKFLOW_RUN_REAP_KNOBS = Object.freeze(["maxAgeMs", "keep"]);
56
57
  export class InMemoryWorkflowRunStore {
57
58
  runs = new Map();
58
59
  async put(id, run) {
@@ -79,16 +80,16 @@ export class InMemoryWorkflowRunStore {
79
80
  return queryWorkflowRuns(this.runs.values(), scope, opts);
80
81
  }
81
82
  async reap(scope, now, opts) {
82
- assertRetentionPolicy("WorkflowRunStore.reap", opts);
83
- if (opts?.maxAgeMs === undefined && opts?.keep === undefined)
83
+ const policy = receiveRetentionPolicy("WorkflowRunStore.reap", opts, WORKFLOW_RUN_REAP_KNOBS);
84
+ if (policy.maxAgeMs === undefined && policy.keep === undefined)
84
85
  return 0;
85
86
  const terminal = [...this.runs.values()].filter((r) => r.scope === scope && isTerminalWorkflowStatus(r.status));
86
87
  terminal.sort((a, b) => b.createdAt - a.createdAt);
87
88
  const doomed = new Set();
88
89
  for (let i = 0; i < terminal.length; i++) {
89
90
  const r = terminal[i];
90
- const tooOld = opts.maxAgeMs !== undefined && (r.endedAt ?? r.createdAt) < now - opts.maxAgeMs;
91
- const overKeep = opts.keep !== undefined && i >= opts.keep;
91
+ const tooOld = policy.maxAgeMs !== undefined && (r.endedAt ?? r.createdAt) < now - policy.maxAgeMs;
92
+ const overKeep = policy.keep !== undefined && i >= policy.keep;
92
93
  if (tooOld || overKeep)
93
94
  doomed.add(r.id);
94
95
  }