@sema-agent/core 7.51.2 → 7.52.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 (363) hide show
  1. package/CHANGELOG.md +504 -2
  2. package/dist/agents/agent-transcript-tool.d.ts +1 -1
  3. package/dist/agents/cascade.js +4 -0
  4. package/dist/agents/cumulative-stats.d.ts +3 -0
  5. package/dist/agents/cumulative-stats.js +3 -0
  6. package/dist/agents/list-agents-tool.d.ts +1 -1
  7. package/dist/agents/read-inbox-tool.d.ts +1 -1
  8. package/dist/agents/repair-loop.js +4 -0
  9. package/dist/agents/send-message-tool.d.ts +11 -16
  10. package/dist/agents/send-message-tool.js +11 -13
  11. package/dist/agents/subagent.js +6 -4
  12. package/dist/agents/tool-filter.d.ts +40 -13
  13. package/dist/agents/tool-filter.js +28 -14
  14. package/dist/bench/metrics.d.ts +1 -0
  15. package/dist/brain/anthropic.js +16 -12
  16. package/dist/brain/model-presets.d.ts +4 -5
  17. package/dist/brain/model-presets.js +4 -4
  18. package/dist/brain/open-responses.js +16 -12
  19. package/dist/brain/openai.js +16 -12
  20. package/dist/brain/request-params.d.ts +12 -33
  21. package/dist/brain/request-params.js +5 -2
  22. package/dist/brain/request-route.d.ts +9 -8
  23. package/dist/brain/request-route.js +1 -0
  24. package/dist/brain/route-adjudicator.d.ts +117 -47
  25. package/dist/brain/route-adjudicator.js +171 -42
  26. package/dist/brain/route-conformance.js +2 -2
  27. package/dist/brain/status-sink.d.ts +18 -0
  28. package/dist/brain/status-sink.js +7 -0
  29. package/dist/core/allow-entry.d.ts +40 -8
  30. package/dist/core/allow-entry.js +23 -16
  31. package/dist/core/auto-compaction.d.ts +23 -20
  32. package/dist/core/auto-compaction.js +37 -16
  33. package/dist/core/auto-promote.d.ts +2 -1
  34. package/dist/core/auto-promote.js +2 -2
  35. package/dist/core/caller-tool-name.d.ts +9 -0
  36. package/dist/core/caller-tool-name.js +13 -0
  37. package/dist/core/checkpoint-requirements.d.ts +7 -1
  38. package/dist/core/checkpoint-requirements.js +2 -0
  39. package/dist/core/checkpoint-store.d.ts +36 -12
  40. package/dist/core/checkpoint-store.js +1 -1
  41. package/dist/core/child-clamp-seats.d.ts +6 -0
  42. package/dist/core/child-clamp-seats.js +2 -1
  43. package/dist/core/credential-vocabulary.d.ts +33 -8
  44. package/dist/core/credential-vocabulary.js +32 -7
  45. package/dist/core/decision-receipt.d.ts +2 -2
  46. package/dist/core/delegation-frames.d.ts +9 -2
  47. package/dist/core/delegation-name.d.ts +18 -0
  48. package/dist/core/delegation-name.js +47 -0
  49. package/dist/core/engine-capabilities.d.ts +8 -1
  50. package/dist/core/engine-capabilities.js +1 -1
  51. package/dist/core/engine-notice.d.ts +36 -19
  52. package/dist/core/frontmatter-fence.d.ts +10 -0
  53. package/dist/core/frontmatter-fence.js +6 -0
  54. package/dist/core/gate-fold.js +5 -23
  55. package/dist/core/gate-lanes.js +356 -270
  56. package/dist/core/governance-codes.d.ts +9 -4
  57. package/dist/core/governance-codes.js +9 -3
  58. package/dist/core/hooks.d.ts +276 -734
  59. package/dist/core/hooks.js +97 -192
  60. package/dist/{tools/fs → core}/image-admission.d.ts +21 -3
  61. package/dist/{tools/fs → core}/image-admission.js +24 -6
  62. package/dist/core/mcp-connection-pool.d.ts +4 -1
  63. package/dist/core/mcp-connection-pool.js +7 -2
  64. package/dist/core/mcp-probe.d.ts +12 -9
  65. package/dist/core/mcp-probe.js +2 -2
  66. package/dist/core/mcp-server-spec.d.ts +16 -0
  67. package/dist/core/mcp.d.ts +11 -7
  68. package/dist/core/mcp.js +11 -5
  69. package/dist/core/memory-engine/data-plane.js +5 -1
  70. package/dist/core/memory-engine/distiller.js +16 -2
  71. package/dist/core/memory-engine/engine.d.ts +8 -11
  72. package/dist/core/memory-engine/engine.js +9 -5
  73. package/dist/core/memory-engine/frontmatter.d.ts +6 -0
  74. package/dist/core/memory-engine/frontmatter.js +19 -16
  75. package/dist/core/memory.d.ts +2 -2
  76. package/dist/core/mode-policy.d.ts +4 -0
  77. package/dist/core/mode-policy.js +7 -5
  78. package/dist/core/model-seat.d.ts +4 -1
  79. package/dist/core/mods/dollar.d.ts +109 -0
  80. package/dist/core/mods/dollar.js +154 -0
  81. package/dist/core/mods/host.d.ts +23 -0
  82. package/dist/core/mods/host.js +21 -0
  83. package/dist/core/mods/kernel/budget.d.ts +43 -0
  84. package/dist/core/mods/kernel/budget.js +83 -0
  85. package/dist/core/mods/kernel/dispatch.d.ts +100 -0
  86. package/dist/core/mods/kernel/dispatch.js +701 -0
  87. package/dist/core/mods/kernel/events.d.ts +242 -0
  88. package/dist/core/mods/kernel/events.js +210 -0
  89. package/dist/core/mods/kernel/index.d.ts +6 -0
  90. package/dist/core/mods/kernel/index.js +5 -0
  91. package/dist/core/mods/kernel/receive.d.ts +65 -0
  92. package/dist/core/mods/kernel/receive.js +123 -0
  93. package/dist/core/mods/kernel/registration.d.ts +131 -0
  94. package/dist/core/mods/kernel/registration.js +102 -0
  95. package/dist/core/mods/kernel/site-rules.d.ts +84 -0
  96. package/dist/core/mods/kernel/site-rules.js +104 -0
  97. package/dist/core/mods/stations.d.ts +350 -0
  98. package/dist/core/mods/stations.js +444 -0
  99. package/dist/core/own-property-receipt.js +11 -23
  100. package/dist/core/parent-spec-seat.d.ts +18 -7
  101. package/dist/core/parent-spec-seat.js +6 -2
  102. package/dist/core/path-identity.js +2 -1
  103. package/dist/core/permission-rule-syntax.d.ts +15 -0
  104. package/dist/core/permission-rule-syntax.js +24 -16
  105. package/dist/core/permission-rules.d.ts +7 -1
  106. package/dist/core/permission-rules.js +26 -15
  107. package/dist/core/prompt-section-seat.d.ts +15 -27
  108. package/dist/core/prompt-section-seat.js +73 -40
  109. package/dist/core/protocol-http-auth.d.ts +3 -1
  110. package/dist/core/protocol-http-auth.js +2 -0
  111. package/dist/core/reminder-mint.d.ts +2 -2
  112. package/dist/core/remote-env.d.ts +24 -12
  113. package/dist/core/remote-env.js +1 -0
  114. package/dist/core/resume-startup-cause.d.ts +16 -1
  115. package/dist/core/resume-startup-cause.js +4 -1
  116. package/dist/core/retired-keys.d.ts +4 -0
  117. package/dist/core/retired-keys.js +3 -0
  118. package/dist/core/runner/announce-once-ledger.d.ts +31 -1
  119. package/dist/core/runner/announce-once-ledger.js +22 -0
  120. package/dist/core/runner/assemble-result.d.ts +9 -0
  121. package/dist/core/runner/assemble-result.js +3 -1
  122. package/dist/core/runner/call-hook-stations.d.ts +23 -27
  123. package/dist/core/runner/call-hook-stations.js +58 -42
  124. package/dist/core/runner/caller-stop-gate.d.ts +25 -0
  125. package/dist/core/runner/caller-stop-gate.js +7 -0
  126. package/dist/core/runner/compaction-seams.d.ts +8 -22
  127. package/dist/core/runner/compaction-seams.js +28 -53
  128. package/dist/core/runner/construction-doors.js +11 -1
  129. package/dist/core/runner/contracts.d.ts +85 -83
  130. package/dist/core/runner/credential-origin-seat.d.ts +2 -0
  131. package/dist/core/runner/credential-origin-seat.js +19 -0
  132. package/dist/core/runner/extra-body-dropped-seat.d.ts +2 -6
  133. package/dist/core/runner/gate-exit.d.ts +47 -36
  134. package/dist/core/runner/gate-exit.js +8 -2
  135. package/dist/core/runner/image.js +1 -2
  136. package/dist/core/runner/inline-image.js +1 -1
  137. package/dist/core/runner/notice-seat-input.d.ts +11 -0
  138. package/dist/core/runner/notice-seat-input.js +1 -0
  139. package/dist/core/runner/person-path-rows.js +1 -0
  140. package/dist/core/runner/prepare-acquire-reconcile.js +5 -1
  141. package/dist/core/runner/prepare-ask-lane.d.ts +5 -7
  142. package/dist/core/runner/prepare-ask-lane.js +6 -15
  143. package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -2
  144. package/dist/core/runner/prepare-caps-and-workflow.js +25 -8
  145. package/dist/core/runner/prepare-config-doors.d.ts +5 -0
  146. package/dist/core/runner/prepare-config-doors.js +9 -0
  147. package/dist/core/runner/prepare-defer-classify.js +3 -4
  148. package/dist/core/runner/prepare-gate-stations.d.ts +8 -11
  149. package/dist/core/runner/prepare-gate-stations.js +11 -10
  150. package/dist/core/runner/prepare-inherited-gate.d.ts +8 -12
  151. package/dist/core/runner/prepare-inherited-gate.js +8 -21
  152. package/dist/core/runner/prepare-memory-engine-session.js +1 -1
  153. package/dist/core/runner/prepare-park-ask.js +10 -14
  154. package/dist/core/runner/prepare-policy-chain.d.ts +17 -15
  155. package/dist/core/runner/prepare-policy-chain.js +95 -100
  156. package/dist/core/runner/prepare-project-context.js +7 -10
  157. package/dist/core/runner/prepare-prompt-assembly.d.ts +45 -40
  158. package/dist/core/runner/prepare-prompt-assembly.js +134 -101
  159. package/dist/core/runner/prepare-prompt-inputs.d.ts +18 -19
  160. package/dist/core/runner/prepare-prompt-inputs.js +5 -7
  161. package/dist/core/runner/prepare-protocol-tools.d.ts +6 -4
  162. package/dist/core/runner/prepare-protocol-tools.js +2 -2
  163. package/dist/core/runner/prepare-safety-scan.js +6 -10
  164. package/dist/core/runner/prepare-suspend-saga.d.ts +6 -0
  165. package/dist/core/runner/prepare-suspend-saga.js +7 -5
  166. package/dist/core/runner/prepare-task.js +33 -15
  167. package/dist/core/runner/prepare-turn-wiring.d.ts +13 -15
  168. package/dist/core/runner/prepare-turn-wiring.js +29 -27
  169. package/dist/core/runner/prepare-wiring-manifest.d.ts +5 -6
  170. package/dist/core/runner/prepare-wiring-manifest.js +7 -7
  171. package/dist/core/runner/resume-apply.d.ts +5 -2
  172. package/dist/core/runner/resume-apply.js +24 -42
  173. package/dist/core/runner/resume-checkpoint-screen.d.ts +1 -0
  174. package/dist/core/runner/resume-checkpoint-screen.js +9 -1
  175. package/dist/core/runner/resume-preflight.js +38 -16
  176. package/dist/core/runner/retired-runner-deps.js +3 -1
  177. package/dist/core/runner/run-brain-sinks.d.ts +3 -2
  178. package/dist/core/runner/run-brain-sinks.js +5 -1
  179. package/dist/core/runner/run-compaction-machinery.d.ts +7 -1
  180. package/dist/core/runner/run-compaction-machinery.js +7 -33
  181. package/dist/core/runner/run-harness-handlers.js +4 -2
  182. package/dist/core/runner/run-identity-wiring.d.ts +3 -1
  183. package/dist/core/runner/run-identity-wiring.js +3 -2
  184. package/dist/core/runner/run-leg.js +62 -84
  185. package/dist/core/runner/run-notification-lane.js +1 -0
  186. package/dist/core/runner/run-recovery-lanes.d.ts +3 -0
  187. package/dist/core/runner/run-recovery-lanes.js +11 -10
  188. package/dist/core/runner/run-settle-and-teardown.js +9 -28
  189. package/dist/core/runner/run-stop-and-final-verify.js +18 -25
  190. package/dist/core/runner/run-terminal-adoption.d.ts +3 -0
  191. package/dist/core/runner/run-terminal-adoption.js +33 -22
  192. package/dist/core/runner/run-tool-mount-facts.js +5 -3
  193. package/dist/core/runner/run-turn-boundary.js +23 -34
  194. package/dist/core/runner/runtask.d.ts +6 -7
  195. package/dist/core/runner/runtask.js +14 -72
  196. package/dist/core/runner/session-rule-policy.d.ts +5 -5
  197. package/dist/core/runner/session-rule-policy.js +13 -8
  198. package/dist/core/runner/side-call-account.d.ts +68 -0
  199. package/dist/core/runner/side-call-account.js +61 -0
  200. package/dist/core/runner/stream-halt-verbs.js +12 -17
  201. package/dist/core/runner/stream-lifecycle-verbs.js +8 -5
  202. package/dist/core/runner/stream-steer-verb.d.ts +1 -1
  203. package/dist/core/runner/stream-steer-verb.js +20 -38
  204. package/dist/core/runner/sub-agent-deny-lists.d.ts +121 -22
  205. package/dist/core/runner/sub-agent-deny-lists.js +228 -71
  206. package/dist/core/runner/tool-end-body.d.ts +5 -6
  207. package/dist/core/runner/tool-end-body.js +6 -4
  208. package/dist/core/runner/tool-not-executed.d.ts +15 -0
  209. package/dist/core/runner/tool-not-executed.js +30 -0
  210. package/dist/core/runner/tool-occurrence.d.ts +8 -7
  211. package/dist/core/runner/tool-occurrence.js +5 -5
  212. package/dist/core/runner/tool-result-media-seat.d.ts +1 -1
  213. package/dist/core/runner-deps.d.ts +20 -28
  214. package/dist/core/safety-merge-corpus.js +18 -2
  215. package/dist/core/secret-env.d.ts +88 -20
  216. package/dist/core/secret-env.js +192 -38
  217. package/dist/core/session-policy-store.d.ts +52 -16
  218. package/dist/core/session-policy-store.js +118 -28
  219. package/dist/core/session-reconcile.d.ts +4 -0
  220. package/dist/core/session-reconcile.js +2 -1
  221. package/dist/core/shell-read-silence.js +3 -32
  222. package/dist/core/side-query.d.ts +5 -3
  223. package/dist/core/skill-grant.d.ts +3 -2
  224. package/dist/core/skill-grant.js +17 -9
  225. package/dist/core/skills-directory.d.ts +31 -11
  226. package/dist/core/skills-directory.js +655 -104
  227. package/dist/core/task-event.d.ts +13 -3
  228. package/dist/core/task-result.d.ts +8 -0
  229. package/dist/core/task-spec.d.ts +20 -19
  230. package/dist/core/task-stream.d.ts +14 -4
  231. package/dist/core/tighten-task-spec.d.ts +4 -3
  232. package/dist/core/tighten-task-spec.js +2 -4
  233. package/dist/core/tool-check-reading.d.ts +74 -0
  234. package/dist/core/tool-check-reading.js +80 -0
  235. package/dist/core/tool-policy.d.ts +59 -18
  236. package/dist/core/tool-policy.js +77 -12
  237. package/dist/core/tool-registry.d.ts +20 -0
  238. package/dist/core/tool-registry.js +4 -0
  239. package/dist/core/tool-spec.d.ts +10 -6
  240. package/dist/core/tools.js +2 -0
  241. package/dist/core/trace.d.ts +51 -32
  242. package/dist/core/unc-spelling.d.ts +10 -0
  243. package/dist/core/unc-spelling.js +3 -0
  244. package/dist/core/untrusted-egress.d.ts +8 -0
  245. package/dist/core/untrusted-egress.js +4 -1
  246. package/dist/core/user-attachment.d.ts +12 -2
  247. package/dist/core/user-attachment.js +17 -2
  248. package/dist/core/wiring-manifest.d.ts +14 -13
  249. package/dist/core/wiring-manifest.js +2 -2
  250. package/dist/engine/compaction/utils.js +1 -2
  251. package/dist/engine/execution-env/node-execution-env.d.ts +4 -3
  252. package/dist/engine/execution-env/symlink-chain.js +1 -1
  253. package/dist/engine/harness/agent-harness.d.ts +1 -1
  254. package/dist/engine/harness/agent-harness.js +3 -3
  255. package/dist/engine/harness/types.d.ts +17 -16
  256. package/dist/engine/harness/types.js +7 -1
  257. package/dist/engine/llm/types.d.ts +12 -7
  258. package/dist/engine/loop/agent-loop.js +1 -1
  259. package/dist/engine/loop/types.d.ts +1 -1
  260. package/dist/engine/lsp/node-lsp-manager.d.ts +2 -2
  261. package/dist/engine/session/import-validate.js +3 -10
  262. package/dist/engine/session/session.d.ts +4 -4
  263. package/dist/engine/session/session.js +4 -4
  264. package/dist/index.d.ts +20 -16
  265. package/dist/index.js +13 -11
  266. package/dist/internal/harness.d.ts +1 -1
  267. package/dist/internal/harness.js +1 -1
  268. package/dist/orchestration/run-spec.d.ts +4 -6
  269. package/dist/orchestration/run-spec.js +39 -63
  270. package/dist/orchestration/run-workflow-tool.js +1 -2
  271. package/dist/orchestration/workflow.d.ts +11 -3
  272. package/dist/orchestration/workflow.js +11 -2
  273. package/dist/prompt-assembly/artifact-store.d.ts +37 -56
  274. package/dist/prompt-assembly/artifact-store.js +31 -49
  275. package/dist/prompt-assembly/artifact.d.ts +89 -76
  276. package/dist/prompt-assembly/artifact.js +167 -146
  277. package/dist/prompt-assembly/assemble.d.ts +34 -29
  278. package/dist/prompt-assembly/assemble.js +33 -220
  279. package/dist/prompt-assembly/bands.d.ts +20 -0
  280. package/dist/prompt-assembly/bands.js +18 -0
  281. package/dist/prompt-assembly/catalog/constitution.d.ts +23 -0
  282. package/dist/prompt-assembly/catalog/constitution.js +69 -0
  283. package/dist/prompt-assembly/catalog/core-behavior.d.ts +9 -0
  284. package/dist/prompt-assembly/catalog/core-behavior.js +85 -0
  285. package/dist/prompt-assembly/catalog/index.d.ts +11 -0
  286. package/dist/prompt-assembly/catalog/index.js +59 -0
  287. package/dist/prompt-assembly/catalog/modes.d.ts +15 -0
  288. package/dist/prompt-assembly/catalog/modes.js +137 -0
  289. package/dist/prompt-assembly/catalog/role.d.ts +10 -0
  290. package/dist/prompt-assembly/catalog/role.js +157 -0
  291. package/dist/prompt-assembly/catalog/schema.d.ts +124 -0
  292. package/dist/prompt-assembly/catalog/schema.js +25 -0
  293. package/dist/prompt-assembly/catalog/sections.d.ts +9 -0
  294. package/dist/prompt-assembly/catalog/sections.js +98 -0
  295. package/dist/prompt-assembly/catalog/team.d.ts +4 -0
  296. package/dist/prompt-assembly/catalog/team.js +258 -0
  297. package/dist/prompt-assembly/composer.d.ts +24 -28
  298. package/dist/prompt-assembly/composer.js +124 -46
  299. package/dist/prompt-assembly/epoch.d.ts +89 -79
  300. package/dist/prompt-assembly/epoch.js +115 -142
  301. package/dist/prompt-assembly/explain.d.ts +58 -34
  302. package/dist/prompt-assembly/explain.js +21 -24
  303. package/dist/prompt-assembly/overlay.d.ts +127 -0
  304. package/dist/prompt-assembly/overlay.js +301 -0
  305. package/dist/prompt-assembly/renderers.d.ts +21 -0
  306. package/dist/prompt-assembly/renderers.js +39 -0
  307. package/dist/prompt-assembly/section-usage.d.ts +3 -3
  308. package/dist/prompt-assembly/section-usage.js +1 -1
  309. package/dist/prompt-assembly/select.d.ts +56 -0
  310. package/dist/prompt-assembly/select.js +69 -0
  311. package/dist/prompt-assembly/sugar.d.ts +31 -0
  312. package/dist/prompt-assembly/sugar.js +20 -0
  313. package/dist/prompt-assembly/turn-snapshot.d.ts +3 -2
  314. package/dist/prompt-assembly/types.d.ts +45 -148
  315. package/dist/prompts/coordinator.d.ts +2 -21
  316. package/dist/prompts/coordinator.js +3 -255
  317. package/dist/prompts/cowork.d.ts +27 -16
  318. package/dist/prompts/cowork.js +2 -23
  319. package/dist/prompts/default.d.ts +38 -500
  320. package/dist/prompts/default.js +20 -285
  321. package/dist/prompts/supervisor.d.ts +6 -71
  322. package/dist/prompts/supervisor.js +6 -117
  323. package/dist/tools/fs/bash-readonly-classifier.d.ts +6 -5
  324. package/dist/tools/fs/dir-entries.d.ts +4 -2
  325. package/dist/tools/fs/dir-entries.js +16 -4
  326. package/dist/tools/fs/fs-bash.d.ts +1 -1
  327. package/dist/tools/fs/fs-bash.js +22 -11
  328. package/dist/tools/fs/fs-pdf.js +17 -13
  329. package/dist/tools/fs/fs-read.js +4 -3
  330. package/dist/tools/fs/fs-shared.d.ts +1 -10
  331. package/dist/tools/fs/fs-shared.js +3 -4
  332. package/dist/tools/fs/fs-write.js +2 -1
  333. package/dist/tools/fs/notebook.js +1 -1
  334. package/dist/tools/fs/pdf.d.ts +20 -10
  335. package/dist/tools/fs/pdf.js +19 -10
  336. package/dist/tools/fs/program-read-model.d.ts +68 -8
  337. package/dist/tools/fs/program-read-model.js +112 -33
  338. package/dist/tools/fs/program-read-model.rows.js +30 -10
  339. package/dist/tools/fs/read-deny-home.d.ts +25 -9
  340. package/dist/tools/fs/read-deny-home.js +28 -27
  341. package/dist/tools/fs/read-deny.d.ts +41 -11
  342. package/dist/tools/fs/read-deny.js +51 -5
  343. package/dist/tools/fs/safety.d.ts +4 -26
  344. package/dist/tools/fs/safety.js +10 -32
  345. package/dist/tools/fs/search.js +15 -10
  346. package/dist/tools/fs/shell-read-argv.d.ts +3 -2
  347. package/dist/tools/fs/shell-read-argv.js +118 -38
  348. package/dist/tools/fs/shell-read-establish.d.ts +5 -5
  349. package/dist/tools/fs/shell-read-establish.js +11 -61
  350. package/dist/tools/fs/shell-read-identity.js +6 -3
  351. package/dist/tools/fs/shell-read-judge.d.ts +13 -15
  352. package/dist/tools/fs/shell-read-judge.js +18 -4
  353. package/dist/tools/fs/shell-read-plan.d.ts +2 -2
  354. package/dist/tools/web.js +1 -1
  355. package/package.json +13 -1
  356. package/test/export-surface.snapshot.json +242 -99
  357. package/wire-changes/core@7.52.0.json +5859 -0
  358. package/dist/core/hook-seats.d.ts +0 -66
  359. package/dist/core/hook-seats.js +0 -37
  360. package/dist/prompt-assembly/packs/sema-default.d.ts +0 -2
  361. package/dist/prompt-assembly/packs/sema-default.js +0 -147
  362. package/dist/prompts/simple-sections.d.ts +0 -58
  363. package/dist/prompts/simple-sections.js +0 -43
