@blockrun/franklin 3.32.0 → 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.
@@ -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-20251001';
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
@@ -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 as of 2026-06: \`anthropic/claude-sonnet-4.6\`, \`anthropic/claude-opus-4.8\`, \`deepseek/deepseek-v4-pro\`, \`zai/glm-5.2\`, \`nvidia/llama-4-maverick\`, \`openai/gpt-5-nano\`). 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.
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)**
@@ -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/llama-4-maverick'];
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));
@@ -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-20251001': 16_384,
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,
@@ -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
@@ -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-20251001',
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>;
@@ -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
- const controller = new AbortController();
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 (msg.includes('fetch') || msg.includes('ECONNREFUSED') || msg.includes('ENOTFOUND')) {
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
  }
@@ -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
- export type ModelPricing = PaidPricing | FlatPricing | PerImagePricing | PerSecondPricing | PerTrackPricing;
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
@@ -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/llama-4-maverick', // Diverse-family free fallback
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 }, // public flagship 2026-06-04, OpenRouter resale
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).
@@ -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
- // with nvidia/llama-4-maverick kept as a DIFFERENT-family fallback for resilience.
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/llama-4-maverick'],
584
- trading: ['nvidia/qwen3-next-80b-a3b-instruct', 'nvidia/llama-4-maverick'],
585
- research: ['nvidia/qwen3-next-80b-a3b-instruct', 'nvidia/llama-4-maverick'],
586
- reasoning: ['nvidia/qwen3-next-80b-a3b-instruct', 'nvidia/llama-4-maverick'],
587
- chat: ['nvidia/qwen3-next-80b-a3b-instruct', 'nvidia/llama-4-maverick'],
588
- creative: ['nvidia/qwen3-next-80b-a3b-instruct', 'nvidia/llama-4-maverick'],
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/llama-4-maverick',
598
+ 'nvidia/mistral-nemotron',
593
599
  ];
594
600
  /**
595
601
  * Pick the next free model to try given the question category and which
@@ -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-20251001',
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 — Llama 4 Maverick + Nemotron Nano VL are multimodal;
58
- // deepseek/qwen-coder are not.
59
- 'nvidia/llama-4-maverick',
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/llama-4-maverick', // Free, agent-tested general chat (diverse family)
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(PICKER_MODELS_FLAT.length - 1, i + 1));
981
+ setPickerIdx(i => Math.min(pickerFlat.length - 1, i + 1));
943
982
  else if (key.return) {
944
- const selected = PICKER_MODELS_FLAT[pickerIdx];
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 = PICKER_MODELS_FLAT.findIndex(m => m.id === currentModel);
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 = PICKER_MODELS_FLAT.length;
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 = PICKER_CATEGORIES.map((cat) => {
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"] }) })), PICKER_CATEGORIES.map((cat, catIdx) => {
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.
@@ -4,6 +4,7 @@
4
4
  */
5
5
  import readline from 'node:readline';
6
6
  import chalk from 'chalk';
7
+ import { getGatewayModels } from '../gateway-models.js';
7
8
  // ─── Model Shortcuts (same as proxy) ───────────────────────────────────────
8
9
  export const MODEL_SHORTCUTS = {
9
10
  // Routing profiles — Auto is the only profile surfaced in the picker.
@@ -29,8 +30,8 @@ export const MODEL_SHORTCUTS = {
29
30
  'opus-4.7': 'anthropic/claude-opus-4.7',
30
31
  'opus-4.6': 'anthropic/claude-opus-4.6',
31
32
  'opus-4.5': 'anthropic/claude-opus-4.5',
32
- haiku: 'anthropic/claude-haiku-4.5-20251001',
33
- 'haiku-4.5': 'anthropic/claude-haiku-4.5-20251001',
33
+ haiku: 'anthropic/claude-haiku-4.5',
34
+ 'haiku-4.5': 'anthropic/claude-haiku-4.5',
34
35
  // OpenAI
35
36
  // `gpt` / `gpt5` / `gpt-5` follow the gateway's flagship — currently 5.6 Sol.
36
37
  gpt: 'openai/gpt-5.6-sol',
@@ -64,9 +65,13 @@ export const MODEL_SHORTCUTS = {
64
65
  'gemini-3.5-flash': 'google/gemini-3.5-flash',
65
66
  'gemini-3': 'google/gemini-3.1-pro',
66
67
  'gemini-3.1': 'google/gemini-3.1-pro',
67
- // xAI — grok-4.3 is the public flagship since 2026-06-04 (grok-3 and the
68
- // fast families are hidden on the gateway; explicit IDs still resolve).
69
- grok: 'xai/grok-4.3',
68
+ // xAI — grok-4.5 is the public flagship since 2026-07-14; `grok` follows it
69
+ // per the bare-alias-tracks-flagship convention. 4.3 stays pinned: it's
70
+ // cheaper ($1.5/$4 vs $2.5/$9) and carries 1M context to 4.5's 500K, so it's
71
+ // the better pick for long-context work. (grok-3 and the fast families are
72
+ // hidden on the gateway; explicit IDs still resolve.)
73
+ grok: 'xai/grok-4.5',
74
+ 'grok-4.5': 'xai/grok-4.5',
70
75
  'grok-4.3': 'xai/grok-4.3',
71
76
  'grok-build': 'xai/grok-build-0.1',
72
77
  'grok-3': 'xai/grok-3',
@@ -98,7 +103,6 @@ export const MODEL_SHORTCUTS = {
98
103
  qwen3: 'nvidia/qwen3-next-80b-a3b-instruct',
99
104
  'qwen3-next': 'nvidia/qwen3-next-80b-a3b-instruct',
100
105
  'qwen3.5': 'nvidia/qwen3.5-122b-a10b',
101
- maverick: 'nvidia/llama-4-maverick',
102
106
  glm4: 'nvidia/qwen3-next-80b-a3b-instruct',
103
107
  'deepseek-free': 'nvidia/qwen3-next-80b-a3b-instruct',
104
108
  'qwen-coder': 'nvidia/qwen3-next-80b-a3b-instruct',
@@ -107,19 +111,24 @@ export const MODEL_SHORTCUTS = {
107
111
  'gpt-oss-small': 'nvidia/qwen3-next-80b-a3b-instruct',
108
112
  'mistral-small': 'nvidia/qwen3-next-80b-a3b-instruct',
109
113
  'mistral-nemotron': 'nvidia/mistral-nemotron',
110
- // llama shortcuts point at the still-live free maverick model (not the free
111
- // default — that's qwen3-next above). Kept as explicit aliases so the name
112
- // resolves for users who type it.
113
- llama: 'nvidia/llama-4-maverick',
114
- 'llama-4': 'nvidia/llama-4-maverick',
115
- 'llama-4-maverick': 'nvidia/llama-4-maverick',
114
+ // Maverick left the gateway catalog on/before 2026-07-14. The id still
115
+ // answers, but only because the free pool silently substitutes another model
116
+ // for it — so pointing users at it would be promising a model they don't get.
117
+ // Follow the established retired-free-id pattern instead: resolve to the
118
+ // current free default so muscle memory keeps working.
119
+ llama: 'nvidia/qwen3-next-80b-a3b-instruct',
120
+ 'llama-4': 'nvidia/qwen3-next-80b-a3b-instruct',
121
+ 'llama-4-maverick': 'nvidia/qwen3-next-80b-a3b-instruct',
122
+ maverick: 'nvidia/qwen3-next-80b-a3b-instruct',
116
123
  // Backward-compatibility aliases for models the gateway retired or exposes
117
124
  // unreliably on /v1/messages. Map to agent-tested free models so shortcuts
118
125
  // keep working without silent paid fallback or empty tool-use turns.
119
126
  // Map to the closest current free model so old session records + user
120
127
  // muscle memory keep working.
121
- nemotron: 'nvidia/llama-4-maverick',
122
- devstral: 'nvidia/llama-4-maverick',
128
+ // `nemotron` now resolves to the real Mistral Nemotron (in-catalog, and one
129
+ // of the few free ids that verifiably serves itself) rather than to Maverick.
130
+ nemotron: 'nvidia/mistral-nemotron',
131
+ devstral: 'nvidia/qwen3-next-80b-a3b-instruct',
123
132
  // Others
124
133
  minimax: 'minimax/minimax-m3',
125
134
  'm3': 'minimax/minimax-m3',
@@ -227,7 +236,7 @@ export const PICKER_CATEGORIES = [
227
236
  { id: 'openai/gpt-5.6-sol', shortcut: 'gpt', label: 'GPT-5.6 Sol', price: '$5/$30', highlight: true },
228
237
  { id: 'google/gemini-3.1-pro', shortcut: 'gemini-3', label: 'Gemini 3.1 Pro', price: '$2/$12' },
229
238
  { id: 'google/gemini-2.5-pro', shortcut: 'gemini', label: 'Gemini 2.5 Pro', price: '$1.25/$10' },
230
- { id: 'xai/grok-4.3', shortcut: 'grok', label: 'Grok 4.3', price: '$1.5/$4' },
239
+ { id: 'xai/grok-4.5', shortcut: 'grok', label: 'Grok 4.5', price: '$2.5/$9' },
231
240
  ],
232
241
  },
233
242
  {
@@ -249,7 +258,7 @@ export const PICKER_CATEGORIES = [
249
258
  {
250
259
  category: '💰 Budget',
251
260
  models: [
252
- { id: 'anthropic/claude-haiku-4.5-20251001', shortcut: 'haiku', label: 'Claude Haiku 4.5', price: '$1/$5' },
261
+ { id: 'anthropic/claude-haiku-4.5', shortcut: 'haiku', label: 'Claude Haiku 4.5', price: '$1/$5' },
253
262
  { id: 'openai/gpt-5-mini', shortcut: 'mini', label: 'GPT-5 Mini', price: '$0.25/$2' },
254
263
  { id: 'google/gemini-2.5-flash', shortcut: 'flash', label: 'Gemini 2.5 Flash', price: '$0.3/$2.5' },
255
264
  // Re-aliased to V4 Flash Chat upstream — context 1M, price 30% lower.
@@ -267,26 +276,124 @@ export const PICKER_CATEGORIES = [
267
276
  {
268
277
  category: '🆓 Free (no USDC needed)',
269
278
  models: [
270
- // Qwen3-Next 80B leads: cleanest free instruction-follower (no thinking
271
- // leak / markdown fences — verified live 2026-07-11) and the default the
272
- // `free` shortcut + free routing profile resolve to. Llama 4 Maverick is
273
- // the diverse-family secondary. (nvidia/deepseek-v4-flash removed
274
- // 2026-07-11: the gateway 410s on it.) Both are $0 — the free tier never
275
- // falls back to a paid model.
279
+ // Qwen3-Next 80B leads: it's what the `free` shortcut + free routing
280
+ // profile resolve to. Mistral Nemotron is the diverse-family secondary,
281
+ // promoted 2026-07-14 when nvidia/llama-4-maverick fell out of the
282
+ // gateway catalog. Both are $0 — the free tier never falls back to paid.
283
+ //
284
+ // Caveat worth knowing before editing this list: the NVIDIA free pool
285
+ // silently substitutes. Verified live 2026-07-14 — qwen3-next and
286
+ // mistral-large-3-675b both came back served by
287
+ // `nvidia/nemotron-3-super-120b-a12b-free`, so the free id you request
288
+ // is not necessarily the one you get. mistral-nemotron was picked as the
289
+ // secondary precisely because it does serve itself, consistently, and
290
+ // answers without leaking reasoning prose.
276
291
  { id: 'nvidia/qwen3-next-80b-a3b-instruct', shortcut: 'free', label: 'Qwen3-Next 80B', price: 'FREE', highlight: true },
277
- { id: 'nvidia/llama-4-maverick', shortcut: 'maverick', label: 'Llama 4 Maverick', price: 'FREE' },
292
+ { id: 'nvidia/mistral-nemotron', shortcut: 'nemotron', label: 'Mistral Nemotron', price: 'FREE' },
278
293
  ],
279
294
  },
280
295
  ];
281
296
  /** Flat list of all picker models (for index-based navigation). */
282
297
  export const PICKER_MODELS_FLAT = PICKER_CATEGORIES.flatMap(c => c.models);
283
- // Kept for backward compatibility with the readline pickModel() below.
284
- const PICKER_MODELS = PICKER_CATEGORIES;
298
+ // ─── Live hydration against the gateway catalog ────────────────────────────
299
+ /**
300
+ * Synthetic ids that are Franklin concepts, not gateway models (`blockrun/auto`
301
+ * is a routing profile resolved client-side). They never appear in the catalog,
302
+ * so they're exempt from the drop-if-absent rule below.
303
+ */
304
+ function isSyntheticId(id) {
305
+ return id.startsWith('blockrun/');
306
+ }
307
+ /** Render a gateway price object into the picker's display format. */
308
+ function formatPrice(m) {
309
+ const p = m.pricing;
310
+ switch (m.billing_mode) {
311
+ case 'free':
312
+ return 'FREE';
313
+ case 'paid':
314
+ return `$${p.input ?? 0}/$${p.output ?? 0}`;
315
+ case 'flat':
316
+ return `$${p.flat ?? 0} flat`;
317
+ default:
318
+ // Non-chat billing modes (per_image/per_second/…) shouldn't reach the
319
+ // picker, but don't invent a number if one does.
320
+ return '—';
321
+ }
322
+ }
323
+ /**
324
+ * The picker list, reconciled against the live gateway catalog.
325
+ *
326
+ * {@link PICKER_CATEGORIES} stays the editorial layer — which models are worth
327
+ * featuring, in what order, under which heading, with which shortcut. The
328
+ * gateway is the source of truth for everything factual: whether a model still
329
+ * exists, its display name, and its price. That split is deliberate: the
330
+ * gateway lists 57 chat models and the picker deliberately shows ~21 (see the
331
+ * v3.9.3 trim), so we can't just render the catalog.
332
+ *
333
+ * Reconciliation rules:
334
+ * - Curated row present in the catalog → refresh its label + price from the
335
+ * gateway, so a price change upstream can't leave a stale number on screen.
336
+ * - Curated row absent → drop it. This is the self-healing half: an id the
337
+ * gateway retired (the `claude-haiku-4.5-20251001` case) stops being
338
+ * offered without waiting on a Franklin release. Its MODEL_SHORTCUTS alias
339
+ * survives, matching the long-standing "hide the row, keep the shortcut"
340
+ * pattern.
341
+ * - Gateway unreachable → serve the static list verbatim (`live: false`).
342
+ * An offline picker showing a slightly stale list beats an empty one.
343
+ *
344
+ * Note the catalog hides some models that still resolve (grok-3 and the xAI
345
+ * fast family, for instance). Hidden-but-working ids are therefore dropped from
346
+ * the *visible* list while remaining reachable by typing the shortcut — which
347
+ * is the intended behavior, not a bug.
348
+ */
349
+ export async function getPickerCategories() {
350
+ try {
351
+ return reconcilePicker(await getGatewayModels());
352
+ }
353
+ catch {
354
+ return { categories: PICKER_CATEGORIES, moreCount: 0, live: false };
355
+ }
356
+ }
357
+ /**
358
+ * Pure reconciliation step behind {@link getPickerCategories} — exported so the
359
+ * rules can be tested against a synthetic catalog without touching the network.
360
+ */
361
+ export function reconcilePicker(catalog) {
362
+ const byId = new Map(catalog.map(m => [m.id, m]));
363
+ const categories = [];
364
+ const curated = new Set();
365
+ for (const cat of PICKER_CATEGORIES) {
366
+ const models = [];
367
+ for (const row of cat.models) {
368
+ curated.add(row.id);
369
+ if (isSyntheticId(row.id)) {
370
+ models.push(row);
371
+ continue;
372
+ }
373
+ const live = byId.get(row.id);
374
+ if (!live)
375
+ continue; // retired upstream — drop the row, keep the alias
376
+ // Price comes from the gateway (it's factual, it drifts, and it's the
377
+ // user's money). The label stays curated: gateway names are longer than
378
+ // the picker's tuned columns ("Qwen3-Next 80B Instruct (Free)" is 30
379
+ // chars against a 26-wide field) and carry redundant "(Free)" suffixes
380
+ // that the 🆓 heading already says.
381
+ models.push({ ...row, price: formatPrice(live) });
382
+ }
383
+ if (models.length > 0)
384
+ categories.push({ ...cat, models });
385
+ }
386
+ const moreCount = catalog.filter(m => m.categories?.includes('chat') && !curated.has(m.id)).length;
387
+ return { categories, moreCount, live: true };
388
+ }
285
389
  /**
286
390
  * Show interactive model picker. Returns the selected model ID.
287
391
  * Falls back to text input if terminal doesn't support raw mode.
288
392
  */
289
393
  export async function pickModel(currentModel) {
394
+ // Same gateway reconciliation the Ink picker gets — falls back to the static
395
+ // curation when the catalog is unreachable.
396
+ const { categories: PICKER_MODELS, moreCount } = await getPickerCategories();
290
397
  // Flatten for numbering
291
398
  const allModels = [];
292
399
  for (const cat of PICKER_MODELS) {
@@ -306,6 +413,9 @@ export async function pickModel(currentModel) {
306
413
  }
307
414
  console.error('');
308
415
  }
416
+ if (moreCount > 0) {
417
+ console.error(chalk.dim(` + ${moreCount} more on gateway — run \`franklin models\` to list them.\n`));
418
+ }
309
419
  console.error(chalk.dim(' Enter number, shortcut, or full model ID:'));
310
420
  // Read input
311
421
  const rl = readline.createInterface({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blockrun/franklin",
3
- "version": "3.32.0",
3
+ "version": "3.33.0",
4
4
  "description": "Franklin Agent — The AI agent with a wallet. Spends USDC autonomously to get real work done. Pay per action, no subscriptions.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -66,7 +66,7 @@
66
66
  "node": ">=20.19.0"
67
67
  },
68
68
  "dependencies": {
69
- "@blockrun/llm": "^2.0.0",
69
+ "@blockrun/llm": "^3.5.2",
70
70
  "@colbymchenry/codegraph": "^0.9.7",
71
71
  "@modelcontextprotocol/sdk": "^1.29.0",
72
72
  "@polymarket/builder-relayer-client": "^0.0.10",