@runtypelabs/persona 1.47.0 → 2.0.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 (73) hide show
  1. package/README.md +140 -8
  2. package/dist/index.cjs +90 -39
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +1093 -25
  5. package/dist/index.d.ts +1093 -25
  6. package/dist/index.global.js +111 -60
  7. package/dist/index.global.js.map +1 -1
  8. package/dist/index.js +90 -39
  9. package/dist/index.js.map +1 -1
  10. package/dist/install.global.js +1 -1
  11. package/dist/install.global.js.map +1 -1
  12. package/dist/widget.css +852 -505
  13. package/package.json +1 -1
  14. package/src/artifacts-session.test.ts +80 -0
  15. package/src/client.test.ts +20 -21
  16. package/src/client.ts +153 -4
  17. package/src/components/approval-bubble.ts +45 -42
  18. package/src/components/artifact-card.ts +91 -0
  19. package/src/components/artifact-pane.ts +501 -0
  20. package/src/components/composer-builder.ts +32 -27
  21. package/src/components/event-stream-view.ts +40 -40
  22. package/src/components/feedback.ts +36 -36
  23. package/src/components/forms.ts +11 -11
  24. package/src/components/header-builder.test.ts +32 -0
  25. package/src/components/header-builder.ts +55 -36
  26. package/src/components/header-layouts.ts +58 -125
  27. package/src/components/launcher.ts +36 -21
  28. package/src/components/message-bubble.ts +92 -65
  29. package/src/components/messages.ts +2 -2
  30. package/src/components/panel.ts +42 -11
  31. package/src/components/reasoning-bubble.ts +23 -23
  32. package/src/components/registry.ts +4 -0
  33. package/src/components/suggestions.ts +1 -1
  34. package/src/components/tool-bubble.ts +32 -32
  35. package/src/defaults.ts +30 -4
  36. package/src/index.ts +80 -2
  37. package/src/install.ts +22 -0
  38. package/src/plugins/types.ts +23 -0
  39. package/src/postprocessors.ts +2 -2
  40. package/src/runtime/host-layout.ts +174 -0
  41. package/src/runtime/init.test.ts +236 -0
  42. package/src/runtime/init.ts +114 -55
  43. package/src/session.ts +173 -7
  44. package/src/styles/tailwind.css +1 -1
  45. package/src/styles/widget.css +852 -505
  46. package/src/types/theme.ts +354 -0
  47. package/src/types.ts +348 -16
  48. package/src/ui.docked.test.ts +104 -0
  49. package/src/ui.ts +1093 -244
  50. package/src/utils/artifact-gate.test.ts +255 -0
  51. package/src/utils/artifact-gate.ts +142 -0
  52. package/src/utils/artifact-resize.test.ts +64 -0
  53. package/src/utils/artifact-resize.ts +67 -0
  54. package/src/utils/attachment-manager.ts +10 -10
  55. package/src/utils/code-generators.test.ts +52 -0
  56. package/src/utils/code-generators.ts +40 -36
  57. package/src/utils/dock.ts +17 -0
  58. package/src/utils/dom-context.test.ts +504 -0
  59. package/src/utils/dom-context.ts +896 -0
  60. package/src/utils/dom.ts +12 -1
  61. package/src/utils/message-fingerprint.test.ts +187 -0
  62. package/src/utils/message-fingerprint.ts +105 -0
  63. package/src/utils/migration.ts +179 -0
  64. package/src/utils/morph.ts +1 -1
  65. package/src/utils/plugins.ts +175 -0
  66. package/src/utils/positioning.ts +4 -4
  67. package/src/utils/theme.test.ts +125 -0
  68. package/src/utils/theme.ts +216 -60
  69. package/src/utils/tokens.ts +682 -0
  70. package/src/voice/audio-playback-manager.ts +187 -0
  71. package/src/voice/runtype-voice-provider.ts +305 -69
  72. package/src/voice/voice-activity-detector.ts +90 -0
  73. package/src/voice/voice.test.ts +6 -5
