open-multi-agent-kit 1.2.3 → 1.2.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 +14 -0
- package/README.md +2 -2
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +2 -0
- package/dist/cli/help.js.map +1 -1
- package/dist/commands/doctor-provider.d.ts.map +1 -1
- package/dist/commands/doctor-provider.js +2 -13
- package/dist/commands/doctor-provider.js.map +1 -1
- package/dist/commands/provider-adopt-cli.d.ts +24 -0
- package/dist/commands/provider-adopt-cli.d.ts.map +1 -0
- package/dist/commands/provider-adopt-cli.js +182 -0
- package/dist/commands/provider-adopt-cli.js.map +1 -0
- package/dist/commands/provider-adopt-status.d.ts +21 -0
- package/dist/commands/provider-adopt-status.d.ts.map +1 -0
- package/dist/commands/provider-adopt-status.js +84 -0
- package/dist/commands/provider-adopt-status.js.map +1 -0
- package/dist/commands/provider-known-apis.d.ts +2 -0
- package/dist/commands/provider-known-apis.d.ts.map +1 -0
- package/dist/commands/provider-known-apis.js +28 -0
- package/dist/commands/provider-known-apis.js.map +1 -0
- package/dist/commands/run-command.d.ts.map +1 -1
- package/dist/commands/run-command.js +4 -0
- package/dist/commands/run-command.js.map +1 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +6 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +16 -16
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +94 -111
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +13 -10
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/inert-tail.d.ts +23 -0
- package/dist/core/compaction/inert-tail.d.ts.map +1 -0
- package/dist/core/compaction/inert-tail.js +108 -0
- package/dist/core/compaction/inert-tail.js.map +1 -0
- package/dist/core/compaction/provenance.d.ts +30 -0
- package/dist/core/compaction/provenance.d.ts.map +1 -0
- package/dist/core/compaction/provenance.js +59 -0
- package/dist/core/compaction/provenance.js.map +1 -0
- package/dist/core/compaction/transaction.d.ts.map +1 -1
- package/dist/core/compaction/transaction.js +4 -1
- package/dist/core/compaction/transaction.js.map +1 -1
- package/dist/core/external-credential-sources.d.ts +48 -0
- package/dist/core/external-credential-sources.d.ts.map +1 -0
- package/dist/core/external-credential-sources.js +176 -0
- package/dist/core/external-credential-sources.js.map +1 -0
- package/dist/core/model-registry.d.ts +11 -0
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +28 -14
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/oauth-account-import.d.ts +52 -0
- package/dist/core/oauth-account-import.d.ts.map +1 -0
- package/dist/core/oauth-account-import.js +125 -0
- package/dist/core/oauth-account-import.js.map +1 -0
- package/dist/core/oauth-credential.d.ts +22 -0
- package/dist/core/oauth-credential.d.ts.map +1 -0
- package/dist/core/oauth-credential.js +36 -0
- package/dist/core/oauth-credential.js.map +1 -0
- package/dist/core/session-compaction-service.d.ts +2 -2
- package/dist/core/session-compaction-service.d.ts.map +1 -1
- package/dist/core/session-compaction-service.js +20 -57
- package/dist/core/session-compaction-service.js.map +1 -1
- package/dist/core/verified-run/owned-execution.d.ts.map +1 -1
- package/dist/core/verified-run/owned-execution.js +13 -1
- package/dist/core/verified-run/owned-execution.js.map +1 -1
- package/docs/compaction.md +2 -0
- package/docs/extensions.md +1 -1
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +18 -18
- package/package.json +6 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-adopt-cli.d.ts","sourceRoot":"","sources":["../../src/commands/provider-adopt-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA+BH,MAAM,WAAW,4BAA4B;IAC5C,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IAC5D,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IAC7C,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5C;AAED,MAAM,WAAW,uBAAuB;IACvC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC1B;AA+ID,wBAAsB,mBAAmB,CACxC,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,SAAS,GAAE,4BAAiC,GAC1C,OAAO,CAAC,uBAAuB,CAAC,CAmClC","sourcesContent":["/**\n * `omk provider adopt [<provider-id>] [--from <source>] [--dry-run] [--json] [--status]`\n *\n * Copies credentials this machine already holds (an OpenAI Codex CLI login, a Claude Code CLI\n * login) into OMK's own credential store, so a subscription does not have to be signed in twice.\n * `--status` only reports what the store holds; it never refreshes, writes or contacts a provider.\n *\n * Exit codes: 0 = adopted, already current, or status reported; 1 = no usable source or the store\n * is unreadable; 2 = usage error. No output contains token material.\n */\n\nimport { join } from \"node:path\";\nimport { APP_NAME, getAgentDir } from \"../config.ts\";\nimport { AuthStorage } from \"../core/auth-storage.ts\";\nimport {\n\tcredentialSourcePath,\n\tcredentialSourcesFor,\n\tEXTERNAL_CREDENTIAL_SOURCE_LABELS,\n\ttype ExternalCredentialIo,\n\ttype ExternalCredentialSourceId,\n\treadExternalCredential,\n} from \"../core/external-credential-sources.ts\";\nimport { readAuthStoreFile, storedProviderIds, writeStatusReport } from \"./provider-adopt-status.ts\";\n\nconst USAGE = `Usage: ${APP_NAME} provider adopt [<provider-id>] [--from <source>] [--dry-run] [--json] [--status]`;\nconst HELP = [\n\t\"Provider adopt: copy credentials that already exist on this machine into OMK's store.\",\n\t\"\",\n\tUSAGE,\n\t\"\",\n\t\" --from <source> credential store to read: codex-cli | claude-code\",\n\t\" --dry-run report what would change without writing auth.json\",\n\t\" --json print one JSON document instead of the text report\",\n\t\" --status report the stored accounts (valid/expired) and exit; writes nothing\",\n\t\"\",\n\t\"Sources: codex-cli = ~/.codex/auth.json (Codex CLI), claude-code = ~/.claude/.credentials.json.\",\n\t\"Providers: openai-codex <- codex-cli, anthropic <- claude-code.\",\n\t\"Exit codes: 0 = adopted or nothing to change, 1 = source unusable or store unreadable, 2 = usage error.\",\n].join(\"\\n\");\n\nexport interface ProviderAdoptCliDependencies {\n\treadonly agentDir?: string;\n\treadonly env?: Readonly<Record<string, string | undefined>>;\n\treadonly readFile?: (path: string) => string;\n\treadonly now?: () => number;\n\treadonly home?: string;\n\treadonly writeLine?: (line: string) => void;\n}\n\nexport interface ProviderAdoptCliOutcome {\n\treadonly handled: boolean;\n\treadonly exitCode: number;\n}\n\ntype ParsedAdoptArgs = {\n\treadonly providerId?: string;\n\treadonly from?: ExternalCredentialSourceId;\n\treadonly dryRun: boolean;\n\treadonly json: boolean;\n\treadonly status: boolean;\n};\n\ntype ParseOutcome =\n\t| { readonly kind: \"absent\" }\n\t| { readonly kind: \"help\" }\n\t| { readonly kind: \"error\"; readonly message: string }\n\t| { readonly kind: \"ok\"; readonly parsed: ParsedAdoptArgs };\n\nconst SOURCE_IDS: readonly ExternalCredentialSourceId[] = [\"codex-cli\", \"claude-code\"];\n\nfunction parseArgs(args: readonly string[]): ParseOutcome {\n\tif (args[0] !== \"provider\" || args[1] !== \"adopt\") return { kind: \"absent\" };\n\tif (args.includes(\"--help\") || args.includes(\"-h\")) return { kind: \"help\" };\n\tlet providerId: string | undefined;\n\tlet from: ExternalCredentialSourceId | undefined;\n\tlet dryRun = false;\n\tlet json = false;\n\tlet status = false;\n\tfor (let index = 2; index < args.length; index += 1) {\n\t\tconst arg = args[index] ?? \"\";\n\t\tif (arg === \"--dry-run\") dryRun = true;\n\t\telse if (arg === \"--json\") json = true;\n\t\telse if (arg === \"--status\") status = true;\n\t\telse if (arg === \"--from\") {\n\t\t\tconst value = args[index + 1];\n\t\t\tif (value === undefined || value.startsWith(\"-\"))\n\t\t\t\treturn { kind: \"error\", message: \"Missing value for --from.\" };\n\t\t\tif (!SOURCE_IDS.includes(value as ExternalCredentialSourceId)) {\n\t\t\t\treturn { kind: \"error\", message: `Unknown --from value. Use one of: ${SOURCE_IDS.join(\", \")}.` };\n\t\t\t}\n\t\t\tfrom = value as ExternalCredentialSourceId;\n\t\t\tindex += 1;\n\t\t} else if (arg.startsWith(\"-\")) return { kind: \"error\", message: \"Unknown option for provider adopt.\" };\n\t\telse if (providerId === undefined) providerId = arg;\n\t\telse return { kind: \"error\", message: \"Unexpected extra argument.\" };\n\t}\n\tif (!status && providerId === undefined) return { kind: \"error\", message: \"Missing provider id.\" };\n\treturn { kind: \"ok\", parsed: { providerId, from, dryRun, json, status } };\n}\n\n/**\n * Sources to try for one provider. `--from` narrows the provider's own mapping; it must never\n * broaden it, or a foreign provider's OAuth grant would be stored under this provider id.\n */\nfunction sourcesForAdoption(\n\tproviderId: string,\n\tfrom: ExternalCredentialSourceId | undefined,\n): readonly ExternalCredentialSourceId[] {\n\tconst mapped = credentialSourcesFor(providerId);\n\treturn from === undefined ? mapped : mapped.filter((source) => source === from);\n}\n\n/** Adopt one provider's credential from the first source that yields a usable token. */\nfunction adoptProvider(\n\targs: ParsedAdoptArgs,\n\tdependencies: ProviderAdoptCliDependencies,\n\tstorage: AuthStorage,\n\tauthPath: string,\n\twriteLine: (line: string) => void,\n): number {\n\tconst providerId = args.providerId ?? \"\";\n\tconst io: ExternalCredentialIo = {\n\t\treadFile: dependencies.readFile,\n\t\tnow: dependencies.now,\n\t\tenv: dependencies.env,\n\t\thome: dependencies.home,\n\t};\n\tconst sources = sourcesForAdoption(providerId, args.from);\n\tif (sources.length === 0) {\n\t\twriteLine(`No external credential source is mapped to \"${providerId}\".`);\n\t\twriteLine(`Known mappings: openai-codex <- codex-cli, anthropic <- claude-code.`);\n\t\treturn 2;\n\t}\n\n\tlet failure: { source: ExternalCredentialSourceId; path: string; reason: string } | undefined;\n\tfor (const source of sources) {\n\t\tconst lookup = readExternalCredential(source, io);\n\t\tif (lookup.status !== \"found\") {\n\t\t\tfailure = { source, path: lookup.path, reason: lookup.reason };\n\t\t\tcontinue;\n\t\t}\n\t\tconst preview = args.dryRun\n\t\t\t? storage.previewOAuthAccountImport(providerId, lookup.candidate.credentials)\n\t\t\t: storage.addOAuthAccount(providerId, lookup.candidate.credentials);\n\t\tif (args.json) {\n\t\t\twriteLine(\n\t\t\t\tJSON.stringify(\n\t\t\t\t\t{\n\t\t\t\t\t\tprovider: providerId,\n\t\t\t\t\t\tsource,\n\t\t\t\t\t\tpath: lookup.candidate.path,\n\t\t\t\t\t\tdetail: lookup.candidate.detail,\n\t\t\t\t\t\taction: preview.action,\n\t\t\t\t\t\taccountIndex: preview.accountIndex,\n\t\t\t\t\t\treason: preview.reason,\n\t\t\t\t\t\tdryRun: args.dryRun,\n\t\t\t\t\t},\n\t\t\t\t\tnull,\n\t\t\t\t\t2,\n\t\t\t\t),\n\t\t\t);\n\t\t} else {\n\t\t\twriteLine(`${providerId} <- ${EXTERNAL_CREDENTIAL_SOURCE_LABELS[source]}`);\n\t\t\twriteLine(` found: ${lookup.candidate.detail}`);\n\t\t\tconst where = preview.accountIndex === undefined ? \"\" : ` account[${preview.accountIndex}]`;\n\t\t\tconst suffix = preview.reason ? ` (${preview.reason})` : \"\";\n\t\t\twriteLine(` ${args.dryRun ? \"would be\" : \"result\"}: ${preview.action}${where}${suffix}`);\n\t\t\twriteLine(args.dryRun ? ` dry run: ${authPath} not written` : ` wrote ${authPath}`);\n\t\t}\n\t\tif (preview.action === \"blocked\") return 1;\n\t\t// A write swallowed into the error queue still prints \"wrote auth.json\" above; check the\n\t\t// queue so adopt cannot report success while nothing persisted.\n\t\tconst writeErrors = storage.drainErrors();\n\t\tif (writeErrors.length > 0) {\n\t\t\twriteLine(` warning: the credential store reported an error: ${writeErrors[0]?.message}`);\n\t\t\treturn 1;\n\t\t}\n\t\treturn 0;\n\t}\n\n\tconst reason = failure ? `${failure.reason}` : \"no source produced a credential\";\n\tconst failedSource = failure?.source ?? sources[0] ?? \"codex-cli\";\n\tconst path = failure?.path ?? credentialSourcePath(failedSource, io);\n\tif (args.json) {\n\t\twriteLine(\n\t\t\tJSON.stringify({ provider: providerId, source: failedSource, path, action: \"unavailable\", reason }, null, 2),\n\t\t);\n\t} else {\n\t\twriteLine(`${providerId}: no usable credential to adopt from ${EXTERNAL_CREDENTIAL_SOURCE_LABELS[failedSource]}`);\n\t\twriteLine(` ${path}`);\n\t\twriteLine(` ${reason}`);\n\t}\n\treturn 1;\n}\n\nexport async function runProviderAdoptCli(\n\targs: readonly string[],\n\toverrides: ProviderAdoptCliDependencies = {},\n): Promise<ProviderAdoptCliOutcome> {\n\tconst outcome = parseArgs(args);\n\tif (outcome.kind === \"absent\") return { handled: false, exitCode: 0 };\n\tconst writeLine = overrides.writeLine ?? ((line: string) => process.stdout.write(`${line}\\n`));\n\tif (outcome.kind === \"help\") {\n\t\twriteLine(HELP);\n\t\treturn { handled: true, exitCode: 0 };\n\t}\n\tif (outcome.kind === \"error\") {\n\t\twriteLine(outcome.message);\n\t\twriteLine(USAGE);\n\t\treturn { handled: true, exitCode: 2 };\n\t}\n\n\tconst authPath = join(overrides.agentDir ?? getAgentDir(), \"auth.json\");\n\tconst storage = AuthStorage.create(authPath);\n\tconst now = (overrides.now ?? Date.now)();\n\tconst readFile = overrides.readFile ?? readAuthStoreFile;\n\n\tif (outcome.parsed.status) {\n\t\t// An unreadable store is not an empty store: report the load failure instead of\n\t\t// \"no stored credential\", the same distinction the request path enforces.\n\t\tif (storage.hasLoadError()) {\n\t\t\twriteLine(`The credential store could not be read: ${authPath}`);\n\t\t\twriteLine(` Another session may hold the lock. Retry shortly.`);\n\t\t\treturn { handled: true, exitCode: 1 };\n\t\t}\n\t\tconst providerIds = outcome.parsed.providerId\n\t\t\t? [outcome.parsed.providerId]\n\t\t\t: storedProviderIds(authPath, readFile);\n\t\twriteStatusReport({ storage, providerIds, json: outcome.parsed.json, authPath, writeLine, now });\n\t\treturn { handled: true, exitCode: 0 };\n\t}\n\n\treturn { handled: true, exitCode: adoptProvider(outcome.parsed, overrides, storage, authPath, writeLine) };\n}\n"]}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `omk provider adopt [<provider-id>] [--from <source>] [--dry-run] [--json] [--status]`
|
|
3
|
+
*
|
|
4
|
+
* Copies credentials this machine already holds (an OpenAI Codex CLI login, a Claude Code CLI
|
|
5
|
+
* login) into OMK's own credential store, so a subscription does not have to be signed in twice.
|
|
6
|
+
* `--status` only reports what the store holds; it never refreshes, writes or contacts a provider.
|
|
7
|
+
*
|
|
8
|
+
* Exit codes: 0 = adopted, already current, or status reported; 1 = no usable source or the store
|
|
9
|
+
* is unreadable; 2 = usage error. No output contains token material.
|
|
10
|
+
*/
|
|
11
|
+
import { join } from "node:path";
|
|
12
|
+
import { APP_NAME, getAgentDir } from "../config.js";
|
|
13
|
+
import { AuthStorage } from "../core/auth-storage.js";
|
|
14
|
+
import { credentialSourcePath, credentialSourcesFor, EXTERNAL_CREDENTIAL_SOURCE_LABELS, readExternalCredential, } from "../core/external-credential-sources.js";
|
|
15
|
+
import { readAuthStoreFile, storedProviderIds, writeStatusReport } from "./provider-adopt-status.js";
|
|
16
|
+
const USAGE = `Usage: ${APP_NAME} provider adopt [<provider-id>] [--from <source>] [--dry-run] [--json] [--status]`;
|
|
17
|
+
const HELP = [
|
|
18
|
+
"Provider adopt: copy credentials that already exist on this machine into OMK's store.",
|
|
19
|
+
"",
|
|
20
|
+
USAGE,
|
|
21
|
+
"",
|
|
22
|
+
" --from <source> credential store to read: codex-cli | claude-code",
|
|
23
|
+
" --dry-run report what would change without writing auth.json",
|
|
24
|
+
" --json print one JSON document instead of the text report",
|
|
25
|
+
" --status report the stored accounts (valid/expired) and exit; writes nothing",
|
|
26
|
+
"",
|
|
27
|
+
"Sources: codex-cli = ~/.codex/auth.json (Codex CLI), claude-code = ~/.claude/.credentials.json.",
|
|
28
|
+
"Providers: openai-codex <- codex-cli, anthropic <- claude-code.",
|
|
29
|
+
"Exit codes: 0 = adopted or nothing to change, 1 = source unusable or store unreadable, 2 = usage error.",
|
|
30
|
+
].join("\n");
|
|
31
|
+
const SOURCE_IDS = ["codex-cli", "claude-code"];
|
|
32
|
+
function parseArgs(args) {
|
|
33
|
+
if (args[0] !== "provider" || args[1] !== "adopt")
|
|
34
|
+
return { kind: "absent" };
|
|
35
|
+
if (args.includes("--help") || args.includes("-h"))
|
|
36
|
+
return { kind: "help" };
|
|
37
|
+
let providerId;
|
|
38
|
+
let from;
|
|
39
|
+
let dryRun = false;
|
|
40
|
+
let json = false;
|
|
41
|
+
let status = false;
|
|
42
|
+
for (let index = 2; index < args.length; index += 1) {
|
|
43
|
+
const arg = args[index] ?? "";
|
|
44
|
+
if (arg === "--dry-run")
|
|
45
|
+
dryRun = true;
|
|
46
|
+
else if (arg === "--json")
|
|
47
|
+
json = true;
|
|
48
|
+
else if (arg === "--status")
|
|
49
|
+
status = true;
|
|
50
|
+
else if (arg === "--from") {
|
|
51
|
+
const value = args[index + 1];
|
|
52
|
+
if (value === undefined || value.startsWith("-"))
|
|
53
|
+
return { kind: "error", message: "Missing value for --from." };
|
|
54
|
+
if (!SOURCE_IDS.includes(value)) {
|
|
55
|
+
return { kind: "error", message: `Unknown --from value. Use one of: ${SOURCE_IDS.join(", ")}.` };
|
|
56
|
+
}
|
|
57
|
+
from = value;
|
|
58
|
+
index += 1;
|
|
59
|
+
}
|
|
60
|
+
else if (arg.startsWith("-"))
|
|
61
|
+
return { kind: "error", message: "Unknown option for provider adopt." };
|
|
62
|
+
else if (providerId === undefined)
|
|
63
|
+
providerId = arg;
|
|
64
|
+
else
|
|
65
|
+
return { kind: "error", message: "Unexpected extra argument." };
|
|
66
|
+
}
|
|
67
|
+
if (!status && providerId === undefined)
|
|
68
|
+
return { kind: "error", message: "Missing provider id." };
|
|
69
|
+
return { kind: "ok", parsed: { providerId, from, dryRun, json, status } };
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Sources to try for one provider. `--from` narrows the provider's own mapping; it must never
|
|
73
|
+
* broaden it, or a foreign provider's OAuth grant would be stored under this provider id.
|
|
74
|
+
*/
|
|
75
|
+
function sourcesForAdoption(providerId, from) {
|
|
76
|
+
const mapped = credentialSourcesFor(providerId);
|
|
77
|
+
return from === undefined ? mapped : mapped.filter((source) => source === from);
|
|
78
|
+
}
|
|
79
|
+
/** Adopt one provider's credential from the first source that yields a usable token. */
|
|
80
|
+
function adoptProvider(args, dependencies, storage, authPath, writeLine) {
|
|
81
|
+
const providerId = args.providerId ?? "";
|
|
82
|
+
const io = {
|
|
83
|
+
readFile: dependencies.readFile,
|
|
84
|
+
now: dependencies.now,
|
|
85
|
+
env: dependencies.env,
|
|
86
|
+
home: dependencies.home,
|
|
87
|
+
};
|
|
88
|
+
const sources = sourcesForAdoption(providerId, args.from);
|
|
89
|
+
if (sources.length === 0) {
|
|
90
|
+
writeLine(`No external credential source is mapped to "${providerId}".`);
|
|
91
|
+
writeLine(`Known mappings: openai-codex <- codex-cli, anthropic <- claude-code.`);
|
|
92
|
+
return 2;
|
|
93
|
+
}
|
|
94
|
+
let failure;
|
|
95
|
+
for (const source of sources) {
|
|
96
|
+
const lookup = readExternalCredential(source, io);
|
|
97
|
+
if (lookup.status !== "found") {
|
|
98
|
+
failure = { source, path: lookup.path, reason: lookup.reason };
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
const preview = args.dryRun
|
|
102
|
+
? storage.previewOAuthAccountImport(providerId, lookup.candidate.credentials)
|
|
103
|
+
: storage.addOAuthAccount(providerId, lookup.candidate.credentials);
|
|
104
|
+
if (args.json) {
|
|
105
|
+
writeLine(JSON.stringify({
|
|
106
|
+
provider: providerId,
|
|
107
|
+
source,
|
|
108
|
+
path: lookup.candidate.path,
|
|
109
|
+
detail: lookup.candidate.detail,
|
|
110
|
+
action: preview.action,
|
|
111
|
+
accountIndex: preview.accountIndex,
|
|
112
|
+
reason: preview.reason,
|
|
113
|
+
dryRun: args.dryRun,
|
|
114
|
+
}, null, 2));
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
writeLine(`${providerId} <- ${EXTERNAL_CREDENTIAL_SOURCE_LABELS[source]}`);
|
|
118
|
+
writeLine(` found: ${lookup.candidate.detail}`);
|
|
119
|
+
const where = preview.accountIndex === undefined ? "" : ` account[${preview.accountIndex}]`;
|
|
120
|
+
const suffix = preview.reason ? ` (${preview.reason})` : "";
|
|
121
|
+
writeLine(` ${args.dryRun ? "would be" : "result"}: ${preview.action}${where}${suffix}`);
|
|
122
|
+
writeLine(args.dryRun ? ` dry run: ${authPath} not written` : ` wrote ${authPath}`);
|
|
123
|
+
}
|
|
124
|
+
if (preview.action === "blocked")
|
|
125
|
+
return 1;
|
|
126
|
+
// A write swallowed into the error queue still prints "wrote auth.json" above; check the
|
|
127
|
+
// queue so adopt cannot report success while nothing persisted.
|
|
128
|
+
const writeErrors = storage.drainErrors();
|
|
129
|
+
if (writeErrors.length > 0) {
|
|
130
|
+
writeLine(` warning: the credential store reported an error: ${writeErrors[0]?.message}`);
|
|
131
|
+
return 1;
|
|
132
|
+
}
|
|
133
|
+
return 0;
|
|
134
|
+
}
|
|
135
|
+
const reason = failure ? `${failure.reason}` : "no source produced a credential";
|
|
136
|
+
const failedSource = failure?.source ?? sources[0] ?? "codex-cli";
|
|
137
|
+
const path = failure?.path ?? credentialSourcePath(failedSource, io);
|
|
138
|
+
if (args.json) {
|
|
139
|
+
writeLine(JSON.stringify({ provider: providerId, source: failedSource, path, action: "unavailable", reason }, null, 2));
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
writeLine(`${providerId}: no usable credential to adopt from ${EXTERNAL_CREDENTIAL_SOURCE_LABELS[failedSource]}`);
|
|
143
|
+
writeLine(` ${path}`);
|
|
144
|
+
writeLine(` ${reason}`);
|
|
145
|
+
}
|
|
146
|
+
return 1;
|
|
147
|
+
}
|
|
148
|
+
export async function runProviderAdoptCli(args, overrides = {}) {
|
|
149
|
+
const outcome = parseArgs(args);
|
|
150
|
+
if (outcome.kind === "absent")
|
|
151
|
+
return { handled: false, exitCode: 0 };
|
|
152
|
+
const writeLine = overrides.writeLine ?? ((line) => process.stdout.write(`${line}\n`));
|
|
153
|
+
if (outcome.kind === "help") {
|
|
154
|
+
writeLine(HELP);
|
|
155
|
+
return { handled: true, exitCode: 0 };
|
|
156
|
+
}
|
|
157
|
+
if (outcome.kind === "error") {
|
|
158
|
+
writeLine(outcome.message);
|
|
159
|
+
writeLine(USAGE);
|
|
160
|
+
return { handled: true, exitCode: 2 };
|
|
161
|
+
}
|
|
162
|
+
const authPath = join(overrides.agentDir ?? getAgentDir(), "auth.json");
|
|
163
|
+
const storage = AuthStorage.create(authPath);
|
|
164
|
+
const now = (overrides.now ?? Date.now)();
|
|
165
|
+
const readFile = overrides.readFile ?? readAuthStoreFile;
|
|
166
|
+
if (outcome.parsed.status) {
|
|
167
|
+
// An unreadable store is not an empty store: report the load failure instead of
|
|
168
|
+
// "no stored credential", the same distinction the request path enforces.
|
|
169
|
+
if (storage.hasLoadError()) {
|
|
170
|
+
writeLine(`The credential store could not be read: ${authPath}`);
|
|
171
|
+
writeLine(` Another session may hold the lock. Retry shortly.`);
|
|
172
|
+
return { handled: true, exitCode: 1 };
|
|
173
|
+
}
|
|
174
|
+
const providerIds = outcome.parsed.providerId
|
|
175
|
+
? [outcome.parsed.providerId]
|
|
176
|
+
: storedProviderIds(authPath, readFile);
|
|
177
|
+
writeStatusReport({ storage, providerIds, json: outcome.parsed.json, authPath, writeLine, now });
|
|
178
|
+
return { handled: true, exitCode: 0 };
|
|
179
|
+
}
|
|
180
|
+
return { handled: true, exitCode: adoptProvider(outcome.parsed, overrides, storage, authPath, writeLine) };
|
|
181
|
+
}
|
|
182
|
+
//# sourceMappingURL=provider-adopt-cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-adopt-cli.js","sourceRoot":"","sources":["../../src/commands/provider-adopt-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EACN,oBAAoB,EACpB,oBAAoB,EACpB,iCAAiC,EAGjC,sBAAsB,GACtB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAErG,MAAM,KAAK,GAAG,UAAU,QAAQ,mFAAmF,CAAC;AACpH,MAAM,IAAI,GAAG;IACZ,uFAAuF;IACvF,EAAE;IACF,KAAK;IACL,EAAE;IACF,sEAAsE;IACtE,uEAAuE;IACvE,uEAAuE;IACvE,wFAAwF;IACxF,EAAE;IACF,iGAAiG;IACjG,iEAAiE;IACjE,yGAAyG;CACzG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AA8Bb,MAAM,UAAU,GAA0C,CAAC,WAAW,EAAE,aAAa,CAA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AS,EAAE,GAAG,EAAE,CAAC,CAAC;QACjG,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;IACvC,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,aAAa,CAAC,OAAO,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAE,CAAC;AAAA,CAC3G","sourcesContent":["/**\n * `omk provider adopt [<provider-id>] [--from <source>] [--dry-run] [--json] [--status]`\n *\n * Copies credentials this machine already holds (an OpenAI Codex CLI login, a Claude Code CLI\n * login) into OMK's own credential store, so a subscription does not have to be signed in twice.\n * `--status` only reports what the store holds; it never refreshes, writes or contacts a provider.\n *\n * Exit codes: 0 = adopted, already current, or status reported; 1 = no usable source or the store\n * is unreadable; 2 = usage error. No output contains token material.\n */\n\nimport { join } from \"node:path\";\nimport { APP_NAME, getAgentDir } from \"../config.ts\";\nimport { AuthStorage } from \"../core/auth-storage.ts\";\nimport {\n\tcredentialSourcePath,\n\tcredentialSourcesFor,\n\tEXTERNAL_CREDENTIAL_SOURCE_LABELS,\n\ttype ExternalCredentialIo,\n\ttype ExternalCredentialSourceId,\n\treadExternalCredential,\n} from \"../core/external-credential-sources.ts\";\nimport { readAuthStoreFile, storedProviderIds, writeStatusReport } from \"./provider-adopt-status.ts\";\n\nconst USAGE = `Usage: ${APP_NAME} provider adopt [<provider-id>] [--from <source>] [--dry-run] [--json] [--status]`;\nconst HELP = [\n\t\"Provider adopt: copy credentials that already exist on this machine into OMK's store.\",\n\t\"\",\n\tUSAGE,\n\t\"\",\n\t\" --from <source> credential store to read: codex-cli | claude-code\",\n\t\" --dry-run report what would change without writing auth.json\",\n\t\" --json print one JSON document instead of the text report\",\n\t\" --status report the stored accounts (valid/expired) and exit; writes nothing\",\n\t\"\",\n\t\"Sources: codex-cli = ~/.codex/auth.json (Codex CLI), claude-code = ~/.claude/.credentials.json.\",\n\t\"Providers: openai-codex <- codex-cli, anthropic <- claude-code.\",\n\t\"Exit codes: 0 = adopted or nothing to change, 1 = source unusable or store unreadable, 2 = usage error.\",\n].join(\"\\n\");\n\nexport interface ProviderAdoptCliDependencies {\n\treadonly agentDir?: string;\n\treadonly env?: Readonly<Record<string, string | undefined>>;\n\treadonly readFile?: (path: string) => string;\n\treadonly now?: () => number;\n\treadonly home?: string;\n\treadonly writeLine?: (line: string) => void;\n}\n\nexport interface ProviderAdoptCliOutcome {\n\treadonly handled: boolean;\n\treadonly exitCode: number;\n}\n\ntype ParsedAdoptArgs = {\n\treadonly providerId?: string;\n\treadonly from?: ExternalCredentialSourceId;\n\treadonly dryRun: boolean;\n\treadonly json: boolean;\n\treadonly status: boolean;\n};\n\ntype ParseOutcome =\n\t| { readonly kind: \"absent\" }\n\t| { readonly kind: \"help\" }\n\t| { readonly kind: \"error\"; readonly message: string }\n\t| { readonly kind: \"ok\"; readonly parsed: ParsedAdoptArgs };\n\nconst SOURCE_IDS: readonly ExternalCredentialSourceId[] = [\"codex-cli\", \"claude-code\"];\n\nfunction parseArgs(args: readonly string[]): ParseOutcome {\n\tif (args[0] !== \"provider\" || args[1] !== \"adopt\") return { kind: \"absent\" };\n\tif (args.includes(\"--help\") || args.includes(\"-h\")) return { kind: \"help\" };\n\tlet providerId: string | undefined;\n\tlet from: ExternalCredentialSourceId | undefined;\n\tlet dryRun = false;\n\tlet json = false;\n\tlet status = false;\n\tfor (let index = 2; index < args.length; index += 1) {\n\t\tconst arg = args[index] ?? \"\";\n\t\tif (arg === \"--dry-run\") dryRun = true;\n\t\telse if (arg === \"--json\") json = true;\n\t\telse if (arg === \"--status\") status = true;\n\t\telse if (arg === \"--from\") {\n\t\t\tconst value = args[index + 1];\n\t\t\tif (value === undefined || value.startsWith(\"-\"))\n\t\t\t\treturn { kind: \"error\", message: \"Missing value for --from.\" };\n\t\t\tif (!SOURCE_IDS.includes(value as ExternalCredentialSourceId)) {\n\t\t\t\treturn { kind: \"error\", message: `Unknown --from value. Use one of: ${SOURCE_IDS.join(\", \")}.` };\n\t\t\t}\n\t\t\tfrom = value as ExternalCredentialSourceId;\n\t\t\tindex += 1;\n\t\t} else if (arg.startsWith(\"-\")) return { kind: \"error\", message: \"Unknown option for provider adopt.\" };\n\t\telse if (providerId === undefined) providerId = arg;\n\t\telse return { kind: \"error\", message: \"Unexpected extra argument.\" };\n\t}\n\tif (!status && providerId === undefined) return { kind: \"error\", message: \"Missing provider id.\" };\n\treturn { kind: \"ok\", parsed: { providerId, from, dryRun, json, status } };\n}\n\n/**\n * Sources to try for one provider. `--from` narrows the provider's own mapping; it must never\n * broaden it, or a foreign provider's OAuth grant would be stored under this provider id.\n */\nfunction sourcesForAdoption(\n\tproviderId: string,\n\tfrom: ExternalCredentialSourceId | undefined,\n): readonly ExternalCredentialSourceId[] {\n\tconst mapped = credentialSourcesFor(providerId);\n\treturn from === undefined ? mapped : mapped.filter((source) => source === from);\n}\n\n/** Adopt one provider's credential from the first source that yields a usable token. */\nfunction adoptProvider(\n\targs: ParsedAdoptArgs,\n\tdependencies: ProviderAdoptCliDependencies,\n\tstorage: AuthStorage,\n\tauthPath: string,\n\twriteLine: (line: string) => void,\n): number {\n\tconst providerId = args.providerId ?? \"\";\n\tconst io: ExternalCredentialIo = {\n\t\treadFile: dependencies.readFile,\n\t\tnow: dependencies.now,\n\t\tenv: dependencies.env,\n\t\thome: dependencies.home,\n\t};\n\tconst sources = sourcesForAdoption(providerId, args.from);\n\tif (sources.length === 0) {\n\t\twriteLine(`No external credential source is mapped to \"${providerId}\".`);\n\t\twriteLine(`Known mappings: openai-codex <- codex-cli, anthropic <- claude-code.`);\n\t\treturn 2;\n\t}\n\n\tlet failure: { source: ExternalCredentialSourceId; path: string; reason: string } | undefined;\n\tfor (const source of sources) {\n\t\tconst lookup = readExternalCredential(source, io);\n\t\tif (lookup.status !== \"found\") {\n\t\t\tfailure = { source, path: lookup.path, reason: lookup.reason };\n\t\t\tcontinue;\n\t\t}\n\t\tconst preview = args.dryRun\n\t\t\t? storage.previewOAuthAccountImport(providerId, lookup.candidate.credentials)\n\t\t\t: storage.addOAuthAccount(providerId, lookup.candidate.credentials);\n\t\tif (args.json) {\n\t\t\twriteLine(\n\t\t\t\tJSON.stringify(\n\t\t\t\t\t{\n\t\t\t\t\t\tprovider: providerId,\n\t\t\t\t\t\tsource,\n\t\t\t\t\t\tpath: lookup.candidate.path,\n\t\t\t\t\t\tdetail: lookup.candidate.detail,\n\t\t\t\t\t\taction: preview.action,\n\t\t\t\t\t\taccountIndex: preview.accountIndex,\n\t\t\t\t\t\treason: preview.reason,\n\t\t\t\t\t\tdryRun: args.dryRun,\n\t\t\t\t\t},\n\t\t\t\t\tnull,\n\t\t\t\t\t2,\n\t\t\t\t),\n\t\t\t);\n\t\t} else {\n\t\t\twriteLine(`${providerId} <- ${EXTERNAL_CREDENTIAL_SOURCE_LABELS[source]}`);\n\t\t\twriteLine(` found: ${lookup.candidate.detail}`);\n\t\t\tconst where = preview.accountIndex === undefined ? \"\" : ` account[${preview.accountIndex}]`;\n\t\t\tconst suffix = preview.reason ? ` (${preview.reason})` : \"\";\n\t\t\twriteLine(` ${args.dryRun ? \"would be\" : \"result\"}: ${preview.action}${where}${suffix}`);\n\t\t\twriteLine(args.dryRun ? ` dry run: ${authPath} not written` : ` wrote ${authPath}`);\n\t\t}\n\t\tif (preview.action === \"blocked\") return 1;\n\t\t// A write swallowed into the error queue still prints \"wrote auth.json\" above; check the\n\t\t// queue so adopt cannot report success while nothing persisted.\n\t\tconst writeErrors = storage.drainErrors();\n\t\tif (writeErrors.length > 0) {\n\t\t\twriteLine(` warning: the credential store reported an error: ${writeErrors[0]?.message}`);\n\t\t\treturn 1;\n\t\t}\n\t\treturn 0;\n\t}\n\n\tconst reason = failure ? `${failure.reason}` : \"no source produced a credential\";\n\tconst failedSource = failure?.source ?? sources[0] ?? \"codex-cli\";\n\tconst path = failure?.path ?? credentialSourcePath(failedSource, io);\n\tif (args.json) {\n\t\twriteLine(\n\t\t\tJSON.stringify({ provider: providerId, source: failedSource, path, action: \"unavailable\", reason }, null, 2),\n\t\t);\n\t} else {\n\t\twriteLine(`${providerId}: no usable credential to adopt from ${EXTERNAL_CREDENTIAL_SOURCE_LABELS[failedSource]}`);\n\t\twriteLine(` ${path}`);\n\t\twriteLine(` ${reason}`);\n\t}\n\treturn 1;\n}\n\nexport async function runProviderAdoptCli(\n\targs: readonly string[],\n\toverrides: ProviderAdoptCliDependencies = {},\n): Promise<ProviderAdoptCliOutcome> {\n\tconst outcome = parseArgs(args);\n\tif (outcome.kind === \"absent\") return { handled: false, exitCode: 0 };\n\tconst writeLine = overrides.writeLine ?? ((line: string) => process.stdout.write(`${line}\\n`));\n\tif (outcome.kind === \"help\") {\n\t\twriteLine(HELP);\n\t\treturn { handled: true, exitCode: 0 };\n\t}\n\tif (outcome.kind === \"error\") {\n\t\twriteLine(outcome.message);\n\t\twriteLine(USAGE);\n\t\treturn { handled: true, exitCode: 2 };\n\t}\n\n\tconst authPath = join(overrides.agentDir ?? getAgentDir(), \"auth.json\");\n\tconst storage = AuthStorage.create(authPath);\n\tconst now = (overrides.now ?? Date.now)();\n\tconst readFile = overrides.readFile ?? readAuthStoreFile;\n\n\tif (outcome.parsed.status) {\n\t\t// An unreadable store is not an empty store: report the load failure instead of\n\t\t// \"no stored credential\", the same distinction the request path enforces.\n\t\tif (storage.hasLoadError()) {\n\t\t\twriteLine(`The credential store could not be read: ${authPath}`);\n\t\t\twriteLine(` Another session may hold the lock. Retry shortly.`);\n\t\t\treturn { handled: true, exitCode: 1 };\n\t\t}\n\t\tconst providerIds = outcome.parsed.providerId\n\t\t\t? [outcome.parsed.providerId]\n\t\t\t: storedProviderIds(authPath, readFile);\n\t\twriteStatusReport({ storage, providerIds, json: outcome.parsed.json, authPath, writeLine, now });\n\t\treturn { handled: true, exitCode: 0 };\n\t}\n\n\treturn { handled: true, exitCode: adoptProvider(outcome.parsed, overrides, storage, authPath, writeLine) };\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { AuthStorage } from "../core/auth-storage.ts";
|
|
2
|
+
export type AccountHealth = {
|
|
3
|
+
readonly index: number;
|
|
4
|
+
readonly label: string;
|
|
5
|
+
readonly selected: boolean;
|
|
6
|
+
readonly state: "valid" | "refreshable" | "expired";
|
|
7
|
+
readonly expiresAt?: number;
|
|
8
|
+
readonly hasRefresh: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare function describeAccounts(storage: AuthStorage, providerId: string, now: number): AccountHealth[];
|
|
11
|
+
export declare function storedProviderIds(authPath: string, readFile: (path: string) => string): readonly string[];
|
|
12
|
+
export declare function writeStatusReport(input: {
|
|
13
|
+
readonly storage: AuthStorage;
|
|
14
|
+
readonly providerIds: readonly string[];
|
|
15
|
+
readonly json: boolean;
|
|
16
|
+
readonly authPath: string;
|
|
17
|
+
readonly writeLine: (line: string) => void;
|
|
18
|
+
readonly now: number;
|
|
19
|
+
}): void;
|
|
20
|
+
export declare function readAuthStoreFile(authPath: string): string;
|
|
21
|
+
//# sourceMappingURL=provider-adopt-status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-adopt-status.d.ts","sourceRoot":"","sources":["../../src/commands/provider-adopt-status.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,MAAM,aAAa,GAAG;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,aAAa,GAAG,SAAS,CAAC;IACpD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,aAAa,EAAE,CAqBvG;AAgBD,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,MAAM,EAAE,CAQzG;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE;IACxC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACrB,GAAG,IAAI,CA0BP;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE1D","sourcesContent":["/**\n * `--status` reporting helpers for `omk provider adopt`.\n *\n * Extracted from provider-adopt-cli.ts so the command stays under the module-size\n * ceiling: account health rendering and store enumeration are independent of the\n * adoption write path.\n */\nimport { readFileSync } from \"node:fs\";\nimport type { OAuthCredentials } from \"omk-ai\";\nimport type { AuthStorage } from \"../core/auth-storage.ts\";\n\nexport type AccountHealth = {\n\treadonly index: number;\n\treadonly label: string;\n\treadonly selected: boolean;\n\treadonly state: \"valid\" | \"refreshable\" | \"expired\";\n\treadonly expiresAt?: number;\n\treadonly hasRefresh: boolean;\n};\n\nexport function describeAccounts(storage: AuthStorage, providerId: string, now: number): AccountHealth[] {\n\tconst credential = storage.get(providerId);\n\tif (credential?.type !== \"oauth\") return [];\n\tconst labels = storage.listOAuthAccounts(providerId);\n\tconst accounts: OAuthCredentials[] =\n\t\tArray.isArray(credential.accounts) && credential.accounts.length > 0 ? credential.accounts : [credential];\n\tconst selectedIndex = typeof credential.activeAccount === \"number\" ? credential.activeAccount : 0;\n\treturn accounts.map((account, index) => {\n\t\tconst expires = typeof account.expires === \"number\" ? account.expires : undefined;\n\t\tconst hasRefresh = Boolean(account.refresh);\n\t\tconst state: AccountHealth[\"state\"] =\n\t\t\texpires !== undefined && expires > now ? \"valid\" : hasRefresh ? \"refreshable\" : \"expired\";\n\t\treturn {\n\t\t\tindex,\n\t\t\tlabel: labels.find((entry) => entry.index === index)?.label ?? `Account ${index + 1}`,\n\t\t\tselected: index === selectedIndex,\n\t\t\tstate,\n\t\t\texpiresAt: expires,\n\t\t\thasRefresh,\n\t\t};\n\t});\n}\n\nfunction formatInstant(ms: number | undefined): string {\n\tif (ms === undefined || !Number.isFinite(ms)) return \"an unknown time\";\n\treturn `${new Date(ms).toISOString().slice(0, 16).replace(\"T\", \" \")} UTC`;\n}\n\nfunction accountLine(account: AccountHealth): string {\n\tconst selected = account.selected ? \"selected\" : \"not selected\";\n\tif (account.state === \"valid\")\n\t\treturn `valid until ${formatInstant(account.expiresAt)}, refresh ${account.hasRefresh ? \"yes\" : \"no\"} (${selected})`;\n\tif (account.state === \"refreshable\")\n\t\treturn `expired ${formatInstant(account.expiresAt)}, refreshes on use (${selected})`;\n\treturn `expired ${formatInstant(account.expiresAt)}, no refresh token: sign in again (${selected})`;\n}\n\nexport function storedProviderIds(authPath: string, readFile: (path: string) => string): readonly string[] {\n\ttry {\n\t\tconst parsed: unknown = JSON.parse(readFile(authPath));\n\t\tif (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) return [];\n\t\treturn Object.keys(parsed as Record<string, unknown>).sort();\n\t} catch {\n\t\treturn [];\n\t}\n}\n\nexport function writeStatusReport(input: {\n\treadonly storage: AuthStorage;\n\treadonly providerIds: readonly string[];\n\treadonly json: boolean;\n\treadonly authPath: string;\n\treadonly writeLine: (line: string) => void;\n\treadonly now: number;\n}): void {\n\tconst providers = input.providerIds.map((providerId) => {\n\t\tconst credential = input.storage.get(providerId);\n\t\tconst kind = credential?.type === \"oauth\" ? \"oauth\" : credential?.type === \"api_key\" ? \"api_key\" : \"none\";\n\t\tconst accounts = kind === \"oauth\" ? describeAccounts(input.storage, providerId, input.now) : [];\n\t\treturn { provider: providerId, kind, accounts };\n\t});\n\tif (input.json) {\n\t\tinput.writeLine(JSON.stringify({ status: \"reported\", authPath: input.authPath, providers }, null, 2));\n\t\treturn;\n\t}\n\tinput.writeLine(`${input.authPath}`);\n\tfor (const entry of providers) {\n\t\tif (entry.kind === \"none\") {\n\t\t\tinput.writeLine(` ${entry.provider}: no stored credential`);\n\t\t\tcontinue;\n\t\t}\n\t\tif (entry.kind === \"api_key\") {\n\t\t\tinput.writeLine(` ${entry.provider}: API key stored`);\n\t\t\tcontinue;\n\t\t}\n\t\tinput.writeLine(` ${entry.provider}: ${entry.accounts.length} OAuth account(s)`);\n\t\tfor (const account of entry.accounts) {\n\t\t\tinput.writeLine(` [${account.index}] ${account.label} ${accountLine(account)}`);\n\t\t}\n\t}\n}\n\nexport function readAuthStoreFile(authPath: string): string {\n\treturn readFileSync(authPath, \"utf-8\");\n}\n"]}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `--status` reporting helpers for `omk provider adopt`.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from provider-adopt-cli.ts so the command stays under the module-size
|
|
5
|
+
* ceiling: account health rendering and store enumeration are independent of the
|
|
6
|
+
* adoption write path.
|
|
7
|
+
*/
|
|
8
|
+
import { readFileSync } from "node:fs";
|
|
9
|
+
export function describeAccounts(storage, providerId, now) {
|
|
10
|
+
const credential = storage.get(providerId);
|
|
11
|
+
if (credential?.type !== "oauth")
|
|
12
|
+
return [];
|
|
13
|
+
const labels = storage.listOAuthAccounts(providerId);
|
|
14
|
+
const accounts = Array.isArray(credential.accounts) && credential.accounts.length > 0 ? credential.accounts : [credential];
|
|
15
|
+
const selectedIndex = typeof credential.activeAccount === "number" ? credential.activeAccount : 0;
|
|
16
|
+
return accounts.map((account, index) => {
|
|
17
|
+
const expires = typeof account.expires === "number" ? account.expires : undefined;
|
|
18
|
+
const hasRefresh = Boolean(account.refresh);
|
|
19
|
+
const state = expires !== undefined && expires > now ? "valid" : hasRefresh ? "refreshable" : "expired";
|
|
20
|
+
return {
|
|
21
|
+
index,
|
|
22
|
+
label: labels.find((entry) => entry.index === index)?.label ?? `Account ${index + 1}`,
|
|
23
|
+
selected: index === selectedIndex,
|
|
24
|
+
state,
|
|
25
|
+
expiresAt: expires,
|
|
26
|
+
hasRefresh,
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function formatInstant(ms) {
|
|
31
|
+
if (ms === undefined || !Number.isFinite(ms))
|
|
32
|
+
return "an unknown time";
|
|
33
|
+
return `${new Date(ms).toISOString().slice(0, 16).replace("T", " ")} UTC`;
|
|
34
|
+
}
|
|
35
|
+
function accountLine(account) {
|
|
36
|
+
const selected = account.selected ? "selected" : "not selected";
|
|
37
|
+
if (account.state === "valid")
|
|
38
|
+
return `valid until ${formatInstant(account.expiresAt)}, refresh ${account.hasRefresh ? "yes" : "no"} (${selected})`;
|
|
39
|
+
if (account.state === "refreshable")
|
|
40
|
+
return `expired ${formatInstant(account.expiresAt)}, refreshes on use (${selected})`;
|
|
41
|
+
return `expired ${formatInstant(account.expiresAt)}, no refresh token: sign in again (${selected})`;
|
|
42
|
+
}
|
|
43
|
+
export function storedProviderIds(authPath, readFile) {
|
|
44
|
+
try {
|
|
45
|
+
const parsed = JSON.parse(readFile(authPath));
|
|
46
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
|
|
47
|
+
return [];
|
|
48
|
+
return Object.keys(parsed).sort();
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export function writeStatusReport(input) {
|
|
55
|
+
const providers = input.providerIds.map((providerId) => {
|
|
56
|
+
const credential = input.storage.get(providerId);
|
|
57
|
+
const kind = credential?.type === "oauth" ? "oauth" : credential?.type === "api_key" ? "api_key" : "none";
|
|
58
|
+
const accounts = kind === "oauth" ? describeAccounts(input.storage, providerId, input.now) : [];
|
|
59
|
+
return { provider: providerId, kind, accounts };
|
|
60
|
+
});
|
|
61
|
+
if (input.json) {
|
|
62
|
+
input.writeLine(JSON.stringify({ status: "reported", authPath: input.authPath, providers }, null, 2));
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
input.writeLine(`${input.authPath}`);
|
|
66
|
+
for (const entry of providers) {
|
|
67
|
+
if (entry.kind === "none") {
|
|
68
|
+
input.writeLine(` ${entry.provider}: no stored credential`);
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (entry.kind === "api_key") {
|
|
72
|
+
input.writeLine(` ${entry.provider}: API key stored`);
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
input.writeLine(` ${entry.provider}: ${entry.accounts.length} OAuth account(s)`);
|
|
76
|
+
for (const account of entry.accounts) {
|
|
77
|
+
input.writeLine(` [${account.index}] ${account.label} ${accountLine(account)}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
export function readAuthStoreFile(authPath) {
|
|
82
|
+
return readFileSync(authPath, "utf-8");
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=provider-adopt-status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-adopt-status.js","sourceRoot":"","sources":["../../src/commands/provider-adopt-status.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAavC,MAAM,UAAU,gBAAgB,CAAC,OAAoB,EAAE,UAAkB,EAAE,GAAW,EAAmB;IACxG,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC3C,IAAI,UAAU,EAAE,IAAI,KAAK,OAAO;QAAE,OAAO,EAAE,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9B,KAAK,CAAC,SAAS,CAAC,KAAK,KAAK,CAAC,QAAQ,kBAAkB,CAAC,CAAC;YACvD,SAAS;QACV,CAAC;QACD,KAAK,CAAC,SAAS,CAAC,KAAK,KAAK,CAAC,QAAQ,KAAK,KAAK,CAAC,QAAQ,CAAC,MAAM,mBAAmB,CAAC,CAAC;QAClF,KAAK,MAAM,OAAO,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;YACtC,KAAK,CAAC,SAAS,CAAC,QAAQ,OAAO,CAAC,KAAK,KAAK,OAAO,CAAC,KAAK,IAAI,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACpF,CAAC;IACF,CAAC;AAAA,CACD;AAED,MAAM,UAAU,iBAAiB,CAAC,QAAgB,EAAU;IAC3D,OAAO,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAAA,CACvC","sourcesContent":["/**\n * `--status` reporting helpers for `omk provider adopt`.\n *\n * Extracted from provider-adopt-cli.ts so the command stays under the module-size\n * ceiling: account health rendering and store enumeration are independent of the\n * adoption write path.\n */\nimport { readFileSync } from \"node:fs\";\nimport type { OAuthCredentials } from \"omk-ai\";\nimport type { AuthStorage } from \"../core/auth-storage.ts\";\n\nexport type AccountHealth = {\n\treadonly index: number;\n\treadonly label: string;\n\treadonly selected: boolean;\n\treadonly state: \"valid\" | \"refreshable\" | \"expired\";\n\treadonly expiresAt?: number;\n\treadonly hasRefresh: boolean;\n};\n\nexport function describeAccounts(storage: AuthStorage, providerId: string, now: number): AccountHealth[] {\n\tconst credential = storage.get(providerId);\n\tif (credential?.type !== \"oauth\") return [];\n\tconst labels = storage.listOAuthAccounts(providerId);\n\tconst accounts: OAuthCredentials[] =\n\t\tArray.isArray(credential.accounts) && credential.accounts.length > 0 ? credential.accounts : [credential];\n\tconst selectedIndex = typeof credential.activeAccount === \"number\" ? credential.activeAccount : 0;\n\treturn accounts.map((account, index) => {\n\t\tconst expires = typeof account.expires === \"number\" ? account.expires : undefined;\n\t\tconst hasRefresh = Boolean(account.refresh);\n\t\tconst state: AccountHealth[\"state\"] =\n\t\t\texpires !== undefined && expires > now ? \"valid\" : hasRefresh ? \"refreshable\" : \"expired\";\n\t\treturn {\n\t\t\tindex,\n\t\t\tlabel: labels.find((entry) => entry.index === index)?.label ?? `Account ${index + 1}`,\n\t\t\tselected: index === selectedIndex,\n\t\t\tstate,\n\t\t\texpiresAt: expires,\n\t\t\thasRefresh,\n\t\t};\n\t});\n}\n\nfunction formatInstant(ms: number | undefined): string {\n\tif (ms === undefined || !Number.isFinite(ms)) return \"an unknown time\";\n\treturn `${new Date(ms).toISOString().slice(0, 16).replace(\"T\", \" \")} UTC`;\n}\n\nfunction accountLine(account: AccountHealth): string {\n\tconst selected = account.selected ? \"selected\" : \"not selected\";\n\tif (account.state === \"valid\")\n\t\treturn `valid until ${formatInstant(account.expiresAt)}, refresh ${account.hasRefresh ? \"yes\" : \"no\"} (${selected})`;\n\tif (account.state === \"refreshable\")\n\t\treturn `expired ${formatInstant(account.expiresAt)}, refreshes on use (${selected})`;\n\treturn `expired ${formatInstant(account.expiresAt)}, no refresh token: sign in again (${selected})`;\n}\n\nexport function storedProviderIds(authPath: string, readFile: (path: string) => string): readonly string[] {\n\ttry {\n\t\tconst parsed: unknown = JSON.parse(readFile(authPath));\n\t\tif (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) return [];\n\t\treturn Object.keys(parsed as Record<string, unknown>).sort();\n\t} catch {\n\t\treturn [];\n\t}\n}\n\nexport function writeStatusReport(input: {\n\treadonly storage: AuthStorage;\n\treadonly providerIds: readonly string[];\n\treadonly json: boolean;\n\treadonly authPath: string;\n\treadonly writeLine: (line: string) => void;\n\treadonly now: number;\n}): void {\n\tconst providers = input.providerIds.map((providerId) => {\n\t\tconst credential = input.storage.get(providerId);\n\t\tconst kind = credential?.type === \"oauth\" ? \"oauth\" : credential?.type === \"api_key\" ? \"api_key\" : \"none\";\n\t\tconst accounts = kind === \"oauth\" ? describeAccounts(input.storage, providerId, input.now) : [];\n\t\treturn { provider: providerId, kind, accounts };\n\t});\n\tif (input.json) {\n\t\tinput.writeLine(JSON.stringify({ status: \"reported\", authPath: input.authPath, providers }, null, 2));\n\t\treturn;\n\t}\n\tinput.writeLine(`${input.authPath}`);\n\tfor (const entry of providers) {\n\t\tif (entry.kind === \"none\") {\n\t\t\tinput.writeLine(` ${entry.provider}: no stored credential`);\n\t\t\tcontinue;\n\t\t}\n\t\tif (entry.kind === \"api_key\") {\n\t\t\tinput.writeLine(` ${entry.provider}: API key stored`);\n\t\t\tcontinue;\n\t\t}\n\t\tinput.writeLine(` ${entry.provider}: ${entry.accounts.length} OAuth account(s)`);\n\t\tfor (const account of entry.accounts) {\n\t\t\tinput.writeLine(` [${account.index}] ${account.label} ${accountLine(account)}`);\n\t\t}\n\t}\n}\n\nexport function readAuthStoreFile(authPath: string): string {\n\treturn readFileSync(authPath, \"utf-8\");\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-known-apis.d.ts","sourceRoot":"","sources":["../../src/commands/provider-known-apis.ts"],"names":[],"mappings":"AAwBA,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAG/C","sourcesContent":["/**\n * Whether an `api` string names a supported provider API.\n *\n * The engine's own registry is authoritative: `registerBuiltins` registers `devin-agent` and\n * `cursor-agent`, which a hand-written list had missed, so `omk provider doctor devin` failed\n * every run with \"Provider API type is unsupported\" for a supported provider. The literal stays\n * as the bootstrap fallback for processes where the registry is not populated yet.\n */\nimport { getApiProviders } from \"omk-ai\";\n\nconst STATIC_KNOWN_APIS: readonly string[] = [\n\t\"openai-completions\",\n\t\"mistral-conversations\",\n\t\"openai-responses\",\n\t\"azure-openai-responses\",\n\t\"openai-codex-responses\",\n\t\"anthropic-messages\",\n\t\"bedrock-converse-stream\",\n\t\"google-generative-ai\",\n\t\"google-vertex\",\n\t\"devin-agent\",\n\t\"cursor-agent\",\n];\n\nexport function isKnownApi(api: string): boolean {\n\tif (STATIC_KNOWN_APIS.includes(api)) return true;\n\treturn getApiProviders().some((provider) => provider.api === api);\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether an `api` string names a supported provider API.
|
|
3
|
+
*
|
|
4
|
+
* The engine's own registry is authoritative: `registerBuiltins` registers `devin-agent` and
|
|
5
|
+
* `cursor-agent`, which a hand-written list had missed, so `omk provider doctor devin` failed
|
|
6
|
+
* every run with "Provider API type is unsupported" for a supported provider. The literal stays
|
|
7
|
+
* as the bootstrap fallback for processes where the registry is not populated yet.
|
|
8
|
+
*/
|
|
9
|
+
import { getApiProviders } from "omk-ai";
|
|
10
|
+
const STATIC_KNOWN_APIS = [
|
|
11
|
+
"openai-completions",
|
|
12
|
+
"mistral-conversations",
|
|
13
|
+
"openai-responses",
|
|
14
|
+
"azure-openai-responses",
|
|
15
|
+
"openai-codex-responses",
|
|
16
|
+
"anthropic-messages",
|
|
17
|
+
"bedrock-converse-stream",
|
|
18
|
+
"google-generative-ai",
|
|
19
|
+
"google-vertex",
|
|
20
|
+
"devin-agent",
|
|
21
|
+
"cursor-agent",
|
|
22
|
+
];
|
|
23
|
+
export function isKnownApi(api) {
|
|
24
|
+
if (STATIC_KNOWN_APIS.includes(api))
|
|
25
|
+
return true;
|
|
26
|
+
return getApiProviders().some((provider) => provider.api === api);
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=provider-known-apis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-known-apis.js","sourceRoot":"","sources":["../../src/commands/provider-known-apis.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEzC,MAAM,iBAAiB,GAAsB;IAC5C,oBAAoB;IACpB,uBAAuB;IACvB,kBAAkB;IAClB,wBAAwB;IACxB,wBAAwB;IACxB,oBAAoB;IACpB,yBAAyB;IACzB,sBAAsB;IACtB,eAAe;IACf,aAAa;IACb,cAAc;CACd,CAAC;AAEF,MAAM,UAAU,UAAU,CAAC,GAAW,EAAW;IAChD,IAAI,iBAAiB,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IACjD,OAAO,eAAe,EAAE,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;AAAA,CAClE","sourcesContent":["/**\n * Whether an `api` string names a supported provider API.\n *\n * The engine's own registry is authoritative: `registerBuiltins` registers `devin-agent` and\n * `cursor-agent`, which a hand-written list had missed, so `omk provider doctor devin` failed\n * every run with \"Provider API type is unsupported\" for a supported provider. The literal stays\n * as the bootstrap fallback for processes where the registry is not populated yet.\n */\nimport { getApiProviders } from \"omk-ai\";\n\nconst STATIC_KNOWN_APIS: readonly string[] = [\n\t\"openai-completions\",\n\t\"mistral-conversations\",\n\t\"openai-responses\",\n\t\"azure-openai-responses\",\n\t\"openai-codex-responses\",\n\t\"anthropic-messages\",\n\t\"bedrock-converse-stream\",\n\t\"google-generative-ai\",\n\t\"google-vertex\",\n\t\"devin-agent\",\n\t\"cursor-agent\",\n];\n\nexport function isKnownApi(api: string): boolean {\n\tif (STATIC_KNOWN_APIS.includes(api)) return true;\n\treturn getApiProviders().some((provider) => provider.api === api);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-command.d.ts","sourceRoot":"","sources":["../../src/commands/run-command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"run-command.d.ts","sourceRoot":"","sources":["../../src/commands/run-command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAY/E,KAAK,UAAU,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAY3E,+EAA+E;AAC/E,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,UAAU,CAAC,CAYlG","sourcesContent":["import type { VerifiedRunRuntime } from \"../core/verified-run/session-port.ts\";\nimport { runAdaptOrchDoctorCli } from \"./adaptorch-doctor-cli.ts\";\nimport { runDoctorProviderCli } from \"./doctor-provider-cli.ts\";\nimport { runProviderAdoptCli } from \"./provider-adopt-cli.ts\";\nimport { runProviderSyncCli } from \"./provider-sync-cli.ts\";\nimport { runResourceDoctorCli } from \"./resource-doctor-cli.ts\";\nimport { runRouterFeedbackCli } from \"./router-feedback-cli.ts\";\nimport { runSdkSessionCli } from \"./sdk-session-cli.ts\";\nimport { runSessionDoctorCli } from \"./session-doctor-cli.ts\";\nimport { runStatsCli } from \"./stats-cli.ts\";\nimport { runVerifiedRunCli } from \"./verified-run-cli.ts\";\n\ntype CliOutcome = { readonly handled: boolean; readonly exitCode: number };\n\nconst COMMANDS: ReadonlyArray<(args: string[]) => CliOutcome | Promise<CliOutcome>> = [\n\trunSessionDoctorCli,\n\trunDoctorProviderCli,\n\trunResourceDoctorCli,\n\trunAdaptOrchDoctorCli,\n\trunStatsCli,\n\trunSdkSessionCli,\n\trunRouterFeedbackCli,\n];\n\n/** Each handler owns a distinct prefix; preserve the first handled outcome. */\nexport async function runCommand(args: string[], runtime?: VerifiedRunRuntime): Promise<CliOutcome> {\n\tconst providerAdopt = await runProviderAdoptCli(args);\n\tif (providerAdopt.handled) return providerAdopt;\n\tconst providerSync = await runProviderSyncCli(args);\n\tif (providerSync.handled) return providerSync;\n\tconst verifiedRun = await runVerifiedRunCli(args, runtime);\n\tif (verifiedRun.handled) return verifiedRun;\n\tfor (const command of COMMANDS) {\n\t\tconst outcome = await command(args);\n\t\tif (outcome.handled) return outcome;\n\t}\n\treturn { handled: false, exitCode: 0 };\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { runAdaptOrchDoctorCli } from "./adaptorch-doctor-cli.js";
|
|
2
2
|
import { runDoctorProviderCli } from "./doctor-provider-cli.js";
|
|
3
|
+
import { runProviderAdoptCli } from "./provider-adopt-cli.js";
|
|
3
4
|
import { runProviderSyncCli } from "./provider-sync-cli.js";
|
|
4
5
|
import { runResourceDoctorCli } from "./resource-doctor-cli.js";
|
|
5
6
|
import { runRouterFeedbackCli } from "./router-feedback-cli.js";
|
|
@@ -18,6 +19,9 @@ const COMMANDS = [
|
|
|
18
19
|
];
|
|
19
20
|
/** Each handler owns a distinct prefix; preserve the first handled outcome. */
|
|
20
21
|
export async function runCommand(args, runtime) {
|
|
22
|
+
const providerAdopt = await runProviderAdoptCli(args);
|
|
23
|
+
if (providerAdopt.handled)
|
|
24
|
+
return providerAdopt;
|
|
21
25
|
const providerSync = await runProviderSyncCli(args);
|
|
22
26
|
if (providerSync.handled)
|
|
23
27
|
return providerSync;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-command.js","sourceRoot":"","sources":["../../src/commands/run-command.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAI1D,MAAM,QAAQ,GAAwE;IACrF,mBAAmB;IACnB,oBAAoB;IACpB,oBAAoB;IACpB,qBAAqB;IACrB,WAAW;IACX,gBAAgB;IAChB,oBAAoB;CACpB,CAAC;AAEF,+EAA+E;AAC/E,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,IAAc,EAAE,OAA4B,EAAuB;IACnG,MAAM,YAAY,GAAG,MAAM,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACpD,IAAI,YAAY,CAAC,OAAO;QAAE,OAAO,YAAY,CAAC;IAC9C,MAAM,WAAW,GAAG,MAAM,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3D,IAAI,WAAW,CAAC,OAAO;QAAE,OAAO,WAAW,CAAC;IAC5C,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAChC,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,OAAO,CAAC,OAAO;YAAE,OAAO,OAAO,CAAC;IACrC,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;AAAA,CACvC","sourcesContent":["import type { VerifiedRunRuntime } from \"../core/verified-run/session-port.ts\";\nimport { runAdaptOrchDoctorCli } from \"./adaptorch-doctor-cli.ts\";\nimport { runDoctorProviderCli } from \"./doctor-provider-cli.ts\";\nimport { runProviderSyncCli } from \"./provider-sync-cli.ts\";\nimport { runResourceDoctorCli } from \"./resource-doctor-cli.ts\";\nimport { runRouterFeedbackCli } from \"./router-feedback-cli.ts\";\nimport { runSdkSessionCli } from \"./sdk-session-cli.ts\";\nimport { runSessionDoctorCli } from \"./session-doctor-cli.ts\";\nimport { runStatsCli } from \"./stats-cli.ts\";\nimport { runVerifiedRunCli } from \"./verified-run-cli.ts\";\n\ntype CliOutcome = { readonly handled: boolean; readonly exitCode: number };\n\nconst COMMANDS: ReadonlyArray<(args: string[]) => CliOutcome | Promise<CliOutcome>> = [\n\trunSessionDoctorCli,\n\trunDoctorProviderCli,\n\trunResourceDoctorCli,\n\trunAdaptOrchDoctorCli,\n\trunStatsCli,\n\trunSdkSessionCli,\n\trunRouterFeedbackCli,\n];\n\n/** Each handler owns a distinct prefix; preserve the first handled outcome. */\nexport async function runCommand(args: string[], runtime?: VerifiedRunRuntime): Promise<CliOutcome> {\n\tconst providerSync = await runProviderSyncCli(args);\n\tif (providerSync.handled) return providerSync;\n\tconst verifiedRun = await runVerifiedRunCli(args, runtime);\n\tif (verifiedRun.handled) return verifiedRun;\n\tfor (const command of COMMANDS) {\n\t\tconst outcome = await command(args);\n\t\tif (outcome.handled) return outcome;\n\t}\n\treturn { handled: false, exitCode: 0 };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"run-command.js","sourceRoot":"","sources":["../../src/commands/run-command.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAI1D,MAAM,QAAQ,GAAwE;IACrF,mBAAmB;IACnB,oBAAoB;IACpB,oBAAoB;IACpB,qBAAqB;IACrB,WAAW;IACX,gBAAgB;IAChB,oBAAoB;CACpB,CAAC;AAEF,+EAA+E;AAC/E,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,IAAc,EAAE,OAA4B,EAAuB;IACnG,MAAM,aAAa,GAAG,MAAM,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACtD,IAAI,aAAa,CAAC,OAAO;QAAE,OAAO,aAAa,CAAC;IAChD,MAAM,YAAY,GAAG,MAAM,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACpD,IAAI,YAAY,CAAC,OAAO;QAAE,OAAO,YAAY,CAAC;IAC9C,MAAM,WAAW,GAAG,MAAM,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3D,IAAI,WAAW,CAAC,OAAO;QAAE,OAAO,WAAW,CAAC;IAC5C,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAChC,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,OAAO,CAAC,OAAO;YAAE,OAAO,OAAO,CAAC;IACrC,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;AAAA,CACvC","sourcesContent":["import type { VerifiedRunRuntime } from \"../core/verified-run/session-port.ts\";\nimport { runAdaptOrchDoctorCli } from \"./adaptorch-doctor-cli.ts\";\nimport { runDoctorProviderCli } from \"./doctor-provider-cli.ts\";\nimport { runProviderAdoptCli } from \"./provider-adopt-cli.ts\";\nimport { runProviderSyncCli } from \"./provider-sync-cli.ts\";\nimport { runResourceDoctorCli } from \"./resource-doctor-cli.ts\";\nimport { runRouterFeedbackCli } from \"./router-feedback-cli.ts\";\nimport { runSdkSessionCli } from \"./sdk-session-cli.ts\";\nimport { runSessionDoctorCli } from \"./session-doctor-cli.ts\";\nimport { runStatsCli } from \"./stats-cli.ts\";\nimport { runVerifiedRunCli } from \"./verified-run-cli.ts\";\n\ntype CliOutcome = { readonly handled: boolean; readonly exitCode: number };\n\nconst COMMANDS: ReadonlyArray<(args: string[]) => CliOutcome | Promise<CliOutcome>> = [\n\trunSessionDoctorCli,\n\trunDoctorProviderCli,\n\trunResourceDoctorCli,\n\trunAdaptOrchDoctorCli,\n\trunStatsCli,\n\trunSdkSessionCli,\n\trunRouterFeedbackCli,\n];\n\n/** Each handler owns a distinct prefix; preserve the first handled outcome. */\nexport async function runCommand(args: string[], runtime?: VerifiedRunRuntime): Promise<CliOutcome> {\n\tconst providerAdopt = await runProviderAdoptCli(args);\n\tif (providerAdopt.handled) return providerAdopt;\n\tconst providerSync = await runProviderSyncCli(args);\n\tif (providerSync.handled) return providerSync;\n\tconst verifiedRun = await runVerifiedRunCli(args, runtime);\n\tif (verifiedRun.handled) return verifiedRun;\n\tfor (const command of COMMANDS) {\n\t\tconst outcome = await command(args);\n\t\tif (outcome.handled) return outcome;\n\t}\n\treturn { handled: false, exitCode: 0 };\n}\n"]}
|