@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
@@ -26,9 +26,12 @@ export interface ToolResultSeatEvent {
26
26
  details: unknown;
27
27
  isError: boolean;
28
28
  }
29
- /** The station: the patch the loop applies to the result (`undefined` = unchanged). */
29
+ /** The station: the patch the loop applies to the result (`undefined` = unchanged); `details` (emptied) and `isError` only on a
30
+ * result it withholds — nothing of the result rides on. */
30
31
  export type ToolResultStation = (e: ToolResultSeatEvent) => Promise<{
31
32
  content: Array<TextContent | ImageContent | DocumentContent>;
33
+ details?: Record<string, never>;
34
+ isError?: true;
32
35
  } | undefined>;
33
36
  export interface ToolResultStationInput {
34
37
  /** borrowed-readonly — the leg's mods bus: `classic.PostToolUse` / `classic.PostToolUseFailure` are raised on it, and a
@@ -40,6 +43,9 @@ export interface ToolResultStationInput {
40
43
  toolRosterDeltas: ToolRosterDeltaSeat;
41
44
  /** borrowed-mutable — PreToolUse `additionalContext` per call id. Writer here: the one-shot drain (`delete`). */
42
45
  preToolContexts: Map<string, string[]>;
46
+ /** borrowed-readonly — an inherited installation judges this leg's calls at its gate, so a context line may be stashed for a
47
+ * call though no handler of the leg's own hangs on `classic.PreToolUse`. */
48
+ inheritedScreens: boolean;
43
49
  /** borrowed-readonly — prepare's abort seat; `.signal` is the post events' abort and the failure event's interrupt fact. */
44
50
  abortController: {
45
51
  readonly signal: AbortSignal;
@@ -61,8 +67,8 @@ export interface ToolResultStationInput {
61
67
  }
62
68
  /** The `tool_result` station, or undefined when no post / screening hook is wired (nothing to register). */
63
69
  export declare function createToolResultStation(input: ToolResultStationInput): ToolResultStation | undefined;
64
- /** What the resumed leg does with the approved call: refuse it with a sentence (it is NOT executed), or run these bytes.
65
- * `admit` stashes the screen's context for the result's drain — called only once the call is past every belt and about
70
+ /** What the resumed leg does with the approved call: refuse it with a sentence (it is NOT executed), or let the approved bytes
71
+ * run. `admit` stashes the screen's context for the result's drain — called only once the call is past every belt and about
66
72
  * to run (a refused call stashes nothing, the live gate's rule). */
67
73
  export type ApprovedCallScreen = NonNullable<Prepared["approvedCallScreen"]>;
68
74
  export type ApprovedCallVerdict = Awaited<ReturnType<ApprovedCallScreen>>;
@@ -89,15 +95,16 @@ export interface ApprovedCallScreenInput {
89
95
  * the call (the decide is the upper bound; the screen can only narrow): a deny, a failed or cancelled screening, or a
90
96
  * refused answer refuses the call in the live gate's own sentences; an ask is the question the decide already answered —
91
97
  * unless it demands a person and the decide was the deployment's policy (the one predicate every resume station holds a
92
- * decide against); a rewrite comes back as the args — what executes when the decide carried no edit, a refusal of the edit
93
- * when it did (a person's bytes are the ceiling, rewrite-rejudge.ts); context rides the result. Undefined when no handler hangs
94
- * on `classic.PreToolUse`.
98
+ * decide against); context rides the result. Its three outlets are those — a refusal, an ask, the context: a rewrite is not
99
+ * one. The bytes that run are the bytes the decide approved (the person's edit, or the call as shown), so an `updatedInput`
100
+ * here is not adopted — the reference's form, where a parked answer's own input stands over the hook's. Undefined when no
101
+ * handler hangs on `classic.PreToolUse`.
95
102
  */
96
103
  export declare function createApprovedCallScreen(input: ApprovedCallScreenInput): ApprovedCallScreen | undefined;
97
104
  /**
98
- * Why the frozen inherited chain cannot judge bytes no gate judged (an approver's edit, the re-screen's rewrite): the
99
- * row predates the chain, a layer is opaque, or a layer declares a live remainder — undefined when the frozen
100
- * projections can judge them, or when no parent constraint binds. ONE rule for the pre-claim edit rung (which refuses
101
- * the edit, the row pending) and the resumed leg's belt (which refuses a rewrite, the approval spent).
105
+ * Why the frozen inherited chain cannot judge bytes no gate judged (an approver's edit): the row predates the chain, a
106
+ * layer is opaque, or a layer declares a live remainder — undefined when the frozen projections can judge them, or when no
107
+ * parent constraint binds. ONE rule for the pre-claim edit rung (which refuses the edit, the row pending) and the resumed
108
+ * leg's belt behind it (which refuses it, the approval spent).
102
109
  */
103
110
  export declare function chainCannotJudge(ig: Checkpoint["state"]["inheritedGate"]): string | undefined;
@@ -1,9 +1,11 @@
1
1
  import { createPreToolUseScreening, formatHookFeedback } from "../hooks.js";
2
2
  import { classicEventBase, dispatchClassic, stringMembersAnswer, stringMembersOf } from "../mods/stations.js";
3
3
  import { policyCannotAnswer } from "../real-approval.js";
4
+ import { decisionText } from "../tool-policy.js";
4
5
  import { rosterToolName } from "../tool-roster.js";
5
6
  import { wireOf } from "../tool-name-readings.js";
6
- import { noteHostRewrite } from "../frame-settlement.js";
7
+ import { noteHostRewrite, settleWithheldResult } from "../frame-settlement.js";
8
+ import { extensionWords } from "../untrusted-egress.js";
7
9
  function postToolUseAnswer(answer) {
8
10
  const strings = stringMembersAnswer("classic.PostToolUse", ["additionalContext"])(answer);
9
11
  if (strings !== undefined || typeof answer !== "object" || answer === null)
@@ -21,8 +23,8 @@ function isContentBlock(c) {
21
23
  return typeof c === "object" && c !== null && typeof Reflect.get(c, "type") === "string";
22
24
  }
23
25
  export function createToolResultStation(input) {
24
- const { modBus, blockedToolCalls, toolRosterDeltas, preToolContexts, abortController, spec, handsCwdRef, hookEnvFace, hookIdentity, permissionMode, reminderMark, frameSettlement } = input;
25
- const toolResultStationArmed = modBus.hasHandlers("classic.PostToolUse") || modBus.hasHandlers("classic.PreToolUse") || modBus.hasHandlers("classic.PostToolUseFailure");
26
+ const { modBus, blockedToolCalls, toolRosterDeltas, preToolContexts, inheritedScreens, abortController, spec, handsCwdRef, hookEnvFace, hookIdentity, permissionMode, reminderMark, frameSettlement } = input;
27
+ const toolResultStationArmed = modBus.hasHandlers("classic.PostToolUse") || modBus.hasHandlers("classic.PreToolUse") || modBus.hasHandlers("classic.PostToolUseFailure") || inheritedScreens;
26
28
  if (toolResultStationArmed) {
27
29
  return async (e) => {
28
30
  if (blockedToolCalls.delete(e.toolCallId)) {
@@ -30,6 +32,7 @@ export function createToolResultStation(input) {
30
32
  }
31
33
  let content = e.content;
32
34
  let changed = false;
35
+ let withheld = false;
33
36
  const post = { toolName: rosterToolName(toolRosterDeltas.current, e.toolName) };
34
37
  const callFacts = (tool) => ({
35
38
  ...classicEventBase(hookIdentity, permissionMode.observed),
@@ -65,7 +68,13 @@ export function createToolResultStation(input) {
65
68
  }
66
69
  }
67
70
  else if (modBus.hasHandlers("classic.PostToolUse")) {
68
- const outcome = await dispatchClassic(modBus, "classic.PostToolUse", { ...callFacts(wireOf("hook.postToolUse", post)), output: { content: e.content, details: e.details, isError: e.isError } }, { signal: abortController.signal, checkAnswer: postToolUseAnswer }).catch(() => undefined);
71
+ const outcome = await dispatchClassic(modBus, "classic.PostToolUse", { ...callFacts(wireOf("hook.postToolUse", post)), output: { content: e.content, details: e.details, isError: e.isError } }, { signal: abortController.signal, checkAnswer: postToolUseAnswer }).catch(() => ({ kind: "rejected" }));
72
+ if (outcome?.kind === "failed" || outcome?.kind === "rejected") {
73
+ content = [{ type: "text", text: formatHookFeedback(`the result of this call to "${extensionWords(post.toolName, 80)}" could not be given to the classic.PostToolUse extensions that check it: a hook that checks this result could not hand back its answer, so the result is withheld — the call ran (fail-closed)`, reminderMark) }];
74
+ withheld = true;
75
+ changed = true;
76
+ settleWithheldResult(frameSettlement, e.toolCallId, content);
77
+ }
69
78
  const answer = outcome?.kind === "answered" ? outcome.answer : undefined;
70
79
  const updatedOutput = updatedOutputOf(answer);
71
80
  const patch = stringMembersOf(answer, ["additionalContext"]);
@@ -85,7 +94,7 @@ export function createToolResultStation(input) {
85
94
  content = [...content, ...pre.map((t) => ({ type: "text", text: formatHookFeedback(t, reminderMark) }))];
86
95
  changed = true;
87
96
  }
88
- return changed ? { content } : undefined;
97
+ return changed ? { content, ...(withheld ? { details: {}, isError: true } : {}) } : undefined;
89
98
  };
90
99
  }
91
100
  return undefined;
@@ -105,20 +114,22 @@ export function createApprovedCallScreen(input) {
105
114
  abortSignal: abortController.signal,
106
115
  });
107
116
  if (screening === undefined)
108
- return { args, admit: () => undefined };
117
+ return { admit: () => undefined };
109
118
  const subject = `this call to "${toolName}"`;
110
119
  const screened = await screening.screen(args, subject);
111
120
  if (screened.kind === "refused")
112
121
  return { refused: screened.reason, ...(screened.extension !== undefined ? { extension: screened.extension } : {}) };
122
+ if (screened.kind === "settled")
123
+ return { refused: decisionText(screened.deny) ?? `${subject} was refused` };
113
124
  const r = screened.answer;
114
125
  if (r?.action === "deny")
115
126
  return { refused: screening.deniedReason(r), ...(screened.answeredBy !== undefined ? { extension: screened.answeredBy } : {}) };
116
127
  if (r !== undefined && policyCannotAnswer(r, decidedBy))
117
128
  return { refused: `a PreToolUse hook requires a person's approval for ${subject}, and this approval was the deployment's policy — not executed` };
118
- const context = r?.additionalContext;
119
- return { args: r?.updatedInput !== undefined ? r.updatedInput : args, admit: () => {
120
- if (context)
121
- preToolContexts.set(toolCallId, [context]);
129
+ const contexts = screened.contexts;
130
+ return { admit: () => {
131
+ if (contexts.length > 0)
132
+ preToolContexts.set(toolCallId, [...contexts]);
122
133
  } };
123
134
  };
124
135
  }
@@ -30,8 +30,9 @@ export declare function deploymentCanRerootChild(deps: Pick<RunnerDeps, "executi
30
30
  */
31
31
  export declare function childPlacementOf(env: Pick<ExecutionEnv, "canonicalPath">, childRoot: string, asked: string | undefined, callerRoot: string): Promise<ChildPlacement>;
32
32
  /** A delegated leg's placement: the place asked for is the hint (a minted worktree, an explicit cwd, the caller's own cwd)
33
- * — or, for a worktree the factory mints itself (`isolation`), that worktree on the caller's host (a remote environment's
34
- * is another namespace). A leg no delegation caller placed (no `callerRoot`) has no placement and reads nothing. */
33
+ * — or, for a worktree the factory mints itself (`isolation`), that worktree on the caller's host when the environment's
34
+ * paths are the host's (`pathsAreHostLocal`; any other environment's is another namespace). A leg no delegation caller
35
+ * placed (no `callerRoot`) has no placement and reads nothing. */
35
36
  export declare function childPlacementOnLeg(env: ExecutionEnv, internals: Pick<RunInternals, "isolation" | "parentCwd"> & {
36
37
  readonly callerRoot: string;
37
38
  }, root: string): Promise<ChildPlacement>;
@@ -66,7 +67,7 @@ export type ChainInstallationGap = "absent" | "misaligned" | "invalid";
66
67
  * installing those entries anywhere else (the chain's top leg, this leg) would move what they protect. Entries whose rules
67
68
  * do not depend on it, and installed entries, never need a record.
68
69
  */
69
- export declare function chainInstallationGaps(chain: readonly ToolPolicy[], installations: ChainInstallations, rebase: (p: string) => string): Array<{
70
+ export declare function chainInstallationGaps(chain: readonly (ToolPolicy | undefined)[], installations: ChainInstallations, rebase: (p: string) => string): Array<{
70
71
  readonly position: number;
71
72
  readonly gap: ChainInstallationGap;
72
73
  }>;
@@ -90,7 +91,7 @@ export declare function chainPolicyOnLeg(cfg: {
90
91
  leg: PathRuleBases;
91
92
  chainTop: PathRuleBases;
92
93
  placement: ChildPlacement | undefined;
93
- chain: readonly ToolPolicy[];
94
+ chain: readonly (ToolPolicy | undefined)[];
94
95
  installations: ChainInstallations;
95
96
  rebase: (p: string) => string;
96
97
  }): {
@@ -98,13 +99,11 @@ export declare function chainPolicyOnLeg(cfg: {
98
99
  chained: (policy: ToolPolicy, position: number) => ToolPolicy;
99
100
  };
100
101
  /** The installation record of a chain entry (its root and home), `null` for an entry with no path rules installed. */
101
- export declare function installationRecordOf(policy: ToolPolicy): {
102
+ export declare function installationRecordOf(policy: ToolPolicy | undefined): {
102
103
  readonly root: string;
103
104
  readonly home?: string;
104
105
  } | null;
105
106
  /** What a leg hands its children about anchors (data half): the chain's top leg's anchors — the person's global / session
106
107
  * rows and every `~/` row anchor there — and where each entry handed down was installed, position for position (a chain
107
108
  * re-supplied uninstalled is installed there again; absent when no entry is an installation). */
108
- export declare function chainAnchorRecords(chainTop: PathRuleBases, chain: readonly {
109
- readonly policy: ToolPolicy;
110
- }[]): Pick<InheritedGate, "pathRuleAnchors" | "pathRuleInstallations">;
109
+ export declare function chainAnchorRecords(chainTop: PathRuleBases, chain: NonNullable<InheritedGate["parentConstraints"]>): Pick<InheritedGate, "pathRuleAnchors" | "pathRuleInstallations">;
@@ -1,4 +1,4 @@
1
- import { isRemoteExecutionEnv } from "../remote-env.js";
1
+ import { pathsAreHostLocal } from "../remote-env.js";
2
2
  import { validatePath } from "../effective-path-target.js";
3
3
  import { installPolicyAnchors, installationAnchorsOf, installedFrom } from "../path-rule-binding.js";
4
4
  import { CheckpointError } from "../checkpoint-store.js";
@@ -23,7 +23,7 @@ export async function childPlacementOf(env, childRoot, asked, callerRoot) {
23
23
  return root === tree || root.startsWith(tree.endsWith(sep) ? tree : tree + sep) ? "caller_tree" : "elsewhere";
24
24
  }
25
25
  export function childPlacementOnLeg(env, internals, root) {
26
- const asked = internals.isolation === "worktree" ? (isRemoteExecutionEnv(env) ? undefined : root) : internals.parentCwd;
26
+ const asked = internals.isolation === "worktree" ? (pathsAreHostLocal(env) ? root : undefined) : internals.parentCwd;
27
27
  return childPlacementOf(env, root, asked, internals.callerRoot);
28
28
  }
29
29
  export function worktreeNotHonored(cwd) {
@@ -64,7 +64,7 @@ function recordedInstallation(installations, chainLength, position, rebase) {
64
64
  }
65
65
  export function chainInstallationGaps(chain, installations, rebase) {
66
66
  return chain.flatMap((policy, position) => {
67
- if (!dependsOnInstallation(policy))
67
+ if (policy === undefined || !dependsOnInstallation(policy))
68
68
  return [];
69
69
  const r = recordedInstallation(installations, chain.length, position, rebase);
70
70
  return typeof r === "string" ? [{ position, gap: r }] : [];
@@ -90,18 +90,18 @@ export function chainPolicyOnLeg(cfg) {
90
90
  const own = (policy) => {
91
91
  if (policy === undefined)
92
92
  return undefined;
93
- const position = cfg.placement === "elsewhere" ? -1 : cfg.chain.findIndex((c) => (installedFrom(c) ?? c) === (installedFrom(policy) ?? policy));
93
+ const position = cfg.placement === "elsewhere" ? -1 : cfg.chain.findIndex((c) => c !== undefined && (installedFrom(c) ?? c) === (installedFrom(policy) ?? policy));
94
94
  return position >= 0 ? chained(cfg.chain[position], position) : installPolicyAnchors(policy, cfg.leg);
95
95
  };
96
96
  return { own, chained };
97
97
  }
98
98
  export function installationRecordOf(policy) {
99
- const a = installationAnchorsOf(policy);
99
+ const a = policy !== undefined ? installationAnchorsOf(policy) : undefined;
100
100
  return a?.root === undefined ? null : { root: a.root, ...(a.home !== undefined ? { home: a.home } : {}) };
101
101
  }
102
102
  export function chainAnchorRecords(chainTop, chain) {
103
103
  return {
104
104
  ...(chainTop.root !== undefined ? { pathRuleAnchors: { root: chainTop.root, ...(chainTop.home !== undefined ? { home: chainTop.home } : {}) } } : {}),
105
- ...(chain.some((pc) => installationAnchorsOf(pc.policy)?.root !== undefined) ? { pathRuleInstallations: chain.map((pc) => installationRecordOf(pc.policy)) } : {}),
105
+ ...(chain.some((pc) => installationRecordOf(pc.policy) !== null) ? { pathRuleInstallations: chain.map((pc) => installationRecordOf(pc.policy)) } : {}),
106
106
  };
107
107
  }
@@ -25,6 +25,10 @@
25
25
  * ② THE LADDER — here, AFTER a call. Trigger: the rung produced no RULING. Effect: the next rung is asked.
26
26
  * Record: `GateDisposition.classifier.fallback` on every classification this run's own gate decided (an
27
27
  * inherited-ancestor chain carries the form and no attribution) + the throttled `classifier.fallback`.
28
+ * The ladder has ONE terminating law: a rung whose dispatch ended on the provider's rate limit on
29
+ * `rateLimitBreakAfter` classifications in a row is not asked again this run (the decider's retirement,
30
+ * `auto-mode.ts`) — the walk starts behind it, and `classifier.seat_rate_limited` says so once. It is the
31
+ * ladder's own end-of-the-line for a rung, not a second retry beside the brain's backoff.
28
32
  *
29
33
  * They FOLD rather than stack: after a ① SWAP the seat and the main model are the same route, so
30
34
  * {@link classifierLadderRungs} returns ONE rung and ② cannot fire in the same run (and under `"none"`, where
@@ -277,12 +281,16 @@ export declare function classifierReplyAsksAgain(reply: AssistantMessage): boole
277
281
  * and the decider maps the throw to `unavailable` (`error`), as it maps every leg failure; the sibling
278
282
  * side-channel legs (compaction, consolidation) already read an error stop this way. The cap-cut form
279
283
  * (`errorKind: "length_empty"`) is not a failure: it is the empty-at-cap reply the re-ask owns.
284
+ *
285
+ * A failure whose provider status was a 429 (`apiErrorStatus`, stamped by the brain on the terminal of a call whose own
286
+ * backoff ladder ran out) carries `AUTO_MODE_RUNG_RATE_LIMITED_CODE`: the one fact the decider's retirement count reads.
287
+ * Nothing else about the failure changes — it is still the leg failure the decider maps to `unavailable` / `error`.
280
288
  */
281
289
  export declare function classifierReplyFailure(reply: AssistantMessage): Error | undefined;
282
290
  /**
283
291
  * The per-decision READ of a classification, as one seat: the `auto_mode.classified` trace frame (wall time,
284
- * verdict, cause), the ladder's throttled `classifier.fallback` disclosure and the per-model
285
- * `classifier.contract_broken` streak. All are observers — a throwing sink never reaches the gate (the decider
292
+ * verdict, cause), the ladder's throttled `classifier.fallback` disclosure, the per-model
293
+ * `classifier.contract_broken` streak and the decider's one `classifier.seat_rate_limited` report. All are observers — a throwing sink never reaches the gate (the decider
286
294
  * swallows it), and none changes a verdict.
287
295
  *
288
296
  * The frame's `model` is the model the classification RAN ON, which is what the field has always meant (its
@@ -1,9 +1,9 @@
1
1
  import { sameRouteIdentity } from "../../brain/route-adjudicator.js";
2
2
  import { lowestReasoningSeat } from "../../brain/reasoning-request.js";
3
3
  import { AUTO_MODE_CLASSIFIER_CONTRACT_BROKEN_AFTER, AUTO_MODE_CLASSIFIER_LOW_REASONING_BUDGET_TOKENS, AUTO_MODE_CLASSIFIER_MAX_TOKENS, AUTO_MODE_CLASSIFIER_THINK_BUDGET_TOKENS } from "../auto-mode-defaults.js";
4
- import { autoModeClassifierFallbackOf, parseAutoModeResponse } from "../auto-mode.js";
4
+ import { AUTO_MODE_RUNG_RATE_LIMITED_CODE, autoModeClassifierFallbackOf, parseAutoModeResponse } from "../auto-mode.js";
5
5
  import { classifierUnavailableDispositionOf } from "../classifier-unavailable-arm.js";
6
- import { DEFAULT_TIER_ORDER, expandTiers, resolveTaskModel, roleSpecNamesModel } from "../roles.js";
6
+ import { catalogModel, DEFAULT_TIER_ORDER, isReceivedCatalog, receiveModelCatalog, receiveRoleMap, resolveTaskModel, roleSpecNamesModel } from "../roles.js";
7
7
  import { emitTrace } from "../trace.js";
8
8
  import { deliverEngineNotice } from "../types.js";
9
9
  export function classifierLadderRungs(knob, classifier, main) {
@@ -22,7 +22,8 @@ function sameRouteQuietly(a, b) {
22
22
  export const CLASSIFIER_ROLE_DEFAULT_REASONS = Object.freeze(["tier_below_main", "tier_table", "role_fallback", "main_only", "role_unresolvable"]);
23
23
  export function classifierSeatModel(args) {
24
24
  const { main } = args;
25
- const deps = normalizeSeatDeps(args.deps);
25
+ const normalized = normalizeSeatDeps(args.deps);
26
+ const deps = { ...normalized, roles: receiveRoleMap(normalized.roles, "RunnerDeps.roles") };
26
27
  if (roleSpecNamesModel(deps.roles?.classifier)) {
27
28
  try {
28
29
  return { model: resolveTaskModel({ modelRole: "classifier" }, deps).model };
@@ -45,20 +46,28 @@ export function classifierSeatModel(args) {
45
46
  }
46
47
  }
47
48
  export function normalizeSeatDeps(deps) {
48
- if (deps.tiers === undefined)
49
+ if (deps.tiers === undefined || isReceivedCatalog(deps.models))
49
50
  return deps;
50
51
  try {
51
- return { ...deps, models: expandTiers(deps.models, deps.tiers) };
52
+ return { ...deps, ...receiveModelCatalog(deps.models, deps.tiers, "RunnerDeps") };
52
53
  }
53
54
  catch {
54
55
  return deps;
55
56
  }
56
57
  }
58
+ function tierModelQuietly(deps, tier) {
59
+ try {
60
+ return catalogModel(tier, deps.models, `tiers.${tier}`);
61
+ }
62
+ catch {
63
+ return undefined;
64
+ }
65
+ }
57
66
  export function tierIndexOf(deps, model) {
58
67
  if (deps.tiers === undefined || Object.keys(deps.tiers).length === 0 || deps.models === undefined)
59
68
  return undefined;
60
69
  for (let i = DEFAULT_TIER_ORDER.length - 1; i >= 0; i--) {
61
- const m = deps.models[DEFAULT_TIER_ORDER[i]];
70
+ const m = tierModelQuietly(deps, DEFAULT_TIER_ORDER[i]);
62
71
  if (m !== undefined && sameRouteQuietly(m, model))
63
72
  return i;
64
73
  }
@@ -68,7 +77,7 @@ function tierBelowMain(deps, main) {
68
77
  const mainTier = tierIndexOf(deps, main);
69
78
  if (mainTier === undefined)
70
79
  return undefined;
71
- const bound = DEFAULT_TIER_ORDER.map((tier) => deps.models?.[tier]);
80
+ const bound = DEFAULT_TIER_ORDER.map((tier) => tierModelQuietly(deps, tier));
72
81
  for (let i = mainTier + 1; i < bound.length; i++) {
73
82
  const m = bound[i];
74
83
  if (m !== undefined && !sameRouteQuietly(m, main))
@@ -191,6 +200,23 @@ function classifierContractAnnouncer(args) {
191
200
  streak.delete(`${landed}:${record.modelUsed}`);
192
201
  };
193
202
  }
203
+ function announceRateLimitBreak(args, brk) {
204
+ deliverEngineNotice(args.onNotice, {
205
+ code: "classifier.seat_rate_limited",
206
+ message: `the auto-mode classifier model "${brk.model}" was rate limited (HTTP 429) on ${brk.consecutive} consecutive classifications — ` +
207
+ `for the rest of this run it is not asked again, and every gated call is judged on "${brk.to}" without waiting for it. ` +
208
+ "Raise that model's rate limit at its gateway, or name a different `classifier` role; RunnerDeps.autoMode.rateLimitBreakAfter sets how many in a row it takes.",
209
+ detail: {
210
+ model: brk.model,
211
+ to: brk.to,
212
+ rung: brk.rung,
213
+ consecutive: brk.consecutive,
214
+ ...(args.sessionId !== undefined ? { sessionId: args.sessionId } : {}),
215
+ ...(args.runId !== undefined ? { runId: args.runId } : {}),
216
+ },
217
+ ...(args.sessionId !== undefined ? { sessionId: args.sessionId } : {}),
218
+ });
219
+ }
194
220
  export const CLASSIFIER_OFF_SEAT = { reasoning: "off", maxTokens: AUTO_MODE_CLASSIFIER_MAX_TOKENS };
195
221
  export const CLASSIFIER_LOW_SEAT = { reasoning: "low", maxTokens: AUTO_MODE_CLASSIFIER_MAX_TOKENS + AUTO_MODE_CLASSIFIER_LOW_REASONING_BUDGET_TOKENS };
196
222
  export const CLASSIFIER_THINK_SEAT = { reasoning: "low", maxTokens: AUTO_MODE_CLASSIFIER_MAX_TOKENS + AUTO_MODE_CLASSIFIER_THINK_BUDGET_TOKENS };
@@ -236,7 +262,10 @@ export function classifierReplyFailure(reply) {
236
262
  return new Error("the auto-mode classifier request was aborted");
237
263
  if (reply.stopReason !== "error" || reply.errorKind === "length_empty")
238
264
  return undefined;
239
- return new Error(`the auto-mode classifier request failed: ${reply.errorMessage ?? "the model leg reported an error with no message"}`);
265
+ const failure = new Error(`the auto-mode classifier request failed: ${reply.errorMessage ?? "the model leg reported an error with no message"}`);
266
+ if (reply.apiErrorStatus === 429)
267
+ failure.code = AUTO_MODE_RUNG_RATE_LIMITED_CODE;
268
+ return failure;
240
269
  }
241
270
  export function classifierRoundObserver(args) {
242
271
  const announceFallback = classifierFallbackAnnouncer(args);
@@ -256,5 +285,7 @@ export function classifierRoundObserver(args) {
256
285
  }));
257
286
  announceFallback(info.classifier);
258
287
  countContract(info);
288
+ for (const brk of info.rateLimitBreaks ?? [])
289
+ announceRateLimitBreak(args, brk);
259
290
  };
260
291
  }
@@ -1,10 +1,12 @@
1
1
  import { checkedAgentConfigDir } from "../agent-config-dir.js";
2
2
  import { checkedMediaByteCap } from "../media-byte-cap.js";
3
+ import { checkedImageProcessorSeat } from "../image-downsample.js";
3
4
  import { receiptRefusal, receiveOwnProperties, refuseProxy } from "../own-property-receipt.js";
4
5
  import { assertNoRetiredRunnerDeps } from "./retired-runner-deps.js";
5
6
  import { copyReadDenySeat, READ_DENY_DEPLOYMENT_SEATS } from "../read-face-seats.js";
6
7
  import { receiveHostFloor } from "../host-floor.js";
7
8
  import { holdOwnCredentialValues } from "../secret-env.js";
9
+ import { receivePeerSeat } from "../peer-seat.js";
8
10
  export function retainRunnerDeps(deps) {
9
11
  const words = { subject: "RunnerDeps", unit: "seat", moment: "at new Runner" };
10
12
  refuseProxy(deps, words);
@@ -12,12 +14,15 @@ export function retainRunnerDeps(deps) {
12
14
  const retained = receiveOwnProperties(deps, words);
13
15
  checkedAgentConfigDir(retained.agentConfigDir, "RunnerDeps.agentConfigDir");
14
16
  checkedMediaByteCap(retained.mediaByteCapBytes, "RunnerDeps.mediaByteCapBytes");
17
+ checkedImageProcessorSeat(retained.imageProcessor, "RunnerDeps.imageProcessor");
15
18
  for (const seat of READ_DENY_DEPLOYMENT_SEATS) {
16
19
  if (Object.hasOwn(retained, seat))
17
20
  Object.defineProperty(retained, seat, { value: copyReadDenySeat(Reflect.get(retained, seat)), enumerable: true, writable: true, configurable: true });
18
21
  }
19
22
  if (Object.hasOwn(retained, "hostFloor"))
20
23
  Object.defineProperty(retained, "hostFloor", { value: receiveHostFloor(Reflect.get(retained, "hostFloor")), enumerable: true, writable: true, configurable: true });
24
+ if (Object.hasOwn(retained, "peerSeat"))
25
+ Object.defineProperty(retained, "peerSeat", { value: receivePeerSeat(Reflect.get(retained, "peerSeat"), "RunnerDeps.peerSeat"), enumerable: true, writable: true, configurable: true });
21
26
  let consolidationKey;
22
27
  try {
23
28
  const chat = retained.memoryConsolidationDriver?.chat;
@@ -37,7 +37,7 @@ import type { Checkpoint, CheckpointState, CheckpointStore, CheckpointToken, Pen
37
37
  import type { ExecutionOutcomeRecordWord } from "../checkpoint-execution-record.js";
38
38
  import type { ClearedProjectionLedger, MicroCompactMachine, OccurrenceIndex } from "../context-edit.js";
39
39
  import type { ModBus } from "../mods/kernel/index.js";
40
- import type { LegModBus, LegMods, ModChainLink } from "../mods/stations.js";
40
+ import type { LegModBus, LegMods } from "../mods/stations.js";
41
41
  import type { HookInvocationIdentity, OrgGateVerdict, PermissionDeniedPayload, PostToolBatchCall, ToolGateInput } from "../hooks.js";
42
42
  import type { MaterializedMcp } from "../mcp.js";
43
43
  import type { MemoryEngine } from "../memory-engine/engine.js";
@@ -474,7 +474,6 @@ export interface Prepared {
474
474
  readonly refused: string;
475
475
  readonly extension?: string;
476
476
  } | {
477
- readonly args: unknown;
478
477
  readonly admit: () => void;
479
478
  }>;
480
479
  /** The leg's `tool.call` station (`mods/tool-call.ts`) — every execution of a call passes it; absent when no handler hangs on the event. */
@@ -570,6 +569,8 @@ export interface Prepared {
570
569
  /** The pending commits of this leg's attachment frames, settled by the transcript-append receipt sink — the one place
571
570
  * an attachment's read effects are applied. Always present. */
572
571
  attachmentDelivery: import("../user-attachment.js").AttachmentDelivery;
572
+ /** The run's once-per-run account of an image sent unprocessed over the soft target — the tool-result seat's and the leg's (task images, attachments). */
573
+ imageUnprocessed: (bytes: number) => void;
573
574
  /** The leg's one file reader — the Read tool's own (one read state, one set of disclosure windows and counters),
574
575
  * handed to the leg's other carriers of a file. Present iff hands are mounted. */
575
576
  modelFileReader?: import("../../tools/fs/fs-read.js").ModelFileReader;
@@ -1219,15 +1220,23 @@ export interface Prepared {
1219
1220
  /** The posture composition's run-local half (the newest carrier's protection slot; the row last composed for). */
1220
1221
  postureFrameRef: import("../auto-mode-directive.js").PostureFrameRef;
1221
1222
  /** G1 通告层 — narrow getter over the process task registry: THIS run's visible live background tasks
1222
- * (pending / running / parked under the same owner/scope/session identity the TaskOutput/TaskStop tools
1223
- * use), EVERY one (`TaskRegistry.liveTasks`), as a projection (id/description/status — never
1224
- * handles/env/abort). Read by the post-compact listing (which caps what it renders), the resume's orphan
1225
- * diff and the stop hook's `backgroundTasks` view. */
1226
- listBackgroundTasks: () => Array<{
1223
+ * (pending / running / parked under the same owner/scope/session identity the TaskStop tool
1224
+ * uses), EVERY one (`TaskRegistry.liveTasks`), as a projection (id/description/status and the row's read handle,
1225
+ * `TaskRegistry.readHandleOf` — never handles/env/abort). Read by the post-compact listing (which caps what it
1226
+ * renders), the resume's orphan diff and the stop hook's `backgroundTasks` view. `{ settled: true }` = the same rows with
1227
+ * the finished ones too (`TaskRegistry.list`) — the whole-session notification loss's table, where a finished task's
1228
+ * lost frame is the likeliest loss and its read handle the one way back. */
1229
+ listBackgroundTasks: (opts?: {
1230
+ settled?: true;
1231
+ }) => Array<{
1227
1232
  id: string;
1228
1233
  description?: string;
1229
1234
  status: string;
1235
+ read?: string;
1230
1236
  }>;
1237
+ /** One task's read handle under the same identity (`TaskRegistry.readHandleOf`) — a live or terminal row this leg reaches;
1238
+ * `undefined` for an unreachable id or a row with nothing to read. Read by a dropped notification's disclosure line. */
1239
+ taskReadHandleOf: (taskId: string) => string | undefined;
1231
1240
  /** The parent-run subagent-retain ledger (present ONLY when `spec.retainSubagentSessions`
1232
1241
  * is enabled). The Runner disposes it (abort in-flight resumes + unpin + release every retained child
1233
1242
  * session) in the task's terminal `finally` — same UNCONDITIONAL posture as the background-agent reap:
@@ -1374,13 +1383,15 @@ export interface PrepareResume {
1374
1383
  * (`"always"`): a child inherits it and cannot lift it. `permissionMode` is the ceiling a child's own
1375
1384
  * declaration is clamped under.
1376
1385
  * - **Opaque half** (`parentConstraints`): each ancestor's live caller `ToolPolicy` plus its FROZEN
1377
- * `onAsk`, ancestors first — and, for a hook-wired ancestor, a SECOND entry: its PreToolUse screening
1378
- * face folded into a `ToolPolicy` (`createPreToolUseConstraintPolicy`), carrying its own frozen
1379
- * approver/mandate/env axes (the `preToolUse`/`hookEnv` fields below). Folded AFTER the child's own caller policy and BEFORE the trailing
1380
- * deny-narrowing re-check, each wrapper resolving its own `ask` via the ancestor's frozen approver —
1381
- * so a parent `ask` never widens into a child auto-allow, and a parent `allow{updatedInput}` rewrite
1382
- * is still re-checked by the child's narrowing layers. NOT serializable: a durable resume must
1383
- * re-supply it via `resumeStream(..., internals)` (see {@link CheckpointState.inheritedGate}).
1386
+ * `onAsk`, ancestors first — and, for a mods-wired ancestor, a SECOND entry: its installation (the bus
1387
+ * its admission mounted, `installation`), carrying its own frozen approver/mandate/env axes. A caller
1388
+ * policy is folded AFTER the child's own caller policy and BEFORE the trailing deny-narrowing re-check,
1389
+ * each wrapper resolving its own `ask` via the ancestor's frozen approver — so a parent `ask` never
1390
+ * widens into a child auto-allow, and a parent `allow{updatedInput}` rewrite is still re-checked by the
1391
+ * child's narrowing layers. An installation judges the child's calls at the child's gate, on the
1392
+ * installation's own bus (`classic.PreToolUse` at phase 1, `tool.check` at the verdict read), its
1393
+ * question settled under the same frozen axes. NOT serializable: a durable resume must re-supply it via
1394
+ * `resumeStream(..., internals)` (see {@link CheckpointState.inheritedGate}).
1384
1395
  *
1385
1396
  * Chain assembly is single-sited in prepareTask's ctx injection (`inheritedGateForChildren`): upstream
1386
1397
  * chain + THIS task's own contribution (its session-rule snapshot, its RESOLVED caller policy —
@@ -1489,9 +1500,18 @@ export interface InheritedGate extends InheritedAutoModeFace {
1489
1500
  * same frozen `onAsk` — no mandate). It is a CONSERVATIVE descendant-side mandate: whether or not a given ask would actually
1490
1501
  * have parked at the ancestor (the regime may be scoped), the durable-park semantics cannot be
1491
1502
  * reconstructed in a delegated child's context — so a wrapper seeing `ask` under this flag denies
1492
- * fail-closed (tighten-only holds) instead of resolving synchronously. */
1493
- parentConstraints?: ReadonlyArray<{
1503
+ * fail-closed (tighten-only holds) instead of resolving synchronously.
1504
+ *
1505
+ * Each entry is exactly ONE of two kinds: a caller policy (`policy`), or a screening installation
1506
+ * (`installation` — the bus a leg's admission mounted, or {@link import("../mods/stations.js").admitModChain}'s on a
1507
+ * cross-process re-supply). A chain naming both, neither, or an installation no engine admission mounted is refused. */
1508
+ parentConstraints?: ReadonlyArray<({
1494
1509
  policy: ToolPolicy;
1510
+ installation?: undefined;
1511
+ } | {
1512
+ installation: LegModBus;
1513
+ policy?: undefined;
1514
+ }) & {
1495
1515
  onAsk?: OnAsk;
1496
1516
  durableMandate?: boolean;
1497
1517
  /** The CONTENT-ask twin of `durableMandate`, frozen from the QUESTION seat (`spec.onQuestion ??
@@ -1543,26 +1563,14 @@ export interface InheritedGate extends InheritedAutoModeFace {
1543
1563
  };
1544
1564
  };
1545
1565
  /**
1546
- * Set by the constraint mint's caller on an entry whose `policy` is the folded form of an ancestor's
1547
- * `classic.PreToolUse` chain (`createPreToolUseConstraintPolicy`): the chain that leg's admission MOUNTED, as the
1548
- * entry declares it. It is read for ONE thing — a declaration that this entry carries a chain: beside a policy the
1549
- * mint did not make, a declared judging `tool.check` handler is refused (`config.mods_invalid`; the guard has no bus to
1550
- * be raised on), and such an entry is never treated as a caller policy (it licenses no ask grant). It is NEVER the
1551
- * entry's identity: the chain an entry stands for is read off the bus its policy was minted over (that bus's admission
1552
- * recorded it), so a host may hand any list here (`[]` included, or none) without moving what is judged.
1553
- *
1554
- * The identity (`sameInstallation`) is that chain plus the context the entry's questions are settled in — the frozen
1555
- * approver, the two durable mandates, the environment, the classifier instance — and it is the CONSERVATIVE test:
1556
- * two chains over the same registrations in a different order, or a re-built registration object, compare unequal,
1557
- * and a bus no engine admission mounted is no leg's installation. Chain assembly does not re-append a leg already on
1558
- * the chain; a descendant's own gate stands in for an entry only when that identity holds under no mandate (the
1559
- * pass-through of its `classic.PreToolUse`, the skip of its `tool.check`); any other entry is judged on both events
1560
- * under its own context — judged twice rather than skipped, never toward a missed one.
1561
- */
1562
- mods?: readonly ModChainLink[];
1563
- /**
1564
- * The environment this screening face was installed against — the source of the `HookEnvCapabilities`
1565
- * handed to it, compared BY REFERENCE, `undefined` when the installation had no env face. Part of the
1566
+ * The environment this installation was installed against — the source of the `HookEnvCapabilities` face its
1567
+ * `classic.PreToolUse` e carries (`env`), compared BY REFERENCE, `undefined` when the installation had no env. The
1568
+ * installation identity (`sameInstallation`) is the chain its bus's admission recorded plus the context its questions are
1569
+ * settled in — the frozen approver, the two durable mandates, this environment, the classifier instance — the
1570
+ * CONSERVATIVE test: two chains over the same registrations in a different order, or a re-built registration object,
1571
+ * compare unequal. Chain assembly does not re-append a leg already on the chain; a descendant's own gate stands in for an
1572
+ * installation only when that identity holds under no mandate; any other is judged on both events under its own context
1573
+ * — judged twice rather than skipped, never toward a missed one. Part of the
1566
1574
  * installation's identity for the same reason the frozen approver is (HIGH): a face that
1567
1575
  * resolves paths through `ctx.env` answers a different question in a different environment, so an
1568
1576
  * ancestor running against the deployment's tree and a descendant running in an isolated worktree are
@@ -1634,6 +1642,11 @@ export interface RunInternals {
1634
1642
  * releases the lease when its materialization is disposed — see `mcp-connection-pool.ts`. Trusted, never a TaskSpec field.
1635
1643
  */
1636
1644
  mcpPool?: import("../mcp-connection-pool.js").McpConnectionPool;
1645
+ /** This leg's host seats by declaration name: a `{ kind: "host" }` server of `TaskSpec.mcp` / `ResumeTaskConfig.mcp` dials through its
1646
+ * seat (mcp-host-seat.ts); a declaration with no seat fails its dial (`config.mcp_host_seat_missing`), a seat with no declaration is
1647
+ * announced once (`config.mcp_host_seat_undeclared`). The leg's own: a delegated child is handed the seats of the host servers it
1648
+ * is declared (inherited or its definition's own), a retained child's snapshot keeps none (its waker's seats ride each wake). Trusted, never a TaskSpec field. */
1649
+ mcpHostSeats?: ReadonlyMap<string, import("../mcp-host-seat.js").McpHostSeat>;
1637
1650
  /**
1638
1651
  * The tool-selector layers of the run that spawned this leg — its ceiling ({@link ToolFaceSnapshot.selector}`.layers`): this
1639
1652
  * leg's selector is these layers plus its own `allowTools` / `excludeTools`, so nothing a child names can widen what its
@@ -2103,6 +2116,9 @@ export interface RunInternals {
2103
2116
  * per run" true across the lanes that forward. A caller value is overridden like the refs beside it;
2104
2117
  * absent ⇒ the door mints a per-object one, so containment never depends on the threading. */
2105
2118
  forwardScope?: import("./forward-sink.js").ForwardSinkScope;
2119
+ /** The door's receipt of this leg's `mcp` / `a2a` declarations — ENGINE-owned, taken by `Runner.runTaskStream` at the call for every
2120
+ * leg (a caller value is overridden): the leg's door judges this copy, and the references it names are what the leg holds (peer-seat.ts). */
2121
+ receivedPeers?: import("../locked-config.js").ReceivedPeerDeclarations;
2106
2122
  /**
2107
2123
  * The Runner's per-session read-file-state seats (CC parity: readFileState is
2108
2124
  * session-scoped). Always set by the Runner's own prepare call (overriding any caller value, like
@@ -2349,10 +2365,11 @@ export interface ResolvedWorkspace {
2349
2365
  cwd: string;
2350
2366
  /** True only for an accepted `isolation: "worktree"` request (⇒ `cwd` is this agent's own worktree). */
2351
2367
  isolated: boolean;
2352
- /** True when the task's execution env is REMOTE: `cwd` then names a path INSIDE the remote
2353
- * target (a per-task sandbox on the shape-(d) exemption leg, e.g. `/workspace`), which does not exist —
2354
- * or names an unrelated directory — on the host. `isolated && !remote` is the only combination under
2355
- * which `cwd` is a host path a consumer may diff / merge / remove. */
2368
+ /** True when the task's execution env does not declare its paths the host's (`pathsAreHostLocal` is false — whatever
2369
+ * interface drives it): `cwd` then names a path INSIDE that target (a per-task sandbox on the shape-(d) exemption leg,
2370
+ * e.g. `/workspace`), which does not exist — or names an unrelated directory — on the host. A host lane driven through
2371
+ * the remote seam reads `false`. `isolated && !remote` is the only combination under which `cwd` is a host path a
2372
+ * consumer may diff / merge / remove. */
2356
2373
  remote: boolean;
2357
2374
  /** Where a delegated child's environment placed it against where its caller asked; absent on a leg no delegation
2358
2375
  * caller placed. */
@@ -2432,7 +2449,7 @@ export interface SuspendSaga {
2432
2449
  suspendLoopCapHit: (count: number, cap: number | undefined, detail: string) => boolean;
2433
2450
  /** The `suspendVM` target by CAPABILITY, or undefined. */
2434
2451
  suspendableEnv: RemoteExecutionEnv | undefined;
2435
- /** The park-only remote target (non-suspendable, externally durable), or undefined. */
2452
+ /** The park-only remote target (declares `suspendable: false`: externally durable), or undefined. */
2436
2453
  parkOnlyRemoteEnv: RemoteExecutionEnv | undefined;
2437
2454
  /** The park-only identity capture (snapshotId stripped, `restoreMode: "park_only"`). */
2438
2455
  parkOnlyHandle: (env: RemoteExecutionEnv) => WorkspaceHandle;
@@ -2551,6 +2568,7 @@ export interface RunState {
2551
2568
  turnResponseModel: string | undefined;
2552
2569
  /** B15 三期使能:postToolBatch 的本回合聚集批(每回合边界消费并重置 — 回合语义,故归 turn)。 */
2553
2570
  toolBatch: PostToolBatchCall[];
2571
+ completed?: readonly import("../mods/lifecycle-stations.js").CompletedTurn[];
2554
2572
  };
2555
2573
  counters: {
2556
2574
  /** How many LIMIT-APPROACH frames have been injected this run (0..2). Also the
@@ -2864,6 +2882,9 @@ export interface RunnerSelfSeat {
2864
2882
  canRerootChild?(): boolean;
2865
2883
  /** Fire `RunnerDeps.onTaskOutcome` through the swallow-guarded chokepoint (thin compositions emit at their terminal state). */
2866
2884
  emitTaskOutcome(outcome: TaskOutcome): void;
2885
+ /** A hold, on the peer seat THIS runner's legs ask, of the references `declared` names — taken by a keeper of declarations
2886
+ * outside a leg (a retained child's ledger entry), released by it once (peer-seat.ts `holdPeerDeclarations`). */
2887
+ holdDeclarations(declared: import("../peer-seat.js").PeerDeclarations): import("../peer-seat.js").PeerDeclarationHold;
2867
2888
  /** Run a task to completion. `internals` is the TRUSTED run-scoped channel (never a TaskSpec field). */
2868
2889
  runTask(spec: TaskSpec, internals?: RunInternals): Promise<TaskResult>;
2869
2890
  /** Streaming form of {@link RunnerSelfSeat.runTask}; `resume` is the run loop's resume plan, `internals` the trusted channel. */