@runtypelabs/persona 4.13.0 → 4.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.
- package/dist/codegen.cjs +1 -1
- package/dist/codegen.js +1 -1
- package/dist/context-mentions.d.cts +98 -6
- package/dist/context-mentions.d.ts +98 -6
- package/dist/index.cjs +64 -64
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +183 -8
- package/dist/index.d.ts +183 -8
- package/dist/index.global.js +54 -54
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +67 -67
- package/dist/index.js.map +1 -1
- package/dist/launcher.global.js +1 -1
- package/dist/launcher.global.js.map +1 -1
- package/dist/smart-dom-reader.d.cts +98 -6
- package/dist/smart-dom-reader.d.ts +98 -6
- package/dist/theme-editor-preview.cjs +66 -66
- package/dist/theme-editor-preview.d.cts +100 -6
- package/dist/theme-editor-preview.d.ts +100 -6
- package/dist/theme-editor-preview.js +75 -75
- package/dist/theme-editor.cjs +10 -10
- package/dist/theme-editor.d.cts +134 -7
- package/dist/theme-editor.d.ts +134 -7
- package/dist/theme-editor.js +10 -10
- package/dist/theme-reference.cjs +1 -1
- package/dist/widget.css +1 -1
- package/package.json +1 -1
- package/src/artifacts-session.test.ts +106 -0
- package/src/client.test.ts +2 -2
- package/src/client.ts +4 -1
- package/src/components/artifact-card.ts +13 -2
- package/src/components/artifact-inline.ts +11 -2
- package/src/components/composer-builder.test.ts +2 -0
- package/src/components/composer-builder.ts +1 -1
- package/src/components/composer-parts.test.ts +2 -0
- package/src/components/composer-parts.ts +1 -1
- package/src/components/message-bubble.test.ts +7 -1
- package/src/components/message-bubble.ts +11 -8
- package/src/index-core.ts +34 -0
- package/src/session.ts +45 -4
- package/src/styles/widget.css +10 -1
- package/src/theme-editor/index.ts +5 -0
- package/src/theme-editor/presets.test.ts +43 -0
- package/src/theme-editor/presets.ts +101 -87
- package/src/theme-editor/sections.test.ts +39 -7
- package/src/theme-editor/sections.ts +60 -8
- package/src/theme-editor/state-preferences.test.ts +15 -0
- package/src/theme-editor/state.ts +46 -0
- package/src/theme-editor/types.ts +15 -1
- package/src/theme-editor/webmcp/tools.test.ts +13 -0
- package/src/theme-editor/webmcp/tools.ts +5 -0
- package/src/types.ts +139 -9
- package/src/ui.artifact-pane-gating.test.ts +5 -5
- package/src/ui.config-preferences.test.ts +166 -0
- package/src/ui.ts +43 -25
- package/src/ui.typing-indicator.test.ts +135 -0
- package/src/utils/artifact-display.test.ts +180 -16
- package/src/utils/artifact-display.ts +155 -14
- package/src/utils/config-merge.test.ts +60 -0
- package/src/utils/config-merge.ts +6 -1
- package/src/utils/feature-preferences.test.ts +326 -0
- package/src/utils/feature-preferences.ts +498 -0
- package/src/utils/theme.test.ts +92 -0
- package/src/utils/tokens.ts +7 -7
|
@@ -2237,6 +2237,14 @@ type AgentToolsConfig = {
|
|
|
2237
2237
|
};
|
|
2238
2238
|
/** Artifact kinds for the Persona sidebar and dispatch payload */
|
|
2239
2239
|
type PersonaArtifactKind = "markdown" | "component";
|
|
2240
|
+
type PersonaArtifactPresentation = {
|
|
2241
|
+
/**
|
|
2242
|
+
* Producer hint for where this artifact renders (content-disposition
|
|
2243
|
+
* model). Beats configured defaults; loses to explicit `files`/`byKind`
|
|
2244
|
+
* rules. Persona never infers it; the producer or host supplies it.
|
|
2245
|
+
*/
|
|
2246
|
+
preferredMode?: PersonaArtifactDisplayModeInput;
|
|
2247
|
+
};
|
|
2240
2248
|
/**
|
|
2241
2249
|
* Agent configuration for agent execution mode.
|
|
2242
2250
|
* When provided in the widget config, enables agent loop execution instead of flow dispatch.
|
|
@@ -2765,7 +2773,48 @@ type AgentWidgetArtifactsLayoutConfig = {
|
|
|
2765
2773
|
jsonPayload: string;
|
|
2766
2774
|
}) => void | Promise<void>;
|
|
2767
2775
|
};
|
|
2768
|
-
|
|
2776
|
+
/**
|
|
2777
|
+
* Where the artifact body renders by default. Every mode shows the compact
|
|
2778
|
+
* reference in the transcript; the mode names where the body goes:
|
|
2779
|
+
* nowhere yet (`collapsed`), the side panel (`panel`), or the conversation
|
|
2780
|
+
* itself (`inline`).
|
|
2781
|
+
*/
|
|
2782
|
+
type PersonaArtifactDisplayMode = "collapsed" | "panel" | "inline";
|
|
2783
|
+
/**
|
|
2784
|
+
* Accepted wherever a display mode is written. `"card"` is a deprecated
|
|
2785
|
+
* alias of `"collapsed"` (the old name described the reference card, which
|
|
2786
|
+
* every mode shows, instead of where the body renders). Resolution and
|
|
2787
|
+
* parsing always canonicalize to `"collapsed"`.
|
|
2788
|
+
*/
|
|
2789
|
+
type PersonaArtifactDisplayModeInput = PersonaArtifactDisplayMode | "card";
|
|
2790
|
+
/**
|
|
2791
|
+
* Display rules for file-backed artifacts. `byMediaType` keys are exact MIME
|
|
2792
|
+
* types (`"text/html"`) or major-type wildcards (`"image/*"`), matched
|
|
2793
|
+
* case-insensitively without parameters; exact beats wildcard.
|
|
2794
|
+
*/
|
|
2795
|
+
type PersonaArtifactFilesDisplayRules = {
|
|
2796
|
+
default?: PersonaArtifactDisplayModeInput;
|
|
2797
|
+
byMediaType?: Record<string, PersonaArtifactDisplayModeInput>;
|
|
2798
|
+
};
|
|
2799
|
+
/**
|
|
2800
|
+
* Scoped artifact display rules. Matching resolves from the most specific
|
|
2801
|
+
* selector to `default`; see `resolveArtifactDisplay`.
|
|
2802
|
+
*
|
|
2803
|
+
* Across preference layers, one merge rule applies everywhere: a string value
|
|
2804
|
+
* replaces the whole subtree it names; an object refines it per key. So
|
|
2805
|
+
* `files: "inline"` overrides every lower-layer file rule, while
|
|
2806
|
+
* `files: { default: "inline" }` keeps lower-layer MIME exceptions.
|
|
2807
|
+
*/
|
|
2808
|
+
type PersonaArtifactDisplayRules = {
|
|
2809
|
+
default?: PersonaArtifactDisplayModeInput;
|
|
2810
|
+
byKind?: Partial<Record<PersonaArtifactKind, PersonaArtifactDisplayModeInput>>;
|
|
2811
|
+
/**
|
|
2812
|
+
* @deprecated Use `byKind`. When both are present, `byKind` wins.
|
|
2813
|
+
*/
|
|
2814
|
+
byType?: Partial<Record<PersonaArtifactKind, PersonaArtifactDisplayModeInput>>;
|
|
2815
|
+
/** Rules for any artifact carrying file metadata. */
|
|
2816
|
+
files?: PersonaArtifactDisplayModeInput | PersonaArtifactFilesDisplayRules;
|
|
2817
|
+
};
|
|
2769
2818
|
/** Context handed to custom artifact actions. Content fields are best-effort: resolved from live session state or, after a refresh, from the persisted reference-card payload. */
|
|
2770
2819
|
type PersonaArtifactActionContext = {
|
|
2771
2820
|
artifactId: string | null;
|
|
@@ -2822,13 +2871,10 @@ type AgentWidgetArtifactsFeature = {
|
|
|
2822
2871
|
allowedTypes?: PersonaArtifactKind[];
|
|
2823
2872
|
/**
|
|
2824
2873
|
* Where artifact bodies render. A single mode applies to all artifacts;
|
|
2825
|
-
* the object form sets a default plus
|
|
2874
|
+
* the object form sets a default plus scoped overrides.
|
|
2826
2875
|
* Defaults to "panel" (current behavior).
|
|
2827
2876
|
*/
|
|
2828
|
-
display?:
|
|
2829
|
-
default?: PersonaArtifactDisplayMode;
|
|
2830
|
-
byType?: Partial<Record<PersonaArtifactKind, PersonaArtifactDisplayMode>>;
|
|
2831
|
-
};
|
|
2877
|
+
display?: PersonaArtifactDisplayModeInput | PersonaArtifactDisplayRules;
|
|
2832
2878
|
/** Split / drawer dimensions and launcher widen behavior */
|
|
2833
2879
|
layout?: AgentWidgetArtifactsLayoutConfig;
|
|
2834
2880
|
/**
|
|
@@ -3557,6 +3603,41 @@ type AgentWidgetFeatureFlags = {
|
|
|
3557
3603
|
*/
|
|
3558
3604
|
suggestReplies?: AgentWidgetSuggestRepliesFeature;
|
|
3559
3605
|
};
|
|
3606
|
+
/**
|
|
3607
|
+
* Persistable artifact-layout choices. The full layout config deliberately is
|
|
3608
|
+
* not exposed because it also contains callbacks and embedder-owned chrome.
|
|
3609
|
+
*/
|
|
3610
|
+
type WidgetArtifactLayoutPreference = Pick<AgentWidgetArtifactsLayoutConfig, "paneWidth" | "paneMaxWidth" | "paneMinWidth" | "expandLauncherPanelWhenOpen" | "expandedPanelWidth" | "resizable" | "resizableMinWidth" | "resizableMaxWidth">;
|
|
3611
|
+
/**
|
|
3612
|
+
* Curated, JSON-serializable display preferences in native `features` shape.
|
|
3613
|
+
*
|
|
3614
|
+
* Absence means inherit the next preference layer and ultimately Persona's
|
|
3615
|
+
* current default. Persist only explicit choices; resetting a choice deletes
|
|
3616
|
+
* its key.
|
|
3617
|
+
*
|
|
3618
|
+
* Capability facts (`artifacts.enabled`, `allowedTypes`), trusted iframe
|
|
3619
|
+
* security, callbacks, actions, renderers, labels, and theme styling are
|
|
3620
|
+
* intentionally excluded because they remain embedder/code-owned.
|
|
3621
|
+
*/
|
|
3622
|
+
type WidgetPreferenceSlice = {
|
|
3623
|
+
showToolCalls?: boolean;
|
|
3624
|
+
showReasoning?: boolean;
|
|
3625
|
+
toolCallDisplay?: Pick<AgentWidgetToolCallDisplayFeature, "collapsedMode" | "expandable" | "grouped" | "groupedMode" | "loadingAnimation">;
|
|
3626
|
+
reasoningDisplay?: Pick<AgentWidgetReasoningDisplayFeature, "expandable" | "activePreview">;
|
|
3627
|
+
artifacts?: {
|
|
3628
|
+
/**
|
|
3629
|
+
* String and object forms are both persistable and mean different things
|
|
3630
|
+
* when layers merge: a string replaces every lower-layer display rule; an
|
|
3631
|
+
* object refines lower layers per selector key (same rule applies to
|
|
3632
|
+
* `display.files`).
|
|
3633
|
+
*/
|
|
3634
|
+
display?: PersonaArtifactDisplayModeInput | PersonaArtifactDisplayRules;
|
|
3635
|
+
filePreview?: {
|
|
3636
|
+
enabled?: boolean;
|
|
3637
|
+
};
|
|
3638
|
+
layout?: WidgetArtifactLayoutPreference;
|
|
3639
|
+
};
|
|
3640
|
+
};
|
|
3560
3641
|
/**
|
|
3561
3642
|
* Feature config for the built-in `suggest_replies` quick-reply chips.
|
|
3562
3643
|
* Chips render in the existing suggestions slot above the composer and are
|
|
@@ -5998,6 +6079,15 @@ type AgentWidgetConfig = {
|
|
|
5998
6079
|
*/
|
|
5999
6080
|
colorScheme?: 'auto' | 'light' | 'dark';
|
|
6000
6081
|
features?: AgentWidgetFeatureFlags;
|
|
6082
|
+
/**
|
|
6083
|
+
* Per-instance display overrides, applied over `features` through the
|
|
6084
|
+
* preference allowlist (security/capability keys cannot pass). String
|
|
6085
|
+
* `display` values replace the base rule subtree; objects refine it per
|
|
6086
|
+
* key. Each `controller.update({ preferences })` replaces the previous
|
|
6087
|
+
* slice wholesale (dropped keys revert to the base `features`); an
|
|
6088
|
+
* explicit-undefined patch clears it entirely.
|
|
6089
|
+
*/
|
|
6090
|
+
preferences?: WidgetPreferenceSlice;
|
|
6001
6091
|
/**
|
|
6002
6092
|
* When true, focus the chat input after the panel opens and the open animation completes.
|
|
6003
6093
|
* Applies to launcher mode (user click, controller.open(), autoExpand) and inline mode (on init).
|
|
@@ -6758,6 +6848,8 @@ type PersonaArtifactRecord = {
|
|
|
6758
6848
|
props?: Record<string, unknown>;
|
|
6759
6849
|
/** Present when this markdown artifact is a previewable file (see PersonaArtifactFileMeta). */
|
|
6760
6850
|
file?: PersonaArtifactFileMeta;
|
|
6851
|
+
/** Optional presentation metadata such as the producer's display-mode hint. */
|
|
6852
|
+
presentation?: PersonaArtifactPresentation;
|
|
6761
6853
|
};
|
|
6762
6854
|
|
|
6763
6855
|
/**
|
|
@@ -2237,6 +2237,14 @@ type AgentToolsConfig = {
|
|
|
2237
2237
|
};
|
|
2238
2238
|
/** Artifact kinds for the Persona sidebar and dispatch payload */
|
|
2239
2239
|
type PersonaArtifactKind = "markdown" | "component";
|
|
2240
|
+
type PersonaArtifactPresentation = {
|
|
2241
|
+
/**
|
|
2242
|
+
* Producer hint for where this artifact renders (content-disposition
|
|
2243
|
+
* model). Beats configured defaults; loses to explicit `files`/`byKind`
|
|
2244
|
+
* rules. Persona never infers it; the producer or host supplies it.
|
|
2245
|
+
*/
|
|
2246
|
+
preferredMode?: PersonaArtifactDisplayModeInput;
|
|
2247
|
+
};
|
|
2240
2248
|
/**
|
|
2241
2249
|
* Agent configuration for agent execution mode.
|
|
2242
2250
|
* When provided in the widget config, enables agent loop execution instead of flow dispatch.
|
|
@@ -2765,7 +2773,48 @@ type AgentWidgetArtifactsLayoutConfig = {
|
|
|
2765
2773
|
jsonPayload: string;
|
|
2766
2774
|
}) => void | Promise<void>;
|
|
2767
2775
|
};
|
|
2768
|
-
|
|
2776
|
+
/**
|
|
2777
|
+
* Where the artifact body renders by default. Every mode shows the compact
|
|
2778
|
+
* reference in the transcript; the mode names where the body goes:
|
|
2779
|
+
* nowhere yet (`collapsed`), the side panel (`panel`), or the conversation
|
|
2780
|
+
* itself (`inline`).
|
|
2781
|
+
*/
|
|
2782
|
+
type PersonaArtifactDisplayMode = "collapsed" | "panel" | "inline";
|
|
2783
|
+
/**
|
|
2784
|
+
* Accepted wherever a display mode is written. `"card"` is a deprecated
|
|
2785
|
+
* alias of `"collapsed"` (the old name described the reference card, which
|
|
2786
|
+
* every mode shows, instead of where the body renders). Resolution and
|
|
2787
|
+
* parsing always canonicalize to `"collapsed"`.
|
|
2788
|
+
*/
|
|
2789
|
+
type PersonaArtifactDisplayModeInput = PersonaArtifactDisplayMode | "card";
|
|
2790
|
+
/**
|
|
2791
|
+
* Display rules for file-backed artifacts. `byMediaType` keys are exact MIME
|
|
2792
|
+
* types (`"text/html"`) or major-type wildcards (`"image/*"`), matched
|
|
2793
|
+
* case-insensitively without parameters; exact beats wildcard.
|
|
2794
|
+
*/
|
|
2795
|
+
type PersonaArtifactFilesDisplayRules = {
|
|
2796
|
+
default?: PersonaArtifactDisplayModeInput;
|
|
2797
|
+
byMediaType?: Record<string, PersonaArtifactDisplayModeInput>;
|
|
2798
|
+
};
|
|
2799
|
+
/**
|
|
2800
|
+
* Scoped artifact display rules. Matching resolves from the most specific
|
|
2801
|
+
* selector to `default`; see `resolveArtifactDisplay`.
|
|
2802
|
+
*
|
|
2803
|
+
* Across preference layers, one merge rule applies everywhere: a string value
|
|
2804
|
+
* replaces the whole subtree it names; an object refines it per key. So
|
|
2805
|
+
* `files: "inline"` overrides every lower-layer file rule, while
|
|
2806
|
+
* `files: { default: "inline" }` keeps lower-layer MIME exceptions.
|
|
2807
|
+
*/
|
|
2808
|
+
type PersonaArtifactDisplayRules = {
|
|
2809
|
+
default?: PersonaArtifactDisplayModeInput;
|
|
2810
|
+
byKind?: Partial<Record<PersonaArtifactKind, PersonaArtifactDisplayModeInput>>;
|
|
2811
|
+
/**
|
|
2812
|
+
* @deprecated Use `byKind`. When both are present, `byKind` wins.
|
|
2813
|
+
*/
|
|
2814
|
+
byType?: Partial<Record<PersonaArtifactKind, PersonaArtifactDisplayModeInput>>;
|
|
2815
|
+
/** Rules for any artifact carrying file metadata. */
|
|
2816
|
+
files?: PersonaArtifactDisplayModeInput | PersonaArtifactFilesDisplayRules;
|
|
2817
|
+
};
|
|
2769
2818
|
/** Context handed to custom artifact actions. Content fields are best-effort: resolved from live session state or, after a refresh, from the persisted reference-card payload. */
|
|
2770
2819
|
type PersonaArtifactActionContext = {
|
|
2771
2820
|
artifactId: string | null;
|
|
@@ -2822,13 +2871,10 @@ type AgentWidgetArtifactsFeature = {
|
|
|
2822
2871
|
allowedTypes?: PersonaArtifactKind[];
|
|
2823
2872
|
/**
|
|
2824
2873
|
* Where artifact bodies render. A single mode applies to all artifacts;
|
|
2825
|
-
* the object form sets a default plus
|
|
2874
|
+
* the object form sets a default plus scoped overrides.
|
|
2826
2875
|
* Defaults to "panel" (current behavior).
|
|
2827
2876
|
*/
|
|
2828
|
-
display?:
|
|
2829
|
-
default?: PersonaArtifactDisplayMode;
|
|
2830
|
-
byType?: Partial<Record<PersonaArtifactKind, PersonaArtifactDisplayMode>>;
|
|
2831
|
-
};
|
|
2877
|
+
display?: PersonaArtifactDisplayModeInput | PersonaArtifactDisplayRules;
|
|
2832
2878
|
/** Split / drawer dimensions and launcher widen behavior */
|
|
2833
2879
|
layout?: AgentWidgetArtifactsLayoutConfig;
|
|
2834
2880
|
/**
|
|
@@ -3557,6 +3603,41 @@ type AgentWidgetFeatureFlags = {
|
|
|
3557
3603
|
*/
|
|
3558
3604
|
suggestReplies?: AgentWidgetSuggestRepliesFeature;
|
|
3559
3605
|
};
|
|
3606
|
+
/**
|
|
3607
|
+
* Persistable artifact-layout choices. The full layout config deliberately is
|
|
3608
|
+
* not exposed because it also contains callbacks and embedder-owned chrome.
|
|
3609
|
+
*/
|
|
3610
|
+
type WidgetArtifactLayoutPreference = Pick<AgentWidgetArtifactsLayoutConfig, "paneWidth" | "paneMaxWidth" | "paneMinWidth" | "expandLauncherPanelWhenOpen" | "expandedPanelWidth" | "resizable" | "resizableMinWidth" | "resizableMaxWidth">;
|
|
3611
|
+
/**
|
|
3612
|
+
* Curated, JSON-serializable display preferences in native `features` shape.
|
|
3613
|
+
*
|
|
3614
|
+
* Absence means inherit the next preference layer and ultimately Persona's
|
|
3615
|
+
* current default. Persist only explicit choices; resetting a choice deletes
|
|
3616
|
+
* its key.
|
|
3617
|
+
*
|
|
3618
|
+
* Capability facts (`artifacts.enabled`, `allowedTypes`), trusted iframe
|
|
3619
|
+
* security, callbacks, actions, renderers, labels, and theme styling are
|
|
3620
|
+
* intentionally excluded because they remain embedder/code-owned.
|
|
3621
|
+
*/
|
|
3622
|
+
type WidgetPreferenceSlice = {
|
|
3623
|
+
showToolCalls?: boolean;
|
|
3624
|
+
showReasoning?: boolean;
|
|
3625
|
+
toolCallDisplay?: Pick<AgentWidgetToolCallDisplayFeature, "collapsedMode" | "expandable" | "grouped" | "groupedMode" | "loadingAnimation">;
|
|
3626
|
+
reasoningDisplay?: Pick<AgentWidgetReasoningDisplayFeature, "expandable" | "activePreview">;
|
|
3627
|
+
artifacts?: {
|
|
3628
|
+
/**
|
|
3629
|
+
* String and object forms are both persistable and mean different things
|
|
3630
|
+
* when layers merge: a string replaces every lower-layer display rule; an
|
|
3631
|
+
* object refines lower layers per selector key (same rule applies to
|
|
3632
|
+
* `display.files`).
|
|
3633
|
+
*/
|
|
3634
|
+
display?: PersonaArtifactDisplayModeInput | PersonaArtifactDisplayRules;
|
|
3635
|
+
filePreview?: {
|
|
3636
|
+
enabled?: boolean;
|
|
3637
|
+
};
|
|
3638
|
+
layout?: WidgetArtifactLayoutPreference;
|
|
3639
|
+
};
|
|
3640
|
+
};
|
|
3560
3641
|
/**
|
|
3561
3642
|
* Feature config for the built-in `suggest_replies` quick-reply chips.
|
|
3562
3643
|
* Chips render in the existing suggestions slot above the composer and are
|
|
@@ -5998,6 +6079,15 @@ type AgentWidgetConfig = {
|
|
|
5998
6079
|
*/
|
|
5999
6080
|
colorScheme?: 'auto' | 'light' | 'dark';
|
|
6000
6081
|
features?: AgentWidgetFeatureFlags;
|
|
6082
|
+
/**
|
|
6083
|
+
* Per-instance display overrides, applied over `features` through the
|
|
6084
|
+
* preference allowlist (security/capability keys cannot pass). String
|
|
6085
|
+
* `display` values replace the base rule subtree; objects refine it per
|
|
6086
|
+
* key. Each `controller.update({ preferences })` replaces the previous
|
|
6087
|
+
* slice wholesale (dropped keys revert to the base `features`); an
|
|
6088
|
+
* explicit-undefined patch clears it entirely.
|
|
6089
|
+
*/
|
|
6090
|
+
preferences?: WidgetPreferenceSlice;
|
|
6001
6091
|
/**
|
|
6002
6092
|
* When true, focus the chat input after the panel opens and the open animation completes.
|
|
6003
6093
|
* Applies to launcher mode (user click, controller.open(), autoExpand) and inline mode (on init).
|
|
@@ -6758,6 +6848,8 @@ type PersonaArtifactRecord = {
|
|
|
6758
6848
|
props?: Record<string, unknown>;
|
|
6759
6849
|
/** Present when this markdown artifact is a previewable file (see PersonaArtifactFileMeta). */
|
|
6760
6850
|
file?: PersonaArtifactFileMeta;
|
|
6851
|
+
/** Optional presentation metadata such as the producer's display-mode hint. */
|
|
6852
|
+
presentation?: PersonaArtifactPresentation;
|
|
6761
6853
|
};
|
|
6762
6854
|
|
|
6763
6855
|
/**
|