@blockrun/franklin 3.32.1 → 3.33.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.
- package/dist/agent/compact.js +1 -1
- package/dist/agent/context.js +1 -1
- package/dist/agent/loop.js +2 -2
- package/dist/agent/optimize.js +1 -1
- package/dist/agent/tokens.js +2 -0
- package/dist/commands/init.js +1 -1
- package/dist/commands/models.d.ts +11 -0
- package/dist/commands/models.js +157 -37
- package/dist/gateway-models.d.ts +14 -2
- package/dist/gateway-models.js +8 -0
- package/dist/learnings/extractor.js +1 -1
- package/dist/pricing.js +4 -1
- package/dist/router/index.js +15 -9
- package/dist/router/vision.js +5 -4
- package/dist/tools/moa.js +1 -1
- package/dist/ui/app.js +54 -9
- package/dist/ui/model-picker.d.ts +40 -0
- package/dist/ui/model-picker.js +135 -25
- package/package.json +1 -1
- package/dist/agent/media-router.d.ts +0 -98
- package/dist/agent/media-router.js +0 -328
package/dist/agent/compact.js
CHANGED
|
@@ -464,7 +464,7 @@ function pickCompactionModel(primaryModel) {
|
|
|
464
464
|
return 'anthropic/claude-sonnet-4.6';
|
|
465
465
|
}
|
|
466
466
|
if (primaryModel.includes('sonnet') || primaryModel.includes('gpt-5.4') || primaryModel.includes('gpt-5.5') || primaryModel.includes('gemini-2.5-pro')) {
|
|
467
|
-
return 'anthropic/claude-haiku-4.5
|
|
467
|
+
return 'anthropic/claude-haiku-4.5';
|
|
468
468
|
}
|
|
469
469
|
if (primaryModel.includes('haiku') || primaryModel.includes('mini') || primaryModel.includes('nano')) {
|
|
470
470
|
return 'google/gemini-2.5-flash'; // Cheapest capable model
|
package/dist/agent/context.js
CHANGED
|
@@ -242,7 +242,7 @@ You run on the BlockRun AI Gateway. When the user asks you to "test the BlockRun
|
|
|
242
242
|
- \`GET /.well-known/x402\` — x402 resource list with prices
|
|
243
243
|
|
|
244
244
|
**LLM (POST, x402-paid)**
|
|
245
|
-
- \`POST /v1/chat/completions\` — OpenAI-compatible. Body: \`{ model, messages, stream?, tools?, max_tokens?, temperature? }\`. \`model\` MUST come from \`GET /v1/models\` (real frontier examples on the gateway
|
|
245
|
+
- \`POST /v1/chat/completions\` — OpenAI-compatible. Body: \`{ model, messages, stream?, tools?, max_tokens?, temperature? }\`. \`model\` MUST come from \`GET /v1/models\` (real frontier examples on the gateway, verified live 2026-07-14: \`anthropic/claude-sonnet-5\`, \`anthropic/claude-opus-4.8\`, \`deepseek/deepseek-v4-pro\`, \`zai/glm-5.2\`, \`xai/grok-4.5\`, \`nvidia/qwen3-next-80b-a3b-instruct\` (free)). Do NOT invent versions like \`openai/gpt-5.1\` or \`xai/grok-5\` — those don't exist; the gateway 400s with the valid list in the error body, so when in doubt fetch \`GET /v1/models\` first.
|
|
246
246
|
- \`POST /v1/messages\` — Anthropic-compatible. Body: \`{ model, messages, max_tokens, system?, tools? }\`.
|
|
247
247
|
|
|
248
248
|
**Media (POST, x402-paid; GET to poll async jobs)**
|
package/dist/agent/loop.js
CHANGED
|
@@ -1417,7 +1417,7 @@ export async function interactiveSession(config, getUserInput, onEvent, onAbortR
|
|
|
1417
1417
|
// Free-only recovery chain — a free/empty-response session must NEVER
|
|
1418
1418
|
// fall back to a paid model (would silently charge the wallet). Both
|
|
1419
1419
|
// entries are $0 nvidia models.
|
|
1420
|
-
const EMPTY_FALLBACK_MODELS = ['nvidia/qwen3-next-80b-a3b-instruct', 'nvidia/
|
|
1420
|
+
const EMPTY_FALLBACK_MODELS = ['nvidia/qwen3-next-80b-a3b-instruct', 'nvidia/mistral-nemotron'];
|
|
1421
1421
|
const nextModel = EMPTY_FALLBACK_MODELS.find(m => m !== config.model && !turnFailedModels.has(m));
|
|
1422
1422
|
if (nextModel && recoveryAttempts < 2 && !config.disableModelFallback) {
|
|
1423
1423
|
recoveryAttempts++;
|
|
@@ -1460,7 +1460,7 @@ export async function interactiveSession(config, getUserInput, onEvent, onAbortR
|
|
|
1460
1460
|
const TOOL_USE_FALLBACK_MODELS = [
|
|
1461
1461
|
'anthropic/claude-haiku-4.5',
|
|
1462
1462
|
'moonshot/kimi-k2.7',
|
|
1463
|
-
'openai/gpt-5',
|
|
1463
|
+
'openai/gpt-5.4',
|
|
1464
1464
|
'anthropic/claude-sonnet-4.6',
|
|
1465
1465
|
];
|
|
1466
1466
|
const nextModel = TOOL_USE_FALLBACK_MODELS.find(m => m !== config.model && !turnFailedModels.has(m));
|
package/dist/agent/optimize.js
CHANGED
|
@@ -33,7 +33,7 @@ const MODEL_MAX_OUTPUT = {
|
|
|
33
33
|
'anthropic/claude-sonnet-5': 128_000,
|
|
34
34
|
'anthropic/claude-sonnet-4.6': 64_000,
|
|
35
35
|
'anthropic/claude-sonnet-4.5': 64_000,
|
|
36
|
-
'anthropic/claude-haiku-4.5
|
|
36
|
+
'anthropic/claude-haiku-4.5': 16_384,
|
|
37
37
|
'openai/gpt-5.6-sol': 128_000,
|
|
38
38
|
'openai/gpt-5.6-terra': 128_000,
|
|
39
39
|
'openai/gpt-5.6-luna': 128_000,
|
package/dist/agent/tokens.js
CHANGED
|
@@ -207,6 +207,8 @@ const MODEL_CONTEXT_WINDOWS = {
|
|
|
207
207
|
'anthropic/claude-sonnet-4.5': 200_000,
|
|
208
208
|
'anthropic/claude-sonnet-4': 200_000,
|
|
209
209
|
'anthropic/claude-haiku-4.5': 200_000,
|
|
210
|
+
// Retired 2026-07-14 (gateway 400s on it) — kept so replayed sessions that
|
|
211
|
+
// recorded the dated id still resolve a context window.
|
|
210
212
|
'anthropic/claude-haiku-4.5-20251001': 200_000,
|
|
211
213
|
// OpenAI
|
|
212
214
|
// gpt-5.5 advertises 1.05M context at the gateway, but Franklin keeps the
|
package/dist/commands/init.js
CHANGED
|
@@ -30,7 +30,7 @@ export async function initCommand(options) {
|
|
|
30
30
|
ANTHROPIC_MODEL: 'blockrun/auto',
|
|
31
31
|
ANTHROPIC_DEFAULT_SONNET_MODEL: 'anthropic/claude-sonnet-4.6',
|
|
32
32
|
ANTHROPIC_DEFAULT_OPUS_MODEL: 'anthropic/claude-opus-4.8',
|
|
33
|
-
ANTHROPIC_DEFAULT_HAIKU_MODEL: 'anthropic/claude-haiku-4.5
|
|
33
|
+
ANTHROPIC_DEFAULT_HAIKU_MODEL: 'anthropic/claude-haiku-4.5',
|
|
34
34
|
};
|
|
35
35
|
fs.mkdirSync(path.dirname(CLAUDE_SETTINGS_FILE), { recursive: true });
|
|
36
36
|
fs.writeFileSync(CLAUDE_SETTINGS_FILE, JSON.stringify(settings, null, 2));
|
|
@@ -1 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compact USD — keeps sub-cent prices honest ($0.435/M must not round to
|
|
3
|
+
* $0.44). Exported for tests.
|
|
4
|
+
*/
|
|
5
|
+
export declare function money(n: number): string;
|
|
6
|
+
/**
|
|
7
|
+
* 1000000 → 1M, 1048576 → 1M, 1050000 → 1.1M, 262144 → 262K.
|
|
8
|
+
* Both 1000000 and 1048576 are "1M context" to a reader — don't render one as
|
|
9
|
+
* `1M` and the other as `1.0M` in the same column. Exported for tests.
|
|
10
|
+
*/
|
|
11
|
+
export declare function formatContext(n: number | undefined): string;
|
|
1
12
|
export declare function modelsCommand(): Promise<void>;
|
package/dist/commands/models.js
CHANGED
|
@@ -1,56 +1,176 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import { loadChain, API_URLS } from '../config.js';
|
|
3
|
+
import { getGatewayModels, GATEWAY_MARGIN, } from '../gateway-models.js';
|
|
4
|
+
/**
|
|
5
|
+
* `franklin models` — the live catalog.
|
|
6
|
+
*
|
|
7
|
+
* Reuses gateway-models.ts rather than re-fetching: it already types every
|
|
8
|
+
* billing mode, caches for 5 minutes, and serves stale-on-error.
|
|
9
|
+
*
|
|
10
|
+
* The old version modelled pricing as `{ input, output }` for every model and
|
|
11
|
+
* printed `$0.00/M` for anything that isn't token-metered — so the entire
|
|
12
|
+
* image/video/music/speech catalog rendered as free under a "Paid Models"
|
|
13
|
+
* heading. The gateway actually bills seven different ways, and each needs its
|
|
14
|
+
* own unit; that's what BILLING_GROUPS below encodes.
|
|
15
|
+
*/
|
|
16
|
+
const RULE_WIDTH = 74;
|
|
17
|
+
/**
|
|
18
|
+
* Compact USD — keeps sub-cent prices honest ($0.435/M must not round to
|
|
19
|
+
* $0.44). Exported for tests.
|
|
20
|
+
*/
|
|
21
|
+
export function money(n) {
|
|
22
|
+
if (n === 0)
|
|
23
|
+
return '$0';
|
|
24
|
+
const decimals = n < 0.01 ? 4 : n < 1 ? 3 : 2;
|
|
25
|
+
return `$${n.toFixed(decimals).replace(/(\.\d*?)0+$/, '$1').replace(/\.$/, '')}`;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* 1000000 → 1M, 1048576 → 1M, 1050000 → 1.1M, 262144 → 262K.
|
|
29
|
+
* Both 1000000 and 1048576 are "1M context" to a reader — don't render one as
|
|
30
|
+
* `1M` and the other as `1.0M` in the same column. Exported for tests.
|
|
31
|
+
*/
|
|
32
|
+
export function formatContext(n) {
|
|
33
|
+
if (!n)
|
|
34
|
+
return '';
|
|
35
|
+
if (n >= 1_000_000)
|
|
36
|
+
return `${(n / 1_000_000).toFixed(1).replace(/\.0$/, '')}M`;
|
|
37
|
+
return `${Math.round(n / 1000)}K`;
|
|
38
|
+
}
|
|
39
|
+
function pricingOf(m) {
|
|
40
|
+
return m.pricing;
|
|
41
|
+
}
|
|
42
|
+
// Ordered as printed. `free` and `paid` are handled separately — free gets its
|
|
43
|
+
// own promoted section, and paid is the only one with an Input/Output/Context
|
|
44
|
+
// table rather than a single price column.
|
|
45
|
+
const BILLING_GROUPS = [
|
|
46
|
+
{
|
|
47
|
+
mode: 'per_image',
|
|
48
|
+
heading: 'Image generation (per image)',
|
|
49
|
+
render: m => `${money(pricingOf(m).per_image ?? 0)}/image`,
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
mode: 'per_second',
|
|
53
|
+
heading: 'Video generation (per second)',
|
|
54
|
+
render: m => {
|
|
55
|
+
const p = pricingOf(m);
|
|
56
|
+
const per = p.per_second ?? 0;
|
|
57
|
+
const def = p.default_duration_seconds;
|
|
58
|
+
const max = p.max_duration_seconds;
|
|
59
|
+
const parts = [`${money(per)}/sec`];
|
|
60
|
+
if (def)
|
|
61
|
+
parts.push(`${def}s default ≈ ${money(per * def)}`);
|
|
62
|
+
if (max)
|
|
63
|
+
parts.push(`max ${max}s`);
|
|
64
|
+
return parts.join(' · ');
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
mode: 'per_character',
|
|
69
|
+
heading: 'Speech / TTS (per 1K characters)',
|
|
70
|
+
render: m => {
|
|
71
|
+
const p = pricingOf(m);
|
|
72
|
+
const s = `${money(p.per_1k_chars ?? 0)}/1K chars`;
|
|
73
|
+
return p.max_input_chars ? `${s} · max ${formatContext(p.max_input_chars)} chars` : s;
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
mode: 'per_track',
|
|
78
|
+
heading: 'Music (per track)',
|
|
79
|
+
render: m => `${money(pricingOf(m).per_track ?? 0)}/track`,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
mode: 'per_generation',
|
|
83
|
+
heading: 'Sound effects (per generation)',
|
|
84
|
+
render: m => {
|
|
85
|
+
const p = pricingOf(m);
|
|
86
|
+
const s = `${money(p.per_generation ?? 0)}/generation`;
|
|
87
|
+
return p.max_duration_seconds ? `${s} · max ${p.max_duration_seconds}s` : s;
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
mode: 'flat',
|
|
92
|
+
heading: 'Flat rate (per call)',
|
|
93
|
+
render: m => `${money(pricingOf(m).flat ?? 0)}/call`,
|
|
94
|
+
},
|
|
95
|
+
];
|
|
96
|
+
function printSection(heading, models, render) {
|
|
97
|
+
if (models.length === 0)
|
|
98
|
+
return;
|
|
99
|
+
console.log(chalk.yellow.bold(heading));
|
|
100
|
+
console.log(chalk.dim('─'.repeat(RULE_WIDTH)));
|
|
101
|
+
for (const m of models) {
|
|
102
|
+
console.log(` ${chalk.cyan(m.id.padEnd(44))} ${render(m)}`);
|
|
103
|
+
}
|
|
104
|
+
console.log('');
|
|
105
|
+
}
|
|
3
106
|
export async function modelsCommand() {
|
|
4
107
|
const chain = loadChain();
|
|
5
108
|
const apiUrl = API_URLS[chain];
|
|
6
109
|
console.log(chalk.bold('Available Models\n'));
|
|
7
110
|
console.log(`Chain: ${chalk.magenta(chain)} — ${chalk.dim(apiUrl)}\n`);
|
|
111
|
+
let models;
|
|
8
112
|
try {
|
|
9
|
-
|
|
10
|
-
const timeout = setTimeout(() => controller.abort(), 15_000);
|
|
11
|
-
const response = await fetch(`${apiUrl}/v1/models`, { signal: controller.signal });
|
|
12
|
-
clearTimeout(timeout);
|
|
13
|
-
if (!response.ok) {
|
|
14
|
-
console.log(chalk.red(`Failed to fetch models: ${response.status}`));
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
const data = (await response.json());
|
|
18
|
-
if (!data.data || data.data.length === 0) {
|
|
19
|
-
console.log(chalk.yellow('No models returned from API.'));
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
const models = data.data
|
|
23
|
-
.sort((a, b) => (a.pricing?.input ?? 0) - (b.pricing?.input ?? 0));
|
|
24
|
-
const free = models.filter((m) => m.billing_mode === 'free');
|
|
25
|
-
const paid = models.filter((m) => m.billing_mode !== 'free');
|
|
26
|
-
if (free.length > 0) {
|
|
27
|
-
console.log(chalk.green.bold('Free Models (no USDC needed)'));
|
|
28
|
-
console.log(chalk.dim('─'.repeat(70)));
|
|
29
|
-
for (const m of free) {
|
|
30
|
-
console.log(` ${chalk.cyan(m.id)}`);
|
|
31
|
-
}
|
|
32
|
-
console.log('');
|
|
33
|
-
}
|
|
34
|
-
console.log(chalk.yellow.bold('Paid Models'));
|
|
35
|
-
console.log(chalk.dim('─'.repeat(70)));
|
|
36
|
-
console.log(chalk.dim(` ${'Model'.padEnd(35)} ${'Input'.padEnd(12)} ${'Output'.padEnd(12)} Context`));
|
|
37
|
-
console.log(chalk.dim('─'.repeat(70)));
|
|
38
|
-
for (const m of paid) {
|
|
39
|
-
const input = `$${(m.pricing?.input ?? 0).toFixed(2)}/M`;
|
|
40
|
-
const output = `$${(m.pricing?.output ?? 0).toFixed(2)}/M`;
|
|
41
|
-
const ctx = '';
|
|
42
|
-
console.log(` ${chalk.cyan(m.id.padEnd(35))} ${input.padEnd(12)} ${output.padEnd(12)} ${ctx}`);
|
|
43
|
-
}
|
|
44
|
-
console.log(`\n${chalk.dim(`${models.length} models available. Use:`)} ${chalk.bold('franklin start --model <model-id>')}`);
|
|
113
|
+
models = await getGatewayModels();
|
|
45
114
|
}
|
|
46
115
|
catch (err) {
|
|
47
116
|
const msg = err instanceof Error ? err.message : 'unknown error';
|
|
48
|
-
if (
|
|
117
|
+
if (/fetch|ECONNREFUSED|ENOTFOUND|abort/i.test(msg)) {
|
|
49
118
|
console.log(chalk.red(`Cannot reach BlockRun API at ${apiUrl}`));
|
|
50
119
|
console.log(chalk.dim('Check your internet connection or try again later.'));
|
|
51
120
|
}
|
|
52
121
|
else {
|
|
53
122
|
console.log(chalk.red(`Error: ${msg}`));
|
|
54
123
|
}
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (models.length === 0) {
|
|
127
|
+
console.log(chalk.yellow('No models returned from API.'));
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
// Free first — it's the "no USDC needed" on-ramp and the reason many people
|
|
131
|
+
// install Franklin at all.
|
|
132
|
+
const free = models.filter(m => m.billing_mode === 'free');
|
|
133
|
+
if (free.length > 0) {
|
|
134
|
+
console.log(chalk.green.bold('Free Models (no USDC needed)'));
|
|
135
|
+
console.log(chalk.dim('─'.repeat(RULE_WIDTH)));
|
|
136
|
+
for (const m of free) {
|
|
137
|
+
const ctx = formatContext(m.context_window);
|
|
138
|
+
console.log(` ${chalk.cyan(m.id.padEnd(44))} ${chalk.dim(ctx ? `${ctx} ctx` : '')}`);
|
|
139
|
+
}
|
|
140
|
+
console.log('');
|
|
141
|
+
}
|
|
142
|
+
// Token-metered — the only group with a two-price table.
|
|
143
|
+
const paid = models
|
|
144
|
+
.filter(m => m.billing_mode === 'paid')
|
|
145
|
+
.sort((a, b) => {
|
|
146
|
+
const ap = a.pricing;
|
|
147
|
+
const bp = b.pricing;
|
|
148
|
+
return (ap.input ?? 0) - (bp.input ?? 0);
|
|
149
|
+
});
|
|
150
|
+
if (paid.length > 0) {
|
|
151
|
+
console.log(chalk.yellow.bold('Chat & Reasoning (per 1M tokens)'));
|
|
152
|
+
console.log(chalk.dim('─'.repeat(RULE_WIDTH)));
|
|
153
|
+
console.log(chalk.dim(` ${'Model'.padEnd(44)} ${'Input'.padEnd(11)} ${'Output'.padEnd(11)} Context`));
|
|
154
|
+
console.log(chalk.dim('─'.repeat(RULE_WIDTH)));
|
|
155
|
+
for (const m of paid) {
|
|
156
|
+
const p = pricingOf(m);
|
|
157
|
+
const input = `${money(p.input ?? 0)}/M`;
|
|
158
|
+
const output = `${money(p.output ?? 0)}/M`;
|
|
159
|
+
console.log(` ${chalk.cyan(m.id.padEnd(44))} ${input.padEnd(11)} ${output.padEnd(11)} ${chalk.dim(formatContext(m.context_window))}`);
|
|
160
|
+
}
|
|
161
|
+
console.log('');
|
|
162
|
+
}
|
|
163
|
+
for (const group of BILLING_GROUPS) {
|
|
164
|
+
const inGroup = models.filter(m => m.billing_mode === group.mode);
|
|
165
|
+
printSection(group.heading, inGroup, group.render);
|
|
55
166
|
}
|
|
167
|
+
// Anything the gateway starts billing a way this build doesn't know about
|
|
168
|
+
// must still be listed — silently dropping a model is how the $0.00/M bug
|
|
169
|
+
// stayed invisible. Show it with its raw pricing rather than a wrong unit.
|
|
170
|
+
const known = new Set(['free', 'paid', ...BILLING_GROUPS.map(g => g.mode)]);
|
|
171
|
+
const unknown = models.filter(m => !known.has(m.billing_mode));
|
|
172
|
+
printSection('Other billing modes (not yet modelled by this Franklin build)', unknown, m => chalk.dim(`${m.billing_mode}: ${JSON.stringify(m.pricing)}`));
|
|
173
|
+
const margin = Math.round((GATEWAY_MARGIN - 1) * 100);
|
|
174
|
+
console.log(chalk.dim(`${models.length} models available. Prices are gateway list — x402 settlement adds ~${margin}%.`));
|
|
175
|
+
console.log(`${chalk.dim('Use:')} ${chalk.bold('franklin start --model <model-id>')}`);
|
|
56
176
|
}
|
package/dist/gateway-models.d.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* so actual charge = base * 1.05 (confirmed against a live 402 response
|
|
14
14
|
* on seedance-2.0-fast: 5s × $0.15 × 1.05 = $0.7875).
|
|
15
15
|
*/
|
|
16
|
-
export type BillingMode = 'paid' | 'free' | 'flat' | 'per_image' | 'per_second' | 'per_track';
|
|
16
|
+
export type BillingMode = 'paid' | 'free' | 'flat' | 'per_image' | 'per_second' | 'per_track' | 'per_character' | 'per_generation';
|
|
17
17
|
export interface PaidPricing {
|
|
18
18
|
input: number;
|
|
19
19
|
output: number;
|
|
@@ -32,7 +32,17 @@ export interface PerSecondPricing {
|
|
|
32
32
|
export interface PerTrackPricing {
|
|
33
33
|
per_track: number;
|
|
34
34
|
}
|
|
35
|
-
|
|
35
|
+
/** ElevenLabs / ByteDance speech — billed per 1K characters of input text. */
|
|
36
|
+
export interface PerCharacterPricing {
|
|
37
|
+
per_1k_chars: number;
|
|
38
|
+
max_input_chars?: number;
|
|
39
|
+
}
|
|
40
|
+
/** ElevenLabs sound effects — flat charge per generation. */
|
|
41
|
+
export interface PerGenerationPricing {
|
|
42
|
+
per_generation: number;
|
|
43
|
+
max_duration_seconds?: number;
|
|
44
|
+
}
|
|
45
|
+
export type ModelPricing = PaidPricing | FlatPricing | PerImagePricing | PerSecondPricing | PerTrackPricing | PerCharacterPricing | PerGenerationPricing;
|
|
36
46
|
export interface GatewayModel {
|
|
37
47
|
id: string;
|
|
38
48
|
name: string;
|
|
@@ -63,6 +73,8 @@ export interface EstimateContext {
|
|
|
63
73
|
quantity?: number;
|
|
64
74
|
/** Clip length in seconds (per_second). Falls back to model's default_duration_seconds, then 8. */
|
|
65
75
|
duration_seconds?: number;
|
|
76
|
+
/** Input text length (per_character). Required for a meaningful speech estimate. */
|
|
77
|
+
characters?: number;
|
|
66
78
|
}
|
|
67
79
|
/**
|
|
68
80
|
* Estimated USD charge to generate one response from this model under the
|
package/dist/gateway-models.js
CHANGED
|
@@ -108,6 +108,14 @@ export function estimateCostUsd(model, ctx = {}) {
|
|
|
108
108
|
case 'per_track':
|
|
109
109
|
base = p.per_track ?? 0;
|
|
110
110
|
break;
|
|
111
|
+
case 'per_character':
|
|
112
|
+
// Priced per 1K characters of input text. Without a length there's no
|
|
113
|
+
// meaningful estimate, so fall through to 0 rather than invent one.
|
|
114
|
+
base = ((p.per_1k_chars ?? 0) * (ctx.characters ?? 0)) / 1000;
|
|
115
|
+
break;
|
|
116
|
+
case 'per_generation':
|
|
117
|
+
base = p.per_generation ?? 0;
|
|
118
|
+
break;
|
|
111
119
|
case 'flat':
|
|
112
120
|
base = p.flat ?? 0;
|
|
113
121
|
break;
|
|
@@ -10,7 +10,7 @@ import { loadLearnings, mergeLearning, saveLearnings, loadSkills, saveSkill } fr
|
|
|
10
10
|
// Ordered by reliability: try the best free model first, fall back to others.
|
|
11
11
|
const EXTRACTION_MODELS = [
|
|
12
12
|
'nvidia/qwen3-next-80b-a3b-instruct', // Clean JSON output, no thinking leak (verified live)
|
|
13
|
-
'nvidia/
|
|
13
|
+
'nvidia/mistral-nemotron', // Diverse-family free fallback (serves itself; maverick is pooled)
|
|
14
14
|
];
|
|
15
15
|
const VALID_CATEGORIES = new Set([
|
|
16
16
|
'language', 'model_preference', 'tool_pattern', 'coding_style',
|
package/dist/pricing.js
CHANGED
|
@@ -45,6 +45,8 @@ export const MODEL_PRICING = {
|
|
|
45
45
|
'anthropic/claude-sonnet-4.6': { input: 3.0, output: 15.0 },
|
|
46
46
|
'anthropic/claude-sonnet-4.5': { input: 3.0, output: 15.0 },
|
|
47
47
|
'anthropic/claude-haiku-4.5': { input: 1.0, output: 5.0 },
|
|
48
|
+
// Retired 2026-07-14: the gateway 400s on the dated id (undated is canonical).
|
|
49
|
+
// Kept for cost lookup on sessions recorded before the switch.
|
|
48
50
|
'anthropic/claude-haiku-4.5-20251001': { input: 1.0, output: 5.0 },
|
|
49
51
|
// OpenAI
|
|
50
52
|
'openai/gpt-5-nano': { input: 0.05, output: 0.4 },
|
|
@@ -89,7 +91,8 @@ export const MODEL_PRICING = {
|
|
|
89
91
|
'xai/grok-3-mini': { input: 0.3, output: 0.5 },
|
|
90
92
|
'xai/grok-2-vision': { input: 2.0, output: 10.0 },
|
|
91
93
|
'xai/grok-3': { input: 3.0, output: 15.0 },
|
|
92
|
-
'xai/grok-4.3': { input: 1.5, output: 4.0 }, //
|
|
94
|
+
'xai/grok-4.3': { input: 1.5, output: 4.0 }, // 1M ctx; demoted from flagship 2026-07-14
|
|
95
|
+
'xai/grok-4.5': { input: 2.5, output: 9.0 }, // xAI flagship — 500K ctx (note: less than 4.3's 1M)
|
|
93
96
|
'xai/grok-build-0.1': { input: 1.5, output: 3.0 }, // agentic coding, OpenRouter resale
|
|
94
97
|
// DeepSeek (gateway re-aliased these to V4 Flash on 2026-05-03; price
|
|
95
98
|
// dropped from $0.28/$0.42 to $0.20/$0.40, context bumped 128K→1M).
|
package/dist/router/index.js
CHANGED
|
@@ -577,19 +577,25 @@ export function getFallbackChain(tier, profile = 'auto') {
|
|
|
577
577
|
// gateway redirected it to a now-dead model, so routing to it just wasted a slot.
|
|
578
578
|
// 2026-07-11: nvidia/deepseek-v4-flash removed — the gateway no longer serves
|
|
579
579
|
// it (410). Free tier is now led by nvidia/qwen3-next-80b-a3b-instruct (cleanest
|
|
580
|
-
// free instruction-follower — no thinking leak / markdown fences, verified live)
|
|
581
|
-
//
|
|
580
|
+
// free instruction-follower — no thinking leak / markdown fences, verified live).
|
|
581
|
+
// 2026-07-14: nvidia/llama-4-maverick replaced by nvidia/mistral-nemotron as the
|
|
582
|
+
// different-family fallback. Maverick left the gateway catalog, and the free
|
|
583
|
+
// pool silently substitutes for it — a live probe showed both maverick and
|
|
584
|
+
// qwen3-next answering as `nvidia/nemotron-3-super-120b-a12b-free`. Two chain
|
|
585
|
+
// entries backed by the same pooled model is fake resilience: the fallback
|
|
586
|
+
// couldn't rescue a turn the primary had already failed. mistral-nemotron
|
|
587
|
+
// verifiably serves itself, so the chain is genuinely two families again.
|
|
582
588
|
const FREE_MODELS_BY_CATEGORY = {
|
|
583
|
-
coding: ['nvidia/qwen3-next-80b-a3b-instruct', 'nvidia/
|
|
584
|
-
trading: ['nvidia/qwen3-next-80b-a3b-instruct', 'nvidia/
|
|
585
|
-
research: ['nvidia/qwen3-next-80b-a3b-instruct', 'nvidia/
|
|
586
|
-
reasoning: ['nvidia/qwen3-next-80b-a3b-instruct', 'nvidia/
|
|
587
|
-
chat: ['nvidia/qwen3-next-80b-a3b-instruct', 'nvidia/
|
|
588
|
-
creative: ['nvidia/qwen3-next-80b-a3b-instruct', 'nvidia/
|
|
589
|
+
coding: ['nvidia/qwen3-next-80b-a3b-instruct', 'nvidia/mistral-nemotron'],
|
|
590
|
+
trading: ['nvidia/qwen3-next-80b-a3b-instruct', 'nvidia/mistral-nemotron'],
|
|
591
|
+
research: ['nvidia/qwen3-next-80b-a3b-instruct', 'nvidia/mistral-nemotron'],
|
|
592
|
+
reasoning: ['nvidia/qwen3-next-80b-a3b-instruct', 'nvidia/mistral-nemotron'],
|
|
593
|
+
chat: ['nvidia/qwen3-next-80b-a3b-instruct', 'nvidia/mistral-nemotron'],
|
|
594
|
+
creative: ['nvidia/qwen3-next-80b-a3b-instruct', 'nvidia/mistral-nemotron'],
|
|
589
595
|
};
|
|
590
596
|
const DEFAULT_FREE_CHAIN = [
|
|
591
597
|
'nvidia/qwen3-next-80b-a3b-instruct',
|
|
592
|
-
'nvidia/
|
|
598
|
+
'nvidia/mistral-nemotron',
|
|
593
599
|
];
|
|
594
600
|
/**
|
|
595
601
|
* Pick the next free model to try given the question category and which
|
package/dist/router/vision.js
CHANGED
|
@@ -28,7 +28,7 @@ const VISION_MODELS = new Set([
|
|
|
28
28
|
'anthropic/claude-sonnet-5',
|
|
29
29
|
'anthropic/claude-sonnet-4.6',
|
|
30
30
|
'anthropic/claude-sonnet-4.5',
|
|
31
|
-
'anthropic/claude-haiku-4.5
|
|
31
|
+
'anthropic/claude-haiku-4.5',
|
|
32
32
|
// OpenAI — multimodal flagships + o3 (Codex 5.3 is text-only, excluded).
|
|
33
33
|
// GPT-5.6 family + 5.4-mini are vision; 5.4-nano is text-only.
|
|
34
34
|
'openai/gpt-5.6-sol',
|
|
@@ -54,9 +54,10 @@ const VISION_MODELS = new Set([
|
|
|
54
54
|
// Moonshot — K2.7 (flagship) + K2.6 are multimodal (image + video input)
|
|
55
55
|
'moonshot/kimi-k2.7',
|
|
56
56
|
'moonshot/kimi-k2.6',
|
|
57
|
-
// NVIDIA inference —
|
|
58
|
-
//
|
|
59
|
-
'
|
|
57
|
+
// NVIDIA inference — Nemotron Nano VL is multimodal; deepseek/qwen-coder are
|
|
58
|
+
// not. Llama 4 Maverick dropped 2026-07-14: it left the gateway catalog, and
|
|
59
|
+
// listing it here contradicted routeRequest()'s own "maverick is text-only"
|
|
60
|
+
// note — the free profile would route a vision turn to a text-only model.
|
|
60
61
|
'nvidia/nemotron-nano-12b-v2-vl',
|
|
61
62
|
]);
|
|
62
63
|
/** Does this concrete gateway model accept image input? */
|
package/dist/tools/moa.js
CHANGED
|
@@ -15,7 +15,7 @@ import { ModelClient } from '../agent/llm.js';
|
|
|
15
15
|
/** Reference models — diverse, cheap/free models for parallel queries. */
|
|
16
16
|
const REFERENCE_MODELS = [
|
|
17
17
|
'nvidia/qwen3-next-80b-a3b-instruct', // Free, clean instruction-follower
|
|
18
|
-
'nvidia/
|
|
18
|
+
'nvidia/mistral-nemotron', // Free, diverse family (maverick left the catalog 2026-07-14)
|
|
19
19
|
'google/gemini-2.5-flash', // Fast, cheap
|
|
20
20
|
'deepseek/deepseek-chat', // Cheap, good reasoning
|
|
21
21
|
];
|
package/dist/ui/app.js
CHANGED
|
@@ -8,13 +8,13 @@ import fs from 'node:fs';
|
|
|
8
8
|
import os from 'node:os';
|
|
9
9
|
import path from 'node:path';
|
|
10
10
|
import { execFileSync } from 'node:child_process';
|
|
11
|
-
import { useState, useEffect, useCallback, useRef } from 'react';
|
|
11
|
+
import { useState, useEffect, useCallback, useMemo, useRef } from 'react';
|
|
12
12
|
import { render, Static, Box, Text, useApp, useInput, useStdout } from 'ink';
|
|
13
13
|
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, PICKER_CATEGORIES, PICKER_MODELS_FLAT, } from './model-picker.js';
|
|
17
|
+
import { resolveModel, getPickerCategories, 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';
|
|
@@ -716,6 +716,16 @@ function RunCodeApp({ initialModel, workDir, walletAddress, walletBalance, chain
|
|
|
716
716
|
// Short preview of latest response shown in dynamic area (last ~5 lines, cleared on next turn)
|
|
717
717
|
const [responsePreview, setResponsePreview] = useState('');
|
|
718
718
|
const [currentModel, setCurrentModel] = useState(initialModel || PICKER_MODELS_FLAT[0].id);
|
|
719
|
+
// Gateway-reconciled picker list. Seeded with the static curation so the
|
|
720
|
+
// first paint is instant and an offline session still gets a usable picker;
|
|
721
|
+
// replaced by the hydrated list once the catalog fetch lands.
|
|
722
|
+
const [pickerCats, setPickerCats] = useState(PICKER_CATEGORIES);
|
|
723
|
+
const [pickerMoreCount, setPickerMoreCount] = useState(0);
|
|
724
|
+
const pickerFlat = useMemo(() => pickerCats.flatMap(c => c.models), [pickerCats]);
|
|
725
|
+
// Track the live model without re-firing the hydration effect on every model
|
|
726
|
+
// change — the effect should run when the picker opens, not when the model
|
|
727
|
+
// switches, but it still needs the current id to re-anchor the cursor.
|
|
728
|
+
const currentModelRef = useRef(initialModel);
|
|
719
729
|
const [ready, setReady] = useState(!startWithPicker);
|
|
720
730
|
const [mode, setMode] = useState(startWithPicker ? 'model-picker' : 'input');
|
|
721
731
|
const [pickerIdx, setPickerIdx] = useState(0);
|
|
@@ -751,6 +761,35 @@ function RunCodeApp({ initialModel, workDir, walletAddress, walletBalance, chain
|
|
|
751
761
|
// tab and the agent stops to ask for approval — verified 2026-05-04
|
|
752
762
|
// from a real screenshot where the user missed the dialog because the
|
|
753
763
|
// input box still read "Working...". Opt-out via FRANKLIN_NO_BELL=1.
|
|
764
|
+
// Single sync point for currentModelRef — cheaper to keep correct than
|
|
765
|
+
// updating the ref at every setCurrentModel call site.
|
|
766
|
+
useEffect(() => { currentModelRef.current = currentModel; }, [currentModel]);
|
|
767
|
+
// Reconcile the picker against the live gateway catalog whenever it opens —
|
|
768
|
+
// covers both /model with no args and --model-picker startup. Runs in the
|
|
769
|
+
// background: the picker has already painted from the static curation (or the
|
|
770
|
+
// 5-min cached catalog), so a slow gateway delays nothing. gateway-models.ts
|
|
771
|
+
// dedupes concurrent fetches and serves stale-on-error, so re-opening the
|
|
772
|
+
// picker is cheap and an offline session simply keeps the static list.
|
|
773
|
+
useEffect(() => {
|
|
774
|
+
if (mode !== 'model-picker')
|
|
775
|
+
return;
|
|
776
|
+
let cancelled = false;
|
|
777
|
+
void getPickerCategories()
|
|
778
|
+
.then(({ categories, moreCount, live }) => {
|
|
779
|
+
if (cancelled || !live)
|
|
780
|
+
return;
|
|
781
|
+
setPickerCats(categories);
|
|
782
|
+
setPickerMoreCount(moreCount);
|
|
783
|
+
// Rows may have dropped out from under the cursor — re-anchor on the
|
|
784
|
+
// model actually in use rather than leaving the highlight on whatever
|
|
785
|
+
// slid into that index.
|
|
786
|
+
const flat = categories.flatMap(c => c.models);
|
|
787
|
+
const at = flat.findIndex(m => m.id === currentModelRef.current);
|
|
788
|
+
setPickerIdx(at >= 0 ? at : 0);
|
|
789
|
+
})
|
|
790
|
+
.catch(() => { });
|
|
791
|
+
return () => { cancelled = true; };
|
|
792
|
+
}, [mode]);
|
|
754
793
|
const bellPlayedRef = useRef(false);
|
|
755
794
|
useEffect(() => {
|
|
756
795
|
const dialogActive = !!permissionRequest || !!askUserRequest;
|
|
@@ -939,9 +978,13 @@ function RunCodeApp({ initialModel, workDir, walletAddress, walletBalance, chain
|
|
|
939
978
|
if (key.upArrow)
|
|
940
979
|
setPickerIdx(i => Math.max(0, i - 1));
|
|
941
980
|
else if (key.downArrow)
|
|
942
|
-
setPickerIdx(i => Math.min(
|
|
981
|
+
setPickerIdx(i => Math.min(pickerFlat.length - 1, i + 1));
|
|
943
982
|
else if (key.return) {
|
|
944
|
-
|
|
983
|
+
// Hydration can shrink the list under the cursor (a retired row drops
|
|
984
|
+
// out), so treat the index as untrusted rather than assuming a hit.
|
|
985
|
+
const selected = pickerFlat[pickerIdx] ?? pickerFlat[0];
|
|
986
|
+
if (!selected)
|
|
987
|
+
return;
|
|
945
988
|
setCurrentModel(selected.id);
|
|
946
989
|
onModelChange(selected.id, 'user');
|
|
947
990
|
showStatus(`Model → ${selected.label}`, 'success', 3000);
|
|
@@ -1025,8 +1068,10 @@ function RunCodeApp({ initialModel, workDir, walletAddress, walletBalance, chain
|
|
|
1025
1068
|
showStatus(`Model → ${resolved}`, 'success', 3000);
|
|
1026
1069
|
}
|
|
1027
1070
|
else {
|
|
1028
|
-
const idx =
|
|
1071
|
+
const idx = pickerFlat.findIndex(m => m.id === currentModel);
|
|
1029
1072
|
setPickerIdx(idx >= 0 ? idx : 0);
|
|
1073
|
+
// Gateway reconciliation is kicked off by an effect on picker mode
|
|
1074
|
+
// (see below), so it covers this path and --model-picker startup.
|
|
1030
1075
|
// Defensive: ensure no draft text survives into the picker —
|
|
1031
1076
|
// closing handlers clear input too, so both ends are covered.
|
|
1032
1077
|
setInput('');
|
|
@@ -1439,7 +1484,7 @@ function RunCodeApp({ initialModel, workDir, walletAddress, walletBalance, chain
|
|
|
1439
1484
|
const { rendered, partial } = renderMarkdownStreaming(visible);
|
|
1440
1485
|
return (_jsxs(Box, { flexDirection: "column", marginTop: 0, marginBottom: 0, marginLeft: 2, children: [truncated && (_jsxs(Text, { dimColor: true, children: ["\u2191 ", lines.length - maxLines, " earlier line", lines.length - maxLines === 1 ? '' : 's', " \u2014 full response will appear in scrollback when this turn finishes"] })), _jsxs(Text, { wrap: "wrap", children: [rendered, rendered && partial ? '\n' : '', partial] })] }));
|
|
1441
1486
|
})(), responsePreview && !streamText && !permissionRequest && !askUserRequest && (_jsx(Box, { flexDirection: "column", marginBottom: 0, marginLeft: 2, children: _jsx(Text, { wrap: "wrap", children: renderMarkdown(responsePreview) }) })), inPicker && (() => {
|
|
1442
|
-
const totalModels =
|
|
1487
|
+
const totalModels = pickerFlat.length;
|
|
1443
1488
|
const maxModels = Math.max(6, termRows - 12);
|
|
1444
1489
|
let start = Math.max(0, pickerIdx - Math.floor(maxModels / 2));
|
|
1445
1490
|
let end = Math.min(totalModels, start + maxModels);
|
|
@@ -1452,12 +1497,12 @@ function RunCodeApp({ initialModel, workDir, walletAddress, walletBalance, chain
|
|
|
1452
1497
|
// Pre-compute each category's base offset into the flat model list so
|
|
1453
1498
|
// we can map (cat, localIdx) → globalIdx in one pass without re-walking.
|
|
1454
1499
|
let cursor = 0;
|
|
1455
|
-
const catBases =
|
|
1500
|
+
const catBases = pickerCats.map((cat) => {
|
|
1456
1501
|
const base = cursor;
|
|
1457
1502
|
cursor += cat.models.length;
|
|
1458
1503
|
return base;
|
|
1459
1504
|
});
|
|
1460
|
-
return (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsxs(Box, { marginLeft: 2, children: [_jsx(Text, { bold: true, children: "Select a model " }), _jsx(Text, { dimColor: true, children: "(\u2191\u2193 navigate, Enter select, Esc cancel)" })] }), hiddenAbove > 0 && (_jsx(Box, { marginLeft: 2, marginTop: 1, children: _jsxs(Text, { dimColor: true, children: ["\u2191 ", hiddenAbove, " more above"] }) })),
|
|
1505
|
+
return (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsxs(Box, { marginLeft: 2, children: [_jsx(Text, { bold: true, children: "Select a model " }), _jsx(Text, { dimColor: true, children: "(\u2191\u2193 navigate, Enter select, Esc cancel)" })] }), hiddenAbove > 0 && (_jsx(Box, { marginLeft: 2, marginTop: 1, children: _jsxs(Text, { dimColor: true, children: ["\u2191 ", hiddenAbove, " more above"] }) })), pickerCats.map((cat, catIdx) => {
|
|
1461
1506
|
const base = catBases[catIdx];
|
|
1462
1507
|
const visible = cat.models
|
|
1463
1508
|
.map((m, localIdx) => ({ m, globalIdx: base + localIdx }))
|
|
@@ -1470,7 +1515,7 @@ function RunCodeApp({ initialModel, workDir, walletAddress, walletBalance, chain
|
|
|
1470
1515
|
const isHighlight = m.highlight === true;
|
|
1471
1516
|
return (_jsxs(Box, { marginLeft: 2, children: [_jsxs(Text, { inverse: isSelected, color: isSelected ? 'cyan' : isHighlight ? 'yellow' : undefined, bold: isSelected || isHighlight, children: [' ', m.label.padEnd(26), ' '] }), _jsxs(Text, { dimColor: true, children: [" ", m.shortcut.padEnd(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));
|
|
1472
1517
|
})] }, cat.category));
|
|
1473
|
-
}), hiddenBelow > 0 && (_jsx(Box, { marginLeft: 2, marginTop: 1, children: _jsxs(Text, { dimColor: true, children: ["\u2193 ", hiddenBelow, " more below"] }) })), _jsx(Box, { marginTop: 1, marginLeft: 2, children: _jsx(Text, { dimColor: true, children: "Your conversation stays above \u2014 picking a model keeps all history intact." }) })] }));
|
|
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 `franklin models` to list, 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." }) })] }));
|
|
1474
1519
|
})(), !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 }))] }));
|
|
1475
1520
|
}
|
|
1476
1521
|
export function launchInkUI(opts) {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Interactive model picker for Franklin.
|
|
3
3
|
* Shows categorized model list, supports shortcuts and arrow-key selection.
|
|
4
4
|
*/
|
|
5
|
+
import { type GatewayModel } from '../gateway-models.js';
|
|
5
6
|
export declare const MODEL_SHORTCUTS: Record<string, string>;
|
|
6
7
|
/**
|
|
7
8
|
* Resolve a model name — supports shortcuts. Returns the canonical model id.
|
|
@@ -55,6 +56,45 @@ export interface ModelCategory {
|
|
|
55
56
|
export declare const PICKER_CATEGORIES: ModelCategory[];
|
|
56
57
|
/** Flat list of all picker models (for index-based navigation). */
|
|
57
58
|
export declare const PICKER_MODELS_FLAT: ModelEntry[];
|
|
59
|
+
export interface HydratedPicker {
|
|
60
|
+
categories: ModelCategory[];
|
|
61
|
+
/** Chat models live on the gateway that aren't curated into the picker. */
|
|
62
|
+
moreCount: number;
|
|
63
|
+
/** False when the gateway was unreachable and this is the static fallback. */
|
|
64
|
+
live: boolean;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The picker list, reconciled against the live gateway catalog.
|
|
68
|
+
*
|
|
69
|
+
* {@link PICKER_CATEGORIES} stays the editorial layer — which models are worth
|
|
70
|
+
* featuring, in what order, under which heading, with which shortcut. The
|
|
71
|
+
* gateway is the source of truth for everything factual: whether a model still
|
|
72
|
+
* exists, its display name, and its price. That split is deliberate: the
|
|
73
|
+
* gateway lists 57 chat models and the picker deliberately shows ~21 (see the
|
|
74
|
+
* v3.9.3 trim), so we can't just render the catalog.
|
|
75
|
+
*
|
|
76
|
+
* Reconciliation rules:
|
|
77
|
+
* - Curated row present in the catalog → refresh its label + price from the
|
|
78
|
+
* gateway, so a price change upstream can't leave a stale number on screen.
|
|
79
|
+
* - Curated row absent → drop it. This is the self-healing half: an id the
|
|
80
|
+
* gateway retired (the `claude-haiku-4.5-20251001` case) stops being
|
|
81
|
+
* offered without waiting on a Franklin release. Its MODEL_SHORTCUTS alias
|
|
82
|
+
* survives, matching the long-standing "hide the row, keep the shortcut"
|
|
83
|
+
* pattern.
|
|
84
|
+
* - Gateway unreachable → serve the static list verbatim (`live: false`).
|
|
85
|
+
* An offline picker showing a slightly stale list beats an empty one.
|
|
86
|
+
*
|
|
87
|
+
* Note the catalog hides some models that still resolve (grok-3 and the xAI
|
|
88
|
+
* fast family, for instance). Hidden-but-working ids are therefore dropped from
|
|
89
|
+
* the *visible* list while remaining reachable by typing the shortcut — which
|
|
90
|
+
* is the intended behavior, not a bug.
|
|
91
|
+
*/
|
|
92
|
+
export declare function getPickerCategories(): Promise<HydratedPicker>;
|
|
93
|
+
/**
|
|
94
|
+
* Pure reconciliation step behind {@link getPickerCategories} — exported so the
|
|
95
|
+
* rules can be tested against a synthetic catalog without touching the network.
|
|
96
|
+
*/
|
|
97
|
+
export declare function reconcilePicker(catalog: GatewayModel[]): HydratedPicker;
|
|
58
98
|
/**
|
|
59
99
|
* Show interactive model picker. Returns the selected model ID.
|
|
60
100
|
* Falls back to text input if terminal doesn't support raw mode.
|