@sema-agent/core 7.51.2 → 7.53.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 (446) hide show
  1. package/CHANGELOG.md +698 -2
  2. package/README.md +3 -1
  3. package/dist/agents/agent-transcript-tool.d.ts +1 -1
  4. package/dist/agents/cascade.js +4 -0
  5. package/dist/agents/cross-session-envelope.d.ts +8 -0
  6. package/dist/agents/cross-session-envelope.js +6 -0
  7. package/dist/agents/cross-session-judge.d.ts +21 -1
  8. package/dist/agents/cross-session-judge.js +8 -0
  9. package/dist/agents/cross-session-ref.d.ts +5 -0
  10. package/dist/agents/cross-session-ref.js +1 -0
  11. package/dist/agents/cumulative-stats.d.ts +3 -0
  12. package/dist/agents/cumulative-stats.js +3 -0
  13. package/dist/agents/list-agents-tool.d.ts +1 -1
  14. package/dist/agents/org-delivery-gate.d.ts +122 -0
  15. package/dist/agents/org-delivery-gate.js +69 -0
  16. package/dist/agents/peer-held-queue.d.ts +9 -4
  17. package/dist/agents/peer-held-queue.js +6 -5
  18. package/dist/agents/peer-session-drain.d.ts +35 -5
  19. package/dist/agents/peer-session-drain.js +271 -180
  20. package/dist/agents/read-inbox-tool.d.ts +8 -1
  21. package/dist/agents/read-inbox-tool.js +5 -1
  22. package/dist/agents/repair-loop.js +4 -0
  23. package/dist/agents/send-message-tool.d.ts +11 -16
  24. package/dist/agents/send-message-tool.js +11 -13
  25. package/dist/agents/subagent.d.ts +3 -0
  26. package/dist/agents/subagent.js +105 -76
  27. package/dist/agents/tool-filter.d.ts +58 -13
  28. package/dist/agents/tool-filter.js +34 -14
  29. package/dist/bench/metrics.d.ts +1 -0
  30. package/dist/brain/anthropic.d.ts +6 -1
  31. package/dist/brain/anthropic.js +17 -13
  32. package/dist/brain/model-presets.d.ts +4 -5
  33. package/dist/brain/model-presets.js +6 -5
  34. package/dist/brain/open-responses.js +16 -12
  35. package/dist/brain/openai.js +16 -12
  36. package/dist/brain/request-params.d.ts +12 -33
  37. package/dist/brain/request-params.js +5 -2
  38. package/dist/brain/request-route.d.ts +9 -8
  39. package/dist/brain/request-route.js +1 -0
  40. package/dist/brain/route-adjudicator.d.ts +123 -47
  41. package/dist/brain/route-adjudicator.js +171 -42
  42. package/dist/brain/route-conformance.js +2 -2
  43. package/dist/brain/routing.d.ts +24 -1
  44. package/dist/brain/routing.js +54 -19
  45. package/dist/brain/status-sink.d.ts +18 -0
  46. package/dist/brain/status-sink.js +7 -0
  47. package/dist/brain/timeout.js +5 -4
  48. package/dist/core/a2a.d.ts +5 -2
  49. package/dist/core/a2a.js +30 -13
  50. package/dist/core/allow-entry.d.ts +42 -9
  51. package/dist/core/allow-entry.js +25 -18
  52. package/dist/core/auto-compaction.d.ts +80 -20
  53. package/dist/core/auto-compaction.js +65 -18
  54. package/dist/core/auto-promote.d.ts +2 -1
  55. package/dist/core/auto-promote.js +2 -2
  56. package/dist/core/caller-tool-name.d.ts +9 -0
  57. package/dist/core/caller-tool-name.js +13 -0
  58. package/dist/core/checkpoint-requirements.d.ts +7 -1
  59. package/dist/core/checkpoint-requirements.js +2 -0
  60. package/dist/core/checkpoint-store.d.ts +57 -24
  61. package/dist/core/checkpoint-store.js +3 -3
  62. package/dist/core/child-clamp-seats.d.ts +6 -0
  63. package/dist/core/child-clamp-seats.js +2 -1
  64. package/dist/core/compliance.js +3 -1
  65. package/dist/core/credential-vocabulary.d.ts +33 -8
  66. package/dist/core/credential-vocabulary.js +32 -7
  67. package/dist/core/decision-receipt.d.ts +2 -2
  68. package/dist/core/delegation-frames.d.ts +9 -2
  69. package/dist/core/delegation-name.d.ts +18 -0
  70. package/dist/core/delegation-name.js +47 -0
  71. package/dist/core/effective-path-target.d.ts +25 -6
  72. package/dist/core/effective-path-target.js +24 -2
  73. package/dist/core/engine-capabilities.d.ts +8 -1
  74. package/dist/core/engine-capabilities.js +1 -1
  75. package/dist/core/engine-notice.d.ts +49 -21
  76. package/dist/core/frontmatter-fence.d.ts +10 -0
  77. package/dist/core/frontmatter-fence.js +6 -0
  78. package/dist/core/gate-fold.js +8 -25
  79. package/dist/core/gate-lanes.js +358 -274
  80. package/dist/core/gate-outcome.d.ts +11 -6
  81. package/dist/core/governance-codes.d.ts +11 -4
  82. package/dist/core/governance-codes.js +12 -3
  83. package/dist/core/hands-band-screen.d.ts +7 -0
  84. package/dist/core/hands-band-screen.js +32 -0
  85. package/dist/core/hooks.d.ts +283 -739
  86. package/dist/core/hooks.js +100 -193
  87. package/dist/{tools/fs → core}/image-admission.d.ts +21 -3
  88. package/dist/{tools/fs → core}/image-admission.js +24 -6
  89. package/dist/core/locked-config.d.ts +84 -32
  90. package/dist/core/locked-config.js +128 -42
  91. package/dist/core/mcp-connection-pool.d.ts +4 -1
  92. package/dist/core/mcp-connection-pool.js +7 -2
  93. package/dist/core/mcp-probe.d.ts +12 -9
  94. package/dist/core/mcp-probe.js +3 -3
  95. package/dist/core/mcp-server-spec.d.ts +104 -10
  96. package/dist/core/mcp-server-spec.js +183 -33
  97. package/dist/core/mcp.d.ts +31 -20
  98. package/dist/core/mcp.js +66 -56
  99. package/dist/core/memory-engine/data-plane.js +5 -1
  100. package/dist/core/memory-engine/distiller.js +16 -2
  101. package/dist/core/memory-engine/engine.d.ts +22 -30
  102. package/dist/core/memory-engine/engine.js +16 -10
  103. package/dist/core/memory-engine/frontmatter.d.ts +6 -0
  104. package/dist/core/memory-engine/frontmatter.js +19 -16
  105. package/dist/core/memory.d.ts +2 -2
  106. package/dist/core/mode-policy.d.ts +5 -16
  107. package/dist/core/mode-policy.js +7 -19
  108. package/dist/core/model-seat.d.ts +4 -1
  109. package/dist/core/mods/dollar.d.ts +109 -0
  110. package/dist/core/mods/dollar.js +154 -0
  111. package/dist/core/mods/host.d.ts +23 -0
  112. package/dist/core/mods/host.js +21 -0
  113. package/dist/core/mods/kernel/budget.d.ts +43 -0
  114. package/dist/core/mods/kernel/budget.js +83 -0
  115. package/dist/core/mods/kernel/dispatch.d.ts +100 -0
  116. package/dist/core/mods/kernel/dispatch.js +699 -0
  117. package/dist/core/mods/kernel/events.d.ts +245 -0
  118. package/dist/core/mods/kernel/events.js +210 -0
  119. package/dist/core/mods/kernel/index.d.ts +6 -0
  120. package/dist/core/mods/kernel/index.js +5 -0
  121. package/dist/core/mods/kernel/receive.d.ts +94 -0
  122. package/dist/core/mods/kernel/receive.js +188 -0
  123. package/dist/core/mods/kernel/registration.d.ts +131 -0
  124. package/dist/core/mods/kernel/registration.js +102 -0
  125. package/dist/core/mods/kernel/site-rules.d.ts +149 -0
  126. package/dist/core/mods/kernel/site-rules.js +296 -0
  127. package/dist/core/mods/stations.d.ts +344 -0
  128. package/dist/core/mods/stations.js +437 -0
  129. package/dist/core/mounted-mcp.d.ts +57 -0
  130. package/dist/core/mounted-mcp.js +71 -2
  131. package/dist/core/own-property-receipt.d.ts +13 -0
  132. package/dist/core/own-property-receipt.js +13 -23
  133. package/dist/core/parent-spec-seat.d.ts +18 -7
  134. package/dist/core/parent-spec-seat.js +6 -2
  135. package/dist/core/path-identity.js +2 -1
  136. package/dist/core/permission-rule-model.d.ts +58 -9
  137. package/dist/core/permission-rule-model.js +81 -7
  138. package/dist/core/permission-rule-org.d.ts +163 -33
  139. package/dist/core/permission-rule-org.js +205 -71
  140. package/dist/core/permission-rule-syntax.d.ts +15 -0
  141. package/dist/core/permission-rule-syntax.js +24 -16
  142. package/dist/core/permission-rules.d.ts +14 -2
  143. package/dist/core/permission-rules.js +63 -23
  144. package/dist/core/prompt-section-seat.d.ts +15 -27
  145. package/dist/core/prompt-section-seat.js +73 -40
  146. package/dist/core/protocol-http-auth.d.ts +3 -1
  147. package/dist/core/protocol-http-auth.js +2 -0
  148. package/dist/core/reminder-mint.d.ts +2 -2
  149. package/dist/core/remote-env.d.ts +24 -12
  150. package/dist/core/remote-env.js +1 -0
  151. package/dist/core/resume-startup-cause.d.ts +16 -1
  152. package/dist/core/resume-startup-cause.js +4 -1
  153. package/dist/core/retention.js +7 -2
  154. package/dist/core/retired-keys.d.ts +12 -2
  155. package/dist/core/retired-keys.js +15 -1
  156. package/dist/core/roles.js +60 -10
  157. package/dist/core/rule-lane-reads.js +1 -1
  158. package/dist/core/runner/announce-once-ledger.d.ts +31 -1
  159. package/dist/core/runner/announce-once-ledger.js +22 -0
  160. package/dist/core/runner/assemble-result.d.ts +9 -0
  161. package/dist/core/runner/assemble-result.js +3 -1
  162. package/dist/core/runner/call-hook-stations.d.ts +23 -27
  163. package/dist/core/runner/call-hook-stations.js +58 -42
  164. package/dist/core/runner/caller-stop-gate.d.ts +25 -0
  165. package/dist/core/runner/caller-stop-gate.js +7 -0
  166. package/dist/core/runner/compaction-seams.d.ts +8 -22
  167. package/dist/core/runner/compaction-seams.js +28 -53
  168. package/dist/core/runner/construction-doors.js +11 -1
  169. package/dist/core/runner/contracts.d.ts +86 -83
  170. package/dist/core/runner/credential-origin-seat.d.ts +2 -0
  171. package/dist/core/runner/credential-origin-seat.js +19 -0
  172. package/dist/core/runner/extra-body-dropped-seat.d.ts +2 -6
  173. package/dist/core/runner/gate-exit.d.ts +47 -36
  174. package/dist/core/runner/gate-exit.js +12 -5
  175. package/dist/core/runner/image.js +1 -2
  176. package/dist/core/runner/inline-image.js +1 -1
  177. package/dist/core/runner/mcp-redial.d.ts +52 -10
  178. package/dist/core/runner/mcp-redial.js +38 -9
  179. package/dist/core/runner/notice-seat-input.d.ts +11 -0
  180. package/dist/core/runner/notice-seat-input.js +1 -0
  181. package/dist/core/runner/permission-rule-lanes.d.ts +5 -2
  182. package/dist/core/runner/permission-rule-lanes.js +22 -10
  183. package/dist/core/runner/person-path-rows.d.ts +3 -1
  184. package/dist/core/runner/person-path-rows.js +3 -2
  185. package/dist/core/runner/prepare-acquire-reconcile.js +5 -1
  186. package/dist/core/runner/prepare-ask-lane.d.ts +5 -7
  187. package/dist/core/runner/prepare-ask-lane.js +6 -15
  188. package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -2
  189. package/dist/core/runner/prepare-caps-and-workflow.js +25 -8
  190. package/dist/core/runner/prepare-config-doors.d.ts +52 -1
  191. package/dist/core/runner/prepare-config-doors.js +168 -143
  192. package/dist/core/runner/prepare-defer-classify.js +7 -11
  193. package/dist/core/runner/prepare-delegation-surface.d.ts +2 -2
  194. package/dist/core/runner/prepare-delegation-surface.js +7 -5
  195. package/dist/core/runner/prepare-gate-stations.d.ts +8 -11
  196. package/dist/core/runner/prepare-gate-stations.js +11 -10
  197. package/dist/core/runner/prepare-hands-readface.d.ts +1 -1
  198. package/dist/core/runner/prepare-hands-readface.js +2 -1
  199. package/dist/core/runner/prepare-inherited-gate.d.ts +8 -12
  200. package/dist/core/runner/prepare-inherited-gate.js +10 -23
  201. package/dist/core/runner/prepare-listings.d.ts +1 -1
  202. package/dist/core/runner/prepare-listings.js +4 -2
  203. package/dist/core/runner/prepare-memory-engine-session.d.ts +0 -6
  204. package/dist/core/runner/prepare-memory-engine-session.js +20 -7
  205. package/dist/core/runner/prepare-memory.d.ts +3 -2
  206. package/dist/core/runner/prepare-memory.js +6 -2
  207. package/dist/core/runner/prepare-offload-wrappers.d.ts +4 -4
  208. package/dist/core/runner/prepare-offload-wrappers.js +2 -1
  209. package/dist/core/runner/prepare-park-ask.js +10 -14
  210. package/dist/core/runner/prepare-policy-chain.d.ts +17 -15
  211. package/dist/core/runner/prepare-policy-chain.js +104 -109
  212. package/dist/core/runner/prepare-project-context.d.ts +1 -1
  213. package/dist/core/runner/prepare-project-context.js +11 -12
  214. package/dist/core/runner/prepare-prompt-assembly.d.ts +45 -40
  215. package/dist/core/runner/prepare-prompt-assembly.js +138 -101
  216. package/dist/core/runner/prepare-prompt-inputs.d.ts +28 -23
  217. package/dist/core/runner/prepare-prompt-inputs.js +11 -10
  218. package/dist/core/runner/prepare-protocol-tools.d.ts +11 -7
  219. package/dist/core/runner/prepare-protocol-tools.js +20 -13
  220. package/dist/core/runner/prepare-question-face.d.ts +4 -2
  221. package/dist/core/runner/prepare-question-face.js +4 -3
  222. package/dist/core/runner/prepare-safety-scan.js +6 -10
  223. package/dist/core/runner/prepare-suspend-saga.d.ts +6 -0
  224. package/dist/core/runner/prepare-suspend-saga.js +7 -5
  225. package/dist/core/runner/prepare-task.js +41 -23
  226. package/dist/core/runner/prepare-turn-wiring.d.ts +13 -15
  227. package/dist/core/runner/prepare-turn-wiring.js +29 -27
  228. package/dist/core/runner/prepare-wiring-manifest.d.ts +13 -9
  229. package/dist/core/runner/prepare-wiring-manifest.js +14 -11
  230. package/dist/core/runner/resume-admission.d.ts +4 -1
  231. package/dist/core/runner/resume-admission.js +7 -5
  232. package/dist/core/runner/resume-apply.d.ts +5 -2
  233. package/dist/core/runner/resume-apply.js +24 -42
  234. package/dist/core/runner/resume-checkpoint-screen.d.ts +1 -0
  235. package/dist/core/runner/resume-checkpoint-screen.js +9 -1
  236. package/dist/core/runner/resume-internals-and-config.d.ts +3 -3
  237. package/dist/core/runner/resume-internals-and-config.js +3 -8
  238. package/dist/core/runner/resume-preflight.js +38 -16
  239. package/dist/core/runner/retired-runner-deps.d.ts +5 -6
  240. package/dist/core/runner/retired-runner-deps.js +4 -5
  241. package/dist/core/runner/run-brain-sinks.d.ts +3 -2
  242. package/dist/core/runner/run-brain-sinks.js +5 -1
  243. package/dist/core/runner/run-compaction-machinery.d.ts +7 -1
  244. package/dist/core/runner/run-compaction-machinery.js +7 -33
  245. package/dist/core/runner/run-harness-handlers.js +4 -2
  246. package/dist/core/runner/run-identity-wiring.d.ts +3 -1
  247. package/dist/core/runner/run-identity-wiring.js +3 -2
  248. package/dist/core/runner/run-leg.js +103 -95
  249. package/dist/core/runner/run-notification-lane.js +1 -0
  250. package/dist/core/runner/run-recovery-lanes.d.ts +3 -0
  251. package/dist/core/runner/run-recovery-lanes.js +14 -11
  252. package/dist/core/runner/run-settle-and-teardown.js +9 -28
  253. package/dist/core/runner/run-stop-and-final-verify.js +18 -25
  254. package/dist/core/runner/run-terminal-adoption.d.ts +3 -0
  255. package/dist/core/runner/run-terminal-adoption.js +34 -22
  256. package/dist/core/runner/run-tool-mount-facts.js +5 -3
  257. package/dist/core/runner/run-turn-boundary.js +32 -37
  258. package/dist/core/runner/runtask.d.ts +6 -7
  259. package/dist/core/runner/runtask.js +15 -73
  260. package/dist/core/runner/session-rule-policy.d.ts +5 -5
  261. package/dist/core/runner/session-rule-policy.js +13 -8
  262. package/dist/core/runner/side-call-account.d.ts +68 -0
  263. package/dist/core/runner/side-call-account.js +61 -0
  264. package/dist/core/runner/skills-seat.d.ts +15 -0
  265. package/dist/core/runner/skills-seat.js +57 -0
  266. package/dist/core/runner/stream-halt-verbs.js +12 -17
  267. package/dist/core/runner/stream-lifecycle-verbs.js +8 -5
  268. package/dist/core/runner/stream-steer-verb.d.ts +1 -1
  269. package/dist/core/runner/stream-steer-verb.js +20 -38
  270. package/dist/core/runner/sub-agent-deny-lists.d.ts +124 -23
  271. package/dist/core/runner/sub-agent-deny-lists.js +230 -71
  272. package/dist/core/runner/synthetic-tools.d.ts +5 -2
  273. package/dist/core/runner/synthetic-tools.js +2 -12
  274. package/dist/core/runner/tool-end-body.d.ts +5 -6
  275. package/dist/core/runner/tool-end-body.js +6 -4
  276. package/dist/core/runner/tool-not-executed.d.ts +15 -0
  277. package/dist/core/runner/tool-not-executed.js +30 -0
  278. package/dist/core/runner/tool-occurrence.d.ts +8 -7
  279. package/dist/core/runner/tool-occurrence.js +5 -5
  280. package/dist/core/runner/tool-result-media-seat.d.ts +1 -1
  281. package/dist/core/runner-deps.d.ts +43 -36
  282. package/dist/core/safety-merge-corpus.js +18 -2
  283. package/dist/core/secret-env.d.ts +88 -20
  284. package/dist/core/secret-env.js +192 -38
  285. package/dist/core/session-policy-store.d.ts +71 -16
  286. package/dist/core/session-policy-store.js +138 -28
  287. package/dist/core/session-reconcile.d.ts +4 -0
  288. package/dist/core/session-reconcile.js +2 -1
  289. package/dist/core/shell-read-silence.js +3 -32
  290. package/dist/core/side-query.d.ts +5 -3
  291. package/dist/core/skill-grant.d.ts +3 -2
  292. package/dist/core/skill-grant.js +17 -9
  293. package/dist/core/skills-directory.d.ts +31 -11
  294. package/dist/core/skills-directory.js +655 -104
  295. package/dist/core/store-contracts/mailbox-store-contract.js +13 -0
  296. package/dist/core/task-event.d.ts +49 -3
  297. package/dist/core/task-notification.js +2 -2
  298. package/dist/core/task-result.d.ts +8 -0
  299. package/dist/core/task-spec.d.ts +20 -19
  300. package/dist/core/task-stream.d.ts +14 -4
  301. package/dist/core/tighten-task-spec.d.ts +4 -3
  302. package/dist/core/tighten-task-spec.js +2 -4
  303. package/dist/core/tool-check-reading.d.ts +74 -0
  304. package/dist/core/tool-check-reading.js +80 -0
  305. package/dist/core/tool-policy.d.ts +62 -18
  306. package/dist/core/tool-policy.js +86 -15
  307. package/dist/core/tool-registry.d.ts +20 -0
  308. package/dist/core/tool-registry.js +4 -0
  309. package/dist/core/tool-spec.d.ts +10 -6
  310. package/dist/core/tools.js +2 -0
  311. package/dist/core/trace.d.ts +51 -32
  312. package/dist/core/types.d.ts +2 -2
  313. package/dist/core/types.js +1 -1
  314. package/dist/core/unc-spelling.d.ts +10 -0
  315. package/dist/core/unc-spelling.js +3 -0
  316. package/dist/core/untrusted-egress.d.ts +8 -0
  317. package/dist/core/untrusted-egress.js +4 -1
  318. package/dist/core/untrusted-text.d.ts +16 -0
  319. package/dist/core/untrusted-text.js +7 -2
  320. package/dist/core/user-attachment.d.ts +25 -4
  321. package/dist/core/user-attachment.js +63 -42
  322. package/dist/core/wiring-manifest.d.ts +18 -15
  323. package/dist/core/wiring-manifest.js +2 -2
  324. package/dist/engine/compaction/utils.js +1 -2
  325. package/dist/engine/execution-env/node-execution-env.d.ts +4 -3
  326. package/dist/engine/execution-env/symlink-chain.js +1 -1
  327. package/dist/engine/harness/agent-harness.d.ts +1 -1
  328. package/dist/engine/harness/agent-harness.js +5 -4
  329. package/dist/engine/harness/types.d.ts +20 -16
  330. package/dist/engine/harness/types.js +7 -1
  331. package/dist/engine/llm/types.d.ts +12 -7
  332. package/dist/engine/loop/agent-loop.d.ts +12 -1
  333. package/dist/engine/loop/agent-loop.js +18 -6
  334. package/dist/engine/loop/types.d.ts +8 -2
  335. package/dist/engine/lsp/node-lsp-manager.d.ts +2 -2
  336. package/dist/engine/session/import-validate.js +3 -10
  337. package/dist/engine/session/session.d.ts +4 -4
  338. package/dist/engine/session/session.js +4 -4
  339. package/dist/index.d.ts +33 -23
  340. package/dist/index.js +23 -15
  341. package/dist/internal/harness.d.ts +2 -1
  342. package/dist/internal/harness.js +2 -1
  343. package/dist/orchestration/goal.d.ts +24 -1
  344. package/dist/orchestration/goal.js +3 -2
  345. package/dist/orchestration/run-spec.d.ts +4 -6
  346. package/dist/orchestration/run-spec.js +39 -63
  347. package/dist/orchestration/run-workflow-tool.js +1 -2
  348. package/dist/orchestration/workflow.d.ts +11 -3
  349. package/dist/orchestration/workflow.js +11 -2
  350. package/dist/prompt-assembly/artifact-store.d.ts +72 -56
  351. package/dist/prompt-assembly/artifact-store.js +60 -52
  352. package/dist/prompt-assembly/artifact.d.ts +90 -76
  353. package/dist/prompt-assembly/artifact.js +197 -145
  354. package/dist/prompt-assembly/assemble.d.ts +36 -29
  355. package/dist/prompt-assembly/assemble.js +34 -220
  356. package/dist/prompt-assembly/bands.d.ts +20 -0
  357. package/dist/prompt-assembly/bands.js +18 -0
  358. package/dist/prompt-assembly/catalog/constitution.d.ts +23 -0
  359. package/dist/prompt-assembly/catalog/constitution.js +69 -0
  360. package/dist/prompt-assembly/catalog/core-behavior.d.ts +9 -0
  361. package/dist/prompt-assembly/catalog/core-behavior.js +85 -0
  362. package/dist/prompt-assembly/catalog/index.d.ts +11 -0
  363. package/dist/prompt-assembly/catalog/index.js +60 -0
  364. package/dist/prompt-assembly/catalog/memory.d.ts +13 -0
  365. package/dist/prompt-assembly/catalog/memory.js +6 -0
  366. package/dist/prompt-assembly/catalog/modes.d.ts +15 -0
  367. package/dist/prompt-assembly/catalog/modes.js +137 -0
  368. package/dist/prompt-assembly/catalog/role.d.ts +10 -0
  369. package/dist/prompt-assembly/catalog/role.js +157 -0
  370. package/dist/prompt-assembly/catalog/schema.d.ts +138 -0
  371. package/dist/prompt-assembly/catalog/schema.js +25 -0
  372. package/dist/prompt-assembly/catalog/sections.d.ts +9 -0
  373. package/dist/prompt-assembly/catalog/sections.js +98 -0
  374. package/dist/prompt-assembly/catalog/team.d.ts +4 -0
  375. package/dist/prompt-assembly/catalog/team.js +258 -0
  376. package/dist/prompt-assembly/composer.d.ts +26 -28
  377. package/dist/prompt-assembly/composer.js +124 -46
  378. package/dist/prompt-assembly/epoch.d.ts +89 -79
  379. package/dist/prompt-assembly/epoch.js +115 -142
  380. package/dist/prompt-assembly/explain.d.ts +58 -34
  381. package/dist/prompt-assembly/explain.js +21 -24
  382. package/dist/prompt-assembly/overlay.d.ts +137 -0
  383. package/dist/prompt-assembly/overlay.js +339 -0
  384. package/dist/prompt-assembly/renderers.d.ts +21 -0
  385. package/dist/prompt-assembly/renderers.js +39 -0
  386. package/dist/prompt-assembly/section-usage.d.ts +3 -3
  387. package/dist/prompt-assembly/section-usage.js +1 -1
  388. package/dist/prompt-assembly/select.d.ts +71 -0
  389. package/dist/prompt-assembly/select.js +106 -0
  390. package/dist/prompt-assembly/sugar.d.ts +31 -0
  391. package/dist/prompt-assembly/sugar.js +20 -0
  392. package/dist/prompt-assembly/turn-snapshot.d.ts +3 -2
  393. package/dist/prompt-assembly/types.d.ts +45 -148
  394. package/dist/prompts/coordinator.d.ts +2 -21
  395. package/dist/prompts/coordinator.js +3 -255
  396. package/dist/prompts/cowork.d.ts +27 -16
  397. package/dist/prompts/cowork.js +2 -23
  398. package/dist/prompts/default.d.ts +38 -511
  399. package/dist/prompts/default.js +20 -288
  400. package/dist/prompts/supervisor.d.ts +6 -71
  401. package/dist/prompts/supervisor.js +6 -117
  402. package/dist/stores/file/permission-rule-store.d.ts +1 -1
  403. package/dist/stores/file/permission-rule-store.js +2 -1
  404. package/dist/tools/artifact/artifact-tool.js +4 -3
  405. package/dist/tools/fs/bash-readonly-classifier.d.ts +6 -5
  406. package/dist/tools/fs/dir-entries.d.ts +4 -2
  407. package/dist/tools/fs/dir-entries.js +16 -4
  408. package/dist/tools/fs/fs-bash.d.ts +1 -1
  409. package/dist/tools/fs/fs-bash.js +22 -11
  410. package/dist/tools/fs/fs-pdf.js +17 -13
  411. package/dist/tools/fs/fs-read.js +4 -3
  412. package/dist/tools/fs/fs-shared.d.ts +1 -10
  413. package/dist/tools/fs/fs-shared.js +3 -4
  414. package/dist/tools/fs/fs-write.js +2 -1
  415. package/dist/tools/fs/notebook.js +1 -1
  416. package/dist/tools/fs/pdf.d.ts +20 -10
  417. package/dist/tools/fs/pdf.js +19 -10
  418. package/dist/tools/fs/program-read-model.d.ts +68 -8
  419. package/dist/tools/fs/program-read-model.js +112 -33
  420. package/dist/tools/fs/program-read-model.rows.js +30 -10
  421. package/dist/tools/fs/read-deny-home.d.ts +25 -9
  422. package/dist/tools/fs/read-deny-home.js +28 -27
  423. package/dist/tools/fs/read-deny.d.ts +41 -11
  424. package/dist/tools/fs/read-deny.js +51 -5
  425. package/dist/tools/fs/safety.d.ts +4 -26
  426. package/dist/tools/fs/safety.js +10 -32
  427. package/dist/tools/fs/search.js +15 -10
  428. package/dist/tools/fs/shell-read-argv.d.ts +3 -2
  429. package/dist/tools/fs/shell-read-argv.js +118 -38
  430. package/dist/tools/fs/shell-read-establish.d.ts +5 -5
  431. package/dist/tools/fs/shell-read-establish.js +11 -61
  432. package/dist/tools/fs/shell-read-identity.js +6 -3
  433. package/dist/tools/fs/shell-read-judge.d.ts +13 -15
  434. package/dist/tools/fs/shell-read-judge.js +18 -4
  435. package/dist/tools/fs/shell-read-plan.d.ts +2 -2
  436. package/dist/tools/web.js +1 -1
  437. package/package.json +13 -1
  438. package/test/export-surface.snapshot.json +306 -103
  439. package/wire-changes/core@7.52.0.json +5859 -0
  440. package/wire-changes/core@7.53.0.json +1946 -0
  441. package/dist/core/hook-seats.d.ts +0 -66
  442. package/dist/core/hook-seats.js +0 -37
  443. package/dist/prompt-assembly/packs/sema-default.d.ts +0 -2
  444. package/dist/prompt-assembly/packs/sema-default.js +0 -147
  445. package/dist/prompts/simple-sections.d.ts +0 -58
  446. package/dist/prompts/simple-sections.js +0 -43
