@sema-agent/core 7.59.0 → 7.61.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (643) hide show
  1. package/CHANGELOG.md +1169 -0
  2. package/README.md +2 -2
  3. package/dist/agents/agent-definition.d.ts +7 -0
  4. package/dist/agents/agent-definition.js +12 -0
  5. package/dist/agents/agent-transcript-tool.d.ts +4 -3
  6. package/dist/agents/agent-transcript-tool.js +4 -2
  7. package/dist/agents/cascade.d.ts +61 -10
  8. package/dist/agents/cascade.js +60 -20
  9. package/dist/agents/child-model-seat.js +6 -3
  10. package/dist/agents/composition-allowance.d.ts +53 -0
  11. package/dist/agents/composition-allowance.js +49 -0
  12. package/dist/agents/composition-placement.d.ts +29 -0
  13. package/dist/agents/composition-placement.js +24 -0
  14. package/dist/agents/cumulative-stats.d.ts +4 -0
  15. package/dist/agents/cumulative-stats.js +3 -1
  16. package/dist/agents/inherited-tool-pool.d.ts +28 -1
  17. package/dist/agents/inherited-tool-pool.js +22 -0
  18. package/dist/agents/list-agents-tool.d.ts +1 -1
  19. package/dist/agents/peer-notice-route.d.ts +1 -1
  20. package/dist/agents/peer-notice-route.js +4 -3
  21. package/dist/agents/peer-notices.d.ts +4 -4
  22. package/dist/agents/peer-notices.js +8 -4
  23. package/dist/agents/peer-session-drain.d.ts +8 -1
  24. package/dist/agents/peer-session-drain.js +36 -7
  25. package/dist/agents/repair-loop.js +16 -6
  26. package/dist/agents/retain-ledger.d.ts +11 -1
  27. package/dist/agents/retain-ledger.js +16 -3
  28. package/dist/agents/roster-store.d.ts +2 -2
  29. package/dist/agents/roster-store.js +8 -3
  30. package/dist/agents/send-message-tool.d.ts +14 -27
  31. package/dist/agents/send-message-tool.js +47 -54
  32. package/dist/agents/subagent-completion-gate.d.ts +35 -0
  33. package/dist/agents/subagent-completion-gate.js +62 -0
  34. package/dist/agents/subagent-steps.d.ts +7 -6
  35. package/dist/agents/subagent.d.ts +52 -28
  36. package/dist/agents/subagent.js +276 -246
  37. package/dist/agents/suspend-guard.d.ts +9 -0
  38. package/dist/agents/suspend-guard.js +4 -0
  39. package/dist/agents/tool-filter.d.ts +1 -3
  40. package/dist/agents/tool-filter.js +4 -12
  41. package/dist/agents/verify.d.ts +41 -14
  42. package/dist/agents/verify.js +37 -27
  43. package/dist/bench/metrics.d.ts +3 -5
  44. package/dist/bench/metrics.js +0 -1
  45. package/dist/brain/anthropic.js +1 -0
  46. package/dist/brain/degrading.js +3 -1
  47. package/dist/brain/errors.d.ts +7 -1
  48. package/dist/brain/errors.js +6 -0
  49. package/dist/brain/failover.js +2 -1
  50. package/dist/brain/open-responses.js +1 -0
  51. package/dist/brain/openai.js +1 -0
  52. package/dist/brain/provider-dialect.d.ts +10 -0
  53. package/dist/brain/provider-dialect.js +13 -2
  54. package/dist/brain/route-adjudicator.js +3 -1
  55. package/dist/brain/status-sink.d.ts +7 -1
  56. package/dist/brain/status-sink.js +6 -0
  57. package/dist/brain/stream-engine.d.ts +3 -0
  58. package/dist/brain/stream-engine.js +4 -0
  59. package/dist/brain/timeout.d.ts +3 -1
  60. package/dist/brain/timeout.js +18 -5
  61. package/dist/core/a2a.d.ts +15 -5
  62. package/dist/core/a2a.js +34 -19
  63. package/dist/core/agent-definition.d.ts +20 -0
  64. package/dist/core/agent-state.d.ts +1 -1
  65. package/dist/core/allow-entry.d.ts +61 -23
  66. package/dist/core/allow-entry.js +134 -39
  67. package/dist/core/artifact-host.d.ts +0 -2
  68. package/dist/core/artifact-host.js +0 -1
  69. package/dist/core/ask-origin.d.ts +79 -0
  70. package/dist/core/ask-origin.js +76 -0
  71. package/dist/core/ask-question.d.ts +19 -13
  72. package/dist/core/ask-question.js +8 -2
  73. package/dist/core/auto-compaction.d.ts +2 -0
  74. package/dist/core/auto-compaction.js +2 -1
  75. package/dist/core/auto-mode-defaults.d.ts +8 -0
  76. package/dist/core/auto-mode-defaults.js +1 -0
  77. package/dist/core/auto-mode-rebuild.d.ts +2 -1
  78. package/dist/core/auto-mode.d.ts +39 -4
  79. package/dist/core/auto-mode.js +66 -17
  80. package/dist/core/background-agent-store.d.ts +17 -6
  81. package/dist/core/background-agent-store.js +15 -13
  82. package/dist/core/background-shell.d.ts +12 -1
  83. package/dist/core/background-shell.js +12 -0
  84. package/dist/core/checkpoint-requirements.d.ts +24 -3
  85. package/dist/core/checkpoint-requirements.js +9 -1
  86. package/dist/core/checkpoint-store.d.ts +86 -32
  87. package/dist/core/checkpoint-store.js +10 -5
  88. package/dist/core/child-clamp-seats.d.ts +3 -2
  89. package/dist/core/child-clamp-seats.js +4 -3
  90. package/dist/core/closest-name.d.ts +13 -0
  91. package/dist/core/closest-name.js +35 -0
  92. package/dist/core/compliance.d.ts +1 -1
  93. package/dist/core/context-settings.js +3 -5
  94. package/dist/core/credential-echo.d.ts +52 -0
  95. package/dist/core/credential-echo.js +65 -0
  96. package/dist/core/credential-vocabulary.d.ts +13 -3
  97. package/dist/core/credential-vocabulary.js +12 -4
  98. package/dist/core/cross-boundary-taint.d.ts +5 -6
  99. package/dist/core/decision-receipt.d.ts +14 -1
  100. package/dist/core/decision-receipt.js +6 -3
  101. package/dist/core/delegation-frames.d.ts +13 -9
  102. package/dist/core/effective-path-target.js +2 -3
  103. package/dist/core/engine-attestation.d.ts +11 -1
  104. package/dist/core/engine-attestation.js +2 -0
  105. package/dist/core/engine-notice.d.ts +106 -32
  106. package/dist/core/file-history-retention.d.ts +8 -0
  107. package/dist/core/file-history-retention.js +14 -11
  108. package/dist/core/file-history-store.d.ts +31 -1
  109. package/dist/core/file-history-store.js +31 -2
  110. package/dist/core/frame-settlement.d.ts +15 -0
  111. package/dist/core/frame-settlement.js +10 -1
  112. package/dist/core/fs-write-gate-policy.d.ts +3 -3
  113. package/dist/core/fs-write-gate-policy.js +8 -7
  114. package/dist/core/gate-fold.js +9 -6
  115. package/dist/core/gate-lanes.js +46 -12
  116. package/dist/core/gate-outcome.d.ts +40 -1
  117. package/dist/core/gate-outcome.js +10 -0
  118. package/dist/core/git-worktree-env.d.ts +7 -3
  119. package/dist/core/git-worktree-env.js +16 -13
  120. package/dist/core/governance-codes.d.ts +19 -3
  121. package/dist/core/governance-codes.js +27 -3
  122. package/dist/core/hands-band-screen.js +0 -1
  123. package/dist/core/hands-band.d.ts +0 -3
  124. package/dist/core/hooks.d.ts +51 -60
  125. package/dist/core/hooks.js +131 -78
  126. package/dist/core/host-floor.js +3 -5
  127. package/dist/core/image-admission.d.ts +145 -52
  128. package/dist/core/image-admission.js +202 -47
  129. package/dist/core/image-downsample.d.ts +36 -69
  130. package/dist/core/image-downsample.js +111 -73
  131. package/dist/core/input-author.d.ts +36 -0
  132. package/dist/core/input-author.js +39 -0
  133. package/dist/core/integer-option.d.ts +21 -0
  134. package/dist/core/integer-option.js +13 -0
  135. package/dist/core/leg-identity.d.ts +62 -0
  136. package/dist/core/leg-identity.js +18 -0
  137. package/dist/core/locked-config.d.ts +55 -3
  138. package/dist/core/locked-config.js +84 -51
  139. package/dist/core/lsp.d.ts +5 -3
  140. package/dist/core/lsp.js +3 -2
  141. package/dist/core/mailbox-store.d.ts +85 -10
  142. package/dist/core/mailbox-store.js +31 -10
  143. package/dist/core/mcp-call-meta.d.ts +2 -2
  144. package/dist/core/mcp-call-meta.js +9 -10
  145. package/dist/core/mcp-connection-pool.d.ts +6 -20
  146. package/dist/core/mcp-connection-pool.js +10 -28
  147. package/dist/core/mcp-failure.d.ts +83 -16
  148. package/dist/core/mcp-failure.js +67 -30
  149. package/dist/core/mcp-host-seat.d.ts +131 -0
  150. package/dist/core/mcp-host-seat.js +305 -0
  151. package/dist/core/mcp-probe.d.ts +7 -2
  152. package/dist/core/mcp-probe.js +9 -4
  153. package/dist/core/mcp-server-link.d.ts +18 -6
  154. package/dist/core/mcp-server-link.js +19 -4
  155. package/dist/core/mcp-server-spec.d.ts +39 -9
  156. package/dist/core/mcp-server-spec.js +55 -21
  157. package/dist/core/mcp-session-end.d.ts +1 -2
  158. package/dist/core/mcp-session-end.js +1 -1
  159. package/dist/core/mcp.d.ts +23 -55
  160. package/dist/core/mcp.js +172 -156
  161. package/dist/core/media-byte-cap.d.ts +21 -46
  162. package/dist/core/media-byte-cap.js +55 -55
  163. package/dist/core/member-group.d.ts +7 -0
  164. package/dist/core/member-group.js +35 -0
  165. package/dist/core/memory-admission.d.ts +23 -6
  166. package/dist/core/memory-admission.js +19 -9
  167. package/dist/core/memory-engine/consolidation.d.ts +1 -1
  168. package/dist/core/memory-engine/consolidation.js +7 -1
  169. package/dist/core/memory-engine/content-origin.d.ts +13 -0
  170. package/dist/core/memory-engine/content-origin.js +21 -3
  171. package/dist/core/memory-engine/dual-root.d.ts +31 -0
  172. package/dist/core/memory-engine/dual-root.js +59 -11
  173. package/dist/core/memory-engine/engine.js +27 -24
  174. package/dist/core/memory-engine/file-backend.d.ts +13 -0
  175. package/dist/core/memory-engine/file-backend.js +35 -15
  176. package/dist/core/memory-engine/index.d.ts +2 -1
  177. package/dist/core/memory-engine/index.js +2 -1
  178. package/dist/core/memory-engine/layout.d.ts +3 -0
  179. package/dist/core/memory-engine/layout.js +13 -3
  180. package/dist/core/memory-engine/memory-deployment.d.ts +110 -0
  181. package/dist/core/memory-engine/memory-deployment.js +182 -0
  182. package/dist/core/memory-engine/scope-contract.d.ts +13 -3
  183. package/dist/core/memory-engine/scope-contract.js +2 -2
  184. package/dist/core/memory-engine/sync-client.d.ts +68 -13
  185. package/dist/core/memory-engine/sync-client.js +147 -18
  186. package/dist/core/memory-engine/sync-report.d.ts +106 -0
  187. package/dist/core/memory-engine/sync-report.js +119 -0
  188. package/dist/core/memory-engine/sync.d.ts +13 -3
  189. package/dist/core/mode-policy.d.ts +15 -7
  190. package/dist/core/mode-policy.js +18 -6
  191. package/dist/core/model-receipt.d.ts +39 -0
  192. package/dist/core/model-receipt.js +139 -0
  193. package/dist/core/mods/agent-stations.d.ts +100 -0
  194. package/dist/core/mods/agent-stations.js +154 -0
  195. package/dist/core/mods/dollar.d.ts +62 -0
  196. package/dist/core/mods/extension-call.d.ts +15 -1
  197. package/dist/core/mods/extension-call.js +7 -2
  198. package/dist/core/mods/kernel/dispatch.d.ts +9 -4
  199. package/dist/core/mods/kernel/dispatch.js +8 -8
  200. package/dist/core/mods/kernel/events.d.ts +13 -4
  201. package/dist/core/mods/kernel/events.js +14 -10
  202. package/dist/core/mods/kernel/receive.d.ts +5 -0
  203. package/dist/core/mods/kernel/receive.js +10 -0
  204. package/dist/core/mods/kernel/registration.d.ts +3 -0
  205. package/dist/core/mods/kernel/registration.js +5 -0
  206. package/dist/core/mods/kernel/site-rules.d.ts +6 -3
  207. package/dist/core/mods/kernel/site-rules.js +10 -2
  208. package/dist/core/mods/lifecycle-stations.d.ts +41 -0
  209. package/dist/core/mods/lifecycle-stations.js +35 -0
  210. package/dist/core/mods/session-append.d.ts +115 -0
  211. package/dist/core/mods/session-append.js +311 -0
  212. package/dist/core/mods/session-compact.d.ts +48 -0
  213. package/dist/core/mods/session-compact.js +194 -0
  214. package/dist/core/mods/session-receive.d.ts +93 -0
  215. package/dist/core/mods/session-receive.js +141 -0
  216. package/dist/core/mods/session-send.d.ts +72 -0
  217. package/dist/core/mods/session-send.js +88 -0
  218. package/dist/core/mods/stations.d.ts +89 -75
  219. package/dist/core/mods/stations.js +57 -53
  220. package/dist/core/mods/tool-call.d.ts +12 -4
  221. package/dist/core/mods/tool-call.js +32 -16
  222. package/dist/core/mounted-mcp.d.ts +5 -0
  223. package/dist/core/mounted-mcp.js +2 -2
  224. package/dist/core/namespaced-rule-name.d.ts +7 -1
  225. package/dist/core/namespaced-rule-name.js +13 -2
  226. package/dist/core/oracle-isolation.js +1 -1
  227. package/dist/core/output-style.js +3 -4
  228. package/dist/core/own-property-receipt.d.ts +62 -0
  229. package/dist/core/own-property-receipt.js +43 -0
  230. package/dist/core/park-selfcheck.js +12 -10
  231. package/dist/core/path-identity.d.ts +11 -0
  232. package/dist/core/path-identity.js +4 -0
  233. package/dist/core/path-rule-binding.d.ts +3 -1
  234. package/dist/core/path-rule-binding.js +3 -1
  235. package/dist/core/peer-seat.d.ts +66 -11
  236. package/dist/core/peer-seat.js +199 -42
  237. package/dist/core/permission-rule-consent.d.ts +21 -26
  238. package/dist/core/permission-rule-consent.js +22 -3
  239. package/dist/core/permission-rule-model.d.ts +38 -13
  240. package/dist/core/permission-rule-model.js +54 -16
  241. package/dist/core/permission-rule-org.d.ts +1 -1
  242. package/dist/core/permission-rule-provider.js +4 -1
  243. package/dist/core/permission-rules.d.ts +4 -0
  244. package/dist/core/permission-rules.js +11 -16
  245. package/dist/core/protocol-http-auth.d.ts +14 -2
  246. package/dist/core/protocol-http-auth.js +16 -7
  247. package/dist/core/read-face-seats.d.ts +7 -5
  248. package/dist/core/read-face-seats.js +4 -1
  249. package/dist/core/redaction-marks.d.ts +4 -3
  250. package/dist/core/redaction-marks.js +2 -2
  251. package/dist/core/remote-env.d.ts +218 -122
  252. package/dist/core/remote-env.js +133 -14
  253. package/dist/core/retention-policy.d.ts +24 -23
  254. package/dist/core/retention-policy.js +36 -2
  255. package/dist/core/retention.d.ts +4 -1
  256. package/dist/core/retention.js +37 -12
  257. package/dist/core/retired-keys.d.ts +8 -3
  258. package/dist/core/retired-keys.js +4 -1
  259. package/dist/core/rewrite-rejudge.d.ts +12 -5
  260. package/dist/core/rewrite-rejudge.js +9 -5
  261. package/dist/core/roles.d.ts +37 -3
  262. package/dist/core/roles.js +126 -78
  263. package/dist/core/row-admission.d.ts +10 -0
  264. package/dist/core/row-admission.js +5 -0
  265. package/dist/core/rule-owner.d.ts +3 -0
  266. package/dist/core/runner/advisor-instructions.d.ts +2 -1
  267. package/dist/core/runner/advisor-instructions.js +2 -1
  268. package/dist/core/runner/announce-once-ledger.d.ts +4 -4
  269. package/dist/core/runner/assemble-result.d.ts +13 -8
  270. package/dist/core/runner/assemble-result.js +12 -8
  271. package/dist/core/runner/call-hook-stations.d.ts +17 -10
  272. package/dist/core/runner/call-hook-stations.js +21 -10
  273. package/dist/core/runner/caller-roster.d.ts +12 -9
  274. package/dist/core/runner/caller-roster.js +5 -2
  275. package/dist/core/runner/checkpoint-scope.d.ts +16 -1
  276. package/dist/core/runner/checkpoint-scope.js +21 -0
  277. package/dist/core/runner/child-tree.d.ts +7 -8
  278. package/dist/core/runner/child-tree.js +6 -6
  279. package/dist/core/runner/classifier-ladder.d.ts +10 -2
  280. package/dist/core/runner/classifier-ladder.js +39 -8
  281. package/dist/core/runner/compact-session.js +14 -2
  282. package/dist/core/runner/compaction-call-options.d.ts +1 -1
  283. package/dist/core/runner/compaction-restate.d.ts +2 -2
  284. package/dist/core/runner/compaction-restate.js +4 -3
  285. package/dist/core/runner/construction-doors.d.ts +2 -2
  286. package/dist/core/runner/construction-doors.js +7 -2
  287. package/dist/core/runner/contracts.d.ts +158 -65
  288. package/dist/core/runner/cross-boundary-lane.d.ts +4 -6
  289. package/dist/core/runner/cross-boundary-lane.js +11 -2
  290. package/dist/core/runner/decide-continuation.d.ts +4 -2
  291. package/dist/core/runner/decide-continuation.js +7 -4
  292. package/dist/core/runner/denial-limit-arms.d.ts +15 -21
  293. package/dist/core/runner/denial-limit-arms.js +17 -10
  294. package/dist/core/runner/env-capability-census.d.ts +15 -20
  295. package/dist/core/runner/env-capability-census.js +25 -34
  296. package/dist/core/runner/expire-settle.d.ts +44 -0
  297. package/dist/core/runner/expire-settle.js +55 -0
  298. package/dist/core/runner/file-history-request.d.ts +2 -2
  299. package/dist/core/runner/file-history-request.js +0 -8
  300. package/dist/core/runner/gate-exit.d.ts +75 -7
  301. package/dist/core/runner/gate-exit.js +20 -1
  302. package/dist/core/runner/git-status-frame.d.ts +5 -2
  303. package/dist/core/runner/git-status-frame.js +4 -4
  304. package/dist/core/runner/halt-attribution.d.ts +2 -1
  305. package/dist/core/runner/halt-attribution.js +2 -1
  306. package/dist/core/runner/image.d.ts +7 -2
  307. package/dist/core/runner/image.js +14 -8
  308. package/dist/core/runner/inline-image.d.ts +10 -8
  309. package/dist/core/runner/inline-image.js +11 -9
  310. package/dist/core/runner/local-claims.d.ts +17 -0
  311. package/dist/core/runner/local-claims.js +18 -0
  312. package/dist/core/runner/media-removed-seat.d.ts +46 -0
  313. package/dist/core/runner/media-removed-seat.js +88 -0
  314. package/dist/core/runner/memory-consolidation-driver.js +4 -4
  315. package/dist/core/runner/park-commit.d.ts +2 -2
  316. package/dist/core/runner/permission-rule-lanes.d.ts +5 -1
  317. package/dist/core/runner/permission-rule-lanes.js +29 -10
  318. package/dist/core/runner/person-path-rows.js +1 -1
  319. package/dist/core/runner/placement-fence.d.ts +26 -0
  320. package/dist/core/runner/placement-fence.js +38 -0
  321. package/dist/core/runner/prepare-ask-lane.d.ts +6 -12
  322. package/dist/core/runner/prepare-ask-lane.js +4 -4
  323. package/dist/core/runner/prepare-boundary-parks.d.ts +6 -3
  324. package/dist/core/runner/prepare-boundary-parks.js +4 -4
  325. package/dist/core/runner/prepare-caps-and-workflow.d.ts +6 -0
  326. package/dist/core/runner/prepare-caps-and-workflow.js +5 -3
  327. package/dist/core/runner/prepare-config-doors.d.ts +6 -1
  328. package/dist/core/runner/prepare-config-doors.js +30 -26
  329. package/dist/core/runner/prepare-context-lane.d.ts +6 -2
  330. package/dist/core/runner/prepare-context-lane.js +13 -13
  331. package/dist/core/runner/prepare-delegation-surface.d.ts +13 -11
  332. package/dist/core/runner/prepare-delegation-surface.js +7 -8
  333. package/dist/core/runner/prepare-execution-env.d.ts +5 -2
  334. package/dist/core/runner/prepare-execution-env.js +7 -4
  335. package/dist/core/runner/prepare-file-history.d.ts +10 -12
  336. package/dist/core/runner/prepare-file-history.js +3 -12
  337. package/dist/core/runner/prepare-gate-stations.d.ts +23 -17
  338. package/dist/core/runner/prepare-gate-stations.js +10 -7
  339. package/dist/core/runner/prepare-hands-readface.d.ts +8 -6
  340. package/dist/core/runner/prepare-hands-readface.js +19 -11
  341. package/dist/core/runner/prepare-inherited-gate.d.ts +11 -4
  342. package/dist/core/runner/prepare-inherited-gate.js +12 -5
  343. package/dist/core/runner/prepare-lsp.d.ts +3 -0
  344. package/dist/core/runner/prepare-lsp.js +2 -2
  345. package/dist/core/runner/prepare-memory-engine-session.js +1 -1
  346. package/dist/core/runner/prepare-memory.d.ts +2 -2
  347. package/dist/core/runner/prepare-memory.js +2 -2
  348. package/dist/core/runner/prepare-park-ask.d.ts +8 -7
  349. package/dist/core/runner/prepare-park-ask.js +6 -12
  350. package/dist/core/runner/prepare-policy-chain.d.ts +15 -25
  351. package/dist/core/runner/prepare-policy-chain.js +131 -128
  352. package/dist/core/runner/prepare-project-context.d.ts +2 -2
  353. package/dist/core/runner/prepare-project-context.js +8 -5
  354. package/dist/core/runner/prepare-prompt-inputs.d.ts +4 -0
  355. package/dist/core/runner/prepare-prompt-inputs.js +4 -2
  356. package/dist/core/runner/prepare-protocol-tools.d.ts +5 -3
  357. package/dist/core/runner/prepare-protocol-tools.js +9 -2
  358. package/dist/core/runner/prepare-question-face.d.ts +6 -4
  359. package/dist/core/runner/prepare-question-face.js +2 -2
  360. package/dist/core/runner/prepare-run-refs.d.ts +3 -0
  361. package/dist/core/runner/prepare-run-refs.js +2 -2
  362. package/dist/core/runner/prepare-suspend-saga.d.ts +11 -9
  363. package/dist/core/runner/prepare-suspend-saga.js +21 -13
  364. package/dist/core/runner/prepare-task.d.ts +1 -1
  365. package/dist/core/runner/prepare-task.js +84 -42
  366. package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +6 -0
  367. package/dist/core/runner/prepare-tool-disclosure-mount.js +3 -1
  368. package/dist/core/runner/prepare-turn-wiring.d.ts +2 -0
  369. package/dist/core/runner/prepare-turn-wiring.js +7 -2
  370. package/dist/core/runner/prepare-wiring-manifest.d.ts +7 -3
  371. package/dist/core/runner/prepare-wiring-manifest.js +34 -19
  372. package/dist/core/runner/prepare-workspace-restore.d.ts +5 -0
  373. package/dist/core/runner/prepare-workspace-restore.js +12 -8
  374. package/dist/core/runner/read-root-grant.d.ts +1 -1
  375. package/dist/core/runner/read-root-grant.js +2 -1
  376. package/dist/core/runner/resume-admission.d.ts +5 -3
  377. package/dist/core/runner/resume-admission.js +17 -3
  378. package/dist/core/runner/resume-apply.js +3 -1
  379. package/dist/core/runner/resume-checkpoint-screen.js +4 -4
  380. package/dist/core/runner/resume-claim.d.ts +8 -3
  381. package/dist/core/runner/resume-claim.js +28 -12
  382. package/dist/core/runner/resume-internals-and-config.d.ts +2 -2
  383. package/dist/core/runner/resume-internals-and-config.js +10 -1
  384. package/dist/core/runner/resume-preflight.d.ts +3 -2
  385. package/dist/core/runner/resume-preflight.js +13 -26
  386. package/dist/core/runner/retired-runner-deps.js +6 -1
  387. package/dist/core/runner/run-attachment-seats.js +3 -3
  388. package/dist/core/runner/run-brain-sinks.js +1 -0
  389. package/dist/core/runner/run-git-lane.d.ts +3 -1
  390. package/dist/core/runner/run-git-lane.js +3 -2
  391. package/dist/core/runner/run-harness-handlers.d.ts +3 -1
  392. package/dist/core/runner/run-harness-handlers.js +5 -3
  393. package/dist/core/runner/run-identity-wiring.d.ts +2 -2
  394. package/dist/core/runner/run-identity-wiring.js +15 -6
  395. package/dist/core/runner/run-leg.d.ts +3 -3
  396. package/dist/core/runner/run-leg.js +65 -56
  397. package/dist/core/runner/run-notification-lane.d.ts +3 -1
  398. package/dist/core/runner/run-notification-lane.js +36 -12
  399. package/dist/core/runner/run-recovery-lanes.js +3 -2
  400. package/dist/core/runner/run-settle-and-teardown.js +14 -8
  401. package/dist/core/runner/run-stop-and-final-verify.d.ts +4 -0
  402. package/dist/core/runner/run-stop-and-final-verify.js +12 -4
  403. package/dist/core/runner/run-telemetry-and-budget-seats.d.ts +1 -1
  404. package/dist/core/runner/run-terminal-adoption.d.ts +1 -1
  405. package/dist/core/runner/run-terminal-adoption.js +26 -17
  406. package/dist/core/runner/run-turn-boundary.js +37 -19
  407. package/dist/core/runner/runtask.d.ts +25 -7
  408. package/dist/core/runner/runtask.js +46 -22
  409. package/dist/core/runner/session-rule-policy.d.ts +1 -1
  410. package/dist/core/runner/session-rule-policy.js +6 -1
  411. package/dist/core/runner/shell-env-withheld.d.ts +1 -1
  412. package/dist/core/runner/skills-seat.js +2 -2
  413. package/dist/core/runner/stream-halt-verbs.d.ts +1 -14
  414. package/dist/core/runner/stream-halt-verbs.js +4 -3
  415. package/dist/core/runner/stream-reap.d.ts +7 -6
  416. package/dist/core/runner/stream-reap.js +13 -16
  417. package/dist/core/runner/stream-settle-backstop.d.ts +3 -2
  418. package/dist/core/runner/stream-settle-backstop.js +5 -3
  419. package/dist/core/runner/stream-steer-verb.d.ts +5 -2
  420. package/dist/core/runner/stream-steer-verb.js +8 -7
  421. package/dist/core/runner/sub-agent-deny-lists.js +10 -7
  422. package/dist/core/runner/synthetic-tools.js +2 -2
  423. package/dist/core/runner/terminal-account.d.ts +11 -1
  424. package/dist/core/runner/terminal-account.js +20 -0
  425. package/dist/core/runner/terminal-projection.d.ts +8 -2
  426. package/dist/core/runner/terminal-projection.js +2 -2
  427. package/dist/core/runner/tool-disclosure.d.ts +3 -0
  428. package/dist/core/runner/tool-disclosure.js +5 -4
  429. package/dist/core/runner/tool-end-body.d.ts +3 -3
  430. package/dist/core/runner/tool-end-body.js +1 -1
  431. package/dist/core/runner/tool-face-overlay.d.ts +1 -1
  432. package/dist/core/runner/tool-face-overlay.js +26 -19
  433. package/dist/core/runner/tool-output-projection.d.ts +3 -3
  434. package/dist/core/runner/tool-output-projection.js +7 -6
  435. package/dist/core/runner/tool-result-media-seat.d.ts +9 -1
  436. package/dist/core/runner/tool-result-media-seat.js +17 -1
  437. package/dist/core/runner/tool-table-view.d.ts +56 -0
  438. package/dist/core/runner/tool-table-view.js +51 -0
  439. package/dist/core/runner/turn-attachments.d.ts +6 -7
  440. package/dist/core/runner/turn-attachments.js +4 -17
  441. package/dist/core/runner/void-verifier-pause.d.ts +33 -0
  442. package/dist/core/runner/void-verifier-pause.js +41 -0
  443. package/dist/core/runner-deps.d.ts +55 -43
  444. package/dist/core/secret-env.d.ts +14 -13
  445. package/dist/core/secret-env.js +8 -9
  446. package/dist/core/session-log-transfer.js +9 -10
  447. package/dist/core/session-policy-store.d.ts +10 -3
  448. package/dist/core/session-policy-store.js +21 -3
  449. package/dist/core/session-reconcile.d.ts +3 -2
  450. package/dist/core/session-reconcile.js +7 -4
  451. package/dist/core/session-store.d.ts +5 -2
  452. package/dist/core/session-store.js +53 -16
  453. package/dist/core/session.d.ts +2 -1
  454. package/dist/core/shell-confinement.d.ts +37 -0
  455. package/dist/core/shell-confinement.js +56 -0
  456. package/dist/core/skill-grant.d.ts +9 -0
  457. package/dist/core/skill-grant.js +18 -0
  458. package/dist/core/store-contracts/checkpoint-store-contract.d.ts +2 -2
  459. package/dist/core/store-contracts/checkpoint-store-contract.js +15 -2
  460. package/dist/core/store-contracts/file-history-store-contract.d.ts +5 -2
  461. package/dist/core/store-contracts/file-history-store-contract.js +25 -1
  462. package/dist/core/store-contracts/mailbox-store-contract.d.ts +12 -5
  463. package/dist/core/store-contracts/mailbox-store-contract.js +156 -9
  464. package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
  465. package/dist/core/store-contracts/tool-result-store-contract.js +67 -0
  466. package/dist/core/stub-env.d.ts +5 -5
  467. package/dist/core/stub-env.js +11 -1
  468. package/dist/core/swappable-deps.d.ts +17 -43
  469. package/dist/core/swappable-deps.js +15 -5
  470. package/dist/core/synthetic-read-verdict.d.ts +1 -1
  471. package/dist/core/task-event.d.ts +35 -10
  472. package/dist/core/task-limits.d.ts +5 -0
  473. package/dist/core/task-notification.d.ts +172 -12
  474. package/dist/core/task-notification.js +209 -12
  475. package/dist/core/task-registry-agent.d.ts +23 -55
  476. package/dist/core/task-registry-agent.js +41 -56
  477. package/dist/core/task-registry-monitor.d.ts +8 -1
  478. package/dist/core/task-registry-monitor.js +43 -61
  479. package/dist/core/task-registry-shared.d.ts +52 -114
  480. package/dist/core/task-registry-shared.js +24 -48
  481. package/dist/core/task-registry-workflow.js +5 -22
  482. package/dist/core/task-registry.d.ts +64 -90
  483. package/dist/core/task-registry.js +73 -119
  484. package/dist/core/task-result.d.ts +27 -19
  485. package/dist/core/task-spec-members.d.ts +39 -0
  486. package/dist/core/task-spec-members.js +92 -0
  487. package/dist/core/task-spec.d.ts +13 -16
  488. package/dist/core/task-stream.d.ts +1 -1
  489. package/dist/core/task-tool-shape.d.ts +7 -57
  490. package/dist/core/task-tool-shape.js +7 -66
  491. package/dist/core/terminal-cause.d.ts +30 -0
  492. package/dist/core/terminal-cause.js +1 -0
  493. package/dist/core/tool-catalog-entries.js +3 -6
  494. package/dist/core/tool-check-reading.js +16 -10
  495. package/dist/core/tool-conformance.js +1 -2
  496. package/dist/core/tool-errors.d.ts +6 -3
  497. package/dist/core/tool-errors.js +2 -0
  498. package/dist/core/tool-face-reader.d.ts +7 -6
  499. package/dist/core/tool-face-reader.js +6 -4
  500. package/dist/core/tool-face.d.ts +2 -3
  501. package/dist/core/tool-name-aliases.d.ts +23 -28
  502. package/dist/core/tool-name-aliases.js +63 -7
  503. package/dist/core/tool-name-readings.d.ts +14 -3
  504. package/dist/core/tool-name-readings.js +2 -0
  505. package/dist/core/tool-policy.d.ts +113 -22
  506. package/dist/core/tool-policy.js +85 -15
  507. package/dist/core/tool-registry.d.ts +5 -5
  508. package/dist/core/tool-registry.js +2 -2
  509. package/dist/core/tool-result-store.d.ts +111 -5
  510. package/dist/core/tool-result-store.js +52 -12
  511. package/dist/core/tool-spec.d.ts +39 -10
  512. package/dist/core/trace.d.ts +18 -2
  513. package/dist/core/types.d.ts +3 -3
  514. package/dist/core/types.js +1 -1
  515. package/dist/core/untrusted-text.js +1 -1
  516. package/dist/core/user-attachment.d.ts +10 -5
  517. package/dist/core/user-attachment.js +40 -27
  518. package/dist/core/workflow-journal-store.d.ts +1 -1
  519. package/dist/core/workflow-run-store.d.ts +2 -0
  520. package/dist/core/workflow-run-store.js +6 -5
  521. package/dist/core/workflow-settled-run.d.ts +5 -0
  522. package/dist/core/workflow-settled-run.js +7 -0
  523. package/dist/engine/execution-env/node-execution-env.d.ts +37 -7
  524. package/dist/engine/execution-env/node-execution-env.js +224 -21
  525. package/dist/engine/harness/agent-harness.d.ts +66 -19
  526. package/dist/engine/harness/agent-harness.js +98 -27
  527. package/dist/engine/harness/messages.d.ts +4 -3
  528. package/dist/engine/harness/messages.js +2 -2
  529. package/dist/engine/harness/types.d.ts +151 -34
  530. package/dist/engine/llm/media-removed.d.ts +14 -0
  531. package/dist/engine/llm/media-removed.js +9 -0
  532. package/dist/engine/llm/rejected-images.d.ts +35 -25
  533. package/dist/engine/llm/rejected-images.js +59 -10
  534. package/dist/engine/llm/types.d.ts +24 -3
  535. package/dist/engine/llm/types.js +7 -3
  536. package/dist/engine/loop/agent-loop.d.ts +18 -13
  537. package/dist/engine/loop/agent-loop.js +173 -32
  538. package/dist/engine/loop/types.d.ts +21 -5
  539. package/dist/engine/lsp/node-lsp-manager.d.ts +3 -3
  540. package/dist/engine/lsp/node-lsp-manager.js +32 -13
  541. package/dist/engine/session/import-validate.js +7 -0
  542. package/dist/fixtures/index.d.ts +7 -5
  543. package/dist/fixtures/index.js +5 -3
  544. package/dist/index.d.ts +41 -23
  545. package/dist/index.js +29 -16
  546. package/dist/internal/harness-types.d.ts +3 -1
  547. package/dist/internal/llm.d.ts +2 -1
  548. package/dist/internal/llm.js +1 -0
  549. package/dist/orchestration/goal.d.ts +6 -2
  550. package/dist/orchestration/goal.js +6 -3
  551. package/dist/orchestration/run-workflow-tool.d.ts +20 -20
  552. package/dist/orchestration/run-workflow-tool.js +63 -56
  553. package/dist/orchestration/workflow-governance.d.ts +1 -1
  554. package/dist/orchestration/workflow-governance.js +2 -1
  555. package/dist/orchestration/workflow-types.d.ts +2 -2
  556. package/dist/orchestration/workflow.d.ts +8 -0
  557. package/dist/orchestration/workflow.js +33 -9
  558. package/dist/prompts/default.d.ts +1 -10
  559. package/dist/prompts/default.js +0 -2
  560. package/dist/stores/file/background-agent-store.d.ts +1 -1
  561. package/dist/stores/file/background-agent-store.js +19 -14
  562. package/dist/stores/file/checkpoint-store.d.ts +127 -2
  563. package/dist/stores/file/checkpoint-store.js +24 -16
  564. package/dist/stores/file/file-history-store.d.ts +1 -1
  565. package/dist/stores/file/file-history-store.js +4 -1
  566. package/dist/stores/file/index.d.ts +9 -6
  567. package/dist/stores/file/index.js +33 -9
  568. package/dist/stores/file/ledger-tuning.d.ts +23 -0
  569. package/dist/stores/file/ledger-tuning.js +21 -0
  570. package/dist/stores/file/mailbox-store.d.ts +1 -1
  571. package/dist/stores/file/mailbox-store.js +43 -21
  572. package/dist/stores/file/memory-store.d.ts +1 -1
  573. package/dist/stores/file/memory-store.js +4 -1
  574. package/dist/stores/file/permission-rule-adopt.js +24 -21
  575. package/dist/stores/file/permission-rule-store.js +6 -3
  576. package/dist/stores/file/session-policy-store.d.ts +1 -1
  577. package/dist/stores/file/session-policy-store.js +4 -1
  578. package/dist/stores/file/session-store.d.ts +17 -4
  579. package/dist/stores/file/session-store.js +22 -19
  580. package/dist/stores/file/shared-ledger.d.ts +26 -0
  581. package/dist/stores/file/shared-ledger.js +38 -9
  582. package/dist/stores/file/tool-result-store.d.ts +31 -2
  583. package/dist/stores/file/tool-result-store.js +129 -7
  584. package/dist/stores/file/usage-window-store.d.ts +1 -1
  585. package/dist/stores/file/usage-window-store.js +4 -1
  586. package/dist/stores/file/workflow-journal-store.d.ts +1 -13
  587. package/dist/stores/file/workflow-journal-store.js +4 -18
  588. package/dist/stores/file/workflow-run-store.d.ts +1 -1
  589. package/dist/stores/file/workflow-run-store.js +15 -10
  590. package/dist/tools/fs/containment-face.d.ts +5 -0
  591. package/dist/tools/fs/dead-cwd.d.ts +5 -5
  592. package/dist/tools/fs/dead-cwd.js +4 -11
  593. package/dist/tools/fs/encoding.d.ts +13 -4
  594. package/dist/tools/fs/encoding.js +17 -2
  595. package/dist/tools/fs/fs-bash-background-text.d.ts +13 -0
  596. package/dist/tools/fs/fs-bash-background-text.js +7 -0
  597. package/dist/tools/fs/fs-bash.d.ts +11 -22
  598. package/dist/tools/fs/fs-bash.js +58 -154
  599. package/dist/tools/fs/fs-pdf.d.ts +2 -2
  600. package/dist/tools/fs/fs-pdf.js +34 -27
  601. package/dist/tools/fs/fs-read.d.ts +5 -4
  602. package/dist/tools/fs/fs-read.js +35 -18
  603. package/dist/tools/fs/fs-search-tools.js +4 -1
  604. package/dist/tools/fs/fs-shared.d.ts +39 -16
  605. package/dist/tools/fs/fs-shared.js +25 -6
  606. package/dist/tools/fs/fs-write.js +5 -5
  607. package/dist/tools/fs/index.d.ts +15 -9
  608. package/dist/tools/fs/index.js +12 -18
  609. package/dist/tools/fs/pdf.d.ts +4 -4
  610. package/dist/tools/fs/pdf.js +6 -6
  611. package/dist/tools/fs/read-deny-home.js +8 -1
  612. package/dist/tools/fs/read-deny.d.ts +26 -2
  613. package/dist/tools/fs/read-deny.js +9 -2
  614. package/dist/tools/fs/read-floor.d.ts +57 -6
  615. package/dist/tools/fs/read-floor.js +241 -2
  616. package/dist/tools/fs/removal-targets.d.ts +9 -4
  617. package/dist/tools/fs/removal-targets.js +17 -9
  618. package/dist/tools/fs/search.d.ts +6 -5
  619. package/dist/tools/fs/search.js +10 -10
  620. package/dist/tools/fs/shell-read-establish.js +3 -1
  621. package/dist/tools/fs/shell-read-identity.d.ts +3 -1
  622. package/dist/tools/fs/shell-read-identity.js +4 -2
  623. package/dist/tools/fs/shell-read-judge.d.ts +7 -1
  624. package/dist/tools/fs/shell-read-judge.js +1 -1
  625. package/dist/tools/monitor.d.ts +12 -10
  626. package/dist/tools/monitor.js +22 -13
  627. package/dist/tools/scheduler-tools.js +42 -4
  628. package/dist/tools/web.d.ts +0 -10
  629. package/dist/tools/web.js +1 -4
  630. package/dist/tools/worktree.d.ts +5 -1
  631. package/dist/tools/worktree.js +20 -17
  632. package/package.json +8 -3
  633. package/test/export-surface.snapshot.json +166 -30
  634. package/wire-changes/core-stores-sql@7.60.0.json +30 -0
  635. package/wire-changes/core-stores-sql@7.61.0.json +480 -0
  636. package/wire-changes/core@7.60.0.json +3274 -0
  637. package/wire-changes/core@7.61.0.json +4405 -0
  638. package/wire-changes/mods-kernel@7.60.0.json +62 -0
  639. package/wire-changes/mods-kernel@7.61.0.json +65 -0
  640. package/wire-changes/primitives@7.60.0.json +30 -0
  641. package/wire-changes/primitives@7.61.0.json +30 -0
  642. package/dist/core/runner/image-removed-seat.d.ts +0 -12
  643. package/dist/core/runner/image-removed-seat.js +0 -19
