@blockrun/franklin 3.47.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/README.md +31 -15
- package/dist/agent/context.js +1 -1
- package/dist/agent/intent-prefetch.js +4 -3
- package/dist/agent/llm.js +6 -6
- package/dist/agent/tokens.js +13 -0
- package/dist/commands/models.js +3 -2
- package/dist/gateway-models.d.ts +11 -5
- package/dist/gateway-models.js +11 -5
- package/dist/payments/auth-mode.d.ts +9 -0
- package/dist/payments/auth-mode.js +11 -0
- package/dist/pricing.js +25 -11
- package/dist/router/index.js +4 -3
- package/dist/router/vision.js +13 -0
- package/dist/tools/blockrun.js +2 -2
- package/dist/tools/defillama.js +2 -2
- package/dist/tools/exa.js +2 -2
- package/dist/tools/imagegen.js +2 -2
- package/dist/tools/modal.js +2 -2
- package/dist/tools/musicgen.js +2 -2
- package/dist/tools/phone.js +2 -2
- package/dist/tools/prediction.js +2 -2
- package/dist/tools/realface.js +2 -2
- package/dist/tools/rpc.js +2 -2
- package/dist/tools/surf.js +2 -2
- package/dist/tools/videogen.js +2 -2
- package/dist/tools/voice.js +2 -2
- package/dist/trading/providers/blockrun/client.js +2 -2
- package/dist/ui/model-picker.js +17 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -54,8 +54,8 @@ Built by the [BlockRun](https://blockrun.ai) team. Apache-2.0. TypeScript. Ships
|
|
|
54
54
|
> **YOPO — You Only Pay Outcome**
|
|
55
55
|
>
|
|
56
56
|
> Not a subscription (pay for access). Not a generic pay-per-call (pay for trying).
|
|
57
|
-
> You pay only for the work Franklin Agent delivers.
|
|
58
|
-
> in USDC. No monthly fees. No rate limits. No overdraft.
|
|
57
|
+
> You pay only for the work Franklin Agent delivers. Chat is provider cost with no markup, plus $0.001
|
|
58
|
+
> per call; media carries 5%. Settled per action in USDC. No monthly fees. No rate limits. No overdraft.
|
|
59
59
|
|
|
60
60
|
---
|
|
61
61
|
|
|
@@ -248,7 +248,7 @@ use the [dashboard](https://user.blockrun.ai/dashboard).
|
|
|
248
248
|
| ----------------------- | -------------------------------------------- | ------------------------------------ |
|
|
249
249
|
| AI subscription | Access. Paid whether you use it or not. | $20–200/month, rate-limited. |
|
|
250
250
|
| Pay-per-call (OpenAI API, etc.) | Every attempt — even failed ones. | Hidden cost from retries, dead ends. |
|
|
251
|
-
| **Franklin Agent (YOPO)** | **The outcome.** Each signed micropayment. | **Provider cost + 5
|
|
251
|
+
| **Franklin Agent (YOPO)** | **The outcome.** Each signed micropayment. | **Provider cost on chat, no markup, + $0.001/call. Media +5%.** |
|
|
252
252
|
|
|
253
253
|
Three consequences fall out of this:
|
|
254
254
|
|
|
@@ -544,6 +544,12 @@ Core is workflow-agnostic. Add new verticals without touching the loop. Discover
|
|
|
544
544
|
| `/insights [--days N]` | Rich usage analytics |
|
|
545
545
|
| `/help` | Full command list |
|
|
546
546
|
|
|
547
|
+
`/model` takes a shortcut or any full gateway id. The newest models have
|
|
548
|
+
explicit version shortcuts: `opus-5.5`, `sonnet-5.5`, `fable-5.1`,
|
|
549
|
+
`gpt-6-astra`, `gpt-6-sol`, `gpt-6-luna`, `gpt-5.1`, `grok-4.7` and `grok-4.6`
|
|
550
|
+
(e.g. `/model gpt-6-sol` or `/model anthropic/claude-opus-5.5`). Bare aliases
|
|
551
|
+
like `opus`, `gpt` and `grok` keep their current targets.
|
|
552
|
+
|
|
547
553
|
---
|
|
548
554
|
|
|
549
555
|
## How it works
|
|
@@ -719,20 +725,30 @@ For the recommended live validation order and failure triage, see [docs/live-e2e
|
|
|
719
725
|
|
|
720
726
|
Franklin uses [BlockRun Model Core](https://github.com/BlockRunAI/model-catalog)
|
|
721
727
|
for model metadata, picker policy and price estimates. The runtime dependency
|
|
722
|
-
is pinned to an immutable commit. On refresh, Franklin reads the public
|
|
728
|
+
is pinned to an immutable commit. On refresh, Franklin reads the public policy
|
|
723
729
|
snapshot and the active gateway's catalog, so new models and prices can appear
|
|
724
730
|
without a Franklin release. Base, Solana and API accounts have separate caches.
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
731
|
+
The default picker shows Auto and curated groups; other available chat models
|
|
732
|
+
remain accessible through +more / Ctrl+A.
|
|
733
|
+
|
|
734
|
+
Existing Franklin shortcuts, including free aliases, retain their model targets.
|
|
735
|
+
Shared policy can add new shortcuts but cannot retarget one Franklin already
|
|
736
|
+
ships. Gateway price estimates still refresh for the selected model; a stable
|
|
737
|
+
shortcut does not freeze that model's price. Historical explicit IDs and cost
|
|
738
|
+
records remain usable.
|
|
739
|
+
|
|
740
|
+
Policy and gateway requests run concurrently, each with a four-second deadline.
|
|
741
|
+
Successful refreshes are cached for five minutes. If the policy host is
|
|
742
|
+
unreachable, Franklin keeps the last good policy and still refreshes live gateway
|
|
743
|
+
rows. If the gateway fails, the last valid catalog is retained; a cold start can
|
|
744
|
+
use the bundled snapshot, which is not presented as live gateway data. CLI
|
|
745
|
+
startup warms the catalog in the background.
|
|
746
|
+
|
|
747
|
+
`BLOCKRUN_MODEL_CATALOG_URL` overrides the policy snapshot URL; an empty value
|
|
748
|
+
disables remote policy updates. `FRANKLIN_CATALOG_OFFLINE=1` uses bundled data
|
|
749
|
+
without catalog network requests. Payment signing and settlement remain in
|
|
750
|
+
Franklin and its payment SDK. Auto routing's candidate policy remains separate
|
|
751
|
+
from the shared catalog.
|
|
736
752
|
|
|
737
753
|
## License
|
|
738
754
|
|
package/dist/agent/context.js
CHANGED
|
@@ -279,7 +279,7 @@ Use the built-in tools so the right host and credential are applied. Never switc
|
|
|
279
279
|
- \`GET /.well-known/x402\` — x402 resource list with prices
|
|
280
280
|
|
|
281
281
|
**LLM (POST, billed to ${chargedBy})**
|
|
282
|
-
- \`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-08-30: \`anthropic/claude-sonnet-5\`, \`anthropic/claude-opus-5\`, \`openai/gpt-5.6-sol\`, \`deepseek/deepseek-v4-pro\`, \`zai/glm-5.3\`, \`zai/glm-5.3-flash\`, \`xai/grok-4.5\`, \`qwen/qwen3.7-flash\`, \`nvidia/nemotron-3-nano-omni-30b-a3b-reasoning\` (free, the only free id on BOTH the Base and Solana gateways — the other free models are Base-only)). Do NOT invent versions like \`openai/gpt-
|
|
282
|
+
- \`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-08-30: \`anthropic/claude-sonnet-5\`, \`anthropic/claude-opus-5\`, \`openai/gpt-5.6-sol\`, \`deepseek/deepseek-v4-pro\`, \`zai/glm-5.3\`, \`zai/glm-5.3-flash\`, \`xai/grok-4.5\`, \`qwen/qwen3.7-flash\`, \`nvidia/nemotron-3-nano-omni-30b-a3b-reasoning\` (free, the only free id on BOTH the Base and Solana gateways — the other free models are Base-only)). Do NOT invent versions like \`openai/gpt-7\` 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.
|
|
283
283
|
- \`POST /v1/messages\` — Anthropic-compatible. Body: \`{ model, messages, max_tokens, system?, tools? }\`.
|
|
284
284
|
|
|
285
285
|
**Media (POST, billed to ${chargedBy}; GET to poll async jobs)**
|
|
@@ -158,16 +158,17 @@ async function exaAnswerTry(query, client) {
|
|
|
158
158
|
// tool framework because prefetch runs outside the agent loop — no
|
|
159
159
|
// permission prompt, no streaming.
|
|
160
160
|
const { loadChain } = await import('../config.js');
|
|
161
|
-
const { gatewayBase, gatewayHeaders } = await import('../payments/auth-mode.js');
|
|
161
|
+
const { gatewayBase, gatewayHeaders, walletMayPay } = await import('../payments/auth-mode.js');
|
|
162
162
|
const chain = loadChain();
|
|
163
163
|
const apiUrl = gatewayBase();
|
|
164
164
|
void client; // (future: unify the paid-endpoint client so we reuse wallet caching)
|
|
165
|
+
const requestHeaders = { 'Content-Type': 'application/json', ...gatewayHeaders() };
|
|
165
166
|
const res = await fetch(`${apiUrl}/v1/exa/answer`, {
|
|
166
167
|
method: 'POST',
|
|
167
|
-
headers:
|
|
168
|
+
headers: requestHeaders,
|
|
168
169
|
body: JSON.stringify({ query }),
|
|
169
170
|
});
|
|
170
|
-
if (res.status === 402) {
|
|
171
|
+
if (res.status === 402 && walletMayPay(requestHeaders)) {
|
|
171
172
|
const payHdr = await extractPaymentReq(res);
|
|
172
173
|
if (!payHdr)
|
|
173
174
|
return { text: null, costUsd: 0 };
|
package/dist/agent/llm.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { getOrCreateWallet, getOrCreateSolanaWallet, createPaymentPayload, createSolanaPaymentPayload, parsePaymentRequired, extractPaymentDetails, solanaKeyToBytes, SOLANA_NETWORK, } from '@blockrun/llm';
|
|
7
7
|
import { USER_AGENT } from '../config.js';
|
|
8
|
-
import { gatewayHeaders } from '../payments/auth-mode.js';
|
|
8
|
+
import { gatewayHeaders, walletMayPay } from '../payments/auth-mode.js';
|
|
9
9
|
import { appendSettlementRow } from '../stats/cost-log.js';
|
|
10
10
|
import { routeRequest, parseRoutingProfile } from '../router/index.js';
|
|
11
11
|
import { ThinkTagStripper } from './think-tag-stripper.js';
|
|
@@ -657,10 +657,9 @@ export class ModelClient {
|
|
|
657
657
|
body,
|
|
658
658
|
signal: requestController.signal,
|
|
659
659
|
}), requestController, createModelTimeoutError('request', request.model, requestTimeoutMs), requestTimeoutMs);
|
|
660
|
-
// Handle x402 payment
|
|
661
|
-
//
|
|
662
|
-
|
|
663
|
-
if (response.status === 402 && !headers.Authorization) {
|
|
660
|
+
// Handle x402 payment. An account 402 is a credit refusal, never a
|
|
661
|
+
// challenge the wallet may answer.
|
|
662
|
+
if (response.status === 402 && walletMayPay(headers)) {
|
|
664
663
|
if (this.debug)
|
|
665
664
|
console.error('[franklin] Payment required — signing...');
|
|
666
665
|
const signedPayment = await this.signPayment(response, request.model);
|
|
@@ -734,7 +733,8 @@ export class ModelClient {
|
|
|
734
733
|
body: retryBody,
|
|
735
734
|
signal: requestController.signal,
|
|
736
735
|
}), requestController, createModelTimeoutError('request', request.model, requestTimeoutMs), requestTimeoutMs);
|
|
737
|
-
|
|
736
|
+
// A retry must preserve the request's original payment rail too.
|
|
737
|
+
if (response.status === 402 && walletMayPay(headers)) {
|
|
738
738
|
const signedPayment = await this.signPayment(response, request.model);
|
|
739
739
|
if (!signedPayment) {
|
|
740
740
|
yield { kind: 'error', payload: { message: 'Payment signing failed' } };
|
package/dist/agent/tokens.js
CHANGED
|
@@ -199,6 +199,11 @@ const MODEL_CONTEXT_WINDOWS = {
|
|
|
199
199
|
// a real >200k call has been verified end-to-end.
|
|
200
200
|
// Fable 5 / Sonnet 5 advertise 1M at the gateway; keep the 200k safe baseline
|
|
201
201
|
// (same rationale as Opus above) until a real >200k call is verified.
|
|
202
|
+
// Fable 5.1 / Opus 5.5 / Sonnet 5.5 (2026-10) also advertise 1M; same
|
|
203
|
+
// 200k baseline. Without a row the live catalog's 1M would win here.
|
|
204
|
+
'anthropic/claude-fable-5.1': 200_000,
|
|
205
|
+
'anthropic/claude-opus-5.5': 200_000,
|
|
206
|
+
'anthropic/claude-sonnet-5.5': 200_000,
|
|
202
207
|
'anthropic/claude-fable-5': 200_000,
|
|
203
208
|
'anthropic/claude-opus-5': 200_000,
|
|
204
209
|
'anthropic/claude-opus-4.8': 200_000,
|
|
@@ -217,6 +222,12 @@ const MODEL_CONTEXT_WINDOWS = {
|
|
|
217
222
|
// gpt-5.5 advertises 1.05M context at the gateway, but Franklin keeps the
|
|
218
223
|
// conservative 128k baseline matching every other gpt-5.x line — bump in
|
|
219
224
|
// a separate change once a real >128k call has been verified end-to-end.
|
|
225
|
+
// GPT-6 (1.05M advertised; input above 272K bills at 2x) and GPT-5.1 (400K
|
|
226
|
+
// advertised) take the same 128k baseline until verified end-to-end.
|
|
227
|
+
'openai/gpt-6-astra': 128_000,
|
|
228
|
+
'openai/gpt-6-sol': 128_000,
|
|
229
|
+
'openai/gpt-6-luna': 128_000,
|
|
230
|
+
'openai/gpt-5.1': 128_000,
|
|
220
231
|
'openai/gpt-5.6-sol': 128_000,
|
|
221
232
|
'openai/gpt-5.6-terra': 128_000,
|
|
222
233
|
'openai/gpt-5.6-luna': 128_000,
|
|
@@ -256,6 +267,8 @@ const MODEL_CONTEXT_WINDOWS = {
|
|
|
256
267
|
// xAI. grok-4.5 / 4.3 / build were missing until 2026-08-20: neither matches
|
|
257
268
|
// any inference pattern below, so a cold catalog cache fell through to the
|
|
258
269
|
// blind 128k default and compacted a 500K–1M window ~4-8x too early.
|
|
270
|
+
'xai/grok-4.7': 500_000,
|
|
271
|
+
'xai/grok-4.6': 500_000,
|
|
259
272
|
'xai/grok-4.5': 500_000,
|
|
260
273
|
'xai/grok-4.3': 1_000_000,
|
|
261
274
|
'xai/grok-build-0.1': 256_000,
|
package/dist/commands/models.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import { loadChain } from '../config.js';
|
|
3
3
|
import { gatewayBase } from '../payments/auth-mode.js';
|
|
4
|
-
import { getGatewayModels, GATEWAY_MARGIN, } from '../gateway-models.js';
|
|
4
|
+
import { getGatewayModels, GATEWAY_MARGIN, GATEWAY_TRANSACTION_FEE_USD, } from '../gateway-models.js';
|
|
5
5
|
/**
|
|
6
6
|
* `franklin models` — the live catalog.
|
|
7
7
|
*
|
|
@@ -172,6 +172,7 @@ export async function modelsCommand() {
|
|
|
172
172
|
const unknown = models.filter(m => !known.has(m.billing_mode));
|
|
173
173
|
printSection('Other billing modes (not yet modelled by this Franklin build)', unknown, m => chalk.dim(`${m.billing_mode}: ${JSON.stringify(m.pricing)}`));
|
|
174
174
|
const margin = Math.round((GATEWAY_MARGIN - 1) * 100);
|
|
175
|
-
console.log(chalk.dim(`${models.length} models available. Prices are gateway list —
|
|
175
|
+
console.log(chalk.dim(`${models.length} models available. Prices are gateway list — chat adds only the ` +
|
|
176
|
+
`$${GATEWAY_TRANSACTION_FEE_USD} per-call fee; media adds ${margin}% + $${GATEWAY_TRANSACTION_FEE_USD}.`));
|
|
176
177
|
console.log(`${chalk.dim('Use:')} ${chalk.bold('franklin start --model <model-id>')}`);
|
|
177
178
|
}
|
package/dist/gateway-models.d.ts
CHANGED
|
@@ -9,8 +9,10 @@
|
|
|
9
9
|
*
|
|
10
10
|
* Per gateway team (2026-04-22): every model returns `billing_mode` and
|
|
11
11
|
* a mode-specific `pricing` object. Dispatch on billing_mode to compute
|
|
12
|
-
* an estimated charge.
|
|
13
|
-
*
|
|
12
|
+
* an estimated charge. Token-metered chat is billed at the provider's list
|
|
13
|
+
* rate with no margin (since 2026-09-04); media (image/video/music/speech/
|
|
14
|
+
* sfx) and Live Search carry a 5% platform fee. Every paid call adds a flat
|
|
15
|
+
* $0.001 per-transaction fee (Base since
|
|
14
16
|
* 2026-07-10; Solana instead enforces a $0.001 minimum per call with no
|
|
15
17
|
* service fee — the flat-fee estimate over-counts there by ≤$0.001, which
|
|
16
18
|
* is the safe direction for budget tracking).
|
|
@@ -100,11 +102,15 @@ export declare function getGatewayModels(): Promise<GatewayModel[]>;
|
|
|
100
102
|
export declare function getModelsByCategory(category: string): Promise<GatewayModel[]>;
|
|
101
103
|
/** Find a single model by ID, or null if it's not in the current catalog. */
|
|
102
104
|
export declare function findModel(id: string): Promise<GatewayModel | null>;
|
|
103
|
-
/**
|
|
105
|
+
/**
|
|
106
|
+
* Platform fee multiplier on MEDIA (per_image / per_second / per_track /
|
|
107
|
+
* per_character / per_generation / flat) list prices. Token-metered chat
|
|
108
|
+
* carries no margin — the gateway bills it at the provider's list rate.
|
|
109
|
+
*/
|
|
104
110
|
export declare const GATEWAY_MARGIN = 1.05;
|
|
105
111
|
/**
|
|
106
112
|
* Flat per-transaction fee (USD) the gateway adds on top of the margined
|
|
107
|
-
* price on every PAID call (no-op on $0 calls). Introduced upstream
|
|
113
|
+
* (media) or list (chat) price on every PAID call (no-op on $0 calls). Introduced upstream
|
|
108
114
|
* 2026-07-10, briefly $0.002, back to $0.001 since 2026-07-29
|
|
109
115
|
* (blockrun src/lib/transaction-fee.ts).
|
|
110
116
|
*/
|
|
@@ -119,7 +125,7 @@ export interface EstimateContext {
|
|
|
119
125
|
}
|
|
120
126
|
/**
|
|
121
127
|
* Estimated USD charge to generate one response from this model under the
|
|
122
|
-
* given context. Includes the 5%
|
|
128
|
+
* given context. Includes the 5% media platform fee and the flat $0.001
|
|
123
129
|
* per-transaction fee on paid calls. Returns 0 for free and token-metered
|
|
124
130
|
* (paid) models where a pre-call estimate isn't meaningful.
|
|
125
131
|
*/
|
package/dist/gateway-models.js
CHANGED
|
@@ -9,8 +9,10 @@
|
|
|
9
9
|
*
|
|
10
10
|
* Per gateway team (2026-04-22): every model returns `billing_mode` and
|
|
11
11
|
* a mode-specific `pricing` object. Dispatch on billing_mode to compute
|
|
12
|
-
* an estimated charge.
|
|
13
|
-
*
|
|
12
|
+
* an estimated charge. Token-metered chat is billed at the provider's list
|
|
13
|
+
* rate with no margin (since 2026-09-04); media (image/video/music/speech/
|
|
14
|
+
* sfx) and Live Search carry a 5% platform fee. Every paid call adds a flat
|
|
15
|
+
* $0.001 per-transaction fee (Base since
|
|
14
16
|
* 2026-07-10; Solana instead enforces a $0.001 minimum per call with no
|
|
15
17
|
* service fee — the flat-fee estimate over-counts there by ≤$0.001, which
|
|
16
18
|
* is the safe direction for budget tracking).
|
|
@@ -113,18 +115,22 @@ export async function findModel(id) {
|
|
|
113
115
|
return all.find(m => m.id === id) ?? null;
|
|
114
116
|
}
|
|
115
117
|
// ─── Cost estimation ────────────────────────────────────────────────────
|
|
116
|
-
/**
|
|
118
|
+
/**
|
|
119
|
+
* Platform fee multiplier on MEDIA (per_image / per_second / per_track /
|
|
120
|
+
* per_character / per_generation / flat) list prices. Token-metered chat
|
|
121
|
+
* carries no margin — the gateway bills it at the provider's list rate.
|
|
122
|
+
*/
|
|
117
123
|
export const GATEWAY_MARGIN = 1.05;
|
|
118
124
|
/**
|
|
119
125
|
* Flat per-transaction fee (USD) the gateway adds on top of the margined
|
|
120
|
-
* price on every PAID call (no-op on $0 calls). Introduced upstream
|
|
126
|
+
* (media) or list (chat) price on every PAID call (no-op on $0 calls). Introduced upstream
|
|
121
127
|
* 2026-07-10, briefly $0.002, back to $0.001 since 2026-07-29
|
|
122
128
|
* (blockrun src/lib/transaction-fee.ts).
|
|
123
129
|
*/
|
|
124
130
|
export const GATEWAY_TRANSACTION_FEE_USD = 0.001;
|
|
125
131
|
/**
|
|
126
132
|
* Estimated USD charge to generate one response from this model under the
|
|
127
|
-
* given context. Includes the 5%
|
|
133
|
+
* given context. Includes the 5% media platform fee and the flat $0.001
|
|
128
134
|
* per-transaction fee on paid calls. Returns 0 for free and token-metered
|
|
129
135
|
* (paid) models where a pre-call estimate isn't meaningful.
|
|
130
136
|
*/
|
|
@@ -74,6 +74,15 @@ export declare function walletBase(chain?: Chain): string;
|
|
|
74
74
|
* where payment rides on the PAYMENT-SIGNATURE header instead.
|
|
75
75
|
*/
|
|
76
76
|
export declare function gatewayHeaders(mode?: PayMode): Record<string, string>;
|
|
77
|
+
/**
|
|
78
|
+
* Whether a 402 on a request sent with these headers may be answered from the
|
|
79
|
+
* wallet. A request that carried an account key gets a credit refusal, not an
|
|
80
|
+
* x402 challenge, and an account failure is never permission to spend from a
|
|
81
|
+
* wallet — the 402 must surface as an error. Branch on the request's own
|
|
82
|
+
* headers rather than re-resolving the mode, so the decision always matches the
|
|
83
|
+
* rail the request actually went out on.
|
|
84
|
+
*/
|
|
85
|
+
export declare function walletMayPay(requestHeaders: Record<string, string>): boolean;
|
|
77
86
|
/**
|
|
78
87
|
* A key's credit standing, from GET /v1/credits. The authoritative figure for
|
|
79
88
|
* display — the per-response `x-blockrun-credit-remaining-usd` header can
|
|
@@ -140,6 +140,17 @@ export function gatewayHeaders(mode = resolvePayMode()) {
|
|
|
140
140
|
headers['Authorization'] = `Bearer ${mode.key}`;
|
|
141
141
|
return headers;
|
|
142
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* Whether a 402 on a request sent with these headers may be answered from the
|
|
145
|
+
* wallet. A request that carried an account key gets a credit refusal, not an
|
|
146
|
+
* x402 challenge, and an account failure is never permission to spend from a
|
|
147
|
+
* wallet — the 402 must surface as an error. Branch on the request's own
|
|
148
|
+
* headers rather than re-resolving the mode, so the decision always matches the
|
|
149
|
+
* rail the request actually went out on.
|
|
150
|
+
*/
|
|
151
|
+
export function walletMayPay(requestHeaders) {
|
|
152
|
+
return !requestHeaders['Authorization'];
|
|
153
|
+
}
|
|
143
154
|
/**
|
|
144
155
|
* Fetch the key's credit standing. Null when there is no key, the gateway is
|
|
145
156
|
* unreachable, or it answers with something unexpected — callers show what they
|
package/dist/pricing.js
CHANGED
|
@@ -48,6 +48,11 @@ const LEGACY_PRICING = {
|
|
|
48
48
|
'nvidia/nemotron-3-super-120b': { input: 0, output: 0 },
|
|
49
49
|
'nvidia/nemotron-super-49b': { input: 0, output: 0 },
|
|
50
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 },
|
|
51
56
|
'anthropic/claude-fable-5': { input: 10.0, output: 50.0 }, // Mythos-class tier above Opus, 1M ctx
|
|
52
57
|
// Opus 5 lands at the same $5/$25 as the 4.x Opus line — a straight upgrade
|
|
53
58
|
// with no cost delta, so nothing downstream needs a pricing carve-out.
|
|
@@ -55,7 +60,7 @@ const LEGACY_PRICING = {
|
|
|
55
60
|
'anthropic/claude-opus-4.8': { input: 5.0, output: 25.0 },
|
|
56
61
|
'anthropic/claude-opus-4.7': { input: 5.0, output: 25.0 },
|
|
57
62
|
'anthropic/claude-opus-4.5': { input: 5.0, output: 25.0 },
|
|
58
|
-
'anthropic/claude-sonnet-5': { input:
|
|
63
|
+
'anthropic/claude-sonnet-5': { input: 2.0, output: 10.0 }, // near-Opus at Sonnet cost, 1M ctx (live list 2026-10-02)
|
|
59
64
|
'anthropic/claude-sonnet-4.6': { input: 3.0, output: 15.0 },
|
|
60
65
|
'anthropic/claude-sonnet-4.5': { input: 3.0, output: 15.0 },
|
|
61
66
|
'anthropic/claude-haiku-4.5': { input: 1.0, output: 5.0 },
|
|
@@ -63,6 +68,13 @@ const LEGACY_PRICING = {
|
|
|
63
68
|
// Kept for cost lookup on sessions recorded before the switch.
|
|
64
69
|
'anthropic/claude-haiku-4.5-20251001': { input: 1.0, output: 5.0 },
|
|
65
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 },
|
|
66
78
|
'openai/gpt-4.1-nano': { input: 0.1, output: 0.4 },
|
|
67
79
|
'openai/gpt-4o-mini': { input: 0.15, output: 0.6 },
|
|
68
80
|
'openai/gpt-5.4-nano': { input: 0.2, output: 1.25 },
|
|
@@ -84,12 +96,12 @@ const LEGACY_PRICING = {
|
|
|
84
96
|
'openai/o4-mini': { input: 1.1, output: 4.4 },
|
|
85
97
|
'openai/o1': { input: 15.0, output: 60.0 },
|
|
86
98
|
'openai/gpt-5.5': { input: 5.0, output: 30.0 },
|
|
87
|
-
'openai/gpt-5.6-sol': { input:
|
|
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
|
|
88
100
|
// GPT-5.6 Pro tiers + 5.5 Pro + chat-latest, added upstream 2026-08-03
|
|
89
101
|
// (base #329) — priced from the live catalog 2026-08-12.
|
|
90
|
-
'openai/gpt-5.6-luna-pro': { input: 0.
|
|
91
|
-
'openai/gpt-5.6-terra-pro': { input:
|
|
92
|
-
'openai/gpt-5.6-sol-pro': { input:
|
|
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
|
|
93
105
|
'openai/gpt-5.5-pro': { input: 30.0, output: 180.0 },
|
|
94
106
|
'openai/chat-latest': { input: 5.0, output: 30.0 },
|
|
95
107
|
'openai/gpt-5.2-pro': { input: 21.0, output: 168.0 },
|
|
@@ -103,20 +115,22 @@ const LEGACY_PRICING = {
|
|
|
103
115
|
// Google's rate and corrected upstream (base #304) — mirror the real price.
|
|
104
116
|
'google/gemini-3.5-flash': { input: 1.5, output: 9.0 }, // latest Flash w/ thinking, 1M ctx
|
|
105
117
|
'google/gemini-3.5-flash-lite': { input: 0.3, output: 2.5 },
|
|
106
|
-
'google/gemini-3.6-flash': { input:
|
|
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
|
|
107
119
|
'google/gemini-2.5-pro': { input: 1.25, output: 10.0 },
|
|
108
120
|
'google/gemini-3.1-pro': { input: 2.0, output: 12.0 },
|
|
109
121
|
// xAI
|
|
110
122
|
'xai/grok-4.3': { input: 1.25, output: 2.5 }, // 1M ctx; demoted from flagship 2026-07-14
|
|
111
|
-
'xai/grok-4.
|
|
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)
|
|
112
126
|
'xai/grok-build-0.1': { input: 1.0, output: 2.0 }, // agentic coding, OpenRouter resale
|
|
113
127
|
// DeepSeek (gateway re-aliased these to V4 Flash on 2026-05-03; price cut
|
|
114
128
|
// again upstream 2026-08-07 to $0.14/$0.28 — mirrored here 2026-08-12).
|
|
115
129
|
'deepseek/deepseek-chat': { input: 0.14, output: 0.28 },
|
|
116
130
|
'deepseek/deepseek-reasoner': { input: 0.14, output: 0.28 },
|
|
117
|
-
// V4 Pro (1.6T MoE / 49B active, 1M ctx, 65K out).
|
|
118
|
-
//
|
|
119
|
-
'deepseek/deepseek-v4-pro': { input:
|
|
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 },
|
|
120
134
|
// Minimax
|
|
121
135
|
'minimax/minimax-m3': { input: 0.3, output: 1.2 },
|
|
122
136
|
'minimax/minimax-m2.7': { input: 0.3, output: 1.2 },
|
|
@@ -125,7 +139,7 @@ const LEGACY_PRICING = {
|
|
|
125
139
|
'qwen/qwen3.7-plus': { input: 0.32, output: 1.28 },
|
|
126
140
|
'qwen/qwen3.7-flash': { input: 0.03, output: 0.13 },
|
|
127
141
|
// New providers added upstream 2026-08 — priced from the live catalog.
|
|
128
|
-
'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
|
|
129
143
|
'xiaomi/mimo-v2.5-pro': { input: 0.435, output: 0.87 },
|
|
130
144
|
// Moonshot — K3 is the gateway flagship (2026-07): 2.8T open MoE, 1M
|
|
131
145
|
// context, multimodal (image+text), returns reasoning_content. Pricier
|
package/dist/router/index.js
CHANGED
|
@@ -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
|
|
144
|
-
// MEDIUM agent work — Sonnet-quality
|
|
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 $
|
|
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
|
*/
|
package/dist/router/vision.js
CHANGED
|
@@ -36,6 +36,11 @@ const VISION_MODELS = new Set([
|
|
|
36
36
|
'anthropic/claude-sonnet-4.6',
|
|
37
37
|
'anthropic/claude-sonnet-4.5',
|
|
38
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',
|
|
39
44
|
// OpenAI — multimodal flagships + o3 (Codex 5.3 is text-only, excluded).
|
|
40
45
|
// GPT-5.6 family + 5.4-mini are vision; 5.4-nano is text-only.
|
|
41
46
|
'openai/gpt-5.6-sol',
|
|
@@ -59,6 +64,11 @@ const VISION_MODELS = new Set([
|
|
|
59
64
|
'openai/gpt-4.1',
|
|
60
65
|
'openai/gpt-4o',
|
|
61
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',
|
|
62
72
|
// Google — vision baked into every Gemini SKU we surface (flash-lite excepted)
|
|
63
73
|
'google/gemini-3.1-pro',
|
|
64
74
|
'google/gemini-3.6-flash',
|
|
@@ -75,6 +85,9 @@ const VISION_MODELS = new Set([
|
|
|
75
85
|
'xai/grok-4.3',
|
|
76
86
|
'xai/grok-4-0709',
|
|
77
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',
|
|
78
91
|
// Moonshot — K3 is the flagship; the K2.x line is hidden from /v1/models
|
|
79
92
|
// but still served (probed 2026-08-29) and is catalogued as multimodal.
|
|
80
93
|
'moonshot/kimi-k3',
|
package/dist/tools/blockrun.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, 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 {
|
package/dist/tools/defillama.js
CHANGED
|
@@ -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');
|
package/dist/tools/imagegen.js
CHANGED
|
@@ -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 };
|
package/dist/tools/modal.js
CHANGED
|
@@ -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: '' };
|
package/dist/tools/musicgen.js
CHANGED
|
@@ -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 };
|
package/dist/tools/phone.js
CHANGED
|
@@ -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');
|
package/dist/tools/prediction.js
CHANGED
|
@@ -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');
|
package/dist/tools/realface.js
CHANGED
|
@@ -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');
|
package/dist/tools/surf.js
CHANGED
|
@@ -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 };
|
package/dist/tools/videogen.js
CHANGED
|
@@ -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 };
|
package/dist/tools/voice.js
CHANGED
|
@@ -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) {
|
package/dist/ui/model-picker.js
CHANGED
|
@@ -28,6 +28,11 @@ const LEGACY_SHORTCUTS = {
|
|
|
28
28
|
'sonnet-4.5': 'anthropic/claude-sonnet-4.5',
|
|
29
29
|
opus: 'anthropic/claude-opus-5',
|
|
30
30
|
'opus-5': 'anthropic/claude-opus-5',
|
|
31
|
+
// 2026-10 additions — explicit version pins only. The bare `opus` /
|
|
32
|
+
// `sonnet` / `fable` / `claude` aliases above are deliberately NOT moved.
|
|
33
|
+
'opus-5.5': 'anthropic/claude-opus-5.5',
|
|
34
|
+
'sonnet-5.5': 'anthropic/claude-sonnet-5.5',
|
|
35
|
+
'fable-5.1': 'anthropic/claude-fable-5.1',
|
|
31
36
|
'opus-4.8': 'anthropic/claude-opus-4.8',
|
|
32
37
|
'opus-4.7': 'anthropic/claude-opus-4.7',
|
|
33
38
|
// Hidden from /v1/models since 2026-08, still served (probed 2026-08-29).
|
|
@@ -41,13 +46,18 @@ const LEGACY_SHORTCUTS = {
|
|
|
41
46
|
gpt5: 'openai/gpt-5.6-sol',
|
|
42
47
|
'gpt-5': 'openai/gpt-5.6-sol',
|
|
43
48
|
'gpt-5.6': 'openai/gpt-5.6-sol',
|
|
49
|
+
// GPT-6 family + GPT-5.1 (2026-10) — explicit pins; `gpt` is NOT moved.
|
|
50
|
+
'gpt-6-astra': 'openai/gpt-6-astra',
|
|
51
|
+
'gpt-6-sol': 'openai/gpt-6-sol',
|
|
52
|
+
'gpt-6-luna': 'openai/gpt-6-luna',
|
|
53
|
+
'gpt-5.1': 'openai/gpt-5.1',
|
|
44
54
|
'gpt-5.6-sol': 'openai/gpt-5.6-sol',
|
|
45
55
|
'gpt-5.6-terra': 'openai/gpt-5.6-terra',
|
|
46
56
|
'gpt-5.6-luna': 'openai/gpt-5.6-luna',
|
|
47
57
|
// GPT-5.6 pro reasoning tier (gateway, 2026-08). Same base models with pro
|
|
48
|
-
// reasoning mode on
|
|
49
|
-
//
|
|
50
|
-
//
|
|
58
|
+
// reasoning mode on, each at its base tier's price (Sol Pro $4/$20, Terra
|
|
59
|
+
// Pro $2/$12, Luna Pro $0.2/$1.2 — live 2026-10-02) — so the pro ids are the
|
|
60
|
+
// better pick for anything reasoning-shaped. `gpt` stays pinned
|
|
51
61
|
// to Sol: bare aliases track the gateway's flagship, not the cheapest
|
|
52
62
|
// sibling.
|
|
53
63
|
'gpt-5.6-sol-pro': 'openai/gpt-5.6-sol-pro',
|
|
@@ -119,6 +129,9 @@ const LEGACY_SHORTCUTS = {
|
|
|
119
129
|
// hidden on the gateway; explicit IDs still resolve.)
|
|
120
130
|
grok: 'xai/grok-4.5',
|
|
121
131
|
'grok-4.5': 'xai/grok-4.5',
|
|
132
|
+
// Grok 4.7 / 4.6 (2026-10) — explicit pins; `grok` is NOT moved.
|
|
133
|
+
'grok-4.7': 'xai/grok-4.7',
|
|
134
|
+
'grok-4.6': 'xai/grok-4.6',
|
|
122
135
|
'grok-4.3': 'xai/grok-4.3',
|
|
123
136
|
'grok-build': 'xai/grok-build-0.1',
|
|
124
137
|
// grok-3 / grok-4-0709 / the grok-4-1-fast pair are hidden from
|
|
@@ -133,7 +146,7 @@ const LEGACY_SHORTCUTS = {
|
|
|
133
146
|
// Flash modes upstream); free tier routes through nvidia/*.
|
|
134
147
|
deepseek: 'deepseek/deepseek-chat', // V4 Flash Chat (paid, $0.20/$0.40)
|
|
135
148
|
r1: 'deepseek/deepseek-reasoner', // V4 Flash Reasoner (paid)
|
|
136
|
-
// V4 Pro: paid flagship, 1.6T MoE / 49B active, 1M ctx,
|
|
149
|
+
// V4 Pro: paid flagship, 1.6T MoE / 49B active, 1M ctx, $1.32/$3.96 (live 2026-10-02).
|
|
137
150
|
'deepseek-v4-pro': 'deepseek/deepseek-v4-pro',
|
|
138
151
|
'dsv4-pro': 'deepseek/deepseek-v4-pro',
|
|
139
152
|
'v4-pro': 'deepseek/deepseek-v4-pro',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blockrun/franklin",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.48.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": {
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"sharp": "^0.35.3",
|
|
101
101
|
"viem": "^2.48.1",
|
|
102
102
|
"ws": "^8.21.1",
|
|
103
|
-
"@blockrun/model-catalog": "https://codeload.github.com/BlockRunAI/model-catalog/tar.gz/
|
|
103
|
+
"@blockrun/model-catalog": "https://codeload.github.com/BlockRunAI/model-catalog/tar.gz/465c45941fb8ea9d6858fe8402abc8ba8934be90"
|
|
104
104
|
},
|
|
105
105
|
"devDependencies": {
|
|
106
106
|
"@types/node": "^26.1.1",
|