@sema-agent/core 7.54.1 → 7.55.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 (399) hide show
  1. package/CHANGELOG.md +437 -0
  2. package/dist/agents/agent-transcript-tool.js +2 -1
  3. package/dist/agents/builtin-agents.d.ts +12 -14
  4. package/dist/agents/cc-peer-directory.d.ts +36 -0
  5. package/dist/agents/cc-peer-directory.js +138 -0
  6. package/dist/agents/cc-peer-wire.d.ts +105 -0
  7. package/dist/agents/cc-peer-wire.js +98 -0
  8. package/dist/agents/cc-uds-peer-channel.d.ts +40 -0
  9. package/dist/agents/cc-uds-peer-channel.js +457 -0
  10. package/dist/agents/cross-session-envelope.d.ts +4 -1
  11. package/dist/agents/cross-session-envelope.js +8 -1
  12. package/dist/agents/cross-session-judge.d.ts +2 -2
  13. package/dist/agents/list-agents-tool.js +2 -1
  14. package/dist/agents/observer.d.ts +4 -5
  15. package/dist/agents/observer.js +2 -1
  16. package/dist/agents/peer-admission.d.ts +6 -0
  17. package/dist/agents/peer-admission.js +4 -1
  18. package/dist/agents/peer-directory.d.ts +43 -9
  19. package/dist/agents/peer-directory.js +66 -23
  20. package/dist/agents/peer-notices.d.ts +1 -1
  21. package/dist/agents/peer-session-drain.d.ts +3 -1
  22. package/dist/agents/peer-session-drain.js +1 -0
  23. package/dist/agents/read-inbox-tool.js +2 -1
  24. package/dist/agents/retain-ledger.d.ts +1 -1
  25. package/dist/agents/roster-store.d.ts +1 -1
  26. package/dist/agents/send-message-tool.d.ts +10 -0
  27. package/dist/agents/send-message-tool.js +34 -5
  28. package/dist/agents/subagent.d.ts +34 -79
  29. package/dist/agents/subagent.js +45 -46
  30. package/dist/agents/tool-filter.d.ts +29 -46
  31. package/dist/agents/tool-filter.js +8 -31
  32. package/dist/agents/verify.d.ts +3 -3
  33. package/dist/brain/anthropic.js +14 -9
  34. package/dist/brain/errors.d.ts +15 -0
  35. package/dist/brain/errors.js +10 -0
  36. package/dist/brain/model-presets.d.ts +4 -4
  37. package/dist/brain/open-responses.js +15 -10
  38. package/dist/brain/openai.js +17 -12
  39. package/dist/brain/provider-dialect.d.ts +39 -3
  40. package/dist/brain/provider-dialect.js +28 -0
  41. package/dist/brain/reasoning.d.ts +1 -1
  42. package/dist/brain/request-params.d.ts +55 -5
  43. package/dist/brain/request-params.js +35 -3
  44. package/dist/brain/retry.d.ts +1 -1
  45. package/dist/brain/route-adjudicator.d.ts +15 -0
  46. package/dist/brain/route-adjudicator.js +15 -0
  47. package/dist/brain/stream-engine.js +6 -5
  48. package/dist/brain/stream-shared.d.ts +1 -1
  49. package/dist/core/advisor-verdict.d.ts +120 -0
  50. package/dist/core/advisor-verdict.js +92 -0
  51. package/dist/core/agent-definition.d.ts +7 -8
  52. package/dist/core/allow-entry.d.ts +49 -23
  53. package/dist/core/allow-entry.js +57 -32
  54. package/dist/core/allow-rule-shadow.d.ts +7 -0
  55. package/dist/core/approval-object.d.ts +2 -1
  56. package/dist/core/approval-object.js +6 -6
  57. package/dist/core/ask-origin.d.ts +63 -11
  58. package/dist/core/ask-origin.js +27 -5
  59. package/dist/core/ask-question.js +10 -4
  60. package/dist/core/auto-compaction.d.ts +11 -8
  61. package/dist/core/auto-compaction.js +4 -2
  62. package/dist/core/auto-mode-arming.d.ts +2 -2
  63. package/dist/core/auto-mode-defaults.d.ts +8 -8
  64. package/dist/core/auto-mode-prompt-assets.d.ts +3 -3
  65. package/dist/core/auto-mode-prompt.d.ts +1 -1
  66. package/dist/core/auto-mode.d.ts +17 -9
  67. package/dist/core/auto-mode.js +9 -6
  68. package/dist/core/background-agent-store.d.ts +3 -3
  69. package/dist/core/canonical-json.d.ts +1 -1
  70. package/dist/core/canonical-json.js +2 -2
  71. package/dist/core/checkpoint-requirements.d.ts +6 -3
  72. package/dist/core/checkpoint-requirements.js +4 -14
  73. package/dist/core/checkpoint-store.d.ts +80 -51
  74. package/dist/core/checkpoint-store.js +56 -74
  75. package/dist/core/child-clamp-seats.d.ts +6 -0
  76. package/dist/core/child-clamp-seats.js +3 -16
  77. package/dist/core/compliance.d.ts +2 -2
  78. package/dist/core/context-edit.d.ts +6 -7
  79. package/dist/core/cross-boundary-taint.d.ts +9 -3
  80. package/dist/core/cross-boundary-taint.js +5 -3
  81. package/dist/core/decision-receipt.js +2 -2
  82. package/dist/core/effective-path-target.d.ts +1 -1
  83. package/dist/core/engine-notice.d.ts +19 -5
  84. package/dist/core/exec-output-tail.d.ts +1 -1
  85. package/dist/core/file-history-retention.d.ts +1 -1
  86. package/dist/core/file-history-store.d.ts +59 -9
  87. package/dist/core/file-history-store.js +35 -17
  88. package/dist/core/gate-fold.js +3 -2
  89. package/dist/core/gate-lanes.js +12 -8
  90. package/dist/core/gate-outcome.d.ts +17 -4
  91. package/dist/core/gate-outcome.js +30 -0
  92. package/dist/core/governance-codes.d.ts +13 -3
  93. package/dist/core/governance-codes.js +10 -0
  94. package/dist/core/hands-band.d.ts +1 -1
  95. package/dist/core/hooks.d.ts +4 -4
  96. package/dist/core/host-target.d.ts +49 -0
  97. package/dist/core/host-target.js +59 -0
  98. package/dist/core/image-downsample.d.ts +1 -1
  99. package/dist/core/lsp-diagnostics.d.ts +4 -4
  100. package/dist/core/lsp.d.ts +3 -3
  101. package/dist/core/mailbox-store.d.ts +4 -0
  102. package/dist/core/mcp-connection-pool.d.ts +18 -2
  103. package/dist/core/mcp-connection-pool.js +53 -6
  104. package/dist/core/mcp-failure.d.ts +23 -4
  105. package/dist/core/mcp-failure.js +26 -11
  106. package/dist/core/mcp-listing-drift.d.ts +10 -0
  107. package/dist/core/mcp-listing-drift.js +6 -0
  108. package/dist/core/mcp-server-link.d.ts +173 -0
  109. package/dist/core/mcp-server-link.js +127 -0
  110. package/dist/core/mcp-server-spec.d.ts +4 -2
  111. package/dist/core/mcp-session-end.d.ts +26 -0
  112. package/dist/core/mcp-session-end.js +29 -0
  113. package/dist/core/mcp-startup-request.d.ts +17 -0
  114. package/dist/core/mcp-startup-request.js +17 -0
  115. package/dist/core/mcp.d.ts +13 -13
  116. package/dist/core/mcp.js +187 -162
  117. package/dist/core/media-byte-cap.d.ts +1 -1
  118. package/dist/core/memory-engine/engine.d.ts +9 -9
  119. package/dist/core/memory-engine/provenance-wording.d.ts +1 -1
  120. package/dist/core/memory-engine/tools.js +4 -1
  121. package/dist/core/mode-policy.d.ts +1 -1
  122. package/dist/core/namespaced-rule-name.d.ts +33 -7
  123. package/dist/core/namespaced-rule-name.js +39 -25
  124. package/dist/core/output-style.d.ts +1 -1
  125. package/dist/core/param-rule-reach.d.ts +15 -0
  126. package/dist/core/param-rule-reach.js +30 -0
  127. package/dist/core/parent-spec-seat.d.ts +8 -1
  128. package/dist/core/parent-spec-seat.js +4 -0
  129. package/dist/core/pause-registry.d.ts +16 -5
  130. package/dist/core/pause-registry.js +6 -2
  131. package/dist/core/peer-channel.d.ts +70 -0
  132. package/dist/core/peer-channel.js +1 -0
  133. package/dist/core/permission-rule-consent.d.ts +11 -5
  134. package/dist/core/permission-rule-consent.js +37 -30
  135. package/dist/core/permission-rule-model.d.ts +233 -64
  136. package/dist/core/permission-rule-model.js +384 -85
  137. package/dist/core/permission-rule-provider.d.ts +2 -1
  138. package/dist/core/permission-rule-store.d.ts +20 -25
  139. package/dist/core/permission-rule-store.js +1 -4
  140. package/dist/core/permission-rule-sync.d.ts +11 -2
  141. package/dist/core/permission-rule-sync.js +8 -1
  142. package/dist/core/permission-rules.d.ts +49 -11
  143. package/dist/core/permission-rules.js +123 -89
  144. package/dist/core/persisted-rule-arms.d.ts +4 -2
  145. package/dist/core/present-plan-tool.js +3 -1
  146. package/dist/core/protocol-naming.d.ts +2 -2
  147. package/dist/core/read-only-shell-table.d.ts +1 -1
  148. package/dist/core/read-only-shell.d.ts +1 -1
  149. package/dist/core/roles.d.ts +6 -2
  150. package/dist/core/roles.js +45 -44
  151. package/dist/core/rule-offer-read.d.ts +53 -0
  152. package/dist/core/rule-offer-read.js +146 -0
  153. package/dist/core/rule-owner.d.ts +46 -0
  154. package/dist/core/rule-owner.js +28 -0
  155. package/dist/core/runner/advisor-instructions.d.ts +70 -0
  156. package/dist/core/runner/advisor-instructions.js +61 -0
  157. package/dist/core/runner/advisor-tool.d.ts +33 -0
  158. package/dist/core/runner/advisor-tool.js +112 -0
  159. package/dist/core/runner/announce-once-ledger.d.ts +4 -26
  160. package/dist/core/runner/announce-once-ledger.js +14 -46
  161. package/dist/core/runner/approval-feedback.js +6 -3
  162. package/dist/core/runner/assemble-result.d.ts +1 -1
  163. package/dist/core/runner/caller-roster.d.ts +7 -0
  164. package/dist/core/runner/caller-roster.js +11 -0
  165. package/dist/core/runner/classifier-ladder.d.ts +27 -5
  166. package/dist/core/runner/classifier-ladder.js +12 -11
  167. package/dist/core/runner/compaction-restate.d.ts +10 -6
  168. package/dist/core/runner/compaction-restate.js +9 -3
  169. package/dist/core/runner/contracts.d.ts +13 -9
  170. package/dist/core/runner/conversation-segment.d.ts +28 -0
  171. package/dist/core/runner/conversation-segment.js +42 -0
  172. package/dist/core/runner/cross-boundary-lane.d.ts +6 -5
  173. package/dist/core/runner/cross-boundary-lane.js +26 -15
  174. package/dist/core/runner/decide-continuation.d.ts +7 -4
  175. package/dist/core/runner/decide-continuation.js +2 -2
  176. package/dist/core/runner/denial-limit-arms.d.ts +2 -2
  177. package/dist/core/runner/derived-route-fallback.d.ts +24 -24
  178. package/dist/core/runner/derived-route-fallback.js +9 -7
  179. package/dist/core/runner/gate-exit.d.ts +6 -0
  180. package/dist/core/runner/gate-exit.js +7 -2
  181. package/dist/core/runner/initial-run-state.js +1 -1
  182. package/dist/core/runner/permission-rule-lanes.d.ts +2 -2
  183. package/dist/core/runner/permission-rule-lanes.js +14 -7
  184. package/dist/core/runner/person-path-rows.js +1 -1
  185. package/dist/core/runner/prepare-advisor.d.ts +63 -0
  186. package/dist/core/runner/prepare-advisor.js +77 -0
  187. package/dist/core/runner/prepare-caps-and-workflow.js +1 -1
  188. package/dist/core/runner/prepare-config-doors.d.ts +6 -4
  189. package/dist/core/runner/prepare-config-doors.js +18 -12
  190. package/dist/core/runner/prepare-delegation-surface.d.ts +2 -2
  191. package/dist/core/runner/prepare-delegation-surface.js +1 -1
  192. package/dist/core/runner/prepare-file-history.js +39 -39
  193. package/dist/core/runner/prepare-gate-stations.d.ts +1 -4
  194. package/dist/core/runner/prepare-gate-stations.js +2 -7
  195. package/dist/core/runner/prepare-inherited-gate.d.ts +5 -4
  196. package/dist/core/runner/prepare-inherited-gate.js +3 -3
  197. package/dist/core/runner/prepare-park-ask.js +7 -7
  198. package/dist/core/runner/prepare-policy-chain.d.ts +1 -1
  199. package/dist/core/runner/prepare-policy-chain.js +4 -10
  200. package/dist/core/runner/prepare-project-context.d.ts +5 -2
  201. package/dist/core/runner/prepare-project-context.js +6 -3
  202. package/dist/core/runner/prepare-prompt-inputs.js +1 -1
  203. package/dist/core/runner/prepare-protocol-tools.d.ts +2 -2
  204. package/dist/core/runner/prepare-protocol-tools.js +3 -2
  205. package/dist/core/runner/prepare-safety-scan.d.ts +9 -12
  206. package/dist/core/runner/prepare-safety-scan.js +8 -6
  207. package/dist/core/runner/prepare-task.js +15 -18
  208. package/dist/core/runner/prepare-tool-disclosure-mount.js +6 -4
  209. package/dist/core/runner/prepare-wiring-manifest.d.ts +6 -3
  210. package/dist/core/runner/prepare-wiring-manifest.js +2 -2
  211. package/dist/core/runner/resume-policy-outcome.js +1 -1
  212. package/dist/core/runner/retired-runner-deps.js +1 -1
  213. package/dist/core/runner/run-attachment-seats.js +0 -1
  214. package/dist/core/runner/run-compaction-machinery.d.ts +1 -1
  215. package/dist/core/runner/run-compaction-machinery.js +2 -12
  216. package/dist/core/runner/run-git-lane.d.ts +1 -0
  217. package/dist/core/runner/run-harness-handlers.js +2 -3
  218. package/dist/core/runner/run-leg.js +13 -0
  219. package/dist/core/runner/run-settle-and-teardown.js +1 -1
  220. package/dist/core/runner/run-telemetry-and-budget-seats.js +1 -1
  221. package/dist/core/runner/run-turn-boundary.d.ts +1 -0
  222. package/dist/core/runner/run-turn-boundary.js +14 -12
  223. package/dist/core/runner/session-rule-policy.d.ts +22 -21
  224. package/dist/core/runner/session-rule-policy.js +13 -28
  225. package/dist/core/runner/side-call-account.d.ts +32 -8
  226. package/dist/core/runner/side-call-account.js +23 -1
  227. package/dist/core/runner/strict-output-schema.d.ts +1 -1
  228. package/dist/core/runner/sub-agent-deny-lists.js +4 -3
  229. package/dist/core/runner/synthetic-tools.d.ts +10 -13
  230. package/dist/core/runner/synthetic-tools.js +4 -2
  231. package/dist/core/runner/tool-disclosure.js +2 -1
  232. package/dist/core/runner/tool-face-overlay.d.ts +2 -1
  233. package/dist/core/runner/tool-face-overlay.js +17 -1
  234. package/dist/core/runner/tool-progress-lane.d.ts +2 -2
  235. package/dist/core/runner/tool-turn-repair-seat.d.ts +3 -2
  236. package/dist/core/runner/turn-attachments.d.ts +60 -67
  237. package/dist/core/runner-deps.d.ts +37 -37
  238. package/dist/core/runtime-caps.d.ts +4 -4
  239. package/dist/core/safety-merge-corpus.js +17 -1
  240. package/dist/core/same-plain-value.d.ts +40 -0
  241. package/dist/core/same-plain-value.js +49 -0
  242. package/dist/core/scheduler.d.ts +1 -1
  243. package/dist/core/sensitive-path-policy.d.ts +1 -1
  244. package/dist/core/sensitive-path-policy.js +1 -1
  245. package/dist/core/session-policy-store.d.ts +77 -22
  246. package/dist/core/session-policy-store.js +56 -14
  247. package/dist/core/session-reconcile.d.ts +2 -2
  248. package/dist/core/session-store.d.ts +80 -30
  249. package/dist/core/session-store.js +118 -76
  250. package/dist/core/session.d.ts +24 -46
  251. package/dist/core/shared-memory/tools.js +3 -1
  252. package/dist/core/shared-memory/types.d.ts +1 -1
  253. package/dist/core/side-query.d.ts +10 -0
  254. package/dist/core/side-query.js +5 -0
  255. package/dist/core/store-contracts/checkpoint-store-contract.js +29 -2
  256. package/dist/core/store-contracts/file-history-store-contract.js +43 -3
  257. package/dist/core/store-contracts/session-policy-store-contract.d.ts +7 -0
  258. package/dist/core/store-contracts/session-policy-store-contract.js +130 -0
  259. package/dist/core/store-contracts/session-repo-contract.js +125 -0
  260. package/dist/core/store-contracts/session-store-contract.d.ts +4 -7
  261. package/dist/core/store-contracts/session-store-contract.js +215 -41
  262. package/dist/core/store-contracts/workflow-journal-store-contract.js +26 -1
  263. package/dist/core/surrogate-safe-slice.d.ts +3 -3
  264. package/dist/core/task-event.d.ts +10 -4
  265. package/dist/core/task-notification.d.ts +3 -3
  266. package/dist/core/task-registry-agent.d.ts +4 -4
  267. package/dist/core/task-registry-shared.d.ts +4 -4
  268. package/dist/core/task-registry-shared.js +1 -0
  269. package/dist/core/task-registry.d.ts +4 -4
  270. package/dist/core/task-registry.js +3 -1
  271. package/dist/core/task-result.d.ts +3 -3
  272. package/dist/core/task-spec.d.ts +52 -52
  273. package/dist/core/task-stream.d.ts +6 -6
  274. package/dist/core/task-tool-shape.d.ts +4 -4
  275. package/dist/core/tighten-task-spec.d.ts +1 -1
  276. package/dist/core/tool-catalog-entries.d.ts +19 -2
  277. package/dist/core/tool-catalog-entries.js +57 -42
  278. package/dist/core/tool-conformance.js +1 -0
  279. package/dist/core/tool-errors.d.ts +2 -2
  280. package/dist/core/tool-face-reader.js +5 -3
  281. package/dist/core/tool-face.d.ts +21 -2
  282. package/dist/core/tool-face.js +1 -1
  283. package/dist/core/tool-model-gate.d.ts +3 -3
  284. package/dist/core/tool-name-aliases.d.ts +29 -8
  285. package/dist/core/tool-name-aliases.js +27 -3
  286. package/dist/core/tool-name-readings.d.ts +5 -8
  287. package/dist/core/tool-name-readings.js +1 -2
  288. package/dist/core/tool-policy.d.ts +24 -5
  289. package/dist/core/tool-policy.js +34 -10
  290. package/dist/core/tool-registry.d.ts +14 -7
  291. package/dist/core/tool-registry.js +17 -7
  292. package/dist/core/tool-result-store.js +2 -1
  293. package/dist/core/tool-roster.d.ts +47 -18
  294. package/dist/core/tool-roster.js +53 -32
  295. package/dist/core/tool-spec-members.js +1 -1
  296. package/dist/core/tool-spec.d.ts +35 -21
  297. package/dist/core/tools.js +3 -2
  298. package/dist/core/trace.d.ts +4 -0
  299. package/dist/core/untrusted-egress.d.ts +1 -1
  300. package/dist/core/untrusted-text.d.ts +1 -1
  301. package/dist/core/warm-resume.d.ts +1 -1
  302. package/dist/core/wiring-manifest.d.ts +49 -0
  303. package/dist/core/wiring-manifest.js +13 -5
  304. package/dist/core/workflow-journal-store.d.ts +62 -0
  305. package/dist/core/workflow-journal-store.js +77 -1
  306. package/dist/core/workflow-run-store.d.ts +6 -0
  307. package/dist/core/workflow-run-store.js +2 -0
  308. package/dist/engine/compaction/compaction.d.ts +9 -9
  309. package/dist/engine/execution-env/node-execution-env.d.ts +19 -5
  310. package/dist/engine/execution-env/node-execution-env.js +43 -22
  311. package/dist/engine/harness/agent-harness.d.ts +14 -8
  312. package/dist/engine/harness/agent-harness.js +33 -26
  313. package/dist/engine/harness/types.d.ts +29 -7
  314. package/dist/engine/harness/types.js +12 -1
  315. package/dist/engine/llm/types.d.ts +9 -9
  316. package/dist/engine/llm/validation.d.ts +4 -1
  317. package/dist/engine/llm/validation.js +13 -1
  318. package/dist/engine/loop/agent-loop.d.ts +1 -1
  319. package/dist/engine/loop/agent-loop.js +10 -8
  320. package/dist/engine/loop/types.d.ts +15 -13
  321. package/dist/engine/lsp/node-lsp-manager.d.ts +2 -2
  322. package/dist/engine/session/memory-repo.d.ts +10 -11
  323. package/dist/engine/session/memory-repo.js +13 -8
  324. package/dist/engine/session/parent-chain-guard.d.ts +3 -2
  325. package/dist/engine/session/parent-chain-guard.js +1 -1
  326. package/dist/engine/session/repo-utils.d.ts +31 -3
  327. package/dist/engine/session/repo-utils.js +42 -5
  328. package/dist/index.d.ts +27 -15
  329. package/dist/index.js +21 -11
  330. package/dist/internal/harness-types.d.ts +1 -1
  331. package/dist/internal/harness.d.ts +3 -3
  332. package/dist/internal/harness.js +2 -2
  333. package/dist/internal/llm.d.ts +1 -1
  334. package/dist/internal/llm.js +1 -1
  335. package/dist/orchestration/goal.js +2 -2
  336. package/dist/orchestration/run-workflow-tool.d.ts +2 -2
  337. package/dist/orchestration/run-workflow-tool.js +5 -3
  338. package/dist/orchestration/workflow-size-guideline.d.ts +4 -4
  339. package/dist/orchestration/workflow-types.d.ts +18 -0
  340. package/dist/orchestration/workflow-types.js +6 -0
  341. package/dist/orchestration/workflow.d.ts +2 -13
  342. package/dist/orchestration/workflow.js +21 -31
  343. package/dist/prompt-assembly/event-registry.js +1 -0
  344. package/dist/prompt-assembly/tool-catalog.d.ts +3 -0
  345. package/dist/prompt-assembly/tool-catalog.js +3 -0
  346. package/dist/prompts/default.d.ts +14 -14
  347. package/dist/scenarios/full-body.d.ts +4 -4
  348. package/dist/stores/file/adoption/adopt.d.ts +4 -3
  349. package/dist/stores/file/adoption/adopt.js +24 -31
  350. package/dist/stores/file/adoption/marker.d.ts +6 -13
  351. package/dist/stores/file/adoption/marker.js +6 -15
  352. package/dist/stores/file/checkpoint-store.d.ts +3 -0
  353. package/dist/stores/file/checkpoint-store.js +9 -3
  354. package/dist/stores/file/file-history-store.d.ts +20 -19
  355. package/dist/stores/file/file-history-store.js +152 -135
  356. package/dist/stores/file/fs-atomic.d.ts +15 -0
  357. package/dist/stores/file/fs-atomic.js +89 -14
  358. package/dist/stores/file/index.d.ts +1 -1
  359. package/dist/stores/file/mailbox-store.d.ts +3 -0
  360. package/dist/stores/file/mailbox-store.js +3 -1
  361. package/dist/stores/file/permission-rule-adopt.d.ts +1 -1
  362. package/dist/stores/file/permission-rule-adopt.js +15 -16
  363. package/dist/stores/file/permission-rule-store.d.ts +18 -2
  364. package/dist/stores/file/permission-rule-store.js +21 -14
  365. package/dist/stores/file/session-policy-store.d.ts +3 -3
  366. package/dist/stores/file/session-store.d.ts +26 -11
  367. package/dist/stores/file/session-store.js +77 -40
  368. package/dist/stores/file/workflow-journal-store.d.ts +10 -4
  369. package/dist/stores/file/workflow-journal-store.js +28 -13
  370. package/dist/tools/artifact/artifact-text.d.ts +1 -1
  371. package/dist/tools/artifact/artifact-tool.js +2 -1
  372. package/dist/tools/fs/bash-readonly-classifier.d.ts +3 -3
  373. package/dist/tools/fs/fs-bash.d.ts +2 -2
  374. package/dist/tools/fs/fs-bash.js +3 -1
  375. package/dist/tools/fs/fs-shared.d.ts +8 -8
  376. package/dist/tools/fs/gh-rate-limit.d.ts +1 -1
  377. package/dist/tools/fs/notebook.d.ts +2 -2
  378. package/dist/tools/fs/read-deny.d.ts +29 -7
  379. package/dist/tools/fs/read-deny.js +63 -22
  380. package/dist/tools/fs/removal-targets.d.ts +1 -1
  381. package/dist/tools/fs/safety.d.ts +9 -9
  382. package/dist/tools/fs/search.d.ts +6 -6
  383. package/dist/tools/fs/shell-read-check.js +6 -1
  384. package/dist/tools/fs/shell-read-judge.d.ts +4 -0
  385. package/dist/tools/fs/shell-read-judge.js +5 -2
  386. package/dist/tools/loop-tick.d.ts +2 -2
  387. package/dist/tools/scheduler-tools.js +5 -1
  388. package/dist/tools/task-list.d.ts +7 -7
  389. package/dist/tools/task-list.js +5 -1
  390. package/dist/tools/todo.js +2 -1
  391. package/dist/tools/web.d.ts +1 -1
  392. package/dist/tools/web.js +40 -37
  393. package/dist/tools/worktree.d.ts +3 -3
  394. package/dist/tools/worktree.js +3 -1
  395. package/package.json +1 -1
  396. package/test/export-surface.snapshot.json +5756 -5638
  397. package/wire-changes/core@7.55.0.json +3318 -0
  398. package/dist/core/store-contracts/session-store-incarnation-contract.d.ts +0 -39
  399. package/dist/core/store-contracts/session-store-incarnation-contract.js +0 -95
