@alexeiled/claude-router 1.11.0 → 1.13.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 +34 -0
- package/README.md +1 -1
- package/docs/activity-routing.md +3 -3
- package/docs/architecture.md +4 -4
- package/docs/evaluation.md +7 -7
- package/docs/native-router.md +6 -6
- package/docs/router-pane-now.svg +111 -75
- package/docs/router-pane-usage-whatif.svg +128 -0
- package/docs/router-pane-usage.svg +100 -87
- package/docs/user-guide.md +47 -21
- package/hooks/native-router.mjs +170 -45
- package/lib/display.mjs +5 -9
- package/lib/panel.mjs +719 -436
- package/lib/savings.mjs +8 -23
- package/lib/usage.mjs +399 -0
- package/lib/view.mjs +61 -11
- package/package.json +1 -1
- package/types/index.d.ts +45 -11
package/types/index.d.ts
CHANGED
|
@@ -104,15 +104,12 @@ declare module 'claude-code' {
|
|
|
104
104
|
strongerUsd: number;
|
|
105
105
|
switchUsd: number;
|
|
106
106
|
}
|
|
107
|
-
// A session's totals
|
|
108
|
-
// stronger model they ran on.
|
|
107
|
+
// A session's totals, and replies by the stronger model they ran on.
|
|
109
108
|
interface RouterSavingsSession extends RouterSavingsSums {
|
|
110
|
-
tiers: Partial<Record<RouterTier | 'none', number>>;
|
|
111
|
-
tierUsd: Partial<Record<RouterTier | 'none', number>>;
|
|
112
109
|
stronger: Record<string, number>;
|
|
113
110
|
}
|
|
114
|
-
// Totals
|
|
115
|
-
//
|
|
111
|
+
// Totals one session kept under store key 'savings:v1:<session id>' before the usage records, or their sum in the
|
|
112
|
+
// view: no longer written, added to the Usage tab's All period as undated history.
|
|
116
113
|
interface RouterSavingsStore extends RouterSavingsSums {
|
|
117
114
|
version: 1;
|
|
118
115
|
since: number | null;
|
|
@@ -145,6 +142,26 @@ declare module 'claude-code' {
|
|
|
145
142
|
routed: { on: Record<string, RouterSubagentCounts> };
|
|
146
143
|
passed: Partial<Record<'fork' | 'explicit' | 'teammate' | 'workflow' | 'unlisted', RouterSubagentPassed>>;
|
|
147
144
|
}
|
|
145
|
+
// One local calendar day of routed replies (lib/usage.mjs). `cells` by 'activity|tier|modelId@effort' hold, in order,
|
|
146
|
+
// replies, routedUsd, yoursUsd, cheaperUsd, strongerUsd, switchUsd, inputTokens, cacheReadTokens, outputTokens.
|
|
147
|
+
// `whatIf` is [replies, USD] of the same tokens on each model id as yours; `yours` replies by your model's id;
|
|
148
|
+
// `hours` routed USD by local hour; `turns` and `switches` count turns on the day they ended.
|
|
149
|
+
interface RouterUsageDay {
|
|
150
|
+
cells: Record<string, number[]>;
|
|
151
|
+
whatIf: Record<string, [number, number]>;
|
|
152
|
+
yours: Record<string, number>;
|
|
153
|
+
hours: Record<string, number>;
|
|
154
|
+
turns: number;
|
|
155
|
+
switches: { tier: number; activity: number };
|
|
156
|
+
}
|
|
157
|
+
// Kept across sessions, one per session under store key 'usage:v1:<session id>' or their sum in the view, by day
|
|
158
|
+
// ('2026-10-13'), since its first turn written after the last reset (ms).
|
|
159
|
+
interface RouterUsageStore {
|
|
160
|
+
version: 1;
|
|
161
|
+
since: number | null;
|
|
162
|
+
days: Record<string, RouterUsageDay>;
|
|
163
|
+
}
|
|
164
|
+
type RouterUsagePeriod = 'session' | 'today' | '7d' | '30d' | 'month' | 'all';
|
|
148
165
|
interface RouterView {
|
|
149
166
|
phase: 'ready' | 'choosing' | 'routed' | 'manual' | 'unavailable';
|
|
150
167
|
mode: 'auto' | 'manual';
|
|
@@ -179,10 +196,17 @@ declare module 'claude-code' {
|
|
|
179
196
|
activityProbabilities?: Partial<Record<RouterActivityAnswer, number>> | null;
|
|
180
197
|
history?: number[];
|
|
181
198
|
tiers?: (RouterTier | null)[];
|
|
182
|
-
//
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
routes
|
|
199
|
+
// Every reply since Claude Code started the session by tier: each cell counts up to `per` replies, `none` for one
|
|
200
|
+
// routing did not serve; `from` is when the first one arrived (ms).
|
|
201
|
+
strip?: { per: number; cells: Partial<Record<RouterTier | 'none', number>>[]; from?: number | null } | null;
|
|
202
|
+
// The last route switch, at turn start or inside a turn: when, the routes it moved between with their tiers, and
|
|
203
|
+
// the activity the new route runs for.
|
|
204
|
+
lastSwitch?: {
|
|
205
|
+
at: number;
|
|
206
|
+
from: { tier: RouterTier | null; model: string; effort: string | null };
|
|
207
|
+
to: { tier: RouterTier | null; model: string; effort: string | null };
|
|
208
|
+
activity: RouterActivity | null;
|
|
209
|
+
} | null;
|
|
186
210
|
activityStats?: RouterActivitySession | null;
|
|
187
211
|
// The counts kept across sessions as last read or written.
|
|
188
212
|
activityStore?: RouterActivityStore | null;
|
|
@@ -190,6 +214,16 @@ declare module 'claude-code' {
|
|
|
190
214
|
savings?: RouterSavingsSession | null;
|
|
191
215
|
savingsStore?: RouterSavingsStore | null;
|
|
192
216
|
subagentStore?: RouterSubagentStore | null;
|
|
217
|
+
// Every session's usage records as last read or written, and this session's own.
|
|
218
|
+
usageStore?: RouterUsageStore | null;
|
|
219
|
+
usageSession?: RouterUsageStore | null;
|
|
220
|
+
// The Usage tab: its period (kept across sessions under store key 'usage:period'), breakdown, What if, the open
|
|
221
|
+
// row ('<group>:<name>'), and whether Delete history waits for its confirmation.
|
|
222
|
+
usagePeriod?: RouterUsagePeriod;
|
|
223
|
+
usageGroup?: 'activity' | 'model' | 'tier';
|
|
224
|
+
usageCompare?: boolean;
|
|
225
|
+
usageOpen?: string | null;
|
|
226
|
+
confirmDelete?: boolean;
|
|
193
227
|
configPath?: string | null;
|
|
194
228
|
tuning?: Partial<RouterTuning> | null;
|
|
195
229
|
tuningBase?: RouterTuning | null;
|
|
@@ -199,7 +233,7 @@ declare module 'claude-code' {
|
|
|
199
233
|
tab?: 'now' | 'routes' | 'policy' | 'classifier' | 'usage';
|
|
200
234
|
// The Routes grid cell whose editor is open: '<activity>.<tier>', or 'tier.<tier>' for a tier's own route.
|
|
201
235
|
routeCell?: string | null;
|
|
202
|
-
// Whether the
|
|
236
|
+
// Whether the Now tab shows Claude's readings in detail, with the estimates.
|
|
203
237
|
usageDetail?: boolean;
|
|
204
238
|
help?: boolean;
|
|
205
239
|
bandDetail?: boolean;
|