@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
@@ -7,8 +7,9 @@ import { cloneObserverInput, resolveHookTimeoutMs } from "../hooks.js";
7
7
  import { assertHookSeatsCallable } from "../hook-seats.js";
8
8
  import { isNamespacedCoveringRuleName, namespacedRuleNameCovers } from "../permission-rules.js";
9
9
  import { isIsolated } from "../remote-env.js";
10
- import { askApproverIdentity, carryEngineAttestations, carryPrecedingSettlement, checkToolPolicyProjection, combinePolicies, createTranscriptIntegrityPolicy, createUnverifiableDeletePolicy, durableParkOptInDeclared, isLiveApproverSeat, refuseOutOfContractDecision, resolveAsk, toolPolicyNameSets, wrapToolPolicy, attestAskUnresolvableCause } from "../tool-policy.js";
10
+ import { askApproverIdentity, attest, attestationOf, checkToolPolicyProjection, combinePolicies, createTranscriptIntegrityPolicy, createUnverifiableDeletePolicy, durableParkOptInDeclared, isLiveApproverSeat, mergeAttestation, refuseOutOfContractDecision, resolveAsk, toolPolicyNameSets, withAttestation, wrapToolPolicy } from "../tool-policy.js";
11
11
  import { judgeRuleToolName, mountedToolNames } from "../tool-name-aliases.js";
12
+ import { approvalCardMemberOf } from "../tool-roster.js";
12
13
  import { NAMESPACED_NAME_SHAPES } from "../protocol-table.js";
13
14
  import { emitTrace } from "../trace.js";
14
15
  import { skillGrantBindingMembers } from "../skill-grant.js";
@@ -189,11 +190,11 @@ export async function preparePolicyChain(input) {
189
190
  return true;
190
191
  };
191
192
  const mandatedCallFloats = (toolCallId) => resolveCheckpointStore(spec, deps) !== undefined && durableParkOptInDeclared({ forceDurableGate: runtimeCaps?.forceDurableGate === true, durableApprovalDeclared: spec.durableApproval !== undefined }) && markInheritedUnavailable(toolCallId);
192
- const mandateUnreconstructibleDeny = (creq) => attestAskUnresolvableCause({
193
+ const mandateUnreconstructibleDeny = (creq) => attest({
193
194
  action: "deny",
194
195
  message: `inherited parent policy requires durable approval for "${creq.toolName}" — the parent's durable ask cannot be reconstructed in a delegated child; denied fail-closed (tighten-only)`,
195
- }, "mandate_unreconstructible", creq);
196
- const markerChannelFullDeny = (creq) => attestAskUnresolvableCause({ action: "deny", message: `no approver is reachable for the inherited approval of "${creq.toolName}" and the marker channel is at capacity — denied fail-closed` }, "approver_unavailable", creq);
196
+ }, creq, { unresolvableCause: "mandate_unreconstructible" });
197
+ const markerChannelFullDeny = (creq) => attest({ action: "deny", message: `no approver is reachable for the inherited approval of "${creq.toolName}" and the marker channel is at capacity — denied fail-closed` }, creq, { unresolvableCause: "approver_unavailable" });
197
198
  const inheritedAskGrants = new Map();
