@sema-agent/core 7.59.0 → 7.60.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 (360) hide show
  1. package/CHANGELOG.md +564 -0
  2. package/dist/agents/agent-definition.d.ts +7 -0
  3. package/dist/agents/agent-definition.js +12 -0
  4. package/dist/agents/agent-transcript-tool.d.ts +2 -1
  5. package/dist/agents/agent-transcript-tool.js +3 -1
  6. package/dist/agents/child-model-seat.js +6 -3
  7. package/dist/agents/cumulative-stats.js +0 -1
  8. package/dist/agents/inherited-tool-pool.d.ts +26 -1
  9. package/dist/agents/inherited-tool-pool.js +22 -0
  10. package/dist/agents/retain-ledger.d.ts +11 -1
  11. package/dist/agents/retain-ledger.js +13 -2
  12. package/dist/agents/roster-store.d.ts +1 -1
  13. package/dist/agents/roster-store.js +3 -1
  14. package/dist/agents/send-message-tool.d.ts +8 -19
  15. package/dist/agents/send-message-tool.js +11 -38
  16. package/dist/agents/subagent.d.ts +51 -17
  17. package/dist/agents/subagent.js +117 -78
  18. package/dist/agents/tool-filter.d.ts +1 -3
  19. package/dist/agents/tool-filter.js +4 -12
  20. package/dist/bench/metrics.d.ts +3 -5
  21. package/dist/bench/metrics.js +0 -1
  22. package/dist/brain/degrading.js +3 -1
  23. package/dist/brain/route-adjudicator.js +3 -1
  24. package/dist/brain/status-sink.d.ts +7 -1
  25. package/dist/brain/status-sink.js +6 -0
  26. package/dist/brain/timeout.d.ts +3 -1
  27. package/dist/brain/timeout.js +18 -5
  28. package/dist/core/a2a.d.ts +15 -5
  29. package/dist/core/a2a.js +34 -19
  30. package/dist/core/agent-definition.d.ts +20 -0
  31. package/dist/core/allow-entry.d.ts +2 -0
  32. package/dist/core/allow-entry.js +3 -1
  33. package/dist/core/artifact-host.d.ts +0 -2
  34. package/dist/core/artifact-host.js +0 -1
  35. package/dist/core/auto-mode-defaults.d.ts +8 -0
  36. package/dist/core/auto-mode-defaults.js +1 -0
  37. package/dist/core/auto-mode-rebuild.d.ts +2 -1
  38. package/dist/core/auto-mode.d.ts +39 -4
  39. package/dist/core/auto-mode.js +63 -12
  40. package/dist/core/background-agent-store.d.ts +10 -1
  41. package/dist/core/background-agent-store.js +3 -2
  42. package/dist/core/background-shell.d.ts +12 -1
  43. package/dist/core/background-shell.js +12 -0
  44. package/dist/core/checkpoint-store.d.ts +8 -13
  45. package/dist/core/checkpoint-store.js +4 -3
  46. package/dist/core/compliance.d.ts +1 -1
  47. package/dist/core/credential-echo.d.ts +52 -0
  48. package/dist/core/credential-echo.js +65 -0
  49. package/dist/core/credential-vocabulary.d.ts +13 -3
  50. package/dist/core/credential-vocabulary.js +12 -4
  51. package/dist/core/cross-boundary-taint.d.ts +4 -5
  52. package/dist/core/engine-notice.d.ts +58 -15
  53. package/dist/core/frame-settlement.d.ts +5 -0
  54. package/dist/core/frame-settlement.js +4 -0
  55. package/dist/core/gate-fold.js +7 -5
  56. package/dist/core/gate-lanes.js +39 -8
  57. package/dist/core/governance-codes.d.ts +9 -1
  58. package/dist/core/governance-codes.js +12 -0
  59. package/dist/core/hands-band-screen.js +0 -1
  60. package/dist/core/hands-band.d.ts +0 -3
  61. package/dist/core/hooks.d.ts +39 -56
  62. package/dist/core/hooks.js +123 -77
  63. package/dist/core/image-admission.d.ts +104 -51
  64. package/dist/core/image-admission.js +170 -46
  65. package/dist/core/image-downsample.d.ts +36 -69
  66. package/dist/core/image-downsample.js +111 -73
  67. package/dist/core/integer-option.d.ts +21 -0
  68. package/dist/core/integer-option.js +13 -0
  69. package/dist/core/locked-config.d.ts +54 -3
  70. package/dist/core/locked-config.js +81 -50
  71. package/dist/core/mcp-call-meta.d.ts +2 -2
  72. package/dist/core/mcp-call-meta.js +9 -10
  73. package/dist/core/mcp-failure.d.ts +9 -3
  74. package/dist/core/mcp-failure.js +10 -0
  75. package/dist/core/mcp-host-seat.d.ts +92 -0
  76. package/dist/core/mcp-host-seat.js +131 -0
  77. package/dist/core/mcp-probe.d.ts +7 -2
  78. package/dist/core/mcp-probe.js +7 -2
  79. package/dist/core/mcp-server-spec.d.ts +38 -9
  80. package/dist/core/mcp-server-spec.js +55 -21
  81. package/dist/core/mcp.d.ts +17 -6
  82. package/dist/core/mcp.js +67 -55
  83. package/dist/core/memory-admission.d.ts +23 -6
  84. package/dist/core/memory-admission.js +19 -9
  85. package/dist/core/memory-engine/content-origin.d.ts +13 -0
  86. package/dist/core/memory-engine/content-origin.js +21 -3
  87. package/dist/core/memory-engine/index.d.ts +2 -1
  88. package/dist/core/memory-engine/index.js +2 -1
  89. package/dist/core/memory-engine/scope-contract.d.ts +13 -3
  90. package/dist/core/memory-engine/scope-contract.js +2 -2
  91. package/dist/core/memory-engine/sync-client.d.ts +45 -11
  92. package/dist/core/memory-engine/sync-client.js +82 -11
  93. package/dist/core/memory-engine/sync-report.d.ts +103 -0
  94. package/dist/core/memory-engine/sync-report.js +119 -0
  95. package/dist/core/memory-engine/sync.d.ts +4 -2
  96. package/dist/core/mode-policy.d.ts +9 -1
  97. package/dist/core/mode-policy.js +11 -1
  98. package/dist/core/model-receipt.d.ts +39 -0
  99. package/dist/core/model-receipt.js +139 -0
  100. package/dist/core/mods/agent-stations.d.ts +65 -0
  101. package/dist/core/mods/agent-stations.js +105 -0
  102. package/dist/core/mods/kernel/dispatch.d.ts +5 -1
  103. package/dist/core/mods/kernel/dispatch.js +4 -4
  104. package/dist/core/mods/kernel/events.d.ts +10 -4
  105. package/dist/core/mods/kernel/events.js +10 -6
  106. package/dist/core/mods/kernel/receive.d.ts +5 -0
  107. package/dist/core/mods/kernel/receive.js +10 -0
  108. package/dist/core/mods/lifecycle-stations.d.ts +41 -0
  109. package/dist/core/mods/lifecycle-stations.js +35 -0
  110. package/dist/core/mods/stations.d.ts +51 -59
  111. package/dist/core/mods/stations.js +32 -42
  112. package/dist/core/mods/tool-call.d.ts +10 -4
  113. package/dist/core/mods/tool-call.js +28 -12
  114. package/dist/core/mounted-mcp.d.ts +5 -0
  115. package/dist/core/mounted-mcp.js +2 -2
  116. package/dist/core/namespaced-rule-name.d.ts +7 -1
  117. package/dist/core/namespaced-rule-name.js +13 -2
  118. package/dist/core/oracle-isolation.js +1 -1
  119. package/dist/core/own-property-receipt.d.ts +3 -0
  120. package/dist/core/own-property-receipt.js +3 -0
  121. package/dist/core/park-selfcheck.js +8 -8
  122. package/dist/core/peer-seat.d.ts +63 -8
  123. package/dist/core/peer-seat.js +179 -34
  124. package/dist/core/permission-rule-consent.d.ts +0 -21
  125. package/dist/core/permission-rule-consent.js +1 -2
  126. package/dist/core/permission-rule-model.d.ts +4 -2
  127. package/dist/core/permission-rule-model.js +7 -6
  128. package/dist/core/protocol-http-auth.d.ts +14 -2
  129. package/dist/core/protocol-http-auth.js +16 -7
  130. package/dist/core/read-face-seats.d.ts +7 -5
  131. package/dist/core/read-face-seats.js +4 -1
  132. package/dist/core/redaction-marks.d.ts +4 -3
  133. package/dist/core/redaction-marks.js +2 -2
  134. package/dist/core/remote-env.d.ts +146 -98
  135. package/dist/core/remote-env.js +113 -14
  136. package/dist/core/retention.js +37 -12
  137. package/dist/core/retired-keys.d.ts +6 -1
  138. package/dist/core/retired-keys.js +4 -1
  139. package/dist/core/rewrite-rejudge.d.ts +12 -5
  140. package/dist/core/rewrite-rejudge.js +9 -5
  141. package/dist/core/roles.d.ts +37 -3
  142. package/dist/core/roles.js +126 -78
  143. package/dist/core/rule-owner.d.ts +3 -0
  144. package/dist/core/runner/assemble-result.d.ts +0 -5
  145. package/dist/core/runner/assemble-result.js +0 -1
  146. package/dist/core/runner/call-hook-stations.d.ts +17 -10
  147. package/dist/core/runner/call-hook-stations.js +21 -10
  148. package/dist/core/runner/child-tree.d.ts +7 -8
  149. package/dist/core/runner/child-tree.js +6 -6
  150. package/dist/core/runner/classifier-ladder.d.ts +10 -2
  151. package/dist/core/runner/classifier-ladder.js +39 -8
  152. package/dist/core/runner/construction-doors.js +5 -0
  153. package/dist/core/runner/contracts.d.ts +62 -41
  154. package/dist/core/runner/cross-boundary-lane.d.ts +3 -5
  155. package/dist/core/runner/cross-boundary-lane.js +11 -2
  156. package/dist/core/runner/env-capability-census.d.ts +15 -20
  157. package/dist/core/runner/env-capability-census.js +25 -34
  158. package/dist/core/runner/file-history-request.d.ts +2 -2
  159. package/dist/core/runner/file-history-request.js +0 -8
  160. package/dist/core/runner/gate-exit.d.ts +75 -7
  161. package/dist/core/runner/gate-exit.js +20 -1
  162. package/dist/core/runner/git-status-frame.d.ts +5 -2
  163. package/dist/core/runner/git-status-frame.js +3 -4
  164. package/dist/core/runner/image.d.ts +7 -2
  165. package/dist/core/runner/image.js +14 -8
  166. package/dist/core/runner/inline-image.d.ts +10 -8
  167. package/dist/core/runner/inline-image.js +11 -9
  168. package/dist/core/runner/memory-consolidation-driver.js +4 -4
  169. package/dist/core/runner/permission-rule-lanes.js +1 -1
  170. package/dist/core/runner/prepare-boundary-parks.d.ts +2 -2
  171. package/dist/core/runner/prepare-boundary-parks.js +3 -3
  172. package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -0
  173. package/dist/core/runner/prepare-caps-and-workflow.js +4 -3
  174. package/dist/core/runner/prepare-config-doors.d.ts +6 -1
  175. package/dist/core/runner/prepare-config-doors.js +14 -9
  176. package/dist/core/runner/prepare-delegation-surface.d.ts +5 -3
  177. package/dist/core/runner/prepare-delegation-surface.js +4 -4
  178. package/dist/core/runner/prepare-file-history.d.ts +10 -12
  179. package/dist/core/runner/prepare-file-history.js +3 -12
  180. package/dist/core/runner/prepare-gate-stations.d.ts +4 -3
  181. package/dist/core/runner/prepare-gate-stations.js +4 -3
  182. package/dist/core/runner/prepare-hands-readface.d.ts +3 -1
  183. package/dist/core/runner/prepare-hands-readface.js +15 -7
  184. package/dist/core/runner/prepare-inherited-gate.d.ts +5 -4
  185. package/dist/core/runner/prepare-inherited-gate.js +9 -5
  186. package/dist/core/runner/prepare-memory-engine-session.js +1 -1
  187. package/dist/core/runner/prepare-memory.d.ts +2 -2
  188. package/dist/core/runner/prepare-memory.js +2 -2
  189. package/dist/core/runner/prepare-park-ask.d.ts +3 -5
  190. package/dist/core/runner/prepare-park-ask.js +3 -8
  191. package/dist/core/runner/prepare-policy-chain.d.ts +5 -4
  192. package/dist/core/runner/prepare-policy-chain.js +120 -108
  193. package/dist/core/runner/prepare-project-context.js +8 -5
  194. package/dist/core/runner/prepare-prompt-inputs.d.ts +4 -1
  195. package/dist/core/runner/prepare-prompt-inputs.js +3 -2
  196. package/dist/core/runner/prepare-protocol-tools.d.ts +5 -3
  197. package/dist/core/runner/prepare-protocol-tools.js +9 -2
  198. package/dist/core/runner/prepare-suspend-saga.d.ts +0 -2
  199. package/dist/core/runner/prepare-suspend-saga.js +5 -7
  200. package/dist/core/runner/prepare-task.js +41 -27
  201. package/dist/core/runner/prepare-turn-wiring.d.ts +2 -0
  202. package/dist/core/runner/prepare-turn-wiring.js +7 -2
  203. package/dist/core/runner/prepare-wiring-manifest.d.ts +4 -3
  204. package/dist/core/runner/prepare-wiring-manifest.js +32 -18
  205. package/dist/core/runner/prepare-workspace-restore.js +3 -3
  206. package/dist/core/runner/resume-checkpoint-screen.js +4 -4
  207. package/dist/core/runner/retired-runner-deps.js +4 -1
  208. package/dist/core/runner/run-attachment-seats.js +3 -3
  209. package/dist/core/runner/run-brain-sinks.js +1 -0
  210. package/dist/core/runner/run-git-lane.d.ts +3 -1
  211. package/dist/core/runner/run-git-lane.js +1 -1
  212. package/dist/core/runner/run-harness-handlers.d.ts +3 -1
  213. package/dist/core/runner/run-harness-handlers.js +3 -1
  214. package/dist/core/runner/run-identity-wiring.js +1 -1
  215. package/dist/core/runner/run-leg.js +26 -28
  216. package/dist/core/runner/run-notification-lane.d.ts +3 -1
  217. package/dist/core/runner/run-notification-lane.js +16 -10
  218. package/dist/core/runner/run-settle-and-teardown.js +5 -1
  219. package/dist/core/runner/run-stop-and-final-verify.d.ts +4 -0
  220. package/dist/core/runner/run-stop-and-final-verify.js +12 -4
  221. package/dist/core/runner/run-turn-boundary.js +12 -7
  222. package/dist/core/runner/runtask.d.ts +7 -4
  223. package/dist/core/runner/runtask.js +19 -11
  224. package/dist/core/runner/skills-seat.js +2 -2
  225. package/dist/core/runner/sub-agent-deny-lists.js +10 -7
  226. package/dist/core/runner/synthetic-tools.js +2 -2
  227. package/dist/core/runner/tool-disclosure.js +0 -2
  228. package/dist/core/runner/tool-face-overlay.d.ts +1 -1
  229. package/dist/core/runner/tool-face-overlay.js +26 -19
  230. package/dist/core/runner/tool-result-media-seat.d.ts +9 -1
  231. package/dist/core/runner/tool-result-media-seat.js +17 -1
  232. package/dist/core/runner/turn-attachments.d.ts +3 -5
  233. package/dist/core/runner/turn-attachments.js +3 -16
  234. package/dist/core/runner-deps.d.ts +31 -18
  235. package/dist/core/secret-env.d.ts +3 -2
  236. package/dist/core/session-policy-store.d.ts +9 -2
  237. package/dist/core/session-policy-store.js +16 -1
  238. package/dist/core/session-store.d.ts +3 -2
  239. package/dist/core/session-store.js +50 -11
  240. package/dist/core/skill-grant.d.ts +9 -0
  241. package/dist/core/skill-grant.js +18 -0
  242. package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
  243. package/dist/core/store-contracts/tool-result-store-contract.js +37 -0
  244. package/dist/core/stub-env.d.ts +5 -5
  245. package/dist/core/stub-env.js +11 -1
  246. package/dist/core/swappable-deps.d.ts +17 -43
  247. package/dist/core/swappable-deps.js +15 -5
  248. package/dist/core/synthetic-read-verdict.d.ts +1 -1
  249. package/dist/core/task-event.d.ts +18 -2
  250. package/dist/core/task-notification.d.ts +88 -5
  251. package/dist/core/task-notification.js +130 -7
  252. package/dist/core/task-registry-agent.d.ts +18 -12
  253. package/dist/core/task-registry-agent.js +18 -6
  254. package/dist/core/task-registry-monitor.d.ts +7 -0
  255. package/dist/core/task-registry-monitor.js +28 -1
  256. package/dist/core/task-registry-shared.d.ts +38 -3
  257. package/dist/core/task-registry-shared.js +21 -7
  258. package/dist/core/task-registry-workflow.js +1 -1
  259. package/dist/core/task-registry.d.ts +50 -35
  260. package/dist/core/task-registry.js +64 -23
  261. package/dist/core/task-result.d.ts +3 -12
  262. package/dist/core/task-spec.d.ts +3 -6
  263. package/dist/core/task-stream.d.ts +1 -1
  264. package/dist/core/tool-catalog-entries.js +1 -1
  265. package/dist/core/tool-face-reader.d.ts +7 -6
  266. package/dist/core/tool-face-reader.js +4 -3
  267. package/dist/core/tool-name-aliases.d.ts +19 -0
  268. package/dist/core/tool-name-aliases.js +54 -2
  269. package/dist/core/tool-policy.d.ts +5 -4
  270. package/dist/core/tool-policy.js +1 -1
  271. package/dist/core/tool-registry.d.ts +5 -5
  272. package/dist/core/tool-registry.js +2 -2
  273. package/dist/core/tool-result-store.d.ts +88 -5
  274. package/dist/core/tool-result-store.js +51 -12
  275. package/dist/core/tool-spec.d.ts +20 -4
  276. package/dist/core/trace.d.ts +0 -1
  277. package/dist/core/types.d.ts +3 -3
  278. package/dist/core/types.js +1 -1
  279. package/dist/core/untrusted-text.js +1 -1
  280. package/dist/core/user-attachment.d.ts +10 -5
  281. package/dist/core/user-attachment.js +14 -6
  282. package/dist/engine/execution-env/node-execution-env.d.ts +7 -2
  283. package/dist/engine/execution-env/node-execution-env.js +12 -1
  284. package/dist/engine/harness/agent-harness.d.ts +1 -1
  285. package/dist/engine/harness/agent-harness.js +8 -4
  286. package/dist/engine/harness/types.d.ts +112 -29
  287. package/dist/engine/loop/agent-loop.d.ts +12 -12
  288. package/dist/engine/loop/agent-loop.js +153 -21
  289. package/dist/engine/loop/types.d.ts +9 -2
  290. package/dist/engine/lsp/node-lsp-manager.d.ts +3 -3
  291. package/dist/engine/lsp/node-lsp-manager.js +32 -13
  292. package/dist/index.d.ts +22 -14
  293. package/dist/index.js +15 -10
  294. package/dist/internal/harness-types.d.ts +1 -1
  295. package/dist/orchestration/run-workflow-tool.d.ts +9 -3
  296. package/dist/orchestration/run-workflow-tool.js +59 -29
  297. package/dist/orchestration/workflow-governance.d.ts +1 -1
  298. package/dist/orchestration/workflow-governance.js +2 -1
  299. package/dist/orchestration/workflow.d.ts +4 -0
  300. package/dist/orchestration/workflow.js +25 -4
  301. package/dist/prompts/default.d.ts +1 -10
  302. package/dist/prompts/default.js +0 -2
  303. package/dist/stores/file/background-agent-store.d.ts +1 -1
  304. package/dist/stores/file/background-agent-store.js +3 -1
  305. package/dist/stores/file/checkpoint-store.d.ts +127 -2
  306. package/dist/stores/file/checkpoint-store.js +19 -14
  307. package/dist/stores/file/file-history-store.d.ts +1 -1
  308. package/dist/stores/file/file-history-store.js +3 -1
  309. package/dist/stores/file/index.d.ts +4 -3
  310. package/dist/stores/file/index.js +17 -8
  311. package/dist/stores/file/mailbox-store.d.ts +1 -1
  312. package/dist/stores/file/mailbox-store.js +3 -1
  313. package/dist/stores/file/memory-store.d.ts +1 -1
  314. package/dist/stores/file/memory-store.js +3 -1
  315. package/dist/stores/file/session-policy-store.d.ts +1 -1
  316. package/dist/stores/file/session-policy-store.js +3 -1
  317. package/dist/stores/file/session-store.d.ts +1 -1
  318. package/dist/stores/file/session-store.js +3 -1
  319. package/dist/stores/file/shared-ledger.d.ts +26 -0
  320. package/dist/stores/file/shared-ledger.js +38 -9
  321. package/dist/stores/file/tool-result-store.d.ts +20 -2
  322. package/dist/stores/file/tool-result-store.js +74 -6
  323. package/dist/stores/file/usage-window-store.d.ts +1 -1
  324. package/dist/stores/file/usage-window-store.js +3 -1
  325. package/dist/stores/file/workflow-journal-store.d.ts +1 -11
  326. package/dist/stores/file/workflow-journal-store.js +3 -2
  327. package/dist/tools/fs/containment-face.d.ts +5 -0
  328. package/dist/tools/fs/encoding.d.ts +13 -4
  329. package/dist/tools/fs/encoding.js +17 -2
  330. package/dist/tools/fs/fs-bash-background-text.d.ts +7 -0
  331. package/dist/tools/fs/fs-bash-background-text.js +1 -0
  332. package/dist/tools/fs/fs-bash.d.ts +8 -4
  333. package/dist/tools/fs/fs-bash.js +26 -35
  334. package/dist/tools/fs/fs-pdf.d.ts +2 -2
  335. package/dist/tools/fs/fs-pdf.js +26 -21
  336. package/dist/tools/fs/fs-read.d.ts +5 -4
  337. package/dist/tools/fs/fs-read.js +35 -18
  338. package/dist/tools/fs/fs-search-tools.js +4 -1
  339. package/dist/tools/fs/fs-shared.d.ts +11 -13
  340. package/dist/tools/fs/fs-shared.js +11 -7
  341. package/dist/tools/fs/fs-write.js +5 -5
  342. package/dist/tools/fs/index.d.ts +14 -8
  343. package/dist/tools/fs/index.js +8 -4
  344. package/dist/tools/fs/read-floor.d.ts +44 -1
  345. package/dist/tools/fs/read-floor.js +35 -0
  346. package/dist/tools/fs/removal-targets.d.ts +9 -4
  347. package/dist/tools/fs/removal-targets.js +17 -9
  348. package/dist/tools/fs/search.d.ts +3 -3
  349. package/dist/tools/fs/search.js +4 -4
  350. package/dist/tools/monitor.d.ts +5 -4
  351. package/dist/tools/monitor.js +15 -8
  352. package/dist/tools/scheduler-tools.js +42 -4
  353. package/dist/tools/web.d.ts +0 -10
  354. package/dist/tools/web.js +1 -4
  355. package/package.json +4 -2
  356. package/test/export-surface.snapshot.json +75 -21
  357. package/wire-changes/core-stores-sql@7.60.0.json +30 -0
  358. package/wire-changes/core@7.60.0.json +3274 -0
  359. package/wire-changes/mods-kernel@7.60.0.json +62 -0
  360. package/wire-changes/primitives@7.60.0.json +30 -0