@@ -5,6 +5,7 @@ import { bindDelegationName } from "../core/delegation-name.js";
5
5
  import { resumeRefusalDetailOf, resumeStartupCauseOf } from "../core/resume-startup-cause.js";
6
6
  import { errorCodeOf, thrownFailureOf } from "../core/runner/terminal-account.js";
7
7
  import { applyParentSpecSeat, parentSpecSeatOfCtx } from "../core/parent-spec-seat.js";
8
+ import { ADVISOR_FORK_SENTENCE, ADVISOR_TOOL_NAME } from "../core/advisor-verdict.js";
8
9
  import { applyClampSeats, assertClampRecord, childClampSeats, clampSeatsOf, clampSourceOf, engineHeadlessLegSeats, foldClampSources, postureUnderClamps } from "../core/child-clamp-seats.js";
9
10
  import { assertNoRetiredKeys } from "../core/retired-keys.js";
10
11
  import { stripSpawnTurnQuestionFace } from "../core/ask-question.js";
@@ -17,7 +18,7 @@ import { enqueueMemoryAnnouncement } from "../core/memory-engine/layout.js";
17
18
  import { resolveModel, resolveModelDisplayLabel } from "../core/roles.js";
18
19
  import { childModelSeat, childThinkingSeat, deploymentStatesSubagentModel, deploymentSubagentThinking, forkModelSeat, inheritedParentModel, runnerRoleMap } from "./child-model-seat.js";
