@sema-agent/core 7.57.0 → 7.59.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (399) hide show
  1. package/CHANGELOG.md +1161 -0
  2. package/README.md +6 -4
  3. package/dist/agents/cc-peer-directory.js +8 -8
  4. package/dist/agents/child-model-seat.d.ts +4 -2
  5. package/dist/agents/child-model-seat.js +5 -3
  6. package/dist/agents/peer-directory.d.ts +9 -0
  7. package/dist/agents/peer-directory.js +6 -2
  8. package/dist/agents/send-message-tool.js +21 -12
  9. package/dist/agents/subagent-steps.js +2 -4
  10. package/dist/agents/subagent.js +33 -34
  11. package/dist/brain/anthropic.js +161 -45
  12. package/dist/brain/errors.d.ts +9 -3
  13. package/dist/brain/errors.js +7 -1
  14. package/dist/brain/failover.js +2 -1
  15. package/dist/brain/open-responses.js +3 -3
  16. package/dist/brain/openai.js +103 -53
  17. package/dist/brain/provider-dialect.d.ts +11 -0
  18. package/dist/brain/provider-dialect.js +5 -2
  19. package/dist/brain/reasoning-request.js +5 -4
  20. package/dist/brain/reasoning.d.ts +19 -0
  21. package/dist/brain/reasoning.js +17 -2
  22. package/dist/brain/request-route.d.ts +4 -1
  23. package/dist/brain/request-route.js +4 -1
  24. package/dist/brain/route-adjudicator.d.ts +84 -18
  25. package/dist/brain/route-adjudicator.js +89 -22
  26. package/dist/brain/route-conformance.js +1 -1
  27. package/dist/brain/stream-engine.js +84 -49
  28. package/dist/brain/stream-shared.d.ts +30 -0
  29. package/dist/brain/stream-shared.js +34 -1
  30. package/dist/brain/timeout.d.ts +62 -5
  31. package/dist/brain/timeout.js +93 -6
  32. package/dist/core/a2a.d.ts +2 -1
  33. package/dist/core/a2a.js +23 -10
  34. package/dist/core/account-row.d.ts +61 -0
  35. package/dist/core/account-row.js +51 -0
  36. package/dist/core/advisor-verdict.d.ts +2 -1
  37. package/dist/core/advisor-verdict.js +1 -1
  38. package/dist/core/allow-entry.d.ts +20 -7
  39. package/dist/core/allow-entry.js +18 -9
  40. package/dist/core/approval-object.d.ts +29 -15
  41. package/dist/core/approval-object.js +47 -19
  42. package/dist/core/ask-origin.d.ts +21 -2
  43. package/dist/core/ask-origin.js +5 -1
  44. package/dist/core/auto-compaction.d.ts +4 -0
  45. package/dist/core/auto-compaction.js +2 -2
  46. package/dist/core/auto-mode-directive.d.ts +29 -5
  47. package/dist/core/auto-mode-directive.js +38 -8
  48. package/dist/core/background-agent-store.d.ts +16 -3
  49. package/dist/core/checkpoint-requirements.d.ts +19 -1
  50. package/dist/core/checkpoint-requirements.js +5 -1
  51. package/dist/core/checkpoint-store.d.ts +85 -23
  52. package/dist/core/checkpoint-store.js +31 -9
  53. package/dist/core/child-clamp-seats.d.ts +29 -0
  54. package/dist/core/child-clamp-seats.js +56 -1
  55. package/dist/core/compliance.d.ts +2 -2
  56. package/dist/core/compliance.js +1 -1
  57. package/dist/core/effective-path-target.d.ts +8 -2
  58. package/dist/core/effective-path-target.js +8 -3
  59. package/dist/core/engine-notice.d.ts +99 -9
  60. package/dist/core/engine-notice.js +19 -5
  61. package/dist/core/fs-write-gate-policy.d.ts +4 -2
  62. package/dist/core/fs-write-gate-policy.js +7 -3
  63. package/dist/core/gate-fold.js +7 -4
  64. package/dist/core/gate-lanes.js +19 -6
  65. package/dist/core/gate-outcome.d.ts +32 -3
  66. package/dist/core/gate-outcome.js +19 -1
  67. package/dist/core/git-worktree-env.d.ts +53 -11
  68. package/dist/core/git-worktree-env.js +96 -12
  69. package/dist/core/governance-codes.d.ts +9 -1
  70. package/dist/core/governance-codes.js +13 -0
  71. package/dist/core/hooks.d.ts +35 -4
  72. package/dist/core/hooks.js +17 -11
  73. package/dist/core/human-input-projection.d.ts +1 -0
  74. package/dist/core/human-input-projection.js +3 -0
  75. package/dist/core/image-admission.d.ts +6 -5
  76. package/dist/core/image-admission.js +18 -14
  77. package/dist/core/locked-config.d.ts +20 -3
  78. package/dist/core/locked-config.js +40 -3
  79. package/dist/core/mailbox-store.d.ts +45 -1
  80. package/dist/core/mailbox-store.js +53 -9
  81. package/dist/core/mcp-call-meta.d.ts +66 -0
  82. package/dist/core/mcp-call-meta.js +103 -0
  83. package/dist/core/mcp-connection-pool.d.ts +3 -1
  84. package/dist/core/mcp-connection-pool.js +3 -1
  85. package/dist/core/mcp-failure.d.ts +117 -15
  86. package/dist/core/mcp-failure.js +71 -3
  87. package/dist/core/mcp-probe.d.ts +4 -0
  88. package/dist/core/mcp-probe.js +1 -1
  89. package/dist/core/mcp-server-link.d.ts +27 -3
  90. package/dist/core/mcp-server-link.js +25 -1
  91. package/dist/core/mcp-server-spec.d.ts +46 -18
  92. package/dist/core/mcp-server-spec.js +1 -18
  93. package/dist/core/mcp.d.ts +16 -20
  94. package/dist/core/mcp.js +112 -55
  95. package/dist/core/memory-engine/consolidation-driver.d.ts +2 -4
  96. package/dist/core/memory-engine/consolidation-driver.js +3 -3
  97. package/dist/core/memory-engine/consolidation.d.ts +4 -0
  98. package/dist/core/memory-engine/consolidation.js +1 -0
  99. package/dist/core/memory-engine/delegation-settlement.js +5 -12
  100. package/dist/core/memory-engine/distiller.js +2 -2
  101. package/dist/core/memory-engine/dual-root.d.ts +50 -1
  102. package/dist/core/memory-engine/dual-root.js +44 -1
  103. package/dist/core/memory-engine/engine.d.ts +67 -14
  104. package/dist/core/memory-engine/engine.js +384 -212
  105. package/dist/core/memory-engine/export-bundle.d.ts +23 -0
  106. package/dist/core/memory-engine/export-bundle.js +23 -4
  107. package/dist/core/memory-engine/file-backend.d.ts +128 -55
  108. package/dist/core/memory-engine/file-backend.js +290 -117
  109. package/dist/core/memory-engine/index.d.ts +1 -1
  110. package/dist/core/memory-engine/layout.d.ts +59 -11
  111. package/dist/core/memory-engine/layout.js +190 -40
  112. package/dist/core/memory-engine/memory-backend-contract.d.ts +1 -1
  113. package/dist/core/memory-engine/memory-backend-contract.js +39 -2
  114. package/dist/core/memory-engine/scope-contract.d.ts +45 -4
  115. package/dist/core/memory-engine/scope-contract.js +80 -11
  116. package/dist/core/memory-engine/sync-client.d.ts +9 -1
  117. package/dist/core/memory-engine/sync-client.js +31 -8
  118. package/dist/core/memory-engine/sync.d.ts +5 -0
  119. package/dist/core/memory-engine/types.d.ts +6 -0
  120. package/dist/core/mode-policy.d.ts +8 -5
  121. package/dist/core/mode-policy.js +5 -4
  122. package/dist/core/mods/classic-events.d.ts +5 -1
  123. package/dist/core/mods/host.js +1 -1
  124. package/dist/core/mods/kernel/dispatch.d.ts +3 -0
  125. package/dist/core/mods/kernel/dispatch.js +12 -9
  126. package/dist/core/mods/kernel/events.d.ts +6 -1
  127. package/dist/core/mods/kernel/events.js +2 -2
  128. package/dist/core/mods/kernel/registration.d.ts +9 -1
  129. package/dist/core/mods/kernel/registration.js +3 -0
  130. package/dist/core/mods/kernel/site-rules.d.ts +3 -0
  131. package/dist/core/mods/kernel/site-rules.js +10 -0
  132. package/dist/core/mods/package.d.ts +23 -0
  133. package/dist/core/mods/package.js +118 -0
  134. package/dist/core/mods/stations.d.ts +33 -12
  135. package/dist/core/mods/stations.js +45 -11
  136. package/dist/core/mods/tool-call.d.ts +5 -1
  137. package/dist/core/mods/tool-call.js +13 -4
  138. package/dist/core/parent-spec-seat.d.ts +8 -3
  139. package/dist/core/parent-spec-seat.js +2 -0
  140. package/dist/core/park-selfcheck.js +6 -0
  141. package/dist/core/path-guard-rows.d.ts +20 -0
  142. package/dist/core/path-guard-rows.js +11 -0
  143. package/dist/core/peer-seat.d.ts +248 -0
  144. package/dist/core/peer-seat.js +439 -0
  145. package/dist/core/permission-rule-consent.js +10 -4
  146. package/dist/core/permission-rule-model.d.ts +16 -0
  147. package/dist/core/permission-rule-model.js +1 -1
  148. package/dist/core/present-plan-tool.d.ts +20 -3
  149. package/dist/core/present-plan-tool.js +48 -4
  150. package/dist/core/protocol-http-auth.d.ts +40 -29
  151. package/dist/core/protocol-http-auth.js +30 -32
  152. package/dist/core/redaction-marks.d.ts +16 -0
  153. package/dist/core/redaction-marks.js +16 -0
  154. package/dist/core/redaction-passes.js +8 -9
  155. package/dist/core/resume-startup-cause.js +1 -0
  156. package/dist/core/retention.d.ts +41 -15
  157. package/dist/core/retention.js +59 -12
  158. package/dist/core/rewrite-rejudge.d.ts +38 -0
  159. package/dist/core/rewrite-rejudge.js +42 -2
  160. package/dist/core/roles.d.ts +34 -2
  161. package/dist/core/roles.js +43 -4
  162. package/dist/core/run-origin.d.ts +40 -0
  163. package/dist/core/run-origin.js +37 -0
  164. package/dist/core/runner/advertised-writable-dirs.d.ts +57 -38
  165. package/dist/core/runner/advertised-writable-dirs.js +126 -0
  166. package/dist/core/runner/announce-once-ledger.d.ts +5 -4
  167. package/dist/core/runner/announce-once-ledger.js +4 -2
  168. package/dist/core/runner/call-hook-stations.js +2 -2
  169. package/dist/core/runner/compaction-restate.d.ts +15 -6
  170. package/dist/core/runner/compaction-restate.js +28 -2
  171. package/dist/core/runner/contracts.d.ts +33 -21
  172. package/dist/core/runner/credential-origin-seat.js +4 -3
  173. package/dist/core/runner/cwd-alignment-probe.d.ts +20 -0
  174. package/dist/core/runner/cwd-alignment-probe.js +21 -0
  175. package/dist/core/runner/decide-continuation.d.ts +2 -2
  176. package/dist/core/runner/gate-exit.d.ts +30 -8
  177. package/dist/core/runner/gate-exit.js +15 -8
  178. package/dist/core/runner/image-removed-seat.d.ts +12 -0
  179. package/dist/core/runner/image-removed-seat.js +19 -0
  180. package/dist/core/runner/inline-image.js +1 -1
  181. package/dist/core/runner/memory-consolidation-driver.js +3 -3
  182. package/dist/core/runner/park-commit.d.ts +1 -1
  183. package/dist/core/runner/park-commit.js +3 -0
  184. package/dist/core/runner/prepare-ask-lane.d.ts +1 -1
  185. package/dist/core/runner/prepare-ask-lane.js +2 -1
  186. package/dist/core/runner/prepare-boundary-parks.js +2 -2
  187. package/dist/core/runner/prepare-caps-and-workflow.d.ts +5 -5
  188. package/dist/core/runner/prepare-caps-and-workflow.js +3 -1
  189. package/dist/core/runner/prepare-config-doors.d.ts +8 -5
  190. package/dist/core/runner/prepare-config-doors.js +14 -10
  191. package/dist/core/runner/prepare-context-lane.js +2 -0
  192. package/dist/core/runner/prepare-delegation-surface.d.ts +8 -0
  193. package/dist/core/runner/prepare-delegation-surface.js +16 -18
  194. package/dist/core/runner/prepare-gate-stations.js +1 -1
  195. package/dist/core/runner/prepare-hands-readface.d.ts +11 -3
  196. package/dist/core/runner/prepare-hands-readface.js +9 -1
  197. package/dist/core/runner/prepare-inherited-gate.d.ts +1 -3
  198. package/dist/core/runner/prepare-inherited-gate.js +14 -27
  199. package/dist/core/runner/prepare-memory.d.ts +3 -0
  200. package/dist/core/runner/prepare-memory.js +26 -37
  201. package/dist/core/runner/prepare-park-ask.d.ts +1 -1
  202. package/dist/core/runner/prepare-park-ask.js +2 -1
  203. package/dist/core/runner/prepare-policy-chain.d.ts +7 -7
  204. package/dist/core/runner/prepare-policy-chain.js +18 -15
  205. package/dist/core/runner/prepare-project-context.d.ts +2 -2
  206. package/dist/core/runner/prepare-project-context.js +2 -2
  207. package/dist/core/runner/prepare-prompt-inputs.d.ts +1 -1
  208. package/dist/core/runner/prepare-prompt-inputs.js +8 -19
  209. package/dist/core/runner/prepare-protocol-tools.d.ts +4 -2
  210. package/dist/core/runner/prepare-protocol-tools.js +11 -3
  211. package/dist/core/runner/prepare-run-refs.d.ts +2 -3
  212. package/dist/core/runner/prepare-run-refs.js +4 -1
  213. package/dist/core/runner/prepare-suspend-saga.d.ts +2 -0
  214. package/dist/core/runner/prepare-suspend-saga.js +2 -1
  215. package/dist/core/runner/prepare-task.js +28 -13
  216. package/dist/core/runner/prepare-wiring-manifest.d.ts +2 -1
  217. package/dist/core/runner/prepare-wiring-manifest.js +4 -3
  218. package/dist/core/runner/prepare-workspace-restore.d.ts +3 -0
  219. package/dist/core/runner/prepare-workspace-restore.js +4 -4
  220. package/dist/core/runner/reply-pricing.d.ts +30 -0
  221. package/dist/core/runner/reply-pricing.js +19 -0
  222. package/dist/core/runner/resume-admission.js +5 -3
  223. package/dist/core/runner/resume-apply.js +6 -1
  224. package/dist/core/runner/resume-checkpoint-screen.js +2 -0
  225. package/dist/core/runner/resume-policy-outcome.js +5 -5
  226. package/dist/core/runner/role-seat-defaulted.d.ts +44 -0
  227. package/dist/core/runner/role-seat-defaulted.js +40 -0
  228. package/dist/core/runner/run-brain-sinks.js +2 -0
  229. package/dist/core/runner/run-harness-handlers.d.ts +3 -4
  230. package/dist/core/runner/run-harness-handlers.js +1 -8
  231. package/dist/core/runner/run-identity-wiring.d.ts +2 -5
  232. package/dist/core/runner/run-identity-wiring.js +6 -4
  233. package/dist/core/runner/run-leg.d.ts +2 -0
  234. package/dist/core/runner/run-leg.js +42 -29
  235. package/dist/core/runner/run-notification-lane.js +3 -0
  236. package/dist/core/runner/run-stop-and-final-verify.js +2 -2
  237. package/dist/core/runner/run-terminal-adoption.d.ts +2 -5
  238. package/dist/core/runner/run-terminal-adoption.js +9 -3
  239. package/dist/core/runner/run-turn-boundary.js +77 -70
  240. package/dist/core/runner/runtask.d.ts +1 -1
  241. package/dist/core/runner/runtask.js +2 -2
  242. package/dist/core/runner/side-call-account.d.ts +1 -1
  243. package/dist/core/runner/side-call-account.js +3 -18
  244. package/dist/core/runner/sub-agent-deny-lists.d.ts +24 -0
  245. package/dist/core/runner/sub-agent-deny-lists.js +10 -0
  246. package/dist/core/runner/terminal-account.js +3 -3
  247. package/dist/core/runner/tool-end-body.js +2 -1
  248. package/dist/core/runner/tool-occurrence.d.ts +5 -2
  249. package/dist/core/runner/tool-occurrence.js +4 -3
  250. package/dist/core/runner/turn-attachments.d.ts +26 -22
  251. package/dist/core/runner/turn-attachments.js +24 -26
  252. package/dist/core/runner/write-protection-station.d.ts +8 -2
  253. package/dist/core/runner/write-protection-station.js +2 -0
  254. package/dist/core/runner-deps.d.ts +3 -3
  255. package/dist/core/secret-env.d.ts +32 -2
  256. package/dist/core/secret-env.js +65 -3
  257. package/dist/core/sensitive-path-policy.js +9 -10
  258. package/dist/core/session-log-transfer.d.ts +24 -0
  259. package/dist/core/session-log-transfer.js +166 -0
  260. package/dist/core/session-policy-store.d.ts +3 -1
  261. package/dist/core/session-policy-store.js +13 -9
  262. package/dist/core/session-store.d.ts +86 -24
  263. package/dist/core/session-store.js +162 -24
  264. package/dist/core/session.d.ts +92 -1
  265. package/dist/core/shell-read-silence.js +1 -0
  266. package/dist/core/side-query.d.ts +11 -1
  267. package/dist/core/side-query.js +9 -0
  268. package/dist/core/skill-grant-binding.d.ts +31 -2
  269. package/dist/core/skill-grant-binding.js +31 -1
  270. package/dist/core/skill-grant.d.ts +8 -5
  271. package/dist/core/skill-grant.js +6 -6
  272. package/dist/core/steer-replay.d.ts +4 -2
  273. package/dist/core/steer-replay.js +2 -1
  274. package/dist/core/store-contracts/background-agent-store-contract.js +27 -0
  275. package/dist/core/store-contracts/checkpoint-store-contract.js +20 -2
  276. package/dist/core/store-contracts/mailbox-store-contract.js +31 -1
  277. package/dist/core/store-contracts/session-repo-contract.js +112 -5
  278. package/dist/core/store-contracts/session-store-contract.d.ts +4 -1
  279. package/dist/core/store-contracts/session-store-contract.js +236 -2
  280. package/dist/core/synthetic-read-verdict.js +2 -1
  281. package/dist/core/task-event.d.ts +92 -8
  282. package/dist/core/task-notification.js +16 -10
  283. package/dist/core/task-registry-agent.js +1 -0
  284. package/dist/core/task-registry-shared.d.ts +7 -1
  285. package/dist/core/task-spec.d.ts +49 -1
  286. package/dist/core/task-stream.d.ts +2 -1
  287. package/dist/core/terminal-cause.d.ts +11 -1
  288. package/dist/core/tool-catalog-entries.js +1 -0
  289. package/dist/core/tool-check-reading.d.ts +1 -0
  290. package/dist/core/tool-check-reading.js +3 -3
  291. package/dist/core/tool-policy.d.ts +16 -0
  292. package/dist/core/tool-result-store.d.ts +17 -10
  293. package/dist/core/tool-result-store.js +3 -1
  294. package/dist/core/tool-roster.d.ts +112 -5
  295. package/dist/core/tool-roster.js +42 -1
  296. package/dist/core/tool-spec.d.ts +3 -1
  297. package/dist/core/types.d.ts +3 -3
  298. package/dist/core/types.js +1 -1
  299. package/dist/core/untrusted-egress.d.ts +0 -2
  300. package/dist/core/untrusted-egress.js +10 -14
  301. package/dist/core/user-attachment.js +1 -1
  302. package/dist/core/wiring-manifest.d.ts +18 -6
  303. package/dist/core/wiring-manifest.js +4 -3
  304. package/dist/core/workspace-snapshot.d.ts +44 -0
  305. package/dist/core/workspace-snapshot.js +34 -0
  306. package/dist/core/write-protect.d.ts +43 -3
  307. package/dist/core/write-protect.js +43 -16
  308. package/dist/engine/compaction/compaction.js +29 -3
  309. package/dist/engine/execution-env/node-execution-env.d.ts +4 -3
  310. package/dist/engine/execution-env/node-execution-env.js +24 -23
  311. package/dist/engine/execution-env/symlink-chain.d.ts +7 -5
  312. package/dist/engine/harness/agent-harness.d.ts +30 -2
  313. package/dist/engine/harness/agent-harness.js +43 -12
  314. package/dist/engine/harness/messages.d.ts +3 -1
  315. package/dist/engine/harness/messages.js +3 -2
  316. package/dist/engine/harness/types.d.ts +56 -7
  317. package/dist/engine/harness/types.js +5 -1
  318. package/dist/engine/llm/rejected-images.d.ts +46 -0
  319. package/dist/engine/llm/rejected-images.js +54 -0
  320. package/dist/engine/llm/tool-turns.d.ts +2 -1
  321. package/dist/engine/llm/types.d.ts +30 -10
  322. package/dist/engine/llm/types.js +1 -1
  323. package/dist/engine/loop/agent-loop.d.ts +8 -0
  324. package/dist/engine/loop/agent-loop.js +52 -15
  325. package/dist/engine/loop/types.d.ts +3 -1
  326. package/dist/engine/session/import-validate.js +3 -0
  327. package/dist/engine/session/memory-repo.d.ts +17 -9
  328. package/dist/engine/session/memory-repo.js +44 -34
  329. package/dist/engine/session/path-to-root.d.ts +38 -0
  330. package/dist/engine/session/path-to-root.js +39 -0
  331. package/dist/engine/session/repo-utils.d.ts +22 -4
  332. package/dist/engine/session/repo-utils.js +49 -1
  333. package/dist/engine/session/storage-base.d.ts +10 -1
  334. package/dist/engine/session/storage-base.js +11 -22
  335. package/dist/index.d.ts +29 -16
  336. package/dist/index.js +21 -11
  337. package/dist/internal/harness-types.d.ts +2 -2
  338. package/dist/internal/harness.d.ts +3 -2
  339. package/dist/internal/harness.js +2 -2
  340. package/dist/internal/llm.d.ts +1 -0
  341. package/dist/orchestration/workflow-observe.d.ts +17 -1
  342. package/dist/orchestration/workflow-observe.js +20 -0
  343. package/dist/orchestration/workflow-types.d.ts +32 -7
  344. package/dist/orchestration/workflow.js +739 -489
  345. package/dist/shell/counting-pass.d.ts +50 -0
  346. package/dist/shell/counting-pass.js +502 -0
  347. package/dist/shell/lex.d.ts +4 -2
  348. package/dist/shell/lex.js +93 -34
  349. package/dist/shell/shell-words.d.ts +1 -1
  350. package/dist/shell/shell-words.js +7 -6
  351. package/dist/stores/file/index.d.ts +4 -1
  352. package/dist/stores/file/index.js +4 -1
  353. package/dist/stores/file/mailbox-store.js +6 -10
  354. package/dist/stores/file/session-store.d.ts +15 -8
  355. package/dist/stores/file/session-store.js +28 -13
  356. package/dist/tools/fs/fs-bash.d.ts +6 -0
  357. package/dist/tools/fs/fs-bash.js +6 -3
  358. package/dist/tools/fs/fs-write.d.ts +6 -3
  359. package/dist/tools/fs/fs-write.js +8 -7
  360. package/dist/tools/fs/index.d.ts +3 -0
  361. package/dist/tools/fs/index.js +7 -3
  362. package/dist/tools/fs/program-read-model.d.ts +13 -0
  363. package/dist/tools/fs/program-read-model.js +15 -0
  364. package/dist/tools/fs/program-read-model.rows.js +1 -1
  365. package/dist/tools/fs/read-deny.d.ts +13 -10
  366. package/dist/tools/fs/read-deny.js +25 -5
  367. package/dist/tools/fs/read-floor.d.ts +19 -0
  368. package/dist/tools/fs/read-floor.js +23 -0
  369. package/dist/tools/fs/safety.js +40 -8
  370. package/dist/tools/fs/search.js +6 -24
  371. package/dist/tools/fs/shell-read-check.d.ts +9 -2
  372. package/dist/tools/fs/shell-read-check.js +61 -16
  373. package/dist/tools/fs/shell-read-establish.js +2 -1
  374. package/dist/tools/fs/shell-read-identity.js +1 -1
  375. package/dist/tools/fs/shell-read-judge.d.ts +26 -9
  376. package/dist/tools/fs/shell-read-judge.js +10 -6
  377. package/dist/tools/fs/shell-read-plan.d.ts +6 -1
  378. package/dist/tools/fs/shell-read-plan.js +22 -15
  379. package/dist/tools/fs/shell-read-start.js +1 -0
  380. package/dist/tools/fs/shell-reentry-text.d.ts +15 -1
  381. package/dist/tools/fs/shell-reentry-text.js +25 -3
  382. package/dist/tools/monitor.d.ts +4 -0
  383. package/dist/tools/monitor.js +2 -0
  384. package/dist/tools/worktree.d.ts +42 -15
  385. package/dist/tools/worktree.js +60 -32
  386. package/package.json +5 -2
  387. package/test/export-surface.snapshot.json +149 -1
  388. package/wire-changes/core-stores-sql@7.58.0.json +29 -0
  389. package/wire-changes/core-stores-sql@7.59.0.json +29 -0
  390. package/wire-changes/core@7.58.0.json +2188 -0
  391. package/wire-changes/core@7.59.0.json +2459 -0
  392. package/wire-changes/mods-kernel@7.58.0.json +81 -0
  393. package/wire-changes/mods-kernel@7.59.0.json +29 -0
  394. package/wire-changes/primitives@7.58.0.json +29 -0
  395. package/wire-changes/primitives@7.59.0.json +29 -0
  396. package/dist/primitives/credential-ref.d.ts +0 -89
  397. package/dist/primitives/credential-ref.js +0 -125
  398. package/dist/primitives/index.d.ts +0 -2
  399. package/dist/primitives/index.js +0 -1
