@sema-agent/core 7.59.0 → 7.61.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 (643) hide show
  1. package/CHANGELOG.md +1169 -0
  2. package/README.md +2 -2
  3. package/dist/agents/agent-definition.d.ts +7 -0
  4. package/dist/agents/agent-definition.js +12 -0
  5. package/dist/agents/agent-transcript-tool.d.ts +4 -3
  6. package/dist/agents/agent-transcript-tool.js +4 -2
  7. package/dist/agents/cascade.d.ts +61 -10
  8. package/dist/agents/cascade.js +60 -20
  9. package/dist/agents/child-model-seat.js +6 -3
  10. package/dist/agents/composition-allowance.d.ts +53 -0
  11. package/dist/agents/composition-allowance.js +49 -0
  12. package/dist/agents/composition-placement.d.ts +29 -0
  13. package/dist/agents/composition-placement.js +24 -0
  14. package/dist/agents/cumulative-stats.d.ts +4 -0
  15. package/dist/agents/cumulative-stats.js +3 -1
  16. package/dist/agents/inherited-tool-pool.d.ts +28 -1
  17. package/dist/agents/inherited-tool-pool.js +22 -0
  18. package/dist/agents/list-agents-tool.d.ts +1 -1
  19. package/dist/agents/peer-notice-route.d.ts +1 -1
  20. package/dist/agents/peer-notice-route.js +4 -3
  21. package/dist/agents/peer-notices.d.ts +4 -4
  22. package/dist/agents/peer-notices.js +8 -4
  23. package/dist/agents/peer-session-drain.d.ts +8 -1
  24. package/dist/agents/peer-session-drain.js +36 -7
  25. package/dist/agents/repair-loop.js +16 -6
  26. package/dist/agents/retain-ledger.d.ts +11 -1
  27. package/dist/agents/retain-ledger.js +16 -3
  28. package/dist/agents/roster-store.d.ts +2 -2
  29. package/dist/agents/roster-store.js +8 -3
  30. package/dist/agents/send-message-tool.d.ts +14 -27
  31. package/dist/agents/send-message-tool.js +47 -54
  32. package/dist/agents/subagent-completion-gate.d.ts +35 -0
  33. package/dist/agents/subagent-completion-gate.js +62 -0
  34. package/dist/agents/subagent-steps.d.ts +7 -6
  35. package/dist/agents/subagent.d.ts +52 -28
  36. package/dist/agents/subagent.js +276 -246
  37. package/dist/agents/suspend-guard.d.ts +9 -0
  38. package/dist/agents/suspend-guard.js +4 -0
  39. package/dist/agents/tool-filter.d.ts +1 -3
  40. package/dist/agents/tool-filter.js +4 -12
  41. package/dist/agents/verify.d.ts +41 -14
  42. package/dist/agents/verify.js +37 -27
  43. package/dist/bench/metrics.d.ts +3 -5
  44. package/dist/bench/metrics.js +0 -1
  45. package/dist/brain/anthropic.js +1 -0
  46. package/dist/brain/degrading.js +3 -1
  47. package/dist/brain/errors.d.ts +7 -1
  48. package/dist/brain/errors.js +6 -0
  49. package/dist/brain/failover.js +2 -1
  50. package/dist/brain/open-responses.js +1 -0
  51. package/dist/brain/openai.js +1 -0
  52. package/dist/brain/provider-dialect.d.ts +10 -0
  53. package/dist/brain/provider-dialect.js +13 -2
  54. package/dist/brain/route-adjudicator.js +3 -1
  55. package/dist/brain/status-sink.d.ts +7 -1
  56. package/dist/brain/status-sink.js +6 -0
  57. package/dist/brain/stream-engine.d.ts +3 -0
  58. package/dist/brain/stream-engine.js +4 -0
  59. package/dist/brain/timeout.d.ts +3 -1
  60. package/dist/brain/timeout.js +18 -5
  61. package/dist/core/a2a.d.ts +15 -5
  62. package/dist/core/a2a.js +34 -19
  63. package/dist/core/agent-definition.d.ts +20 -0
  64. package/dist/core/agent-state.d.ts +1 -1
  65. package/dist/core/allow-entry.d.ts +61 -23
  66. package/dist/core/allow-entry.js +134 -39
  67. package/dist/core/artifact-host.d.ts +0 -2
  68. package/dist/core/artifact-host.js +0 -1
  69. package/dist/core/ask-origin.d.ts +79 -0
  70. package/dist/core/ask-origin.js +76 -0
  71. package/dist/core/ask-question.d.ts +19 -13
  72. package/dist/core/ask-question.js +8 -2
  73. package/dist/core/auto-compaction.d.ts +2 -0
  74. package/dist/core/auto-compaction.js +2 -1
  75. package/dist/core/auto-mode-defaults.d.ts +8 -0
  76. package/dist/core/auto-mode-defaults.js +1 -0
  77. package/dist/core/auto-mode-rebuild.d.ts +2 -1
  78. package/dist/core/auto-mode.d.ts +39 -4
  79. package/dist/core/auto-mode.js +66 -17
  80. package/dist/core/background-agent-store.d.ts +17 -6
  81. package/dist/core/background-agent-store.js +15 -13
  82. package/dist/core/background-shell.d.ts +12 -1
  83. package/dist/core/background-shell.js +12 -0
  84. package/dist/core/checkpoint-requirements.d.ts +24 -3
  85. package/dist/core/checkpoint-requirements.js +9 -1
  86. package/dist/core/checkpoint-store.d.ts +86 -32
  87. package/dist/core/checkpoint-store.js +10 -5
  88. package/dist/core/child-clamp-seats.d.ts +3 -2
  89. package/dist/core/child-clamp-seats.js +4 -3
  90. package/dist/core/closest-name.d.ts +13 -0
  91. package/dist/core/closest-name.js +35 -0
  92. package/dist/core/compliance.d.ts +1 -1
  93. package/dist/core/context-settings.js +3 -5
  94. package/dist/core/credential-echo.d.ts +52 -0
  95. package/dist/core/credential-echo.js +65 -0
  96. package/dist/core/credential-vocabulary.d.ts +13 -3
  97. package/dist/core/credential-vocabulary.js +12 -4
  98. package/dist/core/cross-boundary-taint.d.ts +5 -6
  99. package/dist/core/decision-receipt.d.ts +14 -1
  100. package/dist/core/decision-receipt.js +6 -3
  101. package/dist/core/delegation-frames.d.ts +13 -9
  102. package/dist/core/effective-path-target.js +2 -3
  103. package/dist/core/engine-attestation.d.ts +11 -1
  104. package/dist/core/engine-attestation.js +2 -0
  105. package/dist/core/engine-notice.d.ts +106 -32
  106. package/dist/core/file-history-retention.d.ts +8 -0
  107. package/dist/core/file-history-retention.js +14 -11
  108. package/dist/core/file-history-store.d.ts +31 -1
  109. package/dist/core/file-history-store.js +31 -2
  110. package/dist/core/frame-settlement.d.ts +15 -0
  111. package/dist/core/frame-settlement.js +10 -1
  112. package/dist/core/fs-write-gate-policy.d.ts +3 -3
  113. package/dist/core/fs-write-gate-policy.js +8 -7
  114. package/dist/core/gate-fold.js +9 -6
  115. package/dist/core/gate-lanes.js +46 -12
  116. package/dist/core/gate-outcome.d.ts +40 -1
  117. package/dist/core/gate-outcome.js +10 -0
  118. package/dist/core/git-worktree-env.d.ts +7 -3
  119. package/dist/core/git-worktree-env.js +16 -13
  120. package/dist/core/governance-codes.d.ts +19 -3
  121. package/dist/core/governance-codes.js +27 -3
  122. package/dist/core/hands-band-screen.js +0 -1
  123. package/dist/core/hands-band.d.ts +0 -3
  124. package/dist/core/hooks.d.ts +51 -60
  125. package/dist/core/hooks.js +131 -78
  126. package/dist/core/host-floor.js +3 -5
  127. package/dist/core/image-admission.d.ts +145 -52
  128. package/dist/core/image-admission.js +202 -47
  129. package/dist/core/image-downsample.d.ts +36 -69
  130. package/dist/core/image-downsample.js +111 -73
  131. package/dist/core/input-author.d.ts +36 -0
  132. package/dist/core/input-author.js +39 -0
  133. package/dist/core/integer-option.d.ts +21 -0
  134. package/dist/core/integer-option.js +13 -0
  135. package/dist/core/leg-identity.d.ts +62 -0
  136. package/dist/core/leg-identity.js +18 -0
  137. package/dist/core/locked-config.d.ts +55 -3
  138. package/dist/core/locked-config.js +84 -51
  139. package/dist/core/lsp.d.ts +5 -3
  140. package/dist/core/lsp.js +3 -2
  141. package/dist/core/mailbox-store.d.ts +85 -10
  142. package/dist/core/mailbox-store.js +31 -10
  143. package/dist/core/mcp-call-meta.d.ts +2 -2
  144. package/dist/core/mcp-call-meta.js +9 -10
  145. package/dist/core/mcp-connection-pool.d.ts +6 -20
  146. package/dist/core/mcp-connection-pool.js +10 -28
  147. package/dist/core/mcp-failure.d.ts +83 -16
  148. package/dist/core/mcp-failure.js +67 -30
  149. package/dist/core/mcp-host-seat.d.ts +131 -0
  150. package/dist/core/mcp-host-seat.js +305 -0
  151. package/dist/core/mcp-probe.d.ts +7 -2
  152. package/dist/core/mcp-probe.js +9 -4
  153. package/dist/core/mcp-server-link.d.ts +18 -6
  154. package/dist/core/mcp-server-link.js +19 -4
  155. package/dist/core/mcp-server-spec.d.ts +39 -9
  156. package/dist/core/mcp-server-spec.js +55 -21
  157. package/dist/core/mcp-session-end.d.ts +1 -2
  158. package/dist/core/mcp-session-end.js +1 -1
  159. package/dist/core/mcp.d.ts +23 -55
  160. package/dist/core/mcp.js +172 -156
  161. package/dist/core/media-byte-cap.d.ts +21 -46
  162. package/dist/core/media-byte-cap.js +55 -55
  163. package/dist/core/member-group.d.ts +7 -0
  164. package/dist/core/member-group.js +35 -0
  165. package/dist/core/memory-admission.d.ts +23 -6
  166. package/dist/core/memory-admission.js +19 -9
  167. package/dist/core/memory-engine/consolidation.d.ts +1 -1
  168. package/dist/core/memory-engine/consolidation.js +7 -1
  169. package/dist/core/memory-engine/content-origin.d.ts +13 -0
  170. package/dist/core/memory-engine/content-origin.js +21 -3
  171. package/dist/core/memory-engine/dual-root.d.ts +31 -0
  172. package/dist/core/memory-engine/dual-root.js +59 -11
  173. package/dist/core/memory-engine/engine.js +27 -24
  174. package/dist/core/memory-engine/file-backend.d.ts +13 -0
  175. package/dist/core/memory-engine/file-backend.js +35 -15
  176. package/dist/core/memory-engine/index.d.ts +2 -1
  177. package/dist/core/memory-engine/index.js +2 -1
  178. package/dist/core/memory-engine/layout.d.ts +3 -0
  179. package/dist/core/memory-engine/layout.js +13 -3
  180. package/dist/core/memory-engine/memory-deployment.d.ts +110 -0
  181. package/dist/core/memory-engine/memory-deployment.js +182 -0
  182. package/dist/core/memory-engine/scope-contract.d.ts +13 -3
  183. package/dist/core/memory-engine/scope-contract.js +2 -2
  184. package/dist/core/memory-engine/sync-client.d.ts +68 -13
  185. package/dist/core/memory-engine/sync-client.js +147 -18
  186. package/dist/core/memory-engine/sync-report.d.ts +106 -0
  187. package/dist/core/memory-engine/sync-report.js +119 -0
  188. package/dist/core/memory-engine/sync.d.ts +13 -3
  189. package/dist/core/mode-policy.d.ts +15 -7
  190. package/dist/core/mode-policy.js +18 -6
  191. package/dist/core/model-receipt.d.ts +39 -0
  192. package/dist/core/model-receipt.js +139 -0
  193. package/dist/core/mods/agent-stations.d.ts +100 -0
  194. package/dist/core/mods/agent-stations.js +154 -0
  195. package/dist/core/mods/dollar.d.ts +62 -0
  196. package/dist/core/mods/extension-call.d.ts +15 -1
  197. package/dist/core/mods/extension-call.js +7 -2
  198. package/dist/core/mods/kernel/dispatch.d.ts +9 -4
  199. package/dist/core/mods/kernel/dispatch.js +8 -8
  200. package/dist/core/mods/kernel/events.d.ts +13 -4
  201. package/dist/core/mods/kernel/events.js +14 -10
  202. package/dist/core/mods/kernel/receive.d.ts +5 -0
  203. package/dist/core/mods/kernel/receive.js +10 -0
  204. package/dist/core/mods/kernel/registration.d.ts +3 -0
  205. package/dist/core/mods/kernel/registration.js +5 -0
  206. package/dist/core/mods/kernel/site-rules.d.ts +6 -3
  207. package/dist/core/mods/kernel/site-rules.js +10 -2
  208. package/dist/core/mods/lifecycle-stations.d.ts +41 -0
  209. package/dist/core/mods/lifecycle-stations.js +35 -0
  210. package/dist/core/mods/session-append.d.ts +115 -0
  211. package/dist/core/mods/session-append.js +311 -0
  212. package/dist/core/mods/session-compact.d.ts +48 -0
  213. package/dist/core/mods/session-compact.js +194 -0
  214. package/dist/core/mods/session-receive.d.ts +93 -0
  215. package/dist/core/mods/session-receive.js +141 -0
  216. package/dist/core/mods/session-send.d.ts +72 -0
  217. package/dist/core/mods/session-send.js +88 -0
  218. package/dist/core/mods/stations.d.ts +89 -75
  219. package/dist/core/mods/stations.js +57 -53
  220. package/dist/core/mods/tool-call.d.ts +12 -4
  221. package/dist/core/mods/tool-call.js +32 -16
  222. package/dist/core/mounted-mcp.d.ts +5 -0
  223. package/dist/core/mounted-mcp.js +2 -2
  224. package/dist/core/namespaced-rule-name.d.ts +7 -1
  225. package/dist/core/namespaced-rule-name.js +13 -2
  226. package/dist/core/oracle-isolation.js +1 -1
  227. package/dist/core/output-style.js +3 -4
  228. package/dist/core/own-property-receipt.d.ts +62 -0
  229. package/dist/core/own-property-receipt.js +43 -0
  230. package/dist/core/park-selfcheck.js +12 -10
  231. package/dist/core/path-identity.d.ts +11 -0
  232. package/dist/core/path-identity.js +4 -0
  233. package/dist/core/path-rule-binding.d.ts +3 -1
  234. package/dist/core/path-rule-binding.js +3 -1
  235. package/dist/core/peer-seat.d.ts +66 -11
  236. package/dist/core/peer-seat.js +199 -42
  237. package/dist/core/permission-rule-consent.d.ts +21 -26
  238. package/dist/core/permission-rule-consent.js +22 -3
  239. package/dist/core/permission-rule-model.d.ts +38 -13
  240. package/dist/core/permission-rule-model.js +54 -16
  241. package/dist/core/permission-rule-org.d.ts +1 -1
  242. package/dist/core/permission-rule-provider.js +4 -1
  243. package/dist/core/permission-rules.d.ts +4 -0
  244. package/dist/core/permission-rules.js +11 -16
  245. package/dist/core/protocol-http-auth.d.ts +14 -2
  246. package/dist/core/protocol-http-auth.js +16 -7
  247. package/dist/core/read-face-seats.d.ts +7 -5
  248. package/dist/core/read-face-seats.js +4 -1
  249. package/dist/core/redaction-marks.d.ts +4 -3
  250. package/dist/core/redaction-marks.js +2 -2
  251. package/dist/core/remote-env.d.ts +218 -122
  252. package/dist/core/remote-env.js +133 -14
  253. package/dist/core/retention-policy.d.ts +24 -23
  254. package/dist/core/retention-policy.js +36 -2
  255. package/dist/core/retention.d.ts +4 -1
  256. package/dist/core/retention.js +37 -12
  257. package/dist/core/retired-keys.d.ts +8 -3
  258. package/dist/core/retired-keys.js +4 -1
  259. package/dist/core/rewrite-rejudge.d.ts +12 -5
  260. package/dist/core/rewrite-rejudge.js +9 -5
  261. package/dist/core/roles.d.ts +37 -3
  262. package/dist/core/roles.js +126 -78
  263. package/dist/core/row-admission.d.ts +10 -0
  264. package/dist/core/row-admission.js +5 -0
  265. package/dist/core/rule-owner.d.ts +3 -0
  266. package/dist/core/runner/advisor-instructions.d.ts +2 -1
  267. package/dist/core/runner/advisor-instructions.js +2 -1
  268. package/dist/core/runner/announce-once-ledger.d.ts +4 -4
  269. package/dist/core/runner/assemble-result.d.ts +13 -8
  270. package/dist/core/runner/assemble-result.js +12 -8
  271. package/dist/core/runner/call-hook-stations.d.ts +17 -10
  272. package/dist/core/runner/call-hook-stations.js +21 -10
  273. package/dist/core/runner/caller-roster.d.ts +12 -9
  274. package/dist/core/runner/caller-roster.js +5 -2
  275. package/dist/core/runner/checkpoint-scope.d.ts +16 -1
  276. package/dist/core/runner/checkpoint-scope.js +21 -0
  277. package/dist/core/runner/child-tree.d.ts +7 -8
  278. package/dist/core/runner/child-tree.js +6 -6
  279. package/dist/core/runner/classifier-ladder.d.ts +10 -2
  280. package/dist/core/runner/classifier-ladder.js +39 -8
  281. package/dist/core/runner/compact-session.js +14 -2
  282. package/dist/core/runner/compaction-call-options.d.ts +1 -1
  283. package/dist/core/runner/compaction-restate.d.ts +2 -2
  284. package/dist/core/runner/compaction-restate.js +4 -3
  285. package/dist/core/runner/construction-doors.d.ts +2 -2
  286. package/dist/core/runner/construction-doors.js +7 -2
  287. package/dist/core/runner/contracts.d.ts +158 -65
  288. package/dist/core/runner/cross-boundary-lane.d.ts +4 -6
  289. package/dist/core/runner/cross-boundary-lane.js +11 -2
  290. package/dist/core/runner/decide-continuation.d.ts +4 -2
  291. package/dist/core/runner/decide-continuation.js +7 -4
  292. package/dist/core/runner/denial-limit-arms.d.ts +15 -21
  293. package/dist/core/runner/denial-limit-arms.js +17 -10
  294. package/dist/core/runner/env-capability-census.d.ts +15 -20
  295. package/dist/core/runner/env-capability-census.js +25 -34
  296. package/dist/core/runner/expire-settle.d.ts +44 -0
  297. package/dist/core/runner/expire-settle.js +55 -0
  298. package/dist/core/runner/file-history-request.d.ts +2 -2
  299. package/dist/core/runner/file-history-request.js +0 -8
  300. package/dist/core/runner/gate-exit.d.ts +75 -7
  301. package/dist/core/runner/gate-exit.js +20 -1
  302. package/dist/core/runner/git-status-frame.d.ts +5 -2
  303. package/dist/core/runner/git-status-frame.js +4 -4
  304. package/dist/core/runner/halt-attribution.d.ts +2 -1
  305. package/dist/core/runner/halt-attribution.js +2 -1
  306. package/dist/core/runner/image.d.ts +7 -2
  307. package/dist/core/runner/image.js +14 -8
  308. package/dist/core/runner/inline-image.d.ts +10 -8
  309. package/dist/core/runner/inline-image.js +11 -9
  310. package/dist/core/runner/local-claims.d.ts +17 -0
  311. package/dist/core/runner/local-claims.js +18 -0
  312. package/dist/core/runner/media-removed-seat.d.ts +46 -0
  313. package/dist/core/runner/media-removed-seat.js +88 -0
  314. package/dist/core/runner/memory-consolidation-driver.js +4 -4
  315. package/dist/core/runner/park-commit.d.ts +2 -2
  316. package/dist/core/runner/permission-rule-lanes.d.ts +5 -1
  317. package/dist/core/runner/permission-rule-lanes.js +29 -10
  318. package/dist/core/runner/person-path-rows.js +1 -1
  319. package/dist/core/runner/placement-fence.d.ts +26 -0
  320. package/dist/core/runner/placement-fence.js +38 -0
  321. package/dist/core/runner/prepare-ask-lane.d.ts +6 -12
  322. package/dist/core/runner/prepare-ask-lane.js +4 -4
  323. package/dist/core/runner/prepare-boundary-parks.d.ts +6 -3
  324. package/dist/core/runner/prepare-boundary-parks.js +4 -4
  325. package/dist/core/runner/prepare-caps-and-workflow.d.ts +6 -0
  326. package/dist/core/runner/prepare-caps-and-workflow.js +5 -3
  327. package/dist/core/runner/prepare-config-doors.d.ts +6 -1
  328. package/dist/core/runner/prepare-config-doors.js +30 -26
  329. package/dist/core/runner/prepare-context-lane.d.ts +6 -2
  330. package/dist/core/runner/prepare-context-lane.js +13 -13
  331. package/dist/core/runner/prepare-delegation-surface.d.ts +13 -11
  332. package/dist/core/runner/prepare-delegation-surface.js +7 -8
  333. package/dist/core/runner/prepare-execution-env.d.ts +5 -2
  334. package/dist/core/runner/prepare-execution-env.js +7 -4
  335. package/dist/core/runner/prepare-file-history.d.ts +10 -12
  336. package/dist/core/runner/prepare-file-history.js +3 -12
  337. package/dist/core/runner/prepare-gate-stations.d.ts +23 -17
  338. package/dist/core/runner/prepare-gate-stations.js +10 -7
  339. package/dist/core/runner/prepare-hands-readface.d.ts +8 -6
  340. package/dist/core/runner/prepare-hands-readface.js +19 -11
  341. package/dist/core/runner/prepare-inherited-gate.d.ts +11 -4
  342. package/dist/core/runner/prepare-inherited-gate.js +12 -5
  343. package/dist/core/runner/prepare-lsp.d.ts +3 -0
  344. package/dist/core/runner/prepare-lsp.js +2 -2
  345. package/dist/core/runner/prepare-memory-engine-session.js +1 -1
  346. package/dist/core/runner/prepare-memory.d.ts +2 -2
  347. package/dist/core/runner/prepare-memory.js +2 -2
  348. package/dist/core/runner/prepare-park-ask.d.ts +8 -7
  349. package/dist/core/runner/prepare-park-ask.js +6 -12
  350. package/dist/core/runner/prepare-policy-chain.d.ts +15 -25
  351. package/dist/core/runner/prepare-policy-chain.js +131 -128
  352. package/dist/core/runner/prepare-project-context.d.ts +2 -2
  353. package/dist/core/runner/prepare-project-context.js +8 -5
  354. package/dist/core/runner/prepare-prompt-inputs.d.ts +4 -0
  355. package/dist/core/runner/prepare-prompt-inputs.js +4 -2
  356. package/dist/core/runner/prepare-protocol-tools.d.ts +5 -3
  357. package/dist/core/runner/prepare-protocol-tools.js +9 -2
  358. package/dist/core/runner/prepare-question-face.d.ts +6 -4
  359. package/dist/core/runner/prepare-question-face.js +2 -2
  360. package/dist/core/runner/prepare-run-refs.d.ts +3 -0
  361. package/dist/core/runner/prepare-run-refs.js +2 -2
  362. package/dist/core/runner/prepare-suspend-saga.d.ts +11 -9
  363. package/dist/core/runner/prepare-suspend-saga.js +21 -13
  364. package/dist/core/runner/prepare-task.d.ts +1 -1
  365. package/dist/core/runner/prepare-task.js +84 -42
  366. package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +6 -0
  367. package/dist/core/runner/prepare-tool-disclosure-mount.js +3 -1
  368. package/dist/core/runner/prepare-turn-wiring.d.ts +2 -0
  369. package/dist/core/runner/prepare-turn-wiring.js +7 -2
  370. package/dist/core/runner/prepare-wiring-manifest.d.ts +7 -3
  371. package/dist/core/runner/prepare-wiring-manifest.js +34 -19
  372. package/dist/core/runner/prepare-workspace-restore.d.ts +5 -0
  373. package/dist/core/runner/prepare-workspace-restore.js +12 -8
  374. package/dist/core/runner/read-root-grant.d.ts +1 -1
  375. package/dist/core/runner/read-root-grant.js +2 -1
  376. package/dist/core/runner/resume-admission.d.ts +5 -3
  377. package/dist/core/runner/resume-admission.js +17 -3
  378. package/dist/core/runner/resume-apply.js +3 -1
  379. package/dist/core/runner/resume-checkpoint-screen.js +4 -4
  380. package/dist/core/runner/resume-claim.d.ts +8 -3
  381. package/dist/core/runner/resume-claim.js +28 -12
  382. package/dist/core/runner/resume-internals-and-config.d.ts +2 -2
  383. package/dist/core/runner/resume-internals-and-config.js +10 -1
  384. package/dist/core/runner/resume-preflight.d.ts +3 -2
  385. package/dist/core/runner/resume-preflight.js +13 -26
  386. package/dist/core/runner/retired-runner-deps.js +6 -1
  387. package/dist/core/runner/run-attachment-seats.js +3 -3
  388. package/dist/core/runner/run-brain-sinks.js +1 -0
  389. package/dist/core/runner/run-git-lane.d.ts +3 -1
  390. package/dist/core/runner/run-git-lane.js +3 -2
  391. package/dist/core/runner/run-harness-handlers.d.ts +3 -1
  392. package/dist/core/runner/run-harness-handlers.js +5 -3
  393. package/dist/core/runner/run-identity-wiring.d.ts +2 -2
  394. package/dist/core/runner/run-identity-wiring.js +15 -6
  395. package/dist/core/runner/run-leg.d.ts +3 -3
  396. package/dist/core/runner/run-leg.js +65 -56
  397. package/dist/core/runner/run-notification-lane.d.ts +3 -1
  398. package/dist/core/runner/run-notification-lane.js +36 -12
  399. package/dist/core/runner/run-recovery-lanes.js +3 -2
  400. package/dist/core/runner/run-settle-and-teardown.js +14 -8
  401. package/dist/core/runner/run-stop-and-final-verify.d.ts +4 -0
  402. package/dist/core/runner/run-stop-and-final-verify.js +12 -4
  403. package/dist/core/runner/run-telemetry-and-budget-seats.d.ts +1 -1
  404. package/dist/core/runner/run-terminal-adoption.d.ts +1 -1
  405. package/dist/core/runner/run-terminal-adoption.js +26 -17
  406. package/dist/core/runner/run-turn-boundary.js +37 -19
  407. package/dist/core/runner/runtask.d.ts +25 -7
  408. package/dist/core/runner/runtask.js +46 -22
  409. package/dist/core/runner/session-rule-policy.d.ts +1 -1
  410. package/dist/core/runner/session-rule-policy.js +6 -1
  411. package/dist/core/runner/shell-env-withheld.d.ts +1 -1
  412. package/dist/core/runner/skills-seat.js +2 -2
  413. package/dist/core/runner/stream-halt-verbs.d.ts +1 -14
  414. package/dist/core/runner/stream-halt-verbs.js +4 -3
  415. package/dist/core/runner/stream-reap.d.ts +7 -6
  416. package/dist/core/runner/stream-reap.js +13 -16
  417. package/dist/core/runner/stream-settle-backstop.d.ts +3 -2
  418. package/dist/core/runner/stream-settle-backstop.js +5 -3
  419. package/dist/core/runner/stream-steer-verb.d.ts +5 -2
  420. package/dist/core/runner/stream-steer-verb.js +8 -7
  421. package/dist/core/runner/sub-agent-deny-lists.js +10 -7
  422. package/dist/core/runner/synthetic-tools.js +2 -2
  423. package/dist/core/runner/terminal-account.d.ts +11 -1
  424. package/dist/core/runner/terminal-account.js +20 -0
  425. package/dist/core/runner/terminal-projection.d.ts +8 -2
  426. package/dist/core/runner/terminal-projection.js +2 -2
  427. package/dist/core/runner/tool-disclosure.d.ts +3 -0
  428. package/dist/core/runner/tool-disclosure.js +5 -4
  429. package/dist/core/runner/tool-end-body.d.ts +3 -3
  430. package/dist/core/runner/tool-end-body.js +1 -1
  431. package/dist/core/runner/tool-face-overlay.d.ts +1 -1
  432. package/dist/core/runner/tool-face-overlay.js +26 -19
  433. package/dist/core/runner/tool-output-projection.d.ts +3 -3
  434. package/dist/core/runner/tool-output-projection.js +7 -6
  435. package/dist/core/runner/tool-result-media-seat.d.ts +9 -1
  436. package/dist/core/runner/tool-result-media-seat.js +17 -1
  437. package/dist/core/runner/tool-table-view.d.ts +56 -0
  438. package/dist/core/runner/tool-table-view.js +51 -0
  439. package/dist/core/runner/turn-attachments.d.ts +6 -7
  440. package/dist/core/runner/turn-attachments.js +4 -17
  441. package/dist/core/runner/void-verifier-pause.d.ts +33 -0
  442. package/dist/core/runner/void-verifier-pause.js +41 -0
  443. package/dist/core/runner-deps.d.ts +55 -43
  444. package/dist/core/secret-env.d.ts +14 -13
  445. package/dist/core/secret-env.js +8 -9
  446. package/dist/core/session-log-transfer.js +9 -10
  447. package/dist/core/session-policy-store.d.ts +10 -3
  448. package/dist/core/session-policy-store.js +21 -3
  449. package/dist/core/session-reconcile.d.ts +3 -2
  450. package/dist/core/session-reconcile.js +7 -4
  451. package/dist/core/session-store.d.ts +5 -2
  452. package/dist/core/session-store.js +53 -16
  453. package/dist/core/session.d.ts +2 -1
  454. package/dist/core/shell-confinement.d.ts +37 -0
  455. package/dist/core/shell-confinement.js +56 -0
  456. package/dist/core/skill-grant.d.ts +9 -0
  457. package/dist/core/skill-grant.js +18 -0
  458. package/dist/core/store-contracts/checkpoint-store-contract.d.ts +2 -2
  459. package/dist/core/store-contracts/checkpoint-store-contract.js +15 -2
  460. package/dist/core/store-contracts/file-history-store-contract.d.ts +5 -2
  461. package/dist/core/store-contracts/file-history-store-contract.js +25 -1
  462. package/dist/core/store-contracts/mailbox-store-contract.d.ts +12 -5
  463. package/dist/core/store-contracts/mailbox-store-contract.js +156 -9
  464. package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
  465. package/dist/core/store-contracts/tool-result-store-contract.js +67 -0
  466. package/dist/core/stub-env.d.ts +5 -5
  467. package/dist/core/stub-env.js +11 -1
  468. package/dist/core/swappable-deps.d.ts +17 -43
  469. package/dist/core/swappable-deps.js +15 -5
  470. package/dist/core/synthetic-read-verdict.d.ts +1 -1
  471. package/dist/core/task-event.d.ts +35 -10
  472. package/dist/core/task-limits.d.ts +5 -0
  473. package/dist/core/task-notification.d.ts +172 -12
  474. package/dist/core/task-notification.js +209 -12
  475. package/dist/core/task-registry-agent.d.ts +23 -55
  476. package/dist/core/task-registry-agent.js +41 -56
  477. package/dist/core/task-registry-monitor.d.ts +8 -1
  478. package/dist/core/task-registry-monitor.js +43 -61
  479. package/dist/core/task-registry-shared.d.ts +52 -114
  480. package/dist/core/task-registry-shared.js +24 -48
  481. package/dist/core/task-registry-workflow.js +5 -22
  482. package/dist/core/task-registry.d.ts +64 -90
  483. package/dist/core/task-registry.js +73 -119
  484. package/dist/core/task-result.d.ts +27 -19
  485. package/dist/core/task-spec-members.d.ts +39 -0
  486. package/dist/core/task-spec-members.js +92 -0
  487. package/dist/core/task-spec.d.ts +13 -16
  488. package/dist/core/task-stream.d.ts +1 -1
  489. package/dist/core/task-tool-shape.d.ts +7 -57
  490. package/dist/core/task-tool-shape.js +7 -66
  491. package/dist/core/terminal-cause.d.ts +30 -0
  492. package/dist/core/terminal-cause.js +1 -0
  493. package/dist/core/tool-catalog-entries.js +3 -6
  494. package/dist/core/tool-check-reading.js +16 -10
  495. package/dist/core/tool-conformance.js +1 -2
  496. package/dist/core/tool-errors.d.ts +6 -3
  497. package/dist/core/tool-errors.js +2 -0
  498. package/dist/core/tool-face-reader.d.ts +7 -6
  499. package/dist/core/tool-face-reader.js +6 -4
  500. package/dist/core/tool-face.d.ts +2 -3
  501. package/dist/core/tool-name-aliases.d.ts +23 -28
  502. package/dist/core/tool-name-aliases.js +63 -7
  503. package/dist/core/tool-name-readings.d.ts +14 -3
  504. package/dist/core/tool-name-readings.js +2 -0
  505. package/dist/core/tool-policy.d.ts +113 -22
  506. package/dist/core/tool-policy.js +85 -15
  507. package/dist/core/tool-registry.d.ts +5 -5
  508. package/dist/core/tool-registry.js +2 -2
  509. package/dist/core/tool-result-store.d.ts +111 -5
  510. package/dist/core/tool-result-store.js +52 -12
  511. package/dist/core/tool-spec.d.ts +39 -10
  512. package/dist/core/trace.d.ts +18 -2
  513. package/dist/core/types.d.ts +3 -3
  514. package/dist/core/types.js +1 -1
  515. package/dist/core/untrusted-text.js +1 -1
  516. package/dist/core/user-attachment.d.ts +10 -5
  517. package/dist/core/user-attachment.js +40 -27
  518. package/dist/core/workflow-journal-store.d.ts +1 -1
  519. package/dist/core/workflow-run-store.d.ts +2 -0
  520. package/dist/core/workflow-run-store.js +6 -5
  521. package/dist/core/workflow-settled-run.d.ts +5 -0
  522. package/dist/core/workflow-settled-run.js +7 -0
  523. package/dist/engine/execution-env/node-execution-env.d.ts +37 -7
  524. package/dist/engine/execution-env/node-execution-env.js +224 -21
  525. package/dist/engine/harness/agent-harness.d.ts +66 -19
  526. package/dist/engine/harness/agent-harness.js +98 -27
  527. package/dist/engine/harness/messages.d.ts +4 -3
  528. package/dist/engine/harness/messages.js +2 -2
  529. package/dist/engine/harness/types.d.ts +151 -34
  530. package/dist/engine/llm/media-removed.d.ts +14 -0
  531. package/dist/engine/llm/media-removed.js +9 -0
  532. package/dist/engine/llm/rejected-images.d.ts +35 -25
  533. package/dist/engine/llm/rejected-images.js +59 -10
  534. package/dist/engine/llm/types.d.ts +24 -3
  535. package/dist/engine/llm/types.js +7 -3
  536. package/dist/engine/loop/agent-loop.d.ts +18 -13
  537. package/dist/engine/loop/agent-loop.js +173 -32
  538. package/dist/engine/loop/types.d.ts +21 -5
  539. package/dist/engine/lsp/node-lsp-manager.d.ts +3 -3
  540. package/dist/engine/lsp/node-lsp-manager.js +32 -13
  541. package/dist/engine/session/import-validate.js +7 -0
  542. package/dist/fixtures/index.d.ts +7 -5
  543. package/dist/fixtures/index.js +5 -3
  544. package/dist/index.d.ts +41 -23
  545. package/dist/index.js +29 -16
  546. package/dist/internal/harness-types.d.ts +3 -1
  547. package/dist/internal/llm.d.ts +2 -1
  548. package/dist/internal/llm.js +1 -0
  549. package/dist/orchestration/goal.d.ts +6 -2
  550. package/dist/orchestration/goal.js +6 -3
  551. package/dist/orchestration/run-workflow-tool.d.ts +20 -20
  552. package/dist/orchestration/run-workflow-tool.js +63 -56
  553. package/dist/orchestration/workflow-governance.d.ts +1 -1
  554. package/dist/orchestration/workflow-governance.js +2 -1
  555. package/dist/orchestration/workflow-types.d.ts +2 -2
  556. package/dist/orchestration/workflow.d.ts +8 -0
  557. package/dist/orchestration/workflow.js +33 -9
  558. package/dist/prompts/default.d.ts +1 -10
  559. package/dist/prompts/default.js +0 -2
  560. package/dist/stores/file/background-agent-store.d.ts +1 -1
  561. package/dist/stores/file/background-agent-store.js +19 -14
  562. package/dist/stores/file/checkpoint-store.d.ts +127 -2
  563. package/dist/stores/file/checkpoint-store.js +24 -16
  564. package/dist/stores/file/file-history-store.d.ts +1 -1
  565. package/dist/stores/file/file-history-store.js +4 -1
  566. package/dist/stores/file/index.d.ts +9 -6
  567. package/dist/stores/file/index.js +33 -9
  568. package/dist/stores/file/ledger-tuning.d.ts +23 -0
  569. package/dist/stores/file/ledger-tuning.js +21 -0
  570. package/dist/stores/file/mailbox-store.d.ts +1 -1
  571. package/dist/stores/file/mailbox-store.js +43 -21
  572. package/dist/stores/file/memory-store.d.ts +1 -1
  573. package/dist/stores/file/memory-store.js +4 -1
  574. package/dist/stores/file/permission-rule-adopt.js +24 -21
  575. package/dist/stores/file/permission-rule-store.js +6 -3
  576. package/dist/stores/file/session-policy-store.d.ts +1 -1
  577. package/dist/stores/file/session-policy-store.js +4 -1
  578. package/dist/stores/file/session-store.d.ts +17 -4
  579. package/dist/stores/file/session-store.js +22 -19
  580. package/dist/stores/file/shared-ledger.d.ts +26 -0
  581. package/dist/stores/file/shared-ledger.js +38 -9
  582. package/dist/stores/file/tool-result-store.d.ts +31 -2
  583. package/dist/stores/file/tool-result-store.js +129 -7
  584. package/dist/stores/file/usage-window-store.d.ts +1 -1
  585. package/dist/stores/file/usage-window-store.js +4 -1
  586. package/dist/stores/file/workflow-journal-store.d.ts +1 -13
  587. package/dist/stores/file/workflow-journal-store.js +4 -18
  588. package/dist/stores/file/workflow-run-store.d.ts +1 -1
  589. package/dist/stores/file/workflow-run-store.js +15 -10
  590. package/dist/tools/fs/containment-face.d.ts +5 -0
  591. package/dist/tools/fs/dead-cwd.d.ts +5 -5
  592. package/dist/tools/fs/dead-cwd.js +4 -11
  593. package/dist/tools/fs/encoding.d.ts +13 -4
  594. package/dist/tools/fs/encoding.js +17 -2
  595. package/dist/tools/fs/fs-bash-background-text.d.ts +13 -0
  596. package/dist/tools/fs/fs-bash-background-text.js +7 -0
  597. package/dist/tools/fs/fs-bash.d.ts +11 -22
  598. package/dist/tools/fs/fs-bash.js +58 -154
  599. package/dist/tools/fs/fs-pdf.d.ts +2 -2
  600. package/dist/tools/fs/fs-pdf.js +34 -27
  601. package/dist/tools/fs/fs-read.d.ts +5 -4
  602. package/dist/tools/fs/fs-read.js +35 -18
  603. package/dist/tools/fs/fs-search-tools.js +4 -1
  604. package/dist/tools/fs/fs-shared.d.ts +39 -16
  605. package/dist/tools/fs/fs-shared.js +25 -6
  606. package/dist/tools/fs/fs-write.js +5 -5
  607. package/dist/tools/fs/index.d.ts +15 -9
  608. package/dist/tools/fs/index.js +12 -18
  609. package/dist/tools/fs/pdf.d.ts +4 -4
  610. package/dist/tools/fs/pdf.js +6 -6
  611. package/dist/tools/fs/read-deny-home.js +8 -1
  612. package/dist/tools/fs/read-deny.d.ts +26 -2
  613. package/dist/tools/fs/read-deny.js +9 -2
  614. package/dist/tools/fs/read-floor.d.ts +57 -6
  615. package/dist/tools/fs/read-floor.js +241 -2
  616. package/dist/tools/fs/removal-targets.d.ts +9 -4
  617. package/dist/tools/fs/removal-targets.js +17 -9
  618. package/dist/tools/fs/search.d.ts +6 -5
  619. package/dist/tools/fs/search.js +10 -10
  620. package/dist/tools/fs/shell-read-establish.js +3 -1
  621. package/dist/tools/fs/shell-read-identity.d.ts +3 -1
  622. package/dist/tools/fs/shell-read-identity.js +4 -2
  623. package/dist/tools/fs/shell-read-judge.d.ts +7 -1
  624. package/dist/tools/fs/shell-read-judge.js +1 -1
  625. package/dist/tools/monitor.d.ts +12 -10
  626. package/dist/tools/monitor.js +22 -13
  627. package/dist/tools/scheduler-tools.js +42 -4
  628. package/dist/tools/web.d.ts +0 -10
  629. package/dist/tools/web.js +1 -4
  630. package/dist/tools/worktree.d.ts +5 -1
  631. package/dist/tools/worktree.js +20 -17
  632. package/package.json +8 -3
  633. package/test/export-surface.snapshot.json +166 -30
  634. package/wire-changes/core-stores-sql@7.60.0.json +30 -0
  635. package/wire-changes/core-stores-sql@7.61.0.json +480 -0
  636. package/wire-changes/core@7.60.0.json +3274 -0
  637. package/wire-changes/core@7.61.0.json +4405 -0
  638. package/wire-changes/mods-kernel@7.60.0.json +62 -0
  639. package/wire-changes/mods-kernel@7.61.0.json +65 -0
  640. package/wire-changes/primitives@7.60.0.json +30 -0
  641. package/wire-changes/primitives@7.61.0.json +30 -0
  642. package/dist/core/runner/image-removed-seat.d.ts +0 -12
  643. package/dist/core/runner/image-removed-seat.js +0 -19
