@blockrun/franklin 3.35.6 → 3.37.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.
@@ -242,7 +242,7 @@ You run on the BlockRun AI Gateway. When the user asks you to "test the BlockRun
242
242
  - \`GET /.well-known/x402\` — x402 resource list with prices
243
243
 
244
244
  **LLM (POST, x402-paid)**
245
- - \`POST /v1/chat/completions\` — OpenAI-compatible. Body: \`{ model, messages, stream?, tools?, max_tokens?, temperature? }\`. \`model\` MUST come from \`GET /v1/models\` (real frontier examples on the gateway, verified live 2026-07-14: \`anthropic/claude-sonnet-5\`, \`anthropic/claude-opus-4.8\`, \`deepseek/deepseek-v4-pro\`, \`zai/glm-5.2\`, \`xai/grok-4.5\`, \`nvidia/qwen3-next-80b-a3b-instruct\` (free)). Do NOT invent versions like \`openai/gpt-5.1\` or \`xai/grok-5\` — those don't exist; the gateway 400s with the valid list in the error body, so when in doubt fetch \`GET /v1/models\` first.
245
+ - \`POST /v1/chat/completions\` — OpenAI-compatible. Body: \`{ model, messages, stream?, tools?, max_tokens?, temperature? }\`. \`model\` MUST come from \`GET /v1/models\` (real frontier examples on the gateway, verified live 2026-07-24: \`anthropic/claude-sonnet-5\`, \`anthropic/claude-opus-5\`, \`deepseek/deepseek-v4-pro\`, \`zai/glm-5.2\`, \`xai/grok-4.5\`, \`nvidia/qwen3-next-80b-a3b-instruct\` (free)). Do NOT invent versions like \`openai/gpt-5.1\` or \`xai/grok-5\` — those don't exist; the gateway 400s with the valid list in the error body, so when in doubt fetch \`GET /v1/models\` first.
246
246
  - \`POST /v1/messages\` — Anthropic-compatible. Body: \`{ model, messages, max_tokens, system?, tools? }\`.
247
247
 
248
248
  **Media (POST, x402-paid; GET to poll async jobs)**
package/dist/agent/llm.js CHANGED
@@ -243,6 +243,12 @@ export function modelHasExtendedThinking(model) {
243
243
  const m = model.toLowerCase();
244
244
  // Excluded: Opus 4.7+, Sonnet 5, and Fable 5 use adaptive / always-on
245
245
  // thinking; sending an explicit `thinking: enabled` causes the API to 400.
246
+ // Opus 5 goes further — thinking is ON by default (omitting the field runs
247
+ // adaptive, unlike 4.8/4.7 where omitting it meant no thinking), and
248
+ // `budget_tokens` is rejected outright. Listed explicitly rather than left
249
+ // to fall through, so the allowlist stays readable as the source of truth.
250
+ if (m.includes('opus-5') || m.includes('opus5'))
251
+ return false;
246
252
  if (m.includes('opus-4.8') || m.includes('opus-4-8'))
247
253
  return false;
248
254
  if (m.includes('opus-4.7') || m.includes('opus-4-7'))
@@ -570,13 +576,26 @@ export class ModelClient {
570
576
  // flag); passing the extended-thinking flag to them makes Anthropic
571
577
  // reject the request. See `modelHasExtendedThinking` for the allowlist.
572
578
  if (modelHasExtendedThinking(request.model)) {
579
+ // Anthropic requires 1024 <= budget_tokens < max_tokens. The old
580
+ // `Math.min(maxOut, 16_384)` violated both ends: any caller with
581
+ // max_tokens <= 16_384 got budget_tokens == max_tokens (400 "max_tokens
582
+ // must be greater than thinking.budget_tokens"), and a caller under
583
+ // 1024 got a sub-minimum budget (400 on the floor instead). That hit
584
+ // real paths, not just edge cases — compaction tiers Opus sessions down
585
+ // to Sonnet 4.6 and asks for exactly 16_000, so summarizing a long Opus
586
+ // session failed outright. Reserve a quarter of the ceiling (min 1024)
587
+ // for the visible answer, and skip the block entirely when there isn't
588
+ // room for a legal budget — no thinking beats a rejected request.
573
589
  const maxOut = (request.max_tokens ?? 16_384);
574
- requestPayload['thinking'] = {
575
- type: 'enabled',
576
- budget_tokens: Math.min(maxOut, 16_384), // Cap thinking budget — most benefit comes from first few K tokens
577
- };
578
- // Extended thinking requires temperature=1 on Anthropic API
579
- requestPayload['temperature'] = 1;
590
+ const budgetTokens = Math.min(16_384, Math.floor(maxOut * 0.75));
591
+ if (budgetTokens >= 1024) {
592
+ requestPayload['thinking'] = {
593
+ type: 'enabled',
594
+ budget_tokens: budgetTokens, // Cap thinking budget — most benefit comes from first few K tokens
595
+ };
596
+ // Extended thinking requires temperature=1 on Anthropic API
597
+ requestPayload['temperature'] = 1;
598
+ }
580
599
  }
581
600
  // ─ Anthropic prompt caching: budgeted breakpoints ───────────────────
582
601
  // Anthropic permits at most 4 cache_control breakpoints, counted across
@@ -27,6 +27,7 @@ const MODEL_MAX_OUTPUT = {
27
27
  // 128k unlocks the full headroom — runaway generations are gated
28
28
  // separately by CAPPED_MAX_TOKENS / ESCALATED_MAX_TOKENS budgets.
29
29
  'anthropic/claude-fable-5': 128_000,
30
+ 'anthropic/claude-opus-5': 128_000,
30
31
  'anthropic/claude-opus-4.8': 128_000,
31
32
  'anthropic/claude-opus-4.7': 128_000,
32
33
  'anthropic/claude-opus-4.6': 32_000,
@@ -192,13 +192,14 @@ export function estimateHistoryTokens(history) {
192
192
  */
193
193
  const MODEL_CONTEXT_WINDOWS = {
194
194
  // Anthropic. The BlockRun gateway model entry advertises 1M context for
195
- // Opus 4.8 / 4.7, but the 1M beta header may not be enabled at the gateway
195
+ // Opus 5 / 4.8 / 4.7, but the 1M beta header may not be enabled at the gateway
196
196
  // edge yet — sending more than 200k without it 413s. Keep 200k as the
197
197
  // safe Franklin baseline; bump to 1_000_000 in a separate commit once
198
198
  // a real >200k call has been verified end-to-end.
199
199
  // Fable 5 / Sonnet 5 advertise 1M at the gateway; keep the 200k safe baseline
200
200
  // (same rationale as Opus above) until a real >200k call is verified.
201
201
  'anthropic/claude-fable-5': 200_000,
202
+ 'anthropic/claude-opus-5': 200_000,
202
203
  'anthropic/claude-opus-4.8': 200_000,
203
204
  'anthropic/claude-opus-4.7': 200_000,
204
205
  'anthropic/claude-opus-4.6': 200_000,
@@ -1,4 +1,4 @@
1
- declare const VALID_KEYS: readonly ["default-model", "sonnet-model", "opus-model", "haiku-model", "smart-routing", "permission-mode", "max-turns", "auto-compact", "cost-saver", "session-save", "debug", "zerox-api-key", "base-rpc-url"];
1
+ declare const VALID_KEYS: readonly ['default-model', 'sonnet-model', 'opus-model', 'haiku-model', 'smart-routing', 'permission-mode', 'max-turns', 'auto-compact', 'cost-saver', 'session-save', 'debug', 'zerox-api-key', 'base-rpc-url'];
2
2
  type ConfigKey = (typeof VALID_KEYS)[number];
3
3
  export interface AppConfig {
4
4
  'default-model'?: string;
@@ -29,7 +29,7 @@ export async function initCommand(options) {
29
29
  ANTHROPIC_AUTH_TOKEN: 'x402-proxy-handles-auth',
30
30
  ANTHROPIC_MODEL: 'blockrun/auto',
31
31
  ANTHROPIC_DEFAULT_SONNET_MODEL: 'anthropic/claude-sonnet-4.6',
32
- ANTHROPIC_DEFAULT_OPUS_MODEL: 'anthropic/claude-opus-4.8',
32
+ ANTHROPIC_DEFAULT_OPUS_MODEL: 'anthropic/claude-opus-5',
33
33
  ANTHROPIC_DEFAULT_HAIKU_MODEL: 'anthropic/claude-haiku-4.5',
34
34
  };
35
35
  fs.mkdirSync(path.dirname(CLAUDE_SETTINGS_FILE), { recursive: true });
@@ -11,7 +11,7 @@
11
11
  * tool-call trace (what it searched and what it found), the terminal reason and
12
12
  * token usage. Human-readable streaming otherwise.
13
13
  *
14
- * franklin predict --model anthropic/claude-opus-4.8 \
14
+ * franklin predict --model anthropic/claude-opus-5 \
15
15
  * --question "Who wins the 2026 FIFA World Cup? Pick one country." --json
16
16
  */
17
17
  import { interactiveSession } from '../agent/loop.js';
package/dist/index.js CHANGED
@@ -73,7 +73,7 @@ program
73
73
  program
74
74
  .command('predict')
75
75
  .description('Prediction mode — forecast one real-world event with a research-only toolset (web/markets), headless')
76
- .requiredOption('-m, --model <model>', 'Model to use (e.g. anthropic/claude-opus-4.8, openai/gpt-5.5)')
76
+ .requiredOption('-m, --model <model>', 'Model to use (e.g. anthropic/claude-opus-5, openai/gpt-5.5)')
77
77
  .requiredOption('-q, --question <text>', 'The event question to forecast (include the allowed options)')
78
78
  .option('--max-turns <n>', 'Max agent turns before forcing an answer', '8')
79
79
  .option('--max-tool-calls <n>', 'Max tool calls before forcing an answer', '6')
@@ -31,6 +31,19 @@ function userEnabled() {
31
31
  * isn't installed / resolvable. The shim is plain JS runnable by any node.
32
32
  */
33
33
  export function resolveCodegraphShim() {
34
+ // CodeGraph 1.x added an `exports` map that no longer lists ./npm-shim.js,
35
+ // so resolving that subpath directly throws ERR_PACKAGE_PATH_NOT_EXPORTED
36
+ // even though the file still ships (it's the package's `bin`). `./package.json`
37
+ // stays exported, so resolve the manifest and walk to the shim beside it.
38
+ try {
39
+ const manifest = require.resolve('@colbymchenry/codegraph/package.json');
40
+ const shim = path.join(path.dirname(manifest), 'npm-shim.js');
41
+ if (fs.existsSync(shim))
42
+ return shim;
43
+ }
44
+ catch {
45
+ /* fall through to the pre-1.x subpath resolve */
46
+ }
34
47
  try {
35
48
  const shim = require.resolve('@colbymchenry/codegraph/npm-shim.js');
36
49
  return fs.existsSync(shim) ? shim : null;
package/dist/pricing.js CHANGED
@@ -37,6 +37,9 @@ export const MODEL_PRICING = {
37
37
  'nvidia/nemotron-super-49b': { input: 0, output: 0 },
38
38
  // Anthropic
39
39
  'anthropic/claude-fable-5': { input: 10.0, output: 50.0 }, // Mythos-class tier above Opus, 1M ctx
40
+ // Opus 5 lands at the same $5/$25 as the 4.x Opus line — a straight upgrade
41
+ // with no cost delta, so nothing downstream needs a pricing carve-out.
42
+ 'anthropic/claude-opus-5': { input: 5.0, output: 25.0 },
40
43
  'anthropic/claude-opus-4.8': { input: 5.0, output: 25.0 },
41
44
  'anthropic/claude-opus-4.7': { input: 5.0, output: 25.0 },
42
45
  'anthropic/claude-opus-4.6': { input: 5.0, output: 25.0 },
@@ -125,7 +128,7 @@ export const MODEL_PRICING = {
125
128
  'zai/glm-5.1-turbo': { input: 1.2, output: 4.0 }, // client alias for zai/glm-5-turbo
126
129
  };
127
130
  /** Opus pricing for savings calculations — tracks the current flagship. */
128
- export const OPUS_PRICING = MODEL_PRICING['anthropic/claude-opus-4.8'];
131
+ export const OPUS_PRICING = MODEL_PRICING['anthropic/claude-opus-5'];
129
132
  /**
130
133
  * Estimate cost in USD for a request.
131
134
  * Falls back to $2/$10 per 1M for unknown models.
@@ -58,16 +58,17 @@ const AUTO_TIERS = {
58
58
  // Hard tasks — multi-file refactors, ambiguous specs, dense reasoning
59
59
  // chains — still go to Opus. V4 Pro is great but not a Sonnet/Opus
60
60
  // replacement at the high end of difficulty per recent agent-bench runs.
61
- primary: 'anthropic/claude-opus-4.8',
62
- fallback: ['anthropic/claude-opus-4.7', 'openai/gpt-5.5', 'anthropic/claude-sonnet-4.6', 'deepseek/deepseek-v4-pro'],
61
+ primary: 'anthropic/claude-opus-5',
62
+ fallback: ['anthropic/claude-opus-4.8', 'openai/gpt-5.5', 'anthropic/claude-sonnet-4.6', 'deepseek/deepseek-v4-pro'],
63
63
  },
64
64
  REASONING: {
65
- // Opus 4.8: latest flagship, most capable for agentic coding. 4.7 and 4.6
66
- // stay in the fallback chain in case of rollout delays.
67
- primary: 'anthropic/claude-opus-4.8',
65
+ // Opus 5: latest flagship, most capable for agentic coding, same $5/$25 as
66
+ // the 4.x Opus line. 4.8 and 4.7 stay in the fallback chain in case of
67
+ // rollout delays.
68
+ primary: 'anthropic/claude-opus-5',
68
69
  fallback: [
70
+ 'anthropic/claude-opus-4.8',
69
71
  'anthropic/claude-opus-4.7',
70
- 'anthropic/claude-opus-4.6',
71
72
  'openai/o3',
72
73
  'deepseek/deepseek-v4-pro',
73
74
  'xai/grok-4-1-fast-reasoning',
@@ -21,6 +21,7 @@
21
21
  const VISION_MODELS = new Set([
22
22
  // Anthropic — native vision across the line
23
23
  'anthropic/claude-fable-5',
24
+ 'anthropic/claude-opus-5',
24
25
  'anthropic/claude-opus-4.8',
25
26
  'anthropic/claude-opus-4.7',
26
27
  'anthropic/claude-opus-4.6',
@@ -19,7 +19,9 @@
19
19
  import http from 'node:http';
20
20
  import fs from 'node:fs';
21
21
  import path from 'node:path';
22
- import WebSocket from 'ws';
22
+ // `ws` 8 moved the server class off the default export onto a named one. The
23
+ // default import stays for the `WebSocket` type and its `OPEN` constant.
24
+ import WebSocket, { WebSocketServer } from 'ws';
23
25
  import { loadChain, API_URLS, BLOCKRUN_DIR } from '../config.js';
24
26
  import { loadConfig, setConfigValue } from '../commands/config.js';
25
27
  import { assembleInstructions } from '../agent/context.js';
@@ -890,7 +892,7 @@ export async function startServer(opts) {
890
892
  res.writeHead(404);
891
893
  res.end();
892
894
  });
893
- const wss = new WebSocket.Server({
895
+ const wss = new WebSocketServer({
894
896
  server: httpServer,
895
897
  path: '/agent',
896
898
  // Same gate as /file: refuse upgrades from non-allowlisted browser origins
@@ -125,8 +125,11 @@ async function execute(input, ctx) {
125
125
  let normalizeNote = '';
126
126
  if (stat.size > SKIP_BELOW_BYTES) {
127
127
  try {
128
- const sharpMod = await import('sharp');
129
- const sharp = sharpMod.default;
128
+ // sharp 0.35 ships proper ESM types: the default export is the
129
+ // constructor itself, so the old cast (which claimed `default` was
130
+ // the whole module namespace) no longer type-checks. Runtime shape
131
+ // is unchanged — `.default` was always the callable.
132
+ const { default: sharp } = await import('sharp');
130
133
  const img = sharp(rawBytes, { failOn: 'none' });
131
134
  const meta = await img.metadata();
132
135
  const longEdge = Math.max(meta.width ?? 0, meta.height ?? 0);
package/dist/ui/app.js CHANGED
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  /**
3
3
  * RunCode ink-based terminal UI.
4
4
  * Real-time streaming, thinking animation, tool progress, slash commands.
@@ -182,8 +182,9 @@ async function shrinkImageInPlace(filePath) {
182
182
  try {
183
183
  const before = fs.statSync(filePath).size;
184
184
  const raw = fs.readFileSync(filePath);
185
- const sharpMod = await import('sharp');
186
- const sharp = sharpMod.default;
185
+ // See the note in src/tools/read.ts: sharp 0.35's default export is the
186
+ // constructor, so the old namespace cast no longer type-checks.
187
+ const { default: sharp } = await import('sharp');
187
188
  const meta = await sharp(raw, { failOn: 'none' }).metadata();
188
189
  let hasAlpha = false;
189
190
  if (meta.hasAlpha) {
@@ -20,11 +20,12 @@ export const MODEL_SHORTCUTS = {
20
20
  fable: 'anthropic/claude-fable-5',
21
21
  'fable-5': 'anthropic/claude-fable-5',
22
22
  sonnet: 'anthropic/claude-sonnet-5',
23
- claude: 'anthropic/claude-opus-4.8',
23
+ claude: 'anthropic/claude-opus-5',
24
24
  'sonnet-5': 'anthropic/claude-sonnet-5',
25
25
  'sonnet-4.6': 'anthropic/claude-sonnet-4.6',
26
26
  'sonnet-4.5': 'anthropic/claude-sonnet-4.5',
27
- opus: 'anthropic/claude-opus-4.8',
27
+ opus: 'anthropic/claude-opus-5',
28
+ 'opus-5': 'anthropic/claude-opus-5',
28
29
  'opus-4.8': 'anthropic/claude-opus-4.8',
29
30
  'opus-4.7': 'anthropic/claude-opus-4.7',
30
31
  'opus-4.6': 'anthropic/claude-opus-4.6',
@@ -259,7 +260,10 @@ export const PICKER_CATEGORIES = [
259
260
  category: '✨ Premium frontier',
260
261
  models: [
261
262
  { id: 'anthropic/claude-fable-5', shortcut: 'fable', label: 'Claude Fable 5', price: '$10/$50' },
262
- { id: 'anthropic/claude-opus-4.8', shortcut: 'opus', label: 'Claude Opus 4.8', price: '$5/$25', highlight: true },
263
+ // Opus 5 supersedes 4.8 at the same $5/$25 — 4.8 drops out of the visible
264
+ // list (its `opus-4.8` shortcut stays live) rather than sitting next to a
265
+ // strictly-better entry at an identical price.
266
+ { id: 'anthropic/claude-opus-5', shortcut: 'opus', label: 'Claude Opus 5', price: '$5/$25', highlight: true },
263
267
  { id: 'anthropic/claude-sonnet-5', shortcut: 'sonnet', label: 'Claude Sonnet 5', price: '$3/$15' },
264
268
  { id: 'qwen/qwen3.7-max', shortcut: 'qwen-max', label: 'Qwen3.7 Max', price: '$1.475/$4.425', highlight: true },
265
269
  { id: 'openai/gpt-5.6-sol', shortcut: 'gpt', label: 'GPT-5.6 Sol', price: '$5/$30', highlight: true },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blockrun/franklin",
3
- "version": "3.35.6",
3
+ "version": "3.37.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": {
@@ -67,33 +67,37 @@
67
67
  },
68
68
  "dependencies": {
69
69
  "@blockrun/llm": "^3.5.2",
70
- "@colbymchenry/codegraph": "0.9.7",
70
+ "@colbymchenry/codegraph": "^1.5.0",
71
71
  "@modelcontextprotocol/sdk": "^1.29.0",
72
72
  "@polymarket/builder-relayer-client": "^0.0.10",
73
73
  "@polymarket/builder-signing-sdk": "0.0.8",
74
74
  "@polymarket/clob-client-v2": "1.0.8",
75
- "@slack/bolt": "^4.7.3",
75
+ "@slack/bolt": "^5.0.0",
76
76
  "@solana/spl-token": "^0.4.14",
77
77
  "@solana/web3.js": "^1.98.4",
78
78
  "@types/react": "^19.2.14",
79
79
  "axios": "^1.18.1",
80
80
  "bs58": "^6.0.0",
81
81
  "chalk": "^5.4.0",
82
- "commander": "^13.0.0",
82
+ "commander": "^15.0.0",
83
83
  "https-proxy-agent": "^9.1.0",
84
- "ink": "^6.8.0",
84
+ "ink": "^7.1.1",
85
85
  "ink-spinner": "^5.0.0",
86
86
  "ink-text-input": "^6.0.0",
87
87
  "playwright-core": "^1.49.1",
88
88
  "qrcode": "^1.5.4",
89
89
  "react": "^19.2.4",
90
- "sharp": "^0.34.5",
91
- "viem": "^2.48.1"
90
+ "sharp": "^0.35.3",
91
+ "viem": "^2.48.1",
92
+ "ws": "^8.21.1"
92
93
  },
93
94
  "devDependencies": {
94
- "@types/node": "^22.0.0",
95
+ "@types/node": "^26.1.1",
95
96
  "@types/qrcode": "^1.5.6",
96
- "@types/ws": "^7.4.7",
97
- "typescript": "^5.7.0"
97
+ "@types/ws": "^8.18.1",
98
+ "typescript": "^7.0.2"
99
+ },
100
+ "overrides": {
101
+ "ws@>=8.0.0 <=8.20.1": "^8.21.1"
98
102
  }
99
103
  }