@sema-agent/core 7.72.0 → 7.74.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 (375) hide show
  1. package/CHANGELOG.md +565 -0
  2. package/dist/agents/inherited-tool-pool.d.ts +26 -1
  3. package/dist/agents/inherited-tool-pool.js +46 -2
  4. package/dist/agents/list-agents-tool.js +1 -1
  5. package/dist/agents/parked-resume-drive.d.ts +10 -0
  6. package/dist/agents/parked-resume-drive.js +9 -0
  7. package/dist/agents/retain-ledger.d.ts +3 -0
  8. package/dist/agents/retain-ledger.js +3 -3
  9. package/dist/agents/send-message-tool.js +5 -4
  10. package/dist/agents/send-user-message-tool.d.ts +12 -0
  11. package/dist/agents/send-user-message-tool.js +67 -0
  12. package/dist/agents/subagent-steps.d.ts +9 -0
  13. package/dist/agents/subagent-steps.js +38 -0
  14. package/dist/agents/subagent.d.ts +2 -0
  15. package/dist/agents/subagent.js +43 -12
  16. package/dist/agents/verify.js +23 -8
  17. package/dist/agents/yield-adoption.js +3 -1
  18. package/dist/brain/anthropic.d.ts +42 -1
  19. package/dist/brain/anthropic.js +68 -13
  20. package/dist/brain/failover.d.ts +5 -0
  21. package/dist/brain/failover.js +51 -22
  22. package/dist/brain/model-lane.d.ts +12 -3
  23. package/dist/brain/model-lane.js +5 -5
  24. package/dist/brain/open-responses.js +7 -8
  25. package/dist/brain/openai.js +31 -24
  26. package/dist/brain/route-adjudicator.d.ts +33 -4
  27. package/dist/brain/route-adjudicator.js +49 -12
  28. package/dist/brain/stream-engine.js +166 -156
  29. package/dist/brain/stream-shared.d.ts +4 -3
  30. package/dist/brain/stream-shared.js +2 -2
  31. package/dist/core/actions-digest.d.ts +43 -0
  32. package/dist/core/actions-digest.js +22 -0
  33. package/dist/core/allow-entry.js +4 -4
  34. package/dist/core/ask-class.d.ts +2 -2
  35. package/dist/core/ask-headline.d.ts +1 -1
  36. package/dist/core/ask-origin.d.ts +44 -4
  37. package/dist/core/ask-origin.js +29 -10
  38. package/dist/core/auto-mode.d.ts +7 -9
  39. package/dist/core/auto-mode.js +114 -8
  40. package/dist/core/background-agent-store.d.ts +1 -0
  41. package/dist/core/background-agent-store.js +49 -8
  42. package/dist/core/checkpoint-features.d.ts +3 -2
  43. package/dist/core/checkpoint-features.js +1 -1
  44. package/dist/core/checkpoint-rekey.d.ts +1 -1
  45. package/dist/core/checkpoint-rekey.js +6 -1
  46. package/dist/core/checkpoint-requirements.d.ts +23 -3
  47. package/dist/core/checkpoint-requirements.js +5 -1
  48. package/dist/core/checkpoint-row-verdict.d.ts +1 -1
  49. package/dist/core/checkpoint-row-verdict.js +9 -3
  50. package/dist/core/checkpoint-store.d.ts +26 -2
  51. package/dist/core/checkpoint-store.js +9 -2
  52. package/dist/core/child-clamp-seats.d.ts +15 -0
  53. package/dist/core/child-clamp-seats.js +15 -0
  54. package/dist/core/config-refusal-codes.d.ts +1 -1
  55. package/dist/core/config-refusal-codes.js +1 -0
  56. package/dist/core/cron.js +9 -1
  57. package/dist/core/delegation-frames.d.ts +1 -0
  58. package/dist/core/delegation-frames.js +1 -1
  59. package/dist/core/deployment-shape.d.ts +7 -0
  60. package/dist/core/deployment-shape.js +19 -0
  61. package/dist/core/engine-capabilities.d.ts +13 -1
  62. package/dist/core/engine-capabilities.js +1 -1
  63. package/dist/core/engine-notice.d.ts +41 -28
  64. package/dist/core/engine-version.js +1 -1
  65. package/dist/core/entries-not-applied.d.ts +19 -7
  66. package/dist/core/entries-not-applied.js +33 -1
  67. package/dist/core/gate-fold.js +5 -4
  68. package/dist/core/gate-lanes.js +8 -12
  69. package/dist/core/gate-outcome.d.ts +8 -2
  70. package/dist/core/gate-outcome.js +10 -3
  71. package/dist/core/governance-codes.d.ts +14 -2
  72. package/dist/core/governance-codes.js +22 -6
  73. package/dist/core/hook-condition.d.ts +37 -0
  74. package/dist/core/hook-condition.js +567 -0
  75. package/dist/core/hooks.d.ts +5 -0
  76. package/dist/core/hooks.js +1 -0
  77. package/dist/core/host-instance.d.ts +23 -0
  78. package/dist/core/host-instance.js +69 -0
  79. package/dist/core/instruction-preview.d.ts +63 -0
  80. package/dist/core/instruction-preview.js +406 -0
  81. package/dist/core/leg-budget.d.ts +26 -0
  82. package/dist/core/leg-budget.js +9 -0
  83. package/dist/core/leg-identity.d.ts +51 -1
  84. package/dist/core/leg-identity.js +45 -2
  85. package/dist/core/manager-launch-check.d.ts +48 -0
  86. package/dist/core/manager-launch-check.js +64 -0
  87. package/dist/core/mcp-call-meta.d.ts +2 -2
  88. package/dist/core/mcp-injection-drop.d.ts +20 -10
  89. package/dist/core/mcp-injection-drop.js +9 -3
  90. package/dist/core/mcp-server-spec.d.ts +2 -1
  91. package/dist/core/member-outcome.d.ts +3 -2
  92. package/dist/core/member-outcome.js +1 -1
  93. package/dist/core/memory-engine/deletion-record.d.ts +46 -0
  94. package/dist/core/memory-engine/deletion-record.js +96 -0
  95. package/dist/core/memory-engine/engine.js +24 -16
  96. package/dist/core/memory-engine/file-backend.js +7 -5
  97. package/dist/core/memory-engine/projection-ledger.d.ts +1 -1
  98. package/dist/core/memory-engine/projection-ledger.js +1 -1
  99. package/dist/core/memory-engine/scope-contract.d.ts +18 -13
  100. package/dist/core/memory-engine/scope-contract.js +18 -18
  101. package/dist/core/memory-engine/sync-client.js +26 -6
  102. package/dist/core/memory-engine/sync.d.ts +20 -2
  103. package/dist/core/memory-engine/sync.js +18 -17
  104. package/dist/core/mode-policy.d.ts +25 -6
  105. package/dist/core/mode-policy.js +33 -8
  106. package/dist/core/model-seat.d.ts +8 -5
  107. package/dist/core/model-shell.d.ts +129 -0
  108. package/dist/core/model-shell.js +249 -0
  109. package/dist/core/mods/kernel/digest.d.ts +4 -0
  110. package/dist/core/mods/kernel/digest.js +5 -0
  111. package/dist/core/mods/kernel/dispatch.d.ts +3 -0
  112. package/dist/core/mods/kernel/dispatch.js +15 -6
  113. package/dist/core/mods/kernel/events.d.ts +21 -5
  114. package/dist/core/mods/kernel/events.js +19 -10
  115. package/dist/core/mods/kernel/hash-mirror.d.ts +1 -0
  116. package/dist/core/mods/kernel/hash-mirror.js +55 -0
  117. package/dist/core/mods/kernel/index.d.ts +1 -0
  118. package/dist/core/mods/kernel/index.js +1 -0
  119. package/dist/core/mods/kernel/package-reader.d.ts +48 -0
  120. package/dist/core/mods/kernel/package-reader.js +149 -0
  121. package/dist/core/mods/kernel/site-rules.d.ts +4 -0
  122. package/dist/core/mods/kernel/site-rules.js +13 -0
  123. package/dist/core/mods/package.d.ts +7 -3
  124. package/dist/core/mods/package.js +47 -80
  125. package/dist/core/own-property-receipt.js +11 -4
  126. package/dist/core/parent-spec-seat.d.ts +13 -11
  127. package/dist/core/parent-spec-seat.js +13 -9
  128. package/dist/core/peer-seat.js +3 -3
  129. package/dist/core/peer-task-store.d.ts +365 -0
  130. package/dist/core/peer-task-store.js +682 -0
  131. package/dist/core/permission-rule-consent.js +6 -11
  132. package/dist/core/permission-rule-model.d.ts +27 -0
  133. package/dist/core/permission-rule-model.js +33 -5
  134. package/dist/core/permission-rule-org.js +13 -3
  135. package/dist/core/permission-rule-provider.d.ts +35 -33
  136. package/dist/core/permission-rule-provider.js +38 -295
  137. package/dist/core/permission-rule-store.d.ts +181 -8
  138. package/dist/core/permission-rule-store.js +420 -17
  139. package/dist/core/permission-rule-sync.js +15 -1
  140. package/dist/core/permission-rules.js +4 -1
  141. package/dist/core/project-seat.d.ts +55 -0
  142. package/dist/core/project-seat.js +96 -0
  143. package/dist/core/protocol-http-auth.d.ts +3 -2
  144. package/dist/core/protocol-http-auth.js +26 -18
  145. package/dist/core/remote-env.d.ts +4 -4
  146. package/dist/core/retain-seat.d.ts +42 -0
  147. package/dist/core/retain-seat.js +76 -0
  148. package/dist/core/retired-keys.js +1 -0
  149. package/dist/core/rewind-refusal-codes.d.ts +8 -0
  150. package/dist/core/rewind-refusal-codes.js +12 -0
  151. package/dist/core/roles.d.ts +2 -2
  152. package/dist/core/roles.js +15 -1
  153. package/dist/core/rule-offer-read.d.ts +1 -1
  154. package/dist/core/rule-offer-read.js +32 -4
  155. package/dist/core/rule-store-fault.d.ts +9 -7
  156. package/dist/core/rule-store-fault.js +8 -3
  157. package/dist/core/run-ledger-seat.d.ts +66 -0
  158. package/dist/core/run-ledger-seat.js +70 -0
  159. package/dist/core/run-ledger.d.ts +332 -0
  160. package/dist/core/run-ledger.js +550 -0
  161. package/dist/core/runner/checkpoint-scope.d.ts +14 -3
  162. package/dist/core/runner/checkpoint-scope.js +16 -6
  163. package/dist/core/runner/compact-session.js +1 -1
  164. package/dist/core/runner/construction-doors.js +8 -0
  165. package/dist/core/runner/contracts.d.ts +21 -5
  166. package/dist/core/runner/cross-boundary-lane.d.ts +8 -1
  167. package/dist/core/runner/cross-boundary-lane.js +4 -0
  168. package/dist/core/runner/delegation-owner.d.ts +30 -0
  169. package/dist/core/runner/delegation-owner.js +20 -4
  170. package/dist/core/runner/finish-reason-seat.js +4 -2
  171. package/dist/core/runner/gate-exit.d.ts +7 -0
  172. package/dist/core/runner/gate-exit.js +2 -1
  173. package/dist/core/runner/leg-frame.js +3 -0
  174. package/dist/core/runner/model-lane-seat.d.ts +3 -0
  175. package/dist/core/runner/model-lane-seat.js +4 -0
  176. package/dist/core/runner/nested-memory-lane.d.ts +22 -5
  177. package/dist/core/runner/nested-memory-lane.js +91 -30
  178. package/dist/core/runner/person-path-rows.d.ts +27 -16
  179. package/dist/core/runner/person-path-rows.js +93 -15
  180. package/dist/core/runner/prepare-caps-and-workflow.js +98 -88
  181. package/dist/core/runner/prepare-config-doors.d.ts +1 -0
  182. package/dist/core/runner/prepare-config-doors.js +13 -7
  183. package/dist/core/runner/prepare-context-lane.js +1 -0
  184. package/dist/core/runner/prepare-delegation-surface.d.ts +3 -0
  185. package/dist/core/runner/prepare-delegation-surface.js +6 -0
  186. package/dist/core/runner/prepare-execution-env.d.ts +3 -3
  187. package/dist/core/runner/prepare-gate-stations.d.ts +6 -0
  188. package/dist/core/runner/prepare-gate-stations.js +3 -1
  189. package/dist/core/runner/prepare-hands-readface.d.ts +5 -2
  190. package/dist/core/runner/prepare-hands-readface.js +15 -3
  191. package/dist/core/runner/prepare-inherited-gate.d.ts +6 -3
  192. package/dist/core/runner/prepare-inherited-gate.js +13 -5
  193. package/dist/core/runner/prepare-offload-wrappers.js +1 -1
  194. package/dist/core/runner/prepare-run-refs.d.ts +1 -1
  195. package/dist/core/runner/prepare-run-refs.js +3 -2
  196. package/dist/core/runner/prepare-suspend-saga.d.ts +6 -2
  197. package/dist/core/runner/prepare-suspend-saga.js +4 -2
  198. package/dist/core/runner/prepare-task.js +42 -30
  199. package/dist/core/runner/prepare-turn-wiring.d.ts +4 -3
  200. package/dist/core/runner/prepare-turn-wiring.js +2 -1
  201. package/dist/core/runner/prepare-wiring-manifest.d.ts +3 -1
  202. package/dist/core/runner/prepare-wiring-manifest.js +8 -6
  203. package/dist/core/runner/resume-apply.js +11 -5
  204. package/dist/core/runner/resume-policy-outcome.js +5 -2
  205. package/dist/core/runner/resume-review-outcome.d.ts +3 -0
  206. package/dist/core/runner/resume-review-outcome.js +24 -1
  207. package/dist/core/runner/role-seat-defaulted.d.ts +3 -3
  208. package/dist/core/runner/role-seat-defaulted.js +1 -1
  209. package/dist/core/runner/rule-store-unreadable-notice.d.ts +1 -1
  210. package/dist/core/runner/rule-store-unreadable-notice.js +3 -3
  211. package/dist/core/runner/run-harness-handlers.js +4 -1
  212. package/dist/core/runner/run-identity-wiring.js +3 -2
  213. package/dist/core/runner/run-leg.js +5 -2
  214. package/dist/core/runner/run-notification-lane.js +20 -1
  215. package/dist/core/runner/run-settle-and-teardown.js +21 -12
  216. package/dist/core/runner/run-stop-and-final-verify.js +6 -0
  217. package/dist/core/runner/run-telemetry-and-budget-seats.js +1 -1
  218. package/dist/core/runner/runtask.d.ts +6 -2
  219. package/dist/core/runner/runtask.js +21 -9
  220. package/dist/core/runner/shell-env-withheld.d.ts +6 -4
  221. package/dist/core/runner/shell-env-withheld.js +25 -3
  222. package/dist/core/runner/stop-tail-notice.d.ts +10 -2
  223. package/dist/core/runner/stop-tail-notice.js +9 -2
  224. package/dist/core/runner/stream-settle-backstop.d.ts +1 -0
  225. package/dist/core/runner/stream-settle-backstop.js +1 -0
  226. package/dist/core/runner/sub-agent-deny-lists.js +9 -5
  227. package/dist/core/runner/task-start-doors.js +6 -3
  228. package/dist/core/runner/terminal-account.d.ts +6 -1
  229. package/dist/core/runner/terminal-account.js +16 -1
  230. package/dist/core/runner/tool-end-body.d.ts +1 -1
  231. package/dist/core/runner/tool-not-executed.d.ts +27 -8
  232. package/dist/core/runner/tool-not-executed.js +22 -11
  233. package/dist/core/runner/unreadable-person-rows.d.ts +2 -1
  234. package/dist/core/runner/write-protection-station.d.ts +1 -1
  235. package/dist/core/runner/write-protection-station.js +1 -1
  236. package/dist/core/runner-deps.d.ts +17 -10
  237. package/dist/core/secret-env.d.ts +61 -37
  238. package/dist/core/secret-env.js +49 -49
  239. package/dist/core/session-checkout.d.ts +3 -0
  240. package/dist/core/session-checkout.js +1 -0
  241. package/dist/core/session-store.d.ts +12 -6
  242. package/dist/core/session-store.js +26 -6
  243. package/dist/core/session.d.ts +31 -8
  244. package/dist/core/shell-read-silence.d.ts +40 -2
  245. package/dist/core/shell-read-silence.js +23 -4
  246. package/dist/core/store-contracts/checkpoint-store-contract.js +10 -0
  247. package/dist/core/store-contracts/peer-task-store-contract.d.ts +21 -0
  248. package/dist/core/store-contracts/peer-task-store-contract.js +516 -0
  249. package/dist/core/store-contracts/session-store-contract.d.ts +15 -2
  250. package/dist/core/store-contracts/session-store-contract.js +87 -3
  251. package/dist/core/store-contracts/workflow-journal-store-contract.d.ts +19 -1
  252. package/dist/core/store-contracts/workflow-journal-store-contract.js +89 -1
  253. package/dist/core/task-event.d.ts +14 -7
  254. package/dist/core/task-notification.d.ts +96 -10
  255. package/dist/core/task-notification.js +135 -6
  256. package/dist/core/task-registry-agent.d.ts +1 -0
  257. package/dist/core/task-registry-agent.js +1 -1
  258. package/dist/core/task-registry-shared.d.ts +12 -1
  259. package/dist/core/task-registry-shared.js +3 -1
  260. package/dist/core/task-registry-workflow.d.ts +1 -1
  261. package/dist/core/task-registry-workflow.js +9 -1
  262. package/dist/core/task-registry.d.ts +40 -2
  263. package/dist/core/task-registry.js +80 -15
  264. package/dist/core/task-result.d.ts +18 -3
  265. package/dist/core/task-spec-members.d.ts +3 -1
  266. package/dist/core/task-spec-members.js +19 -3
  267. package/dist/core/task-spec.d.ts +48 -22
  268. package/dist/core/tool-catalog-entries.js +2 -0
  269. package/dist/core/tool-gate-phase.d.ts +6 -3
  270. package/dist/core/tool-gate-phase.js +1 -0
  271. package/dist/core/tool-mount-facts.d.ts +8 -4
  272. package/dist/core/tool-mount-facts.js +7 -2
  273. package/dist/core/tool-mount-plan.d.ts +3 -1
  274. package/dist/core/tool-mount-plan.js +10 -3
  275. package/dist/core/tool-mount-static.d.ts +1 -1
  276. package/dist/core/tool-mount-static.js +4 -2
  277. package/dist/core/tool-result-store.d.ts +56 -3
  278. package/dist/core/tool-result-store.js +219 -25
  279. package/dist/core/tool-spec.d.ts +9 -2
  280. package/dist/core/trace.d.ts +3 -3
  281. package/dist/core/user-attachment.d.ts +5 -1
  282. package/dist/core/user-attachment.js +14 -7
  283. package/dist/core/wiring-manifest.d.ts +26 -20
  284. package/dist/core/wiring-manifest.js +7 -3
  285. package/dist/core/workflow-journal-store.d.ts +53 -10
  286. package/dist/core/workflow-journal-store.js +27 -4
  287. package/dist/core/workflow-run-store-contract.js +16 -0
  288. package/dist/core/workflow-run-store.d.ts +9 -7
  289. package/dist/core/workflow-run-store.js +4 -1
  290. package/dist/engine/execution-env/node-execution-env.d.ts +75 -1
  291. package/dist/engine/execution-env/node-execution-env.js +227 -13
  292. package/dist/engine/harness/types.d.ts +49 -1
  293. package/dist/engine/harness/types.js +10 -0
  294. package/dist/engine/llm/types.d.ts +13 -7
  295. package/dist/engine/llm/validation.d.ts +8 -1
  296. package/dist/engine/llm/validation.js +31 -2
  297. package/dist/engine/lsp/node-lsp-manager.js +2 -1
  298. package/dist/engine/session/import-validate.js +6 -1
  299. package/dist/engine/session/session.d.ts +15 -2
  300. package/dist/engine/session/session.js +34 -4
  301. package/dist/host-env.d.ts +10 -0
  302. package/dist/host-env.js +1 -0
  303. package/dist/index.d.ts +28 -9
  304. package/dist/index.js +22 -6
  305. package/dist/internal/harness-types.d.ts +1 -1
  306. package/dist/orchestration/goal.js +1 -1
  307. package/dist/orchestration/run-workflow-tool.js +40 -32
  308. package/dist/orchestration/workflow-park-adoption.d.ts +51 -12
  309. package/dist/orchestration/workflow-park-adoption.js +47 -12
  310. package/dist/orchestration/workflow-primitives.js +10 -1
  311. package/dist/orchestration/workflow-script-runner.d.ts +2 -2
  312. package/dist/orchestration/workflow-stop.d.ts +128 -0
  313. package/dist/orchestration/workflow-stop.js +156 -0
  314. package/dist/orchestration/workflow.d.ts +31 -7
  315. package/dist/orchestration/workflow.js +119 -57
  316. package/dist/prompts/manager-recipe.d.ts +18 -0
  317. package/dist/prompts/manager-recipe.js +24 -0
  318. package/dist/shell/lex.d.ts +2 -2
  319. package/dist/shell/lex.js +1 -1
  320. package/dist/stores/file/permission-rule-store.d.ts +3 -1
  321. package/dist/stores/file/permission-rule-store.js +0 -1
  322. package/dist/stores/file/workflow-journal-store.d.ts +16 -3
  323. package/dist/stores/file/workflow-journal-store.js +93 -5
  324. package/dist/stores/file/workflow-run-store.d.ts +1 -1
  325. package/dist/tools/fs/bash-model-shell.d.ts +23 -0
  326. package/dist/tools/fs/bash-model-shell.js +25 -0
  327. package/dist/tools/fs/bash-readonly-classifier.d.ts +6 -0
  328. package/dist/tools/fs/bash-readonly-classifier.js +3 -0
  329. package/dist/tools/fs/file-write-check.js +9 -3
  330. package/dist/tools/fs/fs-bash.js +13 -11
  331. package/dist/tools/fs/index.d.ts +8 -7
  332. package/dist/tools/fs/index.js +4 -4
  333. package/dist/tools/fs/read-deny-home.d.ts +1 -1
  334. package/dist/tools/fs/read-deny-home.js +5 -5
  335. package/dist/tools/fs/read-deny.d.ts +33 -8
  336. package/dist/tools/fs/read-deny.js +114 -25
  337. package/dist/tools/fs/safety.d.ts +4 -1
  338. package/dist/tools/fs/safety.js +4 -2
  339. package/dist/tools/fs/shell-read-argv.js +1 -0
  340. package/dist/tools/fs/shell-read-check.d.ts +9 -2
  341. package/dist/tools/fs/shell-read-check.js +134 -22
  342. package/dist/tools/fs/shell-read-establish.d.ts +9 -0
  343. package/dist/tools/fs/shell-read-establish.js +21 -11
  344. package/dist/tools/fs/shell-read-judge.d.ts +13 -1
  345. package/dist/tools/fs/shell-read-judge.js +26 -7
  346. package/dist/tools/fs/shell-read-plan.d.ts +7 -3
  347. package/dist/tools/fs/shell-read-plan.js +8 -5
  348. package/dist/tools/fs/shell-read-word.d.ts +8 -0
  349. package/dist/tools/fs/shell-read-word.js +13 -4
  350. package/dist/tools/fs/shell-read-write-targets.js +17 -9
  351. package/dist/tools/monitor.js +12 -8
  352. package/dist/tools/scheduler-tools.d.ts +1 -0
  353. package/dist/tools/scheduler-tools.js +5 -2
  354. package/package.json +3 -2
  355. package/test/export-surface.snapshot.json +192 -3
  356. package/wire-changes/answers/core-stores-sql@7.73.0.json +28 -0
  357. package/wire-changes/answers/core-stores-sql@7.74.0.json +7 -0
  358. package/wire-changes/answers/core@7.73.0.json +216 -0
  359. package/wire-changes/answers/core@7.74.0.json +68 -0
  360. package/wire-changes/answers/mods-kernel@7.73.0.json +7 -0
  361. package/wire-changes/answers/mods-kernel@7.74.0.json +21 -0
  362. package/wire-changes/answers/primitives@7.73.0.json +12 -0
  363. package/wire-changes/answers/primitives@7.74.0.json +7 -0
  364. package/wire-changes/answers/wiki-gate@7.73.0.json +7 -0
  365. package/wire-changes/answers/wiki-gate@7.74.0.json +8 -0
  366. package/wire-changes/core-stores-sql@7.73.0.json +326 -0
  367. package/wire-changes/core-stores-sql@7.74.0.json +143 -0
  368. package/wire-changes/core@7.73.0.json +6480 -0
  369. package/wire-changes/core@7.74.0.json +2210 -0
  370. package/wire-changes/mods-kernel@7.73.0.json +147 -0
  371. package/wire-changes/mods-kernel@7.74.0.json +421 -0
  372. package/wire-changes/primitives@7.73.0.json +227 -0
  373. package/wire-changes/primitives@7.74.0.json +174 -0
  374. package/wire-changes/wiki-gate@7.73.0.json +145 -0
  375. package/wire-changes/wiki-gate@7.74.0.json +145 -0
