@blockrun/franklin 3.34.1 → 3.34.3

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.
@@ -1331,6 +1331,7 @@ export async function interactiveSession(config, getUserInput, onEvent, onAbortR
1331
1331
  abortSignal: abort.signal,
1332
1332
  onAskUser: config.onAskUser,
1333
1333
  onApproval: config.approvalPromptFn,
1334
+ sessionId,
1334
1335
  parentContext: {
1335
1336
  goal: lastUserInput?.slice(0, 200),
1336
1337
  recentFiles: [...readFileCache].slice(-10),
@@ -1604,11 +1605,12 @@ export async function interactiveSession(config, getUserInput, onEvent, onAbortR
1604
1605
  .join('\n');
1605
1606
  if (looksLikeStalledIntent(tailText)) {
1606
1607
  // Tool-use-strong fallbacks. Ordered cheap → premium so a free
1607
- // tier still gets a Kimi/Haiku attempt before paying for GPT-5.
1608
+ // tier still gets a Haiku attempt before paying for GPT-5.
1608
1609
  // Excludes nvidia/* and *-coder-* — they're the source population.
1610
+ // (Kimi dropped 2026-07: retired K2.x, and K3 is premium-priced —
1611
+ // Haiku already fills the cheap tool-use slot here.)
1609
1612
  const TOOL_USE_FALLBACK_MODELS = [
1610
1613
  'anthropic/claude-haiku-4.5',
1611
- 'moonshot/kimi-k2.7',
1612
1614
  'openai/gpt-5.4',
1613
1615
  'anthropic/claude-sonnet-4.6',
1614
1616
  ];
@@ -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,
@@ -94,6 +94,14 @@ export interface ExecutionScope {
94
94
  * anything that requires an explicit decision.
95
95
  */
96
96
  onApproval?: import('./approvals.js').ApprovalPromptFn;
97
+ /**
98
+ * The executing session's id. Threaded so session-scoped tools (TradePlan)
99
+ * bind to THIS session rather than a process-global slot — required for
100
+ * correctness when one serve process hosts multiple concurrent agents
101
+ * (AgentHost). Absent in older/library callers; tools fall back to the
102
+ * module-global session then.
103
+ */
104
+ sessionId?: string;
97
105
  /** Context from parent agent — helps sub-agents avoid duplicate work */
98
106
  parentContext?: {
99
107
  goal?: string;
@@ -36,8 +36,17 @@ export function globalMemoryPath() {
36
36
  function slugify(text) {
37
37
  return text.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 32) || 'workspace';
38
38
  }
39
+ // Memoized per workDir: repoIdentity is called several times per memory
40
+ // search (workspaceMemoryPath + sessionLogsDir + workspaceDir), and each call
41
+ // otherwise spawns `git remote get-url origin`. The origin remote doesn't
42
+ // change within a session, so cache it. `null` (not a repo) is cached too.
43
+ const repoIdentityCache = new Map();
39
44
  /** org/repo from the git origin remote, or null outside a repo. */
40
45
  export function repoIdentity(workDir) {
46
+ const cached = repoIdentityCache.get(workDir);
47
+ if (cached !== undefined)
48
+ return cached;
49
+ let identity = null;
41
50
  try {
42
51
  const url = execFileSync('git', ['-C', workDir, 'remote', 'get-url', 'origin'], {
43
52
  encoding: 'utf-8',
@@ -45,11 +54,13 @@ export function repoIdentity(workDir) {
45
54
  stdio: ['ignore', 'pipe', 'ignore'],
46
55
  }).trim();
47
56
  const m = url.match(/[:/]([^/:]+\/[^/]+?)(?:\.git)?$/);
48
- return m ? m[1] : url || null;
57
+ identity = m ? m[1] : url || null;
49
58
  }
50
59
  catch {
51
- return null;
60
+ identity = null;
52
61
  }
62
+ repoIdentityCache.set(workDir, identity);
63
+ return identity;
53
64
  }
54
65
  export function workspaceKey(workDir) {
55
66
  const identity = repoIdentity(workDir) ?? workDir;
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"
@@ -52,7 +52,10 @@ export function createTradePlanCapability() {
52
52
  concurrent: false,
53
53
  execute: async (input, ctx) => {
54
54
  const action = String(input.action || '');
55
- const sessionId = getSchedulerSessionId();
55
+ // Bind to THIS session (threaded via the execution scope) so concurrent
56
+ // hosted agents each propose/query under their own id. Falls back to the
57
+ // process-global slot for callers that don't populate the scope.
58
+ const sessionId = ctx.sessionId ?? getSchedulerSessionId();
56
59
  if (action === 'status') {
57
60
  const active = activeTradePlan(sessionId);
58
61
  if (active) {
@@ -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.1",
3
+ "version": "3.34.3",
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": {