@alexeiled/claude-router 1.22.1 → 1.23.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 +19 -0
- package/docs/activity-routing.md +31 -6
- package/docs/architecture.md +14 -3
- package/docs/configuration.md +10 -2
- package/docs/native-router.md +2 -2
- package/docs/providers.md +1 -1
- package/docs/router-band.svg +11 -11
- package/docs/router-pane-now.svg +4 -4
- package/docs/router-pane-usage-whatif.svg +10 -9
- package/docs/router-pane-usage.svg +10 -9
- package/docs/routing-modes.md +13 -11
- package/docs/user-guide.md +37 -19
- package/hooks/native-router.mjs +18 -6
- package/lib/activity.mjs +42 -25
- package/lib/band.mjs +4 -4
- package/lib/config.mjs +15 -2
- package/lib/costs.mjs +2 -2
- package/lib/display.mjs +5 -5
- package/lib/modes.mjs +12 -1
- package/lib/panel.mjs +17 -20
- package/lib/route.mjs +140 -31
- package/lib/subagents.mjs +3 -3
- package/lib/view.mjs +3 -0
- package/package.json +1 -1
- package/types/index.d.ts +5 -1
package/docs/user-guide.md
CHANGED
|
@@ -71,10 +71,10 @@ While routing is on, hover over the band for a second row: a pin per tier, low t
|
|
|
71
71
|
**2 rows** adds the session under the route, in the same numbers as the pane's SESSION block. On a Claude plan it leads with the plan windows Claude Code reports:
|
|
72
72
|
|
|
73
73
|
```text
|
|
74
|
-
plan 5h ▰▰▰▰▱▱▱▱ 48% ↻18:00 7d 43% session ≈$6.40 API
|
|
74
|
+
plan 5h ▰▰▰▰▱▱▱▱ 48% ↻18:00 7d 43% session ≈$6.40 API estimate −$1.84 (−22%) vs Opus 5.5 64 replies
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
-
On an API key, or a provider billed in credits, the
|
|
77
|
+
On a plan, an API key, or a provider billed in credits, the row labels dollars `≈$6.40 API estimate`: observed tokens at configured API rates (list/custom), not an invoice or measured quota use. The difference, `−$1.84 (−22%) vs Opus 5.5`, compares the same tokens with the model `/model` selected. The band names that model while every main reply was priced against it and no subagent ran. Otherwise it reads `vs unrouted`: your model on every main-thread reply and Claude Code's own pick for every subagent. Minus is cheaper, plus is dearer; past double it reads as a ratio, `+$2.48 (×5.0)`. A mixed profile adds the estimated credits subtotal, `credits ≈$4.10`. See [How dollars are paid](#how-dollars-are-paid). Before the tenth routed reply the count reads `3 replies so far`, because one model switch and its cache write can still decide a short run. Some situations change the middle part:
|
|
78
78
|
|
|
79
79
|
- `effort low 4 · high 2`: the profile runs one model and routing moves only the effort, so no saving is estimated; see [Providers](providers.md).
|
|
80
80
|
- `3 of 20 not compared`: some replies have no comparison, such as on a provider whose cache hit rate cannot be known; no saving is shown.
|
|
@@ -87,7 +87,7 @@ The band steps aside while a survey needs the space.
|
|
|
87
87
|
|
|
88
88
|
Inside a turn the router checks the route again as the work changes; see [Changes during a task](#changes-during-a-task). A subagent gets at most one model, when it starts, and keeps it for every step: For the Anthropic profile, these are Haiku for exploration, Opus for clearly hard tasks, and Sonnet for the rest. Other profiles have [their own defaults](providers.md#activity-overrides). An agent that pins a model in its definition keeps it, unless it sets `modelRouting: auto`. The Usage tab's **SUBAGENTS** section shows what each agent type ran on and cost, and the Now tab adds this session's agents to its total. See [Subagent routing](configuration.md#subagent-routing).
|
|
89
89
|
|
|
90
|
-
In a subagent's transcript the band names the model the agent runs on and who picked it. `agent ■ Haiku 5.5 ↓ from Opus 5.5 (Claude Code’s pick)` means the router chose a cheaper model than Claude Code would have; `↑` means a
|
|
90
|
+
In a subagent's transcript the band names the model the agent runs on and who picked it. `agent ■ Haiku 5.5 ↓ from Opus 5.5 (Claude Code’s pick)` means the router chose a cheaper model than Claude Code would have; `↑` means a higher declared strength rank. When ranks are unknown, a model change has no strength direction. A hollow `□` means the agent ran on Claude Code's pick, because the router agreed or did not route it, and says why: `agent □ Opus 5.5 = Claude Code’s pick: the workflow sets it`. A narrow band drops the comparison first. The band falls back to `agent · model chosen at spawn` when the router has no record of the agent, such as after a plugin reload, and to `agent · keeps its own model (subagent routing off)`.
|
|
91
91
|
|
|
92
92
|
## Open the router pane
|
|
93
93
|
|
|
@@ -103,7 +103,7 @@ Run `/router` or select **Router** above the prompt. Without a UI surface, as in
|
|
|
103
103
|
|
|
104
104
|
The top line of every tab, `ROUTER [ ◉ on ] [ ○ off ] Jev ready · 347 ms`, shows the routing mode, switches it, and says whether the classifier is ready. Press `o` or `f` while the pane has focus. The tabs under it carry their digits, `[ 1 Now ] [ 2 Routes ] …`, and **?** shows what the numbers mean above the tab. When routing is unavailable, the top line reads `ROUTER unavailable Claude’s model is kept` with the reason under it, and offers no on or off: see [Troubleshooting](#troubleshooting).
|
|
105
105
|
|
|
106
|
-

|
|
107
107
|
|
|
108
108
|
The **Now** tab has four blocks, each with its name in capitals.
|
|
109
109
|
|
|
@@ -115,7 +115,7 @@ The **Now** tab has four blocks, each with its name in capitals.
|
|
|
115
115
|
|
|
116
116
|
```text
|
|
117
117
|
SESSION since 14:18 · 86 replies · 6 agents · 9 switches ● 1 running
|
|
118
|
-
≈$8.97 API
|
|
118
|
+
≈$8.97 API estimate · plan quota, not a charge [ Usage ]
|
|
119
119
|
−$4.09 (−31%) vs unrouted ≈$13.06
|
|
120
120
|
main ≈$6.45 ████████████████ −$4.17 vs Opus 5.5 · xhigh
|
|
121
121
|
agents ≈$2.52 ██████░░░░░░░░░░ +$0.08 vs their picks
|
|
@@ -123,7 +123,7 @@ SESSION since 14:18 · 86 replies · 6 agents · 9 switches ● 1 running
|
|
|
123
123
|
▂▄ 41 ▂▄▆ 12 ▂▄▆█ 33
|
|
124
124
|
```
|
|
125
125
|
|
|
126
|
-
- The first line is the
|
|
126
|
+
- The first line is the configured-rate estimate and its billing product: `API estimate · plan quota, not a charge` on a plan, `API estimate · configured rates, not an invoice` on an API key or credits, and `API estimate · credits ≈$4.10` for a mixed profile. See [How dollars are paid](#how-dollars-are-paid). **Usage** opens the Usage tab on this session.
|
|
127
127
|
- The second line is the difference and what the same tokens would have cost: `vs Opus 5.5 ≈$13.06` when every main reply was priced against your model and no subagent ran, else `vs unrouted ≈$13.06`. The parts add up: main and agents make the total, and their differences make the session's difference (−$4.17 + $0.08 = −$4.09). Before the tenth main reply a line follows: `3 replies so far: one model switch can still move this a lot`. A narrow pane drops the amount first.
|
|
128
128
|
- **main** compares the main thread with your model, **agents** compares the subagents with Claude Code's picks. The bars share one scale.
|
|
129
129
|
- An effort-only profile shows `effort routing on one model: no saving is estimated` and its effort mix instead. When some replies have no comparison, the block says how many and shows no saving.
|
|
@@ -161,31 +161,31 @@ main · 221 replies ≈$15.33 −$11.78 ≈$27.11
|
|
|
161
161
|
cache rebuilds +$0.51 4% of the saving
|
|
162
162
|
agents · 15 ≈$5.60 −$0.51 ≈$6.11
|
|
163
163
|
─────────────────────────────────────────────────────────────
|
|
164
|
-
7 days ·
|
|
164
|
+
7 days · API estimate ≈$20.93 −$12.29 ≈$33.22
|
|
165
165
|
```
|
|
166
166
|
|
|
167
167
|
| Row | What it is |
|
|
168
|
-
|
|
|
168
|
+
| --------------- | --------------------------------------------------------------------------------------------------------------- |
|
|
169
169
|
| main | The main thread's routed replies, against the same tokens on your model with one cache that never switched. |
|
|
170
170
|
| cheaper models | What routing saved on replies that ran on models cheaper than yours. |
|
|
171
171
|
| stronger models | What replies on models stronger than yours cost on top. Shown only when not zero. |
|
|
172
172
|
| cache rebuilds | What rewriting the prompt cache after a model switch cost, and its share of the saving. |
|
|
173
173
|
| agents | The subagents, against the same tokens on Claude Code's pick for each. |
|
|
174
|
-
| total
|
|
174
|
+
| total | The period's cost, its difference, and what unrouted would have cost: `API estimate` for every billing product. |
|
|
175
175
|
|
|
176
|
-
Each row reads across: cost − unrouted = the difference. Down the table, main and agents make the total, and cheaper models, stronger models and cache rebuilds make main's difference. A profile that mixes plan and credits models adds `
|
|
176
|
+
Each row reads across: cost − unrouted = the difference. Down the table, main and agents make the total, and cheaper models, stronger models and cache rebuilds make main's difference. A profile that mixes plan and credits models adds `credits estimate` under the total. Below 10 routed replies the difference adds `3 replies so far: one model switch can still move this a lot`, because one switch and its cache write can decide a short run.
|
|
177
177
|
|
|
178
|
-
When some replies have no comparison, the tab says `3 of 20 replies have no comparison: no saving is shown.`, and the table shows the cost alone. Counts, tokens, breakdowns and trends still include those replies; a row with incomplete coverage shows `—` against no routing, and **What if** stays unavailable rather than inventing a baseline. This is common with automatic provider caches, whose future hit rates are unknown. An effort-only profile says `Effort routing on one model: no saving is estimated;
|
|
178
|
+
When some replies have no comparison, the tab says `3 of 20 replies have no comparison: no saving is shown.`, and the table shows the cost alone. Counts, tokens, breakdowns and trends still include those replies; a row with incomplete coverage shows `—` against no routing, and **What if** stays unavailable rather than inventing a baseline. This is common with automatic provider caches, whose future hit rates are unknown. An effort-only profile says `Effort routing on one model: no saving is estimated; cost uses configured API rates.`
|
|
179
179
|
|
|
180
180
|
#### How dollars are paid
|
|
181
181
|
|
|
182
|
-
Every dollar in the band, `/router`, the Now tab and Usage
|
|
182
|
+
Every dollar in the band, `/router`, the Now tab and Usage estimates the reply's tokens at the configured API rates in `router.json` (vendor list rates or custom rates). Amounts use `≈` for every billing product. They are not invoices or measured plan-quota savings:
|
|
183
183
|
|
|
184
|
-
- **On a Claude plan
|
|
185
|
-
- **On an API key, or a provider billed in credits**,
|
|
186
|
-
- **A profile
|
|
184
|
+
- **On a Claude plan**, `≈$8.97 API estimate` is a configured-rate equivalent, not a charge or measured quota use. Claude Code's reported plan windows appear separately.
|
|
185
|
+
- **On an API key, or a provider billed in credits**, the same `≈$8.97 API estimate` applies. Gateway billing, discounts and invoice rates may differ.
|
|
186
|
+
- **A mixed profile**, such as [model-proxy](providers.md#mix-anthropic-and-deepseek-with-model-proxy), gets one sum and an estimated credits subtotal: `≈$24.10 API estimate · credits ≈$4.10`.
|
|
187
187
|
|
|
188
|
-
The router
|
|
188
|
+
The router identifies plan billing from Claude Code's reported plan windows, from the first reply on. Without those windows it treats the product as API/credits, but its dollars remain configured-rate estimates. `billing` in `router.json` controls the cold-cache credits cap, not the estimate's price basis. The router's dollars leave out what it does not see: titles, compaction, server-side tools and classifier charges. For the whole session cost, run Claude Code's `/cost`.
|
|
189
189
|
|
|
190
190
|
A line of counts follows the table: replies, turns, input tokens, the share of the input read from the cache, and output tokens. With routing off or unavailable and no routed reply this session, the tab says the replies use your model and are not counted.
|
|
191
191
|
|
|
@@ -223,7 +223,7 @@ These are estimates, not a bill. They hold the tokens and the output length the
|
|
|
223
223
|
|
|
224
224
|
On the Usage tab, **SUBAGENTS** covers the same period as the rest of the tab: this session, or every session in every project that uses this router install (`all projects`), since the last **Delete history**. Each agent is one square, colored by the model it ran on: filled (`■`) when the router moved it off the model Claude Code would have picked, hollow (`□`) when it ran on Claude Code's pick, because the router agreed or did not route it. The models and their agents follow the squares, then how many the router moved, and what routing saved or cost on the routed agents against Claude Code's picks, in the session's words: `routing −$0.10 (−13%) vs Claude Code’s picks on 3 routed agents`. 7d, 30d, Month and All add the agents per day. **ROUTED** lists each agent type the router picked a model for: its squares, agents, cost, and **vs CC**, the same tokens on Claude Code's pick. A row opens to its models, each with how many agents the router kept, moved up or moved down, and to its requests per agent, respawns and classifier failures. **NOT ROUTED** lists the agents Claude Code picked a model for, by reason, with why: `the workflow sets it`, `your model` for a fork, `its agent file sets it`. A row without any priced request says `no price`. Records from before 1.14.0 have no date or model: Session and All add them as one line, and an empty Today or 7d says so. See [Subagent routing](configuration.md#subagent-routing). On the Now tab, **details** adds the context and cache counters, the output of the last reply, the input per reply, and the estimates above.
|
|
225
225
|
|
|
226
|
-
The router keeps no bill. Its dollars are estimates at configured list
|
|
226
|
+
The router keeps no bill. Its dollars are estimates at configured API rates (list/custom) and leave out classifier charges and the side calls it does not see; run `/cost` for Claude Code's own session cost.
|
|
227
227
|
|
|
228
228
|
## Route by activity
|
|
229
229
|
|
|
@@ -239,7 +239,10 @@ A tier says how hard the work is. The goal says what the active task must delive
|
|
|
239
239
|
| `ops` | Executed commands: git, builds, test runs, CI, deploys |
|
|
240
240
|
| `docs` | Prose for people: README, docs, comments, commit messages |
|
|
241
241
|
|
|
242
|
-
A mixed turn such as "fix it and commit" keeps goal `code`. Verification and delivery steps can retain that goal while changing phase. A positively supported verification-only or execution-only phase can use the `ops` cell; mixed checks and fixes cannot.
|
|
242
|
+
A mixed turn such as "fix it and commit" keeps goal `code`. Verification and delivery steps can retain that goal while changing phase. A positively supported verification-only or execution-only phase can use the `ops` cell; mixed checks and fixes cannot. For goal `ops`, accepted `reason` uses the same-tier `debug` preference and `produce` uses `code`, without changing
|
|
243
|
+
the durable goal. Report or unclear phase keeps an eligible continuation or uses the fresh generic baseline; it
|
|
244
|
+
does not introduce a new ops discount. All preferences still pass the usual switching gates.
|
|
245
|
+
The router then picks the route by tier and activity. With the default overrides, a `low` coding turn runs on Sonnet 5.5 at `high`, a `low` git turn stays on Haiku 5.5 at `high`, and a `medium` git turn moves from Opus 5.5 to Haiku 5.5 at `high`. [Activity routing](activity-routing.md) explains the default matrix, why each cell is there, and how to change it.
|
|
243
246
|
|
|
244
247
|
The mode decides what happens with the label:
|
|
245
248
|
|
|
@@ -263,6 +266,21 @@ How the router moves inside a tier:
|
|
|
263
266
|
|
|
264
267
|
The band names the accepted goal and phase when available, and distinguishes the effective route activity: `code / verify → ops`. These are classifier estimates, not observed proof of the work done. The two-row band and the **Replies** strip show the activities of recent replies.
|
|
265
268
|
|
|
269
|
+
### Selection and request evidence
|
|
270
|
+
|
|
271
|
+
With no UI surface, `/router` distinguishes the selected model/effort, the **last recorded completed engine request**,
|
|
272
|
+
and the **response-reported model**. The completed-request snapshot changes only after an accepted reply, so it can
|
|
273
|
+
still name the previous request while the next one is pending or aborted. Delegation is not proof of API transmission or backend identity: Claude Code
|
|
274
|
+
can change or ignore settings, and a proxy can echo a requested model. API-transmitted and served effort remain
|
|
275
|
+
unknown; neither the band nor decision/usage records attest them. A record's effort is selected/delegated metadata,
|
|
276
|
+
not a response-reported setting.
|
|
277
|
+
|
|
278
|
+
Dollars use configured API-rate estimates (vendor list rates or custom profile rates), including tracked child
|
|
279
|
+
estimates where available. They are not invoices, measured subscription-quota savings, or cost per accepted task.
|
|
280
|
+
Missing pricing/comparison coverage stays visible in the existing Usage and classifier metrics. Decision `start`,
|
|
281
|
+
`review`, `observed`, and `end` rows describe routing events and coverage: `end` records requests, priced requests
|
|
282
|
+
and unpriced causes, not semantic success or task acceptance. A caller must evaluate task acceptance separately.
|
|
283
|
+
|
|
266
284
|
### Changes during a task
|
|
267
285
|
|
|
268
286
|
The classifier labels a turn from its prompt, and the work can change after that: a brief that reads as `ops` may turn into an hour of coding, and a hard fix may end in routine commands. The router therefore checks the route again while a task runs, for the tier and the activity, in both directions.
|
|
@@ -297,7 +315,7 @@ On Claude Code 2.1.322 an effort that the router changed inside a turn was not s
|
|
|
297
315
|
|
|
298
316
|
On the **Classifier** tab, **ACROSS SESSIONS · since the last reset** shows the counts kept across sessions, once there are any: the turns labelled from their tools, **Tool compatibility** over them, **Code/ops/explore**, the same agreement over the turns the classifier answered `code`, `ops` or `explore` (omitted when there are none), the two most frequent mismatches as `predicted → observed count` (`code → read 3`), **Activity moves**, the moves to another route inside a tier, taken and refused for any reason, **Escalations**, such as `after a cheaper activity move: 1 in 12 moves`, the tool-error escalations that followed a move to a cheaper route in `on` while the turns stayed on it in `on` (turning routing off, a turn with routing off, or a turn in `off` ends the watch, a pin in between does not, and an escalation the credits cap held counts). Each of these lines appears only when it has data. The active classifier's p95 wait across sessions shows on its **Deadline** line instead (not recorded with activity routing `off`). This agreement compares the classifier's raw answer, so it can differ from the session's. The pane reads these counts when the session starts and when it opens, and adds this session's turns as they finish; another session's new latency and escalation readings show the next time the pane opens. **Delete history** on the Usage tab deletes these counts with the usage and subagent records, for this session and across sessions.
|
|
299
317
|
|
|
300
|
-
`/router` without a UI surface distinguishes `Goal: code (95%)`, `Phase: verify` and `Route activity: ops`, followed by the resolved route. It labels tool compatibility explicitly as not accuracy. Goal-contract counters start a separate series; pre-change turn-label counters remain stored but are excluded until **Delete history** removes them. It also prints the session in the band's words, such as `Session:
|
|
318
|
+
`/router` without a UI surface distinguishes `Goal: code (95%)`, `Phase: verify` and `Route activity: ops`, followed by the resolved route. It labels tool compatibility explicitly as not accuracy. Goal-contract counters start a separate series; pre-change turn-label counters remain stored but are excluded until **Delete history** removes them. It also prints the session in the band's words, such as `Session: ≈$6.40 API estimate · −$1.84 (−22%) vs Opus 5.5 ≈$8.24 · 64 replies`, after a `Plan: 5h 48% · 7d 43%` line on a Claude plan.
|
|
301
319
|
|
|
302
320
|
## Change routing
|
|
303
321
|
|
package/hooks/native-router.mjs
CHANGED
|
@@ -743,8 +743,11 @@ function detailText(config, view, usage) {
|
|
|
743
743
|
...(view.routingMode ? [`Mode: ${modeLabel(view.routingMode)}`] : []),
|
|
744
744
|
...(view.projectError ? [`Ignored: ${view.projectError}`] : []),
|
|
745
745
|
`Native model: ${view.nativeModel}`,
|
|
746
|
-
`Selected: ${view.selectedModel ?? 'not selected'}`,
|
|
747
|
-
`
|
|
746
|
+
`Selected: ${view.selectedModel ?? 'not selected'} · effort ${view.effort ?? 'session/default'}`,
|
|
747
|
+
`Last recorded completed engine request: ${view.delegatedModel ?? 'none'} · effort ${view.delegatedEffort ?? 'session/default'}`,
|
|
748
|
+
`Response-reported model: ${view.actualModel ?? 'no response yet'}`,
|
|
749
|
+
'API-transmitted and served effort: unknown (engine delegation is not wire evidence).',
|
|
750
|
+
'Cost basis: configured API-rate estimates (list/custom), not bills or measured quota savings.',
|
|
748
751
|
`Reason: ${view.reason}`,
|
|
749
752
|
...activityDetailLines(config, view),
|
|
750
753
|
storeAgreementLine(view),
|
|
@@ -803,7 +806,12 @@ async function* passMain($, e, next, loop, version, nativeModel, reason, router)
|
|
|
803
806
|
const compared = await compareYours($, router, loop, response, e.effort ?? null, nativeModel);
|
|
804
807
|
if (compared) observed.yoursBy = compared.states;
|
|
805
808
|
const written = await $.state.set(ref, observed, { ifVersion: version });
|
|
806
|
-
if (written.isSet)
|
|
809
|
+
if (written.isSet)
|
|
810
|
+
await updateView($, router, {
|
|
811
|
+
...responseMetrics(router.view, response, null, Date.now()),
|
|
812
|
+
delegatedModel: e.model,
|
|
813
|
+
delegatedEffort: e.effort ?? null,
|
|
814
|
+
});
|
|
807
815
|
}
|
|
808
816
|
return response;
|
|
809
817
|
}
|
|
@@ -1164,10 +1172,14 @@ async function reviewMidTurn($, router, cfg, loop, e, { context, nativeModel, av
|
|
|
1164
1172
|
}
|
|
1165
1173
|
|
|
1166
1174
|
// A routed reply's metrics in the view, with the tier that served it, and added to the turn's activity record with its list price (`routedUsd`, null when unpriced) and, when its tier served it, its route.
|
|
1167
|
-
async function publishReply($, router, turnId, response, tier, route, routedUsd, cause = null) {
|
|
1175
|
+
async function publishReply($, router, turnId, request, response, tier, route, routedUsd, cause = null) {
|
|
1168
1176
|
const turn = router.turnActivities.get(turnId);
|
|
1169
1177
|
const metrics = responseMetrics(router.view, response, tier, Date.now());
|
|
1170
|
-
await updateView($, router,
|
|
1178
|
+
await updateView($, router, {
|
|
1179
|
+
...metrics,
|
|
1180
|
+
delegatedModel: request.model,
|
|
1181
|
+
delegatedEffort: request.effort ?? null,
|
|
1182
|
+
});
|
|
1171
1183
|
if (turn)
|
|
1172
1184
|
router.turnActivities.set(turnId, {
|
|
1173
1185
|
...turn,
|
|
@@ -1217,7 +1229,7 @@ async function observeRouted($, router, { turnId, cfg, loop, loopVersion, reques
|
|
|
1217
1229
|
yours: { model: nativeModel },
|
|
1218
1230
|
ttl: compared.ttl,
|
|
1219
1231
|
}) ?? 'error');
|
|
1220
|
-
await publishReply($, router, turnId, response, tier, route, observedUsd, cause);
|
|
1232
|
+
await publishReply($, router, turnId, request, response, tier, route, observedUsd, cause);
|
|
1221
1233
|
// Kept by model id, under the model that served it: a substitute's cost is not the requested model's, and a models
|
|
1222
1234
|
// key can name another model later.
|
|
1223
1235
|
const idOf = (model) => modelSpec(cfg, model)?.id ?? model;
|
package/lib/activity.mjs
CHANGED
|
@@ -20,15 +20,27 @@ export function acceptPhase(config, advice) {
|
|
|
20
20
|
return answer.probabilities?.[answer.choice] >= config.policy.activityMass ? answer.choice : null;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
export function opsWorkActivity(config, advice) {
|
|
24
|
+
if (acceptActivity(config, advice) !== 'ops') return null;
|
|
25
|
+
const phase = acceptPhase(config, advice);
|
|
26
|
+
return phase === 'reason' ? 'debug' : phase === 'produce' ? 'code' : null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Phase chooses a work preference, never a new durable goal. Ops discounts require positive bounded evidence;
|
|
30
|
+
// adaptive ops uses the profile's same-tier engineering floor, not its potentially weaker generic row.
|
|
24
31
|
// The minimum is a conservative support floor, not a multiplied or calibrated joint probability.
|
|
25
32
|
export function routingActivity(config, advice) {
|
|
26
33
|
const answer = advice?.activity;
|
|
27
34
|
if (!answer) return null;
|
|
28
35
|
const phase = acceptPhase(config, advice);
|
|
29
36
|
const mass = answer.probabilities?.[answer.choice] ?? 0;
|
|
30
|
-
|
|
31
|
-
|
|
37
|
+
const goal = acceptActivity(config, advice);
|
|
38
|
+
const supported = phase ? Math.min(mass, advice.phase.probabilities[phase]) : mass;
|
|
39
|
+
if (goal && (phase === 'verify' || phase === 'execute')) return { choice: 'ops', mass: supported };
|
|
40
|
+
if (goal === 'ops') {
|
|
41
|
+
const floor = opsWorkActivity(config, advice);
|
|
42
|
+
return floor ? { choice: floor, mass: supported } : null;
|
|
43
|
+
}
|
|
32
44
|
return { choice: answer.choice, mass };
|
|
33
45
|
}
|
|
34
46
|
|
|
@@ -37,20 +49,14 @@ const acceptRoutingActivity = (config, advice) => {
|
|
|
37
49
|
return ACTIVITIES.includes(signal?.choice) && signal.mass >= config.policy.activityMass ? signal.choice : null;
|
|
38
50
|
};
|
|
39
51
|
|
|
40
|
-
// 1 when route `a` is stronger than `b`, -1 when
|
|
41
|
-
//
|
|
42
|
-
//
|
|
43
|
-
// efforts do not order. A missing output price orders only against the same model.
|
|
52
|
+
// 1 when route `a` is stronger than `b`, -1 when weaker, 0 when equal in declared strength, null when unordered.
|
|
53
|
+
// Different models require declared strength ranks; tariffs are economics, not capability evidence. Equal declared
|
|
54
|
+
// ranks compare by effort. A null effort is the one handed to Claude Code; absent or numeric efforts do not order.
|
|
44
55
|
export function compareRoutes(config, a, b, sentEffort) {
|
|
45
56
|
if (a.model !== b.model) {
|
|
46
|
-
const [pa, pb] = [routeSpec(config, a).output, routeSpec(config, b).output];
|
|
47
57
|
const [sa, sb] = [routeSpec(config, a).strength, routeSpec(config, b).strength];
|
|
48
|
-
if (Number.isFinite(sa)
|
|
49
|
-
|
|
50
|
-
} else {
|
|
51
|
-
if (!Number.isFinite(pa) || !Number.isFinite(pb)) return null;
|
|
52
|
-
if (pa !== pb) return Math.sign(pa - pb);
|
|
53
|
-
}
|
|
58
|
+
if (!Number.isFinite(sa) || !Number.isFinite(sb)) return null;
|
|
59
|
+
if (sa !== sb) return Math.sign(sa - sb);
|
|
54
60
|
}
|
|
55
61
|
const [ea, eb] = [routeEffort(config, a, sentEffort), routeEffort(config, b, sentEffort)];
|
|
56
62
|
if (ea === eb) return 0;
|
|
@@ -67,24 +73,35 @@ export const sameRequest = (config, a, b, sentEffort) =>
|
|
|
67
73
|
// stays: a flaky step must not move the route every turn. On the same task (sameTaskOf: a review inside a turn, a turn
|
|
68
74
|
// with a progress origin, or a continuation prompt) a stronger label is taken at once (explore, then code), and a weaker
|
|
69
75
|
// one only with at least `downgradeMass` probability once facts.downAllowed holds: the dwell has passed and a checkpoint
|
|
70
|
-
// (completedSince) since the last model change. An unclear label keeps the running activity.
|
|
76
|
+
// (completedSince) since the last model change. An unclear label keeps the running activity. The nomination carries
|
|
77
|
+
// its floor provenance; a later physical refusal must restore the incumbent's accepted provenance.
|
|
71
78
|
export function chooseActivity(config, advice, incumbent, sentEffort, facts = {}) {
|
|
72
|
-
|
|
73
|
-
|
|
79
|
+
const floor = opsWorkActivity(config, advice);
|
|
80
|
+
const stay = { activity: incumbent.activity, floorActivity: floor ? (incumbent.floorActivity ?? null) : null };
|
|
81
|
+
const nominate = (activity) => ({ activity, floorActivity: activity === floor ? floor : null });
|
|
82
|
+
if (!advice?.activity) return stay;
|
|
83
|
+
if (!sameTaskOf(config, advice, facts)) return nominate(acceptRoutingActivity(config, advice));
|
|
74
84
|
const signal = routingActivity(config, advice);
|
|
75
|
-
const label = signal
|
|
76
|
-
if (!ACTIVITIES.includes(label)) return
|
|
77
|
-
const
|
|
78
|
-
|
|
85
|
+
const label = signal?.choice;
|
|
86
|
+
if (!ACTIVITIES.includes(label)) return stay;
|
|
87
|
+
const candidate = resolveRoute(config, incumbent.tier, label);
|
|
88
|
+
const order = compareRoutes(config, candidate, incumbent.route, sentEffort);
|
|
89
|
+
if (order > 0) return nominate(label);
|
|
90
|
+
// An explicitly declared ops work floor may be nominated without inventing a physical-model ranking.
|
|
91
|
+
// The lateral confidence/cache/hold/cash gates still decide; inherited generic cells get no exception.
|
|
92
|
+
// Equal requests can adopt the semantic work preference without a model/effort switch. Higher tiers may differ.
|
|
93
|
+
if (label === floor && sameRequest(config, candidate, incumbent.route, sentEffort)) return nominate(label);
|
|
94
|
+
const declared = config.configuredActivities ?? config.activities;
|
|
95
|
+
if (order === null && label === floor && declared[label]?.[incumbent.tier]) return nominate(label);
|
|
79
96
|
const mass = signal.mass;
|
|
80
|
-
if (order < 0 && facts.downAllowed && mass >= config.policy.downgradeMass) return label;
|
|
81
|
-
return
|
|
97
|
+
if (order < 0 && facts.downAllowed && mass >= config.policy.downgradeMass) return nominate(label);
|
|
98
|
+
return stay;
|
|
82
99
|
}
|
|
83
100
|
|
|
84
101
|
// A route change inside the incumbent's tier, `from` → `to`. Up on evidence: `mass`, the label's probability (1 for
|
|
85
102
|
// the base route), must clear the tier upgrade bar for this switching tax. Down on economics: the move must pay back
|
|
86
|
-
// its cache write within the downgrade horizon. A pair that does not order (
|
|
87
|
-
//
|
|
103
|
+
// its cache write within the downgrade horizon. A pair that does not order (unknown strength or a numeric effort)
|
|
104
|
+
// counts as up: it needs evidence, and the base route is always reachable. Labels alone never
|
|
88
105
|
// switch, so one vote is enough. During an escalation hold only a stronger route may be taken. A cheaper route on the
|
|
89
106
|
// same task (`sameTask`) waits for facts.downAllowed, as a tier downgrade does: a routing mode changes the route
|
|
90
107
|
// without a new label, and a free switch must still wait out the dwell. A model with a lower input price also counts
|
package/lib/band.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { activeClassifier, resolveRoute, TIERS } from './config.mjs';
|
|
2
2
|
import { resetText } from './costs.mjs';
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
API_ESTIMATE,
|
|
5
5
|
baselineName,
|
|
6
6
|
classifierLabel,
|
|
7
7
|
classifierStatus,
|
|
@@ -268,7 +268,7 @@ export function bandSegments(config, view, usage, actions) {
|
|
|
268
268
|
|
|
269
269
|
// The second row: the plan windows on a Claude plan, then this session's cost with its subagents, and how it compares
|
|
270
270
|
// with your /model (or `unrouted` with subagents):
|
|
271
|
-
// "plan 5h ▰▰▰▱▱▱▱▱ 37% ↻17:00 7d 62% session ≈$7.60 API
|
|
271
|
+
// "plan 5h ▰▰▰▱▱▱▱▱ 37% ↻17:00 7d 62% session ≈$7.60 API estimate −$1.76 (−19%) vs Sonnet 5.5 24 replies".
|
|
272
272
|
// An effort-only profile shows its effort mix instead of a saving. When the band is narrow the reset time, the
|
|
273
273
|
// counts and the words go first; the 5h window and the session total stay.
|
|
274
274
|
export function sessionSegments(config, view, usage, now = Date.now()) {
|
|
@@ -296,11 +296,11 @@ export function sessionSegments(config, view, usage, now = Date.now()) {
|
|
|
296
296
|
if (!cost.replies && !cost.agents) return [...out, segment(2, dim('session · no replies yet'))].filter(Boolean);
|
|
297
297
|
out.push(
|
|
298
298
|
segment(0, dim('session '), part(costText(cost.totalUsd, cost.billing), { bold: true }), {
|
|
299
|
-
...dim(` ${
|
|
299
|
+
...dim(` ${API_ESTIMATE}`),
|
|
300
300
|
priority: 5,
|
|
301
301
|
}),
|
|
302
302
|
);
|
|
303
|
-
if (cost.billing === 'mixed') out.push(segment(1, part(`
|
|
303
|
+
if (cost.billing === 'mixed') out.push(segment(1, part(`credits ${costText(cost.creditsUsd, cost.billing)}`)));
|
|
304
304
|
if (cost.effortOnly && cost.effortMix.length)
|
|
305
305
|
out.push(segment(2, dim('effort '), part(cost.effortMix.map(([effort, n]) => `${effort} ${n}`).join(' · '))));
|
|
306
306
|
else if (cost.diffUsd !== null)
|
package/lib/config.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Defaults, user overrides and validation. Pure: callers pass env and the parsed user file.
|
|
2
2
|
|
|
3
3
|
import { listPrice } from './prices.mjs';
|
|
4
|
-
import { executionDefaults, providerName } from './providers.mjs';
|
|
4
|
+
import { canonicalModel, executionDefaults, providerName } from './providers.mjs';
|
|
5
5
|
|
|
6
6
|
export const TIERS = ['micro', 'low', 'medium', 'high'];
|
|
7
7
|
export const EFFORTS = ['low', 'medium', 'high', 'xhigh', 'max'];
|
|
@@ -82,6 +82,7 @@ export const DEFAULTS = {
|
|
|
82
82
|
models: {
|
|
83
83
|
fable: {
|
|
84
84
|
id: 'claude-fable-5-2',
|
|
85
|
+
strength: 4,
|
|
85
86
|
...listPrice('claude-fable-5-2'),
|
|
86
87
|
contextWindow: 1_000_000,
|
|
87
88
|
billing: 'plan',
|
|
@@ -89,6 +90,7 @@ export const DEFAULTS = {
|
|
|
89
90
|
},
|
|
90
91
|
opus: {
|
|
91
92
|
id: 'claude-opus-5-5',
|
|
93
|
+
strength: 3,
|
|
92
94
|
...listPrice('claude-opus-5-5'),
|
|
93
95
|
contextWindow: 1_000_000,
|
|
94
96
|
billing: 'plan',
|
|
@@ -96,6 +98,7 @@ export const DEFAULTS = {
|
|
|
96
98
|
},
|
|
97
99
|
sonnet: {
|
|
98
100
|
id: 'claude-sonnet-5-5',
|
|
101
|
+
strength: 2,
|
|
99
102
|
...listPrice('claude-sonnet-5-5'),
|
|
100
103
|
contextWindow: 1_000_000,
|
|
101
104
|
billing: 'plan',
|
|
@@ -103,6 +106,7 @@ export const DEFAULTS = {
|
|
|
103
106
|
},
|
|
104
107
|
haiku: {
|
|
105
108
|
id: 'claude-haiku-5-5',
|
|
109
|
+
strength: 1,
|
|
106
110
|
...listPrice('claude-haiku-5-5'),
|
|
107
111
|
contextWindow: 1_000_000,
|
|
108
112
|
billing: 'plan',
|
|
@@ -277,7 +281,16 @@ export const defaultsFor = (provider = 'anthropic') => executionDefaults(provide
|
|
|
277
281
|
export function loadConfig({ userFile = null, provider = 'anthropic' } = {}) {
|
|
278
282
|
provider = providerName(provider);
|
|
279
283
|
if (userFile !== null) checkShape(userFile);
|
|
280
|
-
const
|
|
284
|
+
const defaults = defaultsFor(provider);
|
|
285
|
+
const merged = merge(structuredClone(defaults), withoutShadow(userFile ?? {}));
|
|
286
|
+
// Reusing a preset alias for a different model is not a declaration of equal capability.
|
|
287
|
+
for (const [alias, patch] of Object.entries(userFile?.models ?? {}))
|
|
288
|
+
if (
|
|
289
|
+
patch.id &&
|
|
290
|
+
canonicalModel(patch.id) !== canonicalModel(defaults.models[alias]?.id) &&
|
|
291
|
+
!Object.hasOwn(patch, 'strength')
|
|
292
|
+
)
|
|
293
|
+
delete merged.models[alias].strength;
|
|
281
294
|
// A user entry without `api` speaks the System One protocol that every entry spoke before 1.5.
|
|
282
295
|
const config = {
|
|
283
296
|
...merged,
|
package/lib/costs.mjs
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// numbers at the same moment. Pure: the inputs are the period's usage summary (usage.mjs), its subagent summary
|
|
3
3
|
// (subagents.mjs), the configured models and Claude Code's plan windows.
|
|
4
4
|
//
|
|
5
|
-
// Every dollar
|
|
6
|
-
//
|
|
5
|
+
// Every dollar estimates tokens at the router file's configured API rates (list/custom), never an invoice or measured
|
|
6
|
+
// quota use. The billing product only distinguishes plan quota from API/credits. "No routing" is what
|
|
7
7
|
// the same tokens cost without the router: your model on the main thread, Claude Code's pick for each subagent.
|
|
8
8
|
|
|
9
9
|
import { EFFORTS, TIERS } from './config.mjs';
|
package/lib/display.mjs
CHANGED
|
@@ -380,7 +380,7 @@ export function savingsLine(config, view, usage, now) {
|
|
|
380
380
|
const lines = plan ? [`Plan: ${plan}`] : [];
|
|
381
381
|
if (!cost.replies && !cost.agents) return [...lines, 'Session: no routed replies yet'].join('\n');
|
|
382
382
|
const split = cost.agents ? ` (main ${usd(cost.mainUsd)} + agents ${usd(cost.agentUsd)})` : '';
|
|
383
|
-
const credits = cost.creditsUsd ? ` ·
|
|
383
|
+
const credits = cost.creditsUsd ? ` · credits ${costText(cost.creditsUsd, cost.billing)}` : '';
|
|
384
384
|
const versus =
|
|
385
385
|
cost.diffUsd !== null
|
|
386
386
|
? ` · ${diffText(cost.diffUsd, cost.baseUsd)} vs ${baselineName(view, sessionUsage(view, now), cost)} ${costText(cost.baseUsd, cost.billing)}`
|
|
@@ -388,7 +388,7 @@ export function savingsLine(config, view, usage, now) {
|
|
|
388
388
|
? ` · effort ${cost.effortMix.map(([effort, n]) => `${effort} ${n}`).join(' · ')}`
|
|
389
389
|
: ` · ${uncomparedText(cost)}`;
|
|
390
390
|
lines.push(
|
|
391
|
-
`Session: ${costText(cost.totalUsd, cost.billing)} ${
|
|
391
|
+
`Session: ${costText(cost.totalUsd, cost.billing)} ${API_ESTIMATE}${split}${credits}${versus} · ${repliesText(cost)}`,
|
|
392
392
|
);
|
|
393
393
|
return lines.join('\n');
|
|
394
394
|
}
|
|
@@ -479,9 +479,9 @@ export function shortRoute(config, route) {
|
|
|
479
479
|
const METER = '▂▄▆█';
|
|
480
480
|
export const tierBars = (tier) => METER.slice(0, TIERS.indexOf(tier) + 1);
|
|
481
481
|
|
|
482
|
-
//
|
|
483
|
-
export const costText = (value,
|
|
484
|
-
export const
|
|
482
|
+
// All amounts price observed tokens at configured rates, irrespective of the billing product.
|
|
483
|
+
export const costText = (value, _billing) => `≈${usd(value)}`;
|
|
484
|
+
export const API_ESTIMATE = 'API estimate';
|
|
485
485
|
// "−$1.76 (−19%)", or "+$2.48 (×5.0)" past double; one format for every difference against no routing.
|
|
486
486
|
export function diffText(diff, base) {
|
|
487
487
|
const share = base > 0 ? Math.round((diff / base) * 100) : 0;
|
package/lib/modes.mjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// classifier and the configured routes stay as they are; the mode moves each tier's route by one fixed step. Pure.
|
|
3
3
|
import { ACTIVITIES, DEFAULTS, EFFORTS, ROUTING_MODES, rank, resolveRoute, sameRoute, TIERS } from './config.mjs';
|
|
4
4
|
import { clampEffort } from './cost.mjs';
|
|
5
|
+
import { canonicalModel } from './providers.mjs';
|
|
5
6
|
|
|
6
7
|
// The route's effort one level up (`step` 1) or down (-1), on what the model lists; null when it cannot move that
|
|
7
8
|
// way: a null effort (the session's), a model without efforts, or no listed level in that direction. The model's
|
|
@@ -31,6 +32,14 @@ export function modeRoute(config, mode, tier, activity = null) {
|
|
|
31
32
|
const effort = steppedEffort(config, route, -1);
|
|
32
33
|
return effort ? { model: route.model, effort } : route;
|
|
33
34
|
}
|
|
35
|
+
// Haiku's documented xhigh empty-answer risk is not a provider-wide effort limit. Preserve explicit higher
|
|
36
|
+
// efforts and session effort; only the automatic promotion prefers High, except medium bounded ops.
|
|
37
|
+
const model = config.models[route.model];
|
|
38
|
+
if (canonicalModel(model.id).replace(/-\d{8}$/, '') === 'claude-haiku-5-5' && route.effort) {
|
|
39
|
+
if (['xhigh', 'max'].includes(route.effort)) return route;
|
|
40
|
+
if (!(tier === 'medium' && activity === 'ops') && model.efforts.includes('high'))
|
|
41
|
+
return { model: route.model, effort: 'high' };
|
|
42
|
+
}
|
|
34
43
|
const effort = steppedEffort(config, route, 1);
|
|
35
44
|
return effort ? { model: route.model, effort } : routeAt(TIERS[Math.min(TIERS.length - 1, rank(tier) + 1)]);
|
|
36
45
|
}
|
|
@@ -50,7 +59,9 @@ export function applyMode(config, routingMode) {
|
|
|
50
59
|
const route = modeRoute(config, mode, tier, activity);
|
|
51
60
|
if (!sameRoute(route, routes[tier])) activities[activity] = { ...activities[activity], [tier]: route };
|
|
52
61
|
}
|
|
53
|
-
|
|
62
|
+
// The sparse effective table can erase an explicit use-tier cell or add an inherited mode preference.
|
|
63
|
+
// Preserve the original declarations so phase floors never override an explicit user cell.
|
|
64
|
+
return { ...config, routes, activities, configuredActivities: config.activities, policy, routingMode };
|
|
54
65
|
}
|
|
55
66
|
|
|
56
67
|
// The active mode and its source: a session override, then the project file, then the profile router.json.
|
package/lib/panel.mjs
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
import { effortSharesCache, routeEffort } from './cost.mjs';
|
|
18
18
|
import { periodCost, resetText } from './costs.mjs';
|
|
19
19
|
import {
|
|
20
|
+
API_ESTIMATE,
|
|
20
21
|
activityReading,
|
|
21
22
|
baselineName,
|
|
22
23
|
classifierLabel,
|
|
@@ -434,11 +435,11 @@ function planLines(ui, cost, now) {
|
|
|
434
435
|
];
|
|
435
436
|
}
|
|
436
437
|
|
|
437
|
-
//
|
|
438
|
+
// The estimate's billing product is context, never evidence of an invoice or measured quota use.
|
|
438
439
|
function billingWords(cost) {
|
|
439
|
-
if (cost.billing === 'plan') return
|
|
440
|
-
if (cost.billing === 'mixed') return
|
|
441
|
-
return
|
|
440
|
+
if (cost.billing === 'plan') return `${API_ESTIMATE} · plan quota, not a charge`;
|
|
441
|
+
if (cost.billing === 'mixed') return `${API_ESTIMATE} · credits ${costText(cost.creditsUsd, cost.billing)}`;
|
|
442
|
+
return `${API_ESTIMATE} · configured rates, not an invoice`;
|
|
442
443
|
}
|
|
443
444
|
|
|
444
445
|
// SESSION: one total with the subagents, the difference against no routing, the main thread and the subagents as bars
|
|
@@ -632,7 +633,7 @@ function readingDetail(ui, view, metrics) {
|
|
|
632
633
|
ui.head(`INPUT PER REPLY · last ${plural(history.length, 'reply', 'replies')} · lowest to highest`),
|
|
633
634
|
trend,
|
|
634
635
|
ui.text(' '),
|
|
635
|
-
ui.head('ESTIMATES · configured
|
|
636
|
+
ui.head('ESTIMATES · configured API rates'),
|
|
636
637
|
ui.text(`Cache hits saved ${dollars(metrics.cacheBenefit)}`),
|
|
637
638
|
Number.isFinite(view.estimate?.taxUsd) ? ui.text(`Switch cost ${dollars(view.estimate.taxUsd)}`) : null,
|
|
638
639
|
...(view.comparison
|
|
@@ -1345,8 +1346,8 @@ function storeUsage(ui, store, metrics) {
|
|
|
1345
1346
|
// The footer as [text, joiner] pieces, packed to the pane: two lines at full width, more in a narrow pane, never a
|
|
1346
1347
|
// line that ends in a joiner.
|
|
1347
1348
|
const SAVINGS_FOOTER = [
|
|
1348
|
-
['
|
|
1349
|
-
['
|
|
1349
|
+
['≈$ = tokens × configured API rates (list/custom)', ' · '],
|
|
1350
|
+
['not invoices or measured quota savings', ' · '],
|
|
1350
1351
|
['answer quality not measured', ''],
|
|
1351
1352
|
];
|
|
1352
1353
|
const FULL_WIDTH = 68;
|
|
@@ -1665,7 +1666,9 @@ function subagentUsage(ui, config, view, actions, period, now, columns, billing)
|
|
|
1665
1666
|
out.push(
|
|
1666
1667
|
ui.text(' '),
|
|
1667
1668
|
...dimLines(ui, ' ■ moved by the router · □ Claude Code’s pick · color: the model', columns),
|
|
1668
|
-
...(routed.length
|
|
1669
|
+
...(routed.length
|
|
1670
|
+
? dimLines(ui, ' vs CC: the same tokens on Claude Code’s pick, at configured API rates', columns)
|
|
1671
|
+
: []),
|
|
1669
1672
|
);
|
|
1670
1673
|
return out;
|
|
1671
1674
|
}
|
|
@@ -2063,7 +2066,7 @@ function costHeadline(ui, cost) {
|
|
|
2063
2066
|
);
|
|
2064
2067
|
return ui.dim(
|
|
2065
2068
|
cost.effortOnly
|
|
2066
|
-
? 'Effort routing on one model: no saving is estimated;
|
|
2069
|
+
? 'Effort routing on one model: no saving is estimated; cost uses configured API rates.'
|
|
2067
2070
|
: `${uncomparedText(cost).replace(/^./, (c) => c.toUpperCase())}: no saving is shown.`,
|
|
2068
2071
|
);
|
|
2069
2072
|
}
|
|
@@ -2074,7 +2077,7 @@ function costTable(ui, config, view, period, cost, legacy, actions, columns) {
|
|
|
2074
2077
|
if (!cost.replies && !cost.agents) return emptyCost(ui, config, view, period);
|
|
2075
2078
|
const compared = cost.diffUsd !== null;
|
|
2076
2079
|
const r = cost.readout;
|
|
2077
|
-
//
|
|
2080
|
+
// All products use configured-rate estimates, including the credits subtotal.
|
|
2078
2081
|
const row = (label, amount, diff, base, style = {}, billing = cost.billing) =>
|
|
2079
2082
|
ui.line(
|
|
2080
2083
|
ui.cell(COST_LABEL, ui.text(label, style)),
|
|
@@ -2132,14 +2135,8 @@ function costTable(ui, config, view, period, cost, legacy, actions, columns) {
|
|
|
2132
2135
|
)
|
|
2133
2136
|
: null,
|
|
2134
2137
|
ui.dim('─'.repeat(COST_LABEL + COST_AMOUNT + (compared ? COST_DIFF + COST_BASE : 0))),
|
|
2135
|
-
row(
|
|
2136
|
-
|
|
2137
|
-
cost.totalUsd,
|
|
2138
|
-
cost.diffUsd,
|
|
2139
|
-
cost.baseUsd,
|
|
2140
|
-
{ bold: true },
|
|
2141
|
-
),
|
|
2142
|
-
cost.billing === 'mixed' ? row(' billed as credits', cost.creditsUsd, null, null, {}, 'billed') : null,
|
|
2138
|
+
row(`${total} · ${API_ESTIMATE}`, cost.totalUsd, cost.diffUsd, cost.baseUsd, { bold: true }),
|
|
2139
|
+
cost.billing === 'mixed' ? row(' credits estimate', cost.creditsUsd, null, null, {}, 'billed') : null,
|
|
2143
2140
|
].filter(Boolean);
|
|
2144
2141
|
if (legacy?.replies)
|
|
2145
2142
|
out.push(
|
|
@@ -2161,8 +2158,8 @@ const COST_BASE = 12;
|
|
|
2161
2158
|
function helpLines(ui) {
|
|
2162
2159
|
return [
|
|
2163
2160
|
ui.head('ABOUT THESE NUMBERS'),
|
|
2164
|
-
ui.dim('
|
|
2165
|
-
ui.dim('
|
|
2161
|
+
ui.dim('≈$ is tokens × configured API rates in router.json (list/custom).'),
|
|
2162
|
+
ui.dim('These are estimates, not invoices or measured plan-quota savings.'),
|
|
2166
2163
|
ui.dim('No routing: your model on the main thread, Claude Code’s pick per agent,'),
|
|
2167
2164
|
ui.dim('same tokens and output length. Answer quality is not measured.'),
|
|
2168
2165
|
ui.dim('For the whole session cost, with side calls such as titles and compaction'),
|