@alexeiled/claude-router 1.24.0 → 1.25.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.
Files changed (78) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +44 -0
  3. package/README.md +39 -7
  4. package/docs/architecture.md +27 -4
  5. package/docs/configuration.md +23 -14
  6. package/docs/evaluation.md +3 -3
  7. package/docs/native-router.md +11 -3
  8. package/docs/router-band.svg +124 -133
  9. package/docs/router-pane-classifier.svg +24 -23
  10. package/docs/router-pane-now.svg +9 -7
  11. package/docs/router-pane-policy.svg +4 -4
  12. package/docs/router-pane-routes.svg +8 -8
  13. package/docs/router-pane-usage-whatif.svg +14 -14
  14. package/docs/router-pane-usage.svg +20 -20
  15. package/docs/routing-modes.md +10 -8
  16. package/docs/user-guide.md +70 -17
  17. package/hooks/native-router.mjs +333 -80
  18. package/lib/activity-stats.mjs +23 -4
  19. package/lib/activity.mjs +7 -5
  20. package/lib/auto-engine.mjs +13 -6
  21. package/lib/auto-route.mjs +10 -4
  22. package/lib/band.mjs +35 -440
  23. package/lib/classifier-client.mjs +12 -8
  24. package/lib/config-file.mjs +7 -2
  25. package/lib/config.mjs +24 -9
  26. package/lib/cost.mjs +5 -1
  27. package/lib/costs.mjs +4 -2
  28. package/lib/decisions.mjs +13 -9
  29. package/lib/display.mjs +69 -20
  30. package/lib/facts.mjs +3 -0
  31. package/lib/modes.mjs +8 -4
  32. package/lib/panel.mjs +75 -2167
  33. package/lib/policy.mjs +7 -6
  34. package/lib/replay-trace.mjs +5 -2
  35. package/lib/replay.mjs +7 -1
  36. package/lib/route-line.mjs +46 -0
  37. package/lib/route.mjs +21 -16
  38. package/lib/savings.mjs +14 -3
  39. package/lib/subagents.mjs +41 -11
  40. package/lib/subcommands.mjs +60 -0
  41. package/lib/ui/fallback.mjs +22 -0
  42. package/lib/ui/graphical/band.mjs +256 -0
  43. package/lib/ui/graphical/charts.mjs +163 -0
  44. package/lib/ui/graphical/classifier.mjs +153 -0
  45. package/lib/ui/graphical/frame.mjs +227 -0
  46. package/lib/ui/graphical/kit.mjs +156 -0
  47. package/lib/ui/graphical/meter.mjs +25 -0
  48. package/lib/ui/graphical/now.mjs +353 -0
  49. package/lib/ui/graphical/policy.mjs +56 -0
  50. package/lib/ui/graphical/routes.mjs +264 -0
  51. package/lib/ui/graphical/squares.mjs +29 -0
  52. package/lib/ui/graphical/usage.mjs +376 -0
  53. package/lib/ui/model/band.mjs +439 -0
  54. package/lib/ui/model/classifier.mjs +308 -0
  55. package/lib/ui/model/draft.mjs +62 -0
  56. package/lib/ui/model/format.mjs +41 -0
  57. package/lib/ui/model/frame.mjs +359 -0
  58. package/lib/ui/model/now.mjs +390 -0
  59. package/lib/ui/model/policy.mjs +194 -0
  60. package/lib/ui/model/routes.mjs +392 -0
  61. package/lib/ui/model/usage-agents.mjs +311 -0
  62. package/lib/ui/model/usage-breakdown.mjs +237 -0
  63. package/lib/ui/model/usage-shared.mjs +58 -0
  64. package/lib/ui/model/usage.mjs +330 -0
  65. package/lib/ui/terminal/band.mjs +220 -0
  66. package/lib/ui/terminal/classifier.mjs +142 -0
  67. package/lib/ui/terminal/frame.mjs +169 -0
  68. package/lib/ui/terminal/kit.mjs +133 -0
  69. package/lib/ui/terminal/now.mjs +300 -0
  70. package/lib/ui/terminal/policy.mjs +52 -0
  71. package/lib/ui/terminal/routes.mjs +167 -0
  72. package/lib/ui/terminal/usage.mjs +363 -0
  73. package/lib/ui/terminal/wrap.mjs +37 -0
  74. package/lib/ui/tokens.mjs +106 -0
  75. package/lib/usage.mjs +5 -5
  76. package/lib/view.mjs +5 -2
  77. package/package.json +3 -2
  78. package/types/index.d.ts +15 -0
