@alexeiled/claude-router 1.2.0 → 1.3.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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "router",
3
3
  "displayName": "Router",
4
- "version": "1.2.0",
4
+ "version": "1.3.0",
5
5
  "description": "Model and effort routing for the main conversation, advised by a prompt classifier (Jev, Clef or Clef Flash). Preserves subagent model choices.",
6
6
  "author": {
7
7
  "name": "Alexei Ledenev",
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.3.0 (2026-10-06)
4
+
5
+ ### Changed
6
+
7
+ - The pane's settings follow one rule per tab. **Routing** (was Tiers, now with the policy controls) edits routes and policy as one draft with one **Save** (`s`) and **Discard** (`d`). **Classifier** (was the classifier part of Tuning) writes a row or a deadline at once.
8
+ - Unsaved routing changes show on every tab: the tab reads **Routing ●**, and the status bar lists the `router.json` lines **Save** will write. The draft stays when you change tab or close the pane, and a new session drops it.
9
+ - **Undo** (`u`) puts back the settings the last pane write changed, from any tab: a classifier, a deadline, or a routing save. It writes back what `router.json` held before that write, so a hand edit elsewhere in the file stays. It no longer goes away when you change tab.
10
+ - **Reset policy to defaults** joins **Reset routes to defaults**. A policy value equal to its default is removed from `router.json`, as routes and deadlines already were.
11
+ - Notices sit in the status bar: green for a write or an undo, red for a refused write. In Manual the pin buttons give way to "Pins need Auto". **Manual: keep /model** is now **Manual**.
12
+
13
+ ### Fixed
14
+
15
+ - The pane opened with the notice from the last press before it was closed. It now opens without one; the last write keeps its **Undo**.
16
+
3
17
  ## 1.2.0 (2026-10-05)
4
18
 
5
19
  ### Added
package/README.md CHANGED
@@ -56,7 +56,7 @@ claude plugin marketplace add alexei-led/claude-router
56
56
  claude plugin install router@alexei-led-claude-router
57
57
  ```
58
58
 
59
- Start Claude Code on the full baseline model, for example `claude --model claude-sonnet-5-5`. Run `/plugin configure router` and save the key. For Clef or Clef Flash, save the Cloudflare token and account ID, then pick the classifier on the pane's Tuning tab. A session on the baseline model starts in Auto; on another model it starts in Manual, and `/router auto` turns routing on.
59
+ Start Claude Code on the full baseline model, for example `claude --model claude-sonnet-5-5`. Run `/plugin configure router` and save the key. For Clef or Clef Flash, save the Cloudflare token and account ID, then pick the classifier on the pane's Classifier tab. A session on the baseline model starts in Auto; on another model it starts in Manual, and `/router auto` turns routing on.
60
60
 
61
61
  Claude Code updates the plugin at startup when auto-update is on for this marketplace. Otherwise run `claude plugin marketplace update alexei-led-claude-router`, then `claude plugin update router@alexei-led-claude-router`.
62
62
 
@@ -9,7 +9,7 @@ The router works with its built-in defaults. Configure the key of the active cla
9
9
  | Jev API key | Sensitive plugin option `typesafe_api_key` | Run `/plugin configure router`, or use **Set up** or **Credentials → Edit** in the router pane. |
10
10
  | Cloudflare API token | Sensitive plugin option `cloudflare_api_token` | The same dialog. Used by Clef and Clef Flash. |
11
11
  | Cloudflare account ID | Plugin option `cloudflare_account_id` | The same dialog, or the config menu row. Not a secret. |
12
- | Router settings and classifier | `router.json` in the active Claude Code profile | Edit the file directly, or use the pane's Tiers and Tuning tabs. |
12
+ | Router settings and classifier | `router.json` in the active Claude Code profile | Edit the file directly, or use the pane's Routing and Classifier tabs. |
13
13
  | Anthropic credentials and API cost | Claude Code | The Mod leaves these to Claude Code. |
14
14
 
15
15
  The active profile directory is `CLAUDE_CONFIG_DIR` when set. Otherwise it is `~/.claude`. The Mod does not need an Anthropic proxy URL, model alias, hint header, daemon, or custom status line.
@@ -57,7 +57,7 @@ Prices are configured list-price inputs for estimates. They are not a subscripti
57
57
  | `clef` | `https://api.cloudflare.com/client/v4/accounts/{cloudflare_account_id}/ai/run/@cf/cloudflare/clef` | `clef` | `cloudflare_api_token` | `3000` |
58
58
  | `clef-flash` | `https://api.cloudflare.com/client/v4/accounts/{cloudflare_account_id}/ai/run/@cf/cloudflare/clef-flash` | `clef-flash` | `cloudflare_api_token` | `3000` |
59
59
 
60
- `jev` is the default. Select another one with a row in the pane's **Tuning → Classifier**, or in `router.json`:
60
+ `jev` is the default. Select another one with a row on the pane's **Classifier** tab, or in `router.json`:
61
61
 
62
62
  ```json
63
63
  { "classifier": "clef-flash" }
@@ -128,7 +128,7 @@ Policy defaults:
128
128
  | `escalationHoldTurns` | `2` | Turns held after a repeated tool error escalates the route. |
129
129
  | `cashCapUsd` | `2` | Maximum estimated cold cache write for a `credits` model. It does not cap output or session spend. |
130
130
 
131
- The pane writes a subset of these settings. The **Tiers** tab sets `routes` and `baselineTier`: it writes only tiers that differ from the defaults and removes the rest. The **Tuning** tab sets `classifier` and the active classifier's `timeoutMs` at once, and `policy.downgradeVotes`, `policy.downgradeHorizonTurns`, and `policy.cashCapUsd`. Each save validates the whole file, keeps other keys, and applies from the next turn. A failed check names the setting and leaves the file unchanged. The pane refuses to write through a symlink. Model aliases and the other settings require a direct edit.
131
+ The pane writes a subset of these settings. The **Routing** tab sets `routes`, `baselineTier`, `policy.downgradeVotes`, `policy.downgradeHorizonTurns`, and `policy.cashCapUsd` in one save: it writes only values that differ from the defaults and removes the rest. The **Classifier** tab sets `classifier` and the active classifier's `timeoutMs` at once. **Undo** reverts the settings the last pane write changed. Each save validates the whole file, keeps other keys, and applies from the next turn. A failed check names the setting and leaves the file unchanged. The pane refuses to write through a symlink. Model aliases and the other settings require a direct edit.
132
132
 
133
133
  Native cache freshness is unknown after 270 seconds or after a history reset. Claude usage does not report the cache TTL. The policy evaluates price bounds for five-minute and one-hour writes, but the one-hour case is not observed fact. See the [architecture](architecture.md#cache-and-cost) for the estimate rules.
134
134
 
@@ -26,7 +26,7 @@ Mode belongs to a Claude Code session. Clear starts a new session in Auto. Resum
26
26
 
27
27
  ## Router pane
28
28
 
29
- The status band is one line above the prompt: a tier meter, the route, a short reason, classifier support, and context and cache use. Segments drop by priority when the band is narrow. Hovering reveals pins, Manual, and a two-row view. The band yields to surveys and does not describe subagent transcripts. A model change between turns raises a toast. A pin, or a step that changes only the effort, such as `medium` to `high` on the defaults, raises none. While the classifier runs, the turn's spinner says `Choosing model`. In Manual mode or when routing is unavailable, the prompt footer carries `router off` or `router unavailable`. The **Router** button opens the pane. The pane has four tabs, Now, Tiers, Tuning, and Usage, with Auto and Manual on every tab. The [user guide](user-guide.md#open-the-router-pane) describes each tab.
29
+ The status band is one line above the prompt: a tier meter, the route, a short reason, classifier support, and context and cache use. Segments drop by priority when the band is narrow. Hovering reveals pins, Manual, and a two-row view. The band yields to surveys and does not describe subagent transcripts. A model change between turns raises a toast. A pin, or a step that changes only the effort, such as `medium` to `high` on the defaults, raises none. While the classifier runs, the turn's spinner says `Choosing model`. In Manual mode or when routing is unavailable, the prompt footer carries `router off` or `router unavailable`. The **Router** button opens the pane. The pane has four tabs, Now, Routing, Classifier, and Usage, with Auto and Manual on every tab. The [user guide](user-guide.md#open-the-router-pane) describes each tab.
30
30
 
31
31
  | Reading | Meaning and limits |
32
32
  | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
@@ -46,9 +46,9 @@ The status band is one line above the prompt: a tier meter, the route, a short r
46
46
 
47
47
  There is no router-owned cost ledger or cumulative savings counter. Classifier charges are not included. See [Evaluation](evaluation.md) for what the available trace can support.
48
48
 
49
- ## Tuning
49
+ ## Routing and classifier settings
50
50
 
51
- The Tiers tab edits each tier's model alias and effort and the baseline tier. The Tuning tab has the classifier choice with its deadline, and three policy controls. Drafts do not affect the active turn. **Save routes** and **Save tuning** validate the whole file with the same loader the Mod starts with, write `router.json` for future turns, and keep unrelated keys. A route equal to the built-in default is removed from the file, so later default changes still reach it.
51
+ The Routing tab edits each tier's model alias and effort, the baseline tier, and three policy controls as one draft. The draft does not affect the active turn, survives a tab change or closing the pane, and is dropped at a new session. **Save** validates the whole file with the same loader the Mod starts with, writes `router.json` for future turns, and keeps unrelated keys. A route or policy value equal to the built-in default is removed from the file, so later default changes still reach it. The Classifier tab writes the classifier choice and its deadline at once. **Undo** reverts the settings the last pane write changed, from any tab, until the next write or a new session.
52
52
 
53
53
  | Control | Values in the pane | Effect |
54
54
  | ---------------- | --------------------------- | ---------------------------------------------------------------------------------------- |
@@ -57,7 +57,7 @@ The Tiers tab edits each tier's model alias and effort and the baseline tier. Th
57
57
  | Payback horizon | 1, 3, 5, 10 turns | Later turns included in downgrade economics. |
58
58
  | Credits cap | $0.50, $1, $2, $5 | Largest estimated cold write on a `credits` model. |
59
59
 
60
- The classifier section lists every configured classifier as a row with its service host and whether its key and endpoint settings are complete. Selecting a row writes `classifier` to `router.json` at once, or removes it for the default, through the same validation, and resets the new classifier's failure count. A turn already being classified finishes with its own classifier; its readings stay off the pane. **Undo** returns to the previous classifier until you leave the tab. The deadline saves at once too, and a built-in classifier's default deadline is written as no override. **Sends** names the host that receives prompt text.
60
+ The classifier section lists every configured classifier as a row with its service host and whether its key and endpoint settings are complete. Selecting a row writes `classifier` to `router.json` at once, or removes it for the default, through the same validation, and resets the new classifier's failure count. A turn already being classified finishes with its own classifier; its readings stay off the pane. **Undo** returns to the previous classifier. The deadline saves at once too, and a built-in classifier's default deadline is written as no override. **Sends** names the host that receives prompt text.
61
61
 
62
62
  The pane refuses to write through a symlink. A failed validation names the setting and leaves the file unchanged. New model aliases and the other supported fields need an edit to the active profile's `router.json`.
63
63
 
@@ -0,0 +1,45 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 626 363" role="img" aria-labelledby="title desc">
2
+ <title id="title">Router pane, Classifier tab</title>
3
+ <desc id="desc">The classifier rows with the active one marked, a missing Jev API key with Set up, the deadline, health, the receiving host and the credentials each classifier needs, and Undo after a switch.</desc>
4
+ <style>
5
+ text { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace; font-size: 13px; }
6
+ .cap { font-family: system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 12px; fill: #9a988f; }
7
+ </style>
8
+ <rect width="626" height="363" rx="8" fill="#1c1c1c"/>
9
+ <rect x="10" y="10" width="606" height="343" rx="6" fill="none" stroke="#3f5f8f"/>
10
+ <text x="24.0" y="34" fill="#5fafd7" font-weight="700" xml:space="preserve">ROUTER · Auto</text>
11
+ <text x="148.8" y="34" fill="#87d787" xml:space="preserve">Clef Flash ready</text>
12
+ <text x="24.0" y="53" fill="#87afff" font-weight="700" xml:space="preserve">[ Auto ]</text>
13
+ <text x="94.2" y="53" fill="#d0d0d0" xml:space="preserve">[ Manual ]</text>
14
+ <text x="172.2" y="53" fill="#7c7c7c" xml:space="preserve"> Manual keeps the /model choice</text>
15
+ <text x="24.0" y="72" fill="#d0d0d0" xml:space="preserve">[ Now ]</text>
16
+ <text x="86.4" y="72" fill="#d0d0d0" xml:space="preserve">[ Routing ]</text>
17
+ <text x="180.0" y="72" fill="#87afff" font-weight="700" xml:space="preserve">[ Classifier ]</text>
18
+ <text x="297.0" y="72" fill="#d0d0d0" xml:space="preserve">[ Usage ]</text>
19
+ <text x="375.0" y="72" fill="#d0d0d0" xml:space="preserve">[ ? ]</text>
20
+ <text x="24.0" y="110" fill="#5fafd7" font-weight="700" xml:space="preserve">CLASSIFIER</text>
21
+ <text x="102.0" y="110" fill="#7c7c7c" xml:space="preserve"> · applies next turn · saves at once</text>
22
+ <text x="24.0" y="129" fill="#7c7c7c" xml:space="preserve">Asked once per new turn.</text>
23
+ <text x="24.0" y="148" fill="#d0d0d0" xml:space="preserve">[ ○ Jev ]</text>
24
+ <text x="164.4" y="148" fill="#7c7c7c" xml:space="preserve">api.typesafe.ai</text>
25
+ <text x="320.4" y="148" fill="#d7af5f" xml:space="preserve">○ no API key </text>
26
+ <text x="429.6" y="148" fill="#d0d0d0" xml:space="preserve">[ Set up ]</text>
27
+ <text x="24.0" y="167" fill="#d0d0d0" xml:space="preserve">[ ○ Clef ]</text>
28
+ <text x="164.4" y="167" fill="#7c7c7c" xml:space="preserve">api.cloudflare.com</text>
29
+ <text x="320.4" y="167" fill="#87d787" xml:space="preserve">● ready</text>
30
+ <text x="24.0" y="186" fill="#87afff" font-weight="700" xml:space="preserve">[ ◉ Clef Flash ]</text>
31
+ <text x="164.4" y="186" fill="#7c7c7c" xml:space="preserve">api.cloudflare.com</text>
32
+ <text x="320.4" y="186" fill="#87d787" xml:space="preserve">● ready</text>
33
+ <text x="24.0" y="205" fill="#d0d0d0" xml:space="preserve">Deadline</text>
34
+ <text x="94.2" y="205" fill="#d0d0d0" xml:space="preserve">3000 ms ▾</text>
35
+ <text x="187.8" y="205" fill="#7c7c7c" xml:space="preserve">then keep the model</text>
36
+ <text x="24.0" y="224" fill="#d0d0d0" xml:space="preserve">Health active · 0 recent failures</text>
37
+ <text x="24.0" y="243" fill="#7c7c7c" xml:space="preserve">Sends prompt + 6 recent turns → api.cloudflare.com</text>
38
+ <text x="24.0" y="262" fill="#d0d0d0" xml:space="preserve">Credentials </text>
39
+ <text x="125.4" y="262" fill="#d0d0d0" xml:space="preserve">[ Edit ]</text>
40
+ <text x="187.8" y="262" fill="#7c7c7c" xml:space="preserve"> opens /plugin configure</text>
41
+ <text x="24.0" y="281" fill="#7c7c7c" xml:space="preserve"> Jev: API key · Clef, Clef Flash: API token, account ID</text>
42
+ <text x="24.0" y="319" fill="#87d787" xml:space="preserve">Saved: classifier Clef → Clef Flash. Applies from the next turn. </text>
43
+ <text x="538.8" y="319" fill="#d0d0d0" xml:space="preserve">[ Undo ]</text>
44
+ <text x="24.0" y="338" fill="#d0d0d0" xml:space="preserve">[ Close ]</text>
45
+ </svg>
@@ -10,12 +10,13 @@
10
10
  <text x="24.0" y="34" fill="#5fafd7" font-weight="700" xml:space="preserve">ROUTER · Auto</text>
11
11
  <text x="148.8" y="34" fill="#87d787" xml:space="preserve">Jev ready · 347 ms</text>
12
12
  <text x="24.0" y="53" fill="#87afff" font-weight="700" xml:space="preserve">[ Auto ]</text>
13
- <text x="94.2" y="53" fill="#d0d0d0" xml:space="preserve">[ Manual: keep /model ]</text>
13
+ <text x="94.2" y="53" fill="#d0d0d0" xml:space="preserve">[ Manual ]</text>
14
+ <text x="172.2" y="53" fill="#7c7c7c" xml:space="preserve"> Manual keeps the /model choice</text>
14
15
  <text x="24.0" y="72" fill="#87afff" font-weight="700" xml:space="preserve">[ Now ]</text>
15
- <text x="86.4" y="72" fill="#d0d0d0" xml:space="preserve">[ Tiers ]</text>
16
- <text x="164.4" y="72" fill="#d0d0d0" xml:space="preserve">[ Tuning ]</text>
17
- <text x="250.2" y="72" fill="#d0d0d0" xml:space="preserve">[ Usage ]</text>
18
- <text x="328.2" y="72" fill="#d0d0d0" xml:space="preserve">[ ? ]</text>
16
+ <text x="86.4" y="72" fill="#d0d0d0" xml:space="preserve">[ Routing ]</text>
17
+ <text x="180.0" y="72" fill="#d0d0d0" xml:space="preserve">[ Classifier ]</text>
18
+ <text x="297.0" y="72" fill="#d0d0d0" xml:space="preserve">[ Usage ]</text>
19
+ <text x="375.0" y="72" fill="#d0d0d0" xml:space="preserve">[ ? ]</text>
19
20
  <text x="24.0" y="110" fill="#d0d0d0" xml:space="preserve">Now </text>
20
21
  <text x="78.6" y="110" fill="#e0708a" font-weight="700" xml:space="preserve">▌high </text>
21
22
  <text x="133.2" y="110" fill="#d0d0d0" xml:space="preserve">Opus 5.5 · xhigh</text>
@@ -0,0 +1,81 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 594 686" role="img" aria-labelledby="title desc">
2
+ <title id="title">Router pane, Routing tab</title>
3
+ <desc id="desc">Model and effort per tier with prices and windows, the baseline tier, how the policy prices each step up, the policy controls, and the unsaved router.json change with Save and Discard.</desc>
4
+ <style>
5
+ text { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace; font-size: 13px; }
6
+ .cap { font-family: system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 12px; fill: #9a988f; }
7
+ </style>
8
+ <rect width="594" height="686" rx="8" fill="#1c1c1c"/>
9
+ <rect x="10" y="10" width="574" height="666" rx="6" fill="none" stroke="#3f5f8f"/>
10
+ <text x="24.0" y="34" fill="#5fafd7" font-weight="700" xml:space="preserve">ROUTER · Auto</text>
11
+ <text x="148.8" y="34" fill="#87d787" xml:space="preserve">Jev ready · 347 ms</text>
12
+ <text x="24.0" y="53" fill="#87afff" font-weight="700" xml:space="preserve">[ Auto ]</text>
13
+ <text x="94.2" y="53" fill="#d0d0d0" xml:space="preserve">[ Manual ]</text>
14
+ <text x="172.2" y="53" fill="#7c7c7c" xml:space="preserve"> Manual keeps the /model choice</text>
15
+ <text x="24.0" y="72" fill="#d0d0d0" xml:space="preserve">[ Now ]</text>
16
+ <text x="86.4" y="72" fill="#87afff" font-weight="700" xml:space="preserve">[ Routing ● ]</text>
17
+ <text x="195.6" y="72" fill="#d0d0d0" xml:space="preserve">[ Classifier ]</text>
18
+ <text x="312.6" y="72" fill="#d0d0d0" xml:space="preserve">[ Usage ]</text>
19
+ <text x="390.6" y="72" fill="#d0d0d0" xml:space="preserve">[ ? ]</text>
20
+ <text x="24.0" y="110" fill="#5fafd7" font-weight="700" xml:space="preserve">ROUTES</text>
21
+ <text x="70.8" y="110" fill="#7c7c7c" xml:space="preserve"> · applies next turn · edit, then Save</text>
22
+ <text x="24.0" y="129" fill="#7c7c7c" xml:space="preserve">tier model effort $/M in · out window</text>
23
+ <text x="24.0" y="148" fill="#e0708a" font-weight="700" xml:space="preserve">high</text>
24
+ <text x="86.4" y="148" fill="#d0d0d0" xml:space="preserve">Opus 5.5 ▾</text>
25
+ <text x="195.6" y="148" fill="#d0d0d0" xml:space="preserve">xhigh ▾</text>
26
+ <text x="304.8" y="148" fill="#d0d0d0" xml:space="preserve">4 · 20</text>
27
+ <text x="414.0" y="148" fill="#d0d0d0" xml:space="preserve">1M</text>
28
+ <text x="24.0" y="167" fill="#d7af5f" font-weight="700" xml:space="preserve">medium</text>
29
+ <text x="86.4" y="167" fill="#d0d0d0" xml:space="preserve">Sonnet 5.5 ▾</text>
30
+ <text x="195.6" y="167" fill="#d0d0d0" xml:space="preserve">xhigh ▾</text>
31
+ <text x="289.2" y="167" fill="#d7af5f" xml:space="preserve">●</text>
32
+ <text x="304.8" y="167" fill="#d0d0d0" xml:space="preserve">2 · 10</text>
33
+ <text x="414.0" y="167" fill="#d0d0d0" xml:space="preserve">1M</text>
34
+ <text x="24.0" y="186" fill="#5f9fe0" font-weight="700" xml:space="preserve">low</text>
35
+ <text x="86.4" y="186" fill="#d0d0d0" xml:space="preserve">Sonnet 5.5 ▾</text>
36
+ <text x="195.6" y="186" fill="#d0d0d0" xml:space="preserve">session ▾</text>
37
+ <text x="304.8" y="186" fill="#d0d0d0" xml:space="preserve">2 · 10</text>
38
+ <text x="414.0" y="186" fill="#d0d0d0" xml:space="preserve">1M</text>
39
+ <text x="24.0" y="205" fill="#5fd7af" font-weight="700" xml:space="preserve">micro</text>
40
+ <text x="86.4" y="205" fill="#d0d0d0" xml:space="preserve">Haiku 4.5 ▾</text>
41
+ <text x="195.6" y="205" fill="#7c7c7c" xml:space="preserve">none</text>
42
+ <text x="304.8" y="205" fill="#d0d0d0" xml:space="preserve">1 · 5</text>
43
+ <text x="414.0" y="205" fill="#d0d0d0" xml:space="preserve">200K</text>
44
+ <text x="24.0" y="224" fill="#d0d0d0" xml:space="preserve">Baseline tier: low ▾</text>
45
+ <text x="304.8" y="224" fill="#7c7c7c" xml:space="preserve">start here, fall back here</text>
46
+ <text x="24.0" y="262" fill="#5fafd7" font-weight="700" xml:space="preserve">SWITCH COST · from these routes</text>
47
+ <text x="24.0" y="281" fill="#7c7c7c" xml:space="preserve">· </text>
48
+ <text x="39.6" y="281" fill="#d0d0d0" xml:space="preserve">medium → high </text>
49
+ <text x="164.4" y="281" fill="#d0d0d0" xml:space="preserve">model change: priced as a cold cache write</text>
50
+ <text x="24.0" y="300" fill="#7c7c7c" xml:space="preserve">· </text>
51
+ <text x="39.6" y="300" fill="#d0d0d0" xml:space="preserve">low → medium </text>
52
+ <text x="164.4" y="300" fill="#d0d0d0" xml:space="preserve">same model, new effort: priced as a new cache</text>
53
+ <text x="24.0" y="319" fill="#7c7c7c" xml:space="preserve">· </text>
54
+ <text x="39.6" y="319" fill="#d0d0d0" xml:space="preserve">micro → low </text>
55
+ <text x="164.4" y="319" fill="#d0d0d0" xml:space="preserve">model change: priced as a cold cache write</text>
56
+ <text x="24.0" y="338" fill="#d0d0d0" xml:space="preserve">[ Reset routes to defaults ]</text>
57
+ <text x="24.0" y="357" fill="#7c7c7c" xml:space="preserve">A new model ID needs router.json → models: price, window, efforts.</text>
58
+ <text x="24.0" y="395" fill="#5fafd7" font-weight="700" xml:space="preserve">POLICY</text>
59
+ <text x="70.8" y="395" fill="#7c7c7c" xml:space="preserve"> · applies next turn · edit, then Save</text>
60
+ <text x="24.0" y="414" fill="#d0d0d0" xml:space="preserve">Votes to go down</text>
61
+ <text x="180.0" y="414" fill="#d0d0d0" xml:space="preserve">2 ▾</text>
62
+ <text x="289.2" y="414" fill="#7c7c7c" xml:space="preserve">agreeing turns before cheaper</text>
63
+ <text x="24.0" y="433" fill="#d0d0d0" xml:space="preserve">Payback horizon</text>
64
+ <text x="180.0" y="433" fill="#d0d0d0" xml:space="preserve">5 turns ▾</text>
65
+ <text x="289.2" y="433" fill="#7c7c7c" xml:space="preserve">a switch repays its cache</text>
66
+ <text x="24.0" y="452" fill="#d0d0d0" xml:space="preserve">Credits cap</text>
67
+ <text x="180.0" y="452" fill="#d0d0d0" xml:space="preserve">$2.00 ▾</text>
68
+ <text x="289.2" y="452" fill="#7c7c7c" xml:space="preserve">max cold write on credits</text>
69
+ <text x="24.0" y="471" fill="#d0d0d0" xml:space="preserve">[ Reset policy to defaults ]</text>
70
+ <text x="24.0" y="509" fill="#5fafd7" font-weight="700" xml:space="preserve">CONFIG</text>
71
+ <text x="24.0" y="528" fill="#d0d0d0" xml:space="preserve">File ~/.claude/router.json </text>
72
+ <text x="273.6" y="528" fill="#d0d0d0" xml:space="preserve">[ copy ]</text>
73
+ <text x="24.0" y="547" fill="#7c7c7c" xml:space="preserve">Main conversation only. Subagents keep their own model.</text>
74
+ <text x="24.0" y="585" fill="#7c7c7c" xml:space="preserve">router.json changes:</text>
75
+ <text x="24.0" y="604" fill="#e06c6c" xml:space="preserve">- routes.medium Opus 5.5 · medium</text>
76
+ <text x="24.0" y="623" fill="#87d787" xml:space="preserve">+ routes.medium Sonnet 5.5 · xhigh</text>
77
+ <text x="24.0" y="642" fill="#d7af5f" xml:space="preserve">● 1 unsaved routing change </text>
78
+ <text x="242.4" y="642" fill="#87afff" font-weight="700" xml:space="preserve">[ Save ]</text>
79
+ <text x="312.6" y="642" fill="#d0d0d0" xml:space="preserve">[ Discard ]</text>
80
+ <text x="24.0" y="661" fill="#d0d0d0" xml:space="preserve">[ Close ]</text>
81
+ </svg>
@@ -21,7 +21,7 @@ In Claude Code:
21
21
  2. Enter the credentials of the classifier you use, and save them:
22
22
  - **Jev** (the default): the Jev API key from typesafe.ai.
23
23
  - **Clef** or **Clef Flash** on Cloudflare Workers AI: the Cloudflare API token and the Cloudflare account ID. One token covers both models.
24
- 3. To use Clef or Clef Flash, open the pane's **Tuning** tab and select its row under **Classifier**. See [Choose the classifier](#choose-the-classifier).
24
+ 3. To use Clef or Clef Flash, open the pane's **Classifier** tab and select its row. See [Choose the classifier](#choose-the-classifier).
25
25
  4. Check the band above the prompt: `▂▄▆█ Auto · ready`. On another model the session starts in Manual; run `/router auto` to route.
26
26
 
27
27
  Keys are stored as sensitive plugin options. Do not paste them into a model conversation. The [configuration guide](configuration.md) covers optional settings and migrations.
@@ -66,18 +66,27 @@ Run `/router` or select **Router** above the prompt. Without a UI surface, as in
66
66
 
67
67
  The **Now** tab answers "what runs next turn, and why". The ladder lists the tiers from strongest to cheapest with the route each one uses. The bar is the support the classifier gave that tier on the last turn. The line under the ladder compares the support for a switch with the bar the policy required and shows the estimated switch tax. **pin** forces that tier for the next turn only.
68
68
 
69
- ![The Tiers tab: model and effort per tier, the baseline tier, how each step up is priced, and the router.json change to save](router-pane-tiers.svg)
69
+ ![The Routing tab: model and effort per tier, the baseline tier, how each step up is priced, the policy controls, and the unsaved router.json change with Save and Discard](router-pane-routing.svg)
70
70
 
71
- The **Tiers** tab edits the routes. In the picture, `medium` was changed to Sonnet 5.5 at `xhigh`: the tier shows **●**, the switch-cost lines now price `medium → high` as a model change, and the diff lists the one `router.json` line that **Save routes** will write. [Edit tiers](#edit-tiers) explains the controls.
71
+ The **Routing** tab edits the routes and the policy. In the picture, `medium` was changed to Sonnet 5.5 at `xhigh`: the tier shows **●**, the tab reads **Routing ●**, the switch-cost lines now price `medium → high` as a model change, and the status bar lists the one `router.json` line that **Save** will write. [Edit routes and policy](#edit-routes-and-policy) explains the controls.
72
72
 
73
- | Tab | What it shows |
74
- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
75
- | 1 Now | The current tier, model, and reason; the classifier's support for each tier with a **pin** button; the last 30 replies by tier; context and cache. |
76
- | 2 Tiers | The model and effort for each tier, the baseline tier, the cache cost of each step up, and the `router.json` change to save. |
77
- | 3 Tuning | The classifier with its deadline, health, and keys; downgrade votes, payback horizon, and credits cap; the `router.json` path. |
78
- | 4 Usage | Claude-reported cost, context and cache detail, input per reply, quota, and configured-price estimates. |
73
+ | Tab | What it shows |
74
+ | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
75
+ | 1 Now | The current tier, model, and reason; the classifier's support for each tier with a **pin** button; the last 30 replies by tier; context and cache. |
76
+ | 2 Routing | The model and effort for each tier, the baseline tier, the cache cost of each step up; downgrade votes, payback horizon, and credits cap; the `router.json` path. |
77
+ | 3 Classifier | The classifier rows with their credentials state, the active classifier's deadline and health, and the credentials each classifier needs. |
78
+ | 4 Usage | Claude-reported cost, context and cache detail, input per reply, quota, and configured-price estimates. |
79
79
 
80
- **Auto** and **Manual: keep /model** stay at the top of every tab. **?** shows what the estimates leave out.
80
+ **Auto** and **Manual** stay at the top of every tab. **?** shows what the estimates leave out.
81
+
82
+ ### Save and undo changes
83
+
84
+ The two settings tabs follow one rule each, and the section captions say which:
85
+
86
+ - **Routing**: edit as a set, then save. Changes stay a draft until **Save** (`s`). **Discard** (`d`) drops them. The draft stays when you change tab or close the pane: the tab reads **Routing ●**, and every tab shows the `router.json` lines that **Save** will write, with **Save** and **Discard**. A new session drops the draft.
87
+ - **Classifier**: a row or a deadline is written to `router.json` when you select it.
88
+
89
+ Every write applies from the next turn and can be undone. **Undo** (`u`) puts back the settings the last write changed, from any tab, and leaves any other edit to `router.json` alone. A new session clears it. Green notices confirm a write or an undo; a red one names why nothing was written.
81
90
 
82
91
  ### Understand usage and estimates
83
92
 
@@ -102,30 +111,30 @@ There is no router-side spend or savings ledger. The pane does not include class
102
111
  | `/router off` | Enter Manual mode and preserve Claude's selected model. |
103
112
  | `/router pin <micro\|low\|medium\|high>` | Pin the next turn and its tool continuations. Auto must already be enabled. |
104
113
  | `/model <name>` | Select a model and enter Manual mode. Use `/router auto` to resume. |
105
- | **Auto** / **Manual: keep /model** | The same as `/router auto` and `/router off`. |
114
+ | **Auto** / **Manual** | The same as `/router auto` and `/router off`. |
106
115
  | **pin** on the Now tab | Pin that tier for the next turn. Auto must already be enabled. |
107
116
 
108
117
  A pin does not change the next turn after the pinned turn finishes. A fresh session on the baseline model starts in Auto. A fresh session on another model starts in Manual. `/clear` starts the new session in Auto. Resuming a saved session restores its saved Auto or Manual mode.
109
118
 
110
- ## Edit tiers
119
+ ## Edit routes and policy
111
120
 
112
- On the **Tiers** tab, pick a model and an effort for any tier. The model list comes from the aliases in `router.json` `models`, limited by the `availableModels` setting. `session` keeps the effort Claude Code sends. A model without effort levels, such as Haiku, shows `none`.
121
+ On the **Routing** tab, pick a model and an effort for any tier. The model list comes from the aliases in `router.json` `models`, limited by the `availableModels` setting. `session` keeps the effort Claude Code sends. A model without effort levels, such as Haiku, shows `none`.
113
122
 
114
- Changed tiers show **●**. The tab lists the `router.json` lines that **Save routes** will write. **Discard** drops the draft. **Reset to defaults** loads the built-in routes; saving then removes your route overrides from `router.json`. A saved change applies from the next turn.
123
+ Changed tiers show **●**. **Reset routes to defaults** (`r`) loads the built-in routes into the draft; **Save** then removes your route overrides from `router.json`.
115
124
 
116
125
  **Switch cost** reads the draft from the bottom tier up and shows how the policy prices each step. A model change is priced as a cold cache write. An effort change on the same model is also priced as a new messages cache; whether the API actually keeps the cache across an effort change is not measured. Two identical tiers make that step change nothing.
117
126
 
118
127
  A new model ID needs an entry in `router.json` `models` with its price, context window, and effort levels. See [Configuration](configuration.md).
119
128
 
120
- ## Tune future decisions
129
+ ### Tune future decisions
121
130
 
122
- On the **Tuning** tab, under **Policy**, pick the values, then select **Save tuning**:
131
+ Under **Policy** on the same tab, pick the values. One **Save** writes them with any route changes:
123
132
 
124
133
  - **Votes to go down:** 1, 2, or 3 consecutive votes before a cheaper tier.
125
134
  - **Payback horizon:** 1, 3, 5, or 10 later turns used by the downgrade estimate.
126
135
  - **Credits cap:** $0.50, $1, $2, or $5 for an estimated cold cache write on a `credits` model.
127
136
 
128
- The current turn keeps the settings it started with. A save preserves unrelated `router.json` keys and refuses to write through a symlink. When validation fails, the pane names the setting and leaves the file unchanged.
137
+ **Reset policy to defaults** loads the built-in values; **Save** then removes your policy overrides. The current turn keeps the settings it started with. A save preserves unrelated `router.json` keys and refuses to write through a symlink. When validation fails, the pane names the setting and leaves the file unchanged.
129
138
 
130
139
  ## Choose the classifier
131
140
 
@@ -137,13 +146,13 @@ Router asks one classifier per turn. Three are built in:
137
146
  | Clef | Cloudflare Workers AI, 27B | Cloudflare API token and Cloudflare account ID | 3,000 ms |
138
147
  | Clef Flash | Cloudflare Workers AI, 9B | Cloudflare API token and Cloudflare account ID | 3,000 ms |
139
148
 
140
- ![The Tuning tab: classifier rows with the active one marked, a missing Jev API key with Set up, Undo after a switch, the deadline, health, the receiving host, the credentials each classifier needs, and the policy controls](router-pane-tuning.svg)
149
+ ![The Classifier tab: classifier rows with the active one marked, a missing Jev API key with Set up, the deadline, health, the receiving host, the credentials each classifier needs, and Undo after a switch](router-pane-classifier.svg)
141
150
 
142
- You can save credentials for all of them; only the active one is asked. The **Classifier** section at the top of the **Tuning** tab has one row per classifier: `◉` marks the active one, followed by its service and whether its credentials are complete. A row that lacks one names it, such as `○ no API token`, and has its own **Set up** button.
151
+ You can save credentials for all of them; only the active one is asked. The **Classifier** tab has one row per classifier: `◉` marks the active one, followed by its service and whether its credentials are complete. A row that lacks one names it, such as `○ no API token`, and has its own **Set up** button.
143
152
 
144
- Select a row to switch. The choice is written to `router.json` at once and applies from the next turn. A line under the rows names the previous classifier with an **Undo** button; it goes when you leave the tab. A turn that is already being classified finishes with the classifier it started with. The new classifier starts with a clean failure count.
153
+ Select a row to switch. The choice is written to `router.json` at once and applies from the next turn. **Undo** in the status bar returns to the previous classifier. A turn that is already being classified finishes with the classifier it started with. The new classifier starts with a clean failure count.
145
154
 
146
- - **Deadline:** 500, 1,000, 1,500, or 3,000 ms for the active classifier's total advice attempt, including any retry. Each classifier keeps its own deadline, saved at once.
155
+ - **Deadline:** 500, 1,000, 1,500, or 3,000 ms for the active classifier's total advice attempt, including any retry. Each classifier keeps its own deadline, saved at once, with **Undo**.
147
156
  - **Health** shows recent failures or a pause. **Sends** names the service that receives prompt text.
148
157
  - **Credentials** lists what each classifier needs, such as `Jev: API key · Clef, Clef Flash: API token, account ID`. **Edit** opens Claude Code's secure plugin configuration, where you enter them.
149
158
 
@@ -16,7 +16,7 @@ import { resolveCredentials } from '../lib/jev-contract.mjs';
16
16
  import { renderBand, switchToast } from '../lib/native-band.mjs';
17
17
  import { classifierStatus, GATEWAY_CLEANUP, GATEWAY_SETTINGS, missingCredentials } from '../lib/native-display.mjs';
18
18
  import { NativeJev } from '../lib/native-jev.mjs';
19
- import { renderPanel, routeDraftOf } from '../lib/native-panel.mjs';
19
+ import { renderPanel, routeDraftOf, routingChanges } from '../lib/native-panel.mjs';
20
20
  import {
21
21
  chooseRoute,
22
22
  continueRoute,
@@ -70,7 +70,7 @@ function initialView(model) {
70
70
  tuning: null,
71
71
  tuningBase: null,
72
72
  routeDraft: null,
73
- classifierUndo: null,
73
+ lastWrite: null,
74
74
  tab: 'now',
75
75
  help: false,
76
76
  notice: null,
@@ -109,6 +109,13 @@ async function updateView($, runtime, patch) {
109
109
  await $.state.set(VIEW, runtime.view);
110
110
  }
111
111
 
112
+ // A notice answers the last press in the pane, so the pane opens without one; the last write keeps its Undo in the
113
+ // status bar.
114
+ async function openPane($, runtime) {
115
+ await updateView($, runtime, { notice: null });
116
+ await $.ui.open({ id: PANE, title: PANE_TITLE, focus: true, closeOnEscape: true });
117
+ }
118
+
112
119
  async function changeMode($, runtime, mode) {
113
120
  const view = runtime.view ?? (await readView($, runtime));
114
121
  for (const controller of runtime.controllers) controller.abort();
@@ -181,6 +188,51 @@ function openKeySettings($) {
181
188
  $.clock.after(0, () => $.command.run({ command: 'plugin', args: `configure ${$.plugin.name}` }).catch(() => {}));
182
189
  }
183
190
 
191
+ const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
192
+
193
+ // The leaves where router.json `after` differs from `before`, each with its value in `before`, or no `value` where it
194
+ // had none. An object present on one side only is walked as empty on the other, so a sibling stays out of it.
195
+ function changedLeaves(before, after, path = []) {
196
+ const out = [];
197
+ for (const key of new Set([...Object.keys(before), ...Object.keys(after)])) {
198
+ const [a, b] = [before[key], after[key]];
199
+ if ((isRecord(a) || a === undefined) && (isRecord(b) || b === undefined) && (isRecord(a) || isRecord(b)))
200
+ out.push(...changedLeaves(a ?? {}, b ?? {}, [...path, key]));
201
+ else if (JSON.stringify(a) !== JSON.stringify(b))
202
+ out.push(Object.hasOwn(before, key) ? { path: [...path, key], value: a } : { path: [...path, key] });
203
+ }
204
+ return out;
205
+ }
206
+
207
+ // The router.json `file` with each leaf of one pane write put back as it was before it: a value written again
208
+ // verbatim, a leaf that was absent deleted along with any object that leaves empty. Leaves the write did not touch,
209
+ // such as an edit made on disk since, stay as they are.
210
+ function restored(file, leaves) {
211
+ const next = structuredClone(file);
212
+ for (const { path, ...leaf } of leaves) {
213
+ const parents = path.slice(0, -1);
214
+ const key = path.at(-1);
215
+ if (Object.hasOwn(leaf, 'value')) {
216
+ let node = next;
217
+ for (const name of parents) {
218
+ if (!isRecord(node[name])) node[name] = {};
219
+ node = node[name];
220
+ }
221
+ node[key] = leaf.value;
222
+ continue;
223
+ }
224
+ const chain = [next];
225
+ for (const name of parents) {
226
+ if (!isRecord(chain.at(-1)[name])) break;
227
+ chain.push(chain.at(-1)[name]);
228
+ }
229
+ if (chain.length !== path.length) continue;
230
+ delete chain.at(-1)[key];
231
+ for (let i = chain.length - 1; i > 0 && !Object.keys(chain[i]).length; i -= 1) delete chain[i - 1][path[i - 1]];
232
+ }
233
+ return next;
234
+ }
235
+
184
236
  // Writes router.json through `change(previousFile)` once the result validates. Returns the new config or an error
185
237
  // line for the pane; a failure leaves the file untouched.
186
238
  async function saveConfig($, path, change) {
@@ -354,6 +406,8 @@ export function register(on, options) {
354
406
  configPath: config.nativePath,
355
407
  tuning: null,
356
408
  tuningBase: null,
409
+ routeDraft: null,
410
+ lastWrite: null,
357
411
  bandDetail: (await $.store.get(BAND_DETAIL).catch(() => false)) === true,
358
412
  });
359
413
  } catch (error) {
@@ -396,7 +450,7 @@ export function register(on, options) {
396
450
  const storedView = await readView($, runtime);
397
451
  const view = { ...storedView, mode: await modeOf($, runtime, storedView.mode) };
398
452
  if (!(await $.session.surfaces()).length) return { text: detailText(config, view) };
399
- await $.ui.open({ id: PANE, title: PANE_TITLE, focus: true, closeOnEscape: true });
453
+ await openPane($, runtime);
400
454
  return {};
401
455
  });
402
456
 
@@ -651,7 +705,6 @@ export function register(on, options) {
651
705
  const elements = $.ui.resolve(e);
652
706
  const { Box } = elements;
653
707
  const usage = await $.session.usage().catch(() => null);
654
- const openPane = () => $.ui.open({ id: PANE, title: PANE_TITLE, focus: true, closeOnEscape: true });
655
708
  if (e.component === 'AbovePrompt') {
656
709
  if (e.props.hasSurvey) return next(e);
657
710
  return Box({
@@ -665,7 +718,7 @@ export function register(on, options) {
665
718
  usage,
666
719
  { columns: e.props.bodyColumns, agentId: e.props.view?.agentId },
667
720
  {
668
- open: openPane,
721
+ open: () => openPane($, runtime),
669
722
  mode: (mode) => changeMode($, runtime, mode),
670
723
  pin: async (tier) => $.ui.toast(await setPin($, runtime, tier)),
671
724
  unpin: () => updateView($, runtime, { pendingPin: null }),
@@ -708,20 +761,50 @@ export function register(on, options) {
708
761
  health: healthOf(clientOf(config.classifier), config.classifier),
709
762
  };
710
763
  };
764
+ // Pending drafts re-pointed at the config a write just adopted. An edit that still differs stays; everything else
765
+ // follows the file, and the file becomes what the draft compares against, so picking a value the write replaced
766
+ // counts as a change again.
767
+ const rebased = ({ routeDraft, tuning, tuningBase }) => {
768
+ const routes = routeDraft && effectiveRoutes(routeDraft, config);
769
+ const edited = Object.entries(tuning ?? {}).filter(([key, value]) => value !== tuningBase?.[key]);
770
+ return {
771
+ routeDraft: routes ? { ...routes, base: routeDraftOf(config, {}).base } : null,
772
+ tuning: edited.length ? Object.fromEntries(edited) : null,
773
+ tuningBase: edited.length ? tuningOf(config) : null,
774
+ };
775
+ };
711
776
  const save = async (change, saved) => {
712
777
  const result = await saveConfig($, config.nativePath, change);
713
778
  if (result.error) return updateView($, runtime, { notice: result.error });
779
+ const drafts = runtime.view ?? view;
714
780
  const reset = await adopt(result.config);
715
- return updateView($, runtime, { ...reset, ...saved(config) });
781
+ return updateView($, runtime, { ...reset, ...rebased(drafts), ...saved(config) });
782
+ };
783
+ // Defaults go into the routing draft like any edit; the notice says whether Save has anything of that section left
784
+ // to write.
785
+ const loadDefaults = (patch, what) => {
786
+ const changes = routingChanges(config, { ...(runtime.view ?? view), ...patch });
787
+ const pending = what === 'route' ? changes.tiers.length + Number(changes.baseline) : changes.policy.length;
788
+ return updateView($, runtime, {
789
+ ...patch,
790
+ notice: pending
791
+ ? `${what === 'route' ? 'Route' : 'Policy'} defaults loaded. Save removes your ${what} overrides from router.json.`
792
+ : `${what === 'route' ? 'Routes' : 'Policy'} already at defaults.`,
793
+ });
794
+ };
795
+ // A pane write keeps the leaves it changed as router.json had them, read from the file it rewrites rather than from
796
+ // the loaded config, so Undo restores them verbatim. A later write replaces them, and Undo clears them.
797
+ const write = (label, change, patch = {}) => {
798
+ let leaves = [];
799
+ return save(
800
+ (file) => {
801
+ const written = change(file);
802
+ leaves = changedLeaves(file, written);
803
+ return written;
804
+ },
805
+ () => ({ ...patch, lastWrite: { label, leaves }, notice: `Saved: ${label}. Applies from the next turn.` }),
806
+ );
716
807
  };
717
- // A classifier choice applies at once; `undo` is the one Undo returns to, null after an Undo.
718
- const activateClassifier = (id, undo) =>
719
- !id || id === config.classifier || !Object.hasOwn(config.classifiers, id)
720
- ? undefined
721
- : save(
722
- (file) => withClassifier(file, id),
723
- () => ({ classifierUndo: undo, notice: null }),
724
- );
725
808
  return renderPanel(
726
809
  elements,
727
810
  config,
@@ -729,7 +812,7 @@ export function register(on, options) {
729
812
  usage,
730
813
  {
731
814
  mode: (mode) => changeMode($, runtime, mode),
732
- tab: (tab) => updateView($, runtime, { tab, notice: null, classifierUndo: null }),
815
+ tab: (tab) => updateView($, runtime, { tab, notice: null }),
733
816
  help: () => updateView($, runtime, { help: !view.help }),
734
817
  pin: async (tier) => {
735
818
  await updateView($, runtime, { notice: await setPin($, runtime, tier) });
@@ -754,50 +837,70 @@ export function register(on, options) {
754
837
  const draft = routeDraftOf(config, runtime.view ?? view);
755
838
  await updateView($, runtime, { routeDraft: { ...draft, baselineTier: tier }, notice: null });
756
839
  },
757
- saveRoutes: async () => {
758
- const draft = (runtime.view ?? view).routeDraft;
759
- if (!draft) return updateView($, runtime, { notice: 'No route changes to save.' });
760
- return save(
761
- (file) => withRoutes(file, draft),
762
- () => ({ routeDraft: null, notice: 'Saved routes. They apply from the next turn.' }),
840
+ saveRouting: async () => {
841
+ const current = runtime.view ?? view;
842
+ const routeDraft = current.routeDraft;
843
+ const saved = tuningOf(config);
844
+ const base = current.tuningBase ?? saved;
845
+ const edited = Object.keys(current.tuning ?? {}).filter((key) => current.tuning[key] !== base[key]);
846
+ const changes = routingChanges(config, current).count;
847
+ if (!changes) return updateView($, runtime, { notice: 'No routing changes to save.' });
848
+ const after = Object.fromEntries(edited.map((key) => [key, current.tuning[key]]));
849
+ return write(
850
+ `${changes} routing change${changes === 1 ? '' : 's'}`,
851
+ (file) => {
852
+ const routed = routeDraft ? withRoutes(file, routeDraft) : file;
853
+ return edited.length ? withTuning(routed, { ...base, ...after }, base) : routed;
854
+ },
855
+ { routeDraft: null, tuning: null, tuningBase: null },
763
856
  );
764
857
  },
765
- discardRoutes: () => updateView($, runtime, { routeDraft: null, notice: null }),
858
+ discardRouting: () =>
859
+ updateView($, runtime, { routeDraft: null, tuning: null, tuningBase: null, notice: null }),
766
860
  resetRoutes: () =>
767
- updateView($, runtime, {
768
- routeDraft: {
769
- ...structuredClone({ routes: DEFAULTS.routes, baselineTier: DEFAULTS.baselineTier }),
770
- base: routeDraftOf(config, {}).base,
861
+ loadDefaults(
862
+ {
863
+ routeDraft: {
864
+ ...structuredClone({ routes: DEFAULTS.routes, baselineTier: DEFAULTS.baselineTier }),
865
+ base: routeDraftOf(config, {}).base,
866
+ },
771
867
  },
772
- notice: 'Defaults loaded. Save routes to remove your overrides from router.json.',
773
- }),
868
+ 'route',
869
+ ),
774
870
  tune: (key, value) =>
775
871
  updateView($, runtime, {
776
872
  tuning: { ...(runtime.view ?? view).tuning, [key]: value },
777
873
  tuningBase: (runtime.view ?? view).tuningBase ?? tuningOf(config),
778
874
  notice: null,
779
875
  }),
780
- saveTuning: async () => {
781
- const current = runtime.view ?? view;
782
- const base = current.tuningBase ?? tuningOf(config);
783
- const draft = { ...base, ...current.tuning };
784
- if (Object.keys(base).every((key) => draft[key] === base[key]))
785
- return updateView($, runtime, { notice: 'No tuning changes to save.' });
876
+ resetPolicy: () =>
877
+ loadDefaults(
878
+ // The draft is replaced whole, so it starts from the saved values, not from an older draft's base.
879
+ { tuning: tuningOf(DEFAULTS), tuningBase: tuningOf(config) },
880
+ 'policy',
881
+ ),
882
+ classifier: (id) => {
883
+ if (!id || id === config.classifier || !Object.hasOwn(config.classifiers, id)) return undefined;
884
+ const from = config.classifier;
885
+ return write(`classifier ${config.classifiers[from].label} → ${config.classifiers[id].label}`, (file) =>
886
+ withClassifier(file, id),
887
+ );
888
+ },
889
+ classifierTimeout: (timeoutMs) => {
890
+ const active = activeClassifier(config);
891
+ if (timeoutMs === active.timeoutMs) return undefined;
892
+ return write(`${active.label} deadline ${active.timeoutMs} → ${timeoutMs} ms`, (file) =>
893
+ withClassifierTimeout(file, config.classifier, timeoutMs),
894
+ );
895
+ },
896
+ undo: async () => {
897
+ const last = (runtime.view ?? view).lastWrite;
898
+ if (!last) return undefined;
786
899
  return save(
787
- (file) => withTuning(file, draft, base),
788
- () => ({ tuning: null, tuningBase: null, notice: 'Saved. New tuning applies to future turns.' }),
900
+ (file) => restored(file, last.leaves),
901
+ () => ({ lastWrite: null, notice: `Undid: ${last.label}.` }),
789
902
  );
790
903
  },
791
- resetTuning: () => updateView($, runtime, { tuning: null, tuningBase: null, notice: null }),
792
- classifier: (id) => activateClassifier(id, config.classifier),
793
- undoClassifier: () => activateClassifier((runtime.view ?? view).classifierUndo, null),
794
- classifierTimeout: (timeoutMs) =>
795
- save(
796
- (file) => withClassifierTimeout(file, config.classifier, timeoutMs),
797
- (saved) => ({
798
- notice: `Saved. ${activeClassifier(saved).label} waits ${timeoutMs} ms from the next turn.`,
799
- }),
800
- ),
801
904
  },
802
905
  { modelOptions },
803
906
  );
package/lib/config.mjs CHANGED
@@ -202,11 +202,17 @@ export function tuningOf(config) {
202
202
  );
203
203
  }
204
204
 
205
- // The router.json `file` with only the tuning values the person changed in `draft` against `saved`.
205
+ // The router.json `file` with only the tuning values the person changed in `draft` against `saved`. A value equal to
206
+ // the default is written as no key, and a section left empty is dropped, as for routes and deadlines.
206
207
  export function withTuning(file, draft, saved) {
207
208
  let next = file;
208
- for (const [key, [section, field]] of Object.entries(TUNING_FIELDS))
209
- if (draft[key] !== saved[key]) next = { ...next, [section]: { ...next[section], [field]: draft[key] } };
209
+ for (const [key, [section, field]] of Object.entries(TUNING_FIELDS)) {
210
+ if (draft[key] === saved[key]) continue;
211
+ const { [field]: _, ...kept } = next[section] ?? {};
212
+ const entry = draft[key] === DEFAULTS[section][field] ? kept : { ...kept, [field]: draft[key] };
213
+ const { [section]: __, ...rest } = next;
214
+ next = Object.keys(entry).length ? { ...rest, [section]: entry } : rest;
215
+ }
210
216
  return next;
211
217
  }
212
218
 
@@ -16,8 +16,8 @@ import {
16
16
 
17
17
  export const TABS = [
18
18
  ['now', '1', 'Now'],
19
- ['tiers', '2', 'Tiers'],
20
- ['tuning', '3', 'Tuning'],
19
+ ['routing', '2', 'Routing'],
20
+ ['classifier', '3', 'Classifier'],
21
21
  ['usage', '4', 'Usage'],
22
22
  ];
23
23
  export const TUNING_CHOICES = {
@@ -44,7 +44,7 @@ export function routeName(config, route) {
44
44
  return `${modelName(model.id)}${model.efforts.length ? ` · ${route.effort ?? SESSION_EFFORT}` : ''}`;
45
45
  }
46
46
 
47
- // The draft the Tiers tab edits: the saved routes until the person changes one.
47
+ // The route draft the Routing tab edits: the saved routes until the person changes one.
48
48
  export function routeDraftOf(config, view) {
49
49
  if (view.routeDraft) return view.routeDraft;
50
50
  const base = structuredClone({ routes: config.routes, baselineTier: config.baselineTier });
@@ -97,20 +97,20 @@ export function renderPanel(
97
97
  ) {
98
98
  const ui = kit(elements);
99
99
  const tab = TABS.some(([id]) => id === view.tab) ? view.tab : 'now';
100
- const body = { now: nowTab, tiers: tiersTab, tuning: tuningTab, usage: usageTab }[tab];
100
+ const body = { now: nowTab, routing: routingTab, classifier: classifierTab, usage: usageTab }[tab];
101
101
  return ui.Box({
102
102
  flexDirection: 'column',
103
103
  children: [
104
- ...header(ui, config, view, actions),
104
+ ...header(ui, config, view, tab, actions),
105
105
  ...body(ui, config, view, usage, actions, modelOptions),
106
106
  ...(view.help ? helpLines(ui) : []),
107
- view.notice ? ui.text(view.notice, { color: 'yellow' }) : null,
107
+ ...statusBar(ui, config, view, actions),
108
108
  ui.Button({ key: 'close', label: 'Close', hotkey: 'q', role: 'dismiss', onPress: actions.close }),
109
109
  ],
110
110
  });
111
111
  }
112
112
 
113
- function header(ui, config, view, actions) {
113
+ function header(ui, config, view, tab, actions) {
114
114
  const auto = view.mode === 'auto';
115
115
  const label = classifierLabel(config);
116
116
  const error = view.error ?? missingCredentials(view, config.classifier);
@@ -137,19 +137,20 @@ function header(ui, config, view, actions) {
137
137
  ' ',
138
138
  ui.Button({
139
139
  key: 'manual',
140
- label: 'Manual: keep /model',
140
+ label: 'Manual',
141
141
  hotkey: 'm',
142
142
  variant: auto ? 'secondary' : 'primary',
143
143
  onPress: () => actions.mode('manual'),
144
144
  }),
145
+ ui.dim(' Manual keeps the /model choice'),
145
146
  ),
146
147
  ui.line(
147
148
  ...TABS.flatMap(([id, hotkey, label]) => [
148
149
  ui.Button({
149
150
  key: `tab-${id}`,
150
- label,
151
+ label: id === 'routing' && routingChanges(config, view).count ? `${label} ●` : label,
151
152
  hotkey,
152
- variant: (view.tab ?? 'now') === id ? 'primary' : 'secondary',
153
+ variant: tab === id ? 'primary' : 'secondary',
153
154
  onPress: () => actions.tab(id),
154
155
  }),
155
156
  ' ',
@@ -207,12 +208,7 @@ function nowTab(ui, config, view, usage, actions) {
207
208
  routeName(config, config.routes[tier]).padEnd(22),
208
209
  meter ? ui.text(meter.text, { color: TIER_COLOR[tier] }) : ui.dim('—'.padEnd(10)),
209
210
  meter ? ` ${percent(support).padStart(4)} ` : ' ',
210
- ui.Button({
211
- key: `pin-${tier}`,
212
- label: 'pin',
213
- dimColor: !auto,
214
- onPress: () => actions.pin(tier),
215
- }),
211
+ auto ? ui.Button({ key: `pin-${tier}`, label: 'pin', onPress: () => actions.pin(tier) }) : null,
216
212
  ),
217
213
  );
218
214
  }
@@ -263,16 +259,40 @@ function replies(ui, view) {
263
259
  ];
264
260
  }
265
261
 
266
- function tiersTab(ui, config, view, _usage, actions, modelOptions) {
262
+ const POLICY_ROWS = [
263
+ ['downgradeVotes', 'Votes to go down', String, 'agreeing turns before cheaper', 'policy.downgradeVotes'],
264
+ ['horizon', 'Payback horizon', (v) => `${v} turns`, 'a switch repays its cache', 'policy.downgradeHorizonTurns'],
265
+ ['cashCapUsd', 'Credits cap', (v) => `$${v.toFixed(2)}`, 'max cold write on credits', 'policy.cashCapUsd'],
266
+ ];
267
+
268
+ // What the Routing tab changed and has not saved: tiers and baseline against the saved routes, policy values against
269
+ // the values the draft started from.
270
+ export function routingChanges(config, view) {
267
271
  const draft = effectiveRoutes(routeDraftOf(config, view), config);
272
+ const saved = tuningOf(config);
273
+ const base = view.tuningBase ?? saved;
274
+ const tuning = { ...saved, ...view.tuning };
275
+ const tiers = TIERS.filter((tier) => !sameRoute(draft.routes[tier], config.routes[tier]));
276
+ const baseline = draft.baselineTier !== config.baselineTier;
277
+ const policy = POLICY_ROWS.map(([key]) => key).filter(
278
+ (key) => Object.hasOwn(view.tuning ?? {}, key) && view.tuning[key] !== base[key],
279
+ );
280
+ return { draft, saved, tuning, tiers, baseline, policy, count: tiers.length + Number(baseline) + policy.length };
281
+ }
282
+
283
+ const marker = (ui, changed) => ui.cell(2, changed ? ui.text('●', { color: 'yellow' }) : '');
284
+
285
+ // Routes and policy are edited as one set: the switch-cost lines read the whole ladder, so nothing here is written
286
+ // until Save in the status bar.
287
+ function routingTab(ui, config, view, _usage, actions, modelOptions) {
288
+ const { draft, tuning, tiers, baseline, policy } = routingChanges(config, view);
268
289
  const out = [
269
- ui.head('ROUTES · future turns'),
270
- ui.dim(`${'tier'.padEnd(8)}${'model'.padEnd(14)}${'effort'.padEnd(12)}${'$/M in · out'.padEnd(14)}window`),
290
+ ui.line(ui.head('ROUTES'), ui.dim(' · applies next turn · edit, then Save')),
291
+ ui.dim(`${'tier'.padEnd(8)}${'model'.padEnd(14)}${'effort'.padEnd(14)}${'$/M in · out'.padEnd(14)}window`),
271
292
  ];
272
293
  for (const tier of LADDER) {
273
294
  const route = draft.routes[tier];
274
295
  const model = config.models[route.model];
275
- const changed = !sameRoute(route, config.routes[tier]);
276
296
  const aliases = modelOptions.includes(route.model) ? modelOptions : [route.model, ...modelOptions];
277
297
  out.push(
278
298
  ui.line(
@@ -301,24 +321,28 @@ function tiersTab(ui, config, view, _usage, actions, modelOptions) {
301
321
  })
302
322
  : (route.effort ?? SESSION_EFFORT),
303
323
  ),
324
+ marker(ui, tiers.includes(tier)),
304
325
  ui.cell(14, `${model.input} · ${model.output ?? '?'}`),
305
326
  windowSize(model.contextWindow),
306
- changed ? ui.text(' ●', { color: 'yellow' }) : null,
307
327
  ),
308
328
  );
309
329
  }
310
330
  out.push(
311
331
  ui.line(
312
- ui.Select
313
- ? ui.Select({
314
- key: 'baseline',
315
- label: 'Baseline tier',
316
- value: draft.baselineTier,
317
- options: TIERS.map((tier) => ({ value: tier, label: tier })),
318
- onSelect: (tier) => actions.baseline(tier),
319
- })
320
- : `Baseline tier: ${draft.baselineTier}`,
321
- ui.dim(' start here, fall back here'),
332
+ ui.cell(
333
+ 34,
334
+ ui.Select
335
+ ? ui.Select({
336
+ key: 'baseline',
337
+ label: 'Baseline tier',
338
+ value: draft.baselineTier,
339
+ options: TIERS.map((tier) => ({ value: tier, label: tier })),
340
+ onSelect: (tier) => actions.baseline(tier),
341
+ })
342
+ : `Baseline tier: ${draft.baselineTier}`,
343
+ ),
344
+ marker(ui, baseline),
345
+ ui.dim('start here, fall back here'),
322
346
  ),
323
347
  ui.text(' '),
324
348
  ui.head('SWITCH COST · from these routes'),
@@ -333,78 +357,23 @@ function tiersTab(ui, config, view, _usage, actions, modelOptions) {
333
357
  out.push(ui.line(ui.dim('· '), pair, 'same model, new effort: priced as a new cache'));
334
358
  else out.push(ui.line(ui.dim('· '), pair, 'model change: priced as a cold cache write'));
335
359
  }
336
- const changes = TIERS.filter((tier) => !sameRoute(draft.routes[tier], config.routes[tier]));
337
- const baselineChanged = draft.baselineTier !== config.baselineTier;
338
- const dirty = changes.length > 0 || baselineChanged;
339
- out.push(ui.text(' '));
340
- if (dirty) {
341
- out.push(ui.dim('router.json changes:'));
342
- for (const tier of changes) {
343
- out.push(ui.text(`- routes.${tier.padEnd(7)} ${routeName(config, config.routes[tier])}`, { color: 'red' }));
344
- out.push(ui.text(`+ routes.${tier.padEnd(7)} ${routeName(config, draft.routes[tier])}`, { color: 'green' }));
345
- }
346
- if (baselineChanged) {
347
- out.push(ui.text(`- baselineTier ${config.baselineTier}`, { color: 'red' }));
348
- out.push(ui.text(`+ baselineTier ${draft.baselineTier}`, { color: 'green' }));
349
- }
350
- } else out.push(ui.dim('No changes. Pick a model or an effort above.'));
351
360
  out.push(
352
- ui.line(
353
- ui.Button({
354
- key: 'save-routes',
355
- label: 'Save routes',
356
- hotkey: 's',
357
- variant: dirty ? 'primary' : 'secondary',
358
- dimColor: !dirty,
359
- onPress: actions.saveRoutes,
360
- }),
361
- ' ',
362
- ui.Button({ key: 'discard-routes', label: 'Discard', dimColor: !dirty, onPress: actions.discardRoutes }),
363
- ' ',
364
- ui.Button({ key: 'reset-routes', label: 'Reset to defaults', hotkey: 'r', onPress: actions.resetRoutes }),
365
- ),
361
+ ui.Button({ key: 'reset-routes', label: 'Reset routes to defaults', hotkey: 'r', onPress: actions.resetRoutes }),
366
362
  ui.dim('A new model ID needs router.json → models: price, window, efforts.'),
367
- );
368
- return out;
369
- }
370
-
371
- function tuningTab(ui, config, view, _usage, actions) {
372
- const saved = tuningOf(config);
373
- const draft = { ...saved, ...view.tuning };
374
- const base = view.tuningBase ?? saved;
375
- const edited = (key) => Object.hasOwn(view.tuning ?? {}, key) && view.tuning[key] !== base[key];
376
- const rows = [
377
- ['downgradeVotes', 'Votes to go down', String, 'agreeing turns before cheaper'],
378
- ['horizon', 'Payback horizon', (v) => `${v} turns`, 'a switch repays its cache'],
379
- ['cashCapUsd', 'Credits cap', (v) => `$${v.toFixed(2)}`, 'max cold write on credits'],
380
- ];
381
- const dirty = rows.some(([key]) => edited(key));
382
- return [
383
- ...classifierSection(ui, config, view, actions),
384
363
  ui.text(' '),
385
- ui.head('POLICY · future turns'),
386
- ...rows.map(([key, label, format, hint]) =>
364
+ ui.line(ui.head('POLICY'), ui.dim(' · applies next turn · edit, then Save')),
365
+ ...POLICY_ROWS.map(([key, label, format, hint]) =>
387
366
  ui.line(
388
367
  ui.cell(20, label),
389
368
  ui.cell(
390
369
  12,
391
- choice(ui, key, draft[key], format, (value) => actions.tune(key, value)),
370
+ choice(ui, key, tuning[key], format, (value) => actions.tune(key, value)),
392
371
  ),
393
- ui.cell(2, edited(key) ? ui.text('●', { color: 'yellow' }) : ''),
372
+ marker(ui, policy.includes(key)),
394
373
  ui.dim(hint),
395
374
  ),
396
375
  ),
397
- ui.line(
398
- ui.Button({
399
- key: 'save-tuning',
400
- label: 'Save tuning',
401
- variant: dirty ? 'primary' : 'secondary',
402
- dimColor: !dirty,
403
- onPress: actions.saveTuning,
404
- }),
405
- ' ',
406
- ui.Button({ key: 'reset-tuning', label: 'Discard', dimColor: !dirty, onPress: actions.resetTuning }),
407
- ),
376
+ ui.Button({ key: 'reset-policy', label: 'Reset policy to defaults', onPress: actions.resetPolicy }),
408
377
  ui.text(' '),
409
378
  ui.head('CONFIG'),
410
379
  ui.line(
@@ -412,7 +381,8 @@ function tuningTab(ui, config, view, _usage, actions) {
412
381
  view.configPath ? ui.Button({ key: 'copy-path', label: 'copy', onPress: actions.copyPath }) : null,
413
382
  ),
414
383
  ui.dim('Main conversation only. Subagents keep their own model.'),
415
- ];
384
+ );
385
+ return out;
416
386
  }
417
387
 
418
388
  // A Select over TUNING_CHOICES[key], with a saved value outside them kept as the first option.
@@ -427,12 +397,11 @@ function choice(ui, key, value, format, pick) {
427
397
  });
428
398
  }
429
399
 
430
- // One row per configured classifier: pressing a row makes it active at once, written to router.json, with Undo. The
431
- // deadline belongs to the active classifier and saves at once too; the policy below keeps its draft and Save.
432
- function classifierSection(ui, config, view, actions) {
400
+ // One row per configured classifier. A row press and the deadline are single values with nothing to review as a set,
401
+ // so each writes router.json at once; Undo in the status bar puts it back.
402
+ function classifierTab(ui, config, view, _usage, actions) {
433
403
  const active = activeClassifier(config);
434
404
  const health = view.health ?? { failures: 0, pausedUntil: 0 };
435
- const undo = view.classifierUndo;
436
405
  const rows = Object.entries(config.classifiers).map(([id, entry]) => {
437
406
  const isActive = id === config.classifier;
438
407
  const missing = missingCredentials(view, id);
@@ -456,16 +425,9 @@ function classifierSection(ui, config, view, actions) {
456
425
  );
457
426
  });
458
427
  return [
459
- ui.head('CLASSIFIER · asked once per new turn'),
428
+ ui.line(ui.head('CLASSIFIER'), ui.dim(' · applies next turn · saves at once')),
429
+ ui.dim('Asked once per new turn.'),
460
430
  ...rows,
461
- undo && undo !== config.classifier && Object.hasOwn(config.classifiers, undo)
462
- ? ui.line(
463
- ui.text(`Switched from ${config.classifiers[undo].label}: ${active.label} from the next turn `, {
464
- color: 'yellow',
465
- }),
466
- ui.Button({ key: 'undo-classifier', label: 'Undo', onPress: actions.undoClassifier }),
467
- )
468
- : null,
469
431
  ui.line(
470
432
  ui.cell(9, 'Deadline'),
471
433
  ui.cell(
@@ -487,6 +449,56 @@ function classifierSection(ui, config, view, actions) {
487
449
  ];
488
450
  }
489
451
 
452
+ // Green for a write or its undo, red for a refused write, yellow for everything else that needs a look.
453
+ const noticeColor = (notice) =>
454
+ /^Not saved/.test(notice) ? 'red' : /^(Saved|Undid|Path copied)/.test(notice) ? 'green' : 'yellow';
455
+
456
+ // The one place for commit state on every tab: the unsaved routing diff with Save and Discard, the last notice, and
457
+ // Undo for the last write to router.json.
458
+ function statusBar(ui, config, view, actions) {
459
+ const changes = routingChanges(config, view);
460
+ const out = [];
461
+ if (changes.count) {
462
+ const diff = (key, before, after) => [
463
+ ui.text(`- ${key.padEnd(30)} ${before}`, { color: 'red' }),
464
+ ui.text(`+ ${key.padEnd(30)} ${after}`, { color: 'green' }),
465
+ ];
466
+ out.push(ui.text(' '), ui.dim('router.json changes:'));
467
+ for (const tier of changes.tiers)
468
+ out.push(
469
+ ...diff(
470
+ `routes.${tier}`,
471
+ routeName(config, config.routes[tier]),
472
+ routeName(config, changes.draft.routes[tier]),
473
+ ),
474
+ );
475
+ if (changes.baseline) out.push(...diff('baselineTier', config.baselineTier, changes.draft.baselineTier));
476
+ for (const [key, , format, , field] of POLICY_ROWS.filter(([key]) => changes.policy.includes(key)))
477
+ out.push(...diff(field, format(changes.saved[key]), format(changes.tuning[key])));
478
+ out.push(
479
+ ui.line(
480
+ ui.text(`● ${changes.count} unsaved routing change${changes.count === 1 ? '' : 's'} `, { color: 'yellow' }),
481
+ ui.Button({
482
+ key: 'save-routing',
483
+ label: 'Save',
484
+ hotkey: 's',
485
+ variant: 'primary',
486
+ onPress: actions.saveRouting,
487
+ }),
488
+ ' ',
489
+ ui.Button({ key: 'discard-routing', label: 'Discard', hotkey: 'd', onPress: actions.discardRouting }),
490
+ ),
491
+ );
492
+ }
493
+ const undo = view.lastWrite ? ui.Button({ key: 'undo', label: 'Undo', hotkey: 'u', onPress: actions.undo }) : null;
494
+ const confirmsWrite = Boolean(undo && view.notice?.startsWith('Saved'));
495
+ if (view.notice || undo) out.push(ui.text(' '));
496
+ if (view.notice)
497
+ out.push(ui.line(ui.text(`${view.notice} `, { color: noticeColor(view.notice) }), confirmsWrite ? undo : null));
498
+ if (undo && !confirmsWrite) out.push(ui.line(ui.dim(`Last change: ${view.lastWrite.label} `), undo));
499
+ return out;
500
+ }
501
+
490
502
  function usageTab(ui, config, view, usage) {
491
503
  const metrics = usageMetrics(config, view, usage);
492
504
  const history = view.history ?? [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexeiled/claude-router",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Native Claude Code Mod: model and effort routing for the main conversation, advised by Jev, Clef or Clef Flash.",
5
5
  "license": "MIT",
6
6
  "author": "Alexei Ledenev",
package/types/index.d.ts CHANGED
@@ -60,9 +60,9 @@ declare module 'claude-code' {
60
60
  tuning?: Partial<RouterTuning> | null;
61
61
  tuningBase?: RouterTuning | null;
62
62
  routeDraft?: (RouterRoutes & { base: RouterRoutes }) | null;
63
- // The classifier Undo returns to after a switch in the pane.
64
- classifierUndo?: string | null;
65
- tab?: 'now' | 'tiers' | 'tuning' | 'usage';
63
+ // The last pane write to router.json: each leaf it changed with the value the file had before, none if absent.
64
+ lastWrite?: { label: string; leaves: { path: string[]; value?: unknown }[] } | null;
65
+ tab?: 'now' | 'routing' | 'classifier' | 'usage';
66
66
  help?: boolean;
67
67
  bandDetail?: boolean;
68
68
  notice?: string | null;
@@ -1,62 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 594 477" role="img" aria-labelledby="title desc">
2
- <title id="title">Router pane, Tiers tab</title>
3
- <desc id="desc">Model and effort per tier with prices and windows, the baseline tier, how the policy prices each step up, and the router.json change Save routes will write.</desc>
4
- <style>
5
- text { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace; font-size: 13px; }
6
- .cap { font-family: system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 12px; fill: #9a988f; }
7
- </style>
8
- <rect width="594" height="477" rx="8" fill="#1c1c1c"/>
9
- <rect x="10" y="10" width="574" height="457" rx="6" fill="none" stroke="#3f5f8f"/>
10
- <text x="24.0" y="34" fill="#5fafd7" font-weight="700" xml:space="preserve">ROUTER · Auto</text>
11
- <text x="148.8" y="34" fill="#87d787" xml:space="preserve">Jev ready · 347 ms</text>
12
- <text x="24.0" y="53" fill="#87afff" font-weight="700" xml:space="preserve">[ Auto ]</text>
13
- <text x="94.2" y="53" fill="#d0d0d0" xml:space="preserve">[ Manual: keep /model ]</text>
14
- <text x="24.0" y="72" fill="#d0d0d0" xml:space="preserve">[ Now ]</text>
15
- <text x="86.4" y="72" fill="#87afff" font-weight="700" xml:space="preserve">[ Tiers ]</text>
16
- <text x="164.4" y="72" fill="#d0d0d0" xml:space="preserve">[ Tuning ]</text>
17
- <text x="250.2" y="72" fill="#d0d0d0" xml:space="preserve">[ Usage ]</text>
18
- <text x="328.2" y="72" fill="#d0d0d0" xml:space="preserve">[ ? ]</text>
19
- <text x="24.0" y="110" fill="#5fafd7" font-weight="700" xml:space="preserve">ROUTES · future turns</text>
20
- <text x="24.0" y="129" fill="#7c7c7c" xml:space="preserve">tier model effort $/M in · out window</text>
21
- <text x="24.0" y="148" fill="#e0708a" font-weight="700" xml:space="preserve">high</text>
22
- <text x="86.4" y="148" fill="#d0d0d0" xml:space="preserve">Opus 5.5 ▾</text>
23
- <text x="195.6" y="148" fill="#d0d0d0" xml:space="preserve">xhigh ▾</text>
24
- <text x="289.2" y="148" fill="#d0d0d0" xml:space="preserve">4 · 20</text>
25
- <text x="398.4" y="148" fill="#d0d0d0" xml:space="preserve">1M</text>
26
- <text x="24.0" y="167" fill="#d7af5f" font-weight="700" xml:space="preserve">medium</text>
27
- <text x="86.4" y="167" fill="#d0d0d0" xml:space="preserve">Sonnet 5.5 ▾</text>
28
- <text x="195.6" y="167" fill="#d0d0d0" xml:space="preserve">xhigh ▾</text>
29
- <text x="289.2" y="167" fill="#d0d0d0" xml:space="preserve">2 · 10</text>
30
- <text x="398.4" y="167" fill="#d0d0d0" xml:space="preserve">1M</text>
31
- <text x="414.0" y="167" fill="#d7af5f" xml:space="preserve"> ●</text>
32
- <text x="24.0" y="186" fill="#5f9fe0" font-weight="700" xml:space="preserve">low</text>
33
- <text x="86.4" y="186" fill="#d0d0d0" xml:space="preserve">Sonnet 5.5 ▾</text>
34
- <text x="195.6" y="186" fill="#d0d0d0" xml:space="preserve">session ▾</text>
35
- <text x="289.2" y="186" fill="#d0d0d0" xml:space="preserve">2 · 10</text>
36
- <text x="398.4" y="186" fill="#d0d0d0" xml:space="preserve">1M</text>
37
- <text x="24.0" y="205" fill="#5fd7af" font-weight="700" xml:space="preserve">micro</text>
38
- <text x="86.4" y="205" fill="#d0d0d0" xml:space="preserve">Haiku 4.5 ▾</text>
39
- <text x="195.6" y="205" fill="#7c7c7c" xml:space="preserve">none</text>
40
- <text x="289.2" y="205" fill="#d0d0d0" xml:space="preserve">1 · 5</text>
41
- <text x="398.4" y="205" fill="#d0d0d0" xml:space="preserve">200K</text>
42
- <text x="24.0" y="224" fill="#d0d0d0" xml:space="preserve">Baseline tier: low ▾</text>
43
- <text x="180.0" y="224" fill="#7c7c7c" xml:space="preserve"> start here, fall back here</text>
44
- <text x="24.0" y="262" fill="#5fafd7" font-weight="700" xml:space="preserve">SWITCH COST · from these routes</text>
45
- <text x="24.0" y="281" fill="#7c7c7c" xml:space="preserve">· </text>
46
- <text x="39.6" y="281" fill="#d0d0d0" xml:space="preserve">medium → high </text>
47
- <text x="164.4" y="281" fill="#d0d0d0" xml:space="preserve">model change: priced as a cold cache write</text>
48
- <text x="24.0" y="300" fill="#7c7c7c" xml:space="preserve">· </text>
49
- <text x="39.6" y="300" fill="#d0d0d0" xml:space="preserve">low → medium </text>
50
- <text x="164.4" y="300" fill="#d0d0d0" xml:space="preserve">same model, new effort: priced as a new cache</text>
51
- <text x="24.0" y="319" fill="#7c7c7c" xml:space="preserve">· </text>
52
- <text x="39.6" y="319" fill="#d0d0d0" xml:space="preserve">micro → low </text>
53
- <text x="164.4" y="319" fill="#d0d0d0" xml:space="preserve">model change: priced as a cold cache write</text>
54
- <text x="24.0" y="357" fill="#7c7c7c" xml:space="preserve">router.json changes:</text>
55
- <text x="24.0" y="376" fill="#e06c6c" xml:space="preserve">- routes.medium Opus 5.5 · medium</text>
56
- <text x="24.0" y="395" fill="#87d787" xml:space="preserve">+ routes.medium Sonnet 5.5 · xhigh</text>
57
- <text x="24.0" y="414" fill="#87afff" font-weight="700" xml:space="preserve">[ Save routes ]</text>
58
- <text x="148.8" y="414" fill="#d0d0d0" xml:space="preserve">[ Discard ]</text>
59
- <text x="242.4" y="414" fill="#d0d0d0" xml:space="preserve">[ Reset to defaults ]</text>
60
- <text x="24.0" y="433" fill="#7c7c7c" xml:space="preserve">A new model ID needs router.json → models: price, window, efforts.</text>
61
- <text x="24.0" y="452" fill="#d0d0d0" xml:space="preserve">[ Close ]</text>
62
- </svg>
@@ -1,58 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 594 515" role="img" aria-labelledby="title desc">
2
- <title id="title">Router pane, Tuning tab</title>
3
- <desc id="desc">The classifier rows with the active one marked, a missing Jev API key with Set up, Undo after a switch, the deadline, health, the receiving host and the credentials each classifier needs, then the policy controls.</desc>
4
- <style>
5
- text { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace; font-size: 13px; }
6
- .cap { font-family: system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 12px; fill: #9a988f; }
7
- </style>
8
- <rect width="594" height="515" rx="8" fill="#1c1c1c"/>
9
- <rect x="10" y="10" width="574" height="495" rx="6" fill="none" stroke="#3f5f8f"/>
10
- <text x="24.0" y="34" fill="#5fafd7" font-weight="700" xml:space="preserve">ROUTER · Auto</text>
11
- <text x="148.8" y="34" fill="#87d787" xml:space="preserve">Clef Flash ready</text>
12
- <text x="24.0" y="53" fill="#87afff" font-weight="700" xml:space="preserve">[ Auto ]</text>
13
- <text x="94.2" y="53" fill="#d0d0d0" xml:space="preserve">[ Manual: keep /model ]</text>
14
- <text x="24.0" y="72" fill="#d0d0d0" xml:space="preserve">[ Now ]</text>
15
- <text x="86.4" y="72" fill="#d0d0d0" xml:space="preserve">[ Tiers ]</text>
16
- <text x="164.4" y="72" fill="#87afff" font-weight="700" xml:space="preserve">[ Tuning ]</text>
17
- <text x="250.2" y="72" fill="#d0d0d0" xml:space="preserve">[ Usage ]</text>
18
- <text x="328.2" y="72" fill="#d0d0d0" xml:space="preserve">[ ? ]</text>
19
- <text x="24.0" y="110" fill="#5fafd7" font-weight="700" xml:space="preserve">CLASSIFIER · asked once per new turn</text>
20
- <text x="24.0" y="129" fill="#d0d0d0" xml:space="preserve">[ ○ Jev ]</text>
21
- <text x="164.4" y="129" fill="#7c7c7c" xml:space="preserve">api.typesafe.ai</text>
22
- <text x="320.4" y="129" fill="#d7af5f" xml:space="preserve">○ no API key </text>
23
- <text x="429.6" y="129" fill="#d0d0d0" xml:space="preserve">[ Set up ]</text>
24
- <text x="24.0" y="148" fill="#d0d0d0" xml:space="preserve">[ ○ Clef ]</text>
25
- <text x="164.4" y="148" fill="#7c7c7c" xml:space="preserve">api.cloudflare.com</text>
26
- <text x="320.4" y="148" fill="#87d787" xml:space="preserve">● ready</text>
27
- <text x="24.0" y="167" fill="#87afff" font-weight="700" xml:space="preserve">[ ◉ Clef Flash ]</text>
28
- <text x="164.4" y="167" fill="#7c7c7c" xml:space="preserve">api.cloudflare.com</text>
29
- <text x="320.4" y="167" fill="#87d787" xml:space="preserve">● ready</text>
30
- <text x="24.0" y="186" fill="#d7af5f" xml:space="preserve">Switched from Clef: Clef Flash from the next turn </text>
31
- <text x="421.8" y="186" fill="#d0d0d0" xml:space="preserve">[ Undo ]</text>
32
- <text x="24.0" y="205" fill="#d0d0d0" xml:space="preserve">Deadline</text>
33
- <text x="94.2" y="205" fill="#d0d0d0" xml:space="preserve">3000 ms ▾</text>
34
- <text x="187.8" y="205" fill="#7c7c7c" xml:space="preserve">then keep the model</text>
35
- <text x="24.0" y="224" fill="#d0d0d0" xml:space="preserve">Health active · 0 recent failures</text>
36
- <text x="24.0" y="243" fill="#7c7c7c" xml:space="preserve">Sends prompt + 6 recent turns → api.cloudflare.com</text>
37
- <text x="24.0" y="262" fill="#d0d0d0" xml:space="preserve">Credentials </text>
38
- <text x="125.4" y="262" fill="#d0d0d0" xml:space="preserve">[ Edit ]</text>
39
- <text x="187.8" y="262" fill="#7c7c7c" xml:space="preserve"> opens /plugin configure</text>
40
- <text x="24.0" y="281" fill="#7c7c7c" xml:space="preserve"> Jev: API key · Clef, Clef Flash: API token, account ID</text>
41
- <text x="24.0" y="319" fill="#5fafd7" font-weight="700" xml:space="preserve">POLICY · future turns</text>
42
- <text x="24.0" y="338" fill="#d0d0d0" xml:space="preserve">Votes to go down</text>
43
- <text x="180.0" y="338" fill="#d0d0d0" xml:space="preserve">2 ▾</text>
44
- <text x="289.2" y="338" fill="#7c7c7c" xml:space="preserve">agreeing turns before cheaper</text>
45
- <text x="24.0" y="357" fill="#d0d0d0" xml:space="preserve">Payback horizon</text>
46
- <text x="180.0" y="357" fill="#d0d0d0" xml:space="preserve">5 turns ▾</text>
47
- <text x="289.2" y="357" fill="#7c7c7c" xml:space="preserve">a switch repays its cache</text>
48
- <text x="24.0" y="376" fill="#d0d0d0" xml:space="preserve">Credits cap</text>
49
- <text x="180.0" y="376" fill="#d0d0d0" xml:space="preserve">$2.00 ▾</text>
50
- <text x="289.2" y="376" fill="#7c7c7c" xml:space="preserve">max cold write on credits</text>
51
- <text x="24.0" y="395" fill="#7c7c7c" xml:space="preserve">[ Save tuning ]</text>
52
- <text x="148.8" y="395" fill="#7c7c7c" xml:space="preserve">[ Discard ]</text>
53
- <text x="24.0" y="433" fill="#5fafd7" font-weight="700" xml:space="preserve">CONFIG</text>
54
- <text x="24.0" y="452" fill="#d0d0d0" xml:space="preserve">File ~/.claude/router.json </text>
55
- <text x="273.6" y="452" fill="#d0d0d0" xml:space="preserve">[ copy ]</text>
56
- <text x="24.0" y="471" fill="#7c7c7c" xml:space="preserve">Main conversation only. Subagents keep their own model.</text>
57
- <text x="24.0" y="490" fill="#d0d0d0" xml:space="preserve">[ Close ]</text>
58
- </svg>