@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
@@ -6577,6 +6577,22 @@ type AgentWidgetStatusIndicatorConfig = {
6577
6577
  /** Status text while a reconnect attempt is in flight. */
6578
6578
  resumingText?: string;
6579
6579
  };
6580
+ /** Built-in `voiceRecognition.prewarm` triggers. See {@link AgentWidgetVoiceRecognitionConfig.prewarm}. */
6581
+ type AgentWidgetVoicePrewarmTrigger = 'hover';
6582
+ /**
6583
+ * Custom `voiceRecognition.prewarm` trigger. Runs while the composer has a mic
6584
+ * button, and again when the button is rebuilt or `update()` swaps in a
6585
+ * different function. Call `warm()` whenever the visitor shows intent to talk
6586
+ * (it is safe to call repeatedly). Return a cleanup to run on replacement.
6587
+ */
6588
+ type AgentWidgetVoicePrewarmHook = (context: {
6589
+ /** Fire-and-forget voice warm-up; latched and error-swallowing. */
6590
+ warm: () => void;
6591
+ /** The composer's current mic button. */
6592
+ micButton: HTMLButtonElement;
6593
+ /** The widget's mount element. */
6594
+ mount: HTMLElement;
6595
+ }) => void | (() => void);
6580
6596
  type AgentWidgetVoiceRecognitionConfig = {
6581
6597
  /**
6582
6598
  * Enable the mic button and voice input. The mic still only renders when the
@@ -6642,6 +6658,29 @@ type AgentWidgetVoiceRecognitionConfig = {
6642
6658
  * Fires once per turn after the reply completes.
6643
6659
  */
6644
6660
  onMetrics?: (metrics: VoiceMetrics) => void;
6661
+ /**
6662
+ * Warm the voice path when the visitor shows intent to talk, before the mic
6663
+ * click, so the call starts faster.
6664
+ *
6665
+ * - `'hover'`: when the pointer enters the mic button, it receives focus, or
6666
+ * (on touch) the first pointer-down on it.
6667
+ * - `false`: never.
6668
+ * - A function: custom trigger. Called with `{ warm, micButton, mount }`
6669
+ * while the mic button exists (and again when the button is rebuilt or
6670
+ * `update()` swaps in a different function); call `warm()` whenever you
6671
+ * decide, e.g. when the panel opens. May return a cleanup that runs on
6672
+ * destroy, rebuild, or replacement. Replaces the built-in trigger.
6673
+ *
6674
+ * What `warm()` does depends on the provider: `runtype` fires its prewarm
6675
+ * (see `provider.runtype.prewarmMode`), a `custom` provider's optional
6676
+ * {@link VoiceProvider.prewarm} runs, and the browser (Web Speech) path
6677
+ * starts the client-token session init (as `sessionInit` does), since speech
6678
+ * recognition itself cannot start before the click. Warming is
6679
+ * fire-and-forget, latched, and never surfaces an error or UI state.
6680
+ *
6681
+ * @default 'hover' in client token mode, otherwise `false`
6682
+ */
6683
+ prewarm?: AgentWidgetVoicePrewarmTrigger | AgentWidgetVoicePrewarmHook | false;
6645
6684
  provider?: {
6646
6685
  type: 'browser' | 'runtype' | 'custom';
6647
6686
  browser?: {
@@ -6663,6 +6702,23 @@ type AgentWidgetVoiceRecognitionConfig = {
6663
6702
  * `@runtypelabs/persona/voice-worklet-player` for a jitter-buffered engine.
6664
6703
  */
6665
6704
  createPlaybackEngine?: () => VoicePlaybackEngine | Promise<VoicePlaybackEngine>;
6705
+ /**
6706
+ * How `prewarm()` warms the voice path (see `voiceRecognition.prewarm`).
6707
+ *
6708
+ * - `'request'` (default): a fire-and-forget
6709
+ * `POST {host}/v1/client/agents/{agentId}/voice/prewarm`.
6710
+ * - `'attach'`: open the voice WebSocket ahead of the click without
6711
+ * starting a call; the click then starts the call on that socket. It can
6712
+ * create server work before the visitor clicks, so it is opt-in.
6713
+ * @default 'request'
6714
+ */
6715
+ prewarmMode?: 'request' | 'attach';
6716
+ /**
6717
+ * `'attach'` mode: how long (ms) an attached socket waits for the click
6718
+ * before it closes. The server clamps it to 30000..600000.
6719
+ * @default 30000
6720
+ */
6721
+ attachIdleMs?: number;
6666
6722
  /** @deprecated No-op on the realtime path: the server's STT owns turn-taking. */
6667
6723
  pauseDuration?: number;
6668
6724
  /** @deprecated No-op on the realtime path: the server's STT owns turn-taking. */
@@ -6963,6 +7019,13 @@ interface VoiceProvider {
6963
7019
  deactivateBargeIn?(): Promise<void>;
6964
7020
  /** Stop playback / cancel in-flight request without starting recording */
6965
7021
  stopPlayback?(): void;
7022
+ /**
7023
+ * Warm the provider ahead of `startListening()` (the widget calls it on mic
7024
+ * intent, see `voiceRecognition.prewarm`). Must be fire-and-forget: never
7025
+ * throw, emit errors or status, or acquire the microphone. May be called
7026
+ * repeatedly; throttle as needed.
7027
+ */
7028
+ prewarm?(): void;
6966
7029
  }
6967
7030
  /**
6968
7031
  * Extra context for an approval decision, surfaced to `onDecision` and to the
@@ -6577,6 +6577,22 @@ type AgentWidgetStatusIndicatorConfig = {
6577
6577
  /** Status text while a reconnect attempt is in flight. */
6578
6578
  resumingText?: string;
6579
6579
  };
6580
+ /** Built-in `voiceRecognition.prewarm` triggers. See {@link AgentWidgetVoiceRecognitionConfig.prewarm}. */
6581
+ type AgentWidgetVoicePrewarmTrigger = 'hover';
6582
+ /**
6583
+ * Custom `voiceRecognition.prewarm` trigger. Runs while the composer has a mic
6584
+ * button, and again when the button is rebuilt or `update()` swaps in a
6585
+ * different function. Call `warm()` whenever the visitor shows intent to talk
6586
+ * (it is safe to call repeatedly). Return a cleanup to run on replacement.
6587
+ */
6588
+ type AgentWidgetVoicePrewarmHook = (context: {
6589
+ /** Fire-and-forget voice warm-up; latched and error-swallowing. */
6590
+ warm: () => void;
6591
+ /** The composer's current mic button. */
6592
+ micButton: HTMLButtonElement;
6593
+ /** The widget's mount element. */
6594
+ mount: HTMLElement;
6595
+ }) => void | (() => void);
6580
6596
  type AgentWidgetVoiceRecognitionConfig = {
6581
6597
  /**
6582
6598
  * Enable the mic button and voice input. The mic still only renders when the
@@ -6642,6 +6658,29 @@ type AgentWidgetVoiceRecognitionConfig = {
6642
6658
  * Fires once per turn after the reply completes.
6643
6659
  */
6644
6660
  onMetrics?: (metrics: VoiceMetrics) => void;
6661
+ /**
6662
+ * Warm the voice path when the visitor shows intent to talk, before the mic
6663
+ * click, so the call starts faster.
6664
+ *
6665
+ * - `'hover'`: when the pointer enters the mic button, it receives focus, or
6666
+ * (on touch) the first pointer-down on it.
6667
+ * - `false`: never.
6668
+ * - A function: custom trigger. Called with `{ warm, micButton, mount }`
6669
+ * while the mic button exists (and again when the button is rebuilt or
6670
+ * `update()` swaps in a different function); call `warm()` whenever you
6671
+ * decide, e.g. when the panel opens. May return a cleanup that runs on
6672
+ * destroy, rebuild, or replacement. Replaces the built-in trigger.
6673
+ *
6674
+ * What `warm()` does depends on the provider: `runtype` fires its prewarm
6675
+ * (see `provider.runtype.prewarmMode`), a `custom` provider's optional
6676
+ * {@link VoiceProvider.prewarm} runs, and the browser (Web Speech) path
6677
+ * starts the client-token session init (as `sessionInit` does), since speech
6678
+ * recognition itself cannot start before the click. Warming is
6679
+ * fire-and-forget, latched, and never surfaces an error or UI state.
6680
+ *
6681
+ * @default 'hover' in client token mode, otherwise `false`
6682
+ */
6683
+ prewarm?: AgentWidgetVoicePrewarmTrigger | AgentWidgetVoicePrewarmHook | false;
6645
6684
  provider?: {
6646
6685
  type: 'browser' | 'runtype' | 'custom';
6647
6686
  browser?: {
@@ -6663,6 +6702,23 @@ type AgentWidgetVoiceRecognitionConfig = {
6663
6702
  * `@runtypelabs/persona/voice-worklet-player` for a jitter-buffered engine.
6664
6703
  */
6665
6704
  createPlaybackEngine?: () => VoicePlaybackEngine | Promise<VoicePlaybackEngine>;
6705
+ /**
6706
+ * How `prewarm()` warms the voice path (see `voiceRecognition.prewarm`).
6707
+ *
6708
+ * - `'request'` (default): a fire-and-forget
6709
+ * `POST {host}/v1/client/agents/{agentId}/voice/prewarm`.
6710
+ * - `'attach'`: open the voice WebSocket ahead of the click without
6711
+ * starting a call; the click then starts the call on that socket. It can
6712
+ * create server work before the visitor clicks, so it is opt-in.
6713
+ * @default 'request'
6714
+ */
6715
+ prewarmMode?: 'request' | 'attach';
6716
+ /**
6717
+ * `'attach'` mode: how long (ms) an attached socket waits for the click
6718
+ * before it closes. The server clamps it to 30000..600000.
6719
+ * @default 30000
6720
+ */
6721
+ attachIdleMs?: number;
6666
6722
  /** @deprecated No-op on the realtime path: the server's STT owns turn-taking. */
6667
6723
  pauseDuration?: number;
6668
6724
  /** @deprecated No-op on the realtime path: the server's STT owns turn-taking. */
@@ -6963,6 +7019,13 @@ interface VoiceProvider {
6963
7019
  deactivateBargeIn?(): Promise<void>;
6964
7020
  /** Stop playback / cancel in-flight request without starting recording */
6965
7021
  stopPlayback?(): void;
7022
+ /**
7023
+ * Warm the provider ahead of `startListening()` (the widget calls it on mic
7024
+ * intent, see `voiceRecognition.prewarm`). Must be fire-and-forget: never
7025
+ * throw, emit errors or status, or acquire the microphone. May be called
7026
+ * repeatedly; throttle as needed.
7027
+ */
7028
+ prewarm?(): void;
6966
7029
  }
6967
7030
  /**
6968
7031
  * Extra context for an approval decision, surfaced to `onDecision` and to the
@@ -6846,6 +6846,22 @@ type AgentWidgetStatusIndicatorConfig = {
6846
6846
  /** Status text while a reconnect attempt is in flight. */
6847
6847
  resumingText?: string;
6848
6848
  };
6849
+ /** Built-in `voiceRecognition.prewarm` triggers. See {@link AgentWidgetVoiceRecognitionConfig.prewarm}. */
6850
+ type AgentWidgetVoicePrewarmTrigger = 'hover';
6851
+ /**
6852
+ * Custom `voiceRecognition.prewarm` trigger. Runs while the composer has a mic
6853
+ * button, and again when the button is rebuilt or `update()` swaps in a
6854
+ * different function. Call `warm()` whenever the visitor shows intent to talk
6855
+ * (it is safe to call repeatedly). Return a cleanup to run on replacement.
6856
+ */
6857
+ type AgentWidgetVoicePrewarmHook = (context: {
6858
+ /** Fire-and-forget voice warm-up; latched and error-swallowing. */
6859
+ warm: () => void;
6860
+ /** The composer's current mic button. */
6861
+ micButton: HTMLButtonElement;
6862
+ /** The widget's mount element. */
6863
+ mount: HTMLElement;
6864
+ }) => void | (() => void);
6849
6865
  type AgentWidgetVoiceRecognitionConfig = {
6850
6866
  /**
6851
6867
  * Enable the mic button and voice input. The mic still only renders when the
@@ -6911,6 +6927,29 @@ type AgentWidgetVoiceRecognitionConfig = {
6911
6927
  * Fires once per turn after the reply completes.
6912
6928
  */
6913
6929
  onMetrics?: (metrics: VoiceMetrics) => void;
6930
+ /**
6931
+ * Warm the voice path when the visitor shows intent to talk, before the mic
6932
+ * click, so the call starts faster.
6933
+ *
6934
+ * - `'hover'`: when the pointer enters the mic button, it receives focus, or
6935
+ * (on touch) the first pointer-down on it.
6936
+ * - `false`: never.
6937
+ * - A function: custom trigger. Called with `{ warm, micButton, mount }`
6938
+ * while the mic button exists (and again when the button is rebuilt or
6939
+ * `update()` swaps in a different function); call `warm()` whenever you
6940
+ * decide, e.g. when the panel opens. May return a cleanup that runs on
6941
+ * destroy, rebuild, or replacement. Replaces the built-in trigger.
6942
+ *
6943
+ * What `warm()` does depends on the provider: `runtype` fires its prewarm
6944
+ * (see `provider.runtype.prewarmMode`), a `custom` provider's optional
6945
+ * {@link VoiceProvider.prewarm} runs, and the browser (Web Speech) path
6946
+ * starts the client-token session init (as `sessionInit` does), since speech
6947
+ * recognition itself cannot start before the click. Warming is
6948
+ * fire-and-forget, latched, and never surfaces an error or UI state.
6949
+ *
6950
+ * @default 'hover' in client token mode, otherwise `false`
6951
+ */
6952
+ prewarm?: AgentWidgetVoicePrewarmTrigger | AgentWidgetVoicePrewarmHook | false;
6914
6953
  provider?: {
6915
6954
  type: 'browser' | 'runtype' | 'custom';
6916
6955
  browser?: {
@@ -6932,6 +6971,23 @@ type AgentWidgetVoiceRecognitionConfig = {
6932
6971
  * `@runtypelabs/persona/voice-worklet-player` for a jitter-buffered engine.
6933
6972
  */
6934
6973
  createPlaybackEngine?: () => VoicePlaybackEngine | Promise<VoicePlaybackEngine>;
6974
+ /**
6975
+ * How `prewarm()` warms the voice path (see `voiceRecognition.prewarm`).
6976
+ *
6977
+ * - `'request'` (default): a fire-and-forget
6978
+ * `POST {host}/v1/client/agents/{agentId}/voice/prewarm`.
6979
+ * - `'attach'`: open the voice WebSocket ahead of the click without
6980
+ * starting a call; the click then starts the call on that socket. It can
6981
+ * create server work before the visitor clicks, so it is opt-in.
6982
+ * @default 'request'
6983
+ */
6984
+ prewarmMode?: 'request' | 'attach';
6985
+ /**
6986
+ * `'attach'` mode: how long (ms) an attached socket waits for the click
6987
+ * before it closes. The server clamps it to 30000..600000.
6988
+ * @default 30000
6989
+ */
6990
+ attachIdleMs?: number;
6935
6991
  /** @deprecated No-op on the realtime path: the server's STT owns turn-taking. */
6936
6992
  pauseDuration?: number;
6937
6993
  /** @deprecated No-op on the realtime path: the server's STT owns turn-taking. */
@@ -7232,6 +7288,13 @@ interface VoiceProvider {
7232
7288
  deactivateBargeIn?(): Promise<void>;
7233
7289
  /** Stop playback / cancel in-flight request without starting recording */
7234
7290
  stopPlayback?(): void;
7291
+ /**
7292
+ * Warm the provider ahead of `startListening()` (the widget calls it on mic
7293
+ * intent, see `voiceRecognition.prewarm`). Must be fire-and-forget: never
7294
+ * throw, emit errors or status, or acquire the microphone. May be called
7295
+ * repeatedly; throttle as needed.
7296
+ */
7297
+ prewarm?(): void;
7235
7298
  }
7236
7299
  /**
7237
7300
  * Extra context for an approval decision, surfaced to `onDecision` and to the
@@ -6846,6 +6846,22 @@ type AgentWidgetStatusIndicatorConfig = {
6846
6846
  /** Status text while a reconnect attempt is in flight. */
6847
6847
  resumingText?: string;
6848
6848
  };
6849
+ /** Built-in `voiceRecognition.prewarm` triggers. See {@link AgentWidgetVoiceRecognitionConfig.prewarm}. */
6850
+ type AgentWidgetVoicePrewarmTrigger = 'hover';
6851
+ /**
6852
+ * Custom `voiceRecognition.prewarm` trigger. Runs while the composer has a mic
6853
+ * button, and again when the button is rebuilt or `update()` swaps in a
6854
+ * different function. Call `warm()` whenever the visitor shows intent to talk
6855
+ * (it is safe to call repeatedly). Return a cleanup to run on replacement.
6856
+ */
6857
+ type AgentWidgetVoicePrewarmHook = (context: {
6858
+ /** Fire-and-forget voice warm-up; latched and error-swallowing. */
6859
+ warm: () => void;
6860
+ /** The composer's current mic button. */
6861
+ micButton: HTMLButtonElement;
6862
+ /** The widget's mount element. */
6863
+ mount: HTMLElement;
6864
+ }) => void | (() => void);
6849
6865
  type AgentWidgetVoiceRecognitionConfig = {
6850
6866
  /**
6851
6867
  * Enable the mic button and voice input. The mic still only renders when the
@@ -6911,6 +6927,29 @@ type AgentWidgetVoiceRecognitionConfig = {
6911
6927
  * Fires once per turn after the reply completes.
6912
6928
  */
6913
6929
  onMetrics?: (metrics: VoiceMetrics) => void;
6930
+ /**
6931
+ * Warm the voice path when the visitor shows intent to talk, before the mic
6932
+ * click, so the call starts faster.
6933
+ *
6934
+ * - `'hover'`: when the pointer enters the mic button, it receives focus, or
6935
+ * (on touch) the first pointer-down on it.
6936
+ * - `false`: never.
6937
+ * - A function: custom trigger. Called with `{ warm, micButton, mount }`
6938
+ * while the mic button exists (and again when the button is rebuilt or
6939
+ * `update()` swaps in a different function); call `warm()` whenever you
6940
+ * decide, e.g. when the panel opens. May return a cleanup that runs on
6941
+ * destroy, rebuild, or replacement. Replaces the built-in trigger.
6942
+ *
6943
+ * What `warm()` does depends on the provider: `runtype` fires its prewarm
6944
+ * (see `provider.runtype.prewarmMode`), a `custom` provider's optional
6945
+ * {@link VoiceProvider.prewarm} runs, and the browser (Web Speech) path
6946
+ * starts the client-token session init (as `sessionInit` does), since speech
6947
+ * recognition itself cannot start before the click. Warming is
6948
+ * fire-and-forget, latched, and never surfaces an error or UI state.
6949
+ *
6950
+ * @default 'hover' in client token mode, otherwise `false`
6951
+ */
6952
+ prewarm?: AgentWidgetVoicePrewarmTrigger | AgentWidgetVoicePrewarmHook | false;
6914
6953
  provider?: {
6915
6954
  type: 'browser' | 'runtype' | 'custom';
6916
6955
  browser?: {
@@ -6932,6 +6971,23 @@ type AgentWidgetVoiceRecognitionConfig = {
6932
6971
  * `@runtypelabs/persona/voice-worklet-player` for a jitter-buffered engine.
6933
6972
  */
6934
6973
  createPlaybackEngine?: () => VoicePlaybackEngine | Promise<VoicePlaybackEngine>;
6974
+ /**
6975
+ * How `prewarm()` warms the voice path (see `voiceRecognition.prewarm`).
6976
+ *
6977
+ * - `'request'` (default): a fire-and-forget
6978
+ * `POST {host}/v1/client/agents/{agentId}/voice/prewarm`.
6979
+ * - `'attach'`: open the voice WebSocket ahead of the click without
6980
+ * starting a call; the click then starts the call on that socket. It can
6981
+ * create server work before the visitor clicks, so it is opt-in.
6982
+ * @default 'request'
6983
+ */
6984
+ prewarmMode?: 'request' | 'attach';
6985
+ /**
6986
+ * `'attach'` mode: how long (ms) an attached socket waits for the click
6987
+ * before it closes. The server clamps it to 30000..600000.
6988
+ * @default 30000
6989
+ */
6990
+ attachIdleMs?: number;
6935
6991
  /** @deprecated No-op on the realtime path: the server's STT owns turn-taking. */
6936
6992
  pauseDuration?: number;
6937
6993
  /** @deprecated No-op on the realtime path: the server's STT owns turn-taking. */
@@ -7232,6 +7288,13 @@ interface VoiceProvider {
7232
7288
  deactivateBargeIn?(): Promise<void>;
7233
7289
  /** Stop playback / cancel in-flight request without starting recording */
7234
7290
  stopPlayback?(): void;
7291
+ /**
7292
+ * Warm the provider ahead of `startListening()` (the widget calls it on mic
7293
+ * intent, see `voiceRecognition.prewarm`). Must be fire-and-forget: never
7294
+ * throw, emit errors or status, or acquire the microphone. May be called
7295
+ * repeatedly; throttle as needed.
7296
+ */
7297
+ prewarm?(): void;
7235
7298
  }
7236
7299
  /**
7237
7300
  * Extra context for an approval decision, surfaced to `onDecision` and to the