@blockrun/franklin 3.34.3 → 3.35.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/agent/context.js +7 -3
- package/dist/agent/llm.js +15 -2
- package/dist/agent/optimize.js +4 -0
- package/dist/agent/tokens.js +3 -0
- package/dist/hooks/runner.js +9 -8
- package/dist/pricing.js +2 -0
- package/dist/ui/app.js +33 -18
- package/dist/ui/model-picker.d.ts +6 -5
- package/dist/ui/model-picker.js +219 -11
- package/package.json +1 -1
package/dist/agent/context.js
CHANGED
|
@@ -534,9 +534,12 @@ export function getModelGuidance(model) {
|
|
|
534
534
|
- Keep responses under 300 words. Be direct, not verbose.
|
|
535
535
|
- Before responding: does every URL and fact come from a tool result? If not, remove it.`;
|
|
536
536
|
}
|
|
537
|
-
// Medium models: balanced guidance
|
|
537
|
+
// Medium models: balanced guidance. The bare `qwen` match dates from when
|
|
538
|
+
// every qwen id on the gateway was a free NVIDIA SKU — qwen3.7-max is a paid
|
|
539
|
+
// 1M-context flagship and belongs in the strong branch below.
|
|
538
540
|
if (m.includes('kimi') || m.includes('grok') || m.includes('flash') ||
|
|
539
|
-
m.includes('haiku') || m.includes('deepseek') ||
|
|
541
|
+
m.includes('haiku') || m.includes('deepseek') ||
|
|
542
|
+
(m.includes('qwen') && !m.includes('qwen3.7-max'))) {
|
|
540
543
|
return `# Execution Guidance
|
|
541
544
|
- Use tools to verify facts before stating them. Do not answer from memory when a tool can confirm.
|
|
542
545
|
- Batch independent tool calls in one response (parallel execution).
|
|
@@ -546,7 +549,8 @@ export function getModelGuidance(model) {
|
|
|
546
549
|
// Strong models: quality standards + thinking guidance
|
|
547
550
|
if (m.includes('claude') || m.includes('gpt-5') || m.includes('opus') ||
|
|
548
551
|
m.includes('sonnet') || m.includes('gemini-2.5-pro') || m.includes('gemini-3') ||
|
|
549
|
-
m.includes('o3') || m.includes('o1') || m.includes('codex')
|
|
552
|
+
m.includes('o3') || m.includes('o1') || m.includes('codex') ||
|
|
553
|
+
m.includes('qwen3.7-max')) {
|
|
550
554
|
return `# Quality Standards (strong model)
|
|
551
555
|
- Keep calling tools until the task is complete AND the result is verified. Don't stop at "this should work" — prove it works.
|
|
552
556
|
- Before finalizing: check correctness, grounding in tool output, and formatting.
|
package/dist/agent/llm.js
CHANGED
|
@@ -19,6 +19,10 @@ const MODELS_WITHOUT_TOOL_CHOICE_SUBSTR = [
|
|
|
19
19
|
'deepseek-reasoner',
|
|
20
20
|
'openai/o1',
|
|
21
21
|
'openai/o3',
|
|
22
|
+
// Qwen3.7 Max — plain tool use works, but any `tool_choice` on the payload
|
|
23
|
+
// 400s ("Invalid request: 400 Provider returned error"). Caught 2026-07-20
|
|
24
|
+
// by the grounding-retry path, which is the only place we force tool use.
|
|
25
|
+
'qwen3.7-max',
|
|
22
26
|
];
|
|
23
27
|
function modelDoesNotSupportToolChoice(model) {
|
|
24
28
|
if (!model)
|
|
@@ -678,10 +682,19 @@ export class ModelClient {
|
|
|
678
682
|
// know that. Catch the error, drop tool_choice, re-fire once.
|
|
679
683
|
// No payment re-sign needed — original 402 already settled, and
|
|
680
684
|
// the gateway treats this as the same logical request.
|
|
685
|
+
// Second shape, verified 2026-07-20 on qwen/qwen3.7-max: the gateway
|
|
686
|
+
// returns an OPAQUE `400 Invalid request: 400 Provider returned error`
|
|
687
|
+
// that never names tool_choice, so the precise match below can't fire
|
|
688
|
+
// and the user just sees "Tool schema rejected by this model". Since
|
|
689
|
+
// the request has already failed, dropping tool_choice and re-firing
|
|
690
|
+
// once costs nothing on the happy path and self-heals the whole class
|
|
691
|
+
// for models we haven't catalogued yet. If tool_choice wasn't the
|
|
692
|
+
// cause, the retry 400s again and the original error still surfaces.
|
|
681
693
|
const lc = message.toLowerCase();
|
|
682
694
|
const looksLikeToolChoiceReject = response.status === 400 &&
|
|
683
|
-
lc.includes('tool_choice') &&
|
|
684
|
-
|
|
695
|
+
((lc.includes('tool_choice') &&
|
|
696
|
+
(lc.includes('not support') || lc.includes('unsupported') || lc.includes('does not support'))) ||
|
|
697
|
+
requestPayload['tool_choice'] !== undefined);
|
|
685
698
|
if (looksLikeToolChoiceReject && requestPayload['tool_choice'] !== undefined) {
|
|
686
699
|
delete requestPayload['tool_choice'];
|
|
687
700
|
const retryBody = JSON.stringify(requestPayload);
|
package/dist/agent/optimize.js
CHANGED
|
@@ -57,6 +57,10 @@ const MODEL_MAX_OUTPUT = {
|
|
|
57
57
|
'moonshot/kimi-k3': 65_536,
|
|
58
58
|
'moonshot/kimi-k2.7': 65_536,
|
|
59
59
|
'moonshot/kimi-k2.6': 65_536,
|
|
60
|
+
// Qwen3.7 Max — gateway model entry reports max_output: 65536. Same 4×
|
|
61
|
+
// headroom the K3 entry above recovers; without it the paid model gets the
|
|
62
|
+
// 16K default and truncates mid-answer, burning USDC on continuation calls.
|
|
63
|
+
'qwen/qwen3.7-max': 65_536,
|
|
60
64
|
};
|
|
61
65
|
/** Get max output tokens for a model */
|
|
62
66
|
export function getMaxOutputTokens(model) {
|
package/dist/agent/tokens.js
CHANGED
|
@@ -266,6 +266,9 @@ const MODEL_CONTEXT_WINDOWS = {
|
|
|
266
266
|
'nvidia/nemotron-nano-12b-v2-vl': 131_072,
|
|
267
267
|
'nvidia/llama-4-maverick': 131_072,
|
|
268
268
|
'nvidia/mistral-large-3-675b': 131_072,
|
|
269
|
+
// Qwen (paid) — Max tier is 1M ctx; the generic `qwen` fallback below is
|
|
270
|
+
// 128k and would compact ~8x too early.
|
|
271
|
+
'qwen/qwen3.7-max': 1_000_000,
|
|
269
272
|
};
|
|
270
273
|
/**
|
|
271
274
|
* Get the context window size for a model, with a conservative default.
|
package/dist/hooks/runner.js
CHANGED
|
@@ -112,14 +112,15 @@ export class HookEngine {
|
|
|
112
112
|
logger.warn(`[hooks] ${path.basename(hook.sourceFile)} ${input.hookEventName} handler failed open: ${err.message.slice(0, 160)}`);
|
|
113
113
|
resolve({ decision: 'allow' });
|
|
114
114
|
});
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
115
|
+
child.stdin?.on('error', err => {
|
|
116
|
+
// EPIPE from a handler that exits before reading stdin is fine; the
|
|
117
|
+
// decision still comes from exit code / stdout.
|
|
118
|
+
if (err.code !== 'EPIPE') {
|
|
119
|
+
logger.warn(`[hooks] ${path.basename(hook.sourceFile)} stdin write failed open: ${err.message.slice(0, 160)}`);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
child.stdin?.write(JSON.stringify(input));
|
|
123
|
+
child.stdin?.end();
|
|
123
124
|
});
|
|
124
125
|
}
|
|
125
126
|
}
|
package/dist/pricing.js
CHANGED
|
@@ -105,6 +105,8 @@ export const MODEL_PRICING = {
|
|
|
105
105
|
'minimax/minimax-m3': { input: 0.3, output: 1.2 },
|
|
106
106
|
'minimax/minimax-m2.7': { input: 0.3, output: 1.2 },
|
|
107
107
|
'minimax/minimax-m2.5': { input: 0.3, output: 1.2 },
|
|
108
|
+
// Qwen
|
|
109
|
+
'qwen/qwen3.7-max': { input: 1.475, output: 4.425 },
|
|
108
110
|
// Moonshot — K3 is the gateway flagship (2026-07): 2.8T open MoE, 1M
|
|
109
111
|
// context, multimodal (image+text), returns reasoning_content. Pricier
|
|
110
112
|
// than the K2.x line it replaced ($3/$15 vs K2.7's $0.95/$4).
|
package/dist/ui/app.js
CHANGED
|
@@ -14,7 +14,7 @@ import Spinner from 'ink-spinner';
|
|
|
14
14
|
import TextInput from 'ink-text-input';
|
|
15
15
|
import VimInput from './vim-input.js';
|
|
16
16
|
import { renderMarkdown, renderMarkdownStreaming } from './markdown.js';
|
|
17
|
-
import { resolveModel, getPickerCategories, PICKER_CATEGORIES, PICKER_MODELS_FLAT, } from './model-picker.js';
|
|
17
|
+
import { resolveModel, getPickerCategories, getExpandedPickerCategories, PICKER_CATEGORIES, PICKER_MODELS_FLAT, } from './model-picker.js';
|
|
18
18
|
import { estimateCost } from '../pricing.js';
|
|
19
19
|
import { formatTokens, shortModelName } from '../stats/format.js';
|
|
20
20
|
import { mouse, forceDisableMouseTracking } from './mouse.js';
|
|
@@ -688,6 +688,13 @@ function formatAgentErrorForDisplay(error) {
|
|
|
688
688
|
out.push(`- Tip: ${tip}`);
|
|
689
689
|
return out.join('\n');
|
|
690
690
|
}
|
|
691
|
+
function fitPickerText(value, width) {
|
|
692
|
+
if (value.length <= width)
|
|
693
|
+
return value.padEnd(width);
|
|
694
|
+
if (width <= 1)
|
|
695
|
+
return value.slice(0, width);
|
|
696
|
+
return `${value.slice(0, width - 1)}…`;
|
|
697
|
+
}
|
|
691
698
|
function RunCodeApp({ initialModel, workDir, walletAddress, walletBalance, chain, initialTranscript, startWithPicker, onSubmit, onModelChange, onAbort, onExit, }) {
|
|
692
699
|
const { exit } = useApp();
|
|
693
700
|
// Track terminal rows so we can cap the dynamic-region height. Ink wipes the
|
|
@@ -721,6 +728,7 @@ function RunCodeApp({ initialModel, workDir, walletAddress, walletBalance, chain
|
|
|
721
728
|
// replaced by the hydrated list once the catalog fetch lands.
|
|
722
729
|
const [pickerCats, setPickerCats] = useState(PICKER_CATEGORIES);
|
|
723
730
|
const [pickerMoreCount, setPickerMoreCount] = useState(0);
|
|
731
|
+
const [pickerExpanded, setPickerExpanded] = useState(false);
|
|
724
732
|
const pickerFlat = useMemo(() => pickerCats.flatMap(c => c.models), [pickerCats]);
|
|
725
733
|
// Track the live model without re-firing the hydration effect on every model
|
|
726
734
|
// change — the effect should run when the picker opens, not when the model
|
|
@@ -774,7 +782,7 @@ function RunCodeApp({ initialModel, workDir, walletAddress, walletBalance, chain
|
|
|
774
782
|
if (mode !== 'model-picker')
|
|
775
783
|
return;
|
|
776
784
|
let cancelled = false;
|
|
777
|
-
void getPickerCategories()
|
|
785
|
+
void (pickerExpanded ? getExpandedPickerCategories() : getPickerCategories())
|
|
778
786
|
.then(({ categories, moreCount, live }) => {
|
|
779
787
|
if (cancelled || !live)
|
|
780
788
|
return;
|
|
@@ -789,7 +797,7 @@ function RunCodeApp({ initialModel, workDir, walletAddress, walletBalance, chain
|
|
|
789
797
|
})
|
|
790
798
|
.catch(() => { });
|
|
791
799
|
return () => { cancelled = true; };
|
|
792
|
-
}, [mode]);
|
|
800
|
+
}, [mode, pickerExpanded]);
|
|
793
801
|
const bellPlayedRef = useRef(false);
|
|
794
802
|
useEffect(() => {
|
|
795
803
|
const dialogActive = !!permissionRequest || !!askUserRequest;
|
|
@@ -952,9 +960,10 @@ function RunCodeApp({ initialModel, workDir, walletAddress, walletBalance, chain
|
|
|
952
960
|
r('always');
|
|
953
961
|
}
|
|
954
962
|
}, { isActive: !!permissionRequest });
|
|
955
|
-
// Key handler for picker +
|
|
956
|
-
|
|
957
|
-
|
|
963
|
+
// Key handler for picker + abort. Esc aborts active work or closes dialogs;
|
|
964
|
+
// it must not exit the app while idle — Ctrl+C and /exit are the exit paths.
|
|
965
|
+
const isPickerOrAbort = mode === 'model-picker' || !ready;
|
|
966
|
+
useInput((ch, key) => {
|
|
958
967
|
// Escape during generation → abort current turn (skip if permission dialog open)
|
|
959
968
|
if (key.escape && !ready && !permissionRequest) {
|
|
960
969
|
onAbort();
|
|
@@ -964,17 +973,18 @@ function RunCodeApp({ initialModel, workDir, walletAddress, walletBalance, chain
|
|
|
964
973
|
setThinking(false);
|
|
965
974
|
return;
|
|
966
975
|
}
|
|
967
|
-
// Esc to quit (only when input is empty and in input mode)
|
|
968
|
-
// In Vim mode: Esc goes to normal mode (handled by VimInput), only quit on Esc in normal mode with empty input
|
|
969
|
-
if (key.escape && mode === 'input' && ready && !input) {
|
|
970
|
-
if (vimEnabled && currentVimMode === 'insert')
|
|
971
|
-
return; // Let VimInput handle Esc → normal
|
|
972
|
-
requestExit(false);
|
|
973
|
-
return;
|
|
974
|
-
}
|
|
975
976
|
// Arrow key navigation for model picker
|
|
976
977
|
if (mode !== 'model-picker')
|
|
977
978
|
return;
|
|
979
|
+
if (key.ctrl && ch === 'a') {
|
|
980
|
+
const nextExpanded = !pickerExpanded;
|
|
981
|
+
setPickerExpanded(nextExpanded);
|
|
982
|
+
if (!nextExpanded)
|
|
983
|
+
setPickerCats(PICKER_CATEGORIES);
|
|
984
|
+
setPickerMoreCount(0);
|
|
985
|
+
setPickerIdx(0);
|
|
986
|
+
return;
|
|
987
|
+
}
|
|
978
988
|
if (key.upArrow)
|
|
979
989
|
setPickerIdx(i => Math.max(0, i - 1));
|
|
980
990
|
else if (key.downArrow)
|
|
@@ -993,16 +1003,18 @@ function RunCodeApp({ initialModel, workDir, walletAddress, walletBalance, chain
|
|
|
993
1003
|
// the picker closed, which is both confusing and a privacy risk.
|
|
994
1004
|
setInput('');
|
|
995
1005
|
setHistoryIdx(-1);
|
|
1006
|
+
setPickerExpanded(false);
|
|
996
1007
|
setMode('input');
|
|
997
1008
|
setReady(true);
|
|
998
1009
|
}
|
|
999
1010
|
else if (key.escape) {
|
|
1000
1011
|
setInput('');
|
|
1001
1012
|
setHistoryIdx(-1);
|
|
1013
|
+
setPickerExpanded(false);
|
|
1002
1014
|
setMode('input');
|
|
1003
1015
|
setReady(true);
|
|
1004
1016
|
}
|
|
1005
|
-
}, { isActive:
|
|
1017
|
+
}, { isActive: isPickerOrAbort });
|
|
1006
1018
|
// Tab key: toggle expand/collapse on the last completed tool
|
|
1007
1019
|
useInput((_ch, key) => {
|
|
1008
1020
|
if (key.tab && expandableTool) {
|
|
@@ -1076,6 +1088,9 @@ function RunCodeApp({ initialModel, workDir, walletAddress, walletBalance, chain
|
|
|
1076
1088
|
// closing handlers clear input too, so both ends are covered.
|
|
1077
1089
|
setInput('');
|
|
1078
1090
|
setHistoryIdx(-1);
|
|
1091
|
+
setPickerExpanded(false);
|
|
1092
|
+
setPickerCats(PICKER_CATEGORIES);
|
|
1093
|
+
setPickerMoreCount(0);
|
|
1079
1094
|
setMode('model-picker');
|
|
1080
1095
|
}
|
|
1081
1096
|
return;
|
|
@@ -1502,7 +1517,7 @@ function RunCodeApp({ initialModel, workDir, walletAddress, walletBalance, chain
|
|
|
1502
1517
|
cursor += cat.models.length;
|
|
1503
1518
|
return base;
|
|
1504
1519
|
});
|
|
1505
|
-
return (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsxs(Box, { marginLeft: 2, children: [_jsx(Text, { bold: true, children: "Select a model " }),
|
|
1520
|
+
return (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsxs(Box, { marginLeft: 2, children: [_jsx(Text, { bold: true, children: "Select a model " }), _jsxs(Text, { dimColor: true, children: ["(\u2191\u2193 navigate, Enter select, Ctrl+A ", pickerExpanded ? 'curated' : 'all models', ", Esc cancel)"] })] }), hiddenAbove > 0 && (_jsx(Box, { marginLeft: 2, marginTop: 1, children: _jsxs(Text, { dimColor: true, children: ["\u2191 ", hiddenAbove, " more above"] }) })), pickerCats.map((cat, catIdx) => {
|
|
1506
1521
|
const base = catBases[catIdx];
|
|
1507
1522
|
const visible = cat.models
|
|
1508
1523
|
.map((m, localIdx) => ({ m, globalIdx: base + localIdx }))
|
|
@@ -1513,9 +1528,9 @@ function RunCodeApp({ initialModel, workDir, walletAddress, walletBalance, chain
|
|
|
1513
1528
|
const isSelected = globalIdx === pickerIdx;
|
|
1514
1529
|
const isCurrent = m.id === currentModel;
|
|
1515
1530
|
const isHighlight = m.highlight === true;
|
|
1516
|
-
return (_jsxs(Box, { marginLeft: 2, children: [_jsxs(Text, { inverse: isSelected, color: isSelected ? 'cyan' : isHighlight ? 'yellow' : undefined, bold: isSelected || isHighlight, children: [' ', m.label
|
|
1531
|
+
return (_jsxs(Box, { marginLeft: 2, children: [_jsxs(Text, { inverse: isSelected, color: isSelected ? 'cyan' : isHighlight ? 'yellow' : undefined, bold: isSelected || isHighlight, children: [' ', fitPickerText(m.label, 26), ' '] }), _jsxs(Text, { dimColor: true, children: [" ", fitPickerText(m.shortcut, 14)] }), _jsx(Text, { color: m.price === 'FREE' ? 'green' : isHighlight ? 'yellow' : undefined, dimColor: !isHighlight && m.price !== 'FREE', children: m.price }), isCurrent && _jsx(Text, { color: "green", children: " \u2190" })] }, m.id));
|
|
1517
1532
|
})] }, cat.category));
|
|
1518
|
-
}), hiddenBelow > 0 && (_jsx(Box, { marginLeft: 2, marginTop: 1, children: _jsxs(Text, { dimColor: true, children: ["\u2193 ", hiddenBelow, " more below"] }) })), pickerMoreCount > 0 && (_jsx(Box, { marginTop: 1, marginLeft: 2, children: _jsxs(Text, { dimColor: true, children: ["+ ", pickerMoreCount, " more on gateway \u2014
|
|
1533
|
+
}), hiddenBelow > 0 && (_jsx(Box, { marginLeft: 2, marginTop: 1, children: _jsxs(Text, { dimColor: true, children: ["\u2193 ", hiddenBelow, " more below"] }) })), pickerMoreCount > 0 && (_jsx(Box, { marginTop: 1, marginLeft: 2, children: _jsxs(Text, { dimColor: true, children: ["+ ", pickerMoreCount, " more on gateway \u2014 Ctrl+A to show all, or /model <id> to pick one"] }) })), _jsx(Box, { marginTop: 1, marginLeft: 2, children: _jsx(Text, { dimColor: true, children: "Your conversation stays above \u2014 picking a model keeps all history intact." }) })] }));
|
|
1519
1534
|
})(), !inPicker && !permissionRequest && !askUserRequest && (_jsx(InputBox, { input: input, setInput: setInput, onSubmit: handleSubmit, model: currentModel, balance: liveBalance, chain: chain, walletTail: walletAddress && walletAddress.length >= 4 && !walletAddress.startsWith('not set') ? walletAddress.slice(-4) : undefined, sessionCost: totalCost, queued: queuedInputs[0] || undefined, queuedCount: queuedInputs.length, focused: !permissionRequest && !askUserRequest, busy: !askUserRequest && (waiting || thinking || tools.size > 0), awaitingApproval: !!permissionRequest, awaitingAnswer: !!askUserRequest, contextPct: contextPct, vimMode: vimEnabled, onVimModeChange: setCurrentVimMode }))] }));
|
|
1520
1535
|
}
|
|
1521
1536
|
export function launchInkUI(opts) {
|
|
@@ -69,13 +69,12 @@ export interface HydratedPicker {
|
|
|
69
69
|
* {@link PICKER_CATEGORIES} stays the editorial layer — which models are worth
|
|
70
70
|
* featuring, in what order, under which heading, with which shortcut. The
|
|
71
71
|
* gateway is the source of truth for everything factual: whether a model still
|
|
72
|
-
* exists
|
|
73
|
-
*
|
|
74
|
-
* v3.9.3 trim), so we can't just render the catalog.
|
|
72
|
+
* exists and its price. Ctrl+A uses {@link getExpandedPickerCategories} when the
|
|
73
|
+
* user explicitly wants the full gateway chat catalog.
|
|
75
74
|
*
|
|
76
75
|
* Reconciliation rules:
|
|
77
|
-
* - Curated row present in the catalog →
|
|
78
|
-
*
|
|
76
|
+
* - Curated row present in the catalog → keep its label/shortcut/highlight and
|
|
77
|
+
* refresh its price from the gateway.
|
|
79
78
|
* - Curated row absent → drop it. This is the self-healing half: an id the
|
|
80
79
|
* gateway retired (the `claude-haiku-4.5-20251001` case) stops being
|
|
81
80
|
* offered without waiting on a Franklin release. Its MODEL_SHORTCUTS alias
|
|
@@ -95,6 +94,8 @@ export declare function getPickerCategories(): Promise<HydratedPicker>;
|
|
|
95
94
|
* rules can be tested against a synthetic catalog without touching the network.
|
|
96
95
|
*/
|
|
97
96
|
export declare function reconcilePicker(catalog: GatewayModel[]): HydratedPicker;
|
|
97
|
+
export declare function getExpandedPickerCategories(): Promise<HydratedPicker>;
|
|
98
|
+
export declare function reconcileExpandedPicker(catalog: GatewayModel[]): HydratedPicker;
|
|
98
99
|
/**
|
|
99
100
|
* Show interactive model picker. Returns the selected model ID.
|
|
100
101
|
* Falls back to text input if terminal doesn't support raw mode.
|
package/dist/ui/model-picker.js
CHANGED
|
@@ -16,12 +16,11 @@ export const MODEL_SHORTCUTS = {
|
|
|
16
16
|
smart: 'blockrun/auto',
|
|
17
17
|
eco: 'blockrun/auto',
|
|
18
18
|
premium: 'blockrun/auto',
|
|
19
|
-
// Anthropic — `
|
|
20
|
-
// Mythos-class tier above Opus.
|
|
19
|
+
// Anthropic — `claude` follows Opus; `fable` is the Mythos-class tier above it.
|
|
21
20
|
fable: 'anthropic/claude-fable-5',
|
|
22
21
|
'fable-5': 'anthropic/claude-fable-5',
|
|
23
22
|
sonnet: 'anthropic/claude-sonnet-5',
|
|
24
|
-
claude: 'anthropic/claude-
|
|
23
|
+
claude: 'anthropic/claude-opus-4.8',
|
|
25
24
|
'sonnet-5': 'anthropic/claude-sonnet-5',
|
|
26
25
|
'sonnet-4.6': 'anthropic/claude-sonnet-4.6',
|
|
27
26
|
'sonnet-4.5': 'anthropic/claude-sonnet-4.5',
|
|
@@ -133,6 +132,11 @@ export const MODEL_SHORTCUTS = {
|
|
|
133
132
|
minimax: 'minimax/minimax-m3',
|
|
134
133
|
'm3': 'minimax/minimax-m3',
|
|
135
134
|
'm2.7': 'minimax/minimax-m2.7',
|
|
135
|
+
// Qwen (paid). NOTE: bare `qwen` stays pinned to the FREE nvidia default
|
|
136
|
+
// above — never repoint a free alias at a paid model.
|
|
137
|
+
'qwen-max': 'qwen/qwen3.7-max',
|
|
138
|
+
'qwen3.7-max': 'qwen/qwen3.7-max',
|
|
139
|
+
'qwen-3.7-max': 'qwen/qwen3.7-max',
|
|
136
140
|
glm: 'zai/glm-5.2',
|
|
137
141
|
'glm-5': 'zai/glm-5',
|
|
138
142
|
'glm-5.2': 'zai/glm-5.2',
|
|
@@ -198,6 +202,30 @@ export function resolveModelStrict(input) {
|
|
|
198
202
|
`or a full id like anthropic/claude-sonnet-4.6.`,
|
|
199
203
|
};
|
|
200
204
|
}
|
|
205
|
+
const PROVIDER_ORDER = [
|
|
206
|
+
'anthropic',
|
|
207
|
+
'openai',
|
|
208
|
+
'google',
|
|
209
|
+
'xai',
|
|
210
|
+
'zai',
|
|
211
|
+
'moonshot',
|
|
212
|
+
'minimax',
|
|
213
|
+
'qwen',
|
|
214
|
+
'deepseek',
|
|
215
|
+
'nvidia',
|
|
216
|
+
];
|
|
217
|
+
const PROVIDER_LABELS = {
|
|
218
|
+
anthropic: 'Anthropic / Claude',
|
|
219
|
+
openai: 'OpenAI / GPT',
|
|
220
|
+
google: 'Google / Gemini',
|
|
221
|
+
xai: 'xAI / Grok',
|
|
222
|
+
zai: 'Z.AI / GLM',
|
|
223
|
+
moonshot: 'Moonshot / Kimi',
|
|
224
|
+
minimax: 'MiniMax',
|
|
225
|
+
qwen: 'Qwen / Alibaba',
|
|
226
|
+
deepseek: 'DeepSeek',
|
|
227
|
+
nvidia: 'Free / NVIDIA',
|
|
228
|
+
};
|
|
201
229
|
/**
|
|
202
230
|
* Single source of truth for the /model picker.
|
|
203
231
|
* ~30 models across 6 categories. Every ID here is present in src/pricing.ts
|
|
@@ -233,6 +261,7 @@ export const PICKER_CATEGORIES = [
|
|
|
233
261
|
{ id: 'anthropic/claude-fable-5', shortcut: 'fable', label: 'Claude Fable 5', price: '$10/$50' },
|
|
234
262
|
{ id: 'anthropic/claude-opus-4.8', shortcut: 'opus', label: 'Claude Opus 4.8', price: '$5/$25', highlight: true },
|
|
235
263
|
{ id: 'anthropic/claude-sonnet-5', shortcut: 'sonnet', label: 'Claude Sonnet 5', price: '$3/$15' },
|
|
264
|
+
{ id: 'qwen/qwen3.7-max', shortcut: 'qwen-max', label: 'Qwen3.7 Max', price: '$1.475/$4.425', highlight: true },
|
|
236
265
|
{ id: 'openai/gpt-5.6-sol', shortcut: 'gpt', label: 'GPT-5.6 Sol', price: '$5/$30', highlight: true },
|
|
237
266
|
{ id: 'google/gemini-3.1-pro', shortcut: 'gemini-3', label: 'Gemini 3.1 Pro', price: '$2/$12' },
|
|
238
267
|
{ id: 'google/gemini-2.5-pro', shortcut: 'gemini', label: 'Gemini 2.5 Pro', price: '$1.25/$10' },
|
|
@@ -306,6 +335,130 @@ export const PICKER_MODELS_FLAT = PICKER_CATEGORIES.flatMap(c => c.models);
|
|
|
306
335
|
function isSyntheticId(id) {
|
|
307
336
|
return id.startsWith('blockrun/');
|
|
308
337
|
}
|
|
338
|
+
function providerOf(id) {
|
|
339
|
+
return id.split('/', 1)[0] || 'other';
|
|
340
|
+
}
|
|
341
|
+
function providerRank(provider) {
|
|
342
|
+
const index = PROVIDER_ORDER.indexOf(provider);
|
|
343
|
+
return index >= 0 ? index : PROVIDER_ORDER.length;
|
|
344
|
+
}
|
|
345
|
+
function providerHeading(provider) {
|
|
346
|
+
return PROVIDER_LABELS[provider] || provider;
|
|
347
|
+
}
|
|
348
|
+
function modelSuffix(id) {
|
|
349
|
+
return id.includes('/') ? id.slice(id.indexOf('/') + 1) : id;
|
|
350
|
+
}
|
|
351
|
+
function versionScoreFrom(match) {
|
|
352
|
+
if (!match)
|
|
353
|
+
return 0;
|
|
354
|
+
const parts = match[1].split('.').map(part => Number.parseInt(part, 10) || 0);
|
|
355
|
+
return parts.slice(0, 3).reduce((score, part, index) => score + part * [1_000_000, 100_000, 1_000][index], 0);
|
|
356
|
+
}
|
|
357
|
+
function providerVersionScore(provider, suffix) {
|
|
358
|
+
switch (provider) {
|
|
359
|
+
case 'anthropic':
|
|
360
|
+
return versionScoreFrom(suffix.match(/claude-(?:fable|opus|sonnet|haiku)-(\d+(?:\.\d+)*)/));
|
|
361
|
+
case 'openai':
|
|
362
|
+
if (suffix.startsWith('gpt-4o'))
|
|
363
|
+
return versionScoreFrom(['', '4.0']);
|
|
364
|
+
return versionScoreFrom(suffix.match(/(?:gpt-|o)(\d+(?:\.\d+)*)/));
|
|
365
|
+
case 'google':
|
|
366
|
+
return versionScoreFrom(suffix.match(/gemini-(\d+(?:\.\d+)*)/));
|
|
367
|
+
case 'xai':
|
|
368
|
+
return versionScoreFrom(suffix.match(/grok-(\d+(?:\.\d+)*)/));
|
|
369
|
+
case 'zai':
|
|
370
|
+
return versionScoreFrom(suffix.match(/glm-(\d+(?:\.\d+)*)/));
|
|
371
|
+
case 'moonshot':
|
|
372
|
+
return versionScoreFrom(suffix.match(/kimi-k(\d+(?:\.\d+)*)/));
|
|
373
|
+
case 'minimax':
|
|
374
|
+
return versionScoreFrom(suffix.match(/minimax-m(\d+(?:\.\d+)*)/));
|
|
375
|
+
case 'deepseek':
|
|
376
|
+
return versionScoreFrom(suffix.match(/deepseek-v(\d+(?:\.\d+)*)/));
|
|
377
|
+
case 'nvidia':
|
|
378
|
+
return versionScoreFrom(suffix.match(/deepseek-v(\d+(?:\.\d+)*)/) ??
|
|
379
|
+
suffix.match(/qwen(\d+(?:\.\d+)*)/) ??
|
|
380
|
+
suffix.match(/step-(\d+(?:\.\d+)*)/) ??
|
|
381
|
+
suffix.match(/nemotron-(\d+(?:\.\d+)*)/) ??
|
|
382
|
+
suffix.match(/mistral-large-(\d+(?:\.\d+)*)/) ??
|
|
383
|
+
suffix.match(/v(\d+(?:\.\d+)*)/));
|
|
384
|
+
default:
|
|
385
|
+
return versionScoreFrom(suffix.match(/(?:^|[^\d])(\d+(?:\.\d+)*)(?:[^\d]|$)/));
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
function expandedModelRank(model) {
|
|
389
|
+
const suffix = modelSuffix(model.id).toLowerCase();
|
|
390
|
+
const provider = providerOf(model.id);
|
|
391
|
+
let score = providerVersionScore(provider, suffix);
|
|
392
|
+
switch (provider) {
|
|
393
|
+
case 'anthropic':
|
|
394
|
+
score += suffix.includes('fable') ? 90_000 : suffix.includes('opus') ? 80_000 : suffix.includes('sonnet') ? 70_000 : suffix.includes('haiku') ? 40_000 : 0;
|
|
395
|
+
break;
|
|
396
|
+
case 'openai':
|
|
397
|
+
score += suffix.startsWith('gpt-') ? 80_000 : suffix.startsWith('o') ? 65_000 : 0;
|
|
398
|
+
if (suffix.includes('codex'))
|
|
399
|
+
score += 8_000;
|
|
400
|
+
if (suffix.includes('pro') || suffix.includes('sol'))
|
|
401
|
+
score += 3_000;
|
|
402
|
+
if (suffix.includes('terra'))
|
|
403
|
+
score += 2_000;
|
|
404
|
+
if (suffix.includes('luna'))
|
|
405
|
+
score += 1_000;
|
|
406
|
+
if (suffix.includes('mini'))
|
|
407
|
+
score -= 8_000;
|
|
408
|
+
if (suffix.includes('nano'))
|
|
409
|
+
score -= 12_000;
|
|
410
|
+
break;
|
|
411
|
+
case 'google':
|
|
412
|
+
score += suffix.includes('gemini') ? 80_000 : 0;
|
|
413
|
+
if (suffix.includes('pro'))
|
|
414
|
+
score += 5_000;
|
|
415
|
+
if (suffix.includes('flash'))
|
|
416
|
+
score -= 5_000;
|
|
417
|
+
break;
|
|
418
|
+
case 'xai':
|
|
419
|
+
score += suffix.includes('grok') ? 80_000 : 0;
|
|
420
|
+
if (suffix.includes('fast'))
|
|
421
|
+
score -= 4_000;
|
|
422
|
+
if (suffix.includes('build'))
|
|
423
|
+
score -= 8_000;
|
|
424
|
+
break;
|
|
425
|
+
case 'zai':
|
|
426
|
+
score += suffix.includes('glm') ? 80_000 : 0;
|
|
427
|
+
if (suffix.includes('turbo'))
|
|
428
|
+
score -= 5_000;
|
|
429
|
+
break;
|
|
430
|
+
case 'moonshot':
|
|
431
|
+
score += suffix.includes('kimi') ? 80_000 : 0;
|
|
432
|
+
break;
|
|
433
|
+
case 'minimax':
|
|
434
|
+
score += suffix.includes('minimax') ? 80_000 : 0;
|
|
435
|
+
break;
|
|
436
|
+
case 'deepseek':
|
|
437
|
+
score += suffix.includes('v4-pro') ? 90_000 : suffix.includes('reasoner') ? 75_000 : suffix.includes('chat') ? 70_000 : 0;
|
|
438
|
+
break;
|
|
439
|
+
case 'nvidia':
|
|
440
|
+
score += suffix.includes('qwen3-next') ? 80_000 : suffix.includes('qwen') ? 70_000 : suffix.includes('nemotron') ? 60_000 : 0;
|
|
441
|
+
break;
|
|
442
|
+
}
|
|
443
|
+
return score;
|
|
444
|
+
}
|
|
445
|
+
function cleanGatewayLabel(model) {
|
|
446
|
+
return (model.name || modelSuffix(model.id))
|
|
447
|
+
.replace(/\s*\((?:free|paid)\)\s*$/i, '')
|
|
448
|
+
.trim();
|
|
449
|
+
}
|
|
450
|
+
function buildShortcutById() {
|
|
451
|
+
const preferred = new Map();
|
|
452
|
+
for (const row of PICKER_CATEGORIES.flatMap(category => category.models)) {
|
|
453
|
+
preferred.set(row.id, row.shortcut);
|
|
454
|
+
}
|
|
455
|
+
for (const [shortcut, id] of Object.entries(MODEL_SHORTCUTS)) {
|
|
456
|
+
const existing = preferred.get(id);
|
|
457
|
+
if (!existing || shortcut.length < existing.length)
|
|
458
|
+
preferred.set(id, shortcut);
|
|
459
|
+
}
|
|
460
|
+
return preferred;
|
|
461
|
+
}
|
|
309
462
|
/** Render a gateway price object into the picker's display format. */
|
|
310
463
|
function formatPrice(m) {
|
|
311
464
|
const p = m.pricing;
|
|
@@ -328,13 +481,12 @@ function formatPrice(m) {
|
|
|
328
481
|
* {@link PICKER_CATEGORIES} stays the editorial layer — which models are worth
|
|
329
482
|
* featuring, in what order, under which heading, with which shortcut. The
|
|
330
483
|
* gateway is the source of truth for everything factual: whether a model still
|
|
331
|
-
* exists
|
|
332
|
-
*
|
|
333
|
-
* v3.9.3 trim), so we can't just render the catalog.
|
|
484
|
+
* exists and its price. Ctrl+A uses {@link getExpandedPickerCategories} when the
|
|
485
|
+
* user explicitly wants the full gateway chat catalog.
|
|
334
486
|
*
|
|
335
487
|
* Reconciliation rules:
|
|
336
|
-
* - Curated row present in the catalog →
|
|
337
|
-
*
|
|
488
|
+
* - Curated row present in the catalog → keep its label/shortcut/highlight and
|
|
489
|
+
* refresh its price from the gateway.
|
|
338
490
|
* - Curated row absent → drop it. This is the self-healing half: an id the
|
|
339
491
|
* gateway retired (the `claude-haiku-4.5-20251001` case) stops being
|
|
340
492
|
* offered without waiting on a Franklin release. Its MODEL_SHORTCUTS alias
|
|
@@ -377,9 +529,7 @@ export function reconcilePicker(catalog) {
|
|
|
377
529
|
continue; // retired upstream — drop the row, keep the alias
|
|
378
530
|
// Price comes from the gateway (it's factual, it drifts, and it's the
|
|
379
531
|
// user's money). The label stays curated: gateway names are longer than
|
|
380
|
-
// the picker's tuned columns
|
|
381
|
-
// chars against a 26-wide field) and carry redundant "(Free)" suffixes
|
|
382
|
-
// that the 🆓 heading already says.
|
|
532
|
+
// the picker's tuned columns and often carry redundant suffixes.
|
|
383
533
|
models.push({ ...row, price: formatPrice(live) });
|
|
384
534
|
}
|
|
385
535
|
if (models.length > 0)
|
|
@@ -388,6 +538,64 @@ export function reconcilePicker(catalog) {
|
|
|
388
538
|
const moreCount = catalog.filter(m => m.categories?.includes('chat') && !curated.has(m.id)).length;
|
|
389
539
|
return { categories, moreCount, live: true };
|
|
390
540
|
}
|
|
541
|
+
export async function getExpandedPickerCategories() {
|
|
542
|
+
try {
|
|
543
|
+
return reconcileExpandedPicker(await getGatewayModels());
|
|
544
|
+
}
|
|
545
|
+
catch {
|
|
546
|
+
return { categories: PICKER_CATEGORIES, moreCount: 0, live: false };
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
export function reconcileExpandedPicker(catalog) {
|
|
550
|
+
const categories = [{ ...PICKER_CATEGORIES[0], models: [...PICKER_CATEGORIES[0].models] }];
|
|
551
|
+
const curated = new Set();
|
|
552
|
+
const curatedRows = new Map();
|
|
553
|
+
for (const cat of PICKER_CATEGORIES) {
|
|
554
|
+
for (const row of cat.models) {
|
|
555
|
+
curated.add(row.id);
|
|
556
|
+
if (!isSyntheticId(row.id))
|
|
557
|
+
curatedRows.set(row.id, row);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
const shortcutById = buildShortcutById();
|
|
561
|
+
const chatModels = catalog
|
|
562
|
+
.filter(m => m.categories?.includes('chat'))
|
|
563
|
+
.sort((a, b) => {
|
|
564
|
+
const providerDelta = providerRank(providerOf(a.id)) - providerRank(providerOf(b.id));
|
|
565
|
+
if (providerDelta !== 0)
|
|
566
|
+
return providerDelta;
|
|
567
|
+
const rankDelta = expandedModelRank(b) - expandedModelRank(a);
|
|
568
|
+
if (rankDelta !== 0)
|
|
569
|
+
return rankDelta;
|
|
570
|
+
const curatedDelta = Number(!curated.has(a.id)) - Number(!curated.has(b.id));
|
|
571
|
+
if (curatedDelta !== 0)
|
|
572
|
+
return curatedDelta;
|
|
573
|
+
return modelSuffix(a.id).localeCompare(modelSuffix(b.id));
|
|
574
|
+
});
|
|
575
|
+
const byProvider = new Map();
|
|
576
|
+
for (const model of chatModels) {
|
|
577
|
+
const provider = providerOf(model.id);
|
|
578
|
+
const curatedRow = curatedRows.get(model.id);
|
|
579
|
+
const row = curatedRow
|
|
580
|
+
? { ...curatedRow, price: formatPrice(model) }
|
|
581
|
+
: {
|
|
582
|
+
id: model.id,
|
|
583
|
+
shortcut: shortcutById.get(model.id) || model.id,
|
|
584
|
+
label: cleanGatewayLabel(model),
|
|
585
|
+
price: formatPrice(model),
|
|
586
|
+
};
|
|
587
|
+
const rows = byProvider.get(provider) ?? [];
|
|
588
|
+
rows.push(row);
|
|
589
|
+
byProvider.set(provider, rows);
|
|
590
|
+
}
|
|
591
|
+
for (const [provider, models] of [...byProvider.entries()].sort((a, b) => {
|
|
592
|
+
const rankDelta = providerRank(a[0]) - providerRank(b[0]);
|
|
593
|
+
return rankDelta !== 0 ? rankDelta : a[0].localeCompare(b[0]);
|
|
594
|
+
})) {
|
|
595
|
+
categories.push({ category: providerHeading(provider), models });
|
|
596
|
+
}
|
|
597
|
+
return { categories, moreCount: 0, live: true };
|
|
598
|
+
}
|
|
391
599
|
/**
|
|
392
600
|
* Show interactive model picker. Returns the selected model ID.
|
|
393
601
|
* Falls back to text input if terminal doesn't support raw mode.
|
package/package.json
CHANGED