gearbox-code 0.1.8 → 0.1.10
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/README.md +3 -0
- package/dist/cli.mjs +152 -40
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -38,6 +38,9 @@ Common setup commands:
|
|
|
38
38
|
```bash
|
|
39
39
|
gearbox auth add <api-key> # auto-detects known key prefixes
|
|
40
40
|
gearbox auth add <provider> <api-key> # anthropic, openai, google, deepseek, openrouter, groq, xai, mistral...
|
|
41
|
+
gearbox auth add codex # ChatGPT subscription through the Codex CLI
|
|
42
|
+
gearbox auth add codex work # second ChatGPT account, isolated CODEX_HOME
|
|
43
|
+
gearbox auth add claude work # second Claude account, isolated config
|
|
41
44
|
gearbox auth import # import credentials from env/cloud config
|
|
42
45
|
gearbox auth providers # list supported providers
|
|
43
46
|
```
|
package/dist/cli.mjs
CHANGED
|
@@ -64452,6 +64452,17 @@ function cleanCliStderr(text2) {
|
|
|
64452
64452
|
}
|
|
64453
64453
|
return cleaned;
|
|
64454
64454
|
}
|
|
64455
|
+
function cliFailureMessage(binary, stderr, opts = {}) {
|
|
64456
|
+
const err = cleanCliStderr(stderr);
|
|
64457
|
+
const isCodex = binary.includes("codex");
|
|
64458
|
+
if (isCodex && /app_session_terminated|Your session has ended|Failed to refresh token|HTTP error: 401 Unauthorized/i.test(err)) {
|
|
64459
|
+
const account = opts.accountLabel ? ` for ${opts.accountLabel}` : "";
|
|
64460
|
+
const relogin = opts.reloginCommand ? ` Run ${opts.reloginCommand} to sign in again, then /retry.` : " Sign in to that Codex account again, then /retry.";
|
|
64461
|
+
return `Codex session expired${account}.${relogin}`;
|
|
64462
|
+
}
|
|
64463
|
+
const hint = isCodex ? "Codex CLI failed before returning an assistant message. Check the line above, then /retry." : `${binary} failed before returning an assistant message. Check the line above, then /retry.`;
|
|
64464
|
+
return err ? `${hint} ${err}` : hint;
|
|
64465
|
+
}
|
|
64455
64466
|
async function runCliTask(opts) {
|
|
64456
64467
|
const { binary, prompt, messages, onEvent, signal } = opts;
|
|
64457
64468
|
const args = buildCliArgs(binary, prompt, { sessionId: opts.sessionId, autoApprove: opts.autoApprove, modelId: opts.modelId, effort: opts.effort });
|
|
@@ -64513,8 +64524,7 @@ async function runCliTask(opts) {
|
|
|
64513
64524
|
if (!signal?.aborted) {
|
|
64514
64525
|
const err = cleanCliStderr(stderr);
|
|
64515
64526
|
if ((proc.exitCode ?? 0) !== 0) {
|
|
64516
|
-
|
|
64517
|
-
onEvent({ type: "error", message: err ? `${hint} ${err}` : hint });
|
|
64527
|
+
onEvent({ type: "error", message: cliFailureMessage(binary, stderr, { accountLabel: opts.accountLabel, reloginCommand: opts.reloginCommand }) });
|
|
64518
64528
|
} else if (!state.text && !sawEvent && err) {
|
|
64519
64529
|
onEvent({ type: "error", message: `${binary} produced no JSON output: ${err}` });
|
|
64520
64530
|
} else if (!state.text && !sawEvent) {
|
|
@@ -134618,7 +134628,23 @@ function App2({ selector: initialSelector, runner, fullscreen = false, resumeId
|
|
|
134618
134628
|
const cliChoices = cliModelChoices(cli.binary);
|
|
134619
134629
|
const cliChoice = cliChoices.find((m2) => m2.id === activeCliModelRef.current) ?? cliChoices[0];
|
|
134620
134630
|
const cliEffort = cliChoice ? normalizeEffort(effortRef.current, cliChoice.efforts ?? []) ?? undefined : undefined;
|
|
134621
|
-
const
|
|
134631
|
+
const activeAccount = getAccount(cli.id);
|
|
134632
|
+
const activeName = activeAccount ? accountName(activeAccount).match(/\((.*)\)/)?.[1] : undefined;
|
|
134633
|
+
const reloginCommand = cli.binary.includes("codex") ? `/account add codex${activeName ? ` ${activeName}` : ""}` : `/account add claude${activeName ? ` ${activeName}` : ""}`;
|
|
134634
|
+
const r3 = await runCliTask({
|
|
134635
|
+
binary: cli.binary,
|
|
134636
|
+
prompt,
|
|
134637
|
+
messages,
|
|
134638
|
+
onEvent,
|
|
134639
|
+
signal,
|
|
134640
|
+
sessionId: cliSessionRef.current,
|
|
134641
|
+
autoApprove: isYolo(),
|
|
134642
|
+
profile: cli.profile,
|
|
134643
|
+
modelId: activeCliModelRef.current,
|
|
134644
|
+
effort: cliEffort,
|
|
134645
|
+
accountLabel: activeAccount ? accountLabel(activeAccount) : cli.id,
|
|
134646
|
+
reloginCommand
|
|
134647
|
+
});
|
|
134622
134648
|
cliSessionRef.current = r3.sessionId ?? cliSessionRef.current;
|
|
134623
134649
|
cliMetaRef.current = { costUSD: r3.costUSD, rates: r3.rates };
|
|
134624
134650
|
return { messages: r3.messages, usage: r3.usage };
|
|
@@ -136281,8 +136307,48 @@ function App2({ selector: initialSelector, runner, fullscreen = false, resumeId
|
|
|
136281
136307
|
var jsx_dev_runtime13 = __toESM(require_jsx_dev_runtime(), 1);
|
|
136282
136308
|
process.env.LANG = process.env.LANG || "en_US.UTF-8";
|
|
136283
136309
|
process.env.LC_ALL = process.env.LC_ALL || "en_US.UTF-8";
|
|
136284
|
-
var VERSION16 = "0.1.
|
|
136310
|
+
var VERSION16 = "0.1.10";
|
|
136285
136311
|
var args = process.argv.slice(2);
|
|
136312
|
+
var supportsAnsi = process.env.NO_COLOR !== "1" && process.env.TERM !== "dumb" && (process.stdout.isTTY || process.env.FORCE_COLOR === "1");
|
|
136313
|
+
var ansi = (code) => supportsAnsi ? `\x1B[${code}m` : "";
|
|
136314
|
+
var paint = (code, text2) => `${ansi(code)}${text2}${ansi("0")}`;
|
|
136315
|
+
var bold = (text2) => paint("1", text2);
|
|
136316
|
+
var accent = (text2) => paint("36", text2);
|
|
136317
|
+
var dim = (text2) => paint("2", text2);
|
|
136318
|
+
var ok = (text2) => paint("32", text2);
|
|
136319
|
+
var warn = (text2) => paint("33", text2);
|
|
136320
|
+
var errColor = (text2) => paint("31", text2);
|
|
136321
|
+
var stripAnsi2 = (text2) => text2.replace(/\x1b\[[0-9;]*m/g, "");
|
|
136322
|
+
var visibleLength = (text2) => stripAnsi2(text2).length;
|
|
136323
|
+
var padVisible = (text2, width) => text2 + " ".repeat(Math.max(width - visibleLength(text2), 0));
|
|
136324
|
+
function onboardingBoo() {
|
|
136325
|
+
return [
|
|
136326
|
+
" .-''''-.",
|
|
136327
|
+
" .' .--. '.",
|
|
136328
|
+
" / ( ) \\",
|
|
136329
|
+
" | .-. .-. |",
|
|
136330
|
+
" | |_| |_| |",
|
|
136331
|
+
" | __ |",
|
|
136332
|
+
" \\ .' '. /",
|
|
136333
|
+
" '._\\____/_.'",
|
|
136334
|
+
" /| |\\"
|
|
136335
|
+
].join(`
|
|
136336
|
+
`);
|
|
136337
|
+
}
|
|
136338
|
+
function box(title, lines) {
|
|
136339
|
+
const width = Math.min(78, Math.max(title.length + 4, ...lines.map((l) => visibleLength(l) + 4)));
|
|
136340
|
+
const rule = "─".repeat(width - 2);
|
|
136341
|
+
console.log(accent(`╭${rule}╮`));
|
|
136342
|
+
console.log(accent("│ ") + padVisible(bold(title), width - 3) + accent("│"));
|
|
136343
|
+
console.log(accent(`├${rule}┤`));
|
|
136344
|
+
for (const line of lines) {
|
|
136345
|
+
console.log(accent("│ ") + padVisible(line, width - 3) + accent("│"));
|
|
136346
|
+
}
|
|
136347
|
+
console.log(accent(`╰${rule}╯`));
|
|
136348
|
+
}
|
|
136349
|
+
function optionLine(key, label, detail) {
|
|
136350
|
+
return `${accent(key.padStart(2))} ${bold(label)} ${dim(detail)}`;
|
|
136351
|
+
}
|
|
136286
136352
|
async function runCliOnboarding() {
|
|
136287
136353
|
const { listAccounts: listAccounts2 } = await Promise.resolve().then(() => (init_store(), exports_store));
|
|
136288
136354
|
const { importableEnvCreds: importableEnvCreds2, importEnvCred: importEnvCred2, importableCloudCreds: importableCloudCreds2, importCloudCred: importCloudCred2 } = await Promise.resolve().then(() => (init_detect(), exports_detect));
|
|
@@ -136290,41 +136356,55 @@ async function runCliOnboarding() {
|
|
|
136290
136356
|
const { subscriptionEnv: subscriptionEnv2 } = await Promise.resolve().then(() => (init_cli_backend(), exports_cli_backend));
|
|
136291
136357
|
const { detectProviderByKey: detectProviderByKey2 } = await Promise.resolve().then(() => (init_catalog(), exports_catalog));
|
|
136292
136358
|
const { which: which2 } = await Promise.resolve().then(() => (init_proc(), exports_proc));
|
|
136293
|
-
const
|
|
136294
|
-
const
|
|
136295
|
-
const
|
|
136359
|
+
const pipedAnswers = process.stdin.isTTY ? null : (await readStdin()).split(/\r?\n/);
|
|
136360
|
+
const rl = pipedAnswers ? null : createInterface({ input: process.stdin, output: process.stdout });
|
|
136361
|
+
const ask = async (q) => {
|
|
136362
|
+
if (pipedAnswers) {
|
|
136363
|
+
const answer = (pipedAnswers.shift() ?? "").trim();
|
|
136364
|
+
console.log(accent(q) + answer);
|
|
136365
|
+
return answer;
|
|
136366
|
+
}
|
|
136367
|
+
return (await rl.question(accent(q))).trim();
|
|
136368
|
+
};
|
|
136369
|
+
const providerRows = () => addableProviders2().map((p) => ` ${accent(p.id.padEnd(16))} ${p.label}`).join(`
|
|
136296
136370
|
`);
|
|
136297
136371
|
const testAndReport = async (account) => {
|
|
136298
|
-
console.log("Testing credential...");
|
|
136372
|
+
console.log(dim("Testing credential with the provider..."));
|
|
136299
136373
|
const t2 = await testAccount2(account);
|
|
136300
|
-
console.log(t2.ok ? `
|
|
136374
|
+
console.log(t2.ok ? ok(`Credential works: ${t2.message}`) : warn(`Stored, but the live test failed: ${t2.message}`));
|
|
136301
136375
|
};
|
|
136302
136376
|
const addSubscription = async (provider) => {
|
|
136303
136377
|
const res = addCliAccount2(provider);
|
|
136304
|
-
console.log(res.message);
|
|
136378
|
+
console.log(res.ok ? ok(res.message) : errColor(res.message));
|
|
136305
136379
|
if (!res.ok || !res.account || res.account.auth.kind !== "cli")
|
|
136306
136380
|
return false;
|
|
136307
136381
|
const bin = res.account.auth.binary;
|
|
136308
136382
|
const profile = res.account.auth.loginProfile;
|
|
136309
136383
|
let status = await cliAuthStatus2(bin, profile);
|
|
136310
136384
|
if (!status.loggedIn) {
|
|
136311
|
-
console.log(`Starting ${bin} sign-in...`);
|
|
136385
|
+
console.log(dim(`Starting ${bin} sign-in in this terminal...`));
|
|
136312
136386
|
const r2 = spawnSync(bin, cliLoginArgs2(bin), { stdio: "inherit", env: subscriptionEnv2(bin, profile) });
|
|
136313
136387
|
if ((r2.status ?? 1) !== 0)
|
|
136314
136388
|
return false;
|
|
136315
136389
|
status = await cliAuthStatus2(bin, profile);
|
|
136316
136390
|
}
|
|
136317
136391
|
if (!status.loggedIn) {
|
|
136318
|
-
console.log(`${bin} did not report a completed sign-in.`);
|
|
136392
|
+
console.log(warn(`${bin} did not report a completed sign-in.`));
|
|
136319
136393
|
return false;
|
|
136320
136394
|
}
|
|
136321
|
-
console.log(
|
|
136395
|
+
console.log(ok(`${bin} subscription ready${status.detail ? ` (${status.detail})` : ""}`));
|
|
136322
136396
|
return true;
|
|
136323
136397
|
};
|
|
136324
136398
|
try {
|
|
136325
136399
|
console.log("");
|
|
136326
|
-
|
|
136327
|
-
|
|
136400
|
+
if (supportsAnsi)
|
|
136401
|
+
console.log(paint("38;5;117", onboardingBoo()));
|
|
136402
|
+
else
|
|
136403
|
+
console.log(onboardingBoo());
|
|
136404
|
+
console.log("");
|
|
136405
|
+
console.log(bold("Gearbox setup"));
|
|
136406
|
+
console.log("Boo needs one model account before the coding app opens.");
|
|
136407
|
+
console.log(dim("Your credentials stay local. API keys are stored in Gearbox's credential store; subscription sign-ins stay inside the vendor CLI."));
|
|
136328
136408
|
console.log("");
|
|
136329
136409
|
while (!anyProviderAvailable()) {
|
|
136330
136410
|
const env3 = importableEnvCreds2();
|
|
@@ -136332,27 +136412,32 @@ async function runCliOnboarding() {
|
|
|
136332
136412
|
const existing = listAccounts2();
|
|
136333
136413
|
if (existing.length)
|
|
136334
136414
|
break;
|
|
136335
|
-
|
|
136336
|
-
if (env3.length || cloud.length)
|
|
136337
|
-
|
|
136338
|
-
|
|
136339
|
-
|
|
136340
|
-
|
|
136415
|
+
const options2 = [];
|
|
136416
|
+
if (env3.length || cloud.length) {
|
|
136417
|
+
const names = [...env3.map((c) => c.envVar), ...cloud.map((c) => `${c.label} (${c.source})`)];
|
|
136418
|
+
options2.push(optionLine("1", "Import detected credentials", names.join(", ")));
|
|
136419
|
+
}
|
|
136420
|
+
options2.push(optionLine("2", "Paste API key", "auto-detects common key prefixes"));
|
|
136421
|
+
options2.push(optionLine("3", "Choose provider + key", "Anthropic, OpenAI, Gemini, OpenRouter, Groq, ..."));
|
|
136422
|
+
options2.push(optionLine("4", "Azure endpoint + key", "Azure OpenAI or Azure AI Foundry"));
|
|
136341
136423
|
if (which2("claude"))
|
|
136342
|
-
|
|
136424
|
+
options2.push(optionLine("5", "Claude subscription", "uses the official claude CLI; no token extraction"));
|
|
136343
136425
|
if (which2("codex"))
|
|
136344
|
-
|
|
136345
|
-
|
|
136346
|
-
|
|
136426
|
+
options2.push(optionLine("6", "ChatGPT subscription", "uses the official codex CLI; no token extraction"));
|
|
136427
|
+
options2.push(optionLine("p", "Show provider catalog", "all API-key providers Gearbox knows how to add"));
|
|
136428
|
+
options2.push(optionLine("q", "Quit setup", "Gearbox will not open the coding app yet"));
|
|
136429
|
+
box("Choose how Gearbox should connect", options2);
|
|
136347
136430
|
console.log("");
|
|
136348
136431
|
const choice = (await ask("Selection: ")).toLowerCase();
|
|
136349
136432
|
if (choice === "q" || choice === "quit" || choice === "skip") {
|
|
136350
136433
|
console.log("");
|
|
136351
|
-
console.log("Setup skipped. Run `gearbox onboard` when you are ready.");
|
|
136434
|
+
console.log(warn("Setup skipped. Run `gearbox onboard` when you are ready."));
|
|
136352
136435
|
return false;
|
|
136353
136436
|
}
|
|
136354
136437
|
if (choice === "p" || choice === "providers") {
|
|
136355
136438
|
console.log("");
|
|
136439
|
+
console.log(bold("Provider catalog"));
|
|
136440
|
+
console.log(dim("Use these ids with: gearbox auth add <provider> <api-key>"));
|
|
136356
136441
|
console.log(providerRows());
|
|
136357
136442
|
console.log("");
|
|
136358
136443
|
continue;
|
|
@@ -136362,20 +136447,21 @@ async function runCliOnboarding() {
|
|
|
136362
136447
|
await importEnvCred2(c);
|
|
136363
136448
|
for (const c of cloud)
|
|
136364
136449
|
await importCloudCred2(c);
|
|
136365
|
-
console.log(`Imported ${env3.length + cloud.length} credential${env3.length + cloud.length === 1 ? "" : "s"}.`);
|
|
136450
|
+
console.log(ok(`Imported ${env3.length + cloud.length} credential${env3.length + cloud.length === 1 ? "" : "s"}.`));
|
|
136366
136451
|
break;
|
|
136367
136452
|
}
|
|
136368
136453
|
if (choice === "2") {
|
|
136454
|
+
console.log(dim("Paste is visible in most terminals. Use option 3 if you want to be explicit about the provider."));
|
|
136369
136455
|
const key = await ask("Paste API key: ");
|
|
136370
136456
|
if (!key)
|
|
136371
136457
|
continue;
|
|
136372
136458
|
const detected = detectProviderByKey2(key);
|
|
136373
136459
|
if (!detected) {
|
|
136374
|
-
console.log("Could not detect the provider from that key. Use option 3.");
|
|
136460
|
+
console.log(warn("Could not detect the provider from that key. Use option 3."));
|
|
136375
136461
|
continue;
|
|
136376
136462
|
}
|
|
136377
136463
|
const res = await addByPastedKey2(key);
|
|
136378
|
-
console.log(res.message);
|
|
136464
|
+
console.log(res.ok ? ok(res.message) : errColor(res.message));
|
|
136379
136465
|
if (res.ok && res.account) {
|
|
136380
136466
|
await testAndReport(res.account);
|
|
136381
136467
|
break;
|
|
@@ -136384,12 +136470,14 @@ async function runCliOnboarding() {
|
|
|
136384
136470
|
}
|
|
136385
136471
|
if (choice === "3") {
|
|
136386
136472
|
console.log("");
|
|
136473
|
+
console.log(bold("Provider catalog"));
|
|
136387
136474
|
console.log(providerRows());
|
|
136388
136475
|
console.log("");
|
|
136389
136476
|
const provider = await ask("Provider id: ");
|
|
136477
|
+
console.log(dim("The key is stored locally and tested before setup finishes."));
|
|
136390
136478
|
const key = await ask("API key: ");
|
|
136391
136479
|
const res = await addApiKeyAccount2(provider, key);
|
|
136392
|
-
console.log(res.message);
|
|
136480
|
+
console.log(res.ok ? ok(res.message) : errColor(res.message));
|
|
136393
136481
|
if (res.ok && res.account) {
|
|
136394
136482
|
await testAndReport(res.account);
|
|
136395
136483
|
break;
|
|
@@ -136397,11 +136485,12 @@ async function runCliOnboarding() {
|
|
|
136397
136485
|
continue;
|
|
136398
136486
|
}
|
|
136399
136487
|
if (choice === "4") {
|
|
136488
|
+
console.log(dim("Use a resource name like my-openai-resource, or a full Foundry endpoint URL."));
|
|
136400
136489
|
const endpoint = await ask("Azure resource name or endpoint: ");
|
|
136401
136490
|
const key = await ask("API key: ");
|
|
136402
136491
|
const apiVersion = await ask("API version (optional): ");
|
|
136403
136492
|
const res = /^https?:\/\//i.test(endpoint) ? await addAzureFoundryAccount2(endpoint, key) : await addAzureAccount2(endpoint, key, { apiVersion: apiVersion || undefined });
|
|
136404
|
-
console.log(res.message);
|
|
136493
|
+
console.log(res.ok ? ok(res.message) : errColor(res.message));
|
|
136405
136494
|
if (res.ok && res.account) {
|
|
136406
136495
|
await testAndReport(res.account);
|
|
136407
136496
|
break;
|
|
@@ -136418,16 +136507,22 @@ async function runCliOnboarding() {
|
|
|
136418
136507
|
break;
|
|
136419
136508
|
continue;
|
|
136420
136509
|
}
|
|
136421
|
-
console.log("Choose one of the listed options.");
|
|
136510
|
+
console.log(warn("Choose one of the listed options."));
|
|
136422
136511
|
}
|
|
136423
136512
|
console.log("");
|
|
136424
|
-
console.log("Gearbox is ready.");
|
|
136425
|
-
console.log("
|
|
136513
|
+
console.log(ok("Gearbox is ready."));
|
|
136514
|
+
console.log(`Next: ${accent("cd ~/your-project")} and run ${accent("gearbox")}.`);
|
|
136426
136515
|
return true;
|
|
136427
136516
|
} finally {
|
|
136428
|
-
rl
|
|
136517
|
+
rl?.close();
|
|
136429
136518
|
}
|
|
136430
136519
|
}
|
|
136520
|
+
async function readStdin() {
|
|
136521
|
+
let input = "";
|
|
136522
|
+
for await (const chunk2 of process.stdin)
|
|
136523
|
+
input += chunk2;
|
|
136524
|
+
return input;
|
|
136525
|
+
}
|
|
136431
136526
|
if (args[0] === "upgrade" || args[0] === "update") {
|
|
136432
136527
|
const root2 = resolve11(import.meta.dir, "..");
|
|
136433
136528
|
if (!existsSync8(resolve11(root2, ".git"))) {
|
|
@@ -136470,6 +136565,8 @@ Set up at least one provider first:
|
|
|
136470
136565
|
gearbox onboard
|
|
136471
136566
|
gearbox auth add <api-key>
|
|
136472
136567
|
gearbox auth add <provider> <api-key>
|
|
136568
|
+
gearbox auth add codex [name]
|
|
136569
|
+
gearbox auth add claude [name]
|
|
136473
136570
|
gearbox auth import
|
|
136474
136571
|
|
|
136475
136572
|
Models: ${MODELS.map((m2) => m2.label).join(", ")}
|
|
@@ -136487,7 +136584,8 @@ if (args[0] === "onboard" || args[0] === "setup") {
|
|
|
136487
136584
|
if (args[0] === "auth") {
|
|
136488
136585
|
const { listAccounts: listAccounts2, loadAccounts: loadAccounts3, removeAccount: removeAccount2 } = await Promise.resolve().then(() => (init_store(), exports_store));
|
|
136489
136586
|
const { importableEnvCreds: importableEnvCreds2, importEnvCred: importEnvCred2, importableCloudCreds: importableCloudCreds2, importCloudCred: importCloudCred2 } = await Promise.resolve().then(() => (init_detect(), exports_detect));
|
|
136490
|
-
const { addApiKeyAccount: addApiKeyAccount2, addByPastedKey: addByPastedKey2, testAccount: testAccount2, addableProviders: addableProviders2 } = await Promise.resolve().then(() => (init_onboard(), exports_onboard));
|
|
136587
|
+
const { addApiKeyAccount: addApiKeyAccount2, addByPastedKey: addByPastedKey2, testAccount: testAccount2, addableProviders: addableProviders2, addCliAccount: addCliAccount2, cliAuthStatus: cliAuthStatus2, cliLoginArgs: cliLoginArgs2 } = await Promise.resolve().then(() => (init_onboard(), exports_onboard));
|
|
136588
|
+
const { subscriptionEnv: subscriptionEnv2 } = await Promise.resolve().then(() => (init_cli_backend(), exports_cli_backend));
|
|
136491
136589
|
const { detectProviderByKey: detectProviderByKey2 } = await Promise.resolve().then(() => (init_catalog(), exports_catalog));
|
|
136492
136590
|
const sub = args[1];
|
|
136493
136591
|
const rest2 = args.slice(2);
|
|
@@ -136511,11 +136609,25 @@ Importable from your env (gearbox auth import): ${imp.map((c) => c.envVar).join(
|
|
|
136511
136609
|
const names = [...keys2.map((c) => c.provider), ...cloud.map((c) => c.provider)];
|
|
136512
136610
|
console.log(names.length ? `Imported ${names.length}: ${names.join(", ")}` : "Nothing to import.");
|
|
136513
136611
|
} else if (sub === "add") {
|
|
136514
|
-
const
|
|
136612
|
+
const head2 = (rest2[0] ?? "").toLowerCase();
|
|
136613
|
+
const cliProvider = head2 === "codex" || head2 === "chatgpt" ? "codex-cli" : head2 === "claude" ? "claude-cli" : "";
|
|
136614
|
+
const res = cliProvider ? addCliAccount2(cliProvider, rest2.slice(1).join(" ").trim() || undefined) : rest2[0] && !rest2[1] && detectProviderByKey2(rest2[0]) ? await addByPastedKey2(rest2[0]) : rest2[0] && rest2[1] ? await addApiKeyAccount2(rest2[0], rest2[1]) : { ok: false, message: "usage: gearbox auth add <key> | gearbox auth add <provider> <key> | gearbox auth add codex [name]" };
|
|
136515
136615
|
console.log(res.message);
|
|
136516
136616
|
if (res.ok && res.account) {
|
|
136517
|
-
|
|
136518
|
-
|
|
136617
|
+
if (res.account.exec === "cli" && res.account.auth.kind === "cli") {
|
|
136618
|
+
const bin = res.account.auth.binary;
|
|
136619
|
+
const profile = res.account.auth.loginProfile;
|
|
136620
|
+
let st = await cliAuthStatus2(bin, profile);
|
|
136621
|
+
if (!st.loggedIn) {
|
|
136622
|
+
console.log(` sign-in: starting ${bin} ${cliLoginArgs2(bin).join(" ")}`);
|
|
136623
|
+
spawnSync(bin, cliLoginArgs2(bin), { stdio: "inherit", env: subscriptionEnv2(bin, profile) });
|
|
136624
|
+
st = await cliAuthStatus2(bin, profile);
|
|
136625
|
+
}
|
|
136626
|
+
console.log(st.loggedIn ? ` sign-in: ✓ ${st.detail ?? "ready"}` : ` sign-in: ✗ not signed in${st.detail ? ` (${st.detail})` : ""}`);
|
|
136627
|
+
} else {
|
|
136628
|
+
const t2 = await testAccount2(res.account);
|
|
136629
|
+
console.log(t2.ok ? " test: ✓ " + t2.message : " test: ✗ " + t2.message + " (stored anyway)");
|
|
136630
|
+
}
|
|
136519
136631
|
}
|
|
136520
136632
|
} else if (sub === "test" && rest2[0]) {
|
|
136521
136633
|
const a = listAccounts2().find((x2) => x2.id === rest2[0]);
|
|
@@ -136527,7 +136639,7 @@ Importable from your env (gearbox auth import): ${imp.map((c) => c.envVar).join(
|
|
|
136527
136639
|
for (const p of addableProviders2())
|
|
136528
136640
|
console.log(`${p.id.padEnd(16)} ${p.label} (${p.group})`);
|
|
136529
136641
|
} else {
|
|
136530
|
-
console.log("gearbox auth [list|import|add <key>|add <provider> <key>|test <id>|rm <id>|providers]");
|
|
136642
|
+
console.log("gearbox auth [list|import|add <key>|add <provider> <key>|add codex [name]|add claude [name]|test <id>|rm <id>|providers]");
|
|
136531
136643
|
}
|
|
136532
136644
|
process.exit(0);
|
|
136533
136645
|
}
|
package/package.json
CHANGED