@blockrun/franklin 3.48.0 → 3.49.1

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.
@@ -694,6 +694,7 @@ a:hover { text-decoration:underline; }
694
694
  <div class="chain-switcher" role="tablist" aria-label="Payment chain">
695
695
  <button type="button" data-chain="base" id="chain-btn-base" role="tab">Base</button>
696
696
  <button type="button" data-chain="solana" id="chain-btn-solana" role="tab">Solana</button>
697
+ <button type="button" data-chain="arc" id="chain-btn-arc" role="tab">Arc</button>
697
698
  </div>
698
699
  <span class="chain-switcher-note" id="chain-switcher-note"></span>
699
700
 
@@ -735,7 +736,7 @@ a:hover { text-decoration:underline; }
735
736
  <strong>This overwrites your existing wallet file.</strong>
736
737
  Make sure the current key is backed up first, or you will lose access to any funds still on it.
737
738
  </p>
738
- <textarea id="wallet-import-input" class="wallet-import-input" placeholder="0x… (Base) or base58 key (Solana)"></textarea>
739
+ <textarea id="wallet-import-input" class="wallet-import-input" placeholder="0x… (Base / Arc) or base58 key (Solana)"></textarea>
739
740
  <div class="wallet-actions">
740
741
  <button class="btn btn-danger" id="wallet-import-btn">Import &amp; replace</button>
741
742
  <span class="wallet-import-status" id="wallet-import-status"></span>
@@ -1190,6 +1191,8 @@ async function loadLearnings() {
1190
1191
  }).join('');
1191
1192
  }
1192
1193
 
