@tangle-network/agent-app 0.51.6 → 0.51.7

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 (39) hide show
  1. package/dist/{DesignCanvasEditor-ZHKJIDOB.js → DesignCanvasEditor-Z6UUPJKS.js} +3 -3
  2. package/dist/chat-routes/index.js +4 -4
  3. package/dist/{chunk-KU5YAGLB.js → chunk-2YSXWBBL.js} +2 -2
  4. package/dist/chunk-C4V2LIUC.js +150 -0
  5. package/dist/chunk-C4V2LIUC.js.map +1 -0
  6. package/dist/{chunk-CBRYWGUO.js → chunk-D3OYEEHO.js} +2 -2
  7. package/dist/{chunk-CBRYWGUO.js.map → chunk-D3OYEEHO.js.map} +1 -1
  8. package/dist/{chunk-2PDKWV2S.js → chunk-E4SBLZRW.js} +2 -2
  9. package/dist/{chunk-PF3AZD5G.js → chunk-EYTU3Z7T.js} +4 -4
  10. package/dist/{chunk-SYIV74NB.js → chunk-KGUC7S72.js} +2 -2
  11. package/dist/{chunk-IYLPQKAH.js → chunk-SOGWOBFF.js} +2 -2
  12. package/dist/{chunk-QGSVF6DZ.js → chunk-ZVNPAJ7Z.js} +18 -8
  13. package/dist/chunk-ZVNPAJ7Z.js.map +1 -0
  14. package/dist/design-canvas-react/index.js +3 -3
  15. package/dist/design-canvas-react/lazy.js +1 -1
  16. package/dist/preset-cloudflare/index.js +2 -2
  17. package/dist/sandbox/index.js +4 -4
  18. package/dist/theme/brand.generated.d.ts +91 -0
  19. package/dist/theme/index.d.ts +1 -1
  20. package/dist/theme/index.js +1 -1
  21. package/dist/theme/tailwind-preset.d.ts +13 -17
  22. package/dist/theme/tailwind-preset.js +24 -64
  23. package/dist/theme/tailwind-preset.js.map +1 -1
  24. package/dist/theme/theme.d.ts +3 -15
  25. package/dist/theme/tokens.css +1051 -608
  26. package/dist/theme-contract/cli.js +1 -1
  27. package/dist/theme-contract/index.js +1 -1
  28. package/dist/tools/index.js +4 -4
  29. package/dist/work-product/index.js +2 -2
  30. package/package.json +7 -4
  31. package/dist/chunk-Q2QKEV6J.js +0 -144
  32. package/dist/chunk-Q2QKEV6J.js.map +0 -1
  33. package/dist/chunk-QGSVF6DZ.js.map +0 -1
  34. /package/dist/{DesignCanvasEditor-ZHKJIDOB.js.map → DesignCanvasEditor-Z6UUPJKS.js.map} +0 -0
  35. /package/dist/{chunk-KU5YAGLB.js.map → chunk-2YSXWBBL.js.map} +0 -0
  36. /package/dist/{chunk-2PDKWV2S.js.map → chunk-E4SBLZRW.js.map} +0 -0
  37. /package/dist/{chunk-PF3AZD5G.js.map → chunk-EYTU3Z7T.js.map} +0 -0
  38. /package/dist/{chunk-SYIV74NB.js.map → chunk-KGUC7S72.js.map} +0 -0
  39. /package/dist/{chunk-IYLPQKAH.js.map → chunk-SOGWOBFF.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  checkThemeContract
4
- } from "../chunk-QGSVF6DZ.js";
4
+ } from "../chunk-ZVNPAJ7Z.js";
5
5
  import "../chunk-EMLGWEHV.js";
6
6
  import {
7
7
  invokedAsScript
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  checkThemeContract
3
- } from "../chunk-QGSVF6DZ.js";
3
+ } from "../chunk-ZVNPAJ7Z.js";
4
4
  import "../chunk-EMLGWEHV.js";
5
5
  export {
6
6
  checkThemeContract
@@ -9,7 +9,7 @@ import {
9
9
  restrictTaxonomy,
10
10
  verifyCapabilityToken,
11
11
  verifyExpiringCapabilityToken
12
- } from "../chunk-PF3AZD5G.js";
12
+ } from "../chunk-EYTU3Z7T.js";
13
13
  import {
14
14
  DEFAULT_APP_TOOL_PATHS,
15
15
  DEFAULT_HEADER_NAMES,
@@ -29,13 +29,13 @@ import {
29
29
  defineAppTool,
30
30
  findCustomTool,
31
31
  isAppToolName
32
- } from "../chunk-2PDKWV2S.js";
32
+ } from "../chunk-E4SBLZRW.js";
33
33
  import "../chunk-UGWQLQDS.js";
34
34
  import "../chunk-S5SRJJQG.js";
