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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/dist/builtin/intercom/CHANGELOG.md +8 -0
  3. package/dist/builtin/intercom/broker/broker-instance.ts +15 -1
  4. package/dist/builtin/intercom/broker/broker.ts +25 -8
  5. package/dist/builtin/intercom/broker/client.ts +29 -14
  6. package/dist/builtin/intercom/broker/multinode-router.ts +193 -52
  7. package/dist/builtin/intercom/broker/multinode-state-store.ts +6 -2
  8. package/dist/builtin/intercom/broker/restoring-recipients.ts +5 -0
  9. package/dist/builtin/intercom/broker/sql-outbox-store.ts +3 -2
  10. package/dist/builtin/intercom/index.bundle.mjs +19 -12
  11. package/dist/builtin/intercom/package.json +1 -1
  12. package/dist/builtin/intercom/types.ts +6 -2
  13. package/dist/builtin/mcp/package.json +1 -1
  14. package/dist/builtin/subagents/CHANGELOG.md +6 -0
  15. package/dist/builtin/subagents/package.json +1 -1
  16. package/dist/builtin/subagents/src/extension/index.bundle.mjs +17 -6
  17. package/dist/builtin/web-access/package.json +1 -1
  18. package/dist/builtin/workflows/CHANGELOG.md +12 -0
  19. package/dist/builtin/workflows/package.json +1 -1
  20. package/dist/builtin/workflows/src/extension/index.bundle.mjs +310 -344
  21. package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +99 -17
  22. package/dist/builtin/workflows/src/index.js +99 -17
  23. package/dist/builtin/workflows/src/local-worker-entry.mjs +99 -17
  24. package/dist/cli/storage-command.js +8 -0
  25. package/dist/cli/storage-command.js.map +1 -1
  26. package/dist/core/auth-storage-backends.d.ts.map +1 -1
  27. package/dist/core/auth-storage-backends.js +1 -0
  28. package/dist/core/auth-storage-backends.js.map +1 -1
  29. package/dist/core/keybindings.d.ts +8 -0
  30. package/dist/core/keybindings.d.ts.map +1 -1
  31. package/dist/core/keybindings.js +4 -0
  32. package/dist/core/keybindings.js.map +1 -1
  33. package/dist/core/process-start-token.d.ts.map +1 -1
  34. package/dist/core/process-start-token.js +8 -1
  35. package/dist/core/process-start-token.js.map +1 -1
  36. package/dist/core/resume/blueprint/build-lock.d.ts.map +1 -1
  37. package/dist/core/resume/blueprint/build-lock.js +2 -1
  38. package/dist/core/resume/blueprint/build-lock.js.map +1 -1
  39. package/dist/core/storage/errors.d.ts +4 -2
  40. package/dist/core/storage/errors.d.ts.map +1 -1
  41. package/dist/core/storage/errors.js +6 -1
  42. package/dist/core/storage/errors.js.map +1 -1
  43. package/dist/core/tasks/completion.d.ts +5 -0
  44. package/dist/core/tasks/completion.d.ts.map +1 -1
  45. package/dist/core/tasks/completion.js +13 -0
  46. package/dist/core/tasks/completion.js.map +1 -1
  47. package/dist/core/tools/shell-task-render.d.ts +1 -2
  48. package/dist/core/tools/shell-task-render.d.ts.map +1 -1
  49. package/dist/core/tools/shell-task-render.js +3 -7
  50. package/dist/core/tools/shell-task-render.js.map +1 -1
  51. package/dist/core/tools/windows-directory-security.d.ts.map +1 -1
  52. package/dist/core/tools/windows-directory-security.js +3 -11
  53. package/dist/core/tools/windows-directory-security.js.map +1 -1
  54. package/dist/core/worktree-snapshot/capture.d.ts.map +1 -1
  55. package/dist/core/worktree-snapshot/capture.js +25 -1
  56. package/dist/core/worktree-snapshot/capture.js.map +1 -1
  57. package/dist/core/worktree-snapshot/restore.d.ts.map +1 -1
  58. package/dist/core/worktree-snapshot/restore.js +38 -9
  59. package/dist/core/worktree-snapshot/restore.js.map +1 -1
  60. package/dist/index.d.ts +2 -1
  61. package/dist/index.d.ts.map +1 -1
  62. package/dist/index.js +2 -1
  63. package/dist/index.js.map +1 -1
  64. package/dist/modes/interactive/components/agent-panel.d.ts +5 -0
  65. package/dist/modes/interactive/components/agent-panel.d.ts.map +1 -1
  66. package/dist/modes/interactive/components/agent-panel.js +13 -0
  67. package/dist/modes/interactive/components/agent-panel.js.map +1 -1
  68. package/dist/modes/interactive/components/chat-transcript.d.ts.map +1 -1
  69. package/dist/modes/interactive/components/chat-transcript.js +5 -2
  70. package/dist/modes/interactive/components/chat-transcript.js.map +1 -1
  71. package/dist/modes/interactive/components/custom-message.js +1 -1
  72. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  73. package/dist/modes/interactive/components/heartbeat-block.d.ts +34 -0
  74. package/dist/modes/interactive/components/heartbeat-block.d.ts.map +1 -0
  75. package/dist/modes/interactive/components/heartbeat-block.js +50 -0
  76. package/dist/modes/interactive/components/heartbeat-block.js.map +1 -0
  77. package/dist/modes/interactive/components/input-label.d.ts.map +1 -1
  78. package/dist/modes/interactive/components/input-label.js +8 -3
  79. package/dist/modes/interactive/components/input-label.js.map +1 -1
  80. package/dist/modes/interactive/components/main-composer-keys.d.ts.map +1 -1
  81. package/dist/modes/interactive/components/main-composer-keys.js +3 -7
  82. package/dist/modes/interactive/components/main-composer-keys.js.map +1 -1
  83. package/dist/modes/interactive/components/mermaid.d.ts.map +1 -1
  84. package/dist/modes/interactive/components/mermaid.js +13 -7
  85. package/dist/modes/interactive/components/mermaid.js.map +1 -1
  86. package/dist/modes/interactive/components/notice-line.d.ts +10 -2
  87. package/dist/modes/interactive/components/notice-line.d.ts.map +1 -1
  88. package/dist/modes/interactive/components/notice-line.js +13 -3
  89. package/dist/modes/interactive/components/notice-line.js.map +1 -1
  90. package/dist/modes/interactive/components/provider-brand.d.ts.map +1 -1
  91. package/dist/modes/interactive/components/provider-brand.js +3 -0
  92. package/dist/modes/interactive/components/provider-brand.js.map +1 -1
  93. package/dist/modes/interactive/components/task-heartbeat-message.d.ts +9 -4
  94. package/dist/modes/interactive/components/task-heartbeat-message.d.ts.map +1 -1
  95. package/dist/modes/interactive/components/task-heartbeat-message.js +33 -27
  96. package/dist/modes/interactive/components/task-heartbeat-message.js.map +1 -1
  97. package/dist/modes/interactive/components/task-inspector.d.ts +16 -0
  98. package/dist/modes/interactive/components/task-inspector.d.ts.map +1 -1
  99. package/dist/modes/interactive/components/task-inspector.js +95 -4
  100. package/dist/modes/interactive/components/task-inspector.js.map +1 -1
  101. package/dist/modes/interactive/components/task-list.d.ts +5 -1
  102. package/dist/modes/interactive/components/task-list.d.ts.map +1 -1
  103. package/dist/modes/interactive/components/task-list.js +20 -3
  104. package/dist/modes/interactive/components/task-list.js.map +1 -1
  105. package/dist/modes/interactive/components/task-transcript-page.d.ts +1 -1
  106. package/dist/modes/interactive/components/task-transcript-page.d.ts.map +1 -1
  107. package/dist/modes/interactive/components/task-transcript-page.js +10 -7
  108. package/dist/modes/interactive/components/task-transcript-page.js.map +1 -1
  109. package/dist/modes/interactive/interactive-startup.js +1 -2
  110. package/dist/modes/interactive/interactive-startup.js.map +1 -1
  111. package/dist/modes/interactive/theme/color-utils.d.ts +29 -1
  112. package/dist/modes/interactive/theme/color-utils.d.ts.map +1 -1
  113. package/dist/modes/interactive/theme/color-utils.js +81 -7
  114. package/dist/modes/interactive/theme/color-utils.js.map +1 -1
  115. package/dist/modes/interactive/theme/global-theme.d.ts.map +1 -1
  116. package/dist/modes/interactive/theme/global-theme.js +3 -0
  117. package/dist/modes/interactive/theme/global-theme.js.map +1 -1
  118. package/dist/modes/interactive/theme/theme-class.d.ts +22 -2
  119. package/dist/modes/interactive/theme/theme-class.d.ts.map +1 -1
  120. package/dist/modes/interactive/theme/theme-class.js +64 -18
  121. package/dist/modes/interactive/theme/theme-class.js.map +1 -1
  122. package/dist/modes/interactive/theme/theme.d.ts +1 -0
  123. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  124. package/dist/modes/interactive/theme/theme.js +1 -0
  125. package/dist/modes/interactive/theme/theme.js.map +1 -1
  126. package/dist/utils/clipboard-image.d.ts.map +1 -1
  127. package/dist/utils/clipboard-image.js +2 -0
  128. package/dist/utils/clipboard-image.js.map +1 -1
  129. package/dist/utils/clipboard.d.ts.map +1 -1
  130. package/dist/utils/clipboard.js +2 -1
  131. package/dist/utils/clipboard.js.map +1 -1
  132. package/dist/utils/tools-manager.d.ts +6 -0
  133. package/dist/utils/tools-manager.d.ts.map +1 -1
  134. package/dist/utils/tools-manager.js +170 -15
  135. package/dist/utils/tools-manager.js.map +1 -1
  136. package/dist/utils/windows-powershell.d.ts +9 -0
  137. package/dist/utils/windows-powershell.d.ts.map +1 -0
  138. package/dist/utils/windows-powershell.js +16 -0
  139. package/dist/utils/windows-powershell.js.map +1 -0
  140. package/docs/background-tasks.md +6 -6
  141. package/docs/getting-started/installation.md +4 -2
  142. package/docs/keybindings.md +3 -0
  143. package/docs/storage.md +24 -5
  144. package/docs/subagents.md +1 -1
  145. package/docs/themes/reference.md +7 -0
  146. package/docs/tui/reference.md +1 -1
  147. package/docs/windows.md +1 -1
  148. package/docs/workflows/api-reference.md +9 -1
  149. package/docs/workflows/operations.md +1 -1
  150. package/npm-shrinkwrap.json +49 -49
  151. package/package.json +6 -6
  152. package/schemas/keybindings.schema.json +4 -0
