@lunaroute/cli 0.14.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.
- package/dist/index.js +20 -4
- 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.14.
|
|
7
|
+
var version = "0.14.1";
|
|
8
8
|
|
|
9
9
|
// src/login.ts
|
|
10
10
|
import { createServer } from "http";
|
|
@@ -1339,6 +1339,9 @@ function requireFirstModel(ctx, harness) {
|
|
|
1339
1339
|
function buildPlan3(ctx) {
|
|
1340
1340
|
const firstModel = requireFirstModel(ctx, "claude-code");
|
|
1341
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;
|
|
1342
1345
|
return {
|
|
1343
1346
|
fileWrites: [],
|
|
1344
1347
|
exports: [
|
|
@@ -1354,6 +1357,10 @@ function buildPlan3(ctx) {
|
|
|
1354
1357
|
// 009h).
|
|
1355
1358
|
{ name: "ANTHROPIC_AUTH_TOKEN", value: `$${ctx.keyEnvVar}` },
|
|
1356
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) }] : [],
|
|
1357
1364
|
// Pins Claude Code's background (Haiku-class) model — titles, summaries,
|
|
1358
1365
|
// compaction, the auxiliary classifier — so those requests route through
|
|
1359
1366
|
// LunaRoute instead of 404'ing against Anthropic's hardcoded Haiku id,
|
|
@@ -1395,6 +1402,9 @@ function buildPlan3(ctx) {
|
|
|
1395
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."
|
|
1396
1403
|
] : [],
|
|
1397
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
|
+
] : [],
|
|
1398
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.",
|
|
1399
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.",
|
|
1400
1410
|
"(Auth travels in the Authorization: Bearer header via ANTHROPIC_AUTH_TOKEN.)",
|
|
@@ -3308,6 +3318,8 @@ async function runSkillInstall(profile, opts) {
|
|
|
3308
3318
|
|
|
3309
3319
|
// src/run/adapters/claudeCode.ts
|
|
3310
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;
|
|
3311
3323
|
return {
|
|
3312
3324
|
command: "claude",
|
|
3313
3325
|
args: [],
|
|
@@ -3315,6 +3327,8 @@ function buildRunSpec(ctx) {
|
|
|
3315
3327
|
ANTHROPIC_BASE_URL: ctx.routingUrl,
|
|
3316
3328
|
ANTHROPIC_AUTH_TOKEN: ctx.apiKey,
|
|
3317
3329
|
ANTHROPIC_MODEL: ctx.model,
|
|
3330
|
+
...windowTokens ? { CLAUDE_CODE_MAX_CONTEXT_TOKENS: String(windowTokens) } : {},
|
|
3331
|
+
...outputTokens ? { CLAUDE_CODE_MAX_OUTPUT_TOKENS: String(outputTokens) } : {},
|
|
3318
3332
|
// Pins the Haiku/background model so Claude Code's background tasks
|
|
3319
3333
|
// (titles, summaries, compaction) route through LunaRoute instead of
|
|
3320
3334
|
// 404'ing against Anthropic's hardcoded Haiku id. Mirrors the Connect tab
|
|
@@ -3510,6 +3524,7 @@ var ADAPTERS2 = {
|
|
|
3510
3524
|
agy: buildRunSpec4
|
|
3511
3525
|
};
|
|
3512
3526
|
var MODEL_LOOKUP_TIMEOUT_MS = 3e3;
|
|
3527
|
+
var WANTS_MODEL_ROW = /* @__PURE__ */ new Set(["codex", "claude", "claude-code"]);
|
|
3513
3528
|
var INSTALL_HINT = {
|
|
3514
3529
|
claude: "Install Claude Code: https://docs.anthropic.com/claude-code/install",
|
|
3515
3530
|
"claude-code": "Install Claude Code: https://docs.anthropic.com/claude-code/install",
|
|
@@ -3551,7 +3566,7 @@ async function runRun(harness, opts, deps = realDeps) {
|
|
|
3551
3566
|
return 1;
|
|
3552
3567
|
}
|
|
3553
3568
|
console.error(`# using model ${model} (pass --model to change)`);
|
|
3554
|
-
} else if (usesModel && harness
|
|
3569
|
+
} else if (usesModel && WANTS_MODEL_ROW.has(harness)) {
|
|
3555
3570
|
try {
|
|
3556
3571
|
models = await deps.fetchModels(creds.routing_url, creds.routing_key, {
|
|
3557
3572
|
signal: AbortSignal.timeout(MODEL_LOOKUP_TIMEOUT_MS)
|
|
@@ -3560,12 +3575,13 @@ async function runRun(harness, opts, deps = realDeps) {
|
|
|
3560
3575
|
models = [];
|
|
3561
3576
|
}
|
|
3562
3577
|
}
|
|
3563
|
-
const
|
|
3578
|
+
const row = models.find((m) => m.id === model);
|
|
3564
3579
|
const spec = adapter({
|
|
3565
3580
|
routingUrl: creds.routing_url,
|
|
3566
3581
|
apiKey: creds.routing_key,
|
|
3567
3582
|
model,
|
|
3568
|
-
contextWindow
|
|
3583
|
+
contextWindow: row?.context_window_tokens,
|
|
3584
|
+
maxOutputTokens: row?.max_output_tokens
|
|
3569
3585
|
});
|
|
3570
3586
|
if (spec.notice) console.error(spec.notice);
|
|
3571
3587
|
const args = spec.args.concat(opts.passthrough ?? []);
|