@alexeiled/claude-router 1.3.1 → 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/lib/view.mjs ADDED
@@ -0,0 +1,71 @@
1
+ // The view the band and pane draw from: its initial shape and the patches built from pure inputs. Pure: the hook
2
+ // writes the view to $.state.
3
+
4
+ // Replies kept for the pane's trend and tier strip.
5
+ const HISTORY = 30;
6
+
7
+ export function initialView(model) {
8
+ return {
9
+ phase: 'ready',
10
+ activeTurnId: null,
11
+ mode: 'auto',
12
+ nativeModel: model,
13
+ selectedModel: null,
14
+ actualModel: null,
15
+ tier: null,
16
+ effort: null,
17
+ reason: 'ready',
18
+ error: null,
19
+ pendingPin: null,
20
+ credentials: null,
21
+ contextTokens: null,
22
+ contextKnown: false,
23
+ cacheRead: null,
24
+ cacheWrite: null,
25
+ health: { failures: 0, pausedUntil: 0 },
26
+ inputTokens: null,
27
+ outputTokens: null,
28
+ adviceMs: null,
29
+ adviceChoice: null,
30
+ estimate: null,
31
+ comparison: null,
32
+ probabilities: null,
33
+ history: [],
34
+ tiers: [],
35
+ configPath: null,
36
+ tuning: null,
37
+ tuningBase: null,
38
+ routeDraft: null,
39
+ lastWrite: null,
40
+ tab: 'now',
41
+ help: false,
42
+ notice: null,
43
+ };
44
+ }
45
+
46
+ // Failures and a pause belong to the classifier that earned them.
47
+ export const healthOf = (client, id) => ({ ...client.snapshot(), classifier: id });
48
+ // The last classification's readings, cleared when another classifier takes over so no label claims them.
49
+ export const CLEARED_READINGS = { adviceMs: null, adviceChoice: null, probabilities: null, estimate: null };
50
+
51
+ // The view patch for a main reply's usage. `tier` is the routed tier that served it, else null.
52
+ export function responseMetrics(view, response, tier) {
53
+ const usage = response.usage;
54
+ const counters = usage ? [usage.input_tokens, usage.cache_read_input_tokens, usage.cache_creation_input_tokens] : [];
55
+ const inputTokens =
56
+ counters.length && counters.every(Number.isFinite) ? counters.reduce((sum, n) => sum + n, 0) : null;
57
+ return {
58
+ actualModel: usage?.model ?? null,
59
+ cacheRead: usage?.cache_read_input_tokens ?? null,
60
+ cacheWrite: usage?.cache_creation_input_tokens ?? null,
61
+ inputTokens,
62
+ outputTokens: usage?.output_tokens ?? null,
63
+ // Appended together so the Usage trend can color each reading by its tier.
64
+ ...(Number.isFinite(inputTokens)
65
+ ? {
66
+ history: [...(view?.history ?? []), inputTokens].slice(-HISTORY),
67
+ tiers: [...(view?.tiers ?? []), tier ?? null].slice(-HISTORY),
68
+ }
69
+ : {}),
70
+ };
71
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexeiled/claude-router",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "Native Claude Code Mod: model and effort routing for the main conversation, advised by Jev, Clef or Clef Flash.",
5
5
  "license": "MIT",
6
6
  "author": "Alexei Ledenev",
@@ -28,8 +28,9 @@
28
28
  "access": "public"
29
29
  },
30
30
  "scripts": {
31
- "test": "node --test --test-timeout=8000 test/*.test.mjs",
32
- "check": "biome check lib scripts test hooks types .claude-plugin package.json package-lock.json biome.json experiments/mod-router",
31
+ "test": "node --test --test-timeout=8000 test/*.test.mjs experiments/mod-router/scripts/*.test.mjs",
32
+ "check": "biome check lib scripts test hooks types .claude-plugin package.json package-lock.json biome.json tsconfig.json experiments/mod-router",
33
+ "typecheck": "tsc -p tsconfig.json",
33
34
  "validate": "claude plugin validate .claude-plugin/plugin.json && claude plugin validate .claude-plugin/marketplace.json",
34
35
  "test:plugin": "bash scripts/plugin-test.sh",
35
36
  "format": "biome format --write .",
@@ -38,6 +39,7 @@
38
39
  "prepublishOnly": "npm run check && npm test"
39
40
  },
40
41
  "devDependencies": {
41
- "@biomejs/biome": "2.5.14"
42
+ "@biomejs/biome": "2.5.14",
43
+ "typescript": "7.0.2"
42
44
  }
43
45
  }
File without changes