@@ -23,7 +23,7 @@ import type { AgentTool } from "../../internal/harness.js";
23
23
  import type { ExecutionEnv } from "../../internal/harness.js";
24
24
  import { type AskClass } from "../ask-class.js";
25
25
  import type { AutoModeDecider } from "../auto-mode.js";
26
- import { type Hooks } from "../hooks.js";
26
+ import { type InheritedToolCheck, type LegModBus, type ModChainLink } from "../mods/stations.js";
27
27
  import type { LockedPreflight } from "../locked-config.js";
28
28
  import { type SessionPermissionRules } from "../session-policy-store.js";
29
29
  import { type OnAsk, type ToolPolicy } from "../tool-policy.js";
@@ -34,6 +34,7 @@ import type { CwdRef } from "../../tools/fs/fs-shared.js";
34
34
  import type { ReadDenyMatcher } from "../../tools/fs/read-deny.js";
35
35
  import { type SkillGrantLane, type SkillGrantSource, type SkillGrantTable } from "../skill-grant.js";
36
36
  import type { GrantBindingOf } from "../skill-grant-binding.js";
37
+ import type { ToolSelector } from "../tool-face.js";
37
38
  import { type AllowEntryLane, type AllowEntryTable } from "../allow-entry.js";
38
39
  import type { InheritedGate, IrreversibilityTier, PrepareResume, RunInternals, StopForDenialLimit } from "./contracts.js";