198
199
  const recordInheritedAskGrant = (toolCallId, approver, presented, waitMs, settled, classes) => {
199
200
  if (typeof approver !== "function")
@@ -357,12 +358,8 @@ export async function preparePolicyChain(input) {
357
358
  const ancestorTracker = ancestorAutoMode?.denialTracking;
358
359
  let editArgs = edit;
359
360
  let settledBy = approved;
360
- const vetoed = (d) => {
361
- const out = { ...d };
362
- carryEngineAttestations(d, out);
363
- carryPrecedingSettlement(settledBy, out);
364
- return out;
365
- };
361
+ const onApproval = (d) => withAttestation(d, mergeAttestation(creq, attestationOf(settledBy, creq), attestationOf(d, creq), "answer"));
362
+ const vetoed = onApproval;
366
363
  for (let round = 0;; round++) {
367
364
  if (round >= 3) {
368
365
  return vetoed({
@@ -385,19 +382,13 @@ export async function preparePolicyChain(input) {
385
382
  return vetoed(re);
386
383
  if (re.action === "allow") {
387
384
  const stated = re.updatedInput === undefined ? "mode" : re.decisionReason;
388
- const out = { action: "allow", updatedInput: re.updatedInput !== undefined ? re.updatedInput : editArgs, ...(stated !== undefined ? { decisionReason: stated } : {}) };
389
- carryEngineAttestations(re, out);
390
- carryPrecedingSettlement(settledBy, out);
391
- return out;
385
+ return onApproval(withAttestation({ action: "allow", updatedInput: re.updatedInput !== undefined ? re.updatedInput : editArgs, ...(stated !== undefined ? { decisionReason: stated } : {}) }, re.attestation));
392
386
  }
393
387
  if (re.updatedInput !== undefined)
394
388
  editArgs = re.updatedInput;
395
389
  const judged = await judgeInheritedClassifier({ liveMode: () => permissionMode.current, autoMode: ancestorAutoMode, ask: re, req: { ...creq, args: editArgs }, signal: csignal ?? abortController.signal, subject: "the approved edit", allowRewrite: editArgs, facts: inheritedStationFacts(creq), unavailableSeat: classifierUnavailableSeat({ station: "ancestor", ...(ancestorDecider?.timeoutMs !== undefined ? { budgetMs: ancestorDecider.timeoutMs } : {}), approvalSeat: isLiveApproverSeat(onAskOf), onNotice: deps.onNotice, sessionId, runId }) });
396
390
  if (judged.kind === "allow") {
397
- const cleared = { ...judged.result };
398
- carryEngineAttestations(judged.result, cleared);
399
- carryPrecedingSettlement(settledBy, cleared);
400
- return cleared;
391
+ return onApproval(judged.result);
401
392
  }
402
393
  if (judged.kind === "deny")
403
394
  return vetoed(judged.result);
@@ -405,9 +396,7 @@ export async function preparePolicyChain(input) {
405
396
  re = editAsk;
406
397
  const editArbitrated = arbitrateInherited(re, creq.toolCallId, judged);
407
398
  if (editArbitrated !== undefined) {
408
- const out = editArbitrated.action === "allow" ? { action: "allow", updatedInput: editArgs, decisionReason: "mode" } : editArbitrated;
409
- carryPrecedingSettlement(settledBy, out);
410
- return out;
399
+ return onApproval(editArbitrated.action === "allow" ? { action: "allow", updatedInput: editArgs, decisionReason: "mode" } : editArbitrated);
411
400
  }
412
401
  const { resolved: rr, judged: settled } = await resolveInheritedAsk(judged, (j) => resolveAsk({
413
402
  toolName: creq.toolName,
@@ -417,22 +406,20 @@ export async function preparePolicyChain(input) {
417
406
  ...cardDisclosureOf(j.ask, inheritedAskFallbackMessage(creq.toolName)),
418
407
  ...askSourceIdentity(),
419
408
  ...riskAxesOf(creq),
409
+ ...approvalCardMemberOf(creq),
420
410
  ...grantBindingOf(creq, editArgs),
421
411
  ...(j.ask.requiresRealApproval === true ? { requiresRealApproval: true } : {}),
422
412
  ...askMandateMember(ancestorFacts(j.ask)),
423
413
  ...inheritedAskCarry(j, isLiveApproverSeat(onAskOf), ancestorTracker),
424
414
  ruleEvidence: inheritedAskEvidence,
425
- }, onAskOf, csignal ?? abortController.signal, lateAskSettlementObserver({ toolName: creq.toolName, toolCallId: creq.toolCallId, sessionId, runId, ...(spec.taskId !== undefined ? { taskId: spec.taskId } : {}), onNotice: deps.onNotice, onError: deps.onError })), ancestorTracker, creq.toolName, inheritedStationFacts(creq));
415
+ }, onAskOf, csignal ?? abortController.signal, lateAskSettlementObserver({ toolName: creq.toolName, toolCallId: creq.toolCallId, sessionId, runId, ...(spec.taskId !== undefined ? { taskId: spec.taskId } : {}), onNotice: deps.onNotice, onError: deps.onError })), ancestorTracker, creq, inheritedStationFacts(creq));
426
416
  void settleReadRootGrant(rr.readRootGrant, undefined, { toolName: creq.toolName, toolCallId: creq.toolCallId, sessionId, runId, ...(spec.taskId !== undefined ? { taskId: spec.taskId } : {}), onNotice: deps.onNotice });
427
417
  settleDenialLimitFallback({ fallback: settled.fallback, mintedHere: settled.mintedHere, tracker: ancestorTracker, resolved: rr, headless: headlessDenyAtRecheck, stop: stopForDenialLimit, toolName: creq.toolName, toolCallId: creq.toolCallId });
428
418
  if (rr.action !== "allow")
429
419
  return rr;
430
420
  settledBy = rr;
431
- if (rr.updatedInput === undefined) {
432
- const out = { action: "allow", updatedInput: editArgs, decisionReason: "mode" };
433
- carryPrecedingSettlement(rr, out);
434
- return out;
435
- }
421
+ if (rr.updatedInput === undefined)
422
+ return onApproval({ action: "allow", updatedInput: editArgs, decisionReason: "mode" });
436
423
  editArgs = rr.updatedInput;
437
424
  }
438
425
  };
@@ -497,12 +484,13 @@ export async function preparePolicyChain(input) {
497
484
  ...cardDisclosureOf(j.ask, inheritedAskFallbackMessage(creq.toolName)),
498
485
  ...askSourceIdentity(),
499
486
  ...riskAxesOf(creq),
487
+ ...approvalCardMemberOf(creq),
500
488
  ...grantBindingOf(creq, presentedArgs),
501
489
  ...(j.ask.action === "ask" && j.ask.requiresRealApproval === true ? { requiresRealApproval: true } : {}),
502
490
  ...askMandateMember(ancestorFacts(j.ask.action === "ask" ? j.ask : undefined)),
503
491
  ...inheritedAskCarry(j, isLiveApproverSeat(pc.onAsk), pc.autoMode?.denialTracking),
504
492
  ruleEvidence: inheritedAskEvidence,
505
- }, pc.onAsk, csignal ?? abortController.signal, lateAskSettlementObserver({ toolName: creq.toolName, toolCallId: creq.toolCallId, sessionId, runId, ...(spec.taskId !== undefined ? { taskId: spec.taskId } : {}), onNotice: deps.onNotice, onError: deps.onError })), pc.autoMode?.denialTracking, creq.toolName, inheritedStationFacts(creq));
493
+ }, pc.onAsk, csignal ?? abortController.signal, lateAskSettlementObserver({ toolName: creq.toolName, toolCallId: creq.toolCallId, sessionId, runId, ...(spec.taskId !== undefined ? { taskId: spec.taskId } : {}), onNotice: deps.onNotice, onError: deps.onError })), pc.autoMode?.denialTracking, creq, inheritedStationFacts(creq));
506
494
  void settleReadRootGrant(resolved.readRootGrant, undefined, { toolName: creq.toolName, toolCallId: creq.toolCallId, sessionId, runId, ...(spec.taskId !== undefined ? { taskId: spec.taskId } : {}), onNotice: deps.onNotice });