35
- import "../chunk-IYLPQKAH.js";
35
+ import "../chunk-SOGWOBFF.js";
36
36
  import {
37
37
  ToolInputError
38
- } from "../chunk-CBRYWGUO.js";
38
+ } from "../chunk-D3OYEEHO.js";
39
39
  export {
40
40
  APP_TOOL_NAMES,
41
41
  DEFAULT_APP_TOOL_PATHS,
@@ -4,11 +4,11 @@ import {
4
4
  } from "../chunk-GEYACSFW.js";
5
5
  import {
6
6
  defineAppTool
7
- } from "../chunk-2PDKWV2S.js";
7
+ } from "../chunk-E4SBLZRW.js";
8
8
  import "../chunk-UGWQLQDS.js";
9
9
  import {
10
10
  ToolInputError
11
- } from "../chunk-CBRYWGUO.js";
11
+ } from "../chunk-D3OYEEHO.js";
12
12
  import {
13
13
  isWorkProductStatus,
14
14
  parseAgentCheckInput,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-app",
3
- "version": "0.51.6",
3
+ "version": "0.51.7",
4
4
  "packageManager": "pnpm@11.24.0",
5
5
  "description": "Build agent applications with typed chat, tools, sandboxes, integrations, billing, and evaluation.",
6
6
  "keywords": [
@@ -25,7 +25,9 @@
25
25
  },
26
26
  "license": "MIT",
27
27
  "type": "module",
28
- "sideEffects": false,
28
+ "sideEffects": [
29
+ "./dist/**/*.css"
30
+ ],
29
31
  "files": [
30
32
  "dist",
31
33
  "bin",
@@ -562,12 +564,13 @@
562
564
  }
563
565
  },
