@sema-agent/core 7.51.2 → 7.53.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (446) hide show
  1. package/CHANGELOG.md +698 -2
  2. package/README.md +3 -1
  3. package/dist/agents/agent-transcript-tool.d.ts +1 -1
  4. package/dist/agents/cascade.js +4 -0
  5. package/dist/agents/cross-session-envelope.d.ts +8 -0
  6. package/dist/agents/cross-session-envelope.js +6 -0
  7. package/dist/agents/cross-session-judge.d.ts +21 -1
  8. package/dist/agents/cross-session-judge.js +8 -0
  9. package/dist/agents/cross-session-ref.d.ts +5 -0
  10. package/dist/agents/cross-session-ref.js +1 -0
  11. package/dist/agents/cumulative-stats.d.ts +3 -0
  12. package/dist/agents/cumulative-stats.js +3 -0
  13. package/dist/agents/list-agents-tool.d.ts +1 -1
  14. package/dist/agents/org-delivery-gate.d.ts +122 -0
  15. package/dist/agents/org-delivery-gate.js +69 -0
  16. package/dist/agents/peer-held-queue.d.ts +9 -4
  17. package/dist/agents/peer-held-queue.js +6 -5
  18. package/dist/agents/peer-session-drain.d.ts +35 -5
  19. package/dist/agents/peer-session-drain.js +271 -180
  20. package/dist/agents/read-inbox-tool.d.ts +8 -1
  21. package/dist/agents/read-inbox-tool.js +5 -1
  22. package/dist/agents/repair-loop.js +4 -0
  23. package/dist/agents/send-message-tool.d.ts +11 -16
  24. package/dist/agents/send-message-tool.js +11 -13
  25. package/dist/agents/subagent.d.ts +3 -0
  26. package/dist/agents/subagent.js +105 -76
  27. package/dist/agents/tool-filter.d.ts +58 -13
  28. package/dist/agents/tool-filter.js +34 -14
  29. package/dist/bench/metrics.d.ts +1 -0
  30. package/dist/brain/anthropic.d.ts +6 -1
  31. package/dist/brain/anthropic.js +17 -13
  32. package/dist/brain/model-presets.d.ts +4 -5
  33. package/dist/brain/model-presets.js +6 -5
  34. package/dist/brain/open-responses.js +16 -12
  35. package/dist/brain/openai.js +16 -12
  36. package/dist/brain/request-params.d.ts +12 -33
  37. package/dist/brain/request-params.js +5 -2
  38. package/dist/brain/request-route.d.ts +9 -8
  39. package/dist/brain/request-route.js +1 -0
  40. package/dist/brain/route-adjudicator.d.ts +123 -47
  41. package/dist/brain/route-adjudicator.js +171 -42
  42. package/dist/brain/route-conformance.js +2 -2
  43. package/dist/brain/routing.d.ts +24 -1
  44. package/dist/brain/routing.js +54 -19
  45. package/dist/brain/status-sink.d.ts +18 -0
  46. package/dist/brain/status-sink.js +7 -0
  47. package/dist/brain/timeout.js +5 -4
  48. package/dist/core/a2a.d.ts +5 -2
  49. package/dist/core/a2a.js +30 -13
  50. package/dist/core/allow-entry.d.ts +42 -9
  51. package/dist/core/allow-entry.js +25 -18
  52. package/dist/core/auto-compaction.d.ts +80 -20
  53. package/dist/core/auto-compaction.js +65 -18
  54. package/dist/core/auto-promote.d.ts +2 -1
  55. package/dist/core/auto-promote.js +2 -2
  56. package/dist/core/caller-tool-name.d.ts +9 -0
  57. package/dist/core/caller-tool-name.js +13 -0
  58. package/dist/core/checkpoint-requirements.d.ts +7 -1
  59. package/dist/core/checkpoint-requirements.js +2 -0
  60. package/dist/core/checkpoint-store.d.ts +57 -24
  61. package/dist/core/checkpoint-store.js +3 -3
  62. package/dist/core/child-clamp-seats.d.ts +6 -0
  63. package/dist/core/child-clamp-seats.js +2 -1
  64. package/dist/core/compliance.js +3 -1
  65. package/dist/core/credential-vocabulary.d.ts +33 -8
  66. package/dist/core/credential-vocabulary.js +32 -7
  67. package/dist/core/decision-receipt.d.ts +2 -2
  68. package/dist/core/delegation-frames.d.ts +9 -2
  69. package/dist/core/delegation-name.d.ts +18 -0
  70. package/dist/core/delegation-name.js +47 -0
  71. package/dist/core/effective-path-target.d.ts +25 -6
  72. package/dist/core/effective-path-target.js +24 -2
  73. package/dist/core/engine-capabilities.d.ts +8 -1
  74. package/dist/core/engine-capabilities.js +1 -1
  75. package/dist/core/engine-notice.d.ts +49 -21
  76. package/dist/core/frontmatter-fence.d.ts +10 -0
  77. package/dist/core/frontmatter-fence.js +6 -0
  78. package/dist/core/gate-fold.js +8 -25
  79. package/dist/core/gate-lanes.js +358 -274
  80. package/dist/core/gate-outcome.d.ts +11 -6
  81. package/dist/core/governance-codes.d.ts +11 -4
  82. package/dist/core/governance-codes.js +12 -3
  83. package/dist/core/hands-band-screen.d.ts +7 -0
  84. package/dist/core/hands-band-screen.js +32 -0
  85. package/dist/core/hooks.d.ts +283 -739
  86. package/dist/core/hooks.js +100 -193
  87. package/dist/{tools/fs → core}/image-admission.d.ts +21 -3
  88. package/dist/{tools/fs → core}/image-admission.js +24 -6
  89. package/dist/core/locked-config.d.ts +84 -32
  90. package/dist/core/locked-config.js +128 -42
  91. package/dist/core/mcp-connection-pool.d.ts +4 -1
  92. package/dist/core/mcp-connection-pool.js +7 -2
  93. package/dist/core/mcp-probe.d.ts +12 -9
  94. package/dist/core/mcp-probe.js +3 -3
  95. package/dist/core/mcp-server-spec.d.ts +104 -10
  96. package/dist/core/mcp-server-spec.js +183 -33
  97. package/dist/core/mcp.d.ts +31 -20
  98. package/dist/core/mcp.js +66 -56
  99. package/dist/core/memory-engine/data-plane.js +5 -1
  100. package/dist/core/memory-engine/distiller.js +16 -2
  101. package/dist/core/memory-engine/engine.d.ts +22 -30
  102. package/dist/core/memory-engine/engine.js +16 -10
  103. package/dist/core/memory-engine/frontmatter.d.ts +6 -0
  104. package/dist/core/memory-engine/frontmatter.js +19 -16
  105. package/dist/core/memory.d.ts +2 -2
  106. package/dist/core/mode-policy.d.ts +5 -16
  107. package/dist/core/mode-policy.js +7 -19
  108. package/dist/core/model-seat.d.ts +4 -1
  109. package/dist/core/mods/dollar.d.ts +109 -0
  110. package/dist/core/mods/dollar.js +154 -0
  111. package/dist/core/mods/host.d.ts +23 -0
  112. package/dist/core/mods/host.js +21 -0
  113. package/dist/core/mods/kernel/budget.d.ts +43 -0
  114. package/dist/core/mods/kernel/budget.js +83 -0
  115. package/dist/core/mods/kernel/dispatch.d.ts +100 -0
  116. package/dist/core/mods/kernel/dispatch.js +699 -0
  117. package/dist/core/mods/kernel/events.d.ts +245 -0
  118. package/dist/core/mods/kernel/events.js +210 -0
  119. package/dist/core/mods/kernel/index.d.ts +6 -0
  120. package/dist/core/mods/kernel/index.js +5 -0
  121. package/dist/core/mods/kernel/receive.d.ts +94 -0
  122. package/dist/core/mods/kernel/receive.js +188 -0
  123. package/dist/core/mods/kernel/registration.d.ts +131 -0
  124. package/dist/core/mods/kernel/registration.js +102 -0
  125. package/dist/core/mods/kernel/site-rules.d.ts +149 -0
  126. package/dist/core/mods/kernel/site-rules.js +296 -0
  127. package/dist/core/mods/stations.d.ts +344 -0
  128. package/dist/core/mods/stations.js +437 -0
  129. package/dist/core/mounted-mcp.d.ts +57 -0
  130. package/dist/core/mounted-mcp.js +71 -2
  131. package/dist/core/own-property-receipt.d.ts +13 -0
  132. package/dist/core/own-property-receipt.js +13 -23
  133. package/dist/core/parent-spec-seat.d.ts +18 -7
  134. package/dist/core/parent-spec-seat.js +6 -2
  135. package/dist/core/path-identity.js +2 -1
  136. package/dist/core/permission-rule-model.d.ts +58 -9
  137. package/dist/core/permission-rule-model.js +81 -7
  138. package/dist/core/permission-rule-org.d.ts +163 -33
  139. package/dist/core/permission-rule-org.js +205 -71
  140. package/dist/core/permission-rule-syntax.d.ts +15 -0
  141. package/dist/core/permission-rule-syntax.js +24 -16
  142. package/dist/core/permission-rules.d.ts +14 -2
  143. package/dist/core/permission-rules.js +63 -23
  144. package/dist/core/prompt-section-seat.d.ts +15 -27
  145. package/dist/core/prompt-section-seat.js +73 -40
  146. package/dist/core/protocol-http-auth.d.ts +3 -1
  147. package/dist/core/protocol-http-auth.js +2 -0
  148. package/dist/core/reminder-mint.d.ts +2 -2
  149. package/dist/core/remote-env.d.ts +24 -12
  150. package/dist/core/remote-env.js +1 -0
  151. package/dist/core/resume-startup-cause.d.ts +16 -1
  152. package/dist/core/resume-startup-cause.js +4 -1
  153. package/dist/core/retention.js +7 -2
  154. package/dist/core/retired-keys.d.ts +12 -2
  155. package/dist/core/retired-keys.js +15 -1
  156. package/dist/core/roles.js +60 -10
  157. package/dist/core/rule-lane-reads.js +1 -1
  158. package/dist/core/runner/announce-once-ledger.d.ts +31 -1
  159. package/dist/core/runner/announce-once-ledger.js +22 -0
  160. package/dist/core/runner/assemble-result.d.ts +9 -0
  161. package/dist/core/runner/assemble-result.js +3 -1
  162. package/dist/core/runner/call-hook-stations.d.ts +23 -27
  163. package/dist/core/runner/call-hook-stations.js +58 -42
  164. package/dist/core/runner/caller-stop-gate.d.ts +25 -0
  165. package/dist/core/runner/caller-stop-gate.js +7 -0
  166. package/dist/core/runner/compaction-seams.d.ts +8 -22
  167. package/dist/core/runner/compaction-seams.js +28 -53
  168. package/dist/core/runner/construction-doors.js +11 -1
  169. package/dist/core/runner/contracts.d.ts +86 -83
  170. package/dist/core/runner/credential-origin-seat.d.ts +2 -0
  171. package/dist/core/runner/credential-origin-seat.js +19 -0
  172. package/dist/core/runner/extra-body-dropped-seat.d.ts +2 -6
  173. package/dist/core/runner/gate-exit.d.ts +47 -36
  174. package/dist/core/runner/gate-exit.js +12 -5
  175. package/dist/core/runner/image.js +1 -2
  176. package/dist/core/runner/inline-image.js +1 -1
  177. package/dist/core/runner/mcp-redial.d.ts +52 -10
  178. package/dist/core/runner/mcp-redial.js +38 -9
  179. package/dist/core/runner/notice-seat-input.d.ts +11 -0
  180. package/dist/core/runner/notice-seat-input.js +1 -0
  181. package/dist/core/runner/permission-rule-lanes.d.ts +5 -2
  182. package/dist/core/runner/permission-rule-lanes.js +22 -10
  183. package/dist/core/runner/person-path-rows.d.ts +3 -1
  184. package/dist/core/runner/person-path-rows.js +3 -2
  185. package/dist/core/runner/prepare-acquire-reconcile.js +5 -1
  186. package/dist/core/runner/prepare-ask-lane.d.ts +5 -7
  187. package/dist/core/runner/prepare-ask-lane.js +6 -15
  188. package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -2
  189. package/dist/core/runner/prepare-caps-and-workflow.js +25 -8
  190. package/dist/core/runner/prepare-config-doors.d.ts +52 -1
  191. package/dist/core/runner/prepare-config-doors.js +168 -143
  192. package/dist/core/runner/prepare-defer-classify.js +7 -11
  193. package/dist/core/runner/prepare-delegation-surface.d.ts +2 -2
  194. package/dist/core/runner/prepare-delegation-surface.js +7 -5
  195. package/dist/core/runner/prepare-gate-stations.d.ts +8 -11
  196. package/dist/core/runner/prepare-gate-stations.js +11 -10
  197. package/dist/core/runner/prepare-hands-readface.d.ts +1 -1
  198. package/dist/core/runner/prepare-hands-readface.js +2 -1
  199. package/dist/core/runner/prepare-inherited-gate.d.ts +8 -12
  200. package/dist/core/runner/prepare-inherited-gate.js +10 -23
  201. package/dist/core/runner/prepare-listings.d.ts +1 -1
  202. package/dist/core/runner/prepare-listings.js +4 -2
  203. package/dist/core/runner/prepare-memory-engine-session.d.ts +0 -6
  204. package/dist/core/runner/prepare-memory-engine-session.js +20 -7
  205. package/dist/core/runner/prepare-memory.d.ts +3 -2
  206. package/dist/core/runner/prepare-memory.js +6 -2
  207. package/dist/core/runner/prepare-offload-wrappers.d.ts +4 -4
  208. package/dist/core/runner/prepare-offload-wrappers.js +2 -1
  209. package/dist/core/runner/prepare-park-ask.js +10 -14
  210. package/dist/core/runner/prepare-policy-chain.d.ts +17 -15
  211. package/dist/core/runner/prepare-policy-chain.js +104 -109
  212. package/dist/core/runner/prepare-project-context.d.ts +1 -1
  213. package/dist/core/runner/prepare-project-context.js +11 -12
  214. package/dist/core/runner/prepare-prompt-assembly.d.ts +45 -40
  215. package/dist/core/runner/prepare-prompt-assembly.js +138 -101
  216. package/dist/core/runner/prepare-prompt-inputs.d.ts +28 -23
  217. package/dist/core/runner/prepare-prompt-inputs.js +11 -10
  218. package/dist/core/runner/prepare-protocol-tools.d.ts +11 -7
  219. package/dist/core/runner/prepare-protocol-tools.js +20 -13
  220. package/dist/core/runner/prepare-question-face.d.ts +4 -2
  221. package/dist/core/runner/prepare-question-face.js +4 -3
  222. package/dist/core/runner/prepare-safety-scan.js +6 -10
  223. package/dist/core/runner/prepare-suspend-saga.d.ts +6 -0
  224. package/dist/core/runner/prepare-suspend-saga.js +7 -5
  225. package/dist/core/runner/prepare-task.js +41 -23
  226. package/dist/core/runner/prepare-turn-wiring.d.ts +13 -15
  227. package/dist/core/runner/prepare-turn-wiring.js +29 -27
  228. package/dist/core/runner/prepare-wiring-manifest.d.ts +13 -9
  229. package/dist/core/runner/prepare-wiring-manifest.js +14 -11
  230. package/dist/core/runner/resume-admission.d.ts +4 -1
  231. package/dist/core/runner/resume-admission.js +7 -5
  232. package/dist/core/runner/resume-apply.d.ts +5 -2
  233. package/dist/core/runner/resume-apply.js +24 -42
  234. package/dist/core/runner/resume-checkpoint-screen.d.ts +1 -0
  235. package/dist/core/runner/resume-checkpoint-screen.js +9 -1
  236. package/dist/core/runner/resume-internals-and-config.d.ts +3 -3
  237. package/dist/core/runner/resume-internals-and-config.js +3 -8
  238. package/dist/core/runner/resume-preflight.js +38 -16
  239. package/dist/core/runner/retired-runner-deps.d.ts +5 -6
  240. package/dist/core/runner/retired-runner-deps.js +4 -5
  241. package/dist/core/runner/run-brain-sinks.d.ts +3 -2
  242. package/dist/core/runner/run-brain-sinks.js +5 -1
  243. package/dist/core/runner/run-compaction-machinery.d.ts +7 -1
  244. package/dist/core/runner/run-compaction-machinery.js +7 -33
  245. package/dist/core/runner/run-harness-handlers.js +4 -2
  246. package/dist/core/runner/run-identity-wiring.d.ts +3 -1
  247. package/dist/core/runner/run-identity-wiring.js +3 -2
  248. package/dist/core/runner/run-leg.js +103 -95
  249. package/dist/core/runner/run-notification-lane.js +1 -0
  250. package/dist/core/runner/run-recovery-lanes.d.ts +3 -0
  251. package/dist/core/runner/run-recovery-lanes.js +14 -11
  252. package/dist/core/runner/run-settle-and-teardown.js +9 -28
  253. package/dist/core/runner/run-stop-and-final-verify.js +18 -25
  254. package/dist/core/runner/run-terminal-adoption.d.ts +3 -0
  255. package/dist/core/runner/run-terminal-adoption.js +34 -22
  256. package/dist/core/runner/run-tool-mount-facts.js +5 -3
  257. package/dist/core/runner/run-turn-boundary.js +32 -37
  258. package/dist/core/runner/runtask.d.ts +6 -7
  259. package/dist/core/runner/runtask.js +15 -73
  260. package/dist/core/runner/session-rule-policy.d.ts +5 -5
  261. package/dist/core/runner/session-rule-policy.js +13 -8
  262. package/dist/core/runner/side-call-account.d.ts +68 -0
  263. package/dist/core/runner/side-call-account.js +61 -0
  264. package/dist/core/runner/skills-seat.d.ts +15 -0
  265. package/dist/core/runner/skills-seat.js +57 -0
  266. package/dist/core/runner/stream-halt-verbs.js +12 -17
  267. package/dist/core/runner/stream-lifecycle-verbs.js +8 -5
  268. package/dist/core/runner/stream-steer-verb.d.ts +1 -1
  269. package/dist/core/runner/stream-steer-verb.js +20 -38
  270. package/dist/core/runner/sub-agent-deny-lists.d.ts +124 -23
  271. package/dist/core/runner/sub-agent-deny-lists.js +230 -71
  272. package/dist/core/runner/synthetic-tools.d.ts +5 -2
  273. package/dist/core/runner/synthetic-tools.js +2 -12
  274. package/dist/core/runner/tool-end-body.d.ts +5 -6
  275. package/dist/core/runner/tool-end-body.js +6 -4
  276. package/dist/core/runner/tool-not-executed.d.ts +15 -0
  277. package/dist/core/runner/tool-not-executed.js +30 -0
  278. package/dist/core/runner/tool-occurrence.d.ts +8 -7
  279. package/dist/core/runner/tool-occurrence.js +5 -5
  280. package/dist/core/runner/tool-result-media-seat.d.ts +1 -1
  281. package/dist/core/runner-deps.d.ts +43 -36
  282. package/dist/core/safety-merge-corpus.js +18 -2
  283. package/dist/core/secret-env.d.ts +88 -20
  284. package/dist/core/secret-env.js +192 -38
  285. package/dist/core/session-policy-store.d.ts +71 -16
  286. package/dist/core/session-policy-store.js +138 -28
  287. package/dist/core/session-reconcile.d.ts +4 -0
  288. package/dist/core/session-reconcile.js +2 -1
  289. package/dist/core/shell-read-silence.js +3 -32
  290. package/dist/core/side-query.d.ts +5 -3
  291. package/dist/core/skill-grant.d.ts +3 -2
  292. package/dist/core/skill-grant.js +17 -9
  293. package/dist/core/skills-directory.d.ts +31 -11
  294. package/dist/core/skills-directory.js +655 -104
  295. package/dist/core/store-contracts/mailbox-store-contract.js +13 -0
  296. package/dist/core/task-event.d.ts +49 -3
  297. package/dist/core/task-notification.js +2 -2
  298. package/dist/core/task-result.d.ts +8 -0
  299. package/dist/core/task-spec.d.ts +20 -19
  300. package/dist/core/task-stream.d.ts +14 -4
  301. package/dist/core/tighten-task-spec.d.ts +4 -3
  302. package/dist/core/tighten-task-spec.js +2 -4
  303. package/dist/core/tool-check-reading.d.ts +74 -0
  304. package/dist/core/tool-check-reading.js +80 -0
  305. package/dist/core/tool-policy.d.ts +62 -18
  306. package/dist/core/tool-policy.js +86 -15
  307. package/dist/core/tool-registry.d.ts +20 -0
  308. package/dist/core/tool-registry.js +4 -0
  309. package/dist/core/tool-spec.d.ts +10 -6
  310. package/dist/core/tools.js +2 -0
  311. package/dist/core/trace.d.ts +51 -32
  312. package/dist/core/types.d.ts +2 -2
  313. package/dist/core/types.js +1 -1
  314. package/dist/core/unc-spelling.d.ts +10 -0
  315. package/dist/core/unc-spelling.js +3 -0
  316. package/dist/core/untrusted-egress.d.ts +8 -0
  317. package/dist/core/untrusted-egress.js +4 -1
  318. package/dist/core/untrusted-text.d.ts +16 -0
  319. package/dist/core/untrusted-text.js +7 -2
  320. package/dist/core/user-attachment.d.ts +25 -4
  321. package/dist/core/user-attachment.js +63 -42
  322. package/dist/core/wiring-manifest.d.ts +18 -15
  323. package/dist/core/wiring-manifest.js +2 -2
  324. package/dist/engine/compaction/utils.js +1 -2
  325. package/dist/engine/execution-env/node-execution-env.d.ts +4 -3
  326. package/dist/engine/execution-env/symlink-chain.js +1 -1
  327. package/dist/engine/harness/agent-harness.d.ts +1 -1
  328. package/dist/engine/harness/agent-harness.js +5 -4
  329. package/dist/engine/harness/types.d.ts +20 -16
  330. package/dist/engine/harness/types.js +7 -1
  331. package/dist/engine/llm/types.d.ts +12 -7
  332. package/dist/engine/loop/agent-loop.d.ts +12 -1
  333. package/dist/engine/loop/agent-loop.js +18 -6
  334. package/dist/engine/loop/types.d.ts +8 -2
  335. package/dist/engine/lsp/node-lsp-manager.d.ts +2 -2
  336. package/dist/engine/session/import-validate.js +3 -10
  337. package/dist/engine/session/session.d.ts +4 -4
  338. package/dist/engine/session/session.js +4 -4
  339. package/dist/index.d.ts +33 -23
  340. package/dist/index.js +23 -15
  341. package/dist/internal/harness.d.ts +2 -1
  342. package/dist/internal/harness.js +2 -1
  343. package/dist/orchestration/goal.d.ts +24 -1
  344. package/dist/orchestration/goal.js +3 -2
  345. package/dist/orchestration/run-spec.d.ts +4 -6
  346. package/dist/orchestration/run-spec.js +39 -63
  347. package/dist/orchestration/run-workflow-tool.js +1 -2
  348. package/dist/orchestration/workflow.d.ts +11 -3
  349. package/dist/orchestration/workflow.js +11 -2
  350. package/dist/prompt-assembly/artifact-store.d.ts +72 -56
  351. package/dist/prompt-assembly/artifact-store.js +60 -52
  352. package/dist/prompt-assembly/artifact.d.ts +90 -76
  353. package/dist/prompt-assembly/artifact.js +197 -145
  354. package/dist/prompt-assembly/assemble.d.ts +36 -29
  355. package/dist/prompt-assembly/assemble.js +34 -220
  356. package/dist/prompt-assembly/bands.d.ts +20 -0
  357. package/dist/prompt-assembly/bands.js +18 -0
  358. package/dist/prompt-assembly/catalog/constitution.d.ts +23 -0
  359. package/dist/prompt-assembly/catalog/constitution.js +69 -0
  360. package/dist/prompt-assembly/catalog/core-behavior.d.ts +9 -0
  361. package/dist/prompt-assembly/catalog/core-behavior.js +85 -0
  362. package/dist/prompt-assembly/catalog/index.d.ts +11 -0
  363. package/dist/prompt-assembly/catalog/index.js +60 -0
  364. package/dist/prompt-assembly/catalog/memory.d.ts +13 -0
  365. package/dist/prompt-assembly/catalog/memory.js +6 -0
  366. package/dist/prompt-assembly/catalog/modes.d.ts +15 -0
  367. package/dist/prompt-assembly/catalog/modes.js +137 -0
  368. package/dist/prompt-assembly/catalog/role.d.ts +10 -0
  369. package/dist/prompt-assembly/catalog/role.js +157 -0
  370. package/dist/prompt-assembly/catalog/schema.d.ts +138 -0
  371. package/dist/prompt-assembly/catalog/schema.js +25 -0
  372. package/dist/prompt-assembly/catalog/sections.d.ts +9 -0
  373. package/dist/prompt-assembly/catalog/sections.js +98 -0
  374. package/dist/prompt-assembly/catalog/team.d.ts +4 -0
  375. package/dist/prompt-assembly/catalog/team.js +258 -0
  376. package/dist/prompt-assembly/composer.d.ts +26 -28
  377. package/dist/prompt-assembly/composer.js +124 -46
  378. package/dist/prompt-assembly/epoch.d.ts +89 -79
  379. package/dist/prompt-assembly/epoch.js +115 -142
  380. package/dist/prompt-assembly/explain.d.ts +58 -34
  381. package/dist/prompt-assembly/explain.js +21 -24
  382. package/dist/prompt-assembly/overlay.d.ts +137 -0
  383. package/dist/prompt-assembly/overlay.js +339 -0
  384. package/dist/prompt-assembly/renderers.d.ts +21 -0
  385. package/dist/prompt-assembly/renderers.js +39 -0
  386. package/dist/prompt-assembly/section-usage.d.ts +3 -3
  387. package/dist/prompt-assembly/section-usage.js +1 -1
  388. package/dist/prompt-assembly/select.d.ts +71 -0
  389. package/dist/prompt-assembly/select.js +106 -0
  390. package/dist/prompt-assembly/sugar.d.ts +31 -0
  391. package/dist/prompt-assembly/sugar.js +20 -0
  392. package/dist/prompt-assembly/turn-snapshot.d.ts +3 -2
  393. package/dist/prompt-assembly/types.d.ts +45 -148
  394. package/dist/prompts/coordinator.d.ts +2 -21
  395. package/dist/prompts/coordinator.js +3 -255
  396. package/dist/prompts/cowork.d.ts +27 -16
  397. package/dist/prompts/cowork.js +2 -23
  398. package/dist/prompts/default.d.ts +38 -511
  399. package/dist/prompts/default.js +20 -288
  400. package/dist/prompts/supervisor.d.ts +6 -71
  401. package/dist/prompts/supervisor.js +6 -117
  402. package/dist/stores/file/permission-rule-store.d.ts +1 -1
  403. package/dist/stores/file/permission-rule-store.js +2 -1
  404. package/dist/tools/artifact/artifact-tool.js +4 -3
  405. package/dist/tools/fs/bash-readonly-classifier.d.ts +6 -5
  406. package/dist/tools/fs/dir-entries.d.ts +4 -2
  407. package/dist/tools/fs/dir-entries.js +16 -4
  408. package/dist/tools/fs/fs-bash.d.ts +1 -1
  409. package/dist/tools/fs/fs-bash.js +22 -11
  410. package/dist/tools/fs/fs-pdf.js +17 -13
  411. package/dist/tools/fs/fs-read.js +4 -3
  412. package/dist/tools/fs/fs-shared.d.ts +1 -10
  413. package/dist/tools/fs/fs-shared.js +3 -4
  414. package/dist/tools/fs/fs-write.js +2 -1
  415. package/dist/tools/fs/notebook.js +1 -1
  416. package/dist/tools/fs/pdf.d.ts +20 -10
  417. package/dist/tools/fs/pdf.js +19 -10
  418. package/dist/tools/fs/program-read-model.d.ts +68 -8
  419. package/dist/tools/fs/program-read-model.js +112 -33
  420. package/dist/tools/fs/program-read-model.rows.js +30 -10
  421. package/dist/tools/fs/read-deny-home.d.ts +25 -9
  422. package/dist/tools/fs/read-deny-home.js +28 -27
  423. package/dist/tools/fs/read-deny.d.ts +41 -11
  424. package/dist/tools/fs/read-deny.js +51 -5
  425. package/dist/tools/fs/safety.d.ts +4 -26
  426. package/dist/tools/fs/safety.js +10 -32
  427. package/dist/tools/fs/search.js +15 -10
  428. package/dist/tools/fs/shell-read-argv.d.ts +3 -2
  429. package/dist/tools/fs/shell-read-argv.js +118 -38
  430. package/dist/tools/fs/shell-read-establish.d.ts +5 -5
  431. package/dist/tools/fs/shell-read-establish.js +11 -61
  432. package/dist/tools/fs/shell-read-identity.js +6 -3
  433. package/dist/tools/fs/shell-read-judge.d.ts +13 -15
  434. package/dist/tools/fs/shell-read-judge.js +18 -4
  435. package/dist/tools/fs/shell-read-plan.d.ts +2 -2
  436. package/dist/tools/web.js +1 -1
  437. package/package.json +13 -1
  438. package/test/export-surface.snapshot.json +306 -103
  439. package/wire-changes/core@7.52.0.json +5859 -0
  440. package/wire-changes/core@7.53.0.json +1946 -0
  441. package/dist/core/hook-seats.d.ts +0 -66
  442. package/dist/core/hook-seats.js +0 -37
  443. package/dist/prompt-assembly/packs/sema-default.d.ts +0 -2
  444. package/dist/prompt-assembly/packs/sema-default.js +0 -147
  445. package/dist/prompts/simple-sections.d.ts +0 -58
  446. package/dist/prompts/simple-sections.js +0 -43