@@ -2,12 +2,12 @@ import type { ExecutionEnv } from "../../internal/harness-types.js";
2
2
  import type { AssistantMessage, Message, Model, Usage } from "../../internal/llm.js";
3
3
  import type { CwdRef } from "../../tools/fs/fs-shared.js";
4
4
  import { type PermissionResult, type ToolCallRequest } from "../tool-policy.js";
5
- import type { ClassicEventBase, HookInvocationIdentity, PermissionDeniedPayload, UserPromptSubmitEvent } from "../hooks.js";
5
+ import type { ClassicEventBase, HookInvocationIdentity, PermissionDeniedPayload, SubagentStartResult, UserPromptSubmitEvent } from "../hooks.js";
6
6
  import type { ClassicEventMap, ClassicEventName } from "./classic-events.js";
7
7
  import type { PermissionMode } from "../ask-origin.js";
8
8
  import type { RunnerDeps } from "../runner-deps.js";
9
9
  import type { TaskSpec } from "../task-spec.js";
10
- import { type ModAnswerRanks, type ModBus, type ModCallEntry, type ModMountedHandler, type ModDispatchOutcome, type ModEventPayload, type ModRegistration } from "./kernel/index.js";
10
+ import { type ModAnswerCheck, type ModAnswerRanks, type ModBus, type ModCallEntry, type ModMountedHandler, type ModDispatchOutcome, type ModEventPayload, type ModRegistration } from "./kernel/index.js";
11
11
  import { type SourcedOverlay } from "../../prompt-assembly/overlay.js";