@@ -6,10 +6,14 @@ import { PEER_MESSAGE_NOTICE } from "../agents/peer-admission.js";
6
6
  import { buildCrossSessionEnvelope, CROSS_PRINCIPAL_MESSAGE_NOTICE, CROSS_SESSION_MESSAGE_NOTICE, neutralizePeerBody } from "../agents/cross-session-envelope.js";
7
7
  import { isMemberOutcome, isMemberCoverage, isRefusedAskList, memberRefusalFaces, outcomeOfLegacyRow, sealMemberLedger, sealMemberOutcome } from "./member-outcome.js";
8
8
  import { deliverEngineNotice } from "./engine-notice.js";
9
+ import { isSubagentActions, subagentActionsLine } from "./actions-digest.js";
9
10
  import { isAutoModeFallbackCause } from "./auto-mode.js";
10
11
  import { sameOccupant } from "../engine/session/repo-utils.js";
11
12
  import { codedRefusal } from "./thrown-value.js";
13
+ import { PEER_TASK_HANDLE_RE } from "./task-registry-shared.js";
14
+ import { A2A_WAITING_FOR } from "./a2a-task-state.js";
12
15
  import { ONE_SHOT_WAIT_CEILING_DEFAULT_MS } from "../config/defaults.js";
16
+ import { waitForOffloadPuts } from "./tool-result-store.js";
13
17
  export { ONE_SHOT_WAIT_CEILING_DEFAULT_MS };
