@runtypelabs/persona 4.24.0 → 4.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/approval-ui.d.cts +63 -0
  2. package/dist/approval-ui.d.ts +63 -0
  3. package/dist/artifacts-ui.d.cts +63 -0
  4. package/dist/artifacts-ui.d.ts +63 -0
  5. package/dist/codegen.cjs +1 -1
  6. package/dist/codegen.js +1 -1
  7. package/dist/context-mentions.d.cts +63 -0
  8. package/dist/context-mentions.d.ts +63 -0
  9. package/dist/event-stream-view.d.cts +63 -0
  10. package/dist/event-stream-view.d.ts +63 -0
  11. package/dist/forms-ui.d.cts +74 -0
  12. package/dist/forms-ui.d.ts +74 -0
  13. package/dist/index.cjs +42 -42
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.cts +75 -1
  16. package/dist/index.d.ts +75 -1
  17. package/dist/index.global.js +27 -27
  18. package/dist/index.global.js.map +1 -1
  19. package/dist/index.js +42 -42
  20. package/dist/index.js.map +1 -1
  21. package/dist/session-reconnect.d.cts +63 -0
  22. package/dist/session-reconnect.d.ts +63 -0
  23. package/dist/smart-dom-reader.d.cts +63 -0
  24. package/dist/smart-dom-reader.d.ts +63 -0
  25. package/dist/theme-editor-preview.cjs +49 -49
  26. package/dist/theme-editor-preview.d.cts +63 -0
  27. package/dist/theme-editor-preview.d.ts +63 -0
  28. package/dist/theme-editor-preview.js +27 -27
  29. package/dist/theme-editor.d.cts +63 -0
  30. package/dist/theme-editor.d.ts +63 -0
  31. package/dist/voice-runtime-7DA7MJH4.js +1 -0
  32. package/dist/voice-runtime.cjs +1 -1
  33. package/dist/voice-runtime.d.cts +33 -0
  34. package/dist/voice-runtime.d.ts +33 -0
  35. package/dist/voice-runtime.js +1 -1
  36. package/package.json +1 -1
  37. package/src/index-core.ts +2 -0
  38. package/src/session.ts +30 -1
  39. package/src/session.voice.test.ts +72 -1
  40. package/src/types.ts +71 -0
  41. package/src/ui.ts +59 -0
  42. package/src/ui.voice-prewarm.test.ts +222 -0
  43. package/src/voice/runtype-voice-provider.ts +238 -27
  44. package/src/voice/voice.test.ts +272 -2
  45. package/dist/voice-runtime-EFR3R5ES.js +0 -1
@@ -6720,6 +6720,22 @@ type AgentWidgetStatusIndicatorConfig = {
6720
6720
  /** Status text while a reconnect attempt is in flight. */
6721
6721
  resumingText?: string;
6722
6722
  };