507
495
  const askWaitMs = Math.max(0, now() - askT0);
508
496
  if (resolved.action === "deny" && resolved.approverUnavailable === true) {
@@ -570,12 +558,13 @@ export async function preparePolicyChain(input) {
570
558
  ...cardDisclosureOf(j.ask, inheritedAskFallbackMessage(creq.toolName)),
571
559
  ...askSourceIdentity(),
572
560
  ...riskAxesOf(creq),
561
+ ...approvalCardMemberOf(creq),
573
562
  ...grantBindingOf(creq, presentedArgs),
574
563
  ...(j.ask.action === "ask" && j.ask.requiresRealApproval === true ? { requiresRealApproval: true } : {}),
575
564
  ...askMandateMember(ancestorFacts(j.ask.action === "ask" ? j.ask : undefined)),
576
565
  ...inheritedAskCarry(j, isLiveApproverSeat(pc.onAsk), pc.autoMode?.denialTracking),
577
566
  ruleEvidence: inheritedAskEvidence,
578
- }, pc.onAsk, csignal ?? abortController.signal, lateAskSettlementObserver({ toolName: creq.toolName, toolCallId: creq.toolCallId, sessionId, runId, ...(spec.taskId !== undefined ? { taskId: spec.taskId } : {}), onNotice: deps.onNotice, onError: deps.onError })), pc.autoMode?.denialTracking, creq.toolName, inheritedStationFacts(creq));
567
+ }, pc.onAsk, csignal ?? abortController.signal, lateAskSettlementObserver({ toolName: creq.toolName, toolCallId: creq.toolCallId, sessionId, runId, ...(spec.taskId !== undefined ? { taskId: spec.taskId } : {}), onNotice: deps.onNotice, onError: deps.onError })), pc.autoMode?.denialTracking, creq, inheritedStationFacts(creq));
579
568
  void settleReadRootGrant(resolved.readRootGrant, undefined, { toolName: creq.toolName, toolCallId: creq.toolCallId, sessionId, runId, ...(spec.taskId !== undefined ? { taskId: spec.taskId } : {}), onNotice: deps.onNotice });
580
569
  const askWaitMs = Math.max(0, now() - askT0);
581
570
  if (resolved.action === "deny" && resolved.approverUnavailable === true) {
@@ -594,9 +583,7 @@ export async function preparePolicyChain(input) {
594
583
  }
595
584
  if (decision.updatedInput === undefined)
596
585
  return resolved;
597
- const approvedWithRewrite = { ...resolved, updatedInput: decision.updatedInput };
598
- carryEngineAttestations(resolved, approvedWithRewrite);
599
- return approvedWithRewrite;
586
+ return { ...resolved, updatedInput: decision.updatedInput };
600
587
  }));
601
588
  const rewriteCapableLayers = policy !== undefined || parentConstraintWrappers.length > 0;
602
589
  const rewriteEmitterIndex = new Map();