@@ -1,13 +1,13 @@
1
1
  import { types } from "node:util";
2
- import { DECLARATION_PATH_RULES, NO_DECLARATION_PATH_RULES, declarationFaultOf, declarerWord, readToolAxes, receiveDeclaration, toolAxesRefusal } from "./mcp-server-spec.js";
2
+ import { DECLARATION_ENTRY_WORDS, DECLARATION_PATH_RULES, NO_DECLARATION_PATH_RULES, TOOL_AXIS_WORDS, callerText, declarationFaultOf, declarationPath, declarerWord, readToolAxes, receiveDeclaration, toolAxesRefusal, } from "./mcp-server-spec.js";
3
3
  import { isPlainRecord, receive } from "./mods/kernel/receive.js";
4
- import { readToolFaces } from "./tool-face-reader.js";
4
+ import { TOOL_FACE_WORDS, readToolFaces } from "./tool-face-reader.js";
5
5
  import { judgeSessionMetaKey } from "./mcp-call-meta.js";
6
- import { CONFIG_RECEIPT_MODE } from "./own-property-receipt.js";
6
+ import { CONFIG_RECEIPT_MODE, optionKeys, strayMembersOf } from "./own-property-receipt.js";
7
7
  import { isToolContentOrigin, TOOL_CONTENT_ORIGINS } from "./memory-engine/content-origin.js";
