@sema-agent/core 7.67.3 → 7.68.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 (496) hide show
  1. package/CHANGELOG.md +1516 -0
  2. package/README.md +18 -9
  3. package/README.zh-CN.md +16 -8
  4. package/dist/agents/agent-definition.d.ts +1 -1
  5. package/dist/agents/agent-definition.js +4 -1
  6. package/dist/agents/cascade.d.ts +2 -2
  7. package/dist/agents/cascade.js +3 -1
  8. package/dist/agents/cumulative-stats.d.ts +2 -1
  9. package/dist/agents/cumulative-stats.js +4 -1
  10. package/dist/agents/list-agents-tool.d.ts +30 -0
  11. package/dist/agents/list-agents-tool.js +45 -3
  12. package/dist/agents/peer-admission.d.ts +2 -2
  13. package/dist/agents/peer-session-drain.d.ts +2 -0
  14. package/dist/agents/peer-session-drain.js +1 -0
  15. package/dist/agents/repair-loop.js +3 -1
  16. package/dist/agents/retain-ledger.d.ts +61 -8
  17. package/dist/agents/retain-ledger.js +25 -3
  18. package/dist/agents/roster-store.d.ts +4 -2
  19. package/dist/agents/send-message-tool.d.ts +1 -1
  20. package/dist/agents/send-message-tool.js +20 -15
  21. package/dist/agents/subagent-steps.js +2 -10
  22. package/dist/agents/subagent.d.ts +3 -0
  23. package/dist/agents/subagent.js +106 -76
  24. package/dist/agents/tool-filter.d.ts +20 -11
  25. package/dist/agents/tool-filter.js +8 -4
  26. package/dist/agents/verify.d.ts +3 -1
  27. package/dist/agents/verify.js +2 -0
  28. package/dist/brain/anthropic.js +4 -4
  29. package/dist/brain/open-responses.js +3 -1
  30. package/dist/brain/openai.js +3 -1
  31. package/dist/brain/reasoning-request.d.ts +73 -19
  32. package/dist/brain/reasoning-request.js +164 -72
  33. package/dist/brain/reasoning-stamp.d.ts +26 -0
  34. package/dist/brain/reasoning-stamp.js +10 -0
  35. package/dist/brain/reasoning.d.ts +95 -162
  36. package/dist/brain/reasoning.js +31 -86
  37. package/dist/brain/route-adjudicator.d.ts +9 -7
  38. package/dist/brain/route-adjudicator.js +12 -10
  39. package/dist/brain/status-sink.d.ts +19 -64
  40. package/dist/brain/status-sink.js +5 -21
  41. package/dist/brain/stream-engine.d.ts +11 -2
  42. package/dist/brain/stream-engine.js +10 -0
  43. package/dist/core/a2a.d.ts +17 -5
  44. package/dist/core/a2a.js +11 -3
  45. package/dist/core/allow-entry.d.ts +35 -15
  46. package/dist/core/allow-entry.js +47 -60
  47. package/dist/core/ask-headline.d.ts +68 -0
  48. package/dist/core/ask-headline.js +23 -0
  49. package/dist/core/ask-origin.d.ts +36 -8
  50. package/dist/core/ask-origin.js +17 -10
  51. package/dist/core/ask-question.d.ts +34 -7
  52. package/dist/core/ask-question.js +10 -1
  53. package/dist/core/ask-unresolvable-notice.d.ts +7 -0
  54. package/dist/core/ask-unresolvable-notice.js +9 -3
  55. package/dist/core/auto-strip.d.ts +53 -0
  56. package/dist/core/auto-strip.js +76 -0
  57. package/dist/core/background-agent-store.d.ts +45 -5
  58. package/dist/core/background-agent-store.js +69 -15
  59. package/dist/core/background-shell.d.ts +2 -2
  60. package/dist/core/caller-text.js +2 -2
  61. package/dist/core/canonical-json.d.ts +13 -0
  62. package/dist/core/canonical-json.js +7 -0
  63. package/dist/core/checkpoint-features.d.ts +66 -20
  64. package/dist/core/checkpoint-features.js +12 -1
  65. package/dist/core/checkpoint-generation.d.ts +1 -1
  66. package/dist/core/checkpoint-queries.d.ts +1 -1
  67. package/dist/core/checkpoint-queries.js +4 -1
  68. package/dist/core/checkpoint-requirements.d.ts +25 -1
  69. package/dist/core/checkpoint-requirements.js +5 -1
  70. package/dist/core/checkpoint-row-verdict.d.ts +1 -0
  71. package/dist/core/checkpoint-row-verdict.js +4 -0
  72. package/dist/core/checkpoint-store.d.ts +66 -38
  73. package/dist/core/checkpoint-store.js +15 -6
  74. package/dist/core/child-clamp-seats.d.ts +6 -0
  75. package/dist/core/child-clamp-seats.js +1 -0
  76. package/dist/core/config-refusal-codes.d.ts +1 -1
  77. package/dist/core/config-refusal-codes.js +1 -0
  78. package/dist/core/delegation-frames.d.ts +9 -12
  79. package/dist/core/delegation-frames.js +9 -8
  80. package/dist/core/engine-capabilities.d.ts +21 -8
  81. package/dist/core/engine-capabilities.js +1 -1
  82. package/dist/core/engine-notice.d.ts +147 -34
  83. package/dist/core/engine-notice.js +27 -16
  84. package/dist/core/engine-storage-backend.d.ts +2 -1
  85. package/dist/core/env-budget.js +3 -3
  86. package/dist/core/env-knob-announce.d.ts +10 -10
  87. package/dist/core/env-knob-announce.js +3 -6
  88. package/dist/core/file-history-store.d.ts +29 -4
  89. package/dist/core/file-history-store.js +13 -0
  90. package/dist/core/frame-settlement.d.ts +2 -1
  91. package/dist/core/gate-fold.js +1 -1
  92. package/dist/core/gate-lanes.js +56 -49
  93. package/dist/core/governance-codes.d.ts +39 -3
  94. package/dist/core/governance-codes.js +61 -3
  95. package/dist/core/hooks.d.ts +29 -11
  96. package/dist/core/hooks.js +5 -2
  97. package/dist/core/human-input-projection.js +3 -3
  98. package/dist/core/input-author.d.ts +17 -3
  99. package/dist/core/input-author.js +15 -3
  100. package/dist/core/leg-identity.d.ts +10 -28
  101. package/dist/core/leg-identity.js +1 -21
  102. package/dist/core/lsp.d.ts +18 -13
  103. package/dist/core/lsp.js +30 -22
  104. package/dist/core/mailbox-store.d.ts +1 -1
  105. package/dist/core/mailbox-store.js +4 -4
  106. package/dist/core/mcp-connection-pool.d.ts +93 -4
  107. package/dist/core/mcp-connection-pool.js +104 -1
  108. package/dist/core/mcp-failure.d.ts +38 -12
  109. package/dist/core/mcp-failure.js +9 -13
  110. package/dist/core/mcp-probe.d.ts +4 -3
  111. package/dist/core/mcp-server-link.d.ts +4 -2
  112. package/dist/core/mcp-server-link.js +4 -5
  113. package/dist/core/mcp-server-spec.d.ts +3 -3
  114. package/dist/core/mcp-server-unavailable-notice.d.ts +22 -8
  115. package/dist/core/mcp-server-unavailable-notice.js +18 -4
  116. package/dist/core/mcp.d.ts +40 -6
  117. package/dist/core/mcp.js +39 -13
  118. package/dist/core/memory-engine/content-origin.js +2 -2
  119. package/dist/core/memory-engine/control-objects.d.ts +2 -4
  120. package/dist/core/memory-engine/control-objects.js +2 -10
  121. package/dist/core/memory-engine/delegation-settlement.js +6 -1
  122. package/dist/core/memory-engine/dual-root.js +3 -0
  123. package/dist/core/memory-engine/engine.d.ts +6 -4
  124. package/dist/core/memory-engine/engine.js +32 -29
  125. package/dist/core/memory-engine/file-backend.d.ts +20 -5
  126. package/dist/core/memory-engine/file-backend.js +21 -31
  127. package/dist/core/memory-engine/frontmatter.d.ts +2 -0
  128. package/dist/core/memory-engine/frontmatter.js +4 -0
  129. package/dist/core/memory-engine/layout.d.ts +114 -20
  130. package/dist/core/memory-engine/layout.js +340 -22
  131. package/dist/core/memory-engine/memory-deployment.d.ts +7 -5
  132. package/dist/core/memory-engine/mount-failed-notice.d.ts +19 -7
  133. package/dist/core/memory-engine/mount-failed-notice.js +43 -10
  134. package/dist/core/memory-engine/sync-client.js +4 -5
  135. package/dist/core/model-fallbacks.d.ts +5 -1
  136. package/dist/core/model-fallbacks.js +3 -3
  137. package/dist/core/model-receipt.d.ts +2 -1
  138. package/dist/core/model-receipt.js +12 -1
  139. package/dist/core/mods/kernel/dispatch.d.ts +2 -2
  140. package/dist/core/mods/kernel/dispatch.js +14 -6
  141. package/dist/core/mods/kernel/events.d.ts +8 -5
  142. package/dist/core/mods/kernel/events.js +2 -2
  143. package/dist/core/mods/kernel/index.d.ts +1 -1
  144. package/dist/core/mods/kernel/registration.d.ts +9 -0
  145. package/dist/core/mods/package.js +1 -1
  146. package/dist/core/mods/session-append.d.ts +4 -2
  147. package/dist/core/mods/session-append.js +3 -0
  148. package/dist/core/mods/stations.d.ts +7 -11
  149. package/dist/core/mods/stations.js +4 -7
  150. package/dist/core/mods/tool-call.d.ts +10 -8
  151. package/dist/core/mods/tool-call.js +15 -18
  152. package/dist/core/mounted-mcp.d.ts +0 -4
  153. package/dist/core/mounted-mcp.js +1 -1
  154. package/dist/core/park-noun.d.ts +24 -0
  155. package/dist/core/park-noun.js +21 -0
  156. package/dist/core/park-resumability.d.ts +60 -0
  157. package/dist/core/park-resumability.js +30 -0
  158. package/dist/core/permission-rule-provider.d.ts +24 -2
  159. package/dist/core/permission-rule-provider.js +11 -8
  160. package/dist/core/permission-rule-store.d.ts +8 -1
  161. package/dist/core/permission-rule-store.js +2 -3
  162. package/dist/core/permission-rules.d.ts +2 -1
  163. package/dist/core/permission-rules.js +8 -4
  164. package/dist/core/persisted-rule-arms.d.ts +3 -0
  165. package/dist/core/persisted-rule-arms.js +2 -1
  166. package/dist/core/present-plan-tool.d.ts +47 -3
  167. package/dist/core/present-plan-tool.js +62 -4
  168. package/dist/core/principal-name.d.ts +1 -1
  169. package/dist/core/principal-name.js +5 -5
  170. package/dist/core/process-identity.js +10 -5
  171. package/dist/core/protocol-http-auth.d.ts +20 -14
  172. package/dist/core/protocol-http-auth.js +70 -50
  173. package/dist/core/read-only-shell.js +9 -5
  174. package/dist/core/redaction-marks.d.ts +4 -26
  175. package/dist/core/redaction-marks.js +9 -21
  176. package/dist/core/remote-env.d.ts +43 -16
  177. package/dist/core/remote-env.js +1 -1
  178. package/dist/core/request-copy-projection.d.ts +1 -1
  179. package/dist/core/request-copy-projection.js +40 -50
  180. package/dist/core/resume-config-judge.js +1 -1
  181. package/dist/core/resume-startup-cause.d.ts +35 -18
  182. package/dist/core/resume-startup-cause.js +13 -10
  183. package/dist/core/retention.d.ts +167 -25
  184. package/dist/core/retention.js +100 -20
  185. package/dist/core/roles.d.ts +6 -0
  186. package/dist/core/roles.js +11 -5
  187. package/dist/core/rule-lane-reads.d.ts +3 -0
  188. package/dist/core/rule-lane-reads.js +5 -1
  189. package/dist/core/rule-store-fault.d.ts +70 -0
  190. package/dist/core/rule-store-fault.js +102 -0
  191. package/dist/core/runner/advertised-writable-dirs.js +16 -31
  192. package/dist/core/runner/announce-once-ledger.d.ts +19 -2
  193. package/dist/core/runner/announce-once-ledger.js +24 -2
  194. package/dist/core/runner/assemble-result.d.ts +6 -0
  195. package/dist/core/runner/assemble-result.js +1 -1
  196. package/dist/core/runner/auto-strip-notice.d.ts +36 -0
  197. package/dist/core/runner/auto-strip-notice.js +59 -0
  198. package/dist/core/runner/branch-window.d.ts +3 -0
  199. package/dist/core/runner/branch-window.js +37 -0
  200. package/dist/core/runner/caller-roster.d.ts +8 -3
  201. package/dist/core/runner/capability-withheld-seat.js +3 -9
  202. package/dist/core/runner/clock-and-limits.d.ts +22 -1
  203. package/dist/core/runner/clock-and-limits.js +30 -0
  204. package/dist/core/runner/contracts.d.ts +58 -35
  205. package/dist/core/runner/credential-refusal-seat.d.ts +2 -0
  206. package/dist/core/runner/credential-refusal-seat.js +47 -0
  207. package/dist/core/runner/cross-boundary-lane.js +6 -4
  208. package/dist/core/runner/decide-continuation.js +1 -1
  209. package/dist/core/runner/file-history-restore.d.ts +53 -2
  210. package/dist/core/runner/file-history-restore.js +29 -10
  211. package/dist/core/runner/forward-sink.d.ts +14 -1
  212. package/dist/core/runner/forward-sink.js +14 -12
  213. package/dist/core/runner/gate-exit.d.ts +8 -7
  214. package/dist/core/runner/gate-exit.js +13 -13
  215. package/dist/core/runner/git-status-frame.js +2 -4
  216. package/dist/core/runner/initial-run-state.js +1 -1
  217. package/dist/core/runner/main-call-account.d.ts +3 -1
  218. package/dist/core/runner/main-call-account.js +5 -3
  219. package/dist/core/runner/mcp-redial.d.ts +2 -5
  220. package/dist/core/runner/mcp-redial.js +2 -2
  221. package/dist/core/runner/nested-memory-content.d.ts +7 -1
  222. package/dist/core/runner/nested-memory-content.js +73 -13
  223. package/dist/core/runner/nested-memory-lane.d.ts +44 -19
  224. package/dist/core/runner/nested-memory-lane.js +152 -76
  225. package/dist/core/runner/park-commit.js +3 -1
  226. package/dist/core/runner/permission-rule-lanes.d.ts +8 -2
  227. package/dist/core/runner/permission-rule-lanes.js +29 -3
  228. package/dist/core/runner/person-path-rows.d.ts +3 -11
  229. package/dist/core/runner/person-path-rows.js +21 -24
  230. package/dist/core/runner/prepare-acquire-reconcile.js +3 -1
  231. package/dist/core/runner/prepare-artifact.d.ts +1 -1
  232. package/dist/core/runner/prepare-artifact.js +20 -14
  233. package/dist/core/runner/prepare-ask-lane.d.ts +9 -6
  234. package/dist/core/runner/prepare-ask-lane.js +6 -5
  235. package/dist/core/runner/prepare-boundary-parks.d.ts +7 -1
  236. package/dist/core/runner/prepare-boundary-parks.js +27 -24
  237. package/dist/core/runner/prepare-caps-and-workflow.d.ts +5 -2
  238. package/dist/core/runner/prepare-caps-and-workflow.js +4 -3
  239. package/dist/core/runner/prepare-config-doors.d.ts +9 -24
  240. package/dist/core/runner/prepare-config-doors.js +58 -41
  241. package/dist/core/runner/prepare-context-lane.d.ts +2 -2
  242. package/dist/core/runner/prepare-context-lane.js +3 -5
  243. package/dist/core/runner/prepare-defer-classify.d.ts +1 -1
  244. package/dist/core/runner/prepare-defer-classify.js +1 -1
  245. package/dist/core/runner/prepare-delegation-surface.d.ts +2 -2
  246. package/dist/core/runner/prepare-delegation-surface.js +3 -2
  247. package/dist/core/runner/prepare-file-history.d.ts +62 -26
  248. package/dist/core/runner/prepare-file-history.js +117 -46
  249. package/dist/core/runner/prepare-gate-stations.d.ts +4 -0
  250. package/dist/core/runner/prepare-gate-stations.js +6 -5
  251. package/dist/core/runner/prepare-hands-readface.d.ts +9 -4
  252. package/dist/core/runner/prepare-hands-readface.js +8 -4
  253. package/dist/core/runner/prepare-inherited-gate.d.ts +11 -4
  254. package/dist/core/runner/prepare-inherited-gate.js +6 -6
  255. package/dist/core/runner/prepare-listings.d.ts +1 -1
  256. package/dist/core/runner/prepare-listings.js +1 -1
  257. package/dist/core/runner/prepare-memory.js +2 -2
  258. package/dist/core/runner/prepare-offload-wrappers.d.ts +1 -1
  259. package/dist/core/runner/prepare-offload-wrappers.js +1 -1
  260. package/dist/core/runner/prepare-park-ask.d.ts +10 -3
  261. package/dist/core/runner/prepare-park-ask.js +7 -9
  262. package/dist/core/runner/prepare-policy-chain.d.ts +18 -9
  263. package/dist/core/runner/prepare-policy-chain.js +18 -13
  264. package/dist/core/runner/prepare-project-context.d.ts +1 -1
  265. package/dist/core/runner/prepare-project-context.js +5 -3
  266. package/dist/core/runner/prepare-prompt-assembly.js +2 -1
  267. package/dist/core/runner/prepare-prompt-inputs.d.ts +2 -2
  268. package/dist/core/runner/prepare-prompt-inputs.js +1 -1
  269. package/dist/core/runner/prepare-protocol-tools.d.ts +4 -5
  270. package/dist/core/runner/prepare-protocol-tools.js +7 -7
  271. package/dist/core/runner/prepare-question-face.d.ts +4 -2
  272. package/dist/core/runner/prepare-run-refs.d.ts +7 -2
  273. package/dist/core/runner/prepare-run-refs.js +8 -7
  274. package/dist/core/runner/prepare-safety-scan.d.ts +4 -3
  275. package/dist/core/runner/prepare-suspend-saga.d.ts +3 -7
  276. package/dist/core/runner/prepare-suspend-saga.js +4 -3
  277. package/dist/core/runner/prepare-task.js +66 -53
  278. package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +3 -2
  279. package/dist/core/runner/prepare-tool-disclosure-mount.js +2 -1
  280. package/dist/core/runner/prepare-turn-wiring.d.ts +3 -1
  281. package/dist/core/runner/prepare-turn-wiring.js +1 -1
  282. package/dist/core/runner/prepare-wiring-manifest.d.ts +9 -4
  283. package/dist/core/runner/prepare-wiring-manifest.js +14 -6
  284. package/dist/core/runner/prepare-workspace-restore.d.ts +4 -4
  285. package/dist/core/runner/prepare-workspace-restore.js +15 -6
  286. package/dist/core/runner/remote-env-retry.d.ts +3 -3
  287. package/dist/core/runner/restore-seat.d.ts +41 -0
  288. package/dist/core/runner/restore-seat.js +38 -0
  289. package/dist/core/runner/resume-admission.js +1 -1
  290. package/dist/core/runner/resume-apply.js +4 -3
  291. package/dist/core/runner/resume-checkpoint-screen.js +2 -1
  292. package/dist/core/runner/resume-internals-and-config.js +2 -1
  293. package/dist/core/runner/resume-preflight.js +2 -1
  294. package/dist/core/runner/rewind-files.js +22 -6
  295. package/dist/core/runner/rule-store-unreadable-notice.d.ts +8 -0
  296. package/dist/core/runner/rule-store-unreadable-notice.js +11 -0
  297. package/dist/core/runner/run-brain-sinks.d.ts +3 -6
  298. package/dist/core/runner/run-brain-sinks.js +6 -6
  299. package/dist/core/runner/run-compaction-machinery.d.ts +2 -2
  300. package/dist/core/runner/run-git-lane.d.ts +2 -0
  301. package/dist/core/runner/run-git-lane.js +2 -1
  302. package/dist/core/runner/run-harness-handlers.js +5 -4
  303. package/dist/core/runner/run-identity-wiring.js +20 -12
  304. package/dist/core/runner/run-leg.js +31 -72
  305. package/dist/core/runner/run-notification-lane.d.ts +3 -0
  306. package/dist/core/runner/run-notification-lane.js +2 -4
  307. package/dist/core/runner/run-reasoning-seat.d.ts +5 -6
  308. package/dist/core/runner/run-reasoning-seat.js +13 -18
  309. package/dist/core/runner/run-settle-and-teardown.js +13 -9
  310. package/dist/core/runner/run-terminal-adoption.js +4 -8
  311. package/dist/core/runner/run-turn-boundary.js +6 -3
  312. package/dist/core/runner/runtask.d.ts +9 -4
  313. package/dist/core/runner/runtask.js +29 -22
  314. package/dist/core/runner/session-rule-policy.d.ts +11 -1
  315. package/dist/core/runner/shell-env-withheld.js +2 -7
  316. package/dist/core/runner/side-call-account.d.ts +5 -6
  317. package/dist/core/runner/side-call-account.js +2 -2
  318. package/dist/core/runner/stream-lifecycle-verbs.d.ts +3 -0
  319. package/dist/core/runner/stream-lifecycle-verbs.js +5 -3
  320. package/dist/core/runner/stream-settle-backstop.js +4 -6
  321. package/dist/core/runner/stream-steer-verb.d.ts +1 -1
  322. package/dist/core/runner/stream-steer-verb.js +4 -4
  323. package/dist/core/runner/sub-agent-deny-lists.d.ts +8 -3
  324. package/dist/core/runner/sub-agent-deny-lists.js +7 -4
  325. package/dist/core/runner/teardown-bounded.d.ts +7 -0
  326. package/dist/core/runner/teardown-bounded.js +7 -0
  327. package/dist/core/runner/terminal-account.js +41 -13
  328. package/dist/core/runner/terminal-projection.d.ts +1 -5
  329. package/dist/core/runner/tool-end-body.d.ts +9 -3
  330. package/dist/core/runner/tool-end-body.js +6 -3
  331. package/dist/core/runner/tool-output-projection.d.ts +13 -4
  332. package/dist/core/runner/tool-output-projection.js +10 -14
  333. package/dist/core/runner/turn-attachments.d.ts +3 -2
  334. package/dist/core/runner/turn-attachments.js +12 -5
  335. package/dist/core/runner-deps.d.ts +6 -6
  336. package/dist/core/runtime-caps.d.ts +2 -1
  337. package/dist/core/secret-env.d.ts +20 -3
  338. package/dist/core/secret-env.js +13 -15
  339. package/dist/core/session-checkout.d.ts +115 -15
  340. package/dist/core/session-checkout.js +435 -136
  341. package/dist/core/session-policy-store.js +21 -3
  342. package/dist/core/session-reconcile.js +1 -0
  343. package/dist/core/session-store.js +2 -0
  344. package/dist/core/session.d.ts +11 -1
  345. package/dist/core/shell-run-candidates.d.ts +1 -0
  346. package/dist/core/shell-run-candidates.js +1 -1
  347. package/dist/core/shutdown-debug.d.ts +6 -5
  348. package/dist/core/shutdown-debug.js +5 -1
  349. package/dist/core/skill-grant.js +4 -1
  350. package/dist/core/skills-directory.js +5 -3
  351. package/dist/core/spec-contract.d.ts +1 -1
  352. package/dist/core/store-contracts/checkpoint-store-contract.js +2 -7
  353. package/dist/core/store-contracts/file-history-store-contract.js +26 -2
  354. package/dist/core/store-contracts/session-deletion-cascade-contract.js +130 -14
  355. package/dist/core/store-contracts/task-list-store-contract.d.ts +2 -1
  356. package/dist/core/store-contracts/task-list-store-contract.js +28 -1
  357. package/dist/core/task-event.d.ts +48 -27
  358. package/dist/core/task-notification.d.ts +15 -9
  359. package/dist/core/task-notification.js +12 -0
  360. package/dist/core/task-registry-agent.d.ts +24 -22
  361. package/dist/core/task-registry-agent.js +65 -46
  362. package/dist/core/task-registry-shared.d.ts +17 -5
  363. package/dist/core/task-registry.d.ts +17 -6
  364. package/dist/core/task-registry.js +6 -1
  365. package/dist/core/task-result.d.ts +71 -25
  366. package/dist/core/task-spec-members.d.ts +0 -1
  367. package/dist/core/task-spec-members.js +1 -1
  368. package/dist/core/task-spec.d.ts +60 -52
  369. package/dist/core/task-stream.d.ts +45 -12
  370. package/dist/core/terminal-cause.d.ts +45 -8
  371. package/dist/core/terminal-cause.js +5 -0
  372. package/dist/core/tool-card-bound.d.ts +32 -0
  373. package/dist/core/tool-card-bound.js +33 -0
  374. package/dist/core/tool-catalog-entries.d.ts +9 -0
  375. package/dist/core/tool-catalog-entries.js +48 -0
  376. package/dist/core/tool-errors.d.ts +4 -3
  377. package/dist/core/tool-face.d.ts +3 -3
  378. package/dist/core/tool-mount-facts.d.ts +3 -2
  379. package/dist/core/tool-mount-facts.js +1 -1
  380. package/dist/core/tool-mount-static.js +7 -5
  381. package/dist/core/tool-policy.d.ts +21 -19
  382. package/dist/core/tool-policy.js +5 -6
  383. package/dist/core/tool-registry.d.ts +3 -1
  384. package/dist/core/tool-registry.js +15 -1
  385. package/dist/core/tool-result-store.d.ts +9 -3
  386. package/dist/core/tool-result-store.js +14 -1
  387. package/dist/core/tool-roster.d.ts +6 -0
  388. package/dist/core/tool-roster.js +18 -0
  389. package/dist/core/tool-spec.d.ts +17 -8
  390. package/dist/core/trace.d.ts +35 -31
  391. package/dist/core/types.d.ts +2 -2
  392. package/dist/core/untrusted-egress.d.ts +10 -9
  393. package/dist/core/untrusted-egress.js +9 -9
  394. package/dist/core/untrusted-text.d.ts +0 -18
  395. package/dist/core/untrusted-text.js +7 -3
  396. package/dist/core/user-attachment.d.ts +9 -6
  397. package/dist/core/user-attachment.js +12 -10
  398. package/dist/core/user-row-origin.d.ts +44 -25
  399. package/dist/core/user-row-origin.js +30 -20
  400. package/dist/core/wiring-manifest.d.ts +26 -7
  401. package/dist/core/wiring-manifest.js +14 -11
  402. package/dist/core/workspace-snapshot.d.ts +3 -1
  403. package/dist/core/workspace-snapshot.js +1 -0
  404. package/dist/engine/execution-env/node-execution-env.d.ts +23 -16
  405. package/dist/engine/execution-env/node-execution-env.js +127 -67
  406. package/dist/engine/harness/agent-harness.d.ts +4 -5
  407. package/dist/engine/harness/agent-harness.js +2 -7
  408. package/dist/engine/harness/types.d.ts +51 -19
  409. package/dist/engine/harness/types.js +28 -1
  410. package/dist/engine/llm/types.d.ts +26 -14
  411. package/dist/engine/llm/types.js +2 -2
  412. package/dist/engine/loop/agent-loop.d.ts +2 -2
  413. package/dist/engine/loop/agent-loop.js +51 -275
  414. package/dist/engine/loop/types.d.ts +0 -18
  415. package/dist/engine/session/import-validate.d.ts +3 -0
  416. package/dist/engine/session/import-validate.js +34 -2
  417. package/dist/engine/session/repo-utils.d.ts +42 -4
  418. package/dist/engine/session/repo-utils.js +33 -5
  419. package/dist/engine/session/session.d.ts +41 -14
  420. package/dist/engine/session/session.js +96 -25
  421. package/dist/index.d.ts +21 -16
  422. package/dist/index.js +16 -10
  423. package/dist/orchestration/run-spec.d.ts +1 -1
  424. package/dist/orchestration/run-workflow-tool.d.ts +12 -9
  425. package/dist/orchestration/run-workflow-tool.js +15 -19
  426. package/dist/orchestration/workflow-governance.js +13 -21
  427. package/dist/orchestration/workflow-observe.d.ts +4 -3
  428. package/dist/orchestration/workflow-primitives.d.ts +1 -1
  429. package/dist/orchestration/workflow-record-artifact.d.ts +14 -0
  430. package/dist/orchestration/workflow-record-artifact.js +32 -0
  431. package/dist/orchestration/workflow-script-store.d.ts +9 -0
  432. package/dist/orchestration/workflow-script-store.js +20 -1
  433. package/dist/orchestration/workflow-types.d.ts +33 -3
  434. package/dist/orchestration/workflow.d.ts +24 -14
  435. package/dist/orchestration/workflow.js +52 -23
  436. package/dist/prompt-assembly/artifact.js +4 -8
  437. package/dist/prompt-assembly/catalog/engine.d.ts +263 -0
  438. package/dist/prompt-assembly/catalog/engine.js +30 -0
  439. package/dist/prompt-assembly/catalog/index.d.ts +1 -1
  440. package/dist/prompt-assembly/catalog/index.js +2 -2
  441. package/dist/prompt-assembly/catalog/locales/zh-Hans/engine.d.ts +1 -1
  442. package/dist/prompt-assembly/catalog/locales/zh-Hans/engine.js +29 -0
  443. package/dist/prompt-assembly/epoch.js +6 -8
  444. package/dist/prompt-assembly/turn-snapshot.js +8 -9
  445. package/dist/stores/file/background-agent-store.js +5 -6
  446. package/dist/stores/file/checkpoint-store.d.ts +0 -4
  447. package/dist/stores/file/checkpoint-store.js +7 -3
  448. package/dist/stores/file/file-history-store.d.ts +8 -0
  449. package/dist/stores/file/file-history-store.js +72 -0
  450. package/dist/stores/file/fs-atomic.js +17 -12
  451. package/dist/stores/file/index.js +11 -5
  452. package/dist/stores/file/mailbox-store.js +13 -4
  453. package/dist/stores/file/permission-rule-store.js +14 -13
  454. package/dist/stores/file/shared-ledger.d.ts +4 -0
  455. package/dist/stores/file/shared-ledger.js +4 -0
  456. package/dist/stores/file/task-list-store.js +12 -3
  457. package/dist/stores/file/workflow-run-store.js +1 -0
  458. package/dist/tools/fs/bash-program-position.d.ts +4 -2
  459. package/dist/tools/fs/bash-program-position.js +1 -1
  460. package/dist/tools/fs/bash-readonly-classifier.js +1 -1
  461. package/dist/tools/fs/bound-open.d.ts +97 -0
  462. package/dist/tools/fs/bound-open.js +103 -0
  463. package/dist/tools/fs/containment-face.d.ts +2 -2
  464. package/dist/tools/fs/fs-pdf.d.ts +7 -1
  465. package/dist/tools/fs/fs-pdf.js +31 -23
  466. package/dist/tools/fs/fs-read.d.ts +24 -17
  467. package/dist/tools/fs/fs-read.js +84 -53
  468. package/dist/tools/fs/fs-shared.d.ts +14 -12
  469. package/dist/tools/fs/fs-shared.js +5 -4
  470. package/dist/tools/fs/fs-write.d.ts +2 -2
  471. package/dist/tools/fs/fs-write.js +20 -12
  472. package/dist/tools/fs/index.d.ts +4 -4
  473. package/dist/tools/fs/index.js +2 -2
  474. package/dist/tools/fs/notebook.d.ts +1 -1
  475. package/dist/tools/fs/pdf.d.ts +12 -3
  476. package/dist/tools/fs/pdf.js +22 -9
  477. package/dist/tools/fs/read-deny-home.d.ts +3 -2
  478. package/dist/tools/fs/read-deny-home.js +8 -11
  479. package/dist/tools/fs/safety.d.ts +3 -2
  480. package/dist/tools/fs/shell-read-check.js +10 -9
  481. package/dist/tools/monitor.d.ts +6 -5
  482. package/dist/tools/task-list.d.ts +16 -6
  483. package/dist/tools/task-list.js +4 -0
  484. package/dist/tools/web.d.ts +9 -1
  485. package/dist/tools/web.js +8 -3
  486. package/dist/tools/worktree.d.ts +7 -5
  487. package/dist/tools/worktree.js +4 -3
  488. package/package.json +4 -3
  489. package/test/export-surface.snapshot.json +93 -7
  490. package/wire-changes/core-stores-sql@7.68.0.json +39 -0
  491. package/wire-changes/core@7.68.0.json +4257 -0
  492. package/wire-changes/mods-kernel@7.68.0.json +129 -0
  493. package/wire-changes/primitives@7.68.0.json +253 -0
  494. package/wire-changes/wiki-gate@7.68.0.json +39 -0
  495. package/dist/core/runner/credential-origin-seat.d.ts +0 -2
  496. package/dist/core/runner/credential-origin-seat.js +0 -20