14
18
  export const TASK_NOTIFICATION_TERMINAL_STATUSES = Object.freeze(["completed", "failed", "killed", "cancelled"]);
15
19
  export const NOTIFICATION_INJECTION_OUTCOMES = Object.freeze(["queued", "parked", "parked_durably", "dropped_duplicate", "refused"]);
@@ -48,6 +52,7 @@ const TASK_NOTIFICATION_TAGS = [
48
52
  "session-id",
49
53
  "recent-steps",
50
54
  "edited-files",
55
+ "actions",
51
56
  "refused-asks",
52
57
  "resumable",
53
58
  "agent-name",
@@ -156,6 +161,7 @@ function renderTaskNotificationCarrier(n) {
156
161
  const residual = renderResidual(n);
157
162
  return residual !== undefined ? [tag("recent-steps", residual)] : [];
158
163
  })(),
164
+ ...(n.actions !== undefined ? [tag("actions", subagentActionsLine(n.actions))] : []),
159
165
  ...((faces) => [...(faces.asks !== undefined ? [tag("refused-asks", faces.asks)] : []), ...(faces.rest !== undefined ? [tag("refused", faces.rest)] : [])])(memberRefusalFaces(n.outcome)),
160
166
  ...(n.resumable !== undefined ? [tag("resumable", n.resumable)] : []),
