@bastani/atomic 0.9.89-alpha.2 → 0.9.90-alpha.1

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 (868) hide show
  1. package/CHANGELOG.md +357 -0
  2. package/dist/builtin/intercom/CHANGELOG.md +36 -0
  3. package/dist/builtin/intercom/README.md +3 -1
  4. package/dist/builtin/intercom/broker/broker.ts +35 -10
  5. package/dist/builtin/intercom/broker/client.ts +42 -1
  6. package/dist/builtin/intercom/index.bundle.mjs +400 -67
  7. package/dist/builtin/intercom/package.json +1 -1
  8. package/dist/builtin/intercom/skills/intercom/SKILL.md +24 -5
  9. package/dist/builtin/intercom/types.ts +5 -0
  10. package/dist/builtin/mcp/package.json +1 -1
  11. package/dist/builtin/subagents/CHANGELOG.md +66 -0
  12. package/dist/builtin/subagents/README.md +18 -20
  13. package/dist/builtin/subagents/agents/worker.md +1 -1
  14. package/dist/builtin/subagents/package.json +1 -1
  15. package/dist/builtin/subagents/skills/feedback/SKILL.md +2 -2
  16. package/dist/builtin/subagents/skills/qlty/SKILL.md +2 -2
  17. package/dist/builtin/subagents/skills/qlty/references/commands.md +45 -12
  18. package/dist/builtin/subagents/skills/qlty/references/quickstart.md +102 -21
  19. package/dist/builtin/subagents/skills/subagent/SKILL.md +18 -17
  20. package/dist/builtin/subagents/skills/tdd/LICENSE.txt +50 -0
  21. package/dist/builtin/subagents/skills/tdd/SKILL.md +10 -0
  22. package/dist/builtin/subagents/skills/tdd/tests.md +16 -0
  23. package/dist/builtin/subagents/skills/tmux/LICENSE.txt +24 -0
  24. package/dist/builtin/subagents/skills/tmux/SKILL.md +20 -1
  25. package/dist/builtin/subagents/skills/tmux/scripts/find-sessions.sh +19 -10
  26. package/dist/builtin/subagents/skills/tmux/scripts/wait-for-text.sh +231 -19
  27. package/dist/builtin/subagents/src/extension/index.bundle.mjs +1911 -845
  28. package/dist/builtin/web-access/CHANGELOG.md +17 -0
  29. package/dist/builtin/web-access/index.bundle.mjs +158 -34
  30. package/dist/builtin/web-access/package.json +1 -1
  31. package/dist/builtin/workflows/CHANGELOG.md +130 -0
  32. package/dist/builtin/workflows/builtin/{chunk-tjk7jp9a.js → chunk-akmcsx14.js} +1 -1
  33. package/dist/builtin/workflows/builtin/{chunk-913nwrzq.js → chunk-erpybg3c.js} +109 -30
  34. package/dist/builtin/workflows/builtin/{chunk-e07n7en6.js → chunk-wpgpr31s.js} +1 -1
  35. package/dist/builtin/workflows/builtin/goal.js +2 -2
  36. package/dist/builtin/workflows/builtin/index.js +3 -3
  37. package/dist/builtin/workflows/builtin/ralph.js +2 -2
  38. package/dist/builtin/workflows/package.json +1 -1
  39. package/dist/builtin/workflows/skills/bro/SKILL.md +1 -1
  40. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5_2.md +19 -19
  41. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_haiku_5_5.md +2 -2
  42. package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_5_5.md +3 -3
  43. package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6.md +2 -2
  44. package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6_1_sol.md +2 -2
  45. package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6_1_terra.md +3 -3
  46. package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6_2.md +3 -2
  47. package/dist/builtin/workflows/skills/show-me/SKILL.md +2 -2
  48. package/dist/builtin/workflows/skills/skill-creator/scripts/run_eval.py +29 -24
  49. package/dist/builtin/workflows/skills/teach/SKILL.md +8 -8
  50. package/dist/builtin/workflows/skills/unslop/SKILL.md +29 -51
  51. package/dist/builtin/workflows/src/durable/journal/internal.d.ts +10 -5
  52. package/dist/builtin/workflows/src/durable/journal/sharded-run-journal.d.ts +6 -3
  53. package/dist/builtin/workflows/src/durable/journal/sql-run-journal.d.ts +25 -3
  54. package/dist/builtin/workflows/src/extension/index.bundle.mjs +4444 -1356
  55. package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +2544 -568
  56. package/dist/builtin/workflows/src/index.js +2467 -549
  57. package/dist/builtin/workflows/src/local-worker-entry.mjs +2544 -568
  58. package/dist/cli/storage-command.d.ts +6 -0
  59. package/dist/cli/storage-command.d.ts.map +1 -1
  60. package/dist/cli/storage-command.js +11 -0
  61. package/dist/cli/storage-command.js.map +1 -1
  62. package/dist/cli/storage-search-database.d.ts +18 -0
  63. package/dist/cli/storage-search-database.d.ts.map +1 -0
  64. package/dist/cli/storage-search-database.js +90 -0
  65. package/dist/cli/storage-search-database.js.map +1 -0
  66. package/dist/cli/storage-search-session.d.ts +5 -0
  67. package/dist/cli/storage-search-session.d.ts.map +1 -0
  68. package/dist/cli/storage-search-session.js +133 -0
  69. package/dist/cli/storage-search-session.js.map +1 -0
  70. package/dist/core/agent-session-accessors.d.ts.map +1 -1
  71. package/dist/core/agent-session-accessors.js +107 -1
  72. package/dist/core/agent-session-accessors.js.map +1 -1
  73. package/dist/core/agent-session-bash.d.ts.map +1 -1
  74. package/dist/core/agent-session-bash.js +2 -0
  75. package/dist/core/agent-session-bash.js.map +1 -1
  76. package/dist/core/agent-session-boundaries.d.ts +2 -0
  77. package/dist/core/agent-session-boundaries.d.ts.map +1 -1
  78. package/dist/core/agent-session-boundaries.js +9 -4
  79. package/dist/core/agent-session-boundaries.js.map +1 -1
  80. package/dist/core/agent-session-custom-message-commit.d.ts.map +1 -1
  81. package/dist/core/agent-session-custom-message-commit.js +2 -1
  82. package/dist/core/agent-session-custom-message-commit.js.map +1 -1
  83. package/dist/core/agent-session-detached-tools.d.ts +3 -2
  84. package/dist/core/agent-session-detached-tools.d.ts.map +1 -1
  85. package/dist/core/agent-session-detached-tools.js +156 -41
  86. package/dist/core/agent-session-detached-tools.js.map +1 -1
  87. package/dist/core/agent-session-events.d.ts +2 -1
  88. package/dist/core/agent-session-events.d.ts.map +1 -1
  89. package/dist/core/agent-session-events.js +59 -23
  90. package/dist/core/agent-session-events.js.map +1 -1
  91. package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
  92. package/dist/core/agent-session-extension-bindings.js +53 -4
  93. package/dist/core/agent-session-extension-bindings.js.map +1 -1
  94. package/dist/core/agent-session-message-queue.d.ts.map +1 -1
  95. package/dist/core/agent-session-message-queue.js +2 -1
  96. package/dist/core/agent-session-message-queue.js.map +1 -1
  97. package/dist/core/agent-session-methods.d.ts +23 -3
  98. package/dist/core/agent-session-methods.d.ts.map +1 -1
  99. package/dist/core/agent-session-methods.js.map +1 -1
  100. package/dist/core/agent-session-models.d.ts.map +1 -1
  101. package/dist/core/agent-session-models.js +2 -0
  102. package/dist/core/agent-session-models.js.map +1 -1
  103. package/dist/core/agent-session-prompt.d.ts +1 -1
  104. package/dist/core/agent-session-prompt.d.ts.map +1 -1
  105. package/dist/core/agent-session-prompt.js +14 -3
  106. package/dist/core/agent-session-prompt.js.map +1 -1
  107. package/dist/core/agent-session-queue-pause.d.ts +2 -1
  108. package/dist/core/agent-session-queue-pause.d.ts.map +1 -1
  109. package/dist/core/agent-session-queue-pause.js +8 -4
  110. package/dist/core/agent-session-queue-pause.js.map +1 -1
  111. package/dist/core/agent-session-retry.d.ts +7 -3
  112. package/dist/core/agent-session-retry.d.ts.map +1 -1
  113. package/dist/core/agent-session-retry.js +113 -112
  114. package/dist/core/agent-session-retry.js.map +1 -1
  115. package/dist/core/agent-session-runtime.d.ts +15 -0
  116. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  117. package/dist/core/agent-session-runtime.js +26 -0
  118. package/dist/core/agent-session-runtime.js.map +1 -1
  119. package/dist/core/agent-session-services.d.ts +5 -2
  120. package/dist/core/agent-session-services.d.ts.map +1 -1
  121. package/dist/core/agent-session-services.js +6 -6
  122. package/dist/core/agent-session-services.js.map +1 -1
  123. package/dist/core/agent-session-tasks.js.map +1 -1
  124. package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
  125. package/dist/core/agent-session-tool-registry.js +4 -2
  126. package/dist/core/agent-session-tool-registry.js.map +1 -1
  127. package/dist/core/agent-session-types.d.ts +19 -1
  128. package/dist/core/agent-session-types.d.ts.map +1 -1
  129. package/dist/core/agent-session-types.js.map +1 -1
  130. package/dist/core/agent-session.d.ts +11 -0
  131. package/dist/core/agent-session.d.ts.map +1 -1
  132. package/dist/core/agent-session.js +8 -0
  133. package/dist/core/agent-session.js.map +1 -1
  134. package/dist/core/anthropic-thinking-guard.d.ts +16 -1
  135. package/dist/core/anthropic-thinking-guard.d.ts.map +1 -1
  136. package/dist/core/anthropic-thinking-guard.js +124 -7
  137. package/dist/core/anthropic-thinking-guard.js.map +1 -1
  138. package/dist/core/auth-storage.d.ts +3 -0
  139. package/dist/core/auth-storage.d.ts.map +1 -1
  140. package/dist/core/auth-storage.js +10 -0
  141. package/dist/core/auth-storage.js.map +1 -1
  142. package/dist/core/detached-tool-output.d.ts +4 -0
  143. package/dist/core/detached-tool-output.d.ts.map +1 -0
  144. package/dist/core/detached-tool-output.js +48 -0
  145. package/dist/core/detached-tool-output.js.map +1 -0
  146. package/dist/core/event-loop-monitor.d.ts +4 -1
  147. package/dist/core/event-loop-monitor.d.ts.map +1 -1
  148. package/dist/core/event-loop-monitor.js +84 -159
  149. package/dist/core/event-loop-monitor.js.map +1 -1
  150. package/dist/core/export-html/index.d.ts.map +1 -1
  151. package/dist/core/export-html/index.js +26 -4
  152. package/dist/core/export-html/index.js.map +1 -1
  153. package/dist/core/export-html/saved-agent-cards.d.ts +15 -0
  154. package/dist/core/export-html/saved-agent-cards.d.ts.map +1 -0
  155. package/dist/core/export-html/saved-agent-cards.js +255 -0
  156. package/dist/core/export-html/saved-agent-cards.js.map +1 -0
  157. package/dist/core/export-html/saved-agent-viewer.js +101 -0
  158. package/dist/core/extensions/builtin-subagent-record-writer.d.ts +11 -0
  159. package/dist/core/extensions/builtin-subagent-record-writer.d.ts.map +1 -0
  160. package/dist/core/extensions/builtin-subagent-record-writer.js +33 -0
  161. package/dist/core/extensions/builtin-subagent-record-writer.js.map +1 -0
  162. package/dist/core/extensions/loader-api.d.ts +1 -1
  163. package/dist/core/extensions/loader-api.d.ts.map +1 -1
  164. package/dist/core/extensions/loader-api.js +9 -2
  165. package/dist/core/extensions/loader-api.js.map +1 -1
  166. package/dist/core/extensions/loader-bindings.d.ts +7 -0
  167. package/dist/core/extensions/loader-bindings.d.ts.map +1 -1
  168. package/dist/core/extensions/loader-bindings.js +42 -1
  169. package/dist/core/extensions/loader-bindings.js.map +1 -1
  170. package/dist/core/extensions/loader-core.d.ts.map +1 -1
  171. package/dist/core/extensions/loader-core.js +33 -12
  172. package/dist/core/extensions/loader-core.js.map +1 -1
  173. package/dist/core/extensions/runner-events.d.ts +2 -0
  174. package/dist/core/extensions/runner-events.d.ts.map +1 -1
  175. package/dist/core/extensions/runner-events.js +17 -7
  176. package/dist/core/extensions/runner-events.js.map +1 -1
  177. package/dist/core/extensions/runner.d.ts +6 -2
  178. package/dist/core/extensions/runner.d.ts.map +1 -1
  179. package/dist/core/extensions/runner.js +5 -2
  180. package/dist/core/extensions/runner.js.map +1 -1
  181. package/dist/core/extensions/ui-types.d.ts +4 -0
  182. package/dist/core/extensions/ui-types.d.ts.map +1 -1
  183. package/dist/core/extensions/ui-types.js.map +1 -1
  184. package/dist/core/extensions/workflow-run-control-hub.d.ts +2 -2
  185. package/dist/core/extensions/workflow-run-control-hub.d.ts.map +1 -1
  186. package/dist/core/extensions/workflow-run-control-hub.js +2 -2
  187. package/dist/core/extensions/workflow-run-control-hub.js.map +1 -1
  188. package/dist/core/extensions/workflow-run-control.d.ts +10 -3
  189. package/dist/core/extensions/workflow-run-control.d.ts.map +1 -1
  190. package/dist/core/extensions/workflow-run-control.js.map +1 -1
  191. package/dist/core/first-prompt-model.d.ts +22 -0
  192. package/dist/core/first-prompt-model.d.ts.map +1 -0
  193. package/dist/core/first-prompt-model.js +84 -0
  194. package/dist/core/first-prompt-model.js.map +1 -0
  195. package/dist/core/footer-data-provider.d.ts.map +1 -1
  196. package/dist/core/footer-data-provider.js +11 -7
  197. package/dist/core/footer-data-provider.js.map +1 -1
  198. package/dist/core/fork-replay-pair.d.ts +22 -0
  199. package/dist/core/fork-replay-pair.d.ts.map +1 -0
  200. package/dist/core/fork-replay-pair.js +174 -0
  201. package/dist/core/fork-replay-pair.js.map +1 -0
  202. package/dist/core/fork-replay-wire.d.ts +11 -0
  203. package/dist/core/fork-replay-wire.d.ts.map +1 -0
  204. package/dist/core/fork-replay-wire.js +116 -0
  205. package/dist/core/fork-replay-wire.js.map +1 -0
  206. package/dist/core/messages.d.ts +2 -0
  207. package/dist/core/messages.d.ts.map +1 -1
  208. package/dist/core/messages.js +8 -4
  209. package/dist/core/messages.js.map +1 -1
  210. package/dist/core/model-runtime.d.ts +10 -1
  211. package/dist/core/model-runtime.d.ts.map +1 -1
  212. package/dist/core/model-runtime.js +76 -11
  213. package/dist/core/model-runtime.js.map +1 -1
  214. package/dist/core/package-manager-auto-resources.d.ts.map +1 -1
  215. package/dist/core/package-manager-auto-resources.js +3 -2
  216. package/dist/core/package-manager-auto-resources.js.map +1 -1
  217. package/dist/core/package-manager-resource-files.js +7 -8
  218. package/dist/core/package-manager-resource-files.js.map +1 -1
  219. package/dist/core/project-trust-state.d.ts +90 -0
  220. package/dist/core/project-trust-state.d.ts.map +1 -0
  221. package/dist/core/project-trust-state.js +65 -0
  222. package/dist/core/project-trust-state.js.map +1 -0
  223. package/dist/core/provider-rate-limits.d.ts +6 -0
  224. package/dist/core/provider-rate-limits.d.ts.map +1 -1
  225. package/dist/core/provider-rate-limits.js +43 -0
  226. package/dist/core/provider-rate-limits.js.map +1 -1
  227. package/dist/core/provider-request-admission.d.ts.map +1 -1
  228. package/dist/core/provider-request-admission.js +10 -1
  229. package/dist/core/provider-request-admission.js.map +1 -1
  230. package/dist/core/remote-catalog-provider.d.ts +6 -1
  231. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  232. package/dist/core/remote-catalog-provider.js +22 -1
  233. package/dist/core/remote-catalog-provider.js.map +1 -1
  234. package/dist/core/resolve-config-value.d.ts.map +1 -1
  235. package/dist/core/resolve-config-value.js +5 -2
  236. package/dist/core/resolve-config-value.js.map +1 -1
  237. package/dist/core/resource-loader-core.d.ts.map +1 -1
  238. package/dist/core/resource-loader-core.js +3 -0
  239. package/dist/core/resource-loader-core.js.map +1 -1
  240. package/dist/core/resource-loader-extensions.d.ts +2 -2
  241. package/dist/core/resource-loader-extensions.d.ts.map +1 -1
  242. package/dist/core/resource-loader-extensions.js +6 -4
  243. package/dist/core/resource-loader-extensions.js.map +1 -1
  244. package/dist/core/resource-loader-package-resources.d.ts +1 -0
  245. package/dist/core/resource-loader-package-resources.d.ts.map +1 -1
  246. package/dist/core/resource-loader-package-resources.js +2 -1
  247. package/dist/core/resource-loader-package-resources.js.map +1 -1
  248. package/dist/core/resource-loader-reload.d.ts +1 -1
  249. package/dist/core/resource-loader-reload.d.ts.map +1 -1
  250. package/dist/core/resource-loader-reload.js +3 -2
  251. package/dist/core/resource-loader-reload.js.map +1 -1
  252. package/dist/core/resource-loader-types.d.ts +2 -0
  253. package/dist/core/resource-loader-types.d.ts.map +1 -1
  254. package/dist/core/resource-loader-types.js.map +1 -1
  255. package/dist/core/resume/blueprint/actions.d.ts.map +1 -1
  256. package/dist/core/resume/blueprint/actions.js +15 -15
  257. package/dist/core/resume/blueprint/actions.js.map +1 -1
  258. package/dist/core/resume/blueprint/process.d.ts +6 -1
  259. package/dist/core/resume/blueprint/process.d.ts.map +1 -1
  260. package/dist/core/resume/blueprint/process.js +132 -21
  261. package/dist/core/resume/blueprint/process.js.map +1 -1
  262. package/dist/core/runtime-credentials.d.ts +5 -0
  263. package/dist/core/runtime-credentials.d.ts.map +1 -1
  264. package/dist/core/runtime-credentials.js +34 -0
  265. package/dist/core/runtime-credentials.js.map +1 -1
  266. package/dist/core/sdk-types.d.ts +2 -0
  267. package/dist/core/sdk-types.d.ts.map +1 -1
  268. package/dist/core/sdk-types.js.map +1 -1
  269. package/dist/core/sdk.d.ts +1 -1
  270. package/dist/core/sdk.d.ts.map +1 -1
  271. package/dist/core/sdk.js +187 -32
  272. package/dist/core/sdk.js.map +1 -1
  273. package/dist/core/session-account-model.d.ts +15 -0
  274. package/dist/core/session-account-model.d.ts.map +1 -0
  275. package/dist/core/session-account-model.js +105 -0
  276. package/dist/core/session-account-model.js.map +1 -0
  277. package/dist/core/session-lifecycle-scope.d.ts +5 -0
  278. package/dist/core/session-lifecycle-scope.d.ts.map +1 -1
  279. package/dist/core/session-lifecycle-scope.js.map +1 -1
  280. package/dist/core/session-manager-core.d.ts +21 -2
  281. package/dist/core/session-manager-core.d.ts.map +1 -1
  282. package/dist/core/session-manager-core.js +64 -8
  283. package/dist/core/session-manager-core.js.map +1 -1
  284. package/dist/core/session-manager-history.d.ts +3 -1
  285. package/dist/core/session-manager-history.d.ts.map +1 -1
  286. package/dist/core/session-manager-history.js +19 -5
  287. package/dist/core/session-manager-history.js.map +1 -1
  288. package/dist/core/session-manager-types.d.ts +2 -0
  289. package/dist/core/session-manager-types.d.ts.map +1 -1
  290. package/dist/core/session-manager-types.js.map +1 -1
  291. package/dist/core/session-retry-status.d.ts +22 -0
  292. package/dist/core/session-retry-status.d.ts.map +1 -0
  293. package/dist/core/session-retry-status.js +25 -0
  294. package/dist/core/session-retry-status.js.map +1 -0
  295. package/dist/core/session-worktree-snapshots.d.ts +4 -2
  296. package/dist/core/session-worktree-snapshots.d.ts.map +1 -1
  297. package/dist/core/session-worktree-snapshots.js +8 -4
  298. package/dist/core/session-worktree-snapshots.js.map +1 -1
  299. package/dist/core/settings-manager-core.d.ts +4 -0
  300. package/dist/core/settings-manager-core.d.ts.map +1 -1
  301. package/dist/core/settings-manager-core.js +73 -1
  302. package/dist/core/settings-manager-core.js.map +1 -1
  303. package/dist/core/settings-schema.js +1 -1
  304. package/dist/core/settings-schema.js.map +1 -1
  305. package/dist/core/slash-commands.d.ts +2 -2
  306. package/dist/core/slash-commands.d.ts.map +1 -1
  307. package/dist/core/slash-commands.js +15 -4
  308. package/dist/core/slash-commands.js.map +1 -1
  309. package/dist/core/storage/database.d.ts +14 -2
  310. package/dist/core/storage/database.d.ts.map +1 -1
  311. package/dist/core/storage/database.js.map +1 -1
  312. package/dist/core/storage/dialect.d.ts +13 -0
  313. package/dist/core/storage/dialect.d.ts.map +1 -1
  314. package/dist/core/storage/dialect.js +9 -1
  315. package/dist/core/storage/dialect.js.map +1 -1
  316. package/dist/core/storage/errors.d.ts +23 -1
  317. package/dist/core/storage/errors.d.ts.map +1 -1
  318. package/dist/core/storage/errors.js +28 -5
  319. package/dist/core/storage/errors.js.map +1 -1
  320. package/dist/core/storage/journal-transfer.d.ts.map +1 -1
  321. package/dist/core/storage/journal-transfer.js +90 -5
  322. package/dist/core/storage/journal-transfer.js.map +1 -1
  323. package/dist/core/storage/node-sqlite.d.ts.map +1 -1
  324. package/dist/core/storage/node-sqlite.js +61 -1
  325. package/dist/core/storage/node-sqlite.js.map +1 -1
  326. package/dist/core/storage/session/chunked-resume-projection.d.ts +4 -0
  327. package/dist/core/storage/session/chunked-resume-projection.d.ts.map +1 -0
  328. package/dist/core/storage/session/chunked-resume-projection.js +369 -0
  329. package/dist/core/storage/session/chunked-resume-projection.js.map +1 -0
  330. package/dist/core/storage/session/legacy-session-store.d.ts +5 -0
  331. package/dist/core/storage/session/legacy-session-store.d.ts.map +1 -1
  332. package/dist/core/storage/session/legacy-session-store.js +10 -2
  333. package/dist/core/storage/session/legacy-session-store.js.map +1 -1
  334. package/dist/core/storage/session/memory-session-store.d.ts.map +1 -1
  335. package/dist/core/storage/session/memory-session-store.js +6 -1
  336. package/dist/core/storage/session/memory-session-store.js.map +1 -1
  337. package/dist/core/storage/session/snapshot-generation.d.ts +8 -0
  338. package/dist/core/storage/session/snapshot-generation.d.ts.map +1 -0
  339. package/dist/core/storage/session/snapshot-generation.js +17 -0
  340. package/dist/core/storage/session/snapshot-generation.js.map +1 -0
  341. package/dist/core/storage/session/sql-session-store.d.ts +12 -0
  342. package/dist/core/storage/session/sql-session-store.d.ts.map +1 -1
  343. package/dist/core/storage/session/sql-session-store.js +243 -46
  344. package/dist/core/storage/session/sql-session-store.js.map +1 -1
  345. package/dist/core/storage/sqlite-facade.d.ts +17 -2
  346. package/dist/core/storage/sqlite-facade.d.ts.map +1 -1
  347. package/dist/core/storage/sqlite-facade.js +17 -1
  348. package/dist/core/storage/sqlite-facade.js.map +1 -1
  349. package/dist/core/tasks/agent-adapter.d.ts +13 -2
  350. package/dist/core/tasks/agent-adapter.d.ts.map +1 -1
  351. package/dist/core/tasks/agent-adapter.js +25 -8
  352. package/dist/core/tasks/agent-adapter.js.map +1 -1
  353. package/dist/core/tasks/agent-panel-rules.d.ts +77 -0
  354. package/dist/core/tasks/agent-panel-rules.d.ts.map +1 -0
  355. package/dist/core/tasks/agent-panel-rules.js +88 -0
  356. package/dist/core/tasks/agent-panel-rules.js.map +1 -0
  357. package/dist/core/tasks/agent-panel-source.d.ts +19 -0
  358. package/dist/core/tasks/agent-panel-source.d.ts.map +1 -1
  359. package/dist/core/tasks/agent-panel-source.js +50 -9
  360. package/dist/core/tasks/agent-panel-source.js.map +1 -1
  361. package/dist/core/tasks/command-output.d.ts +17 -2
  362. package/dist/core/tasks/command-output.d.ts.map +1 -1
  363. package/dist/core/tasks/command-output.js +59 -3
  364. package/dist/core/tasks/command-output.js.map +1 -1
  365. package/dist/core/tasks/completion-message.d.ts +8 -3
  366. package/dist/core/tasks/completion-message.d.ts.map +1 -1
  367. package/dist/core/tasks/completion-message.js +14 -10
  368. package/dist/core/tasks/completion-message.js.map +1 -1
  369. package/dist/core/tasks/completion.d.ts +14 -4
  370. package/dist/core/tasks/completion.d.ts.map +1 -1
  371. package/dist/core/tasks/completion.js +58 -17
  372. package/dist/core/tasks/completion.js.map +1 -1
  373. package/dist/core/tasks/contracts.d.ts +10 -1
  374. package/dist/core/tasks/contracts.d.ts.map +1 -1
  375. package/dist/core/tasks/contracts.js +3 -1
  376. package/dist/core/tasks/contracts.js.map +1 -1
  377. package/dist/core/tasks/heartbeat.js +2 -1
  378. package/dist/core/tasks/heartbeat.js.map +1 -1
  379. package/dist/core/tasks/live-elapsed.d.ts +16 -1
  380. package/dist/core/tasks/live-elapsed.d.ts.map +1 -1
  381. package/dist/core/tasks/live-elapsed.js +43 -4
  382. package/dist/core/tasks/live-elapsed.js.map +1 -1
  383. package/dist/core/tasks/owner-store.d.ts +8 -0
  384. package/dist/core/tasks/owner-store.d.ts.map +1 -1
  385. package/dist/core/tasks/owner-store.js +34 -4
  386. package/dist/core/tasks/owner-store.js.map +1 -1
  387. package/dist/core/tasks/session-scope.d.ts +7 -0
  388. package/dist/core/tasks/session-scope.d.ts.map +1 -1
  389. package/dist/core/tasks/session-scope.js +15 -9
  390. package/dist/core/tasks/session-scope.js.map +1 -1
  391. package/dist/core/tasks/supervisor.d.ts +7 -3
  392. package/dist/core/tasks/supervisor.d.ts.map +1 -1
  393. package/dist/core/tasks/supervisor.js +92 -17
  394. package/dist/core/tasks/supervisor.js.map +1 -1
  395. package/dist/core/tasks/task-archive-snapshot.d.ts +7 -0
  396. package/dist/core/tasks/task-archive-snapshot.d.ts.map +1 -0
  397. package/dist/core/tasks/task-archive-snapshot.js +33 -0
  398. package/dist/core/tasks/task-archive-snapshot.js.map +1 -0
  399. package/dist/core/tasks/task-resumer.d.ts +5 -3
  400. package/dist/core/tasks/task-resumer.d.ts.map +1 -1
  401. package/dist/core/tasks/task-resumer.js +37 -13
  402. package/dist/core/tasks/task-resumer.js.map +1 -1
  403. package/dist/core/tasks/task-view-source.d.ts +25 -3
  404. package/dist/core/tasks/task-view-source.d.ts.map +1 -1
  405. package/dist/core/tasks/task-view-source.js +144 -44
  406. package/dist/core/tasks/task-view-source.js.map +1 -1
  407. package/dist/core/tasks/transcript.d.ts +3 -1
  408. package/dist/core/tasks/transcript.d.ts.map +1 -1
  409. package/dist/core/tasks/transcript.js +27 -0
  410. package/dist/core/tasks/transcript.js.map +1 -1
  411. package/dist/core/tools/ask-user-question/view/dialog-builder.d.ts.map +1 -1
  412. package/dist/core/tools/ask-user-question/view/dialog-builder.js +2 -1
  413. package/dist/core/tools/ask-user-question/view/dialog-builder.js.map +1 -1
  414. package/dist/core/tools/bash.d.ts.map +1 -1
  415. package/dist/core/tools/bash.js +2 -1
  416. package/dist/core/tools/bash.js.map +1 -1
  417. package/dist/core/tools/history-protocol.d.ts.map +1 -1
  418. package/dist/core/tools/history-protocol.js +130 -29
  419. package/dist/core/tools/history-protocol.js.map +1 -1
  420. package/dist/core/tools/history-search-position.d.ts +30 -0
  421. package/dist/core/tools/history-search-position.d.ts.map +1 -0
  422. package/dist/core/tools/history-search-position.js +161 -0
  423. package/dist/core/tools/history-search-position.js.map +1 -0
  424. package/dist/core/tools/history-search-wire.d.ts +25 -0
  425. package/dist/core/tools/history-search-wire.d.ts.map +1 -0
  426. package/dist/core/tools/history-search-wire.js +210 -0
  427. package/dist/core/tools/history-search-wire.js.map +1 -0
  428. package/dist/core/tools/resource-selectors.d.ts +7 -1
  429. package/dist/core/tools/resource-selectors.d.ts.map +1 -1
  430. package/dist/core/tools/resource-selectors.js +18 -11
  431. package/dist/core/tools/resource-selectors.js.map +1 -1
  432. package/dist/core/tools/search.d.ts.map +1 -1
  433. package/dist/core/tools/search.js +24 -3
  434. package/dist/core/tools/search.js.map +1 -1
  435. package/dist/core/tools/sqlite-selector-connection.d.ts +3 -0
  436. package/dist/core/tools/sqlite-selector-connection.d.ts.map +1 -1
  437. package/dist/core/tools/sqlite-selector-connection.js +4 -0
  438. package/dist/core/tools/sqlite-selector-connection.js.map +1 -1
  439. package/dist/core/tools/tool-abort-grace.d.ts +13 -0
  440. package/dist/core/tools/tool-abort-grace.d.ts.map +1 -0
  441. package/dist/core/tools/tool-abort-grace.js +72 -0
  442. package/dist/core/tools/tool-abort-grace.js.map +1 -0
  443. package/dist/core/tools/tool-concurrency.d.ts +5 -1
  444. package/dist/core/tools/tool-concurrency.d.ts.map +1 -1
  445. package/dist/core/tools/tool-concurrency.js +36 -6
  446. package/dist/core/tools/tool-concurrency.js.map +1 -1
  447. package/dist/core/workflow-resume.d.ts +1 -1
  448. package/dist/core/workflow-resume.d.ts.map +1 -1
  449. package/dist/core/workflow-resume.js +13 -3
  450. package/dist/core/workflow-resume.js.map +1 -1
  451. package/dist/core/workflow-summary-lifecycle.d.ts.map +1 -1
  452. package/dist/core/workflow-summary-lifecycle.js +8 -2
  453. package/dist/core/workflow-summary-lifecycle.js.map +1 -1
  454. package/dist/core/workspace/errors.d.ts +5 -2
  455. package/dist/core/workspace/errors.d.ts.map +1 -1
  456. package/dist/core/workspace/errors.js +59 -5
  457. package/dist/core/workspace/errors.js.map +1 -1
  458. package/dist/core/worktree-snapshot/blob-store.d.ts +138 -17
  459. package/dist/core/worktree-snapshot/blob-store.d.ts.map +1 -1
  460. package/dist/core/worktree-snapshot/blob-store.js +788 -82
  461. package/dist/core/worktree-snapshot/blob-store.js.map +1 -1
  462. package/dist/core/worktree-snapshot/garbage.d.ts +17 -2
  463. package/dist/core/worktree-snapshot/garbage.d.ts.map +1 -1
  464. package/dist/core/worktree-snapshot/garbage.js +20 -4
  465. package/dist/core/worktree-snapshot/garbage.js.map +1 -1
  466. package/dist/core/worktree-snapshot/index.d.ts +1 -1
  467. package/dist/core/worktree-snapshot/index.d.ts.map +1 -1
  468. package/dist/core/worktree-snapshot/index.js +1 -1
  469. package/dist/core/worktree-snapshot/index.js.map +1 -1
  470. package/dist/core/worktree-snapshot/pool.d.ts.map +1 -1
  471. package/dist/core/worktree-snapshot/pool.js +38 -6
  472. package/dist/core/worktree-snapshot/pool.js.map +1 -1
  473. package/dist/core/worktree-snapshot/shared-clock.d.ts +3 -1
  474. package/dist/core/worktree-snapshot/shared-clock.d.ts.map +1 -1
  475. package/dist/core/worktree-snapshot/shared-clock.js +116 -26
  476. package/dist/core/worktree-snapshot/shared-clock.js.map +1 -1
  477. package/dist/core/worktree-snapshot/types.d.ts +4 -1
  478. package/dist/core/worktree-snapshot/types.d.ts.map +1 -1
  479. package/dist/core/worktree-snapshot/types.js.map +1 -1
  480. package/dist/extensions/llama/huggingface-ui.d.ts.map +1 -1
  481. package/dist/extensions/llama/huggingface-ui.js +2 -2
  482. package/dist/extensions/llama/huggingface-ui.js.map +1 -1
  483. package/dist/extensions/llama/index.d.ts +2 -0
  484. package/dist/extensions/llama/index.d.ts.map +1 -1
  485. package/dist/extensions/llama/index.js +19 -2
  486. package/dist/extensions/llama/index.js.map +1 -1
  487. package/dist/index.d.ts +9 -6
  488. package/dist/index.d.ts.map +1 -1
  489. package/dist/index.js +8 -4
  490. package/dist/index.js.map +1 -1
  491. package/dist/main.d.ts.map +1 -1
  492. package/dist/main.js +74 -15
  493. package/dist/main.js.map +1 -1
  494. package/dist/modes/interactive/components/agent-panel.d.ts +22 -6
  495. package/dist/modes/interactive/components/agent-panel.d.ts.map +1 -1
  496. package/dist/modes/interactive/components/agent-panel.js +80 -23
  497. package/dist/modes/interactive/components/agent-panel.js.map +1 -1
  498. package/dist/modes/interactive/components/assistant-message.d.ts +2 -0
  499. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  500. package/dist/modes/interactive/components/assistant-message.js +11 -0
  501. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  502. package/dist/modes/interactive/components/atomic-working-status.d.ts.map +1 -1
  503. package/dist/modes/interactive/components/atomic-working-status.js +10 -3
  504. package/dist/modes/interactive/components/atomic-working-status.js.map +1 -1
  505. package/dist/modes/interactive/components/bash-execution.d.ts +3 -2
  506. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  507. package/dist/modes/interactive/components/bash-execution.js +7 -7
  508. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  509. package/dist/modes/interactive/components/branch-summary-message.d.ts +6 -0
  510. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
  511. package/dist/modes/interactive/components/branch-summary-message.js +12 -7
  512. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  513. package/dist/modes/interactive/components/chat-message-renderer.d.ts +2 -0
  514. package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
  515. package/dist/modes/interactive/components/chat-message-renderer.js +24 -3
  516. package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
  517. package/dist/modes/interactive/components/chat-session-host-actions.d.ts +1 -1
  518. package/dist/modes/interactive/components/chat-session-host-actions.d.ts.map +1 -1
  519. package/dist/modes/interactive/components/chat-session-host-actions.js +16 -10
  520. package/dist/modes/interactive/components/chat-session-host-actions.js.map +1 -1
  521. package/dist/modes/interactive/components/chat-session-host-events.d.ts +10 -0
  522. package/dist/modes/interactive/components/chat-session-host-events.d.ts.map +1 -1
  523. package/dist/modes/interactive/components/chat-session-host-events.js +76 -31
  524. package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -1
  525. package/dist/modes/interactive/components/chat-session-host-rendering.d.ts +17 -5
  526. package/dist/modes/interactive/components/chat-session-host-rendering.d.ts.map +1 -1
  527. package/dist/modes/interactive/components/chat-session-host-rendering.js +79 -24
  528. package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -1
  529. package/dist/modes/interactive/components/chat-session-host-runtime.d.ts.map +1 -1
  530. package/dist/modes/interactive/components/chat-session-host-runtime.js +5 -4
  531. package/dist/modes/interactive/components/chat-session-host-runtime.js.map +1 -1
  532. package/dist/modes/interactive/components/chat-session-host-state.d.ts +16 -1
  533. package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
  534. package/dist/modes/interactive/components/chat-session-host-state.js +22 -0
  535. package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
  536. package/dist/modes/interactive/components/chat-session-host-types.d.ts +8 -2
  537. package/dist/modes/interactive/components/chat-session-host-types.d.ts.map +1 -1
  538. package/dist/modes/interactive/components/chat-session-host-types.js.map +1 -1
  539. package/dist/modes/interactive/components/chat-session-host-utils.d.ts +1 -0
  540. package/dist/modes/interactive/components/chat-session-host-utils.d.ts.map +1 -1
  541. package/dist/modes/interactive/components/chat-session-host-utils.js +2 -1
  542. package/dist/modes/interactive/components/chat-session-host-utils.js.map +1 -1
  543. package/dist/modes/interactive/components/chat-session-host.d.ts +35 -9
  544. package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
  545. package/dist/modes/interactive/components/chat-session-host.js +129 -35
  546. package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
  547. package/dist/modes/interactive/components/chat-transcript.d.ts +13 -2
  548. package/dist/modes/interactive/components/chat-transcript.d.ts.map +1 -1
  549. package/dist/modes/interactive/components/chat-transcript.js +24 -4
  550. package/dist/modes/interactive/components/chat-transcript.js.map +1 -1
  551. package/dist/modes/interactive/components/compaction-boundary-message.d.ts +6 -0
  552. package/dist/modes/interactive/components/compaction-boundary-message.d.ts.map +1 -1
  553. package/dist/modes/interactive/components/compaction-boundary-message.js +12 -7
  554. package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -1
  555. package/dist/modes/interactive/components/composer-rule.d.ts +0 -2
  556. package/dist/modes/interactive/components/composer-rule.d.ts.map +1 -1
  557. package/dist/modes/interactive/components/composer-rule.js +4 -6
  558. package/dist/modes/interactive/components/composer-rule.js.map +1 -1
  559. package/dist/modes/interactive/components/countdown-timer.d.ts +5 -9
  560. package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -1
  561. package/dist/modes/interactive/components/countdown-timer.js +32 -23
  562. package/dist/modes/interactive/components/countdown-timer.js.map +1 -1
  563. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  564. package/dist/modes/interactive/components/custom-editor.js +4 -3
  565. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  566. package/dist/modes/interactive/components/custom-entry.d.ts +6 -0
  567. package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
  568. package/dist/modes/interactive/components/custom-entry.js +15 -0
  569. package/dist/modes/interactive/components/custom-entry.js.map +1 -1
  570. package/dist/modes/interactive/components/custom-message.d.ts +7 -3
  571. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  572. package/dist/modes/interactive/components/custom-message.js +17 -15
  573. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  574. package/dist/modes/interactive/components/footer.d.ts +10 -3
  575. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  576. package/dist/modes/interactive/components/footer.js +37 -45
  577. package/dist/modes/interactive/components/footer.js.map +1 -1
  578. package/dist/modes/interactive/components/heartbeat-block.d.ts.map +1 -1
  579. package/dist/modes/interactive/components/heartbeat-block.js +3 -1
  580. package/dist/modes/interactive/components/heartbeat-block.js.map +1 -1
  581. package/dist/modes/interactive/components/host-input-form.d.ts.map +1 -1
  582. package/dist/modes/interactive/components/host-input-form.js +3 -3
  583. package/dist/modes/interactive/components/host-input-form.js.map +1 -1
  584. package/dist/modes/interactive/components/index.d.ts +1 -1
  585. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  586. package/dist/modes/interactive/components/index.js.map +1 -1
  587. package/dist/modes/interactive/components/input-label.d.ts.map +1 -1
  588. package/dist/modes/interactive/components/input-label.js +4 -5
  589. package/dist/modes/interactive/components/input-label.js.map +1 -1
  590. package/dist/modes/interactive/components/keybinding-hints.d.ts +7 -0
  591. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
  592. package/dist/modes/interactive/components/keybinding-hints.js +27 -6
  593. package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
  594. package/dist/modes/interactive/components/main-composer-keys.d.ts +17 -2
  595. package/dist/modes/interactive/components/main-composer-keys.d.ts.map +1 -1
  596. package/dist/modes/interactive/components/main-composer-keys.js +44 -27
  597. package/dist/modes/interactive/components/main-composer-keys.js.map +1 -1
  598. package/dist/modes/interactive/components/model-selector.d.ts +6 -1
  599. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  600. package/dist/modes/interactive/components/model-selector.js +13 -7
  601. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  602. package/dist/modes/interactive/components/nav-keys.d.ts +7 -2
  603. package/dist/modes/interactive/components/nav-keys.d.ts.map +1 -1
  604. package/dist/modes/interactive/components/nav-keys.js +51 -17
  605. package/dist/modes/interactive/components/nav-keys.js.map +1 -1
  606. package/dist/modes/interactive/components/notice-line.d.ts +8 -0
  607. package/dist/modes/interactive/components/notice-line.d.ts.map +1 -1
  608. package/dist/modes/interactive/components/notice-line.js +6 -1
  609. package/dist/modes/interactive/components/notice-line.js.map +1 -1
  610. package/dist/modes/interactive/components/selector.d.ts +3 -0
  611. package/dist/modes/interactive/components/selector.d.ts.map +1 -1
  612. package/dist/modes/interactive/components/selector.js +30 -7
  613. package/dist/modes/interactive/components/selector.js.map +1 -1
  614. package/dist/modes/interactive/components/session-selector-list.d.ts.map +1 -1
  615. package/dist/modes/interactive/components/session-selector-list.js +11 -11
  616. package/dist/modes/interactive/components/session-selector-list.js.map +1 -1
  617. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  618. package/dist/modes/interactive/components/session-selector.js +2 -2
  619. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  620. package/dist/modes/interactive/components/settings-picker.d.ts +5 -0
  621. package/dist/modes/interactive/components/settings-picker.d.ts.map +1 -1
  622. package/dist/modes/interactive/components/settings-picker.js +36 -2
  623. package/dist/modes/interactive/components/settings-picker.js.map +1 -1
  624. package/dist/modes/interactive/components/settings-selector-submenus.d.ts +10 -0
  625. package/dist/modes/interactive/components/settings-selector-submenus.d.ts.map +1 -1
  626. package/dist/modes/interactive/components/settings-selector-submenus.js +89 -19
  627. package/dist/modes/interactive/components/settings-selector-submenus.js.map +1 -1
  628. package/dist/modes/interactive/components/settings-selector-types.d.ts +6 -0
  629. package/dist/modes/interactive/components/settings-selector-types.d.ts.map +1 -1
  630. package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
  631. package/dist/modes/interactive/components/settings-selector.d.ts +7 -0
  632. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  633. package/dist/modes/interactive/components/settings-selector.js +12 -0
  634. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  635. package/dist/modes/interactive/components/skill-invocation-message.d.ts +6 -0
  636. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
  637. package/dist/modes/interactive/components/skill-invocation-message.js +12 -7
  638. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  639. package/dist/modes/interactive/components/task-board.d.ts.map +1 -1
  640. package/dist/modes/interactive/components/task-board.js +9 -2
  641. package/dist/modes/interactive/components/task-board.js.map +1 -1
  642. package/dist/modes/interactive/components/task-completion-message.d.ts +10 -3
  643. package/dist/modes/interactive/components/task-completion-message.d.ts.map +1 -1
  644. package/dist/modes/interactive/components/task-completion-message.js +173 -19
  645. package/dist/modes/interactive/components/task-completion-message.js.map +1 -1
  646. package/dist/modes/interactive/components/task-inspector.d.ts +1 -1
  647. package/dist/modes/interactive/components/task-inspector.d.ts.map +1 -1
  648. package/dist/modes/interactive/components/task-inspector.js +28 -19
  649. package/dist/modes/interactive/components/task-inspector.js.map +1 -1
  650. package/dist/modes/interactive/components/task-list.d.ts +7 -3
  651. package/dist/modes/interactive/components/task-list.d.ts.map +1 -1
  652. package/dist/modes/interactive/components/task-list.js +60 -33
  653. package/dist/modes/interactive/components/task-list.js.map +1 -1
  654. package/dist/modes/interactive/components/task-row.d.ts +7 -0
  655. package/dist/modes/interactive/components/task-row.d.ts.map +1 -1
  656. package/dist/modes/interactive/components/task-row.js +25 -11
  657. package/dist/modes/interactive/components/task-row.js.map +1 -1
  658. package/dist/modes/interactive/components/task-transcript-notices.d.ts +16 -0
  659. package/dist/modes/interactive/components/task-transcript-notices.d.ts.map +1 -0
  660. package/dist/modes/interactive/components/task-transcript-notices.js +74 -0
  661. package/dist/modes/interactive/components/task-transcript-notices.js.map +1 -0
  662. package/dist/modes/interactive/components/task-transcript-page.d.ts +11 -6
  663. package/dist/modes/interactive/components/task-transcript-page.d.ts.map +1 -1
  664. package/dist/modes/interactive/components/task-transcript-page.js +48 -21
  665. package/dist/modes/interactive/components/task-transcript-page.js.map +1 -1
  666. package/dist/modes/interactive/components/tool-block-families.d.ts.map +1 -1
  667. package/dist/modes/interactive/components/tool-block-families.js +2 -1
  668. package/dist/modes/interactive/components/tool-block-families.js.map +1 -1
  669. package/dist/modes/interactive/components/tool-execution.d.ts +3 -2
  670. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  671. package/dist/modes/interactive/components/tool-execution.js +23 -9
  672. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  673. package/dist/modes/interactive/components/transcript-block-clicks.d.ts +54 -14
  674. package/dist/modes/interactive/components/transcript-block-clicks.d.ts.map +1 -1
  675. package/dist/modes/interactive/components/transcript-block-clicks.js +151 -16
  676. package/dist/modes/interactive/components/transcript-block-clicks.js.map +1 -1
  677. package/dist/modes/interactive/components/tree-selector-help.d.ts.map +1 -1
  678. package/dist/modes/interactive/components/tree-selector-help.js +25 -30
  679. package/dist/modes/interactive/components/tree-selector-help.js.map +1 -1
  680. package/dist/modes/interactive/components/tree-selector-list.d.ts +4 -0
  681. package/dist/modes/interactive/components/tree-selector-list.d.ts.map +1 -1
  682. package/dist/modes/interactive/components/tree-selector-list.js +21 -21
  683. package/dist/modes/interactive/components/tree-selector-list.js.map +1 -1
  684. package/dist/modes/interactive/components/working-run-meter.d.ts +31 -2
  685. package/dist/modes/interactive/components/working-run-meter.d.ts.map +1 -1
  686. package/dist/modes/interactive/components/working-run-meter.js +81 -10
  687. package/dist/modes/interactive/components/working-run-meter.js.map +1 -1
  688. package/dist/modes/interactive/interactive-agent-events.js +67 -14
  689. package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
  690. package/dist/modes/interactive/interactive-autocomplete.js +2 -2
  691. package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
  692. package/dist/modes/interactive/interactive-deferred-startup.d.ts.map +1 -1
  693. package/dist/modes/interactive/interactive-deferred-startup.js +10 -4
  694. package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
  695. package/dist/modes/interactive/interactive-editor-actions.js +4 -1
  696. package/dist/modes/interactive/interactive-editor-actions.js.map +1 -1
  697. package/dist/modes/interactive/interactive-extension-custom-ui.js +13 -3
  698. package/dist/modes/interactive/interactive-extension-custom-ui.js.map +1 -1
  699. package/dist/modes/interactive/interactive-extension-runtime.js +4 -2
  700. package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
  701. package/dist/modes/interactive/interactive-extension-widgets.js +6 -8
  702. package/dist/modes/interactive/interactive-extension-widgets.js.map +1 -1
  703. package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
  704. package/dist/modes/interactive/interactive-input-handling.js +43 -3
  705. package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
  706. package/dist/modes/interactive/interactive-mode-base.d.ts +7 -0
  707. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  708. package/dist/modes/interactive/interactive-mode-base.js +9 -2
  709. package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
  710. package/dist/modes/interactive/interactive-mode-deps.d.ts +1 -1
  711. package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
  712. package/dist/modes/interactive/interactive-mode-deps.js +1 -1
  713. package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
  714. package/dist/modes/interactive/interactive-mode-helpers.d.ts +5 -0
  715. package/dist/modes/interactive/interactive-mode-helpers.d.ts.map +1 -1
  716. package/dist/modes/interactive/interactive-mode-helpers.js +9 -0
  717. package/dist/modes/interactive/interactive-mode-helpers.js.map +1 -1
  718. package/dist/modes/interactive/interactive-mode-surface.d.ts +10 -2
  719. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  720. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  721. package/dist/modes/interactive/interactive-model-routing.d.ts.map +1 -1
  722. package/dist/modes/interactive/interactive-model-routing.js +63 -21
  723. package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
  724. package/dist/modes/interactive/interactive-prompt-turn.js +1 -1
  725. package/dist/modes/interactive/interactive-prompt-turn.js.map +1 -1
  726. package/dist/modes/interactive/interactive-render-chat.d.ts.map +1 -1
  727. package/dist/modes/interactive/interactive-render-chat.js +71 -10
  728. package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
  729. package/dist/modes/interactive/interactive-resource-rendering.js +9 -18
  730. package/dist/modes/interactive/interactive-resource-rendering.js.map +1 -1
  731. package/dist/modes/interactive/interactive-selectors.js +106 -57
  732. package/dist/modes/interactive/interactive-selectors.js.map +1 -1
  733. package/dist/modes/interactive/interactive-session-routing.js +10 -5
  734. package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
  735. package/dist/modes/interactive/interactive-session-runtime.d.ts +3 -0
  736. package/dist/modes/interactive/interactive-session-runtime.d.ts.map +1 -1
  737. package/dist/modes/interactive/interactive-session-runtime.js +11 -0
  738. package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
  739. package/dist/modes/interactive/interactive-slash-commands.js +3 -0
  740. package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
  741. package/dist/modes/interactive/interactive-startup-chat-container.d.ts +5 -1
  742. package/dist/modes/interactive/interactive-startup-chat-container.d.ts.map +1 -1
  743. package/dist/modes/interactive/interactive-startup-chat-container.js +8 -3
  744. package/dist/modes/interactive/interactive-startup-chat-container.js.map +1 -1
  745. package/dist/modes/interactive/interactive-startup-trust.d.ts +2 -0
  746. package/dist/modes/interactive/interactive-startup-trust.d.ts.map +1 -1
  747. package/dist/modes/interactive/interactive-startup-trust.js +21 -0
  748. package/dist/modes/interactive/interactive-startup-trust.js.map +1 -1
  749. package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
  750. package/dist/modes/interactive/interactive-startup.js +39 -17
  751. package/dist/modes/interactive/interactive-startup.js.map +1 -1
  752. package/dist/modes/interactive/interactive-task-projection.d.ts.map +1 -1
  753. package/dist/modes/interactive/interactive-task-projection.js +11 -1
  754. package/dist/modes/interactive/interactive-task-projection.js.map +1 -1
  755. package/dist/modes/interactive/resume-catalog.d.ts.map +1 -1
  756. package/dist/modes/interactive/resume-catalog.js +1 -0
  757. package/dist/modes/interactive/resume-catalog.js.map +1 -1
  758. package/dist/modes/interactive/theme/theme-controller.d.ts +6 -1
  759. package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
  760. package/dist/modes/interactive/theme/theme-controller.js +19 -1
  761. package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
  762. package/dist/modes/interactive-engine/engine-child-liveness.d.ts +2 -0
  763. package/dist/modes/interactive-engine/engine-child-liveness.d.ts.map +1 -1
  764. package/dist/modes/interactive-engine/engine-child-liveness.js +2 -0
  765. package/dist/modes/interactive-engine/engine-child-liveness.js.map +1 -1
  766. package/dist/modes/interactive-engine/engine-custom-ui.d.ts.map +1 -1
  767. package/dist/modes/interactive-engine/engine-custom-ui.js +54 -4
  768. package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -1
  769. package/dist/modes/interactive-engine/engine-render-service.d.ts.map +1 -1
  770. package/dist/modes/interactive-engine/engine-render-service.js +21 -2
  771. package/dist/modes/interactive-engine/engine-render-service.js.map +1 -1
  772. package/dist/modes/interactive-engine/extension-ui-bridge.d.ts +4 -2
  773. package/dist/modes/interactive-engine/extension-ui-bridge.d.ts.map +1 -1
  774. package/dist/modes/interactive-engine/extension-ui-bridge.js +4 -0
  775. package/dist/modes/interactive-engine/extension-ui-bridge.js.map +1 -1
  776. package/dist/modes/interactive-engine/isolated-runtime.d.ts +39 -3
  777. package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
  778. package/dist/modes/interactive-engine/isolated-runtime.js +219 -29
  779. package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
  780. package/dist/modes/interactive-engine/protocol.d.ts +33 -1
  781. package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
  782. package/dist/modes/interactive-engine/protocol.js +40 -2
  783. package/dist/modes/interactive-engine/protocol.js.map +1 -1
  784. package/dist/modes/interactive-engine/remote-command-catalog.d.ts +2 -2
  785. package/dist/modes/interactive-engine/remote-command-catalog.d.ts.map +1 -1
  786. package/dist/modes/interactive-engine/remote-command-catalog.js +7 -3
  787. package/dist/modes/interactive-engine/remote-command-catalog.js.map +1 -1
  788. package/dist/modes/interactive-engine/remote-component.d.ts.map +1 -1
  789. package/dist/modes/interactive-engine/remote-component.js +31 -5
  790. package/dist/modes/interactive-engine/remote-component.js.map +1 -1
  791. package/dist/modes/interactive-engine/remote-renderer.d.ts +20 -12
  792. package/dist/modes/interactive-engine/remote-renderer.d.ts.map +1 -1
  793. package/dist/modes/interactive-engine/remote-renderer.js +100 -34
  794. package/dist/modes/interactive-engine/remote-renderer.js.map +1 -1
  795. package/dist/modes/print-mode.d.ts.map +1 -1
  796. package/dist/modes/print-mode.js +4 -1
  797. package/dist/modes/print-mode.js.map +1 -1
  798. package/dist/modes/rpc/agent-panel-bridge.d.ts +7 -0
  799. package/dist/modes/rpc/agent-panel-bridge.d.ts.map +1 -1
  800. package/dist/modes/rpc/agent-panel-bridge.js +119 -114
  801. package/dist/modes/rpc/agent-panel-bridge.js.map +1 -1
  802. package/dist/modes/rpc/rpc-client-process.d.ts +2 -1
  803. package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -1
  804. package/dist/modes/rpc/rpc-client-process.js +2 -1
  805. package/dist/modes/rpc/rpc-client-process.js.map +1 -1
  806. package/dist/modes/rpc/rpc-client.d.ts +8 -0
  807. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  808. package/dist/modes/rpc/rpc-client.js +5 -1
  809. package/dist/modes/rpc/rpc-client.js.map +1 -1
  810. package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
  811. package/dist/modes/rpc/rpc-command-handler.js +19 -2
  812. package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
  813. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  814. package/dist/modes/rpc/rpc-mode.js +4 -2
  815. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  816. package/dist/modes/rpc/rpc-session-binding.d.ts.map +1 -1
  817. package/dist/modes/rpc/rpc-session-binding.js +7 -0
  818. package/dist/modes/rpc/rpc-session-binding.js.map +1 -1
  819. package/dist/modes/rpc/rpc-types.d.ts +13 -1
  820. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  821. package/dist/modes/rpc/rpc-types.js.map +1 -1
  822. package/dist/utils/interactive-engine-bootstrap.d.ts +3 -0
  823. package/dist/utils/interactive-engine-bootstrap.d.ts.map +1 -1
  824. package/dist/utils/interactive-engine-bootstrap.js +25 -0
  825. package/dist/utils/interactive-engine-bootstrap.js.map +1 -1
  826. package/dist/utils/interactive-engine-env.d.ts +3 -0
  827. package/dist/utils/interactive-engine-env.d.ts.map +1 -1
  828. package/dist/utils/interactive-engine-env.js +1 -0
  829. package/dist/utils/interactive-engine-env.js.map +1 -1
  830. package/dist/utils/shell.d.ts +2 -0
  831. package/dist/utils/shell.d.ts.map +1 -1
  832. package/dist/utils/shell.js +3 -3
  833. package/dist/utils/shell.js.map +1 -1
  834. package/docs/background-tasks.md +32 -37
  835. package/docs/compaction.md +2 -2
  836. package/docs/computer-use.md +2 -0
  837. package/docs/development.md +11 -1
  838. package/docs/environment-variables.md +2 -0
  839. package/docs/extensions/api-reference.md +7 -3
  840. package/docs/extensions/authoring.md +3 -1
  841. package/docs/extensions/events.md +3 -1
  842. package/docs/extensions/ui.md +2 -0
  843. package/docs/guides/resume-on-any-machine.md +3 -1
  844. package/docs/intercom/reference.md +1 -1
  845. package/docs/intercom.md +3 -3
  846. package/docs/keybindings.md +6 -2
  847. package/docs/libraries/tui.md +4 -0
  848. package/docs/providers.md +1 -1
  849. package/docs/rpc/protocol.md +6 -4
  850. package/docs/sdk/reference.md +10 -4
  851. package/docs/sdk.md +5 -2
  852. package/docs/security.md +5 -1
  853. package/docs/session-format.md +1 -1
  854. package/docs/sessions.md +16 -0
  855. package/docs/settings.md +2 -2
  856. package/docs/skills.md +3 -3
  857. package/docs/storage.md +25 -4
  858. package/docs/subagents.md +42 -45
  859. package/docs/tui.md +1 -1
  860. package/docs/usage.md +3 -1
  861. package/docs/workflows/api-reference.md +3 -1
  862. package/docs/workflows/authoring.md +1 -1
  863. package/docs/workflows/operations.md +21 -14
  864. package/docs/workflows.md +1 -1
  865. package/docs/worktree-snapshots.md +10 -8
  866. package/npm-shrinkwrap.json +71 -49
  867. package/package.json +9 -8
  868. package/schemas/settings.schema.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"journal-transfer.d.ts","sourceRoot":"","sources":["../../../src/core/storage/journal-transfer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,OAAO,KAAK,EAAE,cAAc,EAA0C,MAAM,eAAe,CAAC;AAG5F,OAAO,EAIN,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EAGvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAKN,KAAK,kBAAkB,EACvB,MAAM,sBAAsB,CAAC;AAiB9B,kDAAkD;AAClD,eAAO,MAAM,wBAAwB,wBAAwB,CAAC;AAC9D,8DAA8D;AAC9D,eAAO,MAAM,2BAA2B,IAAI,CAAC;AAC7C;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,SAAU,CAAC;AACzD;;;GAGG;AACH,eAAO,MAAM,sCAAsC,IAAI,CAAC;AAExD,+CAA+C;AAC/C,MAAM,MAAM,sBAAsB,GAC/B,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,sBAAsB,EAAE,GACjC;IAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,sBAAsB,CAAA;CAAE,CAAC;AAEtD,gCAAgC;AAChC,MAAM,WAAW,uBAAuB;IACvC,QAAQ,CAAC,IAAI,EAAE,OAAO,wBAAwB,CAAC;IAC/C,QAAQ,CAAC,OAAO,EAAE,OAAO,2BAA2B,CAAC;IACrD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;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,GAAG,WAAW,CAAC;AAsJrE,8GAA8G;AAC9G,UAAU,UAAU;IACnB,QAAQ,CAAC,GAAG,EAAE,iBAAiB,CAAC;IAChC,QAAQ,CAAC,MAAM,EAAE,uBAAuB,CAAC;IACzC,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC;IACvC,mDAAmD;IACnD,QAAQ,CAAC,KAAK,CAAC,EAAE,kBAAkB,CAAC;IACpC,iDAAiD;IACjD,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;CAC7B;AAED,iHAAiH;AACjH,MAAM,WAAW,qBAAqB;IACrC,QAAQ,CAAC,OAAO,EAAE,0BAA0B,CAAC;IAC7C,QAAQ,CAAC,IAAI,EAAE,SAAS,UAAU,EAAE,CAAC;CACrC;AAED,2CAA2C;AAC3C,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,qBAAqB,GAAG,MAAM,EAAE,CAEzE;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CAC1C,OAAO,EAAE,0BAA0B,EACnC,IAAI,EAAE,SAAS,iBAAiB,EAAE,GAChC,OAAO,CAAC,qBAAqB,CAAC,CA0ChC;AAWD;;;;;;;;GAQG;AACH,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAgG1G;AAED;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CACvC,OAAO,EAAE,0BAA0B,EACnC,SAAS,EAAE,MAAM,GACf,OAAO,CAAC,uBAAuB,CAAC,CAElC"}
