@blockrun/franklin 3.47.0 → 3.49.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.
Files changed (59) hide show
  1. package/README.md +31 -15
  2. package/dist/agent/commands.js +11 -9
  3. package/dist/agent/context.js +6 -6
  4. package/dist/agent/intent-prefetch.js +4 -3
  5. package/dist/agent/llm.js +6 -6
  6. package/dist/agent/tokens.js +13 -0
  7. package/dist/agent/types.d.ts +2 -1
  8. package/dist/channel/slack.js +4 -2
  9. package/dist/channel/telegram.js +4 -2
  10. package/dist/commands/balance.js +5 -4
  11. package/dist/commands/doctor.js +3 -2
  12. package/dist/commands/models.js +3 -2
  13. package/dist/commands/proxy.js +4 -4
  14. package/dist/commands/setup.js +6 -5
  15. package/dist/commands/start.js +4 -2
  16. package/dist/config.d.ts +13 -1
  17. package/dist/config.js +28 -8
  18. package/dist/gateway-models.d.ts +11 -5
  19. package/dist/gateway-models.js +11 -5
  20. package/dist/index.js +4 -4
  21. package/dist/model-catalog.d.ts +3 -2
  22. package/dist/model-catalog.js +18 -8
  23. package/dist/onramp/client.js +5 -0
  24. package/dist/panel/html.js +39 -22
  25. package/dist/panel/server.js +8 -7
  26. package/dist/payments/auth-mode.d.ts +11 -1
  27. package/dist/payments/auth-mode.js +13 -1
  28. package/dist/pricing.js +25 -11
  29. package/dist/proxy/server.js +2 -1
  30. package/dist/router/index.js +4 -3
  31. package/dist/router/vision.js +13 -0
  32. package/dist/serve/agent-host.d.ts +2 -1
  33. package/dist/serve/server.js +4 -1
  34. package/dist/session/storage.d.ts +2 -1
  35. package/dist/skills/bootstrap.d.ts +2 -1
  36. package/dist/tools/blockrun.js +2 -2
  37. package/dist/tools/defillama.js +2 -2
  38. package/dist/tools/exa.js +2 -2
  39. package/dist/tools/imagegen.js +2 -2
  40. package/dist/tools/moa.d.ts +2 -1
  41. package/dist/tools/modal.d.ts +2 -1
  42. package/dist/tools/modal.js +2 -2
  43. package/dist/tools/musicgen.js +2 -2
  44. package/dist/tools/phone.js +2 -2
  45. package/dist/tools/prediction.js +2 -2
  46. package/dist/tools/realface.js +2 -2
  47. package/dist/tools/rpc.js +2 -2
  48. package/dist/tools/subagent.d.ts +2 -1
  49. package/dist/tools/surf.js +2 -2
  50. package/dist/tools/videogen.js +2 -2
  51. package/dist/tools/voice.js +2 -2
  52. package/dist/tools/wallet.d.ts +2 -1
  53. package/dist/tools/wallet.js +2 -1
  54. package/dist/trading/providers/blockrun/client.js +5 -4
  55. package/dist/ui/model-picker.js +17 -4
  56. package/dist/wallet/manager.d.ts +15 -0
  57. package/dist/wallet/manager.js +27 -1
  58. package/dist/wallet/reservation.js +4 -2
  59. package/package.json +6 -6
@@ -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 };
@@ -11,6 +11,7 @@
11
11
  * Inspired by the Mixture-of-Agents architecture from Together.ai research.
12
12
  */
13
13
  import type { CapabilityHandler } from '../agent/types.js';
14
+ import type { Chain } from '../config.js';
14
15
  export declare const moaCapability: CapabilityHandler;
15
16
  /** Register the API URL for MoA tool (called during agent setup). */
16
- export declare function registerMoAConfig(apiUrl: string, chain: 'base' | 'solana', parentModel?: string): void;
17
+ export declare function registerMoAConfig(apiUrl: string, chain: Chain, parentModel?: string): void;
@@ -26,6 +26,7 @@
26
26
  * the SessionSandboxTracker registry.
