@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
@@ -0,0 +1,7 @@
1
+ export function mintCallerStopGate(callerSignal) {
2
+ const verbs = new AbortController();
3
+ return {
4
+ stop: () => verbs.abort(),
5
+ signal: callerSignal !== undefined ? AbortSignal.any([verbs.signal, callerSignal]) : verbs.signal,
6
+ };
7
+ }
@@ -1,5 +1,4 @@
1
1
  import type { MaybeCompactOptions } from "../auto-compaction.js";
2
- import type { TaskSpec } from "../types.js";
3
2
  import type { Prepared, RunnerDepsSeat } from "./contracts.js";
4
3
  /**
5
4
  * The cost-optimization compaction options threaded into BOTH `maybeCompact` call
@@ -13,27 +12,14 @@ import type { Prepared, RunnerDepsSeat } from "./contracts.js";
13
12
  * function itself always returns an object.
14
13
  */
15
14
  export declare function seamCCompactionOptions(runner: RunnerDepsSeat, prepared: Prepared): Pick<MaybeCompactOptions, "summaryProvider" | "onCompaction" | "maxConsecutiveProviderReuse" | "consecutiveProviderReuse" | "onCommitted">;
16
- /** Resolve the pre/postCompact lifecycle callbacks (whole-slot `spec.hooks ??
17
- * deps.hooks`, same resolution as the stop hook) and wrap each in a SWALLOW+TRACE shell before
18
- * threading them into maybeCompact. The wrapper owns the observability half of the R3 MED contract
19
- * (maybeCompact swallows defensively too, but has no sink): a throwing callback is reported via
20
- * `onError(phase:"hook")` and treated as absent; a `block` returned under a "forced" trigger is
21
- * reported as ignored (maybeCompact enforces the ignore — blocking a compaction the provider/trim
22
- * layer already demanded would kill the run). */
23
- export declare function compactionHookOptions(runner: RunnerDepsSeat, spec: TaskSpec, sessionId: string, trigger: "auto" | "manual" | "forced",
24
- /** The leg's identity envelope, spread onto both compaction contexts by the wrappers
25
- * below (the compaction module builds its contexts below the runner and cannot know the leg;
26
- * the wrapper is the runner's seam). Every runner call site supplies `prepared.hookIdentity`;
27
- * optional only so a context built without a leg stays honestly identity-less. */
28
- identity?: import("../hooks.js").HookInvocationIdentity,
29
- /** The leg's already-validated seat bound (`Prepared.hookTimeoutMs`) and its abort signal. Optional
30
- * for the same reason `identity` is — a wrapper built without a prepared leg still works, on the
31
- * default bound and with no signal. The signal is what keeps a hung compaction hook from holding a
32
- * CANCELLED run's turn boundary for the whole deadline (the seat's post-abort grace). */
33
- seatBound?: {
34
- timeoutMs: number;
35
- signal?: AbortSignal;
36
- }): Pick<MaybeCompactOptions, "trigger" | "preCompact" | "postCompact">;
15
+ /** The pre/postCompact stations threaded into maybeCompact: `classic.PreCompact` and `classic.PostCompact` raised on the
16
+ * leg's bus (a station is wired only when a handler hangs on its event). Their failure and abort columns are the
17
+ * bus's — a handler that throws or runs past its budget is skipped and reported, so a failed gate is "no block, no
18
+ * instructions" and the compaction that was already deemed necessary proceeds. A `block` answered under a "forced"
19
+ * trigger is reported as ignored (maybeCompact enforces the ignore — blocking a compaction the provider/trim layer
20
+ * already demanded would kill the run). `signal` is the pass's abort (absent ⇒ each handler's own budget is the
21
+ * whole bound). */
22
+ export declare function compactionHookOptions(runner: RunnerDepsSeat, prepared: Pick<Prepared, "modBus" | "hookIdentity" | "sessionId">, trigger: "auto" | "manual" | "forced", signal: AbortSignal | undefined): Pick<MaybeCompactOptions, "trigger" | "preCompact" | "postCompact">;
37
23
  /** Fold a finished compaction's `reused` flag into the run-scoped consecutive-reuse
38
24
  * counter: a reused (provider) summary increments it, a real (LLM) summary resets it to 0. A no-op
39
25
  * compaction (`compacted:false`) leaves the counter untouched. No-op when no provider is wired. */
