@alexeiled/claude-router 1.9.0 → 1.10.1
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 +22 -0
- package/README.md +3 -3
- package/docs/activity-routing.md +35 -34
- package/docs/architecture.md +5 -7
- package/docs/configuration.md +25 -23
- package/docs/evaluation.md +8 -9
- package/docs/native-router.md +15 -16
- package/docs/router-band.svg +3 -21
- package/docs/router-pane-classifier.svg +82 -63
- package/docs/router-pane-now.svg +95 -109
- package/docs/router-pane-policy.svg +70 -0
- package/docs/router-pane-routes.svg +103 -0
- package/docs/router-pane-usage.svg +100 -127
- package/docs/user-guide.md +63 -49
- package/hooks/native-router.mjs +20 -50
- package/lib/activity-stats.mjs +21 -70
- package/lib/band.mjs +3 -6
- package/lib/config.mjs +11 -8
- package/lib/cost.mjs +3 -3
- package/lib/display.mjs +14 -41
- package/lib/panel.mjs +651 -477
- package/lib/route.mjs +4 -53
- package/lib/subagents.mjs +12 -17
- package/lib/view.mjs +3 -3
- package/package.json +1 -1
- package/types/index.d.ts +10 -36
- package/docs/router-pane-routing.svg +0 -150
package/lib/activity-stats.mjs
CHANGED
|
@@ -34,22 +34,6 @@ const CONFUSION_ROWS = [...ACTIVITY_VALUES, 'none'];
|
|
|
34
34
|
|
|
35
35
|
const count = (n) => (Number.isFinite(n) && n > 0 ? Math.floor(n) : 0);
|
|
36
36
|
|
|
37
|
-
// The shadow readout: turns in shadow, those `on` would have routed differently, and of those the ones with a
|
|
38
|
-
// next-request estimate (`estimated`) and the sum of their [min, max] ranges in USD at configured list prices.
|
|
39
|
-
const emptyShadow = () => ({ differs: 0, turns: 0, estimated: 0, minUsd: 0, maxUsd: 0 });
|
|
40
|
-
const isRange = (r) => Number.isFinite(r?.minUsd) && Number.isFinite(r?.maxUsd);
|
|
41
|
-
|
|
42
|
-
function addShadow(shadow, wouldDiffer, range) {
|
|
43
|
-
const priced = wouldDiffer && isRange(range);
|
|
44
|
-
return {
|
|
45
|
-
differs: shadow.differs + (wouldDiffer ? 1 : 0),
|
|
46
|
-
turns: shadow.turns + 1,
|
|
47
|
-
estimated: shadow.estimated + (priced ? 1 : 0),
|
|
48
|
-
minUsd: shadow.minUsd + (priced ? range.minUsd : 0),
|
|
49
|
-
maxUsd: shadow.maxUsd + (priced ? range.maxUsd : 0),
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
37
|
function addRoutes(before, added) {
|
|
54
38
|
const next = { ...before };
|
|
55
39
|
for (const [route, n] of Object.entries(added ?? {})) if (count(n)) next[route] = (next[route] ?? 0) + count(n);
|
|
@@ -69,15 +53,12 @@ export function emptySession() {
|
|
|
69
53
|
switches: { tier: 0, activity: 0 },
|
|
70
54
|
lateral: { taken: 0, refused: 0 },
|
|
71
55
|
agreement: { matched: 0, total: 0 },
|
|
72
|
-
shadow: emptyShadow(),
|
|
73
56
|
};
|
|
74
57
|
}
|
|
75
58
|
|
|
76
59
|
// One finished turn. `activity` is the turn's label (null: none), `answer` the classifier's accepted activity, which
|
|
77
|
-
// agreement compares with the tools (null: not counted), `lateral` the turn's lateral outcome (turnActivity
|
|
78
|
-
//
|
|
79
|
-
// differently (null: no would-route) and `wouldUsd` prices that difference. `routedUsd` is the list price of the
|
|
80
|
-
// turn's priced replies (null: none had a price), `pricedRequests` how many of its replies had one, and `routes` counts
|
|
60
|
+
// agreement compares with the tools (null: not counted), `lateral` the turn's lateral outcome (turnActivity).
|
|
61
|
+
// `routedUsd` is the list price of the turn's priced replies (null: none had a price), `pricedRequests` how many of its replies had one, and `routes` counts
|
|
81
62
|
// its routed replies by the `model@effort` they went out with.
|
|
82
63
|
export function recordTurn(
|
|
83
64
|
session,
|
|
@@ -94,9 +75,6 @@ export function recordTurn(
|
|
|
94
75
|
tierSwitches,
|
|
95
76
|
activitySwitches,
|
|
96
77
|
lateral,
|
|
97
|
-
wouldDiffer,
|
|
98
|
-
wouldUsd,
|
|
99
|
-
shadow,
|
|
100
78
|
},
|
|
101
79
|
) {
|
|
102
80
|
const key = activity ?? 'none';
|
|
@@ -121,19 +99,13 @@ export function recordTurn(
|
|
|
121
99
|
tier: session.switches.tier + count(tierSwitches),
|
|
122
100
|
activity: session.switches.activity + count(activitySwitches),
|
|
123
101
|
},
|
|
124
|
-
|
|
125
|
-
lateral:
|
|
126
|
-
!shadow && (lateral === 'taken' || lateral === 'refused') ? { ...moves, [lateral]: moves[lateral] + 1 } : moves,
|
|
102
|
+
lateral: lateral === 'taken' || lateral === 'refused' ? { ...moves, [lateral]: moves[lateral] + 1 } : moves,
|
|
127
103
|
agreement: answer
|
|
128
104
|
? {
|
|
129
105
|
matched: session.agreement.matched + (agrees(answer, observed) ? 1 : 0),
|
|
130
106
|
total: session.agreement.total + 1,
|
|
131
107
|
}
|
|
132
108
|
: session.agreement,
|
|
133
|
-
// A view saved by 1.6.0 has no estimate fields.
|
|
134
|
-
shadow: shadow
|
|
135
|
-
? addShadow({ ...emptyShadow(), ...session.shadow }, wouldDiffer === true, wouldUsd)
|
|
136
|
-
: { ...emptyShadow(), ...session.shadow },
|
|
137
109
|
};
|
|
138
110
|
}
|
|
139
111
|
|
|
@@ -146,7 +118,7 @@ const LATENCY_BUCKETS = LATENCY_BOUNDS.length + 1;
|
|
|
146
118
|
const LATENCY_CLASSIFIERS = 8;
|
|
147
119
|
|
|
148
120
|
export function emptyStore() {
|
|
149
|
-
return { version: 1, confusion: {}, runs: {}, lateral: { taken: 0, refused: 0 }
|
|
121
|
+
return { version: 1, confusion: {}, runs: {}, lateral: { taken: 0, refused: 0 } };
|
|
150
122
|
}
|
|
151
123
|
|
|
152
124
|
// The p95 of a latency histogram: the upper bound of its bucket in ms, `over` when it lies above the last bound, and
|
|
@@ -171,21 +143,9 @@ const countsOf = (v, keys) => onlyKeys(v, keys) && Object.values(v).every(isCoun
|
|
|
171
143
|
const exactCountsOf = (v, keys) =>
|
|
172
144
|
isRecord(v) && Object.keys(v).length === keys.length && keys.every((k) => isCount(v[k]));
|
|
173
145
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
//
|
|
177
|
-
const isShadow = (v) =>
|
|
178
|
-
exactCountsOf(v, SHADOW_COUNTS) ||
|
|
179
|
-
(onlyKeys(v, [...SHADOW_COUNTS, ...SHADOW_ESTIMATE]) &&
|
|
180
|
-
Object.keys(v).length === 5 &&
|
|
181
|
-
SHADOW_COUNTS.every((k) => isCount(v[k])) &&
|
|
182
|
-
isCount(v.estimated) &&
|
|
183
|
-
Number.isFinite(v.minUsd) &&
|
|
184
|
-
Number.isFinite(v.maxUsd));
|
|
185
|
-
|
|
186
|
-
// The stored value if it has a known shape, filled to the current one, else an empty store: a hand-edited or
|
|
187
|
-
// unknown file must not break stats. The shape is 1.7.0's, which rejects any other key: a new count goes under its own
|
|
188
|
-
// key, such as METRICS_KEY, so a downgrade keeps these.
|
|
146
|
+
// The stored value if it has a known shape, else an empty store: a hand-edited or unknown file must not break stats.
|
|
147
|
+
// Any other key is rejected: a new count goes under its own key, such as METRICS_KEY. A store saved before 1.10.1 also
|
|
148
|
+
// holds the shadow readout, which reads as dropped; a release before 1.10.1 resets a store saved without it.
|
|
189
149
|
export function readStore(value) {
|
|
190
150
|
const ok =
|
|
191
151
|
onlyKeys(value, ['version', 'confusion', 'runs', 'lateral', 'shadow']) &&
|
|
@@ -196,22 +156,21 @@ export function readStore(value) {
|
|
|
196
156
|
Object.values(value.runs).every(
|
|
197
157
|
(lengths) => Array.isArray(lengths) && lengths.length === RUN_BUCKETS && lengths.every(isCount),
|
|
198
158
|
) &&
|
|
199
|
-
exactCountsOf(value.lateral, ['taken', 'refused'])
|
|
200
|
-
|
|
201
|
-
|
|
159
|
+
exactCountsOf(value.lateral, ['taken', 'refused']);
|
|
160
|
+
if (!ok) return emptyStore();
|
|
161
|
+
const { shadow: _retired, ...store } = value;
|
|
162
|
+
return store;
|
|
202
163
|
}
|
|
203
164
|
|
|
204
|
-
// One finished turn. `predicted` is the classifier's answer (null: none), `runEnded` a run that closed this turn
|
|
205
|
-
// `lateral` the outcome of a lateral switch decision,
|
|
206
|
-
|
|
207
|
-
export function recordStore(store, { predicted, observed, runEnded, lateral, wouldDiffer, wouldUsd }) {
|
|
165
|
+
// One finished turn. `predicted` is the classifier's answer (null: none), `runEnded` a run that closed this turn and
|
|
166
|
+
// `lateral` the outcome of a lateral switch decision. Unknown labels are dropped, so the store keeps a fixed set of keys.
|
|
167
|
+
export function recordStore(store, { predicted, observed, runEnded, lateral }) {
|
|
208
168
|
const row = predicted ?? 'none';
|
|
209
169
|
const next = {
|
|
210
170
|
version: 1,
|
|
211
171
|
confusion: { ...store.confusion },
|
|
212
172
|
runs: { ...store.runs },
|
|
213
173
|
lateral: { ...store.lateral },
|
|
214
|
-
shadow: { ...store.shadow },
|
|
215
174
|
};
|
|
216
175
|
if (CONFUSION_ROWS.includes(row) && OBSERVED.includes(observed))
|
|
217
176
|
next.confusion[row] = { ...next.confusion[row], [observed]: (next.confusion[row]?.[observed] ?? 0) + 1 };
|
|
@@ -221,7 +180,6 @@ export function recordStore(store, { predicted, observed, runEnded, lateral, wou
|
|
|
221
180
|
next.runs[runEnded.activity] = lengths;
|
|
222
181
|
}
|
|
223
182
|
if (lateral === 'taken' || lateral === 'refused') next.lateral[lateral] += 1;
|
|
224
|
-
if (typeof wouldDiffer === 'boolean') next.shadow = addShadow(next.shadow, wouldDiffer, wouldUsd);
|
|
225
183
|
return next;
|
|
226
184
|
}
|
|
227
185
|
|
|
@@ -334,31 +292,25 @@ const lateralOf = (decision) =>
|
|
|
334
292
|
decision?.lateral === 'taken' || decision?.lateral === 'refused' ? decision.lateral : null;
|
|
335
293
|
|
|
336
294
|
// What one routed turn adds to the stats, from its config, the classifier's advice, and the decisions before and
|
|
337
|
-
// after it. `label` is the
|
|
338
|
-
//
|
|
339
|
-
//
|
|
340
|
-
// or a pin. `lateral` reads the decision that carries an activity, the would-route in `shadow`.
|
|
295
|
+
// after it. `label` is the activity applied in `on`; `answer` is the accepted answer, which the tools are checked
|
|
296
|
+
// against and runs follow. `switched` names what moved the route from the previous turn's: 'activity' for a lateral
|
|
297
|
+
// move, 'tier' for any other, null for none or a pin.
|
|
341
298
|
export function turnActivity(config, advice, previous, decision) {
|
|
342
299
|
const mode = config.activityRouting;
|
|
343
|
-
const
|
|
300
|
+
const on = mode === 'on';
|
|
344
301
|
const switched =
|
|
345
302
|
previous?.model && !decision.pinned && differs(previous, decision)
|
|
346
303
|
? lateralOf(decision) === 'taken'
|
|
347
304
|
? 'activity'
|
|
348
305
|
: 'tier'
|
|
349
306
|
: null;
|
|
350
|
-
const answer = mode === 'off' ? null : acceptActivity(config, advice);
|
|
351
|
-
const wouldDiffer = mode === 'shadow' ? Boolean(would && differs(would, decision)) : null;
|
|
352
307
|
return {
|
|
353
308
|
mode,
|
|
354
|
-
answer,
|
|
355
|
-
label:
|
|
309
|
+
answer: on ? acceptActivity(config, advice) : null,
|
|
310
|
+
label: on ? (decision.activity ?? null) : null,
|
|
356
311
|
predicted: advice?.activity?.choice ?? null,
|
|
357
312
|
switched,
|
|
358
|
-
lateral:
|
|
359
|
-
// A shadow turn always counts, so the session and store denominators agree.
|
|
360
|
-
wouldDiffer,
|
|
361
|
-
wouldUsd: wouldDiffer ? (would.difference ?? null) : null,
|
|
313
|
+
lateral: on ? lateralOf(decision) : null,
|
|
362
314
|
};
|
|
363
315
|
}
|
|
364
316
|
|
|
@@ -394,6 +346,5 @@ export function storeSummary(store) {
|
|
|
394
346
|
focus,
|
|
395
347
|
disagreements: misses.sort((a, b) => b.n - a.n).slice(0, 2),
|
|
396
348
|
lateral: store.lateral,
|
|
397
|
-
shadow: store.shadow,
|
|
398
349
|
};
|
|
399
350
|
}
|
package/lib/band.mjs
CHANGED
|
@@ -91,14 +91,11 @@ const pendingMeter = () => [...BARS].map((bar) => part(bar, { color: COLOR.accen
|
|
|
91
91
|
|
|
92
92
|
const route = (view) => routeLabel(view.actualModel ?? view.selectedModel ?? view.nativeModel, view.effort);
|
|
93
93
|
|
|
94
|
-
// The turn's activity between the tier and the route, as a verb in orange italic
|
|
95
|
-
//
|
|
94
|
+
// The turn's activity between the tier and the route, as a verb in orange italic. One part with its arrow, so a
|
|
95
|
+
// narrow band drops both before the reason.
|
|
96
96
|
function activityPart(config, view) {
|
|
97
97
|
if (!view.activity || config.activityRouting === 'off') return null;
|
|
98
|
-
|
|
99
|
-
return config.activityRouting === 'shadow'
|
|
100
|
-
? { ...part(`${verb} (shadow) → `, { dimColor: true }), priority: 2 }
|
|
101
|
-
: { ...part(`${verb} → `, { color: COLOR.activity, italic: true }), priority: 2 };
|
|
98
|
+
return { ...part(`${activityVerb(view.activity)} → `, { color: COLOR.activity, italic: true }), priority: 2 };
|
|
102
99
|
}
|
|
103
100
|
|
|
104
101
|
function served(view) {
|
package/lib/config.mjs
CHANGED
|
@@ -5,12 +5,15 @@ export const EFFORTS = ['low', 'medium', 'high', 'xhigh', 'max'];
|
|
|
5
5
|
// What kind of work a turn does, named by what it produces. Closed: the classifier question is built for this set.
|
|
6
6
|
export const ACTIVITIES = ['code', 'debug', 'explore', 'plan', 'review', 'ops', 'docs'];
|
|
7
7
|
export const ACTIVITY_VALUES = [...ACTIVITIES, 'uncertain'];
|
|
8
|
-
// `off` asks nothing new and routes as 1.5; `
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
// `subagentRouting` takes the same modes: `off` asks and records nothing, `shadow` decides and records but keeps core's
|
|
12
|
-
// model, `on` applies the decision at agent.spawn.
|
|
8
|
+
// `off` asks nothing new and routes as 1.5; `on`, the default since 1.7, applies overrides.
|
|
9
|
+
export const ACTIVITY_MODES = ['off', 'on'];
|
|
10
|
+
// `subagentRouting` takes the same modes: `off` asks and records nothing, `on` applies the decision at agent.spawn.
|
|
13
11
|
export const SUBAGENT_MODES = ACTIVITY_MODES;
|
|
12
|
+
// Both modes took `shadow` until 1.10.1. A file that still sets it is read as not setting the key, and a write from the
|
|
13
|
+
// pane drops it.
|
|
14
|
+
const MODE_KEYS = ['activityRouting', 'subagentRouting'];
|
|
15
|
+
const withoutShadow = (file) =>
|
|
16
|
+
Object.fromEntries(Object.entries(file).filter(([key, value]) => !(value === 'shadow' && MODE_KEYS.includes(key))));
|
|
14
17
|
// A `subagents.types` value that asks the classifier instead of naming a model.
|
|
15
18
|
export const CLASSIFY = 'classify';
|
|
16
19
|
const SONNET_HIGH = { model: 'sonnet', effort: 'high' };
|
|
@@ -61,7 +64,7 @@ export const DEFAULTS = {
|
|
|
61
64
|
// not a multiplier (Opus 5.5 reads at 0.05x input, the rest at the standard 0.1x). `longContext` multiplies every
|
|
62
65
|
// rate of a request whose prompt (input, cache read and cache write) is over `above` tokens: Haiku 5.5 lists its
|
|
63
66
|
// rates for prompts up to 100,000 tokens and 5x above. A price change must also change
|
|
64
|
-
// test/fixtures/list-prices.json, with its source and date. `output` feeds the
|
|
67
|
+
// test/fixtures/list-prices.json, with its source and date. `output` feeds the downgrade tax.
|
|
65
68
|
// `efforts` lists what the model accepts; an empty list means no effort field and no adaptive thinking. A change
|
|
66
69
|
// must also change test/fixtures/effort-support.json, from a new probe against the real API.
|
|
67
70
|
models: {
|
|
@@ -195,7 +198,7 @@ export const MIGRATION_HINT =
|
|
|
195
198
|
|
|
196
199
|
export function loadConfig({ userFile = null } = {}) {
|
|
197
200
|
if (userFile !== null) checkShape(userFile);
|
|
198
|
-
const merged = merge(DEFAULTS, userFile ?? {});
|
|
201
|
+
const merged = merge(DEFAULTS, withoutShadow(userFile ?? {}));
|
|
199
202
|
// A user entry without `api` speaks the System One protocol that every entry spoke before 1.5.
|
|
200
203
|
const config = {
|
|
201
204
|
...merged,
|
|
@@ -325,7 +328,7 @@ export function editActivity(draft, current, activity, tier, kind, value = null)
|
|
|
325
328
|
// route in `file` (the merge would bring the built-in back otherwise), so call this after withRoutes.
|
|
326
329
|
export function withActivities(file, draft) {
|
|
327
330
|
const { base } = draft;
|
|
328
|
-
const { activities: kept = {}, activityRouting: keptMode, ...rest } = file;
|
|
331
|
+
const { activities: kept = {}, activityRouting: keptMode, ...rest } = withoutShadow(file);
|
|
329
332
|
const activities = {};
|
|
330
333
|
for (const activity of ACTIVITIES) {
|
|
331
334
|
for (const tier of TIERS) {
|
package/lib/cost.mjs
CHANGED
|
@@ -90,7 +90,7 @@ export function switchingTaxUsd(config, candidate, incumbent, facts, now) {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
// The next request on `candidate` against `incumbent` as a range: the input bounds crossed, plus the output difference
|
|
93
|
-
// at the last reply's length when both routes have an output price, as
|
|
93
|
+
// at the last reply's length when both routes have an output price, as switchEconomics compares.
|
|
94
94
|
export function nextTurnRange(config, candidate, incumbent, facts, now) {
|
|
95
95
|
const tokens = nextContextTokens(facts);
|
|
96
96
|
const proposed = inputBounds(config, candidate, tokens, facts, now);
|
|
@@ -101,7 +101,7 @@ export function nextTurnRange(config, candidate, incumbent, facts, now) {
|
|
|
101
101
|
return { minUsd: proposed.min - current.max + output, maxUsd: proposed.max - current.min + output };
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
export function
|
|
104
|
+
export function switchEconomics(config, candidate, incumbent, facts, now) {
|
|
105
105
|
const tokens = nextContextTokens(facts);
|
|
106
106
|
const proposed = ratesAt(routeSpec(config, candidate), tokens);
|
|
107
107
|
const current = ratesAt(routeSpec(config, incumbent), tokens);
|
|
@@ -120,7 +120,7 @@ export function shadowEconomics(config, candidate, incumbent, facts, now) {
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
export function downgradeTaxUsd(config, candidate, incumbent, facts, now, turns) {
|
|
123
|
-
const estimate =
|
|
123
|
+
const estimate = switchEconomics(config, candidate, incumbent, facts, now);
|
|
124
124
|
if (!estimate) return Math.max(0, switchingTaxUsd(config, candidate, incumbent, facts, now));
|
|
125
125
|
return Math.max(0, estimate.nextTurnUsd + (turns - 1) * estimate.laterTurnUsd);
|
|
126
126
|
}
|
package/lib/display.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from './config.mjs';
|
|
11
11
|
import { ratesAt } from './cost.mjs';
|
|
12
12
|
import { PROBE_RESULTS } from './probe-results.mjs';
|
|
13
|
-
import { cellForModel
|
|
13
|
+
import { cellForModel } from './route.mjs';
|
|
14
14
|
import { emptyTotals, readout, readSavingsStore } from './savings.mjs';
|
|
15
15
|
|
|
16
16
|
// Cost order, cheapest first, so the colors read as a scale. Hex values: every surface draws them.
|
|
@@ -37,9 +37,6 @@ export function routeName(config, route) {
|
|
|
37
37
|
return `${modelName(model.id)}${model.efforts.length ? ` · ${route.effort ?? 'session'}` : ''}`;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
// One letter per activity for the REPLIES strip: `docs` is `w` (writing), since `debug` has `d`.
|
|
41
|
-
export const ACTIVITY_LETTER = { code: 'c', debug: 'd', explore: 'e', plan: 'p', review: 'r', ops: 'o', docs: 'w' };
|
|
42
|
-
|
|
43
40
|
// Changes of route between consecutive replies, from the (model, effort) each request went out with, so a move inside
|
|
44
41
|
// a tier counts and a later change of settings does not rewrite the count. A reply routing did not choose breaks no run.
|
|
45
42
|
export const switchCount = (routes) =>
|
|
@@ -96,24 +93,6 @@ export function missingText(config, id, missing) {
|
|
|
96
93
|
return `no ${CLASSIFIER_OPTIONS[option] ?? 'setting'}`;
|
|
97
94
|
}
|
|
98
95
|
|
|
99
|
-
// Every setting the configured classifiers read, grouped by classifier: "Jev: API key · Clef, Clef Flash: API token,
|
|
100
|
-
// account ID · Ollama: no key needed".
|
|
101
|
-
export function credentialsNeeded(config) {
|
|
102
|
-
// Grouped by option name, not by its words: Jev's "API key" and OpenAI's "API key" are different settings.
|
|
103
|
-
const groups = new Map();
|
|
104
|
-
for (const entry of Object.values(config.classifiers)) {
|
|
105
|
-
const options = [entry.keyOption, ...endpointSettings(entry.endpoint)].filter((option) => option !== null);
|
|
106
|
-
const key = options.join(', ');
|
|
107
|
-
const group = groups.get(key) ?? {
|
|
108
|
-
needs: options.map((option) => CLASSIFIER_OPTIONS[option]).join(', ') || 'no key needed',
|
|
109
|
-
labels: [],
|
|
110
|
-
};
|
|
111
|
-
group.labels.push(entry.label);
|
|
112
|
-
groups.set(key, group);
|
|
113
|
-
}
|
|
114
|
-
return [...groups.values()].map(({ needs, labels }) => `${labels.join(', ')}: ${needs}`).join(' · ');
|
|
115
|
-
}
|
|
116
|
-
|
|
117
96
|
// The active classifier with what went wrong: "Jev: no API key", "Clef timed out". Short: the band keeps it whole.
|
|
118
97
|
export function classifierStatus(config, error) {
|
|
119
98
|
const label = activeClassifier(config).label;
|
|
@@ -207,21 +186,9 @@ export function activityReading(view) {
|
|
|
207
186
|
return { choice, share: Number.isFinite(share) ? percent(share) : null, others };
|
|
208
187
|
}
|
|
209
188
|
|
|
210
|
-
// The route the turn's cell resolves to, against the tier's base route
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
const mode = config.activityRouting;
|
|
214
|
-
if (mode === 'shadow') {
|
|
215
|
-
const would = view.wouldRoute;
|
|
216
|
-
if (!would?.tier) return null;
|
|
217
|
-
const current = view.selectedModel ?? view.nativeModel;
|
|
218
|
-
const same = isSameModel(would.model, current) && (would.effort ?? null) === (view.effort ?? null);
|
|
219
|
-
return (
|
|
220
|
-
`${would.tier}${would.activity ? ` + ${would.activity}` : ''} would use ${routeLabel(would.model, would.effort)}` +
|
|
221
|
-
` (shadow; ${same ? 'same route' : `using ${routeLabel(current, view.effort)}`})`
|
|
222
|
-
);
|
|
223
|
-
}
|
|
224
|
-
if (mode !== 'on' || !view.tier) return null;
|
|
189
|
+
// The route the turn's cell resolves to, against the tier's base route. Null outside `on`, or before a turn has a tier.
|
|
190
|
+
function activityRouteText(config, view) {
|
|
191
|
+
if (config.activityRouting !== 'on' || !view.tier) return null;
|
|
225
192
|
const cell = `${view.tier}${view.activity ? ` + ${view.activity}` : ''}`;
|
|
226
193
|
const route = resolveRoute(config, view.tier, view.activity ?? null);
|
|
227
194
|
const base = resolveRoute(config, view.tier);
|
|
@@ -233,7 +200,7 @@ export function activityRouteText(config, view) {
|
|
|
233
200
|
// Reasons that only say the route stayed: on an override cell they leave out why it is not the tier's base route.
|
|
234
201
|
const STAYED = ['ready', 'same-tier', 'no-advice', 'continuation', 'uncertain'];
|
|
235
202
|
|
|
236
|
-
// The Now tab's Why. In `on`, an activity move, or a stay on an override cell, says the cell plainly: "
|
|
203
|
+
// The Now tab's Why. In `on`, an activity move, or a stay on an override cell, says the cell plainly: "coding at low
|
|
237
204
|
// runs on Sonnet 5.5 · high", or for a move to no activity "low runs on its base route, Haiku 5.5 · high".
|
|
238
205
|
// Every other decision keeps its reason: a refusal, a hold or a tier move says more than the cell.
|
|
239
206
|
export function whyText(config, view) {
|
|
@@ -245,7 +212,7 @@ export function whyText(config, view) {
|
|
|
245
212
|
const moved = view.reason === 'activity-up' || view.reason === 'activity-down';
|
|
246
213
|
if (!moved && !(override && STAYED.includes(view.reason ?? 'ready'))) return reason;
|
|
247
214
|
return activity
|
|
248
|
-
? `${activity} at ${view.tier} runs on ${routeName(config, route)}`
|
|
215
|
+
? `${activityVerb(activity)} at ${view.tier} runs on ${routeName(config, route)}`
|
|
249
216
|
: `${view.tier} runs on its base route, ${routeName(config, route)}`;
|
|
250
217
|
}
|
|
251
218
|
|
|
@@ -270,11 +237,17 @@ export function storeAgreementLine(view) {
|
|
|
270
237
|
return `Agreement across sessions: ${all}${code}`;
|
|
271
238
|
}
|
|
272
239
|
|
|
240
|
+
// The classifier's last checked-in activity probe, or null when none was run on the model it is configured with.
|
|
241
|
+
export const probeOf = (config, id) => {
|
|
242
|
+
const probe = PROBE_RESULTS[id];
|
|
243
|
+
return probe && probe.model === config.classifiers[id]?.model ? probe : null;
|
|
244
|
+
};
|
|
245
|
+
|
|
273
246
|
// The classifier's last checked-in activity probe, "activity probe 70/70 · p95 299 ms · Oct 10", or null when none
|
|
274
247
|
// was run on the model it is configured with.
|
|
275
248
|
export function probeText(config, id) {
|
|
276
|
-
const probe =
|
|
277
|
-
if (!probe
|
|
249
|
+
const probe = probeOf(config, id);
|
|
250
|
+
if (!probe) return null;
|
|
278
251
|
const day = new Date(`${probe.date}T00:00:00Z`).toLocaleDateString('en-US', {
|
|
279
252
|
month: 'short',
|
|
280
253
|
day: 'numeric',
|