@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
@@ -14,7 +14,7 @@ import { screenSwappableDeps } from "../swappable-deps.js";
14
14
  import { runSideQuery } from "../side-query.js";
15
15
  import { PushQueue } from "../push-queue.js";
16
16
  import { TtlSessionStore } from "../session-store.js";
17
- import { errorCodeOf } from "./assemble-result.js";
17
+ import { errorCodeOf } from "./terminal-account.js";
18
18
  import { effectiveDelegationFacts, prepareTask } from "./prepare-task.js";
19
19
  import { SessionReadFileStates } from "./session-read-file-states.js";
20
20
  import { SessionModeSeats } from "./session-mode-seats.js";
@@ -25,7 +25,7 @@ import { PendingSessionNotifications } from "../task-notification.js";
25
25
  import { ToolDetachHub } from "../tool-detach.js";
26
26
  import { assertContextSettingsValue, assertContextSettingsWords, contextOverlayFor } from "../context-settings.js";
27
27
  import { createRunState } from "./initial-run-state.js";
28
- import { reconciledToolEndBody } from "./tool-end-body.js";
28
+ import { emitSettled, reconciledEnd } from "./tool-end-body.js";
29
29
  import { answerFaceForRedeemedCall } from "./decide-continuation.js";
30
30
  import { createTurnBoundary } from "./run-turn-boundary.js";
31
31
  import { createHarnessHandlers } from "./run-harness-handlers.js";
@@ -463,12 +463,12 @@ export class Runner {
463
463
  const { todoToolMounted, taskToolsMounted, writeFamilyOf, toolStartAt, startedToolCallIds } = runToolMountFacts({ spec, prepared, rs });
464
464
  const { observeReasoningWireFacts, reasoningResolution } = runReasoningSeat({ prepared, rs, taskIdRef });
465
465
  const { effectiveTimeoutMs, walltimeMonotonicDeadline, timeout, pushContent, ownCommittedTailRef, emitCommitted } = runClockAndContent({ spec, prepared, queue, internals, rs, ident, parentToolCallId, startedToolCallIds });
466
- const toolProgress = createToolProgressLane(pushContent, ident);
466
+ const toolProgress = createToolProgressLane(pushContent, ident, prepared.toolOccurrences);
467
467
  prepared.toolProgressRef.current = toolProgress;
468
- const { subagentName, withBrainSinks } = runBrainSinks({ queue, internals, rs, ident, parentToolCallId, observeReasoningWireFacts });
468
+ const { subagentName, withBrainSinks, withExtraBodyDroppedSink } = runBrainSinks({ queue, internals, rs, ident, parentToolCallId, observeReasoningWireFacts, notice: { onNotice: this.deps.onNotice, sessionId: prepared.sessionId, runId: prepared.runId } });
469
469
  const toolLabels = new Map(prepared.tools.flatMap((t) => (t.label !== undefined && t.label !== t.name ? [[t.name, t.label]] : [])));
470
470
  for (const orphan of prepared.wakeRecovered) {
471
- queue.push({ type: "tool_end", toolCallId: orphan.toolCallId, toolName: orphan.toolName, ...(toolLabels.has(orphan.toolName) ? { label: toolLabels.get(orphan.toolName) } : {}), isError: true, ...reconciledToolEndBody(orphan, prepared.structuredProjector), ...ident() });
471
+ emitSettled(prepared.toolOccurrences, { toolCallId: orphan.toolCallId, spelledName: orphan.toolName, ...(toolLabels.has(orphan.toolName) ? { label: toolLabels.get(orphan.toolName) } : {}), args: orphan.args }, reconciledEnd(orphan), { push: (f) => queue.push({ ...f, ...ident() }), structured: prepared.structuredProjector });
472
472
  emitCommitted(orphan.entryId, "toolResult", orphan.toolCallId);
473
473
  }
474
474
  const postToolBatchHook = (spec.hooks ?? this.deps.hooks)?.postToolBatch;
@@ -504,8 +504,8 @@ export class Runner {
504
504
  },
505
505
  });
506
506
  const { flushGitMirror, unsubGitRetry, unsubBoundary, unsub } = runGitLane({ prepared, queue, rs, ident, onMessageUpdate, onMessageEnd, onToolStart, onToolEnd, onTurnEnd, onTurnBoundary, runner: this.depsSeat });