161
167
  ...(n.compaction !== undefined ? [tag("context", renderCompactionDisclosure(n.compaction))] : []),
@@ -241,19 +247,73 @@ export async function completionResultField(result, persist, record, notifier) {
241
247
  }, "completionResultField.shortReportWrite");
242
248
  return { text: report };
243
249
  }
244
- const artifact = await persist(report);
250
+ const waited = await waitForOffloadPuts([Promise.resolve(persist(report))]);
251
+ const first = waited.outcomes[0];
252
+ if (first.status === "rejected")
253
+ throw first.reason;
254
+ const artifact = first.status === "settled" ? first.value : { kind: "unconfirmed" };
245
255
  if (artifact.kind === "stored")
246
256
  record(artifact.ref);
247
257
  return { text: `${report.slice(0, COMPLETION_REPORT_MAX)}\n[result truncated: ${report.length} chars total — ${cutReportReading(artifact)}]` };
248
258
  }
249
- export const ENGINE_FRAME_CODEC_VERSION = 1;
250
- export const ENGINE_FRAME_TASK_TYPES = Object.freeze(["background_agent", "monitor", "workflow"]);
259
+ export const PEER_TASK_FOLLOW_UPS = Object.freeze(["accepted", "not_accepted"]);
260
+ export const PEER_TASK_CANCEL_STATES = Object.freeze(["not_requested", "requested", "confirmed"]);
261
+ export const PEER_TASK_CLOCK_STATES = Object.freeze(["running", "paused"]);
262
+ export const PEER_TASK_REMINDER_TARGETS = Object.freeze(["peer", "peer_owner", "peer_approver"]);
263
+ export const PEER_TASK_REMINDER_DISPOSITIONS = Object.freeze(["due", "skipped_not_sent", "sent", "received", "answered"]);
264
+ export const PEER_TASK_REMINDER_ROUTES = Object.freeze(["pending_list", "run", "none"]);
265
+ export function peerTaskNotification(input) {
266
+ if (!PEER_TASK_HANDLE_RE.test(input.task_id)) {
267
+ throw new RangeError(`peerTaskNotification: task_id must match ${PEER_TASK_HANDLE_RE}, got ${JSON.stringify(input.task_id)}`);
268
+ }
269
+ if (!Number.isSafeInteger(input.seq) || input.seq < 1) {
270
+ throw new RangeError(`peerTaskNotification: seq must be a positive safe integer, got ${String(input.seq)}`);
271
+ }
272
+ if (input.overdueTail === true && input.status !== "event") {
273
+ throw new RangeError(`peerTaskNotification: overdueTail frames must carry status "event", got ${JSON.stringify(input.status)}`);
274
+ }
275
+ const pt = input.peerTask;
276
+ const terminal = isTerminalTaskNotification({ status: input.status });
277
+ const peerTask = {
278
+ destination: pt.destination,
279
+ followUps: pt.followUps,
280
+ cancel: pt.cancel,
281
+ ackBy: pt.ackBy,
282
+ finalBy: pt.finalBy,
283
+ ...(!terminal && pt.waitingFor !== undefined ? { waitingFor: pt.waitingFor } : {}),
284
+ ...((terminal || input.overdueTail === true) && pt.remoteMayContinue === true ? { remoteMayContinue: true } : {}),
285
+ };
286
+ const bad = malformedPeerTaskFacet(peerTask);
287
+ if (bad !== undefined)
288
+ throw new RangeError(`peerTaskNotification: ${bad}`);
289
+ const noWake = input.overdueTail === true && input.status === "event" && pt.destination.boundary === "outside";
290
+ return {
291
+ task_id: input.task_id,
292
+ task_type: "peer_task",
293
+ status: input.status,
294
+ seq: input.seq,
295
+ summary: input.summary,
296
+ ...(input.result !== undefined ? { result: input.result } : {}),
297
+ ...(input.error !== undefined ? { error: input.error } : {}),
298
+ ...(input.errorCode !== undefined ? { errorCode: input.errorCode } : {}),
299
+ ...(input.stoppedBy !== undefined ? { stoppedBy: input.stoppedBy } : {}),
300
+ ...(input.outcome !== undefined ? { outcome: input.outcome } : {}),
301
+ ...(input.completionId !== undefined ? { completionId: input.completionId } : {}),
302
+ ...(noWake ? { noWake: true } : {}),
303
+ peerTask,
304
+ };
305
+ }
306
+ export const ENGINE_FRAME_CODEC_VERSION = 2;
307
+ export const ENGINE_FRAME_TASK_TYPES = Object.freeze(["background_agent", "monitor", "workflow", "peer_task"]);
308
+ export function engineFrameCodecVersionFor(taskType) {
309
+ return taskType === "peer_task" ? 2 : 1;
310
+ }
251
311
  const SHELL_LESS_CARRIERS = ["agentMessage", "crossSessionMessage", "crossSessionNotice", "inboxNotice", "_sema_provenance"];
252
312
  export function isEngineFrameParkable(payload) {
253
313
  return ENGINE_FRAME_TASK_TYPES.includes(payload.task_type) && SHELL_LESS_CARRIERS.every((k) => payload[k] === undefined);
254
314
  }
255
315
  export function encodeEngineFrame(payload, priority) {
256
- return JSON.stringify({ codecVersion: ENGINE_FRAME_CODEC_VERSION, priority, payload });
316
+ return JSON.stringify({ codecVersion: engineFrameCodecVersionFor(payload.task_type), priority, payload });
257
317
  }
