@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
@@ -1,7 +1,7 @@
1
1
  export const ROUTE_ADJUDICATION_CONFORMANCE_CORPUS = [
2
2
  {
3
3
  name: "per-model-on-root",
4
- intent: "a per-model credential is paired by construction, on the deployment root",
4
+ intent: "a per-model credential not bound yet is servable, on the deployment root",
5
5
  model: { id: "m-main", baseUrl: "https://gw.example.com" },
6
6
  credential: { source: "per-model", apiKey: "k-main" },
7
7
  config: { baseUrl: "https://gw.example.com" },
@@ -9,7 +9,7 @@ export const ROUTE_ADJUDICATION_CONFORMANCE_CORPUS = [
9
9
  },
10
10
  {
11
11
  name: "per-model-off-root",
12
- intent: "a per-model credential is paired by construction even off the deployment root (the resolver was asked about THIS entry)",
12
+ intent: "a per-model credential not bound yet is servable off the deployment root too (the resolver was asked about THIS entry)",
13
13
  model: { id: "m-third", baseUrl: "https://third-party.example.net/v1" },
14
14
  credential: { source: "per-model", apiKey: "k-third" },
15
15
  config: { baseUrl: "https://gw.example.com" },
@@ -5,9 +5,31 @@ export interface RoutingBrainOptions {
5
5
  /** Brain used when no route matches. If omitted, an unmatched model yields an error. */
6
6
  fallback?: Brain;
7
7
  }
8
+ /** The two `Model` fields a route can be named by — a catalog entry that carries only a provider word is as good a subject as a whole `Model`. */
9
+ type RouteWords = {
10
+ readonly provider?: string | undefined;
11
+ readonly api?: string | undefined;
12
+ };
13
+ /**
14
+ * THE judge of which line serves a model: the model's route word (`provider`, or `api` when `by` says so) IF the route table
15
+ * has an OWN route under that word, else `undefined` — the fallback (the deployment's gateway) serves it. A word the model
16
+ * carries without a route, and a model with no string word at all, both answer `undefined`: a route that is not mounted is
17
+ * not a line, whatever the model says.
18
+ *
19
+ * `routes` is the route TABLE itself — the very object a host hands {@link createRoutingBrain}, which asks this function for
20
+ * every request — so the judge and the router answer from one reading of one table, whatever its shape. The question is
21
+ * `Object.hasOwn(routes, word)`: it evaluates no entry and lists no keys, so a non-enumerable own route is a route, a lazily
22
+ * keyed table is asked about the one name it is asked about, and a name the table only inherits (`constructor`, `__proto__`)
23
+ * is not a route. The judge never reads a route's value: a route mounted under the word IS the line, and when its value is not
24
+ * a brain the router fails that request on that line (an error terminal naming the route) rather than moving it to the
25
+ * fallback — so the line this answers is the line the request was sent to, either way. A table that cannot answer the question
26
+ * (it is not an object, or its trap throws) throws here, and the router fails the request with an error terminal.
27
+ */
28
+ export declare function brainLaneOf(model: RouteWords, routes: Readonly<Record<string, unknown>>, by?: NonNullable<RoutingBrainOptions["by"]>): string | undefined;
8
29
  /**
9
30
  * Route to different brains by a Model field (default `model.provider`). Lets one Runner serve
10
- * multiple providers/gateways; compose with `createFailoverBrain` for per-route failover.
31
+ * multiple providers/gateways; compose with `createFailoverBrain` for per-route failover. Which route serves a
32
+ * model is {@link brainLaneOf}'s answer.
11
33
  *
12
34
  * @example
13
35
  * createRoutingBrain({
@@ -16,3 +38,4 @@ export interface RoutingBrainOptions {
16
38
  * }, { fallback: createOpenAIBrain({ baseUrl: VLLM }) });
17
39
  */
18
40
  export declare function createRoutingBrain(routes: Record<string, Brain>, opts?: RoutingBrainOptions): Brain;
41
+ export {};
@@ -1,42 +1,77 @@
1
1
  import { createAssistantMessageEventStream, } from "../internal/llm.js";
2
2
  import { ZERO_USAGE } from "./errors.js";
3
- function errorMessage(model, text) {
3
+ function errorMessage(who, text) {
4
4
  return {
5
5
  role: "assistant",
6
6
  content: [{ type: "text", text: "" }],
7
- api: model.api,
8
- provider: model.provider,
9
- model: model.id,
7
+ api: who.api,
8
+ provider: who.provider,
9
+ model: who.id,
10
10
  stopReason: "error",
11
11
  errorMessage: text,
12
12
  usage: ZERO_USAGE,
13
13
  timestamp: Date.now(),
14
14
  };
15
15
  }
16
+ const BLANK_IDENTITY = { api: "", provider: "", id: "" };
17
+ function spelled(word) {
18
+ return (typeof word === "object" && word !== null) || typeof word === "function" ? `[${typeof word}]` : String(word);
19
+ }
20
+ function routeKeyOf(model, by) {
21
+ return by === "api" ? model.api : model.provider;
22
+ }
23
+ function isBrain(value) {
24
+ return value !== null && typeof value === "object" && typeof value.stream === "function";
25
+ }
26
+ export function brainLaneOf(model, routes, by = "provider") {
27
+ const word = routeKeyOf(model, by);
28
+ return typeof word === "string" && Object.hasOwn(routes, word) ? word : undefined;
29
+ }
16
30
  export function createRoutingBrain(routes, opts = {}) {
17
31
  const by = opts.by ?? "provider";
18
32
  const resolveTarget = (model) => {
19
- const key = by === "api" ? model.api : model.provider;
20
- const routed = Object.hasOwn(routes, key) ? routes[key] : undefined;
21
- const matched = routed !== null && typeof routed === "object" && typeof routed.stream === "function"
22
- ? routed
23
- : undefined;
24
- return matched ?? opts.fallback;
33
+ const lane = brainLaneOf(model, routes, by);
34
+ if (lane === undefined)
35
+ return { target: opts.fallback };
36
+ const routed = routes[lane];
37
+ return isBrain(routed) ? { target: routed } : { broken: `route ${by}="${lane}" is mounted but its value is not a brain` };
25
38
  };
26
39
  const stream = (model, context, options) => {
27
- const key = by === "api" ? model.api : model.provider;
28
- const target = resolveTarget(model);
29
- if (!target) {
40
+ const reject = (text, named) => {
30
41
  const out = createAssistantMessageEventStream();
31
- out.push({
32
- type: "error",
33
- reason: "error",
34
- error: errorMessage(model, `createRoutingBrain: no brain for ${by}="${key}"`),
35
- });
42
+ try {
43
+ const wordOf = (field) => (field === by && named !== undefined ? named.value : model[field]);
44
+ out.push({ type: "error", reason: "error", error: errorMessage({ api: wordOf("api"), provider: wordOf("provider"), id: wordOf("id") }, text) });
45
+ }
46
+ catch {
47
+ out.push({ type: "error", reason: "error", error: errorMessage(BLANK_IDENTITY, `${text} (the model's own words could not be read either)`) });
48
+ }
36
49
  return out;
50
+ };
51
+ let word;
52
+ try {
53
+ word = { value: routeKeyOf(model, by) };
37
54
  }
55
+ catch {
56
+ return reject(`createRoutingBrain: the model's ${by} could not be read`);
57
+ }
58
+ const named = word.value;
59
+ const asked = { api: named, provider: named };
60
+ let resolved;
61
+ try {
62
+ resolved = resolveTarget(asked);
63
+ }
64
+ catch {
65
+ return reject(`createRoutingBrain: the route table threw while ${by}="${spelled(named)}" was looked up`, word);
66
+ }
67
+ const target = "target" in resolved ? resolved.target : undefined;
68
+ if (!target)
69
+ return reject("broken" in resolved ? `createRoutingBrain: ${resolved.broken}` : `createRoutingBrain: no brain for ${by}="${spelled(named)}"`, word);
38
70
  return target.stream(model, context, options);
39
71
  };
40
- const adjudicateRoute = (model, perModelAuth) => resolveTarget(model)?.adjudicateRoute?.(model, perModelAuth);
72
+ const adjudicateRoute = (model, perModelAuth) => {
73
+ const resolved = resolveTarget(model);
74
+ return "target" in resolved ? resolved.target?.adjudicateRoute?.(model, perModelAuth) : undefined;
75
+ };
41
76
  return { stream, adjudicateRoute };
42
77
  }
@@ -150,3 +150,21 @@ export declare function runWithExtraBodyDropped<T>(observe: (r: ExtraBodyDropped
150
150
  /** Report the strip of the request the engine has SELECTED to send, to the active per-run sink, if any (called at the
151
151
  * engine's commit points, never from `buildRequest`, which is also built speculatively). */
152
152
  export declare function reportExtraBodyDropped(report: ExtraBodyDroppedReport): void;
153
+ /** A request refused because the per-model credential it would carry is bound to another origin: the catalog id it was
154
+ * for and the two origins, each in its DISPLAY spelling. Never a value, never a digest of one. */
155
+ export interface CredentialOriginRefusalReport {
156
+ modelId: string;
157
+ boundOrigin: string;
158
+ requestOrigin: string;
159
+ }
160
+ /**
161
+ * Run `fn` with a per-run credential-origin refusal sink in scope — the FIFTH brain→runner ALS channel, with the fourth's
162
+ * shape and for its reasons: the WHOLE leg (a refused compaction summary, side query or classifier call is refused for the
163
+ * same reason as a turn), not shielded around the leg's internal calls, not revoked on settlement, no-op outside the scope.
164
+ * The refusal is already decided when it is reported.
165
+ */
166
+ export declare function runWithCredentialOriginRefusals<T>(observe: (r: CredentialOriginRefusalReport) => void, fn: () => Promise<T>): Promise<T>;
167
+ /** Report a credential-origin refusal to the active per-run sink, if any (called by the request gate's refusal,
168
+ * `routeRefusalError`; a judgment that only advises reports nothing). The
169
+ * observer is the Runner's own seat, whose one delivery is the guarded `deliverEngineNotice` — nothing is swallowed here. */
170
+ export declare function reportCredentialOriginRefusal(report: CredentialOriginRefusalReport): void;
@@ -68,3 +68,10 @@ export function reportExtraBodyDropped(report) {
68
68
  catch {
69
69
  }
70
70
  }
71
+ const credentialOriginRefusalSinkStore = new AsyncLocalStorage();
72
+ export function runWithCredentialOriginRefusals(observe, fn) {
73
+ return credentialOriginRefusalSinkStore.run({ observe }, fn);
74
+ }
75
+ export function reportCredentialOriginRefusal(report) {
76
+ credentialOriginRefusalSinkStore.getStore()?.observe(report);
77
+ }
@@ -1,14 +1,15 @@
1
+ import { describeRejectedValue } from "../core/tool-search-setting.js";
1
2
  export const MAX_TIMER_DELAY_MS = 2_147_483_647;
2
3
  export function resolveStallTimeoutMs(value, knob) {
3
4
  if (value === undefined)
4
5
  return undefined;
5
6
  if (!Number.isFinite(value) || value < 0) {
6
- const e = new Error(`${knob} must be a non-negative finite number of milliseconds (got ${String(value)})`);
7
+ const e = new Error(`${knob} must be a non-negative finite number of milliseconds (got ${describeRejectedValue(value)})`);
7
8
  e.code = "config.stall_timeout_invalid";
8
9
  throw e;
9
10
  }
10
11
  if (value > MAX_TIMER_DELAY_MS) {
11
- const e = new Error(`${knob} must not exceed ${MAX_TIMER_DELAY_MS}ms (~24.8 days) — a host timer truncates a larger delay and fires immediately, so this watchdog would abort every call instead of tolerating a long one (got ${String(value)}). Pass 0 to disable it.`);
12
+ const e = new Error(`${knob} must not exceed ${MAX_TIMER_DELAY_MS}ms (~24.8 days) — a host timer truncates a larger delay and fires immediately, so this watchdog would abort every call instead of tolerating a long one (got ${describeRejectedValue(value)}). Pass 0 to disable it.`);
12
13
  e.code = "config.stall_timeout_invalid";
13
14
  throw e;
14
15
  }
@@ -112,12 +113,12 @@ export function resolveBrainCallGuardrailMs(knob) {
112
113
  if (knob === false || knob === 0)
113
114
  return undefined;
114
115
  if (typeof knob !== "number" || !Number.isFinite(knob) || knob < 0) {
115
- const e = new Error(`brainCallGuardrailMs must be a positive number of milliseconds, 0, or false (got ${String(knob)})`);
116
+ const e = new Error(`brainCallGuardrailMs must be a positive number of milliseconds, 0, or false (got ${describeRejectedValue(knob)})`);
116
117
  e.code = "config.brain_call_guardrail_invalid";
117
118
  throw e;
118
119
  }
119
120
  if (knob > MAX_TIMER_DELAY_MS) {
120
- const e = new Error(`brainCallGuardrailMs must not exceed ${MAX_TIMER_DELAY_MS}ms (~24.8 days) — a host timer truncates a larger delay and fires immediately, so the backstop would abort every model call (got ${String(knob)}). Pass false or 0 to turn the backstop off.`);
121
+ const e = new Error(`brainCallGuardrailMs must not exceed ${MAX_TIMER_DELAY_MS}ms (~24.8 days) — a host timer truncates a larger delay and fires immediately, so the backstop would abort every model call (got ${describeRejectedValue(knob)}). Pass false or 0 to turn the backstop off.`);
121
122
  e.code = "config.brain_call_guardrail_invalid";
122
123
  throw e;
123
124
  }
@@ -69,8 +69,11 @@ export interface MaterializedA2a {
69
69
  /** One entry per DECLARED peer, in declaration order, ready or failed — the declaration as this materialization read it once. */
70
70
  statuses: A2aPeerStatus[];
71
71
  /** Re-read one peer's card (or every declared peer) and re-derive its tools. Unlike the MCP refresh
72
- * this dials nothing new — every A2A call is a fresh request anyway — so a peer that failed at
73
- * prepare time can genuinely recover here. */
72
+ * this dials nothing new — every A2A call is a fresh request anyway — so a peer whose card or network
73
+ * failed at prepare time can genuinely recover here. The DECLARATION is not re-read: a refresh works
74
+ * from the copy this materialization took and judged — the members too (`headers`, `allowSkills`,
75
+ * `toolAxes` are copied, not shared) — so a declaration refused then is refused again and a caller
76
+ * rewriting its object afterwards, by replacing a member or by editing one in place, changes nothing. */
74
77
  refresh: (peer?: string) => Promise<A2aRefreshResult[]>;
75
78
  /**
76
79
  * Task teardown. There is no socket to close (every call is its own request), so what this owns is the
package/dist/core/a2a.js CHANGED
@@ -5,6 +5,7 @@ import { assertEndpointBound, redirectPolicy, resolveProtocolHttpHeaders, underD
5
5
  import { describeHttpTransportFailure } from "./mcp-failure.js";
6
6
  import { findNamespacePrefixCollision, mintNamespacePrefix, mintNamespacedToolName } from "./protocol-naming.js";
7
7
  import { A2A_NAMESPACE } from "./protocol-table.js";
8
+ import { judgeEntryToolAxes, refusedDeclarer, snapshotDeclaredEntry } from "./locked-config.js";
8
9
  import { delimitUntrusted, inlineUntrusted } from "./untrusted-text.js";
9
10
  import { thrownText } from "./thrown-value.js";
10
11
  const A2A_REQUEST_TIMEOUT_MS = 30_000;
@@ -540,25 +541,39 @@ function buildSkillTool(spec, t, skill, lifecycle) {
540
541
  },
541
542
  };
542
543
  }
543
- async function materializePeer(declaredSpec, principal, lifecycle, signal) {
544
- const spec = Object.freeze({ ...declaredSpec });
544
+ function declaredPeerOf(declared, index) {
545
+ let snapshot;
546
+ try {
547
+ snapshot = snapshotDeclaredEntry(declared, "a2a");
548
+ }
549
+ catch (err) {
550
+ return { spec: { name: refusedDeclarer(err) ?? `(peer #${index + 1}, name unreadable)` }, refusal: err };
551
+ }
552
+ const judged = judgeEntryToolAxes(snapshot, "a2a");
553
+ return judged.ok ? { spec: judged.entry } : { spec: snapshot, refusal: judged.error };
554
+ }
555
+ async function materializePeer(peer, principal, lifecycle, signal) {
556
+ if ("refusal" in peer)
557
+ throw peer.refusal;
558
+ const { spec } = peer;
559
+ const declaredAxes = spec.toolAxes;
545
560
  const headers = resolveProtocolHttpHeaders(A2A_NAMESPACE.id, spec, principal);
546
561
  const discovery = { peer: spec.name, endpoint: spec.url, headers };
547
562
  const card = readCard(spec.name, await discoverCardBody(spec, discovery, signal), spec.url);
548
563
  assertEndpointBound(A2A_NAMESPACE.id, spec.name, card.endpoint, spec.cardUrl === undefined ? [spec.url] : [spec.url, spec.cardUrl], headers);
549
564
  const transport = { peer: spec.name, endpoint: card.endpoint, headers };
550
565
  const tools = [];
551
- const axes = [];
566
+ const skillAxes = [];
552
567
  for (const skill of card.skills) {
553
568
  if (spec.allowSkills !== undefined && !spec.allowSkills.includes(skill.id))
554
569
  continue;
555
570
  const tool = buildSkillTool(spec, transport, skill, lifecycle);
556
571
  tools.push(tool);
557
- axes.push(a2aAxisFor(tool.name, spec.toolAxes?.[skill.id]));
572
+ skillAxes.push(a2aAxisFor(tool.name, declaredAxes?.[skill.id]));
558
573
  }
559
574
  return {
560
575
  tools,
561
- axes,
576
+ axes: skillAxes,
562
577
  status: {
563
578
  name: spec.name,
564
579
  status: "ready",
@@ -576,8 +591,9 @@ function asPeerWarning(spec, err) {
576
591
  return warning;
577
592
  }
578
593
  export async function materializeA2aTools(specs, principal, signal) {
579
- if (specs.length > 0) {
580
- const collision = findNamespacePrefixCollision(A2A_NAMESPACE, specs.map((s) => s.name));
594
+ const peers = specs.map((spec, index) => declaredPeerOf(spec, index));
595
+ if (peers.length > 0) {
596
+ const collision = findNamespacePrefixCollision(A2A_NAMESPACE, peers.map((p) => p.spec.name));
581
597
  if (collision) {
582
598
  const [a, b] = collision.peers;
583
599
  const e = new Error(a === b
@@ -592,9 +608,9 @@ export async function materializeA2aTools(specs, principal, signal) {
592
608
  const toolAxes = [];
593
609
  const warnings = [];
594
610
  const statuses = [];
595
- const settled = await Promise.allSettled(specs.map((spec) => materializePeer(spec, principal, lifecycle, signal)));
596
- for (let i = 0; i < specs.length; i++) {
597
- const spec = specs[i];
611
+ const settled = await Promise.allSettled(peers.map((peer) => materializePeer(peer, principal, lifecycle, signal)));
612
+ for (let i = 0; i < peers.length; i++) {
613
+ const spec = peers[i].spec;
598
614
  const outcome = settled[i];
599
615
  if (outcome.status === "fulfilled") {
600
616
  tools.push(...outcome.value.tools);
@@ -613,12 +629,13 @@ export async function materializeA2aTools(specs, principal, signal) {
613
629
  statuses,
614
630
  refresh: async (peer) => {
615
631
  const prefixOf = (name) => mintNamespacePrefix(A2A_NAMESPACE, name);
616
- const targets = peer !== undefined ? specs.filter((s) => s.name === peer) : specs;
632
+ const targets = peer !== undefined ? peers.filter((p) => p.spec.name === peer) : peers;
617
633
  if (peer !== undefined && targets.length === 0) {
618
634
  return [{ peer, prefix: prefixOf(peer), status: "failed", toolCount: 0, added: [], removed: [], error: "no peer of that name is declared for this task" }];
619
635
  }
620
636
  const results = [];
621
- for (const spec of targets) {
637
+ for (const target of targets) {
638
+ const { spec } = target;
622
639
  const prefix = prefixOf(spec.name);
623
640
  if (lifecycle.disposed) {
624
641
  results.push({ peer: spec.name, prefix, status: "disposed", toolCount: 0, added: [], removed: [] });
@@ -626,7 +643,7 @@ export async function materializeA2aTools(specs, principal, signal) {
626
643
  }
627
644
  const previous = statuses.find((s) => s.name === spec.name)?.toolNames ?? [];
628
645
  try {
629
- const fresh = await materializePeer(spec, principal, lifecycle, signal);
646
+ const fresh = await materializePeer(target, principal, lifecycle, signal);
630
647
  const names = fresh.tools.map((t) => t.name);
631
648
  results.push({
632
649
  peer: spec.name,
@@ -8,8 +8,9 @@ import { type EngineNotice } from "./engine-notice.js";
8
8
  /** Why an entry grants (or refuses) nothing — the closed set the start-of-run notice names, for every list. `tool_name`: the
9
9
  * entry's tool name is one the name judgment reads as stale against the run's roster (`verdict` says which); `near_miss`: the
10
10
  * run mounts no tool of that exact name but mounts one that differs only by case (`currentName` is its spelling);
11
- * `earlier_grammar`: a session's stored rules are written in an earlier rule grammar, in which the entry named no tool (the
12
- * session store's list reading, `compileSessionRuleBucket` — this reader never answers it). */
11
+ * `earlier_grammar`: a session's stored rules are written in an earlier rule grammar, in which the entry named no tool, or which
12
+ * read an entry this grammar reads as no rule (the session store's list reading, `compileSessionRuleBucket` — this reader never
13
+ * answers it). */
13
14
  export declare const ALLOW_ENTRY_INERT_REASONS: readonly ["wildcard_all", "namespace_wildcard", "content_unsupported", "grammar", "tool_name", "near_miss", "earlier_grammar"];
14
15
  export type AllowEntryInertReason = (typeof ALLOW_ENTRY_INERT_REASONS)[number];
15
16
  /** The facts beside a reason: for `tool_name` / `near_miss` the judgment's word, the judgment's own one-line sentence when it has
@@ -21,7 +22,13 @@ export interface AllowEntryInertDetail {
21
22
  readonly guidance?: string;
22
23
  readonly currentName?: string;
23
24
  readonly valueType?: string;
25
+ /** Where the spelling of a `near_miss` comes from, when the station that read it reads more than the run's roster
26
+ * ({@link NearMissCarrier}); absent ⇒ the roster the run mounts. A sentence only — never a field of a wire detail. */
27
+ readonly carriedBy?: NearMissCarrier;
24
28
  }
29
+ /** Who carries the spelling a near miss reads as another spelling of: the roster the run mounts, a delegation tool's pool, or
30
+ * only the engine's tool catalog (a tool the engine may mount, which this run's roster does not carry). */
31
+ export type NearMissCarrier = "run" | "pool" | "catalog";
25
32
  /**
26
33
  * How a list member that is not a string is named wherever a list's entries are named (the inert record's `entry`, the Skill
27
34
  * card's binding): its TYPE, in a spelling no readable entry can have — a readable entry's name holds no whitespace and a
@@ -64,6 +71,25 @@ export type CompiledAllowEntry = {
64
71
  readonly kind: "domain";
65
72
  readonly rule: PersistedRule;
66
73
  };
74
+ /**
75
+ * THE near-miss reading of a tool name the judgment calls current: the spelling the run mounts when the run mounts no tool of this
76
+ * exact name but one that differs from it only by case (`BASH` beside `Bash`), else `undefined`. Two kinds of name are never a near
77
+ * miss, because the roster they would be read against is not the final one: an engine tool's (the engine mounts some of its tools
78
+ * after a list is read) and a protocol tool's (a refresh mounts and unmounts them while the run goes on) — in both the exact
79
+ * spelling can be the right one by the time it matters. Every station that asks "is this name a case twin of a mounted tool" reads
80
+ * this answer: an entry list ({@link readRuleEntry}), a tool policy's name lists (the prepare-time policy-name audit).
81
+ */
82
+ export declare function nearMissSpellingOf(name: string, roster: ReadonlySet<string>): string | undefined;
83
+ /**
84
+ * THE universe a ROOT-facing tool-name list is read against: every name the engine's catalog carries, and the names the reader knows
85
+ * are carried (`carried`). A list is root-facing when it bounds the tools of the run that holds it — the run's own `allowTools` /
86
+ * `excludeTools` (also the ceiling of its children), a tool policy's name lists, a session's stored rules — and its reader is that
87
+ * run (`carried`: its roster, the caller's own tools, and the exact names of the pools its reachable delegation tools declare and can
88
+ * list) or the store that writes the rules (`carried`: the tools its deployment declared). Another spelling of a carried name is
89
+ * always refused there, whatever a delegation tool injects per spawn: the run's own tools are known, and an entry that is a case
90
+ * twin of one of them names the other tool by mistake. A delegation tool's pool that cannot be listed carries nothing here.
91
+ */
92
+ export declare function rootFacingToolNames(carried: Iterable<string>): Set<string>;
67
93
  /** What one rule entry means under one direction ({@link readRuleEntry}): the row the grammar compiles it to, or the reason it
68
94
  * reads as nothing with the facts a sentence about it names. */
69
95
  export type RuleEntryReading = {
@@ -87,9 +113,10 @@ export declare function compiledEntryName(compiled: CompiledAllowEntry): string;
87
113
  /**
88
114
  * Compile one list WHOLE through {@link readRuleEntry}: the entries it reads and the ones it reads as nothing (each with its
89
115
  * reason and, for a name the roster refuses, the judgment's word and the spelling to write). An allow list holding `*` voids
90
- * the list (every other entry on it reads as nothing too: the list grants nothing — the safe direction). A `*` on a deny list
91
- * reads as nothing by itself and the rest of that list still refuses: a deny list never loses an entry to a wildcard beside
92
- * it. `roster` as in {@link readRuleEntry}.
116
+ * the list (every other entry on it reads as nothing too: the list grants nothing — the safe direction) — `*` as the lenient
117
+ * rule parser names it ({@link namesWholeRoster}), so an entry the stricter entry grammar refuses (`* (*)`) still voids. A
118
+ * `*` on a deny list reads as nothing by itself and the rest of that list still refuses: a deny list never loses an entry to
119
+ * a wildcard beside it. `roster` as in {@link readRuleEntry}.
93
120
  */
94
121
  export declare function compileAllowList(entries: readonly string[], behavior: "allow" | "deny", roster?: ReadonlySet<string>): {
95
122
  rows: Array<{
@@ -136,7 +163,8 @@ export declare function uncoveredCommandSegment(rows: readonly AllowEntryRow[],
136
163
  * segment covered by a row — or, for a `grant` list, read-only by itself); deny: a row whose program run the call performs (the
137
164
  * wide tightening reading; a call that cannot be read against the row is refused too). PATH — the persisted path adjudication
138
165
  * (allow: the narrow reading, every view of the target inside what the row names; deny: any view reaching it). NAME / DOMAIN —
139
- * the one predicate of each (the name the call names, the host it fetches).
166
+ * the one predicate of each (the name the call names, the host it fetches); a keyed tool's call naming no value for its key is
167
+ * refused by a deny list's row of the key and granted by no allow row (the persisted walk's reading, `keyedValueAbsentReason`).
140
168
  */
141
169
  export declare function judgeAllowEntries<R extends AllowEntryRow>(rows: readonly R[], req: ToolCallRequest, behavior: "allow" | "deny", ctx: AllowEntryJudgeContext, posture?: AdmissionPosture): readonly R[] | undefined;
142
170
  /** The allow rows of a list, as the allow layer reads them in `mode`: the strip applied BEFORE the match (in `auto`). */
@@ -294,11 +322,16 @@ export type AllowEntryInertNote = ({
294
322
  } & AllowEntryInert) | ({
295
323
  readonly source: AllowEntrySource;
296
324
  } & AllowEntryInert);
325
+ /**
326
+ * A list entry spelled so a person reads what the engine read: the entry as a JSON string — quotes, backslashes and the usual
327
+ * escapes — with every character that prints as nothing, or as a space, written as `\uXXXX` (`\u{…}` beyond the BMP) and a
328
+ * run of spaces kept space by space. Uncapped and one-to-one (two entries never share a spelling), so a value that BINDS an
329
+ * entry may hold it ({@link renderListEntry} is this, capped for a sentence).
330
+ */
331
+ export declare function spelledListEntry(entry: string): string;
297
332
  /**
298
333
  * THE ONE WRITER of a list entry into a sentence (the start-of-run notice, a skill's refusal and its decisions, a sub-agent
299
- * list's refusals and advisories): the entry as a JSON string — quotes, backslashes and the usual escapes — with every
300
- * character that prints as nothing, or as a space, written as `\uXXXX` (`\u{…}` beyond the BMP) and a run of spaces kept
301
- * space by space, so what a person reads is what the engine read. Capped on what is printed.
334
+ * list's refusals and advisories): {@link spelledListEntry}, capped on what is printed.
302
335
  */
303
336
  export declare function renderListEntry(entry: string): string;
304
337
  /**
@@ -1,9 +1,10 @@
1
1
  import { heldBy } from "./tool-name-readings.js";
2
- import { isNamespacedCoveringRuleName, namespacedRuleNameCovers, parsePermissionRule } from "./permission-rules.js";
2
+ import { isNamespacedCoveringRuleName, namespacedRuleNameCovers } from "./permission-rules.js";
3
+ import { parsePermissionRule, ruleSpellingOf } from "./permission-rule-syntax.js";
3
4
  import { judgeRuleToolName, splitNamespacedName } from "./tool-name-aliases.js";
4
5
  import { catalogToolNames, isShellFaceToolName } from "./tool-registry.js";
5
6
  import { ALLOW_RULE_MEMBERS } from "./allow-rule-shadow.js";
6
- import { COMMAND_RULE_TOOL, adjudicatePersistedDomainRules, adjudicatePersistedNameRules, commandCoverageOf, domainRuleSubjectOf, laneToolNamesOf, nameRuleSubjectOf, parseRuleText, programRunReachOf, ruleToolGrammarOf } from "./permission-rule-model.js";
7
+ import { COMMAND_RULE_TOOL, adjudicatePersistedDomainRules, adjudicatePersistedNameRules, commandCoverageOf, domainRuleSubjectOf, laneToolNamesOf, nameRuleSubjectOf, noticeRuleText, parseRuleText, programRunReachOf, ruleToolGrammarOf } from "./permission-rule-model.js";
7
8
  import { pathRuleLaneAnswer } from "./runner/permission-rule-lanes.js";
8
9
  import { callTargetReadingOf } from "./effective-path-target.js";
9
10
  import { splitShellCompoundSegments } from "../tools/fs/bash-readonly-classifier.js";
@@ -12,6 +13,7 @@ import { inlineUntrusted } from "./untrusted-text.js";
12
13
  import { valueTypeLabel } from "./tool-name-list.js";
13
14
  import { deliverEngineNotice } from "./engine-notice.js";
14
15
  export const ALLOW_ENTRY_INERT_REASONS = Object.freeze(["wildcard_all", "namespace_wildcard", "content_unsupported", "grammar", "tool_name", "near_miss", "earlier_grammar"]);
16
+ const NEAR_MISS_CARRIER = { run: "the mounted spelling is", pool: "a delegation pool carries", catalog: "the engine's tool catalog names" };
15
17
  export function nonStringMemberLabel(value) {
16
18
  return `<not a string: ${valueTypeLabel(value)}>`;
17
19
  }
@@ -21,7 +23,6 @@ export function nonListValueLabel(read) {
21
23
  function ruleRowOf(parsed) {
22
24
  return { ...parsed, scope: { kind: "global" }, adds: [{ dot: { actor: "list", counter: 1 }, origin: "user", createdAt: "" }] };
23
25
  }
24
- const TOOL_NAME_SPELLING = /^[^\s()\p{Cc}\p{Cf}]+$/u;
25
26
  function mountedSpellingOf(name, roster) {
26
27
  const folded = name.toLowerCase();
27
28
  for (const mounted of roster)
@@ -29,6 +30,14 @@ function mountedSpellingOf(name, roster) {
29
30
  return mounted;
30
31
  return undefined;
31
32
  }
33
+ export function nearMissSpellingOf(name, roster) {
34
+ if (roster.has(name) || catalogToolNames().has(name) || splitNamespacedName(name) !== undefined)
35
+ return undefined;
36
+ return mountedSpellingOf(name, roster);
37
+ }
38
+ export function rootFacingToolNames(carried) {
39
+ return new Set([...catalogToolNames(), ...carried]);
40
+ }
32
41
  function toolNameReading(name, roster) {
33
42
  const verdict = judgeRuleToolName(name, roster);
34
43
  if (verdict.kind === "unprefixed_namespace")
@@ -36,9 +45,7 @@ function toolNameReading(name, roster) {
36
45
  if (verdict.kind !== "current") {
37
46
  return { kind: "inert", reason: "tool_name", verdict: verdict.kind, guidance: verdict.guidance, ...(verdict.currentName !== undefined ? { currentName: verdict.currentName } : {}) };
38
47
  }
39
- if (roster.has(name) || catalogToolNames().has(name) || splitNamespacedName(name) !== undefined)
40
- return undefined;
41
- const mounted = mountedSpellingOf(name, roster);
48
+ const mounted = nearMissSpellingOf(name, roster);
42
49
  return mounted === undefined ? undefined : { kind: "inert", reason: "near_miss", currentName: mounted };
43
50
  }
44
51
  export function readRuleEntry(raw, behavior, roster) {
@@ -46,12 +53,10 @@ export function readRuleEntry(raw, behavior, roster) {
46
53
  const row = (compiled) => ({ kind: "row", compiled });
47
54
  if (typeof raw !== "string")
48
55
  return { kind: "inert", reason: "grammar", valueType: valueTypeLabel(raw) };
49
- if (raw !== raw.trim())
56
+ const parsed = ruleSpellingOf(raw);
57
+ if (parsed === undefined)
50
58
  return inert("grammar");
51
- const parsed = parsePermissionRule(raw);
52
59
  const name = parsed.toolName;
53
- if (!TOOL_NAME_SPELLING.test(name))
54
- return inert("grammar");
55
60
  if (name === "*")
56
61
  return inert("wildcard_all");
57
62
  if (roster !== undefined) {
@@ -98,7 +103,7 @@ function inertReasonOf(code) {
98
103
  return code === "unsupported.tool" ? "content_unsupported" : "grammar";
99
104
  }
100
105
  export function compileAllowList(entries, behavior, roster) {
101
- const voided = behavior === "allow" && entries.some((e) => isWildcardAll(readRuleEntry(e, behavior)));
106
+ const voided = behavior === "allow" && entries.some(namesWholeRoster);
102
107
  const rows = [];
103
108
  const inert = [];
104
109
  for (const entry of entries) {
@@ -113,8 +118,8 @@ export function compileAllowList(entries, behavior, roster) {
113
118
  }
114
119
  return { rows, inert };
115
120
  }
116
- function isWildcardAll(read) {
117
- return read.kind === "inert" && read.reason === "wildcard_all";
121
+ function namesWholeRoster(entry) {
122
+ return typeof entry === "string" && entry === entry.trim() && parsePermissionRule(entry).toolName === "*";
118
123
  }
119
124
  function answersTo(req, has) {
120
125
  return heldBy("allowEntry.names", { has }, req);
@@ -415,11 +420,13 @@ function escapedCodePoint(ch) {
415
420
  const hex = cp.toString(16).padStart(4, "0");
416
421
  return cp > 0xffff ? `\\u{${hex}}` : `\\u${hex}`;
417
422
  }
418
- export function renderListEntry(entry) {
419
- const quoted = JSON.stringify(entry)
423
+ export function spelledListEntry(entry) {
424
+ return JSON.stringify(entry)
420
425
  .replace(/ {2,}/g, (run) => "\\u0020".repeat(run.length))
421
426
  .replace(UNSEEN_IN_ENTRY, (ch) => (ch === " " ? ch : escapedCodePoint(ch)));
422
- return inlineUntrusted(quoted, ENTRY_RENDER_MAX);
427
+ }
428
+ export function renderListEntry(entry) {
429
+ return inlineUntrusted(spelledListEntry(entry), ENTRY_RENDER_MAX);
423
430
  }
424
431
  export function inertEntryPhrase(e) {
425
432
  if (e.valueType !== undefined)
@@ -427,7 +434,7 @@ export function inertEntryPhrase(e) {
427
434
  const spelling = e.currentName !== undefined ? inlineUntrusted(e.currentName, 120) : undefined;
428
435
  const why = (() => {
429
436
  if (e.reason === "near_miss")
430
- return `near_miss: the mounted spelling is "${spelling}"`;
437
+ return `near_miss: ${NEAR_MISS_CARRIER[e.carriedBy ?? "run"]} "${spelling}"`;
431
438
  if (e.reason !== "tool_name" || e.verdict === undefined)
432
439
  return e.reason;
433
440
  switch (e.verdict) {
@@ -455,6 +462,6 @@ export function allowedToolsNotGrantedNotice(inert, sessionId) {
455
462
  message: `${inert.length} allowed-tools entr${inert.length === 1 ? "y grants" : "ies grant"} or refuse${inert.length === 1 ? "s" : ""} nothing — ${shown.join("; ")}${rest > 0 ? `; and ${rest} more` : ""}. ` +
456
463
  "A list holding `*` voids the list, `mcp__*` names no server, a rule the grammar refuses (`grammar`) or one on a tool with no such rule form (`content_unsupported`: an allow by path is an `Edit(…)` or `Read(…)` rule) grants nothing, and a tool name must be spelled as the tool is mounted; name the tools (or `mcp__<server>`) instead." +
457
464
  (refusing ? " Such an entry in a disallowed-tools list keeps its Skill from activating: a refusal that reads as nothing is not dropped." : ""),
458
- detail: { ...(sessionId !== undefined ? { sessionId } : {}), entries: inert.map((e) => ({ ...e })) },
465
+ detail: { ...(sessionId !== undefined ? { sessionId } : {}), entries: inert.map((e) => ({ ...e, entry: noticeRuleText(e.entry) })) },
459
466
  };
460
467
  }