@@ -1,10 +1,9 @@
1
1
  import type { AgentHarness, AgentTool, ExecutionEnv, ThinkingLevel } from "../../internal/harness.js";
2
2
  import type { Model } from "../../internal/llm.js";
3
3
  import { type AssembledPrompt, type AssembleInputs } from "../../prompt-assembly/assemble.js";
4
- import { type PromptEpochArtifact } from "../../prompt-assembly/artifact.js";
5
- import type { EpochDeclaredSections } from "../../prompt-assembly/epoch.js";
6
4
  import { type TurnPromptSnapshot } from "../../prompt-assembly/turn-snapshot.js";
7
- import type { PromptTextDeclaration } from "../../prompts/default.js";
5
+ import { type CenterAdoption } from "../../prompt-assembly/artifact.js";
6
+ import type { RunPromptIdentity } from "../../prompt-assembly/epoch.js";
8
7
  import { CacheBreakDetector, type ToolFingerprintInput } from "../cache-break-detector.js";
9
8
  import type { ToolPolicy } from "../tool-policy.js";
10
9
  import { type SyntheticReadJudge } from "../synthetic-read-verdict.js";
@@ -39,8 +38,8 @@ export interface PrepareTurnWiringInput {
39
38
  };
40
39
  /** borrowed-readonly — the task model: `provider` / `id` / `maxTokens` / `api` (the snapshot's identity elements). */