@@ -2,7 +2,7 @@ import type { ExecutionEnv } from "../../internal/harness-types.js";
2
2
  import type { AssistantMessage, Message, Model, Usage } from "../../internal/llm.js";
3
3
  import type { CwdRef } from "../../tools/fs/fs-shared.js";
4
4
  import { type PermissionResult, type ToolCallRequest } from "../tool-policy.js";
5
- import type { ClassicEventBase, HookInvocationIdentity, PermissionDeniedPayload, SubagentStartResult, UserPromptSubmitEvent } from "../hooks.js";
5
+ import type { ClassicEventBase, HookEnvCapabilities, HookInvocationIdentity, PermissionDeniedPayload, SubagentStartResult, UserPromptSubmitEvent } from "../hooks.js";
6
6
  import type { ClassicEventMap, ClassicEventName } from "./classic-events.js";
7
7
  import type { PermissionMode } from "../ask-origin.js";
8
8
  import type { RunnerDeps } from "../runner-deps.js";
@@ -77,31 +77,25 @@ export declare function sameModChain(a: readonly ModChainLink[], b: readonly Mod
77
77
  * screening constraint, and what a child's own gate stands in for when it mounted the same.
78
78
  */
79
79
  export declare function chainJudges(bus: LegModBus): boolean;
80
- /** Give a minted screening `policy` its installation — own, fixed and not enumerable, the object held in a closure no clone can re-point, so a copy or a wrapper of the policy carries none. Written only by the constraint mint (`createPreToolUseConstraintPolicy`). */
81
- export declare function withInstallation<P extends object>(policy: P, bus: LegModBus): P;
82
- /** The installation an inherited entry carries (its policy's own member, read off the descriptor: no getter or trap runs, and a
83
- * member minted on another object is not this one's), or `undefined` when the mint did not make the entry's policy. */
84
- export declare function installationOf(pc: {
85
- readonly policy: object;
86
- }): LegModBus | undefined;
87
80
  /** How an inherited installation's question is settled: under the context its installation froze (its approver, its durable
88
- * mandates, its classifier — the settlement its `classic.PreToolUse` ask takes in the fold), never at this leg's approver. An
89
- * allow carrying `updatedInput` is a person's approval of an edit; an ask is one the settlement floated (the call is marked for
90
- * the park). */
81
+ * mandates, its classifier), never at this leg's approver — whichever event raised it (`classic.PreToolUse` at the gate's phase
82
+ * 1, `tool.check` at its verdict read). An allow carrying `updatedInput` is a person's approval of an edit; an ask is one the
83
+ * settlement floated (the call is marked for the park). */
91
84
  export type InstallationAskSettlement = (ask: Extract<PermissionResult, {
92
85
  action: "ask";
93
86
  }>, call: ToolCallRequest, signal: AbortSignal | undefined) => Promise<PermissionResult>;
