@blockrun/franklin 3.34.0 → 3.34.2

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.
@@ -1604,11 +1604,12 @@ export async function interactiveSession(config, getUserInput, onEvent, onAbortR
1604
1604
  .join('\n');
1605
1605
  if (looksLikeStalledIntent(tailText)) {
1606
1606
  // Tool-use-strong fallbacks. Ordered cheap → premium so a free
1607
- // tier still gets a Kimi/Haiku attempt before paying for GPT-5.
1607
+ // tier still gets a Haiku attempt before paying for GPT-5.
1608
1608
  // Excludes nvidia/* and *-coder-* — they're the source population.
1609
+ // (Kimi dropped 2026-07: retired K2.x, and K3 is premium-priced —
1610
+ // Haiku already fills the cheap tool-use slot here.)
1609
1611
  const TOOL_USE_FALLBACK_MODELS = [
1610
1612
  'anthropic/claude-haiku-4.5',
1611
- 'moonshot/kimi-k2.7',
1612
1613
  'openai/gpt-5.4',
1613
1614
  'anthropic/claude-sonnet-4.6',
1614
1615
  ];
@@ -50,10 +50,11 @@ const MODEL_MAX_OUTPUT = {
50
50
  'deepseek/deepseek-chat': 65_536,
51
51
  'deepseek/deepseek-reasoner': 65_536,
52
52
  'deepseek/deepseek-v4-pro': 65_536,
53
- // Kimi K2.7 (flagship) + K2.6 support 65K output per the BlockRun gateway
53
+ // Kimi K3 (flagship, 2026-07) supports 65K output per the BlockRun gateway
54
54
  // model entry (max_output: 65536). Without this entry the default 16K cap
55
55
  // left users with 4× headroom on the table for long-form coding outputs
56
56
  // and dashboard scaffolds the model can otherwise emit in a single response.
57
+ 'moonshot/kimi-k3': 65_536,
57
58
  'moonshot/kimi-k2.7': 65_536,
58
59
  'moonshot/kimi-k2.6': 65_536,
59
60
  };
@@ -249,6 +249,7 @@ const MODEL_CONTEXT_WINDOWS = {
249
249
  // Others
250
250
  'zai/glm-5.2': 1_000_000, // flagship bump 2026-06 — context jumped 200K → 1M
251
251
  'zai/glm-5.1': 200_000,
252
+ 'moonshot/kimi-k3': 1_048_576,
252
253
  'moonshot/kimi-k2.7': 256_000,
253
254
  'moonshot/kimi-k2.6': 256_000,
254
255
  'moonshot/kimi-k2.5': 128_000,
package/dist/pricing.js CHANGED
@@ -105,12 +105,14 @@ export const MODEL_PRICING = {
105
105
  'minimax/minimax-m3': { input: 0.3, output: 1.2 },
106
106
  'minimax/minimax-m2.7': { input: 0.3, output: 1.2 },
107
107
  'minimax/minimax-m2.5': { input: 0.3, output: 1.2 },
108
- // Moonshot — K2.7 is the gateway flagship (2026-06); K2.6 demoted but still
109
- // routes, kept for the `k2.6` pin + legacy session-cost records.
108
+ // Moonshot — K3 is the gateway flagship (2026-07): 2.8T open MoE, 1M
109
+ // context, multimodal (image+text), returns reasoning_content. Pricier
110
+ // than the K2.x line it replaced ($3/$15 vs K2.7's $0.95/$4).
111
+ 'moonshot/kimi-k3': { input: 3.0, output: 15.0 },
112
+ // Retired K2.x line (kept for legacy session-cost records; the gateway no
113
+ // longer serves these and the `kimi`/`k2.*` shortcuts now resolve to K3).
110
114
  'moonshot/kimi-k2.7': { input: 0.95, output: 4.0 },
111
115
  'moonshot/kimi-k2.6': { input: 0.95, output: 4.0 },
112
- // Retired (kept for legacy session-cost records; the gateway no longer
113
- // serves these and the picker shortcuts now resolve to the current flagship).
114
116
  'moonshot/kimi-k2.5': { input: 0.6, output: 3.0 },
115
117
  'nvidia/kimi-k2.5': { input: 0.55, output: 2.5 },
116
118
  // PROMOTION (active ~2026-04): flat $0.001/call for all GLM models
@@ -45,7 +45,10 @@ function loadLearnedWeights() {
45
45
  const AUTO_TIERS = {
46
46
  SIMPLE: {
47
47
  primary: 'deepseek/deepseek-v4-pro',
48
- fallback: ['google/gemini-2.5-flash', 'moonshot/kimi-k2.7', 'deepseek/deepseek-chat'],
48
+ // Cheap-tier fallbacks only. Kimi dropped here 2026-07: the K2.x line was
49
+ // retired and its replacement K3 is premium-priced ($3/$15) — it doesn't
50
+ // belong in a cost-saving fallback chain.
51
+ fallback: ['google/gemini-2.5-flash', 'deepseek/deepseek-chat'],
49
52
  },
50
53
  MEDIUM: {
51
54
  primary: 'deepseek/deepseek-v4-pro',
@@ -51,9 +51,10 @@ const VISION_MODELS = new Set([
51
51
  // xAI — only Grok 4 base supports vision; grok-4-1-fast-reasoning is text-only
52
52
  'xai/grok-4-0709',
53
53
  'xai/grok-3',
54
- // Moonshot — K2.7 (flagship) + K2.6 are multimodal (image + video input)
55
- 'moonshot/kimi-k2.7',
56
- 'moonshot/kimi-k2.6',
54
+ // Moonshot — K3 (flagship, 2026-07) is multimodal (image + text input);
55
+ // gateway catalog lists it under the "vision" category. Replaced the
56
+ // retired K2.7/K2.6 line.
57
+ 'moonshot/kimi-k3',
57
58
  // NVIDIA inference — Nemotron Nano VL is multimodal; deepseek/qwen-coder are
58
59
  // not. Llama 4 Maverick dropped 2026-07-14: it left the gateway catalog, and
59
60
  // listing it here contradicted routeRequest()'s own "maverick is text-only"
@@ -260,6 +260,11 @@ export async function startServer(opts) {
260
260
  // The socket + correlation id for the in-flight turn (single-window).
261
261
  let activeWs = null;
262
262
  let activeTurnId = null;
263
+ // Pending approval asks for the legacy desktop session (trade plans).
264
+ // Keyed by askId — the wire contract the desktop UI already declares
265
+ // (agent.permissionAsk / agent.permissionResponse with askId + decision).
266
+ let askSeq = 0;
267
+ const legacyAsks = new Map();
263
268
  // We sometimes inject helper commands (`/model …`, `/clear`) as their own
264
269
  // turns ahead of the real prompt. Each ends with its own turn_done — which
265
270
  // would emit agent.done and clear activeTurnId, killing the real prompt's
@@ -443,10 +448,38 @@ export async function startServer(opts) {
443
448
  capabilities,
444
449
  maxTurns: 100,
445
450
  workingDir: workDir,
446
- permissionMode: 'trust', // the desktop UI has no permission prompt yet
451
+ permissionMode: 'trust', // tools auto-run; money still gates via approvalPromptFn below
447
452
  debug: !!debug,
448
453
  showPrefetchStatus: false,
449
454
  costSaver,
455
+ // Structured approvals (trade plans): surfaced to the desktop over the
456
+ // in-flight turn stream as agent.permissionAsk; the UI answers with
457
+ // agent.permissionResponse {askId, decision}. Without a connected
458
+ // client — or unanswered past the TTL — the approval fails closed,
459
+ // matching the trade-plan gate's deny-by-default posture.
460
+ approvalPromptFn: (req) => new Promise((resolve) => {
461
+ if (!activeWs || !activeTurnId) {
462
+ resolve({ choice: 'deny', message: 'no client connected to approve' });
463
+ return;
464
+ }
465
+ const askId = `ask_${++askSeq}_${Date.now().toString(36)}`;
466
+ const timer = setTimeout(() => {
467
+ if (legacyAsks.delete(askId)) {
468
+ resolve({ choice: 'deny', message: 'approval timed out' });
469
+ }
470
+ }, req.timeoutMs ?? 15 * 60 * 1000);
471
+ timer.unref?.();
472
+ legacyAsks.set(askId, (decision) => {
473
+ clearTimeout(timer);
474
+ resolve(decision);
475
+ });
476
+ emit('agent.permissionAsk', {
477
+ sessionId: '',
478
+ toolName: req.kind === 'trade-plan' ? 'TradePlan' : req.title,
479
+ description: `${req.title}\n\n${req.description}`,
480
+ askId,
481
+ });
482
+ }),
450
483
  };
451
484
  agentConfig = config;
452
485
  interactiveSession(config, getUserInput, onEvent, (abort) => { abortFn = abort; })
@@ -692,14 +725,35 @@ export async function startServer(opts) {
692
725
  abortFn();
693
726
  break;
694
727
  case 'agent.permissionResponse': {
695
- // Hosted agents: resolve the parked approval by (sessionId, requestId).
696
- // Legacy desktop path runs in trust mode — nothing to unblock there,
697
- // so a payload without ids stays a no-op (byte-compatible).
728
+ // Two resolution paths:
729
+ // - Hosted agents: (sessionId, requestId) → AgentHost broker.
730
+ // - Legacy desktop session: (askId, decision y/n/always) → the parked
731
+ // approvalPromptFn promise (trade-plan approvals).
732
+ // A payload with neither stays a no-op (byte-compatible with clients
733
+ // that predate both).
698
734
  const sid = p.sessionId ? String(p.sessionId) : '';
699
735
  const rid = p.requestId ? String(p.requestId) : '';
700
736
  if (sid && rid) {
701
737
  const ok = host.respond(sid, rid, String(p.choice ?? p.decision ?? 'no'), p.message ? String(p.message) : undefined);
702
738
  send(ws, id, 'response', { ok });
739
+ break;
740
+ }
741
+ const askId = p.askId ? String(p.askId) : '';
742
+ if (askId) {
743
+ const resolver = legacyAsks.get(askId);
744
+ if (resolver) {
745
+ legacyAsks.delete(askId);
746
+ const decision = String(p.decision ?? p.choice ?? 'n').toLowerCase();
747
+ const approve = decision === 'y' || decision === 'yes' || decision === 'always' || decision === 'approve';
748
+ resolver({
749
+ choice: approve ? 'approve' : 'deny',
750
+ message: p.message ? String(p.message) : undefined,
751
+ });
752
+ send(ws, id, 'response', { ok: true });
753
+ }
754
+ else {
755
+ send(ws, id, 'response', { ok: false });
756
+ }
703
757
  }
704
758
  break;
705
759
  }
@@ -141,15 +141,15 @@ export const MODEL_SHORTCUTS = {
141
141
  'glm-5.1': 'zai/glm-5.1',
142
142
  'glm-turbo': 'zai/glm-5-turbo',
143
143
  'glm5': 'zai/glm-5.2',
144
- kimi: 'moonshot/kimi-k2.7',
145
- 'k2.7': 'moonshot/kimi-k2.7',
146
- // K2.6 demoted 2026-06 (gateway flagship is K2.7) but still routes — the
147
- // `k2.6` pin keeps working for anyone who wants it explicitly.
148
- 'k2.6': 'moonshot/kimi-k2.6',
149
- // K2.5 was retired by the gateway. Aliases stay so muscle memory keeps
150
- // working but resolve to the current Kimi flagship (K2.7).
151
- 'kimi-k2.5': 'moonshot/kimi-k2.7',
152
- 'k2.5': 'moonshot/kimi-k2.7',
144
+ kimi: 'moonshot/kimi-k3',
145
+ k3: 'moonshot/kimi-k3',
146
+ // The K2.x line was retired by the gateway (2026-07, replaced by K3).
147
+ // These pins stay so muscle memory keeps working but resolve to the
148
+ // current Kimi flagship (K3).
149
+ 'k2.7': 'moonshot/kimi-k3',
150
+ 'k2.6': 'moonshot/kimi-k3',
151
+ 'kimi-k2.5': 'moonshot/kimi-k3',
152
+ 'k2.5': 'moonshot/kimi-k3',
153
153
  };
154
154
  /**
155
155
  * Resolve a model name — supports shortcuts. Returns the canonical model id.
@@ -237,6 +237,9 @@ export const PICKER_CATEGORIES = [
237
237
  { id: 'google/gemini-3.1-pro', shortcut: 'gemini-3', label: 'Gemini 3.1 Pro', price: '$2/$12' },
238
238
  { id: 'google/gemini-2.5-pro', shortcut: 'gemini', label: 'Gemini 2.5 Pro', price: '$1.25/$10' },
239
239
  { id: 'xai/grok-4.5', shortcut: 'grok', label: 'Grok 4.5', price: '$2.5/$9' },
240
+ // Kimi K3 (2026-07): 2.8T open MoE, 1M context, multimodal + reasoning.
241
+ // Replaced the budget K2.7 line — now premium-priced ($3/$15).
242
+ { id: 'moonshot/kimi-k3', shortcut: 'kimi', label: 'Kimi K3', price: '$3/$15' },
240
243
  ],
241
244
  },
242
245
  {
@@ -263,7 +266,6 @@ export const PICKER_CATEGORIES = [
263
266
  { id: 'google/gemini-2.5-flash', shortcut: 'flash', label: 'Gemini 2.5 Flash', price: '$0.3/$2.5' },
264
267
  // Re-aliased to V4 Flash Chat upstream — context 1M, price 30% lower.
265
268
  { id: 'deepseek/deepseek-chat', shortcut: 'deepseek', label: 'DeepSeek V4 Flash Chat', price: '$0.2/$0.4' },
266
- { id: 'moonshot/kimi-k2.7', shortcut: 'kimi', label: 'Kimi K2.7', price: '$0.95/$4' },
267
269
  // GLM flat-rate promos fully ended 2026-06-06 — whole family per-token
268
270
  // now (glm-5 $0.60/$1.92; `glm` shortcut pins flagship glm-5.2, listed
269
271
  // in Reasoning above).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blockrun/franklin",
3
- "version": "3.34.0",
3
+ "version": "3.34.2",
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": {