@lunaroute/cli 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +31 -12
  2. package/package.json +1 -1
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.6.0";
7
+ var version = "0.7.0";
8
8
 
9
9
  // src/login.ts
10
10
  import { createServer } from "http";
@@ -469,7 +469,8 @@ var KeyRejectedError = class extends Error {
469
469
  var NON_CHAT_CAPABILITIES = [
470
470
  "image_generation",
471
471
  "embeddings",
472
- "rerank"
472
+ "rerank",
473
+ "systemone"
473
474
  ];
474
475
  function isChatModel(m) {
475
476
  for (const c of NON_CHAT_CAPABILITIES) {
@@ -1021,9 +1022,20 @@ function buildKeyPlan2(key2) {
1021
1022
  };
1022
1023
  }
1023
1024
 
1025
+ // src/setup/adapters/first-model.ts
1026
+ function requireFirstModel(ctx, harness) {
1027
+ const first = ctx.models[0]?.id;
1028
+ if (!first) {
1029
+ throw new Error(
1030
+ `no LunaRoute chat models in the catalog \u2014 nothing to configure for ${harness}`
1031
+ );
1032
+ }
1033
+ return first;
1034
+ }
1035
+
1024
1036
  // src/setup/adapters/claudeCode.ts
1025
1037
  function buildPlan3(ctx) {
1026
- const firstModel = ctx.models[0]?.id ?? "<model>";
1038
+ const firstModel = requireFirstModel(ctx, "claude-code");
1027
1039
  return {
1028
1040
  fileWrites: [],
1029
1041
  exports: [
@@ -1038,12 +1050,18 @@ function buildPlan3(ctx) {
1038
1050
  // keys are ignored and the OAuth token 401s through the gateway, kata
1039
1051
  // 009h).
1040
1052
  { name: "ANTHROPIC_AUTH_TOKEN", value: `$${ctx.keyEnvVar}` },
1041
- { name: "ANTHROPIC_MODEL", value: firstModel }
1053
+ { name: "ANTHROPIC_MODEL", value: firstModel },
1054
+ // Claude Code sends this hint header (x-claude-code-request-class:
1055
+ // auxiliary) only when asked to, and LunaRoute reads it to give
1056
+ // auto-mode classifier and other auxiliary requests a fast dedicated
1057
+ // lane instead of queueing them behind the session's own requests.
1058
+ { name: "CLAUDE_CODE_GATEWAY_HINT_HEADERS", value: "1" }
1042
1059
  ],
1043
1060
  notes: [
1044
1061
  "\nClaude Code: add the exports above to your shell profile, then restart Claude Code.",
1045
1062
  `Change ANTHROPIC_MODEL to any of: ${ctx.models.map((m) => m.id).join(", ")}`,
1046
1063
  "(Auth travels in the Authorization: Bearer header via ANTHROPIC_AUTH_TOKEN.)",
1064
+ "CLAUDE_CODE_GATEWAY_HINT_HEADERS=1 makes Claude Code label its auxiliary requests (the auto-mode safety classifier) so LunaRoute can route them to a fast dedicated lane; without it they are still detected via their wire marker, just less directly.",
1047
1065
  "If your Claude Code build predates ANTHROPIC_AUTH_TOKEN support, set ANTHROPIC_API_KEY=$LUNAROUTE_API_KEY instead \u2014 LunaRoute also authenticates lr_ keys sent as x-api-key. Bearer wins whenever both are set.",
1048
1066
  "To set these in ~/.claude/settings.json instead, note its env values are literal \u2014 the key would be baked into the file rather than read from $LUNAROUTE_API_KEY.",
1049
1067
  "If Claude Code hangs or keeps retrying when connecting, your key is likely wrong \u2014 it retries auth errors silently. Debug with the curl below, which fails fast with the real error:",
@@ -1078,7 +1096,7 @@ function validatedRoutingUrl(routingUrl) {
1078
1096
  // src/setup/adapters/codex.ts
1079
1097
  function buildPlan4(ctx) {
1080
1098
  const base = validatedRoutingUrl(ctx.routingUrl);
1081
- const model = ctx.models[0]?.id ?? "<model>";
1099
+ const model = requireFirstModel(ctx, "codex");
1082
1100
  const contextWindow = ctx.models[0]?.context_window_tokens;
1083
1101
  const lines = [`model = "${model}"`, 'model_provider = "lunaroute"'];
1084
1102
  if (Number.isInteger(contextWindow) && (contextWindow ?? 0) > 0) {
@@ -1107,7 +1125,7 @@ function buildPlan4(ctx) {
1107
1125
 
1108
1126
  // src/setup/adapters/copilotCli.ts
1109
1127
  function buildPlan5(ctx) {
1110
- const firstModel = ctx.models[0]?.id ?? "<model>";
1128
+ const firstModel = requireFirstModel(ctx, "copilot-cli");
1111
1129
  return {
1112
1130
  fileWrites: [],
1113
1131
  exports: [
@@ -1141,8 +1159,8 @@ function buildPlan6(ctx) {
1141
1159
  ` Base URL: ${ctx.routingUrl}/v1`,
1142
1160
  ` Auth: header Authorization: Bearer $${ctx.keyEnvVar}`,
1143
1161
  ` Auth (alt): path ${ctx.routingUrl}/a/$${ctx.keyEnvVar}/v1`,
1144
- ` Sample model id: ${ctx.models[0]?.id ?? "<model>"}`,
1145
- ` All models: ${ctx.models.map((m) => m.id).join(", ")}`
1162
+ ` Sample model id: ${ctx.models[0]?.id ?? "(no chat models in the catalog yet)"}`,
1163
+ ` All models: ${ctx.models.map((m) => m.id).join(", ") || "(none)"}`
1146
1164
  ]
1147
1165
  };
1148
1166
  }
@@ -1154,6 +1172,7 @@ function asRecord(v) {
1154
1172
  function buildPlan7(ctx) {
1155
1173
  const base = validatedRoutingUrl(ctx.routingUrl);
1156
1174
  const models = ctx.models.map((m) => ({ id: m.id, name: m.id }));
1175
+ const primary = requireFirstModel(ctx, "openclaw");
1157
1176
  return {
1158
1177
  fileWrites: [
1159
1178
  {
@@ -1191,7 +1210,7 @@ function buildPlan7(ctx) {
1191
1210
  model: {
1192
1211
  ...model,
1193
1212
  // Preserve an existing primary model, like OpenClaw onboarding.
1194
- primary: model.primary ?? `lunaroute/${ctx.models[0]?.id ?? "<model>"}`
1213
+ primary: model.primary ?? `lunaroute/${primary}`
1195
1214
  }
1196
1215
  }
1197
1216
  }
@@ -1202,7 +1221,7 @@ function buildPlan7(ctx) {
1202
1221
  exports: [{ name: ctx.keyEnvVar, value: "__KEY__" }],
1203
1222
  notes: [
1204
1223
  `
1205
- openclaw: restart the gateway, then \`openclaw models list\` and \`openclaw models set lunaroute/${ctx.models[0]?.id ?? "<model>"}\` (only if you have no default model already). If lunaroute/* models do not appear in \`openclaw models list\`, check that models.mode is merge \u2014 setup preserves whatever mode you have.`
1224
+ openclaw: restart the gateway, then \`openclaw models list\` and \`openclaw models set lunaroute/${primary}\` (only if you have no default model already). If lunaroute/* models do not appear in \`openclaw models list\`, check that models.mode is merge \u2014 setup preserves whatever mode you have.`
1206
1225
  ]
1207
1226
  };
1208
1227
  }
@@ -1380,7 +1399,7 @@ async function runSetup(harness, opts, deps = {
1380
1399
  return 1;
1381
1400
  }
1382
1401
  if (opts.key && (opts.extension || opts.models)) {
1383
- console.error("--key runs the full pi or opencode flow; drop --extension/--models.");
1402
+ console.error("--key runs the full setup flow for every harness; drop --extension/--models.");
1384
1403
  return 1;
1385
1404
  }
1386
1405
  const adapter = ADAPTERS[harness];
@@ -1449,7 +1468,7 @@ async function runSetup(harness, opts, deps = {
1449
1468
  models = await fetchModels(routingUrl, creds.routing_key);
1450
1469
  } catch (err) {
1451
1470
  console.error(
1452
- `Could not fetch the model catalog (${err instanceof Error ? err.message : err}) \u2014 continuing; model ids show as <model> until it answers.`
1471
+ `Could not fetch the model catalog (${err instanceof Error ? err.message : err}).`
1453
1472
  );
1454
1473
  models = [];
1455
1474
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunaroute/cli",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "LunaRoute CLI — configure coding harnesses and manage your LunaRoute account.",
5
5
  "repository": {
6
6
  "type": "git",