507
- return runLeg({
508
- spec, queue, prepared, resume, rs, isDelegatedChild: internals?.isDelegatedChild === true, entryActor, effectiveTimeoutMs, timeout, pushContent, ident, emitCommitted, writeFamilyOf, startedToolCallIds,
507
+ return withExtraBodyDroppedSink(() => runLeg({
508
+ spec, queue, prepared, resume, rs, entryActor, effectiveTimeoutMs, timeout, pushContent, ident, emitCommitted, writeFamilyOf, startedToolCallIds,
509
509
  announceWorkspaceMove, withBrainSinks, flushGitMirror, loopLatch, notificationLane, unsubscribeTaskNotifications, unsubGitRetry, unsubBoundary, unsub,
510
510
  runner: this.depsSeat,
511
511
  next: ({ final, threw, abortedLive, userInterruptedLive, strandedHumanAnswers }) => runTerminalAdoption({
@@ -517,7 +517,7 @@ export class Runner {
517
517
  setResult, onSuggestions, onSuspend, runner: this.depsSeat, sessions: this.sessions,
518
518
  }),
519
519
  }),
520
- });
520
+ }));
521
521
  },
522
522
  });
523
523
  },
@@ -7,6 +7,8 @@ import { ruleDenialSentence } from "../rule-denial-sentence.js";
7
7
  import { DEFAULT_GATE_AWAIT_TIMEOUT_MS, gateWaitFailureOf, withGateTimeout } from "../gate-bounded-await.js";
8
8
  import { declaredPathTargetOf, isProtectedWrite, pathConfinableWriteToolNames } from "../tool-registry.js";
9
9
  import { pathTargetBaseOf } from "../effective-path-target.js";
10
+ import { judgePathRows } from "../path-guard-rows.js";
11
+ import { domainRow } from "../fs-write-gate-policy.js";
10
12
  export const PATH_CONFINABLE_WRITE_TOOLS = pathConfinableWriteToolNames();
11
13
  export function isWithin(root, p) {
12
14
  if (!root)
@@ -165,17 +167,15 @@ export function createSessionRulePolicy(rules, opts) {
165
167
  return deny(req.toolName, "the call has no resolvable path to confine, while the rule confines writes to allowDirs");
166
168
  }
167
169
  const canon = await canonicalizeTarget(env, path, signal, pathFamilyOf({ root: rootPath, cwd: req.cwd ?? env.cwd }), pathTargetBaseOf(declared, { root: rootPath, cwd: req.cwd }));
168
- if (!canon.ok) {
169
- return deny(req.toolName, `the real target of the write to ${JSON.stringify(path)} could not be resolved against the session-rule allowDirs`);
170
- }
171
170
  const roots = [];
172
171
  for (const raw of allowDirs) {
173
172
  const r = await canonicalizeTarget(env, raw, signal, pathFamilyOf({ root: rootPath ?? env.cwd }), rootPath);
174
173
  if (r.ok)
175
174
  roots.push(r.key);
176
175
  }
177
- if (!roots.some((root) => isWithin(root, canon.key))) {
178
- return deny(req.toolName, `the write to ${JSON.stringify(path)} is outside the session-rule allowDirs (${allowDirs.join(", ")})`);
176
+ const views = canon.ok ? { views: [{ path: canon.key, kind: "canonical" }] } : { views: [], unreadable: canon.message };
177
+ if (judgePathRows([domainRow("session", roots)], views, "allow") === undefined) {
178
+ return deny(req.toolName, canon.ok ? `the write to ${JSON.stringify(path)} is outside the session-rule allowDirs (${allowDirs.join(", ")})` : `the real target of the write to ${JSON.stringify(path)} could not be resolved against the session-rule allowDirs`);
179
179
  }
180
180
  }
181
181
  }
@@ -1,4 +1,4 @@
1
- import { errorCodeOf } from "./assemble-result.js";
1
+ import { errorCodeOf, thrownFailureOf } from "./terminal-account.js";
2
2
  import { resumeDecisionWasNegative } from "./decide-continuation.js";
3
3
  import { drainForwardedFramesBeforeDone, forwardsSubagentEvents } from "./prepare-run-refs.js";
4
4
  import { hasDestroy } from "../remote-env.js";
