@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/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; per tier ('none': not chosen by routing) its replies and their routed cost, and replies by the
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 kept across sessions, one per session under store key 'savings:v1:<session id>' or their sum in the view,
115
- // since the first reply after the last reset (ms).
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
- // Aligned with `history` and `tiers`.
183
- activities?: (RouterActivity | null)[];
184
- // The (model, effort) each reply's request went out with, aligned with tiers; null where routing did not choose.
185
- routes?: (string | null)[];
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 Usage tab shows Claude's readings in detail, with the estimates.
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;