@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
@@ -1,8 +1,8 @@
1
1
  import { isAbsolute, sep } from "node:path";
2
2
  import { deliverEngineNotice } from "../types.js";
3
3
  import { admitMemoryScopes } from "../memory-admission.js";
4
- import { adoptLegacyRepoDirs, canonicalize, deriveRepoControlPlaneDir, deriveProjectControlDir, deriveProjectMemoryDir, deriveRepoMemoryDir, drainMemoryAnnouncements, effectiveControlRootOf, enqueueMemoryAnnouncement, isContainedIn, lookupProjectIdHint, recordProjectIdHint, resolveMemoryEngineRoot } from "../memory-engine/layout.js";
5
- import { classifyScopePlanes, derivePersonalControlDir, derivePersonalMemoryDir, mergeHarvestReports, mergeInjections, needsDualRoots, parsedProjectPlane } from "../memory-engine/dual-root.js";
4
+ import { adoptLegacyRepoDirs, canonicalize, deriveRepoControlPlaneDir, deriveProjectControlDir, deriveProjectMemoryDir, deriveRepoKey, deriveRepoMemoryDir, effectiveControlRootOf, isContainedIn, lookupProjectIdHint, recordProjectIdHint, resolveMemoryEngineRoot, transferMemoryAnnouncements } from "../memory-engine/layout.js";
5
+ import { derivePersonalControlDir, derivePersonalMemoryDir, directoryPinOf, memoryPlaneStore, mergeHarvestReports, mergeInjections, needsDualRoots, parsedProjectPlane, scopePlanesOf } from "../memory-engine/dual-root.js";
6
6
  import { memoryProjectScopeAbsentNotice, normalizeMemorySpec } from "../memory.js";
7
7
  import { deriveSupersededSet } from "../memory-engine/consolidation.js";
8
8
  import { shadowNamesOf } from "../memory-engine/shadowing.js";
