@blockrun/franklin 3.49.24 → 3.49.26

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 CHANGED
@@ -45,7 +45,7 @@
45
45
 
46
46
  ## The pitch in one paragraph
47
47
 
48
- Franklin Agent is an **autonomous economic agent** — an AI that holds a USDC wallet and spends it to get real work done, with **trading as its flagship arena**. It buys live market data, proposes trade plans you approve before a cent moves, pursues long-running goals across sessions, keeps a wallet-bound trading journal, and picks the best model per task from <!-- br:models.chatVisible -->90<!-- /br:models.chatVisible --> models. You state an outcome and set a budget. Franklin Agent decides what to call, what to pay for, and when to stop. No subscriptions, no seats, no rate limits.
48
+ Franklin Agent is an **autonomous economic agent** — an AI that holds a USDC wallet and spends it to get real work done, with **trading as its flagship arena**. It buys live market data, proposes trade plans you approve before a cent moves, pursues long-running goals across sessions, keeps a wallet-bound trading journal, and picks the best model per task from <!-- br:models.chatVisible -->91<!-- /br:models.chatVisible --> models. You state an outcome and set a budget. Franklin Agent decides what to call, what to pay for, and when to stop. No subscriptions, no seats, no rate limits.
49
49
 
50
50
  Funding it is your choice. Fund a **USDC wallet** and every paid action routes through the [x402](https://x402.org) micropayment protocol, settling on-chain against a wallet only you control — no signup, no account, the wallet is the identity. Or top up a **prepaid balance** at [user.blockrun.ai](https://user.blockrun.ai) and hand Franklin an API key. Same models, same tools, same agent. See [Two ways to pay](#two-ways-to-pay).
51
51
 
@@ -387,7 +387,7 @@ Every tool call is itemized. Every token is priced. When the wallet hits zero, F
387
387
 
388
388
  ## Smart Router
389
389
 
390
- **<!-- br:models.chatVisible -->90<!-- /br:models.chatVisible --> models. One decision. Zero guesswork.**
390
+ **<!-- br:models.chatVisible -->91<!-- /br:models.chatVisible --> models. One decision. Zero guesswork.**
391
391
 
392
392
  You don't pick models. Franklin picks for you.
393
393
 
@@ -467,7 +467,7 @@ No email. No phone. No KYC. Your Solana, Base or Arc address is your account —
467
467
  | -------------------------------------- | ---------------- | ----------------------- | -------------------- | ------------------------------- |
468
468
  | **Spends money for you** | ❌ | ⚠️ you wire payments | ⚠️ trades only | ✅ **USDC wallet or prepaid key** |
469
469
  | **Buys data + APIs + images + search** | ❌ | ⚠️ one key per service | ❌ | ✅ **one wallet pays for all** |
470
- | Picks best model per task | ❌ single-vendor | ⚠️ you pick | ❌ | ✅ **Smart Router, <!-- br:models.chatVisible -->90<!-- /br:models.chatVisible --> models** |
470
+ | Picks best model per task | ❌ single-vendor | ⚠️ you pick | ❌ | ✅ **Smart Router, <!-- br:models.chatVisible -->91<!-- /br:models.chatVisible --> models** |
471
471
  | **Money moves only on your approval** | — | ⚠️ build it yourself | ❌ runs on rules | ✅ **trade plan, every mode** |
472
472
  | Spend guardrails | — | ⚠️ build it yourself | ⚠️ per-bot limits | ✅ **budget caps + hooks** |
473
473
  | Works when a provider goes down | ❌ | ⚠️ if you code it | ❌ | ✅ **routes to another** |
@@ -494,14 +494,14 @@ Ask "what's BTC looking like?" — Franklin fetches live price data, computes RS
494
494
  **🎨 AI image generation**
495
495
  Ask "generate a logo" — Franklin calls DALL-E / GPT Image, saves the result locally, paid from your wallet.
496
496
 
497
- **🧠 <!-- br:models.chatVisible -->90<!-- /br:models.chatVisible --> models via one wallet**
497
+ **🧠 <!-- br:models.chatVisible -->91<!-- /br:models.chatVisible --> models via one wallet**
498
498
  Anthropic, OpenAI, Google, xAI, DeepSeek, GLM, Kimi, Minimax, plus a free tier. One wallet, one interface, automatic fallback.
499
499
 
500
500
  **💳 x402 micropayments (YOPO)**
501
501
  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.
502
502
 
503
503
  **🧠 Learned model router**
504
- Trained on 2M+ real requests. Classifies your task and picks the best model from <!-- br:models.chatVisible -->90<!-- /br:models.chatVisible --> LLMs. Four profiles (auto/eco/premium/free). Adapts to your usage over time.
504
+ Trained on 2M+ real requests. Classifies your task and picks the best model from <!-- br:models.chatVisible -->91<!-- /br:models.chatVisible --> LLMs. Four profiles (auto/eco/premium/free). Adapts to your usage over time.
505
505
 
506
506
  </td>
507
507
  <td width="50%" valign="top">
@@ -567,7 +567,8 @@ Franklin holds money, so the defaults assume a model can be steered by what it r
567
567
  - **Money moves only on your approval.** Trades need a trade plan you approve, in every permission mode. `--max-spend` sets a spending ceiling, and [lifecycle hooks](docs/examples/hooks/) can veto any paid action before it runs.
568
568
  - **The wallet key never reaches the model.** File, search and browser tools refuse the key store and the machine's own credential stores (`~/.ssh`, `~/.aws`, cloud and Solana CLI keys). The exact key values are also scrubbed from every tool result.
569
569
  - **Network calls stay public.** Model-driven requests (web fetch, webhooks, the browser) refuse loopback, private and cloud-metadata addresses, and re-check every redirect.
570
- - **The local panel answers only you.** It listens on loopback, checks the `Host` header, and its wallet and spend routes require a token that only the page it serves knows.
570
+ - **The local panel answers only you.** It listens on loopback, checks the `Host` header, and its wallet and spend routes require a token that only the page it serves knows. The browser is opened through an owner-only file, so that token never appears on a command line.
571
+ - **`franklin serve` answers only token holders.** Every socket must carry a per-start token, kept in the owner-only `~/.blockrun/serve-url` that `franklin panel` reads. An approval prompt can be answered only by the connection it was sent to.
571
572
 
572
573
  Found a vulnerability? Please report it privately — see [SECURITY.md](SECURITY.md).
573
574
 
@@ -581,13 +582,13 @@ Found a vulnerability? Please report it privately — see [SECURITY.md](SECURITY
581
582
  │ Intent → Smart Router → Tool Use → Spend Control → Result │
582
583
  ├──────────────────────────────────────────────────────────────┤
583
584
  │ Learned Router │
584
- │ 2M+ requests · <!-- br:models.chatVisible@live -->90<!-- /br:models.chatVisible@live --> models · category detection · Elo scores │
585
+ │ 2M+ requests · <!-- br:models.chatVisible@live -->91<!-- /br:models.chatVisible@live --> models · category detection · Elo scores │
585
586
  ├──────────────────────────────────────────────────────────────┤
586
587
  │ Agent Loop │
587
588
  │ 60+ tools · Sessions · Compaction · Pricing · Plugin SDK │
588
589
  ├──────────────────────────────────────────────────────────────┤
589
590
  │ BlockRun Gateway │
590
- │ <!-- br:models.chatVisible@live -->90<!-- /br:models.chatVisible@live --> LLMs · CoinGecko · Search · Image APIs · paid services │
591
+ │ <!-- br:models.chatVisible@live -->91<!-- /br:models.chatVisible@live --> LLMs · CoinGecko · Search · Image APIs · paid services │
591
592
  ├──────────────────────────────────────────────────────────────┤
592
593
  │ x402 Micropayment Protocol │
593
594
  │ HTTP 402 · USDC on Solana, Base & Arc · signed payloads │
@@ -636,7 +637,7 @@ src/
636
637
  ├── stats/ Usage tracking + insights engine
637
638
  ├── ui/ Ink-based terminal UI
638
639
  ├── proxy/ Payment proxy for external tools
639
- ├── router/ Learned model router (<!-- br:models.chatVisible@live -->90<!-- /br:models.chatVisible@live --> models, Elo scoring)
640
+ ├── router/ Learned model router (<!-- br:models.chatVisible@live -->91<!-- /br:models.chatVisible@live --> models, Elo scoring)
640
641
  ├── wallet/ Wallet management (Base/Arc + Solana)
641
642
  ├── mcp/ MCP server auto-discovery
642
643
  └── commands/ CLI subcommands
@@ -2,10 +2,23 @@
2
2
  * franklin panel — launch the local web dashboard.
3
3
  */
4
4
  /**
5
- * Open a URL in the default browser without going through a shell: the URL
6
- * carries the panel token and `?`/`#`, which a shell would glob or cut.
5
+ * How to hand a staged launch page to the default browser. The argument is the
6
+ * owner-only file from writePanelOpenFile, never the URL: argument vectors are
7
+ * readable by other local accounts (/proc/<pid>/cmdline on Linux), and the
8
+ * URL carries the token that unlocks /api/wallet/secret. No shell is involved.
7
9
  */
8
- export declare function openInBrowser(url: string): void;
10
+ export declare function browserOpenCommand(filePath: string, platform?: NodeJS.Platform): {
11
+ cmd: string;
12
+ args: string[];
13
+ windowsVerbatimArguments?: boolean;
14
+ };
15
+ /**
16
+ * Open the panel launch URL in the default browser. The browser is pointed at
17
+ * a 0600 redirect page so the token never enters any process's command line.
18
+ * If staging fails, nothing is opened: the starting terminal still shows the
19
+ * link, and leaking the token is worse than a manual click.
20
+ */
21
+ export declare function openInBrowser(launchUrl: string): void;
9
22
  export declare function panelCommand(options: {
10
23
  port?: string;
11
24
  open?: string | boolean;
@@ -4,21 +4,39 @@
4
4
  import chalk from 'chalk';
5
5
  import fs from 'node:fs';
6
6
  import { execFile } from 'node:child_process';
7
- import { createPanelServer, writePanelUrlFile, PANEL_URL_FILE } from '../panel/server.js';
7
+ import { createPanelServer, writePanelUrlFile, writePanelOpenFile, PANEL_URL_FILE } from '../panel/server.js';
8
8
  /**
9
- * Open a URL in the default browser without going through a shell: the URL
10
- * carries the panel token and `?`/`#`, which a shell would glob or cut.
9
+ * How to hand a staged launch page to the default browser. The argument is the
10
+ * owner-only file from writePanelOpenFile, never the URL: argument vectors are
11
+ * readable by other local accounts (/proc/<pid>/cmdline on Linux), and the
12
+ * URL carries the token that unlocks /api/wallet/secret. No shell is involved.
11
13
  */
12
- export function openInBrowser(url) {
13
- const onError = () => { };
14
- if (process.platform === 'darwin')
15
- execFile('open', [url], onError);
16
- else if (process.platform === 'win32') {
14
+ export function browserOpenCommand(filePath, platform = process.platform) {
15
+ if (platform === 'darwin')
16
+ return { cmd: 'open', args: [filePath] };
17
+ if (platform === 'win32') {
17
18
  // `start` treats its first quoted argument as a window title.
18
- execFile('cmd', ['/c', 'start', '""', `"${url}"`], { windowsVerbatimArguments: true }, onError);
19
+ return { cmd: 'cmd', args: ['/c', 'start', '""', `"${filePath}"`], windowsVerbatimArguments: true };
19
20
  }
20
- else
21
- execFile('xdg-open', [url], onError);
21
+ return { cmd: 'xdg-open', args: [filePath] };
22
+ }
23
+ /**
24
+ * Open the panel launch URL in the default browser. The browser is pointed at
25
+ * a 0600 redirect page so the token never enters any process's command line.
26
+ * If staging fails, nothing is opened: the starting terminal still shows the
27
+ * link, and leaking the token is worse than a manual click.
28
+ */
29
+ export function openInBrowser(launchUrl) {
30
+ let file;
31
+ try {
32
+ file = writePanelOpenFile(launchUrl);
33
+ }
34
+ catch {
35
+ return;
36
+ }
37
+ const { cmd, args, windowsVerbatimArguments } = browserOpenCommand(file);
38
+ const onError = () => { };
39
+ execFile(cmd, args, { windowsVerbatimArguments }, onError);
22
40
  }
23
41
  /**
24
42
  * `franklin panel --open [section]`: open the panel that is already running
@@ -1969,7 +1969,7 @@ function renderPhoneNumbers(data) {
1969
1969
  const human = formatPhoneNumber(n.phone_number);
1970
1970
  const renewBtn = tier === 'expired'
1971
1971
  ? ''
1972
- : '<button class="btn btn-warn" data-phone-renew="' + n.phone_number + '">Renew $5</button>';
1972
+ : '<button class="btn btn-warn" data-phone-renew="' + esc(n.phone_number) + '">Renew $5</button>';
1973
1973
  const releaseLabel = tier === 'expired' ? 'Remove' : 'Release';
1974
1974
  return ''
1975
1975
  + '<div class="phone-row' + rowCls + '">'
@@ -1979,15 +1979,15 @@ function renderPhoneNumbers(data) {
1979
1979
  + ' </svg>'
1980
1980
  + ' </div>'
1981
1981
  + ' <div class="phone-main">'
1982
- + ' <div class="phone-num">' + human + '</div>'
1982
+ + ' <div class="phone-num">' + esc(human) + '</div>'
1983
1983
  + ' <div class="phone-meta">'
1984
- + ' <span class="chip">' + (n.chain || '—') + '</span>'
1984
+ + ' <span class="chip">' + esc(n.chain || '—') + '</span>'
1985
1985
  + ' <span class="chip ' + chipCls + '">' + phoneCountdownLabel(d) + '</span>'
1986
1986
  + ' </div>'
1987
1987
  + ' </div>'
1988
1988
  + ' <div class="phone-actions">'
1989
1989
  + renewBtn
1990
- + ' <button class="btn btn-ghost" data-phone-release="' + n.phone_number + '" title="' + releaseLabel + ' this number">' + releaseLabel + '</button>'
1990
+ + ' <button class="btn btn-ghost" data-phone-release="' + esc(n.phone_number) + '" title="' + releaseLabel + ' this number">' + releaseLabel + '</button>'
1991
1991
  + ' </div>'
1992
1992
  + '</div>';
1993
1993
  }).join('');
@@ -2017,7 +2017,7 @@ async function loadPhone(opts) {
2017
2017
  if (!r.ok) {
2018
2018
  if (statusEl) { statusEl.textContent = data.error || 'Failed to load'; statusEl.className = 'phone-status err'; }
2019
2019
  const list = document.getElementById('phone-list');
2020
- if (list) list.innerHTML = '<div class="phone-empty"><strong>Could not load numbers</strong>' + (data.error || 'Unknown error') + '</div>';
2020
+ if (list) list.innerHTML = '<div class="phone-empty"><strong>Could not load numbers</strong>' + esc(data.error || 'Unknown error') + '</div>';
2021
2021
  return;
2022
2022
  }
2023
2023
  phoneState.data = data;
@@ -25,4 +25,18 @@ export declare const PANEL_URL_FILE: string;
25
25
  * Returns the launch URL.
26
26
  */
27
27
  export declare function writePanelUrlFile(port: number): string;
28
+ /**
29
+ * Where `openInBrowser` stages the launch URL. A process's argument vector is
30
+ * not private: /proc/<pid>/cmdline is world-readable on Linux, so passing the
31
+ * token-bearing URL to xdg-open (and on to the browser it starts) would show
32
+ * the token to every local account. The opener gets this file's path instead,
33
+ * and the page inside forwards the browser to the real URL.
34
+ */
35
+ export declare const PANEL_OPEN_FILE: string;
36
+ /**
37
+ * Write the owner-only redirect page for `launchUrl` and return its path.
38
+ * Throws on anything that is not a panel launch URL, so nothing else can be
39
+ * smuggled into the page.
40
+ */
41
+ export declare function writePanelOpenFile(launchUrl: string): string;
28
42
  export declare function createPanelServer(port: number): http.Server;
@@ -136,6 +136,34 @@ export function writePanelUrlFile(port) {
136
136
  catch { /* best-effort: the terminal still shows the link */ }
137
137
  return launch;
138
138
  }
139
+ /**
140
+ * Where `openInBrowser` stages the launch URL. A process's argument vector is
141
+ * not private: /proc/<pid>/cmdline is world-readable on Linux, so passing the
142
+ * token-bearing URL to xdg-open (and on to the browser it starts) would show
143
+ * the token to every local account. The opener gets this file's path instead,
144
+ * and the page inside forwards the browser to the real URL.
145
+ */
146
+ export const PANEL_OPEN_FILE = path.join(BLOCKRUN_DIR, 'panel-open.html');
147
+ // Launch URLs are always our own: 127.0.0.1, a hex token, an optional #section.
148
+ const LAUNCH_URL_RE = /^http:\/\/127\.0\.0\.1:\d{1,5}\/\?token=[0-9a-f]{64}(?:#[a-z0-9-]+)?$/i;
149
+ /**
150
+ * Write the owner-only redirect page for `launchUrl` and return its path.
151
+ * Throws on anything that is not a panel launch URL, so nothing else can be
152
+ * smuggled into the page.
153
+ */
154
+ export function writePanelOpenFile(launchUrl) {
155
+ if (!LAUNCH_URL_RE.test(launchUrl))
156
+ throw new Error('not a panel launch URL');
157
+ const page = '<!DOCTYPE html><html><head><meta charset="utf-8">'
158
+ + '<meta name="referrer" content="no-referrer"><title>Franklin Panel</title>'
159
+ + `<meta http-equiv="refresh" content="0;url=${launchUrl}">`
160
+ + `<script>location.replace(${JSON.stringify(launchUrl)});</script>`
161
+ + `</head><body><a href="${launchUrl}">Open the Franklin panel</a></body></html>`;
162
+ fs.mkdirSync(BLOCKRUN_DIR, { recursive: true });
163
+ fs.writeFileSync(PANEL_OPEN_FILE, page, { encoding: 'utf8', mode: 0o600 });
164
+ fs.chmodSync(PANEL_OPEN_FILE, 0o600);
165
+ return PANEL_OPEN_FILE;
166
+ }
139
167
  const LOCKED_PAGE = `<!DOCTYPE html><html><head><meta charset="utf-8"><title>Franklin Panel</title>
140
168
  <meta name="referrer" content="no-referrer"></head>
141
169
  <body style="font-family:system-ui,sans-serif;max-width:34rem;margin:4rem auto;line-height:1.5">
@@ -18,6 +18,8 @@
18
18
  */
19
19
  import type { AgentConfig } from '../agent/types.js';
20
20
  export declare function isOriginAllowed(origin: string | undefined): boolean;
21
+ /** The token clients must present, minting a random one if none was supplied. */
22
+ export declare function ensureServeToken(): string;
21
23
  export declare function tokenOk(url: URL): boolean;
22
24
  export declare function localFileUrl(port: number, filePath: string): string;
23
25
  export declare function fileTokenOk(url: URL): boolean;
@@ -166,8 +166,12 @@ const MEDIA_MIME = {
166
166
  // FRANKLIN_SERVE_ALLOWED_ORIGINS (comma-separated). The literal "null" origin
167
167
  // is REJECTED by default — sandboxed iframes on hostile pages also serialize
168
168
  // to "null" — set FRANKLIN_SERVE_ALLOW_NULL_ORIGIN=1 if a renderer needs it.
169
- // Defense-in-depth: when FRANKLIN_SERVE_TOKEN is set, every WS upgrade and
170
- // /file request must also carry it (?token=…).
169
+ // The origin check alone is not authentication: a client with no Origin header
170
+ // may be another local account, and any page on a localhost dev server passes
171
+ // it. Every WS upgrade must therefore carry the server token (?token=…) and
172
+ // every /file request an HMAC signed with it. The token is FRANKLIN_SERVE_TOKEN
173
+ // when the launcher supplies one (Desktop does), otherwise minted per process
174
+ // by startServer. There is no unauthenticated mode.
171
175
  const DEFAULT_ALLOWED_ORIGINS = ['https://franklin.run'];
172
176
  export function isOriginAllowed(origin) {
173
177
  if (!origin)
@@ -189,10 +193,30 @@ export function isOriginAllowed(origin) {
189
193
  .split(',').map((s) => s.trim()).filter(Boolean);
190
194
  return [...DEFAULT_ALLOWED_ORIGINS, ...extra].includes(origin);
191
195
  }
196
+ // Minted by ensureServeToken() when the launcher supplied none. Kept out of
197
+ // process.env on purpose: the agent's own subprocesses (Bash, hooks, MCP)
198
+ // inherit the environment, and a model-driven command holding this token
199
+ // could open the socket and approve its own permission prompts.
200
+ let mintedServeToken = null;
201
+ function requiredServeToken() {
202
+ return process.env.FRANKLIN_SERVE_TOKEN || mintedServeToken;
203
+ }
204
+ function fileSigningKey() {
205
+ return process.env.FRANKLIN_SERVE_FILE_TOKEN || requiredServeToken();
206
+ }
207
+ /** The token clients must present, minting a random one if none was supplied. */
208
+ export function ensureServeToken() {
209
+ const existing = requiredServeToken();
210
+ if (existing)
211
+ return existing;
212
+ mintedServeToken = crypto.randomBytes(32).toString('base64url');
213
+ return mintedServeToken;
214
+ }
192
215
  export function tokenOk(url) {
193
- const required = process.env.FRANKLIN_SERVE_TOKEN;
216
+ // Fail closed: no configured token means nobody is authorised, never everybody.
217
+ const required = requiredServeToken();
194
218
  if (!required)
195
- return true;
219
+ return false;
196
220
  const supplied = url.searchParams.get('token');
197
221
  if (!supplied)
198
222
  return false;
@@ -203,16 +227,16 @@ export function tokenOk(url) {
203
227
  export function localFileUrl(port, filePath) {
204
228
  const url = new URL(`http://127.0.0.1:${port}/file`);
205
229
  url.searchParams.set('path', filePath);
206
- const signingKey = process.env.FRANKLIN_SERVE_FILE_TOKEN || process.env.FRANKLIN_SERVE_TOKEN;
230
+ const signingKey = fileSigningKey();
207
231
  if (signingKey) {
208
232
  url.searchParams.set('sig', crypto.createHmac('sha256', signingKey).update(filePath).digest('base64url'));
209
233
  }
210
234
  return url.toString();
211
235
  }
212
236
  export function fileTokenOk(url) {
213
- const signingKey = process.env.FRANKLIN_SERVE_FILE_TOKEN || process.env.FRANKLIN_SERVE_TOKEN;
237
+ const signingKey = fileSigningKey();
214
238
  if (!signingKey)
215
- return true;
239
+ return false;
216
240
  const filePath = url.searchParams.get('path');
217
241
  const supplied = url.searchParams.get('sig');
218
242
  if (!filePath || !supplied)
@@ -389,6 +413,9 @@ function dialogueText(content) {
389
413
  export async function startServer(opts) {
390
414
  let { port } = opts;
391
415
  const { workDir, debug } = opts;
416
+ // Before anything can mint a /file URL or accept a socket.
417
+ const tokenSupplied = !!process.env.FRANKLIN_SERVE_TOKEN;
418
+ const serveToken = ensureServeToken();
392
419
  const chain = loadChain();
393
420
  const apiUrl = gatewayBase();
394
421
  const userConfig = loadConfig();
@@ -444,6 +471,8 @@ export async function startServer(opts) {
444
471
  // (agent.permissionAsk / agent.permissionResponse with askId + decision).
445
472
  const questions = new DesktopQuestions();
446
473
  let askSeq = 0;
474
+ // Each ask remembers the socket it was sent to. Only that socket may answer
475
+ // it: holding an askId must not be enough to approve a tool or a payment.
447
476
  const legacyAsks = new Map();
448
477
  const requestDesktopPermission = (toolName, description, timeoutMs = 15 * 60 * 1000) => new Promise((resolve) => {
449
478
  if (!activeWs || !activeTurnId) {
@@ -456,9 +485,12 @@ export async function startServer(opts) {
456
485
  resolve('no');
457
486
  }, timeoutMs);
458
487
  timer.unref?.();
459
- legacyAsks.set(askId, (decision) => {
460
- clearTimeout(timer);
461
- resolve(decision);
488
+ legacyAsks.set(askId, {
489
+ ws: activeWs,
490
+ resolve: (decision) => {
491
+ clearTimeout(timer);
492
+ resolve(decision);
493
+ },
462
494
  });
463
495
  emit('agent.permissionAsk', { sessionId: '', toolName, description, askId });
464
496
  });
@@ -957,11 +989,11 @@ export async function startServer(opts) {
957
989
  }
958
990
  const askId = p.askId ? String(p.askId) : '';
959
991
  if (askId) {
960
- const resolver = legacyAsks.get(askId);
961
- if (resolver) {
992
+ const ask = legacyAsks.get(askId);
993
+ if (ask && ask.ws === ws) {
962
994
  legacyAsks.delete(askId);
963
995
  const decision = String(p.decision ?? p.choice ?? 'n').toLowerCase();
964
- resolver(decision === 'always' ? 'always' :
996
+ ask.resolve(decision === 'always' ? 'always' :
965
997
  decision === 'y' || decision === 'yes' || decision === 'approve' ? 'yes' : 'no');
966
998
  send(ws, id, 'response', { ok: true });
967
999
  }
@@ -1155,15 +1187,24 @@ export async function startServer(opts) {
1155
1187
  if (discoveryEnabled) {
1156
1188
  try {
1157
1189
  const discoveryUrl = new URL(`ws://127.0.0.1:${port}/agent`);
1158
- const token = process.env.FRANKLIN_SERVE_TOKEN;
1159
- if (token)
1160
- discoveryUrl.searchParams.set('token', token);
1190
+ discoveryUrl.searchParams.set('token', serveToken);
1161
1191
  writtenDiscoveryUrl = discoveryUrl.toString();
1162
1192
  fs.mkdirSync(BLOCKRUN_DIR, { recursive: true });
1163
1193
  fs.writeFileSync(serveUrlFile, writtenDiscoveryUrl, { mode: 0o600 });
1194
+ // mode only applies on create; tighten a file an earlier run left behind.
1195
+ fs.chmodSync(serveUrlFile, 0o600);
1164
1196
  }
1165
1197
  catch { /* best-effort */ }
1166
1198
  }
1199
+ if (!tokenSupplied) {
1200
+ // A minted token is useless unless a client can get it. The 0600 discovery
1201
+ // file is the normal channel (`franklin panel` reads it); with discovery off
1202
+ // only this terminal can hand it on, same as the panel's launch link.
1203
+ // eslint-disable-next-line no-console
1204
+ console.log(writtenDiscoveryUrl
1205
+ ? `Clients authenticate with the per-start token in ${serveUrlFile} (owner-only).`
1206
+ : `Connect with: ws://127.0.0.1:${port}/agent?token=${serveToken}`);
1207
+ }
1167
1208
  const cleanup = () => {
1168
1209
  // Do not remove another server's discovery record. Packaged Desktop has
1169
1210
  // discovery disabled, and multiple standalone servers may overlap.
@@ -1,2 +1,2 @@
1
- export declare const SENSITIVE_ENV_NAMES: readonly ['BLOCKRUN_API_KEY', 'BLOCKRUN_WALLET_KEY', 'BASE_CHAIN_WALLET_KEY', 'SOLANA_WALLET_KEY'];
1
+ export declare const SENSITIVE_ENV_NAMES: readonly ['BLOCKRUN_API_KEY', 'BLOCKRUN_WALLET_KEY', 'BASE_CHAIN_WALLET_KEY', 'SOLANA_WALLET_KEY', 'FRANKLIN_SERVE_TOKEN', 'FRANKLIN_SERVE_FILE_TOKEN'];
2
2
  export declare function sanitizeSubprocessEnv(env?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
@@ -4,6 +4,10 @@ export const SENSITIVE_ENV_NAMES = [
4
4
  'BLOCKRUN_WALLET_KEY',
5
5
  'BASE_CHAIN_WALLET_KEY',
6
6
  'SOLANA_WALLET_KEY',
7
+ // `franklin serve` socket credentials (Desktop passes them in the env). A
8
+ // model-driven command holding one could connect and approve its own prompts.
9
+ 'FRANKLIN_SERVE_TOKEN',
10
+ 'FRANKLIN_SERVE_FILE_TOKEN',
7
11
  ];
8
12
  export function sanitizeSubprocessEnv(env = process.env) {
9
13
  const sanitized = { ...env };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blockrun/franklin",
3
- "version": "3.49.24",
3
+ "version": "3.49.26",
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,7 +38,7 @@
38
38
  "desktop:package:win": "npm run dist:win --workspace @blockrun/franklin-desktop",
39
39
  "dev": "tsc --watch",
40
40
  "start": "node dist/index.js",
41
- "test": "npm run build && node --test --test-concurrency=4 --test-reporter=spec test/local.mjs test/api-key.local.mjs test/solana-migration.local.mjs test/serve-security.local.mjs test/skills.local.mjs test/skills-management.local.mjs test/glob-responsive.local.mjs test/desktop-auto-routing.local.mjs test/desktop-questions.local.mjs test/desktop-question-flow.local.mjs test/desktop-input.local.mjs test/desktop-image-flow.local.mjs test/repair.mjs test/model-resolver.mjs test/exa.local.mjs test/audit-batch.local.mjs test/polymarket.local.mjs test/market.local.mjs test/hooks.local.mjs test/scheduler.local.mjs test/trade-plan.local.mjs test/goal.local.mjs test/memory.local.mjs test/agent-host.local.mjs test/reservation.local.mjs test/model-catalog.local.mjs test/arc.local.mjs test/subprocess-env.local.mjs test/withdraw.local.mjs test/orders.local.mjs test/payment-hold.local.mjs test/experience.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/serve-auth.local.mjs test/skills.local.mjs test/skills-management.local.mjs test/glob-responsive.local.mjs test/desktop-auto-routing.local.mjs test/desktop-questions.local.mjs test/desktop-question-flow.local.mjs test/desktop-input.local.mjs test/desktop-image-flow.local.mjs test/repair.mjs test/model-resolver.mjs test/exa.local.mjs test/audit-batch.local.mjs test/polymarket.local.mjs test/market.local.mjs test/hooks.local.mjs test/scheduler.local.mjs test/trade-plan.local.mjs test/goal.local.mjs test/memory.local.mjs test/agent-host.local.mjs test/reservation.local.mjs test/model-catalog.local.mjs test/arc.local.mjs test/subprocess-env.local.mjs test/withdraw.local.mjs test/orders.local.mjs test/payment-hold.local.mjs test/experience.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",
@@ -77,7 +77,7 @@
77
77
  "dependencies": {
78
78
  "@blockrun/llm": "^3.19.1",
79
79
  "@blockrun/model-catalog": "https://codeload.github.com/BlockRunAI/model-catalog/tar.gz/aecf20b4d5ee51af4a38a69a1b9c81e3e64b955c",
80
- "@blockrun/router-core": "https://codeload.github.com/BlockRunAI/router-core/tar.gz/fd6d03d035ff676642ba1683c333d929939f8a00",
80
+ "@blockrun/router-core": "https://codeload.github.com/BlockRunAI/router-core/tar.gz/273c2af0a9abe70212efbad7117b72eb3038cffc",
81
81
  "@colbymchenry/codegraph": "^1.5.0",
82
82
  "@modelcontextprotocol/sdk": "^1.29.0",
83
83
  "@polymarket/builder-relayer-client": "^0.0.10",