@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
@@ -1,4 +1,5 @@
1
- import { AUTO_MODE_DEFAULT_TIMEOUT_MS, AUTO_MODE_DENIAL_AUTO_DENY_DEFAULT_MS, AUTO_MODE_DENIAL_LIMIT_DEFAULTS } from "./auto-mode-defaults.js";
1
+ import { AUTO_MODE_DEFAULT_TIMEOUT_MS, AUTO_MODE_DENIAL_AUTO_DENY_DEFAULT_MS, AUTO_MODE_DENIAL_LIMIT_DEFAULTS, AUTO_MODE_RATE_LIMIT_BREAK_AFTER_DEFAULT } from "./auto-mode-defaults.js";
2
+ import { withStatusSeat } from "../brain/status-sink.js";
2
3
  import { thrownIs } from "./thrown-value.js";
3
4
  import { describeRejectedValue } from "./tool-search-setting.js";
4
5
  import { isPlainRecord } from "./mods/kernel/receive.js";
@@ -46,6 +47,16 @@ export function autoModeTimeoutMsOf(v) {
46
47
  e.code = "config.auto_mode_timeout_invalid";
47
48
  throw e;
48
49
  }
50
+ export function autoModeRateLimitBreakAfterOf(v) {
51
+ if (v === undefined)
52
+ return AUTO_MODE_RATE_LIMIT_BREAK_AFTER_DEFAULT;
53
+ if (typeof v === "number" && Number.isSafeInteger(v) && v >= 1)
54
+ return v;
55
+ const e = new Error(`RunnerDeps.autoMode.rateLimitBreakAfter must be a whole number of classifications, at least 1 ` +
56
+ `(got ${describeRejectedValue(v)}) — omit it for the default ${AUTO_MODE_RATE_LIMIT_BREAK_AFTER_DEFAULT}`);
57
+ e.code = "config.auto_mode_rate_limit_break_invalid";
58
+ throw e;
59
+ }
49
60
  export const AUTO_MODE_ROUND_NOT_ASKED_CODE = "auto_mode.round_not_asked";