@@ -0,0 +1,392 @@
1
+ // The Routes tab's model: the grid of tier by activity with every cell's route, marks and handlers, the selected
2
+ // cell's editor, and the cache footer. Nothing is written until Save; the cache count reads the whole draft.
3
+
4
+ import { compareRoutes } from '../../activity.mjs';
5
+ import { ACTIVITIES, ACTIVITY_MODES, defaultsFor, resolveRoute, sameRoute, TIERS } from '../../config.mjs';
6
+ import { effortSharesCache } from '../../cost.mjs';
7
+ import { cardRoute, modelName, routeName } from '../../display.mjs';
8
+ import { routingChanges } from './draft.mjs';
9
+ import { plural, sentence, tierLabel } from './format.mjs';
10
+
11
+ const LADDER = [...TIERS].reverse();
12
+ // The effort option that sends no effort of its own: the request keeps the one Claude Code sends.
13
+ const SESSION_EFFORT = 'session';
14
+ const INHERIT = 'inherit';
15
+ // The Routes grid's marks, as its legend explains them, each in its tone.
16
+ // `card` is the glyph a card draws where the terminal's is too slight in a Button.
17
+ /** @type {{ inherits: RouteMark, preset: RouteMark, edited: RouteMark }} */
18
+ export const ROUTE_MARKS = {
19
+ inherits: { glyph: '·', card: '—', tone: 'muted', text: 'runs the tier’s model' },
20
+ preset: { glyph: '°', tone: 'muted', text: 'built-in default' },
21
+ edited: { glyph: '●', tone: 'warning', text: 'unsaved' },
22
+ };
23
+ const UNPRICED_OUTPUT = '$? out';
24
+
25
+ // The Routes grid's row of the tiers' own routes; every other row is an activity.
26
+ const TIER_ROW = 'tier';
27
+
28
+ const ACTIVITY_MODE_HINT = {
29
+ off: 'not asked; every turn runs its tier’s model',
30
+ on: 'an activity can change its tier’s model',
31
+ };
32
+ const windowSize = (tokens) => (tokens >= 1e6 ? `${tokens / 1e6}M` : `${Math.round(tokens / 1e3)}K`);
33
+
34
+ // A route as the grid names it: the models key, not the model name (two Haiku versions in router.json still read
35
+ // apart), and its effort, `inherit` for a route that leaves the effort to the session; no effort for a model without
36
+ // efforts.
37
+ const gridRoute = (config, route) => ({
38
+ model: route.model,
39
+ effort: config.models[route.model].efforts.length ? (route.effort ?? INHERIT) : null,
40
+ });
41
+ const routeKey = (route) => `${route.model}@${route.effort ?? ''}`;
42
+ const builtIn = (config, activity, tier) => defaultsFor(config.provider).activities[activity]?.[tier] ?? null;
43
+ const sharesEffort = (config, route) => effortSharesCache(config, config.models[route.model]?.id);
44
+ // The cache a route runs on: one per model on a model that keeps one cache across efforts, else one per route.
45
+ const cacheOf = (config, route) => (sharesEffort(config, route) ? route.model : routeKey(route));
46
+
47
+ // Why an override may be a mistake: no effect, a route above the next tier's, or a cache no other cell runs on.
48
+ function overrideWarnings(config, uses, activity, tier) {
49
+ const route = resolveRoute(config, tier, activity);
50
+ if (sameRoute(route, config.routes[tier])) return [];
51
+ const aboveTier = TIERS[TIERS.indexOf(tier) + 1];
52
+ const above = aboveTier === undefined ? undefined : config.routes[aboveTier];
53
+ return [
54
+ above && (compareRoutes(config, route, above) ?? 0) > 0 ? 'stronger than the tier above' : null,
55
+ uses.get(cacheOf(config, route)) === 1
56
+ ? config.cache.mode === 'automatic'
57
+ ? 'a route only this cell uses; cache sharing is unknown'
58
+ : `${sharesEffort(config, route) ? 'a model' : 'a model + effort'} only this cell uses: one more cache`
59
+ : null,
60
+ ].filter((warning) => warning !== null);
61
+ }
62
+
63
+ // The model and effort choices of one route; `session` is offered as `inherit`. `effort` is null for a model without
64
+ // efforts. `name` and `text` are what a surface without Select shows.
65
+ function routeChoices(config, key, route, modelOptions, onModel, onEffort) {
66
+ const model = config.models[route.model];
67
+ const aliases = modelOptions.includes(route.model) ? modelOptions : [route.model, ...modelOptions];
68
+ return {
69
+ key,
70
+ model: {
71
+ value: route.model,
72
+ name: modelName(model.id),
73
+ options: aliases.map((alias) => ({ value: alias, label: modelName(config.models[alias].id) })),
74
+ pick: onModel,
75
+ },
76
+ effort: model.efforts.length
77
+ ? {
78
+ value: route.effort ?? SESSION_EFFORT,
79
+ text: route.effort ?? INHERIT,
80
+ options: [
81
+ { value: SESSION_EFFORT, label: INHERIT },
82
+ ...model.efforts.map((effort) => ({ value: effort, label: effort })),
83
+ ],
84
+ pick: (effort) => onEffort(effort === SESSION_EFFORT ? null : effort),
85
+ }
86
+ : null,
87
+ };
88
+ }
89
+
90
+ // Routes per cache: the tiers' routes, and the overrides when `overrides` is set. The count shows the overrides once
91
+ // activity routing is on; the one-more-cache warning always counts them, so it reads the same in every mode. `shared`
92
+ // says, per counted route, whether its model keeps one cache across efforts.
93
+ function cacheUses(draft, overrides) {
94
+ const uses = new Map();
95
+ const shared = [];
96
+ const count = (route) => {
97
+ shared.push(sharesEffort(draft, route));
98
+ uses.set(cacheOf(draft, route), (uses.get(cacheOf(draft, route)) ?? 0) + 1);
99
+ };
100
+ for (const tier of TIERS) count(draft.routes[tier]);
101
+ if (overrides)
102
+ for (const activity of ACTIVITIES)
103
+ for (const tier of TIERS) {
104
+ const route = resolveRoute(draft, tier, activity);
105
+ if (!sameRoute(route, draft.routes[tier])) count(route);
106
+ }
107
+ return { uses, shared };
108
+ }
109
+
110
+ /**
111
+ * @typedef {object} RouteMark a mark in the grid and its legend
112
+ * @property {string} glyph
113
+ * @property {string} [card] the glyph a card draws where the terminal's is too slight in a Button
114
+ * @property {import('../tokens.mjs').Tone} tone
115
+ * @property {string} text
116
+ *
117
+ * @typedef {object} Choice a model or effort Select: its value, options and what a surface without Select shows
118
+ * @property {string | null} value
119
+ * @property {{ value: string | null, label: string }[]} options
120
+ * @property {(value: string) => void} pick
121
+ *
122
+ * @typedef {object} GridCell
123
+ * @property {string} tier
124
+ * @property {string} key
125
+ * @property {{ model: string, effort: string | null } | null} route as the terminal's grid names it; null where it runs the tier's
126
+ * @property {string} label a card's label
127
+ * @property {boolean} inherits
128
+ * @property {RouteMark[]} marks
129
+ * @property {boolean} muted runs nothing now
130
+ * @property {boolean} selected
131
+ * @property {() => void} press
132
+ *
133
+ * @typedef {object} GridRow
134
+ * @property {string} id
135
+ * @property {string} kind 'tier' or 'activity'
136
+ * @property {import('./format.mjs').Words} label
137
+ * @property {GridCell[]} cells
138
+ *
139
+ * @typedef {object} TierEditor a tier's own route with its prices
140
+ * @property {'tier'} kind
141
+ * @property {string} tier
142
+ * @property {string} title a card's title
143
+ * @property {{ key: string, model: Choice & { name: string }, effort: (Choice & { text: string }) | null }} choices
144
+ * @property {boolean} changed
145
+ * @property {{ terminal: string, graphical: string }} rates
146
+ *
147
+ * @typedef {object} ActivityEditor an activity's cell with what it runs and the ways back
148
+ * @property {'activity'} kind
149
+ * @property {string} tier
150
+ * @property {string} activity
151
+ * @property {string} title a card's title
152
+ * @property {{ key: string, model: Choice & { name: string }, effort: (Choice & { text: string }) | null }} choices
153
+ * @property {boolean} changed
154
+ * @property {import('./format.mjs').Words} state
155
+ * @property {{ key: string, label: { terminal: string, graphical: string }, note: string, press: () => void } | null} remove
156
+ * @property {{ key: string, label: string, press: () => void } | null} restore
157
+ * @property {import('./format.mjs').Words[]} warnings
158
+ *
159
+ * @typedef {TierEditor | ActivityEditor} RouteEditor the selected cell's editor
160
+ *
161
+ * @typedef {object} RoutesModel The Routes tab: the grid, the cell editor and the cache footer.
162
+ * @property {{ id: string, label: import('./format.mjs').Words }[]} tiers
163
+ * @property {{ label: string, value: string, options: { value: string, label: import('./format.mjs').Words }[], changed: boolean, hint: import('./format.mjs').Words, pick: (mode: string) => void }} mode
164
+ * @property {{ warning: boolean, text: string, after: string | null } | null} overrides
165
+ * @property {GridRow[]} rows
166
+ * @property {RouteEditor | null} editor
167
+ * @property {string | null} hint what a cell press does, until one is pressed
168
+ * @property {RouteMark} inheritMark
169
+ * @property {RouteMark[]} legend
170
+ * @property {RouteMark} unsaved
171
+ * @property {{ text: import('./format.mjs').Words, wrap: boolean }} cache
172
+ * @property {import('./format.mjs').Words[]} steps
173
+ * @property {{ label: string, press: () => void }} reset
174
+ * @property {string} note
175
+ */
176
+ /**
177
+ * @param {import('./frame.mjs').PaneContext} ctx
178
+ * @returns {RoutesModel}
179
+ */
180
+ export function routesOf({ config, view, actions, modelOptions }) {
181
+ const changes = routingChanges(config, view);
182
+ const draft = { ...config, ...changes.draft };
183
+ const mode = draft.activityRouting;
184
+ const { uses, shared } = cacheUses(draft, mode === 'on');
185
+ const selected = view.routeCell ?? null;
186
+ // One grid cell: its route as the terminal grid writes it, null where it runs the tier's; a card's label, the display
187
+ // name the model Select shows and the full effort word the effort Select shows; then its marks.
188
+ const cell = (row, tier, route, { inherits = false, preset = false, edited = false, muted = false }) => ({
189
+ tier,
190
+ key: `cell-${row}-${tier}`,
191
+ route: inherits ? null : gridRoute(draft, route),
192
+ label: inherits ? ROUTE_MARKS.inherits.card : cardRoute(draft, route),
193
+ inherits,
194
+ marks: [preset ? ROUTE_MARKS.preset : null, edited ? ROUTE_MARKS.edited : null].filter((mark) => mark !== null),
195
+ // Runs nothing now: the tier's model, or an override while activity routing is not on.
196
+ muted,
197
+ selected: selected === `${row}.${tier}`,
198
+ press: () => actions.selectCell(`${row}.${tier}`),
199
+ });
200
+ const rows = [
201
+ // The tiers' own routes: "every turn" in the terminal grid, "Default" on a card.
202
+ {
203
+ id: TIER_ROW,
204
+ kind: TIER_ROW,
205
+ label: { terminal: 'every turn', graphical: 'Default' },
206
+ cells: TIERS.map((tier) => cell(TIER_ROW, tier, draft.routes[tier], { edited: changes.tiers.includes(tier) })),
207
+ },
208
+ ...ACTIVITIES.map((activity) => ({
209
+ id: activity,
210
+ kind: 'activity',
211
+ label: activity,
212
+ cells: TIERS.map((tier) => {
213
+ const route = resolveRoute(draft, tier, activity);
214
+ const edited = changes.cells.some(([a, t]) => a === activity && t === tier);
215
+ if (sameRoute(route, draft.routes[tier]))
216
+ return cell(activity, tier, route, { inherits: true, edited, muted: true });
217
+ const preset = builtIn(draft, activity, tier);
218
+ return cell(activity, tier, route, {
219
+ preset: Boolean(preset) && sameRoute(route, { model: preset.model, effort: preset.effort ?? null }),
220
+ edited,
221
+ muted: mode !== 'on',
222
+ });
223
+ }),
224
+ })),
225
+ ];
226
+ const editor = editorOf(draft, changes, selected, cacheUses(draft, true).uses, actions, modelOptions);
227
+ const cacheWords =
228
+ config.cache.mode === 'automatic'
229
+ ? 'Automatic prefix cache: hits are observed; lifetime and sharing across efforts are unknown. No cache-write premium.'
230
+ : config.cache.mode === 'disabled'
231
+ ? 'Prompt caching disabled: input is priced at the uncached rate.'
232
+ : cacheSentence(uses.size, shared, mode);
233
+ // Two adjacent tiers on one route: that step changes nothing.
234
+ const same = LADDER.slice(0, -1).flatMap((upper, i) => {
235
+ const lower = LADDER[i + 1];
236
+ return lower !== undefined && sameRoute(draft.routes[upper], draft.routes[lower]) ? [[lower, upper]] : [];
237
+ });
238
+ const stepText = (lower, upper) => `${lower} and ${upper} run the same model and effort: that step changes nothing`;
239
+ const modeHint = ACTIVITY_MODE_HINT[mode];
240
+ return {
241
+ tiers: TIERS.map((id) => ({ id, label: { terminal: id, graphical: tierLabel(id) } })),
242
+ mode: {
243
+ label: 'Activity routing',
244
+ value: mode,
245
+ options: ACTIVITY_MODES.map((m) => ({ value: m, label: { terminal: m, graphical: sentence(m) } })),
246
+ changed: changes.mode,
247
+ hint: { terminal: modeHint, graphical: sentence(modeHint) },
248
+ pick: (m) => actions.activityMode(m),
249
+ },
250
+ overrides: overridesOf(view, config.activityRouting, mode),
251
+ rows,
252
+ editor,
253
+ // What a cell press does, until one is pressed.
254
+ hint: editor ? null : 'Select a cell to change its model and effort.',
255
+ inheritMark: ROUTE_MARKS.inherits,
256
+ legend: [ROUTE_MARKS.inherits, ROUTE_MARKS.preset, ROUTE_MARKS.edited],
257
+ unsaved: ROUTE_MARKS.edited,
258
+ // `wrap`: the terminal wraps the sentence that counts caches, not the fixed ones.
259
+ cache: {
260
+ text: { terminal: cacheWords, graphical: sentence(cacheWords) },
261
+ wrap: config.cache.mode !== 'automatic' && config.cache.mode !== 'disabled',
262
+ },
263
+ steps: same.map(([lower, upper]) => ({
264
+ terminal: stepText(lower, upper),
265
+ graphical: stepText(tierLabel(lower), tierLabel(upper)),
266
+ })),
267
+ reset: { label: 'Reset routes to defaults', press: actions.resetRoutes },
268
+ note: 'A new model ID needs the active file → models: price, window, efforts.',
269
+ };
270
+ }
271
+
272
+ // Why the cache count matters: a model keeps one cache across efforts (the 5.5 models on an API key or a subscription)
273
+ // or one per effort (other providers).
274
+ function cacheSentence(n, shared, mode) {
275
+ const scope = mode === 'on' ? '' : ' (tiers only: activity routing is not on)';
276
+ const per = shared.every(Boolean)
277
+ ? 'one per model; effort changes keep it'
278
+ : shared.some(Boolean)
279
+ ? 'one per model, or per model + effort where efforts cache apart'
280
+ : 'one per model + effort';
281
+ return `${plural(n, 'prompt cache')} in use${scope}: ${per}. A switch to a cold cache writes the whole context again, the switch cost on Now.`;
282
+ }
283
+
284
+ // The editor of the selected grid cell: a tier's own route with its prices, or an activity's cell with what it runs,
285
+ // its built-in default, and the two ways back. Null with no cell, or one that names no tier and row.
286
+ /** @returns {RouteEditor | null} */
287
+ function editorOf(draft, changes, selected, uses, actions, modelOptions) {
288
+ const [row, tier] = selected?.split('.') ?? [];
289
+ if (!TIERS.includes(tier) || (row !== TIER_ROW && !ACTIVITIES.includes(row))) return null;
290
+ if (row === TIER_ROW) {
291
+ const route = draft.routes[tier];
292
+ const model = draft.models[route.model];
293
+ const output = model.output ?? null;
294
+ const span = `${windowSize(model.contextWindow)} window`;
295
+ return {
296
+ kind: TIER_ROW,
297
+ tier,
298
+ title: `Edit Default at ${tierLabel(tier)}`,
299
+ choices: routeChoices(
300
+ draft,
301
+ `route-${tier}`,
302
+ route,
303
+ modelOptions,
304
+ (alias) => actions.routeModel(tier, alias),
305
+ (effort) => actions.routeEffort(tier, effort),
306
+ ),
307
+ changed: changes.tiers.includes(tier),
308
+ // Per million tokens. Without an output price in router.json the terminal has always written `$? out`;
309
+ // a card leaves the output price out.
310
+ rates: {
311
+ terminal: `$${model.input} in · ${output === null ? UNPRICED_OUTPUT : `$${output} out`} per M tokens · ${span}`,
312
+ graphical: `$${model.input} in${output === null ? '' : ` · $${output} out`} per M tokens · ${span}`,
313
+ },
314
+ };
315
+ }
316
+ const activity = row;
317
+ const route = resolveRoute(draft, tier, activity);
318
+ const base = draft.routes[tier];
319
+ const preset = builtIn(draft, activity, tier);
320
+ const presetRoute = preset ? { model: preset.model, effort: preset.effort ?? null } : null;
321
+ const own = !sameRoute(route, base);
322
+ // A saved cell that resolves to the tier's route and is no built-in one changes nothing; 1.6 wrote such cells.
323
+ const noEffect = !own && !presetRoute && Boolean(draft.activities[activity]?.[tier]);
324
+ const drop = own || noEffect;
325
+ const back = Boolean(presetRoute) && !sameRoute(route, presetRoute);
326
+ const state = !own
327
+ ? presetRoute && !sameRoute(route, presetRoute)
328
+ ? 'runs the tier’s model; the built-in default is removed'
329
+ : noEffect
330
+ ? 'same as the tier’s model: no effect'
331
+ : 'runs the tier’s model'
332
+ : presetRoute && sameRoute(route, presetRoute)
333
+ ? 'built-in default'
334
+ : 'your override';
335
+ const note = `tier model: ${routeName(draft, base)}`;
336
+ const warnings = overrideWarnings(draft, uses, activity, tier);
337
+ return {
338
+ kind: 'activity',
339
+ activity,
340
+ tier,
341
+ title: `Edit ${activity} at ${tierLabel(tier)}`,
342
+ choices: routeChoices(
343
+ draft,
344
+ `activity-${activity}-${tier}`,
345
+ route,
346
+ modelOptions,
347
+ (alias) => actions.activityModel(activity, tier, alias),
348
+ (effort) => actions.activityEffort(activity, tier, effort),
349
+ ),
350
+ changed: changes.cells.some(([a, t]) => a === activity && t === tier),
351
+ state: { terminal: state, graphical: sentence(state) },
352
+ // Back to the tier's route, and back to the built-in default, where each would change the cell.
353
+ remove: drop
354
+ ? {
355
+ key: `activity-tier-${activity}-${tier}`,
356
+ // The terminal names the way back; a card names what it removes and says what runs after.
357
+ label: { terminal: `Use tier model: ${routeName(draft, base)}`, graphical: 'Remove override' },
358
+ note: sentence(note),
359
+ press: () => actions.removeActivity(activity, tier),
360
+ }
361
+ : null,
362
+ restore: back
363
+ ? {
364
+ key: `activity-default-${activity}-${tier}`,
365
+ label: `Restore default: ${routeName(draft, presetRoute)}`,
366
+ press: () => actions.restoreActivity(activity, tier),
367
+ }
368
+ : null,
369
+ warnings: warnings.map((warning) => ({ terminal: warning, graphical: sentence(warning) })),
370
+ };
371
+ }
372
+
373
+ // Whether the overrides run now: the saved mode decides, since a draft runs nothing until Save. A different draft mode
374
+ // says what Save will change. Null while they run and Save changes nothing.
375
+ function overridesOf(view, saved, drafted) {
376
+ const why = (mode) =>
377
+ view.phase === 'unavailable'
378
+ ? 'routing is unavailable'
379
+ : view.mode === 'manual'
380
+ ? 'routing is off'
381
+ : mode === 'on'
382
+ ? null
383
+ : `activity routing is ${mode}`;
384
+ const now = why(saved);
385
+ const after = drafted === saved || Boolean(why(drafted)) === Boolean(now) ? null : why(drafted) ? 'not' : 'in';
386
+ if (!now && !after) return null;
387
+ return {
388
+ warning: Boolean(now),
389
+ text: now ? `Activity overrides not in use: ${now}` : 'Activity overrides in use',
390
+ after: after ? `${after === 'not' ? 'not in use' : 'in use'} after Save` : null,
391
+ };
392
+ }