@blockrun/franklin 3.42.0 → 3.42.1
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/dist/agent/tokens.js +4 -0
- package/dist/pricing.js +7 -0
- package/dist/proxy/server.js +12 -1
- package/dist/router/index.js +36 -6
- package/package.json +1 -1
package/dist/agent/tokens.js
CHANGED
|
@@ -261,8 +261,12 @@ const MODEL_CONTEXT_WINDOWS = {
|
|
|
261
261
|
// xAI 3.x / 4-0709 / 4-1-fast: hidden from /v1/models since 2026-08 but
|
|
262
262
|
// still served and charged (probed 2026-08-29) — keep their windows.
|
|
263
263
|
'xai/grok-3': 131_072,
|
|
264
|
+
'xai/grok-3-mini': 131_072,
|
|
264
265
|
'xai/grok-4-0709': 131_072,
|
|
265
266
|
'xai/grok-4-1-fast-reasoning': 131_072,
|
|
267
|
+
'xai/grok-4-1-fast-non-reasoning': 131_072,
|
|
268
|
+
'xai/grok-4-fast-reasoning': 131_072,
|
|
269
|
+
'xai/grok-4-fast-non-reasoning': 131_072,
|
|
266
270
|
// Others
|
|
267
271
|
'zai/glm-5.3': 1_000_000, // flagship 2026-08 — 1M context, always-on reasoning
|
|
268
272
|
'zai/glm-5.3-flash': 1_000_000, // 2026-08-29 catalog sync — 1M context, vision, $0.15/$0.5
|
package/dist/pricing.js
CHANGED
|
@@ -148,6 +148,13 @@ export const MODEL_PRICING = {
|
|
|
148
148
|
'xai/grok-4-fast-reasoning': { input: 0.2, output: 0.5 }, // (probed)
|
|
149
149
|
'xai/grok-4-1-fast': { input: 0.2, output: 0.5 },
|
|
150
150
|
'xai/grok-4-1-fast-reasoning': { input: 0.2, output: 0.5 }, // (probed)
|
|
151
|
+
// The two non-reasoning ids sit in the shared Router's SIMPLE chains and
|
|
152
|
+
// were charged today, yet had no row here — Franklin reported them as $0
|
|
153
|
+
// and the portfolio scorer, which treats an unpriced id as infinitely
|
|
154
|
+
// expensive, could never pick them over a priced rung. Priced with their
|
|
155
|
+
// reasoning siblings (xAI bills the pair identically).
|
|
156
|
+
'xai/grok-4-1-fast-non-reasoning': { input: 0.2, output: 0.5 }, // (probed)
|
|
157
|
+
'xai/grok-4-fast-non-reasoning': { input: 0.2, output: 0.5 }, // (probed)
|
|
151
158
|
'xai/grok-4-0709': { input: 3.0, output: 15.0 }, // (probed) gateway lists $3/$15 (was mispriced here at $0.2/$1.5)
|
|
152
159
|
'xai/grok-3-mini': { input: 0.3, output: 0.5 }, // (probed)
|
|
153
160
|
'xai/grok-2-vision': { input: 2.0, output: 10.0 },
|
package/dist/proxy/server.js
CHANGED
|
@@ -7,7 +7,8 @@ import { MODEL_SHORTCUTS } from '../ui/model-picker.js';
|
|
|
7
7
|
import { appendSettlementRow } from '../stats/cost-log.js';
|
|
8
8
|
import { appendAudit } from '../stats/audit.js';
|
|
9
9
|
import { buildFallbackChain, DEFAULT_FALLBACK_CONFIG, ROUTING_PROFILES, } from './fallback.js';
|
|
10
|
-
import { routeRequest, parseRoutingProfile, isVisionModel, messagesNeedVision, pickVisionSibling, } from '../router/index.js';
|
|
10
|
+
import { routeRequest, parseRoutingProfile, isVisionModel, messagesNeedVision, pickVisionSibling, markModelUnavailable, } from '../router/index.js';
|
|
11
|
+
import { classifyAgentError } from '../agent/error-classifier.js';
|
|
11
12
|
import { estimateCost } from '../pricing.js';
|
|
12
13
|
import { getMaxOutputTokens } from '../agent/optimize.js';
|
|
13
14
|
import { VERSION } from '../config.js';
|
|
@@ -523,6 +524,16 @@ export function createProxy(options) {
|
|
|
523
524
|
else {
|
|
524
525
|
// Wrap in Anthropic error format
|
|
525
526
|
const errorMsg = parsed.error?.message || parsed.message || rawText.slice(0, 500);
|
|
527
|
+
// The proxy's fallback chain only retries 429/5xx, so a routed
|
|
528
|
+
// id the gateway rejects outright (400 "Unknown model", 404,
|
|
529
|
+
// 410) reaches here untouched. Feed the router's dead-rung
|
|
530
|
+
// kill-switch so the next routed request skips it; a client
|
|
531
|
+
// that pinned the id by name is left alone.
|
|
532
|
+
if (routerCandidates.length > 0 && classifyAgentError(String(errorMsg)).modelUnavailable) {
|
|
533
|
+
if (markModelUnavailable(finalModel)) {
|
|
534
|
+
logger.warn(`[franklin] ${finalModel} rejected by the gateway as unavailable — removed from routing for this process`);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
526
537
|
errorBody = JSON.stringify({
|
|
527
538
|
type: 'error',
|
|
528
539
|
error: {
|
package/dist/router/index.js
CHANGED
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import fs from 'node:fs';
|
|
13
13
|
import path from 'node:path';
|
|
14
|
-
import { DEFAULT_ROUTING_CONFIG as SHARED_ROUTING_CONFIG, route as routeWithSharedCore, } from '@blockrun/router-core';
|
|
14
|
+
import { DEFAULT_MODEL_CAPABILITIES as SHARED_MODEL_CAPABILITIES_BASE, DEFAULT_ROUTING_CONFIG as SHARED_ROUTING_CONFIG, route as routeWithSharedCore, } from '@blockrun/router-core';
|
|
15
15
|
import { MODEL_PRICING, OPUS_PRICING } from '../pricing.js';
|
|
16
16
|
import { BLOCKRUN_DIR } from '../config.js';
|
|
17
17
|
import { detectCategory, mapCategoryToTier } from './categories.js';
|
|
18
18
|
import { selectModel } from './selector.js';
|
|
19
19
|
import { computeLocalElo, blendElo } from './local-elo.js';
|
|
20
|
-
import { isVisionModel } from './vision.js';
|
|
20
|
+
import { isVisionModel, pickVisionSibling } from './vision.js';
|
|
21
21
|
export { isVisionModel, messageNeedsVision, messagesNeedVision, pickVisionSibling } from './vision.js';
|
|
22
22
|
// ─── Learned Weights Loading ───
|
|
23
23
|
const WEIGHTS_FILE = path.join(BLOCKRUN_DIR, 'router-weights.json');
|
|
@@ -118,6 +118,19 @@ export function isModelUnavailable(model) {
|
|
|
118
118
|
export function resetUnavailableModels() {
|
|
119
119
|
observedUnavailable.clear();
|
|
120
120
|
}
|
|
121
|
+
// The core's capability snapshot decides vision eligibility inside the
|
|
122
|
+
// portfolio, but it lags the catalog (36 gateway chat ids have no entry as of
|
|
123
|
+
// 2026-08-29, and it disagrees with Franklin's allowlist on gpt-5-mini / o3 /
|
|
124
|
+
// grok-4-0709, all of which accept images). Franklin's allowlist in vision.ts
|
|
125
|
+
// is the maintained source, so its verdict overrides `supportsVision` on
|
|
126
|
+
// every entry the core knows. Ids the core does not know fail OPEN inside
|
|
127
|
+
// the core (`isEligible` returns true) — that gap is closed by the
|
|
128
|
+
// post-selection guard in routeRequest, not by inventing context/output
|
|
129
|
+
// numbers here that would silently change eligibility.
|
|
130
|
+
const SHARED_MODEL_CAPABILITIES = Object.fromEntries(Object.entries(SHARED_MODEL_CAPABILITIES_BASE).map(([id, caps]) => [
|
|
131
|
+
id,
|
|
132
|
+
{ ...caps, supportsVision: isVisionModel(id) },
|
|
133
|
+
]));
|
|
121
134
|
function normalizeRoutingContext(context) {
|
|
122
135
|
return typeof context === 'boolean' ? { needsVision: context } : context;
|
|
123
136
|
}
|
|
@@ -616,6 +629,7 @@ export function routeRequest(prompt, profile = 'auto', context = false) {
|
|
|
616
629
|
strategy: process.env.FRANKLIN_ROUTER_STRATEGY === 'rules' ? 'rules' : 'portfolio',
|
|
617
630
|
},
|
|
618
631
|
modelPricing: SHARED_MODEL_PRICING,
|
|
632
|
+
modelCapabilities: SHARED_MODEL_CAPABILITIES,
|
|
619
633
|
routingProfile: 'auto',
|
|
620
634
|
hasTools: normalizedContext.hasTools ?? toolNames.length > 0,
|
|
621
635
|
toolCount: toolNames.length,
|
|
@@ -628,14 +642,30 @@ export function routeRequest(prompt, profile = 'auto', context = false) {
|
|
|
628
642
|
unavailableModels: getUnavailableModels(normalizedContext.unavailableModels),
|
|
629
643
|
});
|
|
630
644
|
const category = detectCategory(prompt, loadLearnedWeights()?.category_keywords).category;
|
|
645
|
+
let model = decision.model;
|
|
646
|
+
let candidates = decision.candidates ?? [decision.model];
|
|
647
|
+
const signals = [decision.routerVersion ?? decision.method, ...(decision.taskType ? [decision.taskType] : [])];
|
|
648
|
+
// Vision is a hard requirement, and the core fails open for any id
|
|
649
|
+
// missing from its capability snapshot (see SHARED_MODEL_CAPABILITIES).
|
|
650
|
+
// Before this guard an image turn could land on a text-only model the
|
|
651
|
+
// core simply had no opinion about — zai/glm-5.2 sits in the long-context
|
|
652
|
+
// evidence list, for instance — and the model would then hallucinate
|
|
653
|
+
// from the `Image file: <path>` stub. Walk the core's own recovery chain
|
|
654
|
+
// for the first model that can see; fall back to the family sibling.
|
|
655
|
+
if (normalizedContext.needsVision && !isVisionModel(model)) {
|
|
656
|
+
const sighted = candidates.filter(isVisionModel);
|
|
657
|
+
model = sighted[0] ?? pickVisionSibling(model);
|
|
658
|
+
candidates = sighted.length > 0 ? sighted : [model];
|
|
659
|
+
signals.push('vision-required');
|
|
660
|
+
}
|
|
631
661
|
return {
|
|
632
|
-
model
|
|
662
|
+
model,
|
|
633
663
|
tier: decision.tier,
|
|
634
664
|
confidence: decision.confidence,
|
|
635
|
-
signals
|
|
636
|
-
savings: decision.savings,
|
|
665
|
+
signals,
|
|
666
|
+
savings: model === decision.model ? decision.savings : computeSavings(model),
|
|
637
667
|
category,
|
|
638
|
-
candidates
|
|
668
|
+
candidates,
|
|
639
669
|
taskType: decision.taskType,
|
|
640
670
|
routerVersion: decision.routerVersion,
|
|
641
671
|
reasoning: decision.reasoning,
|
package/package.json
CHANGED