@sema-agent/core 7.58.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 (519) hide show
  1. package/CHANGELOG.md +1340 -0
  2. package/README.md +6 -4
  3. package/dist/agents/agent-definition.d.ts +7 -0
  4. package/dist/agents/agent-definition.js +12 -0
  5. package/dist/agents/agent-transcript-tool.d.ts +2 -1
  6. package/dist/agents/agent-transcript-tool.js +3 -1
  7. package/dist/agents/cc-peer-directory.js +8 -8
  8. package/dist/agents/child-model-seat.d.ts +4 -2
  9. package/dist/agents/child-model-seat.js +9 -4
  10. package/dist/agents/cumulative-stats.js +0 -1
  11. package/dist/agents/inherited-tool-pool.d.ts +26 -1
  12. package/dist/agents/inherited-tool-pool.js +22 -0
  13. package/dist/agents/peer-directory.d.ts +9 -0
  14. package/dist/agents/peer-directory.js +6 -2
  15. package/dist/agents/retain-ledger.d.ts +11 -1
  16. package/dist/agents/retain-ledger.js +13 -2
  17. package/dist/agents/roster-store.d.ts +1 -1
  18. package/dist/agents/roster-store.js +3 -1
  19. package/dist/agents/send-message-tool.d.ts +8 -19
  20. package/dist/agents/send-message-tool.js +32 -50
  21. package/dist/agents/subagent.d.ts +51 -17
  22. package/dist/agents/subagent.js +150 -112
  23. package/dist/agents/tool-filter.d.ts +1 -3
  24. package/dist/agents/tool-filter.js +4 -12
  25. package/dist/bench/metrics.d.ts +3 -5
  26. package/dist/bench/metrics.js +0 -1
  27. package/dist/brain/anthropic.js +161 -45
  28. package/dist/brain/degrading.js +3 -1
  29. package/dist/brain/errors.d.ts +9 -3
  30. package/dist/brain/errors.js +7 -1
  31. package/dist/brain/failover.js +2 -1
  32. package/dist/brain/open-responses.js +3 -3
  33. package/dist/brain/openai.js +103 -53
  34. package/dist/brain/provider-dialect.d.ts +11 -0
  35. package/dist/brain/provider-dialect.js +5 -2
  36. package/dist/brain/reasoning-request.js +5 -4
  37. package/dist/brain/reasoning.d.ts +19 -0
  38. package/dist/brain/reasoning.js +17 -2
  39. package/dist/brain/request-route.d.ts +4 -1
  40. package/dist/brain/request-route.js +4 -1
  41. package/dist/brain/route-adjudicator.d.ts +84 -18
  42. package/dist/brain/route-adjudicator.js +90 -22
  43. package/dist/brain/route-conformance.js +1 -1
  44. package/dist/brain/status-sink.d.ts +7 -1
  45. package/dist/brain/status-sink.js +6 -0
  46. package/dist/brain/stream-engine.js +84 -49
  47. package/dist/brain/stream-shared.d.ts +30 -0
  48. package/dist/brain/stream-shared.js +34 -1
  49. package/dist/brain/timeout.d.ts +65 -6
  50. package/dist/brain/timeout.js +111 -11
  51. package/dist/core/a2a.d.ts +15 -5
  52. package/dist/core/a2a.js +34 -19
  53. package/dist/core/account-row.d.ts +61 -0
  54. package/dist/core/account-row.js +51 -0
  55. package/dist/core/advisor-verdict.d.ts +2 -1
  56. package/dist/core/advisor-verdict.js +1 -1
  57. package/dist/core/agent-definition.d.ts +20 -0
  58. package/dist/core/allow-entry.d.ts +20 -6
  59. package/dist/core/allow-entry.js +17 -7
  60. package/dist/core/approval-object.d.ts +29 -15
  61. package/dist/core/approval-object.js +47 -19
  62. package/dist/core/artifact-host.d.ts +0 -2
  63. package/dist/core/artifact-host.js +0 -1
  64. package/dist/core/auto-compaction.js +1 -1
  65. package/dist/core/auto-mode-defaults.d.ts +8 -0
  66. package/dist/core/auto-mode-defaults.js +1 -0
  67. package/dist/core/auto-mode-rebuild.d.ts +2 -1
  68. package/dist/core/auto-mode.d.ts +39 -4
  69. package/dist/core/auto-mode.js +63 -12
  70. package/dist/core/background-agent-store.d.ts +26 -4
  71. package/dist/core/background-agent-store.js +3 -2
  72. package/dist/core/background-shell.d.ts +12 -1
  73. package/dist/core/background-shell.js +12 -0
  74. package/dist/core/checkpoint-requirements.d.ts +13 -1
  75. package/dist/core/checkpoint-requirements.js +3 -1
  76. package/dist/core/checkpoint-store.d.ts +66 -25
  77. package/dist/core/checkpoint-store.js +22 -9
  78. package/dist/core/child-clamp-seats.d.ts +29 -0
  79. package/dist/core/child-clamp-seats.js +56 -1
  80. package/dist/core/compliance.d.ts +3 -3
  81. package/dist/core/compliance.js +1 -1
  82. package/dist/core/credential-echo.d.ts +52 -0
  83. package/dist/core/credential-echo.js +65 -0
  84. package/dist/core/credential-vocabulary.d.ts +13 -3
  85. package/dist/core/credential-vocabulary.js +12 -4
  86. package/dist/core/cross-boundary-taint.d.ts +4 -5
  87. package/dist/core/effective-path-target.d.ts +8 -2
  88. package/dist/core/effective-path-target.js +8 -3
  89. package/dist/core/engine-notice.d.ts +156 -23
  90. package/dist/core/engine-notice.js +19 -5
  91. package/dist/core/frame-settlement.d.ts +5 -0
  92. package/dist/core/frame-settlement.js +4 -0
  93. package/dist/core/gate-fold.js +8 -6
  94. package/dist/core/gate-lanes.js +47 -12
  95. package/dist/core/gate-outcome.d.ts +32 -3
  96. package/dist/core/gate-outcome.js +19 -1
  97. package/dist/core/governance-codes.d.ts +17 -1
  98. package/dist/core/governance-codes.js +25 -0
  99. package/dist/core/hands-band-screen.js +0 -1
  100. package/dist/core/hands-band.d.ts +0 -3
  101. package/dist/core/hooks.d.ts +70 -59
  102. package/dist/core/hooks.js +125 -80
  103. package/dist/core/image-admission.d.ts +106 -52
  104. package/dist/core/image-admission.js +184 -56
  105. package/dist/core/image-downsample.d.ts +36 -69
  106. package/dist/core/image-downsample.js +111 -73
  107. package/dist/core/integer-option.d.ts +21 -0
  108. package/dist/core/integer-option.js +13 -0
  109. package/dist/core/locked-config.d.ts +59 -5
  110. package/dist/core/locked-config.js +82 -50
  111. package/dist/core/mailbox-store.d.ts +45 -1
  112. package/dist/core/mailbox-store.js +53 -9
  113. package/dist/core/mcp-call-meta.d.ts +2 -2
  114. package/dist/core/mcp-call-meta.js +9 -10
  115. package/dist/core/mcp-failure.d.ts +122 -20
  116. package/dist/core/mcp-failure.js +73 -5
  117. package/dist/core/mcp-host-seat.d.ts +92 -0
  118. package/dist/core/mcp-host-seat.js +131 -0
  119. package/dist/core/mcp-probe.d.ts +7 -2
  120. package/dist/core/mcp-probe.js +7 -2
  121. package/dist/core/mcp-server-link.d.ts +22 -1
  122. package/dist/core/mcp-server-link.js +25 -1
  123. package/dist/core/mcp-server-spec.d.ts +38 -9
  124. package/dist/core/mcp-server-spec.js +55 -21
  125. package/dist/core/mcp.d.ts +27 -12
  126. package/dist/core/mcp.js +105 -76
  127. package/dist/core/memory-admission.d.ts +23 -6
  128. package/dist/core/memory-admission.js +19 -9
  129. package/dist/core/memory-engine/consolidation-driver.d.ts +2 -4
  130. package/dist/core/memory-engine/consolidation-driver.js +3 -3
  131. package/dist/core/memory-engine/consolidation.d.ts +4 -0
  132. package/dist/core/memory-engine/consolidation.js +1 -0
  133. package/dist/core/memory-engine/content-origin.d.ts +13 -0
  134. package/dist/core/memory-engine/content-origin.js +21 -3
  135. package/dist/core/memory-engine/delegation-settlement.js +5 -12
  136. package/dist/core/memory-engine/distiller.js +2 -2
  137. package/dist/core/memory-engine/dual-root.d.ts +50 -1
  138. package/dist/core/memory-engine/dual-root.js +44 -1
  139. package/dist/core/memory-engine/engine.d.ts +67 -14
  140. package/dist/core/memory-engine/engine.js +384 -212
  141. package/dist/core/memory-engine/export-bundle.d.ts +23 -0
  142. package/dist/core/memory-engine/export-bundle.js +23 -4
  143. package/dist/core/memory-engine/file-backend.d.ts +128 -55
  144. package/dist/core/memory-engine/file-backend.js +290 -117
  145. package/dist/core/memory-engine/index.d.ts +3 -2
  146. package/dist/core/memory-engine/index.js +2 -1
  147. package/dist/core/memory-engine/layout.d.ts +59 -11
  148. package/dist/core/memory-engine/layout.js +190 -40
  149. package/dist/core/memory-engine/memory-backend-contract.d.ts +1 -1
  150. package/dist/core/memory-engine/memory-backend-contract.js +39 -2
  151. package/dist/core/memory-engine/scope-contract.d.ts +13 -3
  152. package/dist/core/memory-engine/scope-contract.js +2 -2
  153. package/dist/core/memory-engine/sync-client.d.ts +51 -9
  154. package/dist/core/memory-engine/sync-client.js +107 -13
  155. package/dist/core/memory-engine/sync-report.d.ts +103 -0
  156. package/dist/core/memory-engine/sync-report.js +119 -0
  157. package/dist/core/memory-engine/sync.d.ts +8 -1
  158. package/dist/core/memory-engine/types.d.ts +6 -0
  159. package/dist/core/mode-policy.d.ts +9 -1
  160. package/dist/core/mode-policy.js +11 -1
  161. package/dist/core/model-receipt.d.ts +39 -0
  162. package/dist/core/model-receipt.js +139 -0
  163. package/dist/core/mods/agent-stations.d.ts +65 -0
  164. package/dist/core/mods/agent-stations.js +105 -0
  165. package/dist/core/mods/classic-events.d.ts +5 -1
  166. package/dist/core/mods/kernel/dispatch.d.ts +5 -1
  167. package/dist/core/mods/kernel/dispatch.js +6 -5
  168. package/dist/core/mods/kernel/events.d.ts +11 -4
  169. package/dist/core/mods/kernel/events.js +11 -7
  170. package/dist/core/mods/kernel/receive.d.ts +5 -0
  171. package/dist/core/mods/kernel/receive.js +10 -0
  172. package/dist/core/mods/kernel/registration.d.ts +4 -0
  173. package/dist/core/mods/kernel/registration.js +3 -0
  174. package/dist/core/mods/lifecycle-stations.d.ts +41 -0
  175. package/dist/core/mods/lifecycle-stations.js +35 -0
  176. package/dist/core/mods/stations.d.ts +73 -60
  177. package/dist/core/mods/stations.js +64 -40
  178. package/dist/core/mods/tool-call.d.ts +10 -4
  179. package/dist/core/mods/tool-call.js +28 -12
  180. package/dist/core/mounted-mcp.d.ts +5 -0
  181. package/dist/core/mounted-mcp.js +2 -2
  182. package/dist/core/namespaced-rule-name.d.ts +7 -1
  183. package/dist/core/namespaced-rule-name.js +13 -2
  184. package/dist/core/oracle-isolation.js +1 -1
  185. package/dist/core/own-property-receipt.d.ts +3 -0
  186. package/dist/core/own-property-receipt.js +3 -0
  187. package/dist/core/parent-spec-seat.d.ts +8 -3
  188. package/dist/core/parent-spec-seat.js +2 -0
  189. package/dist/core/park-selfcheck.js +14 -8
  190. package/dist/core/peer-seat.d.ts +133 -16
  191. package/dist/core/peer-seat.js +319 -42
  192. package/dist/core/permission-rule-consent.d.ts +0 -21
  193. package/dist/core/permission-rule-consent.js +11 -6
  194. package/dist/core/permission-rule-model.d.ts +20 -2
  195. package/dist/core/permission-rule-model.js +8 -7
  196. package/dist/core/present-plan-tool.d.ts +11 -3
  197. package/dist/core/present-plan-tool.js +2 -2
  198. package/dist/core/protocol-http-auth.d.ts +14 -2
  199. package/dist/core/protocol-http-auth.js +16 -7
  200. package/dist/core/read-face-seats.d.ts +7 -5
  201. package/dist/core/read-face-seats.js +4 -1
  202. package/dist/core/redaction-marks.d.ts +4 -3
  203. package/dist/core/redaction-marks.js +2 -2
  204. package/dist/core/remote-env.d.ts +146 -98
  205. package/dist/core/remote-env.js +113 -14
  206. package/dist/core/resume-startup-cause.js +1 -0
  207. package/dist/core/retention.js +37 -12
  208. package/dist/core/retired-keys.d.ts +6 -1
  209. package/dist/core/retired-keys.js +4 -1
  210. package/dist/core/rewrite-rejudge.d.ts +13 -5
  211. package/dist/core/rewrite-rejudge.js +9 -5
  212. package/dist/core/roles.d.ts +69 -3
  213. package/dist/core/roles.js +167 -80
  214. package/dist/core/rule-owner.d.ts +3 -0
  215. package/dist/core/runner/announce-once-ledger.d.ts +5 -4
  216. package/dist/core/runner/announce-once-ledger.js +4 -2
  217. package/dist/core/runner/assemble-result.d.ts +0 -5
  218. package/dist/core/runner/assemble-result.js +0 -1
  219. package/dist/core/runner/call-hook-stations.d.ts +17 -10
  220. package/dist/core/runner/call-hook-stations.js +23 -12
  221. package/dist/core/runner/child-tree.d.ts +7 -8
  222. package/dist/core/runner/child-tree.js +6 -6
  223. package/dist/core/runner/classifier-ladder.d.ts +10 -2
  224. package/dist/core/runner/classifier-ladder.js +39 -8
  225. package/dist/core/runner/construction-doors.js +5 -0
  226. package/dist/core/runner/contracts.d.ts +82 -57
  227. package/dist/core/runner/credential-origin-seat.js +4 -3
  228. package/dist/core/runner/cross-boundary-lane.d.ts +3 -5
  229. package/dist/core/runner/cross-boundary-lane.js +11 -2
  230. package/dist/core/runner/cwd-alignment-probe.d.ts +20 -0
  231. package/dist/core/runner/cwd-alignment-probe.js +21 -0
  232. package/dist/core/runner/decide-continuation.d.ts +2 -2
  233. package/dist/core/runner/env-capability-census.d.ts +15 -20
  234. package/dist/core/runner/env-capability-census.js +25 -34
  235. package/dist/core/runner/file-history-request.d.ts +2 -2
  236. package/dist/core/runner/file-history-request.js +0 -8
  237. package/dist/core/runner/gate-exit.d.ts +87 -11
  238. package/dist/core/runner/gate-exit.js +30 -8
  239. package/dist/core/runner/git-status-frame.d.ts +5 -2
  240. package/dist/core/runner/git-status-frame.js +3 -4
  241. package/dist/core/runner/image-removed-seat.d.ts +12 -0
  242. package/dist/core/runner/image-removed-seat.js +19 -0
  243. package/dist/core/runner/image.d.ts +7 -2
  244. package/dist/core/runner/image.js +14 -8
  245. package/dist/core/runner/inline-image.d.ts +10 -8
  246. package/dist/core/runner/inline-image.js +11 -9
  247. package/dist/core/runner/memory-consolidation-driver.js +5 -5
  248. package/dist/core/runner/park-commit.d.ts +1 -1
  249. package/dist/core/runner/park-commit.js +3 -0
  250. package/dist/core/runner/permission-rule-lanes.js +1 -1
  251. package/dist/core/runner/prepare-ask-lane.d.ts +1 -1
  252. package/dist/core/runner/prepare-ask-lane.js +2 -1
  253. package/dist/core/runner/prepare-boundary-parks.d.ts +2 -2
  254. package/dist/core/runner/prepare-boundary-parks.js +5 -5
  255. package/dist/core/runner/prepare-caps-and-workflow.d.ts +7 -5
  256. package/dist/core/runner/prepare-caps-and-workflow.js +6 -3
  257. package/dist/core/runner/prepare-config-doors.d.ts +6 -1
  258. package/dist/core/runner/prepare-config-doors.js +16 -9
  259. package/dist/core/runner/prepare-context-lane.js +2 -0
  260. package/dist/core/runner/prepare-delegation-surface.d.ts +9 -3
  261. package/dist/core/runner/prepare-delegation-surface.js +5 -4
  262. package/dist/core/runner/prepare-file-history.d.ts +10 -12
  263. package/dist/core/runner/prepare-file-history.js +3 -12
  264. package/dist/core/runner/prepare-gate-stations.d.ts +4 -3
  265. package/dist/core/runner/prepare-gate-stations.js +4 -3
  266. package/dist/core/runner/prepare-hands-readface.d.ts +7 -1
  267. package/dist/core/runner/prepare-hands-readface.js +19 -6
  268. package/dist/core/runner/prepare-inherited-gate.d.ts +6 -7
  269. package/dist/core/runner/prepare-inherited-gate.js +22 -31
  270. package/dist/core/runner/prepare-memory-engine-session.js +1 -1
  271. package/dist/core/runner/prepare-memory.d.ts +2 -2
  272. package/dist/core/runner/prepare-memory.js +12 -19
  273. package/dist/core/runner/prepare-park-ask.d.ts +4 -6
  274. package/dist/core/runner/prepare-park-ask.js +5 -9
  275. package/dist/core/runner/prepare-policy-chain.d.ts +8 -7
  276. package/dist/core/runner/prepare-policy-chain.js +136 -121
  277. package/dist/core/runner/prepare-project-context.d.ts +2 -2
  278. package/dist/core/runner/prepare-project-context.js +10 -7
  279. package/dist/core/runner/prepare-prompt-inputs.d.ts +5 -2
  280. package/dist/core/runner/prepare-prompt-inputs.js +10 -20
  281. package/dist/core/runner/prepare-protocol-tools.d.ts +5 -3
  282. package/dist/core/runner/prepare-protocol-tools.js +17 -2
  283. package/dist/core/runner/prepare-run-refs.d.ts +2 -3
  284. package/dist/core/runner/prepare-run-refs.js +4 -1
  285. package/dist/core/runner/prepare-suspend-saga.d.ts +0 -2
  286. package/dist/core/runner/prepare-suspend-saga.js +5 -7
  287. package/dist/core/runner/prepare-task.js +44 -28
  288. package/dist/core/runner/prepare-turn-wiring.d.ts +2 -0
  289. package/dist/core/runner/prepare-turn-wiring.js +7 -2
  290. package/dist/core/runner/prepare-wiring-manifest.d.ts +5 -4
  291. package/dist/core/runner/prepare-wiring-manifest.js +34 -19
  292. package/dist/core/runner/prepare-workspace-restore.js +3 -3
  293. package/dist/core/runner/reply-pricing.d.ts +30 -0
  294. package/dist/core/runner/reply-pricing.js +19 -0
  295. package/dist/core/runner/resume-admission.js +4 -2
  296. package/dist/core/runner/resume-apply.js +6 -1
  297. package/dist/core/runner/resume-checkpoint-screen.js +4 -4
  298. package/dist/core/runner/resume-policy-outcome.js +5 -5
  299. package/dist/core/runner/retired-runner-deps.js +4 -1
  300. package/dist/core/runner/role-seat-defaulted.d.ts +44 -0
  301. package/dist/core/runner/role-seat-defaulted.js +40 -0
  302. package/dist/core/runner/run-attachment-seats.js +3 -3
  303. package/dist/core/runner/run-brain-sinks.js +3 -0
  304. package/dist/core/runner/run-git-lane.d.ts +3 -1
  305. package/dist/core/runner/run-git-lane.js +1 -1
  306. package/dist/core/runner/run-harness-handlers.d.ts +3 -1
  307. package/dist/core/runner/run-harness-handlers.js +3 -1
  308. package/dist/core/runner/run-identity-wiring.d.ts +2 -5
  309. package/dist/core/runner/run-identity-wiring.js +6 -5
  310. package/dist/core/runner/run-leg.d.ts +2 -0
  311. package/dist/core/runner/run-leg.js +63 -56
  312. package/dist/core/runner/run-notification-lane.d.ts +3 -1
  313. package/dist/core/runner/run-notification-lane.js +16 -10
  314. package/dist/core/runner/run-settle-and-teardown.js +5 -1
  315. package/dist/core/runner/run-stop-and-final-verify.d.ts +4 -0
  316. package/dist/core/runner/run-stop-and-final-verify.js +14 -6
  317. package/dist/core/runner/run-terminal-adoption.d.ts +2 -5
  318. package/dist/core/runner/run-terminal-adoption.js +9 -3
  319. package/dist/core/runner/run-turn-boundary.js +89 -77
  320. package/dist/core/runner/runtask.d.ts +8 -5
  321. package/dist/core/runner/runtask.js +21 -13
  322. package/dist/core/runner/side-call-account.d.ts +1 -1
  323. package/dist/core/runner/side-call-account.js +3 -18
  324. package/dist/core/runner/skills-seat.js +2 -2
  325. package/dist/core/runner/sub-agent-deny-lists.d.ts +24 -0
  326. package/dist/core/runner/sub-agent-deny-lists.js +20 -7
  327. package/dist/core/runner/synthetic-tools.js +2 -2
  328. package/dist/core/runner/tool-disclosure.js +0 -2
  329. package/dist/core/runner/tool-end-body.js +2 -2
  330. package/dist/core/runner/tool-face-overlay.d.ts +1 -1
  331. package/dist/core/runner/tool-face-overlay.js +26 -19
  332. package/dist/core/runner/tool-occurrence.d.ts +1 -1
  333. package/dist/core/runner/tool-occurrence.js +2 -2
  334. package/dist/core/runner/tool-result-media-seat.d.ts +9 -1
  335. package/dist/core/runner/tool-result-media-seat.js +17 -1
  336. package/dist/core/runner/turn-attachments.d.ts +29 -27
  337. package/dist/core/runner/turn-attachments.js +27 -42
  338. package/dist/core/runner-deps.d.ts +32 -19
  339. package/dist/core/secret-env.d.ts +35 -4
  340. package/dist/core/secret-env.js +65 -3
  341. package/dist/core/sensitive-path-policy.js +3 -3
  342. package/dist/core/session-policy-store.d.ts +12 -3
  343. package/dist/core/session-policy-store.js +29 -10
  344. package/dist/core/session-store.d.ts +5 -7
  345. package/dist/core/session-store.js +50 -11
  346. package/dist/core/side-query.d.ts +11 -1
  347. package/dist/core/side-query.js +9 -0
  348. package/dist/core/skill-grant-binding.d.ts +31 -2
  349. package/dist/core/skill-grant-binding.js +31 -1
  350. package/dist/core/skill-grant.d.ts +17 -5
  351. package/dist/core/skill-grant.js +24 -6
  352. package/dist/core/store-contracts/background-agent-store-contract.js +27 -0
  353. package/dist/core/store-contracts/checkpoint-store-contract.js +3 -2
  354. package/dist/core/store-contracts/mailbox-store-contract.js +31 -1
  355. package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
  356. package/dist/core/store-contracts/tool-result-store-contract.js +37 -0
  357. package/dist/core/stub-env.d.ts +5 -5
  358. package/dist/core/stub-env.js +11 -1
  359. package/dist/core/swappable-deps.d.ts +17 -43
  360. package/dist/core/swappable-deps.js +15 -5
  361. package/dist/core/synthetic-read-verdict.d.ts +1 -1
  362. package/dist/core/synthetic-read-verdict.js +2 -1
  363. package/dist/core/task-event.d.ts +50 -10
  364. package/dist/core/task-notification.d.ts +88 -5
  365. package/dist/core/task-notification.js +146 -17
  366. package/dist/core/task-registry-agent.d.ts +18 -12
  367. package/dist/core/task-registry-agent.js +19 -6
  368. package/dist/core/task-registry-monitor.d.ts +7 -0
  369. package/dist/core/task-registry-monitor.js +28 -1
  370. package/dist/core/task-registry-shared.d.ts +43 -3
  371. package/dist/core/task-registry-shared.js +21 -7
  372. package/dist/core/task-registry-workflow.js +1 -1
  373. package/dist/core/task-registry.d.ts +50 -35
  374. package/dist/core/task-registry.js +64 -23
  375. package/dist/core/task-result.d.ts +3 -12
  376. package/dist/core/task-spec.d.ts +15 -7
  377. package/dist/core/task-stream.d.ts +1 -1
  378. package/dist/core/terminal-cause.d.ts +10 -0
  379. package/dist/core/tool-catalog-entries.js +1 -1
  380. package/dist/core/tool-check-reading.d.ts +1 -0
  381. package/dist/core/tool-check-reading.js +3 -3
  382. package/dist/core/tool-face-reader.d.ts +7 -6
  383. package/dist/core/tool-face-reader.js +4 -3
  384. package/dist/core/tool-name-aliases.d.ts +19 -0
  385. package/dist/core/tool-name-aliases.js +54 -2
  386. package/dist/core/tool-policy.d.ts +21 -4
  387. package/dist/core/tool-policy.js +1 -1
  388. package/dist/core/tool-registry.d.ts +5 -5
  389. package/dist/core/tool-registry.js +2 -2
  390. package/dist/core/tool-result-store.d.ts +88 -5
  391. package/dist/core/tool-result-store.js +51 -12
  392. package/dist/core/tool-roster.d.ts +112 -5
  393. package/dist/core/tool-roster.js +42 -1
  394. package/dist/core/tool-spec.d.ts +23 -5
  395. package/dist/core/trace.d.ts +0 -1
  396. package/dist/core/types.d.ts +5 -5
  397. package/dist/core/types.js +2 -2
  398. package/dist/core/untrusted-text.js +1 -1
  399. package/dist/core/user-attachment.d.ts +10 -5
  400. package/dist/core/user-attachment.js +15 -7
  401. package/dist/core/wiring-manifest.d.ts +6 -3
  402. package/dist/engine/compaction/compaction.js +29 -3
  403. package/dist/engine/execution-env/node-execution-env.d.ts +11 -5
  404. package/dist/engine/execution-env/node-execution-env.js +21 -13
  405. package/dist/engine/harness/agent-harness.d.ts +26 -3
  406. package/dist/engine/harness/agent-harness.js +49 -16
  407. package/dist/engine/harness/messages.d.ts +3 -1
  408. package/dist/engine/harness/messages.js +3 -2
  409. package/dist/engine/harness/types.d.ts +119 -28
  410. package/dist/engine/llm/rejected-images.d.ts +46 -0
  411. package/dist/engine/llm/rejected-images.js +54 -0
  412. package/dist/engine/llm/tool-turns.d.ts +2 -1
  413. package/dist/engine/llm/types.d.ts +18 -7
  414. package/dist/engine/loop/agent-loop.d.ts +20 -12
  415. package/dist/engine/loop/agent-loop.js +205 -36
  416. package/dist/engine/loop/types.d.ts +12 -3
  417. package/dist/engine/lsp/node-lsp-manager.d.ts +3 -3
  418. package/dist/engine/lsp/node-lsp-manager.js +32 -13
  419. package/dist/engine/session/path-to-root.d.ts +38 -0
  420. package/dist/engine/session/path-to-root.js +39 -0
  421. package/dist/engine/session/storage-base.js +4 -21
  422. package/dist/index.d.ts +35 -21
  423. package/dist/index.js +26 -17
  424. package/dist/internal/harness-types.d.ts +1 -1
  425. package/dist/internal/harness.d.ts +1 -0
  426. package/dist/internal/llm.d.ts +1 -0
  427. package/dist/orchestration/run-workflow-tool.d.ts +9 -3
  428. package/dist/orchestration/run-workflow-tool.js +59 -29
  429. package/dist/orchestration/workflow-governance.d.ts +1 -1
  430. package/dist/orchestration/workflow-governance.js +2 -1
  431. package/dist/orchestration/workflow-observe.d.ts +17 -1
  432. package/dist/orchestration/workflow-observe.js +20 -0
  433. package/dist/orchestration/workflow-types.d.ts +32 -7
  434. package/dist/orchestration/workflow.d.ts +4 -0
  435. package/dist/orchestration/workflow.js +762 -491
  436. package/dist/prompts/default.d.ts +1 -10
  437. package/dist/prompts/default.js +0 -2
  438. package/dist/shell/counting-pass.d.ts +50 -0
  439. package/dist/shell/counting-pass.js +502 -0
  440. package/dist/shell/lex.d.ts +4 -2
  441. package/dist/shell/lex.js +93 -34
  442. package/dist/shell/shell-words.d.ts +1 -1
  443. package/dist/shell/shell-words.js +7 -6
  444. package/dist/stores/file/background-agent-store.d.ts +1 -1
  445. package/dist/stores/file/background-agent-store.js +3 -1
  446. package/dist/stores/file/checkpoint-store.d.ts +127 -2
  447. package/dist/stores/file/checkpoint-store.js +19 -14
  448. package/dist/stores/file/file-history-store.d.ts +1 -1
  449. package/dist/stores/file/file-history-store.js +3 -1
  450. package/dist/stores/file/index.d.ts +4 -3
  451. package/dist/stores/file/index.js +17 -8
  452. package/dist/stores/file/mailbox-store.d.ts +1 -1
  453. package/dist/stores/file/mailbox-store.js +9 -11
  454. package/dist/stores/file/memory-store.d.ts +1 -1
  455. package/dist/stores/file/memory-store.js +3 -1
  456. package/dist/stores/file/session-policy-store.d.ts +1 -1
  457. package/dist/stores/file/session-policy-store.js +3 -1
  458. package/dist/stores/file/session-store.d.ts +1 -1
  459. package/dist/stores/file/session-store.js +3 -1
  460. package/dist/stores/file/shared-ledger.d.ts +26 -0
  461. package/dist/stores/file/shared-ledger.js +38 -9
  462. package/dist/stores/file/tool-result-store.d.ts +20 -2
  463. package/dist/stores/file/tool-result-store.js +74 -6
  464. package/dist/stores/file/usage-window-store.d.ts +1 -1
  465. package/dist/stores/file/usage-window-store.js +3 -1
  466. package/dist/stores/file/workflow-journal-store.d.ts +1 -11
  467. package/dist/stores/file/workflow-journal-store.js +3 -2
  468. package/dist/tools/fs/containment-face.d.ts +5 -0
  469. package/dist/tools/fs/encoding.d.ts +13 -4
  470. package/dist/tools/fs/encoding.js +17 -2
  471. package/dist/tools/fs/fs-bash-background-text.d.ts +7 -0
  472. package/dist/tools/fs/fs-bash-background-text.js +1 -0
  473. package/dist/tools/fs/fs-bash.d.ts +14 -4
  474. package/dist/tools/fs/fs-bash.js +29 -35
  475. package/dist/tools/fs/fs-pdf.d.ts +2 -2
  476. package/dist/tools/fs/fs-pdf.js +26 -21
  477. package/dist/tools/fs/fs-read.d.ts +5 -4
  478. package/dist/tools/fs/fs-read.js +35 -18
  479. package/dist/tools/fs/fs-search-tools.js +4 -1
  480. package/dist/tools/fs/fs-shared.d.ts +11 -13
  481. package/dist/tools/fs/fs-shared.js +11 -7
  482. package/dist/tools/fs/fs-write.js +5 -5
  483. package/dist/tools/fs/index.d.ts +14 -8
  484. package/dist/tools/fs/index.js +13 -5
  485. package/dist/tools/fs/program-read-model.d.ts +13 -0
  486. package/dist/tools/fs/program-read-model.js +15 -0
  487. package/dist/tools/fs/program-read-model.rows.js +1 -1
  488. package/dist/tools/fs/read-deny.d.ts +13 -10
  489. package/dist/tools/fs/read-deny.js +25 -5
  490. package/dist/tools/fs/read-floor.d.ts +62 -0
  491. package/dist/tools/fs/read-floor.js +58 -0
  492. package/dist/tools/fs/removal-targets.d.ts +9 -4
  493. package/dist/tools/fs/removal-targets.js +17 -9
  494. package/dist/tools/fs/search.d.ts +3 -3
  495. package/dist/tools/fs/search.js +4 -4
  496. package/dist/tools/fs/shell-read-check.d.ts +1 -1
  497. package/dist/tools/fs/shell-read-check.js +2 -1
  498. package/dist/tools/fs/shell-read-judge.d.ts +16 -8
  499. package/dist/tools/fs/shell-read-judge.js +10 -6
  500. package/dist/tools/fs/shell-read-plan.d.ts +6 -1
  501. package/dist/tools/fs/shell-read-plan.js +22 -15
  502. package/dist/tools/fs/shell-read-start.js +1 -0
  503. package/dist/tools/fs/shell-reentry-text.d.ts +15 -1
  504. package/dist/tools/fs/shell-reentry-text.js +25 -3
  505. package/dist/tools/monitor.d.ts +9 -4
  506. package/dist/tools/monitor.js +17 -8
  507. package/dist/tools/scheduler-tools.js +42 -4
  508. package/dist/tools/web.d.ts +0 -10
  509. package/dist/tools/web.js +1 -4
  510. package/package.json +5 -2
  511. package/test/export-surface.snapshot.json +161 -21
  512. package/wire-changes/core-stores-sql@7.59.0.json +29 -0
  513. package/wire-changes/core-stores-sql@7.60.0.json +30 -0
  514. package/wire-changes/core@7.59.0.json +2459 -0
  515. package/wire-changes/core@7.60.0.json +3274 -0
  516. package/wire-changes/mods-kernel@7.59.0.json +29 -0
  517. package/wire-changes/mods-kernel@7.60.0.json +62 -0
  518. package/wire-changes/primitives@7.59.0.json +29 -0
  519. package/wire-changes/primitives@7.60.0.json +30 -0
