@runtypelabs/persona 4.6.1 → 4.8.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 (120) hide show
  1. package/dist/animations/glyph-cycle.cjs +2 -2
  2. package/dist/animations/glyph-cycle.d.cts +1 -1
  3. package/dist/animations/glyph-cycle.d.ts +1 -1
  4. package/dist/animations/glyph-cycle.js +2 -2
  5. package/dist/animations/{types-CSmiKRVa.d.cts → types-BsZtXPKK.d.cts} +43 -3
  6. package/dist/animations/{types-CSmiKRVa.d.ts → types-BsZtXPKK.d.ts} +43 -3
  7. package/dist/animations/wipe.cjs +2 -2
  8. package/dist/animations/wipe.d.cts +1 -1
  9. package/dist/animations/wipe.d.ts +1 -1
  10. package/dist/chunk-5EIIHQLQ.js +1 -0
  11. package/dist/codegen.cjs +12 -12
  12. package/dist/codegen.js +14 -14
  13. package/dist/index.cjs +91 -68
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.cts +918 -174
  16. package/dist/index.d.ts +918 -174
  17. package/dist/index.global.js +81 -57
  18. package/dist/index.global.js.map +1 -1
  19. package/dist/index.js +89 -66
  20. package/dist/index.js.map +1 -1
  21. package/dist/install.global.js +1 -1
  22. package/dist/install.global.js.map +1 -1
  23. package/dist/launcher.global.js +3 -2
  24. package/dist/launcher.global.js.map +1 -1
  25. package/dist/markdown-parsers.js +24 -24
  26. package/dist/plugin-kit.cjs +1 -1
  27. package/dist/plugin-kit.js +1 -1
  28. package/dist/runtype-tts-entry-UJAEF7NZ.js +1 -0
  29. package/dist/runtype-tts.js +1 -1
  30. package/dist/session-reconnect-JKIJBHS5.js +1 -0
  31. package/dist/smart-dom-reader.cjs +17 -17
  32. package/dist/smart-dom-reader.d.cts +753 -15
  33. package/dist/smart-dom-reader.d.ts +753 -15
  34. package/dist/smart-dom-reader.js +17 -17
  35. package/dist/testing.cjs +3 -3
  36. package/dist/testing.js +3 -3
  37. package/dist/theme-editor-preview.cjs +81 -58
  38. package/dist/theme-editor-preview.d.cts +761 -15
  39. package/dist/theme-editor-preview.d.ts +761 -15
  40. package/dist/theme-editor-preview.js +81 -58
  41. package/dist/theme-editor.cjs +6 -6
  42. package/dist/theme-editor.d.cts +753 -15
  43. package/dist/theme-editor.d.ts +753 -15
  44. package/dist/theme-editor.js +10 -10
  45. package/dist/theme-reference.cjs +1 -1
  46. package/dist/theme-reference.d.cts +74 -0
  47. package/dist/theme-reference.d.ts +74 -0
  48. package/dist/theme-reference.js +1 -1
  49. package/dist/voice-worklet-player.cjs +2 -2
  50. package/dist/voice-worklet-player.js +2 -2
  51. package/dist/webmcp-polyfill.js +2 -2
  52. package/dist/widget.css +1 -1
  53. package/package.json +2 -3
  54. package/src/artifacts-session.test.ts +178 -0
  55. package/src/client.test.ts +500 -1
  56. package/src/client.ts +285 -93
  57. package/src/components/artifact-card.test.ts +333 -0
  58. package/src/components/artifact-card.ts +75 -28
  59. package/src/components/artifact-inline.test.ts +1328 -0
  60. package/src/components/artifact-inline.ts +920 -0
  61. package/src/components/artifact-pane.test.ts +1042 -0
  62. package/src/components/artifact-pane.ts +440 -131
  63. package/src/components/artifact-preview.test.ts +1155 -0
  64. package/src/components/artifact-preview.ts +994 -0
  65. package/src/components/pill-composer-builder.test.ts +6 -2
  66. package/src/components/pill-composer-builder.ts +6 -6
  67. package/src/components/reasoning-bubble.ts +1 -13
  68. package/src/components/registry.ts +38 -3
  69. package/src/components/tool-bubble.ts +1 -13
  70. package/src/defaults.ts +1 -0
  71. package/src/generated/runtype-openapi-contract.ts +55 -3
  72. package/src/index-core.ts +20 -1
  73. package/src/index.ts +8 -0
  74. package/src/markdown-parsers-loader.test.ts +158 -0
  75. package/src/markdown-parsers-loader.ts +74 -9
  76. package/src/runtime/host-layout.test.ts +163 -0
  77. package/src/runtime/host-layout.ts +110 -7
  78. package/src/runtime/init.ts +18 -61
  79. package/src/runtime/persist-state.test.ts +118 -0
  80. package/src/session.ts +76 -22
  81. package/src/styles/widget.css +773 -26
  82. package/src/theme-editor/preview.ts +2 -0
  83. package/src/theme-editor/sections.test.ts +26 -1
  84. package/src/theme-editor/sections.ts +10 -2
  85. package/src/theme-reference.ts +2 -2
  86. package/src/tool-call-display-defaults.test.ts +1 -0
  87. package/src/types/theme.ts +77 -0
  88. package/src/types.ts +516 -17
  89. package/src/ui.artifact-pane-gating.test.ts +636 -0
  90. package/src/ui.component-directive.test.ts +104 -0
  91. package/src/ui.composer-bar.test.ts +60 -2
  92. package/src/ui.detached-panel.test.ts +1049 -0
  93. package/src/ui.scroll-additive.test.ts +1 -1
  94. package/src/ui.streaming-coalescing.test.ts +312 -0
  95. package/src/ui.tool-display.test.ts +51 -0
  96. package/src/ui.ts +933 -214
  97. package/src/utils/artifact-custom-actions.ts +128 -0
  98. package/src/utils/artifact-display.test.ts +42 -0
  99. package/src/utils/artifact-display.ts +84 -0
  100. package/src/utils/artifact-file.test.ts +116 -0
  101. package/src/utils/artifact-file.ts +117 -0
  102. package/src/utils/artifact-gate.test.ts +112 -5
  103. package/src/utils/artifact-gate.ts +39 -14
  104. package/src/utils/artifact-loading-status.ts +55 -0
  105. package/src/utils/artifact-status-label.ts +190 -0
  106. package/src/utils/buttons.ts +7 -1
  107. package/src/utils/code-highlight.test.ts +186 -0
  108. package/src/utils/code-highlight.ts +400 -0
  109. package/src/utils/icons.ts +2 -0
  110. package/src/utils/roving-tablist.test.ts +152 -0
  111. package/src/utils/roving-tablist.ts +111 -0
  112. package/src/utils/spinner.ts +45 -0
  113. package/src/utils/theme.test.ts +48 -0
  114. package/src/utils/theme.ts +7 -0
  115. package/src/utils/tokens.ts +91 -0
  116. package/src/utils/tool-loading-animation.test.ts +32 -0
  117. package/src/utils/tool-loading-animation.ts +24 -0
  118. package/dist/chunk-DFBSCFYN.js +0 -1
  119. package/dist/runtype-tts-entry-HFUV2UF7.js +0 -1
  120. package/dist/session-reconnect-U77QFUR7.js +0 -1