19
20
  export { childThinkingSeat, deploymentSubagentThinking, deploymentSubagentTierModel } from "./child-model-seat.js";
20
- import { OUTPUT_TOOL_NAME, REPORT_BLOCKED_TOOL_NAME } from "../core/runner/synthetic-tools.js";
21
+ import { REPORT_BLOCKED_TOOL_NAME } from "../core/runner/synthetic-tools.js";
21
22
  import { TOOL_SEARCH_NAME } from "../core/runner/tool-disclosure.js";
22
23
  import { OFFLOAD_TOOL_NAME } from "../core/tool-result-store.js";
23
24
  import { compileToolSelector, delegationListWhere, snapshotDefinitionLists, toolListsDigest, toolNameAllowed, toolNameListFlaw } from "./tool-filter.js";
@@ -73,7 +74,8 @@ import { recordRosterSpawn } from "./roster-store.js";
73
74
  import { LAUNCH_RECEIPT_OWN_WORDS_CLAUSE, launchReceiptNoQuoteClause } from "./launch-receipt-contract.js";
74
75
  import { ObserverDigestTap, ObserverPairing, createObserverReportToolSpec, markObserverTaskId, unmarkObserverTaskId, isObserverTaskId, ObserverResumeStateError, ObserverStoppedByUserError, observerFramingPrompt, observerSlug, resolveObserverDeclaration, } from "./observer.js";