564
566
  "scripts": {
565
- "build": "tsup && tsc -p tsconfig.build.json",
567
+ "build": "node src/theme/build.mjs --check && tsup && tsc -p tsconfig.build.json",
566
568
  "dev": "tsup --watch",
567
569
  "dev:types": "tsc -p tsconfig.build.json --watch --preserveWatchOutput",
568
570
  "prepare": "pnpm run build",
569
571
  "test": "vitest run",
570
572
  "test:generated": "node .github/scripts/test-generated-projects.mjs",
573
+ "test:theme:packed": "node tests/theme/packed-styles-consumer.mjs",
571
574
  "test:gates": "vitest run src/sandbox/index.test.ts src/profile/index.test.ts tests/chat-stream.test.ts tests/browser-safe-subpaths.test.ts tests/test-quality.test.ts tests/knip-entries-fresh.test.ts tests/web-react/popover-escapes-host.test.tsx tests/web-react/popover-canon-source.test.ts tests/studio/layer-order.test.ts",
572
575
  "test:watch": "vitest",
573
576
  "typecheck": "tsc --noEmit",
@@ -593,7 +596,7 @@
593
596
  "@tangle-network/agent-knowledge": "18.0.0",
594
597
  "@tangle-network/agent-profile-materialize": "0.20.1",
595
598
  "@tangle-network/agent-runtime": "0.289.1",
596
- "@tangle-network/brand": "1.9.1",
599
+ "@tangle-network/brand": "1.10.0",
597
600
  "@tangle-network/hub-sdk": "0.22.1",
598
601
  "@tangle-network/sandbox": "0.59.0",
599
602
  "@tangle-network/sandbox-ui": "0.117.0",
@@ -1,144 +0,0 @@
1
- // src/theme/theme.ts
2
- var lightTheme = {
3
- background: "233.2 14.8% 93.4%",
4
- foreground: "234.9 28.5% 6.4%",
5
- card: "0 0% 100%",
6
- cardForeground: "234.9 28.5% 6.4%",
7
- popover: "0 0% 100%",
8
- popoverForeground: "234.9 28.5% 6.4%",
9
- primary: "245 62% 57%",
10
- primaryForeground: "0 0% 100%",
11
- secondary: "233.2 19.9% 95.9%",
12
- secondaryForeground: "234.2 17.6% 11.3%",
13
- muted: "233.2 19.9% 95.9%",
14
- mutedForeground: "239.7 1.3% 38.2%",
15
- accent: "233.2 19.9% 95.9%",
16
- accentForeground: "234.2 17.6% 11.3%",
17
- destructive: "0 72% 41%",
18
- destructiveForeground: "0 0% 100%",
19
- border: "233.1 6.8% 81.4%",
20
- input: "233.1 6.8% 81.4%",
21
- ring: "245 62% 57%",
22
- success: "160 84% 26%",
23
- successForeground: "0 0% 100%",
24
- warning: "41 96% 38%",
25
- warningForeground: "38 92% 12%",
26
- warningStrong: "41 96% 27%",
27
- canvasBackdrop: "hsl(233.1 12.5% 90.9%)",
28
- borderSoft: "color-mix(in oklch, hsl(var(--border)) 40%, transparent)",
29
- cardEdge: "color-mix(in oklch, hsl(var(--border)) 60%, transparent)",
30
- canvasRender: {
31
- grid: "#c0c0c0",
32
- snapGrid: "#a0a0a0",
33
- snapGuide: "#3b82f6",
34
- snapPage: "#f59e0b",
35
- snapElement: "#f43f5e",
36
- selectionStroke: "#00a1ff",
37
- selectionAnchorFill: "#ffffff",
38
- placeholderFill: "#1f2937",
39
- placeholderStroke: "#374151",
40
- brokenFill: "#e5e7eb",
41
- brokenStroke: "#9ca3af"
42
- }
43
- };
44
- var darkTheme = {
45
- background: "234.5 21.2% 9%",
46
- foreground: "233.2 14.8% 93.4%",
47
- card: "233.8 12.9% 15.4%",
48
- cardForeground: "233.2 14.8% 93.4%",
49
- popover: "233.6 9.3% 21.2%",
50
- popoverForeground: "233.2 14.8% 93.4%",
51
- primary: "239 84% 74%",
52
- // Inverted, not copied from light: white on this fill measures 3.02:1.
53
- primaryForeground: "234.9 28.5% 6.4%",
54
- secondary: "233.7 10.7% 19.3%",
55
- secondaryForeground: "233.2 14.8% 93.4%",
56
- muted: "233.7 10.7% 19.3%",
57
- mutedForeground: "239.6 1.5% 62.5%",
58
- accent: "233.7 10.7% 19.3%",
59
- accentForeground: "233.2 14.8% 93.4%",
60
- destructive: "348 90% 68%",
61
- destructiveForeground: "234.2 17.6% 11.3%",
62
- border: "233.4 7% 25.6%",
63
- input: "234.2 17.6% 11.3%",
64
- ring: "239 84% 74%",
65
- success: "160 70% 52%",
66
- successForeground: "160 84% 10%",
67
- warning: "40 94% 56%",
68
- warningForeground: "38 92% 12%",
69
- warningStrong: "40 94% 56%",
70
- canvasBackdrop: "hsl(234.9 28.5% 6.4%)",
71
- // The lifted border (L 0.365) leaves room to soften: 60% still reads 1.265
72
- // on the card, where the old border at full strength read 1.158.
73
- borderSoft: "color-mix(in oklch, hsl(var(--border)) 60%, transparent)",
74
- cardEdge: "color-mix(in oklch, hsl(var(--border)) 80%, transparent)",
75
- canvasRender: {
76
- grid: "#3a3a3a",
77
- snapGrid: "#5a5a5a",
78
- snapGuide: "#3b82f6",
79
- snapPage: "#f59e0b",
80
- snapElement: "#f43f5e",
81
- selectionStroke: "#00a1ff",
82
- selectionAnchorFill: "#e5e7eb",
83
- placeholderFill: "#2a2f3a",
84
- placeholderStroke: "#3f4654",
85
- brokenFill: "#262b33",
86
- brokenStroke: "#4b5563"
87
- }
88
- };
89
- function themeColor(value) {
90
- return /^(hsl|rgb|oklch|oklab|lch|lab|color|color-mix|#)/.test(value) ? value : `hsl(${value})`;
91
- }
92
- function themeToCssVars(theme) {
93
- return {
94
- "--background": theme.background,
95
- "--foreground": theme.foreground,
96
- "--card": theme.card,
97
- "--card-foreground": theme.cardForeground,
98
- "--popover": theme.popover,
99
- "--popover-foreground": theme.popoverForeground,
100
- "--primary": theme.primary,
101
- "--primary-foreground": theme.primaryForeground,
102
- "--secondary": theme.secondary,
103
- "--secondary-foreground": theme.secondaryForeground,
104
- "--muted": theme.muted,
105
- "--muted-foreground": theme.mutedForeground,
106
- "--accent": theme.accent,
107
- "--accent-foreground": theme.accentForeground,
108
- "--destructive": theme.destructive,
109
- "--destructive-foreground": theme.destructiveForeground,
110
- "--border": theme.border,
111
- "--input": theme.input,
112
- "--ring": theme.ring,
113
- "--success": theme.success,
114
- "--success-foreground": theme.successForeground,
115
- "--warning": theme.warning,
116
- "--warning-foreground": theme.warningForeground,
117
- // Falls back to the pairing the tinted surfaces used before this token
118
- // existed, so an unset value restores the previous look rather than an
119
- // unthemed one.
120
- "--warning-strong": theme.warningStrong ?? theme.warningForeground,
121
- "--bg-input": `hsl(${theme.card})`,
122
- "--text-primary": `hsl(${theme.foreground})`,
123
- "--text-secondary": `hsl(${theme.secondaryForeground})`,
124
- "--text-muted": `hsl(${theme.mutedForeground})`,
125
- "--text-danger": `hsl(${theme.destructive})`,
126
- "--border-default": `hsl(${theme.border})`,
127
- "--brand-primary": `hsl(${theme.primary})`,
128
- "--editor-selection-background": `hsl(${theme.primary})`,
129
- "--editor-selection-foreground": `hsl(${theme.background})`,
130
- "--canvas-backdrop": theme.canvasBackdrop,
131
- // Full strength is the safe default: an unset tier can under-draw an edge,
132
- // never erase one.
133
- "--border-soft": theme.borderSoft ?? `hsl(${theme.border})`,
134
- "--card-edge": theme.cardEdge ?? `hsl(${theme.border})`
135
- };
136
- }
137
-
138
- export {
139
- lightTheme,
140
- darkTheme,
141
- themeColor,
142
- themeToCssVars
143
- };
144
- //# sourceMappingURL=chunk-Q2QKEV6J.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/theme/theme.ts"],"sourcesContent":["/**\n * Typed mirror of tokens.css for runtime/JS theming. The canonical source is\n * tokens.css (`import '@tangle-network/agent-app/styles'`); this module is for\n * apps that compute theme variables in JS, or read color values where CSS\n * custom properties cannot reach — notably Konva canvas render code, which\n * paints to a bitmap and cannot resolve `var(--…)`.\n *\n * Values are shadcn-style HSL channel triples (\"H S% L%\"); wrap with `color()`.\n *\n * The neutral triples are the RESOLVED form of tokens.css's `--neutral-*` ramp\n * (that file states them as `var(--neutral-NN-hsl)`; JS has no cascade to\n * resolve through, so they are inlined here). `tests/theme/tokens-contract.test.ts`\n * resolves the CSS one level and fails if this mirror has drifted.\n */\n\nexport interface AgentAppTheme {\n background: string\n foreground: string\n card: string\n cardForeground: string\n popover: string\n popoverForeground: string\n primary: string\n primaryForeground: string\n secondary: string\n secondaryForeground: string\n muted: string\n mutedForeground: string\n accent: string\n accentForeground: string\n destructive: string\n destructiveForeground: string\n border: string\n input: string\n ring: string\n success: string\n successForeground: string\n warning: string\n warningForeground: string\n /**\n * Warning as TEXT on a warning-TINTED surface, as a channel triple. Optional\n * so a consumer's existing `AgentAppTheme` literal still type-checks;\n * {@link themeToCssVars} falls back to `warningForeground`, which is what the\n * surface used before this token existed.\n */\n warningStrong?: string\n /** Full CSS color (not a triple) — the canvas/scene backdrop. */\n canvasBackdrop: string\n /**\n * Border tiers as FULL CSS colors (they are `color-mix()` results, not\n * triples). Optional so a consumer's existing `AgentAppTheme` literal still\n * type-checks; {@link themeToCssVars} falls back to full-strength\n * `hsl(var(--border))`, which can never erase an edge.\n */\n borderSoft?: string\n /** @see borderSoft */\n cardEdge?: string\n /** Konva render palette — full hex colors the bitmap canvas paints with\n * (it cannot resolve `var(--…)`). NOT emitted by themeToCssVars. */\n canvasRender: CanvasRenderPalette\n}\n\n/**\n * Colors the Konva design-canvas paints directly. Konva renders to a bitmap\n * and cannot read CSS custom properties, so these are full hex strings sourced\n * from the active theme and threaded through the canvas components.\n */\nexport interface CanvasRenderPalette {\n /** Grid line color (GridLayer). */\n grid: string\n /** Grid-snap guide line (SnapGuidesOverlay, kind 'grid'). */\n snapGrid: string\n /** Saved ruler-guide snap line (kind 'guide'). */\n snapGuide: string\n /** Page edge/center snap line (kinds 'page-edge'/'page-center'). */\n snapPage: string\n /** Element edge/center snap line (kinds 'element-edge'/'element-center'). */\n snapElement: string\n /** Transformer border + anchor stroke (SelectionLayer). */\n selectionStroke: string\n /** Transformer anchor fill (SelectionLayer). */\n selectionAnchorFill: string\n /** Video placeholder fill (ElementNode VideoNode). */\n placeholderFill: string\n /** Video placeholder stroke (ElementNode VideoNode). */\n placeholderStroke: string\n /** Broken/loading image placeholder fill (ElementNode ImageNode). */\n brokenFill: string\n /** Broken/loading image placeholder stroke (ElementNode ImageNode). */\n brokenStroke: string\n}\n\n/** Define a light color theme with specific background, foreground, and accent color values */\nexport const lightTheme: AgentAppTheme = {\n background: '233.2 14.8% 93.4%',\n foreground: '234.9 28.5% 6.4%',\n card: '0 0% 100%',\n cardForeground: '234.9 28.5% 6.4%',\n popover: '0 0% 100%',\n popoverForeground: '234.9 28.5% 6.4%',\n primary: '245 62% 57%',\n primaryForeground: '0 0% 100%',\n secondary: '233.2 19.9% 95.9%',\n secondaryForeground: '234.2 17.6% 11.3%',\n muted: '233.2 19.9% 95.9%',\n mutedForeground: '239.7 1.3% 38.2%',\n accent: '233.2 19.9% 95.9%',\n accentForeground: '234.2 17.6% 11.3%',\n destructive: '0 72% 41%',\n destructiveForeground: '0 0% 100%',\n border: '233.1 6.8% 81.4%',\n input: '233.1 6.8% 81.4%',\n ring: '245 62% 57%',\n success: '160 84% 26%',\n successForeground: '0 0% 100%',\n warning: '41 96% 38%',\n warningForeground: '38 92% 12%',\n warningStrong: '41 96% 27%',\n canvasBackdrop: 'hsl(233.1 12.5% 90.9%)',\n borderSoft: 'color-mix(in oklch, hsl(var(--border)) 40%, transparent)',\n cardEdge: 'color-mix(in oklch, hsl(var(--border)) 60%, transparent)',\n canvasRender: {\n grid: '#c0c0c0',\n snapGrid: '#a0a0a0',\n snapGuide: '#3b82f6',\n snapPage: '#f59e0b',\n snapElement: '#f43f5e',\n selectionStroke: '#00a1ff',\n selectionAnchorFill: '#ffffff',\n placeholderFill: '#1f2937',\n placeholderStroke: '#374151',\n brokenFill: '#e5e7eb',\n brokenStroke: '#9ca3af',\n },\n}\n\n/** Define a dark color scheme for the Agent app interface with specific background and foreground hues */\nexport const darkTheme: AgentAppTheme = {\n background: '234.5 21.2% 9%',\n foreground: '233.2 14.8% 93.4%',\n card: '233.8 12.9% 15.4%',\n cardForeground: '233.2 14.8% 93.4%',\n popover: '233.6 9.3% 21.2%',\n popoverForeground: '233.2 14.8% 93.4%',\n primary: '239 84% 74%',\n // Inverted, not copied from light: white on this fill measures 3.02:1.\n primaryForeground: '234.9 28.5% 6.4%',\n secondary: '233.7 10.7% 19.3%',\n secondaryForeground: '233.2 14.8% 93.4%',\n muted: '233.7 10.7% 19.3%',\n mutedForeground: '239.6 1.5% 62.5%',\n accent: '233.7 10.7% 19.3%',\n accentForeground: '233.2 14.8% 93.4%',\n destructive: '348 90% 68%',\n destructiveForeground: '234.2 17.6% 11.3%',\n border: '233.4 7% 25.6%',\n input: '234.2 17.6% 11.3%',\n ring: '239 84% 74%',\n success: '160 70% 52%',\n successForeground: '160 84% 10%',\n warning: '40 94% 56%',\n warningForeground: '38 92% 12%',\n warningStrong: '40 94% 56%',\n canvasBackdrop: 'hsl(234.9 28.5% 6.4%)',\n // The lifted border (L 0.365) leaves room to soften: 60% still reads 1.265\n // on the card, where the old border at full strength read 1.158.\n borderSoft: 'color-mix(in oklch, hsl(var(--border)) 60%, transparent)',\n cardEdge: 'color-mix(in oklch, hsl(var(--border)) 80%, transparent)',\n canvasRender: {\n grid: '#3a3a3a',\n snapGrid: '#5a5a5a',\n snapGuide: '#3b82f6',\n snapPage: '#f59e0b',\n snapElement: '#f43f5e',\n selectionStroke: '#00a1ff',\n selectionAnchorFill: '#e5e7eb',\n placeholderFill: '#2a2f3a',\n placeholderStroke: '#3f4654',\n brokenFill: '#262b33',\n brokenStroke: '#4b5563',\n },\n}\n\n/**\n * Wrap a channel triple in `hsl()`; pass through values already in a color form.\n * `oklch(…)` / `oklab(…)` / `color-mix(…)` are recognised because the ramp is\n * authored in oklch and the border tiers are colour mixes — wrapping either in\n * `hsl()` yields an invalid colour that paints as nothing.\n */\nexport function themeColor(value: string): string {\n return /^(hsl|rgb|oklch|oklab|lch|lab|color|color-mix|#)/.test(value) ? value : `hsl(${value})`\n}\n\n/**\n * Map a theme to the full CSS-variable set (shadcn triples + canvas/sequences\n * aliases + canvas surface). Apply at runtime to scope a theme without loading\n * tokens.css: `Object.assign(el.style, themeToCssVars(darkTheme))`.\n */\nexport function themeToCssVars(theme: AgentAppTheme): Record<string, string> {\n return {\n '--background': theme.background,\n '--foreground': theme.foreground,\n '--card': theme.card,\n '--card-foreground': theme.cardForeground,\n '--popover': theme.popover,\n '--popover-foreground': theme.popoverForeground,\n '--primary': theme.primary,\n '--primary-foreground': theme.primaryForeground,\n '--secondary': theme.secondary,\n '--secondary-foreground': theme.secondaryForeground,\n '--muted': theme.muted,\n '--muted-foreground': theme.mutedForeground,\n '--accent': theme.accent,\n '--accent-foreground': theme.accentForeground,\n '--destructive': theme.destructive,\n '--destructive-foreground': theme.destructiveForeground,\n '--border': theme.border,\n '--input': theme.input,\n '--ring': theme.ring,\n '--success': theme.success,\n '--success-foreground': theme.successForeground,\n '--warning': theme.warning,\n '--warning-foreground': theme.warningForeground,\n // Falls back to the pairing the tinted surfaces used before this token\n // existed, so an unset value restores the previous look rather than an\n // unthemed one.\n '--warning-strong': theme.warningStrong ?? theme.warningForeground,\n '--bg-input': `hsl(${theme.card})`,\n '--text-primary': `hsl(${theme.foreground})`,\n '--text-secondary': `hsl(${theme.secondaryForeground})`,\n '--text-muted': `hsl(${theme.mutedForeground})`,\n '--text-danger': `hsl(${theme.destructive})`,\n '--border-default': `hsl(${theme.border})`,\n '--brand-primary': `hsl(${theme.primary})`,\n '--editor-selection-background': `hsl(${theme.primary})`,\n '--editor-selection-foreground': `hsl(${theme.background})`,\n '--canvas-backdrop': theme.canvasBackdrop,\n // Full strength is the safe default: an unset tier can under-draw an edge,\n // never erase one.\n '--border-soft': theme.borderSoft ?? `hsl(${theme.border})`,\n '--card-edge': theme.cardEdge ?? `hsl(${theme.border})`,\n }\n}\n"],"mappings":";AA6FO,IAAM,aAA4B;AAAA,EACvC,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,MAAM;AAAA,EACN,gBAAgB;AAAA,EAChB,SAAS;AAAA,EACT,mBAAmB;AAAA,EACnB,SAAS;AAAA,EACT,mBAAmB;AAAA,EACnB,WAAW;AAAA,EACX,qBAAqB;AAAA,EACrB,OAAO;AAAA,EACP,iBAAiB;AAAA,EACjB,QAAQ;AAAA,EACR,kBAAkB;AAAA,EAClB,aAAa;AAAA,EACb,uBAAuB;AAAA,EACvB,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,MAAM;AAAA,EACN,SAAS;AAAA,EACT,mBAAmB;AAAA,EACnB,SAAS;AAAA,EACT,mBAAmB;AAAA,EACnB,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,cAAc;AAAA,IACZ,MAAM;AAAA,IACN,UAAU;AAAA,IACV,WAAW;AAAA,IACX,UAAU;AAAA,IACV,aAAa;AAAA,IACb,iBAAiB;AAAA,IACjB,qBAAqB;AAAA,IACrB,iBAAiB;AAAA,IACjB,mBA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W,MAAM;AAAA,IACjB,sBAAsB,MAAM;AAAA,IAC5B,YAAY,MAAM;AAAA,IAClB,uBAAuB,MAAM;AAAA,IAC7B,iBAAiB,MAAM;AAAA,IACvB,4BAA4B,MAAM;AAAA,IAClC,YAAY,MAAM;AAAA,IAClB,WAAW,MAAM;AAAA,IACjB,UAAU,MAAM;AAAA,IAChB,aAAa,MAAM;AAAA,IACnB,wBAAwB,MAAM;AAAA,IAC9B,aAAa,MAAM;AAAA,IACnB,wBAAwB,MAAM;AAAA;AAAA;AAAA;AAAA,IAI9B,oBAAoB,MAAM,iBAAiB,MAAM;AAAA,IACjD,cAAc,OAAO,MAAM,IAAI;AAAA,IAC/B,kBAAkB,OAAO,MAAM,UAAU;AAAA,IACzC,oBAAoB,OAAO,MAAM,mBAAmB;AAAA,IACpD,gBAAgB,OAAO,MAAM,eAAe;AAAA,IAC5C,iBAAiB,OAAO,MAAM,WAAW;AAAA,IACzC,oBAAoB,OAAO,MAAM,MAAM;AAAA,IACvC,mBAAmB,OAAO,MAAM,OAAO;AAAA,IACvC,iCAAiC,OAAO,MAAM,OAAO;AAAA,IACrD,iCAAiC,OAAO,MAAM,UAAU;AAAA,IACxD,qBAAqB,MAAM;AAAA;AAAA;AAAA,IAG3B,iBAAiB,MAAM,cAAc,OAAO,MAAM,MAAM;AAAA,IACxD,eAAe,MAAM,YAAY,OAAO,MAAM,MAAM;AAAA,EACtD;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/theme-contract/index.ts"],"sourcesContent":["/**\n * Exportable theme-token contract checker — the incident guard for the\n * invisible-popover class of bugs.\n *\n * The failure mode (tax-agent's transparent model dropdown; the whole\n * `bg-surface-container-*` family): a consumer app ships a component that\n * references a theme token — either as `var(--popover)` or as a Tailwind class\n * like `bg-surface-container-high` that the agent-app preset maps to\n * `hsl(var(--popover))` — but the app's OWN build never emits that custom\n * property (it forgot `import '@tangle-network/agent-app/styles'`, or dropped a\n * token in its local tokens.css). CSS resolves the missing var to nothing, the\n * surface paints transparent, and NOTHING errors. It ships invisible.\n *\n * `tests/theme/tokens-contract.test.ts` guards agent-app's OWN components. This\n * module lifts that walking logic into a function every CONSUMER app can run\n * against ITS OWN source in CI, comparing references to the tokens.css agent-app\n * ships plus any extra CSS the app defines.\n *\n * ── What each check covers (scope is deliberately honest) ────────────────────\n *\n * 1. var(--…) check — COMPLETE. Every `var(--name)` literal in the scanned\n * source (inline styles, `bg-[var(--name)]` arbitrary Tailwind values, CSS\n * template strings) is matched and compared against the defined token set.\n * This is exact: a `var(--x)` reference is unambiguous. It is a raw-text\n * scan (no AST), so a `var(--x)` written inside a comment or string literal\n * counts too — deliberate: it keeps the single-source logic identical to the\n * agent-app self-test, and a dangling `var(--x)` in a comment is a smell\n * worth surfacing. Suppress a deliberate one with `allowlist`.\n *\n * 2. Tailwind-utility check — INTENTIONALLY PARTIAL. Bare classes like\n * `bg-card` carry no `var(--)` and so are invisible to check 1; Tailwind\n * resolves them to `hsl(var(--card))` at build via the preset. Fully\n * resolving arbitrary Tailwind config is out of scope (it would mean\n * re-implementing Tailwind). Instead we check the SPECIFIC known-dangerous\n * families that have actually shipped invisible: the MD3 surface ladder\n * (`surface-container` / `-high` / `-highest`) and the `card` / `popover`\n * elevation pairs — exactly the utilities the agent-app tailwind-preset\n * registers onto elevation tokens (see src/theme/tailwind-preset.ts, the\n * source of truth for this mapping). The canvas/sequence aliases\n * (`--bg-input`, `--text-primary`, …) are consumed as `bg-[var(--…)]`\n * arbitrary values and so are already covered fully by check 1 — they need\n * no entry here.\n *\n * Node-only (reads the filesystem) → this lives in the `./theme-contract`\n * subpath, NOT `./theme`, which must stay browser-clean (it's in the\n * browser-safe manifest test).\n */\n\nimport { existsSync, readFileSync } from 'node:fs'\nimport { relative } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { walkSources } from '../legibility/walk-sources'\n\n/** Define options for scanning source directories and CSS token files in a theme contract */\nexport interface ThemeContractOptions {\n /** Consumer source directories to scan for token references (recursively). */\n srcDirs: string[]\n /**\n * Path to the base tokens.css whose `--name:` definitions are the ground\n * truth. Defaults to the tokens.css agent-app ships (`./styles`) — the set a\n * consumer gets from `import '@tangle-network/agent-app/styles'`.\n */\n tokensCss?: string\n /**\n * Additional CSS files whose `--name:` definitions also count as defined —\n * the app's own overrides/extensions layered on top of the base tokens.\n */\n extraTokensCss?: string[]\n /**\n * Token names (e.g. `--my-app-accent`) to treat as always-defined, suppressing\n * them from the missing list. For app-specific vars defined outside any CSS\n * the checker can see (injected at runtime, from a third-party stylesheet, …).\n */\n allowlist?: string[]\n}\n\n/** Describe a missing theme contract variable and where it was referenced */\nexport interface ThemeContractMiss {\n /** The undefined custom property, e.g. `--popover`. */\n varName: string\n /**\n * Where it was referenced: `path/to/file.tsx`, or\n * `path/to/file.tsx (via bg-surface-container-high)` when the reference is a\n * Tailwind utility that resolves to the token rather than a literal var().\n */\n referencedIn: string\n}\n\n/** Describe the result of validating a theme contract including success status and missing items */\nexport interface ThemeContractResult {\n ok: boolean\n missing: ThemeContractMiss[]\n}\n\n/**\n * Known-dangerous Tailwind utility families and the elevation token each\n * resolves to, mirroring src/theme/tailwind-preset.ts. Ordered longest-suffix\n * first so `surface-container-highest` is matched before `surface-container`.\n * The negative look-around in {@link buildUtilityRe} makes ordering belt-and-\n * suspenders rather than load-bearing.\n */\nconst DANGEROUS_UTILITIES: ReadonlyArray<{ suffix: string; varName: string }> = [\n { suffix: 'surface-container-highest', varName: '--secondary' },\n { suffix: 'surface-container-high', varName: '--popover' },\n { suffix: 'surface-container', varName: '--card' },\n { suffix: 'card-foreground', varName: '--card-foreground' },\n { suffix: 'popover-foreground', varName: '--popover-foreground' },\n { suffix: 'card', varName: '--card' },\n { suffix: 'popover', varName: '--popover' },\n]\n\n/** Tailwind color-utility prefixes that can carry a background/text/border color. */\nconst UTILITY_PREFIXES = 'bg|text|border|ring|fill|stroke'\n\n/**\n * Match a whole utility class for `suffix`, tolerant of variants (`hover:`,\n * `dark:`) and opacity (`/95`) but not of longer siblings: the trailing\n * `(?![\\w-])` stops `bg-surface-container` from matching inside\n * `bg-surface-container-high`, and `bg-card` from matching inside\n * `bg-card-foreground`.\n */\nfunction buildUtilityRe(suffix: string): RegExp {\n return new RegExp(`(?<![\\\\w-])(?:${UTILITY_PREFIXES})-${suffix}(?![\\\\w-])`, 'g')\n}\n\n/**\n * Every `--name:` DEFINITION across the given CSS files. A definition is\n * `--name:` at the start of a (trimmed) line; RHS references like\n * `hsl(var(--card))` are mid-line and are never counted as definitions.\n */\nfunction definedVars(cssFiles: string[]): Set<string> {\n const defs = new Set<string>()\n for (const file of cssFiles) {\n let css: string\n try {\n css = readFileSync(file, 'utf8')\n } catch {\n continue\n }\n for (const m of css.matchAll(/^\\s*(--[a-z0-9-]+)\\s*:/gim)) if (m[1]) defs.add(m[1])\n }\n return defs\n}\n\n/**\n * Default tokens.css: the one agent-app ships as `./styles`. Resolved relative\n * to this module's URL, but tolerant of where the bundler lands the running\n * code — tsup code-splits shared logic into a chunk at the dist ROOT, so the\n * tokens.css sits one directory DIFFERENTLY depending on layout:\n * - source (src/theme-contract/index.ts) → ../theme/tokens.css (src/theme)\n * - split chunk (dist/contract-*.js) → ./theme/tokens.css (dist/theme)\n * - unsplit entry (dist/theme-contract/index.js) → ../theme/tokens.css\n * Probe both and return the one that exists; fall back to the first for a\n * sensible error path if neither is present.\n */\nfunction defaultTokensCss(): string {\n const candidates = ['../theme/tokens.css', './theme/tokens.css'].map((rel) =>\n fileURLToPath(new URL(rel, import.meta.url)),\n )\n return candidates.find((p) => existsSync(p)) ?? candidates[0]!\n}\n\n/**\n * Check that every theme token a consumer's source references is actually\n * defined in the CSS that consumer ships. Returns the full missing set; the\n * caller decides how to fail (the bin exits non-zero on any miss).\n */\nexport function checkThemeContract(opts: ThemeContractOptions): ThemeContractResult {\n const tokensCss = opts.tokensCss ?? defaultTokensCss()\n const defined = definedVars([tokensCss, ...(opts.extraTokensCss ?? [])])\n const allow = new Set(opts.allowlist ?? [])\n const isDefined = (name: string) => defined.has(name) || allow.has(name)\n\n const files = opts.srcDirs.flatMap((dir) => walkSources(dir, ['.d.ts']))\n const utilityMatchers = DANGEROUS_UTILITIES.map((u) => ({ ...u, re: buildUtilityRe(u.suffix) }))\n\n // Dedupe by varName (literal check) and by varName+utility (utility check),\n // keeping the FIRST referencing file — enough to locate the offender without\n // drowning the report when one token is referenced across many files.\n const seenVar = new Map<string, string>()\n const seenUtility = new Map<string, string>()\n\n for (const file of files) {\n let text: string\n try {\n text = readFileSync(file, 'utf8')\n } catch {\n continue\n }\n const where = displayPath(file)\n\n // Check 1 — literal var(--…) references.\n for (const m of text.matchAll(/var\\(\\s*(--[a-z0-9-]+)/gi)) {\n const name = m[1]\n if (!name || isDefined(name) || seenVar.has(name)) continue\n seenVar.set(name, where)\n }\n\n // Check 2 — known-dangerous Tailwind utility classes.\n for (const u of utilityMatchers) {\n if (isDefined(u.varName)) continue\n const key = `${u.varName}::${u.suffix}`\n if (seenUtility.has(key)) continue\n u.re.lastIndex = 0\n if (u.re.test(text)) seenUtility.set(key, `${where} (via ${firstUtilityHit(text, u.suffix)})`)\n }\n }\n\n const missing: ThemeContractMiss[] = [\n ...[...seenVar].map(([varName, referencedIn]) => ({ varName, referencedIn })),\n ...[...seenUtility].map(([key, referencedIn]) => ({ varName: key.split('::')[0]!, referencedIn })),\n ]\n return { ok: missing.length === 0, missing }\n}\n\n/** The literal utility class (with prefix) first seen in `text` for `suffix`, for the report. */\nfunction firstUtilityHit(text: string, suffix: string): string {\n const m = buildUtilityRe(suffix).exec(text)\n return m?.[0] ?? `<utility>-${suffix}`\n}\n\n/** Path relative to cwd when it stays inside it, else the path as given — for readable reports. */\nfunction displayPath(file: string): string {\n const rel = relative(process.cwd(), file)\n return rel && !rel.startsWith('..') ? rel : file\n}\n"],"mappings":";;;;;AAgDA,SAAS,YAAY,oBAAoB;AACzC,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAmD9B,IAAM,sBAA0E;AAAA,E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