6723
+ /** Built-in `voiceRecognition.prewarm` triggers. See {@link AgentWidgetVoiceRecognitionConfig.prewarm}. */
6724
+ type AgentWidgetVoicePrewarmTrigger = 'hover';
6725
+ /**
6726
+ * Custom `voiceRecognition.prewarm` trigger. Runs while the composer has a mic
6727
+ * button, and again when the button is rebuilt or `update()` swaps in a
6728
+ * different function. Call `warm()` whenever the visitor shows intent to talk
6729
+ * (it is safe to call repeatedly). Return a cleanup to run on replacement.
6730
+ */
6731
+ type AgentWidgetVoicePrewarmHook = (context: {
6732
+ /** Fire-and-forget voice warm-up; latched and error-swallowing. */
6733
+ warm: () => void;
6734
+ /** The composer's current mic button. */
6735
+ micButton: HTMLButtonElement;
6736
+ /** The widget's mount element. */
6737
+ mount: HTMLElement;
6738
+ }) => void | (() => void);
6723
6739
  type AgentWidgetVoiceRecognitionConfig = {
6724
6740
  /**
6725
6741
  * Enable the mic button and voice input. The mic still only renders when the
@@ -6785,6 +6801,29 @@ type AgentWidgetVoiceRecognitionConfig = {
6785
6801
  * Fires once per turn after the reply completes.
6786
6802
  */
6787
6803
  onMetrics?: (metrics: VoiceMetrics) => void;
6804
+ /**
6805
+ * Warm the voice path when the visitor shows intent to talk, before the mic
6806
+ * click, so the call starts faster.
6807
+ *
6808
+ * - `'hover'`: when the pointer enters the mic button, it receives focus, or
6809
+ * (on touch) the first pointer-down on it.
6810
+ * - `false`: never.
6811
+ * - A function: custom trigger. Called with `{ warm, micButton, mount }`
6812
+ * while the mic button exists (and again when the button is rebuilt or
6813
+ * `update()` swaps in a different function); call `warm()` whenever you
6814
+ * decide, e.g. when the panel opens. May return a cleanup that runs on
6815
+ * destroy, rebuild, or replacement. Replaces the built-in trigger.
6816
+ *
6817
+ * What `warm()` does depends on the provider: `runtype` fires its prewarm
6818
+ * (see `provider.runtype.prewarmMode`), a `custom` provider's optional
6819
+ * {@link VoiceProvider.prewarm} runs, and the browser (Web Speech) path
6820
+ * starts the client-token session init (as `sessionInit` does), since speech
6821
+ * recognition itself cannot start before the click. Warming is
6822
+ * fire-and-forget, latched, and never surfaces an error or UI state.
6823
+ *
6824
+ * @default 'hover' in client token mode, otherwise `false`
6825
+ */
6826
+ prewarm?: AgentWidgetVoicePrewarmTrigger | AgentWidgetVoicePrewarmHook | false;
6788
6827
  provider?: {
6789
6828
  type: 'browser' | 'runtype' | 'custom';
6790
6829
  browser?: {
@@ -6806,6 +6845,23 @@ type AgentWidgetVoiceRecognitionConfig = {
6806
6845
  * `@runtypelabs/persona/voice-worklet-player` for a jitter-buffered engine.
6807
6846
  */
6808
6847
  createPlaybackEngine?: () => VoicePlaybackEngine | Promise<VoicePlaybackEngine>;
6848
+ /**
6849
+ * How `prewarm()` warms the voice path (see `voiceRecognition.prewarm`).
6850
+ *
6851
+ * - `'request'` (default): a fire-and-forget
6852
+ * `POST {host}/v1/client/agents/{agentId}/voice/prewarm`.
6853
+ * - `'attach'`: open the voice WebSocket ahead of the click without
6854
+ * starting a call; the click then starts the call on that socket. It can
6855
+ * create server work before the visitor clicks, so it is opt-in.
6856
+ * @default 'request'
6857
+ */
6858
+ prewarmMode?: 'request' | 'attach';
6859
+ /**
6860
+ * `'attach'` mode: how long (ms) an attached socket waits for the click
6861
+ * before it closes. The server clamps it to 30000..600000.
6862
+ * @default 30000
6863
+ */
6864
+ attachIdleMs?: number;
6809
6865
  /** @deprecated No-op on the realtime path: the server's STT owns turn-taking. */
6810
6866
  pauseDuration?: number;
6811
6867
  /** @deprecated No-op on the realtime path: the server's STT owns turn-taking. */
@@ -7115,6 +7171,13 @@ interface VoiceProvider {
7115
7171
  deactivateBargeIn?(): Promise<void>;
7116
7172
  /** Stop playback / cancel in-flight request without starting recording */
7117
7173
  stopPlayback?(): void;
7174
+ /**
7175
+ * Warm the provider ahead of `startListening()` (the widget calls it on mic
7176
+ * intent, see `voiceRecognition.prewarm`). Must be fire-and-forget: never
7177
+ * throw, emit errors or status, or acquire the microphone. May be called
7178
+ * repeatedly; throttle as needed.
7179
+ */
7180
+ prewarm?(): void;
7118
7181
  }
7119
7182
  /**
7120
7183
  * Extra context for an approval decision, surfaced to `onDecision` and to the
@@ -6720,6 +6720,22 @@ type AgentWidgetStatusIndicatorConfig = {
6720
6720
  /** Status text while a reconnect attempt is in flight. */
6721
6721
  resumingText?: string;
6722
6722
  };
6723
+ /** Built-in `voiceRecognition.prewarm` triggers. See {@link AgentWidgetVoiceRecognitionConfig.prewarm}. */
6724
+ type AgentWidgetVoicePrewarmTrigger = 'hover';
6725
+ /**
6726
+ * Custom `voiceRecognition.prewarm` trigger. Runs while the composer has a mic
6727
+ * button, and again when the button is rebuilt or `update()` swaps in a
6728
+ * different function. Call `warm()` whenever the visitor shows intent to talk
6729
+ * (it is safe to call repeatedly). Return a cleanup to run on replacement.
6730
+ */
6731
+ type AgentWidgetVoicePrewarmHook = (context: {
6732
+ /** Fire-and-forget voice warm-up; latched and error-swallowing. */
6733
+ warm: () => void;
6734
+ /** The composer's current mic button. */
6735
+ micButton: HTMLButtonElement;
6736
+ /** The widget's mount element. */
6737
+ mount: HTMLElement;
6738
+ }) => void | (() => void);
6723
6739
  type AgentWidgetVoiceRecognitionConfig = {
6724
6740
  /**
6725
6741
  * Enable the mic button and voice input. The mic still only renders when the
@@ -6785,6 +6801,29 @@ type AgentWidgetVoiceRecognitionConfig = {
6785
6801
  * Fires once per turn after the reply completes.
6786
6802
  */
6787
6803
  onMetrics?: (metrics: VoiceMetrics) => void;
6804
+ /**
6805
+ * Warm the voice path when the visitor shows intent to talk, before the mic
6806
+ * click, so the call starts faster.
6807
+ *
6808
+ * - `'hover'`: when the pointer enters the mic button, it receives focus, or
6809
+ * (on touch) the first pointer-down on it.
6810
+ * - `false`: never.
6811
+ * - A function: custom trigger. Called with `{ warm, micButton, mount }`
6812
+ * while the mic button exists (and again when the button is rebuilt or
6813
+ * `update()` swaps in a different function); call `warm()` whenever you
6814
+ * decide, e.g. when the panel opens. May return a cleanup that runs on
6815
+ * destroy, rebuild, or replacement. Replaces the built-in trigger.
6816
+ *
6817
+ * What `warm()` does depends on the provider: `runtype` fires its prewarm
6818
+ * (see `provider.runtype.prewarmMode`), a `custom` provider's optional
6819
+ * {@link VoiceProvider.prewarm} runs, and the browser (Web Speech) path
6820
+ * starts the client-token session init (as `sessionInit` does), since speech
6821
+ * recognition itself cannot start before the click. Warming is
6822
+ * fire-and-forget, latched, and never surfaces an error or UI state.
6823
+ *
6824
+ * @default 'hover' in client token mode, otherwise `false`
6825
+ */
6826
+ prewarm?: AgentWidgetVoicePrewarmTrigger | AgentWidgetVoicePrewarmHook | false;
6788
6827
  provider?: {
6789
6828
  type: 'browser' | 'runtype' | 'custom';
6790
6829
  browser?: {
@@ -6806,6 +6845,23 @@ type AgentWidgetVoiceRecognitionConfig = {
6806
6845
  * `@runtypelabs/persona/voice-worklet-player` for a jitter-buffered engine.
6807
6846
  */
6808
6847
  createPlaybackEngine?: () => VoicePlaybackEngine | Promise<VoicePlaybackEngine>;
6848
+ /**
6849
+ * How `prewarm()` warms the voice path (see `voiceRecognition.prewarm`).
6850
+ *
6851
+ * - `'request'` (default): a fire-and-forget
6852
+ * `POST {host}/v1/client/agents/{agentId}/voice/prewarm`.
6853
+ * - `'attach'`: open the voice WebSocket ahead of the click without
6854
+ * starting a call; the click then starts the call on that socket. It can
6855
+ * create server work before the visitor clicks, so it is opt-in.
6856
+ * @default 'request'
6857
+ */
6858
+ prewarmMode?: 'request' | 'attach';
6859
+ /**
6860
+ * `'attach'` mode: how long (ms) an attached socket waits for the click
6861
+ * before it closes. The server clamps it to 30000..600000.
6862
+ * @default 30000
6863
+ */
6864
+ attachIdleMs?: number;
6809
6865
  /** @deprecated No-op on the realtime path: the server's STT owns turn-taking. */
6810
6866
  pauseDuration?: number;
6811
6867
  /** @deprecated No-op on the realtime path: the server's STT owns turn-taking. */
@@ -7115,6 +7171,13 @@ interface VoiceProvider {
7115
7171
  deactivateBargeIn?(): Promise<void>;
7116
7172
  /** Stop playback / cancel in-flight request without starting recording */
7117
7173
  stopPlayback?(): void;
7174
+ /**
7175
+ * Warm the provider ahead of `startListening()` (the widget calls it on mic
7176
+ * intent, see `voiceRecognition.prewarm`). Must be fire-and-forget: never
7177
+ * throw, emit errors or status, or acquire the microphone. May be called
7178
+ * repeatedly; throttle as needed.
7179
+ */
7180
+ prewarm?(): void;
7118
7181
  }
7119
7182
  /**
7120
7183
  * Extra context for an approval decision, surfaced to `onDecision` and to the