27
27
  */
28
28
  import type { CapabilityHandler } from '../agent/types.js';
29
+ import { type Chain } from '../config.js';
29
30
  import { type ReservationToken } from '../wallet/reservation.js';
30
31
  export interface SandboxRecord {
31
32
  id: string;
@@ -43,7 +44,7 @@ declare class SessionSandboxTracker {
43
44
  }
44
45
  export declare const sessionSandboxTracker: SessionSandboxTracker;
45
46
  export declare function _setPaymentSignerForTests(fn: typeof signPayment | null): void;
46
- declare function signPayment(response: Response, chain: 'base' | 'solana', endpoint: string, resourceDescription: string): Promise<Record<string, string> | null>;
47
+ declare function signPayment(response: Response, chain: Chain, endpoint: string, resourceDescription: string): Promise<Record<string, string> | null>;
47
48
  /**
48
49
  * Generic POST-with-x402-retry helper used by all four Modal endpoints. The
49
50
  * first POST gets a 402 with payment requirements; we sign and retry once
@@ -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');
@@ -2,4 +2,5 @@
2
2
  * SubAgent capability — spawn a child agent for independent tasks.
3
3
  */
4
4
  import type { CapabilityHandler } from '../agent/types.js';
5
- export declare function createSubAgentCapability(apiUrl: string, chain: 'base' | 'solana', capabilities: CapabilityHandler[], parentModel?: string): CapabilityHandler;
5
+ import type { Chain } from '../config.js';
6
+ export declare function createSubAgentCapability(apiUrl: string, chain: Chain, capabilities: CapabilityHandler[], parentModel?: string): CapabilityHandler;
@@ -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');
@@ -12,9 +12,10 @@
12
12
  * Bash is still available for non-trivial wallet operations (sending,
13
13
  * signing arbitrary tx) — Wallet is read-only by design.
14
14
  */
15
+ import { type Chain } from '../config.js';
15
16
  import type { CapabilityHandler } from '../agent/types.js';
16
17
  export interface WalletReportInput {
17
- chain: 'base' | 'solana';
18
+ chain: Chain;
18
19
  address: string;
19
20
  balanceUsd: number;
20
21
  }
@@ -13,6 +13,7 @@
13
13
  * signing arbitrary tx) — Wallet is read-only by design.
14
14
  */
15
15
  import { loadChain } from '../config.js';
16
+ import { readEvmBalance } from '../wallet/manager.js';
16
17
  /** Pure formatter — small, deterministic, easy to unit-test. */
