@blockrun/franklin 3.45.0 → 3.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -11
- package/dist/agent/context.js +58 -10
- package/dist/agent/llm.js +14 -6
- package/dist/agent/loop.js +34 -6
- package/dist/agent/optimize.d.ts +1 -1
- package/dist/agent/optimize.js +17 -7
- package/dist/agent/secret-redact.d.ts +26 -0
- package/dist/agent/secret-redact.js +48 -0
- package/dist/agent/streaming-executor.js +15 -0
- package/dist/commands/doctor.js +18 -0
- package/dist/commands/start.js +4 -0
- package/dist/commands/usage.d.ts +14 -0
- package/dist/commands/usage.js +86 -0
- package/dist/commands/wallet-adopt.d.ts +12 -0
- package/dist/commands/wallet-adopt.js +49 -0
- package/dist/free-models.js +2 -1
- package/dist/gateway-models.js +34 -66
- package/dist/index.js +16 -0
- package/dist/model-catalog.d.ts +10 -0
- package/dist/model-catalog.js +77 -0
- package/dist/payments/auth-mode.d.ts +5 -19
- package/dist/payments/auth-mode.js +15 -17
- package/dist/payments/billing-copy.d.ts +37 -0
- package/dist/payments/billing-copy.js +57 -0
- package/dist/payments/post-with-payment.js +8 -15
- package/dist/payments/price-catalog.d.ts +9 -0
- package/dist/payments/price-catalog.js +13 -0
- package/dist/payments/usage.d.ts +106 -0
- package/dist/payments/usage.js +168 -0
- package/dist/pricing.d.ts +2 -6
- package/dist/pricing.js +16 -3
- package/dist/router/vision.js +9 -1
- package/dist/stats/tracker.d.ts +9 -1
- package/dist/stats/tracker.js +6 -1
- package/dist/tools/bash.js +17 -7
- package/dist/tools/blockrun.js +1 -1
- package/dist/tools/defillama.js +2 -2
- package/dist/tools/imagegen.js +5 -4
- package/dist/tools/modal.js +12 -6
- package/dist/tools/musicgen.js +4 -3
- package/dist/tools/phone.js +16 -15
- package/dist/tools/prediction.js +12 -11
- package/dist/tools/realface.js +2 -2
- package/dist/tools/rpc.js +2 -2
- package/dist/tools/sensitive-paths.d.ts +1 -1
- package/dist/tools/sensitive-paths.js +13 -4
- package/dist/tools/surf.js +2 -2
- package/dist/tools/videogen.js +6 -5
- package/dist/tools/voice.d.ts +1 -1
- package/dist/tools/voice.js +5 -4
- package/dist/ui/model-picker.d.ts +1 -2
- package/dist/ui/model-picker.js +34 -117
- package/dist/wallet/reservation.d.ts +24 -0
- package/dist/wallet/reservation.js +50 -4
- package/dist/wallet/solana-migration.d.ts +48 -0
- package/dist/wallet/solana-migration.js +81 -0
- package/package.json +6 -4
package/dist/ui/model-picker.js
CHANGED
|
@@ -6,8 +6,9 @@ import readline from 'node:readline';
|
|
|
6
6
|
import chalk from 'chalk';
|
|
7
7
|
import { getGatewayModels } from '../gateway-models.js';
|
|
8
8
|
import { FREE_DEFAULT_MODEL } from '../free-models.js';
|
|
9
|
+
import { getModelCatalog, onModelCatalogChange } from '../model-catalog.js';
|
|
9
10
|
// ─── Model Shortcuts (same as proxy) ───────────────────────────────────────
|
|
10
|
-
|
|
11
|
+
const LEGACY_SHORTCUTS = {
|
|
11
12
|
// Routing profiles — Auto is the only profile surfaced in the picker.
|
|
12
13
|
// `eco` / `premium` were retired 2026-05-03 (V4 Pro launch made Auto cheap
|
|
13
14
|
// enough that separate profiles for "cheap" and "best" were redundant).
|
|
@@ -281,7 +282,7 @@ export function resolveModelStrict(input) {
|
|
|
281
282
|
}
|
|
282
283
|
const lower = trimmed.toLowerCase();
|
|
283
284
|
if (Object.prototype.hasOwnProperty.call(MODEL_SHORTCUTS, lower)) {
|
|
284
|
-
return { ok: true, id: MODEL_SHORTCUTS[lower], viaShortcut:
|
|
285
|
+
return { ok: true, id: MODEL_SHORTCUTS[lower], viaShortcut: MODEL_SHORTCUTS[lower] !== trimmed };
|
|
285
286
|
}
|
|
286
287
|
if (trimmed.includes('/')) {
|
|
287
288
|
return { ok: true, id: trimmed, viaShortcut: false };
|
|
@@ -331,121 +332,37 @@ const PROVIDER_LABELS = {
|
|
|
331
332
|
* (pickModel() below) import from this array. To add or remove models,
|
|
332
333
|
* edit this one place.
|
|
333
334
|
*/
|
|
334
|
-
export const
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
// Gemini 2.5 Pro's row retired here the same way Opus 4.8's did: a
|
|
366
|
-
// superseded sibling listed directly under its successor is choice
|
|
367
|
-
// paralysis, not choice. `gemini-2.5` still resolves to it.
|
|
368
|
-
{ id: 'google/gemini-3.1-pro', shortcut: 'gemini', label: 'Gemini 3.1 Pro', price: '$2/$12' },
|
|
369
|
-
{ id: 'xai/grok-4.5', shortcut: 'grok', label: 'Grok 4.5', price: '$2/$6' },
|
|
370
|
-
// Kimi K3 (2026-07): 2.8T open MoE, 1M context, multimodal + reasoning.
|
|
371
|
-
// Replaced the budget K2.7 line — now premium-priced ($3/$15).
|
|
372
|
-
{ id: 'moonshot/kimi-k3', shortcut: 'kimi', label: 'Kimi K3', price: '$3/$15' },
|
|
373
|
-
],
|
|
374
|
-
},
|
|
375
|
-
{
|
|
376
|
-
category: '🔬 Reasoning',
|
|
377
|
-
models: [
|
|
378
|
-
{ id: 'openai/o3', shortcut: 'o3', label: 'O3', price: '$2/$8' },
|
|
379
|
-
{ id: 'openai/gpt-5.3-codex', shortcut: 'codex', label: 'GPT-5.3 Codex', price: '$1.75/$14' },
|
|
380
|
-
// V4 Pro: the 75% launch promo became DeepSeek's permanent list price
|
|
381
|
-
// after 2026-05-31. 1M context, 1.6T MoE → punches up to GPT-5.5/Opus
|
|
382
|
-
// on hard tasks at <1/10 the price.
|
|
383
|
-
{ id: 'deepseek/deepseek-v4-pro', shortcut: 'deepseek-v4-pro', label: 'DeepSeek V4 Pro', price: '$0.435/$0.87', highlight: true },
|
|
384
|
-
{ id: 'deepseek/deepseek-reasoner', shortcut: 'r1', label: 'DeepSeek V4 Flash R.', price: '$0.2/$0.4' },
|
|
385
|
-
// Terra Pro took the row grok-4-1-fast-reasoning used to hold: the xAI
|
|
386
|
-
// fast family is hidden from /v1/models, so reconcilePicker dropped that
|
|
387
|
-
// row on every live render anyway (`grok-fast` still resolves). Terra
|
|
388
|
-
// Pro is GPT-5.6 Terra with pro reasoning on, at HALF Terra's price.
|
|
389
|
-
{ id: 'openai/gpt-5.6-terra-pro', shortcut: 'terra-pro', label: 'GPT-5.6 Terra Pro', price: '$1/$6', highlight: true },
|
|
390
|
-
// GLM-5.3: Z.AI's flagship — 1M context, always-on reasoning, strong on
|
|
391
|
-
// long-horizon coding. `glm`/`glm5` shortcuts pin it.
|
|
392
|
-
{ id: 'zai/glm-5.3', shortcut: 'glm-5.3', label: 'GLM-5.3', price: '$1.4/$4.4' },
|
|
393
|
-
],
|
|
394
|
-
},
|
|
395
|
-
{
|
|
396
|
-
category: '💰 Budget',
|
|
397
|
-
models: [
|
|
398
|
-
{ id: 'anthropic/claude-haiku-4.5', shortcut: 'haiku', label: 'Claude Haiku 4.5', price: '$1/$5' },
|
|
399
|
-
{ id: 'openai/gpt-5-mini', shortcut: 'mini', label: 'GPT-5 Mini', price: '$0.25/$2' },
|
|
400
|
-
// GLM-5.3 Flash took Gemini 2.5 Flash's row 2026-08-29: half the price,
|
|
401
|
-
// the same 1M context and vision, plus reasoning. `gemini-2.5-flash`
|
|
402
|
-
// still resolves — hide the row, keep the shortcut.
|
|
403
|
-
{ id: 'zai/glm-5.3-flash', shortcut: 'glm-flash', label: 'GLM-5.3 Flash', price: '$0.15/$0.5' },
|
|
404
|
-
// Re-aliased to V4 Flash Chat upstream — context 1M, price 30% lower.
|
|
405
|
-
{ id: 'deepseek/deepseek-chat', shortcut: 'deepseek', label: 'DeepSeek V4 Flash Chat', price: '$0.14/$0.28' },
|
|
406
|
-
// Cheapest paid model on the gateway, and it still carries 1M context
|
|
407
|
-
// with reasoning — the budget slot GLM-5 used to hold (its flat-rate
|
|
408
|
-
// promo ended 2026-06-06 and it now lists at $1/$3.2, no longer a budget
|
|
409
|
-
// number; the `glm-5` shortcut stays live).
|
|
410
|
-
{ id: 'qwen/qwen3.7-flash', shortcut: 'qwen-flash', label: 'Qwen3.7 Flash', price: '$0.03/$0.13', highlight: true },
|
|
411
|
-
// Minimax M2.7 hidden to make room for V4 Pro in Reasoning + V4 Flash
|
|
412
|
-
// (free) without exceeding the picker's 24-entry cap. Shortcut `minimax`
|
|
413
|
-
// still resolves to it.
|
|
414
|
-
],
|
|
415
|
-
},
|
|
416
|
-
{
|
|
417
|
-
category: '🆓 Free (no USDC needed)',
|
|
418
|
-
models: [
|
|
419
|
-
// Nemotron Nano 9B leads: it's what the `free` shortcut + free routing
|
|
420
|
-
// profile resolve to, promoted 2026-08-12 when qwen3-next-80b-a3b-instruct
|
|
421
|
-
// hit NVIDIA's EOL (410). All rows are $0 — the free tier never falls
|
|
422
|
-
// back to paid.
|
|
423
|
-
//
|
|
424
|
-
// Caveat worth knowing before editing this list: only the FIRST row is
|
|
425
|
-
// available on both chains. The Solana gateway lists exactly one free
|
|
426
|
-
// model and 400s ("Unknown model") on the other three, which are
|
|
427
|
-
// Base-only as of the 2026-08-30 rotation. That is why `free` — and
|
|
428
|
-
// every legacy free alias — points at the chain-safe id, and why the
|
|
429
|
-
// ROUTER upgrades to the 550B at runtime from the live catalog rather
|
|
430
|
-
// than from this list (see src/free-models.ts, freeChain).
|
|
431
|
-
//
|
|
432
|
-
// The rows are still worth showing on both chains: the picker hydrates
|
|
433
|
-
// against the gateway catalog, and a user who pins a Base-only id on
|
|
434
|
-
// Solana gets a clear "Unknown model" rather than a silent wrong model.
|
|
435
|
-
//
|
|
436
|
-
// Deliberately absent (NOT quarantined — QUARANTINED_FREE_MODELS is
|
|
437
|
-
// empty): nemotron-3.5-lightning is merely slow, cohere/north-mini-code
|
|
438
|
-
// is a routable chain rung with no picker row, and llama-3.2-11b-vision
|
|
439
|
-
// is vision-only. Reasons per id live in src/free-models.ts.
|
|
440
|
-
{ id: FREE_DEFAULT_MODEL, shortcut: 'free', label: 'Nemotron 3 Nano Omni', price: 'FREE', highlight: true },
|
|
441
|
-
{ id: 'nvidia/nemotron-3-ultra-550b', shortcut: 'ultra-550b', label: 'Nemotron 3 Ultra 550B', price: 'FREE' },
|
|
442
|
-
{ id: 'nvidia/nemotron-3-nano-30b', shortcut: 'nano-30b', label: 'Nemotron 3 Nano 30B', price: 'FREE' },
|
|
443
|
-
{ id: 'poolside/laguna-xs-2.1', shortcut: 'laguna', label: 'Laguna XS 2.1', price: 'FREE' },
|
|
444
|
-
],
|
|
445
|
-
},
|
|
446
|
-
];
|
|
447
|
-
/** Flat list of all picker models (for index-based navigation). */
|
|
448
|
-
export const PICKER_MODELS_FLAT = PICKER_CATEGORIES.flatMap(c => c.models);
|
|
335
|
+
export const MODEL_SHORTCUTS = {};
|
|
336
|
+
export const PICKER_CATEGORIES = [];
|
|
337
|
+
export const PICKER_MODELS_FLAT = [];
|
|
338
|
+
function updateCatalogView(state) {
|
|
339
|
+
for (const key of Object.keys(MODEL_SHORTCUTS))
|
|
340
|
+
delete MODEL_SHORTCUTS[key];
|
|
341
|
+
// Franklin's own aliases win over the shared policy: a remote catalog edit may
|
|
342
|
+
// add new shortcuts, but never retarget one a user already relies on (that
|
|
343
|
+
// would change which model runs, and what it costs, without a release). The
|
|
344
|
+
// same rule keeps every existing free shortcut free.
|
|
345
|
+
Object.assign(MODEL_SHORTCUTS, state.shortcuts, LEGACY_SHORTCUTS);
|
|
346
|
+
const categories = [{
|
|
347
|
+
category: '🧠 Smart routing (auto-pick)',
|
|
348
|
+
models: [{ id: 'blockrun/auto', shortcut: 'auto', label: 'Auto', price: 'routed' }],
|
|
349
|
+
}, ...state.groups.filter(group => group.id !== 'other').map(group => ({
|
|
350
|
+
category: group.title,
|
|
351
|
+
models: group.models.map(model => ({
|
|
352
|
+
id: model.id, label: model.name,
|
|
353
|
+
// Shortest alias reads best in the picker column (`opus`, not `opus-5`).
|
|
354
|
+
shortcut: Object.entries(MODEL_SHORTCUTS)
|
|
355
|
+
.filter(([key, target]) => target === model.id && !key.includes('/'))
|
|
356
|
+
.map(([key]) => key)
|
|
357
|
+
.reduce((best, key) => !best || key.length < best.length ? key : best, undefined) ?? model.id,
|
|
358
|
+
price: formatPrice(model),
|
|
359
|
+
})),
|
|
360
|
+
}))];
|
|
361
|
+
PICKER_CATEGORIES.splice(0, PICKER_CATEGORIES.length, ...categories);
|
|
362
|
+
PICKER_MODELS_FLAT.splice(0, PICKER_MODELS_FLAT.length, ...categories.flatMap(c => c.models));
|
|
363
|
+
}
|
|
364
|
+
updateCatalogView(getModelCatalog());
|
|
365
|
+
onModelCatalogChange(updateCatalogView);
|
|
449
366
|
// ─── Live hydration against the gateway catalog ────────────────────────────
|
|
450
367
|
/**
|
|
451
368
|
* Synthetic ids that are Franklin concepts, not gateway models (`blockrun/auto`
|
|
@@ -40,6 +40,30 @@ export interface ReservationToken {
|
|
|
40
40
|
* Callers pass `graceMs = timeoutMs + AMBIGUOUS_GRACE_MS`.
|
|
41
41
|
*/
|
|
42
42
|
export declare const AMBIGUOUS_GRACE_MS = 30000;
|
|
43
|
+
/**
|
|
44
|
+
* A Solana zero is not a balance — it is the SDK's error value too.
|
|
45
|
+
*
|
|
46
|
+
* `SolanaLLMClient.getBalance()` catches every transport error and returns 0,
|
|
47
|
+
* and an RPC that answers 200 with a JSON-RPC error body reaches the same 0
|
|
48
|
+
* through `data.result?.value || []`. So a zero means "empty wallet" OR "the
|
|
49
|
+
* endpoint is not answering", and Franklin cannot tell which from the number.
|
|
50
|
+
*
|
|
51
|
+
* Refusing on it is the worse mistake of the two. A false zero blocks every
|
|
52
|
+
* paid tool for the length of an RPC blip — precisely the outcome
|
|
53
|
+
* `fetchBalance`'s fail-open exists to prevent — while trusting it costs
|
|
54
|
+
* nothing when the wallet really is empty, because those calls fail at payment
|
|
55
|
+
* anyway. The reservation layer's job is stopping concurrent calls from
|
|
56
|
+
* over-committing a KNOWN balance; there is nothing to over-commit at zero.
|
|
57
|
+
*
|
|
58
|
+
* This THROWS rather than returning Infinity on purpose. `fetchBalance` prunes
|
|
59
|
+
* ambiguous settlement entries only on a read that came back, so a throw both
|
|
60
|
+
* trips the fail-open and keeps those holds from being pruned against a number
|
|
61
|
+
* that reflects nothing (blockrun#140).
|
|
62
|
+
*
|
|
63
|
+
* Base is unaffected: its `getBalance()` propagates errors, so a zero there is
|
|
64
|
+
* a real zero.
|
|
65
|
+
*/
|
|
66
|
+
export declare function readSolanaBalance(getBalance: () => Promise<number>): Promise<number>;
|
|
43
67
|
declare class WalletReservationManager {
|
|
44
68
|
private reserved;
|
|
45
69
|
private ambiguous;
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
*/
|
|
31
31
|
import { setupAgentWallet, setupAgentSolanaWallet } from '@blockrun/llm';
|
|
32
32
|
import { loadChain } from '../config.js';
|
|
33
|
+
import { fetchCreditBalance, isKeyMode } from '../payments/auth-mode.js';
|
|
33
34
|
const BALANCE_CACHE_MS = 5_000;
|
|
34
35
|
/**
|
|
35
36
|
* Settlement margin added on top of the caller-supplied request timeout for
|
|
@@ -39,10 +40,55 @@ const BALANCE_CACHE_MS = 5_000;
|
|
|
39
40
|
* Callers pass `graceMs = timeoutMs + AMBIGUOUS_GRACE_MS`.
|
|
40
41
|
*/
|
|
41
42
|
export const AMBIGUOUS_GRACE_MS = 30_000;
|
|
42
|
-
|
|
43
|
+
/**
|
|
44
|
+
* A Solana zero is not a balance — it is the SDK's error value too.
|
|
45
|
+
*
|
|
46
|
+
* `SolanaLLMClient.getBalance()` catches every transport error and returns 0,
|
|
47
|
+
* and an RPC that answers 200 with a JSON-RPC error body reaches the same 0
|
|
48
|
+
* through `data.result?.value || []`. So a zero means "empty wallet" OR "the
|
|
49
|
+
* endpoint is not answering", and Franklin cannot tell which from the number.
|
|
50
|
+
*
|
|
51
|
+
* Refusing on it is the worse mistake of the two. A false zero blocks every
|
|
52
|
+
* paid tool for the length of an RPC blip — precisely the outcome
|
|
53
|
+
* `fetchBalance`'s fail-open exists to prevent — while trusting it costs
|
|
54
|
+
* nothing when the wallet really is empty, because those calls fail at payment
|
|
55
|
+
* anyway. The reservation layer's job is stopping concurrent calls from
|
|
56
|
+
* over-committing a KNOWN balance; there is nothing to over-commit at zero.
|
|
57
|
+
*
|
|
58
|
+
* This THROWS rather than returning Infinity on purpose. `fetchBalance` prunes
|
|
59
|
+
* ambiguous settlement entries only on a read that came back, so a throw both
|
|
60
|
+
* trips the fail-open and keeps those holds from being pruned against a number
|
|
61
|
+
* that reflects nothing (blockrun#140).
|
|
62
|
+
*
|
|
63
|
+
* Base is unaffected: its `getBalance()` propagates errors, so a zero there is
|
|
64
|
+
* a real zero.
|
|
65
|
+
*/
|
|
66
|
+
export async function readSolanaBalance(getBalance) {
|
|
67
|
+
const balance = await getBalance();
|
|
68
|
+
if (balance === 0) {
|
|
69
|
+
throw new Error('Solana balance read returned 0, which the SDK also returns on RPC failure — treating the balance as unknown');
|
|
70
|
+
}
|
|
71
|
+
return balance;
|
|
72
|
+
}
|
|
73
|
+
async function readSpendableBalance() {
|
|
74
|
+
// Key mode has no wallet to read. Gating on one made every Modal call fail
|
|
75
|
+
// with "Insufficient USDC — fund the wallet" for a user whose account
|
|
76
|
+
// credits were fine, because an unfunded (or absent) wallet reads $0.
|
|
77
|
+
//
|
|
78
|
+
// The right ceiling in key mode is the prepaid balance, so use it when the
|
|
79
|
+
// gateway reports one. `remainingUsd: null` means an ungated account with
|
|
80
|
+
// no ceiling, and a null balance means the gateway was unreachable — in
|
|
81
|
+
// both cases return Infinity rather than invent a limit. That is not
|
|
82
|
+
// "unbounded": the gateway still 402s when credits run out, and --max-spend
|
|
83
|
+
// still bounds the session. This layer only prevents Franklin from
|
|
84
|
+
// over-committing against a balance it can actually see.
|
|
85
|
+
if (isKeyMode()) {
|
|
86
|
+
const credit = await fetchCreditBalance().catch(() => null);
|
|
87
|
+
return credit?.remainingUsd ?? Number.POSITIVE_INFINITY;
|
|
88
|
+
}
|
|
43
89
|
if (loadChain() === 'solana') {
|
|
44
90
|
const client = await setupAgentSolanaWallet({ silent: true });
|
|
45
|
-
return client.getBalance();
|
|
91
|
+
return readSolanaBalance(() => client.getBalance());
|
|
46
92
|
}
|
|
47
93
|
const client = setupAgentWallet({ silent: true });
|
|
48
94
|
return client.getBalance();
|
|
@@ -52,7 +98,7 @@ class WalletReservationManager {
|
|
|
52
98
|
ambiguous = new Map();
|
|
53
99
|
cachedBalance = null;
|
|
54
100
|
balanceFetchInflight = null;
|
|
55
|
-
balanceFetcher =
|
|
101
|
+
balanceFetcher = readSpendableBalance;
|
|
56
102
|
async fetchBalance() {
|
|
57
103
|
if (this.cachedBalance && Date.now() - this.cachedBalance.fetchedAt < BALANCE_CACHE_MS) {
|
|
58
104
|
return this.cachedBalance.value;
|
|
@@ -171,7 +217,7 @@ class WalletReservationManager {
|
|
|
171
217
|
this.ambiguous.clear();
|
|
172
218
|
this.cachedBalance = null;
|
|
173
219
|
this.balanceFetchInflight = null;
|
|
174
|
-
this.balanceFetcher = fetcher ??
|
|
220
|
+
this.balanceFetcher = fetcher ?? readSpendableBalance;
|
|
175
221
|
}
|
|
176
222
|
/** Testing only — seed the balance cache so hold() never touches RPC. */
|
|
177
223
|
_seedBalanceForTests(value) {
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detect a Solana wallet the upgrade silently stopped using (blockrun#119).
|
|
3
|
+
*
|
|
4
|
+
* Franklin 3.35.6 tightened SDK wallet selection: startup now takes
|
|
5
|
+
* `SOLANA_WALLET_KEY`, then `~/.blockrun/.solana-session`, then creates a new
|
|
6
|
+
* wallet. The legacy `~/.blockrun/solana-wallet.json` is no longer selected.
|
|
7
|
+
* That was a deliberate security fix and it stays.
|
|
8
|
+
*
|
|
9
|
+
* What it left behind is a silent address change. The SDK prints a migration
|
|
10
|
+
* notice, but only when it CREATES a wallet — and the install that hurts has a
|
|
11
|
+
* `.solana-session` already, so nothing is created, nothing is printed, and the
|
|
12
|
+
* user is simply on a different address than the one holding their USDC.
|
|
13
|
+
*
|
|
14
|
+
* This module only looks. It derives public addresses (never trusting the
|
|
15
|
+
* `address` field in a file, and never reading a key it does not derive from),
|
|
16
|
+
* and reports a divergence for `franklin doctor` to show. Adopting one is an
|
|
17
|
+
* explicit, separate act — `franklin wallet-adopt <address>` — because the
|
|
18
|
+
* whole complaint is that the active wallet changed without anyone asking.
|
|
19
|
+
*/
|
|
20
|
+
export interface SolanaWalletDivergence {
|
|
21
|
+
/** Address Franklin will actually spend from, or null if none is active. */
|
|
22
|
+
active: string | null;
|
|
23
|
+
/** Discovered wallets whose address differs from the active one. */
|
|
24
|
+
alternatives: Array<{
|
|
25
|
+
address: string;
|
|
26
|
+
source: string;
|
|
27
|
+
}>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The address the SDK will select, derived from the canonical session file.
|
|
31
|
+
*
|
|
32
|
+
* Deliberately does not call `getOrCreateSolanaWallet()`: that CREATES a wallet
|
|
33
|
+
* as a side effect, which is exactly the wrong thing to do inside a diagnostic
|
|
34
|
+
* that is trying to tell the user which wallet they already have. Same
|
|
35
|
+
* primitives the signing path uses.
|
|
36
|
+
*/
|
|
37
|
+
export declare function activeSolanaAddress(): string | null;
|
|
38
|
+
/**
|
|
39
|
+
* Wallets on this machine that Franklin can see but is not using.
|
|
40
|
+
*
|
|
41
|
+
* Returns null when there is nothing to say — no active wallet, or every
|
|
42
|
+
* discovered wallet is the active one. `listDiscoveredSolanaWallets()` derives
|
|
43
|
+
* each address from the secret key rather than trusting the file, and returns
|
|
44
|
+
* no secret material.
|
|
45
|
+
*/
|
|
46
|
+
export declare function detectSolanaWalletDivergence(): Promise<SolanaWalletDivergence | null>;
|
|
47
|
+
/** One-line-per-wallet report. Public addresses only. */
|
|
48
|
+
export declare function formatDivergence(d: SolanaWalletDivergence): string;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detect a Solana wallet the upgrade silently stopped using (blockrun#119).
|
|
3
|
+
*
|
|
4
|
+
* Franklin 3.35.6 tightened SDK wallet selection: startup now takes
|
|
5
|
+
* `SOLANA_WALLET_KEY`, then `~/.blockrun/.solana-session`, then creates a new
|
|
6
|
+
* wallet. The legacy `~/.blockrun/solana-wallet.json` is no longer selected.
|
|
7
|
+
* That was a deliberate security fix and it stays.
|
|
8
|
+
*
|
|
9
|
+
* What it left behind is a silent address change. The SDK prints a migration
|
|
10
|
+
* notice, but only when it CREATES a wallet — and the install that hurts has a
|
|
11
|
+
* `.solana-session` already, so nothing is created, nothing is printed, and the
|
|
12
|
+
* user is simply on a different address than the one holding their USDC.
|
|
13
|
+
*
|
|
14
|
+
* This module only looks. It derives public addresses (never trusting the
|
|
15
|
+
* `address` field in a file, and never reading a key it does not derive from),
|
|
16
|
+
* and reports a divergence for `franklin doctor` to show. Adopting one is an
|
|
17
|
+
* explicit, separate act — `franklin wallet-adopt <address>` — because the
|
|
18
|
+
* whole complaint is that the active wallet changed without anyone asking.
|
|
19
|
+
*/
|
|
20
|
+
import fs from 'node:fs';
|
|
21
|
+
import path from 'node:path';
|
|
22
|
+
import bs58 from 'bs58';
|
|
23
|
+
import { Keypair } from '@solana/web3.js';
|
|
24
|
+
import { BLOCKRUN_DIR } from '../config.js';
|
|
25
|
+
/**
|
|
26
|
+
* The address the SDK will select, derived from the canonical session file.
|
|
27
|
+
*
|
|
28
|
+
* Deliberately does not call `getOrCreateSolanaWallet()`: that CREATES a wallet
|
|
29
|
+
* as a side effect, which is exactly the wrong thing to do inside a diagnostic
|
|
30
|
+
* that is trying to tell the user which wallet they already have. Same
|
|
31
|
+
* primitives the signing path uses.
|
|
32
|
+
*/
|
|
33
|
+
export function activeSolanaAddress() {
|
|
34
|
+
try {
|
|
35
|
+
const key = fs.readFileSync(path.join(BLOCKRUN_DIR, '.solana-session'), 'utf-8').trim();
|
|
36
|
+
if (!key)
|
|
37
|
+
return null;
|
|
38
|
+
return Keypair.fromSecretKey(bs58.decode(key)).publicKey.toBase58();
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return null; // absent, unreadable, or not a key we can derive from
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Wallets on this machine that Franklin can see but is not using.
|
|
46
|
+
*
|
|
47
|
+
* Returns null when there is nothing to say — no active wallet, or every
|
|
48
|
+
* discovered wallet is the active one. `listDiscoveredSolanaWallets()` derives
|
|
49
|
+
* each address from the secret key rather than trusting the file, and returns
|
|
50
|
+
* no secret material.
|
|
51
|
+
*/
|
|
52
|
+
export async function detectSolanaWalletDivergence() {
|
|
53
|
+
const active = activeSolanaAddress();
|
|
54
|
+
if (!active)
|
|
55
|
+
return null;
|
|
56
|
+
let discovered = [];
|
|
57
|
+
try {
|
|
58
|
+
const { listDiscoveredSolanaWallets } = await import('@blockrun/llm');
|
|
59
|
+
discovered = await listDiscoveredSolanaWallets();
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return null; // SDK unavailable or scan failed — a diagnostic must not throw
|
|
63
|
+
}
|
|
64
|
+
const alternatives = discovered.filter((w) => w.address !== active);
|
|
65
|
+
if (alternatives.length === 0)
|
|
66
|
+
return null;
|
|
67
|
+
return { active, alternatives };
|
|
68
|
+
}
|
|
69
|
+
/** One-line-per-wallet report. Public addresses only. */
|
|
70
|
+
export function formatDivergence(d) {
|
|
71
|
+
const lines = [
|
|
72
|
+
`Active Solana wallet: ${d.active}`,
|
|
73
|
+
`Franklin can also see ${d.alternatives.length} other wallet(s) on this machine:`,
|
|
74
|
+
...d.alternatives.map((w) => ` ${w.address} (${w.source})`),
|
|
75
|
+
'',
|
|
76
|
+
'If your USDC is on one of those, Franklin is not spending from it. Adopt it with:',
|
|
77
|
+
` franklin wallet-adopt <address>`,
|
|
78
|
+
'The current session file is backed up before anything is replaced.',
|
|
79
|
+
];
|
|
80
|
+
return lines.join('\n');
|
|
81
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blockrun/franklin",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.47.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,13 +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/serve-security.local.mjs test/skills.local.mjs test/repair.mjs test/model-resolver.mjs test/exa.local.mjs test/audit-batch.local.mjs test/polymarket.local.mjs test/market.local.mjs test/hooks.local.mjs test/scheduler.local.mjs test/trade-plan.local.mjs test/goal.local.mjs test/memory.local.mjs test/agent-host.local.mjs test/reservation.local.mjs",
|
|
41
|
+
"test": "npm run build && node --test --test-concurrency=4 --test-reporter=spec test/local.mjs test/api-key.local.mjs test/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",
|
|
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
|
-
"test:e2e:watch": "node --test --watch test/e2e.mjs"
|
|
47
|
+
"test:e2e:watch": "node --test --watch test/e2e.mjs",
|
|
48
|
+
"test:catalog": "npm run build && node --test test/model-catalog.local.mjs"
|
|
48
49
|
},
|
|
49
50
|
"keywords": [
|
|
50
51
|
"franklin",
|
|
@@ -98,7 +99,8 @@
|
|
|
98
99
|
"react": "^19.2.4",
|
|
99
100
|
"sharp": "^0.35.3",
|
|
100
101
|
"viem": "^2.48.1",
|
|
101
|
-
"ws": "^8.21.1"
|
|
102
|
+
"ws": "^8.21.1",
|
|
103
|
+
"@blockrun/model-catalog": "https://codeload.github.com/BlockRunAI/model-catalog/tar.gz/2b55804b109cd132bd988096fb3617fb48e67cfb"
|
|
102
104
|
},
|
|
103
105
|
"devDependencies": {
|
|
104
106
|
"@types/node": "^26.1.1",
|