@sema-agent/core 7.71.1 → 7.73.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 (348) hide show
  1. package/CHANGELOG.md +500 -0
  2. package/dist/agents/cross-session-ref.d.ts +2 -2
  3. package/dist/agents/cross-session-ref.js +7 -2
  4. package/dist/agents/inherited-tool-pool.d.ts +30 -2
  5. package/dist/agents/inherited-tool-pool.js +53 -7
  6. package/dist/agents/parked-resume-drive.d.ts +10 -0
  7. package/dist/agents/parked-resume-drive.js +9 -0
  8. package/dist/agents/retain-ledger.d.ts +3 -0
  9. package/dist/agents/send-message-tool.js +7 -2
  10. package/dist/agents/send-user-message-tool.d.ts +12 -0
  11. package/dist/agents/send-user-message-tool.js +67 -0
  12. package/dist/agents/subagent-steps.d.ts +9 -0
  13. package/dist/agents/subagent-steps.js +38 -0
  14. package/dist/agents/subagent.d.ts +2 -0
  15. package/dist/agents/subagent.js +47 -12
  16. package/dist/agents/verify.js +23 -7
  17. package/dist/agents/yield-adoption.js +3 -1
  18. package/dist/brain/anthropic.js +14 -9
  19. package/dist/brain/open-responses.js +4 -5
  20. package/dist/brain/openai.js +30 -23
  21. package/dist/brain/stream-engine.js +159 -151
  22. package/dist/core/a2a.d.ts +24 -3
  23. package/dist/core/a2a.js +27 -8
  24. package/dist/core/actions-digest.d.ts +43 -0
  25. package/dist/core/actions-digest.js +22 -0
  26. package/dist/core/agent-state.d.ts +28 -7
  27. package/dist/core/agent-state.js +19 -6
  28. package/dist/core/allow-entry.js +3 -3
  29. package/dist/core/approval-object.d.ts +7 -3
  30. package/dist/core/approval-object.js +30 -9
  31. package/dist/core/auto-mode.d.ts +7 -9
  32. package/dist/core/auto-mode.js +114 -8
  33. package/dist/core/checkpoint-features.d.ts +16 -5
  34. package/dist/core/checkpoint-features.js +35 -6
  35. package/dist/core/checkpoint-rekey.d.ts +1 -1
  36. package/dist/core/checkpoint-rekey.js +6 -1
  37. package/dist/core/checkpoint-requirements.d.ts +23 -3
  38. package/dist/core/checkpoint-requirements.js +5 -1
  39. package/dist/core/checkpoint-row-verdict.d.ts +1 -1
  40. package/dist/core/checkpoint-row-verdict.js +10 -4
  41. package/dist/core/checkpoint-store.d.ts +24 -2
  42. package/dist/core/checkpoint-store.js +1 -0
  43. package/dist/core/child-clamp-seats.d.ts +15 -0
  44. package/dist/core/child-clamp-seats.js +15 -0
  45. package/dist/core/delegation-frames.d.ts +1 -0
  46. package/dist/core/delegation-frames.js +1 -1
  47. package/dist/core/effective-path-target.d.ts +19 -0
  48. package/dist/core/effective-path-target.js +95 -38
  49. package/dist/core/engine-capabilities.d.ts +5 -1
  50. package/dist/core/engine-capabilities.js +1 -1
  51. package/dist/core/engine-notice.d.ts +34 -23
  52. package/dist/core/engine-version.js +1 -1
  53. package/dist/core/entries-not-applied.d.ts +19 -7
  54. package/dist/core/entries-not-applied.js +33 -1
  55. package/dist/core/file-history-store.d.ts +15 -4
  56. package/dist/core/file-history-store.js +53 -23
  57. package/dist/core/gate-fold.js +3 -1
  58. package/dist/core/governance-codes.d.ts +10 -1
  59. package/dist/core/governance-codes.js +17 -5
  60. package/dist/core/hooks.d.ts +3 -0
  61. package/dist/core/hooks.js +1 -0
  62. package/dist/core/host-instance.d.ts +23 -0
  63. package/dist/core/host-instance.js +69 -0
  64. package/dist/core/instruction-preview.d.ts +63 -0
  65. package/dist/core/instruction-preview.js +406 -0
  66. package/dist/core/judged-read.d.ts +57 -0
  67. package/dist/core/judged-read.js +1 -0
  68. package/dist/core/leg-budget.d.ts +26 -0
  69. package/dist/core/leg-budget.js +9 -0
  70. package/dist/core/leg-identity.d.ts +51 -1
  71. package/dist/core/leg-identity.js +45 -2
  72. package/dist/core/manager-launch-check.d.ts +48 -0
  73. package/dist/core/manager-launch-check.js +64 -0
  74. package/dist/core/mcp-call-meta.d.ts +2 -2
  75. package/dist/core/mcp-host-seat.d.ts +5 -0
  76. package/dist/core/mcp-host-seat.js +7 -1
  77. package/dist/core/mcp-injection-drop.d.ts +20 -10
  78. package/dist/core/mcp-injection-drop.js +9 -3
  79. package/dist/core/mcp-server-spec.d.ts +2 -1
  80. package/dist/core/mcp.js +3 -1
  81. package/dist/core/member-outcome.d.ts +3 -2
  82. package/dist/core/member-outcome.js +1 -1
  83. package/dist/core/memory-engine/deletion-record.d.ts +46 -0
  84. package/dist/core/memory-engine/deletion-record.js +96 -0
  85. package/dist/core/memory-engine/engine.js +24 -16
  86. package/dist/core/memory-engine/file-backend.js +7 -5
  87. package/dist/core/memory-engine/index.d.ts +1 -1
  88. package/dist/core/memory-engine/index.js +1 -1
  89. package/dist/core/memory-engine/layout.js +6 -4
  90. package/dist/core/memory-engine/projection-ledger.d.ts +1 -1
  91. package/dist/core/memory-engine/projection-ledger.js +1 -1
  92. package/dist/core/memory-engine/scope-contract.d.ts +69 -11
  93. package/dist/core/memory-engine/scope-contract.js +99 -34
  94. package/dist/core/memory-engine/sync-client.js +26 -6
  95. package/dist/core/memory-engine/sync.d.ts +20 -2
  96. package/dist/core/memory-engine/sync.js +18 -17
  97. package/dist/core/mode-policy.d.ts +21 -6
  98. package/dist/core/mode-policy.js +15 -6
  99. package/dist/core/mounted-mcp.d.ts +7 -2
  100. package/dist/core/mounted-mcp.js +10 -1
  101. package/dist/core/own-property-receipt.js +11 -4
  102. package/dist/core/param-rule-reach.d.ts +8 -3
  103. package/dist/core/param-rule-reach.js +9 -1
  104. package/dist/core/parent-spec-seat.d.ts +13 -1
  105. package/dist/core/parent-spec-seat.js +18 -0
  106. package/dist/core/peer-registration.d.ts +52 -0
  107. package/dist/core/peer-registration.js +37 -0
  108. package/dist/core/peer-seat.d.ts +3 -1
  109. package/dist/core/peer-seat.js +3 -3
  110. package/dist/core/peer-task-store.d.ts +365 -0
  111. package/dist/core/peer-task-store.js +682 -0
  112. package/dist/core/permission-rule-consent.js +6 -11
  113. package/dist/core/permission-rule-model.d.ts +27 -0
  114. package/dist/core/permission-rule-model.js +34 -6
  115. package/dist/core/permission-rule-provider.d.ts +35 -33
  116. package/dist/core/permission-rule-provider.js +38 -295
  117. package/dist/core/permission-rule-store.d.ts +181 -8
  118. package/dist/core/permission-rule-store.js +420 -17
  119. package/dist/core/permission-rule-sync.js +15 -1
  120. package/dist/core/project-seat.d.ts +55 -0
  121. package/dist/core/project-seat.js +96 -0
  122. package/dist/core/protocol-http-auth.d.ts +3 -2
  123. package/dist/core/protocol-http-auth.js +26 -18
  124. package/dist/core/remote-env.d.ts +4 -4
  125. package/dist/core/retired-keys.js +1 -0
  126. package/dist/core/rule-offer-read.d.ts +1 -1
  127. package/dist/core/rule-offer-read.js +32 -4
  128. package/dist/core/run-ledger-seat.d.ts +66 -0
  129. package/dist/core/run-ledger-seat.js +70 -0
  130. package/dist/core/run-ledger.d.ts +332 -0
  131. package/dist/core/run-ledger.js +550 -0
  132. package/dist/core/runner/chain-mismatch.d.ts +32 -0
  133. package/dist/core/runner/chain-mismatch.js +29 -0
  134. package/dist/core/runner/changes-history.d.ts +1 -0
  135. package/dist/core/runner/changes-history.js +2 -2
  136. package/dist/core/runner/checkpoint-scope.d.ts +13 -3
  137. package/dist/core/runner/checkpoint-scope.js +12 -4
  138. package/dist/core/runner/construction-doors.js +6 -0
  139. package/dist/core/runner/contracts.d.ts +22 -3
  140. package/dist/core/runner/delegation-owner.d.ts +30 -0
  141. package/dist/core/runner/delegation-owner.js +20 -4
  142. package/dist/core/runner/file-history-restore.d.ts +3 -1
  143. package/dist/core/runner/file-history-restore.js +9 -6
  144. package/dist/core/runner/finish-reason-seat.js +4 -2
  145. package/dist/core/runner/leg-frame.js +3 -0
  146. package/dist/core/runner/loaded-skills.d.ts +2 -0
  147. package/dist/core/runner/loaded-skills.js +10 -0
  148. package/dist/core/runner/nested-memory-lane.d.ts +22 -5
  149. package/dist/core/runner/nested-memory-lane.js +91 -30
  150. package/dist/core/runner/person-path-rows.d.ts +23 -20
  151. package/dist/core/runner/person-path-rows.js +82 -18
  152. package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -0
  153. package/dist/core/runner/prepare-caps-and-workflow.js +105 -90
  154. package/dist/core/runner/prepare-config-doors.d.ts +1 -0
  155. package/dist/core/runner/prepare-config-doors.js +5 -3
  156. package/dist/core/runner/prepare-context-lane.js +1 -0
  157. package/dist/core/runner/prepare-delegation-surface.d.ts +3 -0
  158. package/dist/core/runner/prepare-delegation-surface.js +6 -0
  159. package/dist/core/runner/prepare-execution-env.d.ts +3 -3
  160. package/dist/core/runner/prepare-file-history.js +1 -1
  161. package/dist/core/runner/prepare-hands-readface.d.ts +10 -2
  162. package/dist/core/runner/prepare-hands-readface.js +36 -22
  163. package/dist/core/runner/prepare-inherited-gate.d.ts +8 -5
  164. package/dist/core/runner/prepare-inherited-gate.js +14 -6
  165. package/dist/core/runner/prepare-memory-engine-session.d.ts +2 -2
  166. package/dist/core/runner/prepare-memory-engine-session.js +2 -2
  167. package/dist/core/runner/prepare-memory.js +3 -15
  168. package/dist/core/runner/prepare-project-context.d.ts +1 -1
  169. package/dist/core/runner/prepare-project-context.js +3 -7
  170. package/dist/core/runner/prepare-protocol-tools.d.ts +5 -0
  171. package/dist/core/runner/prepare-protocol-tools.js +2 -2
  172. package/dist/core/runner/prepare-run-refs.d.ts +1 -1
  173. package/dist/core/runner/prepare-run-refs.js +3 -2
  174. package/dist/core/runner/prepare-suspend-saga.d.ts +6 -2
  175. package/dist/core/runner/prepare-suspend-saga.js +4 -2
  176. package/dist/core/runner/prepare-task.js +50 -37
  177. package/dist/core/runner/prepare-turn-wiring.d.ts +4 -3
  178. package/dist/core/runner/prepare-turn-wiring.js +2 -1
  179. package/dist/core/runner/prepare-wiring-manifest.d.ts +5 -1
  180. package/dist/core/runner/prepare-wiring-manifest.js +8 -4
  181. package/dist/core/runner/read-session-changes.js +1 -1
  182. package/dist/core/runner/resume-apply.js +11 -5
  183. package/dist/core/runner/resume-checkpoint-screen.d.ts +8 -7
  184. package/dist/core/runner/resume-checkpoint-screen.js +7 -6
  185. package/dist/core/runner/resume-review-outcome.d.ts +3 -0
  186. package/dist/core/runner/resume-review-outcome.js +24 -1
  187. package/dist/core/runner/rewind-files.js +3 -2
  188. package/dist/core/runner/run-harness-handlers.js +3 -0
  189. package/dist/core/runner/run-identity-wiring.js +3 -2
  190. package/dist/core/runner/run-leg.js +9 -2
  191. package/dist/core/runner/run-notification-lane.js +20 -1
  192. package/dist/core/runner/run-settle-and-teardown.js +21 -12
  193. package/dist/core/runner/run-stop-and-final-verify.js +6 -0
  194. package/dist/core/runner/run-telemetry-and-budget-seats.js +1 -1
  195. package/dist/core/runner/runtask.d.ts +6 -2
  196. package/dist/core/runner/runtask.js +21 -9
  197. package/dist/core/runner/shell-env-withheld.d.ts +3 -2
  198. package/dist/core/runner/shell-env-withheld.js +1 -2
  199. package/dist/core/runner/stop-tail-notice.d.ts +10 -2
  200. package/dist/core/runner/stop-tail-notice.js +9 -2
  201. package/dist/core/runner/stream-settle-backstop.d.ts +1 -0
  202. package/dist/core/runner/stream-settle-backstop.js +1 -0
  203. package/dist/core/runner/task-start-doors.js +6 -3
  204. package/dist/core/runner/terminal-account.d.ts +10 -1
  205. package/dist/core/runner/terminal-account.js +23 -3
  206. package/dist/core/runner/tool-face-overlay.d.ts +2 -11
  207. package/dist/core/runner/tool-face-overlay.js +39 -0
  208. package/dist/core/runner/trim-stretch.js +7 -2
  209. package/dist/core/runner/unreadable-person-rows.d.ts +2 -1
  210. package/dist/core/runner-deps.d.ts +13 -10
  211. package/dist/core/scheduler.d.ts +47 -7
  212. package/dist/core/scheduler.js +19 -7
  213. package/dist/core/secret-env.d.ts +60 -37
  214. package/dist/core/secret-env.js +45 -48
  215. package/dist/core/sensitive-path-policy.js +14 -7
  216. package/dist/core/session-checkout.d.ts +3 -0
  217. package/dist/core/session-checkout.js +1 -0
  218. package/dist/core/session-store.d.ts +12 -6
  219. package/dist/core/session-store.js +26 -6
  220. package/dist/core/session.d.ts +31 -8
  221. package/dist/core/shell-read-silence.js +1 -0
  222. package/dist/core/store-contracts/checkpoint-store-contract.js +17 -0
  223. package/dist/core/store-contracts/peer-task-store-contract.d.ts +21 -0
  224. package/dist/core/store-contracts/peer-task-store-contract.js +516 -0
  225. package/dist/core/store-contracts/session-store-contract.d.ts +15 -2
  226. package/dist/core/store-contracts/session-store-contract.js +87 -3
  227. package/dist/core/store-contracts/workflow-journal-store-contract.d.ts +19 -1
  228. package/dist/core/store-contracts/workflow-journal-store-contract.js +89 -1
  229. package/dist/core/task-event.d.ts +11 -3
  230. package/dist/core/task-notification.d.ts +97 -10
  231. package/dist/core/task-notification.js +129 -5
  232. package/dist/core/task-registry-shared.d.ts +12 -1
  233. package/dist/core/task-registry-shared.js +3 -1
  234. package/dist/core/task-registry-workflow.d.ts +1 -1
  235. package/dist/core/task-registry-workflow.js +9 -1
  236. package/dist/core/task-registry.d.ts +39 -2
  237. package/dist/core/task-registry.js +76 -12
  238. package/dist/core/task-result.d.ts +13 -0
  239. package/dist/core/task-spec-members.d.ts +3 -1
  240. package/dist/core/task-spec-members.js +11 -3
  241. package/dist/core/task-spec.d.ts +57 -23
  242. package/dist/core/tool-catalog-entries.js +4 -0
  243. package/dist/core/tool-face-reader.js +1 -1
  244. package/dist/core/tool-face.d.ts +7 -0
  245. package/dist/core/tool-face.js +1 -0
  246. package/dist/core/tool-mount-facts.d.ts +5 -3
  247. package/dist/core/tool-mount-facts.js +4 -3
  248. package/dist/core/tool-mount-plan.d.ts +7 -3
  249. package/dist/core/tool-mount-plan.js +11 -5
  250. package/dist/core/tool-mount-static.d.ts +2 -2
  251. package/dist/core/tool-mount-static.js +28 -14
  252. package/dist/core/tool-registry.d.ts +33 -1
  253. package/dist/core/tool-registry.js +33 -0
  254. package/dist/core/tool-result-store.d.ts +19 -2
  255. package/dist/core/tool-result-store.js +51 -2
  256. package/dist/core/tool-roster.d.ts +16 -0
  257. package/dist/core/tool-roster.js +6 -0
  258. package/dist/core/tool-spec.d.ts +13 -4
  259. package/dist/core/tools.d.ts +6 -0
  260. package/dist/core/tools.js +1 -1
  261. package/dist/core/user-attachment.d.ts +5 -1
  262. package/dist/core/user-attachment.js +14 -7
  263. package/dist/core/wiring-manifest.d.ts +89 -29
  264. package/dist/core/wiring-manifest.js +44 -4
  265. package/dist/core/workflow-journal-store.d.ts +53 -10
  266. package/dist/core/workflow-journal-store.js +27 -4
  267. package/dist/core/workflow-run-store-contract.js +16 -0
  268. package/dist/core/workflow-run-store.d.ts +9 -7
  269. package/dist/core/workflow-run-store.js +4 -1
  270. package/dist/engine/execution-env/node-execution-env.js +3 -1
  271. package/dist/engine/harness/messages.d.ts +1 -1
  272. package/dist/engine/harness/messages.js +2 -1
  273. package/dist/engine/harness/types.d.ts +24 -1
  274. package/dist/engine/harness/types.js +10 -0
  275. package/dist/engine/llm/types.d.ts +5 -7
  276. package/dist/engine/loop/types.d.ts +2 -0
  277. package/dist/engine/lsp/node-lsp-manager.js +2 -1
  278. package/dist/engine/session/import-validate.js +6 -1
  279. package/dist/engine/session/session.d.ts +15 -2
  280. package/dist/engine/session/session.js +35 -5
  281. package/dist/index.d.ts +27 -12
  282. package/dist/index.js +20 -8
  283. package/dist/orchestration/run-workflow-tool.js +40 -32
  284. package/dist/orchestration/workflow-park-adoption.d.ts +51 -12
  285. package/dist/orchestration/workflow-park-adoption.js +47 -12
  286. package/dist/orchestration/workflow-stop.d.ts +128 -0
  287. package/dist/orchestration/workflow-stop.js +156 -0
  288. package/dist/orchestration/workflow.d.ts +30 -6
  289. package/dist/orchestration/workflow.js +117 -54
  290. package/dist/prompts/manager-recipe.d.ts +18 -0
  291. package/dist/prompts/manager-recipe.js +24 -0
  292. package/dist/stores/file/adoption/marker.d.ts +2 -27
  293. package/dist/stores/file/adoption/marker.js +12 -0
  294. package/dist/stores/file/index.d.ts +1 -1
  295. package/dist/stores/file/index.js +1 -1
  296. package/dist/stores/file/permission-rule-store.d.ts +3 -1
  297. package/dist/stores/file/permission-rule-store.js +0 -1
  298. package/dist/stores/file/workflow-journal-store.d.ts +16 -3
  299. package/dist/stores/file/workflow-journal-store.js +93 -5
  300. package/dist/stores/file/workflow-run-store.d.ts +1 -1
  301. package/dist/tools/artifact/artifact-tool.js +11 -6
  302. package/dist/tools/fs/file-read-check.d.ts +45 -11
  303. package/dist/tools/fs/file-read-check.js +200 -57
  304. package/dist/tools/fs/file-write-check.js +9 -3
  305. package/dist/tools/fs/index.d.ts +8 -7
  306. package/dist/tools/fs/index.js +4 -4
  307. package/dist/tools/fs/judged-reads.d.ts +51 -0
  308. package/dist/tools/fs/judged-reads.js +68 -0
  309. package/dist/tools/fs/read-deny-home.d.ts +1 -1
  310. package/dist/tools/fs/read-deny-home.js +5 -5
  311. package/dist/tools/fs/read-deny.d.ts +33 -8
  312. package/dist/tools/fs/read-deny.js +114 -25
  313. package/dist/tools/fs/safety.d.ts +12 -1
  314. package/dist/tools/fs/safety.js +16 -3
  315. package/dist/tools/fs/shell-read-check.d.ts +25 -5
  316. package/dist/tools/fs/shell-read-check.js +100 -15
  317. package/dist/tools/fs/shell-read-establish.d.ts +9 -0
  318. package/dist/tools/fs/shell-read-establish.js +34 -14
  319. package/dist/tools/fs/shell-read-judge.d.ts +13 -1
  320. package/dist/tools/fs/shell-read-judge.js +26 -7
  321. package/dist/tools/fs/shell-read-plan.d.ts +5 -0
  322. package/dist/tools/fs/shell-read-write-targets.js +17 -9
  323. package/dist/tools/scheduler-store-move.d.ts +74 -0
  324. package/dist/tools/scheduler-store-move.js +103 -0
  325. package/dist/tools/scheduler-tools.d.ts +43 -29
  326. package/dist/tools/scheduler-tools.js +161 -118
  327. package/package.json +2 -2
  328. package/test/export-surface.snapshot.json +173 -3
  329. package/wire-changes/answers/core-stores-sql@7.72.0.json +12 -0
  330. package/wire-changes/answers/core-stores-sql@7.73.0.json +28 -0
  331. package/wire-changes/answers/core@7.72.0.json +84 -0
  332. package/wire-changes/answers/core@7.73.0.json +216 -0
  333. package/wire-changes/answers/mods-kernel@7.72.0.json +7 -0
  334. package/wire-changes/answers/mods-kernel@7.73.0.json +7 -0
  335. package/wire-changes/answers/primitives@7.72.0.json +6 -0
  336. package/wire-changes/answers/primitives@7.73.0.json +12 -0
  337. package/wire-changes/answers/wiki-gate@7.72.0.json +7 -0
  338. package/wire-changes/answers/wiki-gate@7.73.0.json +7 -0
  339. package/wire-changes/core-stores-sql@7.72.0.json +215 -0
  340. package/wire-changes/core-stores-sql@7.73.0.json +326 -0
  341. package/wire-changes/core@7.72.0.json +2426 -0
  342. package/wire-changes/core@7.73.0.json +6480 -0
  343. package/wire-changes/mods-kernel@7.72.0.json +147 -0
  344. package/wire-changes/mods-kernel@7.73.0.json +147 -0
  345. package/wire-changes/primitives@7.72.0.json +143 -0
  346. package/wire-changes/primitives@7.73.0.json +227 -0
  347. package/wire-changes/wiki-gate@7.72.0.json +145 -0
  348. package/wire-changes/wiki-gate@7.73.0.json +145 -0