75
76
  import { SubagentStepRecorder } from "./subagent-steps.js";
76
- import { toolFace } from "../core/tool-catalog-entries.js";
77
+ import { OUTPUT_TOOL_NAME, mountRuleFace, toolFace } from "../core/tool-catalog-entries.js";
78
+ import { canonicalNameValue } from "../core/permission-rule-model.js";
77
79
  import { inheritedChildPool, inheritedMcpDeclarations } from "./inherited-tool-pool.js";
78
80
  import { readMember, thrownText } from "../core/thrown-value.js";
79
81
  const BG_AGENT_RESULT_MAX = 4_000;
@@ -1182,18 +1184,36 @@ function chargeDelegationEntryHandle(registry, key, store, handle) {
1182
1184
  armDelegationLedgerLifecycle(registry);
1183
1185
  sweepDelegationLedgerRound(registry, 3);
1184
1186
  }
1185
- export function normalizeSubagentType(value) {
1186
- return value.normalize("NFKC").toLowerCase().replace(/[\p{White_Space}\p{Pd}_]+/gu, "");
1187
- }
1188
- function foldGeneralPurposeAlias(args, shadowed) {
1189
- if (shadowed)
1187
+ export { normalizeSubagentType } from "../core/permission-rule-model.js";
1188
+ function canonicalSubagentTypeArgs(args, accepted, generalPurposeShadowed) {
1189
+ if (args === null || typeof args !== "object" || Array.isArray(args))
1190
1190
  return args;
1191
1191
  const raw = args;
1192
- if (raw !== null && typeof raw === "object" && raw.subagent_type === GENERAL_PURPOSE_SUBAGENT_TYPE) {
1193
- const { subagent_type: _dropped, ...rest } = raw;
1194
- return rest;
1192
+ const requested = raw["subagent_type"];
1193
+ if (requested === undefined || requested === "") {
1194
+ if (!generalPurposeShadowed)
1195
+ return { ...raw, subagent_type: GENERAL_PURPOSE_SUBAGENT_TYPE };
1196
+ if (requested === undefined)
1197
+ return args;
1198
+ const { subagent_type: _empty, ...omitted } = raw;
1199
+ return omitted;
1195
1200
  }
1196
- return args;
1201
+ if (typeof requested !== "string")
1202
+ return args;
1203
+ const resolved = canonicalNameValue(requested, accepted);
1204
+ return resolved.kind === "entry" && resolved.entry !== requested ? { ...raw, subagent_type: resolved.entry } : args;
1205
+ }
1206
+ function subagentTypeRefusal(requested, accepted) {
1207
+ if (requested === undefined || requested === "")
1208
+ return undefined;
1209
+ if (typeof requested !== "string")
1210
+ return { content: `Sub-agent not started: subagent_type must be a string. Available subagent_type values: ${accepted.join(", ")}.`, error: "unknown subagent_type" };
1211
+ const resolved = canonicalNameValue(requested, accepted);
1212
+ if (resolved.kind === "ambiguous")
1213
+ return { content: `Sub-agent not started: subagent_type "${requested}" is ambiguous — it matches ${resolved.entries.join(", ")}. Use the exact name.`, error: "ambiguous subagent_type" };
1214
+ if (resolved.kind === "unknown")
1215
+ return { content: `Sub-agent not started: unknown subagent_type "${requested}". Available subagent_type values: ${accepted.join(", ")}.`, error: "unknown subagent_type" };
1216
+ return undefined;
1197
1217
  }
1198
1218
  export const SUBAGENT_SYSTEM_NOTE = "You can delegate a self-contained subtask to an isolated sub-agent via the delegation tool. " +
1199
1219
  "The sub-agent runs in a clean context and returns a single report. Delegate slow, parallelizable, " +
@@ -1379,6 +1399,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
1379
1399
  return bindDelegationName(delegationToolName, {
1380
1400
  name: opts.name ?? DEFAULT_SUBAGENT_TOOL_NAME,
1381
1401
  ...toolFace("agent"),
1402
+ ruleFace: { ...mountRuleFace("agent"), nameValues: acceptedSubagentTypes() },
1382
1403
  agentListing,
1383
1404
  agentToolFaces,
1384
1405
  ...(depth === 0 && opts.allowTools !== undefined ? { agentToolLevelAllowTools: opts.allowTools } : {}),
@@ -1471,9 +1492,13 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
1471
1492
  }
1472
1493
  : {}),
1473
1494
  }),
