@bastani/atomic 0.9.38-alpha.6 → 0.9.38-alpha.8

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 (256) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/dist/builtin/intercom/package.json +2 -2
  3. package/dist/builtin/mcp/package.json +1 -1
  4. package/dist/builtin/subagents/CHANGELOG.md +12 -0
  5. package/dist/builtin/subagents/README.md +9 -4
  6. package/dist/builtin/subagents/package.json +3 -3
  7. package/dist/builtin/subagents/src/extension/index.bundle.mjs +143 -134
  8. package/dist/builtin/web-access/package.json +2 -2
  9. package/dist/builtin/workflows/CHANGELOG.md +25 -0
  10. package/dist/builtin/workflows/builtin/{chunk-q7dx7kh7.js → chunk-85mx6wcf.js} +6 -6
  11. package/dist/builtin/workflows/builtin/{chunk-neszcj53.js → chunk-8kkv04hz.js} +15 -15
  12. package/dist/builtin/workflows/builtin/{chunk-g1a4hw0s.js → chunk-8x61e0s7.js} +13 -25
  13. package/dist/builtin/workflows/builtin/{chunk-2qgfyvzs.js → chunk-y45tkftg.js} +7 -7
  14. package/dist/builtin/workflows/builtin/goal.js +2 -2
  15. package/dist/builtin/workflows/builtin/index.js +4 -4
  16. package/dist/builtin/workflows/builtin/open-claude-design.js +1 -1
  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/durable/journal/internal.d.ts +0 -19
  20. package/dist/builtin/workflows/src/durable/journal/legacy-journal-tables.d.ts +42 -0
  21. package/dist/builtin/workflows/src/durable/journal/memory-run-journal.d.ts +3 -11
  22. package/dist/builtin/workflows/src/durable/journal/resolution.d.ts +15 -9
  23. package/dist/builtin/workflows/src/durable/journal/sql-run-journal.d.ts +3 -0
  24. package/dist/builtin/workflows/src/durable/journal/types.d.ts +3 -93
  25. package/dist/builtin/workflows/src/extension/index.bundle.mjs +1137 -748
  26. package/dist/builtin/workflows/src/index.js +709 -403
  27. package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +1 -1
  28. package/dist/cli/args.d.ts +2 -0
  29. package/dist/cli/args.d.ts.map +1 -1
  30. package/dist/cli/args.js +29 -3
  31. package/dist/cli/args.js.map +1 -1
  32. package/dist/cli/session-picker.d.ts +1 -1
  33. package/dist/cli/session-picker.d.ts.map +1 -1
  34. package/dist/cli/session-picker.js +2 -2
  35. package/dist/cli/session-picker.js.map +1 -1
  36. package/dist/core/agent-session-events.d.ts.map +1 -1
  37. package/dist/core/agent-session-events.js +6 -1
  38. package/dist/core/agent-session-events.js.map +1 -1
  39. package/dist/core/agent-session-runtime.d.ts +4 -0
  40. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  41. package/dist/core/agent-session-runtime.js +44 -4
  42. package/dist/core/agent-session-runtime.js.map +1 -1
  43. package/dist/core/agent-session-services.d.ts +1 -1
  44. package/dist/core/agent-session-services.d.ts.map +1 -1
  45. package/dist/core/agent-session-services.js +2 -2
  46. package/dist/core/agent-session-services.js.map +1 -1
  47. package/dist/core/compaction/branch-summarization.d.ts +1 -4
  48. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  49. package/dist/core/compaction/branch-summarization.js +0 -4
  50. package/dist/core/compaction/branch-summarization.js.map +1 -1
  51. package/dist/core/compaction/pi-summary-fallback.d.ts.map +1 -1
  52. package/dist/core/compaction/pi-summary-fallback.js +1 -3
  53. package/dist/core/compaction/pi-summary-fallback.js.map +1 -1
  54. package/dist/core/extensions/loader-api.js +1 -1
  55. package/dist/core/extensions/loader-api.js.map +1 -1
  56. package/dist/core/extensions/runner-context.d.ts.map +1 -1
  57. package/dist/core/extensions/runner-context.js +7 -1
  58. package/dist/core/extensions/runner-context.js.map +1 -1
  59. package/dist/core/fast-model-routing.js +1 -1
  60. package/dist/core/fast-model-routing.js.map +1 -1
  61. package/dist/core/model-config.d.ts +765 -0
  62. package/dist/core/model-config.d.ts.map +1 -1
  63. package/dist/core/model-config.js +46 -24
  64. package/dist/core/model-config.js.map +1 -1
  65. package/dist/core/model-resolver-defaults.js +1 -1
  66. package/dist/core/model-resolver-defaults.js.map +1 -1
  67. package/dist/core/resource-loader-reload.js +1 -1
  68. package/dist/core/resource-loader-reload.js.map +1 -1
  69. package/dist/core/resource-loader-types.d.ts +1 -1
  70. package/dist/core/resource-loader-types.d.ts.map +1 -1
  71. package/dist/core/resource-loader-types.js.map +1 -1
  72. package/dist/core/sdk-types.d.ts +4 -0
  73. package/dist/core/sdk-types.d.ts.map +1 -1
  74. package/dist/core/sdk-types.js.map +1 -1
  75. package/dist/core/sdk.d.ts +1 -1
  76. package/dist/core/sdk.d.ts.map +1 -1
  77. package/dist/core/sdk.js +48 -19
  78. package/dist/core/sdk.js.map +1 -1
  79. package/dist/core/session-lifecycle-work.d.ts +3 -0
  80. package/dist/core/session-lifecycle-work.d.ts.map +1 -1
  81. package/dist/core/session-lifecycle-work.js +2 -0
  82. package/dist/core/session-lifecycle-work.js.map +1 -1
  83. package/dist/core/session-manager-core.d.ts +7 -4
  84. package/dist/core/session-manager-core.d.ts.map +1 -1
  85. package/dist/core/session-manager-core.js +149 -41
  86. package/dist/core/session-manager-core.js.map +1 -1
  87. package/dist/core/session-manager-list.d.ts.map +1 -1
  88. package/dist/core/session-manager-list.js +7 -7
  89. package/dist/core/session-manager-list.js.map +1 -1
  90. package/dist/core/session-manager-storage.d.ts +2 -1
  91. package/dist/core/session-manager-storage.d.ts.map +1 -1
  92. package/dist/core/session-manager-storage.js +24 -9
  93. package/dist/core/session-manager-storage.js.map +1 -1
  94. package/dist/core/session-manager-types.d.ts +1 -1
  95. package/dist/core/session-manager-types.d.ts.map +1 -1
  96. package/dist/core/session-manager-types.js.map +1 -1
  97. package/dist/core/session-manager.d.ts +1 -1
  98. package/dist/core/session-manager.d.ts.map +1 -1
  99. package/dist/core/session-manager.js +1 -1
  100. package/dist/core/session-manager.js.map +1 -1
  101. package/dist/core/session-resume-args.d.ts +4 -0
  102. package/dist/core/session-resume-args.d.ts.map +1 -0
  103. package/dist/core/session-resume-args.js +9 -0
  104. package/dist/core/session-resume-args.js.map +1 -0
  105. package/dist/core/session-storage.d.ts +26 -0
  106. package/dist/core/session-storage.d.ts.map +1 -0
  107. package/dist/core/session-storage.js +171 -0
  108. package/dist/core/session-storage.js.map +1 -0
  109. package/dist/core/session-store-list.d.ts +4 -0
  110. package/dist/core/session-store-list.d.ts.map +1 -0
  111. package/dist/core/session-store-list.js +28 -0
  112. package/dist/core/session-store-list.js.map +1 -0
  113. package/dist/core/settings-manager-basic-accessors.d.ts +0 -1
  114. package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
  115. package/dist/core/settings-manager-basic-accessors.js +0 -5
  116. package/dist/core/settings-manager-basic-accessors.js.map +1 -1
  117. package/dist/core/settings-merge.d.ts.map +1 -1
  118. package/dist/core/settings-merge.js +5 -0
  119. package/dist/core/settings-merge.js.map +1 -1
  120. package/dist/core/settings-schema.d.ts +74 -3
  121. package/dist/core/settings-schema.d.ts.map +1 -1
  122. package/dist/core/settings-schema.js +28 -14
  123. package/dist/core/settings-schema.js.map +1 -1
  124. package/dist/core/storage/errors.d.ts +1 -0
  125. package/dist/core/storage/errors.d.ts.map +1 -1
  126. package/dist/core/storage/errors.js.map +1 -1
  127. package/dist/core/storage/index.d.ts +4 -0
  128. package/dist/core/storage/index.d.ts.map +1 -1
  129. package/dist/core/storage/index.js +3 -0
  130. package/dist/core/storage/index.js.map +1 -1
  131. package/dist/core/storage/provider.d.ts +58 -0
  132. package/dist/core/storage/provider.d.ts.map +1 -0
  133. package/dist/core/storage/provider.js +243 -0
  134. package/dist/core/storage/provider.js.map +1 -0
  135. package/dist/core/storage/run-journal.d.ts +93 -0
  136. package/dist/core/storage/run-journal.d.ts.map +1 -0
  137. package/dist/core/storage/run-journal.js +15 -0
  138. package/dist/core/storage/run-journal.js.map +1 -0
  139. package/dist/core/storage/selection.d.ts +16 -0
  140. package/dist/core/storage/selection.d.ts.map +1 -0
  141. package/dist/core/storage/selection.js +87 -0
  142. package/dist/core/storage/selection.js.map +1 -0
  143. package/dist/core/storage/session/jsonl-session-store.d.ts +9 -1
  144. package/dist/core/storage/session/jsonl-session-store.d.ts.map +1 -1
  145. package/dist/core/storage/session/jsonl-session-store.js +82 -44
  146. package/dist/core/storage/session/jsonl-session-store.js.map +1 -1
  147. package/dist/core/storage/session/legacy-format.d.ts +20 -0
  148. package/dist/core/storage/session/legacy-format.d.ts.map +1 -0
  149. package/dist/core/storage/session/legacy-format.js +89 -0
  150. package/dist/core/storage/session/legacy-format.js.map +1 -0
  151. package/dist/core/storage/session/legacy-session-store.d.ts +60 -0
  152. package/dist/core/storage/session/legacy-session-store.d.ts.map +1 -0
  153. package/dist/core/storage/session/legacy-session-store.js +225 -0
  154. package/dist/core/storage/session/legacy-session-store.js.map +1 -0
  155. package/dist/core/storage/session/memory-session-store.d.ts +3 -1
  156. package/dist/core/storage/session/memory-session-store.d.ts.map +1 -1
  157. package/dist/core/storage/session/memory-session-store.js +9 -2
  158. package/dist/core/storage/session/memory-session-store.js.map +1 -1
  159. package/dist/core/storage/session/sql-session-store.d.ts +4 -1
  160. package/dist/core/storage/session/sql-session-store.d.ts.map +1 -1
  161. package/dist/core/storage/session/sql-session-store.js +25 -6
  162. package/dist/core/storage/session/sql-session-store.js.map +1 -1
  163. package/dist/core/storage/session/types.d.ts +4 -0
  164. package/dist/core/storage/session/types.d.ts.map +1 -1
  165. package/dist/core/storage/session/types.js.map +1 -1
  166. package/dist/core/tools/read-url.d.ts.map +1 -1
  167. package/dist/core/tools/read-url.js +6 -1
  168. package/dist/core/tools/read-url.js.map +1 -1
  169. package/dist/extensions/codemode/execute.d.ts.map +1 -1
  170. package/dist/extensions/codemode/execute.js +13 -0
  171. package/dist/extensions/codemode/execute.js.map +1 -1
  172. package/dist/extensions/herdr/index.d.ts.map +1 -1
  173. package/dist/extensions/herdr/index.js +5 -3
  174. package/dist/extensions/herdr/index.js.map +1 -1
  175. package/dist/index.d.ts +3 -1
  176. package/dist/index.d.ts.map +1 -1
  177. package/dist/index.js +3 -1
  178. package/dist/index.js.map +1 -1
  179. package/dist/main-session.d.ts +5 -1
  180. package/dist/main-session.d.ts.map +1 -1
  181. package/dist/main-session.js +106 -45
  182. package/dist/main-session.js.map +1 -1
  183. package/dist/main.d.ts.map +1 -1
  184. package/dist/main.js +49 -15
  185. package/dist/main.js.map +1 -1
  186. package/dist/modes/interactive/components/chat-session-host.d.ts +3 -1
  187. package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
  188. package/dist/modes/interactive/components/chat-session-host.js +15 -7
  189. package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
  190. package/dist/modes/interactive/components/session-selector-delete.d.ts +1 -1
  191. package/dist/modes/interactive/components/session-selector-delete.d.ts.map +1 -1
  192. package/dist/modes/interactive/components/session-selector-delete.js.map +1 -1
  193. package/dist/modes/interactive/components/session-selector-list.d.ts +4 -4
  194. package/dist/modes/interactive/components/session-selector-list.d.ts.map +1 -1
  195. package/dist/modes/interactive/components/session-selector-list.js +13 -12
  196. package/dist/modes/interactive/components/session-selector-list.js.map +1 -1
  197. package/dist/modes/interactive/components/session-selector.d.ts +1 -0
  198. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  199. package/dist/modes/interactive/components/session-selector.js +16 -5
  200. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  201. package/dist/modes/interactive/interactive-mode-helpers.d.ts.map +1 -1
  202. package/dist/modes/interactive/interactive-mode-helpers.js +6 -2
  203. package/dist/modes/interactive/interactive-mode-helpers.js.map +1 -1
  204. package/dist/modes/interactive/interactive-session-routing.js +19 -7
  205. package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
  206. package/dist/modes/interactive/interactive-slash-commands.js +3 -1
  207. package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
  208. package/dist/modes/interactive-engine/create-isolated-runtime.d.ts.map +1 -1
  209. package/dist/modes/interactive-engine/create-isolated-runtime.js +8 -1
  210. package/dist/modes/interactive-engine/create-isolated-runtime.js.map +1 -1
  211. package/dist/modes/interactive-engine/engine-args.d.ts.map +1 -1
  212. package/dist/modes/interactive-engine/engine-args.js +5 -1
  213. package/dist/modes/interactive-engine/engine-args.js.map +1 -1
  214. package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
  215. package/dist/modes/interactive-engine/isolated-runtime.js +21 -15
  216. package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
  217. package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -1
  218. package/dist/modes/rpc/rpc-client-process.js +3 -1
  219. package/dist/modes/rpc/rpc-client-process.js.map +1 -1
  220. package/dist/modes/rpc/rpc-command-handler.js +1 -1
  221. package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
  222. package/dist/modes/rpc/rpc-terminal-drain.d.ts.map +1 -1
  223. package/dist/modes/rpc/rpc-terminal-drain.js +11 -2
  224. package/dist/modes/rpc/rpc-terminal-drain.js.map +1 -1
  225. package/dist/utils/canonical-path.d.ts +5 -0
  226. package/dist/utils/canonical-path.d.ts.map +1 -0
  227. package/dist/utils/canonical-path.js +26 -0
  228. package/dist/utils/canonical-path.js.map +1 -0
  229. package/dist/utils/paths.d.ts +1 -7
  230. package/dist/utils/paths.d.ts.map +1 -1
  231. package/dist/utils/paths.js +1 -15
  232. package/dist/utils/paths.js.map +1 -1
  233. package/docs/codemode.md +2 -0
  234. package/docs/compaction.md +2 -2
  235. package/docs/docs.json +1 -0
  236. package/docs/environment-variables.md +6 -2
  237. package/docs/getting-started/installation.md +1 -1
  238. package/docs/models/reference.md +2 -0
  239. package/docs/models-configuration.md +206 -0
  240. package/docs/models.md +11 -1
  241. package/docs/providers.md +2 -2
  242. package/docs/reference/cli.md +4 -0
  243. package/docs/sdk/web-server.md +3 -3
  244. package/docs/sdk.md +40 -3
  245. package/docs/session-format.md +30 -25
  246. package/docs/sessions.md +43 -17
  247. package/docs/settings.md +31 -9
  248. package/docs/storage.md +85 -2
  249. package/docs/subagents.md +19 -6
  250. package/docs/workflows/api-reference.md +23 -15
  251. package/docs/workflows/operations.md +3 -3
  252. package/docs/workflows/reliable-design.md +16 -16
  253. package/npm-shrinkwrap.json +53 -53
  254. package/package.json +7 -6
  255. package/schemas/models.schema.json +62 -29
  256. package/schemas/settings.schema.json +136 -31
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/web-access",
3
- "version": "0.9.38-alpha.6",
3
+ "version": "0.9.38-alpha.8",
4
4
  "private": true,