@@ -1,5 +1,4 @@
1
- import { hookSeatExpiredError, resolveHookTimeoutMs, runHookSeat } from "../hooks.js";
2
- import { asThrownError } from "../thrown-value.js";
1
+ import { classicEventBase, dispatchClassic, observeClassic, stringMembersAnswer, stringMembersOf } from "../mods/stations.js";
3
2
  export function seamCCompactionOptions(runner, prepared) {
4
3
  return {
5
4
  ...(runner.deps.summaryProvider
@@ -17,66 +16,42 @@ export function seamCCompactionOptions(runner, prepared) {
17
16
  },
18
17
  };
19
18
  }
20
- export function compactionHookOptions(runner, spec, sessionId, trigger, identity, seatBound) {
21
- const hooks = spec.hooks ?? runner.deps.hooks;
22
- const pre = hooks?.preCompact;
23
- const post = hooks?.postCompact;
24
- const seatMs = seatBound?.timeoutMs ?? resolveHookTimeoutMs(hooks?.timeoutMs);
25
- const seatSignal = seatBound?.signal;
26
- const withIdentity = (ctx) => identity !== undefined ? { ...ctx, identity } : ctx;
19
+ export function compactionHookOptions(runner, prepared, trigger, signal) {
20
+ const bus = prepared.modBus;
21
+ const base = classicEventBase(prepared.hookIdentity);
22
+ const report = (err) => {
23
+ try {
24
+ runner.deps.onError?.(err, { phase: "hook", sessionId: prepared.sessionId });
25
+ }
26
+ catch {
27
+ }
28
+ };
27
29
  return {
28
30
  trigger,
29
- ...(pre
31
+ ...(bus.hasHandlers("classic.PreCompact")
30
32
  ? {
31
- preCompact: async (rawCtx) => {
32
- const ctx = withIdentity(rawCtx);
33
- const report = (err) => {
34
- try {
35
- runner.deps.onError?.(err, { phase: "hook", sessionId });
36
- }
37
- catch {
38
- }
39
- };
40
- try {
41
- const seat = await runHookSeat("preCompact", { timeoutMs: seatMs, ...(seatSignal !== undefined ? { signal: seatSignal } : {}) }, (sig) => pre.call(hooks, { ...ctx, signal: sig }));
42
- if (seat.expired) {
43
- report(hookSeatExpiredError("preCompact", seatMs, seat.cause, `the "${ctx.trigger}" compaction PROCEEDED unblocked and with no additional instructions`));
44
- return undefined;
45
- }
46
- const r = seat.value;
47
- if (r?.block && ctx.trigger === "forced") {
48
- report(new Error(`a preCompact callback blocked a "forced" compaction — ignored (PTL/trim-pressure compaction is not optional): ${r.block}`));
49
- }
50
- return r;
51
- }
52
- catch (err) {
53
- report(asThrownError(err));
33
+ preCompact: async (ctx) => {
34
+ const outcome = await dispatchClassic(bus, "classic.PreCompact", { ...base, trigger: ctx.trigger, ...(ctx.customInstructions !== undefined ? { customInstructions: ctx.customInstructions } : {}) }, { ...(signal !== undefined ? { signal } : {}), checkAnswer: stringMembersAnswer("classic.PreCompact", ["block", "additionalInstructions"]) });
35
+ if (outcome?.kind !== "answered")
54
36
  return undefined;
37
+ const r = stringMembersOf(outcome.answer, ["block", "additionalInstructions"]);
38
+ if (r.block && ctx.trigger === "forced") {
39
+ report(new Error(`a preCompact handler blocked a "forced" compaction — ignored (PTL/trim-pressure compaction is not optional): ${r.block}`));
55
40
  }
41
+ return r;
56
42
  },
57
43
  }
58
44
  : {}),
59
- ...(post
45
+ ...(bus.hasHandlers("classic.PostCompact")
60
46
  ? {
61
- postCompact: async (rawCtx) => {
62
- try {
63
- const seat = await runHookSeat("postCompact", { timeoutMs: seatMs, ...(seatSignal !== undefined ? { signal: seatSignal } : {}) }, (sig) => post.call(hooks, { ...withIdentity(rawCtx), signal: sig }));
64
- if (seat.expired) {
65
- try {
66
- runner.deps.onError?.(hookSeatExpiredError("postCompact", seatMs, seat.cause, "the observation was abandoned; the compaction that already landed is unchanged"), { phase: "hook", sessionId });
67
- }
68
- catch {
69
- }
70
- }
71
- }
72
- catch (err) {
73
- try {
74
- runner.deps.onError?.(asThrownError(err), { phase: "hook", sessionId });
75
- }
76
- catch {
77
- }
78
- }
79
- },
47
+ postCompact: (ctx) => observeClassic(bus, "classic.PostCompact", {
48
+ ...base,
49
+ trigger: ctx.trigger,
50
+ summary: ctx.summary,
51
+ ...(ctx.tokensBefore !== undefined ? { tokensBefore: ctx.tokensBefore } : {}),
52
+ ...(ctx.tokensAfter !== undefined ? { tokensAfter: ctx.tokensAfter } : {}),
53
+ ...(ctx.freedTokens !== undefined ? { freedTokens: ctx.freedTokens } : {}),
54
+ }, signal),
80
55
  }
81
56
  : {}),
82
57
  };
@@ -1,8 +1,9 @@
1
1
  import { checkedAgentConfigDir } from "../agent-config-dir.js";
2
2
  import { checkedMediaByteCap } from "../media-byte-cap.js";
3
- import { receiveOwnProperties, refuseProxy } from "../own-property-receipt.js";
3
+ import { receiptRefusal, receiveOwnProperties, refuseProxy } from "../own-property-receipt.js";
4
4
  import { assertNoRetiredRunnerDeps } from "./retired-runner-deps.js";
5
5
  import { copyReadDenySeat, READ_DENY_DEPLOYMENT_SEATS } from "../read-face-seats.js";
6
+ import { holdOwnCredentialValues } from "../secret-env.js";
6
7
  export function retainRunnerDeps(deps) {
7
8
  const words = { subject: "RunnerDeps", unit: "seat", moment: "at new Runner" };
8
9
  refuseProxy(deps, words);
@@ -14,5 +15,14 @@ export function retainRunnerDeps(deps) {
14
15
  if (Object.hasOwn(retained, seat))
15
16
  Object.defineProperty(retained, seat, { value: copyReadDenySeat(Reflect.get(retained, seat)), enumerable: true, writable: true, configurable: true });
16
17
  }
18
+ let consolidationKey;
19
+ try {
20
+ const chat = retained.memoryConsolidationDriver?.chat;
21
+ consolidationKey = typeof chat === "object" && chat !== null ? Reflect.get(chat, "apiKey") : undefined;
22
+ }
23
+ catch {
24
+ throw receiptRefusal("RunnerDeps.memoryConsolidationDriver.chat threw while its apiKey was read at new Runner — refused (the thrown value is not repeated)");
25
+ }
26
+ holdOwnCredentialValues([typeof consolidationKey === "string" ? consolidationKey : undefined], retained.onNotice);
17
27
  return retained;
18
28
  }
@@ -36,7 +36,9 @@ import type { CacheBreakDetector, ToolFingerprintInput } from "../cache-break-de
36
36
  import type { Checkpoint, CheckpointState, CheckpointStore, CheckpointToken, PendingSteerEntry, PlatformLimitReason, ReopenReason, ResourceLedger, ResourceLimitReason, ResumeOutcome, SerializedCheckpointState } from "../checkpoint-store.js";
37
37
  import type { ExecutionOutcomeRecordWord } from "../checkpoint-execution-record.js";
38
38
  import type { ClearedProjectionLedger, MicroCompactMachine, OccurrenceIndex } from "../context-edit.js";
39
- import type { HookInvocationIdentity, Hooks, OrgGateVerdict, PermissionDeniedPayload, PostToolBatchCall, PostToolBatchResult, ToolGateInput } from "../hooks.js";
39
+ import type { ModBus } from "../mods/kernel/index.js";
40
+ import type { LegModBus, LegMods, ModChainLink } from "../mods/stations.js";
41
+ import type { HookInvocationIdentity, OrgGateVerdict, PermissionDeniedPayload, PostToolBatchCall, ToolGateInput } from "../hooks.js";
40
42
  import type { MaterializedMcp } from "../mcp.js";
41
43
  import type { MemoryEngine } from "../memory-engine/engine.js";
42
44
  import type { ResolvedSkillListingBudget } from "../skill-listing-budget.js";
@@ -62,6 +64,7 @@ import type { SessionReadFileStates } from "./session-read-file-states.js";
62
64
  import type { LegModeCeiling, SessionModeSeats } from "./session-mode-seats.js";
63
65
  import type { BlockedRef, OutputRef, SkillListingEntry } from "./synthetic-tools.js";
64
66
  import type { createAttachmentState, WriteFamily } from "./turn-attachments.js";
67
+ import type { SideCallBook } from "./side-call-account.js";
65
68
  import type { cacheFamilyOf } from "./usage-accounting.js";
66
69
  /**
67
70
  * The frozen task-start copies of the caller's tool-face control arrays, as the config-doors phase takes them (synchronously,
@@ -99,6 +102,14 @@ export interface ToolFaceSnapshot {
99
102
  */
100
103
  export interface AnnounceOnceSink {
101
104
  onError: NonNullable<RunnerDeps["onError"]>;
105
+ /**
106
+ * The same operator sink for a fact about the DEPLOYMENT rather than the conversation (a built-in tool pair that
107
+ * declines to mount because of the deployment's own selector or roster): deduplicated per RUNNER by
108
+ * `(code, text)` instead of per session, because a serving layer that opens a fresh session per request would
109
+ * otherwise repeat a standing configuration fact on every request. Independent of the session record — it
110
+ * writes nothing to the transcript. Same signature as `RunnerDeps.onError`.
111
+ */
112
+ onErrorOncePerRunner: NonNullable<RunnerDeps["onError"]>;
102
113
  }
103
114
  /** Static per-tool irreversibility tier, resolved at prepare time by the safety scan. */
104
115
  export type IrreversibilityTier = Map<string, "never" | "maybe" | "always">;
@@ -524,6 +535,8 @@ export interface Prepared {
524
535
  * leg always knows its identity.
525
536
  */
526
537
  hookIdentity: HookInvocationIdentity;
538
+ /** The leg's mods bus: one per leg, admitted at this leg's prepare (both seats, `plugin.register` run once for this leg). Every classic station raises its event on it; its `records` are the manifest's `mods[]`. */
539
+ modBus: ModBus;
527
540
  /**
528
541
  * This session's DURABLE box, present iff this leg mounted the session-box drain (a top-level leg
529
542
  * over a cross-process-safe mailbox with a grammatical session id). The notification lane binds it
@@ -566,38 +579,18 @@ export interface Prepared {
566
579
  peerBoundaryRound?: (o: {
567
580
  continues: boolean;
568
581
  }) => Promise<void>;
569
- /**
570
- * The per-invocation TIME BOUND every hook seat of this leg runs under (`Hooks.timeoutMs`, already
571
- * validated — a garbage value was refused to the default and disclosed ONCE, here, rather than on
572
- * every tool call). Published for the same reason `hookIdentity` is: the seats live in two files, and
573
- * a number each station re-derived would be two answers to one wiring question — including two
574
- * chances to re-refuse the same bad value.
575
- */
576
- hookTimeoutMs: number;
582
+ /** The composition manifest (v3) the `prompt.assembled` frame reports (`trace.ts`, the same member types). */
577
583
  promptManifest: {
578
- constitution: "core" | "replaced" | "provider-assembled";
584
+ identity: import("../trace.js").PromptManifestIdentity;
585
+ selectors: import("../trace.js").PromptManifestSelectors;
579
586
  blocks: Array<{
580
587
  id: string;
581
588
  chars: number;
582
589
  hash: string;
583
590
  }>;
584
- /** Manifest v2 (stage S1, additive): the compiled-IR section view (slot/carrier/cadence/
585
- * cacheClass per section). `contentHash` is the
586
- * digest-tiering face: present ONLY on operator-declared sections (the typed
587
- * `stableBlocks` lane, owner "deployment") as an UNSALTED full sha256 of the section text —
588
- * the center-publish ↔ manifest end-to-end reconciliation anchor. Core-native sections (env
589
- * facts, memory tail, user role text) stay salted-only: a plain hash of a short guessable
590
- * block is a dictionary-preimage surface for trace readers ([E]). */
591
- sections?: Array<{
592
- id: string;
593
- slot: string;
594
- carrier: string;
595
- cadence: string;
596
- cacheClass: string;
597
- chars: number;
598
- hash: string;
599
- contentHash?: string;
600
- }>;
591
+ sections: import("../trace.js").PromptManifestSection[];
592
+ /** Each overlay the composition superseded; absent when none was. */
593
+ superseded?: import("../../prompt-assembly/overlay.js").SupersededOverlay[];
601
594
  /** S2 (additive): the mounted tools plane — contract identity, durable-replay aliases,
602
595
  * presentation-invariant shape digest and full wire digest per tool (initial mount face). */
603
596
  tools?: ToolManifestRow[];
@@ -615,26 +608,18 @@ export interface Prepared {
615
608
  * seat chose it. Absent when nothing is deferred (there is no disclosure to describe). */
616
609
  toolDisclosure?: ToolDisclosureManifest;
617
610
  };
618
- /** This run's provider-declared prompt sections (epoch declaration axis),
619
- * threaded to every compaction-boundary epoch selection so boundary re-pins hash the same
620
- * artifact identity as the prepare-time pin. Empty on declaration-free runs. */
621
- epochDeclaredSections: import("../../prompt-assembly/epoch.js").EpochDeclaredSections;
611
+ /** This run's prompt identity inputs and its pinned center layer's provenance, threaded to every compaction-boundary
612
+ * epoch selection so a boundary restates the same identity the prepare-time record names. Replaced by a committed
613
+ * compaction-boundary center change. */
614
+ promptIdentity: import("../../prompt-assembly/epoch.js").RunPromptIdentity;
622
615
  /** The LIVE nine-element identity face (refreshed by deferred materialization and
623
616
  * the deferred-materialization adoption swap); the manifest holds the prepare-time initial copy. */
624
617
  turnSnapshot?: import("../../prompt-assembly/turn-snapshot.js").TurnPromptSnapshot;
625
- /** The compaction-boundary center-adoption seam (undefined = no source
626
- * wired or session not center-pinned). Returns the maybeCompact `centerAdoption` fragment or
627
- * undefined; `apply` runs post-CAS only (auto-compaction owns the ordering). Both
628
- * `epochDeclaredSections` and `promptOverheadTokens` on THIS object are mutated by a successful
629
- * adoption (read them at call time, never capture early). */
630
- centerCompactionCandidate?: () => {
631
- centerArtifactDigest?: string;
632
- sourceRevision?: string;
633
- clear?: true;
634
- declaredSections: import("../../prompt-assembly/epoch.js").EpochDeclaredSections;
635
- overheadTokensAfter: number;
636
- apply: (committedArtifactDigest?: string) => void;
637
- } | undefined;
618
+ /** The compaction-boundary center-layer seam (undefined = no source wired, or a child run — a child composes its
619
+ * parent's layer). Returns the maybeCompact `centerAdoption` fragment or undefined; `apply` runs post-CAS only
620
+ * (auto-compaction owns the ordering). Both `promptIdentity` and `promptOverheadTokens` on THIS object are mutated by
621
+ * a successful change (read them at call time, never capture early). */
622
+ centerCompactionCandidate?: () => NonNullable<import("../auto-compaction.js").MaybeCompactOptions["centerAdoption"]> | undefined;
638
623
  /** Deferred-tool disclosure: the monotonic set of activated deferred-tool names. Empty
639
624
  * (and no `tool_search` injected) when nothing is deferred. Mutated by BOTH disclosure lanes across
640
625
  * the run — the injected `tool_search` and the direct-call placeholder lane (default ON) —
@@ -924,6 +909,12 @@ export interface Prepared {
924
909
  walltimeMs: number;
925
910
  };
926
911
  };
912
+ /** The cell the run body binds with the leg's side-call door once `stats` exists; a lane built at prepare (the
913
+ * permission classifier) books its replies through it. A lane that books before the run body bound it is an
914
+ * engine defect and throws. */
915
+ sideCallBookRef: {
916
+ book?: SideCallBook;
917
+ };
927
918
  /** The per-task human-review accumulator (synchronous `resolveAsk` waits this leg + the carried
928
919
  * prior-leg burden seeded from the resumed checkpoint). The run loop ADDS the durable-resume latency
929
920
  * (`now() − cp.suspendedAt`) on a resume, then surfaces it as `stats.humanReview` at assembly (omitted when
@@ -1323,6 +1314,9 @@ export interface PrepareResume {
1323
1314
  /** The decision this resume carries (the gate word and, for a review, approve / edit / reject) — read by the mode seed
1324
1315
  * (`modeRequestAfterResume`: an approved or edited `plan_review` exits a recorded plan to its pre-plan word). Absent on a prepare that resumes nothing. */
1325
1316
  outcome?: ResumeRun["outcome"];
1317
+ /** The leg's mods bus, when the resume entrance already admitted it (a wake message's screen raises
1318
+ * `classic.UserPromptSubmit` before this leg prepares): prepare adopts it instead of admitting a second time. */
1319
+ legMods?: LegMods;
1326
1320
  /** How many times this task already suspended (the resumed checkpoint's
1327
1321
  * `suspendCount`). The next suspend mints `priorSuspendCount + 1`; past `maxSuspends` it fails
1328
1322
  * (`suspend.loop`) instead of re-suspending. Absent/0 ⇒ no prior suspends. */
@@ -1544,24 +1538,23 @@ export interface InheritedGate extends InheritedAutoModeFace {
1544
1538
  };
1545
1539
  };
1546
1540
  /**
1547
- * Set ONLY on an entry whose `policy` is the folded form of an ancestor's PreToolUse screening face
1548
- * (issue #33 — the face used to stop at the task that installed it, so a call the ancestor had
1549
- * refused executed one level down). It carries the raw callback for ONE purpose: identity. A
1550
- * deployment-level face (`RunnerDeps.hooks`) is resolved by every task in the tree on its own, so
1551
- * each descendant's gate already runs it in phase 1 — folding it AGAIN as an inherited constraint
1552
- * would consult the same callback twice per call at depth 1 and once more per level below. Two
1553
- * identity tests keep that at exactly one consultation per call: chain assembly does not re-append a
1554
- * face already on the chain, and a descendant substitutes a pass-through for the entry naming the
1555
- * very callback its own gate will run. A per-task face (`TaskSpec.hooks`) is a different function in
1556
- * the descendant (or absent), so it folds and travels.
1541
+ * Set by the constraint mint's caller on an entry whose `policy` is the folded form of an ancestor's
1542
+ * `classic.PreToolUse` chain (`createPreToolUseConstraintPolicy`): the chain that leg's admission MOUNTED, as the
1543
+ * entry declares it. It is read for ONE thing — a declaration that this entry carries a chain: beside a policy the
1544
+ * mint did not make, a declared judging `tool.check` handler is refused (`config.mods_invalid`; the guard has no bus to
1545
+ * be raised on), and such an entry is never treated as a caller policy (it licenses no ask grant). It is NEVER the
1546
+ * entry's identity: the chain an entry stands for is read off the bus its policy was minted over (that bus's admission
1547
+ * recorded it), so a host may hand any list here (`[]` included, or none) without moving what is judged.
1557
1548
  *
1558
- * Identity is the only sound test here, and it is deliberately the CONSERVATIVE one: an assembly that
1559
- * hands each task a freshly bound wrapper over one underlying callback (the `runSpec` mux does this)
1560
- * produces two distinct function objects, so the descendant both folds the ancestor's entry and runs
1561
- * its own — the callback is consulted twice rather than skipped. Erring toward a second screening,
1562
- * never toward a missed one, is what makes an identity miss a cost rather than a hole.
1549
+ * The identity (`sameInstallation`) is that chain plus the context the entry's questions are settled in — the frozen
1550
+ * approver, the two durable mandates, the environment, the classifier instance — and it is the CONSERVATIVE test:
1551
+ * two chains over the same registrations in a different order, or a re-built registration object, compare unequal,
1552
+ * and a bus no engine admission mounted is no leg's installation. Chain assembly does not re-append a leg already on
1553
+ * the chain; a descendant's own gate stands in for an entry only when that identity holds under no mandate (the
1554
+ * pass-through of its `classic.PreToolUse`, the skip of its `tool.check`); any other entry is judged on both events
1555
+ * under its own context — judged twice rather than skipped, never toward a missed one.
1563
1556
  */
1564
- preToolUse?: Hooks["preToolUse"];
1557
+ mods?: readonly ModChainLink[];
1565
1558
  /**
1566
1559
  * The environment this screening face was installed against — the source of the `HookEnvCapabilities`
1567
1560
  * handed to it, compared BY REFERENCE, `undefined` when the installation had no env face. Part of the
@@ -1646,14 +1639,21 @@ export interface RunInternals {
1646
1639
  */
1647
1640
  toolCeiling?: readonly import("../tool-face.js").ToolSelectorLayer[];
1648
1641
  /** Set by the delegation lane when the spawning run's prepare judged this leg's own tool lists (its spec's `allowTools` /
1649
- * `excludeTools` — a definition's or the delegation tool's) where they were mounted: their digest (`toolListsDigest`), the evidence
1650
- * bound to exactly those lists. A prepare whose own lists digest to it does not judge them again against its own, narrower universe,
1651
- * and its rows record it (`CheckpointState.toolListsJudged`) so a resume that hands no internals keeps the judgment. Absent (a
1652
- * workflow agent, a team member, a host's direct `runTask`), or lists that digest differently ⇒ the leg judges its own lists. */
1642
+ * `excludeTools` — a definition's or the delegation tool's) against a pool it could list: their digest (`toolListsDigest`), the
1643
+ * evidence bound to exactly those lists. A prepare whose own lists digest to it does not judge them again, and its rows record it
1644
+ * (`CheckpointState.toolListsJudged`) so a resume that hands no internals keeps the judgment. Absent (a delegation tool whose pool
1645
+ * cannot be listed, a workflow agent, a team member, a host's direct `runTask`), or lists that digest differently ⇒ the leg judges its own lists. */
1653
1646
  toolListsJudged?: string;
1654
- /** Set by the delegation lane: whose lists this leg's own are (`delegationListWhere` — the agent definition it was spawned as, or the
1655
- * delegation tool's tool-level list), so a refusal at the leg's prepare names the list to fix. Absent ⇒ the leg's own `TaskSpec` seats. */
1656
- ownToolListsWhere?: string;
1647
+ /** Set by the delegation lane: whose lists this leg's own are — the delegation tool that spawned it (its declared name, its mounted one), the
1648
+ * agent definition it was spawned as (absent ⇒ the tool's tool-level list) and `lists`, the digest of exactly the lists it wrote. A refusal
1649
+ * at the leg's prepare names that list (`delegationListWhere`), and the tool's name is a name of this leg's lineage: its own lists are
1650
+ * asked of a universe that carries it. Held only for the lists it wrote ({@link boundOwnToolLists}): other lists are the host's own
1651
+ * `TaskSpec` seats. Absent ⇒ no delegation tool behind the leg's own `TaskSpec` seats. */
1652
+ ownToolLists?: {
1653
+ readonly toolName: string;
1654
+ readonly definition?: string;
1655
+ readonly lists: string;
1656
+ };
1657
1657
  /** Set only on an observer sidecar's legs: the leg kind whose protocol is the observer's report tool. */
1658
1658
  observerLeg?: true;
1659
1659
  /** The live repair bundle from a `runRepairLoop` attempt in flight (attemptCount>0). Serialized onto a
@@ -2647,6 +2647,8 @@ export interface ResumeRun {
2647
2647
  * §4.3-3 reserves for the cross-process parked leg). Present only when a wake message passed a
2648
2648
  * screen that supplied context. */
2649
2649
  wakeMessageHookContext?: string;
2650
+ /** The resumed leg's bus when the wake-message screen admitted it before the claim — prepare adopts it. */
2651
+ legMods?: LegMods;
2650
2652
  /** Compensation hook: called iff the resumed run fails with `resume.env_failed` (post-CAS
2651
2653
  * workspace `resumeVM` failed) OR `resume.tool_unavailable` (P-7: the approved tool vanished) — in both
2652
2654
  * the CAS already consumed the checkpoint but the pending action never ran. `resumeStream` supplies a
@@ -2695,11 +2697,12 @@ export interface SuspendReap {
2695
2697
  export interface TurnBoundaryDeps {
2696
2698
  spec: TaskSpec;
2697
2699
  queue: PushQueue<TaskEvent>;
2698
- /** The run loop's own latch — read for `userHalted` (the public `TaskStream.halt()` verb, which sets
2699
- * the harness stop latch directly, not through the ctx primitive `Prepared.stopRequestedRef`
2700
- * mirrors): a halted boundary has no next request either, so the bundle is not collected there. */
2700
+ /** The run loop's own latch — read for `userHalted` (the `TaskStream.halt()` verb sets the harness stop latch directly,
2701
+ * not through the ctx primitive `Prepared.stopRequestedRef` mirrors: a halted boundary has no next request either, so
2702
+ * the bundle is not collected there) and for `callerStop`, the gate the boundary's compaction pass admits on and carries. */
2701
2703
  loopLatch: {
2702
2704
  readonly userHalted: boolean;
2705
+ readonly callerStop: import("./caller-stop-gate.js").CallerStopGate;
2703
2706
  };
2704
2707
  manualCompactRef: {
2705
2708
  requested: boolean;
@@ -2722,9 +2725,8 @@ export interface TurnBoundaryDeps {
2722
2725
  parentToolCallId?: string;
2723
2726
  sourceTaskId?: string;
2724
2727
  };
2725
- postToolBatchHook: ((batch: PostToolBatchCall[], meta?: {
2726
- injectedThisTurn: "final_verification" | "finalize";
2727
- }, ctx?: import("../hooks.js").PostToolBatchContext) => PostToolBatchResult | undefined | Promise<PostToolBatchResult | undefined>) | undefined;
2728
+ /** Whether a handler hangs on `classic.PostToolBatch` (the batch is collected only then). */
2729
+ postToolBatchArmed: boolean;
2728
2730
  batchArgs: Map<string, unknown> | undefined;
2729
2731
  compactionBrain: Brain;
2730
2732
  withinTaskCompaction: () => boolean;
@@ -2784,9 +2786,8 @@ export interface HarnessHandlersDeps {
2784
2786
  toolProgress: ToolProgressLane;
2785
2787
  writeFamilyOf: (name: string) => WriteFamily | undefined;
2786
2788
  toolLabels: Map<string, string>;
2787
- postToolBatchHook: ((batch: PostToolBatchCall[], meta?: {
2788
- injectedThisTurn: "final_verification" | "finalize";
2789
- }, ctx?: import("../hooks.js").PostToolBatchContext) => PostToolBatchResult | undefined | Promise<PostToolBatchResult | undefined>) | undefined;
2789
+ /** Whether a handler hangs on `classic.PostToolBatch` (the batch is collected only then). */
2790
+ postToolBatchArmed: boolean;
2790
2791
  batchArgs: Map<string, unknown> | undefined;
2791
2792
  runnerHooks: {
2792
2793
  onError: RunnerDeps["onError"];
@@ -2841,10 +2842,9 @@ export interface RunnerSelfSeat {
2841
2842
  * against the catalog in force): prepare hands its leg a call-time reader over it, because this is the one seat a
2842
2843
  * running leg re-reads (geometry, not route — see `context-settings.ts`). */
2843
2844
  contextOverlayOf?(ref: import("../model-seat.js").ModelRef | undefined): import("../context-settings.js").ContextWindowOverlay | undefined;
2844
- /** The deployment-level gating baseline (deps toolPolicy / hooks) as delegate wrappers — for assemblers that compose with it. */
2845
+ /** The deployment-level gating baseline (deps toolPolicy) as a delegate wrapper — for assemblers that compose with it. */
2845
2846
  readonly gateBaseline: {
2846
2847
  toolPolicy?: RunnerDeps["toolPolicy"];
2847
- hooks?: RunnerDeps["hooks"];
2848
2848
  };
2849
2849
  /** Whether a child task THIS runner runs can be placed in a tree other than the caller's (an explicit cwd, a worktree):
2850
2850
  * true only when its deps carry an `executionEnvFactory` (live read — `swapDeps` replaces the deps). The delegation tool asks
@@ -2883,10 +2883,10 @@ export type PrepareTaskFn = (spec: TaskSpec, deps: RunnerDeps, sessions: Session
2883
2883
  */
2884
2884
  export interface InstallingPhaseResult {
2885
2885
  }
2886
- /** The live-task handle `runLocked` publishes once the harness exists: the harness + abort
2887
- * controller, the loop-liveness latch (`ended` flips when the single `harness.prompt` settles; `userInterrupted`
2888
- * / `userHalted` are the interrupt and halt verbs' attribution seats), the run's reminder mark, its session and
2889
- * engine-minted run id, and the hook bound + identity envelope the steer entrance screen runs under. */
2886
+ /** The live-task handle `runLocked` publishes once the harness exists: the harness + abort controller, the loop latch
2887
+ * (`ended` flips when the single `harness.prompt` settles; `userInterrupted` / `userHalted` are the interrupt and halt
2888
+ * verbs' attribution seats; `callerStop` is the run's caller-stop gate the three stop verbs trip), the run's reminder
2889
+ * mark, its session and engine-minted run id, and the bus + identity envelope the steer entrance screen runs on. */
2890
2890
  export interface LiveHandle {
2891
2891
  harness: AgentHarness;
2892
2892
  abortController: AbortController;
@@ -2894,13 +2894,15 @@ export interface LiveHandle {
2894
2894
  ended: boolean;
2895
2895
  userInterrupted: boolean;
2896
2896
  userHalted: boolean;
2897
+ callerStop: import("./caller-stop-gate.js").CallerStopGate;
2897
2898
  };
2898
2899
  reminderMark: string;
2899
2900
  sessionId: string;
2900
2901
  /** The run body's engine-minted run id, so the stream-layer verbs can name the run their disclosures are about. */
2901
2902
  runId: string;
2902
- hookTimeoutMs: number;
2903
2903
  hookIdentity: HookInvocationIdentity;
2904
+ /** The leg's mods bus (the steer entrance raises `classic.UserPromptSubmit` on it). */
2905
+ modBus: LegModBus;
2904
2906
  /** The leg's live permission-mode seat (`TaskStream.setPermissionMode` steers it). */
2905
2907
  permissionMode: PermissionModeController;
2906
2908
  }
@@ -2936,6 +2938,7 @@ export interface ManualCompactRef {
2936
2938
  */
2937
2939
  export type EndOfTaskCompaction = {
2938
2940
  compacted: boolean;
2941
+ pass?: string;
2939
2942
  tokensBefore?: number;
2940
2943
  freedTokens?: number;
2941
2944
  triggerTokens?: number;
@@ -0,0 +1,2 @@
1
+ import type { NoticeSeatInput } from "./notice-seat-input.js";
2
+ export declare function createCredentialOriginRefusalScope({ onNotice, sessionId, runId }: NoticeSeatInput): <T>(fn: () => Promise<T>) => Promise<T>;
@@ -0,0 +1,19 @@
1
+ import { runWithCredentialOriginRefusals } from "../../brain/status-sink.js";
2
+ import { deliverEngineNotice } from "../engine-notice.js";
3
+ export function createCredentialOriginRefusalScope({ onNotice, sessionId, runId }) {
4
+ const announced = new Set();
5
+ return (fn) => runWithCredentialOriginRefusals(({ modelId, boundOrigin, requestOrigin }) => {
6
+ const key = `${modelId}\u0000${boundOrigin}\u0000${requestOrigin}`;
7
+ if (announced.has(key))
8
+ return;
9
+ announced.add(key);
10
+ deliverEngineNotice(onNotice, {
11
+ code: "route.credential_origin_mismatch",
12
+ message: `A request for model "${modelId}" was not sent: the model's own credential belongs to ${boundOrigin}, the host it was ` +
13
+ `first sent to, and this request was going to ${requestOrigin}. A credential does not follow its model to another host — ` +
14
+ `the deployment has to give the model a credential for ${requestOrigin} (or point it back at ${boundOrigin}). ` +
15
+ `Said once per run for this model and these two hosts.`,
16
+ detail: { modelId, boundOrigin, requestOrigin, sessionId, runId },
17
+ });
18
+ }, fn);
19
+ }
@@ -1,8 +1,4 @@
1
- import type { EngineNotice } from "../engine-notice.js";
1
+ import type { NoticeSeatInput } from "./notice-seat-input.js";
2
2
  /** Where the announcement goes and whom it is attributed to — the same triple as the sibling `route.*` seats. */
3
- export interface ExtraBodyDroppedSeatInput {
4
- onNotice: ((notice: EngineNotice) => void) | undefined;
5
- sessionId: string;
6
- runId: string;
7
- }
3
+ export type ExtraBodyDroppedSeatInput = NoticeSeatInput;
8
4
  export declare function createExtraBodyDroppedScope({ onNotice, sessionId, runId }: ExtraBodyDroppedSeatInput): <T>(fn: () => Promise<T>) => Promise<T>;