@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
@@ -35,7 +35,7 @@ import { reviewSubjectOf } from "../agents/delegation-review-faces.js";
35
35
  import { OUTPUT_TOOL_NAME, TOOL_CATALOG_ENTRIES } from "../core/tool-catalog-entries.js";
36
36
  import { readDelegationReview } from "../core/classifier-unavailable-arm.js";
37
37
  import { judgeHostToolCeiling, refuseUnusableDefinition } from "../core/runner/sub-agent-deny-lists.js";
38
- import { definitionSelectorLayer, withDefinitionServers } from "../agents/inherited-tool-pool.js";
38
+ import { announceShadowedDefinitionServers, definitionSelectorLayer, mergeDefinitionServers } from "../agents/inherited-tool-pool.js";
39
39
  import { isToolSelectorLayer } from "../agents/tool-filter.js";
40
40
  import { legRetiredNameView, selectorLayerUnderView } from "../core/tool-name-aliases.js";
41
41
  import { snapshotToolNameList } from "../core/tool-name-list.js";
@@ -47,7 +47,8 @@ import { callerPlacementSeats } from "../core/runner/child-tree.js";
47
47
  import { judgedOwnerSeat } from "../core/runner/delegation-owner.js";
48
48
  import { WorkflowBudgetExceededError, WorkflowNestingError, WorkflowAgentBlockedError, WorkflowAgentParkedError, WorkflowAgentSchemaError, WorkflowAgentStalledError, WorkflowMaxAgentsError, WORKFLOW_SPAWN_BLOCKED_ERROR_CODE, WORKFLOW_AGENT_OUTLIVED_RUN_CODE, PARK_NOT_PENDING_STATUSES, WORKFLOW_AGENT_PARKED_ERROR_CODE, WORKFLOW_STORE_WAIT_BOUND_MS, firstFailedAgentCodeOf, parkHolderAmong, runParkedOf, workflowRowStatusOf } from "./workflow-types.js";
49
49
  import { memberOutcomeOf, memberRefusalsOf } from "../core/member-outcome.js";
50
- import { CLAIM_REMAINING_UNREADABLE_NOTE, claimRemainingOf, isAnswerRecordClaimHolder, readWorkflowRunTreeWithin, runThatDrove, storeErrorClassOf, workflowLineForkReason, workflowLineTailOf, workflowParkDecisionOf, workflowRunChildrenIn, workflowRunInTree, workflowRunsBelow, workflowRunTreeOfOne, WORKFLOW_TREE_OVER_BOUND_REASON } from "./workflow-park-adoption.js";
50
+ import { CLAIM_REMAINING_UNREADABLE_NOTE, claimRemainingOf, isAnswerRecordClaimHolder, parkBindingFault, readWorkflowRunTreeWithin, runThatDrove, sameClaimKeys, storeErrorClassOf, workflowClaimKeysOf, workflowLineForkReason, workflowLineTailOf, workflowParkDecisionOf, workflowRunChildrenIn, workflowRunInTree, workflowRunsBelow, workflowRunTreeOfOne, WORKFLOW_TREE_OVER_BOUND_REASON } from "./workflow-park-adoption.js";
51
+ import { dropLocalClaimHolder, holdLocalWorkflowRun, noteLocalClaimHolder, readWorkflowStopper, stopWorkflowTree } from "./workflow-stop.js";
51
52
  import { WorkflowScriptError } from "./workflow-meta.js";
52
53
  import { firstByteLaneKnobMs, STALL_FIRST_BYTE_MS, STALL_FIRST_TOKEN_MS } from "../brain/timeout.js";
53
54
  import { asThrownError, codedRefusal, isErrorLike, readMember, thrownIs, thrownName, thrownText } from "../core/thrown-value.js";
@@ -69,7 +70,6 @@ const MAX_ACTIVITY = 30;
69
70
  const MAX_REVIEWED_SCHEMA_BYTES = 4096;
70
71
  const MAX_REVIEW_REASON_CHARS = 500;
71
72
  const MAX_REVIEWED_PROMPT_CHARS = 2_000;
72
- const MAX_MEMBER_STOPPER_CHARS = 256;
73
73
  const MAX_SCHEMA_WALK_DEPTH = 32;