@@ -13,6 +13,7 @@ import { mkdir } from "node:fs/promises";
13
13
  import { join } from "node:path";
14
14
  import { closeEach, withCleanup } from "./cleanup.js";
15
15
  import { dialectOf } from "./dialect.js";
16
+ import { isStorageResponseRefusal } from "./errors.js";
16
17
  import { discoverLegacyJournal, ensureRunJournalSchema, isReadableRunJournalVersion, legacyDefaultJournalPath, runJournalTables, } from "./journal-adoption.js";
17
18
  import { isFinishedJournalStatus, JOURNAL_CATALOG_FILE, JournalCatalog, } from "./journal-catalog.js";
18
19
  import { openNodeSqliteDatabase } from "./node-sqlite.js";
@@ -106,10 +107,6 @@ async function schemaVersion(executor, t) {
106
107
  const rows = await executor.all(`SELECT schema_version FROM ${t.meta}`);
107
108
  return rows.length === 1 ? rows[0].schema_version : undefined;
108
109
  }
109
- /**
110
- * Opens a journal file for an export and begins its read transaction; the reason when it cannot. `open` opens a
111
- * named selection's database instead, which is read without a transaction: its runs are each read whole.
112
- */
113
110
  async function openExportSource(path, t, shardId, open) {
114
111
  if (open === undefined && !existsSync(path))
115
112
  return { path, reason: "the journal file no longer exists", oldFormat: false };
@@ -132,7 +129,21 @@ async function openExportSource(path, t, shardId, open) {
132
129
  await closeExportSource({ database, snapshot: open === undefined });
133
130
  return { path, reason: `unsupported journal schema version ${String(version)}`, oldFormat: false };
134
131
  }
135
- const runs = await database.all(`SELECT * FROM ${t.runs} ORDER BY run_id`);
132
+ const request = database.all(`SELECT * FROM ${t.runs} ORDER BY run_id`);
133
+ let runs;
134
+ try {
135
+ runs = await request;
136
+ }
137
+ catch (error) {
138
+ if (open === undefined || !isStorageResponseRefusal(error))
139
+ throw error;
140
+ return {
141
+ oldFormat: "refused",
142
+ path,
143
+ reader: database,
144
+ failure: error,
145
+ };
146
+ }
136
147
  return {
137
148
  path,
138
149
  database,
@@ -147,6 +158,63 @@ async function openExportSource(path, t, shardId, open) {
147
158
  return { path, reason: `the journal file cannot be read: ${error.message}`, oldFormat: false };
148
159
  }
149
160
  }
161
+ function singleExportId(ids) {
162
+ let selected;
163
+ let count = 0;
164
+ for (const id of ids ?? []) {
165
+ if (++count > 1)
166
+ return undefined;
167
+ selected = id;
168
+ }
169
+ return selected;
170
+ }
171
+ function catalogRefusal({ path, failure }) {
172
+ return new StorageTransferError({ path, reason: `the journal file cannot be read: ${failure.message}` });
173
+ }
174
+ async function exportSelectedAfterRefusal(refused, id, options, directory, t) {
175
+ const { reader: database, path } = refused;
176
+ let refusedPoint;
177
+ const header = async (tx, columns) => {
178
+ const version = await schemaVersion(tx, t);
179
+ if (!isReadableRunJournalVersion(version))
180
+ throw new StorageTransferError({ path, reason: `unsupported journal schema version ${String(version)}` });
181
+ const row = await tx.get(`SELECT ${columns} FROM ${t.runs} WHERE run_id = ?`, id).catch((error) => {
182
+ if (isStorageResponseRefusal(error))
183
+ refusedPoint = error;
184
+ throw error;
185
+ });
186
+ if (!row)
187
+ throw new StorageTransferError({ path, id, reason: `run ${id} is not in this workflow journal` });
188
+ return row;
189
+ };
190
+ try {
191
+ const { run, events } = await database.transaction(async (tx) => {
192
+ const run = await header(tx, "*");
193
+ const events = await withJournalPayloads(tx, t.eventChunks, await tx.all(`SELECT * FROM ${t.events} WHERE run_id = ? ORDER BY seq`, id));
194
+ return { run, events };
195
+ }, { readOnly: true });
196
+ // Do not publish a run deleted or upgraded during recovery. The header body was already read with its events.
197
+ await database.transaction((tx) => header(tx, "1 AS found"), { readOnly: true });
198
+ // Only a complete, supported run reaches the caller's remaining selection options, outside the transaction.
199
+ let included = !options.unfinished || !isFinishedJournalStatus(run.status) ? [id] : [];
200
+ if (options.limit !== undefined)
201
+ included = included.slice(0, options.limit);
202
+ if (included.length === 0) {
203
+ await mkdir(directory, { recursive: true });
204
+ return { written: [], unchanged: [], skipped: [] };
205
+ }
206
+ const file = transferFile(directory, id), lines = exportLines(run, events, path);
207
+ await mkdir(directory, { recursive: true });
208
+ const outcome = await writeLinesAtomically(file, lines);
209
+ return { written: outcome === "written" ? [id] : [], unchanged: outcome === "written" ? [] : [id], skipped: [] };
210
+ }
211
+ catch (error) {
212
+ // Only the confirmed header refusal goes back to the caller's close-before-diagnostic path.
213
+ if (refusedPoint !== undefined && error === refusedPoint)
214
+ return undefined;
215
+ throw error;
216
+ }
217
+ }
150
218
  async function closeExportSource(source) {
151
219
  if (source.snapshot)
152
220
  await source.database.exec("COMMIT").catch(() => undefined);
@@ -280,6 +348,7 @@ export async function exportWorkflowRuns(storage, directory, options = {}) {
280
348
  const skipped = [];
281
349
  const sources = new ExportSources(t);
282
350
  let single;
351
+ let refused;
283
352
  return withCleanup(async () => {
284
353
  const listed = new Map();
285
354
  const unexported = new Map();
@@ -288,6 +357,8 @@ export async function exportWorkflowRuns(storage, directory, options = {}) {
288
357
  const opened = await openExportSource(storageLocation(storage), t, undefined, storage.kind === "database" ? storage.open : undefined);
289
358
  if ("database" in opened)
290
359
  single = opened;
360
+ else if (opened.oldFormat === "refused")
361
+ refused = opened;
291
362
  // A named database that cannot be read fails the export: an empty export would pass for a backup.
292
363
  else if (storage.kind === "database" && !opened.oldFormat)
293
364
  throw new StorageTransferError({ path: opened.path, reason: opened.reason });
@@ -320,6 +391,18 @@ export async function exportWorkflowRuns(storage, directory, options = {}) {
320
391
  listed.set(run.run_id, { source, run });
321
392
  }
322
393
  let selected = [...listed.values()];
394
+ if (refused !== undefined) {
395
+ const id = singleExportId(options.runs);
396
+ if (id !== undefined) {
397
+ const report = await exportSelectedAfterRefusal(refused, id, options, directory, t);
398
+ if (report !== undefined)
399
+ return report;
400
+ }
401
+ const original = refused;
402
+ refused = undefined;
403
+ await original.reader.close().catch(() => undefined);
404
+ throw catalogRefusal(original);
405
+ }
323
406
  if (options.runs !== undefined) {
324
407
  for (const runId of options.runs) {
325
408
  if (listed.has(runId))
@@ -363,6 +446,8 @@ export async function exportWorkflowRuns(storage, directory, options = {}) {
363
446
  await sources.close();
364
447
  if (single !== undefined)
365
448
  await closeExportSource(single);
449
+ if (refused !== undefined)
450
+ await refused.reader.close();
366
451
  });
367
452
  }
368
453
  function isObject(value) {
@@ -1 +1 @@
1
- {"version":3,"file":"journal-transfer.js","sourceRoot":"","sources":["../../../src/core/storage/journal-transfer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC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orkflowRuns` writes each run of a local workflow\n * journal to `<dir>/<runId>.jsonl`, and the import functions restore such files into one. The journal stays the\n * working store; the files are the form runs take at rest, so a host that persists only files can carry them between\n * machines. `atomic storage export` and `import` use `<exportDir>/workflows` as `<dir>`.\n *\n * Line 1 of a file is the run's header: the row of the journal's runs table. Every later line is one row of its\n * events table, in sequence order, with its payload as a JSON value instead of JSON text. Leases, local-worker pool\n * state and worktree snapshot blobs are not exported: they belong to the machine that wrote them.\n */\n\nimport { existsSync } from \"node:fs\";\nimport { mkdir } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { closeEach, withCleanup } from \"./cleanup.js\";\nimport type { SqliteDatabase, SqliteExecutor, SqliteRow, SqliteValue } from \"./database.js\";\nimport { dialectOf, type StorageDialect } from \"./dialect.js\";\nimport type { StorageFailureCause } from \"./errors.js\";\nimport {\n\tdiscoverLegacyJournal,\n\tensureRunJournalSchema,\n\tisReadableRunJournalVersion,\n\ttype JournalEventTableRow,\n\ttype JournalLeaseTableRow,\n\ttype JournalRunTableRow,\n\tlegacyDefaultJournalPath,\n\trunJournalTables,\n} from \"./journal-adoption.js\";\nimport {\n\tisFinishedJournalStatus,\n\tJOURNAL_CATALOG_FILE,\n\tJournalCatalog,\n\ttype JournalCatalogRun,\n\ttype JournalShardRecord,\n} from \"./journal-catalog.js\";\nimport { openNodeSqliteDatabase } from \"./node-sqlite.js\";\nimport {\n\tRUN_EVENT_TYPES,\n\tstoredJournalPayload,\n\twithJournalPayloads,\n\twriteJournalPayloadChunks,\n} from \"./run-journal.js\";\nimport {\n\treadTransferDirectory,\n\tStorageImportIncompleteError,\n\tStorageTransferError,\n\ttype TransferFileLines,\n\ttransferFile,\n\twriteLinesAtomically,\n} from \"./transfer-files.js\";\n\n/** The `type` of an export file's header line. */\nexport const WORKFLOW_RUN_EXPORT_TYPE = \"atomic.workflow-run\";\n/** The export format version this Atomic writes and reads. */\nexport const WORKFLOW_RUN_EXPORT_VERSION = 1;\n/**\n * A lease renewed this recently belongs to a process that may still be running the run on this machine, so an import\n * does not add events to that run. It matches the window in which the workflows runtime treats a running run's owner\n * as live.\n */\nexport const WORKFLOW_RUN_IMPORT_LIVE_LEASE_MS = 120_000;\n/**\n * How many times an export reads the catalog again after reading the journal files, for runs a consolidation moved\n * in between; a run still not found where the catalog names it after the last read is reported with its reason.\n */\nexport const WORKFLOW_RUN_EXPORT_PLACEMENT_ATTEMPTS = 5;\n\n/** A JSON value as an export file holds it. */\nexport type WorkflowRunExportValue =\n\t| string\n\t| number\n\t| boolean\n\t| null\n\t| readonly WorkflowRunExportValue[]\n\t| { readonly [key: string]: WorkflowRunExportValue };\n\n/** Line 1 of an export file. */\nexport interface WorkflowRunExportHeader {\n\treadonly type: typeof WORKFLOW_RUN_EXPORT_TYPE;\n\treadonly version: typeof WORKFLOW_RUN_EXPORT_VERSION;\n\treadonly runId: string;\n\treadonly name: string;\n\treadonly cwd: string;\n\treadonly createdAt: number;\n\t/** The run's latest status. */\n\treadonly status: string;\n\t/** How many event lines follow. */\n\treadonly events: number;\n\t/** The run header the journal recorded when the run was created. */\n\treadonly header: { readonly [key: string]: WorkflowRunExportValue };\n}\n\n/** One event line of an export file: one journal entry. */\nexport interface WorkflowRunExportEvent {\n\treadonly type: string;\n\treadonly seq: number;\n\treadonly epoch: number;\n\treadonly key: string | null;\n\treadonly at: number;\n\treadonly payload: WorkflowRunExportValue;\n}\n\n/**\n * The workflow journal storage that runs are exported from and imported into: the local journal store, a SQLite file,\n * or a database a named selection opens (`open` is called for each use and the database closed after it; `location`\n * names it in reports and errors).\n */\nexport type WorkflowRunTransferStorage =\n\t| { readonly kind: \"store\"; readonly directory: string }\n\t| { readonly kind: \"sqlite\"; readonly path: string; readonly prefix?: string }\n\t| {\n\t\t\treadonly kind: \"database\";\n\t\t\treadonly open: () => Promise<SqliteDatabase>;\n\t\t\treadonly location: string;\n\t\t\treadonly prefix?: string;\n\t };\n\nexport interface WorkflowRunExportOptions {\n\t/** Only these runs; a run the storage does not hold fails the export before any file is written. */\n\treadonly runs?: readonly string[];\n\t/** Only runs that are not completed, failed or cancelled. */\n\treadonly unfinished?: boolean;\n\t/** At most this many runs, newest first. */\n\treadonly limit?: number;\n}\n\nexport interface WorkflowRunExportReport {\n\t/** Runs whose file was written. */\n\treadonly written: readonly string[];\n\t/** Runs whose file already held exactly this export, left untouched. */\n\treadonly unchanged: readonly string[];\n\t/** Journal files that could not be read, and catalogued runs that could not be exported, with the reason. */\n\treadonly skipped: readonly { readonly path: string; readonly runId?: string; readonly reason: string }[];\n}\n\nexport interface WorkflowRunImportReport {\n\t/** Runs the storage did not hold. */\n\treadonly added: readonly string[];\n\t/** Runs the storage held an earlier part of, which now have the file's later events. */\n\treadonly updated: readonly string[];\n\t/** Runs the storage already held every event of. */\n\treadonly unchanged: readonly string[];\n}\n\nconst TRANSFER_TRANSACTION = { lockWaitMs: 10 * 60_000 } as const;\nconst EVENT_TYPES: ReadonlySet<string> = new Set(Object.values(RUN_EVENT_TYPES));\nconst HEADER_FIELDS = [\"type\", \"version\", \"runId\", \"name\", \"cwd\", \"createdAt\", \"status\", \"events\", \"header\"] as const;\nconst EVENT_FIELDS = [\"type\", \"seq\", \"epoch\", \"key\", \"at\", \"payload\"] as const;\n/** The runs table of the journal format before 0.9.38, which an export cannot read. */\nconst LEGACY_RUNS_TABLE = \"runs\";\nconst OLD_FORMAT_REASON = \"it is in the journal format of Atomic before 0.9.38; resume it once to convert it\";\n\ntype JsonObject = { readonly [key: string]: WorkflowRunExportValue };\ntype Tables = ReturnType<typeof runJournalTables>;\n\nfunction storageLocation(storage: WorkflowRunTransferStorage): string {\n\treturn storage.kind === \"store\" ? storage.directory : storage.kind === \"sqlite\" ? storage.path : storage.location;\n}\n\nfunction storagePrefix(storage: WorkflowRunTransferStorage): string | undefined {\n\treturn storage.kind === \"store\" ? undefined : storage.prefix;\n}\n\nfunction parseStored(text: string, path: string, runId: string, what: string): WorkflowRunExportValue {\n\ttry {\n\t\treturn JSON.parse(text) as WorkflowRunExportValue;\n\t} catch (cause) {\n\t\tthrow new StorageTransferError({\n\t\t\tpath,\n\t\t\tid: runId,\n\t\t\treason: `run ${runId} has ${what} that is not valid JSON`,\n\t\t\tcause: cause as StorageFailureCause,\n\t\t});\n\t}\n}\n\n/** A run and its events as the lines of its export file. */\nfunction exportLines(run: JournalRunTableRow, events: readonly JournalEventTableRow[], path: string): string[] {\n\tconst header = parseStored(run.header_json, path, run.run_id, \"a header\");\n\tif (!isObject(header))\n\t\tthrow new StorageTransferError({\n\t\t\tpath,\n\t\t\tid: run.run_id,\n\t\t\treason: `run ${run.run_id} has a header that is not an object`,\n\t\t});\n\tconst lines = [\n\t\tJSON.stringify({\n\t\t\ttype: WORKFLOW_RUN_EXPORT_TYPE,\n\t\t\tversion: WORKFLOW_RUN_EXPORT_VERSION,\n\t\t\trunId: run.run_id,\n\t\t\tname: run.name,\n\t\t\tcwd: run.cwd,\n\t\t\tcreatedAt: Number(run.created_at),\n\t\t\tstatus: run.status,\n\t\t\tevents: events.length,\n\t\t\theader,\n\t\t} satisfies WorkflowRunExportHeader),\n\t];\n\tfor (const event of events)\n\t\tlines.push(\n\t\t\tJSON.stringify({\n\t\t\t\ttype: event.type,\n\t\t\t\tseq: Number(event.seq),\n\t\t\t\tepoch: Number(event.epoch),\n\t\t\t\tkey: event.key,\n\t\t\t\tat: Number(event.at),\n\t\t\t\tpayload: parseStored(event.payload, path, run.run_id, `event ${event.seq} with a payload`),\n\t\t\t} satisfies WorkflowRunExportEvent),\n\t\t);\n\treturn lines;\n}\n\nasync function hasTables(executor: SqliteExecutor, t: Tables, dialect: StorageDialect): Promise<boolean> {\n\tfor (const table of [t.meta, t.runs, t.events]) if (!(await hasTable(executor, table, dialect))) return false;\n\treturn true;\n}\n\nasync function hasTable(executor: SqliteExecutor, name: string, dialect: StorageDialect): Promise<boolean> {\n\tconst exists = dialect.tableExists(name);\n\treturn (await executor.get(exists.sql, ...exists.params)) !== undefined;\n}\n\nasync function schemaVersion(executor: SqliteExecutor, t: Tables): Promise<SqliteValue | undefined> {\n\tconst rows = await executor.all<SqliteRow & { schema_version: SqliteValue }>(`SELECT schema_version FROM ${t.meta}`);\n\treturn rows.length === 1 ? rows[0]!.schema_version : undefined;\n}\n\n/** One journal file an export reads, inside one read transaction, so every run it holds is read as of one moment. */\ninterface ExportSource {\n\treadonly path: string;\n\treadonly shardId?: number;\n\treadonly database: SqliteDatabase;\n\t/** Whether the source is read in one read transaction, which closing it ends. */\n\treadonly snapshot: boolean;\n\treadonly runs: readonly JournalRunTableRow[];\n\treadonly byId: ReadonlyMap<string, JournalRunTableRow>;\n}\n\n/** A journal file an export could not read, and whether that is because it holds only the format before 0.9.38. */\ninterface UnreadableSource {\n\treadonly path: string;\n\treadonly reason: string;\n\treadonly oldFormat: boolean;\n}\n\n/**\n * Opens a journal file for an export and begins its read transaction; the reason when it cannot. `open` opens a\n * named selection's database instead, which is read without a transaction: its runs are each read whole.\n */\nasync function openExportSource(\n\tpath: string,\n\tt: Tables,\n\tshardId: number | undefined,\n\topen?: () => Promise<SqliteDatabase>,\n): Promise<ExportSource | UnreadableSource> {\n\tif (open === undefined && !existsSync(path))\n\t\treturn { path, reason: \"the journal file no longer exists\", oldFormat: false };\n\tlet database: SqliteDatabase;\n\ttry {\n\t\tdatabase = await (open ?? (() => openNodeSqliteDatabase(path, { readOnly: true })))();\n\t} catch (error) {\n\t\treturn { path, reason: `the journal file cannot be opened: ${(error as Error).message}`, oldFormat: false };\n\t}\n\ttry {\n\t\tif (open === undefined) await database.exec(\"BEGIN\");\n\t\tif (!(await hasTables(database, t, dialectOf(database)))) {\n\t\t\tawait closeExportSource({ database, snapshot: open === undefined });\n\t\t\treturn { path, reason: \"it has no workflow runs in the current journal format\", oldFormat: true };\n\t\t}\n\t\tconst version = await schemaVersion(database, t);\n\t\tif (!isReadableRunJournalVersion(version)) {\n\t\t\tawait closeExportSource({ database, snapshot: open === undefined });\n\t\t\treturn { path, reason: `unsupported journal schema version ${String(version)}`, oldFormat: false };\n\t\t}\n\t\tconst runs = await database.all<JournalRunTableRow>(`SELECT * FROM ${t.runs} ORDER BY run_id`);\n\t\treturn {\n\t\t\tpath,\n\t\t\tdatabase,\n\t\t\tsnapshot: open === undefined,\n\t\t\truns,\n\t\t\tbyId: new Map(runs.map((run) => [run.run_id, run])),\n\t\t\t...(shardId === undefined ? {} : { shardId }),\n\t\t};\n\t} catch (error) {\n\t\tawait database.close().catch(() => undefined);\n\t\treturn { path, reason: `the journal file cannot be read: ${(error as Error).message}`, oldFormat: false };\n\t}\n}\n\nasync function closeExportSource(source: Pick<ExportSource, \"database\" | \"snapshot\">): Promise<void> {\n\tif (source.snapshot) await source.database.exec(\"COMMIT\").catch(() => undefined);\n\tawait source.database.close();\n}\n\n/**\n * Adopts the default journal of Atomic before the journal store, as opening the store does, so its runs are exported\n * and compared like every other run; whether the store has a catalog.\n */\nasync function adoptLegacyJournal(directory: string): Promise<boolean> {\n\tif (existsSync(legacyDefaultJournalPath(directory))) {\n\t\tconst catalog = await JournalCatalog.open(directory);\n\t\tawait withCleanup(\n\t\t\tasync () => {\n\t\t\t\tawait discoverLegacyJournal(catalog, legacyDefaultJournalPath(directory));\n\t\t\t},\n\t\t\t() => catalog.close(),\n\t\t);\n\t}\n\treturn existsSync(join(directory, JOURNAL_CATALOG_FILE));\n}\n\n/** What the catalog of a journal store says at one moment: its shards, and its runs with the shard each is on. */\ninterface CatalogView {\n\treadonly shards: readonly JournalShardRecord[];\n\treadonly runs: readonly JournalCatalogRun[];\n\treadonly owners: ReadonlyMap<string, number>;\n}\n\nasync function readCatalog(directory: string): Promise<CatalogView> {\n\tconst catalog = await JournalCatalog.open(directory);\n\treturn withCleanup(\n\t\tasync () => {\n\t\t\tconst shards = await catalog.shards();\n\t\t\tconst runs = await catalog.runs();\n\t\t\treturn { shards, runs, owners: new Map(runs.map((run) => [run.runId, run.shard])) };\n\t\t},\n\t\t() => catalog.close(),\n\t);\n}\n\nfunction newestFirst(left: JournalRunTableRow, right: JournalRunTableRow): number {\n\tconst created = Number(right.created_at) - Number(left.created_at);\n\tif (created !== 0) return created;\n\treturn left.run_id < right.run_id ? -1 : left.run_id > right.run_id ? 1 : 0;\n}\n\n/** The journal files of a store an export reads, by shard, kept open in their read transactions until it finishes. */\nclass ExportSources {\n\treadonly opened = new Map<number, ExportSource>();\n\treadonly unreadable = new Map<number, UnreadableSource>();\n\n\tprivate readonly t: Tables;\n\n\tconstructor(t: Tables) {\n\t\tthis.t = t;\n\t}\n\n\t/** Opens every shard of `view` not opened yet, and opens `fresh` again with a new snapshot. */\n\tasync open(view: CatalogView, fresh: ReadonlySet<number> = new Set()): Promise<void> {\n\t\tfor (const shard of view.shards) {\n\t\t\tconst current = this.opened.get(shard.id);\n\t\t\tif (current !== undefined && !fresh.has(shard.id)) continue;\n\t\t\tif (current === undefined && this.unreadable.has(shard.id) && !fresh.has(shard.id)) continue;\n\t\t\tif (current !== undefined) {\n\t\t\t\tthis.opened.delete(shard.id);\n\t\t\t\tawait closeExportSource(current);\n\t\t\t}\n\t\t\tthis.unreadable.delete(shard.id);\n\t\t\tconst source = await openExportSource(shard.path, this.t, shard.id);\n\t\t\tif (\"database\" in source) this.opened.set(shard.id, source);\n\t\t\telse this.unreadable.set(shard.id, source);\n\t\t}\n\t}\n\n\t/** The catalogued runs of `view` that the snapshot of the shard the catalog names for them does not hold. */\n\tmissing(view: CatalogView): JournalCatalogRun[] {\n\t\treturn view.runs.filter((run) => {\n\t\t\tconst source = this.opened.get(run.shard);\n\t\t\treturn run.status !== undefined && source !== undefined && !source.byId.has(run.runId);\n\t\t});\n\t}\n\n\tclose(): Promise<void> {\n\t\treturn closeEach([...this.opened.values()].map((source) => ({ close: () => closeExportSource(source) })));\n\t}\n}\n\n/**\n * Reads a journal store's catalog and opens its shards, then reads the catalog again for every run the shard it named\n * did not hold: a consolidation may have moved the run between the two reads, into an existing shard or one it\n * created. The shard the run moved to is read again, and so on until the placements agree or the attempts run out.\n */\nasync function settleExportSources(directory: string, sources: ExportSources): Promise<CatalogView> {\n\tlet view = await readCatalog(directory);\n\tawait sources.open(view);\n\tfor (let attempt = 1; attempt < WORKFLOW_RUN_EXPORT_PLACEMENT_ATTEMPTS; attempt++) {\n\t\tconst missing = sources.missing(view);\n\t\tif (missing.length === 0) return view;\n\t\tconst next = await readCatalog(directory);\n\t\tconst moved = new Set<number>();\n\t\tfor (const run of missing) {\n\t\t\tconst now = next.owners.get(run.runId);\n\t\t\tif (now !== undefined && now !== run.shard) moved.add(now);\n\t\t}\n\t\tconst added = next.shards.some((shard) => !sources.opened.has(shard.id) && !sources.unreadable.has(shard.id));\n\t\tview = next;\n\t\tif (moved.size === 0 && !added) return view;\n\t\tawait sources.open(view, moved);\n\t}\n\treturn view;\n}\n\n/** Why a catalogued run that its shard's snapshot does not hold, or whose shard could not be read, is not exported. */\nasync function missingRunReason(\n\trun: JournalCatalogRun,\n\tview: CatalogView,\n\tsources: ExportSources,\n): Promise<{ path: string; runId: string; reason: string }> {\n\tconst unreadable = sources.unreadable.get(run.shard);\n\tif (unreadable !== undefined)\n\t\treturn {\n\t\t\tpath: unreadable.path,\n\t\t\trunId: run.runId,\n\t\t\treason: unreadable.oldFormat ? OLD_FORMAT_REASON : `its journal file cannot be read: ${unreadable.reason}`,\n\t\t};\n\tconst source = sources.opened.get(run.shard);\n\tif (source === undefined) {\n\t\tconst path = view.shards.find((shard) => shard.id === run.shard)?.path ?? `shard ${run.shard}`;\n\t\treturn { path, runId: run.runId, reason: `the catalog names shard ${run.shard} for it, which it does not list` };\n\t}\n\tif (\n\t\t(await hasTable(source.database, LEGACY_RUNS_TABLE, dialectOf(source.database))) &&\n\t\t(await source.database.get(`SELECT 1 AS found FROM ${LEGACY_RUNS_TABLE} WHERE run_id = ?`, run.runId))\n\t)\n\t\treturn { path: source.path, runId: run.runId, reason: OLD_FORMAT_REASON };\n\treturn {\n\t\tpath: source.path,\n\t\trunId: run.runId,\n\t\treason:\n\t\t\t\"the journal file the catalog names for it does not hold it; it was moved or deleted while the export ran, so export again\",\n\t};\n}\n\n/**\n * Exports runs of a local workflow journal to `<directory>/<runId>.jsonl`, one file per run. Each journal file is read\n * in one read transaction, and each export file is written whole or not at all. The same journal state gives the same\n * bytes, and a file that already holds them is not rewritten. A run the store's catalog lists is taken only from the\n * shard the catalog names for it, read again when a consolidation moved it while the export ran; one that cannot be\n * exported is reported with the reason.\n */\nexport async function exportWorkflowRuns(\n\tstorage: WorkflowRunTransferStorage,\n\tdirectory: string,\n\toptions: WorkflowRunExportOptions = {},\n): Promise<WorkflowRunExportReport> {\n\tconst t = runJournalTables(storagePrefix(storage));\n\tconst skipped: { path: string; runId?: string; reason: string }[] = [];\n\tconst sources = new ExportSources(t);\n\tlet single: ExportSource | undefined;\n\treturn withCleanup(\n\t\tasync () => {\n\t\t\tconst listed = new Map<string, { readonly source: ExportSource; readonly run: JournalRunTableRow }>();\n\t\t\tconst unexported = new Map<string, { path: string; runId: string; reason: string }>();\n\t\t\tif (storage.kind === \"sqlite\" || storage.kind === \"database\") {\n\t\t\t\tif (storage.kind === \"database\" || existsSync(storage.path)) {\n\t\t\t\t\tconst opened = await openExportSource(\n\t\t\t\t\t\tstorageLocation(storage),\n\t\t\t\t\t\tt,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tstorage.kind === \"database\" ? storage.open : undefined,\n\t\t\t\t\t);\n\t\t\t\t\tif (\"database\" in opened) single = opened;\n\t\t\t\t\t// A named database that cannot be read fails the export: an empty export would pass for a backup.\n\t\t\t\t\telse if (storage.kind === \"database\" && !opened.oldFormat)\n\t\t\t\t\t\tthrow new StorageTransferError({ path: opened.path, reason: opened.reason });\n\t\t\t\t\telse skipped.push({ path: opened.path, reason: opened.reason });\n\t\t\t\t}\n\t\t\t\tfor (const run of single?.runs ?? []) listed.set(run.run_id, { source: single!, run });\n\t\t\t} else if (await adoptLegacyJournal(storage.directory)) {\n\t\t\t\tconst view = await settleExportSources(storage.directory, sources);\n\t\t\t\tconst catalogued = new Set<number>(view.runs.map((run) => run.shard));\n\t\t\t\tfor (const [id, unreadable] of sources.unreadable)\n\t\t\t\t\tif (!catalogued.has(id)) skipped.push({ path: unreadable.path, reason: unreadable.reason });\n\t\t\t\tfor (const run of view.runs) {\n\t\t\t\t\tconst source = sources.opened.get(run.shard);\n\t\t\t\t\tconst row = source?.byId.get(run.runId);\n\t\t\t\t\tif (source !== undefined && row !== undefined) listed.set(run.runId, { source, run: row });\n\t\t\t\t\telse if (run.status !== undefined) unexported.set(run.runId, await missingRunReason(run, view, sources));\n\t\t\t\t}\n\t\t\t\t// A run no catalog entry names yet (another process wrote it to a shard) is taken from the first shard\n\t\t\t\t// holding it. A catalogued run is never taken from another shard, which may hold an older copy an\n\t\t\t\t// interrupted consolidation left behind.\n\t\t\t\tfor (const source of sources.opened.values())\n\t\t\t\t\tfor (const run of source.runs)\n\t\t\t\t\t\tif (!view.owners.has(run.run_id) && !listed.has(run.run_id)) listed.set(run.run_id, { source, run });\n\t\t\t}\n\t\t\tlet selected = [...listed.values()];\n\t\t\tif (options.runs !== undefined) {\n\t\t\t\tfor (const runId of options.runs) {\n\t\t\t\t\tif (listed.has(runId)) continue;\n\t\t\t\t\tconst reason = unexported.get(runId);\n\t\t\t\t\tthrow new StorageTransferError({\n\t\t\t\t\t\tpath: reason?.path ?? storageLocation(storage),\n\t\t\t\t\t\tid: runId,\n\t\t\t\t\t\treason:\n\t\t\t\t\t\t\treason === undefined\n\t\t\t\t\t\t\t\t? `run ${runId} is not in this workflow journal`\n\t\t\t\t\t\t\t\t: `run ${runId} cannot be exported: ${reason.reason}`,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tselected = [...new Set(options.runs)].map((runId) => listed.get(runId)!);\n\t\t\t} else skipped.push(...unexported.values());\n\t\t\tif (options.unfinished) selected = selected.filter(({ run }) => !isFinishedJournalStatus(run.status));\n\t\t\tselected.sort((left, right) => newestFirst(left.run, right.run));\n\t\t\tif (options.limit !== undefined) selected = selected.slice(0, options.limit);\n\t\t\tawait mkdir(directory, { recursive: true });\n\t\t\tconst written: string[] = [];\n\t\t\tconst unchanged: string[] = [];\n\t\t\tfor (const { source, run: listedRun } of selected) {\n\t\t\t\tconst readEvents = async (executor: SqliteExecutor) =>\n\t\t\t\t\twithJournalPayloads(\n\t\t\t\t\t\texecutor,\n\t\t\t\t\t\tt.eventChunks,\n\t\t\t\t\t\tawait executor.all<JournalEventTableRow>(\n\t\t\t\t\t\t\t`SELECT * FROM ${t.events} WHERE run_id = ? ORDER BY seq`,\n\t\t\t\t\t\t\tlistedRun.run_id,\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t// A source without a read snapshot reads each run's row and events together, in one transaction, so a\n\t\t\t\t// run that finishes meanwhile is exported with the status its events reach.\n\t\t\t\tconst { run, events } = source.snapshot\n\t\t\t\t\t? { run: listedRun, events: await readEvents(source.database) }\n\t\t\t\t\t: await source.database.transaction(async (tx) => ({\n\t\t\t\t\t\t\trun:\n\t\t\t\t\t\t\t\t(await tx.get<JournalRunTableRow>(\n\t\t\t\t\t\t\t\t\t`SELECT * FROM ${t.runs} WHERE run_id = ?`,\n\t\t\t\t\t\t\t\t\tlistedRun.run_id,\n\t\t\t\t\t\t\t\t)) ?? listedRun,\n\t\t\t\t\t\t\tevents: await readEvents(tx),\n\t\t\t\t\t\t}));\n\t\t\t\tconst outcome = await writeLinesAtomically(\n\t\t\t\t\ttransferFile(directory, run.run_id),\n\t\t\t\t\texportLines(run, events, source.path),\n\t\t\t\t);\n\t\t\t\t(outcome === \"written\" ? written : unchanged).push(run.run_id);\n\t\t\t}\n\t\t\treturn { written, unchanged, skipped };\n\t\t},\n\t\tasync () => {\n\t\t\tawait sources.close();\n\t\t\tif (single !== undefined) await closeExportSource(single);\n\t\t},\n\t);\n}\n\n/** A run read from an export file and checked: everything an import writes for it. */\nexport interface ParsedWorkflowRun {\n\treadonly file: string;\n\treadonly header: WorkflowRunExportHeader;\n\treadonly events: readonly WorkflowRunExportEvent[];\n}\n\nfunction isObject(value: WorkflowRunExportValue | undefined): value is JsonObject {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction invalidText(value: string): string | undefined {\n\tif (value.includes(\"\\u0000\")) return \"contains a NUL character\";\n\tif (/\\p{Surrogate}/u.test(value)) return \"is not well-formed Unicode\";\n\treturn undefined;\n}\n\nfunction counter(value: WorkflowRunExportValue | undefined, minimum: number): value is number {\n\treturn typeof value === \"number\" && Number.isSafeInteger(value) && value >= minimum;\n}\n\n/** Checks that a line has exactly `fields`; the reason when it does not. */\nfunction fieldsReason(line: JsonObject, fields: readonly string[]): string | undefined {\n\tfor (const field of fields) if (!(field in line)) return `has no \"${field}\" field`;\n\tfor (const field of Object.keys(line)) if (!fields.includes(field)) return `has an unexpected \"${field}\" field`;\n\treturn undefined;\n}\n\n/** Checks one export file, throwing a `StorageTransferError` that names the file and line. */\nfunction parseExportFile({ file, lines }: TransferFileLines): ParsedWorkflowRun {\n\tconst fail = (line: number | undefined, reason: string, runId?: string): never => {\n\t\tthrow new StorageTransferError({ path: file, ...(line === undefined ? {} : { line }), id: runId, reason });\n\t};\n\tif (lines.length === 0) return fail(1, \"is empty; expected a workflow run header\");\n\tconst parse = (index: number): JsonObject => {\n\t\tconst line = lines[index]!.text;\n\t\tif (line.trim() === \"\") return fail(index + 1, \"is empty\");\n\t\tlet value: WorkflowRunExportValue;\n\t\ttry {\n\t\t\tvalue = JSON.parse(line) as WorkflowRunExportValue;\n\t\t} catch (error) {\n\t\t\treturn fail(index + 1, `is not valid JSON (${(error as Error).message})`);\n\t\t}\n\t\tif (!isObject(value)) return fail(index + 1, \"is not a JSON object\");\n\t\tif (typeof value.type !== \"string\") return fail(index + 1, 'has no string \"type\"');\n\t\treturn value;\n\t};\n\tconst first = parse(0);\n\tif (first.type !== WORKFLOW_RUN_EXPORT_TYPE)\n\t\tfail(1, `is not an Atomic workflow run export: its type is \"${first.type}\", not \"${WORKFLOW_RUN_EXPORT_TYPE}\"`);\n\tif (first.version !== WORKFLOW_RUN_EXPORT_VERSION)\n\t\tfail(\n\t\t\t1,\n\t\t\t`has unsupported export version ${JSON.stringify(first.version ?? null)}; this Atomic reads version ${WORKFLOW_RUN_EXPORT_VERSION}`,\n\t\t);\n\tconst headerFields = fieldsReason(first, HEADER_FIELDS);\n\tif (headerFields !== undefined) fail(1, headerFields);\n\tfor (const field of [\"runId\", \"name\", \"cwd\", \"status\"] as const) {\n\t\tconst value = first[field];\n\t\tif (typeof value !== \"string\") fail(1, `has a \"${field}\" that is not a string`);\n\t\tconst reason = invalidText(value as string);\n\t\tif (reason !== undefined) fail(1, `has a \"${field}\" that ${reason}`);\n\t}\n\tconst runId = first.runId as string;\n\tif (runId === \"\") fail(1, 'has an empty \"runId\"');\n\tif (!counter(first.createdAt, Number.MIN_SAFE_INTEGER)) fail(1, 'has a \"createdAt\" that is not an integer', runId);\n\tif (!counter(first.events, 0)) fail(1, 'has an \"events\" count that is not a non-negative integer', runId);\n\tif (!isObject(first.header)) fail(1, 'has a \"header\" that is not an object', runId);\n\tif ((first.header as JsonObject).runId !== runId)\n\t\tfail(1, `has a \"header\" whose runId is not the run's ID ${runId}`, runId);\n\tconst events: WorkflowRunExportEvent[] = [];\n\tconst keys = new Map<string, number>();\n\tfor (let index = 1; index < lines.length; index++) {\n\t\tconst line = index + 1;\n\t\tconst event = parse(index);\n\t\tconst reason = fieldsReason(event, EVENT_FIELDS);\n\t\tif (reason !== undefined) fail(line, reason, runId);\n\t\tif (!EVENT_TYPES.has(event.type as string)) fail(line, `has unknown event type \"${event.type}\"`, runId);\n\t\tif (event.seq !== index) fail(line, `has seq ${JSON.stringify(event.seq)}; expected ${index}`, runId);\n\t\tif (!counter(event.epoch, 0)) fail(line, 'has an \"epoch\" that is not a non-negative integer', runId);\n\t\tif (!counter(event.at, Number.MIN_SAFE_INTEGER)) fail(line, 'has an \"at\" that is not an integer', runId);\n\t\tconst key = event.key;\n\t\tif (key !== null) {\n\t\t\tif (typeof key !== \"string\") fail(line, 'has a \"key\" that is neither a string nor null', runId);\n\t\t\tconst keyReason = invalidText(key as string);\n\t\t\tif (keyReason !== undefined) fail(line, `has a \"key\" that ${keyReason}`, runId);\n\t\t\tconst earlier = keys.get(key as string);\n\t\t\tif (earlier !== undefined) fail(line, `repeats the key of line ${earlier}`, runId);\n\t\t\tkeys.set(key as string, line);\n\t\t}\n\t\tif (event.type === RUN_EVENT_TYPES.statusChanged) {\n\t\t\tconst status = isObject(event.payload) ? event.payload.status : undefined;\n\t\t\tif (typeof status !== \"string\")\n\t\t\t\tfail(line, 'is a StatusChanged event whose payload has no string \"status\"', runId);\n\t\t\tconst statusReason = invalidText(status as string);\n\t\t\tif (statusReason !== undefined) fail(line, `has a status that ${statusReason}`, runId);\n\t\t}\n\t\tevents.push({\n\t\t\ttype: event.type as string,\n\t\t\tseq: event.seq as number,\n\t\t\tepoch: event.epoch as number,\n\t\t\tkey: key as string | null,\n\t\t\tat: event.at as number,\n\t\t\tpayload: event.payload!,\n\t\t});\n\t}\n\tif (lines.length - 1 !== first.events)\n\t\tfail(1, `says the run has ${first.events} events, but the file has ${lines.length - 1} event lines`, runId);\n\tconst header: WorkflowRunExportHeader = {\n\t\ttype: WORKFLOW_RUN_EXPORT_TYPE,\n\t\tversion: WORKFLOW_RUN_EXPORT_VERSION,\n\t\trunId,\n\t\tname: first.name as string,\n\t\tcwd: first.cwd as string,\n\t\tcreatedAt: first.createdAt as number,\n\t\tstatus: first.status as string,\n\t\tevents: first.events as number,\n\t\theader: first.header as JsonObject,\n\t};\n\treturn { file, header, events };\n}\n\n/**\n * Reads and checks every `*.jsonl` export file in `directory`; nothing is written. A directory that does not exist\n * holds no runs. Throws `StorageTransferError` with the file and line for the first file that is not a valid export.\n */\nexport async function readWorkflowRunExports(directory: string): Promise<ParsedWorkflowRun[]> {\n\tconst parsed: ParsedWorkflowRun[] = [];\n\tconst files = new Map<string, string>();\n\tfor (const lines of await readTransferDirectory(directory)) {\n\t\tconst run = parseExportFile(lines);\n\t\tconst earlier = files.get(run.header.runId);\n\t\tif (earlier !== undefined)\n\t\t\tthrow new StorageTransferError({\n\t\t\t\tpath: run.file,\n\t\t\t\tline: 1,\n\t\t\t\tid: run.header.runId,\n\t\t\t\treason: `run ${run.header.runId} is also in ${earlier}; keep one file per run`,\n\t\t\t});\n\t\tfiles.set(run.header.runId, run.file);\n\t\tparsed.push(run);\n\t}\n\treturn parsed;\n}\n\n/** The fields import checks against a stored run: everything but string content, which a tool may redact. */\nfunction sameEntry(stored: JournalEventTableRow, exported: WorkflowRunExportEvent): boolean {\n\treturn (\n\t\tNumber(stored.seq) === exported.seq &&\n\t\tNumber(stored.epoch) === exported.epoch &&\n\t\tstored.key === exported.key &&\n\t\tstored.type === exported.type &&\n\t\tNumber(stored.at) === exported.at\n\t);\n}\n\ninterface StoredRun {\n\treadonly run: JournalRunTableRow;\n\treadonly events: readonly JournalEventTableRow[];\n\treadonly lease?: JournalLeaseTableRow & { readonly age_ms: number };\n}\n\nasync function readStoredRun(\n\texecutor: SqliteExecutor,\n\tt: Tables,\n\trunId: string,\n\tdialect: StorageDialect,\n): Promise<StoredRun | undefined> {\n\tif (!(await hasTables(executor, t, dialect))) return undefined;\n\tconst run = await executor.get<JournalRunTableRow>(`SELECT * FROM ${t.runs} WHERE run_id = ?`, runId);\n\tif (run === undefined) return undefined;\n\tconst events = await withJournalPayloads(\n\t\texecutor,\n\t\tt.eventChunks,\n\t\tawait executor.all<JournalEventTableRow>(`SELECT * FROM ${t.events} WHERE run_id = ? ORDER BY seq`, runId),\n\t);\n\tconst lease = (await hasTable(executor, t.leases, dialect))\n\t\t? await executor.get<JournalLeaseTableRow & { age_ms: number }>(\n\t\t\t\t`SELECT *, ${dialect.greatest(\"0\", `${dialect.nowMs} - renewed_at`)} AS age_ms FROM ${t.leases} WHERE run_id = ?`,\n\t\t\t\trunId,\n\t\t\t)\n\t\t: undefined;\n\treturn { run, events, ...(lease === undefined ? {} : { lease }) };\n}\n\n/**\n * What of a stored run an import depends on: its status, how many events it has and the last of them, and its lease.\n * A run whose fingerprint differs from the one the import checked was changed by another process in between.\n */\nfunction fingerprint(stored: StoredRun | undefined): string {\n\tif (stored === undefined) return \"absent\";\n\tconst last = stored.events.at(-1);\n\tconst lease = stored.lease;\n\treturn JSON.stringify([\n\t\tstored.run.status,\n\t\tNumber(stored.run.created_at),\n\t\tstored.events.length,\n\t\tlast === undefined ? null : [Number(last.seq), Number(last.epoch), last.key, last.type, Number(last.at)],\n\t\tlease === undefined ? null : [lease.holder_id, Number(lease.epoch), Number(lease.renewed_at)],\n\t]);\n}\n\n/** What an import does to one run. */\nexport type WorkflowRunImportAction = \"add\" | \"update\" | \"unchanged\";\n\n/**\n * What importing `parsed` does to the run as `stored` holds it: add it, add the file's later events, or nothing when\n * the storage already holds every event of the file. A run whose history differs from the file's, or that a process\n * here may still be running, fails with the file and line.\n */\nfunction importAction(\n\tparsed: ParsedWorkflowRun,\n\tstored: StoredRun | undefined,\n\tlocation: string,\n): WorkflowRunImportAction {\n\tif (stored === undefined) return \"add\";\n\tconst { header, events, file } = parsed;\n\tconst fail = (line: number, reason: string): never => {\n\t\tthrow new StorageTransferError({ path: file, line, id: header.runId, reason });\n\t};\n\tif (Number(stored.run.created_at) !== header.createdAt)\n\t\tfail(1, `run ${header.runId} in ${location} was created at another time; it is a different run with the same ID`);\n\tconst shared = Math.min(stored.events.length, events.length);\n\tfor (let index = 0; index < shared; index++)\n\t\tif (!sameEntry(stored.events[index]!, events[index]!))\n\t\t\tfail(\n\t\t\t\tindex + 2,\n\t\t\t\t`event ${index + 1} differs from event ${index + 1} of run ${header.runId} in ${location}: the run continued differently there`,\n\t\t\t);\n\tif (events.length <= stored.events.length) return \"unchanged\";\n\tconst lease = stored.lease;\n\tif (lease !== undefined && lease.holder_id !== null && Number(lease.age_ms) < WORKFLOW_RUN_IMPORT_LIVE_LEASE_MS)\n\t\tfail(\n\t\t\t1,\n\t\t\t`run ${header.runId} is held by ${lease.holder_id} in ${location}, which may still be running it; stop it and import again`,\n\t\t);\n\treturn \"update\";\n}\n\n/**\n * Writes the part of `parsed` that `stored` lacks inside the caller's transaction: the run row when it is new, the\n * events after the stored ones, the latest status, and an unheld lease at an epoch above every epoch the run's events\n * and any earlier holder used, so no holder from another machine is imported and a stale one here is fenced.\n */\nasync function writeImport(\n\ttx: SqliteExecutor,\n\tt: Tables,\n\tparsed: ParsedWorkflowRun,\n\tstored: StoredRun | undefined,\n\tdialect: StorageDialect,\n): Promise<void> {\n\tconst { header, events } = parsed;\n\tif (stored === undefined)\n\t\tawait tx.run(\n\t\t\t`INSERT INTO ${t.runs}(run_id, name, cwd, created_at, status, header_json) VALUES (?, ?, ?, ?, ?, ?)`,\n\t\t\theader.runId,\n\t\t\theader.name,\n\t\t\theader.cwd,\n\t\t\theader.createdAt,\n\t\t\theader.status,\n\t\t\tJSON.stringify(header.header),\n\t\t);\n\telse await tx.run(`UPDATE ${t.runs} SET status = ? WHERE run_id = ?`, header.status, header.runId);\n\tfor (const event of events.slice(stored?.events.length ?? 0)) {\n\t\tconst payload = storedJournalPayload(JSON.stringify(event.payload), event.payload);\n\t\tawait tx.run(\n\t\t\t`INSERT INTO ${t.events}(run_id, seq, epoch, key, type, payload, at, chunks) VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,\n\t\t\theader.runId,\n\t\t\tevent.seq,\n\t\t\tevent.epoch,\n\t\t\tevent.key,\n\t\t\tevent.type,\n\t\t\tpayload.payload,\n\t\t\tevent.at,\n\t\t\tpayload.chunks.length,\n\t\t);\n\t\tawait writeJournalPayloadChunks(tx, t.eventChunks, header.runId, event.seq, payload.chunks);\n\t}\n\tconst epoch = events.reduce((highest, event) => Math.max(highest, event.epoch), 0);\n\tawait tx.run(\n\t\t`INSERT INTO ${t.leases}(run_id, holder_id, epoch, renewed_at) VALUES (?, NULL, ?, ${dialect.nowMs})\n\t\tON CONFLICT(run_id) DO UPDATE SET holder_id = NULL, renewed_at = excluded.renewed_at,\n\t\t\tepoch = ${dialect.greatest(\"excluded.epoch\", `${t.leases}.epoch + (CASE WHEN ${t.leases}.holder_id IS NULL THEN 0 ELSE 1 END)`)}`,\n\t\theader.runId,\n\t\tepoch,\n\t);\n}\n\n/**\n * A journal file an import reads its runs from while it decides what to write: read-only, opened once. A named\n * selection's database is opened through its own `open`.\n */\nclass ReadOnlyFiles {\n\tprivate readonly opened = new Map<string, Promise<SqliteDatabase>>();\n\tprivate readonly named?: Extract<WorkflowRunTransferStorage, { kind: \"database\" }>;\n\n\tconstructor(named?: Extract<WorkflowRunTransferStorage, { kind: \"database\" }>) {\n\t\tthis.named = named;\n\t}\n\n\tread(path: string): Promise<SqliteDatabase> {\n\t\tlet database = this.opened.get(path);\n\t\tif (database === undefined) {\n\t\t\t// A named selection's database is the only one its import reads.\n\t\t\tdatabase = this.named?.open() ?? openNodeSqliteDatabase(path, { readOnly: true });\n\t\t\tthis.opened.set(path, database);\n\t\t}\n\t\treturn database;\n\t}\n\n\tasync close(): Promise<void> {\n\t\tconst settled = await Promise.allSettled(this.opened.values());\n\t\tawait closeEach(settled.flatMap((result) => (result.status === \"fulfilled\" ? [result.value] : [])));\n\t}\n}\n\nfunction unreadableShard(parsed: ParsedWorkflowRun, path: string, error: Error): StorageTransferError {\n\treturn new StorageTransferError({\n\t\tpath: parsed.file,\n\t\tline: 1,\n\t\tid: parsed.header.runId,\n\t\treason: `run ${parsed.header.runId} is in the journal file ${path}, which cannot be read: ${error.message}`,\n\t\tcause: error,\n\t});\n}\n\n/**\n * The shard of a store holding `runId`: the one the catalog names, else any shard that holds it although the catalog\n * does not list it, as an adopted journal another process wrote to or a shard an interrupted import wrote to before\n * it recorded the run in the catalog.\n */\nasync function storedShard(\n\tcatalog: JournalCatalog,\n\tfiles: ReadOnlyFiles,\n\tt: Tables,\n\trunId: string,\n): Promise<{ readonly shard: JournalShardRecord; readonly catalogued: boolean } | undefined> {\n\tconst found = await catalog.locate(runId);\n\tif (found !== undefined) return { shard: found.shard, catalogued: true };\n\tfor (const shard of await catalog.shards()) {\n\t\tif (!existsSync(shard.path)) continue;\n\t\ttry {\n\t\t\tconst database = await files.read(shard.path);\n\t\t\tif (\n\t\t\t\t(await hasTables(database, t, dialectOf(database))) &&\n\t\t\t\t(await database.get(`SELECT 1 FROM ${t.runs} WHERE run_id = ?`, runId))\n\t\t\t)\n\t\t\t\treturn { shard, catalogued: false };\n\t\t} catch {}\n\t}\n\treturn undefined;\n}\n\n/** One run of an import plan: what the import does to it, and the storage's copy the decision was made on. */\ninterface PlannedRun {\n\treadonly run: ParsedWorkflowRun;\n\treadonly action: WorkflowRunImportAction;\n\treadonly stored: StoredRun | undefined;\n\t/** The shard holding the run; for a store only. */\n\treadonly shard?: JournalShardRecord;\n\t/** Whether the store's catalog lists the run. */\n\treadonly catalogued: boolean;\n}\n\n/** What importing a set of export files does to a local workflow journal, decided before anything is written. */\nexport interface WorkflowRunImportPlan {\n\treadonly storage: WorkflowRunTransferStorage;\n\treadonly runs: readonly PlannedRun[];\n}\n\n/** The runs of a plan an import writes. */\nexport function pendingWorkflowRuns(plan: WorkflowRunImportPlan): string[] {\n\treturn plan.runs.filter((run) => run.action !== \"unchanged\").map((run) => run.run.header.runId);\n}\n\n/**\n * Compares every run of `runs` with the storage's copy, writing nothing: a run that continued differently here, or that\n * a process here may still be running, fails with the file and line.\n */\nexport async function planWorkflowRunImport(\n\tstorage: WorkflowRunTransferStorage,\n\truns: readonly ParsedWorkflowRun[],\n): Promise<WorkflowRunImportPlan> {\n\tconst t = runJournalTables(storagePrefix(storage));\n\tconst location = storageLocation(storage);\n\tconst files = new ReadOnlyFiles(storage.kind === \"database\" ? storage : undefined);\n\tconst planned: PlannedRun[] = [];\n\tif (runs.length === 0) return { storage, runs: planned };\n\tawait withCleanup(\n\t\tasync () => {\n\t\t\tconst catalogExists = storage.kind === \"store\" && (await adoptLegacyJournal(storage.directory));\n\t\t\tconst catalog = catalogExists ? await JournalCatalog.open(storage.directory) : undefined;\n\t\t\tawait withCleanup(\n\t\t\t\tasync () => {\n\t\t\t\t\tfor (const run of runs) {\n\t\t\t\t\t\tconst found =\n\t\t\t\t\t\t\tcatalog === undefined ? undefined : await storedShard(catalog, files, t, run.header.runId);\n\t\t\t\t\t\tlet path = found?.shard.path;\n\t\t\t\t\t\tif (storage.kind === \"sqlite\") path = existsSync(storage.path) ? storage.path : undefined;\n\t\t\t\t\t\tif (storage.kind === \"database\") path = storage.location;\n\t\t\t\t\t\tlet stored: StoredRun | undefined;\n\t\t\t\t\t\tif (path !== undefined && (storage.kind === \"database\" || existsSync(path))) {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tconst database = await files.read(path);\n\t\t\t\t\t\t\t\tstored = await readStoredRun(database, t, run.header.runId, dialectOf(database));\n\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\tthrow unreadableShard(run, path, error as Error);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tplanned.push({\n\t\t\t\t\t\t\trun,\n\t\t\t\t\t\t\taction: importAction(run, stored, path ?? location),\n\t\t\t\t\t\t\tstored,\n\t\t\t\t\t\t\tcatalogued: found?.catalogued ?? false,\n\t\t\t\t\t\t\t...(found === undefined ? {} : { shard: found.shard }),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tasync () => catalog?.close(),\n\t\t\t);\n\t\t},\n\t\t() => files.close(),\n\t);\n\treturn { storage, runs: planned };\n}\n\n/** The runs an import writes to one journal file, under that file's write lock. */\ninterface ImportGroup {\n\treadonly path: string;\n\treadonly shard?: JournalShardRecord;\n\treadonly runs: PlannedRun[];\n\tdatabase?: SqliteDatabase;\n\ttx?: SqliteExecutor;\n}\n\n/**\n * Writes what `plan` decided. Every journal file the import writes to is opened and its write lock taken, in path\n * order, before anything is written, and every run is compared again under those locks: a run another process changed\n * since the plan was made (a resume took its lease, events were added, a consolidation moved it) fails the import with\n * nothing written. The locks are held until the last run is written; each file then commits. Separate journal files\n * cannot commit together, so when one fails to commit after another did, `StorageImportIncompleteError` names the runs\n * written and the runs not written, and importing again writes only the rest. A store's catalog records added runs\n * after their files commit; a run an interrupted import wrote before recording it is found and recorded by the next.\n */\nexport async function applyWorkflowRunImport(plan: WorkflowRunImportPlan): Promise<WorkflowRunImportReport> {\n\tconst { storage } = plan;\n\tconst prefix = storagePrefix(storage);\n\tconst t = runJournalTables(prefix);\n\tconst report = { added: [] as string[], updated: [] as string[], unchanged: [] as string[] };\n\tconst pending = plan.runs.filter((run) => {\n\t\tif (run.action === \"unchanged\") report.unchanged.push(run.run.header.runId);\n\t\treturn run.action !== \"unchanged\";\n\t});\n\tconst uncatalogued = plan.runs.filter((run) => run.action === \"unchanged\" && !run.catalogued && run.shard);\n\tif (pending.length === 0 && uncatalogued.length === 0) return report;\n\tconst catalog = storage.kind === \"store\" ? await JournalCatalog.open(storage.directory) : undefined;\n\tconst groups = new Map<string, ImportGroup>();\n\tconst committed: ImportGroup[] = [];\n\tconst written = () => committed.flatMap((group) => group.runs.map((run) => run.run.header.runId));\n\ttry {\n\t\tfor (const run of pending) {\n\t\t\tconst shard =\n\t\t\t\tcatalog === undefined ? undefined : (run.shard ?? (await catalog.homeShard(run.run.header.runId)));\n\t\t\tconst path = shard?.path ?? storageLocation(storage);\n\t\t\tlet group = groups.get(path);\n\t\t\tif (group === undefined) {\n\t\t\t\tgroup = { path, runs: [], ...(shard === undefined ? {} : { shard }) };\n\t\t\t\tgroups.set(path, group);\n\t\t\t}\n\t\t\tgroup.runs.push(run);\n\t\t}\n\t\tconst ordered = [...groups.values()].sort((left, right) => (left.path < right.path ? -1 : 1));\n\t\tfor (const group of ordered) {\n\t\t\ttry {\n\t\t\t\tgroup.database =\n\t\t\t\t\tstorage.kind === \"database\" ? await storage.open() : await openNodeSqliteDatabase(group.path);\n\t\t\t} catch (error) {\n\t\t\t\tthrow unreadableShard(group.runs[0]!.run, group.path, error as Error);\n\t\t\t}\n\t\t}\n\t\tconst lockAll = async (index: number): Promise<void> => {\n\t\t\tif (index === ordered.length) {\n\t\t\t\tfor (const group of ordered)\n\t\t\t\t\tfor (const run of group.runs) {\n\t\t\t\t\t\tconst now = await readStoredRun(group.tx!, t, run.run.header.runId, dialectOf(group.database!));\n\t\t\t\t\t\tif (fingerprint(now) !== fingerprint(run.stored))\n\t\t\t\t\t\t\tthrow new StorageTransferError({\n\t\t\t\t\t\t\t\tpath: run.run.file,\n\t\t\t\t\t\t\t\tline: 1,\n\t\t\t\t\t\t\t\tid: run.run.header.runId,\n\t\t\t\t\t\t\t\treason: `run ${run.run.header.runId} changed in ${group.path} after the import compared it (another process wrote to it, took its lease or moved it); nothing was imported, so import again`,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\timportAction(run.run, now, group.path);\n\t\t\t\t\t}\n\t\t\t\tfor (const group of ordered) {\n\t\t\t\t\tawait ensureRunJournalSchema(group.tx!, prefix, dialectOf(group.database!));\n\t\t\t\t\tfor (const run of group.runs)\n\t\t\t\t\t\tawait writeImport(group.tx!, t, run.run, run.stored, dialectOf(group.database!));\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst group = ordered[index]!;\n\t\t\tawait group.database!.transaction(async (tx) => {\n\t\t\t\tgroup.tx = tx;\n\t\t\t\tawait lockAll(index + 1);\n\t\t\t}, TRANSFER_TRANSACTION);\n\t\t\tcommitted.push(group);\n\t\t};\n\t\tawait lockAll(0);\n\t\tif (catalog !== undefined) {\n\t\t\tfor (const group of ordered)\n\t\t\t\tfor (const run of group.runs) {\n\t\t\t\t\tconst { runId, name, cwd, status } = run.run.header;\n\t\t\t\t\tif (run.catalogued) await catalog.setStatus(runId, status);\n\t\t\t\t\telse await catalog.index(group.shard!.id, { runId, name, cwd, status });\n\t\t\t\t}\n\t\t\tfor (const run of uncatalogued) {\n\t\t\t\tconst { runId, name, cwd, status } = run.run.header;\n\t\t\t\tawait catalog.index(run.shard!.id, { runId, name, cwd, status });\n\t\t\t}\n\t\t}\n\t} catch (error) {\n\t\tconst done = written();\n\t\tif (done.length === 0) throw error;\n\t\tconst doneSet = new Set(done);\n\t\tthrow new StorageImportIncompleteError(error as Error, {\n\t\t\twritten: { sessions: [], workflows: done },\n\t\t\tnotWritten: {\n\t\t\t\tsessions: [],\n\t\t\t\tworkflows: pending.map((run) => run.run.header.runId).filter((runId) => !doneSet.has(runId)),\n\t\t\t},\n\t\t});\n\t} finally {\n\t\tawait closeEach(\n\t\t\t[...groups.values()].flatMap((group) => (group.database === undefined ? [] : [group.database])),\n\t\t).catch(() => undefined);\n\t\tawait catalog?.close();\n\t}\n\tfor (const run of pending) (run.action === \"add\" ? report.added : report.updated).push(run.run.header.runId);\n\treturn report;\n}\n\n/**\n * Imports every `<name>.jsonl` export file in `directory` into a local workflow journal: `readWorkflowRunExports`,\n * `planWorkflowRunImport` and `applyWorkflowRunImport` in turn. Every file is read and checked, and every run compared\n * with the storage's copy, before anything is written. A run the storage does not hold is added; one whose earlier\n * events it holds gets the file's later ones; one it holds every event of is left as it is, so importing again changes\n * nothing. String values inside the records are not compared, so a file whose strings a tool redacted imports as the\n * run it was exported from.\n */\nexport async function importWorkflowRuns(\n\tstorage: WorkflowRunTransferStorage,\n\tdirectory: string,\n): Promise<WorkflowRunImportReport> {\n\treturn applyWorkflowRunImport(await planWorkflowRunImport(storage, await readWorkflowRunExports(directory)));\n}\n"]}
1
+ {"version":3,"file":"journal-transfer.js","sourceRoot":"","sources":["../../../src/core/storage/journal-transfer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEtD,OAAO,EAAE,SAAS,EAAuB,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,wBAAwB,EAA8D,MAAM,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AE,CAAC,SAAS,CAAC,CAAC;QACzB,MAAM,OAAO,EAAE,KAAK,EAAE,CAAC;IACxB,CAAC;IACD,KAAK,MAAM,GAAG,IAAI,OAAO;QAAE,CAAC,GAAG,CAAC,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7G,OAAO,MAAM,CAAC;AACf,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACvC,OAAmC,EACnC,SAAiB;IAEjB,OAAO,sBAAsB,CAAC,MAAM,qBAAqB,CAAC,OAAO,EAAE,MAAM,sBAAsB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AAC9G,CAAC","sourcesContent":["/**\n * Workflow runs as versioned JSONL files (#4716, #4720): `exportWorkflowRuns` writes each run of a local workflow\n * journal to `<dir>/<runId>.jsonl`, and the import functions restore such files into one. The journal stays the\n * working store; the files are the form runs take at rest, so a host that persists only files can carry them between\n * machines. `atomic storage export` and `import` use `<exportDir>/workflows` as `<dir>`.\n *\n * Line 1 of a file is the run's header: the row of the journal's runs table. Every later line is one row of its\n * events table, in sequence order, with its payload as a JSON value instead of JSON text. Leases, local-worker pool\n * state and worktree snapshot blobs are not exported: they belong to the machine that wrote them.\n */\n\nimport { existsSync } from \"node:fs\";\nimport { mkdir } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { closeEach, withCleanup } from \"./cleanup.js\";\nimport type { SqliteDatabase, SqliteExecutor, SqliteRow, SqliteValue } from \"./database.js\";\nimport { dialectOf, type StorageDialect } from \"./dialect.js\";\nimport { isStorageResponseRefusal, type StorageFailureCause, type StoragePayloadTooLargeError } from \"./errors.js\";\nimport {\n\tdiscoverLegacyJournal,\n\tensureRunJournalSchema,\n\tisReadableRunJournalVersion,\n\ttype JournalEventTableRow,\n\ttype JournalLeaseTableRow,\n\ttype JournalRunTableRow,\n\tlegacyDefaultJournalPath,\n\trunJournalTables,\n} from \"./journal-adoption.js\";\nimport {\n\tisFinishedJournalStatus,\n\tJOURNAL_CATALOG_FILE,\n\tJournalCatalog,\n\ttype JournalCatalogRun,\n\ttype JournalShardRecord,\n} from \"./journal-catalog.js\";\nimport { openNodeSqliteDatabase } from \"./node-sqlite.js\";\nimport {\n\tRUN_EVENT_TYPES,\n\tstoredJournalPayload,\n\twithJournalPayloads,\n\twriteJournalPayloadChunks,\n} from \"./run-journal.js\";\nimport {\n\treadTransferDirectory,\n\tStorageImportIncompleteError,\n\tStorageTransferError,\n\ttype TransferFileLines,\n\ttransferFile,\n\twriteLinesAtomically,\n} from \"./transfer-files.js\";\n\n/** The `type` of an export file's header line. */\nexport const WORKFLOW_RUN_EXPORT_TYPE = \"atomic.workflow-run\";\n/** The export format version this Atomic writes and reads. */\nexport const WORKFLOW_RUN_EXPORT_VERSION = 1;\n/**\n * A lease renewed this recently belongs to a process that may still be running the run on this machine, so an import\n * does not add events to that run. It matches the window in which the workflows runtime treats a running run's owner\n * as live.\n */\nexport const WORKFLOW_RUN_IMPORT_LIVE_LEASE_MS = 120_000;\n/**\n * How many times an export reads the catalog again after reading the journal files, for runs a consolidation moved\n * in between; a run still not found where the catalog names it after the last read is reported with its reason.\n */\nexport const WORKFLOW_RUN_EXPORT_PLACEMENT_ATTEMPTS = 5;\n\n/** A JSON value as an export file holds it. */\nexport type WorkflowRunExportValue =\n\t| string\n\t| number\n\t| boolean\n\t| null\n\t| readonly WorkflowRunExportValue[]\n\t| { readonly [key: string]: WorkflowRunExportValue };\n\n/** Line 1 of an export file. */\nexport interface WorkflowRunExportHeader {\n\treadonly type: typeof WORKFLOW_RUN_EXPORT_TYPE;\n\treadonly version: typeof WORKFLOW_RUN_EXPORT_VERSION;\n\treadonly runId: string;\n\treadonly name: string;\n\treadonly cwd: string;\n\treadonly createdAt: number;\n\t/** The run's latest status. */\n\treadonly status: string;\n\t/** How many event lines follow. */\n\treadonly events: number;\n\t/** The run header the journal recorded when the run was created. */\n\treadonly header: { readonly [key: string]: WorkflowRunExportValue };\n}\n\n/** One event line of an export file: one journal entry. */\nexport interface WorkflowRunExportEvent {\n\treadonly type: string;\n\treadonly seq: number;\n\treadonly epoch: number;\n\treadonly key: string | null;\n\treadonly at: number;\n\treadonly payload: WorkflowRunExportValue;\n}\n\n/**\n * The workflow journal storage that runs are exported from and imported into: the local journal store, a SQLite file,\n * or a database a named selection opens (`open` is called for each use and the database closed after it; `location`\n * names it in reports and errors).\n */\nexport type WorkflowRunTransferStorage =\n\t| { readonly kind: \"store\"; readonly directory: string }\n\t| { readonly kind: \"sqlite\"; readonly path: string; readonly prefix?: string }\n\t| {\n\t\t\treadonly kind: \"database\";\n\t\t\treadonly open: () => Promise<SqliteDatabase>;\n\t\t\treadonly location: string;\n\t\t\treadonly prefix?: string;\n\t };\n\nexport interface WorkflowRunExportOptions {\n\t/** Only these runs; a run the storage does not hold fails the export before any file is written. */\n\treadonly runs?: readonly string[];\n\t/** Only runs that are not completed, failed or cancelled. */\n\treadonly unfinished?: boolean;\n\t/** At most this many runs, newest first. */\n\treadonly limit?: number;\n}\n\nexport interface WorkflowRunExportReport {\n\t/** Runs whose file was written. */\n\treadonly written: readonly string[];\n\t/** Runs whose file already held exactly this export, left untouched. */\n\treadonly unchanged: readonly string[];\n\t/** Journal files that could not be read, and catalogued runs that could not be exported, with the reason. */\n\treadonly skipped: readonly { readonly path: string; readonly runId?: string; readonly reason: string }[];\n}\n\nexport interface WorkflowRunImportReport {\n\t/** Runs the storage did not hold. */\n\treadonly added: readonly string[];\n\t/** Runs the storage held an earlier part of, which now have the file's later events. */\n\treadonly updated: readonly string[];\n\t/** Runs the storage already held every event of. */\n\treadonly unchanged: readonly string[];\n}\n\nconst TRANSFER_TRANSACTION = { lockWaitMs: 10 * 60_000 } as const;\nconst EVENT_TYPES: ReadonlySet<string> = new Set(Object.values(RUN_EVENT_TYPES));\nconst HEADER_FIELDS = [\"type\", \"version\", \"runId\", \"name\", \"cwd\", \"createdAt\", \"status\", \"events\", \"header\"] as const;\nconst EVENT_FIELDS = [\"type\", \"seq\", \"epoch\", \"key\", \"at\", \"payload\"] as const;\n/** The runs table of the journal format before 0.9.38, which an export cannot read. */\nconst LEGACY_RUNS_TABLE = \"runs\";\nconst OLD_FORMAT_REASON = \"it is in the journal format of Atomic before 0.9.38; resume it once to convert it\";\n\ntype JsonObject = { readonly [key: string]: WorkflowRunExportValue };\ntype Tables = ReturnType<typeof runJournalTables>;\n\nfunction storageLocation(storage: WorkflowRunTransferStorage): string {\n\treturn storage.kind === \"store\" ? storage.directory : storage.kind === \"sqlite\" ? storage.path : storage.location;\n}\n\nfunction storagePrefix(storage: WorkflowRunTransferStorage): string | undefined {\n\treturn storage.kind === \"store\" ? undefined : storage.prefix;\n}\n\nfunction parseStored(text: string, path: string, runId: string, what: string): WorkflowRunExportValue {\n\ttry {\n\t\treturn JSON.parse(text) as WorkflowRunExportValue;\n\t} catch (cause) {\n\t\tthrow new StorageTransferError({\n\t\t\tpath,\n\t\t\tid: runId,\n\t\t\treason: `run ${runId} has ${what} that is not valid JSON`,\n\t\t\tcause: cause as StorageFailureCause,\n\t\t});\n\t}\n}\n\n/** A run and its events as the lines of its export file. */\nfunction exportLines(run: JournalRunTableRow, events: readonly JournalEventTableRow[], path: string): string[] {\n\tconst header = parseStored(run.header_json, path, run.run_id, \"a header\");\n\tif (!isObject(header))\n\t\tthrow new StorageTransferError({\n\t\t\tpath,\n\t\t\tid: run.run_id,\n\t\t\treason: `run ${run.run_id} has a header that is not an object`,\n\t\t});\n\tconst lines = [\n\t\tJSON.stringify({\n\t\t\ttype: WORKFLOW_RUN_EXPORT_TYPE,\n\t\t\tversion: WORKFLOW_RUN_EXPORT_VERSION,\n\t\t\trunId: run.run_id,\n\t\t\tname: run.name,\n\t\t\tcwd: run.cwd,\n\t\t\tcreatedAt: Number(run.created_at),\n\t\t\tstatus: run.status,\n\t\t\tevents: events.length,\n\t\t\theader,\n\t\t} satisfies WorkflowRunExportHeader),\n\t];\n\tfor (const event of events)\n\t\tlines.push(\n\t\t\tJSON.stringify({\n\t\t\t\ttype: event.type,\n\t\t\t\tseq: Number(event.seq),\n\t\t\t\tepoch: Number(event.epoch),\n\t\t\t\tkey: event.key,\n\t\t\t\tat: Number(event.at),\n\t\t\t\tpayload: parseStored(event.payload, path, run.run_id, `event ${event.seq} with a payload`),\n\t\t\t} satisfies WorkflowRunExportEvent),\n\t\t);\n\treturn lines;\n}\n\nasync function hasTables(executor: SqliteExecutor, t: Tables, dialect: StorageDialect): Promise<boolean> {\n\tfor (const table of [t.meta, t.runs, t.events]) if (!(await hasTable(executor, table, dialect))) return false;\n\treturn true;\n}\n\nasync function hasTable(executor: SqliteExecutor, name: string, dialect: StorageDialect): Promise<boolean> {\n\tconst exists = dialect.tableExists(name);\n\treturn (await executor.get(exists.sql, ...exists.params)) !== undefined;\n}\n\nasync function schemaVersion(executor: SqliteExecutor, t: Tables): Promise<SqliteValue | undefined> {\n\tconst rows = await executor.all<SqliteRow & { schema_version: SqliteValue }>(`SELECT schema_version FROM ${t.meta}`);\n\treturn rows.length === 1 ? rows[0]!.schema_version : undefined;\n}\n\n/** One journal file an export reads, inside one read transaction, so every run it holds is read as of one moment. */\ninterface ExportSource {\n\treadonly path: string;\n\treadonly shardId?: number;\n\treadonly database: SqliteDatabase;\n\t/** Whether the source is read in one read transaction, which closing it ends. */\n\treadonly snapshot: boolean;\n\treadonly runs: readonly JournalRunTableRow[];\n\treadonly byId: ReadonlyMap<string, JournalRunTableRow>;\n}\n\n/** A journal file an export could not read, and whether that is because it holds only the format before 0.9.38. */\ninterface UnreadableSource {\n\treadonly path: string;\n\treadonly reason: string;\n\treadonly oldFormat: boolean;\n}\n\n/** A named source kept open until the caller selects a run (or reports the original refusal). */\ninterface RefusedCatalog {\n\treadonly oldFormat: \"refused\";\n\treadonly path: string;\n\treadonly reader: SqliteDatabase;\n\treadonly failure: StoragePayloadTooLargeError;\n}\n\n/**\n * Opens a journal file for an export and begins its read transaction; the reason when it cannot. `open` opens a\n * named selection's database instead, which is read without a transaction: its runs are each read whole.\n */\nfunction openExportSource(path: string, t: Tables, shardId: number): Promise<ExportSource | UnreadableSource>;\nfunction openExportSource(\n\tpath: string,\n\tt: Tables,\n\tshardId: undefined,\n\topen: (() => Promise<SqliteDatabase>) | undefined,\n): Promise<ExportSource | UnreadableSource | RefusedCatalog>;\nasync function openExportSource(\n\tpath: string,\n\tt: Tables,\n\tshardId: number | undefined,\n\topen?: () => Promise<SqliteDatabase>,\n): Promise<ExportSource | UnreadableSource | RefusedCatalog> {\n\tif (open === undefined && !existsSync(path))\n\t\treturn { path, reason: \"the journal file no longer exists\", oldFormat: false };\n\tlet database: SqliteDatabase;\n\ttry {\n\t\tdatabase = await (open ?? (() => openNodeSqliteDatabase(path, { readOnly: true })))();\n\t} catch (error) {\n\t\treturn { path, reason: `the journal file cannot be opened: ${(error as Error).message}`, oldFormat: false };\n\t}\n\ttry {\n\t\tif (open === undefined) await database.exec(\"BEGIN\");\n\t\tif (!(await hasTables(database, t, dialectOf(database)))) {\n\t\t\tawait closeExportSource({ database, snapshot: open === undefined });\n\t\t\treturn { path, reason: \"it has no workflow runs in the current journal format\", oldFormat: true };\n\t\t}\n\t\tconst version = await schemaVersion(database, t);\n\t\tif (!isReadableRunJournalVersion(version)) {\n\t\t\tawait closeExportSource({ database, snapshot: open === undefined });\n\t\t\treturn { path, reason: `unsupported journal schema version ${String(version)}`, oldFormat: false };\n\t\t}\n\t\tconst request = database.all<JournalRunTableRow>(`SELECT * FROM ${t.runs} ORDER BY run_id`);\n\t\tlet runs: JournalRunTableRow[];\n\t\ttry {\n\t\t\truns = await request;\n\t\t} catch (error) {\n\t\t\tif (open === undefined || !isStorageResponseRefusal(error)) throw error;\n\t\t\treturn {\n\t\t\t\toldFormat: \"refused\",\n\t\t\t\tpath,\n\t\t\t\treader: database,\n\t\t\t\tfailure: error,\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tpath,\n\t\t\tdatabase,\n\t\t\tsnapshot: open === undefined,\n\t\t\truns,\n\t\t\tbyId: new Map(runs.map((run) => [run.run_id, run])),\n\t\t\t...(shardId === undefined ? {} : { shardId }),\n\t\t};\n\t} catch (error) {\n\t\tawait database.close().catch(() => undefined);\n\t\treturn { path, reason: `the journal file cannot be read: ${(error as Error).message}`, oldFormat: false };\n\t}\n}\n\nfunction singleExportId(ids: readonly string[] | undefined): string | undefined {\n\tlet selected: string | undefined;\n\tlet count = 0;\n\tfor (const id of ids ?? []) {\n\t\tif (++count > 1) return undefined;\n\t\tselected = id;\n\t}\n\treturn selected;\n}\n\nfunction catalogRefusal({ path, failure }: RefusedCatalog): StorageTransferError {\n\treturn new StorageTransferError({ path, reason: `the journal file cannot be read: ${failure.message}` });\n}\n\nasync function exportSelectedAfterRefusal(\n\trefused: RefusedCatalog,\n\tid: string,\n\toptions: WorkflowRunExportOptions,\n\tdirectory: string,\n\tt: Tables,\n): Promise<WorkflowRunExportReport | undefined> {\n\tconst { reader: database, path } = refused;\n\tlet refusedPoint: StoragePayloadTooLargeError | undefined;\n\tconst header = async <Row extends SqliteRow>(tx: SqliteExecutor, columns: string) => {\n\t\tconst version = await schemaVersion(tx, t);\n\t\tif (!isReadableRunJournalVersion(version))\n\t\t\tthrow new StorageTransferError({ path, reason: `unsupported journal schema version ${String(version)}` });\n\t\tconst row = await tx.get<Row>(`SELECT ${columns} FROM ${t.runs} WHERE run_id = ?`, id).catch((error: unknown) => {\n\t\t\tif (isStorageResponseRefusal(error)) refusedPoint = error;\n\t\t\tthrow error;\n\t\t});\n\t\tif (!row) throw new StorageTransferError({ path, id, reason: `run ${id} is not in this workflow journal` });\n\t\treturn row;\n\t};\n\ttry {\n\t\tconst { run, events } = await database.transaction(\n\t\t\tasync (tx) => {\n\t\t\t\tconst run = await header<JournalRunTableRow>(tx, \"*\");\n\t\t\t\tconst events = await withJournalPayloads(\n\t\t\t\t\ttx,\n\t\t\t\t\tt.eventChunks,\n\t\t\t\t\tawait tx.all<JournalEventTableRow>(`SELECT * FROM ${t.events} WHERE run_id = ? ORDER BY seq`, id),\n\t\t\t\t);\n\t\t\t\treturn { run, events };\n\t\t\t},\n\t\t\t{ readOnly: true },\n\t\t);\n\t\t// Do not publish a run deleted or upgraded during recovery. The header body was already read with its events.\n\t\tawait database.transaction((tx) => header(tx, \"1 AS found\"), { readOnly: true });\n\t\t// Only a complete, supported run reaches the caller's remaining selection options, outside the transaction.\n\t\tlet included = !options.unfinished || !isFinishedJournalStatus(run.status) ? [id] : [];\n\t\tif (options.limit !== undefined) included = included.slice(0, options.limit);\n\t\tif (included.length === 0) {\n\t\t\tawait mkdir(directory, { recursive: true });\n\t\t\treturn { written: [], unchanged: [], skipped: [] };\n\t\t}\n\t\tconst file = transferFile(directory, id),\n\t\t\tlines = exportLines(run, events, path);\n\t\tawait mkdir(directory, { recursive: true });\n\t\tconst outcome = await writeLinesAtomically(file, lines);\n\t\treturn { written: outcome === \"written\" ? [id] : [], unchanged: outcome === \"written\" ? [] : [id], skipped: [] };\n\t} catch (error) {\n\t\t// Only the confirmed header refusal goes back to the caller's close-before-diagnostic path.\n\t\tif (refusedPoint !== undefined && error === refusedPoint) return undefined;\n\t\tthrow error;\n\t}\n}\n\nasync function closeExportSource(source: Pick<ExportSource, \"database\" | \"snapshot\">): Promise<void> {\n\tif (source.snapshot) await source.database.exec(\"COMMIT\").catch(() => undefined);\n\tawait source.database.close();\n}\n\n/**\n * Adopts the default journal of Atomic before the journal store, as opening the store does, so its runs are exported\n * and compared like every other run; whether the store has a catalog.\n */\nasync function adoptLegacyJournal(directory: string): Promise<boolean> {\n\tif (existsSync(legacyDefaultJournalPath(directory))) {\n\t\tconst catalog = await JournalCatalog.open(directory);\n\t\tawait withCleanup(\n\t\t\tasync () => {\n\t\t\t\tawait discoverLegacyJournal(catalog, legacyDefaultJournalPath(directory));\n\t\t\t},\n\t\t\t() => catalog.close(),\n\t\t);\n\t}\n\treturn existsSync(join(directory, JOURNAL_CATALOG_FILE));\n}\n\n/** What the catalog of a journal store says at one moment: its shards, and its runs with the shard each is on. */\ninterface CatalogView {\n\treadonly shards: readonly JournalShardRecord[];\n\treadonly runs: readonly JournalCatalogRun[];\n\treadonly owners: ReadonlyMap<string, number>;\n}\n\nasync function readCatalog(directory: string): Promise<CatalogView> {\n\tconst catalog = await JournalCatalog.open(directory);\n\treturn withCleanup(\n\t\tasync () => {\n\t\t\tconst shards = await catalog.shards();\n\t\t\tconst runs = await catalog.runs();\n\t\t\treturn { shards, runs, owners: new Map(runs.map((run) => [run.runId, run.shard])) };\n\t\t},\n\t\t() => catalog.close(),\n\t);\n}\n\nfunction newestFirst(left: JournalRunTableRow, right: JournalRunTableRow): number {\n\tconst created = Number(right.created_at) - Number(left.created_at);\n\tif (created !== 0) return created;\n\treturn left.run_id < right.run_id ? -1 : left.run_id > right.run_id ? 1 : 0;\n}\n\n/** The journal files of a store an export reads, by shard, kept open in their read transactions until it finishes. */\nclass ExportSources {\n\treadonly opened = new Map<number, ExportSource>();\n\treadonly unreadable = new Map<number, UnreadableSource>();\n\n\tprivate readonly t: Tables;\n\n\tconstructor(t: Tables) {\n\t\tthis.t = t;\n\t}\n\n\t/** Opens every shard of `view` not opened yet, and opens `fresh` again with a new snapshot. */\n\tasync open(view: CatalogView, fresh: ReadonlySet<number> = new Set()): Promise<void> {\n\t\tfor (const shard of view.shards) {\n\t\t\tconst current = this.opened.get(shard.id);\n\t\t\tif (current !== undefined && !fresh.has(shard.id)) continue;\n\t\t\tif (current === undefined && this.unreadable.has(shard.id) && !fresh.has(shard.id)) continue;\n\t\t\tif (current !== undefined) {\n\t\t\t\tthis.opened.delete(shard.id);\n\t\t\t\tawait closeExportSource(current);\n\t\t\t}\n\t\t\tthis.unreadable.delete(shard.id);\n\t\t\tconst source = await openExportSource(shard.path, this.t, shard.id);\n\t\t\tif (\"database\" in source) this.opened.set(shard.id, source);\n\t\t\telse this.unreadable.set(shard.id, source);\n\t\t}\n\t}\n\n\t/** The catalogued runs of `view` that the snapshot of the shard the catalog names for them does not hold. */\n\tmissing(view: CatalogView): JournalCatalogRun[] {\n\t\treturn view.runs.filter((run) => {\n\t\t\tconst source = this.opened.get(run.shard);\n\t\t\treturn run.status !== undefined && source !== undefined && !source.byId.has(run.runId);\n\t\t});\n\t}\n\n\tclose(): Promise<void> {\n\t\treturn closeEach([...this.opened.values()].map((source) => ({ close: () => closeExportSource(source) })));\n\t}\n}\n\n/**\n * Reads a journal store's catalog and opens its shards, then reads the catalog again for every run the shard it named\n * did not hold: a consolidation may have moved the run between the two reads, into an existing shard or one it\n * created. The shard the run moved to is read again, and so on until the placements agree or the attempts run out.\n */\nasync function settleExportSources(directory: string, sources: ExportSources): Promise<CatalogView> {\n\tlet view = await readCatalog(directory);\n\tawait sources.open(view);\n\tfor (let attempt = 1; attempt < WORKFLOW_RUN_EXPORT_PLACEMENT_ATTEMPTS; attempt++) {\n\t\tconst missing = sources.missing(view);\n\t\tif (missing.length === 0) return view;\n\t\tconst next = await readCatalog(directory);\n\t\tconst moved = new Set<number>();\n\t\tfor (const run of missing) {\n\t\t\tconst now = next.owners.get(run.runId);\n\t\t\tif (now !== undefined && now !== run.shard) moved.add(now);\n\t\t}\n\t\tconst added = next.shards.some((shard) => !sources.opened.has(shard.id) && !sources.unreadable.has(shard.id));\n\t\tview = next;\n\t\tif (moved.size === 0 && !added) return view;\n\t\tawait sources.open(view, moved);\n\t}\n\treturn view;\n}\n\n/** Why a catalogued run that its shard's snapshot does not hold, or whose shard could not be read, is not exported. */\nasync function missingRunReason(\n\trun: JournalCatalogRun,\n\tview: CatalogView,\n\tsources: ExportSources,\n): Promise<{ path: string; runId: string; reason: string }> {\n\tconst unreadable = sources.unreadable.get(run.shard);\n\tif (unreadable !== undefined)\n\t\treturn {\n\t\t\tpath: unreadable.path,\n\t\t\trunId: run.runId,\n\t\t\treason: unreadable.oldFormat ? OLD_FORMAT_REASON : `its journal file cannot be read: ${unreadable.reason}`,\n\t\t};\n\tconst source = sources.opened.get(run.shard);\n\tif (source === undefined) {\n\t\tconst path = view.shards.find((shard) => shard.id === run.shard)?.path ?? `shard ${run.shard}`;\n\t\treturn { path, runId: run.runId, reason: `the catalog names shard ${run.shard} for it, which it does not list` };\n\t}\n\tif (\n\t\t(await hasTable(source.database, LEGACY_RUNS_TABLE, dialectOf(source.database))) &&\n\t\t(await source.database.get(`SELECT 1 AS found FROM ${LEGACY_RUNS_TABLE} WHERE run_id = ?`, run.runId))\n\t)\n\t\treturn { path: source.path, runId: run.runId, reason: OLD_FORMAT_REASON };\n\treturn {\n\t\tpath: source.path,\n\t\trunId: run.runId,\n\t\treason:\n\t\t\t\"the journal file the catalog names for it does not hold it; it was moved or deleted while the export ran, so export again\",\n\t};\n}\n\n/**\n * Exports runs of a local workflow journal to `<directory>/<runId>.jsonl`, one file per run. Each journal file is read\n * in one read transaction, and each export file is written whole or not at all. The same journal state gives the same\n * bytes, and a file that already holds them is not rewritten. A run the store's catalog lists is taken only from the\n * shard the catalog names for it, read again when a consolidation moved it while the export ran; one that cannot be\n * exported is reported with the reason.\n */\nexport async function exportWorkflowRuns(\n\tstorage: WorkflowRunTransferStorage,\n\tdirectory: string,\n\toptions: WorkflowRunExportOptions = {},\n): Promise<WorkflowRunExportReport> {\n\tconst t = runJournalTables(storagePrefix(storage));\n\tconst skipped: { path: string; runId?: string; reason: string }[] = [];\n\tconst sources = new ExportSources(t);\n\tlet single: ExportSource | undefined;\n\tlet refused: RefusedCatalog | undefined;\n\treturn withCleanup(\n\t\tasync () => {\n\t\t\tconst listed = new Map<string, { readonly source: ExportSource; readonly run: JournalRunTableRow }>();\n\t\t\tconst unexported = new Map<string, { path: string; runId: string; reason: string }>();\n\t\t\tif (storage.kind === \"sqlite\" || storage.kind === \"database\") {\n\t\t\t\tif (storage.kind === \"database\" || existsSync(storage.path)) {\n\t\t\t\t\tconst opened = await openExportSource(\n\t\t\t\t\t\tstorageLocation(storage),\n\t\t\t\t\t\tt,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tstorage.kind === \"database\" ? storage.open : undefined,\n\t\t\t\t\t);\n\t\t\t\t\tif (\"database\" in opened) single = opened;\n\t\t\t\t\telse if (opened.oldFormat === \"refused\") refused = opened;\n\t\t\t\t\t// A named database that cannot be read fails the export: an empty export would pass for a backup.\n\t\t\t\t\telse if (storage.kind === \"database\" && !opened.oldFormat)\n\t\t\t\t\t\tthrow new StorageTransferError({ path: opened.path, reason: opened.reason });\n\t\t\t\t\telse skipped.push({ path: opened.path, reason: opened.reason });\n\t\t\t\t}\n\t\t\t\tfor (const run of single?.runs ?? []) listed.set(run.run_id, { source: single!, run });\n\t\t\t} else if (await adoptLegacyJournal(storage.directory)) {\n\t\t\t\tconst view = await settleExportSources(storage.directory, sources);\n\t\t\t\tconst catalogued = new Set<number>(view.runs.map((run) => run.shard));\n\t\t\t\tfor (const [id, unreadable] of sources.unreadable)\n\t\t\t\t\tif (!catalogued.has(id)) skipped.push({ path: unreadable.path, reason: unreadable.reason });\n\t\t\t\tfor (const run of view.runs) {\n\t\t\t\t\tconst source = sources.opened.get(run.shard);\n\t\t\t\t\tconst row = source?.byId.get(run.runId);\n\t\t\t\t\tif (source !== undefined && row !== undefined) listed.set(run.runId, { source, run: row });\n\t\t\t\t\telse if (run.status !== undefined) unexported.set(run.runId, await missingRunReason(run, view, sources));\n\t\t\t\t}\n\t\t\t\t// A run no catalog entry names yet (another process wrote it to a shard) is taken from the first shard\n\t\t\t\t// holding it. A catalogued run is never taken from another shard, which may hold an older copy an\n\t\t\t\t// interrupted consolidation left behind.\n\t\t\t\tfor (const source of sources.opened.values())\n\t\t\t\t\tfor (const run of source.runs)\n\t\t\t\t\t\tif (!view.owners.has(run.run_id) && !listed.has(run.run_id)) listed.set(run.run_id, { source, run });\n\t\t\t}\n\t\t\tlet selected = [...listed.values()];\n\t\t\tif (refused !== undefined) {\n\t\t\t\tconst id = singleExportId(options.runs);\n\t\t\t\tif (id !== undefined) {\n\t\t\t\t\tconst report = await exportSelectedAfterRefusal(refused, id, options, directory, t);\n\t\t\t\t\tif (report !== undefined) return report;\n\t\t\t\t}\n\t\t\t\tconst original = refused;\n\t\t\t\trefused = undefined;\n\t\t\t\tawait original.reader.close().catch(() => undefined);\n\t\t\t\tthrow catalogRefusal(original);\n\t\t\t}\n\t\t\tif (options.runs !== undefined) {\n\t\t\t\tfor (const runId of options.runs) {\n\t\t\t\t\tif (listed.has(runId)) continue;\n\t\t\t\t\tconst reason = unexported.get(runId);\n\t\t\t\t\tthrow new StorageTransferError({\n\t\t\t\t\t\tpath: reason?.path ?? storageLocation(storage),\n\t\t\t\t\t\tid: runId,\n\t\t\t\t\t\treason:\n\t\t\t\t\t\t\treason === undefined\n\t\t\t\t\t\t\t\t? `run ${runId} is not in this workflow journal`\n\t\t\t\t\t\t\t\t: `run ${runId} cannot be exported: ${reason.reason}`,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tselected = [...new Set(options.runs)].map((runId) => listed.get(runId)!);\n\t\t\t} else skipped.push(...unexported.values());\n\t\t\tif (options.unfinished) selected = selected.filter(({ run }) => !isFinishedJournalStatus(run.status));\n\t\t\tselected.sort((left, right) => newestFirst(left.run, right.run));\n\t\t\tif (options.limit !== undefined) selected = selected.slice(0, options.limit);\n\t\t\tawait mkdir(directory, { recursive: true });\n\t\t\tconst written: string[] = [];\n\t\t\tconst unchanged: string[] = [];\n\t\t\tfor (const { source, run: listedRun } of selected) {\n\t\t\t\tconst readEvents = async (executor: SqliteExecutor) =>\n\t\t\t\t\twithJournalPayloads(\n\t\t\t\t\t\texecutor,\n\t\t\t\t\t\tt.eventChunks,\n\t\t\t\t\t\tawait executor.all<JournalEventTableRow>(\n\t\t\t\t\t\t\t`SELECT * FROM ${t.events} WHERE run_id = ? ORDER BY seq`,\n\t\t\t\t\t\t\tlistedRun.run_id,\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t// A source without a read snapshot reads each run's row and events together, in one transaction, so a\n\t\t\t\t// run that finishes meanwhile is exported with the status its events reach.\n\t\t\t\tconst { run, events } = source.snapshot\n\t\t\t\t\t? { run: listedRun, events: await readEvents(source.database) }\n\t\t\t\t\t: await source.database.transaction(async (tx) => ({\n\t\t\t\t\t\t\trun:\n\t\t\t\t\t\t\t\t(await tx.get<JournalRunTableRow>(\n\t\t\t\t\t\t\t\t\t`SELECT * FROM ${t.runs} WHERE run_id = ?`,\n\t\t\t\t\t\t\t\t\tlistedRun.run_id,\n\t\t\t\t\t\t\t\t)) ?? listedRun,\n\t\t\t\t\t\t\tevents: await readEvents(tx),\n\t\t\t\t\t\t}));\n\t\t\t\tconst outcome = await writeLinesAtomically(\n\t\t\t\t\ttransferFile(directory, run.run_id),\n\t\t\t\t\texportLines(run, events, source.path),\n\t\t\t\t);\n\t\t\t\t(outcome === \"written\" ? written : unchanged).push(run.run_id);\n\t\t\t}\n\t\t\treturn { written, unchanged, skipped };\n\t\t},\n\t\tasync () => {\n\t\t\tawait sources.close();\n\t\t\tif (single !== undefined) await closeExportSource(single);\n\t\t\tif (refused !== undefined) await refused.reader.close();\n\t\t},\n\t);\n}\n\n/** A run read from an export file and checked: everything an import writes for it. */\nexport interface ParsedWorkflowRun {\n\treadonly file: string;\n\treadonly header: WorkflowRunExportHeader;\n\treadonly events: readonly WorkflowRunExportEvent[];\n}\n\nfunction isObject(value: WorkflowRunExportValue | undefined): value is JsonObject {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction invalidText(value: string): string | undefined {\n\tif (value.includes(\"\\u0000\")) return \"contains a NUL character\";\n\tif (/\\p{Surrogate}/u.test(value)) return \"is not well-formed Unicode\";\n\treturn undefined;\n}\n\nfunction counter(value: WorkflowRunExportValue | undefined, minimum: number): value is number {\n\treturn typeof value === \"number\" && Number.isSafeInteger(value) && value >= minimum;\n}\n\n/** Checks that a line has exactly `fields`; the reason when it does not. */\nfunction fieldsReason(line: JsonObject, fields: readonly string[]): string | undefined {\n\tfor (const field of fields) if (!(field in line)) return `has no \"${field}\" field`;\n\tfor (const field of Object.keys(line)) if (!fields.includes(field)) return `has an unexpected \"${field}\" field`;\n\treturn undefined;\n}\n\n/** Checks one export file, throwing a `StorageTransferError` that names the file and line. */\nfunction parseExportFile({ file, lines }: TransferFileLines): ParsedWorkflowRun {\n\tconst fail = (line: number | undefined, reason: string, runId?: string): never => {\n\t\tthrow new StorageTransferError({ path: file, ...(line === undefined ? {} : { line }), id: runId, reason });\n\t};\n\tif (lines.length === 0) return fail(1, \"is empty; expected a workflow run header\");\n\tconst parse = (index: number): JsonObject => {\n\t\tconst line = lines[index]!.text;\n\t\tif (line.trim() === \"\") return fail(index + 1, \"is empty\");\n\t\tlet value: WorkflowRunExportValue;\n\t\ttry {\n\t\t\tvalue = JSON.parse(line) as WorkflowRunExportValue;\n\t\t} catch (error) {\n\t\t\treturn fail(index + 1, `is not valid JSON (${(error as Error).message})`);\n\t\t}\n\t\tif (!isObject(value)) return fail(index + 1, \"is not a JSON object\");\n\t\tif (typeof value.type !== \"string\") return fail(index + 1, 'has no string \"type\"');\n\t\treturn value;\n\t};\n\tconst first = parse(0);\n\tif (first.type !== WORKFLOW_RUN_EXPORT_TYPE)\n\t\tfail(1, `is not an Atomic workflow run export: its type is \"${first.type}\", not \"${WORKFLOW_RUN_EXPORT_TYPE}\"`);\n\tif (first.version !== WORKFLOW_RUN_EXPORT_VERSION)\n\t\tfail(\n\t\t\t1,\n\t\t\t`has unsupported export version ${JSON.stringify(first.version ?? null)}; this Atomic reads version ${WORKFLOW_RUN_EXPORT_VERSION}`,\n\t\t);\n\tconst headerFields = fieldsReason(first, HEADER_FIELDS);\n\tif (headerFields !== undefined) fail(1, headerFields);\n\tfor (const field of [\"runId\", \"name\", \"cwd\", \"status\"] as const) {\n\t\tconst value = first[field];\n\t\tif (typeof value !== \"string\") fail(1, `has a \"${field}\" that is not a string`);\n\t\tconst reason = invalidText(value as string);\n\t\tif (reason !== undefined) fail(1, `has a \"${field}\" that ${reason}`);\n\t}\n\tconst runId = first.runId as string;\n\tif (runId === \"\") fail(1, 'has an empty \"runId\"');\n\tif (!counter(first.createdAt, Number.MIN_SAFE_INTEGER)) fail(1, 'has a \"createdAt\" that is not an integer', runId);\n\tif (!counter(first.events, 0)) fail(1, 'has an \"events\" count that is not a non-negative integer', runId);\n\tif (!isObject(first.header)) fail(1, 'has a \"header\" that is not an object', runId);\n\tif ((first.header as JsonObject).runId !== runId)\n\t\tfail(1, `has a \"header\" whose runId is not the run's ID ${runId}`, runId);\n\tconst events: WorkflowRunExportEvent[] = [];\n\tconst keys = new Map<string, number>();\n\tfor (let index = 1; index < lines.length; index++) {\n\t\tconst line = index + 1;\n\t\tconst event = parse(index);\n\t\tconst reason = fieldsReason(event, EVENT_FIELDS);\n\t\tif (reason !== undefined) fail(line, reason, runId);\n\t\tif (!EVENT_TYPES.has(event.type as string)) fail(line, `has unknown event type \"${event.type}\"`, runId);\n\t\tif (event.seq !== index) fail(line, `has seq ${JSON.stringify(event.seq)}; expected ${index}`, runId);\n\t\tif (!counter(event.epoch, 0)) fail(line, 'has an \"epoch\" that is not a non-negative integer', runId);\n\t\tif (!counter(event.at, Number.MIN_SAFE_INTEGER)) fail(line, 'has an \"at\" that is not an integer', runId);\n\t\tconst key = event.key;\n\t\tif (key !== null) {\n\t\t\tif (typeof key !== \"string\") fail(line, 'has a \"key\" that is neither a string nor null', runId);\n\t\t\tconst keyReason = invalidText(key as string);\n\t\t\tif (keyReason !== undefined) fail(line, `has a \"key\" that ${keyReason}`, runId);\n\t\t\tconst earlier = keys.get(key as string);\n\t\t\tif (earlier !== undefined) fail(line, `repeats the key of line ${earlier}`, runId);\n\t\t\tkeys.set(key as string, line);\n\t\t}\n\t\tif (event.type === RUN_EVENT_TYPES.statusChanged) {\n\t\t\tconst status = isObject(event.payload) ? event.payload.status : undefined;\n\t\t\tif (typeof status !== \"string\")\n\t\t\t\tfail(line, 'is a StatusChanged event whose payload has no string \"status\"', runId);\n\t\t\tconst statusReason = invalidText(status as string);\n\t\t\tif (statusReason !== undefined) fail(line, `has a status that ${statusReason}`, runId);\n\t\t}\n\t\tevents.push({\n\t\t\ttype: event.type as string,\n\t\t\tseq: event.seq as number,\n\t\t\tepoch: event.epoch as number,\n\t\t\tkey: key as string | null,\n\t\t\tat: event.at as number,\n\t\t\tpayload: event.payload!,\n\t\t});\n\t}\n\tif (lines.length - 1 !== first.events)\n\t\tfail(1, `says the run has ${first.events} events, but the file has ${lines.length - 1} event lines`, runId);\n\tconst header: WorkflowRunExportHeader = {\n\t\ttype: WORKFLOW_RUN_EXPORT_TYPE,\n\t\tversion: WORKFLOW_RUN_EXPORT_VERSION,\n\t\trunId,\n\t\tname: first.name as string,\n\t\tcwd: first.cwd as string,\n\t\tcreatedAt: first.createdAt as number,\n\t\tstatus: first.status as string,\n\t\tevents: first.events as number,\n\t\theader: first.header as JsonObject,\n\t};\n\treturn { file, header, events };\n}\n\n/**\n * Reads and checks every `*.jsonl` export file in `directory`; nothing is written. A directory that does not exist\n * holds no runs. Throws `StorageTransferError` with the file and line for the first file that is not a valid export.\n */\nexport async function readWorkflowRunExports(directory: string): Promise<ParsedWorkflowRun[]> {\n\tconst parsed: ParsedWorkflowRun[] = [];\n\tconst files = new Map<string, string>();\n\tfor (const lines of await readTransferDirectory(directory)) {\n\t\tconst run = parseExportFile(lines);\n\t\tconst earlier = files.get(run.header.runId);\n\t\tif (earlier !== undefined)\n\t\t\tthrow new StorageTransferError({\n\t\t\t\tpath: run.file,\n\t\t\t\tline: 1,\n\t\t\t\tid: run.header.runId,\n\t\t\t\treason: `run ${run.header.runId} is also in ${earlier}; keep one file per run`,\n\t\t\t});\n\t\tfiles.set(run.header.runId, run.file);\n\t\tparsed.push(run);\n\t}\n\treturn parsed;\n}\n\n/** The fields import checks against a stored run: everything but string content, which a tool may redact. */\nfunction sameEntry(stored: JournalEventTableRow, exported: WorkflowRunExportEvent): boolean {\n\treturn (\n\t\tNumber(stored.seq) === exported.seq &&\n\t\tNumber(stored.epoch) === exported.epoch &&\n\t\tstored.key === exported.key &&\n\t\tstored.type === exported.type &&\n\t\tNumber(stored.at) === exported.at\n\t);\n}\n\ninterface StoredRun {\n\treadonly run: JournalRunTableRow;\n\treadonly events: readonly JournalEventTableRow[];\n\treadonly lease?: JournalLeaseTableRow & { readonly age_ms: number };\n}\n\nasync function readStoredRun(\n\texecutor: SqliteExecutor,\n\tt: Tables,\n\trunId: string,\n\tdialect: StorageDialect,\n): Promise<StoredRun | undefined> {\n\tif (!(await hasTables(executor, t, dialect))) return undefined;\n\tconst run = await executor.get<JournalRunTableRow>(`SELECT * FROM ${t.runs} WHERE run_id = ?`, runId);\n\tif (run === undefined) return undefined;\n\tconst events = await withJournalPayloads(\n\t\texecutor,\n\t\tt.eventChunks,\n\t\tawait executor.all<JournalEventTableRow>(`SELECT * FROM ${t.events} WHERE run_id = ? ORDER BY seq`, runId),\n\t);\n\tconst lease = (await hasTable(executor, t.leases, dialect))\n\t\t? await executor.get<JournalLeaseTableRow & { age_ms: number }>(\n\t\t\t\t`SELECT *, ${dialect.greatest(\"0\", `${dialect.nowMs} - renewed_at`)} AS age_ms FROM ${t.leases} WHERE run_id = ?`,\n\t\t\t\trunId,\n\t\t\t)\n\t\t: undefined;\n\treturn { run, events, ...(lease === undefined ? {} : { lease }) };\n}\n\n/**\n * What of a stored run an import depends on: its status, how many events it has and the last of them, and its lease.\n * A run whose fingerprint differs from the one the import checked was changed by another process in between.\n */\nfunction fingerprint(stored: StoredRun | undefined): string {\n\tif (stored === undefined) return \"absent\";\n\tconst last = stored.events.at(-1);\n\tconst lease = stored.lease;\n\treturn JSON.stringify([\n\t\tstored.run.status,\n\t\tNumber(stored.run.created_at),\n\t\tstored.events.length,\n\t\tlast === undefined ? null : [Number(last.seq), Number(last.epoch), last.key, last.type, Number(last.at)],\n\t\tlease === undefined ? null : [lease.holder_id, Number(lease.epoch), Number(lease.renewed_at)],\n\t]);\n}\n\n/** What an import does to one run. */\nexport type WorkflowRunImportAction = \"add\" | \"update\" | \"unchanged\";\n\n/**\n * What importing `parsed` does to the run as `stored` holds it: add it, add the file's later events, or nothing when\n * the storage already holds every event of the file. A run whose history differs from the file's, or that a process\n * here may still be running, fails with the file and line.\n */\nfunction importAction(\n\tparsed: ParsedWorkflowRun,\n\tstored: StoredRun | undefined,\n\tlocation: string,\n): WorkflowRunImportAction {\n\tif (stored === undefined) return \"add\";\n\tconst { header, events, file } = parsed;\n\tconst fail = (line: number, reason: string): never => {\n\t\tthrow new StorageTransferError({ path: file, line, id: header.runId, reason });\n\t};\n\tif (Number(stored.run.created_at) !== header.createdAt)\n\t\tfail(1, `run ${header.runId} in ${location} was created at another time; it is a different run with the same ID`);\n\tconst shared = Math.min(stored.events.length, events.length);\n\tfor (let index = 0; index < shared; index++)\n\t\tif (!sameEntry(stored.events[index]!, events[index]!))\n\t\t\tfail(\n\t\t\t\tindex + 2,\n\t\t\t\t`event ${index + 1} differs from event ${index + 1} of run ${header.runId} in ${location}: the run continued differently there`,\n\t\t\t);\n\tif (events.length <= stored.events.length) return \"unchanged\";\n\tconst lease = stored.lease;\n\tif (lease !== undefined && lease.holder_id !== null && Number(lease.age_ms) < WORKFLOW_RUN_IMPORT_LIVE_LEASE_MS)\n\t\tfail(\n\t\t\t1,\n\t\t\t`run ${header.runId} is held by ${lease.holder_id} in ${location}, which may still be running it; stop it and import again`,\n\t\t);\n\treturn \"update\";\n}\n\n/**\n * Writes the part of `parsed` that `stored` lacks inside the caller's transaction: the run row when it is new, the\n * events after the stored ones, the latest status, and an unheld lease at an epoch above every epoch the run's events\n * and any earlier holder used, so no holder from another machine is imported and a stale one here is fenced.\n */\nasync function writeImport(\n\ttx: SqliteExecutor,\n\tt: Tables,\n\tparsed: ParsedWorkflowRun,\n\tstored: StoredRun | undefined,\n\tdialect: StorageDialect,\n): Promise<void> {\n\tconst { header, events } = parsed;\n\tif (stored === undefined)\n\t\tawait tx.run(\n\t\t\t`INSERT INTO ${t.runs}(run_id, name, cwd, created_at, status, header_json) VALUES (?, ?, ?, ?, ?, ?)`,\n\t\t\theader.runId,\n\t\t\theader.name,\n\t\t\theader.cwd,\n\t\t\theader.createdAt,\n\t\t\theader.status,\n\t\t\tJSON.stringify(header.header),\n\t\t);\n\telse await tx.run(`UPDATE ${t.runs} SET status = ? WHERE run_id = ?`, header.status, header.runId);\n\tfor (const event of events.slice(stored?.events.length ?? 0)) {\n\t\tconst payload = storedJournalPayload(JSON.stringify(event.payload), event.payload);\n\t\tawait tx.run(\n\t\t\t`INSERT INTO ${t.events}(run_id, seq, epoch, key, type, payload, at, chunks) VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,\n\t\t\theader.runId,\n\t\t\tevent.seq,\n\t\t\tevent.epoch,\n\t\t\tevent.key,\n\t\t\tevent.type,\n\t\t\tpayload.payload,\n\t\t\tevent.at,\n\t\t\tpayload.chunks.length,\n\t\t);\n\t\tawait writeJournalPayloadChunks(tx, t.eventChunks, header.runId, event.seq, payload.chunks);\n\t}\n\tconst epoch = events.reduce((highest, event) => Math.max(highest, event.epoch), 0);\n\tawait tx.run(\n\t\t`INSERT INTO ${t.leases}(run_id, holder_id, epoch, renewed_at) VALUES (?, NULL, ?, ${dialect.nowMs})\n\t\tON CONFLICT(run_id) DO UPDATE SET holder_id = NULL, renewed_at = excluded.renewed_at,\n\t\t\tepoch = ${dialect.greatest(\"excluded.epoch\", `${t.leases}.epoch + (CASE WHEN ${t.leases}.holder_id IS NULL THEN 0 ELSE 1 END)`)}`,\n\t\theader.runId,\n\t\tepoch,\n\t);\n}\n\n/**\n * A journal file an import reads its runs from while it decides what to write: read-only, opened once. A named\n * selection's database is opened through its own `open`.\n */\nclass ReadOnlyFiles {\n\tprivate readonly opened = new Map<string, Promise<SqliteDatabase>>();\n\tprivate readonly named?: Extract<WorkflowRunTransferStorage, { kind: \"database\" }>;\n\n\tconstructor(named?: Extract<WorkflowRunTransferStorage, { kind: \"database\" }>) {\n\t\tthis.named = named;\n\t}\n\n\tread(path: string): Promise<SqliteDatabase> {\n\t\tlet database = this.opened.get(path);\n\t\tif (database === undefined) {\n\t\t\t// A named selection's database is the only one its import reads.\n\t\t\tdatabase = this.named?.open() ?? openNodeSqliteDatabase(path, { readOnly: true });\n\t\t\tthis.opened.set(path, database);\n\t\t}\n\t\treturn database;\n\t}\n\n\tasync close(): Promise<void> {\n\t\tconst settled = await Promise.allSettled(this.opened.values());\n\t\tawait closeEach(settled.flatMap((result) => (result.status === \"fulfilled\" ? [result.value] : [])));\n\t}\n}\n\nfunction unreadableShard(parsed: ParsedWorkflowRun, path: string, error: Error): StorageTransferError {\n\treturn new StorageTransferError({\n\t\tpath: parsed.file,\n\t\tline: 1,\n\t\tid: parsed.header.runId,\n\t\treason: `run ${parsed.header.runId} is in the journal file ${path}, which cannot be read: ${error.message}`,\n\t\tcause: error,\n\t});\n}\n\n/**\n * The shard of a store holding `runId`: the one the catalog names, else any shard that holds it although the catalog\n * does not list it, as an adopted journal another process wrote to or a shard an interrupted import wrote to before\n * it recorded the run in the catalog.\n */\nasync function storedShard(\n\tcatalog: JournalCatalog,\n\tfiles: ReadOnlyFiles,\n\tt: Tables,\n\trunId: string,\n): Promise<{ readonly shard: JournalShardRecord; readonly catalogued: boolean } | undefined> {\n\tconst found = await catalog.locate(runId);\n\tif (found !== undefined) return { shard: found.shard, catalogued: true };\n\tfor (const shard of await catalog.shards()) {\n\t\tif (!existsSync(shard.path)) continue;\n\t\ttry {\n\t\t\tconst database = await files.read(shard.path);\n\t\t\tif (\n\t\t\t\t(await hasTables(database, t, dialectOf(database))) &&\n\t\t\t\t(await database.get(`SELECT 1 FROM ${t.runs} WHERE run_id = ?`, runId))\n\t\t\t)\n\t\t\t\treturn { shard, catalogued: false };\n\t\t} catch {}\n\t}\n\treturn undefined;\n}\n\n/** One run of an import plan: what the import does to it, and the storage's copy the decision was made on. */\ninterface PlannedRun {\n\treadonly run: ParsedWorkflowRun;\n\treadonly action: WorkflowRunImportAction;\n\treadonly stored: StoredRun | undefined;\n\t/** The shard holding the run; for a store only. */\n\treadonly shard?: JournalShardRecord;\n\t/** Whether the store's catalog lists the run. */\n\treadonly catalogued: boolean;\n}\n\n/** What importing a set of export files does to a local workflow journal, decided before anything is written. */\nexport interface WorkflowRunImportPlan {\n\treadonly storage: WorkflowRunTransferStorage;\n\treadonly runs: readonly PlannedRun[];\n}\n\n/** The runs of a plan an import writes. */\nexport function pendingWorkflowRuns(plan: WorkflowRunImportPlan): string[] {\n\treturn plan.runs.filter((run) => run.action !== \"unchanged\").map((run) => run.run.header.runId);\n}\n\n/**\n * Compares every run of `runs` with the storage's copy, writing nothing: a run that continued differently here, or that\n * a process here may still be running, fails with the file and line.\n */\nexport async function planWorkflowRunImport(\n\tstorage: WorkflowRunTransferStorage,\n\truns: readonly ParsedWorkflowRun[],\n): Promise<WorkflowRunImportPlan> {\n\tconst t = runJournalTables(storagePrefix(storage));\n\tconst location = storageLocation(storage);\n\tconst files = new ReadOnlyFiles(storage.kind === \"database\" ? storage : undefined);\n\tconst planned: PlannedRun[] = [];\n\tif (runs.length === 0) return { storage, runs: planned };\n\tawait withCleanup(\n\t\tasync () => {\n\t\t\tconst catalogExists = storage.kind === \"store\" && (await adoptLegacyJournal(storage.directory));\n\t\t\tconst catalog = catalogExists ? await JournalCatalog.open(storage.directory) : undefined;\n\t\t\tawait withCleanup(\n\t\t\t\tasync () => {\n\t\t\t\t\tfor (const run of runs) {\n\t\t\t\t\t\tconst found =\n\t\t\t\t\t\t\tcatalog === undefined ? undefined : await storedShard(catalog, files, t, run.header.runId);\n\t\t\t\t\t\tlet path = found?.shard.path;\n\t\t\t\t\t\tif (storage.kind === \"sqlite\") path = existsSync(storage.path) ? storage.path : undefined;\n\t\t\t\t\t\tif (storage.kind === \"database\") path = storage.location;\n\t\t\t\t\t\tlet stored: StoredRun | undefined;\n\t\t\t\t\t\tif (path !== undefined && (storage.kind === \"database\" || existsSync(path))) {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tconst database = await files.read(path);\n\t\t\t\t\t\t\t\tstored = await readStoredRun(database, t, run.header.runId, dialectOf(database));\n\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\tthrow unreadableShard(run, path, error as Error);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tplanned.push({\n\t\t\t\t\t\t\trun,\n\t\t\t\t\t\t\taction: importAction(run, stored, path ?? location),\n\t\t\t\t\t\t\tstored,\n\t\t\t\t\t\t\tcatalogued: found?.catalogued ?? false,\n\t\t\t\t\t\t\t...(found === undefined ? {} : { shard: found.shard }),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tasync () => catalog?.close(),\n\t\t\t);\n\t\t},\n\t\t() => files.close(),\n\t);\n\treturn { storage, runs: planned };\n}\n\n/** The runs an import writes to one journal file, under that file's write lock. */\ninterface ImportGroup {\n\treadonly path: string;\n\treadonly shard?: JournalShardRecord;\n\treadonly runs: PlannedRun[];\n\tdatabase?: SqliteDatabase;\n\ttx?: SqliteExecutor;\n}\n\n/**\n * Writes what `plan` decided. Every journal file the import writes to is opened and its write lock taken, in path\n * order, before anything is written, and every run is compared again under those locks: a run another process changed\n * since the plan was made (a resume took its lease, events were added, a consolidation moved it) fails the import with\n * nothing written. The locks are held until the last run is written; each file then commits. Separate journal files\n * cannot commit together, so when one fails to commit after another did, `StorageImportIncompleteError` names the runs\n * written and the runs not written, and importing again writes only the rest. A store's catalog records added runs\n * after their files commit; a run an interrupted import wrote before recording it is found and recorded by the next.\n */\nexport async function applyWorkflowRunImport(plan: WorkflowRunImportPlan): Promise<WorkflowRunImportReport> {\n\tconst { storage } = plan;\n\tconst prefix = storagePrefix(storage);\n\tconst t = runJournalTables(prefix);\n\tconst report = { added: [] as string[], updated: [] as string[], unchanged: [] as string[] };\n\tconst pending = plan.runs.filter((run) => {\n\t\tif (run.action === \"unchanged\") report.unchanged.push(run.run.header.runId);\n\t\treturn run.action !== \"unchanged\";\n\t});\n\tconst uncatalogued = plan.runs.filter((run) => run.action === \"unchanged\" && !run.catalogued && run.shard);\n\tif (pending.length === 0 && uncatalogued.length === 0) return report;\n\tconst catalog = storage.kind === \"store\" ? await JournalCatalog.open(storage.directory) : undefined;\n\tconst groups = new Map<string, ImportGroup>();\n\tconst committed: ImportGroup[] = [];\n\tconst written = () => committed.flatMap((group) => group.runs.map((run) => run.run.header.runId));\n\ttry {\n\t\tfor (const run of pending) {\n\t\t\tconst shard =\n\t\t\t\tcatalog === undefined ? undefined : (run.shard ?? (await catalog.homeShard(run.run.header.runId)));\n\t\t\tconst path = shard?.path ?? storageLocation(storage);\n\t\t\tlet group = groups.get(path);\n\t\t\tif (group === undefined) {\n\t\t\t\tgroup = { path, runs: [], ...(shard === undefined ? {} : { shard }) };\n\t\t\t\tgroups.set(path, group);\n\t\t\t}\n\t\t\tgroup.runs.push(run);\n\t\t}\n\t\tconst ordered = [...groups.values()].sort((left, right) => (left.path < right.path ? -1 : 1));\n\t\tfor (const group of ordered) {\n\t\t\ttry {\n\t\t\t\tgroup.database =\n\t\t\t\t\tstorage.kind === \"database\" ? await storage.open() : await openNodeSqliteDatabase(group.path);\n\t\t\t} catch (error) {\n\t\t\t\tthrow unreadableShard(group.runs[0]!.run, group.path, error as Error);\n\t\t\t}\n\t\t}\n\t\tconst lockAll = async (index: number): Promise<void> => {\n\t\t\tif (index === ordered.length) {\n\t\t\t\tfor (const group of ordered)\n\t\t\t\t\tfor (const run of group.runs) {\n\t\t\t\t\t\tconst now = await readStoredRun(group.tx!, t, run.run.header.runId, dialectOf(group.database!));\n\t\t\t\t\t\tif (fingerprint(now) !== fingerprint(run.stored))\n\t\t\t\t\t\t\tthrow new StorageTransferError({\n\t\t\t\t\t\t\t\tpath: run.run.file,\n\t\t\t\t\t\t\t\tline: 1,\n\t\t\t\t\t\t\t\tid: run.run.header.runId,\n\t\t\t\t\t\t\t\treason: `run ${run.run.header.runId} changed in ${group.path} after the import compared it (another process wrote to it, took its lease or moved it); nothing was imported, so import again`,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\timportAction(run.run, now, group.path);\n\t\t\t\t\t}\n\t\t\t\tfor (const group of ordered) {\n\t\t\t\t\tawait ensureRunJournalSchema(group.tx!, prefix, dialectOf(group.database!));\n\t\t\t\t\tfor (const run of group.runs)\n\t\t\t\t\t\tawait writeImport(group.tx!, t, run.run, run.stored, dialectOf(group.database!));\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst group = ordered[index]!;\n\t\t\tawait group.database!.transaction(async (tx) => {\n\t\t\t\tgroup.tx = tx;\n\t\t\t\tawait lockAll(index + 1);\n\t\t\t}, TRANSFER_TRANSACTION);\n\t\t\tcommitted.push(group);\n\t\t};\n\t\tawait lockAll(0);\n\t\tif (catalog !== undefined) {\n\t\t\tfor (const group of ordered)\n\t\t\t\tfor (const run of group.runs) {\n\t\t\t\t\tconst { runId, name, cwd, status } = run.run.header;\n\t\t\t\t\tif (run.catalogued) await catalog.setStatus(runId, status);\n\t\t\t\t\telse await catalog.index(group.shard!.id, { runId, name, cwd, status });\n\t\t\t\t}\n\t\t\tfor (const run of uncatalogued) {\n\t\t\t\tconst { runId, name, cwd, status } = run.run.header;\n\t\t\t\tawait catalog.index(run.shard!.id, { runId, name, cwd, status });\n\t\t\t}\n\t\t}\n\t} catch (error) {\n\t\tconst done = written();\n\t\tif (done.length === 0) throw error;\n\t\tconst doneSet = new Set(done);\n\t\tthrow new StorageImportIncompleteError(error as Error, {\n\t\t\twritten: { sessions: [], workflows: done },\n\t\t\tnotWritten: {\n\t\t\t\tsessions: [],\n\t\t\t\tworkflows: pending.map((run) => run.run.header.runId).filter((runId) => !doneSet.has(runId)),\n\t\t\t},\n\t\t});\n\t} finally {\n\t\tawait closeEach(\n\t\t\t[...groups.values()].flatMap((group) => (group.database === undefined ? [] : [group.database])),\n\t\t).catch(() => undefined);\n\t\tawait catalog?.close();\n\t}\n\tfor (const run of pending) (run.action === \"add\" ? report.added : report.updated).push(run.run.header.runId);\n\treturn report;\n}\n\n/**\n * Imports every `<name>.jsonl` export file in `directory` into a local workflow journal: `readWorkflowRunExports`,\n * `planWorkflowRunImport` and `applyWorkflowRunImport` in turn. Every file is read and checked, and every run compared\n * with the storage's copy, before anything is written. A run the storage does not hold is added; one whose earlier\n * events it holds gets the file's later ones; one it holds every event of is left as it is, so importing again changes\n * nothing. String values inside the records are not compared, so a file whose strings a tool redacted imports as the\n * run it was exported from.\n */\nexport async function importWorkflowRuns(\n\tstorage: WorkflowRunTransferStorage,\n\tdirectory: string,\n): Promise<WorkflowRunImportReport> {\n\treturn applyWorkflowRunImport(await planWorkflowRunImport(storage, await readWorkflowRunExports(directory)));\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"node-sqlite.d.ts","sourceRoot":"","sources":["../../../src/core/storage/node-sqlite.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAIhD,OAAO,KAAK,EACX,cAAc,EAMd,MAAM,eAAe,CAAC;AAEvB,OAAO,EAaN,+BAA+B,EAI/B,MAAM,aAAa,CAAC;AAkmBrB,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAE/D;AAwWD;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,MAAM,CAAC;AA0BhD,mHAAmH;AACnH,MAAM,WAAW,gBAAgB;IAChC,sHAAsH;IACtH,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,oHAAoH;IACpH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,wGAAwG;IACxG,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,0FAA0F;IAC1F,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,6DAA6D;IAC7D,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;CAClC;AA8rBD;;;;GAIG;AACH,wBAAgB,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