@blockrun/franklin 3.46.0 → 3.48.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/pricing.d.ts CHANGED
@@ -1,17 +1,13 @@
1
- /**
2
- * Single source of truth for model pricing (per 1M tokens).
3
- * Used by agent loop, proxy server, stats tracker, and router.
4
- */
1
+ export declare function hasHistoricalPrice(model: string): boolean;
2
+ /** Gateway prices override historical fallbacks without replacing map identities. */
5
3
  export declare const MODEL_PRICING: Record<string, {
6
4
  input: number;
7
5
  output: number;
8
6
  perCall?: number;
9
7
  }>;
10
- /** Opus pricing for savings calculations — tracks the current flagship. */
11
8
  export declare const OPUS_PRICING: {
12
9
  input: number;
13
10
  output: number;
14
- perCall?: number;
15
11
  };
16
12
  /**
17
13
  * Estimate cost in USD for a request.
package/dist/pricing.js CHANGED
@@ -1,8 +1,9 @@
1
+ import { getModelCatalog, onModelCatalogChange } from './model-catalog.js';
1
2
  /**
2
3
  * Single source of truth for model pricing (per 1M tokens).
3
4
  * Used by agent loop, proxy server, stats tracker, and router.
4
5
  */
5
- export const MODEL_PRICING = {
6
+ const LEGACY_PRICING = {
6
7
  // Routing profiles (blended averages). Auto + Free are the only profiles
7
8
  // surfaced after the 2026-05-03 collapse; eco/premium were retired and
8
9
  // their parser mapping promotes them to Auto upstream of cost estimation.
@@ -47,6 +48,11 @@ export const MODEL_PRICING = {
47
48
  'nvidia/nemotron-3-super-120b': { input: 0, output: 0 },
48
49
  'nvidia/nemotron-super-49b': { input: 0, output: 0 },
49
50
  // Anthropic
51
+ // 2026-10 gateway additions (live /api/v1/models, 2026-10-02). Opus 5.5 and
52
+ // Sonnet 5.5 come in BELOW the 5.0 line; Fable 5.1 holds Fable 5's price.
53
+ 'anthropic/claude-fable-5.1': { input: 10.0, output: 50.0 },
54
+ 'anthropic/claude-opus-5.5': { input: 4.0, output: 20.0 },
55
+ 'anthropic/claude-sonnet-5.5': { input: 2.0, output: 10.0 },
50
56
  'anthropic/claude-fable-5': { input: 10.0, output: 50.0 }, // Mythos-class tier above Opus, 1M ctx
51
57
  // Opus 5 lands at the same $5/$25 as the 4.x Opus line — a straight upgrade
52
58
  // with no cost delta, so nothing downstream needs a pricing carve-out.
@@ -54,7 +60,7 @@ export const MODEL_PRICING = {
54
60
  'anthropic/claude-opus-4.8': { input: 5.0, output: 25.0 },
55
61
  'anthropic/claude-opus-4.7': { input: 5.0, output: 25.0 },
56
62
  'anthropic/claude-opus-4.5': { input: 5.0, output: 25.0 },
57
- 'anthropic/claude-sonnet-5': { input: 3.0, output: 15.0 }, // near-Opus at Sonnet cost, 1M ctx
63
+ 'anthropic/claude-sonnet-5': { input: 2.0, output: 10.0 }, // near-Opus at Sonnet cost, 1M ctx (live list 2026-10-02)
58
64
  'anthropic/claude-sonnet-4.6': { input: 3.0, output: 15.0 },
59
65
  'anthropic/claude-sonnet-4.5': { input: 3.0, output: 15.0 },
60
66
  'anthropic/claude-haiku-4.5': { input: 1.0, output: 5.0 },
@@ -62,6 +68,13 @@ export const MODEL_PRICING = {
62
68
  // Kept for cost lookup on sessions recorded before the switch.
63
69
  'anthropic/claude-haiku-4.5-20251001': { input: 1.0, output: 5.0 },
64
70
  // OpenAI
71
+ // GPT-6 family + GPT-5.1 (live catalog 2026-10-02). Base rates only: GPT-6
72
+ // bills 2x input / 1.5x output above 272K input tokens, which a flat
73
+ // per-1M table cannot express — the catalog's long_context tiers carry that.
74
+ 'openai/gpt-6-astra': { input: 10.0, output: 50.0 },
75
+ 'openai/gpt-6-sol': { input: 2.0, output: 10.0 },
76
+ 'openai/gpt-6-luna': { input: 0.1, output: 0.5 },
77
+ 'openai/gpt-5.1': { input: 1.25, output: 10.0 },
65
78
  'openai/gpt-4.1-nano': { input: 0.1, output: 0.4 },
66
79
  'openai/gpt-4o-mini': { input: 0.15, output: 0.6 },
67
80
  'openai/gpt-5.4-nano': { input: 0.2, output: 1.25 },
@@ -83,12 +96,12 @@ export const MODEL_PRICING = {
83
96
  'openai/o4-mini': { input: 1.1, output: 4.4 },
84
97
  'openai/o1': { input: 15.0, output: 60.0 },
85
98
  'openai/gpt-5.5': { input: 5.0, output: 30.0 },
86
- 'openai/gpt-5.6-sol': { input: 5.0, output: 30.0 }, // GPT-5.6 flagship, deepest reasoning, 1M ctx
99
+ 'openai/gpt-5.6-sol': { input: 4.0, output: 20.0 }, // GPT-5.6 flagship, 1M ctx — cut from $5/$30 on 2026-08-21
87
100
  // GPT-5.6 Pro tiers + 5.5 Pro + chat-latest, added upstream 2026-08-03
88
101
  // (base #329) — priced from the live catalog 2026-08-12.
89
- 'openai/gpt-5.6-luna-pro': { input: 0.1, output: 0.6 },
90
- 'openai/gpt-5.6-terra-pro': { input: 1.0, output: 6.0 },
91
- 'openai/gpt-5.6-sol-pro': { input: 5.0, output: 30.0 },
102
+ 'openai/gpt-5.6-luna-pro': { input: 0.2, output: 1.2 }, // = Luna list (live 2026-10-02)
103
+ 'openai/gpt-5.6-terra-pro': { input: 2.0, output: 12.0 }, // = Terra list (live 2026-10-02)
104
+ 'openai/gpt-5.6-sol-pro': { input: 4.0, output: 20.0 }, // cut from $5/$30 on 2026-08-21
92
105
  'openai/gpt-5.5-pro': { input: 30.0, output: 180.0 },
93
106
  'openai/chat-latest': { input: 5.0, output: 30.0 },
94
107
  'openai/gpt-5.2-pro': { input: 21.0, output: 168.0 },
@@ -102,20 +115,22 @@ export const MODEL_PRICING = {
102
115
  // Google's rate and corrected upstream (base #304) — mirror the real price.
103
116
  'google/gemini-3.5-flash': { input: 1.5, output: 9.0 }, // latest Flash w/ thinking, 1M ctx
104
117
  'google/gemini-3.5-flash-lite': { input: 0.3, output: 2.5 },
105
- 'google/gemini-3.6-flash': { input: 1.5, output: 7.5 }, // added upstream 2026-08-03 (base #329)
118
+ 'google/gemini-3.6-flash': { input: 0.75, output: 3.75 }, // added upstream 2026-08-03 (base #329); live promo rate 2026-10-02
106
119
  'google/gemini-2.5-pro': { input: 1.25, output: 10.0 },
107
120
  'google/gemini-3.1-pro': { input: 2.0, output: 12.0 },
108
121
  // xAI
109
122
  'xai/grok-4.3': { input: 1.25, output: 2.5 }, // 1M ctx; demoted from flagship 2026-07-14
110
- 'xai/grok-4.5': { input: 2.0, output: 6.0 }, // xAI flagship — 500K ctx (note: less than 4.3's 1M)
123
+ 'xai/grok-4.7': { input: 2.0, output: 6.0 }, // newest Grok, 500K ctx (2x at >=200K input)
124
+ 'xai/grok-4.6': { input: 2.0, output: 6.0 }, // 500K ctx (2x at >=200K input)
125
+ 'xai/grok-4.5': { input: 2.0, output: 6.0 }, // 500K ctx (note: less than 4.3's 1M)
111
126
  'xai/grok-build-0.1': { input: 1.0, output: 2.0 }, // agentic coding, OpenRouter resale
112
127
  // DeepSeek (gateway re-aliased these to V4 Flash on 2026-05-03; price cut
113
128
  // again upstream 2026-08-07 to $0.14/$0.28 — mirrored here 2026-08-12).
114
129
  'deepseek/deepseek-chat': { input: 0.14, output: 0.28 },
115
130
  'deepseek/deepseek-reasoner': { input: 0.14, output: 0.28 },
116
- // V4 Pro (1.6T MoE / 49B active, 1M ctx, 65K out). 75% launch promo
117
- // through 2026-05-31 — list is $2.00/$4.00, promo is $0.50/$1.00.
118
- 'deepseek/deepseek-v4-pro': { input: 0.435, output: 0.87 }, // 75% promo became permanent list after 2026-05-31
131
+ // V4 Pro (1.6T MoE / 49B active, 1M ctx, 65K out). Live list 2026-10-02;
132
+ // the old $0.435/$0.87 promo figure no longer matches the gateway.
133
+ 'deepseek/deepseek-v4-pro': { input: 1.32, output: 3.96 },
119
134
  // Minimax
120
135
  'minimax/minimax-m3': { input: 0.3, output: 1.2 },
121
136
  'minimax/minimax-m2.7': { input: 0.3, output: 1.2 },
@@ -124,7 +139,7 @@ export const MODEL_PRICING = {
124
139
  'qwen/qwen3.7-plus': { input: 0.32, output: 1.28 },
125
140
  'qwen/qwen3.7-flash': { input: 0.03, output: 0.13 },
126
141
  // New providers added upstream 2026-08 — priced from the live catalog.
127
- 'tencent/hy3': { input: 0.132, output: 0.528 },
142
+ 'tencent/hy3': { input: 0.132, output: 0.528 }, // retired upstream (hidden) — kept for session-cost records
128
143
  'xiaomi/mimo-v2.5-pro': { input: 0.435, output: 0.87 },
129
144
  // Moonshot — K3 is the gateway flagship (2026-07): 2.8T open MoE, 1M
130
145
  // context, multimodal (image+text), returns reasoning_content. Pricier
@@ -177,8 +192,20 @@ export const MODEL_PRICING = {
177
192
  'nvidia/kimi-k2.5': { input: 0.55, output: 2.5 },
178
193
  'zai/glm-5.1-turbo': { input: 1.2, output: 4.0 }, // was a client alias for zai/glm-5-turbo
179
194
  };
180
- /** Opus pricing for savings calculations — tracks the current flagship. */
181
- export const OPUS_PRICING = MODEL_PRICING['anthropic/claude-opus-5'];
195
+ export function hasHistoricalPrice(model) { return model in LEGACY_PRICING; }
196
+ /** Gateway prices override historical fallbacks without replacing map identities. */
197
+ export const MODEL_PRICING = {};
198
+ export const OPUS_PRICING = { input: 5, output: 25 };
199
+ function updatePrices(state) {
200
+ for (const key of Object.keys(MODEL_PRICING))
201
+ delete MODEL_PRICING[key];
202
+ Object.assign(MODEL_PRICING, LEGACY_PRICING, state.pricing);
203
+ const opus = MODEL_PRICING['anthropic/claude-opus-5'];
204
+ if (opus)
205
+ Object.assign(OPUS_PRICING, opus);
206
+ }
207
+ updatePrices(getModelCatalog());
208
+ onModelCatalogChange(updatePrices);
182
209
  /**
183
210
  * Estimate cost in USD for a request.
184
211
  * Falls back to $2/$10 per 1M for unknown models.
@@ -140,8 +140,9 @@ function normalizeRoutingContext(context) {
140
140
  }
141
141
  // ─── Tier Model Configs ───
142
142
  // Auto-routing strategy (post-DeepSeek-V4-Pro launch promo, 2026-05-03):
143
- // V4 Pro at $0.435/$0.87 with 1M context is the new sweet spot for SIMPLE +
144
- // MEDIUM agent work — Sonnet-quality reasoning at ~1/6 the price. Reserve
143
+ // V4 Pro (launched at $0.435/$0.87; $1.32/$3.96 list as of 2026-10-02) with
144
+ // 1M context is the sweet spot for SIMPLE + MEDIUM agent work — Sonnet-quality
145
+ // reasoning at well under Sonnet's price. Reserve
145
146
  // Opus only for genuinely complex multi-file/multi-decision tasks where
146
147
  // the model's wider context handling and tighter tool-use discipline still
147
148
  // pay for themselves. Sonnet drops to fallback because V4 Pro covers most
@@ -187,7 +188,7 @@ const AUTO_TIERS = {
187
188
  * if none of them have vision, escalates to COMPLEX (Opus is always vision).
188
189
  *
189
190
  * Note: only applied when the caller signals needsVision=true. Without that
190
- * hint the classic per-tier defaults still rule — V4 Pro's $0.435/$0.87 price
191
+ * hint the classic per-tier defaults still rule — V4 Pro's $1.32/$3.96 price
191
192
  * is the right SIMPLE/MEDIUM pick for text-only turns and we don't want to
192
193
  * blanket-upgrade everyone to a vision model.
193
194
  */
@@ -18,6 +18,8 @@
18
18
  * model — having no vision pathway — would hallucinate based on the
19
19
  * `Image file: <path>` description string. Expensive AND wrong.
20
20
  */
21
+ import { hasHistoricalPrice } from '../pricing.js';
22
+ import { getModelCatalog } from '../model-catalog.js';
21
23
  import { freeVisionModel } from '../free-models.js';
22
24
  const VISION_MODELS = new Set([
23
25
  // Anthropic — native vision across the line
@@ -34,6 +36,11 @@ const VISION_MODELS = new Set([
34
36
  'anthropic/claude-sonnet-4.6',
35
37
  'anthropic/claude-sonnet-4.5',
36
38
  'anthropic/claude-haiku-4.5',
39
+ // 2026-10 additions — vision-tagged in the live catalog. Listed after the
40
+ // existing rows so pickVisionSibling's same-family pick is unchanged.
41
+ 'anthropic/claude-fable-5.1',
42
+ 'anthropic/claude-opus-5.5',
43
+ 'anthropic/claude-sonnet-5.5',
37
44
  // OpenAI — multimodal flagships + o3 (Codex 5.3 is text-only, excluded).
38
45
  // GPT-5.6 family + 5.4-mini are vision; 5.4-nano is text-only.
39
46
  'openai/gpt-5.6-sol',
@@ -57,6 +64,11 @@ const VISION_MODELS = new Set([
57
64
  'openai/gpt-4.1',
58
65
  'openai/gpt-4o',
59
66
  'openai/o3',
67
+ // GPT-6 family + GPT-5.1 (2026-10, vision-tagged in the live catalog).
68
+ 'openai/gpt-6-astra',
69
+ 'openai/gpt-6-sol',
70
+ 'openai/gpt-6-luna',
71
+ 'openai/gpt-5.1',
60
72
  // Google — vision baked into every Gemini SKU we surface (flash-lite excepted)
61
73
  'google/gemini-3.1-pro',
62
74
  'google/gemini-3.6-flash',
@@ -73,6 +85,9 @@ const VISION_MODELS = new Set([
73
85
  'xai/grok-4.3',
74
86
  'xai/grok-4-0709',
75
87
  'xai/grok-3',
88
+ // Grok 4.7 / 4.6 (2026-10, vision-tagged in the live catalog).
89
+ 'xai/grok-4.7',
90
+ 'xai/grok-4.6',
76
91
  // Moonshot — K3 is the flagship; the K2.x line is hidden from /v1/models
77
92
  // but still served (probed 2026-08-29) and is catalogued as multimodal.
78
93
  'moonshot/kimi-k3',
@@ -120,7 +135,13 @@ export function isVisionModel(modelId) {
120
135
  // on gateway deploy state and on FRANKLIN_FREE_VISION_MODEL. freeVisionModel()
121
136
  // returns null when no free model can be trusted with an image, and this
122
137
  // stays false there.
123
- return modelId === freeVisionModel();
138
+ if (modelId === freeVisionModel())
139
+ return true;
140
+ // Preserve vetted exclusions for existing models; use metadata for new IDs.
141
+ if (hasHistoricalPrice(modelId))
142
+ return false;
143
+ const model = getModelCatalog().models.find(entry => entry.id === modelId);
144
+ return model?.billing_mode !== 'free' && model?.categories.includes('vision') === true;
124
145
  }
125
146
  /** Lower-cased copy used for prefix family matching in pickVisionSibling. */
126
147
  const VISION_MODELS_LIST = Array.from(VISION_MODELS);
@@ -20,7 +20,7 @@
20
20
  import { getOrCreateWallet, getOrCreateSolanaWallet, createPaymentPayload, createSolanaPaymentPayload, parsePaymentRequired, extractPaymentDetails, solanaKeyToBytes, SOLANA_NETWORK, } from '@blockrun/llm';
21
21
  import { loadChain, USER_AGENT } from '../config.js';
22
22
  import { resolveCharge } from '../payments/price-catalog.js';
23
- import { gatewayBase, gatewayHeaders } from '../payments/auth-mode.js';
23
+ import { gatewayBase, gatewayHeaders, walletMayPay } from '../payments/auth-mode.js';
24
24
  import { recordUsage } from '../stats/tracker.js';
25
25
  import { logger } from '../logger.js';
26
26
  const DEFAULT_TIMEOUT_MS = 30_000;
@@ -108,7 +108,7 @@ async function callGateway(url, method, body, resourceDescription, abortSignal,
108
108
  const payload = method === 'POST' && body !== undefined ? JSON.stringify(body) : undefined;
109
109
  let response = await fetch(url, { method, signal: ctrl.signal, headers, body: payload });
110
110
  let paidUsd = 0;
111
- if (response.status === 402) {
111
+ if (response.status === 402 && walletMayPay(headers)) {
112
112
  const signed = await signPayment(response, chain, url, resourceDescription);
113
113
  if (!signed) {
114
114
  return {
@@ -18,7 +18,7 @@
18
18
  import { getOrCreateWallet, getOrCreateSolanaWallet, createPaymentPayload, createSolanaPaymentPayload, parsePaymentRequired, extractPaymentDetails, solanaKeyToBytes, SOLANA_NETWORK, } from '@blockrun/llm';
19
19
  import { loadChain, VERSION } from '../config.js';
20
20
  import { chargeFromResponse, requestIdFromResponse, resolveCharge } from '../payments/price-catalog.js';
21
- import { gatewayBase, gatewayHeaders } from '../payments/auth-mode.js';
21
+ import { gatewayBase, gatewayHeaders, walletMayPay } from '../payments/auth-mode.js';
22
22
  import { logger } from '../logger.js';
23
23
  import { recordUsage } from '../stats/tracker.js';
24
24
  import { frameUntrusted } from './untrusted.js';
@@ -45,7 +45,7 @@ async function getWithPayment(path, ctx) {
45
45
  signal: controller.signal,
46
46
  headers,
47
47
  });
48
- if (response.status === 402) {
48
+ if (response.status === 402 && walletMayPay(headers)) {
49
49
  const signed = await signPayment(response, chain, endpoint);
50
50
  if (!signed) {
51
51
  throw new Error('Payment signing failed — check wallet balance');
package/dist/tools/exa.js CHANGED
@@ -20,7 +20,7 @@
20
20
  import { getOrCreateWallet, getOrCreateSolanaWallet, createPaymentPayload, createSolanaPaymentPayload, parsePaymentRequired, extractPaymentDetails, solanaKeyToBytes, SOLANA_NETWORK, } from '@blockrun/llm';
21
21
  import { loadChain, VERSION } from '../config.js';
22
22
  import { chargeFromResponse, resolveCharge } from '../payments/price-catalog.js';
23
- import { gatewayBase, gatewayHeaders } from '../payments/auth-mode.js';
23
+ import { gatewayBase, gatewayHeaders, walletMayPay } from '../payments/auth-mode.js';
24
24
  import { frameUntrusted } from './untrusted.js';
25
25
  import { recordUsage } from '../stats/tracker.js';
26
26
  import { logger } from '../logger.js';
@@ -48,7 +48,7 @@ async function postWithPayment(path, body, ctx) {
48
48
  body: bodyStr,
49
49
  });
50
50
  let settled = false;
51
- if (response.status === 402) {
51
+ if (response.status === 402 && walletMayPay(headers)) {
52
52
  const paymentHeaders = await signPayment(response, chain, endpoint);
53
53
  if (!paymentHeaders) {
54
54
  throw new Error('Payment signing failed — check wallet balance');
@@ -6,7 +6,7 @@ import fs from 'node:fs';
6
6
  import path from 'node:path';
7
7
  import { getOrCreateWallet, getOrCreateSolanaWallet, createPaymentPayload, createSolanaPaymentPayload, parsePaymentRequired, extractPaymentDetails, solanaKeyToBytes, SOLANA_NETWORK, } from '@blockrun/llm';
8
8
  import { loadChain, VERSION } from '../config.js';
9
- import { gatewayBase, gatewayHeaders } from '../payments/auth-mode.js';
9
+ import { gatewayBase, gatewayHeaders, walletMayPay } from '../payments/auth-mode.js';
10
10
  import { checkImageBudget, recordImageAsset } from '../content/record-image.js';
11
11
  import { estimateImageCostUsd } from '../content/image-pricing.js';
12
12
  import { recordUsage } from '../stats/tracker.js';
@@ -357,7 +357,7 @@ function buildExecute(deps) {
357
357
  // re-presents the same authorization (the gateway settles on the
358
358
  // first completed poll, same contract as videogen.ts:251).
359
359
  let paymentHeaders = null;
360
- if (response.status === 402) {
360
+ if (response.status === 402 && walletMayPay(headers)) {
361
361
  paymentHeaders = await signPayment(response, chain, endpoint);
362
362
  if (!paymentHeaders) {
363
363
  return { output: 'Payment failed. Check wallet balance with: franklin balance', isError: true };
@@ -27,7 +27,7 @@
27
27
  */
28
28
  import { getOrCreateWallet, getOrCreateSolanaWallet, createPaymentPayload, createSolanaPaymentPayload, parsePaymentRequired, extractPaymentDetails, solanaKeyToBytes, SOLANA_NETWORK, } from '@blockrun/llm';
29
29
  import { loadChain, VERSION, DASHBOARD_URL } from '../config.js';
30
- import { gatewayBase, gatewayHeaders, isKeyMode } from '../payments/auth-mode.js';
30
+ import { gatewayBase, gatewayHeaders, isKeyMode, walletMayPay } from '../payments/auth-mode.js';
31
31
  import { walletReservation, AMBIGUOUS_GRACE_MS } from '../wallet/reservation.js';
32
32
  import { recordUsage } from '../stats/tracker.js';
33
33
  import { logger } from '../logger.js';
@@ -151,7 +151,7 @@ export async function postWithPayment(endpoint, body, resourceDescription, abort
151
151
  try {
152
152
  const payload = JSON.stringify(body);
153
153
  let response = await fetch(endpoint, { method: 'POST', signal: ctrl.signal, headers, body: payload });
154
- if (response.status === 402) {
154
+ if (response.status === 402 && walletMayPay(headers)) {
155
155
  const paymentHeaders = await paymentSigner(response, chain, endpoint, resourceDescription);
156
156
  if (!paymentHeaders) {
157
157
  return { ok: false, status: 402, body: { error: 'payment signing failed' }, raw: '' };
@@ -17,7 +17,7 @@ import fs from 'node:fs';
17
17
  import path from 'node:path';
18
18
  import { getOrCreateWallet, getOrCreateSolanaWallet, createPaymentPayload, createSolanaPaymentPayload, parsePaymentRequired, extractPaymentDetails, solanaKeyToBytes, SOLANA_NETWORK, } from '@blockrun/llm';
19
19
  import { loadChain, VERSION } from '../config.js';
20
- import { gatewayBase, gatewayHeaders } from '../payments/auth-mode.js';
20
+ import { gatewayBase, gatewayHeaders, walletMayPay } from '../payments/auth-mode.js';
21
21
  import { logger } from '../logger.js';
22
22
  import { isWalletKeyPath } from './sensitive-paths.js';
23
23
  import { findModel, estimateCostUsd } from '../gateway-models.js';
@@ -111,7 +111,7 @@ function buildExecute(deps) {
111
111
  headers,
112
112
  body,
113
113
  });
114
- if (response.status === 402) {
114
+ if (response.status === 402 && walletMayPay(headers)) {
115
115
  const paymentHeaders = await signPayment(response, chain, endpoint);
116
116
  if (!paymentHeaders) {
117
117
  return { output: 'Payment failed. Check wallet balance with: franklin balance', isError: true };
@@ -13,7 +13,7 @@
13
13
  */
14
14
  import { getOrCreateWallet, getOrCreateSolanaWallet, createPaymentPayload, createSolanaPaymentPayload, parsePaymentRequired, extractPaymentDetails, solanaKeyToBytes, SOLANA_NETWORK, } from '@blockrun/llm';
15
15
  import { loadChain, VERSION } from '../config.js';
16
- import { gatewayBase, gatewayHeaders } from '../payments/auth-mode.js';
16
+ import { gatewayBase, gatewayHeaders, walletMayPay } from '../payments/auth-mode.js';
17
17
  import { logger } from '../logger.js';
18
18
  import { recordUsage } from '../stats/tracker.js';
19
19
  import { chargedNote, noChargeNote, cancelHint } from '../payments/billing-copy.js';
@@ -40,7 +40,7 @@ async function postWithPayment(path, body, ctx, meta) {
40
40
  headers,
41
41
  body: bodyStr,
42
42
  });
43
- if (response.status === 402) {
43
+ if (response.status === 402 && walletMayPay(headers)) {
44
44
  const paymentHeaders = await signPayment(response, chain, endpoint, 'Franklin phone');
45
45
  if (!paymentHeaders)
46
46
  throw new Error('Payment signing failed — check wallet balance');
@@ -38,7 +38,7 @@
38
38
  import { getOrCreateWallet, getOrCreateSolanaWallet, createPaymentPayload, createSolanaPaymentPayload, parsePaymentRequired, extractPaymentDetails, solanaKeyToBytes, SOLANA_NETWORK, } from '@blockrun/llm';
39
39
  import { loadChain, VERSION } from '../config.js';
40
40
  import { chargeFromResponse, requestIdFromResponse, resolveCharge } from '../payments/price-catalog.js';
41
- import { gatewayBase, gatewayHeaders } from '../payments/auth-mode.js';
41
+ import { gatewayBase, gatewayHeaders, walletMayPay } from '../payments/auth-mode.js';
42
42
  import { logger } from '../logger.js';
43
43
  import { recordFetch } from '../trading/providers/telemetry.js';
44
44
  import { recordUsage } from '../stats/tracker.js';
@@ -92,7 +92,7 @@ async function getWithPayment(path, query, ctx) {
92
92
  let costRecorded = 0;
93
93
  try {
94
94
  let response = await fetch(endpoint, { method: 'GET', signal: controller.signal, headers });
95
- if (response.status === 402) {
95
+ if (response.status === 402 && walletMayPay(headers)) {
96
96
  const paymentHeaders = await signPayment(response, chain, endpoint);
97
97
  if (!paymentHeaders) {
98
98
  throw new Error('Payment signing failed — check wallet balance');
@@ -28,7 +28,7 @@
28
28
  import { getOrCreateWallet, getOrCreateSolanaWallet, createPaymentPayload, createSolanaPaymentPayload, parsePaymentRequired, extractPaymentDetails, solanaKeyToBytes, SOLANA_NETWORK, } from '@blockrun/llm';
29
29
  import { loadChain, USER_AGENT } from '../config.js';
30
30
  import { chargeFromResponse, requestIdFromResponse, resolveCharge } from '../payments/price-catalog.js';
31
- import { gatewayBase, gatewayHeaders } from '../payments/auth-mode.js';
31
+ import { gatewayBase, gatewayHeaders, walletMayPay } from '../payments/auth-mode.js';
32
32
  import { recordUsage } from '../stats/tracker.js';
33
33
  import { logger } from '../logger.js';
34
34
  const REQUEST_TIMEOUT_MS = 60_000;
@@ -179,7 +179,7 @@ async function actionEnroll(base, chain, input, ctx) {
179
179
  const start = Date.now();
180
180
  let res = await timedFetch(url, { method: 'POST', headers, body }, ctx);
181
181
  let paidUsd = 0;
182
- if (res.status === 402) {
182
+ if (res.status === 402 && walletMayPay(headers)) {
183
183
  const signed = await signPayment(res, chain, url, `RealFace enrollment — "${name.slice(0, 32)}"`);
184
184
  if (!signed)
185
185
  return { output: 'RealFace enroll: payment signing failed. Check wallet balance with `franklin balance`.', isError: true };
package/dist/tools/rpc.js CHANGED
@@ -19,7 +19,7 @@
19
19
  import { getOrCreateWallet, getOrCreateSolanaWallet, createPaymentPayload, createSolanaPaymentPayload, parsePaymentRequired, extractPaymentDetails, solanaKeyToBytes, SOLANA_NETWORK, } from '@blockrun/llm';
20
20
  import { loadChain, VERSION } from '../config.js';
21
21
  import { chargeFromResponse, requestIdFromResponse, resolveCharge } from '../payments/price-catalog.js';
22
- import { gatewayBase, gatewayHeaders } from '../payments/auth-mode.js';
22
+ import { gatewayBase, gatewayHeaders, walletMayPay } from '../payments/auth-mode.js';
23
23
  import { logger } from '../logger.js';
24
24
  import { recordUsage } from '../stats/tracker.js';
25
25
  const TIMEOUT_MS = 30_000;
@@ -70,7 +70,7 @@ async function postRpcWithPayment(network, jsonRpcBody, ctx) {
70
70
  headers,
71
71
  body: bodyStr,
72
72
  });
73
- if (response.status === 402) {
73
+ if (response.status === 402 && walletMayPay(headers)) {
74
74
  const signed = await signPayment(response, chain, endpoint);
75
75
  if (!signed) {
76
76
  throw new Error('Payment signing failed — check wallet balance');
@@ -19,7 +19,7 @@ import { getOrCreateWallet, getOrCreateSolanaWallet, createPaymentPayload, creat
19
19
  import { loadChain, USER_AGENT } from '../config.js';
20
20
  import { basePriceForPath, chargeFromResponse, requestIdFromResponse, resolveCharge } from '../payments/price-catalog.js';
21
21
  import { GATEWAY_TRANSACTION_FEE_USD } from '../gateway-models.js';
22
- import { gatewayBase, gatewayHeaders } from '../payments/auth-mode.js';
22
+ import { gatewayBase, gatewayHeaders, walletMayPay } from '../payments/auth-mode.js';
23
23
  import { frameUntrusted } from './untrusted.js';
24
24
  import { recordUsage } from '../stats/tracker.js';
25
25
  import { logger } from '../logger.js';
@@ -198,7 +198,7 @@ async function callSurf(toolName, table, input, ctx) {
198
198
  try {
199
199
  let response = await fetch(url, { method: entry.method, signal: ctrl.signal, headers, body: payload });
200
200
  let paidUsd = 0;
201
- if (response.status === 402) {
201
+ if (response.status === 402 && walletMayPay(headers)) {
202
202
  const signed = await signPayment(response, chain, url, resourceDescription);
203
203
  if (!signed)
204
204
  return { output: `${toolName} ${endpoint}: payment signing failed`, isError: true };
@@ -23,7 +23,7 @@ import fs from 'node:fs';
23
23
  import path from 'node:path';
24
24
  import { getOrCreateWallet, getOrCreateSolanaWallet, createPaymentPayload, createSolanaPaymentPayload, parsePaymentRequired, extractPaymentDetails, solanaKeyToBytes, SOLANA_NETWORK, } from '@blockrun/llm';
25
25
  import { loadChain, VERSION } from '../config.js';
26
- import { gatewayBase, gatewayHeaders } from '../payments/auth-mode.js';
26
+ import { gatewayBase, gatewayHeaders, walletMayPay } from '../payments/auth-mode.js';
27
27
  import { logger } from '../logger.js';
28
28
  import { resolveReferenceImage } from './imagegen.js';
29
29
  import { isWalletKeyPath } from './sensitive-paths.js';
@@ -217,7 +217,7 @@ function buildExecute(deps) {
217
217
  headers,
218
218
  body,
219
219
  });
220
- if (response.status === 402) {
220
+ if (response.status === 402 && walletMayPay(headers)) {
221
221
  paymentHeaders = await signPayment(response, chain, endpoint);
222
222
  if (!paymentHeaders) {
223
223
  return { output: 'Payment failed. Check wallet balance with: franklin balance', isError: true };
@@ -16,7 +16,7 @@
16
16
  */
17
17
  import { getOrCreateWallet, getOrCreateSolanaWallet, createPaymentPayload, createSolanaPaymentPayload, parsePaymentRequired, extractPaymentDetails, solanaKeyToBytes, SOLANA_NETWORK, } from '@blockrun/llm';
18
18
  import { loadChain, VERSION } from '../config.js';
19
- import { gatewayBase, gatewayHeaders } from '../payments/auth-mode.js';
19
+ import { gatewayBase, gatewayHeaders, walletMayPay } from '../payments/auth-mode.js';
20
20
  import { logger } from '../logger.js';
21
21
  import { recordUsage } from '../stats/tracker.js';
22
22
  import { frameUntrusted } from './untrusted.js';
@@ -78,7 +78,7 @@ async function postWithPayment(path, body, ctx, meta) {
78
78
  headers,
79
79
  body: bodyStr,
80
80
  });
81
- if (response.status === 402) {
81
+ if (response.status === 402 && walletMayPay(headers)) {
82
82
  const paymentHeaders = await signPayment(response, chain, endpoint);
83
83
  if (!paymentHeaders)
84
84
  throw new Error('Payment signing failed — check wallet balance');
@@ -14,7 +14,7 @@
14
14
  * together with the x402 signing wrapper.
15
15
  */
16
16
  import { USER_AGENT, loadChain } from '../../../config.js';
17
- import { gatewayHeaders, resolvePayMode } from '../../../payments/auth-mode.js';
17
+ import { gatewayHeaders, resolvePayMode, walletMayPay } from '../../../payments/auth-mode.js';
18
18
  import { recordFetch } from '../telemetry.js';
19
19
  import { getOrCreateWallet, getOrCreateSolanaWallet, createPaymentPayload, createSolanaPaymentPayload, parsePaymentRequired, extractPaymentDetails, solanaKeyToBytes, SOLANA_NETWORK, } from '@blockrun/llm';
20
20
  const TIMEOUT_MS = 10_000;
@@ -190,7 +190,7 @@ export async function blockrunGetPaid(path, opts) {
190
190
  };
191
191
  try {
192
192
  let res = await fetch(url, { headers, signal: ctrl.signal });
193
- if (res.status === 402) {
193
+ if (res.status === 402 && walletMayPay(headers)) {
194
194
  try {
195
195
  const paid = await signGatewayPayment(res, chain, url);
196
196
  if (!paid) {
@@ -3,7 +3,6 @@
3
3
  * Shows categorized model list, supports shortcuts and arrow-key selection.
4
4
  */
5
5
  import { type GatewayModel } from '../gateway-models.js';
6
- export declare const MODEL_SHORTCUTS: Record<string, string>;
7
6
  /**
8
7
  * Resolve a model name — supports shortcuts. Returns the canonical model id.
9
8
  *
@@ -53,8 +52,8 @@ export interface ModelCategory {
53
52
  * (pickModel() below) import from this array. To add or remove models,
54
53
  * edit this one place.
55
54
  */
55
+ export declare const MODEL_SHORTCUTS: Record<string, string>;
56
56
  export declare const PICKER_CATEGORIES: ModelCategory[];
57
- /** Flat list of all picker models (for index-based navigation). */
58
57
  export declare const PICKER_MODELS_FLAT: ModelEntry[];
59
58
  export interface HydratedPicker {
60
59
  categories: ModelCategory[];