74
74
  function isUsableSchema(v) {
75
75
  if (v === true)
@@ -157,13 +157,18 @@ export function applyWorkflowAgentType(spec, agentType, registry) {
157
157
  if (out.memoryPersistenceCapable === undefined && def.memoryPersistenceCapable !== undefined)
158
158
  out.memoryPersistenceCapable = def.memoryPersistenceCapable;
159
159
  const ownServers = def.mcp;
160
- if (ownServers !== undefined && ownServers.length > 0)
161
- out.mcp = withDefinitionServers(out.mcp !== undefined ? snapshotAndValidateMcpEntries(out.mcp) : undefined, ownServers);
160
+ let droppedMcp;
161
+ if (ownServers !== undefined && ownServers.length > 0) {
162
+ const merged = mergeDefinitionServers(out.mcp !== undefined ? snapshotAndValidateMcpEntries(out.mcp) : undefined, ownServers);
163
+ out.mcp = merged.servers;
164
+ if (merged.dropped.length > 0)
165
+ droppedMcp = merged.dropped;
166
+ }
162
167
  const lists = { allowTools: snapshotToolNameList(def.allowTools), denyTools: snapshotToolNameList(def.denyTools) };
163
168
  if (lists.allowTools == null && lists.denyTools == null)
164
- return { spec: out, agentType: def.name };
169
+ return { spec: out, agentType: def.name, ...(droppedMcp !== undefined ? { droppedMcp } : {}) };
165
170
  refuseUnusableDefinition(def.name, lists);
166
- return { spec: out, agentType: def.name, definitionToolLists: { agentType: def.name, layer: definitionSelectorLayer({ ...lists, ...(ownServers !== undefined ? { mcp: ownServers } : {}) }) } };
171
+ return { spec: out, agentType: def.name, definitionToolLists: { agentType: def.name, layer: definitionSelectorLayer({ ...lists, ...(ownServers !== undefined ? { mcp: ownServers } : {}) }) }, ...(droppedMcp !== undefined ? { droppedMcp } : {}) };
167
172
  }
168
173
  export function workflowAgentRegistry(opts) {
169
174
  const deployment = (opts.agents ?? []).map(snapshotDefinitionLists);
@@ -340,6 +345,22 @@ function runStoreUnreadableRefusal(fromRunId, cause) {
340
345
  const what = cause === undefined ? `no answer within ${WORKFLOW_STORE_WAIT_BOUND_MS}ms, or records that name each other in a loop` : storeErrorClassOf(cause.err);
341
346
  return new WorkflowParkRefusal("workflow.park_truth_unreadable", `startWorkflow: resume from "${fromRunId}" was REFUSED — the prior run's record, or that of a run it was resumed from, could not be read from the run store (${what}), so its parks cannot be proven.`, { reason: "store_threw" });
342
347
  }
348
+ function claimRefusalOf(what, decision) {
349
+ if (decision.stopped !== undefined) {
350
+ return new Error(`startWorkflow: ${what} was REFUSED — the workflow was stopped (workflow_stopped, by ${clampRunIdText(decision.stopped.by)}): no run of it starts another step. Nothing ran; to run the work again, start the workflow again.`);
351
+ }
352
+ const forAnswer = isAnswerRecordClaimHolder(decision.holder);
353
+ const holder = decision.holder !== undefined && !forAnswer ? clampRunIdText(decision.holder) : "";
354
+ const lapse = decision.lapse;
355
+ return new Error(`startWorkflow: ${what} was REFUSED — ` +
356
+ (forAnswer
357
+ ? "another leg of the workflow holds the resume claim on it for a moment, to record a person's answer to continuing it (no run holds it): resume again once it gives the claim back. If that leg's process stopped without giving the claim back, "
358
+ : `another run already holds the resume claim on it${holder ? ` (holder: ${holder})` : " (holder unknown to the store)"}. ` +
359
+ "Two concurrent resumes of one source run fork its execution: both replay the same prefix and then " +
360
+ "re-run the whole suffix live, duplicating every side effect. Wait for the holder to reach a terminal " +
361
+ "state (or stop it) and resume again. If the holder's process stopped without giving the claim back, ") +
362
+ `the claim lapses ${lapse?.kind === "at" ? `at ${new Date(lapse.at).toISOString()} at the latest` : `when the journal store's expiry frees it${lapse?.kind === "unreadable" ? ` (${CLAIM_REMAINING_UNREADABLE_NOTE})` : ""}`}, and the same resume goes through then.`);
363
+ }
343
364
  function journalStoreClaimRefusal(fromRunId, err) {
344
365
  return new WorkflowParkRefusal("workflow.park_truth_unreadable", `startWorkflow: resume from "${fromRunId}" was REFUSED — the journal store threw while the workflow's resume claim was taken (${storeErrorClassOf(err)}), so nothing guards the resume against another one; nothing ran. Resume again once the journal store answers.`, { reason: "store_threw" });
345
366
  }
@@ -601,9 +622,14 @@ export const workflowResumeClaimFallback = {
601
622
  table.delete(key);
602
623
  },
603
624
  };
604
- export function takeWorkflowResumeClaim(store, input) {
625
+ export function takeWorkflowResumeClaim(store, input, carriesDecision = false) {
626
+ const noted = (v) => {
627
+ if (v.granted)
628
+ noteLocalClaimHolder(input.newRunId, carriesDecision);
629
+ return v;
630
+ };
605
631
  if (store.resumeClaim === undefined)
606
- return Promise.resolve({ ...workflowResumeClaimFallback.acquire(store, input), fallback: true });
632
+ return Promise.resolve(noted({ ...workflowResumeClaimFallback.acquire(store, input), fallback: true }));
607
633
  let asked;
608
634
  try {
609
635
  asked = Promise.resolve(store.resumeClaim(input));
@@ -614,10 +640,37 @@ export function takeWorkflowResumeClaim(store, input) {
614
640
  return asked
615
641
  .then((v) => {
616
642
  const granted = Boolean(v.granted);
617
- return { granted, ...(v.holder !== undefined ? { holder: v.holder } : {}), ...(granted ? {} : { lapse: claimRemainingOf(v, Date.now()) }), fallback: false };
643
+ const by = granted ? undefined : v.stopped?.by;
644
+ return noted({ granted, ...(v.holder !== undefined ? { holder: v.holder } : {}), ...(granted ? {} : { lapse: claimRemainingOf(v, Date.now()) }), ...(typeof by === "string" ? { stopped: { by } } : {}), fallback: false });
618
645
  });
619
646
  }
647
+ export async function takeWorkflowResumeClaims(store, keys, newRunId, scope, carriesDecision = false) {
648
+ const taken = [];
649
+ const giveBack = () => Promise.all(taken.map((t) => releaseWorkflowResumeClaim(store, t.input, t.fallback)));
650
+ let last = { granted: true, fallback: store.resumeClaim === undefined };
651
+ for (const sourceRunId of keys) {
652
+ const input = { sourceRunId, newRunId, scope };
653
+ try {
654
+ last = await takeWorkflowResumeClaim(store, input, carriesDecision);
655
+ }
656
+ catch (err) {
657
+ await giveBack();
658
+ throw err;
659
+ }
660
+ if (!last.granted) {
661
+ await giveBack();
662
+ return last;
663
+ }
664
+ taken.push({ input, fallback: last.fallback });
665
+ }
666
+ return last;
667
+ }
668
+ export async function releaseWorkflowResumeClaims(store, keys, newRunId, scope, fallback) {
669
+ for (const sourceRunId of keys)
670
+ await releaseWorkflowResumeClaim(store, { sourceRunId, newRunId, scope }, fallback);
671
+ }
620
672
  export async function releaseWorkflowResumeClaim(store, input, fallback) {
673
+ dropLocalClaimHolder(input.newRunId);
621
674
  if (fallback)
622
675
  return workflowResumeClaimFallback.release(store, input);
623
676
  try {
@@ -1162,7 +1215,7 @@ export function startWorkflow(runner, fn, opts = {}, internals) {
1162
1215
  return observed;
1163
1216
  };
1164
1217
  const journalStore = opts.journalStore;
1165
- let resumeClaim;
1218
+ const resumeClaims = [];
1166
1219
  const replayByOrdinal = [];
1167
1220
  let divergence;
1168
1221
  const recordedOrdinalOfPosition = new Map();
@@ -1490,8 +1543,9 @@ export function startWorkflow(runner, fn, opts = {}, internals) {
1490
1543
  const withoutToken = (text, token) => (token === "" ? text : text.split(token).join("<token>"));
1491
1544
  const parkBindingBroken = (ordinal, why) => new WorkflowParkRefusal("workflow.park_binding_broken", `workflow resume: ordinal ${ordinal}'s park cannot be bound to its checkpoint (${why}) — the recorded park is inconsistent. Decide the checkpoint through the deployment's approval channel and start a fresh run.`, { ordinal });
1492
1545
  const readParkTruth = async (seat, key, ordinal) => {
1493
- if (key.token === "" || key.sessionId === "")
1494
- throw parkBindingBroken(ordinal, "the record names no token or no session for it");
1546
+ const keyFault = parkBindingFault(key);
1547
+ if (keyFault !== undefined)
1548
+ throw parkBindingBroken(ordinal, keyFault);
1495
1549
  const read = await finalizeWithin(timers, new Promise((resolve) => resolve(seat.get(key.token))).then((cp) => ({ cp }), (err) => ({ err })), "timeout");
1496
1550
  if (read === "timeout" || "err" in read) {
1497
1551
  throw new WorkflowParkRefusal("workflow.park_truth_unreadable", `workflow resume: ordinal ${ordinal} is recorded as PARKED and its checkpoint could not be read from the checkpoint store (${read === "timeout" ? `the read did not settle within ${WORKFLOW_STORE_WAIT_BOUND_MS}ms` : withoutToken(errText(read.err), key.token)}); the resume is refused rather than run beside a pinned child.`, { reason: "checkpoint_store_threw" });
@@ -1499,10 +1553,9 @@ export function startWorkflow(runner, fn, opts = {}, internals) {
1499
1553
  const cp = read.cp;
1500
1554
  if (cp === null)
1501
1555
  return { kind: "not_pending", key, status: "absent" };
1502
- if (cp.token !== key.token)
1503
- throw parkBindingBroken(ordinal, "the checkpoint store answered a row under another token");
1504
- if (cp.sessionId !== key.sessionId)
1505
- throw parkBindingBroken(ordinal, "the checkpoint belongs to another session than the parked row");
1556
+ const rowFault = parkBindingFault(key, cp);
1557
+ if (rowFault !== undefined)
1558
+ throw parkBindingBroken(ordinal, rowFault);
1506
1559
  if (cp.status !== "pending")
1507
1560
  return { kind: "not_pending", key, status: cp.status, ...(cp.checkpointId !== undefined ? { checkpointId: cp.checkpointId } : {}) };
1508
1561
  return { kind: "pending", key, cp };
@@ -2771,6 +2824,8 @@ export function startWorkflow(runner, fn, opts = {}, internals) {
2771
2824
  if (inheritedModelError !== undefined)
2772
2825
  throw inheritedModelError;
2773
2826
  const typed = applyWorkflowAgentType(spec, agentOpts.agentType, agentRegistry);
2827
+ if (typed.droppedMcp !== undefined)
2828
+ announceShadowedDefinitionServers({ runner, leg: bornChildSessionId, root: spawnAttribution, agent: typed.agentType, dropped: typed.droppedMcp });
2774
2829
  const typedSpec0 = typed.spec;
2775
2830
  const typedSpec = withWorkflowChildSeats(typedSpec0, inheritedModelSnap, inheritedThinkingSnap, runnerRoleMap(runner));
2776
2831
  const seatedSpec = applyParentSpecSeat(withWorkflowChildPersona(typedSpec, agentOpts.schema ?? typedSpec.outputSchema), opts.parentSpecSeat);
@@ -2790,7 +2845,7 @@ export function startWorkflow(runner, fn, opts = {}, internals) {
2790
2845
  opts.onForwardEvent(e.type === "task_progress" || e.type === "task_started" ? memberStamp(e, callKey, label) : e);
2791
2846
  }
2792
2847
  : undefined;
2793
- const baseInternals = { ...parkGapInherit(seatedSpec), ...(agentOpts.isolation ? { isolation: agentOpts.isolation } : {}), ...(opts.parentCwd !== undefined ? { parentCwd: opts.parentCwd } : {}), ...(opts.parentSpecSeat?.projectId !== undefined ? { parentProjectId: opts.parentSpecSeat.projectId } : {}), ...callerPlacementSeats(opts.parentCwd, opts.callerRoot), ...spawnAttribution, ...definitionSeats(typed), ...(await captureFloorSeatsNow()), ...(enrichedForward !== undefined ? { onForwardEvent: enrichedForward } : {}), delegationTaskType: "workflow", spendParent: memberSpendParent, agentName: label, ...memberSeat(callKey, label), onWorkspaceResolved: createWorkspaceObserver(rec) };
2848
+ const baseInternals = { ...parkGapInherit(seatedSpec), ...(agentOpts.isolation ? { isolation: agentOpts.isolation } : {}), ...(opts.parentCwd !== undefined ? { parentCwd: opts.parentCwd } : {}), ...(opts.parentSpecSeat?.project !== undefined ? { parentProject: opts.parentSpecSeat.project } : {}), ...callerPlacementSeats(opts.parentCwd, opts.callerRoot), ...spawnAttribution, ...definitionSeats(typed), ...(await captureFloorSeatsNow()), ...(enrichedForward !== undefined ? { onForwardEvent: enrichedForward } : {}), delegationTaskType: "workflow", spendParent: memberSpendParent, agentName: label, ...memberSeat(callKey, label), onWorkspaceResolved: createWorkspaceObserver(rec) };
2794
2849
  let attempts = 0;
2795
2850
  let throttleRetried = false;
2796
2851
  let throttleFirst;
@@ -3237,6 +3292,8 @@ export function startWorkflow(runner, fn, opts = {}, internals) {
3237
3292
  if (inheritedModelError !== undefined)
3238
3293
  throw inheritedModelError;
3239
3294
  const typed = applyWorkflowAgentType(spec, agentOpts.agentType, agentRegistry);
3295
+ if (typed.droppedMcp !== undefined)
3296
+ announceShadowedDefinitionServers({ runner, leg: childSessionId, root: spawnAttribution, agent: typed.agentType, dropped: typed.droppedMcp });
3240
3297
  const typedSpec0 = typed.spec;
3241
3298
  const typedSpec = withWorkflowChildSeats(typedSpec0, inheritedModelSnap, inheritedThinkingSnap, runnerRoleMap(runner));
3242
3299
  const seatedSpec = applyParentSpecSeat(withWorkflowChildPersona(typedSpec, agentOpts.schema ?? typedSpec.outputSchema), opts.parentSpecSeat);
@@ -3266,7 +3323,7 @@ export function startWorkflow(runner, fn, opts = {}, internals) {
3266
3323
  ...(drive === undefined && !spec.sessionId && childSessionId !== undefined ? { sessionIdMintedBySpawner: true } : {}),
3267
3324
  ...(agentOpts.isolation ? { isolation: agentOpts.isolation } : {}),
3268
3325
  ...(opts.parentCwd !== undefined ? { parentCwd: opts.parentCwd } : {}),
3269
- ...(opts.parentSpecSeat?.projectId !== undefined ? { parentProjectId: opts.parentSpecSeat.projectId } : {}),
3326
+ ...(opts.parentSpecSeat?.project !== undefined ? { parentProject: opts.parentSpecSeat.project } : {}),
3270
3327
  ...callerPlacementSeats(opts.parentCwd, opts.callerRoot),
3271
3328
  ...spawnAttribution,
3272
3329
  ...definitionSeats(typed),
@@ -3637,8 +3694,31 @@ export function startWorkflow(runner, fn, opts = {}, internals) {
3637
3694
  emitRunLog(`launch: this run's launch record was not kept (${why}) — nothing could continue a card this run parked on, so its agents do not park on approvals.`);
3638
3695
  }
3639
3696
  }
3697
+ const takeRunClaim = async (keys, what, onThrow) => {
3698
+ const store = journalStore;
3699
+ const fallback = store.resumeClaim === undefined;
3700
+ for (const key of keys) {
3701
+ if (resumeClaims.some((c) => c.sourceRunId === key))
3702
+ continue;
3703
+ if (finalized)
3704
+ throw new Error("workflow run already finalized — its resume admission takes no claim after the run ended");
3705
+ const verdict = takeWorkflowResumeClaim(store, { sourceRunId: key, newRunId: runId, scope }, (parkedResume?.length ?? 0) > 0);
3706
+ resumeClaims.push({ sourceRunId: key, verdict, fallback });
3707
+ let decision;
3708
+ try {
3709
+ decision = await verdict;
3710
+ }
3711
+ catch (err) {
3712
+ throw onThrow(err);
3713
+ }
3714
+ if (!decision.granted)
3715
+ throw claimRefusalOf(what, decision);
3716
+ }
3717
+ };
3718
+ if (opts.resumeFromRunId === undefined && journalStore) {
3719
+ await takeRunClaim([runId], `run "${clampRunIdText(runId)}"`, (err) => new Error(`startWorkflow: run "${clampRunIdText(runId)}" was REFUSED — the journal store threw while the workflow's claim was taken (${storeErrorClassOf(err)}), so nothing guards the run against a continuation of it; nothing ran. Start it again once the journal store answers.`));
3720
+ }
3640
3721
  if (opts.resumeFromRunId !== undefined && journalStore) {
3641
- const usingFallback = journalStore.resumeClaim === undefined;
3642
3722
  const named = opts.resumeFromRunId;
3643
3723
  let walkThrew;
3644
3724
  const walkWithin = (p) => storeWithin(p.catch((err) => ((walkThrew ??= { err }), Promise.reject(err))));
@@ -3657,38 +3737,18 @@ export function startWorkflow(runner, fn, opts = {}, internals) {
3657
3737
  const keyTree = store === undefined || heldKey !== undefined ? undefined : await readTree();
3658
3738
  if (typeof keyTree === "string")
3659
3739
  throw await treeRefusal(keyTree);
3660
- const root = heldKey ?? (keyTree === undefined ? named : keyTree.root.id);
3740
+ const firstKeys = heldKey !== undefined ? [heldKey] : keyTree === undefined ? [named] : workflowClaimKeysOf(keyTree).keys;
3661
3741
  const otherRoot = () => new Error(`startWorkflow: resume from "${clampRunIdText(named)}" was REFUSED — the workflow's records now lead to another first run than the one its resume claim was taken for (a run of the workflow was removed or created again meanwhile), so its claim cannot hold it. Resume again.`);
3662
- if (finalized)
3663
- throw new Error("workflow run already finalized — its resume admission takes no claim after the run ended");
3664
- const verdict = takeWorkflowResumeClaim(journalStore, { sourceRunId: root, newRunId: runId, scope });
3665
- resumeClaim = { sourceRunId: root, verdict, fallback: usingFallback };
3666
- let decision;
3667
- try {
3668
- decision = await verdict;
3669
- }
3670
- catch (err) {
3671
- throw journalStoreClaimRefusal(clampRunIdText(named), err);
3672
- }
3673
- if (!decision.granted) {
3674
- const forAnswer = isAnswerRecordClaimHolder(decision.holder);
3675
- const holder = decision.holder !== undefined && !forAnswer ? clampRunIdText(decision.holder) : "";
3676
- const lapse = decision.lapse;
3677
- throw new Error(`startWorkflow: resume from "${clampRunIdText(named)}" was REFUSED — ` +
3678
- (forAnswer
3679
- ? "another leg of the workflow holds the resume claim on it for a moment, to record a person's answer to continuing it (no run holds it): resume again once it gives the claim back. If that leg's process stopped without giving the claim back, "
3680
- : `another run already holds the resume claim on it${holder ? ` (holder: ${holder})` : " (holder unknown to the store)"}. ` +
3681
- "Two concurrent resumes of one source run fork its execution: both replay the same prefix and then " +
3682
- "re-run the whole suffix live, duplicating every side effect. Wait for the holder to reach a terminal " +
3683
- "state (or stop it) and resume again. If the holder's process stopped without giving the claim back, ") +
3684
- `the claim lapses ${lapse?.kind === "at" ? `at ${new Date(lapse.at).toISOString()} at the latest` : `when the journal store's expiry frees it${lapse?.kind === "unreadable" ? ` (${CLAIM_REMAINING_UNREADABLE_NOTE})` : ""}`}, and the same resume goes through then.`);
3685
- }
3742
+ const claimThrew = (err) => journalStoreClaimRefusal(clampRunIdText(named), err);
3743
+ await takeRunClaim(firstKeys, `resume from "${clampRunIdText(named)}"`, claimThrew);
3686
3744
  if (store !== undefined) {
3687
3745
  const tree = await readTree();
3688
3746
  if (typeof tree === "string")
3689
3747
  throw await treeRefusal(tree);
3690
- if (tree.root.id !== root)
3748
+ const keys = workflowClaimKeysOf(tree).keys;
3749
+ if (heldKey !== undefined ? keys[0] !== heldKey : !sameClaimKeys(keys, firstKeys))
3691
3750
  throw otherRoot();
3751
+ await takeRunClaim(keys, `resume from "${clampRunIdText(named)}"`, claimThrew);
3692
3752
  admissionTree = Promise.resolve(tree);
3693
3753
  for (const e of parkedResume ?? []) {
3694
3754
  const was = e.decisionId === undefined ? undefined : workflowParkDecisionOf(e.token, e.decisionId, tree);
@@ -3908,12 +3968,12 @@ export function startWorkflow(runner, fn, opts = {}, internals) {
3908
3968
  if (resumeRefusal !== undefined)
3909
3969
  throw refusalTerminal(resumeRefusal);
3910
3970
  if (maxResultChars !== undefined) {
3911
- let size = 0;
3971
+ let size;
3912
3972
  try {
3913
3973
  size = JSON.stringify(result)?.length ?? 0;
3914
3974
  }
3915
3975
  catch {
3916
- size = 0;
3976
+ size = Number.POSITIVE_INFINITY;
3917
3977
  }
3918
3978
  if (size > maxResultChars)
3919
3979
  throw new WorkflowResultTooLargeError(size, maxResultChars);
@@ -4008,7 +4068,7 @@ export function startWorkflow(runner, fn, opts = {}, internals) {
4008
4068
  answer();
4009
4069
  }
4010
4070
  awaitedAppends.clear();
4011
- if (resumeClaim !== undefined) {
4071
+ for (const resumeClaim of resumeClaims) {
4012
4072
  const granted = await finalizeWithin(timers, resumeClaim.verdict.then((v) => v.granted, () => false), false);
4013
4073
  if (granted) {
4014
4074
  if (resumeClaim.fallback) {
@@ -4025,6 +4085,7 @@ export function startWorkflow(runner, fn, opts = {}, internals) {
4025
4085
  }
4026
4086
  }
4027
4087
  }
4088
+ dropLocalClaimHolder(runId);
4028
4089
  for (const row of [...bceLive.values()]) {
4029
4090
  bceTerminal(row.callKey, "failed", "abandoned by run finalize", undefined);
4030
4091
  }
@@ -4046,19 +4107,20 @@ export function startWorkflow(runner, fn, opts = {}, internals) {
4046
4107
  }
4047
4108
  })();
4048
4109
  bindSettledRun(done, run);
4049
- return {
4110
+ const cancel = (reason) => cancelController.abort(reason ? new Error(reason) : undefined);
4111
+ const handle = {
4050
4112
  runId,
4051
4113
  done,
4052
- cancel: (reason) => cancelController.abort(reason ? new Error(reason) : undefined),
4114
+ cancel,
4053
4115
  parked: () => runParkedOf(run),
4054
- stopAgent: async (callKey, o) => {
4055
- const by = o?.stoppedBy;
4056
- if (by !== undefined && (typeof by !== "string" || by.trim() === "" || by.length > MAX_MEMBER_STOPPER_CHARS))
4057
- throw new TypeError(`WorkflowHandle.stopAgent: stoppedBy must be a non-empty string of at most ${MAX_MEMBER_STOPPER_CHARS} characters`);
4058
- return stopMember(callKey, by ?? "parent");
4059
- },
4116
+ stopAgent: async (callKey, o) => stopMember(callKey, readWorkflowStopper(o?.stoppedBy, "WorkflowHandle.stopAgent")),
4117
+ stop: async (o) => stopWorkflowTree(runId, scope, readWorkflowStopper(o?.stoppedBy, "WorkflowHandle.stop"), seats, { self: run, own: local, keysWithoutTree: resumeClaims.length > 0 ? resumeClaims.map((c) => c.sourceRunId) : [opts.resumeFromRunId ?? runId] }),
4060
4118
  recordLanded: () => recordLanded.then((o) => o.ok),
4061
4119
  };
4120
+ const seats = { ...(store !== undefined ? { runStore: store } : {}), ...(journalStore !== undefined ? { journalStore } : {}), ...(parkSeat !== undefined ? { checkpointStore: parkSeat } : {}) };
4121
+ const local = { runId, creationId: () => creationId, cancel: (reason) => cancel(reason), done, handle };
4122
+ holdLocalWorkflowRun(local);
4123
+ return handle;
4062
4124
  }
4063
4125
  export async function runWorkflow(runner, fn, opts = {}, internals) {
4064
4126
  return startWorkflow(runner, fn, opts, internals).done;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * THE MANAGER RECIPE: data and text a host composes into its own spec and agent definitions, not an engine mode — the coordinator
3
+ * role text (unchanged), `ownHandsReadOnly` (the manager's own hands only), `runLedger` (the member ledger, the report tool, the
4
+ * actions section, the launch check), and the duties on `appendSystemPrompt`. A worker's definition carries no delegation tool
5
+ * ({@link managerWorkerDefinition}); no agent-to-agent peer tool is mounted (a peer call waits in the call; a manager must not).
6
+ */
7
+ import type { AgentDefinition } from "../core/agent-definition.js";
8
+ /** The duties the manager reads after its role text. */
9
+ export declare const MANAGER_DUTIES_ADDENDUM = "# Your duties as the manager of this work\n\nThe work you direct can be of any kind \u2014 code, research, analysis, operations, writing. Where the coordinator text above speaks of software engineering, read it for whatever this work is.\n\nYou do not change the work yourself. Your own hands read: files, searches, read-only commands, and your workers' full records (AgentTranscript). Every change goes through a worker. A manager who edits becomes a party to the work, with nobody left to check it.\n\nVerifying is your duty, not a suggestion. A worker's report says what it meant to do, not necessarily what it did. Before you tell the person that a result holds:\n- read what the worker actually did \u2014 the <actions> section of its notification, its record (AgentTranscript), the files it says it changed;\n- where checking needs something run, send a fresh verification worker (never the worker that did the work) and read its result;\n- when what a worker said and what it did disagree, say so plainly.\n\nReport to the person with SendUserMessage: when you start (the plan, and what it will cost), when a result is overturned, when you are blocked or need a decision, and at the end. For each conclusion about a worker, say what it rests on: \"verified\" only for a check made after that worker reported (cite your call id, or the verification worker's task id); \"relayed\" for what the worker said that you did not check; \"inferred\" for your own judgment. Beside every message the engine delivers its own ledger of the workers \u2014 how each ended, what each did, which ones nobody checked \u2014 so a report that claims more than was checked shows it.\n\nNever tell the person that everything passed while a worker failed, is still running, or was never checked.";
10
+ /** The manager's own task seats (spread into the host's spec; the host adds its objective, model, delegation tool and workers). */
11
+ export declare const MANAGER_RECIPE: Readonly<{
12
+ readonly promptRole: "coordinator";
13
+ readonly ownHandsReadOnly: true;
14
+ readonly runLedger: true;
15
+ readonly appendSystemPrompt: "# Your duties as the manager of this work\n\nThe work you direct can be of any kind — code, research, analysis, operations, writing. Where the coordinator text above speaks of software engineering, read it for whatever this work is.\n\nYou do not change the work yourself. Your own hands read: files, searches, read-only commands, and your workers' full records (AgentTranscript). Every change goes through a worker. A manager who edits becomes a party to the work, with nobody left to check it.\n\nVerifying is your duty, not a suggestion. A worker's report says what it meant to do, not necessarily what it did. Before you tell the person that a result holds:\n- read what the worker actually did — the <actions> section of its notification, its record (AgentTranscript), the files it says it changed;\n- where checking needs something run, send a fresh verification worker (never the worker that did the work) and read its result;\n- when what a worker said and what it did disagree, say so plainly.\n\nReport to the person with SendUserMessage: when you start (the plan, and what it will cost), when a result is overturned, when you are blocked or need a decision, and at the end. For each conclusion about a worker, say what it rests on: \"verified\" only for a check made after that worker reported (cite your call id, or the verification worker's task id); \"relayed\" for what the worker said that you did not check; \"inferred\" for your own judgment. Beside every message the engine delivers its own ledger of the workers — how each ended, what each did, which ones nobody checked — so a report that claims more than was checked shows it.\n\nNever tell the person that everything passed while a worker failed, is still running, or was never checked.";
16
+ }>;
17
+ /** A worker's definition under the recipe: the host's, with the delegation tool (mounted as `delegationToolName`) denied. */
18
+ export declare function managerWorkerDefinition(def: AgentDefinition, delegationToolName?: string): AgentDefinition;
@@ -0,0 +1,24 @@
1
+ export const MANAGER_DUTIES_ADDENDUM = `# Your duties as the manager of this work
2
+
3
+ The work you direct can be of any kind — code, research, analysis, operations, writing. Where the coordinator text above speaks of software engineering, read it for whatever this work is.
4
+
5
+ You do not change the work yourself. Your own hands read: files, searches, read-only commands, and your workers' full records (AgentTranscript). Every change goes through a worker. A manager who edits becomes a party to the work, with nobody left to check it.
6
+
7
+ Verifying is your duty, not a suggestion. A worker's report says what it meant to do, not necessarily what it did. Before you tell the person that a result holds:
8
+ - read what the worker actually did — the <actions> section of its notification, its record (AgentTranscript), the files it says it changed;
9
+ - where checking needs something run, send a fresh verification worker (never the worker that did the work) and read its result;
10
+ - when what a worker said and what it did disagree, say so plainly.
11
+
12
+ Report to the person with SendUserMessage: when you start (the plan, and what it will cost), when a result is overturned, when you are blocked or need a decision, and at the end. For each conclusion about a worker, say what it rests on: "verified" only for a check made after that worker reported (cite your call id, or the verification worker's task id); "relayed" for what the worker said that you did not check; "inferred" for your own judgment. Beside every message the engine delivers its own ledger of the workers — how each ended, what each did, which ones nobody checked — so a report that claims more than was checked shows it.
13
+
14
+ Never tell the person that everything passed while a worker failed, is still running, or was never checked.`;
15
+ export const MANAGER_RECIPE = Object.freeze({
16
+ promptRole: "coordinator",
17
+ ownHandsReadOnly: true,
18
+ runLedger: true,
19
+ appendSystemPrompt: MANAGER_DUTIES_ADDENDUM,
20
+ });
21
+ export function managerWorkerDefinition(def, delegationToolName = "Agent") {
22
+ const denied = def.denyTools ?? [];
23
+ return denied.includes(delegationToolName) ? { ...def } : { ...def, denyTools: [...denied, delegationToolName] };
24
+ }
@@ -1,5 +1,5 @@
1
- /** The dialect this lexer reads. The execution environment falls back to `sh` when no bash is found; a reader on
2
- * that path must degrade every word carrying a {@link BashOnlyConstruct} to the conservative reading. */
1
+ /** The dialect this lexer reads — the one model text runs in: an environment starts it only on a bash it declared and asked
2
+ * (`ExecutionEnv.modelShell`), never on `sh`. The engine's own commands (`ExecutionEnv.exec`) are not read by it. */
3
3
  export declare const SHELL_LEX_DIALECT = "bash";
4
4
  /** What holds a character quoted: the four quote forms and the backslash escape, one reason each. */
5
5
  export declare const QUOTE_KINDS: readonly ["'", "\"", "$'", "$\"", "\\"];
package/dist/shell/lex.js CHANGED
@@ -1557,7 +1557,7 @@ function scanText(source, connectorsAreText, segments, level, list, resumed) {
1557
1557
  return undefined;
1558
1558
  if (w.inSubscript())
1559
1559
  return fail("unterminated_subscript", w.srcOfRaw[w.subscript.rawStart]);
1560
- const word = w.finish(acceptable, pendingHeredoc === undefined);
1560
+ const word = w.finish(acceptable && pendingRedirect === undefined, pendingHeredoc === undefined);
1561
1561
  const at = w.at;
1562
1562
  w = new WordBuilder();
1563
1563
  if (pendingHeredoc !== undefined) {
@@ -57,7 +57,9 @@
57
57
  * A file that does not parse, or whose checksum does not match its contents, yields ZERO rules and a loud
58
58
  * disclosure — never a partial load. Half a rule set is a set nobody reviewed. Note what the checksum is
59
59
  * and is not: it detects corruption, and it does not detect an editor, because an editor recomputes it.
60
- * For this backend the trust is host = user, exactly as for the settings file it mirrors.
60
+ * For this backend the trust is host = user, exactly as for the settings file it mirrors. So a RULE row
61
+ * in bytes that passed the check is what someone wrote: one that is no data is that row's fault alone,
62
+ * named by the one row reader every backend's rows go through — never a reason to drop the rows beside it.
61
63
  */
62
64
  import type { PersistedRule, RuleTombstone } from "../../core/permission-rule-model.js";
63
65
  import type { DurableRulePartition, DurableRulePartitionProvider, PermissionRuleWriter, QuarantinedRuleAdd, RuleSyncFrontier, StoredRules, WritableDurableRulePartition } from "../../core/permission-rule-store.js";
@@ -283,7 +283,6 @@ class FileDurableRulePartition {
283
283
  : unreadable(`${grammar.sentence}; ${whole}`);
284
284
  }
285
285
  const rowKinds = [
286
- ["rule", parsed.rules],
287
286
  ["tombstone", parsed.tombstones],
288
287
  ["quarantined", parsed.quarantined ?? []],
289
288
  ];
@@ -1,4 +1,4 @@
1
- import { type WorkflowJournalEntry, type WorkflowJournalStore, type WorkflowLaunchRecord, type ResumeClaimArgs, type ResumeClaimAnswer } from "../../core/workflow-journal-store.js";
1
+ import { type WorkflowJournalEntry, type WorkflowJournalStore, type WorkflowLaunchRecord, type ResumeClaimArgs, type ResumeClaimAnswer, type StopResumeClaimArgs, type StopResumeClaimAnswer } from "../../core/workflow-journal-store.js";
2
2
  import { type CorruptReadInfo } from "./corrupt-read-sink.js";
3
3
  /**
4
4
  * RB-242 — how long a resume claim survives WITHOUT an engine release. This is the backstop for an engine that
@@ -149,6 +149,12 @@ export declare class FileWorkflowJournalStore implements WorkflowJournalStore {
149
149
  * and a release that could not create one must not leave the claim standing for its lease.
150
150
  */
151
151
  private removeIfUnchanged;
152
+ /**
153
+ * Atomically replace a claim file IN PLACE with `payload` ONLY if the bytes on disk are still `judged`, under the same
154
+ * removal gate {@link removeIfUnchanged} uses. Unlike unlink + link, `rename` leaves no empty-file window where a concurrent
155
+ * `resumeClaim` could acquire the slot while arm (c)'s local holder is still running before cancel.
156
+ */
157
+ private replaceIfUnchanged;
152
158
  /**
153
159
  * The removal gate of the claim at `path` judged as `judged` — or, given a gate file's own path, that gate. Its name is a fixed
154
160
  * length (a digest of the claim file's name and the bytes, `<digest>.takeover`), never the claim's name with more appended: a
@@ -187,9 +193,16 @@ export declare class FileWorkflowJournalStore implements WorkflowJournalStore {
187
193
  */
188
194
  resumeClaim(input: ResumeClaimArgs): Promise<ResumeClaimAnswer>;
189
195
  /** RB-242 — release ONLY a claim this `newRunId` still holds in this process ({@link heldHere}). A claim that is already gone
190
- * (TTL-reaped and possibly taken over), or one the same run id holds from another process, is a no-op: unlinking a successor's
191
- * claim would re-open the very fork this prevents. */
196
+ * (TTL-reaped and possibly taken over), a tombstone, or one the same run id holds from another process, is a no-op: unlinking
197
+ * a successor's claim would re-open the very fork this prevents. */
192
198
  releaseResumeClaim(input: ResumeClaimArgs): Promise<void>;
199
+ /**
200
+ * #5156 R1 — compare-and-write a permanent stop tombstone on `(sourceRunId, scope)`.
201
+ * Writes no `holderProcess` and sets finite `expiresAt = Number.MAX_SAFE_INTEGER` (never `Infinity`, which serializes to
202
+ * `null`), so pre-tombstone (v7.71.x) readers also refuse, never take over and never reap the tombstone. Arms (b) and (c)
203
+ * replace the existing claim atomically in place under its removal gate, dropping any old `holderProcess` with no empty window.
204
+ */
205
+ stopResumeClaim(input: StopResumeClaimArgs): Promise<StopResumeClaimAnswer>;
193
206
  /** Release ledger fds (graceful shutdown; parity with the other file stores' dispose).
194
207
  * Refcounted: the fds are shared with any other instance on the same directory, so the LAST holder
195
208
  * closes them. Idempotent — a second dispose() on the same instance must not decrement twice and pull