@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.
- package/dist/animations/glyph-cycle.cjs +2 -2
- package/dist/animations/glyph-cycle.d.cts +1 -1
- package/dist/animations/glyph-cycle.d.ts +1 -1
- package/dist/animations/glyph-cycle.js +2 -2
- package/dist/animations/{types-CSmiKRVa.d.cts → types-BsZtXPKK.d.cts} +43 -3
- package/dist/animations/{types-CSmiKRVa.d.ts → types-BsZtXPKK.d.ts} +43 -3
- package/dist/animations/wipe.cjs +2 -2
- package/dist/animations/wipe.d.cts +1 -1
- package/dist/animations/wipe.d.ts +1 -1
- package/dist/chunk-5EIIHQLQ.js +1 -0
- package/dist/codegen.cjs +12 -12
- package/dist/codegen.js +14 -14
- package/dist/index.cjs +91 -68
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +918 -174
- package/dist/index.d.ts +918 -174
- package/dist/index.global.js +81 -57
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +89 -66
- package/dist/index.js.map +1 -1
- package/dist/install.global.js +1 -1
- package/dist/install.global.js.map +1 -1
- package/dist/launcher.global.js +3 -2
- package/dist/launcher.global.js.map +1 -1
- package/dist/markdown-parsers.js +24 -24
- package/dist/plugin-kit.cjs +1 -1
- package/dist/plugin-kit.js +1 -1
- package/dist/runtype-tts-entry-UJAEF7NZ.js +1 -0
- package/dist/runtype-tts.js +1 -1
- package/dist/session-reconnect-JKIJBHS5.js +1 -0
- package/dist/smart-dom-reader.cjs +17 -17
- package/dist/smart-dom-reader.d.cts +753 -15
- package/dist/smart-dom-reader.d.ts +753 -15
- package/dist/smart-dom-reader.js +17 -17
- package/dist/testing.cjs +3 -3
- package/dist/testing.js +3 -3
- package/dist/theme-editor-preview.cjs +81 -58
- package/dist/theme-editor-preview.d.cts +761 -15
- package/dist/theme-editor-preview.d.ts +761 -15
- package/dist/theme-editor-preview.js +81 -58
- package/dist/theme-editor.cjs +6 -6
- package/dist/theme-editor.d.cts +753 -15
- package/dist/theme-editor.d.ts +753 -15
- package/dist/theme-editor.js +10 -10
- package/dist/theme-reference.cjs +1 -1
- package/dist/theme-reference.d.cts +74 -0
- package/dist/theme-reference.d.ts +74 -0
- package/dist/theme-reference.js +1 -1
- package/dist/voice-worklet-player.cjs +2 -2
- package/dist/voice-worklet-player.js +2 -2
- package/dist/webmcp-polyfill.js +2 -2
- package/dist/widget.css +1 -1
- package/package.json +2 -3
- package/src/artifacts-session.test.ts +178 -0
- package/src/client.test.ts +500 -1
- package/src/client.ts +285 -93
- package/src/components/artifact-card.test.ts +333 -0
- package/src/components/artifact-card.ts +75 -28
- package/src/components/artifact-inline.test.ts +1328 -0
- package/src/components/artifact-inline.ts +920 -0
- package/src/components/artifact-pane.test.ts +1042 -0
- package/src/components/artifact-pane.ts +440 -131
- package/src/components/artifact-preview.test.ts +1155 -0
- package/src/components/artifact-preview.ts +994 -0
- package/src/components/pill-composer-builder.test.ts +6 -2
- package/src/components/pill-composer-builder.ts +6 -6
- package/src/components/reasoning-bubble.ts +1 -13
- package/src/components/registry.ts +38 -3
- package/src/components/tool-bubble.ts +1 -13
- package/src/defaults.ts +1 -0
- package/src/generated/runtype-openapi-contract.ts +55 -3
- package/src/index-core.ts +20 -1
- package/src/index.ts +8 -0
- package/src/markdown-parsers-loader.test.ts +158 -0
- package/src/markdown-parsers-loader.ts +74 -9
- package/src/runtime/host-layout.test.ts +163 -0
- package/src/runtime/host-layout.ts +110 -7
- package/src/runtime/init.ts +18 -61
- package/src/runtime/persist-state.test.ts +118 -0
- package/src/session.ts +76 -22
- package/src/styles/widget.css +773 -26
- package/src/theme-editor/preview.ts +2 -0
- package/src/theme-editor/sections.test.ts +26 -1
- package/src/theme-editor/sections.ts +10 -2
- package/src/theme-reference.ts +2 -2
- package/src/tool-call-display-defaults.test.ts +1 -0
- package/src/types/theme.ts +77 -0
- package/src/types.ts +516 -17
- package/src/ui.artifact-pane-gating.test.ts +636 -0
- package/src/ui.component-directive.test.ts +104 -0
- package/src/ui.composer-bar.test.ts +60 -2
- package/src/ui.detached-panel.test.ts +1049 -0
- package/src/ui.scroll-additive.test.ts +1 -1
- package/src/ui.streaming-coalescing.test.ts +312 -0
- package/src/ui.tool-display.test.ts +51 -0
- package/src/ui.ts +933 -214
- package/src/utils/artifact-custom-actions.ts +128 -0
- package/src/utils/artifact-display.test.ts +42 -0
- package/src/utils/artifact-display.ts +84 -0
- package/src/utils/artifact-file.test.ts +116 -0
- package/src/utils/artifact-file.ts +117 -0
- package/src/utils/artifact-gate.test.ts +112 -5
- package/src/utils/artifact-gate.ts +39 -14
- package/src/utils/artifact-loading-status.ts +55 -0
- package/src/utils/artifact-status-label.ts +190 -0
- package/src/utils/buttons.ts +7 -1
- package/src/utils/code-highlight.test.ts +186 -0
- package/src/utils/code-highlight.ts +400 -0
- package/src/utils/icons.ts +2 -0
- package/src/utils/roving-tablist.test.ts +152 -0
- package/src/utils/roving-tablist.ts +111 -0
- package/src/utils/spinner.ts +45 -0
- package/src/utils/theme.test.ts +48 -0
- package/src/utils/theme.ts +7 -0
- package/src/utils/tokens.ts +91 -0
- package/src/utils/tool-loading-animation.test.ts +32 -0
- package/src/utils/tool-loading-animation.ts +24 -0
- package/dist/chunk-DFBSCFYN.js +0 -1
- package/dist/runtype-tts-entry-HFUV2UF7.js +0 -1
- package/dist/session-reconnect-U77QFUR7.js +0 -1
package/src/session.ts
CHANGED
|
@@ -28,6 +28,10 @@ import {
|
|
|
28
28
|
generateAssistantMessageId
|
|
29
29
|
} from "./utils/message-id";
|
|
30
30
|
import { IMAGE_ONLY_MESSAGE_FALLBACK_TEXT } from "./utils/content";
|
|
31
|
+
import {
|
|
32
|
+
buildArtifactRefRawContent,
|
|
33
|
+
resolveArtifactDisplayMode
|
|
34
|
+
} from "./utils/artifact-display";
|
|
31
35
|
import type {
|
|
32
36
|
VoiceProvider,
|
|
33
37
|
VoiceStatus,
|
|
@@ -2607,33 +2611,82 @@ export class AgentWidgetSession {
|
|
|
2607
2611
|
const id =
|
|
2608
2612
|
manual.id ||
|
|
2609
2613
|
`art_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 9)}`;
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
component: manual.component,
|
|
2629
|
-
props: manual.props ?? {}
|
|
2630
|
-
};
|
|
2614
|
+
const rec: PersonaArtifactRecord =
|
|
2615
|
+
manual.artifactType === "markdown"
|
|
2616
|
+
? {
|
|
2617
|
+
id,
|
|
2618
|
+
artifactType: "markdown",
|
|
2619
|
+
title: manual.title,
|
|
2620
|
+
status: "complete",
|
|
2621
|
+
markdown: manual.content,
|
|
2622
|
+
...(manual.file ? { file: manual.file } : {})
|
|
2623
|
+
}
|
|
2624
|
+
: {
|
|
2625
|
+
id,
|
|
2626
|
+
artifactType: "component",
|
|
2627
|
+
title: manual.title,
|
|
2628
|
+
status: "complete",
|
|
2629
|
+
component: manual.component,
|
|
2630
|
+
props: manual.props ?? {}
|
|
2631
|
+
};
|
|
2631
2632
|
this.artifacts.set(id, rec);
|
|
2632
2633
|
this.selectedArtifactId = id;
|
|
2633
2634
|
this.emitArtifactsState();
|
|
2635
|
+
if (manual.transcript !== false) {
|
|
2636
|
+
this.injectArtifactRefBlock(rec);
|
|
2637
|
+
}
|
|
2634
2638
|
return rec;
|
|
2635
2639
|
}
|
|
2636
2640
|
|
|
2641
|
+
/**
|
|
2642
|
+
* Injects (or refreshes) the in-thread artifact block for a programmatically
|
|
2643
|
+
* upserted artifact, matching the streamed UX: the resolved display mode
|
|
2644
|
+
* picks the component ("card"/"panel" → reference card, "inline" → inline
|
|
2645
|
+
* preview).
|
|
2646
|
+
*
|
|
2647
|
+
* Unlike the streamed path (which embeds content on `artifact_complete`),
|
|
2648
|
+
* the programmatic record is complete up front, so the final markdown /
|
|
2649
|
+
* file meta / component name + props are embedded immediately and the block
|
|
2650
|
+
* hydrates after a refresh without the original registry state.
|
|
2651
|
+
*
|
|
2652
|
+
* A re-upsert of the same id rebuilds the existing block's persisted
|
|
2653
|
+
* rawContent in place (the registry is not persisted, so hydration reads
|
|
2654
|
+
* these props); without this the block would keep the first version's
|
|
2655
|
+
* content after a refresh.
|
|
2656
|
+
*/
|
|
2657
|
+
private injectArtifactRefBlock(rec: PersonaArtifactRecord): void {
|
|
2658
|
+
const refId = `artifact-ref-${rec.id}`;
|
|
2659
|
+
const displayMode = resolveArtifactDisplayMode(
|
|
2660
|
+
this.config.features?.artifacts,
|
|
2661
|
+
rec.artifactType
|
|
2662
|
+
);
|
|
2663
|
+
const rawContent = buildArtifactRefRawContent(displayMode, {
|
|
2664
|
+
artifactId: rec.id,
|
|
2665
|
+
title: rec.title,
|
|
2666
|
+
artifactType: rec.artifactType,
|
|
2667
|
+
status: "complete",
|
|
2668
|
+
...(rec.file ? { file: rec.file } : {}),
|
|
2669
|
+
...(rec.component ? { component: rec.component } : {}),
|
|
2670
|
+
...(rec.props ? { componentProps: rec.props } : {}),
|
|
2671
|
+
...(rec.markdown !== undefined ? { markdown: rec.markdown } : {})
|
|
2672
|
+
});
|
|
2673
|
+
// Re-upsert: mutate the STORED message (inject stores a copy via
|
|
2674
|
+
// ensureSequence, so a local copy would be lost) and notify so the
|
|
2675
|
+
// transcript re-renders and persistence picks up the new version.
|
|
2676
|
+
const existing = this.messages.find((m) => m.id === refId);
|
|
2677
|
+
if (existing) {
|
|
2678
|
+
existing.rawContent = rawContent;
|
|
2679
|
+
existing.streaming = false;
|
|
2680
|
+
this.callbacks.onMessagesChanged([...this.messages]);
|
|
2681
|
+
return;
|
|
2682
|
+
}
|
|
2683
|
+
this.injectAssistantMessage({
|
|
2684
|
+
id: refId,
|
|
2685
|
+
content: "",
|
|
2686
|
+
rawContent
|
|
2687
|
+
});
|
|
2688
|
+
}
|
|
2689
|
+
|
|
2637
2690
|
private clearArtifactState(): void {
|
|
2638
2691
|
if (this.artifacts.size === 0 && this.selectedArtifactId === null) return;
|
|
2639
2692
|
this.artifacts.clear();
|
|
@@ -2657,7 +2710,8 @@ export class AgentWidgetSession {
|
|
|
2657
2710
|
artifactType: "markdown",
|
|
2658
2711
|
title: ev.title,
|
|
2659
2712
|
status: "streaming",
|
|
2660
|
-
markdown: ""
|
|
2713
|
+
markdown: "",
|
|
2714
|
+
...(ev.file ? { file: ev.file } : {})
|
|
2661
2715
|
});
|
|
2662
2716
|
} else {
|
|
2663
2717
|
this.artifacts.set(ev.id, {
|