@@ -0,0 +1,296 @@
1
+ import { describe } from "./events.js";
2
+ import { describeFault, isPlainRecord, MODS_PAYLOAD_MODE, receive } from "./receive.js";
3
+ export const MODS_VALUE_DEPTH = 1_000;
4
+ const HANDED_MODE = Object.freeze({ ...MODS_PAYLOAD_MODE, depth: MODS_VALUE_DEPTH + 1, past: "refuse" });
5
+ function payloadMode(isProxy) {
6
+ return isProxy === undefined ? HANDED_MODE : Object.freeze({ ...HANDED_MODE, isProxy });
7
+ }
8
+ const TOO_DEEP_TO_COMPARE = `too deep to compare (nested past ${MODS_VALUE_DEPTH} levels)`;
9
+ function faultClause(fault) {
10
+ if (fault.kind !== "too-deep")
11
+ return describeFault(fault);
12
+ return `a value nested past ${MODS_VALUE_DEPTH} levels${fault.path.length > 0 ? ` under "${fault.path[0]}"` : ""}`;
13
+ }
14
+ export const MOD_FAILURE_CAUSES = Object.freeze(["threw", "timeout", "violation", "reentry"]);
15
+ export const NEXT_IN_FLIGHT = Object.freeze({ inFlight: true });
16
+ const TOO_DEEP = Object.freeze({ tooDeep: true });
17
+ const OPEN = "open";
18
+ function sameModValue(a0, b0, paired, depth0, homes) {
19
+ const stack = [];
20
+ const named = (r) => Object.keys(r).filter((k) => r[k] !== undefined);
21
+ const meet = (a, b, depth) => {
22
+ if (a === b || (Number.isNaN(a) && Number.isNaN(b)))
23
+ return 0;
24
+ if (typeof a !== "object" || typeof b !== "object" || a === null || b === null)
25
+ return false;
26
+ let row = paired.get(a);
27
+ const met = row?.get(b);
28
+ if (met !== undefined) {
29
+ const height = met === OPEN ? 1 : met;
30
+ if (depth + height - 1 > MODS_VALUE_DEPTH)
31
+ throw TOO_DEEP;
32
+ return height;
33
+ }
34
+ if (depth > MODS_VALUE_DEPTH)
35
+ throw TOO_DEEP;
36
+ if (row === undefined)
37
+ paired.set(a, (row = new Map()));
38
+ row.set(b, OPEN);
39
+ if (!homes.has(b))
40
+ homes.set(b, a);
41
+ if (Array.isArray(a) || Array.isArray(b)) {
42
+ if (!Array.isArray(a) || !Array.isArray(b) || Object.getPrototypeOf(a) !== Array.prototype || Object.getPrototypeOf(b) !== Array.prototype || a.length !== b.length)
43
+ return false;
44
+ }
45
+ else if (!isPlainRecord(a) || !isPlainRecord(b))
46
+ return false;
47
+ const ra = a;
48
+ const rb = b;
49
+ const names = named(ra);
50
+ if (names.length !== named(rb).length)
51
+ return false;
52
+ stack.push({ a: ra, b: rb, row, names, depth, next: 0, height: 1 });
53
+ return undefined;
54
+ };
55
+ const top = meet(a0, b0, depth0);
56
+ if (top !== undefined)
57
+ return top;
58
+ for (;;) {
59
+ const f = stack[stack.length - 1];
60
+ if (f.next < f.names.length) {
61
+ const k = f.names[f.next++];
62
+ if (!Object.hasOwn(f.b, k))
63
+ return false;
64
+ const below = meet(f.a[k], f.b[k], f.depth + 1);
65
+ if (below === false)
66
+ return false;
67
+ if (below !== undefined)
68
+ f.height = Math.max(f.height, below + 1);
69
+ continue;
70
+ }
71
+ f.row.set(f.b, f.height);
72
+ stack.pop();
73
+ const holder = stack[stack.length - 1];
74
+ if (holder === undefined)
75
+ return f.height;
76
+ holder.height = Math.max(holder.height, f.height + 1);
77
+ }
78
+ }
79
+ export function pinnedKeyChanged(pinned, received, passed) {
80
+ const compared = comparePinned(pinned, received, passed);
81
+ return "broke" in compared ? compared.broke : undefined;
82
+ }
83
+ function comparePinned(pinned, received, passed) {
84
+ const paired = new Map();
85
+ const homes = new Map();
86
+ for (const key of pinned) {
87
+ try {
88
+ if (sameModValue(received[key], passed[key], paired, 1, homes) === false)
89
+ return { broke: { key } };
90
+ }
91
+ catch (err) {
92
+ return { broke: { key, unproven: err === TOO_DEEP ? TOO_DEEP_TO_COMPARE : "the comparison could not walk it to the end" } };
93
+ }
94
+ }
95
+ return { homes };
96
+ }
97
+ function engineObjects(held) {
98
+ const found = new Set();
99
+ const stack = Object.values(held);
100
+ while (stack.length > 0) {
101
+ const v = stack.pop();
102
+ if (typeof v !== "object" || v === null || found.has(v) || !Object.isFrozen(v))
103
+ continue;
104
+ if (!isPlainRecord(v) && !(Array.isArray(v) && Object.getPrototypeOf(v) === Array.prototype))
105
+ continue;
106
+ found.add(v);
107
+ for (const k of Object.keys(v))
108
+ stack.push(v[k]);
109
+ }
110
+ return found;
111
+ }
112
+ export function engineObjectsOnce(held) {
113
+ let found;
114
+ return () => (found ??= engineObjects(held));
115
+ }
116
+ const unprovenCopy = (key, why) => `next() handed on a copy of the pinned key "${key}" that is ${why}; a copy is taken only when proven the same`;
117
+ export function handedOn(pinned, held, passed, engines, isProxy) {
118
+ const received = receiveRecord(passed, payloadMode(isProxy), engines);
119
+ if ("refusal" in received) {
120
+ const key = received.fault?.kind === "too-deep" ? received.fault.path[0] : undefined;
121
+ return { violation: key !== undefined && pinned.includes(key) ? unprovenCopy(key, TOO_DEEP_TO_COMPARE) : `next() takes the event object: ${received.refusal}` };
122
+ }
123
+ return pinnedHandOn(pinned, held, received.payload, engines);
124
+ }
125
+ export function pinnedHandOn(pinned, held, passed, engines) {
126
+ const compared = comparePinned(pinned, held, passed);
127
+ if ("broke" in compared) {
128
+ return { violation: compared.broke.unproven === undefined ? `next() changed the pinned key "${compared.broke.key}"` : unprovenCopy(compared.broke.key, compared.broke.unproven) };
129
+ }
130
+ if (pinned.every((k) => Object.hasOwn(passed, k) === Object.hasOwn(held, k) && Object.is(passed[k], held[k])))
131
+ return { payload: passed };
132
+ return { payload: rehomed(pinned, held, passed, compared.homes, engines ?? engineObjects(held)) };
133
+ }
134
+ function rehomed(pinned, held, passed, homes, engines) {
135
+ const swap = new Map();
136
+ for (const [copy, home] of homes)
137
+ if (copy !== passed && !engines.has(copy))
138
+ swap.set(copy, home);
139
+ const isContainer = (v) => typeof v === "object" && v !== null && !engines.has(v) && !swap.has(v) && (isPlainRecord(v) || (Array.isArray(v) && Object.getPrototypeOf(v) === Array.prototype));
140
+ const holders = new Map();
141
+ const walked = new Set([passed]);
142
+ const stack = [passed];
143
+ while (stack.length > 0) {
144
+ const node = stack.pop();
145
+ for (const k of Object.keys(node)) {
146
+ if (node === passed && pinned.includes(k))
147
+ continue;
148
+ const v = node[k];
149
+ if (v !== passed && !swap.has(v) && !isContainer(v))
150
+ continue;
151
+ const by = holders.get(v);
152
+ if (by === undefined)
153
+ holders.set(v, [node]);
154
+ else
155
+ by.push(node);
156
+ if (isContainer(v) && !walked.has(v)) {
157
+ walked.add(v);
158
+ stack.push(v);
159
+ }
160
+ }
161
+ }
162
+ const twins = new Map([[passed, {}]]);
163
+ const reach = [passed, ...swap.keys()];
164
+ while (reach.length > 0) {
165
+ for (const h of holders.get(reach.pop()) ?? []) {
166
+ if (twins.has(h))
167
+ continue;
168
+ twins.set(h, Array.isArray(h) ? [] : {});
169
+ reach.push(h);
170
+ }
171
+ }
172
+ const put = (to, k, v) => void Object.defineProperty(to, k, { value: v, enumerable: true, writable: true, configurable: true });
173
+ const moved = (v) => (typeof v !== "object" || v === null ? v : swap.has(v) ? swap.get(v) : (twins.get(v) ?? v));
174
+ for (const [from, to] of twins) {
175
+ const r = from;
176
+ for (const k of Object.keys(r)) {
177
+ if (from !== passed || !pinned.includes(k))
178
+ put(to, k, moved(r[k]));
179
+ else if (Object.hasOwn(held, k))
180
+ put(to, k, held[k]);
181
+ }
182
+ if (from === passed)
183
+ for (const k of pinned)
184
+ if (Object.hasOwn(held, k) && !Object.hasOwn(to, k))
185
+ put(to, k, held[k]);
186
+ if (Array.isArray(from) && Array.isArray(to))
187
+ to.length = from.length;
188
+ }
189
+ for (const to of twins.values())
190
+ Object.freeze(to);
191
+ return twins.get(passed);
192
+ }
193
+ export function answerViolation(answer, check, e, by, below) {
194
+ if (answer === undefined)
195
+ return "returned no answer (return next(e) to pass the event on)";
196
+ if (check === undefined)
197
+ return undefined;
198
+ try {
199
+ return check(answer, e, by, below);
200
+ }
201
+ catch {
202
+ return "returned an answer the station cannot read";
203
+ }
204
+ }
205
+ const denyOf = (a) => (typeof a === "object" && a !== null && Object.prototype.hasOwnProperty.call(a, "deny") ? Reflect.get(a, "deny") : undefined);
206
+ export function methodAnswerViolation(answer, _e, _by, below = []) {
207
+ if (!isPlainRecord(answer))
208
+ return "takes { value } or { deny }";
209
+ const hasValue = Object.prototype.hasOwnProperty.call(answer, "value");
210
+ const deny = denyOf(answer);
211
+ if (deny !== undefined) {
212
+ if (hasValue || typeof deny !== "string" || deny === "")
213
+ return "takes { value } or { deny: <reason> }";
214
+ return below.some((b) => denyOf(b) === undefined) ? "a deny after its next() was answered or while it still runs (deny in place of next)" : undefined;
215
+ }
216
+ if (!hasValue)
217
+ return "takes { value } or { deny }";
218
+ return below.includes(NEXT_IN_FLIGHT) ? "a value while its next() still runs (value in place of next)" : undefined;
219
+ }
220
+ export function matcherViolation(m) {
221
+ if (typeof m !== "object" || m === null || Array.isArray(m))
222
+ return `a matcher is an object of top-level fields, not ${describe(m)}`;
223
+ for (const [k, v] of Object.entries(m)) {
224
+ if (typeof v !== "string" && typeof v !== "number" && typeof v !== "boolean")
225
+ return `matcher field "${k}" is ${describe(v)}; a matcher value is a string, a number or a boolean`;
226
+ }
227
+ return undefined;
228
+ }
229
+ export function matcherMatches(m, e) {
230
+ if (m === undefined)
231
+ return true;
232
+ return Object.entries(m).every(([k, v]) => Object.prototype.hasOwnProperty.call(e, k) && e[k] === v);
233
+ }
234
+ function receiveRecord(v, mode, held) {
235
+ if (mode.isProxy !== undefined && typeof v === "object" && v !== null && mode.isProxy(v))
236
+ return { refusal: "the payload is a Proxy (refused before any of its traps runs)" };
237
+ if (!isPlainRecord(v))
238
+ return { refusal: `an event payload is a plain object, not ${describe(v)}` };
239
+ const r = receive(v, mode, held);
240
+ return r.ok ? { payload: Object.freeze(r.value) } : { refusal: `the payload holds ${faultClause(r.fault)}`, fault: r.fault };
241
+ }
242
+ export function receivePayload(v, isProxy, held) {
243
+ const r = receiveRecord(v, payloadMode(isProxy), held);
244
+ return "refusal" in r ? { refusal: r.refusal } : r;
245
+ }
246
+ export function receiveEvent(e) {
247
+ const r = receiveRecord(e, MODS_PAYLOAD_MODE);
248
+ return "refusal" in r ? { refusal: r.refusal } : r;
249
+ }
250
+ export function answerUpward(v) {
251
+ if (typeof v !== "object" || v === null || Object.isFrozen(v))
252
+ return v;
253
+ if (Array.isArray(v) && Object.getPrototypeOf(v) === Array.prototype)
254
+ return Object.freeze([...v]);
255
+ return isPlainRecord(v) ? Object.freeze({ ...v }) : v;
256
+ }
257
+ export function receiveAnswer(answer, engines, isProxy) {
258
+ const r = receive(answer, payloadMode(isProxy), engines);
259
+ return r.ok ? { answer: r.value } : { refusal: `answered ${faultClause(r.fault)}` };
260
+ }
261
+ const DETACHED_MODE = Object.freeze({ accessors: "refuse", depth: Infinity, others: "as-is" });
262
+ export function detachedCopy(e) {
263
+ const r = receive(e, DETACHED_MODE);
264
+ if (!r.ok)
265
+ throw new Error(`the observer's copy of the event could not be made: ${describeFault(r.fault)}`);
266
+ const copy = r.value;
267
+ const clones = new Map();
268
+ const walked = new Set([copy]);
269
+ const stack = [copy];
270
+ while (stack.length > 0) {
271
+ const node = stack.pop();
272
+ for (const k of Object.keys(node)) {
273
+ const v = node[k];
274
+ if (typeof v !== "object" || v === null)
275
+ continue;
276
+ if (isPlainRecord(v) || (Array.isArray(v) && Object.getPrototypeOf(v) === Array.prototype)) {
277
+ if (!walked.has(v)) {
278
+ walked.add(v);
279
+ stack.push(v);
280
+ }
281
+ continue;
282
+ }
283
+ if (!clones.has(v)) {
284
+ let own = v;
285
+ try {
286
+ own = structuredClone(v);
287
+ }
288
+ catch {
289
+ }
290
+ clones.set(v, own);
291
+ }
292
+ Object.defineProperty(node, k, { value: clones.get(v), enumerable: true, writable: true, configurable: true });
293
+ }
294
+ }
295
+ return copy;
296
+ }
@@ -0,0 +1,344 @@
1
+ import type { ExecutionEnv } from "../../internal/harness-types.js";
2
+ import type { AssistantMessage, Message, Model, Usage } from "../../internal/llm.js";
3
+ import type { CwdRef } from "../../tools/fs/fs-shared.js";
4
+ import { type PermissionResult, type ToolCallRequest } from "../tool-policy.js";
5
+ import type { HookInvocationIdentity, PermissionDeniedPayload } from "../hooks.js";
6
+ import type { PermissionMode } from "../ask-origin.js";
7
+ import type { RunnerDeps } from "../runner-deps.js";
8
+ import type { TaskSpec } from "../task-spec.js";
9
+ import { type ModBus, type ModMountedHandler, type ModDispatchOutcome, type ModEventName, type ModEventPayload, type ModRegistration } from "./kernel/index.js";
10
+ import { type SourcedOverlay } from "../../prompt-assembly/overlay.js";
11
+ import type { BandId } from "../../prompt-assembly/catalog/schema.js";
12
+ import type { ModParticipant } from "./kernel/dispatch.js";
13
+ import { type EngineDollar, type ModelCompleteRequest, type ModelCompleteResult, type ModSeatView } from "./dollar.js";
14
+ /**
15
+ * What the engine's core answers at the bottom of every classic chain: the engine itself has nothing to add.
16
+ * Frozen and empty, so it reads as "no opinion" in every classic station's answer form, and a handler that
17
+ * builds on it (`{ ...(await next(e)), additionalContext }`) builds a well-formed answer.
18
+ */
19
+ export declare const ENGINE_CORE_ANSWER: Readonly<Record<string, never>>;
20
+ /** The classic chains' bottom. */
21
+ export declare function engineCore(): Readonly<Record<string, never>>;
22
+ /** The leg's bus seat, as the stations read it. */
23
+ export type LegModBus = Pick<ModBus, "hasHandlers" | "dispatch">;
24
+ /**
25
+ * The id a delegated leg's events carry as `agentId` (the leg's task id — the key its `task_progress` frames
26
+ * and its parent's fleet row use). A top-level leg carries none.
27
+ */
28
+ export declare function agentIdOf(identity: HookInvocationIdentity | undefined): string | undefined;
29
+ /**
30
+ * The stop event a leg raises when its run would otherwise end: `classic.SubagentStop` on a delegated child's leg — the
31
+ * delegation fact, which a child resumed from its checkpoint keeps — else `classic.Stop`. Not the leg kind: a resumed
32
+ * leg's kind reads `"resume"` whoever it runs as.
33
+ */
34
+ export declare function stopEventOf(identity: Pick<HookInvocationIdentity, "isDelegatedChild"> | undefined): "classic.Stop" | "classic.SubagentStop";
35
+ /**
36
+ * The args as a judging handler receives them: the gate pass's own immutable value ({@link ownArgs} — the value itself when
37
+ * the gate already took it, which is every call the gate raises an event over), so the bytes a handler judges are the bytes
38
+ * that run — an in-place edit throws instead of moving what executes, or what a handler further down judges (a rewrite is
39
+ * an answer's `updatedInput`). A graph the copy refuses is handed as is (the gate refuses such args at its entry).
40
+ */
41
+ export declare function judgedInputOf(args: unknown): unknown;
42
+ /** One link of a leg's chain as a constraint entry names it: a registration the leg's admission mounted, with the handlers it hung. */
43
+ export interface ModChainLink {
44
+ readonly registration: ModRegistration<EngineDollar>;
45
+ readonly handlers: readonly ModMountedHandler[];
46
+ }
47
+ /**
48
+ * A bus's chain identity: the registrations its admission MOUNTED (a refused one judges nothing there), in run order, each
49
+ * with the handlers it actually hung (pattern, matcher, observe, `.catch`, in hang order). Two legs that offered the same
50
+ * registrations but admitted — or hung — differently are different chains: an inherited entry collapses into a child's phase
51
+ * 1 only when the child mounted the very same. A handler's code is not compared (each leg's `register` builds its own
52
+ * closures); what it was hung on is. Every engine admission records it once ({@link chainOfBus}).
53
+ */
54
+ export declare function admittedChainOf(bus: Pick<ModBus, "records" | "mounted">, spec: Pick<TaskSpec, "mods">, deps: Pick<RunnerDeps, "mods">): readonly ModChainLink[];
55
+ /** The chain identity a bus's admission recorded, or `undefined` for a bus no engine admission mounted (its chain cannot be
56
+ * read, so it is the same chain as none). */
57
+ export declare function chainOfBus(bus: object): readonly ModChainLink[] | undefined;
58
+ /** Whether two chains are the same links: the same registration objects, in the same order, having hung the same handlers. */
59
+ export declare function sameModChain(a: readonly ModChainLink[], b: readonly ModChainLink[]): boolean;
60
+ /**
61
+ * Whether the leg's chain JUDGES a tool call: a judging handler on either event a call is judged on — `classic.PreToolUse`
62
+ * (the gate's phase 1) or `tool.check` (the gate's verdict read). Such a chain is what a leg hands its children as a
63
+ * screening constraint, and what a child's own gate stands in for when it mounted the same.
64
+ */
65
+ export declare function chainJudges(bus: LegModBus): boolean;
66
+ /** Record what the constraint mint minted `policy` over. */
67
+ export declare function recordScreeningChain(policy: object, chain: LegModBus): void;
68
+ /** The chain a screening constraint was minted over, or `undefined` when the mint did not make this object. */
69
+ export declare function screeningChainOf(policy: object): LegModBus | undefined;
70
+ /** How an inherited installation's question is settled: under the context its installation froze (its approver, its durable
71
+ * mandates, its classifier — the settlement its `classic.PreToolUse` ask takes in the fold), never at this leg's approver. An
72
+ * allow carrying `updatedInput` is a person's approval of an edit; an ask is one the settlement floated (the call is marked for
73
+ * the park). */
74
+ export type InstallationAskSettlement = (ask: Extract<PermissionResult, {
75
+ action: "ask";
76
+ }>, call: ToolCallRequest, signal: AbortSignal | undefined) => Promise<PermissionResult>;
77
+ /** An inherited installation as a leg's gate raises `tool.check` on it: the bus that mounted that chain, which of its handlers
78
+ * judge here, and how its question is settled. */
79
+ export interface InheritedToolCheck {
80
+ readonly bus: LegModBus;
81
+ readonly judges: (p: ModParticipant) => boolean;
82
+ readonly settle: InstallationAskSettlement;
83
+ }
84
+ /** An inherited chain entry as its installation identity reads it: the policy (whose mint names the bus, whose admission names
85
+ * the chain), the approver it froze, its two durable mandates, the environment it was installed against, its classifier. */
86
+ export interface InstallationEntry {
87
+ readonly policy: object;
88
+ readonly onAsk?: unknown;
89
+ readonly durableMandate?: boolean;
90
+ readonly contentMandate?: boolean;
91
+ readonly hookEnv?: unknown;
92
+ readonly autoMode?: {
93
+ readonly decider: unknown;
94
+ };
95
+ }
96
+ /** A leg's own installation context: its chain identity, its frozen approver, its two durable mandates, the environment its
97
+ * phase 1 runs in, its classifier instance. */
98
+ export interface LegInstallation {
99
+ readonly chain: readonly ModChainLink[];
100
+ readonly onAsk: unknown;
101
+ readonly durableMandate: boolean;
102
+ readonly contentMandate: boolean;
103
+ readonly hookEnv: unknown;
104
+ readonly decider: unknown;
105
+ }
106
+ /**
107
+ * Whether an inherited entry IS a leg's installation — the ONE installation identity. The chain is read off the entry's own
108
+ * bus (the one its policy was minted over, as that bus's admission recorded it), never off a list the entry carries: an entry
109
+ * whose policy the mint did not make, or whose bus no engine admission mounted, is no leg's installation. The rest is the
110
+ * context its questions are settled in: the same approver ({@link askApproverIdentity}), the same two durable mandates, the
111
+ * same environment, the same classifier instance. Readers: chain assembly (a leg already on the chain is not appended again)
112
+ * and {@link standsInFor} (the fold's pass-through and the `tool.check` raise).
113
+ */
114
+ export declare function sameInstallation(pc: InstallationEntry, leg: LegInstallation): boolean;
115
+ /**
116
+ * 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
117
+ * settled with no durable mandate — its phase 1 then judges the call with the same chain, and its questions go to the same
118
+ * approver under no mandate, so the entry adds nothing on either judging event. The fold's pass-through for the entry's
119
+ * `classic.PreToolUse` and the skip of its `tool.check` raise are this one test (an entry it does not hold for is judged under
120
+ * its own context on both: a second judgment, never a lost one).
121
+ */
122
+ export declare function standsInFor(pc: InstallationEntry, leg: Omit<LegInstallation, "durableMandate" | "contentMandate">, legChainJudges: boolean): boolean;
123
+ /** An inherited screening installation as the carrier check reads it: the bus its policy was minted over (absent when the mint
124
+ * did not make the policy) and the chain the entry declares (its `mods`; absent when it declares none). The declaration is read
125
+ * for one thing — a guard the leg cannot raise ({@link unraisableGuardsOf}); identity is read off the bus ({@link sameInstallation}). */
126
+ export interface ScreeningInstallation {
127
+ readonly bus: LegModBus | undefined;
128
+ readonly chain: readonly ModChainLink[] | undefined;
129
+ }
130
+ /** The screening installations among a chain's entries, in the chain's order: every entry whose policy the mint made or that
131
+ * declares a chain. */
132
+ export declare function screeningInstallationsOf(entries: ReadonlyArray<{
133
+ readonly policy: object;
134
+ readonly mods?: readonly ModChainLink[];
135
+ }>): readonly ScreeningInstallation[];
136
+ /** Why an inherited chain cannot hold its guards, or `undefined`: an entry that names a judging `tool.check` handler beside a
137
+ * 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
138
+ * and at the leg's prepare — so it is refused, never run without the guard. */
139
+ export declare function unraisableGuardsOf(installations: readonly ScreeningInstallation[]): string | undefined;
140
+ /**
141
+ * The inherited installations a leg's gate raises `tool.check` on after its own bus — the rule's one home. Every entry whose
142
+ * policy the mint made is one installation, raised whole in the chain's order (the order its `classic.PreToolUse` folds in),
143
+ * except one the leg's own gate stands in for (`standsIn` — the fold's pass-through test, {@link standsInFor}). Raised whole
144
+ * because a handler's answer depends on the chain it sits in (an outer handler may answer without calling `next`, or rule on
145
+ * what an inner one answered), so a registration the leg also mounts in a chain of its own judges again inside the ancestor's
146
+ * chain, as the PreToolUse constraint judges it (a second judgment, never a lost one). Each carries its entry's settlement of a
147
+ * question (`settleOf`): an installation's `ask` goes where its PreToolUse ask goes. Observe handlers never take part (a
148
+ * constraint carries no observer). An entry that cannot raise its guard is refused (`config.mods_invalid`, {@link unraisableGuardsOf}).
149
+ */
150
+ export declare function inheritedToolChecks<E extends InstallationEntry & {
151
+ readonly mods?: readonly ModChainLink[];
152
+ }>(entries: readonly E[], standsIn: (pc: E) => boolean, settleOf: (pc: E) => InstallationAskSettlement): readonly InheritedToolCheck[];
153
+ /** The members every classic `e` of a leg carries: the identity envelope, the delegated leg's `agentId`, the leg's observed mode. */
154
+ export declare function classicEventBase(identity: HookInvocationIdentity | undefined, permissionMode?: PermissionMode): ModEventPayload;
155
+ /**
156
+ * Raise an observation event (a skip-on-failure event whose answer no station reads): no handler, no dispatch.
157
+ * Its failures are the bus's to report; a rejected dispatch (an engine fault, never a handler's) is swallowed —
158
+ * an observation must never change what it observes.
159
+ */
160
+ export declare function observeClassic(bus: LegModBus, event: ModEventName, e: ModEventPayload, signal: AbortSignal | undefined): Promise<void>;
161
+ /**
162
+ * Raise a classic event whose answer the station reads: `undefined` when no handler hangs on it (the station
163
+ * runs as if the bus were not there), else the dispatch outcome. A rejection is an engine fault, never a
164
+ * handler's (handlers fail into the outcome); a decision station fails closed on it, an observation swallows it.
165
+ */
166
+ export declare function dispatchClassic(bus: LegModBus, event: ModEventName, e: ModEventPayload, options: {
167
+ readonly signal?: AbortSignal;
168
+ readonly checkAnswer?: (answer: unknown) => string | undefined;
169
+ }): Promise<ModDispatchOutcome | undefined>;
170
+ /** The answer form of a classic event whose answer is an object of optional string members (`block`, `additionalContext`, …). */
171
+ export declare function stringMembersAnswer(event: string, members: readonly string[]): (answer: unknown) => string | undefined;
172
+ /** The string members of an answer the station reads (a member of any other type reads as absent — the answer check has already refused it). */
173
+ export declare function stringMembersOf<M extends string>(answer: unknown, members: readonly M[]): {
174
+ [K in M]?: string;
175
+ };
176
+ /** The clause a fail-closed station puts in its sentence for the handler that failed it: `crashed (extension "x" threw boom)`. */
177
+ export declare function failedHandlerClause(f: Extract<ModDispatchOutcome, {
178
+ kind: "failed";
179
+ }>): string;
180
+ /**
181
+ * The PermissionDenied station: the leg's `classic.PermissionDenied` handlers, then a host's own raw observer (a host
182
+ * driving the tool gate itself) as one more observe handler of the same event on a bus of its own — so every observer
183
+ * of a deny runs under that station's columns (the handler's budget, skipped on a failure, a short grace past an
184
+ * abort) and none can hold the deny it reports. The raw observer's failure goes to `onHostObserverFailure`.
185
+ */
186
+ export declare function observePermissionDenied(input: {
187
+ readonly legBus: LegModBus | undefined;
188
+ readonly hostObserver: ((payload: PermissionDeniedPayload) => void | Promise<void>) | undefined;
189
+ readonly payload: PermissionDeniedPayload;
190
+ readonly signal: AbortSignal | undefined;
191
+ readonly onHostObserverFailure: (err: Error) => void;
192
+ }): Promise<void>;
193
+ /** What a `classic.UserPromptSubmit` screen came to, as the four entrances read it. */
194
+ export type PromptScreen = {
195
+ readonly kind: "answered";
196
+ readonly block?: string;
197
+ readonly additionalContext?: string;
198
+ } | Extract<ModDispatchOutcome, {
199
+ kind: "failed";
200
+ }> | {
201
+ readonly kind: "aborted";
202
+ };
203
+ /**
204
+ * Raise `classic.UserPromptSubmit` (undefined when no handler hangs on it). A decision event: a handler that throws,
205
+ * runs past its budget or breaks the site's contract ends the screen `failed`, and every entrance fails closed on it;
206
+ * a cancelled screen ends `aborted` at once. A dispatch the engine itself could not run is `failed` too.
207
+ */
208
+ export declare function screenUserPrompt(bus: LegModBus, e: ModEventPayload, signal: AbortSignal | undefined): Promise<PromptScreen | undefined>;
209
+ /** The three words a `tool.check` verdict speaks. */
210
+ export declare const TOOL_CHECK_DECISIONS: readonly ["allow", "ask", "deny"];
211
+ export type ToolCheckDecision = (typeof TOOL_CHECK_DECISIONS)[number];
212
+ /**
213
+ * The gate's standing verdict as the bottom of the `tool.check` chain answers it — what a handler reads from `next(e)`.
214
+ * Never `deny` (a standing refusal raises nothing). On an ask: its classes, and `mandated` — true when an `allow`
215
+ * answer cannot clear it at this point of the gate. `ceiling` mirrors `e.ceiling`. Read-only metadata: the gate reads
216
+ * the answer's `decision` and `reason` and nothing else of it.
217
+ */
218
+ export interface ToolCheckProjection {
219
+ readonly decision: "allow" | "ask";
220
+ readonly reason?: string;
221
+ readonly classes?: readonly string[];
222
+ readonly mandated?: boolean;
223
+ readonly ceiling?: "ask";
224
+ }
225
+ /** What one `tool.check` raise came to: the chain's verdict (`by` = the registration whose answer the chain returned;
226
+ * absent when no handler spoke and the gate's own verdict came back up), a handler's failure, or a cancel. */
227
+ export type ToolCheckOutcome = {
228
+ readonly kind: "answered";
229
+ readonly decision: ToolCheckDecision;
230
+ readonly reason?: string;
231
+ readonly by?: string;
232
+ } | Extract<ModDispatchOutcome, {
233
+ kind: "failed";
234
+ }> | {
235
+ readonly kind: "aborted";
236
+ };
237
+ /**
238
+ * Raise `tool.check` over the gate's standing verdict (undefined when no handler hangs on it — nothing is raised). A
239
+ * refusing event: a handler that throws, runs past its budget or answers out of the site's form ends the raise
240
+ * `failed`, a cancel ends it `aborted`, and the gate refuses the call on either. A dispatch the engine itself could not
241
+ * run is `failed` too. `judges` = which handlers take part (absent ⇒ every handler on the bus: the leg's own raise; an
242
+ * inherited installation's raise passes its {@link InheritedToolCheck.judges}).
243
+ */
244
+ export declare function raiseToolCheck(bus: LegModBus, e: ModEventPayload, projection: ToolCheckProjection, signal: AbortSignal | undefined, judges?: (p: ModParticipant) => boolean): Promise<ToolCheckOutcome | undefined>;
245
+ /** What a `prompt.compose` raise came to: each source class's overlays in application order, and the operator lines
246
+ * for every handler whose answer was skipped. */
247
+ export interface PromptComposeOutcome {
248
+ readonly deploy: readonly SourcedOverlay[];
249
+ readonly task: readonly SourcedOverlay[];
250
+ readonly warnings: readonly string[];
251
+ }
252
+ /**
253
+ * Raise `prompt.compose` — the collection point of the deploy and task source classes' overlays — over the leg's
254
+ * bus (nothing is raised when no handler hangs on it). A collecting event: a handler's contribution is what its
255
+ * answer adds after what its `next(e)` returned, and what `next(e)` returned must stand unchanged, in order, at the
256
+ * head of its answer — a handler that answers without its `next(e)` (or before it returned), rewrites or removes a
257
+ * lower contribution, or adds an overlay the band table does not grant its seat's class (or one that carries locked
258
+ * text, or one that is not data), is skipped, and what is below it stands (runs in its place, when it never called
259
+ * `next`). The engine records, at each handler's boundary, the overlays as it validated them and who contributed
260
+ * each (the registration and its seat: the deployment seat is the deploy class, the task seat the task class); what
261
+ * applies is that record, never the answer read again. Each class applies its contributions in chain order, so a
262
+ * later registration's overlay on the same target wins.
263
+ *
264
+ * `lowerAdds` — the entries the classes below deploy already added (the only entries a deploy `drop` may name
265
+ * besides a built-in section).
266
+ */
267
+ export declare function raisePromptCompose(bus: LegModBus, e: ModEventPayload, options: {
268
+ readonly lowerAdds: ReadonlyMap<string, BandId>;
269
+ readonly signal?: AbortSignal;
270
+ }): Promise<PromptComposeOutcome>;
271
+ /** The seats behind the engine facade, bound once the leg has them. Every member is read at its call. */
272
+ export interface LegFacadeSeats {
273
+ readonly exec: ModSeatView["env"]["exec"];
274
+ complete(request: ModelCompleteRequest, signal: AbortSignal): Promise<ModelCompleteResult>;
275
+ readonly sessionId: string;
276
+ /** The run's account of side model calls ({@link ModSeatView.book}). */
277
+ book: ModSeatView["book"];
278
+ cwd(): string;
279
+ root(): string;
280
+ model(): string;
281
+ messages(): readonly Message[];
282
+ now(): number;
283
+ tools(): readonly string[];
284
+ agents(): readonly string[];
285
+ }
286
+ /** The leg's admitted bus, its chain identity (the one its admission recorded, {@link chainOfBus}) and the binding of the
287
+ * facade its `$` reaches. */
288
+ export interface LegMods {
289
+ readonly bus: ModBus;
290
+ readonly chain: readonly ModChainLink[];
291
+ /** Bind the engine facade once the leg is prepared. Until then a `$` call throws, naming the method. */
292
+ bindFacade(seats: LegFacadeSeats): void;
293
+ }
294
+ /**
295
+ * Admit the leg's bus: both seats (`RunnerDeps.mods`, `TaskSpec.mods`), screened and put to `plugin.register`.
296
+ * Called once per leg, at that leg's own prepare (a delegated child and a resumed leg each admit their own);
297
+ * each refused registration becomes one `mods.registration_refused` notice. Throws `config.mods_invalid` for a
298
+ * registration the kernel cannot take.
299
+ */
300
+ export declare function admitLegMods(input: {
301
+ readonly spec: Pick<TaskSpec, "mods">;
302
+ readonly deps: Pick<RunnerDeps, "mods" | "onError" | "onNotice">;
303
+ readonly sessionId: string;
304
+ }): Promise<LegMods>;
305
+ /** What a leg hands {@link legFacadeSeats}: the seats it already has. */
306
+ export interface LegFacadeInput {
307
+ readonly deps: Pick<RunnerDeps, "brain" | "models" | "now">;
308
+ readonly spec: Pick<TaskSpec, "getApiKeyAndHeaders">;
309
+ readonly sessionId: string;
310
+ readonly model: Model;
311
+ readonly executionEnv: Pick<ExecutionEnv, "exec">;
312
+ readonly taskRoot: string;
313
+ readonly cwdRef: CwdRef | undefined;
314
+ /** The leg's latest model request as recorded at the provider seam (the session's messages as the model last saw them). */
315
+ readonly lastBrainContext: () => {
316
+ readonly messages: readonly Message[];
317
+ } | undefined;
318
+ readonly activeTools: ReadonlySet<string>;
319
+ readonly agentListing: {
320
+ readonly entries: ReadonlyArray<{
321
+ readonly name: string;
322
+ }>;
323
+ } | undefined;
324
+ /** The run's one account of side model calls (the same entry the classifier's side calls book on), handed the model a
325
+ * `$.model.complete` call resolved to, the usage its reply reported (absent ⇒ none reported) and the reply's
326
+ * diagnostics when it carried any (a degraded brain's fallback is priced by them). */
327
+ readonly book: (model: Model, reply: {
328
+ readonly usage: Usage | undefined;
329
+ readonly diagnostics?: AssistantMessage["diagnostics"];
330
+ }) => void;
331
+ }
332
+ /** The engine facade's seats over a prepared leg — each one a seat the leg already has (no new capability). */
333
+ export declare function legFacadeSeats(input: LegFacadeInput): LegFacadeSeats;
334
+ /**
335
+ * A chain admitted outside any leg — what a host rebuilds to re-supply an inherited screening entry on a fresh Runner
336
+ * (a cross-process resume hands back `createPreToolUseConstraintPolicy(chain, env)` over the same registrations). The
337
+ * same admission a leg runs (both seats, `plugin.register`); no leg exists, so its `$` facade is never bound and a `$`
338
+ * call throws. Handler failures go to `onError` (absent ⇒ unreported). Its chain identity is recorded as a leg's is
339
+ * ({@link chainOfBus}), so an entry minted over it is read by what it mounted — whatever list the entry carries.
340
+ */
341
+ export declare function admitModChain(seats: {
342
+ readonly deployment?: readonly ModRegistration<EngineDollar>[];
343
+ readonly task?: readonly ModRegistration<EngineDollar>[];
344
+ }, onError?: (err: Error) => void): Promise<ModBus>;