@runtypelabs/persona 3.34.1 → 3.35.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/README.md +11 -11
- package/dist/animations/glyph-cycle.d.cts +1 -1
- package/dist/animations/glyph-cycle.d.ts +1 -1
- package/dist/animations/{types-CthJFfNx.d.cts → types-DgYsuwXL.d.cts} +15 -14
- package/dist/animations/{types-CthJFfNx.d.ts → types-DgYsuwXL.d.ts} +15 -14
- package/dist/animations/wipe.d.cts +1 -1
- package/dist/animations/wipe.d.ts +1 -1
- package/dist/codegen.cjs +11 -11
- package/dist/codegen.js +10 -10
- package/dist/index.cjs +46 -44
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +514 -158
- package/dist/index.d.ts +514 -158
- package/dist/index.global.js +41 -89
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +46 -44
- 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 +2 -2
- package/dist/launcher.global.js.map +1 -1
- package/dist/markdown-parsers.js +53 -0
- package/dist/plugin-kit.d.cts +4 -4
- package/dist/plugin-kit.d.ts +4 -4
- package/dist/runtype-tts.js +1 -0
- package/dist/smart-dom-reader.cjs +1 -1
- package/dist/smart-dom-reader.d.cts +352 -103
- package/dist/smart-dom-reader.d.ts +352 -103
- package/dist/smart-dom-reader.js +1 -1
- package/dist/theme-editor-preview.cjs +203 -0
- package/dist/theme-editor-preview.d.cts +5748 -0
- package/dist/theme-editor-preview.d.ts +5748 -0
- package/dist/theme-editor-preview.js +203 -0
- package/dist/theme-editor.cjs +14 -131
- package/dist/theme-editor.d.cts +362 -574
- package/dist/theme-editor.d.ts +362 -574
- package/dist/theme-editor.js +14 -131
- package/dist/theme-reference.cjs +1 -1
- package/dist/theme-reference.d.cts +1 -1
- package/dist/theme-reference.d.ts +1 -1
- package/dist/theme-reference.js +1 -1
- package/dist/voice-worklet-player.cjs +80 -0
- package/dist/voice-worklet-player.d.cts +215 -0
- package/dist/voice-worklet-player.d.ts +215 -0
- package/dist/voice-worklet-player.js +80 -0
- package/dist/widget.css +54 -36
- package/package.json +16 -2
- package/src/animations/glyph-cycle.ts +11 -14
- package/src/animations/wipe.ts +1 -1
- package/src/ask-user-question-tool.test.ts +1 -1
- package/src/ask-user-question-tool.ts +6 -8
- package/src/client.test.ts +12 -12
- package/src/client.ts +30 -31
- package/src/codegen.test.ts +1 -1
- package/src/codegen.ts +1 -1
- package/src/components/approval-bubble.test.ts +1 -1
- package/src/components/approval-bubble.ts +3 -3
- package/src/components/artifact-pane.ts +3 -3
- package/src/components/ask-user-question-bubble.test.ts +14 -14
- package/src/components/ask-user-question-bubble.ts +10 -10
- package/src/components/composer-builder.ts +17 -16
- package/src/components/composer-parts.test.ts +54 -0
- package/src/components/composer-parts.ts +95 -126
- package/src/components/demo-carousel.ts +1 -1
- package/src/components/event-stream-view.test.ts +7 -7
- package/src/components/event-stream-view.ts +5 -5
- package/src/components/header-builder.ts +33 -27
- package/src/components/header-layouts.ts +1 -1
- package/src/components/header-parts.test.ts +90 -0
- package/src/components/header-parts.ts +62 -93
- package/src/components/launcher.test.ts +11 -0
- package/src/components/launcher.ts +1 -1
- package/src/components/message-bubble.test.ts +74 -2
- package/src/components/message-bubble.ts +25 -11
- package/src/components/messages.ts +2 -2
- package/src/components/panel.test.ts +1 -1
- package/src/components/panel.ts +92 -97
- package/src/components/pill-composer-builder.ts +28 -24
- package/src/components/reasoning-bubble.ts +2 -2
- package/src/components/suggestions.ts +1 -1
- package/src/components/tool-bubble.ts +1 -1
- package/src/components/widget-view.test.ts +181 -0
- package/src/components/widget-view.ts +234 -0
- package/src/defaults.ts +54 -51
- package/src/generated/runtype-openapi-contract.ts +5 -0
- package/src/index-core.ts +30 -4
- package/src/index-global.ts +73 -6
- package/src/index.ts +7 -1
- package/src/install.test.ts +11 -11
- package/src/install.ts +28 -18
- package/src/launcher-global.ts +25 -14
- package/src/markdown-parsers-eager.ts +20 -0
- package/src/markdown-parsers-entry.ts +4 -0
- package/src/markdown-parsers-loader.ts +49 -0
- package/src/plugin-kit.test.ts +1 -1
- package/src/plugin-kit.ts +7 -7
- package/src/plugins/types.ts +5 -5
- package/src/postprocessors.ts +27 -14
- package/src/runtime/host-layout.test.ts +1 -1
- package/src/runtime/host-layout.ts +4 -5
- package/src/runtime/init.ts +2 -2
- package/src/session.test.ts +5 -6
- package/src/session.ts +333 -227
- package/src/session.voice.test.ts +146 -0
- package/src/session.webmcp.test.ts +24 -25
- package/src/smart-dom-reader.ts +3 -4
- package/src/styles/widget.css +54 -36
- package/src/suggest-replies-tool.test.ts +3 -3
- package/src/suggest-replies-tool.ts +5 -5
- package/src/testing/index.ts +1 -1
- package/src/theme-editor/color-utils.ts +2 -2
- package/src/theme-editor/index.ts +4 -13
- package/src/theme-editor/presets.ts +1 -1
- package/src/theme-editor/preview-utils.ts +22 -20
- package/src/theme-editor/preview.ts +4 -1
- package/src/theme-editor/role-mappings.ts +3 -3
- package/src/theme-editor/sections.ts +21 -20
- package/src/theme-editor/types.ts +1 -1
- package/src/theme-editor/webmcp/index.ts +1 -1
- package/src/theme-editor/webmcp/summary.ts +1 -2
- package/src/theme-editor/webmcp/tools.ts +30 -30
- package/src/theme-editor/webmcp/types.ts +2 -2
- package/src/theme-editor-preview.ts +10 -0
- package/src/theme-reference.ts +26 -26
- package/src/types.ts +368 -99
- package/src/ui.approval-plugin.test.ts +3 -3
- package/src/ui.ask-user-question-plugin.test.ts +9 -9
- package/src/ui.component-directive.test.ts +4 -4
- package/src/ui.composer-bar.test.ts +10 -11
- package/src/ui.composer-keyboard.test.ts +5 -5
- package/src/ui.header-icon-color.test.ts +59 -0
- package/src/ui.scroll.test.ts +5 -6
- package/src/ui.stop-button.test.ts +3 -4
- package/src/ui.suggest-replies.test.ts +2 -2
- package/src/ui.ts +292 -131
- package/src/utils/buttons.ts +1 -1
- package/src/utils/code-generators.ts +1 -1
- package/src/utils/composer-history.ts +3 -3
- package/src/utils/dom-context.test.ts +2 -2
- package/src/utils/dom-context.ts +7 -7
- package/src/utils/dom.test.ts +67 -0
- package/src/utils/dom.ts +75 -0
- package/src/utils/dropdown.ts +2 -2
- package/src/utils/event-stream-buffer.test.ts +2 -2
- package/src/utils/message-fingerprint.test.ts +9 -0
- package/src/utils/message-fingerprint.ts +5 -0
- package/src/utils/morph.ts +1 -1
- package/src/utils/sanitize.ts +32 -16
- package/src/utils/sequence-buffer.test.ts +8 -8
- package/src/utils/sequence-buffer.ts +4 -4
- package/src/utils/smart-dom-adapter.test.ts +1 -1
- package/src/utils/smart-dom-adapter.ts +4 -5
- package/src/utils/speech-text.test.ts +122 -0
- package/src/utils/speech-text.ts +101 -0
- package/src/utils/stream-animation.test.ts +3 -3
- package/src/utils/stream-animation.ts +6 -6
- package/src/utils/theme.test.ts +1 -1
- package/src/utils/throughput-tracker.test.ts +11 -11
- package/src/utils/throughput-tracker.ts +9 -9
- package/src/utils/tokens.ts +13 -13
- package/src/utils/virtual-scroller.ts +1 -1
- package/src/vendor/smart-dom-reader/README.md +4 -4
- package/src/vendor/smart-dom-reader/index.d.ts +1 -1
- package/src/vendor/smart-dom-reader/index.js +2 -2
- package/src/version.ts +1 -1
- package/src/voice/audio-playback-manager.test.ts +159 -0
- package/src/voice/audio-playback-manager.ts +145 -30
- package/src/voice/browser-speech-engine.ts +130 -0
- package/src/voice/fallback-speech-engine.ts +89 -0
- package/src/voice/index.ts +21 -0
- package/src/voice/read-aloud-controller.test.ts +143 -0
- package/src/voice/read-aloud-controller.ts +136 -0
- package/src/voice/runtype-speech-engine.test.ts +280 -0
- package/src/voice/runtype-speech-engine.ts +211 -0
- package/src/voice/runtype-tts-entry.ts +10 -0
- package/src/voice/runtype-tts-loader.test.ts +47 -0
- package/src/voice/runtype-tts-loader.ts +42 -0
- package/src/voice/runtype-voice-provider.ts +332 -537
- package/src/voice/voice-factory.ts +26 -4
- package/src/voice/voice.test.ts +321 -7
- package/src/voice/worklet-playback-engine.ts +272 -0
- package/src/voice-worklet-player.ts +39 -0
- package/src/webmcp-bridge.test.ts +6 -6
- package/src/webmcp-bridge.ts +24 -25
- package/src/webmcp-polyfill.ts +1 -1
- package/src/voice/voice-activity-detector.ts +0 -90
package/dist/theme-editor.d.cts
CHANGED
|
@@ -529,7 +529,7 @@ interface AgentWidgetPlugin {
|
|
|
529
529
|
defaultRenderer: () => HTMLElement;
|
|
530
530
|
onSubmit: (text: string) => void;
|
|
531
531
|
/**
|
|
532
|
-
* When true, the assistant stream is active
|
|
532
|
+
* When true, the assistant stream is active: same moment `session.isStreaming()` becomes true.
|
|
533
533
|
* Prefer wiring controls to `data-persona-composer-disable-when-streaming` plus `setComposerDisabled`
|
|
534
534
|
* in the host, or react to `footer.dataset.personaComposerStreaming === "true"`.
|
|
535
535
|
*/
|
|
@@ -578,14 +578,14 @@ interface AgentWidgetPlugin {
|
|
|
578
578
|
* Custom renderer for `ask_user_question` tool calls.
|
|
579
579
|
*
|
|
580
580
|
* When a plugin returns an `HTMLElement`, it is inserted into the transcript
|
|
581
|
-
* in place of the default (which is no transcript bubble
|
|
581
|
+
* in place of the default (which is no transcript bubble: the built-in
|
|
582
582
|
* renders a sheet over the composer). The built-in composer-overlay sheet
|
|
583
583
|
* is suppressed so the plugin's UI fully owns the interaction.
|
|
584
584
|
*
|
|
585
585
|
* Return `null` to fall through to the built-in overlay sheet.
|
|
586
586
|
*
|
|
587
587
|
* The context gives you a pre-parsed `payload` (may be partial while the
|
|
588
|
-
* tool call is still streaming
|
|
588
|
+
* tool call is still streaming: check `complete`) and two callbacks:
|
|
589
589
|
* `resolve(answer)` resumes the paused LOCAL tool with the user's answer,
|
|
590
590
|
* and `dismiss()` cancels with the sentinel `"(dismissed)"`.
|
|
591
591
|
*
|
|
@@ -634,8 +634,8 @@ interface AgentWidgetPlugin {
|
|
|
634
634
|
*
|
|
635
635
|
* Return an `HTMLElement` to fully own the approval UI, `defaultRenderer()`
|
|
636
636
|
* to render (or wrap) the built-in bubble, or `null` to fall through to the
|
|
637
|
-
* default. Unlike the built-in bubble
|
|
638
|
-
* via delegation
|
|
637
|
+
* default. Unlike the built-in bubble: whose Approve/Deny buttons are wired
|
|
638
|
+
* via delegation: a fully custom element resolves the approval by calling
|
|
639
639
|
* the `approve`/`deny` callbacks. Both route through the same path the
|
|
640
640
|
* built-in buttons use (optimistic update, `onDecision`, in-place anchoring).
|
|
641
641
|
*
|
|
@@ -1026,6 +1026,7 @@ type RuntypeFlowSSEEvent = {
|
|
|
1026
1026
|
totalSteps?: number;
|
|
1027
1027
|
type: "flow_start";
|
|
1028
1028
|
} | {
|
|
1029
|
+
claudeManagedAgentId?: string;
|
|
1029
1030
|
completedAt?: string;
|
|
1030
1031
|
completedSteps?: number;
|
|
1031
1032
|
duration?: number;
|
|
@@ -1140,6 +1141,7 @@ type RuntypeFlowSSEEvent = {
|
|
|
1140
1141
|
toolId: string;
|
|
1141
1142
|
};
|
|
1142
1143
|
type: "step_complete";
|
|
1144
|
+
unresolvedVariables?: Array<string>;
|
|
1143
1145
|
}) | {
|
|
1144
1146
|
error: string;
|
|
1145
1147
|
executionId?: string;
|
|
@@ -1473,7 +1475,7 @@ type AgentConfig = {
|
|
|
1473
1475
|
temperature?: number;
|
|
1474
1476
|
/** Tool configuration for the agent */
|
|
1475
1477
|
tools?: AgentToolsConfig;
|
|
1476
|
-
/** Persona artifacts
|
|
1478
|
+
/** Persona artifacts: sibling of tools (virtual agent / API parity) */
|
|
1477
1479
|
artifacts?: ArtifactConfigPayload;
|
|
1478
1480
|
/** Loop configuration for multi-turn execution */
|
|
1479
1481
|
loopConfig?: AgentLoopConfig;
|
|
@@ -1495,7 +1497,7 @@ type AgentRequestOptions = {
|
|
|
1495
1497
|
* Wire shape for a single client-discovered tool sent on `dispatch.clientTools[]`.
|
|
1496
1498
|
*
|
|
1497
1499
|
* Mirrors the SDK's `ClientToolDefinition` in `@runtypelabs/sdk`. Only the
|
|
1498
|
-
* JSON-serializable surface of a WebMCP tool
|
|
1500
|
+
* JSON-serializable surface of a WebMCP tool: the `execute` function stays
|
|
1499
1501
|
* client-side; the server merges these into the agent's tool catalog under
|
|
1500
1502
|
* the `webmcp:` namespace.
|
|
1501
1503
|
*/
|
|
@@ -1503,16 +1505,16 @@ type ClientToolDefinition = {
|
|
|
1503
1505
|
/** Bare tool name; the server prepends `webmcp:` on the wire. */
|
|
1504
1506
|
name: string;
|
|
1505
1507
|
description: string;
|
|
1506
|
-
/** JSON Schema (per WebMCP spec)
|
|
1508
|
+
/** JSON Schema (per WebMCP spec): passed through as-is. */
|
|
1507
1509
|
parametersSchema?: object;
|
|
1508
1510
|
/**
|
|
1509
1511
|
* `'webmcp'` for tools discovered via the polyfill (server prepends the
|
|
1510
1512
|
* `webmcp:` wire prefix); `'sdk'` for widget/SDK-provided tools (name stays
|
|
1511
|
-
* bare on the wire). Matches the server's accepted enum
|
|
1513
|
+
* bare on the wire). Matches the server's accepted enum: any other value
|
|
1512
1514
|
* fails dispatch validation.
|
|
1513
1515
|
*/
|
|
1514
1516
|
origin?: 'webmcp' | 'sdk';
|
|
1515
|
-
/** Origin of the page that registered the tool
|
|
1517
|
+
/** Origin of the page that registered the tool: for server-side audit. */
|
|
1516
1518
|
pageOrigin?: string;
|
|
1517
1519
|
/**
|
|
1518
1520
|
* WebMCP `Tool.annotations` (spec). Not used for gating server-side; the
|
|
@@ -1544,7 +1546,7 @@ type WebMcpConfirmInfo = {
|
|
|
1544
1546
|
untrustedContentHint?: boolean;
|
|
1545
1547
|
};
|
|
1546
1548
|
/**
|
|
1547
|
-
* Why the confirm was requested. Currently always `'gate'
|
|
1549
|
+
* Why the confirm was requested. Currently always `'gate'`: the default
|
|
1548
1550
|
* confirm-by-default gate that fires before every `webmcp:*` call. (The
|
|
1549
1551
|
* `@mcp-b/webmcp-polyfill` owns the spec's `requestUserInteraction` callback
|
|
1550
1552
|
* internally, so Persona no longer surfaces a nested in-tool confirm.)
|
|
@@ -1558,7 +1560,7 @@ type WebMcpConfirmHandler = (info: WebMcpConfirmInfo) => Promise<boolean>;
|
|
|
1558
1560
|
/**
|
|
1559
1561
|
* Widget-level WebMCP configuration. Set `enabled: true` to opt in. The
|
|
1560
1562
|
* surface's server-side `webmcp` policy is the source of truth for which
|
|
1561
|
-
* tools are accepted
|
|
1563
|
+
* tools are accepted: these client-side options are convenience filters.
|
|
1562
1564
|
*/
|
|
1563
1565
|
type AgentWidgetWebMcpConfig = {
|
|
1564
1566
|
/** Master switch. Default: `false` (widget never installs the polyfill). */
|
|
@@ -1574,7 +1576,7 @@ type AgentWidgetWebMcpConfig = {
|
|
|
1574
1576
|
* `webmcp:*` call; return `true` to approve immediately and skip the
|
|
1575
1577
|
* confirmation UI entirely. Use this to auto-allow read-only tools (e.g.
|
|
1576
1578
|
* a catalog search) while still gating mutating ones. Only consulted on
|
|
1577
|
-
* the default-UI path
|
|
1579
|
+
* the default-UI path: a custom `onConfirm` takes full control instead.
|
|
1578
1580
|
*/
|
|
1579
1581
|
autoApprove?: (info: WebMcpConfirmInfo) => boolean;
|
|
1580
1582
|
/**
|
|
@@ -1617,7 +1619,7 @@ type AgentMessageMetadata = {
|
|
|
1617
1619
|
* `flow_await` events for a LOCAL tool (core#3878). Present only when the
|
|
1618
1620
|
* server emits it. Two PARALLEL calls to the same tool in one turn share a
|
|
1619
1621
|
* `toolName` (and a collapsed `toolId`) but get DISTINCT `webMcpToolCallId`s,
|
|
1620
|
-
* so this is the key the widget batches a single `/resume` on
|
|
1622
|
+
* so this is the key the widget batches a single `/resume` on: preferred
|
|
1621
1623
|
* over tool name, which collides for same-tool parallel calls. Absent →
|
|
1622
1624
|
* fall back to the legacy name-keyed resume contract.
|
|
1623
1625
|
*/
|
|
@@ -1702,15 +1704,6 @@ interface AgentWidgetStorageAdapter {
|
|
|
1702
1704
|
save?: (state: AgentWidgetStoredState) => void | Promise<void>;
|
|
1703
1705
|
clear?: () => void | Promise<void>;
|
|
1704
1706
|
}
|
|
1705
|
-
type AgentWidgetVoiceStateEvent = {
|
|
1706
|
-
active: boolean;
|
|
1707
|
-
source: "user" | "auto" | "restore" | "system";
|
|
1708
|
-
timestamp: number;
|
|
1709
|
-
};
|
|
1710
|
-
type AgentWidgetActionEventPayload = {
|
|
1711
|
-
action: AgentWidgetParsedAction;
|
|
1712
|
-
message: AgentWidgetMessage;
|
|
1713
|
-
};
|
|
1714
1707
|
/**
|
|
1715
1708
|
* Feedback event payload for upvote/downvote actions on messages
|
|
1716
1709
|
*/
|
|
@@ -1762,6 +1755,14 @@ type AgentWidgetMessageActionsConfig = {
|
|
|
1762
1755
|
* @default false
|
|
1763
1756
|
*/
|
|
1764
1757
|
showDownvote?: boolean;
|
|
1758
|
+
/**
|
|
1759
|
+
* Show a "Read aloud" button that speaks the assistant message via
|
|
1760
|
+
* text-to-speech (play / pause / resume). Uses the browser Web Speech API by
|
|
1761
|
+
* default, or a hosted engine supplied via `textToSpeech.createEngine`.
|
|
1762
|
+
* Voice, rate and pitch are read from the `textToSpeech` config.
|
|
1763
|
+
* @default false
|
|
1764
|
+
*/
|
|
1765
|
+
showReadAloud?: boolean;
|
|
1765
1766
|
/**
|
|
1766
1767
|
* Visibility mode: 'always' shows buttons always, 'hover' shows on hover only
|
|
1767
1768
|
* @default 'hover'
|
|
@@ -1796,44 +1797,6 @@ type AgentWidgetMessageActionsConfig = {
|
|
|
1796
1797
|
*/
|
|
1797
1798
|
onCopy?: (message: AgentWidgetMessage) => void;
|
|
1798
1799
|
};
|
|
1799
|
-
type AgentWidgetStateEvent = {
|
|
1800
|
-
open: boolean;
|
|
1801
|
-
source: "user" | "auto" | "api" | "system";
|
|
1802
|
-
timestamp: number;
|
|
1803
|
-
};
|
|
1804
|
-
type AgentWidgetStateSnapshot = {
|
|
1805
|
-
open: boolean;
|
|
1806
|
-
launcherEnabled: boolean;
|
|
1807
|
-
voiceActive: boolean;
|
|
1808
|
-
streaming: boolean;
|
|
1809
|
-
};
|
|
1810
|
-
type AgentWidgetControllerEventMap = {
|
|
1811
|
-
"user:message": AgentWidgetMessage;
|
|
1812
|
-
"assistant:message": AgentWidgetMessage;
|
|
1813
|
-
"assistant:complete": AgentWidgetMessage;
|
|
1814
|
-
"voice:state": AgentWidgetVoiceStateEvent;
|
|
1815
|
-
"action:detected": AgentWidgetActionEventPayload;
|
|
1816
|
-
"action:resubmit": AgentWidgetActionEventPayload;
|
|
1817
|
-
"widget:opened": AgentWidgetStateEvent;
|
|
1818
|
-
"widget:closed": AgentWidgetStateEvent;
|
|
1819
|
-
"widget:state": AgentWidgetStateSnapshot;
|
|
1820
|
-
"message:feedback": AgentWidgetMessageFeedback;
|
|
1821
|
-
"message:copy": AgentWidgetMessage;
|
|
1822
|
-
"eventStream:opened": {
|
|
1823
|
-
timestamp: number;
|
|
1824
|
-
};
|
|
1825
|
-
"eventStream:closed": {
|
|
1826
|
-
timestamp: number;
|
|
1827
|
-
};
|
|
1828
|
-
"approval:requested": {
|
|
1829
|
-
approval: AgentWidgetApproval;
|
|
1830
|
-
message: AgentWidgetMessage;
|
|
1831
|
-
};
|
|
1832
|
-
"approval:resolved": {
|
|
1833
|
-
approval: AgentWidgetApproval;
|
|
1834
|
-
decision: string;
|
|
1835
|
-
};
|
|
1836
|
-
};
|
|
1837
1800
|
/**
|
|
1838
1801
|
* Layout for the artifact split / drawer (CSS lengths unless noted).
|
|
1839
1802
|
*
|
|
@@ -1874,8 +1837,8 @@ type AgentWidgetArtifactsLayoutConfig = {
|
|
|
1874
1837
|
resizableMaxWidth?: string;
|
|
1875
1838
|
/**
|
|
1876
1839
|
* Visual treatment for the artifact column in split mode.
|
|
1877
|
-
* - `'panel'
|
|
1878
|
-
* - `'seamless'
|
|
1840
|
+
* - `'panel'`: bordered sidebar with left border, gap, and shadow (default).
|
|
1841
|
+
* - `'seamless'`: flush with chat: no border or shadow, container background, zero gap.
|
|
1879
1842
|
* @default 'panel'
|
|
1880
1843
|
*/
|
|
1881
1844
|
paneAppearance?: "panel" | "seamless";
|
|
@@ -1889,7 +1852,7 @@ type AgentWidgetArtifactsLayoutConfig = {
|
|
|
1889
1852
|
*/
|
|
1890
1853
|
paneBorder?: string;
|
|
1891
1854
|
/**
|
|
1892
|
-
* `border-left` shorthand only
|
|
1855
|
+
* `border-left` shorthand only: typical for split view next to chat (with or without resizer).
|
|
1893
1856
|
* Ignored if `paneBorder` is set. Example: `"1px solid #cccccc"`.
|
|
1894
1857
|
*/
|
|
1895
1858
|
paneBorderLeft?: string;
|
|
@@ -1916,8 +1879,8 @@ type AgentWidgetArtifactsLayoutConfig = {
|
|
|
1916
1879
|
panePadding?: string;
|
|
1917
1880
|
/**
|
|
1918
1881
|
* Toolbar layout preset.
|
|
1919
|
-
* - `default
|
|
1920
|
-
* - `document
|
|
1882
|
+
* - `default`: "Artifacts" title, horizontal tabs, text close.
|
|
1883
|
+
* - `document`: view/source toggle, document title, copy / refresh / close; tab strip hidden when only one artifact.
|
|
1921
1884
|
* @default 'default'
|
|
1922
1885
|
*/
|
|
1923
1886
|
toolbarPreset?: "default" | "document";
|
|
@@ -1929,7 +1892,7 @@ type AgentWidgetArtifactsLayoutConfig = {
|
|
|
1929
1892
|
* When `toolbarPreset` is `document`, show a small chevron after the copy control (e.g. menu affordance).
|
|
1930
1893
|
*/
|
|
1931
1894
|
documentToolbarShowCopyChevron?: boolean;
|
|
1932
|
-
/** Document toolbar icon buttons (view, code, copy, refresh, close)
|
|
1895
|
+
/** Document toolbar icon buttons (view, code, copy, refresh, close): CSS color. Sets `--persona-artifact-doc-toolbar-icon-color` on the widget root. */
|
|
1933
1896
|
documentToolbarIconColor?: string;
|
|
1934
1897
|
/** Active view/source toggle background. Sets `--persona-artifact-doc-toggle-active-bg`. */
|
|
1935
1898
|
documentToolbarToggleActiveBackground?: string;
|
|
@@ -2073,11 +2036,11 @@ type AgentWidgetToolCallDisplayFeature = {
|
|
|
2073
2036
|
expandable?: boolean;
|
|
2074
2037
|
/**
|
|
2075
2038
|
* Animation mode applied to the tool call header text while the tool is active.
|
|
2076
|
-
* - "none"
|
|
2077
|
-
* - "pulse"
|
|
2078
|
-
* - "shimmer"
|
|
2079
|
-
* - "shimmer-color"
|
|
2080
|
-
* - "rainbow"
|
|
2039
|
+
* - "none": static text, no animation
|
|
2040
|
+
* - "pulse": opacity pulse on the entire header text
|
|
2041
|
+
* - "shimmer": monochrome opacity sweep per character
|
|
2042
|
+
* - "shimmer-color": color gradient sweep per character
|
|
2043
|
+
* - "rainbow": rainbow color cycle per character
|
|
2081
2044
|
* @default "none"
|
|
2082
2045
|
*/
|
|
2083
2046
|
loadingAnimation?: AgentWidgetToolCallLoadingAnimation;
|
|
@@ -2106,11 +2069,11 @@ type AgentWidgetReasoningDisplayFeature = {
|
|
|
2106
2069
|
/**
|
|
2107
2070
|
* Animation mode applied to the reasoning header text while reasoning is active.
|
|
2108
2071
|
* Reuses the same modes as tool call animations.
|
|
2109
|
-
* - "none"
|
|
2110
|
-
* - "pulse"
|
|
2111
|
-
* - "shimmer"
|
|
2112
|
-
* - "shimmer-color"
|
|
2113
|
-
* - "rainbow"
|
|
2072
|
+
* - "none": static text, no animation
|
|
2073
|
+
* - "pulse": opacity pulse on the entire header text
|
|
2074
|
+
* - "shimmer": monochrome opacity sweep per character
|
|
2075
|
+
* - "shimmer-color": color gradient sweep per character
|
|
2076
|
+
* - "rainbow": rainbow color cycle per character
|
|
2114
2077
|
* @default "none"
|
|
2115
2078
|
*/
|
|
2116
2079
|
loadingAnimation?: AgentWidgetToolCallLoadingAnimation;
|
|
@@ -2119,34 +2082,34 @@ type AgentWidgetReasoningDisplayFeature = {
|
|
|
2119
2082
|
* Reveal animation applied to assistant message text while it is streaming.
|
|
2120
2083
|
*
|
|
2121
2084
|
* Built-in types always available:
|
|
2122
|
-
* - `none
|
|
2123
|
-
* - `typewriter
|
|
2124
|
-
* - `pop-bubble
|
|
2125
|
-
* - `letter-rise
|
|
2126
|
-
* - `word-fade
|
|
2085
|
+
* - `none`: text appears as tokens arrive (default).
|
|
2086
|
+
* - `typewriter`: characters fade in with a blinking caret.
|
|
2087
|
+
* - `pop-bubble`: the bubble scales in; text streams normally afterward.
|
|
2088
|
+
* - `letter-rise`: per-char translateY + fade reveal.
|
|
2089
|
+
* - `word-fade`: per-word blur + translateY fade-in.
|
|
2127
2090
|
*
|
|
2128
2091
|
* Subpath plugins (import from `@runtypelabs/persona/animations/*` to register):
|
|
2129
2092
|
* - `wipe`, `glyph-cycle`.
|
|
2130
2093
|
*
|
|
2131
|
-
* Custom types are allowed
|
|
2094
|
+
* Custom types are allowed: register a plugin with any string name and
|
|
2132
2095
|
* reference it by that name in `type`.
|
|
2133
2096
|
*/
|
|
2134
2097
|
type AgentWidgetStreamAnimationBuiltinType = "none" | "typewriter" | "word-fade" | "letter-rise" | "glyph-cycle" | "wipe" | "pop-bubble";
|
|
2135
2098
|
type AgentWidgetStreamAnimationType = AgentWidgetStreamAnimationBuiltinType | (string & {});
|
|
2136
2099
|
/**
|
|
2137
2100
|
* Placeholder shown inside a streaming assistant bubble before the first token arrives.
|
|
2138
|
-
* - `none
|
|
2139
|
-
* - `skeleton
|
|
2101
|
+
* - `none`: use the default typing-dots indicator (existing behavior).
|
|
2102
|
+
* - `skeleton`: shimmer bars, replaced by streaming content once it starts.
|
|
2140
2103
|
*/
|
|
2141
2104
|
type AgentWidgetStreamAnimationPlaceholder = "none" | "skeleton";
|
|
2142
2105
|
/**
|
|
2143
2106
|
* How much of the accumulated streaming content to display while tokens are
|
|
2144
2107
|
* still arriving. Trimming to a boundary means in-progress words or lines
|
|
2145
|
-
* stay hidden until they complete
|
|
2108
|
+
* stay hidden until they complete: useful for animations that benefit from
|
|
2146
2109
|
* unit-complete reveals (e.g. wipe, glyph-cycle).
|
|
2147
|
-
* - `none
|
|
2148
|
-
* - `word
|
|
2149
|
-
* - `line
|
|
2110
|
+
* - `none`: show every character as it arrives (default).
|
|
2111
|
+
* - `word`: trim to the last whitespace boundary.
|
|
2112
|
+
* - `line`: trim to the last newline boundary.
|
|
2150
2113
|
*/
|
|
2151
2114
|
type AgentWidgetStreamAnimationBuffer = "none" | "word" | "line";
|
|
2152
2115
|
/**
|
|
@@ -2177,7 +2140,7 @@ type StreamAnimationContext = {
|
|
|
2177
2140
|
* widget's style host.
|
|
2178
2141
|
* - For each streaming assistant message whose `type` matches `name`, the
|
|
2179
2142
|
* widget applies `containerClass` / `bubbleClass`, wraps text per `wrap`,
|
|
2180
|
-
* and
|
|
2143
|
+
* and, if `useCaret` is true, appends a blinking caret.
|
|
2181
2144
|
* - Hooks fire after the live DOM is morphed; plugins use stable element IDs
|
|
2182
2145
|
* and `data-preserve-animation` to safely mutate per-char or per-word spans
|
|
2183
2146
|
* without idiomorph clobbering in-flight work.
|
|
@@ -2193,7 +2156,7 @@ type StreamAnimationPlugin = {
|
|
|
2193
2156
|
wrap?: "none" | "char" | "word";
|
|
2194
2157
|
/**
|
|
2195
2158
|
* HTML tags whose descendant text is skipped during wrapping. Defaults to
|
|
2196
|
-
* `["pre", "code", "a", "script", "style"]
|
|
2159
|
+
* `["pre", "code", "a", "script", "style"]`: useful for keeping code
|
|
2197
2160
|
* blocks legible and link click-targets intact. Plugins that want to
|
|
2198
2161
|
* animate characters inside inline code (e.g. `glyph-cycle`) can narrow
|
|
2199
2162
|
* the list.
|
|
@@ -2222,8 +2185,7 @@ type StreamAnimationPlugin = {
|
|
|
2222
2185
|
/**
|
|
2223
2186
|
* Report whether the plugin still has in-flight animation work for a
|
|
2224
2187
|
* message. When `true`, the widget keeps rendering the message in its
|
|
2225
|
-
* "streaming-animated" mode even after `message.streaming` flips false
|
|
2226
|
-
* preventing the final non-animated render from yanking the rug out from
|
|
2188
|
+
* "streaming-animated" mode even after `message.streaming` flips false: * preventing the final non-animated render from yanking the rug out from
|
|
2227
2189
|
* under unfinished per-char cycles or reveals.
|
|
2228
2190
|
*/
|
|
2229
2191
|
isAnimating?: (message: AgentWidgetMessage) => boolean;
|
|
@@ -2236,7 +2198,7 @@ type AgentWidgetStreamAnimationFeature = {
|
|
|
2236
2198
|
/**
|
|
2237
2199
|
* Per-unit animation duration (ms) for `typewriter`, `letter-rise`, `word-fade`,
|
|
2238
2200
|
* and per-unit plugin animations. Each arriving character/word animates from
|
|
2239
|
-
* invisible to visible over this duration, independent of its position
|
|
2201
|
+
* invisible to visible over this duration, independent of its position: the
|
|
2240
2202
|
* streaming cadence itself provides the visible stagger.
|
|
2241
2203
|
* @default 120
|
|
2242
2204
|
*/
|
|
@@ -2296,7 +2258,7 @@ type AgentWidgetFeatureFlags = {
|
|
|
2296
2258
|
* Built-in `suggest_replies` quick-reply chips. When the assistant invokes
|
|
2297
2259
|
* the tool, the widget shows the suggestions as tappable chips above the
|
|
2298
2260
|
* composer (reusing the suggestion-chips surface) and immediately resumes
|
|
2299
|
-
* the execution
|
|
2261
|
+
* the execution: fire-and-forget, no user input awaited.
|
|
2300
2262
|
*/
|
|
2301
2263
|
suggestReplies?: AgentWidgetSuggestRepliesFeature;
|
|
2302
2264
|
};
|
|
@@ -2310,14 +2272,14 @@ type AgentWidgetFeatureFlags = {
|
|
|
2310
2272
|
type AgentWidgetSuggestRepliesFeature = {
|
|
2311
2273
|
/**
|
|
2312
2274
|
* Enable the feature. Defaults to true. When false, `suggest_replies`
|
|
2313
|
-
* renders as a regular tool bubble and is NOT auto-resumed
|
|
2275
|
+
* renders as a regular tool bubble and is NOT auto-resumed: only set this
|
|
2314
2276
|
* with no server-side `suggest_replies` declaration, or the execution
|
|
2315
2277
|
* parks awaiting a resume that never comes.
|
|
2316
2278
|
*/
|
|
2317
2279
|
enabled?: boolean;
|
|
2318
2280
|
/**
|
|
2319
2281
|
* Advertise the built-in `suggest_replies` tool to the agent on every
|
|
2320
|
-
* dispatch via `clientTools[]
|
|
2282
|
+
* dispatch via `clientTools[]`: no server-side `runtimeTools` declaration
|
|
2321
2283
|
* needed. Defaults to `false`: flows that already declare the tool via
|
|
2322
2284
|
* `runtimeTools` would otherwise present it to the model twice. Ignored
|
|
2323
2285
|
* when `enabled` is `false`.
|
|
@@ -2333,7 +2295,7 @@ type AskUserQuestionOption = {
|
|
|
2333
2295
|
label: string;
|
|
2334
2296
|
/** Optional long-form description (shown as a subtitle on tap-hover). */
|
|
2335
2297
|
description?: string;
|
|
2336
|
-
/** Optional rich preview
|
|
2298
|
+
/** Optional rich preview: reserved for future rendering; ignored in v1. */
|
|
2337
2299
|
preview?: string;
|
|
2338
2300
|
};
|
|
2339
2301
|
/**
|
|
@@ -2385,14 +2347,14 @@ type AgentWidgetAskUserQuestionFeature = {
|
|
|
2385
2347
|
enabled?: boolean;
|
|
2386
2348
|
/**
|
|
2387
2349
|
* Advertise the built-in `ask_user_question` tool to the agent on every
|
|
2388
|
-
* dispatch via `clientTools[]
|
|
2350
|
+
* dispatch via `clientTools[]`: no server-side `runtimeTools` declaration
|
|
2389
2351
|
* needed. The tool ships with a model-facing description and JSON schema
|
|
2390
2352
|
* matching {@link AskUserQuestionPayload}; when the model calls it, the
|
|
2391
2353
|
* existing answer-pill sheet renders and the answer resumes the execution.
|
|
2392
2354
|
*
|
|
2393
2355
|
* Defaults to `false`: flows that already declare `ask_user_question` via
|
|
2394
2356
|
* `runtimeTools` would otherwise present the tool to the model twice.
|
|
2395
|
-
* Ignored when `enabled` is `false
|
|
2357
|
+
* Ignored when `enabled` is `false`: never offer the agent a question
|
|
2396
2358
|
* tool the widget can't render an answer UI for.
|
|
2397
2359
|
*/
|
|
2398
2360
|
expose?: boolean;
|
|
@@ -2413,17 +2375,17 @@ type AgentWidgetAskUserQuestionFeature = {
|
|
|
2413
2375
|
/**
|
|
2414
2376
|
* In grouped (multi-question) mode, auto-advance to the next page after a
|
|
2415
2377
|
* single-select pill pick or free-text submit on intermediate pages.
|
|
2416
|
-
* Defaults to `true`. The final page never auto-submits
|
|
2378
|
+
* Defaults to `true`. The final page never auto-submits: users always
|
|
2417
2379
|
* confirm with an explicit "Submit all" click. Multi-select pages always
|
|
2418
2380
|
* require an explicit Next regardless of this setting.
|
|
2419
2381
|
*/
|
|
2420
2382
|
groupedAutoAdvance?: boolean;
|
|
2421
2383
|
/**
|
|
2422
2384
|
* Visual layout for the option list.
|
|
2423
|
-
* - `"rows"` (default)
|
|
2385
|
+
* - `"rows"` (default): full-width stacked rows with always-visible
|
|
2424
2386
|
* descriptions, right-edge number badges (single-select) or checkboxes
|
|
2425
2387
|
* (multi-select), and an always-visible inline "Other" input.
|
|
2426
|
-
* - `"pills"
|
|
2388
|
+
* - `"pills"`: legacy compact pill list with horizontal wrap; description
|
|
2427
2389
|
* surfaces as a tooltip and the "Other…" pill expands on click.
|
|
2428
2390
|
*/
|
|
2429
2391
|
layout?: "rows" | "pills";
|
|
@@ -2591,7 +2553,7 @@ type AgentWidgetDockConfig = {
|
|
|
2591
2553
|
*
|
|
2592
2554
|
* - Set a CSS length (e.g. `"600px"`, `"80vh"`) to override the cap.
|
|
2593
2555
|
* - Set `false` to disable the guard entirely (the panel then sizes purely
|
|
2594
|
-
* from the surrounding layout
|
|
2556
|
+
* from the surrounding layout: make sure your page provides a definite
|
|
2595
2557
|
* height all the way down to the dock target's parent).
|
|
2596
2558
|
*
|
|
2597
2559
|
* @default "100dvh"
|
|
@@ -2665,7 +2627,7 @@ type AgentWidgetComposerBarConfig = {
|
|
|
2665
2627
|
*/
|
|
2666
2628
|
modalMaxHeight?: string;
|
|
2667
2629
|
/**
|
|
2668
|
-
* Configuration for the "peek" banner
|
|
2630
|
+
* Configuration for the "peek" banner: the chrome-less row above the
|
|
2669
2631
|
* collapsed pill that previews the most recent assistant message.
|
|
2670
2632
|
*/
|
|
2671
2633
|
peek?: AgentWidgetComposerBarPeekConfig;
|
|
@@ -2680,7 +2642,7 @@ type AgentWidgetComposerBarConfig = {
|
|
|
2680
2642
|
* - Otherwise the peek inherits from `features.streamAnimation`.
|
|
2681
2643
|
*
|
|
2682
2644
|
* Per-surface carve-outs:
|
|
2683
|
-
* - `bubbleClass` from a plugin (used by `pop-bubble`) is ignored
|
|
2645
|
+
* - `bubbleClass` from a plugin (used by `pop-bubble`) is ignored: the peek
|
|
2684
2646
|
* has no bubble analog.
|
|
2685
2647
|
* - `containerClass`, `wrap` ("char" | "word"), `useCaret`, `placeholder`
|
|
2686
2648
|
* ("skeleton"), `buffer` ("word" | "line"), `speed`, `duration`, and
|
|
@@ -2926,6 +2888,11 @@ type AgentWidgetVoiceRecognitionConfig = {
|
|
|
2926
2888
|
/** Button border color while speaking. Inherits idle borderColor if not set */
|
|
2927
2889
|
speakingBorderColor?: string;
|
|
2928
2890
|
autoResume?: boolean | "assistant";
|
|
2891
|
+
/**
|
|
2892
|
+
* Called with per-turn latency metrics on the realtime (`runtype`) voice path.
|
|
2893
|
+
* Fires once per turn after the reply completes.
|
|
2894
|
+
*/
|
|
2895
|
+
onMetrics?: (metrics: VoiceMetrics) => void;
|
|
2929
2896
|
provider?: {
|
|
2930
2897
|
type: 'browser' | 'runtype' | 'custom';
|
|
2931
2898
|
browser?: {
|
|
@@ -2934,15 +2901,31 @@ type AgentWidgetVoiceRecognitionConfig = {
|
|
|
2934
2901
|
};
|
|
2935
2902
|
runtype?: {
|
|
2936
2903
|
agentId: string;
|
|
2937
|
-
clientToken
|
|
2904
|
+
/** Defaults to the widget's `clientToken` when omitted. */
|
|
2905
|
+
clientToken?: string;
|
|
2906
|
+
/** Defaults to the widget's `apiUrl` when omitted. */
|
|
2938
2907
|
host?: string;
|
|
2939
2908
|
voiceId?: string;
|
|
2940
|
-
/**
|
|
2909
|
+
/**
|
|
2910
|
+
* Optional custom streaming playback engine. Defaults to the built-in
|
|
2911
|
+
* `AudioPlaybackManager`. Import `createWorkletPlaybackEngine` from
|
|
2912
|
+
* `@runtypelabs/persona/voice-worklet-player` for a jitter-buffered engine.
|
|
2913
|
+
*/
|
|
2914
|
+
createPlaybackEngine?: () => VoicePlaybackEngine | Promise<VoicePlaybackEngine>;
|
|
2915
|
+
/** @deprecated No-op on the realtime path: the server's STT owns turn-taking. */
|
|
2941
2916
|
pauseDuration?: number;
|
|
2942
|
-
/**
|
|
2917
|
+
/** @deprecated No-op on the realtime path: the server's STT owns turn-taking. */
|
|
2943
2918
|
silenceThreshold?: number;
|
|
2944
2919
|
};
|
|
2945
|
-
|
|
2920
|
+
/**
|
|
2921
|
+
* Bring-your-own voice provider. Set `type: 'custom'` and pass either a
|
|
2922
|
+
* ready {@link VoiceProvider} instance or a `() => VoiceProvider` factory
|
|
2923
|
+
* (the factory defers construction until voice is set up). STT-style
|
|
2924
|
+
* providers deliver a final transcript via `onResult` (sent as a user
|
|
2925
|
+
* message); full-duplex providers can drive `onTranscript`/`onMetrics` like
|
|
2926
|
+
* the realtime `runtype` provider.
|
|
2927
|
+
*/
|
|
2928
|
+
custom?: VoiceProvider | (() => VoiceProvider);
|
|
2946
2929
|
};
|
|
2947
2930
|
};
|
|
2948
2931
|
/**
|
|
@@ -2965,18 +2948,68 @@ type TextToSpeechConfig = {
|
|
|
2965
2948
|
enabled: boolean;
|
|
2966
2949
|
/**
|
|
2967
2950
|
* TTS provider.
|
|
2968
|
-
* - `'browser'
|
|
2969
|
-
* - `'runtype'
|
|
2970
|
-
*
|
|
2951
|
+
* - `'browser'`: Use the Web Speech API for all assistant messages (default).
|
|
2952
|
+
* - `'runtype'`: Use Runtype-hosted TTS. The realtime voice path speaks
|
|
2953
|
+
* replies during a voice call, and the per-message "Read aloud" button (and
|
|
2954
|
+
* auto-speak of text-typed replies) stream from Runtype's
|
|
2955
|
+
* `POST {host}/v1/agents/:agentId/speak` endpoint via the built-in
|
|
2956
|
+
* {@link SpeechEngine}. `host`/`agentId`/`clientToken` are derived from the
|
|
2957
|
+
* widget config (see `agentId`/`host` below); unless `browserFallback` is
|
|
2958
|
+
* `false`, a missing endpoint or transient failure falls back to the browser
|
|
2959
|
+
* voice so the button is never broken.
|
|
2971
2960
|
*/
|
|
2972
2961
|
provider?: 'browser' | 'runtype';
|
|
2973
2962
|
/**
|
|
2974
|
-
* When `provider` is `'runtype'
|
|
2975
|
-
*
|
|
2963
|
+
* When `provider` is `'runtype'`:
|
|
2964
|
+
* - Read-aloud / auto-speak: acts as a safety net — if Runtype TTS is
|
|
2965
|
+
* unreachable (no endpoint yet, network/auth failure) or the Runtype config
|
|
2966
|
+
* is incomplete, speech falls back to the browser Web Speech API instead of
|
|
2967
|
+
* erroring. Set to `false` to surface Runtype errors instead. **Defaults to
|
|
2968
|
+
* on for this path.**
|
|
2969
|
+
* - Auto-speak of text-typed replies also requires this to be truthy (the
|
|
2970
|
+
* realtime voice path already speaks voice-call replies).
|
|
2971
|
+
*
|
|
2976
2972
|
* Has no effect when provider is `'browser'` (browser TTS is always used).
|
|
2977
|
-
* @default false
|
|
2978
2973
|
*/
|
|
2979
2974
|
browserFallback?: boolean;
|
|
2975
|
+
/**
|
|
2976
|
+
* When `provider` is `'runtype'`, the agent whose configured voice synthesizes
|
|
2977
|
+
* read-aloud / auto-speak audio. Falls back to
|
|
2978
|
+
* `voiceRecognition.provider.runtype.agentId` when omitted. Required (here or
|
|
2979
|
+
* there) for Runtype TTS to activate; without it the browser voice is used.
|
|
2980
|
+
*/
|
|
2981
|
+
agentId?: string;
|
|
2982
|
+
/**
|
|
2983
|
+
* When `provider` is `'runtype'`, the Runtype API host (e.g.
|
|
2984
|
+
* `https://api.runtype.com`). Defaults to the widget's `apiUrl`.
|
|
2985
|
+
*/
|
|
2986
|
+
host?: string;
|
|
2987
|
+
/**
|
|
2988
|
+
* When `provider` is `'runtype'`, audio (ms) the streaming player buffers
|
|
2989
|
+
* before the first sample and after an underrun. Lower = snappier start;
|
|
2990
|
+
* higher = rides out delivery hiccups. Default 200. Applies to the default
|
|
2991
|
+
* in-bundle player; a custom `createPlaybackEngine` manages its own prebuffer.
|
|
2992
|
+
*/
|
|
2993
|
+
prebufferMs?: number;
|
|
2994
|
+
/**
|
|
2995
|
+
* When `provider` is `'runtype'`, an optional factory for the streaming PCM
|
|
2996
|
+
* player that synthesizes read-aloud / auto-speak audio. Defaults to the
|
|
2997
|
+
* in-bundle, main-thread `AudioPlaybackManager` (smooth for steady Runtype
|
|
2998
|
+
* streams, no AudioWorklet — keeps the widget bundle lean).
|
|
2999
|
+
*
|
|
3000
|
+
* For the higher-quality, jitter-buffered AudioWorklet player, import
|
|
3001
|
+
* `createPcmStreamPlayer` from `@runtypelabs/persona/voice-worklet-player` and
|
|
3002
|
+
* pass it here — it then ships in your bundle, not Persona's:
|
|
3003
|
+
*
|
|
3004
|
+
* @example
|
|
3005
|
+
* import { createPcmStreamPlayer } from '@runtypelabs/persona/voice-worklet-player'
|
|
3006
|
+
* textToSpeech: {
|
|
3007
|
+
* enabled: true,
|
|
3008
|
+
* provider: 'runtype',
|
|
3009
|
+
* createPlaybackEngine: () => createPcmStreamPlayer({ prebufferMs: 400 }),
|
|
3010
|
+
* }
|
|
3011
|
+
*/
|
|
3012
|
+
createPlaybackEngine?: () => PcmStreamPlayer | Promise<PcmStreamPlayer>;
|
|
2980
3013
|
/** Voice name to use for browser TTS (e.g., 'Google US English'). If not found, uses auto-detect. */
|
|
2981
3014
|
voice?: string;
|
|
2982
3015
|
/**
|
|
@@ -2995,7 +3028,177 @@ type TextToSpeechConfig = {
|
|
|
2995
3028
|
rate?: number;
|
|
2996
3029
|
/** Speech pitch (0 - 2). Default: 1 */
|
|
2997
3030
|
pitch?: number;
|
|
3031
|
+
/**
|
|
3032
|
+
* Factory for a custom {@link SpeechEngine}, used by both the auto-speak path
|
|
3033
|
+
* and the per-message "Read aloud" action. When omitted, the browser Web
|
|
3034
|
+
* Speech API engine is used. Return a hosted engine here to use server-side
|
|
3035
|
+
* TTS (e.g. Runtype) — such an engine can stream audio through the realtime
|
|
3036
|
+
* voice {@link VoicePlaybackEngine}. May be async (it is resolved on first
|
|
3037
|
+
* playback, inside the user gesture).
|
|
3038
|
+
*/
|
|
3039
|
+
createEngine?: () => SpeechEngine | Promise<SpeechEngine>;
|
|
2998
3040
|
};
|
|
3041
|
+
/** A unit of speech handed to a {@link SpeechEngine}. */
|
|
3042
|
+
interface SpeechRequest {
|
|
3043
|
+
/** Plain text to speak. The widget strips Markdown before calling the engine. */
|
|
3044
|
+
text: string;
|
|
3045
|
+
/** Preferred voice identifier (engine-specific; browser = voice name). */
|
|
3046
|
+
voice?: string;
|
|
3047
|
+
/** Speech rate (engine-specific range; browser: 0.1–10, default 1). */
|
|
3048
|
+
rate?: number;
|
|
3049
|
+
/** Speech pitch (engine-specific range; browser: 0–2, default 1). */
|
|
3050
|
+
pitch?: number;
|
|
3051
|
+
}
|
|
3052
|
+
/** Lifecycle callbacks a {@link SpeechEngine} invokes during playback. */
|
|
3053
|
+
interface SpeechCallbacks {
|
|
3054
|
+
/** Audio has started playing. */
|
|
3055
|
+
onStart?: () => void;
|
|
3056
|
+
/** Playback finished naturally (or was canceled). */
|
|
3057
|
+
onEnd?: () => void;
|
|
3058
|
+
/** Playback failed. */
|
|
3059
|
+
onError?: (error: Error) => void;
|
|
3060
|
+
}
|
|
3061
|
+
/**
|
|
3062
|
+
* Pluggable text-to-speech engine behind the "Read aloud" message action.
|
|
3063
|
+
*
|
|
3064
|
+
* The widget ships a browser Web Speech API engine by default. Provide a hosted
|
|
3065
|
+
* engine (Runtype TTS, ElevenLabs, a server proxy, …) by implementing this
|
|
3066
|
+
* interface and returning it from {@link TextToSpeechConfig.createEngine}; a
|
|
3067
|
+
* server engine can stream audio into the realtime voice
|
|
3068
|
+
* {@link VoicePlaybackEngine}.
|
|
3069
|
+
*/
|
|
3070
|
+
interface SpeechEngine {
|
|
3071
|
+
/** Stable identifier, e.g. `"browser"`, `"runtype"`, or a custom id. */
|
|
3072
|
+
readonly id: string;
|
|
3073
|
+
/**
|
|
3074
|
+
* Whether {@link pause}/{@link resume} are supported. When `false`, the UI
|
|
3075
|
+
* offers play/stop only (tapping a playing message stops it).
|
|
3076
|
+
*/
|
|
3077
|
+
readonly supportsPause: boolean;
|
|
3078
|
+
/** Begin speaking. Drives the lifecycle through `callbacks`. */
|
|
3079
|
+
speak(request: SpeechRequest, callbacks: SpeechCallbacks): void;
|
|
3080
|
+
/** Pause playback (no-op if unsupported). */
|
|
3081
|
+
pause(): void;
|
|
3082
|
+
/** Resume paused playback (no-op if unsupported). */
|
|
3083
|
+
resume(): void;
|
|
3084
|
+
/** Stop playback and discard any queued audio. */
|
|
3085
|
+
stop(): void;
|
|
3086
|
+
/** Optional teardown of engine resources. */
|
|
3087
|
+
destroy?(): void;
|
|
3088
|
+
}
|
|
3089
|
+
/**
|
|
3090
|
+
* Voice recognition result with transcript and optional audio
|
|
3091
|
+
*/
|
|
3092
|
+
type VoiceResult = {
|
|
3093
|
+
text: string;
|
|
3094
|
+
transcript?: string;
|
|
3095
|
+
audio?: {
|
|
3096
|
+
base64: string;
|
|
3097
|
+
format: 'wav' | 'mp3' | 'ogg' | 'webm';
|
|
3098
|
+
sampleRate: number;
|
|
3099
|
+
duration: number;
|
|
3100
|
+
};
|
|
3101
|
+
confidence?: number;
|
|
3102
|
+
provider: 'runtype' | 'browser' | 'custom';
|
|
3103
|
+
};
|
|
3104
|
+
/**
|
|
3105
|
+
* Voice provider status states
|
|
3106
|
+
*/
|
|
3107
|
+
type VoiceStatus = 'disconnected' | 'connected' | 'listening' | 'processing' | 'speaking' | 'error' | 'idle';
|
|
3108
|
+
/**
|
|
3109
|
+
* Per-turn latency metrics emitted by the realtime voice path.
|
|
3110
|
+
* The wire frame is snake_case (`metrics`); decoded to camelCase at the
|
|
3111
|
+
* provider boundary before being surfaced through `onMetrics`.
|
|
3112
|
+
*/
|
|
3113
|
+
type VoiceMetrics = {
|
|
3114
|
+
/** LLM generation time (ms). */
|
|
3115
|
+
llmMs?: number;
|
|
3116
|
+
/** Text-to-speech synthesis time (ms). */
|
|
3117
|
+
ttsMs?: number;
|
|
3118
|
+
/** Time to first audio frame (ms). */
|
|
3119
|
+
firstAudioMs?: number;
|
|
3120
|
+
/** Total turn time (ms). */
|
|
3121
|
+
totalMs?: number;
|
|
3122
|
+
};
|
|
3123
|
+
/**
|
|
3124
|
+
* Streaming PCM playback engine used by the realtime voice provider.
|
|
3125
|
+
*
|
|
3126
|
+
* The provider feeds raw PCM16 LE mono @ 24kHz (WAV header already stripped)
|
|
3127
|
+
* via `enqueue`, signals end-of-reply with `markStreamEnd`, and learns when
|
|
3128
|
+
* playback has fully drained via `onFinished`. The default implementation is
|
|
3129
|
+
* `AudioPlaybackManager`; an optional jitter-buffered AudioWorklet engine ships
|
|
3130
|
+
* from `@runtypelabs/persona/voice-worklet-player` and can be injected via the
|
|
3131
|
+
* `runtype.createPlaybackEngine` config hook.
|
|
3132
|
+
*/
|
|
3133
|
+
interface VoicePlaybackEngine {
|
|
3134
|
+
/** Enqueue a raw PCM16 LE mono @ 24kHz chunk (no WAV header). */
|
|
3135
|
+
enqueue(pcm: Uint8Array): void;
|
|
3136
|
+
/** Signal that no more chunks will arrive for the current reply. */
|
|
3137
|
+
markStreamEnd(): void;
|
|
3138
|
+
/** Immediately stop playback and discard queued audio. */
|
|
3139
|
+
flush(): void;
|
|
3140
|
+
/** Register a callback fired once all queued audio has finished playing. */
|
|
3141
|
+
onFinished(callback: () => void): void;
|
|
3142
|
+
/** Release all audio resources. */
|
|
3143
|
+
destroy(): Promise<void> | void;
|
|
3144
|
+
}
|
|
3145
|
+
/**
|
|
3146
|
+
* A {@link VoicePlaybackEngine} that also supports pause/resume. Returned by
|
|
3147
|
+
* `createPcmStreamPlayer` (`@runtypelabs/persona/voice-worklet-player`): a
|
|
3148
|
+
* jitter-buffered AudioWorklet player for raw PCM16 / 24 kHz / mono streams.
|
|
3149
|
+
* Reuse it inside a hosted {@link SpeechEngine} to get gapless playback with a
|
|
3150
|
+
* configurable prebuffer and graceful underrun handling — feed each streamed
|
|
3151
|
+
* chunk to {@link VoicePlaybackEngine.enqueue} and the worklet does the rest.
|
|
3152
|
+
*/
|
|
3153
|
+
interface PcmStreamPlayer extends VoicePlaybackEngine {
|
|
3154
|
+
/** Pause playback; the audio clock suspends and {@link resume} continues in place. */
|
|
3155
|
+
pause(): void;
|
|
3156
|
+
/** Resume playback after {@link pause}. */
|
|
3157
|
+
resume(): void;
|
|
3158
|
+
/**
|
|
3159
|
+
* Register a callback fired once audible playback actually begins — i.e. the
|
|
3160
|
+
* prebuffer waterline filled and the first sample reached the output. Use this
|
|
3161
|
+
* (rather than "first chunk enqueued") to flip a UI from loading to playing, so
|
|
3162
|
+
* the spinner holds through the prebuffer. Fires once per playback session
|
|
3163
|
+
* (cleared by {@link VoicePlaybackEngine.flush}); a mid-reply underrun re-buffer
|
|
3164
|
+
* does not re-fire it.
|
|
3165
|
+
*/
|
|
3166
|
+
onStarted(callback: () => void): void;
|
|
3167
|
+
}
|
|
3168
|
+
/**
|
|
3169
|
+
* Voice provider interface
|
|
3170
|
+
* Abstract interface for all voice providers in the Persona SDK
|
|
3171
|
+
*/
|
|
3172
|
+
interface VoiceProvider {
|
|
3173
|
+
type: 'browser' | 'runtype' | 'custom';
|
|
3174
|
+
connect(): Promise<void>;
|
|
3175
|
+
disconnect(): Promise<void>;
|
|
3176
|
+
startListening(): Promise<void>;
|
|
3177
|
+
stopListening(): Promise<void>;
|
|
3178
|
+
onResult(callback: (result: VoiceResult) => void): void;
|
|
3179
|
+
onError(callback: (error: Error) => void): void;
|
|
3180
|
+
onStatusChange(callback: (status: VoiceStatus) => void): void;
|
|
3181
|
+
/** Register a callback fired when recording stops and audio is about to be sent */
|
|
3182
|
+
onProcessingStart?(callback: () => void): void;
|
|
3183
|
+
/**
|
|
3184
|
+
* Register a callback for incremental transcript updates during a voice turn.
|
|
3185
|
+
* `isFinal=false` is a live interim update (user partials, or assistant deltas
|
|
3186
|
+
* on providers that stream them); `isFinal=true` finalizes that role's text.
|
|
3187
|
+
* On the realtime `runtype` path, interim updates fire for the `user` only and
|
|
3188
|
+
* the `assistant` arrives as a single final.
|
|
3189
|
+
*/
|
|
3190
|
+
onTranscript?(callback: (role: 'user' | 'assistant', text: string, isFinal: boolean) => void): void;
|
|
3191
|
+
/** Register a callback for per-turn latency metrics (realtime path). */
|
|
3192
|
+
onMetrics?(callback: (metrics: VoiceMetrics) => void): void;
|
|
3193
|
+
/** Returns the current interruption mode (only meaningful for Runtype provider) */
|
|
3194
|
+
getInterruptionMode?(): "none" | "cancel" | "barge-in";
|
|
3195
|
+
/** Returns true if the barge-in mic stream is alive (hot mic between turns) */
|
|
3196
|
+
isBargeInActive?(): boolean;
|
|
3197
|
+
/** Tear down the barge-in mic pipeline: "hang up" the always-on mic */
|
|
3198
|
+
deactivateBargeIn?(): Promise<void>;
|
|
3199
|
+
/** Stop playback / cancel in-flight request without starting recording */
|
|
3200
|
+
stopPlayback?(): void;
|
|
3201
|
+
}
|
|
2999
3202
|
/**
|
|
3000
3203
|
* Extra context for an approval decision, surfaced to `onDecision` and to the
|
|
3001
3204
|
* `approve`/`deny` callbacks passed to the `renderApproval` plugin hook.
|
|
@@ -3004,7 +3207,7 @@ type AgentWidgetApprovalDecisionOptions = {
|
|
|
3004
3207
|
/**
|
|
3005
3208
|
* The user chose a "remember this" affordance (e.g. an "Always allow"
|
|
3006
3209
|
* button) rather than a one-time decision. The widget resolves the *current*
|
|
3007
|
-
* approval identically whether or not this is set
|
|
3210
|
+
* approval identically whether or not this is set: an approval bubble is a
|
|
3008
3211
|
* single binary gate (`approved`/`denied`). Persisting a don't-ask-again
|
|
3009
3212
|
* policy for *future* approvals (auto-resolving them, or not surfacing them)
|
|
3010
3213
|
* is the integrator's responsibility, typically inside `onDecision`.
|
|
@@ -3058,9 +3261,9 @@ type AgentWidgetApprovalConfig = {
|
|
|
3058
3261
|
/**
|
|
3059
3262
|
* How the technical details (the tool's agent-facing description and the
|
|
3060
3263
|
* raw parameters JSON) are presented:
|
|
3061
|
-
* - `"collapsed"` (default)
|
|
3062
|
-
* - `"expanded"
|
|
3063
|
-
* - `"hidden"
|
|
3264
|
+
* - `"collapsed"` (default): hidden behind a "Show details" toggle
|
|
3265
|
+
* - `"expanded"`: visible, with the toggle available to hide them
|
|
3266
|
+
* - `"hidden"`: never rendered
|
|
3064
3267
|
*/
|
|
3065
3268
|
detailsDisplay?: "collapsed" | "expanded" | "hidden";
|
|
3066
3269
|
/** Label for the toggle that reveals the technical details */
|
|
@@ -3082,7 +3285,7 @@ type AgentWidgetApprovalConfig = {
|
|
|
3082
3285
|
displayTitle?: string;
|
|
3083
3286
|
/**
|
|
3084
3287
|
* Agent-authored justification for this specific call, when the agent
|
|
3085
|
-
* provided one. It is the agent's own claim
|
|
3288
|
+
* provided one. It is the agent's own claim: if you fold it into the
|
|
3086
3289
|
* summary, keep it attributed to the agent.
|
|
3087
3290
|
*/
|
|
3088
3291
|
reason?: string;
|
|
@@ -3188,7 +3391,7 @@ type AgentWidgetToolCallConfig$1 = {
|
|
|
3188
3391
|
*
|
|
3189
3392
|
* **Placeholders:** `{toolName}` (tool name), `{duration}` (live-updating elapsed time).
|
|
3190
3393
|
*
|
|
3191
|
-
* **Inline formatting:** `~dim~`, `*italic*`, `**bold
|
|
3394
|
+
* **Inline formatting:** `~dim~`, `*italic*`, `**bold**`: parsed at render time and
|
|
3192
3395
|
* applied as styled `<span>` elements. Works with all animation modes.
|
|
3193
3396
|
*
|
|
3194
3397
|
* When not set, falls back to the current `collapsedMode` behavior.
|
|
@@ -3201,7 +3404,7 @@ type AgentWidgetToolCallConfig$1 = {
|
|
|
3201
3404
|
*
|
|
3202
3405
|
* **Placeholders:** `{toolName}` (tool name), `{duration}` (final elapsed time).
|
|
3203
3406
|
*
|
|
3204
|
-
* **Inline formatting:** `~dim~`, `*italic*`, `**bold
|
|
3407
|
+
* **Inline formatting:** `~dim~`, `*italic*`, `**bold**`: same syntax as `activeTextTemplate`.
|
|
3205
3408
|
*
|
|
3206
3409
|
* When not set, falls back to the existing "Used tool for X seconds" text.
|
|
3207
3410
|
* @example "Finished {toolName} ~{duration}~"
|
|
@@ -3262,7 +3465,7 @@ type AgentWidgetReasoningConfig = {
|
|
|
3262
3465
|
*
|
|
3263
3466
|
* **Placeholders:** `{duration}` (live-updating elapsed time).
|
|
3264
3467
|
*
|
|
3265
|
-
* **Inline formatting:** `~dim~`, `*italic*`, `**bold
|
|
3468
|
+
* **Inline formatting:** `~dim~`, `*italic*`, `**bold**`: parsed at render time.
|
|
3266
3469
|
*
|
|
3267
3470
|
* When not set, falls back to the default "Thinking..." text.
|
|
3268
3471
|
* @example "Thinking... ~{duration}~"
|
|
@@ -3273,7 +3476,7 @@ type AgentWidgetReasoningConfig = {
|
|
|
3273
3476
|
*
|
|
3274
3477
|
* **Placeholders:** `{duration}` (final elapsed time).
|
|
3275
3478
|
*
|
|
3276
|
-
* **Inline formatting:** `~dim~`, `*italic*`, `**bold
|
|
3479
|
+
* **Inline formatting:** `~dim~`, `*italic*`, `**bold**`: same syntax as `activeTextTemplate`.
|
|
3277
3480
|
*
|
|
3278
3481
|
* When not set, falls back to the default "Thought for X seconds" text.
|
|
3279
3482
|
* @example "Thought for ~{duration}~"
|
|
@@ -3372,7 +3575,7 @@ type AgentWidgetSSEEventResult = {
|
|
|
3372
3575
|
done?: boolean;
|
|
3373
3576
|
/** Error message if an error occurred */
|
|
3374
3577
|
error?: string;
|
|
3375
|
-
/** Text segment identity
|
|
3578
|
+
/** Text segment identity: when this changes, a new assistant message bubble is created */
|
|
3376
3579
|
partId?: string;
|
|
3377
3580
|
} | null;
|
|
3378
3581
|
/**
|
|
@@ -4352,7 +4555,7 @@ type AgentWidgetConfig = {
|
|
|
4352
4555
|
* Per-stop-reason copy for the inline notice rendered on assistant
|
|
4353
4556
|
* bubbles when the runtime reports a non-natural stop (e.g. the agent
|
|
4354
4557
|
* loop hit `max_tool_calls` and was cut off mid-loop). Each key is
|
|
4355
|
-
* optional
|
|
4558
|
+
* optional: keys you omit fall back to the built-in defaults. Set a
|
|
4356
4559
|
* key to an empty string to suppress the notice for that reason.
|
|
4357
4560
|
*/
|
|
4358
4561
|
stopReasonNotice?: Partial<Record<StopReasonKind, string>>;
|
|
@@ -4445,12 +4648,12 @@ type AgentWidgetConfig = {
|
|
|
4445
4648
|
*/
|
|
4446
4649
|
approval?: AgentWidgetApprovalConfig | false;
|
|
4447
4650
|
/**
|
|
4448
|
-
* WebMCP
|
|
4651
|
+
* WebMCP: consume page-registered tools (`document.modelContext.registerTool`).
|
|
4449
4652
|
* When `enabled`, the widget installs `@mcp-b/webmcp-polyfill`, snapshots the
|
|
4450
4653
|
* registry on every dispatch, ships it as `clientTools[]`, and executes
|
|
4451
4654
|
* returned `webmcp:*` tool calls with confirm-by-default gating.
|
|
4452
4655
|
*
|
|
4453
|
-
* Server-side policy on the chat surface is the source of truth
|
|
4656
|
+
* Server-side policy on the chat surface is the source of truth: these
|
|
4454
4657
|
* fields layer on top.
|
|
4455
4658
|
*
|
|
4456
4659
|
* @example
|
|
@@ -4484,7 +4687,7 @@ type AgentWidgetConfig = {
|
|
|
4484
4687
|
* This hook runs synchronously and must return the (potentially modified) state.
|
|
4485
4688
|
*
|
|
4486
4689
|
* Returning `{ state, open: true }` also signals that the widget panel should
|
|
4487
|
-
* open after initialization
|
|
4690
|
+
* open after initialization: useful when injecting a post-navigation message
|
|
4488
4691
|
* that the user should immediately see.
|
|
4489
4692
|
*
|
|
4490
4693
|
* @example
|
|
@@ -4803,7 +5006,7 @@ type AgentWidgetConfig = {
|
|
|
4803
5006
|
* Setting this to `false` is the explicit kill-switch: it disables UI-state
|
|
4804
5007
|
* persistence **and** message-history persistence. When `false`, any
|
|
4805
5008
|
* `storageAdapter` you configure is ignored and the default localStorage
|
|
4806
|
-
* adapter is not created
|
|
5009
|
+
* adapter is not created: no chat history is read or written. Pass `true`
|
|
4807
5010
|
* (or omit) to keep the default behavior of persisting messages via the
|
|
4808
5011
|
* configured `storageAdapter` (or the built-in localStorage adapter).
|
|
4809
5012
|
*
|
|
@@ -4832,7 +5035,7 @@ type AgentWidgetConfig = {
|
|
|
4832
5035
|
*
|
|
4833
5036
|
* @example
|
|
4834
5037
|
* ```typescript
|
|
4835
|
-
* // Ephemeral widget
|
|
5038
|
+
* // Ephemeral widget: no message history written anywhere
|
|
4836
5039
|
* config: {
|
|
4837
5040
|
* persistState: false
|
|
4838
5041
|
* }
|
|
@@ -4899,7 +5102,7 @@ type AgentWidgetApproval = {
|
|
|
4899
5102
|
* Agent-authored justification for this specific call (the agent's own
|
|
4900
5103
|
* claim about its intent, extracted server-side from the reserved
|
|
4901
5104
|
* `_approvalReason` parameter). Render it attributed to the agent and as
|
|
4902
|
-
* plain text
|
|
5105
|
+
* plain text: it is approver context, not a system statement.
|
|
4903
5106
|
*/
|
|
4904
5107
|
reason?: string;
|
|
4905
5108
|
parameters?: unknown;
|
|
@@ -4909,16 +5112,16 @@ type AgentWidgetMessageVariant = "assistant" | "reasoning" | "tool" | "approval"
|
|
|
4909
5112
|
/**
|
|
4910
5113
|
* Per-turn / per-step stop reason emitted by the runtime on
|
|
4911
5114
|
* `agent_turn_complete` and `step_complete` SSE events. The vocabulary is
|
|
4912
|
-
* owned by the upstream Runtype API
|
|
5115
|
+
* owned by the upstream Runtype API: do not extend without coordination.
|
|
4913
5116
|
*
|
|
4914
|
-
* - `end_turn
|
|
4915
|
-
* - `max_tool_calls
|
|
4916
|
-
* - `length
|
|
4917
|
-
* - `content_filter
|
|
4918
|
-
* - `error
|
|
4919
|
-
* - `unknown
|
|
5117
|
+
* - `end_turn`: natural completion (no affordance needed)
|
|
5118
|
+
* - `max_tool_calls`: agent loop tripped the configured tool-call ceiling
|
|
5119
|
+
* - `length`: provider hit max output tokens
|
|
5120
|
+
* - `content_filter`: provider content filter intervened
|
|
5121
|
+
* - `error`: provider/runtime error (prefer existing error rendering)
|
|
5122
|
+
* - `unknown`: explicitly reported but uninformative
|
|
4920
5123
|
*
|
|
4921
|
-
* Absent (`undefined`) means "not reported"
|
|
5124
|
+
* Absent (`undefined`) means "not reported": distinct from `'unknown'`.
|
|
4922
5125
|
*/
|
|
4923
5126
|
type StopReasonKind = RuntypeStopReasonKind;
|
|
4924
5127
|
/**
|
|
@@ -5019,156 +5222,6 @@ type AgentWidgetMessage = {
|
|
|
5019
5222
|
*/
|
|
5020
5223
|
stopReason?: StopReasonKind;
|
|
5021
5224
|
};
|
|
5022
|
-
/**
|
|
5023
|
-
* Options for injecting a message into the conversation.
|
|
5024
|
-
* Supports dual-content where UI display differs from LLM context.
|
|
5025
|
-
*
|
|
5026
|
-
* @example
|
|
5027
|
-
* // Same content for user and LLM
|
|
5028
|
-
* {
|
|
5029
|
-
* role: 'assistant',
|
|
5030
|
-
* content: 'Here are your search results...'
|
|
5031
|
-
* }
|
|
5032
|
-
*
|
|
5033
|
-
* @example
|
|
5034
|
-
* // Different content: user sees full details, LLM sees summary
|
|
5035
|
-
* {
|
|
5036
|
-
* role: 'assistant',
|
|
5037
|
-
* content: '**Found 3 products:**\n- iPhone 15 Pro ($1,199)\n- iPhone 15 ($999)',
|
|
5038
|
-
* llmContent: '[Search results: 3 iPhones, $999-$1199]'
|
|
5039
|
-
* }
|
|
5040
|
-
*/
|
|
5041
|
-
type InjectMessageOptions = {
|
|
5042
|
-
/**
|
|
5043
|
-
* Message role: "assistant", "user", or "system"
|
|
5044
|
-
*/
|
|
5045
|
-
role: AgentWidgetMessageRole;
|
|
5046
|
-
/**
|
|
5047
|
-
* Content displayed to the user in the chat UI.
|
|
5048
|
-
* This is what appears in the message bubble.
|
|
5049
|
-
*/
|
|
5050
|
-
content: string;
|
|
5051
|
-
/**
|
|
5052
|
-
* Content sent to the LLM in API requests.
|
|
5053
|
-
* When omitted, `content` is used for both display and LLM.
|
|
5054
|
-
*
|
|
5055
|
-
* Use cases:
|
|
5056
|
-
* - Redacted content: Show full product details to user, send summary to LLM
|
|
5057
|
-
* - Structured data: Show formatted markdown to user, send JSON to LLM
|
|
5058
|
-
* - Token optimization: Show verbose content to user, send concise version to LLM
|
|
5059
|
-
*/
|
|
5060
|
-
llmContent?: string;
|
|
5061
|
-
/**
|
|
5062
|
-
* Multi-modal content parts for the LLM (images, files).
|
|
5063
|
-
* Takes precedence over `llmContent` when present.
|
|
5064
|
-
* The `content` field is still used for UI display.
|
|
5065
|
-
*/
|
|
5066
|
-
contentParts?: ContentPart[];
|
|
5067
|
-
/**
|
|
5068
|
-
* Optional message ID. If omitted, auto-generated based on role.
|
|
5069
|
-
*/
|
|
5070
|
-
id?: string;
|
|
5071
|
-
/**
|
|
5072
|
-
* Optional creation timestamp (ISO string). If omitted, uses current time.
|
|
5073
|
-
*/
|
|
5074
|
-
createdAt?: string;
|
|
5075
|
-
/**
|
|
5076
|
-
* Optional sequence number for ordering.
|
|
5077
|
-
*/
|
|
5078
|
-
sequence?: number;
|
|
5079
|
-
/**
|
|
5080
|
-
* Whether the message is still streaming (for incremental updates).
|
|
5081
|
-
* @default false
|
|
5082
|
-
*/
|
|
5083
|
-
streaming?: boolean;
|
|
5084
|
-
/**
|
|
5085
|
-
* Mark this message as a voice processing placeholder.
|
|
5086
|
-
* Consumers can detect this in `messageTransform` to render custom UI.
|
|
5087
|
-
*/
|
|
5088
|
-
voiceProcessing?: boolean;
|
|
5089
|
-
/**
|
|
5090
|
-
* Raw structured payload (typically a JSON string) representing the
|
|
5091
|
-
* full directive that produced this message — e.g. `{ "text": "...",
|
|
5092
|
-
* "component": "Foo", "props": {...} }`.
|
|
5093
|
-
*
|
|
5094
|
-
* Mirrors the field populated by stream parsers during normal LLM
|
|
5095
|
-
* responses. Set this when injecting a message that should render as a
|
|
5096
|
-
* component directive (`hasComponentDirective` /
|
|
5097
|
-
* `extractComponentDirectiveFromMessage` look at `rawContent` first).
|
|
5098
|
-
*
|
|
5099
|
-
* Priority for the API payload remains:
|
|
5100
|
-
* `contentParts > llmContent > rawContent > content`. Pass `llmContent`
|
|
5101
|
-
* alongside `rawContent` if the LLM should see something other than the
|
|
5102
|
-
* raw directive.
|
|
5103
|
-
*/
|
|
5104
|
-
rawContent?: string;
|
|
5105
|
-
};
|
|
5106
|
-
/**
|
|
5107
|
-
* Options for injecting assistant messages (most common case).
|
|
5108
|
-
* Role defaults to 'assistant'.
|
|
5109
|
-
*/
|
|
5110
|
-
type InjectAssistantMessageOptions = Omit<InjectMessageOptions, "role">;
|
|
5111
|
-
/**
|
|
5112
|
-
* Options for injecting user messages.
|
|
5113
|
-
* Role defaults to 'user'.
|
|
5114
|
-
*/
|
|
5115
|
-
type InjectUserMessageOptions = Omit<InjectMessageOptions, "role">;
|
|
5116
|
-
/**
|
|
5117
|
-
* Options for injecting system messages.
|
|
5118
|
-
* Role defaults to 'system'.
|
|
5119
|
-
*/
|
|
5120
|
-
type InjectSystemMessageOptions = Omit<InjectMessageOptions, "role">;
|
|
5121
|
-
/**
|
|
5122
|
-
* Options for injecting an assistant message that renders as a component
|
|
5123
|
-
* directive — sugar over `injectAssistantMessage` for the common case of
|
|
5124
|
-
* "render this registered component, same as if the LLM had emitted it".
|
|
5125
|
-
*
|
|
5126
|
-
* Equivalent to calling `injectAssistantMessage({ content: text, rawContent:
|
|
5127
|
-
* JSON.stringify({ text, component, props }), llmContent })`.
|
|
5128
|
-
*
|
|
5129
|
-
* @example
|
|
5130
|
-
* widget.injectComponentDirective({
|
|
5131
|
-
* component: "DynamicForm",
|
|
5132
|
-
* props: { title: "Book a demo", fields: [...] },
|
|
5133
|
-
* text: "Share your details to book a demo.",
|
|
5134
|
-
* llmContent: "[Showed booking form]"
|
|
5135
|
-
* });
|
|
5136
|
-
*/
|
|
5137
|
-
type InjectComponentDirectiveOptions = {
|
|
5138
|
-
/**
|
|
5139
|
-
* Name of a renderer registered via `componentRegistry.register(...)`.
|
|
5140
|
-
*/
|
|
5141
|
-
component: string;
|
|
5142
|
-
/**
|
|
5143
|
-
* Props passed to the component renderer.
|
|
5144
|
-
*/
|
|
5145
|
-
props?: Record<string, unknown>;
|
|
5146
|
-
/**
|
|
5147
|
-
* Bubble copy displayed above (or with) the rendered component.
|
|
5148
|
-
* Mirrors the `text` field in a streamed JSON directive.
|
|
5149
|
-
* @default ""
|
|
5150
|
-
*/
|
|
5151
|
-
text?: string;
|
|
5152
|
-
/**
|
|
5153
|
-
* Content sent to the LLM in API requests. When omitted, the raw
|
|
5154
|
-
* directive JSON is what the LLM would see (per the standard
|
|
5155
|
-
* priority chain). Provide a redacted/short version to avoid sending
|
|
5156
|
-
* the full directive in subsequent turns.
|
|
5157
|
-
*/
|
|
5158
|
-
llmContent?: string;
|
|
5159
|
-
/**
|
|
5160
|
-
* Optional message ID. If omitted, an assistant id is auto-generated.
|
|
5161
|
-
*/
|
|
5162
|
-
id?: string;
|
|
5163
|
-
/**
|
|
5164
|
-
* Optional creation timestamp (ISO string). If omitted, uses current time.
|
|
5165
|
-
*/
|
|
5166
|
-
createdAt?: string;
|
|
5167
|
-
/**
|
|
5168
|
-
* Optional sequence number for ordering.
|
|
5169
|
-
*/
|
|
5170
|
-
sequence?: number;
|
|
5171
|
-
};
|
|
5172
5225
|
type PersonaArtifactRecord = {
|
|
5173
5226
|
id: string;
|
|
5174
5227
|
artifactType: PersonaArtifactKind;
|
|
@@ -5178,49 +5231,8 @@ type PersonaArtifactRecord = {
|
|
|
5178
5231
|
component?: string;
|
|
5179
5232
|
props?: Record<string, unknown>;
|
|
5180
5233
|
};
|
|
5181
|
-
/** Programmatic artifact upsert (controller / window API) */
|
|
5182
|
-
type PersonaArtifactManualUpsert = {
|
|
5183
|
-
id?: string;
|
|
5184
|
-
artifactType: "markdown";
|
|
5185
|
-
title?: string;
|
|
5186
|
-
content: string;
|
|
5187
|
-
} | {
|
|
5188
|
-
id?: string;
|
|
5189
|
-
artifactType: "component";
|
|
5190
|
-
title?: string;
|
|
5191
|
-
component: string;
|
|
5192
|
-
props?: Record<string, unknown>;
|
|
5193
|
-
};
|
|
5194
|
-
type AgentWidgetEvent = {
|
|
5195
|
-
type: "message";
|
|
5196
|
-
message: AgentWidgetMessage;
|
|
5197
|
-
} | {
|
|
5198
|
-
type: "status";
|
|
5199
|
-
status: "connecting" | "connected" | "error" | "idle";
|
|
5200
|
-
} | {
|
|
5201
|
-
type: "error";
|
|
5202
|
-
error: Error;
|
|
5203
|
-
} | {
|
|
5204
|
-
type: "artifact_start";
|
|
5205
|
-
id: string;
|
|
5206
|
-
artifactType: PersonaArtifactKind;
|
|
5207
|
-
title?: string;
|
|
5208
|
-
component?: string;
|
|
5209
|
-
} | {
|
|
5210
|
-
type: "artifact_delta";
|
|
5211
|
-
id: string;
|
|
5212
|
-
artDelta: string;
|
|
5213
|
-
} | {
|
|
5214
|
-
type: "artifact_update";
|
|
5215
|
-
id: string;
|
|
5216
|
-
props: Record<string, unknown>;
|
|
5217
|
-
component?: string;
|
|
5218
|
-
} | {
|
|
5219
|
-
type: "artifact_complete";
|
|
5220
|
-
id: string;
|
|
5221
|
-
};
|
|
5222
5234
|
|
|
5223
|
-
/** Field definition types for the declarative configurator system (headless
|
|
5235
|
+
/** Field definition types for the declarative configurator system (headless: no DOM) */
|
|
5224
5236
|
|
|
5225
5237
|
type FieldType = 'color' | 'slider' | 'toggle' | 'select' | 'text' | 'chip-list' | 'color-scale' | 'token-ref' | 'role-assignment';
|
|
5226
5238
|
interface SliderOptions {
|
|
@@ -5413,7 +5425,7 @@ declare class ThemeEditorState {
|
|
|
5413
5425
|
private restoreSnapshot;
|
|
5414
5426
|
}
|
|
5415
5427
|
|
|
5416
|
-
/** Declarative section/field definitions for the theme editor (pure data
|
|
5428
|
+
/** Declarative section/field definitions for the theme editor (pure data: no DOM, no render logic) */
|
|
5417
5429
|
|
|
5418
5430
|
declare const STYLE_SECTIONS: SectionDef[];
|
|
5419
5431
|
declare const PALETTE_SECTION: SectionDef;
|
|
@@ -5426,19 +5438,19 @@ declare const COMPONENT_COLOR_SECTIONS: SectionDef[];
|
|
|
5426
5438
|
declare const COMPONENTS_SECTIONS: SectionDef[];
|
|
5427
5439
|
declare const CONFIGURE_SUB_GROUPS: SubGroupDef[];
|
|
5428
5440
|
declare const CONFIGURE_SECTIONS: SectionDef[];
|
|
5429
|
-
/** Section 1: Theme
|
|
5441
|
+
/** Section 1: Theme: color mode selection */
|
|
5430
5442
|
declare const THEME_SECTION: SectionDef;
|
|
5431
|
-
/** Section 2: Brand Palette
|
|
5443
|
+
/** Section 2: Brand Palette: primary colors + collapsed status colors */
|
|
5432
5444
|
declare const BRAND_PALETTE_SECTION: SectionDef;
|
|
5433
|
-
/** Section 2b: Status palette
|
|
5445
|
+
/** Section 2b: Status palette: collapsed under Brand Palette */
|
|
5434
5446
|
declare const STATUS_PALETTE_SECTION: SectionDef;
|
|
5435
|
-
/** Section 3: Interface Roles
|
|
5447
|
+
/** Section 3: Interface Roles: the main theming surface */
|
|
5436
5448
|
declare const INTERFACE_ROLES_SECTION: SectionDef;
|
|
5437
|
-
/** Section 4: Status Colors
|
|
5449
|
+
/** Section 4: Status Colors: feedback semantic tokens */
|
|
5438
5450
|
declare const STATUS_COLORS_SECTION: SectionDef;
|
|
5439
|
-
/** Section 5: Advanced Tokens
|
|
5451
|
+
/** Section 5: Advanced Tokens: entry point for drill-downs (no fields) */
|
|
5440
5452
|
declare const ADVANCED_TOKENS_SECTION: SectionDef;
|
|
5441
|
-
/** V2 Style tab sections
|
|
5453
|
+
/** V2 Style tab sections: outcome-oriented editor */
|
|
5442
5454
|
declare const STYLE_SECTIONS_V2: SectionDef[];
|
|
5443
5455
|
declare const ALL_TABS: TabDef[];
|
|
5444
5456
|
type ThemeScope = 'theme' | 'darkTheme';
|
|
@@ -5448,7 +5460,7 @@ declare function findSection(sections: SectionDef[], id: string): SectionDef;
|
|
|
5448
5460
|
/** Create a light/dark scoped copy of a section */
|
|
5449
5461
|
declare function scopeSection(section: SectionDef, scope: ThemeScope, variant: ThemeVariant, collapsed?: boolean | undefined): SectionDef;
|
|
5450
5462
|
|
|
5451
|
-
/** Theme editor presets
|
|
5463
|
+
/** Theme editor presets: unified collection of built-in presets */
|
|
5452
5464
|
|
|
5453
5465
|
declare const BUILT_IN_PRESETS: ThemeEditorPreset[];
|
|
5454
5466
|
/** All built-in presets */
|
|
@@ -5456,155 +5468,6 @@ declare const THEME_EDITOR_PRESETS: ThemeEditorPreset[];
|
|
|
5456
5468
|
/** Look up a preset by ID */
|
|
5457
5469
|
declare function getThemeEditorPreset(id: string): ThemeEditorPreset | undefined;
|
|
5458
5470
|
|
|
5459
|
-
type AgentWidgetSessionStatus = "idle" | "connecting" | "connected" | "error";
|
|
5460
|
-
|
|
5461
|
-
/**
|
|
5462
|
-
* Feedback UI components for CSAT and NPS collection
|
|
5463
|
-
*/
|
|
5464
|
-
type CSATFeedbackOptions = {
|
|
5465
|
-
/** Callback when user submits CSAT feedback */
|
|
5466
|
-
onSubmit: (rating: number, comment?: string) => void | Promise<void>;
|
|
5467
|
-
/** Callback when user dismisses the feedback form */
|
|
5468
|
-
onDismiss?: () => void;
|
|
5469
|
-
/** Title text */
|
|
5470
|
-
title?: string;
|
|
5471
|
-
/** Subtitle/question text */
|
|
5472
|
-
subtitle?: string;
|
|
5473
|
-
/** Placeholder for optional comment field */
|
|
5474
|
-
commentPlaceholder?: string;
|
|
5475
|
-
/** Submit button text */
|
|
5476
|
-
submitText?: string;
|
|
5477
|
-
/** Skip button text */
|
|
5478
|
-
skipText?: string;
|
|
5479
|
-
/** Show comment field */
|
|
5480
|
-
showComment?: boolean;
|
|
5481
|
-
/** Rating labels (5 items for ratings 1-5) */
|
|
5482
|
-
ratingLabels?: [string, string, string, string, string];
|
|
5483
|
-
};
|
|
5484
|
-
type NPSFeedbackOptions = {
|
|
5485
|
-
/** Callback when user submits NPS feedback */
|
|
5486
|
-
onSubmit: (rating: number, comment?: string) => void | Promise<void>;
|
|
5487
|
-
/** Callback when user dismisses the feedback form */
|
|
5488
|
-
onDismiss?: () => void;
|
|
5489
|
-
/** Title text */
|
|
5490
|
-
title?: string;
|
|
5491
|
-
/** Subtitle/question text */
|
|
5492
|
-
subtitle?: string;
|
|
5493
|
-
/** Placeholder for optional comment field */
|
|
5494
|
-
commentPlaceholder?: string;
|
|
5495
|
-
/** Submit button text */
|
|
5496
|
-
submitText?: string;
|
|
5497
|
-
/** Skip button text */
|
|
5498
|
-
skipText?: string;
|
|
5499
|
-
/** Show comment field */
|
|
5500
|
-
showComment?: boolean;
|
|
5501
|
-
/** Low label (left side) */
|
|
5502
|
-
lowLabel?: string;
|
|
5503
|
-
/** High label (right side) */
|
|
5504
|
-
highLabel?: string;
|
|
5505
|
-
};
|
|
5506
|
-
|
|
5507
|
-
type Controller = {
|
|
5508
|
-
update: (config: AgentWidgetConfig) => void;
|
|
5509
|
-
destroy: () => void;
|
|
5510
|
-
open: () => void;
|
|
5511
|
-
close: () => void;
|
|
5512
|
-
toggle: () => void;
|
|
5513
|
-
clearChat: () => void;
|
|
5514
|
-
setMessage: (message: string) => boolean;
|
|
5515
|
-
submitMessage: (message?: string) => boolean;
|
|
5516
|
-
startVoiceRecognition: () => boolean;
|
|
5517
|
-
stopVoiceRecognition: () => boolean;
|
|
5518
|
-
/**
|
|
5519
|
-
* Inject a message into the conversation with dual-content support.
|
|
5520
|
-
* Auto-opens the widget if closed and launcher is enabled.
|
|
5521
|
-
*/
|
|
5522
|
-
injectMessage: (options: InjectMessageOptions) => AgentWidgetMessage;
|
|
5523
|
-
/**
|
|
5524
|
-
* Convenience method for injecting assistant messages.
|
|
5525
|
-
*/
|
|
5526
|
-
injectAssistantMessage: (options: InjectAssistantMessageOptions) => AgentWidgetMessage;
|
|
5527
|
-
/**
|
|
5528
|
-
* Convenience method for injecting user messages.
|
|
5529
|
-
*/
|
|
5530
|
-
injectUserMessage: (options: InjectUserMessageOptions) => AgentWidgetMessage;
|
|
5531
|
-
/**
|
|
5532
|
-
* Convenience method for injecting system messages.
|
|
5533
|
-
*/
|
|
5534
|
-
injectSystemMessage: (options: InjectSystemMessageOptions) => AgentWidgetMessage;
|
|
5535
|
-
/**
|
|
5536
|
-
* Inject multiple messages in a single batch with one sort and one render pass.
|
|
5537
|
-
*/
|
|
5538
|
-
injectMessageBatch: (optionsList: InjectMessageOptions[]) => AgentWidgetMessage[];
|
|
5539
|
-
/**
|
|
5540
|
-
* Convenience method for injecting an assistant message that renders as a
|
|
5541
|
-
* registered component — same shape Persona produces from a streamed
|
|
5542
|
-
* `{ "text": "...", "component": "...", "props": {...} }` payload.
|
|
5543
|
-
*/
|
|
5544
|
-
injectComponentDirective: (options: InjectComponentDirectiveOptions) => AgentWidgetMessage;
|
|
5545
|
-
/**
|
|
5546
|
-
* @deprecated Use injectMessage() instead.
|
|
5547
|
-
*/
|
|
5548
|
-
injectTestMessage: (event: AgentWidgetEvent) => void;
|
|
5549
|
-
getMessages: () => AgentWidgetMessage[];
|
|
5550
|
-
getStatus: () => AgentWidgetSessionStatus;
|
|
5551
|
-
getPersistentMetadata: () => Record<string, unknown>;
|
|
5552
|
-
updatePersistentMetadata: (updater: (prev: Record<string, unknown>) => Record<string, unknown>) => void;
|
|
5553
|
-
on: <K extends keyof AgentWidgetControllerEventMap>(event: K, handler: (payload: AgentWidgetControllerEventMap[K]) => void) => () => void;
|
|
5554
|
-
off: <K extends keyof AgentWidgetControllerEventMap>(event: K, handler: (payload: AgentWidgetControllerEventMap[K]) => void) => void;
|
|
5555
|
-
isOpen: () => boolean;
|
|
5556
|
-
isVoiceActive: () => boolean;
|
|
5557
|
-
getState: () => AgentWidgetStateSnapshot;
|
|
5558
|
-
showCSATFeedback: (options?: Partial<CSATFeedbackOptions>) => void;
|
|
5559
|
-
showNPSFeedback: (options?: Partial<NPSFeedbackOptions>) => void;
|
|
5560
|
-
submitCSATFeedback: (rating: number, comment?: string) => Promise<void>;
|
|
5561
|
-
submitNPSFeedback: (rating: number, comment?: string) => Promise<void>;
|
|
5562
|
-
/**
|
|
5563
|
-
* Connect an external SSE stream and process it through the SDK's
|
|
5564
|
-
* native event pipeline (tools, reasoning, streaming text, etc.).
|
|
5565
|
-
*/
|
|
5566
|
-
connectStream: (stream: ReadableStream<Uint8Array>, options?: {
|
|
5567
|
-
assistantMessageId?: string;
|
|
5568
|
-
}) => Promise<void>;
|
|
5569
|
-
/** Push a raw event into the event stream buffer (for testing/debugging) */
|
|
5570
|
-
__pushEventStreamEvent: (event: {
|
|
5571
|
-
type: string;
|
|
5572
|
-
payload: unknown;
|
|
5573
|
-
}) => void;
|
|
5574
|
-
/** Opens the event stream panel */
|
|
5575
|
-
showEventStream: () => void;
|
|
5576
|
-
/** Closes the event stream panel */
|
|
5577
|
-
hideEventStream: () => void;
|
|
5578
|
-
/** Returns current visibility state of the event stream panel */
|
|
5579
|
-
isEventStreamVisible: () => boolean;
|
|
5580
|
-
/** Show artifact sidebar (no-op if features.artifacts.enabled is false) */
|
|
5581
|
-
showArtifacts: () => void;
|
|
5582
|
-
/** Hide artifact sidebar */
|
|
5583
|
-
hideArtifacts: () => void;
|
|
5584
|
-
/** Upsert an artifact programmatically */
|
|
5585
|
-
upsertArtifact: (manual: PersonaArtifactManualUpsert) => PersonaArtifactRecord | null;
|
|
5586
|
-
selectArtifact: (id: string) => void;
|
|
5587
|
-
clearArtifacts: () => void;
|
|
5588
|
-
/** Read current artifacts (useful on init to rebuild host-side tab state after hydration). */
|
|
5589
|
-
getArtifacts: () => PersonaArtifactRecord[];
|
|
5590
|
-
/** Read the currently selected artifact id (paired with `getArtifacts`). */
|
|
5591
|
-
getSelectedArtifactId: () => string | null;
|
|
5592
|
-
/**
|
|
5593
|
-
* Focus the chat input. Returns true if focus succeeded, false if panel is closed
|
|
5594
|
-
* (launcher mode) or textarea is unavailable.
|
|
5595
|
-
*/
|
|
5596
|
-
focusInput: () => boolean;
|
|
5597
|
-
/**
|
|
5598
|
-
* Programmatically resolve a pending approval.
|
|
5599
|
-
* @param approvalId - The approval ID to resolve
|
|
5600
|
-
* @param decision - "approved" or "denied"
|
|
5601
|
-
* @param options - Optional decision context (e.g. `{ remember: true }`),
|
|
5602
|
-
* forwarded to `config.approval.onDecision`.
|
|
5603
|
-
*/
|
|
5604
|
-
resolveApproval: (approvalId: string, decision: 'approved' | 'denied', options?: AgentWidgetApprovalDecisionOptions) => Promise<void>;
|
|
5605
|
-
};
|
|
5606
|
-
type AgentWidgetController = Controller;
|
|
5607
|
-
|
|
5608
5471
|
/**
|
|
5609
5472
|
* Shared preview building blocks for theme editor preview renderers.
|
|
5610
5473
|
* Used by both `createThemePreview()` (simple API) and the configurator's
|
|
@@ -5690,87 +5553,12 @@ interface PreviewConfigOptions {
|
|
|
5690
5553
|
declare function buildPreviewConfig(options: PreviewConfigOptions, shellModeOverride?: 'light' | 'dark'): AgentWidgetConfig;
|
|
5691
5554
|
declare function buildPreviewConfigWithMessages(options: PreviewConfigOptions, messages: AgentWidgetMessage[], shellModeOverride?: 'light' | 'dark'): AgentWidgetConfig;
|
|
5692
5555
|
|
|
5693
|
-
/**
|
|
5694
|
-
* Imperative preview renderer for the theme editor.
|
|
5695
|
-
* Manages iframe-based widget previews with device frames, zoom, scenes, and compare mode.
|
|
5696
|
-
* No external DOM dependencies — only needs a container element to mount into.
|
|
5697
|
-
*
|
|
5698
|
-
* For advanced preview needs (background URLs, inline editing, contrast checking),
|
|
5699
|
-
* use the lifecycle hooks in `ThemePreviewOptions` and import shared building blocks
|
|
5700
|
-
* from `./preview-utils` directly.
|
|
5701
|
-
*/
|
|
5702
|
-
|
|
5703
|
-
type PreviewDevice = 'desktop' | 'mobile';
|
|
5704
|
-
|
|
5705
|
-
type PreviewShellMode = 'light' | 'dark';
|
|
5706
|
-
type CompareMode = 'off' | 'baseline' | 'themes';
|
|
5707
|
-
/** Context passed to lifecycle hooks after mounting or updating */
|
|
5708
|
-
interface PreviewLifecycleContext {
|
|
5709
|
-
iframes: HTMLIFrameElement[];
|
|
5710
|
-
controllers: AgentWidgetController[];
|
|
5711
|
-
}
|
|
5712
|
-
interface ThemePreviewOptions {
|
|
5713
|
-
/** Device frame dimensions */
|
|
5714
|
-
device?: PreviewDevice;
|
|
5715
|
-
/** Widget state */
|
|
5716
|
-
scene?: PreviewScene;
|
|
5717
|
-
/** Browser chrome appearance */
|
|
5718
|
-
shellMode?: PreviewShellMode;
|
|
5719
|
-
/** Side-by-side comparison */
|
|
5720
|
-
compareMode?: CompareMode;
|
|
5721
|
-
/** Widget config */
|
|
5722
|
-
config?: Partial<AgentWidgetConfig>;
|
|
5723
|
-
/** Light mode theme */
|
|
5724
|
-
theme?: DeepPartial<PersonaTheme>;
|
|
5725
|
-
/** Dark mode theme */
|
|
5726
|
-
darkTheme?: DeepPartial<PersonaTheme>;
|
|
5727
|
-
/** Zoom level (0.15–1.5), or undefined for auto-fit */
|
|
5728
|
-
zoom?: number;
|
|
5729
|
-
/** Path to widget.css (defaults to looking for /widget-dist/widget.css) */
|
|
5730
|
-
widgetCssPath?: string;
|
|
5731
|
-
/** Config for the baseline side of a baseline comparison */
|
|
5732
|
-
baselineConfig?: Partial<AgentWidgetConfig>;
|
|
5733
|
-
/** Theme for the baseline side of a baseline comparison */
|
|
5734
|
-
baselineTheme?: DeepPartial<PersonaTheme>;
|
|
5735
|
-
/** Dark theme for the baseline side of a baseline comparison */
|
|
5736
|
-
baselineDarkTheme?: DeepPartial<PersonaTheme>;
|
|
5737
|
-
/** Called after all iframes load and widgets mount */
|
|
5738
|
-
onAfterMount?: (ctx: PreviewLifecycleContext) => void;
|
|
5739
|
-
/** Called after fast-path controller updates */
|
|
5740
|
-
onAfterUpdate?: (ctx: PreviewLifecycleContext) => void;
|
|
5741
|
-
/** Called before controllers are destroyed */
|
|
5742
|
-
onBeforeDestroy?: () => void;
|
|
5743
|
-
/** Called whenever the preview scale changes */
|
|
5744
|
-
onScaleChange?: (scale: number) => void;
|
|
5745
|
-
/** Override iframe srcdoc generation (for background URLs, etc.) */
|
|
5746
|
-
buildSrcdoc?: (mountId: string, shellMode: PreviewShellMode, docked: boolean, cssPath: string) => string;
|
|
5747
|
-
/** Override container HTML injection (for Idiomorph, etc.) */
|
|
5748
|
-
morphContainer?: (container: HTMLElement, html: string) => void;
|
|
5749
|
-
}
|
|
5750
|
-
interface ThemePreviewHandle {
|
|
5751
|
-
/** Update the preview (fast path when possible, full remount when needed) */
|
|
5752
|
-
update(options: Partial<ThemePreviewOptions>): void;
|
|
5753
|
-
/** Destroy preview and clean up */
|
|
5754
|
-
destroy(): void;
|
|
5755
|
-
/** Get live widget controllers */
|
|
5756
|
-
getControllers(): AgentWidgetController[];
|
|
5757
|
-
/** Recalculate auto-fit zoom */
|
|
5758
|
-
fitToContainer(): void;
|
|
5759
|
-
/** Get all preview iframes */
|
|
5760
|
-
getIframes(): HTMLIFrameElement[];
|
|
5761
|
-
/** Get current computed scale */
|
|
5762
|
-
getScale(): number;
|
|
5763
|
-
/** Set explicit zoom (or undefined to auto-fit) */
|
|
5764
|
-
setZoom(zoom: number | undefined): void;
|
|
5765
|
-
}
|
|
5766
|
-
declare function createThemePreview(container: HTMLElement, initialOptions: ThemePreviewOptions): ThemePreviewHandle;
|
|
5767
|
-
|
|
5768
5556
|
/**
|
|
5769
5557
|
* Interface Role → Token mapping layer.
|
|
5770
5558
|
*
|
|
5771
5559
|
* Maps high-level editor choices (family + intensity) to concrete palette
|
|
5772
5560
|
* token references across multiple component/semantic paths. This is the
|
|
5773
|
-
* core of the "Interface Roles" editor section
|
|
5561
|
+
* core of the "Interface Roles" editor section: one picker writes to
|
|
5774
5562
|
* many tokens atomically.
|
|
5775
5563
|
*
|
|
5776
5564
|
* All functions are pure and headless (no DOM).
|
|
@@ -5815,7 +5603,7 @@ interface DetectedRoleAssignment {
|
|
|
5815
5603
|
*/
|
|
5816
5604
|
declare function detectRoleAssignment(getValue: (path: string) => unknown, role: RoleAssignmentOptions): DetectedRoleAssignment | null;
|
|
5817
5605
|
|
|
5818
|
-
/** Color parsing, normalization, and scale generation utilities (pure functions
|
|
5606
|
+
/** Color parsing, normalization, and scale generation utilities (pure functions: no DOM) */
|
|
5819
5607
|
|
|
5820
5608
|
interface ParsedCssValue {
|
|
5821
5609
|
value: number;
|
|
@@ -5831,7 +5619,7 @@ declare function isValidHex(value: string): boolean;
|
|
|
5831
5619
|
* Parse an `rgb()` / `rgba()` string into `#rrggbb`. Accepts integer (0-255) or
|
|
5832
5620
|
* percentage channels; any alpha component is dropped. Returns `null` when the
|
|
5833
5621
|
* string is not a parseable rgb/rgba value, so callers can fall back. This lets
|
|
5834
|
-
* the HSL/luminance paths
|
|
5622
|
+
* the HSL/luminance paths, which otherwise `parseInt` hex digits, accept the
|
|
5835
5623
|
* `rgb()` inputs that `coerceColor` admits without producing `#NaNNaNNaN`.
|
|
5836
5624
|
*/
|
|
5837
5625
|
declare function rgbToHex(value: string): string | null;
|
|
@@ -5906,14 +5694,14 @@ interface WebMcpTool {
|
|
|
5906
5694
|
}
|
|
5907
5695
|
/**
|
|
5908
5696
|
* Wrap a JSON-serializable payload in the MCP tool-result envelope. Compact
|
|
5909
|
-
* JSON (no indentation)
|
|
5697
|
+
* JSON (no indentation): the text is consumed by a model, where pretty-print
|
|
5910
5698
|
* whitespace is pure token overhead.
|
|
5911
5699
|
*/
|
|
5912
5700
|
declare function toolResult(payload: unknown): ToolResult;
|
|
5913
5701
|
/**
|
|
5914
5702
|
* Structural subset of `ThemeEditorState` (and the example app's `state`
|
|
5915
5703
|
* module) that the tools require. Anything satisfying this shape can be wired
|
|
5916
|
-
* to the tools
|
|
5704
|
+
* to the tools: the headless `ThemeEditorState`, or a host's stateful wrapper
|
|
5917
5705
|
* that also drives a live preview (e.g. a Persona widget styling itself).
|
|
5918
5706
|
*/
|
|
5919
5707
|
interface ThemeEditorLike {
|
|
@@ -5945,8 +5733,8 @@ interface CreateThemeEditorToolsOptions {
|
|
|
5945
5733
|
* `createThemeEditorTools(state)` returns transport-agnostic tool definitions
|
|
5946
5734
|
* designed for Agent Experience: intent-level operations (set brand colors,
|
|
5947
5735
|
* assign a color role, set roundness…) rather than a 1:1 mapping of the ~150
|
|
5948
|
-
* editor fields. Two altitudes
|
|
5949
|
-
* escape hatch (`set_theme_fields`)
|
|
5736
|
+
* editor fields. Two altitudes: high-level semantic tools plus a low-level
|
|
5737
|
+
* escape hatch (`set_theme_fields`): keep the catalog small without losing
|
|
5950
5738
|
* coverage. Every mutation returns a compact summary + contrast warnings.
|
|
5951
5739
|
*/
|
|
5952
5740
|
|
|
@@ -6057,4 +5845,4 @@ declare function runContrastChecks(state: ThemeEditorLike, level?: ContrastLevel
|
|
|
6057
5845
|
/** Compact contrast warnings for the regions a mutation touched. */
|
|
6058
5846
|
declare function quickContrastWarnings(state: ThemeEditorLike, pairKeys: string[], variant?: 'light' | 'dark' | 'both', level?: ContrastLevel): ContrastWarning[];
|
|
6059
5847
|
|
|
6060
|
-
export { ADVANCED_TOKENS_SECTION, ALL_ROLES, ALL_TABS, BRAND_PALETTE_SECTION, BUILT_IN_PRESETS, type BuildTranscriptStreamFramesOptions, COLORS_SECTIONS, COLOR_FAMILIES, COMPONENTS_SECTIONS, COMPONENT_COLOR_SECTIONS, COMPONENT_SHAPE_SECTIONS, CONFIGURE_SECTIONS, CONFIGURE_SUB_GROUPS, CONTRAST_PAIRS, CSS_NAMED_COLORS, type ColorScaleOptions, type
|
|
5848
|
+
export { ADVANCED_TOKENS_SECTION, ALL_ROLES, ALL_TABS, BRAND_PALETTE_SECTION, BUILT_IN_PRESETS, type BuildTranscriptStreamFramesOptions, COLORS_SECTIONS, COLOR_FAMILIES, COMPONENTS_SECTIONS, COMPONENT_COLOR_SECTIONS, COMPONENT_SHAPE_SECTIONS, CONFIGURE_SECTIONS, CONFIGURE_SUB_GROUPS, CONTRAST_PAIRS, CSS_NAMED_COLORS, type ColorScaleOptions, type ConfigChangeListener, type ConfiguratorSnapshot, type ContrastCheck, type ContrastLevel, type ContrastReport, type ContrastWarning, type CreateThemeEditorToolsOptions, DEVICE_DIMENSIONS, type DetectedRoleAssignment, type EditTarget, type FieldDef, type FieldType, HOME_SUGGESTION_CHIPS, INTERFACE_ROLES_SECTION, MOCK_BROWSER_CONTENT, MOCK_WORKSPACE_CONTENT, type OnChangeCallback, PALETTE_SECTION, PREVIEW_STORAGE_ADAPTER, type PreviewConfigOptions, type PreviewScene, type PreviewShellPalette, type PreviewTranscriptEntryPreset, RADIUS_PRESETS, ROLE_ASSISTANT_MESSAGES, ROLE_BORDERS, ROLE_FAMILIES, ROLE_FAMILY_LABELS, ROLE_HEADER, ROLE_INPUT, ROLE_INTENSITIES, ROLE_LINKS_FOCUS, ROLE_PRIMARY_ACTIONS, ROLE_SCROLL_TO_BOTTOM, ROLE_SURFACES, ROLE_USER_MESSAGES, type RoleAssignmentOptions, type RoleFamily, type RoleIntensity, type RoleState, type RoleTarget, type RoleTargetKind, SEMANTIC_COLORS_SECTION, SHADE_KEYS, SHELL_STYLE_ID, STATUS_COLORS_SECTION, STATUS_PALETTE_SECTION, STYLE_SECTIONS, STYLE_SECTIONS_V2, type SectionDef, type SectionPreset, type SelectOption, type SliderOptions, type SubGroupDef, THEME_EDITOR_PRESETS, THEME_SECTION, type TabDef, type ThemeEditorLike, type ThemeEditorPreset, ThemeEditorState, type ThemeSummary, type TokenRefOptions, type ToolAnnotations, type ToolContent, type ToolExecute, type ToolImageContent, type ToolResult, type ToolTextContent, type TranscriptStreamFrame, type WebMcpTool, ZOOM_MAX, ZOOM_MIN, appendPreviewTranscriptEntry, applySceneConfig, applyShellTheme, buildPreviewConfig, buildPreviewConfigWithMessages, buildShellCss, buildSrcdoc, buildSummary, buildTranscriptStreamFrames, coerceColor, coerceFamily, coerceIntensity, coerceRadius, coerceRoundnessStyle, coerceScheme, convertFromPx, convertToPx, createPreviewMessages, createPreviewTranscriptEntry, createThemeEditorTools, detectRoleAssignment, escapeHtml, findSection, formatCssValue, generateColorScale, getPreviewTranscriptPresetLabel, getShellPalette, getThemeEditorPreset, hexToHsl, hslToHex, isValidHex, normalizeColorValue, paletteColorPath, parseCssValue, presetStreamsText, quickContrastWarnings, resolveRoleAssignment, resolveThemeColorPath, rgbToHex, runContrastChecks, scopeSection, tokenRefDisplayName, toolResult, wcagContrastRatio };
|