@lunaroute/cli 0.13.0 → 0.14.1

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.
Files changed (3) hide show
  1. package/README.md +2 -2
  2. package/dist/index.js +318 -115
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -27,7 +27,7 @@ Prefer a script? `setup pi --extension` / `--models` pick a flow, `--yes` accept
27
27
  ## What it enables
28
28
 
29
29
  - **One-command setup** — `lunaroute setup` writes the right config for `pi`, `claude-code`, `codex`, `opencode`, `copilot-cli`, or `generic` (any OpenAI-compatible base URL swap).
30
- - **Session launches** — `lunaroute run claude` or `lunaroute run codex` starts a session wired to LunaRoute; `--model` picks from the catalog, everything after `--` passes through to the harness.
30
+ - **Session launches** — `lunaroute run claude` or `lunaroute run codex` starts a session wired to LunaRoute; `--model` picks from the catalog, everything after `--` passes through to the harness. `lunaroute run agy` does the same for Antigravity CLI (Gemini CLI's successor) through its gateway env vars — agy reads the model list from LunaRoute's own catalog, so any catalog model is selectable.
31
31
  - **The catalog, in your terminal** — `models`, `pricing`, and `usage` show what's available, what it costs (credits per million tokens), and your wallet balance plus recent ledger entries.
32
32
  - **Project memory** — `memory search` and `memory read` query your past agent conversations for the current project. `lunaroute mcp` exposes the same tools as a stdio MCP server, and `skill install` wires the memory skill + MCP into Claude Code.
33
33
 
@@ -39,7 +39,7 @@ Prefer a script? `setup pi --extension` / `--models` pick a flow, `--yes` accept
39
39
  | `lunaroute whoami` | Show the signed-in user and organization |
40
40
  | `lunaroute logout` | Remove stored credentials |
41
41
  | `lunaroute setup <harness>` | Configure `opencode` \| `pi` \| `openclaw` \| `claude-code` \| `codex` \| `copilot-cli` \| `generic`. pi setup is interactive (asks before writing); `--extension` / `--models` pick a flow, `--yes` accepts prompts, `--print` previews |
42
- | `lunaroute run <harness>` | Launch `claude` \| `claude-code` \| `codex` on LunaRoute for this session |
42
+ | `lunaroute run <harness>` | Launch `claude` \| `claude-code` \| `codex` \| `zed` \| `agy` on LunaRoute for this session |
43
43
  | `lunaroute models` | List available LunaRoute models |
44
44
  | `lunaroute pricing` | Per-model pricing (credits per million tokens) |
45
45
  | `lunaroute usage` | Wallet balance and recent usage |
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@
4
4
  import { Command, InvalidArgumentError, Option } from "commander";
5
5
 
6
6
  // package.json
7
- var version = "0.13.0";
7
+ var version = "0.14.1";
8
8
 
9
9
  // src/login.ts
10
10
  import { createServer } from "http";
@@ -137,8 +137,8 @@ async function listSearchKeys(ctx) {
137
137
  async function listSearchKeysRaw(ctx) {
138
138
  return cliRequestRaw(ctx, "GET", "/v1/cli/search-provider-keys");
139
139
  }
140
- async function putSearchKey(ctx, provider, apiKey) {
141
- return cliRequest(ctx, "PUT", "/v1/cli/search-provider-keys", { provider, api_key: apiKey });
140
+ async function putSearchKey(ctx, provider, apiKey2) {
141
+ return cliRequest(ctx, "PUT", "/v1/cli/search-provider-keys", { provider, api_key: apiKey2 });
142
142
  }
143
143
  async function deleteSearchKey(ctx, provider) {
144
144
  await cliRequest(ctx, "DELETE", `/v1/cli/search-provider-keys?provider=${encodeURIComponent(provider)}`);
@@ -314,7 +314,7 @@ async function startLoopbackServer() {
314
314
  close: () => server.close()
315
315
  };
316
316
  }
317
- async function runLogin(profile) {
317
+ async function runLogin(profile, label) {
318
318
  const settings = resolveSettings(profile);
319
319
  const state = genState();
320
320
  const verifier = genVerifier();
@@ -338,7 +338,7 @@ async function runLogin(profile) {
338
338
  const result = await exchangeCode(settings.api_url, {
339
339
  code: cb.code,
340
340
  verifier,
341
- label: hostname()
341
+ label: label ?? hostname()
342
342
  });
343
343
  saveProfile(profile, {
344
344
  api_url: settings.api_url,
@@ -453,6 +453,203 @@ function key(profile) {
453
453
  console.log(creds.routing_key);
454
454
  }
455
455
 
456
+ // src/commands/apiKey.ts
457
+ import { hostname as hostname2 } from "os";
458
+
459
+ // src/setup/prompt.ts
460
+ import { createInterface } from "readline/promises";
461
+ var NonInteractiveTerminalError = class extends Error {
462
+ };
463
+ async function confirm(question, opts = {}) {
464
+ if (opts.yes) return true;
465
+ const input = opts.input ?? process.stdin;
466
+ if (!input.isTTY) {
467
+ throw new NonInteractiveTerminalError();
468
+ }
469
+ const rl = createInterface({ input, output: opts.output ?? process.stdout });
470
+ try {
471
+ const answer = (await rl.question(`${question} [y/N] `)).trim().toLowerCase();
472
+ return answer === "y" || answer === "yes";
473
+ } finally {
474
+ rl.close();
475
+ }
476
+ }
477
+ async function promptInput(question, opts = {}) {
478
+ if (!process.stdin.isTTY && opts.default === void 0) {
479
+ throw new NonInteractiveTerminalError(`${question} requires a TTY \u2014 pass a flag instead`);
480
+ }
481
+ if (!process.stdin.isTTY) {
482
+ return opts.default;
483
+ }
484
+ process.stdout.write(question + (opts.default !== void 0 ? ` [${opts.default}] ` : ": "));
485
+ const raw = !!opts.hidden && !!process.stdin.isTTY;
486
+ if (raw) {
487
+ process.stdin.setRawMode(true);
488
+ }
489
+ const chunks = [];
490
+ process.stdin.resume();
491
+ await new Promise((resolve) => {
492
+ const off = () => {
493
+ process.stdin.removeListener("data", onData);
494
+ process.stdin.pause();
495
+ };
496
+ const trimOneCodepoint = () => {
497
+ const all = Buffer.concat(chunks);
498
+ let end = all.length;
499
+ while (end > 0 && (all[end - 1] & 192) === 128) end--;
500
+ if (end > 0) end--;
501
+ chunks.length = 0;
502
+ if (end > 0) chunks.push(all.subarray(0, end));
503
+ };
504
+ const onData = (c) => {
505
+ let i = 0;
506
+ let runStart = -1;
507
+ const flushRun = (upto) => {
508
+ if (runStart >= 0) {
509
+ chunks.push(c.subarray(runStart, upto));
510
+ runStart = -1;
511
+ }
512
+ };
513
+ while (i < c.length) {
514
+ const b = c[i];
515
+ if (raw && b === 3) {
516
+ off();
517
+ process.stdin.setRawMode(false);
518
+ process.exit(130);
519
+ }
520
+ if (b === 13 || b === 10) {
521
+ flushRun(i);
522
+ off();
523
+ resolve();
524
+ return;
525
+ }
526
+ if (raw && (b === 127 || b === 8)) {
527
+ flushRun(i);
528
+ trimOneCodepoint();
529
+ i++;
530
+ continue;
531
+ }
532
+ if (runStart < 0) runStart = i;
533
+ i++;
534
+ }
535
+ flushRun(c.length);
536
+ };
537
+ process.stdin.on("data", onData);
538
+ });
539
+ if (raw) {
540
+ process.stdin.setRawMode(false);
541
+ process.stdout.write("\n");
542
+ }
543
+ const value = Buffer.concat(chunks).toString("utf8").trim();
544
+ return value === "" && opts.default !== void 0 ? opts.default : value;
545
+ }
546
+
547
+ // src/commands/apiKey.ts
548
+ async function apiKeyShow(profile, opts = {}) {
549
+ const creds = loadProfile(profile);
550
+ if (!creds?.routing_key) {
551
+ const canPrompt = process.stdin.isTTY && process.stdout.isTTY || !!opts.yes;
552
+ if (canPrompt) {
553
+ let want = false;
554
+ try {
555
+ want = await confirm(`No API key for profile "${profile}". Generate a new one?`, { yes: opts.yes });
556
+ } catch (e) {
557
+ if (e instanceof NonInteractiveTerminalError) {
558
+ console.error('Not logged in. Run "lunaroute login" to get started.');
559
+ process.exitCode = 1;
560
+ return;
561
+ }
562
+ throw e;
563
+ }
564
+ if (!want) {
565
+ console.error('Not logged in. Run "lunaroute login" to get started.');
566
+ process.exitCode = 1;
567
+ return;
568
+ }
569
+ let name = opts.name;
570
+ if (!name && !opts.yes) {
571
+ try {
572
+ const n = await promptInput("Name for new API key", { default: "" });
573
+ if (n.trim()) name = n.trim();
574
+ } catch {
575
+ }
576
+ }
577
+ await runLogin(profile, name ?? hostname2());
578
+ const fresh = loadProfile(profile);
579
+ if (fresh?.routing_key) {
580
+ console.log(fresh.routing_key);
581
+ return;
582
+ }
583
+ console.error("Failed to create API key.");
584
+ process.exitCode = 1;
585
+ return;
586
+ }
587
+ console.error('Not logged in. Run "lunaroute login" to get started.');
588
+ process.exitCode = 1;
589
+ return;
590
+ }
591
+ const shouldValidate = process.stdin.isTTY && process.stdout.isTTY || !!opts.yes;
592
+ if (shouldValidate) {
593
+ const effectiveApiUrl = resolveSettings(profile).api_url;
594
+ const valid = await isKeyValid({ api_url: effectiveApiUrl, routing_key: creds.routing_key });
595
+ if (valid === false) {
596
+ console.error(`Stored key for profile "${profile}" is revoked or invalid (401).`);
597
+ let create = false;
598
+ try {
599
+ create = await confirm(`Generate a new API key for profile "${profile}"?`, { yes: opts.yes });
600
+ } catch (e) {
601
+ if (e instanceof NonInteractiveTerminalError) {
602
+ console.error(`Run "lunaroute login" to generate a new key${opts.name ? ` (e.g. --name "${opts.name}")` : ""}.`);
603
+ process.exitCode = 1;
604
+ return;
605
+ }
606
+ throw e;
607
+ }
608
+ if (!create) {
609
+ console.error("Aborted. Showing revoked key for reference (it will not authenticate).");
610
+ console.log(creds.routing_key);
611
+ return;
612
+ }
613
+ let name = opts.name;
614
+ if (!name && !opts.yes) {
615
+ try {
616
+ const n = await promptInput("Name for new API key (leave empty for default)", { default: "" });
617
+ if (n.trim()) name = n.trim();
618
+ } catch {
619
+ }
620
+ }
621
+ await runLogin(profile, name ?? hostname2());
622
+ const fresh = loadProfile(profile);
623
+ if (fresh?.routing_key) {
624
+ console.log(fresh.routing_key);
625
+ return;
626
+ }
627
+ console.error("Failed to create API key.");
628
+ process.exitCode = 1;
629
+ return;
630
+ }
631
+ }
632
+ console.log(creds.routing_key);
633
+ }
634
+ async function isKeyValid(creds) {
635
+ const controller = new AbortController();
636
+ const t = setTimeout(() => controller.abort(), 2500);
637
+ try {
638
+ const res = await fetch(`${creds.api_url}/v1/cli/models`, {
639
+ method: "GET",
640
+ headers: { Authorization: `Bearer ${creds.routing_key}` },
641
+ signal: controller.signal
642
+ });
643
+ if (res.status === 401) return false;
644
+ if (res.ok) return true;
645
+ return null;
646
+ } catch {
647
+ return null;
648
+ } finally {
649
+ clearTimeout(t);
650
+ }
651
+ }
652
+
456
653
  // src/commands/logout.ts
457
654
  function logout(profile) {
458
655
  if (!loadProfile(profile)) {
@@ -755,94 +952,6 @@ ${block.header}`);
755
952
  return summary;
756
953
  }
757
954
 
758
- // src/setup/prompt.ts
759
- import { createInterface } from "readline/promises";
760
- var NonInteractiveTerminalError = class extends Error {
761
- };
762
- async function confirm(question, opts = {}) {
763
- if (opts.yes) return true;
764
- const input = opts.input ?? process.stdin;
765
- if (!input.isTTY) {
766
- throw new NonInteractiveTerminalError();
767
- }
768
- const rl = createInterface({ input, output: opts.output ?? process.stdout });
769
- try {
770
- const answer = (await rl.question(`${question} [y/N] `)).trim().toLowerCase();
771
- return answer === "y" || answer === "yes";
772
- } finally {
773
- rl.close();
774
- }
775
- }
776
- async function promptInput(question, opts = {}) {
777
- if (!process.stdin.isTTY && opts.default === void 0) {
778
- throw new NonInteractiveTerminalError(`${question} requires a TTY \u2014 pass a flag instead`);
779
- }
780
- if (!process.stdin.isTTY) {
781
- return opts.default;
782
- }
783
- process.stdout.write(question + (opts.default !== void 0 ? ` [${opts.default}] ` : ": "));
784
- const raw = !!opts.hidden && !!process.stdin.isTTY;
785
- if (raw) {
786
- process.stdin.setRawMode(true);
787
- }
788
- const chunks = [];
789
- process.stdin.resume();
790
- await new Promise((resolve) => {
791
- const off = () => {
792
- process.stdin.removeListener("data", onData);
793
- process.stdin.pause();
794
- };
795
- const trimOneCodepoint = () => {
796
- const all = Buffer.concat(chunks);
797
- let end = all.length;
798
- while (end > 0 && (all[end - 1] & 192) === 128) end--;
799
- if (end > 0) end--;
800
- chunks.length = 0;
801
- if (end > 0) chunks.push(all.subarray(0, end));
802
- };
803
- const onData = (c) => {
804
- let i = 0;
805
- let runStart = -1;
806
- const flushRun = (upto) => {
807
- if (runStart >= 0) {
808
- chunks.push(c.subarray(runStart, upto));
809
- runStart = -1;
810
- }
811
- };
812
- while (i < c.length) {
813
- const b = c[i];
814
- if (raw && b === 3) {
815
- off();
816
- process.stdin.setRawMode(false);
817
- process.exit(130);
818
- }
819
- if (b === 13 || b === 10) {
820
- flushRun(i);
821
- off();
822
- resolve();
823
- return;
824
- }
825
- if (raw && (b === 127 || b === 8)) {
826
- flushRun(i);
827
- trimOneCodepoint();
828
- i++;
829
- continue;
830
- }
831
- if (runStart < 0) runStart = i;
832
- i++;
833
- }
834
- flushRun(c.length);
835
- };
836
- process.stdin.on("data", onData);
837
- });
838
- if (raw) {
839
- process.stdin.setRawMode(false);
840
- process.stdout.write("\n");
841
- }
842
- const value = Buffer.concat(chunks).toString("utf8").trim();
843
- return value === "" && opts.default !== void 0 ? opts.default : value;
844
- }
845
-
846
955
  // src/spawn.ts
847
956
  import { spawn as nodeSpawn } from "child_process";
848
957
  import { spawn as crossSpawn } from "cross-spawn";
@@ -1230,6 +1339,9 @@ function requireFirstModel(ctx, harness) {
1230
1339
  function buildPlan3(ctx) {
1231
1340
  const firstModel = requireFirstModel(ctx, "claude-code");
1232
1341
  const isWin = (ctx.dialect ?? resolveDialect()) === "win32";
1342
+ const row = ctx.models[0];
1343
+ const windowTokens = row?.context_window_tokens && row.context_window_tokens > 0 ? row.context_window_tokens : void 0;
1344
+ const outputTokens = row?.max_output_tokens && row.max_output_tokens > 0 ? row.max_output_tokens : void 0;
1233
1345
  return {
1234
1346
  fileWrites: [],
1235
1347
  exports: [
@@ -1245,6 +1357,10 @@ function buildPlan3(ctx) {
1245
1357
  // 009h).
1246
1358
  { name: "ANTHROPIC_AUTH_TOKEN", value: `$${ctx.keyEnvVar}` },
1247
1359
  { name: "ANTHROPIC_MODEL", value: firstModel },
1360
+ // Declaring a below-200K window also stops a session from silently
1361
+ // outgrowing what we accept: Claude Code would not compact until 200K.
1362
+ ...windowTokens ? [{ name: "CLAUDE_CODE_MAX_CONTEXT_TOKENS", value: String(windowTokens) }] : [],
1363
+ ...outputTokens ? [{ name: "CLAUDE_CODE_MAX_OUTPUT_TOKENS", value: String(outputTokens) }] : [],
1248
1364
  // Pins Claude Code's background (Haiku-class) model — titles, summaries,
1249
1365
  // compaction, the auxiliary classifier — so those requests route through
1250
1366
  // LunaRoute instead of 404'ing against Anthropic's hardcoded Haiku id,
@@ -1286,6 +1402,9 @@ function buildPlan3(ctx) {
1286
1402
  "WSL is a separate environment: Windows user variables do not cross into it (WSLENV is the bridge) and the npm global install is separate. Run `lunaroute setup claude-code` again inside the distribution."
1287
1403
  ] : [],
1288
1404
  `Change ANTHROPIC_MODEL to any of: ${ctx.models.map((m) => m.id).join(", ")}`,
1405
+ ...windowTokens || outputTokens ? [
1406
+ "CLAUDE_CODE_MAX_CONTEXT_TOKENS / CLAUDE_CODE_MAX_OUTPUT_TOKENS carry the pinned model's real window and output cap: Claude Code otherwise assumes 200K and asks for 32K whatever /v1/models reports. They describe ANTHROPIC_MODEL, not the Claude-shaped alias ids the /model picker lists (Claude Code ignores the window variable for those, and for any id it recognizes as a Claude model \u2014 those run at their built-in window), and one value serves the whole session \u2014 re-run setup when you switch to a model with a different window or output cap. Claude Code clamps the output value to its own maximum, and a bigger output cap leaves less context before compaction."
1407
+ ] : [],
1289
1408
  "ANTHROPIC_CUSTOM_HEADERS carries X-LunaRoute-Client: claude-desktop so the /model picker's gateway discovery returns Claude-shaped alias ids instead of an empty list: Claude Code drops any discovered id without 'claude'/'anthropic' in it, and LunaRoute's normal catalog has none. The aliases route back to the real model at the gateway \u2014 pick one in /model like any other, or set ANTHROPIC_MODEL to a plain model id to skip the aliases.",
1290
1409
  "ANTHROPIC_DEFAULT_HAIKU_MODEL pins Claude Code's background model (titles, summaries, compaction, the auxiliary classifier) \u2014 it defaults to your main model, and you can point it at a smaller/faster model from the list above.",
1291
1410
  "(Auth travels in the Authorization: Bearer header via ANTHROPIC_AUTH_TOKEN.)",
@@ -1759,8 +1878,8 @@ function buildPlan10(ctx) {
1759
1878
  };
1760
1879
  const notes = [
1761
1880
  "\nzed: restart Zed, then pick a LunaRoute model in the agent panel.",
1762
- 'zed: to paste the key in Zed, run "agent: open settings" and open LLM Providers \u2192 LunaRoute \u2192 paste. Print the key with "lunaroute key" (or create one in the dashboard if you have none); Zed stores it in the OS keychain.',
1763
- `zed: or set ${ctx.keyEnvVar} (the block above), which Zed reads at launch and which takes precedence over the keychain; or launch with "lunaroute run zed" to inject it for one session \u2014 quit a running Zed first.`
1881
+ 'zed: paste the API key in Zed via Settings \u2192 AI \u2192 General \u2192 LLM Providers \u2192 Configure \u2192 find lunaroute \u2192 Configure \u2192 paste the API key. Print the key with "lunaroute key" (or create one in the dashboard if you have none); this stores it in the OS keychain.',
1882
+ `zed: or set ${ctx.keyEnvVar} (the block above), which Zed reads at launch and takes precedence over the keychain; or launch with "lunaroute run zed" to inject it for one session \u2014 quit a running Zed first.`
1764
1883
  ];
1765
1884
  if (skipped.length > 0) {
1766
1885
  notes.push(`Skipped (no context window or output limit in the catalog): ${skipped.join(", ")}`);
@@ -1791,6 +1910,26 @@ function buildPlan10(ctx) {
1791
1910
  };
1792
1911
  }
1793
1912
 
1913
+ // src/setup/adapters/agy.ts
1914
+ function buildPlan11(ctx) {
1915
+ const model = ctx.models[0]?.id ?? "(no chat models in the catalog yet)";
1916
+ return {
1917
+ fileWrites: [],
1918
+ exports: [
1919
+ { name: "AGY_LLM_GATEWAY_URL", value: `${ctx.routingUrl}/v1` },
1920
+ { name: "AGY_LLM_GATEWAY_API_KEY", value: "__KEY__" }
1921
+ ],
1922
+ notes: [
1923
+ "\nAntigravity CLI (agy) setup:",
1924
+ " Nothing is written to ~/.gemini/antigravity-cli \u2014 agy reads these two variables at launch.",
1925
+ " Or skip the exports entirely and let the CLI own the session:",
1926
+ " lunaroute run agy # first model in the catalog",
1927
+ ` lunaroute run agy --model ${model}`,
1928
+ " agy takes its model list from LunaRoute's catalog, so any model id is selectable."
1929
+ ]
1930
+ };
1931
+ }
1932
+
1794
1933
  // src/setup/snapshot.ts
1795
1934
  import {
1796
1935
  chmodSync as chmodSync4,
@@ -1990,6 +2129,7 @@ var ADAPTERS = {
1990
2129
  "claude-desktop": buildPlan4,
1991
2130
  codex: buildPlan5,
1992
2131
  "copilot-cli": buildPlan6,
2132
+ agy: buildPlan11,
1993
2133
  generic: buildPlan7
1994
2134
  };
1995
2135
  var PI_INSTALL_PACKAGES = ["npm:@lunaroute/pi-extension"];
@@ -2956,7 +3096,7 @@ async function runSearchKeysSet(profile, opts) {
2956
3096
  const ctx = { apiUrl: s.api_url, apiKey: s.routing_key };
2957
3097
  try {
2958
3098
  let provider = opts.provider;
2959
- let apiKey = opts.apiKey ?? process.env.LUNAROUTE_SEARCH_API_KEY;
3099
+ let apiKey2 = opts.apiKey ?? process.env.LUNAROUTE_SEARCH_API_KEY;
2960
3100
  const providers = await listSearchProviders(ctx);
2961
3101
  const known = providers.map((p) => p.key);
2962
3102
  if (!provider) {
@@ -2966,10 +3106,10 @@ async function runSearchKeysSet(profile, opts) {
2966
3106
  console.error(`unknown provider "${provider}" \u2014 this server offers: ${known.join(", ")}`);
2967
3107
  return 1;
2968
3108
  }
2969
- if (!apiKey) {
2970
- apiKey = await promptInput("API key", { hidden: true });
3109
+ if (!apiKey2) {
3110
+ apiKey2 = await promptInput("API key", { hidden: true });
2971
3111
  }
2972
- const meta = await putSearchKey(ctx, provider, apiKey);
3112
+ const meta = await putSearchKey(ctx, provider, apiKey2);
2973
3113
  console.log(`Stored key for ${meta.provider} (updated ${meta.updated_at}).`);
2974
3114
  return 0;
2975
3115
  } catch (err) {
@@ -3178,6 +3318,8 @@ async function runSkillInstall(profile, opts) {
3178
3318
 
3179
3319
  // src/run/adapters/claudeCode.ts
3180
3320
  function buildRunSpec(ctx) {
3321
+ const windowTokens = ctx.contextWindow && ctx.contextWindow > 0 ? ctx.contextWindow : void 0;
3322
+ const outputTokens = ctx.maxOutputTokens && ctx.maxOutputTokens > 0 ? ctx.maxOutputTokens : void 0;
3181
3323
  return {
3182
3324
  command: "claude",
3183
3325
  args: [],
@@ -3185,6 +3327,8 @@ function buildRunSpec(ctx) {
3185
3327
  ANTHROPIC_BASE_URL: ctx.routingUrl,
3186
3328
  ANTHROPIC_AUTH_TOKEN: ctx.apiKey,
3187
3329
  ANTHROPIC_MODEL: ctx.model,
3330
+ ...windowTokens ? { CLAUDE_CODE_MAX_CONTEXT_TOKENS: String(windowTokens) } : {},
3331
+ ...outputTokens ? { CLAUDE_CODE_MAX_OUTPUT_TOKENS: String(outputTokens) } : {},
3188
3332
  // Pins the Haiku/background model so Claude Code's background tasks
3189
3333
  // (titles, summaries, compaction) route through LunaRoute instead of
3190
3334
  // 404'ing against Anthropic's hardcoded Haiku id. Mirrors the Connect tab
@@ -3239,9 +3383,13 @@ function buildRunSpec2(ctx) {
3239
3383
  }
3240
3384
 
3241
3385
  // src/run/adapters/zed.ts
3242
- import { accessSync, constants as constants2, existsSync as existsSync6, readFileSync as readFileSync8, realpathSync as realpathSync2 } from "fs";
3386
+ import { existsSync as existsSync6, readFileSync as readFileSync8, realpathSync as realpathSync2 } from "fs";
3243
3387
  import { homedir as homedir3 } from "os";
3244
- import { basename as basename2, dirname as dirname4, join as join5 } from "path";
3388
+ import { basename as basename2, dirname as dirname4, join as join6 } from "path";
3389
+
3390
+ // src/run/which.ts
3391
+ import { accessSync, constants as constants2 } from "fs";
3392
+ import { join as join5 } from "path";
3245
3393
  function which(cmd, env, platform) {
3246
3394
  const pathVar = env.PATH ?? env.Path ?? "";
3247
3395
  const exts = platform === "win32" ? (env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean) : [""];
@@ -3259,6 +3407,8 @@ function which(cmd, env, platform) {
3259
3407
  }
3260
3408
  return null;
3261
3409
  }
3410
+
3411
+ // src/run/adapters/zed.ts
3262
3412
  function firstExisting(paths) {
3263
3413
  for (const path of paths) if (existsSync6(path)) return path;
3264
3414
  return null;
@@ -3273,7 +3423,7 @@ function resolveZedCommand(deps = {}) {
3273
3423
  try {
3274
3424
  const real = realpathSync2(shim);
3275
3425
  if (basename2(real) === "cli") {
3276
- const app = join5(dirname4(real), "zed");
3426
+ const app = join6(dirname4(real), "zed");
3277
3427
  if (existsSync6(app)) return app;
3278
3428
  }
3279
3429
  return real;
@@ -3283,20 +3433,20 @@ function resolveZedCommand(deps = {}) {
3283
3433
  }
3284
3434
  return firstExisting([
3285
3435
  "/Applications/Zed.app/Contents/MacOS/zed",
3286
- join5(home, "Applications", "Zed.app", "Contents", "MacOS", "zed"),
3436
+ join6(home, "Applications", "Zed.app", "Contents", "MacOS", "zed"),
3287
3437
  "/Applications/Zed Preview.app/Contents/MacOS/zed",
3288
- join5(home, "Applications", "Zed Preview.app", "Contents", "MacOS", "zed"),
3438
+ join6(home, "Applications", "Zed Preview.app", "Contents", "MacOS", "zed"),
3289
3439
  "/Applications/Zed Nightly.app/Contents/MacOS/zed"
3290
3440
  ]);
3291
3441
  }
3292
3442
  if (platform === "win32") {
3293
3443
  const onPath = which("zed", env, platform);
3294
3444
  if (onPath) return onPath;
3295
- return env.LOCALAPPDATA ? firstExisting([join5(env.LOCALAPPDATA, "Programs", "Zed", "zed.exe")]) : null;
3445
+ return env.LOCALAPPDATA ? firstExisting([join6(env.LOCALAPPDATA, "Programs", "Zed", "zed.exe")]) : null;
3296
3446
  }
3297
3447
  return which("zed", env, platform) ?? which("zed-x11", env, platform) ?? firstExisting([
3298
- join5(home, ".local", "bin", "zed"),
3299
- join5(home, ".local", "zed.app", "bin", "zed")
3448
+ join6(home, ".local", "bin", "zed"),
3449
+ join6(home, ".local", "zed.app", "bin", "zed")
3300
3450
  ]);
3301
3451
  }
3302
3452
  function hasLunarouteProvider(settingsPath) {
@@ -3321,19 +3471,66 @@ function buildRunSpec3(ctx, deps = {}) {
3321
3471
  };
3322
3472
  }
3323
3473
 
3474
+ // src/run/adapters/agy.ts
3475
+ import { accessSync as accessSync2, constants as constants3 } from "fs";
3476
+ import { homedir as homedir4 } from "os";
3477
+ import { join as join7 } from "path";
3478
+ function firstRunnable(paths, platform) {
3479
+ for (const path of paths) {
3480
+ try {
3481
+ accessSync2(path, platform === "win32" ? constants3.F_OK : constants3.X_OK);
3482
+ return path;
3483
+ } catch {
3484
+ }
3485
+ }
3486
+ return null;
3487
+ }
3488
+ function resolveAgyCommand(deps = {}) {
3489
+ const platform = deps.platform ?? process.platform;
3490
+ const env = deps.env ?? process.env;
3491
+ const home = env.HOME || env.USERPROFILE || homedir4();
3492
+ const onPath = which("agy", env, platform);
3493
+ if (onPath) return onPath;
3494
+ if (platform === "win32") {
3495
+ const localAppData = env.LOCALAPPDATA;
3496
+ const programFiles = env.ProgramFiles || env.PROGRAMFILES || "C:\\Program Files";
3497
+ return firstRunnable(
3498
+ [
3499
+ ...localAppData ? [join7(localAppData, "agy", "bin", "agy.exe")] : [],
3500
+ join7(programFiles, "Google", "antigravity-cli", "agy.exe")
3501
+ ],
3502
+ platform
3503
+ );
3504
+ }
3505
+ return firstRunnable([join7(home, ".local", "bin", "agy")], platform);
3506
+ }
3507
+ function buildRunSpec4(ctx, deps = {}) {
3508
+ return {
3509
+ command: resolveAgyCommand(deps) ?? "agy",
3510
+ args: ["--model", ctx.model],
3511
+ env: {
3512
+ AGY_LLM_GATEWAY_URL: `${ctx.routingUrl}/v1`,
3513
+ AGY_LLM_GATEWAY_API_KEY: ctx.apiKey
3514
+ }
3515
+ };
3516
+ }
3517
+
3324
3518
  // src/commands/run.ts
3325
3519
  var ADAPTERS2 = {
3326
3520
  claude: buildRunSpec,
3327
3521
  "claude-code": buildRunSpec,
3328
3522
  codex: buildRunSpec2,
3329
- zed: buildRunSpec3
3523
+ zed: buildRunSpec3,
3524
+ agy: buildRunSpec4
3330
3525
  };
3331
3526
  var MODEL_LOOKUP_TIMEOUT_MS = 3e3;
3527
+ var WANTS_MODEL_ROW = /* @__PURE__ */ new Set(["codex", "claude", "claude-code"]);
3332
3528
  var INSTALL_HINT = {
3333
3529
  claude: "Install Claude Code: https://docs.anthropic.com/claude-code/install",
3334
3530
  "claude-code": "Install Claude Code: https://docs.anthropic.com/claude-code/install",
3335
3531
  codex: "Install Codex: https://github.com/openai/codex#install",
3336
- zed: "Install Zed: https://zed.dev/download (Windows: winget install -e --id ZedIndustries.Zed)"
3532
+ zed: "Install Zed: https://zed.dev/download (Windows: winget install -e --id ZedIndustries.Zed)",
3533
+ agy: "Install Antigravity CLI: curl -fsSL https://antigravity.google/cli/install.sh | bash (Windows: https://antigravity.google/cli/install.ps1)"
3337
3534
  };
3338
3535
  var realDeps = {
3339
3536
  spawn: makeRealSpawn(),
@@ -3369,7 +3566,7 @@ async function runRun(harness, opts, deps = realDeps) {
3369
3566
  return 1;
3370
3567
  }
3371
3568
  console.error(`# using model ${model} (pass --model to change)`);
3372
- } else if (usesModel && harness === "codex") {
3569
+ } else if (usesModel && WANTS_MODEL_ROW.has(harness)) {
3373
3570
  try {
3374
3571
  models = await deps.fetchModels(creds.routing_url, creds.routing_key, {
3375
3572
  signal: AbortSignal.timeout(MODEL_LOOKUP_TIMEOUT_MS)
@@ -3378,12 +3575,13 @@ async function runRun(harness, opts, deps = realDeps) {
3378
3575
  models = [];
3379
3576
  }
3380
3577
  }
3381
- const contextWindow = models.find((m) => m.id === model)?.context_window_tokens;
3578
+ const row = models.find((m) => m.id === model);
3382
3579
  const spec = adapter({
3383
3580
  routingUrl: creds.routing_url,
3384
3581
  apiKey: creds.routing_key,
3385
3582
  model,
3386
- contextWindow
3583
+ contextWindow: row?.context_window_tokens,
3584
+ maxOutputTokens: row?.max_output_tokens
3387
3585
  });
3388
3586
  if (spec.notice) console.error(spec.notice);
3389
3587
  const args = spec.args.concat(opts.passthrough ?? []);
@@ -3430,10 +3628,15 @@ program.command("whoami").description("Show the signed-in user and organization.
3430
3628
  program.command("key").description('Print the stored routing key, for shell use (e.g. "$(lunaroute key)").').action(() => {
3431
3629
  key(program.opts().profile);
3432
3630
  });
3631
+ var apiKey = program.command("api-key").alias("api-keys").description("Manage API keys.");
3632
+ apiKey.command("show").description('Show the stored API key (same as "lunaroute key"; reuses existing key, prompts with --name on revocation).').option("--name <name>", "name for the new key when generating after revocation (or when no key exists)").option("--yes", "accept prompts without a TTY", false).action(async (opts) => {
3633
+ await apiKeyShow(program.opts().profile, { name: opts.name, yes: opts.yes });
3634
+ if (process.exitCode && process.exitCode !== 0) process.exit(process.exitCode);
3635
+ });
3433
3636
  program.command("logout").description("Remove stored credentials for the active profile.").action(() => {
3434
3637
  logout(program.opts().profile);
3435
3638
  });
3436
- program.command("setup <harness>").description("Configure a coding harness (opencode | pi | hermes | claude-code | claude-desktop | codex | copilot-cli | openclaw | dsh | zed | generic).").option("--print", "print the config instead of writing files", false).option("--routing-url <url>", "override the routing base URL").option("--yes", "accept all confirmation prompts without a TTY (for scripts)", false).option("--extension", "pi only: jump straight to installing the Pi extension").option("--models", "pi only: jump straight to writing the models.json provider block").option("--remove", "claude-desktop: restore the profile from the snapshot taken at setup (writes nothing when no snapshot exists)").option("--key <key>", "a LunaRoute routing key (lr_\u2026), e.g. from the dashboard's onboarding page \u2014 stores it and skips the browser login").action(async (harness, opts) => {
3639
+ program.command("setup <harness>").description("Configure a coding harness (opencode | pi | hermes | claude-code | claude-desktop | codex | copilot-cli | openclaw | dsh | zed | agy | generic).").option("--print", "print the config instead of writing files", false).option("--routing-url <url>", "override the routing base URL").option("--yes", "accept all confirmation prompts without a TTY (for scripts)", false).option("--extension", "pi only: jump straight to installing the Pi extension").option("--models", "pi only: jump straight to writing the models.json provider block").option("--remove", "claude-desktop: restore the profile from the snapshot taken at setup (writes nothing when no snapshot exists)").option("--key <key>", "a LunaRoute routing key (lr_\u2026), e.g. from the dashboard's onboarding page \u2014 stores it and skips the browser login").action(async (harness, opts) => {
3437
3640
  const code = await runSetup(harness, {
3438
3641
  profile: program.opts().profile,
3439
3642
  print: opts.print,
@@ -3446,7 +3649,7 @@ program.command("setup <harness>").description("Configure a coding harness (open
3446
3649
  });
3447
3650
  if (code !== 0) process.exit(code);
3448
3651
  });
3449
- program.command("run <harness>").description("Launch a coding harness (claude | claude-code | codex | zed) configured to use LunaRoute for this session.").option("--model <id>", "model id to launch on (default: first model in the catalog)").argument("[extra...]").action(async (harness, extra, opts) => {
3652
+ program.command("run <harness>").description("Launch a coding harness (claude | claude-code | codex | zed | agy) configured to use LunaRoute for this session.").option("--model <id>", "model id to launch on (default: first model in the catalog)").argument("[extra...]").action(async (harness, extra, opts) => {
3450
3653
  const sep = process.argv.indexOf("--");
3451
3654
  const post = sep !== -1 ? process.argv.slice(sep + 1) : [];
3452
3655
  const before = post.length <= extra.length ? extra.slice(0, extra.length - post.length) : extra;
@@ -3514,7 +3717,7 @@ searchKeys.command("list").description("List configured search provider keys.").
3514
3717
  const code = await runSearchKeysList(program.opts().profile, { json: opts.json });
3515
3718
  if (code !== 0) process.exit(code);
3516
3719
  });
3517
- searchKeys.command("set").description("Store or replace a search provider key (prompts for missing values).").option("--provider <key>", "provider key (e.g. kagi, brave, exa)").option("--api-key <key>", "API key (visible in shell history \u2014 prefer the prompt or LUNAROUTE_SEARCH_API_KEY)").action(async (opts) => {
3720
+ searchKeys.command("set").description("Store or replace a search provider key (prompts for missing values).").option("--provider <key>", "provider key (e.g. kagi, brave, exa, youcom)").option("--api-key <key>", "API key (visible in shell history \u2014 prefer the prompt or LUNAROUTE_SEARCH_API_KEY)").action(async (opts) => {
3518
3721
  const code = await runSearchKeysSet(program.opts().profile, { provider: opts.provider, apiKey: opts.apiKey });
3519
3722
  if (code !== 0) process.exit(code);
3520
3723
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunaroute/cli",
3
- "version": "0.13.0",
3
+ "version": "0.14.1",
4
4
  "description": "LunaRoute CLI — configure coding harnesses and manage your LunaRoute account.",
5
5
  "repository": {
6
6
  "type": "git",