8
8
  import { inlineUntrusted } from "./untrusted-text.js";
9
9
  import { assertNoRetiredToolPolicyKeys } from "./retired-keys.js";
10
- import { CREDENTIALS_MEMBER, declaredCredentials, peerSeatMissing, retiredValueMember } from "./peer-seat.js";
10
+ import { CREDENTIALS_MEMBER, RETIRED_VALUE_MEMBERS, declaredCredentials, peerSeatMissing, retiredValueMember } from "./peer-seat.js";
11
11
  export const LOCKED_KEY_REGISTRY = {
12
12
  mcp: { specFields: ["mcp"] },
13
13
  a2a: { specFields: ["a2a"] },
@@ -29,7 +29,7 @@ export function resolveLockedKeys(config) {
29
29
  for (let index = 0; index < listed.length; index++) {
30
30
  const key = listed[index];
31
31
  if (!Object.hasOwn(LOCKED_KEY_REGISTRY, key)) {
32
- throw lockDeclarationRefusal(`RunnerDeps.lockedConfig.keys[${index}]`, `is ${inlineUntrusted(JSON.stringify(key), 80)}, which is not a member of the locked-key registry (${Object.keys(LOCKED_KEY_REGISTRY).join(", ")})`);
32
+ throw lockDeclarationRefusal(`RunnerDeps.lockedConfig.keys[${index}]`, `is ${callerText(key)}, which is not a member of the locked-key registry (${Object.keys(LOCKED_KEY_REGISTRY).join(", ")})`);
33
33
  }
34
34
  keys.add(key);
35
35
  }
@@ -38,13 +38,13 @@ export function resolveLockedKeys(config) {
38
38
  function declaredLockKeys(config) {
39
39
  const received = receiveDeclaration(config, NO_DECLARATION_PATH_RULES);
40
40
  if (!received.ok)
41
- throw lockDeclarationRefusal(memberPath(received.fault.path, "RunnerDeps.lockedConfig"), `cannot be read: ${received.fault.problem}`);
41
+ throw lockDeclarationRefusal(declarationPath(received.fault.path, LOCK_DECLARATION_WORDS, "RunnerDeps.lockedConfig"), `cannot be read: ${received.fault.problem}`);
42
42
  const copy = received.value;
43
43
  if (!isPlainRecord(copy))
44
- throw lockDeclarationRefusal("RunnerDeps.lockedConfig", `is ${inlineUntrusted(describeDeclared(copy), 80)}, not an object with a \`keys\` list`);
44
+ throw lockDeclarationRefusal("RunnerDeps.lockedConfig", `is ${callerText(copy)}, not an object with a \`keys\` list`);
45
45
  const keys = Object.hasOwn(copy, "keys") ? copy["keys"] : undefined;
46
46
  if (!Array.isArray(keys))
47
- throw lockDeclarationRefusal("RunnerDeps.lockedConfig.keys", `is ${inlineUntrusted(describeDeclared(keys), 80)}, not a list of locked keys`);
47
+ throw lockDeclarationRefusal("RunnerDeps.lockedConfig.keys", `is ${callerText(keys)}, not a list of locked keys`);
48
48
  return keys;
49
49
  }
50
50
  function lockDeclarationRefusal(member, problem) {
@@ -53,16 +53,8 @@ function lockDeclarationRefusal(member, problem) {
53
53
  export function snapshotMcpEntries(entries) {
54
54
  return entries.map((entry) => snapshotDeclaredEntry(entry, "mcp"));
55
55
  }
56
- function memberPath(path, base = "") {
57
- let rendered = base;
58
- for (const key of path) {
59
- const name = typeof key === "string" && /^\d+$/.test(key) ? JSON.stringify(key) : String(key);
60
- rendered += typeof key === "number" ? `[${key}]` : rendered === "" ? name : `.${name}`;
61
- if (rendered.length > 120 + base.length)
62
- break;
63
- }
64
- return rendered;
65
- }
56
+ const LOCK_DECLARATION_WORDS = new Set(["keys"]);
57
+ const ENTRY_PATH_WORDS = new Set([...DECLARATION_ENTRY_WORDS, ...TOOL_AXIS_WORDS, ...TOOL_FACE_WORDS, ...Object.values(RETIRED_VALUE_MEMBERS).flat(2)]);
66
58
  function unreadableDeclaration(at, declarer, member, problem) {
67
59
  const refusal = codedError("config.invalid_argument", `${declarerWord(at)}${declarer === undefined ? "" : ` ${declarerNameOf(declarer)}`} declares ${inlineUntrusted(member, 80)} the engine cannot read: ${problem}. A declaration the engine cannot read is refused ` +
68
60
  `rather than partly applied — what the caller wrote and what the engine runs on would otherwise differ without anyone being told.`);
@@ -82,7 +74,7 @@ function capturedName(entry) {
82
74
  return typeof entry === "object" && entry !== null && !types.isProxy(entry) ? ownDataString(entry, "name") : undefined;
83
75
  }
84
76
  function entryFaultRefusal(at, declarer, path, problem) {
85
- return unreadableDeclaration(at, declarer, path.length === 0 ? "an entry" : memberPath(path), problem);
77
+ return unreadableDeclaration(at, declarer, path.length === 0 ? "an entry" : declarationPath(path, ENTRY_PATH_WORDS), problem);
86
78
  }
87
79
  export function snapshotDeclaredEntry(entry, at) {
88
80
  const declared = entry;
@@ -91,7 +83,7 @@ export function snapshotDeclaredEntry(entry, at) {
91
83
  if (!received.ok)
92
84
  throw entryFaultRefusal(at, declarer, received.fault.path, received.fault.problem);
93
85
  if (!isPlainRecord(received.value))
94
- throw unreadableDeclaration(at, declarer, "an entry", `it is ${inlineUntrusted(describeDeclared(received.value), 80)}, not an object`);
86
+ throw unreadableDeclaration(at, declarer, "an entry", `it is ${callerText(received.value)}, not an object`);
95
87
  const retired = retiredValueMember(received.value, at);
96
88
  if (retired !== undefined) {
97
89
  throw declarationRefusal("config.credential_in_declaration", at, declarer, `declares ${retired.join(".")}, a member that carried values and is retired: a declaration names the peer and at most one opaque reference (${CREDENTIALS_MEMBER[at].join(".")}); the pieces a request carries are answered per send by the deployment's peer seat (RunnerDeps.peerSeat). The value is not repeated here.`);
@@ -116,20 +108,7 @@ function assertPeerSeatFor(entries, at, seat) {
116
108
  throw missing;
117
109
  }
118
110
  }
119
- function describeDeclared(value) {
120
- try {
121
- return JSON.stringify(value) ?? String(value);
122
- }
123
- catch {
124
- try {
125
- return String(value);
126
- }
127
- catch {
128
- return `[unrepresentable ${typeof value}]`;
129
- }
130
- }
131
- }
132
- const declarerNameOf = (name) => inlineUntrusted(typeof name === "string" ? JSON.stringify(name) : describeDeclared(name), 80);
111
+ const declarerNameOf = (name) => (typeof name === "string" ? inlineUntrusted(JSON.stringify(name), 80) : callerText(name));
133
112
  export function judgeEntryToolAxes(copy, at) {
134
113
  const { toolAxes: declaredAxes, ...rest } = copy;
135
114
  const axes = readToolAxes(declaredAxes, at);
@@ -150,8 +129,9 @@ function deepFrozen(value) {
150
129
  }
151
130
  return value;
152
131
  }
132
+ const FACES_PROBLEM_MAX = 400;
153
133
  function toolFacesRefusal(name, problem) {
154
- return codedError("config.tool_face_invalid", `${declarerWord("mcp")} ${name} declares toolFaces the engine cannot read: ${inlineUntrusted(problem, 240)}. A per-tool face declaration is the deployment's own ` +
134
+ return codedError("config.tool_face_invalid", `${declarerWord("mcp")} ${name} declares toolFaces the engine cannot read: ${inlineUntrusted(problem, FACES_PROBLEM_MAX)}. A per-tool face declaration is the deployment's own ` +
155
135
  `narrowing (which argument names a tool's path, how a write is confined, which approval card and rule vocabulary the tool wears), so it is refused ` +
156
136
  `rather than partly applied — a member dropped or a word defaulted would mount the tool without the protection its operator declared.`);
157
137
  }
@@ -170,12 +150,27 @@ export function judgeEntrySessionMetaKey(copy) {
170
150
  return { ok: true, entry: copy };
171
151
  return { ok: false, error: codedError("config.invalid_argument", `${declarerWord("mcp")} ${declarerNameOf(copy.name)} declares ${inlineUntrusted(read.problem, 200)}. The key decides where the leg's session id rides on this server's requests, so it is refused rather than dropped or defaulted — a connector keyed on a session it never receives would share one state across every session.`) };
172
152
  }
153
+ const HOST_TRANSPORT_KEYS = optionKeys()({ kind: 0 });
154
+ export function judgeEntryHostTransport(copy) {
155
+ const transport = copy.transport;
156
+ if (!isPlainRecord(transport) || transport["kind"] !== "host")
157
+ return { ok: true, entry: copy };
158
+ const stray = strayMembersOf(transport, { subject: "a host-supplied transport", unit: "member", moment: "when the entry is read" }, HOST_TRANSPORT_KEYS)?.names[0];
159
+ const extra = stray === undefined ? undefined : String(stray);
160
+ const problem = extra !== undefined
161
+ ? `a host-supplied transport with the member ${inlineUntrusted(JSON.stringify(extra), 80)}: a host transport carries its kind alone — the host seat carries what each request needs, so a member here would read as in force while nothing carries it`
162
+ : copy.elicitation === true
163
+ ? `elicitation on a host-supplied transport: the server behind a host's pipe is the host's own code, so a question it has for the user goes through the host's own interface — the engine advertises no elicitation for it`
164
+ : undefined;
165
+ return problem === undefined ? { ok: true, entry: copy } : { ok: false, error: codedError("config.invalid_argument", `${declarerWord("mcp")} ${declarerNameOf(copy.name)} declares ${problem}.`) };
166
+ }
173
167
  export function judgeMcpEntryDeclarations(copy) {
174
168
  const axes = judgeEntryToolAxes(copy, "mcp");
175
169
  const faces = axes.ok ? judgeEntryToolFaces(axes.entry) : axes;
176
- return faces.ok ? judgeEntrySessionMetaKey(faces.entry) : faces;
170
+ const metaKey = faces.ok ? judgeEntrySessionMetaKey(faces.entry) : faces;
171
+ return metaKey.ok ? judgeEntryHostTransport(metaKey.entry) : metaKey;
177
172
  }
178
- function declaredEntriesOf(declared, at) {
173
+ function declaredEntriesOf(declared, at, where) {
179
174
  const field = at;
180
175
  const received = receive(declared, CONFIG_RECEIPT_MODE);
181
176
  let problem;
@@ -183,7 +178,7 @@ function declaredEntriesOf(declared, at) {
183
178
  const list = received.value;
184
179
  if (Array.isArray(list) && list !== declared)
185
180
  return Array.from({ length: list.length }, (_, index) => list[index]);
186
- problem = typeof list === "object" && list !== null ? "it is not an array" : `it is ${inlineUntrusted(describeDeclared(list), 80)}`;
181
+ problem = typeof list === "object" && list !== null ? "it is not an array" : `it is ${callerText(list)}`;
187
182
  }
188
183
  else {
189
184
  const fault = declarationFaultOf(received.fault);
@@ -191,26 +186,65 @@ function declaredEntriesOf(declared, at) {
191
186
  throw unreadableDeclaration(at, undefined, "an entry", fault.problem);
192
187
  problem = fault.problem;
193
188
  }
194
- throw codedError("config.invalid_argument", `TaskSpec.${field} must be a readable array of ${declarerWord(at)} declarations; ${problem}. A list the engine cannot read ` +
189
+ throw codedError("config.invalid_argument", `${where ?? `TaskSpec.${field}`} must be a readable array of ${declarerWord(at)} declarations; ${problem}. A list the engine cannot read ` +
195
190
  `is refused rather than read as "no entries" — the declared ${declarerWord(at)}s would otherwise be dropped without anyone being told.`);
196
191
  }
197
- function snapshotAndValidateA2aEntries(declared) {
198
- const entries = declaredEntriesOf(declared, "a2a");
192
+ function validatedA2aEntries(entries) {
199
193
  if (entries.length === 0)
200
194
  return undefined;
201
195
  return entries.map((entry) => {
202
- const judged = judgeEntryToolAxes(snapshotDeclaredEntry(entry, "a2a"), "a2a");
196
+ const judged = judgeEntryToolAxes(received(entry), "a2a");
203
197
  if (!judged.ok)
204
198
  throw judged.error;
205
199
  return judged.entry;
206
200
  });
207
201
  }
208
- function snapshotAndValidateMcpEntries(declared) {
209
- return snapshotMcpEntries(declaredEntriesOf(declared, "mcp")).map((copy) => {
202
+ const receiving = (read) => {
203
+ try {
204
+ return { read: read() };
205
+ }
206
+ catch (refused) {
207
+ return { refused };
208
+ }
209
+ };
210
+ const received = (r) => {
211
+ if ("refused" in r)
212
+ throw r.refused;
213
+ return r.read;
214
+ };
215
+ export function receivePeerDeclarations(spec, deps) {
216
+ const locks = receiving(() => resolveLockedKeys(deps.lockedConfig));
217
+ if ("refused" in locks)
218
+ return { locks };
219
+ const list = (at) => {
220
+ if (locks.read.has(at))
221
+ return undefined;
222
+ const declared = receiving(() => spec[at]);
223
+ if ("refused" in declared)
224
+ return declared;
225
+ if (declared.read === undefined)
226
+ return undefined;
227
+ return receiving(() => declaredEntriesOf(declared.read, at).map((entry) => receiving(() => snapshotDeclaredEntry(entry, at))));
228
+ };
229
+ const mcp = list("mcp");
230
+ const a2a = list("a2a");
231
+ return { locks, ...(mcp !== undefined ? { mcp } : {}), ...(a2a !== undefined ? { a2a } : {}) };
232
+ }
233
+ export function receivedDeclarations(receipt) {
234
+ const copies = (r) => r === undefined || "refused" in r ? undefined : r.read.flatMap((entry) => ("read" in entry ? [entry.read] : []));
235
+ const mcp = copies(receipt.mcp);
236
+ const a2a = copies(receipt.a2a);
237
+ return { ...(mcp !== undefined ? { mcp } : {}), ...(a2a !== undefined ? { a2a } : {}) };
238
+ }
239
+ export function snapshotAndValidateMcpEntries(declared, where) {
240
+ return validatedMcpEntries(snapshotMcpEntries(declaredEntriesOf(declared, "mcp", where)));
241
+ }
242
+ function validatedMcpEntries(copies) {
243
+ return copies.map((copy) => {
210
244
  const declared = copy.contentOrigin;
211
245
  if (declared !== undefined && !isToolContentOrigin(declared)) {
212
246
  throw codedError("config.mcp_content_class", `MCP server ${declarerNameOf(copy.name)} declares contentOrigin ` +
213
- `${inlineUntrusted(describeDeclared(declared), 80)}, which is not one of ` +
247
+ `${callerText(declared)}, which is not one of ` +
214
248
  `${TOOL_CONTENT_ORIGINS.map((v) => `"${v}"`).join(" | ")}. The declaration decides whether this server's tools ` +
215
249
  `mark the session's memory externally exposed — a value this engine cannot read is refused at the door rather ` +
216
250
  `than folded to a class, because folding it would let a deployment believe a declaration is in force while every ` +
@@ -222,8 +256,9 @@ function snapshotAndValidateMcpEntries(declared) {
222
256
  return judged.entry;
223
257
  });
224
258
  }
225
- export function preflightLockedConfig(spec, deps, enter = ENTER_AS_IS) {
226
- const lockedKeys = enter("deps", () => resolveLockedKeys(deps.lockedConfig));
259
+ export function preflightLockedConfig(spec, deps, enter = ENTER_AS_IS, receipt) {
260
+ const peers = receipt ?? receivePeerDeclarations(spec, { lockedConfig: deps.lockedConfig });
261
+ const lockedKeys = enter("deps", () => received(peers.locks));
227
262
  enter("taskConfig", () => {
228
263
  for (const key of lockedKeys) {
229
264
  for (const field of LOCKED_KEY_REGISTRY[key].specFields) {
@@ -240,10 +275,8 @@ export function preflightLockedConfig(spec, deps, enter = ENTER_AS_IS) {
240
275
  const policies = callerPolicySeats(task, deps, toolPolicyLocked);
241
276
  enter(!toolPolicyLocked && task.toolPolicy != null ? "taskConfig" : "deps", () => assertNoRetiredToolPolicyKeys(policies.toolPolicy));
242
277
  enter(!toolPolicyLocked && task.basePolicyForResumeEdit != null ? "taskConfig" : "deps", () => assertNoRetiredToolPolicyKeys(policies.basePolicyForResumeEdit));
243
- const declaredServers = lockedKeys.has("mcp") ? undefined : spec.mcp;
244
- const mcp = declaredServers === undefined ? undefined : enter("taskConfig", () => snapshotAndValidateMcpEntries(declaredServers));
245
- const declaredPeers = lockedKeys.has("a2a") ? undefined : spec.a2a;
246
- const a2a = declaredPeers === undefined ? undefined : enter("taskConfig", () => snapshotAndValidateA2aEntries(declaredPeers));
278
+ const mcp = lockedKeys.has("mcp") || peers.mcp === undefined ? undefined : enter("taskConfig", () => validatedMcpEntries(received(peers.mcp).map(received)));
279
+ const a2a = lockedKeys.has("a2a") || peers.a2a === undefined ? undefined : enter("taskConfig", () => validatedA2aEntries(received(peers.a2a)));
247
280
  enter("taskConfig", () => {
248
281
  assertPeerSeatFor(mcp, "mcp", deps.peerSeat);
249
282
  assertPeerSeatFor(a2a, "a2a", deps.peerSeat);
@@ -2,7 +2,7 @@ import { type RootsSeat } from "../tools/fs/safety.js";
2
2
  import { type ReadDenyMatcher } from "../tools/fs/read-deny.js";
3
3
  import type { HomeViewsCarrier } from "../tools/fs/read-deny-home.js";
4
4
  import type { ContainmentFace } from "../tools/fs/containment-face.js";
5
- import type { AgentTool, BoundFileObject, ExecutionEnv } from "../internal/harness-types.js";
5
+ import type { AgentTool, BoundFileObject, ExecutionEnv, ReadFloor } from "../internal/harness-types.js";
6
6
  /**
7
7
  * LSP code-intelligence tool (design/64 §13.1) — the app-dev命门 (go-to-def / find-refs / hover across
8
8
  * Dart/Kotlin/TS). A single `lsp` tool with a 9-operation enum, built over a pluggable {@link LspServerManager}.
@@ -301,6 +301,8 @@ export interface LspToolOptions {
301
301
  export declare function createLspTool(manager: LspServerManager, opts?: LspToolOptions): AgentTool;
302
302
  /**
303
303
  * A git-check-ignore-based path filter for {@link LspToolOptions.isPathIgnored} (CC parity). Best-effort:
304
- * if git isn't available or the check fails, nothing is treated as ignored (keep all). Caches per path.
304
+ * if git isn't available or the check fails, nothing is treated as ignored (keep all). Caches per path. `readFloor` = the
305
+ * byte floor each check's start carries, read as it starts (a run's: the run's base table; absent ⇒ none — a caller with
306
+ * no run). A floor that cannot be read is a failed check.
305
307
  */
306
- export declare function gitCheckIgnoreFilter(env: ExecutionEnv, root: string): (uri: string) => Promise<boolean>;
308
+ export declare function gitCheckIgnoreFilter(env: ExecutionEnv, root: string, readFloor?: () => ReadFloor | undefined): (uri: string) => Promise<boolean>;
package/dist/core/lsp.js CHANGED
@@ -349,7 +349,7 @@ function toModelBase(result) {
349
349
  }
350
350
  return result;
351
351
  }
352
- export function gitCheckIgnoreFilter(env, root) {
352
+ export function gitCheckIgnoreFilter(env, root, readFloor) {
353
353
  const cache = new Map();
354
354
  return async (uri) => {
355
355
  const path = uriToPath(uri);
@@ -359,7 +359,8 @@ export function gitCheckIgnoreFilter(env, root) {
359
359
  let ignored = false;
360
360
  try {
361
361
  const q = `'${path.replace(/'/g, `'\\''`)}'`;
362
- const res = await env.exec(`git check-ignore ${q}`, { cwd: root, timeout: 10 });
362
+ const floor = readFloor?.();
363
+ const res = await env.exec(`git check-ignore ${q}`, { cwd: root, timeout: 10, ...(floor !== undefined ? { readFloor: floor } : {}) });
363
364
  ignored = res.ok && res.value.exitCode === 0;
364
365
  }
365
366
  catch {
@@ -199,8 +199,9 @@ export interface MailboxLease {
199
199
  export interface MailboxAppendMessage {
200
200
  /**
201
201
  * The record's identity, minted by its producer — a re-park of the same message carries the same
202
- * one. While the box HOLDS a record under this id, an append under it is that record: identical on
203
- * every {@link MAILBOX_REPLAY_FACETS} facet ⇒ the held `seq`, nothing written; any facet different ⇒
202
+ * one. While the box holds a record under this id, or has it in its received window
203
+ * ({@link MAILBOX_CONSUMED_ID_WINDOW}), an append under it is that record: identical on every
204
+ * {@link MAILBOX_REPLAY_FACETS} facet ⇒ that record's `seq`, nothing written; any facet different ⇒
204
205
  * refused with {@link MAILBOX_DUPLICATE_RECORD_ID_CODE}. Absent = the producer states no identity and
205
206
  * every append is a new record (its `seq` is all it is known by). Validated by {@link readMailboxRecordId}.
206
207
  */
@@ -215,7 +216,7 @@ export interface MailboxAppendMessage {
215
216
  }
216
217
  /** An `id` that is not a non-empty string of at most {@link MAILBOX_RECORD_ID_MAX_CHARS} characters. */
217
218
  export declare const MAILBOX_INVALID_RECORD_ID_CODE = "mailbox.invalid_record_id";
218
- /** An append under an `id` the box holds, whose record differs from the held one. */
219
+ /** An append under an `id` the box holds or has received, whose record differs from that one. */
219
220
  export declare const MAILBOX_DUPLICATE_RECORD_ID_CODE = "mailbox.duplicate_record_id";
220
221
  export declare const MAILBOX_RECORD_ID_MAX_CHARS = 1024;
221
222
  /**
@@ -224,6 +225,27 @@ export declare const MAILBOX_RECORD_ID_MAX_CHARS = 1024;
224
225
  */
225
226
  export declare const MAILBOX_REPLAY_FACETS: readonly ["from", "content", "hopChain", "peerMeta"];
226
227
  export type MailboxReplayFacet = (typeof MAILBOX_REPLAY_FACETS)[number];
228
+ /**
229
+ * How many id-bearing records a box remembers after consuming them — its RECEIVED WINDOW, kept at exactly this size by
230
+ * every backend (an out-of-repo backend imports the constant, never a copy of the number). An `ack` that deletes
231
+ * id-bearing records enters each one; the window keeps the newest by `seq`; a record with no id never takes a place.
232
+ * `drop` ends the window with the box's lifetime; `reap` keeps it, as it keeps the high-water mark (what it clears was
233
+ * never received).
234
+ */
235
+ export declare const MAILBOX_CONSUMED_ID_WINDOW = 256;
236
+ /** One record of a box's received window: the producer's id, the `seq` the record held, and its
237
+ * {@link mailboxReplayDigests} — what a later append under the id is judged against. */
238
+ export interface MailboxConsumedRecord {
239
+ readonly id: string;
240
+ readonly seq: number;
241
+ readonly digests: Readonly<Record<MailboxReplayFacet, string>>;
242
+ }
243
+ /** One digest per {@link MAILBOX_REPLAY_FACETS} facet (sha-256 of the facet's one spelling): the form a held record, a
244
+ * received one and an incoming append are compared in. */
245
+ export declare function mailboxReplayDigests(record: Partial<Pick<MailboxAppendMessage, MailboxReplayFacet>>): Record<MailboxReplayFacet, string>;
246
+ /** The received window once `removed` (the records an `ack` deleted) entered it — the one fold every bundled backend
247
+ * runs; the result holds the newest {@link MAILBOX_CONSUMED_ID_WINDOW} by `seq`. Module-level, not a root export. */
248
+ export declare function foldMailboxConsumed(window: readonly MailboxConsumedRecord[], removed: readonly MailboxMessage[]): MailboxConsumedRecord[];
227
249
  /** Validate a record id at `append`, before any side effect. `undefined` = no identity stated. */
228
250
  export declare function readMailboxRecordId(raw: unknown): string | undefined;
229
251
  /**
@@ -234,15 +256,20 @@ export declare function readMailboxRecordId(raw: unknown): string | undefined;
234
256
  export declare function readMailboxAppend(msg: MailboxAppendMessage): MailboxAppendMessage;
235
257
  /**
236
258
  * THE append-by-identity judgment, the one every backend runs inside its write critical section
237
- * (with `msg` already validated: `id` by {@link readMailboxRecordId}, `peerMeta` by {@link readMailboxPeerMeta}).
238
- * Returns the held record's `seq` when `msg` replays it (the caller writes nothing), `undefined` when the
239
- * box holds no record under `msg.id` (the caller appends), and throws {@link MAILBOX_DUPLICATE_RECORD_ID_CODE}
259
+ * (with `msg` already validated: `id` by {@link readMailboxRecordId}, `peerMeta` by {@link readMailboxPeerMeta}),
260
+ * over the box's two sets: the records it HOLDS and its received window ({@link MAILBOX_CONSUMED_ID_WINDOW}).
261
+ * Returns that record's `seq` when `msg` replays it (the caller writes nothing), `undefined` when neither set
262
+ * has a record under `msg.id` (the caller appends), and throws {@link MAILBOX_DUPLICATE_RECORD_ID_CODE}
240
263
  * naming the facets when a different record claims the id. A third-party backend calls this function too.
241
264
  */
242
- export declare function judgeMailboxAppendById(held: readonly MailboxMessage[], msg: MailboxAppendMessage): number | undefined;
265
+ export declare function judgeMailboxAppendById(box: {
266
+ readonly held: readonly MailboxMessage[];
267
+ readonly consumed: readonly MailboxConsumedRecord[];
268
+ }, msg: MailboxAppendMessage): number | undefined;
243
269
  /**
244
270
  * The pluggable mailbox seam (design/151 §7.1). Contract notes for implementations (file/pg):
245
- * - `append` is durable-first (a returned seq means the message survives a crash); seq is monotonic
271
+ * - `append` is durable-first (a returned seq means the box has taken the message: it survives a crash, still
272
+ * parked or — an id-bearing replay — already consumed inside the received window); seq is monotonic
246
273
  * per (scope, handle) and never reused WITHIN a box's lifetime (across lease/ack cycles the
247
274
  * high-water mark persists). `drop` ENDS the lifetime — a later rebuild restarts at 1 (server[1523]
248
275
  * 定谳: the row died with the box, dedup keys carry the handle, and a* handles are 64-bit-random).
@@ -281,7 +308,9 @@ export declare function judgeMailboxAppendById(held: readonly MailboxMessage[],
281
308
  * the box). A backend with NO view of that
282
309
  * lifecycle (the two bundled ones, the CC inbox adapter) has nothing to refuse and keeps accepting
283
310
  * — the clause fixes the SPELLING of the refusal, so a deployment reads one code instead of a
284
- * per-backend dialect. Acceptance kit: `mailboxTombstonedRecipientContract`.
311
+ * per-backend dialect. A backend that keeps the state writes it through its own
312
+ * `retireRecipient` and lists it through `listRetiredRecipients` (one optional pair); a backend
313
+ * without the pair has its box dropped instead. Acceptance kit: `mailboxTombstonedRecipientContract`.
285
314
  * - PEER METADATA (design/385, additive): `append` takes an optional typed `peerMeta`; a backend
286
315
  * persists it and hands it back on `claimLease` byte-for-byte (a detached copy), absent stays absent,
287
316
  * and a malformed value is REFUSED with `"mailbox.invalid_peer_meta"` before any side effect
@@ -293,7 +322,13 @@ export declare function judgeMailboxAppendById(held: readonly MailboxMessage[],
293
322
  * written), `"mailbox.duplicate_record_id"` for a different one — atomically with the seq allocation;
294
323
  * a malformed id is refused with `"mailbox.invalid_record_id"` before any side effect. This is what
295
324
  * makes re-asking a store whose reply was lost safe: a rejected append is not proof that nothing was
296
- * written. The box answers for what it HOLDS — once a record is acked its id is free again.
325
+ * written. The box answers for what it has RECEIVED, not only for what it holds: `ack` enters every
326
+ * id-bearing record it deletes into the box's received window — exactly the newest
327
+ * {@link MAILBOX_CONSUMED_ID_WINDOW} by seq, each kept as `{ id, seq, digests }`
328
+ * ({@link MailboxConsumedRecord}, {@link mailboxReplayDigests}) — persisted and shared like the
329
+ * high-water mark, and the same judgment answers from it: the consumed record's `seq` (nothing written),
330
+ * or the refusal. `drop` clears the window; `reap` keeps it. Acceptance: the window cases of
331
+ * `mailboxStoreContract` (T1) and `mailboxCrossProcessContract` (T2).
297
332
  * - CROSS-PROCESS SAFETY (design/385, optional capability declared on the store): the session-box
298
333
  * drain shares ONE box between several OS processes. A backend that is correct under that sharing —
299
334
  * seq minted once across processes, lease/ack never crossing, one process's housekeeping never
@@ -355,7 +390,45 @@ export interface MailboxStore {
355
390
  reap(scope: string, now: number, opts?: {
356
391
  maxAgeMs?: number;
357
392
  }): Promise<number>;
393
+ /**
394
+ * Put `(scope, handle)` into the PRE-DELETE state — the tombstone `append` refuses by
395
+ * (`"mailbox.recipient_tombstoned"`). Marks only: the messages already parked, their seqs and any live lease are
396
+ * untouched, so a deletion cascade retires the recipient first and drops the box after. Repeating it updates the
397
+ * tombstone's time and label. The tombstone lives as long as the box: `drop` removes both, so an id registered
398
+ * again later is a new recipient (there is no un-retire verb, and none is needed). `at` is the retirement time
399
+ * (epoch ms); `label` the recipient's name before it went, when it had one.
400
+ *
401
+ * `true` = a tombstone was written. `false` = none was, and the recipient is still refused: the store keeps no
402
+ * pre-delete state for this box and dropped it instead, or its key judge does not admit this handle (an `append`
403
+ * to it is refused by that judge's own sentence).
404
+ *
405
+ * Optional, and one capability with {@link listRetiredRecipients}: a store carries both or neither (read through
406
+ * {@link mailboxRecipientLifecycleOf}, which refuses half). Absent ⇒ the store has no view of its recipients'
407
+ * lifecycle; a deletion cascade drops the box. Acceptance kit: `mailboxTombstonedRecipientContract`.
408
+ */
409
+ retireRecipient?(scope: string, handle: string, at: number, label?: string): Promise<boolean>;
410
+ /** The tombstones under `scope` whose handle starts with `handlePrefix` — what a directory shows as a recipient
411
+ * being deleted. Optional, one capability with {@link retireRecipient}. */
412
+ listRetiredRecipients?(scope: string, handlePrefix: string): Promise<readonly MailboxRecipientTombstone[]>;
413
+ }
414
+ /** One retired recipient ({@link MailboxStore.listRetiredRecipients}). */
415
+ export interface MailboxRecipientTombstone {
416
+ /** The box handle (a session box is `session.<id>`). */
417
+ readonly handle: string;
418
+ /** When it was retired (epoch ms). */
419
+ readonly retiredAt: number;
420
+ /** Its name before it went; absent when it had none. */
421
+ readonly label?: string;
358
422
  }
423
+ /**
424
+ * The store's recipient-lifecycle pair, read as one capability: `undefined` when the store carries neither member;
425
+ * both, bound to the store, when it carries both; a refusal (`config.invalid_argument`) naming the missing one when
426
+ * it carries one — half the pair is not a smaller capability.
427
+ */
428
+ export declare function mailboxRecipientLifecycleOf(store: MailboxStore): Readonly<{
429
+ retireRecipient: NonNullable<MailboxStore["retireRecipient"]>;
430
+ listRetiredRecipients: NonNullable<MailboxStore["listRetiredRecipients"]>;
431
+ }> | undefined;
359
432
  /** The lane-mount verdict on a backend's cross-process declaration. */
360
433
  export type MailboxCrossProcessVerdict = {
361
434
  ok: true;
@@ -386,6 +459,8 @@ export declare function detachMailboxMessage(m: MailboxMessage): MailboxMessage;
386
459
  * {@link import("./background-agent-store.js").InMemoryBackgroundAgentStore}: not default-mounted,
387
460
  * detached copies at both boundaries, single-event-loop atomicity.
388
461
  */
462
+ /** The retention knobs a mailbox `reap` takes (an age sweep only: a box is cleared, never trimmed by count). */
463
+ export declare const MAILBOX_REAP_KNOBS: readonly ["maxAgeMs"];
389
464
  export declare class InMemoryMailboxStore implements MailboxStore {
390
465
  /** Process-local by construction (a Map): never a cross-process box, said so explicitly. */
391
466
  readonly crossProcessSafe = false;
@@ -1,4 +1,6 @@
1
- import { assertRetentionPolicy } from "./retention-policy.js";
1
+ import { createHash } from "node:crypto";
2
+ import { receiveRetentionPolicy } from "./retention-policy.js";
3
+ import { readMemberGroup } from "./member-group.js";
2
4
  export const MAILBOX_DECISIONS = Object.freeze(["held", "approved", "delivered", "denied", "expired", "refused", "dropped"]);
3
5
  export function readStoredMailboxDecision(raw) {
4
6
  if (raw === undefined)
@@ -154,6 +156,18 @@ export const MAILBOX_INVALID_RECORD_ID_CODE = "mailbox.invalid_record_id";
154
156
  export const MAILBOX_DUPLICATE_RECORD_ID_CODE = "mailbox.duplicate_record_id";
155
157
  export const MAILBOX_RECORD_ID_MAX_CHARS = 1024;
156
158
  export const MAILBOX_REPLAY_FACETS = Object.freeze(["from", "content", "hopChain", "peerMeta"]);
159
+ export const MAILBOX_CONSUMED_ID_WINDOW = 256;
160
+ export function mailboxReplayDigests(record) {
161
+ const out = {};
162
+ for (const f of MAILBOX_REPLAY_FACETS)
163
+ out[f] = createHash("sha256").update(facetSpelling(record[f])).digest("hex");
164
+ return out;
165
+ }
166
+ export function foldMailboxConsumed(window, removed) {
167
+ const entered = removed.flatMap((m) => (m.id !== undefined ? [{ id: m.id, seq: m.seq, digests: mailboxReplayDigests(m) }] : []));
168
+ const next = [...window, ...entered].sort((a, b) => a.seq - b.seq);
169
+ return next.length > MAILBOX_CONSUMED_ID_WINDOW ? next.slice(next.length - MAILBOX_CONSUMED_ID_WINDOW) : next;
170
+ }
157
171
  export function readMailboxRecordId(raw) {
158
172
  if (raw === undefined)
159
173
  return undefined;
@@ -187,16 +201,21 @@ function facetSpelling(v) {
187
201
  return `[${Array.from(v, facetSpelling).join(",")}]`;
188
202
  return `{${Object.keys(v).filter((k) => v[k] !== undefined).sort().map((k) => `${JSON.stringify(k)}:${facetSpelling(v[k])}`).join(",")}}`;
189
203
  }
190
- export function judgeMailboxAppendById(held, msg) {
204
+ export function judgeMailboxAppendById(box, msg) {
191
205
  if (msg.id === undefined)
192
206
  return undefined;
193
- const prior = held.find((m) => m.id === msg.id);
207
+ const holding = box.held.find((m) => m.id === msg.id);
208
+ const prior = holding !== undefined ? { seq: holding.seq, digests: mailboxReplayDigests(holding) } : box.consumed.find((c) => c.id === msg.id);
194
209
  if (prior === undefined)
195
210
  return undefined;
196
- const differs = MAILBOX_REPLAY_FACETS.filter((f) => facetSpelling(prior[f]) !== facetSpelling(msg[f]));
211
+ const asked = mailboxReplayDigests(msg);
212
+ const differs = MAILBOX_REPLAY_FACETS.filter((f) => prior.digests[f] !== asked[f]);
197
213
  if (differs.length === 0)
198
214
  return prior.seq;
199
- throw new MailboxStoreError(MAILBOX_DUPLICATE_RECORD_ID_CODE, `MailboxStore.append: the box already holds a different record under this id (it differs in: ${differs.join(", ")}) — a new message takes a new id; an identical repeat would have been a replay`);
215
+ throw new MailboxStoreError(MAILBOX_DUPLICATE_RECORD_ID_CODE, `MailboxStore.append: the box already ${holding !== undefined ? "holds" : "received"} a different record under this id (it differs in: ${differs.join(", ")}) — a new message takes a new id; an identical repeat would have been a replay`);
216
+ }
217
+ export function mailboxRecipientLifecycleOf(store) {
218
+ return readMemberGroup("MailboxStore", store, ["retireRecipient", "listRetiredRecipients"]);
200
219
  }
201
220
  export function mailboxCrossProcessMountVerdict(store) {
202
221
  const declared = store.crossProcessSafe;
@@ -226,6 +245,7 @@ export function detachMailboxMessage(m) {
226
245
  ...(m.peerMeta !== undefined ? { peerMeta: cloneMailboxPeerMeta(m.peerMeta) } : {}),
227
246
  };
228
247
  }
248
+ export const MAILBOX_REAP_KNOBS = Object.freeze(["maxAgeMs"]);
229
249
  export class InMemoryMailboxStore {
230
250
  crossProcessSafe = false;
231
251
  boxes = new Map();
@@ -239,7 +259,7 @@ export class InMemoryMailboxStore {
239
259
  const k = this.key(scope, handle);
240
260
  let b = this.boxes.get(k);
241
261
  if (!b) {
242
- b = { scope, messages: [], nextSeq: 1 };
262
+ b = { scope, messages: [], nextSeq: 1, consumed: [] };
243
263
  this.boxes.set(k, b);
244
264
  }
245
265
  return b;
@@ -249,7 +269,7 @@ export class InMemoryMailboxStore {
249
269
  throw new Error("MailboxStore.append: refusing a message without a scope");
250
270
  const record = readMailboxAppend(msg);
251
271
  const b = this.box(scope, handle);
252
- const held = judgeMailboxAppendById(b.messages, record);
272
+ const held = judgeMailboxAppendById({ held: b.messages, consumed: b.consumed }, record);
253
273
  if (held !== undefined)
254
274
  return held;
255
275
  const seq = b.nextSeq++;
@@ -272,6 +292,7 @@ export class InMemoryMailboxStore {
272
292
  return { acked: false };
273
293
  if (b.lease === undefined || b.lease.owner !== owner)
274
294
  return { acked: false };
295
+ b.consumed = foldMailboxConsumed(b.consumed, b.messages.filter((m) => m.seq <= upToSeq));
275
296
  b.messages = b.messages.filter((m) => m.seq > upToSeq);
276
297
  if (b.lease.maxSeq <= upToSeq)
277
298
  b.lease = undefined;
@@ -299,15 +320,15 @@ export class InMemoryMailboxStore {
299
320
  this.boxes.delete(this.key(scope, handle));
300
321
  }
301
322
  async reap(scope, now, opts) {
302
- assertRetentionPolicy("MailboxStore.reap", opts);
303
- if (opts?.maxAgeMs === undefined)
323
+ const policy = receiveRetentionPolicy("MailboxStore.reap", opts, MAILBOX_REAP_KNOBS);
324
+ if (policy.maxAgeMs === undefined)
304
325
  return 0;
305
326
  let dropped = 0;
306
327
  for (const b of this.boxes.values()) {
307
328
  if (b.scope !== scope)
308
329
  continue;
309
330
  const newest = newestSentAt(b.messages);
310
- if (newest !== undefined && newest < now - opts.maxAgeMs) {
331
+ if (newest !== undefined && newest < now - policy.maxAgeMs) {
311
332
  b.messages = [];
312
333
  b.lease = undefined;
313
334
  dropped++;
@@ -35,8 +35,8 @@ export type SessionMetaKeyReading = {
35
35
  * prefix of dot-separated labels and a slash, then a name — the format is what a conforming server accepts, and it keeps out names such
36
36
  * as `__proto__` that the SDK's own request parse drops) that names no `_meta` member of anyone else's: not the SDK's `progressToken`,
37
37
  * not a key under the engine's `sema/` namespace, not under a prefix MCP reserves (the prefix is the text before the first `/`; its
38
- * labels are DNS labels, so the second one is compared with case folded). Every refusal names the key; the key is the declaration's own
39
- * text, bounded in the sentence.
38
+ * labels are DNS labels, so the second one is compared with case folded). A refusal says which rule the key breaks and never the key: the
39
+ * key is the declaration's own text, shown in the one caller's-text shape (`callerText`: the redaction mark and its length).
40
40
  */
41
41
  export declare function judgeSessionMetaKey(value: unknown): SessionMetaKeyReading;
42
42
  /**
@@ -1,12 +1,11 @@
1
1
  import { AsyncLocalStorage } from "node:async_hooks";
2
2
  import { types } from "node:util";
3
3
  import { isPlainRecord } from "./mods/kernel/receive.js";
4
- import { dataKind } from "./mcp-server-spec.js";
4
+ import { callerText, dataKind } from "./mcp-server-spec.js";
5
5
  export const MCP_TOOL_USE_ID_META_KEY = "sema/toolUseId";
6
6
  export const MCP_REQUEST_META_KEY = "sema/requestMeta";
7
7
  export const MCP_REQUEST_META_MAX_BYTES = 262_144;
8
8
  const kindOf = (v) => v === null ? "null" : Array.isArray(v) ? "a list" : typeof v === "object" ? (types.isProxy(v) ? "a Proxy" : "an object that is not a plain record") : `a ${typeof v}`;
9
- const named = (key) => JSON.stringify(key.length > 60 ? `${key.slice(0, 60)}…` : key);
10
9
  export function judgeRequestMeta(value) {
11
10
  if (value === undefined)
12
11
  return { meta: undefined };
@@ -23,10 +22,10 @@ export function judgeRequestMeta(value) {
23
22
  for (const key of Object.getOwnPropertyNames(descriptors)) {
24
23
  const d = descriptors[key];
25
24
  if (!Object.hasOwn(d, "value") || d.enumerable !== true)
26
- return { problem: `requestMeta's member ${named(key)} is not an enumerable data property (a getter is never run)` };
25
+ return { problem: `requestMeta's member ${callerText(key)} is not an enumerable data property (a getter is never run)` };
27
26
  const v = d.value;
28
27
  if (typeof v !== "string")
29
- return { problem: `requestMeta's member ${named(key)} is ${kindOf(v)}, not a string` };
28
+ return { problem: `requestMeta's member ${callerText(key)} is ${kindOf(v)}, not a string` };
30
29
  bytes += Buffer.byteLength(key, "utf8") + Buffer.byteLength(v, "utf8");
31
30
  Object.defineProperty(copy, key, { value: v, enumerable: true, writable: false, configurable: false });
32
31
  members += 1;
@@ -57,20 +56,20 @@ export function judgeSessionMetaKey(value) {
57
56
  if (value === "")
58
57
  return { problem: "sessionMetaKey is the empty string; it takes a non-empty string" };
59
58
  if (value.length > MCP_SESSION_META_KEY_MAX_CHARS)
60
- return { problem: `sessionMetaKey ${named(value)} is ${value.length} characters; the most is ${MCP_SESSION_META_KEY_MAX_CHARS}` };
59
+ return { problem: `sessionMetaKey is ${value.length} characters; the most is ${MCP_SESSION_META_KEY_MAX_CHARS}` };
61
60
  const slash = value.indexOf("/");
62
61
  const labels = slash === -1 ? [] : value.slice(0, slash).split(".");
63
62
  if (!labels.every((label) => META_LABEL.test(label)))
64
- return { problem: `sessionMetaKey ${named(value)} has a prefix that is not dot-separated labels (a label starts with a letter, ends with a letter or digit, and holds letters, digits and hyphens) followed by a slash` };
63
+ return { problem: `sessionMetaKey ${callerText(value)} has a prefix that is not dot-separated labels (a label starts with a letter, ends with a letter or digit, and holds letters, digits and hyphens) followed by a slash` };
65
64
  if (!META_NAME.test(value.slice(slash + 1)))
66
- return { problem: `sessionMetaKey ${named(value)} has a name that does not begin and end with a letter or digit, or holds a character other than letters, digits, hyphen, underscore and dot` };
65
+ return { problem: `sessionMetaKey ${callerText(value)} has a name that does not begin and end with a letter or digit, or holds a character other than letters, digits, hyphen, underscore and dot` };
67
66
  if (value === SDK_PROGRESS_TOKEN_KEY)
68
- return { problem: `sessionMetaKey ${named(value)} is the key the MCP SDK writes for its own progress token` };
67
+ return { problem: `sessionMetaKey ${callerText(value)} is the key the MCP SDK writes for its own progress token` };
69
68
  if (value.startsWith(ENGINE_META_NAMESPACE))
70
- return { problem: `sessionMetaKey ${named(value)} is under the engine's own "${ENGINE_META_NAMESPACE}" namespace` };
69
+ return { problem: `sessionMetaKey ${callerText(value)} is under the engine's own "${ENGINE_META_NAMESPACE}" namespace` };
71
70
  const second = labels[1]?.toLowerCase();
72
71
  if (second !== undefined && MCP_RESERVED_LABELS.includes(second))
73
- return { problem: `sessionMetaKey ${named(value)} is under a prefix MCP reserves (second label "${second}")` };
72
+ return { problem: `sessionMetaKey ${callerText(value)} is under a prefix MCP reserves (second label "${second}")` };
74
73
  return { key: value };
75
74
  }
76
75
  export function mcpCallMeta(toolUseId, requestMeta, sessionMetaKey, sessionId) {