94
- /** An inherited installation as a leg's gate raises `tool.check` on it: the bus that mounted that chain, which of its handlers
95
- * judge here, and how its question is settled. */
96
- export interface InheritedToolCheck {
87
+ /** An inherited installation as a leg's gate raises its judging events on it (`classic.PreToolUse` at phase 1, `tool.check` at the
88
+ * verdict read): the bus that mounted that chain, which of its handlers judge here, the capability face of the environment it was
89
+ * installed against (the `env` of its `classic.PreToolUse` e), and how its question is settled. */
90
+ export interface InheritedInstallation {
97
91
  readonly bus: LegModBus;
98
92
  readonly judges: (p: ModParticipant) => boolean;
93
+ readonly env?: HookEnvCapabilities;
99
94
  readonly settle: InstallationAskSettlement;
100
95
  }
101
- /** An inherited chain entry as its installation identity reads it: the policy (whose mint names the bus, whose admission names
102
- * the chain), the approver it froze, its two durable mandates, the environment it was installed against, its classifier. */
96
+ /** An inherited chain entry as its installation identity reads it (the installation is absent on a caller-policy entry). */
103
97
  export interface InstallationEntry {
104
- readonly policy: object;
98
+ readonly installation?: LegModBus;
105
99
  readonly onAsk?: unknown;
106
100
  readonly durableMandate?: boolean;
107
101
  readonly contentMandate?: boolean;
@@ -121,52 +115,43 @@ export interface LegInstallation {
121
115
  readonly decider: unknown;
122
116
  }
123
117
  /**
124
- * Whether an inherited entry IS a leg's installation — the ONE installation identity. The chain is read off the entry's own
125
- * bus ({@link installationOf}, as that bus's admission recorded it), never off a list the entry carries: an entry
126
- * whose policy the mint did not make, or whose bus no engine admission mounted, is no leg's installation. The rest is the
127
- * context its questions are settled in: the same approver ({@link askApproverIdentity}), the same two durable mandates, the
128
- * same environment, the same classifier instance. Readers: chain assembly (a leg already on the chain is not appended again)
129
- * and {@link standsInFor} (the fold's pass-through and the `tool.check` raise).
118
+ * Whether an inherited entry IS a leg's installation — the ONE installation identity: the chain is read off the entry's own
119
+ * installation; a caller-policy entry, or one whose bus no engine admission mounted, is no leg's installation. The rest is
120
+ * the context its questions are settled in ({@link askApproverIdentity}, the two durable mandates, the environment, the classifier).
130
121
  */
131
122
  export declare function sameInstallation(pc: InstallationEntry, leg: LegInstallation): boolean;
132
123
  /**
133
124
  * Whether a leg's own gate stands in for an inherited entry: the leg's chain judges, and the entry is the leg's installation
134
125
  * settled with no durable mandate — its phase 1 then judges the call with the same chain, and its questions go to the same
135
- * approver under no mandate, so the entry adds nothing on either judging event. The fold's pass-through for the entry's
136
- * `classic.PreToolUse` and the skip of its `tool.check` raise are this one test (an entry it does not hold for is judged under
137
- * its own context on both: a second judgment, never a lost one).
126
+ * approver under no mandate, so the entry adds nothing on either judging event. Whether the gate raises the entry's
127
+ * `classic.PreToolUse` and `tool.check` is this one test (an entry it does not hold for is judged under its own context on both:
128
+ * a second judgment, never a lost one).
138
129
  */
139
130
  export declare function standsInFor(pc: InstallationEntry, leg: Omit<LegInstallation, "durableMandate" | "contentMandate">, legChainJudges: boolean): boolean;
140
- /** An inherited screening installation as the carrier check reads it: the bus its policy was minted over (absent when the mint
141
- * did not make the policy) and the chain the entry declares (its `mods`; absent when it declares none). The declaration is read
142
- * for one thing — a guard the leg cannot raise ({@link unraisableGuardsOf}); identity is read off the bus ({@link sameInstallation}). */
143
- export interface ScreeningInstallation {
144
- readonly bus: LegModBus | undefined;
145
- readonly chain: readonly ModChainLink[] | undefined;
146
- }
147
- /** The screening installations among a chain's entries, in the chain's order: every entry whose policy the mint made or that
148
- * declares a chain. */
149
- export declare function screeningInstallationsOf(entries: ReadonlyArray<{
150
- readonly policy: object;
151
- readonly mods?: readonly ModChainLink[];
152
- }>): readonly ScreeningInstallation[];
153
- /** Why an inherited chain cannot hold its guards, or `undefined`: an entry that names a judging `tool.check` handler beside a
154
- * policy the mint did not make has no bus to raise that guard on. Read where the chain enters a leg — before a resume's claim
155
- * and at the leg's prepare — so it is refused, never run without the guard. */
156
- export declare function unraisableGuardsOf(installations: readonly ScreeningInstallation[]): string | undefined;
157
131
  /**
158
- * The inherited installations a leg's gate raises `tool.check` on after its own bus — the rule's one home. Every entry whose
159
- * policy the mint made is one installation, raised whole in the chain's order (the order its `classic.PreToolUse` folds in),
160
- * except one the leg's own gate stands in for (`standsIn` — the fold's pass-through test, {@link standsInFor}). Raised whole
161
- * because a handler's answer depends on the chain it sits in (an outer handler may answer without calling `next`, or rule on
162
- * what an inner one answered), so a registration the leg also mounts in a chain of its own judges again inside the ancestor's
163
- * chain, as the PreToolUse constraint judges it (a second judgment, never a lost one). Each carries its entry's settlement of a
164
- * question (`settleOf`): an installation's `ask` goes where its PreToolUse ask goes. Observe handlers never take part (a
165
- * constraint carries no observer). An entry that cannot raise its guard is refused (`config.mods_invalid`, {@link unraisableGuardsOf}).
132
+ * Why an inherited chain cannot be held, or `undefined`. Every entry is ONE of two kinds — a caller policy (`policy`, folded into
133
+ * the leg's restriction chain) or a screening installation (`installation`, the bus an engine admission mounted: a leg's own, or
134
+ * {@link admitModChain}'s, whose judging events the leg's gate raises). An entry naming both, or neither, or an installation no
135
+ * engine admission mounted has no way to judge the leg's calls. Read where the chain enters a leg — before a resume's claim and
136
+ * at the leg's prepare — so it is refused, never run without the judgment.
137
+ */
138
+ export declare function chainEntryFault(entries: ReadonlyArray<{
139
+ readonly policy?: object;
140
+ readonly installation?: object;
141
+ }>): string | undefined;
142
+ /**
143
+ * The inherited installations a leg's gate judges its calls on after its own bus — the rule's one home, read by both judging
144
+ * events (`classic.PreToolUse` at phase 1, `tool.check` at the verdict read). Every screening entry is one installation, raised
145
+ * whole in the chain's order, except one the leg's own gate stands in for (`standsIn`, {@link standsInFor}). Raised whole because
146
+ * a handler's answer depends on the chain it sits in (an outer handler may answer without calling `next`, or rule on what an
147
+ * inner one answered), so a registration the leg also mounts in a chain of its own judges again inside the ancestor's chain (a
148
+ * second judgment, never a lost one). Each carries the environment face its installation was installed against (`envOf`) and
149
+ * its entry's settlement of a question (`settleOf`): an installation's `ask`, on either event, goes to the regime it froze.
150
+ * Observe handlers never take part. A chain with a malformed entry is refused (`config.mods_invalid`, {@link chainEntryFault}).
166
151
  */
167
- export declare function inheritedToolChecks<E extends InstallationEntry & {
168
- readonly mods?: readonly ModChainLink[];
169
- }>(entries: readonly E[], standsIn: (pc: E) => boolean, settleOf: (pc: E) => InstallationAskSettlement): readonly InheritedToolCheck[];
152
+ export declare function inheritedInstallations<E extends InstallationEntry & {
153
+ readonly policy?: object;
154
+ }>(entries: readonly E[], standsIn: (pc: E) => boolean, envOf: (pc: E) => HookEnvCapabilities | undefined, settleOf: (pc: E) => InstallationAskSettlement): readonly InheritedInstallation[];
170
155
  /** The members every classic `e` of a leg carries: the identity envelope, the delegated leg's `agentId`, the leg's observed mode. */
171
156
  export declare function classicEventBase(identity: HookInvocationIdentity | undefined, permissionMode?: PermissionMode): ClassicEventBase;
172
157
  /**
@@ -185,6 +170,7 @@ export declare function dispatchClassic<K extends ClassicEventName>(bus: LegModB
185
170
  readonly signal?: AbortSignal;
186
171
  readonly checkAnswer?: ModAnswerCheck;
187
172
  readonly ranks?: ModAnswerRanks;
173
+ readonly participant?: (p: ModParticipant) => boolean;
188
174
  }): Promise<ModDispatchOutcome | undefined>;
189
175
  /** The answer form of a classic event whose answer is an object of optional string members (`block`, `additionalContext`, …). */
190
176
  export declare function stringMembersAnswer(event: string, members: readonly string[]): (answer: unknown) => string | undefined;
@@ -192,10 +178,16 @@ export declare function stringMembersAnswer(event: string, members: readonly str
192
178
  export declare function stringMembersOf<M extends string>(answer: unknown, members: readonly M[]): {
193
179
  [K in M]?: string;
194
180
  };
195
- /** The clause a fail-closed station puts in its sentence for the handler that failed it: `crashed (extension "x" threw boom)`. */
181
+ /** The clause a fail-closed station puts in its sentence for the handler that failed it: `crashed (extension "x" threw boom)`
182
+ * — what it did, who it is and the bus's reason. */
196
183
  export declare function failedHandlerClause(f: Extract<ModDispatchOutcome, {
197
184
  kind: "failed";
198
185
  }>): string;
186
+ /** The clause without the bus's reason, `crashed (extension "x")`: for a sentence in place of a result the handler saw (its
187
+ * reason may quote that result; the reason is said on the report sink). */
188
+ export declare function failedHandlerName(f: Extract<ModDispatchOutcome, {
189
+ kind: "failed";
190
+ }>): string;
199
191
  /**
200
192
  * The PermissionDenied station: the leg's `classic.PermissionDenied` handlers, then a host's own raw observer (a host
201
193
  * driving the tool gate itself) as one more observe handler of the same event on a bus of its own — so every observer
@@ -374,10 +366,10 @@ export interface LegFacadeInput {
374
366
  export declare function legFacadeSeats(input: LegFacadeInput): LegFacadeSeats;
375
367
  /**
376
368
  * A chain admitted outside any leg — what a host rebuilds to re-supply an inherited screening entry on a fresh Runner
377
- * (a cross-process resume hands back `createPreToolUseConstraintPolicy(chain, env)` over the same registrations). The
378
- * same admission a leg runs (both seats, `plugin.register`); no leg exists, so its `$` facade is never bound and a `$`
379
- * call throws. Handler failures go to `onError` (absent ⇒ unreported). Its chain identity is recorded as a leg's is
380
- * ({@link chainOfBus}), so an entry minted over it is read by what it mounted — whatever list the entry carries.
369
+ * (a cross-process resume hands back `{ installation: await admitModChain(…), hookEnv, …regime }` over the same
370
+ * registrations). The same admission a leg runs (both seats, `plugin.register`); no leg exists, so its `$` facade is never
371
+ * bound and a `$` call throws. Handler failures go to `onError` (absent ⇒ unreported). Its chain identity is recorded as a
372
+ * leg's is ({@link chainOfBus}), so an entry carrying it is read by what it mounted.
381
373
  */
382
374
  export declare function admitModChain(seats: {
383
375
  readonly deployment?: readonly ModRegistration<EngineDollar>[];
@@ -2,10 +2,9 @@ import { types } from "node:util";
2
2
  import { resolveModel } from "../roles.js";
3
3
  import { brainToRuntime } from "../runtime.js";
4
4
  import { deliverEngineNotice } from "../engine-notice.js";
5
- import { inlineUntrusted } from "../untrusted-text.js";
6
5
  import { extensionWords } from "../untrusted-egress.js";
7
6
  import { askApproverIdentity, describeThrown, ownArgs } from "../tool-policy.js";
8
- import { admitMods, expandModPattern } from "./kernel/index.js";
7
+ import { admitMods } from "./kernel/index.js";
9
8
  import { legBusOf } from "./extension-call.js";
10
9
  import { validateOverlay } from "../../prompt-assembly/overlay.js";
11
10
  import { modsInvalid } from "./kernel/registration.js";
@@ -74,19 +73,8 @@ const judgesCall = (p) => !p.observe;
74
73
  export function chainJudges(bus) {
75
74
  return bus.hasHandlers("classic.PreToolUse", judgesCall) || bus.hasHandlers("tool.check", judgesCall);
76
75
  }
77
- const INSTALLATION = Symbol("installation");
78
- export function withInstallation(policy, bus) {
79
- return Object.defineProperty(policy, INSTALLATION, { value: Object.freeze({ bus, mintedAs: (o) => o === policy }) });
80
- }
81
- export function installationOf(pc) {
82
- const p = pc.policy;
83
- if (p === null || p === undefined || types.isProxy(p))
84
- return undefined;
85
- const minted = Object.getOwnPropertyDescriptor(p, INSTALLATION)?.value;
86
- return minted !== undefined && minted.mintedAs(p) ? minted.bus : undefined;
87
- }
88
76
  export function sameInstallation(pc, leg) {
89
- const bus = installationOf(pc);
77
+ const bus = pc.installation;
90
78
  const chain = bus !== undefined ? chainOfBus(bus) : undefined;
91
79
  return (chain !== undefined &&
92
80
  sameModChain(chain, leg.chain) &&
@@ -99,33 +87,31 @@ export function sameInstallation(pc, leg) {
99
87
  export function standsInFor(pc, leg, legChainJudges) {
100
88
  return legChainJudges && sameInstallation(pc, { ...leg, durableMandate: false, contentMandate: false });
101
89
  }
102
- const judgesToolCheck = (h) => {
103
- const selected = expandModPattern(h.pattern);
104
- return !h.observe && "names" in selected && selected.names.includes("tool.check");
105
- };
106
- export function screeningInstallationsOf(entries) {
107
- return entries.flatMap((pc) => {
108
- const bus = installationOf(pc);
109
- return bus !== undefined || pc.mods !== undefined ? [{ bus, chain: pc.mods }] : [];
110
- });
111
- }
112
- export function unraisableGuardsOf(installations) {
113
- const guards = installations.flatMap((i) => (i.bus !== undefined ? [] : (i.chain ?? []).filter((l) => l.handlers.some(judgesToolCheck)).map((l) => `"${inlineUntrusted(l.registration.name, 80)}"`)));
114
- return guards.length === 0 ? undefined : `an inherited screening entry names the tool.check guard of ${guards.join(", ")}, but its policy is not one createPreToolUseConstraintPolicy minted, so the guard has no chain to judge this leg's calls on — hand the minted policy back as it is`;
90
+ export function chainEntryFault(entries) {
91
+ for (const [i, pc] of entries.entries()) {
92
+ const policy = pc.policy !== undefined;
93
+ const installation = pc.installation;
94
+ if (policy === (installation !== undefined))
95
+ return `inherited chain entry ${i} carries ${policy ? "both a policy and an installation" : "neither a policy nor an installation"} — an entry is either a caller policy or a screening installation`;
96
+ if (installation !== undefined && chainOfBus(installation) === undefined)
97
+ return `inherited chain entry ${i}'s installation is not a chain an engine admission mounted — rebuild it with admitModChain over the same registrations`;
98
+ }
99
+ return undefined;
115
100
  }
116
101
  const judges = (p) => judgesCall(p);
117
- export function inheritedToolChecks(entries, standsIn, settleOf) {
118
- const unraisable = unraisableGuardsOf(screeningInstallationsOf(entries));
119
- if (unraisable !== undefined)
120
- throw modsInvalid(unraisable);
121
- const checks = [];
102
+ export function inheritedInstallations(entries, standsIn, envOf, settleOf) {
103
+ const fault = chainEntryFault(entries);
104
+ if (fault !== undefined)
105
+ throw modsInvalid(fault);
106
+ const installations = [];
122
107
  for (const pc of entries) {
123
- const bus = installationOf(pc);
124
- if (bus === undefined || standsIn(pc) || !bus.hasHandlers("tool.check", judges))
108
+ const bus = pc.installation;
109
+ if (bus === undefined || standsIn(pc) || !chainJudges(bus))
125
110
  continue;
126
- checks.push(Object.freeze({ bus, judges, settle: settleOf(pc) }));
111
+ const env = envOf(pc);
112
+ installations.push(Object.freeze({ bus, judges, ...(env !== undefined ? { env } : {}), settle: settleOf(pc) }));
127
113
  }
128
- return Object.freeze(checks);
114
+ return Object.freeze(installations);
129
115
  }
130
116
  export function classicEventBase(identity, permissionMode) {
131
117
  const agentId = agentIdOf(identity);
@@ -145,11 +131,12 @@ export async function observeClassic(bus, event, e, signal) {
145
131
  }
146
132
  }
147
133
  export async function dispatchClassic(bus, event, e, options) {
148
- if (!bus.hasHandlers(event))
134
+ if (!bus.hasHandlers(event, options.participant))
149
135
  return undefined;
150
136
  const check = options.checkAnswer;
151
137
  return await bus.dispatch(event, e, {
152
138
  bottom: engineCore,
139
+ ...(options.participant !== undefined ? { participant: options.participant } : {}),
153
140
  ...(options.signal !== undefined ? { signal: options.signal } : {}),
154
141
  ...(check !== undefined ? { checkAnswer: (a, ce, by, below, run) => (a === ENGINE_CORE_ANSWER ? undefined : check(a, ce, by, below, run)) } : {}),
155
142
  ...(options.ranks !== undefined ? { ranks: options.ranks } : {}),
@@ -181,13 +168,16 @@ export function stringMembersOf(answer, members) {
181
168
  return out;
182
169
  }
183
170
  const FAILURE_CLAUSE = Object.freeze({
184
- threw: (who, why) => `crashed (extension "${who}" ${why})`,
185
- timeout: (who, why) => `did not answer (extension "${who}" ${why})`,
186
- violation: (who, why) => `gave an answer the station cannot take (extension "${who}" ${why})`,
187
- reentry: (who, why) => `was skipped on re-entry and its .catch did not answer (extension "${who}" ${why})`,
171
+ threw: (who, tail) => `crashed (extension "${who}"${tail})`,
172
+ timeout: (who, tail) => `did not answer (extension "${who}"${tail})`,
173
+ violation: (who, tail) => `gave an answer the station cannot take (extension "${who}"${tail})`,
174
+ reentry: (who, tail) => `was skipped on re-entry and its .catch did not answer (extension "${who}"${tail})`,
188
175
  });
189
176
  export function failedHandlerClause(f) {
190
- return FAILURE_CLAUSE[f.cause](extensionWords(f.registration, 80), extensionWords(f.reason, 200));
177
+ return FAILURE_CLAUSE[f.cause](extensionWords(f.registration, 80), ` ${extensionWords(f.reason, 200)}`);
178
+ }
179
+ export function failedHandlerName(f) {
180
+ return FAILURE_CLAUSE[f.cause](extensionWords(f.registration, 80), "");
191
181
  }
192
182
  export async function observePermissionDenied(input) {
193
183
  const { payload, hostObserver } = input;
@@ -1,20 +1,22 @@
1
1
  /**
2
2
  * The `tool.call` station: raised on the leg's bus between the gate letting a call go and the tool's body, for every
3
3
  * execution of a call (the live loop's lanes through the loop's execution seat, the resumed leg's approved call through
4
- * the same function). The chain's bottom is the tool's body; the event's failure column is `refuse_until_run`, so a
5
- * handler's failure refuses the call while the body has not started and, once it has, the body's real result stands.
4
+ * the same function). The chain's bottom is the tool's body; the event's failure column is `refuse`, so a handler's
5
+ * failure refuses the call while the body has not started and, once it has, WITHHOLDS the body's result: the call ran (its
6
+ * record is a call the gate let go, with no `notExecuted`), and the model is told a hook that checks the result could not
7
+ * hand back its answer instead of the result.
6
8
  *
7
9
  * `e = { tool, tool_use_id, agentId?, input }` (all four pinned — what the gate judged is what runs; a rewrite belongs to
8
10
  * `classic.PreToolUse`) plus the identity envelope; a handler may hand on `requestMeta` too (a record of strings an MCP call carries
9
11
  * as `_meta["sema/requestMeta"]`, judged where it is handed on — `mcp-call-meta.ts`). A handler answers:
10
12
  * - `next(e)` — the body runs; what came up is `{ result: { content, isError } }`, a frozen view of the real result;
11
13
  * - `{ deny: <reason> }` — refused before the body: the call is not executed and the record says an extension refused it
12
- * (a deny once the body has started stands in place of a call that ran: a violation, the real result stands);
14
+ * (a deny once the body has started cannot stand in place of a call that ran: a violation, and the result is withheld);
13
15
  * - `{ result }` — an extension's own result in place of the body (a string, or a list of text blocks), taken only when
14
16
  * both facts hold: the gate let this call go without anyone being asked about it (its latest gate record is an allow
15
17
  * with no settlement, release or clearance — a person's or a rule's yes is a yes to running the tool), and the body
16
18
  * has not started (the kernel's own record). Either missing, the answer is a violation: before the body the call is
17
- * refused, after it the real result stands. A taken result is the call's result; the record says the body never ran
19
+ * refused, after it the result is withheld. A taken result is the call's result; the record says the body never ran
18
20
  * and names the extension (`tool_end.notExecuted`, `tool_end.answeredBy`).
19
21
  * Context for the model is added at `classic.PostToolUse`, not here. Whatever an extension answered in place of the body,
20
22
  * the call's post-execution stations stay silent, as for a call the gate blocked.
@@ -31,6 +33,7 @@ import type { HookInvocationIdentity } from "../hooks.js";
31
33
  import type { ToolOccurrenceTable } from "../runner/tool-occurrence.js";
32
34
  import { type McpRequestMetaSeat } from "../mcp-call-meta.js";
33
35
  import { type LegModBus } from "./stations.js";
36
+ import { type FrameSettlement } from "../frame-settlement.js";
34
37
  import type { ModBus, ModCallEntry } from "./kernel/index.js";
35
38
  /** One execution as the station sees it: the call, the tool that runs (its mounted name), the arguments the gate let go. */
36
39
  export interface ToolCallExecution {
@@ -50,6 +53,9 @@ export interface ToolCallStationInput {
50
53
  readonly reminderMark?: string;
51
54
  /** The leg's request-meta seat: what the chain handed on as `requestMeta` stands under the call's id while its body runs. */
52
55
  readonly requestMeta: Pick<McpRequestMetaSeat, "hold">;
56
+ /** The leg's settlement seam: a result this station withholds settles the frames it carried as withheld by the host side
57
+ * (`settleWithheldResult`), so none is owed again through another lane. Absent ⇒ no frame rides a call of this station. */
58
+ readonly frameSettlement?: FrameSettlement;
53
59
  }
54
60
  /** The station over the leg's bus, or undefined when no handler hangs on `tool.call` (nothing is raised; the body runs). */
55
61
  export declare function createToolCallStation(input: ToolCallStationInput): ToolCallStation | undefined;
@@ -7,8 +7,9 @@ import { readHandedRequestMeta } from "../mcp-call-meta.js";
7
7
  import { ENGINE_ORIGIN } from "./kernel/index.js";
8
8
  import { isPlainRecord } from "./kernel/receive.js";
9
9
  import { NEXT_IN_FLIGHT } from "./kernel/site-rules.js";
10
- import { classicEventBase, failedHandlerClause, judgedInputOf } from "./stations.js";
10
+ import { classicEventBase, failedHandlerClause, failedHandlerName, judgedInputOf } from "./stations.js";
11
11
  import { runExtensionCall } from "./extension-call.js";
12
+ import { settleWithheldResult } from "../frame-settlement.js";
12
13
  import { randomUUID } from "node:crypto";
13
14
  const FORM = "tool.call takes next(e), { deny: <reason> } or { result } (a string, or a list of text blocks)";
14
15
  const denyOf = (a) => isPlainRecord(a) && Object.keys(a).length === 1 && typeof a["deny"] === "string" && a["deny"] !== "" ? a["deny"] : undefined;
@@ -49,13 +50,18 @@ const RANKS = Object.freeze({ of: (a) => (denyOf(a) !== undefined ? 1 : 0), top:
49
50
  export function createToolCallStation(input) {
50
51
  if (!input.bus.hasHandlers("tool.call"))
51
52
  return undefined;
52
- const refusal = (call, by, text) => {
53
- if (input.occurrences.get(call.toolCallId) !== undefined) {
54
- input.occurrences.refuse(call.toolCallId, "hook", by);
55
- input.occurrences.answeredInPlace(call.toolCallId, by);
53
+ const stationAnswer = (call, by, text) => {
54
+ const content = [{ type: "text", text: formatHookFeedback(text, input.reminderMark) }];
55
+ if (by !== undefined) {
56
+ if (input.occurrences.get(call.toolCallId) !== undefined) {
57
+ input.occurrences.refuse(call.toolCallId, "hook", by);
58
+ input.occurrences.answeredInPlace(call.toolCallId, by);
59
+ }
60
+ input.blockedToolCalls.add(call.toolCallId);
56
61
  }
57
- input.blockedToolCalls.add(call.toolCallId);
58
- return { content: [{ type: "text", text: formatHookFeedback(text, input.reminderMark) }], details: {}, isError: true };
62
+ else if (input.frameSettlement !== undefined)
63
+ settleWithheldResult(input.frameSettlement, call.toolCallId, content);
64
+ return { content, details: {}, isError: true };
59
65
  };
60
66
  return async (call, run, signal) => {
61
67
  const e = { ...classicEventBase(input.identity), tool: call.toolName, tool_use_id: call.toolCallId, input: judgedInputOf(call.args) };
@@ -83,7 +89,7 @@ export function createToolCallStation(input) {
83
89
  if (!denied && substituteOf(a) === undefined)
84
90
  return FORM;
85
91
  if (ran.bottomStarted)
86
- return `a ${denied ? "deny" : "result"} after the tool started (once the tool runs, only its own outcome stands)`;
92
+ return `a ${denied ? "deny" : "result"} after the tool started (once the tool runs, nothing answers in its place)`;
87
93
  if (denied)
88
94
  return below.some((b) => denyOf(b) === undefined) ? "a deny while its next(e) still runs or after it was answered (deny in place of next)" : undefined;
89
95
  if (below.includes(NEXT_IN_FLIGHT))
@@ -97,7 +103,7 @@ export function createToolCallStation(input) {
97
103
  catch (err) {
98
104
  if (body !== undefined)
99
105
  return body;
100
- return refusal(call, ENGINE_ORIGIN.plugin, `the tool.call station could not be raised (${describeThrown(err)}); this call to "${extensionWords(call.toolName, 80)}" was NOT executed (fail-closed)`);
106
+ return stationAnswer(call, ENGINE_ORIGIN.plugin, `the tool.call station could not be raised (${describeThrown(err)}); this call to "${extensionWords(call.toolName, 80)}" was NOT executed (fail-closed)`);
101
107
  }
102
108
  if (outcome.kind === "aborted") {
103
109
  if (body !== undefined)
@@ -105,7 +111,17 @@ export function createToolCallStation(input) {
105
111
  return { content: [{ type: "text", text: "Operation aborted" }], details: {}, isError: true };
106
112
  }
107
113
  if (outcome.kind === "failed") {
108
- return refusal(call, outcome.registration, `a tool.call extension ${failedHandlerClause(outcome)} before this call to "${extensionWords(call.toolName, 80)}" ran; the call was NOT executed (fail-closed)`);
114
+ if (outcome.bottomStarted === true && body !== undefined) {
115
+ try {
116
+ await body;
117
+ }
118
+ catch {
119
+ return body;
120
+ }
121
+ }
122
+ if (outcome.bottomStarted === true)
123
+ return stationAnswer(call, undefined, `a tool.call extension ${failedHandlerName(outcome)} after this call to "${extensionWords(call.toolName, 80)}" ran: a hook that checks this result could not hand back its answer, so the result is withheld — the call ran (fail-closed)`);
124
+ return stationAnswer(call, outcome.registration, `a tool.call extension ${failedHandlerClause(outcome)} before this call to "${extensionWords(call.toolName, 80)}" ran; the call was NOT executed (fail-closed)`);
109
125
  }
110
126
  const answer = outcome.answer;
111
127
  const ran = typeof answer === "object" && answer !== null ? bodies.get(answer) : undefined;
@@ -114,10 +130,10 @@ export function createToolCallStation(input) {
114
130
  const by = outcome.answeredBy ?? ENGINE_ORIGIN.plugin;
115
131
  const reason = denyOf(answer);
116
132
  if (reason !== undefined)
117
- return refusal(call, by, `extension "${extensionWords(by, 80)}" refused this call to "${extensionWords(call.toolName, 80)}" before it ran: ${extensionWords(reason, 300)}`);
133
+ return stationAnswer(call, by, `extension "${extensionWords(by, 80)}" refused this call to "${extensionWords(call.toolName, 80)}" before it ran: ${extensionWords(reason, 300)}`);
118
134
  const content = substituteOf(answer);
119
135
  if (content === undefined)
120
- return refusal(call, by, `extension "${extensionWords(by, 80)}" answered this call in a form tool.call does not take; the call was NOT executed (fail-closed)`);
136
+ return stationAnswer(call, by, `extension "${extensionWords(by, 80)}" answered this call in a form tool.call does not take; the call was NOT executed (fail-closed)`);
121
137
  if (input.occurrences.get(call.toolCallId) !== undefined)
122
138
  input.occurrences.answeredInPlace(call.toolCallId, by);
123
139
  input.blockedToolCalls.add(call.toolCallId);
@@ -10,6 +10,7 @@
10
10
  import type { McpServerSpec } from "./mcp-server-spec.js";
11
11
  import type { ToolContentOrigin } from "./tool-spec.js";
12
12
  import type { McpConnectionPool } from "./mcp-connection-pool.js";
13
+ import type { McpHostSeat } from "./mcp-host-seat.js";
13
14
  import type { McpInstructionsEntry } from "./prompt-section-seat.js";
14
15
  /** The two names a server's `allowTools` carries to let the cross-server resource readers reach its resources (a server whose allowlist omits one is left out of that reader). */
15
16
  export declare const MCP_RESOURCE_LIST_ALLOW = "list_resources";
@@ -18,6 +19,7 @@ export declare const MCP_RESOURCE_READ_ALLOW = "read_resource";
18
19
  export declare const LIST_MCP_RESOURCES = "ListMcpResourcesTool";
19
20
  export declare const READ_MCP_RESOURCE = "ReadMcpResourceTool";
20
21
  export declare const READ_MCP_RESOURCE_DIR = "ReadMcpResourceDirTool";
22
+ export declare const MCP_RESOURCE_FACES: readonly string[];
21
23
  /** Does the valve (`leaves`: its one predicate) leave at least one of the cross-server resource tools? While it does, a connected server may contribute to them whatever it lists. */
22
24
  export declare function resourceFacesLeft(leaves: (tool: {
23
25
  readonly name: string;
@@ -76,6 +78,8 @@ export interface MountedMcp {
76
78
  readonly aggregate: ReadonlyArray<string>;
77
79
  /** The run tree's connection pool: a child that inherits the mount leases its connections from it. */
78
80
  readonly pool?: McpConnectionPool;
81
+ /** The run's host seats by declaration name: a child declared a host-transport server (inherited or its definition's own) is handed that server's seat. */
82
+ readonly hostSeats?: ReadonlyMap<string, McpHostSeat>;
79
83
  }
80
84
  /** A roster entry as far as this reading goes. */
81
85
  interface RosterEntry {
@@ -101,6 +105,7 @@ export declare function mountedMcpOf(input: {
101
105
  readonly roster: ReadonlyArray<RosterEntry>;
102
106
  readonly aggregateNames: ReadonlySet<string>;
103
107
  readonly pool?: McpConnectionPool;
108
+ readonly hostSeats?: ReadonlyMap<string, McpHostSeat>;
104
109
  }): MountedMcp;
105
110
  /**
106
111
  * The MCP tools of a mount as pool rows (name and the server's declared content class) — what the memory content-origin face adds to
@@ -5,7 +5,7 @@ export const MCP_RESOURCE_READ_ALLOW = "read_resource";
5
5
  export const LIST_MCP_RESOURCES = "ListMcpResourcesTool";
6
6
  export const READ_MCP_RESOURCE = "ReadMcpResourceTool";
7
7
  export const READ_MCP_RESOURCE_DIR = "ReadMcpResourceDirTool";
8
- const MCP_RESOURCE_FACES = [LIST_MCP_RESOURCES, READ_MCP_RESOURCE, READ_MCP_RESOURCE_DIR];
8
+ export const MCP_RESOURCE_FACES = Object.freeze([LIST_MCP_RESOURCES, READ_MCP_RESOURCE, READ_MCP_RESOURCE_DIR]);
9
9
  export function resourceFacesLeft(leaves) {
10
10
  return MCP_RESOURCE_FACES.some((name) => leaves({ name }));
11
11
  }
@@ -78,7 +78,7 @@ export function mountedMcpOf(input) {
78
78
  return { server, tools };
79
79
  });
80
80
  const aggregate = input.roster.filter((t) => input.aggregateNames.has(t.name)).map((t) => t.name);
81
- return { servers, aggregate, ...(input.pool !== undefined ? { pool: input.pool } : {}) };
81
+ return { servers, aggregate, ...(input.pool !== undefined ? { pool: input.pool } : {}), ...(input.hostSeats !== undefined ? { hostSeats: input.hostSeats } : {}) };
82
82
  }
83
83
  export function mountedMcpPoolRows(mounted) {
84
84
  return [
@@ -30,6 +30,12 @@ export declare function wildcardMatch(pattern: string, value: string): boolean;
30
30
  * that is no behavior word (an array index handed by `filter`, say) is refused loudly, never read as either list.
31
31
  */
32
32
  export declare function isCoveringRuleName(name: string, behavior: RuleBehavior): boolean;
33
+ /**
34
+ * The part of {@link isCoveringRuleName} that is a fact about the NAME alone: the name reaches a SET of tool names whatever list it
35
+ * is written in (a `*` it reads, or a bare protocol peer). A stored rule names ONE tool, so its grammar asks only this — a tool name
36
+ * that a restricting list also reads as another server's spelling ({@link peerReadingsOf}) is still one tool's name there.
37
+ */
38
+ export declare function namesASetOfTools(name: string, behavior: RuleBehavior): boolean;
33
39
  /**
34
40
  * Does a covering rule name ({@link isCoveringRuleName}) cover `toolName`? A name with a `*` is a glob over the WHOLE name
35
41
  * ({@link wildcardMatch} — the reference's `p` matcher): `mcp__srv__get_*` reaches `mcp__srv__get_issue`, `mcp__*` every MCP tool,
@@ -46,4 +52,4 @@ export declare function ruleNameCovers(ruleName: string, toolName: string): bool
46
52
  * minted under the peer is then matched by the glob up to its last `*`, which takes the rest; a glob that does not end in `*` leaves
47
53
  * a tool name it does not match. The one reading of a name against a peer that the tool-name lists take.
48
54
  */
49
- export declare function ruleNameReachIntoPeer(ruleName: string, ns: ProtocolNamespace, peer: string): "all" | "some" | "none";
55
+ export declare function ruleNameReachIntoPeer(ruleName: string, ns: ProtocolNamespace, peer: string, readsOtherServers?: boolean): "all" | "some" | "none";
@@ -1,4 +1,4 @@
1
- import { grantWildcardRefusalOf, readsNameGlob, splitNamespacedName } from "./tool-name-aliases.js";
1
+ import { grantWildcardRefusalOf, peerReadingsOf, readsNameGlob, splitNamespacedName } from "./tool-name-aliases.js";
2
2
  export function wildcardMatch(pattern, value) {
3
3
  const first = pattern.indexOf("*");
4
4
  if (first < 0)
@@ -28,6 +28,9 @@ function namespacedPeerOf(name) {
28
28
  return split === undefined || split.peer === "" ? undefined : split;
29
29
  }
30
30
  export function isCoveringRuleName(name, behavior) {
31
+ return namesASetOfTools(name, behavior) || (readsNameGlob(behavior) && peerReadingsOf(name).length > 0);
32
+ }
33
+ export function namesASetOfTools(name, behavior) {
31
34
  if (behavior !== "deny" && behavior !== "ask" && behavior !== "allow") {
32
35
  throw new TypeError(`isCoveringRuleName: the list's behavior must be "deny", "ask" or "allow" (got ${typeof behavior === "string" ? JSON.stringify(behavior) : typeof behavior}) — a "*" in a name reads one way on a list that restricts and another on one that grants`);
33
36
  }
@@ -39,19 +42,27 @@ export function isCoveringRuleName(name, behavior) {
39
42
  export function ruleNameCovers(ruleName, toolName) {
40
43
  if (ruleName.includes("*"))
41
44
  return wildcardMatch(ruleName, toolName);
45
+ const readings = peerReadingsOf(ruleName);
46
+ if (readings.length > 0) {
47
+ const target = namespacedPeerOf(toolName);
48
+ return target !== undefined && readings.some((r) => r.ns.id === target.ns.id && r.peer === target.peer && (r.tool === undefined || r.tool === target.tool));
49
+ }
42
50
  const rule = namespacedPeerOf(ruleName);
43
51
  if (rule === undefined || rule.tool !== undefined)
44
52
  return false;
45
53
  const target = namespacedPeerOf(toolName);
46
54
  return target !== undefined && target.ns.id === rule.ns.id && target.peer === rule.peer;
47
55
  }
48
- export function ruleNameReachIntoPeer(ruleName, ns, peer) {
56
+ export function ruleNameReachIntoPeer(ruleName, ns, peer, readsOtherServers = false) {
49
57
  if (ruleName.includes("*")) {
50
58
  if (ruleName.endsWith("*") && wildcardMatch(ruleName, `${ns.prefix}${peer}__`))
51
59
  return "all";
52
60
  const rule = namespacedPeerOf(ruleName);
53
61
  return rule !== undefined && rule.ns.id === ns.id && rule.peer === peer ? "some" : "none";
54
62
  }
63
+ const readings = readsOtherServers ? peerReadingsOf(ruleName).filter((r) => r.ns.id === ns.id && r.peer === peer) : [];
64
+ if (readings.length > 0)
65
+ return readings.some((r) => r.tool === undefined) ? "all" : "some";
55
66
  const rule = namespacedPeerOf(ruleName);
56
67
  if (rule === undefined || rule.ns.id !== ns.id || rule.peer !== peer)
57
68
  return "none";
@@ -6,7 +6,7 @@ function probeCommand(canonOraclePath) {
6
6
  return `touch -- ${q}/.oracle-isolation-probe 2>/dev/null`;
7
7
  }
8
8
  export async function assertOracleIsolation(workerEnv, grader, opts) {
9
- const isolationClass = isIsolated(grader.env)
9
+ const isolationClass = isIsolated(grader.env) && isRemoteExecutionEnv(grader.env)
10
10
  ? "out_of_process"
11
11
  : "in_process_probe_only";
12
12
  if (grader.env === workerEnv) {
@@ -27,5 +27,8 @@ export declare const CONFIG_RECEIPT_MODE: ReceiptMode;
27
27
  * itself, a container nested deeper — a shared one measured where it sits each time it is met), every copied container frozen.
28
28
  */
29
29
  export declare const DECLARATION_RECEIPT_MODE: ReceiptMode;
30
+ /** The OPTIONS DOOR — a constructor's options bag received by the receipt law, absent ⇒ an empty one: every option the constructor reads
31
+ * is read off this copy, once, and the caller's bag is never read again (a store keeps no hold of it). `owner` names the constructor. */
32
+ export declare function receiveOptions<T extends object>(given: T | undefined, owner: string): T;
30
33
  /** Read `given` by the receipt law (module note): the plain copy, every own member taken once from its captured descriptor. */
31
34
  export declare function receiveOwnProperties<T extends object>(given: T, words: OwnPropertyReceiptWords): T;
@@ -12,6 +12,9 @@ export function refuseProxy(given, words) {
12
12
  }
13
13
  export const CONFIG_RECEIPT_MODE = Object.freeze({ accessors: "call-once", depth: 1, others: "as-is", isProxy: (v) => types.isProxy(v) });
14
14
  export const DECLARATION_RECEIPT_MODE = Object.freeze({ accessors: "call-once", depth: MODS_VALUE_DEPTH + 1, others: "refuse", freeze: true, isProxy: (v) => types.isProxy(v) });
15
+ export function receiveOptions(given, owner) {
16
+ return given === undefined ? {} : receiveOwnProperties(given, { subject: `${owner} options`, unit: "option", moment: `at new ${owner}` });
17
+ }
15
18
  export function receiveOwnProperties(given, words) {
16
19
  refuseProxy(given, words);
17
20
  if (!isPlainRecord(given)) {