@koinzhang/paseo-plugin-activity 0.5.0 → 0.7.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 (74) hide show
  1. package/CHANGELOG.md +78 -1
  2. package/README.md +15 -8
  3. package/client/activity-heatmap.tsx +126 -93
  4. package/client/agent-creations.tsx +216 -0
  5. package/client/attention-pill.tsx +16 -5
  6. package/client/attention-popover.tsx +19 -23
  7. package/client/color-mix.test.ts +27 -0
  8. package/client/color-mix.ts +38 -0
  9. package/client/design-tokens.test.ts +39 -0
  10. package/client/design-tokens.ts +168 -0
  11. package/client/fit-text.test.ts +41 -0
  12. package/client/fit-text.ts +33 -0
  13. package/client/formatted-time.tsx +4 -4
  14. package/client/global-surface.tsx +316 -275
  15. package/client/header-button.ts +136 -0
  16. package/client/hourly-activity-timeline.tsx +425 -0
  17. package/client/measured-width.ts +72 -0
  18. package/client/panel-visibility.test.ts +25 -0
  19. package/client/panel-visibility.ts +45 -0
  20. package/client/panel.tsx +83 -108
  21. package/client/provider-dropdown.tsx +131 -0
  22. package/client/provider-filter.test.ts +17 -13
  23. package/client/provider-filter.ts +5 -7
  24. package/client/range.test.ts +44 -0
  25. package/client/range.ts +14 -0
  26. package/client/rank-color.test.ts +108 -14
  27. package/client/rank-color.ts +261 -48
  28. package/client/ranking-bars.tsx +291 -0
  29. package/client/ui.tsx +339 -0
  30. package/client/usage-popover.tsx +62 -134
  31. package/client/usage-stats.tsx +137 -8
  32. package/client/use-agent-turn-end.ts +2 -1
  33. package/client/use-app-language.ts +17 -0
  34. package/client/web.ts +73 -18
  35. package/client/workspace/agent-row.tsx +18 -25
  36. package/client/workspace/agents-section.tsx +23 -20
  37. package/client/workspace/constants.ts +6 -6
  38. package/client/workspace/display-menu.tsx +5 -4
  39. package/client/workspace/filters.test.ts +1 -1
  40. package/client/workspace/filters.ts +4 -2
  41. package/client/workspace/panel.tsx +176 -104
  42. package/client/workspace/rank-section.tsx +157 -44
  43. package/client/workspace/terminals-section.tsx +13 -9
  44. package/index.client.tsx +40 -20
  45. package/index.server.ts +63 -31
  46. package/package.json +2 -2
  47. package/paseo-plugin.json +2 -1
  48. package/server/agents.ts +20 -2
  49. package/server/background-sync.test.ts +43 -0
  50. package/server/background-sync.ts +43 -4
  51. package/server/handlers-query.test.ts +252 -1
  52. package/server/handlers.ts +174 -13
  53. package/server/ingest.test.ts +8 -0
  54. package/server/messages.test.ts +96 -1
  55. package/server/prompt-dedupe.ts +52 -0
  56. package/server/rpc-cache.test.ts +74 -0
  57. package/server/rpc-cache.ts +48 -0
  58. package/server/store.test.ts +122 -0
  59. package/server/store.ts +313 -19
  60. package/server/ttl-cache.ts +3 -0
  61. package/shared/activity.test.ts +159 -6
  62. package/shared/activity.ts +140 -5
  63. package/shared/classify.test.ts +1 -0
  64. package/shared/classify.ts +4 -1
  65. package/shared/explorer-agent-display.test.ts +61 -0
  66. package/shared/explorer-agent-display.ts +21 -2
  67. package/shared/format.test.ts +28 -3
  68. package/shared/format.ts +25 -2
  69. package/shared/i18n.test.ts +34 -0
  70. package/shared/i18n.ts +363 -0
  71. package/shared/insights.test.ts +162 -80
  72. package/shared/insights.ts +136 -61
  73. package/shared/usage.test.ts +330 -0
  74. package/shared/usage.ts +471 -0