39
40
  import { type Arbitration } from "../ask-origin.js";
@@ -43,14 +44,14 @@ import { createRuleOffersOf, type PermissionRuleLanes } from "./permission-rule-
43
44
  import type { ToolCallLike } from "../tool-registry.js";
44
45
  export interface PreparePolicyChainInput {
45
46
  /** borrowed-readonly — the REBOUND spec. Read: `sessionId` / `principal` (the session-rule read and the lanes' identity),
46
- * `hooks` (spec over deps), `durableApproval` / `checkpointStore` (the mandate-park facility test and the sandbox arming's park prerequisites), `taskId` (the late-ask observer's detail).
47
- * Never mutated. */
48
- spec: Pick<TaskSpec, "sessionId" | "principal" | "hooks" | "durableApproval" | "taskId" | "checkpointStore">;
49
- /** borrowed-readonly — the deployment seats: `sessionPolicyStore` (the rule reads), `hooks` (the fallback record),
47
+ * `durableApproval` / `checkpointStore` (the mandate-park facility test and the sandbox arming's park prerequisites), `taskId` (the late-ask observer's detail),
48
+ * `tools` (the names the caller mounted, for the name audit). Never mutated. */
49
+ spec: Pick<TaskSpec, "sessionId" | "principal" | "durableApproval" | "taskId" | "checkpointStore" | "tools">;
50
+ /** borrowed-readonly — the deployment seats: `sessionPolicyStore` (the rule reads),
50
51
  * `permissionRuleStore` / `localOwnerRules` (the lanes and the offer factory), `onError` / `onNotice` (the advisories,
51
52
  * the refusal disclosures, the late-ask observer), `tracer` (the admission and rule-store frames), `checkpointStore` (the park facility). Receiver preserved;
52
53
  * the advisory dedupe is KEYED on this object's identity. */
53
- deps: Pick<RunnerDeps, "sessionPolicyStore" | "hooks" | "permissionRuleStore" | "localOwnerRules" | "onError" | "onNotice" | "tracer" | "checkpointStore" | "a2a">;
54
+ deps: Pick<RunnerDeps, "sessionPolicyStore" | "permissionRuleStore" | "localOwnerRules" | "onError" | "onNotice" | "tracer" | "checkpointStore" | "a2a">;
54
55
  /** borrowed-readonly — the trusted spawn-side channel: `parentTaskId` (the from-subagent bit), `explicitAgentName` /
55
56
  * `agentName` (the source agent name) — the ask source identity's local, trusted facts. */
56
57
  internals: Pick<RunInternals, "parentTaskId" | "explicitAgentName" | "agentName"> | undefined;
@@ -82,6 +83,8 @@ export interface PreparePolicyChainInput {
82
83
  tools: ReadonlyArray<AgentTool>;
83
84
  /** borrowed-readonly — the harness list (placeholders keep their deferred names), the audit universe's second half. */
84
85
  harnessTools: ReadonlyArray<AgentTool>;
86
+ /** borrowed-readonly — the leg's compiled tool selector: the name audit reads the delegation tools it leaves ({@link delegationPoolReading}). */
87
+ selector: Pick<ToolSelector, "admits">;
85
88
  /** borrowed-readonly — the effect collection, read by the narrowing layers (path-confinable write tools). */
86
89
  toolEffects: ReadonlyMap<string, ToolEffect>;
87
90
  /** borrowed-readonly — the egress mark set (the risk axes, the boundary predicate, the offer factory). */
@@ -146,8 +149,12 @@ export interface PreparePolicyChainInput {
146
149
  frozenOnAsk: OnAsk | undefined;
147
150
  /** borrowed-readonly — the identity of this task's hook-env source (the pass-through test's environment term). */
148
151
  hookEnvSource: unknown;
149
- /** borrowed-readonly — the own-hook crash reporter (the timeout seat's bad-value disclosure). */
152
+ /** borrowed-readonly — the leg's own failure lane (`onError`, phase `hook`, swallow-guarded): an inherited policy that threw. */
150
153
  notifyOwnHookCrash: (err: unknown) => void;
154
+ /** borrowed-readonly — the leg's mods bus (whether this leg's own phase 1 judges with `classic.PreToolUse` — the pass-through test). */
155
+ modBus: LegModBus;
156
+ /** borrowed-readonly — this leg's chain identity as its admission recorded it (`chainOfBus`) — the stand-in test's chain term. */
157
+ ownModChain: readonly ModChainLink[];
151
158
  /** borrowed-readonly — LATE-BOUND: this task's own classifier instance (the pass-through test's decider term), read at chain
152
159
  * assembly (the arming runs after this phase, and again on a steer into `auto`). */
153
160
  autoModeDecider: () => AutoModeDecider | undefined;
@@ -182,14 +189,6 @@ export interface PreparePolicyChainInput {
182
189
  };
183
190
  }
184
191
  export interface PreparePolicyChainResult {
185
- /** owned — the resolved hook record (`spec.hooks ?? deps.hooks`), or undefined. */
186
- hooks: Hooks | undefined;
187
- /** owned — the per-leg hook timeout, resolved and validated ONCE (`Prepared.hookTimeoutMs`). */
188
- hookTimeoutMs: number;
189
- /** owned — whether the deployment declared its screening face observational. */
190
- preToolUseObservational: boolean;
191
- /** owned — the screening face this task's OWN gate runs in phase 1 (the observational wrapper when declared). */
192
- ownGatePreToolUse: Hooks["preToolUse"] | undefined;
193
192
  /** owned — the resume-edit base policy (`Prepared.basePolicyForResumeEdit`), or undefined. */
194
193
  basePolicyForResumeEdit: ToolPolicy | undefined;
195
194
  /** owned — the deny-narrowing fold (`Prepared.denyNarrowingPolicy`), or undefined when no layer exists. */
@@ -208,6 +207,9 @@ export interface PreparePolicyChainResult {
208
207
  /** borrowed-mutable — the inherited-unavailable marker channel. Writers: the inherited arms here (mark); the gate station
209
208
  * (the lifecycle-end sweep) and the park lane's consumers (delete on consumption). */
210
209
  inheritedUnavailableAsks: Set<string>;
210
+ /** owned — the inherited installations THIS leg's gate raises `tool.check` on after its own bus (every screening entry the
211
+ * leg's own gate does not stand in for — the fold's pass-through test), each with the settlement its question takes. */
212
+ inheritedToolChecks: readonly InheritedToolCheck[];
211
213
  /** owned — the inherited stations' MODE ARBITRATIONS by tool call (a release or a refusal made inside the fold,
212
214
  * where an ancestor's ask is arbitrated before its frozen approver). Writers: the three inherited stations here; the gate's
213
215
  * exit reads it onto the disposition and the gate station deletes it at the call's end. */
@@ -3,19 +3,19 @@ import { policyAskClassOf } from "../ask-class.js";
3
3
  import { ASK_USER_QUESTION_TOOL_NAME } from "../ask-question.js";
4
4
  import { classifierUnavailableSeat } from "./classifier-ladder.js";
5
5
  import { resolveCheckpointStore } from "../checkpoint-store.js";
6
- import { cloneObserverInput, resolveHookTimeoutMs } from "../hooks.js";
7
- import { assertHookSeatsCallable } from "../hook-seats.js";
6
+ import { chainJudges, inheritedToolChecks, screeningInstallationsOf, standsInFor } from "../mods/stations.js";
8
7
  import { isNamespacedCoveringRuleName, namespacedRuleNameCovers } from "../permission-rules.js";
9
8
  import { isIsolated } from "../remote-env.js";
10
9
  import { earlierGrammarAdvisory } from "../session-policy-store.js";
11
- import { askApproverIdentity, attest, attestationOf, checkToolPolicyProjection, combinePolicies, createTranscriptIntegrityPolicy, createUnverifiableDeletePolicy, durableParkOptInDeclared, isLiveApproverSeat, mergeAttestation, refuseOutOfContractDecision, resolveAsk, toolPolicyNameSets, withAttestation, wrapToolPolicy } from "../tool-policy.js";
10
+ import { attest, attestationOf, checkToolPolicyProjection, combinePolicies, createTranscriptIntegrityPolicy, createUnverifiableDeletePolicy, durableParkOptInDeclared, isLiveApproverSeat, mergeAttestation, refuseOutOfContractDecision, resolveAsk, toolPolicyNameSets, withAttestation, wrapToolPolicy } from "../tool-policy.js";
12
11
  import { judgeRuleToolName, mountedToolNames } from "../tool-name-aliases.js";
13
12
  import { approvalCardMemberOf } from "../tool-roster.js";
14
13
  import { NAMESPACED_NAME_SHAPES } from "../protocol-table.js";
15
14
  import { emitTrace } from "../trace.js";
16
15
  import { skillGrantBindingMembers } from "../skill-grant.js";
17
16
  import { SKILL_TOOL_NAME } from "./synthetic-tools.js";
18
- import { autoStrippedRule, cardDisclosureOf } from "../allow-entry.js";
17
+ import { delegationPoolReading } from "./sub-agent-deny-lists.js";
18
+ import { autoStrippedRule, cardDisclosureOf, nearMissSpellingOf, rootFacingToolNames } from "../allow-entry.js";
19
19
  import { arbitrateByMode, askClassMembersOf, askFaceOf, askMandateMember } from "../ask-origin.js";
20
20
  import { createModeGatePolicy, mountedToolDeclaresReadOnly } from "../mode-policy.js";
21
21
  const ancestorFacts = (ask) => ({ ...(ask ?? {}), ancestorResolved: true });
@@ -28,7 +28,7 @@ import { createLiveSessionRules, createSessionRulePolicy } from "./session-rule-
28
28
  import { policyThrowLine, reportPolicyThrow } from "./policy-throw.js";
29
29
  import { heldBy, heldValues, seatOf, wireOf } from "../tool-name-readings.js";
30
30
  export async function preparePolicyChain(input) {
31
- const { spec, deps, internals, sessionId, runId, hostTaskId, taskRootFinal, additionalRootsCanonical, executionEnv, lockedPreflight, pathRuleAnchors, headLeads, tools, harnessTools, toolEffects, egressTools, irreversibilityTier, axisExplicitNegatives, shellGatedTools, toolMarkSources, envHandToolNames, handsCwdRef, readDenyMatcher, personRows, questionToolMounted, runtimeCaps, inheritedAncestorRules, ancestorSessionRulesRef, inheritedParentConstraints, seedInheritedGate, skillGrants, skillSpecs, allowedToolTables, frozenOnAsk, hookEnvSource, notifyOwnHookCrash, autoModeDecider, readFace, permissionMode, scratchpadDir, toolRosterDeltas, stopForDenialLimit, delegation, abortController, now, ownSessionRulesRef } = input;
31
+ const { spec, deps, internals, sessionId, runId, hostTaskId, taskRootFinal, additionalRootsCanonical, executionEnv, lockedPreflight, pathRuleAnchors, headLeads, tools, harnessTools, selector, toolEffects, egressTools, irreversibilityTier, axisExplicitNegatives, shellGatedTools, toolMarkSources, envHandToolNames, handsCwdRef, readDenyMatcher, personRows, questionToolMounted, runtimeCaps, inheritedAncestorRules, ancestorSessionRulesRef, inheritedParentConstraints, seedInheritedGate, skillGrants, skillSpecs, allowedToolTables, frozenOnAsk, hookEnvSource, notifyOwnHookCrash, modBus, ownModChain, autoModeDecider, readFace, permissionMode, scratchpadDir, toolRosterDeltas, stopForDenialLimit, delegation, abortController, now, ownSessionRulesRef } = input;
32
32
  const ancestorArbitrations = new Map();
33
33
  const arbitrateInherited = (ask, toolCallId, judged) => {
34
34
  const verdict = arbitrateByMode(permissionMode.current, judged.classification, { origin: judged.origin, ...askMandateMember(ancestorFacts(judged.ask.action === "ask" ? judged.ask : undefined)) });
@@ -40,32 +40,40 @@ export async function preparePolicyChain(input) {
40
40
  return { action: "deny", message: `refused by the ${verdict.mode} permission mode at an inherited ancestor layer (${verdict.askClass})`, decisionReason: "mode" };
41
41
  };
42
42
  const policy = lockedPreflight.toolPolicy;
43
- const auditPolicyNames = (auditee) => {
43
+ const auditPolicyNames = (auditee, inherited = false) => {
44
44
  const nameGroups = toolPolicyNameSets(auditee);
45
45
  if (nameGroups.length > 0) {
46
46
  const known = mountedToolNames(tools);
47
47
  for (const t of harnessTools)
48
48
  known.add(t.name);
49
+ const pool = delegationPoolReading(spec.tools ?? [], selector);
50
+ const callerNames = mountedToolNames(spec.tools ?? []);
51
+ const rootFacing = rootFacingToolNames([...known, ...callerNames, ...pool.names]);
49
52
  const unmatched = new Set();
50
53
  for (const g of nameGroups) {
51
54
  for (const [kind, list] of [["deny", g.deny], ["ask", g.ask], ["allow", g.allow]]) {
52
55
  for (const n of list ?? []) {
53
56
  const verdict = judgeRuleToolName(n, known);
54
- if (verdict.kind !== "current") {
57
+ const twin = verdict.kind === "current" && !inherited ? nearMissSpellingOf(n, rootFacing) : undefined;
58
+ const stale = verdict.kind !== "current" ? verdict : twin !== undefined ? { kind: "case_twin", twin, carrier: known.has(twin) || callerNames.has(twin) ? "run" : pool.names.has(twin) ? "pool" : "catalog" } : undefined;
59
+ if (stale !== undefined) {
55
60
  const entry = `tool policy ${kind}-list entry "${n}"`;
56
61
  let message;
57
- switch (verdict.kind) {
62
+ switch (stale.kind) {
58
63
  case "retired":
59
- message = `${entry} is a RETIRED tool name (${verdict.guidance}) and matches nothing in this run's roster — legacy-name normalization was removed (RB-476-A), so this entry would silently guard nothing. Update the deployment's rule to the current name.`;
64
+ message = `${entry} is a RETIRED tool name (${stale.guidance}) and matches nothing in this run's roster — legacy-name normalization was removed (RB-476-A), so this entry would silently guard nothing. Update the deployment's rule to the current name.`;
60
65
  break;
61
66
  case "unprefixed_namespace":
62
67
  message = `${entry} carries the "__" namespace separator but no protocol prefix, and matches nothing in this run's roster — protocol tools are named ${NAMESPACED_NAME_SHAPES}, and legacy-name normalization was removed (RB-476-A), so this entry would silently guard nothing. Prefix the entry with the owning protocol's marker.`;
63
68
  break;
64
69
  case "unmintable_segment":
65
- message = `${entry} can match no tool, ever (${verdict.guidance}), so it would silently guard nothing.${verdict.currentName !== undefined ? ` Write "${verdict.currentName}".` : ""}`;
70
+ message = `${entry} can match no tool, ever (${stale.guidance}), so it would silently guard nothing.${stale.currentName !== undefined ? ` Write "${stale.currentName}".` : ""}`;
71
+ break;
72
+ case "case_twin":
73
+ message = `${entry} differs from ${stale.carrier === "run" ? "the mounted tool" : stale.carrier === "pool" ? "the tool a delegation pool carries" : "the engine's catalog tool"} "${stale.twin}" only in case, and a policy compares tool names exactly, so it matches nothing in this run's roster and would silently guard nothing. Write "${stale.twin}".`;
66
74
  break;
67
75
  default: {
68
- const exhaustive = verdict;
76
+ const exhaustive = stale;
69
77
  return exhaustive;
70
78
  }
71
79
  }
@@ -111,7 +119,7 @@ export async function preparePolicyChain(input) {
111
119
  catch {
112
120
  }
113
121
  };
114
- const announceEarlierGrammar = (rulesSessionId) => (entries) => deps.onError?.(Object.assign(new Error(earlierGrammarAdvisory(rulesSessionId, entries)), { code: "config.session_rules_earlier_grammar" }), { phase: "config", sessionId });
122
+ const announceEarlierGrammar = (rulesSessionId) => (entries, field, grammar) => deps.onError?.(Object.assign(new Error(earlierGrammarAdvisory(rulesSessionId, entries, field, grammar)), { code: "config.session_rules_earlier_grammar" }), { phase: "config", sessionId });
115
123
  let sessionRulePolicy;
116
124
  if (deps.sessionPolicyStore && spec.sessionId) {
117
125
  const store = deps.sessionPolicyStore;
@@ -156,31 +164,12 @@ export async function preparePolicyChain(input) {
156
164
  check: (creq) => checkToolPolicyProjection(entry, creq) ?? { action: "allow" },
157
165
  }));
158
166
  const narrowingLayers = [sessionRulePolicy, ...ancestorRulePolicies, ...frozenConstraintLayers].filter((p) => p !== undefined);
159
- for (const layer of narrowingLayers)
160
- auditPolicyNames(layer);
167
+ auditPolicyNames(sessionRulePolicy);
168
+ for (const layer of ancestorRulePolicies)
169
+ auditPolicyNames(layer, true);
161
170
  const denyNarrowingPolicy = narrowingLayers.length === 0 ? undefined : narrowingLayers.length === 1 ? narrowingLayers[0] : combinePolicies(...narrowingLayers);
162
171
  const basePolicyForResumeEdit = lockedPreflight.basePolicyForResumeEdit ?? lockedPreflight.toolPolicy;
163
- const hooks = spec.hooks ?? deps.hooks;
164
- assertHookSeatsCallable(hooks, spec.hooks !== undefined ? "spec" : "deps");
165
- const hookTimeoutMs = resolveHookTimeoutMs(hooks?.timeoutMs, notifyOwnHookCrash, hooks);
166
- const preToolUseObservational = hooks?.preToolUse !== undefined && hooks.preToolUseObservational === true;
167
- const ownGatePreToolUse = !preToolUseObservational
168
- ? hooks?.preToolUse
169
- : async (toolName, input, ctx) => {
170
- const r = await hooks.preToolUse(toolName, cloneObserverInput(input), ctx);
171
- if (r === undefined)
172
- return undefined;
173
- try {
174
- const action = typeof r.action === "string" ? r.action : "(non-string action)";
175
- deps.onError?.(new Error(`a PreToolUse hook declared observational (Hooks.preToolUseObservational) returned a decision ("${action}") while screening ` +
176
- `"${toolName}" — the decision was NOT adopted and the call proceeded as if the hook had no opinion. ` +
177
- `A declared-observational face must return undefined; drop the declaration if its verdicts are meant to count ` +
178
- `(they then also travel to delegated children as an inherited screening constraint).`), { phase: "hook", sessionId, classification: "observational-hook-verdict-ignored" });
179
- }
180
- catch {
181
- }
182
- return undefined;
183
- };
172
+ const ownChainJudges = chainJudges(modBus);
184
173
  const sameInstanceAncestorCount = policy === undefined ? 0 : (inheritedParentConstraints ?? []).reduce((n, pc) => (pc.policy === policy ? n + 1 : n), 0);
185
174
  const sharedFirstDecision = new Map();
186
175
  const SHARED_FIRST_DECISION_CAP = 256;
@@ -422,14 +411,66 @@ export async function preparePolicyChain(input) {
422
411
  editArgs = rr.updatedInput;
423
412
  }
424
413
  };
425
- const parentConstraintWrappers = (inheritedParentConstraints ?? []).map((pc) => pc.preToolUse !== undefined &&
426
- pc.preToolUse === hooks?.preToolUse &&
427
- !preToolUseObservational &&
428
- pc.durableMandate !== true &&
429
- pc.contentMandate !== true &&
430
- askApproverIdentity(pc.onAsk) === askApproverIdentity(frozenOnAsk) &&
431
- pc.hookEnv === hookEnvSource &&
432
- pc.autoMode?.decider === autoModeDecider()
414
+ const settleInstallationAsk = async (pc, decision, creq, csignal) => {
415
+ const settledAs = (result) => ({ kind: "settled", result });
416
+ if (isDelegatedQuestion(creq)) {
417
+ if (pc.contentMandate !== true || markInheritedUnavailable(creq.toolCallId))
418
+ return settledAs(decision);
419
+ return settledAs({
420
+ action: "deny",
421
+ message: `inherited parent policy requires durable handling of the question raised for "${creq.toolName}" and the marker channel is at capacity — ` +
422
+ `denied fail-closed (tighten-only)`,
423
+ });
424
+ }
425
+ if (pc.durableMandate === true) {
426
+ if (mandatedCallFloats(creq.toolCallId))
427
+ return settledAs(decision);
428
+ return settledAs(mandateUnreconstructibleDeny(creq));
429
+ }
430
+ const presentedArgs = decision.updatedInput !== undefined ? decision.updatedInput : creq.args;
431
+ const judged = await judgeInheritedClassifier({ liveMode: () => permissionMode.current, autoMode: pc.autoMode, ask: decision, req: { ...creq, args: presentedArgs }, signal: csignal ?? abortController.signal, subject: "this call", allowRewrite: decision.updatedInput, facts: inheritedStationFacts(creq), unavailableSeat: classifierUnavailableSeat({ station: "ancestor", ...(pc.autoMode?.decider.timeoutMs !== undefined ? { budgetMs: pc.autoMode.decider.timeoutMs } : {}), route: frozenApproverRoute(pc.onAsk), onNotice: deps.onNotice, sessionId, runId }) });
432
+ if (judged.kind === "allow")
433
+ return settledAs(judged.result);
434
+ if (judged.kind === "deny")
435
+ return settledAs(judged.result);
436
+ const { ask: inheritedAsk, fallback } = judged;
437
+ if (fallback === undefined && sandboxAdmissionArmed && policyAskClassOf(pc.policy) === "sandbox_local" && !sandboxBoundaryCapable(creq) && judged.classification.row.sandboxAdmission) {
438
+ recordAncestorSandboxAdmission(creq.toolCallId, creq.toolName);
439
+ return settledAs(decision.updatedInput !== undefined ? { action: "allow", updatedInput: decision.updatedInput, decisionReason: "sandbox" } : { action: "allow", decisionReason: "sandbox" });
440
+ }
441
+ const arbitrated = arbitrateInherited(inheritedAsk.action === "ask" ? { ...inheritedAsk, ...(decision.updatedInput !== undefined ? { updatedInput: decision.updatedInput } : {}) } : inheritedAsk, creq.toolCallId, judged);
442
+ if (arbitrated !== undefined)
443
+ return settledAs(arbitrated);
444
+ const askT0 = now();
445
+ const { resolved, judged: settled } = await resolveInheritedAsk(judged, (j) => resolveAsk({
446
+ toolName: creq.toolName,
447
+ toolCallId: creq.toolCallId,
448
+ args: presentedArgs,
449
+ ...ruleOffersOf(creq, presentedArgs, ancestorFacts(j.ask.action === "ask" ? j.ask : undefined)),
450
+ ...cardDisclosureOf(j.ask, inheritedAskFallbackMessage(creq.toolName)),
451
+ ...askSourceIdentity(),
452
+ ...riskAxesOf(creq),
453
+ ...approvalCardMemberOf(creq),
454
+ ...grantBindingOf(creq, presentedArgs),
455
+ ...(j.ask.action === "ask" && j.ask.requiresRealApproval === true ? { requiresRealApproval: true } : {}),
456
+ ...askMandateMember(ancestorFacts(j.ask.action === "ask" ? j.ask : undefined)),
457
+ ...inheritedAskCarry(j, isLiveApproverSeat(pc.onAsk), pc.autoMode?.denialTracking),
458
+ ruleEvidence: inheritedAskEvidence,
459
+ }, pc.onAsk, csignal ?? abortController.signal, lateAskSettlementObserver({ toolName: creq.toolName, toolCallId: creq.toolCallId, sessionId, runId, ...(spec.taskId !== undefined ? { taskId: spec.taskId } : {}), onNotice: deps.onNotice, onError: deps.onError })), pc.autoMode?.denialTracking, creq, inheritedStationFacts(creq));
460
+ void settleReadRootGrant(resolved.readRootGrant, undefined, { toolName: creq.toolName, toolCallId: creq.toolCallId, sessionId, runId, ...(spec.taskId !== undefined ? { taskId: spec.taskId } : {}), onNotice: deps.onNotice });
461
+ const askWaitMs = Math.max(0, now() - askT0);
462
+ if (resolved.action === "deny" && resolved.approverUnavailable === true) {
463
+ if (markInheritedUnavailable(creq.toolCallId))
464
+ return settledAs(settled.ask);
465
+ return settledAs(markerChannelFullDeny(creq));
466
+ }
467
+ settleDenialLimitFallback({ fallback: settled.fallback, mintedHere: settled.mintedHere, tracker: pc.autoMode?.denialTracking, resolved, headless: headlessDenyAtFold, stop: stopForDenialLimit, toolName: creq.toolName, toolCallId: creq.toolCallId });
468
+ if (resolved.action !== "allow")
469
+ return settledAs(resolved);
470
+ return { kind: "approved", resolved, askWaitMs, classes: askClassMembersOf(judged.classification).classes };
471
+ };
472
+ const legStandsIn = (pc) => standsInFor(pc, { chain: ownModChain, onAsk: frozenOnAsk, hookEnv: hookEnvSource, decider: autoModeDecider() }, ownChainJudges);
473
+ const parentConstraintWrappers = (inheritedParentConstraints ?? []).map((pc) => legStandsIn(pc)
433
474
  ? { check: () => ({ action: "allow" }) }
434
475
  : policy !== undefined && pc.policy === policy
435
476
  ? {
@@ -521,70 +562,24 @@ export async function preparePolicyChain(input) {
521
562
  }
522
563
  if (decision.action !== "ask")
523
564
  return decision;
524
- if (isDelegatedQuestion(creq)) {
525
- if (pc.contentMandate !== true || markInheritedUnavailable(creq.toolCallId))
526
- return decision;
527
- return {
528
- action: "deny",
529
- message: `inherited parent policy requires durable handling of the question raised for "${creq.toolName}" and the marker channel is at capacity — ` +
530
- `denied fail-closed (tighten-only)`,
531
- };
532
- }
533
- if (pc.durableMandate === true) {
534
- if (mandatedCallFloats(creq.toolCallId))
535
- return decision;
536
- return mandateUnreconstructibleDeny(creq);
537
- }
538
- const presentedArgs = decision.updatedInput !== undefined ? decision.updatedInput : creq.args;
539
- const judged = await judgeInheritedClassifier({ liveMode: () => permissionMode.current, autoMode: pc.autoMode, ask: decision, req: { ...creq, args: presentedArgs }, signal: csignal ?? abortController.signal, subject: "this call", allowRewrite: decision.updatedInput, facts: inheritedStationFacts(creq), unavailableSeat: classifierUnavailableSeat({ station: "ancestor", ...(pc.autoMode?.decider.timeoutMs !== undefined ? { budgetMs: pc.autoMode.decider.timeoutMs } : {}), route: frozenApproverRoute(pc.onAsk), onNotice: deps.onNotice, sessionId, runId }) });
540
- if (judged.kind === "allow")
541
- return judged.result;
542
- if (judged.kind === "deny")
543
- return judged.result;
544
- const { ask: inheritedAsk, fallback } = judged;
545
- if (fallback === undefined && sandboxAdmissionArmed && policyAskClassOf(pc.policy) === "sandbox_local" && !sandboxBoundaryCapable(creq) && judged.classification.row.sandboxAdmission) {
546
- recordAncestorSandboxAdmission(creq.toolCallId, creq.toolName);
547
- return decision.updatedInput !== undefined ? { action: "allow", updatedInput: decision.updatedInput, decisionReason: "sandbox" } : { action: "allow", decisionReason: "sandbox" };
548
- }
549
- const arbitrated = arbitrateInherited(inheritedAsk.action === "ask" ? { ...inheritedAsk, ...(decision.updatedInput !== undefined ? { updatedInput: decision.updatedInput } : {}) } : inheritedAsk, creq.toolCallId, judged);
550
- if (arbitrated !== undefined)
551
- return arbitrated;
552
- const askT0 = now();
553
- const { resolved, judged: settled } = await resolveInheritedAsk(judged, (j) => resolveAsk({
554
- toolName: creq.toolName,
555
- toolCallId: creq.toolCallId,
556
- args: presentedArgs,
557
- ...ruleOffersOf(creq, presentedArgs, ancestorFacts(j.ask.action === "ask" ? j.ask : undefined)),
558
- ...cardDisclosureOf(j.ask, inheritedAskFallbackMessage(creq.toolName)),
559
- ...askSourceIdentity(),
560
- ...riskAxesOf(creq),
561
- ...approvalCardMemberOf(creq),
562
- ...grantBindingOf(creq, presentedArgs),
563
- ...(j.ask.action === "ask" && j.ask.requiresRealApproval === true ? { requiresRealApproval: true } : {}),
564
- ...askMandateMember(ancestorFacts(j.ask.action === "ask" ? j.ask : undefined)),
565
- ...inheritedAskCarry(j, isLiveApproverSeat(pc.onAsk), pc.autoMode?.denialTracking),
566
- ruleEvidence: inheritedAskEvidence,
567
- }, pc.onAsk, csignal ?? abortController.signal, lateAskSettlementObserver({ toolName: creq.toolName, toolCallId: creq.toolCallId, sessionId, runId, ...(spec.taskId !== undefined ? { taskId: spec.taskId } : {}), onNotice: deps.onNotice, onError: deps.onError })), pc.autoMode?.denialTracking, creq, inheritedStationFacts(creq));
568
- void settleReadRootGrant(resolved.readRootGrant, undefined, { toolName: creq.toolName, toolCallId: creq.toolCallId, sessionId, runId, ...(spec.taskId !== undefined ? { taskId: spec.taskId } : {}), onNotice: deps.onNotice });
569
- const askWaitMs = Math.max(0, now() - askT0);
570
- if (resolved.action === "deny" && resolved.approverUnavailable === true) {
571
- if (markInheritedUnavailable(creq.toolCallId))
572
- return settled.ask;
573
- return markerChannelFullDeny(creq);
574
- }
575
- settleDenialLimitFallback({ fallback: settled.fallback, mintedHere: settled.mintedHere, tracker: pc.autoMode?.denialTracking, resolved, headless: headlessDenyAtFold, stop: stopForDenialLimit, toolName: creq.toolName, toolCallId: creq.toolCallId });
576
- if (resolved.action !== "allow")
577
- return resolved;
565
+ const settled = await settleInstallationAsk(pc, decision, creq, csignal);
566
+ if (settled.kind === "settled")
567
+ return settled.result;
568
+ const { resolved } = settled;
578
569
  if (resolved.updatedInput !== undefined) {
579
570
  return recheckApprovedEdit(pc.policy, pc.onAsk, creq, resolved.updatedInput, resolved, csignal, pc.autoMode);
580
571
  }
581
- if (pc.preToolUse === undefined) {
582
- recordInheritedAskGrant(creq.toolCallId, pc.onAsk, resolved.presentedInput, askWaitMs, resolved, askClassMembersOf(judged.classification).classes);
572
+ if (screeningInstallationsOf([pc]).length === 0) {
573
+ recordInheritedAskGrant(creq.toolCallId, pc.onAsk, resolved.presentedInput, settled.askWaitMs, resolved, settled.classes);
583
574
  }
584
575
  if (decision.updatedInput === undefined)
585
576
  return resolved;
586
577
  return { ...resolved, updatedInput: decision.updatedInput };
587
578
  }));
579
+ const installationToolChecks = inheritedToolChecks(inheritedParentConstraints ?? [], legStandsIn, (pc) => async (ask, creq, csignal) => {
580
+ const settled = await settleInstallationAsk(pc, ask, creq, csignal);
581
+ return settled.kind === "settled" ? settled.result : settled.resolved;
582
+ });
588
583
  const rewriteCapableLayers = policy !== undefined || parentConstraintWrappers.length > 0;
589
584
  const rewriteEmitterIndex = new Map();
590
585
  const rewriteCapableChain = [
@@ -678,7 +673,7 @@ export async function preparePolicyChain(input) {
678
673
  return decision;
679
674
  })
680
675
  : foldedPolicy;
681
- return { hooks, hookTimeoutMs, preToolUseObservational, ownGatePreToolUse, basePolicyForResumeEdit, denyNarrowingPolicy, skillGrantLane, allowEntryLanes, policyLayers, effectivePolicy, inheritedUnavailableAsks, inheritedAskGrants, askSourceIdentity, riskAxesOf, ruleOffersOf, grantBindingOf, permissionRuleLane, ruleLaneFacts, permissionRuleOrgLane, sandboxAdmissionArmed, sandboxBoundaryCapable, emitSandboxAdmitted, foldAskClasses, ancestorSandboxAdmissions, ancestorArbitrations };
676
+ return { basePolicyForResumeEdit, denyNarrowingPolicy, skillGrantLane, allowEntryLanes, policyLayers, effectivePolicy, inheritedUnavailableAsks, inheritedAskGrants, askSourceIdentity, riskAxesOf, ruleOffersOf, grantBindingOf, permissionRuleLane, ruleLaneFacts, permissionRuleOrgLane, sandboxAdmissionArmed, sandboxBoundaryCapable, emitSandboxAdmitted, foldAskClasses, ancestorSandboxAdmissions, ancestorArbitrations, inheritedToolChecks: installationToolChecks };
682
677
  }
683
678
  const advisedPolicyNames = new WeakMap();
684
679
  const ADVISED_KEYS_CAP = 64;
@@ -8,6 +8,7 @@ import { defineTool } from "../tools.js";
8
8
  import { readFrozenSkillGrants, seedSkillGrants, skillSeatReader } from "../skill-grant.js";
9
9
  import { allowedToolsNotGrantedNotice, seedAllowEntryTables } from "../allow-entry.js";
10
10
  import { deliverEngineNotice } from "../engine-notice.js";
11
+ import { announceMemoryNotMounted } from "./announce-once-ledger.js";
11
12
  import { SKILL_CONTENT_MAX_CHARS, SKILL_TOOL_NAME, createSkillTool, normalizeSkills } from "./synthetic-tools.js";
12
13
  import { skillLoadReading } from "./skill-base-dir.js";
13
14
  import { RosterBuilder } from "../tool-roster.js";
@@ -117,11 +118,9 @@ export async function prepareProjectContext(input) {
117
118
  const excludedName = SHARED_MEMORY_TOOL_NAMES.find((n) => !toolFaceSnapshot.selector.admits({ name: n }));
118
119
  const occupiedName = SHARED_MEMORY_TOOL_NAMES.find((n) => mountedNameDomain.has(n));
119
120
  if (excludedName !== undefined || occupiedName !== undefined) {
120
- onceLedger.onError(new Error(`Shared memory tools ${SHARED_MEMORY_TOOL_NAMES.join("/")} were NOT mounted: ` +
121
- (excludedName !== undefined
122
- ? `the run's tool selector (allowTools / excludeTools) does not admit "${excludedName}"`
123
- : `this task already declares a tool named "${occupiedName}" (the built-in yields to it)`) +
124
- " — the pair mounts together or not at all."), { phase: "config", sessionId, classification: "shared-memory-not-mounted" });
121
+ announceMemoryNotMounted(onceLedger, sessionId, "shared", SHARED_MEMORY_TOOL_NAMES, excludedName !== undefined
122
+ ? `the run's tool selector (allowTools / excludeTools) does not admit "${excludedName}"`
123
+ : `this task already declares a tool named "${occupiedName}" (the built-in yields to it)`);
125
124
  }
126
125
  else {
127
126
  roster.mountAll(createSharedMemoryTools({
@@ -137,11 +136,9 @@ export async function prepareProjectContext(input) {
137
136
  memoryEnginePairMounted = true;
138
137
  }
139
138
  else if (memoryEngineSession !== undefined && !memorySearchToolsPlanned) {
140
- onceLedger.onError(new Error(`Memory tools ${MEMORY_ENGINE_TOOL_NAMES.join("/")} were NOT mounted: ` +
141
- (memoryPairExcludedName !== undefined
142
- ? `the run's tool selector (allowTools / excludeTools) does not admit "${memoryPairExcludedName}"`
143
- : `this task already declares a tool named "${memoryPairOccupiedName}" (the built-in yields to it)`) +
144
- " — these tools mount together or not at all."), { phase: "config", sessionId, classification: "memory-tools-not-mounted" });
139
+ announceMemoryNotMounted(onceLedger, sessionId, "engine", MEMORY_ENGINE_TOOL_NAMES, memoryPairExcludedName !== undefined
140
+ ? `the run's tool selector (allowTools / excludeTools) does not admit "${memoryPairExcludedName}"`
141
+ : `this task already declares a tool named "${memoryPairOccupiedName}" (the built-in yields to it)`);
145
142
  }
146
143
  const skillsListing = skillSpecs.length > 0
147
144
  ? {
@@ -1,37 +1,42 @@
1
1
  import type { AgentTool } from "../../internal/harness.js";
2
2
  import type { Model } from "../../internal/llm.js";
3
3
  import { assemblePrompt, type AssembledPrompt } from "../../prompt-assembly/assemble.js";
4
- import { type PromptEpochArtifact } from "../../prompt-assembly/artifact.js";
5
- import { type EpochDeclaredSections } from "../../prompt-assembly/epoch.js";
6
- import { type EnvironmentFacts, type PromptProvider, type PromptTextDeclaration } from "../../prompts/default.js";
4
+ import { type CenterAdoption } from "../../prompt-assembly/artifact.js";
5
+ import { type RunPromptIdentity } from "../../prompt-assembly/epoch.js";
6
+ import type { HostForm, HostRole } from "../../prompt-assembly/catalog/schema.js";
7
+ import type { SourcedOverlay } from "../../prompt-assembly/overlay.js";
8
+ import { type EnvironmentFacts } from "../../prompts/default.js";
9
+ import { type LegModBus } from "../mods/stations.js";
7
10
  import { type StoredSession } from "../session.js";
8
11
  import type { RunnerDeps } from "../types.js";
9
12
  import type { AnnounceOnceSink, Prepared, PrepareResume, PromptFeatureFlags, RunInternals } from "./contracts.js";
10
- /** The center adoption a run composes under: the artifact and, when the source stamped one, its revision. */
11
- export type CenterAdoption = {
12
- artifact: PromptEpochArtifact;
13
- sourceRevision?: string;
14
- };
15
13
  export interface PreparePromptAssemblyInput {
16
- /** borrowed-mutable — the acquired session. Read: `getPromptEpoch` (the pin, twice — the center arm and the epoch
17
- * resolution), `getBranch` (the freshness discriminator on the pinless arms). Writer here: `appendPromptEpoch`, the
18
- * ONE pin write of this leg (only when the resolution migrated). The acquire phase and the run loop write it elsewhere. */
14
+ /** borrowed-mutable — the acquired session. Read: `getPromptEpoch` (the stored record), `getBranch` (the freshness
15
+ * discriminator on the record-less arms). Writer here: `appendPromptEpoch`, the ONE record write of this leg (only
16
+ * when the run's identity differs from the stored record's). The acquire phase and the run loop write it elsewhere. */
19
17
  session: Pick<StoredSession, "getPromptEpoch" | "getBranch" | "appendPromptEpoch">;
20
- /** borrowed-readonly — the deployment seats: `promptSource` (the center artifact store and its live candidate), `onError`
21
- * (the assembly's warn channel, the prompt-constitution line, the missing-declaration disclosure). Receiver preserved. */
18
+ /** borrowed-readonly — the deployment seats: `promptSource` (the center artifact source, its candidate and its
19
+ * tri-state), `onError` (the assembly's warn channel). Receiver preserved. */
22
20
  deps: Pick<RunnerDeps, "promptSource" | "onError">;
23
- /** borrowed-readonly — the trusted spawn-side channel: the parent's center closure (`parentCenterArtifactDigest`,
21
+ /** borrowed-readonly — the trusted spawn-side channel: the parent's center layer (`parentCenterArtifactDigest`,
24
22
  * `parentCenterSourceRevision`), the top-level freshness facts (`parentTaskId`, `parentSessionId`) and the named-child
25
23
  * fact the teammate flag reads (`explicitAgentName`). */
26
24
  internals: Pick<RunInternals, "parentCenterArtifactDigest" | "parentCenterSourceRevision" | "parentTaskId" | "parentSessionId" | "explicitAgentName"> | undefined;
27
25
  /** borrowed-readonly — the resume leg, or undefined; PRESENCE only (a resumed leg is never truly fresh). */
28
26
  resume: Pick<PrepareResume, "seed"> | undefined;
29
- /** borrowed-readonly — the resolved prompt provider (compared against the default for `isDefaultProvider`). */
30
- provider: PromptProvider;
31
- /** borrowed-readonly — the caller's role-layer prompt, or undefined. */
32
- userSystemPrompt: string | undefined;
33
- /** borrowed-readonly — the caller's appended prompt, or undefined. */
34
- userAppendSystemPrompt: string | undefined;
27
+ /** borrowed-readonly — the request-body sugar's overlays (the task class's first contributions). */
28
+ sugar: readonly SourcedOverlay[];
29
+ /** borrowed-readonly — the host selector values (`promptRole` / `promptForm`). */
30
+ host: {
31
+ readonly role?: HostRole;
32
+ readonly form?: HostForm;
33
+ };
34
+ /** borrowed-readonly — the center binding (`TaskSpec.promptBinding`, validated), or undefined. */
35
+ binding: string | undefined;
36
+ /** borrowed-readonly — the leg's mods bus: `prompt.compose` collects the deploy and task seats' overlays. */
37
+ modBus: LegModBus;
38
+ /** borrowed-readonly — the run's abort signal (the compose raise ends with it). */
39
+ signal?: AbortSignal;
35
40
  /** borrowed-readonly — the harness-context flags; the two orchestration flags are re-derived against the post-exclusion
36
41
  * roster at assembly. */
37
42
  featureFlags: PromptFeatureFlags;
@@ -49,47 +54,47 @@ export interface PreparePromptAssemblyInput {
49
54
  /** borrowed-readonly — the run's ONE tool roster, read only: the assembly receives DETACHED copies, the audit and the
50
55
  * manifest read it in place. Never mutated here. */
51
56
  tools: readonly AgentTool[];
52
- /** borrowed-readonly — the task model; only `promptGuidance` (the model-guidance section). */
53
- model: Pick<Model, "promptGuidance">;
57
+ /** borrowed-readonly — the task model: `promptGuidance` (the model-guidance section) and `id` (the compose event's `model`). */
58
+ model: Pick<Model, "id" | "promptGuidance">;
54
59
  /** borrowed-readonly — the acquired session id (every operator line's attribution). */
55
60
  sessionId: string;
56
- /** borrowed-readonly — the session's reminder provenance mark (the declaration the assembled prompt must render). */
57
- reminderMark: string;
58
61
  /** borrowed-readonly — the once-per-session ledger's operator sink (the collision audit's two lines). */
59
62
  onceLedger: Pick<AnnounceOnceSink, "onError">;
60
63
  }
61
64
  export interface PreparePromptAssemblyResult {
62
65
  /** borrowed-mutable — the LIVE system prompt (an accessor cell over this phase's closure variable). Writers: this
63
66
  * phase's `renderWithDate` (the date re-render, called by the listings phase's date_change seam); the turn-wiring
64
- * phase's center candidate `apply` (the compaction-boundary swap). Readers: the harness construction, the cache
67
+ * phase's center candidate `apply` (the compaction-boundary change). Readers: the harness construction, the cache
65
68
  * fingerprint, the turn snapshot's stable text, the prompt-overhead term. */
66
69
  systemPromptSeat: {
67
70
  current: string;
68
71
  };
69
- /** owned — the date re-render, or undefined for a provider whose assembly cannot re-render. Returns the new prompt and
70
- * writes it into `systemPromptSeat`. */
72
+ /** owned — the date re-render. Returns the new prompt and writes it into `systemPromptSeat`. */
71
73
  renderWithDate: ((date: string) => string) | undefined;
72
- /** owned — the physical block face of the assembled prompt, or undefined (the harness's systemBlocks and the turn
73
- * snapshot's layout groups). */
74
+ /** owned — the physical block face of the assembled prompt (the harness's systemBlocks and the turn snapshot's
75
+ * layout groups). */
74
76
  systemBlocks: AssembledPrompt["systemBlocks"];
75
77
  /** borrowed-mutable — the composition manifest (`Prepared.promptManifest`). Writers after this phase: the tool-disclosure
76
78
  * phase writes `toolDisclosure` (when deferred tools exist); the turn-wiring phase backfills `snapshot` and `lowering`
77
79
  * once the final wire tool list exists. */
78
80
  promptManifest: Prepared["promptManifest"];
79
- /** owned — the provider-declared sections in the epoch shape (id, slot, chars, opt-in contentHash; never text). */
80
- epochDeclaredSections: EpochDeclaredSections;
81
- /** owned — the resolved epoch's artifact digest, the turn snapshot's identity element. */
82
- epochArtifactDigestForSnapshot: string;
83
- /** owned — the re-invokable assemble-inputs BUILDER: the compaction-boundary candidate re-assembles with a new
84
- * artifact's declarations through it (facts and tails identical; only the center closure differs). */
85
- buildAssembleInputs: (centerDecls?: PromptTextDeclaration[]) => Parameters<typeof assemblePrompt>[0];
81
+ /** owned — the run's identity inputs and the pinned center layer's provenance (`Prepared.promptIdentity`; the
82
+ * compaction-boundary candidate replaces it after a committed center change). */
83
+ promptIdentity: RunPromptIdentity;
84
+ /** owned — the re-invokable assemble-inputs BUILDER: the compaction-boundary candidate re-assembles with a new center
85
+ * layer through it (facts, tails and the run-frozen mods overlays identical; only the center class differs). */
86
+ buildAssembleInputs: (center: CenterAdoption | undefined) => Parameters<typeof assemblePrompt>[0];
87
+ /** owned — the identity inputs under another center layer (the compaction-boundary candidate's record). */
88
+ identityFor: (center: CenterAdoption | undefined) => RunPromptIdentity;
89
+ /** owned — whether this run adopts center candidates at its boundaries: a top-level run does; a child composes its
90
+ * parent's layer and never adopts one of its own. */
91
+ adoptsCandidates: boolean;
86
92
  /** borrowed-mutable — the LIVE center adoption (an accessor cell over this phase's closure variable), or undefined.
87
- * Writers: this phase (the three arms; the all-shadowed drop on the fresh arm); the turn-wiring phase's center
88
- * candidate `apply` (the boundary swap / the explicit-disable rollback). Readers: the two late-bound ctx getters
89
- * (inherited-gate, caps-and-workflow), the pin write, the candidate's same-artifact test. */
93
+ * Writers: this phase (the resolution arms); the turn-wiring phase's center candidate `apply` (the boundary change).
94
+ * Readers: the two late-bound ctx getters (inherited-gate, caps-and-workflow), the candidate's same-artifact test. */
90
95
  centerAdoptionRef: {
91
96
  current: CenterAdoption | undefined;
92
97
  };
93
98
  }
94
- /** The M13 phase body — prepareTask's prompt-assembly stretch, verbatim (see the module header). */
99
+ /** The M13 phase body — prepareTask's prompt-assembly stretch (see the module header). */
95
100
  export declare function preparePromptAssembly(input: PreparePromptAssemblyInput): Promise<PreparePromptAssemblyResult>;