1474
- prepareArguments: (args) => foldGeneralPurposeAlias(args, generalPurposeShadowed),
1495
+ prepareArguments: (args) => canonicalSubagentTypeArgs(args, acceptedSubagentTypes(), generalPurposeShadowed),
1496
+ validateInput: (args) => {
1497
+ const refusal = subagentTypeRefusal(args.subagent_type, acceptedSubagentTypes());
1498
+ return refusal === undefined ? { ok: true } : { ok: false, message: refusal.content, code: refusal.error };
1499
+ },
1475
1500
  execute: async (args, ctx) => {
1476
- const a = foldGeneralPurposeAlias(args, generalPurposeShadowed);
1501
+ const a = canonicalSubagentTypeArgs(args, acceptedSubagentTypes(), generalPurposeShadowed);
1477
1502
  const parentSpecSeat = parentSpecSeatOfCtx(ctx);
1478
1503
  const reviveClaim = ctx.reviveClaim;
1479
1504
  if (reviveClaim !== undefined && opts.background === undefined) {
@@ -1487,31 +1512,10 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
1487
1512
  if (!prompt) {
1488
1513
  return notStartedResult({ isError: true, content: "Sub-agent not started: 'prompt' was empty.", details: { error: "empty prompt" } });
1489
1514
  }
1490
- if (a.subagent_type !== undefined && typeof a.subagent_type !== "string") {
1491
- return notStartedResult({
1492
- isError: true,
1493
- content: `Sub-agent not started: subagent_type must be a string. Available subagent_type values: ${acceptedSubagentTypes().join(", ")}.`,
1494
- details: { error: "unknown subagent_type" },
1495
- });
1496
- }
1497
- const requestedType = a.subagent_type ?? "";
1498
- let rawType = requestedType;
1499
- if (requestedType !== "") {
1500
- const accepted = acceptedSubagentTypes();
1501
- if (!accepted.includes(requestedType)) {
1502
- const wanted = normalizeSubagentType(requestedType);
1503
- const hits = wanted === "" ? [] : accepted.filter((n) => normalizeSubagentType(n) === wanted);
1504
- if (hits.length > 1) {
1505
- return notStartedResult({
1506
- isError: true,
1507
- content: `Sub-agent not started: subagent_type "${requestedType}" is ambiguous — it matches ${hits.join(", ")}. Use the exact name.`,
1508
- details: { error: "ambiguous subagent_type" },
1509
- });
1510
- }
1511
- if (hits.length === 1)
1512
- rawType = hits[0];
1513
- }
1514
- }
1515
+ const typeRefusal = subagentTypeRefusal(a.subagent_type, acceptedSubagentTypes());
1516
+ if (typeRefusal !== undefined)
1517
+ return notStartedResult({ isError: true, content: typeRefusal.content, details: { error: typeRefusal.error } });
1518
+ const rawType = typeof a.subagent_type === "string" ? a.subagent_type : "";
1515
1519
  const wantsFork = forkOffered && rawType === FORK_SUBAGENT_TYPE;
1516
1520
  if (reviveClaim !== undefined && wantsFork) {
1517
1521
  return notStartedResult({ isError: true, content: `Sub-agent not revived: a "${FORK_SUBAGENT_TYPE}" agent cannot be revived — launch a new agent with the needed context instead.`, details: { error: "revive.fork_unsupported" } });
@@ -1520,13 +1524,6 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
1520
1524
  const def = hasAgents && !wantsFork && !omitted ? agentMap.get(rawType) : undefined;
1521
1525
  const wantsBackground = opts.background !== undefined && (a.run_in_background !== false || def?.background === true);
1522
1526
  const spawnAgentType = wantsFork ? FORK_SUBAGENT_TYPE : omitted ? GENERAL_PURPOSE_SUBAGENT_TYPE : rawType;
1523
- if (!def && !wantsFork && !omitted) {
1524
- return notStartedResult({
1525
- isError: true,
1526
- content: `Sub-agent not started: unknown subagent_type "${rawType}". Available subagent_type values: ${acceptedSubagentTypes().join(", ")}.`,
1527
- details: { error: "unknown subagent_type" },
1528
- });
1529
- }
1530
1527
  const allowFlaw = toolNameListFlaw(delegationListWhere(toolName, def?.name), "allowed", def !== undefined ? def.allowTools : opts.allowTools);
1531
1528
  if (allowFlaw !== undefined)
1532
1529
  return notStartedResult({ isError: true, content: `Sub-agent not started: ${inlineUntrusted(allowFlaw, 480)}`, details: { error: "config.agent.unknown_tool" } });
@@ -1922,6 +1919,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
1922
1919
  ...(ctx.getApiKeyAndHeaders !== undefined ? { getApiKeyAndHeaders: ctx.getApiKeyAndHeaders } : {}),
1923
1920
  ...(ctx.checkpointStoreForChildren !== undefined ? { checkpointStore: ctx.checkpointStoreForChildren } : {}),
1924
1921
  tools: [reportTool],
1922
+ ...(parentSpecSeat?.advisorModel !== undefined ? { excludeTools: [ADVISOR_TOOL_NAME] } : {}),
1925
1923
  ...(ctx.deferTools !== undefined ? { deferTools: [...ctx.deferTools] } : {}),
1926
1924
  ...(ctx.alwaysLoadTools !== undefined ? { alwaysLoadTools: [...ctx.alwaysLoadTools] } : {}),
1927
1925
  ...(ctx.restoreGatedTools !== undefined ? { restoreGatedTools: ctx.restoreGatedTools === true ? true : [...ctx.restoreGatedTools] } : {}),
@@ -1942,6 +1940,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
1942
1940
  const observerGate = parentGate === undefined
1943
1941
  ? undefined
1944
1942
  : {
1943
+ ...(parentGate.ancestorRules !== undefined ? { ancestorRules: parentGate.ancestorRules } : {}),
1945
1944
  ...(parentGate.permissionMode !== undefined ? { permissionMode: parentGate.permissionMode } : {}),
1946
1945
  ...(parentGate.permissionModeCeiling !== undefined ? { permissionModeCeiling: parentGate.permissionModeCeiling } : {}),
1947
1946
  ...(parentGate.shellGate !== undefined ? { shellGate: parentGate.shellGate } : {}),
@@ -2423,7 +2422,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
2423
2422
  const forkInternals = { ...childInternals, insideFork: true, ...(ctx.reminderMark !== undefined ? { reminderMark: ctx.reminderMark } : {}) };
2424
2423
  stepRecorder.lockTo(forkedId);
2425
2424
  const forkWorktreeNote = worktreeDir !== undefined ? forkWorktreeTranslationNote(ctx.parentCwd, worktreeDir) : undefined;
2426
- const forkObjective = `${FORK_DIRECTIVE_FRAME}${prompt}${forkWorktreeNote !== undefined ? `\n\n${forkWorktreeNote}` : ""}`;
2425
+ const forkObjective = `${FORK_DIRECTIVE_FRAME}${prompt}${forkWorktreeNote !== undefined ? `\n\n${forkWorktreeNote}` : ""}${parentSpecSeat?.advisorModel !== undefined ? `\n\n${ADVISOR_FORK_SENTENCE}` : ""}`;
2427
2426
  if (wantsBackground) {
2428
2427
  const bg = opts.background;
2429
2428
  const notify = ctx.onTaskNotification ?? bg.notify;
@@ -1,6 +1,5 @@
1
1
  import type { AgentDefinition, ToolSpec } from "../core/types.js";
2
2
  import { type ToolLegKind, type ToolSelector, type ToolSelectorLayer } from "../core/tool-face.js";
3
- import { type ProtocolId } from "../core/protocol-table.js";
4
3
  import { type ToolNameListReading } from "../core/tool-name-list.js";
5
4
  /**
6
5
  * The tool selector (design/38 1A, one operation since #1623): what tools a run may use, read once over the universe it can get
@@ -10,27 +9,23 @@ import { type ToolNameListReading } from "../core/tool-name-list.js";
10
9
  * run that spawned it), so there is no spawn-time filter and no complement anywhere.
11
10
  *
12
11
  * - an allowed list absent, or holding `"*"` (any spelling the rule syntax reads as it: `*()`, `*(*)`), sets no allowlist on
13
- * its layer; otherwise the layer keeps only what it names
14
- * (`[]` keeps nothing — intentional, not a mistake);
12
+ * its layer; otherwise the layer keeps only what it names (`[]` keeps nothing — intentional);
15
13
  * - a denied list removes what it names from whatever remains (a denied tool always loses);
16
14
  * - a layer above a run (its ceiling) bounds it: a child's `"*"` never widens what its parent could use.
17
15
  *
18
- * An entry is read by the rule syntax ({@link readDeniedEntry}: `Tool(content)` names `Tool`, the content is not read, the
19
- * whole tool is hidden; an entry the syntax cannot read names no tool); a protocol spelling (`mcp__srv`, `mcp__srv__*`, a glob over the tool segment) reaches the
20
- * tools of that peer, including ones it lists later; an entry no tool answers to is kept by name and reaches one mounted later.
21
- * Judged at the prepare that receives it: a spelling no tool name can have is refused, an unknown name told (`sub-agent-deny-lists.ts`).
16
+ * An entry is read by the rule syntax ({@link readDeniedEntry}); a protocol spelling (`mcp__srv`, `mcp__srv__*`, a glob over the
17
+ * tool segment) reaches the tools of that peer, including ones it lists later; an entry no tool answers to is kept by name and
18
+ * reaches one mounted later. Judged at the prepare that receives it (`sub-agent-deny-lists.ts`).
22
19
  *
23
- * `"*"` in an allowed list is the "allow all" sentinel and never a name: no tool is named `*` (the caller tool name
24
- * contract, `caller-tool-name.ts`, refuses it at the mount; engine and protocol-minted names never are).
20
+ * `"*"` in an allowed list is the "allow all" sentinel and never a name (`caller-tool-name.ts` refuses it at the mount).
25
21
  */
26
22
  /**
27
23
  * How ONE denied-tools entry is read — by the rule syntax's own test of a rule spelling (`ruleSpellingOf`, the one every entry
28
24
  * list's reader asks), exactly as written: `Tool(content)` names `Tool` (the content is not read here, so the whole tool is
29
25
  * hidden), `Tool()` and `Tool(*)` are the bare name. An entry the syntax cannot read — surrounding whitespace, a tool name
30
26
  * outside its spelling (a blank or an invisible character before the `(`, a leading `-`), a parenthesis that does not close
31
- * the entry — names no tool: `unreadable`, the entry as written. A value that is not a string (a list a host read from a file
32
- * can hold anything) names no tool either: it reads as `not_a_string` with a fixed label of its TYPE, and nothing about the
33
- * value is read, converted or printed — `typeof` and the array test only.
27
+ * the entry — names no tool: `unreadable`, the entry as written. A value that is not a string names no tool either: it reads as
28
+ * `not_a_string` with a fixed label of its TYPE, and nothing about the value is read, converted or printed.
34
29
  */
35
30
  export type DeniedEntryReading = {
36
31
  readonly kind: "name";
@@ -57,9 +52,9 @@ export declare function notAListSentence(where: string, side: ToolNameListSide,
57
52
  export declare function delegationListWhere(toolName: string, definitionName: string | undefined): string;
58
53
  /**
59
54
  * The digest of a run's own two tool lists as its selector reads them (an absent denied list reads as an empty one): sha256 over the
60
- * binding serializer's canonical form — the serializer the checkpoint row digest uses. It is the evidence that the spawning run judged
61
- * EXACTLY these lists (`RunInternals.toolListsJudged`, and the row's `CheckpointState.toolListsJudged` on a resume); `undefined` for
62
- * lists the serializer cannot encode, which therefore never match any evidence.
55
+ * binding serializer's canonical form. It is the evidence that the spawning run judged EXACTLY these lists
56
+ * (`RunInternals.toolListsJudged`, and the row's `CheckpointState.toolListsJudged` on a resume); `undefined` for lists the
57
+ * serializer cannot encode, which therefore never match any evidence.
63
58
  */
64
59
  export declare function toolListsDigest(allow: readonly unknown[] | undefined, deny: readonly unknown[] | undefined): string | undefined;
65
60
  /**
@@ -67,46 +62,36 @@ export declare function toolListsDigest(allow: readonly unknown[] | undefined, d
67
62
  * of strings. The one reading the judgment before the run and the spawn-time check of a tool that never went through prepare share.
68
63
  */
69
64
  export declare function toolNameListFlaw(where: string, side: ToolNameListSide, value: unknown): string | undefined;
70
- /** A definition with its two tool-name lists replaced by their one copy — the copy every later reader (the judgment before the
71
- * run, the roster, the filter at each spawn) takes instead of the host's container. */
65
+ /** A definition with its two tool-name lists replaced by their one copy — the copy every later reader takes instead of the host's container. */
72
66
  export declare function snapshotDefinitionLists(def: AgentDefinition): AgentDefinition;
73
67
  /**
74
- * What ONE tool-name list reaches — the single reading every consumer of an allowed or a denied list takes (the spawn-time
75
- * filter, the nested-delegation check, the memory content-origin face, the judgment before the run):
76
- * - `names`: exact spellings; a tool answers to its wire name and to every alias it declares;
77
- * - `covering`: the protocol spellings that cover a SET — a peer (`mcp__srv`), the same set written with the star
78
- * (`mcp__srv__*`), a glob over the tool segment (`mcp__srv__get_*`) — matched by the allow layer's own covering matcher,
79
- * peers compared exactly, both sides in the same namespace;
80
- * - `wholeProtocols`: a denied list's `mcp__*` — every tool of that protocol. An allowed list reads it as nothing (the
81
- * reference's allow resolution has no such form: it keeps no MCP tool by it).
68
+ * What ONE tool-name list reaches — the single reading every consumer of an allowed or a denied list takes: `names` are exact
69
+ * spellings (a tool answers to its wire name and every alias it declares); `covering` the protocol spellings that cover a SET
70
+ * (`mcp__srv`, `mcp__srv__*`, `mcp__srv__get_*`; on a denied list also `mcp__*` / `mcp__*__*`, which an allowed list reads as nothing).
82
71
  */
83
72
  export interface ToolNameListReach {
84
73
  readonly names: ReadonlySet<string>;
85
74
  readonly covering: readonly string[];
86
- readonly wholeProtocols: ReadonlySet<ProtocolId>;
87
75
  }
88
76
  /**
89
77
  * The tool ONE entry of a list on `side` reaches ({@link readDeniedEntry}) — the one per-entry reading every list reader takes:
90
- * `Tool()` / `Tool(*)` are the bare `Tool` (`*()` / `*(*)` the wildcard `*`); a denied `Tool(content)` hides the whole `Tool`;
91
- * an allowed one, an unreadable entry or a non-string reaches nothing (`undefined`).
78
+ * `Tool()` / `Tool(*)` are the bare `Tool`; a denied `Tool(content)` hides the whole `Tool`; an allowed one, an unreadable entry
79
+ * or a non-string reaches nothing (`undefined`).
92
80
  */
93
81
  export declare function toolNameOfEntry(entry: unknown, side: ToolNameListSide): string | undefined;
94
82
  /**
95
- * Is this entry a bare tool name as the rule syntax reads it, written as such (`Read`, `mcp__srv__*`, `*`; never `Read()`,
96
- * `Read(*)`, `Read(x)`, an unreadable spelling or a non-string)? The one form a checkpoint row records and is read back in.
97
- */
83
+ * Is this entry a bare tool name as the rule syntax reads it, written as such (`Read`, `mcp__srv__*`, `*`; never `Read()` or
84
+ * `Read(x)`)? The one form a checkpoint row records and is read back in. */
98
85
  export declare function isCanonicalToolName(entry: unknown): boolean;
99
86
  /**
100
- * A tool-name list as a checkpoint row records it: each entry as {@link toolNameOfEntry} reads it, in canonical spelling, an
101
- * allowed entry that admits nothing left out — the copy reaches what the list reached, in the spelling a reader accepts
102
- * ({@link isCanonicalToolName}). An unreadable entry stays as written: prepare refuses it before the park, the reader again.
87
+ * A tool-name list as a checkpoint row records it: each entry as {@link toolNameOfEntry} reads it, in canonical spelling
88
+ * ({@link isCanonicalToolName}), an allowed entry that admits nothing left out. An unreadable entry stays as written: prepare
89
+ * refuses it before the park, the reader again.
103
90
  */
104
91
  export declare function persistedToolNameList(entries: readonly string[], side: ToolNameListSide): string[];
105
92
  /**
106
- * What an allowed-tools value admits, or `undefined` when it names no allowlist: absent, `null`, or a list holding the
107
- * wildcard — an entry {@link toolNameOfEntry} reads as `*` (`*`, `*()`, `*(*)`). A list admits its string entries (an entry that
108
- * is not a string admits nothing); a value that is not a list admits NOTHING — the judge before the run refuses it, and a
109
- * reader that meets it first fails closed.
93
+ * What an allowed-tools value admits, or `undefined` when it names no allowlist: absent, `null`, or a list holding the wildcard
94
+ * ({@link toolNameOfEntry} reads `*`, `*()`, `*(*)` as it). A value that is not a list admits NOTHING (refused before the run).
110
95
  */
111
96
  export declare function readAllowedToolList(allowTools: unknown): ToolNameListReach | undefined;
112
97
  /** What a denied value hides: its string entries read as {@link readDeniedEntry} reads them (an entry it reads as `unreadable` or not a string, or a value that is not a list, hides nothing here — the judgment before the run refuses each). */
@@ -132,17 +117,15 @@ export declare function isToolSelectorLayer(layer: unknown): layer is ToolSelect
132
117
  /**
133
118
  * Compile ONE run's tool selector from its layers (the ceiling it was spawned under, then its own lists — the LAST layer is its own)
134
119
  * and the kinds of leg it is. Each list is read by the one reading ({@link readAllowedToolList} / {@link readDeniedToolList}) and
135
- * matched by the one matcher ({@link listReaches}); a protocol tool of one of `legs` is admitted whatever the leg's own lists say —
136
- * and whatever the ceiling says too, unless a kind of its row shares its spawner's tool surface ({@link protocolRowUnderCeiling}):
137
- * the ceiling layers decide it. Whether a list may reach a protocol tool at all is judged at prepare. The layers are kept as handed —
138
- * the producer passes frozen copies of the lists it read.
120
+ * matched by the one matcher ({@link listReaches}); a protocol tool of one of `legs` is admitted whatever the leg's own lists say,
121
+ * and whatever the ceiling says unless a kind of its row shares its spawner's tool surface ({@link protocolRowUnderCeiling}), when
122
+ * the ceiling layers decide it. Whether a list may reach a protocol tool at all is judged at prepare.
139
123
  */
140
124
  export declare function compileToolSelector(layers: readonly ToolSelectorLayer[], legs?: readonly ToolLegKind[]): ToolSelector;
141
125
  /**
142
126
  * What a leg's tool valve leaves mounted — its one reading: nothing under the run's whole-face switch (`excludeAllTools`: every
143
127
  * tool unmounts, protocol tools included), else what the compiled selector admits. The valve unmounts by it, and every question
144
- * prepare asks about the post-valve roster before the valve runs (the full shell's reachability, the memory write channel, the
145
- * persistence verdict, the two memory pairs' planning) asks it too.
128
+ * prepare asks about the post-valve roster before the valve runs asks it too.
146
129
  */
147
130
  export declare function valveLeaves(spec: {
148
131
  readonly excludeAllTools?: true;
@@ -150,8 +133,8 @@ export declare function valveLeaves(spec: {
150
133
  /**
151
134
  * The valve's reading at the SERVER level — {@link valveLeaves} asked of a whole peer before any of its tools is known: can the valve
152
135
  * leave a tool of the peer `prefix` (`mcp__srv__`) at all? Nothing under the run's whole-face switch; else what the compiled selector's
153
- * lists can reach of the peer ({@link ToolSelector.admitsPeer} — read off the lists, never off what the server lists). A peer this
154
- * answers `false` for leaves no tool on the roster whatever it lists, so a run has no reason to dial it or to teach its instructions.
136
+ * lists can reach of the peer ({@link ToolSelector.admitsPeer}). A peer answered `false` leaves no tool on the roster, so a run has no
137
+ * reason to dial it or to teach its instructions.
155
138
  */
156
139
  export declare function valveLeavesPeer(spec: {
157
140
  readonly excludeAllTools?: true;
@@ -3,9 +3,8 @@ import { canonicalize, UNCANONICALIZABLE } from "../core/canonical-json.js";
3
3
  import { SPAWNER_SURFACE_LEG_KINDS } from "../core/tool-face.js";
4
4
  import { ruleSpellingOf } from "../core/permission-rule-syntax.js";
5
5
  import { TOOL_CATALOG_ENTRIES } from "../core/tool-catalog-entries.js";
6
- import { isNamespacedCoveringRuleName, namespacedRuleNameCovers } from "../core/namespaced-rule-name.js";
7
- import { protocolOf } from "../core/protocol-table.js";
8
- import { splitNamespacedName } from "../core/tool-name-aliases.js";
6
+ import { isNamespacedCoveringRuleName, namespacedRuleNameCovers, namespacedRuleReachInto } from "../core/namespaced-rule-name.js";
7
+ import { splitNamespacedName, wholeProtocolOf } from "../core/tool-name-aliases.js";
9
8
  import { readToolNameList, snapshotToolNameList, valueTypeLabel } from "../core/tool-name-list.js";
10
9
  export function readDeniedEntry(entry) {
11
10
  if (typeof entry !== "string")
@@ -72,23 +71,16 @@ export function persistedToolNameList(entries, side) {
72
71
  function reachOf(entries, side) {
73
72
  const names = new Set();
74
73
  const covering = [];
75
- const wholeProtocols = new Set();
76
74
  for (const entry of entries) {
77
75
  const name = toolNameOfEntry(entry, side);
78
76
  if (name === undefined)
79
77
  continue;
80
- const split = splitNamespacedName(name);
81
- if (split !== undefined && split.tool === undefined && split.peer === "*") {
82
- if (side === "denied")
83
- wholeProtocols.add(split.ns.id);
84
- continue;
85
- }
86
- if (isNamespacedCoveringRuleName(name))
78
+ if (isNamespacedCoveringRuleName(name, side === "denied" ? "deny" : "allow"))
87
79
  covering.push(name);
88
- else
80
+ else if (wholeProtocolOf(name) === undefined)
89
81
  names.add(name);
90
82
  }
91
- return { names, covering, wholeProtocols };
83
+ return { names, covering };
92
84
  }
93
85
  export function readAllowedToolList(allowTools) {
94
86
  if (allowTools === undefined || allowTools === null)
@@ -111,11 +103,6 @@ export function listReaches(reach, tool) {
111
103
  for (const pattern of reach.covering)
112
104
  if (namespacedRuleNameCovers(pattern, spelling))
113
105
  return true;
114
- if (reach.wholeProtocols.size > 0) {
115
- const ns = protocolOf(spelling);
116
- if (ns !== undefined && reach.wholeProtocols.has(ns.id))
117
- return true;
118
- }
119
106
  }
120
107
  return false;
121
108
  }
@@ -127,21 +114,11 @@ export function protocolToolNames(legs) {
127
114
  return [...new Set(PROTOCOL_ROWS.filter((r) => r.legs.some((l) => legs.includes(l))).map((r) => r.name))];
128
115
  }
129
116
  function reachTouchesPeer(reach, peer) {
130
- if (reach.wholeProtocols.has(peer.ns))
131
- return true;
132
- const inPeer = (spelling) => {
133
- const split = splitNamespacedName(spelling);
134
- return split !== undefined && split.ns.id === peer.ns && split.peer === peer.peer;
135
- };
136
- return [...reach.names].some(inPeer) || reach.covering.some(inPeer);
117
+ const into = (spelling) => namespacedRuleReachInto(spelling, peer.ns, peer.peer) !== "none";
118
+ return [...reach.names].some(into) || reach.covering.some(into);
137
119
  }
138
120
  function reachCoversPeer(reach, peer) {
139
- if (reach.wholeProtocols.has(peer.ns))
140
- return true;
141
- return reach.covering.some((pattern) => {
142
- const split = splitNamespacedName(pattern);
143
- return split !== undefined && split.ns.id === peer.ns && split.peer === peer.peer && (split.tool === undefined || split.tool === "*");
144
- });
121
+ return reach.covering.some((pattern) => namespacedRuleReachInto(pattern, peer.ns, peer.peer) === "all");
145
122
  }
146
123
  export function isToolSelectorLayer(layer) {
147
124
  return typeof layer === "object" && layer !== null && !Array.isArray(layer);
@@ -7,13 +7,13 @@ import type { ModelRef, TaskResult, TaskSpec, TaskStatus, ToolSpec } from "../co
7
7
  * an implementation task and tries to BREAK it — read-only, evidence-required, returning a structured
8
8
  * verdict — then the gate loops fix→re-verify until PASS or a round cap.
9
9
  *
10
- * PROVENANCE (2026-07-14; re-verified and CORRECTED against CC 2.1.220): distilled and de-branded from the
10
+ * PROVENANCE (2026-07-14; re-verified and CORRECTED): distilled and de-branded from the
11
11
  * MIT-era upstream source's dedicated `verification` agent — which was an Anthropic-internal A/B experiment
12
- * (third-party default OFF) and has since been RETIRED upstream: 2.1.207 through 2.1.220 ship NO verification
12
+ * (third-party default OFF) and has since been RETIRED upstream: later releases ship NO verification
13
13
  * agent. The current upstream completion-gate shape is (a) the Stop hook (`decision:"block"` + reason fed
14
14
  * back — sema's Stop hook is at full parity) and (b) — corrected — NOT a bundled skill. There is no built-in
15
15
  * `verify` skill in the 220 corpus. What 220 ships is an INSTRUCTION TO CREATE ONE PER PROJECT: its memory
16
- * prompt (@190146 (cli250.js:38927)) forbids creating project skills ("never create one — a new project skill
16
+ * prompt forbids creating project skills ("never create one — a new project skill
17
17
  * silently shadows a same-named built-in skill") and makes exactly one exception — "The single exception is
18
18
  * verify, because how a project verifies changes is project-specific: put a verify correction in the
19
19
  * `.claude/skills/verify/ SKILL.md` closest to the code it covers … and if that file does not exist, create
@@ -9,6 +9,7 @@ import { errorResultMediaNote, IMAGE_OMITTED_NO_VISION, modelSupportsVision, sen
9
9
  import { ANTHROPIC_RESERVED, OUTPUT_CAP_KEYS, applyExtraBody, effectiveOutputCap, headerBagOnce, lockHeader, mergeHeaders, takeHeaderCasefold } from "./request-params.js";
10
10
  import { admitRouteRequest, applyRouteCredentialHeaders, assertServableRequestRoot, brainConfigSnapshot, createBrainRouteJudge, joinRequestUrl, resolveRequestRootOf, resolveRouteCredential } from "./route-adjudicator.js";
11
11
  import { requestRouteOf } from "./request-route.js";
12
+ import { NAMES_AS_WRITTEN, resolveProviderDialect, endpointToolNames } from "./provider-dialect.js";
12
13
  import { MIN_THINKING_TOKENS, budgetCapSkipsThinking, declaredEffortLevels, reasoningBudgetShare, reasoningRequestCarried, resolveEffort } from "./reasoning.js";
13
14
  import { runStreamingBrain } from "./stream-engine.js";
14
15
  import { refuseRetiredTimeoutKnobs } from "./timeout.js";
@@ -49,7 +50,7 @@ function toUserBlocks(content, supportsVision = true) {
49
50
  emitBrainTelemetry({ kind: "vision_placeholder", count: omitted });
50
51
  return blocks;
51
52
  }
52
- function toAnthropicMessages(ctx, model) {
53
+ function toAnthropicMessages(ctx, model, toolNames) {
53
54
  const supportsVision = modelSupportsVision(model);
54
55
  const raw = [];
55
56
  let pendingDocs = [];
@@ -86,7 +87,7 @@ function toAnthropicMessages(ctx, model) {
86
87
  blocks.push({ type: "text", text: c.text });
87
88
  }
88
89
  else if (c.type === "toolCall") {
89
- blocks.push({ type: "tool_use", id: providerToolCallId(c), name: c.name, input: c.arguments ?? {} });
90
+ blocks.push({ type: "tool_use", id: providerToolCallId(c), name: toolNames.sent(c.name), input: c.arguments ?? {} });
90
91
  }
91
92
  }
92
93
  raw.push({ role: "assistant", content: blocks.length ? blocks : [{ type: "text", text: NO_CONTENT }] });
@@ -155,12 +156,12 @@ function toAnthropicMessages(ctx, model) {
155
156
  }
156
157
  return merged;
157
158
  }
158
- function toAnthropicTools(ctx, cacheBreakpoints) {
159
+ function toAnthropicTools(ctx, cacheBreakpoints, toolNames) {
159
160
  if (!ctx.tools || ctx.tools.length === 0) {
160
161
  return undefined;
161
162
  }
162
163
  return ctx.tools.map((t, i) => ({
163
- name: t.name,
164
+ name: toolNames.sent(t.name),
164
165
  description: t.description,
165
166
  input_schema: t.parameters,
166
167
  ...(cacheBreakpoints && i === ctx.tools.length - 1 ? { cache_control: EPHEMERAL } : {}),
@@ -238,6 +239,7 @@ export function createAnthropicBrain(given = {}) {
238
239
  let thinkingRequested = false;
239
240
  let sentMaxTokens;
240
241
  let sentMaxTokensLane = "config-default";
242
+ let sentToolNames = NAMES_AS_WRITTEN;
241
243
  return runStreamingBrain({
242
244
  model,
243
245
  doFetch,
@@ -249,6 +251,8 @@ export function createAnthropicBrain(given = {}) {
249
251
  buildRequest: (overrides) => {
250
252
  const routed = { id: model.id, baseUrl: model.baseUrl };
251
253
  const { root, origin: rootOrigin } = resolveRequestRootOf(routed.baseUrl, config.baseUrl, ANTHROPIC_DEFAULT_BASE_URL);
254
+ const url = joinRequestUrl(root, "/v1/messages");
255
+ const builtToolNames = endpointToolNames(resolveProviderDialect(url, model.api), model.api, (context.tools ?? []).map((t) => t.name));
252
256
  const modelHeaders = headerBagOnce(model.headers);
253
257
  const optionsHeaders = headerBagOnce(options?.headers);
254
258
  const routeCredential = resolveRouteCredential({
@@ -274,12 +278,12 @@ export function createAnthropicBrain(given = {}) {
274
278
  const body = {
275
279
  model: model.id,
276
280
  max_tokens: overrides?.maxOutputTokens ?? options?.maxTokens ?? model.maxTokens ?? config.defaultMaxTokens ?? 4096,
277
- messages: toAnthropicMessages(context, model),
281
+ messages: toAnthropicMessages(context, model, builtToolNames),
278
282
  stream: true,
279
283
  };
280
284
  if (system)
281
285
  body.system = system;
282
- const tools = toAnthropicTools(context, cacheBreakpoints);
286
+ const tools = toAnthropicTools(context, cacheBreakpoints, builtToolNames);
283
287
  if (tools)
284
288
  body.tools = tools;
285
289
  const anthCompat = (model.compat ?? {});
@@ -355,9 +359,9 @@ export function createAnthropicBrain(given = {}) {
355
359
  : model.maxTokens !== undefined
356
360
  ? "model"
357
361
  : "config-default";
358
- const { body: wire, dropped: extraBodyDropped } = applyExtraBody(body, model.extraBody, ANTHROPIC_RESERVED);
362
+ const { body: wire, dropped: extraBodyDropped } = applyExtraBody(body, model, ANTHROPIC_RESERVED);
359
363
  return {
360
- url: joinRequestUrl(root, "/v1/messages"),
364
+ url,
361
365
  headers,
362
366
  body: JSON.stringify(wire),
363
367
  extraBodyDropped,
@@ -369,6 +373,7 @@ export function createAnthropicBrain(given = {}) {
369
373
  thinkingRequested = builtThinkingRequested;
370
374
  sentMaxTokens = builtMaxTokens;
371
375
  sentMaxTokensLane = builtMaxTokensLane;
376
+ sentToolNames = builtToolNames;
372
377
  if (builtReasoningFacts !== undefined)
373
378
  reportReasoningWireFacts(builtReasoningFacts);
374
379
  },
@@ -540,7 +545,7 @@ export function createAnthropicBrain(given = {}) {
540
545
  else if (cb.type === "tool_use") {
541
546
  acc.type = "tool_use";
542
547
  acc.toolId = cb.id ?? "";
543
- acc.toolName = cb.name ?? "";
548
+ acc.toolName = sentToolNames.called(cb.name ?? "");
544
549
  }
545
550
  else {
546
551
  acc.type = "text";
@@ -256,6 +256,21 @@ export declare function abortLikeName(err: unknown): "AbortError" | "TimeoutErro
256
256
  * rather than testing `instanceof BrainError`, which walks a chain a revoked proxy traps — and the one
257
257
  * site that did so sits in an async IIFE with no `.catch`. */
258
258
  export declare function brainErrorCodeOf(e: unknown): BrainErrorCode | undefined;
259
+ /** What a thrown brain failure says about itself in machine words: its code, and the structural input-too-long cause
260
+ * its minter declared (or ruled out). Empty for a value that carries no brain code. */
261
+ export interface ThrownBrainFailure {
262
+ readonly code?: BrainErrorCode;
263
+ readonly errorKind?: "input_too_long";
264
+ readonly inputTooLongRuledOut?: true;
265
+ }
266
+ /**
267
+ * The one reading of a thrown brain failure's structure: the code word ({@link brainErrorCodeOf}, never `instanceof`)
268
+ * and, only when the value carries a code, the input-too-long cause it was minted with — read by brand, so a value from
269
+ * another realm or behind a revoked proxy reads the same as a local `BrainError`. The stream engine's terminal shell and
270
+ * every caller that catches a brain call read it, so a failure that is thrown and one that is returned on a message
271
+ * carry the same facts.
272
+ */
273
+ export declare function thrownBrainFailure(e: unknown): ThrownBrainFailure;
259
274
  /** Render a transport-level error WITHOUT folding away its cause chain: undici rejects with
260
275
  * `TypeError("fetch failed", { cause })` where the CAUSE carries the actionable fact, and the shell
261
276
  * alone reads the same for refused / DNS / mid-stream disconnect. Walks the chain (bounded), appending
@@ -247,6 +247,16 @@ export function brainErrorCodeOf(e) {
247
247
  const code = readMember(e, "code");
248
248
  return typeof code === "string" && BRAIN_ERROR_CODES.includes(code) ? code : undefined;
249
249
  }
250
+ export function thrownBrainFailure(e) {
251
+ const code = brainErrorCodeOf(e);
252
+ if (code === undefined)
253
+ return {};
254
+ if (readMember(e, "inputTooLong") === true)
255
+ return { code, errorKind: "input_too_long" };
256
+ if (readMember(e, "inputTooLongRuledOut") === true)
257
+ return { code, inputTooLongRuledOut: true };
258
+ return { code };
259
+ }
250
260
  export function describeNetworkError(e) {
251
261
  const top = thrownText(e);
252
262
  const parts = [];
@@ -1,5 +1,5 @@
1
1
  /**
2
- * First-party model presets (design/119, CC 2.1.198 rebaseline).
2
+ * First-party model presets (design/119).
3
3
  *
4
4
  * sema stays caller-injects-`Model` by design (no baked catalog — the CC catalog/alias/family layer
5
5
  * is a product surface we deliberately don't carry). What IS worth shipping is the per-model
@@ -7,12 +7,12 @@
7
7
  * (adaptive thinking form, effort tiers, temperature rejection) that a wrong guess turns into a
8
8
  * hard 400. These presets are DATA, not mechanism — every field can be overridden by the caller.
9
9
  *
10
- * Pricing is deliberately NOT baked (CC 198 doesn't bake it either): `cost` defaults to zeros and a
10
+ * Pricing is deliberately NOT baked (the reference doesn't bake it either): `cost` defaults to zeros and a
11
11
  * deployment that wants cost accounting fills in the current official per-MTok rates.
12
12
  */
13
13
  import type { AnthropicMessagesCompat, Model } from "../internal/llm.js";
14
14
  /**
15
- * The Fable-5-class Anthropic wire contract (CC 2.1.198 capability bits, design/119 P0):
15
+ * The Fable-5-class Anthropic wire contract (capability bits, design/119 P0):
16
16
  * - `thinkingMode: "adaptive"` — `thinking: { type: "adaptive" }`, NO budget_tokens (400 on budget).
17
17
  * - `effortLevels` — the full five-tier `output_config.effort` range (fable-5 has `xhigh_effort` +
18
18
  * `max_effort`; a model without those bits should declare a shorter list and higher requests clamp).
@@ -26,7 +26,7 @@ export declare const FABLE_5_COMPAT: AnthropicMessagesCompat;
26
26
  */
27
27
  export declare const FABLE_5_PROMPT_GUIDANCE: readonly string[];
28
28
  /**
29
- * A ready-to-use `claude-fable-5` {@link Model} (CC 2.1.198 registry facts: 1M-token native context
29
+ * A ready-to-use `claude-fable-5` {@link Model} (registry facts: 1M-token native context
30
30
  * window, 64k default max output — the 128k tier is opt-in via `maxTokens` override, knowledge
31
31
  * cutoff Jan 2026, `default_effort: "high"`). Override anything per deployment; set `cost` for
32
32
  * accounting (not baked — see module note).