@bastani/atomic 0.9.27 → 0.9.28-alpha.2

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 (383) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/dist/builtin/intercom/CHANGELOG.md +6 -0
  3. package/dist/builtin/intercom/broker/broker.ts +13 -1
  4. package/dist/builtin/intercom/package.json +2 -2
  5. package/dist/builtin/mcp/CHANGELOG.md +6 -0
  6. package/dist/builtin/mcp/package.json +1 -1
  7. package/dist/builtin/subagents/package.json +3 -3
  8. package/dist/builtin/web-access/index.bundle.mjs +194 -44
  9. package/dist/builtin/web-access/package.json +3 -3
  10. package/dist/builtin/workflows/CHANGELOG.md +31 -0
  11. package/dist/builtin/workflows/builtin/{chunk-gw7rghda.js → chunk-aqv8ny38.js} +257 -259
  12. package/dist/builtin/workflows/builtin/{chunk-gts8wgjr.js → chunk-br4ac9a3.js} +1 -1
  13. package/dist/builtin/workflows/builtin/{chunk-9bhs02gm.js → chunk-p3xmajmj.js} +439 -40
  14. package/dist/builtin/workflows/builtin/chunk-p6jagvyf.js +8 -0
  15. package/dist/builtin/workflows/builtin/goal.js +2 -2
  16. package/dist/builtin/workflows/builtin/index.js +4 -4
  17. package/dist/builtin/workflows/builtin/ralph.js +2 -2
  18. package/dist/builtin/workflows/package.json +2 -2
  19. package/dist/builtin/workflows/src/authoring.d.ts +14 -0
  20. package/dist/builtin/workflows/src/extension/index.bundle.mjs +108110 -107201
  21. package/dist/builtin/workflows/src/index.js +42226 -41077
  22. package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +16 -11
  23. package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +16 -1
  24. package/dist/cli/args.d.ts +1 -0
  25. package/dist/cli/args.d.ts.map +1 -1
  26. package/dist/cli/args.js +12 -5
  27. package/dist/cli/args.js.map +1 -1
  28. package/dist/cli/credential-print.d.ts +1 -1
  29. package/dist/cli/credential-print.d.ts.map +1 -1
  30. package/dist/cli/credential-print.js +2 -56
  31. package/dist/cli/credential-print.js.map +1 -1
  32. package/dist/codemode-worker.js +99 -3
  33. package/dist/core/agent-session-accessors.d.ts.map +1 -1
  34. package/dist/core/agent-session-accessors.js +6 -1
  35. package/dist/core/agent-session-accessors.js.map +1 -1
  36. package/dist/core/agent-session-compaction.d.ts.map +1 -1
  37. package/dist/core/agent-session-compaction.js +20 -3
  38. package/dist/core/agent-session-compaction.js.map +1 -1
  39. package/dist/core/agent-session-events.d.ts.map +1 -1
  40. package/dist/core/agent-session-events.js +3 -2
  41. package/dist/core/agent-session-events.js.map +1 -1
  42. package/dist/core/agent-session-extension-bindings.d.ts +6 -0
  43. package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
  44. package/dist/core/agent-session-extension-bindings.js +96 -12
  45. package/dist/core/agent-session-extension-bindings.js.map +1 -1
  46. package/dist/core/agent-session-methods.d.ts +4 -1
  47. package/dist/core/agent-session-methods.d.ts.map +1 -1
  48. package/dist/core/agent-session-methods.js.map +1 -1
  49. package/dist/core/agent-session-prompt.d.ts.map +1 -1
  50. package/dist/core/agent-session-prompt.js +19 -3
  51. package/dist/core/agent-session-prompt.js.map +1 -1
  52. package/dist/core/agent-session-services.d.ts +1 -0
  53. package/dist/core/agent-session-services.d.ts.map +1 -1
  54. package/dist/core/agent-session-services.js +1 -0
  55. package/dist/core/agent-session-services.js.map +1 -1
  56. package/dist/core/agent-session-state.d.ts.map +1 -1
  57. package/dist/core/agent-session-state.js +3 -2
  58. package/dist/core/agent-session-state.js.map +1 -1
  59. package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
  60. package/dist/core/agent-session-tool-registry.js +11 -16
  61. package/dist/core/agent-session-tool-registry.js.map +1 -1
  62. package/dist/core/agent-session-types.d.ts +1 -0
  63. package/dist/core/agent-session-types.d.ts.map +1 -1
  64. package/dist/core/agent-session-types.js.map +1 -1
  65. package/dist/core/agent-session.d.ts +2 -0
  66. package/dist/core/agent-session.d.ts.map +1 -1
  67. package/dist/core/agent-session.js +5 -0
  68. package/dist/core/agent-session.js.map +1 -1
  69. package/dist/core/auth-storage-backends.d.ts.map +1 -1
  70. package/dist/core/auth-storage-backends.js +2 -1
  71. package/dist/core/auth-storage-backends.js.map +1 -1
  72. package/dist/core/auth-storage.d.ts +1 -1
  73. package/dist/core/auth-storage.d.ts.map +1 -1
  74. package/dist/core/auth-storage.js +15 -7
  75. package/dist/core/auth-storage.js.map +1 -1
  76. package/dist/core/azure-provider-compat.d.ts +8 -0
  77. package/dist/core/azure-provider-compat.d.ts.map +1 -0
  78. package/dist/core/azure-provider-compat.js +65 -0
  79. package/dist/core/azure-provider-compat.js.map +1 -0
  80. package/dist/core/child-session-options.d.ts +1 -1
  81. package/dist/core/child-session-options.d.ts.map +1 -1
  82. package/dist/core/child-session-options.js +11 -2
  83. package/dist/core/child-session-options.js.map +1 -1
  84. package/dist/core/compaction/classifier-compaction.d.ts +13 -0
  85. package/dist/core/compaction/classifier-compaction.d.ts.map +1 -0
  86. package/dist/core/compaction/classifier-compaction.js +110 -0
  87. package/dist/core/compaction/classifier-compaction.js.map +1 -0
  88. package/dist/core/compaction/compaction-boundary.d.ts.map +1 -1
  89. package/dist/core/compaction/compaction-boundary.js +2 -6
  90. package/dist/core/compaction/compaction-boundary.js.map +1 -1
  91. package/dist/core/compaction/compaction-runner.d.ts +16 -1
  92. package/dist/core/compaction/compaction-runner.d.ts.map +1 -1
  93. package/dist/core/compaction/compaction-runner.js +97 -12
  94. package/dist/core/compaction/compaction-runner.js.map +1 -1
  95. package/dist/core/compaction/compaction-types.d.ts +18 -1
  96. package/dist/core/compaction/compaction-types.d.ts.map +1 -1
  97. package/dist/core/compaction/compaction-types.js +1 -1
  98. package/dist/core/compaction/compaction-types.js.map +1 -1
  99. package/dist/core/compaction/fallback-planner.d.ts +1 -0
  100. package/dist/core/compaction/fallback-planner.d.ts.map +1 -1
  101. package/dist/core/compaction/fallback-planner.js +2 -0
  102. package/dist/core/compaction/fallback-planner.js.map +1 -1
  103. package/dist/core/compaction/index.d.ts +3 -0
  104. package/dist/core/compaction/index.d.ts.map +1 -1
  105. package/dist/core/compaction/index.js +3 -0
  106. package/dist/core/compaction/index.js.map +1 -1
  107. package/dist/core/compaction/model-resolver.d.ts +16 -0
  108. package/dist/core/compaction/model-resolver.d.ts.map +1 -0
  109. package/dist/core/compaction/model-resolver.js +18 -0
  110. package/dist/core/compaction/model-resolver.js.map +1 -0
  111. package/dist/core/compaction/morph-compaction.d.ts +14 -0
  112. package/dist/core/compaction/morph-compaction.d.ts.map +1 -0
  113. package/dist/core/compaction/morph-compaction.js +99 -0
  114. package/dist/core/compaction/morph-compaction.js.map +1 -0
  115. package/dist/core/compaction/pi-summary-fallback.d.ts +34 -0
  116. package/dist/core/compaction/pi-summary-fallback.d.ts.map +1 -0
  117. package/dist/core/compaction/pi-summary-fallback.js +357 -0
  118. package/dist/core/compaction/pi-summary-fallback.js.map +1 -0
  119. package/dist/core/compaction/planner-outcome.d.ts +10 -6
  120. package/dist/core/compaction/planner-outcome.d.ts.map +1 -1
  121. package/dist/core/compaction/planner-outcome.js +11 -4
  122. package/dist/core/compaction/planner-outcome.js.map +1 -1
  123. package/dist/core/compaction/range-planner-diagnostics.d.ts +3 -1
  124. package/dist/core/compaction/range-planner-diagnostics.d.ts.map +1 -1
  125. package/dist/core/compaction/range-planner-diagnostics.js +11 -0
  126. package/dist/core/compaction/range-planner-diagnostics.js.map +1 -1
  127. package/dist/core/compaction/range-planner.d.ts +3 -3
  128. package/dist/core/compaction/range-planner.d.ts.map +1 -1
  129. package/dist/core/compaction/range-planner.js +59 -28
  130. package/dist/core/compaction/range-planner.js.map +1 -1
  131. package/dist/core/compaction/region-trimming.d.ts.map +1 -1
  132. package/dist/core/compaction/region-trimming.js +7 -0
  133. package/dist/core/compaction/region-trimming.js.map +1 -1
  134. package/dist/core/compaction/structured-compaction-input.d.ts +19 -0
  135. package/dist/core/compaction/structured-compaction-input.d.ts.map +1 -0
  136. package/dist/core/compaction/structured-compaction-input.js +70 -0
  137. package/dist/core/compaction/structured-compaction-input.js.map +1 -0
  138. package/dist/core/compaction/transcript-serialization.d.ts +1 -0
  139. package/dist/core/compaction/transcript-serialization.d.ts.map +1 -1
  140. package/dist/core/compaction/transcript-serialization.js +26 -0
  141. package/dist/core/compaction/transcript-serialization.js.map +1 -1
  142. package/dist/core/extensions/api-types.d.ts +3 -2
  143. package/dist/core/extensions/api-types.d.ts.map +1 -1
  144. package/dist/core/extensions/api-types.js.map +1 -1
  145. package/dist/core/extensions/context-types.d.ts +1 -0
  146. package/dist/core/extensions/context-types.d.ts.map +1 -1
  147. package/dist/core/extensions/context-types.js.map +1 -1
  148. package/dist/core/extensions/loader-api.d.ts.map +1 -1
  149. package/dist/core/extensions/loader-api.js +5 -0
  150. package/dist/core/extensions/loader-api.js.map +1 -1
  151. package/dist/core/extensions/loader-host-modules.d.ts +1 -0
  152. package/dist/core/extensions/loader-host-modules.d.ts.map +1 -1
  153. package/dist/core/extensions/loader-host-modules.js +12 -0
  154. package/dist/core/extensions/loader-host-modules.js.map +1 -1
  155. package/dist/core/extensions/runner-context.d.ts +10 -4
  156. package/dist/core/extensions/runner-context.d.ts.map +1 -1
  157. package/dist/core/extensions/runner-context.js +47 -3
  158. package/dist/core/extensions/runner-context.js.map +1 -1
  159. package/dist/core/extensions/runner.d.ts +11 -4
  160. package/dist/core/extensions/runner.d.ts.map +1 -1
  161. package/dist/core/extensions/runner.js +38 -9
  162. package/dist/core/extensions/runner.js.map +1 -1
  163. package/dist/core/extensions/tool-types.d.ts +2 -0
  164. package/dist/core/extensions/tool-types.d.ts.map +1 -1
  165. package/dist/core/extensions/tool-types.js.map +1 -1
  166. package/dist/core/extensions/workflow-events.d.ts +49 -0
  167. package/dist/core/extensions/workflow-events.d.ts.map +1 -1
  168. package/dist/core/extensions/workflow-events.js.map +1 -1
  169. package/dist/core/extensions/workflow-run-control-hub.d.ts +16 -4
  170. package/dist/core/extensions/workflow-run-control-hub.d.ts.map +1 -1
  171. package/dist/core/extensions/workflow-run-control-hub.js +72 -1
  172. package/dist/core/extensions/workflow-run-control-hub.js.map +1 -1
  173. package/dist/core/extensions/workflow-run-control.d.ts +11 -3
  174. package/dist/core/extensions/workflow-run-control.d.ts.map +1 -1
  175. package/dist/core/extensions/workflow-run-control.js.map +1 -1
  176. package/dist/core/fast-model-variants.d.ts +1 -1
  177. package/dist/core/fast-model-variants.js +1 -1
  178. package/dist/core/fast-model-variants.js.map +1 -1
  179. package/dist/core/keybindings.d.ts +4 -4
  180. package/dist/core/messages.d.ts +1 -0
  181. package/dist/core/messages.d.ts.map +1 -1
  182. package/dist/core/messages.js +5 -1
  183. package/dist/core/messages.js.map +1 -1
  184. package/dist/core/model-config.d.ts.map +1 -1
  185. package/dist/core/model-config.js +2 -1
  186. package/dist/core/model-config.js.map +1 -1
  187. package/dist/core/model-fallback-failures.d.ts.map +1 -1
  188. package/dist/core/model-fallback-failures.js +5 -1
  189. package/dist/core/model-fallback-failures.js.map +1 -1
  190. package/dist/core/model-resolver-cli.d.ts.map +1 -1
  191. package/dist/core/model-resolver-cli.js +5 -1
  192. package/dist/core/model-resolver-cli.js.map +1 -1
  193. package/dist/core/model-resolver-defaults.js +1 -1
  194. package/dist/core/model-resolver-defaults.js.map +1 -1
  195. package/dist/core/model-resolver-initial.d.ts.map +1 -1
  196. package/dist/core/model-resolver-initial.js +6 -1
  197. package/dist/core/model-resolver-initial.js.map +1 -1
  198. package/dist/core/model-resolver-patterns.d.ts.map +1 -1
  199. package/dist/core/model-resolver-patterns.js +2 -1
  200. package/dist/core/model-resolver-patterns.js.map +1 -1
  201. package/dist/core/model-resolver-scope.d.ts.map +1 -1
  202. package/dist/core/model-resolver-scope.js +3 -1
  203. package/dist/core/model-resolver-scope.js.map +1 -1
  204. package/dist/core/model-runtime-streaming.d.ts.map +1 -1
  205. package/dist/core/model-runtime-streaming.js +2 -0
  206. package/dist/core/model-runtime-streaming.js.map +1 -1
  207. package/dist/core/model-runtime.d.ts.map +1 -1
  208. package/dist/core/model-runtime.js +48 -22
  209. package/dist/core/model-runtime.js.map +1 -1
  210. package/dist/core/provider-composer-internal.d.ts.map +1 -1
  211. package/dist/core/provider-composer-internal.js +4 -1
  212. package/dist/core/provider-composer-internal.js.map +1 -1
  213. package/dist/core/provider-display-names.js +1 -1
  214. package/dist/core/provider-display-names.js.map +1 -1
  215. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  216. package/dist/core/remote-catalog-provider.js +3 -0
  217. package/dist/core/remote-catalog-provider.js.map +1 -1
  218. package/dist/core/resource-loader-core.d.ts +1 -0
  219. package/dist/core/resource-loader-core.d.ts.map +1 -1
  220. package/dist/core/resource-loader-core.js +4 -0
  221. package/dist/core/resource-loader-core.js.map +1 -1
  222. package/dist/core/resource-loader-internals.d.ts +1 -0
  223. package/dist/core/resource-loader-internals.d.ts.map +1 -1
  224. package/dist/core/resource-loader-internals.js.map +1 -1
  225. package/dist/core/resource-loader-reload.d.ts.map +1 -1
  226. package/dist/core/resource-loader-reload.js +28 -5
  227. package/dist/core/resource-loader-reload.js.map +1 -1
  228. package/dist/core/resource-loader-types.d.ts +2 -0
  229. package/dist/core/resource-loader-types.d.ts.map +1 -1
  230. package/dist/core/resource-loader-types.js.map +1 -1
  231. package/dist/core/sdk-types.d.ts +6 -4
  232. package/dist/core/sdk-types.d.ts.map +1 -1
  233. package/dist/core/sdk-types.js.map +1 -1
  234. package/dist/core/sdk.d.ts.map +1 -1
  235. package/dist/core/sdk.js +5 -3
  236. package/dist/core/sdk.js.map +1 -1
  237. package/dist/core/session-lifecycle-work.d.ts +2 -1
  238. package/dist/core/session-lifecycle-work.d.ts.map +1 -1
  239. package/dist/core/session-lifecycle-work.js +15 -1
  240. package/dist/core/session-lifecycle-work.js.map +1 -1
  241. package/dist/core/session-manager-history.d.ts.map +1 -1
  242. package/dist/core/session-manager-history.js +4 -2
  243. package/dist/core/session-manager-history.js.map +1 -1
  244. package/dist/core/settings-manager-basic-accessors.d.ts +2 -0
  245. package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
  246. package/dist/core/settings-manager-basic-accessors.js +33 -4
  247. package/dist/core/settings-manager-basic-accessors.js.map +1 -1
  248. package/dist/core/settings-manager-core.d.ts.map +1 -1
  249. package/dist/core/settings-manager-core.js +2 -0
  250. package/dist/core/settings-manager-core.js.map +1 -1
  251. package/dist/core/settings-storage.d.ts.map +1 -1
  252. package/dist/core/settings-storage.js +2 -1
  253. package/dist/core/settings-storage.js.map +1 -1
  254. package/dist/core/settings-types.d.ts +1 -0
  255. package/dist/core/settings-types.d.ts.map +1 -1
  256. package/dist/core/settings-types.js.map +1 -1
  257. package/dist/core/skills.d.ts +1 -1
  258. package/dist/core/skills.d.ts.map +1 -1
  259. package/dist/core/skills.js +3 -1
  260. package/dist/core/skills.js.map +1 -1
  261. package/dist/core/system-prompt.d.ts +3 -0
  262. package/dist/core/system-prompt.d.ts.map +1 -1
  263. package/dist/core/system-prompt.js +7 -3
  264. package/dist/core/system-prompt.js.map +1 -1
  265. package/dist/core/tool-loadout.d.ts.map +1 -1
  266. package/dist/core/tool-loadout.js +8 -1
  267. package/dist/core/tool-loadout.js.map +1 -1
  268. package/dist/core/tool-selection.d.ts +13 -0
  269. package/dist/core/tool-selection.d.ts.map +1 -0
  270. package/dist/core/tool-selection.js +43 -0
  271. package/dist/core/tool-selection.js.map +1 -0
  272. package/dist/core/tools/read.d.ts +7 -0
  273. package/dist/core/tools/read.d.ts.map +1 -1
  274. package/dist/core/tools/read.js +11 -1
  275. package/dist/core/tools/read.js.map +1 -1
  276. package/dist/core/transcript.d.ts +58 -0
  277. package/dist/core/transcript.d.ts.map +1 -0
  278. package/dist/core/transcript.js +185 -0
  279. package/dist/core/transcript.js.map +1 -0
  280. package/dist/extensions/codemode/execute.d.ts.map +1 -1
  281. package/dist/extensions/codemode/execute.js +2 -1
  282. package/dist/extensions/codemode/execute.js.map +1 -1
  283. package/dist/extensions/codemode/index.d.ts.map +1 -1
  284. package/dist/extensions/codemode/index.js +1 -0
  285. package/dist/extensions/codemode/index.js.map +1 -1
  286. package/dist/extensions/codemode/tool.d.ts +4 -1
  287. package/dist/extensions/codemode/tool.d.ts.map +1 -1
  288. package/dist/extensions/codemode/tool.js +6 -3
  289. package/dist/extensions/codemode/tool.js.map +1 -1
  290. package/dist/extensions/herdr/index.d.ts.map +1 -1
  291. package/dist/extensions/herdr/index.js +15 -10
  292. package/dist/extensions/herdr/index.js.map +1 -1
  293. package/dist/extensions/herdr/pane-owner.d.ts +6 -2
  294. package/dist/extensions/herdr/pane-owner.d.ts.map +1 -1
  295. package/dist/extensions/herdr/pane-owner.js +19 -4
  296. package/dist/extensions/herdr/pane-owner.js.map +1 -1
  297. package/dist/extensions/mcp/client/oauth/flow.d.ts.map +1 -1
  298. package/dist/extensions/mcp/client/oauth/flow.js +14 -1
  299. package/dist/extensions/mcp/client/oauth/flow.js.map +1 -1
  300. package/dist/extensions/mcp/client/oauth/types.d.ts +1 -0
  301. package/dist/extensions/mcp/client/oauth/types.d.ts.map +1 -1
  302. package/dist/extensions/mcp/client/oauth/types.js.map +1 -1
  303. package/dist/extensions/mcp/index.js.map +1 -1
  304. package/dist/extensions/mcp/runtime.d.ts +5 -2
  305. package/dist/extensions/mcp/runtime.d.ts.map +1 -1
  306. package/dist/extensions/mcp/runtime.js +18 -4
  307. package/dist/extensions/mcp/runtime.js.map +1 -1
  308. package/dist/index.d.ts +2 -0
  309. package/dist/index.d.ts.map +1 -1
  310. package/dist/index.js +2 -0
  311. package/dist/index.js.map +1 -1
  312. package/dist/main.d.ts.map +1 -1
  313. package/dist/main.js +2 -0
  314. package/dist/main.js.map +1 -1
  315. package/dist/migrations-azure.d.ts +4 -0
  316. package/dist/migrations-azure.d.ts.map +1 -0
  317. package/dist/migrations-azure.js +41 -0
  318. package/dist/migrations-azure.js.map +1 -0
  319. package/dist/migrations.d.ts.map +1 -1
  320. package/dist/migrations.js +2 -0
  321. package/dist/migrations.js.map +1 -1
  322. package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
  323. package/dist/modes/interactive/components/chat-session-host-state.js +2 -1
  324. package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
  325. package/dist/modes/interactive/components/chat-transcript.d.ts +2 -0
  326. package/dist/modes/interactive/components/chat-transcript.d.ts.map +1 -1
  327. package/dist/modes/interactive/components/chat-transcript.js +9 -3
  328. package/dist/modes/interactive/components/chat-transcript.js.map +1 -1
  329. package/dist/modes/interactive/components/compaction-boundary-message.d.ts +2 -0
  330. package/dist/modes/interactive/components/compaction-boundary-message.d.ts.map +1 -1
  331. package/dist/modes/interactive/components/compaction-boundary-message.js +15 -3
  332. package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -1
  333. package/dist/modes/interactive/components/settings-selector-items.d.ts.map +1 -1
  334. package/dist/modes/interactive/components/settings-selector-items.js +43 -0
  335. package/dist/modes/interactive/components/settings-selector-items.js.map +1 -1
  336. package/dist/modes/interactive/components/settings-selector-types.d.ts +6 -0
  337. package/dist/modes/interactive/components/settings-selector-types.d.ts.map +1 -1
  338. package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
  339. package/dist/modes/interactive/interactive-prompt-turn.js +6 -4
  340. package/dist/modes/interactive/interactive-prompt-turn.js.map +1 -1
  341. package/dist/modes/interactive/interactive-render-chat.js +13 -1
  342. package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
  343. package/dist/modes/interactive/interactive-selectors.js +8 -0
  344. package/dist/modes/interactive/interactive-selectors.js.map +1 -1
  345. package/dist/modes/interactive/interactive-session-runtime.js +2 -0
  346. package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
  347. package/dist/modes/interactive/interactive-startup.js +1 -1
  348. package/dist/modes/interactive/interactive-startup.js.map +1 -1
  349. package/dist/modes/interactive/theme/tui-theme.d.ts.map +1 -1
  350. package/dist/modes/interactive/theme/tui-theme.js +1 -0
  351. package/dist/modes/interactive/theme/tui-theme.js.map +1 -1
  352. package/dist/modes/interactive-engine/engine-args.d.ts.map +1 -1
  353. package/dist/modes/interactive-engine/engine-args.js +1 -0
  354. package/dist/modes/interactive-engine/engine-args.js.map +1 -1
  355. package/dist/utils/credential-redaction.d.ts +2 -0
  356. package/dist/utils/credential-redaction.d.ts.map +1 -0
  357. package/dist/utils/credential-redaction.js +20 -0
  358. package/dist/utils/credential-redaction.js.map +1 -0
  359. package/dist/utils/syntax-highlight.d.ts.map +1 -1
  360. package/dist/utils/syntax-highlight.js +6 -1
  361. package/dist/utils/syntax-highlight.js.map +1 -1
  362. package/docs/codemode.md +3 -2
  363. package/docs/compaction/reference.md +10 -4
  364. package/docs/compaction.md +40 -8
  365. package/docs/docs.json +1 -0
  366. package/docs/extensions/api-reference.md +18 -0
  367. package/docs/extensions/authoring.md +1 -1
  368. package/docs/extensions/events.md +2 -2
  369. package/docs/extensions.md +2 -0
  370. package/docs/keybindings.md +9 -9
  371. package/docs/mcp-servers.md +4 -0
  372. package/docs/providers.md +33 -3
  373. package/docs/reference/cli.md +10 -3
  374. package/docs/sdk/reference.md +16 -1
  375. package/docs/sdk/web-server.md +325 -0
  376. package/docs/sdk.md +83 -1
  377. package/docs/security.md +1 -1
  378. package/docs/workflows/api-reference.md +74 -4
  379. package/docs/workflows/authoring.md +6 -2
  380. package/docs/workflows/builtins.md +4 -0
  381. package/docs/workflows/operations.md +12 -4
  382. package/npm-shrinkwrap.json +78 -74
  383. package/package.json +9 -9