@@ -1,22 +1,55 @@
1
- import { readMember } from "../thrown-value.js";
2
- import { STORE_FORM_REFUSAL_CODES } from "./layout.js";
1
+ import { storeFormRefusalReadingOf } from "./layout.js";
2
+ const OPERATOR_TAIL = "Whoever runs this deployment can do this (the service log names the exact step); the next run mounts it again.";
3
+ const OUTSIDE = {
4
+ act_outside: {
5
+ clause: "a folder inside the memory store is a link that points to a place outside it",
6
+ restore: "replace that link inside the memory store with a real directory",
7
+ tail: OPERATOR_TAIL,
8
+ },
9
+ root_moved: {
10
+ clause: "the memory store's directory now leads to a different place than the one it was set up in",
11
+ restore: "put the memory directory back where it was — or, if it was moved on purpose, confirm its new location",
12
+ tail: OPERATOR_TAIL,
13
+ },
14
+ root_gone: {
15
+ clause: "the memory store's directory is no longer where it was set up",
16
+ restore: "put the memory directory back — or, if it was moved on purpose, confirm its new location (to start over, create it again and confirm it there)",
17
+ tail: OPERATOR_TAIL,
18
+ },
19
+ root_reanchored: {
20
+ clause: "the memory this conversation opened has been moved to another place since",
21
+ restore: "start a new conversation, which opens it in its new place",
22
+ tail: "Nothing else needs doing.",
23
+ },
24
+ };
3
25
  const CLAUSE = {
4
- "memory.target_outside_store": "a path of the memory store resolves outside the store (a symbolic link points out of it, or its root moved)",
5
26
  "memory.scope_home_not_directory": "a memory scope's directory is a symbolic link or not a real directory",
6
27
  "memory.control_plane_links_unsupported": "the file system under the memory store cannot make hard links",
7
- "memory.control_plane_strays": "the memory control plane still holds records of an earlier governance store that nobody has adopted",
28
+ "memory.control_plane_strays": "memory records from an earlier setup are still kept beside the current ones, and nothing reads them",
8
29
  "memory.store_root_sensitive": "the memory store is configured inside a directory the engine's write guard protects (a credential or access-control directory)",
30
+ "memory.control_plane_split": "since the memory store's location was moved, what is kept beside it stands in two places that disagree",
9
31
  unclassified: "the memory store could not be opened",
10
32
  };
