@calliopelabs/ui 0.12.0 → 0.14.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 (80) hide show
  1. package/README.md +68 -3
  2. package/dist/agent/AgentChat.d.ts +56 -0
  3. package/dist/agent/AgentChat.js +76 -0
  4. package/dist/agent/AgentLauncher.d.ts +25 -0
  5. package/dist/agent/AgentLauncher.js +25 -0
  6. package/dist/agent/AgentProvider.d.ts +82 -0
  7. package/dist/agent/AgentProvider.js +176 -0
  8. package/dist/agent/CalliopeAgent.d.ts +43 -0
  9. package/dist/agent/CalliopeAgent.js +111 -0
  10. package/dist/agent/controller.d.ts +148 -0
  11. package/dist/agent/controller.js +463 -0
  12. package/dist/agent/copilotkit/CopilotKitAgentProvider.d.ts +41 -0
  13. package/dist/agent/copilotkit/CopilotKitAgentProvider.js +145 -0
  14. package/dist/agent/copilotkit/index.d.ts +6 -0
  15. package/dist/agent/copilotkit/index.js +6 -0
  16. package/dist/agent/engine.d.ts +41 -0
  17. package/dist/agent/engine.js +93 -0
  18. package/dist/agent/index.d.ts +15 -0
  19. package/dist/agent/index.js +15 -0
  20. package/dist/agent/mock.d.ts +34 -0
  21. package/dist/agent/mock.js +112 -0
  22. package/dist/agent/surface.d.ts +30 -0
  23. package/dist/agent/surface.js +90 -0
  24. package/dist/agent/tool.d.ts +98 -0
  25. package/dist/agent/tool.js +81 -0
  26. package/dist/appearance/brands.d.ts +14 -12
  27. package/dist/appearance/brands.js +18 -51
  28. package/dist/chat/AgentProgress.d.ts +19 -0
  29. package/dist/chat/AgentProgress.js +34 -0
  30. package/dist/chat/Composer.d.ts +31 -0
  31. package/dist/chat/Composer.js +44 -0
  32. package/dist/chat/MessageBubble.d.ts +23 -0
  33. package/dist/chat/MessageBubble.js +26 -0
  34. package/dist/chat/MessageList.d.ts +36 -0
  35. package/dist/chat/MessageList.js +68 -0
  36. package/dist/chat/ModelPicker.d.ts +17 -0
  37. package/dist/chat/ModelPicker.js +13 -0
  38. package/dist/chat/ToolCallCard.d.ts +27 -0
  39. package/dist/chat/ToolCallCard.js +52 -0
  40. package/dist/chat/model.d.ts +123 -0
  41. package/dist/chat/model.js +337 -0
  42. package/dist/chat/patch.d.ts +12 -0
  43. package/dist/chat/patch.js +149 -0
  44. package/dist/chat/useAgUiRun.d.ts +52 -0
  45. package/dist/chat/useAgUiRun.js +137 -0
  46. package/dist/index.d.ts +11 -2
  47. package/dist/index.js +11 -1
  48. package/dist/primitives/Button.d.ts +1 -1
  49. package/dist/provider/messages.d.ts +83 -1
  50. package/dist/provider/messages.js +91 -0
  51. package/dist/theme/mappings/palette.d.ts +52 -0
  52. package/dist/theme/mappings/palette.js +208 -0
  53. package/dist/theme/mappings/render.d.ts +9 -0
  54. package/dist/theme/mappings/render.js +520 -0
  55. package/dist/theme/mappings/targets.d.ts +43 -0
  56. package/dist/theme/mappings/targets.js +222 -0
  57. package/dist/theme/tokens.d.ts +10 -9
  58. package/dist/theme/tokens.generated.d.ts +353 -0
  59. package/dist/theme/tokens.generated.js +357 -0
  60. package/dist/theme/tokens.js +20 -264
  61. package/dist/tokens/README.jupyterlab.md +125 -0
  62. package/dist/tokens/README.md +15 -0
  63. package/dist/tokens/README.native.md +29 -0
  64. package/dist/tokens/README.plain.md +84 -0
  65. package/dist/tokens/README.python.md +33 -0
  66. package/dist/tokens/README.vscode.md +114 -0
  67. package/dist/tokens/jupyterlab.css +1710 -0
  68. package/dist/tokens/plain.css +930 -0
  69. package/dist/tokens/tokens.native.d.ts +85 -0
  70. package/dist/tokens/tokens.native.js +773 -0
  71. package/dist/tokens/tokens.py +1043 -0
  72. package/dist/tokens/vscode.css +1138 -0
  73. package/dist/workflow/canvas/WorkflowCanvas.js +41 -1
  74. package/dist/workflow/definition.d.ts +20 -0
  75. package/dist/workflow/definition.js +44 -0
  76. package/dist/workflow/editor/WorkflowInspector.d.ts +21 -3
  77. package/dist/workflow/editor/WorkflowInspector.js +13 -5
  78. package/dist/workflow/editor/WorkflowWorkspace.d.ts +28 -3
  79. package/dist/workflow/editor/WorkflowWorkspace.js +75 -16
  80. package/package.json +35 -2
