@blockrun/franklin 3.29.1 → 3.29.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.
- package/README.md +4 -0
- package/dist/agent/context.js +1 -1
- package/dist/agent/llm.js +12 -2
- package/dist/agent/loop.js +10 -2
- package/dist/agent/repair/scavenge.js +42 -9
- package/dist/agent/tokens.js +1 -0
- package/dist/pricing.js +1 -0
- package/dist/proxy/server.js +5 -2
- package/dist/ui/model-picker.js +11 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -500,6 +500,10 @@ Same wallet. Same tools. From your phone.
|
|
|
500
500
|
|
|
501
501
|
## Documentation
|
|
502
502
|
|
|
503
|
+
Full BlockRun docs: **https://blockrun.ai/docs**
|
|
504
|
+
|
|
505
|
+
- [Agent developer guide](https://blockrun.ai/docs/getting-started/agent-developers) — building agents on BlockRun
|
|
506
|
+
- [Models, SDKs & APIs](https://blockrun.ai/docs) — the full gateway reference
|
|
503
507
|
- [Plugin SDK guide](docs/plugin-sdk.md) — build your own workflow vertical
|
|
504
508
|
- [Changelog](CHANGELOG.md) — every release explained
|
|
505
509
|
- [Roadmap](docs/ROADMAP.md) — what's coming next
|
package/dist/agent/context.js
CHANGED
|
@@ -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 as of 2026-06: \`anthropic/claude-sonnet-4.6\`, \`anthropic/claude-opus-4.8\`, \`deepseek/deepseek-v4-pro\`, \`zai/glm-5.
|
|
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 as of 2026-06: \`anthropic/claude-sonnet-4.6\`, \`anthropic/claude-opus-4.8\`, \`deepseek/deepseek-v4-pro\`, \`zai/glm-5.2\`, \`nvidia/llama-4-maverick\`, \`openai/gpt-5-nano\`). 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
|
@@ -949,9 +949,16 @@ export class ModelClient {
|
|
|
949
949
|
}
|
|
950
950
|
if (currentText) {
|
|
951
951
|
if (textEmission.mode === 'hold' && isRoleplayedJsonToolCallText(currentText)) {
|
|
952
|
+
// A roleplayed JSON tool call. Do NOT stream it to the UI,
|
|
953
|
+
// but DO keep it in `collected` so the loop's scavenge pass
|
|
954
|
+
// (src/agent/repair/scavenge.ts) can turn it into a real
|
|
955
|
+
// tool_use and execute it. If scavenge can't recover a valid
|
|
956
|
+
// call, the loop strips this text, restoring the old
|
|
957
|
+
// "non-productive → switch model" recovery.
|
|
958
|
+
collected.push({ type: 'text', text: currentText });
|
|
952
959
|
if (this.debug) {
|
|
953
960
|
console.error(`[franklin] Model ${request.model} emitted a raw JSON function-call object as text. ` +
|
|
954
|
-
'
|
|
961
|
+
'Held from display; loop will scavenge it into a tool_use or strip it.');
|
|
955
962
|
}
|
|
956
963
|
}
|
|
957
964
|
else if (textEmission.mode === 'hold' && isNemotronProse) {
|
|
@@ -1038,9 +1045,12 @@ export class ModelClient {
|
|
|
1038
1045
|
}
|
|
1039
1046
|
if (currentText) {
|
|
1040
1047
|
if (textEmission.mode === 'hold' && isRoleplayedJsonToolCallText(currentText)) {
|
|
1048
|
+
// See the matching branch in content_block_stop: keep it for the
|
|
1049
|
+
// loop's scavenge pass instead of dropping it.
|
|
1050
|
+
collected.push({ type: 'text', text: currentText });
|
|
1041
1051
|
if (this.debug) {
|
|
1042
1052
|
console.error(`[franklin] Model ${request.model} emitted a raw JSON function-call object as text. ` +
|
|
1043
|
-
'
|
|
1053
|
+
'Held from display; loop will scavenge it into a tool_use or strip it.');
|
|
1044
1054
|
}
|
|
1045
1055
|
}
|
|
1046
1056
|
else if (textEmission.mode === 'hold' && isNemotronProse) {
|
package/dist/agent/loop.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Franklin Agent Loop
|
|
3
3
|
* The core reasoning-action cycle: prompt → model → extract capabilities → execute → repeat.
|
|
4
4
|
*/
|
|
5
|
-
import { ModelClient } from './llm.js';
|
|
5
|
+
import { ModelClient, isRoleplayedJsonToolCallText } from './llm.js';
|
|
6
6
|
import { autoCompactIfNeeded, forceCompact, microCompact, projectCompactionSavings } from './compact.js';
|
|
7
7
|
import { estimateHistoryTokens, updateActualTokens, resetTokenAnchor, getAnchoredTokenCount, getContextWindow, setEstimationModel } from './tokens.js';
|
|
8
8
|
import { handleSlashCommand } from './commands.js';
|
|
@@ -1368,6 +1368,14 @@ export async function interactiveSession(config, getUserInput, onEvent, onAbortR
|
|
|
1368
1368
|
responseParts = [...responseParts, ...novelCalls];
|
|
1369
1369
|
logger.warn(`[franklin] scavenged ${repaired.report.scavenged} leaked tool call(s) from ${config.model}: ${repaired.report.notes.join('; ')}`);
|
|
1370
1370
|
}
|
|
1371
|
+
// Strip pure roleplayed-JSON tool-call text parts. The LLM client
|
|
1372
|
+
// holds these out of the live stream (never shown) but keeps them
|
|
1373
|
+
// in `content` so the scavenge above can recover the call. Whether
|
|
1374
|
+
// or not a call was recovered, the raw JSON must not linger as the
|
|
1375
|
+
// assistant's "answer" — drop it. When nothing was scavenged this
|
|
1376
|
+
// also empties the turn, so the empty-response recovery below can
|
|
1377
|
+
// switch models, preserving the prior behavior.
|
|
1378
|
+
responseParts = responseParts.filter(p => !(p.type === 'text' && isRoleplayedJsonToolCallText(p.text)));
|
|
1371
1379
|
}
|
|
1372
1380
|
// ── Empty response recovery ──
|
|
1373
1381
|
// If the model returns nothing, DON'T just retry the same model with the same input.
|
|
@@ -1376,7 +1384,7 @@ export async function interactiveSession(config, getUserInput, onEvent, onAbortR
|
|
|
1376
1384
|
const hasTools = responseParts.some(p => p.type === 'tool_use');
|
|
1377
1385
|
const hasThinking = responseParts.some(p => p.type === 'thinking');
|
|
1378
1386
|
if (!hasText && !hasTools && !hasThinking) {
|
|
1379
|
-
const EMPTY_FALLBACK_MODELS = ['nvidia/llama-4-maverick', 'nvidia/deepseek-v4-flash', 'zai/glm-5.
|
|
1387
|
+
const EMPTY_FALLBACK_MODELS = ['nvidia/llama-4-maverick', 'nvidia/deepseek-v4-flash', 'zai/glm-5.2'];
|
|
1380
1388
|
const nextModel = EMPTY_FALLBACK_MODELS.find(m => m !== config.model && !turnFailedModels.has(m));
|
|
1381
1389
|
if (nextModel && recoveryAttempts < 2) {
|
|
1382
1390
|
recoveryAttempts++;
|
|
@@ -50,8 +50,9 @@ export function scavengeToolCalls(text, opts) {
|
|
|
50
50
|
for (const candidate of iterateJsonObjects(nonDsml)) {
|
|
51
51
|
if (out.length >= max)
|
|
52
52
|
break;
|
|
53
|
-
const call
|
|
54
|
-
|
|
53
|
+
for (const call of coerceToInvocations(candidate, opts.allowedNames)) {
|
|
54
|
+
if (out.length >= max)
|
|
55
|
+
break;
|
|
55
56
|
out.push(call);
|
|
56
57
|
notes.push(`scavenged call: ${call.name}`);
|
|
57
58
|
}
|
|
@@ -134,17 +135,41 @@ function* iterateJsonObjects(text) {
|
|
|
134
135
|
}
|
|
135
136
|
}
|
|
136
137
|
}
|
|
137
|
-
function
|
|
138
|
+
function coerceToInvocations(candidateJson, allowedNames) {
|
|
138
139
|
let parsed;
|
|
139
140
|
try {
|
|
140
141
|
parsed = JSON.parse(candidateJson);
|
|
141
142
|
}
|
|
142
143
|
catch {
|
|
143
|
-
return
|
|
144
|
+
return [];
|
|
144
145
|
}
|
|
145
146
|
if (!parsed || typeof parsed !== 'object')
|
|
146
|
-
return
|
|
147
|
+
return [];
|
|
147
148
|
const obj = parsed;
|
|
149
|
+
// Envelope A — OpenAI assistant message { tool_calls: [ {...}, ... ] }.
|
|
150
|
+
// Gateway models that lack native tool-calling sometimes dump the whole
|
|
151
|
+
// assistant-message JSON into the text channel.
|
|
152
|
+
if (Array.isArray(obj.tool_calls)) {
|
|
153
|
+
const calls = [];
|
|
154
|
+
for (const tc of obj.tool_calls) {
|
|
155
|
+
const c = coerceObj(tc, allowedNames);
|
|
156
|
+
if (c)
|
|
157
|
+
calls.push(c);
|
|
158
|
+
}
|
|
159
|
+
return calls;
|
|
160
|
+
}
|
|
161
|
+
// Envelope B — legacy single { function_call: { name, arguments } }.
|
|
162
|
+
if (obj.function_call && typeof obj.function_call === 'object') {
|
|
163
|
+
const c = coerceObj({ type: 'function', function: obj.function_call }, allowedNames);
|
|
164
|
+
return c ? [c] : [];
|
|
165
|
+
}
|
|
166
|
+
const c = coerceObj(obj, allowedNames);
|
|
167
|
+
return c ? [c] : [];
|
|
168
|
+
}
|
|
169
|
+
function coerceObj(value, allowedNames) {
|
|
170
|
+
if (!value || typeof value !== 'object')
|
|
171
|
+
return null;
|
|
172
|
+
const obj = value;
|
|
148
173
|
// Pattern 1 — { name, arguments } (Anthropic-ish flat form) AND the flat
|
|
149
174
|
// OpenAI leak { type: "function", name, parameters } emitted by the free
|
|
150
175
|
// DeepSeek model — both carry the name at the top level. Args land under
|
|
@@ -188,10 +213,18 @@ function resolveAllowedName(name, allowedNames) {
|
|
|
188
213
|
return null;
|
|
189
214
|
if (allowedNames.has(name))
|
|
190
215
|
return name;
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
216
|
+
// Try the name as-is, then with any provider namespace stripped
|
|
217
|
+
// (`functions.web_search` / `tools.web_search` → `web_search`), which
|
|
218
|
+
// Gemini- and OpenAI-style function declarations sometimes prepend.
|
|
219
|
+
const candidates = [name];
|
|
220
|
+
if (name.includes('.'))
|
|
221
|
+
candidates.push(name.slice(name.lastIndexOf('.') + 1));
|
|
222
|
+
for (const candidate of candidates) {
|
|
223
|
+
const target = normalizeName(candidate);
|
|
224
|
+
for (const allowed of allowedNames) {
|
|
225
|
+
if (normalizeName(allowed) === target)
|
|
226
|
+
return allowed;
|
|
227
|
+
}
|
|
195
228
|
}
|
|
196
229
|
return null;
|
|
197
230
|
}
|
package/dist/agent/tokens.js
CHANGED
|
@@ -232,6 +232,7 @@ const MODEL_CONTEXT_WINDOWS = {
|
|
|
232
232
|
'xai/grok-4-0709': 131_072,
|
|
233
233
|
'xai/grok-4-1-fast-reasoning': 131_072,
|
|
234
234
|
// Others
|
|
235
|
+
'zai/glm-5.2': 1_000_000, // flagship bump 2026-06 — context jumped 200K → 1M
|
|
235
236
|
'zai/glm-5.1': 200_000,
|
|
236
237
|
'moonshot/kimi-k2.7': 256_000,
|
|
237
238
|
'moonshot/kimi-k2.6': 256_000,
|
package/dist/pricing.js
CHANGED
|
@@ -92,6 +92,7 @@ export const MODEL_PRICING = {
|
|
|
92
92
|
// PROMOTION (active ~2026-04): flat $0.001/call for all GLM models
|
|
93
93
|
'zai/glm-5': { input: 0.6, output: 1.92 }, // flat promo ended 2026-06-06 — per-token now
|
|
94
94
|
'zai/glm-5.1': { input: 1.40, output: 4.40 }, // launch promo ended 2026-06-05 — per-token now
|
|
95
|
+
'zai/glm-5.2': { input: 1.40, output: 4.40 }, // new flagship 2026-06 — 1M context, same per-token price as 5.1
|
|
95
96
|
'zai/glm-5-turbo': { input: 1.2, output: 4.0 }, // flat promo ended 2026-06-06 — per-token now
|
|
96
97
|
'zai/glm-5.1-turbo': { input: 1.2, output: 4.0 }, // client alias for zai/glm-5-turbo
|
|
97
98
|
};
|
package/dist/proxy/server.js
CHANGED
|
@@ -158,9 +158,12 @@ const MODEL_SHORTCUTS = {
|
|
|
158
158
|
'm3': 'minimax/minimax-m3',
|
|
159
159
|
'm2.7': 'minimax/minimax-m2.7',
|
|
160
160
|
// Others
|
|
161
|
-
glm: 'zai/glm-5.
|
|
161
|
+
glm: 'zai/glm-5.2',
|
|
162
|
+
'glm-5.2': 'zai/glm-5.2',
|
|
163
|
+
// glm-5.1 demoted to back-compat pin 2026-06 (flagship is 5.2) — still routes.
|
|
164
|
+
'glm-5.1': 'zai/glm-5.1',
|
|
162
165
|
'glm-turbo': 'zai/glm-5-turbo',
|
|
163
|
-
'glm5': 'zai/glm-5.
|
|
166
|
+
'glm5': 'zai/glm-5.2',
|
|
164
167
|
kimi: 'moonshot/kimi-k2.7',
|
|
165
168
|
'k2.7': 'moonshot/kimi-k2.7',
|
|
166
169
|
// K2.6 demoted 2026-06 (flagship is K2.7) but still routes — `k2.6` pins it.
|
package/dist/ui/model-picker.js
CHANGED
|
@@ -97,10 +97,14 @@ export const MODEL_SHORTCUTS = {
|
|
|
97
97
|
minimax: 'minimax/minimax-m3',
|
|
98
98
|
'm3': 'minimax/minimax-m3',
|
|
99
99
|
'm2.7': 'minimax/minimax-m2.7',
|
|
100
|
-
glm: 'zai/glm-5.
|
|
100
|
+
glm: 'zai/glm-5.2',
|
|
101
101
|
'glm-5': 'zai/glm-5',
|
|
102
|
+
'glm-5.2': 'zai/glm-5.2',
|
|
103
|
+
// GLM-5.1 demoted to a back-compat pin 2026-06 (flagship is 5.2) — still
|
|
104
|
+
// routes for anyone who wants the 200K-context build explicitly.
|
|
105
|
+
'glm-5.1': 'zai/glm-5.1',
|
|
102
106
|
'glm-turbo': 'zai/glm-5-turbo',
|
|
103
|
-
'glm5': 'zai/glm-5.
|
|
107
|
+
'glm5': 'zai/glm-5.2',
|
|
104
108
|
kimi: 'moonshot/kimi-k2.7',
|
|
105
109
|
'k2.7': 'moonshot/kimi-k2.7',
|
|
106
110
|
// K2.6 demoted 2026-06 (gateway flagship is K2.7) but still routes — the
|
|
@@ -169,6 +173,9 @@ export const PICKER_CATEGORIES = [
|
|
|
169
173
|
{ id: 'deepseek/deepseek-v4-pro', shortcut: 'deepseek-v4-pro', label: 'DeepSeek V4 Pro', price: '$0.435/$0.87', highlight: true },
|
|
170
174
|
{ id: 'deepseek/deepseek-reasoner', shortcut: 'r1', label: 'DeepSeek V4 Flash R.', price: '$0.2/$0.4' },
|
|
171
175
|
{ id: 'xai/grok-4-1-fast-reasoning', shortcut: 'grok-fast', label: 'Grok 4.1 Fast R.', price: '$0.2/$0.5' },
|
|
176
|
+
// GLM-5.2: Z.AI's new flagship — 1M context, top open-source on
|
|
177
|
+
// long-horizon coding. `glm`/`glm5` shortcuts pin it.
|
|
178
|
+
{ id: 'zai/glm-5.2', shortcut: 'glm', label: 'GLM-5.2', price: '$1.4/$4.4' },
|
|
172
179
|
],
|
|
173
180
|
},
|
|
174
181
|
{
|
|
@@ -181,7 +188,8 @@ export const PICKER_CATEGORIES = [
|
|
|
181
188
|
{ id: 'deepseek/deepseek-chat', shortcut: 'deepseek', label: 'DeepSeek V4 Flash Chat', price: '$0.2/$0.4' },
|
|
182
189
|
{ id: 'moonshot/kimi-k2.7', shortcut: 'kimi', label: 'Kimi K2.7', price: '$0.95/$4' },
|
|
183
190
|
// GLM flat-rate promos fully ended 2026-06-06 — whole family per-token
|
|
184
|
-
// now (glm-5 $0.60/$1.92; `glm` shortcut
|
|
191
|
+
// now (glm-5 $0.60/$1.92; `glm` shortcut pins flagship glm-5.2, listed
|
|
192
|
+
// in Reasoning above).
|
|
185
193
|
{ id: 'zai/glm-5', shortcut: 'glm-5', label: 'GLM-5', price: '$0.6/$1.92' },
|
|
186
194
|
// Minimax M2.7 hidden to make room for V4 Pro in Reasoning + V4 Flash
|
|
187
195
|
// (free) without exceeding the picker's 24-entry cap. Shortcut `minimax`
|
package/package.json
CHANGED