41
40
  model: Pick<Model, "provider" | "id" | "maxTokens" | "api">;
42
- /** borrowed-readonly — the resolved epoch's artifact digest (the snapshot's identity element). */
43
- epochArtifactDigestForSnapshot: string;
41
+ /** borrowed-readonly — the run's prompt identity (the snapshot's `artifactDigest` element). */
42
+ promptIdentityDigest: string;
44
43
  /** borrowed-readonly — the resolved prompt profile (a snapshot element). */
45
44
  promptProfile: "simple" | "classic";
46
45
  /** borrowed-readonly — the fable mitigations switch (a snapshot element). */
@@ -109,21 +108,20 @@ export interface PrepareTurnWiringInput {
109
108
  /** borrowed-readonly — the registry scope the background listing reads under. */
110
109
  taskScope: string;
111
110
  /** borrowed-readonly — the prompt-assembly phase's re-invokable assemble-inputs builder (the candidate re-assembles). */
112
- buildAssembleInputs: (centerDecls?: PromptTextDeclaration[]) => AssembleInputs;
113
- /** borrowed-mutable — the LIVE center adoption (the prompt-assembly phase's accessor cell). Read: the candidate's arming and
114
- * same-artifact test. Writer here: the candidate's `apply` (the boundary swap / the explicit-disable rollback). */
111
+ buildAssembleInputs: (center: CenterAdoption | undefined) => AssembleInputs;
112
+ /** borrowed-readonly — the prompt-assembly phase's identity inputs under another center layer (the candidate's record). */
113
+ identityFor: (center: CenterAdoption | undefined) => RunPromptIdentity;
114
+ /** borrowed-readonly — whether this run adopts center candidates at its boundaries (a child never does). */
115
+ adoptsCandidates: boolean;
116
+ /** borrowed-mutable — the LIVE center adoption (the prompt-assembly phase's accessor cell). Read: the candidate's
117
+ * same-artifact test. Writer here: the candidate's `apply` (the boundary adoption / the explicit-disable emptying). */
115
118
  centerAdoptionRef: {
116
- current: {
117
- artifact: PromptEpochArtifact;
118
- sourceRevision?: string;
119
- } | undefined;
119
+ current: CenterAdoption | undefined;
120
120
  };
121
121
  /** borrowed-readonly — the harness ref (the candidate's `apply` calls `setSystemPrompt` on the current harness). */
122
122
  harnessRef: {
123
123
  current?: AgentHarness;
124
124
  };
125
- /** borrowed-readonly — the provider-declared sections in the epoch shape (the candidate's declared-sections TYPE). */
126
- epochDeclaredSections: EpochDeclaredSections;
127
125
  /** borrowed-readonly — the ONE carrier-face expression both delegation mounts consume (the observation seat). */
128
126
  carrierReadFace: () => ContainmentFace | undefined;
129
127
  /** borrowed-readonly — the same carrier expression on the WRITE seat. */
@@ -134,7 +132,7 @@ export interface PrepareTurnWiringInput {
134
132
  caseSensitive: boolean;
135
133
  }>;
136
134
  /** borrowed-mutable — the holder of the built Prepared. Writer: the DRIVER fills `current` right after `buildPrepared()`;
137
- * the candidate's `apply` then writes `current.epochDeclaredSections` and `current.promptOverheadTokens` at a boundary. */
135
+ * the candidate's `apply` then writes `current.promptIdentity` and `current.promptOverheadTokens` at a boundary. */
138
136
  preparedHolder: {
139
137
  current?: Prepared;
140
138
  };
@@ -1,7 +1,7 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { assemblePrompt } from "../../prompt-assembly/assemble.js";
3
- import { artifactDeclarations } from "../../prompt-assembly/artifact.js";
4
3
  import { buildTurnPromptSnapshot } from "../../prompt-assembly/turn-snapshot.js";
4
+ import { adoptCenter } from "../../prompt-assembly/artifact.js";
5
5
  import { CacheBreakDetector, toolsToFingerprintInputs } from "../cache-break-detector.js";
6
6
  import { defaultTaskRegistry } from "../task-registry.js";
7
7
  import { createSyntheticReadJudge } from "../synthetic-read-verdict.js";
@@ -15,7 +15,7 @@ import { PROMPT_HASH_SALT } from "./prompt-hash-salt.js";
15
15
  import { CHANGED_FILES_MTIME_EPS_MS } from "./turn-attachments.js";
16
16
  import { thrownText } from "../thrown-value.js";
17
17
  export function prepareTurnWiring(input) {
18
- const { deps, systemPromptSeat, harnessTools, fpRef, model, epochArtifactDigestForSnapshot, promptProfile, fableMitigations, systemBlocks, thinking, spec, sessionId, turnSnapshotRef, promptManifest, charsPerToken, handsEnabled, executionEnv, attachmentRootCanonical, readRoots, readDenyMatcher, resolvedReadFace, handsCwdRef, readFileStateForCheckpoint, denyNarrowingPolicy, skillGrants, callerPolicy, inheritedPolicies, persistedRuleLane, ruleLaneFacts, personRowsBeyondRun, orgRuleLane, stampCallTarget, abortController, hostTaskId, taskScope, buildAssembleInputs, centerAdoptionRef, harnessRef, epochDeclaredSections, carrierReadFace, carrierWriteFace, readDenyAdditionsNormalized, preparedHolder } = input;
18
+ const { deps, systemPromptSeat, harnessTools, fpRef, model, promptIdentityDigest, promptProfile, fableMitigations, systemBlocks, thinking, spec, sessionId, turnSnapshotRef, promptManifest, charsPerToken, handsEnabled, executionEnv, attachmentRootCanonical, readRoots, readDenyMatcher, resolvedReadFace, handsCwdRef, readFileStateForCheckpoint, denyNarrowingPolicy, skillGrants, callerPolicy, inheritedPolicies, persistedRuleLane, ruleLaneFacts, personRowsBeyondRun, orgRuleLane, stampCallTarget, abortController, hostTaskId, taskScope, buildAssembleInputs, identityFor, adoptsCandidates, centerAdoptionRef, harnessRef, carrierReadFace, carrierWriteFace, readDenyAdditionsNormalized, preparedHolder } = input;
19
19
  const cacheBreakDetector = deps.cacheBreakDetection === false ? undefined : new CacheBreakDetector();
20
20
  const cacheFingerprint = cacheBreakDetector
21
21
  ? { systemPrompt: systemPromptSeat.current, tools: toolsToFingerprintInputs(harnessTools) }
@@ -24,7 +24,7 @@ export function prepareTurnWiring(input) {
24
24
  const turnSnapshot = buildTurnPromptSnapshot({
25
25
  provider: model.provider,
26
26
  modelId: model.id,
27
- artifactDigest: epochArtifactDigestForSnapshot,
27
+ artifactDigest: promptIdentityDigest,
28
28
  promptProfile,
29
29
  fableMitigations,
30
30
  layoutGroups: (systemBlocks ?? [{ groupId: "body", cacheControlBoundary: true }]).map((b) => ({ groupId: b.groupId, cacheControlBoundary: b.cacheControlBoundary })),
@@ -165,49 +165,51 @@ export function prepareTurnWiring(input) {
165
165
  .filter((t) => t.status === "pending" || t.status === "running" || t.status === "parked")
166
166
  .map((t) => ({ id: t.task_id, ...(t.description !== undefined ? { description: t.description } : {}), status: t.status }));
167
167
  const overheadState = { promptChars: 0 };
168
- const centerCompactionCandidate = deps.promptSource !== undefined && centerAdoptionRef.current !== undefined
168
+ const centerCompactionCandidate = deps.promptSource !== undefined && adoptsCandidates
169
169
  ? () => {
170
- const state = deps.promptSource.sourceState?.() ?? "unavailable";
171
- const cand = deps.promptSource.current();
172
- const toBundled = state === "disabled";
173
- if (!toBundled && (cand === undefined || cand.artifact.artifactDigest === centerAdoptionRef.current.artifact.artifactDigest))
170
+ const state = deps.promptSource.sourceState();
171
+ const now = centerAdoptionRef.current;
172
+ let next;
173
+ if (state === "disabled") {
174
+ if (now === undefined)
175
+ return undefined;
176
+ next = undefined;
177
+ }
178
+ else if (state === "active") {
179
+ const cand = deps.promptSource.current();
180
+ if (cand === undefined || cand.artifactDigest === now?.artifact.artifactDigest)
181
+ return undefined;
182
+ next = adoptCenter(cand, cand.sourceRevision);
183
+ if (next === undefined)
184
+ return undefined;
185
+ }
186
+ else {
174
187
  return undefined;
188
+ }
175
189
  let a2;
176
190
  try {
177
- a2 = assemblePrompt(buildAssembleInputs(toBundled ? undefined : artifactDeclarations(cand.artifact)));
191
+ a2 = assemblePrompt(buildAssembleInputs(next));
178
192
  }
179
193
  catch {
180
194
  return undefined;
181
195
  }
182
- if (!toBundled && a2.centerMounted !== true)
183
- return undefined;
184
- const declared2 = (a2.sections ?? [])
185
- .filter((sec) => sec.origin === "provider")
186
- .map((sec) => ({ id: sec.id, slot: sec.slot, chars: sec.text.length, ...(sec.declaredContentHash !== undefined ? { contentHash: sec.declaredContentHash } : {}) }));
196
+ const promptIdentity = identityFor(next);
187
197
  const overheadTokensAfter = preparedHolder.current.promptOverheadTokens -
188
198
  Math.ceil(overheadState.promptChars / charsPerToken) +
189
199
  Math.ceil(a2.systemPrompt.length / charsPerToken);
190
200
  return {
191
- ...(toBundled
192
- ? { clear: true }
193
- : {
194
- centerArtifactDigest: cand.artifact.artifactDigest,
195
- ...(cand.sourceRevision !== undefined ? { sourceRevision: cand.sourceRevision } : {}),
196
- }),
197
- declaredSections: declared2,
201
+ promptIdentity,
198
202
  overheadTokensAfter,
199
- apply: (committedArtifactDigest) => {
203
+ apply: (committedIdentity) => {
200
204
  systemPromptSeat.current = a2.systemPrompt;
201
205
  harnessRef.current?.setSystemPrompt(a2.systemPrompt, a2.systemBlocks);
202
206
  if (fpRef.current)
203
207
  fpRef.current.systemPrompt = a2.systemPrompt;
204
- turnSnapshotRef.current?.refreshStableSystem(a2.systemPrompt, committedArtifactDigest);
205
- preparedHolder.current.epochDeclaredSections = declared2;
208
+ turnSnapshotRef.current?.refreshStableSystem(a2.systemPrompt, committedIdentity);
209
+ preparedHolder.current.promptIdentity = promptIdentity;
206
210
  preparedHolder.current.promptOverheadTokens = overheadTokensAfter;
207
211
  overheadState.promptChars = a2.systemPrompt.length;
208
- centerAdoptionRef.current = toBundled
209
- ? undefined
210
- : { artifact: cand.artifact, ...(cand.sourceRevision !== undefined ? { sourceRevision: cand.sourceRevision } : {}) };
212
+ centerAdoptionRef.current = next;
211
213
  },
212
214
  };
213
215
  }
@@ -21,7 +21,8 @@ import { type PeerLaneRefs } from "../../agents/peer-session-drain.js";
21
21
  import type { SessionBoxBinding } from "../task-notification.js";
22
22
  import type { OnQuestion } from "../ask-question.js";
23
23
  import type { CheckpointStore } from "../checkpoint-store.js";
24
- import { type HookEnvCapabilities, type HookInvocationIdentity, type Hooks } from "../hooks.js";
24
+ import { type HookEnvCapabilities, type HookInvocationIdentity } from "../hooks.js";
25
+ import type { ModBus } from "../mods/kernel/index.js";
25
26
  import type { LockedPreflight } from "../locked-config.js";
26
27
  import type { MaterializedMcp } from "../mcp.js";
27
28
  import type { SessionStore } from "../session.js";
@@ -39,7 +40,7 @@ export interface PrepareWiringManifestInput {
39
40
  * `resourceSuspend` (the task-axis lane), `durableApproval` / `principal` (the synthesis and the notice), `interactiveTools` /
40
41
  * `mcp` / `checkpointStore` (manifest cells and the notice's cause), `enablePlanMode` (the gate-machinery predicate's
41
42
  * plan-mode term), `writeProtectedAdditions` (the request's rows of the write-protection table). Never mutated. */
42
- spec: Pick<TaskSpec, "onQuestion" | "handsReadOnly" | "tools" | "resourceSuspend" | "durableApproval" | "principal" | "interactiveTools" | "mcp" | "checkpointStore" | "enablePlanMode" | "hooks" | "peerPresence" | "writeProtectedAdditions">;
43
+ spec: Pick<TaskSpec, "onQuestion" | "handsReadOnly" | "tools" | "resourceSuspend" | "durableApproval" | "principal" | "interactiveTools" | "mcp" | "checkpointStore" | "enablePlanMode" | "peerPresence" | "writeProtectedAdditions">;
43
44
  /** borrowed-readonly — the deployment seats, whole: `onError` (the warning), `executionEnv`
44
45
  * (the hook-env predicate), `checkpointStore` (durable infra), the manifest's dozen wiring facts (`backgroundAgentStore`,
45
46
  * `permissionRuleStore`, `permissionRuleSyncWired`, `onBackgroundChildEvent`, `lockedConfig`, `compliancePostureResolver`,
@@ -62,10 +63,8 @@ export interface PrepareWiringManifestInput {
62
63
  taskScope: string;
63
64
  /** borrowed-readonly — this leg's checkpoint scope (the driver's one derivation): the scope of the synthesized `durableApproval`. */
64
65
  checkpointScope: string;
65
- /** borrowed-readonly — the resolved hook record (`spec.hooks ?? deps.hooks`): the effect-aware-gate term, the tracked flag and the hook-env consumer test. */
66
- hooks: Hooks | undefined;
67
- /** borrowed-readonly — whether the deployment declared its screening face observational (then it is no gate). */
68
- preToolUseObservational: boolean;
66
+ /** borrowed-readonly — the leg's mods bus: the effect-aware-gate term, the tracked flag, the hook-env consumer test, and `mods[]` (its admission records). */
67
+ modBus: ModBus;
69
68
  /** borrowed-readonly — the caller-facing policy layers; only their COUNT is read (an effect-aware gate exists). */ policyLayers: ReadonlyArray<unknown>;
70
69
  /** borrowed-readonly — the policy chain's effective policy, or undefined; only its PRESENCE is read (the first term of the
71
70
  * gate-machinery predicate below). Never called here. */
@@ -115,7 +114,8 @@ export interface PrepareWiringManifestInput {
115
114
  /** borrowed-readonly — the model gate's per-leg read face, or undefined. */
116
115
  modelGateManifest: WiringManifest["modelGate"];
117
116
  /** borrowed-readonly — the leg's minted tool roster: rides the manifest's `tools` section and is the
118
- * source of the hand band's write-capable names for the ungated-write warning (what actually MOUNTED). */
117
+ * source of the hand band's write-capable names for the ungated-write warning (what actually MOUNTED) and of each MCP server's
118
+ * `toolCount` (its tools among the roster's names). */
119
119
  toolRoster: ToolRoster;
120
120
  /** borrowed-readonly — from the read-face phase: the built-in read-deny TIERS that leg's own
121
121
  * resolution materially activated; relayed onto the manifest (present iff non-empty), never
@@ -141,6 +141,9 @@ export interface PrepareWiringManifestInput {
141
141
  frameSettlement: import("../frame-settlement.js").FrameSettlement;
142
142
  /** borrowed-readonly — the session-box drain's mount verdict (prepare-task's one judgment): present ⇒ this leg drains its own box. */
143
143
  sessionBox: SessionBoxBinding | undefined;
144
+ /** borrowed-readonly, read late — the memory session's one-way pollution face (absent with no memory session). The drain marks
145
+ * it when it INJECTS a letter from another principal (the injection path; the tool path is accounted by `ReadInbox`'s class). */
146
+ memoryPollution?: () => Pick<NonNullable<Prepared["memoryEngineSession"]>["pollution"], "markPolluted"> | undefined;
144
147
  /** borrowed-readonly — the built harness the peer drain binds to. */
145
148
  harness: AgentHarness;
146
149
  /** borrowed-readonly — the durable-suspend holder; the drain's parked predicate reads `token` at run time. Not written here. */
@@ -203,7 +206,8 @@ export interface PrepareWiringManifestResult {
203
206
  * The wiring manifest's per-server MCP read face for one leg ({@link WiringManifest.mcp}): every
204
207
  * server the leg's FROZEN entry snapshot declared, in declaration order, joined by name to this leg's
205
208
  * materialization statuses. Pure projection — no connection logic, no second look at any transport:
206
- * · a status `connected` ⇒ `connected` with the mounted roster size (the intake's post-filter count);
209
+ * · a status `connected` ⇒ `connected` with the server's tools among `rosterNames` — the names of the roster the row is read
210
+ * against: a run's (the valve and the deployment's overlay applied), or the no-run probe's own dials (no run, so no lists apply);
207
211
  * · a status `failed` ⇒ `failed` with the failure record the materialization stamped (`errorCode`/`delivered`/
208
212
  * `httpStatus` = the MCP vocabulary's `McpFailure` spread flat) and the remote text SECRET-REDACTED (an HTTP endpoint's error body rides the SDK's message
209
213
  * verbatim, and a body that echoes the bearer it rejected must not reach a stream consumer),
@@ -214,6 +218,6 @@ export interface PrepareWiringManifestResult {
214
218
  * `liveness` is the status record's own observation deep-copied (see {@link WiringManifestMcpEntry.liveness}).
215
219
  * The entries are fresh objects so the manifest never aliases the status records the refresh face mutates.
216
220
  */
217
- export declare function mcpManifestEntries(entries: ReadonlyArray<import("../types.js").McpServerSpec> | undefined, statuses: ReadonlyArray<import("../mcp.js").McpServerStatus>): WiringManifestMcpEntry[];
221
+ export declare function mcpManifestEntries(entries: ReadonlyArray<import("../types.js").McpServerSpec> | undefined, statuses: ReadonlyArray<import("../mcp.js").McpServerStatus>, rosterNames: ReadonlyArray<string>): WiringManifestMcpEntry[];
218
222
  /** The M18 phase body — prepareTask's wiring-manifest stretch, verbatim (see the module header). */
219
223
  export declare function prepareWiringManifest(input: PrepareWiringManifestInput): PrepareWiringManifestResult;
@@ -2,7 +2,8 @@ import { bindPeerLaneDrain } from "../../agents/peer-session-drain.js";
2
2
  import { teamRoleOf } from "../../agents/team-role.js";
3
3
  import { resolveCheckpointStore } from "../checkpoint-store.js";
4
4
  import { createHookEnvCapabilities, mintHookInvocationIdentity } from "../hooks.js";
5
- import { wiredHookEntries } from "../hook-seats.js";
5
+ import { chainJudges } from "../mods/stations.js";
6
+ import { toolNamesOfServer } from "../mounted-mcp.js";
6
7
  import { isRemoteExecutionEnv, missingRestoreSurface } from "../remote-env.js";
7
8
  import { isVolatileOffloadStore } from "../tool-result-store.js";
8
9
  import { durableMandateSourceOf, isLiveApproverSeat } from "../tool-policy.js";
@@ -13,7 +14,7 @@ import { autoRunOnRecommendationEffective } from "./memory-consolidation-driver.
13
14
  import { GLOBAL_USAGE_KEY, usageRetryAfterMs, windowsGovernCost } from "../usage-window-store.js";
14
15
  import { LSP_CONTRACT_ID, askSeatEffective, countElicitOptIns, deriveHandsSeam, deriveLspSeam, deriveWiringManifest, resolveDeclaredDurability, resolveElicitSeam, resolveQuestionSeam, resolveSubagentTranscriptTier } from "../wiring-manifest.js";
15
16
  import { modePolicyOf } from "../mode-policy.js";
16
- export function mcpManifestEntries(entries, statuses) {
17
+ export function mcpManifestEntries(entries, statuses, rosterNames) {
17
18
  return (entries ?? []).map((entry) => {
18
19
  const status = statuses.find((s) => s.name === entry.name);
19
20
  const source = typeof entry.source === "string" && entry.source.length > 0 ? { source: inlineUntrusted(entry.source, 80) } : {};
@@ -21,7 +22,7 @@ export function mcpManifestEntries(entries, statuses) {
21
22
  if (status === undefined)
22
23
  return { name: entry.name, ...source, status: "skipped", toolCount: 0 };
23
24
  if (status.status === "connected")
24
- return { name: entry.name, ...source, status: "connected", toolCount: status.toolNames?.length ?? 0, ...liveness };
25
+ return { name: entry.name, ...source, status: "connected", toolCount: toolNamesOfServer(rosterNames, entry.name).length, ...liveness };
25
26
  return {
26
27
  name: entry.name,
27
28
  ...source,
@@ -116,13 +117,14 @@ function announceDurableGateUnavailable(args) {
116
117
  });
117
118
  }
118
119
  export function prepareWiringManifest(input) {
119
- const { spec, deps, internals, resume, sessionId, runId, hostTaskId, taskScope, checkpointScope, hooks, preToolUseObservational, 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, lspDiagnosticsLive, fileHistoryFact } = input;
120
+ const { spec, deps, internals, resume, sessionId, runId, hostTaskId, taskScope, modBus, 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, lspDiagnosticsLive, fileHistoryFact, memoryPollution } = input;
120
121
  const onAsk = askSeat.value;
121
122
  const handWriteTools = toolRoster.entries.filter((e) => e.mountedBy === "hands" && (e.effect === "write" || e.effect === "idempotent")).map((e) => e.name);
122
- const hasEffectAwareGate = Boolean(policyLayers.length > 0 || (hooks?.preToolUse !== undefined && !preToolUseObservational));
123
+ const hasEffectAwareGate = policyLayers.length > 0 || chainJudges(modBus);
124
+ const rosterHolds = new Set(toolRoster.entries.map((e) => e.name));
123
125
  const peerWriteUngated = modePolicyOf(permissionMode.current).unstated === "ask"
124
126
  ? []
125
- : mcp.tools.filter((t) => t.permissionSeat === "passthrough" && !irreversibleTools.has(t.name) && !egressTools.has(t.name) && (toolEffects.get(t.name) ?? "write") !== "read").map((t) => t.name);
127
+ : 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);
126
128
  const firstPartyWriteUngated = (spec.tools ?? [])
127
129
  .map((t) => t.name)
128
130
  .filter((name) => !irreversibleTools.has(name) && !egressTools.has(name) && toolEffects.get(name) === "write");
@@ -151,7 +153,7 @@ export function prepareWiringManifest(input) {
151
153
  const preToolContexts = new Map();
152
154
  const blockedToolCalls = new Set();
153
155
  const batchHaltRef = {};
154
- const blockedTracked = Boolean(hooks?.postToolUse || hooks?.preToolUse || hooks?.postToolUseFailure || hooks?.postToolBatch);
156
+ const blockedTracked = ["classic.PostToolUse", "classic.PreToolUse", "classic.PostToolUseFailure", "classic.PostToolBatch"].some((ev) => modBus.hasHandlers(ev));
155
157
  const restoreSurfaceGap = ownedEnv !== undefined && isRemoteExecutionEnv(ownedEnv) && ownedEnv.capabilities.suspendable ? missingRestoreSurface(ownedEnv) : [];
156
158
  const incompleteSuspendAdapter = restoreSurfaceGap.length > 0 ? restoreSurfaceGap : undefined;
157
159
  const durableSuspendInfraReady = resolveCheckpointStore(spec, deps) !== undefined &&
@@ -213,12 +215,12 @@ export function prepareWiringManifest(input) {
213
215
  ...(modelGateManifest !== undefined ? { modelGate: modelGateManifest } : {}),
214
216
  autoMode: { ...autoModeArmReason() },
215
217
  permissionMode: permissionMode.receipt(),
216
- mcp: mcpManifestEntries(lockedPreflight.mcp, mcp.statuses),
218
+ mcp: mcpManifestEntries(lockedPreflight.mcp, mcp.statuses, toolRoster.entries.map((e) => e.name)),
217
219
  ...(writeProtection.mount !== undefined ? { writeProtectionTargetView: writeProtection.mount.targetView } : {}),
218
220
  readDenyBuiltinTiersActive,
219
221
  autoConsolidationOnRecommendation: autoRunOnRecommendationEffective(deps),
220
222
  tools: toolRoster,
221
- hooks: wiredHookEntries(hooks, spec.hooks !== undefined ? "spec" : "deps", preToolUseObservational),
223
+ mods: modBus.records,
222
224
  ...(lspManagerWired ? { lsp: deriveLspSeam(toolRoster.entries.some((e) => e.contract.contractId === LSP_CONTRACT_ID), lspDiagnosticsLive) } : {}),
223
225
  hands: deriveHandsSeam(handsEnabled),
224
226
  fileHistory: fileHistoryFact,
@@ -238,12 +240,13 @@ export function prepareWiringManifest(input) {
238
240
  settlement: frameSettlement,
239
241
  selfName: () => internals?.explicitAgentName,
240
242
  parked: () => pausedRef.current !== undefined,
243
+ markExternalContent: (reason) => memoryPollution?.()?.markPolluted(reason, "observed"),
241
244
  });
242
245
  frameSettlement.boxBacked = (payload) => peerLaneRefs.isBoxBacked?.(payload) ?? false;
243
246
  }
244
247
  const parkLaneArmed = wiringManifest.parkLane.effective === true;
245
248
  const gateMachineryActive = effectivePolicy !== undefined ||
246
- hooks?.preToolUse !== undefined ||
249
+ modBus.hasHandlers("classic.PreToolUse") ||
247
250
  egressTools.size > 0 ||
248
251
  irreversibleTools.size > 0 ||
249
252
  shellReadStationArmed ||
@@ -262,7 +265,7 @@ export function prepareWiringManifest(input) {
262
265
  ...(internals?.spawnAgentType !== undefined ? { agentType: internals.spawnAgentType } : {}),
263
266
  ...(internals?.parentToolCallId !== undefined ? { parentToolCallId: internals.parentToolCallId } : {}),
264
267
  });
265
- const hookContextConsumerWired = hooks?.preToolUse !== undefined || hooks?.postToolUse !== undefined || hooks?.postToolUseFailure !== undefined;
268
+ const hookContextConsumerWired = ["classic.PreToolUse", "classic.PostToolUse", "classic.PostToolUseFailure"].some((ev) => modBus.hasHandlers(ev));
266
269
  const hookEnvFace = hookContextConsumerWired && (ownedEnv ?? deps.executionEnv) != null ? createHookEnvCapabilities(executionEnv) : undefined;
267
270
  return { onAsk, preToolContexts, blockedToolCalls, batchHaltRef, blockedTracked, incompleteSuspendAdapter, durableSuspendInfraReady, resourceSuspendEligible, usageGovernance, platformSuspendArmed, durableApproval, wiringManifest, writeProtection, parkLaneArmed, gateMachineryActive, hookIdentity, hookEnvFace, sessionBoxBound };
268
271
  }
@@ -12,6 +12,7 @@
12
12
  */
13
13
  import { type Checkpoint, type CheckpointStore, type CheckpointToken, type PendingSteerEntry, type ResumeOutcome } from "../checkpoint-store.js";
14
14
  import type { InheritedGate, ResumeTaskConfig, RunInternals, RunnerDepsSeat } from "./contracts.js";
15
+ import type { SessionStore } from "../session.js";
15
16
  /** What the admission rung was called with. */
16
17
  export interface ResumeAdmissionInput<R> {
17
18
  /** borrowed-readonly — the checkpoint token the caller is redeeming. */
@@ -28,6 +29,8 @@ export interface ResumeAdmissionInput<R> {
28
29
  /** borrowed-readonly — the Runner's deployment deps, read LIVE through the Runner (the store resolution reads `checkpointStore`); the one home of why it is a
29
30
  * seat and not a captured object is {@link RunnerDepsSeat}. */
30
31
  runner: RunnerDepsSeat;
32
+ /** borrowed-readonly — the Runner's session store, fixed at its construction (unlike its deps): the retention capability door judges it. */
33
+ sessions: SessionStore;
31
34
  /** borrowed-readonly — the Runner's same-process parked-constraint registry; read for this token (never written here). */
32
35
  parentConstraintRegistry: ReadonlyMap<CheckpointToken, NonNullable<InheritedGate["parentConstraints"]>>;
33
36
  /** borrowed-readonly — the rung after admission, entered in this rung's last continuation with what it admitted. */
@@ -35,7 +38,7 @@ export interface ResumeAdmissionInput<R> {
35
38
  }
36
39
  /** What admission established — the constants every later rung reads. */
37
40
  export interface ResumeAdmissionResult {
38
- /** The caller's config, snapshotted once (own enumerable fields). */
41
+ /** The caller's config, snapshotted once (own enumerable fields), its MCP / A2A entries the frozen ones the doors judged. */
39
42
  config: ResumeTaskConfig;
40
43
  /** The trusted internals snapshot, with the parked parent chain re-supplied when this Runner spawned the leg. */
41
44
  internals: RunInternals | undefined;
@@ -1,16 +1,18 @@
1
1
  import { CheckpointError, readPendingSteerQueue, refuseRetiredModeSeed, resolveCheckpointStore, validatePendingSteer } from "../checkpoint-store.js";
2
- import { refuseResumeDoors } from "../mode-policy.js";
2
+ import { assertResumeConfigRecord, checkpointStoreSeat, refuseResumeDoors } from "./prepare-config-doors.js";
3
+ import { asResumeConfigRefusal } from "../mode-policy.js";
3
4
  import { describeSuppliedValue } from "./decide-continuation.js";
4
5
  import { detachSkillLists } from "../skill-grant.js";
5
6
  export async function resumeAdmission(input) {
6
- const { token, outcome, taskConfig, runner, parentConstraintRegistry } = input;
7
+ const { token, outcome, taskConfig, runner, sessions, parentConstraintRegistry } = input;
7
8
  let internals = input.internals;
8
9
  if (outcome === null || typeof outcome !== "object") {
9
10
  throw new CheckpointError("checkpoint.invalid_outcome", `resume outcome must be an object naming its gate (got ${outcome === null ? "null" : typeof outcome})`);
10
11
  }
11
- const config = typeof taskConfig === "object" && taskConfig !== null ? { ...taskConfig, ...(Array.isArray(taskConfig.skills) ? { skills: detachSkillLists(taskConfig.skills) } : {}) } : taskConfig;
12
+ asResumeConfigRefusal("taskConfig", () => assertResumeConfigRecord(taskConfig));
13
+ let config = { ...taskConfig, ...(Array.isArray(taskConfig.skills) ? { skills: detachSkillLists(taskConfig.skills) } : {}) };
12
14
  internals = internals !== undefined ? { ...internals } : undefined;
13
- const store = resolveCheckpointStore(config, runner.deps);
15
+ const store = asResumeConfigRefusal(checkpointStoreSeat(config), () => resolveCheckpointStore(config, runner.deps));
14
16
  if (!store) {
15
17
  throw new CheckpointError("checkpoint.not_found", "no CheckpointStore wired — cannot resume (set RunnerDeps.checkpointStore or taskConfig.checkpointStore)");
16
18
  }
@@ -39,7 +41,7 @@ export async function resumeAdmission(input) {
39
41
  const resumeSignal = config.signal;
40
42
  let suppliedMessage;
41
43
  refuseRetiredModeSeed(cp.state);
42
- refuseResumeDoors(config, cp.state.inheritedGate);
44
+ config = refuseResumeDoors(config, cp.state.inheritedGate, runner.deps, sessions);
43
45
  const parkedSteers = readPendingSteerQueue(cp.state);
44
46
  if (outcomeGate === "wake") {
45
47
  suppliedMessage = outcome.message;
@@ -1,9 +1,10 @@
1
1
  import { type Checkpoint, type PendingSteerEntry, type ResumeOutcome } from "../checkpoint-store.js";
2
+ import { type LegMods } from "../mods/stations.js";
2
3
  import type { ResumeRun, ResumeTaskConfig, RunInternals, RunnerDepsSeat } from "./contracts.js";
3
4
  export interface ResumeApplyInput<R> {
4
5
  /** borrowed-readonly — the pending row (session id, pending call, inherited chain, ledger, hands cwd). */
5
6
  cp: Checkpoint;
6
- /** borrowed-readonly — the config snapshot (`hooks`, `taskId`, `signal`, the policy seats). */
7
+ /** borrowed-readonly — the config snapshot (`mods`, `taskId`, `signal`, the policy seats). */
7
8
  config: ResumeTaskConfig;
8
9
  /** borrowed-readonly — the internals snapshot (delegation identity facts for the screen's envelope). */
9
10
  internals: RunInternals | undefined;
@@ -27,7 +28,7 @@ export interface ResumeApplyInput<R> {
27
28
  plainParkOutcome: Extract<ResumeOutcome, {
28
29
  gate: "wake" | "resource_limit";
29
30
  }> | undefined;
30
- /** borrowed-readonly — the Runner's deployment deps, read LIVE through the Runner (reads `hooks`, `onError`, `lockedConfig`, `basePolicyForResumeEdit`, `toolPolicy` — the last three AFTER this rung's awaits); the one home of why it is a
31
+ /** borrowed-readonly — the Runner's deployment deps, read LIVE through the Runner (reads `mods`, `onError`, `lockedConfig`, `basePolicyForResumeEdit`, `toolPolicy` — the last three AFTER this rung's awaits); the one home of why it is a
31
32
  * seat and not a captured object is {@link RunnerDepsSeat}. */
32
33
  runner: RunnerDepsSeat;
33
34
  /** borrowed-readonly — the orchestrator's delegation-facts fold (a lane may not name the orchestrator; the driver hands it in). */
@@ -40,6 +41,8 @@ export interface ResumeApplyInput<R> {
40
41
  export interface ResumeApplyResult {
41
42
  /** The screen's `additionalContext` for the wake message, when a screen ran and supplied one. */
42
43
  wakeHookContext: string | undefined;
44
+ /** The resumed leg's bus, when the wake-message screen made this rung admit it (the leg adopts it). */
45
+ legMods?: LegMods;
43
46
  /** The approval lane's twin WITH its minted settlement record (undefined on every other lane). */
44
47
  plainPolicyOutcome: Extract<ResumeOutcome, {
45
48
  gate: "policy_ask";
@@ -1,8 +1,9 @@
1
1
  import { snapshotActorAssertion } from "../../internal/llm.js";
2
2
  import { ASK_USER_QUESTION_TOOL_NAME } from "../ask-question.js";
3
3
  import { CheckpointError, remainingBudgetMicroUsd } from "../checkpoint-store.js";
4
- import { mintHookInvocationIdentity, resolveHookTimeoutMs, runHookSeat } from "../hooks.js";
5
4
  import { chainPolicyOnLeg, chainTopAnchors } from "./child-tree.js";
5
+ import { mintHookInvocationIdentity } from "../hooks.js";
6
+ import { admitLegMods, classicEventBase, failedHandlerClause, screenUserPrompt } from "../mods/stations.js";
6
7
  import { checkToolPolicyProjection, policyCannotAnswer, refuseOutOfContractDecision } from "../tool-policy.js";
7
8
  import { callFaceSeat, parkedCallFaceOf } from "../tool-roster.js";
8
9
  import { readCallTarget } from "../effective-path-target.js";
@@ -10,7 +11,7 @@ import { inlineUntrusted } from "../untrusted-text.js";
10
11
  import { deepJsonEqual, describeSuppliedValue, mintDecideRecord } from "./decide-continuation.js";
11
12
  import { orgVerdictBeforeClaim } from "./permission-rule-lanes.js";
12
13
  import { chainCannotJudge } from "./call-hook-stations.js";
13
- import { asThrownError, thrownText } from "../thrown-value.js";
14
+ import { thrownText } from "../thrown-value.js";
14
15
  import { wireOf } from "../tool-name-readings.js";
15
16
  import { parkedSkillApprovalRefusal } from "../skill-grant.js";
16
17
  import { SKILL_CONTENT_MAX_CHARS, SKILL_TOOL_NAME, normalizeSkills } from "./synthetic-tools.js";
@@ -19,10 +20,12 @@ export async function resumeApply(input) {
19
20
  const { cp, config, internals, outcomeGate, wakeMessage, resumeSignal, recheckGovernanceWindow, plainReviewOutcome, plainParkOutcome, runner, effectiveDelegationFacts } = input;
20
21
  let plainPolicyOutcome = input.plainPolicyOutcome;
21
22
  let wakeHookContext;
23
+ let legMods;
22
24
  if (outcomeGate === "wake" && wakeMessage !== undefined) {
23
- const resumeScreenHooks = config.hooks ?? runner.deps.hooks;
24
- const screen = resumeScreenHooks?.userPromptSubmit;
25
- if (screen !== undefined && resumeSignal?.aborted !== true) {
25
+ if (resumeSignal?.aborted !== true) {
26
+ legMods = await admitLegMods({ spec: config, deps: runner.deps, sessionId: cp.sessionId });
27
+ }
28
+ if (legMods !== undefined && legMods.bus.hasHandlers("classic.UserPromptSubmit")) {
26
29
  const screenedMessage = wakeMessage;
27
30
  const identity = mintHookInvocationIdentity({
28
31
  sessionId: cp.sessionId,
@@ -35,45 +38,24 @@ export async function resumeApply(input) {
35
38
  ...(internals?.spawnAgentType !== undefined ? { agentType: internals.spawnAgentType } : {}),
36
39
  ...(internals?.parentToolCallId !== undefined ? { parentToolCallId: internals.parentToolCallId } : {}),
37
40
  });
38
- const screenTimeoutMs = resolveHookTimeoutMs(resumeScreenHooks?.timeoutMs, (badErr) => {
39
- try {
40
- runner.deps.onError?.(asThrownError(badErr), { phase: "hook", sessionId: cp.sessionId });
41
- }
42
- catch {
43
- }
44
- }, resumeScreenHooks);
45
- let decision;
46
- try {
47
- const seat = await runHookSeat("userPromptSubmit", { timeoutMs: screenTimeoutMs, ...(resumeSignal !== undefined ? { signal: resumeSignal } : {}), abortEnds: true }, (sig) => screen(screenedMessage.text, {
48
- identity,
49
- signal: sig,
50
- source: "resume_message",
51
- ...(screenedMessage.inputId !== undefined ? { inputId: screenedMessage.inputId } : {}),
52
- ...(screenedMessage.actor !== undefined ? { actor: snapshotActorAssertion(screenedMessage.actor) } : {}),
53
- }));
54
- if (seat.expired) {
55
- if (seat.cause === "aborted")
56
- throw new CheckpointError("checkpoint.resume_aborted", "the resume was aborted while the deployment's userPromptSubmit hook was still screening this wake message — the checkpoint stays pending and is resumable with a live signal");
57
- throw new CheckpointError("steering.blocked_by_hook", `the deployment's userPromptSubmit hook did not answer within its ${screenTimeoutMs}ms bound while screening this wake message; the resume was refused (fail-closed) and the checkpoint stays pending`);
58
- }
59
- decision = seat.value;
41
+ const screen = await screenUserPrompt(legMods.bus, {
42
+ ...classicEventBase(identity),
43
+ prompt: screenedMessage.text,
44
+ source: "resume_message",
45
+ ...(screenedMessage.inputId !== undefined ? { inputId: screenedMessage.inputId } : {}),
46
+ ...(screenedMessage.actor !== undefined ? { actor: snapshotActorAssertion(screenedMessage.actor) } : {}),
47
+ }, resumeSignal);
48
+ if (screen?.kind === "aborted") {
49
+ throw new CheckpointError("checkpoint.resume_aborted", "the resume was aborted while the deployment's userPromptSubmit hook was still screening this wake message — the checkpoint stays pending and is resumable with a live signal");
60
50
  }
61
- catch (hookErr) {
62
- if (hookErr instanceof CheckpointError)
63
- throw hookErr;
64
- const err = asThrownError(hookErr);
65
- try {
66
- runner.deps.onError?.(err, { phase: "hook", sessionId: cp.sessionId });
67
- }
68
- catch {
69
- }
70
- throw new CheckpointError("steering.blocked_by_hook", `the deployment's userPromptSubmit hook crashed while screening this wake message (${inlineUntrusted(err.message)}); the resume was refused (fail-closed) and the checkpoint stays pending`);
51
+ if (screen?.kind === "failed") {
52
+ throw new CheckpointError("steering.blocked_by_hook", `the deployment's userPromptSubmit hook ${failedHandlerClause(screen)} while screening this wake message; the resume was refused (fail-closed) and the checkpoint stays pending`);
71
53
  }
72
- if (decision?.block !== undefined && decision.block !== "") {
73
- throw new CheckpointError("steering.blocked_by_hook", `the deployment's userPromptSubmit hook blocked this wake message: ${inlineUntrusted(decision.block)}`);
54
+ if (screen?.block !== undefined && screen.block !== "") {
55
+ throw new CheckpointError("steering.blocked_by_hook", `the deployment's userPromptSubmit hook blocked this wake message: ${inlineUntrusted(screen.block)}`);
74
56
  }
75
- if (decision?.additionalContext !== undefined && decision.additionalContext !== "") {
76
- wakeHookContext = decision.additionalContext;
57
+ if (screen?.additionalContext !== undefined && screen.additionalContext !== "") {
58
+ wakeHookContext = screen.additionalContext;
77
59
  }
78
60
  if (recheckGovernanceWindow !== undefined)
79
61
  await recheckGovernanceWindow();
@@ -192,5 +174,5 @@ export async function resumeApply(input) {
192
174
  if (outcomeForStore === undefined) {
193
175
  throw new CheckpointError("checkpoint.invalid_outcome", `resume outcome (gate "${describeSuppliedValue(outcomeGate)}") matched the checkpoint gate but no lane captured it — refusing pre-CAS rather than passing the caller's live object to the store and the resumed run`);
194
176
  }
195
- return await input.next({ wakeHookContext, plainPolicyOutcome, outcomeForStore });
177
+ return await input.next({ wakeHookContext, ...(legMods !== undefined ? { legMods } : {}), plainPolicyOutcome, outcomeForStore });
196
178
  }
@@ -7,6 +7,7 @@ export interface ResumeCheckpointScreenInput {
7
7
  resumeSignal: AbortSignal | undefined;
8
8
  /** borrowed-readonly — the internals snapshot (the re-supplied chain, the requested cwd). */
9
9
  internals: RunInternals | undefined;
10
+ /** borrowed-readonly — the roster the resume hands (`ResumeTaskConfig.tools`), as the caller mounts it. */ tools: unknown;
10
11
  /** borrowed-readonly — the Runner's deployment deps, read LIVE through the Runner (reads `permissionRuleStore` and `executionEnvFactory`); the one home of why it is a
11
12
  * seat and not a captured object is {@link RunnerDepsSeat}. */
12
13
  runner: RunnerDepsSeat;
@@ -6,8 +6,11 @@ import { judgeCheckpointRequirements } from "../checkpoint-requirements.js";
6
6
  import { constraintChainDigest, constraintChainEntryOfSuppliedLayer } from "../tool-policy.js";
7
7
  import { readFrozenSkillGrants } from "../skill-grant.js";
8
8
  import { chainInstallationGaps, chainInstallationRefusal } from "./child-tree.js";
9
+ import { screeningInstallationsOf, unraisableGuardsOf } from "../mods/stations.js";
10
+ import { refusePersistedToolNames, refuseRenamedDelegationMounts } from "./sub-agent-deny-lists.js";
11
+ import { asResumeConfigRefusal } from "../mode-policy.js";
9
12
  export function resumeCheckpointScreen(input) {
10
- const { cp, resumeSignal, internals, runner } = input;
13
+ const { cp, resumeSignal, internals, tools, runner } = input;
11
14
  const { realApproval: realApprovalRow, face: faceRow, f012: f012Row } = CHECKPOINT_FEATURES;
12
15
  if (checkpointVersionOf(cp) > MAX_SUPPORTED_CHECKPOINT_VERSION) {
13
16
  throw new CheckpointError("checkpoint.unsupported_version", `checkpoint requires reader capabilities this worker lacks (row format v${checkpointVersionOf(cp)}; this worker reads up to v${MAX_SUPPORTED_CHECKPOINT_VERSION}) — resume it on a worker at or above the version that parked it`, { reason: "version_newer" });
@@ -84,6 +87,8 @@ export function resumeCheckpointScreen(input) {
84
87
  "the restored workspace's own mount path is authoritative for the task root. Drop requestedCwd on resume legs " +
85
88
  "(the checkpoint stays pending and is resumable without it).");
86
89
  }
90
+ asResumeConfigRefusal("inheritedGate", () => refusePersistedToolNames((internals?.toolCeiling ?? undefined) === undefined ? cp.state.toolCeiling : undefined, cp.state.inheritedGate?.constraintChain, (internals?.ownToolLists ?? undefined) === undefined ? cp.state.ownToolLists : undefined));
91
+ asResumeConfigRefusal("taskConfig", () => refuseRenamedDelegationMounts(tools));
87
92
  if (cp.state.inheritedGate?.requiresParentConstraint === true) {
88
93
  const supplied = internals?.inheritedGate?.parentConstraints?.length ?? 0;
89
94
  if (supplied === 0) {
@@ -126,6 +131,9 @@ export function resumeCheckpointScreen(input) {
126
131
  if (gaps.length > 0)
127
132
  throw chainInstallationRefusal(gaps, true);
128
133
  }
134
+ const unraisable = unraisableGuardsOf(screeningInstallationsOf(internals?.inheritedGate?.parentConstraints ?? []));
135
+ if (unraisable !== undefined)
136
+ throw new CheckpointError("resume.parent_constraint_mismatch", `${unraisable}; rejected pre-CAS (the checkpoint stays pending)`);
129
137
  const resumeInternals = internals?.inheritedGate?.parentConstraints !== undefined
130
138
  ? {
131
139
  ...internals,
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * The resume ladder's INTERNALS-AND-CONFIG rung (E7), verbatim from `Runner.resumeStream`:
3
- * the locked-policy guard on the resume-edit seat, the principal and placement identity-continuity rungs,
3
+ * the inherited constraints' retired-member door, the principal and placement 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
@@ -14,13 +14,13 @@ import type { ResumeTaskConfig, RunInternals, RunnerDepsSeat } from "./contracts
14
14
  export interface ResumeInternalsAndConfigInput {
15
15
  /** borrowed-readonly — the pending row (recorded principal, placement root, parked steers, background tasks). */
16
16
  cp: Checkpoint;
17
- /** borrowed-readonly — the config snapshot (`basePolicyForResumeEdit`, `principal`). */
17
+ /** borrowed-readonly — the config snapshot (`principal`). */
18
18
  config: ResumeTaskConfig;
19
19
  /** borrowed-readonly — the internals snapshot (`placementRoot`). */
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"];
23
- /** borrowed-readonly — the Runner's deployment deps, read LIVE through the Runner (reads `lockedConfig`, `usageWindowStore`, `usageWindows`); the one home of why it is a
23
+ /** borrowed-readonly — the Runner's deployment deps, read LIVE through the Runner (reads `usageWindowStore`, `usageWindows`); the one home of why it is a
24
24
  * seat and not a captured object is {@link RunnerDepsSeat}. */
25
25
  runner: RunnerDepsSeat;
26
26
  }