@sema-agent/core 7.59.0 → 7.61.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (643) hide show
  1. package/CHANGELOG.md +1169 -0
  2. package/README.md +2 -2
  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 +4 -3
  6. package/dist/agents/agent-transcript-tool.js +4 -2
  7. package/dist/agents/cascade.d.ts +61 -10
  8. package/dist/agents/cascade.js +60 -20
  9. package/dist/agents/child-model-seat.js +6 -3
  10. package/dist/agents/composition-allowance.d.ts +53 -0
  11. package/dist/agents/composition-allowance.js +49 -0
  12. package/dist/agents/composition-placement.d.ts +29 -0
  13. package/dist/agents/composition-placement.js +24 -0
  14. package/dist/agents/cumulative-stats.d.ts +4 -0
  15. package/dist/agents/cumulative-stats.js +3 -1
  16. package/dist/agents/inherited-tool-pool.d.ts +28 -1
  17. package/dist/agents/inherited-tool-pool.js +22 -0
  18. package/dist/agents/list-agents-tool.d.ts +1 -1
  19. package/dist/agents/peer-notice-route.d.ts +1 -1
  20. package/dist/agents/peer-notice-route.js +4 -3
  21. package/dist/agents/peer-notices.d.ts +4 -4
  22. package/dist/agents/peer-notices.js +8 -4
  23. package/dist/agents/peer-session-drain.d.ts +8 -1
  24. package/dist/agents/peer-session-drain.js +36 -7
  25. package/dist/agents/repair-loop.js +16 -6
  26. package/dist/agents/retain-ledger.d.ts +11 -1
  27. package/dist/agents/retain-ledger.js +16 -3
  28. package/dist/agents/roster-store.d.ts +2 -2
  29. package/dist/agents/roster-store.js +8 -3
  30. package/dist/agents/send-message-tool.d.ts +14 -27
  31. package/dist/agents/send-message-tool.js +47 -54
  32. package/dist/agents/subagent-completion-gate.d.ts +35 -0
  33. package/dist/agents/subagent-completion-gate.js +62 -0
  34. package/dist/agents/subagent-steps.d.ts +7 -6
  35. package/dist/agents/subagent.d.ts +52 -28
  36. package/dist/agents/subagent.js +276 -246
  37. package/dist/agents/suspend-guard.d.ts +9 -0
  38. package/dist/agents/suspend-guard.js +4 -0
  39. package/dist/agents/tool-filter.d.ts +1 -3
  40. package/dist/agents/tool-filter.js +4 -12
  41. package/dist/agents/verify.d.ts +41 -14
  42. package/dist/agents/verify.js +37 -27
  43. package/dist/bench/metrics.d.ts +3 -5
  44. package/dist/bench/metrics.js +0 -1
  45. package/dist/brain/anthropic.js +1 -0
  46. package/dist/brain/degrading.js +3 -1
  47. package/dist/brain/errors.d.ts +7 -1
  48. package/dist/brain/errors.js +6 -0
  49. package/dist/brain/failover.js +2 -1
  50. package/dist/brain/open-responses.js +1 -0
  51. package/dist/brain/openai.js +1 -0
  52. package/dist/brain/provider-dialect.d.ts +10 -0
  53. package/dist/brain/provider-dialect.js +13 -2
  54. package/dist/brain/route-adjudicator.js +3 -1
  55. package/dist/brain/status-sink.d.ts +7 -1
  56. package/dist/brain/status-sink.js +6 -0
  57. package/dist/brain/stream-engine.d.ts +3 -0
  58. package/dist/brain/stream-engine.js +4 -0
  59. package/dist/brain/timeout.d.ts +3 -1
  60. package/dist/brain/timeout.js +18 -5
  61. package/dist/core/a2a.d.ts +15 -5
  62. package/dist/core/a2a.js +34 -19
  63. package/dist/core/agent-definition.d.ts +20 -0
  64. package/dist/core/agent-state.d.ts +1 -1
  65. package/dist/core/allow-entry.d.ts +61 -23
  66. package/dist/core/allow-entry.js +134 -39
  67. package/dist/core/artifact-host.d.ts +0 -2
  68. package/dist/core/artifact-host.js +0 -1
  69. package/dist/core/ask-origin.d.ts +79 -0
  70. package/dist/core/ask-origin.js +76 -0
  71. package/dist/core/ask-question.d.ts +19 -13
  72. package/dist/core/ask-question.js +8 -2
  73. package/dist/core/auto-compaction.d.ts +2 -0
  74. package/dist/core/auto-compaction.js +2 -1
  75. package/dist/core/auto-mode-defaults.d.ts +8 -0
  76. package/dist/core/auto-mode-defaults.js +1 -0
  77. package/dist/core/auto-mode-rebuild.d.ts +2 -1
  78. package/dist/core/auto-mode.d.ts +39 -4
  79. package/dist/core/auto-mode.js +66 -17
  80. package/dist/core/background-agent-store.d.ts +17 -6
  81. package/dist/core/background-agent-store.js +15 -13
  82. package/dist/core/background-shell.d.ts +12 -1
  83. package/dist/core/background-shell.js +12 -0
  84. package/dist/core/checkpoint-requirements.d.ts +24 -3
  85. package/dist/core/checkpoint-requirements.js +9 -1
  86. package/dist/core/checkpoint-store.d.ts +86 -32
  87. package/dist/core/checkpoint-store.js +10 -5
  88. package/dist/core/child-clamp-seats.d.ts +3 -2
  89. package/dist/core/child-clamp-seats.js +4 -3
  90. package/dist/core/closest-name.d.ts +13 -0
  91. package/dist/core/closest-name.js +35 -0
  92. package/dist/core/compliance.d.ts +1 -1
  93. package/dist/core/context-settings.js +3 -5
  94. package/dist/core/credential-echo.d.ts +52 -0
  95. package/dist/core/credential-echo.js +65 -0
  96. package/dist/core/credential-vocabulary.d.ts +13 -3
  97. package/dist/core/credential-vocabulary.js +12 -4
  98. package/dist/core/cross-boundary-taint.d.ts +5 -6
  99. package/dist/core/decision-receipt.d.ts +14 -1
  100. package/dist/core/decision-receipt.js +6 -3
  101. package/dist/core/delegation-frames.d.ts +13 -9
  102. package/dist/core/effective-path-target.js +2 -3
  103. package/dist/core/engine-attestation.d.ts +11 -1
  104. package/dist/core/engine-attestation.js +2 -0
  105. package/dist/core/engine-notice.d.ts +106 -32
  106. package/dist/core/file-history-retention.d.ts +8 -0
  107. package/dist/core/file-history-retention.js +14 -11
  108. package/dist/core/file-history-store.d.ts +31 -1
  109. package/dist/core/file-history-store.js +31 -2
  110. package/dist/core/frame-settlement.d.ts +15 -0
  111. package/dist/core/frame-settlement.js +10 -1
  112. package/dist/core/fs-write-gate-policy.d.ts +3 -3
  113. package/dist/core/fs-write-gate-policy.js +8 -7
  114. package/dist/core/gate-fold.js +9 -6
  115. package/dist/core/gate-lanes.js +46 -12
  116. package/dist/core/gate-outcome.d.ts +40 -1
  117. package/dist/core/gate-outcome.js +10 -0
  118. package/dist/core/git-worktree-env.d.ts +7 -3
  119. package/dist/core/git-worktree-env.js +16 -13
  120. package/dist/core/governance-codes.d.ts +19 -3
  121. package/dist/core/governance-codes.js +27 -3
  122. package/dist/core/hands-band-screen.js +0 -1
  123. package/dist/core/hands-band.d.ts +0 -3
  124. package/dist/core/hooks.d.ts +51 -60
  125. package/dist/core/hooks.js +131 -78
  126. package/dist/core/host-floor.js +3 -5
  127. package/dist/core/image-admission.d.ts +145 -52
  128. package/dist/core/image-admission.js +202 -47
  129. package/dist/core/image-downsample.d.ts +36 -69
  130. package/dist/core/image-downsample.js +111 -73
  131. package/dist/core/input-author.d.ts +36 -0
  132. package/dist/core/input-author.js +39 -0
  133. package/dist/core/integer-option.d.ts +21 -0
  134. package/dist/core/integer-option.js +13 -0
  135. package/dist/core/leg-identity.d.ts +62 -0
  136. package/dist/core/leg-identity.js +18 -0
  137. package/dist/core/locked-config.d.ts +55 -3
  138. package/dist/core/locked-config.js +84 -51
  139. package/dist/core/lsp.d.ts +5 -3
  140. package/dist/core/lsp.js +3 -2
  141. package/dist/core/mailbox-store.d.ts +85 -10
  142. package/dist/core/mailbox-store.js +31 -10
  143. package/dist/core/mcp-call-meta.d.ts +2 -2
  144. package/dist/core/mcp-call-meta.js +9 -10
  145. package/dist/core/mcp-connection-pool.d.ts +6 -20
  146. package/dist/core/mcp-connection-pool.js +10 -28
  147. package/dist/core/mcp-failure.d.ts +83 -16
  148. package/dist/core/mcp-failure.js +67 -30
  149. package/dist/core/mcp-host-seat.d.ts +131 -0
  150. package/dist/core/mcp-host-seat.js +305 -0
  151. package/dist/core/mcp-probe.d.ts +7 -2
  152. package/dist/core/mcp-probe.js +9 -4
  153. package/dist/core/mcp-server-link.d.ts +18 -6
  154. package/dist/core/mcp-server-link.js +19 -4
  155. package/dist/core/mcp-server-spec.d.ts +39 -9
  156. package/dist/core/mcp-server-spec.js +55 -21
  157. package/dist/core/mcp-session-end.d.ts +1 -2
  158. package/dist/core/mcp-session-end.js +1 -1
  159. package/dist/core/mcp.d.ts +23 -55
  160. package/dist/core/mcp.js +172 -156
  161. package/dist/core/media-byte-cap.d.ts +21 -46
  162. package/dist/core/media-byte-cap.js +55 -55
  163. package/dist/core/member-group.d.ts +7 -0
  164. package/dist/core/member-group.js +35 -0
  165. package/dist/core/memory-admission.d.ts +23 -6
  166. package/dist/core/memory-admission.js +19 -9
  167. package/dist/core/memory-engine/consolidation.d.ts +1 -1
  168. package/dist/core/memory-engine/consolidation.js +7 -1
  169. package/dist/core/memory-engine/content-origin.d.ts +13 -0
  170. package/dist/core/memory-engine/content-origin.js +21 -3
  171. package/dist/core/memory-engine/dual-root.d.ts +31 -0
  172. package/dist/core/memory-engine/dual-root.js +59 -11
  173. package/dist/core/memory-engine/engine.js +27 -24
  174. package/dist/core/memory-engine/file-backend.d.ts +13 -0
  175. package/dist/core/memory-engine/file-backend.js +35 -15
  176. package/dist/core/memory-engine/index.d.ts +2 -1
  177. package/dist/core/memory-engine/index.js +2 -1
  178. package/dist/core/memory-engine/layout.d.ts +3 -0
  179. package/dist/core/memory-engine/layout.js +13 -3
  180. package/dist/core/memory-engine/memory-deployment.d.ts +110 -0
  181. package/dist/core/memory-engine/memory-deployment.js +182 -0
  182. package/dist/core/memory-engine/scope-contract.d.ts +13 -3
  183. package/dist/core/memory-engine/scope-contract.js +2 -2
  184. package/dist/core/memory-engine/sync-client.d.ts +68 -13
  185. package/dist/core/memory-engine/sync-client.js +147 -18
  186. package/dist/core/memory-engine/sync-report.d.ts +106 -0
  187. package/dist/core/memory-engine/sync-report.js +119 -0
  188. package/dist/core/memory-engine/sync.d.ts +13 -3
  189. package/dist/core/mode-policy.d.ts +15 -7
  190. package/dist/core/mode-policy.js +18 -6
  191. package/dist/core/model-receipt.d.ts +39 -0
  192. package/dist/core/model-receipt.js +139 -0
  193. package/dist/core/mods/agent-stations.d.ts +100 -0
  194. package/dist/core/mods/agent-stations.js +154 -0
  195. package/dist/core/mods/dollar.d.ts +62 -0
  196. package/dist/core/mods/extension-call.d.ts +15 -1
  197. package/dist/core/mods/extension-call.js +7 -2
  198. package/dist/core/mods/kernel/dispatch.d.ts +9 -4
  199. package/dist/core/mods/kernel/dispatch.js +8 -8
  200. package/dist/core/mods/kernel/events.d.ts +13 -4
  201. package/dist/core/mods/kernel/events.js +14 -10
  202. package/dist/core/mods/kernel/receive.d.ts +5 -0
  203. package/dist/core/mods/kernel/receive.js +10 -0
  204. package/dist/core/mods/kernel/registration.d.ts +3 -0
  205. package/dist/core/mods/kernel/registration.js +5 -0
  206. package/dist/core/mods/kernel/site-rules.d.ts +6 -3
  207. package/dist/core/mods/kernel/site-rules.js +10 -2
  208. package/dist/core/mods/lifecycle-stations.d.ts +41 -0
  209. package/dist/core/mods/lifecycle-stations.js +35 -0
  210. package/dist/core/mods/session-append.d.ts +115 -0
  211. package/dist/core/mods/session-append.js +311 -0
  212. package/dist/core/mods/session-compact.d.ts +48 -0
  213. package/dist/core/mods/session-compact.js +194 -0
  214. package/dist/core/mods/session-receive.d.ts +93 -0
  215. package/dist/core/mods/session-receive.js +141 -0
  216. package/dist/core/mods/session-send.d.ts +72 -0
  217. package/dist/core/mods/session-send.js +88 -0
  218. package/dist/core/mods/stations.d.ts +89 -75
  219. package/dist/core/mods/stations.js +57 -53
  220. package/dist/core/mods/tool-call.d.ts +12 -4
  221. package/dist/core/mods/tool-call.js +32 -16
  222. package/dist/core/mounted-mcp.d.ts +5 -0
  223. package/dist/core/mounted-mcp.js +2 -2
  224. package/dist/core/namespaced-rule-name.d.ts +7 -1
  225. package/dist/core/namespaced-rule-name.js +13 -2
  226. package/dist/core/oracle-isolation.js +1 -1
  227. package/dist/core/output-style.js +3 -4
  228. package/dist/core/own-property-receipt.d.ts +62 -0
  229. package/dist/core/own-property-receipt.js +43 -0
  230. package/dist/core/park-selfcheck.js +12 -10
  231. package/dist/core/path-identity.d.ts +11 -0
  232. package/dist/core/path-identity.js +4 -0
  233. package/dist/core/path-rule-binding.d.ts +3 -1
  234. package/dist/core/path-rule-binding.js +3 -1
  235. package/dist/core/peer-seat.d.ts +66 -11
  236. package/dist/core/peer-seat.js +199 -42
  237. package/dist/core/permission-rule-consent.d.ts +21 -26
  238. package/dist/core/permission-rule-consent.js +22 -3
  239. package/dist/core/permission-rule-model.d.ts +38 -13
  240. package/dist/core/permission-rule-model.js +54 -16
  241. package/dist/core/permission-rule-org.d.ts +1 -1
  242. package/dist/core/permission-rule-provider.js +4 -1
  243. package/dist/core/permission-rules.d.ts +4 -0
  244. package/dist/core/permission-rules.js +11 -16
  245. package/dist/core/protocol-http-auth.d.ts +14 -2
  246. package/dist/core/protocol-http-auth.js +16 -7
  247. package/dist/core/read-face-seats.d.ts +7 -5
  248. package/dist/core/read-face-seats.js +4 -1
  249. package/dist/core/redaction-marks.d.ts +4 -3
  250. package/dist/core/redaction-marks.js +2 -2
  251. package/dist/core/remote-env.d.ts +218 -122
  252. package/dist/core/remote-env.js +133 -14
  253. package/dist/core/retention-policy.d.ts +24 -23
  254. package/dist/core/retention-policy.js +36 -2
  255. package/dist/core/retention.d.ts +4 -1
  256. package/dist/core/retention.js +37 -12
  257. package/dist/core/retired-keys.d.ts +8 -3
  258. package/dist/core/retired-keys.js +4 -1
  259. package/dist/core/rewrite-rejudge.d.ts +12 -5
  260. package/dist/core/rewrite-rejudge.js +9 -5
  261. package/dist/core/roles.d.ts +37 -3
  262. package/dist/core/roles.js +126 -78
  263. package/dist/core/row-admission.d.ts +10 -0
  264. package/dist/core/row-admission.js +5 -0
  265. package/dist/core/rule-owner.d.ts +3 -0
  266. package/dist/core/runner/advisor-instructions.d.ts +2 -1
  267. package/dist/core/runner/advisor-instructions.js +2 -1
  268. package/dist/core/runner/announce-once-ledger.d.ts +4 -4
  269. package/dist/core/runner/assemble-result.d.ts +13 -8
  270. package/dist/core/runner/assemble-result.js +12 -8
  271. package/dist/core/runner/call-hook-stations.d.ts +17 -10
  272. package/dist/core/runner/call-hook-stations.js +21 -10
  273. package/dist/core/runner/caller-roster.d.ts +12 -9
  274. package/dist/core/runner/caller-roster.js +5 -2
  275. package/dist/core/runner/checkpoint-scope.d.ts +16 -1
  276. package/dist/core/runner/checkpoint-scope.js +21 -0
  277. package/dist/core/runner/child-tree.d.ts +7 -8
  278. package/dist/core/runner/child-tree.js +6 -6
  279. package/dist/core/runner/classifier-ladder.d.ts +10 -2
  280. package/dist/core/runner/classifier-ladder.js +39 -8
  281. package/dist/core/runner/compact-session.js +14 -2
  282. package/dist/core/runner/compaction-call-options.d.ts +1 -1
  283. package/dist/core/runner/compaction-restate.d.ts +2 -2
  284. package/dist/core/runner/compaction-restate.js +4 -3
  285. package/dist/core/runner/construction-doors.d.ts +2 -2
  286. package/dist/core/runner/construction-doors.js +7 -2
  287. package/dist/core/runner/contracts.d.ts +158 -65
  288. package/dist/core/runner/cross-boundary-lane.d.ts +4 -6
  289. package/dist/core/runner/cross-boundary-lane.js +11 -2
  290. package/dist/core/runner/decide-continuation.d.ts +4 -2
  291. package/dist/core/runner/decide-continuation.js +7 -4
  292. package/dist/core/runner/denial-limit-arms.d.ts +15 -21
  293. package/dist/core/runner/denial-limit-arms.js +17 -10
  294. package/dist/core/runner/env-capability-census.d.ts +15 -20
  295. package/dist/core/runner/env-capability-census.js +25 -34
  296. package/dist/core/runner/expire-settle.d.ts +44 -0
  297. package/dist/core/runner/expire-settle.js +55 -0
  298. package/dist/core/runner/file-history-request.d.ts +2 -2
  299. package/dist/core/runner/file-history-request.js +0 -8
  300. package/dist/core/runner/gate-exit.d.ts +75 -7
  301. package/dist/core/runner/gate-exit.js +20 -1
  302. package/dist/core/runner/git-status-frame.d.ts +5 -2
  303. package/dist/core/runner/git-status-frame.js +4 -4
  304. package/dist/core/runner/halt-attribution.d.ts +2 -1
  305. package/dist/core/runner/halt-attribution.js +2 -1
  306. package/dist/core/runner/image.d.ts +7 -2
  307. package/dist/core/runner/image.js +14 -8
  308. package/dist/core/runner/inline-image.d.ts +10 -8
  309. package/dist/core/runner/inline-image.js +11 -9
  310. package/dist/core/runner/local-claims.d.ts +17 -0
  311. package/dist/core/runner/local-claims.js +18 -0
  312. package/dist/core/runner/media-removed-seat.d.ts +46 -0
  313. package/dist/core/runner/media-removed-seat.js +88 -0
  314. package/dist/core/runner/memory-consolidation-driver.js +4 -4
  315. package/dist/core/runner/park-commit.d.ts +2 -2
  316. package/dist/core/runner/permission-rule-lanes.d.ts +5 -1
  317. package/dist/core/runner/permission-rule-lanes.js +29 -10
  318. package/dist/core/runner/person-path-rows.js +1 -1
  319. package/dist/core/runner/placement-fence.d.ts +26 -0
  320. package/dist/core/runner/placement-fence.js +38 -0
  321. package/dist/core/runner/prepare-ask-lane.d.ts +6 -12
  322. package/dist/core/runner/prepare-ask-lane.js +4 -4
  323. package/dist/core/runner/prepare-boundary-parks.d.ts +6 -3
  324. package/dist/core/runner/prepare-boundary-parks.js +4 -4
  325. package/dist/core/runner/prepare-caps-and-workflow.d.ts +6 -0
  326. package/dist/core/runner/prepare-caps-and-workflow.js +5 -3
  327. package/dist/core/runner/prepare-config-doors.d.ts +6 -1
  328. package/dist/core/runner/prepare-config-doors.js +30 -26
  329. package/dist/core/runner/prepare-context-lane.d.ts +6 -2
  330. package/dist/core/runner/prepare-context-lane.js +13 -13
  331. package/dist/core/runner/prepare-delegation-surface.d.ts +13 -11
  332. package/dist/core/runner/prepare-delegation-surface.js +7 -8
  333. package/dist/core/runner/prepare-execution-env.d.ts +5 -2
  334. package/dist/core/runner/prepare-execution-env.js +7 -4
  335. package/dist/core/runner/prepare-file-history.d.ts +10 -12
  336. package/dist/core/runner/prepare-file-history.js +3 -12
  337. package/dist/core/runner/prepare-gate-stations.d.ts +23 -17
  338. package/dist/core/runner/prepare-gate-stations.js +10 -7
  339. package/dist/core/runner/prepare-hands-readface.d.ts +8 -6
  340. package/dist/core/runner/prepare-hands-readface.js +19 -11
  341. package/dist/core/runner/prepare-inherited-gate.d.ts +11 -4
  342. package/dist/core/runner/prepare-inherited-gate.js +12 -5
  343. package/dist/core/runner/prepare-lsp.d.ts +3 -0
  344. package/dist/core/runner/prepare-lsp.js +2 -2
  345. package/dist/core/runner/prepare-memory-engine-session.js +1 -1
  346. package/dist/core/runner/prepare-memory.d.ts +2 -2
  347. package/dist/core/runner/prepare-memory.js +2 -2
  348. package/dist/core/runner/prepare-park-ask.d.ts +8 -7
  349. package/dist/core/runner/prepare-park-ask.js +6 -12
  350. package/dist/core/runner/prepare-policy-chain.d.ts +15 -25
  351. package/dist/core/runner/prepare-policy-chain.js +131 -128
  352. package/dist/core/runner/prepare-project-context.d.ts +2 -2
  353. package/dist/core/runner/prepare-project-context.js +8 -5
  354. package/dist/core/runner/prepare-prompt-inputs.d.ts +4 -0
  355. package/dist/core/runner/prepare-prompt-inputs.js +4 -2
  356. package/dist/core/runner/prepare-protocol-tools.d.ts +5 -3
  357. package/dist/core/runner/prepare-protocol-tools.js +9 -2
  358. package/dist/core/runner/prepare-question-face.d.ts +6 -4
  359. package/dist/core/runner/prepare-question-face.js +2 -2
  360. package/dist/core/runner/prepare-run-refs.d.ts +3 -0
  361. package/dist/core/runner/prepare-run-refs.js +2 -2
  362. package/dist/core/runner/prepare-suspend-saga.d.ts +11 -9
  363. package/dist/core/runner/prepare-suspend-saga.js +21 -13
  364. package/dist/core/runner/prepare-task.d.ts +1 -1
  365. package/dist/core/runner/prepare-task.js +84 -42
  366. package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +6 -0
  367. package/dist/core/runner/prepare-tool-disclosure-mount.js +3 -1
  368. package/dist/core/runner/prepare-turn-wiring.d.ts +2 -0
  369. package/dist/core/runner/prepare-turn-wiring.js +7 -2
  370. package/dist/core/runner/prepare-wiring-manifest.d.ts +7 -3
  371. package/dist/core/runner/prepare-wiring-manifest.js +34 -19
  372. package/dist/core/runner/prepare-workspace-restore.d.ts +5 -0
  373. package/dist/core/runner/prepare-workspace-restore.js +12 -8
  374. package/dist/core/runner/read-root-grant.d.ts +1 -1
  375. package/dist/core/runner/read-root-grant.js +2 -1
  376. package/dist/core/runner/resume-admission.d.ts +5 -3
  377. package/dist/core/runner/resume-admission.js +17 -3
  378. package/dist/core/runner/resume-apply.js +3 -1
  379. package/dist/core/runner/resume-checkpoint-screen.js +4 -4
  380. package/dist/core/runner/resume-claim.d.ts +8 -3
  381. package/dist/core/runner/resume-claim.js +28 -12
  382. package/dist/core/runner/resume-internals-and-config.d.ts +2 -2
  383. package/dist/core/runner/resume-internals-and-config.js +10 -1
  384. package/dist/core/runner/resume-preflight.d.ts +3 -2
  385. package/dist/core/runner/resume-preflight.js +13 -26
  386. package/dist/core/runner/retired-runner-deps.js +6 -1
  387. package/dist/core/runner/run-attachment-seats.js +3 -3
  388. package/dist/core/runner/run-brain-sinks.js +1 -0
  389. package/dist/core/runner/run-git-lane.d.ts +3 -1
  390. package/dist/core/runner/run-git-lane.js +3 -2
  391. package/dist/core/runner/run-harness-handlers.d.ts +3 -1
  392. package/dist/core/runner/run-harness-handlers.js +5 -3
  393. package/dist/core/runner/run-identity-wiring.d.ts +2 -2
  394. package/dist/core/runner/run-identity-wiring.js +15 -6
  395. package/dist/core/runner/run-leg.d.ts +3 -3
  396. package/dist/core/runner/run-leg.js +65 -56
  397. package/dist/core/runner/run-notification-lane.d.ts +3 -1
  398. package/dist/core/runner/run-notification-lane.js +36 -12
  399. package/dist/core/runner/run-recovery-lanes.js +3 -2
  400. package/dist/core/runner/run-settle-and-teardown.js +14 -8
  401. package/dist/core/runner/run-stop-and-final-verify.d.ts +4 -0
  402. package/dist/core/runner/run-stop-and-final-verify.js +12 -4
  403. package/dist/core/runner/run-telemetry-and-budget-seats.d.ts +1 -1
  404. package/dist/core/runner/run-terminal-adoption.d.ts +1 -1
  405. package/dist/core/runner/run-terminal-adoption.js +26 -17
  406. package/dist/core/runner/run-turn-boundary.js +37 -19
  407. package/dist/core/runner/runtask.d.ts +25 -7
  408. package/dist/core/runner/runtask.js +46 -22
  409. package/dist/core/runner/session-rule-policy.d.ts +1 -1
  410. package/dist/core/runner/session-rule-policy.js +6 -1
  411. package/dist/core/runner/shell-env-withheld.d.ts +1 -1
  412. package/dist/core/runner/skills-seat.js +2 -2
  413. package/dist/core/runner/stream-halt-verbs.d.ts +1 -14
  414. package/dist/core/runner/stream-halt-verbs.js +4 -3
  415. package/dist/core/runner/stream-reap.d.ts +7 -6
  416. package/dist/core/runner/stream-reap.js +13 -16
  417. package/dist/core/runner/stream-settle-backstop.d.ts +3 -2
  418. package/dist/core/runner/stream-settle-backstop.js +5 -3
  419. package/dist/core/runner/stream-steer-verb.d.ts +5 -2
  420. package/dist/core/runner/stream-steer-verb.js +8 -7
  421. package/dist/core/runner/sub-agent-deny-lists.js +10 -7
  422. package/dist/core/runner/synthetic-tools.js +2 -2
  423. package/dist/core/runner/terminal-account.d.ts +11 -1
  424. package/dist/core/runner/terminal-account.js +20 -0
  425. package/dist/core/runner/terminal-projection.d.ts +8 -2
  426. package/dist/core/runner/terminal-projection.js +2 -2
  427. package/dist/core/runner/tool-disclosure.d.ts +3 -0
  428. package/dist/core/runner/tool-disclosure.js +5 -4
  429. package/dist/core/runner/tool-end-body.d.ts +3 -3
  430. package/dist/core/runner/tool-end-body.js +1 -1
  431. package/dist/core/runner/tool-face-overlay.d.ts +1 -1
  432. package/dist/core/runner/tool-face-overlay.js +26 -19
  433. package/dist/core/runner/tool-output-projection.d.ts +3 -3
  434. package/dist/core/runner/tool-output-projection.js +7 -6
  435. package/dist/core/runner/tool-result-media-seat.d.ts +9 -1
  436. package/dist/core/runner/tool-result-media-seat.js +17 -1
  437. package/dist/core/runner/tool-table-view.d.ts +56 -0
  438. package/dist/core/runner/tool-table-view.js +51 -0
  439. package/dist/core/runner/turn-attachments.d.ts +6 -7
  440. package/dist/core/runner/turn-attachments.js +4 -17
  441. package/dist/core/runner/void-verifier-pause.d.ts +33 -0
  442. package/dist/core/runner/void-verifier-pause.js +41 -0
  443. package/dist/core/runner-deps.d.ts +55 -43
  444. package/dist/core/secret-env.d.ts +14 -13
  445. package/dist/core/secret-env.js +8 -9
  446. package/dist/core/session-log-transfer.js +9 -10
  447. package/dist/core/session-policy-store.d.ts +10 -3
  448. package/dist/core/session-policy-store.js +21 -3
  449. package/dist/core/session-reconcile.d.ts +3 -2
  450. package/dist/core/session-reconcile.js +7 -4
  451. package/dist/core/session-store.d.ts +5 -2
  452. package/dist/core/session-store.js +53 -16
  453. package/dist/core/session.d.ts +2 -1
  454. package/dist/core/shell-confinement.d.ts +37 -0
  455. package/dist/core/shell-confinement.js +56 -0
  456. package/dist/core/skill-grant.d.ts +9 -0
  457. package/dist/core/skill-grant.js +18 -0
  458. package/dist/core/store-contracts/checkpoint-store-contract.d.ts +2 -2
  459. package/dist/core/store-contracts/checkpoint-store-contract.js +15 -2
  460. package/dist/core/store-contracts/file-history-store-contract.d.ts +5 -2
  461. package/dist/core/store-contracts/file-history-store-contract.js +25 -1
  462. package/dist/core/store-contracts/mailbox-store-contract.d.ts +12 -5
  463. package/dist/core/store-contracts/mailbox-store-contract.js +156 -9
  464. package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
  465. package/dist/core/store-contracts/tool-result-store-contract.js +67 -0
  466. package/dist/core/stub-env.d.ts +5 -5
  467. package/dist/core/stub-env.js +11 -1
  468. package/dist/core/swappable-deps.d.ts +17 -43
  469. package/dist/core/swappable-deps.js +15 -5
  470. package/dist/core/synthetic-read-verdict.d.ts +1 -1
  471. package/dist/core/task-event.d.ts +35 -10
  472. package/dist/core/task-limits.d.ts +5 -0
  473. package/dist/core/task-notification.d.ts +172 -12
  474. package/dist/core/task-notification.js +209 -12
  475. package/dist/core/task-registry-agent.d.ts +23 -55
  476. package/dist/core/task-registry-agent.js +41 -56
  477. package/dist/core/task-registry-monitor.d.ts +8 -1
  478. package/dist/core/task-registry-monitor.js +43 -61
  479. package/dist/core/task-registry-shared.d.ts +52 -114
  480. package/dist/core/task-registry-shared.js +24 -48
  481. package/dist/core/task-registry-workflow.js +5 -22
  482. package/dist/core/task-registry.d.ts +64 -90
  483. package/dist/core/task-registry.js +73 -119
  484. package/dist/core/task-result.d.ts +27 -19
  485. package/dist/core/task-spec-members.d.ts +39 -0
  486. package/dist/core/task-spec-members.js +92 -0
  487. package/dist/core/task-spec.d.ts +13 -16
  488. package/dist/core/task-stream.d.ts +1 -1
  489. package/dist/core/task-tool-shape.d.ts +7 -57
  490. package/dist/core/task-tool-shape.js +7 -66
  491. package/dist/core/terminal-cause.d.ts +30 -0
  492. package/dist/core/terminal-cause.js +1 -0
  493. package/dist/core/tool-catalog-entries.js +3 -6
  494. package/dist/core/tool-check-reading.js +16 -10
  495. package/dist/core/tool-conformance.js +1 -2
  496. package/dist/core/tool-errors.d.ts +6 -3
  497. package/dist/core/tool-errors.js +2 -0
  498. package/dist/core/tool-face-reader.d.ts +7 -6
  499. package/dist/core/tool-face-reader.js +6 -4
  500. package/dist/core/tool-face.d.ts +2 -3
  501. package/dist/core/tool-name-aliases.d.ts +23 -28
  502. package/dist/core/tool-name-aliases.js +63 -7
  503. package/dist/core/tool-name-readings.d.ts +14 -3
  504. package/dist/core/tool-name-readings.js +2 -0
  505. package/dist/core/tool-policy.d.ts +113 -22
  506. package/dist/core/tool-policy.js +85 -15
  507. package/dist/core/tool-registry.d.ts +5 -5
  508. package/dist/core/tool-registry.js +2 -2
  509. package/dist/core/tool-result-store.d.ts +111 -5
  510. package/dist/core/tool-result-store.js +52 -12
  511. package/dist/core/tool-spec.d.ts +39 -10
  512. package/dist/core/trace.d.ts +18 -2
  513. package/dist/core/types.d.ts +3 -3
  514. package/dist/core/types.js +1 -1
  515. package/dist/core/untrusted-text.js +1 -1
  516. package/dist/core/user-attachment.d.ts +10 -5
  517. package/dist/core/user-attachment.js +40 -27
  518. package/dist/core/workflow-journal-store.d.ts +1 -1
  519. package/dist/core/workflow-run-store.d.ts +2 -0
  520. package/dist/core/workflow-run-store.js +6 -5
  521. package/dist/core/workflow-settled-run.d.ts +5 -0
  522. package/dist/core/workflow-settled-run.js +7 -0
  523. package/dist/engine/execution-env/node-execution-env.d.ts +37 -7
  524. package/dist/engine/execution-env/node-execution-env.js +224 -21
  525. package/dist/engine/harness/agent-harness.d.ts +66 -19
  526. package/dist/engine/harness/agent-harness.js +98 -27
  527. package/dist/engine/harness/messages.d.ts +4 -3
  528. package/dist/engine/harness/messages.js +2 -2
  529. package/dist/engine/harness/types.d.ts +151 -34
  530. package/dist/engine/llm/media-removed.d.ts +14 -0
  531. package/dist/engine/llm/media-removed.js +9 -0
  532. package/dist/engine/llm/rejected-images.d.ts +35 -25
  533. package/dist/engine/llm/rejected-images.js +59 -10
  534. package/dist/engine/llm/types.d.ts +24 -3
  535. package/dist/engine/llm/types.js +7 -3
  536. package/dist/engine/loop/agent-loop.d.ts +18 -13
  537. package/dist/engine/loop/agent-loop.js +173 -32
  538. package/dist/engine/loop/types.d.ts +21 -5
  539. package/dist/engine/lsp/node-lsp-manager.d.ts +3 -3
  540. package/dist/engine/lsp/node-lsp-manager.js +32 -13
  541. package/dist/engine/session/import-validate.js +7 -0
  542. package/dist/fixtures/index.d.ts +7 -5
  543. package/dist/fixtures/index.js +5 -3
  544. package/dist/index.d.ts +41 -23
  545. package/dist/index.js +29 -16
  546. package/dist/internal/harness-types.d.ts +3 -1
  547. package/dist/internal/llm.d.ts +2 -1
  548. package/dist/internal/llm.js +1 -0
  549. package/dist/orchestration/goal.d.ts +6 -2
  550. package/dist/orchestration/goal.js +6 -3
  551. package/dist/orchestration/run-workflow-tool.d.ts +20 -20
  552. package/dist/orchestration/run-workflow-tool.js +63 -56
  553. package/dist/orchestration/workflow-governance.d.ts +1 -1
  554. package/dist/orchestration/workflow-governance.js +2 -1
  555. package/dist/orchestration/workflow-types.d.ts +2 -2
  556. package/dist/orchestration/workflow.d.ts +8 -0
  557. package/dist/orchestration/workflow.js +33 -9
  558. package/dist/prompts/default.d.ts +1 -10
  559. package/dist/prompts/default.js +0 -2
  560. package/dist/stores/file/background-agent-store.d.ts +1 -1
  561. package/dist/stores/file/background-agent-store.js +19 -14
  562. package/dist/stores/file/checkpoint-store.d.ts +127 -2
  563. package/dist/stores/file/checkpoint-store.js +24 -16
  564. package/dist/stores/file/file-history-store.d.ts +1 -1
  565. package/dist/stores/file/file-history-store.js +4 -1
  566. package/dist/stores/file/index.d.ts +9 -6
  567. package/dist/stores/file/index.js +33 -9
  568. package/dist/stores/file/ledger-tuning.d.ts +23 -0
  569. package/dist/stores/file/ledger-tuning.js +21 -0
  570. package/dist/stores/file/mailbox-store.d.ts +1 -1
  571. package/dist/stores/file/mailbox-store.js +43 -21
  572. package/dist/stores/file/memory-store.d.ts +1 -1
  573. package/dist/stores/file/memory-store.js +4 -1
  574. package/dist/stores/file/permission-rule-adopt.js +24 -21
  575. package/dist/stores/file/permission-rule-store.js +6 -3
  576. package/dist/stores/file/session-policy-store.d.ts +1 -1
  577. package/dist/stores/file/session-policy-store.js +4 -1
  578. package/dist/stores/file/session-store.d.ts +17 -4
  579. package/dist/stores/file/session-store.js +22 -19
  580. package/dist/stores/file/shared-ledger.d.ts +26 -0
  581. package/dist/stores/file/shared-ledger.js +38 -9
  582. package/dist/stores/file/tool-result-store.d.ts +31 -2
  583. package/dist/stores/file/tool-result-store.js +129 -7
  584. package/dist/stores/file/usage-window-store.d.ts +1 -1
  585. package/dist/stores/file/usage-window-store.js +4 -1
  586. package/dist/stores/file/workflow-journal-store.d.ts +1 -13
  587. package/dist/stores/file/workflow-journal-store.js +4 -18
  588. package/dist/stores/file/workflow-run-store.d.ts +1 -1
  589. package/dist/stores/file/workflow-run-store.js +15 -10
  590. package/dist/tools/fs/containment-face.d.ts +5 -0
  591. package/dist/tools/fs/dead-cwd.d.ts +5 -5
  592. package/dist/tools/fs/dead-cwd.js +4 -11
  593. package/dist/tools/fs/encoding.d.ts +13 -4
  594. package/dist/tools/fs/encoding.js +17 -2
  595. package/dist/tools/fs/fs-bash-background-text.d.ts +13 -0
  596. package/dist/tools/fs/fs-bash-background-text.js +7 -0
  597. package/dist/tools/fs/fs-bash.d.ts +11 -22
  598. package/dist/tools/fs/fs-bash.js +58 -154
  599. package/dist/tools/fs/fs-pdf.d.ts +2 -2
  600. package/dist/tools/fs/fs-pdf.js +34 -27
  601. package/dist/tools/fs/fs-read.d.ts +5 -4
  602. package/dist/tools/fs/fs-read.js +35 -18
  603. package/dist/tools/fs/fs-search-tools.js +4 -1
  604. package/dist/tools/fs/fs-shared.d.ts +39 -16
  605. package/dist/tools/fs/fs-shared.js +25 -6
  606. package/dist/tools/fs/fs-write.js +5 -5
  607. package/dist/tools/fs/index.d.ts +15 -9
  608. package/dist/tools/fs/index.js +12 -18
  609. package/dist/tools/fs/pdf.d.ts +4 -4
  610. package/dist/tools/fs/pdf.js +6 -6
  611. package/dist/tools/fs/read-deny-home.js +8 -1
  612. package/dist/tools/fs/read-deny.d.ts +26 -2
  613. package/dist/tools/fs/read-deny.js +9 -2
  614. package/dist/tools/fs/read-floor.d.ts +57 -6
  615. package/dist/tools/fs/read-floor.js +241 -2
  616. package/dist/tools/fs/removal-targets.d.ts +9 -4
  617. package/dist/tools/fs/removal-targets.js +17 -9
  618. package/dist/tools/fs/search.d.ts +6 -5
  619. package/dist/tools/fs/search.js +10 -10
  620. package/dist/tools/fs/shell-read-establish.js +3 -1
  621. package/dist/tools/fs/shell-read-identity.d.ts +3 -1
  622. package/dist/tools/fs/shell-read-identity.js +4 -2
  623. package/dist/tools/fs/shell-read-judge.d.ts +7 -1
  624. package/dist/tools/fs/shell-read-judge.js +1 -1
  625. package/dist/tools/monitor.d.ts +12 -10
  626. package/dist/tools/monitor.js +22 -13
  627. package/dist/tools/scheduler-tools.js +42 -4
  628. package/dist/tools/web.d.ts +0 -10
  629. package/dist/tools/web.js +1 -4
  630. package/dist/tools/worktree.d.ts +5 -1
  631. package/dist/tools/worktree.js +20 -17
  632. package/package.json +8 -3
  633. package/test/export-surface.snapshot.json +166 -30
  634. package/wire-changes/core-stores-sql@7.60.0.json +30 -0
  635. package/wire-changes/core-stores-sql@7.61.0.json +480 -0
  636. package/wire-changes/core@7.60.0.json +3274 -0
  637. package/wire-changes/core@7.61.0.json +4405 -0
  638. package/wire-changes/mods-kernel@7.60.0.json +62 -0
  639. package/wire-changes/mods-kernel@7.61.0.json +65 -0
  640. package/wire-changes/primitives@7.60.0.json +30 -0
  641. package/wire-changes/primitives@7.61.0.json +30 -0
  642. package/dist/core/runner/image-removed-seat.d.ts +0 -12
  643. package/dist/core/runner/image-removed-seat.js +0 -19