11
- export function memoryMountFailedCauseOf(thrown) {
12
- const code = readMember(thrown, "code");
13
- return typeof code === "string" && STORE_FORM_REFUSAL_CODES.includes(code) ? code : "unclassified";
33
+ const RESTORE = {
34
+ "memory.scope_home_not_directory": "replace that link or file with a real directory",
35
+ "memory.control_plane_links_unsupported": "move the memory store to a disk that supports hard links",
36
+ "memory.control_plane_strays": "merge the memory records the earlier setup left beside the current ones",
37
+ "memory.store_root_sensitive": "point the memory store at a directory outside the protected one",
38
+ "memory.control_plane_split": "keep one of the two copies of each record the service log names and remove the other",
39
+ unclassified: "check the service log for why the memory store could not be opened",
40
+ };
41
+ export function memoryMountFailedReadingOf(thrown) {
42
+ const refusal = storeFormRefusalReadingOf(thrown);
43
+ if (refusal === undefined)
44
+ return { cause: "unclassified" };
45
+ return "outsideReason" in refusal ? { cause: refusal.code, outsideReason: refusal.outsideReason } : { cause: refusal.code };
14
46
  }
15
47
  export function memoryMountFailedNotice(input) {
48
+ const words = "outsideReason" in input ? OUTSIDE[input.outsideReason] : { clause: CLAUSE[input.cause], restore: RESTORE[input.cause], tail: OPERATOR_TAIL };
16
49
  return {
17
50
  code: "memory.mount_failed",
18
- message: `Memory did not mount for this session: ${CLAUSE[input.cause]}. The task runs without it — stored memory is not available to the assistant, ` +
19
- `and nothing is saved into that memory store in this session; a later run may mount it.`,
20
- detail: { sessionId: input.sessionId, scopes: [...input.scopes], cause: input.cause },
51
+ message: `Memory did not mount for this session: ${words.clause}. The task runs without it — stored memory is not available to the assistant, ` +
52
+ `and nothing is saved into that memory store in this session. To restore it: ${words.restore}. ${words.tail}`,
53
+ detail: { sessionId: input.sessionId, scopes: [...input.scopes], cause: input.cause, ...("outsideReason" in input ? { outsideReason: input.outsideReason } : {}) },
21
54
  };
22
55
  }
@@ -7,8 +7,7 @@ import { MEMORY_ORIGIN_CAUSES } from "./types.js";
7
7
  import { directoryPinOf } from "./dual-root.js";
8
8
  import { landingPathOf } from "./layout.js";
9
9
  import { egressText } from "../untrusted-egress.js";
10
- import { userinfoHolds } from "@sema-agent/primitives";
11
- import { REDACTION_MARKS } from "../redaction-marks.js";
10
+ import { REDACTION_MARKS, userinfoHolds } from "@sema-agent/primitives";
12
11
  import { isReplicableScope } from "./scope-contract.js";
13
12
  const DROP_THE_CURSOR = "drop the cursor to accept re-convergence from an empty baseline — entries changed on both sides are reported as conflicts, " +
14
13
  "and entries deleted on one side since the last round come back from the other side";
@@ -63,7 +62,7 @@ function syncRefusal(on, head, want) {
63
62
  }
64
63
  else {
65
64
  e.code = "config.memory_sync_cursor_mismatch";
66
- e.detail = Object.freeze({ axis: on.axis, found: on.found, want: carriesCredential(want) ? REDACTION_MARKS.credentials : want });
65
+ e.detail = Object.freeze({ axis: on.axis, found: on.found, want: carriesCredential(want) ? REDACTION_MARKS.bare : want });
67
66
  }
68
67
  e.outs = outs;
69
68
  MINTED_REFUSALS.add(e);
@@ -109,7 +108,7 @@ const namesSomething = (v) => typeof v === "string" && v.trim().length > 0;
109
108
  function quoted(v) {
110
109
  if (typeof v !== "string")
111
110
  return JSON.stringify(typeof v);
112
- return carriesCredential(v) ? REDACTION_MARKS.credentials : JSON.stringify(v);
111
+ return carriesCredential(v) ? REDACTION_MARKS.bare : JSON.stringify(v);
113
112
  }
114
113
  const isAsciiLetter = (c) => (c >= 65 && c <= 90) || (c >= 97 && c <= 122);
115
114
  const isSchemeChar = (c) => isAsciiLetter(c) || (c >= 48 && c <= 57) || c === 43 || c === 45 || c === 46;
@@ -354,7 +353,7 @@ export async function syncMemoryScope(opts) {
354
353
  throw new Error("memory sync: scope must be a non-empty string");
355
354
  if (!isReplicableScope(scope)) {
356
355
  const e = new Error(egressText("same-principal", `memory sync: scope ${quoted(scope)} is a userlocal: key — its layer never leaves the store it is written in, so no sync carries it; ` +
357
- "nothing was read or sent. Leave this layer out of the sync (isReplicableScope)."));
356
+ "nothing was read or sent. Leave this scope out of what you sync; memory meant to travel goes under a scope that does not start with userlocal:."));
358
357
  e.code = "config.memory_scope_key";
359
358
  throw e;
360
359
  }