@@ -1 +1 @@
1
- {"version":3,"file":"storage-command.js","sourceRoot":"","sources":["../../src/cli/storage-command.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AAEzE,OAAO,EAAE,mBAAmB,EAAE,gCAAgC,EAAE,MAAM,4BAA4B,CAAC;AACnG,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,4BAA4B,EAAE,MAAM,iCAAiC,CAAC;AAE/E,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,mBAA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Q,KAAK,SAAS,EAAE,CAAC;YACnC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAC;YACtD,GAAG,CACF,YAAY,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,SAAS,yBAAyB,CAAC,SAAS,CAAC,KAAK,KAAK,CAAC,MAAM,WAAW,OAAO,CAAC,MAAM,aAAa,SAAS,CAAC,MAAM,uBAAuB,CAC1N,CAAC;QACH,CAAC;QACD,IAAI,MAAM,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;YACpC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC,SAAS,CAAC;YACvD,GAAG,CACF,YAAY,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,cAAc,CAAC,SAAS,0BAA0B,CAAC,SAAS,CAAC,KAAK,KAAK,CAAC,MAAM,WAAW,OAAO,CAAC,MAAM,aAAa,SAAS,CAAC,MAAM,uBAAuB,CAChO,CAAC;QACH,CAAC;QACD,OAAO,CAAC,CAAC;IACV,CAAC;YAAS,CAAC;QACV,MAAM,YAAY,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,CAAC;IACvC,CAAC;AACF,CAAC;AAED,SAAS,YAAY,CAAC,QAAwD;IAC7E,OAAO,QAAQ,KAAK,SAAS,IAAI,QAAQ,IAAI,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AACrF,CAAC","sourcesContent":["/**\n * `atomic storage status` shows which storage each domain (sessions, workflow runs, Intercom) selects, where the\n * selection comes from, whether its adapter loads and its database answers, and what the running Intercom broker\n * uses. `atomic storage join` points this machine's global `storage` setting at a shared libSQL / Turso or\n * PostgreSQL database.\n * `atomic storage adopt` registers existing journal files in the journal store in place, and `atomic storage\n * consolidate` moves their finished runs into the store's own shards. `atomic storage export` and `atomic storage\n * import` move sessions and workflow runs between their storage and JSONL files (#4716, #4720).\n */\n\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { APP_NAME } from \"../config.js\";\nimport { getBuiltinPackageLocations } from \"../core/builtin-packages.ts\";\nimport type { IntercomBrokerControl } from \"../core/intercom-broker-control.js\";\nimport { resolveSessionStore, selectSessionStorageWithSettings } from \"../core/session-storage.js\";\nimport { exportSessions } from \"../core/session-transfer.ts\";\nimport { SettingsManager } from \"../core/settings-manager.ts\";\nimport { openAdapterSelectionDatabase } from \"../core/storage/adapter-open.js\";\nimport type { SqliteDatabase, SqliteRow } from \"../core/storage/database.js\";\nimport { dialectOf } from \"../core/storage/dialect.js\";\nimport { isJournalStoreError, isTeamProfileConfigError, isTeamProfileError } from \"../core/storage/errors.js\";\nimport {\n\tadoptJournals,\n\tconsolidateJournalStore,\n\tdefaultJournalStoreDirectory,\n} from \"../core/storage/journal-adoption.js\";\nimport {\n\texportWorkflowRuns,\n\tWORKFLOW_RUN_EXPORT_VERSION,\n\ttype WorkflowRunTransferStorage,\n} from \"../core/storage/journal-transfer.js\";\nimport {\n\tmovePostgresStorageToSchema,\n\tPOSTGRES_ATOMIC_SCHEMA,\n\tstrayPostgresStorageTables,\n} from \"../core/storage/postgres-schema.js\";\nimport { StorageProvider, type StorageSelection } from \"../core/storage/provider.js\";\nimport {\n\tcheckSharedDatabaseArguments,\n\tisFileUrl,\n\tisPostgresUrl,\n\tLIBSQL_ADAPTER_PACKAGE,\n\tmissingTeamToken,\n\tPOSTGRES_ADAPTER_PACKAGE,\n\ttype PostgresAuth,\n\tSTORAGE_TOKEN_FILE,\n\ttype StorageSettingsSelection,\n\tselectStorage,\n} from \"../core/storage/selection.js\";\nimport type { SessionStore } from \"../core/storage/session/types.js\";\nimport { SESSION_FORMAT_VERSION } from \"../core/storage/session/types.js\";\nimport {\n\tcollectStorageStatus,\n\ttype DomainStatus,\n\tdescribeStorageError,\n\tdescribeStorageSelection,\n\teffectiveJournalSelection,\n\tprojectTrust,\n\ttype StorageStatus,\n} from \"../core/storage/storage-status.js\";\nimport { joinSharedDatabase } from \"../core/storage/team.js\";\nimport {\n\tisStorageImportIncompleteError,\n\tisStorageTransferError,\n\ttype TransferredIds,\n} from \"../core/storage/transfer-files.js\";\nimport { importStorage, sessionsTransferDirectory, workflowsTransferDirectory } from \"../core/storage-transfer.ts\";\nimport {\n\tloadWorkerHostModule,\n\ttype WorkerDatabase,\n\ttype WorkerHostModule,\n\tworkerJournalSelection,\n} from \"./worker-command.js\";\n\nexport { LIBSQL_ADAPTER_PACKAGE, STORAGE_TOKEN_FILE };\n\nconst JOIN_USAGE = `${APP_NAME} storage join <url> [--token-file <path> | --password-file <path> | --auth azure|aws|gcp]\n [--prefix <prefix>]`;\n\nconst MIGRATE_USAGE = `${APP_NAME} storage migrate [--db <url> [--password-file <path> | --token-file <path> | --auth azure|aws|gcp]]\n [--prefix <prefix>]`;\n\nconst HELP = `Usage:\n ${APP_NAME} storage status [--json]\n ${JOIN_USAGE}\n ${MIGRATE_USAGE}\n ${APP_NAME} storage adopt <path>... [--no-discover]\n ${APP_NAME} storage consolidate\n ${APP_NAME} storage export <dir> [--sessions] [--workflows] [--run <id>]... [--unfinished]\n [--limit <n>] [--since <time>] [--storage <json> | --storage-file <path>]\n ${APP_NAME} storage import <dir> [--sessions] [--workflows] [--storage <json> | --storage-file <path>]\n\nCommands:\n status Show, for sessions, workflow runs, and Intercom, the selected storage and where the\n selection comes from (environment variable, project or global settings, or default),\n whether its adapter loads, whether its database answers a SELECT 1, and what the running\n Intercom broker uses. Exits 1 when a selection is invalid, an adapter cannot load, or a\n database does not answer. Nothing is created or changed.\n join Use a shared database on this machine: a libSQL / Turso database (libsql://, https://,\n wss:// or file:) through ${LIBSQL_ADAPTER_PACKAGE}, or a PostgreSQL database\n (postgres:// or postgresql://) through ${POSTGRES_ADAPTER_PACKAGE}. Checks the credential\n and the connection (SELECT 1, within 15 seconds), then writes only the global \\`storage\\`\n setting; nothing is written when a check fails. A token or --password-file is stored in\n the agent directory (mode 600); --token-file is referenced where it is, and read again\n for every new connection. Settings hold a file reference, never a password or token.\n Reports environment variables and settings that override it. Creates no tables; Atomic\n creates them on first use.\n migrate Create or upgrade Atomic's tables in a shared database (the journal this machine selects, or\n --db): sessions, workflow runs, worker pools and Intercom. Run it as the database's owner role\n after joining and after each Atomic upgrade, so worker hosts and roots that connect with a\n runtime role (DML privileges only) run no DDL. On PostgreSQL the tables live in schema atomic;\n tables an earlier release created in public are moved there, and processes of that release\n still using public are refused. Running it again on a current schema changes nothing.\n adopt Register existing workflow journal files in the journal store in place, without copying,\n so their runs resolve by ID for status, resume, attach, fork and history://. Each <path>\n is a journal .sqlite file or a directory holding journal.sqlite. Every path is checked\n before the first is registered. Journals the adopted runs were written to are adopted\n too unless --no-discover is given.\n consolidate\n Move finished runs (completed, failed or cancelled, not leased, without local workers)\n from adopted journals into the journal store's own shards. Other runs stay where they\n are. An interrupted consolidation leaves every run readable; run it again to finish.\n export Write sessions to <dir>/sessions/<sessionId>.jsonl (session format version\n ${SESSION_FORMAT_VERSION}, the format \\`${APP_NAME} --import\\` reads) and workflow runs to\n <dir>/workflows/<runId>.jsonl (workflow run export version ${WORKFLOW_RUN_EXPORT_VERSION}), one file per\n session or run. Both kinds by default; --sessions or --workflows limits it to one. Each\n file is replaced whole, one that already holds the same bytes is not rewritten, and no\n file is deleted. A kind kept in a shared libSQL / Turso or PostgreSQL database is skipped\n (an error when --sessions or --workflows asks for it): every machine joined to it reads it\n already. Name the database with --storage or --storage-file to export from it anyway.\n import Restore the sessions in <dir>/sessions and the workflow runs in <dir>/workflows into\n this directory's storage, or the one --storage or --storage-file names; other files are\n ignored. Every file of both kinds is checked\n first, so a malformed or unsupported file changes nothing. Importing again adds\n nothing; a newer export of a session or run adds its later entries. Imported runs are\n not owned by any process: an interrupted one can be resumed here. If the import fails\n after writing part of it, it names what was and was not written; run it again to finish.\n\nOptions:\n --json Print the status as JSON\n --token-file <path> libSQL: file holding the database token, for example from \\`turso db tokens create\\`;\n surrounding whitespace is removed. Required except for file: URLs.\n PostgreSQL: a password or token file another process keeps fresh (a Vault agent,\n a workload-identity sidecar); its path is saved and it is read for every new connection\n --password-file <path>\n PostgreSQL: file holding the database password; it is copied to the agent directory\n (mode 600)\n --auth azure|aws|gcp PostgreSQL: use the platform's identity (Microsoft Entra ID, AWS IAM, Google Cloud\n IAM) instead of a password\n PostgreSQL URLs take exactly one of --password-file, --token-file and --auth, and\n never a password in the URL\n --prefix <prefix> Table prefix, to share one database between projects or teams\n --no-discover adopt: register only the given paths\n --sessions export, import: sessions only (with --workflows too: both)\n --workflows export, import: workflow runs only (with --sessions too: both)\n --run <id> export: only this workflow run; repeat for more\n --unfinished export: only workflow runs that are not completed, failed or cancelled\n --limit <n> export: at most n workflow runs, newest first, and at most n sessions,\n most recently modified first\n --since <time> export: only sessions modified at or after <time>, a date such as\n 2026-11-01 or a date and time such as 2026-11-01T09:30:00Z\n --storage <json> export, import: read from or write to this storage instead of the one selected\n here, given in the form of the \\`storage\\` setting, for example\n {\"path\":\"/path/to/journal.sqlite\"} or an adapter with its options and secrets.\n A shared database named this way is exported from and imported into: use it to\n move runs and sessions between stores\n --storage-file <path> export, import: as --storage, from a JSON file, for example the \\`storage\\`\n value of another machine's settings`;\n\nconst HELP_HINT = `Use \"${APP_NAME} storage --help\" for usage.`;\n\nexport type StorageCommand =\n\t| { readonly kind: \"help\" }\n\t| { readonly kind: \"status\"; readonly json: boolean }\n\t| {\n\t\t\treadonly kind: \"join\";\n\t\t\treadonly url: string;\n\t\t\treadonly tokenFile?: string;\n\t\t\t/** Postgres only. */\n\t\t\treadonly passwordFile?: string;\n\t\t\t/** Postgres only. */\n\t\t\treadonly auth?: PostgresAuth;\n\t\t\treadonly prefix?: string;\n\t }\n\t| {\n\t\t\treadonly kind: \"migrate\";\n\t\t\t/** `--db` and its credential; the journal this machine selects without it. */\n\t\t\treadonly database?: WorkerDatabase;\n\t }\n\t| { readonly kind: \"adopt\"; readonly paths: readonly string[]; readonly discover: boolean }\n\t| { readonly kind: \"consolidate\" }\n\t| ({\n\t\t\treadonly kind: \"export\";\n\t\t\treadonly directory: string;\n\t\t\t/** The kinds to export; both when neither `--sessions` nor `--workflows` is given. */\n\t\t\treadonly kinds: TransferKinds;\n\t\t\treadonly runs?: readonly string[];\n\t\t\treadonly unfinished: boolean;\n\t\t\treadonly limit?: number;\n\t\t\t/** `--since`, in milliseconds since the epoch. */\n\t\t\treadonly since?: number;\n\t } & NamedStorage)\n\t| ({ readonly kind: \"import\"; readonly directory: string; readonly kinds: TransferKinds } & NamedStorage);\n\n/** The storage an export reads or an import writes, named with `--storage` or `--storage-file` instead of selected. */\nexport interface NamedStorage {\n\t/** `--storage`: a selection in the settings form. */\n\treadonly storage?: StorageSettingsSelection;\n\t/** `--storage-file`: a file holding one. */\n\treadonly storageFile?: string;\n}\n\n/** Which kinds an export or import covers, and whether `--sessions` or `--workflows` named them. */\nexport interface TransferKinds {\n\treadonly sessions: boolean;\n\treadonly workflows: boolean;\n\treadonly explicit: boolean;\n}\n\nexport class StorageCommandError extends Error {}\n\n/** Parse the arguments after `storage`. */\nexport function parseStorageCommand(args: readonly string[]): StorageCommand {\n\tconst [command, ...rest] = args;\n\tif (command === undefined || command === \"help\" || args.includes(\"--help\") || args.includes(\"-h\")) {\n\t\treturn { kind: \"help\" };\n\t}\n\tconst positional: string[] = [];\n\tconst values = new Map<string, string>();\n\tlet json = false;\n\tlet discover = true;\n\tlet unfinished = false;\n\tlet sessions = false;\n\tlet workflows = false;\n\tconst runs: string[] = [];\n\tfor (let index = 0; index < rest.length; index++) {\n\t\tconst arg = rest[index]!;\n\t\tif (command === \"status\" && arg === \"--json\") {\n\t\t\tjson = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (command === \"adopt\" && arg === \"--no-discover\") {\n\t\t\tdiscover = false;\n\t\t\tcontinue;\n\t\t}\n\t\tif ((command === \"export\" || command === \"import\") && (arg === \"--sessions\" || arg === \"--workflows\")) {\n\t\t\tif (arg === \"--sessions\") sessions = true;\n\t\t\telse workflows = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (command === \"export\" && arg === \"--unfinished\") {\n\t\t\tunfinished = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (command === \"export\" && arg === \"--run\") {\n\t\t\tconst value = rest[++index];\n\t\t\tif (value === undefined || value === \"\") throw new StorageCommandError(\"--run needs a run ID.\");\n\t\t\truns.push(value);\n\t\t\tcontinue;\n\t\t}\n\t\tif (\n\t\t\t((command === \"join\" || command === \"migrate\") &&\n\t\t\t\t(arg === \"--token-file\" || arg === \"--password-file\" || arg === \"--auth\" || arg === \"--prefix\")) ||\n\t\t\t(command === \"migrate\" && arg === \"--db\") ||\n\t\t\t(command === \"export\" && (arg === \"--limit\" || arg === \"--since\")) ||\n\t\t\t((command === \"export\" || command === \"import\") && (arg === \"--storage\" || arg === \"--storage-file\"))\n\t\t) {\n\t\t\tconst value = rest[++index];\n\t\t\tif (value === undefined) throw new StorageCommandError(`${arg} needs a value.`);\n\t\t\tvalues.set(arg, value);\n\t\t\tcontinue;\n\t\t}\n\t\tif (arg.startsWith(\"-\"))\n\t\t\tthrow new StorageCommandError(`Unknown option ${arg} for \"storage ${command}\".\\n${HELP_HINT}`);\n\t\tpositional.push(arg);\n\t}\n\tif (command === \"status\") {\n\t\tif (positional.length > 0) throw new StorageCommandError(`Usage: ${APP_NAME} storage status [--json]`);\n\t\treturn { kind: \"status\", json };\n\t}\n\tif (command === \"join\") {\n\t\tconst [url, ...extra] = positional;\n\t\tif (url === undefined || extra.length > 0) throw new StorageCommandError(`Usage: ${JOIN_USAGE}`);\n\t\tconst checked = checkSharedDatabaseArguments({\n\t\t\turl,\n\t\t\ttokenFile: values.get(\"--token-file\"),\n\t\t\tpasswordFile: values.get(\"--password-file\"),\n\t\t\tauth: values.get(\"--auth\"),\n\t\t});\n\t\tif (!isPostgresUrl(url) && checked.tokenFile === undefined && !isFileUrl(url)) throw missingTeamToken(url, \"cli\");\n\t\tconst prefix = values.get(\"--prefix\");\n\t\treturn { kind: \"join\", ...checked, ...(prefix === undefined ? {} : { prefix }) };\n\t}\n\tif (command === \"migrate\") {\n\t\tif (positional.length > 0) throw new StorageCommandError(`Usage: ${MIGRATE_USAGE}`);\n\t\tconst url = values.get(\"--db\");\n\t\tif (url === undefined) {\n\t\t\tfor (const option of [\"--token-file\", \"--password-file\", \"--auth\", \"--prefix\"])\n\t\t\t\tif (values.has(option))\n\t\t\t\t\tthrow new StorageCommandError(`${option} qualifies --db; pass the database URL with --db too.`);\n\t\t\treturn { kind: \"migrate\" };\n\t\t}\n\t\tconst checked = checkSharedDatabaseArguments({\n\t\t\turl,\n\t\t\ttokenFile: values.get(\"--token-file\"),\n\t\t\tpasswordFile: values.get(\"--password-file\"),\n\t\t\tauth: values.get(\"--auth\"),\n\t\t});\n\t\tconst prefix = values.get(\"--prefix\");\n\t\treturn {\n\t\t\tkind: \"migrate\",\n\t\t\tdatabase: {\n\t\t\t\turl,\n\t\t\t\t...(checked.tokenFile === undefined ? {} : { tokenFile: checked.tokenFile }),\n\t\t\t\t...(checked.passwordFile === undefined ? {} : { passwordFile: checked.passwordFile }),\n\t\t\t\t...(checked.auth === undefined ? {} : { auth: checked.auth }),\n\t\t\t\t...(prefix === undefined ? {} : { prefix }),\n\t\t\t},\n\t\t};\n\t}\n\tif (command === \"adopt\") {\n\t\tif (positional.length === 0)\n\t\t\tthrow new StorageCommandError(`Usage: ${APP_NAME} storage adopt <path>... [--no-discover]`);\n\t\treturn { kind: \"adopt\", paths: positional, discover };\n\t}\n\tif (command === \"consolidate\") {\n\t\tif (positional.length > 0) throw new StorageCommandError(`Usage: ${APP_NAME} storage consolidate`);\n\t\treturn { kind: \"consolidate\" };\n\t}\n\tconst named = namedStorage(values);\n\tconst kinds: TransferKinds =\n\t\tsessions || workflows\n\t\t\t? { sessions, workflows, explicit: true }\n\t\t\t: { sessions: true, workflows: true, explicit: false };\n\tif (command === \"export\") {\n\t\tconst [directory, ...extra] = positional;\n\t\tif (directory === undefined || extra.length > 0)\n\t\t\tthrow new StorageCommandError(\n\t\t\t\t`Usage: ${APP_NAME} storage export <dir> [--sessions] [--workflows] [--run <id>]... [--unfinished] [--limit <n>] [--since <time>]`,\n\t\t\t);\n\t\tconst limitText = values.get(\"--limit\");\n\t\tconst limit = limitText === undefined ? undefined : Number(limitText);\n\t\tif (limit !== undefined && (!/^[0-9]+$/.test(limitText!) || !Number.isSafeInteger(limit) || limit < 1))\n\t\t\tthrow new StorageCommandError(`--limit needs a positive whole number, not \"${limitText}\".`);\n\t\tconst sinceText = values.get(\"--since\");\n\t\tconst since = sinceText === undefined ? undefined : Date.parse(sinceText);\n\t\tif (since !== undefined && Number.isNaN(since))\n\t\t\tthrow new StorageCommandError(\n\t\t\t\t`--since needs a date such as 2026-11-01 or a date and time such as 2026-11-01T09:30:00Z, not \"${sinceText}\".`,\n\t\t\t);\n\t\tif (!kinds.workflows && (runs.length > 0 || unfinished))\n\t\t\tthrow new StorageCommandError(\n\t\t\t\t`${runs.length > 0 ? \"--run\" : \"--unfinished\"} selects workflow runs, which --sessions alone does not export.`,\n\t\t\t);\n\t\tif (!kinds.sessions && since !== undefined)\n\t\t\tthrow new StorageCommandError(\"--since selects sessions, which --workflows alone does not export.\");\n\t\treturn {\n\t\t\tkind: \"export\",\n\t\t\tdirectory,\n\t\t\tkinds,\n\t\t\tunfinished,\n\t\t\t...(runs.length === 0 ? {} : { runs }),\n\t\t\t...(limit === undefined ? {} : { limit }),\n\t\t\t...(since === undefined ? {} : { since }),\n\t\t\t...named,\n\t\t};\n\t}\n\tif (command === \"import\") {\n\t\tconst [directory, ...extra] = positional;\n\t\tif (directory === undefined || extra.length > 0)\n\t\t\tthrow new StorageCommandError(`Usage: ${APP_NAME} storage import <dir> [--sessions] [--workflows]`);\n\t\treturn { kind: \"import\", directory, kinds, ...named };\n\t}\n\tthrow new StorageCommandError(`Unknown storage command \"${command}\".\\n${HELP_HINT}`);\n}\n\nfunction namedStorage(values: ReadonlyMap<string, string>): NamedStorage {\n\tconst text = values.get(\"--storage\");\n\tconst storageFile = values.get(\"--storage-file\");\n\tif (text !== undefined && storageFile !== undefined)\n\t\tthrow new StorageCommandError(\"Pass only one of --storage and --storage-file.\");\n\tif (storageFile !== undefined) return { storageFile };\n\tif (text === undefined) return {};\n\treturn { storage: storageSelectionJson(text, \"--storage\") };\n}\n\n/** A selection in the settings form, from JSON text; `field` names where it came from. */\nfunction storageSelectionJson(text: string, field: string): StorageSettingsSelection {\n\tlet value: StorageSettingsSelection | null;\n\ttry {\n\t\tvalue = JSON.parse(text) as StorageSettingsSelection | null;\n\t} catch {\n\t\tvalue = null;\n\t}\n\tif (value === null || typeof value !== \"object\" || Array.isArray(value))\n\t\tthrow new StorageCommandError(\n\t\t\t`${field} needs a JSON object in the form of the \\`storage\\` setting, for example {\"path\":\"/path/to/journal.sqlite\"}.`,\n\t\t);\n\treturn value;\n}\n\n/** The selection `--storage` or `--storage-file` names, checked like a settings selection; undefined for neither. */\nfunction namedSelection(command: NamedStorage, cwd: string): StorageSelection | undefined {\n\tlet value = command.storage;\n\tconst field = command.storageFile === undefined ? \"--storage\" : \"--storage-file\";\n\tif (command.storageFile !== undefined) {\n\t\tconst path = resolve(cwd, command.storageFile);\n\t\tlet text: string;\n\t\ttry {\n\t\t\ttext = readFileSync(path, \"utf8\");\n\t\t} catch (error) {\n\t\t\tthrow new StorageCommandError(`--storage-file ${path} cannot be read: ${errorText(error as Error)}.`);\n\t\t}\n\t\tvalue = storageSelectionJson(text, `--storage-file ${path}`);\n\t}\n\tif (value === undefined) return undefined;\n\tconst selection = selectStorage(value, \"cli\", field, \"\");\n\tif (selection.kind !== \"sqlite\") return selection;\n\tif (selection.path === \":memory:\") return { kind: \"memory\" };\n\tif (selection.path === \"\")\n\t\tthrow new StorageCommandError(`${field} names no storage: give a \"path\" or an \"adapter\" with its options.`);\n\treturn { ...selection, path: resolve(cwd, selection.path) };\n}\n\nexport interface StorageCommandOptions {\n\treadonly cwd: string;\n\treadonly agentDir: string;\n\treadonly log?: (line: string) => void;\n\treadonly error?: (line: string) => void;\n\t/** Defaults to the bundled Intercom package's broker control. */\n\treadonly loadControl?: () => Promise<IntercomBrokerControl>;\n\t/** `migrate`: defaults to the bundled workflows package's public entry. */\n\treadonly loadWorkerModule?: () => Promise<Pick<WorkerHostModule, \"migrateWorkflowStorage\">>;\n\t/** `migrate`: defaults to the bundled Intercom package's broker state opener. */\n\treadonly loadBrokerState?: () => Promise<BrokerStateModule>;\n}\n\nconst errorText = describeStorageError;\n\n/** The bundled Intercom package's broker control, or why it could not load. */\nexport async function loadBrokerControl(options: {\n\treadonly loadControl?: () => Promise<IntercomBrokerControl>;\n}): Promise<IntercomBrokerControl | Error> {\n\ttry {\n\t\tif (options.loadControl) return await options.loadControl();\n\t\tconst { loadIntercomBrokerControl } = await import(\"../core/intercom-broker-control.js\");\n\t\treturn await loadIntercomBrokerControl();\n\t} catch (error) {\n\t\treturn error instanceof Error ? error : new Error(String(error));\n\t}\n}\n\n/** Whether a domain's selection is invalid, its adapter cannot load, or its database did not answer. */\nexport function failed(domain: DomainStatus): boolean {\n\treturn (\n\t\tdomain.error !== undefined ||\n\t\tdomain.probe?.adapter?.loaded === false ||\n\t\tdomain.probe?.connection.status === \"failed\" ||\n\t\t(domain.journalStore?.unavailable.length ?? 0) > 0\n\t);\n}\n\nconst DOMAIN_LABELS: Record<DomainStatus[\"domain\"], string> = {\n\tsessions: \"Sessions\",\n\tjournal: \"Workflow runs\",\n\tintercom: \"Intercom\",\n};\n\n/** The status as the lines `atomic storage status` prints. */\nexport function formatStorageStatus(status: StorageStatus): string[] {\n\tconst lines = [\n\t\t`Agent directory: ${status.agentDir}`,\n\t\t`Project: ${status.cwd}${status.projectTrusted ? \"\" : \" (not trusted)\"}`,\n\t];\n\tfor (const domain of status.domains) {\n\t\tlines.push(\"\", `${DOMAIN_LABELS[domain.domain]}: ${domain.selection}`);\n\t\tlines.push(` source: ${domain.source}`);\n\t\tif (domain.overridden.length > 0) lines.push(` overrides: ${domain.overridden.join(\", \")}`);\n\t\tif (domain.error !== undefined) lines.push(` error: ${domain.error}`);\n\t\tconst probe = domain.probe;\n\t\tif (probe?.sameAs !== undefined) {\n\t\t\tlines.push(` connection: same as ${DOMAIN_LABELS[probe.sameAs].toLowerCase()}`);\n\t\t} else if (probe !== undefined) {\n\t\t\tif (probe.adapter !== undefined) {\n\t\t\t\tlines.push(\n\t\t\t\t\t` adapter: ${probe.adapter.loaded ? \"loaded\" : \"failed to load\"}${probe.adapter.detail === undefined ? \"\" : ` (${probe.adapter.detail})`}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tlines.push(` connection: ${probe.connection.status} (${probe.connection.detail})`);\n\t\t}\n\t\tif (domain.multiNode !== undefined) lines.push(` multi-node: ${domain.multiNode}`);\n\t\tif (domain.liveBrokers !== undefined) {\n\t\t\tlines.push(\n\t\t\t\t` brokers: ${domain.liveBrokers.length} live in the database${domain.liveBrokers.length === 0 ? \"\" : ` (${[...new Set(domain.liveBrokers)].join(\", \")})`}`,\n\t\t\t);\n\t\t}\n\t\tconst store = domain.journalStore;\n\t\tif (store !== undefined) {\n\t\t\tlines.push(\n\t\t\t\t` journals: ${store.shards} shard${store.shards === 1 ? \"\" : \"s\"}, ${store.adopted} adopted journal${store.adopted === 1 ? \"\" : \"s\"}, ${store.runs} run${store.runs === 1 ? \"\" : \"s\"}`,\n\t\t\t);\n\t\t\tfor (const shard of store.unavailable)\n\t\t\t\tlines.push(\n\t\t\t\t\t` unavailable: ${shard.path} (${shard.kind}, ${shard.code === \"shard-missing\" ? \"no longer exists\" : \"cannot be opened\"}: ${shard.code}${shard.detail === undefined ? \"\" : `, ${shard.detail}`})`,\n\t\t\t\t);\n\t\t\tfor (const skipped of store.skipped) lines.push(` skipped: ${skipped.path} (${skipped.reason})`);\n\t\t}\n\t}\n\tconst broker = status.broker;\n\tif (broker !== undefined) {\n\t\tlines.push(\"\");\n\t\tif (broker.state === \"stopped\") {\n\t\t\tlines.push(\n\t\t\t\t\"Intercom broker: not running (the next session that uses Intercom starts one with the selection above)\",\n\t\t\t);\n\t\t} else if (broker.state === \"unknown\") {\n\t\t\tlines.push(`Intercom broker: unknown (${broker.error ?? \"no answer\"})`);\n\t\t} else if (broker.state === \"legacy\") {\n\t\t\tlines.push(\n\t\t\t\t`Intercom broker: running${broker.pid === undefined ? \"\" : ` (pid ${broker.pid})`}, started by an older Atomic that does not report its storage; run \\`${APP_NAME} intercom restart\\``,\n\t\t\t);\n\t\t} else {\n\t\t\tlines.push(\n\t\t\t\t`Intercom broker: running (pid ${broker.pid}, ${broker.sessions} session${broker.sessions === 1 ? \"\" : \"s\"} connected)`,\n\t\t\t);\n\t\t\tlines.push(\n\t\t\t\tbroker.matchesCurrent\n\t\t\t\t\t? \" storage: matches the selection above\"\n\t\t\t\t\t: ` storage: differs from the selection above${broker.source === \"env\" ? \" (a session started it with ATOMIC_STORAGE, ATOMIC_PROFILE=ci or --storage)\" : \"\"}; run \\`${APP_NAME} intercom restart\\` to use the current one`,\n\t\t\t);\n\t\t\tif (broker.multiNodeLine !== undefined) lines.push(` multi-node: ${broker.multiNodeLine}`);\n\t\t}\n\t}\n\tif (status.notes.length > 0) lines.push(\"\", \"Notes:\", ...status.notes.map((note) => ` - ${note}`));\n\treturn lines;\n}\n\nasync function status(json: boolean, options: StorageCommandOptions, log: (line: string) => void): Promise<number> {\n\tconst control = await loadBrokerControl(options);\n\tconst collected = await collectStorageStatus({\n\t\tcwd: options.cwd,\n\t\tagentDir: options.agentDir,\n\t\tprobe: true,\n\t\t...(control instanceof Error ? {} : { control }),\n\t});\n\tconst result: StorageStatus =\n\t\tcontrol instanceof Error ? { ...collected, broker: { state: \"unknown\", error: errorText(control) } } : collected;\n\tif (json) log(JSON.stringify(result, null, 2));\n\telse for (const line of formatStorageStatus(result)) log(line);\n\treturn result.domains.some(failed) ? 1 : 0;\n}\n\nasync function joinStorage(\n\tcommand: Extract<StorageCommand, { kind: \"join\" }>,\n\toptions: StorageCommandOptions,\n\tlog: (...lines: string[]) => void,\n): Promise<number> {\n\tconst { agentDir, cwd } = options;\n\tconst joined = await joinSharedDatabase({ ...command, agentDir, cwd, pinLocalSessions: false }, \"cli\");\n\tlog(`Connected to ${command.url}.`);\n\tconst secret = command.passwordFile === undefined ? \"token\" : \"password\";\n\tif (joined.tokenPath !== undefined) {\n\t\tlog(\n\t\t\tjoined.token === \"reused\"\n\t\t\t\t? `Kept the ${secret} in ${joined.tokenPath}; it already holds this ${secret}.`\n\t\t\t\t: `Stored the ${secret} in ${joined.tokenPath} (mode 600).`,\n\t\t);\n\t}\n\tif (joined.referencedFile !== undefined)\n\t\tlog(`The password stays in ${joined.referencedFile} and is read again for every new connection.`);\n\tif (command.auth !== undefined) log(`The adapter obtains a ${command.auth} credential for every new connection.`);\n\tlog(`Set \\`storage\\` in ${join(agentDir, \"settings.json\")}; other settings are unchanged.`);\n\tif (joined.replaced !== undefined) log(`It replaces the previous selection: ${joined.replaced}.`);\n\n\tconst control = await loadBrokerControl(options);\n\tlet collected: StorageStatus;\n\ttry {\n\t\tcollected = await collectStorageStatus({\n\t\t\tcwd,\n\t\t\tagentDir,\n\t\t\tprobe: false,\n\t\t\t...(control instanceof Error ? {} : { control }),\n\t\t});\n\t} catch (error) {\n\t\t// Settings and the token are already committed; optional diagnostics cannot undo that success.\n\t\tlog(`Storage was saved, but could not report overrides: ${errorText(error as Error)}.`);\n\t\tlog(`Run \\`${APP_NAME} storage status\\` after fixing the reported settings error.`);\n\t\treturn 0;\n\t}\n\tconst overridden = collected.domains.filter(\n\t\t(domain) => domain.source !== \"global settings: storage\" && domain.source !== \"default\",\n\t);\n\tif (overridden.length > 0) {\n\t\tlog(\"\", \"These take precedence over the new selection here:\");\n\t\tfor (const domain of overridden) log(` - ${DOMAIN_LABELS[domain.domain]}: ${domain.source}`);\n\t}\n\tfor (const note of collected.notes) log(`Note: ${note}`);\n\tconst broker = collected.broker;\n\tif (broker?.state === \"running\" && !broker.matchesCurrent) {\n\t\tlog(\n\t\t\t`The running Intercom broker (pid ${broker.pid}) still uses its previous selection. Run \\`${APP_NAME} intercom restart\\` so it uses the new one.`,\n\t\t);\n\t} else if (broker?.state === \"legacy\") {\n\t\tlog(\n\t\t\t`An Intercom broker from an older ${APP_NAME} is running. Run \\`${APP_NAME} intercom restart\\` to replace it.`,\n\t\t);\n\t}\n\tlog(`Run \\`${APP_NAME} storage status\\` to check each domain.`);\n\treturn 0;\n}\n\n/** Run `atomic storage <args>` and return the exit code. */\nexport async function runStorageCommand(args: readonly string[], options: StorageCommandOptions): Promise<number> {\n\tconst log = options.log ?? ((line: string) => console.log(line));\n\tconst error = options.error ?? ((line: string) => console.error(line));\n\ttry {\n\t\tconst command = parseStorageCommand(args);\n\t\tif (command.kind === \"help\") {\n\t\t\tlog(HELP);\n\t\t\treturn 0;\n\t\t}\n\t\tif (command.kind === \"status\") return await status(command.json, options, log);\n\t\tif (command.kind === \"adopt\") return await adopt(command, options, log);\n\t\tif (command.kind === \"consolidate\") return await consolidate(options, log);\n\t\tif (command.kind === \"migrate\") return await migrate(command, options, log);\n\t\tif (command.kind === \"export\") return await exportRuns(command, options, log, error);\n\t\tif (command.kind === \"import\") return await importRuns(command, options, log, error);\n\t\treturn await joinStorage(command, options, (...lines) => {\n\t\t\tfor (const line of lines) log(line);\n\t\t});\n\t} catch (caught) {\n\t\tif (isJournalStoreError(caught)) {\n\t\t\terror(caught.message);\n\t\t\tif (caught.hint !== undefined) error(caught.hint);\n\t\t\treturn 1;\n\t\t}\n\t\terror(\n\t\t\tcaught instanceof StorageCommandError ||\n\t\t\t\tisStorageTransferError(caught) ||\n\t\t\t\tisTeamProfileError(caught) ||\n\t\t\t\tisTeamProfileConfigError(caught)\n\t\t\t\t? caught.message\n\t\t\t\t: `Error: ${errorText(caught as Error)}`,\n\t\t);\n\t\treturn 1;\n\t}\n}\n\n/** Intercom's broker state opener, as the bundled Intercom package's `broker/open-broker-state` module exports it. */\ninterface BrokerStateModule {\n\topenIntercomBrokerState(source: {\n\t\treadonly prefix?: string;\n\t\treadonly openDatabase: () => Promise<SqliteDatabase>;\n\t}): Promise<{ readonly state: { close(): Promise<void> }; readonly bus: { close(): Promise<void> } }>;\n}\n\n/** Loads the bundled Intercom package's broker state opener, as extensions see the host's modules. */\nasync function loadBrokerStateModule(): Promise<BrokerStateModule> {\n\tconst intercom = getBuiltinPackageLocations().find(({ distDirName }) => distDirName === \"intercom\");\n\tif (intercom === undefined) throw new Error(\"The bundled Intercom package was not found.\");\n\tconst modulePath = [\"broker/open-broker-state.ts\", \"broker/open-broker-state.js\"]\n\t\t.map((path) => join(intercom.packageDir, path))\n\t\t.find((path) => existsSync(path));\n\tif (modulePath === undefined) throw new Error(\"The bundled Intercom package has no broker state module.\");\n\tconst [{ createHostModuleJiti }, { getVirtualModules }] = await Promise.all([\n\t\timport(\"../core/extensions/loader-virtual-modules.js\"),\n\t\timport(\"../core/extensions/loader-host-modules.js\"),\n\t]);\n\tconst loader = await createHostModuleJiti(pathToFileURL(modulePath).href, await getVirtualModules());\n\treturn loader.import<BrokerStateModule>(modulePath);\n}\n\n/**\n * `atomic storage migrate` (#5218): sets up or upgrades every store's tables in the shared database, as its owner role.\n * On PostgreSQL, tables an earlier release created in `public` move to schema `atomic` first.\n */\nasync function migrate(\n\tcommand: Extract<StorageCommand, { kind: \"migrate\" }>,\n\toptions: StorageCommandOptions,\n\tlog: (line: string) => void,\n): Promise<number> {\n\tconst { agentDir, cwd } = options;\n\tconst database = command.database === undefined ? undefined : { ...command.database };\n\tif (database?.tokenFile !== undefined) database.tokenFile = resolve(cwd, database.tokenFile);\n\tif (database?.passwordFile !== undefined) database.passwordFile = resolve(cwd, database.passwordFile);\n\tconst settings = database === undefined ? undefined : workerJournalSelection(database);\n\tconst selection =\n\t\tsettings === undefined\n\t\t\t? effectiveJournalSelection(cwd, agentDir)\n\t\t\t: selectStorage(settings as StorageSettingsSelection, \"cli\", \"--db\", \"\");\n\tif (selection.kind !== \"adapter\") {\n\t\tlog(\n\t\t\t`Workflow runs here use ${describeStorageSelection(selection)}, which sets itself up on first use; there is nothing to migrate.`,\n\t\t);\n\t\treturn 0;\n\t}\n\tconst open = (domain: \"journal\" | \"intercom\") => openAdapterSelectionDatabase(selection, { agentDir, domain });\n\tconst opened = await open(\"journal\");\n\ttry {\n\t\tconst explicitSchema = (selection.options as { schema?: unknown }).schema !== undefined;\n\t\tif (dialectOf(opened).name === \"postgres\" && !explicitSchema) {\n\t\t\tconst row = await opened.get<SqliteRow & { schema: string | null }>(\"SELECT current_schema() AS schema\");\n\t\t\tif (row?.schema === \"public\") {\n\t\t\t\tconst moved = await movePostgresStorageToSchema(opened);\n\t\t\t\tlog(\n\t\t\t\t\tmoved.skipped\n\t\t\t\t\t\t? `Another \\`${APP_NAME} storage migrate\\` moved the tables to schema ${POSTGRES_ATOMIC_SCHEMA} first.`\n\t\t\t\t\t\t: `Moved ${moved.tables.length} table${moved.tables.length === 1 ? \"\" : \"s\"} and ${moved.functions.length} trigger function${moved.functions.length === 1 ? \"\" : \"s\"} from schema public to schema ${POSTGRES_ATOMIC_SCHEMA}; processes of an earlier Atomic still using public are refused until they are upgraded.`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t} finally {\n\t\tawait opened.close();\n\t}\n\tawait (await new StorageProvider().openSessionStore(selection, { agentDir, domain: \"sessions\" })).close();\n\tconst workflows = await (options.loadWorkerModule ?? loadWorkerHostModule)();\n\tif (workflows.migrateWorkflowStorage === undefined)\n\t\tthrow new Error(\"The bundled workflows package cannot migrate storage; reinstall Atomic.\");\n\tawait workflows.migrateWorkflowStorage({ ...(settings === undefined ? {} : { journal: settings }), agentDir });\n\tconst intercom = await (options.loadBrokerState ?? loadBrokerStateModule)();\n\tconst broker = await intercom.openIntercomBrokerState({\n\t\t...(selection.prefix === undefined ? {} : { prefix: selection.prefix }),\n\t\topenDatabase: () => open(\"intercom\"),\n\t});\n\tawait broker.bus.close();\n\tawait broker.state.close();\n\t// Tables created in public after the move hold state the moved ones do not (#5218).\n\tconst checked = await open(\"journal\");\n\tlet strays: string[];\n\ttry {\n\t\tstrays = await strayPostgresStorageTables(checked);\n\t} finally {\n\t\tawait checked.close();\n\t}\n\tif (strays.length > 0) {\n\t\tlog(\n\t\t\t`Found ${strays.length} of Atomic's table${strays.length === 1 ? \"\" : \"s\"} in schema public that a process created after the move to schema ${POSTGRES_ATOMIC_SCHEMA}: ${strays.join(\", \")}. A process of an earlier Atomic, or one started before the move, still uses public, and what it wrote there is not in schema ${POSTGRES_ATOMIC_SCHEMA}. Stop or upgrade it, then drop those tables, or copy what you need into schema ${POSTGRES_ATOMIC_SCHEMA} first.`,\n\t\t);\n\t\treturn 1;\n\t}\n\tlog(\n\t\t`Atomic's tables in ${describeStorageSelection(selection)} are set up for this version: sessions, workflow runs, worker pools and Intercom.`,\n\t);\n\treturn 0;\n}\n\n/** A note when this directory's workflow runs use another journal than the journal store `adopt` writes to. */\nfunction storeSelectionNote(options: StorageCommandOptions, directory: string): string | undefined {\n\tconst selection = effectiveJournalSelection(options.cwd, options.agentDir);\n\tif (selection.kind === \"sharded\") return undefined;\n\treturn `Note: workflow runs here use ${describeStorageSelection(selection)}, so they see the journal store ${directory} only once that selection is removed.`;\n}\n\nasync function adopt(\n\tcommand: Extract<StorageCommand, { kind: \"adopt\" }>,\n\toptions: StorageCommandOptions,\n\tlog: (line: string) => void,\n): Promise<number> {\n\tconst directory = defaultJournalStoreDirectory(options.agentDir);\n\tconst report = await adoptJournals(\n\t\tdirectory,\n\t\tcommand.paths.map((path) => resolve(options.cwd, path)),\n\t\t{ discover: command.discover },\n\t);\n\tfor (const outcome of report.adopted) {\n\t\tlog(\n\t\t\toutcome.status === \"adopted\"\n\t\t\t\t? `Adopted ${outcome.path} in place (shard ${outcome.shardId}, ${outcome.runs} run${outcome.runs === 1 ? \"\" : \"s\"}).`\n\t\t\t\t: `Already registered: ${outcome.path} (shard ${outcome.shardId}).`,\n\t\t);\n\t}\n\tfor (const record of report.discovered) {\n\t\tlog(\n\t\t\trecord.outcome === \"skipped\"\n\t\t\t\t? `Skipped ${record.path}, referenced by runs in ${record.referencedBy} (${record.reason}).`\n\t\t\t\t: `Adopted ${record.path}, referenced by runs in ${record.referencedBy}.`,\n\t\t);\n\t}\n\tconst note = storeSelectionNote(options, directory);\n\tif (note !== undefined) log(note);\n\treturn 0;\n}\n\nasync function consolidate(options: StorageCommandOptions, log: (line: string) => void): Promise<number> {\n\tconst directory = defaultJournalStoreDirectory(options.agentDir);\n\tconst report = await consolidateJournalStore(directory);\n\tlog(`Moved ${report.moved} finished run${report.moved === 1 ? \"\" : \"s\"} into the journal store's shards.`);\n\tconst reasons = new Map<string, number>();\n\tfor (const run of report.runs)\n\t\tif (run.outcome === \"skipped\") reasons.set(run.reason, (reasons.get(run.reason) ?? 0) + 1);\n\tfor (const [reason, count] of reasons)\n\t\tlog(`Skipped completing consolidation for ${count} run${count === 1 ? \"\" : \"s\"}: ${reason}.`);\n\tconst failures = new Map<string, string>();\n\tfor (const run of report.runs)\n\t\tif (run.error !== undefined) failures.set(run.error.message, `${run.error.message} ${run.error.hint}`);\n\tfor (const failure of failures.values()) log(failure);\n\tconst note = storeSelectionNote(options, directory);\n\tif (note !== undefined) log(note);\n\treturn failures.size === 0 ? 0 : 1;\n}\n\n/** What an export or import of one kind reads or writes, or why that kind is refused here. */\ntype Transfer<T> = { readonly target: T } | { readonly refused: string };\n\n/**\n * The local workflow journal this directory's runs use, which `export` and `import` read and write. A shared database\n * is refused: every machine joined to it already reads its runs, so there is nothing to carry between them.\n */\nfunction workflowTransfer(\n\toptions: StorageCommandOptions,\n\tcommand: \"export\" | \"import\",\n\tnamed: StorageSelection | undefined,\n): Transfer<WorkflowRunTransferStorage> {\n\tif (named?.kind === \"adapter\")\n\t\treturn {\n\t\t\ttarget: {\n\t\t\t\tkind: \"database\",\n\t\t\t\topen: () => openAdapterSelectionDatabase(named, { agentDir: options.agentDir, domain: \"journal\" }),\n\t\t\t\tlocation: describeStorageSelection(named),\n\t\t\t\tprefix: named.prefix,\n\t\t\t},\n\t\t};\n\tconst selection = named ?? effectiveJournalSelection(options.cwd, options.agentDir);\n\tif (selection.kind === \"sharded\") return { target: { kind: \"store\", directory: selection.dir } };\n\tif (selection.kind === \"sqlite\" && selection.path !== \":memory:\")\n\t\treturn {\n\t\t\ttarget: {\n\t\t\t\tkind: \"sqlite\",\n\t\t\t\tpath: resolve(options.cwd, selection.path),\n\t\t\t\t...(selection.prefix === undefined ? {} : { prefix: selection.prefix }),\n\t\t\t},\n\t\t};\n\treturn {\n\t\trefused:\n\t\t\t`${APP_NAME} storage ${command} works with a local workflow journal (the journal store or a SQLite file), but workflow runs here use ${describeStorageSelection(selection)}.` +\n\t\t\t(selection.kind === \"adapter\"\n\t\t\t\t? \" A shared database already holds the runs of every machine joined to it, so there is nothing to export or import; use its own backups, or name it with --storage or --storage-file to copy runs and sessions out of it or into it.\"\n\t\t\t\t: \"\"),\n\t};\n}\n\n/**\n * The session storage this directory selects, as a session started here would open it: the default database, a JSONL\n * directory, a SQLite file or an adapter. A shared libSQL / Turso database is refused as it is for workflow runs, and so\n * is in-memory storage, which keeps nothing. Undefined target for an export when nothing has been stored yet, so an\n * export creates no database.\n */\nasync function sessionTransfer(\n\toptions: StorageCommandOptions,\n\tcommand: \"export\" | \"import\",\n\tnamed: StorageSelection | undefined,\n): Promise<Transfer<SessionStore | undefined>> {\n\tif (named !== undefined) {\n\t\tif (named.kind !== \"sqlite\" && named.kind !== \"adapter\")\n\t\t\treturn {\n\t\t\t\trefused: `${APP_NAME} storage ${command} needs stored sessions, but ${describeStorageSelection(named)} keeps nothing.`,\n\t\t\t};\n\t\tif (command === \"export\" && named.kind === \"sqlite\" && !existsSync(named.path)) return { target: undefined };\n\t\treturn {\n\t\t\ttarget: await new StorageProvider().openSessionStore(named, {\n\t\t\t\tagentDir: options.agentDir,\n\t\t\t\tdomain: \"sessions\",\n\t\t\t}),\n\t\t};\n\t}\n\tconst settings = SettingsManager.create(options.cwd, options.agentDir, {\n\t\tprojectTrusted: projectTrust(options.cwd, options.agentDir),\n\t}).getSettings();\n\tconst storageOptions = { agentDir: options.agentDir, settings };\n\tconst selection = selectSessionStorageWithSettings(options.cwd, storageOptions);\n\tif (!(\"load\" in selection)) {\n\t\tif (selection.kind === \"memory\" || (selection.kind === \"sqlite\" && selection.path === \":memory:\"))\n\t\t\treturn {\n\t\t\t\trefused: `${APP_NAME} storage ${command} needs stored sessions, but sessions here use ${describeStorageSelection(selection)}, which keeps nothing.`,\n\t\t\t};\n\t\tif (\n\t\t\tselection.kind === \"adapter\" &&\n\t\t\t(selection.module === LIBSQL_ADAPTER_PACKAGE || selection.module === POSTGRES_ADAPTER_PACKAGE)\n\t\t)\n\t\t\treturn {\n\t\t\t\trefused: `${APP_NAME} storage ${command} works with local session storage, but sessions here use ${describeStorageSelection(selection)}. A shared database already holds the sessions of every machine joined to it, so there is nothing to export or import; use its own backups, or name it with --storage or --storage-file to copy runs and sessions out of it or into it.`,\n\t\t\t};\n\t\tif (command === \"export\") {\n\t\t\tconst stored =\n\t\t\t\tselection.kind === \"jsonl\"\n\t\t\t\t\t? existsSync(selection.dir)\n\t\t\t\t\t: selection.kind !== \"sqlite\" ||\n\t\t\t\t\t\texistsSync(resolve(options.cwd, selection.path)) ||\n\t\t\t\t\t\texistsSync(join(options.agentDir, \"sessions\"));\n\t\t\tif (!stored) return { target: undefined };\n\t\t}\n\t}\n\treturn { target: await resolveSessionStore(options.cwd, storageOptions) };\n}\n\nconst plural = (count: number, noun: string) => `${count} ${noun}${count === 1 ? \"\" : \"s\"}`;\n\nasync function exportRuns(\n\tcommand: Extract<StorageCommand, { kind: \"export\" }>,\n\toptions: StorageCommandOptions,\n\tlog: (line: string) => void,\n\terror: (line: string) => void,\n): Promise<number> {\n\tconst directory = resolve(options.cwd, command.directory);\n\tconst named = namedSelection(command, options.cwd);\n\tconst workflows = command.kinds.workflows ? workflowTransfer(options, \"export\", named) : undefined;\n\tconst sessions = command.kinds.sessions ? await sessionTransfer(options, \"export\", named) : undefined;\n\ttry {\n\t\tconst refusals = [workflows, sessions].flatMap((transfer) =>\n\t\t\ttransfer !== undefined && \"refused\" in transfer ? [transfer.refused] : [],\n\t\t);\n\t\tconst kinds = Number(command.kinds.sessions) + Number(command.kinds.workflows);\n\t\tif (refusals.length > 0 && (command.kinds.explicit || refusals.length === kinds))\n\t\t\tthrow new StorageCommandError(refusals.join(\"\\n\"));\n\t\tfor (const refused of refusals) error(`Skipped: ${refused}`);\n\t\t// Workflow runs first: an unknown --run fails the export before any file of either kind is written.\n\t\tif (workflows !== undefined && \"target\" in workflows) {\n\t\t\tconst target = workflowsTransferDirectory(directory);\n\t\t\tconst report = await exportWorkflowRuns(workflows.target, target, {\n\t\t\t\tunfinished: command.unfinished,\n\t\t\t\t...(command.runs === undefined ? {} : { runs: command.runs }),\n\t\t\t\t...(command.limit === undefined ? {} : { limit: command.limit }),\n\t\t\t});\n\t\t\tconst total = report.written.length + report.unchanged.length;\n\t\t\tlog(\n\t\t\t\t`Exported ${plural(total, \"workflow run\")} to ${target} (${report.written.length} written, ${report.unchanged.length} unchanged).`,\n\t\t\t);\n\t\t\tfor (const skipped of report.skipped)\n\t\t\t\terror(\n\t\t\t\t\t`Skipped ${skipped.runId === undefined ? skipped.path : `run ${skipped.runId} (${skipped.path})`}: ${skipped.reason}.`,\n\t\t\t\t);\n\t\t}\n\t\tif (sessions !== undefined && \"target\" in sessions) {\n\t\t\tconst target = sessionsTransferDirectory(directory);\n\t\t\tconst report =\n\t\t\t\tsessions.target === undefined\n\t\t\t\t\t? { written: [], unchanged: [] }\n\t\t\t\t\t: await exportSessions(sessions.target, target, {\n\t\t\t\t\t\t\t...(command.limit === undefined ? {} : { limit: command.limit }),\n\t\t\t\t\t\t\t...(command.since === undefined ? {} : { since: command.since }),\n\t\t\t\t\t\t});\n\t\t\tconst total = report.written.length + report.unchanged.length;\n\t\t\tlog(\n\t\t\t\t`Exported ${plural(total, \"session\")} to ${target} (${report.written.length} written, ${report.unchanged.length} unchanged).`,\n\t\t\t);\n\t\t}\n\t\treturn 0;\n\t} finally {\n\t\tawait sessionStore(sessions)?.close();\n\t}\n}\n\nfunction describeIds(ids: TransferredIds): string {\n\tconst parts = [\n\t\tids.sessions.length === 0\n\t\t\t? undefined\n\t\t\t: `${ids.sessions.length === 1 ? \"session\" : \"sessions\"} ${ids.sessions.join(\", \")}`,\n\t\tids.workflows.length === 0\n\t\t\t? undefined\n\t\t\t: `${ids.workflows.length === 1 ? \"workflow run\" : \"workflow runs\"} ${ids.workflows.join(\", \")}`,\n\t].filter((part) => part !== undefined);\n\treturn parts.length === 0 ? \"nothing\" : parts.join(\"; \");\n}\n\nasync function importRuns(\n\tcommand: Extract<StorageCommand, { kind: \"import\" }>,\n\toptions: StorageCommandOptions,\n\tlog: (line: string) => void,\n\terror: (line: string) => void,\n): Promise<number> {\n\tconst directory = resolve(options.cwd, command.directory);\n\tif (!existsSync(directory)) throw new StorageCommandError(`${directory}: no such directory.`);\n\tconst named = namedSelection(command, options.cwd);\n\tconst workflows = command.kinds.workflows ? workflowTransfer(options, \"import\", named) : undefined;\n\tconst sessions = command.kinds.sessions ? await sessionTransfer(options, \"import\", named) : undefined;\n\ttry {\n\t\tconst refusals = [workflows, sessions].flatMap((transfer) =>\n\t\t\ttransfer !== undefined && \"refused\" in transfer ? [transfer.refused] : [],\n\t\t);\n\t\tconst kinds = Number(command.kinds.sessions) + Number(command.kinds.workflows);\n\t\tif (refusals.length > 0 && (command.kinds.explicit || refusals.length === kinds))\n\t\t\tthrow new StorageCommandError(refusals.join(\"\\n\"));\n\t\tfor (const refused of refusals) error(`Skipped: ${refused}`);\n\t\tconst sessionTarget = sessionStore(sessions);\n\t\tconst workflowStorage = workflows !== undefined && \"target\" in workflows ? workflows.target : undefined;\n\t\tlet report: Awaited<ReturnType<typeof importStorage>>;\n\t\ttry {\n\t\t\treport = await importStorage(directory, {\n\t\t\t\t...(sessionTarget === undefined ? {} : { sessions: sessionTarget }),\n\t\t\t\t...(workflowStorage === undefined ? {} : { workflows: workflowStorage }),\n\t\t\t});\n\t\t} catch (caught) {\n\t\t\tif (isStorageImportIncompleteError(caught)) {\n\t\t\t\terror(caught.message);\n\t\t\t\terror(`Imported before the failure: ${describeIds(caught.written)}.`);\n\t\t\t\terror(`Not imported: ${describeIds(caught.notWritten)}.`);\n\t\t\t\terror(\"Run the same import again to finish: it imports only what is missing.\");\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\tif (isStorageTransferError(caught)) {\n\t\t\t\terror(caught.message);\n\t\t\t\terror(\"Nothing was imported.\");\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\tthrow caught;\n\t\t}\n\t\tif (report.sessions !== undefined) {\n\t\t\tconst { added, updated, unchanged } = report.sessions;\n\t\t\tlog(\n\t\t\t\t`Imported ${plural(added.length + updated.length + unchanged.length, \"session\")} from ${sessionsTransferDirectory(directory)} (${added.length} added, ${updated.length} updated, ${unchanged.length} already up to date).`,\n\t\t\t);\n\t\t}\n\t\tif (report.workflows !== undefined) {\n\t\t\tconst { added, updated, unchanged } = report.workflows;\n\t\t\tlog(\n\t\t\t\t`Imported ${plural(added.length + updated.length + unchanged.length, \"workflow run\")} from ${workflowsTransferDirectory(directory)} (${added.length} added, ${updated.length} updated, ${unchanged.length} already up to date).`,\n\t\t\t);\n\t\t}\n\t\treturn 0;\n\t} finally {\n\t\tawait sessionStore(sessions)?.close();\n\t}\n}\n\nfunction sessionStore(transfer: Transfer<SessionStore | undefined> | undefined): SessionStore | undefined {\n\treturn transfer !== undefined && \"target\" in transfer ? transfer.target : undefined;\n}\n"]}
1
+ {"version":3,"file":"storage-command.js","sourceRoot":"","sources":["../../src/cli/storage-command.ts"],"names":[],"mappings":"AAAA;;;;;;;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AC,SAAS,yBAAyB,CAAC,SAAS,CAAC,KAAK,KAAK,CAAC,MAAM,WAAW,OAAO,CAAC,MAAM,aAAa,SAAS,CAAC,MAAM,uBAAuB,CAC1N,CAAC;QACH,CAAC;QACD,IAAI,MAAM,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;YACpC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC,SAAS,CAAC;YACvD,GAAG,CACF,YAAY,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,cAAc,CAAC,SAAS,0BAA0B,CAAC,SAAS,CAAC,KAAK,KAAK,CAAC,MAAM,WAAW,OAAO,CAAC,MAAM,aAAa,SAAS,CAAC,MAAM,uBAAuB,CAChO,CAAC;QACH,CAAC;QACD,OAAO,CAAC,CAAC;IACV,CAAC;YAAS,CAAC;QACV,MAAM,YAAY,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,CAAC;IACvC,CAAC;AACF,CAAC;AAED,SAAS,YAAY,CAAC,QAAwD;IAC7E,OAAO,QAAQ,KAAK,SAAS,IAAI,QAAQ,IAAI,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AACrF,CAAC","sourcesContent":["/**\n * `atomic storage status` shows which storage each domain (sessions, workflow runs, Intercom) selects, where the\n * selection comes from, whether its adapter loads and its database answers, and what the running Intercom broker\n * uses. `atomic storage join` points this machine's global `storage` setting at a shared libSQL / Turso or\n * PostgreSQL database.\n * `atomic storage adopt` registers existing journal files in the journal store in place, and `atomic storage\n * consolidate` moves their finished runs into the store's own shards. `atomic storage export` and `atomic storage\n * import` move sessions and workflow runs between their storage and JSONL files (#4716, #4720).\n */\n\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { APP_NAME } from \"../config.js\";\nimport { getBuiltinPackageLocations } from \"../core/builtin-packages.ts\";\nimport type { IntercomBrokerControl } from \"../core/intercom-broker-control.js\";\nimport { resolveSessionStore, selectSessionStorageWithSettings } from \"../core/session-storage.js\";\nimport { exportSessions } from \"../core/session-transfer.ts\";\nimport { SettingsManager } from \"../core/settings-manager.ts\";\nimport { openAdapterSelectionDatabase } from \"../core/storage/adapter-open.js\";\nimport type { SqliteDatabase, SqliteRow } from \"../core/storage/database.js\";\nimport { dialectOf } from \"../core/storage/dialect.js\";\nimport { isJournalStoreError, isTeamProfileConfigError, isTeamProfileError } from \"../core/storage/errors.js\";\nimport {\n\tadoptJournals,\n\tconsolidateJournalStore,\n\tdefaultJournalStoreDirectory,\n} from \"../core/storage/journal-adoption.js\";\nimport {\n\texportWorkflowRuns,\n\tWORKFLOW_RUN_EXPORT_VERSION,\n\ttype WorkflowRunTransferStorage,\n} from \"../core/storage/journal-transfer.js\";\nimport {\n\tmovePostgresStorageToSchema,\n\tPOSTGRES_ATOMIC_SCHEMA,\n\tstrayPostgresStorageTables,\n} from \"../core/storage/postgres-schema.js\";\nimport { StorageProvider, type StorageSelection } from \"../core/storage/provider.js\";\nimport {\n\tcheckSharedDatabaseArguments,\n\tisFileUrl,\n\tisPostgresUrl,\n\tLIBSQL_ADAPTER_PACKAGE,\n\tmissingTeamToken,\n\tPOSTGRES_ADAPTER_PACKAGE,\n\ttype PostgresAuth,\n\tSTORAGE_TOKEN_FILE,\n\ttype StorageSettingsSelection,\n\tselectStorage,\n} from \"../core/storage/selection.js\";\nimport type { SessionStore } from \"../core/storage/session/types.js\";\nimport { SESSION_FORMAT_VERSION } from \"../core/storage/session/types.js\";\nimport {\n\tcollectStorageStatus,\n\ttype DomainStatus,\n\tdescribeStorageError,\n\tdescribeStorageSelection,\n\teffectiveJournalSelection,\n\tprojectTrust,\n\ttype StorageStatus,\n} from \"../core/storage/storage-status.js\";\nimport { joinSharedDatabase } from \"../core/storage/team.js\";\nimport {\n\tisStorageImportIncompleteError,\n\tisStorageTransferError,\n\ttype TransferredIds,\n} from \"../core/storage/transfer-files.js\";\nimport { importStorage, sessionsTransferDirectory, workflowsTransferDirectory } from \"../core/storage-transfer.ts\";\nimport {\n\tloadWorkerHostModule,\n\ttype WorkerDatabase,\n\ttype WorkerHostModule,\n\tworkerJournalSelection,\n} from \"./worker-command.js\";\n\nexport { LIBSQL_ADAPTER_PACKAGE, STORAGE_TOKEN_FILE };\n\nconst JOIN_USAGE = `${APP_NAME} storage join <url> [--token-file <path> | --password-file <path> | --auth azure|aws|gcp]\n [--prefix <prefix>]`;\n\nconst MIGRATE_USAGE = `${APP_NAME} storage migrate [--db <url> [--password-file <path> | --token-file <path> | --auth azure|aws|gcp]]\n [--prefix <prefix>]`;\n\nconst HELP = `Usage:\n ${APP_NAME} storage status [--json]\n ${JOIN_USAGE}\n ${MIGRATE_USAGE}\n ${APP_NAME} storage adopt <path>... [--no-discover]\n ${APP_NAME} storage consolidate\n ${APP_NAME} storage export <dir> [--sessions] [--workflows] [--run <id>]... [--unfinished]\n [--limit <n>] [--since <time>] [--storage <json> | --storage-file <path>]\n ${APP_NAME} storage import <dir> [--sessions] [--workflows] [--storage <json> | --storage-file <path>]\n\nCommands:\n status Show, for sessions, workflow runs, and Intercom, the selected storage and where the\n selection comes from (environment variable, project or global settings, or default),\n whether its adapter loads, whether its database answers a SELECT 1, and what the running\n Intercom broker uses. Exits 1 when a selection is invalid, an adapter cannot load, or a\n database does not answer. Nothing is created or changed.\n join Use a shared database on this machine: a libSQL / Turso database (libsql://, https://,\n wss:// or file:) through ${LIBSQL_ADAPTER_PACKAGE}, or a PostgreSQL database\n (postgres:// or postgresql://) through ${POSTGRES_ADAPTER_PACKAGE}. Checks the credential\n and the connection (SELECT 1, within 15 seconds), then writes only the global \\`storage\\`\n setting; nothing is written when a check fails. A token or --password-file is stored in\n the agent directory (mode 600); --token-file is referenced where it is, and read again\n for every new connection. Settings hold a file reference, never a password or token.\n Reports environment variables and settings that override it. Creates no tables; Atomic\n creates them on first use.\n migrate Create or upgrade Atomic's tables in a shared database (the journal this machine selects, or\n --db): sessions, workflow runs, worker pools and Intercom. Run it as the database's owner role\n after joining and after each Atomic upgrade, so worker hosts and roots that connect with a\n runtime role (DML privileges only) run no DDL. On PostgreSQL the tables live in schema atomic;\n tables an earlier release created in public are moved there, and processes of that release\n still using public are refused. Running it again on a current schema changes nothing.\n adopt Register existing workflow journal files in the journal store in place, without copying,\n so their runs resolve by ID for status, resume, attach, fork and history://. Each <path>\n is a journal .sqlite file or a directory holding journal.sqlite. Every path is checked\n before the first is registered. Journals the adopted runs were written to are adopted\n too unless --no-discover is given.\n consolidate\n Move finished runs (completed, failed or cancelled, not leased, without local workers)\n from adopted journals into the journal store's own shards. Other runs stay where they\n are. An interrupted consolidation leaves every run readable; run it again to finish.\n export Write sessions to <dir>/sessions/<sessionId>.jsonl (session format version\n ${SESSION_FORMAT_VERSION}, the format \\`${APP_NAME} --import\\` reads) and workflow runs to\n <dir>/workflows/<runId>.jsonl (workflow run export version ${WORKFLOW_RUN_EXPORT_VERSION}), one file per\n session or run. Both kinds by default; --sessions or --workflows limits it to one. Each\n file is replaced whole, one that already holds the same bytes is not rewritten, and no\n file is deleted. A kind kept in a shared libSQL / Turso or PostgreSQL database is skipped\n (an error when --sessions or --workflows asks for it): every machine joined to it reads it\n already. Name the database with --storage or --storage-file to export from it anyway.\n import Restore the sessions in <dir>/sessions and the workflow runs in <dir>/workflows into\n this directory's storage, or the one --storage or --storage-file names; other files are\n ignored. Every file of both kinds is checked\n first, so a malformed or unsupported file changes nothing. Importing again adds\n nothing; a newer export of a session or run adds its later entries. Imported runs are\n not owned by any process: an interrupted one can be resumed here. If the import fails\n after writing part of it, it names what was and was not written; run it again to finish.\n\nOptions:\n --json Print the status as JSON\n --token-file <path> libSQL: file holding the database token, for example from \\`turso db tokens create\\`;\n surrounding whitespace is removed. Required except for file: URLs.\n PostgreSQL: a password or token file another process keeps fresh (a Vault agent,\n a workload-identity sidecar); its path is saved and it is read for every new connection\n --password-file <path>\n PostgreSQL: file holding the database password; it is copied to the agent directory\n (mode 600)\n --auth azure|aws|gcp PostgreSQL: use the platform's identity (Microsoft Entra ID, AWS IAM, Google Cloud\n IAM) instead of a password\n PostgreSQL URLs take exactly one of --password-file, --token-file and --auth, and\n never a password in the URL\n --prefix <prefix> Table prefix, to share one database between projects or teams\n --no-discover adopt: register only the given paths\n --sessions export, import: sessions only (with --workflows too: both)\n --workflows export, import: workflow runs only (with --sessions too: both)\n --run <id> export: only this workflow run; repeat for more\n --unfinished export: only workflow runs that are not completed, failed or cancelled\n --limit <n> export: at most n workflow runs, newest first, and at most n sessions,\n most recently modified first\n --since <time> export: only sessions modified at or after <time>, a date such as\n 2026-11-01 or a date and time such as 2026-11-01T09:30:00Z\n --storage <json> export, import: read from or write to this storage instead of the one selected\n here, given in the form of the \\`storage\\` setting, for example\n {\"path\":\"/path/to/journal.sqlite\"} or an adapter with its options and secrets.\n A shared database named this way is exported from and imported into: use it to\n move runs and sessions between stores\n --storage-file <path> export, import: as --storage, from a JSON file, for example the \\`storage\\`\n value of another machine's settings`;\n\nconst HELP_HINT = `Use \"${APP_NAME} storage --help\" for usage.`;\n\nexport type StorageCommand =\n\t| { readonly kind: \"help\" }\n\t| { readonly kind: \"status\"; readonly json: boolean }\n\t| {\n\t\t\treadonly kind: \"join\";\n\t\t\treadonly url: string;\n\t\t\treadonly tokenFile?: string;\n\t\t\t/** Postgres only. */\n\t\t\treadonly passwordFile?: string;\n\t\t\t/** Postgres only. */\n\t\t\treadonly auth?: PostgresAuth;\n\t\t\treadonly prefix?: string;\n\t }\n\t| {\n\t\t\treadonly kind: \"migrate\";\n\t\t\t/** `--db` and its credential; the journal this machine selects without it. */\n\t\t\treadonly database?: WorkerDatabase;\n\t }\n\t| { readonly kind: \"adopt\"; readonly paths: readonly string[]; readonly discover: boolean }\n\t| { readonly kind: \"consolidate\" }\n\t| ({\n\t\t\treadonly kind: \"export\";\n\t\t\treadonly directory: string;\n\t\t\t/** The kinds to export; both when neither `--sessions` nor `--workflows` is given. */\n\t\t\treadonly kinds: TransferKinds;\n\t\t\treadonly runs?: readonly string[];\n\t\t\treadonly unfinished: boolean;\n\t\t\treadonly limit?: number;\n\t\t\t/** `--since`, in milliseconds since the epoch. */\n\t\t\treadonly since?: number;\n\t } & NamedStorage)\n\t| ({ readonly kind: \"import\"; readonly directory: string; readonly kinds: TransferKinds } & NamedStorage);\n\n/** The storage an export reads or an import writes, named with `--storage` or `--storage-file` instead of selected. */\nexport interface NamedStorage {\n\t/** `--storage`: a selection in the settings form. */\n\treadonly storage?: StorageSettingsSelection;\n\t/** `--storage-file`: a file holding one. */\n\treadonly storageFile?: string;\n}\n\n/** Which kinds an export or import covers, and whether `--sessions` or `--workflows` named them. */\nexport interface TransferKinds {\n\treadonly sessions: boolean;\n\treadonly workflows: boolean;\n\treadonly explicit: boolean;\n}\n\nexport class StorageCommandError extends Error {}\n\n/** Parse the arguments after `storage`. */\nexport function parseStorageCommand(args: readonly string[]): StorageCommand {\n\tconst [command, ...rest] = args;\n\tif (command === undefined || command === \"help\" || args.includes(\"--help\") || args.includes(\"-h\")) {\n\t\treturn { kind: \"help\" };\n\t}\n\tconst positional: string[] = [];\n\tconst values = new Map<string, string>();\n\tlet json = false;\n\tlet discover = true;\n\tlet unfinished = false;\n\tlet sessions = false;\n\tlet workflows = false;\n\tconst runs: string[] = [];\n\tfor (let index = 0; index < rest.length; index++) {\n\t\tconst arg = rest[index]!;\n\t\tif (command === \"status\" && arg === \"--json\") {\n\t\t\tjson = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (command === \"adopt\" && arg === \"--no-discover\") {\n\t\t\tdiscover = false;\n\t\t\tcontinue;\n\t\t}\n\t\tif ((command === \"export\" || command === \"import\") && (arg === \"--sessions\" || arg === \"--workflows\")) {\n\t\t\tif (arg === \"--sessions\") sessions = true;\n\t\t\telse workflows = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (command === \"export\" && arg === \"--unfinished\") {\n\t\t\tunfinished = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (command === \"export\" && arg === \"--run\") {\n\t\t\tconst value = rest[++index];\n\t\t\tif (value === undefined || value === \"\") throw new StorageCommandError(\"--run needs a run ID.\");\n\t\t\truns.push(value);\n\t\t\tcontinue;\n\t\t}\n\t\tif (\n\t\t\t((command === \"join\" || command === \"migrate\") &&\n\t\t\t\t(arg === \"--token-file\" || arg === \"--password-file\" || arg === \"--auth\" || arg === \"--prefix\")) ||\n\t\t\t(command === \"migrate\" && arg === \"--db\") ||\n\t\t\t(command === \"export\" && (arg === \"--limit\" || arg === \"--since\")) ||\n\t\t\t((command === \"export\" || command === \"import\") && (arg === \"--storage\" || arg === \"--storage-file\"))\n\t\t) {\n\t\t\tconst value = rest[++index];\n\t\t\tif (value === undefined) throw new StorageCommandError(`${arg} needs a value.`);\n\t\t\tvalues.set(arg, value);\n\t\t\tcontinue;\n\t\t}\n\t\tif (arg.startsWith(\"-\"))\n\t\t\tthrow new StorageCommandError(`Unknown option ${arg} for \"storage ${command}\".\\n${HELP_HINT}`);\n\t\tpositional.push(arg);\n\t}\n\tif (command === \"status\") {\n\t\tif (positional.length > 0) throw new StorageCommandError(`Usage: ${APP_NAME} storage status [--json]`);\n\t\treturn { kind: \"status\", json };\n\t}\n\tif (command === \"join\") {\n\t\tconst [url, ...extra] = positional;\n\t\tif (url === undefined || extra.length > 0) throw new StorageCommandError(`Usage: ${JOIN_USAGE}`);\n\t\tconst checked = checkSharedDatabaseArguments({\n\t\t\turl,\n\t\t\ttokenFile: values.get(\"--token-file\"),\n\t\t\tpasswordFile: values.get(\"--password-file\"),\n\t\t\tauth: values.get(\"--auth\"),\n\t\t});\n\t\tif (!isPostgresUrl(url) && checked.tokenFile === undefined && !isFileUrl(url)) throw missingTeamToken(url, \"cli\");\n\t\tconst prefix = values.get(\"--prefix\");\n\t\treturn { kind: \"join\", ...checked, ...(prefix === undefined ? {} : { prefix }) };\n\t}\n\tif (command === \"migrate\") {\n\t\tif (positional.length > 0) throw new StorageCommandError(`Usage: ${MIGRATE_USAGE}`);\n\t\tconst url = values.get(\"--db\");\n\t\tif (url === undefined) {\n\t\t\tfor (const option of [\"--token-file\", \"--password-file\", \"--auth\", \"--prefix\"])\n\t\t\t\tif (values.has(option))\n\t\t\t\t\tthrow new StorageCommandError(`${option} qualifies --db; pass the database URL with --db too.`);\n\t\t\treturn { kind: \"migrate\" };\n\t\t}\n\t\tconst checked = checkSharedDatabaseArguments({\n\t\t\turl,\n\t\t\ttokenFile: values.get(\"--token-file\"),\n\t\t\tpasswordFile: values.get(\"--password-file\"),\n\t\t\tauth: values.get(\"--auth\"),\n\t\t});\n\t\tconst prefix = values.get(\"--prefix\");\n\t\treturn {\n\t\t\tkind: \"migrate\",\n\t\t\tdatabase: {\n\t\t\t\turl,\n\t\t\t\t...(checked.tokenFile === undefined ? {} : { tokenFile: checked.tokenFile }),\n\t\t\t\t...(checked.passwordFile === undefined ? {} : { passwordFile: checked.passwordFile }),\n\t\t\t\t...(checked.auth === undefined ? {} : { auth: checked.auth }),\n\t\t\t\t...(prefix === undefined ? {} : { prefix }),\n\t\t\t},\n\t\t};\n\t}\n\tif (command === \"adopt\") {\n\t\tif (positional.length === 0)\n\t\t\tthrow new StorageCommandError(`Usage: ${APP_NAME} storage adopt <path>... [--no-discover]`);\n\t\treturn { kind: \"adopt\", paths: positional, discover };\n\t}\n\tif (command === \"consolidate\") {\n\t\tif (positional.length > 0) throw new StorageCommandError(`Usage: ${APP_NAME} storage consolidate`);\n\t\treturn { kind: \"consolidate\" };\n\t}\n\tconst named = namedStorage(values);\n\tconst kinds: TransferKinds =\n\t\tsessions || workflows\n\t\t\t? { sessions, workflows, explicit: true }\n\t\t\t: { sessions: true, workflows: true, explicit: false };\n\tif (command === \"export\") {\n\t\tconst [directory, ...extra] = positional;\n\t\tif (directory === undefined || extra.length > 0)\n\t\t\tthrow new StorageCommandError(\n\t\t\t\t`Usage: ${APP_NAME} storage export <dir> [--sessions] [--workflows] [--run <id>]... [--unfinished] [--limit <n>] [--since <time>]`,\n\t\t\t);\n\t\tconst limitText = values.get(\"--limit\");\n\t\tconst limit = limitText === undefined ? undefined : Number(limitText);\n\t\tif (limit !== undefined && (!/^[0-9]+$/.test(limitText!) || !Number.isSafeInteger(limit) || limit < 1))\n\t\t\tthrow new StorageCommandError(`--limit needs a positive whole number, not \"${limitText}\".`);\n\t\tconst sinceText = values.get(\"--since\");\n\t\tconst since = sinceText === undefined ? undefined : Date.parse(sinceText);\n\t\tif (since !== undefined && Number.isNaN(since))\n\t\t\tthrow new StorageCommandError(\n\t\t\t\t`--since needs a date such as 2026-11-01 or a date and time such as 2026-11-01T09:30:00Z, not \"${sinceText}\".`,\n\t\t\t);\n\t\tif (!kinds.workflows && (runs.length > 0 || unfinished))\n\t\t\tthrow new StorageCommandError(\n\t\t\t\t`${runs.length > 0 ? \"--run\" : \"--unfinished\"} selects workflow runs, which --sessions alone does not export.`,\n\t\t\t);\n\t\tif (!kinds.sessions && since !== undefined)\n\t\t\tthrow new StorageCommandError(\"--since selects sessions, which --workflows alone does not export.\");\n\t\treturn {\n\t\t\tkind: \"export\",\n\t\t\tdirectory,\n\t\t\tkinds,\n\t\t\tunfinished,\n\t\t\t...(runs.length === 0 ? {} : { runs }),\n\t\t\t...(limit === undefined ? {} : { limit }),\n\t\t\t...(since === undefined ? {} : { since }),\n\t\t\t...named,\n\t\t};\n\t}\n\tif (command === \"import\") {\n\t\tconst [directory, ...extra] = positional;\n\t\tif (directory === undefined || extra.length > 0)\n\t\t\tthrow new StorageCommandError(`Usage: ${APP_NAME} storage import <dir> [--sessions] [--workflows]`);\n\t\treturn { kind: \"import\", directory, kinds, ...named };\n\t}\n\tthrow new StorageCommandError(`Unknown storage command \"${command}\".\\n${HELP_HINT}`);\n}\n\nfunction namedStorage(values: ReadonlyMap<string, string>): NamedStorage {\n\tconst text = values.get(\"--storage\");\n\tconst storageFile = values.get(\"--storage-file\");\n\tif (text !== undefined && storageFile !== undefined)\n\t\tthrow new StorageCommandError(\"Pass only one of --storage and --storage-file.\");\n\tif (storageFile !== undefined) return { storageFile };\n\tif (text === undefined) return {};\n\treturn { storage: storageSelectionJson(text, \"--storage\") };\n}\n\n/** A selection in the settings form, from JSON text; `field` names where it came from. */\nfunction storageSelectionJson(text: string, field: string): StorageSettingsSelection {\n\tlet value: StorageSettingsSelection | null;\n\ttry {\n\t\tvalue = JSON.parse(text) as StorageSettingsSelection | null;\n\t} catch {\n\t\tvalue = null;\n\t}\n\tif (value === null || typeof value !== \"object\" || Array.isArray(value))\n\t\tthrow new StorageCommandError(\n\t\t\t`${field} needs a JSON object in the form of the \\`storage\\` setting, for example {\"path\":\"/path/to/journal.sqlite\"}.`,\n\t\t);\n\treturn value;\n}\n\n/** The selection `--storage` or `--storage-file` names, checked like a settings selection; undefined for neither. */\nfunction namedSelection(command: NamedStorage, cwd: string): StorageSelection | undefined {\n\tlet value = command.storage;\n\tconst field = command.storageFile === undefined ? \"--storage\" : \"--storage-file\";\n\tif (command.storageFile !== undefined) {\n\t\tconst path = resolve(cwd, command.storageFile);\n\t\tlet text: string;\n\t\ttry {\n\t\t\ttext = readFileSync(path, \"utf8\");\n\t\t} catch (error) {\n\t\t\tthrow new StorageCommandError(`--storage-file ${path} cannot be read: ${errorText(error as Error)}.`);\n\t\t}\n\t\tvalue = storageSelectionJson(text, `--storage-file ${path}`);\n\t}\n\tif (value === undefined) return undefined;\n\tconst selection = selectStorage(value, \"cli\", field, \"\");\n\tif (selection.kind !== \"sqlite\") return selection;\n\tif (selection.path === \":memory:\") return { kind: \"memory\" };\n\tif (selection.path === \"\")\n\t\tthrow new StorageCommandError(`${field} names no storage: give a \"path\" or an \"adapter\" with its options.`);\n\treturn { ...selection, path: resolve(cwd, selection.path) };\n}\n\nexport interface StorageCommandOptions {\n\treadonly cwd: string;\n\treadonly agentDir: string;\n\treadonly log?: (line: string) => void;\n\treadonly error?: (line: string) => void;\n\t/** Defaults to the bundled Intercom package's broker control. */\n\treadonly loadControl?: () => Promise<IntercomBrokerControl>;\n\t/** `migrate`: defaults to the bundled workflows package's public entry. */\n\treadonly loadWorkerModule?: () => Promise<Pick<WorkerHostModule, \"migrateWorkflowStorage\">>;\n\t/** `migrate`: defaults to the bundled Intercom package's broker state opener. */\n\treadonly loadBrokerState?: () => Promise<BrokerStateModule>;\n}\n\nconst errorText = describeStorageError;\n\n/** The bundled Intercom package's broker control, or why it could not load. */\nexport async function loadBrokerControl(options: {\n\treadonly loadControl?: () => Promise<IntercomBrokerControl>;\n}): Promise<IntercomBrokerControl | Error> {\n\ttry {\n\t\tif (options.loadControl) return await options.loadControl();\n\t\tconst { loadIntercomBrokerControl } = await import(\"../core/intercom-broker-control.js\");\n\t\treturn await loadIntercomBrokerControl();\n\t} catch (error) {\n\t\treturn error instanceof Error ? error : new Error(String(error));\n\t}\n}\n\n/** Whether a domain's selection is invalid, its adapter cannot load, or its database did not answer. */\nexport function failed(domain: DomainStatus): boolean {\n\treturn (\n\t\tdomain.error !== undefined ||\n\t\tdomain.probe?.adapter?.loaded === false ||\n\t\tdomain.probe?.connection.status === \"failed\" ||\n\t\t(domain.journalStore?.unavailable.length ?? 0) > 0\n\t);\n}\n\nconst DOMAIN_LABELS: Record<DomainStatus[\"domain\"], string> = {\n\tsessions: \"Sessions\",\n\tjournal: \"Workflow runs\",\n\tintercom: \"Intercom\",\n};\n\n/** The status as the lines `atomic storage status` prints. */\nexport function formatStorageStatus(status: StorageStatus): string[] {\n\tconst lines = [\n\t\t`Agent directory: ${status.agentDir}`,\n\t\t`Project: ${status.cwd}${status.projectTrusted ? \"\" : \" (not trusted)\"}`,\n\t];\n\tfor (const domain of status.domains) {\n\t\tlines.push(\"\", `${DOMAIN_LABELS[domain.domain]}: ${domain.selection}`);\n\t\tlines.push(` source: ${domain.source}`);\n\t\tif (domain.overridden.length > 0) lines.push(` overrides: ${domain.overridden.join(\", \")}`);\n\t\tif (domain.error !== undefined) lines.push(` error: ${domain.error}`);\n\t\tconst probe = domain.probe;\n\t\tif (probe?.sameAs !== undefined) {\n\t\t\tlines.push(` connection: same as ${DOMAIN_LABELS[probe.sameAs].toLowerCase()}`);\n\t\t} else if (probe !== undefined) {\n\t\t\tif (probe.adapter !== undefined) {\n\t\t\t\tlines.push(\n\t\t\t\t\t` adapter: ${probe.adapter.loaded ? \"loaded\" : \"failed to load\"}${probe.adapter.detail === undefined ? \"\" : ` (${probe.adapter.detail})`}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tlines.push(` connection: ${probe.connection.status} (${probe.connection.detail})`);\n\t\t}\n\t\tif (domain.multiNode !== undefined) lines.push(` multi-node: ${domain.multiNode}`);\n\t\tif (domain.liveBrokers !== undefined) {\n\t\t\tlines.push(\n\t\t\t\t` brokers: ${domain.liveBrokers.length} live in the database${domain.liveBrokers.length === 0 ? \"\" : ` (${[...new Set(domain.liveBrokers)].join(\", \")})`}`,\n\t\t\t);\n\t\t}\n\t\tconst store = domain.journalStore;\n\t\tif (store !== undefined) {\n\t\t\tlines.push(\n\t\t\t\t` journals: ${store.shards} shard${store.shards === 1 ? \"\" : \"s\"}, ${store.adopted} adopted journal${store.adopted === 1 ? \"\" : \"s\"}, ${store.runs} run${store.runs === 1 ? \"\" : \"s\"}`,\n\t\t\t);\n\t\t\tfor (const shard of store.unavailable)\n\t\t\t\tlines.push(\n\t\t\t\t\t` unavailable: ${shard.path} (${shard.kind}, ${shard.code === \"shard-missing\" ? \"no longer exists\" : \"cannot be opened\"}: ${shard.code}${shard.detail === undefined ? \"\" : `, ${shard.detail}`})`,\n\t\t\t\t);\n\t\t\tfor (const skipped of store.skipped) lines.push(` skipped: ${skipped.path} (${skipped.reason})`);\n\t\t}\n\t}\n\tconst broker = status.broker;\n\tif (broker !== undefined) {\n\t\tlines.push(\"\");\n\t\tif (broker.state === \"stopped\") {\n\t\t\tlines.push(\n\t\t\t\t\"Intercom broker: not running (the next session that uses Intercom starts one with the selection above)\",\n\t\t\t);\n\t\t} else if (broker.state === \"unknown\") {\n\t\t\tlines.push(`Intercom broker: unknown (${broker.error ?? \"no answer\"})`);\n\t\t} else if (broker.state === \"legacy\") {\n\t\t\tlines.push(\n\t\t\t\t`Intercom broker: running${broker.pid === undefined ? \"\" : ` (pid ${broker.pid})`}, started by an older Atomic that does not report its storage; run \\`${APP_NAME} intercom restart\\``,\n\t\t\t);\n\t\t} else {\n\t\t\tlines.push(\n\t\t\t\t`Intercom broker: running (pid ${broker.pid}, ${broker.sessions} session${broker.sessions === 1 ? \"\" : \"s\"} connected)`,\n\t\t\t);\n\t\t\tlines.push(\n\t\t\t\tbroker.matchesCurrent\n\t\t\t\t\t? \" storage: matches the selection above\"\n\t\t\t\t\t: ` storage: differs from the selection above${broker.source === \"env\" ? \" (a session started it with ATOMIC_STORAGE, ATOMIC_PROFILE=ci or --storage)\" : \"\"}; run \\`${APP_NAME} intercom restart\\` to use the current one`,\n\t\t\t);\n\t\t\tif (broker.multiNodeLine !== undefined) lines.push(` multi-node: ${broker.multiNodeLine}`);\n\t\t}\n\t}\n\tif (status.notes.length > 0) lines.push(\"\", \"Notes:\", ...status.notes.map((note) => ` - ${note}`));\n\treturn lines;\n}\n\nasync function status(json: boolean, options: StorageCommandOptions, log: (line: string) => void): Promise<number> {\n\tconst control = await loadBrokerControl(options);\n\tconst collected = await collectStorageStatus({\n\t\tcwd: options.cwd,\n\t\tagentDir: options.agentDir,\n\t\tprobe: true,\n\t\t...(control instanceof Error ? {} : { control }),\n\t});\n\tconst result: StorageStatus =\n\t\tcontrol instanceof Error ? { ...collected, broker: { state: \"unknown\", error: errorText(control) } } : collected;\n\tif (json) log(JSON.stringify(result, null, 2));\n\telse for (const line of formatStorageStatus(result)) log(line);\n\treturn result.domains.some(failed) ? 1 : 0;\n}\n\nasync function joinStorage(\n\tcommand: Extract<StorageCommand, { kind: \"join\" }>,\n\toptions: StorageCommandOptions,\n\tlog: (...lines: string[]) => void,\n): Promise<number> {\n\tconst { agentDir, cwd } = options;\n\tconst joined = await joinSharedDatabase({ ...command, agentDir, cwd, pinLocalSessions: false }, \"cli\");\n\tlog(`Connected to ${command.url}.`);\n\tconst secret = command.passwordFile === undefined ? \"token\" : \"password\";\n\tif (joined.tokenPath !== undefined) {\n\t\tlog(\n\t\t\tjoined.token === \"reused\"\n\t\t\t\t? `Kept the ${secret} in ${joined.tokenPath}; it already holds this ${secret}.`\n\t\t\t\t: `Stored the ${secret} in ${joined.tokenPath} (mode 600).`,\n\t\t);\n\t}\n\tif (joined.referencedFile !== undefined)\n\t\tlog(`The password stays in ${joined.referencedFile} and is read again for every new connection.`);\n\tif (command.auth !== undefined) log(`The adapter obtains a ${command.auth} credential for every new connection.`);\n\tlog(`Set \\`storage\\` in ${join(agentDir, \"settings.json\")}; other settings are unchanged.`);\n\tif (joined.replaced !== undefined) log(`It replaces the previous selection: ${joined.replaced}.`);\n\n\tconst control = await loadBrokerControl(options);\n\tlet collected: StorageStatus;\n\ttry {\n\t\tcollected = await collectStorageStatus({\n\t\t\tcwd,\n\t\t\tagentDir,\n\t\t\tprobe: false,\n\t\t\t...(control instanceof Error ? {} : { control }),\n\t\t});\n\t} catch (error) {\n\t\t// Settings and the token are already committed; optional diagnostics cannot undo that success.\n\t\tlog(`Storage was saved, but could not report overrides: ${errorText(error as Error)}.`);\n\t\tlog(`Run \\`${APP_NAME} storage status\\` after fixing the reported settings error.`);\n\t\treturn 0;\n\t}\n\tconst overridden = collected.domains.filter(\n\t\t(domain) => domain.source !== \"global settings: storage\" && domain.source !== \"default\",\n\t);\n\tif (overridden.length > 0) {\n\t\tlog(\"\", \"These take precedence over the new selection here:\");\n\t\tfor (const domain of overridden) log(` - ${DOMAIN_LABELS[domain.domain]}: ${domain.source}`);\n\t}\n\tfor (const note of collected.notes) log(`Note: ${note}`);\n\tconst broker = collected.broker;\n\tif (broker?.state === \"running\" && !broker.matchesCurrent) {\n\t\tlog(\n\t\t\t`The running Intercom broker (pid ${broker.pid}) still uses its previous selection. Run \\`${APP_NAME} intercom restart\\` so it uses the new one.`,\n\t\t);\n\t} else if (broker?.state === \"legacy\") {\n\t\tlog(\n\t\t\t`An Intercom broker from an older ${APP_NAME} is running. Run \\`${APP_NAME} intercom restart\\` to replace it.`,\n\t\t);\n\t}\n\tlog(`Run \\`${APP_NAME} storage status\\` to check each domain.`);\n\treturn 0;\n}\n\n/** Run `atomic storage <args>` and return the exit code. */\nexport async function runStorageCommand(args: readonly string[], options: StorageCommandOptions): Promise<number> {\n\tconst log = options.log ?? ((line: string) => console.log(line));\n\tconst error = options.error ?? ((line: string) => console.error(line));\n\ttry {\n\t\tconst command = parseStorageCommand(args);\n\t\tif (command.kind === \"help\") {\n\t\t\tlog(HELP);\n\t\t\treturn 0;\n\t\t}\n\t\tif (command.kind === \"status\") return await status(command.json, options, log);\n\t\tif (command.kind === \"adopt\") return await adopt(command, options, log);\n\t\tif (command.kind === \"consolidate\") return await consolidate(options, log);\n\t\tif (command.kind === \"migrate\") return await migrate(command, options, log);\n\t\tif (command.kind === \"export\") return await exportRuns(command, options, log, error);\n\t\tif (command.kind === \"import\") return await importRuns(command, options, log, error);\n\t\treturn await joinStorage(command, options, (...lines) => {\n\t\t\tfor (const line of lines) log(line);\n\t\t});\n\t} catch (caught) {\n\t\tif (isJournalStoreError(caught)) {\n\t\t\terror(caught.message);\n\t\t\tif (caught.hint !== undefined) error(caught.hint);\n\t\t\treturn 1;\n\t\t}\n\t\terror(\n\t\t\tcaught instanceof StorageCommandError ||\n\t\t\t\tisStorageTransferError(caught) ||\n\t\t\t\tisTeamProfileError(caught) ||\n\t\t\t\tisTeamProfileConfigError(caught)\n\t\t\t\t? caught.message\n\t\t\t\t: `Error: ${errorText(caught as Error)}`,\n\t\t);\n\t\treturn 1;\n\t}\n}\n\n/** Intercom's broker state opener, as the bundled Intercom package's `broker/open-broker-state` module exports it. */\ninterface BrokerStateModule {\n\topenIntercomBrokerState(source: {\n\t\treadonly prefix?: string;\n\t\treadonly openDatabase: () => Promise<SqliteDatabase>;\n\t}): Promise<{ readonly state: { close(): Promise<void> }; readonly bus: { close(): Promise<void> } }>;\n}\n\n/** Loads the bundled Intercom package's broker state opener, as extensions see the host's modules. */\nasync function loadBrokerStateModule(): Promise<BrokerStateModule> {\n\tconst intercom = getBuiltinPackageLocations().find(({ distDirName }) => distDirName === \"intercom\");\n\tif (intercom === undefined) throw new Error(\"The bundled Intercom package was not found.\");\n\tconst modulePath = [\"broker/open-broker-state.ts\", \"broker/open-broker-state.js\"]\n\t\t.map((path) => join(intercom.packageDir, path))\n\t\t.find((path) => existsSync(path));\n\tif (modulePath === undefined) throw new Error(\"The bundled Intercom package has no broker state module.\");\n\tconst [{ createHostModuleJiti }, { getVirtualModules }] = await Promise.all([\n\t\timport(\"../core/extensions/loader-virtual-modules.js\"),\n\t\timport(\"../core/extensions/loader-host-modules.js\"),\n\t]);\n\tconst loader = await createHostModuleJiti(pathToFileURL(modulePath).href, await getVirtualModules());\n\treturn loader.import<BrokerStateModule>(modulePath);\n}\n\n/**\n * `atomic storage migrate` (#5218): sets up or upgrades every store's tables in the shared database, as its owner role.\n * On PostgreSQL, tables an earlier release created in `public` move to schema `atomic` first.\n */\nasync function migrate(\n\tcommand: Extract<StorageCommand, { kind: \"migrate\" }>,\n\toptions: StorageCommandOptions,\n\tlog: (line: string) => void,\n): Promise<number> {\n\tconst { agentDir, cwd } = options;\n\tconst database = command.database === undefined ? undefined : { ...command.database };\n\tif (database?.tokenFile !== undefined) database.tokenFile = resolve(cwd, database.tokenFile);\n\tif (database?.passwordFile !== undefined) database.passwordFile = resolve(cwd, database.passwordFile);\n\tconst settings = database === undefined ? undefined : workerJournalSelection(database);\n\tconst selection =\n\t\tsettings === undefined\n\t\t\t? effectiveJournalSelection(cwd, agentDir)\n\t\t\t: selectStorage(settings as StorageSettingsSelection, \"cli\", \"--db\", \"\");\n\tif (selection.kind !== \"adapter\") {\n\t\tlog(\n\t\t\t`Workflow runs here use ${describeStorageSelection(selection)}, which sets itself up on first use; there is nothing to migrate.`,\n\t\t);\n\t\treturn 0;\n\t}\n\tconst open = (domain: \"journal\" | \"intercom\") => openAdapterSelectionDatabase(selection, { agentDir, domain });\n\tconst opened = await open(\"journal\");\n\ttry {\n\t\tconst explicitSchema = (selection.options as { schema?: unknown }).schema !== undefined;\n\t\tif (dialectOf(opened).name === \"postgres\" && !explicitSchema) {\n\t\t\tconst row = await opened.get<SqliteRow & { schema: string | null }>(\"SELECT current_schema() AS schema\");\n\t\t\tif (row?.schema === \"public\") {\n\t\t\t\tconst moved = await movePostgresStorageToSchema(opened);\n\t\t\t\tlog(\n\t\t\t\t\tmoved.skipped\n\t\t\t\t\t\t? `Another \\`${APP_NAME} storage migrate\\` moved the tables to schema ${POSTGRES_ATOMIC_SCHEMA} first.`\n\t\t\t\t\t\t: `Moved ${moved.tables.length} table${moved.tables.length === 1 ? \"\" : \"s\"} and ${moved.functions.length} trigger function${moved.functions.length === 1 ? \"\" : \"s\"} from schema public to schema ${POSTGRES_ATOMIC_SCHEMA}; processes of an earlier Atomic still using public are refused until they are upgraded.`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t} finally {\n\t\tawait opened.close();\n\t}\n\tawait (await new StorageProvider().openSessionStore(selection, { agentDir, domain: \"sessions\" })).close();\n\tconst workflows = await (options.loadWorkerModule ?? loadWorkerHostModule)();\n\tif (workflows.migrateWorkflowStorage === undefined)\n\t\tthrow new Error(\"The bundled workflows package cannot migrate storage; reinstall Atomic.\");\n\tawait workflows.migrateWorkflowStorage({ ...(settings === undefined ? {} : { journal: settings }), agentDir });\n\tconst intercom = await (options.loadBrokerState ?? loadBrokerStateModule)();\n\tconst broker = await intercom.openIntercomBrokerState({\n\t\t...(selection.prefix === undefined ? {} : { prefix: selection.prefix }),\n\t\topenDatabase: () => open(\"intercom\"),\n\t});\n\tawait broker.bus.close();\n\tawait broker.state.close();\n\t// Tables created in public after the move hold state the moved ones do not (#5218).\n\tconst checked = await open(\"journal\");\n\tlet strays: string[];\n\tlet withoutTrigrams: boolean;\n\ttry {\n\t\tstrays = await strayPostgresStorageTables(checked);\n\t\twithoutTrigrams = dialectOf(checked).name === \"postgres\" && !(await hasPostgresExtension(checked, \"pg_trgm\"));\n\t} finally {\n\t\tawait checked.close();\n\t}\n\tif (strays.length > 0) {\n\t\tlog(\n\t\t\t`Found ${strays.length} of Atomic's table${strays.length === 1 ? \"\" : \"s\"} in schema public that a process created after the move to schema ${POSTGRES_ATOMIC_SCHEMA}: ${strays.join(\", \")}. A process of an earlier Atomic, or one started before the move, still uses public, and what it wrote there is not in schema ${POSTGRES_ATOMIC_SCHEMA}. Stop or upgrade it, then drop those tables, or copy what you need into schema ${POSTGRES_ATOMIC_SCHEMA} first.`,\n\t\t);\n\t\treturn 1;\n\t}\n\tlog(\n\t\t`Atomic's tables in ${describeStorageSelection(selection)} are set up for this version: sessions, workflow runs, worker pools and Intercom.`,\n\t);\n\tif (withoutTrigrams)\n\t\tlog(\n\t\t\t`Searches of session history will read each session a page at a time: the pg_trgm extension, which their index uses, is not installed in this database and this role could not install it. On Azure Database for PostgreSQL and Azure HorizonDB, add pg_trgm to the server parameter azure.extensions; elsewhere, grant this role CREATE on the database or have an administrator run CREATE EXTENSION pg_trgm in it. Then run \\`${APP_NAME} storage migrate\\` again.`,\n\t\t);\n\treturn 0;\n}\n\n/** Whether the PostgreSQL extension `name` is installed in `database`'s current database. */\nasync function hasPostgresExtension(database: SqliteDatabase, name: string): Promise<boolean> {\n\treturn (\n\t\t(await database.get(\"SELECT 1 AS present FROM pg_catalog.pg_extension WHERE extname = ?\", name)) !== undefined\n\t);\n}\n\n/** A note when this directory's workflow runs use another journal than the journal store `adopt` writes to. */\nfunction storeSelectionNote(options: StorageCommandOptions, directory: string): string | undefined {\n\tconst selection = effectiveJournalSelection(options.cwd, options.agentDir);\n\tif (selection.kind === \"sharded\") return undefined;\n\treturn `Note: workflow runs here use ${describeStorageSelection(selection)}, so they see the journal store ${directory} only once that selection is removed.`;\n}\n\nasync function adopt(\n\tcommand: Extract<StorageCommand, { kind: \"adopt\" }>,\n\toptions: StorageCommandOptions,\n\tlog: (line: string) => void,\n): Promise<number> {\n\tconst directory = defaultJournalStoreDirectory(options.agentDir);\n\tconst report = await adoptJournals(\n\t\tdirectory,\n\t\tcommand.paths.map((path) => resolve(options.cwd, path)),\n\t\t{ discover: command.discover },\n\t);\n\tfor (const outcome of report.adopted) {\n\t\tlog(\n\t\t\toutcome.status === \"adopted\"\n\t\t\t\t? `Adopted ${outcome.path} in place (shard ${outcome.shardId}, ${outcome.runs} run${outcome.runs === 1 ? \"\" : \"s\"}).`\n\t\t\t\t: `Already registered: ${outcome.path} (shard ${outcome.shardId}).`,\n\t\t);\n\t}\n\tfor (const record of report.discovered) {\n\t\tlog(\n\t\t\trecord.outcome === \"skipped\"\n\t\t\t\t? `Skipped ${record.path}, referenced by runs in ${record.referencedBy} (${record.reason}).`\n\t\t\t\t: `Adopted ${record.path}, referenced by runs in ${record.referencedBy}.`,\n\t\t);\n\t}\n\tconst note = storeSelectionNote(options, directory);\n\tif (note !== undefined) log(note);\n\treturn 0;\n}\n\nasync function consolidate(options: StorageCommandOptions, log: (line: string) => void): Promise<number> {\n\tconst directory = defaultJournalStoreDirectory(options.agentDir);\n\tconst report = await consolidateJournalStore(directory);\n\tlog(`Moved ${report.moved} finished run${report.moved === 1 ? \"\" : \"s\"} into the journal store's shards.`);\n\tconst reasons = new Map<string, number>();\n\tfor (const run of report.runs)\n\t\tif (run.outcome === \"skipped\") reasons.set(run.reason, (reasons.get(run.reason) ?? 0) + 1);\n\tfor (const [reason, count] of reasons)\n\t\tlog(`Skipped completing consolidation for ${count} run${count === 1 ? \"\" : \"s\"}: ${reason}.`);\n\tconst failures = new Map<string, string>();\n\tfor (const run of report.runs)\n\t\tif (run.error !== undefined) failures.set(run.error.message, `${run.error.message} ${run.error.hint}`);\n\tfor (const failure of failures.values()) log(failure);\n\tconst note = storeSelectionNote(options, directory);\n\tif (note !== undefined) log(note);\n\treturn failures.size === 0 ? 0 : 1;\n}\n\n/** What an export or import of one kind reads or writes, or why that kind is refused here. */\ntype Transfer<T> = { readonly target: T } | { readonly refused: string };\n\n/**\n * The local workflow journal this directory's runs use, which `export` and `import` read and write. A shared database\n * is refused: every machine joined to it already reads its runs, so there is nothing to carry between them.\n */\nfunction workflowTransfer(\n\toptions: StorageCommandOptions,\n\tcommand: \"export\" | \"import\",\n\tnamed: StorageSelection | undefined,\n): Transfer<WorkflowRunTransferStorage> {\n\tif (named?.kind === \"adapter\")\n\t\treturn {\n\t\t\ttarget: {\n\t\t\t\tkind: \"database\",\n\t\t\t\topen: () => openAdapterSelectionDatabase(named, { agentDir: options.agentDir, domain: \"journal\" }),\n\t\t\t\tlocation: describeStorageSelection(named),\n\t\t\t\tprefix: named.prefix,\n\t\t\t},\n\t\t};\n\tconst selection = named ?? effectiveJournalSelection(options.cwd, options.agentDir);\n\tif (selection.kind === \"sharded\") return { target: { kind: \"store\", directory: selection.dir } };\n\tif (selection.kind === \"sqlite\" && selection.path !== \":memory:\")\n\t\treturn {\n\t\t\ttarget: {\n\t\t\t\tkind: \"sqlite\",\n\t\t\t\tpath: resolve(options.cwd, selection.path),\n\t\t\t\t...(selection.prefix === undefined ? {} : { prefix: selection.prefix }),\n\t\t\t},\n\t\t};\n\treturn {\n\t\trefused:\n\t\t\t`${APP_NAME} storage ${command} works with a local workflow journal (the journal store or a SQLite file), but workflow runs here use ${describeStorageSelection(selection)}.` +\n\t\t\t(selection.kind === \"adapter\"\n\t\t\t\t? \" A shared database already holds the runs of every machine joined to it, so there is nothing to export or import; use its own backups, or name it with --storage or --storage-file to copy runs and sessions out of it or into it.\"\n\t\t\t\t: \"\"),\n\t};\n}\n\n/**\n * The session storage this directory selects, as a session started here would open it: the default database, a JSONL\n * directory, a SQLite file or an adapter. A shared libSQL / Turso database is refused as it is for workflow runs, and so\n * is in-memory storage, which keeps nothing. Undefined target for an export when nothing has been stored yet, so an\n * export creates no database.\n */\nasync function sessionTransfer(\n\toptions: StorageCommandOptions,\n\tcommand: \"export\" | \"import\",\n\tnamed: StorageSelection | undefined,\n): Promise<Transfer<SessionStore | undefined>> {\n\tif (named !== undefined) {\n\t\tif (named.kind !== \"sqlite\" && named.kind !== \"adapter\")\n\t\t\treturn {\n\t\t\t\trefused: `${APP_NAME} storage ${command} needs stored sessions, but ${describeStorageSelection(named)} keeps nothing.`,\n\t\t\t};\n\t\tif (command === \"export\" && named.kind === \"sqlite\" && !existsSync(named.path)) return { target: undefined };\n\t\treturn {\n\t\t\ttarget: await new StorageProvider().openSessionStore(named, {\n\t\t\t\tagentDir: options.agentDir,\n\t\t\t\tdomain: \"sessions\",\n\t\t\t}),\n\t\t};\n\t}\n\tconst settings = SettingsManager.create(options.cwd, options.agentDir, {\n\t\tprojectTrusted: projectTrust(options.cwd, options.agentDir),\n\t}).getSettings();\n\tconst storageOptions = { agentDir: options.agentDir, settings };\n\tconst selection = selectSessionStorageWithSettings(options.cwd, storageOptions);\n\tif (!(\"load\" in selection)) {\n\t\tif (selection.kind === \"memory\" || (selection.kind === \"sqlite\" && selection.path === \":memory:\"))\n\t\t\treturn {\n\t\t\t\trefused: `${APP_NAME} storage ${command} needs stored sessions, but sessions here use ${describeStorageSelection(selection)}, which keeps nothing.`,\n\t\t\t};\n\t\tif (\n\t\t\tselection.kind === \"adapter\" &&\n\t\t\t(selection.module === LIBSQL_ADAPTER_PACKAGE || selection.module === POSTGRES_ADAPTER_PACKAGE)\n\t\t)\n\t\t\treturn {\n\t\t\t\trefused: `${APP_NAME} storage ${command} works with local session storage, but sessions here use ${describeStorageSelection(selection)}. A shared database already holds the sessions of every machine joined to it, so there is nothing to export or import; use its own backups, or name it with --storage or --storage-file to copy runs and sessions out of it or into it.`,\n\t\t\t};\n\t\tif (command === \"export\") {\n\t\t\tconst stored =\n\t\t\t\tselection.kind === \"jsonl\"\n\t\t\t\t\t? existsSync(selection.dir)\n\t\t\t\t\t: selection.kind !== \"sqlite\" ||\n\t\t\t\t\t\texistsSync(resolve(options.cwd, selection.path)) ||\n\t\t\t\t\t\texistsSync(join(options.agentDir, \"sessions\"));\n\t\t\tif (!stored) return { target: undefined };\n\t\t}\n\t}\n\treturn { target: await resolveSessionStore(options.cwd, storageOptions) };\n}\n\nconst plural = (count: number, noun: string) => `${count} ${noun}${count === 1 ? \"\" : \"s\"}`;\n\nasync function exportRuns(\n\tcommand: Extract<StorageCommand, { kind: \"export\" }>,\n\toptions: StorageCommandOptions,\n\tlog: (line: string) => void,\n\terror: (line: string) => void,\n): Promise<number> {\n\tconst directory = resolve(options.cwd, command.directory);\n\tconst named = namedSelection(command, options.cwd);\n\tconst workflows = command.kinds.workflows ? workflowTransfer(options, \"export\", named) : undefined;\n\tconst sessions = command.kinds.sessions ? await sessionTransfer(options, \"export\", named) : undefined;\n\ttry {\n\t\tconst refusals = [workflows, sessions].flatMap((transfer) =>\n\t\t\ttransfer !== undefined && \"refused\" in transfer ? [transfer.refused] : [],\n\t\t);\n\t\tconst kinds = Number(command.kinds.sessions) + Number(command.kinds.workflows);\n\t\tif (refusals.length > 0 && (command.kinds.explicit || refusals.length === kinds))\n\t\t\tthrow new StorageCommandError(refusals.join(\"\\n\"));\n\t\tfor (const refused of refusals) error(`Skipped: ${refused}`);\n\t\t// Workflow runs first: an unknown --run fails the export before any file of either kind is written.\n\t\tif (workflows !== undefined && \"target\" in workflows) {\n\t\t\tconst target = workflowsTransferDirectory(directory);\n\t\t\tconst report = await exportWorkflowRuns(workflows.target, target, {\n\t\t\t\tunfinished: command.unfinished,\n\t\t\t\t...(command.runs === undefined ? {} : { runs: command.runs }),\n\t\t\t\t...(command.limit === undefined ? {} : { limit: command.limit }),\n\t\t\t});\n\t\t\tconst total = report.written.length + report.unchanged.length;\n\t\t\tlog(\n\t\t\t\t`Exported ${plural(total, \"workflow run\")} to ${target} (${report.written.length} written, ${report.unchanged.length} unchanged).`,\n\t\t\t);\n\t\t\tfor (const skipped of report.skipped)\n\t\t\t\terror(\n\t\t\t\t\t`Skipped ${skipped.runId === undefined ? skipped.path : `run ${skipped.runId} (${skipped.path})`}: ${skipped.reason}.`,\n\t\t\t\t);\n\t\t}\n\t\tif (sessions !== undefined && \"target\" in sessions) {\n\t\t\tconst target = sessionsTransferDirectory(directory);\n\t\t\tconst report =\n\t\t\t\tsessions.target === undefined\n\t\t\t\t\t? { written: [], unchanged: [] }\n\t\t\t\t\t: await exportSessions(sessions.target, target, {\n\t\t\t\t\t\t\t...(command.limit === undefined ? {} : { limit: command.limit }),\n\t\t\t\t\t\t\t...(command.since === undefined ? {} : { since: command.since }),\n\t\t\t\t\t\t});\n\t\t\tconst total = report.written.length + report.unchanged.length;\n\t\t\tlog(\n\t\t\t\t`Exported ${plural(total, \"session\")} to ${target} (${report.written.length} written, ${report.unchanged.length} unchanged).`,\n\t\t\t);\n\t\t}\n\t\treturn 0;\n\t} finally {\n\t\tawait sessionStore(sessions)?.close();\n\t}\n}\n\nfunction describeIds(ids: TransferredIds): string {\n\tconst parts = [\n\t\tids.sessions.length === 0\n\t\t\t? undefined\n\t\t\t: `${ids.sessions.length === 1 ? \"session\" : \"sessions\"} ${ids.sessions.join(\", \")}`,\n\t\tids.workflows.length === 0\n\t\t\t? undefined\n\t\t\t: `${ids.workflows.length === 1 ? \"workflow run\" : \"workflow runs\"} ${ids.workflows.join(\", \")}`,\n\t].filter((part) => part !== undefined);\n\treturn parts.length === 0 ? \"nothing\" : parts.join(\"; \");\n}\n\nasync function importRuns(\n\tcommand: Extract<StorageCommand, { kind: \"import\" }>,\n\toptions: StorageCommandOptions,\n\tlog: (line: string) => void,\n\terror: (line: string) => void,\n): Promise<number> {\n\tconst directory = resolve(options.cwd, command.directory);\n\tif (!existsSync(directory)) throw new StorageCommandError(`${directory}: no such directory.`);\n\tconst named = namedSelection(command, options.cwd);\n\tconst workflows = command.kinds.workflows ? workflowTransfer(options, \"import\", named) : undefined;\n\tconst sessions = command.kinds.sessions ? await sessionTransfer(options, \"import\", named) : undefined;\n\ttry {\n\t\tconst refusals = [workflows, sessions].flatMap((transfer) =>\n\t\t\ttransfer !== undefined && \"refused\" in transfer ? [transfer.refused] : [],\n\t\t);\n\t\tconst kinds = Number(command.kinds.sessions) + Number(command.kinds.workflows);\n\t\tif (refusals.length > 0 && (command.kinds.explicit || refusals.length === kinds))\n\t\t\tthrow new StorageCommandError(refusals.join(\"\\n\"));\n\t\tfor (const refused of refusals) error(`Skipped: ${refused}`);\n\t\tconst sessionTarget = sessionStore(sessions);\n\t\tconst workflowStorage = workflows !== undefined && \"target\" in workflows ? workflows.target : undefined;\n\t\tlet report: Awaited<ReturnType<typeof importStorage>>;\n\t\ttry {\n\t\t\treport = await importStorage(directory, {\n\t\t\t\t...(sessionTarget === undefined ? {} : { sessions: sessionTarget }),\n\t\t\t\t...(workflowStorage === undefined ? {} : { workflows: workflowStorage }),\n\t\t\t});\n\t\t} catch (caught) {\n\t\t\tif (isStorageImportIncompleteError(caught)) {\n\t\t\t\terror(caught.message);\n\t\t\t\terror(`Imported before the failure: ${describeIds(caught.written)}.`);\n\t\t\t\terror(`Not imported: ${describeIds(caught.notWritten)}.`);\n\t\t\t\terror(\"Run the same import again to finish: it imports only what is missing.\");\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\tif (isStorageTransferError(caught)) {\n\t\t\t\terror(caught.message);\n\t\t\t\terror(\"Nothing was imported.\");\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\tthrow caught;\n\t\t}\n\t\tif (report.sessions !== undefined) {\n\t\t\tconst { added, updated, unchanged } = report.sessions;\n\t\t\tlog(\n\t\t\t\t`Imported ${plural(added.length + updated.length + unchanged.length, \"session\")} from ${sessionsTransferDirectory(directory)} (${added.length} added, ${updated.length} updated, ${unchanged.length} already up to date).`,\n\t\t\t);\n\t\t}\n\t\tif (report.workflows !== undefined) {\n\t\t\tconst { added, updated, unchanged } = report.workflows;\n\t\t\tlog(\n\t\t\t\t`Imported ${plural(added.length + updated.length + unchanged.length, \"workflow run\")} from ${workflowsTransferDirectory(directory)} (${added.length} added, ${updated.length} updated, ${unchanged.length} already up to date).`,\n\t\t\t);\n\t\t}\n\t\treturn 0;\n\t} finally {\n\t\tawait sessionStore(sessions)?.close();\n\t}\n}\n\nfunction sessionStore(transfer: Transfer<SessionStore | undefined> | undefined): SessionStore | undefined {\n\treturn transfer !== undefined && \"target\" in transfer ? transfer.target : undefined;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"auth-storage-backends.d.ts","sourceRoot":"","sources":["../../src/core/auth-storage-backends.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,UAAU,EAAwD,MAAM,oBAAoB,CAAC;AA0B3G,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI;IAC3B,MAAM,EAAE,CAAC,CAAC;IACV,IAAI,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AA4HF,MAAM,WAAW,kBAAkB;IAClC;;;;;;;;;;;;OAYG;IACH,IAAI,CAAC,IAAI,MAAM,GAAG,SAAS,CAAC;IAC5B,OAAO,CAAC,IAAI,MAAM,CAAC;IACnB,SAAS,CAAC,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAC1C,YAAY,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACjC,cAAc,CAAC,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACtD,mBAAmB,CAAC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IACpE,mBAAmB,CAAC,CACnB,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,CAAC,OAAO,EAAE,UAAU,GAAG,SAAS,KAAK,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,EACxE,MAAM,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,UAAU,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC,CAAC;IAC/C,QAAQ,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,KAAK,UAA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AAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAenD;IAEK,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAqCvE;IAED,QAAQ,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,KAAK,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAmBjE;IAEK,aAAa,CAAC,CAAC,EACpB,EAAE,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAC3D,OAAO,GAAE;QAAE,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAA;KAAO,GAClD,OAAO,CAAC,CAAC,CAAC,CAkDZ;CACD;AAED,qBAAa,0BAA2B,YAAW,kBAAkB,EAAE,qBAAqB;IAC3F,OAAO,CAAC,KAAK,CAAqB;IAClC,OAAO,CAAC,YAAY,CAAoC;IAExD,IAAI,IAAI,MAAM,GAAG,SAAS,CAEzB;IAEK,SAAS,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAE7C;IAED,QAAQ,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,KAAK,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAMjE;IAEK,aAAa,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAgB9F;CACD"}
@@ -152,6 +152,7 @@ export class FileAuthStorageBackend {
152
152
  async modifyProviderAsync(provider, fn, signal) {
153
153
  await this.ensureParentDirAsync();
154
154
  await this.ensureFileExistsAsync();
155
+ // The provider id is not a credential: its digest only names the provider's lock file beside auth.json.
155
156
  const providerPath = `${await resolveExistingAuthPathAsync(this.authPath)}.${createHash("sha256").update(provider).digest("hex")}`;
156
157
  let compromised;
157
158
  const release = await this.acquireProviderLock(providerPath, {