@alexeiled/claude-router 1.3.0 → 1.3.2
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 +20 -0
- package/README.md +2 -2
- package/docs/architecture.md +17 -13
- package/docs/configuration.md +3 -3
- package/docs/evaluation.md +1 -1
- package/docs/native-router.md +1 -1
- package/docs/router-pane-now.svg +1 -1
- package/docs/router-pane-routing.svg +4 -4
- package/docs/user-guide.md +1 -1
- package/hooks/native-router.mjs +423 -519
- package/lib/{native-band.mjs → band.mjs} +22 -28
- package/lib/{native-jev.mjs → classifier-client.mjs} +8 -8
- package/lib/{jev-contract.mjs → classifier-contract.mjs} +2 -2
- package/lib/config-file.mjs +62 -0
- package/lib/config.mjs +21 -8
- package/lib/{native-cost.mjs → cost.mjs} +6 -6
- package/lib/{native-display.mjs → display.mjs} +42 -14
- package/lib/{native-panel.mjs → panel.mjs} +15 -23
- package/lib/policy.mjs +6 -6
- package/lib/{native-router.mjs → route.mjs} +30 -31
- package/lib/view.mjs +71 -0
- package/package.json +6 -4
- /package/lib/{facts-pure.mjs → facts.mjs} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "router",
|
|
3
3
|
"displayName": "Router",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.2",
|
|
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,25 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.3.2 (2026-10-08)
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- The band and the pane's **Served** row now call a reply a fallback by the same rule routing uses: the requested model, or its one mapped dated snapshot (Haiku 4.5). Before, they accepted any dated suffix of the requested model, so a reply that routing treated as an engine substitution could show no **fallback**.
|
|
8
|
+
- Pressing **?** in the pane or **2 rows** on the band twice before the next redraw now toggles twice. The second press used to repeat the first.
|
|
9
|
+
|
|
10
|
+
### Internal
|
|
11
|
+
|
|
12
|
+
- Module names drop the historical `native-` and `jev` prefixes: `lib/classifier-contract.mjs`, `classifier-client.mjs` (class `ClassifierClient`), `route.mjs`, `cost.mjs`, `panel.mjs`, `band.mjs`, `display.mjs` and `facts.mjs`. The hook entry stays `hooks/native-router.mjs`; option names, state keys and the pane id are unchanged.
|
|
13
|
+
- Pure logic moved out of the hooks module into `lib/config-file.mjs` and `lib/view.mjs`, with tests. The hook tests are split by area, and lint is stricter, with complexity limits.
|
|
14
|
+
- `npm run typecheck` runs `tsc` on `lib/` in CI and in the pre-push hook. TypeScript is a dev dependency for this check only.
|
|
15
|
+
|
|
16
|
+
## 1.3.1 (2026-10-08)
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- `micro` is now Haiku 5.5 at `low` effort (was Haiku 4.5 with no effort setting). The `haiku` alias is `claude-haiku-5-5` with a 1,000,000-token window, all five effort levels, and list prices of 0.1 / 0.5 / 0.01 USD per million tokens. Those prices hold for prompts up to 100,000 tokens and are higher above, so estimates run low there.
|
|
21
|
+
- To keep Haiku 4.5, set `models.haiku` to `claude-haiku-4-5` with `"efforts": []`, a 200,000-token window, and 1 / 5 / 0.1 prices, and set `routes.micro.effort` to `null`.
|
|
22
|
+
|
|
3
23
|
## 1.3.0 (2026-10-06)
|
|
4
24
|
|
|
5
25
|
### Changed
|
package/README.md
CHANGED
|
@@ -40,7 +40,7 @@ The active classifier labels a new logical turn once. Tool continuations keep th
|
|
|
40
40
|
|
|
41
41
|
| Tier | Default model | Effort |
|
|
42
42
|
| -------- | ------------- | ------------------------ |
|
|
43
|
-
| `micro` | Haiku
|
|
43
|
+
| `micro` | Haiku 5.5 | `low` |
|
|
44
44
|
| `low` | Sonnet 5.5 | Keeps the session effort |
|
|
45
45
|
| `medium` | Opus 5.5 | `medium` |
|
|
46
46
|
| `high` | Opus 5.5 | `xhigh` |
|
|
@@ -77,7 +77,7 @@ Run `/router` to open the pane: route status, per-tier controls, tuning, and usa
|
|
|
77
77
|
Before a push, run the same checks as CI. `npm run validate` and `npm run test:plugin` need the `claude` CLI: they load the Mod in the Claude Code engine, which refuses some faults that lint and unit tests miss.
|
|
78
78
|
|
|
79
79
|
```sh
|
|
80
|
-
npm run check && npm test && npm run validate && npm run test:plugin
|
|
80
|
+
npm run check && npm run typecheck && npm test && npm run validate && npm run test:plugin
|
|
81
81
|
```
|
|
82
82
|
|
|
83
83
|
## Documentation
|
package/docs/architecture.md
CHANGED
|
@@ -34,21 +34,25 @@ The active classifier receives only the current prompt and up to six recent user
|
|
|
34
34
|
|
|
35
35
|
All classifiers share one wire contract: the same `state` and typed `questions` request, and the same `answers.route` choice with per-tier probabilities. Cloudflare's REST API wraps the answer in `{ result, success, errors }`, which the parser unwraps.
|
|
36
36
|
|
|
37
|
-
Claude Code builds each request for the model the Mod selects, so no request rewriting is needed: Haiku
|
|
37
|
+
Claude Code builds each request for the model the Mod selects, so no request rewriting is needed: Haiku 4.5 got its own thinking mode and a 32K output cap. On Claude Code 2.1.289, a billed chain of pinned turns (Opus, Haiku 4.5, Sonnet at `xhigh`, Sonnet, Haiku 4.5) used a tool on every turn over the previous models' history, and no request was rejected. Sonnet and Opus accepted histories above 589K input tokens. These checks cover tested requests. They do not prove every Claude Code feature combination.
|
|
38
38
|
|
|
39
39
|
## Responsibilities
|
|
40
40
|
|
|
41
|
-
| Component
|
|
42
|
-
|
|
|
43
|
-
| [Native hooks](../hooks/native-router.mjs)
|
|
44
|
-
| [
|
|
45
|
-
| [
|
|
46
|
-
| [Router controller](../lib/
|
|
47
|
-
| [Policy](../lib/policy.mjs)
|
|
48
|
-
| [
|
|
49
|
-
| [
|
|
50
|
-
| [
|
|
51
|
-
|
|
|
41
|
+
| Component | Responsibility |
|
|
42
|
+
| ----------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
|
|
43
|
+
| [Native hooks](../hooks/native-router.mjs) | Turn identity, controls, lifecycle, per-step rewrites, response observation, pane actions, and every host call. |
|
|
44
|
+
| [Classifier contract](../lib/classifier-contract.mjs) | Classifier request payload, credentials and endpoint filling, answer validation, and retry rules. |
|
|
45
|
+
| [Classifier client](../lib/classifier-client.mjs) | Classifier HTTP, deadline, in-flight admission, and circuit breaker. |
|
|
46
|
+
| [Router controller](../lib/route.mjs) | Context fit, model identity, engine fallback, cache observations, and one-turn pins. |
|
|
47
|
+
| [Policy](../lib/policy.mjs) | Tier votes, escalation, and switching gates. |
|
|
48
|
+
| [Costs](../lib/cost.mjs) | Cache uncertainty bounds and switching estimates. |
|
|
49
|
+
| [Router view](../lib/view.mjs) | The view's initial shape and the usage readings each reply adds to it. |
|
|
50
|
+
| [Config file](../lib/config-file.mjs) | Pane writes to `router.json`: the validated rewrite and what Undo restores. |
|
|
51
|
+
| [Panel](../lib/panel.mjs) | Tabbed pane: route status, tier pins, the route editor, tuning, and usage. |
|
|
52
|
+
| [Router band](../lib/band.mjs) | Status band segments fitted to the band's width, and route-change toasts. |
|
|
53
|
+
| Claude Code | API requests, tools, authentication, stream output, and usage ledger. |
|
|
54
|
+
|
|
55
|
+
Every function that takes the engine interface `$` lives in the hooks module: the engine does not follow `$` across an import, so the modules in `lib/` stay pure.
|
|
52
56
|
|
|
53
57
|
Node.js is not part of routing. It is used for development, the optional configuration migration, and the classifier probe.
|
|
54
58
|
|
|
@@ -78,7 +82,7 @@ In a 20-process loopback test, timeout fallback had 1,504 ms p95 and 1,505 ms wo
|
|
|
78
82
|
|
|
79
83
|
## Cache and cost
|
|
80
84
|
|
|
81
|
-
Cache identity uses the exact response model ID and effective effort. The
|
|
85
|
+
Cache identity uses the exact response model ID and effective effort. The Haiku 4.5 dated snapshot has an explicit mapping; Haiku 5.5 has no dated ID. An unrecognized substituted model gets no cache credit for the requested route.
|
|
82
86
|
|
|
83
87
|
The cached prefix is observed `cache_read + cache_creation`. Output tokens count only toward the next context size. Freshness uses the configured five-minute lifetime with its safety margin. Claude's usage counters do not prove one-hour cache lifetime.
|
|
84
88
|
|
package/docs/configuration.md
CHANGED
|
@@ -32,7 +32,7 @@ The default baseline is tier `low`. Each route refers to an alias in `models`.
|
|
|
32
32
|
|
|
33
33
|
| Tier | Model alias | Model ID | Effort |
|
|
34
34
|
| -------- | ----------- | ------------------- | ------------------------------------ |
|
|
35
|
-
| `micro` | `haiku` | `claude-haiku-
|
|
35
|
+
| `micro` | `haiku` | `claude-haiku-5-5` | `low` |
|
|
36
36
|
| `low` | `sonnet` | `claude-sonnet-5-5` | Keeps the effort sent by Claude Code |
|
|
37
37
|
| `medium` | `opus` | `claude-opus-5-5` | `medium` |
|
|
38
38
|
| `high` | `opus` | `claude-opus-5-5` | `xhigh` |
|
|
@@ -43,9 +43,9 @@ Default model settings:
|
|
|
43
43
|
| -------- | --------------------------------------------------- | -------------- | ------- | --------------------------------------- |
|
|
44
44
|
| `opus` | 4 / 20 / 0.2 | 1,000,000 | `plan` | `low`, `medium`, `high`, `xhigh`, `max` |
|
|
45
45
|
| `sonnet` | 2 / 10 / 0.2 | 1,000,000 | `plan` | `low`, `medium`, `high`, `xhigh`, `max` |
|
|
46
|
-
| `haiku` | 1 / 5 / 0.
|
|
46
|
+
| `haiku` | 0.1 / 0.5 / 0.01 | 1,000,000 | `plan` | `low`, `medium`, `high`, `xhigh`, `max` |
|
|
47
47
|
|
|
48
|
-
Prices are configured list-price inputs for estimates. They are not a subscription bill or a claim of savings. Haiku receives no effort field. A route without an effort keeps the session effort, clamped to what the model supports. To make a tier whose default names an effort keep the session effort instead, set `"effort": null`, for example `"routes": { "high": { "model": "opus", "effort": null } }`.
|
|
48
|
+
Prices are configured list-price inputs for estimates. They are not a subscription bill or a claim of savings. Haiku 5.5 prices are for prompts up to 100,000 tokens; above that Anthropic charges more, so estimates run low there. A model with `"efforts": []` receives no effort field. A route without an effort keeps the session effort, clamped to what the model supports. To make a tier whose default names an effort keep the session effort instead, set `"effort": null`, for example `"routes": { "high": { "model": "opus", "effort": null } }`.
|
|
49
49
|
|
|
50
50
|
## Classifiers
|
|
51
51
|
|
package/docs/evaluation.md
CHANGED
|
@@ -47,7 +47,7 @@ Run this command with the Team `decisions.jsonl` log available in its usual Clau
|
|
|
47
47
|
|
|
48
48
|
```sh
|
|
49
49
|
node experiments/mod-router/scripts/trace-eval.mjs
|
|
50
|
-
node --test
|
|
50
|
+
node --test experiments/mod-router/scripts/trace-eval.test.mjs
|
|
51
51
|
```
|
|
52
52
|
|
|
53
53
|
The script writes aggregate counts, reason histograms, route transitions, and shadow estimates. It excludes prompts, session identifiers, agent names, error text, headers, keys, and filesystem paths from the result. It reads the local profile log and writes the JSON result file.
|
package/docs/native-router.md
CHANGED
|
@@ -80,6 +80,6 @@ On 2026-10-05, live probes of Clef and Clef Flash on Workers AI took 0.7 to 1.3
|
|
|
80
80
|
|
|
81
81
|
Recorded acceptance checks cover the local HTTP deadline and one-request admission, session clear/resume, circuit-breaker pause, reload, replacement, unload, engine fallback, and interrupt during Jev advice. The interrupt check closed the loopback socket within 4 ms and discarded late advice without changing the active route or UI. Results are stored under [`experiments/mod-router/results`](../experiments/mod-router/results/).
|
|
82
82
|
|
|
83
|
-
A billed chain of pinned turns moved across Opus, Haiku, and Sonnet with a tool call on every turn, and no request was rejected. Claude Code builds each model's request itself; Haiku
|
|
83
|
+
A billed chain of pinned turns moved across Opus, Haiku 4.5, and Sonnet with a tool call on every turn, and no request was rejected. Claude Code builds each model's request itself; Haiku 4.5 received its own thinking mode and a 32K output cap. Haiku 5.5 was not probed. Sonnet and Opus accepted histories above 589K input tokens. These probes validate the tested path only. Claude Code and organization policy control other model and request combinations.
|
|
84
84
|
|
|
85
85
|
To stop routing in a session, run `/router off`. To stop loading the Mod, run `claude plugin disable router@alexei-led-claude-router` and restart.
|
package/docs/router-pane-now.svg
CHANGED
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
<text x="351.6" y="243" fill="#d0d0d0" xml:space="preserve"> 3% </text>
|
|
42
42
|
<text x="406.2" y="243" fill="#d0d0d0" xml:space="preserve">[ pin ]</text>
|
|
43
43
|
<text x="39.6" y="262" fill="#5fd7af" font-weight="700" xml:space="preserve">micro </text>
|
|
44
|
-
<text x="102.0" y="262" fill="#d0d0d0" xml:space="preserve">Haiku
|
|
44
|
+
<text x="102.0" y="262" fill="#d0d0d0" xml:space="preserve">Haiku 5.5 · low </text>
|
|
45
45
|
<text x="273.6" y="262" fill="#5fd7af" xml:space="preserve">░░░░░░░░░░</text>
|
|
46
46
|
<text x="351.6" y="262" fill="#d0d0d0" xml:space="preserve"> 2% </text>
|
|
47
47
|
<text x="406.2" y="262" fill="#d0d0d0" xml:space="preserve">[ pin ]</text>
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
<text x="304.8" y="186" fill="#d0d0d0" xml:space="preserve">2 · 10</text>
|
|
38
38
|
<text x="414.0" y="186" fill="#d0d0d0" xml:space="preserve">1M</text>
|
|
39
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
|
|
41
|
-
<text x="195.6" y="205" fill="#
|
|
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">
|
|
40
|
+
<text x="86.4" y="205" fill="#d0d0d0" xml:space="preserve">Haiku 5.5 ▾</text>
|
|
41
|
+
<text x="195.6" y="205" fill="#d0d0d0" xml:space="preserve">low ▾</text>
|
|
42
|
+
<text x="304.8" y="205" fill="#d0d0d0" xml:space="preserve">0.1 · 0.5</text>
|
|
43
|
+
<text x="414.0" y="205" fill="#d0d0d0" xml:space="preserve">1M</text>
|
|
44
44
|
<text x="24.0" y="224" fill="#d0d0d0" xml:space="preserve">Baseline tier: low ▾</text>
|
|
45
45
|
<text x="304.8" y="224" fill="#7c7c7c" xml:space="preserve">start here, fall back here</text>
|
|
46
46
|
<text x="24.0" y="262" fill="#5fafd7" font-weight="700" xml:space="preserve">SWITCH COST · from these routes</text>
|
package/docs/user-guide.md
CHANGED
|
@@ -118,7 +118,7 @@ A pin does not change the next turn after the pinned turn finishes. A fresh sess
|
|
|
118
118
|
|
|
119
119
|
## Edit routes and policy
|
|
120
120
|
|
|
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
|
|
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 a custom one with `"efforts": []`, shows `none`.
|
|
122
122
|
|
|
123
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`.
|
|
124
124
|
|