258
318
  export function decodeEngineFrame(content) {
259
319
  let raw;
@@ -282,9 +342,13 @@ export function decodeEngineFrame(content) {
282
342
  return { ok: false, reason: "malformed", detail: "task_id missing" };
283
343
  if (!ENGINE_FRAME_TASK_TYPES.includes(f["task_type"]))
284
344
  return { ok: false, reason: "malformed", detail: "task_type outside the engine's lanes" };
345
+ const requiredVersion = engineFrameCodecVersionFor(f["task_type"]);
346
+ if (version < requiredVersion) {
347
+ return { ok: false, reason: "malformed", detail: `task_type ${String(f["task_type"])} requires codec version ${requiredVersion}, got ${version}` };
348
+ }
285
349
  if (typeof f["status"] !== "string" || typeof f["summary"] !== "string")
286
350
  return { ok: false, reason: "malformed", detail: "status/summary missing" };
287
- const facet = malformedFacet(f);
351
+ const facet = malformedFacet(f, version);
288
352
  if (facet !== undefined)
289
353
  return { ok: false, reason: "malformed", detail: facet };
290
354
  const payload = { ...p };
@@ -304,7 +368,7 @@ export function decodeEngineFrame(content) {
304
368
  return { ok: true, payload, priority };
305
369
  }
306
370
  const SPAWN_NAME_RE = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/;
307
- function malformedFacet(f) {
371
+ function malformedFacet(f, codecVersion) {
308
372
  if (f["spawnName"] !== undefined && (typeof f["spawnName"] !== "string" || !SPAWN_NAME_RE.test(f["spawnName"])))
309
373
  return "spawnName outside the spawn-name grammar";
310
374
  if (f["noWake"] !== undefined && f["noWake"] !== true)
@@ -324,6 +388,8 @@ function malformedFacet(f) {
324
388
  const edits = f["editedFiles"];
325
389
  if (edits !== undefined && !(Array.isArray(edits) && edits.every((e) => e !== null && typeof e === "object" && typeof e.path === "string" && typeof e.edits === "number")))
326
390
  return "editedFiles is not a list of files";
391
+ if (f["actions"] !== undefined && !isSubagentActions(f["actions"]))
392
+ return "actions is not an actions digest";
327
393
  const refused = f["refusedAsks"];
328
394
  if (refused !== undefined && !isRefusedAskList(refused))
329
395
  return "refusedAsks is not a non-empty list of refused asks";
@@ -347,6 +413,69 @@ function malformedFacet(f) {
347
413
  if (kind !== undefined && !(typeof kind === "string" && COMPACTION_KINDS.includes(kind)))
348
414
  return "compaction.kind outside its closed set";
349
415
  }
416
+ const pt = f["peerTask"];
417
+ if (pt !== undefined && codecVersion >= engineFrameCodecVersionFor("peer_task")) {
418
+ const ptBad = malformedPeerTaskFacet(pt);
419
+ if (ptBad !== undefined)
420
+ return ptBad;
421
+ }
422
+ return undefined;
423
+ }
424
+ const isEpochMs = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0;
425
+ function malformedPeerTaskFacet(pt) {
426
+ if (pt === null || typeof pt !== "object" || Array.isArray(pt))
427
+ return "peerTask is not an object";
428
+ const { destination, followUps, cancel, waitingFor, remoteMayContinue, ackBy, finalBy, peerFinalBy, approvalBy, clock, reminder } = pt;
429
+ if (destination !== undefined) {
430
+ if (destination === null || typeof destination !== "object" || Array.isArray(destination))
431
+ return "peerTask.destination is not an object";
432
+ const { kind, peer, displayName, ownerTeam, boundary } = destination;
433
+ if (kind !== "a2a_peer")
434
+ return "peerTask.destination.kind is not a2a_peer";
435
+ if (typeof peer !== "string" || peer === "")
436
+ return "peerTask.destination.peer is not a non-empty string";
437
+ if (boundary !== "inside" && boundary !== "outside")
438
+ return "peerTask.destination.boundary outside its closed set";
439
+ if (displayName !== undefined && typeof displayName !== "string")
440
+ return "peerTask.destination.displayName is not a string";
441
+ if (ownerTeam !== undefined && typeof ownerTeam !== "string")
442
+ return "peerTask.destination.ownerTeam is not a string";
443
+ }
444
+ if (followUps !== undefined && !(typeof followUps === "string" && PEER_TASK_FOLLOW_UPS.includes(followUps)))
445
+ return "peerTask.followUps outside its closed set";
446
+ if (cancel !== undefined && !(typeof cancel === "string" && PEER_TASK_CANCEL_STATES.includes(cancel)))
447
+ return "peerTask.cancel outside its closed set";
448
+ if (waitingFor !== undefined && !(typeof waitingFor === "string" && A2A_WAITING_FOR.includes(waitingFor)))
449
+ return "peerTask.waitingFor outside its closed set";
450
+ if (remoteMayContinue !== undefined && remoteMayContinue !== true)
451
+ return "peerTask.remoteMayContinue is not true";
452
+ if (ackBy !== undefined && !isEpochMs(ackBy))
453
+ return "peerTask.ackBy is not an epoch-ms instant";
454
+ if (finalBy !== undefined && !isEpochMs(finalBy))
455
+ return "peerTask.finalBy is not an epoch-ms instant";
456
+ if (peerFinalBy !== undefined && !isEpochMs(peerFinalBy))
457
+ return "peerTask.peerFinalBy is not an epoch-ms instant";
458
+ if (approvalBy !== undefined && !isEpochMs(approvalBy))
459
+ return "peerTask.approvalBy is not an epoch-ms instant";
460
+ if (clock !== undefined && !(typeof clock === "string" && PEER_TASK_CLOCK_STATES.includes(clock)))
461
+ return "peerTask.clock outside its closed set";
462
+ if (reminder !== undefined) {
463
+ if (reminder === null || typeof reminder !== "object" || Array.isArray(reminder))
464
+ return "peerTask.reminder is not an object";
465
+ const { n, target, disposition, routedTo } = reminder;
466
+ if (typeof n !== "number" || !Number.isSafeInteger(n) || n < 1)
467
+ return "peerTask.reminder.n is not a positive integer";
468
+ if (!(typeof target === "string" && PEER_TASK_REMINDER_TARGETS.includes(target)))
469
+ return "peerTask.reminder.target outside its closed set";
470
+ if (!(typeof disposition === "string" && PEER_TASK_REMINDER_DISPOSITIONS.includes(disposition)))
471
+ return "peerTask.reminder.disposition outside its closed set";
472
+ if (routedTo !== undefined) {
473
+ if (disposition !== "received" && disposition !== "answered")
474
+ return "peerTask.reminder.routedTo requires disposition received or answered";
475
+ if (!(typeof routedTo === "string" && PEER_TASK_REMINDER_ROUTES.includes(routedTo)))
476
+ return "peerTask.reminder.routedTo outside its closed set";
477
+ }
478
+ }
350
479
  return undefined;
351
480
  }
352
481
  export function engineFrameRecordOf(payload, priority, to) {
@@ -244,6 +244,7 @@ export declare function reconcileParkedAgentsLane(core: DurableAgentCore, stores
244
244
  }): Promise<{
245
245
  failed: number;
246
246
  rolledBack: number;
247
+ unreadable: number;
247
248
  }>;
248
249
  /**
249
250
  * design/153 §7.2c (件3b) — the RESERVATION half of the parked-resume claim. Pure reservation
@@ -610,7 +610,7 @@ export async function reconcileParkedAgentsLane(core, stores, scope, now, opts)
610
610
  ...(opts?.staleClaimMaxAgeMs !== undefined ? { staleClaimMaxAgeMs: opts.staleClaimMaxAgeMs } : {}),
611
611
  excludeHandles: liveHandles,
612
612
  });
613
- return { failed: storeHalf.failed + liveFailed, rolledBack: storeHalf.rolledBack };
613
+ return { failed: storeHalf.failed + liveFailed, rolledBack: storeHalf.rolledBack, unreadable: storeHalf.unreadable };
614
614
  }
615
615
  export async function claimParkedAgentLane(stores, handle, access) {
616
616
  if (access.scope === undefined)
@@ -9,7 +9,7 @@ import type { TaskArtifactSeat } from "./tool-result-store.js";
9
9
  import type { AssertAllKeysHandled } from "./ask-origin.js";
10
10
  /** The kinds of background task the registry holds, as ONE list: {@link SemaTaskType} is derived from it, so a consumer that
11
11
  * validates a task kind it read off the wire (a stored row, a listing, a frame) iterates the same source the type is. */
12
- export declare const SEMA_TASK_TYPES: readonly ["background_bash", "workflow", "background_agent", "monitor"];
12
+ export declare const SEMA_TASK_TYPES: readonly ["background_bash", "workflow", "background_agent", "monitor", "peer_task"];
13
13
  export type SemaTaskType = (typeof SEMA_TASK_TYPES)[number];
14
14
  /** The handle prefix of each kind: a task id is this one lowercase letter followed by 16 lowercase hex digits (8 random bytes) —
15
15
  * the table `TaskRegistry.mintTaskId` mints with, the only one (a reader that tells a kind by its handle reads it here, never a
@@ -19,9 +19,12 @@ export declare const SEMA_TASK_HANDLE_PREFIXES: Readonly<{
19
19
  readonly workflow: "w";
20
20
  readonly background_agent: "a";
21
21
  readonly monitor: "m";
22
+ readonly peer_task: "p";
22
23
  }>;
23
24
  /** Compile-time fence: `never` while every task kind has a handle prefix. */
24
25
  export type TaskHandlePrefixesCoverEveryType = AssertAllKeysHandled<Exclude<SemaTaskType, keyof typeof SEMA_TASK_HANDLE_PREFIXES>>;
26
+ /** Strict handle shape of a `peer_task` row (`p` + 16 lowercase hex digits), derived from {@link SEMA_TASK_HANDLE_PREFIXES}. */
27
+ export declare const PEER_TASK_HANDLE_RE: RegExp;
25
28
  /** design/134 §3.3 (R3): WHO initiated a kill — recorded at the initiation site (first-marker-wins),
26
29
  * because the settle-side then/catch context has already lost it. OPEN ENUM on the wire, now in the
27
30
  * TYPE too (`(string & {})` keeps literal completion while admitting future values like "timeout"
@@ -298,6 +301,11 @@ export interface WorkflowTaskHandle extends SemaTaskHandle {
298
301
  sessionScoped?: true;
299
302
  /** The run's yield intent — see {@link RegisterWorkflowInput.yieldIntent}. Absent ⇒ the run cannot park its legs. */
300
303
  yieldIntent?: AbortController;
304
+ /** The task that dispatched the run — see {@link RegisterWorkflowInput.parentTaskId}. */
305
+ parentTaskId?: string;
306
+ /** How the run's own members ended (`workflowMembersOf` over its record), captured when the run settles beside {@link result} —
307
+ * what a member ledger of the dispatching task reads for this row. Absent while it runs. */
308
+ members?: import("./member-outcome.js").MemberLedger;
301
309
  /** The bounded return value, captured on the done-hook so the STORE-LESS in-memory lane's
302
310
  * terminal poll can hand it over too (the launch note promises it; without a store there was no result). */
303
311
  result?: string;
@@ -672,6 +680,9 @@ export interface RegisterWorkflowInput extends TaskAccess {
672
680
  * whole-registry {@link TaskRegistry.yieldBackground} aborts it: each leg in flight parks at its own next clean
673
681
  * boundary and the run suspends on its parks. ABSENT ⇒ the run cannot yield (`no_park_lane`). */
674
682
  yieldIntent?: AbortController;
683
+ /** The task that dispatched the run — the key a member ledger of that task reads its members by, written as a background agent's
684
+ * row writes it (the dispatching leg's task id, when it is not its session id). */
685
+ parentTaskId?: string;
675
686
  }
676
687
  /** T2A-7 (2026-07-05 soak): one blocked-poll step, CLAMPED to the caller's deadline — a small timeoutMs
677
688
  * (e.g. 10ms) must not sleep the full 400ms step (~40× overshoot, and the overshoot window even served a
@@ -6,13 +6,15 @@ import { boundedRedactedSummary } from "./untrusted-egress.js";
6
6
  import { clipWithFilePointer, OUTPUT_BUDGET_MIN_CHARS } from "./tool-errors.js";
7
7
  import { resolveEnvBudget } from "./env-budget.js";
8
8
  import { isOccupantToken, sameOccupant } from "../engine/session/repo-utils.js";
9
- export const SEMA_TASK_TYPES = Object.freeze(["background_bash", "workflow", "background_agent", "monitor"]);
9
+ export const SEMA_TASK_TYPES = Object.freeze(["background_bash", "workflow", "background_agent", "monitor", "peer_task"]);
10
10
  export const SEMA_TASK_HANDLE_PREFIXES = Object.freeze({
11
11
  background_bash: "b",
12
12
  workflow: "w",
13
13
  background_agent: "a",
14
14
  monitor: "m",
15
+ peer_task: "p",
15
16
  });
17
+ export const PEER_TASK_HANDLE_RE = new RegExp(`^${SEMA_TASK_HANDLE_PREFIXES.peer_task}[0-9a-f]{16}$`);
16
18
  export function monotonicNow() {
17
19
  return performance.now();
18
20
  }
@@ -1,7 +1,7 @@
1
1
  import type { TaskAccess } from "./task-registry-shared.js";
2
2
  import type { CheckpointSeat } from "./checkpoint-seat.js";
3
3
  import type { WorkflowRunStore } from "./workflow-run-store.js";
4
- import type { WorkflowParkWait, WorkflowRun } from "../orchestration/workflow-types.js";
4
+ import { type WorkflowParkWait, type WorkflowRun } from "../orchestration/workflow-types.js";
5
5
  import { type RegistryCore, type RegisterWorkflowInput, type WorkflowTaskHandle, type UnifiedTaskResult } from "./task-registry-shared.js";
6
6
  export declare function registerWorkflowLane(core: RegistryCore, input: RegisterWorkflowInput): string;
7
7
  /** #5146 — the engine's answers for the parks a finished run made, read when both of the host's stores are at hand (the poll face
@@ -2,6 +2,7 @@ import { boundedRedactedSummary } from "./untrusted-egress.js";
2
2
  import { delimitUntrusted } from "./untrusted-text.js";
3
3
  import { thrownText } from "./thrown-value.js";
4
4
  import { settledRunOf } from "./workflow-settled-run.js";
5
+ import { workflowMembersOf } from "../orchestration/workflow-types.js";
5
6
  import { assertOwnership, canAccessWorkflowRun, formatWorkflowRun, sleepPollStep, activityStamp, stampActivity, occupantStamp, } from "./task-registry-shared.js";
6
7
  export function registerWorkflowLane(core, input) {
7
8
  assertOwnership(input, "registerWorkflow");
@@ -26,8 +27,13 @@ export function registerWorkflowLane(core, input) {
26
27
  ...(input.store !== undefined ? { store: input.store } : {}),
27
28
  ...(originatingSessionId !== undefined ? { originatingSessionId, sessionScoped: true } : {}),
28
29
  ...(input.yieldIntent !== undefined ? { yieldIntent: input.yieldIntent } : {}),
30
+ ...(input.parentTaskId !== undefined ? { parentTaskId: input.parentTaskId } : {}),
29
31
  };
30
32
  core.handles.set(id, handle);
33
+ const holdMembers = (run) => {
34
+ if (run !== undefined && Array.isArray(run.agents))
35
+ handle.members = workflowMembersOf(run);
36
+ };
31
37
  void input.handle.done.then((res) => {
32
38
  handle.status = "completed";
33
39
  const run = res?.run;
@@ -36,6 +42,7 @@ export function registerWorkflowLane(core, input) {
36
42
  handle.result = r;
37
43
  if (run?.completionId !== undefined)
38
44
  handle.completionId = run.completionId;
45
+ holdMembers(run);
39
46
  stampActivity(handle);
40
47
  core.pokeYieldDrains();
41
48
  }, (err) => {
@@ -43,6 +50,7 @@ export function registerWorkflowLane(core, input) {
43
50
  handle.status = "failed";
44
51
  const settledRun = settledRunOf(input.handle.done);
45
52
  const settleId = settledRun?.completionId;
53
+ holdMembers(settledRun);
46
54
  handle.error = boundedRedactedSummary(thrownText(err), 500);
47
55
  if (settleId !== undefined)
48
56
  handle.completionId = settleId;
@@ -135,7 +143,7 @@ export async function stopWorkflowLane(handle) {
135
143
  type: "workflow",
136
144
  status: "cancelled",
137
145
  stopped: true,
138
- note: "workflow cancellation requested; durable run status maps cancellation to failed when it finalizes.",
146
+ note: `workflow cancelled: what was running was stopped. Its record keeps the outcome the run settles with (a script that returns after its stopped agents' results come back is recorded as completed), and it can be continued with resumeFromRunId: "${handle.id}".`,
139
147
  }),
140
148
  details: { task_id: handle.id, type: "workflow", status: "cancelled", retrieval_status: "success" },
141
149
  };
@@ -2,14 +2,17 @@ import type { AgentTool, ExecutionEnv } from "../internal/harness.js";
2
2
  import type { ToolEffect } from "./types.js";
3
3
  import { type BackgroundHardKillOutcome, type BackgroundShellCapability, type BackgroundShellId } from "./background-shell.js";
4
4
  import type { BoundaryLegsGiven } from "./cross-boundary-taint.js";
5
- import type { WorkflowRunStore } from "./workflow-run-store.js";
5
+ import { type WorkflowRunStore } from "./workflow-run-store.js";
6
6
  import type { WorkflowAgentStopReceipt } from "../orchestration/workflow-types.js";
7
+ import type { WorkflowRunStopReceipt } from "../orchestration/workflow-stop.js";
8
+ import type { WorkflowJournalStore } from "./workflow-journal-store.js";
9
+ import type { CheckpointStore } from "./checkpoint-store.js";
7
10
  import { type BackgroundAgentRecord, type BackgroundAgentSettledStatus, type BackgroundAgentStore } from "./background-agent-store.js";
8
11
  import type { TaskNotificationPayload } from "./task-notification.js";
9
12
  import type { ExtensionRequester } from "./task-event.js";
10
13
  import { type TaskArtifactSeat } from "./tool-result-store.js";
11
14
  import { type SemaTaskType, type StopSource, type SemaTaskStatus, type TaskRetrievalStatus, type UnifiedTaskOutput, type UnifiedTaskResult, type SemaTaskHandle, type TaskAccess, type BackgroundAgentTaskHandle, type MonitorTimers, type RegisterMonitorInput, type RegisterWorkflowInput, canAccessWorkflowRun, clipTaskOutput, MONITOR_BATCH_WINDOW_MS, MONITOR_DEFAULT_TIMEOUT_MS, MONITOR_MAX_TIMEOUT_MS, MONITOR_MAX_BATCHES_PER_MINUTE, type OccupantMount } from "./task-registry-shared.js";
12
- export { SEMA_TASK_TYPES, SEMA_TASK_HANDLE_PREFIXES, normalizeAgentName, DURABLE_AGENT_HEARTBEAT_MS, DURABLE_AGENT_HANDLE_RE, BG_AGENT_REAP_STOP_ERROR, engineAgentName, chosenAgentName, PARKED_CLAIM_ROLLBACKS, PARKED_CLAIM_ROLLBACK_FACE } from "./task-registry-shared.js";
15
+ export { SEMA_TASK_TYPES, SEMA_TASK_HANDLE_PREFIXES, PEER_TASK_HANDLE_RE, normalizeAgentName, DURABLE_AGENT_HEARTBEAT_MS, DURABLE_AGENT_HANDLE_RE, BG_AGENT_REAP_STOP_ERROR, engineAgentName, chosenAgentName, PARKED_CLAIM_ROLLBACKS, PARKED_CLAIM_ROLLBACK_FACE } from "./task-registry-shared.js";
13
16
  export type { ParkedClaimTicket, ParkedClaimRollback, RegisterBackgroundAgentInput, BackgroundUnyieldableReason, BackgroundYieldLane, BackgroundYieldOptions, BackgroundYieldReport } from "./task-registry-shared.js";
14
17
  import type { RegisterBackgroundAgentInput, ParkedClaimTicket, ParkedClaimRollback, ChildSessionStore, LandedAgentTerminal, BackgroundYieldOptions, BackgroundYieldReport } from "./task-registry-shared.js";
15
18
  import type { ChildSessionAnchor } from "./task-registry-agent.js";
@@ -185,6 +188,10 @@ export interface AccessibleTaskRow {
185
188
  export declare function abortBackgroundAgentsAtRunEnd(registry: TaskRegistry, access: TaskAccess, opts: {
186
189
  skipSessionScoped?: boolean;
187
190
  }, runEnd: RunEndCause | undefined): number;
191
+ /** Watch the running agents {@link ownerSweepTakes} selects for `access` and `opts`; returns `undefined` when none remain, else an unsubscribe and calls `onSettled` once when they settle. */
192
+ export declare function onRunEndAgentsSettled(registry: TaskRegistry, access: TaskAccess, opts: {
193
+ skipSessionScoped?: boolean;
194
+ }, onSettled: () => void): (() => void) | undefined;
188
195
  export declare class TaskRegistry {
189
196
  private handles;
190
197
  /** observers of the design/129 session terminal anchor — `reapSessionBackground`
@@ -328,6 +335,7 @@ export declare class TaskRegistry {
328
335
  }): Promise<{
329
336
  failed: number;
330
337
  rolledBack: number;
338
+ unreadable: number;
331
339
  }>;
332
340
  claimParkedAgent(stores: {
333
341
  agentStore: import("./background-agent-store.js").BackgroundAgentStore;
@@ -548,6 +556,9 @@ export declare class TaskRegistry {
548
556
  * site building that settle's completion frame (read in the settle's own step, like {@link getCompletionId}). Undefined for a
549
557
  * row still running or parked, a row of another task kind, or an id this registry never held. */
550
558
  getAgentOutcome(id: string): import("./member-outcome.js").MemberOutcome | undefined;
559
+ /** How a workflow run's own members ended, as the row holds it once the run settled ({@link WorkflowTaskHandle.members}) —
560
+ * undefined while it runs, for a row of another task kind, or an id this registry never held. */
561
+ getWorkflowMembers(id: string): import("./member-outcome.js").MemberLedger | undefined;
551
562
  /** Record the ref a task's result was stored under (`persistTaskArtifact` landed it) — the read handle a later list of
552
563
  * tasks names for it. `completionId` = the settle the result belongs to ({@link getCompletionId}, read in that settle's own
553
564
  * synchronous step — every terminal frame carries it): the write records only while the row still holds that settle. A row revived
@@ -562,6 +573,13 @@ export declare class TaskRegistry {
562
573
  /** The read handle ({@link taskReadHandleText}) of a task `access` reaches — `undefined` for an unknown or unreachable
563
574
  * id (the same info-hiding a poll gives) and for a task with nothing to read beyond its notification. */
564
575
  readHandleOf(id: string, access: TaskAccess): string | undefined;
576
+ /** The run teardown's "a person stopped this run" judgement, marked on the background agents the run-end reap takes (the reap's
577
+ * own row set: owner + scope, session-resident rows skipped when `skipSessionScoped`) before that reap marks them "parent" —
578
+ * first-marker-wins then holds "user". Read by the shell settle ({@link settleKilledForOwner}) and by a run whose member ledger
579
+ * reads its last word after the reap (`reapTaskAgentsBeforeLastWord`), whichever runs first. */
580
+ markRunEndAgentsStoppedByUser(access: TaskAccess, opts?: {
581
+ skipSessionScoped?: boolean;
582
+ }): void;
565
583
  /** Bulk stop-source attribution for one owner — the registry-side primitive that
566
584
  * replaces the service's `list()+markStopSource` per-row loop, which had TWO holes: ① `list()` didn't
567
585
  * expose `sessionScoped`, so on the resume leg (canonical taskId==sessionId, rebuilt taskConfig without
@@ -783,6 +801,22 @@ export declare class TaskRegistry {
783
801
  readonly stoppedBy?: StopSource;
784
802
  readonly workflowStore?: WorkflowRunStore;
785
803
  }): Promise<WorkflowAgentStopReceipt>;
804
+ /**
805
+ * #5291 — stop the WORKFLOW `runId` belongs to, for good (`WorkflowHandle.stop`): no run of it starts another step, whichever process
806
+ * continues it, and every approval card of it still waiting is withdrawn. The caller's access is judged before any tree read or write,
807
+ * on the run held here or the record `workflowStore` gives — a run the caller cannot see answers `not_found`, with nothing written. A run held
808
+ * here is stopped through its own handle (its own stores); one read from the store is stopped through the stores given
809
+ * (`journalStore` keeps the stop — without one, or one without `stopResumeClaim`, the stop is not durable; `checkpointStore` is where
810
+ * its cards are withdrawn). The record is read before access is judged (access is judged on it): a row that does not read answers
811
+ * `not_found`, as a missing one does; a store read that throws otherwise rejects. TaskStop ({@link stopTask}) only cancels: a cancelled
812
+ * run can be continued.
813
+ */
814
+ stopWorkflowRun(runId: string, access: TaskAccess, opts?: {
815
+ readonly stoppedBy?: StopSource;
816
+ readonly workflowStore?: WorkflowRunStore;
817
+ readonly journalStore?: WorkflowJournalStore;
818
+ readonly checkpointStore?: CheckpointStore;
819
+ }): Promise<WorkflowRunStopReceipt>;
786
820
  stopTask(id: string, access: TaskAccess, opts?: TaskStopOptions): Promise<UnifiedTaskResult>;
787
821
  /** S2b — bounded delivery-confirmation wait (see deliverToRunningAgent). Test-tunable. */
788
822
  deliverConfirmTimeoutMs: number;
@@ -801,6 +835,10 @@ export declare class TaskRegistry {
801
835
  * cap ({@link list}'s): the one reading of a leg's live background tasks (its end's {@link owedDeliveries}, the post-compaction
802
836
  * listing and the resume's orphan diff, the suspend's snapshot), each consumer projecting its own columns from it. */
803
837
  liveTasks(access: TaskAccess): TaskListRow[];
838
+ /** The background agents and workflow runs `access` reaches whose row names `taskId` as the task that dispatched them
839
+ * (`parentTaskId`), newest first — EVERY one, with no display cap: a task's members read as one set, however many rows of other
840
+ * tasks the reach holds. */
841
+ membersOfTask(access: TaskAccess, taskId: string): TaskListRow[];
804
842
  /** The child session task `taskId`'s row is anchored to — its id and the store the child's run holds it through — when
805
843
  * `access` reaches the row (the reach {@link list} reads with): `undefined` for an unknown or out-of-reach id, `null` for a
806
844
  * reached row with no anchor (no background agent's row, not bound yet, or released). */
@@ -3,16 +3,17 @@ import { defineTool, errorResult } from "./tools.js";
3
3
  import { envDeclaresRetain, hasBackgroundShell, retainsBackgroundProcesses } from "./background-shell.js";
4
4
  import { shutdownDebug } from "./shutdown-debug.js";
5
5
  import { mintCompletionId } from "./completion-id.js";
6
+ import { WORKFLOW_RUN_ROW_MALFORMED_CODE, WorkflowRunStoreError } from "./workflow-run-store.js";
6
7
  import { canAccessAgentRecord, } from "./background-agent-store.js";
7
8
  import { delimitUntrusted } from "./untrusted-text.js";
8
9
  import { createSafeNotifier } from "./safe-notify.js";
9
10
  import { stripCwdSentinel } from "../tools/fs/fs-shared.js";
10
11
  import { readExtensionRequester } from "./extension-requester.js";
11
- import { persistTaskArtifact, taskArtifactOriginOf } from "./tool-result-store.js";
12
+ import { persistTaskArtifact, taskArtifactOriginOf, waitForOffloadPuts } from "./tool-result-store.js";
12
13
  import { registerMonitorLane, pollMonitorLane, stopMonitorLane } from "./task-registry-monitor.js";
13
14
  import { registerWorkflowLane, pollWorkflowLane, stopWorkflowLane, workflowParkWaitsOf } from "./task-registry-workflow.js";
14
15
  import { taskReadHandleText, canAccessWorkflowRun, formatWorkflowRun, clipTaskOutput, assertOwnership, sleepPollStep, statusFromBackground, rollSpoolText, accountDroppedBytes, dropFactsOf, renderSpoolBody, stdoutHeadingOf, REPLAY_FACE, SPOOL_REPLAY, INCREMENT_REPLAY, spoolDropNote, droppedGapNote, alreadyTerminalStopNote, terminalTaskSummary, TASK_OUTPUT_MAX_CHARS, MONITOR_BATCH_WINDOW_MS, MONITOR_DEFAULT_TIMEOUT_MS, MONITOR_MAX_TIMEOUT_MS, MONITOR_MAX_BATCHES_PER_MINUTE, canAccess, isLiveSessionResidentAgent, DURABLE_AGENT_HANDLE_RE, SEMA_TASK_HANDLE_PREFIXES, activityStamp, stampActivity, occupantStamp, callOccupant, } from "./task-registry-shared.js";
15
- export { SEMA_TASK_TYPES, SEMA_TASK_HANDLE_PREFIXES, normalizeAgentName, DURABLE_AGENT_HEARTBEAT_MS, DURABLE_AGENT_HANDLE_RE, BG_AGENT_REAP_STOP_ERROR, engineAgentName, chosenAgentName, PARKED_CLAIM_ROLLBACKS, PARKED_CLAIM_ROLLBACK_FACE } from "./task-registry-shared.js";
16
+ export { SEMA_TASK_TYPES, SEMA_TASK_HANDLE_PREFIXES, PEER_TASK_HANDLE_RE, normalizeAgentName, DURABLE_AGENT_HEARTBEAT_MS, DURABLE_AGENT_HANDLE_RE, BG_AGENT_REAP_STOP_ERROR, engineAgentName, chosenAgentName, PARKED_CLAIM_ROLLBACKS, PARKED_CLAIM_ROLLBACK_FACE } from "./task-registry-shared.js";
16
17
  import { attachYieldLegLane, requestYieldLane, yieldCovers, yieldPopulationLane, yieldPopulationLeftRunning, yieldPopulationWrites, yieldRequested } from "./task-registry-yield.js";
17
18
  import { TASK_STOP_TOOL_NAME, TASK_STOP_MISSING_ID_MESSAGE, TASK_STOP_PARAMS, TASK_STOP_DESCRIPTION, resolveTaskIdArg } from "./task-tool-shape.js";
18
19
  import { durableAgentArmedLane, durableAgentRowProbeLane, durableAgentRowFactsLane, beginDurableClaimLane, endDurableClaimLane, reapDurableAgentsLane, noteBackgroundAgentActivityLane, reapStaleSessionBackgroundAgentsLane, announceLandedAgentTerminal, releaseDurableTranscriptAnchorLane, bindBackgroundAgentSessionLane, childSessionAnchorOf, registerBackgroundAgentLane, recordBackgroundAgentOrgAdmissionLane, parkBackgroundAgentLane, reconcileParkedAgentsLane, claimParkedAgentLane, rollbackParkedClaimLane, consumeParkedFlipLane, finalizeParkedResumeLane, settleBackgroundAgentLane, abortBackgroundAgentsForOwnerLane, ownerSweepTakes, serveDurableAgentRowLane, agentHandleOutcomeOf, resolveBackgroundAgentByNameLane, claimBackgroundAgentNameLane, backgroundAgentCycleSeqLane, activeDelegationHandlesLane, activeDelegationHandlesByRootLane, activeDelegationOccupantsLane, markRetainedContinuationLane, reviveBackgroundAgentLane, settleRevivedAgentLane, unmarkRetainedContinuationLane, endRetentionHoldLane, attachAgentNotifyLane, deliverToRunningAgentLane, runningBackgroundAgentLabelsLane, runningAgentFooterLane, notFoundRunningAgentsTail, pollBackgroundAgentLane, stopBackgroundAgentLane, } from "./task-registry-agent.js";
@@ -112,8 +113,9 @@ function commandRecordSink(rowOf, record, guarded, sink) {
112
113
  if (row.taskArtifacts === undefined || retained === undefined)
113
114
  return sink(gap === "incomplete" ? { ...n, summary: n.summary + commandRecordGapNote(row, gap, undefined) } : n);
114
115
  const body = renderSpoolBody(retained, { running: false, handleStatus: row.status, shape: (text) => text, drainNote: "" });
115
- void persistTaskArtifact(row.taskArtifacts, row.id, body).then((artifact) => {
116
- const ref = artifact.kind === "stored" ? artifact.ref : undefined;
116
+ void waitForOffloadPuts([persistTaskArtifact(row.taskArtifacts, row.id, body)]).then((waited) => {
117
+ const first = waited.outcomes[0];
118
+ const ref = first.status === "settled" && first.value.kind === "stored" ? first.value.ref : undefined;
117
119
  if (ref !== undefined)
118
120
  record(row.id, ref, n.completionId);
119
121
  guarded(() => sink(ref === undefined && gap === "missing" ? n : { ...n, summary: n.summary + commandRecordGapNote(row, gap, ref) }));
@@ -161,6 +163,10 @@ let sweepAtRunEnd;
161
163
  export function abortBackgroundAgentsAtRunEnd(registry, access, opts, runEnd) {
162
164
  return sweepAtRunEnd(registry, access, opts, runEnd);
163
165
  }
166
+ let watchRunEndAgents;
167
+ export function onRunEndAgentsSettled(registry, access, opts, onSettled) {
168
+ return watchRunEndAgents(registry, access, opts, onSettled);
169
+ }
164
170
  export class TaskRegistry {
165
171
  handles = new Map();
166
172
  sessionReapHooks = new Set();
@@ -310,6 +316,24 @@ export class TaskRegistry {
310
316
  }
311
317
  static {
312
318
  sweepAtRunEnd = (registry, access, opts, runEnd) => abortBackgroundAgentsForOwnerLane(registry.core, access, opts, runEnd);
319
+ watchRunEndAgents = (registry, access, opts, onSettled) => {
320
+ const anyLeft = () => {
321
+ for (const handle of registry.handles.values())
322
+ if (ownerSweepTakes(handle, access, opts))
323
+ return true;
324
+ return false;
325
+ };
326
+ if (!anyLeft())
327
+ return undefined;
328
+ const check = () => {
329
+ if (!registry.drainChecks.has(check) || anyLeft())
330
+ return;
331
+ registry.drainChecks.delete(check);
332
+ onSettled();
333
+ };
334
+ registry.drainChecks.add(check);
335
+ return () => void registry.drainChecks.delete(check);
336
+ };
313
337
  }
314
338
  serveDurableAgentRow(row, checkpointSeat) {
315
339
  const read = readAgentState(agentStateSourceOfRecord(row), checkpointSeat, Date.now());
@@ -514,6 +538,10 @@ export class TaskRegistry {
514
538
  const h = this.handles.get(id);
515
539
  return h?.type === "background_agent" ? h.outcome : undefined;
516
540
  }
541
+ getWorkflowMembers(id) {
542
+ const h = this.handles.get(id);
543
+ return h?.type === "workflow" ? h.members : undefined;
544
+ }
517
545
  recordArtifactRef(id, ref, completionId) {
518
546
  const h = this.handles.get(id);
519
547
  if (h === undefined || completionId === undefined || h.completionId !== completionId)
@@ -528,6 +556,17 @@ export class TaskRegistry {
528
556
  const h = this.handles.get(id);
529
557
  return h !== undefined && canAccess(h, access) ? taskReadHandleText(h) : undefined;
530
558
  }
559
+ markRunEndAgentsStoppedByUser(access, opts) {
560
+ for (const handle of this.handles.values()) {
561
+ if (handle.type !== "background_agent" || handle.status !== "running")
562
+ continue;
563
+ if (!canAccess(handle, { owner: access.owner, scope: access.scope }))
564
+ continue;
565
+ if (opts?.skipSessionScoped && handle.sessionScoped)
566
+ continue;
567
+ this.markStopSource(handle.id, "user");
568
+ }
569
+ }
531
570
  markStopSourceForOwner(access, source, opts) {
532
571
  let marked = 0;
533
572
  for (const handle of this.handles.values()) {
@@ -551,17 +590,8 @@ export class TaskRegistry {
551
590
  async settleKilledForOwner(access, opts) {
552
591
  const source = opts?.source ?? "parent";
553
592
  const clause = (by) => by === "user" ? "stopped by user" : by === "parent" ? "its parent run ended" : `stopped by ${by}`;
554
- if (source === "user") {
555
- for (const handle of this.handles.values()) {
556
- if (handle.type !== "background_agent" || handle.status !== "running")
557
- continue;
558
- if (!canAccess(handle, { owner: access.owner, scope: access.scope }))
559
- continue;
560
- if (opts?.skipSessionScoped && handle.sessionScoped)
561
- continue;
562
- this.markStopSource(handle.id, source);
563
- }
564
- }
593
+ if (source === "user")
594
+ this.markRunEndAgentsStoppedByUser(access, opts);
565
595
  let settled = 0;
566
596
  for (const handle of this.handles.values()) {
567
597
  if (handle.type !== "background_bash" && handle.type !== "monitor")
@@ -1115,6 +1145,32 @@ The durable record is still marked running (last update ${new Date(row.updatedAt
1115
1145
  }
1116
1146
  return { answer: "not_found" };
1117
1147
  }
1148
+ async stopWorkflowRun(runId, access, opts = {}) {
1149
+ const id = runId.trim();
1150
+ const { readWorkflowStopper, stopWorkflowTree } = await import("../orchestration/workflow-stop.js");
1151
+ const stoppedBy = readWorkflowStopper(opts.stoppedBy, "TaskRegistry.stopWorkflowRun");
1152
+ const handle = this.resolveInternal(id, access);
1153
+ if (handle !== undefined)
1154
+ return handle.type === "workflow" && handle.handle.stop !== undefined ? handle.handle.stop({ stoppedBy }) : { answer: "not_found" };
1155
+ const store = opts.workflowStore;
1156
+ if (store === undefined)
1157
+ return { answer: "not_found" };
1158
+ let run;
1159
+ try {
1160
+ run = await store.get(id);
1161
+ }
1162
+ catch (err) {
1163
+ if (err instanceof WorkflowRunStoreError && err.code === WORKFLOW_RUN_ROW_MALFORMED_CODE)
1164
+ return { answer: "not_found" };
1165
+ throw err;
1166
+ }
1167
+ const now = this.heldWorkflow(id, store);
1168
+ if (now !== undefined && canAccess(now, access))
1169
+ return now.handle.stop !== undefined ? now.handle.stop({ stoppedBy }) : { answer: "not_found" };
1170
+ if (!run || !canAccessWorkflowRun(run, access, now))
1171
+ return { answer: "not_found" };
1172
+ return stopWorkflowTree(id, run.scope, stoppedBy, { runStore: store, ...(opts.journalStore !== undefined ? { journalStore: opts.journalStore } : {}), ...(opts.checkpointStore !== undefined ? { checkpointStore: opts.checkpointStore } : {}) });
1173
+ }
1118
1174
  async stopTask(id, access, opts = {}) {
1119
1175
  const taskId = id.trim();
1120
1176
  const handle = this.resolveInternal(taskId, access);
@@ -1199,6 +1255,15 @@ The durable record is still marked running (last update ${new Date(row.updatedAt
1199
1255
  liveTasks(access) {
1200
1256
  return this.rowsUnder(access).filter((t) => t.status === "pending" || t.status === "running" || t.status === "parked");
1201
1257
  }
1258
+ membersOfTask(access, taskId) {
1259
+ const out = [];
1260
+ for (const h of this.handles.values()) {
1261
+ if ((h.type === "background_agent" || h.type === "workflow") && h.parentTaskId === taskId && canAccess(h, access))
1262
+ out.push(this.projectedRow(h));
1263
+ }
1264
+ out.sort((a, b) => b.createdAt - a.createdAt);
1265
+ return out;
1266
+ }
1202
1267
  anchoredSession(taskId, access) {
1203
1268
  const h = this.handles.get(taskId);
1204
1269
  return h !== undefined && canAccess(h, access) ? (childSessionAnchorOf(h) ?? null) : undefined;