@@ -5,7 +5,7 @@ import { createHookEnvCapabilities, mintHookInvocationIdentity } from "../hooks.
5
5
  import { chainJudges } from "../mods/stations.js";
6
6
  import { failureFields } from "../mcp-failure.js";
7
7
  import { toolNamesOfServer } from "../mounted-mcp.js";
8
- import { isRemoteExecutionEnv, missingRestoreSurface } from "../remote-env.js";
8
+ import { declaredSuspend, isRemoteExecutionEnv, missingRestoreSurface } from "../remote-env.js";
9
9
  import { isVolatileOffloadStore } from "../tool-result-store.js";
10
10
  import { durableMandateSourceOf, isLiveApproverSeat } from "../tool-policy.js";
11
11
  import { deliverEngineNotice } from "../types.js";
@@ -13,8 +13,10 @@ import { inlineUntrusted } from "../untrusted-text.js";
13
13
  import { mountWriteProtection } from "./write-protection-station.js";
14
14
  import { autoRunOnRecommendationEffective } from "./memory-consolidation-driver.js";
15
15
  import { GLOBAL_USAGE_KEY, usageRetryAfterMs, windowsGovernCost } from "../usage-window-store.js";
16
+ import { rosterEntryNamed, toolCallFaceOf } from "../tool-roster.js";
17
+ import { isShellFaceToolName } from "../tool-registry.js";
16
18
  import { LSP_CONTRACT_ID, askSeatEffective, countElicitOptIns, deriveHandsSeam, deriveLspSeam, deriveWiringManifest, resolveDeclaredDurability, resolveElicitSeam, resolveQuestionSeam, resolveSubagentTranscriptTier } from "../wiring-manifest.js";