@@ -5075,12 +5075,6 @@ var require_lib2 = __commonJS(function(exports, module) {
5075
5075
  }
5076
5076
  });
5077
5077
  });
5078
-
5079
- // dist/builtin/workflows/src/shared/workflow-artifacts.ts
5080
- import { randomUUID as randomUUID3 } from "node:crypto";
5081
- import { mkdir as mkdir2, readdir as readdir2, rm as rm2, stat } from "node:fs/promises";
5082
- import { dirname as dirname4, join as join5 } from "node:path";
5083
- import { getAgentDir, getEnvValue } from "@bastani/atomic";
5084
5078
  // dist/builtin/workflows/src/durable/backend-process-owner.ts
5085
5079
  var DURABLE_BACKEND_PROCESS_OWNER_KEY = Symbol.for("atomic-workflows/durable-backend-process-owner@1");
5086
5080
  function emptyOwner() {
@@ -5105,6 +5099,16 @@ function getDurableBackendProcessOwner() {
5105
5099
  bag[DURABLE_BACKEND_PROCESS_OWNER_KEY] = created;
5106
5100
  return created;
5107
5101
  }
5102
+
5103
+ // dist/builtin/workflows/src/shared/pending-stage-retention.ts
5104
+ var PENDING_STAGE_SETTLED_MESSAGE_LIMIT = 50;
5105
+ async function retainPendingStageMessages(messages, archive) {
5106
+ const settled = messages.filter((entry) => entry.status === "delivered" || entry.status === "undeliverable" && entry.undeliverableNotifiedAt !== undefined);
5107
+ const expired = new Set(settled.slice(0, Math.max(0, settled.length - PENDING_STAGE_SETTLED_MESSAGE_LIMIT)));
5108
+ for (const entry of expired)
5109
+ await archive(entry);
5110
+ return expired.size === 0 ? messages : messages.filter((entry) => !expired.has(entry));
5111
+ }
5108
5112
  // dist/builtin/workflows/src/durable/dbos-admission.ts
5109
5113
  import { AsyncLocalStorage } from "node:async_hooks";
5110
5114
 
@@ -8496,14 +8500,22 @@ function dbosLifecycleState() {
8496
8500
  function isMemoizedBackendUsable(backend) {
8497
8501
  return !backend.persistent || dbosLifecycleState() === "ready";
8498
8502
  }
8499
- function getDurableBackend() {
8500
- const owner = getDurableBackendProcessOwner();
8501
- const memoized = owner.initializedBackend !== undefined && isMemoizedBackendUsable(owner.initializedBackend) ? owner.initializedBackend : undefined;
8502
- const backend = owner.injectedBackend ?? memoized ?? getReadyDbosBackendSync();
8503
+ function getDurableBackend2() {
8504
+ const backend = getAvailableDurableBackend2();
8503
8505
  if (backend === undefined)
8504
8506
  throw new DbosNotReadyError;
8505
8507
  return backend;
8506
8508
  }
8509
+ function getAvailableDurableBackend2() {
8510
+ const owner = getDurableBackendProcessOwner();
8511
+ const memoized = owner.initializedBackend !== undefined && isMemoizedBackendUsable(owner.initializedBackend) ? owner.initializedBackend : undefined;
8512
+ return owner.injectedBackend ?? memoized ?? getReadyDbosBackendSync();
8513
+ }
8514
+ // dist/builtin/workflows/src/shared/workflow-artifacts.ts
8515
+ import { randomUUID as randomUUID3 } from "node:crypto";
8516
+ import { mkdir as mkdir2, readdir as readdir2, rm as rm2, stat } from "node:fs/promises";
8517
+ import { dirname as dirname4, join as join5 } from "node:path";
8518
+ import { getAgentDir, getEnvValue } from "@bastani/atomic";
8507
8519
 
8508
8520
  // dist/builtin/workflows/src/shared/pending-stage-delivery.ts
8509
8521
  var PENDING_STAGE_MESSAGE_LIMIT = 50;
@@ -8638,11 +8650,29 @@ function recordPendingStageMessageDeliveries(messages, runId, messageId, records
8638
8650
  if (additions.length === 0)
8639
8651
  return messages;
8640
8652
  const deliveries = [...entry.deliveries ?? [], ...additions];
8641
- const next = { ...entry, deliveries, deliveryCount: deliveries.length };
8653
+ const next = {
8654
+ ...entry,
8655
+ deliveries,
8656
+ deliveryCount: (entry.deliveryCount ?? entry.deliveries?.length ?? 0) + additions.length
8657
+ };
8642
8658
  const result = [...messages];
8643
8659
  result[index] = next;
8644
8660
  return result;
8645
8661
  }
8662
+ function compactStickyStageMessageDeliveries(messages, runs) {
8663
+ const finished = new Set(runs.flatMap((run) => run.stages.filter((stage) => stage.status === "completed" || stage.status === "skipped").map((stage) => JSON.stringify([run.id, stage.id]))));
8664
+ let changed = false;
8665
+ const next = messages.map((entry) => {
8666
+ if (entry.sticky !== true || entry.deliveries === undefined)
8667
+ return entry;
8668
+ const deliveries = entry.deliveries.filter((delivery) => !finished.has(JSON.stringify([delivery.runId, delivery.stageId])));
8669
+ if (deliveries.length === entry.deliveries.length)
8670
+ return entry;
8671
+ changed = true;
8672
+ return { ...entry, deliveries, deliveryCount: entry.deliveryCount ?? entry.deliveries.length };
8673
+ });
8674
+ return changed ? next : messages;
8675
+ }
8646
8676
  function settleStickyPendingStageMessageDelivered(messages, runId, messageId, settledAt) {
8647
8677
  const index = messages.findIndex((entry) => entry.runId === runId && entry.id === messageId && entry.sticky === true && entry.status === "queued" && (entry.deliveryCount ?? 0) > 0);
8648
8678
  if (index < 0)
@@ -8782,7 +8812,7 @@ function createSessionScopedSingleton(key, createLocal) {
8782
8812
  const target = sessionScopedExtensionState(scope, key, () => {
8783
8813
  targetCreated = true;
8784
8814
  if (shared.localClaimed)
8785
- return createLocal();
8815
+ return (options?.create ?? createLocal)();
8786
8816
  shared.localClaimed = true;
8787
8817
  return shared.local;
8788
8818
  });
@@ -9179,6 +9209,44 @@ function deepFreezeGraphValue(value) {
9179
9209
  // dist/builtin/workflows/src/shared/workflow-observation-runtime.ts
9180
9210
  import { randomUUID as randomUUID2 } from "node:crypto";
9181
9211
 
9212
+ // dist/builtin/workflows/src/shared/workflow-run-ownership.ts
9213
+ function authoritativeWorkflowChildRunId(stage) {
9214
+ if (stage === undefined || stage.status === "failed" || stage.status === "skipped") {
9215
+ return;
9216
+ }
9217
+ if (stage.status === "completed") {
9218
+ return stage.workflowChild?.runId ?? stage.workflowChildRun?.runId;
9219
+ }
9220
+ return stage.workflowChildRun?.runId;
9221
+ }
9222
+ function reciprocalWorkflowRootRunId(runById, runId) {
9223
+ const visited = new Set;
9224
+ const declaredRoots = [];
9225
+ let current = runById.get(runId);
9226
+ while (current !== undefined) {
9227
+ const currentId = current.id;
9228
+ if (visited.has(currentId))
9229
+ return;
9230
+ visited.add(currentId);
9231
+ if (current.rootRunId !== undefined)
9232
+ declaredRoots.push(current.rootRunId);
9233
+ const parentRunId = current.parentRunId;
9234
+ const parentStageId = current.parentStageId;
9235
+ if (parentRunId === undefined !== (parentStageId === undefined))
9236
+ return;
9237
+ if (parentRunId === undefined || parentStageId === undefined) {
9238
+ return declaredRoots.every((declared) => declared === currentId) ? currentId : undefined;
9239
+ }
9240
+ const parent = runById.get(parentRunId);
9241
+ const boundary = parent?.stages.find((stage) => stage.id === parentStageId);
9242
+ if (parent === undefined || authoritativeWorkflowChildRunId(boundary) !== currentId) {
9243
+ return;
9244
+ }
9245
+ current = parent;
9246
+ }
9247
+ return;
9248
+ }
9249
+
9182
9250
  // dist/builtin/workflows/src/shared/workflow-activity.ts
9183
9251
  function workflowActivityNodeKey(runId, nodeId) {
9184
9252
  return `${runId}:${nodeId}`;
@@ -9538,6 +9606,252 @@ function createStoreContext(state = createStoreState()) {
9538
9606
  };
9539
9607
  }
9540
9608
 
9609
+ // dist/builtin/workflows/src/durable/prompt-reservations.ts
9610
+ function durablePromptScope(backend, workflowId) {
9611
+ return backend.promptReservationScope(workflowId);
9612
+ }
9613
+ function claimDurablePromptToken(backend, workflowId, reservationId) {
9614
+ return backend.pendingPromptToken(workflowId, reservationId);
9615
+ }
9616
+ function reserveDurablePrompt(backend, workflowId, reservationId) {
9617
+ return backend.reservePendingPrompt(workflowId, reservationId);
9618
+ }
9619
+ function releaseDurablePrompt(backend, workflowId, reservationId, token) {
9620
+ backend.releasePendingPrompt(workflowId, reservationId, token);
9621
+ }
9622
+
9623
+ // dist/builtin/workflows/src/durable/scoped-backend.ts
9624
+ class ScopedDurableBackend {
9625
+ persistent;
9626
+ inner;
9627
+ scope;
9628
+ constructor(inner, scope) {
9629
+ this.inner = inner;
9630
+ this.scope = scope;
9631
+ this.persistent = inner.persistent;
9632
+ }
9633
+ async archivePendingStageMessage(_workflowId, entry) {
9634
+ await this.inner.archivePendingStageMessage?.(this.scope.rootWorkflowId, entry);
9635
+ }
9636
+ async readSettledPendingStageMessage(workflowId, messageId, logicalRunId = workflowId) {
9637
+ return this.inner.readSettledPendingStageMessage?.(this.scope.rootWorkflowId, messageId, logicalRunId);
9638
+ }
9639
+ getPendingStageMessageDeliveryCount(workflowId, messageId, logicalRunId = workflowId) {
9640
+ return this.inner.getPendingStageMessageDeliveryCount?.(this.scope.rootWorkflowId, messageId, logicalRunId) ?? 0;
9641
+ }
9642
+ async readPendingStageMessageDeliveryCount(workflowId, messageId, logicalRunId = workflowId) {
9643
+ return this.inner.readPendingStageMessageDeliveryCount === undefined ? this.getPendingStageMessageDeliveryCount(workflowId, messageId, logicalRunId) : await this.inner.readPendingStageMessageDeliveryCount(this.scope.rootWorkflowId, messageId, logicalRunId);
9644
+ }
9645
+ async archivePendingStageDeliveryReceipt(_workflowId, messageId, delivery, accounting) {
9646
+ await this.inner.archivePendingStageDeliveryReceipt?.(this.scope.rootWorkflowId, messageId, delivery, accounting);
9647
+ }
9648
+ hasCachedPendingStageDeliveryReceipt(workflowId, messageId, delivery, anySession = false, logicalRunId = workflowId) {
9649
+ return this.inner.hasCachedPendingStageDeliveryReceipt?.(this.scope.rootWorkflowId, messageId, delivery, anySession, logicalRunId) ?? false;
9650
+ }
9651
+ async hasPendingStageDeliveryReceipt(workflowId, messageId, delivery, logicalRunId = workflowId) {
9652
+ return await this.inner.hasPendingStageDeliveryReceipt?.(this.scope.rootWorkflowId, messageId, delivery, logicalRunId) ?? false;
9653
+ }
9654
+ registerWorkflow(_handle) {}
9655
+ persistPendingStageMessages(workflowId, messages, logicalRunId = workflowId) {
9656
+ return this.inner.persistPendingStageMessages(this.scope.rootWorkflowId, messages, logicalRunId);
9657
+ }
9658
+ recordCheckpoint(checkpoint) {
9659
+ this.inner.recordCheckpoint(this.remap(checkpoint));
9660
+ }
9661
+ async recordCheckpointAsync(checkpoint, options) {
9662
+ await this.inner.recordCheckpointAsync(this.remap(checkpoint), options);
9663
+ }
9664
+ async recordAdditiveCheckpointBestEffort(checkpoint) {
9665
+ return await this.inner.recordAdditiveCheckpointBestEffort(this.remap(checkpoint));
9666
+ }
9667
+ flush(workflowId) {
9668
+ return workflowId === undefined ? this.inner.flush() : this.inner.flush(this.scope.rootWorkflowId);
9669
+ }
9670
+ getToolOutput(_workflowId, argsHash) {
9671
+ return this.inner.getToolOutput(this.scope.rootWorkflowId, this.scopeKey(argsHash));
9672
+ }
9673
+ getToolCheckpoint(_workflowId, argsHash) {
9674
+ return this.inner.getToolCheckpoint(this.scope.rootWorkflowId, this.scopeKey(argsHash));
9675
+ }
9676
+ getUiResponse(_workflowId, promptHash) {
9677
+ return this.inner.getUiResponse(this.scope.rootWorkflowId, this.scopeKey(promptHash));
9678
+ }
9679
+ getStageOutput(_workflowId, replayKey) {
9680
+ return this.inner.getStageOutput(this.scope.rootWorkflowId, this.scopeKey(replayKey));
9681
+ }
9682
+ getStageSession(_workflowId, replayKey) {
9683
+ return this.inner.getStageSession(this.scope.rootWorkflowId, this.scopeKey(replayKey));
9684
+ }
9685
+ listCheckpoints(workflowId) {
9686
+ const prefix = `${this.scope.scopePrefix}:`;
9687
+ return this.inner.listCheckpoints(this.scope.rootWorkflowId).filter((checkpoint) => checkpointHasPrefix(checkpoint, prefix)).map((checkpoint) => localCheckpoint(checkpoint, workflowId, prefix));
9688
+ }
9689
+ getWorkflow(_workflowId) {
9690
+ return;
9691
+ }
9692
+ getLoadableWorkflow(_workflowId) {
9693
+ return;
9694
+ }
9695
+ setWorkflowStatus(_workflowId, _status, _pendingPrompts, _resumable) {}
9696
+ async transitionWorkflowStatus(_workflowId, _expectedStatuses, _status, _pendingPrompts, _resumable) {
9697
+ return false;
9698
+ }
9699
+ adjustPendingPrompts(_workflowId, delta) {
9700
+ this.inner.adjustPendingPrompts(this.scope.rootWorkflowId, delta);
9701
+ }
9702
+ promptReservationScope(_workflowId) {
9703
+ return this.effectivePromptScope();
9704
+ }
9705
+ pendingPromptToken(_workflowId, reservationId) {
9706
+ return claimDurablePromptToken(this.inner, this.scope.rootWorkflowId, reservationId);
9707
+ }
9708
+ reservePendingPrompt(_workflowId, reservationId) {
9709
+ return reserveDurablePrompt(this.inner, this.scope.rootWorkflowId, reservationId);
9710
+ }
9711
+ releasePendingPrompt(_workflowId, reservationId, token) {
9712
+ releaseDurablePrompt(this.inner, this.scope.rootWorkflowId, reservationId, token);
9713
+ }
9714
+ listResumableWorkflows() {
9715
+ return [];
9716
+ }
9717
+ listCompletedWorkflows() {
9718
+ return [];
9719
+ }
9720
+ async prepareWorkflowCatalog() {
9721
+ return { resumable: [], completed: [] };
9722
+ }
9723
+ toMetadata(_workflowId) {
9724
+ return;
9725
+ }
9726
+ async deleteWorkflow(_workflowId) {}
9727
+ async deleteWorkflowIfInactive(_workflowId) {
9728
+ return { ok: false, reason: "not_found" };
9729
+ }
9730
+ isWorkflowLoadable(_workflowId) {
9731
+ return false;
9732
+ }
9733
+ reset() {}
9734
+ hydrateWorkflow(_workflowId) {
9735
+ return Promise.resolve();
9736
+ }
9737
+ hydrateWorkflowForInspection(_workflowId) {
9738
+ return Promise.resolve({ kind: "absent" });
9739
+ }
9740
+ hydrateResumableWorkflows() {
9741
+ return Promise.resolve();
9742
+ }
9743
+ effectivePromptScope() {
9744
+ const parent = durablePromptScope(this.inner, this.scope.rootWorkflowId);
9745
+ const scope = parent.scope === "root" ? this.scope.scopePrefix : `${parent.scope}:${this.scope.scopePrefix}`;
9746
+ return {
9747
+ rootWorkflowId: parent.rootWorkflowId,
9748
+ scope
9749
+ };
9750
+ }
9751
+ scopeKey(key) {
9752
+ return `${this.scope.scopePrefix}:${key}`;
9753
+ }
9754
+ remap(checkpoint) {
9755
+ const workflowId = this.scope.rootWorkflowId;
9756
+ if (checkpoint.kind === "tool") {
9757
+ return {
9758
+ ...checkpoint,
9759
+ workflowId,
9760
+ checkpointId: this.scopeKey(checkpoint.checkpointId),
9761
+ argsHash: this.scopeKey(checkpoint.argsHash)
9762
+ };
9763
+ }
9764
+ if (checkpoint.kind === "ui") {
9765
+ return {
9766
+ ...checkpoint,
9767
+ workflowId,
9768
+ checkpointId: this.scopeKey(checkpoint.checkpointId),
9769
+ promptHash: this.scopeKey(checkpoint.promptHash)
9770
+ };
9771
+ }
9772
+ return {
9773
+ ...checkpoint,
9774
+ workflowId,
9775
+ checkpointId: this.scopeKey(checkpoint.checkpointId),
9776
+ replayKey: this.scopeKey(checkpoint.replayKey),
9777
+ ...remappedBoundaryScope(checkpoint, this.scopeKey(checkpoint.topology?.boundary?.replayScope ?? ""))
9778
+ };
9779
+ }
9780
+ }
9781
+ function checkpointHasPrefix(checkpoint, prefix) {
9782
+ if (!checkpoint.checkpointId.startsWith(prefix))
9783
+ return false;
9784
+ if (checkpoint.kind === "tool")
9785
+ return checkpoint.argsHash.startsWith(prefix);
9786
+ if (checkpoint.kind === "ui")
9787
+ return checkpoint.promptHash.startsWith(prefix);
9788
+ return checkpoint.replayKey.startsWith(prefix);
9789
+ }
9790
+ function localCheckpoint(checkpoint, workflowId, prefix) {
9791
+ const checkpointId = checkpoint.checkpointId.slice(prefix.length);
9792
+ if (checkpoint.kind === "tool") {
9793
+ return { ...checkpoint, workflowId, checkpointId, argsHash: checkpoint.argsHash.slice(prefix.length) };
9794
+ }
9795
+ if (checkpoint.kind === "ui") {
9796
+ return { ...checkpoint, workflowId, checkpointId, promptHash: checkpoint.promptHash.slice(prefix.length) };
9797
+ }
9798
+ const replayKey = checkpoint.replayKey.slice(prefix.length);
9799
+ const replayScope = stripOnePrefix(checkpoint.topology?.boundary?.replayScope, prefix);
9800
+ return {
9801
+ ...checkpoint,
9802
+ workflowId,
9803
+ checkpointId,
9804
+ replayKey,
9805
+ ...remappedBoundaryScope(checkpoint, replayScope)
9806
+ };
9807
+ }
9808
+ function remappedBoundaryScope(checkpoint, replayScope) {
9809
+ const topology = checkpoint.topology;
9810
+ if (topology?.boundary === undefined || replayScope === undefined)
9811
+ return {};
9812
+ return {
9813
+ topology: {
9814
+ ...topology,
9815
+ boundary: { ...topology.boundary, replayScope }
9816
+ }
9817
+ };
9818
+ }
9819
+ function stripOnePrefix(value, prefix) {
9820
+ if (value === undefined || !value.startsWith(prefix))
9821
+ return value;
9822
+ return value.slice(prefix.length);
9823
+ }
9824
+
9825
+ // dist/builtin/workflows/src/durable/run-owner-backend.ts
9826
+ function durableRootRunIdForRun(runs, runId) {
9827
+ return reciprocalWorkflowRootRunId(new Map(runs.map((run) => [run.id, run])), runId);
9828
+ }
9829
+ function durableBackendForRun(backend, runs, runId) {
9830
+ const rootRunId = durableRootRunIdForRun(runs, runId);
9831
+ if (rootRunId === undefined)
9832
+ return;
9833
+ const runById = new Map(runs.map((run) => [run.id, run]));
9834
+ if (rootRunId === runId)
9835
+ return backend;
9836
+ const scopes = [];
9837
+ let current = runById.get(runId);
9838
+ while (current !== undefined && current.id !== rootRunId) {
9839
+ const parent = current.parentRunId === undefined ? undefined : runById.get(current.parentRunId);
9840
+ const boundary = parent?.stages.find((stage) => stage.id === current?.parentStageId);
9841
+ if (parent === undefined || boundary?.replayKey === undefined)
9842
+ return;
9843
+ scopes.push(boundary.replayKey);
9844
+ current = parent;
9845
+ }
9846
+ if (current?.id !== rootRunId)
9847
+ return;
9848
+ let view = backend;
9849
+ for (const scopePrefix of scopes.reverse()) {
9850
+ view = new ScopedDurableBackend(view, { rootWorkflowId: rootRunId, scopePrefix });
9851
+ }
9852
+ return view;
9853
+ }
9854
+
9541
9855
  // dist/builtin/workflows/src/shared/store-pending-stage-delivery-methods.ts
9542
9856
  function createPendingStageDeliveryStoreMethods(context) {
9543
9857
  const transitions = new Map;
@@ -9565,13 +9879,14 @@ function createPendingStageDeliveryStoreMethods(context) {
9565
9879
  if (run === undefined)
9566
9880
  return;
9567
9881
  const stageIdentity = resolvePendingStageIdentity(run, input.stageKey);
9568
- const result = queueStageMessage(run.pendingStageMessages ?? [], input, senderGroup, runGroup, stageIdentity);
9882
+ const receipt = await backend.readSettledPendingStageMessage?.(input.runId, input.message.id);
9883
+ const result = queueStageMessage(receipt === undefined ? run.pendingStageMessages ?? [] : [...run.pendingStageMessages ?? [], receipt], input, senderGroup, runGroup, stageIdentity);
9569
9884
  if (result.ok && !result.deduplicated) {
9570
- await persistTransition(backend, input.runId, result.messages);
9571
- run.pendingStageMessages = [...result.messages];
9885
+ const messages = await persistTransition(backend, input.runId, result.messages, context);
9886
+ run.pendingStageMessages = [...messages];
9572
9887
  context.bumpAndNotify();
9573
9888
  }
9574
- return result;
9889
+ return result.ok ? { ...result, messages: run.pendingStageMessages ?? [] } : result;
9575
9890
  });
9576
9891
  },
9577
9892
  async validateLiveStageMessage(input) {
@@ -9579,7 +9894,11 @@ function createPendingStageDeliveryStoreMethods(context) {
9579
9894
  const run = context.findRun(input.runId);
9580
9895
  if (run === undefined)
9581
9896
  return;
9582
- const result = queueStageMessage(run.pendingStageMessages ?? [], input, undefined, undefined, resolvePendingStageIdentity(run, input.stageKey));
9897
+ const { getAvailableDurableBackend } = await import("./chunk-p6jagvyf.js");
9898
+ const availableBackend = getAvailableDurableBackend();
9899
+ const backend = availableBackend === undefined ? undefined : durableBackendForRun(availableBackend, context.state.runs, input.runId);
9900
+ const receipt = await backend?.readSettledPendingStageMessage?.(input.runId, input.message.id);
9901
+ const result = queueStageMessage(receipt === undefined ? run.pendingStageMessages ?? [] : [...run.pendingStageMessages ?? [], receipt], input, undefined, undefined, resolvePendingStageIdentity(run, input.stageKey));
9583
9902
  if (!result.ok) {
9584
9903
  return result.reason === "message_id_conflict" ? { outcome: "message_id_conflict", messageId: result.messageId } : { outcome: "forward" };
9585
9904
  }
@@ -9609,8 +9928,8 @@ function createPendingStageDeliveryStoreMethods(context) {
9609
9928
  const next = markPendingStageMessageDelivered(current, runId, stageKey, messageId, deliveredAt, resolvePendingStageIdentity(run, stageKey));
9610
9929
  if (next === current)
9611
9930
  return false;
9612
- await persistTransition(backend, runId, next);
9613
- run.pendingStageMessages = [...next];
9931
+ const messages = await persistTransition(backend, runId, next, context);
9932
+ run.pendingStageMessages = [...messages];
9614
9933
  context.bumpAndNotify();
9615
9934
  return true;
9616
9935
  });
@@ -9624,8 +9943,8 @@ function createPendingStageDeliveryStoreMethods(context) {
9624
9943
  const next = markPendingStageMessageUndeliverable(current, runId, stageKey, messageId, reason, resolvePendingStageIdentity(run, stageKey));
9625
9944
  if (next === current)
9626
9945
  return false;
9627
- await persistTransition(backend, runId, next);
9628
- run.pendingStageMessages = [...next];
9946
+ const messages = await persistTransition(backend, runId, next, context);
9947
+ run.pendingStageMessages = [...messages];
9629
9948
  context.bumpAndNotify();
9630
9949
  return true;
9631
9950
  });
@@ -9639,8 +9958,8 @@ function createPendingStageDeliveryStoreMethods(context) {
9639
9958
  const next = markPendingStageMessageUndeliverableNotified(current, runId, stageKey, messageId, notificationId, notifiedAt);
9640
9959
  if (next === current)
9641
9960
  return false;
9642
- await persistTransition(backend, runId, next);
9643
- run.pendingStageMessages = [...next];
9961
+ const messages = await persistTransition(backend, runId, next, context);
9962
+ run.pendingStageMessages = [...messages];
9644
9963
  context.bumpAndNotify();
9645
9964
  return true;
9646
9965
  });
@@ -9650,13 +9969,14 @@ function createPendingStageDeliveryStoreMethods(context) {
9650
9969
  const run = context.findRun(input.runId);
9651
9970
  if (run === undefined)
9652
9971
  return;
9653
- const result = queueStickyStageMessage(run.pendingStageMessages ?? [], input, senderGroup, runGroup);
9972
+ const receipt = await backend.readSettledPendingStageMessage?.(input.runId, input.message.id);
9973
+ const result = queueStickyStageMessage(receipt === undefined ? run.pendingStageMessages ?? [] : [...run.pendingStageMessages ?? [], receipt], input, senderGroup, runGroup);
9654
9974
  if (result.ok && !result.deduplicated) {
9655
- await persistTransition(backend, input.runId, result.messages);
9656
- run.pendingStageMessages = [...result.messages];
9975
+ const messages = await persistTransition(backend, input.runId, result.messages, context);
9976
+ run.pendingStageMessages = [...messages];
9657
9977
  context.bumpAndNotify();
9658
9978
  }
9659
- return result;
9979
+ return result.ok ? { ...result, messages: run.pendingStageMessages ?? [] } : result;
9660
9980
  });
9661
9981
  },
9662
9982
  async recordPendingStageMessageDeliveries(runId, messageId, records, deliveredAt, backend) {
@@ -9664,12 +9984,26 @@ function createPendingStageDeliveryStoreMethods(context) {
9664
9984
  const run = context.findRun(runId);
9665
9985
  if (run === undefined)
9666
9986
  return false;
9667
- const current = run.pendingStageMessages ?? [];
9668
- const next = recordPendingStageMessageDeliveries(current, runId, messageId, records, deliveredAt);
9987
+ if (records.length === 0)
9988
+ await backend.readPendingStageMessageDeliveryCount?.(runId, messageId, runId);
9989
+ let current = reconcileDeliveryCounts(backend, runId, run.pendingStageMessages ?? []);
9990
+ const unconfirmedRecords = [];
9991
+ for (const record of records) {
9992
+ const contextReceipt = record.admission === "transport" ? { ...record, admission: "context" } : undefined;
9993
+ if (!await backend.hasPendingStageDeliveryReceipt?.(runId, messageId, record) && (contextReceipt === undefined || !current.find((entry) => entry.id === messageId)?.deliveries?.some((delivery) => delivery.runId === record.runId && delivery.stageId === record.stageId && delivery.sessionId === record.sessionId && delivery.admission === "context") && !await backend.hasPendingStageDeliveryReceipt?.(runId, messageId, contextReceipt))) {
9994
+ unconfirmedRecords.push(record);
9995
+ }
9996
+ }
9997
+ current = reconcileDeliveryCounts(backend, runId, current);
9998
+ if (current !== run.pendingStageMessages) {
9999
+ run.pendingStageMessages = [...current];
10000
+ context.bumpAndNotify();
10001
+ }
10002
+ const next = recordPendingStageMessageDeliveries(current, runId, messageId, unconfirmedRecords, deliveredAt);
9669
10003
  if (next === current)
9670
10004
  return false;
9671
- await persistTransition(backend, runId, next);
9672
- run.pendingStageMessages = [...next];
10005
+ const messages = await persistTransition(backend, runId, next, context);
10006
+ run.pendingStageMessages = [...messages];
9673
10007
  context.bumpAndNotify();
9674
10008
  return true;
9675
10009
  });
@@ -9679,12 +10013,13 @@ function createPendingStageDeliveryStoreMethods(context) {
9679
10013
  const run = context.findRun(runId);
9680
10014
  if (run === undefined)
9681
10015
  return false;
9682
- const current = run.pendingStageMessages ?? [];
10016
+ await backend.readPendingStageMessageDeliveryCount?.(runId, messageId, runId);
10017
+ const current = reconcileDeliveryCounts(backend, runId, run.pendingStageMessages ?? []);
9683
10018
  const next = settleStickyPendingStageMessageDelivered(current, runId, messageId, settledAt);
9684
10019
  if (next === current)
9685
10020
  return false;
9686
- await persistTransition(backend, runId, next);
9687
- run.pendingStageMessages = [...next];
10021
+ const messages = await persistTransition(backend, runId, next, context);
10022
+ run.pendingStageMessages = [...messages];
9688
10023
  context.bumpAndNotify();
9689
10024
  return true;
9690
10025
  });
@@ -9703,11 +10038,75 @@ function resolvePendingStageIdentity(run, stageKey) {
9703
10038
  aliases: stage.id === stage.name ? [stage.id] : [stage.id, stage.name]
9704
10039
  };
9705
10040
  }