5
5
  "description": "Atomic extension for web search, URL fetching, GitHub repo cloning, PDF/video extraction. Fork of: https://github.com/nicobailon/pi-web-access",
6
6
  "contributors": [
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "peerDependencies": {
33
33
  "@bastani/atomic": "*",
34
- "@earendil-works/pi-tui": "^1.2.0"
34
+ "@earendil-works/pi-tui": "^1.3.0"
35
35
  },
36
36
  "peerDependenciesMeta": {
37
37
  "@bastani/atomic": {
@@ -6,6 +6,31 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.9.38-alpha.8] - 2026-10-17
10
+
11
+ ### Fixed
12
+
13
+ - Fixed `/workflow resume` no longer listing or resuming runs recorded before 0.9.38-alpha.6. The default journal now lists runs from its earlier tables and converts a run only when you resume or inspect it, so opening the journal does no extra work. The earlier tables are left in place, and deleted runs stay deleted. Stage checkpoints that identified their session only by transcript path now resume by that transcript's session ID, so their conversations reopen after sessions are imported into the default store.
14
+
15
+ ## [0.9.38-alpha.7] - 2026-10-17
16
+
17
+ ### Breaking Changes
18
+
19
+ - Construct `JournalDurableBackend` with asynchronous `open()`; direct construction and internal synchronous journal methods have been removed.
20
+ - `RunOpts.journal.database` requires the async SQLite facade; wrap an existing native connection with `wrapNodeSqliteDatabase`. Journal selection errors now use `StorageConfigError` and its `source`, `field`, and `reason` fields instead of `JournalConfigurationError`.
21
+ - Replaced `forkFromSessionFile` with `forkFromSessionId`. Use the prior task's `sessionId` in the selected session store. `recordStageSession` now accepts `{ sessionId }` only. Retained chat validation and completed inspection are asynchronous, and transcript paths are display metadata, not resume or fork identities.
22
+ - Durable backend registration, status, reset, and checkpoint writes now use awaited `commit*` methods. Replace `registerWorkflow` with `commitWorkflowRegistration`, `setWorkflowStatus` with `commitWorkflowStatus`, `transitionWorkflowStatus` with `commitWorkflowStatusTransition`, `adjustPendingPrompts` with `commitPendingPromptAdjustment`, and `reset` with `commitReset`. Use `commitCheckpoint` instead of either checkpoint writer and `commitAdditiveCheckpointBestEffort` for additive writes. Cached `ctx.stage()` declarations remain synchronous; their replay metadata is committed before the next async execution boundary.
23
+
24
+ ### Added
25
+
26
+ - Added journal adapter module selection with environment/file secret references and shared `storage` settings. SDK options override environment, journal settings, shared storage, and persistent defaults; nearer settings replace complete selections. Caller-owned database selections accept the async SQLite facade and remain open after journal close.
27
+
28
+ ### Fixed
29
+
30
+ - Workflow journal shutdown waits for queued writes before releasing ownership. Status claims and checkpoints on the same run remain ordered with asynchronous journals.
31
+ - Completed standalone SDK runs now release their stage sessions when no caller registry owns them. Workflow forks and completed-history inspection release temporary session-store connections while preserving caller-owned stores.
32
+ - Starting a workflow after a workflow's completed, failed, or blocked notice no longer fails with `Workflow execution for <runId> is retired`. Notices and late stage messages now reach the chat outside the finished run's execution context.
33
+
9
34
  ## [0.9.38-alpha.6] - 2026-10-16
10
35
 
11
36
  ### Breaking Changes
@@ -582,8 +582,8 @@ function isUiUnavailableRejection(error) {
582
582
 
583
583
  // dist/builtin/workflows/builtin/open-claude-design-phases.ts
584
584
  var GROUNDED_REPORTING2 = "Before reporting progress, audit each claim against a tool result from this session. Report only work you can point to evidence for; say so explicitly when something is unverified.";
585
- function forkContinuationOptions(sessionFile) {
586
- return sessionFile === undefined || sessionFile.length === 0 ? {} : { context: "fork", forkFromSessionFile: sessionFile };
585
+ function forkContinuationOptions(sessionId) {
586
+ return sessionId === undefined ? {} : { context: "fork", forkFromSessionId: sessionId };
587
587
  }
588
588
  async function refineOpenClaudeDesign(options) {
589
589
  const { designContext, prompt, outputType, previewPath, previewFileUrl, browserBootstrapRules, designContextFile, referencesFile, designModelConfig, workflowCwd } = options;
@@ -621,12 +621,12 @@ async function refineOpenClaudeDesign(options) {
621
621
  }
622
622
  async function runLiveReviewSession(options) {
623
623
  const { designContext, round, reviewStageName, previewPath, previewFileUrl, browserBootstrapRules, designModelConfig, workflowCwd } = options;
624
- let sessionFile;
624
+ let sessionId;
625
625
  const start = await designContext.task(`${reviewStageName}-start`, {
626
626
  prompt: buildLiveSessionStartPrompt({ previewPath, previewFileUrl, browserBootstrapRules, round }),
627
627
  ...designModelConfig
628
628
  });
629
- sessionFile = start.sessionFile;
629
+ sessionId = start.sessionId;
630
630
  for (let index = 1;; index += 1) {
631
631
  const event = await designContext.tool(`live-poll-${round}-${index}`, { round, index }, async ({ signal }) => pollLiveEvent({ workflowCwd, signal }));
632
632
  if (event.type === "exit")
@@ -639,9 +639,9 @@ async function runLiveReviewSession(options) {
639
639
  const response = await designContext.task(`live-${event.type}-${round}-${index}`, {
640
640
  prompt: buildLiveEventPrompt({ event, previewPath }),
641
641
  ...designModelConfig,
642
- ...forkContinuationOptions(sessionFile)
642
+ ...forkContinuationOptions(sessionId)
643
643
  });
644
- sessionFile = response.sessionFile ?? sessionFile;
644
+ sessionId = response.sessionId ?? sessionId;
645
645
  const status = replyTokenFor(event);
646
646
  await designContext.tool(`live-reply-${round}-${index}`, { round, index, eventId: event.id, status }, async ({ signal }) => replyLiveEvent({ workflowCwd, event, status, signal }));
647
647
  }
@@ -39,7 +39,7 @@ import {
39
39
  reviewerFailureText,
40
40
  summarizeReviewConvergence,
41
41
  reverify_consolidated_batch
42
- } from "./chunk-g1a4hw0s.js";
42
+ } from "./chunk-8x61e0s7.js";
43
43
  import {
44
44
  fold_usage
45
45
  } from "./chunk-tgt0s5e5.js";
@@ -257,8 +257,8 @@ async function writeJsonArtifact(path, content) {
257
257
  function compactReviewReport(path) {
258
258
  return path === undefined ? "No reviewer artifact was produced." : `Latest review round artifact: ${path}`;
259
259
  }
260
- function forkContinuationOptions(sessionFile) {
261
- return sessionFile === undefined || sessionFile.length === 0 ? {} : { context: "fork", forkFromSessionFile: sessionFile };
260
+ function forkContinuationOptions(sessionId) {
261
+ return sessionId === undefined ? {} : { context: "fork", forkFromSessionId: sessionId };
262
262
  }
263
263
  function renderResearchPromptRefinementPrompt(args) {
264
264
  return taggedPrompt([
@@ -530,15 +530,15 @@ async function runRalphWorkflow(ctx, options) {
530
530
  const artifactDir = await createWorkflowArtifactDirectory(runId);
531
531
  let approved = false;
532
532
  let iterationsCompleted = 0;
533
- let previousResearchPromptRefinementSessionFile;
533
+ let previousResearchPromptRefinementSessionId;
534
534
  const convergenceEntries = [];
535
- let previousResearchSessionFile;
536
- let previousOrchestratorSessionFile;
535
+ let previousResearchSessionId;
536
+ let previousOrchestratorSessionId;
537
537
  for (let iteration = 1;iteration <= maxLoops; iteration += 1) {
538
538
  iterationsCompleted = iteration;
539
- const researchPromptRefinementForkOptions = forkContinuationOptions(previousResearchPromptRefinementSessionFile);
539
+ const researchPromptRefinementForkOptions = forkContinuationOptions(previousResearchPromptRefinementSessionId);
540
540
  const researchPromptRefinement = await ctx.task(`research-prompt-refinement-${iteration}`, {
541
- prompt: researchPromptRefinementForkOptions.forkFromSessionFile === undefined ? renderResearchPromptRefinementPrompt({
541
+ prompt: researchPromptRefinementForkOptions.forkFromSessionId === undefined ? renderResearchPromptRefinementPrompt({
542
542
  request: workflowPrompt,
543
543
  acceptanceCriteria,
544
544
  workflowCwdContext,
@@ -548,11 +548,11 @@ async function runRalphWorkflow(ctx, options) {
548
548
  ...promptEngineerModelConfig,
549
549
  ...researchPromptRefinementForkOptions
550
550
  });
551
- previousResearchPromptRefinementSessionFile = researchPromptRefinement.sessionFile;
551
+ previousResearchPromptRefinementSessionId = researchPromptRefinement.sessionId;
552
552
  finalPlan = researchPromptRefinement.text;
553
- const researchForkOptions = forkContinuationOptions(previousResearchSessionFile);
553
+ const researchForkOptions = forkContinuationOptions(previousResearchSessionId);
554
554
  const research = await ctx.task(`research-${iteration}`, {
555
- prompt: researchForkOptions.forkFromSessionFile === undefined ? renderResearchPrompt({
555
+ prompt: researchForkOptions.forkFromSessionId === undefined ? renderResearchPrompt({
556
556
  transformedResearchQuestion: researchPromptRefinement.text,
557
557
  prompt: workflowPrompt,
558
558
  acceptanceCriteria,
@@ -568,14 +568,14 @@ async function runRalphWorkflow(ctx, options) {
568
568
  ...researchModelConfig,
569
569
  ...researchForkOptions
570
570
  });
571
- previousResearchSessionFile = research.sessionFile;
571
+ previousResearchSessionId = research.sessionId;
572
572
  finalResearch = research.text || `Research artifact: ${workflowResearchPath}`;
573
573
  const researchPath = workflowResearchPath;
574
574
  finalResearchPath = researchPath;
575
575
  finalPlanPath = researchPath;
576
576
  const orchestratorReportPath = join2(artifactDir, "orchestrator-report.md");
577
- const orchestratorForkOptions = forkContinuationOptions(previousOrchestratorSessionFile);
578
- const orchestratorPrompt = orchestratorForkOptions.forkFromSessionFile === undefined ? taggedPrompt([
577
+ const orchestratorForkOptions = forkContinuationOptions(previousOrchestratorSessionId);
578
+ const orchestratorPrompt = orchestratorForkOptions.forkFromSessionId === undefined ? taggedPrompt([
579
579
  ["acceptance_criteria", keepContext(acceptanceCriteria)],
580
580
  ["literal_contract", LITERAL_OBJECTIVE_CONTRACT],
581
581
  ["acceptance_matrix", ACCEPTANCE_MATRIX_CONTRACT],
@@ -654,7 +654,7 @@ Read it before implementation or delegation because it is the primary current im
654
654
  ...orchestratorModelConfig,
655
655
  ...orchestratorForkOptions
656
656
  });
657
- previousOrchestratorSessionFile = orchestrator.sessionFile;
657
+ previousOrchestratorSessionId = orchestrator.sessionId;
658
658
  finalResult = orchestrator.text || `Orchestrator report artifact: ${orchestratorReportPath}`;
659
659
  const reviewPrompt = renderRalphReviewerPrompt({
660
660
  workflowPrompt,
@@ -134,18 +134,15 @@ class ScopedDurableBackend {
134
134
  async hasPendingStageDeliveryReceipt(workflowId, messageId, delivery, logicalRunId = workflowId) {
135
135
  return await this.inner.hasPendingStageDeliveryReceipt?.(this.scope.rootWorkflowId, messageId, delivery, logicalRunId) ?? false;
136
136
  }
137
- registerWorkflow(_handle) {}
137
+ async commitWorkflowRegistration(_handle) {}
138
138
  persistPendingStageMessages(workflowId, messages, logicalRunId = workflowId) {
139
139
  return this.inner.persistPendingStageMessages(this.scope.rootWorkflowId, messages, logicalRunId);
140
140
  }
141
- recordCheckpoint(checkpoint) {
142
- return this.inner.recordCheckpoint(this.remap(checkpoint));
141
+ async commitCheckpoint(checkpoint, options) {
142
+ await this.inner.commitCheckpoint(this.remap(checkpoint), options);
143
143
  }
144
- async recordCheckpointAsync(checkpoint, options) {
145
- await this.inner.recordCheckpointAsync(this.remap(checkpoint), options);
146
- }
147
- async recordAdditiveCheckpointBestEffort(checkpoint) {
148
- return await this.inner.recordAdditiveCheckpointBestEffort(this.remap(checkpoint));
144
+ async commitAdditiveCheckpointBestEffort(checkpoint) {
145
+ return await this.inner.commitAdditiveCheckpointBestEffort(this.remap(checkpoint));
149
146
  }
150
147
  workflowOwnership(_workflowId) {
151
148
  return this.inner.workflowOwnership(this.scope.rootWorkflowId);
@@ -175,12 +172,12 @@ class ScopedDurableBackend {
175
172
  getLoadableWorkflow(_workflowId) {
176
173
  return;
177
174
  }
178
- setWorkflowStatus(_workflowId, _status, _pendingPrompts, _resumable) {}
179
- async transitionWorkflowStatus(_workflowId, _expectedStatuses, _status, _pendingPrompts, _resumable) {
175
+ async commitWorkflowStatus(_workflowId, _status, _pendingPrompts, _resumable) {}
176
+ async commitWorkflowStatusTransition(_workflowId, _expectedStatuses, _status, _pendingPrompts, _resumable) {
180
177
  return false;
181
178
  }
182
- adjustPendingPrompts(_workflowId, delta) {
183
- return this.inner.adjustPendingPrompts(this.scope.rootWorkflowId, delta);
179
+ commitPendingPromptAdjustment(_workflowId, delta) {
180
+ return this.inner.commitPendingPromptAdjustment(this.scope.rootWorkflowId, delta);
184
181
  }
185
182
  promptReservationScope(_workflowId) {
186
183
  return this.effectivePromptScope();
@@ -213,7 +210,7 @@ class ScopedDurableBackend {
213
210
  isWorkflowLoadable(_workflowId) {
214
211
  return false;
215
212
  }
216
- reset() {}
213
+ async commitReset() {}
217
214
  hydrateWorkflow(_workflowId) {
218
215
  return Promise.resolve();
219
216
  }
@@ -343,6 +340,7 @@ function durableBackendForRun(backend, runs, runId) {
343
340
  // dist/builtin/workflows/src/durable/journal/types.ts
344
341
  import { StorageSchemaVersionError } from "@bastani/atomic/storage";
345
342
  import { StorageUnavailableError } from "@bastani/atomic/storage";
343
+ import { RUN_EVENT_TYPES } from "@bastani/atomic/storage";
346
344
  class JournalError extends Error {
347
345
  }
348
346
 
@@ -2437,19 +2435,9 @@ function createStageStoreMethods(context) {
2437
2435
  if (!run)
2438
2436
  return false;
2439
2437
  const stage = context.findStage(run, stageId);
2440
- if (!stage)
2441
- return false;
2442
- let changed = false;
2443
- if (session.sessionId !== undefined && stage.sessionId !== session.sessionId) {
2444
- stage.sessionId = session.sessionId;
2445
- changed = true;
2446
- }
2447
- if (session.sessionFile !== undefined && stage.sessionFile !== session.sessionFile) {
2448
- stage.sessionFile = session.sessionFile;
2449
- changed = true;
2450
- }
2451
- if (!changed)
2438
+ if (!stage || stage.sessionId === session.sessionId)
2452
2439
  return false;
2440
+ stage.sessionId = session.sessionId;
2453
2441
  context.bumpAndNotify();
2454
2442
  return true;
2455
2443
  },
@@ -37,7 +37,7 @@ import {
37
37
  parseFailureDiagnostics,
38
38
  summarizeReviewConvergence,
39
39
  reverify_consolidated_batch
40
- } from "./chunk-g1a4hw0s.js";
40
+ } from "./chunk-8x61e0s7.js";
41
41
  import {
42
42
  VERIFICATION_SCALE
43
43
  } from "./chunk-n1910xc4.js";
@@ -822,8 +822,8 @@ function positiveInteger(value, fallback) {
822
822
  const floored = Math.floor(value);
823
823
  return floored >= 1 ? floored : fallback;
824
824
  }
825
- function forkContinuationOptions(sessionFile) {
826
- return sessionFile === undefined || sessionFile.length === 0 ? {} : { context: "fork", forkFromSessionFile: sessionFile };
825
+ function forkContinuationOptions(sessionId) {
826
+ return sessionId === undefined ? {} : { context: "fork", forkFromSessionId: sessionId };
827
827
  }
828
828
  function normalizeBranchInput(value, fallback) {
829
829
  const trimmed = value?.trim();
@@ -855,7 +855,7 @@ async function runGoalWorkflow(ctx, options) {
855
855
  let latestReviews = [];
856
856
  let latestReviewArtifactPaths = [];
857
857
  let latestReviewReportPath;
858
- let previousOrchestratorSessionFile;
858
+ let previousOrchestratorSessionId;
859
859
  const recordedTurns = new Set(ledger.decisions.map((decision) => decision.turn));
860
860
  const lastRecordedTurn = Math.max(0, ...recordedTurns);
861
861
  for (let turn = 1;turn <= maxTurns && (ledger.status === "active" || turn <= lastRecordedTurn); turn += 1) {
@@ -866,8 +866,8 @@ async function runGoalWorkflow(ctx, options) {
866
866
  await writeGoalLedger(ledgerPath, ledger);
867
867
  }
868
868
  const orchestratorReceiptPath = join3(artifactDir, "orchestrator-receipt.md");
869
- const orchestratorForkOptions = forkContinuationOptions(previousOrchestratorSessionFile);
870
- const orchestratorPrompt = orchestratorForkOptions.forkFromSessionFile === undefined ? renderGoalOrchestratorPrompt({
869
+ const orchestratorForkOptions = forkContinuationOptions(previousOrchestratorSessionId);
870
+ const orchestratorPrompt = orchestratorForkOptions.forkFromSessionId === undefined ? renderGoalOrchestratorPrompt({
871
871
  ledger,
872
872
  ledgerPath,
873
873
  blockerThreshold,
@@ -882,7 +882,7 @@ async function runGoalWorkflow(ctx, options) {
882
882
  ...orchestratorModelConfig,
883
883
  ...orchestratorForkOptions
884
884
  });
885
- previousOrchestratorSessionFile = orchestrator.sessionFile;
885
+ previousOrchestratorSessionId = orchestrator.sessionId;
886
886
  if (!replayingRecordedTurn) {
887
887
  ledger.turns = turn;
888
888
  const receiptAlreadyRecorded = ledger.receipts.some((receipt) => receipt.turn === turn && receipt.artifact_path === orchestratorReceiptPath);
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  goal_default
3
- } from "./chunk-2qgfyvzs.js";
4
- import"./chunk-g1a4hw0s.js";
3
+ } from "./chunk-y45tkftg.js";
4
+ import"./chunk-8x61e0s7.js";
5
5
  import"./chunk-2377r57g.js";
6
6
  import"./chunk-z0d03ktm.js";
7
7
  import"./chunk-n1910xc4.js";
@@ -16,18 +16,18 @@ import {
16
16
  } from "./chunk-5eh0brtd.js";
17
17
  import {
18
18
  goal_default
19
- } from "./chunk-2qgfyvzs.js";
20
- import"./chunk-g1a4hw0s.js";
19
+ } from "./chunk-y45tkftg.js";
20
+ import"./chunk-8x61e0s7.js";
21
21
  import"./chunk-z0d03ktm.js";
22
22
  import {
23
23
  open_claude_design_default
24
- } from "./chunk-q7dx7kh7.js";
24
+ } from "./chunk-85mx6wcf.js";
25
25
  import {
26
26
  loop_until_done_default
27
27
  } from "./chunk-454hz1qt.js";
28
28
  import {
29
29
  ralph_default
30
- } from "./chunk-neszcj53.js";
30
+ } from "./chunk-8kkv04hz.js";
31
31
  import {
32
32
  tournament_default
33
33
  } from "./chunk-4bwtzyjq.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  open_claude_design_default
3
- } from "./chunk-q7dx7kh7.js";
3
+ } from "./chunk-85mx6wcf.js";
4
4
  import"./chunk-qjqn389g.js";
5
5
  import"./chunk-9cm2ckq2.js";
6
6
  export {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ralph_default
3
- } from "./chunk-neszcj53.js";
4
- import"./chunk-g1a4hw0s.js";
3
+ } from "./chunk-8kkv04hz.js";
4
+ import"./chunk-8x61e0s7.js";
5
5
  import"./chunk-2377r57g.js";
6
6
  import"./chunk-z0d03ktm.js";
7
7
  import"./chunk-n1910xc4.js";
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/workflows",
3
- "version": "0.9.38-alpha.6",
3
+ "version": "0.9.38-alpha.8",
4
4
  "private": true,
5
5
  "description": "Atomic extension for multi-stage workflow authoring and execution.",
6
6
  "contributors": [
@@ -85,7 +85,7 @@
85
85
  },
86
86
  "peerDependencies": {
87
87
  "@bastani/atomic": "*",
88
- "@earendil-works/pi-tui": "^1.2.0",
88
+ "@earendil-works/pi-tui": "^1.3.0",
89
89
  "typebox": "*"
90
90
  },
91
91
  "peerDependenciesMeta": {
@@ -1,20 +1 @@
1
- import type { AppendOutcome, JournalEntry, Lease, LeaseOutcome, LeaseState, RunEvent, RunHeader, RunJournal, RunSummary } from "./types.js";
2
1
  export declare const JOURNAL_READ_PAGE_SIZE = 256;
3
- export interface SynchronousRunJournal {
4
- createRunSync(header: RunHeader): "created" | "exists";
5
- listRunsSync(filter?: {
6
- cwd?: string;
7
- }): readonly RunSummary[];
8
- takeoverExpiredSync(runId: string, holderId: string, staleAfterMs: number): LeaseOutcome;
9
- leaseStateSync(runId: string): LeaseState | undefined;
10
- renewSync(lease: Lease): void;
11
- releaseSync(lease: Lease): void;
12
- appendSync(lease: Lease, event: RunEvent, options?: {
13
- key?: string;
14
- expectSeq?: number;
15
- }): AppendOutcome;
16
- readEntries(runId: string, fromSeq?: number): readonly JournalEntry[];
17
- deleteRunSync(runId: string): void;
18
- }
19
- export declare function registerSynchronousJournal(journal: RunJournal, synchronous: SynchronousRunJournal): void;
20
- export declare function synchronousJournal(journal: RunJournal): SynchronousRunJournal | undefined;
@@ -0,0 +1,42 @@
1
+ import { type SqliteDatabase, type SqliteExecutor, type SqliteRow } from "@bastani/atomic/storage";
2
+ import { JOURNAL_COLUMNS as c } from "./types.js";
3
+ type LegacyRunRow = SqliteRow & {
4
+ [c.runId]: string;
5
+ [c.headerJson]: string;
6
+ [c.status]: string;
7
+ };
8
+ type LegacyEventRow = SqliteRow & {
9
+ [c.runId]: string;
10
+ [c.seq]: number;
11
+ [c.epoch]: number;
12
+ [c.key]: string | null;
13
+ [c.type]: string;
14
+ [c.payload]: string;
15
+ [c.at]: number;
16
+ };
17
+ /**
18
+ * Runs recorded before #3682, kept in the unprefixed `meta`/`runs`/`events`/`leases` tables.
19
+ *
20
+ * #3682 renamed the journal tables to `wf_*` without reading the old ones, so
21
+ * `/workflow resume` lost every run recorded before 0.9.38-alpha.6. Those runs are
22
+ * listed from the old tables as they are, and a run is converted into `wf_*` only
23
+ * when it is resumed (its lease is claimed), following pi's migrate-on-load pattern.
24
+ * Until then its events are read from the old tables as they are. The schema version and
25
+ * columns are unchanged, so its rows copy verbatim. The old tables are never
26
+ * modified; deleting a legacy run records its ID so it is not listed again.
27
+ */
28
+ export declare class LegacyJournalRuns {
29
+ /** Present only for the unprefixed journal in a database that still has version-1 legacy tables. */
30
+ static open(database: SqliteDatabase): Promise<LegacyJournalRuns | undefined>;
31
+ pending(executor: SqliteExecutor, filter?: {
32
+ cwd?: string;
33
+ }): Promise<LegacyRunRow[]>;
34
+ find(executor: SqliteExecutor, runId: string): Promise<LegacyRunRow | undefined>;
35
+ /** Events of an unconverted legacy run, read in place. */
36
+ events(executor: SqliteExecutor, runId: string, fromSeq: number, limit: number): Promise<LegacyEventRow[]>;
37
+ eventByKey(executor: SqliteExecutor, runId: string, key: string): Promise<LegacyEventRow | undefined>;
38
+ /** Convert one legacy run into `wf_*` inside the caller's transaction; returns whether it did. */
39
+ convert(tx: SqliteExecutor, runId: string): Promise<boolean>;
40
+ markDeleted(tx: SqliteExecutor, runId: string): Promise<void>;
41
+ }
42
+ export {};
@@ -1,43 +1,35 @@
1
+ import type { StorageDescriptor } from "@bastani/atomic/storage";
1
2
  import { type AppendOutcome, type JournalEntry, type Lease, type LeaseOutcome, type LeaseState, type RunEvent, type RunHeader, type RunJournal, type RunSummary } from "./types.js";
2
3
  export declare class MemoryRunJournal implements RunJournal {
3
4
  private readonly runs;
4
5
  private readonly leases;
5
6
  private closed;
6
- constructor();
7
+ private readonly storage?;
8
+ constructor(storage?: StorageDescriptor);
7
9
  private ensureOpen;
8
10
  createRun(header: RunHeader): Promise<"created" | "exists">;
9
- private createRunSync;
10
11
  getRun(runId: string): Promise<RunSummary | undefined>;
11
12
  listRuns(filter?: {
12
13
  cwd?: string;
13
14
  }): Promise<readonly RunSummary[]>;
14
- private listRunsSync;
15
15
  private requireRun;
16
16
  private grant;
17
17
  acquire(runId: string, holderId: string): Promise<LeaseOutcome>;
18
- private acquireSync;
19
18
  takeover(runId: string, holderId: string, expectedHolder: string): Promise<LeaseOutcome>;
20
19
  takeoverExpired(runId: string, holderId: string, staleAfterMs: number): Promise<LeaseOutcome>;
21
- private takeoverExpiredSync;
22
20
  leaseState(runId: string): Promise<LeaseState | undefined>;
23
- private leaseStateSync;
24
21
  private checkLease;
25
22
  renew(lease: Lease): Promise<void>;
26
- private renewSync;
27
23
  release(lease: Lease): Promise<void>;
28
- private releaseSync;
29
24
  append(lease: Lease, event: RunEvent, options?: {
30
25
  key?: string;
31
26
  expectSeq?: number;
32
27
  }): Promise<AppendOutcome>;
33
- private appendSync;
34
28
  private copyEntry;
35
29
  read(runId: string, fromSeq?: number): AsyncIterable<JournalEntry>;
36
30
  private readPage;
37
- private readEntries;
38
31
  readKey(runId: string, key: string): Promise<JournalEntry | undefined>;
39
32
  deleteRun(runId: string): Promise<void>;
40
- private deleteRunSync;
41
33
  deleteOwnedRun(lease: Lease, expectSeq?: number): Promise<void>;
42
34
  close(): Promise<void>;
43
35
  }
@@ -1,26 +1,32 @@
1
- import type { DatabaseSync } from "node:sqlite";
2
- import { type RunJournal } from "./types.js";
1
+ import { type AdapterOptions, type SecretRef, type SqliteDatabase, type StorageSelection, type StorageSettingsSelection } from "@bastani/atomic/storage";
2
+ import type { RunJournal } from "./types.js";
3
3
  export type RunJournalOption = {
4
4
  path: string;
5
+ prefix?: string;
5
6
  } | {
6
- database: DatabaseSync;
7
+ database: SqliteDatabase;
8
+ prefix?: string;
7
9
  } | {
8
10
  memory: true;
11
+ } | {
12
+ adapter: string;
13
+ options?: AdapterOptions;
14
+ secrets?: Readonly<Record<string, SecretRef>>;
15
+ prefix?: string;
9
16
  } | RunJournal;
10
17
  export interface RunJournalSettings {
11
18
  workflows?: string[] | {
12
- journal?: {
13
- path?: string;
14
- memory?: boolean;
15
- };
19
+ journal?: StorageSettingsSelection;
16
20
  };
21
+ storage?: StorageSettingsSelection;
17
22
  }
18
- /** Resolve configuration without opening storage, so callers can reuse an existing selection. */
19
23
  export declare function selectRunJournal(options?: {
20
24
  journal?: RunJournalOption;
21
25
  settings?: RunJournalSettings;
22
- }): RunJournalOption;
26
+ }): StorageSelection | RunJournal;
23
27
  export declare function resolveRunJournal(options?: {
24
28
  journal?: RunJournalOption;
25
29
  settings?: RunJournalSettings;
26
30
  }): Promise<RunJournal>;
31
+ export declare function openSelectedRunJournal(selection: StorageSelection | RunJournal): Promise<RunJournal>;
32
+ export declare function withRunJournalConfigSource<T>(selection: StorageSelection | RunJournal, open: () => Promise<T>): Promise<T>;
@@ -7,6 +7,7 @@ export declare class SqlRunJournal implements RunJournal {
7
7
  private closePromise?;
8
8
  private readonly database;
9
9
  private readonly tables;
10
+ private readonly legacy;
10
11
  private constructor();
11
12
  static open(database: SqliteDatabase, options?: {
12
13
  readonly prefix?: string;
@@ -22,6 +23,8 @@ export declare class SqlRunJournal implements RunJournal {
22
23
  cwd?: string;
23
24
  }): Promise<readonly RunSummary[]>;
24
25
  private requireRun;
26
+ /** Whether this run exists only in the legacy tables, whose events are then read in place. */
27
+ private isUnconvertedLegacyRun;
25
28
  private leaseRow;
26
29
  private grant;
27
30
  acquire(runId: string, holderId: string): Promise<LeaseOutcome>;