@sema-agent/core 7.59.0 → 7.60.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 (360) hide show
  1. package/CHANGELOG.md +564 -0
  2. package/dist/agents/agent-definition.d.ts +7 -0
  3. package/dist/agents/agent-definition.js +12 -0
  4. package/dist/agents/agent-transcript-tool.d.ts +2 -1
  5. package/dist/agents/agent-transcript-tool.js +3 -1
  6. package/dist/agents/child-model-seat.js +6 -3
  7. package/dist/agents/cumulative-stats.js +0 -1
  8. package/dist/agents/inherited-tool-pool.d.ts +26 -1
  9. package/dist/agents/inherited-tool-pool.js +22 -0
  10. package/dist/agents/retain-ledger.d.ts +11 -1
  11. package/dist/agents/retain-ledger.js +13 -2
  12. package/dist/agents/roster-store.d.ts +1 -1
  13. package/dist/agents/roster-store.js +3 -1
  14. package/dist/agents/send-message-tool.d.ts +8 -19
  15. package/dist/agents/send-message-tool.js +11 -38
  16. package/dist/agents/subagent.d.ts +51 -17
  17. package/dist/agents/subagent.js +117 -78
  18. package/dist/agents/tool-filter.d.ts +1 -3
  19. package/dist/agents/tool-filter.js +4 -12
  20. package/dist/bench/metrics.d.ts +3 -5
  21. package/dist/bench/metrics.js +0 -1
  22. package/dist/brain/degrading.js +3 -1
  23. package/dist/brain/route-adjudicator.js +3 -1
  24. package/dist/brain/status-sink.d.ts +7 -1
  25. package/dist/brain/status-sink.js +6 -0
  26. package/dist/brain/timeout.d.ts +3 -1
  27. package/dist/brain/timeout.js +18 -5
  28. package/dist/core/a2a.d.ts +15 -5
  29. package/dist/core/a2a.js +34 -19
  30. package/dist/core/agent-definition.d.ts +20 -0
  31. package/dist/core/allow-entry.d.ts +2 -0
  32. package/dist/core/allow-entry.js +3 -1
  33. package/dist/core/artifact-host.d.ts +0 -2
  34. package/dist/core/artifact-host.js +0 -1
  35. package/dist/core/auto-mode-defaults.d.ts +8 -0
  36. package/dist/core/auto-mode-defaults.js +1 -0
  37. package/dist/core/auto-mode-rebuild.d.ts +2 -1
  38. package/dist/core/auto-mode.d.ts +39 -4
  39. package/dist/core/auto-mode.js +63 -12
  40. package/dist/core/background-agent-store.d.ts +10 -1
  41. package/dist/core/background-agent-store.js +3 -2
  42. package/dist/core/background-shell.d.ts +12 -1
  43. package/dist/core/background-shell.js +12 -0
  44. package/dist/core/checkpoint-store.d.ts +8 -13
  45. package/dist/core/checkpoint-store.js +4 -3
  46. package/dist/core/compliance.d.ts +1 -1
  47. package/dist/core/credential-echo.d.ts +52 -0
  48. package/dist/core/credential-echo.js +65 -0
  49. package/dist/core/credential-vocabulary.d.ts +13 -3
  50. package/dist/core/credential-vocabulary.js +12 -4
  51. package/dist/core/cross-boundary-taint.d.ts +4 -5
  52. package/dist/core/engine-notice.d.ts +58 -15
  53. package/dist/core/frame-settlement.d.ts +5 -0
  54. package/dist/core/frame-settlement.js +4 -0
  55. package/dist/core/gate-fold.js +7 -5
  56. package/dist/core/gate-lanes.js +39 -8
  57. package/dist/core/governance-codes.d.ts +9 -1
  58. package/dist/core/governance-codes.js +12 -0
  59. package/dist/core/hands-band-screen.js +0 -1
  60. package/dist/core/hands-band.d.ts +0 -3
  61. package/dist/core/hooks.d.ts +39 -56
  62. package/dist/core/hooks.js +123 -77
  63. package/dist/core/image-admission.d.ts +104 -51
  64. package/dist/core/image-admission.js +170 -46
  65. package/dist/core/image-downsample.d.ts +36 -69
  66. package/dist/core/image-downsample.js +111 -73
  67. package/dist/core/integer-option.d.ts +21 -0
  68. package/dist/core/integer-option.js +13 -0
  69. package/dist/core/locked-config.d.ts +54 -3
  70. package/dist/core/locked-config.js +81 -50
  71. package/dist/core/mcp-call-meta.d.ts +2 -2
  72. package/dist/core/mcp-call-meta.js +9 -10
  73. package/dist/core/mcp-failure.d.ts +9 -3
  74. package/dist/core/mcp-failure.js +10 -0
  75. package/dist/core/mcp-host-seat.d.ts +92 -0
  76. package/dist/core/mcp-host-seat.js +131 -0
  77. package/dist/core/mcp-probe.d.ts +7 -2
  78. package/dist/core/mcp-probe.js +7 -2
  79. package/dist/core/mcp-server-spec.d.ts +38 -9
  80. package/dist/core/mcp-server-spec.js +55 -21
  81. package/dist/core/mcp.d.ts +17 -6
  82. package/dist/core/mcp.js +67 -55
  83. package/dist/core/memory-admission.d.ts +23 -6
  84. package/dist/core/memory-admission.js +19 -9
  85. package/dist/core/memory-engine/content-origin.d.ts +13 -0
  86. package/dist/core/memory-engine/content-origin.js +21 -3
  87. package/dist/core/memory-engine/index.d.ts +2 -1
  88. package/dist/core/memory-engine/index.js +2 -1
  89. package/dist/core/memory-engine/scope-contract.d.ts +13 -3
  90. package/dist/core/memory-engine/scope-contract.js +2 -2
  91. package/dist/core/memory-engine/sync-client.d.ts +45 -11
  92. package/dist/core/memory-engine/sync-client.js +82 -11
  93. package/dist/core/memory-engine/sync-report.d.ts +103 -0
  94. package/dist/core/memory-engine/sync-report.js +119 -0
  95. package/dist/core/memory-engine/sync.d.ts +4 -2
  96. package/dist/core/mode-policy.d.ts +9 -1
  97. package/dist/core/mode-policy.js +11 -1
  98. package/dist/core/model-receipt.d.ts +39 -0
  99. package/dist/core/model-receipt.js +139 -0
  100. package/dist/core/mods/agent-stations.d.ts +65 -0
  101. package/dist/core/mods/agent-stations.js +105 -0
  102. package/dist/core/mods/kernel/dispatch.d.ts +5 -1
  103. package/dist/core/mods/kernel/dispatch.js +4 -4
  104. package/dist/core/mods/kernel/events.d.ts +10 -4
  105. package/dist/core/mods/kernel/events.js +10 -6
  106. package/dist/core/mods/kernel/receive.d.ts +5 -0
  107. package/dist/core/mods/kernel/receive.js +10 -0
  108. package/dist/core/mods/lifecycle-stations.d.ts +41 -0
  109. package/dist/core/mods/lifecycle-stations.js +35 -0
  110. package/dist/core/mods/stations.d.ts +51 -59
  111. package/dist/core/mods/stations.js +32 -42
  112. package/dist/core/mods/tool-call.d.ts +10 -4
  113. package/dist/core/mods/tool-call.js +28 -12
  114. package/dist/core/mounted-mcp.d.ts +5 -0
  115. package/dist/core/mounted-mcp.js +2 -2
  116. package/dist/core/namespaced-rule-name.d.ts +7 -1
  117. package/dist/core/namespaced-rule-name.js +13 -2
  118. package/dist/core/oracle-isolation.js +1 -1
  119. package/dist/core/own-property-receipt.d.ts +3 -0
  120. package/dist/core/own-property-receipt.js +3 -0
  121. package/dist/core/park-selfcheck.js +8 -8
  122. package/dist/core/peer-seat.d.ts +63 -8
  123. package/dist/core/peer-seat.js +179 -34
  124. package/dist/core/permission-rule-consent.d.ts +0 -21
  125. package/dist/core/permission-rule-consent.js +1 -2
  126. package/dist/core/permission-rule-model.d.ts +4 -2
  127. package/dist/core/permission-rule-model.js +7 -6
  128. package/dist/core/protocol-http-auth.d.ts +14 -2
  129. package/dist/core/protocol-http-auth.js +16 -7
  130. package/dist/core/read-face-seats.d.ts +7 -5
  131. package/dist/core/read-face-seats.js +4 -1
  132. package/dist/core/redaction-marks.d.ts +4 -3
  133. package/dist/core/redaction-marks.js +2 -2
  134. package/dist/core/remote-env.d.ts +146 -98
  135. package/dist/core/remote-env.js +113 -14
  136. package/dist/core/retention.js +37 -12
  137. package/dist/core/retired-keys.d.ts +6 -1
  138. package/dist/core/retired-keys.js +4 -1
  139. package/dist/core/rewrite-rejudge.d.ts +12 -5
  140. package/dist/core/rewrite-rejudge.js +9 -5
  141. package/dist/core/roles.d.ts +37 -3
  142. package/dist/core/roles.js +126 -78
  143. package/dist/core/rule-owner.d.ts +3 -0
  144. package/dist/core/runner/assemble-result.d.ts +0 -5
  145. package/dist/core/runner/assemble-result.js +0 -1
  146. package/dist/core/runner/call-hook-stations.d.ts +17 -10
  147. package/dist/core/runner/call-hook-stations.js +21 -10
  148. package/dist/core/runner/child-tree.d.ts +7 -8
  149. package/dist/core/runner/child-tree.js +6 -6
  150. package/dist/core/runner/classifier-ladder.d.ts +10 -2
  151. package/dist/core/runner/classifier-ladder.js +39 -8
  152. package/dist/core/runner/construction-doors.js +5 -0
  153. package/dist/core/runner/contracts.d.ts +62 -41
  154. package/dist/core/runner/cross-boundary-lane.d.ts +3 -5
  155. package/dist/core/runner/cross-boundary-lane.js +11 -2
  156. package/dist/core/runner/env-capability-census.d.ts +15 -20
  157. package/dist/core/runner/env-capability-census.js +25 -34
  158. package/dist/core/runner/file-history-request.d.ts +2 -2
  159. package/dist/core/runner/file-history-request.js +0 -8
  160. package/dist/core/runner/gate-exit.d.ts +75 -7
  161. package/dist/core/runner/gate-exit.js +20 -1
  162. package/dist/core/runner/git-status-frame.d.ts +5 -2
  163. package/dist/core/runner/git-status-frame.js +3 -4
  164. package/dist/core/runner/image.d.ts +7 -2
  165. package/dist/core/runner/image.js +14 -8
  166. package/dist/core/runner/inline-image.d.ts +10 -8
  167. package/dist/core/runner/inline-image.js +11 -9
  168. package/dist/core/runner/memory-consolidation-driver.js +4 -4
  169. package/dist/core/runner/permission-rule-lanes.js +1 -1
  170. package/dist/core/runner/prepare-boundary-parks.d.ts +2 -2
  171. package/dist/core/runner/prepare-boundary-parks.js +3 -3
  172. package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -0
  173. package/dist/core/runner/prepare-caps-and-workflow.js +4 -3
  174. package/dist/core/runner/prepare-config-doors.d.ts +6 -1
  175. package/dist/core/runner/prepare-config-doors.js +14 -9
  176. package/dist/core/runner/prepare-delegation-surface.d.ts +5 -3
  177. package/dist/core/runner/prepare-delegation-surface.js +4 -4
  178. package/dist/core/runner/prepare-file-history.d.ts +10 -12
  179. package/dist/core/runner/prepare-file-history.js +3 -12
  180. package/dist/core/runner/prepare-gate-stations.d.ts +4 -3
  181. package/dist/core/runner/prepare-gate-stations.js +4 -3
  182. package/dist/core/runner/prepare-hands-readface.d.ts +3 -1
  183. package/dist/core/runner/prepare-hands-readface.js +15 -7
  184. package/dist/core/runner/prepare-inherited-gate.d.ts +5 -4
  185. package/dist/core/runner/prepare-inherited-gate.js +9 -5
  186. package/dist/core/runner/prepare-memory-engine-session.js +1 -1
  187. package/dist/core/runner/prepare-memory.d.ts +2 -2
  188. package/dist/core/runner/prepare-memory.js +2 -2
  189. package/dist/core/runner/prepare-park-ask.d.ts +3 -5
  190. package/dist/core/runner/prepare-park-ask.js +3 -8
  191. package/dist/core/runner/prepare-policy-chain.d.ts +5 -4
  192. package/dist/core/runner/prepare-policy-chain.js +120 -108
  193. package/dist/core/runner/prepare-project-context.js +8 -5
  194. package/dist/core/runner/prepare-prompt-inputs.d.ts +4 -1
  195. package/dist/core/runner/prepare-prompt-inputs.js +3 -2
  196. package/dist/core/runner/prepare-protocol-tools.d.ts +5 -3
  197. package/dist/core/runner/prepare-protocol-tools.js +9 -2
  198. package/dist/core/runner/prepare-suspend-saga.d.ts +0 -2
  199. package/dist/core/runner/prepare-suspend-saga.js +5 -7
  200. package/dist/core/runner/prepare-task.js +41 -27
  201. package/dist/core/runner/prepare-turn-wiring.d.ts +2 -0
  202. package/dist/core/runner/prepare-turn-wiring.js +7 -2
  203. package/dist/core/runner/prepare-wiring-manifest.d.ts +4 -3
  204. package/dist/core/runner/prepare-wiring-manifest.js +32 -18
  205. package/dist/core/runner/prepare-workspace-restore.js +3 -3
  206. package/dist/core/runner/resume-checkpoint-screen.js +4 -4
  207. package/dist/core/runner/retired-runner-deps.js +4 -1
  208. package/dist/core/runner/run-attachment-seats.js +3 -3
  209. package/dist/core/runner/run-brain-sinks.js +1 -0
  210. package/dist/core/runner/run-git-lane.d.ts +3 -1
  211. package/dist/core/runner/run-git-lane.js +1 -1
  212. package/dist/core/runner/run-harness-handlers.d.ts +3 -1
  213. package/dist/core/runner/run-harness-handlers.js +3 -1
  214. package/dist/core/runner/run-identity-wiring.js +1 -1
  215. package/dist/core/runner/run-leg.js +26 -28
  216. package/dist/core/runner/run-notification-lane.d.ts +3 -1
  217. package/dist/core/runner/run-notification-lane.js +16 -10
  218. package/dist/core/runner/run-settle-and-teardown.js +5 -1
  219. package/dist/core/runner/run-stop-and-final-verify.d.ts +4 -0
  220. package/dist/core/runner/run-stop-and-final-verify.js +12 -4
  221. package/dist/core/runner/run-turn-boundary.js +12 -7
  222. package/dist/core/runner/runtask.d.ts +7 -4
  223. package/dist/core/runner/runtask.js +19 -11
  224. package/dist/core/runner/skills-seat.js +2 -2
  225. package/dist/core/runner/sub-agent-deny-lists.js +10 -7
  226. package/dist/core/runner/synthetic-tools.js +2 -2
  227. package/dist/core/runner/tool-disclosure.js +0 -2
  228. package/dist/core/runner/tool-face-overlay.d.ts +1 -1
  229. package/dist/core/runner/tool-face-overlay.js +26 -19
  230. package/dist/core/runner/tool-result-media-seat.d.ts +9 -1
  231. package/dist/core/runner/tool-result-media-seat.js +17 -1
  232. package/dist/core/runner/turn-attachments.d.ts +3 -5
  233. package/dist/core/runner/turn-attachments.js +3 -16
  234. package/dist/core/runner-deps.d.ts +31 -18
  235. package/dist/core/secret-env.d.ts +3 -2
  236. package/dist/core/session-policy-store.d.ts +9 -2
  237. package/dist/core/session-policy-store.js +16 -1
  238. package/dist/core/session-store.d.ts +3 -2
  239. package/dist/core/session-store.js +50 -11
  240. package/dist/core/skill-grant.d.ts +9 -0
  241. package/dist/core/skill-grant.js +18 -0
  242. package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
  243. package/dist/core/store-contracts/tool-result-store-contract.js +37 -0
  244. package/dist/core/stub-env.d.ts +5 -5
  245. package/dist/core/stub-env.js +11 -1
  246. package/dist/core/swappable-deps.d.ts +17 -43
  247. package/dist/core/swappable-deps.js +15 -5
  248. package/dist/core/synthetic-read-verdict.d.ts +1 -1
  249. package/dist/core/task-event.d.ts +18 -2
  250. package/dist/core/task-notification.d.ts +88 -5
  251. package/dist/core/task-notification.js +130 -7
  252. package/dist/core/task-registry-agent.d.ts +18 -12
  253. package/dist/core/task-registry-agent.js +18 -6
  254. package/dist/core/task-registry-monitor.d.ts +7 -0
  255. package/dist/core/task-registry-monitor.js +28 -1
  256. package/dist/core/task-registry-shared.d.ts +38 -3
  257. package/dist/core/task-registry-shared.js +21 -7
  258. package/dist/core/task-registry-workflow.js +1 -1
  259. package/dist/core/task-registry.d.ts +50 -35
  260. package/dist/core/task-registry.js +64 -23
  261. package/dist/core/task-result.d.ts +3 -12
  262. package/dist/core/task-spec.d.ts +3 -6
  263. package/dist/core/task-stream.d.ts +1 -1
  264. package/dist/core/tool-catalog-entries.js +1 -1
  265. package/dist/core/tool-face-reader.d.ts +7 -6
  266. package/dist/core/tool-face-reader.js +4 -3
  267. package/dist/core/tool-name-aliases.d.ts +19 -0
  268. package/dist/core/tool-name-aliases.js +54 -2
  269. package/dist/core/tool-policy.d.ts +5 -4
  270. package/dist/core/tool-policy.js +1 -1
  271. package/dist/core/tool-registry.d.ts +5 -5
  272. package/dist/core/tool-registry.js +2 -2
  273. package/dist/core/tool-result-store.d.ts +88 -5
  274. package/dist/core/tool-result-store.js +51 -12
  275. package/dist/core/tool-spec.d.ts +20 -4
  276. package/dist/core/trace.d.ts +0 -1
  277. package/dist/core/types.d.ts +3 -3
  278. package/dist/core/types.js +1 -1
  279. package/dist/core/untrusted-text.js +1 -1
  280. package/dist/core/user-attachment.d.ts +10 -5
  281. package/dist/core/user-attachment.js +14 -6
  282. package/dist/engine/execution-env/node-execution-env.d.ts +7 -2
  283. package/dist/engine/execution-env/node-execution-env.js +12 -1
  284. package/dist/engine/harness/agent-harness.d.ts +1 -1
  285. package/dist/engine/harness/agent-harness.js +8 -4
  286. package/dist/engine/harness/types.d.ts +112 -29
  287. package/dist/engine/loop/agent-loop.d.ts +12 -12
  288. package/dist/engine/loop/agent-loop.js +153 -21
  289. package/dist/engine/loop/types.d.ts +9 -2
  290. package/dist/engine/lsp/node-lsp-manager.d.ts +3 -3
  291. package/dist/engine/lsp/node-lsp-manager.js +32 -13
  292. package/dist/index.d.ts +22 -14
  293. package/dist/index.js +15 -10
  294. package/dist/internal/harness-types.d.ts +1 -1
  295. package/dist/orchestration/run-workflow-tool.d.ts +9 -3
  296. package/dist/orchestration/run-workflow-tool.js +59 -29
  297. package/dist/orchestration/workflow-governance.d.ts +1 -1
  298. package/dist/orchestration/workflow-governance.js +2 -1
  299. package/dist/orchestration/workflow.d.ts +4 -0
  300. package/dist/orchestration/workflow.js +25 -4
  301. package/dist/prompts/default.d.ts +1 -10
  302. package/dist/prompts/default.js +0 -2
  303. package/dist/stores/file/background-agent-store.d.ts +1 -1
  304. package/dist/stores/file/background-agent-store.js +3 -1
  305. package/dist/stores/file/checkpoint-store.d.ts +127 -2
  306. package/dist/stores/file/checkpoint-store.js +19 -14
  307. package/dist/stores/file/file-history-store.d.ts +1 -1
  308. package/dist/stores/file/file-history-store.js +3 -1
  309. package/dist/stores/file/index.d.ts +4 -3
  310. package/dist/stores/file/index.js +17 -8
  311. package/dist/stores/file/mailbox-store.d.ts +1 -1
  312. package/dist/stores/file/mailbox-store.js +3 -1
  313. package/dist/stores/file/memory-store.d.ts +1 -1
  314. package/dist/stores/file/memory-store.js +3 -1
  315. package/dist/stores/file/session-policy-store.d.ts +1 -1
  316. package/dist/stores/file/session-policy-store.js +3 -1
  317. package/dist/stores/file/session-store.d.ts +1 -1
  318. package/dist/stores/file/session-store.js +3 -1
  319. package/dist/stores/file/shared-ledger.d.ts +26 -0
  320. package/dist/stores/file/shared-ledger.js +38 -9
  321. package/dist/stores/file/tool-result-store.d.ts +20 -2
  322. package/dist/stores/file/tool-result-store.js +74 -6
  323. package/dist/stores/file/usage-window-store.d.ts +1 -1
  324. package/dist/stores/file/usage-window-store.js +3 -1
  325. package/dist/stores/file/workflow-journal-store.d.ts +1 -11
  326. package/dist/stores/file/workflow-journal-store.js +3 -2
  327. package/dist/tools/fs/containment-face.d.ts +5 -0
  328. package/dist/tools/fs/encoding.d.ts +13 -4
  329. package/dist/tools/fs/encoding.js +17 -2
  330. package/dist/tools/fs/fs-bash-background-text.d.ts +7 -0
  331. package/dist/tools/fs/fs-bash-background-text.js +1 -0
  332. package/dist/tools/fs/fs-bash.d.ts +8 -4
  333. package/dist/tools/fs/fs-bash.js +26 -35
  334. package/dist/tools/fs/fs-pdf.d.ts +2 -2
  335. package/dist/tools/fs/fs-pdf.js +26 -21
  336. package/dist/tools/fs/fs-read.d.ts +5 -4
  337. package/dist/tools/fs/fs-read.js +35 -18
  338. package/dist/tools/fs/fs-search-tools.js +4 -1
  339. package/dist/tools/fs/fs-shared.d.ts +11 -13
  340. package/dist/tools/fs/fs-shared.js +11 -7
  341. package/dist/tools/fs/fs-write.js +5 -5
  342. package/dist/tools/fs/index.d.ts +14 -8
  343. package/dist/tools/fs/index.js +8 -4
  344. package/dist/tools/fs/read-floor.d.ts +44 -1
  345. package/dist/tools/fs/read-floor.js +35 -0
  346. package/dist/tools/fs/removal-targets.d.ts +9 -4
  347. package/dist/tools/fs/removal-targets.js +17 -9
  348. package/dist/tools/fs/search.d.ts +3 -3
  349. package/dist/tools/fs/search.js +4 -4
  350. package/dist/tools/monitor.d.ts +5 -4
  351. package/dist/tools/monitor.js +15 -8
  352. package/dist/tools/scheduler-tools.js +42 -4
  353. package/dist/tools/web.d.ts +0 -10
  354. package/dist/tools/web.js +1 -4
  355. package/package.json +4 -2
  356. package/test/export-surface.snapshot.json +75 -21
  357. package/wire-changes/core-stores-sql@7.60.0.json +30 -0
  358. package/wire-changes/core@7.60.0.json +3274 -0
  359. package/wire-changes/mods-kernel@7.60.0.json +62 -0
  360. package/wire-changes/primitives@7.60.0.json +30 -0