17
- import { modePolicyOf } from "../mode-policy.js";
19
+ import { modePolicyOf, modeQuestionReaches } from "../mode-policy.js";
18
20
  export function mcpManifestEntries(entries, statuses, rosterNames) {
19
21
  return (entries ?? []).map((entry) => {
20
22
  const status = statuses.find((s) => s.name === entry.name);
@@ -118,23 +120,28 @@ function announceDurableGateUnavailable(args) {
118
120
  });
119
121
  }
120
122
  export function prepareWiringManifest(input) {
121
- const { spec, deps, internals, resume, sessionId, runId, hostTaskId, taskScope, modBus, standingModBus, checkpointScope, policyLayers, effectivePolicy, handsEnabled, taskRootFinal, legWriteGuard, mcp, irreversibleTools, egressTools, toolEffects, ownedEnv, executionEnv, offloadStore, onceLedger, usageWindows, envLifetimeSuspendAt, runtimeCaps, resolvedInteractionPosture, durableQuestionFace, liveQuestionFace, checkpointStore, sessions, modelGateManifest, autoModeArmReason, permissionMode, lockedPreflight, peerLaneRefs, frameSettlement, sessionBox, harness, pausedRef, askSeat, liveInheritedGate, delegation, toolRoster, readDenyBuiltinTiersActive, lspManagerWired, shellReadStationArmed, crossBoundaryStationEngaged, lspDiagnosticsLive, fileHistoryFact, projectMemoryFact, sessionRulesChildrenReadLive, memoryPollution, advisorFact, hostFloorPosture, runOrigin } = input;
123
+ const { spec, deps, internals, resume, sessionId, runId, hostTaskId, taskScope, modBus, standingModBus, checkpointScope, policyLayers, effectivePolicy, handsEnabled, taskRootFinal, legWriteGuard, mcp, irreversibleTools, egressTools, toolEffects, ownedEnv, executionEnv, offloadStore, onceLedger, usageWindows, envLifetimeSuspendAt, runtimeCaps, resolvedInteractionPosture, durableQuestionFace, liveQuestionFace, checkpointStore, sessions, modelGateManifest, autoModeArmReason, permissionMode, lockedPreflight, peerLaneRefs, frameSettlement, receiveSeat, sessionBox, harness, pausedRef, askSeat, liveInheritedGate, delegation, toolRoster, readDenyBuiltinTiersActive, lspManagerWired, shellReadStationArmed, crossBoundaryStationEngaged, lspDiagnosticsLive, fileHistoryFact, projectMemoryFact, sessionRulesChildrenReadLive, memoryPollution, advisorFact, hostFloorPosture, runOrigin } = input;
122
124
  const onAsk = askSeat.value;
123
125
  const handWriteTools = toolRoster.entries.filter((e) => e.mountedBy === "hands" && (e.effect === "write" || e.effect === "idempotent")).map((e) => e.name);
124
126
  const hasEffectAwareGate = policyLayers.length > 0 || chainJudges(standingModBus);
125
127
  const rosterHolds = new Set(toolRoster.entries.map((e) => e.name));
126
- const peerWriteUngated = modePolicyOf(permissionMode.current).unstated === "ask"
128
+ const modeAsksUnstated = modePolicyOf(permissionMode.current).unstated === "ask";
129
+ const peerWriteUngated = modeAsksUnstated
127
130
  ? []
128
131
  : mcp.tools.filter((t) => rosterHolds.has(t.name) && t.permissionSeat === "passthrough" && !irreversibleTools.has(t.name) && !egressTools.has(t.name) && (toolEffects.get(t.name) ?? "write") !== "read").map((t) => t.name);
129
- const firstPartyWriteUngated = (spec.tools ?? [])
132
+ const requestWriteTools = (spec.tools ?? [])
130
133
  .map((t) => t.name)
131
- .filter((name) => !irreversibleTools.has(name) && !egressTools.has(name) && toolEffects.get(name) === "write");
132
- const handOrFirstPartyUngated = !hasEffectAwareGate && (handWriteTools.length > 0 || firstPartyWriteUngated.length > 0);
133
- if (handOrFirstPartyUngated || peerWriteUngated.length > 0) {
134
+ .filter((name) => !irreversibleTools.has(name) && !egressTools.has(name))
135
+ .filter((name) => toolEffects.get(name) === "write" || (toolCallFaceOf(toolRoster, name)?.names ?? []).some(isShellFaceToolName));
136
+ const callerAnsweredByMode = (name) => modeAsksUnstated && rosterEntryNamed(toolRoster, name)?.source === "caller";
137
+ const callerWriteUnasked = requestWriteTools.filter((name) => callerAnsweredByMode(name) && !modeQuestionReaches(permissionMode.current, toolRoster, name, (spec.tools ?? []).findLast((t) => t.name === name)?.permissionSeat));
138
+ const firstPartyWriteUngated = hasEffectAwareGate ? [] : requestWriteTools.filter((name) => !callerAnsweredByMode(name));
139
+ if ((!hasEffectAwareGate && handWriteTools.length > 0) || callerWriteUnasked.length > 0 || firstPartyWriteUngated.length > 0 || peerWriteUngated.length > 0) {
134
140
  const what = [
135
141
  !hasEffectAwareGate && handWriteTools.length > 0 ? `hand tools [${handWriteTools.join(", ")}]` : undefined,
136
142
  peerWriteUngated.length > 0 ? `server write tools under ${permissionMode.current} [${peerWriteUngated.join(", ")}]` : undefined,
137
- !hasEffectAwareGate && firstPartyWriteUngated.length > 0 ? `write tools [${firstPartyWriteUngated.join(", ")}]` : undefined,
143
+ firstPartyWriteUngated.length > 0 ? `write tools [${firstPartyWriteUngated.join(", ")}]` : undefined,
144
+ callerWriteUnasked.length > 0 ? `write tools under ${permissionMode.current} [${callerWriteUnasked.join(", ")}]` : undefined,
138
145
  ]
139
146
  .filter(Boolean)
140
147
  .join(" + ");
@@ -145,9 +152,14 @@ export function prepareWiringManifest(input) {
145
152
  ungatedWarnedShapes.set(deps, shapes);
146
153
  }
147
154
  shapes.add(what);
148
- deps.onError?.(new Error(`write-capable ${what} are present but UNGATED — wire an effect-aware tool policy (or a PreToolUse hook). ` +
149
- `bash/MCP irreversible actions are otherwise unadjudicated; the deployment sandbox/egress boundary is the only protection (design/77 §4, design/53 §2.H). ` +
155
+ deps.onError?.(new Error(`write-capable ${what} are present but UNGATED — ` +
156
+ (hasEffectAwareGate
157
+ ? `no question of the ${permissionMode.current} mode reaches their calls. `
158
+ : `wire an effect-aware tool policy (or a PreToolUse hook). bash/MCP irreversible actions are otherwise unadjudicated; the deployment sandbox/egress boundary is the only protection (design/77 §4, design/53 §2.H). `) +
150
159
  (peerWriteUngated.length > 0 ? `Under ${permissionMode.current} a server's tools run with nobody stating them; a deny or ask rule naming them still gates them. ` : "") +
160
+ (callerWriteUnasked.length > 0
161
+ ? `Under ${permissionMode.current} a caller's tool that declares no permission seat answers for itself: the mode's question never reaches its calls (in auto, the classifier rules only on what a rule or a policy asks); declare permissionSeat: "passthrough" on it to put each call to the mode's question. A deny or ask rule naming it still gates it. `
162
+ : "") +
151
163
  `(This warning fires once per deployment per tool-set shape.)`), { phase: "config", sessionId });
152
164
  }
153
165
  }
@@ -155,21 +167,23 @@ export function prepareWiringManifest(input) {
155
167
  const blockedToolCalls = new Set();
156
168
  const batchHaltRef = {};
157
169
  const blockedTracked = ["classic.PostToolUse", "classic.PreToolUse", "classic.PostToolUseFailure", "classic.PostToolBatch"].some((ev) => modBus.hasHandlers(ev));
158
- const restoreSurfaceGap = ownedEnv !== undefined && isRemoteExecutionEnv(ownedEnv) && ownedEnv.capabilities.suspendable ? missingRestoreSurface(ownedEnv) : [];
159
- const incompleteSuspendAdapter = restoreSurfaceGap.length > 0 ? restoreSurfaceGap : undefined;
170
+ const ownedRemote = ownedEnv !== undefined && isRemoteExecutionEnv(ownedEnv) ? ownedEnv : undefined;
171
+ const ownedSuspend = ownedRemote !== undefined ? declaredSuspend(ownedRemote) : undefined;
172
+ const restoreSurfaceGap = ownedRemote !== undefined && ownedSuspend === true ? missingRestoreSurface(ownedRemote) : [];
173
+ const suspendTargetGap = ownedEnv === undefined ? undefined
174
+ : ownedRemote === undefined ? "is not a RemoteExecutionEnv (it would be destroyed on suspend, so a resumed file or shell tool would act on a fresh, empty env)"
175
+ : ownedSuspend === "undeclared" ? "does not declare capabilities.suspendable (absent, not a boolean, or unreadable), so it is neither snapshot nor parked"
176
+ : restoreSurfaceGap.length > 0 ? `declares capabilities.suspendable but its adapter does not implement ${restoreSurfaceGap.join(" or ")}` : undefined;
160
177
  const durableSuspendInfraReady = resolveCheckpointStore(spec, deps) !== undefined &&
161
178
  !(offloadStore !== undefined && isVolatileOffloadStore(offloadStore)) &&
162
- (ownedEnv === undefined || isRemoteExecutionEnv(ownedEnv)) &&
163
- incompleteSuspendAdapter === undefined;
179
+ suspendTargetGap === undefined;
164
180
  const resourceSuspendEligible = spec.resourceSuspend !== undefined && durableSuspendInfraReady;
165
181
  if (spec.resourceSuspend !== undefined && !resourceSuspendEligible) {
166
182
  const why = resolveCheckpointStore(spec, deps) === undefined
167
183
  ? "no CheckpointStore is wired"
168
184
  : offloadStore !== undefined && isVolatileOffloadStore(offloadStore)
169
185
  ? "tool-result offload uses the in-memory store (a resume needs durable results)"
170
- : incompleteSuspendAdapter !== undefined
171
- ? `the per-task execution env declares capabilities.suspendable but its adapter does not implement ${incompleteSuspendAdapter.join(" or ")} (a snapshot nothing can restore is worse than no snapshot)`
172
- : "the per-task execution env is not a RemoteExecutionEnv (it would be destroyed on suspend)";
186
+ : `the per-task execution env ${suspendTargetGap}`;
173
187
  onceLedger.onError(new Error(`resourceSuspend is set but INACTIVE: ${why}; resource limits will hard-fail, not suspend`), {
174
188
  phase: "config",
175
189
  sessionId,
@@ -239,6 +253,7 @@ export function prepareWiringManifest(input) {
239
253
  ownTokens: () => internals?.peerSelfRef?.current.ownTokens ?? [],
240
254
  refs: peerLaneRefs,
241
255
  settlement: frameSettlement,
256
+ receive: receiveSeat,
242
257
  selfName: () => internals?.explicitAgentName,
243
258
  parked: () => pausedRef.current !== undefined,
244
259
  markExternalContent: (reason) => memoryPollution?.()?.markPolluted(reason, "observed"),
@@ -268,5 +283,5 @@ export function prepareWiringManifest(input) {
268
283
  });
269
284
  const hookContextConsumerWired = ["classic.PreToolUse", "classic.PostToolUse", "classic.PostToolUseFailure"].some((ev) => modBus.hasHandlers(ev));
270
285
  const hookEnvFace = hookContextConsumerWired && (ownedEnv ?? deps.executionEnv) != null ? createHookEnvCapabilities(executionEnv) : undefined;
271
- return { onAsk, preToolContexts, blockedToolCalls, batchHaltRef, blockedTracked, incompleteSuspendAdapter, durableSuspendInfraReady, resourceSuspendEligible, usageGovernance, platformSuspendArmed, durableApproval, wiringManifest, writeProtection, parkLaneArmed, gateMachineryActive, hookIdentity, hookEnvFace, sessionBoxBound };
286
+ return { onAsk, preToolContexts, blockedToolCalls, batchHaltRef, blockedTracked, suspendTargetGap, durableSuspendInfraReady, resourceSuspendEligible, usageGovernance, platformSuspendArmed, durableApproval, wiringManifest, writeProtection, parkLaneArmed, gateMachineryActive, hookIdentity, hookEnvFace, sessionBoxBound };
272
287
  }
@@ -1,3 +1,4 @@
1
+ import type { PlacementTarget } from "../remote-env.js";
1
2
  import type { ExecutionEnv } from "../../internal/harness.js";
2
3
  import type { RunnerDeps, TaskSpec } from "../types.js";
3
4
  import type { PrepareResume, RunInternals } from "./contracts.js";
@@ -32,6 +33,8 @@ export interface PrepareWorkspaceRestoreInput {
32
33
  /** borrowed-readonly — where a delegated child landed against where it was asked (the execution-env phase's one
33
34
  * judgment), reported beside the root it resolved; absent on a leg no delegation caller placed. */
34
35
  placement?: import("./contracts.js").ChildPlacement | undefined;
36
+ /** borrowed-readonly — the fence the execution-env phase minted this leg under (absent when unfenced): the receipt reads it. */
37
+ placementFence: PlacementTarget | undefined;
35
38
  /** borrowed-readonly — prepare's abort seat; only `.signal` is read (kept as the object so the
36
39
  * moved body's `abortController.signal` spelling stays verbatim). */
37
40
  abortController: {
@@ -55,6 +58,8 @@ export interface PrepareWorkspaceRestoreResult {
55
58
  /** owned — the leg's ONE remoteness reading: its paths name locations in a remote / non-host env (read by the
56
59
  * observation sink below and the leg's `workspace_changed` frame alike). */
57
60
  remote: boolean;
61
+ /** owned — the target this leg's env reported at the settle point: the fence of every leg it hands work to (absent: none). */
62
+ ownTarget: PlacementTarget | undefined;
58
63
  }
59
64
  /** The B-4 phase body — the workspace-restore slice, verbatim (see the module header for the contract). */
60
65
  export declare function prepareWorkspaceRestore(input: PrepareWorkspaceRestoreInput): Promise<PrepareWorkspaceRestoreResult>;
@@ -1,4 +1,5 @@
1
- import { frozenHandleCopy, isRemoteExecutionEnv, missingRestoreSurface } from "../remote-env.js";
1
+ import { declaredSuspend, frozenHandleCopy, isRemoteExecutionEnv, missingRestoreSurface, pathsAreHostLocal, placementHonored, placementTargetOf } from "../remote-env.js";
2
+ import { settleOwnTarget } from "./placement-fence.js";
2
3
  import { remoteEnvFailureNote, restoreWorkspaceWithRetry } from "./remote-env-retry.js";
3
4
  import { rebaseWorkspacePathAcross } from "./workspace-path.js";
4
5
  export { remoteEnvFailureNote, restoreWorkspaceWithRetry } from "./remote-env-retry.js";
@@ -20,17 +21,18 @@ export async function prepareWorkspaceRestore(input) {
20
21
  if (resumedHandle.provider !== handle.provider) {
21
22
  failResume(`resume workspace identity mismatch: the checkpoint records provider "${handle.provider}" but the resumed env reports "${resumedHandle.provider}" — refusing to continue a workspace on a different backend (wire the factory to rebuild the checkpointed lane and re-resume)`);
22
23
  }
23
- if (handle.deviceId !== undefined && resumedHandle.deviceId !== handle.deviceId) {
24
- failResume(resumedHandle.deviceId === undefined
25
- ? `resume workspace identity mismatch: the checkpoint records deviceId "${handle.deviceId}" but the resumed env reports none — a device-bound workspace cannot be verified on a handle that does not state its device (absence is not a match)`
26
- : `resume workspace identity mismatch: the checkpoint records deviceId "${handle.deviceId}" but the resumed env reports "${resumedHandle.deviceId}" — refusing to continue on a different physical device`);
24
+ const reported = placementTargetOf(resumedHandle);
25
+ if (!placementHonored(input.placementFence, reported)) {
26
+ failResume(reported?.deviceId === undefined
27
+ ? `resume workspace identity mismatch: the placement fence names deviceId "${input.placementFence?.deviceId}" but the resumed env reports none — a device-bound workspace cannot be verified on a handle that does not state its device (absence is not a match)`
28
+ : `resume workspace identity mismatch: the placement fence names deviceId "${input.placementFence?.deviceId}" but the resumed env reports "${reported.deviceId}" — refusing to continue on a different physical device`);
27
29
  }
28
30
  };
29
31
  if (ownedEnv === undefined || !isRemoteExecutionEnv(ownedEnv)) {
30
32
  failResume("resume needs a RemoteExecutionEnv from executionEnvFactory to restore the workspace snapshot");
31
33
  }
32
34
  else if (handle.snapshotId === undefined) {
33
- if (handle.restoreMode !== "park_only" && ownedEnv.capabilities.suspendable) {
35
+ if (handle.restoreMode !== "park_only" && declaredSuspend(ownedEnv) !== false) {
34
36
  failResume("checkpoint workspaceHandle has no snapshotId and is not a park_only handle, but the resumed env is suspendable — refusing to resume on a possibly-unrestored workspace (corrupt checkpoint?)");
35
37
  }
36
38
  refuseIdentityMismatch(ownedEnv.workspaceHandle());
@@ -108,7 +110,8 @@ export async function prepareWorkspaceRestore(input) {
108
110
  }
109
111
  }
110
112
  const workspaceEnv = ownedEnv ?? deps.executionEnv;
111
- const remote = workspaceEnv !== undefined && workspaceEnv !== null && (isRemoteExecutionEnv(workspaceEnv) || workspaceEnv.hostLocalPaths === false);
113
+ const remote = workspaceEnv !== undefined && workspaceEnv !== null && !pathsAreHostLocal(workspaceEnv);
114
+ const ownTarget = settleOwnTarget(workspaceEnv ?? undefined, input.placementFence, resume?.workspaceHandle !== undefined);
112
115
  if (internals?.onWorkspaceResolved !== undefined) {
113
116
  try {
114
117
  internals.onWorkspaceResolved({
@@ -116,10 +119,11 @@ export async function prepareWorkspaceRestore(input) {
116
119
  isolated: internals.isolation === "worktree",
117
120
  remote,
118
121
  ...(input.placement !== undefined ? { placement: input.placement } : {}),
122
+ ...(ownTarget !== undefined ? { target: ownTarget } : {}),
119
123
  });
120
124
  }
121
125
  catch {
122
126
  }
123
127
  }
124
- return { taskRootFinal: taskRootPath, rebaseRestoredPath, remote };
128
+ return { taskRootFinal: taskRootPath, rebaseRestoredPath, remote, ownTarget };
125
129
  }
@@ -44,7 +44,7 @@ export declare function settleReadRootGrant(screen: ReadRootGrantScreen | undefi
44
44
  toolCallId: string;
45
45
  sessionId: string;
46
46
  runId: string;
47
- taskId?: string;
47
+ taskId: string;
48
48
  onNotice: RunnerDeps["onNotice"];
49
49
  signal?: AbortSignal;
50
50
  }): Promise<void> | undefined;
@@ -1,3 +1,4 @@
1
+ import { legNoticeTaskId } from "../mods/stations.js";
1
2
  import { deliverEngineNotice } from "../types.js";
2
3
  import { READ_ROOT_CANDIDATE_DIR_MAX } from "../read-root-candidate.js";
3
4
  import { DEFAULT_GATE_AWAIT_TIMEOUT_MS } from "../gate-bounded-await.js";
@@ -24,7 +25,7 @@ export function readRootGrantOver(seats) {
24
25
  export function settleReadRootGrant(screen, grant, at) {
25
26
  if (screen === undefined)
26
27
  return undefined;
27
- const ids = { toolName: at.toolName, toolCallId: at.toolCallId, sessionId: at.sessionId, runId: at.runId, ...(at.taskId !== undefined ? { taskId: at.taskId } : {}) };
28
+ const ids = { toolName: at.toolName, toolCallId: at.toolCallId, sessionId: at.sessionId, runId: at.runId, ...legNoticeTaskId(at) };
28
29
  const reject = (reason, offered, requested, why) => deliverEngineNotice(at.onNotice, {
29
30
  code: "approval.read_root_grant_rejected",
30
31
  message: `the approval for "${at.toolName}" asked to add a read directory, and nothing was added: ${why}. The approval's own verdict is unchanged.`,
@@ -11,7 +11,7 @@
11
11
  * The same seat shape the tool gate's fold uses to enter its lanes (gate-fold.ts `afterFold`).
12
12
  */
13
13
  import { type Checkpoint, type CheckpointStore, type CheckpointToken, type PendingSteerEntry, type ResumeOutcome } from "../checkpoint-store.js";
14
- import type { InheritedGate, ResumeTaskConfig, RunInternals, RunnerDepsSeat } from "./contracts.js";
14
+ import type { InheritedGate, ResumeTaskConfig, RunInternals, RunnerDepsSeat, SuspendReap } from "./contracts.js";
15
15
  import type { SessionStore } from "../session.js";
16
16
  /** What the admission rung was called with. */
17
17
  export interface ResumeAdmissionInput<R> {
@@ -31,8 +31,10 @@ export interface ResumeAdmissionInput<R> {
31
31
  runner: RunnerDepsSeat;
32
32
  /** borrowed-readonly — the Runner's session store, fixed at its construction (unlike its deps): the retention capability door judges it. */
33
33
  sessions: SessionStore;
34
- /** borrowed-readonly — the Runner's same-process parked-constraint registry; read for this token (never written here). */
35
- parentConstraintRegistry: ReadonlyMap<CheckpointToken, NonNullable<InheritedGate["parentConstraints"]>>;
34
+ /** borrowed-mutable — the Runner's same-process parked-constraint registry; read for this token, and evicted for it only by the expired-row duty. */
35
+ parentConstraintRegistry: Map<CheckpointToken, NonNullable<InheritedGate["parentConstraints"]>>;
36
+ /** borrowed-mutable — the Runner's suspended-env reap handles: a row the confirm reads `expired` has its duty run here (its record taken). */
37
+ suspendedEnvReaps: Map<CheckpointToken, SuspendReap>;
36
38
  /** borrowed-readonly — the rung after admission, entered in this rung's last continuation with what it admitted. */
37
39
  next: (admitted: ResumeAdmissionResult) => Promise<R>;
38
40
  }
@@ -1,8 +1,11 @@
1
1
  import { CheckpointError, judgeParkedSteerRepeat, readPendingSteerQueue, refuseRetiredModeSeed, resolveCheckpointStore, validatePendingSteer } from "../checkpoint-store.js";
2
2
  import { assertResumeConfigRecord, checkpointStoreSeat, refuseResumeDoors } from "./prepare-config-doors.js";
3
+ import { compositionLegRecord } from "./checkpoint-scope.js";
3
4
  import { asResumeConfigRefusal } from "../mode-policy.js";
5
+ import { runExpiredDuty } from "./expire-settle.js";
4
6
  import { describeSuppliedValue } from "./decide-continuation.js";
5
7
  import { detachSkillLists } from "../skill-grant.js";
8
+ import { readCallerSpec } from "../task-spec-members.js";
6
9
  import { isGateKind, PAUSE_REGISTRY } from "../pause-registry.js";
7
10
  const DECIDE_ENTRY_BY_RESUME_GATE = {
8
11
  policy_ask: "a `policy_ask` outcome (decision allow/deny bound to the pending tool call)",
@@ -12,14 +15,18 @@ const DECIDE_ENTRY_BY_RESUME_GATE = {
12
15
  task_done: undefined,
13
16
  };
14
17
  export async function resumeAdmission(input) {
15
- const { token, outcome, taskConfig, runner, sessions, parentConstraintRegistry } = input;
18
+ const { token, outcome, taskConfig, runner, sessions, parentConstraintRegistry, suspendedEnvReaps } = input;
16
19
  let internals = input.internals;
17
20
  if (outcome === null || typeof outcome !== "object") {
18
21
  throw new CheckpointError("checkpoint.invalid_outcome", `resume outcome must be an object naming its gate (got ${outcome === null ? "null" : typeof outcome})`, { field: "outcome" });
19
22
  }
20
23
  asResumeConfigRefusal("taskConfig", () => assertResumeConfigRecord(taskConfig));
21
- let config = { ...taskConfig, ...(Array.isArray(taskConfig.skills) ? { skills: detachSkillLists(taskConfig.skills) } : {}) };
22
- internals = internals !== undefined ? { ...internals } : undefined;
24
+ const configRead = readCallerSpec(taskConfig);
25
+ asResumeConfigRefusal("taskConfig", () => { if (configRead.refusal !== undefined)
26
+ throw configRead.refusal; });
27
+ let config = { ...configRead.spec, ...(Array.isArray(configRead.spec.skills) ? { skills: detachSkillLists(configRead.spec.skills) } : {}) };
28
+ const snapshot = internals !== undefined ? { ...internals } : undefined;
29
+ internals = snapshot?.compositionLeg !== undefined ? { ...snapshot, compositionLeg: compositionLegRecord(snapshot.compositionLeg) } : snapshot;
23
30
  const store = asResumeConfigRefusal(checkpointStoreSeat(config), () => resolveCheckpointStore(config, runner.deps));
24
31
  if (!store) {
25
32
  throw new CheckpointError("checkpoint.not_found", "no CheckpointStore wired — cannot resume (set RunnerDeps.checkpointStore or taskConfig.checkpointStore)");
@@ -33,6 +40,13 @@ export async function resumeAdmission(input) {
33
40
  if (live?.status === "pending") {
34
41
  throw new CheckpointError("checkpoint.reopened_concurrently", "checkpoint changed concurrently (a resolve/reopen cycle landed between this resume's read of the row and its state check) — nothing was validated or executed; re-resume against the current state");
35
42
  }
43
+ if (live?.status === "expired") {
44
+ await runExpiredDuty({
45
+ token, parentConstraintRegistry, suspendedEnvReaps,
46
+ destroyLabel: "expired-row env destroy (resume refused)",
47
+ onDestroyError: (err, sessionId) => runner.deps.onError?.(err, { phase: "config", sessionId }),
48
+ });
49
+ }
36
50
  throw new CheckpointError("checkpoint.already_resolved", `checkpoint is ${describeSuppliedValue(live?.status ?? cp.status)} — the token is consumed, so this resume was neither validated nor executed (idempotent); a different outcome cannot redeem it`);
37
51
  }
38
52
  if ((internals?.inheritedGate?.parentConstraints?.length ?? 0) === 0) {
@@ -3,6 +3,8 @@ import { CheckpointError, remainingBudgetMicroUsd } from "../checkpoint-store.js
3
3
  import { chainPolicyOnLeg, chainTopAnchors } from "./child-tree.js";
4
4
  import { mintHookInvocationIdentity } from "../hooks.js";
5
5
  import { admitLegMods, classicEventBase, failedHandlerClause, screenUserPrompt } from "../mods/stations.js";
6
+ import { legTaskIdOf } from "../leg-identity.js";
7
+ import { restoreRowTaskId } from "./checkpoint-scope.js";
6
8
  import { checkToolPolicyProjection, policyCannotAnswer, refuseOutOfContractDecision } from "../tool-policy.js";
7
9
  import { requestGrantBinding } from "../skill-grant-binding.js";
8
10
  import { skillGrantBindingMembers } from "../skill-grant.js";
@@ -31,7 +33,7 @@ export async function resumeApply(input) {
31
33
  const screenedMessage = wakeMessage;
32
34
  const identity = mintHookInvocationIdentity({
33
35
  sessionId: cp.sessionId,
34
- taskId: config.taskId ?? cp.sessionId,
36
+ taskId: legTaskIdOf(config, restoreRowTaskId(internals, cp.state.rowTaskId), cp.sessionId),
35
37
  legKind: "resume",
36
38
  isDelegatedChild: effectiveDelegationFacts(internals, cp.state.isDelegatedChild).isDelegatedChild,
37
39
  ...(internals?.insideFork === true ? { insideFork: true } : {}),
@@ -7,7 +7,7 @@ import { constraintChainDigest, constraintChainEntryOfSuppliedLayer } from "../t
7
7
  import { readFrozenSkillGrants } from "../skill-grant.js";
8
8
  import { readFrozenSkillScopes } from "../mods/spec-seats.js";
9
9
  import { chainInstallationGaps, chainInstallationRefusal } from "./child-tree.js";
10
- import { screeningInstallationsOf, unraisableGuardsOf } from "../mods/stations.js";
10
+ import { chainEntryFault } from "../mods/stations.js";
11
11
  import { refusePersistedToolNames, refuseRenamedDelegationMounts } from "./sub-agent-deny-lists.js";
12
12
  import { asResumeConfigRefusal } from "../mode-policy.js";
13
13
  import { screenRecordedRunOrigin } from "../run-origin.js";
@@ -136,9 +136,9 @@ export function resumeCheckpointScreen(input) {
136
136
  if (gaps.length > 0)
137
137
  throw chainInstallationRefusal(gaps, true);
138
138
  }
139
- const unraisable = unraisableGuardsOf(screeningInstallationsOf(internals?.inheritedGate?.parentConstraints ?? []));
140
- if (unraisable !== undefined)
141
- throw new CheckpointError("resume.parent_constraint_mismatch", `${unraisable}; rejected pre-CAS (the checkpoint stays pending)`);
139
+ const malformed = chainEntryFault(internals?.inheritedGate?.parentConstraints ?? []);
140
+ if (malformed !== undefined)
141
+ throw new CheckpointError("resume.parent_constraint_mismatch", `${malformed}; rejected pre-CAS (the checkpoint stays pending)`);
142
142
  const resumeInternals = internals?.inheritedGate?.parentConstraints !== undefined
143
143
  ? {
144
144
  ...internals,
@@ -9,7 +9,8 @@
9
9
  * — the post-consume hook fires on the tick the win was read — and returns what that rung returns.
10
10
  */
11
11
  import { type Checkpoint, type CheckpointStore, type CheckpointToken } from "../checkpoint-store.js";
12
- import type { InheritedGate, InstallingPhaseResult, ResumeRun } from "./contracts.js";
12
+ import type { InheritedGate, InstallingPhaseResult, ResumeRun, SuspendReap } from "./contracts.js";
13
+ import type { LocalClaims } from "./local-claims.js";
13
14
  export interface ResumeClaimInput<R> {
14
15
  /** borrowed-readonly — the checkpoint token being claimed. */
15
16
  token: CheckpointToken;
@@ -21,10 +22,14 @@ export interface ResumeClaimInput<R> {
21
22
  outcomeForStore: ResumeRun["outcome"];
22
23
  /** borrowed-readonly — the deployment's claim holder the resume acts under (`RunInternals.holder`), carried into the CAS. */
23
24
  holder?: string | undefined;
24
- /** borrowed-mutable — the Runner's same-Runner claim marks: opened with the resolve attempt, released on a loss. */
25
- locallyClaimedTokens: Set<CheckpointToken>;
25
+ /** borrowed-mutable — the Runner's same-Runner claims: this attempt opens its own with the resolve, closes it on a loss or a throw. */
26
+ locallyClaimedTokens: LocalClaims;
26
27
  /** borrowed-mutable — the Runner's parked-constraint registry: a terminally consumed token's entry is evicted. */
27
28
  parentConstraintRegistry: Map<CheckpointToken, NonNullable<InheritedGate["parentConstraints"]>>;
29
+ /** borrowed-mutable — the Runner's suspended-env reap handles: a loss to an `expired` row runs that row's duty (its record taken). */
30
+ suspendedEnvReaps: Map<CheckpointToken, SuspendReap>;
31
+ /** borrowed-readonly — where the expired duty's bounded destroy failure is said (the Runner's `onError`); never thrown. */
32
+ onDestroyError: (err: unknown, sessionId: string) => void;
28
33
  /** borrowed-readonly — the driver's post-claim rung, entered in this rung's last continuation. */
29
34
  next: (claimed: ResumeClaimResult) => Promise<R>;
30
35
  }
@@ -1,21 +1,28 @@
1
1
  import { CheckpointError } from "../checkpoint-store.js";
2
2
  import { checkpointRevOf } from "../checkpoint-generation.js";
3
+ import { runExpiredDuty } from "./expire-settle.js";
3
4
  export async function resumeClaim(input) {
4
- const { token, cp, store, outcomeForStore, holder, locallyClaimedTokens, parentConstraintRegistry } = input;
5
+ const { token, cp, store, outcomeForStore, holder, locallyClaimedTokens, parentConstraintRegistry, suspendedEnvReaps, onDestroyError } = input;
5
6
  const expect = { rev: checkpointRevOf(cp), ...(holder !== undefined ? { holder } : {}) };
6
- locallyClaimedTokens.add(token);
7
+ locallyClaimedTokens.open(token);
7
8
  let won, loss;
8
- if (store.claimTerminal !== undefined) {
9
- const claim = await store.claimTerminal(token, cp.scope, { kind: "resolve", outcome: outcomeForStore, expect });
10
- won = claim.claimed;
11
- if (!claim.claimed)
12
- loss = { status: claim.current.status, rev: claim.current.status === "absent" ? undefined : claim.current.rev, sameRow: true };
9
+ try {
10
+ if (store.claimTerminal !== undefined) {
11
+ const claim = await store.claimTerminal(token, cp.scope, { kind: "resolve", outcome: outcomeForStore, expect });
12
+ won = claim.claimed;
13
+ if (!claim.claimed)
14
+ loss = { status: claim.current.status, rev: claim.current.status === "absent" ? undefined : claim.current.rev, sameRow: true };
15
+ }
16
+ else {
17
+ won = await store.resolve(token, cp.scope, outcomeForStore, expect);
18
+ }
13
19
  }
14
- else {
15
- won = await store.resolve(token, cp.scope, outcomeForStore, expect);
20
+ catch (casErr) {
21
+ locallyClaimedTokens.close(token);
22
+ throw casErr;
16
23
  }
17
24
  if (!won)
18
- locallyClaimedTokens.delete(token);
25
+ locallyClaimedTokens.close(token);
19
26
  if (!won) {
20
27
  if (loss === undefined) {
21
28
  const row = await store.get(token);
@@ -27,8 +34,17 @@ export async function resumeClaim(input) {
27
34
  }
28
35
  throw new CheckpointError("checkpoint.reopened_concurrently", "checkpoint changed concurrently (its revision advanced via a resolve/reopen cycle since this resume validated) — not executed; re-resume against the current state");
29
36
  }
30
- parentConstraintRegistry.delete(token);
37
+ if (loss.status === "expired")
38
+ await runExpiredDuty({ token, parentConstraintRegistry, suspendedEnvReaps, destroyLabel: "expired-row env destroy (resume lost)", onDestroyError });
39
+ else
40
+ parentConstraintRegistry.delete(token);
31
41
  throw new CheckpointError("checkpoint.already_resolved", "checkpoint already resolved or expired — not re-executed (idempotent)");
32
42
  }
33
- return await input.next({});
43
+ try {
44
+ return await input.next({});
45
+ }
46
+ catch (handoffErr) {
47
+ locallyClaimedTokens.close(token);
48
+ throw handoffErr;
49
+ }
34
50
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * The resume ladder's INTERNALS-AND-CONFIG rung (E7), verbatim from `Runner.resumeStream`:
3
- * the inherited constraints' retired-member door, the principal and placement identity-continuity rungs,
3
+ * the inherited constraints' retired-member door, the principal, placement and composition-leg identity-continuity rungs,
4
4
  * and the governance-window ENTRANCE check for a row that still owes a delivery.
5
5
  *
6
6
  * Synchronous by construction, with the ladder's ONE await at this rung handed back instead of taken: the
@@ -16,7 +16,7 @@ export interface ResumeInternalsAndConfigInput {
16
16
  cp: Checkpoint;
17
17
  /** borrowed-readonly — the config snapshot (`principal`). */
18
18
  config: ResumeTaskConfig;
19
- /** borrowed-readonly — the internals snapshot (`placementRoot`). */
19
+ /** borrowed-readonly — the internals snapshot (`placementRoot`, `compositionLeg`). */
20
20
  internals: RunInternals | undefined;
21
21
  /** borrowed-readonly — the ONE read of the outcome discriminant (a bare resource_limit continue owes nothing). */
22
22
  outcomeGate: ResumeOutcome["gate"];
@@ -1,7 +1,7 @@
1
1
  import { CheckpointError, readPendingSteerQueue } from "../checkpoint-store.js";
2
2
  import { asResumeConfigRefusal } from "../mode-policy.js";
3
3
  import { GLOBAL_USAGE_KEY, resolveUsageWindows, usageRetryAfterMs } from "../usage-window-store.js";
4
- import { placementValueOrAbsent } from "./checkpoint-scope.js";
4
+ import { compositionLegRecord, placementValueOrAbsent, sameCompositionLeg } from "./checkpoint-scope.js";
5
5
  import { assertNoRetiredInheritedConstraints } from "./retired-runner-deps.js";
6
6
  export function resumeInternalsAndConfig(input) {
7
7
  const { cp, config, internals, outcomeGate, runner } = input;
@@ -25,6 +25,15 @@ export function resumeInternalsAndConfig(input) {
25
25
  "refused pre-CAS (the checkpoint stays pending): re-resume with the recorded root, or omit internals.placementRoot to inherit it");
26
26
  }
27
27
  }
28
+ {
29
+ const recordedLeg = compositionLegRecord(cp.state.compositionLeg);
30
+ const suppliedLeg = compositionLegRecord(internals?.compositionLeg);
31
+ if (recordedLeg !== undefined && suppliedLeg !== undefined && !sameCompositionLeg(recordedLeg, suppliedLeg)) {
32
+ throw new CheckpointError("resume.composition_mismatch", `the resume supplied composition leg ${JSON.stringify(suppliedLeg)} but this checkpoint was parked as ${JSON.stringify(recordedLeg)} — ` +
33
+ "continuing would run the leg as another composition's leg or file its next card under another host session; " +
34
+ "refused pre-CAS (the checkpoint stays pending): re-resume with the recorded value, or omit internals.compositionLeg to inherit it");
35
+ }
36
+ }
28
37
  const owesDelivery = outcomeGate !== "resource_limit" ||
29
38
  readPendingSteerQueue(cp.state).length > 0 ||
30
39
  (cp.state.runningBackgroundTasks?.length ?? 0) > 0;
@@ -11,6 +11,7 @@
11
11
  */
12
12
  import { type Checkpoint, type CheckpointStore, type CheckpointToken } from "../checkpoint-store.js";
13
13
  import type { InheritedGate, InstallingPhaseResult, RunnerDepsSeat, SuspendReap } from "./contracts.js";
14
+ import type { LocalClaims } from "./local-claims.js";
14
15
  export interface ResumePreflightInput<R> {
15
16
  /** borrowed-readonly — the checkpoint token (handed to the deployment and to the settling CAS). */
16
17
  token: CheckpointToken;
@@ -25,8 +26,8 @@ export interface ResumePreflightInput<R> {
25
26
  /** borrowed-readonly — the Runner's deployment deps, read LIVE through the Runner (reads `resumePreflight`, `resumePreflightTimeoutMs`, `onError` (after the seat's await too) and is the seat's owner); the one home of why it is a
26
27
  * seat and not a captured object is {@link RunnerDepsSeat}. */
27
28
  runner: RunnerDepsSeat;
28
- /** borrowed-mutable — the Runner's same-Runner claim marks: opened with the expire attempt, released at the duty decision. */
29
- locallyClaimedTokens: Set<CheckpointToken>;
29
+ /** borrowed-mutable — the Runner's same-Runner claims: the terminal arm's expire attempt opens and closes its own. */
30
+ locallyClaimedTokens: LocalClaims;
30
31
  /** borrowed-mutable — the Runner's parked-constraint registry: the token's entry is evicted when the terminal arm wins. */
31
32
  parentConstraintRegistry: Map<CheckpointToken, NonNullable<InheritedGate["parentConstraints"]>>;
32
33
  /** borrowed-mutable — the Runner's suspended-env reap handles: the winning terminal arm takes and destroys this token's. */
@@ -1,9 +1,9 @@
1
1
  import { CheckpointError } from "../checkpoint-store.js";
2
2
  import { MAX_TIMER_MS } from "../mods/kernel/index.js";
3
- import { frozenHandleCopy, hasDestroy } from "../remote-env.js";
3
+ import { frozenHandleCopy } from "../remote-env.js";
4
4
  import { inlineUntrusted } from "../untrusted-text.js";
5
5
  import { describeSuppliedValue } from "./decide-continuation.js";
6
- import { settleTeardownLeg } from "./teardown-bounded.js";
6
+ import { expireRowWithDuty } from "./expire-settle.js";
7
7
  import { asThrownError } from "../thrown-value.js";
8
8
  async function boundedPreflight(timeoutMs, signal, call) {
9
9
  const controller = new AbortController();
@@ -97,37 +97,24 @@ export async function resumePreflight(input) {
97
97
  const readableMessage = typeof suppliedMessage === "string" && suppliedMessage !== "" ? suppliedMessage : undefined;
98
98
  const said = readableMessage !== undefined ? `: ${inlineUntrusted(readableMessage)}` : " (no readable verdict — fail-closed)";
99
99
  if (disposition === "terminal" && readableMessage !== undefined) {
100
- locallyClaimedTokens.add(token);
101
- let settled;
102
- try {
103
- settled = await store.expire(token, cp.scope);
104
- }
105
- catch (expireErr) {
106
- locallyClaimedTokens.delete(token);
107
- throw expireErr;
108
- }
100
+ const settled = await expireRowWithDuty({
101
+ token, scope: cp.scope, store, locallyClaimedTokens, parentConstraintRegistry, suspendedEnvReaps,
102
+ destroyLabel: "terminal-preflight env destroy",
103
+ onDestroyError: (envErr, sessionId) => {
104
+ try {
105
+ runner.deps.onError?.(envErr, { phase: "config", sessionId });
106
+ }
107
+ catch {
108
+ }
109
+ },
110
+ });
109
111
  if (!settled) {
110
- locallyClaimedTokens.delete(token);
111
112
  const live = await store.get(token);
112
113
  if (live?.status === "pending") {
113
114
  throw new CheckpointError("resume.preflight_rejected", `the deployment's resumePreflight ruled this resume PERMANENTLY blocked${said}, but the row moved under this refusal (a concurrent resolve/reopen cycle) — nothing was settled here; the row is pending again, re-resume against the current state (the preflight screens every attempt)`);
114
115
  }
115
116
  throw new CheckpointError("resume.preflight_rejected", `the deployment's resumePreflight ruled this resume PERMANENTLY blocked${said} — a concurrent actor had already settled the row (${describeSuppliedValue(live?.status ?? "consumed")}); nothing was settled by this refusal`);
116
117
  }
117
- parentConstraintRegistry.delete(token);
118
- const terminalReap = suspendedEnvReaps.get(token);
119
- suspendedEnvReaps.delete(token);
120
- locallyClaimedTokens.delete(token);
121
- if (terminalReap?.env !== undefined && hasDestroy(terminalReap.env)) {
122
- const terminalEnv = terminalReap.env;
123
- await settleTeardownLeg(() => terminalEnv.destroy(), "terminal-preflight env destroy", (envErr) => {
124
- try {
125
- runner.deps.onError?.(envErr, { phase: "config", sessionId: terminalReap.sessionId });
126
- }
127
- catch {
128
- }
129
- });
130
- }
131
118
  try {
132
119
  runner.deps.onError?.(new Error(`resumePreflight ruled this row PERMANENTLY blocked${said} — the row was settled terminally (expired) by this refusal's single-shot CAS (token no longer redeemable)`), { phase: "hook", sessionId: cp.sessionId });
133
120
  }
@@ -5,6 +5,10 @@ const RETIRED_RUNNER_DEPS_KEYS = {
5
5
  peerAdmission: "the peer lane's knob table is `RunnerDeps.peerLane` (the same fields: admission gate, delivery budgets, listing window)",
6
6
  builtinWorkflows: "the engine ships no built-in named workflows — the Workflow tool's `{name}` resolves only `RunnerDeps.workflowScriptStore`; register any named workflow there",
7
7
  graderEnvFactory: "the grader env reaches the repair loop as `RepairLoopConfig.graderEnv`, minted by the trusted control plane (`assertOracleIsolation` / `GraderEnv` unchanged)",
8
+ mcpImageResizer: "one image processor seat serves every image of a run: `RunnerDeps.imageProcessor` (an `ImageDownsampler`, or `false` for none; absent detects sharp once per process) — the MCP result, the Read tool, PDF pages, Bash data URIs, any tool's result, task images and attachments all pass the one admission with it",
9
+ mediaByteCapBytes: "the request's media budget is `RunnerDeps.mediaBudgetBase64Chars`, in base64 characters (the unit a provider counts; 0 or Infinity: none, else a whole number of at least twice `IMAGE_ADMISSION.request.hysteresisBase64Chars`)",
10
+ onMediaStripped: "the media a request leaves out is told to the person as the `context.media_removed` notice (reason `media_budget`, once per block per session) and to the operator as the `context.media_removed` trace frame (one per request)",
11
+ "hands.readImageDownsampler": "one image processor seat serves every image of a run: `RunnerDeps.imageProcessor` (an `ImageDownsampler`, or `false` for none; absent detects sharp once per process) — the Read tool's images ride it with every other carrier's",
8
12
  "hands.readCyberReminder": "a Read result carries only the reminders about that read (an empty file, an offset past the end, a file already in context) — no standing content-safety tail, so there is nothing to switch; a deployment that wants that sentence states it in its own `appendSystemPrompt`",
9
13
  promptProvider: "a deployment changes prompt text through overlays: register a `prompt.compose` handler on `RunnerDeps.mods` answering `{ overlays }` (role base `replace`, a brand line `add` to the role band, a behavior or scenario `add`, a core-behavior `replace` / `append` / `drop`), choose the role base per task with `TaskSpec.promptRole`, and dispose of an MCP server's instructions with a `prompt.section` registration answering `{ text }` / `{ text: null }`",
10
14
  allowImageUrl: "a remote image URL is judged by the one egress guard (https, the private-network floor) and the deployment's host floor — declare a CDN list as `RunnerDeps.hostFloor.only` (it bounds every structured egress: the fetch tool, task images, MCP http, A2A, WebSearch's SearXNG backend), or send the image inline",
@@ -15,5 +19,6 @@ export function assertNoRetiredRunnerDeps(deps) {
15
19
  }
16
20
  export function assertNoRetiredInheritedConstraints(internals) {
17
21
  for (const constraint of internals?.inheritedGate?.parentConstraints ?? [])
18
- assertNoRetiredToolPolicyKeys(constraint.policy);
22
+ if (constraint.policy !== undefined)
23
+ assertNoRetiredToolPolicyKeys(constraint.policy);
19
24
  }
@@ -78,12 +78,12 @@ export async function runAttachmentSeats(input) {
78
78
  return [];
79
79
  const full = textOf(e.message);
80
80
  if (m.engineMinted === true)
81
- return [stripGitStatusUnits(full, prepared.reminderMark)];
81
+ return [stripGitStatusUnits(full)];
82
82
  if (Array.isArray(m.engineSegments) && m.engineSegments.length > 0) {
83
- return m.engineSegments.map((s) => stripGitStatusUnits(full.slice(Math.max(0, s.start), Math.max(0, s.end)), prepared.reminderMark));
83
+ return m.engineSegments.map((s) => stripGitStatusUnits(full.slice(Math.max(0, s.start), Math.max(0, s.end))));
84
84
  }
85
85
  if (typeof m.enginePrefixChars === "number" && m.enginePrefixChars > 0)
86
- return [stripGitStatusUnits(full.slice(0, m.enginePrefixChars), prepared.reminderMark)];
86
+ return [stripGitStatusUnits(full.slice(0, m.enginePrefixChars))];
87
87
  return [];
88
88
  });
89
89
  }
@@ -27,6 +27,7 @@ export function runBrainSinks(input) {
27
27
  ...(s.errorStatus !== undefined ? { errorStatus: s.errorStatus } : {}),
28
28
  ...(s.providerCondition !== undefined ? { providerCondition: s.providerCondition } : {}),
29
29
  ...(s.providerConditionSource !== undefined ? { providerConditionSource: s.providerConditionSource } : {}),
30
+ ...(s.seat !== undefined ? { seat: s.seat } : {}),
30
31
  ...ident(),
31
32
  };
32
33
  Object.freeze(frame);