@alexeiled/claude-router 1.12.0 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +16 -0
- package/docs/architecture.md +1 -1
- package/docs/native-router.md +1 -1
- package/docs/router-pane-now.svg +111 -77
- package/docs/router-pane-usage-whatif.svg +62 -67
- package/docs/router-pane-usage.svg +34 -34
- package/docs/user-guide.md +10 -6
- package/hooks/native-router.mjs +34 -18
- package/lib/display.mjs +0 -5
- package/lib/panel.mjs +227 -93
- package/lib/view.mjs +50 -11
- package/package.json +1 -1
- package/types/index.d.ts +11 -4
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 696 781" role="img" aria-labelledby="title desc">
|
|
2
2
|
<title id="title">Router pane, Usage tab</title>
|
|
3
3
|
<desc id="desc">The last 7 days across sessions: the period row, routing saved against each session’s own model as a ledger (your model, cheaper models, stronger models, switch cache writes, routed), the replies and tokens, the cost by activity with coding opened to its routes and cost parts, the cost by day, what is worth a look with a link to Routes, subagents, and Delete history.</desc>
|
|
4
4
|
<style>
|
|
5
5
|
text { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace; font-size: 13px; }
|
|
6
6
|
.cap { font-family: system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 12px; fill: #9a988f; }
|
|
7
7
|
</style>
|
|
8
|
-
<rect width="
|
|
9
|
-
<rect x="10" y="10" width="
|
|
8
|
+
<rect width="696" height="781" rx="8" fill="#1c1c1c"/>
|
|
9
|
+
<rect x="10" y="10" width="676" height="761" rx="6" fill="none" stroke="#3f5f8f"/>
|
|
10
10
|
<text x="24.0" y="34" fill="#5fafd7" font-weight="700" xml:space="preserve">ROUTING</text>
|
|
11
11
|
<rect x="94.2" y="20" width="62.4" height="18" rx="4" fill="#87afff"/>
|
|
12
12
|
<text x="94.2" y="34" fill="#0d1016" font-weight="700" xml:space="preserve">[ ◉ on ]</text>
|
|
@@ -40,28 +40,28 @@
|
|
|
40
40
|
<text x="453.0" y="91" fill="#7c7c7c" xml:space="preserve"> p next</text>
|
|
41
41
|
<text x="24.0" y="110" fill="#7c7c7c" xml:space="preserve">all sessions · Oct 7 – Oct 13 · each session vs its own model</text>
|
|
42
42
|
<text x="24.0" y="148" fill="#d0d0d0" xml:space="preserve">Routing saved </text>
|
|
43
|
-
<text x="133.2" y="148" fill="#6fcf97" font-weight="700" xml:space="preserve">$
|
|
44
|
-
<text x="
|
|
43
|
+
<text x="133.2" y="148" fill="#6fcf97" font-weight="700" xml:space="preserve">$11.78 (43%)</text>
|
|
44
|
+
<text x="226.8" y="148" fill="#d0d0d0" xml:space="preserve"> vs your model</text>
|
|
45
45
|
<text x="55.2" y="186" fill="#d0d0d0" xml:space="preserve">Your model</text>
|
|
46
|
-
<text x="211.2" y="186" fill="#d0d0d0" xml:space="preserve"> $
|
|
46
|
+
<text x="211.2" y="186" fill="#d0d0d0" xml:space="preserve"> $27.11</text>
|
|
47
47
|
<text x="304.8" y="186" fill="#7c7c7c" xml:space="preserve">each session’s own model</text>
|
|
48
48
|
<text x="24.0" y="205" fill="#7c7c7c" xml:space="preserve"> − </text>
|
|
49
49
|
<text x="55.2" y="205" fill="#d0d0d0" xml:space="preserve">Cheaper models</text>
|
|
50
|
-
<text x="211.2" y="205" fill="#6fcf97" xml:space="preserve">
|
|
50
|
+
<text x="211.2" y="205" fill="#6fcf97" xml:space="preserve"> $12.29</text>
|
|
51
51
|
<text x="24.0" y="224" fill="#7c7c7c" xml:space="preserve"> + </text>
|
|
52
52
|
<text x="55.2" y="224" fill="#d0d0d0" xml:space="preserve">Stronger models</text>
|
|
53
53
|
<text x="211.2" y="224" fill="#d0d0d0" xml:space="preserve"> $0.00</text>
|
|
54
54
|
<text x="24.0" y="243" fill="#7c7c7c" xml:space="preserve"> + </text>
|
|
55
55
|
<text x="55.2" y="243" fill="#d0d0d0" xml:space="preserve">Switch cache writes</text>
|
|
56
|
-
<text x="211.2" y="243" fill="#f0b429" xml:space="preserve"> $0.
|
|
57
|
-
<text x="304.8" y="243" fill="#7c7c7c" xml:space="preserve">
|
|
56
|
+
<text x="211.2" y="243" fill="#f0b429" xml:space="preserve"> $0.51</text>
|
|
57
|
+
<text x="304.8" y="243" fill="#7c7c7c" xml:space="preserve">30 route switches · 4% of the saving</text>
|
|
58
58
|
<text x="24.0" y="262" fill="#7c7c7c" xml:space="preserve"> = </text>
|
|
59
59
|
<text x="55.2" y="262" fill="#d0d0d0" font-weight="700" xml:space="preserve">Routed</text>
|
|
60
|
-
<text x="211.2" y="262" fill="#d0d0d0" font-weight="700" xml:space="preserve">
|
|
60
|
+
<text x="211.2" y="262" fill="#d0d0d0" font-weight="700" xml:space="preserve"> $15.33</text>
|
|
61
61
|
<text x="304.8" y="262" fill="#5fafd7" xml:space="preserve">████████████</text>
|
|
62
62
|
<text x="398.4" y="262" fill="#7c7c7c" xml:space="preserve">░░░░░░░░░░</text>
|
|
63
|
-
<text x="476.4" y="262" fill="#7c7c7c" xml:space="preserve">
|
|
64
|
-
<text x="24.0" y="300" fill="#7c7c7c" xml:space="preserve">
|
|
63
|
+
<text x="476.4" y="262" fill="#7c7c7c" xml:space="preserve"> 57% of your model</text>
|
|
64
|
+
<text x="24.0" y="300" fill="#7c7c7c" xml:space="preserve"> 221 replies · 131 turns · input 15.25M · cache hit 90% · output 198.9K</text>
|
|
65
65
|
<text x="24.0" y="338" fill="#5fafd7" font-weight="700" xml:space="preserve">BY </text>
|
|
66
66
|
<rect x="55.2" y="324" width="93.6" height="18" rx="4" fill="#87afff"/>
|
|
67
67
|
<text x="55.2" y="338" fill="#0d1016" font-weight="700" xml:space="preserve">[ Activity ]</text>
|
|
@@ -73,45 +73,45 @@
|
|
|
73
73
|
<text x="24.0" y="357" fill="#7c7c7c" xml:space="preserve"> replies cost vs yours mostly on</text>
|
|
74
74
|
<text x="39.6" y="376" fill="#d0d0d0" xml:space="preserve">▾</text>
|
|
75
75
|
<text x="55.2" y="376" fill="#d7875f" font-style="italic" xml:space="preserve">coding</text>
|
|
76
|
-
<text x="211.2" y="376" fill="#d0d0d0" xml:space="preserve">
|
|
77
|
-
<text x="351.6" y="376" fill="#6fcf97" xml:space="preserve"> −$3.
|
|
76
|
+
<text x="211.2" y="376" fill="#d0d0d0" xml:space="preserve"> 125 $12.70</text>
|
|
77
|
+
<text x="351.6" y="376" fill="#6fcf97" xml:space="preserve"> −$3.55</text>
|
|
78
78
|
<text x="437.4" y="376" fill="#7c7c7c" xml:space="preserve"> Sonnet 5.5 · high</text>
|
|
79
|
-
<text x="70.8" y="395" fill="#d0d0d0" xml:space="preserve">
|
|
80
|
-
<text x="211.2" y="395" fill="#d0d0d0" xml:space="preserve">
|
|
81
|
-
<text x="351.6" y="395" fill="#
|
|
82
|
-
<text x="70.8" y="414" fill="#d0d0d0" xml:space="preserve">
|
|
83
|
-
<text x="211.2" y="414" fill="#d0d0d0" xml:space="preserve">
|
|
84
|
-
<text x="351.6" y="414" fill="#
|
|
85
|
-
<text x="24.0" y="433" fill="#7c7c7c" xml:space="preserve"> cheaper −$3.
|
|
79
|
+
<text x="70.8" y="395" fill="#d0d0d0" xml:space="preserve">Opus 5.5 · xhigh</text>
|
|
80
|
+
<text x="211.2" y="395" fill="#d0d0d0" xml:space="preserve"> 54 $7.02</text>
|
|
81
|
+
<text x="351.6" y="395" fill="#d0d0d0" xml:space="preserve"> $0.00</text>
|
|
82
|
+
<text x="70.8" y="414" fill="#d0d0d0" xml:space="preserve">Sonnet 5.5 · high</text>
|
|
83
|
+
<text x="211.2" y="414" fill="#d0d0d0" xml:space="preserve"> 71 $5.68</text>
|
|
84
|
+
<text x="351.6" y="414" fill="#6fcf97" xml:space="preserve"> −$3.55</text>
|
|
85
|
+
<text x="24.0" y="433" fill="#7c7c7c" xml:space="preserve"> cheaper −$3.69 · stronger $0.00 · switch +$0.14 · input 8.63M · output 112.5K</text>
|
|
86
86
|
<text x="39.6" y="452" fill="#d0d0d0" xml:space="preserve">▸</text>
|
|
87
87
|
<text x="55.2" y="452" fill="#d7875f" font-style="italic" xml:space="preserve">running</text>
|
|
88
|
-
<text x="211.2" y="452" fill="#d0d0d0" xml:space="preserve">
|
|
89
|
-
<text x="351.6" y="452" fill="#6fcf97" xml:space="preserve"> −$
|
|
88
|
+
<text x="211.2" y="452" fill="#d0d0d0" xml:space="preserve"> 50 $1.50</text>
|
|
89
|
+
<text x="351.6" y="452" fill="#6fcf97" xml:space="preserve"> −$4.50</text>
|
|
90
90
|
<text x="437.4" y="452" fill="#7c7c7c" xml:space="preserve"> Haiku 5.5 · high</text>
|
|
91
91
|
<text x="39.6" y="471" fill="#d0d0d0" xml:space="preserve">▸</text>
|
|
92
92
|
<text x="55.2" y="471" fill="#d7875f" font-style="italic" xml:space="preserve">exploring</text>
|
|
93
|
-
<text x="211.2" y="471" fill="#d0d0d0" xml:space="preserve">
|
|
94
|
-
<text x="351.6" y="471" fill="#6fcf97" xml:space="preserve"> −$
|
|
93
|
+
<text x="211.2" y="471" fill="#d0d0d0" xml:space="preserve"> 36 $1.01</text>
|
|
94
|
+
<text x="351.6" y="471" fill="#6fcf97" xml:space="preserve"> −$2.95</text>
|
|
95
95
|
<text x="437.4" y="471" fill="#7c7c7c" xml:space="preserve"> Haiku 5.5 · high</text>
|
|
96
96
|
<text x="39.6" y="490" fill="#d0d0d0" xml:space="preserve">▸</text>
|
|
97
97
|
<text x="55.2" y="490" fill="#d7875f" font-style="italic" xml:space="preserve">planning</text>
|
|
98
|
-
<text x="211.2" y="490" fill="#d0d0d0" xml:space="preserve">
|
|
99
|
-
<text x="351.6" y="490" fill="#6fcf97" xml:space="preserve"> −$0.
|
|
98
|
+
<text x="211.2" y="490" fill="#d0d0d0" xml:space="preserve"> 10 $0.12</text>
|
|
99
|
+
<text x="351.6" y="490" fill="#6fcf97" xml:space="preserve"> −$0.78</text>
|
|
100
100
|
<text x="437.4" y="490" fill="#7c7c7c" xml:space="preserve"> Haiku 5.5 · low</text>
|
|
101
101
|
<text x="24.0" y="528" fill="#5fafd7" font-weight="700" xml:space="preserve">COST BY DAY </text>
|
|
102
|
-
<text x="117.6" y="528" fill="#5fafd7" xml:space="preserve"
|
|
103
|
-
<text x="172.2" y="528" fill="#7c7c7c" xml:space="preserve"> peak $
|
|
102
|
+
<text x="117.6" y="528" fill="#5fafd7" xml:space="preserve">▂▃▁·▂▃█</text>
|
|
103
|
+
<text x="172.2" y="528" fill="#7c7c7c" xml:space="preserve"> peak $7.67 </text>
|
|
104
104
|
<rect x="289.2" y="514" width="85.8" height="18" rx="4" fill="#2e3340"/>
|
|
105
105
|
<text x="289.2" y="528" fill="#d0d0d0" xml:space="preserve">[ What if ]</text>
|
|
106
106
|
<text x="24.0" y="566" fill="#5fafd7" font-weight="700" xml:space="preserve">WORTH A LOOK</text>
|
|
107
107
|
<text x="117.6" y="566" fill="#7c7c7c" xml:space="preserve"> · from the numbers; answer quality is not measured</text>
|
|
108
108
|
<text x="39.6" y="585" fill="#d7875f" font-style="italic" xml:space="preserve">coding</text>
|
|
109
109
|
<text x="86.4" y="585" fill="#7c7c7c" xml:space="preserve"> · </text>
|
|
110
|
-
<text x="109.8" y="585" fill="#
|
|
111
|
-
<text x="
|
|
112
|
-
<text x="
|
|
113
|
-
<rect x="
|
|
114
|
-
<text x="
|
|
110
|
+
<text x="109.8" y="585" fill="#e0708a" font-weight="700" xml:space="preserve">high</text>
|
|
111
|
+
<text x="141.0" y="585" fill="#d0d0d0" xml:space="preserve"> carried 46% of the cost</text>
|
|
112
|
+
<text x="328.2" y="585" fill="#7c7c7c" xml:space="preserve"> · mostly Opus 5.5 · xhigh</text>
|
|
113
|
+
<rect x="546.6" y="571" width="78.0" height="18" rx="4" fill="#2e3340"/>
|
|
114
|
+
<text x="546.6" y="585" fill="#d0d0d0" xml:space="preserve">[ Routes ]</text>
|
|
115
115
|
<text x="24.0" y="623" fill="#5fafd7" font-weight="700" xml:space="preserve">SUBAGENTS · across sessions</text>
|
|
116
116
|
<text x="234.6" y="623" fill="#7c7c7c" xml:space="preserve"> subagent routing on</text>
|
|
117
117
|
<text x="24.0" y="642" fill="#7c7c7c" xml:space="preserve"> no subagents yet</text>
|
package/docs/user-guide.md
CHANGED
|
@@ -67,7 +67,7 @@ Run `/router` or select **Router** above the prompt. Without a UI surface, as in
|
|
|
67
67
|
|
|
68
68
|
| Tab | What it answers |
|
|
69
69
|
| ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
70
|
-
| 1 Now | What runs next turn, and why
|
|
70
|
+
| 1 Now | What runs next turn, and why, with a **pin** per tier; this session and today at a glance; the first finding worth a look. |
|
|
71
71
|
| 2 Routes | Which model runs: one grid of tiers by activities, the activity routing mode, and an editor for the selected cell. |
|
|
72
72
|
| 3 Policy | How readily the router changes models: the start tier, going down, going up, the activity threshold, the credits cap; the `router.json` path. |
|
|
73
73
|
| 4 Classifier | Which classifier to ask: one row per classifier to compare, the active one's deadline, wait, health and credentials, and the counts kept across sessions. |
|
|
@@ -75,9 +75,13 @@ Run `/router` or select **Router** above the prompt. Without a UI surface, as in
|
|
|
75
75
|
|
|
76
76
|
The top line of every tab, `ROUTING [ ◉ on ] [ ○ off ] Jev ready · 347 ms`, shows the routing mode, switches it, and says whether the classifier is ready. Press `o` or `f` while the pane has focus. **?** shows what the estimates leave out. When routing is unavailable, the top line reads `ROUTING unavailable Claude’s model is kept` with the reason under it, and offers no on or off: see [Troubleshooting](#troubleshooting).
|
|
77
77
|
|
|
78
|
-

|
|
79
79
|
|
|
80
|
-
The **Now** tab answers "what runs next turn, and why". **Next turn** names the tier, the model and effort, and, when an activity override runs, the tier's own model beside it. **Activity** names the classifier's activity as a verb, such as `coding 84%`, with the two next answers and the threshold at which an activity applies. **Why** gives the reason; under it, `Jev gave stronger tiers 88% (needs 82%) · switch ≈ $0.48` compares the classifier's support for the switch with the bar the policy set, and gives the estimated switch cost.
|
|
80
|
+
The **Now** tab answers "what runs next turn, and why". **Next turn** names the tier, the model and effort, and, when an activity override runs, the tier's own model beside it. **Activity** names the classifier's activity as a verb, such as `coding 84%`, with the two next answers and the threshold at which an activity applies. **Why** gives the reason; under it, `Jev gave stronger tiers 88% (needs 82%) · switch ≈ $0.48` compares the classifier's support for the switch with the bar the policy set, and gives the estimated switch cost. **Pin next** has one button per tier, strongest first, with the support the classifier gave it on the last turn; `▶` marks the tier that runs now. A press forces that tier for the next turn only.
|
|
81
|
+
|
|
82
|
+
**SESSION** sums this session from its first routed reply: `since 14:18 · 86 routed replies · 9 route switches`. The strip under it colors every reply since Claude Code started the session by the tier that served it; a dot marks replies routing did not serve, such as those with routing off. Each cell is one reply up to 48 cells. Past that, and on a pane too narrow for the cells, pairs of cells merge and the strip says how many replies a cell holds, so it spans all those replies on one line. After Claude Code restarts a resumed session, the strip starts again and says since when, such as `since 15:02`, while the heading still counts the whole session. The replies per tier, `■ low 41 ■ medium 12 ■ high 33`, double as the color key, and the routed replies per activity follow. **last switch** says when the route last changed and between which tiers, or between which routes when a switch stayed inside a tier, with the activity it ran for. The last line is what routing saved, or cost, against your model this session, with the switch cache writes in it; **Usage** opens the Usage tab on this session.
|
|
83
|
+
|
|
84
|
+
**TODAY** appears once another session added to today, with the same line for every session today and its own **Usage** link. **WORTH A LOOK** shows today's first finding from the Usage tab, from 20 routed replies, with the tab that changes it. The last lines give the context gauge, the cache reuse and the cost Claude reports; **details** adds the counters and estimates in [Understand usage and estimates](#understand-usage-and-estimates).
|
|
81
85
|
|
|
82
86
|
### Save and undo changes
|
|
83
87
|
|
|
@@ -134,8 +138,8 @@ These are estimates, not a bill. They hold the tokens and the output length the
|
|
|
134
138
|
- **Context** compares the larger available context reading with the routed model's configured window. The router reserves 20% of that window. Values can be unknown when Claude does not provide the needed estimate.
|
|
135
139
|
- **Cache** reuse is cache-read tokens divided by the last response's input counters.
|
|
136
140
|
- **Classifier support**, such as **Jev support**, is the probability the classifier gave each tier on the last classified turn. The line under **Why** compares the support for a switch with the bar the policy required, and shows the estimated switch cost.
|
|
137
|
-
- **
|
|
138
|
-
- **Input per reply**, under **details** on the Now tab, scales the last 30
|
|
141
|
+
- **Route switches** on the Now tab count the turns whose route differed from the turn before: a change of model or effort, so a move from Sonnet to Haiku inside `low` counts too, although its strip color stays. They are the switches the Usage tab counts, and a pin is not one. **Switch writes** is the cache-write cost of those switches inside the saving.
|
|
142
|
+
- **Input per reply**, under **details** on the Now tab, scales the input sizes of the last 30 replies from the lowest to the highest reading. It is a scale comparison, not a forecast.
|
|
139
143
|
- **Cache hits saved** is a configured-price estimate for cached reads before write costs. It is not a measured saving.
|
|
140
144
|
- **Next-turn difference** compares the candidate with the current model under five-minute and one-hour cache-write scenarios. A negative number means the candidate is estimated to cost less for that request.
|
|
141
145
|
- **Payback** estimates later turns to recover an initial difference under assumed future cache reads and the last observed output size. It does not guarantee savings.
|
|
@@ -201,7 +205,7 @@ These thresholds are starting values. They are not tuned on data yet.
|
|
|
201
205
|
|
|
202
206
|
### Read the activity on the pane
|
|
203
207
|
|
|
204
|
-
- **Now**: the **Activity** line names the classifier's choice as a verb with its share, the two next-best answers, and the threshold at which an activity applies, such as `coding 84% debugging 8% · planning 5% applies at 60%+`. An `uncertain` answer is shown dim: it applies no activity. In `on`, **Why** names the cell when the activity moved the route or the route is an override, such as `coding at low runs on Sonnet 5.5 · high`, or `low runs on its base route, Haiku 5.5 · high` for a move without an activity; a refused move, a hold, or a tier change keeps its reason. **
|
|
208
|
+
- **Now**: the **Activity** line names the classifier's choice as a verb with its share, the two next-best answers, and the threshold at which an activity applies, such as `coding 84% debugging 8% · planning 5% applies at 60%+`. An `uncertain` answer is shown dim: it applies no activity. In `on`, **Why** names the cell when the activity moved the route or the route is an override, such as `coding at low runs on Sonnet 5.5 · high`, or `low runs on its base route, Haiku 5.5 · high` for a move without an activity; a refused move, a hold, or a tier change keeps its reason. **SESSION** counts the routed replies per activity under the strip.
|
|
205
209
|
- **Routes**: see [Edit routes and policy](#edit-routes-and-policy). Each activity is a row of the grid, and a cell shows the model the activity runs at that tier.
|
|
206
210
|
- **Usage**: **BY** with **Activity** lists the period's replies, cost and difference against your model per activity, and `mostly on`, the route most of its replies used, such as `Sonnet 5.5 · high`; opening a row lists its routes. Replies whose turn had no applied activity count as `no activity`. The ledger's switch line counts the route switches by tier and by activity together. See [Compare routing with your model](#compare-routing-with-your-model).
|
|
207
211
|
- **Classifier**: **THIS SESSION** gives **Agreement**, how often the tools a turn used fit the classifier's activity (see [Evaluation](evaluation.md#tool-agreement)).
|
package/hooks/native-router.mjs
CHANGED
|
@@ -116,7 +116,14 @@ import {
|
|
|
116
116
|
USAGE_PREFIX,
|
|
117
117
|
usageAfterReset,
|
|
118
118
|
} from '../lib/usage.mjs';
|
|
119
|
-
import {
|
|
119
|
+
import {
|
|
120
|
+
CLEARED_READINGS,
|
|
121
|
+
continuationView,
|
|
122
|
+
healthOf,
|
|
123
|
+
initialView,
|
|
124
|
+
responseMetrics,
|
|
125
|
+
switchView,
|
|
126
|
+
} from '../lib/view.mjs';
|
|
120
127
|
|
|
121
128
|
// The engine follows $ only into functions declared in this file, never across an import: every helper that takes $
|
|
122
129
|
// lives here, and the pure parts live in lib/.
|
|
@@ -626,7 +633,7 @@ async function* passMain($, e, next, loop, version, nativeModel, reason, router)
|
|
|
626
633
|
const compared = await compareYours($, router, loop, response, e.effort ?? null, nativeModel);
|
|
627
634
|
if (compared) observed.yoursBy = compared.states;
|
|
628
635
|
const written = await $.state.set(ref, observed, { ifVersion: version });
|
|
629
|
-
if (written.isSet) await updateView($, router, responseMetrics(router.view, response, null));
|
|
636
|
+
if (written.isSet) await updateView($, router, responseMetrics(router.view, response, null, Date.now()));
|
|
630
637
|
}
|
|
631
638
|
return response;
|
|
632
639
|
}
|
|
@@ -719,6 +726,7 @@ async function decideTurn($, router, e, signal, step) {
|
|
|
719
726
|
routes: {},
|
|
720
727
|
});
|
|
721
728
|
await updateView($, router, {
|
|
729
|
+
...(activity.switched ? switchView(previous, selected.decision, activity.label, Date.now()) : {}),
|
|
722
730
|
phase: 'routed',
|
|
723
731
|
selectedModel: selected.decision.model,
|
|
724
732
|
actualModel: null,
|
|
@@ -772,6 +780,9 @@ async function transcript($) {
|
|
|
772
780
|
}
|
|
773
781
|
}
|
|
774
782
|
|
|
783
|
+
// The activity a route runs for, as the view labels it: only activity routing `on` applies one.
|
|
784
|
+
const activityLabel = (cfg, decision) => (cfg.activityRouting === 'on' ? (decision.activity ?? null) : null);
|
|
785
|
+
|
|
775
786
|
// A tool continuation whose turn shows stronger work than its route was chosen for moves up once (observedMove). Only
|
|
776
787
|
// tool calls after the last applied review count (`loop.observedFrom`): the review judged the ones before. The
|
|
777
788
|
// transcript is read only when some activity's route at this tier is stronger than the running one.
|
|
@@ -787,7 +798,11 @@ async function moveOnObserved($, router, cfg, loop, e, context) {
|
|
|
787
798
|
// Replies from here on are labelled with the moved activity; the classifier's answer stays as recorded.
|
|
788
799
|
const turn = router.turnActivities.get(e.turnId);
|
|
789
800
|
if (turn) router.turnActivities.set(e.turnId, { ...turn, label: moved.decision.activity });
|
|
790
|
-
await updateView($, router, {
|
|
801
|
+
await updateView($, router, {
|
|
802
|
+
estimate: moved.decision.estimate ?? null,
|
|
803
|
+
comparison: null,
|
|
804
|
+
...switchView(loop.decision, moved.decision, activityLabel(cfg, moved.decision), Date.now()),
|
|
805
|
+
});
|
|
791
806
|
return moved;
|
|
792
807
|
}
|
|
793
808
|
|
|
@@ -820,6 +835,11 @@ async function reviewMidTurn($, router, cfg, loop, e, { context, nativeModel, av
|
|
|
820
835
|
$.ui.toast(switchToast(cfg, previous, selected.decision, selected.decision.estimate));
|
|
821
836
|
const turn = router.turnActivities.get(e.turnId);
|
|
822
837
|
if (turn) router.turnActivities.set(e.turnId, { ...turn, label: selected.decision.activity ?? null });
|
|
838
|
+
await updateView(
|
|
839
|
+
$,
|
|
840
|
+
router,
|
|
841
|
+
switchView(previous, selected.decision, activityLabel(cfg, selected.decision), Date.now()),
|
|
842
|
+
);
|
|
823
843
|
}
|
|
824
844
|
// The pane shows the readings behind the route; a review by a classifier the pane no longer labels keeps them off.
|
|
825
845
|
if (cfg.classifier === router.config.classifier)
|
|
@@ -870,17 +890,10 @@ async function reviewMidTurn($, router, cfg, loop, e, { context, nativeModel, av
|
|
|
870
890
|
return { ...loop, reviewedAt: loop.requests ?? 0 };
|
|
871
891
|
}
|
|
872
892
|
|
|
873
|
-
// A routed reply's metrics in the view,
|
|
874
|
-
// turn's activity record with its list price (`routedUsd`, null when unpriced) and, when its tier served it, its route.
|
|
893
|
+
// A routed reply's metrics in the view, with the tier that served it, and added to the turn's activity record with its list price (`routedUsd`, null when unpriced) and, when its tier served it, its route.
|
|
875
894
|
async function publishReply($, router, turnId, response, tier, route, routedUsd) {
|
|
876
895
|
const turn = router.turnActivities.get(turnId);
|
|
877
|
-
const metrics = responseMetrics(
|
|
878
|
-
router.view,
|
|
879
|
-
response,
|
|
880
|
-
tier,
|
|
881
|
-
tier ? (turn?.label ?? null) : null,
|
|
882
|
-
tier ? route : null,
|
|
883
|
-
);
|
|
896
|
+
const metrics = responseMetrics(router.view, response, tier, Date.now());
|
|
884
897
|
await updateView($, router, metrics);
|
|
885
898
|
if (turn)
|
|
886
899
|
router.turnActivities.set(turnId, {
|
|
@@ -1324,6 +1337,12 @@ function paneActions($, router, view) {
|
|
|
1324
1337
|
() => ({ ...patch, lastWrite: { label, leaves }, notice: `Saved: ${label}. Applies from the next turn.` }),
|
|
1325
1338
|
);
|
|
1326
1339
|
};
|
|
1340
|
+
// The Usage tab's period, kept across sessions; a failed save keeps it for this session.
|
|
1341
|
+
const showPeriod = async (period, patch = {}) => {
|
|
1342
|
+
if (!PERIODS.includes(period)) return;
|
|
1343
|
+
await $.store.set(PERIOD_KEY, period).catch(() => {});
|
|
1344
|
+
await updateView($, router, { usagePeriod: period, usageOpen: null, ...patch });
|
|
1345
|
+
};
|
|
1327
1346
|
return {
|
|
1328
1347
|
mode: (mode) => changeMode($, router, mode),
|
|
1329
1348
|
tab: (tab) => updateView($, router, { tab, notice: null, confirmDelete: false }),
|
|
@@ -1382,12 +1401,9 @@ function paneActions($, router, view) {
|
|
|
1382
1401
|
removeActivity: (activity, tier) => editCell(activity, tier, 'remove'),
|
|
1383
1402
|
selectCell: (cell) => updateView($, router, { routeCell: cell, notice: null }),
|
|
1384
1403
|
usageDetail: () => updateView($, router, { usageDetail: !(router.view ?? view).usageDetail }),
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
await $.store.set(PERIOD_KEY, period).catch(() => {});
|
|
1389
|
-
await updateView($, router, { usagePeriod: period, usageOpen: null });
|
|
1390
|
-
},
|
|
1404
|
+
period: (period) => showPeriod(period),
|
|
1405
|
+
// The Now tab's Usage links: the Usage tab on the period the line sums.
|
|
1406
|
+
usageFor: (period) => showPeriod(period, { tab: 'usage', notice: null, confirmDelete: false }),
|
|
1391
1407
|
usageGroup: (group) => updateView($, router, { usageGroup: group, usageOpen: null }),
|
|
1392
1408
|
usageCompare: () => updateView($, router, { usageCompare: !(router.view ?? view).usageCompare }),
|
|
1393
1409
|
usageOpen: (row) => updateView($, router, { usageOpen: row }),
|
package/lib/display.mjs
CHANGED
|
@@ -38,11 +38,6 @@ export function routeName(config, route) {
|
|
|
38
38
|
return `${modelName(model.id)}${model.efforts.length ? ` · ${route.effort ?? 'session'}` : ''}`;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
// Changes of route between consecutive replies, from the (model, effort) each request went out with, so a move inside
|
|
42
|
-
// a tier counts and a later change of settings does not rewrite the count. A reply routing did not choose breaks no run.
|
|
43
|
-
export const switchCount = (routes) =>
|
|
44
|
-
routes.slice(1).filter((route, i) => route && routes[i] && route !== routes[i]).length;
|
|
45
|
-
|
|
46
41
|
export const percent = (value) => `${Math.round(value * 100)}%`;
|
|
47
42
|
|
|
48
43
|
// Two shares that are compared, such as a classifier's support and the bar it must clear: whole percents, or as many
|