@@ -12,6 +12,13 @@ export declare function absorbMonitorPollLane(handle: MonitorTaskHandle, v: {
12
12
  truncated?: boolean;
13
13
  bytesDroppedBeforeCursor?: number;
14
14
  }): string[];
15
+ /** Append one poll's increment (stdout AND stderr) to the watch's output file — the bash watcher's mirror, for the
16
+ * same absorption's two consumers (the watcher tick and the stop-time drain). Never throws; a failed append is
17
+ * accounted on `spool.mirrorFailed` so the terminal frame says the file is incomplete instead of passing it off as whole. */
18
+ export declare function mirrorMonitorPollLane(handle: MonitorTaskHandle, v: {
19
+ stdout: string;
20
+ stderr: string;
21
+ }): Promise<void>;
15
22
  /** The swallow-guarded event sink, shared by the watcher's emits and the stop-time drain. */
16
23
  export declare function emitMonitorEventLane(handle: MonitorTaskHandle, n: TaskNotificationPayload): void;
17
24
  /** The monitor watcher tick loop. Same zombie-proofing discipline as {@link startBashWatcher}
@@ -19,7 +26,7 @@ export declare function emitMonitorEventLane(handle: MonitorTaskHandle, n: TaskN
19
26
  * plus the three monitor-only exits: watcher-enforced timeout, event-storm auto-stop, and the
20
27
  * line→batched-event emission path. All time reads go through the INJECTED clock (design/87). */