@@ -656,16 +643,13 @@ export async function preparePolicyChain(input) {
656
643
  const finalRead = withArgsReading(req, decision.updatedInput, signal);
657
644
  const finalReq = finalRead !== undefined ? await finalRead : { ...req, args: decision.updatedInput };
658
645
  let asked;
659
- const revalidated = {};
646
+ let revalidated;
660
647
  let restated;
661
648
  try {
662
649
  for (const layer of recheckLayers) {
663
650
  const d = refuseOutOfContractDecision(await layer.check(finalReq, signal));
664
651
  if (d.action === "deny") {
665
- const carried = { ...d, updatedInput: decision.updatedInput };
666
- carryEngineAttestations(d, carried);
667
- carryPrecedingSettlement(decision, carried);
668
- return carried;
652
+ return withAttestation({ ...d, updatedInput: decision.updatedInput }, mergeAttestation(req, attestationOf(decision, req), attestationOf(d, req), "answer"));
669
653
  }
670
654
  if (d.updatedInput !== undefined) {
671
655
  return {
@@ -678,22 +662,18 @@ export async function preparePolicyChain(input) {
678
662
  asked = d;
679
663
  if (d.action === "allow" && restated === undefined && d.decisionReason !== undefined)
680
664
  restated = d.decisionReason;
681
- carryEngineAttestations(d, revalidated);
665
+ revalidated = mergeAttestation(req, revalidated, d.attestation);
682
666
  }
683
667
  }
684
668
  finally {
685
669
  rewriteEmitterIndex.delete(req.toolCallId);
686
670
  }
687
671
  if (asked !== undefined && decision.action === "allow") {
688
- const surfaced = { ...asked, updatedInput: decision.updatedInput };
689
- carryEngineAttestations(asked, surfaced);
690
- return surfaced;
672
+ return { ...asked, updatedInput: decision.updatedInput };
691
673
  }
692
674
  if (decision.action === "allow") {
693
675
  const owned = { ...decision, ...(decision.decisionReason === undefined && restated !== undefined ? { decisionReason: restated } : {}) };
694
- carryEngineAttestations(decision, owned);
695
- carryEngineAttestations(revalidated, owned);
696
- return owned;
676
+ return withAttestation(owned, mergeAttestation(req, attestationOf(decision, req), revalidated));
697
677
  }
698
678
  return decision;
699
679
  })
@@ -62,7 +62,7 @@ export interface PrepareProjectContextInput {
62
62
  * is judged on the ALREADY-MOUNTED read face (names + aliases). */
63
63
  roster: RosterBuilder;
64
64
  /** borrowed-readonly — the frozen task-start tool face; only `exclude` is read (pair yield ①). */
65
- toolFaceSnapshot: Pick<ToolFaceSnapshot, "exclude">;
65
+ toolFaceSnapshot: Pick<ToolFaceSnapshot, "selector">;
66
66
  /** borrowed-readonly — the once-per-session announcement ledger; only its deduplicated `onError`
67
67
  * sink is invoked (a pair's mount shape is a session-level fact, announced once). */
68
68
  onceLedger: AnnounceOnceSink;
@@ -107,19 +107,18 @@ export async function prepareProjectContext(input) {
107
107
  const sharedMemoryProvider = deps.sharedMemoryStores;
108
108
  let sharedMemoryPairMounted = false;
109
109
  if (sharedMemoryProvider !== undefined) {
110
- const excluded = new Set(toolFaceSnapshot.exclude ?? []);
111
110
  const mountedNameDomain = new Set();
112
111
  for (const t of tools) {
113
112
  mountedNameDomain.add(t.name);
114
113
  for (const alias of t.aliases ?? [])
115
114
  mountedNameDomain.add(alias);
116
115
  }
117
- const excludedName = SHARED_MEMORY_TOOL_NAMES.find((n) => excluded.has(n));
116
+ const excludedName = SHARED_MEMORY_TOOL_NAMES.find((n) => !toolFaceSnapshot.selector.admits({ name: n }));
118
117
  const occupiedName = SHARED_MEMORY_TOOL_NAMES.find((n) => mountedNameDomain.has(n));
119
118
  if (excludedName !== undefined || occupiedName !== undefined) {
120
119
  onceLedger.onError(new Error(`Shared memory tools ${SHARED_MEMORY_TOOL_NAMES.join("/")} were NOT mounted: ` +
121
120
  (excludedName !== undefined
122
- ? `excludeTools removes "${excludedName}"`
121
+ ? `the run's tool selector (allowTools / excludeTools) does not admit "${excludedName}"`
123
122
  : `this task already declares a tool named "${occupiedName}" (the built-in yields to it)`) +
124
123
  " — the pair mounts together or not at all."), { phase: "config", sessionId, classification: "shared-memory-not-mounted" });
125
124
  }
@@ -139,7 +138,7 @@ export async function prepareProjectContext(input) {
139
138
  else if (memoryEngineSession !== undefined && !memorySearchToolsPlanned) {
140
139
  onceLedger.onError(new Error(`Memory tools ${MEMORY_ENGINE_TOOL_NAMES.join("/")} were NOT mounted: ` +
141
140
  (memoryPairExcludedName !== undefined
142
- ? `excludeTools removes "${memoryPairExcludedName}"`
141
+ ? `the run's tool selector (allowTools / excludeTools) does not admit "${memoryPairExcludedName}"`
143
142
  : `this task already declares a tool named "${memoryPairOccupiedName}" (the built-in yields to it)`) +
144
143
  " — these tools mount together or not at all."), { phase: "config", sessionId, classification: "memory-tools-not-mounted" });
145
144
  }
@@ -41,6 +41,12 @@ export interface PrepareProtocolToolsInput {
41
41
  * and `mcpImageResizer` ride into the MCP intake; `onError` takes the A2A warnings (no ledger — a peer is
42
42
  * re-read every prepare); `mcpRevocations` + `onNotice` make the revocation wiring. */
43
43
  deps: Pick<RunnerDeps, "onElicit" | "mcpImageResizer" | "onError" | "mcpRevocations" | "onNotice">;
44
+ /** borrowed-readonly — the run tree's MCP connection pool (the leg leases its connections from it) and whether THIS leg created it
45
+ * (then this leg's dispose also closes it). Absent for a leg that declares no server. */
46
+ mcpPool?: {
47
+ pool: import("../mcp-connection-pool.js").McpConnectionPool;
48
+ owned: boolean;
49
+ };
44
50
  /** borrowed-readonly — the leg's reminder mark (the MCP intake's disclosure bounding reads it). */
45
51
  reminderMark: string;
46
52
  /** borrowed-mutable — the reminder-disclosure counters: the MCP intake's bounding writes them here, and
@@ -66,9 +72,9 @@ export interface PrepareProtocolToolsInput {
66
72
  rosterSeat: ToolRosterDeltaSeat;
67
73
  /** borrowed-readonly — the large-result wrapper for protocol tools (per-tool `_meta` bar, 50K default). */
68
74
  remoteToolOffload: (tool: AgentTool) => AgentTool;
69
- /** borrowed-readonly — the frozen tool face; `exclude` is read at REFRESH time so a deployment-excluded
70
- * tool is never re-mounted by a model-triggered refresh. */
71
- toolFaceSnapshot: Pick<ToolFaceSnapshot, "exclude">;
75
+ /** borrowed-readonly — the frozen tool face; its selector is read at REFRESH time so a tool the leg may not use is never
76
+ * mounted by a model-triggered refresh. */
77
+ toolFaceSnapshot: Pick<ToolFaceSnapshot, "selector">;
72
78
  /** borrowed-mutable — the effect table the fold writes under a has-guard (`?? "write"` default) and the
73
79
  * refresh closure resets per prefix domain before re-folding; RefreshMcpTools registers itself `read`. */
74
80
  toolEffects: Map<string, ToolEffect>;
@@ -11,7 +11,7 @@ import { mintNamespacePrefix } from "../protocol-naming.js";
11
11
  import { applyMcpToolFaces } from "./tool-face-overlay.js";
12
12
  import { thrownText } from "../thrown-value.js";
13
13
  export async function prepareProtocolTools(input) {
14
- const { lockedPreflight, spec, deps, reminderMark, reminderDisclosureCounts, runId, sessionId, onceLedger, roster, rosterSeat, remoteToolOffload, toolFaceSnapshot, toolEffects, axisExplicitNegatives, irreversibilityTier, irreversibleTools, egressTools, toolMarkSources, abortController, rollback } = input;
14
+ const { lockedPreflight, spec, deps, mcpPool, reminderMark, reminderDisclosureCounts, runId, sessionId, onceLedger, roster, rosterSeat, remoteToolOffload, toolFaceSnapshot, toolEffects, axisExplicitNegatives, irreversibilityTier, irreversibleTools, egressTools, toolMarkSources, abortController, rollback } = input;
15
15
  const markedBy = (name, source) => {
16
16
  const set = toolMarkSources.get(name);
17
17
  if (set !== undefined)
@@ -24,7 +24,7 @@ export async function prepareProtocolTools(input) {
24
24
  throw Object.assign(new Error(`MCP server name ${JSON.stringify(overPeer.name.slice(0, 40) + "…")} is ${overPeer.name.length} characters; a peer rides every roster row of its tools and the roster's bound on a name is ${TOOL_WIRE_NAME_MAX_CHARS}.`), { code: "config.tool_name_too_long" });
25
25
  }
26
26
  const mcp = lockedPreflight.mcp?.length
27
- ? await materializeMcpTools(lockedPreflight.mcp, spec.principal, deps.onElicit, deps.mcpImageResizer, { reminderMark, counts: reminderDisclosureCounts }, mcpRevocationWiring(deps, runId))
27
+ ? await materializeMcpTools(lockedPreflight.mcp, spec.principal, deps.onElicit, deps.mcpImageResizer, { reminderMark, counts: reminderDisclosureCounts }, mcpRevocationWiring(deps, runId), mcpPool === undefined ? undefined : { pool: mcpPool.pool, ownsPool: mcpPool.owned })
28
28
  :
29
29
  { tools: [], toolAxes: [], warnings: [], serverInstructions: [], instructionsDelta: { pendingAdds: [], pendingRemovals: [] }, droppedTools: [], statuses: [], refresh: async () => [], reconnect: async (server) => ({ server, prefix: mintNamespacePrefix(MCP_NAMESPACE, server), outcome: "not_declared", reason: "this task declared no MCP servers", toolCount: 0, added: [], removed: [] }), dispose: async () => { } };
30
30
  if (lockedPreflight.mcp?.length)
@@ -87,7 +87,6 @@ export async function prepareProtocolTools(input) {
87
87
  const lines = [];
88
88
  let changed = false;
89
89
  let anyActiveFailure = false;
90
- const excludedSet = new Set(toolFaceSnapshot.exclude ?? []);
91
90
  for (const r of results) {
92
91
  if (r.tools === undefined) {
93
92
  lines.push(`${r.server}: ${r.status}${r.error !== undefined ? ` (${r.error})` : ""}`);
@@ -103,7 +102,7 @@ export async function prepareProtocolTools(input) {
103
102
  }
104
103
  changed = true;
105
104
  const detail = [];
106
- const shownAdded = r.added.filter((n) => !excludedSet.has(n));
105
+ const shownAdded = r.added.filter((n) => !applied.excluded.includes(n));
107
106
  if (shownAdded.length > 0)
108
107
  detail.push(`added: ${shownAdded.join(", ")}`);
109
108
  if (r.removed.length > 0)
@@ -23,6 +23,7 @@ import { SkillGrantTable } from "../skill-grant.js";
23
23
  import type { Prepared, RunInternals, ToolProgressLane } from "./contracts.js";
24
24
  import type { PermissionModeController } from "../mode-policy.js";
25
25
  import { type EditedFilesLedger } from "./edited-files-ledger.js";
26
+ import { type ToolOccurrenceTable } from "./tool-occurrence.js";
26
27
  export interface PrepareRunRefsInput {
27
28
  /** borrowed-readonly — the REBOUND spec. Read: `forwardSubagentEvents` (widens the forwarding filter),
28
29
  * `retainSubagentSessions` (the ledger opt-in and its config), `handsReadOnly` (a read-only run mints no
@@ -63,6 +64,8 @@ export interface PrepareRunRefsResult {
63
64
  toolProgressRef: {
64
65
  current?: ToolProgressLane;
65
66
  };
67
+ /** borrowed-mutable — the leg's occurrence table (`Prepared.toolOccurrences`), minted before the band that writes it. */
68
+ toolOccurrences: ToolOccurrenceTable;
66
69
  /** borrowed-mutable — the per-task skill grant table (its rows live for this run). Writers: the project-context phase (the
67
70
  * parent's captured rows, the person's invoked skills) and the `Skill` tool minted over it (a successful activation).
68
71
  * Readers: the tool ctx's `activeSkillGrants()` capture and the gate's skill lane. */
@@ -3,6 +3,7 @@ import { SubagentRetainLedger } from "../../agents/retain-ledger.js";
3
3
  import { SkillGrantTable } from "../skill-grant.js";
4
4
  import { forwardSafely } from "./forward-sink.js";
5
5
  import { createEditedFilesLedger } from "./edited-files-ledger.js";
6
+ import { createToolOccurrenceTable } from "./tool-occurrence.js";
6
7
  export function forwardsSubagentEvents(spec) {
7
8
  return spec.forwardSubagentEvents === true;
8
9
  }
@@ -48,5 +49,5 @@ export function prepareRunRefs(input) {
48
49
  };
49
50
  const subagentRetain = spec.retainSubagentSessions ? new SubagentRetainLedger(spec.retainSubagentSessions) : undefined;
50
51
  const worktreeIsolation = spec.handsReadOnly !== true ? createSubagentWorktreeHelper(executionEnv, taskRootFinal) : undefined;
51
- return { noteFileEdited, editedFilesSnapshot, harnessRef, toolProgressRef, skillGrants, forwardEvent, reviewRequestRef, requestReview, stopRequestedRef, requestStopAfterTurn, bindPermissionModeSeat, enterPlanMode, subagentRetain, worktreeIsolation };
52
+ return { noteFileEdited, editedFilesSnapshot, harnessRef, toolProgressRef, toolOccurrences: createToolOccurrenceTable(), skillGrants, forwardEvent, reviewRequestRef, requestReview, stopRequestedRef, requestStopAfterTurn, bindPermissionModeSeat, enterPlanMode, subagentRetain, worktreeIsolation };
52
53
  }
@@ -1,10 +1,11 @@
1
- import type { RunnerDeps, TaskSpec, ToolEffect } from "../types.js";
1
+ import type { RunnerDeps, ToolEffect } from "../types.js";
2
2
  import type { IrreversibilityTier, ReversibilityProbes } from "./contracts.js";
3
3
  import type { ToolMarkSource } from "../ask-origin.js";
4
+ import type { RosterSpec } from "./caller-roster.js";
4
5
  export interface PrepareSafetyScanInput {
5
6
  /** borrowed-readonly — the REBOUND spec (`spec′`, the config-doors result). The scan reads
6
- * `tools`, `handsReadOnly` and `enablePlanMode`; it never mutates. */
7
- spec: TaskSpec;
7
+ * `tools`, `handsReadOnly` and `enablePlanMode`; it never mutates. Typed as a spec whose roster is snapshot faces. */
8
+ spec: RosterSpec;
8
9
  /** borrowed-readonly — read only for the hands-enablement fact (`executionEnvFactory`/
9
10
  * `executionEnv` presence gates the hand-band effect preseed). */
10
11
  deps: RunnerDeps;
@@ -12,9 +13,6 @@ export interface PrepareSafetyScanInput {
12
13
  /**
13
14
  * The scan's outputs. Ownership annotations (four-class form):
14
15
  *
15
- * `ownToolNames` is **borrowed-readonly** — a first-await snapshot with no mutation anywhere after
16
- * the scan (sandbox containment reads the env-hand roster, not this set).
17
- *
18
16
  * The six collections are **borrowed-mutable**: the driver and later phases fold into them IN
19
17
  * PLACE (identity is part of the contract — closures alias these exact objects). Mutation owners
20
18
  * after this phase, in driver order:
@@ -47,8 +45,6 @@ export interface PrepareSafetyScanResult {
47
45
  * the deployment's own; the protocol fold adds `mcp_annotation` / `a2a_default`). Read by the gate's class
48
46
  * derivation: a mark with no recorded source reads as the deployment's (fail-closed). */
49
47
  toolMarkSources: Map<string, Set<ToolMarkSource>>;
50
- /** borrowed-readonly — the caller roster's own names, snapshotted before the first await. */
51
- ownToolNames: ReadonlySet<string>;
52
48
  }
53
49
  /** The B-2 phase body — the safety-scan slice, verbatim (see the module header for the contract). */
54
50
  export declare function prepareSafetyScan(input: PrepareSafetyScanInput): PrepareSafetyScanResult;
@@ -51,7 +51,7 @@ export function prepareSafetyScan(input) {
51
51
  ...(t.ruleFace !== undefined ? { ruleFace: t.ruleFace } : {}),
52
52
  ...(t.renderHints !== undefined ? { renderHints: t.renderHints } : {}),
53
53
  };
54
- const faceProblem = toolFaceProblem(declared, t.parameters);
54
+ const faceProblem = toolFaceProblem(declared, t.parameters, { toolName: t.name });
55
55
  if (faceProblem !== undefined) {
56
56
  const e = new Error(`Tool "${t.name}" declares a face its schema cannot carry: ${faceProblem}.`);
57
57
  e.code = "config.tool_face_invalid";
@@ -145,6 +145,5 @@ export function prepareSafetyScan(input) {
145
145
  axisExplicitNegatives,
146
146
  reversibilityProbes,
147
147
  toolMarkSources,
148
- ownToolNames,
149
148
  };
150
149
  }
@@ -19,7 +19,7 @@
19
19
  import type { AgentHarness, ExecutionEnv } from "../../internal/harness.js";
20
20
  import type { OwnOrgAdmissionVerdict } from "../memory-admission.js";
21
21
  import type { RemoteExecutionEnv, SnapshotId } from "../remote-env.js";
22
- import type { CheckpointStore, SerializedCheckpointState } from "../checkpoint-store.js";
22
+ import { type CheckpointStore, type SerializedCheckpointState } from "../checkpoint-store.js";
23
23
  import type { RemoteEnvFailureNote, RunnerDeps } from "../types.js";
24
24
  import type { CwdRef } from "../../tools/fs/fs-shared.js";
25
25
  import type { ReadFileState } from "../../tools/fs/safety.js";
@@ -165,6 +165,12 @@ export interface PrepareSuspendSagaInput {
165
165
  hookIdentity: Pick<HookInvocationIdentity, "isDelegatedChild">;
166
166
  /** borrowed-readonly — the frozen prepare-time placement resolution (the row's placement stamp). */
167
167
  placementRootResolved: string;
168
+ /** borrowed-readonly — this leg's checkpoint scope (the driver's one `checkpointScopeOf` derivation; the row's `legScope` stamp). */
169
+ checkpointScope: string;
170
+ /** borrowed-readonly — the tool-selector layers this leg was spawned under (the live seat, else the resumed row's), the row's `toolCeiling` stamp. */
171
+ toolCeiling: readonly import("../tool-face.js").ToolSelectorLayer[] | undefined;
172
+ /** borrowed-readonly — the spawning run's judgment of this leg's own lists, while it is bound to them (`boundToolListsJudgment`), the row's `toolListsJudged` stamp. */
173
+ toolListsJudged: string | undefined;
168
174
  /** borrowed-readonly — the external-content-target fold (the row's monotonic bit). */
169
175
  externalContentTargetActive: boolean;
170
176
  /** borrowed-mutable — the run-scoped remote-lifecycle failure log (`Prepared.remoteEnvFailures`). Writer here: the
@@ -1,5 +1,7 @@
1
1
  import { defaultTaskRegistry } from "../task-registry.js";
2
2
  import { isRemoteExecutionEnv, isSuspendable, RemoteExecutionError } from "../remote-env.js";
3
+ import { resolveDeclaredFidelity } from "../checkpoint-store.js";
4
+ import { judgeAsStored, stampCheckpointRequirements } from "../checkpoint-requirements.js";
3
5
  import { constraintChainDigest, constraintChainEntryOfLayer } from "../tool-policy.js";
4
6
  import { raceSettlementAgainstSignal } from "./abort-race.js";
5
7
  import { placementValueOrAbsent } from "./checkpoint-scope.js";
@@ -79,7 +81,7 @@ function stampPlacementRootSessionId(placementRootResolved) {
79
81
  return placementValueOrAbsent(placementRootResolved);
80
82
  }
81
83
  export function prepareSuspendSaga(input) {
82
- const { gateMachineryActive, abortController, harness, checkpointStore, deps, sessionId, hostTaskId, taskScope, liveSpendRef, resume, nestedStats, internals, activeTools, outputRef, readFileStateForCheckpoint, faceCheckpointSection, writeFaceCheckpointSection, skillGrantCheckpointSection, reminderMark, handsCwdRef, handsRoot, handsHome, worktreeSessionRef, undeliveredContinuationRef, inheritedParentConstraints, seedInheritedGate, ancestorRulesNow, inheritedShellGate, permissionMode, inheritedAdmittedOrgScopes, inheritedPathRuleAnchors, inheritedPathRuleInstallations, ownOrgVerdictRef, orgGovernedProvenance, announcedListingsRef, gitStatusRef, hookIdentity, placementRootResolved, externalContentTargetActive, remoteEnvFailures, memoryEngineSession, suspendLoopRef, ownedEnv, incompleteSuspendAdapter } = input;
84
+ const { gateMachineryActive, abortController, harness, checkpointStore, deps, sessionId, hostTaskId, taskScope, liveSpendRef, resume, nestedStats, internals, activeTools, outputRef, readFileStateForCheckpoint, faceCheckpointSection, writeFaceCheckpointSection, skillGrantCheckpointSection, reminderMark, handsCwdRef, handsRoot, handsHome, worktreeSessionRef, undeliveredContinuationRef, inheritedParentConstraints, seedInheritedGate, ancestorRulesNow, inheritedShellGate, permissionMode, inheritedAdmittedOrgScopes, inheritedPathRuleAnchors, inheritedPathRuleInstallations, ownOrgVerdictRef, orgGovernedProvenance, announcedListingsRef, gitStatusRef, hookIdentity, placementRootResolved, checkpointScope, toolCeiling, toolListsJudged, externalContentTargetActive, remoteEnvFailures, memoryEngineSession, suspendLoopRef, ownedEnv, incompleteSuspendAdapter } = input;
83
85
  if (!gateMachineryActive)
84
86
  return { saga: undefined };
85
87
  const inFlightSpendMicroUsd = () => {
@@ -175,6 +177,9 @@ export function prepareSuspendSaga(input) {
175
177
  isDelegatedChild: hookIdentity.isDelegatedChild ? true : undefined,
176
178
  placementRootSessionId: stampPlacementRootSessionId(placementRootResolved),
177
179
  externalContentTarget: externalContentTargetActive ? true : undefined,
180
+ legScope: checkpointScope,
181
+ toolCeiling: toolCeiling !== undefined ? toolCeiling.map((l) => ({ ...(l.allow !== undefined ? { allow: [...l.allow] } : {}), deny: [...l.deny] })) : undefined,
182
+ toolListsJudged,
178
183
  });
179
184
  const compensatePausedVM = (remoteEnv, snapshotId) => compensateUnparkedPause(remoteEnv, snapshotId, {
180
185
  boundMs: PARK_COMPENSATION_TIMEOUT_MS,
@@ -237,13 +242,33 @@ export function prepareSuspendSaga(input) {
237
242
  return "unknown";
238
243
  }
239
244
  };
245
+ const compensateNotWritten = async (reason) => {
246
+ if (remoteEnv !== undefined && remoteHandle?.snapshotId !== undefined) {
247
+ const back = await compensatePausedVM(remoteEnv, remoteHandle.snapshotId);
248
+ if (back.ok)
249
+ return { tag: "absent", reason };
250
+ abortController.abort();
251
+ void harness.abort();
252
+ return { tag: "compensation_failed", reason };
253
+ }
254
+ return { tag: "absent", reason };
255
+ };
256
+ let putAttempted = false;
240
257
  try {
241
- await checkpointStore.put(token, cp);
258
+ const fidelity = resolveDeclaredFidelity(checkpointStore, "checkpointStore");
259
+ const stamped = stampCheckpointRequirements(cp, fidelity);
260
+ const own = judgeAsStored(stamped, fidelity);
261
+ if (own.kind !== "ok")
262
+ throw new Error(`the checkpoint row was not written: ${own.kind === "damaged" ? own.why : "it lists words this engine lacks"}`);
263
+ putAttempted = true;
264
+ await checkpointStore.put(token, stamped);
242
265
  announceCommittedScreeningPark();
243
266
  return { tag: "committed" };
244
267
  }
245
268
  catch (putErr) {
246
269
  deps.onError?.(putErr, { phase: "config", sessionId });
270
+ if (!putAttempted)
271
+ return compensateNotWritten("the approval checkpoint was not written (the row failed its own requirement judge before the write; the deployment's error face carries why)");
247
272
  const confirmed = await confirmPutOutcome(putErr);
248
273
  if (confirmed === "committed") {
249
274
  try {
@@ -273,16 +298,7 @@ export function prepareSuspendSaga(input) {
273
298
  void harness.abort();
274
299
  return { tag: "unknown", reason: unknownReason };
275
300
  }
276
- const reason = "the approval checkpoint could not be persisted (the store rejected the write; the deployment's error face carries the store's own message)";
277
- if (remoteEnv !== undefined && remoteHandle?.snapshotId !== undefined) {
278
- const back = await compensatePausedVM(remoteEnv, remoteHandle.snapshotId);
279
- if (back.ok)
280
- return { tag: "absent", reason };
281
- abortController.abort();
282
- void harness.abort();
283
- return { tag: "compensation_failed", reason };
284
- }
285
- return { tag: "absent", reason };
301
+ return compensateNotWritten("the approval checkpoint could not be persisted (the store rejected the write; the deployment's error face carries the store's own message)");
286
302
  }
287
303
  };
288
304
  const suspendLoopCapHit = (count, cap, detail) => {
@@ -103,7 +103,7 @@ export declare function effectiveDelegationFacts(internals: Pick<RunInternals, "
103
103
  * hooks + external-signal cancellation, and sets up the cache-break detector. **No run-loop control
104
104
  * flow** lives here — that stays in the Runner loop.
105
105
  */
106
- export declare function prepareTask(spec: TaskSpec, deps: RunnerDeps, sessions: SessionStore, resume?: PrepareResume, internals?: RunInternals,
106
+ export declare function prepareTask(request: TaskSpec, deps: RunnerDeps, sessions: SessionStore, resume?: PrepareResume, internals?: RunInternals,
107
107
  /** A TRUSTED self-reference to the Runner, passed by the Runner itself (never a
108
108
  * TaskSpec field) so the `run_workflow` tool can execute child tasks via `runner.runTask`. Undefined when
109
109
  * prepareTask is exercised standalone (then run_workflow is simply not mounted). */