@@ -10,7 +10,7 @@ import { asThrownError, readMember, thrownText } from "../thrown-value.js";
10
10
  export function streamSettleBackstop(input) {
11
11
  const { spec, resume, queue, taskIdRef, entryTracer, runStartedAt, live, runner, sessions, locallyClaimedTokens, parentConstraintRegistry, suspendedEnvReaps } = input;
12
12
  const onRunRejected = async (err) => {
13
- let code = errorCodeOf(err);
13
+ let { code, message, detail } = thrownFailureOf(err, thrownText(err));
14
14
  const reopenReason = code === "resume.tool_unavailable" || code === "resume.tool_contract_mismatch" ? "tool_unavailable" : "env_failed";
15
15
  const reopenable = resume !== undefined && resume.pendingActionStarted !== true && reopenReason !== undefined && !(resumeDecisionWasNegative(resume) && resume.decisionDelivered === true);
16
16
  let reopenCommitted = false;
@@ -29,7 +29,10 @@ export function streamSettleBackstop(input) {
29
29
  err = Object.assign(new Error(definitive
30
30
  ? `${reopenMsg} (original resume failure: ${original.message})`
31
31
  : `checkpoint reopen threw mid-flight — state UNKNOWN, confirm via the checkpoint store before retrying: ${reopenMsg} (original resume failure: ${original.message})`, { cause: original }), { code: "checkpoint.reopen_failed" });
32
- code = "checkpoint.reopen_failed";
32
+ const replacement = thrownFailureOf(err, thrownText(err));
33
+ code = replacement.code;
34
+ message = replacement.message;
35
+ detail = replacement.detail;
33
36
  }
34
37
  }
35
38
  if (resume)
@@ -69,7 +72,7 @@ export function streamSettleBackstop(input) {
69
72
  taskId: taskIdRef.current ?? "unknown",
70
73
  sessionId: taskIdRef.sessionId ?? "unknown",
71
74
  ...(taskIdRef.runId !== undefined ? { runId: taskIdRef.runId } : {}),
72
- terminal: { kind: "failed", ...(code !== undefined ? { code } : {}), message: thrownText(err) },
75
+ terminal: { kind: "failed", ...(code !== undefined ? { code } : {}), message, ...(detail !== undefined ? { detail } : {}) },
73
76
  result: "",
74
77
  ...(remoteEnvFailure !== undefined ? { remoteEnvFailures: remoteEnvFailure } : {}),
75
78
  ...(taskIdRef.effectiveMemoryScopes !== undefined ? { effectiveMemoryScopes: taskIdRef.effectiveMemoryScopes } : {}),
@@ -1,15 +1,24 @@
1
1
  /**
2
- * The sub-agent tool lists of one prepared task: the allow advisory for `TaskSpec.agents` and THE judgment of every denied-tools
3
- * list a deployment writes — the task's own definitions (`TaskSpec.agents`), the definitions a mounted delegation tool carries
4
- * (the `authored` faces — the engine's built-ins name tools of other vocabularies and are not judged) and its tool-level list.
5
- * Universe = the task's assembled roster plus every mounted delegation tool's pool, names and aliases; a pool the engine cannot
6
- * list (an `extraTools` factory with no declared roster) turns the refusals that need a roster into host notices. A tool's own lists are judged where
7
- * the tool is mounted: only a tool a deployment mounted (depth 0) publishes them (`authored`, `agentToolLevelAllowTools`, `agentToolLevelDenyTools`), the
8
- * engine's nested copy for a delegated child carries neither.
2
+ * THE judgment of every tool-name list one prepared task receives — the run's own selector lists (`TaskSpec.allowTools` /
3
+ * `TaskSpec.excludeTools`, unless the delegation lane spawned it — its spawning run judged them where they were mounted), the definitions it
4
+ * carries (`TaskSpec.agents`), and the definitions and tool-level lists a mounted delegation tool carries (the `authored` faces
5
+ * — the engine's built-ins are not judged; only a tool a deployment mounted (depth 0) publishes them). One rule for both sides:
6
+ * a value that is not a list, an entry that is not a string, a spelling that can name no tool, a stale name and a name the
7
+ * universe does not carry are REFUSED; a list whose universe the engine cannot list (a delegation tool that injects tools per
8
+ * spawn with no declared roster) turns the refusals that need a universe into host notices. And one contradiction, judged on
9
+ * every leg: a denylist (the run's own or one of its ceiling) that reaches a tool the leg's kind relies on (the catalog's
10
+ * protocol column) is refused — neither a silently ignored deny nor a silently crippled leg.
9
11
  *
10
- * Throws `config.agent.unknown_tool` (`refused`, the one site) — synchronous, like the phase that calls it.
12
+ * Universe = the task's assembled roster before the valve, every tool the catalog describes, every mounted delegation tool's
13
+ * pool and the caller's own tools (names and aliases), and the protocol peers the task declares (a namespaced spelling under a
14
+ * declared peer names a tool of it — the peer's tool list is runtime data, so the peer is what is checked).
15
+ *
16
+ * Throws `config.tool_face_control` for the run's own lists and the protocol contradiction, `config.agent.unknown_tool` for a
17
+ * definition's or a delegation tool's lists — synchronous, like the phase that calls it.
11
18
  */
12
19
  import type { AgentTool } from "../../internal/harness.js";
20
+ import { type ProtocolId } from "../protocol-table.js";
21
+ import type { ToolLegKind, ToolSelectorLayer } from "../tool-face.js";
13
22
  import type { TaskSpec } from "../types.js";
14
23
  import type { AnnounceOnceSink } from "./contracts.js";
15
24
  /**
@@ -19,14 +28,44 @@ import type { AnnounceOnceSink } from "./contracts.js";
19
28
  * need the leg's roster and a sink; the leg's own policy-name audit is what reads them.
20
29
  */
21
30
  export declare function deniedToolNamesOf(where: string, value: unknown): string[];
22
- export interface SubAgentToolListsInput {
23
- /** borrowed-readonly — the REBOUND spec: `agents` (the task's definitions) and `tools` (the mounted delegation tools). */
31
+ /**
32
+ * The upstream judgment of a run's own lists, when it holds: the evidence digest the spawning run handed down (live) or the resumed row
33
+ * recorded, returned only when it equals the digest of the lists this prepare read — the evidence is bound to the lists it was minted
34
+ * for, so a resume that hands different lists is judged again. The value returned is what this leg's rows record.
35
+ */
36
+ export declare function boundToolListsJudgment(evidence: string | undefined, own: {
37
+ readonly allow: readonly string[] | undefined;
38
+ readonly exclude: readonly string[] | undefined;
39
+ }): string | undefined;
40
+ export interface RunToolListsInput {
41
+ /** borrowed-readonly — the REBOUND spec: `agents` (the task's definitions) and `tools` (the caller's tools and the mounted delegation tools). */
24
42
  spec: Pick<TaskSpec, "agents" | "tools">;
25
- /** borrowed-readonly — the FULLY ASSEMBLED mount array (names + aliases = the roster half of the universe). */
43
+ /** borrowed-readonly — the assembled mount array BEFORE the selector's valve (names + aliases = the roster half of the universe). */
26
44
  tools: ReadonlyArray<AgentTool>;
45
+ /** borrowed-readonly — the peers the task declares, per protocol of the protocol table (its MCP servers, its A2A peers): a namespaced
46
+ * spelling under one names a tool of it, whether or not the peer answered with any tool. */
47
+ declaredPeers: {
48
+ readonly [P in ProtocolId]: ReadonlyArray<{
49
+ readonly name: string;
50
+ }> | undefined;
51
+ };
52
+ /** borrowed-readonly — the run's own lists (the selector's own layer), as the doors froze them. */
53
+ own: {
54
+ readonly allow: readonly string[] | undefined;
55
+ readonly exclude: readonly string[] | undefined;
56
+ };
57
+ /** borrowed-readonly — every layer of the run's selector (the ceiling, then its own) and the kinds of leg it is. */
58
+ layers: readonly ToolSelectorLayer[];
59
+ legs: readonly ToolLegKind[];
60
+ /** True ⇔ the spawning run's prepare judged exactly these own lists where they were mounted — the evidence digest it handed down
61
+ * (live, or recorded on the resumed row) equals the digest of the lists this prepare read ({@link boundToolListsJudgment}). */
62
+ judgedUpstream: boolean;
63
+ /** Whose lists the run's own are, when the run that spawned it wrote them ({@link delegationListWhere}); absent ⇒ the run's own
64
+ * `TaskSpec` seats. */
65
+ ownWhere: string | undefined;
27
66
  /** borrowed-readonly — the once-per-session ledger whose operator sink carries the notices. */
28
67
  onceLedger: Pick<AnnounceOnceSink, "onError">;
29
68
  /** borrowed-readonly — the acquired session's id (operator-line context). */
30
69
  sessionId: string;
31
70
  }
32
- export declare function auditSubAgentToolLists(input: SubAgentToolListsInput): void;
71
+ export declare function judgeRunToolLists(input: RunToolListsInput): void;
@@ -1,88 +1,91 @@
1
- import { notAListSentence, notAStringSentence, readDeniedEntry, readToolNameList, valueTypeLabel } from "../../agents/tool-filter.js";
1
+ import { deniedProtocolTools, delegationListWhere, listReaches, notAListSentence, toolListsDigest, notAStringSentence, readAllowedToolList, readDeniedEntry, readDeniedToolList } from "../../agents/tool-filter.js";
2
+ import { readToolNameList, valueTypeLabel } from "../tool-name-list.js";
2
3
  import { compileAllowList, inertEntryPhrase, renderListEntry } from "../allow-entry.js";
3
4
  import { inlineUntrusted } from "../untrusted-text.js";
4
- const DENY_LIST_NAMES_ONLY = "To block by path or command, write a deny rule in the caller's permission policy: a denied-tools list only takes tool names (it narrows which tools the agent is handed).";
5
- function refused(message) {
5
+ import { ENGINE_TOOLS } from "../tool-catalog-entries.js";
6
+ import { mintNamespacePrefix } from "../protocol-naming.js";
7
+ import { PROTOCOL_TABLE, protocolOf } from "../protocol-table.js";
8
+ import { splitNamespacedName } from "../tool-name-aliases.js";
9
+ const DENY_LIST_NAMES_ONLY = "To block by path or command, write a deny rule in the caller's permission policy: a tool-name list only takes tool names (it narrows which tools are mounted).";
10
+ function universeCarries(reach, entry, universe) {
11
+ for (const name of universe.known)
12
+ if (listReaches(reach, { name }))
13
+ return true;
14
+ const split = splitNamespacedName(entry);
15
+ if (split === undefined || split.peer === "")
16
+ return false;
17
+ return universe.peers.has(mintNamespacePrefix(split.ns, split.peer));
18
+ }
19
+ function refused(message, code, reason) {
6
20
  const e = new Error(message);
7
- e.code = "config.agent.unknown_tool";
21
+ e.code = code;
22
+ e.detail = { reason };
8
23
  return e;
9
24
  }
10
- function refusal(where, flaw) {
11
- return refused(`${where} declares tool ${inertEntryPhrase(flaw)} in its denied tools, but no tool of that spelling exists in this deployment — fix the entry or mount the tool.${flaw.reason === "grammar" ? ` ${DENY_LIST_NAMES_ONLY}` : ""}`);
12
- }
13
- function refusalNotAString(where, side, index, type) {
14
- return refused(notAStringSentence(where, side, index, type));
15
- }
16
- function refusalNotAList(where, side, list) {
17
- return refused(notAListSentence(where, side, list));
18
- }
19
- export function deniedToolNamesOf(where, value) {
20
- const list = readToolNameList(value);
21
- if (list.kind !== "entries")
22
- throw refusalNotAList(where, "denied", list);
23
- return list.entries.map((entry, index) => {
24
- if (entry === "*")
25
- return entry;
26
- const read = readDeniedEntry(entry);
27
- if (read.kind === "not_a_string")
28
- throw refusalNotAString(where, "denied", index, read.type);
29
- const flaw = compileAllowList([read.name], "deny").inert[0];
30
- if (flaw !== undefined && flaw.reason === "grammar")
31
- throw refusal(where, { ...flaw, entry: read.name });
32
- return read.name;
33
- });
34
- }
35
- function judgeDeniedToolNames(where, value, universe, advise) {
25
+ const LIST_WORD = { allowed: "allowed tools", denied: "denied tools" };
26
+ function judgeToolNameList(where, side, value, universe, advise, code) {
36
27
  if (value === undefined || value === null)
37
28
  return;
38
29
  const list = readToolNameList(value);
39
30
  if (list.kind !== "entries")
40
- throw refusalNotAList(where, "denied", list);
31
+ throw refused(notAListSentence(where, side, list), code, "not_a_list");
41
32
  let index = -1;
42
33
  for (const entry of list.entries) {
43
34
  index += 1;
44
- if (entry === "*")
45
- continue;
35
+ if (typeof entry !== "string")
36
+ throw refused(notAStringSentence(where, side, index, valueTypeLabel(entry)), code, "not_a_string");
37
+ if (entry === "*") {
38
+ if (side === "allowed")
39
+ continue;
40
+ throw refused(`${where} declares "*" in its ${LIST_WORD[side]}: a denied list has no wildcard — the entry would hide nothing. To give the agent no tools, write an empty allowed list.`, code, "unsupported_pattern");
41
+ }
46
42
  const read = readDeniedEntry(entry);
47
- if (read.kind === "not_a_string")
48
- throw refusalNotAString(where, "denied", index, read.type);
49
- const { name, content } = read;
50
- const raw = entry;
51
- const { rows, inert } = compileAllowList([name], "deny", universe.known);
52
- const flaw = inert[0] === undefined ? undefined : { ...inert[0], entry: raw };
43
+ const name = side === "denied" && read.kind === "name" ? read.name : entry;
44
+ const content = side === "denied" && read.kind === "name" && read.content;
45
+ const reach = side === "denied" ? readDeniedToolList([entry]) : (readAllowedToolList([entry]) ?? readDeniedToolList([]));
46
+ const split = splitNamespacedName(name);
47
+ if (split !== undefined && split.peer === "*" && split.tool === undefined) {
48
+ if (side === "denied")
49
+ continue;
50
+ throw refused(`${where} declares ${renderListEntry(entry)} in its ${LIST_WORD[side]}: an allowed list has no protocol-wide form — name a peer (\`${split.ns.prefix}<peer>\`) or its tools.`, code, "unsupported_pattern");
51
+ }
52
+ const { inert } = compileAllowList([name], "deny", universe.known);
53
+ const flaw = inert[0] === undefined ? undefined : { ...inert[0], entry };
53
54
  const stale = flaw !== undefined && (flaw.reason === "tool_name" || flaw.reason === "near_miss");
54
- if (flaw !== undefined && (flaw.reason === "grammar" || (stale && universe.complete)))
55
- throw refusal(where, flaw);
56
- if (flaw === undefined && universe.known.has(name)) {
55
+ if (flaw !== undefined && (flaw.reason === "grammar" || (stale && universe.complete))) {
56
+ throw refused(`${where} declares tool ${inertEntryPhrase(flaw)} in its ${LIST_WORD[side]}, but no tool of that spelling exists in this deployment — fix the entry or mount the tool.${flaw.reason === "grammar" ? ` ${DENY_LIST_NAMES_ONLY}` : ""}`, code, "unknown_name");
57
+ }
58
+ if (flaw === undefined && universeCarries(reach, name, universe)) {
57
59
  if (content)
58
- advise(new Error(`${where} declares ${renderListEntry(raw)} in its denied tools: this list reads tool names, not content, so the whole tool "${inlineUntrusted(name, 80)}" is denied to the agent. ${DENY_LIST_NAMES_ONLY}`));
60
+ advise(new Error(`${where} declares ${renderListEntry(entry)} in its denied tools: this list reads tool names, not content, so the whole tool "${inlineUntrusted(name, 80)}" is denied. ${DENY_LIST_NAMES_ONLY}`));
59
61
  continue;
60
62
  }
61
- advise(new Error(`${where} declares tool ${flaw !== undefined ? inertEntryPhrase(flaw) : renderListEntry(raw)} in its denied tools, a name this task's roster and delegation pools do not carry — the entry hides nothing here. Advisory only: a list shared across deployments is not wrong because one lacks a tool, but a misspelling guards nothing.` +
62
- (rows[0]?.compiled.kind === "namespace" ? " This list matches tool names exactly: a server-level entry hides none of that server's tools; name them, or write a deny rule in the caller's permission policy." : "") +
63
- (universe.complete ? "" : " A delegation tool this task mounts injects tools the engine cannot enumerate (extraTools), so the name cannot be checked here.")));
63
+ const phrase = flaw !== undefined ? inertEntryPhrase(flaw) : renderListEntry(entry);
64
+ if (universe.complete)
65
+ throw refused(`${where} declares tool ${phrase} in its ${LIST_WORD[side]}, a name no tool of this deployment answers to — fix the entry or mount the tool.`, code, "unknown_name");
66
+ advise(new Error(`${where} declares tool ${phrase} in its ${LIST_WORD[side]}, a name no listed tool answers to — a delegation tool this task mounts injects tools the engine cannot enumerate (extraTools), so the name cannot be checked here.`));
64
67
  }
65
68
  }
66
- function judgeAllowedToolList(where, value, known, advise) {
67
- if (value === undefined || value === null)
68
- return;
69
+ export function deniedToolNamesOf(where, value) {
69
70
  const list = readToolNameList(value);
70
71
  if (list.kind !== "entries")
71
- throw refusalNotAList(where, "allowed", list);
72
- const unknownNames = [];
73
- let index = -1;
74
- for (const entry of list.entries) {
75
- index += 1;
76
- if (typeof entry !== "string")
77
- throw refusalNotAString(where, "allowed", index, valueTypeLabel(entry));
78
- if (known !== undefined && entry !== "*" && !known.has(entry))
79
- unknownNames.push(entry);
80
- }
81
- if (unknownNames.length === 0)
82
- return;
83
- advise(new Error(`${where} allows tool(s) ${unknownNames.map(renderListEntry).join(", ")} not present in this task's assembled roster — likely a typo (the entry would be item-filtered at spawn; the agent stays usable). Advisory only: the delegation pool can differ from this roster, so a tool mounted only on the delegation tool or produced by per-spawn extraTools makes this spurious.`));
72
+ throw refused(notAListSentence(where, "denied", list), "config.agent.unknown_tool", "not_a_list");
73
+ return list.entries.map((entry, index) => {
74
+ if (entry === "*")
75
+ return entry;
76
+ const read = readDeniedEntry(entry);
77
+ if (read.kind === "not_a_string")
78
+ throw refused(notAStringSentence(where, "denied", index, read.type), "config.agent.unknown_tool", "not_a_string");
79
+ const flaw = compileAllowList([read.name], "deny").inert[0];
80
+ if (flaw !== undefined && flaw.reason === "grammar")
81
+ throw refused(`${where} declares tool ${inertEntryPhrase({ ...flaw, entry: read.name })} in its denied tools, but no tool of that spelling exists in this deployment — fix the entry or mount the tool. ${DENY_LIST_NAMES_ONLY}`, "config.agent.unknown_tool", "unknown_name");
82
+ return read.name;
83
+ });
84
84
  }
85
- export function auditSubAgentToolLists(input) {
85
+ export function boundToolListsJudgment(evidence, own) {
86
+ return evidence !== undefined && evidence === toolListsDigest(own.allow, own.exclude) ? evidence : undefined;
87
+ }
88
+ export function judgeRunToolLists(input) {
86
89
  const { spec, tools, onceLedger, sessionId } = input;
87
90
  const advise = (err) => {
88
91
  try {
@@ -91,31 +94,59 @@ export function auditSubAgentToolLists(input) {
91
94
  catch {
92
95
  }
93
96
  };
97
+ const denied = deniedProtocolTools(input.layers, input.legs);
98
+ if (denied.length > 0) {
99
+ const names = [...new Set(denied.map((h) => `"${h.name}"`))];
100
+ const one = names.length === 1;
101
+ const deniedBy = (own, whose) => {
102
+ const hits = denied.filter((h) => h.own === own).map((h) => `"${h.name}"`);
103
+ return hits.length > 0 ? [`${whose} denies ${one ? "it" : hits.join(", ")}`] : [];
104
+ };
105
+ const by = [...deniedBy(true, input.ownWhere ?? "this run's own excludeTools"), ...deniedBy(false, "an inherited list (the spawning run's excludeTools, or one it inherits)")];
106
+ throw refused(`This kind of leg (${input.legs.join(", ")}) relies on ${names.join(", ")}, but ${by.join(" and ")} — the leg cannot work without ${one ? "it" : "them"}. Remove the entry from the list that names it.`, "config.tool_face_control", "protocol_denied");
107
+ }
94
108
  const delegationTools = (spec.tools ?? []).filter((t) => t.agentToolFaces !== undefined);
95
- const taskAgents = spec.agents ?? [];
96
- if (taskAgents.length === 0 && delegationTools.length === 0)
97
- return;
98
- const known = new Set(tools.flatMap((t) => [t.name, ...(t.aliases ?? [])]));
99
- const denyKnown = new Set(known);
109
+ const known = new Set();
110
+ const add = (t) => {
111
+ known.add(t.name);
112
+ for (const a of t.aliases ?? [])
113
+ known.add(a);
114
+ };
115
+ for (const t of tools)
116
+ add(t);
117
+ for (const t of ENGINE_TOOLS)
118
+ add(t);
119
+ for (const t of spec.tools ?? [])
120
+ add(t);
100
121
  for (const t of delegationTools)
101
122
  for (const p of t.agentToolPool ?? [])
102
- for (const n of [p.name, ...(p.aliases ?? [])])
103
- denyKnown.add(n);
104
- const universe = { known: denyKnown, complete: delegationTools.every((t) => t.agentToolPool !== undefined) };
105
- for (const def of taskAgents) {
106
- judgeAllowedToolList(`TaskSpec.agents: agent "${def.name}"`, def.allowTools, known, advise);
107
- judgeDeniedToolNames(`TaskSpec.agents: agent "${def.name}"`, def.denyTools, universe, advise);
123
+ add(p);
124
+ const peers = new Set(PROTOCOL_TABLE.flatMap((ns) => (input.declaredPeers[ns.id] ?? []).map((p) => mintNamespacePrefix(ns, p.name))));
125
+ for (const name of known) {
126
+ const ns = protocolOf(name);
127
+ const split = ns !== undefined ? splitNamespacedName(name) : undefined;
128
+ if (split !== undefined && split.peer !== "")
129
+ peers.add(mintNamespacePrefix(split.ns, split.peer));
130
+ }
131
+ const universe = { known, peers, complete: delegationTools.every((t) => t.agentToolPool !== undefined) };
132
+ if (!input.judgedUpstream) {
133
+ judgeToolNameList(input.ownWhere ?? "TaskSpec.allowTools", "allowed", input.own.allow, { ...universe, complete: true }, advise, "config.tool_face_control");
134
+ judgeToolNameList(input.ownWhere ?? "TaskSpec.excludeTools", "denied", input.own.exclude, { ...universe, complete: true }, advise, "config.tool_face_control");
135
+ }
136
+ for (const def of spec.agents ?? []) {
137
+ judgeToolNameList(`TaskSpec.agents: agent "${def.name}"`, "allowed", def.allowTools, universe, advise, "config.agent.unknown_tool");
138
+ judgeToolNameList(`TaskSpec.agents: agent "${def.name}"`, "denied", def.denyTools, universe, advise, "config.agent.unknown_tool");
108
139
  }
109
- const replaced = new Set(taskAgents.map((d) => d.name));
140
+ const replaced = new Set((spec.agents ?? []).map((d) => d.name));
110
141
  for (const t of delegationTools) {
111
142
  for (const face of t.agentToolFaces ?? []) {
112
143
  if (face.authored === true && !replaced.has(face.name)) {
113
- const faceWhere = `delegation tool "${t.name}": agent definition "${face.name}"`;
114
- judgeAllowedToolList(faceWhere, face.allowTools, undefined, advise);
115
- judgeDeniedToolNames(faceWhere, face.denyTools, universe, advise);
144
+ const faceWhere = delegationListWhere(t.name, face.name);
145
+ judgeToolNameList(faceWhere, "allowed", face.allowTools, universe, advise, "config.agent.unknown_tool");
146
+ judgeToolNameList(faceWhere, "denied", face.denyTools, universe, advise, "config.agent.unknown_tool");
116
147
  }
117
148
  }
118
- judgeAllowedToolList(`delegation tool "${t.name}": the tool-level list`, t.agentToolLevelAllowTools, undefined, advise);
119
- judgeDeniedToolNames(`delegation tool "${t.name}": the tool-level list`, t.agentToolLevelDenyTools, universe, advise);
149
+ judgeToolNameList(delegationListWhere(t.name, undefined), "allowed", t.agentToolLevelAllowTools, universe, advise, "config.agent.unknown_tool");
150
+ judgeToolNameList(delegationListWhere(t.name, undefined), "denied", t.agentToolLevelDenyTools, universe, advise, "config.agent.unknown_tool");
120
151
  }
121
152
  }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * The terminal's accounts — `terminal.detail` and its members — each read off the ONE seat its fact was minted on, and
3
+ * admitted as a value this engine did not necessarily build (a host Brain mints the final message too; a host throws
4
+ * the error): every member read once, words admitted only from their closed sets, a malformed member absent rather than
5
+ * repaired. Nothing here re-derives a fact from a sentence. The arbitration of WHICH account a terminal carries is
6
+ * `assemble-result.ts`'s (`terminalCauseOf`); this module only reads.
7
+ */
8
+ import { type AssistantMessage, type ModelOutputInvalid } from "../../internal/llm.js";
9
+ import { type RequestRoute } from "../../brain/request-route.js";
10
+ import type { TerminalCause } from "../types.js";
11
+ import type { TerminalFailureDetail } from "../terminal-cause.js";
12
+ type ProviderRejected = Extract<TerminalFailureDetail, {
13
+ kind: "provider_rejected";
14
+ }>;
15
+ /** The terminal message's provider-condition verdict, as the refusal account carries it: each member read once and
16
+ * admitted only as a word of its closed set (a host Brain mints this message too); the reset instant only beside a
17
+ * condition. Absent members stay absent. */
18
+ export declare function providerVerdictOf(final: AssistantMessage): Pick<ProviderRejected, "providerCondition" | "providerConditionSource" | "providerResetAtMs">;
19
+ /** The terminal message's request route (`apiErrorRoute`), admitted as a shape some request carries
20
+ * (`ROUTE_CREDENTIAL_PAIRING`); anything else is no route. */
21
+ export declare function requestRouteOfMessage(final: AssistantMessage): RequestRoute | undefined;
22
+ /** The terminal message's dropped-calls account (`modelOutputInvalid`): `cause` admitted from its closed set (else no
23
+ * account); `outputLimit` only beside `truncated`, only with a boolean `capStop`, its counts only as non-negative
24
+ * integers — an unreadable limit leaves the cause standing without it. */
25
+ export declare function modelOutputInvalidOfMessage(final: AssistantMessage): ModelOutputInvalid | undefined;
26
+ /**
27
+ * Extract a machine-readable code from a thrown error (e.g. `SessionError.code`, a Node error code).
28
+ * Walks the `cause` chain because the harness wraps lower-level errors (e.g. a `SessionError("conflict")`
29
+ * append failure surfaces as an `AgentHarnessError("unknown")` whose cause is the real one) — so we
30
+ * prefer the first specific code over a generic `"unknown"` wrapper.
31
+ */
32
+ export declare function errorCodeOf(err: unknown): string | undefined;
33
+ /** A thrown failure's terminal account — its code ({@link errorCodeOf}), its sentence (the seat's own describing of the
34
+ * thrown value, `text`, through the secret word list: a throw's message is the thrower's text, and a credential in it
35
+ * must not reach the result any more than one in its `detail`), and, when the coded link's throw site stated a
36
+ * structured `detail`, the `coded` account of it. One reading for every seat that turns a throw into a `failed`
37
+ * terminal (the run's arbitration in `assemble-result.ts` and the stream lane's settle backstop). */
38
+ export declare function thrownFailureOf(err: unknown, text: string): {
39
+ code?: string;
40
+ message: string;
41
+ detail?: TerminalFailureDetail;
42
+ };
43
+ /** The completion's one account: the final turn ended on a provider word the brain does not read (the turn was kept
44
+ * and the run announced the word) — stated beside the completion, in the echo shape the brain carried it in. */
45
+ export declare function completedTerminalOf(final: AssistantMessage | undefined): Extract<TerminalCause, {
46
+ kind: "completed";
47
+ }>;
48
+ export {};