@@ -11,8 +11,7 @@ import { adjudicateCaptureOptOut, captureOptOutDeniedError, captureOptOutUnpersi
11
11
  import { readSessionCaptureOptOut } from "../memory-engine/layout.js";
12
12
  import { sessionIncarnationResolver } from "../memory-engine/session-incarnation.js";
13
13
  import { createMemoryEngineTools } from "../memory-engine/tools.js";
14
- import { assertScopeContractPlacement, parseScopeKey, resolveProjectId } from "../memory-engine/scope-contract.js";
15
- import { FileMemoryEngineBackend } from "../memory-engine/file-backend.js";
14
+ import { assertScopeContractPlacement, parseScopeKey } from "../memory-engine/scope-contract.js";
16
15
  import { writableRootOf } from "../memory-engine/types.js";
17
16
  import { catalogText } from "../../prompt-assembly/catalog/index.js";
18
17
  import { asThrownError, thrownText } from "../thrown-value.js";
@@ -101,7 +100,7 @@ export async function prepareMemory(input) {
101
100
  const backend = deps.memoryBackend;
102
101
  const lineageTokens = new Map(input.captureForkOrigin !== undefined && input.captureForkOriginIncarnation !== undefined ? [[input.captureForkOrigin, input.captureForkOriginIncarnation]] : []);
103
102
  const incarnationOpt = { sessionIncarnation: sessionIncarnationResolver(sessionId, input.sessionIncarnation, lineageTokens) };
104
- const pinned = backend.directoryRoot;
103
+ const pinned = directoryPinOf(backend);
105
104
  const engineRoot = resolveMemoryEngineRoot(deps.memoryEngineDir);
106
105
  const repoRoot = deps.rootPath ?? taskRootPath;
107
106
  if (repoRoot) {
@@ -112,30 +111,12 @@ export async function prepareMemory(input) {
112
111
  const consumesProjectIdentity = [...memorySpec.scopes, ...(memorySpec.writeScope !== null ? [memorySpec.writeScope] : [])]
113
112
  .map(parseScopeKey)
114
113
  .some((k) => k.kind === "proj" || k.kind === "userproj");
115
- let marker = null;
116
- try {
117
- marker = resolveProjectId(repoRoot);
118
- }
119
- catch (err) {
120
- if (consumesProjectIdentity)
121
- throw err;
122
- deps.onError?.(asThrownError(err), { phase: "config", sessionId });
123
- }
114
+ if (input.sessionProject.markerFault !== undefined && consumesProjectIdentity)
115
+ throw input.sessionProject.markerFault;
116
+ const marker = input.sessionProject.project?.source === "marker" ? { projectId: input.sessionProject.project.id } : undefined;
117
+ const verdictOnPartitionRoot = deriveRepoKey(input.sessionProject.root) === deriveRepoKey(repoRoot);
124
118
  if (marker) {
125
119
  identityKey = marker.projectId;
126
- const firstSwitch = lookupProjectIdHint(engineRoot, repoRoot) !== marker.projectId;
127
- recordProjectIdHint(engineRoot, repoRoot, marker.projectId);
128
- if (firstSwitch) {
129
- try {
130
- const oldCtl = deriveRepoControlPlaneDir(engineRoot, repoRoot);
131
- const newCtl = deriveProjectControlDir(engineRoot, marker.projectId);
132
- const drained = drainMemoryAnnouncements(oldCtl);
133
- for (const ann of drained.queue)
134
- enqueueMemoryAnnouncement(newCtl, ann);
135
- }
136
- catch {
137
- }
138
- }
139
120
  if (memorySpec.writeScope !== null) {
140
121
  const w = parseScopeKey(memorySpec.writeScope);
141
122
  if ((w.kind === "proj" || w.kind === "userproj") && w.projectId !== marker.projectId) {
@@ -145,8 +126,21 @@ export async function prepareMemory(input) {
145
126
  throw e;
146
127
  }
147
128
  }
129
+ const firstSwitch = verdictOnPartitionRoot && lookupProjectIdHint(engineRoot, repoRoot) !== marker.projectId;
130
+ if (verdictOnPartitionRoot)
131
+ recordProjectIdHint(engineRoot, repoRoot, marker.projectId);
132
+ if (firstSwitch) {
133
+ try {
134
+ const oldCtl = deriveRepoControlPlaneDir(engineRoot, repoRoot);
135
+ const newCtl = deriveProjectControlDir(engineRoot, marker.projectId);
136
+ transferMemoryAnnouncements(oldCtl, newCtl);
137
+ }
138
+ catch (err) {
139
+ deps.onError?.(asThrownError(err), { phase: "config", sessionId });
140
+ }
141
+ }
148
142
  }
149
- else {
143
+ else if (verdictOnPartitionRoot) {
150
144
  const hint = lookupProjectIdHint(engineRoot, repoRoot);
151
145
  if (hint !== undefined) {
152
146
  deps.onError?.(new Error(`memory project marker missing but recoverable: ${repoRoot} previously carried projectId ${hint} ` +
@@ -155,13 +149,9 @@ export async function prepareMemory(input) {
155
149
  }
156
150
  }
157
151
  }
158
- const memoryDir = typeof pinned === "string" && pinned
159
- ? pinned
160
- : identityKey !== undefined
161
- ? deriveProjectMemoryDir(engineRoot, identityKey)
162
- : deriveRepoMemoryDir(engineRoot, repoRoot);
152
+ const memoryDir = pinned ?? (identityKey !== undefined ? deriveProjectMemoryDir(engineRoot, identityKey) : deriveRepoMemoryDir(engineRoot, repoRoot));
163
153
  const projectControlDir = identityKey !== undefined ? deriveProjectControlDir(engineRoot, identityKey) : deriveRepoControlPlaneDir(engineRoot, repoRoot);
164
- const planes = memorySpec.scopeContract === "v2" ? classifyScopePlanes(memorySpec.scopes, memorySpec.writeScope) : undefined;
154
+ const planes = scopePlanesOf(memorySpec.scopes, memorySpec.writeScope, memorySpec.scopeContract);
165
155
  const dual = planes !== undefined && needsDualRoots(planes);
166
156
  const personalOnly = planes !== undefined && !dual && planes.project.length === 0 && planes.writePlane !== "project" && (planes.personal.length > 0 || planes.writePlane === "personal");
167
157
  if (memorySpec.scopeContract === "v2" && !personalOnly) {
@@ -176,7 +166,6 @@ export async function prepareMemory(input) {
176
166
  const personalMemoryDir = derivePersonalMemoryDir(engineRoot);
177
167
  const personalControlDir = derivePersonalControlDir(engineRoot);
178
168
  const captureStoreOpt = (dir, b, configured) => deps.memoryCaptureRecordStore !== undefined ? { captureRecordStore: deps.memoryCaptureRecordStore({ controlDir: effectiveControlRootOf(dir, { pinnedBy: b, controlDir: configured }) }) } : {};
179
- const choosePersonalBackend = () => typeof pinned === "string" && pinned ? new FileMemoryEngineBackend(personalMemoryDir, { controlDir: personalControlDir }) : backend;
180
169
  const createPersonalEngine = (personalBackend) => {
181
170
  return {
182
171
  engine: new MemoryEngine({ backend: personalBackend, memoryDir: personalMemoryDir, controlDir: personalControlDir, onIncident: onEngineIncident, provenance: input.memoryProvenance, ...captureStoreOpt(personalMemoryDir, personalBackend, personalControlDir), ...incarnationOpt, ...(input.deps.memoryConsolidation !== undefined ? { consolidation: input.deps.memoryConsolidation } : {}) }),
@@ -340,7 +329,7 @@ export async function prepareMemory(input) {
340
329
  return {};
341
330
  };
342
331
  if (dual) {
343
- const personalBackendChosen = choosePersonalBackend();
332
+ const personalBackendChosen = memoryPlaneStore("personal", backend, engineRoot);
344
333
  {
345
334
  const projCtl = effectiveControlRootOf(memoryDir, { pinnedBy: backend, controlDir: projectControlDir });
346
335
  const persCtl = effectiveControlRootOf(personalMemoryDir, { pinnedBy: personalBackendChosen, controlDir: personalControlDir });
@@ -447,7 +436,7 @@ export async function prepareMemory(input) {
447
436
  };
448
437
  }
449
438
  else if (personalOnly) {
450
- const personal = createPersonalEngine(choosePersonalBackend());
439
+ const personal = createPersonalEngine(memoryPlaneStore("personal", backend, engineRoot));
451
440
  const personalEngine = personal.engine;
452
441
  await armCaptureOptOut(personalEngine);
453
442
  const handle = await personalEngine.materialize(memorySpec.scopes, memorySpec.writeScope, { adoptionRestricted: adoptionRestricted || captureOptedOut || captureIndeterminate, sessionId });
@@ -23,7 +23,7 @@ import type { AgentHarness, AgentMessage, AgentTool, ExecutionEnv } from "../../
23
23
  import { type CallTargetStamp } from "../effective-path-target.js";
24
24
  import { type OnQuestion } from "../ask-question.js";
25
25
  import { type CheckpointStore } from "../checkpoint-store.js";
26
- import type { GrantBindingOf } from "../skill-grant-binding.js";
26
+ import { type GrantBindingOf } from "../skill-grant-binding.js";
27
27
  import type { SessionStore } from "../session.js";
28
28
  import { type OnAsk, type ToolCallRequest, type ToolPolicy } from "../tool-policy.js";
29
29
  import { type ToolResultStore } from "../tool-result-store.js";
@@ -8,6 +8,7 @@ import { boundInputHashOf, exactBoundInputHashOf } from "../canonical-json.js";
8
8
  import { buildRiskDescriptor, debitLedger, encodeAtFidelity, mintCheckpointId, mintCheckpointToken, resolveDeclaredFidelity, } from "../checkpoint-store.js";
9
9
  import { pauseOf } from "../pause-registry.js";
10
10
  import { samePlainValue } from "../same-plain-value.js";
11
+ import { requestGrantBinding } from "../skill-grant-binding.js";
11
12
  import { askCarryRowMembers } from "../hooks.js";
12
13
  import { askMandateMember, ownedClearanceFacts } from "../ask-origin.js";
13
14
  import { defaultTaskRegistry } from "../task-registry.js";
@@ -171,7 +172,7 @@ export function prepareParkAsk(input) {
171
172
  ...callFaceSeat(req.face),
172
173
  ...(handsCwdRef !== undefined ? { cwd: handsCwdRef.current } : {}), ...(handsRoot !== undefined ? { root: handsRoot } : {}),
173
174
  ...advertisedWritableRootsSeat(advertisedWritableDirs),
174
- ...exemptRootsSeat(exemptRoots),
175
+ ...exemptRootsSeat(exemptRoots), ...requestGrantBinding(grantBindingOf, req, presented.value),
175
176
  });
176
177
  const withReading = stampCallTarget?.(reprojectedReq(), cutSignal);
177
178
  const reprojectedRaced = await raceSettlementAgainstSignal(withReading === undefined ? Promise.resolve(basePolicyForResumeEdit.check(reprojectedReq(), cutSignal)) : withReading.then((r) => basePolicyForResumeEdit.check(r, cutSignal)), cutSignal);
@@ -33,7 +33,7 @@ import type { RunnerDeps, RuntimeCaps, TaskSpec, ToolEffect } from "../types.js"
33
33
  import type { CwdRef } from "../../tools/fs/fs-shared.js";
34
34
  import type { ReadDenyMatcher } from "../../tools/fs/read-deny.js";
35
35
  import { type SkillGrantLane, type SkillGrantSource, type SkillGrantTable } from "../skill-grant.js";
36
- import type { GrantBindingOf } from "../skill-grant-binding.js";
36
+ import { type GrantBindingOf } from "../skill-grant-binding.js";
37
37
  import type { ToolSelector } from "../tool-face.js";
38
38
  import { type AllowEntryLane, type AllowEntryTable } from "../allow-entry.js";
39
39
  import type { InheritedGate, IrreversibilityTier, PrepareResume, RunInternals, StopForDenialLimit } from "./contracts.js";
@@ -48,8 +48,8 @@ export interface PreparePolicyChainInput {
48
48
  hostFloor: HostFloor | undefined;
49
49
  /** borrowed-readonly — the REBOUND spec. Read: `sessionId` / `principal` (the session-rule read and the lanes' identity),
50
50
  * `durableApproval` / `checkpointStore` (the mandate-park facility test and the sandbox arming's park prerequisites), `taskId` (the late-ask observer's detail),
51
- * `tools` (the names the caller mounted, for the name audit). Never mutated. */
52
- spec: Pick<TaskSpec, "sessionId" | "principal" | "durableApproval" | "taskId" | "checkpointStore" | "tools" | "excludeAllTools">;
51
+ * `tools` (the names the caller mounted, for the name audit), `classifyAllShell` (every allow member's auto strip). Never mutated. */
52
+ spec: Pick<TaskSpec, "sessionId" | "principal" | "durableApproval" | "taskId" | "checkpointStore" | "tools" | "excludeAllTools" | "classifyAllShell">;
53
53
  /** borrowed-readonly — the deployment seats: `sessionPolicyStore` (the rule reads),
54
54
  * `permissionRuleStore` / `localOwnerRules` (the lanes and the offer factory), `onError` / `onNotice` (the advisories,
55
55
  * the refusal disclosures, the late-ask observer), `tracer` (the admission and rule-store frames), `checkpointStore` (the park facility). Receiver preserved;
@@ -66,9 +66,11 @@ export interface PreparePolicyChainInput {
66
66
  hostTaskId: string;
67
67
  /** borrowed-readonly — the FINAL task root (path rules resolve against it; the lanes' and the offers' root). */
68
68
  taskRootFinal: string;
69
- /** borrowed-readonly — the leg's canonical write roots beyond the task root (`additionalDirectories` + advertised writable
70
- * dirs): the `acceptEdits` mode gate allows writes inside the root and these, and asks outside them all. */
69
+ /** borrowed-readonly — the leg's canonical write roots beyond its write location (`additionalDirectories` + advertised writable
70
+ * dirs): the `acceptEdits` mode gate allows writes inside the write location and these, and asks outside them all. */
71
71
  additionalRootsCanonical: readonly string[];
72
+ /** borrowed-readonly — the leg's ONE write-location reader (`writeLocationOf`), read per call by the `acceptEdits` gate. */
73
+ writeLocation: () => string;
72
74
  /** borrowed-readonly — the run's resolved env (path rules resolve in it; the sandbox declaration is read off it). */
73
75
  executionEnv: ExecutionEnv;
74
76
  /** borrowed-readonly — the frozen preflight as installed on this leg: `toolPolicy` (the caller slot) and
@@ -166,8 +168,6 @@ export interface PreparePolicyChainInput {
166
168
  /** borrowed-readonly — the leg's live permission-mode seat: the mode gate policy layer and the inherited stations' arbitration
167
169
  * read `current` per call. */
168
170
  permissionMode: PermissionModeController;
169
- /** borrowed-readonly — the task's scratchpad directory (the mode write gate's one exemption), or undefined. */
170
- scratchpadDir: string | undefined;
171
171
  /** borrowed-readonly — the leg's live roster seat; the mode write gate reads `current` per call. */ toolRosterDeltas: NonNullable<ModeGateSeats["roster"]>;
172
172
  /** borrowed-readonly — the run's ONE typed stop for a denial-limit bound (the fallback settlements call it). */
173
173
  stopForDenialLimit: StopForDenialLimit;
@@ -15,10 +15,11 @@ import { approvalCardMemberOf } from "../tool-roster.js";
15
15
  import { NAMESPACED_NAME_SHAPES } from "../protocol-table.js";
16
16
  import { emitTrace } from "../trace.js";
17
17
  import { skillGrantBindingMembers } from "../skill-grant.js";
18
+ import { withArgsBinding } from "../skill-grant-binding.js";
18
19
  import { SKILL_TOOL_NAME } from "./synthetic-tools.js";
19
- import { delegationPoolReading } from "./sub-agent-deny-lists.js";
20
+ import { delegationPoolReading, policyNameRefusal, POLICY_NAME_REFUSAL_CODE } from "./sub-agent-deny-lists.js";
20
21
  import { valveLeaves } from "../../agents/tool-filter.js";
21
- import { autoStrippedRule, cardDisclosureOf, rootFacingToolNames } from "../allow-entry.js";
22
+ import { autoStrippedRule, cardDisclosureOf, classifiesAllShell, rootFacingToolNames } from "../allow-entry.js";
22
23
  import { arbitrateByMode, askClassMembersOf, askFaceOf, askMandateMember } from "../ask-origin.js";
23
24
  import { createModeGatePolicy, mountedToolDeclaresReadOnly } from "../mode-policy.js";
24
25
  const ancestorFacts = (ask) => ({ ...(ask ?? {}), ancestorResolved: true });
@@ -32,7 +33,7 @@ import { policyThrowLine, reportPolicyThrow } from "./policy-throw.js";
32
33
  import { heldBy, heldValues, seatOf, wireOf } from "../tool-name-readings.js";
33
34
  import { hostFloorPolicy } from "../host-floor.js";
34
35
  export async function preparePolicyChain(input) {
35
- const { spec, deps, internals, sessionId, runId, hostTaskId, taskRootFinal, additionalRootsCanonical, executionEnv, lockedPreflight, pathRuleAnchors, headLeads, tools, harnessTools, selector, toolEffects, egressTools, irreversibilityTier, axisExplicitNegatives, shellGatedTools, toolMarkSources, envHandToolNames, handsCwdRef, readDenyMatcher, personRows, questionToolMounted, runtimeCaps, inheritedAncestorRules, ancestorSessionRulesRef, inheritedParentConstraints, seedInheritedGate, skillGrants, skillSpecs, allowedToolTables, frozenOnAsk, hookEnvSource, notifyOwnHookCrash, modBus, ownModChain, autoModeDecider, readFace, permissionMode, scratchpadDir, toolRosterDeltas, stopForDenialLimit, delegation, abortController, now, ownSessionRulesRef, hostFloor } = input;
36
+ const { spec, deps, internals, sessionId, runId, hostTaskId, taskRootFinal, additionalRootsCanonical, writeLocation, executionEnv, lockedPreflight, pathRuleAnchors, headLeads, tools, harnessTools, selector, toolEffects, egressTools, irreversibilityTier, axisExplicitNegatives, shellGatedTools, toolMarkSources, envHandToolNames, handsCwdRef, readDenyMatcher, personRows, questionToolMounted, runtimeCaps, inheritedAncestorRules, ancestorSessionRulesRef, inheritedParentConstraints, seedInheritedGate, skillGrants, skillSpecs, allowedToolTables, frozenOnAsk, hookEnvSource, notifyOwnHookCrash, modBus, ownModChain, autoModeDecider, readFace, permissionMode, toolRosterDeltas, stopForDenialLimit, delegation, abortController, now, ownSessionRulesRef, hostFloor } = input;
36
37
  const ancestorArbitrations = new Map();
37
38
  const arbitrateInherited = (ask, toolCallId, judged) => {
38
39
  const verdict = arbitrateByMode(permissionMode.current, judged.classification, { origin: judged.origin, ...askMandateMember(ancestorFacts(judged.ask.action === "ask" ? judged.ask : undefined)) });
@@ -44,7 +45,8 @@ export async function preparePolicyChain(input) {
44
45
  return { action: "deny", message: `refused by the ${verdict.mode} permission mode at an inherited ancestor layer (${verdict.askClass})`, decisionReason: "mode" };
45
46
  };
46
47
  const policy = lockedPreflight.toolPolicy;
47
- const auditPolicyNames = (auditee, inherited = false) => {
48
+ const auditPolicyNames = (auditee, layer = "caller_policy") => {
49
+ const refused = [];
48
50
  const nameGroups = toolPolicyNameSets(auditee);
49
51
  if (nameGroups.length > 0) {
50
52
  const known = mountedToolNames(tools);
@@ -58,7 +60,7 @@ export async function preparePolicyChain(input) {
58
60
  for (const [kind, list] of [["deny", g.deny], ["ask", g.ask], ["allow", g.allow]]) {
59
61
  for (const n of list ?? []) {
60
62
  const verdict = judgeRuleToolName(n, known, kind);
61
- const twin = verdict.kind === "current" && !inherited ? nearMissSpellingOf(n, rootFacing) : undefined;
63
+ const twin = verdict.kind === "current" && layer !== "ancestor_session_rules" ? nearMissSpellingOf(n, rootFacing) : undefined;
62
64
  const stale = verdict.kind !== "current" ? verdict : twin !== undefined ? { kind: "case_twin", twin, carrier: known.has(twin) || callerNames.has(twin) ? "run" : pool.names.has(twin) ? "pool" : "catalog" } : undefined;
63
65
  if (stale !== undefined) {
64
66
  const entry = `tool policy ${kind}-list entry "${n}"`;
@@ -81,9 +83,8 @@ export async function preparePolicyChain(input) {
81
83
  return exhaustive;
82
84
  }
83
85
  }
84
- const err = new Error(message);
85
- err.code = "config.legacy_tool_name";
86
- throw err;
86
+ refused.push({ message, problem: { code: POLICY_NAME_REFUSAL_CODE, field: kind, entry: n, reason: stale.kind === "case_twin" ? "near_miss" : stale.kind, layer } });
87
+ continue;
87
88
  }
88
89
  if (known.has(n))
89
90
  continue;
@@ -93,6 +94,8 @@ export async function preparePolicyChain(input) {
93
94
  }
94
95
  }
95
96
  }
97
+ if (refused[0] !== undefined)
98
+ throw policyNameRefusal(refused[0], refused.slice(1));
96
99
  const dedupeKey = [...unmatched].sort().join("|");
97
100
  const advised = advisedPolicyNames.get(deps) ?? new Set();
98
101
  if (unmatched.size > 0 && !advised.has(dedupeKey)) {
@@ -162,9 +165,9 @@ export async function preparePolicyChain(input) {
162
165
  check: (creq) => checkToolPolicyProjection(entry, creq) ?? { action: "allow" },
163
166
  }));
164
167
  const narrowingLayers = [hostFloor !== undefined ? hostFloorPolicy(hostFloor) : undefined, sessionRulePolicy, ...ancestorRulePolicies, ...frozenConstraintLayers].filter((p) => p !== undefined);
165
- auditPolicyNames(sessionRulePolicy);
168
+ auditPolicyNames(sessionRulePolicy, "session_rules");
166
169
  for (const layer of ancestorRulePolicies)
167
- auditPolicyNames(layer, true);
170
+ auditPolicyNames(layer, "ancestor_session_rules");
168
171
  const denyNarrowingPolicy = narrowingLayers.length === 0 ? undefined : narrowingLayers.length === 1 ? narrowingLayers[0] : combinePolicies(...narrowingLayers);
169
172
  const basePolicyForResumeEdit = lockedPreflight.basePolicyForResumeEdit ?? lockedPreflight.toolPolicy;
170
173
  const ownChainJudges = chainJudges(modBus);
@@ -316,7 +319,7 @@ export async function preparePolicyChain(input) {
316
319
  };
317
320
  };
318
321
  const inheritedAskEvidence = inheritedAskRuleEvidence(deps.permissionRuleStore);
319
- const listFacts = { root: taskRootFinal, sessionId, liveCwd: () => handsCwdRef?.current, anchors: pathRuleAnchors.leg };
322
+ const listFacts = { root: taskRootFinal, sessionId, liveCwd: () => handsCwdRef?.current, anchors: pathRuleAnchors.leg, classifyAllShell: classifiesAllShell(spec) };
320
323
  const skillGrantLane = skillGrants.lane(listFacts);
321
324
  const allowEntryLanes = { request: allowedToolTables.request.lane(listFacts), deployment: allowedToolTables.deployment.lane(listFacts) };
322
325
  const ruleLaneFacts = {
@@ -331,7 +334,7 @@ export async function preparePolicyChain(input) {
331
334
  questionToolName: ASK_USER_QUESTION_TOOL_NAME,
332
335
  onRevisionDefect: (message) => deps.onError?.(new Error(message), { phase: "config", sessionId }),
333
336
  onDisclosure: (message) => emitTrace(deps.tracer, () => ({ kind: "permission.rule_store_unreadable", version: 1, taskId: hostTaskId, message, ts: Date.now() })),
334
- stripsAllow: (rule, req) => permissionMode.current === "auto" && autoStrippedRule(rule, req),
337
+ stripsAllow: (rule, req) => autoStrippedRule(rule, req, permissionMode.current, listFacts.classifyAllShell),
335
338
  };
336
339
  const { personal: permissionRuleLane, org: permissionRuleOrgLane } = createPermissionRuleLanes({ provider: deps.permissionRuleStore, localOwnerDeclared: deps.localOwnerRules === true, principal: spec.principal, ...ruleLaneFacts, rows: personRows });
337
340
  const ruleOffersOf = createRuleOffersOf({
@@ -382,7 +385,7 @@ export async function preparePolicyChain(input) {
382
385
  else if (re.action === "allow") {
383
386
  return onApproval(withAttestation({ action: "allow", updatedInput: editArgs, decisionReason: "mode" }, re.attestation));
384
387
  }
385
- const judged = await judgeInheritedClassifier({ liveMode: () => permissionMode.current, autoMode: read.kind === "rewritten" ? undefined : 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 } : {}), route: frozenApproverRoute(onAskOf), onNotice: deps.onNotice, sessionId, runId }) });
388
+ const judged = await judgeInheritedClassifier({ liveMode: () => permissionMode.current, autoMode: read.kind === "rewritten" ? undefined : ancestorAutoMode, ask: re, req: withArgsBinding(creq, editArgs), signal: csignal ?? abortController.signal, subject: "the approved edit", allowRewrite: editArgs, facts: inheritedStationFacts(creq), unavailableSeat: classifierUnavailableSeat({ station: "ancestor", ...(ancestorDecider?.timeoutMs !== undefined ? { budgetMs: ancestorDecider.timeoutMs } : {}), route: frozenApproverRoute(onAskOf), onNotice: deps.onNotice, sessionId, runId }) });
386
389
  if (judged.kind === "allow") {
387
390
  return onApproval(judged.result);
388
391
  }
@@ -439,7 +442,7 @@ export async function preparePolicyChain(input) {
439
442
  return settledAs(mandateUnreconstructibleDeny(creq));
440
443
  }
441
444
  const presentedArgs = decision.updatedInput !== undefined ? argsAsTheToolReads(creq, decision.updatedInput) : creq.args;
442
- const judged = await judgeInheritedClassifier({ liveMode: () => permissionMode.current, autoMode: pc.autoMode, ask: decision, req: { ...creq, args: presentedArgs }, signal: csignal ?? abortController.signal, subject: "this call", allowRewrite: decision.updatedInput, facts: inheritedStationFacts(creq), unavailableSeat: classifierUnavailableSeat({ station: "ancestor", ...(pc.autoMode?.decider.timeoutMs !== undefined ? { budgetMs: pc.autoMode.decider.timeoutMs } : {}), route: frozenApproverRoute(pc.onAsk), onNotice: deps.onNotice, sessionId, runId }) });
445
+ const judged = await judgeInheritedClassifier({ liveMode: () => permissionMode.current, autoMode: pc.autoMode, ask: decision, req: withArgsBinding(creq, presentedArgs), signal: csignal ?? abortController.signal, subject: "this call", allowRewrite: decision.updatedInput, facts: inheritedStationFacts(creq), unavailableSeat: classifierUnavailableSeat({ station: "ancestor", ...(pc.autoMode?.decider.timeoutMs !== undefined ? { budgetMs: pc.autoMode.decider.timeoutMs } : {}), route: frozenApproverRoute(pc.onAsk), onNotice: deps.onNotice, sessionId, runId }) });
443
446
  if (judged.kind === "allow")
444
447
  return settledAs(judged.result);
445
448
  if (judged.kind === "deny")
@@ -609,7 +612,7 @@ export async function preparePolicyChain(input) {
609
612
  }
610
613
  return d;
611
614
  }));
612
- const modeGateLayer = createModeGatePolicy(permissionMode, { env: executionEnv, rootPath: taskRootFinal, acceptDirs: [taskRootFinal, ...additionalRootsCanonical], roster: toolRosterDeltas, readOnlyDeclared: (name) => mountedToolDeclaresReadOnly(tools, name), ...(scratchpadDir !== undefined ? { exemptDirs: [scratchpadDir] } : {}) });
615
+ const modeGateLayer = createModeGatePolicy(permissionMode, { env: executionEnv, rootPath: taskRootFinal, acceptDirs: () => [writeLocation(), ...additionalRootsCanonical], roster: toolRosterDeltas, readOnlyDeclared: (name) => mountedToolDeclaresReadOnly(tools, name) });
613
616
  const policyLayers = [...narrowingLayers, ...instrumentedChain, ...(rewriteCapableChain.length > 0 ? narrowingLayers : [])];
614
617
  const integrityGuardLayers = [createTranscriptIntegrityPolicy(), createUnverifiableDeletePolicy({ removalSeat: { env: executionEnv, additionalRoots: () => additionalRootsCanonical } })];
615
618
  const guardedPolicyLayers = [...integrityGuardLayers, ...policyLayers, modeGateLayer];
@@ -14,8 +14,8 @@ export interface PrepareProjectContextInput {
14
14
  /** borrowed-readonly — the REBOUND spec (`spec′`). Read: `sessionId` (phase derivation + the
15
15
  * continuation projections), `skills` (the roster), `userInvokedSkills` (the person's invoked skills — their
16
16
  * rows are written here), `principal` (the shared-memory tools' trusted identity), `projectMemory` (the request's
17
- * off switch for the seam — the config door's one reading). Never mutated. */
18
- spec: Pick<TaskSpec, "sessionId" | "skills" | "userInvokedSkills" | "principal" | "excludeAllTools" | "projectMemory">;
17
+ * off switch for the seam — the config door's one reading), `classifyAllShell` (the Skill card's auto strip). Never mutated. */
18
+ spec: Pick<TaskSpec, "sessionId" | "skills" | "userInvokedSkills" | "principal" | "excludeAllTools" | "projectMemory" | "classifyAllShell">;
19
19
  /** borrowed-readonly — trusted internals: `agentName` (seam ctx), `inheritedSkillGrants` (the parent's captured
20
20
  * skill grant rows, seeded as `inherited`), `inheritedAllowedTools` (the parent's request entries, seeded as this leg's
21
21
  * own). `undefined` on a standalone prepare. */
@@ -6,7 +6,7 @@ import { createSharedMemoryTools } from "../shared-memory/tools.js";
6
6
  import { SHARED_MEMORY_TOOL_NAMES } from "../shared-memory/types.js";
7
7
  import { defineTool } from "../tools.js";
8
8
  import { readFrozenSkillGrants, seedSkillGrants, skillSeatReader } from "../skill-grant.js";
9
- import { allowedToolsNotGrantedNotice, seedAllowEntryTables } from "../allow-entry.js";
9
+ import { allowedToolsNotGrantedNotice, classifiesAllShell, seedAllowEntryTables } from "../allow-entry.js";
10
10
  import { deliverEngineNotice } from "../engine-notice.js";
11
11
  import { announceMemoryNotMounted } from "./announce-once-ledger.js";
12
12
  import { SKILL_CONTENT_MAX_CHARS, SKILL_TOOL_NAME, createSkillTool, normalizeSkills } from "./synthetic-tools.js";
@@ -110,7 +110,7 @@ export async function prepareProjectContext(input) {
110
110
  }
111
111
  roster.mount(createSkillTool(skillSpecs, skillGrants), { source: "builtin", mountedBy: "optional" });
112
112
  }
113
- const skillSeatOf = skillSeatReader(skillSpecs, mounted);
113
+ const skillSeatOf = skillSeatReader(skillSpecs, classifiesAllShell(spec), mounted);
114
114
  const sharedMemoryProvider = deps.sharedMemoryStores;
115
115
  let sharedMemoryPairMounted = false;
116
116
  if (sharedMemoryProvider !== undefined) {
@@ -55,7 +55,7 @@ export interface PreparePromptInputsInput {
55
55
  * workflow tool): drives the orchestration prompt flags. */
56
56
  selfOrchestrationActive: boolean;
57
57
  /** borrowed-readonly — the task's execution env: `isIsolated` for the isolation flag, `exec` for the
58
- * one batched probe, `canonicalPath` for the alignment guard. Never re-bound, never destroyed here. */
58
+ * one batched probe (which also carries the cwd-alignment question). Never re-bound, never destroyed here. */
59
59
  executionEnv: ExecutionEnv;
60
60
  /** borrowed-readonly — the session's reminder mark (rides the prompt facts for the declaration). */
61
61
  reminderMark: string;
@@ -6,6 +6,7 @@ import { isIsolated } from "../remote-env.js";
6
6
  import { readDateAnchor } from "./conversation-segment.js";
7
7
  import { probeGitStatusLane } from "./git-status-frame.js";
8
8
  import { renderMcpInstructionsEntry } from "./turn-attachments.js";
9
+ import { cwdAlignmentProbe, cwdMisalignmentMessage, readCwdAlignment } from "./cwd-alignment-probe.js";
9
10
  const ULTRA_REASONING_TIERS = new Set(["xhigh", "max"]);
10
11
  import { compactionEnabled } from "../context-settings.js";
11
12
  export async function preparePromptInputs(input) {
@@ -83,7 +84,7 @@ export async function preparePromptInputs(input) {
83
84
  envFacts.additionalReadDirectories = [...additionalReadRootsCanonical];
84
85
  }
85
86
  try {
86
- const probe = await executionEnv.exec('uname -s; uname -r; (git rev-parse --is-inside-work-tree 2>/dev/null || echo false); (git symbolic-ref --short -q HEAD 2>/dev/null || echo "HEAD (detached)"); (git rev-parse --show-toplevel 2>/dev/null || echo); (test -n "$(git status --porcelain 2>/dev/null | head -1)" && echo dirty || echo clean); (s=$(ps -p $$ -o comm= 2>/dev/null); s=${s##*/}; echo "${s#-}"); (test "$(git rev-parse --git-dir 2>/dev/null)" != "$(git rev-parse --git-common-dir 2>/dev/null)" && echo linked || echo main); (pwd -P 2>/dev/null || pwd)', { cwd: envFacts.cwd, timeout: 10 });
87
+ const probe = await executionEnv.exec('uname -s; uname -r; (git rev-parse --is-inside-work-tree 2>/dev/null || echo false); (git symbolic-ref --short -q HEAD 2>/dev/null || echo "HEAD (detached)"); (git rev-parse --show-toplevel 2>/dev/null || echo); (test -n "$(git status --porcelain 2>/dev/null | head -1)" && echo dirty || echo clean); (s=$(ps -p $$ -o comm= 2>/dev/null); s=${s##*/}; echo "${s#-}"); (test "$(git rev-parse --git-dir 2>/dev/null)" != "$(git rev-parse --git-common-dir 2>/dev/null)" && echo linked || echo main); ' + cwdAlignmentProbe(taskRootFinal), { cwd: envFacts.cwd, timeout: 10 });
87
88
  if (probe.ok && probe.value.exitCode === 0) {
88
89
  const lines = probe.value.stdout.split("\n");
89
90
  if (lines.length >= 6) {
@@ -109,24 +110,12 @@ export async function preparePromptInputs(input) {
109
110
  envFacts.shell = sh;
110
111
  if (envFacts.isGitRepo && (lines[7] ?? "").trim() === "linked")
111
112
  envFacts.isLinkedWorktree = true;
112
- const probedPwd = (lines[8] ?? "").trim();
113
- if (probedPwd && envFacts.cwd && probedPwd !== envFacts.cwd) {
114
- const canonOf = async (p) => {
115
- try {
116
- const c = await executionEnv.canonicalPath(p);
117
- return c.ok ? c.value : p;
118
- }
119
- catch {
120
- return p;
121
- }
122
- };
123
- const canonicalProbed = await canonOf(probedPwd);
124
- if (canonicalProbed !== (await canonOf(envFacts.cwd))) {
125
- try {
126
- deps.onError?.(new Error(`execution-env cwd misalignment: task root is "${envFacts.cwd}" but the env's shell reports pwd "${canonicalProbed}" — per-exec cwd injection may be ignored on this lane (execs/artifacts can land outside the workspace root)`), { phase: "config", sessionId });
127
- }
128
- catch {
129
- }
113
+ const alignment = readCwdAlignment(lines);
114
+ if (alignment?.verdict === "differ") {
115
+ try {
116
+ deps.onError?.(new Error(cwdMisalignmentMessage(taskRootFinal, alignment.shellPwd)), { phase: "config", sessionId });
117
+ }
118
+ catch {
130
119
  }
131
120
  }
132
121
  }
@@ -44,8 +44,8 @@ export interface PrepareProtocolToolsInput {
44
44
  spec: Pick<TaskSpec, "principal" | "tools" | "excludeAllTools" | "signal">;
45
45
  /** borrowed-readonly — the deployment seats the materializers and their operator faces read: `onElicit`
46
46
  * and `mcpImageResizer` ride into the MCP intake; `onError` takes the A2A warnings (no ledger — a peer is
47
- * re-read every prepare); `mcpRevocations` + `onNotice` make the revocation wiring. */
48
- deps: Pick<RunnerDeps, "onElicit" | "mcpImageResizer" | "onError" | "mcpRevocations" | "onNotice">;
47
+ * re-read every prepare); `mcpRevocations` + `onNotice` make the revocation wiring; `peerSeat` answers what each MCP / A2A request carries. */
48
+ deps: Pick<RunnerDeps, "onElicit" | "mcpImageResizer" | "onError" | "mcpRevocations" | "onNotice" | "peerSeat">;
49
49
  /** borrowed-readonly — the leg's mods bus: its `prompt.section` station disposes of each server's instructions at the dial. */
50
50
  modBus: LegModBus;
51
51
  /** borrowed-readonly — the run tree's MCP connection pool (the leg leases its connections from it) and whether THIS leg created it
@@ -59,6 +59,8 @@ export interface PrepareProtocolToolsInput {
59
59
  /** borrowed-mutable — the reminder-disclosure counters: the MCP intake's bounding writes them here, and
60
60
  * the run loop's attachment lanes keep writing the same object (`Prepared.reminderDisclosureCounts`). */
61
61
  reminderDisclosureCounts: Prepared["reminderDisclosureCounts"];
62
+ /** borrowed-readonly — the leg's request-meta seat: every minted MCP tool reads what stands for its call, and the leg's session id (`_meta`). */
63
+ mcpRequestMeta: import("../mcp-call-meta.js").McpLegMetaReader;
62
64
  /** borrowed-readonly — the run's invocation id (the revocation probe-failure notice names it). */
63
65
  runId: string;
64
66
  /** borrowed-readonly — the acquired session id (operator-line context). */
@@ -1,9 +1,10 @@
1
1
  import { Type } from "typebox";
2
- import { materializeMcpTools } from "../mcp.js";
2
+ import { materializeLegMcpTools } from "../mcp.js";
3
3
  import { applyMcpRosterDelta, commitMcpRosterChanges, redialMcpServer, rosterHolding, settledOnRoster } from "./mcp-redial.js";
4
4
  import { valveLeaves, valveLeavesPeer } from "../../agents/tool-filter.js";
5
5
  import { resourceFacesLeft } from "../mounted-mcp.js";
6
6
  import { materializeA2aTools } from "../a2a.js";
7
+ import { whereToAuthorize } from "../mcp-failure.js";
7
8
  import { deliverEngineNotice } from "../types.js";
8
9
  import { RosterBuilder } from "../tool-roster.js";
9
10
  import { TOOL_WIRE_NAME_MAX_CHARS } from "../tool-face.js";
@@ -30,7 +31,7 @@ export async function prepareProtocolTools(input) {
30
31
  const leaves = valveLeaves(spec, toolFaceSnapshot.selector);
31
32
  const resourcesReached = resourceFacesLeft(leaves);
32
33
  const mcp = lockedPreflight.mcp?.length
33
- ? 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 }, sectionDisposerOf(input.modBus, abortController.signal), (entry) => resourcesReached || serverReached(mintNamespacePrefix(MCP_NAMESPACE, entry.name)), AbortSignal.any([abortController.signal, ...(spec.signal !== undefined ? [spec.signal] : [])]), hostFloor)
34
+ ? await materializeLegMcpTools(input.mcpRequestMeta, lockedPreflight.mcp, spec.principal, deps.onElicit, deps.mcpImageResizer, { reminderMark, counts: reminderDisclosureCounts }, mcpRevocationWiring(deps, runId), mcpPool === undefined ? undefined : { pool: mcpPool.pool, ownsPool: mcpPool.owned }, sectionDisposerOf(input.modBus, abortController.signal), (entry) => resourcesReached || serverReached(mintNamespacePrefix(MCP_NAMESPACE, entry.name)), AbortSignal.any([abortController.signal, ...(spec.signal !== undefined ? [spec.signal] : [])]), hostFloor, deps.peerSeat, mcpAuthorizationNotice(deps, sessionId, runId, spec.principal))
34
35
  :
35
36
  { 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 () => { } };
36
37
  if (lockedPreflight.mcp?.length)
@@ -167,7 +168,7 @@ export async function prepareProtocolTools(input) {
167
168
  foldProtocolAxes(mcp.toolAxes, "MCP");
168
169
  const a2aDeclared = lockedPreflight.a2a;
169
170
  const a2a = a2aDeclared
170
- ? await materializeA2aTools(a2aDeclared, spec.principal, abortController.signal, hostFloor)
171
+ ? await materializeA2aTools(a2aDeclared, spec.principal, abortController.signal, hostFloor, deps.peerSeat)
171
172
  : { tools: [], toolAxes: [], warnings: [], statuses: [], refresh: async () => [], dispose: async () => { } };
172
173
  if (a2aDeclared)
173
174
  rollback.push(function a2aDispose() { return a2a.dispose(); });
@@ -187,6 +188,13 @@ export async function prepareProtocolTools(input) {
187
188
  foldProtocolAxes(a2a.toolAxes, "A2A");
188
189
  return { mcp, a2a, rebuildHarnessToolsRef, contentOriginWrapRef, toolCallGateArmedRef, ...(mcpRedial !== undefined ? { mcpRedial } : {}) };
189
190
  }
191
+ function mcpAuthorizationNotice(deps, sessionId, runId, principal) {
192
+ return (server, { reason, authorizeUrl }) => deliverEngineNotice(deps.onNotice, {
193
+ code: "mcp.authorization_required",
194
+ message: `MCP server "${server}" needs the user's authorization before it serves them (${reason}) — authorize it ${whereToAuthorize(authorizeUrl)}; its tools are unavailable until then.`,
195
+ detail: { server, reason, ...(authorizeUrl !== undefined ? { authorizeUrl } : {}), ...(principal !== undefined ? { principal } : {}), sessionId, runId },
196
+ });
197
+ }
190
198
  function mcpRevocationWiring(deps, runId) {
191
199
  if (deps.mcpRevocations === undefined)
192
200
  return undefined;
@@ -21,6 +21,7 @@ import { SubagentRetainLedger } from "../../agents/retain-ledger.js";
21
21
  import type { TaskEvent, TaskSpec } from "../types.js";
22
22
  import { SkillGrantTable } from "../skill-grant.js";
23
23
  import type { Prepared, RunInternals, ToolProgressLane } from "./contracts.js";
24
+ import type { ReviewRequest } from "../present-plan-tool.js";
24
25
  import type { PermissionModeController } from "../mode-policy.js";
25
26
  import { type EditedFilesLedger } from "./edited-files-ledger.js";
26
27
  import { type ToolOccurrenceTable } from "./tool-occurrence.js";
@@ -78,9 +79,7 @@ export interface PrepareRunRefsResult {
78
79
  * `plan_review` checkpoint is minted. */
79
80
  reviewRequestRef: Prepared["reviewRequestRef"];
80
81
  /** owned — the ctx primitive that arms `reviewRequestRef`. */
81
- requestReview: (opts?: {
82
- reason?: string;
83
- }) => void;
82
+ requestReview: (opts?: ReviewRequest) => void;
84
83
  /** borrowed-mutable — the stop-after-turn latch (`Prepared.stopRequestedRef`). Writers: `requestStopAfterTurn`
85
84
  * here, and nothing else; the run loop reads it at a turn boundary. */
86
85
  stopRequestedRef: Prepared["stopRequestedRef"];
@@ -30,7 +30,10 @@ export function prepareRunRefs(input) {
30
30
  const reviewRequestRef = {};
31
31
  const requestReview = (opts) => {
32
32
  if (reviewRequestRef.pending === undefined) {
33
- reviewRequestRef.pending = opts?.reason !== undefined ? { reason: opts.reason } : {};
33
+ reviewRequestRef.pending = {
34
+ ...(opts?.reason !== undefined ? { reason: opts.reason } : {}),
35
+ ...(opts?.requestedByCallId !== undefined ? { requestedByCallId: opts.requestedByCallId } : {}),
36
+ };
34
37
  }
35
38
  };
36
39
  const stopRequestedRef = { current: false };
@@ -169,6 +169,8 @@ export interface PrepareSuspendSagaInput {
169
169
  placementRootResolved: string;
170
170
  /** borrowed-readonly — this leg's checkpoint scope (the driver's one `checkpointScopeOf` derivation; the row's `legScope` stamp). */
171
171
  checkpointScope: string;
172
+ /** borrowed-readonly — the config doors' one reading of the leg's run origin (the row's `runOrigin` stamp; absent ⇒ the host said nothing). */
173
+ runOrigin: SerializedCheckpointState["runOrigin"];
172
174
  /** borrowed-readonly — the tool-selector layers this leg was spawned under (the live seat, else the resumed row's), the row's `toolCeiling` stamp. */
173
175
  toolCeiling: readonly import("../tool-face.js").ToolSelectorLayer[] | undefined;
174
176
  /** 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. */
@@ -82,7 +82,7 @@ function stampPlacementRootSessionId(placementRootResolved) {
82
82
  return placementValueOrAbsent(placementRootResolved);
83
83
  }
84
84
  export function prepareSuspendSaga(input) {
85
- const { gateMachineryActive, abortController, harness, checkpointStore, deps, sessionId, hostTaskId, taskScope, liveSpendRef, resume, nestedStats, internals, activeTools, outputRef, readFileStateForCheckpoint, faceCheckpointSection, writeFaceCheckpointSection, skillGrantCheckpointSection, skillScopesCheckpointSection, reminderMark, handsCwdRef, handsRoot, handsHome, worktreeSessionRef, undeliveredContinuationRef, inheritedParentConstraints, seedInheritedGate, ancestorRulesNow, inheritedShellGate, permissionMode, inheritedAdmittedOrgScopes, inheritedPathRuleAnchors, inheritedPathRuleInstallations, ownOrgVerdictRef, orgGovernedProvenance, announcedListingsRef, gitStatusRef, hookIdentity, placementRootResolved, checkpointScope, toolCeiling, toolListsJudged, ownToolLists, externalContentTargetActive, crossBoundary, remoteEnvFailures, memoryEngineSession, suspendLoopRef, ownedEnv, incompleteSuspendAdapter } = input;
85
+ const { gateMachineryActive, abortController, harness, checkpointStore, deps, sessionId, hostTaskId, taskScope, liveSpendRef, resume, nestedStats, internals, activeTools, outputRef, readFileStateForCheckpoint, faceCheckpointSection, writeFaceCheckpointSection, skillGrantCheckpointSection, skillScopesCheckpointSection, reminderMark, handsCwdRef, handsRoot, handsHome, worktreeSessionRef, undeliveredContinuationRef, inheritedParentConstraints, seedInheritedGate, ancestorRulesNow, inheritedShellGate, permissionMode, inheritedAdmittedOrgScopes, inheritedPathRuleAnchors, inheritedPathRuleInstallations, ownOrgVerdictRef, orgGovernedProvenance, announcedListingsRef, gitStatusRef, hookIdentity, placementRootResolved, checkpointScope, runOrigin, toolCeiling, toolListsJudged, ownToolLists, externalContentTargetActive, crossBoundary, remoteEnvFailures, memoryEngineSession, suspendLoopRef, ownedEnv, incompleteSuspendAdapter } = input;
86
86
  if (!gateMachineryActive)
87
87
  return { saga: undefined };
88
88
  const taskAccess = { owner: hostTaskId, scope: taskScope, sessionId };
@@ -178,6 +178,7 @@ export function prepareSuspendSaga(input) {
178
178
  placementRootSessionId: stampPlacementRootSessionId(placementRootResolved),
179
179
  externalContentTarget: externalContentTargetActive ? true : undefined,
180
180
  legScope: checkpointScope,
181
+ runOrigin,
181
182
  toolCeiling: toolCeiling !== undefined ? toolCeiling.map((l) => ({ ...(l.allow !== undefined ? { allow: persistedToolNameList(l.allow, "allowed") } : {}), deny: persistedToolNameList(l.deny, "denied") })) : undefined,
182
183
  toolListsJudged,
183
184
  ownToolLists: ownToolLists !== undefined ? { toolName: ownToolLists.toolName, ...(ownToolLists.definition !== undefined ? { definition: ownToolLists.definition } : {}), lists: ownToolLists.lists } : undefined,