@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.
- package/README.md +17 -8
- package/dist/agent/commands.js +11 -9
- package/dist/agent/context.js +5 -5
- package/dist/agent/types.d.ts +2 -1
- package/dist/channel/slack.js +4 -2
- package/dist/channel/telegram.js +4 -2
- package/dist/commands/balance.js +5 -4
- package/dist/commands/doctor.js +3 -2
- package/dist/commands/proxy.js +4 -4
- package/dist/commands/setup.js +6 -5
- package/dist/commands/start.js +4 -2
- package/dist/config.d.ts +13 -1
- package/dist/config.js +28 -8
- package/dist/index.js +4 -4
- package/dist/model-catalog.d.ts +3 -2
- package/dist/model-catalog.js +18 -8
- package/dist/onramp/client.js +5 -0
- package/dist/panel/html.js +39 -22
- package/dist/panel/server.js +8 -7
- package/dist/payments/auth-mode.d.ts +2 -1
- package/dist/payments/auth-mode.js +2 -1
- package/dist/proxy/server.js +2 -1
- package/dist/serve/agent-host.d.ts +2 -1
- package/dist/serve/server.js +4 -1
- package/dist/session/storage.d.ts +2 -1
- package/dist/skills/bootstrap.d.ts +2 -1
- package/dist/tools/imagegen.js +4 -2
- package/dist/tools/moa.d.ts +2 -1
- package/dist/tools/modal.d.ts +2 -1
- package/dist/tools/musicgen.js +50 -4
- package/dist/tools/subagent.d.ts +2 -1
- package/dist/tools/videogen.js +5 -2
- package/dist/tools/wallet.d.ts +2 -1
- package/dist/tools/wallet.js +2 -1
- package/dist/trading/providers/blockrun/client.js +3 -2
- package/dist/wallet/manager.d.ts +15 -0
- package/dist/wallet/manager.js +27 -1
- package/dist/wallet/reservation.js +4 -2
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -74,7 +74,7 @@ franklin
|
|
|
74
74
|
# Pick ONE — a USDC wallet, or a prepaid API key.
|
|
75
75
|
|
|
76
76
|
# a) Wallet — no signup, no account
|
|
77
|
-
franklin setup solana # or: franklin setup base
|
|
77
|
+
franklin setup solana # or: franklin setup base / franklin setup arc
|
|
78
78
|
franklin balance # show address + USDC balance
|
|
79
79
|
|
|
80
80
|
# b) API key — sign up and top up at https://user.blockrun.ai
|
|
@@ -163,12 +163,20 @@ interchangeable. Everything else about the agent is identical.
|
|
|
163
163
|
| --- | --- | --- |
|
|
164
164
|
| Setup | `franklin setup solana` | Sign up, top up, `franklin login brk_...` |
|
|
165
165
|
| Account required | No | Yes |
|
|
166
|
-
| Crypto required | Yes — USDC on Solana or
|
|
166
|
+
| Crypto required | Yes — USDC on Solana, Base or Arc | No — top up with a card |
|
|
167
167
|
| Settlement | On-chain, per call, via [x402](https://x402.org) | Against a prepaid balance |
|
|
168
|
-
| Gateway | `sol.blockrun.ai` / `blockrun.ai` | `api.blockrun.ai` |
|
|
168
|
+
| Gateway | `sol.blockrun.ai` / `blockrun.ai` / `arc.blockrun.ai` | `api.blockrun.ai` |
|
|
169
169
|
| Where the money lives | A wallet only you hold the key to | Your BlockRun account |
|
|
170
170
|
| Spend visibility | `franklin stats` — exact settled amounts | `franklin balance` + [dashboard](https://user.blockrun.ai/dashboard); exact except chat |
|
|
171
171
|
|
|
172
|
+
**Three wallet chains.** Solana (the default), Base, or Circle's [Arc](https://arc.network)
|
|
173
|
+
(chain 5042). Switch with `franklin solana` / `franklin base` / `franklin arc`, or the chain
|
|
174
|
+
buttons on the panel's wallet page. Base and Arc share one EVM key, so the same address
|
|
175
|
+
receives USDC on both; Solana has its own key. Card purchase (Coinbase Onramp) funds Base
|
|
176
|
+
and Solana only — on Arc, send USDC to the address directly. `franklin balance` always
|
|
177
|
+
reports the active chain's USDC, so after switching to Arc it shows your Arc balance, not
|
|
178
|
+
Base's. Arc's gateway adds models after Base does; the picker lists what Arc serves today.
|
|
179
|
+
|
|
172
180
|
**The wallet is still Franklin's identity.** Memory, the trading journal and goals are
|
|
173
181
|
keyed to it, and the wallet route is the one that needs nothing from us — no signup, no
|
|
174
182
|
KYC, no account to suspend. The API key exists because not everyone wants to hold crypto
|
|
@@ -448,7 +456,7 @@ No single model is best at everything. Sonnet writes better code, Gemini handles
|
|
|
448
456
|
|
|
449
457
|
### 🔐 Wallet is identity
|
|
450
458
|
|
|
451
|
-
No email. No phone. No KYC. Your Solana or
|
|
459
|
+
No email. No phone. No KYC. Your Solana, Base or Arc address is your account — portable, permissionless, global. A wallet requires only USDC. (Prefer an account and a card? [Two ways to pay](#two-ways-to-pay) — the key route exists, it just is not the one that makes the agent sovereign.)
|
|
452
460
|
|
|
453
461
|
</td>
|
|
454
462
|
</tr>
|
|
@@ -495,7 +503,7 @@ Ask "generate a logo" — Franklin calls DALL-E / GPT Image, saves the result lo
|
|
|
495
503
|
Anthropic, OpenAI, Google, xAI, DeepSeek, GLM, Kimi, Minimax, NVIDIA free tier. One wallet, one interface, automatic fallback.
|
|
496
504
|
|
|
497
505
|
**💳 x402 micropayments (YOPO)**
|
|
498
|
-
HTTP 402 native. Every paid action is a signed USDC micropayment
|
|
506
|
+
HTTP 402 native. Every paid action is a signed USDC micropayment — an EIP-712 authorization on Base and Arc, a signed SPL transfer on Solana. Non-custodial: your keys never leave your machine. YOPO: you pay only for outcomes.
|
|
499
507
|
|
|
500
508
|
**🧠 Learned model router**
|
|
501
509
|
Trained on 2M+ real requests. Classifies your task and picks the best model from <!-- br:models.chatVisible -->82<!-- /br:models.chatVisible --> LLMs. Four profiles (auto/eco/premium/free). Adapts to your usage over time.
|
|
@@ -569,7 +577,7 @@ like `opus`, `gpt` and `grok` keep their current targets.
|
|
|
569
577
|
│ <!-- br:models.chatVisible@live -->82<!-- /br:models.chatVisible@live --> LLMs · CoinGecko · Search · Image APIs · paid services │
|
|
570
578
|
├──────────────────────────────────────────────────────────────┤
|
|
571
579
|
│ x402 Micropayment Protocol │
|
|
572
|
-
│ HTTP 402 · USDC on Solana &
|
|
580
|
+
│ HTTP 402 · USDC on Solana, Base & Arc · signed payloads │
|
|
573
581
|
└──────────────────────────────────────────────────────────────┘
|
|
574
582
|
│
|
|
575
583
|
▼
|
|
@@ -611,7 +619,7 @@ src/
|
|
|
611
619
|
├── ui/ Ink-based terminal UI
|
|
612
620
|
├── proxy/ Payment proxy for external tools
|
|
613
621
|
├── router/ Learned model router (<!-- br:models.chatVisible@live -->82<!-- /br:models.chatVisible@live --> models, Elo scoring)
|
|
614
|
-
├── wallet/ Wallet management (Base + Solana)
|
|
622
|
+
├── wallet/ Wallet management (Base/Arc + Solana)
|
|
615
623
|
├── mcp/ MCP server auto-discovery
|
|
616
624
|
└── commands/ CLI subcommands
|
|
617
625
|
```
|
|
@@ -727,7 +735,8 @@ Franklin uses [BlockRun Model Core](https://github.com/BlockRunAI/model-catalog)
|
|
|
727
735
|
for model metadata, picker policy and price estimates. The runtime dependency
|
|
728
736
|
is pinned to an immutable commit. On refresh, Franklin reads the public policy
|
|
729
737
|
snapshot and the active gateway's catalog, so new models and prices can appear
|
|
730
|
-
without a Franklin release. Base, Solana and API accounts have separate caches.
|
|
738
|
+
without a Franklin release. Base, Solana, Arc and API accounts have separate caches.
|
|
739
|
+
Arc reads Base's policy and offline snapshot, with live rows from `arc.blockrun.ai`.
|
|
731
740
|
The default picker shows Auto and curated groups; other available chat models
|
|
732
741
|
remain accessible through +more / Ctrl+A.
|
|
733
742
|
|
package/dist/agent/commands.js
CHANGED
|
@@ -1077,7 +1077,8 @@ export async function handleSlashCommand(input, ctx) {
|
|
|
1077
1077
|
}
|
|
1078
1078
|
// /wallet — show wallet info, import, or export
|
|
1079
1079
|
if (input === '/wallet' || input.startsWith('/wallet ')) {
|
|
1080
|
-
const
|
|
1080
|
+
const { loadChain, CHAIN_LABELS } = await import('../config.js');
|
|
1081
|
+
const chain = loadChain();
|
|
1081
1082
|
const args = input.slice(7).trim();
|
|
1082
1083
|
// /wallet export [--show] — key masked by default; --show prints the full key
|
|
1083
1084
|
// Rationale: terminal scrollback, screen recordings, and shared tmux sessions
|
|
@@ -1113,7 +1114,7 @@ export async function handleSlashCommand(input, ctx) {
|
|
|
1113
1114
|
return { handled: true };
|
|
1114
1115
|
}
|
|
1115
1116
|
const w = getOrCreateWallet();
|
|
1116
|
-
ctx.onEvent({ kind: 'text_delta', text: `**Wallet Export (
|
|
1117
|
+
ctx.onEvent({ kind: 'text_delta', text: `**Wallet Export (${CHAIN_LABELS[chain]})**\n` +
|
|
1117
1118
|
` Address: ${w.address}\n` +
|
|
1118
1119
|
` Private Key: ${showKey ? key : mask(key)}\n\n` +
|
|
1119
1120
|
(showKey
|
|
@@ -1136,16 +1137,16 @@ export async function handleSlashCommand(input, ctx) {
|
|
|
1136
1137
|
const key = args.slice(6).replace(/\s/g, '');
|
|
1137
1138
|
if (!key) {
|
|
1138
1139
|
ctx.onEvent({ kind: 'text_delta', text: `**Usage:** \`/wallet import <private-key>\`\n\n` +
|
|
1139
|
-
` Base:
|
|
1140
|
-
` Solana:
|
|
1140
|
+
` Base / Arc: \`/wallet import 0x...\` (hex, 66 chars)\n` +
|
|
1141
|
+
` Solana: \`/wallet import <bs58-key>\` (base58 encoded)\n`
|
|
1141
1142
|
});
|
|
1142
1143
|
emitDone(ctx);
|
|
1143
1144
|
return { handled: true };
|
|
1144
1145
|
}
|
|
1145
|
-
// Shape-validate before touching disk
|
|
1146
|
-
if (chain
|
|
1146
|
+
// Shape-validate before touching disk. Base and Arc share the EVM key.
|
|
1147
|
+
if (chain !== 'solana') {
|
|
1147
1148
|
if (!/^0x[0-9a-fA-F]{64}$/.test(key)) {
|
|
1148
|
-
ctx.onEvent({ kind: 'text_delta', text:
|
|
1149
|
+
ctx.onEvent({ kind: 'text_delta', text: `Import error: ${CHAIN_LABELS[chain]} key must be 0x + 64 hex chars (66 total).\n` });
|
|
1149
1150
|
emitDone(ctx);
|
|
1150
1151
|
return { handled: true };
|
|
1151
1152
|
}
|
|
@@ -1175,7 +1176,7 @@ export async function handleSlashCommand(input, ctx) {
|
|
|
1175
1176
|
const { saveWallet } = await import('@blockrun/llm');
|
|
1176
1177
|
const account = privateKeyToAccount(key);
|
|
1177
1178
|
saveWallet(key);
|
|
1178
|
-
ctx.onEvent({ kind: 'text_delta', text: `**Wallet Imported (
|
|
1179
|
+
ctx.onEvent({ kind: 'text_delta', text: `**Wallet Imported (${CHAIN_LABELS[chain]})**\n` +
|
|
1179
1180
|
` Address: ${account.address}\n` +
|
|
1180
1181
|
` Saved to: ~/.blockrun/wallet.json\n\n` +
|
|
1181
1182
|
`⚠️ IMPORTANT: This session is still using the OLD wallet.\n` +
|
|
@@ -1209,11 +1210,12 @@ export async function handleSlashCommand(input, ctx) {
|
|
|
1209
1210
|
}
|
|
1210
1211
|
else {
|
|
1211
1212
|
const { getOrCreateWallet, setupAgentWallet } = await import('@blockrun/llm');
|
|
1213
|
+
const { readEvmBalance } = await import('../wallet/manager.js');
|
|
1212
1214
|
const w = getOrCreateWallet();
|
|
1213
1215
|
address = w.address;
|
|
1214
1216
|
try {
|
|
1215
1217
|
const client = setupAgentWallet({ silent: true });
|
|
1216
|
-
const bal = await Promise.race([client
|
|
1218
|
+
const bal = await Promise.race([readEvmBalance(chain, client), fetchTimeout(5000)]);
|
|
1217
1219
|
balance = `$${bal.toFixed(2)} USDC`;
|
|
1218
1220
|
}
|
|
1219
1221
|
catch {
|
package/dist/agent/context.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import fs from 'node:fs';
|
|
6
6
|
import path from 'node:path';
|
|
7
7
|
import { execSync } from 'node:child_process';
|
|
8
|
-
import { BLOCKRUN_DIR } from '../config.js';
|
|
8
|
+
import { API_URLS, BLOCKRUN_DIR, CHAIN_LABELS, CHAINS } from '../config.js';
|
|
9
9
|
import { getWalletAddress as getBaseWalletAddress } from '@blockrun/llm';
|
|
10
10
|
import { Keypair } from '@solana/web3.js';
|
|
11
11
|
import bs58 from 'bs58';
|
|
@@ -264,9 +264,9 @@ function getBlockRunApiSection() {
|
|
|
264
264
|
const chargedBy = mode.kind === 'key' ? 'account credits' : 'x402 wallet payment';
|
|
265
265
|
const hosts = mode.kind === 'key'
|
|
266
266
|
? `- **Your host: \`https://api.blockrun.ai\`** — the account API. Requests carry your configured key; the built-in tools attach it. It is a SEPARATE service, not an alias of the Base gateway.
|
|
267
|
-
- Not yours:
|
|
268
|
-
: `- **Your host: \`${mode.apiBase}\`** — the ${mode.chain
|
|
269
|
-
- Not yours:
|
|
267
|
+
- Not yours: ${CHAINS.map(c => `\`${API_URLS[c]}\` (${CHAIN_LABELS[c]} x402 wallet)`).join(', ')}. They ignore an account key and answer 402. Never send one there, and never attach a wallet payment proof to an account request.`
|
|
268
|
+
: `- **Your host: \`${mode.apiBase}\`** — the ${CHAIN_LABELS[mode.chain]} x402 wallet gateway. Paid calls answer 402 and the tools sign from your ${CHAIN_LABELS[mode.chain]} wallet.
|
|
269
|
+
- Not yours: ${CHAINS.filter(c => c !== mode.chain).map(c => `\`${API_URLS[c]}\` (the ${CHAIN_LABELS[c]} wallet gateway)`).join(', ')} and \`https://api.blockrun.ai\` (the account API, which needs a key and 401s without one — it is not an alias of any wallet host).`;
|
|
270
270
|
return `# BlockRun Gateway API (the network you live on)
|
|
271
271
|
You run on the BlockRun AI Gateway. When the user asks you to "test the BlockRun API", "check all endpoints", or call the gateway directly, use ONLY the paths below. **Never invent, pluralize, or singularize an endpoint** — \`/v1/image/generate\` (singular) is wrong, \`/v1/images/generations\` (plural) is correct. If a path you have in mind isn't in this list, fetch the canonical discovery endpoints before calling it.
|
|
272
272
|
|
|
@@ -742,7 +742,7 @@ function buildEnvironmentSection(workingDir) {
|
|
|
742
742
|
if (wallet.chain)
|
|
743
743
|
lines.push(`- Active chain: ${wallet.chain}`);
|
|
744
744
|
if (wallet.base)
|
|
745
|
-
lines.push(`-
|
|
745
|
+
lines.push(`- EVM wallet address (Base and Arc): ${wallet.base} (private key at ~/.blockrun/.session)`);
|
|
746
746
|
if (wallet.solana)
|
|
747
747
|
lines.push(`- Solana wallet address: ${wallet.solana} (private key at ~/.blockrun/.solana-session)`);
|
|
748
748
|
}
|
package/dist/agent/types.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Core types for the Franklin agent system.
|
|
3
3
|
* All type names and structures are original designs.
|
|
4
4
|
*/
|
|
5
|
+
import type { Chain } from '../config.js';
|
|
5
6
|
export type Role = 'user' | 'assistant';
|
|
6
7
|
export interface TextSegment {
|
|
7
8
|
type: 'text';
|
|
@@ -157,7 +158,7 @@ export type StreamEvent = StreamTextDelta | StreamThinkingDelta | StreamCapabili
|
|
|
157
158
|
export interface AgentConfig {
|
|
158
159
|
model: string;
|
|
159
160
|
apiUrl: string;
|
|
160
|
-
chain:
|
|
161
|
+
chain: Chain;
|
|
161
162
|
systemInstructions: string[];
|
|
162
163
|
capabilities: CapabilityHandler[];
|
|
163
164
|
maxTurns?: number;
|
package/dist/channel/slack.js
CHANGED
|
@@ -28,6 +28,7 @@ import { interactiveSession } from '../agent/loop.js';
|
|
|
28
28
|
import { ModelClient } from '../agent/llm.js';
|
|
29
29
|
import { extractBrainEntities } from '../brain/extract.js';
|
|
30
30
|
import { extractLearnings } from '../learnings/extractor.js';
|
|
31
|
+
import { readEvmBalance } from '../wallet/manager.js';
|
|
31
32
|
// Slack's hard per-message cap is ~40 KB, but readability tanks long before
|
|
32
33
|
// that. Keep chunks small so a long answer arrives as a few tidy messages.
|
|
33
34
|
const CHUNK_MAX = 3500;
|
|
@@ -174,10 +175,11 @@ export async function runSlackBot(agentConfig, opts) {
|
|
|
174
175
|
await postMessage(target, `Chain: solana\nWallet: ${addr}\nBalance: $${bal.toFixed(2)} USDC`);
|
|
175
176
|
}
|
|
176
177
|
else {
|
|
178
|
+
const chain = agentConfig.chain;
|
|
177
179
|
const c = setupAgentWallet({ silent: true });
|
|
178
180
|
const addr = c.getWalletAddress();
|
|
179
|
-
const bal = await c
|
|
180
|
-
await postMessage(target, `Chain:
|
|
181
|
+
const bal = await readEvmBalance(chain, c);
|
|
182
|
+
await postMessage(target, `Chain: ${chain}\nWallet: ${addr}\nBalance: $${bal.toFixed(2)} USDC`);
|
|
181
183
|
}
|
|
182
184
|
}
|
|
183
185
|
catch (err) {
|
package/dist/channel/telegram.js
CHANGED
|
@@ -23,6 +23,7 @@ import { interactiveSession } from '../agent/loop.js';
|
|
|
23
23
|
import { ModelClient } from '../agent/llm.js';
|
|
24
24
|
import { extractBrainEntities } from '../brain/extract.js';
|
|
25
25
|
import { extractLearnings } from '../learnings/extractor.js';
|
|
26
|
+
import { readEvmBalance } from '../wallet/manager.js';
|
|
26
27
|
// Per-bot prefs (persisted so a restart keeps the user's choice).
|
|
27
28
|
const PREFS_FILE = path.join(os.homedir(), '.blockrun', 'telegram-prefs.json');
|
|
28
29
|
function loadPrefs() {
|
|
@@ -201,10 +202,11 @@ export async function runTelegramBot(agentConfig, opts) {
|
|
|
201
202
|
await sendMessage(chatId, `Chain: solana\nWallet: ${addr}\nBalance: $${bal.toFixed(2)} USDC`);
|
|
202
203
|
}
|
|
203
204
|
else {
|
|
205
|
+
const chain = agentConfig.chain;
|
|
204
206
|
const c = setupAgentWallet({ silent: true });
|
|
205
207
|
const addr = c.getWalletAddress();
|
|
206
|
-
const bal = await c
|
|
207
|
-
await sendMessage(chatId, `Chain:
|
|
208
|
+
const bal = await readEvmBalance(chain, c);
|
|
209
|
+
await sendMessage(chatId, `Chain: ${chain}\nWallet: ${addr}\nBalance: $${bal.toFixed(2)} USDC`);
|
|
208
210
|
}
|
|
209
211
|
}
|
|
210
212
|
catch (err) {
|
package/dist/commands/balance.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import { setupAgentWallet, setupAgentSolanaWallet } from '@blockrun/llm';
|
|
3
|
-
import { loadChain, DASHBOARD_URL } from '../config.js';
|
|
3
|
+
import { loadChain, CHAIN_LABELS, DASHBOARD_URL } from '../config.js';
|
|
4
4
|
import { fetchCreditBalance, isKeyMode, loadApiKey, maskApiKey } from '../payments/auth-mode.js';
|
|
5
5
|
import { loadStats } from '../stats/tracker.js';
|
|
6
|
+
import { readEvmBalance } from '../wallet/manager.js';
|
|
6
7
|
export async function balanceCommand() {
|
|
7
8
|
const chain = loadChain();
|
|
8
9
|
// API-key mode settles against a prepaid credit balance. The gateway exposes
|
|
@@ -74,12 +75,12 @@ export async function balanceCommand() {
|
|
|
74
75
|
else {
|
|
75
76
|
const client = setupAgentWallet({ silent: true });
|
|
76
77
|
const address = client.getWalletAddress();
|
|
77
|
-
const balance = await client
|
|
78
|
-
console.log(`Chain: ${chalk.magenta(
|
|
78
|
+
const balance = await readEvmBalance(chain, client);
|
|
79
|
+
console.log(`Chain: ${chalk.magenta(chain)}`);
|
|
79
80
|
console.log(`Wallet: ${chalk.cyan(address)}`);
|
|
80
81
|
console.log(`USDC Balance: ${chalk.green(`$${balance.toFixed(2)}`)}`);
|
|
81
82
|
if (balance === 0) {
|
|
82
|
-
console.log(chalk.dim(`\nSend USDC on
|
|
83
|
+
console.log(chalk.dim(`\nSend USDC on ${CHAIN_LABELS[chain]} to ${address} to get started.`));
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
86
|
}
|
package/dist/commands/doctor.js
CHANGED
|
@@ -19,6 +19,7 @@ import { loadChain, VERSION, BLOCKRUN_DIR, DASHBOARD_URL, KEY_API_URL, USER_AGEN
|
|
|
19
19
|
import { gatewayBase, isKeyMode, loadApiKey, maskApiKey } from '../payments/auth-mode.js';
|
|
20
20
|
import { isTelemetryEnabled, readAllRecords } from '../telemetry/store.js';
|
|
21
21
|
import { getAvailableUpdateFresh, kickoffVersionCheck } from '../version-check.js';
|
|
22
|
+
import { readEvmBalance } from '../wallet/manager.js';
|
|
22
23
|
/** Free, auth-gated probe — proves the key works without spending credit. */
|
|
23
24
|
async function verifyKeyReachable() {
|
|
24
25
|
const key = loadApiKey();
|
|
@@ -106,7 +107,7 @@ async function runChecks() {
|
|
|
106
107
|
name: 'Chain',
|
|
107
108
|
status: 'fail',
|
|
108
109
|
detail: `failed to load — ${err.message}`,
|
|
109
|
-
remedy: 'Run: franklin setup
|
|
110
|
+
remedy: 'Run: franklin setup solana (or: franklin setup base / franklin setup arc)',
|
|
110
111
|
});
|
|
111
112
|
}
|
|
112
113
|
// ── 5. Wallet ─────────────────────────────────────────────────────
|
|
@@ -147,7 +148,7 @@ async function runChecks() {
|
|
|
147
148
|
else {
|
|
148
149
|
const client = setupAgentWallet({ silent: true });
|
|
149
150
|
walletAddress = client.getWalletAddress();
|
|
150
|
-
walletBalance = await client
|
|
151
|
+
walletBalance = await readEvmBalance(chain, client);
|
|
151
152
|
}
|
|
152
153
|
out.push({
|
|
153
154
|
name: 'Wallet',
|
package/dist/commands/proxy.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import chalk from 'chalk';
|
|
6
6
|
import { getOrCreateWallet, getOrCreateSolanaWallet } from '@blockrun/llm';
|
|
7
7
|
import { createProxy } from '../proxy/server.js';
|
|
8
|
-
import { loadChain, DEFAULT_PROXY_PORT } from '../config.js';
|
|
8
|
+
import { loadChain, CHAIN_LABELS, DEFAULT_PROXY_PORT } from '../config.js';
|
|
9
9
|
import { gatewayBase } from '../payments/auth-mode.js';
|
|
10
10
|
import { loadConfig } from './config.js';
|
|
11
11
|
import { printBanner } from '../banner.js';
|
|
@@ -53,12 +53,12 @@ export async function proxyCommand(options) {
|
|
|
53
53
|
if (wallet.isNew) {
|
|
54
54
|
console.log(chalk.yellow('No wallet found — created a new one.'));
|
|
55
55
|
console.log(`Address: ${chalk.cyan(wallet.address)}`);
|
|
56
|
-
console.log(`\nSend USDC on
|
|
56
|
+
console.log(`\nSend USDC on ${CHAIN_LABELS[chain]} to this address, then run ${chalk.bold('franklin proxy')} again.\n`);
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
59
59
|
printBanner(version);
|
|
60
60
|
console.log(`Mode: ${chalk.bold('proxy')}`);
|
|
61
|
-
console.log(`Chain: ${chalk.magenta(
|
|
61
|
+
console.log(`Chain: ${chalk.magenta(chain)}`);
|
|
62
62
|
console.log(`Wallet: ${chalk.cyan(wallet.address)}`);
|
|
63
63
|
if (model)
|
|
64
64
|
console.log(`Model: ${chalk.green(model)}`);
|
|
@@ -68,7 +68,7 @@ export async function proxyCommand(options) {
|
|
|
68
68
|
const server = createProxy({
|
|
69
69
|
port,
|
|
70
70
|
apiUrl,
|
|
71
|
-
chain
|
|
71
|
+
chain,
|
|
72
72
|
modelOverride: model,
|
|
73
73
|
debug: options.debug,
|
|
74
74
|
fallbackEnabled,
|
package/dist/commands/setup.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import { getOrCreateWallet, scanWallets, getOrCreateSolanaWallet, scanSolanaWallets, } from '@blockrun/llm';
|
|
3
|
-
import { saveChain, DASHBOARD_URL } from '../config.js';
|
|
3
|
+
import { CHAIN_LABELS, saveChain, DASHBOARD_URL } from '../config.js';
|
|
4
4
|
import { isKeyMode, loadApiKey, maskApiKey } from '../payments/auth-mode.js';
|
|
5
5
|
export async function setupCommand(chainArg) {
|
|
6
|
-
// Solana is the default chain; `franklin setup base`
|
|
7
|
-
|
|
6
|
+
// Solana is the default chain; `franklin setup base` / `franklin setup arc`
|
|
7
|
+
// opt into an EVM chain. Base and Arc share one EVM wallet.
|
|
8
|
+
const chain = chainArg === 'base' || chainArg === 'arc' ? chainArg : 'solana';
|
|
8
9
|
// A configured key already pays for everything, so creating a wallet here
|
|
9
10
|
// would be busywork the user did not ask for. Say so and stop, rather than
|
|
10
11
|
// silently making a second credential they will never fund.
|
|
@@ -45,7 +46,7 @@ export async function setupCommand(chainArg) {
|
|
|
45
46
|
console.log(chalk.dim(' franklin start — start coding'));
|
|
46
47
|
console.log(chalk.dim(' franklin balance — check USDC balance'));
|
|
47
48
|
console.log(chalk.dim(' franklin start -m free — use free models (no USDC needed)'));
|
|
48
|
-
saveChain(
|
|
49
|
+
saveChain(chain);
|
|
49
50
|
return;
|
|
50
51
|
}
|
|
51
52
|
console.log('Creating new wallet...\n');
|
|
@@ -54,7 +55,7 @@ export async function setupCommand(chainArg) {
|
|
|
54
55
|
console.log(chalk.green('Wallet created!\n'));
|
|
55
56
|
}
|
|
56
57
|
console.log(`Address: ${chalk.cyan(address)}`);
|
|
57
|
-
console.log(`\nSend USDC on
|
|
58
|
+
console.log(`\nSend USDC on ${CHAIN_LABELS[chain]} to this address to fund your account.`);
|
|
58
59
|
}
|
|
59
60
|
saveChain(chain);
|
|
60
61
|
console.log(`Then run ${chalk.bold('franklin start')} to begin.\n`);
|
package/dist/commands/start.js
CHANGED
|
@@ -19,6 +19,7 @@ import { pickModel, resolveModel, resolveModelStrict } from '../ui/model-picker.
|
|
|
19
19
|
import { loadMcpConfig } from '../mcp/config.js';
|
|
20
20
|
import { connectMcpServers, disconnectMcpServers, getMcpServerInstructions } from '../mcp/client.js';
|
|
21
21
|
import { ensureCodegraphIndex } from '../mcp/codegraph.js';
|
|
22
|
+
import { readEvmBalance } from '../wallet/manager.js';
|
|
22
23
|
export async function startCommand(options) {
|
|
23
24
|
const version = options.version ?? '1.0.0';
|
|
24
25
|
// Early-validate explicit resume ID so a typo fails fast — before wallet
|
|
@@ -249,15 +250,16 @@ export async function startCommand(options) {
|
|
|
249
250
|
// zero result; genuinely empty wallets still resolve to $0.00 quickly.
|
|
250
251
|
const fetchBalance = async () => {
|
|
251
252
|
try {
|
|
253
|
+
const payChain = chain;
|
|
252
254
|
const bal = await retryFetchBalance(async () => {
|
|
253
|
-
if (
|
|
255
|
+
if (payChain === 'solana') {
|
|
254
256
|
const { setupAgentSolanaWallet } = await import('@blockrun/llm');
|
|
255
257
|
const client = await setupAgentSolanaWallet({ silent: true });
|
|
256
258
|
return client.getBalance();
|
|
257
259
|
}
|
|
258
260
|
const { setupAgentWallet } = await import('@blockrun/llm');
|
|
259
261
|
const client = setupAgentWallet({ silent: true });
|
|
260
|
-
return client
|
|
262
|
+
return readEvmBalance(payChain, client);
|
|
261
263
|
});
|
|
262
264
|
return `$${bal.toFixed(2)} USDC`;
|
|
263
265
|
}
|
package/dist/config.d.ts
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
export declare const VERSION: string;
|
|
2
2
|
export declare const USER_AGENT: string;
|
|
3
|
-
export type Chain = 'base' | 'solana';
|
|
3
|
+
export type Chain = 'base' | 'solana' | 'arc';
|
|
4
|
+
/**
|
|
5
|
+
* Every chain Franklin can pay on. Base and Arc are both EVM and share one
|
|
6
|
+
* wallet key (~/.blockrun/.session): the same address holds USDC on each, and
|
|
7
|
+
* the 402's `network` selects which chain's USDC domain gets signed. Solana has
|
|
8
|
+
* its own key.
|
|
9
|
+
*/
|
|
10
|
+
export declare const CHAINS: readonly Chain[];
|
|
11
|
+
export declare function isChain(value: unknown): value is Chain;
|
|
12
|
+
/** True for the chains paid from the EVM wallet (Base, Arc). */
|
|
13
|
+
export declare function isEvmChain(chain: Chain): boolean;
|
|
14
|
+
/** Display name, for copy that names the chain a payment settles on. */
|
|
15
|
+
export declare const CHAIN_LABELS: Record<Chain, string>;
|
|
4
16
|
export declare const BLOCKRUN_DIR: string;
|
|
5
17
|
export declare const CHAIN_FILE: string;
|
|
6
18
|
export declare const API_URLS: Record<Chain, string>;
|
package/dist/config.js
CHANGED
|
@@ -12,11 +12,35 @@ catch { /* use default */ }
|
|
|
12
12
|
export const VERSION = _version;
|
|
13
13
|
// Shared User-Agent string for all outbound HTTP requests
|
|
14
14
|
export const USER_AGENT = `franklin/${_version} (node/${process.versions.node}; ${process.platform}; ${process.arch})`;
|
|
15
|
+
/**
|
|
16
|
+
* Every chain Franklin can pay on. Base and Arc are both EVM and share one
|
|
17
|
+
* wallet key (~/.blockrun/.session): the same address holds USDC on each, and
|
|
18
|
+
* the 402's `network` selects which chain's USDC domain gets signed. Solana has
|
|
19
|
+
* its own key.
|
|
20
|
+
*/
|
|
21
|
+
export const CHAINS = ['base', 'solana', 'arc'];
|
|
22
|
+
export function isChain(value) {
|
|
23
|
+
return typeof value === 'string' && CHAINS.includes(value);
|
|
24
|
+
}
|
|
25
|
+
/** True for the chains paid from the EVM wallet (Base, Arc). */
|
|
26
|
+
export function isEvmChain(chain) {
|
|
27
|
+
return chain !== 'solana';
|
|
28
|
+
}
|
|
29
|
+
/** Display name, for copy that names the chain a payment settles on. */
|
|
30
|
+
export const CHAIN_LABELS = {
|
|
31
|
+
base: 'Base',
|
|
32
|
+
solana: 'Solana',
|
|
33
|
+
arc: 'Arc',
|
|
34
|
+
};
|
|
15
35
|
export const BLOCKRUN_DIR = path.join(os.homedir(), '.blockrun');
|
|
16
36
|
export const CHAIN_FILE = path.join(BLOCKRUN_DIR, 'payment-chain');
|
|
17
37
|
export const API_URLS = {
|
|
18
38
|
base: 'https://blockrun.ai/api',
|
|
19
39
|
solana: 'https://sol.blockrun.ai/api',
|
|
40
|
+
// Circle's Arc (eip155:5042): the same gateway API as Base, settled through
|
|
41
|
+
// the Circle facilitator. Needs @blockrun/llm >= 3.16, which signs the 402's
|
|
42
|
+
// network rather than Base's USDC domain.
|
|
43
|
+
arc: 'https://arc.blockrun.ai/api',
|
|
20
44
|
};
|
|
21
45
|
export const DEFAULT_PROXY_PORT = 8402;
|
|
22
46
|
// BlockRun agent-market (the paid skill marketplace Franklin browses with
|
|
@@ -31,16 +55,12 @@ export function saveChain(chain) {
|
|
|
31
55
|
}
|
|
32
56
|
export function loadChain() {
|
|
33
57
|
const envChain = process.env.RUNCODE_CHAIN;
|
|
34
|
-
if (envChain
|
|
35
|
-
return
|
|
36
|
-
if (envChain === 'base')
|
|
37
|
-
return 'base';
|
|
58
|
+
if (isChain(envChain))
|
|
59
|
+
return envChain;
|
|
38
60
|
try {
|
|
39
61
|
const content = fs.readFileSync(CHAIN_FILE, 'utf-8').trim();
|
|
40
|
-
if (content
|
|
41
|
-
return
|
|
42
|
-
if (content === 'solana')
|
|
43
|
-
return 'solana';
|
|
62
|
+
if (isChain(content))
|
|
63
|
+
return content;
|
|
44
64
|
}
|
|
45
65
|
catch { /* no explicit choice on disk — fall through to the default */ }
|
|
46
66
|
// Default chain is Solana. Exception: a Base wallet with no Solana wallet
|
package/dist/index.js
CHANGED
|
@@ -48,13 +48,13 @@ program
|
|
|
48
48
|
.name('franklin')
|
|
49
49
|
.description('Franklin Agent — The AI agent with a wallet.\n\n' +
|
|
50
50
|
'While others chat, Franklin Agent spends — turning your USDC into real work.\n\n' +
|
|
51
|
-
'Pay per action — a USDC wallet on Solana or
|
|
51
|
+
'Pay per action — a USDC wallet on Solana, Base or Arc, or a prepaid API key\n' +
|
|
52
52
|
'from user.blockrun.ai. No subscriptions.')
|
|
53
53
|
.option('--wallet', 'Pay from the USDC wallet even when an API key is configured')
|
|
54
54
|
.version(version);
|
|
55
55
|
program
|
|
56
56
|
.command('setup [chain]')
|
|
57
|
-
.description('Create a new wallet for payments (solana or
|
|
57
|
+
.description('Create a new wallet for payments (solana, base or arc)')
|
|
58
58
|
.action((chain) => setupCommand(chain));
|
|
59
59
|
program
|
|
60
60
|
.command('start')
|
|
@@ -368,8 +368,8 @@ function parseStartFlags(argv, startIdx = 0) {
|
|
|
368
368
|
}
|
|
369
369
|
return opts;
|
|
370
370
|
}
|
|
371
|
-
// Handle chain shortcuts: `franklin solana` or `franklin
|
|
372
|
-
if (firstArg === 'solana' || firstArg === 'base') {
|
|
371
|
+
// Handle chain shortcuts: `franklin solana`, `franklin base` or `franklin arc`
|
|
372
|
+
if (firstArg === 'solana' || firstArg === 'base' || firstArg === 'arc') {
|
|
373
373
|
if (hasAnyFlag(args, HELP_FLAGS)) {
|
|
374
374
|
program.parse(['node', 'franklin', 'start', '--help']);
|
|
375
375
|
}
|
package/dist/model-catalog.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/** Shared model facts and policy; payment credentials stay in Franklin. */
|
|
2
|
-
import { type CatalogState
|
|
2
|
+
import { type CatalogState } from '@blockrun/model-catalog';
|
|
3
|
+
import { type Chain } from './config.js';
|
|
3
4
|
export declare function getModelCatalogIdentity(): string;
|
|
4
5
|
export declare function getModelCatalog(): CatalogState;
|
|
5
6
|
export declare function onModelCatalogChange(listener: (state: CatalogState) => void): () => void;
|
|
6
7
|
export declare function refreshModelCatalog(options?: {
|
|
7
|
-
network?:
|
|
8
|
+
network?: Chain;
|
|
8
9
|
force?: boolean;
|
|
9
10
|
}): Promise<CatalogState>;
|
|
10
11
|
export declare function clearModelCatalogCache(): void;
|
package/dist/model-catalog.js
CHANGED
|
@@ -4,8 +4,17 @@ import { API_URLS, loadChain, USER_AGENT } from './config.js';
|
|
|
4
4
|
import { gatewayHeaders, resolvePayMode } from './payments/auth-mode.js';
|
|
5
5
|
const clients = new Map();
|
|
6
6
|
const bundled = new Map();
|
|
7
|
+
/**
|
|
8
|
+
* Model Core's policy and bundled snapshot know Base and Solana. The Arc
|
|
9
|
+
* gateway is a fork of the Base gateway serving the same catalog, so Arc reads
|
|
10
|
+
* Base's policy and offline snapshot, while its live rows and prices come from
|
|
11
|
+
* arc.blockrun.ai itself (the gateway URL below), cached apart from Base's.
|
|
12
|
+
*/
|
|
13
|
+
function catalogNetwork(chain) {
|
|
14
|
+
return chain === 'arc' ? 'base' : chain;
|
|
15
|
+
}
|
|
7
16
|
function bundledState() {
|
|
8
|
-
const network =
|
|
17
|
+
const network = catalogNetwork(sessionChain ?? loadChain());
|
|
9
18
|
let state = bundled.get(network);
|
|
10
19
|
if (!state) {
|
|
11
20
|
state = createCatalogClient({ network }).current();
|
|
@@ -14,15 +23,16 @@ function bundledState() {
|
|
|
14
23
|
return state;
|
|
15
24
|
}
|
|
16
25
|
const listeners = new Set();
|
|
17
|
-
let
|
|
26
|
+
let sessionChain;
|
|
18
27
|
function activeClient() {
|
|
19
28
|
const mode = resolvePayMode();
|
|
20
|
-
const
|
|
21
|
-
const
|
|
29
|
+
const chain = sessionChain ?? loadChain();
|
|
30
|
+
const network = catalogNetwork(chain);
|
|
31
|
+
const gatewayUrl = `${mode.kind === 'key' ? mode.apiBase : API_URLS[chain]}/v1/models?format=json`;
|
|
22
32
|
const catalogUrl = process.env.BLOCKRUN_MODEL_CATALOG_URL
|
|
23
33
|
?? 'https://raw.githubusercontent.com/BlockRunAI/model-catalog/main/dist/snapshot.v1.json';
|
|
24
34
|
// Separate caches for each chain, endpoint and API account; keys never leave memory.
|
|
25
|
-
const identity = JSON.stringify([
|
|
35
|
+
const identity = JSON.stringify([chain, gatewayUrl, catalogUrl, mode.kind === 'key' ? mode.key : '']);
|
|
26
36
|
let client = clients.get(identity);
|
|
27
37
|
if (!client) {
|
|
28
38
|
const headers = { ...gatewayHeaders(mode), 'User-Agent': USER_AGENT };
|
|
@@ -43,7 +53,7 @@ export function getModelCatalogIdentity() {
|
|
|
43
53
|
return activeClient().identity;
|
|
44
54
|
}
|
|
45
55
|
catch {
|
|
46
|
-
return `unconfigured:${
|
|
56
|
+
return `unconfigured:${sessionChain ?? loadChain()}`;
|
|
47
57
|
}
|
|
48
58
|
}
|
|
49
59
|
export function getModelCatalog() {
|
|
@@ -62,7 +72,7 @@ export function onModelCatalogChange(listener) {
|
|
|
62
72
|
}
|
|
63
73
|
export async function refreshModelCatalog(options = {}) {
|
|
64
74
|
if (options.network)
|
|
65
|
-
|
|
75
|
+
sessionChain = options.network;
|
|
66
76
|
const { identity, client } = activeClient();
|
|
67
77
|
const state = process.env.FRANKLIN_CATALOG_OFFLINE === '1'
|
|
68
78
|
? client.current() : await client.refresh({ force: options.force });
|
|
@@ -73,5 +83,5 @@ export async function refreshModelCatalog(options = {}) {
|
|
|
73
83
|
}
|
|
74
84
|
export function clearModelCatalogCache() {
|
|
75
85
|
clients.clear();
|
|
76
|
-
|
|
86
|
+
sessionChain = undefined;
|
|
77
87
|
}
|
package/dist/onramp/client.js
CHANGED
|
@@ -25,6 +25,11 @@ import { postWithPayment } from '../payments/post-with-payment.js';
|
|
|
25
25
|
*/
|
|
26
26
|
export async function getOnrampUrl(address) {
|
|
27
27
|
const chain = loadChain();
|
|
28
|
+
// Coinbase Onramp cannot deliver to Arc, and the Arc gateway refuses any
|
|
29
|
+
// network but Base. Fail before the x402 handshake rather than after it.
|
|
30
|
+
if (chain === 'arc') {
|
|
31
|
+
throw new Error('Card purchase is not available on Arc. Send USDC on Arc (chain 5042) to this wallet, or switch to Base or Solana to buy with a card.');
|
|
32
|
+
}
|
|
28
33
|
const endpoint = `${gatewayBase()}/v1/onramp/token`;
|
|
29
34
|
const result = await postWithPayment(endpoint, { address, network: chain, asset: 'USDC' }, 'Mint a Coinbase Onramp session link to fund this wallet');
|
|
30
35
|
if (!result.ok) {
|