21
28
  export declare function startMonitorWatcherLane(core: RegistryCore, id: string): void;
22
- /** design/135 G2: TaskOutput over a monitor — a RE-READABLE spool snapshot (the watcher owns the env
29
+ /** design/135 G2: the host poll over a monitor — a RE-READABLE spool snapshot (the watcher owns the env
23
30
  * cursor, exactly the bash G2b spool posture): repeated polls return the same accumulated output. */
24
31
  export declare function pollMonitorLane(handle: MonitorTaskHandle, filter: string | undefined, deadline?: number, signal?: AbortSignal): Promise<UnifiedTaskResult>;
25
32
  export declare function stopMonitorLane(core: RegistryCore, handle: MonitorTaskHandle): Promise<UnifiedTaskResult>;
@@ -1,7 +1,6 @@
1
1
  import { delimitUntrusted } from "./untrusted-text.js";
2
2
  import { envDeclaresRetain, retainsBackgroundProcesses } from "./background-shell.js";
3
- import { assertOwnership, defaultMonitorTimers, MONITOR_MAX_TIMEOUT_MS, MONITOR_DEFAULT_TIMEOUT_MS, MONITOR_BATCH_WINDOW_MS, MONITOR_MAX_BATCHES_PER_MINUTE, MONITOR_STORM_BURST, MONITOR_STORM_KILL_AFTER_MS, MONITOR_LINE_BUF_CAP, MONITOR_SPILL_CAP_CHARS, TASK_OUTPUT_MAX_CHARS, mintCompletionId, clipMonitorEvent, clipMonitorLine, terminalTaskSummary, accountDroppedBytes, renderSpoolBody, SPOOL_REPLAY, rollSpoolText, statusFromBackground, droppedGapNote, firstDropNote, alreadyTerminalStopNote, clipTaskOutput, sleepPollStep, } from "./task-registry-shared.js";
4
- import { buildToolResultRef, OFFLOAD_TOOL_NAME, toolResultProvenanceOf } from "./tool-result-store.js";
3
+ import { assertOwnership, defaultMonitorTimers, MONITOR_MAX_TIMEOUT_MS, MONITOR_DEFAULT_TIMEOUT_MS, MONITOR_BATCH_WINDOW_MS, MONITOR_MAX_BATCHES_PER_MINUTE, MONITOR_STORM_BURST, MONITOR_STORM_KILL_AFTER_MS, MONITOR_LINE_BUF_CAP, TASK_OUTPUT_MAX_CHARS, mintCompletionId, clipMonitorEvent, clipMonitorLine, terminalTaskSummary, accountDroppedBytes, renderSpoolBody, SPOOL_REPLAY, rollSpoolText, statusFromBackground, droppedGapNote, firstDropNote, alreadyTerminalStopNote, clipTaskOutput, sleepPollStep, } from "./task-registry-shared.js";
5
4
  import { thrownText } from "./thrown-value.js";