@@ -1,15 +1,56 @@
1
1
  import assert from "node:assert/strict";
2
2
  import { test } from "node:test";
3
- import { mcpServerColor } from "./rank-color.ts";
3
+ import {
4
+ brandColor,
5
+ chartColorScheme,
6
+ creationProviderColors,
7
+ entityColor,
8
+ knownProviderSlotCount,
9
+ providerColor,
10
+ } from "./rank-color.ts";
4
11
 
5
- const ACCENT = "#20744a";
12
+ const LIGHT_SURFACE = "#f4f4f5";
13
+ const DARK_SURFACE = "#18181b";
6
14
 
7
- test("mcpServerColor is stable for the same server", () => {
8
- assert.equal(mcpServerColor("github", ACCENT), mcpServerColor("github", ACCENT));
15
+ test("chartColorScheme reads light vs dark from surface luminance", () => {
16
+ assert.equal(chartColorScheme(LIGHT_SURFACE), "light");
17
+ assert.equal(chartColorScheme(DARK_SURFACE), "dark");
18
+ assert.equal(chartColorScheme("not-a-color"), "dark");
9
19
  });
10
20
 
11
- test("mcpServerColor spreads servers across distinct colors", () => {
12
- const servers = [
21
+ test("providerColor is stable and switches with scheme", () => {
22
+ assert.equal(providerColor("claude", "light"), providerColor("claude", "light"));
23
+ assert.equal(providerColor("claude/opus", "dark"), providerColor("claude", "dark"));
24
+ assert.notEqual(providerColor("claude", "light"), providerColor("claude", "dark"));
25
+ assert.match(providerColor("claude", "light"), /^#[0-9a-f]{6}$/i);
26
+ });
27
+
28
+ test("providerColor covers known Paseo providers without falling through", () => {
29
+ const known = [
30
+ "claude",
31
+ "codex",
32
+ "cursor",
33
+ "opencode",
34
+ "pi",
35
+ "omp",
36
+ "copilot",
37
+ "gemini",
38
+ "codebuddy-code",
39
+ "devin",
40
+ "hermes",
41
+ "kiro",
42
+ ];
43
+ for (const id of known) {
44
+ assert.match(providerColor(id, "light"), /^#[0-9a-f]{6}$/i);
45
+ }
46
+ assert.equal(providerColor("codebuddy-code", "dark"), providerColor("codebuddy", "dark"));
47
+ assert.ok(knownProviderSlotCount() >= 40, `expected many slots, got ${knownProviderSlotCount()}`);
48
+ });
49
+
50
+ test("entityColor hashes MCP keys into the soft palette", () => {
51
+ assert.equal(entityColor("github", "light"), entityColor("github", "light"));
52
+ assert.notEqual(entityColor("github", "light"), entityColor("github", "dark"));
53
+ const keys = [
13
54
  "github",
14
55
  "playwright",
15
56
  "context7",
@@ -19,17 +60,70 @@ test("mcpServerColor spreads servers across distinct colors", () => {
19
60
  "figma",
20
61
  "slack",
21
62
  ];
22
- const colors = new Set(servers.map((server) => mcpServerColor(server, ACCENT)));
63
+ const colors = new Set(keys.map((key) => entityColor(key, "light")));
23
64
  assert.ok(colors.size >= 6, `expected >= 6 distinct colors, got ${colors.size}`);
24
65
  });
25
66
 
26
- test("mcpServerColor returns hex and falls back to non-hex accents", () => {
27
- assert.match(mcpServerColor("github", ACCENT), /^#[0-9a-f]{6}$/);
28
- assert.equal(mcpServerColor("github", "rgb(32, 116, 74)"), "rgb(32, 116, 74)");
67
+ test("providerColor uses brand accents for Claude / Codex / Cursor / OpenCode / Pi / Oh My Pi", () => {
68
+ assert.equal(providerColor("claude", "light"), "#d97757");
69
+ assert.equal(providerColor("claude", "dark"), "#c46845");
70
+ assert.equal(providerColor("codex", "light"), "#4d9eef");
71
+ assert.equal(providerColor("codex", "dark"), "#0169cc");
72
+ assert.equal(providerColor("cursor", "light"), "#d94816");
73
+ assert.equal(providerColor("cursor", "dark"), "#b83900");
74
+ assert.equal(providerColor("opencode", "light"), "#74a2ec");
75
+ assert.equal(providerColor("opencode", "dark"), "#5a86d4");
76
+ assert.equal(providerColor("pi", "light"), "#f1be58");
77
+ assert.equal(providerColor("pi", "dark"), "#4d9abf");
78
+ assert.equal(providerColor("omp", "light"), "#9a90f5");
79
+ assert.equal(providerColor("omp", "dark"), "#7f73f2");
80
+ assert.equal(providerColor("copilot", "light"), "#5fed83");
81
+ assert.equal(providerColor("copilot", "dark"), "#077124");
82
+ assert.equal(providerColor("codebuddy", "light"), "#6c4dff");
83
+ assert.equal(providerColor("codebuddy", "dark"), "#5a3fd9");
84
+ assert.equal(providerColor("codebuddy-code", "light"), providerColor("codebuddy", "light"));
85
+ assert.equal(providerColor("gemini", "light"), "#8E75B2");
86
+ assert.equal(providerColor("cline", "light"), "#9663F1");
87
+ assert.equal(providerColor("minimax-code", "light"), providerColor("minimax", "light"));
88
+ assert.equal(providerColor("codewhale", "dark"), "#345c9d");
89
+ assert.notEqual(providerColor("omp", "light"), providerColor("pi", "light"));
90
+ assert.notEqual(providerColor("claude", "light"), providerColor("claude", "dark"));
91
+ });
92
+
93
+ test("creationProviderColors keeps brand colours even for the window leader", () => {
94
+ const map = creationProviderColors(["claude", "codex", "cursor"], "light");
95
+ assert.equal(map.get("claude"), providerColor("claude", "light"));
96
+ assert.equal(map.get("codex"), providerColor("codex", "light"));
97
+ assert.equal(map.get("cursor"), providerColor("cursor", "light"));
98
+ });
99
+
100
+ test("creationProviderColors uses soft palette when the leader has no brand colour", () => {
101
+ const map = creationProviderColors(["goose", "claude", "codex"], "light");
102
+ assert.equal(map.get("goose"), providerColor("goose", "light"));
103
+ assert.equal(brandColor("goose", "light"), null);
104
+ assert.equal(map.get("claude"), providerColor("claude", "light"));
105
+ assert.equal(map.get("codex"), providerColor("codex", "light"));
29
106
  });
30
107
 
31
- test("mcpServerColor adds saturation when the theme accent is near-gray", () => {
32
- const color = mcpServerColor("github", "#e4e4e7");
33
- assert.notEqual(color, "#e4e4e7");
34
- assert.match(color, /^#[0-9a-f]{6}$/);
108
+ test("creationProviderColors with a single branded provider keeps the brand", () => {
109
+ const map = creationProviderColors(["pi"], "dark");
110
+ assert.equal(map.get("pi"), providerColor("pi", "dark"));
111
+ assert.equal(map.size, 1);
35
112
  });
113
+
114
+ test("creationProviderColors with a single unbranded provider uses soft palette", () => {
115
+ const map = creationProviderColors(["goose"], "dark");
116
+ assert.equal(map.get("goose"), providerColor("goose", "dark"));
117
+ assert.equal(brandColor("goose", "dark"), null);
118
+ assert.equal(map.size, 1);
119
+ });
120
+
121
+ test("unknown future ACP ids fall back to soft CHART_PALETTE (stable hash)", () => {
122
+ assert.equal(brandColor("brand-new-acp-agent", "light"), null);
123
+ const a = providerColor("brand-new-acp-agent", "light");
124
+ const b = providerColor("brand-new-acp-agent", "light");
125
+ const other = providerColor("another-future-acp", "light");
126
+ assert.equal(a, b);
127
+ assert.match(a, /^#[0-9a-f]{6}$/i);
128
+ assert.notEqual(a, other);
129
+ });
@@ -1,5 +1,190 @@
1
+ import { normalizeProvider } from "../shared/classify.ts";
2
+
3
+ export type ChartColorScheme = "light" | "dark";
4
+
1
5
  type Rgb = [number, number, number];
2
6
 
7
+ /**
8
+ * Soft dashboard fills (Paseo identity-color family): low chroma, even luminance
9
+ * so stacked bars identify without shouting. Light UI uses the brighter set;
10
+ * dark UI uses the deeper set.
11
+ */
12
+ const CHART_PALETTE: Record<ChartColorScheme, readonly string[]> = {
13
+ // Soft fills swapped vs surface: light UI uses the brighter set, dark UI the deeper set.
14
+ light: [
15
+ "#a392d5", // violet
16
+ "#6aa6ce", // sky
17
+ "#6cae96", // emerald
18
+ "#cc8f64", // orange
19
+ "#d87da3", // pink
20
+ "#9299d5", // indigo
21
+ "#6cacab", // teal
22
+ "#d88381", // red
23
+ "#b29d64", // amber
24
+ "#7ba1d5", // blue
25
+ "#9ab87a", // olive
26
+ "#b89ac8", // mauve
27
+ ],
28
+ dark: [
29
+ "#6d49b5", // violet
30
+ "#3d6985", // sky
31
+ "#3e6e5d", // emerald
32
+ "#845838", // orange
33
+ "#974168", // pink
34
+ "#5251c2", // indigo
35
+ "#3e6d6c", // teal
36
+ "#9c4243", // red
37
+ "#716239", // amber
38
+ "#39649e", // blue
39
+ "#5a7a4a", // olive
40
+ "#7a5a8a", // mauve
41
+ ],
42
+ };
43
+
44
+ /**
45
+ * Known Paseo provider ids (builtin + ACP catalog + normalize aliases).
46
+ * Sources: `packages/protocol/src/provider-manifest.ts` builtins,
47
+ * `packages/app/src/data/acp-provider-catalog.ts`, and `normalizeProvider`
48
+ * aliases (`codebuddy-code` → `codebuddy`).
49
+ */
50
+ const KNOWN_PROVIDER_IDS = [
51
+ "agoragentic-acp",
52
+ "amp-acp",
53
+ "auggie",
54
+ "autohand",
55
+ "claude",
56
+ "cline",
57
+ "codebuddy",
58
+ "codebuddy-code",
59
+ "codewhale",
60
+ "codex",
61
+ "copilot",
62
+ "cortex-code",
63
+ "corust-agent",
64
+ "crow-cli",
65
+ "cursor",
66
+ "deepagents",
67
+ "devin",
68
+ "dimcode",
69
+ "dirac",
70
+ "factory-droid",
71
+ "fast-agent",
72
+ "gemini",
73
+ "gjc",
74
+ "glm-acp-agent",
75
+ "goose",
76
+ "grok",
77
+ "hermes",
78
+ "junie",
79
+ "kilo",
80
+ "kimi",
81
+ "kiro",
82
+ "minimax",
83
+ "minimax-code",
84
+ "minion-code",
85
+ "mistral-vibe",
86
+ "nova",
87
+ "omp",
88
+ "opencode",
89
+ "pi",
90
+ "poolside",
91
+ "qoder",
92
+ "qwen-code",
93
+ "sigit",
94
+ "stakpak",
95
+ "traecli",
96
+ "vtcode",
97
+ ] as const;
98
+
99
+ /** High-traffic providers get the first palette slots so stacks stay distinct. */
100
+ const PRIORITY_PROVIDERS = [
101
+ "claude",
102
+ "codex",
103
+ "cursor",
104
+ "opencode",
105
+ "pi",
106
+ "gemini",
107
+ "copilot",
108
+ "kiro",
109
+ "kimi",
110
+ "grok",
111
+ "goose",
112
+ "qwen-code",
113
+ ] as const;
114
+
115
+ /**
116
+ * Official-ish brand accents for providers with a known chromatic identity.
117
+ * Always preferred over the soft chart palette when present. Providers without
118
+ * an entry (and any future ACP id Paseo adds) fall through to CHART_PALETTE.
119
+ */
120
+ const PROVIDER_BRAND: Record<string, Record<ChartColorScheme, string>> = {
121
+ // Anthropic coral — dark is a step deeper than light
122
+ claude: { light: "#d97757", dark: "#c46845" },
123
+ // Codex brand blue
124
+ codex: { light: "#4d9eef", dark: "#0169cc" },
125
+ // Cursor orange — light softened vs neon brand #f54e00 for chart fills
126
+ cursor: { light: "#d94816", dark: "#b83900" },
127
+ // OpenCode blue — dark is a step deeper than light
128
+ opencode: { light: "#74a2ec", dark: "#5a86d4" },
129
+ // Pi
130
+ pi: { light: "#f1be58", dark: "#4d9abf" },
131
+ // Oh My Pi — light is a step brighter than dark
132
+ omp: { light: "#9a90f5", dark: "#7f73f2" },
133
+ // GitHub Copilot
134
+ copilot: { light: "#5fed83", dark: "#077124" },
135
+ // CodeBuddy purple — dark is a step deeper than light
136
+ codebuddy: { light: "#6c4dff", dark: "#5a3fd9" },
137
+
138
+ // --- High-confidence ACP / catalog brands ---
139
+ cline: { light: "#9663F1", dark: "#7b51c6" },
140
+ kiro: { light: "#9046FF", dark: "#7639d1" },
141
+ kilo: { light: "#F8F676", dark: "#cbca61" },
142
+ "factory-droid": { light: "#EF6F2E", dark: "#c45b26" },
143
+ "mistral-vibe": { light: "#FA520F", dark: "#cd430c" },
144
+ "qwen-code": { light: "#615CED", dark: "#504bc2" },
145
+ traecli: { light: "#32F08C", dark: "#29c573" },
146
+ poolside: { light: "#4137FF", dark: "#352dd1" },
147
+ minimax: { light: "#FF6452", dark: "#d15243" },
148
+ "minimax-code": { light: "#FF6452", dark: "#d15243" },
149
+ junie: { light: "#47E054", dark: "#3ab845" },
150
+ kimi: { light: "#007CFF", dark: "#0066d1" },
151
+ gemini: { light: "#8E75B2", dark: "#746092" },
152
+ "cortex-code": { light: "#29B5E8", dark: "#2294be" },
153
+ deepagents: { light: "#7FC8FF", dark: "#68a4d1" },
154
+ "glm-acp-agent": { light: "#3859FF", dark: "#2e49d1" },
155
+ "amp-acp": { light: "#F34E3F", dark: "#c74034" },
156
+ hermes: { light: "#0000F2", dark: "#0000c6" },
157
+ qoder: { light: "#8B5CF6", dark: "#724bca" },
158
+ auggie: { light: "#1AA049", dark: "#15833c" },
159
+ gjc: { light: "#FF6A3D", dark: "#d15732" },
160
+ dirac: { light: "#F59E0B", dark: "#c98209" },
161
+ devin: { light: "#31B388", dark: "#289370" },
162
+
163
+ // --- Medium-confidence (favicon / weak site sample) ---
164
+ codewhale: { light: "#4070C0", dark: "#345c9d" },
165
+ nova: { light: "#222F3E", dark: "#1c2733" },
166
+ };
167
+
168
+ /** Normalized id → palette slot (aliases that normalize together share a slot). */
169
+ const PROVIDER_SLOT = (() => {
170
+ const slots = new Map<string, number>();
171
+ let next = 0;
172
+ const claim = (raw: string) => {
173
+ const id = normalizeProvider(raw);
174
+ if (slots.has(id)) return;
175
+ slots.set(id, next);
176
+ next += 1;
177
+ };
178
+ for (const id of PRIORITY_PROVIDERS) claim(id);
179
+ for (const id of [...KNOWN_PROVIDER_IDS].sort()) claim(id);
180
+ for (const raw of KNOWN_PROVIDER_IDS) {
181
+ const id = normalizeProvider(raw);
182
+ const slot = slots.get(id);
183
+ if (slot != null) slots.set(raw, slot);
184
+ }
185
+ return slots;
186
+ })();
187
+
3
188
  function parseHex(value: string): Rgb | null {
4
189
  const hex = value.trim().replace(/^#/, "");
5
190
  const full = hex.length === 3 ? hex.split("").map((c) => c + c).join("") : hex;
@@ -11,59 +196,87 @@ function parseHex(value: string): Rgb | null {
11
196
  ];
12
197
  }
13
198
 
14
- function rgbToHsl([r, g, b]: Rgb): [number, number, number] {
15
- const rr = r / 255;
16
- const gg = g / 255;
17
- const bb = b / 255;
18
- const max = Math.max(rr, gg, bb);
19
- const min = Math.min(rr, gg, bb);
20
- const lightness = (max + min) / 2;
21
- if (max === min) return [0, 0, lightness];
22
- const delta = max - min;
23
- const saturation = lightness > 0.5 ? delta / (2 - max - min) : delta / (max + min);
24
- const hue =
25
- max === rr
26
- ? ((gg - bb) / delta + (gg < bb ? 6 : 0)) / 6
27
- : max === gg
28
- ? ((bb - rr) / delta + 2) / 6
29
- : ((rr - gg) / delta + 4) / 6;
30
- return [hue * 360, saturation, lightness];
199
+ function channelLuminance(channel: number): number {
200
+ const c = channel / 255;
201
+ return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
31
202
  }
32
203
 
33
- function hslToHex(hue: number, saturation: number, lightness: number): string {
34
- const h = ((hue % 360) + 360) % 360;
35
- const chroma = (1 - Math.abs(2 * lightness - 1)) * saturation;
36
- const second = chroma * (1 - Math.abs(((h / 60) % 2) - 1));
37
- const offset = lightness - chroma / 2;
38
- const [r, g, b] =
39
- h < 60
40
- ? [chroma, second, 0]
41
- : h < 120
42
- ? [second, chroma, 0]
43
- : h < 180
44
- ? [0, chroma, second]
45
- : h < 240
46
- ? [0, second, chroma]
47
- : h < 300
48
- ? [second, 0, chroma]
49
- : [chroma, 0, second];
50
- return `#${[r, g, b]
51
- .map((value) => Math.round((value + offset) * 255).toString(16).padStart(2, "0"))
52
- .join("")}`;
204
+ /** WCAG relative luminance of a hex surface (0 = black, 1 = white). */
205
+ function relativeLuminance(hex: string): number | null {
206
+ const rgb = parseHex(hex);
207
+ if (!rgb) return null;
208
+ const [r, g, b] = rgb;
209
+ return 0.2126 * channelLuminance(r) + 0.7152 * channelLuminance(g) + 0.0722 * channelLuminance(b);
53
210
  }
54
211
 
55
- const GOLDEN_ANGLE = 137.508;
212
+ /**
213
+ * Infer light/dark chart palette from the theme surface.
214
+ * PluginTheme does not expose `appearance` / `colorScheme` (only `colors`), so
215
+ * luminance of `surface0` is the reliable signal.
216
+ */
217
+ export function chartColorScheme(surface0: string): ChartColorScheme {
218
+ const luminance = relativeLuminance(surface0);
219
+ if (luminance == null) return "dark";
220
+ return luminance > 0.45 ? "light" : "dark";
221
+ }
56
222
 
57
- export function mcpServerColor(server: string, accent: string): string {
58
- const rgb = parseHex(accent);
59
- if (!rgb) return accent;
223
+ function hashKey(key: string): number {
60
224
  let hash = 0;
61
- for (let i = 0; i < server.length; i += 1) {
62
- hash = (hash * 31 + server.charCodeAt(i)) >>> 0;
225
+ for (let i = 0; i < key.length; i += 1) {
226
+ hash = (hash * 31 + key.charCodeAt(i)) >>> 0;
227
+ }
228
+ return hash;
229
+ }
230
+
231
+ function paletteColor(slot: number, scheme: ChartColorScheme): string {
232
+ const palette = CHART_PALETTE[scheme];
233
+ return palette[((slot % palette.length) + palette.length) % palette.length]!;
234
+ }
235
+
236
+ /**
237
+ * Stable colour for a provider id:
238
+ * 1. `PROVIDER_BRAND` when present
239
+ * 2. else soft `CHART_PALETTE` — known ids get a reserved slot; unknown /
240
+ * future ACP ids hash into the same palette (no theme accent, no invented brands)
241
+ */
242
+ export function providerColor(provider: string, scheme: ChartColorScheme): string {
243
+ const brand = brandColor(provider, scheme);
244
+ if (brand) return brand;
245
+ const id = normalizeProvider(provider);
246
+ const known = PROVIDER_SLOT.get(id) ?? PROVIDER_SLOT.get(provider.toLowerCase());
247
+ if (known != null) return paletteColor(known, scheme);
248
+ return paletteColor(hashKey(id), scheme);
249
+ }
250
+
251
+ /** Brand fill for a known provider, or `null` when it falls back to the soft palette. */
252
+ export function brandColor(provider: string, scheme: ChartColorScheme): string | null {
253
+ return PROVIDER_BRAND[normalizeProvider(provider)]?.[scheme] ?? null;
254
+ }
255
+
256
+ /**
257
+ * Histogram stack colours: branded providers keep brand accents; everything
258
+ * else (unbranded catalog + future ACP ids) uses soft `CHART_PALETTE`.
259
+ */
260
+ export function creationProviderColors(
261
+ rankedProviders: readonly string[],
262
+ scheme: ChartColorScheme,
263
+ ): Map<string, string> {
264
+ const colors = new Map<string, string>();
265
+ for (const provider of rankedProviders) {
266
+ colors.set(provider, providerColor(provider, scheme));
63
267
  }
64
- const [baseHue, baseSaturation, baseLightness] = rgbToHsl(rgb);
65
- const hue = (baseHue + hash * GOLDEN_ANGLE) % 360;
66
- const saturation = Math.min(0.75, Math.max(0.45, baseSaturation));
67
- const lightness = Math.min(0.7, Math.max(0.32, baseLightness));
68
- return hslToHex(hue, saturation, lightness);
268
+ return colors;
269
+ }
270
+
271
+ /**
272
+ * Soft colour for MCP servers / arbitrary keys — same palette as providers,
273
+ * hash-mapped (no 1:1 name table).
274
+ */
275
+ export function entityColor(key: string, scheme: ChartColorScheme): string {
276
+ return paletteColor(hashKey(key), scheme);
277
+ }
278
+
279
+ /** Test / docs helper: how many unique normalized provider slots we reserve. */
280
+ export function knownProviderSlotCount(): number {
281
+ return new Set(KNOWN_PROVIDER_IDS.map((id) => normalizeProvider(id))).size;
69
282
  }