@blockrun/franklin 3.38.0 โ 3.39.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.
- package/README.md +8 -8
- package/dist/agent/compact.js +1 -1
- package/dist/agent/context.js +3 -3
- package/dist/agent/evaluator.js +1 -1
- package/dist/agent/llm.js +6 -6
- package/dist/agent/loop.js +25 -9
- package/dist/agent/tokens.js +17 -3
- package/dist/agent/turn-analyzer.js +6 -4
- package/dist/agent/verification.js +1 -1
- package/dist/commands/slack.js +1 -1
- package/dist/commands/social.js +1 -1
- package/dist/commands/telegram.js +1 -1
- package/dist/content/image-pricing.js +23 -0
- package/dist/content/library.d.ts +1 -1
- package/dist/gateway-models.d.ts +14 -4
- package/dist/gateway-models.js +18 -5
- package/dist/learnings/extractor.js +2 -2
- package/dist/plugin-sdk/workflow.d.ts +1 -1
- package/dist/plugin-sdk/workflow.js +2 -2
- package/dist/pricing.js +39 -19
- package/dist/proxy/fallback.js +1 -1
- package/dist/proxy/server.js +52 -5
- package/dist/router/index.d.ts +24 -5
- package/dist/router/index.js +100 -35
- package/dist/router/vision.js +5 -3
- package/dist/serve/server.js +4 -4
- package/dist/tools/content-execute.js +1 -1
- package/dist/tools/moa.js +3 -3
- package/dist/tools/prediction.d.ts +5 -2
- package/dist/tools/prediction.js +21 -44
- package/dist/tools/subagent.js +1 -1
- package/dist/tools/videogen.d.ts +4 -3
- package/dist/tools/videogen.js +9 -6
- package/dist/ui/model-picker.js +48 -39
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -257,7 +257,7 @@ Every tool call is itemized. Every token is priced. When the wallet hits zero, F
|
|
|
257
257
|
|
|
258
258
|
## Smart Router
|
|
259
259
|
|
|
260
|
-
|
|
260
|
+
**<!-- br:models.chatVisible -->71<!-- /br:models.chatVisible --> models. One decision. Zero guesswork.**
|
|
261
261
|
|
|
262
262
|
You don't pick models. Franklin picks for you.
|
|
263
263
|
|
|
@@ -316,7 +316,7 @@ You don't subscribe to electricity, you pay for what you use. Franklin brings th
|
|
|
316
316
|
|
|
317
317
|
### ๐ง Multi-model is the future
|
|
318
318
|
|
|
319
|
-
No single model is best at everything. Sonnet writes better code, Gemini handles longer context, DeepSeek costs 20x less for simple tasks. The Smart Router routes every request to the optimal model in <1ms โ
|
|
319
|
+
No single model is best at everything. Sonnet writes better code, Gemini handles longer context, DeepSeek costs 20x less for simple tasks. The Smart Router routes every request to the optimal model in <1ms โ <!-- br:savings.autoVsBaselinePct -->88<!-- /br:savings.autoVsBaselinePct -->% cheaper than pinning Claude Opus 5 for every request.
|
|
320
320
|
|
|
321
321
|
</td>
|
|
322
322
|
<td width="33%" valign="top">
|
|
@@ -338,7 +338,7 @@ No email. No phone. No KYC. Your Base or Solana address is your account โ port
|
|
|
338
338
|
| Writes code | โ
| โ
| โ ๏ธ | โ
|
|
|
339
339
|
| **Spends money for you** | โ | โ | โ | โ
**USDC wallet, x402** |
|
|
340
340
|
| **Buys data + APIs + images + search** | โ | โ | โ | โ
**55+ APIs, one wallet** |
|
|
341
|
-
| Picks best model per task | โ single-vendor | โ plan-tied | โ | โ
**Smart Router,
|
|
341
|
+
| Picks best model per task | โ single-vendor | โ plan-tied | โ | โ
**Smart Router, <!-- br:models.chatVisible -->71<!-- /br:models.chatVisible --> models** |
|
|
342
342
|
| Pricing model | Subscription | Subscription | Subscription | **YOPO** โ per outcome, USDC |
|
|
343
343
|
| Monthly fee | $20โ$200 | $20โ$40 | $20+ | **$0** |
|
|
344
344
|
| Rate-limited | Yes | Yes | Yes | No โ limited only by wallet |
|
|
@@ -366,14 +366,14 @@ Ask "what's BTC looking like?" โ Franklin fetches live price data, computes RS
|
|
|
366
366
|
**๐จ AI image generation**
|
|
367
367
|
Ask "generate a logo" โ Franklin calls DALL-E / GPT Image, saves the result locally, paid from your wallet.
|
|
368
368
|
|
|
369
|
-
**๐ง
|
|
369
|
+
**๐ง <!-- br:models.chatVisible -->71<!-- /br:models.chatVisible --> models via one wallet**
|
|
370
370
|
Anthropic, OpenAI, Google, xAI, DeepSeek, GLM, Kimi, Minimax, NVIDIA free tier. One wallet, one interface, automatic fallback.
|
|
371
371
|
|
|
372
372
|
**๐ณ x402 micropayments (YOPO)**
|
|
373
373
|
HTTP 402 native. Every paid action is a signed USDC micropayment via EIP-712 โ non-custodial, your keys never leave your machine. YOPO: you pay only for outcomes.
|
|
374
374
|
|
|
375
375
|
**๐ง Learned model router**
|
|
376
|
-
Trained on 2M+ real requests. Classifies your task and picks the best model from
|
|
376
|
+
Trained on 2M+ real requests. Classifies your task and picks the best model from <!-- br:models.chatVisible -->71<!-- /br:models.chatVisible --> LLMs. Four profiles (auto/eco/premium/free). Adapts to your usage over time.
|
|
377
377
|
|
|
378
378
|
</td>
|
|
379
379
|
<td width="50%" valign="top">
|
|
@@ -429,13 +429,13 @@ Core is workflow-agnostic. Add new verticals without touching the loop. Discover
|
|
|
429
429
|
โ Intent โ Smart Router โ Tool Use โ Spend Control โ Result โ
|
|
430
430
|
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
|
|
431
431
|
โ Learned Router โ
|
|
432
|
-
โ 2M+ requests ยท
|
|
432
|
+
โ 2M+ requests ยท <!-- br:models.chatVisible -->66<!-- /br:models.chatVisible --> models ยท category detection ยท Elo scores โ
|
|
433
433
|
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
|
|
434
434
|
โ Agent Loop โ
|
|
435
435
|
โ 16 tools ยท Sessions ยท Compaction ยท Pricing ยท Plugin SDK โ
|
|
436
436
|
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
|
|
437
437
|
โ BlockRun Gateway โ
|
|
438
|
-
โ
|
|
438
|
+
โ <!-- br:models.chatVisible -->66<!-- /br:models.chatVisible --> LLMs ยท CoinGecko ยท Search ยท Image APIs ยท paid services โ
|
|
439
439
|
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
|
|
440
440
|
โ x402 Micropayment Protocol โ
|
|
441
441
|
โ HTTP 402 ยท USDC on Base & Solana ยท signed payment payloads โ
|
|
@@ -479,7 +479,7 @@ src/
|
|
|
479
479
|
โโโ stats/ Usage tracking + insights engine
|
|
480
480
|
โโโ ui/ Ink-based terminal UI
|
|
481
481
|
โโโ proxy/ Payment proxy for external tools
|
|
482
|
-
โโโ router/ Learned model router (
|
|
482
|
+
โโโ router/ Learned model router (<!-- br:models.chatVisible -->66<!-- /br:models.chatVisible --> models, Elo scoring)
|
|
483
483
|
โโโ wallet/ Wallet management (Base + Solana)
|
|
484
484
|
โโโ mcp/ MCP server auto-discovery
|
|
485
485
|
โโโ commands/ CLI subcommands
|
package/dist/agent/compact.js
CHANGED
|
@@ -456,7 +456,7 @@ function formatCompactSummary(raw) {
|
|
|
456
456
|
function pickCompactionModel(primaryModel) {
|
|
457
457
|
// Free parent โ free compaction (no silent charge)
|
|
458
458
|
if (primaryModel.startsWith('nvidia/') || primaryModel === 'blockrun/free') {
|
|
459
|
-
return 'nvidia/
|
|
459
|
+
return 'nvidia/nemotron-nano-9b-v2';
|
|
460
460
|
}
|
|
461
461
|
// Use cheapest capable model for summarization to save cost
|
|
462
462
|
// Tier down: opus/pro โ sonnet, sonnet โ haiku, everything else โ flash (cheapest capable)
|
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, verified live 2026-
|
|
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-08-12: \`anthropic/claude-sonnet-5\`, \`anthropic/claude-opus-5\`, \`deepseek/deepseek-v4-pro\`, \`zai/glm-5.2\`, \`xai/grok-4.5\`, \`nvidia/nemotron-nano-9b-v2\` (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)**
|
|
@@ -411,10 +411,10 @@ Your training data is frozen in the past. Live-world questions MUST be answered
|
|
|
411
411
|
|
|
412
412
|
If you find yourself about to emit one of these, stop and call the tool instead. If you don't know which ticker the user means, call ExaSearch or AskUser โ never deflect.
|
|
413
413
|
|
|
414
|
-
**Prediction markets (PredictionMarket).** When the user asks about real-world odds โ elections, "will X happen by year-end", "Polymarket on Y", "Kalshi market for Z", "what are the odds of recession" โ use **PredictionMarket** instead of guessing.
|
|
414
|
+
**Prediction markets (PredictionMarket).** When the user asks about real-world odds โ elections, "will X happen by year-end", "Polymarket on Y", "Kalshi market for Z", "what are the odds of recession" โ use **PredictionMarket** instead of guessing. Nine actions, route by intent:
|
|
415
415
|
- "is there a market on X anywhere?" / unknown which platform โ \`searchAll\` (\$0.005) โ single call across Polymarket+Kalshi+Limitless+Opinion+Predict.Fun.
|
|
416
416
|
- "what are the odds on Polymarket / Kalshi specifically" โ \`searchPolymarket\` (\$0.001) and \`searchKalshi\` (\$0.001) **in parallel**; comparing implied probability across the two venues is the high-value answer.
|
|
417
|
-
- "where do Polymarket and Kalshi disagree / arbitrage" โ \`
|
|
417
|
+
- "where do Polymarket and Kalshi disagree / arbitrage" โ \`searchAll\` (\$0.005): its canonical containers span every venue, so one call surfaces the same market's odds side by side. (The old \`crossPlatform\` matched-pairs feed was discontinued upstream 2026-07-20.)
|
|
418
418
|
- "who's profitable / top traders / who should I follow on Polymarket" โ \`leaderboard\` (\$0.001) โ global top wallets by P&L.
|
|
419
419
|
- "analyze this wallet / can I copy this trader / show me their P&L AND positions" โ run \`walletProfile\` + \`walletPnl\` + \`walletPositions\` IN PARALLEL with the same address. Three \$0.005 calls = full picture for \$0.015. Do NOT \`Bash\`-curl \`data-api.polymarket.com\` directly โ those are paid Predexon endpoints and going around them defeats the wallet-attached architecture. If just the profile is needed: \`walletProfile\` alone (single address โ /wallet/{addr}, comma-list โ batch).
|
|
420
420
|
- "what are smart traders betting on right now / smart money flow across markets" โ \`smartActivity\` (\$0.005) โ markets where high-P&L wallets are positioning.
|
package/dist/agent/evaluator.js
CHANGED
|
@@ -249,7 +249,7 @@ export function parseGroundingResponse(raw) {
|
|
|
249
249
|
* choice so both quality gates have the same cost profile. Override via
|
|
250
250
|
* `FRANKLIN_EVALUATOR_MODEL` to experiment with accuracy/cost trade-offs. */
|
|
251
251
|
export function evaluatorModel() {
|
|
252
|
-
return process.env.FRANKLIN_EVALUATOR_MODEL || 'nvidia/
|
|
252
|
+
return process.env.FRANKLIN_EVALUATOR_MODEL || 'nvidia/nemotron-nano-9b-v2';
|
|
253
253
|
}
|
|
254
254
|
// โโโ Run grounding check โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
255
255
|
const MAX_EVAL_TOKENS = 512;
|
package/dist/agent/llm.js
CHANGED
|
@@ -461,14 +461,14 @@ export class ModelClient {
|
|
|
461
461
|
}
|
|
462
462
|
// Static fallback when the router module isn't loadable. Defaults to a
|
|
463
463
|
// FREE model so users aren't silently charged. The unknown-key path also
|
|
464
|
-
// falls through to
|
|
465
|
-
// strings (now retired routing profiles) end up at the
|
|
466
|
-
// without needing dedicated entries.
|
|
464
|
+
// falls through to nemotron-nano-9b-v2, so legacy `blockrun/eco` /
|
|
465
|
+
// `blockrun/premium` strings (now retired routing profiles) end up at the
|
|
466
|
+
// same place without needing dedicated entries.
|
|
467
467
|
const FALLBACKS = {
|
|
468
|
-
'blockrun/auto': 'nvidia/
|
|
469
|
-
'blockrun/free': 'nvidia/
|
|
468
|
+
'blockrun/auto': 'nvidia/nemotron-nano-9b-v2',
|
|
469
|
+
'blockrun/free': 'nvidia/nemotron-nano-9b-v2',
|
|
470
470
|
};
|
|
471
|
-
return FALLBACKS[model] || 'nvidia/
|
|
471
|
+
return FALLBACKS[model] || 'nvidia/nemotron-nano-9b-v2';
|
|
472
472
|
}
|
|
473
473
|
/**
|
|
474
474
|
* USDC actually charged for the most recent stream. 0 if no payment
|
package/dist/agent/loop.js
CHANGED
|
@@ -43,7 +43,7 @@ import { writeLiveAgent } from '../session/live-registry.js';
|
|
|
43
43
|
import { estimateCost, OPUS_PRICING } from '../pricing.js';
|
|
44
44
|
import { maybeMidSessionExtract } from '../learnings/extractor.js';
|
|
45
45
|
import { extractMentions, buildEntityContext, loadEntities } from '../brain/store.js';
|
|
46
|
-
import {
|
|
46
|
+
import { routeRequest, parseRoutingProfile, getFallbackChain, pickFreeFallback, isVisionModel, messageNeedsVision, pickVisionSibling } from '../router/index.js';
|
|
47
47
|
import { recordOutcome } from '../router/local-elo.js';
|
|
48
48
|
import { shouldPlan, getPlanningPrompt, getExecutorModel, isExecutorStuck, toolCallSignature } from './planner.js';
|
|
49
49
|
import { shouldVerify, runVerification } from './verification.js';
|
|
@@ -953,6 +953,11 @@ export async function interactiveSession(config, getUserInput, onEvent, onAbortR
|
|
|
953
953
|
// the same threshold would flap on every iteration once crossed.
|
|
954
954
|
let bloatCompactedThisTurn = false;
|
|
955
955
|
let maxTokensOverride;
|
|
956
|
+
// Auto picks once for the whole user turn. Internal tool/planning rounds
|
|
957
|
+
// reuse the decision unless a real provider/payment failure deliberately
|
|
958
|
+
// switches config.model to a fallback.
|
|
959
|
+
let pinnedRouting;
|
|
960
|
+
let routingCandidates = [];
|
|
956
961
|
const turnIdleReference = lastSessionActivity;
|
|
957
962
|
lastSessionActivity = Date.now();
|
|
958
963
|
// โโ Grounding retry state (per turn) โโ
|
|
@@ -1355,18 +1360,23 @@ export async function interactiveSession(config, getUserInput, onEvent, onAbortR
|
|
|
1355
1360
|
// the "Image file: <path>" stub. Detect upfront, route accordingly.
|
|
1356
1361
|
const turnNeedsVision = loopCount === 1 && messageNeedsVision(lastUserInput);
|
|
1357
1362
|
// โโ Router: resolve routing profiles to concrete models โโ
|
|
1358
|
-
//
|
|
1359
|
-
//
|
|
1360
|
-
//
|
|
1363
|
+
// The shared Router is local/deterministic and runs once per user turn.
|
|
1364
|
+
// The turn analyzer remains useful for planning and pushback, but no
|
|
1365
|
+
// longer overrides model selection or adds a router-classifier call.
|
|
1361
1366
|
const routingProfile = parseRoutingProfile(config.model);
|
|
1362
1367
|
let resolvedModel = config.model;
|
|
1363
1368
|
let routingTier;
|
|
1364
1369
|
let routingConfidence;
|
|
1365
1370
|
let routingSavings;
|
|
1366
1371
|
if (routingProfile) {
|
|
1367
|
-
const routing =
|
|
1368
|
-
|
|
1369
|
-
:
|
|
1372
|
+
const routing = pinnedRouting ?? routeRequest(lastUserInput || '', routingProfile, {
|
|
1373
|
+
needsVision: turnNeedsVision,
|
|
1374
|
+
maxOutputTokens: maxTokens,
|
|
1375
|
+
hasTools: activeCapabilityMap.size > 0,
|
|
1376
|
+
toolNames: [...activeCapabilityMap.keys()],
|
|
1377
|
+
});
|
|
1378
|
+
pinnedRouting ??= routing;
|
|
1379
|
+
routingCandidates = routing.candidates ?? [routing.model];
|
|
1370
1380
|
resolvedModel = routing.model;
|
|
1371
1381
|
routingTier = routing.tier;
|
|
1372
1382
|
routingConfidence = routing.confidence;
|
|
@@ -1399,6 +1409,10 @@ export async function interactiveSession(config, getUserInput, onEvent, onAbortR
|
|
|
1399
1409
|
text: `*โ ๏ธ ${original} can't see images โ using ${visionSwap} for this turn.*\n\n`,
|
|
1400
1410
|
});
|
|
1401
1411
|
}
|
|
1412
|
+
// The pre-routing cap was calculated from the virtual profile name.
|
|
1413
|
+
// Re-apply it to the concrete pick so capability filtering and the
|
|
1414
|
+
// actual request use the same model output limit.
|
|
1415
|
+
maxTokens = Math.min(maxTokensOverride ?? CAPPED_MAX_TOKENS, getMaxOutputTokens(resolvedModel));
|
|
1402
1416
|
// Update token estimation model for more accurate byte-per-token ratio
|
|
1403
1417
|
setEstimationModel(resolvedModel);
|
|
1404
1418
|
// โโ Plan-then-execute: detect and activate โโ
|
|
@@ -1567,7 +1581,7 @@ export async function interactiveSession(config, getUserInput, onEvent, onAbortR
|
|
|
1567
1581
|
// Free-only recovery chain โ a free/empty-response session must NEVER
|
|
1568
1582
|
// fall back to a paid model (would silently charge the wallet). Both
|
|
1569
1583
|
// entries are $0 nvidia models.
|
|
1570
|
-
const EMPTY_FALLBACK_MODELS = ['nvidia/
|
|
1584
|
+
const EMPTY_FALLBACK_MODELS = ['nvidia/nemotron-nano-9b-v2', 'nvidia/mistral-nemotron'];
|
|
1571
1585
|
const nextModel = EMPTY_FALLBACK_MODELS.find(m => m !== config.model && !turnFailedModels.has(m));
|
|
1572
1586
|
if (nextModel && recoveryAttempts < 2 && !config.disableModelFallback) {
|
|
1573
1587
|
recoveryAttempts++;
|
|
@@ -1777,7 +1791,9 @@ export async function interactiveSession(config, getUserInput, onEvent, onAbortR
|
|
|
1777
1791
|
const streak = (serverErrorsByModel.get(resolvedModel) ?? 0) + 1;
|
|
1778
1792
|
serverErrorsByModel.set(resolvedModel, streak);
|
|
1779
1793
|
if (streak >= SERVER_ERROR_STREAK_BEFORE_SWITCH) {
|
|
1780
|
-
const fallbackChain =
|
|
1794
|
+
const fallbackChain = routingCandidates.length > 0
|
|
1795
|
+
? routingCandidates
|
|
1796
|
+
: getFallbackChain(routingTier ?? 'MEDIUM', parseRoutingProfile(config.model) ?? 'auto');
|
|
1781
1797
|
const nextModel = fallbackChain.find(m => m !== resolvedModel && (serverErrorsByModel.get(m) ?? 0) < SERVER_ERROR_STREAK_BEFORE_SWITCH);
|
|
1782
1798
|
if (nextModel) {
|
|
1783
1799
|
config.model = nextModel;
|
package/dist/agent/tokens.js
CHANGED
|
@@ -257,20 +257,34 @@ const MODEL_CONTEXT_WINDOWS = {
|
|
|
257
257
|
'moonshot/kimi-k2.5': 128_000,
|
|
258
258
|
'minimax/minimax-m3': 1_000_000,
|
|
259
259
|
'minimax/minimax-m2.7': 128_000,
|
|
260
|
-
// NVIDIA-hosted free tier (refreshed 2026-
|
|
261
|
-
|
|
260
|
+
// NVIDIA-hosted free tier (refreshed 2026-08-12 to match live /api/v1/models).
|
|
261
|
+
// Dead ids (qwen3-next, qwen3.5-122b, seed-oss, maverick, mistral-large) are
|
|
262
|
+
// kept so legacy session records still get a sane window.
|
|
263
|
+
'nvidia/qwen3-next-80b-a3b-instruct': 262_144, // NVIDIA EOL 410, 2026-07-27
|
|
262
264
|
'nvidia/qwen3.5-122b-a10b': 131_072,
|
|
263
265
|
'nvidia/nemotron-3-nano-omni-30b-a3b-reasoning': 256_000,
|
|
264
266
|
'nvidia/mistral-nemotron': 131_072,
|
|
265
267
|
'nvidia/step-3.7-flash': 131_072,
|
|
266
268
|
'nvidia/seed-oss-36b': 131_072,
|
|
267
|
-
'nvidia/nemotron-nano-9b-v2': 131_072,
|
|
269
|
+
'nvidia/nemotron-nano-9b-v2': 131_072, // current free default
|
|
268
270
|
'nvidia/nemotron-nano-12b-v2-vl': 131_072,
|
|
269
271
|
'nvidia/llama-4-maverick': 131_072,
|
|
270
272
|
'nvidia/mistral-large-3-675b': 131_072,
|
|
271
273
|
// Qwen (paid) โ Max tier is 1M ctx; the generic `qwen` fallback below is
|
|
272
274
|
// 128k and would compact ~8x too early.
|
|
273
275
|
'qwen/qwen3.7-max': 1_000_000,
|
|
276
|
+
'qwen/qwen3.7-plus': 1_000_000,
|
|
277
|
+
'qwen/qwen3.7-flash': 1_000_000,
|
|
278
|
+
// 2026-08 gateway additions (windows from the live catalog).
|
|
279
|
+
'google/gemini-3.6-flash': 1_048_576,
|
|
280
|
+
'google/gemini-3.5-flash-lite': 1_048_576,
|
|
281
|
+
'openai/gpt-5.6-luna-pro': 1_050_000,
|
|
282
|
+
'openai/gpt-5.6-terra-pro': 1_050_000,
|
|
283
|
+
'openai/gpt-5.6-sol-pro': 1_050_000,
|
|
284
|
+
'openai/gpt-5.5-pro': 1_050_000,
|
|
285
|
+
'openai/chat-latest': 128_000,
|
|
286
|
+
'tencent/hy3': 262_144,
|
|
287
|
+
'xiaomi/mimo-v2.5-pro': 1_048_576,
|
|
274
288
|
};
|
|
275
289
|
/**
|
|
276
290
|
* Get the context window size for a model, with a conservative default.
|
|
@@ -52,10 +52,12 @@ const CACHE_MAX_SIZE = 64;
|
|
|
52
52
|
// โโโ Analyzer prompt โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
53
53
|
//
|
|
54
54
|
// Design: one compact prompt, a few precise examples, instruct the model to
|
|
55
|
-
// emit a single-line JSON.
|
|
56
|
-
//
|
|
57
|
-
//
|
|
58
|
-
|
|
55
|
+
// emit a single-line JSON. The backbone must produce plain-text structured
|
|
56
|
+
// output under tight max_tokens (thinking-first models leave text empty).
|
|
57
|
+
// Nemotron Nano 9B took over 2026-08-12: qwen3-next-80b-a3b-instruct hit
|
|
58
|
+
// NVIDIA's EOL (410) and mistral-nemotron is DEGRADED upstream (stream calls
|
|
59
|
+
// 400). Nano 9B verifiably serves itself โ verified live through the binary.
|
|
60
|
+
const ANALYZER_MODEL_DEFAULT = process.env.FRANKLIN_ANALYZER_MODEL || 'nvidia/nemotron-nano-9b-v2';
|
|
59
61
|
const ANALYZER_SYSTEM = `You analyze ONE user message for Franklin's routing + prefetch harness. Output ONE LINE of compact JSON โ no explanation, no markdown, no code fences.
|
|
60
62
|
|
|
61
63
|
## Fields
|
|
@@ -113,7 +113,7 @@ export async function runVerification(history, handlers, client, config) {
|
|
|
113
113
|
];
|
|
114
114
|
config.onEvent?.({ kind: 'text_delta', text: '\n*Verifying...*\n' });
|
|
115
115
|
// Use agent-tested free model for verification.
|
|
116
|
-
const verificationModel = 'nvidia/
|
|
116
|
+
const verificationModel = 'nvidia/nemotron-nano-9b-v2';
|
|
117
117
|
try {
|
|
118
118
|
// Simple single-turn verification call
|
|
119
119
|
const response = await client.complete({
|
package/dist/commands/slack.js
CHANGED
|
@@ -41,7 +41,7 @@ export async function slackCommand(opts) {
|
|
|
41
41
|
const config = loadConfig();
|
|
42
42
|
const model = opts.model ||
|
|
43
43
|
config['default-model'] ||
|
|
44
|
-
'nvidia/
|
|
44
|
+
'nvidia/nemotron-nano-9b-v2';
|
|
45
45
|
const workingDir = process.cwd();
|
|
46
46
|
const systemInstructions = assembleInstructions(workingDir, model);
|
|
47
47
|
// Connect MCP servers (Notion, etc.) so the bot exposes their tools โ mirrors
|
package/dist/commands/social.js
CHANGED
|
@@ -159,7 +159,7 @@ async function runCommand(options) {
|
|
|
159
159
|
const chain = loadChain();
|
|
160
160
|
const apiUrl = API_URLS[chain];
|
|
161
161
|
const appConfig = loadAppConfig();
|
|
162
|
-
const model = options.model || appConfig['default-model'] || 'nvidia/
|
|
162
|
+
const model = options.model || appConfig['default-model'] || 'nvidia/nemotron-nano-9b-v2';
|
|
163
163
|
console.log(chalk.dim(` Model: ${model}`));
|
|
164
164
|
console.log('');
|
|
165
165
|
let result;
|
|
@@ -44,7 +44,7 @@ export async function telegramCommand(opts) {
|
|
|
44
44
|
// Model: --model flag > config default > free default.
|
|
45
45
|
const model = opts.model ||
|
|
46
46
|
config['default-model'] ||
|
|
47
|
-
'nvidia/
|
|
47
|
+
'nvidia/nemotron-nano-9b-v2';
|
|
48
48
|
const workingDir = process.cwd();
|
|
49
49
|
const systemInstructions = assembleInstructions(workingDir, model);
|
|
50
50
|
// Resume the most recent session tagged for THIS owner so a process
|
|
@@ -18,6 +18,8 @@
|
|
|
18
18
|
* listed for a model fall back to that model's 1024x1024 tier.
|
|
19
19
|
*/
|
|
20
20
|
const PRICE_TABLE = {
|
|
21
|
+
// Retired 2026-07-27 (OpenAI delisted it; the gateway dropped the catalog
|
|
22
|
+
// entry). Kept so legacy Content assets produced by it still price.
|
|
21
23
|
'openai/dall-e-3': {
|
|
22
24
|
base: 0.04,
|
|
23
25
|
sizes: { '1024x1024': 0.04, '1792x1024': 0.08, '1024x1792': 0.08 },
|
|
@@ -34,10 +36,31 @@ const PRICE_TABLE = {
|
|
|
34
36
|
base: 0.05,
|
|
35
37
|
sizes: { '1024x1024': 0.05 },
|
|
36
38
|
},
|
|
39
|
+
// 2026-08 gateway additions (flat per-image pricing from the live catalog).
|
|
40
|
+
'google/nano-banana-2': {
|
|
41
|
+
base: 0.09,
|
|
42
|
+
sizes: { '1024x1024': 0.09 },
|
|
43
|
+
},
|
|
37
44
|
'google/nano-banana-pro': {
|
|
38
45
|
base: 0.1,
|
|
39
46
|
sizes: { '1024x1024': 0.1, '2048x2048': 0.1, '4096x4096': 0.15 },
|
|
40
47
|
},
|
|
48
|
+
'xai/grok-imagine-image': {
|
|
49
|
+
base: 0.02,
|
|
50
|
+
sizes: { '1024x1024': 0.02 },
|
|
51
|
+
},
|
|
52
|
+
'xai/grok-imagine-image-pro': {
|
|
53
|
+
base: 0.07,
|
|
54
|
+
sizes: { '1024x1024': 0.07 },
|
|
55
|
+
},
|
|
56
|
+
'bytedance/seedream-5-pro': {
|
|
57
|
+
base: 0.045,
|
|
58
|
+
sizes: { '1024x1024': 0.045 },
|
|
59
|
+
},
|
|
60
|
+
'zai/cogview-4': {
|
|
61
|
+
base: 0.015,
|
|
62
|
+
sizes: { '1024x1024': 0.015 },
|
|
63
|
+
},
|
|
41
64
|
};
|
|
42
65
|
/**
|
|
43
66
|
* Estimate the USD cost of `n` images for a model + size. `n` defaults to 1.
|
|
@@ -3,7 +3,7 @@ export type ContentStatus = 'outline' | 'drafting' | 'assets' | 'review' | 'publ
|
|
|
3
3
|
export type AssetKind = 'image' | 'audio' | 'video' | 'text';
|
|
4
4
|
export interface ContentAsset {
|
|
5
5
|
kind: AssetKind;
|
|
6
|
-
/** Producer of the asset: model ID like "openai/
|
|
6
|
+
/** Producer of the asset: model ID like "openai/gpt-image-2", or "manual". */
|
|
7
7
|
source: string;
|
|
8
8
|
/** USD actually spent producing this asset. 0 is valid (free models). */
|
|
9
9
|
costUsd: number;
|
package/dist/gateway-models.d.ts
CHANGED
|
@@ -10,8 +10,10 @@
|
|
|
10
10
|
* Per gateway team (2026-04-22): every model returns `billing_mode` and
|
|
11
11
|
* a mode-specific `pricing` object. Dispatch on billing_mode to compute
|
|
12
12
|
* an estimated charge. x402 adds a fixed 5% margin on top of base price,
|
|
13
|
-
*
|
|
14
|
-
*
|
|
13
|
+
* plus a flat $0.001 per-transaction fee on paid calls (Base since
|
|
14
|
+
* 2026-07-10; Solana instead enforces a $0.001 minimum per call with no
|
|
15
|
+
* service fee โ the flat-fee estimate over-counts there by โค$0.001, which
|
|
16
|
+
* is the safe direction for budget tracking).
|
|
15
17
|
*/
|
|
16
18
|
export type BillingMode = 'paid' | 'free' | 'flat' | 'per_image' | 'per_second' | 'per_track' | 'per_character' | 'per_generation';
|
|
17
19
|
export interface PaidPricing {
|
|
@@ -100,6 +102,13 @@ export declare function getModelsByCategory(category: string): Promise<GatewayMo
|
|
|
100
102
|
export declare function findModel(id: string): Promise<GatewayModel | null>;
|
|
101
103
|
/** x402 gateway's fixed margin percentage applied on top of the base price. */
|
|
102
104
|
export declare const GATEWAY_MARGIN = 1.05;
|
|
105
|
+
/**
|
|
106
|
+
* Flat per-transaction fee (USD) the gateway adds on top of the margined
|
|
107
|
+
* price on every PAID call (no-op on $0 calls). Introduced upstream
|
|
108
|
+
* 2026-07-10, briefly $0.002, back to $0.001 since 2026-07-29
|
|
109
|
+
* (blockrun src/lib/transaction-fee.ts).
|
|
110
|
+
*/
|
|
111
|
+
export declare const GATEWAY_TRANSACTION_FEE_USD = 0.001;
|
|
103
112
|
export interface EstimateContext {
|
|
104
113
|
/** Number of images (per_image). Default 1. */
|
|
105
114
|
quantity?: number;
|
|
@@ -110,8 +119,9 @@ export interface EstimateContext {
|
|
|
110
119
|
}
|
|
111
120
|
/**
|
|
112
121
|
* Estimated USD charge to generate one response from this model under the
|
|
113
|
-
* given context. Includes the 5% gateway margin
|
|
114
|
-
*
|
|
122
|
+
* given context. Includes the 5% gateway margin and the flat $0.001
|
|
123
|
+
* per-transaction fee on paid calls. Returns 0 for free and token-metered
|
|
124
|
+
* (paid) models where a pre-call estimate isn't meaningful.
|
|
115
125
|
*/
|
|
116
126
|
export declare function estimateCostUsd(model: GatewayModel, ctx?: EstimateContext): number;
|
|
117
127
|
/** Effective default duration for a per_second model (falls back to 8s). */
|
package/dist/gateway-models.js
CHANGED
|
@@ -10,8 +10,10 @@
|
|
|
10
10
|
* Per gateway team (2026-04-22): every model returns `billing_mode` and
|
|
11
11
|
* a mode-specific `pricing` object. Dispatch on billing_mode to compute
|
|
12
12
|
* an estimated charge. x402 adds a fixed 5% margin on top of base price,
|
|
13
|
-
*
|
|
14
|
-
*
|
|
13
|
+
* plus a flat $0.001 per-transaction fee on paid calls (Base since
|
|
14
|
+
* 2026-07-10; Solana instead enforces a $0.001 minimum per call with no
|
|
15
|
+
* service fee โ the flat-fee estimate over-counts there by โค$0.001, which
|
|
16
|
+
* is the safe direction for budget tracking).
|
|
15
17
|
*/
|
|
16
18
|
import { loadChain, API_URLS, USER_AGENT } from './config.js';
|
|
17
19
|
// โโโ Cache โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
@@ -128,10 +130,18 @@ export async function findModel(id) {
|
|
|
128
130
|
// โโโ Cost estimation โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
129
131
|
/** x402 gateway's fixed margin percentage applied on top of the base price. */
|
|
130
132
|
export const GATEWAY_MARGIN = 1.05;
|
|
133
|
+
/**
|
|
134
|
+
* Flat per-transaction fee (USD) the gateway adds on top of the margined
|
|
135
|
+
* price on every PAID call (no-op on $0 calls). Introduced upstream
|
|
136
|
+
* 2026-07-10, briefly $0.002, back to $0.001 since 2026-07-29
|
|
137
|
+
* (blockrun src/lib/transaction-fee.ts).
|
|
138
|
+
*/
|
|
139
|
+
export const GATEWAY_TRANSACTION_FEE_USD = 0.001;
|
|
131
140
|
/**
|
|
132
141
|
* Estimated USD charge to generate one response from this model under the
|
|
133
|
-
* given context. Includes the 5% gateway margin
|
|
134
|
-
*
|
|
142
|
+
* given context. Includes the 5% gateway margin and the flat $0.001
|
|
143
|
+
* per-transaction fee on paid calls. Returns 0 for free and token-metered
|
|
144
|
+
* (paid) models where a pre-call estimate isn't meaningful.
|
|
135
145
|
*/
|
|
136
146
|
export function estimateCostUsd(model, ctx = {}) {
|
|
137
147
|
const p = model.pricing;
|
|
@@ -169,7 +179,10 @@ export function estimateCostUsd(model, ctx = {}) {
|
|
|
169
179
|
base = 0;
|
|
170
180
|
break;
|
|
171
181
|
}
|
|
172
|
-
|
|
182
|
+
// The flat transaction fee only applies to non-zero charges (the gateway's
|
|
183
|
+
// addTransactionFee is a no-op at $0, keeping free flows free).
|
|
184
|
+
const margined = base * GATEWAY_MARGIN;
|
|
185
|
+
return +(margined > 0 ? margined + GATEWAY_TRANSACTION_FEE_USD : 0).toFixed(6);
|
|
173
186
|
}
|
|
174
187
|
/** Effective default duration for a per_second model (falls back to 8s). */
|
|
175
188
|
export function defaultDurationSeconds(model) {
|
|
@@ -9,8 +9,8 @@ import { loadLearnings, mergeLearning, saveLearnings, loadSkills, saveSkill } fr
|
|
|
9
9
|
// Free models for learning extraction โ JSON extraction is simple enough.
|
|
10
10
|
// Ordered by reliability: try the best free model first, fall back to others.
|
|
11
11
|
const EXTRACTION_MODELS = [
|
|
12
|
-
'nvidia/
|
|
13
|
-
'nvidia/mistral-nemotron', //
|
|
12
|
+
'nvidia/nemotron-nano-9b-v2', // Serves itself on every path (verified live 2026-08-12)
|
|
13
|
+
'nvidia/mistral-nemotron', // Fallback: DEGRADED upstream but non-stream calls ride the gateway fallback
|
|
14
14
|
];
|
|
15
15
|
const VALID_CATEGORIES = new Set([
|
|
16
16
|
'language', 'model_preference', 'tool_pattern', 'coding_style',
|
|
@@ -21,7 +21,7 @@ export interface WorkflowStepContext {
|
|
|
21
21
|
data: Record<string, unknown>;
|
|
22
22
|
/** Call an LLM at the specified tier */
|
|
23
23
|
callModel: (tier: ModelTier, prompt: string, system?: string) => Promise<string>;
|
|
24
|
-
/** Generate an image (
|
|
24
|
+
/** Generate an image (gpt-image / nano-banana) */
|
|
25
25
|
generateImage?: (prompt: string) => Promise<string>;
|
|
26
26
|
/** Search the web (Exa neural / WebSearch fallback) */
|
|
27
27
|
search: (query: string, options?: {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Plugins implement Workflow; core orchestrates execution and provides infrastructure.
|
|
6
6
|
*/
|
|
7
7
|
export const DEFAULT_MODEL_TIERS = {
|
|
8
|
-
free: 'nvidia/
|
|
9
|
-
cheap: 'nvidia/
|
|
8
|
+
free: 'nvidia/nemotron-nano-9b-v2',
|
|
9
|
+
cheap: 'nvidia/nemotron-nano-9b-v2', // Free by default; opt-in to paid flat-rate via 'zai/glm-5.1'.
|
|
10
10
|
premium: 'anthropic/claude-sonnet-5',
|
|
11
11
|
};
|