6
5
  export function registerMonitorLane(core, input) {
7
6
  assertOwnership(input, "registerMonitor");
@@ -29,6 +28,8 @@ export function registerMonitorLane(core, input) {
29
28
  env: input.env,
30
29
  shellId: input.shellId,
31
30
  spool: { stdout: "", stderr: "", rolledChars: 0 },
31
+ ...(input.outputFile !== undefined ? { outputFile: input.outputFile } : {}),
32
+ ...(input.taskArtifacts !== undefined ? { taskArtifacts: input.taskArtifacts } : {}),
32
33
  lineBuf: "",
33
34
  seq: 0,
34
35
  stormTokens: stormBurst,
@@ -40,8 +41,6 @@ export function registerMonitorLane(core, input) {
40
41
  ...(timeoutMs !== undefined ? { timeoutMs, deadlineAt: timers.now() + timeoutMs } : {}),
41
42
  timers,
42
43
  ...(input.onEvent !== undefined ? { onEvent: input.onEvent } : {}),
43
- ...(input.toolResultStore !== undefined ? { toolResultStore: input.toolResultStore } : {}),
44
- ...(input.sessionId !== undefined ? { spillSessionId: input.sessionId } : {}),
45
44
  ...(retainsBackgroundProcesses({ env: envDeclaresRetain(input.env), task: input.retainBackgroundProcesses === true }) ? { retained: true } : {}),
46
45
  ...(input.retainBackgroundProcesses !== undefined ? { retainStatedAtLaunch: true } : {}),
47
46
  };
@@ -55,60 +54,12 @@ export function registerMonitorLane(core, input) {
55
54
  }
56
55
  return id;
57
56
  }
58
- function spillRolledMonitorChunk(handle, stream, dropped) {
59
- const store = handle.toolResultStore;
60
- if (store === undefined)
61
- return;
62
- const used = handle.spillCharsUsed ?? 0;
63
- if (used >= MONITOR_SPILL_CAP_CHARS) {
64
- handle.spillCapped = true;
65
- return;
66
- }
67
- const n = stream === "out" ? (handle.spillSegCount ?? 0) : (handle.spillErrSegCount ?? 0);
68
- const ref = buildToolResultRef(handle.spillSessionId ?? "no-session", handle.id, `${stream}_seg${n}`);
69
- handle.spillCharsUsed = used + dropped.length;
70
- if (stream === "out")
71
- handle.spillSegCount = n + 1;
72
- else
73
- handle.spillErrSegCount = n + 1;
74
- try {
75
- const provenance = handle.spillSessionId === undefined ? undefined : toolResultProvenanceOf(handle.spillSessionId);
76
- void Promise.resolve(store.put(ref, dropped, provenance)).catch(() => {
77
- handle.spillFailed = true;
78
- });
79
- }
80
- catch {
81
- handle.spillFailed = true;
82
- }
83
- }
84
- function monitorSpillNote(handle) {
85
- const outN = handle.spillSegCount ?? 0;
86
- const errN = handle.spillErrSegCount ?? 0;
87
- if (outN === 0 && errN === 0)
88
- return "";
89
- const sid = handle.spillSessionId ?? "no-session";
90
- const segLabel = (stream, n) => {
91
- const first = buildToolResultRef(sid, handle.id, `${stream}_seg0`);
92
- return n <= 1 ? `ref "${first}"` : `refs "${first}" .. "${buildToolResultRef(sid, handle.id, `${stream}_seg${n - 1}`)}"`;
93
- };
94
- const clauses = [];
95
- if (outN > 0)
96
- clauses.push(`stdout ${segLabel("out", outN)}`);
97
- if (errN > 0)
98
- clauses.push(`stderr ${segLabel("err", errN)}`);
99
- const coverage = handle.spillFailed === true
100
- ? " — a write failed partway through; the ref chain may be INCOMPLETE, read what is there"
101
- : handle.spillCapped === true
102
- ? ` — spill cap (${MONITOR_SPILL_CAP_CHARS} chars) reached; earlier segments retained, later rolls were not spilled`
103
- : "";
104
- return `; spilled to ${clauses.join(", ")} (read back via ${OFFLOAD_TOOL_NAME})${coverage}`;
105
- }
106
57
  export function absorbMonitorPollLane(handle, v) {
107
58
  const spool = handle.spool;
108
59
  accountDroppedBytes(spool, v);
109
60
  const ROLL_CAP = 2 * TASK_OUTPUT_MAX_CHARS;
110
- spool.stdout = rollSpoolText(spool, spool.stdout + v.stdout, ROLL_CAP, (dropped) => spillRolledMonitorChunk(handle, "out", dropped));
111
- spool.stderr = rollSpoolText(spool, spool.stderr + v.stderr, ROLL_CAP, (dropped) => spillRolledMonitorChunk(handle, "err", dropped));
61
+ spool.stdout = rollSpoolText(spool, spool.stdout + v.stdout, ROLL_CAP);
62
+ spool.stderr = rollSpoolText(spool, spool.stderr + v.stderr, ROLL_CAP);
112
63
  handle.lineBuf += v.stdout;
113
64
  if (handle.lineBuf.length > MONITOR_LINE_BUF_CAP)
114
65
  handle.lineBuf = handle.lineBuf.slice(-MONITOR_LINE_BUF_CAP);
@@ -116,6 +67,18 @@ export function absorbMonitorPollLane(handle, v) {
116
67
  handle.lineBuf = parts.pop() ?? "";
117
68
  return parts.filter((l) => l !== "");
118
69
  }
70
+ export async function mirrorMonitorPollLane(handle, v) {
71
+ if (handle.outputFile === undefined || (v.stdout.length === 0 && v.stderr.length === 0))
72
+ return;
73
+ try {
74
+ const ap = await handle.env.appendFile(handle.outputFile, v.stdout + v.stderr);
75
+ if (!ap.ok)
76
+ handle.spool.mirrorFailed = true;
77
+ }
78
+ catch {
79
+ handle.spool.mirrorFailed = true;
80
+ }
81
+ }
119
82
  function consumeStormToken(handle, now) {
120
83
  const gained = Math.floor((now - handle.stormRefilledAt) / handle.stormRefillIntervalMs);
121
84
  if (gained > 0) {
@@ -165,6 +128,7 @@ export function startMonitorWatcherLane(core, id) {
165
128
  ...(handle.toolUseId !== undefined ? { toolUseId: handle.toolUseId } : {}),
166
129
  status,
167
130
  ...(status === "killed" && handle.stoppedBy !== undefined ? { stoppedBy: handle.stoppedBy } : {}),
131
+ ...(handle.outputFile !== undefined ? { output_file: handle.outputFile } : {}),
168
132
  summary: `${terminalTaskSummary("monitor", (handle.description ?? "monitor").slice(0, 200), status, exitCode)} — ${detail}${droppedGapNote(handle.spool)}`,
169
133
  ...(finalLines.length > 0 ? { lines: finalLines.map(clipMonitorLine), result: clipMonitorEvent(finalLines.map(clipMonitorLine).join("\n")), ...(status === "killed" ? { partial: true } : {}) } : {}),
170
134
  ...(handle.completionId !== undefined ? { completionId: handle.completionId } : {}),
@@ -190,6 +154,12 @@ export function startMonitorWatcherLane(core, id) {
190
154
  return terminal("failed", `monitor lost its process (${r.error.message}); watch ended.${pendingSuppressionNote()}`, pendingFinalLines([]));
191
155
  }
192
156
  pollFailures = 0;
157
+ const mirrored = mirrorMonitorPollLane(handle, r.value);
158
+ handle.mirrorInFlight = mirrored;
159
+ await mirrored;
160
+ handle.mirrorInFlight = undefined;
161
+ if (core.handles.get(id) !== handle || handle.status !== "running")
162
+ return stop();
193
163
  const spool = handle.spool;
194
164
  const lines = absorbMonitorPollLane(handle, r.value);
195
165
  handle.status = statusFromBackground(r.value.status, r.value.exitCode);
@@ -254,7 +224,7 @@ export function startMonitorWatcherLane(core, id) {
254
224
  handle.status = "killed";
255
225
  handle.stoppedBy = handle.stopSource ?? "system";
256
226
  return terminal("killed", `auto-stopped: too much output (${suppressed} event batch(es) suppressed over ${overloadSecs}s of sustained overload; sustained budget is ${handle.maxBatchesPerMinute} batches/minute). ` +
257
- `The process was killed; its full output remains readable via TaskOutput. Restart it with a quieter command (filter its output) if you still need the watch.`, pendingFinalLines(lines));
227
+ `The process was killed; ${monitorOutputReading(handle, "its full output")}. Restart it with a quieter command (filter its output) if you still need the watch.`, pendingFinalLines(lines));
258
228
  }
259
229
  if ((handle.suppressedBatches ?? 0) > 0) {
260
230
  const suppressed = handle.suppressedBatches;
@@ -269,7 +239,7 @@ export function startMonitorWatcherLane(core, id) {
269
239
  ...(handle.toolUseId !== undefined ? { toolUseId: handle.toolUseId } : {}),
270
240
  status: "event",
271
241
  seq: handle.seq,
272
- summary: `${(handle.description ?? "monitor").slice(0, 200)} — ${suppressed} event batch(es) suppressed (output rate too high); the suppressed output is still readable via TaskOutput`,
242
+ summary: `${(handle.description ?? "monitor").slice(0, 200)} — ${suppressed} event batch(es) suppressed (output rate too high); ${monitorOutputReading(handle, "the suppressed output")}`,
273
243
  result: note,
274
244
  });
275
245
  }
@@ -310,7 +280,7 @@ export async function pollMonitorLane(handle, filter, deadline, signal) {
310
280
  }
311
281
  catch {
312
282
  return {
313
- content: `Error (TaskOutput): invalid filter regex: ${filter}`,
283
+ content: `Error (task poll): invalid filter regex: ${filter}`,
314
284
  details: { task_id: handle.id, type: "monitor", status: handle.status, retrieval_status: "not_ready" },
315
285
  isError: true,
316
286
  };
@@ -327,11 +297,10 @@ export async function pollMonitorLane(handle, filter, deadline, signal) {
327
297
  running,
328
298
  handleStatus: handle.status,
329
299
  shape,
330
- rolledExtraClause: monitorSpillNote(handle),
331
300
  drainNote: spool.drainFailed === true ? "[!] the final output drain at stop failed — the tail of the output may be missing\n" : "",
332
301
  });
333
302
  return {
334
- content: delimitUntrusted(`TaskOutput ${handle.id}`, body),
303
+ content: delimitUntrusted(`task ${handle.id}`, body),
335
304
  details: {
336
305
  task_id: handle.id,
337
306
  type: "monitor",
@@ -354,7 +323,14 @@ function consumePendingSuppressionNote(handle) {
354
323
  if (suppressed <= 0)
355
324
  return "";
356
325
  handle.suppressedBatches = 0;
357
- return ` [${suppressed} event batch(es) suppressed before the watch ended — output rate was too high; the suppressed output is still readable via TaskOutput.]`;
326
+ return ` [${suppressed} event batch(es) suppressed before the watch ended — output rate was too high; ${monitorOutputReading(handle, "the suppressed output")}.]`;
327
+ }
328
+ function monitorOutputReading(handle, what) {
329
+ if (handle.outputFile === undefined)
330
+ return `${what} was not kept (no output file could be created for this watch)`;
331
+ return handle.spool.mirrorFailed === true
332
+ ? `${what} is only partly in its output file (${handle.outputFile} — an append failed, so it is not the whole output)`
333
+ : `${what} is in its output file (${handle.outputFile} — Read it)`;
358
334
  }
359
335
  function explicitStopTerminalNote(handle, alreadyGone) {
360
336
  const label = (handle.description ?? "monitor").slice(0, 200);
@@ -367,6 +343,7 @@ function explicitStopTerminalNote(handle, alreadyGone) {
367
343
  ...(handle.toolUseId !== undefined ? { toolUseId: handle.toolUseId } : {}),
368
344
  status: "killed",
369
345
  ...(handle.stoppedBy !== undefined ? { stoppedBy: handle.stoppedBy } : {}),
346
+ ...(handle.outputFile !== undefined ? { output_file: handle.outputFile } : {}),
370
347
  summary: `${terminalTaskSummary("monitor", label, "killed")} — ${detail}${droppedGapNote(handle.spool)}`,
371
348
  ...(handle.completionId !== undefined ? { completionId: handle.completionId } : {}),
372
349
  });
@@ -377,11 +354,13 @@ export async function stopMonitorLane(core, handle) {
377
354
  handle.timers.clearInterval(handle.watcher);
378
355
  handle.watcher = undefined;
379
356
  }
357
+ let finalIncrement;
380
358
  if (wasRunning && handle.tickInFlight !== true) {
381
359
  try {
382
360
  const drained = await handle.env.pollBackground(handle.shellId);
383
361
  if (drained.ok) {
384
362
  const lines = absorbMonitorPollLane(handle, drained.value);
363
+ finalIncrement = drained.value;
385
364
  const finalLines = handle.lineBuf !== "" ? [...lines, handle.lineBuf] : lines;
386
365
  handle.lineBuf = "";
387
366
  if (finalLines.length > 0 && handle.status === "running") {
@@ -407,9 +386,12 @@ export async function stopMonitorLane(core, handle) {
407
386
  handle.spool.drainFailed = true;
408
387
  }
409
388
  }
410
- const drainNote = handle.spool.drainFailed === true ? " (the final output drain failed — TaskOutput may be missing the last window)" : "";
389
+ const drainNote = handle.spool.drainFailed === true ? " (the final output drain failed — the output file may be missing the last window)" : "";
411
390
  core.markStopSource(handle.id, "parent");
412
391
  const r = await handle.env.killBackground(handle.shellId);
392
+ await handle.mirrorInFlight;
393
+ if (finalIncrement !== undefined)
394
+ await mirrorMonitorPollLane(handle, finalIncrement);
413
395
  if (handle.status !== "running") {
414
396
  return {
415
397
  content: wasRunning ? `Terminated ${handle.id}.${drainNote}${consumePendingSuppressionNote(handle)}` : alreadyTerminalStopNote(handle.id, handle.status),
@@ -4,7 +4,7 @@ import { type WorkflowRunStore } from "./workflow-run-store.js";
4
4
  import type { BackgroundAgentRecord, BackgroundAgentStore } from "./background-agent-store.js";
5
5
  import type { WorkflowHandle, WorkflowRun } from "../orchestration/workflow.js";
6
6
  import type { TaskNotificationPayload } from "./task-notification.js";
7
- import type { ToolResultStore } from "./tool-result-store.js";
7
+ import type { TaskArtifactSeat } from "./tool-result-store.js";
8
8
  import type { AssertAllKeysHandled } from "./ask-origin.js";
9
9
  export type SemaTaskType = "background_bash" | "workflow" | "background_agent" | "monitor";
10
10
  /** design/134 §3.3 (R3): WHO initiated a kill — recorded at the initiation site (first-marker-wins),
@@ -86,8 +86,8 @@ export interface UnifiedTaskOutput {
86
86
  * per-task-kind poll/stop arm). `UnifiedTaskOutput` (the `details` face) has no isError channel of its
87
87
  * own — it is a REQUIRED-field wire shape consumed by callers beyond these two tools too, so isError is
88
88
  * carried as a sibling on the WRAPPER instead (trap avoidance per the E1 sweep: never carry across isError
89
- * through a narrower helper contract). Optional, absent/false = success — `createTaskOutputTool`/
90
- * `createTaskStopTool` forward it onto the real `ToolReturn` at the tool boundary. Every internal helper
89
+ * through a narrower helper contract). Optional, absent/false = success — `createTaskStopTool` forwards it onto
90
+ * the real `ToolReturn` at the tool boundary. Every internal helper
91
91
  * keeps constructing `content`/`details` exactly as before; this only adds a place to say "and this one
92
92
  * is a genuine failure" where the failure is actually detected.
93
93
  */
@@ -107,10 +107,18 @@ export interface SemaTaskHandle {
107
107
  createdAt: number;
108
108
  updatedAt: number;
109
109
  outputFile?: string;
110
+ /** The ref a background agent's or workflow's full result was stored under when its completion frame cut it
111
+ * (`persistTaskArtifact`, recorded by {@link import("./task-registry.js").TaskRegistry.recordArtifactRef}). */
112
+ artifactRef?: string;
110
113
  /** P1-3 — see {@link UnifiedTaskOutput.completionId}. Minted fill-once at this task's own settle
111
114
  * point ({@link mintCompletionId}); absent until the task reaches a terminal status. */
112
115
  completionId?: string;
113
116
  }
117
+ /** THE read handle of one background task, as every model-facing list of tasks names it: a command's output file
118
+ * (Read it), or the ref a cut result is stored under (ReadToolResult). `undefined` = nothing to read beyond what its
119
+ * notification carried. One reading — the post-compaction table and a dropped-notification line both call it. A
120
+ * blank path or ref (empty or all whitespace) names nothing, so it reads as no handle. */
121
+ export declare function taskReadHandleText(h: Pick<SemaTaskHandle, "outputFile" | "artifactRef">): string | undefined;
114
122
  /** Mint a cross-channel completion correlation id ONCE per
115
123
  * handle/record, fill-once (first writer wins): every settle/direct-terminal-flip site calls this
116
124
  * instead of writing `completionId` directly, so no matter how many terminal-transition sites a lane
@@ -144,7 +152,7 @@ export interface BackgroundBashTaskHandle extends SemaTaskHandle {
144
152
  * (`TaskSpec.retainBackgroundProcesses`) or the env capability declares retain, and by a run teardown
145
153
  * whose own spec declares it. In-memory only (shell-lane rows are never persisted); a row without the
146
154
  * field reads as not marked. The row is the delivered daemon's ONLY management surface — while the process runs it survives the
147
- * per-run evict (TaskOutput/TaskStop resolve through this map; the watcher must stay live to mint
155
+ * per-run evict (TaskStop and the host poll resolve through this map; the watcher must stay live to mint
148
156
  * the natural-exit receipt) and rides every later run's dispose except-list on the same env
149
157
  * ({@link TaskRegistry.runningShellIds}). A terminal row evicts normally. Terminals: explicit
150
158
  * TaskStop, the process's own exit (watcher settle), or env destruction (watcher env-death settle)
@@ -158,7 +166,7 @@ export interface BackgroundBashTaskHandle extends SemaTaskHandle {
158
166
  * launcher did not know the lane (a host tool registering directly): the owning run's teardown supplies it. */
159
167
  retainStatedAtLaunch?: true;
160
168
  /** design/116 §7 G2b: when a watcher is attached, the registry accumulates the FULL output here (rolling
161
- * bound) — TaskOutput then serves a RE-READABLE snapshot (CC semantics) instead of a consume-once cursor.
169
+ * bound) — the host poll then serves a RE-READABLE snapshot (CC semantics) instead of a consume-once cursor.
162
170
  * `timedOut`/`timeoutSec` record a SELF-INFLICTED background-timeout kill (the env's per-shell budget
163
171
  * fired), so later re-readable polls keep rendering it distinguishably from an external stop.
164
172
  * `mirrorFailed` records that at least one append to the advertised output FILE failed — the terminal
@@ -178,6 +186,9 @@ export interface BackgroundBashTaskHandle extends SemaTaskHandle {
178
186
  droppedBytes?: number;
179
187
  dropUnknown?: true;
180
188
  };
189
+ /** Where the command's retained output is stored when its output file is missing or incomplete — the result-artifact
190
+ * seat the launching call carried (`ToolExecuteContext.taskArtifacts`); absent ⇒ nothing is stored. */
191
+ taskArtifacts?: TaskArtifactSeat;
181
192
  watcher?: ReturnType<typeof setInterval>;
182
193
  /** design/134 §3.3 (R3 MED, 修类不修点): same attribution pair as the agent handle — see there. */
183
194
  stopSource?: StopSource;
@@ -214,8 +225,6 @@ export interface WorkflowTaskHandle extends SemaTaskHandle {
214
225
  * session end — a would-be regression caught by cross-review before this shipped (see docs/
215
226
  * REVIEW-BACKLOG.md's "RB-215 复核" entry for the full incident). */
216
227
  sessionScoped?: true;
217
- /** See {@link RegisterWorkflowInput.onServedTerminal}. Cleared after the single fire. */
218
- onServedTerminal?: () => void;
219
228
  /** The bounded return value, captured on the done-hook so the STORE-LESS in-memory lane's
220
229
  * terminal poll can hand it over too (the launch note promises it; without a store there was no result). */
221
230
  result?: string;
@@ -260,7 +269,9 @@ export interface BackgroundAgentTaskHandle extends SemaTaskHandle {
260
269
  parentSessionId?: string;
261
270
  rootSessionId?: string;
262
271
  /** design/151 S1a — the child's store session id (transcript/resume anchor), bound once the child
263
- * session is minted ({@link TaskRegistry.bindBackgroundAgentSession}). */
272
+ * session is minted ({@link TaskRegistry.bindBackgroundAgentSession}) and removed — together with the
273
+ * durable record's copy — by the successful release of that session
274
+ * ({@link TaskRegistry.releaseDurableTranscriptAnchor}). Read through `childSessionAnchorOf` only. */
264
275
  sessionId?: string;
265
276
  /** design/151 S1a — the durable write lane (present iff the registration wired a store). */
266
277
  durable?: DurableAgentLane;
@@ -331,7 +342,7 @@ export interface BackgroundAgentTaskHandle extends SemaTaskHandle {
331
342
  * skips it; `reapSessionBackground` is its terminal anchor. Explicit flag, never inferred from key values
332
343
  * (hostTaskId===sessionId deployments would otherwise be ambiguous). */
333
344
  sessionScoped?: true;
334
- /** Terminal snapshot (bounded, {@link BG_AGENT_RESULT_MAX} in subagent.ts) — served by TaskOutput
345
+ /** Terminal snapshot (bounded, {@link BG_AGENT_RESULT_MAX} in subagent.ts) — served by the host poll
335
346
  * once the child finishes. */
336
347
  result?: string;
337
348
  /** The FULL result (bounded only by the defensive {@link BG_AGENT_RESULT_FULL_MAX} ceiling
@@ -340,26 +351,6 @@ export interface BackgroundAgentTaskHandle extends SemaTaskHandle {
340
351
  * ~2-4K chars with no disclosure — clipTaskOutput's own file-pointer/offload-friendly design at the
341
352
  * poll layer was structurally unreachable because `result` itself could never be long enough to need it. */
342
353
  resultFull?: string;
343
- /** design/158 S1 (RB-205-B 半) — the tool-result-store ref `resultFull`'s full text was spilled to,
344
- * the FIRST time a poll's `clipTaskOutput` actually cut it (lazy write, not at settle time). Cached
345
- * here so every LATER poll within the SAME cycle reuses the same ref instead of re-writing (the
346
- * store's own `put` is write-once too, but re-deriving/re-calling it every poll would still cost a
347
- * redundant round-trip on a durable backend, and a changing ref across polls would be a needless
348
- * disclosure churn). {@link reviveBackgroundAgentLane} clears this on revive — the cycle's full text
349
- * is gone, so a stale ref must not be reused across cycles. Ref format ties in `reviveCycle` (see
350
- * {@link import("./task-registry-agent.js").spillClippedAgentResult}) precisely so a revived cycle's
351
- * eventual spill lands under a DIFFERENT ref rather than colliding with (and being silently refused
352
- * by the write-once store under) cycle 1's. */
353
- spillRef?: string;
354
- /** Backlog #169 — the spill `put` for the CURRENT revive cycle threw or rejected. One-time latch,
355
- * scoped to the cycle ({@link import("./task-registry-agent.js").reviveBackgroundAgentLane} clears
356
- * it in lockstep with `spillRef`): later polls serve the clipped text with an honest ref-free loss
357
- * note instead of retrying the write — the ref is minted deterministically, so the known permanent
358
- * failure class (the store's write-once/provenance conflict) would fail identically on every poll,
359
- * each retry a guaranteed-failure round trip to a durable backend. The monitor lane's
360
- * `spillFailed` twin (same degrade discipline, different write shape — that one is fire-and-forget,
361
- * this one is awaited). */
362
- spillFailed?: true;
363
354
  error?: string;
364
355
  /** RB-386② — the machine-readable failure code beside `error`, threaded from the settle
365
356
  * mint point (subagent.ts computes it ONCE from the child's TaskResult.errorCode taxonomy /
@@ -416,7 +407,7 @@ export interface MonitorTimers {
416
407
  }
417
408
  export declare const defaultMonitorTimers: MonitorTimers;
418
409
  /** design/135 G2: Monitor watch — background_bash's near kin, but the watcher streams stdout LINES as
419
- * batched event notifications instead of firing one terminal notify. Spool stays re-readable (TaskOutput). */
410
+ * batched event notifications instead of firing one terminal notify. Spool stays re-readable (host poll) and the output file holds the full record. */
420
411
  export interface MonitorTaskHandle extends SemaTaskHandle {
421
412
  type: "monitor";
422
413
  env: ExecutionEnv & BackgroundShellCapability;
@@ -437,7 +428,17 @@ export interface MonitorTaskHandle extends SemaTaskHandle {
437
428
  drainFailed?: true;
438
429
  timedOut?: boolean;
439
430
  timeoutSec?: number;
431
+ mirrorFailed?: true;
440
432
  };
433
+ /** See {@link BackgroundBashTaskHandle.taskArtifacts} — the same seat, for the watch's retained output. */
434
+ taskArtifacts?: TaskArtifactSeat;
435
+ /** The watch's output file (`createBackgroundOutputFile`, the bash lane's mint): every polled increment, stdout AND
436
+ * stderr, is appended to it — the full record the launch receipt and the terminal frame name, and the one place stderr
437
+ * is read from. Absent = the file could not be created. A failed append is accounted on `spool.mirrorFailed`. */
438
+ outputFile?: string;
439
+ /** The watcher tick's append to {@link outputFile} while it is in flight — a TaskStop that skips its own drain (the tick
440
+ * holds the env cursor) awaits it after the kill, so the terminal frame names a file that holds the tick's bytes. */
441
+ mirrorInFlight?: Promise<void>;
441
442
  /** Partial (newline-less) stdout tail awaiting completion — a line becomes an event only once terminated. */
442
443
  lineBuf: string;
443
444
  /** Per-batch monotonic counter → unique notification dedup keys (see task-notification.ts). */
@@ -487,40 +488,6 @@ export interface MonitorTaskHandle extends SemaTaskHandle {
487
488
  /** Terminal-notification once-latch — same discipline as the bash handle (fidelity R1-3). Only the
488
489
  * TERMINAL frame is latched; "event" frames are unaffected. */
489
490
  terminalNotified?: true;
490
- /** design/158 S2 (RB-364 半) — the offload store a ROLLED-OFF spool middle spills to, captured at
491
- * REGISTRATION time (RegisterMonitorInput's additive field), not per-poll like the background_agent
492
- * lane's `TaskPollOptions.toolResultStore` (S1): the roll happens inside the watcher tick — an async
493
- * timer callback with no per-call "access" to thread a store through — so registration is the only
494
- * point that has one to hang on the handle. Absent ⇒ legal degrade: `rollSpoolText`'s `onDrop` hook
495
- * is simply never wired, byte-identical to pre-S2 rolling (design/158 §2.2). */
496
- toolResultStore?: ToolResultStore;
497
- /** design/158 S2 — the session id spilled refs are scoped under (same `TaskAccess.sessionId` role as
498
- * every other `buildToolResultRef` call site); captured at registration for the same reason as
499
- * `toolResultStore` above. */
500
- spillSessionId?: string;
501
- /** design/158 S2 — next segment index to mint for the STDOUT dropped-middle ref chain (0-based;
502
- * design/158 §3 "方案 a": a ref PER dropped segment, chained by index, rather than one ref with an
503
- * append primitive — ToolResultStore's contract is write-once with no append). stdout and stderr get
504
- * INDEPENDENT counters (this field vs `spillErrSegCount`) so each stream's own segments concatenate
505
- * back in original byte order without interleaving the other stream's drops between them. */
506
- spillSegCount?: number;
507
- /** design/158 S2 — the STDERR twin of {@link spillSegCount}. */
508
- spillErrSegCount?: number;
509
- /** design/158 S2 — cumulative chars (UTF-16 code units, `string.length`) handed to `store.put`
510
- * across every segment this handle has spilled so far (both streams combined) — the per-handle
511
- * disk-cap accounting ({@link import("./task-registry-monitor.js")} reads `MONITOR_SPILL_CAP_CHARS`
512
- * against this). The field used to be named `spillBytesUsed` while the ledger counted
513
- * chars — renamed to the axis it really measures (see the constant's own doc for why chars). */
514
- spillCharsUsed?: number;
515
- /** design/158 S2 — the per-handle spill cap (`MONITOR_SPILL_CAP_CHARS`) was reached; further
516
- * rolled-off middles are no longer spilled (already-written segments stay readable — "earlier
517
- * segments retained"). One-time latch; the poll disclosure reads it to stop claiming full ref
518
- * coverage. */
519
- spillCapped?: true;
520
- /** design/158 S2 — at least one `store.put` for this handle rejected or threw. One-time latch; the
521
- * poll disclosure downgrades its wording once this is set (never claims the ref chain is complete —
522
- * the fire-and-forget write may have silently failed; see task-registry-monitor.ts's spill helper). */
523
- spillFailed?: true;
524
491
  }
525
492
  export type RegisteredTaskHandle = BackgroundBashTaskHandle | WorkflowTaskHandle | BackgroundAgentTaskHandle | MonitorTaskHandle;
526
493
  export interface RegisterMonitorInput extends TaskAccess {
@@ -551,9 +518,10 @@ export interface RegisterMonitorInput extends TaskAccess {
551
518
  /** Burst capacity of the storm bucket (default MONITOR_STORM_BURST = CC's 10). */
552
519
  stormBurst?: number;
553
520
  now?: number;
554
- /** design/158 S2 (RB-364 半) — the offload store a rolled-off spool middle spills to (see
555
- * {@link MonitorTaskHandle.toolResultStore}). Absent ⇒ legal degrade, byte-identical rolling. */
556
- toolResultStore?: ToolResultStore;
521
+ /** The watch's output file (see {@link MonitorTaskHandle.outputFile}); absent when it could not be created. */
522
+ outputFile?: string;
523
+ /** See {@link MonitorTaskHandle.taskArtifacts}. */
524
+ taskArtifacts?: TaskArtifactSeat;
557
525
  }
558
526
  export interface RegisterWorkflowInput extends TaskAccess {
559
527
  runId: string;
@@ -568,13 +536,6 @@ export interface RegisterWorkflowInput extends TaskAccess {
568
536
  * (its completion notification routes to the session) — deliberately unlike a background agent's
569
537
  * live handle, whose sibling-turn invisibility is a channel-discipline ruling (§3.1c). */
570
538
  originatingSessionId?: string;
571
- /**
572
- * Fired AT MOST ONCE when a `pollTask` through THIS registry entry (= the originating
573
- * session's own lane; cross-session store-fallback polls don't fire it) serves a TERMINAL snapshot.
574
- * The RunWorkflow tool wires it to {@link import("../orchestration/run-workflow-tool.js").WorkflowCompletionNotifier.ackServed}
575
- * so the deployment can drop the now-redundant completion-inbox entry. Errors are swallowed.
576
- */
577
- onServedTerminal?: () => void;
578
539
  }
579
540
  /** T2A-7 (2026-07-05 soak): one blocked-poll step, CLAMPED to the caller's deadline — a small timeoutMs
580
541
  * (e.g. 10ms) must not sleep the full 400ms step (~40× overshoot, and the overshoot window even served a
@@ -628,31 +589,11 @@ export declare function clipTaskOutput(s: string, fullOutputPath?: string): stri
628
589
  export declare function statusFromBackground(status: string, exitCode?: number): SemaTaskStatus;
629
590
  /** Rolling middle-drop bound for the bash spool, shared by the watcher's per-tick accumulate and the
630
591
  * teardown settle's terminal flush: keep head+tail halves within `cap`, account the dropped middle in
631
- * `rolledChars` (the honesty counter the poll face reports as permanently-dropped bytes).
632
- *
633
- * design/158 S2 (RB-364 半): `onDrop`, when given, is called SYNCHRONOUSLY (before this function
634
- * returns) with exactly the middle substring being dropped — the ONE place that substring is ever
635
- * materialized, so a caller wanting to preserve it (the monitor lane's spill-to-offload-store) does not
636
- * need to re-derive the same slice arithmetic a second time. Every EXISTING caller (the background_bash
637
- * lane, task-registry.ts) omits the 4th argument, so their behavior — return value AND `rolledChars`
638
- * accounting — is untouched byte-for-byte; the callback is a pure side-channel hook. */
592
+ * `rolledChars` (the honesty counter the poll face reports as permanently-dropped bytes). The full record of
593
+ * a background command or a watch is its output file; the spool is the bounded copy. */
639
594
  export declare function rollSpoolText(spool: {
640
595
  rolledChars: number;
641
- }, s: string, cap: number, onDrop?: (dropped: string) => void): string;
642
- /** design/158 S2 (RB-364 半) — per-monitor-handle hard cap on cumulative CHARS (UTF-16 code units)
643
- * spilled to the offload store (design/158 §3's S3 half, pulled forward alongside S2). Once a
644
- * handle's running total reaches this, further rolled-off middles are simply not spilled —
645
- * already-written segments stay readable (the poll disclosure says "earlier segments retained"),
646
- * matching the pre-S2 loss shape for whatever is dropped PAST the cap. Exported so the boundary is a
647
- * testable contract, not a buried literal.
648
- *
649
- * The constant used to be named
650
- * `..._BYTES` while the ledger added `dropped.length` — chars, up to ~3× fewer than UTF-8 bytes on
651
- * multibyte content. CHARS is the axis kept (name changed, arithmetic untouched) because it is the
652
- * offload store family's own coordinate (`InMemoryToolResultStore.maxTotalChars` evicts by
653
- * `content.length`; `ToolResultSlice.totalChars`) and the spool's `rolledChars` axis — one unit
654
- * end-to-end; a `Buffer.byteLength` ledger here would sit crosswise to the store's own cap. */
655
- export declare const MONITOR_SPILL_CAP_CHARS: number;
596
+ }, s: string, cap: number): string;
656
597
  /** Fold one poll's env-side-loss disclosure into the spool's account. The env's
657
598
  * tail buffer evicts its HEAD under pressure (node-execution-env 8MB bound) — those bytes are gone
658
599
  * before any watcher ever saw them, which is a different loss than the registry-side `rolledChars`
@@ -744,11 +685,10 @@ export interface RenderableSpool {
744
685
  dropUnknown?: true;
745
686
  }
746
687
  /** The per-lane inputs {@link renderSpoolBody} cannot derive from the spool itself.
747
- * `rolledExtraClause` / `drainNote` are PRE-RENDERED STRINGS, deliberately not booleans or a lane
748
- * discriminator: the renderer must stay ignorant of which lane called it, otherwise the two monitor-only
749
- * disclosures (design/158 S2 spill refs; RB-239 stop-time drain failure) come back as in-renderer
750
- * branches on a kind switch — the exact shape that let the two hand-copied renderers drift in the first
751
- * place. Both are "" on a lane that has no such disclosure. */
688
+ * `drainNote` is a PRE-RENDERED STRING, deliberately not a boolean or a lane discriminator: the renderer must stay
689
+ * ignorant of which lane called it, otherwise the monitor-only disclosure (RB-239 stop-time drain failure) comes back
690
+ * as an in-renderer branch on a kind switch — the exact shape that let the two hand-copied renderers drift in the
691
+ * first place. "" on a lane that has no such disclosure. */
752
692
  export interface SpoolBodyOptions {
753
693
  /** The handle is still running (drives the "running" display status). */
754
694
  running: boolean;
@@ -756,12 +696,10 @@ export interface SpoolBodyOptions {
756
696
  handleStatus: SemaTaskStatus;
757
697
  /** The lane's filter+clip projection, applied to stdout and stderr alike. */
758
698
  shape: (text: string) => string;
759
- /** Appended INSIDE the roll note, before its newline ("" when the lane has no extra clause). */
760
- rolledExtraClause: string;
761
699
  /** A full banner line (own trailing newline) rendered after the drop note, or "". */
762
700
  drainNote: string;
763
701
  }
764
- /** The ONE renderer for a re-readable spool's TaskOutput body,
702
+ /** The ONE renderer for a re-readable spool's host-poll body,
765
703
  * shared by the monitor lane (pollMonitorLane) and the bash spool lane (pollBackgroundBash).
766
704
  *
767
705
  * Both faces were hand-copied twins carrying three real disclosure bugs' worth of wording (env-side
@@ -810,7 +748,15 @@ export declare function assertOwnership(input: TaskAccess, site: string): void;
810
748
  * (design/136 §2.3 S-1 定谳 posture, now positive-match on every arm). Exported: the run-workflow
811
749
  * tool's resume-ownership recheck and a deployment's serving layer apply the SAME predicate. */
812
750
  export declare function canAccessWorkflowRun(run: Pick<WorkflowRun, "scope" | "sourceTaskId" | "originatingSessionId">, access: TaskAccess): boolean;
813
- export declare function formatWorkflowRun(run: WorkflowRun): UnifiedTaskResult;
751
+ /** How much of a run {@link formatWorkflowRun} keeps: the poll reply is display-bounded; the stored record (read back by
752
+ * `ReadToolResult`, which pages) keeps every agent row and every finished agent's output. One projection, two bounds. */
753
+ export interface WorkflowRecordBounds {
754
+ readonly rows: number;
755
+ readonly partialResults: number;
756
+ }
757
+ /** The stored record's bounds: none. */
758
+ export declare const WORKFLOW_RECORD_WHOLE: WorkflowRecordBounds;
759
+ export declare function formatWorkflowRun(run: WorkflowRun, bounds?: WorkflowRecordBounds): UnifiedTaskResult;
814
760
  /** design/157 B13 一期定稿(二期细察补充 §「私有成员解法」)——the kernel-面 seam the MON/WF lane free
815
761
  * functions call through instead of `this`: exactly the 5 members `startMonitorWatcher`/`stopMonitor`/
816
762
  * `registerMonitor`/`registerWorkflow` actually reach into (`this.*` 耦合 grep 逐方法统计,见 B13 档).
@@ -875,14 +821,6 @@ export declare const BG_AGENT_REAP_STOP_ERROR = "stopped (parent task ended or T
875
821
  * as this resolver, or an NFKC-equivalent spelling (fullwidth "main") skips the reserved lane and
876
822
  * reaches the description layers. One normalizer, every name face. */
877
823
  export declare function normalizeAgentName(s: string): string;
878
- /** CC `gtr` (fable 复审 F1 — 亲核 @16169850: NOT plain Levenshtein but OSA / restricted
879
- * Damerau-Levenshtein, WITH the adjacent-transposition term `o[i][s]=min(o[i][s], o[i-2][s-2]+1)`
880
- * when `e[i-1]===t[s-2] && e[i-2]===t[s-1]`). The transposition matters: a typo like "tset"→"test"
881
- * is distance 1 (CC has a Did-you-mean), plain Levenshtein would call it 2. */
882
- export declare function editDistance(a: string, b: string): number;
883
- /** CC `htr` shape (206:519814-519827): candidates within Levenshtein ≤2 (length-diff ≤2 pre-filter),
884
- * best-first; the single best is the "Did you mean" suggestion (`htr(e, keys, 1)[0]`, 206:575196). */
885
- export declare function closestName(query: string, candidates: Iterable<string>): string | undefined;
886
824
  /** DEFAULT-DENY on BOTH axes — the old predicate skipped
887
825
  * a missing axis (owner-less handle = readable by everyone in scope; scope-less handle = readable
888
826
  * across scopes), splitting polarity with `canAccessAgentRecord` and re-opening the session-axis