@@ -30,7 +30,11 @@ export declare const DEGRADE_REASONS: readonly ["breaker_open", "rate_limit", "b
30
30
  export type DegradeReason = (typeof DEGRADE_REASONS)[number];
31
31
  /** Whether a value is one of the reason words. */
32
32
  export declare function isDegradeReason(value: unknown): value is DegradeReason;
33
- /** The gate a deployment that configures none walks on: the four reactive classes. */
33
+ /** The words a gate may hold: every reason but `budget`. The one list the policy door judges a gate against and every refusal
34
+ * sentence that names the words reads, and the one a deployment's own documentation or completion reads at runtime
35
+ * (a root export, frozen). */
36
+ export declare const MODEL_FALLBACK_GATE_WORDS: readonly Exclude<DegradeReason, "budget">[];
37
+ /** The gate a deployment that configures none walks on: the four reactive classes (a root export, frozen). */
34
38
  export declare const DEFAULT_FALLBACK_GATE: readonly DegradeReason[];
35
39
  /** What a gate row may admit besides a list of reason words: every failure the shared judge lets through at all. */
36
40
  export declare const ANY_HOP_FAILURE: "any";
@@ -6,6 +6,7 @@ const DEGRADE_REASON_SET = new Set(DEGRADE_REASONS);
6
6
  export function isDegradeReason(value) {
7
7
  return typeof value === "string" && DEGRADE_REASON_SET.has(value);
8
8
  }
9
+ export const MODEL_FALLBACK_GATE_WORDS = Object.freeze(DEGRADE_REASONS.filter((r) => r !== "budget"));
9
10
  export const DEFAULT_FALLBACK_GATE = Object.freeze(["rate_limit", "breaker_open", "server_error", "last_resort"]);
10
11
  export const ANY_HOP_FAILURE = "any";
11
12
  export const GATEWAY_HOP_GATE = Object.freeze({ on: ANY_HOP_FAILURE });
@@ -35,7 +36,6 @@ const RECEIVED_POLICIES = new WeakSet();
35
36
  export const DEFAULT_MODEL_FALLBACK_POLICY = Object.freeze({ on: DEFAULT_FALLBACK_GATE });
36
37
  RECEIVED_POLICIES.add(DEFAULT_MODEL_FALLBACK_POLICY);
37
38
  const POLICY_KEYS = ["on", "firstTokenMs"];
38
- const GATE_WORDS = DEGRADE_REASONS.filter((r) => r !== "budget");
39
39
  export function receiveModelFallbackPolicy(value, field) {
40
40
  if (value === undefined)
41
41
  return DEFAULT_MODEL_FALLBACK_POLICY;
@@ -49,12 +49,12 @@ export function receiveModelFallbackPolicy(value, field) {
49
49
  let on = DEFAULT_MODEL_FALLBACK_POLICY.on;
50
50
  if (held.on !== undefined) {
51
51
  if (!Array.isArray(held.on))
52
- throw modelFallbackRefusal(`${field}.on`, `${field}.on is ${describeRejectedValue(held.on)} — it lists reason words (${GATE_WORDS.join(", ")}).`);
52
+ throw modelFallbackRefusal(`${field}.on`, `${field}.on is ${describeRejectedValue(held.on)} — it lists reason words (${MODEL_FALLBACK_GATE_WORDS.join(", ")}).`);
53
53
  const listed = held.on;
54
54
  const seen = [];
55
55
  for (const word of listed) {
56
56
  if (!isDegradeReason(word) || word === "budget") {
57
- throw modelFallbackRefusal(`${field}.on`, `${field}.on holds ${describeRejectedValue(word)}, which is not a fallback reason — the words are ${GATE_WORDS.join(", ")} (\`budget\` is the run's near-budget switch, never a gate word).`);
57
+ throw modelFallbackRefusal(`${field}.on`, `${field}.on holds ${describeRejectedValue(word)}, which is not a fallback reason — the words are ${MODEL_FALLBACK_GATE_WORDS.join(", ")} (\`budget\` is the run's near-budget switch, never a gate word).`);
58
58
  }
59
59
  if (seen.includes(word))
60
60
  throw modelFallbackRefusal(`${field}.on`, `${field}.on names ${JSON.stringify(word)} twice.`);
@@ -41,7 +41,8 @@ export declare function forkModelSnapshot(snapshot: Model): Model;
41
41
  * `not_a_model_ref`; a retired member — `config.deps_retired_key` (its own sentence); a member outside the contract — `not_a_model_ref`
42
42
  * (a provider's own parameters belong in `Model.params`); an `id` that is not a non-empty string or an `api` that is not a string —
43
43
  * `not_a_model_ref`, naming the member; a `defaultThinking` that is present but not one of the seven tiers — `not_a_model_ref`, naming
44
- * the member; a `fallbacks` that is present but not a list of non-empty strings — `not_a_model_ref`, naming the member.
44
+ * the member; a `fallbacks` that is present but not a list of non-empty strings — `not_a_model_ref`, naming the member; a
45
+ * `compat.thinkingFormat` that is present, not `null` and not a chat-completions dialect name — `not_a_model_ref`, naming the member.
45
46
  *
46
47
  * `fallbacks` is a CATALOG member: its words are resolved by the catalog door over the catalog it receives
47
48
  * (`model-fallbacks.ts`), so only the catalog door's own receipt (`catalogEntry`: a catalog entry, a tier's model object) takes a
@@ -1,5 +1,5 @@
1
1
  import { types } from "node:util";
2
- import { isThinkingLevel, THINKING_LEVELS } from "../brain/reasoning.js";
2
+ import { COMPLETIONS_THINKING_FORMATS, declaredCompletionsFormat, isThinkingLevel, THINKING_LEVELS } from "../brain/reasoning.js";
3
3
  import { describeFault, receive } from "./mods/kernel/receive.js";
4
4
  import { DECLARATION_RECEIPT_MODE } from "./own-property-receipt.js";
5
5
  import { assertNoRetiredKeys, RETIRED_MODEL_KEYS } from "./retired-keys.js";
@@ -121,6 +121,17 @@ function judgeModelCopy(copy, seat, what, note) {
121
121
  if (defaultThinking !== undefined && !isThinkingLevel(defaultThinking)) {
122
122
  throw modelBindingRefusal(seat, "not_a_model_ref", `${seat} is ${what} whose \`defaultThinking\` is ${bindingShown(defaultThinking)} — a model's default thinking level is one of ${THINKING_LEVELS.join(", ")} ("off" spells thinking off), or absent for no default.${note}`);
123
123
  }
124
+ const compat = copy["compat"];
125
+ if (typeof compat === "object" && compat !== null) {
126
+ try {
127
+ declaredCompletionsFormat(compat);
128
+ }
129
+ catch (e) {
130
+ if (e.code !== "config.invalid_argument")
131
+ throw e;
132
+ throw modelBindingRefusal(seat, "not_a_model_ref", `${seat} is ${what} whose \`compat.thinkingFormat\` is ${bindingShown(compat.thinkingFormat)} — a chat-completions thinking dialect is one of ${COMPLETIONS_THINKING_FORMATS.join(", ")}, or absent for "openai".${note}`);
133
+ }
134
+ }
124
135
  const fallbacks = copy["fallbacks"];
125
136
  if (fallbacks !== undefined && (!isList(fallbacks) || !fallbacks.every((w) => typeof w === "string" && w !== ""))) {
126
137
  throw modelBindingRefusal(seat, "not_a_model_ref", `${seat} is ${what} whose \`fallbacks\` is ${bindingShown(fallbacks)} — a model's fallbacks are a list of catalog words (non-empty strings), or absent for none.${note}`);
@@ -43,8 +43,8 @@ export type ModDispatchOutcome = {
43
43
  readonly answeredBy?: string;
44
44
  readonly skipped: readonly ModSkip[];
45
45
  }
46
- /** `bottomStarted`: the chain's bottom had started when the handler failed — on an effect event, what it did happened, and
47
- * its outcome is the station's to withhold. */
46
+ /** `bottomStarted`: the chain's bottom had started when the handler failed — on a `refuse` event, what it did happened
47
+ * (a `refuse_until_run` event never fails once the failing handler's own `next` started it: that handler is skipped). */
48
48
  | {
49
49
  readonly kind: "failed";
50
50
  readonly registration: string;
@@ -401,6 +401,9 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
401
401
  }
402
402
  const observers = all.filter((p) => !p.reentry && p.h.observe).map((p) => p.h);
403
403
  const chain = all.filter((p) => !p.h.observe).map((p) => p.h);
404
+ const roster = chain.map(participantOf);
405
+ const belows = [];
406
+ const belowOf = (i) => (belows[i] ??= Object.freeze(roster.slice(i + 1)));
404
407
  const reentered = new Set(all.filter((p) => p.reentry).map((p) => p.h));
405
408
  const skipped = [];
406
409
  const producers = new Map();
@@ -580,6 +583,7 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
580
583
  origin: { value: origin, enumerable: true },
581
584
  signal: { value: base.signal, enumerable: true },
582
585
  trace: { get: base.trace, enumerable: true },
586
+ below: { value: base.below, enumerable: true },
583
587
  budget: { get: () => base.budget.reading(), enumerable: true },
584
588
  ...(caught !== undefined ? { error: { value: caught.error, enumerable: true }, called: { value: caught.called, enumerable: true } } : {}),
585
589
  });
@@ -630,7 +634,7 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
630
634
  failure = { cause: "reentry", reason: "not run: the dispatch re-entered a frame it is part of" };
631
635
  }
632
636
  else {
633
- const next = makeNext({ budget, signal: ac.signal, trace: () => Object.freeze([...state.below]) }, (x) => descend(x, floors), to);
637
+ const next = makeNext({ budget, signal: ac.signal, trace: () => Object.freeze([...state.below]), below: belowOf(i) }, (x) => descend(x, floors), to);
634
638
  handlerP = runWithDollar(h.reg, myFrames, budget, ac.signal, engines, ($) => h.fn($, e, next));
635
639
  try {
636
640
  const raced = await Promise.race([handlerP, budget.expired]);
@@ -735,7 +739,7 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
735
739
  };
736
740
  const message = failure.cause === "threw" ? describe(failure.error) : failure.cause === "violation" ? failure.reason : undefined;
737
741
  const error = Object.freeze({ kind: failure.cause, ...(message !== undefined ? { message } : {}), budget: catchMs });
738
- const next = makeNext({ budget, signal: ac.signal, trace: () => Object.freeze([...state.below]) }, (x) => replay(x, floors), (x, tier) => {
742
+ const next = makeNext({ budget, signal: ac.signal, trace: () => Object.freeze([...state.below]), below: belowOf(i) }, (x) => replay(x, floors), (x, tier) => {
739
743
  const why = nextToRefusal(h.reg.tier, tier);
740
744
  return why !== undefined ? Promise.reject(new Error(`${h.reg.name}: ${why}`)) : replay(x, [...floors, { from: h.reg.tier, to: tier }]);
741
745
  }, { error, called: state.called });
@@ -766,7 +770,7 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
766
770
  const budget = createSelfBudget(budgetMs, () => ac.abort(new Error(`${name} ran past its ${budgetMs}ms budget`)));
767
771
  const myFrames = handlerFrame(fr, name, h.index, event);
768
772
  const refuse = () => Promise.reject(new Error(`${name}: an observe handler is not in the chain; next() is unavailable`));
769
- const next = makeNext({ budget, signal: ac.signal, trace: () => Object.freeze([]) }, refuse, refuse);
773
+ const next = makeNext({ budget, signal: ac.signal, trace: () => Object.freeze([]), below: NOTHING_BELOW }, refuse, refuse);
770
774
  const verdict = (r) => {
771
775
  if (r === undefined)
772
776
  return;
@@ -790,7 +794,7 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
790
794
  live.add(cac);
791
795
  const catchMs = ownMs(CATCH_BUDGET_MS);
792
796
  const catchBudget = createSelfBudget(catchMs, () => cac.abort(new Error(`${name}: its .catch ran past its ${catchMs}ms budget`)));
793
- const cnext = makeNext({ budget: catchBudget, signal: cac.signal, trace: () => Object.freeze([]) }, refuse, refuse, {
797
+ const cnext = makeNext({ budget: catchBudget, signal: cac.signal, trace: () => Object.freeze([]), below: NOTHING_BELOW }, refuse, refuse, {
794
798
  error: Object.freeze({ kind: cause, ...(cause === "threw" ? { message: describe(err) } : {}), budget: catchMs }),
795
799
  called: false,
796
800
  });
@@ -847,13 +851,17 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
847
851
  return bus;
848
852
  }
849
853
  function admits(participant, h) {
850
- return participant === undefined || participant(Object.freeze({ plugin: h.reg.name, seat: h.reg.seat, observe: h.observe }));
854
+ return participant === undefined || participant(participantOf(h));
851
855
  }
856
+ function participantOf(h) {
857
+ return Object.freeze({ plugin: h.reg.name, seat: h.reg.seat, observe: h.observe });
858
+ }
859
+ const NOTHING_BELOW = Object.freeze([]);
852
860
  function answererOf(h) {
853
861
  return { plugin: h.reg.name, seat: h.reg.seat, tier: h.reg.tier };
854
862
  }
855
863
  function hasNextShape(f) {
856
- return typeof f === "function" && "to" in f && "trace" in f && "budget" in f && "signal" in f && "origin" in f;
864
+ return typeof f === "function" && "to" in f && "trace" in f && "below" in f && "budget" in f && "signal" in f && "origin" in f;
857
865
  }
858
866
  function invokeNow(f) {
859
867
  try {
@@ -52,8 +52,11 @@
52
52
  * that same frame and the bus's lifetime (`ModBusInput.lifetime`), and is refused once the lifetime ends.
53
53
  * `classic.Stop` / `classic.SubagentStop` take `{ end }`, and each seat is judged in its own pass (task, then deployment): a
54
54
  * handler's `next` reaches its own seat and the engine's bottom.
55
+ * 11: `tool.call`'s failure column is `refuse_until_run` again — a handler that fails once its own `next` ran the tool's body is
56
+ * skipped and its last `next()` run's result stands — and its station takes a `{ deny }` given over what that `next` answered
57
+ * once the body ran: the call ran and its result is withheld.
55
58
  */
56
- export declare const KERNEL_CONTRACT_VERSION = 10;
59
+ export declare const KERNEL_CONTRACT_VERSION = 11;
57
60
  /** The five tiers in run order (CC names). `builtin` and `core` are the engine's own. */
58
61
  export declare const MOD_TIERS: readonly ["prepend", "user", "append", "builtin", "core"];
59
62
  export type ModTier = (typeof MOD_TIERS)[number];
@@ -69,10 +72,10 @@ export type ModEventSide = (typeof MOD_EVENT_SIDES)[number];
69
72
  export type ModBusSide = Exclude<ModEventSide, "both">;
70
73
  /**
71
74
  * What a handler's failure means for the dispatch: the station's refusal (final); skip the handler; or — on an event whose
72
- * bottom is a go-ahead the station acts on after the dispatch (`agent.spawn`: the subagent is let start) — the refusal
73
- * while the bottom has not started and, once it has, the go-ahead stands (the failure is reported beside it). A `refuse`
74
- * station refuses whether or not its bottom has started: on one whose bottom is an effect (`tool.call`: a tool runs), the
75
- * dispatch's `failed` outcome says the bottom had started, and the station withholds what it produced.
75
+ * bottom, once started, is what stands (`agent.spawn`: the subagent is let start; `tool.call`: the tool ran) — the refusal
76
+ * while the bottom has not started and, once the handler's own `next` has started it, the handler is skipped and its last
77
+ * `next()` run's answer stands (the failure is reported beside it). A `refuse` station refuses whether or not its bottom has
78
+ * started; the dispatch's `failed` outcome says when it had.
76
79
  */
77
80
  export declare const MOD_FAILURE_ANSWERS: readonly ["refuse", "skip", "refuse_until_run"];
78
81
  export type ModFailureAnswer = (typeof MOD_FAILURE_ANSWERS)[number];
@@ -1,4 +1,4 @@
1
- export const KERNEL_CONTRACT_VERSION = 10;
1
+ export const KERNEL_CONTRACT_VERSION = 11;
2
2
  export const MOD_TIERS = Object.freeze(["prepend", "user", "append", "builtin", "core"]);
3
3
  export const MOD_SEATS = Object.freeze(["deployment", "task"]);
4
4
  export const MOD_EVENT_SIDES = Object.freeze(["engine", "surface", "both"]);
@@ -82,7 +82,7 @@ export const MOD_EVENT_TABLE = Object.freeze({
82
82
  "classic.FileChanged": engine(),
83
83
  "classic.DirectoryAdded": engine(),
84
84
  "classic.MessageDisplay": engine(station("skip", "immediate", ["messageId", "turn", "index", "final", "agentId"], { budgetMs: 10_000 })),
85
- "tool.call": engine(station("refuse", "immediate", ["tool", "tool_use_id", "agentId", "input"], { call: true })),
85
+ "tool.call": engine(station("refuse_until_run", "immediate", ["tool", "tool_use_id", "agentId", "input"], { call: true })),
86
86
  "tool.check": engine(station("refuse", "immediate", ["tool", "input", "tool_use_id", "agentId", "ceiling"])),
87
87
  "ui.render": surface(station("skip", "grace", RENDER_PINNED)),
88
88
  "ui.resolve": surface(station("skip", "grace", ["surface", "component"])),
@@ -3,4 +3,4 @@ export { KERNEL_CONTRACT_VERSION, MOD_TIERS, MOD_SEATS, MOD_EVENT_SIDES, MOD_FAI
3
3
  export { DEFAULT_MOD_BUDGET_MS, CATCH_BUDGET_MS, RUNAWAY_AFTER_MS, POST_ABORT_GRACE_MS, MAX_TIMER_MS, clockMsRefusal, resolveModBudgetMs, type ModBudgetReading, } from "./budget.js";
4
4
  export { MOD_FAILURE_CAUSES, type ModFailureCause, type ModEventPayload, type ModAnswerCheck, type ModAnswerRanks, type ModDispatchRun, type ModAnswerer, type ModMatcher, type ModSkip, } from "./site-rules.js";
5
5
  export { ENGINE_ORIGIN, MODS_INVALID_CODE, MODS_REGISTRATION_REFUSED_CODE, MOD_TRACE_OUTCOMES, type ModTraceOutcome, type ModUses, type ModOrigin, type ModPluginFacts, type ModDollarBase, type ModTraceEntry, type ModCaughtError, type ModNext, type ModHandler, type ModHandlerOptions, type ModEventPair, type ModEventMap, type ModTypedNext, type ModTypedHandler, type On, type MappedOn, type ModRegistration, type ModAdmissionRecord, type ModSeats, } from "./registration.js";
6
- export { admitMods, type ModFrame, type ModBottomContext, type ModMethodBottom, type ModMethodSeat, type ModMethodBottoms, type ModCallEntry, type ModCallEntries, type ModDispatchOutcome, type ModDispatchOptions, type ModBus, type ModMountedHandler, type ModBusInput, type ModTimer, } from "./dispatch.js";
6
+ export { admitMods, type ModFrame, type ModBottomContext, type ModMethodBottom, type ModMethodSeat, type ModMethodBottoms, type ModCallEntry, type ModCallEntries, type ModDispatchOutcome, type ModDispatchOptions, type ModParticipant, type ModBus, type ModMountedHandler, type ModBusInput, type ModTimer, } from "./dispatch.js";
@@ -4,6 +4,7 @@
4
4
  */
5
5
  import { type ModBusSide, type ModEventName, type ModRegistrationTier, type ModSeat, type ModTier } from "./events.js";
6
6
  import { type ModBudgetReading } from "./budget.js";
7
+ import type { ModParticipant } from "./dispatch.js";
7
8
  import type { ModEventPayload, ModFailureCause, ModMatcher, ModSkip } from "./site-rules.js";
8
9
  /** The configuration refusal: a registration the kernel cannot take refuses the whole prepare. */
9
10
  export declare const MODS_INVALID_CODE = "config.mods_invalid";
@@ -63,6 +64,13 @@ export interface ModNext {
63
64
  readonly signal: AbortSignal;
64
65
  /** What ran beneath this handler's last `next`. */
65
66
  readonly trace: readonly ModTraceEntry[];
67
+ /**
68
+ * Who stands in this dispatch's chain beneath this handler, in chain order — the chain as the dispatch assembled it, before
69
+ * anything ran (`trace` records those the run reached). A handler a matcher leaves out of the event is not a member; one the
70
+ * dispatch re-entered (asked through its `.catch`) is. An observer is outside the chain — it ran before it, detached — so it
71
+ * is beneath no one, and an observer's own `below` is empty. Always present and frozen; empty when nothing stands beneath.
72
+ */
73
+ readonly below: readonly ModParticipant[];
66
74
  readonly budget: ModBudgetReading;
67
75
  /** Present on a `.catch`'s `next` only. */
68
76
  readonly error?: ModCaughtError;
@@ -92,6 +100,7 @@ export interface ModTypedNext<P extends ModEventPair> {
92
100
  readonly origin: ModOrigin;
93
101
  readonly signal: AbortSignal;
94
102
  readonly trace: readonly ModTraceEntry[];
103
+ readonly below: readonly ModParticipant[];
95
104
  readonly budget: ModBudgetReading;
96
105
  readonly error?: ModCaughtError;
97
106
  readonly called?: boolean;
@@ -56,7 +56,7 @@ export async function loadModPackage(dir, host = {}) {
56
56
  }
57
57
  async function realRoot(dir) {
58
58
  try {
59
- const root = await physicalPathOfAsync(resolve(dir));
59
+ const root = await physicalPathOfAsync(dir);
60
60
  if ((await stat(root)).isDirectory())
61
61
  return root;
62
62
  }
@@ -4,8 +4,10 @@
4
4
  * THE RULE. A row enters the conversation at one point: its first commit point, before the live context reads it again and
5
5
  * before the store keeps it. Every writer calls the seat there, once — the harness for the rows it commits (a row the loop
6
6
  * ends, the record of an API failure, a row handed to its port), every direct writer of the leg through
7
- * `appendAdmittedRow` (`row-admission.ts`). With a handler on `session.append` the seat raises the event once per row; with none, or before
8
- * the leg's bus is bound, the row passes as made and nothing is raised.
7
+ * `appendAdmittedRow` (`row-admission.ts`). There a user row that does not yet say what it is is stamped with its origin
8
+ * (`stampUserRowOrigin`, `user-row-origin.ts`: the one place every engine row gets the member the store keeps). With a handler on
9
+ * `session.append` the seat raises the event once per row; with none, or before the leg's bus is bound, the row passes as made and
10
+ * nothing is raised.
9
11
  *
10
12
  * `e = { door, origin, agentId?, message }` plus the identity envelope; `door`, `origin` and `agentId` are pinned. `door` and
11
13
  * `origin` are read off the row's own typed facts ({@link doorOf}, {@link originOf}) — no writer names them; an extension's
@@ -2,6 +2,7 @@ import { answeredWithoutModel } from "../../internal/llm.js";
2
2
  import { noteHostRewrite } from "../frame-settlement.js";
3
3
  import { describeThrown } from "../tool-policy.js";
4
4
  import { extensionWords } from "../untrusted-egress.js";
5
+ import { stampUserRowOrigin } from "../user-row-origin.js";
5
6
  import { isPlainRecord } from "./kernel/receive.js";
6
7
  import { NEXT_IN_FLIGHT, receiveEvent, sameModData } from "./kernel/site-rules.js";
7
8
  import { classicEventBase, seatHears } from "./stations.js";
@@ -256,6 +257,8 @@ export function createRowSeat() {
256
257
  };
257
258
  return {
258
259
  admitRows: (rows, raising) => {
260
+ for (const row of rows)
261
+ stampUserRowOrigin(row);
259
262
  const raised = raising !== undefined ? raisings.get(raising) : undefined;
260
263
  if (seatHears(bound, "session.append"))
261
264
  return admitAll(rows, raised);
@@ -205,23 +205,19 @@ export declare function stringMembersOf<M extends string>(answer: unknown, membe
205
205
  export declare function failedHandlerClause(f: Pick<Extract<ModDispatchOutcome, {
206
206
  kind: "failed";
207
207
  }>, "registration" | "cause" | "reason">): string;
208
- /** The clause without the bus's reason, `crashed (extension "x")`: for a sentence in place of a result the handler saw (its
209
- * reason may quote that result; the reason is said on the report sink). */
210
- export declare function failedHandlerName(f: Extract<ModDispatchOutcome, {
211
- kind: "failed";
212
- }>): string;
213
208
  /**
214
- * The PermissionDenied station: the leg's `classic.PermissionDenied` handlers, then a host's own raw observer (a host
215
- * driving the tool gate itself) as one more observe handler of the same event on a bus of its own — so every observer
216
- * of a deny runs under that station's columns (the handler's budget, skipped on a failure, a short grace past an
217
- * abort) and none can hold the deny it reports. The raw observer's failure goes to `onHostObserverFailure`.
209
+ * The PermissionDenied station, the one body every refusal exit raises: the leg's `classic.PermissionDenied` handlers, then a host's
210
+ * own raw observer (a host driving the tool gate) as one more observe handler of the event on a bus of its own, so every observer
211
+ * of a deny runs under the station's columns (budget, skip on failure, grace past an abort) and none can hold the deny it reports.
218
212
  */
219
213
  export declare function observePermissionDenied(input: {
220
214
  readonly legBus: LegModBus | undefined;
221
- readonly hostObserver: ((payload: PermissionDeniedPayload) => void | Promise<void>) | undefined;
215
+ readonly host?: {
216
+ readonly observe: (payload: PermissionDeniedPayload) => void | Promise<void>;
217
+ readonly onFailure: (err: Error) => void;
218
+ };
222
219
  readonly payload: PermissionDeniedPayload;
223
220
  readonly signal: AbortSignal | undefined;
224
- readonly onHostObserverFailure: (err: Error) => void;
225
221
  }): Promise<void>;
226
222
  /** What a prompt's screen came to, as the four entrances read it: `text` is what the entrance delivers (the prompt as it
227
223
  * came, or as `prompt.submit` handed it on — `rewrittenBy` then names who changed it, in the order they did); `block` the
@@ -182,15 +182,12 @@ const FAILURE_CLAUSE = Object.freeze({
182
182
  export function failedHandlerClause(f) {
183
183
  return FAILURE_CLAUSE[f.cause](extensionWords(f.registration, 80), ` ${extensionWords(f.reason, 200)}`);
184
184
  }
185
- export function failedHandlerName(f) {
186
- return FAILURE_CLAUSE[f.cause](extensionWords(f.registration, 80), "");
187
- }
188
185
  export async function observePermissionDenied(input) {
189
- const { payload, hostObserver } = input;
186
+ const { payload, host } = input;
190
187
  const e = { ...payload, ...classicEventBase(payload.identity, payload.permissionMode) };
191
188
  if (input.legBus?.hasHandlers("classic.PermissionDenied") === true)
192
189
  await observeClassic(input.legBus, "classic.PermissionDenied", e, input.signal);
193
- if (hostObserver === undefined)
190
+ if (host === undefined)
194
191
  return;
195
192
  const own = await admitModChain({
196
193
  deployment: [
@@ -198,10 +195,10 @@ export async function observePermissionDenied(input) {
198
195
  name: "toolGate.permissionDenied",
199
196
  tier: "user",
200
197
  uses: { events: ["classic.PermissionDenied"], calls: [] },
201
- register: (on) => on("classic.PermissionDenied", async () => void (await hostObserver(payload)), { observe: true }),
198
+ register: (on) => on("classic.PermissionDenied", async () => void (await host.observe(payload)), { observe: true }),
202
199
  },
203
200
  ],
204
- }, input.onHostObserverFailure);
201
+ }, host.onFailure);
205
202
  await observeClassic(own, "classic.PermissionDenied", e, input.signal);
206
203
  }
207
204
  const USER_PROMPT_RANKS = Object.freeze({ of: (a) => (stringMembersOf(a, ["block"]).block ? 1 : 0), top: 1 });
@@ -1,23 +1,23 @@
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`, 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.
4
+ * the same function). The chain's bottom is the tool's body; the event's failure column is `refuse_until_run`: a handler's
5
+ * failure refuses the call while the body has not started; once its own `next(e)` ran it, the handler is skipped and the
6
+ * result stands (said on the bus's failure sink). Only a `{ deny }` withholds a result that ran.
8
7
  *
9
8
  * `e = { tool, tool_use_id, agentId?, input }` (all four pinned — what the gate judged is what runs; a rewrite belongs to
10
9
  * `classic.PreToolUse`) plus the identity envelope; a handler may hand on `requestMeta` too (a record of strings an MCP call carries
11
10
  * as `_meta["sema/requestMeta"]`, judged where it is handed on — `mcp-call-meta.ts`). A handler answers:
12
11
  * - `next(e)` — the body runs; what came up is `{ result: { content, isError } }`, a frozen view of the real result;
13
- * - `{ deny: <reason> }` — refused before the body: the call is not executed and the record says an extension refused it
14
- * (a deny once the body has started cannot stand in place of a call that ran: a violation, and the result is withheld);
12
+ * - `{ deny: <reason> }` — in place of `next` (before the body): refused, not executed, the record names the extension; over
13
+ * what its `next` answered once the body ran: WITHHELD — the call ran (no `notExecuted`), the model reads who withheld it
14
+ * and why. Over a `next` still running, or over a body that threw (its throw is the outcome): a violation;
15
15
  * - `{ result }` — an extension's own result in place of the body (a string, or a list of text blocks), taken only when
16
16
  * both facts hold: the gate let this call go without anyone being asked about it (its latest gate record is an allow
17
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
18
18
  * has not started (the kernel's own record). Either missing, the answer is a violation: before the body the call is
19
- * refused, after it the result is withheld. A taken result is the call's result; the record says the body never ran
20
- * and names the extension (`tool_end.notExecuted`, `tool_end.answeredBy`).
19
+ * refused, after it the handler is skipped and the result stands. A taken result is the call's result; the record says
20
+ * the body never ran and names the extension (`tool_end.notExecuted`, `tool_end.answeredBy`).
21
21
  * Context for the model is added at `classic.PostToolUse`, not here. Whatever an extension answered in place of the body,
22
22
  * the call's post-execution stations stay silent, as for a call the gate blocked.
23
23
  *
@@ -56,6 +56,8 @@ export interface ToolCallStationInput {
56
56
  /** The leg's settlement seam: a result this station withholds settles the frames it carried as withheld by the host side
57
57
  * (`settleWithheldResult`), so none is owed again through another lane. Absent ⇒ no frame rides a call of this station. */
58
58
  readonly frameSettlement?: FrameSettlement;
59
+ /** The leg's report sink: a deny that gave no readable reason is said there. */
60
+ readonly report: (err: Error) => void;
59
61
  }
60
62
  /** The station over the leg's bus, or undefined when no handler hangs on `tool.call` (nothing is raised; the body runs). */
61
63
  export declare function createToolCallStation(input: ToolCallStationInput): ToolCallStation | undefined;
@@ -7,11 +7,11 @@ 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, failedHandlerName, judgedInputOf } from "./stations.js";
10
+ import { classicEventBase, failedHandlerClause, judgedInputOf } from "./stations.js";
11
11
  import { mintExtensionCallId, runExtensionCall } from "./extension-call.js";
12
12
  import { settleWithheldResult } from "../frame-settlement.js";
13
13
  const FORM = "tool.call takes next(e), { deny: <reason> } or { result } (a string, or a list of text blocks)";
14
- const denyOf = (a) => isPlainRecord(a) && Object.keys(a).length === 1 && typeof a["deny"] === "string" && a["deny"] !== "" ? a["deny"] : undefined;
14
+ const denyOf = (a) => !isPlainRecord(a) || !Object.hasOwn(a, "deny") ? undefined : typeof a["deny"] === "string" && a["deny"] !== "" ? { reason: a["deny"] } : {};
15
15
  function substituteOf(a) {
16
16
  if (!isPlainRecord(a) || Object.keys(a).length !== 1 || !Object.hasOwn(a, "result"))
17
17
  return undefined;
@@ -87,8 +87,10 @@ export function createToolCallStation(input) {
87
87
  const denied = denyOf(a) !== undefined;
88
88
  if (!denied && substituteOf(a) === undefined)
89
89
  return FORM;
90
+ if (denied && ran.bottomStarted)
91
+ return below.some((b) => b !== NEXT_IN_FLIGHT) ? undefined : "a deny after the tool started with no answer from its next(e) to withhold (it still runs, or the tool threw: the throw stands)";
90
92
  if (ran.bottomStarted)
91
- return `a ${denied ? "deny" : "result"} after the tool started (once the tool runs, nothing answers in its place)`;
93
+ return "a result after the tool started (once the tool runs, nothing answers in its place)";
92
94
  if (denied)
93
95
  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;
94
96
  if (below.includes(NEXT_IN_FLIGHT))
@@ -109,27 +111,22 @@ export function createToolCallStation(input) {
109
111
  return body;
110
112
  return { content: [{ type: "text", text: "Operation aborted" }], details: {}, isError: true };
111
113
  }
112
- if (outcome.kind === "failed") {
113
- if (outcome.bottomStarted === true && body !== undefined) {
114
- try {
115
- await body;
116
- }
117
- catch {
118
- return body;
119
- }
120
- }
121
- if (outcome.bottomStarted === true)
122
- 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)`);
114
+ if (outcome.kind === "failed")
123
115
  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)`);
124
- }
125
116
  const answer = outcome.answer;
126
117
  const ran = typeof answer === "object" && answer !== null ? bodies.get(answer) : undefined;
127
118
  if (ran !== undefined)
128
119
  return ran;
129
120
  const by = outcome.answeredBy ?? ENGINE_ORIGIN.plugin;
130
- const reason = denyOf(answer);
131
- if (reason !== undefined)
132
- return stationAnswer(call, by, `extension "${extensionWords(by, 80)}" refused this call to "${extensionWords(call.toolName, 80)}" before it ran: ${extensionWords(reason, 300)}`);
121
+ const deny = denyOf(answer);
122
+ if (deny !== undefined) {
123
+ if (deny.reason === undefined)
124
+ input.report(new Error(`${by}: tool.call: its deny gave no readable reason (a reason is a non-empty string) — the deny stands`));
125
+ const why = deny.reason !== undefined ? `: ${extensionWords(deny.reason, 300)}` : " (it gave no readable reason)";
126
+ if (body !== undefined)
127
+ return stationAnswer(call, undefined, `this call to "${extensionWords(call.toolName, 80)}" ran, and extension "${extensionWords(by, 80)}" withheld its result${why} — the call was executed and whatever it did has happened; it is only its result that is not shown`);
128
+ return stationAnswer(call, by, `extension "${extensionWords(by, 80)}" refused this call to "${extensionWords(call.toolName, 80)}" before it ran${why}`);
129
+ }
133
130
  const content = substituteOf(answer);
134
131
  if (content === undefined)
135
132
  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)`);
@@ -9,7 +9,6 @@
9
9
  */
10
10
  import type { McpServerSpec } from "./mcp-server-spec.js";
11
11
  import type { ToolContentOrigin } from "./tool-spec.js";
12
- import type { McpConnectionPool } from "./mcp-connection-pool.js";
13
12
  import type { McpHostSeat } from "./mcp-host-seat.js";
14
13
  import type { McpInstructionsEntry } from "./prompt-section-seat.js";
15
14
  /**
@@ -103,8 +102,6 @@ export interface MountedMcpServer {
103
102
  export interface MountedMcp {
104
103
  readonly servers: ReadonlyArray<MountedMcpServer>;
105
104
  readonly aggregate: ReadonlyArray<string>;
106
- /** The run tree's connection pool: a child that inherits the mount leases its connections from it. */
107
- readonly pool?: McpConnectionPool;
108
105
  /** 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. */
109
106
  readonly hostSeats?: ReadonlyMap<string, McpHostSeat>;
110
107
  }
@@ -144,7 +141,6 @@ export declare function mountedMcpOf(input: {
144
141
  readonly declared: ReadonlyArray<McpServerSpec> | undefined;
145
142
  readonly roster: ReadonlyArray<RosterEntry>;
146
143
  readonly aggregateNames: ReadonlySet<string>;
147
- readonly pool?: McpConnectionPool;
148
144
  readonly hostSeats?: ReadonlyMap<string, McpHostSeat>;
149
145
  }): MountedMcp;
150
146
  /**