12
12
  import type { BandId } from "../../prompt-assembly/catalog/schema.js";
13
13
  import type { ModParticipant } from "./kernel/dispatch.js";
@@ -29,12 +29,23 @@ export type LegModBus = Pick<ModBus, "hasHandlers" | "dispatch">;
29
29
  * and its parent's fleet row use). A top-level leg carries none.
30
30
  */
31
31
  export declare function agentIdOf(identity: HookInvocationIdentity | undefined): string | undefined;
32
+ export interface LegEvents {
33
+ /** The person's-prompt screen its objective passes — present when a person wrote the objective. */
34
+ readonly screen?: "classic.UserPromptSubmit";
35
+ /** The event it opens on — present on a delegated leg. */
36
+ readonly start?: "classic.SubagentStart";
37
+ /** The event it raises when it would otherwise end. */
38
+ readonly stop: "classic.Stop" | "classic.SubagentStop";
39
+ }
32
40
  /**
33
- * The stop event a leg raises when its run would otherwise end: `classic.SubagentStop` on a delegated child's leg — the
34
- * delegation fact, which a child resumed from its checkpoint keeps — else `classic.Stop`. Not the leg kind: a resumed
35
- * leg's kind reads `"resume"` whoever it runs as.
41
+ * Both ends of a leg. The delegation fact alone picks the lifecycle (a child resumed from its checkpoint keeps it): a
42
+ * delegated leg opens on `classic.SubagentStart` and ends on `classic.SubagentStop`, any other on nothing and
43
+ * `classic.Stop`. Who wrote the objective picks the screen: a top-level leg's objective is a person's prompt, and so is
44
+ * a delegated leg's that carries an operator's words (`operatorObjective`, the trusted resume fact) — both pass
45
+ * `classic.UserPromptSubmit`; any other delegated objective is its delegator's (a parent model, a workflow script, a
46
+ * peer) and is judged at the delegator's gate. Not the leg kind: a resumed leg's kind reads `"resume"` whoever it runs as.
36
47
  */