@@ -1,14 +1,28 @@
1
1
  import { canonicalize } from "./canonical-json.js";
2
2
  import { licenseCovers } from "./tool-policy.js";
3
+ import { pathTargetResolutionOf } from "./effective-path-target.js";
3
4
  import { parkedSkillApprovalRefusal } from "./skill-grant.js";
4
- import { toolIdentityOf } from "./tool-roster.js";
5
+ import { engineMountedRow, toolDeclarationDigestOf, toolIdentityOf } from "./tool-roster.js";
5
6
  import { inlineUntrusted } from "./untrusted-text.js";
7
+ import { isPlainRecord } from "./mods/kernel/receive.js";
6
8
  export const APPROVAL_TARGET_ROLES = Object.freeze(["protective", "declared"]);
9
+ const ALWAYS_MINTED = Object.freeze(["capabilityId", "contractId", "shapeDigest", "implementationRevision", "family", "declarationDigest"]);
10
+ const isString = (v) => typeof v === "string";
11
+ const absentOr = (shape) => (v) => v === undefined || shape(v);
12
+ const isSlot = (v) => isPlainRecord(v) && typeof v["param"] === "string";
13
+ const TOOL_MEMBER_SHAPES = Object.freeze({
14
+ capabilityId: isString, contractId: isString, shapeDigest: isString, implementationRevision: isString, family: isString, declarationDigest: isString,
15
+ engineMounted: absentOr((v) => v === true), pathTarget: absentOr(isSlot), hostTarget: absentOr(isSlot),
16
+ });
17
+ const unreadToolMembers = (row) => Object.keys(TOOL_MEMBER_SHAPES).filter((k) => !TOOL_MEMBER_SHAPES[k](row[k]));
18
+ const wholeTool = (row) => unreadToolMembers(row).length === 0;
7
19
  export function approvalObjectOf(row) {
8
- const { capabilityId, contractId, shapeDigest, implementationRevision, family, pathTarget, hostTarget, targets, targetReads, boundGrantDigest } = row;
9
- const carried = [capabilityId, contractId, shapeDigest, implementationRevision].some((m) => m !== undefined);
20
+ const { targets, targetReads, boundGrantDigest } = row;
21
+ const tool = wholeTool(row)
22
+ ? { capabilityId: row.capabilityId, contractId: row.contractId, shapeDigest: row.shapeDigest, implementationRevision: row.implementationRevision, ...(row.engineMounted === true ? { engineMounted: true } : {}), family: row.family, ...(row.pathTarget !== undefined ? { pathTarget: row.pathTarget } : {}), ...(row.hostTarget !== undefined ? { hostTarget: row.hostTarget } : {}), declarationDigest: row.declarationDigest }
23
+ : { missing: unreadToolMembers(row) };
10
24
  return {
11
- ...(carried ? { tool: { capabilityId, contractId, shapeDigest, implementationRevision, family, pathTarget, hostTarget } } : {}),
25
+ tool,
12
26
  ...(targets !== undefined ? { targets } : {}),
13
27
  ...(targetReads !== undefined ? { targetReads } : {}),
14
28
  ...(boundGrantDigest !== undefined ? { grants: boundGrantDigest } : {}),
@@ -24,33 +38,47 @@ export function approvalTargetsOf(reading, reads) {
24
38
  return { ...(Object.keys(targets).length > 0 ? { targets } : {}), ...(reads !== undefined ? { targetReads: Object.fromEntries(reads.map((r) => [r.key, r.landing])) } : {}) };
25
39
  }
26
40
  export const APPROVAL_STATION_MEMBERS = Object.freeze({
27
- claim: Object.freeze(["grants"]),
41
+ claim: Object.freeze(["tool", "grants"]),
28
42
  session: Object.freeze(["tool"]),
29
43
  execution: Object.freeze(["tool", "grants", "targets"]),
30
44
  });
31
- const IDENTITY_MEMBERS = Object.freeze(["capabilityId", "contractId", "shapeDigest", "implementationRevision"]);
45
+ const IDENTITY_MEMBERS = Object.freeze(["capabilityId", "contractId", "shapeDigest", "implementationRevision", "engineMounted"]);
46
+ const FACE_MEMBERS = Object.freeze(["family", "pathTarget", "hostTarget"]);
32
47
  const shown = (s) => `"${inlineUntrusted(s, 240)}"`;
33
48
  const vetoed = (name, why) => `The approved tool call "${name}" was not executed: ${why}, so the approval does not cover it (resume.target_moved). This approval is spent — the call has to be re-issued: its new card shows what it would act on now.`;
34
- function faceKey(family, pt, ht) {
35
- const slot = pt === undefined ? null : { param: pt.param, access: pt.access, aliases: [...(pt.aliases ?? [])], base: pt.base ?? "cwd", absent: pt.absent ?? "none", patternParam: pt.patternParam ?? null, skillScopeEligible: pt.skillScopeEligible === true };
36
- return canonicalize({ family: family ?? null, pathTarget: slot, hostTarget: ht === undefined ? null : { param: ht.param } });
49
+ function faceKey(face) {
50
+ const resolved = (k) => {
51
+ const pt = face.pathTarget;
52
+ if (k !== "pathTarget")
53
+ return face[k] ?? null;
54
+ return pt === undefined ? null : { param: pt.param, access: pt.access, aliases: [...(pt.aliases ?? [])], ...pathTargetResolutionOf(pt), patternParam: pt.patternParam ?? null, skillScopeEligible: pt.skillScopeEligible === true };
55
+ };
56
+ return canonicalize(Object.fromEntries(FACE_MEMBERS.map((k) => [k, resolved(k)])));
37
57
  }
38
- function judgeTool(row, live) {
58
+ function judgeTool(row, live, station) {
59
+ const bound = approvalObjectOf(row).tool;
60
+ if ("missing" in bound) {
61
+ const why = `carries no whole record of the tool it was asked for (${bound.missing.join(", ")} missing or not in its shape — a row parked by an engine before it recorded them, a call parked while its tool was off the leg's roster, or a damaged row), so which tool the approval covers cannot be read`;
62
+ if (station !== "claim")
63
+ return { member: "tool", disposition: "veto", code: "resume.target_moved", message: vetoed(row.toolName, `its checkpoint row ${why}`) };
64
+ return { member: "tool", disposition: "refuse_pending", code: "checkpoint.unsupported_version", message: `this checkpoint's pending approval ${why}, and it is not redeemed; the checkpoint stays pending: deny it so the model can re-issue the call (a row that also predates the ask's origin is refused a deny too), finish a row an earlier engine parked on a worker of that release, or expire it` };
65
+ }
66
+ if (station === "claim")
67
+ return undefined;
39
68
  const entry = live.tool;
40
69
  if (entry === undefined)
41
70
  return { member: "tool", disposition: "reopen", code: "resume.tool_unavailable", message: `the approved tool "${row.toolName}" is no longer available on resume — refusing to continue as if it ran; the checkpoint is reopened for a retry with the tool present` };
42
- const bound = approvalObjectOf(row).tool;
43
- if (bound === undefined)
44
- return undefined;
45
- const id = toolIdentityOf(entry);
71
+ const id = { ...toolIdentityOf(entry), engineMounted: engineMountedRow(entry) ? true : undefined };
46
72
  const differ = IDENTITY_MEMBERS.filter((k) => bound[k] !== id[k]);
47
73
  if (differ.length > 0) {
48
- const named = differ.map((k) => (bound[k] === undefined ? `${k} (missing on the row)` : k)).join(", ");
49
- return { member: "tool", disposition: "reopen", code: "resume.tool_contract_mismatch", message: `the approved tool "${row.toolName}" on this leg is not the tool the approval was minted against (${named} differ) — refusing to execute a replacement wearing the name; the checkpoint is reopened for a retry with the original tool present` };
74
+ return { member: "tool", disposition: "reopen", code: "resume.tool_contract_mismatch", message: `the approved tool "${row.toolName}" on this leg is not the tool the approval was minted against (${differ.map((k) => (k === "engineMounted" ? "mount site" : k)).join(", ")} differ) — refusing to execute a replacement wearing the name; the checkpoint is reopened for a retry with the original tool present` };
75
+ }
76
+ if (faceKey(bound) !== faceKey(entry)) {
77
+ return { member: "tool", disposition: "veto", code: "resume.target_moved", message: vetoed(row.toolName, "the tool's face (its display family, or the path target or URL slot it declares) changed after the approval") };
50
78
  }
51
- if (faceKey(bound.family, bound.pathTarget, bound.hostTarget) === faceKey(entry.family, entry.pathTarget, entry.hostTarget))
79
+ if (bound.declarationDigest === toolDeclarationDigestOf(entry))
52
80
  return undefined;
53
- return { member: "tool", disposition: "veto", code: "resume.target_moved", message: vetoed(row.toolName, "the tool's face (its display family, or the path target or URL slot it declares) changed after the approval") };
81
+ return { member: "tool", disposition: "veto", code: "resume.target_moved", message: vetoed(row.toolName, "the tool's declaration (what it does, reaches and trusts: its effect, egress, irreversibility, content origin, boundary legs, rule face or model gate) changed after the approval") };
54
82
  }
55
83
  function judgeTargets(row, live) {
56
84
  if ((row.targets === undefined && row.targetReads === undefined) || ("decided" in live && !licenseCovers(row.boundInputHash, live.decided)))
@@ -104,7 +132,7 @@ function judgeGrants(row, live, station) {
104
132
  }
105
133
  export function judgeApprovalObject(row, live, station) {
106
134
  for (const member of APPROVAL_STATION_MEMBERS[station]) {
107
- const miss = member === "tool" ? judgeTool(row, live) : member === "targets" ? judgeTargets(row, live) : judgeGrants(row, live, station === "claim" ? "claim" : "execution");
135
+ const miss = member === "tool" ? judgeTool(row, live, station) : member === "targets" ? judgeTargets(row, live) : judgeGrants(row, live, station === "claim" ? "claim" : "execution");
108
136
  if (miss !== undefined)
109
137
  return miss;
110
138
  }
@@ -77,8 +77,6 @@ export type ResultCodeTableCoversEveryHostFailure = AssertAllKeysHandled<Exclude
77
77
  /** The one result code that is not a host word: the host threw, timed out, or answered outside its contract. */
78
78
  export declare const ARTIFACT_HOST_ERROR_CODE = "artifact.host_error";
79
79
  export type ArtifactResultCode = (typeof ARTIFACT_FAILURE_RESULT_CODE)[ArtifactHostFailureCode] | typeof ARTIFACT_HOST_ERROR_CODE;
80
- /** The `details.type` card the Artifact tool mints on every result. */
81
- export declare const ARTIFACT_CARD = "artifact";
82
80
  /**
83
81
  * What a host declares at mount time. Invariants (a violation refuses the mount and announces
84
82
  * `config.artifact_host_invalid`): `actions` non-empty, duplicate-free, within {@link ARTIFACT_ACTIONS},
@@ -38,7 +38,6 @@ export const ARTIFACT_FAILURE_RESULT_CODE = {
38
38
  refused: "artifact.refused",
39
39
  };
40
40
  export const ARTIFACT_HOST_ERROR_CODE = "artifact.host_error";
41
- export const ARTIFACT_CARD = "artifact";
42
41
  const isPositiveInt = (v) => typeof v === "number" && Number.isSafeInteger(v) && v > 0;
43
42
  const wordOf = (set, v) => typeof v === "string" && set.includes(v);
44
43
  export function readArtifactHostCapabilities(host) {
@@ -470,7 +470,7 @@ export async function maybeCompact(opts) {
470
470
  const restatedEpoch = identityNow !== undefined ? selectCompactionEpoch(current, identityNow.layers, identityNow.sourceRevision) : undefined;
471
471
  const restatedListings = await opts.session.getAnnouncedListing().catch(() => undefined);
472
472
  if (opts.signal?.aborted === true) {
473
- throw Object.assign(new Error("compaction cancelled before commit — the abort signal fired during the summary call; nothing was persisted"), opts.manualCancelSignal?.aborted === true ? { [COMPACTION_MANUAL_CANCEL_FLAG]: true } : {});
473
+ throw Object.assign(new Error("compaction cancelled before commit — the abort signal fired after the summary was produced; nothing was persisted"), opts.manualCancelSignal?.aborted === true ? { [COMPACTION_MANUAL_CANCEL_FLAG]: true } : {});
474
474
  }
475
475
  await opts.session.appendCompaction(summary, firstKeptEntryId, summaryTokensBefore, {
476
476
  ...(details ?? {}),
@@ -16,6 +16,14 @@ export declare const AUTO_MODE_DEFAULT_TIMEOUT_MS = 180000;
16
16
  * would only make the person wait out the rung's budget and hear "timed out" for a failure that was not one.
17
17
  */
18
18
  export declare const AUTO_MODE_CLASSIFIER_MAX_RETRIES = 4;
19
+ /**
20
+ * How many CONSECUTIVE classifications must end on a rung's rate limit (an HTTP 429 that outlived the brain's own
21
+ * {@link AUTO_MODE_CLASSIFIER_MAX_RETRIES} backoffs) before that rung is not asked again for the rest of the run, when
22
+ * `RunnerDeps.autoMode.rateLimitBreakAfter` is omitted. Each such classification has already slept the whole
23
+ * backoff ladder, so the number is the wall time a rate-limited seat may still cost before the walk starts behind it:
24
+ * three, the same count the denial limit hands a run to a person after.
25
+ */
26
+ export declare const AUTO_MODE_RATE_LIMIT_BREAK_AFTER_DEFAULT = 3;
19
27
  /**
20
28
  * What an arming RECORDING that carries no `timeoutMs` meant when it was written: the default of its day. Every
21
29
  * recipe minted since the deadline moved to 60 s MATERIALISES its bound, so an absent recorded knob dates the
@@ -1,5 +1,6 @@
1
1
  export const AUTO_MODE_DEFAULT_TIMEOUT_MS = 180_000;
2
2
  export const AUTO_MODE_CLASSIFIER_MAX_RETRIES = 4;
3
+ export const AUTO_MODE_RATE_LIMIT_BREAK_AFTER_DEFAULT = 3;
3
4
  export const AUTO_MODE_RECORDED_ABSENT_TIMEOUT_MS = 15_000;
4
5
  export const AUTO_MODE_DEFAULT_WINDOW_MAX_ENTRIES = 40;
5
6
  export const AUTO_MODE_DEFAULT_WINDOW_MAX_CHARS = 2_000;
@@ -67,7 +67,8 @@ export type AutoModeRebuildResult = {
67
67
  * overrides / settings-deny rules / session context, plus the engine's cross-session lane rule when
68
68
  * the recipe says the arming leg spliced it), the transcript-window bounds and the round-trip
69
69
  * timeout — i.e. every input the ancestor's own `createAutoModeDecider` call had except the model leg.
70
- * A decider carries no state between rounds, so there is no ancestor state to reproduce or to withhold.
70
+ * The rebuilt decider is one rung, which never retires (the rate-limit memory only a rung with another behind it keeps), so it
71
+ * carries no state between rounds and there is no ancestor state to reproduce or to withhold.
71
72
  *
72
73
  * NOT reproduced: this build's PROMPT ASSETS are its own. The recipe records the deployment's
73
74
  * overrides, so the assembled prompt is checked against the digest the arming recorded — a fleet running
@@ -59,6 +59,12 @@ export declare function isAutoModeTimeoutMs(v: unknown): v is number;
59
59
  * refusal carrying `config.auto_mode_timeout_invalid`. There is no OFF spelling: the budget bounds how long a
60
60
  * permission gate waits, and a gate with no bound is not a setting this knob offers. */
61
61
  export declare function autoModeTimeoutMsOf(v: unknown): number;
62
+ /** Read the retirement knob (`RunnerDeps.autoMode.rateLimitBreakAfter` / `AutoModeDeciderOptions.rateLimitBreakAfter`):
63
+ * absent ⇒ {@link AUTO_MODE_RATE_LIMIT_BREAK_AFTER_DEFAULT}; a safe integer of at least 1 ⇒ itself; ANYTHING ELSE
64
+ * (`0`, a negative, a fraction, NaN, ±Infinity, a string, an object) ⇒ a loud refusal carrying
65
+ * `config.auto_mode_rate_limit_break_invalid` — never clamped, never read as the default. There is no OFF
66
+ * spelling: a deployment that wants the seat asked for longer states a larger count. */
67
+ export declare function autoModeRateLimitBreakAfterOf(v: unknown): number;
62
68
  /** The classifier's verdict over one pending `ask`. Every arm may carry the classification's model
63
69
  * attribution ({@link AutoModeClassifierRound}), present iff the decider was wired with a candidate ladder. */
64
70
  export type AutoModeVerdict = ({
@@ -136,6 +142,15 @@ export declare const AUTO_MODE_ROUND_NOT_ASKED_CODE = "auto_mode.round_not_asked
136
142
  export declare function autoModeRoundNotAsked(reason: unknown): Error & {
137
143
  code: string;
138
144
  };
145
+ /**
146
+ * The word for "this rung's dispatch ended on the provider's RATE LIMIT" — an HTTP 429 that outlived the brain's own
147
+ * backoff ladder. A classify hook throws an error carrying this `code` (the same carrier as
148
+ * {@link AUTO_MODE_ROUND_NOT_ASKED_CODE}: a `code` on the thrown error, so any hook — including one this package never
149
+ * constructed — can raise it without importing a constructor). The decider reads it for one thing, the rung's
150
+ * RETIREMENT count (see the header's RATE-LIMIT RETIREMENT); the rung's verdict is the `unavailable` / `error` every
151
+ * leg failure already is.
152
+ */
153
+ export declare const AUTO_MODE_RUNG_RATE_LIMITED_CODE = "auto_mode.rung_rate_limited";
139
154
  /**
140
155
  * Why a rung did not settle the classification, or `undefined` when it SETTLED it and the ladder stops — the
141
156
  * ONE predicate behind the advance (there is no `if (fallback)` arm anywhere).
@@ -276,6 +291,13 @@ export interface AutoModeDeciderOptions<T = void> {
276
291
  * (`config.auto_mode_timeout_invalid`, {@link autoModeTimeoutMsOf}) — never clamped, never read as the
277
292
  * default, and there is no OFF: a permission gate always has a bound. */
278
293
  timeoutMs?: number;
294
+ /** How many CONSECUTIVE classifications must end on one rung's rate limit ({@link AUTO_MODE_RUNG_RATE_LIMITED_CODE})
295
+ * before that rung is not asked again for the rest of this decider's life — see the header's RATE-LIMIT
296
+ * RETIREMENT. Omitted ⇒ {@link AUTO_MODE_RATE_LIMIT_BREAK_AFTER_DEFAULT}. A present value that is not a whole number
297
+ * of at least 1 is REFUSED at construction (`config.auto_mode_rate_limit_break_invalid`,
298
+ * {@link autoModeRateLimitBreakAfterOf}) — never clamped, never read as the default. Inert on a one-rung ladder:
299
+ * only a rung with a rung behind it retires. */
300
+ rateLimitBreakAfter?: number;
279
301
  /**
280
302
  * Fired once per `decide` call with the verdict the gate is about to act on and the wall time it waited
281
303
  * (`ms`, integer ≥ 0; a timed-out classification reads the deadline, one that walked two rungs the whole
@@ -302,6 +324,17 @@ export interface AutoModeClassified {
302
324
  /** The classification's model attribution, present exactly when the decider was wired with a candidate ladder
303
325
  * ({@link AutoModeClassifierRound}) — the same object the verdict carries. */
304
326
  classifier?: AutoModeClassifierRound;
327
+ /** One entry per rung this classification RETIRED — the classification whose rate-limited dispatch was a rung's
328
+ * `rateLimitBreakAfter`-th in a row, so each retired rung is reported on exactly one classification: which rung stopped
329
+ * being asked (`rung`, its model `model`), the model the walk reaches after it (`to`) and the count that tripped it
330
+ * (`consecutive`; always the configured bound). ABSENT on every other classification, including those that walk
331
+ * behind an already-retired rung. */
332
+ rateLimitBreaks?: readonly {
333
+ readonly rung: number;
334
+ readonly model: string;
335
+ readonly to: string;
336
+ readonly consecutive: number;
337
+ }[];
305
338
  }
306
339
  export interface AutoModeDecider {
307
340
  /** Never rejects. Any internal failure surfaces as `unavailable`/`parse_error` (fail-closed). */
@@ -311,9 +344,10 @@ export interface AutoModeDecider {
311
344
  * host implements by hand. */
312
345
  readonly timeoutMs?: number;
313
346
  }
314
- /** The per-run decider: timeout + fail-closed error mapping, nothing carried between rounds. One instance per
315
- * run (it binds the run's model leg and assembled prompt); a round that failed says nothing about the next,
316
- * which asks the model again. */
347
+ /** The per-run decider: timeout + fail-closed error mapping, and nothing carried between rounds but the rate-limit
348
+ * retirement of a rung that has another behind it. One instance per run (it binds the run's model leg and assembled
349
+ * prompt); a round that failed says nothing about the next, which asks the model again — a rung that was
350
+ * rate-limited `rateLimitBreakAfter` times in a row is the one exception. */
317
351
  export declare function createAutoModeDecider<T = void>(opts: AutoModeDeciderOptions<T>): AutoModeDecider;
318
352
  /** The deployment's bounds for the denial limit (`RunnerDeps.autoMode.denialLimit`). Every member
319
353
  * optional; an omitted member takes its CC default. A present member with a bad value is REFUSED
@@ -445,13 +479,14 @@ export interface AutoModeDenialTracker {
445
479
  };
446
480
  }
447
481
  export declare function autoModeDenialLimitOf(v: unknown): Required<AutoModeDenialLimitOptions>;
448
- /** The deployment face's three value knobs, read by their one readers — every leg's prepare runs it while
482
+ /** The deployment face's four value knobs, read by their one readers — every leg's prepare runs it while
449
483
  * `RunnerDeps.autoMode` is present, whatever mode the leg starts in, so a bad knob refuses the run before a steer or a
450
484
  * parent's live ceiling can reach an arming that would have refused it. */
451
485
  export declare function screenAutoModeKnobs(face: {
452
486
  readonly timeoutMs?: unknown;
453
487
  readonly classifierFallback?: unknown;
454
488
  readonly denialLimit?: unknown;
489
+ readonly rateLimitBreakAfter?: unknown;
455
490
  }): void;
456
491
  /** Build the per-run tracker over {@link autoModeDenialLimitOf}'s bounds (a bad knob refuses there). */
457
492
  export declare function createAutoModeDenialTracker(opts?: AutoModeDenialLimitOptions): AutoModeDenialTracker;
@@ -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;
@@ -144,6 +145,19 @@ export interface BackgroundAgentRecord {
144
145
  /** The explicit org WRITE grant that verdict carried; `null` = the org write face was read-only.
145
146
  * Same absent-reads-as-zero rule as {@link admittedOrgScopes} (absent ⇒ `null`). */
146
147
  admittedOrgWriteScope?: string | null;
148
+ /**
149
+ * The tighten-only floor the row's child was BORN under: the clamp table's projection of the spec the spawn built for it
150
+ * (`clampSeatsOf`, both carriers — the parent's clamps that rode it and the definition's own restrictions), the same shape
151
+ * as {@link import("./child-clamp-seats.js").ClampValues}. Written once, by the registration that creates the row
152
+ * (`{}` when nothing was clamped), and never rewritten: a revival builds its spec under the table's fold of THIS floor and
153
+ * the waking caller's own clamps, so whoever wakes the child can narrow it and nobody can widen it. Same reason as the
154
+ * org-admission pair above for why a policy fact rides a lookup-keys-only row: the tier-3 leg rebuilds the spec from the
155
+ * WAKER's mount, so without the row nothing of the spawning run's clamps reaches the revived cycle.
156
+ * ABSENT is not "no floor": a row that states none (written before rows carried it, or by a store that does not keep the
157
+ * member) is not revived — `readClampFloor` reads it as unreadable and both revival doors refuse
158
+ * (`revive.policy_floor_unreadable`). A store persists it verbatim: `{}` reads back as `{}`.
159
+ */
160
+ policyFloor?: import("./child-clamp-seats.js").ClampValues;
147
161
  /** Optimistic-concurrency revision. The writer always CASes with its OWN held rev (design/151
148
162
  * MED-8): a foreign row (stale leftover / another writer) has an unknown rev, so the CAS loses
149
163
  * instead of clobbering. Bumped by the store on every successful `update`. */
@@ -167,14 +181,22 @@ export interface BackgroundAgentRecord {
167
181
  *
168
182
  * Every member is optional on {@link BackgroundAgentRecord} (that is what makes them clearable);
169
183
  * identity, lifecycle, concurrency and GOVERNANCE fields are deliberately absent — a revival
170
- * inherits those. The org-admission freeze (`admittedOrgScopes` / `admittedOrgWriteScope`) is in
171
- * the governance group on purpose: clearing it would hand the next cycle a blank slate, which is
172
- * the widening the freeze exists to prevent.
184
+ * inherits those. The org-admission freeze (`admittedOrgScopes` / `admittedOrgWriteScope`) and the
185
+ * birth floor (`policyFloor`) are in the governance group on purpose: clearing either would hand the
186
+ * next cycle a blank slate, which is the widening each exists to prevent.
173
187
  */
174
188
  export declare const REVIVED_ROW_CLEARED_FIELDS: readonly ["settledAt", "stoppedBy", "completionId", "finalOutput", "finalOutputFull", "error", "errorCode", "errorRetryable", "errorKind", "errorRetryAfterMs", "resultIsPartial", "summary", "recentSteps", "editedFiles", "usage"];
175
189
  /** Erase {@link REVIVED_ROW_CLEARED_FIELDS} from a record a revival is about to write back. */
176
190
  export declare function clearRevivedRowTerminalPayload(record: BackgroundAgentRecord): void;
177
- 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;
178
200
  /** Content-free projection for list reads (design/151 HIGH-1: `summary`/`finalOutput`/`recentSteps`
179
201
  * and friends NEVER ride a list — content is get-by-handle only, behind the full predicate). */
180
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" &&
@@ -6,7 +6,7 @@ import { type StoreFidelity, type Checkpoint, type CheckpointFeature, type Check
6
6
  * had carried beside the one its word now names, and the members added after the table, each a capability a reader
7
7
  * must have. Downstream reads them for display only (`CheckpointError.detail.requires`).
8
8
  */
9
- export declare const REQUIREMENT_WORDS: readonly ["resource", "binding", "token", "orgAdmission", "f012", "realApproval", "face", "requirements_digest", "org_admission_inherited", "org_write_grant", "org_governed", "delegation_provenance", "skill_grants", "skill_card_binding", "hands_coordinates", "hands_home", "path_rule_anchors", "path_rule_installations", "permission_mode", "plan_mode_restore", "persisted_rule_mandate", "deployment_authored", "call_names", "write_face", "denial_limit_fallback", "leg_scope", "tool_ceiling", "tool_lists_judged", "own_tool_lists", "approval_targets", "approval_target_reads", "cross_boundary", "mount_site", "skill_scopes", "run_origin"];
9
+ export declare const REQUIREMENT_WORDS: readonly ["resource", "binding", "token", "orgAdmission", "f012", "realApproval", "face", "requirements_digest", "org_admission_inherited", "org_write_grant", "org_governed", "delegation_provenance", "skill_grants", "skill_card_binding", "hands_coordinates", "hands_home", "path_rule_anchors", "path_rule_installations", "permission_mode", "plan_mode_restore", "persisted_rule_mandate", "deployment_authored", "call_names", "write_face", "denial_limit_fallback", "leg_scope", "tool_ceiling", "tool_lists_judged", "own_tool_lists", "approval_targets", "approval_target_reads", "cross_boundary", "mount_site", "skill_scopes", "run_origin", "tool_declaration"];
10
10
  export type RequirementWord = (typeof REQUIREMENT_WORDS)[number];
11
11
  /** Runtime twin of {@link RequirementWord}. */
12
12
  export declare function isRequirementWord(word: unknown): word is RequirementWord;
@@ -332,6 +332,9 @@ export declare const PENDING_ACTION_REQUIREMENTS: {
332
332
  readonly engineMounted: {
333
333
  readonly word: "mount_site";
334
334
  };
335
+ readonly declarationDigest: {
336
+ readonly word: "tool_declaration";
337
+ };
335
338
  readonly targets: {
336
339
  readonly word: "approval_targets";
337
340
  };
@@ -365,6 +368,9 @@ export declare const PENDING_ACTION_REQUIREMENTS: {
365
368
  readonly kind: {
366
369
  readonly word: "binding";
367
370
  };
371
+ readonly requestedByCallId: {
372
+ readonly ignorable: "shown, never decided (card, listing, transcript or reported count): every read of the name renders, carries transcript or counts";
373
+ };
368
374
  };
369
375
  readonly task_done: {
370
376
  readonly kind: {
@@ -850,6 +856,9 @@ export declare const CHECKPOINT_REQUIREMENTS: {
850
856
  readonly engineMounted: {
851
857
  readonly word: "mount_site";
852
858
  };
859
+ readonly declarationDigest: {
860
+ readonly word: "tool_declaration";
861
+ };
853
862
  readonly targets: {
854
863
  readonly word: "approval_targets";
855
864
  };
@@ -883,6 +892,9 @@ export declare const CHECKPOINT_REQUIREMENTS: {
883
892
  readonly kind: {
884
893
  readonly word: "binding";
885
894
  };
895
+ readonly requestedByCallId: {
896
+ readonly ignorable: "shown, never decided (card, listing, transcript or reported count): every read of the name renders, carries transcript or counts";
897
+ };
886
898
  };
887
899
  readonly task_done: {
888
900
  readonly kind: {
@@ -37,6 +37,7 @@ export const REQUIREMENT_WORDS = Object.freeze([
37
37
  "mount_site",
38
38
  "skill_scopes",
39
39
  "run_origin",
40
+ "tool_declaration",
40
41
  ]);
41
42
  export function isRequirementWord(word) {
42
43
  return typeof word === "string" && REQUIREMENT_WORDS.includes(word);
@@ -135,6 +136,7 @@ export const PENDING_ACTION_REQUIREMENTS = {
135
136
  hostTarget: DECISION_READ,
136
137
  names: { word: "call_names" },
137
138
  engineMounted: { word: "mount_site" },
139
+ declarationDigest: { word: "tool_declaration" },
138
140
  targets: { word: "approval_targets" },
139
141
  targetReads: { word: "approval_target_reads" },
140
142
  hasBidiControls: SHOWN,
@@ -143,7 +145,7 @@ export const PENDING_ACTION_REQUIREMENTS = {
143
145
  },
144
146
  resource_limit: { kind: DECISION_READ, reason: DECISION_READ },
145
147
  review: { kind: DECISION_READ },
146
- plan_review: { kind: { word: "binding" } },
148
+ plan_review: { kind: { word: "binding" }, requestedByCallId: SHOWN },
147
149
  task_done: { kind: DECISION_READ },
148
150
  };
149
151
  export const CHECKPOINT_GATE_REQUIREMENTS = {