@@ -0,0 +1,354 @@
1
+ export type TokenType = 'color' | 'spacing' | 'typography' | 'shadow' | 'border' | 'radius';
2
+
3
+ export type TokenReference<_T extends TokenType = TokenType> = string;
4
+
5
+ export interface ColorShade {
6
+ 50?: string;
7
+ 100?: string;
8
+ 200?: string;
9
+ 300?: string;
10
+ 400?: string;
11
+ 500?: string;
12
+ 600?: string;
13
+ 700?: string;
14
+ 800?: string;
15
+ 900?: string;
16
+ 950?: string;
17
+ [key: string]: string | undefined;
18
+ }
19
+
20
+ export interface ColorPalette {
21
+ gray: ColorShade;
22
+ primary: ColorShade;
23
+ secondary: ColorShade;
24
+ accent: ColorShade;
25
+ success: ColorShade;
26
+ warning: ColorShade;
27
+ error: ColorShade;
28
+ [key: string]: ColorShade;
29
+ }
30
+
31
+ export interface SpacingScale {
32
+ 0: string;
33
+ 1: string;
34
+ 2: string;
35
+ 3: string;
36
+ 4: string;
37
+ 5: string;
38
+ 6: string;
39
+ 8: string;
40
+ 10: string;
41
+ 12: string;
42
+ 16: string;
43
+ 20: string;
44
+ 24: string;
45
+ 32: string;
46
+ 40: string;
47
+ 48: string;
48
+ 56: string;
49
+ 64: string;
50
+ [key: string]: string;
51
+ }
52
+
53
+ export interface ShadowScale {
54
+ none: string;
55
+ sm: string;
56
+ md: string;
57
+ lg: string;
58
+ xl: string;
59
+ '2xl': string;
60
+ [key: string]: string;
61
+ }
62
+
63
+ export interface BorderScale {
64
+ none: string;
65
+ sm: string;
66
+ md: string;
67
+ lg: string;
68
+ [key: string]: string;
69
+ }
70
+
71
+ export interface RadiusScale {
72
+ none: string;
73
+ sm: string;
74
+ md: string;
75
+ lg: string;
76
+ xl: string;
77
+ full: string;
78
+ [key: string]: string;
79
+ }
80
+
81
+ export interface TypographyScale {
82
+ fontFamily: {
83
+ sans: string;
84
+ serif: string;
85
+ mono: string;
86
+ };
87
+ fontSize: {
88
+ xs: string;
89
+ sm: string;
90
+ base: string;
91
+ lg: string;
92
+ xl: string;
93
+ '2xl': string;
94
+ '3xl': string;
95
+ '4xl': string;
96
+ };
97
+ fontWeight: {
98
+ normal: string;
99
+ medium: string;
100
+ semibold: string;
101
+ bold: string;
102
+ };
103
+ lineHeight: {
104
+ tight: string;
105
+ normal: string;
106
+ relaxed: string;
107
+ };
108
+ }
109
+
110
+ export interface SemanticColors {
111
+ primary: TokenReference<'color'>;
112
+ secondary: TokenReference<'color'>;
113
+ accent: TokenReference<'color'>;
114
+ surface: TokenReference<'color'>;
115
+ background: TokenReference<'color'>;
116
+ container: TokenReference<'color'>;
117
+ text: TokenReference<'color'>;
118
+ textMuted: TokenReference<'color'>;
119
+ textInverse: TokenReference<'color'>;
120
+ border: TokenReference<'color'>;
121
+ divider: TokenReference<'color'>;
122
+ interactive: {
123
+ default: TokenReference<'color'>;
124
+ hover: TokenReference<'color'>;
125
+ focus: TokenReference<'color'>;
126
+ active: TokenReference<'color'>;
127
+ disabled: TokenReference<'color'>;
128
+ };
129
+ feedback: {
130
+ success: TokenReference<'color'>;
131
+ warning: TokenReference<'color'>;
132
+ error: TokenReference<'color'>;
133
+ info: TokenReference<'color'>;
134
+ };
135
+ }
136
+
137
+ export interface SemanticSpacing {
138
+ xs: TokenReference<'spacing'>;
139
+ sm: TokenReference<'spacing'>;
140
+ md: TokenReference<'spacing'>;
141
+ lg: TokenReference<'spacing'>;
142
+ xl: TokenReference<'spacing'>;
143
+ '2xl': TokenReference<'spacing'>;
144
+ }
145
+
146
+ export interface SemanticTypography {
147
+ fontFamily: TokenReference<'typography'>;
148
+ fontSize: TokenReference<'typography'>;
149
+ fontWeight: TokenReference<'typography'>;
150
+ lineHeight: TokenReference<'typography'>;
151
+ }
152
+
153
+ export interface SemanticTokens {
154
+ colors: SemanticColors;
155
+ spacing: SemanticSpacing;
156
+ typography: SemanticTypography;
157
+ }
158
+
159
+ export interface ComponentTokenSet {
160
+ background?: TokenReference<'color'>;
161
+ foreground?: TokenReference<'color'>;
162
+ border?: TokenReference<'color'>;
163
+ borderRadius?: TokenReference<'radius'>;
164
+ padding?: TokenReference<'spacing'>;
165
+ margin?: TokenReference<'spacing'>;
166
+ shadow?: TokenReference<'shadow'>;
167
+ opacity?: number;
168
+ }
169
+
170
+ export interface ButtonTokens extends ComponentTokenSet {
171
+ primary: ComponentTokenSet;
172
+ secondary: ComponentTokenSet;
173
+ ghost: ComponentTokenSet;
174
+ }
175
+
176
+ export interface InputTokens extends ComponentTokenSet {
177
+ background: TokenReference<'color'>;
178
+ placeholder: TokenReference<'color'>;
179
+ focus: {
180
+ border: TokenReference<'color'>;
181
+ ring: TokenReference<'color'>;
182
+ };
183
+ }
184
+
185
+ export interface LauncherTokens extends ComponentTokenSet {
186
+ size: string;
187
+ iconSize: string;
188
+ shadow: TokenReference<'shadow'>;
189
+ }
190
+
191
+ export interface PanelTokens extends ComponentTokenSet {
192
+ width: string;
193
+ maxWidth: string;
194
+ height: string;
195
+ maxHeight: string;
196
+ }
197
+
198
+ export interface HeaderTokens extends ComponentTokenSet {
199
+ background: TokenReference<'color'>;
200
+ border: TokenReference<'color'>;
201
+ borderRadius: TokenReference<'radius'>;
202
+ }
203
+
204
+ export interface MessageTokens {
205
+ user: {
206
+ background: TokenReference<'color'>;
207
+ text: TokenReference<'color'>;
208
+ borderRadius: TokenReference<'radius'>;
209
+ };
210
+ assistant: {
211
+ background: TokenReference<'color'>;
212
+ text: TokenReference<'color'>;
213
+ borderRadius: TokenReference<'radius'>;
214
+ /** Assistant bubble border color (CSS color). */
215
+ border?: TokenReference<'color'>;
216
+ /** Assistant bubble box-shadow (token ref or raw CSS, e.g. `none`). */
217
+ shadow?: string;
218
+ };
219
+ }
220
+
221
+ export interface MarkdownTokens {
222
+ inlineCode: {
223
+ background: TokenReference<'color'>;
224
+ foreground: TokenReference<'color'>;
225
+ };
226
+ /** Foreground for `<a>` in rendered markdown (assistant bubbles + artifact pane). */
227
+ link?: {
228
+ foreground: TokenReference<'color'>;
229
+ };
230
+ /**
231
+ * Body font for rendered markdown blocks (artifact pane + markdown bubbles).
232
+ * Use a raw CSS `font-family` value, e.g. `Georgia, serif`.
233
+ */
234
+ prose?: {
235
+ fontFamily?: string;
236
+ };
237
+ /** Optional heading scale overrides (raw CSS or resolvable token paths). */
238
+ heading?: {
239
+ h1?: {
240
+ fontSize?: string;
241
+ fontWeight?: string;
242
+ };
243
+ h2?: {
244
+ fontSize?: string;
245
+ fontWeight?: string;
246
+ };
247
+ };
248
+ }
249
+
250
+ export interface VoiceTokens {
251
+ recording: {
252
+ indicator: TokenReference<'color'>;
253
+ background: TokenReference<'color'>;
254
+ border: TokenReference<'color'>;
255
+ };
256
+ processing: {
257
+ icon: TokenReference<'color'>;
258
+ background: TokenReference<'color'>;
259
+ };
260
+ speaking: {
261
+ icon: TokenReference<'color'>;
262
+ };
263
+ }
264
+
265
+ export interface ApprovalTokens {
266
+ requested: {
267
+ background: TokenReference<'color'>;
268
+ border: TokenReference<'color'>;
269
+ text: TokenReference<'color'>;
270
+ };
271
+ approve: ComponentTokenSet;
272
+ deny: ComponentTokenSet;
273
+ }
274
+
275
+ export interface AttachmentTokens {
276
+ image: {
277
+ background: TokenReference<'color'>;
278
+ border: TokenReference<'color'>;
279
+ };
280
+ }
281
+
282
+ export interface ComponentTokens {
283
+ button: ButtonTokens;
284
+ input: InputTokens;
285
+ launcher: LauncherTokens;
286
+ panel: PanelTokens;
287
+ header: HeaderTokens;
288
+ message: MessageTokens;
289
+ /** Markdown surfaces (chat + artifact pane). */
290
+ markdown?: MarkdownTokens;
291
+ voice: VoiceTokens;
292
+ approval: ApprovalTokens;
293
+ attachment: AttachmentTokens;
294
+ }
295
+
296
+ export interface PaletteExtras {
297
+ transitions?: Record<string, string>;
298
+ easings?: Record<string, string>;
299
+ }
300
+
301
+ export interface PersonaThemeBase {
302
+ palette: {
303
+ colors: ColorPalette;
304
+ spacing: SpacingScale;
305
+ typography: TypographyScale;
306
+ shadows: ShadowScale;
307
+ borders: BorderScale;
308
+ radius: RadiusScale;
309
+ } & PaletteExtras;
310
+ }
311
+
312
+ export interface PersonaThemeSemantic {
313
+ semantic: SemanticTokens;
314
+ }
315
+
316
+ export interface PersonaThemeComponents {
317
+ components: ComponentTokens;
318
+ }
319
+
320
+ export type PersonaTheme = PersonaThemeBase &
321
+ PersonaThemeSemantic &
322
+ PersonaThemeComponents;
323
+
324
+ export interface ResolvedToken {
325
+ path: string;
326
+ value: string;
327
+ type: TokenType;
328
+ }
329
+
330
+ export interface ThemeValidationError {
331
+ path: string;
332
+ message: string;
333
+ severity: 'error' | 'warning';
334
+ }
335
+
336
+ export interface ThemeValidationResult {
337
+ valid: boolean;
338
+ errors: ThemeValidationError[];
339
+ warnings: ThemeValidationError[];
340
+ }
341
+
342
+ export interface PersonaThemePlugin {
343
+ name: string;
344
+ version: string;
345
+ transform(theme: PersonaTheme): PersonaTheme;
346
+ cssVariables?: Record<string, string>;
347
+ afterResolve?(resolved: Record<string, string>): Record<string, string>;
348
+ }
349
+
350
+ export interface CreateThemeOptions {
351
+ plugins?: PersonaThemePlugin[];
352
+ validate?: boolean;
353
+ extend?: PersonaTheme;
354
+ }