50
61
  export function autoModeRoundNotAsked(reason) {
51
62
  let detail;
@@ -61,8 +72,15 @@ export function autoModeRoundNotAsked(reason) {
61
72
  return e;
62
73
  }
63
74
  function isAutoModeRoundNotAsked(e) {
75
+ return thrownCarriesCode(e, AUTO_MODE_ROUND_NOT_ASKED_CODE);
76
+ }
77
+ export const AUTO_MODE_RUNG_RATE_LIMITED_CODE = "auto_mode.rung_rate_limited";
78
+ function isAutoModeRungRateLimited(e) {
79
+ return thrownCarriesCode(e, AUTO_MODE_RUNG_RATE_LIMITED_CODE);
80
+ }
81
+ function thrownCarriesCode(e, code) {
64
82
  try {
65
- return typeof e === "object" && e !== null && e.code === AUTO_MODE_ROUND_NOT_ASKED_CODE;
83
+ return typeof e === "object" && e !== null && e.code === code;
66
84
  }
67
85
  catch {
68
86
  return false;
@@ -184,9 +202,12 @@ export function createAutoModeDecider(opts) {
184
202
  throw new Error(`AutoModeDeciderOptions.candidates[${bad}] must be a non-empty model id (got ${JSON.stringify(opts.candidates[bad])})`);
185
203
  }
186
204
  const ladder = opts.candidates ?? [undefined];
205
+ const rateLimitBreakAfter = autoModeRateLimitBreakAfterOf(opts.rateLimitBreakAfter);
206
+ const rateLimitStreak = new Map();
207
+ const retired = new Set();
187
208
  const decide = async (input, signal) => {
188
209
  const startedAt = performance.now();
189
- const round = {};
210
+ const round = { rateLimitBreaks: [] };
190
211
  const verdict = await decideUnreported(input, round, signal);
191
212
  if (opts.onClassified !== undefined) {
192
213
  try {
@@ -197,6 +218,7 @@ export function createAutoModeDecider(opts) {
197
218
  ...(verdict.kind === "unavailable" ? { cause: verdict.cause } : {}),
198
219
  ...(round.notAsked !== undefined ? { notAsked: round.notAsked } : {}),
199
220
  ...(verdict.classifier !== undefined ? { classifier: verdict.classifier } : {}),
221
+ ...(round.rateLimitBreaks.length > 0 ? { rateLimitBreaks: round.rateLimitBreaks } : {}),
200
222
  });
201
223
  }
202
224
  catch {
@@ -211,8 +233,14 @@ export function createAutoModeDecider(opts) {
211
233
  let i = 0;
212
234
  const assembled = await assembleRound(input, round, signal);
213
235
  for (; round.notAsked === undefined && i < ladder.length; i++) {
236
+ if (i < ladder.length - 1 && retired.has(i)) {
237
+ causes.push("error");
238
+ continue;
239
+ }
214
240
  const name = ladder[i];
215
- verdict = await askRung(input, signal, name !== undefined ? { index: i, model: name } : undefined, round, assembled);
241
+ const asked = await askRung(input, signal, name !== undefined ? { index: i, model: name } : undefined, round, assembled);
242
+ verdict = asked.verdict;
243
+ noteRungOutcome(i, asked.rateLimited, signal, round);
216
244
  const cause = rungDidNotRule(verdict);
217
245
  if (cause === undefined)
218
246
  break;
@@ -250,20 +278,41 @@ export function createAutoModeDecider(opts) {
250
278
  }
251
279
  async function askRung(input, signal, rung, round, assembled) {
252
280
  try {
253
- return parseAutoModeResponse(await withDeadline(timeoutMs, signal, (inner) => opts.classify(input, inner, rung, assembled)));
281
+ return { verdict: parseAutoModeResponse(await withDeadline(timeoutMs, signal, (inner) => opts.classify(input, inner, rung, assembled), inClassifierLane)), rateLimited: false };
254
282
  }
255
283
  catch (e) {
256
284
  if (isAutoModeRoundNotAsked(e)) {
257
285
  round.notAsked = "failed";
258
- return { kind: "unavailable", cause: "error" };
286
+ return { verdict: { kind: "unavailable", cause: "error" }, rateLimited: false };
259
287
  }
260
288
  if (signal?.aborted)
261
- return { kind: "unavailable", cause: "error" };
262
- return { kind: "unavailable", cause: isAutoModeTimeout(e) ? "timeout" : "error" };
289
+ return { verdict: { kind: "unavailable", cause: "error" }, rateLimited: false };
290
+ return { verdict: { kind: "unavailable", cause: isAutoModeTimeout(e) ? "timeout" : "error" }, rateLimited: isAutoModeRungRateLimited(e) };
291
+ }
292
+ }
293
+ function noteRungOutcome(rungIndex, rateLimited, signal, round) {
294
+ if (signal?.aborted)
295
+ return;
296
+ if (!rateLimited) {
297
+ rateLimitStreak.delete(rungIndex);
298
+ return;
263
299
  }
300
+ const streak = (rateLimitStreak.get(rungIndex) ?? 0) + 1;
301
+ rateLimitStreak.set(rungIndex, streak);
302
+ if (streak < rateLimitBreakAfter || retired.has(rungIndex))
303
+ return;
304
+ let next = rungIndex + 1;
305
+ while (next < ladder.length - 1 && retired.has(next))
306
+ next++;
307
+ const model = ladder[rungIndex];
308
+ const to = ladder[next];
309
+ if (model === undefined || to === undefined)
310
+ return;
311
+ retired.add(rungIndex);
312
+ round.rateLimitBreaks.push({ rung: rungIndex, model, to, consecutive: streak });
264
313
  }
265
314
  }
266
- async function withDeadline(capMs, signal, call) {
315
+ async function withDeadline(capMs, signal, call, scope = (f) => f()) {
267
316
  if (signal?.aborted === true)
268
317
  throw new Error("the classification was cancelled before it was dispatched");
269
318
  let timer;
@@ -279,19 +328,19 @@ async function withDeadline(capMs, signal, call) {
279
328
  end();
280
329
  };
281
330
  onOuterAbort = () => {
282
- inner.abort();
331
+ scope(() => inner.abort());
283
332
  settle(() => reject(new Error("the classification was cancelled")));
284
333
  };
285
334
  signal?.addEventListener("abort", onOuterAbort, { once: true });
286
335
  timer = setTimeout(() => {
287
336
  settle(() => {
288
- inner.abort();
337
+ scope(() => inner.abort());
289
338
  reject(new AutoModeTimeout());
290
339
  });
291
340
  }, capMs);
292
341
  let pending;
293
342
  try {
294
- pending = call(inner.signal);
343
+ pending = scope(() => call(inner.signal));
295
344
  }
296
345
  catch (e) {
297
346
  settle(() => reject(e));
@@ -307,6 +356,7 @@ async function withDeadline(capMs, signal, call) {
307
356
  signal.removeEventListener("abort", onOuterAbort);
308
357
  }
309
358
  }
359
+ const inClassifierLane = (f) => withStatusSeat("classifier", f);
310
360
  class AutoModeTimeout extends Error {
311
361
  constructor() {
312
362
  super("auto-mode classify timeout");
@@ -365,6 +415,7 @@ export function screenAutoModeKnobs(face) {
365
415
  autoModeTimeoutMsOf(face.timeoutMs);
366
416
  autoModeClassifierFallbackOf(face.classifierFallback);
367
417
  autoModeDenialLimitOf(face.denialLimit);
418
+ autoModeRateLimitBreakAfterOf(face.rateLimitBreakAfter);
368
419
  }
369
420
  export function createAutoModeDenialTracker(opts) {
370
421
  const { maxConsecutive, maxTotal, autoDenyAfterMs } = autoModeDenialLimitOf(opts);
@@ -1,4 +1,5 @@
1
1
  import type { SubagentEditedFile, SubagentStep } from "../agents/subagent-steps.js";
2
+ import type { SubagentTranscriptTier } from "./wiring-manifest.js";
2
3
  /** Terminal/live usage rollup persisted on the row (mirror of the task_notification/BCE fields). */
3
4
  export interface BackgroundAgentUsage {
4
5
  totalTokens?: number;
@@ -187,7 +188,15 @@ export interface BackgroundAgentRecord {
187
188
  export declare const REVIVED_ROW_CLEARED_FIELDS: readonly ["settledAt", "stoppedBy", "completionId", "finalOutput", "finalOutputFull", "error", "errorCode", "errorRetryable", "errorKind", "errorRetryAfterMs", "resultIsPartial", "summary", "recentSteps", "editedFiles", "usage"];
188
189
  /** Erase {@link REVIVED_ROW_CLEARED_FIELDS} from a record a revival is about to write back. */
189
190
  export declare function clearRevivedRowTerminalPayload(record: BackgroundAgentRecord): void;
190
- export declare function announceTranscriptIntegrityGapOnce(handle: string, scope: string | undefined, sink: ((handle: string, scope: string | undefined) => void) | undefined): void;
191
+ /**
192
+ * Whether a deployment's subagent transcript tier DECLARES that a finished agent's transcript outlives the process — the one tier a vanished
193
+ * transcript contradicts. `full` makes that promise; `rows` keeps the agent's record but says transcripts follow the session store's fate (a
194
+ * transcript gone from a process-local store is what that tier means), and `none` has no row to bind one. The tier is the wiring manifest's
195
+ * own word (`WiringManifest.fleet.subagentTranscripts`, derived by `resolveSubagentTranscriptTier`); every site that meets a gone transcript
196
+ * hands the tier its mount derived to {@link announceTranscriptIntegrityGapOnce}, which asks this predicate — the one place it is asked.
197
+ */
198
+ export declare const declaresTranscriptDurability: (tier: SubagentTranscriptTier) => boolean;
199
+ export declare function announceTranscriptIntegrityGapOnce(handle: string, scope: string | undefined, sink: ((handle: string, scope: string | undefined) => void) | undefined, tier: SubagentTranscriptTier): void;
191
200
  /** Content-free projection for list reads (design/151 HIGH-1: `summary`/`finalOutput`/`recentSteps`
192
201
  * and friends NEVER ride a list — content is get-by-handle only, behind the full predicate). */
193
202
  export interface BackgroundAgentRowSummary {
@@ -21,9 +21,10 @@ export function clearRevivedRowTerminalPayload(record) {
21
21
  for (const field of REVIVED_ROW_CLEARED_FIELDS)
22
22
  delete record[field];
23
23
  }
24
+ export const declaresTranscriptDurability = (tier) => tier === "full";
24
25
  const transcriptIntegrityAnnounced = new Set();
25
- export function announceTranscriptIntegrityGapOnce(handle, scope, sink) {
26
- if (sink === undefined)
26
+ export function announceTranscriptIntegrityGapOnce(handle, scope, sink, tier) {
27
+ if (sink === undefined || !declaresTranscriptDurability(tier))
27
28
  return;
28
29
  const key = `${scope ?? ""}\u0000${handle}`;
29
30
  if (transcriptIntegrityAnnounced.has(key))
@@ -73,7 +73,7 @@ export interface BackgroundPoll {
73
73
  * 不支持的 env(StubExecutionEnv / SSH / ADB)= 不实现(或 `supported:false`),三个后台工具自动不挂(INERT)。
74
74
  */
75
75
  export interface BackgroundShellCapability {
76
- /** 显式声明能力(像 `RemoteExecutionEnv.capabilities` 一样不猜)。per-env / per-adapter。 */
76
+ /** 显式声明能力(像 `ExecutionEnv.capabilities` 一样不猜)。per-env / per-adapter。 */
77
77
  readonly backgroundCapabilities: {
78
78
  /** 是否真支持后台 spawn;`false` → 三工具不挂(design/103 §3.8)。 */
79
79
  readonly supported: boolean;
@@ -167,6 +167,17 @@ export declare function envDeclaresRetain(env: ExecutionEnv): boolean;
167
167
  * 单谓词足够:remote-env 刻意拆 `isRemoteExecutionEnv`(结构)/`isSuspendable`(语义)是因为 isolation/suspendable 两轴
168
168
  * 彼此独立;这里 `supported` 是唯一语义轴,合进一个谓词不会丢信息。
169
169
  */
170
+ /**
171
+ * THE output file of a background command (a `run_in_background` / detached Bash, a Monitor watch): created empty in the
172
+ * env's temp dir and canonicalized BEFORE it is advertised — the receipt, the completion notification, the registry row
173
+ * and the key Read's root-fence exemption compares (`TaskRegistry.isBackgroundOutputFile`) must be the same string, and
174
+ * the OS temp dir sits behind a symlink on some platforms. The registry watcher appends every polled increment (stdout
175
+ * and stderr) to it. `undefined` = the file could not be created (the row then has no file, and its completion frame
176
+ * says so); a canonicalize failure keeps the raw path (the file still mirrors — only the exemption may miss). No engine
177
+ * deleter: the model may Read the file well after the task ends; reclamation is the temp-dir policy's job, and only the
178
+ * exemption dies early, with the row.
179
+ */
180
+ export declare function createBackgroundOutputFile(env: ExecutionEnv, prefix: "bash-task-" | "monitor-task-"): Promise<string | undefined>;
170
181
  export declare function hasBackgroundShell(env: ExecutionEnv): env is ExecutionEnv & BackgroundShellCapability;
171
182
  /**
172
183
  * The ONE way core runs an env-level background sweep.
@@ -15,6 +15,18 @@ export function envDeclaresRetain(env) {
15
15
  const caps = env.backgroundCapabilities;
16
16
  return typeof caps === "object" && caps !== null && caps.retainBackgroundProcesses === true;
17
17
  }
18
+ export async function createBackgroundOutputFile(env, prefix) {
19
+ try {
20
+ const tf = await env.createTempFile({ prefix, suffix: ".output" });
21
+ if (!tf.ok)
22
+ return undefined;
23
+ const canon = await env.canonicalPath(tf.value);
24
+ return canon.ok ? canon.value : tf.value;
25
+ }
26
+ catch {
27
+ return undefined;
28
+ }
29
+ }
18
30
  export function hasBackgroundShell(env) {
19
31
  const e = env;
20
32
  return (typeof e.spawnBackground === "function" &&
@@ -1367,7 +1367,7 @@ export interface CheckpointState {
1367
1367
  placementRootSessionId?: string;
1368
1368
  /**
1369
1369
  * design/380 O9a — MONOTONIC presence bit: this run's hand-tool content fold was EXTERNAL-TARGET
1370
- * armed (the env declared `ExecutionEnv.externalContentTarget`, or an earlier leg of this suspend
1370
+ * armed (the env declared `capabilities.externalContentTarget`, or an earlier leg of this suspend
1371
1371
  * chain did). Stamped at the suspend mint from the run's RESOLVED fold state — never from first
1372
1372
  * tool use, so a park landing BEFORE the first hand call is covered too. Presence-coded like
1373
1373
  * {@link isDelegatedChild} (absent = never armed; never `false`). The resume side folds
@@ -2246,9 +2246,8 @@ export type CheckpointErrorReason = "version_newer" | "env_factory_missing" | "g
2246
2246
  | "not_a_list" | "not_a_string" | "unknown_name" | "unsupported_pattern" | "invalid_record" | "renamed_mount" | "registry_occupied"
2247
2247
  /** On `config.unknown_role` (a fresh run's terminal `detail.detail.reason`; on a resume, `detail.reason` of `checkpoint.config_refused` with `detail.code` `config.unknown_role`)
2248
2248
  * — a model binding or a role word the engine cannot read: a word the model catalog does not hold (`"unknown_model_ref"`), a value that is
2249
- * no model reference at all — a number, a boolean, a list (`"not_a_model_ref"`), or a role word outside the vocabulary — a `roles` key, a
2250
- * `modelRole` value (`"unknown_role_word"`). The sentence names the seat the refusal's `field` names (`roles.consolidate`, `tiers.pro`, `TaskSpec.model`). */
2251
- | "unknown_model_ref" | "not_a_model_ref" | "unknown_role_word";
2249
+ * no model reference at all — a number, a boolean, a list (`"not_a_model_ref"`), or a role word outside the vocabulary — a `roles` key, a `modelRole` value (`"unknown_role_word"`) — or a task naming no model whose requested role and fallback chain supply none (`"no_model_for_role"`, `field` the requested role's seat). The sentence names the seat the refusal's `field` names (`roles.consolidate`, `tiers.pro`, `TaskSpec.model`). */
2250
+ | "unknown_model_ref" | "not_a_model_ref" | "unknown_role_word" | "no_model_for_role";
2252
2251
  /**
2253
2252
  * The codes a RESUME's pre-claim configuration screen carries as `detail.code` of a `checkpoint.config_refused` — the words prepare's
2254
2253
  * doors throw, held unchanged so one refusal reads the same on a fresh run (`TaskResult.errorCode`) and on a resume: the mode, output-style,
@@ -3076,12 +3075,9 @@ export interface CheckpointStore {
3076
3075
  * full {@link Checkpoint} payloads. Read-only — it never mutates a row, takes no CAS, and has ZERO effect on
3077
3076
  * the once-only resolve. The PENDING predicate is byte-for-byte the {@link resolve} CAS's (`scope === scope &&
3078
3077
  * status === 'pending'`), so the list reflects exactly the rows that are still resumable. Order is unspecified
3079
- * (the inbox sorts by `severity`/`deadline` itself). An empty scope returns `[]`.
3080
- *
3081
- * **OPTIONAL** for backward-compat (RL-1336-checkpoint-listbyscope) with external {@link CheckpointStore} impls (a caller probes
3082
- * `store.listByScope?.(scope) ?? []`); ALL THREE first-party impls (in-memory, file, Pg) provide it.
3078
+ * (the inbox sorts by `severity`/`deadline` itself). An empty scope returns `[]`. Required: every store answers it.
3083
3079
  */
3084
- listByScope?(scope: string): Promise<CheckpointSummary[]>;
3080
+ listByScope(scope: string): Promise<CheckpointSummary[]>;
3085
3081
  /**
3086
3082
  * Deployment seam: the DISTINCT scopes that currently have at least one PENDING checkpoint — the
3087
3083
  * enumeration face `listByScope` lacks. A host keeping its own scope registry (e.g. a sidecar file for a
@@ -3090,7 +3086,7 @@ export interface CheckpointStore {
3090
3086
  * it matches `listByScope`'s visible surface, so `listScopes() × listByScope()` is exactly the full inbox,
3091
3087
  * and a member the summary does not project is read with `get(token)` on the listed token — the composition
3092
3088
  * a deployment's approval queue is, rather than a query of its own over the store's rows.
3093
- * **OPTIONAL** like {@link listByScope}; the in-memory and file first-party impls provide it.
3089
+ * **OPTIONAL** (unlike the required {@link listByScope}); the in-memory and file first-party impls provide it.
3094
3090
  */
3095
3091
  listScopes?(): Promise<string[]>;
3096
3092
  /** The PENDING rows of every scope past their deadline, one facet per call ({@link CheckpointOverdueQuery}; read by
@@ -3250,9 +3246,8 @@ export declare class InMemoryCheckpointStore implements CheckpointStore {
3250
3246
  readonly deleteSessionCheckpoints?: (sessionId: string, guard: CheckpointDeleteGuard) => Promise<number>;
3251
3247
  /** `disclose` is the listing projections' own seat ({@link summarizeCheckpoint}'s and the listing faces'): this store has no
3252
3248
  * path, so it forwards each sentence for a row read past a damage, called synchronously by the listing that read it.
3253
- * `sessionHeadOf` (a session store's `headOf`) is what {@link CheckpointStore.deleteSessionCheckpoints} judges its guard by.
3254
- * `holderIsCurrent` ({@link HolderJudge}) is what a resolve's `expect.holder` is judged by. */
3255
- constructor(opts?: {
3249
+ * `sessionHeadOf` (a session store's `headOf`) is what {@link CheckpointStore.deleteSessionCheckpoints} judges its guard by; `holderIsCurrent` ({@link HolderJudge}), a resolve's `expect.holder`. */
3250
+ constructor(options?: {
3256
3251
  disclose?: (sentence: string) => void;
3257
3252
  sessionHeadOf?: (sessionId: string) => Promise<{
3258
3253
  readonly owner: string | null;
@@ -3,7 +3,7 @@ import { uuidv7 } from "../internal/harness.js";
3
3
  import { PROBE_CAUSE_PATH_MAX, PROBE_REASON_MAX, inlineUntrusted, sanitizeUntrustedText } from "./untrusted-text.js";
4
4
  import { carriesBidiControls } from "./tool-policy.js";
5
5
  import { isAutoModeFallbackCause, readDenialLimitFallback } from "./auto-mode.js";
6
- import { isAskOrigin, isPersistedRuleMandate } from "./ask-origin.js";
6
+ import { isAskOrigin, isPermissionMode, isPersistedRuleMandate } from "./ask-origin.js";
7
7
  import { isRunOrigin, RUN_ORIGINS } from "./run-origin.js";
8
8
  import { describeRejectedValue } from "./tool-search-setting.js";
9
9
  import { readBoundBinding } from "./skill-grant-binding.js";
@@ -14,8 +14,8 @@ import { checkpointDeadlinePassed, deleteSessionRowsAtStart, readCheckpointOverd
14
14
  import { renderUntrustedCommandText, stripFormatCharacters } from "./permission-rule-model.js";
15
15
  import { egressText } from "./untrusted-egress.js";
16
16
  import { steerReplayRefusal } from "./steer-replay.js";
17
- import { isPermissionMode } from "./ask-origin.js";
18
17
  import { readRetentionDeclaration } from "./retention.js";
18
+ import { receiveOptions } from "./own-property-receipt.js";
19
19
  export function mintCheckpointToken() {
20
20
  return randomBytes(16).toString("hex");
21
21
  }
@@ -583,7 +583,8 @@ export class InMemoryCheckpointStore {
583
583
  fault = null;
584
584
  disclose;
585
585
  holderIsCurrent;
586
- constructor(opts = {}) {
586
+ constructor(options) {
587
+ const opts = receiveOptions(options, "InMemoryCheckpointStore");
587
588
  this.retention = readRetentionDeclaration("InMemoryCheckpointStore.retention", opts.retention);
588
589
  this.disclose = opts.disclose;
589
590
  this.holderIsCurrent = opts.holderIsCurrent;
@@ -32,7 +32,7 @@ export declare function resolveComplianceDenies(posture: CompliancePosture): Rea
32
32
  /** One deny list member's refusal under the closed capability set, labelled with the list that carried it, or
33
33
  * `undefined` when it is a member. */
34
34
  export declare function complianceCapabilityProblem(cap: unknown, owner: string): string | undefined;
35
- /** The core web-fetch tool face's canonical mounted name (`createWebFetchTool` in tools/web.ts). */
35
+ /** The core web-fetch tool face's canonical mounted name (`webFetchToolSpec` in tools/web.ts). */
36
36
  export declare const WEB_FETCH_TOOL_NAME = "WebFetch";
37
37
  /**
38
38
  * The CALL-TIME half of the `web_fetch` double point (CC form — mount check + call guard): given the
@@ -0,0 +1,52 @@
1
+ /**
2
+ * A protocol peer's account of itself, read without the credentials its connection's requests carried — the MCP server's `serverInfo`,
3
+ * its instructions and its tool listing, the A2A peer's agent card. The needle is the connection's credentials (`PeerCarrier.credentials`:
4
+ * what the seat answered that the withheld table holds) and the one eraser is `eraseSentCredentials` (protocol-http-auth.ts, beside the
5
+ * failure text's). Free text holding the needle is erased in place; a NAME holding it (a tool's name or input schema, the server's own
6
+ * name, a skill's id, the card's name) is never rewritten — what it names is refused instead. Either way the site is announced, once per
7
+ * (materialization, peer, site), as `mcp.credential_echoed` (operator) through {@link credentialEchoNotice}.
8
+ */
9
+ import { type EngineNotice } from "./engine-notice.js";
10
+ import type { PeerCarrier } from "./peer-seat.js";
11
+ /** Where a peer echoed its connection's credentials into what it said about itself — the closed set `mcp.credential_echoed` names
12
+ * (`detail.where`). */
13
+ export declare const CREDENTIAL_ECHO_SITES: readonly ["server_info", "instructions", "tool_listing", "agent_card"];
14
+ export type CredentialEchoSite = (typeof CREDENTIAL_ECHO_SITES)[number];
15
+ /** What a peer's account is read with: the needle, and who hears that a site held it. */
16
+ export interface CredentialEcho {
17
+ readonly credentials: readonly string[];
18
+ readonly announce: (where: CredentialEchoSite) => void;
19
+ }
20
+ export declare const NO_CREDENTIAL_ECHO: CredentialEcho;
21
+ /** The drop reason of a tool whose name or input schema holds its connection's credential. */
22
+ export declare const CREDENTIAL_ECHO_DROP_REASON = "its name or input schema holds a credential this connection's requests carried (the server echoed it back); neither is rewritten, so the tool is not mounted";
23
+ /** A free text of the peer's with the needle erased in place (absent stays absent); a text that held it announces `where`. */
24
+ export declare function erasedEcho(text: string | undefined, echo: CredentialEcho, where: CredentialEchoSite): string | undefined;
25
+ /** Whether a NAME the peer gave holds the needle (announced as `where` when it does): such a name is refused, never rewritten. */
26
+ export declare function nameEchoes(name: string, echo: CredentialEcho, where: CredentialEchoSite): boolean;
27
+ /** A listed input schema as one text for the needle (its keys and values, JSON-escaped as the echo spellings expect); a schema JSON cannot
28
+ * carry reads as nothing (the schema gate refuses it on its own). */
29
+ export declare function schemaText(schema: unknown): string;
30
+ /** A listed tool the needle refuses — named with it, or its input schema holding it (the schema is the tool's structure: its property
31
+ * names are what the model sends, not prose to edit) — as its drop record, the name erased; `undefined` for a tool the needle leaves. */
32
+ export declare function echoedToolDrop(name: string, inputSchema: unknown, echo: CredentialEcho): {
33
+ tool: string;
34
+ reason: string;
35
+ } | undefined;
36
+ /** How a connection's account is read: its carrier's credentials, a site that held one announced through `announce`. */
37
+ export declare function carrierEcho(carrier: {
38
+ readonly credentials: PeerCarrier["credentials"] | readonly string[];
39
+ }, announce: ((where: CredentialEchoSite) => void) | undefined): CredentialEcho;
40
+ /** The server's `serverInfo` as its status projects it: `name` is a name (holding the needle, the record is not projected — never
41
+ * rewritten), `version` free text (erased in place). */
42
+ export declare function serverInfoOf(info: {
43
+ name: string;
44
+ version: string;
45
+ } | undefined, echo: CredentialEcho): {
46
+ name: string;
47
+ version: string;
48
+ } | undefined;
49
+ /** One materialization's announcer: each (peer, site) heard once, a throwing listener never a fault of the dial it describes. */
50
+ export declare function echoAnnouncer(onCredentialEchoed: ((peer: string, where: CredentialEchoSite) => void) | undefined): (peer: string, where: CredentialEchoSite) => void;
51
+ /** The runner's listener → `mcp.credential_echoed` (engine-notice.ts): the peer and the site, never a value; operator audience. */
52
+ export declare function credentialEchoNotice(onNotice: ((notice: EngineNotice) => void) | undefined, sessionId: string, runId: string, protocol: "mcp" | "a2a"): (server: string, where: CredentialEchoSite) => void;
@@ -0,0 +1,65 @@
1
+ import { deliverEngineNotice } from "./engine-notice.js";
2
+ import { eraseSentCredentials } from "./protocol-http-auth.js";
3
+ import { inlineUntrusted } from "./untrusted-text.js";
4
+ export const CREDENTIAL_ECHO_SITES = Object.freeze(["server_info", "instructions", "tool_listing", "agent_card"]);
5
+ export const NO_CREDENTIAL_ECHO = Object.freeze({ credentials: Object.freeze([]), announce: () => undefined });
6
+ export const CREDENTIAL_ECHO_DROP_REASON = "its name or input schema holds a credential this connection's requests carried (the server echoed it back); neither is rewritten, so the tool is not mounted";
7
+ export function erasedEcho(text, echo, where) {
8
+ if (typeof text !== "string")
9
+ return text;
10
+ const erased = eraseSentCredentials(text, echo.credentials);
11
+ if (erased !== text)
12
+ echo.announce(where);
13
+ return erased;
14
+ }
15
+ export function nameEchoes(name, echo, where) {
16
+ const echoed = typeof name === "string" && eraseSentCredentials(name, echo.credentials) !== name;
17
+ if (echoed)
18
+ echo.announce(where);
19
+ return echoed;
20
+ }
21
+ export function schemaText(schema) {
22
+ try {
23
+ return JSON.stringify(schema) ?? "";
24
+ }
25
+ catch {
26
+ return "";
27
+ }
28
+ }
29
+ export function echoedToolDrop(name, inputSchema, echo) {
30
+ if (!nameEchoes(name, echo, "tool_listing") && !nameEchoes(schemaText(inputSchema), echo, "tool_listing"))
31
+ return undefined;
32
+ return { tool: inlineUntrusted(eraseSentCredentials(name, echo.credentials)), reason: CREDENTIAL_ECHO_DROP_REASON };
33
+ }
34
+ export function carrierEcho(carrier, announce) {
35
+ return { credentials: carrier.credentials, announce: announce ?? NO_CREDENTIAL_ECHO.announce };
36
+ }
37
+ export function serverInfoOf(info, echo) {
38
+ if (info === undefined)
39
+ return undefined;
40
+ if (nameEchoes(info.name, echo, "server_info"))
41
+ return undefined;
42
+ return { name: info.name, version: erasedEcho(info.version, echo, "server_info") ?? info.version };
43
+ }
44
+ export function echoAnnouncer(onCredentialEchoed) {
45
+ const announced = new Set();
46
+ return (peer, where) => {
47
+ const key = `${peer}\u0000${where}`;
48
+ if (onCredentialEchoed === undefined || announced.has(key))
49
+ return;
50
+ announced.add(key);
51
+ try {
52
+ onCredentialEchoed(peer, where);
53
+ }
54
+ catch {
55
+ }
56
+ };
57
+ }
58
+ const SITE_WORDS = { server_info: "serverInfo", instructions: "instructions", tool_listing: "tool listing", agent_card: "agent card" };
59
+ export function credentialEchoNotice(onNotice, sessionId, runId, protocol) {
60
+ return (server, where) => deliverEngineNotice(onNotice, {
61
+ code: "mcp.credential_echoed",
62
+ message: `${protocol === "mcp" ? "MCP server" : "A2A peer"} "${inlineUntrusted(server, 120)}" echoed a credential its requests carried into its ${SITE_WORDS[where]} — the engine erased it there (a name holding it was refused, not rewritten); the endpoint repeats what it is sent, so check what it logs and publishes.`,
63
+ detail: { protocol, server, where, sessionId, runId },
64
+ });
65
+ }
@@ -94,11 +94,21 @@ export interface CredentialVocabulary {
94
94
  readonly policy: VocabularyPolicy;
95
95
  }
96
96
  /**
97
- * The URI scheme, bounded so it cannot backtrack: RFC 3986's scheme production plus `_`, at most 64 characters. An
98
- * unbounded `\w+` made every `://` pattern quadratic in the longest unbroken word run (one long base64 paste cost
99
- * seconds of synchronous CPU); the bound makes it linear and redacts no less on any URL.
97
+ * The URI scheme: RFC 3986's scheme production plus `_`, of any length, read from the START of its run of scheme characters
98
+ * (a run's leading digits and marks are taken into it, so the match keeps them). An unanchored unbounded `\w+` made every
99
+ * `://` pattern quadratic in the longest unbroken word run (one long base64 paste cost seconds of synchronous CPU), and a
100
+ * 64-character cap that replaced it missed a longer scheme; anchored at the run's start, each run is tried once — linear, and
101
+ * no scheme is too long to be read.
100
102
  */
101
103
  export declare const URI_SCHEME_SOURCE: string;
104
+ /**
105
+ * A URL's userinfo with the `@` that ends it, up to the LAST `@` before the host (a password may hold `@`): runs of characters
106
+ * that are no `/`, white space, `"` or `@`, each closed by an `@`. The class holds all of RFC 3986's userinfo (unreserved,
107
+ * pct-encoded, sub-delims — `'` among them — and `:`) and the characters a password written unencoded carries (`#`, `?`, …);
108
+ * `"` ends it, the quote of a string around the URL. The one userinfo grammar: every reader that removes a userinfo matches
109
+ * this, and each renders the match its own way.
110
+ */
111
+ export declare const URL_USERINFO_SOURCE: string;
102
112
  /** The fewest characters a string can have and still be read as a credential: the floor of a vendor-prefixed token's body
103
113
  * and of a bearer / authorization credential run in this table, and of the value rules of the env scrub. A shorter
104
114
  * string names no secret, whoever holds it. */
@@ -1,4 +1,5 @@
1
- export const URI_SCHEME_SOURCE = String.raw `[A-Za-z][A-Za-z0-9+.\-_]{0,63}`;
1
+ export const URI_SCHEME_SOURCE = String.raw `(?<![A-Za-z0-9+.\-_])[0-9+.\-_]*[A-Za-z][A-Za-z0-9+.\-_]*`;
2
+ export const URL_USERINFO_SOURCE = String.raw `(?:[^/\s"@]*@)+`;
2
3
  export const CREDENTIAL_MIN_CHARS = 8;
3
4
  const VENDOR_BODY = `[A-Za-z0-9_-]{${CREDENTIAL_MIN_CHARS},}`;
4
5
  const VALUE_END = String.raw `\s"';|&`;
@@ -23,6 +24,13 @@ const BEARER_TAIL = `(?:(?!${QUOTE})\\S${GLUED_RUN}|(?<==)(?:${QUOTED_VALUE}))`;
23
24
  const HEADER_PARAM = String.raw `=[ \t]*(\\{0,${ESCAPE_DEPTH}})(["'])(?:(?!(?<!\\)\2\3)[^\r\n])*(?:(?<!\\)\2\3(?=[\s,;]|\\{0,${ESCAPE_DEPTH}}["']|$)|(?=[\r\n]|$))`;
24
25
  const HEADER_VALUE = String.raw `(?:[A-Za-z][A-Za-z0-9!#$%&*+.^_|~-]*[ \t]+)?(?:${HEADER_PARAM}|[^\s"',]|[ \t]*,[ \t]*(?=[^\s"',])|[ \t]+(?==)|(?<==)[ \t]+(?=[^\s"',]))+${VALUE_RUN_END}`;
25
26
  const headed = (body, flags = "g") => new RegExp(`${WORD_START}${body}`, flags);
27
+ const HUMP_BEFORE = "[a-z0-9]";
28
+ const KEYWORD_VALUE_WORDS = ["token", "secret", "key", "password", "passwd", "credential"];
29
+ const anyCase = (word) => [...word].map((c) => `[${c.toUpperCase()}${c.toLowerCase()}]`).join("");
30
+ const VALUE_ROW_FIELDS = [["Account", "Key"]];
31
+ const leftToItsRow = (keyword) => VALUE_ROW_FIELDS.filter(([, k]) => k.toLowerCase() === keyword).map(([front]) => `(?<!(?<![A-Za-z0-9])${front})`).join("");
32
+ const KEYWORD_HEAD = `(?:${WORD_START}(?:${KEYWORD_VALUE_WORDS.map(anyCase).join("|")})|(?<=${HUMP_BEFORE})(?:${KEYWORD_VALUE_WORDS.map((w) => leftToItsRow(w) + w[0].toUpperCase() + anyCase(w.slice(1))).join("|")})|(?<=[A-Z])(?:${KEYWORD_VALUE_WORDS.map((w) => w[0].toUpperCase() + w[1] + anyCase(w.slice(2))).join("|")}))`;
33
+ const KEY_QUOTE = `(?:\\\\{0,${ESCAPE_DEPTH}}["'])?`;
26
34
  export const CREDENTIAL_VOCABULARY = {
27
35
  values: [
28
36
  { id: "github-token", kind: "prefixed-token", source: "arg-summary", confidence: "high", pass: "vendor-prefixed", match: headed(`gh[opsur][-_]${VENDOR_BODY}`), strict: /\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{36,}\b/ },
@@ -42,8 +50,8 @@ export const CREDENTIAL_VOCABULARY = {
42
50
  { id: "bearer-token", kind: "bearer-token", source: "arg-summary", confidence: "high", match: headed(String.raw `()[Bb][Ee][Aa][Rr][Ee][Rr]\s+[A-Za-z0-9._~+/-]{${CREDENTIAL_MIN_CHARS},}=*(?:${BEARER_TAIL})?`), strict: /\bAuthorization:\s*Bearer\s+(?=[A-Za-z0-9._~+/-]*[0-9])[A-Za-z0-9._~+/-]{20,}=*/ },
43
51
  { id: "authorization-header", kind: "authorization-header", source: "arg-summary", confidence: "high", match: headed(String.raw `(authorization(?:\\{0,${ESCAPE_DEPTH}}["'])?[ \t]*[=:][ \t]*(?:\\{0,${ESCAPE_DEPTH}}["'])?)${HEADER_VALUE}`, "gi") },
44
52
  { id: "azure-storage-account-key", kind: "prefixed-token", source: "arg-summary", confidence: "high", match: /(AccountKey=)[A-Za-z0-9+/]{40,}={0,2}/g, strict: /AccountKey=[A-Za-z0-9+/]{40,}={0,2}/ },
45
- { id: "keyword-value", kind: "keyword-value", source: "arg-summary", confidence: "medium", match: headed(String.raw `((?:token|secret|key|password|passwd|credential)["']?\s*[=:]\s*["']?)${VALUE_CHAR}{4,}${VALUE_RUN_END}`, "gi") },
46
- { id: "url-userinfo", kind: "url-credentials", source: "untrusted-egress", confidence: "medium", match: new RegExp(String.raw `(${URI_SCHEME_SOURCE}:\/\/)((?:[^/\s"'@]*@)+)`, "gi") },
53
+ { id: "keyword-value", kind: "keyword-value", source: "arg-summary", confidence: "medium", match: new RegExp(String.raw `(${KEYWORD_HEAD}${KEY_QUOTE}\s*[=:]\s*${KEY_QUOTE})${VALUE_CHAR}{4,}${VALUE_RUN_END}`, "g") },
54
+ { id: "url-userinfo", kind: "url-credentials", source: "untrusted-egress", confidence: "medium", match: new RegExp(String.raw `(${URI_SCHEME_SOURCE}:\/\/)(${URL_USERINFO_SOURCE})`, "gi") },
47
55
  { id: "signed-url-param", kind: "signed-url-param", source: "untrusted-egress", confidence: "high", match: /([?&#](?:sig|signature|sas|code)=)[^&\s"'#]+/gi },
48
56
  ],
49
57
  words: [
@@ -137,7 +145,7 @@ export function envNameView(vocabulary) {
137
145
  export function splitCamelCase(name) {
138
146
  return ["OAuth", "NextAuth"]
139
147
  .reduce((text, word) => text.replaceAll(word, word[0] + word.slice(1).toLowerCase()), name)
140
- .replace(/([a-z0-9])([A-Z])/g, "$1_$2")
148
+ .replace(new RegExp(`(${HUMP_BEFORE})([A-Z])`, "g"), "$1_$2")
141
149
  .replace(/([A-Z])([A-Z][a-z])/g, "$1_$2");
142
150
  }
143
151
  export function recordKeyView(vocabulary) {
@@ -12,6 +12,7 @@
12
12
  */
13
13
  import type { AssertAllKeysHandled } from "./ask-origin.js";
14
14
  import type { EngineNotice } from "./engine-notice.js";
15
+ import type { ExecutionEnv } from "../internal/harness-types.js";
15
16
  import type { HostDecider } from "./gate-outcome.js";
16
17
  /** The run tree's two TAINT bits: the tree executes on a target device (`targetExecutionArmed`), and an off-target read
17
18
  * was allowed into it since (`offTargetReadObserved`). Presence-coded on every carrier: `true` or absent, never `false`. */
@@ -50,13 +51,11 @@ export interface CrossBoundaryObligation {
50
51
  readonly record: boolean;
51
52
  }
52
53
  /** What a `"per_call"` definition's dispatch gives for one call: the legs it travels and, when its `env` leg reaches an
53
- * environment other than the calling leg's own (a background shell's), that environment — its declaration is read as the call
54
- * is judged. */
54
+ * environment other than the calling leg's own (a background shell's), that environment — its declaration
55
+ * (`capabilities.externalContentTarget`) is read as the call is judged. */
55
56
  export interface BoundaryLegsGiven {
56
57
  readonly legs: readonly BoundaryLeg[];
57
- readonly env?: {
58
- readonly externalContentTarget?: boolean;
59
- };
58
+ readonly env?: Pick<ExecutionEnv, "capabilities">;
60
59
  }
61
60
  /** What a leg's session is still owed when the leg ends: the legs each unfinished background task its access (the TaskOutput reach) delivers
62
61
  * along, read as the poll the session's next leg — another tree — would make of it (`TaskRegistry.owedDeliveries`). */