@@ -219,10 +219,11 @@ export async function probeParkRoundTrip(deps, spec = {}) {
219
219
  return await failed("row_not_faithful", delta);
220
220
  if (status !== "pending")
221
221
  return await failed("row_not_pending", `the filed row came back with status ${shown(status)} — a park in any other status is one nobody can resolve`);
222
- const enumerable = store.listByScope !== undefined;
223
- if (store.listByScope !== undefined) {
224
- const listByScope = store.listByScope.bind(store);
225
- const listed = await within(() => listByScope(scope), "listByScope");
222
+ {
223
+ const listByScope = store.listByScope;
224
+ if (typeof listByScope !== "function")
225
+ return await failed("row_not_enumerable", "the store implements no listByScope — an inbox enumerating this scope reads nothing");
226
+ const listed = await within(() => listByScope.call(store, scope), "listByScope");
226
227
  if ("timedOut" in listed)
227
228
  return await failed("row_not_enumerable", listed.timedOut);
228
229
  if ("threw" in listed)
@@ -265,8 +266,7 @@ export async function probeParkRoundTrip(deps, spec = {}) {
265
266
  : `expire lost an UNCONTENDED CAS and the row reads ${shown(afterStatus)} — the fence that keeps a checkpoint from being both reaped and resumed does not close here`);
266
267
  }
267
268
  }
268
- const steps = `filed, read back${enumerable ? ", enumerated" : ""} and fenced`;
269
- const notExercised = enumerable ? "" : " (this store implements no listByScope, so the inbox enumeration was NOT exercised)";
269
+ const steps = "filed, read back, enumerated and fenced";
270
270
  const casNote = fenced ? "" : " (the expire CAS reported a loss while the row closed — consistent with store housekeeping, but a backend that mis-reports CAS wins is not distinguished here)";
271
271
  return {
272
272
  verdict: "round_trip_ok",
@@ -274,8 +274,8 @@ export async function probeParkRoundTrip(deps, spec = {}) {
274
274
  ...(fenced ? {} : { casLossObserved: true }),
275
275
  scope,
276
276
  summary: after === null
277
- ? `the park lane ${steps} a synthetic checkpoint${notExercised} — the row is no longer present (a deleting backend or its own housekeeping removed it), so nothing resumable remains${casNote}`
278
- : `the park lane ${steps} a synthetic checkpoint${notExercised} — residual expired row in scope "${scope}"${casNote}`,
277
+ ? `the park lane ${steps} a synthetic checkpoint — the row is no longer present (a deleting backend or its own housekeeping removed it), so nothing resumable remains${casNote}`
278
+ : `the park lane ${steps} a synthetic checkpoint — residual expired row in scope "${scope}"${casNote}`,
279
279
  ...gapCell,
280
280
  };
281
281
  }
@@ -1,6 +1,6 @@
1
1
  import { StreamableHTTPError } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
2
2
  import { type CredentialRef } from "@sema-agent/primitives";
3
- import type { McpServerSpec } from "./mcp-server-spec.js";
3
+ import { type McpServerSpec, type McpTransportKind } from "./mcp-server-spec.js";
4
4
  import type { ProtocolId } from "./protocol-table.js";
5
5
  /** Why the seat is asked: the first send of a connection, any later send, or the send after a 401. */
6
6
  export type PeerAskCause = "connect" | "request" | "rejected";
@@ -40,7 +40,7 @@ export interface PeerQuestion {
40
40
  }
41
41
  /**
42
42
  * The seat's answer: the pieces to carry (`headers` for an http request and an A2A send, `env` for a stdio child — the member of the
43
- * other lane is refused; `expiresAt`, epoch ms, is read by a stdio child only), or that the principal is not authorized here.
43
+ * other lane is refused; `expiresAt`, a non-negative epoch-millisecond number, is read by a stdio child only; a header value is held to the HTTP request grammar and an env value to what a spawn hands the child unchanged), or that the principal is not authorized here.
44
44
  */
45
45
  export type PeerAnswer = {
46
46
  readonly kind: "carry";
@@ -52,10 +52,26 @@ export type PeerAnswer = {
52
52
  readonly authorizeUrl?: string;
53
53
  };
54
54
  /**
55
- * The deployment's peer seat (`RunnerDeps.peerSeat`, TRUSTED). It owes the binding the engine cannot judge: answer only for the
56
- * reference, principal, protocol and destination (or start command) it was asked about — never one token for every peer.
55
+ * The deployment's peer seat (`RunnerDeps.peerSeat`, TRUSTED): one object, three members, all required.
56
+ * · `answer` — what one send carries. It owes the binding the engine cannot judge: answer only for the reference, principal,
57
+ * protocol and destination (or start command) it was asked about — never one token for every peer.
58
+ * · `hold` / `release` — an engine object started / stopped keeping a declaration that names `ref` (see the module note): called
59
+ * once each per keeper and distinct reference, `release` only for a `hold` that succeeded (it returned, or the promise it returned
60
+ * fulfilled — a release due before then is sent then); the reference is a frozen copy, never a value, never a session. A seat that
61
+ * keeps no state per reference makes both no-ops. A throw or a rejection is reported (`onError`, phase `config`) and changes
62
+ * nothing else: a `hold` that failed is not held and gets no `release`.
57
63
  */
58
- export type PeerSeat = (question: PeerQuestion, signal: AbortSignal) => Promise<PeerAnswer>;
64
+ export interface PeerSeat {
65
+ answer(question: PeerQuestion, signal: AbortSignal): Promise<PeerAnswer>;
66
+ hold(ref: CredentialRef): void;
67
+ release(ref: CredentialRef): void;
68
+ }
69
+ /**
70
+ * The one reader of a peer seat handed to the engine (`new Runner`, the three library entrances): absent ⇒ `undefined`; else an
71
+ * object whose three members are functions, each read once and kept bound to that object in a frozen copy — or refused
72
+ * (`config.invalid_argument`) naming what does not fit. A function is the form before 7.60.0: refused with the form that replaced it.
73
+ */
74
+ export declare function receivePeerSeat(raw: unknown, subject: string): PeerSeat | undefined;
59
75
  /** Which answer member each transport carries. */
60
76
  export declare const PEER_ANSWER_LANES: Readonly<{
61
77
  readonly http: "headers";
@@ -140,7 +156,9 @@ export interface CarriedPieces {
140
156
  readonly expiresAt?: number;
141
157
  readonly digest: string;
142
158
  }
143
- /** The seat's answer for `lane`, read once: the pieces, the `unauthorized` answer, or the problem (which member did not fit). */
159
+ /** The seat's answer for `lane`, read once: the pieces, the `unauthorized` answer, or the problem (which member did not fit). The
160
+ * answer's members are its OWN members (a member its prototype would supply is not read), and each value is judged by the grammar of
161
+ * the send that will carry it ({@link VALUE_LAW}). */
144
162
  export declare function readPeerAnswer(raw: unknown, lane: PeerLane): {
145
163
  readonly carry: CarriedPieces;
146
164
  } | {
@@ -150,6 +168,24 @@ export declare function readPeerAnswer(raw: unknown, lane: PeerLane): {
150
168
  } | {
151
169
  readonly problem: string;
152
170
  };
171
+ /** Declarations as a keeper holds them: a spec's (or a spec snapshot's) `mcp` and `a2a` lists, read as given. */
172
+ export interface PeerDeclarations {
173
+ readonly mcp?: unknown;
174
+ readonly a2a?: unknown;
175
+ }
176
+ /** One keeper's hold on the references its declarations name (see the module note), taken when it is made. */
177
+ export interface PeerDeclarationHold {
178
+ /** Release every reference this keeper holds, each once. A second call does nothing. */
179
+ release(): void;
180
+ }
181
+ /**
182
+ * A keeper's hold: `seat.hold` once for each distinct reference (by its canonical form) `declared` names, now, and one `seat.release`
183
+ * for each hold that succeeded, at `release`. A hold succeeds when it returns — or, when it returns a promise, when that promise
184
+ * fulfils (a release asked for before then is sent then). No seat ⇒ nothing is held (a declared reference is refused at the door). A
185
+ * seat member that throws or whose promise rejects reaches `onFault` as the engine's own sentence (the seat's error is not repeated:
186
+ * deployment code may put a value in it); a hold that failed is not held and gets no release.
187
+ */
188
+ export declare function holdPeerDeclarations(seat: PeerSeat | undefined, declared: PeerDeclarations, onFault: (err: Error) => void): PeerDeclarationHold;
153
189
  /** What the re-ask after a 401 said: whether it answered other pieces than the refused send carried, and the seat's `authorizeUrl` when it answered `unauthorized`. */
154
190
  export interface PeerReask {
155
191
  readonly renewed: boolean;
@@ -167,13 +203,17 @@ export declare class PeerCarrier {
167
203
  private readonly principal;
168
204
  private readonly lane;
169
205
  readonly sent: string[];
206
+ /** Every credential value the seat's answers handed this connection, accepted or refused ({@link answeredCredentialValues}), that the
207
+ * withheld table holds (one that names a secret, `namesASecret`: never a blank one, a placeholder or a short dev key) — the needle a
208
+ * remote's account of itself is read without. */
209
+ readonly credentials: string[];
170
210
  /** When the pieces a stdio child was started with stop being good; `undefined` when the answer said nothing. */
171
211
  expiresAt: number | undefined;
172
212
  renewed: boolean;
173
213
  private asked;
174
214
  private waiting;
175
215
  private rejection;
176
- constructor(seat: PeerSeat | undefined, identity: PeerSeatTarget, principal: string | undefined, lane: PeerLane, principalSent: boolean);
216
+ constructor(seat: PeerSeat | undefined, identity: PeerCarrierIdentity, principal: string | undefined, lane: PeerLane, principalSent: boolean);
177
217
  /** The peer as the refusal sentences name it. */
178
218
  get label(): string;
179
219
  /** The pieces the next send carries (see the class note). A seat failure throws {@link PeerSeatFailure}. */
@@ -188,6 +228,14 @@ export declare class PeerCarrier {
188
228
  /** Whether the pieces a stdio child was started with have stopped being good. */
189
229
  expired(now?: number): boolean;
190
230
  private ask;
231
+ /**
232
+ * THE one intake of a seat's answer: every credential value it hands ({@link answeredCredentialValues}) is a value the engine now
233
+ * holds — no child spawned on this host inherits a variable holding it — and a credential of this connection's sends
234
+ * ({@link PeerCarrier.credentials}). Asked of the answer as given, before it is judged, and of the judge's copy of an accepted answer
235
+ * (the pieces that are sent). Each value is held on its own, so one that cannot be withheld (the value of a variable every child is
236
+ * handed) does not keep the others out; the answer is then refused, after the rest were held.
237
+ */
238
+ private holdAnswered;
191
239
  private remember;
192
240
  }
193
241
  /**
@@ -226,8 +274,15 @@ export declare function declaredCredentials(copy: object, at: keyof typeof CREDE
226
274
  export declare function peerSeatMissing(subject: string, credentials: CredentialRef | undefined, seat: PeerSeat | undefined): (Error & {
227
275
  code: string;
228
276
  }) | undefined;
277
+ /** A carrier's identity: the peer the seat is asked about, or a server on a host-supplied transport — whose host seat carries its own
278
+ * pieces, so the peer seat is never asked about it (its carrier carries nothing). */
279
+ export type PeerCarrierIdentity = PeerSeatTarget | {
280
+ readonly protocol: "mcp";
281
+ readonly server: string;
282
+ readonly transport: "host";
283
+ };
229
284
  /** Who an MCP server is, as the seat is asked about it: its name, the whole start command or endpoint, its reference, its mount identity. */
230
- export declare function mcpPeerTarget(spec: McpServerSpec, kind: "stdio" | "http" | undefined): PeerSeatTarget;
285
+ export declare function mcpPeerTarget(spec: McpServerSpec, kind: McpTransportKind | undefined): PeerCarrierIdentity;
231
286
  /** Whether a failure is the HTTP endpoint answering 401 (the SDK's status error, on the thrown value or its cause chain). Structure only. */
232
287
  export declare function answeredUnauthorized(err: unknown): boolean;
233
288
  /** A call answered 401 after which the seat's re-ask answered other pieces: its failure as it would have been thrown then. */
@@ -1,10 +1,41 @@
1
1
  import { createHash } from "node:crypto";
2
+ import { types } from "node:util";
2
3
  import { StreamableHTTPError } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
4
+ import { canonicalize } from "./canonical-json.js";
3
5
  import { readCredentialRef } from "@sema-agent/primitives";
4
- import { readMember } from "./thrown-value.js";
5
- import { resolveProtocolHttpHeaders } from "./protocol-http-auth.js";
6
- import { holdOwnCredentialValues, isSecretEnvKey } from "./secret-env.js";
6
+ import { callerText } from "./mcp-server-spec.js";
7
+ import { readMember, readOwnMembers } from "./thrown-value.js";
8
+ import { httpTrimmed, resolveProtocolHttpHeaders } from "./protocol-http-auth.js";
9
+ import { credentialHeaderValues, holdOwnCredentialValues, isSecretEnvKey, namesASecret } from "./secret-env.js";
7
10
  import { inlineUntrusted } from "./untrusted-text.js";
11
+ const PEER_SEAT_MEMBERS = Object.freeze(["answer", "hold", "release"]);
12
+ export function receivePeerSeat(raw, subject) {
13
+ if (raw === undefined)
14
+ return undefined;
15
+ const refuse = (problem) => Object.assign(new Error(`${subject} ${problem} — the peer seat is an object { answer(question, signal), hold(ref), release(ref) }`), { code: "config.invalid_argument" });
16
+ if (typeof raw === "function")
17
+ throw refuse("is a function (the answer alone): put it under `answer` and add `hold` / `release`");
18
+ if (typeof raw !== "object" || raw === null || types.isProxy(raw))
19
+ throw refuse(raw === null ? "is null" : typeof raw !== "object" ? `is a ${typeof raw}` : "is a Proxy");
20
+ const read = Object.create(null);
21
+ for (const name of PEER_SEAT_MEMBERS) {
22
+ let member;
23
+ try {
24
+ member = Reflect.get(raw, name);
25
+ }
26
+ catch {
27
+ throw refuse(`threw while its \`${name}\` was read`);
28
+ }
29
+ if (typeof member !== "function")
30
+ throw refuse(`has no \`${name}\` function`);
31
+ read[name] = member;
32
+ }
33
+ return Object.freeze({
34
+ answer: (question, signal) => Reflect.apply(read.answer, raw, [question, signal]),
35
+ hold: (ref) => Reflect.apply(read.hold, raw, [ref]),
36
+ release: (ref) => Reflect.apply(read.release, raw, [ref]),
37
+ });
38
+ }
8
39
  export const PEER_ANSWER_LANES = Object.freeze({ http: "headers", a2a: "headers", stdio: "env" });
9
40
  export const PEER_SEAT_WAIT_MS = 30_000;
10
41
  export const AUTHORIZATION_URL_MAX = 2048;
@@ -137,7 +168,10 @@ export function refusedThenRenewed(err) {
137
168
  }
138
169
  const HEADER_NAME = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
139
170
  const ENV_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
140
- const VALUE_BREAK = /[\r\n\0]/;
171
+ const VALUE_LAW = Object.freeze({
172
+ headers: Object.freeze({ refuses: /[^\t\x20-\x7e\x80-\xff]/, holds: "a character an HTTP header value cannot carry" }),
173
+ env: Object.freeze({ refuses: /[\r\n\0]|\p{Surrogate}/u, holds: "a line break, a NUL or a lone surrogate" }),
174
+ });
141
175
  const ANSWER_MEMBERS = { carry: ["kind", "headers", "env", "expiresAt"], unauthorized: ["kind", "authorizeUrl"] };
142
176
  const digestOf = (pieces) => {
143
177
  const rows = (m) => Object.entries(m ?? {}).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
@@ -145,18 +179,19 @@ const digestOf = (pieces) => {
145
179
  };
146
180
  const NO_PIECES = Object.freeze({ digest: digestOf({}) });
147
181
  function nameValues(raw, member) {
148
- if (typeof raw !== "object" || raw === null || Array.isArray(raw))
182
+ const members = readOwnMembers(raw);
183
+ if (members === undefined)
149
184
  return `its ${member} is not a record of names to strings`;
150
185
  const out = Object.create(null);
151
186
  const folded = new Set();
152
- for (const name of Object.keys(raw)) {
153
- const value = raw[name];
187
+ for (const name of Object.keys(members)) {
188
+ const value = members[name];
154
189
  if (typeof value !== "string")
155
190
  return `its ${member} member ${inlineUntrusted(JSON.stringify(name), 80)} is not a string`;
156
191
  if (!(member === "headers" ? HEADER_NAME : ENV_NAME).test(name))
157
192
  return `its ${member} name ${inlineUntrusted(JSON.stringify(name), 80)} is not a ${member === "headers" ? "header" : "variable"} name`;
158
- if (VALUE_BREAK.test(value))
159
- return `its ${member} member ${inlineUntrusted(JSON.stringify(name), 80)} holds a line break or NUL`;
193
+ if (VALUE_LAW[member].refuses.test(value))
194
+ return `its ${member} member ${inlineUntrusted(JSON.stringify(name), 80)} holds ${VALUE_LAW[member].holds}`;
160
195
  if (member === "headers") {
161
196
  if (folded.has(name.toLowerCase()))
162
197
  return `its headers name ${inlineUntrusted(JSON.stringify(name), 80)} twice (header names are case-insensitive)`;
@@ -171,30 +206,31 @@ export function readPeerAnswer(raw, lane) {
171
206
  if (typeof raw !== "object" || raw === null || Array.isArray(raw))
172
207
  return { problem: "answered something that is not an answer record" };
173
208
  const record = raw;
174
- const kind = record["kind"];
209
+ const memberOf = (name) => (Object.hasOwn(record, name) ? record[name] : undefined);
210
+ const kind = memberOf("kind");
175
211
  if (kind !== "carry" && kind !== "unauthorized")
176
212
  return { problem: `answered the kind ${inlineUntrusted(JSON.stringify(kind) ?? String(kind), 80)}, which is neither "carry" nor "unauthorized"` };
177
213
  const extra = Object.keys(record).find((key) => !ANSWER_MEMBERS[kind].includes(key));
178
214
  if (extra !== undefined)
179
215
  return { problem: `answered the member ${inlineUntrusted(JSON.stringify(extra), 80)}, which a "${kind}" answer does not have` };
180
216
  if (kind === "unauthorized") {
181
- const raw = record["authorizeUrl"];
182
- if (raw === undefined)
217
+ const given = memberOf("authorizeUrl");
218
+ if (given === undefined)
183
219
  return { unauthorized: {} };
184
- const url = authorizationUrlOf(raw);
220
+ const url = authorizationUrlOf(given);
185
221
  if (url === undefined)
186
222
  return { problem: `answered an authorizeUrl that is not an absolute http(s) URL without user-info, of at most ${AUTHORIZATION_URL_MAX} characters, without control characters` };
187
223
  return { unauthorized: { authorizeUrl: url } };
188
224
  }
189
225
  const own = PEER_ANSWER_LANES[lane];
190
226
  const other = own === "headers" ? "env" : "headers";
191
- if (record[other] !== undefined)
227
+ if (memberOf(other) !== undefined)
192
228
  return { problem: `answered ${other} for a ${lane} peer, which carries ${own} only` };
193
- const expiresAt = record["expiresAt"];
194
- if (expiresAt !== undefined && (typeof expiresAt !== "number" || !Number.isFinite(expiresAt)))
195
- return { problem: "answered an expiresAt that is not a finite epoch-millisecond number" };
196
- const given = record[own];
197
- const values = given === undefined ? undefined : nameValues(given, own);
229
+ const expiresAt = memberOf("expiresAt");
230
+ if (expiresAt !== undefined && (typeof expiresAt !== "number" || !Number.isFinite(expiresAt) || expiresAt < 0))
231
+ return { problem: "answered an expiresAt that is not a finite, non-negative epoch-millisecond number" };
232
+ const carried = memberOf(own);
233
+ const values = carried === undefined ? undefined : nameValues(carried, own);
198
234
  if (typeof values === "string")
199
235
  return { problem: `answered ${values}` };
200
236
  const lanePieces = values === undefined ? {} : { [own]: values };
@@ -204,6 +240,86 @@ export function readPeerAnswer(raw, lane) {
204
240
  return { problem: "answered a record whose members could not be read" };
205
241
  }
206
242
  }
243
+ function dataMember(holder, key) {
244
+ if (typeof holder !== "object" || holder === null || types.isProxy(holder))
245
+ return undefined;
246
+ const descriptor = Object.getOwnPropertyDescriptor(holder, key);
247
+ return descriptor !== undefined && Object.hasOwn(descriptor, "value") ? descriptor.value : undefined;
248
+ }
249
+ function declaredReferences(declared) {
250
+ const refs = [];
251
+ for (const [list, path] of [[dataMember(declared, "mcp"), CREDENTIALS_MEMBER.mcp], [dataMember(declared, "a2a"), CREDENTIALS_MEMBER.a2a]]) {
252
+ if (!Array.isArray(list) || types.isProxy(list))
253
+ continue;
254
+ const length = dataMember(list, "length");
255
+ for (let index = 0; typeof length === "number" && index < length; index++) {
256
+ let at = dataMember(list, String(index));
257
+ for (const key of path)
258
+ at = dataMember(at, key);
259
+ if (at === undefined || (typeof at === "object" && at !== null && types.isProxy(at)))
260
+ continue;
261
+ const read = readCredentialRef(at);
262
+ if (read.ok)
263
+ refs.push(read.ref);
264
+ }
265
+ }
266
+ return refs;
267
+ }
268
+ export function holdPeerDeclarations(seat, declared, onFault) {
269
+ let released = false;
270
+ const holds = [];
271
+ const fault = (member, ref) => onFault(new Error(`the deployment's peer seat threw from \`${member}\` for a "${ref.kind}" reference${member === "hold" ? " — the reference is not held" : ""}`));
272
+ const call = (member, ref) => {
273
+ let returned;
274
+ try {
275
+ returned = seat[member](ref);
276
+ }
277
+ catch {
278
+ fault(member, ref);
279
+ return false;
280
+ }
281
+ if (typeof returned?.then !== "function")
282
+ return true;
283
+ return Promise.resolve(returned).then(() => true, () => (fault(member, ref), false));
284
+ };
285
+ if (seat !== undefined) {
286
+ const seen = new Set();
287
+ for (const ref of declaredReferences(declared)) {
288
+ const key = canonicalize(ref);
289
+ if (seen.has(key))
290
+ continue;
291
+ seen.add(key);
292
+ const outcome = call("hold", ref);
293
+ if (outcome === false)
294
+ continue;
295
+ if (outcome === true) {
296
+ holds.push(() => void call("release", ref));
297
+ continue;
298
+ }
299
+ let releaseAsked = false;
300
+ let fulfilled = false;
301
+ void outcome.then((ok) => {
302
+ fulfilled = ok;
303
+ if (ok && releaseAsked)
304
+ void call("release", ref);
305
+ });
306
+ holds.push(() => {
307
+ releaseAsked = true;
308
+ if (fulfilled)
309
+ void call("release", ref);
310
+ });
311
+ }
312
+ }
313
+ return {
314
+ release() {
315
+ if (released)
316
+ return;
317
+ released = true;
318
+ for (const releaseOne of holds.splice(0))
319
+ releaseOne();
320
+ },
321
+ };
322
+ }
207
323
  async function askBounded(seat, question, signal) {
208
324
  signal?.throwIfAborted();
209
325
  const wait = new AbortController();
@@ -213,7 +329,7 @@ async function askBounded(seat, question, signal) {
213
329
  try {
214
330
  const stopped = new Promise((_, reject) => stop.addEventListener("abort", () => reject(stop.reason), { once: true }));
215
331
  stopped.catch(() => undefined);
216
- return { answer: await Promise.race([seat(question, stop), stopped]) };
332
+ return { answer: await Promise.race([seat.answer(question, stop), stopped]) };
217
333
  }
218
334
  catch (err) {
219
335
  if (signal?.aborted === true)
@@ -230,6 +346,7 @@ export class PeerCarrier {
230
346
  principal;
231
347
  lane;
232
348
  sent = [];
349
+ credentials = [];
233
350
  expiresAt;
234
351
  renewed = false;
235
352
  asked = false;
@@ -278,40 +395,66 @@ export class PeerCarrier {
278
395
  return this.expiresAt !== undefined && now >= this.expiresAt;
279
396
  }
280
397
  async ask(cause, signal, destination) {
281
- if (this.seat === undefined)
398
+ const identity = this.identity;
399
+ if (this.seat === undefined || (identity.protocol === "mcp" && identity.transport === "host"))
282
400
  return NO_PIECES;
283
- const peer = this.identity.protocol === "a2a" && destination !== undefined ? { ...this.identity, destination } : this.identity;
401
+ const peer = identity.protocol === "a2a" && destination !== undefined ? { ...identity, destination } : identity;
284
402
  const asked = await askBounded(this.seat, { peer, ...(this.principal !== undefined ? { principal: this.principal } : {}), cause }, signal);
285
403
  if ("failed" in asked)
286
404
  throw new PeerSeatFailure(asked.failed, this.label, asked.failed === "timed_out" ? `did not answer within ${PEER_SEAT_WAIT_MS} ms` : "threw");
405
+ this.holdAnswered(asked.answer);
287
406
  const read = readPeerAnswer(asked.answer, this.lane);
288
407
  if ("problem" in read)
289
408
  throw new PeerSeatFailure("answer_invalid", this.label, read.problem);
290
409
  if ("unauthorized" in read)
291
410
  throw new PeerSeatFailure("unauthorized", this.label, "answered that this principal is not authorized", read.unauthorized.authorizeUrl === undefined ? undefined : { authorizeUrl: read.unauthorized.authorizeUrl });
292
411
  const pieces = read.carry;
293
- if (pieces.env !== undefined) {
294
- const held = Object.entries(pieces.env).filter(([name, value]) => isSecretEnvKey(name, value)).map(([, value]) => value);
295
- try {
296
- holdOwnCredentialValues(held);
297
- }
298
- catch {
299
- throw new PeerSeatFailure("answer_invalid", this.label, "answered an environment value that is the value of a variable every child on this host is handed");
300
- }
301
- for (const value of held)
412
+ this.holdAnswered(pieces);
413
+ for (const [name, value] of Object.entries(pieces.env ?? {}))
414
+ if (isSecretEnvKey(name, value))
302
415
  this.remember(value);
303
- }
304
416
  if (this.lane === "stdio")
305
417
  this.expiresAt = pieces.expiresAt;
306
418
  for (const value of Object.values(pieces.headers ?? {}))
307
419
  this.remember(value);
308
420
  return pieces;
309
421
  }
422
+ holdAnswered(answer) {
423
+ let refused;
424
+ for (const value of answeredCredentialValues(answer)) {
425
+ try {
426
+ holdOwnCredentialValues([value]);
427
+ }
428
+ catch (err) {
429
+ refused ??= err instanceof Error ? err.message : "the value of a variable every child on this host is handed";
430
+ }
431
+ if (namesASecret(value) && !this.credentials.includes(value))
432
+ this.credentials.push(value);
433
+ }
434
+ if (refused !== undefined)
435
+ throw new PeerSeatFailure("answer_invalid", this.label, `answered a credential value the engine cannot withhold (${inlineUntrusted(refused, 240)})`);
436
+ }
310
437
  remember(value) {
311
438
  if (value !== "" && !this.sent.includes(value))
312
439
  this.sent.push(value);
313
440
  }
314
441
  }
442
+ function answeredCredentialValues(answer) {
443
+ const found = new Set();
444
+ const members = readOwnMembers(answer) ?? {};
445
+ for (const [name, value] of stringMembers(members["headers"])) {
446
+ for (const sent of new Set([value, httpTrimmed(value)]))
447
+ for (const credential of credentialHeaderValues({ [name]: sent }))
448
+ found.add(credential);
449
+ }
450
+ for (const [name, value] of stringMembers(members["env"]))
451
+ if (isSecretEnvKey(name, value))
452
+ found.add(value);
453
+ return [...found];
454
+ }
455
+ function stringMembers(record) {
456
+ return Object.entries(readOwnMembers(record) ?? {}).filter((entry) => typeof entry[1] === "string");
457
+ }
315
458
  export function carriedHttpHeaders(protocol, carrier, pieces, principalHeader, principal) {
316
459
  try {
317
460
  return resolveProtocolHttpHeaders(protocol, { ...(pieces.headers !== undefined ? { headers: { ...pieces.headers } } : {}), ...(principalHeader !== undefined ? { principalHeader } : {}) }, principal);
@@ -372,7 +515,7 @@ export function declaredCredentials(copy, at) {
372
515
  if (read.ok)
373
516
  return { ref: read.ref };
374
517
  const p = read.problem;
375
- return { problem: `${p.reason}${"kind" in p && p.kind !== undefined ? ` (kind ${JSON.stringify(p.kind)})` : ""}${"field" in p ? ` at ${JSON.stringify(p.field)}` : ""}` };
518
+ return { problem: `${p.reason}${"kind" in p && p.kind !== undefined ? ` (kind ${callerText(p.kind)})` : ""}${"field" in p ? ` at ${JSON.stringify(p.field)}` : ""}` };
376
519
  }
377
520
  export function peerSeatMissing(subject, credentials, seat) {
378
521
  if (credentials === undefined || seat !== undefined)
@@ -381,8 +524,10 @@ export function peerSeatMissing(subject, credentials, seat) {
381
524
  }
382
525
  export function mcpPeerTarget(spec, kind) {
383
526
  const t = spec.transport;
527
+ if (kind === "host")
528
+ return { protocol: "mcp", server: spec.name, transport: "host" };
384
529
  const fingerprint = typeof spec.fingerprint === "string" ? { fingerprint: spec.fingerprint } : {};
385
- const credentials = t.credentials !== undefined ? { credentials: t.credentials } : {};
530
+ const credentials = "credentials" in t && t.credentials !== undefined ? { credentials: t.credentials } : {};
386
531
  if (kind === "stdio" && "command" in t)
387
532
  return { protocol: "mcp", server: spec.name, transport: "stdio", command: t.command, args: [...(t.args ?? [])], ...credentials, ...fingerprint };
388
533
  return { protocol: "mcp", server: spec.name, transport: "http", url: "url" in t ? t.url : "", ...credentials, ...fingerprint };
@@ -567,27 +567,6 @@ export interface ImportPreview {
567
567
  rule: string;
568
568
  reason: string;
569
569
  }>;
570
- /**
571
- * ALWAYS EMPTY in this version — a compatibility seat (RL-1336-import-translated), kept on the wire shape so an existing reader
572
- * keeps finding the key (removing a wire field would break readers for no gain).
573
- *
574
- * The seat once carried the entries whose MATCH FORM was rewritten on the way in (the space-star
575
- * suggestion form of the other product translated to this lane's colon-star form, one row per
576
- * translated candidate with its `scope`). That translation is retired: the space-star wildcard is
577
- * now a first-class match form of this lane's own grammar, so an entry's match form imports as the
578
- * file states it — `Bash(npm run *)` lands as `Bash(npm run *)`, never as a colon-star — and nothing
579
- * is ever pushed here. What `candidates` carries is the grammar's CANONICAL re-projection of each
580
- * entry (the parser folds spacing: `Bash(npm<TAB>run *)` lands as `Bash(npm run *)`); that is the
581
- * ordinary normalization every rule text in this lane undergoes, the same one the store applies,
582
- * and not a translation this seat reports. An entry whose star placement has no rule form is
583
- * refused into `skipped` under `unsupported.wildcard`, named as the file writes it. A reader
584
- * rendering a "rewritten spellings" column from this seat renders an empty column, correctly.
585
- */
586
- translated: Array<{
587
- from: string;
588
- to: string;
589
- scope: RuleScope;
590
- }>;
591
570
  layers: Array<{
592
571
  path: string;
593
572
  layer: ImportedSettingsLayer;
@@ -788,7 +788,6 @@ export async function prepareCcImport(opts) {
788
788
  const owner = resolveCallerOwner(opts.principal, opts.owner, "prepareCcImport");
789
789
  const candidates = [];
790
790
  const skipped = [];
791
- const translated = [];
792
791
  const layers = [];
793
792
  for (const layer of opts.layers) {
794
793
  let raw;
@@ -867,7 +866,7 @@ export async function prepareCcImport(opts) {
867
866
  }
868
867
  }
869
868
  }
870
- const preview = { candidates, skipped, translated, layers, uncovered: { ...IMPORT_UNCOVERED_LAYERS } };
869
+ const preview = { candidates, skipped, layers, uncovered: { ...IMPORT_UNCOVERED_LAYERS } };
871
870
  if (candidates.length === 0)
872
871
  return { preview };
873
872
  const record = {
@@ -1310,9 +1310,11 @@ export declare function adjudicatePersistedDomainRules(rules: readonly Persisted
1310
1310
  * THE predicate of a whole-tool rule (`match: "tool"`) over one call: the rule reaches the call iff the call answers to the name it
1311
1311
  * spells, under every name the call answers to (the model's spelling, the wire name, the aliases that resolve to it) — the
1312
1312
  * reference's tool-wide matcher. Every reader of a rule with no content asks it: an entry list's whole-tool row and a person's stored
1313
- * whole-tool row alike.
1313
+ * whole-tool row alike. A row of a list that RESTRICTS (`behavior` deny / ask) whose MCP name the lookup reads more than one way
1314
+ * ({@link peerReadingsOf}: `mcp__a__b` is tool `b` of server `a` and every tool of server `a__b`) reaches the call under any of its
1315
+ * readings; a granting row keeps the one name it spells — an ambiguous spelling never widens a grant.
1314
1316
  */
1315
- export declare function wholeToolRuleReaches(tool: string, call: NamedCall): boolean;
1317
+ export declare function wholeToolRuleReaches(tool: string, call: NamedCall, behavior?: RuleBehavior): boolean;
1316
1318
  /**
1317
1319
  * The whole-tool sibling of {@link adjudicatePersistedRules}: the same precedence walk (deny > ask > allow) over the whole-tool rows
1318
1320
  * (`match: "tool"`) that reach the call ({@link wholeToolRuleReaches}) and are eligible under their own tool ({@link eligiblePersisted},
@@ -3,8 +3,8 @@ import { shellWordsOf } from "../shell/shell-words.js";
3
3
  import { lexShell } from "../shell/lex.js";
4
4
  import { readProgramPosition } from "../tools/fs/bash-program-position.js";
5
5
  import { isNameableToolName, parsePermissionRule, ruleSpellingOf } from "./permission-rule-syntax.js";
6
- import { isCoveringRuleName } from "./namespaced-rule-name.js";
7
- import { toolNameFaultOf } from "./tool-name-aliases.js";
6
+ import { namesASetOfTools, ruleNameCovers } from "./namespaced-rule-name.js";
7
+ import { peerReadingsOf, readsNameGlob, toolNameFaultOf } from "./tool-name-aliases.js";
8
8
  import { compileReadDeny } from "../tools/fs/read-deny.js";
9
9
  import { carriesShellRedirection, parseLeadingCommandName, splitShellCompoundSegments } from "../tools/fs/bash-readonly-classifier.js";
10
10
  import { INLINE_TRUNCATION_MARK, inlineUntrusted } from "./untrusted-text.js";
@@ -426,7 +426,7 @@ export function respelledRuleTextOf(text, behavior) {
426
426
  return "rule" in read ? read.rule.rule : undefined;
427
427
  }
428
428
  function parseWholeToolRule(text, tool, behavior) {
429
- if (!isNameableToolName(tool) || isCoveringRuleName(tool, behavior)) {
429
+ if (!isNameableToolName(tool) || namesASetOfTools(tool, behavior)) {
430
430
  return reject("invalid.grammar", `"${text}" names a set of tools — a stored rule names one tool, or one tool's content; a set of tools is a list entry's form`);
431
431
  }
432
432
  const fault = toolNameFaultOf(tool, catalogToolNames(), behavior);
@@ -1458,13 +1458,14 @@ export function adjudicatePersistedDomainRules(rules, call) {
1458
1458
  }
1459
1459
  return undefined;
1460
1460
  }
1461
- export function wholeToolRuleReaches(tool, call) {
1462
- return heldBy("policy.persistedToolRule", { has: (name) => name === tool }, call);
1461
+ export function wholeToolRuleReaches(tool, call, behavior) {
1462
+ const readsOtherServers = readsNameGlob(behavior) && peerReadingsOf(tool).length > 0;
1463
+ return heldBy("policy.persistedToolRule", { has: (name) => name === tool || (readsOtherServers && ruleNameCovers(tool, name)) }, call);
1463
1464
  }
1464
1465
  export function adjudicatePersistedToolRules(rules, call) {
1465
1466
  const at = { cwd: call.cwd, ...(call.sessionId !== undefined ? { sessionId: call.sessionId } : {}), ...(call.scopeIdentity !== undefined ? { scopeIdentity: call.scopeIdentity } : {}) };
1466
1467
  for (const behavior of RULE_BEHAVIORS_BY_PRECEDENCE) {
1467
- const row = rules.find((rule) => rule.match === "tool" && wholeToolRuleReaches(rule.tool, call.request) && eligiblePersisted(rule, { ...at, tool: rule.tool }, behavior));
1468
+ const row = rules.find((rule) => rule.match === "tool" && wholeToolRuleReaches(rule.tool, call.request, behavior) && eligiblePersisted(rule, { ...at, tool: rule.tool }, behavior));
1468
1469
  if (row !== undefined)
1469
1470
  return { behavior, rules: [row] };
1470
1471
  }
@@ -7,8 +7,8 @@
7
7
  * transport writes itself (an MCP request's session, protocol version, content type, accept and resume headers) is the
8
8
  * protocol's: neither a seat's answer nor the principal header owns it. The hosted-connector assertion header
9
9
  * ({@link MCP_ASSERTION_HEADER}) is the seat's to answer and never the principal header's name. A header the credential
10
- * vocabulary reads as a credential is one the engine holds from the moment it resolves it: no child spawned on this host
11
- * inherits a variable whose value equals it (`holdOwnCredentialValues`, src/core/secret-env.ts).
10
+ * vocabulary reads as a credential is one the engine holds from the moment the seat answers it, before the answer is judged
11
+ * (the carrier's one intake, src/core/peer-seat.ts): no child spawned on this host inherits a variable whose value equals it.
12
12
  *
13
13
  * A principal header that breaks the rule is that peer's defect: the resolver throws inside the peer's own dial, so the
14
14
  * peer is skipped with a coded warning and its siblings still mount; an answer that breaks it is the seat's, and that send
@@ -54,6 +54,8 @@ export declare function resolveProtocolHttpHeaders(protocol: ProtocolId, t: Prot
54
54
  /** The engine's default request headers under the declared ones: a declared name, in any case, owns that header
55
55
  * (the default of the same name is not sent beside it). */
56
56
  export declare function underDeclaredHeaders(defaults: Readonly<Record<string, string>>, declared: Record<string, string> | undefined): Record<string, string>;
57
+ /** A header value as the transport sends it: the HTTP whitespace at its two edges is not part of the value (WHATWG `Headers`). */
58
+ export declare const httpTrimmed: (value: string) => string;
57
59
  /**
58
60
  * A peer's error text with what the peer was SENT taken out of it. Both kinds of removal are found on the ORIGINAL text (so no marker is
59
61
  * rescanned and no replacement can disturb what another one reads) and the ranges they take are merged, one marker per merged range: every
@@ -69,6 +71,16 @@ export declare function underDeclaredHeaders(defaults: Readonly<Record<string, s
69
71
  * whole marker with it, so the pass over its own output answers the same text.
70
72
  */
71
73
  export declare function scrubRequestEcho(text: string, declared: readonly string[]): string;
74
+ /**
75
+ * A remote's own account of itself read without the credentials its connection's requests carried — THE one eraser of what a successful
76
+ * dial or listing hands the engine (an MCP server's `serverInfo`, instructions and tool listing; an A2A peer's card). The needle is
77
+ * `credentials` (the connection's credential values, `PeerCarrier.credentials`): every occurrence of one, in any spelling the
78
+ * request-echo derivation gives it ({@link requestEchoSpellings}) and in any letter case, becomes the redaction mark in place, the way
79
+ * {@link scrubRequestEcho} takes a declared value out of a failure's words. Nothing else is taken — no Cookie member, no vocabulary
80
+ * guess: the rest of the text is the remote's own account, and only the needle is the engine's to withhold. A text with no needle in it
81
+ * is returned as it was (the same string). The function is a fixed point.
82
+ */
83
+ export declare function eraseSentCredentials(text: string, credentials: readonly string[]): string;
72
84
  /**
73
85
  * THE one form a remote endpoint's words take when the engine carries them in its own words — an MCP server's failure, a model
74
86
  * provider's error body, frame or transport failure, a memory distiller seat's failure: what the request was declared with