oc-codex-multi-auth 6.0.0 → 6.1.0
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/LICENSE +1 -1
- package/README.md +58 -18
- package/assets/readme-hero.svg +10 -10
- package/config/README.md +1 -1
- package/config/minimal-opencode.json +1 -1
- package/config/opencode-legacy.json +1 -1
- package/config/opencode-modern.json +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +98 -2520
- package/dist/index.js.map +1 -1
- package/dist/lib/accounts/persistence.d.ts +34 -0
- package/dist/lib/accounts/persistence.d.ts.map +1 -0
- package/dist/lib/accounts/persistence.js +153 -0
- package/dist/lib/accounts/persistence.js.map +1 -0
- package/dist/lib/accounts/recovery.d.ts +59 -0
- package/dist/lib/accounts/recovery.d.ts.map +1 -0
- package/dist/lib/accounts/recovery.js +229 -0
- package/dist/lib/accounts/recovery.js.map +1 -0
- package/dist/lib/accounts/rotation.d.ts +40 -0
- package/dist/lib/accounts/rotation.d.ts.map +1 -0
- package/dist/lib/accounts/rotation.js +204 -0
- package/dist/lib/accounts/rotation.js.map +1 -0
- package/dist/lib/accounts/state.d.ts +92 -0
- package/dist/lib/accounts/state.d.ts.map +1 -0
- package/dist/lib/accounts/state.js +366 -0
- package/dist/lib/accounts/state.js.map +1 -0
- package/dist/lib/accounts.d.ts +48 -91
- package/dist/lib/accounts.d.ts.map +1 -1
- package/dist/lib/accounts.js +121 -699
- package/dist/lib/accounts.js.map +1 -1
- package/dist/lib/auth/auth.d.ts +1 -1
- package/dist/lib/auth/auth.d.ts.map +1 -1
- package/dist/lib/auth/auth.js +5 -2
- package/dist/lib/auth/auth.js.map +1 -1
- package/dist/lib/auth/login-runner.d.ts +32 -0
- package/dist/lib/auth/login-runner.d.ts.map +1 -1
- package/dist/lib/auth/login-runner.js +79 -64
- package/dist/lib/auth/login-runner.js.map +1 -1
- package/dist/lib/auth/server.d.ts.map +1 -1
- package/dist/lib/auth/server.js +3 -8
- package/dist/lib/auth/server.js.map +1 -1
- package/dist/lib/circuit-breaker.d.ts +53 -2
- package/dist/lib/circuit-breaker.d.ts.map +1 -1
- package/dist/lib/circuit-breaker.js +65 -6
- package/dist/lib/circuit-breaker.js.map +1 -1
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +77 -32
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/error-sentinels.d.ts +20 -0
- package/dist/lib/error-sentinels.d.ts.map +1 -0
- package/dist/lib/error-sentinels.js +28 -0
- package/dist/lib/error-sentinels.js.map +1 -0
- package/dist/lib/errors.d.ts +100 -1
- package/dist/lib/errors.d.ts.map +1 -1
- package/dist/lib/errors.js +116 -1
- package/dist/lib/errors.js.map +1 -1
- package/dist/lib/logger.d.ts +14 -1
- package/dist/lib/logger.d.ts.map +1 -1
- package/dist/lib/logger.js +65 -5
- package/dist/lib/logger.js.map +1 -1
- package/dist/lib/oauth-constants.d.ts +18 -0
- package/dist/lib/oauth-constants.d.ts.map +1 -0
- package/dist/lib/oauth-constants.js +18 -0
- package/dist/lib/oauth-constants.js.map +1 -0
- package/dist/lib/oauth-success.d.ts +2 -0
- package/dist/lib/oauth-success.d.ts.map +1 -0
- package/dist/lib/oauth-success.html +711 -711
- package/dist/lib/oauth-success.js +714 -0
- package/dist/lib/oauth-success.js.map +1 -0
- package/dist/lib/prompts/codex.d.ts.map +1 -1
- package/dist/lib/prompts/codex.js +12 -3
- package/dist/lib/prompts/codex.js.map +1 -1
- package/dist/lib/prompts/opencode-codex.d.ts.map +1 -1
- package/dist/lib/prompts/opencode-codex.js +3 -2
- package/dist/lib/prompts/opencode-codex.js.map +1 -1
- package/dist/lib/recovery/hook.d.ts +43 -0
- package/dist/lib/recovery/hook.d.ts.map +1 -0
- package/dist/lib/recovery/hook.js +325 -0
- package/dist/lib/recovery/hook.js.map +1 -0
- package/dist/lib/recovery/index.d.ts +1 -0
- package/dist/lib/recovery/index.d.ts.map +1 -1
- package/dist/lib/recovery/index.js +1 -0
- package/dist/lib/recovery/index.js.map +1 -1
- package/dist/lib/recovery/storage.d.ts.map +1 -1
- package/dist/lib/recovery/storage.js +5 -1
- package/dist/lib/recovery/storage.js.map +1 -1
- package/dist/lib/recovery.d.ts +15 -30
- package/dist/lib/recovery.d.ts.map +1 -1
- package/dist/lib/recovery.js +14 -312
- package/dist/lib/recovery.js.map +1 -1
- package/dist/lib/request/fetch-helpers.js +1 -1
- package/dist/lib/request/fetch-helpers.js.map +1 -1
- package/dist/lib/request/response-handler.d.ts.map +1 -1
- package/dist/lib/request/response-handler.js +8 -2
- package/dist/lib/request/response-handler.js.map +1 -1
- package/dist/lib/runtime.d.ts +101 -0
- package/dist/lib/runtime.d.ts.map +1 -0
- package/dist/lib/runtime.js +77 -0
- package/dist/lib/runtime.js.map +1 -0
- package/dist/lib/schemas.d.ts +164 -1
- package/dist/lib/schemas.d.ts.map +1 -1
- package/dist/lib/schemas.js +251 -0
- package/dist/lib/schemas.js.map +1 -1
- package/dist/lib/storage/atomic-write.d.ts +31 -0
- package/dist/lib/storage/atomic-write.d.ts.map +1 -0
- package/dist/lib/storage/atomic-write.js +75 -0
- package/dist/lib/storage/atomic-write.js.map +1 -0
- package/dist/lib/storage/backup.d.ts +13 -0
- package/dist/lib/storage/backup.d.ts.map +1 -0
- package/dist/lib/storage/backup.js +59 -0
- package/dist/lib/storage/backup.js.map +1 -0
- package/dist/lib/storage/errors.d.ts +17 -0
- package/dist/lib/storage/errors.d.ts.map +1 -0
- package/dist/lib/storage/errors.js +38 -0
- package/dist/lib/storage/errors.js.map +1 -0
- package/dist/lib/storage/export-import.d.ts +84 -0
- package/dist/lib/storage/export-import.d.ts.map +1 -0
- package/dist/lib/storage/export-import.js +222 -0
- package/dist/lib/storage/export-import.js.map +1 -0
- package/dist/lib/storage/flagged.d.ts +29 -0
- package/dist/lib/storage/flagged.d.ts.map +1 -0
- package/dist/lib/storage/flagged.js +207 -0
- package/dist/lib/storage/flagged.js.map +1 -0
- package/dist/lib/storage/identity.d.ts +72 -0
- package/dist/lib/storage/identity.d.ts.map +1 -0
- package/dist/lib/storage/identity.js +230 -0
- package/dist/lib/storage/identity.js.map +1 -0
- package/dist/lib/storage/keychain.d.ts +146 -0
- package/dist/lib/storage/keychain.d.ts.map +1 -0
- package/dist/lib/storage/keychain.js +278 -0
- package/dist/lib/storage/keychain.js.map +1 -0
- package/dist/lib/storage/load-save.d.ts +61 -0
- package/dist/lib/storage/load-save.d.ts.map +1 -0
- package/dist/lib/storage/load-save.js +606 -0
- package/dist/lib/storage/load-save.js.map +1 -0
- package/dist/lib/storage/migrations.d.ts +35 -0
- package/dist/lib/storage/migrations.d.ts.map +1 -1
- package/dist/lib/storage/migrations.js +37 -0
- package/dist/lib/storage/migrations.js.map +1 -1
- package/dist/lib/storage/normalize.d.ts +22 -0
- package/dist/lib/storage/normalize.d.ts.map +1 -0
- package/dist/lib/storage/normalize.js +114 -0
- package/dist/lib/storage/normalize.js.map +1 -0
- package/dist/lib/storage/paths.d.ts.map +1 -1
- package/dist/lib/storage/paths.js +2 -1
- package/dist/lib/storage/paths.js.map +1 -1
- package/dist/lib/storage/state.d.ts +46 -0
- package/dist/lib/storage/state.d.ts.map +1 -0
- package/dist/lib/storage/state.js +100 -0
- package/dist/lib/storage/state.js.map +1 -0
- package/dist/lib/storage/worktree-lock.d.ts +79 -0
- package/dist/lib/storage/worktree-lock.d.ts.map +1 -0
- package/dist/lib/storage/worktree-lock.js +265 -0
- package/dist/lib/storage/worktree-lock.js.map +1 -0
- package/dist/lib/storage.d.ts +21 -155
- package/dist/lib/storage.d.ts.map +1 -1
- package/dist/lib/storage.js +24 -1167
- package/dist/lib/storage.js.map +1 -1
- package/dist/lib/tools/_shared.d.ts +16 -0
- package/dist/lib/tools/_shared.d.ts.map +1 -0
- package/dist/lib/tools/_shared.js +21 -0
- package/dist/lib/tools/_shared.js.map +1 -0
- package/dist/lib/tools/codex-dashboard.d.ts +8 -0
- package/dist/lib/tools/codex-dashboard.d.ts.map +1 -0
- package/dist/lib/tools/codex-dashboard.js +176 -0
- package/dist/lib/tools/codex-dashboard.js.map +1 -0
- package/dist/lib/tools/codex-diag.d.ts +19 -0
- package/dist/lib/tools/codex-diag.d.ts.map +1 -0
- package/dist/lib/tools/codex-diag.js +139 -0
- package/dist/lib/tools/codex-diag.js.map +1 -0
- package/dist/lib/tools/codex-diff.d.ts +44 -0
- package/dist/lib/tools/codex-diff.d.ts.map +1 -0
- package/dist/lib/tools/codex-diff.js +284 -0
- package/dist/lib/tools/codex-diff.js.map +1 -0
- package/dist/lib/tools/codex-doctor.d.ts +8 -0
- package/dist/lib/tools/codex-doctor.d.ts.map +1 -0
- package/dist/lib/tools/codex-doctor.js +284 -0
- package/dist/lib/tools/codex-doctor.js.map +1 -0
- package/dist/lib/tools/codex-export.d.ts +8 -0
- package/dist/lib/tools/codex-export.d.ts.map +1 -0
- package/dist/lib/tools/codex-export.js +63 -0
- package/dist/lib/tools/codex-export.js.map +1 -0
- package/dist/lib/tools/codex-health.d.ts +8 -0
- package/dist/lib/tools/codex-health.d.ts.map +1 -0
- package/dist/lib/tools/codex-health.js +124 -0
- package/dist/lib/tools/codex-health.js.map +1 -0
- package/dist/lib/tools/codex-help.d.ts +8 -0
- package/dist/lib/tools/codex-help.d.ts.map +1 -0
- package/dist/lib/tools/codex-help.js +127 -0
- package/dist/lib/tools/codex-help.js.map +1 -0
- package/dist/lib/tools/codex-import.d.ts +8 -0
- package/dist/lib/tools/codex-import.d.ts.map +1 -0
- package/dist/lib/tools/codex-import.js +97 -0
- package/dist/lib/tools/codex-import.js.map +1 -0
- package/dist/lib/tools/codex-keychain.d.ts +36 -0
- package/dist/lib/tools/codex-keychain.d.ts.map +1 -0
- package/dist/lib/tools/codex-keychain.js +289 -0
- package/dist/lib/tools/codex-keychain.js.map +1 -0
- package/dist/lib/tools/codex-label.d.ts +8 -0
- package/dist/lib/tools/codex-label.d.ts.map +1 -0
- package/dist/lib/tools/codex-label.js +143 -0
- package/dist/lib/tools/codex-label.js.map +1 -0
- package/dist/lib/tools/codex-limits.d.ts +8 -0
- package/dist/lib/tools/codex-limits.d.ts.map +1 -0
- package/dist/lib/tools/codex-limits.js +497 -0
- package/dist/lib/tools/codex-limits.js.map +1 -0
- package/dist/lib/tools/codex-list.d.ts +8 -0
- package/dist/lib/tools/codex-list.d.ts.map +1 -0
- package/dist/lib/tools/codex-list.js +260 -0
- package/dist/lib/tools/codex-list.js.map +1 -0
- package/dist/lib/tools/codex-metrics.d.ts +8 -0
- package/dist/lib/tools/codex-metrics.d.ts.map +1 -0
- package/dist/lib/tools/codex-metrics.js +180 -0
- package/dist/lib/tools/codex-metrics.js.map +1 -0
- package/dist/lib/tools/codex-next.d.ts +8 -0
- package/dist/lib/tools/codex-next.d.ts.map +1 -0
- package/dist/lib/tools/codex-next.js +54 -0
- package/dist/lib/tools/codex-next.js.map +1 -0
- package/dist/lib/tools/codex-note.d.ts +8 -0
- package/dist/lib/tools/codex-note.d.ts.map +1 -0
- package/dist/lib/tools/codex-note.js +79 -0
- package/dist/lib/tools/codex-note.js.map +1 -0
- package/dist/lib/tools/codex-refresh.d.ts +8 -0
- package/dist/lib/tools/codex-refresh.d.ts.map +1 -0
- package/dist/lib/tools/codex-refresh.js +78 -0
- package/dist/lib/tools/codex-refresh.js.map +1 -0
- package/dist/lib/tools/codex-remove.d.ts +8 -0
- package/dist/lib/tools/codex-remove.d.ts.map +1 -0
- package/dist/lib/tools/codex-remove.js +184 -0
- package/dist/lib/tools/codex-remove.js.map +1 -0
- package/dist/lib/tools/codex-setup.d.ts +8 -0
- package/dist/lib/tools/codex-setup.d.ts.map +1 -0
- package/dist/lib/tools/codex-setup.js +26 -0
- package/dist/lib/tools/codex-setup.js.map +1 -0
- package/dist/lib/tools/codex-status.d.ts +8 -0
- package/dist/lib/tools/codex-status.d.ts.map +1 -0
- package/dist/lib/tools/codex-status.js +263 -0
- package/dist/lib/tools/codex-status.js.map +1 -0
- package/dist/lib/tools/codex-switch.d.ts +8 -0
- package/dist/lib/tools/codex-switch.d.ts.map +1 -0
- package/dist/lib/tools/codex-switch.js +122 -0
- package/dist/lib/tools/codex-switch.js.map +1 -0
- package/dist/lib/tools/codex-tag.d.ts +8 -0
- package/dist/lib/tools/codex-tag.d.ts.map +1 -0
- package/dist/lib/tools/codex-tag.js +101 -0
- package/dist/lib/tools/codex-tag.js.map +1 -0
- package/dist/lib/tools/index.d.ts +143 -0
- package/dist/lib/tools/index.d.ts.map +1 -0
- package/dist/lib/tools/index.js +67 -0
- package/dist/lib/tools/index.js.map +1 -0
- package/dist/lib/ui/format.d.ts.map +1 -1
- package/dist/lib/ui/format.js +5 -0
- package/dist/lib/ui/format.js.map +1 -1
- package/dist/lib/ui/runtime.d.ts +10 -0
- package/dist/lib/ui/runtime.d.ts.map +1 -1
- package/dist/lib/ui/runtime.js +16 -11
- package/dist/lib/ui/runtime.js.map +1 -1
- package/dist/lib/ui/select.d.ts.map +1 -1
- package/dist/lib/ui/select.js +12 -3
- package/dist/lib/ui/select.js.map +1 -1
- package/dist/lib/ui/theme.d.ts +19 -0
- package/dist/lib/ui/theme.d.ts.map +1 -1
- package/dist/lib/ui/theme.js +27 -0
- package/dist/lib/ui/theme.js.map +1 -1
- package/package.json +24 -16
- package/scripts/copy-oauth-success.js +16 -6
- package/scripts/install-oc-codex-multi-auth-core.js +462 -381
- package/scripts/install-oc-codex-multi-auth.js +15 -15
- package/scripts/test-all-models.sh +1 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `codex-export` tool — export accounts to JSON file.
|
|
3
|
+
* Extracted from `index.ts` per RC-1 Phase 2.
|
|
4
|
+
*/
|
|
5
|
+
import { tool } from "@opencode-ai/plugin/tool";
|
|
6
|
+
import { createTimestampedBackupPath, exportAccounts, loadAccounts, } from "../storage.js";
|
|
7
|
+
import { formatUiHeader, formatUiItem, formatUiKeyValue } from "../ui/format.js";
|
|
8
|
+
export function createCodexExportTool(ctx) {
|
|
9
|
+
const { resolveUiRuntime, getStatusMarker } = ctx;
|
|
10
|
+
return tool({
|
|
11
|
+
description: "Export accounts to a JSON file for backup or migration. Can auto-generate timestamped backup paths.",
|
|
12
|
+
args: {
|
|
13
|
+
path: tool.schema
|
|
14
|
+
.string()
|
|
15
|
+
.optional()
|
|
16
|
+
.describe("File path to export to (e.g., ~/codex-backup.json). If omitted, a timestamped backup path is used."),
|
|
17
|
+
force: tool.schema
|
|
18
|
+
.boolean()
|
|
19
|
+
.optional()
|
|
20
|
+
.describe("Overwrite existing file (default: true)"),
|
|
21
|
+
timestamped: tool.schema
|
|
22
|
+
.boolean()
|
|
23
|
+
.optional()
|
|
24
|
+
.describe("When true (default), omitted paths use a timestamped backup filename."),
|
|
25
|
+
},
|
|
26
|
+
async execute({ path: filePath, force, timestamped, }) {
|
|
27
|
+
const ui = resolveUiRuntime();
|
|
28
|
+
const shouldTimestamp = timestamped ?? true;
|
|
29
|
+
const resolvedExportPath = filePath && filePath.trim().length > 0
|
|
30
|
+
? filePath
|
|
31
|
+
: shouldTimestamp
|
|
32
|
+
? createTimestampedBackupPath()
|
|
33
|
+
: "codex-backup.json";
|
|
34
|
+
try {
|
|
35
|
+
await exportAccounts(resolvedExportPath, force ?? true);
|
|
36
|
+
const storage = await loadAccounts();
|
|
37
|
+
const count = storage?.accounts.length ?? 0;
|
|
38
|
+
if (ui.v2Enabled) {
|
|
39
|
+
return [
|
|
40
|
+
...formatUiHeader(ui, "Export accounts"),
|
|
41
|
+
"",
|
|
42
|
+
formatUiItem(ui, `${getStatusMarker(ui, "ok")} Exported ${count} account(s)`, "success"),
|
|
43
|
+
formatUiKeyValue(ui, "Path", resolvedExportPath, "muted"),
|
|
44
|
+
].join("\n");
|
|
45
|
+
}
|
|
46
|
+
return `Exported ${count} account(s) to: ${resolvedExportPath}`;
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
50
|
+
if (ui.v2Enabled) {
|
|
51
|
+
return [
|
|
52
|
+
...formatUiHeader(ui, "Export accounts"),
|
|
53
|
+
"",
|
|
54
|
+
formatUiItem(ui, `${getStatusMarker(ui, "error")} Export failed`, "danger"),
|
|
55
|
+
formatUiKeyValue(ui, "Error", msg, "danger"),
|
|
56
|
+
].join("\n");
|
|
57
|
+
}
|
|
58
|
+
return `Export failed: ${msg}`;
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=codex-export.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex-export.js","sourceRoot":"","sources":["../../../lib/tools/codex-export.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAuB,MAAM,0BAA0B,CAAC;AACrE,OAAO,EACN,2BAA2B,EAC3B,cAAc,EACd,YAAY,GACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGjF,MAAM,UAAU,qBAAqB,CAAC,GAAgB;IACrD,MAAM,EAAE,gBAAgB,EAAE,eAAe,EAAE,GAAG,GAAG,CAAC;IAClD,OAAO,IAAI,CAAC;QACX,WAAW,EACV,qGAAqG;QACtG,IAAI,EAAE;YACL,IAAI,EAAE,IAAI,CAAC,MAAM;iBACf,MAAM,EAAE;iBACR,QAAQ,EAAE;iBACV,QAAQ,CACR,oGAAoG,CACpG;YACF,KAAK,EAAE,IAAI,CAAC,MAAM;iBAChB,OAAO,EAAE;iBACT,QAAQ,EAAE;iBACV,QAAQ,CAAC,yCAAyC,CAAC;YACrD,WAAW,EAAE,IAAI,CAAC,MAAM;iBACtB,OAAO,EAAE;iBACT,QAAQ,EAAE;iBACV,QAAQ,CACR,uEAAuE,CACvE;SACF;QACD,KAAK,CAAC,OAAO,CAAC,EACb,IAAI,EAAE,QAAQ,EACd,KAAK,EACL,WAAW,GAKX;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,EACF,GAAG,eAAe,CAAC,EAAE,EAAE,OAAO,CAAC,gBAAgB,EAC/C,QAAQ,CACR;wBACD,gBAAgB,CAAC,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,CAAC;qBAC5C,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACd,CAAC;gBACD,OAAO,kBAAkB,GAAG,EAAE,CAAC;YAChC,CAAC;QACF,CAAC;KACD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `codex-health` tool — verify refresh tokens for all accounts.
|
|
3
|
+
* Extracted from `index.ts` per RC-1 Phase 2.
|
|
4
|
+
*/
|
|
5
|
+
import { type ToolDefinition } from "@opencode-ai/plugin/tool";
|
|
6
|
+
import type { ToolContext } from "./index.js";
|
|
7
|
+
export declare function createCodexHealthTool(ctx: ToolContext): ToolDefinition;
|
|
8
|
+
//# sourceMappingURL=codex-health.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex-health.d.ts","sourceRoot":"","sources":["../../../lib/tools/codex-health.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,KAAK,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAKrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,WAAW,GAAG,cAAc,CA6ItE"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `codex-health` tool — verify refresh tokens for all accounts.
|
|
3
|
+
* Extracted from `index.ts` per RC-1 Phase 2.
|
|
4
|
+
*/
|
|
5
|
+
import { tool } from "@opencode-ai/plugin/tool";
|
|
6
|
+
import { loadAccounts } from "../storage.js";
|
|
7
|
+
import { queuedRefresh } from "../refresh-queue.js";
|
|
8
|
+
import { formatUiHeader, formatUiItem, paintUiText } from "../ui/format.js";
|
|
9
|
+
import { normalizeToolOutputFormat, renderJsonOutput } from "../runtime.js";
|
|
10
|
+
export function createCodexHealthTool(ctx) {
|
|
11
|
+
const { resolveUiRuntime, formatCommandAccountLabel, getStatusMarker, buildJsonAccountIdentity, } = ctx;
|
|
12
|
+
return tool({
|
|
13
|
+
description: "Check health of all Codex accounts by validating refresh tokens.",
|
|
14
|
+
args: {
|
|
15
|
+
format: tool.schema
|
|
16
|
+
.string()
|
|
17
|
+
.optional()
|
|
18
|
+
.describe('Output format: "text" (default) or "json".'),
|
|
19
|
+
includeSensitive: tool.schema
|
|
20
|
+
.boolean()
|
|
21
|
+
.optional()
|
|
22
|
+
.describe("Include raw account labels, emails, and account IDs in JSON output. Defaults to false."),
|
|
23
|
+
},
|
|
24
|
+
async execute({ format, includeSensitive, } = {}) {
|
|
25
|
+
const ui = resolveUiRuntime();
|
|
26
|
+
const outputFormat = normalizeToolOutputFormat(format);
|
|
27
|
+
const includeSensitiveOutput = includeSensitive === true;
|
|
28
|
+
const storage = await loadAccounts();
|
|
29
|
+
if (!storage || storage.accounts.length === 0) {
|
|
30
|
+
if (outputFormat === "json") {
|
|
31
|
+
return renderJsonOutput({
|
|
32
|
+
message: "No Codex accounts configured. Run: opencode auth login",
|
|
33
|
+
totalAccounts: 0,
|
|
34
|
+
healthyCount: 0,
|
|
35
|
+
unhealthyCount: 0,
|
|
36
|
+
accounts: [],
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
if (ui.v2Enabled) {
|
|
40
|
+
return [
|
|
41
|
+
...formatUiHeader(ui, "Health check"),
|
|
42
|
+
"",
|
|
43
|
+
formatUiItem(ui, "No accounts configured.", "warning"),
|
|
44
|
+
formatUiItem(ui, "Run: opencode auth login", "accent"),
|
|
45
|
+
].join("\n");
|
|
46
|
+
}
|
|
47
|
+
return "No Codex accounts configured. Run: opencode auth login";
|
|
48
|
+
}
|
|
49
|
+
const results = ui.v2Enabled
|
|
50
|
+
? []
|
|
51
|
+
: [`Health Check (${storage.accounts.length} accounts):`, ""];
|
|
52
|
+
const jsonAccounts = [];
|
|
53
|
+
let healthyCount = 0;
|
|
54
|
+
let unhealthyCount = 0;
|
|
55
|
+
for (let i = 0; i < storage.accounts.length; i++) {
|
|
56
|
+
const account = storage.accounts[i];
|
|
57
|
+
if (!account)
|
|
58
|
+
continue;
|
|
59
|
+
const label = formatCommandAccountLabel(account, i);
|
|
60
|
+
try {
|
|
61
|
+
const refreshResult = await queuedRefresh(account.refreshToken);
|
|
62
|
+
if (refreshResult.type === "success") {
|
|
63
|
+
jsonAccounts.push({
|
|
64
|
+
...buildJsonAccountIdentity(i, {
|
|
65
|
+
includeSensitive: includeSensitiveOutput,
|
|
66
|
+
account,
|
|
67
|
+
label,
|
|
68
|
+
}),
|
|
69
|
+
status: "healthy",
|
|
70
|
+
});
|
|
71
|
+
results.push(` ${getStatusMarker(ui, "ok")} ${label}: Healthy`);
|
|
72
|
+
healthyCount++;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
jsonAccounts.push({
|
|
76
|
+
...buildJsonAccountIdentity(i, {
|
|
77
|
+
includeSensitive: includeSensitiveOutput,
|
|
78
|
+
account,
|
|
79
|
+
label,
|
|
80
|
+
}),
|
|
81
|
+
status: "unhealthy",
|
|
82
|
+
error: refreshResult.message ?? refreshResult.reason,
|
|
83
|
+
});
|
|
84
|
+
results.push(` ${getStatusMarker(ui, "error")} ${label}: Token refresh failed`);
|
|
85
|
+
unhealthyCount++;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
90
|
+
jsonAccounts.push({
|
|
91
|
+
...buildJsonAccountIdentity(i, {
|
|
92
|
+
includeSensitive: includeSensitiveOutput,
|
|
93
|
+
account,
|
|
94
|
+
label,
|
|
95
|
+
}),
|
|
96
|
+
status: "unhealthy",
|
|
97
|
+
error: errorMsg.slice(0, 120),
|
|
98
|
+
});
|
|
99
|
+
results.push(` ${getStatusMarker(ui, "error")} ${label}: Error - ${errorMsg.slice(0, 120)}`);
|
|
100
|
+
unhealthyCount++;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
results.push("");
|
|
104
|
+
results.push(`Summary: ${healthyCount} healthy, ${unhealthyCount} unhealthy`);
|
|
105
|
+
if (outputFormat === "json") {
|
|
106
|
+
return renderJsonOutput({
|
|
107
|
+
totalAccounts: storage.accounts.length,
|
|
108
|
+
healthyCount,
|
|
109
|
+
unhealthyCount,
|
|
110
|
+
accounts: jsonAccounts,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
if (ui.v2Enabled) {
|
|
114
|
+
return [
|
|
115
|
+
...formatUiHeader(ui, "Health check"),
|
|
116
|
+
"",
|
|
117
|
+
...results.map((line) => paintUiText(ui, line, "normal")),
|
|
118
|
+
].join("\n");
|
|
119
|
+
}
|
|
120
|
+
return results.join("\n");
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=codex-health.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex-health.js","sourceRoot":"","sources":["../../../lib/tools/codex-health.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAuB,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAG5E,MAAM,UAAU,qBAAqB,CAAC,GAAgB;IACrD,MAAM,EACL,gBAAgB,EAChB,yBAAyB,EACzB,eAAe,EACf,wBAAwB,GACxB,GAAG,GAAG,CAAC;IACR,OAAO,IAAI,CAAC;QACX,WAAW,EACV,kEAAkE;QAC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I,EAAE,EAAE,CAAC,WAAW,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;iBACzD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACd,CAAC;YAED,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3B,CAAC;KACD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `codex-help` tool — beginner-friendly command guide.
|
|
3
|
+
* Extracted from `index.ts` per RC-1 Phase 2.
|
|
4
|
+
*/
|
|
5
|
+
import { type ToolDefinition } from "@opencode-ai/plugin/tool";
|
|
6
|
+
import type { ToolContext } from "./index.js";
|
|
7
|
+
export declare function createCodexHelpTool(ctx: ToolContext): ToolDefinition;
|
|
8
|
+
//# sourceMappingURL=codex-help.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex-help.d.ts","sourceRoot":"","sources":["../../../lib/tools/codex-help.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,KAAK,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAMrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,WAAW,GAAG,cAAc,CA8IpE"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `codex-help` tool — beginner-friendly command guide.
|
|
3
|
+
* Extracted from `index.ts` per RC-1 Phase 2.
|
|
4
|
+
*/
|
|
5
|
+
import { tool } from "@opencode-ai/plugin/tool";
|
|
6
|
+
import { formatUiHeader, formatUiItem, formatUiSection, } from "../ui/format.js";
|
|
7
|
+
export function createCodexHelpTool(ctx) {
|
|
8
|
+
const { resolveUiRuntime } = ctx;
|
|
9
|
+
return tool({
|
|
10
|
+
description: "Beginner-friendly command guide with quickstart and troubleshooting flows.",
|
|
11
|
+
args: {
|
|
12
|
+
topic: tool.schema
|
|
13
|
+
.string()
|
|
14
|
+
.optional()
|
|
15
|
+
.describe("Optional topic: setup, switch, health, backup, dashboard, metrics."),
|
|
16
|
+
},
|
|
17
|
+
async execute({ topic }) {
|
|
18
|
+
const ui = resolveUiRuntime();
|
|
19
|
+
await Promise.resolve();
|
|
20
|
+
const normalizedTopic = (topic ?? "").trim().toLowerCase();
|
|
21
|
+
const sections = [
|
|
22
|
+
{
|
|
23
|
+
key: "setup",
|
|
24
|
+
title: "Quickstart",
|
|
25
|
+
lines: [
|
|
26
|
+
"1) Add account: opencode auth login",
|
|
27
|
+
"2) Verify account health: codex-health",
|
|
28
|
+
"3) View account list: codex-list",
|
|
29
|
+
"4) Run checklist: codex-setup",
|
|
30
|
+
"5) Use guided wizard: codex-setup --wizard",
|
|
31
|
+
"6) Start requests and monitor: codex-dashboard",
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
key: "switch",
|
|
36
|
+
title: "Daily account operations",
|
|
37
|
+
lines: [
|
|
38
|
+
"List accounts: codex-list",
|
|
39
|
+
"Switch active account: codex-switch index=2",
|
|
40
|
+
"Show detailed status: codex-status",
|
|
41
|
+
"Set account label: codex-label index=2 label=\"Work\"",
|
|
42
|
+
"Set account tags: codex-tag index=2 tags=\"work,team-a\"",
|
|
43
|
+
"Set account note: codex-note index=2 note=\"weekday primary\"",
|
|
44
|
+
"Filter by tag: codex-list tag=\"work\"",
|
|
45
|
+
"Remove account: codex-remove index=2",
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
key: "health",
|
|
50
|
+
title: "Health and recovery",
|
|
51
|
+
lines: [
|
|
52
|
+
"Verify token health: codex-health",
|
|
53
|
+
"Refresh all tokens: codex-refresh",
|
|
54
|
+
"Run diagnostics: codex-doctor",
|
|
55
|
+
"Run diagnostics with fixes: codex-doctor --fix",
|
|
56
|
+
"Show best next action: codex-next",
|
|
57
|
+
"Run guided wizard: codex-setup --wizard",
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
key: "dashboard",
|
|
62
|
+
title: "Monitoring",
|
|
63
|
+
lines: [
|
|
64
|
+
"Live dashboard: codex-dashboard",
|
|
65
|
+
"Runtime metrics: codex-metrics",
|
|
66
|
+
"Per-account status detail: codex-status",
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
key: "backup",
|
|
71
|
+
title: "Backup and migration",
|
|
72
|
+
lines: [
|
|
73
|
+
"Export accounts: codex-export <path>",
|
|
74
|
+
"Auto backup export: codex-export",
|
|
75
|
+
"Import preview: codex-import <path> --dryRun",
|
|
76
|
+
"Import apply: codex-import <path>",
|
|
77
|
+
"Setup checklist: codex-setup",
|
|
78
|
+
],
|
|
79
|
+
},
|
|
80
|
+
];
|
|
81
|
+
const visibleSections = normalizedTopic.length === 0
|
|
82
|
+
? sections
|
|
83
|
+
: sections.filter((section) => section.key.includes(normalizedTopic));
|
|
84
|
+
if (visibleSections.length === 0) {
|
|
85
|
+
const available = sections.map((section) => section.key).join(", ");
|
|
86
|
+
if (ui.v2Enabled) {
|
|
87
|
+
return [
|
|
88
|
+
...formatUiHeader(ui, "Codex help"),
|
|
89
|
+
"",
|
|
90
|
+
formatUiItem(ui, `Unknown topic: ${normalizedTopic}`, "warning"),
|
|
91
|
+
formatUiItem(ui, `Available topics: ${available}`, "muted"),
|
|
92
|
+
].join("\n");
|
|
93
|
+
}
|
|
94
|
+
return `Unknown topic: ${normalizedTopic}\n\nAvailable topics: ${available}`;
|
|
95
|
+
}
|
|
96
|
+
if (ui.v2Enabled) {
|
|
97
|
+
const lines = [...formatUiHeader(ui, "Codex help"), ""];
|
|
98
|
+
for (const section of visibleSections) {
|
|
99
|
+
lines.push(...formatUiSection(ui, section.title));
|
|
100
|
+
for (const line of section.lines) {
|
|
101
|
+
lines.push(formatUiItem(ui, line));
|
|
102
|
+
}
|
|
103
|
+
lines.push("");
|
|
104
|
+
}
|
|
105
|
+
lines.push(...formatUiSection(ui, "Tips"));
|
|
106
|
+
lines.push(formatUiItem(ui, "Run codex-setup after adding accounts."));
|
|
107
|
+
lines.push(formatUiItem(ui, "Use codex-setup --wizard for menu-driven onboarding."));
|
|
108
|
+
lines.push(formatUiItem(ui, "Use codex-doctor when request failures increase."));
|
|
109
|
+
return lines.join("\n").trimEnd();
|
|
110
|
+
}
|
|
111
|
+
const lines = ["Codex Help:", ""];
|
|
112
|
+
for (const section of visibleSections) {
|
|
113
|
+
lines.push(`${section.title}:`);
|
|
114
|
+
for (const line of section.lines) {
|
|
115
|
+
lines.push(` - ${line}`);
|
|
116
|
+
}
|
|
117
|
+
lines.push("");
|
|
118
|
+
}
|
|
119
|
+
lines.push("Tips:");
|
|
120
|
+
lines.push(" - Run codex-setup after adding accounts.");
|
|
121
|
+
lines.push(" - Use codex-setup --wizard for menu-driven onboarding.");
|
|
122
|
+
lines.push(" - Use codex-doctor when request failures increase.");
|
|
123
|
+
return lines.join("\n");
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=codex-help.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex-help.js","sourceRoot":"","sources":["../../../lib/tools/codex-help.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAuB,MAAM,0BAA0B,CAAC;AACrE,OAAO,EACN,cAAc,EACd,YAAY,EACZ,eAAe,GACf,MAAM,iBAAiB,CAAC;AAGzB,MAAM,UAAU,mBAAmB,CAAC,GAAgB;IACnD,MAAM,EAAE,gBAAgB,EAAE,GAAG,GAAG,CAAC;IACjC,OAAO,IAAI,CAAC;QACX,WAAW,EACV,4EAA4E;QAC7E,IAAI,EAAE;YACL,KAAK,EAAE,IAAI,CAAC,MAAM;iBAChB,MAAM,EAAE;iBACR,QAAQ,EAAE;iBACV,QAAQ,CACR,oEAAoE,CACpE;SACF;QACD,KAAK,CAA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AAG,eAAe,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;gBAC3C,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,EAAE,wCAAwC,CAAC,CAAC,CAAC;gBACvE,KAAK,CAAC,IAAI,CACT,YAAY,CACX,EAAE,EACF,sDAAsD,CACtD,CACD,CAAC;gBACF,KAAK,CAAC,IAAI,CACT,YAAY,CACX,EAAE,EACF,kDAAkD,CAClD,CACD,CAAC;gBACF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;YACnC,CAAC;YAED,MAAM,KAAK,GAAa,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;YAC5C,KAAK,MAAM,OAAO,IAAI,eAAe,EAAE,CAAC;gBACvC,KAAK,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC;gBAChC,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;oBAClC,KAAK,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;gBAC3B,CAAC;gBACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAChB,CAAC;YACD,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACpB,KAAK,CAAC,IAAI,CAAC,4CAA4C,CAAC,CAAC;YACzD,KAAK,CAAC,IAAI,CACT,0DAA0D,CAC1D,CAAC;YACF,KAAK,CAAC,IAAI,CAAC,sDAAsD,CAAC,CAAC;YACnE,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC;KACD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `codex-import` tool — import accounts from JSON file.
|
|
3
|
+
* Extracted from `index.ts` per RC-1 Phase 2.
|
|
4
|
+
*/
|
|
5
|
+
import { type ToolDefinition } from "@opencode-ai/plugin/tool";
|
|
6
|
+
import type { ToolContext } from "./index.js";
|
|
7
|
+
export declare function createCodexImportTool(ctx: ToolContext): ToolDefinition;
|
|
8
|
+
//# sourceMappingURL=codex-import.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex-import.d.ts","sourceRoot":"","sources":["../../../lib/tools/codex-import.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,KAAK,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAGrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,WAAW,GAAG,cAAc,CAoJtE"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `codex-import` tool — import accounts from JSON file.
|
|
3
|
+
* Extracted from `index.ts` per RC-1 Phase 2.
|
|
4
|
+
*/
|
|
5
|
+
import { tool } from "@opencode-ai/plugin/tool";
|
|
6
|
+
import { importAccounts, previewImportAccounts } from "../storage.js";
|
|
7
|
+
import { formatUiHeader, formatUiItem, formatUiKeyValue } from "../ui/format.js";
|
|
8
|
+
export function createCodexImportTool(ctx) {
|
|
9
|
+
const { resolveUiRuntime, getStatusMarker, invalidateAccountManagerCache } = ctx;
|
|
10
|
+
return tool({
|
|
11
|
+
description: "Import accounts from a JSON file, with dry-run preview and automatic timestamped backup before apply.",
|
|
12
|
+
args: {
|
|
13
|
+
path: tool.schema
|
|
14
|
+
.string()
|
|
15
|
+
.describe("File path to import from (e.g., ~/codex-backup.json)"),
|
|
16
|
+
dryRun: tool.schema
|
|
17
|
+
.boolean()
|
|
18
|
+
.optional()
|
|
19
|
+
.describe("Preview import impact without applying changes."),
|
|
20
|
+
},
|
|
21
|
+
async execute({ path: filePath, dryRun, }) {
|
|
22
|
+
const ui = resolveUiRuntime();
|
|
23
|
+
try {
|
|
24
|
+
const preview = await previewImportAccounts(filePath);
|
|
25
|
+
if (dryRun) {
|
|
26
|
+
if (ui.v2Enabled) {
|
|
27
|
+
return [
|
|
28
|
+
...formatUiHeader(ui, "Import preview"),
|
|
29
|
+
"",
|
|
30
|
+
formatUiItem(ui, "No changes applied (dry run).", "warning"),
|
|
31
|
+
formatUiKeyValue(ui, "Path", filePath, "muted"),
|
|
32
|
+
formatUiKeyValue(ui, "New accounts", String(preview.imported), preview.imported > 0 ? "success" : "muted"),
|
|
33
|
+
formatUiKeyValue(ui, "Duplicates skipped", String(preview.skipped), preview.skipped > 0 ? "warning" : "muted"),
|
|
34
|
+
formatUiKeyValue(ui, "Resulting total", String(preview.total), "accent"),
|
|
35
|
+
].join("\n");
|
|
36
|
+
}
|
|
37
|
+
return [
|
|
38
|
+
"Import preview (dry run):",
|
|
39
|
+
`Path: ${filePath}`,
|
|
40
|
+
`New accounts: ${preview.imported}`,
|
|
41
|
+
`Duplicates skipped: ${preview.skipped}`,
|
|
42
|
+
`Resulting total: ${preview.total}`,
|
|
43
|
+
].join("\n");
|
|
44
|
+
}
|
|
45
|
+
const result = await importAccounts(filePath, {
|
|
46
|
+
preImportBackupPrefix: "codex-pre-import-backup",
|
|
47
|
+
backupMode: "required",
|
|
48
|
+
});
|
|
49
|
+
const backupSummary = result.backupStatus === "created"
|
|
50
|
+
? (result.backupPath ?? "created")
|
|
51
|
+
: result.backupStatus === "failed"
|
|
52
|
+
? `failed (${result.backupError ?? "unknown error"})`
|
|
53
|
+
: "skipped (no existing accounts)";
|
|
54
|
+
const backupStatus = result.backupStatus === "created" ? "ok" : "warning";
|
|
55
|
+
invalidateAccountManagerCache();
|
|
56
|
+
const lines = [`Import complete.`, ``];
|
|
57
|
+
lines.push(`Preview: +${preview.imported} new, ${preview.skipped} skipped, ${preview.total} total`);
|
|
58
|
+
lines.push(`Auto-backup: ${backupSummary}`);
|
|
59
|
+
if (result.imported > 0) {
|
|
60
|
+
lines.push(`New accounts: ${result.imported}`);
|
|
61
|
+
}
|
|
62
|
+
if (result.skipped > 0) {
|
|
63
|
+
lines.push(`Duplicates skipped: ${result.skipped}`);
|
|
64
|
+
}
|
|
65
|
+
lines.push(`Total accounts: ${result.total}`);
|
|
66
|
+
if (ui.v2Enabled) {
|
|
67
|
+
const styled = [
|
|
68
|
+
...formatUiHeader(ui, "Import accounts"),
|
|
69
|
+
"",
|
|
70
|
+
formatUiItem(ui, `${getStatusMarker(ui, "ok")} Import complete`, "success"),
|
|
71
|
+
formatUiKeyValue(ui, "Path", filePath, "muted"),
|
|
72
|
+
formatUiKeyValue(ui, "Auto-backup", backupSummary, backupStatus === "ok" ? "muted" : "warning"),
|
|
73
|
+
formatUiKeyValue(ui, "Preview", `+${preview.imported}, skipped=${preview.skipped}, total=${preview.total}`, "muted"),
|
|
74
|
+
formatUiKeyValue(ui, "New accounts", String(result.imported), result.imported > 0 ? "success" : "muted"),
|
|
75
|
+
formatUiKeyValue(ui, "Duplicates skipped", String(result.skipped), result.skipped > 0 ? "warning" : "muted"),
|
|
76
|
+
formatUiKeyValue(ui, "Total accounts", String(result.total), "accent"),
|
|
77
|
+
];
|
|
78
|
+
return styled.join("\n");
|
|
79
|
+
}
|
|
80
|
+
return lines.join("\n");
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
84
|
+
if (ui.v2Enabled) {
|
|
85
|
+
return [
|
|
86
|
+
...formatUiHeader(ui, "Import accounts"),
|
|
87
|
+
"",
|
|
88
|
+
formatUiItem(ui, `${getStatusMarker(ui, "error")} Import failed`, "danger"),
|
|
89
|
+
formatUiKeyValue(ui, "Error", msg, "danger"),
|
|
90
|
+
].join("\n");
|
|
91
|
+
}
|
|
92
|
+
return `Import failed: ${msg}`;
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=codex-import.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex-import.js","sourceRoot":"","sources":["../../../lib/tools/codex-import.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,gBAAgB,CACf,EAAE,EACF,oBAAoB,EACpB,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EACtB,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CACxC;wBACD,gBAAgB,CACf,EAAE,EACF,gBAAgB,EAChB,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EACpB,QAAQ,CACR;qBACD,CAAC;oBACF,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC1B,CAAC;gBACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACzB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,MAAM,GAAG,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACnE,IAAI,EAAE,CAAC,SAAS,EAAE,CAAC;oBAClB,OAAO;wBACN,GAAG,cAAc,CAAC,EAAE,EAAE,iBAAiB,CAAC;wBACxC,EAAE;wBACF,YAAY,CACX,EAAE,EACF,GAAG,eAAe,CAAC,EAAE,EAAE,OAAO,CAAC,gBAAgB,EAC/C,QAAQ,CACR;wBACD,gBAAgB,CAAC,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,CAAC;qBAC5C,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACd,CAAC;gBACD,OAAO,kBAAkB,GAAG,EAAE,CAAC;YAChC,CAAC;QACF,CAAC;KACD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `codex-keychain` tool — inspect and manage the opt-in OS-keychain backend.
|
|
3
|
+
*
|
|
4
|
+
* Phase 4 F1. Companion to `lib/storage/keychain.ts`. The tool exposes three
|
|
5
|
+
* subcommands chosen for operator-level control over the credential surface:
|
|
6
|
+
*
|
|
7
|
+
* - `status`: report which backend is active and whether the OS keychain
|
|
8
|
+
* is reachable. Never mutates state; safe to run under any config.
|
|
9
|
+
* - `migrate`: explicitly move the current on-disk JSON accounts file into
|
|
10
|
+
* the OS keychain, rename the JSON as
|
|
11
|
+
* `<path>.migrated-to-keychain.<ts>` for rollback, and leave the
|
|
12
|
+
* authoritative copy in the keychain. Idempotent: running again when
|
|
13
|
+
* the keychain already holds a fresher copy is a no-op.
|
|
14
|
+
* - `rollback`: restore the most recent `.migrated-to-keychain.<ts>`
|
|
15
|
+
* backup next to the accounts file and delete the keychain entry so
|
|
16
|
+
* subsequent loads read from disk again. The inverse of `migrate`.
|
|
17
|
+
*
|
|
18
|
+
* Runs under the same storage lock as `saveAccounts`/`loadAccounts` so the
|
|
19
|
+
* mutation cannot interleave with an in-flight rotation save.
|
|
20
|
+
*
|
|
21
|
+
* Security notes:
|
|
22
|
+
* - No secret value ever reaches the tool output. Success messages show
|
|
23
|
+
* account counts and file paths, never token material.
|
|
24
|
+
* - Failures fall back to JSON at the storage layer — this tool never
|
|
25
|
+
* hides that from the operator.
|
|
26
|
+
*/
|
|
27
|
+
import { type ToolDefinition } from "@opencode-ai/plugin/tool";
|
|
28
|
+
import type { ToolContext } from "./index.js";
|
|
29
|
+
/**
|
|
30
|
+
* Test-only export for `findMigrationBackups`. Kept separate from the
|
|
31
|
+
* tool factory so the sort semantics can be asserted directly against a
|
|
32
|
+
* temp directory in `test/tools-codex-keychain.test.ts`.
|
|
33
|
+
*/
|
|
34
|
+
export declare function _findMigrationBackupsForTests(storagePath: string): Promise<string[]>;
|
|
35
|
+
export declare function createCodexKeychainTool(ctx: ToolContext): ToolDefinition;
|
|
36
|
+
//# sourceMappingURL=codex-keychain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex-keychain.d.ts","sourceRoot":"","sources":["../../../lib/tools/codex-keychain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAIH,OAAO,EAAQ,KAAK,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAmBrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AA4D9C;;;;GAIG;AACH,wBAAsB,6BAA6B,CAClD,WAAW,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,EAAE,CAAC,CAEnB;AAED,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,WAAW,GAAG,cAAc,CAoPxE"}
|