@@ -3,13 +3,14 @@ import { screenInboundEntries } from "./data-plane.js";
3
3
  import { scanMemoryFileName, scanMemoryWrite } from "./scan.js";
4
4
  import { MAX_MEMORY_BYTES } from "../memory.js";
5
5
  import { reconcileMemoryEntries } from "./sync.js";
6
+ import { memoryDeletionRecords } from "./deletion-record.js";
6
7
  import { MEMORY_ORIGIN_CAUSES } from "./types.js";
7
8
  import { directoryPinOf, landingPathOf } from "./layout.js";
8
9
  import { egressText } from "../untrusted-egress.js";
9
10
  import { REDACTION_MARKS, userinfoHolds } from "@sema-agent/primitives";
10
11
  import { isReplicableScope } from "./scope-contract.js";
11
12
  const DROP_THE_CURSOR = "drop the cursor to accept re-convergence from an empty baseline — entries changed on both sides are reported as conflicts, " +
12
- "and entries deleted on one side since the last round come back from the other side";
13
+ "and entries deleted on one side since the last round come back from the other side unless that side's store records the deletion and reads it";
13
14
  const REFUSAL_ROWS = {
14
15
  scope: {
15
16
  why: "a cursor is the baseline of one (scope, peer) partition",
@@ -38,8 +39,8 @@ const REFUSAL_ROWS = {
38
39
  outs: () => [
39
40
  "rebind — when this store holds the entries the baseline was taken over (the same store, moved to this root or bound before " +
40
41
  "cursors carried a store), persist the cursor with its store set to this store's identity (memorySyncStoreOf) and sync again",
41
- "clear — delete the cursor and sync from none, accepting that an entry deleted on either side since the last completed round " +
42
- "comes back from the other side",
42
+ "clear — delete the cursor and sync from none, accepting that deletions without a baseline no longer cross and an entry deleted on either side since the last completed round " +
43
+ "comes back from the other side unless that side's store records the deletion and reads it (a recorded deletion blocks landing as a conflict and never deletes on the peer)",
43
44
  ],
44
45
  },
45
46
  "store-plane": {
@@ -444,7 +445,26 @@ export async function syncMemoryScope(opts) {
444
445
  });
445
446
  }
446
447
  }
