gearbox-code 0.1.9 → 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 +52 -9
- 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,7 +136307,7 @@ 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);
|
|
136286
136312
|
var supportsAnsi = process.env.NO_COLOR !== "1" && process.env.TERM !== "dumb" && (process.stdout.isTTY || process.env.FORCE_COLOR === "1");
|
|
136287
136313
|
var ansi = (code) => supportsAnsi ? `\x1B[${code}m` : "";
|
|
@@ -136539,6 +136565,8 @@ Set up at least one provider first:
|
|
|
136539
136565
|
gearbox onboard
|
|
136540
136566
|
gearbox auth add <api-key>
|
|
136541
136567
|
gearbox auth add <provider> <api-key>
|
|
136568
|
+
gearbox auth add codex [name]
|
|
136569
|
+
gearbox auth add claude [name]
|
|
136542
136570
|
gearbox auth import
|
|
136543
136571
|
|
|
136544
136572
|
Models: ${MODELS.map((m2) => m2.label).join(", ")}
|
|
@@ -136556,7 +136584,8 @@ if (args[0] === "onboard" || args[0] === "setup") {
|
|
|
136556
136584
|
if (args[0] === "auth") {
|
|
136557
136585
|
const { listAccounts: listAccounts2, loadAccounts: loadAccounts3, removeAccount: removeAccount2 } = await Promise.resolve().then(() => (init_store(), exports_store));
|
|
136558
136586
|
const { importableEnvCreds: importableEnvCreds2, importEnvCred: importEnvCred2, importableCloudCreds: importableCloudCreds2, importCloudCred: importCloudCred2 } = await Promise.resolve().then(() => (init_detect(), exports_detect));
|
|
136559
|
-
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));
|
|
136560
136589
|
const { detectProviderByKey: detectProviderByKey2 } = await Promise.resolve().then(() => (init_catalog(), exports_catalog));
|
|
136561
136590
|
const sub = args[1];
|
|
136562
136591
|
const rest2 = args.slice(2);
|
|
@@ -136580,11 +136609,25 @@ Importable from your env (gearbox auth import): ${imp.map((c) => c.envVar).join(
|
|
|
136580
136609
|
const names = [...keys2.map((c) => c.provider), ...cloud.map((c) => c.provider)];
|
|
136581
136610
|
console.log(names.length ? `Imported ${names.length}: ${names.join(", ")}` : "Nothing to import.");
|
|
136582
136611
|
} else if (sub === "add") {
|
|
136583
|
-
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]" };
|
|
136584
136615
|
console.log(res.message);
|
|
136585
136616
|
if (res.ok && res.account) {
|
|
136586
|
-
|
|
136587
|
-
|
|
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
|
+
}
|
|
136588
136631
|
}
|
|
136589
136632
|
} else if (sub === "test" && rest2[0]) {
|
|
136590
136633
|
const a = listAccounts2().find((x2) => x2.id === rest2[0]);
|
|
@@ -136596,7 +136639,7 @@ Importable from your env (gearbox auth import): ${imp.map((c) => c.envVar).join(
|
|
|
136596
136639
|
for (const p of addableProviders2())
|
|
136597
136640
|
console.log(`${p.id.padEnd(16)} ${p.label} (${p.group})`);
|
|
136598
136641
|
} else {
|
|
136599
|
-
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]");
|
|
136600
136643
|
}
|
|
136601
136644
|
process.exit(0);
|
|
136602
136645
|
}
|
package/package.json
CHANGED