@blockrun/franklin 3.43.1 → 3.45.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 +105 -11
- package/dist/agent/intent-prefetch.js +4 -3
- package/dist/agent/llm.js +5 -0
- package/dist/agent/loop.js +7 -4
- package/dist/agent/secret-redact.js +11 -0
- package/dist/commands/balance.js +57 -1
- package/dist/commands/doctor.js +48 -2
- package/dist/commands/login.d.ts +14 -0
- package/dist/commands/login.js +97 -0
- package/dist/commands/models.js +3 -2
- package/dist/commands/plugin.js +3 -2
- package/dist/commands/predict.js +3 -2
- package/dist/commands/proxy.js +3 -2
- package/dist/commands/setup.js +15 -1
- package/dist/commands/slack.js +3 -2
- package/dist/commands/social.js +3 -2
- package/dist/commands/start.js +3 -2
- package/dist/commands/stats.js +18 -1
- package/dist/commands/telegram.js +3 -2
- package/dist/config.d.ts +5 -0
- package/dist/config.js +17 -0
- package/dist/gateway-models.js +9 -4
- package/dist/index.js +26 -3
- package/dist/onramp/client.js +3 -2
- package/dist/payments/auth-mode.d.ts +148 -0
- package/dist/payments/auth-mode.js +225 -0
- package/dist/payments/post-with-payment.d.ts +6 -0
- package/dist/payments/post-with-payment.js +40 -6
- package/dist/payments/price-catalog.d.ts +132 -0
- package/dist/payments/price-catalog.js +457 -0
- package/dist/phone/client.js +6 -2
- package/dist/pricing.js +3 -3
- package/dist/proxy/server.js +11 -0
- package/dist/router/index.js +2 -1
- package/dist/serve/cloud-sync.d.ts +1 -0
- package/dist/serve/server.js +10 -3
- package/dist/stats/tracker.d.ts +15 -1
- package/dist/stats/tracker.js +14 -2
- package/dist/tools/blockrun.js +10 -3
- package/dist/tools/defillama.d.ts +5 -5
- package/dist/tools/defillama.js +19 -13
- package/dist/tools/exa.d.ts +1 -1
- package/dist/tools/exa.js +43 -21
- package/dist/tools/imagegen.js +4 -2
- package/dist/tools/modal.js +4 -2
- package/dist/tools/musicgen.js +4 -2
- package/dist/tools/phone.js +4 -2
- package/dist/tools/prediction.js +16 -4
- package/dist/tools/realface.js +14 -8
- package/dist/tools/rpc.d.ts +1 -1
- package/dist/tools/rpc.js +12 -5
- package/dist/tools/surf.js +42 -6
- package/dist/tools/videogen.js +4 -2
- package/dist/tools/voice.js +6 -4
- package/dist/tools/zerox-base.js +4 -2
- package/dist/tools/zerox-gasless.js +6 -4
- package/dist/trading/providers/blockrun/client.js +20 -7
- package/dist/ui/model-picker.js +1 -1
- package/package.json +8 -4
package/dist/tools/prediction.js
CHANGED
|
@@ -36,7 +36,9 @@
|
|
|
36
36
|
* need more should narrow the search.
|
|
37
37
|
*/
|
|
38
38
|
import { getOrCreateWallet, getOrCreateSolanaWallet, createPaymentPayload, createSolanaPaymentPayload, parsePaymentRequired, extractPaymentDetails, solanaKeyToBytes, SOLANA_NETWORK, } from '@blockrun/llm';
|
|
39
|
-
import { loadChain,
|
|
39
|
+
import { loadChain, VERSION } from '../config.js';
|
|
40
|
+
import { chargeFromResponse, resolveCharge } from '../payments/price-catalog.js';
|
|
41
|
+
import { gatewayBase, gatewayHeaders } from '../payments/auth-mode.js';
|
|
40
42
|
import { logger } from '../logger.js';
|
|
41
43
|
import { recordFetch } from '../trading/providers/telemetry.js';
|
|
42
44
|
import { recordUsage } from '../stats/tracker.js';
|
|
@@ -67,7 +69,7 @@ function priceForPath(path) {
|
|
|
67
69
|
// ─── Shared GET-with-x402 flow ────────────────────────────────────────────
|
|
68
70
|
async function getWithPayment(path, query, ctx) {
|
|
69
71
|
const chain = loadChain();
|
|
70
|
-
const apiUrl =
|
|
72
|
+
const apiUrl = gatewayBase();
|
|
71
73
|
const qs = new URLSearchParams();
|
|
72
74
|
for (const [k, v] of Object.entries(query)) {
|
|
73
75
|
if (v == null || v === '')
|
|
@@ -77,6 +79,7 @@ async function getWithPayment(path, query, ctx) {
|
|
|
77
79
|
const queryStr = qs.toString();
|
|
78
80
|
const endpoint = `${apiUrl}${path}${queryStr ? `?${queryStr}` : ''}`;
|
|
79
81
|
const headers = {
|
|
82
|
+
...gatewayHeaders(),
|
|
80
83
|
Accept: 'application/json',
|
|
81
84
|
'User-Agent': `franklin/${VERSION}`,
|
|
82
85
|
};
|
|
@@ -108,18 +111,27 @@ async function getWithPayment(path, query, ctx) {
|
|
|
108
111
|
recordFetch({ provider: 'blockrun', endpoint: path, ok: false, latencyMs: Date.now() - startedAt });
|
|
109
112
|
throw new Error(`PredictionMarket ${path} failed (${response.status}): ${errText.slice(0, 600)}`);
|
|
110
113
|
}
|
|
114
|
+
// `costRecorded` is only set on the post-402 settlement, so it is 0 for
|
|
115
|
+
// every call in API-key mode, where the gateway charges silently. Fall back
|
|
116
|
+
// to this module's own price table, then to the published catalog.
|
|
117
|
+
const charge = resolveCharge({
|
|
118
|
+
apiPath: endpoint,
|
|
119
|
+
chargedUsd: chargeFromResponse(response),
|
|
120
|
+
settledUsd: costRecorded,
|
|
121
|
+
fallbackUsd: priceForPath(path),
|
|
122
|
+
});
|
|
111
123
|
recordFetch({
|
|
112
124
|
provider: 'blockrun',
|
|
113
125
|
endpoint: path,
|
|
114
126
|
ok: true,
|
|
115
127
|
latencyMs: Date.now() - startedAt,
|
|
116
|
-
costUsd:
|
|
128
|
+
costUsd: charge.usd > 0 ? charge.usd : undefined,
|
|
117
129
|
});
|
|
118
130
|
// ALSO persist to franklin-stats (recordFetch is in-memory only, lost on
|
|
119
131
|
// restart). Without this, Predexon spend is absent from `franklin stats`
|
|
120
132
|
// and invisible to the --max-spend ceiling (parity with surf.ts).
|
|
121
133
|
try {
|
|
122
|
-
recordUsage(`PredictionMarket:${path}`, 0, 0,
|
|
134
|
+
recordUsage(`PredictionMarket:${path}`, 0, 0, charge.usd, Date.now() - startedAt, false, charge.estimated);
|
|
123
135
|
}
|
|
124
136
|
catch { /* best-effort */ }
|
|
125
137
|
return (await response.json());
|
package/dist/tools/realface.js
CHANGED
|
@@ -26,7 +26,9 @@
|
|
|
26
26
|
* per the same rationale documented there — a shared module is out of scope).
|
|
27
27
|
*/
|
|
28
28
|
import { getOrCreateWallet, getOrCreateSolanaWallet, createPaymentPayload, createSolanaPaymentPayload, parsePaymentRequired, extractPaymentDetails, solanaKeyToBytes, SOLANA_NETWORK, } from '@blockrun/llm';
|
|
29
|
-
import { loadChain,
|
|
29
|
+
import { loadChain, USER_AGENT } from '../config.js';
|
|
30
|
+
import { chargeFromResponse, resolveCharge } from '../payments/price-catalog.js';
|
|
31
|
+
import { gatewayBase, gatewayHeaders } from '../payments/auth-mode.js';
|
|
30
32
|
import { recordUsage } from '../stats/tracker.js';
|
|
31
33
|
import { logger } from '../logger.js';
|
|
32
34
|
const REQUEST_TIMEOUT_MS = 60_000;
|
|
@@ -113,7 +115,7 @@ async function actionInit(base, input, ctx) {
|
|
|
113
115
|
const body = JSON.stringify(groupId ? { name, groupId } : { name });
|
|
114
116
|
const res = await timedFetch(`${base}/v1/realface/init`, {
|
|
115
117
|
method: 'POST',
|
|
116
|
-
headers: { 'Content-Type': 'application/json', Accept: 'application/json', 'User-Agent': USER_AGENT },
|
|
118
|
+
headers: { ...gatewayHeaders(), 'Content-Type': 'application/json', Accept: 'application/json', 'User-Agent': USER_AGENT },
|
|
117
119
|
body,
|
|
118
120
|
}, ctx);
|
|
119
121
|
const raw = await res.text().catch(() => '');
|
|
@@ -139,7 +141,7 @@ async function actionStatus(base, input, ctx) {
|
|
|
139
141
|
break;
|
|
140
142
|
const res = await timedFetch(`${base}/v1/realface/status?groupId=${encodeURIComponent(groupId)}`, {
|
|
141
143
|
method: 'GET',
|
|
142
|
-
headers: { Accept: 'application/json', 'User-Agent': USER_AGENT },
|
|
144
|
+
headers: { ...gatewayHeaders(), Accept: 'application/json', 'User-Agent': USER_AGENT },
|
|
143
145
|
}, ctx);
|
|
144
146
|
raw = await res.text().catch(() => '');
|
|
145
147
|
if (!res.ok)
|
|
@@ -173,7 +175,7 @@ async function actionEnroll(base, chain, input, ctx) {
|
|
|
173
175
|
}
|
|
174
176
|
const url = `${base}/v1/realface/enroll`;
|
|
175
177
|
const body = JSON.stringify({ name, image_url: imageUrl, group_id: groupId });
|
|
176
|
-
const headers = { 'Content-Type': 'application/json', Accept: 'application/json', 'User-Agent': USER_AGENT };
|
|
178
|
+
const headers = { ...gatewayHeaders(), 'Content-Type': 'application/json', Accept: 'application/json', 'User-Agent': USER_AGENT };
|
|
177
179
|
const start = Date.now();
|
|
178
180
|
let res = await timedFetch(url, { method: 'POST', headers, body }, ctx);
|
|
179
181
|
let paidUsd = 0;
|
|
@@ -187,8 +189,12 @@ async function actionEnroll(base, chain, input, ctx) {
|
|
|
187
189
|
const raw = await res.text().catch(() => '');
|
|
188
190
|
if (!res.ok)
|
|
189
191
|
paidUsd = 0;
|
|
192
|
+
// 0 whenever no 402 was settled, which is every call in API-key mode.
|
|
193
|
+
const charge = res.ok
|
|
194
|
+
? resolveCharge({ apiPath: url, chargedUsd: chargeFromResponse(res), settledUsd: paidUsd })
|
|
195
|
+
: { usd: 0, estimated: false };
|
|
190
196
|
try {
|
|
191
|
-
recordUsage('RealFace:enroll', 0, 0,
|
|
197
|
+
recordUsage('RealFace:enroll', 0, 0, charge.usd, Date.now() - start, false, charge.estimated);
|
|
192
198
|
}
|
|
193
199
|
catch { /* best-effort */ }
|
|
194
200
|
if (res.status === 425) {
|
|
@@ -201,7 +207,7 @@ async function actionEnroll(base, chain, input, ctx) {
|
|
|
201
207
|
return { output: `RealFace enroll failed (status ${res.status}). No charge if 4xx pre-payment.\n${raw.slice(0, 600)}`, isError: true };
|
|
202
208
|
}
|
|
203
209
|
return {
|
|
204
|
-
output: `RealFace enrolled → $${
|
|
210
|
+
output: `RealFace enrolled → $${charge.usd.toFixed(4)} · ${Date.now() - start}ms. ` +
|
|
205
211
|
`Use the returned \`asset_id\` (ta_xxx) as \`real_face_asset_id\` on a VideoGen call with ` +
|
|
206
212
|
`bytedance/seedance-2.0 or -fast for a real-person clip.${fence(raw)}`,
|
|
207
213
|
};
|
|
@@ -210,7 +216,7 @@ async function actionList(base, chain, ctx) {
|
|
|
210
216
|
const addr = await walletAddress(chain);
|
|
211
217
|
const res = await timedFetch(`${base}/v1/wallet/${addr}/realfaces`, {
|
|
212
218
|
method: 'GET',
|
|
213
|
-
headers: { Accept: 'application/json', 'User-Agent': USER_AGENT },
|
|
219
|
+
headers: { ...gatewayHeaders(), Accept: 'application/json', 'User-Agent': USER_AGENT },
|
|
214
220
|
}, ctx);
|
|
215
221
|
const raw = await res.text().catch(() => '');
|
|
216
222
|
if (!res.ok)
|
|
@@ -220,7 +226,7 @@ async function actionList(base, chain, ctx) {
|
|
|
220
226
|
async function execute(input, ctx) {
|
|
221
227
|
const action = typeof input.action === 'string' ? input.action.trim() : '';
|
|
222
228
|
const chain = loadChain();
|
|
223
|
-
const base =
|
|
229
|
+
const base = gatewayBase(); // wallet host ends in /api; the key host does not
|
|
224
230
|
switch (action) {
|
|
225
231
|
case 'init': return actionInit(base, input, ctx);
|
|
226
232
|
case 'status': return actionStatus(base, input, ctx);
|
package/dist/tools/rpc.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Multi-chain RPC — read-only JSON-RPC across 40+ chains via the BlockRun
|
|
3
3
|
* `/v1/rpc/{network}` endpoint (Tatum gateway). x402-paid against the user's
|
|
4
|
-
* USDC wallet, flat $0.
|
|
4
|
+
* USDC wallet, flat $0.0020 base + $0.001 settlement fee (measured 2026-09-05).
|
|
5
5
|
*
|
|
6
6
|
* For a trading agent this covers the on-chain reads the dedicated tools don't:
|
|
7
7
|
* native + ERC-20 balances on any chain, contract reads (eth_call), gas price,
|
package/dist/tools/rpc.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Multi-chain RPC — read-only JSON-RPC across 40+ chains via the BlockRun
|
|
3
3
|
* `/v1/rpc/{network}` endpoint (Tatum gateway). x402-paid against the user's
|
|
4
|
-
* USDC wallet, flat $0.
|
|
4
|
+
* USDC wallet, flat $0.0020 base + $0.001 settlement fee (measured 2026-09-05).
|
|
5
5
|
*
|
|
6
6
|
* For a trading agent this covers the on-chain reads the dedicated tools don't:
|
|
7
7
|
* native + ERC-20 balances on any chain, contract reads (eth_call), gas price,
|
|
@@ -17,7 +17,9 @@
|
|
|
17
17
|
* depend on the SDK's RpcClient, so it works on the pinned @blockrun/llm 2.x.
|
|
18
18
|
*/
|
|
19
19
|
import { getOrCreateWallet, getOrCreateSolanaWallet, createPaymentPayload, createSolanaPaymentPayload, parsePaymentRequired, extractPaymentDetails, solanaKeyToBytes, SOLANA_NETWORK, } from '@blockrun/llm';
|
|
20
|
-
import { loadChain,
|
|
20
|
+
import { loadChain, VERSION } from '../config.js';
|
|
21
|
+
import { chargeFromResponse, resolveCharge } from '../payments/price-catalog.js';
|
|
22
|
+
import { gatewayBase, gatewayHeaders } from '../payments/auth-mode.js';
|
|
21
23
|
import { logger } from '../logger.js';
|
|
22
24
|
import { recordUsage } from '../stats/tracker.js';
|
|
23
25
|
const TIMEOUT_MS = 30_000;
|
|
@@ -46,10 +48,11 @@ const WRITE_METHODS = new Set([
|
|
|
46
48
|
].map((m) => m.toLowerCase()));
|
|
47
49
|
async function postRpcWithPayment(network, jsonRpcBody, ctx) {
|
|
48
50
|
const chain = loadChain();
|
|
49
|
-
const apiUrl =
|
|
51
|
+
const apiUrl = gatewayBase();
|
|
50
52
|
const endpoint = `${apiUrl}/v1/rpc/${network}`;
|
|
51
53
|
const bodyStr = JSON.stringify(jsonRpcBody);
|
|
52
54
|
const headers = {
|
|
55
|
+
...gatewayHeaders(),
|
|
53
56
|
'Content-Type': 'application/json',
|
|
54
57
|
Accept: 'application/json',
|
|
55
58
|
'User-Agent': `franklin/${VERSION}`,
|
|
@@ -86,8 +89,12 @@ async function postRpcWithPayment(network, jsonRpcBody, ctx) {
|
|
|
86
89
|
}
|
|
87
90
|
// Record the settled x402 spend so RPC calls show up in franklin stats /
|
|
88
91
|
// audit AND count against the --max-spend ceiling (parity with surf.ts).
|
|
92
|
+
// `paidUsd` is only ever set by the 402 branch, so in API-key mode — where
|
|
93
|
+
// the gateway settles silently and never sends a 402 — it stays 0. Price the
|
|
94
|
+
// call from the published catalog instead of recording a free call.
|
|
95
|
+
const charge = resolveCharge({ apiPath: endpoint, chargedUsd: chargeFromResponse(response), settledUsd: paidUsd });
|
|
89
96
|
try {
|
|
90
|
-
recordUsage(`MultiChainRPC:${network}`, 0, 0,
|
|
97
|
+
recordUsage(`MultiChainRPC:${network}`, 0, 0, charge.usd, Date.now() - startedAt, false, charge.estimated);
|
|
91
98
|
}
|
|
92
99
|
catch { /* best-effort */ }
|
|
93
100
|
return {
|
|
@@ -155,7 +162,7 @@ export const multiChainRpcCapability = {
|
|
|
155
162
|
spec: {
|
|
156
163
|
name: 'MultiChainRPC',
|
|
157
164
|
description: 'Read-only JSON-RPC against 40+ chains through the BlockRun gateway (one endpoint, no per-chain key). ' +
|
|
158
|
-
'$0.
|
|
165
|
+
'$0.0020 per call, plus a $0.001 settlement fee when paying from a wallet. Use for on-chain reads the other tools do not cover: native/token balances on any ' +
|
|
159
166
|
'chain, contract reads (eth_call), gas price, nonce, block height, and tx receipt checks ("did my swap land?"). ' +
|
|
160
167
|
'EVM chains speak eth_* (eth_blockNumber, eth_getBalance, eth_call, eth_gasPrice, eth_getTransactionReceipt, ...); ' +
|
|
161
168
|
'Solana speaks getSlot/getBalance/getAccountInfo/getTransaction; Bitcoin-family speaks getblockcount etc. ' +
|
package/dist/tools/surf.js
CHANGED
|
@@ -16,7 +16,10 @@
|
|
|
16
16
|
* rationale documented there — refactoring into a shared module is out of scope).
|
|
17
17
|
*/
|
|
18
18
|
import { getOrCreateWallet, getOrCreateSolanaWallet, createPaymentPayload, createSolanaPaymentPayload, parsePaymentRequired, extractPaymentDetails, solanaKeyToBytes, SOLANA_NETWORK, } from '@blockrun/llm';
|
|
19
|
-
import { loadChain,
|
|
19
|
+
import { loadChain, USER_AGENT } from '../config.js';
|
|
20
|
+
import { basePriceForPath, chargeFromResponse, resolveCharge } from '../payments/price-catalog.js';
|
|
21
|
+
import { GATEWAY_TRANSACTION_FEE_USD } from '../gateway-models.js';
|
|
22
|
+
import { gatewayBase, gatewayHeaders } from '../payments/auth-mode.js';
|
|
20
23
|
import { frameUntrusted } from './untrusted.js';
|
|
21
24
|
import { recordUsage } from '../stats/tracker.js';
|
|
22
25
|
import { logger } from '../logger.js';
|
|
@@ -57,7 +60,7 @@ const CHAIN_ENDPOINTS = [
|
|
|
57
60
|
{ path: 'onchain/tx', method: 'GET', required: ['hash', 'chain'], desc: 'Transaction details by hash.' },
|
|
58
61
|
{ path: 'onchain/schema', method: 'GET', required: [], desc: 'Schema introspection for the SQL tables.' },
|
|
59
62
|
{ path: 'onchain/query', method: 'POST', required: [], desc: 'Structured chain query (POST body).' },
|
|
60
|
-
{ path: 'onchain/sql', method: 'POST', required: [], desc: 'Raw SQL against 80+ indexed chain tables (POST body
|
|
63
|
+
{ path: 'onchain/sql', method: 'POST', required: [], desc: 'Raw SQL against 80+ indexed chain tables (POST body).' },
|
|
61
64
|
{ path: 'token/tokenomics', method: 'GET', required: [], desc: 'Token supply / unlock / distribution.' },
|
|
62
65
|
{ path: 'token/dex-trades', method: 'GET', required: ['address'], desc: 'Recent DEX trades for a token.' },
|
|
63
66
|
{ path: 'token/holders', method: 'GET', required: ['address', 'chain'], desc: 'Top holders / concentration.' },
|
|
@@ -166,7 +169,7 @@ async function callSurf(toolName, table, input, ctx) {
|
|
|
166
169
|
};
|
|
167
170
|
}
|
|
168
171
|
const chain = loadChain();
|
|
169
|
-
const base =
|
|
172
|
+
const base = gatewayBase(); // wallet host ends in /api; the key host does not
|
|
170
173
|
let url = `${base}/v1/surf/${entry.path}`;
|
|
171
174
|
const body = entry.method === 'POST'
|
|
172
175
|
? (input.body && typeof input.body === 'object' ? input.body : query)
|
|
@@ -187,7 +190,7 @@ async function callSurf(toolName, table, input, ctx) {
|
|
|
187
190
|
const onAbort = () => ctrl.abort();
|
|
188
191
|
ctx.abortSignal.addEventListener('abort', onAbort, { once: true });
|
|
189
192
|
const timer = setTimeout(() => ctrl.abort(), TIMEOUT_MS);
|
|
190
|
-
const headers = { Accept: 'application/json', 'User-Agent': USER_AGENT };
|
|
193
|
+
const headers = { ...gatewayHeaders(), Accept: 'application/json', 'User-Agent': USER_AGENT };
|
|
191
194
|
if (entry.method === 'POST')
|
|
192
195
|
headers['Content-Type'] = 'application/json';
|
|
193
196
|
const payload = body !== undefined ? JSON.stringify(body) : undefined;
|
|
@@ -208,8 +211,14 @@ async function callSurf(toolName, table, input, ctx) {
|
|
|
208
211
|
if (!response.ok)
|
|
209
212
|
paidUsd = 0;
|
|
210
213
|
const raw = await response.text().catch(() => '');
|
|
214
|
+
// `paidUsd` is 0 unless a 402 was settled — i.e. always 0 in API-key mode.
|
|
215
|
+
// Fall back to the catalog price so Surf spend still counts against
|
|
216
|
+
// --max-spend and shows in stats.
|
|
217
|
+
const charge = response.ok
|
|
218
|
+
? resolveCharge({ apiPath: url, chargedUsd: chargeFromResponse(response), settledUsd: paidUsd })
|
|
219
|
+
: { usd: 0, estimated: false };
|
|
211
220
|
try {
|
|
212
|
-
recordUsage(`${toolName}:${entry.path}`, 0, 0,
|
|
221
|
+
recordUsage(`${toolName}:${entry.path}`, 0, 0, charge.usd, Date.now() - start, false, charge.estimated);
|
|
213
222
|
}
|
|
214
223
|
catch { /* best-effort */ }
|
|
215
224
|
if (!response.ok) {
|
|
@@ -230,13 +239,40 @@ async function callSurf(toolName, table, input, ctx) {
|
|
|
230
239
|
}
|
|
231
240
|
}
|
|
232
241
|
// ── Tool specs ───────────────────────────────────────────────────────────────
|
|
242
|
+
/**
|
|
243
|
+
* Price sentence for the tool description, read from the catalog rather than
|
|
244
|
+
* typed in.
|
|
245
|
+
*
|
|
246
|
+
* This used to read "Tier-1 $0.001, Tier-2 $0.005, Tier-3 $0.02", which the
|
|
247
|
+
* payment layer had long since replaced with one flat rate. Measured against
|
|
248
|
+
* the authoritative 402 on 2026-09-05: every Surf endpoint quotes $0.0085, so
|
|
249
|
+
* the description understated tier-1 by 8.5x and overstated tier-3 by 2.4x.
|
|
250
|
+
*
|
|
251
|
+
* That matters more than an inaccurate comment, because the agent reads this
|
|
252
|
+
* string to decide whether a call is worth making — it was being told the
|
|
253
|
+
* cheapest Surf call costs about a tenth of what it does. A hand-typed price
|
|
254
|
+
* is a published number with no owner; sourcing it from the catalog gives it
|
|
255
|
+
* one, and the guard test keeps literals from creeping back in.
|
|
256
|
+
*
|
|
257
|
+
* It states the BASE price and names the fee separately because there are two
|
|
258
|
+
* real prices per endpoint: the key rail charges the base, the wallet rail adds
|
|
259
|
+
* a settlement fee. One number cannot be right for both, and this phrasing is
|
|
260
|
+
* true on either.
|
|
261
|
+
*/
|
|
262
|
+
function surfPriceBlurb() {
|
|
263
|
+
const base = basePriceForPath('/v1/surf/market/ranking');
|
|
264
|
+
return base === null || base <= 0
|
|
265
|
+
? 'Each call is charged per request; the 402 quote states the exact price.'
|
|
266
|
+
: `Flat $${base.toFixed(4)} per call, plus a $${GATEWAY_TRANSACTION_FEE_USD.toFixed(3)} `
|
|
267
|
+
+ 'settlement fee when paying from a wallet.';
|
|
268
|
+
}
|
|
233
269
|
function makeSurfTool(name, blurb, table, extraParams) {
|
|
234
270
|
const endpointList = table.map((e) => `\`${e.path}\`${e.required.length ? ` (needs ${e.required.join('+')})` : ''} — ${e.desc}`).join('\n');
|
|
235
271
|
return {
|
|
236
272
|
spec: {
|
|
237
273
|
name,
|
|
238
274
|
description: `${blurb} Picks an endpoint from a fixed list and signs the x402 USDC payment from the wallet automatically — ` +
|
|
239
|
-
`you do not build paths or handle payment.
|
|
275
|
+
`you do not build paths or handle payment. ${surfPriceBlurb()}\n\nEndpoints:\n${endpointList}`,
|
|
240
276
|
input_schema: {
|
|
241
277
|
type: 'object',
|
|
242
278
|
properties: {
|
package/dist/tools/videogen.js
CHANGED
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
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
|
-
import { loadChain,
|
|
25
|
+
import { loadChain, VERSION } from '../config.js';
|
|
26
|
+
import { gatewayBase, gatewayHeaders } from '../payments/auth-mode.js';
|
|
26
27
|
import { logger } from '../logger.js';
|
|
27
28
|
import { resolveReferenceImage } from './imagegen.js';
|
|
28
29
|
import { isWalletKeyPath } from './sensitive-paths.js';
|
|
@@ -161,7 +162,7 @@ function buildExecute(deps) {
|
|
|
161
162
|
}
|
|
162
163
|
}
|
|
163
164
|
const chain = loadChain();
|
|
164
|
-
const apiUrl =
|
|
165
|
+
const apiUrl = gatewayBase();
|
|
165
166
|
const endpoint = `${apiUrl}/v1/videos/generations`;
|
|
166
167
|
const outPath = output_path
|
|
167
168
|
? (path.isAbsolute(output_path) ? output_path : path.resolve(ctx.workingDir, output_path))
|
|
@@ -187,6 +188,7 @@ function buildExecute(deps) {
|
|
|
187
188
|
...(real_face_asset_id ? { real_face_asset_id } : {}),
|
|
188
189
|
});
|
|
189
190
|
const headers = {
|
|
191
|
+
...gatewayHeaders(),
|
|
190
192
|
'Content-Type': 'application/json',
|
|
191
193
|
'User-Agent': `franklin/${VERSION}`,
|
|
192
194
|
};
|
package/dist/tools/voice.js
CHANGED
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
* x402 payment flow mirrors src/tools/exa.ts.
|
|
16
16
|
*/
|
|
17
17
|
import { getOrCreateWallet, getOrCreateSolanaWallet, createPaymentPayload, createSolanaPaymentPayload, parsePaymentRequired, extractPaymentDetails, solanaKeyToBytes, SOLANA_NETWORK, } from '@blockrun/llm';
|
|
18
|
-
import { loadChain,
|
|
18
|
+
import { loadChain, VERSION } from '../config.js';
|
|
19
|
+
import { gatewayBase, gatewayHeaders } from '../payments/auth-mode.js';
|
|
19
20
|
import { logger } from '../logger.js';
|
|
20
21
|
import { recordUsage } from '../stats/tracker.js';
|
|
21
22
|
import { frameUntrusted } from './untrusted.js';
|
|
@@ -57,10 +58,11 @@ const VOICE_TIMEOUT_MS = 30_000;
|
|
|
57
58
|
async function postWithPayment(path, body, ctx, meta) {
|
|
58
59
|
const startMs = Date.now();
|
|
59
60
|
const chain = loadChain();
|
|
60
|
-
const apiUrl =
|
|
61
|
+
const apiUrl = gatewayBase();
|
|
61
62
|
const endpoint = `${apiUrl}${path}`;
|
|
62
63
|
const bodyStr = JSON.stringify(body);
|
|
63
64
|
const headers = {
|
|
65
|
+
...gatewayHeaders(),
|
|
64
66
|
'Content-Type': 'application/json',
|
|
65
67
|
'User-Agent': `franklin/${VERSION}`,
|
|
66
68
|
};
|
|
@@ -107,7 +109,7 @@ async function postWithPayment(path, body, ctx, meta) {
|
|
|
107
109
|
async function getNoPayment(path, ctx, meta, record = true) {
|
|
108
110
|
const startMs = Date.now();
|
|
109
111
|
const chain = loadChain();
|
|
110
|
-
const apiUrl =
|
|
112
|
+
const apiUrl = gatewayBase();
|
|
111
113
|
const endpoint = `${apiUrl}${path}`;
|
|
112
114
|
const controller = new AbortController();
|
|
113
115
|
const timeout = setTimeout(() => controller.abort(), VOICE_TIMEOUT_MS);
|
|
@@ -117,7 +119,7 @@ async function getNoPayment(path, ctx, meta, record = true) {
|
|
|
117
119
|
const resp = await fetch(endpoint, {
|
|
118
120
|
method: 'GET',
|
|
119
121
|
signal: controller.signal,
|
|
120
|
-
headers: { 'User-Agent': `franklin/${VERSION}` },
|
|
122
|
+
headers: { ...gatewayHeaders(), 'User-Agent': `franklin/${VERSION}` },
|
|
121
123
|
});
|
|
122
124
|
if (!resp.ok) {
|
|
123
125
|
const errText = await resp.text().catch(() => '');
|
package/dist/tools/zerox-base.js
CHANGED
|
@@ -26,7 +26,8 @@ import { privateKeyToAccount } from 'viem/accounts';
|
|
|
26
26
|
import { base } from 'viem/chains';
|
|
27
27
|
import { getOrCreateWallet } from '@blockrun/llm';
|
|
28
28
|
import { loadConfig } from '../commands/config.js';
|
|
29
|
-
import {
|
|
29
|
+
import { gatewayBase, gatewayHeaders } from '../payments/auth-mode.js';
|
|
30
|
+
import { loadChain, VERSION } from '../config.js';
|
|
30
31
|
import { appendSwap } from '../stats/swap-log.js';
|
|
31
32
|
// ─── BlockRun affiliate identity on Base ─────────────────────────────────
|
|
32
33
|
// Reuses the existing BlockRun ops wallet that already receives x402
|
|
@@ -150,9 +151,10 @@ function makeClient(account) {
|
|
|
150
151
|
// ─── 0x calls via BlockRun gateway (free public passthrough) ─────────────
|
|
151
152
|
async function gatewayGet(path, params, ctx) {
|
|
152
153
|
const chain = loadChain();
|
|
153
|
-
const apiUrl =
|
|
154
|
+
const apiUrl = gatewayBase();
|
|
154
155
|
const endpoint = `${apiUrl}${ZEROX_GATEWAY_PATH}/${path}?${params.toString()}`;
|
|
155
156
|
const headers = {
|
|
157
|
+
...gatewayHeaders(),
|
|
156
158
|
Accept: 'application/json',
|
|
157
159
|
'User-Agent': `franklin/${VERSION}`,
|
|
158
160
|
};
|
|
@@ -23,7 +23,8 @@ import { base } from 'viem/chains';
|
|
|
23
23
|
import { createWalletClient, http, publicActions } from 'viem';
|
|
24
24
|
import { getOrCreateWallet } from '@blockrun/llm';
|
|
25
25
|
import { loadConfig } from '../commands/config.js';
|
|
26
|
-
import {
|
|
26
|
+
import { gatewayBase, gatewayHeaders } from '../payments/auth-mode.js';
|
|
27
|
+
import { VERSION } from '../config.js';
|
|
27
28
|
import { appendSwap } from '../stats/swap-log.js';
|
|
28
29
|
import { logger } from '../logger.js';
|
|
29
30
|
// ─── Constants ────────────────────────────────────────────────────────────
|
|
@@ -145,7 +146,7 @@ function makeClient(account) {
|
|
|
145
146
|
}).extend(publicActions);
|
|
146
147
|
}
|
|
147
148
|
async function gatewayGet(pathSuffix, query, timeoutMs, ctx) {
|
|
148
|
-
const apiUrl =
|
|
149
|
+
const apiUrl = gatewayBase();
|
|
149
150
|
const url = `${apiUrl}${ZEROX_GATEWAY_PATH}/${pathSuffix}?${query.toString()}`;
|
|
150
151
|
const controller = new AbortController();
|
|
151
152
|
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
@@ -154,7 +155,7 @@ async function gatewayGet(pathSuffix, query, timeoutMs, ctx) {
|
|
|
154
155
|
try {
|
|
155
156
|
const res = await fetch(url, {
|
|
156
157
|
method: 'GET',
|
|
157
|
-
headers: { Accept: 'application/json', 'User-Agent': `franklin/${VERSION}` },
|
|
158
|
+
headers: { ...gatewayHeaders(), Accept: 'application/json', 'User-Agent': `franklin/${VERSION}` },
|
|
158
159
|
signal: controller.signal,
|
|
159
160
|
});
|
|
160
161
|
if (!res.ok) {
|
|
@@ -169,7 +170,7 @@ async function gatewayGet(pathSuffix, query, timeoutMs, ctx) {
|
|
|
169
170
|
}
|
|
170
171
|
}
|
|
171
172
|
async function gatewayPost(pathSuffix, body, timeoutMs, ctx) {
|
|
172
|
-
const apiUrl =
|
|
173
|
+
const apiUrl = gatewayBase();
|
|
173
174
|
const url = `${apiUrl}${ZEROX_GATEWAY_PATH}/${pathSuffix}`;
|
|
174
175
|
const controller = new AbortController();
|
|
175
176
|
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
@@ -179,6 +180,7 @@ async function gatewayPost(pathSuffix, body, timeoutMs, ctx) {
|
|
|
179
180
|
const res = await fetch(url, {
|
|
180
181
|
method: 'POST',
|
|
181
182
|
headers: {
|
|
183
|
+
...gatewayHeaders(),
|
|
182
184
|
Accept: 'application/json',
|
|
183
185
|
'Content-Type': 'application/json',
|
|
184
186
|
'User-Agent': `franklin/${VERSION}`,
|
|
@@ -14,13 +14,25 @@
|
|
|
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
18
|
import { recordFetch } from '../telemetry.js';
|
|
18
19
|
import { getOrCreateWallet, getOrCreateSolanaWallet, createPaymentPayload, createSolanaPaymentPayload, parsePaymentRequired, extractPaymentDetails, solanaKeyToBytes, SOLANA_NETWORK, } from '@blockrun/llm';
|
|
19
20
|
const TIMEOUT_MS = 10_000;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Absolute URL for a gateway path. Callers pass `/api/v1/...` because that is
|
|
23
|
+
* the shape the x402 hosts serve; the API-key host serves the same routes at
|
|
24
|
+
* `/v1/...`, so the `/api` segment is stripped in key mode.
|
|
25
|
+
*
|
|
26
|
+
* `loadChain()` dispatches on env / ~/.blockrun/payment-chain and is read every
|
|
27
|
+
* call so mid-session chain switches take effect without a restart. In key mode
|
|
28
|
+
* the chain is irrelevant — the credit balance is chainless.
|
|
29
|
+
*/
|
|
30
|
+
function gatewayUrl(path) {
|
|
31
|
+
const mode = resolvePayMode();
|
|
32
|
+
if (mode.kind === 'key')
|
|
33
|
+
return mode.apiBase + path.replace(/^\/api/, '');
|
|
34
|
+
const origin = loadChain() === 'solana' ? 'https://sol.blockrun.ai' : 'https://blockrun.ai';
|
|
35
|
+
return origin + path;
|
|
24
36
|
}
|
|
25
37
|
const cache = new Map();
|
|
26
38
|
export async function cached(key, ttlMs, fn) {
|
|
@@ -43,11 +55,11 @@ export function clearCache() {
|
|
|
43
55
|
export async function blockrunGet(path, opts = { endpoint: path }) {
|
|
44
56
|
const ctrl = new AbortController();
|
|
45
57
|
const timer = setTimeout(() => ctrl.abort(), TIMEOUT_MS);
|
|
46
|
-
const url =
|
|
58
|
+
const url = gatewayUrl(path);
|
|
47
59
|
const startedAt = Date.now();
|
|
48
60
|
try {
|
|
49
61
|
const res = await fetch(url, {
|
|
50
|
-
headers: { 'User-Agent': USER_AGENT, Accept: 'application/json' },
|
|
62
|
+
headers: { ...gatewayHeaders(), 'User-Agent': USER_AGENT, Accept: 'application/json' },
|
|
51
63
|
signal: ctrl.signal,
|
|
52
64
|
});
|
|
53
65
|
const latencyMs = Date.now() - startedAt;
|
|
@@ -168,10 +180,11 @@ class PaymentSignError extends Error {
|
|
|
168
180
|
export async function blockrunGetPaid(path, opts) {
|
|
169
181
|
const ctrl = new AbortController();
|
|
170
182
|
const timer = setTimeout(() => ctrl.abort(), TIMEOUT_MS);
|
|
171
|
-
const url =
|
|
183
|
+
const url = gatewayUrl(path);
|
|
172
184
|
const chain = loadChain();
|
|
173
185
|
const startedAt = Date.now();
|
|
174
186
|
const headers = {
|
|
187
|
+
...gatewayHeaders(),
|
|
175
188
|
'User-Agent': USER_AGENT,
|
|
176
189
|
Accept: 'application/json',
|
|
177
190
|
};
|
package/dist/ui/model-picker.js
CHANGED
|
@@ -366,7 +366,7 @@ export const PICKER_CATEGORIES = [
|
|
|
366
366
|
// superseded sibling listed directly under its successor is choice
|
|
367
367
|
// paralysis, not choice. `gemini-2.5` still resolves to it.
|
|
368
368
|
{ id: 'google/gemini-3.1-pro', shortcut: 'gemini', label: 'Gemini 3.1 Pro', price: '$2/$12' },
|
|
369
|
-
{ id: 'xai/grok-4.5', shortcut: 'grok', label: 'Grok 4.5', price: '$2
|
|
369
|
+
{ id: 'xai/grok-4.5', shortcut: 'grok', label: 'Grok 4.5', price: '$2/$6' },
|
|
370
370
|
// Kimi K3 (2026-07): 2.8T open MoE, 1M context, multimodal + reasoning.
|
|
371
371
|
// Replaced the budget K2.7 line — now premium-priced ($3/$15).
|
|
372
372
|
{ id: 'moonshot/kimi-k3', shortcut: 'kimi', label: 'Kimi K3', price: '$3/$15' },
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blockrun/franklin",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"description": "Franklin Agent
|
|
3
|
+
"version": "3.45.0",
|
|
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": {
|
|
7
7
|
".": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"desktop:package:win": "npm run dist:win --workspace @blockrun/franklin-desktop",
|
|
39
39
|
"dev": "tsc --watch",
|
|
40
40
|
"start": "node dist/index.js",
|
|
41
|
-
"test": "npm run build && node --test --test-concurrency=4 --test-reporter=spec test/local.mjs test/serve-security.local.mjs test/skills.local.mjs test/repair.mjs test/model-resolver.mjs test/exa.local.mjs test/audit-batch.local.mjs test/polymarket.local.mjs test/market.local.mjs test/hooks.local.mjs test/scheduler.local.mjs test/trade-plan.local.mjs test/goal.local.mjs test/memory.local.mjs test/agent-host.local.mjs test/reservation.local.mjs",
|
|
41
|
+
"test": "npm run build && node --test --test-concurrency=4 --test-reporter=spec test/local.mjs test/api-key.local.mjs test/serve-security.local.mjs test/skills.local.mjs test/repair.mjs test/model-resolver.mjs test/exa.local.mjs test/audit-batch.local.mjs test/polymarket.local.mjs test/market.local.mjs test/hooks.local.mjs test/scheduler.local.mjs test/trade-plan.local.mjs test/goal.local.mjs test/memory.local.mjs test/agent-host.local.mjs test/reservation.local.mjs",
|
|
42
42
|
"test:e2e": "npm run build && node --test --test-reporter=spec test/e2e.mjs",
|
|
43
43
|
"e2e:polymarket:readonly": "npm run build && node scripts/polymarket-e2e-readonly.mjs",
|
|
44
44
|
"test:free-models": "npm run build && node --test --test-reporter=spec test/free-model-matrix.mjs",
|
|
@@ -108,6 +108,10 @@
|
|
|
108
108
|
},
|
|
109
109
|
"overrides": {
|
|
110
110
|
"ws@>=8.0.0 <=8.20.1": "^8.21.1",
|
|
111
|
-
"@polymarket/builder-signing-sdk": "1.0.0"
|
|
111
|
+
"@polymarket/builder-signing-sdk": "1.0.0",
|
|
112
|
+
"@polymarket/builder-relayer-client": {
|
|
113
|
+
"axios": "^1.18.1"
|
|
114
|
+
},
|
|
115
|
+
"qs": "^6.16.0"
|
|
112
116
|
}
|
|
113
117
|
}
|