@sema-agent/core 7.48.0 → 7.49.1

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 (421) hide show
  1. package/CHANGELOG.md +457 -0
  2. package/README.md +2 -2
  3. package/dist/agents/cascade.d.ts +2 -5
  4. package/dist/agents/child-failure.d.ts +20 -0
  5. package/dist/agents/child-failure.js +28 -0
  6. package/dist/agents/cross-session-ref.d.ts +11 -3
  7. package/dist/agents/cross-session-ref.js +6 -0
  8. package/dist/agents/cumulative-stats.d.ts +12 -15
  9. package/dist/agents/cumulative-stats.js +1 -1
  10. package/dist/agents/extra-tool-names.js +1 -1
  11. package/dist/agents/inherited-tool-pool.d.ts +17 -13
  12. package/dist/agents/inherited-tool-pool.js +4 -3
  13. package/dist/agents/peer-session-drain.d.ts +3 -2
  14. package/dist/agents/peer-session-drain.js +5 -4
  15. package/dist/agents/send-message-tool.js +2 -9
  16. package/dist/agents/subagent.d.ts +10 -29
  17. package/dist/agents/subagent.js +65 -53
  18. package/dist/agents/suspend-guard.d.ts +1 -1
  19. package/dist/agents/tool-filter.d.ts +76 -65
  20. package/dist/agents/tool-filter.js +122 -92
  21. package/dist/agents/verify.d.ts +4 -7
  22. package/dist/agents/verify.js +6 -7
  23. package/dist/bench/metrics.d.ts +1 -2
  24. package/dist/brain/anthropic.js +133 -79
  25. package/dist/brain/errors.d.ts +53 -6
  26. package/dist/brain/errors.js +22 -2
  27. package/dist/brain/input-too-long.d.ts +40 -19
  28. package/dist/brain/input-too-long.js +3 -16
  29. package/dist/brain/open-responses.js +19 -10
  30. package/dist/brain/openai.js +123 -32
  31. package/dist/brain/provider-dialect.d.ts +214 -0
  32. package/dist/brain/provider-dialect.js +186 -0
  33. package/dist/brain/request-params.d.ts +27 -8
  34. package/dist/brain/request-params.js +7 -12
  35. package/dist/brain/request-route.d.ts +84 -0
  36. package/dist/brain/request-route.js +41 -0
  37. package/dist/brain/retry.d.ts +8 -0
  38. package/dist/brain/retry.js +10 -4
  39. package/dist/brain/route-adjudicator.d.ts +7 -0
  40. package/dist/brain/route-adjudicator.js +5 -1
  41. package/dist/brain/status-sink.d.ts +20 -0
  42. package/dist/brain/status-sink.js +11 -0
  43. package/dist/brain/stream-engine.d.ts +52 -1
  44. package/dist/brain/stream-engine.js +81 -24
  45. package/dist/brain/stream-shared.d.ts +57 -11
  46. package/dist/brain/stream-shared.js +28 -2
  47. package/dist/core/a2a.d.ts +1 -0
  48. package/dist/core/agent-config-dir.js +3 -2
  49. package/dist/core/allow-entry.d.ts +21 -12
  50. package/dist/core/allow-entry.js +38 -31
  51. package/dist/core/arg-summary.d.ts +21 -28
  52. package/dist/core/arg-summary.js +235 -88
  53. package/dist/core/ask-origin.d.ts +42 -24
  54. package/dist/core/ask-origin.js +18 -13
  55. package/dist/core/auto-mode-prompt-assets.d.ts +2 -2
  56. package/dist/core/auto-mode-prompt-assets.js +1 -1
  57. package/dist/core/auto-mode-prompt.d.ts +11 -1
  58. package/dist/core/auto-mode-prompt.js +13 -10
  59. package/dist/core/auto-mode-rebuild.d.ts +7 -0
  60. package/dist/core/auto-mode-rebuild.js +4 -1
  61. package/dist/core/canonical-json.d.ts +3 -0
  62. package/dist/core/canonical-json.js +2 -1
  63. package/dist/core/checkpoint-requirements.d.ts +892 -0
  64. package/dist/core/checkpoint-requirements.js +333 -0
  65. package/dist/core/checkpoint-store.d.ts +94 -65
  66. package/dist/core/checkpoint-store.js +14 -26
  67. package/dist/core/child-clamp-seats.d.ts +228 -69
  68. package/dist/core/child-clamp-seats.js +211 -17
  69. package/dist/core/classifier-unavailable-arm.d.ts +5 -1
  70. package/dist/core/classifier-unavailable-arm.js +3 -3
  71. package/dist/core/compliance.d.ts +3 -0
  72. package/dist/core/compliance.js +9 -4
  73. package/dist/core/credential-vocabulary.d.ts +140 -0
  74. package/dist/core/credential-vocabulary.js +131 -0
  75. package/dist/core/decision-receipt.js +1 -1
  76. package/dist/core/effective-path-target.d.ts +73 -16
  77. package/dist/core/effective-path-target.js +63 -33
  78. package/dist/core/engine-notice.d.ts +43 -11
  79. package/dist/core/file-history-store.js +2 -2
  80. package/dist/core/fs-write-gate-policy.d.ts +4 -0
  81. package/dist/core/fs-write-gate-policy.js +22 -5
  82. package/dist/core/gate-bounded-await.d.ts +28 -13
  83. package/dist/core/gate-bounded-await.js +41 -4
  84. package/dist/core/gate-fold.d.ts +1 -1
  85. package/dist/core/gate-fold.js +24 -25
  86. package/dist/core/gate-lanes.js +16 -15
  87. package/dist/core/gate-outcome.d.ts +20 -5
  88. package/dist/core/gate-outcome.js +5 -0
  89. package/dist/core/governance-codes.d.ts +11 -4
  90. package/dist/core/governance-codes.js +14 -3
  91. package/dist/core/hooks.d.ts +21 -0
  92. package/dist/core/locked-config.d.ts +8 -0
  93. package/dist/core/locked-config.js +14 -2
  94. package/dist/core/lsp.js +3 -5
  95. package/dist/core/mailbox-store.d.ts +3 -4
  96. package/dist/core/mcp-connection-pool.d.ts +75 -0
  97. package/dist/core/mcp-connection-pool.js +128 -0
  98. package/dist/core/mcp-failure.d.ts +2 -1
  99. package/dist/core/mcp-failure.js +13 -2
  100. package/dist/core/mcp.d.ts +4 -0
  101. package/dist/core/mcp.js +70 -43
  102. package/dist/core/memory-engine/content-origin.js +2 -14
  103. package/dist/core/memory-engine/engine.d.ts +32 -22
  104. package/dist/core/memory-engine/engine.js +103 -55
  105. package/dist/core/memory-engine/file-backend.d.ts +13 -30
  106. package/dist/core/memory-engine/file-backend.js +37 -252
  107. package/dist/core/memory-engine/index.d.ts +1 -1
  108. package/dist/core/memory-engine/index.js +1 -1
  109. package/dist/core/memory-engine/layout.d.ts +139 -9
  110. package/dist/core/memory-engine/layout.js +350 -7
  111. package/dist/core/memory-engine/scope-contract.d.ts +10 -0
  112. package/dist/core/memory-engine/scope-contract.js +8 -0
  113. package/dist/core/memory-engine/session-incarnation.d.ts +14 -4
  114. package/dist/core/memory-engine/session-incarnation.js +5 -2
  115. package/dist/core/memory-engine/types.d.ts +10 -1
  116. package/dist/core/memory.js +5 -17
  117. package/dist/core/model-seat.d.ts +4 -4
  118. package/dist/core/model-seat.js +1 -1
  119. package/dist/core/mounted-mcp.d.ts +57 -0
  120. package/dist/core/mounted-mcp.js +19 -0
  121. package/dist/core/namespaced-rule-name.d.ts +29 -0
  122. package/dist/core/namespaced-rule-name.js +52 -0
  123. package/dist/core/park-selfcheck.d.ts +1 -1
  124. package/dist/core/park-selfcheck.js +16 -6
  125. package/dist/core/path-guard-rows.d.ts +99 -0
  126. package/dist/core/path-guard-rows.js +45 -0
  127. package/dist/core/path-identity.d.ts +22 -16
  128. package/dist/core/path-identity.js +10 -10
  129. package/dist/core/path-rule-binding.d.ts +2 -1
  130. package/dist/core/path-rule-binding.js +3 -1
  131. package/dist/core/pause-registry.d.ts +16 -2
  132. package/dist/core/pause-registry.js +6 -0
  133. package/dist/core/permission-rule-consent.js +0 -7
  134. package/dist/core/permission-rule-model.d.ts +68 -24
  135. package/dist/core/permission-rule-model.js +105 -24
  136. package/dist/core/permission-rule-store.js +2 -2
  137. package/dist/core/permission-rules.d.ts +3 -30
  138. package/dist/core/permission-rules.js +4 -54
  139. package/dist/core/read-root-candidate.d.ts +1 -3
  140. package/dist/core/read-root-candidate.js +4 -15
  141. package/dist/core/real-approval.d.ts +4 -3
  142. package/dist/core/retired-keys.d.ts +13 -0
  143. package/dist/core/retired-keys.js +14 -0
  144. package/dist/core/roles.d.ts +2 -3
  145. package/dist/core/roles.js +15 -6
  146. package/dist/core/runner/assemble-result.d.ts +0 -7
  147. package/dist/core/runner/assemble-result.js +19 -31
  148. package/dist/core/runner/caller-roster.d.ts +78 -0
  149. package/dist/core/runner/caller-roster.js +219 -0
  150. package/dist/core/runner/checkpoint-scope.d.ts +16 -16
  151. package/dist/core/runner/checkpoint-scope.js +2 -2
  152. package/dist/core/runner/child-tree.js +2 -2
  153. package/dist/core/runner/contracts.d.ts +68 -35
  154. package/dist/core/runner/decide-continuation.d.ts +51 -3
  155. package/dist/core/runner/decide-continuation.js +76 -21
  156. package/dist/core/runner/denial-limit-arms.d.ts +17 -5
  157. package/dist/core/runner/denial-limit-arms.js +11 -9
  158. package/dist/core/runner/extra-body-dropped-seat.d.ts +8 -0
  159. package/dist/core/runner/extra-body-dropped-seat.js +22 -0
  160. package/dist/core/runner/finish-reason-seat.d.ts +9 -0
  161. package/dist/core/runner/finish-reason-seat.js +40 -0
  162. package/dist/core/runner/gate-exit.d.ts +44 -32
  163. package/dist/core/runner/gate-exit.js +112 -25
  164. package/dist/core/runner/inherited-ask-grants.js +6 -4
  165. package/dist/core/runner/mcp-redial.d.ts +3 -3
  166. package/dist/core/runner/mcp-redial.js +3 -4
  167. package/dist/core/runner/permission-rule-lanes.d.ts +1 -2
  168. package/dist/core/runner/permission-rule-lanes.js +5 -4
  169. package/dist/core/runner/prepare-artifact.d.ts +4 -0
  170. package/dist/core/runner/prepare-artifact.js +2 -1
  171. package/dist/core/runner/prepare-ask-lane.d.ts +2 -0
  172. package/dist/core/runner/prepare-ask-lane.js +12 -6
  173. package/dist/core/runner/prepare-boundary-parks.d.ts +5 -8
  174. package/dist/core/runner/prepare-boundary-parks.js +4 -7
  175. package/dist/core/runner/prepare-caps-and-workflow.d.ts +11 -15
  176. package/dist/core/runner/prepare-caps-and-workflow.js +19 -27
  177. package/dist/core/runner/prepare-config-doors.d.ts +9 -9
  178. package/dist/core/runner/prepare-config-doors.js +10 -5
  179. package/dist/core/runner/prepare-defer-classify.d.ts +2 -2
  180. package/dist/core/runner/prepare-defer-classify.js +5 -3
  181. package/dist/core/runner/prepare-delegation-surface.d.ts +1 -1
  182. package/dist/core/runner/prepare-delegation-surface.js +3 -3
  183. package/dist/core/runner/prepare-gate-stations.d.ts +4 -4
  184. package/dist/core/runner/prepare-gate-stations.js +9 -7
  185. package/dist/core/runner/prepare-hands-readface.d.ts +7 -7
  186. package/dist/core/runner/prepare-hands-readface.js +7 -7
  187. package/dist/core/runner/prepare-inherited-gate.d.ts +7 -6
  188. package/dist/core/runner/prepare-inherited-gate.js +14 -15
  189. package/dist/core/runner/prepare-listings.d.ts +7 -24
  190. package/dist/core/runner/prepare-listings.js +4 -5
  191. package/dist/core/runner/prepare-memory-engine-session.d.ts +2 -0
  192. package/dist/core/runner/prepare-memory-engine-session.js +4 -3
  193. package/dist/core/runner/prepare-memory.d.ts +6 -0
  194. package/dist/core/runner/prepare-memory.js +13 -13
  195. package/dist/core/runner/prepare-offload-wrappers.d.ts +5 -0
  196. package/dist/core/runner/prepare-offload-wrappers.js +3 -3
  197. package/dist/core/runner/prepare-park-ask.d.ts +7 -8
  198. package/dist/core/runner/prepare-park-ask.js +17 -10
  199. package/dist/core/runner/prepare-policy-chain.js +24 -44
  200. package/dist/core/runner/prepare-project-context.d.ts +1 -1
  201. package/dist/core/runner/prepare-project-context.js +3 -4
  202. package/dist/core/runner/prepare-protocol-tools.d.ts +9 -3
  203. package/dist/core/runner/prepare-protocol-tools.js +3 -4
  204. package/dist/core/runner/prepare-run-refs.d.ts +3 -0
  205. package/dist/core/runner/prepare-run-refs.js +2 -1
  206. package/dist/core/runner/prepare-safety-scan.d.ts +4 -8
  207. package/dist/core/runner/prepare-safety-scan.js +1 -2
  208. package/dist/core/runner/prepare-suspend-saga.d.ts +7 -1
  209. package/dist/core/runner/prepare-suspend-saga.js +28 -12
  210. package/dist/core/runner/prepare-task.d.ts +1 -1
  211. package/dist/core/runner/prepare-task.js +67 -56
  212. package/dist/core/runner/prepare-wiring-manifest.d.ts +11 -10
  213. package/dist/core/runner/prepare-wiring-manifest.js +5 -8
  214. package/dist/core/runner/resume-apply.js +7 -14
  215. package/dist/core/runner/resume-checkpoint-screen.js +11 -4
  216. package/dist/core/runner/resume-internals-and-config.js +2 -2
  217. package/dist/core/runner/resume-policy-outcome.js +5 -32
  218. package/dist/core/runner/resume-review-outcome.js +4 -1
  219. package/dist/core/runner/retired-runner-deps.d.ts +6 -0
  220. package/dist/core/runner/retired-runner-deps.js +10 -1
  221. package/dist/core/runner/run-brain-sinks.d.ts +4 -0
  222. package/dist/core/runner/run-brain-sinks.js +5 -2
  223. package/dist/core/runner/run-harness-handlers.js +29 -36
  224. package/dist/core/runner/run-leg.d.ts +0 -2
  225. package/dist/core/runner/run-leg.js +32 -33
  226. package/dist/core/runner/run-terminal-adoption.js +4 -3
  227. package/dist/core/runner/runtask.js +8 -8
  228. package/dist/core/runner/session-rule-policy.js +5 -5
  229. package/dist/core/runner/stream-settle-backstop.js +7 -4
  230. package/dist/core/runner/sub-agent-deny-lists.d.ts +51 -12
  231. package/dist/core/runner/sub-agent-deny-lists.js +111 -80
  232. package/dist/core/runner/terminal-account.d.ts +48 -0
  233. package/dist/core/runner/terminal-account.js +186 -0
  234. package/dist/core/runner/tool-end-body.d.ts +54 -17
  235. package/dist/core/runner/tool-end-body.js +27 -2
  236. package/dist/core/runner/tool-face-overlay.d.ts +3 -1
  237. package/dist/core/runner/tool-face-overlay.js +6 -4
  238. package/dist/core/runner/tool-occurrence.d.ts +106 -0
  239. package/dist/core/runner/tool-occurrence.js +123 -0
  240. package/dist/core/runner/tool-progress-lane.d.ts +16 -8
  241. package/dist/core/runner/tool-progress-lane.js +25 -34
  242. package/dist/core/runner/tool-turn-repair-seat.d.ts +28 -4
  243. package/dist/core/runner/tool-turn-repair-seat.js +36 -13
  244. package/dist/core/runner/turn-attachments.d.ts +1 -1
  245. package/dist/core/runner/write-protection-station.d.ts +21 -9
  246. package/dist/core/runner/write-protection-station.js +20 -17
  247. package/dist/core/runner-deps.d.ts +12 -22
  248. package/dist/core/secret-env.d.ts +16 -5
  249. package/dist/core/secret-env.js +23 -63
  250. package/dist/core/sensitive-path-policy.d.ts +19 -18
  251. package/dist/core/sensitive-path-policy.js +73 -49
  252. package/dist/core/session-reconcile.d.ts +3 -0
  253. package/dist/core/session-reconcile.js +5 -4
  254. package/dist/core/session-store.d.ts +5 -0
  255. package/dist/core/session-store.js +12 -0
  256. package/dist/core/session.d.ts +13 -0
  257. package/dist/core/shared-memory/normalize.d.ts +17 -4
  258. package/dist/core/shared-memory/normalize.js +7 -7
  259. package/dist/core/shell-lexer.js +5 -4
  260. package/dist/core/shell-wrapper-projection.js +1 -1
  261. package/dist/core/skill-grant.js +1 -1
  262. package/dist/core/store-contracts/checkpoint-store-contract.js +13 -0
  263. package/dist/core/store-contracts/mailbox-store-contract.d.ts +7 -14
  264. package/dist/core/store-contracts/session-store-incarnation-contract.d.ts +27 -0
  265. package/dist/core/store-contracts/session-store-incarnation-contract.js +92 -0
  266. package/dist/core/stub-env.d.ts +2 -0
  267. package/dist/core/stub-env.js +1 -0
  268. package/dist/core/synthetic-read-verdict.js +2 -2
  269. package/dist/core/task-event.d.ts +59 -5
  270. package/dist/core/task-result.d.ts +1 -1
  271. package/dist/core/task-spec.d.ts +42 -9
  272. package/dist/core/terminal-cause.d.ts +94 -11
  273. package/dist/core/tighten-task-spec.d.ts +5 -4
  274. package/dist/core/tighten-task-spec.js +20 -25
  275. package/dist/core/tool-catalog-entries.d.ts +5 -7
  276. package/dist/core/tool-catalog-entries.js +14 -15
  277. package/dist/core/tool-face.d.ts +47 -0
  278. package/dist/core/tool-face.js +5 -0
  279. package/dist/core/tool-model-gate.d.ts +5 -5
  280. package/dist/core/tool-name-aliases.d.ts +26 -2
  281. package/dist/core/tool-name-aliases.js +13 -0
  282. package/dist/core/tool-name-list.d.ts +30 -0
  283. package/dist/core/tool-name-list.js +55 -0
  284. package/dist/core/tool-name-readings.d.ts +1 -9
  285. package/dist/core/tool-name-readings.js +1 -3
  286. package/dist/core/tool-policy.d.ts +195 -85
  287. package/dist/core/tool-policy.js +165 -380
  288. package/dist/core/tool-registry.d.ts +44 -1
  289. package/dist/core/tool-registry.js +26 -0
  290. package/dist/core/tool-roster.d.ts +19 -1
  291. package/dist/core/tool-roster.js +21 -2
  292. package/dist/core/tool-spec-members.d.ts +45 -0
  293. package/dist/core/tool-spec-members.js +169 -0
  294. package/dist/core/tool-spec.d.ts +46 -8
  295. package/dist/core/tools.d.ts +6 -2
  296. package/dist/core/tools.js +8 -4
  297. package/dist/core/untrusted-egress.js +29 -26
  298. package/dist/core/untrusted-text.d.ts +13 -10
  299. package/dist/core/untrusted-text.js +6 -44
  300. package/dist/core/workflow-journal-store.d.ts +4 -1
  301. package/dist/core/write-protect.d.ts +65 -29
  302. package/dist/core/write-protect.js +235 -177
  303. package/dist/engine/compaction/compaction.d.ts +2 -2
  304. package/dist/engine/execution-env/node-execution-env.d.ts +5 -23
  305. package/dist/engine/execution-env/node-execution-env.js +16 -38
  306. package/dist/engine/execution-env/symlink-chain.d.ts +23 -0
  307. package/dist/engine/execution-env/symlink-chain.js +32 -0
  308. package/dist/engine/harness/types.d.ts +7 -0
  309. package/dist/engine/llm/tool-turns.d.ts +3 -0
  310. package/dist/engine/llm/tool-turns.js +1 -0
  311. package/dist/engine/llm/types.d.ts +59 -23
  312. package/dist/engine/loop/agent-loop.js +16 -2
  313. package/dist/engine/session/memory-repo.js +11 -3
  314. package/dist/engine/session/repo-utils.d.ts +8 -0
  315. package/dist/engine/session/repo-utils.js +13 -0
  316. package/dist/index.d.ts +20 -23
  317. package/dist/index.js +17 -20
  318. package/dist/internal/harness.d.ts +1 -1
  319. package/dist/internal/harness.js +1 -1
  320. package/dist/internal/llm.d.ts +2 -2
  321. package/dist/internal/llm.js +1 -1
  322. package/dist/orchestration/governance-baseline-validity.js +1 -1
  323. package/dist/orchestration/run-spec.js +3 -3
  324. package/dist/orchestration/run-workflow-tool.d.ts +16 -35
  325. package/dist/orchestration/run-workflow-tool.js +38 -78
  326. package/dist/orchestration/workflow-governance.d.ts +21 -25
  327. package/dist/orchestration/workflow-governance.js +38 -78
  328. package/dist/orchestration/workflow-primitives.d.ts +7 -22
  329. package/dist/orchestration/workflow-primitives.js +5 -12
  330. package/dist/orchestration/workflow-types.d.ts +1 -1
  331. package/dist/orchestration/workflow.d.ts +61 -11
  332. package/dist/orchestration/workflow.js +189 -117
  333. package/dist/scenarios/full-body.d.ts +1 -1
  334. package/dist/shell/lex.d.ts +0 -21
  335. package/dist/shell/lex.js +250 -68
  336. package/dist/shell/shell-words.d.ts +35 -0
  337. package/dist/shell/shell-words.js +65 -0
  338. package/dist/stores/file/checkpoint-store.d.ts +5 -5
  339. package/dist/stores/file/checkpoint-store.js +5 -2
  340. package/dist/stores/file/index.d.ts +0 -8
  341. package/dist/stores/file/index.js +0 -12
  342. package/dist/stores/file/session-store.d.ts +3 -0
  343. package/dist/stores/file/session-store.js +44 -19
  344. package/dist/tools/artifact/artifact-tool.js +2 -0
  345. package/dist/tools/fs/bash-program-position.d.ts +12 -4
  346. package/dist/tools/fs/bash-program-position.js +32 -9
  347. package/dist/tools/fs/bash-readonly-classifier.d.ts +1 -1
  348. package/dist/tools/fs/bash-readonly-classifier.js +8 -7
  349. package/dist/tools/fs/containment-face.d.ts +4 -0
  350. package/dist/tools/fs/containment-face.js +3 -0
  351. package/dist/tools/fs/fs-shared.d.ts +10 -0
  352. package/dist/tools/fs/fs-shared.js +18 -0
  353. package/dist/tools/fs/fs-write.js +4 -2
  354. package/dist/tools/fs/index.d.ts +1 -1
  355. package/dist/tools/fs/program-read-model.d.ts +46 -20
  356. package/dist/tools/fs/program-read-model.js +50 -20
  357. package/dist/tools/fs/program-read-model.rows.d.ts +0 -14
  358. package/dist/tools/fs/program-read-model.rows.js +16 -15
  359. package/dist/tools/fs/read-deny-home.d.ts +33 -47
  360. package/dist/tools/fs/read-deny-home.js +35 -49
  361. package/dist/tools/fs/read-deny.d.ts +23 -22
  362. package/dist/tools/fs/read-deny.js +114 -89
  363. package/dist/tools/fs/removal-targets.d.ts +56 -23
  364. package/dist/tools/fs/removal-targets.js +65 -87
  365. package/dist/tools/fs/safety.d.ts +29 -22
  366. package/dist/tools/fs/safety.js +17 -11
  367. package/dist/tools/fs/search.js +10 -8
  368. package/dist/tools/fs/shell-read-argv.js +1 -1
  369. package/dist/tools/fs/shell-read-bindings.d.ts +169 -37
  370. package/dist/tools/fs/shell-read-bindings.js +324 -86
  371. package/dist/tools/fs/shell-read-builtins.d.ts +35 -0
  372. package/dist/tools/fs/shell-read-builtins.js +43 -0
  373. package/dist/tools/fs/shell-read-check.d.ts +15 -1
  374. package/dist/tools/fs/shell-read-check.js +67 -43
  375. package/dist/tools/fs/shell-read-establish.js +6 -6
  376. package/dist/tools/fs/shell-read-functions.d.ts +22 -0
  377. package/dist/tools/fs/shell-read-functions.js +29 -0
  378. package/dist/tools/fs/shell-read-judge.d.ts +51 -18
  379. package/dist/tools/fs/shell-read-judge.js +40 -4
  380. package/dist/tools/fs/shell-read-plan.d.ts +12 -6
  381. package/dist/tools/fs/shell-read-plan.js +118 -113
  382. package/dist/tools/fs/shell-read-start.d.ts +29 -6
  383. package/dist/tools/fs/shell-read-start.js +16 -9
  384. package/dist/tools/fs/shell-read-word.js +4 -0
  385. package/dist/tools/fs/shell-read-workdir.d.ts +156 -0
  386. package/dist/tools/fs/shell-read-workdir.js +281 -0
  387. package/dist/tools/fs/shell-read-write-targets.d.ts +5 -2
  388. package/dist/tools/fs/shell-read-write-targets.js +14 -5
  389. package/dist/tools/fs/shell-reentry-text.d.ts +4 -6
  390. package/dist/tools/fs/shell-reentry-text.js +3 -11
  391. package/dist/tools/task-list.d.ts +1 -2
  392. package/dist/tools/web.js +1 -1
  393. package/package.json +4 -1
  394. package/test/export-surface.snapshot.json +107 -143
  395. package/wire-changes/core@7.49.0.json +4765 -0
  396. package/dist/agents/teacher.d.ts +0 -159
  397. package/dist/agents/teacher.js +0 -577
  398. package/dist/agents/team.d.ts +0 -226
  399. package/dist/agents/team.js +0 -257
  400. package/dist/core/strategy-store.d.ts +0 -238
  401. package/dist/core/strategy-store.js +0 -253
  402. package/dist/orchestration/builtin-workflows.d.ts +0 -133
  403. package/dist/orchestration/builtin-workflows.js +0 -159
  404. package/dist/scenarios/env.d.ts +0 -40
  405. package/dist/scenarios/env.js +0 -39
  406. package/dist/scenarios/scenario-registry.d.ts +0 -110
  407. package/dist/scenarios/scenario-registry.js +0 -140
  408. package/dist/scenarios/teacher-quickstart.d.ts +0 -40
  409. package/dist/scenarios/teacher-quickstart.js +0 -12
  410. package/dist/stores/cc/lockfile.d.ts +0 -10
  411. package/dist/stores/cc/lockfile.js +0 -98
  412. package/dist/stores/cc/mailbox-store.d.ts +0 -20
  413. package/dist/stores/cc/mailbox-store.js +0 -255
  414. package/dist/stores/cc/roster-adapter.d.ts +0 -12
  415. package/dist/stores/cc/roster-adapter.js +0 -117
  416. package/dist/stores/cc/sidecar-transcript.d.ts +0 -97
  417. package/dist/stores/cc/sidecar-transcript.js +0 -264
  418. package/dist/stores/cc/task-list-store.d.ts +0 -2
  419. package/dist/stores/cc/task-list-store.js +0 -125
  420. package/dist/stores/file/strategy-store.d.ts +0 -97
  421. package/dist/stores/file/strategy-store.js +0 -341