447
- for (const f of screenInboundEntries(resp.serverEntries.filter((e) => !rejected.has(e.id)))) {
448
+ const heldIds = new Set(fetched.map((e) => e.id));
449
+ const unbaselined = resp.serverEntries.filter((e) => !rejected.has(e.id) && baseRevs[e.id] === undefined && !heldIds.has(e.id));
450
+ const deletionBlocked = new Set();
451
+ if (unbaselined.length > 0) {
452
+ const judged = reconcileMemoryEntries({}, [], unbaselined, { local: await memoryDeletionRecords(backend, unbaselined.map((e) => e.id), scope) });
453
+ for (const c of judged.conflicts) {
454
+ deletionBlocked.add(c.id);
455
+ const record = c.deletion?.record;
456
+ conflicts.push({
457
+ side: "local",
458
+ id: c.id,
459
+ reason: record?.kind === "undecidable"
460
+ ? `deletion_record_unreadable: the center offers ${JSON.stringify(c.id)}, which this store does not hold, and whether this store deleted it cannot be read (${record.why}) — not brought back`
461
+ : `deleted_here: this store deleted ${JSON.stringify(c.id)}${c.baseRev !== undefined ? ` at rev ${JSON.stringify(c.baseRev)}` : ""} and the center offers it at rev ${JSON.stringify(c.remote?.rev)} — not brought back (re-judged next round; nothing deleted on the center)`,
462
+ ...(c.remote?.rev !== undefined ? { currentRev: c.remote.rev } : {}),
463
+ });
464
+ }
465
+ }
466
+ const landable = (id) => !rejected.has(id) && !deletionBlocked.has(id);
467
+ for (const f of screenInboundEntries(resp.serverEntries.filter((e) => landable(e.id)))) {
448
468
  rejected.add(f.id);
449
469
  conflicts.push({
450
470
  side: "local",
@@ -491,7 +511,7 @@ export async function syncMemoryScope(opts) {
491
511
  }
492
512
  const patches = [
493
513
  ...resp.serverEntries
494
- .filter((e) => !rejected.has(e.id))
514
+ .filter((e) => landable(e.id))
495
515
  .map((e) => {
496
516
  const base = baseRevs[e.id];
497
517
  return base !== undefined
@@ -514,7 +534,7 @@ export async function syncMemoryScope(opts) {
514
534
  let nextCursor = cursor;
515
535
  const warnings = [];
516
536
  if (cursorAdvanced) {
517
- const pulledRevById = new Map(resp.serverEntries.map((e) => [e.id, e.rev]));
537
+ const pulledRevById = new Map(resp.serverEntries.filter((e) => landable(e.id)).map((e) => [e.id, e.rev]));
518
538
  const pushedRevById = new Map(request.entries.map((e) => [e.id, e.rev]));
519
539
  const serverAppliedIds = new Set(resp.applied.filter((a) => a.op !== "delete").map((a) => a.id));
520
540
  const disputedIds = new Set(resp.conflicts.map((c) => c.id));
@@ -1,4 +1,5 @@
1
1
  import type { MemoryEntry, ScoredMemoryEntry } from "./types.js";
2
+ import type { DeletionRecord } from "./deletion-record.js";
2
3
  /**
3
4
  * design/142 §3 — the per-replica per-scope sync cursor: the COMMON BASELINE a reconciliation run
4
5
  * judges divergence against (`id → rev` as of the last completed sync round). This is a NEW
@@ -36,6 +37,20 @@ export interface MemorySyncConflict {
36
37
  local?: MemoryEntry;
37
38
  remote?: MemoryEntry;
38
39
  baseRev?: string;
40
+ /** Present when no baseline answered for the id and the absent side's deletion record blocked it from landing on that
41
+ * side: `record` is that side's answer (`deleted` at any version — `baseRev` carries the deleted version when known —
42
+ * or `undecidable`). A deletion record never emits a delete for the other side. */
43
+ deletion?: {
44
+ side: "local" | "remote";
45
+ record: DeletionRecord;
46
+ };
47
+ }
48
+ /** Each side's deletion records for ids it does not hold (`memoryDeletionRecords`): consulted only for an id present on
49
+ * the other side with no baseline. A side whose records are not given is judged as holding none — the caller holding
50
+ * that side's store passes them (a client's push half leaves the peer's side to the peer, which judges it). */
51
+ export interface MemorySyncDeletions {
52
+ local?: ReadonlyMap<string, DeletionRecord>;
53
+ remote?: ReadonlyMap<string, DeletionRecord>;
39
54
  }
40
55
  export interface MemorySyncPlan {
41
56
  /** Entries the LOCAL side should send to the peer (new here or changed-here-only). 独立轨 F8 —
@@ -77,10 +92,13 @@ export interface MemorySyncPlan {
77
92
  * - changed on BOTH sides, or delete-on-one × edit-on-the-other → conflict (caller's ladder);
78
93
  * - deleted on one side × UNCHANGED on the other → the delete propagates (deleteLocal/deleteRemote,
79
94
  * CAS on baseRev: without this leg removals never cross and the plan livelocks);
80
- * - present only on one side with NO baseline → new entry → propagate;
95
+ * - present only on one side with NO baseline → the absent side's deletion record ({@link MemorySyncDeletions}) decides
96
+ * only whether the id may land on that side: `never` (or omitted) ⇒ new entry → propagate; deleted (at any version)
97
+ * or `undecidable` ⇒ conflict carrying `deletion`, never a delete on the present side. Deletions cross only where a
98
+ * baseline exists;
81
99
  * - absent on both but present in baseline → cleared (cursor cleanup).
82
100
  */
83
- export declare function reconcileMemoryEntries(baseRevs: Readonly<Record<string, string>>, local: readonly MemoryEntry[], remote: readonly MemoryEntry[]): MemorySyncPlan;
101
+ export declare function reconcileMemoryEntries(baseRevs: Readonly<Record<string, string>>, local: readonly MemoryEntry[], remote: readonly MemoryEntry[], deletions?: MemorySyncDeletions): MemorySyncPlan;
84
102
  /** The baseline to persist AFTER a sync round completes: every id both sides now agree on. The
85
103
  * caller passes the POST-round entry sets (after applying push/pull and resolving conflicts). */
86
104
  export declare function nextSyncBaseline(local: readonly MemoryEntry[], remote: readonly MemoryEntry[]): Record<string, string>;
@@ -1,4 +1,4 @@
1
- export function reconcileMemoryEntries(baseRevs, local, remote) {
1
+ export function reconcileMemoryEntries(baseRevs, local, remote, deletions) {
2
2
  const plan = { push: [], pull: [], deleteLocal: [], deleteRemote: [], conflicts: [], cleared: [] };
3
3
  const localById = new Map(local.map((e) => [e.id, e]));
4
4
  const remoteById = new Map(remote.map((e) => [e.id, e]));
@@ -20,22 +20,23 @@ export function reconcileMemoryEntries(baseRevs, local, remote) {
20
20
  plan.pull.push(r);
21
21
  continue;
22
22
  }
23
- if (l !== undefined) {
24
- if (base === undefined)
25
- plan.push.push(l);
26
- else if (l.rev !== base)
27
- plan.conflicts.push({ id, local: l, baseRev: base });
28
- else
29
- plan.deleteLocal.push({ id, baseRev: base });
30
- continue;
31
- }
32
- if (r !== undefined) {
33
- if (base === undefined)
34
- plan.pull.push(r);
35
- else if (r.rev !== base)
36
- plan.conflicts.push({ id, remote: r, baseRev: base });
37
- else
38
- plan.deleteRemote.push({ id, baseRev: base });
23
+ if (l !== undefined || r !== undefined) {
24
+ const present = (l ?? r);
25
+ const side = l !== undefined ? { local: l } : { remote: r };
26
+ if (base !== undefined) {
27
+ if (present.rev !== base)
28
+ plan.conflicts.push({ id, ...side, baseRev: base });
29
+ else
30
+ (l !== undefined ? plan.deleteLocal : plan.deleteRemote).push({ id, baseRev: base });
31
+ }
32
+ else {
33
+ const absentSide = l !== undefined ? "remote" : "local";
34
+ const record = deletions?.[absentSide]?.get(id);
35
+ if (record === undefined || record.kind === "never")
36
+ (l !== undefined ? plan.push : plan.pull).push(present);
37
+ else
38
+ plan.conflicts.push({ id, ...side, ...(record.kind === "deleted" && record.rev !== undefined ? { baseRev: record.rev } : {}), deletion: { side: absentSide, record } });
39
+ }
39
40
  continue;
40
41
  }
41
42
  plan.cleared.push(id);
@@ -163,11 +163,15 @@ export declare function createModeGatePolicy(modeRef: {
163
163
  readonly current: PermissionMode;
164
164
  }, seats: ModeGateSeats): ToolPolicy;
165
165
  /**
166
- * The mode a resumed leg REQUESTS: the re-passed spec's word, else the word the checkpoint row recorded — except where the
167
- * resume approves or edits a pause whose approval requests the plan exit (`approvalRequestsPlanExit`, the one answer the
168
- * pause's faces echo: a `plan_review` over a row recorded in `plan`): the plan exits to the word the leg had before it
169
- * (`prePlanMode`, the reference implementation's ExitPlanMode: `prePlanMode ?? "default"`; absent ⇒ the leg's own default),
170
- * unless the resume names another mode — the approver's choice. A re-passed `plan` does not keep an approved plan open.
166
+ * The mode a resumed leg REQUESTS. Without a mode the approval names: the re-passed spec's word, else the word the checkpoint row
167
+ * recorded — except where the resume approves or edits a pause whose approval requests the plan exit (`approvalRequestsPlanExit`, the
168
+ * one answer the pause's faces echo: a `plan_review` over a row recorded in `plan`): the plan exits to the resume's word, else to the
169
+ * word the leg had before it (`prePlanMode`, the reference implementation's ExitPlanMode: `prePlanMode ?? "default"`; absent ⇒ the
170
+ * leg's own default). A re-passed `plan` does not keep an approved plan open.
171
+ * The mode the person's approval names (`outcome.permissionMode`, the one the decided row records), on whatever row it decides: a
172
+ * tightening of that mode holds unconditionally; a widening holds only where the ceiling it is folded under is known — the parent's
173
+ * mode with the deployment's cap (the leg's ceilings fold it after). A leg with a parent whose mode this resume was not handed
174
+ * (`parentModeUnknown`) has no known ceiling: the widening is withheld and the leg requests the mode it would without it.
171
175
  */
172
176
  export declare function modeRequestAfterResume(seat: PermissionMode | undefined, recorded: {
173
177
  readonly permissionMode?: PermissionMode;
@@ -175,7 +179,18 @@ export declare function modeRequestAfterResume(seat: PermissionMode | undefined,
175
179
  }, outcome: {
176
180
  readonly gate: string;
177
181
  readonly decision?: string;
178
- } | undefined): PermissionMode | undefined;
182
+ readonly permissionMode?: PermissionMode;
183
+ } | undefined, parentModeUnknown?: true): PermissionMode | undefined;
184
+ /** The mode an approval named that {@link modeRequestAfterResume} withholds (a widening with no known ceiling), else `undefined` —
185
+ * the one fact a leg says when it does not take the mode a person approved. */
186
+ export declare function withheldApprovalMode(seat: PermissionMode | undefined, recorded: {
187
+ readonly permissionMode?: PermissionMode;
188
+ readonly prePlanMode?: PermissionMode;
189
+ }, outcome: {
190
+ readonly gate: string;
191
+ readonly decision?: string;
192
+ readonly permissionMode?: PermissionMode;
193
+ } | undefined, parentModeUnknown?: true): PermissionMode | undefined;
179
194
  /**
180
195
  * The permission MODE's door — two refusals in the pre-first-await stretch, each by name and never a fold back to
181
196
  * absence (a mode a caller believes it declared must not silently run as another): a `permissionMode` outside
@@ -106,11 +106,17 @@ export function createModeGatePolicy(modeRef, seats) {
106
106
  },
107
107
  };
108
108
  }
109
- export function modeRequestAfterResume(seat, recorded, outcome) {
110
- const exitsPlan = outcome !== undefined && outcome.decision !== "reject" && approvalRequestsPlanExit(outcome.gate, recorded.permissionMode);
111
- if (!exitsPlan)
112
- return seat ?? recorded.permissionMode;
113
- return seat !== undefined && seat !== "plan" ? seat : recorded.prePlanMode;
109
+ export function modeRequestAfterResume(seat, recorded, outcome, parentModeUnknown) {
110
+ const approved = outcome !== undefined && outcome.decision !== "reject";
111
+ const unnamed = !approved || !approvalRequestsPlanExit(outcome.gate, recorded.permissionMode) ? (seat ?? recorded.permissionMode) : seat !== undefined && seat !== "plan" ? seat : recorded.prePlanMode;
112
+ const named = approved ? outcome.permissionMode : undefined;
113
+ if (named === undefined)
114
+ return unnamed;
115
+ return parentModeUnknown !== true || clampPermissionMode(named, unnamed ?? "default").effective === named ? named : unnamed;
116
+ }
117
+ export function withheldApprovalMode(seat, recorded, outcome, parentModeUnknown) {
118
+ const named = outcome !== undefined && outcome.decision !== "reject" ? outcome.permissionMode : undefined;
119
+ return named !== undefined && modeRequestAfterResume(seat, recorded, outcome, parentModeUnknown) !== named ? named : undefined;
114
120
  }
115
121
  export function refusePermissionModeDoors(spec) {
116
122
  const mode = spec.permissionMode;
@@ -236,7 +242,10 @@ export class PermissionModeController {
236
242
  const arming = this.arming;
237
243
  if (effective === "auto" && !this.armedForAuto && arming?.armAuto !== undefined) {
238
244
  this.armedForAuto = true;
239
- void new Promise((resolve) => resolve(arming.armAuto?.())).catch((e) => this.faultSeat.notifyAsync(() => arming.onArmFault?.(e), "permissionMode.onArmFault"));
245
+ void new Promise((resolve) => resolve(arming.armAuto?.())).catch((e) => {
246
+ this.armedForAuto = false;
247
+ this.faultSeat.notifyAsync(() => arming.onArmFault?.(e), "permissionMode.onArmFault");
248
+ });
240
249
  }
241
250
  return effective;
242
251
  }
@@ -7,7 +7,7 @@
7
7
  * The run fills it on `ToolExecuteContext.mountedMcp`; the delegation tool puts the same universe through the child's lists
8
8
  * and declares the child the servers they leave.
9
9
  */
10
- import type { McpServerSpec } from "./mcp-server-spec.js";
10
+ import { type McpServerSpec } from "./mcp-server-spec.js";
11
11
  import type { ToolContentOrigin } from "./tool-spec.js";
12
12
  import type { McpHostSeat } from "./mcp-host-seat.js";
13
13
  import type { McpInstructionsEntry } from "./prompt-section-seat.js";
@@ -111,9 +111,14 @@ export interface MountedMcpServer {
111
111
  export interface MountedMcp {
112
112
  readonly servers: ReadonlyArray<MountedMcpServer>;
113
113
  readonly aggregate: ReadonlyArray<string>;
114
- /** The run's host seats by declaration name: a child that inherits a host-transport server is handed that server's seat. */
114
+ /** The seats of the host-transport servers this leg declares ({@link hostSeatsAlong}): a child that inherits one, or an agent this
115
+ * leg wakes whose own list holds one, is handed that server's seat. A seat the leg holds for a server it does not declare is not here. */
115
116
  readonly hostSeats?: ReadonlyMap<string, McpHostSeat>;
116
117
  }
118
+ /** THE seat judge: of `held`, the seats of the host-transport servers among `servers`, by declaration name — `undefined` when none. A
119
+ * seat follows a declaration; the mount (the leg's own servers), a spawn (the servers a child inherits) and a wake (the woken leg's own
120
+ * list, read against the waker's mount) all read it. */
121
+ export declare function hostSeatsAlong(held: ReadonlyMap<string, McpHostSeat> | undefined, servers: ReadonlyArray<McpServerSpec>): ReadonlyMap<string, McpHostSeat> | undefined;
117
122
  /** A roster entry as far as this reading goes. */
118
123
  interface RosterEntry {
119
124
  readonly name: string;
@@ -1,3 +1,4 @@
1
+ import { transportKindOf } from "./mcp-server-spec.js";
1
2
  import { MCP_NAMESPACE, TOOL_NAME_MAX_CHARS, mintNamespacePrefix, normalizeNameSegment } from "@sema-agent/primitives";
2
3
  export const MCP_RESOURCE_LIST_ALLOW = "list_resources";
3
4
  export const MCP_RESOURCE_READ_ALLOW = "read_resource";
@@ -125,6 +126,13 @@ export function unretractInstructions(lane, server) {
125
126
  if (slot !== undefined)
126
127
  slot.retracting = false;
127
128
  }
129
+ export function hostSeatsAlong(held, servers) {
130
+ const seats = servers.flatMap((s) => {
131
+ const seat = transportKindOf(s) === "host" ? held?.get(s.name) : undefined;
132
+ return seat !== undefined ? [[s.name, seat]] : [];
133
+ });
134
+ return seats.length > 0 ? new Map(seats) : undefined;
135
+ }
128
136
  export function toolNamesOfServer(names, serverName) {
129
137
  const prefix = mintNamespacePrefix(MCP_NAMESPACE, serverName);
130
138
  return [...names].filter((name) => name.startsWith(prefix));
@@ -147,7 +155,8 @@ export function mountedMcpOf(input) {
147
155
  return { server, tools };
148
156
  });
149
157
  const aggregate = input.roster.filter((t) => input.aggregateNames.has(t.name)).map((t) => t.name);
150
- return { servers, aggregate, ...(input.hostSeats !== undefined ? { hostSeats: input.hostSeats } : {}) };
158
+ const hostSeats = hostSeatsAlong(input.hostSeats, input.declared ?? []);
159
+ return { servers, aggregate, ...(hostSeats !== undefined ? { hostSeats } : {}) };
151
160
  }
152
161
  export function mountedMcpPoolRows(mounted) {
153
162
  return [
@@ -8,6 +8,12 @@ export function receiptRefusal(message) {
8
8
  e.code = "config.invalid_argument";
9
9
  return e;
10
10
  }
11
+ function walkRefusal(message, member) {
12
+ const e = receiptRefusal(message);
13
+ if (member !== undefined)
14
+ e.member = member;
15
+ return e;
16
+ }
11
17
  export function refuseProxy(given, words) {
12
18
  if (types.isProxy(given))
13
19
  throw receiptRefusal(`${words.subject} must be a plain object, not a Proxy: its ${words.unit}s are read once off its own descriptors, and a Proxy would run its traps in that read — refused rather than wired through it`);
@@ -51,12 +57,13 @@ function readCaptured(given, words) {
51
57
  const received = receive(given, CONFIG_RECEIPT_MODE);
52
58
  if (received.ok)
53
59
  return received.value;
54
- const name = received.fault.path[0] ?? "";
60
+ const member = received.fault.path[0];
61
+ const name = member ?? "";
55
62
  if (received.fault.kind === "getter-threw")
56
- throw receiptRefusal(`${words.subject}.${name} threw while it was read ${words.moment} — a ${words.unit} is read once, here; refused rather than wired without it`);
63
+ throw walkRefusal(`${words.subject}.${name} threw while it was read ${words.moment} — a ${words.unit} is read once, here; refused rather than wired without it`, member);
57
64
  if (received.fault.kind === "prototype-moved")
58
- throw receiptRefusal(`${words.subject}'s prototype changed while its ${words.unit}s were read ${words.moment} — refused rather than wired from a moving object`);
59
- throw receiptRefusal(`${words.subject} could not be read ${words.moment}: ${describeFault(received.fault)} — refused rather than wired without it`);
65
+ throw walkRefusal(`${words.subject}'s prototype changed while its ${words.unit}s were read ${words.moment} — refused rather than wired from a moving object`, member);
66
+ throw walkRefusal(`${words.subject} could not be read ${words.moment}: ${describeFault(received.fault)} — refused rather than wired without it`, member);
60
67
  }
61
68
  function strayMembersSentence(words, stray, keys) {
62
69
  const named = stray.map((k) => {
@@ -1,15 +1,20 @@
1
+ import type { ToolCallPathTarget } from "./tool-face.js";
1
2
  /** The longest scalar an argument rule reads, unless a policy states its own (`caps.maxScalarValueChars`): a longer value is not
2
3
  * read, and the rule's lane wins (fail-closed). */
3
4
  export declare const DEFAULT_MAX_SCALAR_VALUE_CHARS = 16384;
4
5
  /** The call an argument rule is judged on: its arguments as the loop handed them, and its face (the tool's reading). */
5
6
  export interface ParamRuleCall {
6
7
  readonly args: unknown;
7
- readonly face?: object | undefined;
8
+ readonly face?: (object & {
9
+ readonly pathTarget?: ToolCallPathTarget | undefined;
10
+ }) | undefined;
8
11
  }
9
12
  /**
10
13
  * Does the rule on argument `param` with `pattern` reach this call? Non-object arguments ⇒ no; own top-level properties only
11
14
  * (`param` is a literal key, never a dotted path); scalar values only, trimmed, matched whole by the `*` glob; a value longer than
12
15
  * `maxScalarValueChars` FAIL-CLOSES (reached: it cannot be read, so the rule's lane wins). A call without the parameter is reached
13
- * by a rule whose value the tool's reading folds away ({@link readingAbsorbs}).
16
+ * by a rule whose value the tool's reading folds away ({@link readingAbsorbs}). A list in a slot the call's face reads element by
17
+ * element (`pathTarget.each`, the slot's `param` or an alias) is that many values: a tightening rule (`direction` `"tighten"`, a
18
+ * deny or an ask) reaches the call when it reaches ANY element, an allow only when it reaches EVERY one.
14
19
  */
15
- export declare function paramRuleReaches(call: ParamRuleCall, param: string, pattern: string, maxScalarValueChars?: number): boolean;
20
+ export declare function paramRuleReaches(call: ParamRuleCall, param: string, pattern: string, maxScalarValueChars?: number, direction?: "tighten" | "allow"): boolean;
@@ -2,13 +2,21 @@ import { canonicalize, UNCANONICALIZABLE } from "./canonical-json.js";
2
2
  import { argsAsTheToolReads } from "./effective-path-target.js";
3
3
  import { wildcardMatch } from "./namespaced-rule-name.js";
4
4
  export const DEFAULT_MAX_SCALAR_VALUE_CHARS = 16_384;
5
- export function paramRuleReaches(call, param, pattern, maxScalarValueChars = DEFAULT_MAX_SCALAR_VALUE_CHARS) {
5
+ export function paramRuleReaches(call, param, pattern, maxScalarValueChars = DEFAULT_MAX_SCALAR_VALUE_CHARS, direction = "tighten") {
6
6
  const args = call.args;
7
7
  if (typeof args !== "object" || args === null || Array.isArray(args))
8
8
  return false;
9
9
  if (!Object.hasOwn(args, param))
10
10
  return readingAbsorbs(call, args, param, pattern);
11
11
  const raw = args[param];
12
+ const pt = call.face?.pathTarget;
13
+ if (Array.isArray(raw) && pt?.each === true && [pt.param, ...(pt.aliases ?? [])].includes(param)) {
14
+ const reached = (v) => scalarReached(v, pattern, maxScalarValueChars);
15
+ return raw.length > 0 && (direction === "tighten" ? raw.some(reached) : raw.every(reached));
16
+ }
17
+ return scalarReached(raw, pattern, maxScalarValueChars);
18
+ }
19
+ function scalarReached(raw, pattern, maxScalarValueChars) {
12
20
  if (raw === undefined || raw === null)
13
21
  return false;
14
22
  const t = typeof raw;
@@ -15,8 +15,9 @@ import { type TaskSandboxSettings } from "./command-sandbox.js";
15
15
  import type { ToolExecuteContext } from "./tool-spec.js";
16
16
  import type { FastModeLeg } from "./runner/fast-mode-seat.js";
17
17
  import type { TaskSpec } from "./types.js";
18
+ import { type ProjectSeat } from "./project-seat.js";
18
19
  /** The fields of a spec the seat carries — one `Pick`, shared by the mint's input and the apply's target. */
19
- export type ParentSpecSeatFields = Pick<TaskSpec, "principal" | "isolationScope" | "oneShot" | "clientContext" | "onQuestion" | "mods" | "additionalDirectories" | "additionalReadDirectories" | "envFacts" | "sandbox" | "memoryPersistenceCapable" | "classifyAllShell" | "memory" | "compaction" | "skillListingBudgetFraction" | "skillListingMaxDescChars" | "fileHistory" | "projectMemory" | "promptForm" | "promptBinding" | "promptLocale" | "advisorModel" | "attachments" | "language" | "instructionFamily" | "fastMode">;
20
+ export type ParentSpecSeatFields = Pick<TaskSpec, "principal" | "isolationScope" | "oneShot" | "clientContext" | "onQuestion" | "mods" | "additionalDirectories" | "additionalReadDirectories" | "envFacts" | "sandbox" | "memoryPersistenceCapable" | "classifyAllShell" | "memory" | "compaction" | "skillListingBudgetFraction" | "skillListingMaxDescChars" | "fileHistory" | "projectMemory" | "promptForm" | "promptBinding" | "promptLocale" | "advisorModel" | "attachments" | "language" | "instructionFamily" | "fastMode" | "project">;
20
21
  /**
21
22
  * The seat a run hands its children. Every member is the parent's own value, frozen at mint (arrays copied and
22
23
  * frozen; the facts object copied). Members present iff the parent carries them — an absent member is "nothing to
@@ -88,6 +89,12 @@ export type ParentSpecSeatFields = Pick<TaskSpec, "principal" | "isolationScope"
88
89
  * word as the stream verb (`TaskStream.setFastMode`) last set it ({@link bindParentSpecSeatFastMode}), the spec's word before a
89
90
  * leg is bound — so a toggle reaches every child started after it. Not a clamp: either word travels as written. An ORDINARY
90
91
  * member (fill law): a child's own word stands.
92
+ * · `project` — the parent leg's project SEAT: its verdict's id with the texts that belong to it (`SessionProjectVerdict.seat`; a
93
+ * parent judged by its marker alone hands `{ id }`), bound once after `resolveSessionProject` ({@link bindParentSpecSeatProject}).
94
+ * Every spawner hands it on `RunInternals.parentProject` as the child's DEFAULT (its id used only when the child declares no
95
+ * `project` and its own workspace has no marker; its texts only when the child's verdict is its id) — and a waker hands its own
96
+ * to the agent it wakes. Deliberately NOT copied onto `TaskSpec.project` by {@link applyParentSpecSeat}: a declaration is compared
97
+ * with the child's marker, and a child's own workspace marker must beat the inherited default rather than mismatch against it.
91
98
  */
92
99
  export interface ParentSpecSeat {
93
100
  readonly principal?: string;
@@ -118,6 +125,7 @@ export interface ParentSpecSeat {
118
125
  readonly language?: string;
119
126
  readonly instructionFamily?: TaskSpec["instructionFamily"];
120
127
  readonly fastMode?: boolean;
128
+ readonly project?: ProjectSeat;
121
129
  }
122
130
  /** Refuse (by name, `config.deps_retired_key`) a seat that still carries a retired member. Read at every door a seat enters
123
131
  * by hand: the ctx reader, the apply, and the send lane's waker clamps. */
@@ -125,6 +133,10 @@ export declare function assertParentSpecSeatCurrent(seat: object | undefined): v
125
133
  /** Bind the seat a leg minted to that leg's fast mode: from now on the seat's `fastMode` is what the leg asks for at the moment it
126
134
  * is read — a child started after a toggle is filled with the toggled word. Once per seat, by the leg that minted it. */
127
135
  export declare function bindParentSpecSeatFastMode(seat: ParentSpecSeat, leg: Pick<FastModeLeg, "requested">): void;
136
+ /** Bind the seat a leg minted to that leg's resolved project seat (`sessionProject.seat`): from now on the seat's `project` is the
137
+ * leg's (`undefined` when the leg has no verdict). Bound once per seat, after `resolveSessionProject` runs, so mount validation still
138
+ * runs before the marker walk. */
139
+ export declare function bindParentSpecSeatProject(seat: ParentSpecSeat, project: ProjectSeat | undefined): void;
128
140
  /** Mint the seat off the parent's REBOUND spec and its frozen question face (spec over deps — the caller resolves it once,
129
141
  * the same value the parent's own question routing reads). Absent fields stay absent; `oneShot` only when `true`. `fastMode` is
130
142
  * read when it is read: the bound leg's ask ({@link bindParentSpecSeatFastMode}) — `undefined` while the leg asks for nothing and
@@ -3,6 +3,7 @@ import { assertNoRetiredKeys } from "./retired-keys.js";
3
3
  import { mergeChildSandbox, receiveTaskSandbox } from "./command-sandbox.js";
4
4
  import { codedRefusal } from "./thrown-value.js";
5
5
  import { isolationScopeOf } from "./isolation-scope.js";
6
+ import { screenProjectSeat } from "./project-seat.js";
6
7
  function frozenDataCopy(v) {
7
8
  if (Array.isArray(v))
8
9
  return Object.freeze(Array.from(v, (x) => frozenDataCopy(x)));
@@ -18,15 +19,28 @@ export function assertParentSpecSeatCurrent(seat) {
18
19
  assertNoRetiredKeys(seat, RETIRED_PARENT_SPEC_SEAT_KEYS, "ParentSpecSeat");
19
20
  }
20
21
  const SEAT_FAST_MODE_LEG = new WeakMap();
22
+ const SEAT_PROJECT = new WeakMap();
21
23
  export function bindParentSpecSeatFastMode(seat, leg) {
22
24
  const cell = SEAT_FAST_MODE_LEG.get(seat);
23
25
  if (cell === undefined || cell.leg !== undefined)
24
26
  throw new Error("parentSpecSeat: a seat's fast mode is bound once, by the leg that minted it");
25
27
  cell.leg = leg;
26
28
  }
29
+ export function bindParentSpecSeatProject(seat, project) {
30
+ const cell = SEAT_PROJECT.get(seat);
31
+ if (cell === undefined || cell.bound)
32
+ throw new Error("parentSpecSeat: a seat's project is bound once, by the leg that minted it");
33
+ cell.bound = true;
34
+ cell.seat = project;
35
+ }
27
36
  export function parentSpecSeatOf(spec, frozenOnQuestion) {
28
37
  const word = spec.fastMode;
29
38
  const cell = {};
39
+ const minted = screenProjectSeat(spec.project, "ParentSpecSeatFields.project");
40
+ if (!minted.ok)
41
+ throw codedRefusal(minted.code, minted.message);
42
+ const projectWord = minted.seat;
43
+ const projectCell = { bound: false };
30
44
  const seat = Object.freeze({
31
45
  ...(spec.principal !== undefined ? { principal: spec.principal } : {}),
32
46
  ...(spec.isolationScope !== undefined ? { isolationScope: spec.isolationScope } : {}),
@@ -56,9 +70,13 @@ export function parentSpecSeatOf(spec, frozenOnQuestion) {
56
70
  const asked = cell.leg?.requested;
57
71
  return asked === undefined || (!asked && word === undefined) ? word : asked;
58
72
  },
73
+ get project() {
74
+ return projectCell.bound ? projectCell.seat : projectWord;
75
+ },
59
76
  ...clampFieldSeatsOf(spec),
60
77
  });
61
78
  SEAT_FAST_MODE_LEG.set(seat, cell);
79
+ SEAT_PROJECT.set(seat, projectCell);
62
80
  return seat;
63
81
  }
64
82
  export function applyParentSpecSeat(child, seat) {
@@ -0,0 +1,52 @@
1
+ /**
2
+ * A protocol peer's REGISTRATION as a person's yes binds it: the declaration as the host wrote it — the facts it states about where a
3
+ * call to the peer's tools goes, as whom and with which identity, each as written (no spelling is judged equal to another: the
4
+ * deployment's peer seat is handed the spelling and may answer each differently), read off the declaration the dial judged by that
5
+ * protocol's materializer (`a2aPeerRegistration`, `mcpPeerRegistration`), never off the peer. The one equality is a default the
6
+ * declaration type itself states (`boundary` absent is `outside`, `callerMeta` absent is `false`), which the materializer writes out.
7
+ *
8
+ * A tool carries only their digest (`AgentTool.peerRegistration`), minted here once; the roster row copies it
9
+ * (`ToolRosterEntry.registration`, a declaration member), so a parked approval's declaration digest covers the registration and a
10
+ * resume whose registration moved — another spelling included — vetoes the approved call (`resume.target_moved`). The digest is
11
+ * deterministic and unsalted: one registration has one digest in every frame and deployment. The facts never ride the tool object: it
12
+ * is handed whole to a host's model adapter and counted by the spend meter.
13
+ */
14
+ import type { CredentialRef } from "@sema-agent/primitives";
15
+ import type { A2aServerSpec, McpServerSpec, McpTransportKind } from "./mcp-server-spec.js";
16
+ /** The facts of one registration: JSON data (strings, lists of strings, a credential reference record), an absent fact not a key. */
17
+ export type PeerRegistrationFacts = {
18
+ readonly [fact: string]: unknown;
19
+ };
20
+ /** The digest a tool carries for its peer's registration, keyed by protocol (an MCP server's facts and an A2A peer's never read as one
21
+ * another's). The one mint of `AgentTool.peerRegistration`. */
22
+ export declare function peerRegistrationDigestOf(source: "mcp" | "a2a", facts: PeerRegistrationFacts): string;
23
+ /**
24
+ * A credential reference as a registration fact, by its content (`CREDENTIAL_REF_KINDS`): its kind always — declaring none and
25
+ * declaring one are two registrations — and, for a reference that IS its own content, the rest as written: `env` (header → variable
26
+ * names), `vault` (the stored entry it names), `assertion` (the audience it is requested for). A `handle`'s id is not content: an opaque
27
+ * id the deployment minted, which a deployment may mint again per process for the same credential, so a handle enters as its kind
28
+ * alone (KL-5333-c). The one reading both protocols take.
29
+ */
30
+ export declare function credentialReferenceFact(ref: CredentialRef | undefined): {
31
+ credentials?: CredentialRef | {
32
+ readonly kind: "handle";
33
+ };
34
+ };
35
+ /**
36
+ * An A2A peer's registration facts, each as the host wrote it: its addresses (`url`, `cardUrl`), its side of the trust boundary (absent
37
+ * is `outside`, the declaration type's own default), its owning team, its identity stamp, its credential reference when that is its own
38
+ * content ({@link credentialReferenceFact}) and the header the end user's identity rides under. Not among them: its display name (the
39
+ * card's label for people, as a row's render hints are) and which skills it exposes (`allowSkills` says whether a tool is there at all —
40
+ * a skill no longer mounted is `resume.tool_unavailable`). Read off the declaration the dial judged, never off the card.
41
+ */
42
+ export declare function a2aPeerRegistration(spec: A2aServerSpec): PeerRegistrationFacts;
43
+ /**
44
+ * An MCP server's registration facts, each as the host wrote it: its transport as the peer seat is asked about it ({@link mcpPeerTarget}:
45
+ * the endpoint, or the whole start command, each with its credential reference when that is its own content; or the host's own pipe),
46
+ * the header the end user's identity rides under, its mount identity stamp, and what its requests disclose of the caller
47
+ * (`sessionMetaKey`, `callerMeta` — absent is `false`, the declaration type's own default). A host pipe has no address: what is compared
48
+ * is its stamp and the two caller settings (KL-5333-b). Not among them: which tools it exposes (`allowTools` — a tool no longer mounted
49
+ * is `resume.tool_unavailable`), its startup bound, and the axes the roster row already carries as declaration members. `kind` is the
50
+ * dial's one read of the transport's kind.
51
+ */
52
+ export declare function mcpPeerRegistration(spec: McpServerSpec, kind: McpTransportKind | undefined): PeerRegistrationFacts;
@@ -0,0 +1,37 @@
1
+ import { canonicalJsonStringify, sha16 } from "./canonical-json.js";
2
+ import { mcpPeerTarget } from "./peer-seat.js";
3
+ export function peerRegistrationDigestOf(source, facts) {
4
+ return sha16(canonicalJsonStringify({ source, registration: facts }));
5
+ }
6
+ export function credentialReferenceFact(ref) {
7
+ if (ref === undefined)
8
+ return {};
9
+ return { credentials: ref.kind === "handle" ? { kind: "handle" } : ref };
10
+ }
11
+ export function a2aPeerRegistration(spec) {
12
+ return {
13
+ url: spec.url,
14
+ ...(spec.cardUrl !== undefined ? { cardUrl: spec.cardUrl } : {}),
15
+ boundary: spec.boundary === "inside" ? "inside" : "outside",
16
+ ...(spec.ownerTeam !== undefined ? { ownerTeam: spec.ownerTeam } : {}),
17
+ ...(spec.fingerprint !== undefined ? { fingerprint: spec.fingerprint } : {}),
18
+ ...credentialReferenceFact(spec.credentials),
19
+ ...(spec.principalHeader !== undefined ? { principalHeader: spec.principalHeader } : {}),
20
+ };
21
+ }
22
+ export function mcpPeerRegistration(spec, kind) {
23
+ const target = mcpPeerTarget(spec, kind);
24
+ const t = spec.transport;
25
+ const where = target.transport === "host"
26
+ ? {}
27
+ : target.transport === "stdio"
28
+ ? { command: target.command, args: target.args, ...credentialReferenceFact(target.credentials) }
29
+ : { url: target.url, ...credentialReferenceFact(target.credentials), ...("principalHeader" in t && t.principalHeader !== undefined ? { principalHeader: t.principalHeader } : {}) };
30
+ return {
31
+ transport: target.transport,
32
+ ...where,
33
+ ...(typeof spec.fingerprint === "string" ? { fingerprint: spec.fingerprint } : {}),
34
+ ...(spec.sessionMetaKey !== undefined ? { sessionMetaKey: spec.sessionMetaKey } : {}),
35
+ ...(spec.callerMeta === true ? { callerMeta: true } : {}),
36
+ };
37
+ }
@@ -312,7 +312,9 @@ export type PeerCarrierIdentity = PeerSeatTarget | {
312
312
  readonly transport: "host";
313
313
  };
314
314
  /** 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. */
315
- export declare function mcpPeerTarget(spec: McpServerSpec, kind: McpTransportKind | undefined): PeerCarrierIdentity;
315
+ export declare function mcpPeerTarget(spec: McpServerSpec, kind: McpTransportKind | undefined): Extract<PeerCarrierIdentity, {
316
+ readonly protocol: "mcp";
317
+ }>;
316
318
  /** Whether a failure is the HTTP endpoint answering 401 (the SDK's status error, on the thrown value or its cause chain). Structure only. */
317
319
  export declare function answeredUnauthorized(err: unknown): boolean;
318
320
  /** The one reading of a re-send's failure: its record says it was not delivered (`details.delivered === "no"` — the seat could not
@@ -8,7 +8,7 @@ import { optionKeys, strayMembersOf } from "./own-property-receipt.js";
8
8
  import { readMember, readOwnMembers } from "./thrown-value.js";
9
9
  import { assertEndpointBound, httpTrimmed, resolveProtocolHttpHeaders } from "./protocol-http-auth.js";
10
10
  import { askCarriedRevocation } from "./protocol-revocation.js";
11
- import { credentialHeaderValues, holdOwnCredentialValues, isSecretEnvKey, namesASecret } from "./secret-env.js";
11
+ import { credentialHeaderValues, entryLooksLikeCredential, holdOwnCredentialValues, namesASecret } from "./secret-env.js";
12
12
  import { inlineUntrusted } from "./untrusted-text.js";
13
13
  const PEER_SEAT_MEMBERS = Object.freeze(["answer", "hold", "release"]);
14
14
  const RECEIVED = new WeakMap();
@@ -438,7 +438,7 @@ export class PeerCarrier {
438
438
  const pieces = read.carry;
439
439
  this.holdAnswered(pieces);
440
440
  for (const [name, value] of Object.entries(pieces.env ?? {}))
441
- if (isSecretEnvKey(name, value))
441
+ if (entryLooksLikeCredential(name, value))
442
442
  this.remember(value);
443
443
  if (this.lane === "stdio")
444
444
  this.expiresAt = pieces.expiresAt;
@@ -475,7 +475,7 @@ function answeredCredentialValues(answer) {
475
475
  found.add(credential);
476
476
  }
477
477
  for (const [name, value] of stringMembers(members["env"]))
478
- if (isSecretEnvKey(name, value))
478
+ if (entryLooksLikeCredential(name, value))
479
479
  found.add(value);
480
480
  return [...found];
481
481
  }