@alexeiled/claude-router 1.23.0 → 1.24.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/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +29 -1
- package/docs/architecture.md +1 -1
- package/docs/auto-engine.md +152 -0
- package/docs/configuration.md +36 -1
- package/docs/evaluation.md +219 -0
- package/docs/providers.md +28 -0
- package/docs/routing-modes.md +9 -2
- package/docs/user-guide.md +9 -2
- package/hooks/native-router.mjs +877 -151
- package/lib/activity.mjs +4 -4
- package/lib/auto-engine.mjs +407 -0
- package/lib/auto-route.mjs +247 -0
- package/lib/config.mjs +42 -8
- package/lib/cost.mjs +7 -0
- package/lib/decisions.mjs +71 -0
- package/lib/facts.mjs +27 -0
- package/lib/modes.mjs +5 -5
- package/lib/panel.mjs +4 -0
- package/lib/providers.mjs +7 -0
- package/lib/replay-trace.mjs +547 -0
- package/lib/replay.mjs +712 -0
- package/lib/route.mjs +14 -5
- package/package.json +1 -1
package/lib/route.mjs
CHANGED
|
@@ -58,7 +58,7 @@ export function ownRoute(config, model) {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
export function emptyLoop(config, model) {
|
|
61
|
-
const cell = cellForModel(config, model);
|
|
61
|
+
const cell = config.routingEngine === 'auto' ? null : cellForModel(config, model);
|
|
62
62
|
return {
|
|
63
63
|
lastRoute: cell?.tier ?? config.baselineTier,
|
|
64
64
|
lastActivity: cell?.activity ?? null,
|
|
@@ -66,7 +66,7 @@ export function emptyLoop(config, model) {
|
|
|
66
66
|
// a route edit changes the config, never the route in use. Null until the first decision, except on a session
|
|
67
67
|
// model no route names (ownRoute): it starts at the baseline tier but keeps running until a decision moves it.
|
|
68
68
|
// Taken as the baseline's route, repeated failures on it "escalated" to a weaker model.
|
|
69
|
-
route: ownRoute(config, model),
|
|
69
|
+
route: config.routingEngine === 'auto' ? null : ownRoute(config, model),
|
|
70
70
|
state: initialState(),
|
|
71
71
|
models: {},
|
|
72
72
|
resolutions: {},
|
|
@@ -74,6 +74,7 @@ export function emptyLoop(config, model) {
|
|
|
74
74
|
historyMeasured: false,
|
|
75
75
|
lastMessageCount: null,
|
|
76
76
|
generation: 0,
|
|
77
|
+
hasRoutedDecision: false,
|
|
77
78
|
turnId: null,
|
|
78
79
|
decision: null,
|
|
79
80
|
ineligible: [],
|
|
@@ -109,14 +110,21 @@ export function resetHistory(loop) {
|
|
|
109
110
|
};
|
|
110
111
|
}
|
|
111
112
|
|
|
113
|
+
// Legacy physical observations cannot prove a manual-only prefix. Never regrant startup on ambiguous history.
|
|
114
|
+
export const hasRoutedDecision = (loop) =>
|
|
115
|
+
typeof loop.hasRoutedDecision === 'boolean'
|
|
116
|
+
? loop.hasRoutedDecision
|
|
117
|
+
: Boolean(loop.decision || loop.auto || loop.requests > 0);
|
|
118
|
+
|
|
112
119
|
export function prepareLoop(loop, messageCount) {
|
|
120
|
+
const prepared = { ...loop, hasRoutedDecision: hasRoutedDecision(loop) };
|
|
113
121
|
if (loop.lastMessageCount === null || messageCount >= loop.lastMessageCount)
|
|
114
|
-
return { ...
|
|
122
|
+
return { ...prepared, lastMessageCount: messageCount };
|
|
115
123
|
// Compaction or a rewind shortened the history: message cursors past its end move to it, so checks and edits made
|
|
116
124
|
// from here on count. The request-based dwell is kept.
|
|
117
125
|
const cursor = (count) => Math.min(count ?? 0, messageCount);
|
|
118
126
|
return {
|
|
119
|
-
...resetHistory(
|
|
127
|
+
...resetHistory(prepared),
|
|
120
128
|
lastMessageCount: messageCount,
|
|
121
129
|
switchedAt: loop.switchedAt && { ...loop.switchedAt, messageCount: cursor(loop.switchedAt.messageCount) },
|
|
122
130
|
observedFrom: cursor(loop.observedFrom),
|
|
@@ -160,7 +168,7 @@ export function isModelAllowed(requested, allowed, native) {
|
|
|
160
168
|
);
|
|
161
169
|
}
|
|
162
170
|
|
|
163
|
-
function economicConfig(config, loop) {
|
|
171
|
+
export function economicConfig(config, loop) {
|
|
164
172
|
const models = Object.fromEntries(
|
|
165
173
|
Object.entries(config.models).map(([alias, model]) => [
|
|
166
174
|
alias,
|
|
@@ -185,6 +193,7 @@ export function chooseRoute(config, loop, input) {
|
|
|
185
193
|
return {
|
|
186
194
|
...loop,
|
|
187
195
|
state: applied.state,
|
|
196
|
+
hasRoutedDecision: true,
|
|
188
197
|
lastRoute: kept ? loop.lastRoute : applied.tier,
|
|
189
198
|
lastActivity: kept ? activityOf(config, loop) : applied.activity,
|
|
190
199
|
route: kept ? (loop.route ?? null) : applied.route,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alexeiled/claude-router",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.24.0",
|
|
4
4
|
"description": "Native Claude Code model and effort routing with Anthropic, DeepSeek, z.ai, MiniMax, MiMo and Kimi defaults, custom provider profiles, and classifier advice.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Alexei Ledenev",
|