@@ -1,5 +1,6 @@
1
1
  import { combinePolicies } from "./tool-policy.js";
2
2
  import { clampPermissionMode } from "./ask-origin.js";
3
+ import { CLAMP_SEATS, composeClampSeat, loosensClampSeat } from "./child-clamp-seats.js";
3
4
  export class TaskSpecTightenError extends Error {
4
5
  constructor(message) {
5
6
  super(message);
@@ -21,34 +22,28 @@ export function tightenTaskSpec(base, overrides) {
21
22
  merged[field] = [...new Set([...(b ?? []), ...(o ?? [])])];
22
23
  }
23
24
  }
24
- for (const faceKey of ["readFace", "writeFace"]) {
25
- if (base[faceKey] === "roots" && overrides[faceKey] === "open") {
26
- throw new TaskSpecTightenError(`tightenTaskSpec: cannot loosen ${faceKey} from "roots" to "open" (override may only tighten)`);
27
- }
28
- if (base[faceKey] !== undefined || overrides[faceKey] !== undefined) {
29
- merged[faceKey] = base[faceKey] === "roots" || overrides[faceKey] === "roots" ? "roots" : (overrides[faceKey] ?? base[faceKey]);
25
+ {
26
+ const b = base.allowTools;
27
+ const o = overrides.allowTools;
28
+ if (b !== undefined && o !== undefined && !b.includes("*")) {
29
+ const wider = o.filter((entry) => !b.includes(entry));
30
+ if (wider.length > 0)
31
+ throw new TaskSpecTightenError(`tightenTaskSpec: cannot widen allowTools beyond the base list (override names ${JSON.stringify(wider)}; the override may only narrow)`);
30
32
  }
33
+ const kept = o ?? b;
34
+ if (kept !== undefined)
35
+ merged.allowTools = [...kept];
36
+ else
37
+ delete merged.allowTools;
31
38
  }
32
- if (base.readDenyPatterns !== undefined || overrides.readDenyPatterns !== undefined) {
33
- const seen = new Set();
34
- const union = [];
35
- for (const e of [...(base.readDenyPatterns ?? []), ...(overrides.readDenyPatterns ?? [])]) {
36
- const key = typeof e === "string" ? `i:${e}` : `${e.caseSensitive === true ? "s" : "i"}:${e.pattern}`;
37
- if (seen.has(key))
38
- continue;
39
- seen.add(key);
40
- union.push(e);
39
+ for (const seat of CLAMP_SEATS) {
40
+ const b = base[seat];
41
+ const o = overrides[seat];
42
+ if (loosensClampSeat(seat, b, o)) {
43
+ throw new TaskSpecTightenError(`tightenTaskSpec: cannot loosen ${seat} from ${JSON.stringify(b)} to ${JSON.stringify(o)} (override may only tighten)`);
41
44
  }
42
- merged.readDenyPatterns = union;
43
- }
44
- if (base.handsReadOnly === true && overrides.handsReadOnly === false) {
45
- throw new TaskSpecTightenError("tightenTaskSpec: cannot loosen handsReadOnly from true to false (override may only tighten)");
46
- }
47
- if (base.handsReadOnly !== undefined || overrides.handsReadOnly !== undefined) {
48
- merged.handsReadOnly = base.handsReadOnly === true || overrides.handsReadOnly === true;
49
- }
50
- if (base.approvalReach !== undefined || overrides.approvalReach !== undefined) {
51
- merged.approvalReach = base.approvalReach === "none" || overrides.approvalReach === "none" ? "none" : (overrides.approvalReach ?? base.approvalReach);
45
+ if (b !== undefined || o !== undefined)
46
+ Object.assign(merged, { [seat]: composeClampSeat(seat, b, o) });
52
47
  }
53
48
  if (base.permissionMode !== undefined && overrides.permissionMode !== undefined) {
54
49
  const { effective, clamped } = clampPermissionMode(overrides.permissionMode, base.permissionMode);
@@ -55,16 +55,14 @@ export declare const TOOL_FACES: Readonly<Record<string, ToolFaceDeclaration>>;
55
55
  */
56
56
  export declare const ENGINE_BUILTIN_TOOL_NAMES: readonly string[];
57
57
  /**
58
- * The engine's HAND tools, once each, with the other spellings they answer to: the catalog rows mounted by `hands` — what a run
59
- * mounts for itself over an execution environment (the file and shell band, the worktree pair, the band's background-shell
60
- * pair). A delegated child's tool-name lists govern these beside the tools the delegation tool hands it, so the spawn reads
61
- * this set rather than a list of its own.
58
+ * EVERY tool the catalog describes, once per wire name, with the other spellings it answers to — the engine's side of the one
59
+ * universe a delegated child's tool-name lists govern (beside the tools the delegation tool hands it and the protocol tools
60
+ * its spawning run mounts). The spawn reads this set rather than a list of its own: a definition a catalog row adds later is
61
+ * governed the day it lands, whatever band mounts it.
62
62
  */
63
- export declare const HAND_TOOLS: ReadonlyArray<{
63
+ export declare const ENGINE_TOOLS: ReadonlyArray<{
64
64
  readonly name: string;
65
65
  readonly aliases?: readonly string[];
66
66
  }>;
67
- /** The wire names of {@link HAND_TOOLS}. */
68
- export declare const HAND_TOOL_NAMES: readonly string[];
69
67
  /** Is this name one the engine mounts itself ({@link ENGINE_BUILTIN_TOOL_NAMES})? A caller tool, an MCP tool or a skill tool is not. */
70
68
  export declare function isEngineBuiltinToolName(name: string): boolean;
@@ -110,14 +110,14 @@ export const TOOL_CATALOG_ENTRIES = [
110
110
  { id: "task-output", name: "TaskOutput", source: "builtin", definedIn: "src/core/task-registry.ts", mountedBy: ["delegation"], cards: ["task-output"], face: { family: "delegate", effect: "read", contract: TASK_OUTPUT_CONTRACT } },
111
111
  { id: "task-stop", name: "TaskStop", source: "builtin", definedIn: "src/core/task-registry.ts", mountedBy: ["delegation"], cards: ["task-stop"], face: { family: "delegate", effect: "write", contract: TASK_STOP_CONTRACT } },
112
112
  { id: "monitor", name: "Monitor", source: "builtin", definedIn: "src/tools/monitor.ts", mountedBy: ["backgroundTasks"], cards: ["monitor-start", "readonly_out_of_root", "read_unestablished"], face: { family: "other", effect: "write", contract: c("core.monitor@1"), ruleFace: shellRuleFace(["command", "description", "timeout_ms", "persistent"]), offloadThresholdChars: 10_000 } },
113
- { id: "send-message", name: "SendMessage", source: "builtin", definedIn: "src/agents/send-message-tool.ts", mountedBy: ["delegation", "hostInternals", "peerLane"], cards: ["send-message"], face: { family: "protocol", effect: "write", contract: c("core.send_message@1") } },
113
+ { id: "send-message", name: "SendMessage", protocol: ["teammate"], source: "builtin", definedIn: "src/agents/send-message-tool.ts", mountedBy: ["delegation", "hostInternals", "peerLane"], cards: ["send-message"], face: { family: "protocol", effect: "write", contract: c("core.send_message@1") } },
114
114
  { id: "agent-transcript", name: "AgentTranscript", source: "builtin", definedIn: "src/agents/agent-transcript-tool.ts", mountedBy: ["delegation"], cards: ["agent-transcript"], face: { family: "delegate", effect: "read", contract: c("core.agent_transcript@1") } },
115
115
  { id: "list-agents", name: "ListAgents", source: "builtin", definedIn: "src/agents/list-agents-tool.ts", mountedBy: ["delegation", "peerLane"], cards: ["list-agents"], face: { family: "protocol", effect: "read", aliases: ["ListPeers"], contract: c("core.list_agents@1") } },
116
116
  { id: "read-inbox", name: "ReadInbox", source: "builtin", definedIn: "src/agents/read-inbox-tool.ts", mountedBy: ["peerLane"], cards: ["read-inbox"], face: { family: "protocol", effect: "read", contract: c("core.read_inbox@1"), offload: false, budgetExempt: true } },
117
117
  { id: "workflow", name: "Workflow", source: "builtin", definedIn: "src/orchestration/run-workflow-tool.ts", mountedBy: ["workflow"], cards: ["workflow-run"], face: { family: "delegate", effect: "write", contract: c("core.workflow@1") } },
118
- { id: "report-blocked", name: "ReportBlocked", source: "builtin", definedIn: "src/core/runner/synthetic-tools.ts", mountedBy: ["always"], cards: [], face: { family: "scaffold", effect: "read", contract: c("core.report_blocked@1") } },
118
+ { id: "report-blocked", name: "ReportBlocked", protocol: ["delegated"], source: "builtin", definedIn: "src/core/runner/synthetic-tools.ts", mountedBy: ["always"], cards: [], face: { family: "scaffold", effect: "read", contract: c("core.report_blocked@1") } },
119
119
  { id: "report-findings", name: "ReportFindings", source: "builtin", definedIn: "src/core/runner/synthetic-tools.ts", mountedBy: ["always"], cards: ["report-findings"], face: { family: "scaffold", effect: "read", contract: c("core.report_findings@1") } },
120
- { id: "structured-output", name: "StructuredOutput", source: "synthetic", definedIn: "src/core/runner/synthetic-tools.ts", mountedBy: ["optional"], cards: [], face: { family: "scaffold", effect: "read", contract: c("core.structured_output@1") } },
120
+ { id: "structured-output", name: "StructuredOutput", protocol: ["structured"], source: "synthetic", definedIn: "src/core/runner/synthetic-tools.ts", mountedBy: ["optional"], cards: [], face: { family: "scaffold", effect: "read", contract: c("core.structured_output@1") } },
121
121
  { id: "skill", name: "Skill", source: "builtin", definedIn: "src/core/runner/synthetic-tools.ts", mountedBy: ["optional"], cards: [], face: { family: "scaffold", effect: "read", contract: c("core.skill@1") } },
122
122
  { id: "read-tool-result", name: "ReadToolResult", source: "builtin", definedIn: "src/core/tool-result-store.ts", mountedBy: ["optional"], cards: [], face: { family: "scaffold", effect: "read", contract: c("core.read_tool_result@1"), budgetExempt: true } },
123
123
  { id: "tool-search", name: "ToolSearch", source: "builtin", definedIn: "src/core/runner/tool-disclosure.ts", mountedBy: ["optional"], cards: ["tool-search"], face: { family: "scaffold", effect: "read", contract: c("core.tool_search@1") } },
@@ -130,9 +130,9 @@ export const TOOL_CATALOG_ENTRIES = [
130
130
  { id: "memory-index", name: "memory_index", source: "builtin", definedIn: "src/core/memory-engine/tools.ts", mountedBy: ["memory"], cards: [], face: { family: "memory", effect: "read", contentOrigin: "local", contract: c("core.memory_index@1", "2"), offload: false } },
131
131
  { id: "memory-list", name: "memory_list", source: "builtin", definedIn: "src/core/shared-memory/tools.ts", mountedBy: ["memory"], cards: [], face: { family: "memory", effect: "read", contract: c("core.memory_list@1"), offload: false } },
132
132
  { id: "memory-read", name: "memory_read", source: "builtin", definedIn: "src/core/shared-memory/tools.ts", mountedBy: ["memory"], cards: [], face: { family: "memory", effect: "read", contract: c("core.memory_read@1"), offload: false } },
133
- { id: "cron-create", name: "CronCreate", source: "builtin", definedIn: "src/tools/scheduler-tools.ts", mountedBy: ["scheduler"], cards: ["cron-create"], face: { family: "other", effect: "write", contract: c("core.cron_create@1") } },
134
- { id: "cron-delete", name: "CronDelete", source: "builtin", definedIn: "src/tools/scheduler-tools.ts", mountedBy: ["scheduler"], cards: ["cron-delete"], face: { family: "other", effect: "idempotent", contract: c("core.cron_delete@1") } },
135
- { id: "cron-list", name: "CronList", source: "builtin", definedIn: "src/tools/scheduler-tools.ts", mountedBy: ["scheduler"], cards: ["cron-list"], face: { family: "other", effect: "read", contract: c("core.cron_list@1") } },
133
+ { id: "cron-create", name: "CronCreate", protocol: ["teammate"], source: "builtin", definedIn: "src/tools/scheduler-tools.ts", mountedBy: ["scheduler"], cards: ["cron-create"], face: { family: "other", effect: "write", contract: c("core.cron_create@1") } },
134
+ { id: "cron-delete", name: "CronDelete", protocol: ["teammate"], source: "builtin", definedIn: "src/tools/scheduler-tools.ts", mountedBy: ["scheduler"], cards: ["cron-delete"], face: { family: "other", effect: "idempotent", contract: c("core.cron_delete@1") } },
135
+ { id: "cron-list", name: "CronList", protocol: ["teammate"], source: "builtin", definedIn: "src/tools/scheduler-tools.ts", mountedBy: ["scheduler"], cards: ["cron-list"], face: { family: "other", effect: "read", contract: c("core.cron_list@1") } },
136
136
  { id: "schedule-wakeup", name: "ScheduleWakeup", source: "builtin", definedIn: "src/tools/scheduler-tools.ts", mountedBy: ["scheduler"], cards: ["schedule-wakeup"], face: { family: "other", effect: "write", contract: c("core.schedule_wakeup@1") } },
137
137
  {
138
138
  id: "web-fetch", name: "WebFetch", source: "builtin", definedIn: "src/tools/web.ts", mountedBy: ["scenario"], cards: ["web-fetch"],
@@ -143,13 +143,13 @@ export const TOOL_CATALOG_ENTRIES = [
143
143
  face: { family: "web", effect: "read", contentOrigin: "external", contract: c("core.web_search@1"), ruleFace: { primaryParams: ["query"] }, renderHints: { summaryParams: ["query"] }, compactable: true },
144
144
  },
145
145
  { id: "todo-write", name: TODO_WRITE_TOOL_NAME, source: "builtin", definedIn: "src/tools/todo.ts", mountedBy: ["scenario"], cards: ["todo"], modelGate: "task-scaffold", face: { family: "plan", effect: "idempotent", contract: c("core.todo_write@1") } },
146
- { id: "task-create", name: TASK_CREATE_TOOL_NAME, source: "builtin", definedIn: "src/tools/task-list.ts", mountedBy: ["scenario"], cards: ["task"], modelGate: "task-scaffold", face: { family: "plan", effect: "write", contract: c("core.task_create@1") } },
147
- { id: "task-get", name: TASK_GET_TOOL_NAME, source: "builtin", definedIn: "src/tools/task-list.ts", mountedBy: ["scenario"], cards: ["task"], modelGate: "task-scaffold", face: { family: "plan", effect: "read", contract: c("core.task_get@1") } },
148
- { id: "task-update", name: TASK_UPDATE_TOOL_NAME, source: "builtin", definedIn: "src/tools/task-list.ts", mountedBy: ["scenario"], cards: ["task"], modelGate: "task-scaffold", face: { family: "plan", effect: "idempotent", contract: c("core.task_update@1") } },
149
- { id: "task-list", name: TASK_LIST_TOOL_NAME, source: "builtin", definedIn: "src/tools/task-list.ts", mountedBy: ["scenario"], cards: ["task-list"], modelGate: "task-scaffold", face: { family: "plan", effect: "read", contract: c("core.task_list@1") } },
146
+ { id: "task-create", name: TASK_CREATE_TOOL_NAME, protocol: ["teammate"], protocolUnderCeiling: true, source: "builtin", definedIn: "src/tools/task-list.ts", mountedBy: ["scenario"], cards: ["task"], modelGate: "task-scaffold", face: { family: "plan", effect: "write", contract: c("core.task_create@1") } },
147
+ { id: "task-get", name: TASK_GET_TOOL_NAME, protocol: ["teammate"], protocolUnderCeiling: true, source: "builtin", definedIn: "src/tools/task-list.ts", mountedBy: ["scenario"], cards: ["task"], modelGate: "task-scaffold", face: { family: "plan", effect: "read", contract: c("core.task_get@1") } },
148
+ { id: "task-update", name: TASK_UPDATE_TOOL_NAME, protocol: ["teammate"], protocolUnderCeiling: true, source: "builtin", definedIn: "src/tools/task-list.ts", mountedBy: ["scenario"], cards: ["task"], modelGate: "task-scaffold", face: { family: "plan", effect: "idempotent", contract: c("core.task_update@1") } },
149
+ { id: "task-list", name: TASK_LIST_TOOL_NAME, protocol: ["teammate"], protocolUnderCeiling: true, source: "builtin", definedIn: "src/tools/task-list.ts", mountedBy: ["scenario"], cards: ["task-list"], modelGate: "task-scaffold", face: { family: "plan", effect: "read", contract: c("core.task_list@1") } },
150
150
  { id: "agent", name: "Agent", source: "builtin", definedIn: "src/agents/subagent.ts", mountedBy: ["scenario"], cards: ["agent", "fork"], face: { family: "delegate", contentOrigin: "local", contract: c("core.agent@1") } },
151
- { id: "observer-report", name: "ObserverReport", source: "builtin", definedIn: "src/agents/observer.ts", mountedBy: ["scenario"], cards: [], face: { family: "scaffold", effect: "write", contract: c("core.observer_report@1") } },
152
- { id: "declare-done", name: "DeclareDone", source: "builtin", definedIn: "src/orchestration/goal.ts", mountedBy: ["scenario"], cards: [], face: { family: "scaffold", effect: "read" } },
151
+ { id: "observer-report", name: "ObserverReport", protocol: ["observer"], source: "builtin", definedIn: "src/agents/observer.ts", mountedBy: ["scenario"], cards: [], face: { family: "scaffold", effect: "write", contract: c("core.observer_report@1") } },
152
+ { id: "declare-done", name: "DeclareDone", protocol: ["goal"], source: "builtin", definedIn: "src/orchestration/goal.ts", mountedBy: ["scenario"], cards: [], face: { family: "scaffold", effect: "read" } },
153
153
  ];
154
154
  export const ENGINE_CARDS = Object.freeze({
155
155
  mcp: "src/core/mcp.ts",
@@ -182,11 +182,10 @@ function deepFreeze(value) {
182
182
  deepFreeze(TOOL_CATALOG_ENTRIES);
183
183
  export const TOOL_FACES = Object.freeze(Object.fromEntries(TOOL_CATALOG_ENTRIES.map((e) => [e.id, e.face])));
184
184
  export const ENGINE_BUILTIN_TOOL_NAMES = Object.freeze([...new Set(TOOL_CATALOG_ENTRIES.filter((e) => e.source === "builtin").map((e) => e.name))]);
185
- export const HAND_TOOLS = Object.freeze([...new Set(TOOL_CATALOG_ENTRIES.filter((e) => e.mountedBy.includes("hands")).map((e) => e.name))].map((name) => {
186
- const aliases = [...new Set(TOOL_CATALOG_ENTRIES.filter((e) => e.name === name && e.mountedBy.includes("hands")).flatMap((e) => e.face.aliases ?? []))];
185
+ export const ENGINE_TOOLS = Object.freeze([...new Set(TOOL_CATALOG_ENTRIES.map((e) => e.name))].map((name) => {
186
+ const aliases = [...new Set(TOOL_CATALOG_ENTRIES.filter((e) => e.name === name).flatMap((e) => e.face.aliases ?? []))];
187
187
  return Object.freeze(aliases.length > 0 ? { name, aliases: Object.freeze(aliases) } : { name });
188
188
  }));
189
- export const HAND_TOOL_NAMES = Object.freeze(HAND_TOOLS.map((t) => t.name));
190
189
  export function isEngineBuiltinToolName(name) {
191
190
  return ENGINE_BUILTIN_TOOL_NAMES.includes(name);
192
191
  }
@@ -42,6 +42,12 @@ import type { AssertAllKeysHandled } from "./ask-origin.js";
42
42
  * mounting the card (design/388 §2.5 boundary ①). */
43
43
  export declare const TOOL_APPROVAL_CARDS: readonly ["file-edit", "file-write", "notebook-edit", "shell", "fetch", "plan", "question", "generic"];
44
44
  export type ToolApprovalCard = (typeof TOOL_APPROVAL_CARDS)[number];
45
+ /** Membership in the closed set — the one screen a stored or declared card word passes before it is read. */
46
+ export declare function isToolApprovalCard(word: unknown): word is ToolApprovalCard;
47
+ /** The cards only an engine-defined tool owns: a caller or protocol tool cannot declare one, and the card is minted
48
+ * from the engine's own judgment of the call, never from a row's declaration. */
49
+ export declare const RESERVED_APPROVAL_CARDS: readonly ["question", "plan"];
50
+ export type ReservedApprovalCard = (typeof RESERVED_APPROVAL_CARDS)[number];
45
51
  /** How a path-targeting tool touches its target. `read` never enters a write-confinement face. */
46
52
  export declare const TOOL_PATH_ACCESSES: readonly ["read", "create", "edit"];
47
53
  export type ToolPathAccess = (typeof TOOL_PATH_ACCESSES)[number];
@@ -182,6 +188,7 @@ export interface ToolRenderHints {
182
188
  activity?: string;
183
189
  summaryParams?: readonly string[];
184
190
  resultCards?: readonly string[];
191
+ /** The card family this tool asks under; absent reads `generic`. `question` / `plan` are the engine's own tools' cards — a declaration of either is refused. */
185
192
  approvalCard?: ToolApprovalCard;
186
193
  }
187
194
  /**
@@ -217,6 +224,39 @@ export interface ToolFaceDeclaration {
217
224
  compactable?: true;
218
225
  budgetExempt?: true;
219
226
  }
227
+ /**
228
+ * The kinds of leg a run can be, as far as which tools a leg itself relies on: a delegated child (every lane a delegation
229
+ * tool, a workflow or a team spawns), a NAMED delegated child (a teammate), an iteration of a goal loop, an observer sidecar,
230
+ * a run with an output schema (it finishes by submitting through the structured-output tool). A catalog row's
231
+ * {@link ToolCatalogEntry.protocol} names the kinds whose legs carry that tool as part of their protocol.
232
+ */
233
+ export declare const TOOL_LEG_KINDS: readonly ["delegated", "teammate", "goal", "observer", "structured"];
234
+ export type ToolLegKind = (typeof TOOL_LEG_KINDS)[number];
235
+ /**
236
+ * One layer of a tool selector, as data: an allowed-tools list (absent = no allowlist on this layer) and a denied-tools list,
237
+ * each a frozen copy of the entries a list was written with. A run's own layer is its `allowTools` and `excludeTools`; the
238
+ * layers above it are the ones the run that spawned it was bounded by, plus that run's own.
239
+ */
240
+ export interface ToolSelectorLayer {
241
+ readonly allow?: readonly string[];
242
+ readonly deny: readonly string[];
243
+ }
244
+ /**
245
+ * The compiled tool selector of one run — the one answer to "is this tool available on this run", read at the roster valve
246
+ * and on every later roster change (an MCP refresh or re-dial, the deferred-search lane), and handed down as the ceiling of
247
+ * every run this one spawns (`layers`). A tool is admitted when it is a protocol tool of this run's leg kind, or when every
248
+ * layer admits it: the layer's allowlist (if any) reaches it and its denylist does not.
249
+ */
250
+ export interface ToolSelector {
251
+ readonly layers: readonly ToolSelectorLayer[];
252
+ admits(tool: {
253
+ readonly name: string;
254
+ readonly aliases?: readonly string[];
255
+ }): boolean;
256
+ /** Can ANY tool of the protocol peer whose minted prefix is `prefix` (`mcp__srv__`) be admitted — read off the lists alone,
257
+ * never off what the peer lists now, so a tool the peer lists later is judged by the same answer. */
258
+ admitsPeer(prefix: string): boolean;
259
+ }
220
260
  /**
221
261
  * One row of the static tool catalog (design/388 §2.1 "静态目录"). Keyed by DEFINITION identity, not by
222
262
  * name: two definitions may share a wire name (the full and the read-only shell both answer to `Bash`),
@@ -240,6 +280,13 @@ export interface ToolCatalogEntry {
240
280
  face: ToolFaceDeclaration;
241
281
  /** A `modelGate` class the default-bundle assembler stamps on this definition's default arm. */
242
282
  modelGate?: string;
283
+ /** The leg kinds whose legs rely on this tool as part of their protocol: on such a leg the tool's availability is not a
284
+ * selector's to decide (an allowlist need not name it), and a denylist that reaches it there is a contradiction the run
285
+ * refuses at prepare. */
286
+ protocol?: readonly ToolLegKind[];
287
+ /** A protocol row the leg shares with the run that spawned it (the team task-list family a teammate shares with its leader): on its
288
+ * leg the leg's OWN lists do not decide it, but the ceiling still does — the leg holds it exactly when its spawner may. */
289
+ protocolUnderCeiling?: true;
243
290
  }
244
291
  /**
245
292
  * The band-membership table over the mount tags: a host derives its hand band as the definitions listed under a
@@ -1,6 +1,10 @@
1
1
  export const TOOL_FAMILIES = Object.freeze(["shell", "file-read", "file-write", "search", "web", "delegate", "plan", "scaffold", "memory", "protocol", "other"]);
2
2
  export const TOOL_MOUNT_TAGS = Object.freeze(["hands", "backgroundTasks", "workflow", "delegation", "hostInternals", "peerLane", "scheduler", "memory", "scenario", "always", "optional"]);
3
3
  export const TOOL_APPROVAL_CARDS = Object.freeze(["file-edit", "file-write", "notebook-edit", "shell", "fetch", "plan", "question", "generic"]);
4
+ export function isToolApprovalCard(word) {
5
+ return typeof word === "string" && TOOL_APPROVAL_CARDS.includes(word);
6
+ }
7
+ export const RESERVED_APPROVAL_CARDS = Object.freeze(["question", "plan"]);
4
8
  export const TOOL_PATH_ACCESSES = Object.freeze(["read", "create", "edit"]);
5
9
  export const TOOL_PATH_BASES = Object.freeze(["cwd", "root"]);
6
10
  export const TOOL_PATH_ABSENCES = Object.freeze(["none", "base"]);
@@ -20,6 +24,7 @@ export const TOOL_KEYS_MAX = 1024;
20
24
  export const RENDER_HINT_MAX_CHARS = 64;
21
25
  export const RENDER_HINT_ACTIVITY_MAX_CHARS = 32;
22
26
  export const RENDER_HINT_MAX_LIST = 16;
27
+ export const TOOL_LEG_KINDS = Object.freeze(["delegated", "teammate", "goal", "observer", "structured"]);
23
28
  export const MOUNT_TAG_IN_HANDS_BAND = {
24
29
  hands: true,
25
30
  backgroundTasks: true,
@@ -76,12 +76,12 @@ export declare function isModelGatedForClass(modelId: string, rule: ToolModelGat
76
76
  export declare function assertRestoreGatedToolsValue(value: unknown): asserts value is true | readonly string[] | undefined;
77
77
  /** Doors-facing decision (built + applied inside `prepareConfigDoors`' synchronous stretch —
78
78
  * decision and application share one atomic window, no drift gap). */
79
- export interface ToolModelGateDecision {
79
+ export interface ToolModelGateDecision<T extends ToolSpec = ToolSpec> {
80
80
  /** Present ⇔ at least one entry was removed: the fresh, PRIVATE survivor array `spec.tools` is
81
81
  * rebound to (a caller mutating its original live array afterwards can neither re-add a removed
82
82
  * entry nor displace anything — there are no indices left to misalign). `undefined` = no
83
83
  * removal, the spec is left untouched. */
84
- survivors: ToolSpec[] | undefined;
84
+ survivors: T[] | undefined;
85
85
  /** gate-class → removed wire names (sorted, unique) — the removal-notice payload. */
86
86
  removedByClass: ReadonlyMap<string, readonly string[]>;
87
87
  /** Stamped classes with no row in the merged table — announce-once material (the loud half of
@@ -116,10 +116,10 @@ export interface ToolModelGateDecision {
116
116
  * - the exclusion valve (`excludeTools`, applied downstream at the roster splice) ALWAYS wins in
117
117
  * the result: no restore channel resurrects an excluded name.
118
118
  */
119
- export declare function applyToolModelGate(input: {
120
- tools: ReadonlyArray<ToolSpec> | undefined;
119
+ export declare function applyToolModelGate<T extends ToolSpec>(input: {
120
+ tools: ReadonlyArray<T> | undefined;
121
121
  modelId: string;
122
122
  depsSeat: unknown;
123
123
  restoreGated: true | readonly string[] | undefined;
124
124
  envRaw: string | undefined;
125
- }): ToolModelGateDecision;
125
+ }): ToolModelGateDecision<T>;
@@ -10,8 +10,9 @@ import { type ProtocolNamespace } from "./protocol-table.js";
10
10
  * rather than carried.
11
11
  * - `canonicalToolName` is gone with it: with the mapping cleared it was the identity function, and
12
12
  * keeping an identity shim invites the next mapping to grow back silently.
13
- * - `TOMBSTONED_TOOLS` (per-name re-education messages) is gone: a retired name now gets the same
14
- * loud generic roster miss as any unknown tool.
13
+ * - `TOMBSTONED_TOOLS` (a second table of per-name re-education prose) is gone. A CALL to a retired name is
14
+ * told what the one table here says about it ({@link judgeToolNameMiss}): the miss is `expected-absent`
15
+ * with the successor, where any other unknown name stays the generic roster miss.
15
16
  *
16
17
  * What REMAINS is validation data: {@link RETIRED_TOOL_NAMES} maps every name the engine ever
17
18
  * retired to a one-line guidance string, and {@link judgeRuleToolName} is the ONE reading of it a rule's
@@ -78,8 +79,31 @@ export declare function splitNamespacedName(name: string): {
78
79
  } | undefined;
79
80
  /** See {@link RuleToolNameVerdict}. Pure; the one answer to "is this rule's tool name a name that reaches no tool". */
80
81
  export declare function judgeRuleToolName(name: string, roster: ReadonlySet<string>): RuleToolNameVerdict;
82
+ /** The two kinds of tool-name miss — a closed set. `unknown`: the name is none the engine ever mounted (a typo, a
83
+ * guess). `expected-absent`: the name is one the engine RETIRED ({@link RETIRED_TOOL_NAMES}), so its absence is no
84
+ * surprise and the table says what replaced it (CC 2.1.296 spells the same two words for its render-time miss). */
85
+ export declare const TOOL_MISS_KINDS: readonly ["unknown", "expected-absent"];
86
+ declare const UNKNOWN_MISS: "unknown", ABSENT_MISS: "expected-absent";
87
+ /** What {@link judgeToolNameMiss} answers: the kind (a {@link TOOL_MISS_KINDS} word) and, for `expected-absent`, the clause. */
88
+ export type ToolNameMiss = {
89
+ readonly kind: typeof UNKNOWN_MISS;
90
+ } | {
91
+ readonly kind: typeof ABSENT_MISS;
92
+ readonly detail: string;
93
+ readonly successor?: string;
94
+ };
95
+ /**
96
+ * The answer to "a call named `name` matched nothing in `roster`" — the ONE place a tool-call miss is classified:
97
+ * `expected-absent` (with the model-facing `detail`) for a retired name, `unknown` for everything else. It reads the
98
+ * table through {@link judgeRuleToolName}, so a rule's tool name and a call's tool name are judged by the same reading.
99
+ * The detail is the successor (`renamed "<name>"`) when the table names one AND this run mounts it — a successor the
100
+ * roster lacks (plan mode, no shell) is named as unavailable, never offered as the way forward, and is not returned as
101
+ * `successor` — else the table's own line (`folded into …` / `removed — …`), the grammar in the module header.
102
+ */
103
+ export declare function judgeToolNameMiss(name: string, roster: ReadonlySet<string>): ToolNameMiss;
81
104
  /** The names a run mounts — every tool's primary name and its aliases: the roster {@link judgeRuleToolName} is given. */
82
105
  export declare function mountedToolNames(tools: ReadonlyArray<{
83
106
  readonly name: string;
84
107
  readonly aliases?: readonly string[];
85
108
  }>): Set<string>;
109
+ export {};
@@ -80,6 +80,19 @@ export function judgeRuleToolName(name, roster) {
80
80
  return carriesNamespaceSeparator(name) ? UNPREFIXED : CURRENT;
81
81
  return unmintableSegmentOf(split) ?? CURRENT;
82
82
  }
83
+ export const TOOL_MISS_KINDS = Object.freeze(["unknown", "expected-absent"]);
84
+ const [UNKNOWN_MISS, ABSENT_MISS] = TOOL_MISS_KINDS;
85
+ export function judgeToolNameMiss(name, roster) {
86
+ const v = judgeRuleToolName(name, roster);
87
+ if (v.kind !== "retired")
88
+ return { kind: UNKNOWN_MISS };
89
+ const next = v.currentName;
90
+ if (next === undefined)
91
+ return { kind: ABSENT_MISS, detail: v.guidance };
92
+ if (!roster.has(next))
93
+ return { kind: ABSENT_MISS, detail: `renamed to "${next}", which this run does not mount` };
94
+ return { kind: ABSENT_MISS, detail: `renamed to "${next}"`, successor: next };
95
+ }
83
96
  export function mountedToolNames(tools) {
84
97
  return new Set(tools.flatMap((t) => [t.name, ...(t.aliases ?? [])]));
85
98
  }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * The one reading and the one snapshot of a host-written tool-name list (an agent definition's allowed-tools or denied-tools list,
3
+ * a tool's alias list, a model-id list). The judge before the run, the spawn-time filter, the memory content-origin face and the
4
+ * roster snapshot all meet a list through here, so a hostile container is answered once and the same way everywhere.
5
+ */
6
+ /** A fixed label of a host value's TYPE for a sentence that must not print or convert the value (`typeof` and the array test only). */
7
+ export declare function valueTypeLabel(value: unknown): string;
8
+ /**
9
+ * How a tool-name list's VALUE (an agent definition's allowed-tools or denied-tools list) reads as a list. A host that reads its
10
+ * definitions from a file can hand over anything, and a list can be hostile as a container (an accessor or a proxy trap that
11
+ * throws, an overridden iterator, holes): it is read BY INDEX over its length, once, into a dense copy — no iterator of the host
12
+ * runs, a hole reads as `undefined` (an entry that is not a string) — and a value that is not an array, or an array whose read
13
+ * throws, is reported as such and never printed or converted.
14
+ */
15
+ export type ToolNameListReading = {
16
+ readonly kind: "entries";
17
+ readonly entries: readonly unknown[];
18
+ } | {
19
+ readonly kind: "not_a_list";
20
+ readonly type: string;
21
+ } | {
22
+ readonly kind: "unreadable";
23
+ };
24
+ /** What the mount keeps of a list it could not read: one frozen marker, so the judgment and every later reader meet the same
25
+ * failure and never read the host's container again (a list that throws once and answers afterwards must not pass the second look). */
26
+ export declare const UNREADABLE_LIST: object;
27
+ export declare function readToolNameList(value: unknown): ToolNameListReading;
28
+ /** A tool-name list as the mount keeps it: the dense copy when it reads as a list, the failure marker when it cannot be read, else
29
+ * the value itself (not a list: the judge refuses it, and its type never changes). */
30
+ export declare function snapshotToolNameList(value: unknown): unknown;
@@ -0,0 +1,55 @@
1
+ export function valueTypeLabel(value) {
2
+ if (value === null)
3
+ return "null";
4
+ switch (typeof value) {
5
+ case "string":
6
+ return "a string";
7
+ case "undefined":
8
+ return "undefined";
9
+ case "number":
10
+ return "a number";
11
+ case "boolean":
12
+ return "a boolean";
13
+ case "bigint":
14
+ return "a bigint";
15
+ case "symbol":
16
+ return "a symbol";
17
+ case "function":
18
+ return "a function";
19
+ default:
20
+ try {
21
+ return Array.isArray(value) ? "an array" : "an object";
22
+ }
23
+ catch {
24
+ return "an object";
25
+ }
26
+ }
27
+ }
28
+ const isList = (value) => Array.isArray(value);
29
+ export const UNREADABLE_LIST = Object.freeze({});
30
+ export function readToolNameList(value) {
31
+ if (value === UNREADABLE_LIST)
32
+ return { kind: "unreadable" };
33
+ let list;
34
+ try {
35
+ list = isList(value) ? value : undefined;
36
+ }
37
+ catch {
38
+ return { kind: "not_a_list", type: "an object" };
39
+ }
40
+ if (list === undefined)
41
+ return { kind: "not_a_list", type: valueTypeLabel(value) };
42
+ try {
43
+ const entries = [];
44
+ for (let i = 0; i < list.length; i++)
45
+ entries.push(list[i]);
46
+ return { kind: "entries", entries };
47
+ }
48
+ catch {
49
+ return { kind: "unreadable" };
50
+ }
51
+ }
52
+ export function snapshotToolNameList(value) {
53
+ const read = readToolNameList(value);
54
+ return read.kind === "entries" ? read.entries : read.kind === "unreadable" ? UNREADABLE_LIST : value;
55
+ }
@@ -193,10 +193,6 @@ export declare const NAME_READINGS: {
193
193
  readonly rank: "tier";
194
194
  readonly file: string;
195
195
  };
196
- readonly "park.syncFirstRoute": {
197
- readonly kind: "wire";
198
- readonly file: string;
199
- };
200
196
  readonly "report.riskAxes": {
201
197
  readonly kind: "seat";
202
198
  readonly rank: "tier";
@@ -259,11 +255,7 @@ export declare const NAME_READINGS: {
259
255
  readonly kind: "wire";
260
256
  readonly file: string;
261
257
  };
262
- readonly "park.contentKindProjection": {
263
- readonly kind: "wire";
264
- readonly file: string;
265
- };
266
- readonly "resume.contentAskRow": {
258
+ readonly "card.reserved": {
267
259
  readonly kind: "wire";
268
260
  readonly file: string;
269
261
  };
@@ -49,7 +49,6 @@ export const NAME_READINGS = {
49
49
  "offer.marks": seat("tier", OFFER),
50
50
  "offer.marks.egress": any(OFFER),
51
51
  "park.riskDescriptor": seat("tier", PARK),
52
- "park.syncFirstRoute": wire(PARK),
53
52
  "report.riskAxes": seat("tier", CHAIN),
54
53
  "report.riskAxes.egress": any(CHAIN),
55
54
  "report.riskAxes.negatives": seat("member", CHAIN),
@@ -65,8 +64,7 @@ export const NAME_READINGS = {
65
64
  "reconcile.orphanEffect": spelling("src/core/session-reconcile.ts"),
66
65
  "inherited.questionFloat": wire(CHAIN),
67
66
  "inherited.askFace": wire(CHAIN),
68
- "park.contentKindProjection": wire("src/core/checkpoint-store.ts"),
69
- "resume.contentAskRow": wire("src/core/runner/decide-continuation.ts"),
67
+ "card.reserved": wire("src/core/tool-roster.ts"),
70
68
  "resume.editRecheckQuestionSkip": wire("src/core/runner/resume-apply.ts"),
71
69
  "resume.questionArgsShown": wire("src/core/runner/run-leg.ts"),
72
70
  "budget.exemptResult": wire("src/core/tool-result-budget.ts"),