@@ -317,6 +317,8 @@ export function createThemePreview(
317
317
  artifactType: 'markdown',
318
318
  title: 'Sample Document',
319
319
  content: '# Sample Artifact\n\nThis is a preview of the artifact sidebar.\n\n## Features\n\n- Markdown rendering\n- Document toolbar\n- Resizable panes',
320
+ // Pane-only preview: showcase the sidebar without a chat block.
321
+ transcript: false,
320
322
  });
321
323
  }
322
324
  }
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it } from "vitest";
2
2
 
3
- import { COMPONENTS_SECTIONS, CONFIGURE_SECTIONS, INTERFACE_ROLES_SECTION } from "./sections";
3
+ import { COMPONENTS_SECTIONS, CONFIGURE_SECTIONS, INTERFACE_ROLES_SECTION, STYLE_SECTIONS } from "./sections";
4
4
  import { ALL_ROLES } from "./role-mappings";
5
5
 
6
6
  describe("theme editor scroll-to-bottom controls", () => {
@@ -44,6 +44,14 @@ describe("theme editor scroll-to-bottom controls", () => {
44
44
  expect(fieldPaths).toContain("theme.components.composer.shadow");
45
45
  });
46
46
 
47
+ it("exposes detached panel token controls", () => {
48
+ const componentPaths = COMPONENTS_SECTIONS.flatMap((section) => section.fields.map((field) => field.path));
49
+ const stylePaths = STYLE_SECTIONS.flatMap((section) => section.fields.map((field) => field.path));
50
+
51
+ expect(componentPaths).toContain("theme.components.panel.inset");
52
+ expect(stylePaths).toContain("theme.components.panel.canvasBackground");
53
+ });
54
+
47
55
  it("adds a scroll-to-bottom interface role mapping", () => {
48
56
  const role = ALL_ROLES.find((entry) => entry.roleId === "role-scroll-to-bottom");
49
57
 
@@ -67,6 +75,23 @@ describe("theme editor scroll-to-bottom controls", () => {
67
75
  expect(debugSection?.fields.some((field) => field.path === "features.toolCallDisplay.activeMinHeight")).toBe(true);
68
76
  expect(debugSection?.fields.some((field) => field.path === "features.toolCallDisplay.expandable")).toBe(true);
69
77
  expect(debugSection?.fields.some((field) => field.path === "features.toolCallDisplay.grouped")).toBe(true);
78
+ expect(debugSection?.fields.some((field) => field.path === "features.toolCallDisplay.groupedMode")).toBe(true);
79
+ });
80
+
81
+ it("exposes product-facing artifact toolbar copy", () => {
82
+ const section = CONFIGURE_SECTIONS.find((entry) => entry.id === "artifacts-customization");
83
+ const paths = section?.fields.map((field) => field.path) ?? [];
84
+
85
+ expect(paths).toContain("features.artifacts.layout.toolbarTitle");
86
+ expect(paths).toContain("features.artifacts.layout.closeButtonLabel");
87
+
88
+ // The deprecated no-op unifiedSplitChrome control is gone (welding is now default).
89
+ expect(paths).not.toContain("features.artifacts.layout.unifiedSplitChrome");
90
+ // Split gap defaults to the welded 0, not the old 0.5rem.
91
+ const splitGap = section?.fields.find(
92
+ (field) => field.path === "features.artifacts.layout.splitGap"
93
+ );
94
+ expect(splitGap?.defaultValue).toBe("0");
70
95
  });
71
96
 
72
97
  it("exposes collapsed reasoning preview controls", () => {
@@ -5,6 +5,10 @@ import {
5
5
  DEFAULT_FLOATING_LAUNCHER_MAX_WIDTH,
6
6
  DEFAULT_FLOATING_LAUNCHER_WIDTH,
7
7
  } from '../defaults';
8
+ import {
9
+ DEFAULT_PANEL_CANVAS_BACKGROUND,
10
+ DEFAULT_PANEL_INSET,
11
+ } from '../utils/tokens';
8
12
  import { COLOR_FAMILIES } from './color-utils';
9
13
  import {
10
14
  ROLE_SURFACES,
@@ -180,6 +184,7 @@ const widgetStyleSectionDef: SectionDef = {
180
184
  { value: 'palette.shadows.lg', label: 'Large' },
181
185
  { value: 'palette.shadows.xl', label: 'Extra Large' },
182
186
  ] },
187
+ { id: 'style-panel-canvas-bg', label: 'Detached Canvas Background', description: 'Fills the region behind a detached panel; defaults to transparent', type: 'token-ref', path: 'theme.components.panel.canvasBackground', defaultValue: DEFAULT_PANEL_CANVAS_BACKGROUND, tokenRef: { tokenType: 'color' } },
183
188
  { id: 'style-msg-user-radius', label: 'User Message Radius', type: 'select', path: 'theme.components.message.user.borderRadius', defaultValue: 'palette.radius.lg', options: [
184
189
  { value: 'palette.radius.none', label: 'None' },
185
190
  { value: 'palette.radius.sm', label: 'Small' },
@@ -295,6 +300,7 @@ const panelLayoutSectionDef: SectionDef = {
295
300
  { value: 'palette.shadows.lg', label: 'Large' },
296
301
  { value: 'palette.shadows.xl', label: 'Extra Large' },
297
302
  ] },
303
+ { id: 'panel-inset', label: 'Detached Inset', description: 'Gap around the card when launcher.detachedPanel is on', type: 'text', path: 'theme.components.panel.inset', defaultValue: DEFAULT_PANEL_INSET },
298
304
  ],
299
305
  };
300
306
 
@@ -834,11 +840,12 @@ const artifactCustomizationSectionDef: SectionDef = {
834
840
  id: 'artifacts-customization', title: 'Artifact Customization', collapsed: true,
835
841
  fields: [
836
842
  { id: 'art-toolbar', label: 'Toolbar Preset', type: 'select', path: 'features.artifacts.layout.toolbarPreset', defaultValue: 'default', options: [{ value: 'default', label: 'Default' }, { value: 'document', label: 'Document' }] },
843
+ { id: 'art-toolbar-title', label: 'Toolbar Title', type: 'text', path: 'features.artifacts.layout.toolbarTitle', defaultValue: 'Artifacts' },
844
+ { id: 'art-close-label', label: 'Close Button Label', type: 'text', path: 'features.artifacts.layout.closeButtonLabel', defaultValue: 'Close' },
837
845
  { id: 'art-pane-width', label: 'Pane Width', description: 'CSS width (e.g. 40%, 28rem)', type: 'text', path: 'features.artifacts.layout.paneWidth', defaultValue: '40%' },
838
846
  { id: 'art-pane-max-width', label: 'Pane Max Width', type: 'text', path: 'features.artifacts.layout.paneMaxWidth', defaultValue: '28rem' },
839
- { id: 'art-split-gap', label: 'Split Gap', type: 'text', path: 'features.artifacts.layout.splitGap', defaultValue: '0.5rem' },
847
+ { id: 'art-split-gap', label: 'Split Gap', type: 'text', path: 'features.artifacts.layout.splitGap', defaultValue: '0' },
840
848
  { id: 'art-pane-bg', label: 'Pane Background', type: 'color', path: 'features.artifacts.layout.paneBackground', defaultValue: '' },
841
- { id: 'art-unified', label: 'Unified Split Chrome', description: 'Wrap chat and artifact in a single container', type: 'toggle', path: 'features.artifacts.layout.unifiedSplitChrome', defaultValue: false },
842
849
  { id: 'art-resizable', label: 'Resizable', description: 'Allow dragging the pane divider', type: 'toggle', path: 'features.artifacts.layout.resizable', defaultValue: false },
843
850
  { id: 'art-expand-panel', label: 'Expand Panel When Open', description: 'Widen the launcher panel to fit artifacts', type: 'toggle', path: 'features.artifacts.layout.expandLauncherPanelWhenOpen', defaultValue: true },
844
851
  ],
@@ -864,6 +871,7 @@ const debugSectionDef: SectionDef = {
864
871
  { id: 'dev-tool-active-min-height', label: 'Tool Active Min Height', description: 'CSS min-height for collapsed active tool rows (e.g. 5rem)', type: 'text', path: 'features.toolCallDisplay.activeMinHeight', defaultValue: '' },
865
872
  { id: 'dev-tool-expandable', label: 'Tool Calls Expandable', description: 'Allow expanding tool call rows to see full details', type: 'toggle', path: 'features.toolCallDisplay.expandable', defaultValue: true },
866
873
  { id: 'dev-tool-grouped', label: 'Group Sequential Tool Calls', description: 'Render consecutive tool rows inside a grouped container', type: 'toggle', path: 'features.toolCallDisplay.grouped', defaultValue: false },
874
+ { id: 'dev-tool-grouped-mode', label: 'Grouped Tool Detail', description: 'Show each tool step or one consolidated summary', type: 'select', path: 'features.toolCallDisplay.groupedMode', defaultValue: 'stack', options: [{ value: 'stack', label: 'Show Steps' }, { value: 'summary', label: 'Summary Only' }] },
867
875
  { id: 'dev-reasoning-expandable', label: 'Reasoning Expandable', description: 'Allow expanding reasoning rows to see full details', type: 'toggle', path: 'features.reasoningDisplay.expandable', defaultValue: true },
868
876
  { id: 'dev-reasoning-active-preview', label: 'Reasoning Preview While Active', description: 'Show a lightweight preview in collapsed active reasoning rows', type: 'toggle', path: 'features.reasoningDisplay.activePreview', defaultValue: false },
869
877
  { id: 'dev-reasoning-preview-lines', label: 'Reasoning Preview Lines', type: 'select', path: 'features.reasoningDisplay.previewMaxLines', defaultValue: 3, options: [{ value: '1', label: '1' }, { value: '2', label: '2' }, { value: '3', label: '3' }, { value: '4', label: '4' }, { value: '5', label: '5' }], formatValue: (v: unknown) => String(v ?? 3), parseValue: (v: unknown) => Number(v) },
@@ -115,7 +115,7 @@ export const THEME_TOKEN_DOCS = {
115
115
  panel: {
116
116
  description: 'Chat panel container.',
117
117
  properties:
118
- 'width, maxWidth (440px), height (600px), maxHeight, borderRadius, shadow.',
118
+ 'width, maxWidth (440px), height (600px), maxHeight, borderRadius, shadow, inset (16px, gap around a detached panel), canvasBackground (transparent, fills the region behind a detached panel in docked and inline embed modes; a no-op in sidebar mode, where the gap stays click-through and the host page shows through like floating). inset and canvasBackground apply only when launcher.detachedPanel is true or artifacts.layout.paneAppearance is "detached".',
119
119
  },
120
120
  header: {
121
121
  description: 'Chat panel header.',
@@ -288,7 +288,7 @@ export const THEME_TOKEN_DOCS = {
288
288
  features: {
289
289
  description: 'Feature flags.',
290
290
  properties:
291
- 'showReasoning (AI thinking steps), showToolCalls (tool invocations), toolCallDisplay (collapsedMode, activePreview, activeMinHeight, previewMaxLines, grouped, expandable, loadingAnimation), reasoningDisplay (activePreview, activeMinHeight, previewMaxLines, expandable, loadingAnimation), artifacts (sidebar config).',
291
+ 'showReasoning (AI thinking steps), showToolCalls (tool invocations), toolCallDisplay (collapsedMode, activePreview, activeMinHeight, previewMaxLines, grouped, groupedMode, expandable, loadingAnimation), reasoningDisplay (activePreview, activeMinHeight, previewMaxLines, expandable, loadingAnimation), artifacts (sidebar config).',
292
292
  },
293
293
  },
294
294
  }
@@ -8,6 +8,7 @@ describe("tool call display defaults", () => {
8
8
  collapsedMode: "tool-call",
9
9
  activePreview: false,
10
10
  grouped: false,
11
+ groupedMode: "stack",
11
12
  previewMaxLines: 3,
12
13
  expandable: true,
13
14
  loadingAnimation: "none",
@@ -194,6 +194,10 @@ export interface PanelTokens extends ComponentTokenSet {
194
194
  maxWidth: string;
195
195
  height: string;
196
196
  maxHeight: string;
197
+ /** Gap between the detached panel and its region edges. Only used when detached. */
198
+ inset?: string;
199
+ /** Background of the region revealed behind a detached panel. */
200
+ canvasBackground?: string;
197
201
  }
198
202
 
199
203
  export interface HeaderTokens extends ComponentTokenSet {
@@ -370,6 +374,14 @@ export interface ArtifactToolbarTokens {
370
374
  iconBorder?: string;
371
375
  toggleGroupGap?: string;
372
376
  toggleBorderRadius?: string;
377
+ /** Inner padding of the segmented view/source toggle pill. */
378
+ toggleGroupPadding?: string;
379
+ /** Border of the segmented view/source toggle pill (e.g., `none`). */
380
+ toggleGroupBorder?: string;
381
+ /** Corner radius of the segmented view/source toggle pill. */
382
+ toggleGroupBorderRadius?: string;
383
+ /** Background of the segmented view/source toggle pill. */
384
+ toggleGroupBackground?: string;
373
385
  copyBackground?: string;
374
386
  copyBorder?: string;
375
387
  copyColor?: string;
@@ -403,6 +415,17 @@ export interface ArtifactTabTokens {
403
415
  listPadding?: string;
404
416
  }
405
417
 
418
+ /** Artifact reference card (chat thread) chrome. */
419
+ export interface ArtifactCardTokens {
420
+ background?: string;
421
+ /** Full border shorthand (e.g. `1px solid #e5e7eb`). */
422
+ border?: string;
423
+ borderRadius?: string;
424
+ hoverBackground?: string;
425
+ /** Border color on hover. */
426
+ hoverBorderColor?: string;
427
+ }
428
+
406
429
  /** Artifact pane chrome. */
407
430
  export interface ArtifactPaneTokens {
408
431
  /**
@@ -414,6 +437,56 @@ export interface ArtifactPaneTokens {
414
437
  toolbarBackground?: string;
415
438
  }
416
439
 
440
+ /** Inline artifact block chrome (`display: "inline"` file preview). */
441
+ export interface ArtifactInlineTokens {
442
+ /** Background of the inline preview frame. */
443
+ background?: string;
444
+ /** Full border shorthand for the frame (e.g. `1px solid #e5e7eb`). */
445
+ border?: string;
446
+ /** Border radius of the inline preview frame. */
447
+ borderRadius?: string;
448
+ /** Background of the title/toolbar chrome bar. */
449
+ chromeBackground?: string;
450
+ /** Bottom border of the title bar. */
451
+ chromeBorder?: string;
452
+ /** Title text color in the chrome bar (artifact basename). */
453
+ titleColor?: string;
454
+ /** Muted text color for the type label / streaming status. */
455
+ mutedColor?: string;
456
+ /** Preview iframe height inside the inline body. */
457
+ frameHeight?: string;
458
+ }
459
+
460
+ /**
461
+ * Syntax-highlighted artifact source view (pane + inline), rendered by
462
+ * `utils/code-highlight.ts`. One Light defaults ship in `widget.css`, with a
463
+ * One Dark override keyed off the widget's resolved color scheme (the
464
+ * `data-persona-color-scheme` root attribute, not the OS preference); set any
465
+ * of these to retheme the tokenizer palette and the line-number gutter.
466
+ */
467
+ export interface CodeTokens {
468
+ /** Keywords, booleans, null (e.g. `const`, `true`). */
469
+ keywordColor?: string;
470
+ /** String and template literals; HTML attribute values. */
471
+ stringColor?: string;
472
+ /** Line and block comments. */
473
+ commentColor?: string;
474
+ /** Numeric literals; CSS hex colors / units. */
475
+ numberColor?: string;
476
+ /** HTML tag brackets + names; doctype. */
477
+ tagColor?: string;
478
+ /** HTML attribute names. */
479
+ attrColor?: string;
480
+ /** CSS property names; JSON object keys. */
481
+ propertyColor?: string;
482
+ /** Line-number gutter digits. */
483
+ lineNumberColor?: string;
484
+ /** Right border of the line-number gutter. */
485
+ gutterBorderColor?: string;
486
+ /** Background of the source-view code sheet (defaults to One Light/Dark editor background). */
487
+ background?: string;
488
+ }
489
+
417
490
  /** Icon button chrome (used by createIconButton). */
418
491
  export interface IconButtonTokens {
419
492
  background?: string;
@@ -487,9 +560,13 @@ export interface ComponentTokens {
487
560
  toolbar?: ArtifactToolbarTokens;
488
561
  tab?: ArtifactTabTokens;
489
562
  pane?: ArtifactPaneTokens;
563
+ card?: ArtifactCardTokens;
564
+ inline?: ArtifactInlineTokens;
490
565
  };
491
566
  /** Collapsible widget chrome (tool/reasoning/approval bubbles). */
492
567
  collapsibleWidget?: CollapsibleWidgetTokens;
568
+ /** Syntax-highlighted artifact source view (tokenizer palette + gutter). */
569
+ code?: CodeTokens;
493
570
  }
494
571
 
495
572
  export interface PaletteExtras {