9706
- async function persistTransition(backend, runId, messages) {
9707
- if (!await backend.persistPendingStageMessages(runId, messages)) {
9708
- throw new Error(`atomic-workflows: durable workflow ${runId} is unavailable for pending-stage persistence`);
10041
+ async function persistTransition(backend, runId, messages, context) {
10042
+ let retained = reconcileDeliveryCounts(backend, runId, messages);
10043
+ try {
10044
+ if (backend.archivePendingStageDeliveryReceipt !== undefined && backend.hasPendingStageDeliveryReceipt !== undefined) {
10045
+ const compacted = [];
10046
+ for (const entry of retained) {
10047
+ if (entry.sticky !== true || entry.deliveries === undefined) {
10048
+ compacted.push(entry);
10049
+ continue;
10050
+ }
10051
+ const latest = new Map;
10052
+ entry.deliveries.forEach((delivery, index) => {
10053
+ latest.set(JSON.stringify([delivery.runId, delivery.stageId, delivery.admission]), index);
10054
+ });
10055
+ const deliveries = [];
10056
+ let archivedThrough = -1;
10057
+ for (let index = 0;index < entry.deliveries.length; index++) {
10058
+ const delivery = entry.deliveries[index];
10059
+ const stage = context.state.runs.find((run) => run.id === delivery.runId)?.stages.find((stage) => stage.id === delivery.stageId);
10060
+ if (entry.status !== "queued" || stage?.status === "completed" || stage?.status === "skipped" || stage?.status === "failed" || latest.get(JSON.stringify([delivery.runId, delivery.stageId, delivery.admission])) !== index && delivery.sessionId !== undefined) {
10061
+ while (archivedThrough < index) {
10062
+ const prefixIndex = archivedThrough + 1;
10063
+ await backend.archivePendingStageDeliveryReceipt(runId, entry.id, entry.deliveries[prefixIndex], {
10064
+ messageRunId: entry.runId,
10065
+ deliveryCount: (entry.deliveryCount ?? entry.deliveries.length) - entry.deliveries.length + prefixIndex + 1
10066
+ });
10067
+ archivedThrough = prefixIndex;
10068
+ }
10069
+ } else {
10070
+ deliveries.push(delivery);
10071
+ }
10072
+ }
10073
+ compacted.push(deliveries.length === entry.deliveries.length ? entry : { ...entry, deliveries });
10074
+ }
10075
+ retained = compacted;
10076
+ }
10077
+ retained = compactStickyStageMessageDeliveries(retained, context.state.runs);
10078
+ if (backend.archivePendingStageMessage !== undefined && backend.readSettledPendingStageMessage !== undefined) {
10079
+ retained = await retainPendingStageMessages(retained, (entry) => backend.archivePendingStageMessage(runId, entry));
10080
+ }
10081
+ if (!await backend.persistPendingStageMessages(runId, retained)) {
10082
+ throw new Error(`atomic-workflows: durable workflow ${runId} is unavailable for pending-stage persistence`);
10083
+ }
10084
+ return retained;
10085
+ } finally {
10086
+ const run = context.findRun(runId);
10087
+ if (run !== undefined) {
10088
+ const current = run.pendingStageMessages ?? [];
10089
+ const recovered = reconcileDeliveryCounts(backend, runId, current);
10090
+ if (recovered !== current) {
10091
+ run.pendingStageMessages = [...recovered];
10092
+ context.bumpAndNotify();
10093
+ }
10094
+ }
9709
10095
  }
9710
10096
  }
10097
+ function reconcileDeliveryCounts(backend, runId, messages) {
10098
+ let changed = false;
10099
+ const recovered = messages.map((entry) => {
10100
+ if (entry.sticky !== true)
10101
+ return entry;
10102
+ const count = backend.getPendingStageMessageDeliveryCount?.(runId, entry.id, entry.runId) ?? 0;
10103
+ if (count <= (entry.deliveryCount ?? entry.deliveries?.length ?? 0))
10104
+ return entry;
10105
+ changed = true;
10106
+ return { ...entry, deliveryCount: count };
10107
+ });
10108
+ return changed ? recovered : messages;
10109
+ }
9711
10110
 
9712
10111
  // dist/builtin/workflows/src/shared/store-prompt-methods.ts
9713
10112
  function createPromptStoreMethods(context) {
@@ -10728,7 +11127,7 @@ function createWorkflowArtifactRunStateResolver() {
10728
11127
  let backend;
10729
11128
  let backendReady = true;
10730
11129
  try {
10731
- backend = getDurableBackend();
11130
+ backend = getDurableBackend2();
10732
11131
  } catch {
10733
11132
  backendReady = false;
10734
11133
  }
@@ -10759,7 +11158,7 @@ function createWorkflowArtifactRunStateResolver() {
10759
11158
  async function deleteTerminalDurableEntry(runId) {
10760
11159
  let backend;
10761
11160
  try {
10762
- backend = getDurableBackend();
11161
+ backend = getDurableBackend2();
10763
11162
  } catch {
10764
11163
  return false;
10765
11164
  }
@@ -11134,4 +11533,4 @@ async function reverify_consolidated_batch(ctx, input) {
11134
11533
  return apply_reverify_results(input.batch, audits);
11135
11534
  }
11136
11535
 
11137
- export { workflowArtifactDirectoryPath, ensureWorkflowArtifactDirectory, createWorkflowArtifactDirectory, record_convergence, convergence_escalation_evidence, finalActionRemaining, stopReviewLoopContradictions, contradictedStopReviewLoopGap, consolidateFindingsBatch, parseFailureDiagnostics, reviewerFailureText, summarizeReviewConvergence, reverify_consolidated_batch };
11536
+ export { getDurableBackend2, getAvailableDurableBackend2, workflowArtifactDirectoryPath, ensureWorkflowArtifactDirectory, createWorkflowArtifactDirectory, record_convergence, convergence_escalation_evidence, finalActionRemaining, stopReviewLoopContradictions, contradictedStopReviewLoopGap, consolidateFindingsBatch, parseFailureDiagnostics, reviewerFailureText, summarizeReviewConvergence, reverify_consolidated_batch };
@@ -0,0 +1,8 @@
1
+ import {
2
+ getDurableBackend2,
3
+ getAvailableDurableBackend2
4
+ } from "./chunk-p3xmajmj.js";
5
+ export {
6
+ getAvailableDurableBackend2 as getAvailableDurableBackend,
7
+ getDurableBackend2 as getDurableBackend
8
+ };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  goal_default
3
- } from "./chunk-gw7rghda.js";
4
- import"./chunk-9bhs02gm.js";
3
+ } from "./chunk-aqv8ny38.js";
4
+ import"./chunk-p3xmajmj.js";
5
5
  import"./chunk-2377r57g.js";
6
6
  import"./chunk-z0d03ktm.js";
7
7
  import"./chunk-n1910xc4.js";
@@ -14,11 +14,11 @@ import {
14
14
  import {
15
15
  generate_and_filter_default
16
16
  } from "./chunk-kb7s3gx2.js";
17
- import"./chunk-9bhs02gm.js";
18
- import"./chunk-z0d03ktm.js";
19
17
  import {
20
18
  goal_default
21
- } from "./chunk-gw7rghda.js";
19
+ } from "./chunk-aqv8ny38.js";
20
+ import"./chunk-p3xmajmj.js";
21
+ import"./chunk-z0d03ktm.js";
22
22
  import {
23
23
  open_claude_design_default
24
24
  } from "./chunk-nkj4qhj6.js";
@@ -27,7 +27,7 @@ import {
27
27
  } from "./chunk-94f8zfz1.js";
28
28
  import {
29
29
  ralph_default
30
- } from "./chunk-gts8wgjr.js";
30
+ } from "./chunk-br4ac9a3.js";
31
31
  import {
32
32
  tournament_default
33
33
  } from "./chunk-wf876n16.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ralph_default
3
- } from "./chunk-gts8wgjr.js";
4
- import"./chunk-9bhs02gm.js";
3
+ } from "./chunk-br4ac9a3.js";
4
+ import"./chunk-p3xmajmj.js";
5
5
  import"./chunk-2377r57g.js";
6
6
  import"./chunk-z0d03ktm.js";
7
7
  import"./chunk-n1910xc4.js";