@bastani/atomic 0.9.89 → 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 +113 -0
  2. package/dist/builtin/intercom/CHANGELOG.md +13 -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 +27 -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 +6 -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 +36 -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":"errors.js","sourceRoot":"","sources":["../../../src/core/storage/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAIpD,MAAM,OAAO,YAAa,SAAQ,KAAK;IAEtC,YAAY,OAAe,EAAE,OAAsB;QAClD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC;IAC7B,CAAC;CACD;AAED,MAAM,OAAO,uBAAwB,SAAQ,YAAY;IAC/C,OAAO,CAAS;IAChB,QAAQ,CAAS;IAE1B;;;OAGG;IACH,YAAY,UAA6B,EAAE,KAA0B,EAAE,MAAe;QACrF,KAAK,CAAC,wBAAwB,UAAU,CAAC,OAAO,OAAO,UAAU,CAAC,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE;YAC3G,KAAK;SACL,CAAC,CAAC;QACH,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC;QAClC,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC;IACrC,CAAC;CACD;AAED,MAAM,OAAO,gBAAiB,SAAQ,YAAY;IACxC,OAAO,CAAS;IAChB,QAAQ,CAAS;IAC1B,YAAY,UAA6B;QACxC,KAAK,CAAC,mBAAmB,UAAU,CAAC,OAAO,OAAO,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC;QACzE,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC;QAClC,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC;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MAAM,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;YACzC,SAAS,EAAE,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,IAAI,EAAE;YAC1C,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC;YAC5B,SAAS,EAAE,UAAU,CAAC,SAAS;YAC/B,KAAK;SACL,CAAC,CAAC;IACJ,IAAI,OAAO,CAAC,UAAU,EAAE,mBAAmB,EAAE,yBAAyB,CAAC;QACtE,OAAO,IAAI,iBAAiB,CAAC;YAC5B,IAAI,EAAE,UAAU,CAAC,IAA6B;YAC9C,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE;YAChC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,QAAQ,CAA6C;YAC1E,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC;YAC5B,YAAY,EAAE,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC;YAC1C,KAAK,EAAE,YAAY,CAAC,MAAM,CAAC;YAC3B,SAAS,EAAE,OAAO,CAAC,MAAM,EAAE,WAAW,CAAC;YACvC,KAAK;SACL,CAAC,CAAC;IACJ,OAAO,IAAI,iBAAiB,CAAC;QAC5B,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,MAAM;QACN,SAAS,EAAE,UAAU,CAAC,SAAS;QAC/B,KAAK;KACL,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { SqliteValue, StorageDescriptor } from \"./database.js\";\nimport { isSqliteBusy } from \"./write-ahead-log.js\";\n\nexport type StorageFailureCause = object | SqliteValue | boolean | symbol | undefined;\n\nexport class StorageError extends Error {\n\tdeclare readonly cleanupCause?: StorageFailureCause;\n\tconstructor(message: string, options?: ErrorOptions) {\n\t\tsuper(message, options);\n\t\tthis.name = new.target.name;\n\t}\n}\n\nexport class StorageUnavailableError extends StorageError {\n\treadonly adapter: string;\n\treadonly location: string;\n\tdeclare readonly cause: StorageFailureCause;\n\t/**\n\t * `detail` names the driver failure in the message: a worker or coordinator that relays only `message` across\n\t * a process boundary keeps the reason. Adapters pass it only for causes that cannot carry credentials.\n\t */\n\tconstructor(descriptor: StorageDescriptor, cause: StorageFailureCause, detail?: string) {\n\t\tsuper(`Storage unavailable: ${descriptor.adapter} at ${descriptor.location}${detail ? `: ${detail}` : \"\"}`, {\n\t\t\tcause,\n\t\t});\n\t\tthis.adapter = descriptor.adapter;\n\t\tthis.location = descriptor.location;\n\t}\n}\n\nexport class StoreClosedError extends StorageError {\n\treadonly adapter: string;\n\treadonly location: string;\n\tconstructor(descriptor: StorageDescriptor) {\n\t\tsuper(`Storage closed: ${descriptor.adapter} at ${descriptor.location}`);\n\t\tthis.adapter = descriptor.adapter;\n\t\tthis.location = descriptor.location;\n\t}\n}\n\nexport class StorageTransactionClosedError extends StorageError {\n\tconstructor() {\n\t\tsuper(\"Storage transaction is closed\");\n\t}\n}\n\nexport class StorageRollbackError extends StorageError {\n\tdeclare readonly cause: StorageFailureCause;\n\treadonly rollbackCause: StorageFailureCause;\n\tconstructor(cause: StorageFailureCause, rollbackCause: StorageFailureCause) {\n\t\tsuper(\"Storage rollback failed\", { cause });\n\t\tthis.rollbackCause = rollbackCause;\n\t}\n}\n\nexport class StorageInvalidTextError extends StorageError {\n\treadonly parameterIndex: number;\n\treadonly reason = \"nul-character\";\n\tconstructor(parameterIndex: number) {\n\t\tsuper(`Storage parameter ${parameterIndex} contains a NUL character`);\n\t\tthis.parameterIndex = parameterIndex;\n\t}\n}\n\nexport class StorageSchemaVersionError extends StorageError {\n\treadonly domain: string;\n\treadonly found: SqliteValue;\n\treadonly supported: number;\n\tconstructor(domain: string, found: SqliteValue, supported: number) {\n\t\tsuper(`Unsupported ${domain} storage schema version`);\n\t\tthis.domain = domain;\n\t\tthis.found = found;\n\t\tthis.supported = supported;\n\t}\n}\n\n/** Why a storage prefix is refused. */\nexport type StoragePrefixErrorReason = \"pattern\" | \"reserved\" | \"too-long\" | \"identifier-collision\" | \"uppercase\";\n\nexport class StoragePrefixError extends StorageError {\n\treadonly prefix: string;\n\t/**\n\t * `uppercase`: PostgreSQL folds unquoted names to lowercase, so a prefix with uppercase letters would name the same\n\t * tables as its lowercase form while Atomic's catalog probes looked for the unfolded names (#5218).\n\t */\n\treadonly reason: StoragePrefixErrorReason;\n\t/** With `too-long`: the longest prefix the selected backend takes (#5067). */\n\tdeclare readonly maxLength?: number;\n\t/** With `identifier-collision`: the name PostgreSQL would know two of the prefix's names by (#5219). */\n\tdeclare readonly identifier?: string;\n\tconstructor(prefix: string, reason: StoragePrefixErrorReason, maxLength?: number, identifier?: string) {\n\t\tsuper(\n\t\t\t`Invalid storage prefix: ${reason}${maxLength === undefined ? \"\" : ` (PostgreSQL allows at most ${maxLength} characters)`}${identifier === undefined ? \"\" : ` (two names under it would both be PostgreSQL's ${identifier}; choose another prefix)`}${reason === \"uppercase\" ? ` (PostgreSQL folds names to lowercase: use ${prefix.toLowerCase()})` : \"\"}`,\n\t\t);\n\t\tthis.prefix = prefix;\n\t\tthis.reason = reason;\n\t\tif (maxLength !== undefined) this.maxLength = maxLength;\n\t\tif (identifier !== undefined) this.identifier = identifier;\n\t}\n}\n\n/** The code of every `StorageConfigError`: an option, flag, variable, or setting has an invalid value. */\nexport type StorageConfigErrorCode = \"invalid-config\";\n\nexport class StorageConfigError extends StorageError {\n\t/** {@link TeamProfileConfigError} is the one subclass, with its own name and codes. */\n\toverride readonly name: \"StorageConfigError\" | \"TeamProfileConfigError\" = \"StorageConfigError\";\n\treadonly code: StorageConfigErrorCode | TeamProfileConfigErrorCode = \"invalid-config\";\n\treadonly source: \"sdk\" | \"cli\" | \"env\" | \"settings\";\n\treadonly field: string;\n\treadonly reason: string;\n\t/** What to change, when the place that rejects the value knows it. */\n\tdeclare readonly hint?: string;\n\tconstructor(source: \"sdk\" | \"cli\" | \"env\" | \"settings\", field: string, reason: string, hint?: string) {\n\t\tsuper(`Invalid storage configuration: ${field} (${reason})${hint === undefined ? \"\" : `. ${hint}`}`);\n\t\tthis.source = source;\n\t\tthis.field = field;\n\t\tthis.reason = reason;\n\t\tif (hint !== undefined) this.hint = hint;\n\t}\n}\n\nexport class StorageAdapterLoadError extends StorageError {\n\treadonly module: string;\n\tdeclare readonly cause: StorageFailureCause;\n\tconstructor(module: string, cause: StorageFailureCause) {\n\t\tsuper(`Could not load storage adapter: ${module}`, { cause });\n\t\tthis.module = module;\n\t}\n}\n\nexport class StorageOutcomeUnknownError extends StorageError {\n\treadonly domain: string;\n\treadonly id: string;\n\treadonly key: string;\n\tconstructor(domain: string, id: string, key: string) {\n\t\tsuper(`Storage write outcome unknown: ${domain} ${id}`);\n\t\tthis.domain = domain;\n\t\tthis.id = id;\n\t\tthis.key = key;\n\t}\n}\n\n/**\n * What a backend refused as too large: a value or row a statement writes or computes, or the response to a\n * statement.\n */\nexport type StoragePayloadKind = \"value\" | \"response\";\n\nexport interface StoragePayloadTooLargeOptions {\n\treadonly kind?: StoragePayloadKind;\n\treadonly descriptor?: StorageDescriptor;\n\treadonly cause?: StorageFailureCause;\n}\n\nconst PAYLOAD_TOO_LARGE_HINT =\n\t\"Retrying does not help: store less in one value, or raise the backend's limit (sqld: max_row_size, --max-response-size)\";\n\nfunction byteCount(bytes: number): string {\n\treturn `${bytes.toLocaleString(\"en-US\")} bytes`;\n}\n\n/**\n * The backend refused a payload larger than it accepts: a bound or computed value or row (a libSQL server's\n * `SQLITE_TOOBIG`, `ARGS_INVALID \"string or blob too big\"`, Postgres's `54000`), or a statement's response (a libSQL\n * server's `RESPONSE_TOO_LARGE`). Permanent: the same write fails again, so it is never `retryable` and never a\n * `StorageUnavailableError` (#4954). `limitBytes` is the backend's default limit when the backend does not report its\n * own; `actualBytes` is the largest value the statement bound, or 0 when unknown (a response). A value refused while\n * the largest bound value is within the limit is one the backend built running the statement, a row of several values\n * or a value a query computes, and the message says so instead of calling the small value sent too large (#5260).\n */\nexport class StoragePayloadTooLargeError extends StorageError {\n\treadonly code = \"payload-too-large\" as const;\n\treadonly retryable = false as const;\n\treadonly hint = PAYLOAD_TOO_LARGE_HINT;\n\treadonly limitBytes: number;\n\treadonly actualBytes: number;\n\treadonly kind: StoragePayloadKind;\n\tdeclare readonly adapter?: string;\n\tdeclare readonly location?: string;\n\tdeclare readonly cause: StorageFailureCause;\n\tconstructor(limitBytes: number, actualBytes: number, options: StoragePayloadTooLargeOptions = {}) {\n\t\tconst kind = options.kind ?? \"value\";\n\t\tconst where =\n\t\t\toptions.descriptor === undefined ? \"\" : `: ${options.descriptor.adapter} at ${options.descriptor.location}`;\n\t\tconst limit = limitBytes > 0 ? `the limit is ${byteCount(limitBytes)}` : \"over its limit\";\n\t\tconst built = actualBytes > 0 && actualBytes <= limitBytes;\n\t\tconst what =\n\t\t\tkind === \"response\"\n\t\t\t\t? `refused to return a response larger than it allows; ${limit} per response`\n\t\t\t\t: built\n\t\t\t\t\t? `refused a value or row it built while running the statement, larger than it stores; ${limit} per value or row, and the largest value sent was ${byteCount(actualBytes)}`\n\t\t\t\t\t: `refused a value${actualBytes > 0 ? ` of ${byteCount(actualBytes)}` : \"\"} larger than it stores; ${limit} per value or row`;\n\t\tsuper(\n\t\t\t`Storage payload too large${where}: the backend ${what} (payload-too-large). ${PAYLOAD_TOO_LARGE_HINT}.`,\n\t\t\toptions.cause === undefined ? undefined : { cause: options.cause },\n\t\t);\n\t\tthis.limitBytes = limitBytes;\n\t\tthis.actualBytes = actualBytes;\n\t\tthis.kind = kind;\n\t\tif (options.descriptor !== undefined) {\n\t\t\tthis.adapter = options.descriptor.adapter;\n\t\t\tthis.location = options.descriptor.location;\n\t\t}\n\t}\n}\n\n/** SQLite's result code for a string, blob or row over its length limit. */\nconst SQLITE_TOOBIG = 18;\n\n/** A backend's payload limits, in bytes, for the messages of {@link StoragePayloadTooLargeError}. */\nexport type StoragePayloadLimits = Readonly<Partial<Record<StoragePayloadKind, number>>>;\n/** SQLite's default `SQLITE_MAX_LENGTH`, the limit of Atomic's own SQLite stores. */\nexport const SQLITE_PAYLOAD_LIMITS: StoragePayloadLimits = Object.freeze({ value: 1_000_000_000 });\n\n/**\n * The kind of payload `failure`, or a cause of it, says the backend refused as too large, if it says so: read from\n * codes, never from a message, except libSQL's `ARGS_INVALID`, whose code covers other argument errors too.\n */\nexport function payloadTooLargeKind(failure: StorageFailureCause | Error): StoragePayloadKind | undefined {\n\tlet current: unknown = failure;\n\tfor (let depth = 0; depth < MAX_STORAGE_CAUSE_DEPTH && typeof current === \"object\" && current !== null; depth++) {\n\t\tconst { code, errcode, message, cause } = current as {\n\t\t\treadonly code?: unknown;\n\t\t\treadonly errcode?: unknown;\n\t\t\treadonly message?: unknown;\n\t\t\treadonly cause?: unknown;\n\t\t};\n\t\tif (code === \"RESPONSE_TOO_LARGE\") return \"response\";\n\t\tif (code === \"SQLITE_TOOBIG\" || code === \"54000\") return \"value\";\n\t\tif (code === \"ARGS_INVALID\" && typeof message === \"string\" && /too big/i.test(message)) return \"value\";\n\t\tif (typeof errcode === \"number\" && (errcode & 0xff) === SQLITE_TOOBIG) return \"value\";\n\t\tcurrent = cause;\n\t}\n\treturn undefined;\n}\n\n/** The byte size of the largest text or binary value in `params`, as UTF-8 for text. */\nexport function largestValueBytes(params: readonly SqliteValue[]): number {\n\tlet largest = 0;\n\tfor (const value of params) {\n\t\tconst bytes =\n\t\t\ttypeof value === \"string\"\n\t\t\t\t? Buffer.byteLength(value, \"utf8\")\n\t\t\t\t: value instanceof Uint8Array\n\t\t\t\t\t? value.byteLength\n\t\t\t\t\t: 0;\n\t\tlargest = Math.max(largest, bytes);\n\t}\n\treturn largest;\n}\n\n/** An error and its direct cause on one line, for status output (a module-resolution \"Require stack\" is dropped). */\nexport function describeStorageError(error: Error | object | string | undefined): string {\n\tconst firstLine = (text: string): string => text.split(\"\\n\", 1)[0]!.trim();\n\tif (!(error instanceof Error)) return firstLine(String(error));\n\tconst message = firstLine(error.message);\n\tconst cause = error.cause instanceof Error ? firstLine(error.cause.message) : undefined;\n\treturn cause === undefined || message.includes(cause) ? message : `${message}: ${cause}`;\n}\n\n/** How far guards and the serializer follow `cause`, so a cyclic or very deep chain stays bounded. */\nconst MAX_STORAGE_CAUSE_DEPTH = 8;\n\n/**\n * A storage failure as a command shows it: the first line of its message, then of its innermost cause's when the\n * message does not already hold it, and the innermost code along its causes, such as a TLS error's code, a SQLSTATE\n * or a configuration error's reason. Adapters redact their causes, so nothing here needs redacting again.\n */\nexport function describeStorageFailure(error: Error): string {\n\tconst firstLine = (text: string): string => text.split(\"\\n\", 1)[0]!.trim();\n\tlet innermost: Error = error;\n\tlet code: string | undefined;\n\tlet current = error.cause;\n\tfor (let depth = 0; depth < MAX_STORAGE_CAUSE_DEPTH && current instanceof Error; depth++) {\n\t\tinnermost = current;\n\t\tconst named = current as Error & { readonly code?: string | number; readonly reason?: string };\n\t\tconst label = current instanceof StorageConfigError ? named.reason : named.code;\n\t\tif (typeof label === \"string\") code = label;\n\t\tcurrent = current.cause;\n\t}\n\tconst message = firstLine(error.message);\n\tconst cause = firstLine(innermost.message);\n\tconst text = message.includes(cause) ? message : `${message}: ${cause}`;\n\treturn code === undefined || text.includes(code) ? text : `${text} (${code})`;\n}\n\nexport type StorageWriteLockTimeoutCode = \"write-lock-timeout\";\n/** Where the writer was when it gave up: behind older writers in the queue, or first in line and trying the lock. */\nexport type StorageWriteLockWaitPhase = \"queued\" | \"acquiring\";\n\nexport interface StorageWriteLockTimeoutDetails {\n\t/** The lock wait that ran out: how long the lock may stay held with no other connection committing. */\n\treadonly timeoutMs: number;\n\t/** How long the lock had been held with no other connection committing when the writer gave up. */\n\treadonly elapsedMs: number;\n\treadonly phase: StorageWriteLockWaitPhase;\n\t/** The process whose connection took the lock most recently, when its record names one. */\n\treadonly holderPid?: number;\n\t/** How long ago that process took the lock. */\n\treadonly holderHeldMs?: number;\n\t/**\n\t * When no record names the holder: the processes of the other connections trying for the lock, comma-separated.\n\t * One of them may hold it, having taken it before it could record so.\n\t */\n\treadonly holderCandidates?: string;\n}\n\nconst WRITE_LOCK_TIMEOUT_HINT =\n\t\"Another process holds the database's write lock without committing; check that process (it may be stopped or starved of CPU), or pass a longer lockWaitMs. Retrying later is safe\";\n\n/**\n * A write transaction gave up waiting for the database's write lock: the lock stayed held for the whole lock wait\n * while no other connection committed. Nothing of the transaction ran. It is a `StorageUnavailableError`, so code\n * that handles an unavailable store keeps handling it, and its message keeps that error's `Storage unavailable:`\n * prefix for relays that forward only the message.\n */\nexport class StorageWriteLockTimeoutError extends StorageUnavailableError {\n\toverride readonly name = \"StorageWriteLockTimeoutError\" as const;\n\treadonly code: StorageWriteLockTimeoutCode = \"write-lock-timeout\";\n\treadonly retryable = true as const;\n\treadonly hint: string = WRITE_LOCK_TIMEOUT_HINT;\n\treadonly timeoutMs: number;\n\treadonly elapsedMs: number;\n\treadonly phase: StorageWriteLockWaitPhase;\n\tdeclare readonly holderPid?: number;\n\tdeclare readonly holderHeldMs?: number;\n\tdeclare readonly holderCandidates?: string;\n\tconstructor(descriptor: StorageDescriptor, details: StorageWriteLockTimeoutDetails, cause?: StorageFailureCause) {\n\t\tconst heldBy =\n\t\t\tdetails.holderPid !== undefined\n\t\t\t\t? `by process ${details.holderPid}${details.holderHeldMs === undefined ? \"\" : ` (which took it ${details.holderHeldMs} ms ago)`} `\n\t\t\t\t: details.holderCandidates !== undefined\n\t\t\t\t\t? `by a writer that has not recorded taking it (processes trying for it: ${details.holderCandidates}) `\n\t\t\t\t\t: \"\";\n\t\tsuper(\n\t\t\tdescriptor,\n\t\t\tcause,\n\t\t\t`database is locked; gave up after ${details.elapsedMs} ms waiting for the write lock${details.phase === \"queued\" ? \" in the writers' queue\" : \"\"}, held all that time ${heldBy}with no other connection committing (write-lock-timeout). ${WRITE_LOCK_TIMEOUT_HINT}`,\n\t\t);\n\t\tthis.timeoutMs = details.timeoutMs;\n\t\tthis.elapsedMs = details.elapsedMs;\n\t\tthis.phase = details.phase;\n\t\tif (details.holderPid !== undefined) this.holderPid = details.holderPid;\n\t\tif (details.holderHeldMs !== undefined) this.holderHeldMs = details.holderHeldMs;\n\t\tif (details.holderCandidates !== undefined) this.holderCandidates = details.holderCandidates;\n\t}\n}\n\nexport type StorageUnsupportedOperationCode = \"unsupported-operation\";\n/** Operations that only some database handles support. */\nconst STORAGE_OPERATIONS = [\"getWriterQueueStats\", \"getWriterQueueDegradation\"] as const;\nexport type StorageOperation = (typeof STORAGE_OPERATIONS)[number];\n\n/** The database handle does not support the operation, for example a handle from another adapter. */\nexport class StorageUnsupportedOperationError extends StorageError {\n\toverride readonly name = \"StorageUnsupportedOperationError\" as const;\n\treadonly code: StorageUnsupportedOperationCode = \"unsupported-operation\";\n\treadonly operation: StorageOperation;\n\treadonly adapter: string;\n\treadonly location: string;\n\treadonly hint: string;\n\tconstructor(descriptor: StorageDescriptor, operation: StorageOperation) {\n\t\tconst hint = `Call ${operation} with a database from openNodeSqliteDatabase or wrapNodeSqliteDatabase`;\n\t\tsuper(\n\t\t\t`Unsupported storage operation: ${operation} on ${descriptor.adapter} at ${descriptor.location} (unsupported-operation). ${hint}`,\n\t\t);\n\t\tthis.operation = operation;\n\t\tthis.adapter = descriptor.adapter;\n\t\tthis.location = descriptor.location;\n\t\tthis.hint = hint;\n\t}\n}\n\nexport type StorageWriterQueueDegradedCode = \"writer-queue-degraded\";\nconst WRITER_QUEUE_DEGRADED_REASONS = [\n\t\"watch-unavailable\",\n\t\"wake-failed\",\n\t\"stale-ticket-kept\",\n\t\"holder-record-unavailable\",\n] as const;\n/**\n * What degraded: `\"watch-unavailable\"`, a waiting writer cannot watch its release notice and polls instead;\n * `\"wake-failed\"`, a writer letting go of the lock could not read the queue or notify the next writer;\n * `\"stale-ticket-kept\"`, a ticket or its notice could not be removed, either when its writer left or after abandonment;\n * `\"holder-record-unavailable\"`, the connection could not keep its record of holding the write lock, or remove an\n * exited process's.\n */\nexport type StorageWriterQueueDegradedReason = (typeof WRITER_QUEUE_DEGRADED_REASONS)[number];\n\nconst WRITER_QUEUE_DEGRADED_HINTS: Readonly<Record<StorageWriterQueueDegradedReason, string>> = {\n\t\"watch-unavailable\":\n\t\t\"Writers still take the lock in turn but notice a released lock by polling; check file-watch limits (fs.inotify.max_user_instances and max_user_watches on Linux)\",\n\t\"wake-failed\":\n\t\t\"Writers still take the lock in turn, but the next writer notices a released lock at its next check instead of at once; make the writers' queue directories next to the database (<file>-writers and <file>-wakes) readable and writable\",\n\t\"stale-ticket-kept\":\n\t\t\"An entry or release notice could not be removed from the writers' queue directories next to the database (<file>-writers and <file>-wakes); a remaining live ticket may delay other writers until it becomes stale. Make the directories writable for every writer, or remove abandoned entries by hand\",\n\t\"holder-record-unavailable\":\n\t\t\"Writers still take the lock in turn, but a writer that gives up waiting may not name the process holding the lock; make the write-lock records directory next to the database (<file>-holders) readable and writable for every writer\",\n};\n\n/**\n * Not a failure: a node-sqlite connection fell back from the prompt handoff of the write lock, kept a ticket or\n * notice it could not remove, or could not keep its record of holding the write lock. Transactions keep working. Each reason is recorded once on the connection, readable with\n * `getWriterQueueDegradation`, and emitted once as a process warning (`process.on(\"warning\")`), which Atomic's own\n * processes suppress.\n */\nexport class StorageWriterQueueDegradedError extends StorageError {\n\toverride readonly name = \"StorageWriterQueueDegradedError\" as const;\n\treadonly code: StorageWriterQueueDegradedCode = \"writer-queue-degraded\";\n\treadonly reason: StorageWriterQueueDegradedReason;\n\treadonly adapter: string;\n\treadonly location: string;\n\treadonly hint: string;\n\tdeclare readonly cause: StorageFailureCause;\n\tconstructor(descriptor: StorageDescriptor, reason: StorageWriterQueueDegradedReason, cause?: StorageFailureCause) {\n\t\tconst hint = WRITER_QUEUE_DEGRADED_HINTS[reason];\n\t\tsuper(\n\t\t\t`Storage writers' queue degraded: ${descriptor.adapter} at ${descriptor.location} (writer-queue-degraded, ${reason}). ${hint}`,\n\t\t\t{ cause },\n\t\t);\n\t\tthis.hint = hint;\n\t\tthis.reason = reason;\n\t\tthis.adapter = descriptor.adapter;\n\t\tthis.location = descriptor.location;\n\t}\n}\n\nexport type StorageWriterQueueUnusableCode = \"writer-queue-unusable\";\n\nconst WRITER_QUEUE_UNUSABLE_HINT =\n\t\"Make the writers' queue directories next to the database (<file>-writers and <file>-wakes) readable and writable for every process that writes the database\";\n\n/**\n * A node-sqlite transaction could not use the writers' queue next to the database: it could not read the queue\n * directory, or add, refresh, or read a ticket or its release notice. Nothing of the transaction ran. It is a\n * `StorageUnavailableError`, and its message keeps that error's `Storage unavailable:` prefix.\n */\nexport class StorageWriterQueueUnusableError extends StorageUnavailableError {\n\toverride readonly name = \"StorageWriterQueueUnusableError\" as const;\n\treadonly code: StorageWriterQueueUnusableCode = \"writer-queue-unusable\";\n\treadonly hint: string = WRITER_QUEUE_UNUSABLE_HINT;\n\t/** The filesystem's error code, such as `EACCES`, when the cause has one. */\n\tdeclare readonly errno?: string;\n\tconstructor(descriptor: StorageDescriptor, cause: StorageFailureCause) {\n\t\tconst { code } = (cause ?? {}) as { readonly code?: unknown };\n\t\tsuper(\n\t\t\tdescriptor,\n\t\t\tcause,\n\t\t\t`the writers' queue next to the database is unusable: ${cause instanceof Error ? cause.message : String(cause)} (writer-queue-unusable). ${WRITER_QUEUE_UNUSABLE_HINT}`,\n\t\t);\n\t\tif (typeof code === \"string\") this.errno = code;\n\t}\n}\n\nexport const STORAGE_TRANSIENT_ERROR_CODES = [\n\t\"stream-expired\",\n\t\"transaction-timeout\",\n\t\"connection-refused\",\n\t\"connection-lost\",\n\t\"lock-conflict\",\n\t\"read-only-server\",\n] as const;\n/**\n * Why a call to a database server failed for a while: `\"stream-expired\"`, the server ended a stream that stayed idle\n * too long, as a stream does whose process was stopped in the middle of a transaction; `\"transaction-timeout\"`, the\n * server rolled back a transaction that kept the write lock while another writer waited; `\"connection-refused\"`, no\n * connection to the server could be made; `\"connection-lost\"`, the connection broke while a request was on its way or\n * being answered; `\"lock-conflict\"`, the server aborted the transaction to resolve a lock conflict (a serialization\n * failure, a deadlock, or a lock wait that timed out); `\"read-only-server\"`, the server refused a write because it\n * accepts reads only, as a read replica does, or a primary for a while during a failover or when its storage is\n * nearly full.\n */\nexport type StorageTransientErrorCode = (typeof STORAGE_TRANSIENT_ERROR_CODES)[number];\n/**\n * Whether the failed call may have changed the database: `\"not-applied\"`, it cannot have; `\"unknown\"`, the connection\n * broke after the server may have applied a write that commits on its own (a commit, a batch, or a statement outside\n * a transaction).\n */\nexport type StorageTransientOutcome = \"not-applied\" | \"unknown\";\n\nexport interface StorageTransientErrorDetails {\n\treadonly code: StorageTransientErrorCode;\n\treadonly outcome: StorageTransientOutcome;\n\t/** Which run of the call failed, counting from 1: a call that applied nothing runs again, up to a limit. */\n\treadonly attempts: number;\n}\n\nconst TRANSIENT_HINTS: Readonly<Record<StorageTransientOutcome, string>> = {\n\t\"not-applied\":\n\t\t\"Check that the database server is reachable and that this process is not stopped or starved of CPU, then retry; nothing was written\",\n\tunknown:\n\t\t\"Check that the database server is reachable; the write may have been applied, so read it back before retrying a write that is not idempotent\",\n};\n\n/** What a failure of one of these codes asks of the reader, in place of the hint its outcome gives. */\nconst TRANSIENT_CODE_HINTS: Readonly<Partial<Record<StorageTransientErrorCode, string>>> = {\n\t\"read-only-server\":\n\t\t\"The server accepts reads only (SQLSTATE 25006): either the URL names a read replica or read-only endpoint (use the primary or the read/write endpoint), or the server is read-only right now (storage nearly full, or a failover in progress); nothing was written\",\n};\n\n/**\n * A call to a database server failed for a reason that passes: the server ended an idle stream or a transaction that\n * kept the write lock, or the connection could not be made or broke. `outcome` says whether the call may have written\n * anything. A database from `createSqliteDatabase` runs a call that wrote nothing again before it fails with this\n * error. It is a `StorageUnavailableError`, and its message keeps that error's `Storage unavailable:` prefix.\n */\nexport class StorageTransientError extends StorageUnavailableError {\n\toverride readonly name = \"StorageTransientError\" as const;\n\treadonly code: StorageTransientErrorCode;\n\treadonly outcome: StorageTransientOutcome;\n\treadonly attempts: number;\n\treadonly retryable = true as const;\n\treadonly hint: string;\n\tconstructor(descriptor: StorageDescriptor, details: StorageTransientErrorDetails, cause?: StorageFailureCause) {\n\t\tconst hint = TRANSIENT_CODE_HINTS[details.code] ?? TRANSIENT_HINTS[details.outcome];\n\t\tsuper(\n\t\t\tdescriptor,\n\t\t\tcause,\n\t\t\t`the database server call failed on attempt ${details.attempts} (${details.code}). ${hint}`,\n\t\t);\n\t\tthis.code = details.code;\n\t\tthis.outcome = details.outcome;\n\t\tthis.attempts = details.attempts;\n\t\tthis.hint = hint;\n\t}\n}\n\nexport const SESSION_BLOB_ERROR_CODES = [\n\t\"blobs-unsupported\",\n\t\"blob-missing\",\n\t\"blob-corrupt\",\n\t\"blob-incomplete\",\n] as const;\n/**\n * `\"blobs-unsupported\"`: the session store cannot hold blobs, and the operation needs it to; nothing was written.\n * `\"blob-missing\"`: the session holds no blob with the hash a reference names.\n * `\"blob-corrupt\"`: content carried in an exported session does not have the hash it is recorded under; nothing was\n * written.\n * `\"blob-incomplete\"`: the store holds a blob's record but lost part of its content.\n */\nexport type SessionBlobErrorCode = (typeof SESSION_BLOB_ERROR_CODES)[number];\n\nexport interface SessionBlobErrorFields {\n\treadonly sessionId: string;\n\t/** The blob's recorded SHA-256, as lowercase hex. For `\"blob-missing\"` reported by a copy: the first one missing. */\n\treadonly hash?: string;\n\t/** For `\"blob-missing\"` reported by a copy or an export: how many blobs the source did not hold. */\n\treadonly missing?: number;\n\t/** For `\"blob-incomplete\"`: the size the store recorded for the blob. */\n\treadonly bytes?: number;\n\t/** For `\"blob-corrupt\"`: the SHA-256 of the content that was found instead. */\n\treadonly actualHash?: string;\n\t/** For `\"blobs-unsupported\"`: the adapter of the store that cannot hold blobs. */\n\treadonly adapter?: string;\n}\n\nconst SESSION_BLOB_HINTS: Readonly<Record<SessionBlobErrorCode, string>> = {\n\t\"blobs-unsupported\":\n\t\t\"Keep the session in a SQLite or libSQL session store (the default sessions database, --session-store <path>, or a sessions.storage selection), or give a custom store putBlob and getBlob\",\n\t\"blob-missing\": \"The session no longer holds this output; run the tool again to see it\",\n\t\"blob-corrupt\": \"The exported session was changed after it was written; export it again from its source\",\n\t\"blob-incomplete\": \"The store lost part of this output; run the tool again to see it\",\n};\n\nfunction sessionBlobSubject(code: SessionBlobErrorCode, fields: SessionBlobErrorFields): string {\n\tswitch (code) {\n\t\tcase \"blobs-unsupported\":\n\t\t\treturn `Session store cannot hold blobs: ${fields.adapter} store of session ${fields.sessionId}`;\n\t\tcase \"blob-missing\":\n\t\t\treturn `Session blob not found: ${fields.hash}${(fields.missing ?? 0) > 1 ? ` and ${fields.missing! - 1} more` : \"\"} in session ${fields.sessionId}`;\n\t\tcase \"blob-corrupt\":\n\t\t\treturn `Session blob does not match its hash: ${fields.hash} in session ${fields.sessionId}`;\n\t\tcase \"blob-incomplete\":\n\t\t\treturn `Session blob is incomplete: ${fields.hash} (${fields.bytes} bytes) in session ${fields.sessionId}`;\n\t}\n}\n\n/**\n * A session blob, the content a session stores apart from its entries (a large tool output), could not be stored,\n * found, or trusted. Never retryable: each code needs a different store, a new tool run, or a new export.\n */\nexport class SessionBlobError extends StorageError {\n\toverride readonly name = \"SessionBlobError\" as const;\n\treadonly code: SessionBlobErrorCode;\n\treadonly hint: string;\n\treadonly sessionId: string;\n\tdeclare readonly hash?: string;\n\tdeclare readonly missing?: number;\n\tdeclare readonly bytes?: number;\n\tdeclare readonly actualHash?: string;\n\tdeclare readonly adapter?: string;\n\tconstructor(code: SessionBlobErrorCode, fields: SessionBlobErrorFields, options?: ErrorOptions) {\n\t\tconst hint = SESSION_BLOB_HINTS[code];\n\t\tsuper(`${sessionBlobSubject(code, fields)} (${code}). ${hint}`, options);\n\t\tthis.code = code;\n\t\tthis.hint = hint;\n\t\tthis.sessionId = fields.sessionId;\n\t\tif (fields.hash !== undefined) this.hash = fields.hash;\n\t\tif (fields.missing !== undefined) this.missing = fields.missing;\n\t\tif (fields.bytes !== undefined) this.bytes = fields.bytes;\n\t\tif (fields.actualHash !== undefined) this.actualHash = fields.actualHash;\n\t\tif (fields.adapter !== undefined) this.adapter = fields.adapter;\n\t}\n}\n\nexport const SESSION_SPILL_ERROR_CODES = [\n\t\"spill-dir-refused\",\n\t\"spill-write-failed\",\n\t\"spill-read-failed\",\n\t\"spill-missing\",\n\t\"spill-corrupt\",\n\t\"spill-cleanup-failed\",\n] as const;\n/**\n * How the in-memory session store failed to keep a released session's history in its file on disk, under the agent\n * directory's `released-history` directory.\n * `\"spill-dir-refused\"`: the directory for those files could not be created; released sessions keep their history in\n * memory. Recorded, not thrown.\n * `\"spill-write-failed\"`: a released session's history could not be written to its file; it stays in memory and\n * nothing is lost. Recorded, not thrown.\n * `\"spill-read-failed\"`: a released session's history could not be read back from its file; `retryable` when the\n * filesystem's failure passes (out of file descriptors, interrupted, busy).\n * `\"spill-missing\"`: a released session's file is gone or holds less than was written to it; its history is lost.\n * `\"spill-corrupt\"`: a released session's file holds something other than what was written to it; its history is lost.\n * `\"spill-cleanup-failed\"`: the file of a deleted or replaced session, or a closed store's directory, could not be\n * removed; it stays on disk until the process's directory is removed. Recorded, not thrown.\n */\nexport type SessionSpillErrorCode = (typeof SESSION_SPILL_ERROR_CODES)[number];\n\nexport interface SessionSpillErrorFields {\n\t/** The directory the store keeps released sessions' history in. */\n\treadonly directory: string;\n\t/** The session, for every code but `\"spill-dir-refused\"` and a whole directory's `\"spill-cleanup-failed\"`. */\n\treadonly sessionId?: string;\n\t/** The bytes of history the write held, or that the file should hold. */\n\treadonly bytes?: number;\n\t/** For `\"spill-missing\"` and `\"spill-corrupt\"`: the bytes the file held, when it still exists. */\n\treadonly foundBytes?: number;\n\t/** The filesystem's error code, such as `ENOSPC` or `ENOENT`, when the failure has one. */\n\treadonly errno?: string;\n}\n\n/** Filesystem failures that pass: a read that met one may work when tried again. */\nconst TRANSIENT_SPILL_ERRNOS: ReadonlySet<string | undefined> = new Set([\n\t\"EMFILE\",\n\t\"ENFILE\",\n\t\"EAGAIN\",\n\t\"EBUSY\",\n\t\"EINTR\",\n]);\n\nconst SESSION_SPILL_HINTS: Readonly<Record<SessionSpillErrorCode, string>> = {\n\t\"spill-dir-refused\":\n\t\t\"Released sessions keep their history in memory; make the agent directory writable by this account, or keep sessions in a SQLite session store\",\n\t\"spill-write-failed\":\n\t\t\"The session keeps its history in memory and nothing was lost; free space on the agent directory's disk or make it writable, or keep sessions in a SQLite session store\",\n\t\"spill-read-failed\":\n\t\t\"Check that the agent directory is readable and that the process has file descriptors to spare, then reopen the session\",\n\t\"spill-missing\":\n\t\t\"Something removed or truncated the session's file while the process ran, so the session cannot be reopened; leave the agent directory's released-history directory alone while Atomic runs, or keep sessions in a SQLite session store\",\n\t\"spill-corrupt\":\n\t\t\"Something changed the session's file while the process ran, so the session cannot be reopened; leave the agent directory's released-history directory alone while Atomic runs, or keep sessions in a SQLite session store\",\n\t\"spill-cleanup-failed\":\n\t\t\"The files stay on disk until the process's directory is removed, when it exits or by the next start's sweep; the store is not affected\",\n};\n\nfunction sessionSpillSubject(code: SessionSpillErrorCode, fields: SessionSpillErrorFields): string {\n\tconst session = `session ${fields.sessionId} in ${fields.directory}`;\n\tswitch (code) {\n\t\tcase \"spill-dir-refused\":\n\t\t\treturn `Could not use a directory for released sessions' history: ${fields.directory}`;\n\t\tcase \"spill-write-failed\":\n\t\t\treturn `Could not move a released session's history out of memory: ${session}`;\n\t\tcase \"spill-read-failed\":\n\t\t\treturn `Could not read a released session's history: ${session}`;\n\t\tcase \"spill-missing\":\n\t\t\treturn `A released session's history is missing: ${session}, ${fields.foundBytes ?? 0} of ${fields.bytes} bytes found`;\n\t\tcase \"spill-corrupt\":\n\t\t\treturn `A released session's history was changed on disk: ${session}`;\n\t\tcase \"spill-cleanup-failed\":\n\t\t\treturn `Could not remove released sessions' history from disk: ${fields.sessionId === undefined ? fields.directory : session}`;\n\t}\n}\n\n/**\n * The in-memory session store moves a released session's history to a file of its own under the agent directory and\n * reads it back when the session is loaded; this error says what went wrong with those files. `\"spill-read-failed\"`,\n * `\"spill-missing\"` and `\"spill-corrupt\"` are thrown by `load`, and a retryable `\"spill-read-failed\"` by a listing too;\n * a listing leaves out a session whose history it cannot read otherwise and records why once per session. The other\n * codes are recorded once each on the store. Each record is read with `spillDegradation()` and emitted once as a\n * process warning, and the store keeps the history in memory.\n */\nexport class SessionSpillError extends StorageError {\n\toverride readonly name = \"SessionSpillError\" as const;\n\treadonly code: SessionSpillErrorCode;\n\treadonly hint: string;\n\treadonly retryable: boolean;\n\treadonly directory: string;\n\tdeclare readonly sessionId?: string;\n\tdeclare readonly bytes?: number;\n\tdeclare readonly foundBytes?: number;\n\tdeclare readonly errno?: string;\n\tconstructor(code: SessionSpillErrorCode, fields: SessionSpillErrorFields, options?: ErrorOptions) {\n\t\tconst hint = SESSION_SPILL_HINTS[code];\n\t\tsuper(`${sessionSpillSubject(code, fields)} (${code}). ${hint}`, options);\n\t\tthis.code = code;\n\t\tthis.hint = hint;\n\t\tthis.retryable = code === \"spill-read-failed\" && TRANSIENT_SPILL_ERRNOS.has(fields.errno);\n\t\tthis.directory = fields.directory;\n\t\tif (fields.sessionId !== undefined) this.sessionId = fields.sessionId;\n\t\tif (fields.bytes !== undefined) this.bytes = fields.bytes;\n\t\tif (fields.foundBytes !== undefined) this.foundBytes = fields.foundBytes;\n\t\tif (fields.errno !== undefined) this.errno = fields.errno;\n\t}\n}\n\n/** Every code a storage error that carries one can have. */\nexport type StorageErrorCode =\n\t| SessionBlobErrorCode\n\t| SessionSpillErrorCode\n\t| StorageConfigErrorCode\n\t| StorageWriteLockTimeoutCode\n\t| StorageUnsupportedOperationCode\n\t| StorageWriterQueueDegradedCode\n\t| StorageWriterQueueUnusableCode\n\t| StorageTransientErrorCode\n\t| JournalCatalogErrorCode\n\t| JournalShardUnavailableErrorCode\n\t| JournalAdoptErrorCode;\n\nfunction hasNameAndCode(value: unknown, name: string, code: string): boolean {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tconst candidate = value as { readonly name?: unknown; readonly code?: unknown };\n\treturn candidate.name === name && candidate.code === code;\n}\n\n/** A `StorageConfigError`, from this module or another copy of it, or a rehydrated one. */\nexport function isStorageConfigError(value: unknown): value is StorageConfigError {\n\treturn value instanceof StorageConfigError || hasNameAndCode(value, \"StorageConfigError\", \"invalid-config\");\n}\n\nexport function isStorageWriteLockTimeoutError(value: unknown): value is StorageWriteLockTimeoutError {\n\treturn (\n\t\tvalue instanceof StorageWriteLockTimeoutError ||\n\t\thasNameAndCode(value, \"StorageWriteLockTimeoutError\", \"write-lock-timeout\")\n\t);\n}\n\nexport function isStorageUnsupportedOperationError(value: unknown): value is StorageUnsupportedOperationError {\n\treturn (\n\t\tvalue instanceof StorageUnsupportedOperationError ||\n\t\thasNameAndCode(value, \"StorageUnsupportedOperationError\", \"unsupported-operation\")\n\t);\n}\n\nexport function isStorageWriterQueueDegradedError(value: unknown): value is StorageWriterQueueDegradedError {\n\treturn (\n\t\tvalue instanceof StorageWriterQueueDegradedError ||\n\t\thasNameAndCode(value, \"StorageWriterQueueDegradedError\", \"writer-queue-degraded\")\n\t);\n}\n\nexport function isStorageWriterQueueUnusableError(value: unknown): value is StorageWriterQueueUnusableError {\n\treturn (\n\t\tvalue instanceof StorageWriterQueueUnusableError ||\n\t\thasNameAndCode(value, \"StorageWriterQueueUnusableError\", \"writer-queue-unusable\")\n\t);\n}\n\n/** A `StorageTransientError`, from this module or another copy of it, or a rehydrated one. */\nexport function isStorageTransientError(value: unknown): value is StorageTransientError {\n\treturn (\n\t\tvalue instanceof StorageTransientError || hasCode(value, \"StorageTransientError\", STORAGE_TRANSIENT_ERROR_CODES)\n\t);\n}\n\nexport function isSessionBlobError(value: unknown): value is SessionBlobError {\n\treturn value instanceof SessionBlobError || hasCode(value, \"SessionBlobError\", SESSION_BLOB_ERROR_CODES);\n}\n\n/** A `SessionSpillError`, from this module or another copy of it, or a rehydrated one. */\nexport function isSessionSpillError(value: unknown): value is SessionSpillError {\n\treturn value instanceof SessionSpillError || hasCode(value, \"SessionSpillError\", SESSION_SPILL_ERROR_CODES);\n}\n\n/**\n * Any storage error: an instance of `StorageError` or one of its subclasses, including a rehydrated one, or a copy of\n * a storage error with a stable `code` from another module instance, recognized by its name and code.\n */\nexport function isStorageError(value: unknown): value is StorageError {\n\treturn (\n\t\tvalue instanceof StorageError ||\n\t\tisStorageConfigError(value) ||\n\t\tisStorageWriteLockTimeoutError(value) ||\n\t\tisStorageUnsupportedOperationError(value) ||\n\t\tisStorageWriterQueueDegradedError(value) ||\n\t\tisStorageWriterQueueUnusableError(value) ||\n\t\tisStorageTransientError(value) ||\n\t\tisSessionBlobError(value) ||\n\t\tisSessionSpillError(value) ||\n\t\tisJournalStoreError(value)\n\t);\n}\n\nfunction causeOf(value: unknown): unknown {\n\treturn typeof value === \"object\" && value !== null ? (value as { readonly cause?: unknown }).cause : undefined;\n}\n\n/** The write-lock timeout anywhere in an error's cause chain, for failures that wrap it. */\nexport function findStorageWriteLockTimeoutError(error: unknown): StorageWriteLockTimeoutError | undefined {\n\tlet current = error;\n\tfor (let depth = 0; depth < MAX_STORAGE_CAUSE_DEPTH; depth++) {\n\t\tif (isStorageWriteLockTimeoutError(current)) return current;\n\t\tcurrent = causeOf(current);\n\t}\n\treturn undefined;\n}\n\n/** A JSON-safe fact an error of the journal store carries: an id, a path, a count, a phase. */\nexport type JournalStoreFieldValue = string | number | boolean | null;\nexport type JournalStoreFields = Readonly<Record<string, JournalStoreFieldValue>>;\n\nexport const JOURNAL_CATALOG_ERROR_CODES = [\n\t\"catalog-unavailable\",\n\t\"schema-version\",\n\t\"corrupt\",\n\t\"write-failed\",\n\t\"run-conflict\",\n\t\"run-not-found\",\n\t\"run-moved\",\n] as const;\nexport type JournalCatalogErrorCode = (typeof JOURNAL_CATALOG_ERROR_CODES)[number];\n\nexport const JOURNAL_SHARD_UNAVAILABLE_ERROR_CODES = [\"shard-missing\", \"shard-open-failed\"] as const;\nexport type JournalShardUnavailableErrorCode = (typeof JOURNAL_SHARD_UNAVAILABLE_ERROR_CODES)[number];\n\nexport const JOURNAL_ADOPT_ERROR_CODES = [\"path-not-found\", \"not-a-journal\", \"schema-version\", \"run-conflict\"] as const;\nexport type JournalAdoptErrorCode = (typeof JOURNAL_ADOPT_ERROR_CODES)[number];\n\n/** What a catalog write was doing when it failed. */\nexport type JournalCatalogPhase =\n\t| \"opening\"\n\t| \"placing-run\"\n\t| \"recording-status\"\n\t| \"removing-run\"\n\t| \"registering-shard\"\n\t| \"moving-run\";\n\n/** Why a path is not an adoptable journal. */\nexport type JournalAdoptNotJournalReason = \"not-sqlite\" | \"no-journal-tables\" | \"store-catalog\" | \"directory\";\n\nconst MAX_CAUSE_DEPTH = 8;\nconst DETAIL_LIMIT = 200;\n\n/** The first line of a cause's message, short and free of stack frames, as `StorageUnavailableError` keeps it. */\nfunction causeDetail(cause: StorageFailureCause | Error | undefined): string | null {\n\tif (!(cause instanceof Error)) return null;\n\tconst nested = cause.cause instanceof Error ? cause.cause.message : \"\";\n\tconst line = (cause.message.includes(nested) ? cause.message : `${cause.message}: ${nested}`).split(\"\\n\", 1)[0]!;\n\tconst trimmed = line.trim();\n\tif (trimmed === \"\") return null;\n\treturn trimmed.length > DETAIL_LIMIT ? `${trimmed.slice(0, DETAIL_LIMIT - 1)}…` : trimmed;\n}\n\n/** Only a write lock another connection holds is worth retrying; every other storage failure needs a person. */\nfunction busyCause(cause: StorageFailureCause | Error | undefined): boolean {\n\treturn isSqliteBusy(cause) || isRetryableStorageError(cause);\n}\n\ninterface JournalStoreErrorParts {\n\treadonly name?: string;\n\treadonly code: string;\n\treadonly message: string;\n\treadonly hint?: string;\n\treadonly fields: JournalStoreFields;\n\treadonly retryable: boolean;\n\treadonly cause?: StorageFailureCause | Error;\n}\n\n/**\n * The family of the workflow journal store: its catalog, its shards, and adopting journals into it. Every member\n * carries a stable `code`, JSON-safe `fields`, a `hint` naming what to do next, and `retryable`.\n */\nexport class JournalStoreError extends StorageError {\n\toverride readonly name: string;\n\treadonly code: string;\n\treadonly hint: string | undefined;\n\treadonly fields: JournalStoreFields;\n\treadonly retryable: boolean;\n\n\tconstructor(parts: JournalStoreErrorParts) {\n\t\tsuper(parts.message, parts.cause === undefined ? undefined : { cause: parts.cause });\n\t\tthis.name = parts.name ?? \"JournalStoreError\";\n\t\tthis.code = parts.code;\n\t\tthis.hint = parts.hint;\n\t\tthis.fields = Object.freeze({ ...parts.fields });\n\t\tthis.retryable = parts.retryable;\n\t}\n}\n\nfunction compact(fields: Readonly<Record<string, JournalStoreFieldValue | undefined>>): JournalStoreFields {\n\treturn Object.fromEntries(Object.entries(fields).filter(([, value]) => value !== undefined)) as JournalStoreFields;\n}\n\n/** A schema version as a JSON-safe field: a number or null as it is, any other value SQLite stores as its text. */\nfunction schemaVersionField(found: SqliteValue | undefined): string | number | null | undefined {\n\treturn found === undefined || found === null || typeof found === \"number\" ? found : String(found);\n}\n\nexport interface JournalCatalogErrorInit {\n\treadonly code: JournalCatalogErrorCode;\n\treadonly catalogPath: string;\n\treadonly phase?: JournalCatalogPhase;\n\treadonly runId?: string;\n\treadonly shardId?: number;\n\treadonly shardPath?: string;\n\t/** `schema-version`: the version found in the catalog; null when it has none. */\n\treadonly found?: SqliteValue;\n\t/** `schema-version`: the version this Atomic supports. */\n\treadonly supported?: number;\n\t/** `corrupt`: which consistency rule the catalog breaks. */\n\treadonly rule?: string;\n\t/** `run-not-found`: the journal selection searched, as `atomic storage status` describes it. */\n\treadonly selection?: string;\n\t/** `run-not-found`: whether this machine's storage is local only, so a run of another machine cannot be here. */\n\treadonly localOnly?: boolean;\n\t/** `run-moved`: the last sequence number a read returned before the run moved. */\n\treadonly lastSeq?: number;\n\treadonly retryable?: boolean;\n\treadonly cause?: StorageFailureCause | Error;\n}\n\n/** The command that joins this machine to the team's shared storage; error hints across Atomic name it. */\nexport const SHARED_STORAGE_JOIN_HINT = \"atomic team join <url> --token-file <path>\";\n/** The command that joins a machine to a shared PostgreSQL database, which `atomic team join` refuses (#5218). */\nexport const POSTGRES_STORAGE_JOIN_HINT = \"atomic storage join <postgres-url> --password-file <path>\";\n/** The command that registers an older journal file in the journal store. */\nexport const JOURNAL_ADOPT_COMMAND = \"atomic storage adopt <path>\";\n\nfunction catalogText(init: JournalCatalogErrorInit, detail: string | null): { message: string; hint: string } {\n\tconst subject = init.catalogPath;\n\tswitch (init.code) {\n\t\tcase \"catalog-unavailable\":\n\t\t\treturn {\n\t\t\t\tmessage: `Journal catalog unavailable: ${subject}${detail === null ? \"\" : ` (${detail})`} (catalog-unavailable).`,\n\t\t\t\thint: \"Check that the journal directory is readable and writable and the disk has free space, then retry; `atomic storage status` shows the store in use.\",\n\t\t\t};\n\t\tcase \"schema-version\":\n\t\t\treturn {\n\t\t\t\tmessage: `Journal catalog schema not supported: ${subject} has version ${String(init.found)}, this Atomic supports ${String(init.supported)} (schema-version).`,\n\t\t\t\thint: \"Upgrade Atomic to the version that wrote this catalog, or select another journal with workflows.journal.\",\n\t\t\t};\n\t\tcase \"corrupt\":\n\t\t\treturn {\n\t\t\t\tmessage: `Journal catalog is inconsistent: ${subject} (${init.rule ?? \"unknown rule\"}) (corrupt).`,\n\t\t\t\thint: `Move ${subject} aside, then adopt every shard file in its directory again with \\`atomic storage adopt ${subject.replace(/[\\\\/][^\\\\/]*$/, \"\")}/shard-*.sqlite\\` to rebuild it.`,\n\t\t\t};\n\t\tcase \"write-failed\":\n\t\t\treturn {\n\t\t\t\tmessage: `Journal catalog write failed: ${subject} while ${init.phase ?? \"writing\"}${init.runId === undefined ? \"\" : ` run ${init.runId}`}${detail === null ? \"\" : ` (${detail})`} (write-failed).`,\n\t\t\t\thint: \"Free disk space or release the lock another process holds on the catalog, then retry; checkpoints already written stay on their shard.\",\n\t\t\t};\n\t\tcase \"run-conflict\":\n\t\t\treturn {\n\t\t\t\tmessage: `Journal run conflict: run ${init.runId ?? \"unknown\"} already has a different copy in ${init.shardPath ?? `shard ${String(init.shardId)}`} (run-conflict).`,\n\t\t\t\thint: \"Compare the two copies and check the catalog's current location before retrying consolidation; both copies are preserved when their histories differ.\",\n\t\t\t};\n\t\tcase \"run-moved\":\n\t\t\treturn {\n\t\t\t\tmessage: `Journal run moved while it was read: run ${init.runId ?? \"unknown\"} left ${init.shardPath ?? `shard ${String(init.shardId)}`} after sequence ${String(init.lastSeq)} and its new shard did not continue the history (run-moved).`,\n\t\t\t\thint: \"A consolidation moved this run while it was read; read it again.\",\n\t\t\t};\n\t\tcase \"run-not-found\":\n\t\t\treturn {\n\t\t\t\tmessage: `Workflow run not found: ${init.runId ?? \"unknown\"} in ${init.selection ?? subject} (run-not-found).`,\n\t\t\t\thint: init.localOnly\n\t\t\t\t\t? `This machine uses local-only storage and is not joined to shared storage. If the run started on another machine, join its storage with \\`${SHARED_STORAGE_JOIN_HINT}\\`; if it is in an older journal file, adopt it with \\`${JOURNAL_ADOPT_COMMAND}\\`.`\n\t\t\t\t\t: \"The shared storage selected here does not hold this run; check the run ID with `/workflows`.\",\n\t\t\t};\n\t}\n}\n\n/** The journal catalog, which maps every run to its shard, cannot be opened, read or written. */\nexport class JournalCatalogError extends JournalStoreError {\n\toverride readonly name = \"JournalCatalogError\" as const;\n\tdeclare readonly code: JournalCatalogErrorCode;\n\tdeclare readonly hint: string;\n\treadonly catalogPath: string;\n\treadonly phase: JournalCatalogPhase | undefined;\n\treadonly runId: string | undefined;\n\n\tconstructor(init: JournalCatalogErrorInit) {\n\t\tconst detail = causeDetail(init.cause);\n\t\tconst text = catalogText(init, detail);\n\t\tsuper({\n\t\t\tcode: init.code,\n\t\t\tmessage: text.message,\n\t\t\thint: text.hint,\n\t\t\tfields: compact({\n\t\t\t\tcatalogPath: init.catalogPath,\n\t\t\t\tphase: init.phase,\n\t\t\t\trunId: init.runId,\n\t\t\t\tshardId: init.shardId,\n\t\t\t\tshardPath: init.shardPath,\n\t\t\t\tfound: schemaVersionField(init.found),\n\t\t\t\tsupported: init.supported,\n\t\t\t\trule: init.rule,\n\t\t\t\tselection: init.selection,\n\t\t\t\tlocalOnly: init.localOnly,\n\t\t\t\tlastSeq: init.lastSeq,\n\t\t\t\tdetail: detail ?? undefined,\n\t\t\t}),\n\t\t\tretryable: init.retryable ?? (init.code === \"run-moved\" || busyCause(init.cause)),\n\t\t\tcause: init.cause,\n\t\t});\n\t\tthis.catalogPath = init.catalogPath;\n\t\tthis.phase = init.phase;\n\t\tthis.runId = init.runId;\n\t}\n}\n\nexport interface JournalShardUnavailableErrorInit {\n\treadonly code: JournalShardUnavailableErrorCode;\n\treadonly shardId: number;\n\treadonly shardPath: string;\n\treadonly runId?: string;\n\treadonly retryable?: boolean;\n\treadonly cause?: StorageFailureCause | Error;\n}\n\n/** The shard file that holds a run cannot be opened: it is missing, unreadable, or not a database. */\nexport class JournalShardUnavailableError extends JournalStoreError {\n\toverride readonly name = \"JournalShardUnavailableError\" as const;\n\tdeclare readonly code: JournalShardUnavailableErrorCode;\n\tdeclare readonly hint: string;\n\treadonly shardId: number;\n\treadonly shardPath: string;\n\treadonly runId: string | undefined;\n\n\tconstructor(init: JournalShardUnavailableErrorInit) {\n\t\tconst detail = causeDetail(init.cause);\n\t\tconst subject = `${init.shardPath}${init.runId === undefined ? \"\" : ` for run ${init.runId}`}`;\n\t\tconst missing = init.code === \"shard-missing\";\n\t\tsuper({\n\t\t\tcode: init.code,\n\t\t\tmessage: `Journal shard unavailable: ${subject}${detail === null ? \"\" : ` (${detail})`} (${init.code}).`,\n\t\t\thint: missing\n\t\t\t\t? \"Restore the file at this path: the catalog keeps its runs registered there.\"\n\t\t\t\t: \"Check the file's permissions and the disk's free space, then retry.\",\n\t\t\tfields: compact({\n\t\t\t\tshardId: init.shardId,\n\t\t\t\tshardPath: init.shardPath,\n\t\t\t\trunId: init.runId,\n\t\t\t\tdetail: detail ?? undefined,\n\t\t\t}),\n\t\t\tretryable: init.retryable ?? (!missing && busyCause(init.cause)),\n\t\t\tcause: init.cause,\n\t\t});\n\t\tthis.shardId = init.shardId;\n\t\tthis.shardPath = init.shardPath;\n\t\tthis.runId = init.runId;\n\t}\n}\n\nexport interface JournalAdoptErrorInit {\n\treadonly code: JournalAdoptErrorCode;\n\treadonly path: string;\n\treadonly reason?: JournalAdoptNotJournalReason;\n\treadonly runId?: string;\n\t/** `run-conflict`: where the store already has the run. */\n\treadonly existingPath?: string;\n\t/** `schema-version`: the version found in the journal; null when it has none. */\n\treadonly found?: SqliteValue;\n\treadonly supported?: number;\n\treadonly cause?: StorageFailureCause | Error;\n}\n\nfunction adoptText(init: JournalAdoptErrorInit): { message: string; hint: string } {\n\tswitch (init.code) {\n\t\tcase \"path-not-found\":\n\t\t\treturn {\n\t\t\t\tmessage: `Cannot adopt journal: ${init.path} does not exist (path-not-found).`,\n\t\t\t\thint: \"Pass the path of a journal .sqlite file, or of the directory holding its journal.sqlite.\",\n\t\t\t};\n\t\tcase \"not-a-journal\":\n\t\t\treturn {\n\t\t\t\tmessage: `Cannot adopt journal: ${init.path} is not a workflow journal (${init.reason ?? \"no-journal-tables\"}) (not-a-journal).`,\n\t\t\t\thint:\n\t\t\t\t\tinit.reason === \"store-catalog\"\n\t\t\t\t\t\t? \"The journal store's own catalog is never adopted; pass the path of a legacy journal file.\"\n\t\t\t\t\t\t: \"Pass a SQLite file that Atomic wrote workflow runs to, such as a journal.sqlite selected with ATOMIC_WORKFLOW_JOURNAL_PATH.\",\n\t\t\t};\n\t\tcase \"schema-version\":\n\t\t\treturn {\n\t\t\t\tmessage: `Cannot adopt journal: ${init.path} has schema version ${String(init.found)}, this Atomic supports ${String(init.supported)} (schema-version).`,\n\t\t\t\thint: \"Adopt it with the Atomic version that wrote it, or upgrade Atomic.\",\n\t\t\t};\n\t\tcase \"run-conflict\":\n\t\t\treturn {\n\t\t\t\tmessage: `Cannot adopt journal: ${init.path} holds run ${init.runId ?? \"unknown\"}, which the store already has in ${init.existingPath ?? \"another journal\"} (run-conflict).`,\n\t\t\t\thint: \"Adopt only one copy of a journal; nothing was registered.\",\n\t\t\t};\n\t}\n}\n\n/** A journal file cannot be adopted into the journal store; nothing was registered. */\nexport class JournalAdoptError extends JournalStoreError {\n\toverride readonly name = \"JournalAdoptError\" as const;\n\tdeclare readonly code: JournalAdoptErrorCode;\n\tdeclare readonly hint: string;\n\treadonly path: string;\n\treadonly reason: JournalAdoptNotJournalReason | undefined;\n\n\tconstructor(init: JournalAdoptErrorInit) {\n\t\tconst text = adoptText(init);\n\t\tsuper({\n\t\t\tcode: init.code,\n\t\t\tmessage: text.message,\n\t\t\thint: text.hint,\n\t\t\tfields: compact({\n\t\t\t\tpath: init.path,\n\t\t\t\treason: init.reason,\n\t\t\t\trunId: init.runId,\n\t\t\t\texistingPath: init.existingPath,\n\t\t\t\tfound: schemaVersionField(init.found),\n\t\t\t\tsupported: init.supported,\n\t\t\t\tdetail: causeDetail(init.cause) ?? undefined,\n\t\t\t}),\n\t\t\tretryable: false,\n\t\t\tcause: init.cause,\n\t\t});\n\t\tthis.path = init.path;\n\t\tthis.reason = init.reason;\n\t}\n}\n\nfunction hasCode<Code extends string>(value: unknown, name: string, codes: readonly Code[]): boolean {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tconst candidate = value as { name?: unknown; code?: unknown };\n\treturn candidate.name === name && codes.includes(candidate.code as Code);\n}\n\nconst JOURNAL_STORE_ERROR_NAMES: ReadonlySet<unknown> = new Set([\n\t\"JournalStoreError\",\n\t\"JournalCatalogError\",\n\t\"JournalShardUnavailableError\",\n\t\"JournalAdoptError\",\n]);\n\n/**\n * A journal store error: an instance of `JournalStoreError`, or a copy from another module instance or a process\n * boundary, recognized by the name of one of its classes and the shape every one of them has. An error of another\n * family that happens to carry a `code`, `fields` and `retryable` is not one.\n */\nexport function isJournalStoreError(value: unknown): value is JournalStoreError {\n\tif (value instanceof JournalStoreError) return true;\n\tif (typeof value !== \"object\" || value === null) return false;\n\tconst candidate = value as { name?: unknown; code?: unknown; fields?: unknown; retryable?: unknown };\n\treturn (\n\t\tJOURNAL_STORE_ERROR_NAMES.has(candidate.name) &&\n\t\ttypeof candidate.code === \"string\" &&\n\t\ttypeof candidate.retryable === \"boolean\" &&\n\t\ttypeof candidate.fields === \"object\" &&\n\t\tcandidate.fields !== null\n\t);\n}\n\nexport function isJournalCatalogError(value: unknown): value is JournalCatalogError {\n\treturn value instanceof JournalCatalogError || hasCode(value, \"JournalCatalogError\", JOURNAL_CATALOG_ERROR_CODES);\n}\n\nexport function isJournalShardUnavailableError(value: unknown): value is JournalShardUnavailableError {\n\treturn (\n\t\tvalue instanceof JournalShardUnavailableError ||\n\t\thasCode(value, \"JournalShardUnavailableError\", JOURNAL_SHARD_UNAVAILABLE_ERROR_CODES)\n\t);\n}\n\nexport function isJournalAdoptError(value: unknown): value is JournalAdoptError {\n\treturn value instanceof JournalAdoptError || hasCode(value, \"JournalAdoptError\", JOURNAL_ADOPT_ERROR_CODES);\n}\n\n/** The first journal store error in `error`'s cause chain, looking at most eight causes deep. */\nexport function findJournalStoreError(error: unknown): JournalStoreError | undefined {\n\tlet current = error;\n\tfor (let depth = 0; depth < MAX_CAUSE_DEPTH; depth++) {\n\t\tif (isJournalStoreError(current)) return current;\n\t\tif (!(current instanceof Error)) return undefined;\n\t\tcurrent = current.cause;\n\t}\n\treturn undefined;\n}\n\n/** Whether a storage error in the cause chain says the operation may succeed if tried again later. */\nexport function isRetryableStorageError(error: unknown): boolean {\n\tlet current = error;\n\tfor (let depth = 0; depth < MAX_STORAGE_CAUSE_DEPTH; depth++) {\n\t\tif (isStorageWriteLockTimeoutError(current) && current.retryable === true) return true;\n\t\tif (isStorageTransientError(current) && current.retryable === true) return true;\n\t\tif (isJournalStoreError(current) && current.retryable) return true;\n\t\tif (isSessionSpillError(current) && current.retryable === true) return true;\n\t\tcurrent = causeOf(current);\n\t}\n\treturn false;\n}\n\n/** Whether anything in `error`'s cause chain is a journal store error a caller may retry. */\nexport function isRetryableJournalStoreError(error: unknown): boolean {\n\tlet current = error;\n\tfor (let depth = 0; depth < MAX_CAUSE_DEPTH; depth++) {\n\t\tif (isJournalStoreError(current) && current.retryable) return true;\n\t\tif (!(current instanceof Error)) return false;\n\t\tcurrent = current.cause;\n\t}\n\treturn false;\n}\n\n/** A JSON-safe storage error, for sending across a process boundary; `rehydrateStorageError` reverses it. */\nexport interface SerializedStorageError {\n\treadonly name: string;\n\treadonly code?: string;\n\treadonly message: string;\n\treadonly hint?: string;\n\treadonly fields: Readonly<Record<string, string | number | boolean>>;\n\treadonly cause?: SerializedStorageError;\n\t/** A `StorageRollbackError`'s failed rollback. */\n\treadonly rollbackCause?: SerializedStorageError;\n\t/** A cleanup failure attached to the error it followed. */\n\treadonly cleanupCause?: SerializedStorageError;\n}\n\n/** Own properties carried outside `fields`: `message`, `stack`, and `cause` are not enumerable. */\nconst STRUCTURAL_KEYS = new Set([\"name\", \"code\", \"hint\"]);\n\nfunction isFiniteNumber(value: unknown): value is number {\n\treturn Number.isFinite(value);\n}\n\nfunction scalarFields(source: object, keys: readonly string[]): Record<string, string | number | boolean> {\n\tconst fields: Record<string, string | number | boolean> = {};\n\tfor (const key of keys) {\n\t\tconst value = (source as Record<string, unknown>)[key];\n\t\tif (typeof value === \"string\" || typeof value === \"boolean\" || isFiniteNumber(value)) fields[key] = value;\n\t}\n\treturn fields;\n}\n\nfunction serializeFailure(failure: unknown, depth: number): SerializedStorageError {\n\tif (!(failure instanceof Error)) return { name: \"Error\", message: String(failure), fields: {} };\n\tconst { code, hint, rollbackCause, cleanupCause } = failure as {\n\t\treadonly code?: unknown;\n\t\treadonly hint?: unknown;\n\t\treadonly rollbackCause?: unknown;\n\t\treadonly cleanupCause?: unknown;\n\t};\n\tconst keys = Object.keys(failure).filter((key) => !STRUCTURAL_KEYS.has(key));\n\tconst nested = (key: \"cause\" | \"rollbackCause\" | \"cleanupCause\", value: unknown) =>\n\t\tvalue !== undefined && depth + 1 < MAX_STORAGE_CAUSE_DEPTH ? { [key]: serializeFailure(value, depth + 1) } : {};\n\treturn {\n\t\tname: failure.name,\n\t\t...(typeof code === \"string\" || typeof code === \"number\" ? { code: String(code) } : {}),\n\t\tmessage: failure.message,\n\t\t...(typeof hint === \"string\" ? { hint } : {}),\n\t\tfields: scalarFields(failure, keys),\n\t\t...nested(\"cause\", failure.cause),\n\t\t...nested(\"rollbackCause\", rollbackCause),\n\t\t...nested(\"cleanupCause\", cleanupCause),\n\t};\n}\n\n/**\n * The storage error as `{ name, code, message, hint, fields, cause }`, with its cause chain, a rollback's\n * `rollbackCause`, and an attached `cleanupCause` serialized to a bounded depth. Fields hold only the error's own\n * scalar facts (identifiers, paths, timings, limits), never credentials.\n */\nexport function serializeStorageError(error: StorageError): SerializedStorageError {\n\treturn serializeFailure(error, 0);\n}\n\nfunction field<T extends string | number | boolean>(\n\tserialized: SerializedStorageError,\n\tkey: string,\n\ttype: \"string\" | \"number\" | \"boolean\",\n): T | undefined {\n\tconst value = serialized.fields[key];\n\treturn typeof value === type ? (value as T) : undefined;\n}\n\nfunction descriptorOf(serialized: SerializedStorageError): StorageDescriptor {\n\treturn {\n\t\tadapter: field<string>(serialized, \"adapter\", \"string\") ?? \"unknown\",\n\t\tlocation: field<string>(serialized, \"location\", \"string\") ?? \"unknown\",\n\t};\n}\n\nfunction nestedFailure(serialized: SerializedStorageError | undefined, depth: number): Error | undefined {\n\treturn serialized === undefined || depth + 1 >= MAX_STORAGE_CAUSE_DEPTH\n\t\t? undefined\n\t\t: rehydrateFailure(serialized, depth + 1);\n}\n\n/** The storage class `serializeStorageError` named, rebuilt from its fields; undefined for a name it does not know. */\nfunction knownStorageError(\n\tserialized: SerializedStorageError,\n\tcause: Error | undefined,\n\tdepth: number,\n): Error | undefined {\n\tswitch (serialized.name) {\n\t\tcase \"StorageConfigError\": {\n\t\t\tconst source = field<string>(serialized, \"source\", \"string\");\n\t\t\treturn new StorageConfigError(\n\t\t\t\tsource === \"cli\" || source === \"env\" || source === \"settings\" ? source : \"sdk\",\n\t\t\t\tfield<string>(serialized, \"field\", \"string\") ?? \"\",\n\t\t\t\tfield<string>(serialized, \"reason\", \"string\") ?? \"\",\n\t\t\t\tserialized.hint,\n\t\t\t);\n\t\t}\n\t\tcase \"StorageWriteLockTimeoutError\":\n\t\t\treturn new StorageWriteLockTimeoutError(\n\t\t\t\tdescriptorOf(serialized),\n\t\t\t\t{\n\t\t\t\t\ttimeoutMs: field<number>(serialized, \"timeoutMs\", \"number\") ?? 0,\n\t\t\t\t\telapsedMs: field<number>(serialized, \"elapsedMs\", \"number\") ?? 0,\n\t\t\t\t\tphase: field<string>(serialized, \"phase\", \"string\") === \"queued\" ? \"queued\" : \"acquiring\",\n\t\t\t\t\tholderPid: field<number>(serialized, \"holderPid\", \"number\"),\n\t\t\t\t\tholderHeldMs: field<number>(serialized, \"holderHeldMs\", \"number\"),\n\t\t\t\t\tholderCandidates: field<string>(serialized, \"holderCandidates\", \"string\"),\n\t\t\t\t},\n\t\t\t\tcause,\n\t\t\t);\n\t\tcase \"StorageUnsupportedOperationError\": {\n\t\t\tconst operation = field<string>(serialized, \"operation\", \"string\");\n\t\t\treturn new StorageUnsupportedOperationError(\n\t\t\t\tdescriptorOf(serialized),\n\t\t\t\tSTORAGE_OPERATIONS.find((known) => known === operation) ?? STORAGE_OPERATIONS[0],\n\t\t\t);\n\t\t}\n\t\tcase \"StorageWriterQueueDegradedError\": {\n\t\t\tconst reason = field<string>(serialized, \"reason\", \"string\");\n\t\t\treturn new StorageWriterQueueDegradedError(\n\t\t\t\tdescriptorOf(serialized),\n\t\t\t\tWRITER_QUEUE_DEGRADED_REASONS.find((known) => known === reason) ?? WRITER_QUEUE_DEGRADED_REASONS[0],\n\t\t\t\tcause,\n\t\t\t);\n\t\t}\n\t\tcase \"StorageWriterQueueUnusableError\":\n\t\t\treturn new StorageWriterQueueUnusableError(descriptorOf(serialized), cause);\n\t\tcase \"StorageTransientError\": {\n\t\t\tconst code = STORAGE_TRANSIENT_ERROR_CODES.find((known) => known === serialized.code);\n\t\t\tif (code === undefined) return undefined;\n\t\t\treturn new StorageTransientError(\n\t\t\t\tdescriptorOf(serialized),\n\t\t\t\t{\n\t\t\t\t\tcode,\n\t\t\t\t\toutcome: field<string>(serialized, \"outcome\", \"string\") === \"not-applied\" ? \"not-applied\" : \"unknown\",\n\t\t\t\t\tattempts: field<number>(serialized, \"attempts\", \"number\") ?? 1,\n\t\t\t\t},\n\t\t\t\tcause,\n\t\t\t);\n\t\t}\n\t\tcase \"SessionBlobError\": {\n\t\t\tconst code = SESSION_BLOB_ERROR_CODES.find((known) => known === serialized.code);\n\t\t\tif (code === undefined) return undefined;\n\t\t\treturn new SessionBlobError(\n\t\t\t\tcode,\n\t\t\t\t{\n\t\t\t\t\tsessionId: field<string>(serialized, \"sessionId\", \"string\") ?? \"\",\n\t\t\t\t\thash: field<string>(serialized, \"hash\", \"string\"),\n\t\t\t\t\tmissing: field<number>(serialized, \"missing\", \"number\"),\n\t\t\t\t\tbytes: field<number>(serialized, \"bytes\", \"number\"),\n\t\t\t\t\tactualHash: field<string>(serialized, \"actualHash\", \"string\"),\n\t\t\t\t\tadapter: field<string>(serialized, \"adapter\", \"string\"),\n\t\t\t\t},\n\t\t\t\tcause === undefined ? undefined : { cause },\n\t\t\t);\n\t\t}\n\t\tcase \"SessionSpillError\": {\n\t\t\tconst code = SESSION_SPILL_ERROR_CODES.find((known) => known === serialized.code);\n\t\t\tif (code === undefined) return undefined;\n\t\t\treturn new SessionSpillError(\n\t\t\t\tcode,\n\t\t\t\t{\n\t\t\t\t\tdirectory: field<string>(serialized, \"directory\", \"string\") ?? \"\",\n\t\t\t\t\tsessionId: field<string>(serialized, \"sessionId\", \"string\"),\n\t\t\t\t\tbytes: field<number>(serialized, \"bytes\", \"number\"),\n\t\t\t\t\tfoundBytes: field<number>(serialized, \"foundBytes\", \"number\"),\n\t\t\t\t\terrno: field<string>(serialized, \"errno\", \"string\"),\n\t\t\t\t},\n\t\t\t\tcause === undefined ? undefined : { cause },\n\t\t\t);\n\t\t}\n\t\tcase \"StorageUnavailableError\":\n\t\t\treturn new StorageUnavailableError(descriptorOf(serialized), cause);\n\t\tcase \"StoreClosedError\":\n\t\t\treturn new StoreClosedError(descriptorOf(serialized));\n\t\tcase \"StorageTransactionClosedError\":\n\t\t\treturn new StorageTransactionClosedError();\n\t\tcase \"StorageRollbackError\":\n\t\t\treturn new StorageRollbackError(cause, nestedFailure(serialized.rollbackCause, depth));\n\t\tcase \"StorageInvalidTextError\":\n\t\t\treturn new StorageInvalidTextError(field<number>(serialized, \"parameterIndex\", \"number\") ?? 0);\n\t\tcase \"StorageSchemaVersionError\":\n\t\t\treturn new StorageSchemaVersionError(\n\t\t\t\tfield<string>(serialized, \"domain\", \"string\") ?? \"\",\n\t\t\t\tfield<string>(serialized, \"found\", \"string\") ?? field<number>(serialized, \"found\", \"number\") ?? null,\n\t\t\t\tfield<number>(serialized, \"supported\", \"number\") ?? 0,\n\t\t\t);\n\t\tcase \"StoragePrefixError\": {\n\t\t\tconst reason = field<string>(serialized, \"reason\", \"string\");\n\t\t\treturn new StoragePrefixError(\n\t\t\t\tfield<string>(serialized, \"prefix\", \"string\") ?? \"\",\n\t\t\t\treason === \"reserved\" || reason === \"too-long\" || reason === \"identifier-collision\" ? reason : \"pattern\",\n\t\t\t\tfield<number>(serialized, \"maxLength\", \"number\"),\n\t\t\t\tfield<string>(serialized, \"identifier\", \"string\"),\n\t\t\t);\n\t\t}\n\t\tcase \"StorageAdapterLoadError\":\n\t\t\treturn new StorageAdapterLoadError(field<string>(serialized, \"module\", \"string\") ?? \"\", cause);\n\t\tcase \"StorageOutcomeUnknownError\":\n\t\t\treturn new StorageOutcomeUnknownError(\n\t\t\t\tfield<string>(serialized, \"domain\", \"string\") ?? \"\",\n\t\t\t\tfield<string>(serialized, \"id\", \"string\") ?? \"\",\n\t\t\t\tfield<string>(serialized, \"key\", \"string\") ?? \"\",\n\t\t\t);\n\t\tcase \"StoragePayloadTooLargeError\": {\n\t\t\tconst adapter = field<string>(serialized, \"adapter\", \"string\");\n\t\t\treturn new StoragePayloadTooLargeError(\n\t\t\t\tfield<number>(serialized, \"limitBytes\", \"number\") ?? 0,\n\t\t\t\tfield<number>(serialized, \"actualBytes\", \"number\") ?? 0,\n\t\t\t\t{\n\t\t\t\t\tkind: field<string>(serialized, \"kind\", \"string\") === \"response\" ? \"response\" : \"value\",\n\t\t\t\t\t...(adapter === undefined ? {} : { descriptor: descriptorOf(serialized) }),\n\t\t\t\t\t...(cause === undefined ? {} : { cause }),\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\treturn undefined;\n}\n\nfunction rehydrateFailure(serialized: SerializedStorageError, depth: number): Error {\n\tconst cause = nestedFailure(serialized.cause, depth);\n\tlet error = knownStorageError(serialized, cause, depth);\n\tif (error === undefined) {\n\t\terror =\n\t\t\tdepth === 0 || serialized.name.startsWith(\"Storage\")\n\t\t\t\t? new StorageError(serialized.message, { cause })\n\t\t\t\t: new Error(serialized.message, { cause });\n\t\tObject.assign(error, serialized.fields);\n\t\tObject.defineProperty(error, \"name\", { value: serialized.name });\n\t\tif (serialized.code !== undefined)\n\t\t\tObject.defineProperty(error, \"code\", { value: serialized.code, enumerable: true });\n\t\tif (serialized.hint !== undefined)\n\t\t\tObject.defineProperty(error, \"hint\", { value: serialized.hint, enumerable: true });\n\t}\n\t// The sender's message, which may hold detail no field carries (a `StorageUnavailableError`'s driver reason).\n\terror.message = serialized.message;\n\tconst cleanupCause = nestedFailure(serialized.cleanupCause, depth);\n\tif (cleanupCause !== undefined) Object.defineProperty(error, \"cleanupCause\", { value: cleanupCause });\n\treturn error;\n}\n\n/**\n * The error `serializeStorageError` produced, as the same class with the same message, fields, and causes, so guards\n * and `instanceof` still match on the other side of a process boundary. A storage error this version does not know\n * becomes a `StorageError` with the original `name`, `code`, and fields; a cause that is not a storage error becomes\n * an `Error` with its name and scalar fields (a driver's `errcode`, say). Only scalar facts travel: a\n * `StorageSchemaVersionError` whose `found` was a bigint or binary value comes back with `found: null`.\n */\nexport function rehydrateStorageError(serialized: SerializedStorageError): StorageError {\n\treturn rehydrateFailure(serialized, 0) as StorageError;\n}\n\n/** Why a team setup operation failed after its inputs were accepted. */\nexport type TeamProfileErrorCode =\n\t| \"settings-unreadable\"\n\t| \"adapter-not-installed\"\n\t| \"connection-failed\"\n\t| \"connection-timeout\"\n\t| \"auth-unavailable\"\n\t| \"token-write-failed\"\n\t| \"settings-write-failed\"\n\t| \"settings-locked\"\n\t| \"broker-restart-failed\"\n\t| \"token-delete-failed\";\n\n/** Which team input was rejected: an SDK option, a CLI argument, or an `ATOMIC_PROFILE` / `ATOMIC_TEAM_*` variable. */\nexport type TeamProfileConfigErrorCode =\n\t| \"unknown-profile\"\n\t| \"incomplete-profile\"\n\t| \"missing-url\"\n\t| \"unsupported-url\"\n\t| \"relative-file-url\"\n\t| \"credential-in-url\"\n\t| \"missing-token\"\n\t| \"conflicting-token\"\n\t| \"unreadable-token-file\"\n\t| \"relative-token-file\"\n\t| \"empty-token\"\n\t| \"unsupported-auth\"\n\t| \"unsupported-option\"\n\t| \"invalid-prefix\"\n\t| \"unknown-command\"\n\t| \"unknown-option\"\n\t| \"missing-value\"\n\t| \"unexpected-argument\";\n\nexport const TEAM_PROFILE_ERROR_CODES: ReadonlySet<TeamProfileErrorCode> = new Set<TeamProfileErrorCode>([\n\t\"settings-unreadable\",\n\t\"adapter-not-installed\",\n\t\"connection-failed\",\n\t\"connection-timeout\",\n\t\"auth-unavailable\",\n\t\"token-write-failed\",\n\t\"settings-write-failed\",\n\t\"settings-locked\",\n\t\"broker-restart-failed\",\n\t\"token-delete-failed\",\n]);\n\nexport const TEAM_PROFILE_CONFIG_ERROR_CODES: ReadonlySet<TeamProfileConfigErrorCode> =\n\tnew Set<TeamProfileConfigErrorCode>([\n\t\t\"unknown-profile\",\n\t\t\"incomplete-profile\",\n\t\t\"missing-url\",\n\t\t\"unsupported-url\",\n\t\t\"relative-file-url\",\n\t\t\"credential-in-url\",\n\t\t\"missing-token\",\n\t\t\"conflicting-token\",\n\t\t\"unreadable-token-file\",\n\t\t\"relative-token-file\",\n\t\t\"empty-token\",\n\t\t\"unsupported-auth\",\n\t\t\"unsupported-option\",\n\t\t\"invalid-prefix\",\n\t\t\"unknown-command\",\n\t\t\"unknown-option\",\n\t\t\"missing-value\",\n\t\t\"unexpected-argument\",\n\t]);\n\nconst USAGE_CODES: ReadonlySet<TeamProfileConfigErrorCode> = new Set<TeamProfileConfigErrorCode>([\n\t\"unknown-command\",\n\t\"unknown-option\",\n\t\"missing-value\",\n\t\"unexpected-argument\",\n]);\n\nconst RETRYABLE_CODES: ReadonlySet<TeamProfileErrorCode> = new Set<TeamProfileErrorCode>([\n\t\"connection-failed\",\n\t\"connection-timeout\",\n\t\"settings-locked\",\n\t\"broker-restart-failed\",\n]);\n\nconst SUMMARIES: Readonly<Record<TeamProfileErrorCode, string>> = {\n\t\"settings-unreadable\": \"Cannot update the global settings\",\n\t\"adapter-not-installed\": \"The storage adapter is not installed\",\n\t\"connection-failed\": \"Could not connect to the shared database\",\n\t\"connection-timeout\": \"The shared database did not answer in time\",\n\t\"auth-unavailable\": \"Could not sign in to the shared database\",\n\t\"token-write-failed\": \"Could not store the database token\",\n\t\"settings-write-failed\": \"Could not write the global settings\",\n\t\"settings-locked\": \"Another process is writing the settings\",\n\t\"broker-restart-failed\": \"Could not restart the Intercom broker\",\n\t\"token-delete-failed\": \"Could not delete the token file\",\n};\n\n/** The facts a {@link TeamProfileError} carries; every field is JSON-safe and holds no credential. */\nexport interface TeamProfileErrorFields {\n\t/** What the failure is about: the settings file, the adapter, the database URL, the token file or the agent directory. */\n\treadonly subject: string;\n\treadonly hint: string;\n\t/** A short, credential-free description of the cause. */\n\treadonly detail?: string;\n\treadonly cause?: Error;\n}\n\n/**\n * The family of team setup failures (`joinTeam`, `leaveTeam`, `getTeamProfile`, `atomic storage join`,\n * `atomic team`) after the inputs were accepted. Branch on `code`, never on the message.\n */\nexport class TeamProfileError extends StorageError {\n\toverride readonly name: \"TeamProfileError\" | \"TeamProfileTimeoutError\" = \"TeamProfileError\";\n\treadonly code: TeamProfileErrorCode;\n\treadonly subject: string;\n\treadonly hint: string;\n\tdeclare readonly detail?: string;\n\t/** Whether the same call can succeed later without a change on the caller's side. */\n\treadonly retryable: boolean;\n\n\tconstructor(code: TeamProfileErrorCode, fields: TeamProfileErrorFields) {\n\t\tsuper(\n\t\t\t`${SUMMARIES[code]}: ${fields.subject} (${code})${fields.detail === undefined ? \"\" : `: ${fields.detail}`}. ${fields.hint}`,\n\t\t\tfields.cause === undefined ? undefined : { cause: fields.cause },\n\t\t);\n\t\tthis.code = code;\n\t\tthis.subject = fields.subject;\n\t\tthis.hint = fields.hint;\n\t\tif (fields.detail !== undefined) this.detail = fields.detail;\n\t\tthis.retryable = RETRYABLE_CODES.has(code);\n\t}\n}\n\n/** What a team operation was doing when it ran out of time. */\nexport type TeamProfileTimeoutPhase = \"connect\";\n\n/** A team operation that did not finish in time (`code` `connection-timeout`); retryable. */\nexport class TeamProfileTimeoutError extends TeamProfileError {\n\toverride readonly name = \"TeamProfileTimeoutError\" as const;\n\treadonly timeoutMs: number;\n\treadonly elapsedMs: number;\n\treadonly phase: TeamProfileTimeoutPhase;\n\n\tconstructor(\n\t\tfields: Omit<TeamProfileErrorFields, \"detail\" | \"cause\"> & {\n\t\t\treadonly timeoutMs: number;\n\t\t\treadonly elapsedMs: number;\n\t\t\treadonly phase: TeamProfileTimeoutPhase;\n\t\t},\n\t) {\n\t\tsuper(\"connection-timeout\", {\n\t\t\tsubject: fields.subject,\n\t\t\thint: fields.hint,\n\t\t\tdetail: `no answer within ${fields.timeoutMs} ms (${fields.phase})`,\n\t\t});\n\t\tthis.timeoutMs = fields.timeoutMs;\n\t\tthis.elapsedMs = fields.elapsedMs;\n\t\tthis.phase = fields.phase;\n\t}\n}\n\nexport interface TeamProfileConfigErrorFields {\n\treadonly source: \"sdk\" | \"cli\" | \"env\";\n\t/** The option, argument or variable, for example `tokenFile`, `--token-file` or `ATOMIC_TEAM_URL`. */\n\treadonly field: string;\n\treadonly hint: string;\n\t/** The token file the input names, when the failure is about that file. */\n\treadonly path?: string;\n\t/** `incomplete-profile`: every variable that still has to be set, all reported at once. */\n\treadonly missing?: readonly string[];\n\treadonly cause?: Error;\n}\n\n/**\n * An invalid team input. It is a {@link StorageConfigError} whose `reason` equals `code`, so hosts that already\n * handle invalid `ATOMIC_STORAGE` values handle an invalid `ATOMIC_PROFILE=ci` setup the same way.\n */\nexport class TeamProfileConfigError extends StorageConfigError {\n\toverride readonly name = \"TeamProfileConfigError\" as const;\n\tdeclare readonly source: \"sdk\" | \"cli\" | \"env\";\n\treadonly code: TeamProfileConfigErrorCode;\n\treadonly hint: string;\n\tdeclare readonly path?: string;\n\tdeclare readonly missing?: readonly string[];\n\treadonly retryable = false;\n\n\tconstructor(code: TeamProfileConfigErrorCode, fields: TeamProfileConfigErrorFields) {\n\t\tsuper(fields.source, fields.field, code);\n\t\tthis.message = `${USAGE_CODES.has(code) ? \"Invalid team command\" : \"Invalid storage configuration\"}: ${fields.field} (${code}). ${fields.hint}`;\n\t\tif (fields.cause !== undefined) {\n\t\t\tObject.defineProperty(this, \"cause\", { value: fields.cause, configurable: true, writable: true });\n\t\t}\n\t\tthis.code = code;\n\t\tthis.hint = fields.hint;\n\t\tif (fields.path !== undefined) this.path = fields.path;\n\t\tif (fields.missing !== undefined) this.missing = [...fields.missing];\n\t}\n}\n\nfunction hasNameAndCodeIn(value: unknown, name: string, codes: ReadonlySet<string>): boolean {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tconst candidate = value as { readonly name?: unknown; readonly code?: unknown };\n\treturn candidate.name === name && typeof candidate.code === \"string\" && codes.has(candidate.code);\n}\n\n/** Whether `error` is a {@link TeamProfileError}, also across realms and processes (by `name` and `code`). */\nexport function isTeamProfileError(error: unknown): error is TeamProfileError {\n\treturn (\n\t\terror instanceof TeamProfileError ||\n\t\thasNameAndCodeIn(error, \"TeamProfileError\", TEAM_PROFILE_ERROR_CODES) ||\n\t\tisTeamProfileTimeoutError(error)\n\t);\n}\n\n/** Whether `error` is a {@link TeamProfileTimeoutError}, also across realms and processes (by `name` and `code`). */\nexport function isTeamProfileTimeoutError(error: unknown): error is TeamProfileTimeoutError {\n\treturn (\n\t\terror instanceof TeamProfileTimeoutError ||\n\t\thasNameAndCodeIn(error, \"TeamProfileTimeoutError\", new Set([\"connection-timeout\"]))\n\t);\n}\n\n/** Whether `error` is a {@link TeamProfileConfigError}, also across realms and processes (by `name` and `code`). */\nexport function isTeamProfileConfigError(error: unknown): error is TeamProfileConfigError {\n\treturn (\n\t\terror instanceof TeamProfileConfigError ||\n\t\thasNameAndCodeIn(error, \"TeamProfileConfigError\", TEAM_PROFILE_CONFIG_ERROR_CODES)\n\t);\n}\n\n/** Whether `error` or one of its causes, up to eight levels deep, is a retryable {@link TeamProfileError}. */\nexport function isRetryableTeamProfileError(error: unknown): boolean {\n\tlet current = error;\n\tfor (let depth = 0; depth < MAX_CAUSE_DEPTH && current !== undefined && current !== null; depth++) {\n\t\tif (isTeamProfileError(current) && current.retryable) return true;\n\t\tcurrent = current instanceof Error ? current.cause : undefined;\n\t}\n\treturn false;\n}\n\n/**\n * A cause of a serialized team error, at most eight deep. A team error cause, also one from another realm, is\n * serialized like the error itself when its `message`, `hint`, `retryable` and its class's fields all have their\n * documented types, so it rehydrates as its own class and keeps its `retryable`. Its message names files and\n * settings but never their content or a token. Any other cause keeps only its `name` and `code`, and its `message`\n * is that code, or else its name: a parser, driver or file-system message can quote the settings file or the\n * server's answer, so it never crosses a process boundary.\n */\nexport interface SerializedTeamErrorCause {\n\treadonly name: string;\n\treadonly message: string;\n\treadonly code?: string;\n\treadonly hint?: string;\n\treadonly fields?: SerializedTeamError[\"fields\"];\n\treadonly cause?: SerializedTeamErrorCause;\n}\n\n/** A {@link TeamProfileError} or {@link TeamProfileConfigError} as JSON, to cross a worker, coordinator or broker boundary. */\nexport interface SerializedTeamError {\n\treadonly name: string;\n\treadonly code: string;\n\treadonly message: string;\n\treadonly hint: string;\n\t/** The error's own facts: `subject`, `detail`, `timeoutMs`, `elapsedMs`, `phase`, `source`, `field`, `path`, `missing`, `retryable`. */\n\treadonly fields: Readonly<Record<string, string | number | boolean | readonly string[]>>;\n\treadonly cause?: SerializedTeamErrorCause;\n}\n\nconst SAFE_IDENTIFIER = /^[A-Za-z][A-Za-z0-9_.-]{0,63}$/;\n\nfunction safeIdentifier(value: unknown): string | undefined {\n\treturn typeof value === \"string\" && SAFE_IDENTIFIER.test(value) ? value : undefined;\n}\n\nfunction isText(value: unknown): value is string {\n\treturn typeof value === \"string\";\n}\n\nfunction canSerializeTeamCause(cause: unknown): cause is TeamProfileError | TeamProfileConfigError {\n\tif (!isTeamProfileError(cause) && !isTeamProfileConfigError(cause)) return false;\n\tconst team = cause as unknown as Readonly<Record<string, unknown>>;\n\tif (!isText(team.message) || !isText(team.hint) || typeof team.retryable !== \"boolean\") return false;\n\tif (isTeamProfileConfigError(cause)) {\n\t\treturn (\n\t\t\tisText(team.source) &&\n\t\t\tisText(team.field) &&\n\t\t\t(team.path === undefined || isText(team.path)) &&\n\t\t\t(team.missing === undefined || (Array.isArray(team.missing) && team.missing.every(isText)))\n\t\t);\n\t}\n\tif (!isText(team.subject) || (team.detail !== undefined && !isText(team.detail))) return false;\n\treturn (\n\t\t!isTeamProfileTimeoutError(cause) ||\n\t\t(typeof team.timeoutMs === \"number\" && typeof team.elapsedMs === \"number\" && isText(team.phase))\n\t);\n}\n\nfunction serializeTeamErrorCause(cause: unknown, depth: number): SerializedTeamErrorCause | undefined {\n\tif (depth >= MAX_CAUSE_DEPTH || cause === undefined || cause === null) return undefined;\n\tif (canSerializeTeamCause(cause)) return serializeTeam(cause, depth + 1);\n\tconst error = cause instanceof Error ? cause : undefined;\n\tconst name = safeIdentifier(error?.name) ?? \"Error\";\n\tconst code = safeIdentifier(typeof cause === \"object\" ? (cause as { readonly code?: unknown }).code : undefined);\n\tconst next = serializeTeamErrorCause(error?.cause, depth + 1);\n\treturn {\n\t\tname,\n\t\tmessage: code ?? name,\n\t\t...(code === undefined ? {} : { code }),\n\t\t...(next === undefined ? {} : { cause: next }),\n\t};\n}\n\nfunction rehydrateTeamErrorCause(cause: SerializedTeamErrorCause | undefined, depth: number): Error | undefined {\n\tif (depth >= MAX_CAUSE_DEPTH || cause === undefined) return undefined;\n\tconst { code, hint, fields } = cause;\n\tif (typeof code === \"string\" && typeof hint === \"string\" && typeof fields === \"object\" && fields !== null) {\n\t\treturn rehydrateTeam({ ...cause, code, hint, fields }, depth + 1);\n\t}\n\tconst inner = rehydrateTeamErrorCause(cause.cause, depth + 1);\n\tconst error = new Error(cause.message, inner === undefined ? undefined : { cause: inner });\n\terror.name = cause.name;\n\tif (code !== undefined) Object.assign(error, { code });\n\treturn error;\n}\n\nfunction serializeTeam(error: TeamProfileError | TeamProfileConfigError, causeDepth: number): SerializedTeamError {\n\tconst fields: Record<string, string | number | boolean | readonly string[]> = { retryable: error.retryable };\n\tif (isTeamProfileConfigError(error)) {\n\t\tfields.source = error.source;\n\t\tfields.field = error.field;\n\t\tif (error.path !== undefined) fields.path = error.path;\n\t\tif (error.missing !== undefined) fields.missing = [...error.missing];\n\t} else {\n\t\tfields.subject = error.subject;\n\t\tif (error.detail !== undefined) fields.detail = error.detail;\n\t\tif (isTeamProfileTimeoutError(error)) {\n\t\t\tfields.timeoutMs = error.timeoutMs;\n\t\t\tfields.elapsedMs = error.elapsedMs;\n\t\t\tfields.phase = error.phase;\n\t\t}\n\t}\n\tconst cause = serializeTeamErrorCause(error.cause, causeDepth);\n\treturn {\n\t\tname: error.name,\n\t\tcode: error.code,\n\t\tmessage: error.message,\n\t\thint: error.hint,\n\t\tfields,\n\t\t...(cause === undefined ? {} : { cause }),\n\t};\n}\n\n/** The JSON form of a team error, with its cause chain bounded to eight levels; it holds no token. */\nexport function serializeTeamError(error: TeamProfileError | TeamProfileConfigError): SerializedTeamError {\n\treturn serializeTeam(error, 0);\n}\n\nfunction rehydrateTeam(serialized: SerializedTeamError, causeDepth: number): TeamProfileError | TeamProfileConfigError {\n\tconst { fields } = serialized;\n\tconst text = (key: string): string | undefined =>\n\t\ttypeof fields[key] === \"string\" ? (fields[key] as string) : undefined;\n\tconst count = (key: string): number => (typeof fields[key] === \"number\" ? (fields[key] as number) : 0);\n\tconst cause = rehydrateTeamErrorCause(serialized.cause, causeDepth);\n\tlet error: TeamProfileError | TeamProfileConfigError;\n\tif (serialized.name === \"TeamProfileConfigError\") {\n\t\tconst missing = Array.isArray(fields.missing) ? fields.missing : undefined;\n\t\terror = new TeamProfileConfigError(serialized.code as TeamProfileConfigErrorCode, {\n\t\t\tsource: text(\"source\") as TeamProfileConfigErrorFields[\"source\"],\n\t\t\tfield: text(\"field\") ?? \"\",\n\t\t\thint: serialized.hint,\n\t\t\t...(text(\"path\") === undefined ? {} : { path: text(\"path\") }),\n\t\t\t...(missing === undefined ? {} : { missing }),\n\t\t\t...(cause === undefined ? {} : { cause }),\n\t\t});\n\t} else if (serialized.name === \"TeamProfileTimeoutError\") {\n\t\terror = new TeamProfileTimeoutError({\n\t\t\tsubject: text(\"subject\") ?? \"\",\n\t\t\thint: serialized.hint,\n\t\t\ttimeoutMs: count(\"timeoutMs\"),\n\t\t\telapsedMs: count(\"elapsedMs\"),\n\t\t\tphase: (text(\"phase\") ?? \"connect\") as TeamProfileTimeoutPhase,\n\t\t});\n\t\tif (cause !== undefined)\n\t\t\tObject.defineProperty(error, \"cause\", { value: cause, configurable: true, writable: true });\n\t} else {\n\t\terror = new TeamProfileError(serialized.code as TeamProfileErrorCode, {\n\t\t\tsubject: text(\"subject\") ?? \"\",\n\t\t\thint: serialized.hint,\n\t\t\t...(text(\"detail\") === undefined ? {} : { detail: text(\"detail\") }),\n\t\t\t...(cause === undefined ? {} : { cause }),\n\t\t});\n\t\tif (serialized.name !== error.name) Object.defineProperty(error, \"name\", { value: serialized.name });\n\t}\n\tObject.defineProperty(error, \"message\", { value: serialized.message, configurable: true, writable: true });\n\tif (typeof fields.retryable === \"boolean\" && fields.retryable !== error.retryable) {\n\t\tObject.defineProperty(error, \"retryable\", { value: fields.retryable });\n\t}\n\treturn error;\n}\n\n/**\n * The team error a {@link serializeTeamError} result describes, as an instance of its class, so `instanceof`, the\n * guards and `isRetryableTeamProfileError` work on the receiving side. An unknown name becomes a\n * {@link TeamProfileError} that keeps the original `name`, `code` and `retryable`.\n */\nexport function rehydrateTeamError(serialized: SerializedTeamError): TeamProfileError | TeamProfileConfigError {\n\treturn rehydrateTeam(serialized, 0);\n}\n\n/** A cause as it crosses a process boundary: its name, message and code, never its stack. */\nexport interface SerializedJournalStoreCause {\n\treadonly name: string;\n\treadonly message: string;\n\treadonly code?: string;\n\treadonly cause?: SerializedJournalStoreCause;\n}\n\nexport interface SerializedJournalStoreError {\n\treadonly name: string;\n\treadonly code: string;\n\treadonly message: string;\n\treadonly hint?: string;\n\treadonly retryable: boolean;\n\treadonly fields: JournalStoreFields;\n\treadonly cause?: SerializedJournalStoreCause;\n}\n\nfunction serializeCause(cause: unknown, depth: number): SerializedJournalStoreCause | undefined {\n\tif (depth >= MAX_CAUSE_DEPTH || cause === undefined || cause === null) return undefined;\n\tif (!(cause instanceof Error)) return { name: \"Error\", message: String(cause) };\n\tconst code = (cause as { code?: unknown }).code;\n\tconst nested = serializeCause(cause.cause, depth + 1);\n\treturn {\n\t\tname: cause.name,\n\t\tmessage: cause.message,\n\t\t...(typeof code === \"string\" ? { code } : {}),\n\t\t...(nested === undefined ? {} : { cause: nested }),\n\t};\n}\n\n/** The plain form of a journal store error, for a worker, coordinator or broker message. */\nexport function serializeJournalStoreError(error: JournalStoreError): SerializedJournalStoreError {\n\tconst cause = serializeCause(error.cause, 0);\n\treturn {\n\t\tname: error.name,\n\t\tcode: error.code,\n\t\tmessage: error.message,\n\t\t...(error.hint === undefined ? {} : { hint: error.hint }),\n\t\tretryable: error.retryable,\n\t\tfields: { ...error.fields },\n\t\t...(cause === undefined ? {} : { cause }),\n\t};\n}\n\nfunction rehydrateCause(cause: SerializedJournalStoreCause | undefined): Error | undefined {\n\tif (cause === undefined) return undefined;\n\tconst nested = rehydrateCause(cause.cause);\n\tconst error = new Error(cause.message, nested === undefined ? undefined : { cause: nested });\n\terror.name = cause.name;\n\tif (cause.code !== undefined) Object.defineProperty(error, \"code\", { value: cause.code, enumerable: true });\n\treturn error;\n}\n\nfunction text(fields: JournalStoreFields, key: string): string | undefined {\n\tconst value = fields[key];\n\treturn typeof value === \"string\" ? value : undefined;\n}\n\nfunction numeric(fields: JournalStoreFields, key: string): number | undefined {\n\tconst value = fields[key];\n\treturn typeof value === \"number\" ? value : undefined;\n}\n\nfunction versionField(fields: JournalStoreFields): string | number | null | undefined {\n\tconst value = fields.found;\n\treturn typeof value === \"boolean\" ? undefined : value;\n}\n\n/** Rebuilds the error a process serialized; a name this Atomic does not know becomes the family base, name and code kept. */\nexport function rehydrateJournalStoreError(serialized: SerializedJournalStoreError): JournalStoreError {\n\tconst error = rebuild(serialized);\n\t// The message was built from the same fields; keep the sender's text exactly, whatever its cause looked like here.\n\terror.message = serialized.message;\n\treturn error;\n}\n\nfunction rebuild(serialized: SerializedJournalStoreError): JournalStoreError {\n\tconst { fields } = serialized;\n\tconst cause = rehydrateCause(serialized.cause);\n\tif (hasCode(serialized, \"JournalCatalogError\", JOURNAL_CATALOG_ERROR_CODES))\n\t\treturn new JournalCatalogError({\n\t\t\tcode: serialized.code as JournalCatalogErrorCode,\n\t\t\tcatalogPath: text(fields, \"catalogPath\") ?? \"\",\n\t\t\tphase: text(fields, \"phase\") as JournalCatalogPhase | undefined,\n\t\t\trunId: text(fields, \"runId\"),\n\t\t\tshardId: numeric(fields, \"shardId\"),\n\t\t\tshardPath: text(fields, \"shardPath\"),\n\t\t\tfound: versionField(fields),\n\t\t\tsupported: numeric(fields, \"supported\"),\n\t\t\trule: text(fields, \"rule\"),\n\t\t\tselection: text(fields, \"selection\"),\n\t\t\tlocalOnly: typeof fields.localOnly === \"boolean\" ? fields.localOnly : undefined,\n\t\t\tlastSeq: numeric(fields, \"lastSeq\"),\n\t\t\tretryable: serialized.retryable,\n\t\t\tcause,\n\t\t});\n\tif (hasCode(serialized, \"JournalShardUnavailableError\", JOURNAL_SHARD_UNAVAILABLE_ERROR_CODES))\n\t\treturn new JournalShardUnavailableError({\n\t\t\tcode: serialized.code as JournalShardUnavailableErrorCode,\n\t\t\tshardId: numeric(fields, \"shardId\") ?? -1,\n\t\t\tshardPath: text(fields, \"shardPath\") ?? \"\",\n\t\t\trunId: text(fields, \"runId\"),\n\t\t\tretryable: serialized.retryable,\n\t\t\tcause,\n\t\t});\n\tif (hasCode(serialized, \"JournalAdoptError\", JOURNAL_ADOPT_ERROR_CODES))\n\t\treturn new JournalAdoptError({\n\t\t\tcode: serialized.code as JournalAdoptErrorCode,\n\t\t\tpath: text(fields, \"path\") ?? \"\",\n\t\t\treason: text(fields, \"reason\") as JournalAdoptNotJournalReason | undefined,\n\t\t\trunId: text(fields, \"runId\"),\n\t\t\texistingPath: text(fields, \"existingPath\"),\n\t\t\tfound: versionField(fields),\n\t\t\tsupported: numeric(fields, \"supported\"),\n\t\t\tcause,\n\t\t});\n\treturn new JournalStoreError({\n\t\tname: serialized.name,\n\t\tcode: serialized.code,\n\t\tmessage: serialized.message,\n\t\thint: serialized.hint,\n\t\tfields,\n\t\tretryable: serialized.retryable,\n\t\tcause,\n\t});\n}\n"]}
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/core/storage/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAIpD,MAAM,OAAO,YAAa,SAAQ,KAAK;IAEtC,YAAY,OAAe,EAAE,OAAsB;QAClD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC;IAC7B,CAAC;CACD;AAED,MAAM,OAAO,uBAAwB,SAAQ,YAAY;IAC/C,OAAO,CAAS;IAChB,QAAQ,CAAS;IAE1B;;;OAGG;IACH,YAAY,UAA6B,EAAE,KAA0B,EAAE,MAAe;QACrF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iB,CAAC;QAC5B,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,MAAM;QACN,SAAS,EAAE,UAAU,CAAC,SAAS;QAC/B,KAAK;KACL,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { SqliteValue, StorageDescriptor } from \"./database.js\";\nimport { isSqliteBusy } from \"./write-ahead-log.js\";\n\nexport type StorageFailureCause = object | SqliteValue | boolean | symbol | undefined;\n\nexport class StorageError extends Error {\n\tdeclare readonly cleanupCause?: StorageFailureCause;\n\tconstructor(message: string, options?: ErrorOptions) {\n\t\tsuper(message, options);\n\t\tthis.name = new.target.name;\n\t}\n}\n\nexport class StorageUnavailableError extends StorageError {\n\treadonly adapter: string;\n\treadonly location: string;\n\tdeclare readonly cause: StorageFailureCause;\n\t/**\n\t * `detail` names the driver failure in the message: a worker or coordinator that relays only `message` across\n\t * a process boundary keeps the reason. Adapters pass it only for causes that cannot carry credentials.\n\t */\n\tconstructor(descriptor: StorageDescriptor, cause: StorageFailureCause, detail?: string) {\n\t\tsuper(`Storage unavailable: ${descriptor.adapter} at ${descriptor.location}${detail ? `: ${detail}` : \"\"}`, {\n\t\t\tcause,\n\t\t});\n\t\tthis.adapter = descriptor.adapter;\n\t\tthis.location = descriptor.location;\n\t}\n}\n\nexport class StoreClosedError extends StorageError {\n\treadonly adapter: string;\n\treadonly location: string;\n\tconstructor(descriptor: StorageDescriptor) {\n\t\tsuper(`Storage closed: ${descriptor.adapter} at ${descriptor.location}`);\n\t\tthis.adapter = descriptor.adapter;\n\t\tthis.location = descriptor.location;\n\t}\n}\n\nexport class StorageTransactionClosedError extends StorageError {\n\tconstructor() {\n\t\tsuper(\"Storage transaction is closed\");\n\t}\n}\n\nexport class StorageRollbackError extends StorageError {\n\tdeclare readonly cause: StorageFailureCause;\n\treadonly rollbackCause: StorageFailureCause;\n\tconstructor(cause: StorageFailureCause, rollbackCause: StorageFailureCause) {\n\t\tsuper(\"Storage rollback failed\", { cause });\n\t\tthis.rollbackCause = rollbackCause;\n\t}\n}\n\nexport class StorageInvalidTextError extends StorageError {\n\treadonly parameterIndex: number;\n\treadonly reason = \"nul-character\";\n\tconstructor(parameterIndex: number) {\n\t\tsuper(`Storage parameter ${parameterIndex} contains a NUL character`);\n\t\tthis.parameterIndex = parameterIndex;\n\t}\n}\n\nexport class StorageSchemaVersionError extends StorageError {\n\treadonly domain: string;\n\treadonly found: SqliteValue;\n\treadonly supported: number;\n\tconstructor(domain: string, found: SqliteValue, supported: number) {\n\t\tsuper(`Unsupported ${domain} storage schema version`);\n\t\tthis.domain = domain;\n\t\tthis.found = found;\n\t\tthis.supported = supported;\n\t}\n}\n\n/** Why a storage prefix is refused. */\nexport type StoragePrefixErrorReason = \"pattern\" | \"reserved\" | \"too-long\" | \"identifier-collision\" | \"uppercase\";\n\nexport class StoragePrefixError extends StorageError {\n\treadonly prefix: string;\n\t/**\n\t * `uppercase`: PostgreSQL folds unquoted names to lowercase, so a prefix with uppercase letters would name the same\n\t * tables as its lowercase form while Atomic's catalog probes looked for the unfolded names (#5218).\n\t */\n\treadonly reason: StoragePrefixErrorReason;\n\t/** With `too-long`: the longest prefix the selected backend takes (#5067). */\n\tdeclare readonly maxLength?: number;\n\t/** With `identifier-collision`: the name PostgreSQL would know two of the prefix's names by (#5219). */\n\tdeclare readonly identifier?: string;\n\tconstructor(prefix: string, reason: StoragePrefixErrorReason, maxLength?: number, identifier?: string) {\n\t\tsuper(\n\t\t\t`Invalid storage prefix: ${reason}${maxLength === undefined ? \"\" : ` (PostgreSQL allows at most ${maxLength} characters)`}${identifier === undefined ? \"\" : ` (two names under it would both be PostgreSQL's ${identifier}; choose another prefix)`}${reason === \"uppercase\" ? ` (PostgreSQL folds names to lowercase: use ${prefix.toLowerCase()})` : \"\"}`,\n\t\t);\n\t\tthis.prefix = prefix;\n\t\tthis.reason = reason;\n\t\tif (maxLength !== undefined) this.maxLength = maxLength;\n\t\tif (identifier !== undefined) this.identifier = identifier;\n\t}\n}\n\n/** The code of every `StorageConfigError`: an option, flag, variable, or setting has an invalid value. */\nexport type StorageConfigErrorCode = \"invalid-config\";\n\nexport class StorageConfigError extends StorageError {\n\t/** {@link TeamProfileConfigError} is the one subclass, with its own name and codes. */\n\toverride readonly name: \"StorageConfigError\" | \"TeamProfileConfigError\" = \"StorageConfigError\";\n\treadonly code: StorageConfigErrorCode | TeamProfileConfigErrorCode = \"invalid-config\";\n\treadonly source: \"sdk\" | \"cli\" | \"env\" | \"settings\";\n\treadonly field: string;\n\treadonly reason: string;\n\t/** What to change, when the place that rejects the value knows it. */\n\tdeclare readonly hint?: string;\n\tconstructor(source: \"sdk\" | \"cli\" | \"env\" | \"settings\", field: string, reason: string, hint?: string) {\n\t\tsuper(`Invalid storage configuration: ${field} (${reason})${hint === undefined ? \"\" : `. ${hint}`}`);\n\t\tthis.source = source;\n\t\tthis.field = field;\n\t\tthis.reason = reason;\n\t\tif (hint !== undefined) this.hint = hint;\n\t}\n}\n\nexport class StorageAdapterLoadError extends StorageError {\n\treadonly module: string;\n\tdeclare readonly cause: StorageFailureCause;\n\tconstructor(module: string, cause: StorageFailureCause) {\n\t\tsuper(`Could not load storage adapter: ${module}`, { cause });\n\t\tthis.module = module;\n\t}\n}\n\nexport class StorageOutcomeUnknownError extends StorageError {\n\treadonly domain: string;\n\treadonly id: string;\n\treadonly key: string;\n\tconstructor(domain: string, id: string, key: string) {\n\t\tsuper(`Storage write outcome unknown: ${domain} ${id}`);\n\t\tthis.domain = domain;\n\t\tthis.id = id;\n\t\tthis.key = key;\n\t}\n}\n\n/**\n * What a backend refused as too large: a value or row a statement writes or computes, or the response to a\n * statement.\n */\nexport type StoragePayloadKind = \"value\" | \"response\";\n\nexport interface StoragePayloadTooLargeOptions {\n\treadonly kind?: StoragePayloadKind;\n\treadonly descriptor?: StorageDescriptor;\n\treadonly cause?: StorageFailureCause;\n}\n\nconst PAYLOAD_TOO_LARGE_HINT =\n\t\"Retrying does not help: store less in one value, or raise the backend's limit (sqld: max_row_size, --max-response-size)\";\n\nfunction byteCount(bytes: number): string {\n\treturn `${bytes.toLocaleString(\"en-US\")} bytes`;\n}\n\nlet responseRefusals: WeakSet<object> | undefined;\n\n/** Recognizes a response refusal without inspecting the adapter's rejection (which can even be a revoked proxy). */\nexport function isStorageResponseRefusal(error: unknown): error is StoragePayloadTooLargeError {\n\treturn responseRefusals?.has(error as object) === true;\n}\n\n/**\n * The backend refused a payload larger than it accepts: a bound or computed value or row (a libSQL server's\n * `SQLITE_TOOBIG`, `ARGS_INVALID \"string or blob too big\"`, Postgres's `54000`), or a statement's response (a libSQL\n * server's `RESPONSE_TOO_LARGE`). Permanent: the same write fails again, so it is never `retryable` and never a\n * `StorageUnavailableError` (#4954). `limitBytes` is the backend's default limit when the backend does not report its\n * own; `actualBytes` is the largest value the statement bound, or 0 when unknown (a response). A value refused while\n * the largest bound value is within the limit is one the backend built running the statement, a row of several values\n * or a value a query computes, and the message says so instead of calling the small value sent too large (#5260).\n */\nexport class StoragePayloadTooLargeError extends StorageError {\n\treadonly code = \"payload-too-large\" as const;\n\treadonly retryable = false as const;\n\treadonly hint = PAYLOAD_TOO_LARGE_HINT;\n\treadonly limitBytes: number;\n\treadonly actualBytes: number;\n\treadonly kind: StoragePayloadKind;\n\tdeclare readonly adapter?: string;\n\tdeclare readonly location?: string;\n\tdeclare readonly cause: StorageFailureCause;\n\tconstructor(limitBytes: number, actualBytes: number, options: StoragePayloadTooLargeOptions = {}) {\n\t\tconst kind = options.kind ?? \"value\";\n\t\tconst where =\n\t\t\toptions.descriptor === undefined ? \"\" : `: ${options.descriptor.adapter} at ${options.descriptor.location}`;\n\t\tconst limit = limitBytes > 0 ? `the limit is ${byteCount(limitBytes)}` : \"over its limit\";\n\t\tconst built = actualBytes > 0 && actualBytes <= limitBytes;\n\t\tconst what =\n\t\t\tkind === \"response\"\n\t\t\t\t? `refused to return a response larger than it allows; ${limit} per response`\n\t\t\t\t: built\n\t\t\t\t\t? `refused a value or row it built while running the statement, larger than it stores; ${limit} per value or row, and the largest value sent was ${byteCount(actualBytes)}`\n\t\t\t\t\t: `refused a value${actualBytes > 0 ? ` of ${byteCount(actualBytes)}` : \"\"} larger than it stores; ${limit} per value or row`;\n\t\tsuper(\n\t\t\t`Storage payload too large${where}: the backend ${what} (payload-too-large). ${PAYLOAD_TOO_LARGE_HINT}.`,\n\t\t\toptions.cause === undefined ? undefined : { cause: options.cause },\n\t\t);\n\t\tthis.limitBytes = limitBytes;\n\t\tthis.actualBytes = actualBytes;\n\t\tthis.kind = kind;\n\t\tif (kind === \"response\") {\n\t\t\tresponseRefusals ??= new WeakSet();\n\t\t\tresponseRefusals.add(this);\n\t\t}\n\t\tif (options.descriptor !== undefined) {\n\t\t\tthis.adapter = options.descriptor.adapter;\n\t\t\tthis.location = options.descriptor.location;\n\t\t}\n\t}\n}\n\n/** SQLite's result code for a string, blob or row over its length limit. */\nconst SQLITE_TOOBIG = 18;\n\n/** A backend's payload limits, in bytes, for the messages of {@link StoragePayloadTooLargeError}. */\nexport type StoragePayloadLimits = Readonly<Partial<Record<StoragePayloadKind, number>>>;\n/** SQLite's default `SQLITE_MAX_LENGTH`, the limit of Atomic's own SQLite stores. */\nexport const SQLITE_PAYLOAD_LIMITS: StoragePayloadLimits = Object.freeze({ value: 1_000_000_000 });\n\n/**\n * The kind of payload `failure`, or a cause of it, says the backend refused as too large, if it says so: read from\n * codes, never from a message, except libSQL's `ARGS_INVALID`, whose code covers other argument errors too.\n */\nexport function payloadTooLargeKind(failure: StorageFailureCause | Error): StoragePayloadKind | undefined {\n\tlet current: unknown = failure;\n\tfor (let depth = 0; depth < MAX_STORAGE_CAUSE_DEPTH && typeof current === \"object\" && current !== null; depth++) {\n\t\tconst { code, errcode, message, cause } = current as {\n\t\t\treadonly code?: unknown;\n\t\t\treadonly errcode?: unknown;\n\t\t\treadonly message?: unknown;\n\t\t\treadonly cause?: unknown;\n\t\t};\n\t\tif (code === \"RESPONSE_TOO_LARGE\") return \"response\";\n\t\tif (code === \"SQLITE_TOOBIG\" || code === \"54000\") return \"value\";\n\t\tif (code === \"ARGS_INVALID\" && typeof message === \"string\" && /too big/i.test(message)) return \"value\";\n\t\tif (typeof errcode === \"number\" && (errcode & 0xff) === SQLITE_TOOBIG) return \"value\";\n\t\tcurrent = cause;\n\t}\n\treturn undefined;\n}\n\n/** The byte size of the largest text or binary value in `params`, as UTF-8 for text. */\nexport function largestValueBytes(params: readonly SqliteValue[]): number {\n\tlet largest = 0;\n\tfor (const value of params) {\n\t\tconst bytes =\n\t\t\ttypeof value === \"string\"\n\t\t\t\t? Buffer.byteLength(value, \"utf8\")\n\t\t\t\t: value instanceof Uint8Array\n\t\t\t\t\t? value.byteLength\n\t\t\t\t\t: 0;\n\t\tlargest = Math.max(largest, bytes);\n\t}\n\treturn largest;\n}\n\n/** An error and its direct cause on one line, for status output (a module-resolution \"Require stack\" is dropped). */\nexport function describeStorageError(error: Error | object | string | undefined): string {\n\tconst firstLine = (text: string): string => text.split(\"\\n\", 1)[0]!.trim();\n\tif (!(error instanceof Error)) return firstLine(String(error));\n\tconst message = firstLine(error.message);\n\tconst cause = error.cause instanceof Error ? firstLine(error.cause.message) : undefined;\n\treturn cause === undefined || message.includes(cause) ? message : `${message}: ${cause}`;\n}\n\n/** How far guards and the serializer follow `cause`, so a cyclic or very deep chain stays bounded. */\nconst MAX_STORAGE_CAUSE_DEPTH = 8;\n\n/**\n * A storage failure as a command shows it: the first line of its message, then of its innermost cause's when the\n * message does not already hold it, and the innermost code along its causes, such as a TLS error's code, a SQLSTATE\n * or a configuration error's reason. Adapters redact their causes, so nothing here needs redacting again.\n */\nexport function describeStorageFailure(error: Error): string {\n\tconst firstLine = (text: string): string => text.split(\"\\n\", 1)[0]!.trim();\n\tlet innermost: Error = error;\n\tlet code: string | undefined;\n\tlet current = error.cause;\n\tfor (let depth = 0; depth < MAX_STORAGE_CAUSE_DEPTH && current instanceof Error; depth++) {\n\t\tinnermost = current;\n\t\tconst named = current as Error & { readonly code?: string | number; readonly reason?: string };\n\t\tconst label = current instanceof StorageConfigError ? named.reason : named.code;\n\t\tif (typeof label === \"string\") code = label;\n\t\tcurrent = current.cause;\n\t}\n\tconst message = firstLine(error.message);\n\tconst cause = firstLine(innermost.message);\n\tconst text = message.includes(cause) ? message : `${message}: ${cause}`;\n\treturn code === undefined || text.includes(code) ? text : `${text} (${code})`;\n}\n\nexport type StorageWriteLockTimeoutCode = \"write-lock-timeout\";\n/** Where the writer was when it gave up: behind older writers in the queue, or first in line and trying the lock. */\nexport type StorageWriteLockWaitPhase = \"queued\" | \"acquiring\";\n\nexport interface StorageWriteLockTimeoutDetails {\n\t/** The lock wait that ran out: how long the lock may stay held with no other connection committing. */\n\treadonly timeoutMs: number;\n\t/** How long the lock had been held with no other connection committing when the writer gave up. */\n\treadonly elapsedMs: number;\n\treadonly phase: StorageWriteLockWaitPhase;\n\t/** The process whose connection took the lock most recently, when its record names one. */\n\treadonly holderPid?: number;\n\t/** How long ago that process took the lock. */\n\treadonly holderHeldMs?: number;\n\t/**\n\t * When no record names the holder: the processes of the other connections trying for the lock, comma-separated.\n\t * One of them may hold it, having taken it before it could record so.\n\t */\n\treadonly holderCandidates?: string;\n}\n\nconst WRITE_LOCK_TIMEOUT_HINT =\n\t\"Another process holds the database's write lock without committing; check that process (it may be stopped or starved of CPU), or pass a longer lockWaitMs. Retrying later is safe\";\n\n/**\n * A write transaction gave up waiting for the database's write lock: the lock stayed held for the whole lock wait\n * while no other connection committed. Nothing of the transaction ran. It is a `StorageUnavailableError`, so code\n * that handles an unavailable store keeps handling it, and its message keeps that error's `Storage unavailable:`\n * prefix for relays that forward only the message.\n */\nexport class StorageWriteLockTimeoutError extends StorageUnavailableError {\n\toverride readonly name = \"StorageWriteLockTimeoutError\" as const;\n\treadonly code: StorageWriteLockTimeoutCode = \"write-lock-timeout\";\n\treadonly retryable = true as const;\n\treadonly hint: string = WRITE_LOCK_TIMEOUT_HINT;\n\treadonly timeoutMs: number;\n\treadonly elapsedMs: number;\n\treadonly phase: StorageWriteLockWaitPhase;\n\tdeclare readonly holderPid?: number;\n\tdeclare readonly holderHeldMs?: number;\n\tdeclare readonly holderCandidates?: string;\n\tconstructor(descriptor: StorageDescriptor, details: StorageWriteLockTimeoutDetails, cause?: StorageFailureCause) {\n\t\tconst heldBy =\n\t\t\tdetails.holderPid !== undefined\n\t\t\t\t? `by process ${details.holderPid}${details.holderHeldMs === undefined ? \"\" : ` (which took it ${details.holderHeldMs} ms ago)`} `\n\t\t\t\t: details.holderCandidates !== undefined\n\t\t\t\t\t? `by a writer that has not recorded taking it (processes trying for it: ${details.holderCandidates}) `\n\t\t\t\t\t: \"\";\n\t\tsuper(\n\t\t\tdescriptor,\n\t\t\tcause,\n\t\t\t`database is locked; gave up after ${details.elapsedMs} ms waiting for the write lock${details.phase === \"queued\" ? \" in the writers' queue\" : \"\"}, held all that time ${heldBy}with no other connection committing (write-lock-timeout). ${WRITE_LOCK_TIMEOUT_HINT}`,\n\t\t);\n\t\tthis.timeoutMs = details.timeoutMs;\n\t\tthis.elapsedMs = details.elapsedMs;\n\t\tthis.phase = details.phase;\n\t\tif (details.holderPid !== undefined) this.holderPid = details.holderPid;\n\t\tif (details.holderHeldMs !== undefined) this.holderHeldMs = details.holderHeldMs;\n\t\tif (details.holderCandidates !== undefined) this.holderCandidates = details.holderCandidates;\n\t}\n}\n\nexport type StorageUnsupportedOperationCode = \"unsupported-operation\";\n/** Operations that only some database handles support. */\nconst STORAGE_OPERATIONS = [\"getWriterQueueStats\", \"getWriterQueueDegradation\"] as const;\nexport type StorageOperation = (typeof STORAGE_OPERATIONS)[number];\n\n/** The database handle does not support the operation, for example a handle from another adapter. */\nexport class StorageUnsupportedOperationError extends StorageError {\n\toverride readonly name = \"StorageUnsupportedOperationError\" as const;\n\treadonly code: StorageUnsupportedOperationCode = \"unsupported-operation\";\n\treadonly operation: StorageOperation;\n\treadonly adapter: string;\n\treadonly location: string;\n\treadonly hint: string;\n\tconstructor(descriptor: StorageDescriptor, operation: StorageOperation) {\n\t\tconst hint = `Call ${operation} with a database from openNodeSqliteDatabase or wrapNodeSqliteDatabase`;\n\t\tsuper(\n\t\t\t`Unsupported storage operation: ${operation} on ${descriptor.adapter} at ${descriptor.location} (unsupported-operation). ${hint}`,\n\t\t);\n\t\tthis.operation = operation;\n\t\tthis.adapter = descriptor.adapter;\n\t\tthis.location = descriptor.location;\n\t\tthis.hint = hint;\n\t}\n}\n\nexport type StorageWriterQueueDegradedCode = \"writer-queue-degraded\";\nconst WRITER_QUEUE_DEGRADED_REASONS = [\n\t\"watch-unavailable\",\n\t\"wake-failed\",\n\t\"stale-ticket-kept\",\n\t\"holder-record-unavailable\",\n] as const;\n/**\n * What degraded: `\"watch-unavailable\"`, a waiting writer cannot watch its release notice and polls instead;\n * `\"wake-failed\"`, a writer letting go of the lock could not read the queue or notify the next writer;\n * `\"stale-ticket-kept\"`, a ticket or its notice could not be removed, either when its writer left or after abandonment;\n * `\"holder-record-unavailable\"`, the connection could not keep its record of holding the write lock, or remove an\n * exited process's.\n */\nexport type StorageWriterQueueDegradedReason = (typeof WRITER_QUEUE_DEGRADED_REASONS)[number];\n\nconst WRITER_QUEUE_DEGRADED_HINTS: Readonly<Record<StorageWriterQueueDegradedReason, string>> = {\n\t\"watch-unavailable\":\n\t\t\"Writers still take the lock in turn but notice a released lock by polling; check file-watch limits (fs.inotify.max_user_instances and max_user_watches on Linux)\",\n\t\"wake-failed\":\n\t\t\"Writers still take the lock in turn, but the next writer notices a released lock at its next check instead of at once; make the writers' queue directories next to the database (<file>-writers and <file>-wakes) readable and writable\",\n\t\"stale-ticket-kept\":\n\t\t\"An entry or release notice could not be removed from the writers' queue directories next to the database (<file>-writers and <file>-wakes); a remaining live ticket may delay other writers until it becomes stale. Make the directories writable for every writer, or remove abandoned entries by hand\",\n\t\"holder-record-unavailable\":\n\t\t\"Writers still take the lock in turn, but a writer that gives up waiting may not name the process holding the lock; make the write-lock records directory next to the database (<file>-holders) readable and writable for every writer\",\n};\n\n/**\n * Not a failure: a node-sqlite connection fell back from the prompt handoff of the write lock, kept a ticket or\n * notice it could not remove, or could not keep its record of holding the write lock. Transactions keep working. Each reason is recorded once on the connection, readable with\n * `getWriterQueueDegradation`, and emitted once as a process warning (`process.on(\"warning\")`), which Atomic's own\n * processes suppress.\n */\nexport class StorageWriterQueueDegradedError extends StorageError {\n\toverride readonly name = \"StorageWriterQueueDegradedError\" as const;\n\treadonly code: StorageWriterQueueDegradedCode = \"writer-queue-degraded\";\n\treadonly reason: StorageWriterQueueDegradedReason;\n\treadonly adapter: string;\n\treadonly location: string;\n\treadonly hint: string;\n\tdeclare readonly cause: StorageFailureCause;\n\tconstructor(descriptor: StorageDescriptor, reason: StorageWriterQueueDegradedReason, cause?: StorageFailureCause) {\n\t\tconst hint = WRITER_QUEUE_DEGRADED_HINTS[reason];\n\t\tsuper(\n\t\t\t`Storage writers' queue degraded: ${descriptor.adapter} at ${descriptor.location} (writer-queue-degraded, ${reason}). ${hint}`,\n\t\t\t{ cause },\n\t\t);\n\t\tthis.hint = hint;\n\t\tthis.reason = reason;\n\t\tthis.adapter = descriptor.adapter;\n\t\tthis.location = descriptor.location;\n\t}\n}\n\nexport type StorageWriterQueueUnusableCode = \"writer-queue-unusable\";\n\nconst WRITER_QUEUE_UNUSABLE_HINT =\n\t\"Make the writers' queue directories next to the database (<file>-writers and <file>-wakes) readable and writable for every process that writes the database\";\n\n/**\n * A node-sqlite transaction could not use the writers' queue next to the database: it could not read the queue\n * directory, or add, refresh, or read a ticket or its release notice. Nothing of the transaction ran. It is a\n * `StorageUnavailableError`, and its message keeps that error's `Storage unavailable:` prefix.\n */\nexport class StorageWriterQueueUnusableError extends StorageUnavailableError {\n\toverride readonly name = \"StorageWriterQueueUnusableError\" as const;\n\treadonly code: StorageWriterQueueUnusableCode = \"writer-queue-unusable\";\n\treadonly hint: string = WRITER_QUEUE_UNUSABLE_HINT;\n\t/** The filesystem's error code, such as `EACCES`, when the cause has one. */\n\tdeclare readonly errno?: string;\n\tconstructor(descriptor: StorageDescriptor, cause: StorageFailureCause) {\n\t\tconst { code } = (cause ?? {}) as { readonly code?: unknown };\n\t\tsuper(\n\t\t\tdescriptor,\n\t\t\tcause,\n\t\t\t`the writers' queue next to the database is unusable: ${cause instanceof Error ? cause.message : String(cause)} (writer-queue-unusable). ${WRITER_QUEUE_UNUSABLE_HINT}`,\n\t\t);\n\t\tif (typeof code === \"string\") this.errno = code;\n\t}\n}\n\nexport const STORAGE_TRANSIENT_ERROR_CODES = [\n\t\"stream-expired\",\n\t\"transaction-timeout\",\n\t\"connection-refused\",\n\t\"connection-lost\",\n\t\"lock-conflict\",\n\t\"read-only-server\",\n] as const;\n/**\n * Why a call to a database server failed for a while: `\"stream-expired\"`, the server ended a stream that stayed idle\n * too long, as a stream does whose process was stopped in the middle of a transaction; `\"transaction-timeout\"`, the\n * server rolled back a transaction that kept the write lock while another writer waited; `\"connection-refused\"`, no\n * connection to the server could be made; `\"connection-lost\"`, the connection broke while a request was on its way or\n * being answered; `\"lock-conflict\"`, the server aborted the transaction to resolve a lock conflict (a serialization\n * failure, a deadlock, or a lock wait that timed out); `\"read-only-server\"`, the server refused a write because it\n * accepts reads only, as a read replica does, or a primary for a while during a failover or when its storage is\n * nearly full.\n */\nexport type StorageTransientErrorCode = (typeof STORAGE_TRANSIENT_ERROR_CODES)[number];\n/**\n * Whether the failed call may have changed the database: `\"not-applied\"`, it cannot have; `\"unknown\"`, the connection\n * broke after the server may have applied a write that commits on its own (a commit, a batch, or a statement outside\n * a transaction).\n */\nexport type StorageTransientOutcome = \"not-applied\" | \"unknown\";\n\n/**\n * Where on the way to the database server a call failed, when it failed before it reached the server, such as at a\n * proxy. Neither text holds credentials.\n */\nexport interface StorageTransientHop {\n\t/** The hop, as the hint asks to check it, such as `the proxy http://proxy.example:3128`. */\n\treadonly name: string;\n\t/**\n\t * What happened there, as the message says it in place of \"the database server call failed\", such as\n\t * `the proxy http://proxy.example:3128 could not be reached for the tunnel to db.example.com:5432 (ECONNREFUSED)`.\n\t */\n\treadonly failure: string;\n}\n\nexport interface StorageTransientErrorDetails {\n\treadonly code: StorageTransientErrorCode;\n\treadonly outcome: StorageTransientOutcome;\n\t/** Which run of the call failed, counting from 1: a call that applied nothing runs again, up to a limit. */\n\treadonly attempts: number;\n\t/** Where on the way to the server the call failed, when it did not reach the server. */\n\treadonly hop?: StorageTransientHop;\n}\n\n/** What a failure of this outcome asks of the reader, about `subject`: the database server, or the hop that failed. */\nconst TRANSIENT_HINTS: Readonly<Record<StorageTransientOutcome, (subject: string) => string>> = {\n\t\"not-applied\": (subject) =>\n\t\t`Check that ${subject} is reachable and that this process is not stopped or starved of CPU, then retry; nothing was written`,\n\tunknown: (subject) =>\n\t\t`Check that ${subject} is reachable; the write may have been applied, so read it back before retrying a write that is not idempotent`,\n};\n\n/** What a failure of one of these codes asks of the reader, in place of the hint its outcome gives. */\nconst TRANSIENT_CODE_HINTS: Readonly<Partial<Record<StorageTransientErrorCode, string>>> = {\n\t\"read-only-server\":\n\t\t\"The server accepts reads only (SQLSTATE 25006): either the URL names a read replica or read-only endpoint (use the primary or the read/write endpoint), or the server is read-only right now (storage nearly full, or a failover in progress); nothing was written\",\n};\n\n/**\n * A call to a database server failed for a reason that passes: the server ended an idle stream or a transaction that\n * kept the write lock, or the connection could not be made or broke. `outcome` says whether the call may have written\n * anything. A database from `createSqliteDatabase` runs a call that wrote nothing again before it fails with this\n * error. It is a `StorageUnavailableError`, and its message keeps that error's `Storage unavailable:` prefix. A call\n * that failed on the way to the server, such as at a proxy, names that hop instead of the server.\n */\nexport class StorageTransientError extends StorageUnavailableError {\n\toverride readonly name = \"StorageTransientError\" as const;\n\treadonly code: StorageTransientErrorCode;\n\treadonly outcome: StorageTransientOutcome;\n\treadonly attempts: number;\n\treadonly retryable = true as const;\n\treadonly hint: string;\n\t/** The hop on the way to the server where the call failed (`StorageTransientHop.name`), when it did not reach it. */\n\tdeclare readonly hop?: string;\n\t/** What happened at `hop` (`StorageTransientHop.failure`). */\n\tdeclare readonly hopFailure?: string;\n\tconstructor(descriptor: StorageDescriptor, details: StorageTransientErrorDetails, cause?: StorageFailureCause) {\n\t\tconst { hop } = details;\n\t\tconst hint =\n\t\t\tTRANSIENT_CODE_HINTS[details.code] ?? TRANSIENT_HINTS[details.outcome](hop?.name ?? \"the database server\");\n\t\tsuper(\n\t\t\tdescriptor,\n\t\t\tcause,\n\t\t\t`${hop?.failure ?? \"the database server call failed\"} on attempt ${details.attempts} (${details.code}). ${hint}`,\n\t\t);\n\t\tthis.code = details.code;\n\t\tthis.outcome = details.outcome;\n\t\tthis.attempts = details.attempts;\n\t\tthis.hint = hint;\n\t\tif (hop !== undefined) {\n\t\t\tthis.hop = hop.name;\n\t\t\tthis.hopFailure = hop.failure;\n\t\t}\n\t}\n}\n\nexport const SESSION_BLOB_ERROR_CODES = [\n\t\"blobs-unsupported\",\n\t\"blob-missing\",\n\t\"blob-corrupt\",\n\t\"blob-incomplete\",\n] as const;\n/**\n * `\"blobs-unsupported\"`: the session store cannot hold blobs, and the operation needs it to; nothing was written.\n * `\"blob-missing\"`: the session holds no blob with the hash a reference names.\n * `\"blob-corrupt\"`: content carried in an exported session does not have the hash it is recorded under; nothing was\n * written.\n * `\"blob-incomplete\"`: the store holds a blob's record but lost part of its content.\n */\nexport type SessionBlobErrorCode = (typeof SESSION_BLOB_ERROR_CODES)[number];\n\nexport interface SessionBlobErrorFields {\n\treadonly sessionId: string;\n\t/** The blob's recorded SHA-256, as lowercase hex. For `\"blob-missing\"` reported by a copy: the first one missing. */\n\treadonly hash?: string;\n\t/** For `\"blob-missing\"` reported by a copy or an export: how many blobs the source did not hold. */\n\treadonly missing?: number;\n\t/** For `\"blob-incomplete\"`: the size the store recorded for the blob. */\n\treadonly bytes?: number;\n\t/** For `\"blob-corrupt\"`: the SHA-256 of the content that was found instead. */\n\treadonly actualHash?: string;\n\t/** For `\"blobs-unsupported\"`: the adapter of the store that cannot hold blobs. */\n\treadonly adapter?: string;\n}\n\nconst SESSION_BLOB_HINTS: Readonly<Record<SessionBlobErrorCode, string>> = {\n\t\"blobs-unsupported\":\n\t\t\"Keep the session in a SQLite or libSQL session store (the default sessions database, --session-store <path>, or a sessions.storage selection), or give a custom store putBlob and getBlob\",\n\t\"blob-missing\": \"The session no longer holds this output; run the tool again to see it\",\n\t\"blob-corrupt\": \"The exported session was changed after it was written; export it again from its source\",\n\t\"blob-incomplete\": \"The store lost part of this output; run the tool again to see it\",\n};\n\nfunction sessionBlobSubject(code: SessionBlobErrorCode, fields: SessionBlobErrorFields): string {\n\tswitch (code) {\n\t\tcase \"blobs-unsupported\":\n\t\t\treturn `Session store cannot hold blobs: ${fields.adapter} store of session ${fields.sessionId}`;\n\t\tcase \"blob-missing\":\n\t\t\treturn `Session blob not found: ${fields.hash}${(fields.missing ?? 0) > 1 ? ` and ${fields.missing! - 1} more` : \"\"} in session ${fields.sessionId}`;\n\t\tcase \"blob-corrupt\":\n\t\t\treturn `Session blob does not match its hash: ${fields.hash} in session ${fields.sessionId}`;\n\t\tcase \"blob-incomplete\":\n\t\t\treturn `Session blob is incomplete: ${fields.hash} (${fields.bytes} bytes) in session ${fields.sessionId}`;\n\t}\n}\n\n/**\n * A session blob, the content a session stores apart from its entries (a large tool output), could not be stored,\n * found, or trusted. Never retryable: each code needs a different store, a new tool run, or a new export.\n */\nexport class SessionBlobError extends StorageError {\n\toverride readonly name = \"SessionBlobError\" as const;\n\treadonly code: SessionBlobErrorCode;\n\treadonly hint: string;\n\treadonly sessionId: string;\n\tdeclare readonly hash?: string;\n\tdeclare readonly missing?: number;\n\tdeclare readonly bytes?: number;\n\tdeclare readonly actualHash?: string;\n\tdeclare readonly adapter?: string;\n\tconstructor(code: SessionBlobErrorCode, fields: SessionBlobErrorFields, options?: ErrorOptions) {\n\t\tconst hint = SESSION_BLOB_HINTS[code];\n\t\tsuper(`${sessionBlobSubject(code, fields)} (${code}). ${hint}`, options);\n\t\tthis.code = code;\n\t\tthis.hint = hint;\n\t\tthis.sessionId = fields.sessionId;\n\t\tif (fields.hash !== undefined) this.hash = fields.hash;\n\t\tif (fields.missing !== undefined) this.missing = fields.missing;\n\t\tif (fields.bytes !== undefined) this.bytes = fields.bytes;\n\t\tif (fields.actualHash !== undefined) this.actualHash = fields.actualHash;\n\t\tif (fields.adapter !== undefined) this.adapter = fields.adapter;\n\t}\n}\n\nexport const SESSION_SPILL_ERROR_CODES = [\n\t\"spill-dir-refused\",\n\t\"spill-write-failed\",\n\t\"spill-read-failed\",\n\t\"spill-missing\",\n\t\"spill-corrupt\",\n\t\"spill-cleanup-failed\",\n] as const;\n/**\n * How the in-memory session store failed to keep a released session's history in its file on disk, under the agent\n * directory's `released-history` directory.\n * `\"spill-dir-refused\"`: the directory for those files could not be created; released sessions keep their history in\n * memory. Recorded, not thrown.\n * `\"spill-write-failed\"`: a released session's history could not be written to its file; it stays in memory and\n * nothing is lost. Recorded, not thrown.\n * `\"spill-read-failed\"`: a released session's history could not be read back from its file; `retryable` when the\n * filesystem's failure passes (out of file descriptors, interrupted, busy).\n * `\"spill-missing\"`: a released session's file is gone or holds less than was written to it; its history is lost.\n * `\"spill-corrupt\"`: a released session's file holds something other than what was written to it; its history is lost.\n * `\"spill-cleanup-failed\"`: the file of a deleted or replaced session, or a closed store's directory, could not be\n * removed; it stays on disk until the process's directory is removed. Recorded, not thrown.\n */\nexport type SessionSpillErrorCode = (typeof SESSION_SPILL_ERROR_CODES)[number];\n\nexport interface SessionSpillErrorFields {\n\t/** The directory the store keeps released sessions' history in. */\n\treadonly directory: string;\n\t/** The session, for every code but `\"spill-dir-refused\"` and a whole directory's `\"spill-cleanup-failed\"`. */\n\treadonly sessionId?: string;\n\t/** The bytes of history the write held, or that the file should hold. */\n\treadonly bytes?: number;\n\t/** For `\"spill-missing\"` and `\"spill-corrupt\"`: the bytes the file held, when it still exists. */\n\treadonly foundBytes?: number;\n\t/** The filesystem's error code, such as `ENOSPC` or `ENOENT`, when the failure has one. */\n\treadonly errno?: string;\n}\n\n/** Filesystem failures that pass: a read that met one may work when tried again. */\nconst TRANSIENT_SPILL_ERRNOS: ReadonlySet<string | undefined> = new Set([\n\t\"EMFILE\",\n\t\"ENFILE\",\n\t\"EAGAIN\",\n\t\"EBUSY\",\n\t\"EINTR\",\n]);\n\nconst SESSION_SPILL_HINTS: Readonly<Record<SessionSpillErrorCode, string>> = {\n\t\"spill-dir-refused\":\n\t\t\"Released sessions keep their history in memory; make the agent directory writable by this account, or keep sessions in a SQLite session store\",\n\t\"spill-write-failed\":\n\t\t\"The session keeps its history in memory and nothing was lost; free space on the agent directory's disk or make it writable, or keep sessions in a SQLite session store\",\n\t\"spill-read-failed\":\n\t\t\"Check that the agent directory is readable and that the process has file descriptors to spare, then reopen the session\",\n\t\"spill-missing\":\n\t\t\"Something removed or truncated the session's file while the process ran, so the session cannot be reopened; leave the agent directory's released-history directory alone while Atomic runs, or keep sessions in a SQLite session store\",\n\t\"spill-corrupt\":\n\t\t\"Something changed the session's file while the process ran, so the session cannot be reopened; leave the agent directory's released-history directory alone while Atomic runs, or keep sessions in a SQLite session store\",\n\t\"spill-cleanup-failed\":\n\t\t\"The files stay on disk until the process's directory is removed, when it exits or by the next start's sweep; the store is not affected\",\n};\n\nfunction sessionSpillSubject(code: SessionSpillErrorCode, fields: SessionSpillErrorFields): string {\n\tconst session = `session ${fields.sessionId} in ${fields.directory}`;\n\tswitch (code) {\n\t\tcase \"spill-dir-refused\":\n\t\t\treturn `Could not use a directory for released sessions' history: ${fields.directory}`;\n\t\tcase \"spill-write-failed\":\n\t\t\treturn `Could not move a released session's history out of memory: ${session}`;\n\t\tcase \"spill-read-failed\":\n\t\t\treturn `Could not read a released session's history: ${session}`;\n\t\tcase \"spill-missing\":\n\t\t\treturn `A released session's history is missing: ${session}, ${fields.foundBytes ?? 0} of ${fields.bytes} bytes found`;\n\t\tcase \"spill-corrupt\":\n\t\t\treturn `A released session's history was changed on disk: ${session}`;\n\t\tcase \"spill-cleanup-failed\":\n\t\t\treturn `Could not remove released sessions' history from disk: ${fields.sessionId === undefined ? fields.directory : session}`;\n\t}\n}\n\n/**\n * The in-memory session store moves a released session's history to a file of its own under the agent directory and\n * reads it back when the session is loaded; this error says what went wrong with those files. `\"spill-read-failed\"`,\n * `\"spill-missing\"` and `\"spill-corrupt\"` are thrown by `load`, and a retryable `\"spill-read-failed\"` by a listing too;\n * a listing leaves out a session whose history it cannot read otherwise and records why once per session. The other\n * codes are recorded once each on the store. Each record is read with `spillDegradation()` and emitted once as a\n * process warning, and the store keeps the history in memory.\n */\nexport class SessionSpillError extends StorageError {\n\toverride readonly name = \"SessionSpillError\" as const;\n\treadonly code: SessionSpillErrorCode;\n\treadonly hint: string;\n\treadonly retryable: boolean;\n\treadonly directory: string;\n\tdeclare readonly sessionId?: string;\n\tdeclare readonly bytes?: number;\n\tdeclare readonly foundBytes?: number;\n\tdeclare readonly errno?: string;\n\tconstructor(code: SessionSpillErrorCode, fields: SessionSpillErrorFields, options?: ErrorOptions) {\n\t\tconst hint = SESSION_SPILL_HINTS[code];\n\t\tsuper(`${sessionSpillSubject(code, fields)} (${code}). ${hint}`, options);\n\t\tthis.code = code;\n\t\tthis.hint = hint;\n\t\tthis.retryable = code === \"spill-read-failed\" && TRANSIENT_SPILL_ERRNOS.has(fields.errno);\n\t\tthis.directory = fields.directory;\n\t\tif (fields.sessionId !== undefined) this.sessionId = fields.sessionId;\n\t\tif (fields.bytes !== undefined) this.bytes = fields.bytes;\n\t\tif (fields.foundBytes !== undefined) this.foundBytes = fields.foundBytes;\n\t\tif (fields.errno !== undefined) this.errno = fields.errno;\n\t}\n}\n\n/** Every code a storage error that carries one can have. */\nexport type StorageErrorCode =\n\t| SessionBlobErrorCode\n\t| SessionSpillErrorCode\n\t| StorageConfigErrorCode\n\t| StorageWriteLockTimeoutCode\n\t| StorageUnsupportedOperationCode\n\t| StorageWriterQueueDegradedCode\n\t| StorageWriterQueueUnusableCode\n\t| StorageTransientErrorCode\n\t| JournalCatalogErrorCode\n\t| JournalShardUnavailableErrorCode\n\t| JournalAdoptErrorCode;\n\nfunction hasNameAndCode(value: unknown, name: string, code: string): boolean {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tconst candidate = value as { readonly name?: unknown; readonly code?: unknown };\n\treturn candidate.name === name && candidate.code === code;\n}\n\n/** A `StorageConfigError`, from this module or another copy of it, or a rehydrated one. */\nexport function isStorageConfigError(value: unknown): value is StorageConfigError {\n\treturn value instanceof StorageConfigError || hasNameAndCode(value, \"StorageConfigError\", \"invalid-config\");\n}\n\nexport function isStorageWriteLockTimeoutError(value: unknown): value is StorageWriteLockTimeoutError {\n\treturn (\n\t\tvalue instanceof StorageWriteLockTimeoutError ||\n\t\thasNameAndCode(value, \"StorageWriteLockTimeoutError\", \"write-lock-timeout\")\n\t);\n}\n\nexport function isStorageUnsupportedOperationError(value: unknown): value is StorageUnsupportedOperationError {\n\treturn (\n\t\tvalue instanceof StorageUnsupportedOperationError ||\n\t\thasNameAndCode(value, \"StorageUnsupportedOperationError\", \"unsupported-operation\")\n\t);\n}\n\nexport function isStorageWriterQueueDegradedError(value: unknown): value is StorageWriterQueueDegradedError {\n\treturn (\n\t\tvalue instanceof StorageWriterQueueDegradedError ||\n\t\thasNameAndCode(value, \"StorageWriterQueueDegradedError\", \"writer-queue-degraded\")\n\t);\n}\n\nexport function isStorageWriterQueueUnusableError(value: unknown): value is StorageWriterQueueUnusableError {\n\treturn (\n\t\tvalue instanceof StorageWriterQueueUnusableError ||\n\t\thasNameAndCode(value, \"StorageWriterQueueUnusableError\", \"writer-queue-unusable\")\n\t);\n}\n\n/** A `StorageTransientError`, from this module or another copy of it, or a rehydrated one. */\nexport function isStorageTransientError(value: unknown): value is StorageTransientError {\n\treturn (\n\t\tvalue instanceof StorageTransientError || hasCode(value, \"StorageTransientError\", STORAGE_TRANSIENT_ERROR_CODES)\n\t);\n}\n\nexport function isSessionBlobError(value: unknown): value is SessionBlobError {\n\treturn value instanceof SessionBlobError || hasCode(value, \"SessionBlobError\", SESSION_BLOB_ERROR_CODES);\n}\n\n/** A `SessionSpillError`, from this module or another copy of it, or a rehydrated one. */\nexport function isSessionSpillError(value: unknown): value is SessionSpillError {\n\treturn value instanceof SessionSpillError || hasCode(value, \"SessionSpillError\", SESSION_SPILL_ERROR_CODES);\n}\n\n/**\n * Any storage error: an instance of `StorageError` or one of its subclasses, including a rehydrated one, or a copy of\n * a storage error with a stable `code` from another module instance, recognized by its name and code.\n */\nexport function isStorageError(value: unknown): value is StorageError {\n\treturn (\n\t\tvalue instanceof StorageError ||\n\t\tisStorageConfigError(value) ||\n\t\tisStorageWriteLockTimeoutError(value) ||\n\t\tisStorageUnsupportedOperationError(value) ||\n\t\tisStorageWriterQueueDegradedError(value) ||\n\t\tisStorageWriterQueueUnusableError(value) ||\n\t\tisStorageTransientError(value) ||\n\t\tisSessionBlobError(value) ||\n\t\tisSessionSpillError(value) ||\n\t\tisJournalStoreError(value)\n\t);\n}\n\nfunction causeOf(value: unknown): unknown {\n\treturn typeof value === \"object\" && value !== null ? (value as { readonly cause?: unknown }).cause : undefined;\n}\n\n/** The write-lock timeout anywhere in an error's cause chain, for failures that wrap it. */\nexport function findStorageWriteLockTimeoutError(error: unknown): StorageWriteLockTimeoutError | undefined {\n\tlet current = error;\n\tfor (let depth = 0; depth < MAX_STORAGE_CAUSE_DEPTH; depth++) {\n\t\tif (isStorageWriteLockTimeoutError(current)) return current;\n\t\tcurrent = causeOf(current);\n\t}\n\treturn undefined;\n}\n\n/** A JSON-safe fact an error of the journal store carries: an id, a path, a count, a phase. */\nexport type JournalStoreFieldValue = string | number | boolean | null;\nexport type JournalStoreFields = Readonly<Record<string, JournalStoreFieldValue>>;\n\nexport const JOURNAL_CATALOG_ERROR_CODES = [\n\t\"catalog-unavailable\",\n\t\"schema-version\",\n\t\"corrupt\",\n\t\"write-failed\",\n\t\"run-conflict\",\n\t\"run-not-found\",\n\t\"run-moved\",\n] as const;\nexport type JournalCatalogErrorCode = (typeof JOURNAL_CATALOG_ERROR_CODES)[number];\n\nexport const JOURNAL_SHARD_UNAVAILABLE_ERROR_CODES = [\"shard-missing\", \"shard-open-failed\"] as const;\nexport type JournalShardUnavailableErrorCode = (typeof JOURNAL_SHARD_UNAVAILABLE_ERROR_CODES)[number];\n\nexport const JOURNAL_ADOPT_ERROR_CODES = [\"path-not-found\", \"not-a-journal\", \"schema-version\", \"run-conflict\"] as const;\nexport type JournalAdoptErrorCode = (typeof JOURNAL_ADOPT_ERROR_CODES)[number];\n\n/** What a catalog write was doing when it failed. */\nexport type JournalCatalogPhase =\n\t| \"opening\"\n\t| \"placing-run\"\n\t| \"recording-status\"\n\t| \"removing-run\"\n\t| \"registering-shard\"\n\t| \"moving-run\";\n\n/** Why a path is not an adoptable journal. */\nexport type JournalAdoptNotJournalReason = \"not-sqlite\" | \"no-journal-tables\" | \"store-catalog\" | \"directory\";\n\nconst MAX_CAUSE_DEPTH = 8;\nconst DETAIL_LIMIT = 200;\n\n/** The first line of a cause's message, short and free of stack frames, as `StorageUnavailableError` keeps it. */\nfunction causeDetail(cause: StorageFailureCause | Error | undefined): string | null {\n\tif (!(cause instanceof Error)) return null;\n\tconst nested = cause.cause instanceof Error ? cause.cause.message : \"\";\n\tconst line = (cause.message.includes(nested) ? cause.message : `${cause.message}: ${nested}`).split(\"\\n\", 1)[0]!;\n\tconst trimmed = line.trim();\n\tif (trimmed === \"\") return null;\n\treturn trimmed.length > DETAIL_LIMIT ? `${trimmed.slice(0, DETAIL_LIMIT - 1)}…` : trimmed;\n}\n\n/** Only a write lock another connection holds is worth retrying; every other storage failure needs a person. */\nfunction busyCause(cause: StorageFailureCause | Error | undefined): boolean {\n\treturn isSqliteBusy(cause) || isRetryableStorageError(cause);\n}\n\ninterface JournalStoreErrorParts {\n\treadonly name?: string;\n\treadonly code: string;\n\treadonly message: string;\n\treadonly hint?: string;\n\treadonly fields: JournalStoreFields;\n\treadonly retryable: boolean;\n\treadonly cause?: StorageFailureCause | Error;\n}\n\n/**\n * The family of the workflow journal store: its catalog, its shards, and adopting journals into it. Every member\n * carries a stable `code`, JSON-safe `fields`, a `hint` naming what to do next, and `retryable`.\n */\nexport class JournalStoreError extends StorageError {\n\toverride readonly name: string;\n\treadonly code: string;\n\treadonly hint: string | undefined;\n\treadonly fields: JournalStoreFields;\n\treadonly retryable: boolean;\n\n\tconstructor(parts: JournalStoreErrorParts) {\n\t\tsuper(parts.message, parts.cause === undefined ? undefined : { cause: parts.cause });\n\t\tthis.name = parts.name ?? \"JournalStoreError\";\n\t\tthis.code = parts.code;\n\t\tthis.hint = parts.hint;\n\t\tthis.fields = Object.freeze({ ...parts.fields });\n\t\tthis.retryable = parts.retryable;\n\t}\n}\n\nfunction compact(fields: Readonly<Record<string, JournalStoreFieldValue | undefined>>): JournalStoreFields {\n\treturn Object.fromEntries(Object.entries(fields).filter(([, value]) => value !== undefined)) as JournalStoreFields;\n}\n\n/** A schema version as a JSON-safe field: a number or null as it is, any other value SQLite stores as its text. */\nfunction schemaVersionField(found: SqliteValue | undefined): string | number | null | undefined {\n\treturn found === undefined || found === null || typeof found === \"number\" ? found : String(found);\n}\n\nexport interface JournalCatalogErrorInit {\n\treadonly code: JournalCatalogErrorCode;\n\treadonly catalogPath: string;\n\treadonly phase?: JournalCatalogPhase;\n\treadonly runId?: string;\n\treadonly shardId?: number;\n\treadonly shardPath?: string;\n\t/** `schema-version`: the version found in the catalog; null when it has none. */\n\treadonly found?: SqliteValue;\n\t/** `schema-version`: the version this Atomic supports. */\n\treadonly supported?: number;\n\t/** `corrupt`: which consistency rule the catalog breaks. */\n\treadonly rule?: string;\n\t/** `run-not-found`: the journal selection searched, as `atomic storage status` describes it. */\n\treadonly selection?: string;\n\t/** `run-not-found`: whether this machine's storage is local only, so a run of another machine cannot be here. */\n\treadonly localOnly?: boolean;\n\t/** `run-moved`: the last sequence number a read returned before the run moved. */\n\treadonly lastSeq?: number;\n\treadonly retryable?: boolean;\n\treadonly cause?: StorageFailureCause | Error;\n}\n\n/** The command that joins this machine to the team's shared storage; error hints across Atomic name it. */\nexport const SHARED_STORAGE_JOIN_HINT = \"atomic team join <url> --token-file <path>\";\n/** The command that joins a machine to a shared PostgreSQL database, which `atomic team join` refuses (#5218). */\nexport const POSTGRES_STORAGE_JOIN_HINT = \"atomic storage join <postgres-url> --password-file <path>\";\n/** The command that registers an older journal file in the journal store. */\nexport const JOURNAL_ADOPT_COMMAND = \"atomic storage adopt <path>\";\n\nfunction catalogText(init: JournalCatalogErrorInit, detail: string | null): { message: string; hint: string } {\n\tconst subject = init.catalogPath;\n\tswitch (init.code) {\n\t\tcase \"catalog-unavailable\":\n\t\t\treturn {\n\t\t\t\tmessage: `Journal catalog unavailable: ${subject}${detail === null ? \"\" : ` (${detail})`} (catalog-unavailable).`,\n\t\t\t\thint: \"Check that the journal directory is readable and writable and the disk has free space, then retry; `atomic storage status` shows the store in use.\",\n\t\t\t};\n\t\tcase \"schema-version\":\n\t\t\treturn {\n\t\t\t\tmessage: `Journal catalog schema not supported: ${subject} has version ${String(init.found)}, this Atomic supports ${String(init.supported)} (schema-version).`,\n\t\t\t\thint: \"Upgrade Atomic to the version that wrote this catalog, or select another journal with workflows.journal.\",\n\t\t\t};\n\t\tcase \"corrupt\":\n\t\t\treturn {\n\t\t\t\tmessage: `Journal catalog is inconsistent: ${subject} (${init.rule ?? \"unknown rule\"}) (corrupt).`,\n\t\t\t\thint: `Move ${subject} aside, then adopt every shard file in its directory again with \\`atomic storage adopt ${subject.replace(/[\\\\/][^\\\\/]*$/, \"\")}/shard-*.sqlite\\` to rebuild it.`,\n\t\t\t};\n\t\tcase \"write-failed\":\n\t\t\treturn {\n\t\t\t\tmessage: `Journal catalog write failed: ${subject} while ${init.phase ?? \"writing\"}${init.runId === undefined ? \"\" : ` run ${init.runId}`}${detail === null ? \"\" : ` (${detail})`} (write-failed).`,\n\t\t\t\thint: \"Free disk space or release the lock another process holds on the catalog, then retry; checkpoints already written stay on their shard.\",\n\t\t\t};\n\t\tcase \"run-conflict\":\n\t\t\treturn {\n\t\t\t\tmessage: `Journal run conflict: run ${init.runId ?? \"unknown\"} already has a different copy in ${init.shardPath ?? `shard ${String(init.shardId)}`} (run-conflict).`,\n\t\t\t\thint: \"Compare the two copies and check the catalog's current location before retrying consolidation; both copies are preserved when their histories differ.\",\n\t\t\t};\n\t\tcase \"run-moved\":\n\t\t\treturn {\n\t\t\t\tmessage: `Journal run moved while it was read: run ${init.runId ?? \"unknown\"} left ${init.shardPath ?? `shard ${String(init.shardId)}`} after sequence ${String(init.lastSeq)} and its new shard did not continue the history (run-moved).`,\n\t\t\t\thint: \"A consolidation moved this run while it was read; read it again.\",\n\t\t\t};\n\t\tcase \"run-not-found\":\n\t\t\treturn {\n\t\t\t\tmessage: `Workflow run not found: ${init.runId ?? \"unknown\"} in ${init.selection ?? subject} (run-not-found).`,\n\t\t\t\thint: init.localOnly\n\t\t\t\t\t? `This machine uses local-only storage and is not joined to shared storage. If the run started on another machine, join its storage with \\`${SHARED_STORAGE_JOIN_HINT}\\`; if it is in an older journal file, adopt it with \\`${JOURNAL_ADOPT_COMMAND}\\`.`\n\t\t\t\t\t: \"The shared storage selected here does not hold this run; check the run ID with `/workflows`.\",\n\t\t\t};\n\t}\n}\n\n/** The journal catalog, which maps every run to its shard, cannot be opened, read or written. */\nexport class JournalCatalogError extends JournalStoreError {\n\toverride readonly name = \"JournalCatalogError\" as const;\n\tdeclare readonly code: JournalCatalogErrorCode;\n\tdeclare readonly hint: string;\n\treadonly catalogPath: string;\n\treadonly phase: JournalCatalogPhase | undefined;\n\treadonly runId: string | undefined;\n\n\tconstructor(init: JournalCatalogErrorInit) {\n\t\tconst detail = causeDetail(init.cause);\n\t\tconst text = catalogText(init, detail);\n\t\tsuper({\n\t\t\tcode: init.code,\n\t\t\tmessage: text.message,\n\t\t\thint: text.hint,\n\t\t\tfields: compact({\n\t\t\t\tcatalogPath: init.catalogPath,\n\t\t\t\tphase: init.phase,\n\t\t\t\trunId: init.runId,\n\t\t\t\tshardId: init.shardId,\n\t\t\t\tshardPath: init.shardPath,\n\t\t\t\tfound: schemaVersionField(init.found),\n\t\t\t\tsupported: init.supported,\n\t\t\t\trule: init.rule,\n\t\t\t\tselection: init.selection,\n\t\t\t\tlocalOnly: init.localOnly,\n\t\t\t\tlastSeq: init.lastSeq,\n\t\t\t\tdetail: detail ?? undefined,\n\t\t\t}),\n\t\t\tretryable: init.retryable ?? (init.code === \"run-moved\" || busyCause(init.cause)),\n\t\t\tcause: init.cause,\n\t\t});\n\t\tthis.catalogPath = init.catalogPath;\n\t\tthis.phase = init.phase;\n\t\tthis.runId = init.runId;\n\t}\n}\n\nexport interface JournalShardUnavailableErrorInit {\n\treadonly code: JournalShardUnavailableErrorCode;\n\treadonly shardId: number;\n\treadonly shardPath: string;\n\treadonly runId?: string;\n\treadonly retryable?: boolean;\n\treadonly cause?: StorageFailureCause | Error;\n}\n\n/** The shard file that holds a run cannot be opened: it is missing, unreadable, or not a database. */\nexport class JournalShardUnavailableError extends JournalStoreError {\n\toverride readonly name = \"JournalShardUnavailableError\" as const;\n\tdeclare readonly code: JournalShardUnavailableErrorCode;\n\tdeclare readonly hint: string;\n\treadonly shardId: number;\n\treadonly shardPath: string;\n\treadonly runId: string | undefined;\n\n\tconstructor(init: JournalShardUnavailableErrorInit) {\n\t\tconst detail = causeDetail(init.cause);\n\t\tconst subject = `${init.shardPath}${init.runId === undefined ? \"\" : ` for run ${init.runId}`}`;\n\t\tconst missing = init.code === \"shard-missing\";\n\t\tsuper({\n\t\t\tcode: init.code,\n\t\t\tmessage: `Journal shard unavailable: ${subject}${detail === null ? \"\" : ` (${detail})`} (${init.code}).`,\n\t\t\thint: missing\n\t\t\t\t? \"Restore the file at this path: the catalog keeps its runs registered there.\"\n\t\t\t\t: \"Check the file's permissions and the disk's free space, then retry.\",\n\t\t\tfields: compact({\n\t\t\t\tshardId: init.shardId,\n\t\t\t\tshardPath: init.shardPath,\n\t\t\t\trunId: init.runId,\n\t\t\t\tdetail: detail ?? undefined,\n\t\t\t}),\n\t\t\tretryable: init.retryable ?? (!missing && busyCause(init.cause)),\n\t\t\tcause: init.cause,\n\t\t});\n\t\tthis.shardId = init.shardId;\n\t\tthis.shardPath = init.shardPath;\n\t\tthis.runId = init.runId;\n\t}\n}\n\nexport interface JournalAdoptErrorInit {\n\treadonly code: JournalAdoptErrorCode;\n\treadonly path: string;\n\treadonly reason?: JournalAdoptNotJournalReason;\n\treadonly runId?: string;\n\t/** `run-conflict`: where the store already has the run. */\n\treadonly existingPath?: string;\n\t/** `schema-version`: the version found in the journal; null when it has none. */\n\treadonly found?: SqliteValue;\n\treadonly supported?: number;\n\treadonly cause?: StorageFailureCause | Error;\n}\n\nfunction adoptText(init: JournalAdoptErrorInit): { message: string; hint: string } {\n\tswitch (init.code) {\n\t\tcase \"path-not-found\":\n\t\t\treturn {\n\t\t\t\tmessage: `Cannot adopt journal: ${init.path} does not exist (path-not-found).`,\n\t\t\t\thint: \"Pass the path of a journal .sqlite file, or of the directory holding its journal.sqlite.\",\n\t\t\t};\n\t\tcase \"not-a-journal\":\n\t\t\treturn {\n\t\t\t\tmessage: `Cannot adopt journal: ${init.path} is not a workflow journal (${init.reason ?? \"no-journal-tables\"}) (not-a-journal).`,\n\t\t\t\thint:\n\t\t\t\t\tinit.reason === \"store-catalog\"\n\t\t\t\t\t\t? \"The journal store's own catalog is never adopted; pass the path of a legacy journal file.\"\n\t\t\t\t\t\t: \"Pass a SQLite file that Atomic wrote workflow runs to, such as a journal.sqlite selected with ATOMIC_WORKFLOW_JOURNAL_PATH.\",\n\t\t\t};\n\t\tcase \"schema-version\":\n\t\t\treturn {\n\t\t\t\tmessage: `Cannot adopt journal: ${init.path} has schema version ${String(init.found)}, this Atomic supports ${String(init.supported)} (schema-version).`,\n\t\t\t\thint: \"Adopt it with the Atomic version that wrote it, or upgrade Atomic.\",\n\t\t\t};\n\t\tcase \"run-conflict\":\n\t\t\treturn {\n\t\t\t\tmessage: `Cannot adopt journal: ${init.path} holds run ${init.runId ?? \"unknown\"}, which the store already has in ${init.existingPath ?? \"another journal\"} (run-conflict).`,\n\t\t\t\thint: \"Adopt only one copy of a journal; nothing was registered.\",\n\t\t\t};\n\t}\n}\n\n/** A journal file cannot be adopted into the journal store; nothing was registered. */\nexport class JournalAdoptError extends JournalStoreError {\n\toverride readonly name = \"JournalAdoptError\" as const;\n\tdeclare readonly code: JournalAdoptErrorCode;\n\tdeclare readonly hint: string;\n\treadonly path: string;\n\treadonly reason: JournalAdoptNotJournalReason | undefined;\n\n\tconstructor(init: JournalAdoptErrorInit) {\n\t\tconst text = adoptText(init);\n\t\tsuper({\n\t\t\tcode: init.code,\n\t\t\tmessage: text.message,\n\t\t\thint: text.hint,\n\t\t\tfields: compact({\n\t\t\t\tpath: init.path,\n\t\t\t\treason: init.reason,\n\t\t\t\trunId: init.runId,\n\t\t\t\texistingPath: init.existingPath,\n\t\t\t\tfound: schemaVersionField(init.found),\n\t\t\t\tsupported: init.supported,\n\t\t\t\tdetail: causeDetail(init.cause) ?? undefined,\n\t\t\t}),\n\t\t\tretryable: false,\n\t\t\tcause: init.cause,\n\t\t});\n\t\tthis.path = init.path;\n\t\tthis.reason = init.reason;\n\t}\n}\n\nfunction hasCode<Code extends string>(value: unknown, name: string, codes: readonly Code[]): boolean {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tconst candidate = value as { name?: unknown; code?: unknown };\n\treturn candidate.name === name && codes.includes(candidate.code as Code);\n}\n\nconst JOURNAL_STORE_ERROR_NAMES: ReadonlySet<unknown> = new Set([\n\t\"JournalStoreError\",\n\t\"JournalCatalogError\",\n\t\"JournalShardUnavailableError\",\n\t\"JournalAdoptError\",\n]);\n\n/**\n * A journal store error: an instance of `JournalStoreError`, or a copy from another module instance or a process\n * boundary, recognized by the name of one of its classes and the shape every one of them has. An error of another\n * family that happens to carry a `code`, `fields` and `retryable` is not one.\n */\nexport function isJournalStoreError(value: unknown): value is JournalStoreError {\n\tif (value instanceof JournalStoreError) return true;\n\tif (typeof value !== \"object\" || value === null) return false;\n\tconst candidate = value as { name?: unknown; code?: unknown; fields?: unknown; retryable?: unknown };\n\treturn (\n\t\tJOURNAL_STORE_ERROR_NAMES.has(candidate.name) &&\n\t\ttypeof candidate.code === \"string\" &&\n\t\ttypeof candidate.retryable === \"boolean\" &&\n\t\ttypeof candidate.fields === \"object\" &&\n\t\tcandidate.fields !== null\n\t);\n}\n\nexport function isJournalCatalogError(value: unknown): value is JournalCatalogError {\n\treturn value instanceof JournalCatalogError || hasCode(value, \"JournalCatalogError\", JOURNAL_CATALOG_ERROR_CODES);\n}\n\nexport function isJournalShardUnavailableError(value: unknown): value is JournalShardUnavailableError {\n\treturn (\n\t\tvalue instanceof JournalShardUnavailableError ||\n\t\thasCode(value, \"JournalShardUnavailableError\", JOURNAL_SHARD_UNAVAILABLE_ERROR_CODES)\n\t);\n}\n\nexport function isJournalAdoptError(value: unknown): value is JournalAdoptError {\n\treturn value instanceof JournalAdoptError || hasCode(value, \"JournalAdoptError\", JOURNAL_ADOPT_ERROR_CODES);\n}\n\n/** The first journal store error in `error`'s cause chain, looking at most eight causes deep. */\nexport function findJournalStoreError(error: unknown): JournalStoreError | undefined {\n\tlet current = error;\n\tfor (let depth = 0; depth < MAX_CAUSE_DEPTH; depth++) {\n\t\tif (isJournalStoreError(current)) return current;\n\t\tif (!(current instanceof Error)) return undefined;\n\t\tcurrent = current.cause;\n\t}\n\treturn undefined;\n}\n\n/** Whether a storage error in the cause chain says the operation may succeed if tried again later. */\nexport function isRetryableStorageError(error: unknown): boolean {\n\tlet current = error;\n\tfor (let depth = 0; depth < MAX_STORAGE_CAUSE_DEPTH; depth++) {\n\t\tif (isStorageWriteLockTimeoutError(current) && current.retryable === true) return true;\n\t\tif (isStorageTransientError(current) && current.retryable === true) return true;\n\t\tif (isJournalStoreError(current) && current.retryable) return true;\n\t\tif (isSessionSpillError(current) && current.retryable === true) return true;\n\t\tcurrent = causeOf(current);\n\t}\n\treturn false;\n}\n\n/** Whether anything in `error`'s cause chain is a journal store error a caller may retry. */\nexport function isRetryableJournalStoreError(error: unknown): boolean {\n\tlet current = error;\n\tfor (let depth = 0; depth < MAX_CAUSE_DEPTH; depth++) {\n\t\tif (isJournalStoreError(current) && current.retryable) return true;\n\t\tif (!(current instanceof Error)) return false;\n\t\tcurrent = current.cause;\n\t}\n\treturn false;\n}\n\n/** A JSON-safe storage error, for sending across a process boundary; `rehydrateStorageError` reverses it. */\nexport interface SerializedStorageError {\n\treadonly name: string;\n\treadonly code?: string;\n\treadonly message: string;\n\treadonly hint?: string;\n\treadonly fields: Readonly<Record<string, string | number | boolean>>;\n\treadonly cause?: SerializedStorageError;\n\t/** A `StorageRollbackError`'s failed rollback. */\n\treadonly rollbackCause?: SerializedStorageError;\n\t/** A cleanup failure attached to the error it followed. */\n\treadonly cleanupCause?: SerializedStorageError;\n}\n\n/** Own properties carried outside `fields`: `message`, `stack`, and `cause` are not enumerable. */\nconst STRUCTURAL_KEYS = new Set([\"name\", \"code\", \"hint\"]);\n\nfunction isFiniteNumber(value: unknown): value is number {\n\treturn Number.isFinite(value);\n}\n\nfunction scalarFields(source: object, keys: readonly string[]): Record<string, string | number | boolean> {\n\tconst fields: Record<string, string | number | boolean> = {};\n\tfor (const key of keys) {\n\t\tconst value = (source as Record<string, unknown>)[key];\n\t\tif (typeof value === \"string\" || typeof value === \"boolean\" || isFiniteNumber(value)) fields[key] = value;\n\t}\n\treturn fields;\n}\n\nfunction serializeFailure(failure: unknown, depth: number): SerializedStorageError {\n\tif (!(failure instanceof Error)) return { name: \"Error\", message: String(failure), fields: {} };\n\tconst { code, hint, rollbackCause, cleanupCause } = failure as {\n\t\treadonly code?: unknown;\n\t\treadonly hint?: unknown;\n\t\treadonly rollbackCause?: unknown;\n\t\treadonly cleanupCause?: unknown;\n\t};\n\tconst keys = Object.keys(failure).filter((key) => !STRUCTURAL_KEYS.has(key));\n\tconst nested = (key: \"cause\" | \"rollbackCause\" | \"cleanupCause\", value: unknown) =>\n\t\tvalue !== undefined && depth + 1 < MAX_STORAGE_CAUSE_DEPTH ? { [key]: serializeFailure(value, depth + 1) } : {};\n\treturn {\n\t\tname: failure.name,\n\t\t...(typeof code === \"string\" || typeof code === \"number\" ? { code: String(code) } : {}),\n\t\tmessage: failure.message,\n\t\t...(typeof hint === \"string\" ? { hint } : {}),\n\t\tfields: scalarFields(failure, keys),\n\t\t...nested(\"cause\", failure.cause),\n\t\t...nested(\"rollbackCause\", rollbackCause),\n\t\t...nested(\"cleanupCause\", cleanupCause),\n\t};\n}\n\n/**\n * The storage error as `{ name, code, message, hint, fields, cause }`, with its cause chain, a rollback's\n * `rollbackCause`, and an attached `cleanupCause` serialized to a bounded depth. Fields hold only the error's own\n * scalar facts (identifiers, paths, timings, limits), never credentials.\n */\nexport function serializeStorageError(error: StorageError): SerializedStorageError {\n\treturn serializeFailure(error, 0);\n}\n\nfunction field<T extends string | number | boolean>(\n\tserialized: SerializedStorageError,\n\tkey: string,\n\ttype: \"string\" | \"number\" | \"boolean\",\n): T | undefined {\n\tconst value = serialized.fields[key];\n\treturn typeof value === type ? (value as T) : undefined;\n}\n\nfunction descriptorOf(serialized: SerializedStorageError): StorageDescriptor {\n\treturn {\n\t\tadapter: field<string>(serialized, \"adapter\", \"string\") ?? \"unknown\",\n\t\tlocation: field<string>(serialized, \"location\", \"string\") ?? \"unknown\",\n\t};\n}\n\n/** A `StorageTransientError`'s hop, when the serialized error carried both its name and its failure. */\nfunction transientHopOf(serialized: SerializedStorageError): { hop?: StorageTransientHop } {\n\tconst name = field<string>(serialized, \"hop\", \"string\");\n\tconst failure = field<string>(serialized, \"hopFailure\", \"string\");\n\treturn name === undefined || failure === undefined ? {} : { hop: { name, failure } };\n}\n\nfunction nestedFailure(serialized: SerializedStorageError | undefined, depth: number): Error | undefined {\n\treturn serialized === undefined || depth + 1 >= MAX_STORAGE_CAUSE_DEPTH\n\t\t? undefined\n\t\t: rehydrateFailure(serialized, depth + 1);\n}\n\n/** The storage class `serializeStorageError` named, rebuilt from its fields; undefined for a name it does not know. */\nfunction knownStorageError(\n\tserialized: SerializedStorageError,\n\tcause: Error | undefined,\n\tdepth: number,\n): Error | undefined {\n\tswitch (serialized.name) {\n\t\tcase \"StorageConfigError\": {\n\t\t\tconst source = field<string>(serialized, \"source\", \"string\");\n\t\t\treturn new StorageConfigError(\n\t\t\t\tsource === \"cli\" || source === \"env\" || source === \"settings\" ? source : \"sdk\",\n\t\t\t\tfield<string>(serialized, \"field\", \"string\") ?? \"\",\n\t\t\t\tfield<string>(serialized, \"reason\", \"string\") ?? \"\",\n\t\t\t\tserialized.hint,\n\t\t\t);\n\t\t}\n\t\tcase \"StorageWriteLockTimeoutError\":\n\t\t\treturn new StorageWriteLockTimeoutError(\n\t\t\t\tdescriptorOf(serialized),\n\t\t\t\t{\n\t\t\t\t\ttimeoutMs: field<number>(serialized, \"timeoutMs\", \"number\") ?? 0,\n\t\t\t\t\telapsedMs: field<number>(serialized, \"elapsedMs\", \"number\") ?? 0,\n\t\t\t\t\tphase: field<string>(serialized, \"phase\", \"string\") === \"queued\" ? \"queued\" : \"acquiring\",\n\t\t\t\t\tholderPid: field<number>(serialized, \"holderPid\", \"number\"),\n\t\t\t\t\tholderHeldMs: field<number>(serialized, \"holderHeldMs\", \"number\"),\n\t\t\t\t\tholderCandidates: field<string>(serialized, \"holderCandidates\", \"string\"),\n\t\t\t\t},\n\t\t\t\tcause,\n\t\t\t);\n\t\tcase \"StorageUnsupportedOperationError\": {\n\t\t\tconst operation = field<string>(serialized, \"operation\", \"string\");\n\t\t\treturn new StorageUnsupportedOperationError(\n\t\t\t\tdescriptorOf(serialized),\n\t\t\t\tSTORAGE_OPERATIONS.find((known) => known === operation) ?? STORAGE_OPERATIONS[0],\n\t\t\t);\n\t\t}\n\t\tcase \"StorageWriterQueueDegradedError\": {\n\t\t\tconst reason = field<string>(serialized, \"reason\", \"string\");\n\t\t\treturn new StorageWriterQueueDegradedError(\n\t\t\t\tdescriptorOf(serialized),\n\t\t\t\tWRITER_QUEUE_DEGRADED_REASONS.find((known) => known === reason) ?? WRITER_QUEUE_DEGRADED_REASONS[0],\n\t\t\t\tcause,\n\t\t\t);\n\t\t}\n\t\tcase \"StorageWriterQueueUnusableError\":\n\t\t\treturn new StorageWriterQueueUnusableError(descriptorOf(serialized), cause);\n\t\tcase \"StorageTransientError\": {\n\t\t\tconst code = STORAGE_TRANSIENT_ERROR_CODES.find((known) => known === serialized.code);\n\t\t\tif (code === undefined) return undefined;\n\t\t\treturn new StorageTransientError(\n\t\t\t\tdescriptorOf(serialized),\n\t\t\t\t{\n\t\t\t\t\tcode,\n\t\t\t\t\toutcome: field<string>(serialized, \"outcome\", \"string\") === \"not-applied\" ? \"not-applied\" : \"unknown\",\n\t\t\t\t\tattempts: field<number>(serialized, \"attempts\", \"number\") ?? 1,\n\t\t\t\t\t...transientHopOf(serialized),\n\t\t\t\t},\n\t\t\t\tcause,\n\t\t\t);\n\t\t}\n\t\tcase \"SessionBlobError\": {\n\t\t\tconst code = SESSION_BLOB_ERROR_CODES.find((known) => known === serialized.code);\n\t\t\tif (code === undefined) return undefined;\n\t\t\treturn new SessionBlobError(\n\t\t\t\tcode,\n\t\t\t\t{\n\t\t\t\t\tsessionId: field<string>(serialized, \"sessionId\", \"string\") ?? \"\",\n\t\t\t\t\thash: field<string>(serialized, \"hash\", \"string\"),\n\t\t\t\t\tmissing: field<number>(serialized, \"missing\", \"number\"),\n\t\t\t\t\tbytes: field<number>(serialized, \"bytes\", \"number\"),\n\t\t\t\t\tactualHash: field<string>(serialized, \"actualHash\", \"string\"),\n\t\t\t\t\tadapter: field<string>(serialized, \"adapter\", \"string\"),\n\t\t\t\t},\n\t\t\t\tcause === undefined ? undefined : { cause },\n\t\t\t);\n\t\t}\n\t\tcase \"SessionSpillError\": {\n\t\t\tconst code = SESSION_SPILL_ERROR_CODES.find((known) => known === serialized.code);\n\t\t\tif (code === undefined) return undefined;\n\t\t\treturn new SessionSpillError(\n\t\t\t\tcode,\n\t\t\t\t{\n\t\t\t\t\tdirectory: field<string>(serialized, \"directory\", \"string\") ?? \"\",\n\t\t\t\t\tsessionId: field<string>(serialized, \"sessionId\", \"string\"),\n\t\t\t\t\tbytes: field<number>(serialized, \"bytes\", \"number\"),\n\t\t\t\t\tfoundBytes: field<number>(serialized, \"foundBytes\", \"number\"),\n\t\t\t\t\terrno: field<string>(serialized, \"errno\", \"string\"),\n\t\t\t\t},\n\t\t\t\tcause === undefined ? undefined : { cause },\n\t\t\t);\n\t\t}\n\t\tcase \"StorageUnavailableError\":\n\t\t\treturn new StorageUnavailableError(descriptorOf(serialized), cause);\n\t\tcase \"StoreClosedError\":\n\t\t\treturn new StoreClosedError(descriptorOf(serialized));\n\t\tcase \"StorageTransactionClosedError\":\n\t\t\treturn new StorageTransactionClosedError();\n\t\tcase \"StorageRollbackError\":\n\t\t\treturn new StorageRollbackError(cause, nestedFailure(serialized.rollbackCause, depth));\n\t\tcase \"StorageInvalidTextError\":\n\t\t\treturn new StorageInvalidTextError(field<number>(serialized, \"parameterIndex\", \"number\") ?? 0);\n\t\tcase \"StorageSchemaVersionError\":\n\t\t\treturn new StorageSchemaVersionError(\n\t\t\t\tfield<string>(serialized, \"domain\", \"string\") ?? \"\",\n\t\t\t\tfield<string>(serialized, \"found\", \"string\") ?? field<number>(serialized, \"found\", \"number\") ?? null,\n\t\t\t\tfield<number>(serialized, \"supported\", \"number\") ?? 0,\n\t\t\t);\n\t\tcase \"StoragePrefixError\": {\n\t\t\tconst reason = field<string>(serialized, \"reason\", \"string\");\n\t\t\treturn new StoragePrefixError(\n\t\t\t\tfield<string>(serialized, \"prefix\", \"string\") ?? \"\",\n\t\t\t\treason === \"reserved\" || reason === \"too-long\" || reason === \"identifier-collision\" ? reason : \"pattern\",\n\t\t\t\tfield<number>(serialized, \"maxLength\", \"number\"),\n\t\t\t\tfield<string>(serialized, \"identifier\", \"string\"),\n\t\t\t);\n\t\t}\n\t\tcase \"StorageAdapterLoadError\":\n\t\t\treturn new StorageAdapterLoadError(field<string>(serialized, \"module\", \"string\") ?? \"\", cause);\n\t\tcase \"StorageOutcomeUnknownError\":\n\t\t\treturn new StorageOutcomeUnknownError(\n\t\t\t\tfield<string>(serialized, \"domain\", \"string\") ?? \"\",\n\t\t\t\tfield<string>(serialized, \"id\", \"string\") ?? \"\",\n\t\t\t\tfield<string>(serialized, \"key\", \"string\") ?? \"\",\n\t\t\t);\n\t\tcase \"StoragePayloadTooLargeError\": {\n\t\t\tconst adapter = field<string>(serialized, \"adapter\", \"string\");\n\t\t\treturn new StoragePayloadTooLargeError(\n\t\t\t\tfield<number>(serialized, \"limitBytes\", \"number\") ?? 0,\n\t\t\t\tfield<number>(serialized, \"actualBytes\", \"number\") ?? 0,\n\t\t\t\t{\n\t\t\t\t\tkind: field<string>(serialized, \"kind\", \"string\") === \"response\" ? \"response\" : \"value\",\n\t\t\t\t\t...(adapter === undefined ? {} : { descriptor: descriptorOf(serialized) }),\n\t\t\t\t\t...(cause === undefined ? {} : { cause }),\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\treturn undefined;\n}\n\nfunction rehydrateFailure(serialized: SerializedStorageError, depth: number): Error {\n\tconst cause = nestedFailure(serialized.cause, depth);\n\tlet error = knownStorageError(serialized, cause, depth);\n\tif (error === undefined) {\n\t\terror =\n\t\t\tdepth === 0 || serialized.name.startsWith(\"Storage\")\n\t\t\t\t? new StorageError(serialized.message, { cause })\n\t\t\t\t: new Error(serialized.message, { cause });\n\t\tObject.assign(error, serialized.fields);\n\t\tObject.defineProperty(error, \"name\", { value: serialized.name });\n\t\tif (serialized.code !== undefined)\n\t\t\tObject.defineProperty(error, \"code\", { value: serialized.code, enumerable: true });\n\t\tif (serialized.hint !== undefined)\n\t\t\tObject.defineProperty(error, \"hint\", { value: serialized.hint, enumerable: true });\n\t}\n\t// The sender's message, which may hold detail no field carries (a `StorageUnavailableError`'s driver reason).\n\terror.message = serialized.message;\n\tconst cleanupCause = nestedFailure(serialized.cleanupCause, depth);\n\tif (cleanupCause !== undefined) Object.defineProperty(error, \"cleanupCause\", { value: cleanupCause });\n\treturn error;\n}\n\n/**\n * The error `serializeStorageError` produced, as the same class with the same message, fields, and causes, so guards\n * and `instanceof` still match on the other side of a process boundary. A storage error this version does not know\n * becomes a `StorageError` with the original `name`, `code`, and fields; a cause that is not a storage error becomes\n * an `Error` with its name and scalar fields (a driver's `errcode`, say). Only scalar facts travel: a\n * `StorageSchemaVersionError` whose `found` was a bigint or binary value comes back with `found: null`.\n */\nexport function rehydrateStorageError(serialized: SerializedStorageError): StorageError {\n\treturn rehydrateFailure(serialized, 0) as StorageError;\n}\n\n/** Why a team setup operation failed after its inputs were accepted. */\nexport type TeamProfileErrorCode =\n\t| \"settings-unreadable\"\n\t| \"adapter-not-installed\"\n\t| \"connection-failed\"\n\t| \"connection-timeout\"\n\t| \"auth-unavailable\"\n\t| \"token-write-failed\"\n\t| \"settings-write-failed\"\n\t| \"settings-locked\"\n\t| \"broker-restart-failed\"\n\t| \"token-delete-failed\";\n\n/** Which team input was rejected: an SDK option, a CLI argument, or an `ATOMIC_PROFILE` / `ATOMIC_TEAM_*` variable. */\nexport type TeamProfileConfigErrorCode =\n\t| \"unknown-profile\"\n\t| \"incomplete-profile\"\n\t| \"missing-url\"\n\t| \"unsupported-url\"\n\t| \"relative-file-url\"\n\t| \"credential-in-url\"\n\t| \"missing-token\"\n\t| \"conflicting-token\"\n\t| \"unreadable-token-file\"\n\t| \"relative-token-file\"\n\t| \"empty-token\"\n\t| \"unsupported-auth\"\n\t| \"unsupported-option\"\n\t| \"invalid-prefix\"\n\t| \"unknown-command\"\n\t| \"unknown-option\"\n\t| \"missing-value\"\n\t| \"unexpected-argument\";\n\nexport const TEAM_PROFILE_ERROR_CODES: ReadonlySet<TeamProfileErrorCode> = new Set<TeamProfileErrorCode>([\n\t\"settings-unreadable\",\n\t\"adapter-not-installed\",\n\t\"connection-failed\",\n\t\"connection-timeout\",\n\t\"auth-unavailable\",\n\t\"token-write-failed\",\n\t\"settings-write-failed\",\n\t\"settings-locked\",\n\t\"broker-restart-failed\",\n\t\"token-delete-failed\",\n]);\n\nexport const TEAM_PROFILE_CONFIG_ERROR_CODES: ReadonlySet<TeamProfileConfigErrorCode> =\n\tnew Set<TeamProfileConfigErrorCode>([\n\t\t\"unknown-profile\",\n\t\t\"incomplete-profile\",\n\t\t\"missing-url\",\n\t\t\"unsupported-url\",\n\t\t\"relative-file-url\",\n\t\t\"credential-in-url\",\n\t\t\"missing-token\",\n\t\t\"conflicting-token\",\n\t\t\"unreadable-token-file\",\n\t\t\"relative-token-file\",\n\t\t\"empty-token\",\n\t\t\"unsupported-auth\",\n\t\t\"unsupported-option\",\n\t\t\"invalid-prefix\",\n\t\t\"unknown-command\",\n\t\t\"unknown-option\",\n\t\t\"missing-value\",\n\t\t\"unexpected-argument\",\n\t]);\n\nconst USAGE_CODES: ReadonlySet<TeamProfileConfigErrorCode> = new Set<TeamProfileConfigErrorCode>([\n\t\"unknown-command\",\n\t\"unknown-option\",\n\t\"missing-value\",\n\t\"unexpected-argument\",\n]);\n\nconst RETRYABLE_CODES: ReadonlySet<TeamProfileErrorCode> = new Set<TeamProfileErrorCode>([\n\t\"connection-failed\",\n\t\"connection-timeout\",\n\t\"settings-locked\",\n\t\"broker-restart-failed\",\n]);\n\nconst SUMMARIES: Readonly<Record<TeamProfileErrorCode, string>> = {\n\t\"settings-unreadable\": \"Cannot update the global settings\",\n\t\"adapter-not-installed\": \"The storage adapter is not installed\",\n\t\"connection-failed\": \"Could not connect to the shared database\",\n\t\"connection-timeout\": \"The shared database did not answer in time\",\n\t\"auth-unavailable\": \"Could not sign in to the shared database\",\n\t\"token-write-failed\": \"Could not store the database token\",\n\t\"settings-write-failed\": \"Could not write the global settings\",\n\t\"settings-locked\": \"Another process is writing the settings\",\n\t\"broker-restart-failed\": \"Could not restart the Intercom broker\",\n\t\"token-delete-failed\": \"Could not delete the token file\",\n};\n\n/** The facts a {@link TeamProfileError} carries; every field is JSON-safe and holds no credential. */\nexport interface TeamProfileErrorFields {\n\t/** What the failure is about: the settings file, the adapter, the database URL, the token file or the agent directory. */\n\treadonly subject: string;\n\treadonly hint: string;\n\t/** A short, credential-free description of the cause. */\n\treadonly detail?: string;\n\treadonly cause?: Error;\n}\n\n/**\n * The family of team setup failures (`joinTeam`, `leaveTeam`, `getTeamProfile`, `atomic storage join`,\n * `atomic team`) after the inputs were accepted. Branch on `code`, never on the message.\n */\nexport class TeamProfileError extends StorageError {\n\toverride readonly name: \"TeamProfileError\" | \"TeamProfileTimeoutError\" = \"TeamProfileError\";\n\treadonly code: TeamProfileErrorCode;\n\treadonly subject: string;\n\treadonly hint: string;\n\tdeclare readonly detail?: string;\n\t/** Whether the same call can succeed later without a change on the caller's side. */\n\treadonly retryable: boolean;\n\n\tconstructor(code: TeamProfileErrorCode, fields: TeamProfileErrorFields) {\n\t\tsuper(\n\t\t\t`${SUMMARIES[code]}: ${fields.subject} (${code})${fields.detail === undefined ? \"\" : `: ${fields.detail}`}. ${fields.hint}`,\n\t\t\tfields.cause === undefined ? undefined : { cause: fields.cause },\n\t\t);\n\t\tthis.code = code;\n\t\tthis.subject = fields.subject;\n\t\tthis.hint = fields.hint;\n\t\tif (fields.detail !== undefined) this.detail = fields.detail;\n\t\tthis.retryable = RETRYABLE_CODES.has(code);\n\t}\n}\n\n/** What a team operation was doing when it ran out of time. */\nexport type TeamProfileTimeoutPhase = \"connect\";\n\n/** A team operation that did not finish in time (`code` `connection-timeout`); retryable. */\nexport class TeamProfileTimeoutError extends TeamProfileError {\n\toverride readonly name = \"TeamProfileTimeoutError\" as const;\n\treadonly timeoutMs: number;\n\treadonly elapsedMs: number;\n\treadonly phase: TeamProfileTimeoutPhase;\n\n\tconstructor(\n\t\tfields: Omit<TeamProfileErrorFields, \"detail\" | \"cause\"> & {\n\t\t\treadonly timeoutMs: number;\n\t\t\treadonly elapsedMs: number;\n\t\t\treadonly phase: TeamProfileTimeoutPhase;\n\t\t},\n\t) {\n\t\tsuper(\"connection-timeout\", {\n\t\t\tsubject: fields.subject,\n\t\t\thint: fields.hint,\n\t\t\tdetail: `no answer within ${fields.timeoutMs} ms (${fields.phase})`,\n\t\t});\n\t\tthis.timeoutMs = fields.timeoutMs;\n\t\tthis.elapsedMs = fields.elapsedMs;\n\t\tthis.phase = fields.phase;\n\t}\n}\n\nexport interface TeamProfileConfigErrorFields {\n\treadonly source: \"sdk\" | \"cli\" | \"env\";\n\t/** The option, argument or variable, for example `tokenFile`, `--token-file` or `ATOMIC_TEAM_URL`. */\n\treadonly field: string;\n\treadonly hint: string;\n\t/** The token file the input names, when the failure is about that file. */\n\treadonly path?: string;\n\t/** `incomplete-profile`: every variable that still has to be set, all reported at once. */\n\treadonly missing?: readonly string[];\n\treadonly cause?: Error;\n}\n\n/**\n * An invalid team input. It is a {@link StorageConfigError} whose `reason` equals `code`, so hosts that already\n * handle invalid `ATOMIC_STORAGE` values handle an invalid `ATOMIC_PROFILE=ci` setup the same way.\n */\nexport class TeamProfileConfigError extends StorageConfigError {\n\toverride readonly name = \"TeamProfileConfigError\" as const;\n\tdeclare readonly source: \"sdk\" | \"cli\" | \"env\";\n\treadonly code: TeamProfileConfigErrorCode;\n\treadonly hint: string;\n\tdeclare readonly path?: string;\n\tdeclare readonly missing?: readonly string[];\n\treadonly retryable = false;\n\n\tconstructor(code: TeamProfileConfigErrorCode, fields: TeamProfileConfigErrorFields) {\n\t\tsuper(fields.source, fields.field, code);\n\t\tthis.message = `${USAGE_CODES.has(code) ? \"Invalid team command\" : \"Invalid storage configuration\"}: ${fields.field} (${code}). ${fields.hint}`;\n\t\tif (fields.cause !== undefined) {\n\t\t\tObject.defineProperty(this, \"cause\", { value: fields.cause, configurable: true, writable: true });\n\t\t}\n\t\tthis.code = code;\n\t\tthis.hint = fields.hint;\n\t\tif (fields.path !== undefined) this.path = fields.path;\n\t\tif (fields.missing !== undefined) this.missing = [...fields.missing];\n\t}\n}\n\nfunction hasNameAndCodeIn(value: unknown, name: string, codes: ReadonlySet<string>): boolean {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tconst candidate = value as { readonly name?: unknown; readonly code?: unknown };\n\treturn candidate.name === name && typeof candidate.code === \"string\" && codes.has(candidate.code);\n}\n\n/** Whether `error` is a {@link TeamProfileError}, also across realms and processes (by `name` and `code`). */\nexport function isTeamProfileError(error: unknown): error is TeamProfileError {\n\treturn (\n\t\terror instanceof TeamProfileError ||\n\t\thasNameAndCodeIn(error, \"TeamProfileError\", TEAM_PROFILE_ERROR_CODES) ||\n\t\tisTeamProfileTimeoutError(error)\n\t);\n}\n\n/** Whether `error` is a {@link TeamProfileTimeoutError}, also across realms and processes (by `name` and `code`). */\nexport function isTeamProfileTimeoutError(error: unknown): error is TeamProfileTimeoutError {\n\treturn (\n\t\terror instanceof TeamProfileTimeoutError ||\n\t\thasNameAndCodeIn(error, \"TeamProfileTimeoutError\", new Set([\"connection-timeout\"]))\n\t);\n}\n\n/** Whether `error` is a {@link TeamProfileConfigError}, also across realms and processes (by `name` and `code`). */\nexport function isTeamProfileConfigError(error: unknown): error is TeamProfileConfigError {\n\treturn (\n\t\terror instanceof TeamProfileConfigError ||\n\t\thasNameAndCodeIn(error, \"TeamProfileConfigError\", TEAM_PROFILE_CONFIG_ERROR_CODES)\n\t);\n}\n\n/** Whether `error` or one of its causes, up to eight levels deep, is a retryable {@link TeamProfileError}. */\nexport function isRetryableTeamProfileError(error: unknown): boolean {\n\tlet current = error;\n\tfor (let depth = 0; depth < MAX_CAUSE_DEPTH && current !== undefined && current !== null; depth++) {\n\t\tif (isTeamProfileError(current) && current.retryable) return true;\n\t\tcurrent = current instanceof Error ? current.cause : undefined;\n\t}\n\treturn false;\n}\n\n/**\n * A cause of a serialized team error, at most eight deep. A team error cause, also one from another realm, is\n * serialized like the error itself when its `message`, `hint`, `retryable` and its class's fields all have their\n * documented types, so it rehydrates as its own class and keeps its `retryable`. Its message names files and\n * settings but never their content or a token. Any other cause keeps only its `name` and `code`, and its `message`\n * is that code, or else its name: a parser, driver or file-system message can quote the settings file or the\n * server's answer, so it never crosses a process boundary.\n */\nexport interface SerializedTeamErrorCause {\n\treadonly name: string;\n\treadonly message: string;\n\treadonly code?: string;\n\treadonly hint?: string;\n\treadonly fields?: SerializedTeamError[\"fields\"];\n\treadonly cause?: SerializedTeamErrorCause;\n}\n\n/** A {@link TeamProfileError} or {@link TeamProfileConfigError} as JSON, to cross a worker, coordinator or broker boundary. */\nexport interface SerializedTeamError {\n\treadonly name: string;\n\treadonly code: string;\n\treadonly message: string;\n\treadonly hint: string;\n\t/** The error's own facts: `subject`, `detail`, `timeoutMs`, `elapsedMs`, `phase`, `source`, `field`, `path`, `missing`, `retryable`. */\n\treadonly fields: Readonly<Record<string, string | number | boolean | readonly string[]>>;\n\treadonly cause?: SerializedTeamErrorCause;\n}\n\nconst SAFE_IDENTIFIER = /^[A-Za-z][A-Za-z0-9_.-]{0,63}$/;\n\nfunction safeIdentifier(value: unknown): string | undefined {\n\treturn typeof value === \"string\" && SAFE_IDENTIFIER.test(value) ? value : undefined;\n}\n\nfunction isText(value: unknown): value is string {\n\treturn typeof value === \"string\";\n}\n\nfunction canSerializeTeamCause(cause: unknown): cause is TeamProfileError | TeamProfileConfigError {\n\tif (!isTeamProfileError(cause) && !isTeamProfileConfigError(cause)) return false;\n\tconst team = cause as unknown as Readonly<Record<string, unknown>>;\n\tif (!isText(team.message) || !isText(team.hint) || typeof team.retryable !== \"boolean\") return false;\n\tif (isTeamProfileConfigError(cause)) {\n\t\treturn (\n\t\t\tisText(team.source) &&\n\t\t\tisText(team.field) &&\n\t\t\t(team.path === undefined || isText(team.path)) &&\n\t\t\t(team.missing === undefined || (Array.isArray(team.missing) && team.missing.every(isText)))\n\t\t);\n\t}\n\tif (!isText(team.subject) || (team.detail !== undefined && !isText(team.detail))) return false;\n\treturn (\n\t\t!isTeamProfileTimeoutError(cause) ||\n\t\t(typeof team.timeoutMs === \"number\" && typeof team.elapsedMs === \"number\" && isText(team.phase))\n\t);\n}\n\nfunction serializeTeamErrorCause(cause: unknown, depth: number): SerializedTeamErrorCause | undefined {\n\tif (depth >= MAX_CAUSE_DEPTH || cause === undefined || cause === null) return undefined;\n\tif (canSerializeTeamCause(cause)) return serializeTeam(cause, depth + 1);\n\tconst error = cause instanceof Error ? cause : undefined;\n\tconst name = safeIdentifier(error?.name) ?? \"Error\";\n\tconst code = safeIdentifier(typeof cause === \"object\" ? (cause as { readonly code?: unknown }).code : undefined);\n\tconst next = serializeTeamErrorCause(error?.cause, depth + 1);\n\treturn {\n\t\tname,\n\t\tmessage: code ?? name,\n\t\t...(code === undefined ? {} : { code }),\n\t\t...(next === undefined ? {} : { cause: next }),\n\t};\n}\n\nfunction rehydrateTeamErrorCause(cause: SerializedTeamErrorCause | undefined, depth: number): Error | undefined {\n\tif (depth >= MAX_CAUSE_DEPTH || cause === undefined) return undefined;\n\tconst { code, hint, fields } = cause;\n\tif (typeof code === \"string\" && typeof hint === \"string\" && typeof fields === \"object\" && fields !== null) {\n\t\treturn rehydrateTeam({ ...cause, code, hint, fields }, depth + 1);\n\t}\n\tconst inner = rehydrateTeamErrorCause(cause.cause, depth + 1);\n\tconst error = new Error(cause.message, inner === undefined ? undefined : { cause: inner });\n\terror.name = cause.name;\n\tif (code !== undefined) Object.assign(error, { code });\n\treturn error;\n}\n\nfunction serializeTeam(error: TeamProfileError | TeamProfileConfigError, causeDepth: number): SerializedTeamError {\n\tconst fields: Record<string, string | number | boolean | readonly string[]> = { retryable: error.retryable };\n\tif (isTeamProfileConfigError(error)) {\n\t\tfields.source = error.source;\n\t\tfields.field = error.field;\n\t\tif (error.path !== undefined) fields.path = error.path;\n\t\tif (error.missing !== undefined) fields.missing = [...error.missing];\n\t} else {\n\t\tfields.subject = error.subject;\n\t\tif (error.detail !== undefined) fields.detail = error.detail;\n\t\tif (isTeamProfileTimeoutError(error)) {\n\t\t\tfields.timeoutMs = error.timeoutMs;\n\t\t\tfields.elapsedMs = error.elapsedMs;\n\t\t\tfields.phase = error.phase;\n\t\t}\n\t}\n\tconst cause = serializeTeamErrorCause(error.cause, causeDepth);\n\treturn {\n\t\tname: error.name,\n\t\tcode: error.code,\n\t\tmessage: error.message,\n\t\thint: error.hint,\n\t\tfields,\n\t\t...(cause === undefined ? {} : { cause }),\n\t};\n}\n\n/** The JSON form of a team error, with its cause chain bounded to eight levels; it holds no token. */\nexport function serializeTeamError(error: TeamProfileError | TeamProfileConfigError): SerializedTeamError {\n\treturn serializeTeam(error, 0);\n}\n\nfunction rehydrateTeam(serialized: SerializedTeamError, causeDepth: number): TeamProfileError | TeamProfileConfigError {\n\tconst { fields } = serialized;\n\tconst text = (key: string): string | undefined =>\n\t\ttypeof fields[key] === \"string\" ? (fields[key] as string) : undefined;\n\tconst count = (key: string): number => (typeof fields[key] === \"number\" ? (fields[key] as number) : 0);\n\tconst cause = rehydrateTeamErrorCause(serialized.cause, causeDepth);\n\tlet error: TeamProfileError | TeamProfileConfigError;\n\tif (serialized.name === \"TeamProfileConfigError\") {\n\t\tconst missing = Array.isArray(fields.missing) ? fields.missing : undefined;\n\t\terror = new TeamProfileConfigError(serialized.code as TeamProfileConfigErrorCode, {\n\t\t\tsource: text(\"source\") as TeamProfileConfigErrorFields[\"source\"],\n\t\t\tfield: text(\"field\") ?? \"\",\n\t\t\thint: serialized.hint,\n\t\t\t...(text(\"path\") === undefined ? {} : { path: text(\"path\") }),\n\t\t\t...(missing === undefined ? {} : { missing }),\n\t\t\t...(cause === undefined ? {} : { cause }),\n\t\t});\n\t} else if (serialized.name === \"TeamProfileTimeoutError\") {\n\t\terror = new TeamProfileTimeoutError({\n\t\t\tsubject: text(\"subject\") ?? \"\",\n\t\t\thint: serialized.hint,\n\t\t\ttimeoutMs: count(\"timeoutMs\"),\n\t\t\telapsedMs: count(\"elapsedMs\"),\n\t\t\tphase: (text(\"phase\") ?? \"connect\") as TeamProfileTimeoutPhase,\n\t\t});\n\t\tif (cause !== undefined)\n\t\t\tObject.defineProperty(error, \"cause\", { value: cause, configurable: true, writable: true });\n\t} else {\n\t\terror = new TeamProfileError(serialized.code as TeamProfileErrorCode, {\n\t\t\tsubject: text(\"subject\") ?? \"\",\n\t\t\thint: serialized.hint,\n\t\t\t...(text(\"detail\") === undefined ? {} : { detail: text(\"detail\") }),\n\t\t\t...(cause === undefined ? {} : { cause }),\n\t\t});\n\t\tif (serialized.name !== error.name) Object.defineProperty(error, \"name\", { value: serialized.name });\n\t}\n\tObject.defineProperty(error, \"message\", { value: serialized.message, configurable: true, writable: true });\n\tif (typeof fields.retryable === \"boolean\" && fields.retryable !== error.retryable) {\n\t\tObject.defineProperty(error, \"retryable\", { value: fields.retryable });\n\t}\n\treturn error;\n}\n\n/**\n * The team error a {@link serializeTeamError} result describes, as an instance of its class, so `instanceof`, the\n * guards and `isRetryableTeamProfileError` work on the receiving side. An unknown name becomes a\n * {@link TeamProfileError} that keeps the original `name`, `code` and `retryable`.\n */\nexport function rehydrateTeamError(serialized: SerializedTeamError): TeamProfileError | TeamProfileConfigError {\n\treturn rehydrateTeam(serialized, 0);\n}\n\n/** A cause as it crosses a process boundary: its name, message and code, never its stack. */\nexport interface SerializedJournalStoreCause {\n\treadonly name: string;\n\treadonly message: string;\n\treadonly code?: string;\n\treadonly cause?: SerializedJournalStoreCause;\n}\n\nexport interface SerializedJournalStoreError {\n\treadonly name: string;\n\treadonly code: string;\n\treadonly message: string;\n\treadonly hint?: string;\n\treadonly retryable: boolean;\n\treadonly fields: JournalStoreFields;\n\treadonly cause?: SerializedJournalStoreCause;\n}\n\nfunction serializeCause(cause: unknown, depth: number): SerializedJournalStoreCause | undefined {\n\tif (depth >= MAX_CAUSE_DEPTH || cause === undefined || cause === null) return undefined;\n\tif (!(cause instanceof Error)) return { name: \"Error\", message: String(cause) };\n\tconst code = (cause as { code?: unknown }).code;\n\tconst nested = serializeCause(cause.cause, depth + 1);\n\treturn {\n\t\tname: cause.name,\n\t\tmessage: cause.message,\n\t\t...(typeof code === \"string\" ? { code } : {}),\n\t\t...(nested === undefined ? {} : { cause: nested }),\n\t};\n}\n\n/** The plain form of a journal store error, for a worker, coordinator or broker message. */\nexport function serializeJournalStoreError(error: JournalStoreError): SerializedJournalStoreError {\n\tconst cause = serializeCause(error.cause, 0);\n\treturn {\n\t\tname: error.name,\n\t\tcode: error.code,\n\t\tmessage: error.message,\n\t\t...(error.hint === undefined ? {} : { hint: error.hint }),\n\t\tretryable: error.retryable,\n\t\tfields: { ...error.fields },\n\t\t...(cause === undefined ? {} : { cause }),\n\t};\n}\n\nfunction rehydrateCause(cause: SerializedJournalStoreCause | undefined): Error | undefined {\n\tif (cause === undefined) return undefined;\n\tconst nested = rehydrateCause(cause.cause);\n\tconst error = new Error(cause.message, nested === undefined ? undefined : { cause: nested });\n\terror.name = cause.name;\n\tif (cause.code !== undefined) Object.defineProperty(error, \"code\", { value: cause.code, enumerable: true });\n\treturn error;\n}\n\nfunction text(fields: JournalStoreFields, key: string): string | undefined {\n\tconst value = fields[key];\n\treturn typeof value === \"string\" ? value : undefined;\n}\n\nfunction numeric(fields: JournalStoreFields, key: string): number | undefined {\n\tconst value = fields[key];\n\treturn typeof value === \"number\" ? value : undefined;\n}\n\nfunction versionField(fields: JournalStoreFields): string | number | null | undefined {\n\tconst value = fields.found;\n\treturn typeof value === \"boolean\" ? undefined : value;\n}\n\n/** Rebuilds the error a process serialized; a name this Atomic does not know becomes the family base, name and code kept. */\nexport function rehydrateJournalStoreError(serialized: SerializedJournalStoreError): JournalStoreError {\n\tconst error = rebuild(serialized);\n\t// The message was built from the same fields; keep the sender's text exactly, whatever its cause looked like here.\n\terror.message = serialized.message;\n\treturn error;\n}\n\nfunction rebuild(serialized: SerializedJournalStoreError): JournalStoreError {\n\tconst { fields } = serialized;\n\tconst cause = rehydrateCause(serialized.cause);\n\tif (hasCode(serialized, \"JournalCatalogError\", JOURNAL_CATALOG_ERROR_CODES))\n\t\treturn new JournalCatalogError({\n\t\t\tcode: serialized.code as JournalCatalogErrorCode,\n\t\t\tcatalogPath: text(fields, \"catalogPath\") ?? \"\",\n\t\t\tphase: text(fields, \"phase\") as JournalCatalogPhase | undefined,\n\t\t\trunId: text(fields, \"runId\"),\n\t\t\tshardId: numeric(fields, \"shardId\"),\n\t\t\tshardPath: text(fields, \"shardPath\"),\n\t\t\tfound: versionField(fields),\n\t\t\tsupported: numeric(fields, \"supported\"),\n\t\t\trule: text(fields, \"rule\"),\n\t\t\tselection: text(fields, \"selection\"),\n\t\t\tlocalOnly: typeof fields.localOnly === \"boolean\" ? fields.localOnly : undefined,\n\t\t\tlastSeq: numeric(fields, \"lastSeq\"),\n\t\t\tretryable: serialized.retryable,\n\t\t\tcause,\n\t\t});\n\tif (hasCode(serialized, \"JournalShardUnavailableError\", JOURNAL_SHARD_UNAVAILABLE_ERROR_CODES))\n\t\treturn new JournalShardUnavailableError({\n\t\t\tcode: serialized.code as JournalShardUnavailableErrorCode,\n\t\t\tshardId: numeric(fields, \"shardId\") ?? -1,\n\t\t\tshardPath: text(fields, \"shardPath\") ?? \"\",\n\t\t\trunId: text(fields, \"runId\"),\n\t\t\tretryable: serialized.retryable,\n\t\t\tcause,\n\t\t});\n\tif (hasCode(serialized, \"JournalAdoptError\", JOURNAL_ADOPT_ERROR_CODES))\n\t\treturn new JournalAdoptError({\n\t\t\tcode: serialized.code as JournalAdoptErrorCode,\n\t\t\tpath: text(fields, \"path\") ?? \"\",\n\t\t\treason: text(fields, \"reason\") as JournalAdoptNotJournalReason | undefined,\n\t\t\trunId: text(fields, \"runId\"),\n\t\t\texistingPath: text(fields, \"existingPath\"),\n\t\t\tfound: versionField(fields),\n\t\t\tsupported: numeric(fields, \"supported\"),\n\t\t\tcause,\n\t\t});\n\treturn new JournalStoreError({\n\t\tname: serialized.name,\n\t\tcode: serialized.code,\n\t\tmessage: serialized.message,\n\t\thint: serialized.hint,\n\t\tfields,\n\t\tretryable: serialized.retryable,\n\t\tcause,\n\t});\n}\n"]}