37
- export declare function stopEventOf(identity: Pick<HookInvocationIdentity, "isDelegatedChild"> | undefined): "classic.Stop" | "classic.SubagentStop";
48
+ export declare function legEventsOf(identity: Pick<HookInvocationIdentity, "isDelegatedChild"> | undefined, operatorObjective?: boolean): LegEvents;
38
49
  /**
39
50
  * The args as a judging handler receives them: the gate pass's own immutable value ({@link ownArgs} — the value itself when
40
51
  * the gate already took it, which is every call the gate raises an event over), so the bytes a handler judges are the bytes
@@ -66,10 +77,13 @@ export declare function sameModChain(a: readonly ModChainLink[], b: readonly Mod
66
77
  * screening constraint, and what a child's own gate stands in for when it mounted the same.
67
78
  */
68
79
  export declare function chainJudges(bus: LegModBus): boolean;
69
- /** Record what the constraint mint minted `policy` over. */
70
- export declare function recordScreeningChain(policy: object, chain: LegModBus): void;
71
- /** The chain a screening constraint was minted over, or `undefined` when the mint did not make this object. */
72
- export declare function screeningChainOf(policy: object): LegModBus | undefined;
80
+ /** Give a minted screening `policy` its installation — own, fixed and not enumerable, the object held in a closure no clone can re-point, so a copy or a wrapper of the policy carries none. Written only by the constraint mint (`createPreToolUseConstraintPolicy`). */
81
+ export declare function withInstallation<P extends object>(policy: P, bus: LegModBus): P;
82
+ /** The installation an inherited entry carries (its policy's own member, read off the descriptor: no getter or trap runs, and a
83
+ * member minted on another object is not this one's), or `undefined` when the mint did not make the entry's policy. */
84
+ export declare function installationOf(pc: {
85
+ readonly policy: object;
86
+ }): LegModBus | undefined;
73
87
  /** How an inherited installation's question is settled: under the context its installation froze (its approver, its durable
74
88
  * mandates, its classifier — the settlement its `classic.PreToolUse` ask takes in the fold), never at this leg's approver. An
75
89
  * allow carrying `updatedInput` is a person's approval of an edit; an ask is one the settlement floated (the call is marked for
@@ -108,7 +122,7 @@ export interface LegInstallation {
108
122
  }
109
123
  /**
110
124
  * Whether an inherited entry IS a leg's installation — the ONE installation identity. The chain is read off the entry's own
111
- * bus (the one its policy was minted over, as that bus's admission recorded it), never off a list the entry carries: an entry
125
+ * bus ({@link installationOf}, as that bus's admission recorded it), never off a list the entry carries: an entry
112
126
  * whose policy the mint did not make, or whose bus no engine admission mounted, is no leg's installation. The rest is the
113
127
  * context its questions are settled in: the same approver ({@link askApproverIdentity}), the same two durable mandates, the
114
128
  * same environment, the same classifier instance. Readers: chain assembly (a leg already on the chain is not appended again)
@@ -169,7 +183,7 @@ export declare function observeClassic<K extends ClassicEventName>(bus: LegModBu
169
183
  */
170
184
  export declare function dispatchClassic<K extends ClassicEventName>(bus: LegModBus, event: K, e: ClassicEventMap[K]["e"], options: {
171
185
  readonly signal?: AbortSignal;
172
- readonly checkAnswer?: (answer: unknown) => string | undefined;
186
+ readonly checkAnswer?: ModAnswerCheck;
173
187
  readonly ranks?: ModAnswerRanks;
174
188
  }): Promise<ModDispatchOutcome | undefined>;
175
189
  /** The answer form of a classic event whose answer is an object of optional string members (`block`, `additionalContext`, …). */