@@ -0,0 +1,208 @@
1
+ import { ACCENTS, ACCENT_KEYS, DEFAULT_ACCENT, GROUNDS, GROUND_KEYS, MODE_TOKENS, STATIC_TOKENS, SURFACES, } from "../tokens.js";
2
+ /**
3
+ * The palette a page paints on one ground with one family accent, as
4
+ * concrete colours: what the preset's custom properties compute to on that
5
+ * page with no product brand set. Every token mapping (JupyterLab, VS Code,
6
+ * Python, React Native, plain CSS) is generated from this, and a test holds
7
+ * it to the preset's own cascade.
8
+ *
9
+ * Values are `#rrggbb` or `rgba(r, g, b, a)`. The preset's one colour
10
+ * function, `color-mix(in oklab, var(--primary) N%, transparent)`, is the
11
+ * primary at alpha N% (mixing with transparent only scales alpha), so it is
12
+ * written that way here.
13
+ */
14
+ const STATUS_NAMES = ["success", "warning", "info", "danger"];
15
+ export const COLOR_TOKENS = [
16
+ "background",
17
+ "foreground",
18
+ "card",
19
+ "card-foreground",
20
+ "popover",
21
+ "popover-foreground",
22
+ "primary",
23
+ "primary-foreground",
24
+ "secondary",
25
+ "secondary-foreground",
26
+ "muted",
27
+ "muted-foreground",
28
+ "accent",
29
+ "accent-foreground",
30
+ "destructive",
31
+ "border",
32
+ "input",
33
+ "ring",
34
+ "chart-1",
35
+ "chart-2",
36
+ "chart-3",
37
+ "chart-4",
38
+ "chart-5",
39
+ "sidebar",
40
+ "sidebar-foreground",
41
+ "sidebar-primary",
42
+ "sidebar-primary-foreground",
43
+ "sidebar-accent",
44
+ "sidebar-accent-foreground",
45
+ "sidebar-border",
46
+ "sidebar-ring",
47
+ "sidebar-muted-foreground",
48
+ "surface-0",
49
+ "surface-1",
50
+ "surface-2",
51
+ ...STATUS_NAMES.flatMap((name) => [name, `${name}-fg`, `${name}-bg`, `${name}-border`]),
52
+ ];
53
+ export { ACCENT_KEYS, DEFAULT_ACCENT, GROUNDS, GROUND_KEYS };
54
+ /** The ground `:root` paints when nothing chooses one (the preset's default). */
55
+ export const DEFAULT_GROUND = "black";
56
+ /**
57
+ * The type stacks of the preset (`--font-sans`, `--font-mono`, `--font-head`
58
+ * in preset.css; a test holds them equal). Each names the app's loaded font
59
+ * variable first, then the family, then system fallbacks.
60
+ */
61
+ export const FONTS = {
62
+ sans: 'var(--font-plex-sans, "IBM Plex Sans"), system-ui, sans-serif',
63
+ mono: 'var(--font-plex-mono, "IBM Plex Mono"), ui-monospace, SFMono-Regular, Menlo, monospace',
64
+ head: 'var(--font-dm-sans, "DM Sans"), system-ui, sans-serif',
65
+ };
66
+ /** The family a stack names, for targets that take one font name (React Native). */
67
+ export function fontFamily(stack) {
68
+ const name = /"([^"]+)"/.exec(stack)?.[1];
69
+ if (!name)
70
+ throw new Error(`no family in ${stack}`);
71
+ return name;
72
+ }
73
+ /** `--radius` in px, and the motion durations in ms, as numbers. */
74
+ export function staticNumbers() {
75
+ const n = (value, unit) => {
76
+ if (!value?.endsWith(unit))
77
+ throw new Error(`expected ${unit}: ${value}`);
78
+ return Number(value.slice(0, -unit.length));
79
+ };
80
+ return {
81
+ radius: n(STATIC_TOKENS.radius, "px"),
82
+ motion: {
83
+ fast: n(STATIC_TOKENS["motion-fast"], "ms"),
84
+ base: n(STATIC_TOKENS["motion-base"], "ms"),
85
+ slow: n(STATIC_TOKENS["motion-slow"], "ms"),
86
+ },
87
+ };
88
+ }
89
+ /** Parses `#rrggbb` or `rgba(r, g, b, a)`; anything else is a token this module does not know. */
90
+ export function parseColor(value) {
91
+ const hex = /^#([0-9a-f]{6})$/i.exec(value);
92
+ if (hex) {
93
+ const n = parseInt(hex[1] ?? "", 16);
94
+ return { r: (n >> 16) & 255, g: (n >> 8) & 255, b: n & 255, a: 1 };
95
+ }
96
+ const fn = /^rgba\((\d+), (\d+), (\d+), ([0-9.]+)\)$/.exec(value);
97
+ if (fn)
98
+ return { r: Number(fn[1]), g: Number(fn[2]), b: Number(fn[3]), a: Number(fn[4]) };
99
+ throw new Error(`unsupported colour ${value}`);
100
+ }
101
+ const rgbaString = ({ r, g, b, a }) => `rgba(${r}, ${g}, ${b}, ${a})`;
102
+ /**
103
+ * A translucent token laid on its surface, for targets with no alpha
104
+ * (a terminal, Tk): `sidebar-*` tokens on the sidebar, the rest on the
105
+ * background. Opaque tokens come back as they are.
106
+ */
107
+ export function flatten(palette, token) {
108
+ const top = parseColor(palette[token]);
109
+ if (top.a === 1)
110
+ return top;
111
+ const base = parseColor(palette[token.startsWith("sidebar-") ? "sidebar" : "background"]);
112
+ if (base.a !== 1)
113
+ throw new Error(`${token} sits on a translucent surface`);
114
+ const mix = (t, b) => Math.round(t * top.a + b * (1 - top.a));
115
+ return { r: mix(top.r, base.r), g: mix(top.g, base.g), b: mix(top.b, base.b), a: 1 };
116
+ }
117
+ const PRIMARY_TINT = /^color-mix\(in oklab, var\(--primary\) (\d+)%, transparent\)$/;
118
+ /** A surface value: a colour as it is, or the preset's primary tint at its alpha. */
119
+ function surface(value, primary) {
120
+ const tint = PRIMARY_TINT.exec(value);
121
+ if (tint)
122
+ return rgbaString({ ...parseColor(primary), a: Number(tint[1]) / 100 });
123
+ parseColor(value);
124
+ return value;
125
+ }
126
+ /** The concrete palette of one ground with one family accent, with no product brand. */
127
+ export function resolvePalette(ground, accent = DEFAULT_ACCENT) {
128
+ const { mode } = GROUNDS[ground];
129
+ const s = SURFACES[ground];
130
+ const m = MODE_TOKENS[mode];
131
+ const spec = ACCENTS[accent];
132
+ const primary = mode === "dark" ? spec.dark : spec.light;
133
+ const onPrimary = mode === "dark" ? spec.onDark : spec.onLight;
134
+ const chart = { ...m.chart, ...spec.chart?.[mode] };
135
+ const status = Object.fromEntries(STATUS_NAMES.flatMap((name) => {
136
+ const t = m.status[name];
137
+ return [
138
+ [name, t.base],
139
+ [`${name}-fg`, t.fg],
140
+ [`${name}-bg`, t.bg],
141
+ [`${name}-border`, t.border],
142
+ ];
143
+ }));
144
+ const palette = {
145
+ background: s.background,
146
+ foreground: m.foreground,
147
+ card: s.card,
148
+ "card-foreground": m.foreground,
149
+ popover: s.popover,
150
+ "popover-foreground": m.foreground,
151
+ primary,
152
+ "primary-foreground": onPrimary,
153
+ secondary: s.secondary,
154
+ "secondary-foreground": m.foreground,
155
+ muted: s.muted,
156
+ "muted-foreground": s.mutedForeground,
157
+ accent: s.accent,
158
+ "accent-foreground": m.foreground,
159
+ destructive: m.destructive,
160
+ border: s.border,
161
+ input: s.input,
162
+ ring: primary,
163
+ "chart-1": primary,
164
+ ...chart,
165
+ // With no product brand, a brand sidebar falls back to the ground's card.
166
+ sidebar: s.sidebar === "brand" ? s.card : s.sidebar,
167
+ "sidebar-foreground": m.sidebarForeground,
168
+ "sidebar-primary": primary,
169
+ "sidebar-primary-foreground": onPrimary,
170
+ "sidebar-accent": s.sidebarAccent,
171
+ "sidebar-accent-foreground": m.foreground,
172
+ "sidebar-border": s.sidebarBorder,
173
+ "sidebar-ring": primary,
174
+ "sidebar-muted-foreground": s.mutedForeground,
175
+ "surface-0": s.background,
176
+ "surface-1": s.card,
177
+ "surface-2": s.popover,
178
+ ...status,
179
+ };
180
+ for (const token of COLOR_TOKENS)
181
+ palette[token] = surface(palette[token], primary);
182
+ return palette;
183
+ }
184
+ /** Every ground with every family accent. */
185
+ export function allPalettes() {
186
+ return Object.fromEntries(GROUND_KEYS.map((ground) => [
187
+ ground,
188
+ Object.fromEntries(ACCENT_KEYS.map((accent) => [accent, resolvePalette(ground, accent)])),
189
+ ]));
190
+ }
191
+ /**
192
+ * A target's values split for compact output: per ground, the entries every
193
+ * accent agrees on, and per ground and accent, the entries that move with
194
+ * the accent.
195
+ */
196
+ export function splitByAccent(values) {
197
+ const ground = {};
198
+ const accent = {};
199
+ for (const g of GROUND_KEYS) {
200
+ const each = ACCENT_KEYS.map((a) => [a, values(g, a)]);
201
+ const first = each[0][1];
202
+ const keys = Object.keys(first);
203
+ const moves = new Set(keys.filter((k) => each.some(([, v]) => JSON.stringify(v[k]) !== JSON.stringify(first[k]))));
204
+ ground[g] = Object.fromEntries(keys.filter((k) => !moves.has(k)).map((k) => [k, first[k]]));
205
+ accent[g] = Object.fromEntries(each.map(([a, v]) => [a, Object.fromEntries([...moves].map((k) => [k, v[k]]))]));
206
+ }
207
+ return { ground, accent };
208
+ }
@@ -0,0 +1,9 @@
1
+ export declare function renderJupyterLabCss(): string;
2
+ export declare function renderVsCodeCss(): string;
3
+ export declare function renderPlainCss(): string;
4
+ export declare function renderPython(): string;
5
+ export declare function renderNativeJs(): string;
6
+ export declare function renderNativeDts(): string;
7
+ export declare function renderReadmes(): Record<string, string>;
8
+ /** Every generated file under src/tokens/, by file name. */
9
+ export declare function renderTokenFiles(): Record<string, string>;