@bastani/atomic 0.10.4-alpha.2 → 0.10.4
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.
- package/CHANGELOG.md +194 -0
- package/dist/_shared/chunk-CDOYTDYM.js +4 -0
- package/dist/_shared/chunk-CDOYTDYM.js.map +1 -0
- package/dist/_shared/fork-row-index-UAUAQRD5.js +1 -1
- package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js +2 -2
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +1 -1
- package/dist/_shared/mode-shared-HP7GUA7J.js +4 -4
- package/dist/_shared/sdk-WQIOHVKO.js +1 -1
- package/dist/_shared/session-data-AHTU7IS6.js +2 -2
- package/dist/_shared/sql-session-store-5FD3WBMZ.js +9 -9
- package/dist/_shared/startup-0-0-X4NF3GKM.js +9 -5
- package/dist/_shared/startup-0-0-X4NF3GKM.js.map +1 -1
- package/dist/_shared/startup-0-2-KFDYPDJK.js +1 -1
- package/dist/_shared/startup-0-3-T4DVFYWX.js +2 -2
- package/dist/_shared/startup-0-4-HN5EB4K7.js +1 -1
- package/dist/_shared/startup-0-5-OHJNE6JH.js +3 -3
- package/dist/_shared/startup-10-0-TDQNBDDL.js +3 -3
- package/dist/_shared/startup-15-1-4S7FLMNG.js +14 -14
- package/dist/_shared/startup-8-0-34CBHPZH.js +23 -23
- package/dist/_shared/startup-8-1-KQJBDKRU.js +12 -12
- package/dist/_shared/storage-command-7MGXLJGZ.js +4 -4
- package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +1 -1
- package/dist/_shared/tree-outline-MUEPK5B7.js +2 -2
- package/dist/builtin/intercom/CHANGELOG.md +38 -0
- package/dist/builtin/intercom/index.bundle.mjs +1 -1
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/index.bundle.mjs +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +40 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +1 -1
- package/dist/builtin/web-access/CHANGELOG.md +12 -0
- package/dist/builtin/web-access/index.bundle.mjs +1 -1
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/cli/auth-cli.impl.js +1102 -0
- package/dist/cli/auth-cli.impl.js.map +1 -0
- package/dist/cli/auth-cli.js +28 -1098
- package/dist/cli/auth-cli.js.map +1 -1
- package/dist/cli/blueprint-command.impl.js +906 -0
- package/dist/cli/blueprint-command.impl.js.map +1 -0
- package/dist/cli/blueprint-command.js +27 -901
- package/dist/cli/blueprint-command.js.map +1 -1
- package/dist/cli/intercom-command.impl.js +108 -0
- package/dist/cli/intercom-command.impl.js.map +1 -0
- package/dist/cli/intercom-command.js +29 -105
- package/dist/cli/intercom-command.js.map +1 -1
- package/dist/cli/list-models.impl.js +60 -0
- package/dist/cli/list-models.impl.js.map +1 -0
- package/dist/cli/list-models.js +29 -57
- package/dist/cli/list-models.js.map +1 -1
- package/dist/cli/session-picker.impl.js +55 -0
- package/dist/cli/session-picker.impl.js.map +1 -0
- package/dist/cli/session-picker.js +30 -53
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/cli/startup-ui.impl.js +5 -0
- package/dist/cli/startup-ui.impl.js.map +1 -0
- package/dist/cli/startup-ui.js +31 -4
- package/dist/cli/storage-command.impl.js +3 -0
- package/dist/cli/storage-command.impl.js.map +1 -0
- package/dist/cli/storage-command.js +31 -2
- package/dist/cli/storage-search-session.impl.js +189 -0
- package/dist/cli/storage-search-session.impl.js.map +1 -0
- package/dist/cli/storage-search-session.js +29 -186
- package/dist/cli/storage-search-session.js.map +1 -1
- package/dist/cli/team-command.impl.js +217 -0
- package/dist/cli/team-command.impl.js.map +1 -0
- package/dist/cli/team-command.js +29 -214
- package/dist/cli/team-command.js.map +1 -1
- package/dist/core/debug.impl.js +3 -0
- package/dist/core/debug.impl.js.map +1 -0
- package/dist/core/debug.js +31 -2
- package/dist/core/export-html/card-projection.impl.js +257 -0
- package/dist/core/export-html/card-projection.impl.js.map +1 -0
- package/dist/core/export-html/card-projection.js +30 -255
- package/dist/core/export-html/card-projection.js.map +1 -1
- package/dist/core/export-html/index.impl.js +610 -0
- package/dist/core/export-html/index.impl.js.map +1 -0
- package/dist/core/export-html/index.js +28 -606
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/export-html/json-spans.impl.js +3 -0
- package/dist/core/export-html/json-spans.impl.js.map +1 -0
- package/dist/core/export-html/json-spans.js +31 -2
- package/dist/core/export-html/oversized-render-inputs.impl.js +125 -0
- package/dist/core/export-html/oversized-render-inputs.impl.js.map +1 -0
- package/dist/core/export-html/oversized-render-inputs.js +28 -121
- package/dist/core/export-html/oversized-render-inputs.js.map +1 -1
- package/dist/core/export-html/tool-renderer.impl.js +350 -0
- package/dist/core/export-html/tool-renderer.impl.js.map +1 -0
- package/dist/core/export-html/tool-renderer.js +29 -347
- package/dist/core/export-html/tool-renderer.js.map +1 -1
- package/dist/core/extensions/jiti-loader.impl.js +3 -0
- package/dist/core/extensions/jiti-loader.impl.js.map +1 -0
- package/dist/core/extensions/jiti-loader.js +31 -2
- package/dist/core/extensions/jiti-static-loader.impl.js +3 -0
- package/dist/core/extensions/jiti-static-loader.impl.js.map +1 -0
- package/dist/core/extensions/jiti-static-loader.js +31 -2
- package/dist/core/extensions/loader-host-modules.impl.js +3 -0
- package/dist/core/extensions/loader-host-modules.impl.js.map +1 -0
- package/dist/core/extensions/loader-host-modules.js +31 -2
- package/dist/core/intercom-broker-control-host.impl.js +5 -0
- package/dist/core/intercom-broker-control-host.impl.js.map +1 -0
- package/dist/core/intercom-broker-control-host.js +31 -4
- package/dist/core/intercom-broker-control.impl.js +18 -0
- package/dist/core/intercom-broker-control.impl.js.map +1 -0
- package/dist/core/intercom-broker-control.js +31 -17
- package/dist/core/intercom-broker-control.js.map +1 -1
- package/dist/core/package-manager-storage-adapters.impl.js +3 -0
- package/dist/core/package-manager-storage-adapters.impl.js.map +1 -0
- package/dist/core/package-manager-storage-adapters.js +31 -2
- package/dist/core/sdk.impl.js +9 -0
- package/dist/core/sdk.impl.js.map +1 -0
- package/dist/core/sdk.js +31 -8
- package/dist/core/session-manager-core.js +21 -21
- package/dist/core/session-manager-list.impl.js +3 -0
- package/dist/core/session-manager-list.impl.js.map +1 -0
- package/dist/core/session-manager-list.js +31 -2
- package/dist/core/session-manager.impl.js +8 -0
- package/dist/core/session-manager.impl.js.map +1 -0
- package/dist/core/session-manager.js +31 -7
- package/dist/core/session-storage.impl.js +3 -0
- package/dist/core/session-storage.impl.js.map +1 -0
- package/dist/core/session-storage.js +31 -2
- package/dist/core/storage/index.js +6 -6
- package/dist/core/storage/node-sqlite-thread.js +1 -1
- package/dist/core/storage/node-sqlite.js +1 -1
- package/dist/core/storage/offline-snapshot-file.impl.js +37 -0
- package/dist/core/storage/offline-snapshot-file.impl.js.map +1 -0
- package/dist/core/storage/offline-snapshot-file.js +30 -35
- package/dist/core/storage/offline-snapshot-file.js.map +1 -1
- package/dist/core/storage/provider.js +5 -5
- package/dist/core/storage/selection.js +3 -3
- package/dist/core/storage/session/branch-fork-source.impl.js +101 -0
- package/dist/core/storage/session/branch-fork-source.impl.js.map +1 -0
- package/dist/core/storage/session/branch-fork-source.js +29 -98
- package/dist/core/storage/session/branch-fork-source.js.map +1 -1
- package/dist/core/storage/session/card-view.impl.js +60 -0
- package/dist/core/storage/session/card-view.impl.js.map +1 -0
- package/dist/core/storage/session/card-view.js +30 -58
- package/dist/core/storage/session/card-view.js.map +1 -1
- package/dist/core/storage/session/child-reader.impl.js +94 -0
- package/dist/core/storage/session/child-reader.impl.js.map +1 -0
- package/dist/core/storage/session/child-reader.js +29 -91
- package/dist/core/storage/session/child-reader.js.map +1 -1
- package/dist/core/storage/session/chunked-resume-projection.impl.js +3 -0
- package/dist/core/storage/session/chunked-resume-projection.impl.js.map +1 -0
- package/dist/core/storage/session/chunked-resume-projection.js +31 -2
- package/dist/core/storage/session/expanded-child-details.impl.js +639 -0
- package/dist/core/storage/session/expanded-child-details.impl.js.map +1 -0
- package/dist/core/storage/session/expanded-child-details.js +28 -635
- package/dist/core/storage/session/expanded-child-details.js.map +1 -1
- package/dist/core/storage/session/fork-row-bytes.impl.js +3 -0
- package/dist/core/storage/session/fork-row-bytes.impl.js.map +1 -0
- package/dist/core/storage/session/fork-row-bytes.js +31 -2
- package/dist/core/storage/session/fork-row-index.impl.js +3 -0
- package/dist/core/storage/session/fork-row-index.impl.js.map +1 -0
- package/dist/core/storage/session/fork-row-index.js +31 -2
- package/dist/core/storage/session/fork-staging.impl.js +580 -0
- package/dist/core/storage/session/fork-staging.impl.js.map +1 -0
- package/dist/core/storage/session/fork-staging.js +27 -575
- package/dist/core/storage/session/fork-staging.js.map +1 -1
- package/dist/core/storage/session/fork-window.impl.js +477 -0
- package/dist/core/storage/session/fork-window.impl.js.map +1 -0
- package/dist/core/storage/session/fork-window.js +27 -472
- package/dist/core/storage/session/fork-window.js.map +1 -1
- package/dist/core/storage/session/history-pages.impl.js +3 -0
- package/dist/core/storage/session/history-pages.impl.js.map +1 -0
- package/dist/core/storage/session/history-pages.js +31 -2
- package/dist/core/storage/session/jsonl-entry-projection.impl.js +3 -0
- package/dist/core/storage/session/jsonl-entry-projection.impl.js.map +1 -0
- package/dist/core/storage/session/jsonl-entry-projection.js +31 -2
- package/dist/core/storage/session/jsonl-session-store.impl.js +3 -0
- package/dist/core/storage/session/jsonl-session-store.impl.js.map +1 -0
- package/dist/core/storage/session/jsonl-session-store.js +31 -2
- package/dist/core/storage/session/memory-session-store.impl.js +3 -0
- package/dist/core/storage/session/memory-session-store.impl.js.map +1 -0
- package/dist/core/storage/session/memory-session-store.js +31 -2
- package/dist/core/storage/session/pinned-branch-resume.impl.js +72 -0
- package/dist/core/storage/session/pinned-branch-resume.impl.js.map +1 -0
- package/dist/core/storage/session/pinned-branch-resume.js +29 -69
- package/dist/core/storage/session/pinned-branch-resume.js.map +1 -1
- package/dist/core/storage/session/released-history-files.impl.js +465 -0
- package/dist/core/storage/session/released-history-files.impl.js.map +1 -0
- package/dist/core/storage/session/released-history-files.js +29 -462
- package/dist/core/storage/session/released-history-files.js.map +1 -1
- package/dist/core/storage/session/resident-fork-rows.impl.js +57 -0
- package/dist/core/storage/session/resident-fork-rows.impl.js.map +1 -0
- package/dist/core/storage/session/resident-fork-rows.js +28 -53
- package/dist/core/storage/session/resident-fork-rows.js.map +1 -1
- package/dist/core/storage/session/session-resume.impl.js +3 -0
- package/dist/core/storage/session/session-resume.impl.js.map +1 -0
- package/dist/core/storage/session/session-resume.js +31 -2
- package/dist/core/storage/session/snapshot-cut.impl.js +3 -0
- package/dist/core/storage/session/snapshot-cut.impl.js.map +1 -0
- package/dist/core/storage/session/snapshot-cut.js +31 -2
- package/dist/core/storage/session/snapshot-history.impl.js +62 -0
- package/dist/core/storage/session/snapshot-history.impl.js.map +1 -0
- package/dist/core/storage/session/snapshot-history.js +30 -60
- package/dist/core/storage/session/snapshot-history.js.map +1 -1
- package/dist/core/storage/session/sql-session-store.impl.js +3 -0
- package/dist/core/storage/session/sql-session-store.impl.js.map +1 -0
- package/dist/core/storage/session/sql-session-store.js +31 -2
- package/dist/core/storage/session/tree-outline.impl.js +3 -0
- package/dist/core/storage/session/tree-outline.impl.js.map +1 -0
- package/dist/core/storage/session/tree-outline.js +31 -2
- package/dist/core/storage/session/tree-presentation.impl.js +342 -0
- package/dist/core/storage/session/tree-presentation.impl.js.map +1 -0
- package/dist/core/storage/session/tree-presentation.js +30 -340
- package/dist/core/storage/session/tree-presentation.js.map +1 -1
- package/dist/core/storage/storage-status.impl.js +3 -0
- package/dist/core/storage/storage-status.impl.js.map +1 -0
- package/dist/core/storage/storage-status.js +31 -2
- package/dist/core/storage/team.impl.js +3 -0
- package/dist/core/storage/team.impl.js.map +1 -0
- package/dist/core/storage/team.js +31 -2
- package/dist/core/structured-output/index.impl.js +3 -0
- package/dist/core/structured-output/index.impl.js.map +1 -0
- package/dist/core/structured-output/index.js +31 -2
- package/dist/core/tasks/task-completion-entry.impl.js +254 -0
- package/dist/core/tasks/task-completion-entry.impl.js.map +1 -0
- package/dist/core/tasks/task-completion-entry.js +30 -252
- package/dist/core/tasks/task-completion-entry.js.map +1 -1
- package/dist/core/tasks/task-file-history.impl.js +379 -0
- package/dist/core/tasks/task-file-history.impl.js.map +1 -0
- package/dist/core/tasks/task-file-history.js +28 -375
- package/dist/core/tasks/task-file-history.js.map +1 -1
- package/dist/core/tasks/task-reference-archive.impl.js +469 -0
- package/dist/core/tasks/task-reference-archive.impl.js.map +1 -0
- package/dist/core/tasks/task-reference-archive.js +31 -468
- package/dist/core/tasks/task-reference-archive.js.map +1 -1
- package/dist/core/tasks/task-reference-identity.impl.js +164 -0
- package/dist/core/tasks/task-reference-identity.impl.js.map +1 -0
- package/dist/core/tasks/task-reference-identity.js +28 -160
- package/dist/core/tasks/task-reference-identity.js.map +1 -1
- package/dist/core/tasks/task-reference-stream.impl.js +3 -0
- package/dist/core/tasks/task-reference-stream.impl.js.map +1 -0
- package/dist/core/tasks/task-reference-stream.js +31 -2
- package/dist/core/tasks/task-unsaved-answer.impl.js +3 -0
- package/dist/core/tasks/task-unsaved-answer.impl.js.map +1 -0
- package/dist/core/tasks/task-unsaved-answer.js +31 -2
- package/dist/core/tasks/task-view-source.impl.js +3 -0
- package/dist/core/tasks/task-view-source.impl.js.map +1 -0
- package/dist/core/tasks/task-view-source.js +31 -2
- package/dist/core/tools/read-url.impl.js +1530 -0
- package/dist/core/tools/read-url.impl.js.map +1 -0
- package/dist/core/tools/read-url.js +27 -1525
- package/dist/core/tools/read-url.js.map +1 -1
- package/dist/core/worktree-snapshot/blob-store.js +4 -4
- package/dist/core/worktree-snapshot/errors.impl.js +6 -0
- package/dist/core/worktree-snapshot/errors.impl.js.map +1 -0
- package/dist/core/worktree-snapshot/errors.js +31 -5
- package/dist/core/worktree-snapshot/session-index-reset.impl.js +136 -0
- package/dist/core/worktree-snapshot/session-index-reset.impl.js.map +1 -0
- package/dist/core/worktree-snapshot/session-index-reset.js +30 -134
- package/dist/core/worktree-snapshot/session-index-reset.js.map +1 -1
- package/dist/extensions/codemode/execute.impl.js +618 -0
- package/dist/extensions/codemode/execute.impl.js.map +1 -0
- package/dist/extensions/codemode/execute.js +28 -614
- package/dist/extensions/codemode/execute.js.map +1 -1
- package/dist/extensions/codemode/renderer.impl.js +110 -0
- package/dist/extensions/codemode/renderer.impl.js.map +1 -0
- package/dist/extensions/codemode/renderer.js +29 -107
- package/dist/extensions/codemode/renderer.js.map +1 -1
- package/dist/extensions/mcp/cli.impl.js +565 -0
- package/dist/extensions/mcp/cli.impl.js.map +1 -0
- package/dist/extensions/mcp/cli.js +30 -563
- package/dist/extensions/mcp/cli.js.map +1 -1
- package/dist/extensions/mcp/cli.lazy.impl.js +7 -0
- package/dist/extensions/mcp/cli.lazy.impl.js.map +1 -0
- package/dist/extensions/mcp/cli.lazy.js +32 -7
- package/dist/extensions/mcp/cli.lazy.js.map +1 -1
- package/dist/extensions/mcp/runtime.impl.js +5 -0
- package/dist/extensions/mcp/runtime.impl.js.map +1 -0
- package/dist/extensions/mcp/runtime.js +31 -4
- package/dist/main-first-time-setup.impl.js +12 -0
- package/dist/main-first-time-setup.impl.js.map +1 -0
- package/dist/main-first-time-setup.js +31 -11
- package/dist/main-first-time-setup.js.map +1 -1
- package/dist/modes/interactive/components/stored-tree-view.impl.js +293 -0
- package/dist/modes/interactive/components/stored-tree-view.impl.js.map +1 -0
- package/dist/modes/interactive/components/stored-tree-view.js +30 -291
- package/dist/modes/interactive/components/stored-tree-view.js.map +1 -1
- package/dist/modes/interactive/components/user-message-selector-archive.impl.js +191 -0
- package/dist/modes/interactive/components/user-message-selector-archive.impl.js.map +1 -0
- package/dist/modes/interactive/components/user-message-selector-archive.js +30 -189
- package/dist/modes/interactive/components/user-message-selector-archive.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.js +4 -0
- package/dist/modes/interactive/interactive-mode-deps.js.map +1 -0
- package/dist/package-manager-cli.impl.js +1067 -0
- package/dist/package-manager-cli.impl.js.map +1 -0
- package/dist/package-manager-cli.js +32 -1067
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/utils/startup-database-spare.impl.js +108 -0
- package/dist/utils/startup-database-spare.impl.js.map +1 -0
- package/dist/utils/startup-database-spare.js +30 -106
- package/dist/utils/startup-database-spare.js.map +1 -1
- package/dist/utils/tools-manager.impl.js +3 -0
- package/dist/utils/tools-manager.impl.js.map +1 -0
- package/dist/utils/tools-manager.js +31 -2
- package/docs/reference/cli.md +1 -1
- package/package.json +8 -8
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import "../_shared/rolldown-runtime-BGM3D5V3.js";
|
|
2
|
+
import { APP_NAME } from "../_shared/p0-cli-GUFK7TPN.js";
|
|
3
|
+
import { createGitEnvironment } from "../_shared/startup-0-0-X4NF3GKM.js";
|
|
4
|
+
import { processStorageEnvironment } from "../_shared/startup-0-2-KFDYPDJK.js";
|
|
5
|
+
import { collectStorageStatus, describeStorageError as describeStorageError$1, joinTeamWith, leaveTeamWith, selectTeamProfile } from "../_shared/startup-8-1-KQJBDKRU.js";
|
|
6
|
+
import { failed, formatStorageStatus, loadBrokerControl } from "../_shared/storage-command-7MGXLJGZ.js";
|
|
7
|
+
import { StorageError, TeamProfileConfigError, isTeamProfileConfigError, isTeamProfileError } from "../core/storage/errors.js";
|
|
8
|
+
import { LIBSQL_ADAPTER_PACKAGE } from "../core/storage/selection.js";
|
|
9
|
+
// dist/cli/team-command.js
|
|
10
|
+
/**
|
|
11
|
+
* `atomic team join|status|leave`: the recommended team layout as one command, over the SDK's `joinTeam`,
|
|
12
|
+
* `selectTeamProfile` and `leaveTeam`. Intercom routing shares a team database; sessions stay local.
|
|
13
|
+
*/
|
|
14
|
+
const HELP = `Usage:
|
|
15
|
+
${APP_NAME} team join <url> [--token-file <path>] [--prefix <prefix>]
|
|
16
|
+
${APP_NAME} team status [--json]
|
|
17
|
+
${APP_NAME} team leave
|
|
18
|
+
|
|
19
|
+
Commands:
|
|
20
|
+
join Share Intercom routing with your team through a libSQL / Turso database while
|
|
21
|
+
sessions stay on this machine. Checks the token and the connection with
|
|
22
|
+
${LIBSQL_ADAPTER_PACKAGE}, stores the token in the agent directory (mode 600), sets the
|
|
23
|
+
global \`storage\` setting to the team database and \`sessions.storage\` to the local store in
|
|
24
|
+
one write, restarts the Intercom broker, and prints the storage status. While multi-node
|
|
25
|
+
routing is on, sessions join a project group (project:<owner>/<repo>) instead of "default".
|
|
26
|
+
Nothing is changed when a check fails.
|
|
27
|
+
status Show the profile in effect (individual, team, ci or custom) and the storage status. Exits 1
|
|
28
|
+
when a selection is invalid, an adapter cannot load, or a database does not answer.
|
|
29
|
+
leave Restore the individual layout: remove \`storage\` and \`sessions.storage\` when they hold what
|
|
30
|
+
\`team join\` wrote, delete that token file unless a setting still references it, and restart
|
|
31
|
+
the Intercom broker. Other settings are unchanged; running it again changes nothing.
|
|
32
|
+
|
|
33
|
+
Options:
|
|
34
|
+
--json Print the status as JSON
|
|
35
|
+
--token-file <path> File holding the database token, for example from \`turso db tokens create\`;
|
|
36
|
+
surrounding whitespace is removed. Required except for file: URLs
|
|
37
|
+
--prefix <prefix> Table prefix, to share one database between teams`;
|
|
38
|
+
const HELP_HINT = `Use "${APP_NAME} team --help" for usage.`;
|
|
39
|
+
const PROFILE_DESCRIPTIONS = {
|
|
40
|
+
individual: "sessions on this machine; Intercom on this machine only",
|
|
41
|
+
team: "sessions on this machine; Intercom on the team database",
|
|
42
|
+
ci: "sessions and Intercom on the team database",
|
|
43
|
+
custom: "matches no preset; see the selections below"
|
|
44
|
+
};
|
|
45
|
+
function usage(code, field, hint) {
|
|
46
|
+
return new TeamProfileConfigError(code, {
|
|
47
|
+
source: "cli",
|
|
48
|
+
field,
|
|
49
|
+
hint
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/** Parse the arguments after `team`. An option is named without any `=value` part, which could hold a secret. */
|
|
53
|
+
function parseTeamCommand(args) {
|
|
54
|
+
const [command, ...rest] = args;
|
|
55
|
+
if (command === void 0 || command === "help" || args.includes("--help") || args.includes("-h")) return { kind: "help" };
|
|
56
|
+
if (command !== "join" && command !== "status" && command !== "leave") throw usage("unknown-command", "<command>", `Use join, status or leave. ${HELP_HINT}`);
|
|
57
|
+
const positional = [];
|
|
58
|
+
const values = /* @__PURE__ */ new Map();
|
|
59
|
+
let json = false;
|
|
60
|
+
for (let index = 0; index < rest.length; index++) {
|
|
61
|
+
const arg = rest[index];
|
|
62
|
+
if (command === "status" && arg === "--json") {
|
|
63
|
+
json = true;
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (command === "join" && (arg === "--token-file" || arg === "--prefix")) {
|
|
67
|
+
const value = rest[++index];
|
|
68
|
+
if (value === void 0) throw usage("missing-value", arg, `Pass a value after ${arg}.`);
|
|
69
|
+
values.set(arg, value);
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
if (arg.startsWith("-")) throw usage("unknown-option", arg.split("=")[0], `"${APP_NAME} team ${command}" does not take it. ${HELP_HINT}`);
|
|
73
|
+
positional.push(arg);
|
|
74
|
+
}
|
|
75
|
+
if (command === "join") {
|
|
76
|
+
if (positional.length === 0) throw usage("missing-url", "<url>", `Pass the team database URL: ${APP_NAME} team join <url> [--token-file <path>] [--prefix <prefix>]`);
|
|
77
|
+
if (positional.length > 1) throw usage("unexpected-argument", "arguments after <url>", `Pass one URL. ${HELP_HINT}`);
|
|
78
|
+
const tokenFile = values.get("--token-file");
|
|
79
|
+
const prefix = values.get("--prefix");
|
|
80
|
+
return {
|
|
81
|
+
kind: "join",
|
|
82
|
+
url: positional[0],
|
|
83
|
+
...tokenFile === void 0 ? {} : { tokenFile },
|
|
84
|
+
...prefix === void 0 ? {} : { prefix }
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
if (positional.length > 0) throw usage("unexpected-argument", `arguments after ${command}`, `"${APP_NAME} team ${command}" takes none. ${HELP_HINT}`);
|
|
88
|
+
return command === "status" ? {
|
|
89
|
+
kind: "status",
|
|
90
|
+
json
|
|
91
|
+
} : { kind: "leave" };
|
|
92
|
+
}
|
|
93
|
+
function describeRestart(restart, log, error) {
|
|
94
|
+
if (restart.status === "failed") {
|
|
95
|
+
error(restart.error.message);
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
if (restart.status === "not-running") log("No Intercom broker was running; the next session that uses Intercom starts one with these settings.");
|
|
99
|
+
else if (restart.status === "stopped") log(`Stopped the Intercom broker (pid ${restart.previous.pid}); the next session that uses Intercom starts one with these settings.`);
|
|
100
|
+
else {
|
|
101
|
+
const current = restart.current;
|
|
102
|
+
log(`Restarted the Intercom broker: pid ${restart.previous.pid} → ${current.state === "running" ? current.report.pid : current.pid ?? "unknown"}.`);
|
|
103
|
+
}
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
function projectGroupOf(control, options) {
|
|
107
|
+
if (control instanceof Error) return void 0;
|
|
108
|
+
return control.projectHomeGroup(options.cwd, options.agentDir, processStorageEnvironment(), createGitEnvironment());
|
|
109
|
+
}
|
|
110
|
+
async function report(options, json, log) {
|
|
111
|
+
let profile;
|
|
112
|
+
let profileError;
|
|
113
|
+
try {
|
|
114
|
+
profile = selectTeamProfile({
|
|
115
|
+
agentDir: options.agentDir,
|
|
116
|
+
cwd: options.cwd
|
|
117
|
+
});
|
|
118
|
+
} catch (caught) {
|
|
119
|
+
if (!(caught instanceof StorageError)) throw caught;
|
|
120
|
+
profileError = caught.message;
|
|
121
|
+
}
|
|
122
|
+
const control = await loadBrokerControl(options);
|
|
123
|
+
const collected = await collectStorageStatus({
|
|
124
|
+
cwd: options.cwd,
|
|
125
|
+
agentDir: options.agentDir,
|
|
126
|
+
probe: true,
|
|
127
|
+
...control instanceof Error ? {} : { control }
|
|
128
|
+
});
|
|
129
|
+
const status = control instanceof Error ? {
|
|
130
|
+
...collected,
|
|
131
|
+
broker: {
|
|
132
|
+
state: "unknown",
|
|
133
|
+
error: describeStorageError$1(control)
|
|
134
|
+
}
|
|
135
|
+
} : collected;
|
|
136
|
+
const projectGroup = projectGroupOf(control, options);
|
|
137
|
+
if (json) log(JSON.stringify({
|
|
138
|
+
profile: profile ?? null,
|
|
139
|
+
...profileError === void 0 ? {} : { profileError },
|
|
140
|
+
...projectGroup === void 0 ? {} : { projectGroup },
|
|
141
|
+
...status
|
|
142
|
+
}, null, 2));
|
|
143
|
+
else {
|
|
144
|
+
log(profile === void 0 ? `Profile: unknown (${profileError})` : `Profile: ${profile.profile} (${PROFILE_DESCRIPTIONS[profile.profile]})`);
|
|
145
|
+
if (projectGroup !== void 0) log(`Intercom group: sessions in ${options.cwd} join "${projectGroup}" unless ATOMIC_INTERCOM_GROUP or the Intercom config sets a group; sessions that are already running keep theirs until they restart.`);
|
|
146
|
+
log("");
|
|
147
|
+
for (const line of formatStorageStatus(status)) log(line);
|
|
148
|
+
}
|
|
149
|
+
return { failed: profile === void 0 || status.domains.some(failed) };
|
|
150
|
+
}
|
|
151
|
+
/** Run `atomic team <args>` and return the exit code. */
|
|
152
|
+
async function runTeamCommand(args, options) {
|
|
153
|
+
const log = options.log ?? ((line) => console.log(line));
|
|
154
|
+
const error = options.error ?? ((line) => console.error(line));
|
|
155
|
+
try {
|
|
156
|
+
const command = parseTeamCommand(args);
|
|
157
|
+
if (command.kind === "help") {
|
|
158
|
+
log(HELP);
|
|
159
|
+
return 0;
|
|
160
|
+
}
|
|
161
|
+
const context = options.loadControl === void 0 ? {} : { loadControl: options.loadControl };
|
|
162
|
+
if (command.kind === "status") return (await report(options, command.json, log)).failed ? 1 : 0;
|
|
163
|
+
if (command.kind === "join") {
|
|
164
|
+
const reportJoined = (joined) => {
|
|
165
|
+
log(`Connected to ${command.url}.`);
|
|
166
|
+
if (joined.tokenPath !== void 0) log(joined.token === "reused" ? `Kept the token in ${joined.tokenPath}; it already holds this token.` : `Stored the token in ${joined.tokenPath} (mode 600).`);
|
|
167
|
+
log(`Set \`storage\` to the team database and \`sessions.storage\` to the local store in ${joined.settingsPath}; other settings are unchanged.`);
|
|
168
|
+
if (joined.replaced !== void 0) log(`It replaces the previous selection: ${joined.replaced}.`);
|
|
169
|
+
if (joined.replacedSessionsStorage !== void 0) log(`It replaces the previous \`sessions.storage\`: ${joined.replacedSessionsStorage}.`);
|
|
170
|
+
};
|
|
171
|
+
const restarted = describeRestart((await joinTeamWith({
|
|
172
|
+
...command,
|
|
173
|
+
agentDir: options.agentDir,
|
|
174
|
+
cwd: options.cwd,
|
|
175
|
+
onProgress: log
|
|
176
|
+
}, "cli", {
|
|
177
|
+
...context,
|
|
178
|
+
onJoined: reportJoined
|
|
179
|
+
})).broker, log, error);
|
|
180
|
+
log("");
|
|
181
|
+
const status = await report(options, false, log);
|
|
182
|
+
return restarted && !status.failed ? 0 : 1;
|
|
183
|
+
}
|
|
184
|
+
let reportedLeft = false;
|
|
185
|
+
const reportLeft = (left) => {
|
|
186
|
+
reportedLeft = true;
|
|
187
|
+
if (left.removed.length === 0) log(`Nothing to remove: ${left.settingsPath} holds no settings that \`${APP_NAME} team join\` wrote.`);
|
|
188
|
+
else log(`Removed ${left.removed.map((key) => `\`${key}\``).join(" and ")} from ${left.settingsPath}; other settings are unchanged.`);
|
|
189
|
+
for (const { key, reason } of left.kept) log(reason === "changed" ? `Left \`${key}\` in place: it holds something other than what team join writes.` : `Left \`${key}\` in place: \`storage\` is still set, and without it new sessions would move to that store.`);
|
|
190
|
+
};
|
|
191
|
+
const left = await leaveTeamWith({
|
|
192
|
+
agentDir: options.agentDir,
|
|
193
|
+
cwd: options.cwd,
|
|
194
|
+
onProgress: log
|
|
195
|
+
}, {
|
|
196
|
+
...context,
|
|
197
|
+
onLeft: reportLeft
|
|
198
|
+
});
|
|
199
|
+
if (!reportedLeft) reportLeft(left);
|
|
200
|
+
for (const path of left.deletedTokenFiles) log(`Deleted the token file ${path}.`);
|
|
201
|
+
for (const path of left.keptTokenFiles) log(`Kept the token file ${path}: another setting still references it.`);
|
|
202
|
+
const restarted = left.broker === void 0 || describeRestart(left.broker, log, error);
|
|
203
|
+
const profile = selectTeamProfile({
|
|
204
|
+
agentDir: options.agentDir,
|
|
205
|
+
cwd: options.cwd
|
|
206
|
+
});
|
|
207
|
+
const described = profile.profile === "custom" ? `sessions: ${profile.sessions}; Intercom: ${profile.intercom}` : PROFILE_DESCRIPTIONS[profile.profile];
|
|
208
|
+
log(`Profile: ${profile.profile} (${described})`);
|
|
209
|
+
return restarted ? 0 : 1;
|
|
210
|
+
} catch (caught) {
|
|
211
|
+
error(isTeamProfileError(caught) || isTeamProfileConfigError(caught) ? caught.message : `Error: ${describeStorageError$1(caught)}`);
|
|
212
|
+
return 1;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
export { parseTeamCommand, runTeamCommand };
|
|
216
|
+
|
|
217
|
+
//# sourceMappingURL=team-command.impl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"team-command.impl.js","names":["describeStorageError"],"sources":["../../src/cli/team-command.ts"],"mappings":";;;;;;;;;;;;;AA6BA,MAAM,OAAO;IACT,SAAQ;IACR,SAAQ;IACR,SAAQ;;;;;aAKC,uBAAsB;;;;;;;;;;;;;;;;AAiBnC,MAAM,YAAY,QAAQ,SAAQ;AAQlC,MAAM,uBAAkE;CACvE,YAAY;CACZ,MAAM;CACN,IAAI;CACJ,QAAQ;AACR;AAED,SAAS,MACR,MACA,OACA,MAAY;CAEZ,OAAO,IAAI,uBAAuB,MAAM;EAAE,QAAQ;EAAO;EAAO;CAAI,CAAE;AACvE;;AAGA,SAAgB,iBAAiB,MAAuB;CACvD,MAAM,CAAC,SAAS,GAAG,QAAQ;CAC3B,IAAI,YAAY,KAAA,KAAa,YAAY,UAAU,KAAK,SAAS,QAAQ,KAAK,KAAK,SAAS,IAAI,GAC/F,OAAO,EAAE,MAAM,OAAM;CAEtB,IAAI,YAAY,UAAU,YAAY,YAAY,YAAY,SAC7D,MAAM,MAAM,mBAAmB,aAAa,8BAA8B,WAAW;CA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AAO,IAAK,UAAS,EAAG;EAChD,OAAO,YAAY,IAAI;CACxB,SAAS,QAAQ;EAChB,MACC,mBAAmB,MAAM,KAAK,yBAAyB,MAAM,IAC1D,OAAO,UACP,UAAUA,uBAAqB,MAAe,GAAG;EAErD,OAAO;CACR;AACD"}
|
package/dist/cli/team-command.js
CHANGED
|
@@ -1,217 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
one write, restarts the Intercom broker, and prints the storage status. While multi-node
|
|
25
|
-
routing is on, sessions join a project group (project:<owner>/<repo>) instead of "default".
|
|
26
|
-
Nothing is changed when a check fails.
|
|
27
|
-
status Show the profile in effect (individual, team, ci or custom) and the storage status. Exits 1
|
|
28
|
-
when a selection is invalid, an adapter cannot load, or a database does not answer.
|
|
29
|
-
leave Restore the individual layout: remove \`storage\` and \`sessions.storage\` when they hold what
|
|
30
|
-
\`team join\` wrote, delete that token file unless a setting still references it, and restart
|
|
31
|
-
the Intercom broker. Other settings are unchanged; running it again changes nothing.
|
|
32
|
-
|
|
33
|
-
Options:
|
|
34
|
-
--json Print the status as JSON
|
|
35
|
-
--token-file <path> File holding the database token, for example from \`turso db tokens create\`;
|
|
36
|
-
surrounding whitespace is removed. Required except for file: URLs
|
|
37
|
-
--prefix <prefix> Table prefix, to share one database between teams`;
|
|
38
|
-
const HELP_HINT = `Use "${APP_NAME} team --help" for usage.`;
|
|
39
|
-
const PROFILE_DESCRIPTIONS = {
|
|
40
|
-
individual: "sessions on this machine; Intercom on this machine only",
|
|
41
|
-
team: "sessions on this machine; Intercom on the team database",
|
|
42
|
-
ci: "sessions and Intercom on the team database",
|
|
43
|
-
custom: "matches no preset; see the selections below"
|
|
44
|
-
};
|
|
45
|
-
function usage(code, field, hint) {
|
|
46
|
-
return new TeamProfileConfigError(code, {
|
|
47
|
-
source: "cli",
|
|
48
|
-
field,
|
|
49
|
-
hint
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
/** Parse the arguments after `team`. An option is named without any `=value` part, which could hold a secret. */
|
|
53
|
-
function parseTeamCommand(args) {
|
|
54
|
-
const [command, ...rest] = args;
|
|
55
|
-
if (command === void 0 || command === "help" || args.includes("--help") || args.includes("-h")) return { kind: "help" };
|
|
56
|
-
if (command !== "join" && command !== "status" && command !== "leave") throw usage("unknown-command", "<command>", `Use join, status or leave. ${HELP_HINT}`);
|
|
57
|
-
const positional = [];
|
|
58
|
-
const values = /* @__PURE__ */ new Map();
|
|
59
|
-
let json = false;
|
|
60
|
-
for (let index = 0; index < rest.length; index++) {
|
|
61
|
-
const arg = rest[index];
|
|
62
|
-
if (command === "status" && arg === "--json") {
|
|
63
|
-
json = true;
|
|
64
|
-
continue;
|
|
65
|
-
}
|
|
66
|
-
if (command === "join" && (arg === "--token-file" || arg === "--prefix")) {
|
|
67
|
-
const value = rest[++index];
|
|
68
|
-
if (value === void 0) throw usage("missing-value", arg, `Pass a value after ${arg}.`);
|
|
69
|
-
values.set(arg, value);
|
|
70
|
-
continue;
|
|
71
|
-
}
|
|
72
|
-
if (arg.startsWith("-")) throw usage("unknown-option", arg.split("=")[0], `"${APP_NAME} team ${command}" does not take it. ${HELP_HINT}`);
|
|
73
|
-
positional.push(arg);
|
|
74
|
-
}
|
|
75
|
-
if (command === "join") {
|
|
76
|
-
if (positional.length === 0) throw usage("missing-url", "<url>", `Pass the team database URL: ${APP_NAME} team join <url> [--token-file <path>] [--prefix <prefix>]`);
|
|
77
|
-
if (positional.length > 1) throw usage("unexpected-argument", "arguments after <url>", `Pass one URL. ${HELP_HINT}`);
|
|
78
|
-
const tokenFile = values.get("--token-file");
|
|
79
|
-
const prefix = values.get("--prefix");
|
|
80
|
-
return {
|
|
81
|
-
kind: "join",
|
|
82
|
-
url: positional[0],
|
|
83
|
-
...tokenFile === void 0 ? {} : { tokenFile },
|
|
84
|
-
...prefix === void 0 ? {} : { prefix }
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
if (positional.length > 0) throw usage("unexpected-argument", `arguments after ${command}`, `"${APP_NAME} team ${command}" takes none. ${HELP_HINT}`);
|
|
88
|
-
return command === "status" ? {
|
|
89
|
-
kind: "status",
|
|
90
|
-
json
|
|
91
|
-
} : { kind: "leave" };
|
|
92
|
-
}
|
|
93
|
-
function describeRestart(restart, log, error) {
|
|
94
|
-
if (restart.status === "failed") {
|
|
95
|
-
error(restart.error.message);
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
if (restart.status === "not-running") log("No Intercom broker was running; the next session that uses Intercom starts one with these settings.");
|
|
99
|
-
else if (restart.status === "stopped") log(`Stopped the Intercom broker (pid ${restart.previous.pid}); the next session that uses Intercom starts one with these settings.`);
|
|
100
|
-
else {
|
|
101
|
-
const current = restart.current;
|
|
102
|
-
log(`Restarted the Intercom broker: pid ${restart.previous.pid} → ${current.state === "running" ? current.report.pid : current.pid ?? "unknown"}.`);
|
|
1
|
+
// Written by the build (scripts/in-place-update-gate.mjs): when this module's code cannot load in a process of an earlier release
|
|
2
|
+
// that an in-place update left running, the process is told to restart.
|
|
3
|
+
let module;
|
|
4
|
+
try {
|
|
5
|
+
module = await import("./team-command.impl.js");
|
|
6
|
+
} catch (error) {
|
|
7
|
+
const root = new URL("../", import.meta.url);
|
|
8
|
+
const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
|
|
9
|
+
const key = `${root.href}#0.10.4`;
|
|
10
|
+
let release = releases.get(key);
|
|
11
|
+
if (release === undefined) {
|
|
12
|
+
release = (async () => {
|
|
13
|
+
for (const path of ["modes/interactive/interactive-mode-deps.js","_shared/chunk-CDOYTDYM.js","_shared/p0-cli-GUFK7TPN.js"]) {
|
|
14
|
+
try {
|
|
15
|
+
const held = await import(new URL(path, root).href);
|
|
16
|
+
if (typeof held.VERSION === "string") return { version: held.VERSION, name: held.APP_NAME };
|
|
17
|
+
} catch {
|
|
18
|
+
// Not a file this process can load: the next.
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return undefined;
|
|
22
|
+
})();
|
|
23
|
+
releases.set(key, release);
|
|
103
24
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
return control.projectHomeGroup(options.cwd, options.agentDir, processStorageEnvironment(), createGitEnvironment());
|
|
109
|
-
}
|
|
110
|
-
async function report(options, json, log) {
|
|
111
|
-
let profile;
|
|
112
|
-
let profileError;
|
|
113
|
-
try {
|
|
114
|
-
profile = selectTeamProfile({
|
|
115
|
-
agentDir: options.agentDir,
|
|
116
|
-
cwd: options.cwd
|
|
117
|
-
});
|
|
118
|
-
} catch (caught) {
|
|
119
|
-
if (!(caught instanceof StorageError)) throw caught;
|
|
120
|
-
profileError = caught.message;
|
|
121
|
-
}
|
|
122
|
-
const control = await loadBrokerControl(options);
|
|
123
|
-
const collected = await collectStorageStatus({
|
|
124
|
-
cwd: options.cwd,
|
|
125
|
-
agentDir: options.agentDir,
|
|
126
|
-
probe: true,
|
|
127
|
-
...control instanceof Error ? {} : { control }
|
|
25
|
+
const running = await release;
|
|
26
|
+
if (running === undefined || running.version === "0.10.4") throw error;
|
|
27
|
+
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.4 while this session was running; restart it to keep using this feature.", {
|
|
28
|
+
cause: error,
|
|
128
29
|
});
|
|
129
|
-
const status = control instanceof Error ? {
|
|
130
|
-
...collected,
|
|
131
|
-
broker: {
|
|
132
|
-
state: "unknown",
|
|
133
|
-
error: describeStorageError$1(control)
|
|
134
|
-
}
|
|
135
|
-
} : collected;
|
|
136
|
-
const projectGroup = projectGroupOf(control, options);
|
|
137
|
-
if (json) log(JSON.stringify({
|
|
138
|
-
profile: profile ?? null,
|
|
139
|
-
...profileError === void 0 ? {} : { profileError },
|
|
140
|
-
...projectGroup === void 0 ? {} : { projectGroup },
|
|
141
|
-
...status
|
|
142
|
-
}, null, 2));
|
|
143
|
-
else {
|
|
144
|
-
log(profile === void 0 ? `Profile: unknown (${profileError})` : `Profile: ${profile.profile} (${PROFILE_DESCRIPTIONS[profile.profile]})`);
|
|
145
|
-
if (projectGroup !== void 0) log(`Intercom group: sessions in ${options.cwd} join "${projectGroup}" unless ATOMIC_INTERCOM_GROUP or the Intercom config sets a group; sessions that are already running keep theirs until they restart.`);
|
|
146
|
-
log("");
|
|
147
|
-
for (const line of formatStorageStatus(status)) log(line);
|
|
148
|
-
}
|
|
149
|
-
return { failed: profile === void 0 || status.domains.some(failed) };
|
|
150
|
-
}
|
|
151
|
-
/** Run `atomic team <args>` and return the exit code. */
|
|
152
|
-
async function runTeamCommand(args, options) {
|
|
153
|
-
const log = options.log ?? ((line) => console.log(line));
|
|
154
|
-
const error = options.error ?? ((line) => console.error(line));
|
|
155
|
-
try {
|
|
156
|
-
const command = parseTeamCommand(args);
|
|
157
|
-
if (command.kind === "help") {
|
|
158
|
-
log(HELP);
|
|
159
|
-
return 0;
|
|
160
|
-
}
|
|
161
|
-
const context = options.loadControl === void 0 ? {} : { loadControl: options.loadControl };
|
|
162
|
-
if (command.kind === "status") return (await report(options, command.json, log)).failed ? 1 : 0;
|
|
163
|
-
if (command.kind === "join") {
|
|
164
|
-
const reportJoined = (joined) => {
|
|
165
|
-
log(`Connected to ${command.url}.`);
|
|
166
|
-
if (joined.tokenPath !== void 0) log(joined.token === "reused" ? `Kept the token in ${joined.tokenPath}; it already holds this token.` : `Stored the token in ${joined.tokenPath} (mode 600).`);
|
|
167
|
-
log(`Set \`storage\` to the team database and \`sessions.storage\` to the local store in ${joined.settingsPath}; other settings are unchanged.`);
|
|
168
|
-
if (joined.replaced !== void 0) log(`It replaces the previous selection: ${joined.replaced}.`);
|
|
169
|
-
if (joined.replacedSessionsStorage !== void 0) log(`It replaces the previous \`sessions.storage\`: ${joined.replacedSessionsStorage}.`);
|
|
170
|
-
};
|
|
171
|
-
const restarted = describeRestart((await joinTeamWith({
|
|
172
|
-
...command,
|
|
173
|
-
agentDir: options.agentDir,
|
|
174
|
-
cwd: options.cwd,
|
|
175
|
-
onProgress: log
|
|
176
|
-
}, "cli", {
|
|
177
|
-
...context,
|
|
178
|
-
onJoined: reportJoined
|
|
179
|
-
})).broker, log, error);
|
|
180
|
-
log("");
|
|
181
|
-
const status = await report(options, false, log);
|
|
182
|
-
return restarted && !status.failed ? 0 : 1;
|
|
183
|
-
}
|
|
184
|
-
let reportedLeft = false;
|
|
185
|
-
const reportLeft = (left) => {
|
|
186
|
-
reportedLeft = true;
|
|
187
|
-
if (left.removed.length === 0) log(`Nothing to remove: ${left.settingsPath} holds no settings that \`${APP_NAME} team join\` wrote.`);
|
|
188
|
-
else log(`Removed ${left.removed.map((key) => `\`${key}\``).join(" and ")} from ${left.settingsPath}; other settings are unchanged.`);
|
|
189
|
-
for (const { key, reason } of left.kept) log(reason === "changed" ? `Left \`${key}\` in place: it holds something other than what team join writes.` : `Left \`${key}\` in place: \`storage\` is still set, and without it new sessions would move to that store.`);
|
|
190
|
-
};
|
|
191
|
-
const left = await leaveTeamWith({
|
|
192
|
-
agentDir: options.agentDir,
|
|
193
|
-
cwd: options.cwd,
|
|
194
|
-
onProgress: log
|
|
195
|
-
}, {
|
|
196
|
-
...context,
|
|
197
|
-
onLeft: reportLeft
|
|
198
|
-
});
|
|
199
|
-
if (!reportedLeft) reportLeft(left);
|
|
200
|
-
for (const path of left.deletedTokenFiles) log(`Deleted the token file ${path}.`);
|
|
201
|
-
for (const path of left.keptTokenFiles) log(`Kept the token file ${path}: another setting still references it.`);
|
|
202
|
-
const restarted = left.broker === void 0 || describeRestart(left.broker, log, error);
|
|
203
|
-
const profile = selectTeamProfile({
|
|
204
|
-
agentDir: options.agentDir,
|
|
205
|
-
cwd: options.cwd
|
|
206
|
-
});
|
|
207
|
-
const described = profile.profile === "custom" ? `sessions: ${profile.sessions}; Intercom: ${profile.intercom}` : PROFILE_DESCRIPTIONS[profile.profile];
|
|
208
|
-
log(`Profile: ${profile.profile} (${described})`);
|
|
209
|
-
return restarted ? 0 : 1;
|
|
210
|
-
} catch (caught) {
|
|
211
|
-
error(isTeamProfileError(caught) || isTeamProfileConfigError(caught) ? caught.message : `Error: ${describeStorageError$1(caught)}`);
|
|
212
|
-
return 1;
|
|
213
|
-
}
|
|
214
30
|
}
|
|
215
|
-
export { parseTeamCommand, runTeamCommand };
|
|
216
|
-
|
|
217
|
-
//# sourceMappingURL=team-command.js.map
|
|
31
|
+
export const { parseTeamCommand, runTeamCommand } = module;
|
|
32
|
+
//# sourceMappingURL=team-command.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"team-command.js","
|
|
1
|
+
{"version":3,"file":"team-command.js","sources":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import "../_shared/rolldown-runtime-BGM3D5V3.js";
|
|
2
|
+
export { DEBUG_AREA_VARIABLES, appendDebugRecord, appendDebugRecordAsync, failureDebugFields, flushDebugLog, getDebugLogFailure, isDebugEnabled, reportDebug, reportDebugAsync } from "../_shared/p1b-elig-PXQA2FYP.js";
|
|
3
|
+
//# sourceMappingURL=debug.impl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug.impl.js","sources":[],"names":[],"mappings":""}
|
package/dist/core/debug.js
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// Written by the build (scripts/in-place-update-gate.mjs): when this module's code cannot load in a process of an earlier release
|
|
2
|
+
// that an in-place update left running, the process is told to restart.
|
|
3
|
+
let module;
|
|
4
|
+
try {
|
|
5
|
+
module = await import("./debug.impl.js");
|
|
6
|
+
} catch (error) {
|
|
7
|
+
const root = new URL("../", import.meta.url);
|
|
8
|
+
const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
|
|
9
|
+
const key = `${root.href}#0.10.4`;
|
|
10
|
+
let release = releases.get(key);
|
|
11
|
+
if (release === undefined) {
|
|
12
|
+
release = (async () => {
|
|
13
|
+
for (const path of ["modes/interactive/interactive-mode-deps.js","_shared/chunk-CDOYTDYM.js","_shared/p0-cli-GUFK7TPN.js"]) {
|
|
14
|
+
try {
|
|
15
|
+
const held = await import(new URL(path, root).href);
|
|
16
|
+
if (typeof held.VERSION === "string") return { version: held.VERSION, name: held.APP_NAME };
|
|
17
|
+
} catch {
|
|
18
|
+
// Not a file this process can load: the next.
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return undefined;
|
|
22
|
+
})();
|
|
23
|
+
releases.set(key, release);
|
|
24
|
+
}
|
|
25
|
+
const running = await release;
|
|
26
|
+
if (running === undefined || running.version === "0.10.4") throw error;
|
|
27
|
+
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.4 while this session was running; restart it to keep using this feature.", {
|
|
28
|
+
cause: error,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
export const { DEBUG_AREA_VARIABLES, appendDebugRecord, appendDebugRecordAsync, failureDebugFields, flushDebugLog, getDebugLogFailure, isDebugEnabled, reportDebug, reportDebugAsync } = module;
|
|
3
32
|
//# sourceMappingURL=debug.js.map
|