@@ -211,6 +225,13 @@ export type PromptScreen = {
211
225
  * a cancelled screen ends `aborted` at once. A dispatch the engine itself could not run is `failed` too.
212
226
  */
213
227
  export declare function screenUserPrompt(bus: LegModBus, e: UserPromptSubmitEvent, signal: AbortSignal | undefined): Promise<PromptScreen | undefined>;
228
+ /**
229
+ * Raise `classic.SubagentStart` as a delegated leg opens on its objective (undefined when no handler hangs on it): the
230
+ * context the chain answers. It never keeps the child from starting — a handler that fails is skipped and reported by
231
+ * the bus, a cancel ends the wait at once (the leg's own cancel then ends the child), and a dispatch the engine itself
232
+ * could not run is no answer.
233
+ */
234
+ export declare function openSubagent(bus: LegModBus, identity: HookInvocationIdentity, permissionMode: PermissionMode | undefined, signal: AbortSignal | undefined): Promise<SubagentStartResult | undefined>;
214
235
  /** The three words a `tool.check` verdict speaks. */
215
236
  export declare const TOOL_CHECK_DECISIONS: readonly ["allow", "ask", "deny"];
216
237
  export type ToolCheckDecision = (typeof TOOL_CHECK_DECISIONS)[number];
@@ -20,8 +20,13 @@ export function engineCore() {
20
20
  export function agentIdOf(identity) {
21
21
  return identity?.isDelegatedChild === true ? identity.taskId : undefined;
22
22
  }
23
- export function stopEventOf(identity) {
24
- return identity?.isDelegatedChild === true ? "classic.SubagentStop" : "classic.Stop";
23
+ const PERSON_LEG = Object.freeze({ screen: "classic.UserPromptSubmit", stop: "classic.Stop" });
24
+ const DELEGATED_LEG = Object.freeze({ start: "classic.SubagentStart", stop: "classic.SubagentStop" });
25
+ const OPERATOR_RESUMED_LEG = Object.freeze({ screen: "classic.UserPromptSubmit", start: "classic.SubagentStart", stop: "classic.SubagentStop" });
26
+ export function legEventsOf(identity, operatorObjective = false) {
27
+ if (identity?.isDelegatedChild !== true)
28
+ return PERSON_LEG;
29
+ return operatorObjective ? OPERATOR_RESUMED_LEG : DELEGATED_LEG;
25
30
  }
26
31
  export function judgedInputOf(args) {
27
32
  const owned = ownArgs(args);
@@ -69,15 +74,19 @@ const judgesCall = (p) => !p.observe;
69
74
  export function chainJudges(bus) {
70
75
  return bus.hasHandlers("classic.PreToolUse", judgesCall) || bus.hasHandlers("tool.check", judgesCall);
71
76
  }
72
- const SCREENING_CHAINS = new WeakMap();
73
- export function recordScreeningChain(policy, chain) {
74
- SCREENING_CHAINS.set(policy, chain);
77
+ const INSTALLATION = Symbol("installation");
78
+ export function withInstallation(policy, bus) {
79
+ return Object.defineProperty(policy, INSTALLATION, { value: Object.freeze({ bus, mintedAs: (o) => o === policy }) });
75
80
  }
76
- export function screeningChainOf(policy) {
77
- return SCREENING_CHAINS.get(policy);
81
+ export function installationOf(pc) {
82
+ const p = pc.policy;
83
+ if (p === null || p === undefined || types.isProxy(p))
84
+ return undefined;
85
+ const minted = Object.getOwnPropertyDescriptor(p, INSTALLATION)?.value;
86
+ return minted !== undefined && minted.mintedAs(p) ? minted.bus : undefined;
78
87
  }
79
88
  export function sameInstallation(pc, leg) {
80
- const bus = screeningChainOf(pc.policy);
89
+ const bus = installationOf(pc);
81
90
  const chain = bus !== undefined ? chainOfBus(bus) : undefined;
82
91
  return (chain !== undefined &&
83
92
  sameModChain(chain, leg.chain) &&
@@ -96,7 +105,7 @@ const judgesToolCheck = (h) => {
96
105
  };
97
106
  export function screeningInstallationsOf(entries) {
98
107
  return entries.flatMap((pc) => {
99
- const bus = screeningChainOf(pc.policy);
108
+ const bus = installationOf(pc);
100
109
  return bus !== undefined || pc.mods !== undefined ? [{ bus, chain: pc.mods }] : [];
101
110
  });
102
111
  }
@@ -111,7 +120,7 @@ export function inheritedToolChecks(entries, standsIn, settleOf) {
111
120
  throw modsInvalid(unraisable);
112
121
  const checks = [];
113
122
  for (const pc of entries) {
114
- const bus = screeningChainOf(pc.policy);
123
+ const bus = installationOf(pc);
115
124
  if (bus === undefined || standsIn(pc) || !bus.hasHandlers("tool.check", judges))
116
125
  continue;
117
126
  checks.push(Object.freeze({ bus, judges, settle: settleOf(pc) }));
@@ -142,7 +151,7 @@ export async function dispatchClassic(bus, event, e, options) {
142
151
  return await bus.dispatch(event, e, {
143
152
  bottom: engineCore,
144
153
  ...(options.signal !== undefined ? { signal: options.signal } : {}),
145
- ...(check !== undefined ? { checkAnswer: (a) => (a === ENGINE_CORE_ANSWER ? undefined : check(a)) } : {}),
154
+ ...(check !== undefined ? { checkAnswer: (a, ce, by, below, run) => (a === ENGINE_CORE_ANSWER ? undefined : check(a, ce, by, below, run)) } : {}),
146
155
  ...(options.ranks !== undefined ? { ranks: options.ranks } : {}),
147
156
  });
148
157
  }
@@ -218,6 +227,31 @@ export async function screenUserPrompt(bus, e, signal) {
218
227
  return outcome;
219
228
  return { kind: "answered", ...stringMembersOf(outcome.answer, ["block", "additionalContext"]) };
220
229
  }
230
+ const subagentStartMembers = stringMembersAnswer("classic.SubagentStart", ["additionalContext"]);
231
+ function subagentStartAnswer(answer) {
232
+ const refused = subagentStartMembers(answer);
233
+ if (refused !== undefined)
234
+ return refused;
235
+ if (typeof answer === "object" && answer !== null && Reflect.get(answer, "block") !== undefined) {
236
+ return `answered "block"; classic.SubagentStart cannot keep a subagent from starting (it starts all the same) — a deployment refuses the delegating call at classic.PreToolUse`;
237
+ }
238
+ return undefined;
239
+ }
240
+ export async function openSubagent(bus, identity, permissionMode, signal) {
241
+ const e = {
242
+ ...classicEventBase(identity, permissionMode),
243
+ agentId: identity.taskId,
244
+ ...(identity.agentType !== undefined ? { agentType: identity.agentType } : {}),
245
+ };
246
+ let outcome;
247
+ try {
248
+ outcome = await dispatchClassic(bus, "classic.SubagentStart", e, { ...(signal !== undefined ? { signal } : {}), checkAnswer: subagentStartAnswer });
249
+ }
250
+ catch {
251
+ return undefined;
252
+ }
253
+ return outcome?.kind === "answered" ? stringMembersOf(outcome.answer, ["additionalContext"]) : undefined;
254
+ }
221
255
  export const TOOL_CHECK_DECISIONS = Object.freeze(["allow", "ask", "deny"]);
222
256
  const isToolCheckDecision = (v) => TOOL_CHECK_DECISIONS.some((d) => d === v);
223
257
  const TOOL_CHECK_RANKS = Object.freeze({
@@ -5,7 +5,8 @@
5
5
  * handler's failure refuses the call while the body has not started and, once it has, the body's real result stands.
6
6
  *
7
7
  * `e = { tool, tool_use_id, agentId?, input }` (all four pinned — what the gate judged is what runs; a rewrite belongs to
8
- * `classic.PreToolUse`) plus the identity envelope. A handler answers:
8
+ * `classic.PreToolUse`) plus the identity envelope; a handler may hand on `requestMeta` too (a record of strings an MCP call carries
9
+ * as `_meta["sema/requestMeta"]`, judged where it is handed on — `mcp-call-meta.ts`). A handler answers:
9
10
  * - `next(e)` — the body runs; what came up is `{ result: { content, isError } }`, a frozen view of the real result;
10
11
  * - `{ deny: <reason> }` — refused before the body: the call is not executed and the record says an extension refused it
11
12
  * (a deny once the body has started stands in place of a call that ran: a violation, the real result stands);
@@ -28,6 +29,7 @@
28
29
  import type { AgentToolResult } from "../../internal/harness-types.js";
29
30
  import type { HookInvocationIdentity } from "../hooks.js";
30
31
  import type { ToolOccurrenceTable } from "../runner/tool-occurrence.js";
32
+ import { type McpRequestMetaSeat } from "../mcp-call-meta.js";
31
33
  import { type LegModBus } from "./stations.js";
32
34
  import type { ModBus, ModCallEntry } from "./kernel/index.js";
33
35
  /** One execution as the station sees it: the call, the tool that runs (its mounted name), the arguments the gate let go. */
@@ -46,6 +48,8 @@ export interface ToolCallStationInput {
46
48
  readonly blockedToolCalls: Set<string>;
47
49
  readonly identity?: HookInvocationIdentity;
48
50
  readonly reminderMark?: string;
51
+ /** The leg's request-meta seat: what the chain handed on as `requestMeta` stands under the call's id while its body runs. */
52
+ readonly requestMeta: Pick<McpRequestMetaSeat, "hold">;
49
53
  }
50
54
  /** The station over the leg's bus, or undefined when no handler hangs on `tool.call` (nothing is raised; the body runs). */
51
55
  export declare function createToolCallStation(input: ToolCallStationInput): ToolCallStation | undefined;
@@ -3,6 +3,7 @@ import { toolFace } from "../tool-catalog-entries.js";
3
3
  import { declaredDelegationNameOf } from "../delegation-name.js";
4
4
  import { describeThrown } from "../tool-policy.js";
5
5
  import { extensionWords } from "../untrusted-egress.js";
6
+ import { readHandedRequestMeta } from "../mcp-call-meta.js";
6
7
  import { ENGINE_ORIGIN } from "./kernel/index.js";
7
8
  import { isPlainRecord } from "./kernel/receive.js";
8
9
  import { NEXT_IN_FLIGHT } from "./kernel/site-rules.js";
@@ -50,7 +51,7 @@ export function createToolCallStation(input) {
50
51
  return undefined;
51
52
  const refusal = (call, by, text) => {
52
53
  if (input.occurrences.get(call.toolCallId) !== undefined) {
53
- input.occurrences.refuse(call.toolCallId, "hook");
54
+ input.occurrences.refuse(call.toolCallId, "hook", by);
54
55
  input.occurrences.answeredInPlace(call.toolCallId, by);
55
56
  }
56
57
  input.blockedToolCalls.add(call.toolCallId);
@@ -60,8 +61,16 @@ export function createToolCallStation(input) {
60
61
  const e = { ...classicEventBase(input.identity), tool: call.toolName, tool_use_id: call.toolCallId, input: judgedInputOf(call.args) };
61
62
  const bodies = new Map();
62
63
  let body;
63
- const bottom = async () => {
64
- body = run();
64
+ const judged = new WeakMap();
65
+ const checkHandOn = (payload) => {
66
+ const read = readHandedRequestMeta(payload);
67
+ if ("problem" in read)
68
+ return `next() handed on a requestMeta the call cannot carry: ${read.problem}`;
69
+ judged.set(payload, read.meta);
70
+ return undefined;
71
+ };
72
+ const bottom = async (handed) => {
73
+ body = input.requestMeta.hold(call.toolCallId, judged.get(handed), run);
65
74
  const result = await body;
66
75
  const view = viewOf(result);
67
76
  bodies.set(view, result);
@@ -83,7 +92,7 @@ export function createToolCallStation(input) {
83
92
  };
84
93
  let outcome;
85
94
  try {
86
- outcome = await input.bus.dispatch("tool.call", e, { bottom, checkAnswer, ranks: RANKS, ...(signal !== undefined ? { signal } : {}) });
95
+ outcome = await input.bus.dispatch("tool.call", e, { bottom, checkAnswer, checkHandOn, ranks: RANKS, ...(signal !== undefined ? { signal } : {}) });
87
96
  }
88
97
  catch (err) {
89
98
  if (body !== undefined)
@@ -14,7 +14,7 @@ import type { EngineDollar } from "./mods/dollar.js";
14
14
  import type { ToolExecuteContext } from "./tool-spec.js";
15
15
  import type { TaskSpec } from "./types.js";
16
16
  /** The fields of a spec the seat carries — one `Pick`, shared by the mint's input and the apply's target. */
17
- export type ParentSpecSeatFields = Pick<TaskSpec, "principal" | "oneShot" | "clientContext" | "onQuestion" | "mods" | "additionalDirectories" | "additionalReadDirectories" | "envFacts" | "memoryPersistenceCapable" | "memory" | "compaction" | "skillListingBudgetFraction" | "skillListingMaxDescChars" | "fileHistory" | "projectMemory" | "promptForm" | "promptBinding" | "advisorModel" | "attachments">;
17
+ export type ParentSpecSeatFields = Pick<TaskSpec, "principal" | "oneShot" | "clientContext" | "onQuestion" | "mods" | "additionalDirectories" | "additionalReadDirectories" | "envFacts" | "memoryPersistenceCapable" | "classifyAllShell" | "memory" | "compaction" | "skillListingBudgetFraction" | "skillListingMaxDescChars" | "fileHistory" | "projectMemory" | "promptForm" | "promptBinding" | "advisorModel" | "attachments">;
18
18
  /**
19
19
  * The seat a run hands its children. Every member is the parent's own value, frozen at mint (arrays copied and
20
20
  * frozen; the facts object copied). Members present iff the parent carries them — an absent member is "nothing to
@@ -35,6 +35,9 @@ export type ParentSpecSeatFields = Pick<TaskSpec, "principal" | "oneShot" | "cli
35
35
  * · `envFacts` — the sandbox facts (profile / egress / scratchpad).
36
36
  * · `memoryPersistenceCapable` — the deployment's DECLARED persistence statement: `false` is a REMOVAL (floor),
37
37
  * `true` a default a child's own declaration may narrow.
38
+ * · `classifyAllShell` — the request's "no shell allow entry clears a call in `auto`" declaration: only `true` travels and
39
+ * it is a REMOVAL (the child's shell allow entries stand down in `auto` as the parent's did; a child's own `false` cannot
40
+ * lift it).
38
41
  * · `memory` — the request-level "memory is off" FACT, `{ enabled: false }` and nothing else of the declaration (the clamp
39
42
  * table's `memory.enabled` row; present only when the parent stated `enabled: false`): a REMOVAL (floor) that
40
43
  * REWRITES the one member on the child's own memory declaration — its scopes and knobs are the child's.
@@ -75,6 +78,7 @@ export interface ParentSpecSeat {
75
78
  readonly additionalReadDirectories?: readonly string[];
76
79
  readonly envFacts?: TaskSpec["envFacts"];
77
80
  readonly memoryPersistenceCapable?: boolean;
81
+ readonly classifyAllShell?: true;
78
82
  readonly memory?: {
79
83
  readonly enabled: false;
80
84
  };
@@ -96,8 +100,9 @@ export declare function assertParentSpecSeatCurrent(seat: object | undefined): v
96
100
  export declare function parentSpecSeatOf(spec: Omit<ParentSpecSeatFields, "onQuestion">, frozenOnQuestion: OnQuestion | undefined): ParentSpecSeat;
97
101
  /**
98
102
  * Apply the seat to a child spec — ONE law for every member, both lanes:
99
- * a value the child spec already carries WINS; the seat FILLS an unset one; the three REMOVAL values
100
- * (`oneShot: true`, `memoryPersistenceCapable: false`, `memory: { enabled: false }`) land UNCONDITIONALLY.
103
+ * a value the child spec already carries WINS; the seat FILLS an unset one; the four REMOVAL values
104
+ * (`oneShot: true`, `memoryPersistenceCapable: false`, `classifyAllShell: true`, `memory: { enabled: false }`) land
105
+ * UNCONDITIONALLY.
101
106
  * "Already carries" is the child's own authorship — a deployment baseline, a trusted script, an agent definition's
102
107
  * fold (the Task lane folds the definition's `memoryPersistenceCapable` before applying; the workflow lane applies at
103
108
  * the launch site AFTER the agentType fold) — so a definition may narrow a parent `true` to `false`, a baseline-pinned
@@ -18,6 +18,7 @@ export function parentSpecSeatOf(spec, frozenOnQuestion) {
18
18
  ...(spec.additionalReadDirectories !== undefined ? { additionalReadDirectories: Object.freeze([...spec.additionalReadDirectories]) } : {}),
19
19
  ...(spec.envFacts !== undefined ? { envFacts: Object.freeze({ ...spec.envFacts }) } : {}),
20
20
  ...(spec.memoryPersistenceCapable !== undefined ? { memoryPersistenceCapable: spec.memoryPersistenceCapable } : {}),
21
+ ...(spec.classifyAllShell === true ? { classifyAllShell: true } : {}),
21
22
  ...(spec.compaction !== undefined ? { compaction: Object.freeze({ ...spec.compaction }) } : {}),
22
23
  ...(spec.skillListingBudgetFraction !== undefined ? { skillListingBudgetFraction: spec.skillListingBudgetFraction } : {}),
23
24
  ...(spec.skillListingMaxDescChars !== undefined ? { skillListingMaxDescChars: spec.skillListingMaxDescChars } : {}),
@@ -54,6 +55,7 @@ export function applyParentSpecSeat(child, seat) {
54
55
  ...fill("advisorModel", seat.advisorModel),
55
56
  ...fill("attachments", (seat.attachments !== undefined ? { ...seat.attachments } : undefined)),
56
57
  ...(seat.oneShot === true ? { oneShot: true } : {}),
58
+ ...(seat.classifyAllShell === true ? { classifyAllShell: true } : {}),
57
59
  ...(seat.memoryPersistenceCapable === false ? { memoryPersistenceCapable: false } : fill("memoryPersistenceCapable", seat.memoryPersistenceCapable)),
58
60
  };
59
61
  return applyClampSeats(landed, clampFieldSeatsOf(seat));
@@ -81,6 +81,12 @@ function syntheticCheckpoint(scope, fidelity) {
81
81
  askClass: "denial_limit_fallback",
82
82
  classes: ["denial_limit_fallback"],
83
83
  engineMounted: true,
84
+ capabilityId: "0123456789abcdef",
85
+ contractId: "core.selfcheck@1",
86
+ shapeDigest: "fedcba9876543210",
87
+ implementationRevision: "1",
88
+ family: "other",
89
+ declarationDigest: "d".repeat(64),
84
90
  targets: { protective: "/park-selfcheck/target", declared: null },
85
91
  targetReads: { ["0".repeat(64)]: "f".repeat(64) },
86
92
  batchToolCallIds: [`${scope}:call`],
@@ -88,6 +88,26 @@ export interface PathRowsHit<R> {
88
88
  readonly viewKind?: GuardViewKind;
89
89
  readonly unreadable?: string;
90
90
  }
91
+ /** WHICH reading of the target met a tightening row, in the word every guard that writes about the hit records: `spelling`
92
+ * — the path as written (its placed spelling); `target` — where it really lands; `chain` — a hop of its leaf's symlink
93
+ * chain. A hit with no view (an unreadable hold) and a `home` view — the read-deny home station's, which no write guard
94
+ * mints — read as the spelling. */
95
+ export type GuardHitVia = "spelling" | "target" | "chain";
96
+ /** The ONE reading of a hit's view kind as its {@link GuardHitVia}, for every guard that records or words a hit. */
97
+ export declare function guardHitVia(kind: GuardViewKind | undefined): GuardHitVia;
98
+ /** Which spellings of the leg's current managed checkout a view is placed against (write-protect's current-tree reading): the
99
+ * canonical view against the checkout's canonical identity alone, every other view against every spelling of it. */
100
+ export type CheckoutReading = "canonical-only" | "every-spelling";
101
+ /** The ONE reading of a view kind as the {@link CheckoutReading} its current-tree placement uses (a new {@link GuardViewKind} must pick one). */
102
+ export declare function checkoutReadingOf(kind: GuardViewKind): CheckoutReading;
103
+ /**
104
+ * What a guard's sentence says about WHERE the row was met — one clause for every guard's sentence, said when the reading that
105
+ * met it is not the spelling. `target` and `chain` are one fact to whoever reads the sentence (the person approving, the
106
+ * auto-mode classifier, the model refused): the row was met by following the path on disk, at its real target or at a link on
107
+ * the way. Two wordings of that one fact let the wording, not the fact, move an answer. The clause says which reading met the
108
+ * row and nothing about the spelling: a spelling the identity exemption kept from voting may name the row too.
109
+ */
110
+ export declare function guardHitReachClause(via: GuardHitVia): string | undefined;
91
111
  /**
92
112
  * THE one judgment of guarded rows over a target's views, for every table and every lane: rows outer, views inner — the
93
113
  * first row (in the caller's order) that some view reaches is the answer. `tighten` (deny / ask): any present view reaching
@@ -8,6 +8,17 @@ export function viewSpellings(views) {
8
8
  export function spelledViews(spellings, kind) {
9
9
  return { views: spellings.map((path, i) => ({ path, kind: kind ?? (i === 0 ? "lexical" : "canonical") })) };
10
10
  }
11
+ const GUARD_HIT_VIA = { lexical: "spelling", canonical: "target", hop: "chain", home: "spelling" };
12
+ export function guardHitVia(kind) {
13
+ return kind === undefined ? "spelling" : GUARD_HIT_VIA[kind];
14
+ }
15
+ const CHECKOUT_READING = { lexical: "every-spelling", canonical: "canonical-only", hop: "every-spelling", home: "every-spelling" };
16
+ export function checkoutReadingOf(kind) {
17
+ return CHECKOUT_READING[kind];
18
+ }
19
+ export function guardHitReachClause(via) {
20
+ return via === "spelling" ? undefined : "matched where the path resolves on disk (its real target or a link on the way)";
21
+ }
11
22
  export function judgePathRows(rows, views, direction) {
12
23
  if (direction === "allow") {
13
24
  if (views.unreadable !== undefined || views.views.length === 0)
@@ -0,0 +1,248 @@
1
+ import { StreamableHTTPError } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
2
+ import { type CredentialRef } from "@sema-agent/primitives";
3
+ import type { McpServerSpec } from "./mcp-server-spec.js";
4
+ import type { ProtocolId } from "./protocol-table.js";
5
+ /** Why the seat is asked: the first send of a connection, any later send, or the send after a 401. */
6
+ export type PeerAskCause = "connect" | "request" | "rejected";
7
+ /**
8
+ * Who the request goes to, as the declaration names it — the whole of it, so the seat can bind an answer to the reference, the
9
+ * principal, the protocol and the destination (or the whole start command): an http MCP server's url, a stdio one's command and
10
+ * arguments, an A2A peer's declared urls and THIS send's destination.
11
+ */
12
+ export type PeerSeatTarget = {
13
+ readonly protocol: "mcp";
14
+ readonly server: string;
15
+ readonly transport: "http";
16
+ readonly url: string;
17
+ readonly credentials?: CredentialRef;
18
+ readonly fingerprint?: string;
19
+ } | {
20
+ readonly protocol: "mcp";
21
+ readonly server: string;
22
+ readonly transport: "stdio";
23
+ readonly command: string;
24
+ readonly args: readonly string[];
25
+ readonly credentials?: CredentialRef;
26
+ readonly fingerprint?: string;
27
+ } | {
28
+ readonly protocol: "a2a";
29
+ readonly peer: string;
30
+ readonly url: string;
31
+ readonly cardUrl?: string;
32
+ readonly destination: string;
33
+ readonly credentials?: CredentialRef;
34
+ };
35
+ /** One question to the seat. `principal` is part of the connection's identity; the session is not. */
36
+ export interface PeerQuestion {
37
+ readonly peer: PeerSeatTarget;
38
+ readonly principal?: string;
39
+ readonly cause: PeerAskCause;
40
+ }
41
+ /**
42
+ * The seat's answer: the pieces to carry (`headers` for an http request and an A2A send, `env` for a stdio child — the member of the
43
+ * other lane is refused; `expiresAt`, epoch ms, is read by a stdio child only), or that the principal is not authorized here.
44
+ */
45
+ export type PeerAnswer = {
46
+ readonly kind: "carry";
47
+ readonly headers?: Readonly<Record<string, string>>;
48
+ readonly env?: Readonly<Record<string, string>>;
49
+ readonly expiresAt?: number;
50
+ } | {
51
+ readonly kind: "unauthorized";
52
+ readonly authorizeUrl?: string;
53
+ };
54
+ /**
55
+ * The deployment's peer seat (`RunnerDeps.peerSeat`, TRUSTED). It owes the binding the engine cannot judge: answer only for the
56
+ * reference, principal, protocol and destination (or start command) it was asked about — never one token for every peer.
57
+ */
58
+ export type PeerSeat = (question: PeerQuestion, signal: AbortSignal) => Promise<PeerAnswer>;
59
+ /** Which answer member each transport carries. */
60
+ export declare const PEER_ANSWER_LANES: Readonly<{
61
+ readonly http: "headers";
62
+ readonly a2a: "headers";
63
+ readonly stdio: "env";
64
+ }>;
65
+ export type PeerLane = keyof typeof PEER_ANSWER_LANES;
66
+ /** How long one ask may take before the send goes without it (`credential_unavailable`). */
67
+ export declare const PEER_SEAT_WAIT_MS = 30000;
68
+ /** The longest URL an authorization record keeps (the seat's `authorizeUrl`, the endpoint's `resource_metadata`). */
69
+ export declare const AUTHORIZATION_URL_MAX = 2048;
70
+ /**
71
+ * The one URL law of the authorization record (`McpAuthorization`, mcp-failure.ts): an absolute http(s) URL with no user-info, within
72
+ * {@link AUTHORIZATION_URL_MAX} code units, as the URL parser serializes it with every markup-significant character after the host
73
+ * (brackets, parentheses, angle brackets, quotes, backtick, braces, pipe, caret, backslash) percent-encoded — so the text a model or a
74
+ * host renders is one plain link — else
75
+ * `undefined`. A string carrying a control character is refused before parsing (the parser would silently drop a tab or a line break
76
+ * and keep the rest).
77
+ */
78
+ export declare function authorizationUrlOf(raw: unknown): string | undefined;
79
+ /**
80
+ * The `Bearer` challenge's auth-params in a `WWW-Authenticate` value (RFC 7235 §4.1: a comma-separated list of challenges, each a
81
+ * scheme and its `name=value` params, a value a token or a quoted string) — names lower-cased, the first of a repeated name kept — or
82
+ * `undefined` when no Bearer challenge is there. A param belongs to the challenge it follows, so `not_error=…`, an `error=` inside a
83
+ * quoted description and another scheme's params are never the Bearer `error`. A malformed character is stepped over.
84
+ */
85
+ export declare function bearerChallengeParams(header: string | null): ReadonlyMap<string, string> | undefined;
86
+ /** Why a send went without its pieces. */
87
+ export type PeerSeatFailureReason = "threw" | "timed_out" | "answer_invalid" | "unauthorized";
88
+ /**
89
+ * A send the seat did not furnish: nothing was sent. The text names the peer and the reason, never a value and never the seat's own
90
+ * error text (deployment code may put a credential in it); `authorizeUrl` is the seat's own, when it answered `unauthorized` (read by
91
+ * {@link authorizationUrlOf}). An MCP failure reads `reason: "unauthorized"` as `unauthorized` (reason `none`), every other reason as
92
+ * `credential_unavailable` (mcp-failure.ts).
93
+ */
94
+ export declare class PeerSeatFailure extends Error {
95
+ readonly reason: PeerSeatFailureReason;
96
+ readonly authorizeUrl: string | undefined;
97
+ /** An answer the engine cannot carry is the deployment's configuration fault: `config.peer_answer_invalid`, or the ownership law's
98
+ * own code (`config.protocol_header_collision`) when it names a header it may not. A seat that threw, timed out or refused has none. */
99
+ readonly code: string | undefined;
100
+ constructor(reason: PeerSeatFailureReason, peerLabel: string, problem: string, extra?: {
101
+ authorizeUrl?: string;
102
+ code?: string;
103
+ });
104
+ }
105
+ /**
106
+ * An MCP HTTP request the endpoint refused for its authorization — a 401, or a 403 whose Bearer challenge says `insufficient_scope`
107
+ * (RFC 6750 §3.1) — raised by the one fetch ({@link peerFetch}) in place of the SDK's status error, which keeps no header. It IS the
108
+ * SDK's status error (same class, same `code`), so every structural reader of a status reads it unchanged; it adds what the response
109
+ * said and what the re-ask after a 401 answered:
110
+ * · `reason` — `rejected` (401) or `scope` (403);
111
+ * · `resourceMetadataUrl` — the Bearer challenge's `resource_metadata` ({@link bearerChallengeParams}), the REMOTE's claim, read by
112
+ * {@link authorizationUrlOf};
113
+ * · `authorizeUrl` — the seat's, when it answered the re-ask after a 401 `unauthorized`;
114
+ * · `renewed` — the re-ask after a 401 answered pieces other than the refused send's: a credential this server has not refused yet
115
+ * exists, and a new send carries it (the call layer sends a repeat-safe call again on it). It is NOT "the user owes nothing": a seat
116
+ * that mints a fresh assertion on every ask renews every time, so only a refusal of the credential it renewed to says more.
117
+ * The text is the engine's sentence followed by the response body as the SDK's own error would have carried it (bounded to
118
+ * {@link REFUSAL_BODY_MAX} characters) — REMOTE text, read by every face through the one remote-words reading like any status body.
119
+ */
120
+ export declare class PeerAuthorizationRefused extends StreamableHTTPError {
121
+ readonly reason: "rejected" | "scope";
122
+ readonly resourceMetadataUrl: string | undefined;
123
+ readonly authorizeUrl: string | undefined;
124
+ readonly renewed: boolean;
125
+ constructor(reason: "rejected" | "scope", facts: {
126
+ resourceMetadataUrl?: string;
127
+ authorizeUrl?: string;
128
+ renewed?: boolean;
129
+ body?: string;
130
+ });
131
+ }
132
+ /** How much of a refusal's response body its text keeps. */
133
+ export declare const REFUSAL_BODY_MAX = 4096;
134
+ /** Whether a failure is an authorization refusal after which the deployment furnished a fresh credential ({@link PeerAuthorizationRefused.renewed}). */
135
+ export declare function refusedThenRenewed(err: unknown): boolean;
136
+ /** What one send carries, as the engine took it from an answer, and its digest (whether a re-ask changed anything). */
137
+ export interface CarriedPieces {
138
+ readonly headers?: Readonly<Record<string, string>>;
139
+ readonly env?: Readonly<Record<string, string>>;
140
+ readonly expiresAt?: number;
141
+ readonly digest: string;
142
+ }
143
+ /** The seat's answer for `lane`, read once: the pieces, the `unauthorized` answer, or the problem (which member did not fit). */
144
+ export declare function readPeerAnswer(raw: unknown, lane: PeerLane): {
145
+ readonly carry: CarriedPieces;
146
+ } | {
147
+ readonly unauthorized: {
148
+ readonly authorizeUrl?: string;
149
+ };
150
+ } | {
151
+ readonly problem: string;
152
+ };
153
+ /** What the re-ask after a 401 said: whether it answered other pieces than the refused send carried, and the seat's `authorizeUrl` when it answered `unauthorized`. */
154
+ export interface PeerReask {
155
+ readonly renewed: boolean;
156
+ readonly authorizeUrl?: string;
157
+ }
158
+ /**
159
+ * One connection's (or one A2A peer's) asks of the seat. `next` answers each send: a 401's re-ask answer when one is waiting (carried
160
+ * once), else the seat's answer to this send. `rejected` is the one re-ask after a 401 (concurrent rejections share it); `renewed` says
161
+ * whether that re-ask answered pieces that differ from what the rejected send carried — the call layer sends a repeat-safe call again
162
+ * only then. `sent` is every value a send carried and the principal sent beside them: a remote's words are read without them.
163
+ */
164
+ export declare class PeerCarrier {
165
+ private readonly seat;
166
+ private readonly identity;
167
+ private readonly principal;
168
+ private readonly lane;
169
+ readonly sent: string[];
170
+ /** When the pieces a stdio child was started with stop being good; `undefined` when the answer said nothing. */
171
+ expiresAt: number | undefined;
172
+ renewed: boolean;
173
+ private asked;
174
+ private waiting;
175
+ private rejection;
176
+ constructor(seat: PeerSeat | undefined, identity: PeerSeatTarget, principal: string | undefined, lane: PeerLane, principalSent: boolean);
177
+ /** The peer as the refusal sentences name it. */
178
+ get label(): string;
179
+ /** The pieces the next send carries (see the class note). A seat failure throws {@link PeerSeatFailure}. */
180
+ next(signal?: AbortSignal, destination?: string): Promise<CarriedPieces>;
181
+ /** The pieces the latest send carried (`undefined` before the first). */
182
+ last: CarriedPieces | undefined;
183
+ /** A send that carried `carried` was answered 401: ask once more (`rejected`); the next send carries that answer. Never throws —
184
+ * a re-ask that fails leaves `renewed` false, so the 401 is the call's answer, and the next send asks afresh. Resolves to what the
185
+ * re-ask said (concurrent rejections share one flight and its answer): whether it renewed, and the seat's `authorizeUrl` when it
186
+ * answered `unauthorized`. */
187
+ rejected(carried: CarriedPieces, signal?: AbortSignal, destination?: string): Promise<PeerReask>;
188
+ /** Whether the pieces a stdio child was started with have stopped being good. */
189
+ expired(now?: number): boolean;
190
+ private ask;
191
+ private remember;
192
+ }
193
+ /**
194
+ * The http request headers one send carries: the seat's pieces and the principal under `principalHeader`, judged by the one ownership
195
+ * law ({@link resolveProtocolHttpHeaders}: one owner per name; an MCP request's protocol-owned names are the SDK's). A collision of the
196
+ * answer is the seat's fault ({@link PeerSeatFailure}); the declaration's own principal header was judged when the peer was dialed.
197
+ */
198
+ export declare function carriedHttpHeaders(protocol: ProtocolId, carrier: PeerCarrier, pieces: CarriedPieces, principalHeader: string | undefined, principal: string | undefined): Readonly<Record<string, string>> | undefined;
199
+ /**
200
+ * The MCP HTTP transport's `fetch` under the seat: every request the transport makes (the POST, the SSE GET, the DELETE) asks the
201
+ * carrier first, carries what it answered, goes only to the endpoint the declaration named (no redirect is followed — a 3xx is the
202
+ * answer) and, answered 401, has the carrier ask once more for the next send. A refusal of the authorization — 401, or 403 whose
203
+ * challenge says `insufficient_scope` — is raised here as {@link PeerAuthorizationRefused} carrying the challenge, the re-ask's answer
204
+ * and the bounded body (the SDK would raise its status error from the same response with no header kept).
205
+ */
206
+ export declare function peerFetch(carrier: PeerCarrier, principalHeader: string | undefined, principal: string | undefined): typeof fetch;
207
+ /** The member of a declaration that would carry a value (retired: values come from the seat). */
208
+ export declare const RETIRED_VALUE_MEMBERS: Readonly<{
209
+ readonly mcp: readonly (readonly string[])[];
210
+ readonly a2a: readonly (readonly string[])[];
211
+ }>;
212
+ /** The first retired value member a received copy holds (a member holding `undefined` is absent), as its path. */
213
+ export declare function retiredValueMember(copy: Readonly<Record<string, unknown>>, at: keyof typeof RETIRED_VALUE_MEMBERS): readonly string[] | undefined;
214
+ /** Where a declaration's credential reference sits on each surface. */
215
+ export declare const CREDENTIALS_MEMBER: Readonly<{
216
+ readonly mcp: readonly string[];
217
+ readonly a2a: readonly string[];
218
+ }>;
219
+ /** The credential reference a received copy holds (absent ⇒ `undefined`), judged by the one reader; a problem as a sentence. */
220
+ export declare function declaredCredentials(copy: object, at: keyof typeof CREDENTIALS_MEMBER): {
221
+ readonly ref?: CredentialRef;
222
+ } | {
223
+ readonly problem: string;
224
+ };
225
+ /** A declaration that names a credential reference while no seat is wired: nobody would answer it (`config.peer_seat_missing`). */
226
+ export declare function peerSeatMissing(subject: string, credentials: CredentialRef | undefined, seat: PeerSeat | undefined): (Error & {
227
+ code: string;
228
+ }) | undefined;
229
+ /** Who an MCP server is, as the seat is asked about it: its name, the whole start command or endpoint, its reference, its mount identity. */
230
+ export declare function mcpPeerTarget(spec: McpServerSpec, kind: "stdio" | "http" | undefined): PeerSeatTarget;
231
+ /** Whether a failure is the HTTP endpoint answering 401 (the SDK's status error, on the thrown value or its cause chain). Structure only. */
232
+ export declare function answeredUnauthorized(err: unknown): boolean;
233
+ /** A call answered 401 after which the seat's re-ask answered other pieces: its failure as it would have been thrown then. */
234
+ export declare class Reauthorized {
235
+ readonly error: unknown;
236
+ constructor(error: unknown);
237
+ }
238
+ /**
239
+ * The call layer's one re-send after a 401: `attempt(false)` once; when it answers {@link Reauthorized} and `mayResend`
240
+ * (the revocation probe and `reach`, asked again) holds, `attempt(true)` once more, carrying what the re-ask answered — the flag says
241
+ * whether this is the last attempt (its refusal is the call's answer). A re-send the seat could not furnish ends with the first
242
+ * attempt's failure, whose delivery verdict stands for the call (one of its attempts was sent).
243
+ */
244
+ export declare function sentOnceMore<R>(attempt: (last: boolean) => Promise<R | Reauthorized>, mayResend: () => boolean): Promise<R>;
245
+ export declare function inFlight<T>(client: object, run: () => Promise<T>): Promise<T>;
246
+ export declare function settledInFlight(client: object): Promise<void>;
247
+ export declare function recordCarrier(client: object, carrier: PeerCarrier): void;
248
+ export declare function carrierOf(client: object): PeerCarrier | undefined;