github-router 0.3.26 → 0.3.27
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/main.js +53 -2
- package/dist/main.js.map +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -994,6 +994,9 @@ function normalizeModelId(id) {
|
|
|
994
994
|
* Resolve a model name to the best available variant in the Copilot model list.
|
|
995
995
|
*
|
|
996
996
|
* Resolution cascade:
|
|
997
|
+
* 0. `[1m]` literal-bracket suffix: strip, delegate, warn if downgraded.
|
|
998
|
+
* Bracketed slug must never reach Copilot (400s on it). See cc-backup
|
|
999
|
+
* `src/utils/context.ts:35-40` for Claude Code's 1M unlock mechanism.
|
|
997
1000
|
* 1. Exact match
|
|
998
1001
|
* 2. Case-insensitive match
|
|
999
1002
|
* 3. Family preference (opus→1m, codex→highest version)
|
|
@@ -1007,6 +1010,13 @@ function normalizeModelId(id) {
|
|
|
1007
1010
|
function resolveModel(modelId) {
|
|
1008
1011
|
const models = state.models?.data;
|
|
1009
1012
|
if (!models) return modelId;
|
|
1013
|
+
const oneMMatch = modelId.match(/^(.*)\[1m\]$/i);
|
|
1014
|
+
if (oneMMatch) {
|
|
1015
|
+
const stripped = oneMMatch[1];
|
|
1016
|
+
const resolved = resolveModel(stripped);
|
|
1017
|
+
if (!/-1m(?:$|-)/.test(resolved)) consola.warn(`Model "${modelId}" requested 1M context but no -1m backend is in Copilot's catalog for this tier/family; downgrading upstream to "${resolved}" (200K). Claude Code's local context accounting will still assume 1M — expect premature auto-compact. Drop the [1m] suffix (or unset CLAUDE_CODE_DISABLE_1M_CONTEXT if you set it) to silence.`);
|
|
1018
|
+
return resolved;
|
|
1019
|
+
}
|
|
1010
1020
|
if (models.some((m) => m.id === modelId)) return modelId;
|
|
1011
1021
|
const lower = modelId.toLowerCase();
|
|
1012
1022
|
const ciMatch = models.find((m) => m.id.toLowerCase() === lower);
|
|
@@ -1501,6 +1511,44 @@ const DEFAULT_PORT = 8787;
|
|
|
1501
1511
|
const DEFAULT_CLAUDE_MODEL = "claude-opus-4-7";
|
|
1502
1512
|
const DEFAULT_CLAUDE_MODEL_FALLBACKS = ["claude-opus-4-6", "claude-opus-4-5"];
|
|
1503
1513
|
/**
|
|
1514
|
+
* Cap-aware default picker for `ANTHROPIC_MODEL` on the implicit-default
|
|
1515
|
+
* path. Returns `claude-opus-4-7[1m]` when the live Copilot catalog
|
|
1516
|
+
* contains a `*-opus-4.7-1m*` variant (enterprise tier), else
|
|
1517
|
+
* `DEFAULT_CLAUDE_MODEL` (the bare slug).
|
|
1518
|
+
*
|
|
1519
|
+
* The `[1m]` literal-bracket suffix is Claude Code's local 1M-context
|
|
1520
|
+
* unlock — cc-backup `src/utils/context.ts:35-40` matches `/\[1m\]/i`
|
|
1521
|
+
* to flip the context window from 200K to 1M, which drives compaction
|
|
1522
|
+
* triggers, the status-line context %, and token budgets. Without the
|
|
1523
|
+
* bracket Claude Code accounts against 200K regardless of how the
|
|
1524
|
+
* proxy routes the underlying request.
|
|
1525
|
+
*
|
|
1526
|
+
* Cap-awareness matters because on non-enterprise Copilot tiers there
|
|
1527
|
+
* is no `-1m` opus backend; sending `[1m]` there would either 400 at
|
|
1528
|
+
* Copilot or (with `resolveModel`'s graceful-degrade) silently
|
|
1529
|
+
* downgrade upstream while Claude Code still over-accounts context.
|
|
1530
|
+
* This helper detects the catalog state at launch and only opts in
|
|
1531
|
+
* when the backend can actually serve 1M.
|
|
1532
|
+
*
|
|
1533
|
+
* Sonnet/Haiku families are intentionally NOT given `[1m]` defaults
|
|
1534
|
+
* because Copilot has no `-1m` backend for them (and Anthropic-side
|
|
1535
|
+
* `modelSupports1M` doesn't list haiku at all). See
|
|
1536
|
+
* `src/lib/server-setup.ts:getClaudeCodeEnvVars` for the
|
|
1537
|
+
* `ANTHROPIC_DEFAULT_{SONNET,HAIKU,OPUS}_MODEL` tier defaults.
|
|
1538
|
+
*
|
|
1539
|
+
* Must be called AFTER `cacheModels()` has populated `state.models`.
|
|
1540
|
+
* Returns the bare slug if the catalog isn't populated (resolveModel
|
|
1541
|
+
* can't tell the difference between "no catalog yet" and "no 1M
|
|
1542
|
+
* variant" — defaulting safe-side preserves the pre-change behavior).
|
|
1543
|
+
*/
|
|
1544
|
+
function pickClaudeDefault() {
|
|
1545
|
+
if (state.models?.data.some((m) => /opus-4[.-]7-1m(?:$|-)/i.test(m.id)) ?? false) {
|
|
1546
|
+
consola.info(`Catalog contains opus-4.7-1m variant; defaulting ANTHROPIC_MODEL to "${DEFAULT_CLAUDE_MODEL}[1m]" so Claude Code accounts for 1M context locally. Set CLAUDE_CODE_DISABLE_1M_CONTEXT=1 to opt out (HIPAA), or pass --model ${DEFAULT_CLAUDE_MODEL} to pin 200K.`);
|
|
1547
|
+
return `${DEFAULT_CLAUDE_MODEL}[1m]`;
|
|
1548
|
+
}
|
|
1549
|
+
return DEFAULT_CLAUDE_MODEL;
|
|
1550
|
+
}
|
|
1551
|
+
/**
|
|
1504
1552
|
* Default model for `github-router codex`. `gpt-5.5` is the new flagship
|
|
1505
1553
|
* `/responses` model; the fallback chain handles older Copilot tiers where
|
|
1506
1554
|
* 5.5 hasn't rolled out yet. `resolveCodexModel` provides a final
|
|
@@ -2866,7 +2914,7 @@ function initProxyFromEnv() {
|
|
|
2866
2914
|
//#endregion
|
|
2867
2915
|
//#region package.json
|
|
2868
2916
|
var name = "github-router";
|
|
2869
|
-
var version = "0.3.
|
|
2917
|
+
var version = "0.3.27";
|
|
2870
2918
|
|
|
2871
2919
|
//#endregion
|
|
2872
2920
|
//#region src/lib/approval.ts
|
|
@@ -6561,6 +6609,9 @@ function getClaudeCodeEnvVars(serverUrl, model) {
|
|
|
6561
6609
|
};
|
|
6562
6610
|
if (model) vars.ANTHROPIC_MODEL = model;
|
|
6563
6611
|
if (process.env.ANTHROPIC_SMALL_FAST_MODEL === void 0) vars.ANTHROPIC_SMALL_FAST_MODEL = "claude-haiku-4-5";
|
|
6612
|
+
if (process.env.ANTHROPIC_DEFAULT_SONNET_MODEL === void 0) vars.ANTHROPIC_DEFAULT_SONNET_MODEL = "claude-sonnet-4-6";
|
|
6613
|
+
if (process.env.ANTHROPIC_DEFAULT_HAIKU_MODEL === void 0) vars.ANTHROPIC_DEFAULT_HAIKU_MODEL = "claude-haiku-4-5";
|
|
6614
|
+
if (process.env.ANTHROPIC_DEFAULT_OPUS_MODEL === void 0) vars.ANTHROPIC_DEFAULT_OPUS_MODEL = "claude-opus-4-7";
|
|
6564
6615
|
for (const key of [
|
|
6565
6616
|
"CLAUDE_CODE_ENABLE_EXPERIMENTAL_ADVISOR_TOOL",
|
|
6566
6617
|
"CLAUDE_CODE_FORK_SUBAGENT",
|
|
@@ -6681,7 +6732,7 @@ const claude = defineCommand({
|
|
|
6681
6732
|
}
|
|
6682
6733
|
enableFileLogging();
|
|
6683
6734
|
const usingDefault = !args.model;
|
|
6684
|
-
let chosenSlug = args.model ??
|
|
6735
|
+
let chosenSlug = args.model ?? pickClaudeDefault();
|
|
6685
6736
|
let resolvedSlug = resolveModel(chosenSlug);
|
|
6686
6737
|
if (usingDefault && state.models) {
|
|
6687
6738
|
const inCache = (slug) => state.models?.data.some((m) => m.id === resolveModel(slug)) ?? false;
|