17
18
  export function formatWalletReport(input) {
18
19
  return [
@@ -34,7 +35,7 @@ async function execute() {
34
35
  const { setupAgentWallet } = await import('@blockrun/llm');
35
36
  const c = setupAgentWallet({ silent: true });
36
37
  const address = c.getWalletAddress();
37
- const balance = await c.getBalance();
38
+ const balance = await readEvmBalance(chain, c);
38
39
  return { output: formatWalletReport({ chain, address, balanceUsd: balance }) };
39
40
  }
40
41
  catch (err) {
@@ -13,8 +13,8 @@
13
13
  * stocks endpoints (`/v1/stocks/{market}/price/{symbol}`) arrive in PR 2
14
14
  * together with the x402 signing wrapper.
15
15
  */
16
- import { USER_AGENT, loadChain } from '../../../config.js';
17
- import { gatewayHeaders, resolvePayMode } from '../../../payments/auth-mode.js';
16
+ import { API_URLS, USER_AGENT, loadChain } from '../../../config.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;
@@ -31,7 +31,8 @@ function gatewayUrl(path) {
31
31
  const mode = resolvePayMode();
32
32
  if (mode.kind === 'key')
33
33
  return mode.apiBase + path.replace(/^\/api/, '');
34
- const origin = loadChain() === 'solana' ? 'https://sol.blockrun.ai' : 'https://blockrun.ai';
34
+ // Wallet hosts end in /api and `path` already carries it.
35
+ const origin = API_URLS[loadChain()].replace(/\/api$/, '');
35
36
  return origin + path;
36
37
  }
37
38
  const cache = new Map();
@@ -190,7 +191,7 @@ export async function blockrunGetPaid(path, opts) {
190
191
  };
191
192
  try {
192
193
  let res = await fetch(url, { headers, signal: ctrl.signal });
193
- if (res.status === 402) {
194
+ if (res.status === 402 && walletMayPay(headers)) {
194
195
  try {
195
196
  const paid = await signGatewayPayment(res, chain, url);
196
197
  if (!paid) {
@@ -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: Sol Pro matches Sol at $5/$30, while Terra Pro ($1/$6)
49
- // and Luna Pro ($0.1/$0.6) come in UNDER their own base tiers — so the pro
50
- // ids are the better pick for anything reasoning-shaped. `gpt` stays pinned
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, 75% launch promo.
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',
@@ -1,3 +1,4 @@
1
+ import { type Chain } from '../config.js';
1
2
  export declare function walletExists(): boolean;
2
3
  export declare function setupWallet(): {
3
4
  address: string;
@@ -8,3 +9,17 @@ export declare function setupSolanaWallet(): Promise<{
8
9
  isNew: boolean;
9
10
  }>;
10
11
  export declare function getAddress(): string;
12
+ /**
13
+ * USDC balance of an EVM wallet on the given chain, in dollars.
14
+ *
15
+ * Base reads through the SDK. The SDK's reader is Base-only, so Arc asks the
16
+ * Arc gateway's free `/v1/balance`, which reads the USDC ERC-20 at 0x3600…0000
17
+ * (6 decimals) through BlockRun's own Arc RPC — public Arc proxies answer
18
+ * eth_chainId but fail eth_call. Like the Base reader this THROWS on failure
19
+ * rather than returning 0, so an unreachable endpoint never reads as an empty
20
+ * wallet.
21
+ */
22
+ export declare function readEvmBalance(chain: Exclude<Chain, 'solana'>, client: {
23
+ getWalletAddress(): string;
24
+ getBalance(): Promise<number>;
25
+ }): Promise<number>;
@@ -1,5 +1,5 @@
1
1
  import { getOrCreateWallet, scanWallets, getWalletAddress, getOrCreateSolanaWallet, scanSolanaWallets, } from '@blockrun/llm';
2
- import { loadChain } from '../config.js';
2
+ import { API_URLS, USER_AGENT, loadChain } from '../config.js';
3
3
  export function walletExists() {
4
4
  const chain = loadChain();
5
5
  if (chain === 'solana') {
@@ -21,3 +21,29 @@ export function getAddress() {
21
21
  throw new Error('No wallet found. Run `franklin setup` first.');
22
22
  return addr;
23
23
  }
24
+ /**
25
+ * USDC balance of an EVM wallet on the given chain, in dollars.
26
+ *
27
+ * Base reads through the SDK. The SDK's reader is Base-only, so Arc asks the
28
+ * Arc gateway's free `/v1/balance`, which reads the USDC ERC-20 at 0x3600…0000
29
+ * (6 decimals) through BlockRun's own Arc RPC — public Arc proxies answer
30
+ * eth_chainId but fail eth_call. Like the Base reader this THROWS on failure
31
+ * rather than returning 0, so an unreachable endpoint never reads as an empty
32
+ * wallet.
33
+ */
34
+ export async function readEvmBalance(chain, client) {
35
+ if (chain !== 'arc')
36
+ return client.getBalance();
37
+ const address = client.getWalletAddress();
38
+ const res = await fetch(`${API_URLS.arc}/v1/balance?address=${encodeURIComponent(address)}`, {
39
+ headers: { 'User-Agent': USER_AGENT, Accept: 'application/json' },
40
+ signal: AbortSignal.timeout(10_000),
41
+ });
42
+ if (!res.ok)
43
+ throw new Error(`Arc balance read failed (HTTP ${res.status})`);
44
+ const body = (await res.json());
45
+ if (typeof body.balance !== 'string' || !/^\d+$/.test(body.balance)) {
46
+ throw new Error('Arc balance read returned no balance');
47
+ }
48
+ return Number(BigInt(body.balance)) / 1_000_000;
49
+ }
@@ -31,6 +31,7 @@
31
31
  import { setupAgentWallet, setupAgentSolanaWallet } from '@blockrun/llm';
32
32
  import { loadChain } from '../config.js';
33
33
  import { fetchCreditBalance, isKeyMode } from '../payments/auth-mode.js';
34
+ import { readEvmBalance } from './manager.js';
34
35
  const BALANCE_CACHE_MS = 5_000;
35
36
  /**
36
37
  * Settlement margin added on top of the caller-supplied request timeout for
@@ -86,12 +87,13 @@ async function readSpendableBalance() {
86
87
  const credit = await fetchCreditBalance().catch(() => null);
87
88
  return credit?.remainingUsd ?? Number.POSITIVE_INFINITY;
88
89
  }
89
- if (loadChain() === 'solana') {
90
+ const chain = loadChain();
91
+ if (chain === 'solana') {
90
92
  const client = await setupAgentSolanaWallet({ silent: true });
91
93
  return readSolanaBalance(() => client.getBalance());
92
94
  }
93
95
  const client = setupAgentWallet({ silent: true });
94
- return client.getBalance();
96
+ return readEvmBalance(chain, client);
95
97
  }
96
98
  class WalletReservationManager {
97
99
  reserved = new Map();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blockrun/franklin",
3
- "version": "3.47.0",
3
+ "version": "3.49.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": {
@@ -38,14 +38,14 @@
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/api-key.local.mjs test/solana-migration.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 test/model-catalog.local.mjs",
41
+ "test": "npm run build && node --test --test-concurrency=4 --test-reporter=spec test/local.mjs test/api-key.local.mjs test/solana-migration.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 test/model-catalog.local.mjs test/arc.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",
45
45
  "test:all": "npm run test && npm run test:e2e",
46
46
  "test:watch": "node --test --watch test/local.mjs test/skills.local.mjs test/exa.local.mjs test/audit-batch.local.mjs",
47
47
  "test:e2e:watch": "node --test --watch test/e2e.mjs",
48
- "test:catalog": "npm run build && node --test test/model-catalog.local.mjs"
48
+ "test:catalog": "npm run build && node --test test/model-catalog.local.mjs test/arc.local.mjs"
49
49
  },
50
50
  "keywords": [
51
51
  "franklin",
@@ -75,7 +75,8 @@
75
75
  "node": ">=20.19.0"
76
76
  },
77
77
  "dependencies": {
78
- "@blockrun/llm": "^3.13.1",
78
+ "@blockrun/llm": "^3.19.1",
79
+ "@blockrun/model-catalog": "https://codeload.github.com/BlockRunAI/model-catalog/tar.gz/465c45941fb8ea9d6858fe8402abc8ba8934be90",
79
80
  "@blockrun/router-core": "https://codeload.github.com/BlockRunAI/router-core/tar.gz/d7bc10ce184b3daa40bcc115b523fd629d847a52",
80
81
  "@colbymchenry/codegraph": "^1.5.0",
81
82
  "@modelcontextprotocol/sdk": "^1.29.0",
@@ -99,8 +100,7 @@
99
100
  "react": "^19.2.4",
100
101
  "sharp": "^0.35.3",
101
102
  "viem": "^2.48.1",
102
- "ws": "^8.21.1",
103
- "@blockrun/model-catalog": "https://codeload.github.com/BlockRunAI/model-catalog/tar.gz/2b55804b109cd132bd988096fb3617fb48e67cfb"
103
+ "ws": "^8.21.1"
104
104
  },
105
105
  "devDependencies": {
106
106
  "@types/node": "^26.1.1",