1194
+ // Payment-chain switcher buttons, in display order.
1195
+ const CHAIN_BUTTON_IDS = ['chain-btn-base', 'chain-btn-solana', 'chain-btn-arc'];
1193
1196
  async function loadWallet() {
1194
1197
  const w = await api('wallet');
1195
1198
  if (!w) return;
@@ -1199,56 +1202,71 @@ async function loadWallet() {
1199
1202
  document.getElementById('wallet-chain-pill').textContent = w.chain || '—';
1200
1203
 
1201
1204
  // Chain switcher — highlight active button
1202
- const baseBtn = document.getElementById('chain-btn-base');
1203
- const solanaBtn = document.getElementById('chain-btn-solana');
1204
- if (baseBtn && solanaBtn) {
1205
- baseBtn.classList.toggle('active', w.chain === 'base');
1206
- solanaBtn.classList.toggle('active', w.chain === 'solana');
1207
- }
1205
+ CHAIN_BUTTON_IDS.forEach((id) => {
1206
+ const b = document.getElementById(id);
1207
+ if (b) b.classList.toggle('active', b.getAttribute('data-chain') === w.chain);
1208
+ });
1208
1209
 
1209
- // Coinbase Onramp works on both chains — the gateway of the active chain
1210
- // mints the link, so the buy button stays visible on Base and Solana alike.
1210
+ // Coinbase Onramp funds Base and Solana — the gateway of the active chain
1211
+ // mints the link. It cannot deliver to Arc (the Arc gateway refuses any
1212
+ // network but Base), so on Arc the card button is replaced by a hint.
1213
+ const onrampActions = document.getElementById('wallet-onramp-actions');
1214
+ const onrampHint = document.getElementById('wallet-onramp-hint');
1215
+ const onrampOk = w.chain !== 'arc';
1216
+ if (onrampActions) onrampActions.style.display = onrampOk ? 'flex' : 'none';
1217
+ if (onrampHint) onrampHint.textContent = onrampOk
1218
+ ? 'Powered by Coinbase Onramp \u00b7 60+ fiat currencies'
1219
+ : 'Card purchase is not available on Arc \u2014 send USDC on Arc (chain 5042) to this address.';
1211
1220
 
1212
1221
  // QR via server — never leak address to third parties.
1213
1222
  // Encode chain + USDC token in the QR payload so wallet apps land
1214
1223
  // directly on the right network/token instead of a bare address:
1215
1224
  // Base → EIP-681: ethereum:<USDC>@8453/transfer?address=<addr>
1225
+ // Arc → EIP-681: ethereum:<USDC>@5042/transfer?address=<addr>
1216
1226
  // Solana → Solana Pay: solana:<addr>?spl-token=<USDC mint>
1217
1227
  const qrBox = document.getElementById('wallet-qr');
1218
1228
  const hint = document.getElementById('wallet-qr-hint');
1219
1229
  if (addr && addr !== 'not set') {
1220
1230
  const USDC_BASE = '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913';
1231
+ const USDC_ARC = '0x3600000000000000000000000000000000000000';
1221
1232
  const USDC_SOL_MINT = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v';
1222
1233
  const payload = w.chain === 'solana'
1223
1234
  ? 'solana:' + addr + '?spl-token=' + USDC_SOL_MINT
1224
- : 'ethereum:' + USDC_BASE + '@8453/transfer?address=' + addr;
1235
+ : w.chain === 'arc'
1236
+ ? 'ethereum:' + USDC_ARC + '@5042/transfer?address=' + addr
1237
+ : 'ethereum:' + USDC_BASE + '@8453/transfer?address=' + addr;
1225
1238
  const svg = await fetch('/api/wallet/qr?data=' + encodeURIComponent(payload)).then(r => r.ok ? r.text() : null);
1226
1239
  qrBox.innerHTML = svg || '';
1227
1240
  hint.textContent = w.chain === 'solana'
1228
1241
  ? 'Scan with a Solana wallet (Phantom, Solflare) to send USDC SPL.'
1229
- : 'Scan with an EVM wallet (MetaMask, Coinbase) to send USDC on Base.';
1242
+ : w.chain === 'arc'
1243
+ ? 'Scan with an EVM wallet to send USDC on Arc (chain 5042). Same address as your Base wallet.'
1244
+ : 'Scan with an EVM wallet (MetaMask, Coinbase) to send USDC on Base.';
1230
1245
  } else {
1231
1246
  qrBox.innerHTML = '';
1232
1247
  hint.textContent = 'No wallet set yet — run: franklin setup';
1233
1248
  }
1234
1249
  }
1235
1250
 
1236
- // Chain switcher — click "Base" or "Solana" to flip payment chain.
1237
- // Creates a wallet on the target chain if one does not exist yet.
1238
- // Note: a currently-running franklin agent reads its chain at startup,
1239
- // so a mid-session switch only affects the next agent invocation.
1240
- ['chain-btn-base', 'chain-btn-solana'].forEach((id) => {
1251
+ // Chain switcher — click "Base", "Solana" or "Arc" to flip payment chain.
1252
+ // Creates a wallet on the target chain if one does not exist yet (Base and
1253
+ // Arc share one EVM wallet). Note: a currently-running franklin agent reads
1254
+ // its chain at startup, so a mid-session switch only affects the next run.
1255
+ function setChainButtonsDisabled(disabled) {
1256
+ CHAIN_BUTTON_IDS.forEach((id) => {
1257
+ const b = document.getElementById(id);
1258
+ if (b) b.disabled = disabled;
1259
+ });
1260
+ }
1261
+ CHAIN_BUTTON_IDS.forEach((id) => {
1241
1262
  const btn = document.getElementById(id);
1242
1263
  if (!btn) return;
1243
1264
  btn.addEventListener('click', async () => {
1244
1265
  const target = btn.getAttribute('data-chain');
1245
1266
  const note = document.getElementById('chain-switcher-note');
1246
- const baseBtn = document.getElementById('chain-btn-base');
1247
- const solanaBtn = document.getElementById('chain-btn-solana');
1248
1267
  // Skip if already active
1249
1268
  if (btn.classList.contains('active')) return;
1250
- baseBtn.disabled = true;
1251
- solanaBtn.disabled = true;
1269
+ setChainButtonsDisabled(true);
1252
1270
  note.textContent = 'Switching to ' + target + '…';
1253
1271
  // The onramp status (e.g. a popup-blocked Coinbase link) belongs to the
1254
1272
  // previous chain's wallet — a stale link would fund the wrong chain.
@@ -1273,8 +1291,7 @@ async function loadWallet() {
1273
1291
  } catch (err) {
1274
1292
  note.textContent = 'Error: ' + (err && err.message ? err.message : 'network error');
1275
1293
  } finally {
1276
- baseBtn.disabled = false;
1277
- solanaBtn.disabled = false;
1294
+ setChainButtonsDisabled(false);
1278
1295
  }
1279
1296
  });
1280
1297
  });
@@ -6,7 +6,7 @@
6
6
  import http from 'node:http';
7
7
  import fs from 'node:fs';
8
8
  import path from 'node:path';
9
- import { loadChain, saveChain } from '../config.js';
9
+ import { loadChain, saveChain, isChain, CHAIN_LABELS } from '../config.js';
10
10
  import { listNumbers as gatewayListNumbers, renewNumber as gatewayRenewNumber, buyNumber as gatewayBuyNumber, releaseNumber as gatewayReleaseNumber, } from '../phone/client.js';
11
11
  import { readCache as readPhoneCache, writeCache as writePhoneCache, clearCache as clearPhoneCache, isFresh as isPhoneCacheFresh, } from '../phone/cache.js';
12
12
  import { getStatsSummary, getStatsFilePath } from '../stats/tracker.js';
@@ -24,6 +24,7 @@ import { isTerminalTaskStatus } from '../tasks/types.js';
24
24
  import { readLiveAgents } from '../session/live-registry.js';
25
25
  import { BLOCKRUN_DIR } from '../config.js';
26
26
  import { getHTML } from './html.js';
27
+ import { readEvmBalance } from '../wallet/manager.js';
27
28
  const sseClients = new Set();
28
29
  function json(res, data, status = 200) {
29
30
  res.writeHead(status, {
@@ -103,7 +104,7 @@ function broadcast(data) {
103
104
  }
104
105
  }
105
106
  /**
106
- * Resolve the current active wallet address (Base or Solana, depending on
107
+ * Resolve the current active wallet address (EVM for Base/Arc, or Solana, depending on
107
108
  * the active chain). Used by phone endpoints that key the cache by wallet,
108
109
  * and that must sign x402 payments out of the wallet the user owns.
109
110
  *
@@ -293,7 +294,7 @@ export function createPanelServer(port) {
293
294
  const { setupAgentWallet } = await import('@blockrun/llm');
294
295
  const client = setupAgentWallet({ silent: true });
295
296
  address = client.getWalletAddress();
296
- balance = await client.getBalance();
297
+ balance = await readEvmBalance(chain, client);
297
298
  }
298
299
  json(res, { address, balance, chain });
299
300
  }
@@ -420,7 +421,7 @@ export function createPanelServer(port) {
420
421
  // Base: 0x + 64 hex chars
421
422
  const normalized = pk.startsWith('0x') ? pk : `0x${pk}`;
422
423
  if (!/^0x[0-9a-fA-F]{64}$/.test(normalized)) {
423
- json(res, { error: 'invalid Base private key — expected 0x + 64 hex chars' }, 400);
424
+ json(res, { error: `invalid ${CHAIN_LABELS[chain]} private key — expected 0x + 64 hex chars` }, 400);
424
425
  return;
425
426
  }
426
427
  saveWallet(normalized);
@@ -454,8 +455,8 @@ export function createPanelServer(port) {
454
455
  const raw = await readBody(req);
455
456
  const body = JSON.parse(raw);
456
457
  const target = body.chain;
457
- if (target !== 'base' && target !== 'solana') {
458
- json(res, { error: 'chain must be "base" or "solana"' }, 400);
458
+ if (!isChain(target)) {
459
+ json(res, { error: 'chain must be "base", "solana" or "arc"' }, 400);
459
460
  return;
460
461
  }
461
462
  saveChain(target);
@@ -472,7 +473,7 @@ export function createPanelServer(port) {
472
473
  const { setupAgentWallet } = await import('@blockrun/llm');
473
474
  const client = setupAgentWallet({ silent: true });
474
475
  address = client.getWalletAddress();
475
- balance = await client.getBalance();
476
+ balance = await readEvmBalance(target, client);
476
477
  }
477
478
  json(res, { ok: true, chain: target, address, balance });
478
479
  }
@@ -3,7 +3,8 @@
3
3
  *
4
4
  * Franklin can reach the BlockRun gateway two ways:
5
5
  *
6
- * wallet — blockrun.ai/api (Base) or sol.blockrun.ai/api (Solana). Every
6
+ * wallet — blockrun.ai/api (Base), sol.blockrun.ai/api (Solana) or
7
+ * arc.blockrun.ai/api (Arc). Every
7
8
  * paid call answers a 402 by signing USDC from the local wallet.
8
9
  * key — api.blockrun.ai with `Authorization: Bearer brk_...`, settled
9
10
  * against a prepaid credit balance. No chain involved.
@@ -3,7 +3,8 @@
3
3
  *
4
4
  * Franklin can reach the BlockRun gateway two ways:
5
5
  *
6
- * wallet — blockrun.ai/api (Base) or sol.blockrun.ai/api (Solana). Every
6
+ * wallet — blockrun.ai/api (Base), sol.blockrun.ai/api (Solana) or
7
+ * arc.blockrun.ai/api (Arc). Every
7
8
  * paid call answers a 402 by signing USDC from the local wallet.
8
9
  * key — api.blockrun.ai with `Authorization: Bearer brk_...`, settled
9
10
  * against a prepaid credit balance. No chain involved.
@@ -218,7 +218,8 @@ export function createProxy(options) {
218
218
  const effectiveStreamTimeoutMs = options.streamTimeoutMs ?? getProxyStreamTimeoutMs();
219
219
  let baseWallet = null;
220
220
  let solanaWallet = null;
221
- if (chain === 'base') {
221
+ // Base and Arc both pay from the EVM wallet; the 402 names the network.
222
+ if (chain !== 'solana') {
222
223
  const w = getOrCreateWallet();
223
224
  baseWallet = { privateKey: w.privateKey, address: w.address };
224
225
  }
@@ -20,6 +20,7 @@
20
20
  import { type ApprovalRequest } from '../agent/approvals.js';
21
21
  import { type AgentRunState } from '../events/types.js';
22
22
  import type { AgentConfig, StreamEvent } from '../agent/types.js';
23
+ import type { Chain } from '../config.js';
23
24
  export declare function resolveHostedMaxSpendUsd(requested: number | undefined, ceiling: number | undefined): number | undefined;
24
25
  export interface DispatchOptions {
25
26
  prompt: string;
@@ -43,7 +44,7 @@ export declare class AgentHost {
43
44
  private agents;
44
45
  constructor(opts: {
45
46
  workDir: string;
46
- chain: 'base' | 'solana';
47
+ chain: Chain;
47
48
  apiUrl: string;
48
49
  defaultModel: string;
49
50
  debug?: boolean;
@@ -39,6 +39,7 @@ import { retryFetchBalance } from '../commands/balance-retry.js';
39
39
  import { AgentHost } from './agent-host.js';
40
40
  import { bus } from '../events/bus.js';
41
41
  import { FREE_DEFAULT_MODEL } from '../free-models.js';
42
+ import { readEvmBalance } from '../wallet/manager.js';
42
43
  // Curated Base (chainId 8453) tokens for the wallet "holdings" view. Plain RPC
43
44
  // can't enumerate every token an address holds (no on-chain "list all"), so we
44
45
  // balanceOf a known set and show the non-zero ones. `stable` → USD ≈ amount.
@@ -523,7 +524,9 @@ export async function startServer(opts) {
523
524
  async function fetchBalanceUsd() {
524
525
  try {
525
526
  const client = await getWallet();
526
- return await retryFetchBalance(() => client.getBalance());
527
+ return await retryFetchBalance(() => chain === 'solana'
528
+ ? client.getBalance()
529
+ : readEvmBalance(chain, client));
527
530
  }
528
531
  catch {
529
532
  return undefined;
@@ -2,6 +2,7 @@
2
2
  * Session persistence for Franklin.
3
3
  * Saves conversation history as JSONL for resume capability.
4
4
  */
5
+ import { type Chain } from '../config.js';
5
6
  import type { Dialogue } from '../agent/types.js';
6
7
  export declare function setSessionPersistenceDisabled(disabled: boolean): void;
7
8
  export declare function isSessionPersistenceDisabled(): boolean;
@@ -24,7 +25,7 @@ export interface SessionMeta {
24
25
  * conversation context — switching chains mid-resume is a bug.
25
26
  * Optional for back-compat with pre-3.15.35 sessions.
26
27
  */
27
- chain?: 'base' | 'solana';
28
+ chain?: Chain;
28
29
  inputTokens?: number;
29
30
  outputTokens?: number;
30
31
  costUsd?: number;
@@ -23,6 +23,7 @@
23
23
  */
24
24
  import { Registry } from './registry.js';
25
25
  import type { LoadError } from './types.js';
26
+ import { type Chain } from '../config.js';
26
27
  export interface BundledLoad {
27
28
  registry: Registry;
28
29
  errors: LoadError[];
@@ -45,6 +46,6 @@ export declare function loadAllSkills(workDir: string): AllSkillsLoad;
45
46
  export declare function ensureUserSkillsDir(): string;
46
47
  export declare function ensureLearnedSkillsDir(): string;
47
48
  export interface SkillVarSource {
48
- chain?: 'base' | 'solana';
49
+ chain?: Chain;
49
50
  }
50
51
  export declare function getSkillVars(src: SkillVarSource): Record<string, string>;
@@ -527,7 +527,7 @@ function buildExecute(deps) {
527
527
  ? `\n\nOpen with: open ${savedPaths[0]}`
528
528
  : `\n\nOpen with: open ${savedPaths.join(' ')}`;
529
529
  return {
530
- output: `${header}${revisedPrompt}${openHint}${contentSummary}`,
530
+ output: `${header}\nPrompt sent: ${chosenPrompt}${revisedPrompt}${openHint}${contentSummary}`,
531
531
  };
532
532
  }
533
533
  catch (err) {
@@ -662,7 +662,9 @@ export function createImageGenCapability(deps = {}) {
662
662
  input_schema: {
663
663
  type: 'object',
664
664
  properties: {
665
- prompt: { type: 'string', description: 'Text description of the image to generate, or edit instructions when a reference image is provided' },
665
+ prompt: { type: 'string', description: 'Self-contained text description of the image to generate, or edit instructions when a reference image is provided. ' +
666
+ 'The image model sees ONLY this text, never the conversation: when the user refers to earlier messages ("these numbers", "that chart"), ' +
667
+ 'write those details (figures, names, labels, quoted text) into the prompt verbatim. Never invent data the user did not give.' },
666
668
  output_path: { type: 'string', description: 'Where to save the image. Default: generated-<timestamp>.png in working directory. With n>1, a -1/-2/... suffix is appended before the extension.' },
667
669
  size: { type: 'string', description: 'Image size. gpt-image-1/2: 1024x1024, 1536x1024, 1024x1536. google/nano-banana: 1024x1024. google/nano-banana-pro: 1024x1024, 2048x2048, 4096x4096. Default: 1024x1024. Note: openai/gpt-image-2 is forced to 1024x1024 (other sizes time out at the gateway).' },
668
670
  model: { type: 'string', description: 'Image model to use. Default: openai/gpt-image-1 (text-to-image) / openai/gpt-image-2 (image-to-image).' },
@@ -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
@@ -23,6 +23,7 @@ import { isWalletKeyPath } from './sensitive-paths.js';
23
23
  import { findModel, estimateCostUsd } from '../gateway-models.js';
24
24
  import { recordUsage } from '../stats/tracker.js';
25
25
  import { noChargeNote } from '../payments/billing-copy.js';
26
+ import { pollImageJob } from './imagegen.js';
26
27
  const DEFAULT_MODEL = 'minimax/music-2.5+';
27
28
  // Flat per-track price for the default model — already margin-inclusive
28
29
  // ($0.15/track × 1.05 gateway margin). Fallback when the catalog is unavailable.
@@ -111,8 +112,9 @@ function buildExecute(deps) {
111
112
  headers,
112
113
  body,
113
114
  });
115
+ let paymentHeaders = null;
114
116
  if (response.status === 402 && walletMayPay(headers)) {
115
- const paymentHeaders = await signPayment(response, chain, endpoint);
117
+ paymentHeaders = await signPayment(response, chain, endpoint);
116
118
  if (!paymentHeaders) {
117
119
  return { output: 'Payment failed. Check wallet balance with: franklin balance', isError: true };
118
120
  }
@@ -130,7 +132,48 @@ function buildExecute(deps) {
130
132
  isError: true,
131
133
  };
132
134
  }
133
- const result = (await response.json());
135
+ let result = (await response.json());
136
+ // Slow tracks outrun the gateway's inline window: it answers 202 +
137
+ // poll_url and settles on the first completed poll, so nothing is charged
138
+ // until then. Same contract (and same signed header on each poll) as the
139
+ // ImageGen async path.
140
+ if (response.status === 202 && result.poll_url) {
141
+ const pollEndpoint = result.poll_url.startsWith('http')
142
+ ? result.poll_url
143
+ : `${new URL(apiUrl).origin}${result.poll_url}`;
144
+ clearTimeout(timeout);
145
+ let outcome = await pollImageJob(pollEndpoint, paymentHeaders ? { ...headers, ...paymentHeaders } : headers, controller.signal);
146
+ // The poll may refuse the POST's authorization: the gateway builds the
147
+ // poll's requirements with a longer timeout than the music POST's, and a
148
+ // strict facilitator (Circle, on Arc) rejects the mismatch as
149
+ // invalid_payment_requirements. The poll publishes its own 402 challenge
150
+ // and accepts a fresh signature from the same wallet, so sign that one.
151
+ // The job settles once, on the first completed poll: no double charge.
152
+ if (outcome.kind === 'poll_http_error' && outcome.status === 402 && paymentHeaders && walletMayPay(headers)) {
153
+ const challenge = await fetch(pollEndpoint, { method: 'GET', headers, signal: controller.signal });
154
+ const fresh = challenge.status === 402 ? await signPayment(challenge, chain, pollEndpoint) : null;
155
+ if (fresh) {
156
+ outcome = await pollImageJob(pollEndpoint, { ...headers, ...fresh }, controller.signal);
157
+ }
158
+ }
159
+ if (outcome.kind === 'failed') {
160
+ return {
161
+ output: `Music generation failed upstream: ${JSON.stringify(outcome.error ?? '').slice(0, 240)}. ${noChargeNote()}`,
162
+ isError: true,
163
+ };
164
+ }
165
+ if (outcome.kind === 'poll_http_error') {
166
+ return { output: `Music poll failed (${outcome.status}): ${outcome.bodyPreview}`, isError: true };
167
+ }
168
+ if (outcome.kind === 'timed_out') {
169
+ return {
170
+ output: 'Music generation was queued but did not complete within 5 minutes. ' +
171
+ 'The gateway only charges when a poll sees the finished track.',
172
+ isError: true,
173
+ };
174
+ }
175
+ result = outcome.body;
176
+ }
134
177
  const track = result.data?.[0];
135
178
  if (!track?.url) {
136
179
  return { output: 'No track URL returned from API', isError: true };
@@ -189,7 +232,8 @@ function buildExecute(deps) {
189
232
  }
190
233
  }
191
234
  return {
192
- output: `Track saved to ${outPath} (${sizeMB}MB, ${dur}s, ${musicModel})\n\n` +
235
+ output: `Track saved to ${outPath} (${sizeMB}MB, ${dur}s, ${musicModel})\n` +
236
+ `Prompt sent: ${prompt}\n\n` +
193
237
  `Open with: open ${outPath}${lyricsPreview}${contentSummary}`,
194
238
  };
195
239
  }
@@ -272,7 +316,9 @@ export function createMusicGenCapability(deps = {}) {
272
316
  input_schema: {
273
317
  type: 'object',
274
318
  properties: {
275
- prompt: { type: 'string', description: 'Music style / mood / description' },
319
+ prompt: { type: 'string', description: 'Self-contained music style / mood / description. ' +
320
+ 'The music model sees ONLY this text, never the conversation: when the user refers to earlier messages, ' +
321
+ 'write those details into the prompt.' },
276
322
  output_path: { type: 'string', description: 'Where to save the MP3. Default: generated-<timestamp>.mp3' },
277
323
  model: { type: 'string', description: 'Music model. Default: minimax/music-2.5+' },
278
324
  instrumental: { type: 'boolean', description: 'No vocals. Cannot combine with `lyrics`.' },
@@ -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;
@@ -366,7 +366,8 @@ function buildExecute(deps) {
366
366
  }
367
367
  }
368
368
  return {
369
- output: `Video saved to ${outPath} (${sizeMB}MB, ${dur}s, ${videoModel})\n\n` +
369
+ output: `Video saved to ${outPath} (${sizeMB}MB, ${dur}s, ${videoModel})\n` +
370
+ `Prompt sent: ${prompt}\n\n` +
370
371
  `Open with: open ${outPath}${contentSummary}`,
371
372
  };
372
373
  }
@@ -503,7 +504,9 @@ export function createVideoGenCapability(deps = {}) {
503
504
  input_schema: {
504
505
  type: 'object',
505
506
  properties: {
506
- prompt: { type: 'string', description: 'Text description of the video to generate' },
507
+ prompt: { type: 'string', description: 'Self-contained text description of the video to generate. ' +
508
+ 'The video model sees ONLY this text, never the conversation: when the user refers to earlier messages, ' +
509
+ 'write those details (scenes, names, quoted text) into the prompt verbatim.' },
507
510
  output_path: { type: 'string', description: 'Where to save the MP4. Default: generated-<timestamp>.mp4 in working directory' },
508
511
  model: {
509
512
  type: 'string',
@@ -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,7 +13,7 @@
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';
16
+ import { API_URLS, USER_AGENT, loadChain } from '../../../config.js';
17
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';
@@ -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();
@@ -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();