@runtypelabs/persona 4.31.0 → 4.32.1

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 (141) hide show
  1. package/dist/activity-ui.cjs +2 -2
  2. package/dist/activity-ui.d.cts +11 -3
  3. package/dist/activity-ui.d.ts +11 -3
  4. package/dist/activity-ui.js +1 -1
  5. package/dist/animations/glyph-cycle.d.cts +1 -1
  6. package/dist/animations/glyph-cycle.d.ts +1 -1
  7. package/dist/animations/wipe.d.cts +1 -1
  8. package/dist/animations/wipe.d.ts +1 -1
  9. package/dist/approval-ui.d.cts +2 -2
  10. package/dist/approval-ui.d.ts +2 -2
  11. package/dist/artifacts-ui.d.cts +3 -3
  12. package/dist/artifacts-ui.d.ts +3 -3
  13. package/dist/background-runtime.d.cts +1 -1
  14. package/dist/background-runtime.d.ts +1 -1
  15. package/dist/{chunk-BrptyKSq.js → chunk-B3l7TOOv.js} +1 -1
  16. package/dist/chunk-B4ecQzeK.js +2 -0
  17. package/dist/{chunk-BWCo3rCm.js → chunk-B_H0l3u2.js} +1 -1
  18. package/dist/{chunk-MdlQetfC.js → chunk-BbXc58OA.js} +1 -1
  19. package/dist/chunk-BkOYJ11B.js +1 -0
  20. package/dist/{chunk-DE0cSmku.js → chunk-BpjtKnGI.js} +1 -1
  21. package/dist/{chunk-Co4LmTFv.js → chunk-C9uOhfk5.js} +1 -1
  22. package/dist/{chunk-CHAwCqpk.js → chunk-CdpVP6LZ.js} +1 -1
  23. package/dist/{chunk-WA9UucGf.js → chunk-CumoXK3u.js} +1 -1
  24. package/dist/{chunk-BBtVdcKU.js → chunk-DM-OJt5q.js} +1 -1
  25. package/dist/{chunk-Cb7qy0c7.js → chunk-DNdeIFJ6.js} +1 -1
  26. package/dist/{chunk-VaT6xry9.js → chunk-DTGvDx8o.js} +1 -1
  27. package/dist/{chunk-ezlpsYGk.js → chunk-DVZ8ri1z.js} +1 -1
  28. package/dist/{chunk-DhedQnek.js → chunk-DgZZqy14.js} +1 -1
  29. package/dist/{chunk-C2IbR39s.js → chunk-UWMfWW2a.js} +1 -1
  30. package/dist/client-dispatch.js +1 -1
  31. package/dist/client-history.js +1 -1
  32. package/dist/codegen.cjs +1 -1
  33. package/dist/codegen.js +1 -1
  34. package/dist/composer-actions-runtime.d.cts +2 -2
  35. package/dist/composer-actions-runtime.d.ts +2 -2
  36. package/dist/{composer-input-C2_WizXV.d.cts → composer-input-dwg_o9Z-.d.cts} +1 -1
  37. package/dist/{composer-input-C2_WizXV.d.ts → composer-input-dwg_o9Z-.d.ts} +1 -1
  38. package/dist/{composer-store-BV6kTlKv.d.cts → composer-store-Dw7Zbqxr.d.cts} +1 -1
  39. package/dist/{composer-store-BV6kTlKv.d.ts → composer-store-Dw7Zbqxr.d.ts} +1 -1
  40. package/dist/{context-mention-manager-BfZzcydV.d.cts → context-mention-manager-D2p0-JH-.d.cts} +2 -2
  41. package/dist/{context-mention-manager-BfZzcydV.d.ts → context-mention-manager-D2p0-JH-.d.ts} +2 -2
  42. package/dist/context-mentions-inline.d.cts +2 -2
  43. package/dist/context-mentions-inline.d.ts +2 -2
  44. package/dist/context-mentions.d.cts +3 -3
  45. package/dist/context-mentions.d.ts +3 -3
  46. package/dist/{defaults-DiTeXyr3.d.cts → defaults-CjX0kKzb.d.cts} +1 -1
  47. package/dist/{defaults-DiTeXyr3.d.ts → defaults-CjX0kKzb.d.ts} +1 -1
  48. package/dist/dictation-runtime.d.cts +2 -2
  49. package/dist/dictation-runtime.d.ts +2 -2
  50. package/dist/event-stream-view.d.cts +1 -1
  51. package/dist/event-stream-view.d.ts +1 -1
  52. package/dist/{fallback-speech-engine-DZ6Of7VU.d.cts → fallback-speech-engine-DmF7MczI.d.cts} +1 -1
  53. package/dist/{fallback-speech-engine-DZ6Of7VU.d.ts → fallback-speech-engine-DmF7MczI.d.ts} +1 -1
  54. package/dist/{feature-preferences-BT549D_E.d.cts → feature-preferences-CVFDt9Xf.d.cts} +1 -1
  55. package/dist/{feature-preferences-BT549D_E.d.ts → feature-preferences-CVFDt9Xf.d.ts} +1 -1
  56. package/dist/forms-ui.d.cts +2 -2
  57. package/dist/forms-ui.d.ts +2 -2
  58. package/dist/{history-confirm-dialog-Cm4oK4am.d.cts → history-confirm-dialog-DJEXsTyE.d.cts} +1 -1
  59. package/dist/{history-confirm-dialog-Cm4oK4am.d.ts → history-confirm-dialog-DJEXsTyE.d.ts} +1 -1
  60. package/dist/history-shell.d.cts +6 -6
  61. package/dist/history-shell.d.ts +6 -6
  62. package/dist/history-view.d.cts +1 -1
  63. package/dist/history-view.d.ts +1 -1
  64. package/dist/index.cjs +11 -10
  65. package/dist/index.cjs.map +1 -1
  66. package/dist/index.d.cts +9 -9
  67. package/dist/index.d.ts +9 -9
  68. package/dist/index.global.js +1 -1
  69. package/dist/index.global.js.map +1 -1
  70. package/dist/index.js +23 -22
  71. package/dist/index.js.map +1 -1
  72. package/dist/launcher.global.js +1 -1
  73. package/dist/launcher.global.js.map +1 -1
  74. package/dist/{loading-label-runtime-loader-DmiPDkBu.d.cts → loading-label-runtime-loader-CPxnoaoi.d.cts} +1 -1
  75. package/dist/{loading-label-runtime-loader-DmiPDkBu.d.ts → loading-label-runtime-loader-CPxnoaoi.d.ts} +1 -1
  76. package/dist/loading-label-runtime.d.cts +1 -1
  77. package/dist/loading-label-runtime.d.ts +1 -1
  78. package/dist/{message-bubble-D0rosKuK.d.cts → message-bubble-CkZGlCLC.d.cts} +1 -1
  79. package/dist/{message-bubble-D0rosKuK.d.ts → message-bubble-CkZGlCLC.d.ts} +1 -1
  80. package/dist/preferences-runtime.d.cts +1 -1
  81. package/dist/preferences-runtime.d.ts +1 -1
  82. package/dist/{preview-DRU27q-X.d.cts → preview-DdUvoLb4.d.cts} +2 -2
  83. package/dist/{preview-DRU27q-X.d.ts → preview-DdUvoLb4.d.ts} +2 -2
  84. package/dist/{registry-DRk3VMFc.d.cts → registry-Dz4iHNST.d.cts} +1 -1
  85. package/dist/{registry-DRk3VMFc.d.ts → registry-Dz4iHNST.d.ts} +1 -1
  86. package/dist/{session-Dj4bOm5y.d.cts → session-Baxp9iRK.d.cts} +14 -8
  87. package/dist/{session-Dj4bOm5y.d.ts → session-Baxp9iRK.d.ts} +14 -8
  88. package/dist/session-reconnect.d.cts +2 -2
  89. package/dist/session-reconnect.d.ts +2 -2
  90. package/dist/smart-dom-reader.d.cts +1 -1
  91. package/dist/smart-dom-reader.d.ts +1 -1
  92. package/dist/theme-editor-preview.cjs +46 -45
  93. package/dist/theme-editor-preview.d.cts +1 -1
  94. package/dist/theme-editor-preview.d.ts +1 -1
  95. package/dist/theme-editor-preview.js +19 -18
  96. package/dist/theme-editor.cjs +1 -1
  97. package/dist/theme-editor.d.cts +2 -2
  98. package/dist/theme-editor.d.ts +2 -2
  99. package/dist/theme-editor.js +1 -1
  100. package/dist/theme-reference.cjs +1 -1
  101. package/dist/theme-reference.d.cts +2 -2
  102. package/dist/theme-reference.d.ts +2 -2
  103. package/dist/theme-reference.js +1 -1
  104. package/dist/{tool-loading-animation-D1MS5Ace.d.cts → tool-loading-animation-un3kA5Ur.d.cts} +1 -1
  105. package/dist/{tool-loading-animation-D1MS5Ace.d.ts → tool-loading-animation-un3kA5Ur.d.ts} +1 -1
  106. package/dist/{turn-activity-ui-CorwdlI0.d.cts → turn-activity-ui-BGNhtMcH.d.cts} +2 -2
  107. package/dist/{turn-activity-ui-CorwdlI0.d.ts → turn-activity-ui-BGNhtMcH.d.ts} +2 -2
  108. package/dist/turn-activity-ui.d.cts +1 -1
  109. package/dist/turn-activity-ui.d.ts +1 -1
  110. package/dist/{types-CSXHl5cN.d.cts → types-BOZHQIk0.d.cts} +8 -1
  111. package/dist/{types-CSXHl5cN.d.ts → types-BOZHQIk0.d.ts} +8 -1
  112. package/dist/voice-client-tools.d.cts +1 -1
  113. package/dist/voice-client-tools.d.ts +1 -1
  114. package/dist/voice-runtime.cjs +1 -1
  115. package/dist/voice-runtime.d.cts +2 -2
  116. package/dist/voice-runtime.d.ts +2 -2
  117. package/dist/voice-runtime.js +1 -1
  118. package/dist/voice-worklet-player.d.cts +2 -2
  119. package/dist/voice-worklet-player.d.ts +2 -2
  120. package/dist/{webmcp-runtime-entry-DpDN6k-6.d.cts → webmcp-runtime-entry-DuAG1_yF.d.cts} +1 -1
  121. package/dist/{webmcp-runtime-entry-DpDN6k-6.d.ts → webmcp-runtime-entry-DuAG1_yF.d.ts} +1 -1
  122. package/dist/webmcp-runtime.d.cts +1 -1
  123. package/dist/webmcp-runtime.d.ts +1 -1
  124. package/dist/widget.css +1 -1
  125. package/package.json +1 -1
  126. package/src/activity-ui.ts +23 -0
  127. package/src/components/disclosure-animation.ts +5 -0
  128. package/src/components/tool-bubble.ts +1 -0
  129. package/src/index-core.ts +1 -0
  130. package/src/styles/widget.css +18 -0
  131. package/src/types.ts +8 -0
  132. package/src/ui.footer-visibility.test.ts +54 -0
  133. package/src/ui.reveal-tool-call.test.ts +258 -0
  134. package/src/ui.ts +127 -5
  135. package/src/utils/brand.test.ts +50 -0
  136. package/src/utils/brand.ts +6 -2
  137. package/src/utils/tokens.ts +2 -1
  138. package/src/utils/tool-activity-summary.test.ts +8 -0
  139. package/src/utils/tool-activity-summary.ts +2 -1
  140. package/dist/chunk-B3OrH9Ng.js +0 -2
  141. package/dist/chunk-CjhA_5Jk.js +0 -1
@@ -6511,6 +6511,13 @@ type AgentWidgetOpenConversationOptions = {
6511
6511
  /** Default "reject"; "stop" stops locally; "background" requires backgroundConversations. */
6512
6512
  busy?: "reject" | "stop" | "background";
6513
6513
  };
6514
+ /** Options for `controller.revealToolCall()`. */
6515
+ type AgentWidgetRevealToolCallOptions = {
6516
+ /** Expand the tool's details. Default true. */
6517
+ expand?: boolean;
6518
+ /** How long the bubble keeps `data-persona-revealed`, in ms; 0 skips the mark. Default 2000. */
6519
+ highlightMs?: number;
6520
+ };
6514
6521
  /** The single in-flight history operation, or `null` when idle. */
6515
6522
  type HistoryPendingAction = {
6516
6523
  kind: "refresh" | "load-more" | "start-new" | "clear" | "reset";
@@ -12338,5 +12345,5 @@ type AgentWidgetInitOptions = {
12338
12345
  debugTools?: boolean;
12339
12346
  };
12340
12347
  //#endregion
12341
- export { AgentWidgetEvent as $, ArtifactPaneTokens as $a, VoiceClientToolsSession as $i, ClientToolsFrame as $n, HistoryConversationPage as $r, AgentWidgetStateSnapshot as $t, AgentWidgetConfigPatch as A, HistoryPageOptions as Aa, PersonaArtifactPresentation as Ai, AgentWidgetWelcomeDismiss as An, TypographyScale as Ao, ComposerQuote as Ar, AgentWidgetReadAloudEvent as At, AgentWidgetContextMentionRef as B, RuntypeClientChatStreamEvent as Ba, SlotRenderResult as Bi, AttachmentPreviewRenderContext as Bn, parseCombo as Bo, DictationProviderConfig as Br, AgentWidgetRunStartedEvent as Bt, AgentWidgetAttachmentsConfig as C, IconName as Ca, PersonaArtifactDisplayMode as Ci, AgentWidgetTurnActivityConfig as Cn, ShadowScale as Co, ComposerModeGroupPresentation as Cr, AgentWidgetMessage as Ct, AgentWidgetComponentRenderer as D, HistoryListOptions as Da, PersonaArtifactFilesDisplayRules as Di, AgentWidgetWebMcpConfig as Dn, ThemeValidationResult as Do, ComposerOptionsPayload as Dr, AgentWidgetMessageRoleLayout as Dt, AgentWidgetComponentRenderHandle as E, HistoryDeleteAllOptions as Ea, PersonaArtifactFileMeta as Ei, AgentWidgetVoiceStatusEvent as En, ThemeValidationError as Eo, ComposerModelPickerPresentation as Er, AgentWidgetMessageLayoutConfig as Et, AgentWidgetContextMentionConfig as F, PreparedHistoryActivation as Fa, ResolvedHistoryCopy as Fi, ArtifactConfigPayload as Fn, AgentWidgetRenderWelcomeContext as Fo, ComposerSubmissionSnapshot as Fr, AgentWidgetRenderHistoryStateContext as Ft, AgentWidgetContextProvider as G, RuntypeClientInitResponse as Ga, StreamAnimationContext as Gi, ClientChatRequest as Gn, EventStreamBadgeColor as Gr, AgentWidgetScrollRestorePosition as Gt, AgentWidgetContextMentionSearchContext as H, RuntypeClientFeedbackResponse as Ha, SpeechCallbacks as Hi, AttachmentPreviewState as Hn, ResolvedWelcomeConfig as Ho, DictationRenderHandle as Hr, AgentWidgetSSEEventResult as Ht, AgentWidgetContextMentionItem as I, isHistoryProviderError as Ia, ResolvedHistoryPresentation as Ii, AskUserQuestionOption as In, AgentWidgetSuggestionSelectContext as Io, ComposerSubmitKey as Ir, AgentWidgetRenderHistoryViewContext as It, AgentWidgetCustomFetch as J, RuntypeExecutionStreamEvent as Ja, ToolAnnotations as Ji, ClientInitResponse as Jn, EventStreamRowRenderContext as Jr, AgentWidgetScrollToBottomIconHandle as Jt, AgentWidgetContextProviderContext as K, RuntypeClientResumeRequest as Ka, StreamAnimationPlugin as Ki, ClientFeedbackRequest as Kn, EventStreamConfig as Kr, AgentWidgetScrollToBottomFeature as Kt, AgentWidgetContextMentionItemRenderContext as L, ResolvedTarget as La, ResumableHandle as Li, AskUserQuestionPayload as Ln, AgentWidgetTransformSuggestionsContext as Lo, ContentPart as Lr, AgentWidgetRequestPayload as Lt, AgentWidgetContextMentionChipRenderContext as M, HistoryProvider as Ma, PersonaArtifactStatusLabelContext as Mi, AgentWidgetWelcomeIconBase as Mn, AgentWidgetRailSection as Mo, ComposerState as Mr, AgentWidgetRenderHistoryConversationContext as Mt, AgentWidgetContextMentionCommandContext as N, HistoryProviderError as Na, PreparedClientSession as Ni, AgentWidgetWelcomeIconPlacement as Nn, AgentWidgetRailSectionContext as No, ComposerStreamingSubmitBehavior as Nr, AgentWidgetRenderHistoryHeaderContext as Nt, AgentWidgetComposerConfig as O, HistoryListResult as Oa, PersonaArtifactKind as Oi, AgentWidgetWelcomeAlign as On, ToggleGroupTokens as Oo, ComposerOverflowMenuConfig as Or, AgentWidgetOpenConversationOptions as Ot, AgentWidgetContextMentionComposerCapability as P, HistoryProviderErrorCode as Pa, ReadAloudState as Pi, AgentWidgetWelcomeVariant as Pn, AgentWidgetRenderSuggestionContext as Po, ComposerSubmissionOptions as Pr, AgentWidgetRenderHistoryOpenErrorContext as Pt, AgentWidgetDockConfig as Q, RuntypeTurnCompleteEvent as Qa, VoiceClientToolsChannel as Qi, ClientToolResultFrame as Qn, HistoryConversationDetail as Qr, AgentWidgetStarterSuggestionsConfig as Qt, AgentWidgetContextMentionMenuRenderContext as R, TargetResolver as Ra, SSEEventRecord as Ri, AskUserQuestionPrompt as Rn, ariaCombo as Ro, ConversationExecutionState as Rr, AgentWidgetResolvedSuggestion as Rt, AgentWidgetAttachmentPreviewConfig as S, WidgetPreferenceSlice as Sa, PersonaArtifactCustomAction as Si, AgentWidgetTurnActivity as Sn, SemanticTypography as So, ComposerModeGroup as Sr, AgentWidgetMentionTriggerPosition as St, AgentWidgetComponentRenderContext as T, renderLucideIcon as Ta, PersonaArtifactDisplayRules as Ti, AgentWidgetVoicePrewarmTrigger as Tn, TextStyleTokens as To, ComposerModelPickerConfig as Tr, AgentWidgetMessageFeedback as Tt, AgentWidgetContextMentionSource as U, RuntypeClientFeedbackType as Ua, SpeechEngine as Ui, AttachmentUploadContext as Un, isWelcomeVisible as Uo, DictationState as Ur, AgentWidgetScrollBehaviorFeature as Ut, AgentWidgetContextMentionResolveContext as V, RuntypeClientFeedbackRequest as Va, SlotRenderer as Vi, AttachmentPreviewRenderHandle as Vn, AgentWidgetPluginStorage as Vo, DictationRenderContext as Vr, AgentWidgetSSEEventParser as Vt, AgentWidgetContextMentionTokenRenderContext as W, RuntypeClientInitRequest as Wa, SpeechRequest as Wi, BackgroundConversationAdapter as Wn, resolveWelcomeConfig as Wo, DictationStateEvent as Wr, AgentWidgetScrollMode as Wt, AgentWidgetCustomMessageActionRole as X, RuntypeStopReasonKind as Xa, VoiceClientToolStatus as Xi, ClientToolCallFrame as Xn, EventStreamViewRenderContext as Xr, AgentWidgetSessionInitHook as Xt, AgentWidgetCustomMessageAction as Y, RuntypeStepCompleteEvent as Ya, VoiceClientToolOutcome as Yi, ClientSession as Yn, EventStreamToolbarRenderContext as Yr, AgentWidgetScrollToBottomIconState as Yt, AgentWidgetDictationConfig as Z, RuntypeStreamEventOf as Za, VoiceClientTools as Zi, ClientToolDefinition as Zn, HeaderRenderContext as Zr, AgentWidgetSessionInitTrigger as Zt, AgentWidgetArtifactsFeature as _, WebMcpToolResult as _a, LoadingLabelAnimationHandle as _i, AgentWidgetSuggestionVariant as _n, RadiusScale as _o, ComposerMenuItem as _r, AgentWidgetMarkdownConfig as _t, AgentMessagePhase as a, VoiceDelegationStatus as aa, HistoryReturnSurface as ai, AgentWidgetStreamAnimationFeature as an, BrandConfig as ao, ComposerActionOverflowConfig as ar, AgentWidgetHeadersFunction as at, AgentWidgetAskUserQuestionStyles as b, WidgetLayoutSlot as ba, PcmStreamPlayer as bi, AgentWidgetToolCallLoadingAnimation as bn, SemanticSpacing as bo, ComposerMode as br, AgentWidgetMentionLlmEntry as bt, AgentWidgetActionContext as c, VoicePlaybackEngine as ca, IdleIndicatorRenderContext as ci, AgentWidgetStreamCheckpoint as cn, ComponentTokens as co, ComposerActionRenderContext as cr, AgentWidgetHistoryListAction as ct, AgentWidgetActionHandlerResult as d, VoiceResult as da, InjectComponentDirectiveOptions as di, AgentWidgetSuggestion as dn, DeepPartial as do, ComposerBeforeSendResult as dr, AgentWidgetLauncherConfig as dt, VoiceClientToolsSnapshot as ea, HistoryConversationPatch as ei, AgentWidgetStorageAdapter as en, ArtifactTabTokens as eo, ClientVisitorGrant as er, AgentWidgetEventContext as et, AgentWidgetActionParser as f, VoiceSessionBridge as fa, InjectMessageOptions as fi, AgentWidgetSuggestionBehavior as fn, IconButtonTokens as fo, ComposerButtonAction as fr, AgentWidgetLauncherTeaserConfig as ft, AgentWidgetApprovalDecisionOptions as g, WebMcpConfirmInfo as ga, LoadingLabelAnimationContext as gi, AgentWidgetSuggestionSurfaceConfig as gn, PersonaThemePlugin as go, ComposerLayout as gr, AgentWidgetLoadingLabelConfig as gt, AgentWidgetApprovalConfig as h, WebMcpConfirmHandler as ha, LoadingIndicatorRenderContext as hi, AgentWidgetSuggestionSurface as hn, PersonaTheme as ho, ComposerInputAttributes as hr, AgentWidgetLoadingIndicatorConfig as ht, AgentMessageMetadata as i, VoiceDelegationResult as ia, HistoryPendingAction as ii, AgentWidgetStreamAnimationBuiltinType as in, BorderScale as io, ComposerActionContributionContext as ir, AgentWidgetHeaderLayoutConfig as it, AgentWidgetContentSegment as j, HistoryPageResult as ja, PersonaArtifactRecord as ji, AgentWidgetWelcomeIcon as jn, AgentWidgetPlugin as jo, ComposerResubmitOptions as jr, AgentWidgetReasoning as jt, AgentWidgetConfig as k, HistoryOperationContext as ka, PersonaArtifactManualUpsert as ki, AgentWidgetWelcomeConfig as kn, TokenReference as ko, ComposerPhase as kr, AgentWidgetParsedAction as kt, AgentWidgetActionEventPayload as l, VoicePriorToolResult as la, ImageContentPart as li, AgentWidgetStreamParser as ln, ComposerOverflowMenuTokens as lo, ComposerActionVisibility as lr, AgentWidgetHistoryRenderActions as lt, AgentWidgetApproval as m, VoiceTranscriptMetadata as ma, InjectUserMessageOptions as mi, AgentWidgetSuggestionSource as mn, MessageGeometryTokens as mo, ComposerDisabledOption as mr, AgentWidgetLinkClickContext as mt, AgentExecutionState as n, VoiceDelegationFollowUp as na, HistoryDisplayProjection as ni, AgentWidgetStoredState as nn, AttachmentRemoveTokens as no, ComposerActionBase as nr, AgentWidgetFeatureFlags as nt, AgentRequestOptions as o, VoiceDirectTurn as oa, HistoryScope as oi, AgentWidgetStreamAnimationPlaceholder as on, ColorPalette as oo, ComposerActionPlacement as or, AgentWidgetHistoryCopy as ot, AgentWidgetAgentRequestPayload as p, VoiceStatus as pa, InjectSystemMessageOptions as pi, AgentWidgetSuggestionChipsConfig as pn, LabelButtonTokens as po, ComposerCustomAction as pr, AgentWidgetLayoutConfig as pt, AgentWidgetControllerEventMap as q, RuntypeClientResumeStreamEvent as qa, TextContentPart as qi, ClientFeedbackType as qn, EventStreamPayloadRenderContext as qr, AgentWidgetScrollToBottomIconContext as qt, AgentLoopConfig as r, VoiceDelegationRequest as ra, HistoryIdentityStatus as ri, AgentWidgetStreamAnimationBuffer as rn, AttachmentTokens as ro, ComposerActionContext as rr, AgentWidgetFollowUpSuggestionsConfig as rt, AgentToolsConfig as s, VoiceMetrics as sa, HistoryViewState as si, AgentWidgetStreamAnimationType as sn, ColorShade as so, ComposerActionPresentation as sr, AgentWidgetHistoryFeature as st, AgentConfig as t, VoiceConfig as ta, HistoryConversationSummary as ti, AgentWidgetStoredDraft as tn, ArtifactToolbarTokens as to, ComposerAction as tr, AgentWidgetExpansionConfig as tt, AgentWidgetActionHandler as u, VoiceProvider as ua, InjectAssistantMessageOptions as ui, AgentWidgetStreamParserResult as un, CreateThemeOptions as uo, ComposerAttachmentState as ur, AgentWidgetInitOptions as ut, AgentWidgetArtifactsLayoutConfig as v, WidgetArtifactLayoutPreference as va, MessageContent as vi, AgentWidgetSuggestionsConfig as vn, ResolvedToken as vo, ComposerMenuRenderContext as vr, AgentWidgetMarkdownOptions as vt, AgentWidgetAvatarConfig as w, registerIcons as wa, PersonaArtifactDisplayModeInput as wi, AgentWidgetVoicePrewarmHook as wn, SpacingScale as wo, ComposerModel as wr, AgentWidgetMessageActionsConfig as wt, AgentWidgetAttachmentAdapter as x, WidgetPreferenceCapabilities as xa, PersonaArtifactActionContext as xi, AgentWidgetTooltipConfig as xn, SemanticTokens as xo, ComposerModeChipVisibility as xr, AgentWidgetMentionTriggerChannel as xt, AgentWidgetAskUserQuestionFeature as y, WidgetHistoryInternals as ya, MessageRenderContext as yi, AgentWidgetTimestampConfig as yn, SemanticColors as yo, ComposerMenuRenderHandle as yr, AgentWidgetMarkdownRendererOverrides as yt, AgentWidgetContextMentionPayload as z, RuntypeClientChatRequest as za, SlotRenderContext as zi, AttachmentPreviewRemoveConfig as zn, formatCombo as zo, DictationPhase as zr, AgentWidgetRunFinishedEvent as zt };
12348
+ export { AgentWidgetEvent as $, RuntypeTurnCompleteEvent as $a, VoiceClientToolsChannel as $i, ClientToolResultFrame as $n, HistoryConversationDetail as $r, AgentWidgetStarterSuggestionsConfig as $t, AgentWidgetConfigPatch as A, HistoryOperationContext as Aa, PersonaArtifactManualUpsert as Ai, AgentWidgetWelcomeConfig as An, TokenReference as Ao, ComposerPhase as Ar, AgentWidgetReadAloudEvent as At, AgentWidgetContextMentionRef as B, RuntypeClientChatRequest as Ba, SlotRenderContext as Bi, AttachmentPreviewRemoveConfig as Bn, formatCombo as Bo, DictationPhase as Br, AgentWidgetRunFinishedEvent as Bt, AgentWidgetAttachmentsConfig as C, WidgetPreferenceSlice as Ca, PersonaArtifactCustomAction as Ci, AgentWidgetTurnActivity as Cn, SemanticTypography as Co, ComposerModeGroup as Cr, AgentWidgetMessage as Ct, AgentWidgetComponentRenderer as D, HistoryDeleteAllOptions as Da, PersonaArtifactFileMeta as Di, AgentWidgetVoiceStatusEvent as Dn, ThemeValidationError as Do, ComposerModelPickerPresentation as Dr, AgentWidgetMessageRoleLayout as Dt, AgentWidgetComponentRenderHandle as E, renderLucideIcon as Ea, PersonaArtifactDisplayRules as Ei, AgentWidgetVoicePrewarmTrigger as En, TextStyleTokens as Eo, ComposerModelPickerConfig as Er, AgentWidgetMessageLayoutConfig as Et, AgentWidgetContextMentionConfig as F, HistoryProviderErrorCode as Fa, ReadAloudState as Fi, AgentWidgetWelcomeVariant as Fn, AgentWidgetRenderSuggestionContext as Fo, ComposerSubmissionOptions as Fr, AgentWidgetRenderHistoryStateContext as Ft, AgentWidgetContextProvider as G, RuntypeClientInitRequest as Ga, SpeechRequest as Gi, BackgroundConversationAdapter as Gn, resolveWelcomeConfig as Go, DictationStateEvent as Gr, AgentWidgetScrollMode as Gt, AgentWidgetContextMentionSearchContext as H, RuntypeClientFeedbackRequest as Ha, SlotRenderer as Hi, AttachmentPreviewRenderHandle as Hn, AgentWidgetPluginStorage as Ho, DictationRenderContext as Hr, AgentWidgetSSEEventParser as Ht, AgentWidgetContextMentionItem as I, PreparedHistoryActivation as Ia, ResolvedHistoryCopy as Ii, ArtifactConfigPayload as In, AgentWidgetRenderWelcomeContext as Io, ComposerSubmissionSnapshot as Ir, AgentWidgetRenderHistoryViewContext as It, AgentWidgetCustomFetch as J, RuntypeClientResumeStreamEvent as Ja, TextContentPart as Ji, ClientFeedbackType as Jn, EventStreamPayloadRenderContext as Jr, AgentWidgetScrollToBottomIconContext as Jt, AgentWidgetContextProviderContext as K, RuntypeClientInitResponse as Ka, StreamAnimationContext as Ki, ClientChatRequest as Kn, EventStreamBadgeColor as Kr, AgentWidgetScrollRestorePosition as Kt, AgentWidgetContextMentionItemRenderContext as L, isHistoryProviderError as La, ResolvedHistoryPresentation as Li, AskUserQuestionOption as Ln, AgentWidgetSuggestionSelectContext as Lo, ComposerSubmitKey as Lr, AgentWidgetRequestPayload as Lt, AgentWidgetContextMentionChipRenderContext as M, HistoryPageResult as Ma, PersonaArtifactRecord as Mi, AgentWidgetWelcomeIcon as Mn, AgentWidgetPlugin as Mo, ComposerResubmitOptions as Mr, AgentWidgetRenderHistoryConversationContext as Mt, AgentWidgetContextMentionCommandContext as N, HistoryProvider as Na, PersonaArtifactStatusLabelContext as Ni, AgentWidgetWelcomeIconBase as Nn, AgentWidgetRailSection as No, ComposerState as Nr, AgentWidgetRenderHistoryHeaderContext as Nt, AgentWidgetComposerConfig as O, HistoryListOptions as Oa, PersonaArtifactFilesDisplayRules as Oi, AgentWidgetWebMcpConfig as On, ThemeValidationResult as Oo, ComposerOptionsPayload as Or, AgentWidgetOpenConversationOptions as Ot, AgentWidgetContextMentionComposerCapability as P, HistoryProviderError as Pa, PreparedClientSession as Pi, AgentWidgetWelcomeIconPlacement as Pn, AgentWidgetRailSectionContext as Po, ComposerStreamingSubmitBehavior as Pr, AgentWidgetRenderHistoryOpenErrorContext as Pt, AgentWidgetDockConfig as Q, RuntypeStreamEventOf as Qa, VoiceClientTools as Qi, ClientToolDefinition as Qn, HeaderRenderContext as Qr, AgentWidgetSessionInitTrigger as Qt, AgentWidgetContextMentionMenuRenderContext as R, ResolvedTarget as Ra, ResumableHandle as Ri, AskUserQuestionPayload as Rn, AgentWidgetTransformSuggestionsContext as Ro, ContentPart as Rr, AgentWidgetResolvedSuggestion as Rt, AgentWidgetAttachmentPreviewConfig as S, WidgetPreferenceCapabilities as Sa, PersonaArtifactActionContext as Si, AgentWidgetTooltipConfig as Sn, SemanticTokens as So, ComposerModeChipVisibility as Sr, AgentWidgetMentionTriggerPosition as St, AgentWidgetComponentRenderContext as T, registerIcons as Ta, PersonaArtifactDisplayModeInput as Ti, AgentWidgetVoicePrewarmHook as Tn, SpacingScale as To, ComposerModel as Tr, AgentWidgetMessageFeedback as Tt, AgentWidgetContextMentionSource as U, RuntypeClientFeedbackResponse as Ua, SpeechCallbacks as Ui, AttachmentPreviewState as Un, ResolvedWelcomeConfig as Uo, DictationRenderHandle as Ur, AgentWidgetSSEEventResult as Ut, AgentWidgetContextMentionResolveContext as V, RuntypeClientChatStreamEvent as Va, SlotRenderResult as Vi, AttachmentPreviewRenderContext as Vn, parseCombo as Vo, DictationProviderConfig as Vr, AgentWidgetRunStartedEvent as Vt, AgentWidgetContextMentionTokenRenderContext as W, RuntypeClientFeedbackType as Wa, SpeechEngine as Wi, AttachmentUploadContext as Wn, isWelcomeVisible as Wo, DictationState as Wr, AgentWidgetScrollBehaviorFeature as Wt, AgentWidgetCustomMessageActionRole as X, RuntypeStepCompleteEvent as Xa, VoiceClientToolOutcome as Xi, ClientSession as Xn, EventStreamToolbarRenderContext as Xr, AgentWidgetScrollToBottomIconState as Xt, AgentWidgetCustomMessageAction as Y, RuntypeExecutionStreamEvent as Ya, ToolAnnotations as Yi, ClientInitResponse as Yn, EventStreamRowRenderContext as Yr, AgentWidgetScrollToBottomIconHandle as Yt, AgentWidgetDictationConfig as Z, RuntypeStopReasonKind as Za, VoiceClientToolStatus as Zi, ClientToolCallFrame as Zn, EventStreamViewRenderContext as Zr, AgentWidgetSessionInitHook as Zt, AgentWidgetArtifactsFeature as _, WebMcpConfirmInfo as _a, LoadingLabelAnimationContext as _i, AgentWidgetSuggestionSurfaceConfig as _n, PersonaThemePlugin as _o, ComposerLayout as _r, AgentWidgetMarkdownConfig as _t, AgentMessagePhase as a, VoiceDelegationResult as aa, HistoryPendingAction as ai, AgentWidgetStreamAnimationBuiltinType as an, BorderScale as ao, ComposerActionContributionContext as ar, AgentWidgetHeadersFunction as at, AgentWidgetAskUserQuestionStyles as b, WidgetHistoryInternals as ba, MessageRenderContext as bi, AgentWidgetTimestampConfig as bn, SemanticColors as bo, ComposerMenuRenderHandle as br, AgentWidgetMentionLlmEntry as bt, AgentWidgetActionContext as c, VoiceMetrics as ca, HistoryViewState as ci, AgentWidgetStreamAnimationType as cn, ColorShade as co, ComposerActionPresentation as cr, AgentWidgetHistoryListAction as ct, AgentWidgetActionHandlerResult as d, VoiceProvider as da, InjectAssistantMessageOptions as di, AgentWidgetStreamParserResult as dn, CreateThemeOptions as do, ComposerAttachmentState as dr, AgentWidgetLauncherConfig as dt, VoiceClientToolsSession as ea, HistoryConversationPage as ei, AgentWidgetStateSnapshot as en, ArtifactPaneTokens as eo, ClientToolsFrame as er, AgentWidgetEventContext as et, AgentWidgetActionParser as f, VoiceResult as fa, InjectComponentDirectiveOptions as fi, AgentWidgetSuggestion as fn, DeepPartial as fo, ComposerBeforeSendResult as fr, AgentWidgetLauncherTeaserConfig as ft, AgentWidgetApprovalDecisionOptions as g, WebMcpConfirmHandler as ga, LoadingIndicatorRenderContext as gi, AgentWidgetSuggestionSurface as gn, PersonaTheme as go, ComposerInputAttributes as gr, AgentWidgetLoadingLabelConfig as gt, AgentWidgetApprovalConfig as h, VoiceTranscriptMetadata as ha, InjectUserMessageOptions as hi, AgentWidgetSuggestionSource as hn, MessageGeometryTokens as ho, ComposerDisabledOption as hr, AgentWidgetLoadingIndicatorConfig as ht, AgentMessageMetadata as i, VoiceDelegationRequest as ia, HistoryIdentityStatus as ii, AgentWidgetStreamAnimationBuffer as in, AttachmentTokens as io, ComposerActionContext as ir, AgentWidgetHeaderLayoutConfig as it, AgentWidgetContentSegment as j, HistoryPageOptions as ja, PersonaArtifactPresentation as ji, AgentWidgetWelcomeDismiss as jn, TypographyScale as jo, ComposerQuote as jr, AgentWidgetReasoning as jt, AgentWidgetConfig as k, HistoryListResult as ka, PersonaArtifactKind as ki, AgentWidgetWelcomeAlign as kn, ToggleGroupTokens as ko, ComposerOverflowMenuConfig as kr, AgentWidgetParsedAction as kt, AgentWidgetActionEventPayload as l, VoicePlaybackEngine as la, IdleIndicatorRenderContext as li, AgentWidgetStreamCheckpoint as ln, ComponentTokens as lo, ComposerActionRenderContext as lr, AgentWidgetHistoryRenderActions as lt, AgentWidgetApproval as m, VoiceStatus as ma, InjectSystemMessageOptions as mi, AgentWidgetSuggestionChipsConfig as mn, LabelButtonTokens as mo, ComposerCustomAction as mr, AgentWidgetLinkClickContext as mt, AgentExecutionState as n, VoiceConfig as na, HistoryConversationSummary as ni, AgentWidgetStoredDraft as nn, ArtifactToolbarTokens as no, ComposerAction as nr, AgentWidgetFeatureFlags as nt, AgentRequestOptions as o, VoiceDelegationStatus as oa, HistoryReturnSurface as oi, AgentWidgetStreamAnimationFeature as on, BrandConfig as oo, ComposerActionOverflowConfig as or, AgentWidgetHistoryCopy as ot, AgentWidgetAgentRequestPayload as p, VoiceSessionBridge as pa, InjectMessageOptions as pi, AgentWidgetSuggestionBehavior as pn, IconButtonTokens as po, ComposerButtonAction as pr, AgentWidgetLayoutConfig as pt, AgentWidgetControllerEventMap as q, RuntypeClientResumeRequest as qa, StreamAnimationPlugin as qi, ClientFeedbackRequest as qn, EventStreamConfig as qr, AgentWidgetScrollToBottomFeature as qt, AgentLoopConfig as r, VoiceDelegationFollowUp as ra, HistoryDisplayProjection as ri, AgentWidgetStoredState as rn, AttachmentRemoveTokens as ro, ComposerActionBase as rr, AgentWidgetFollowUpSuggestionsConfig as rt, AgentToolsConfig as s, VoiceDirectTurn as sa, HistoryScope as si, AgentWidgetStreamAnimationPlaceholder as sn, ColorPalette as so, ComposerActionPlacement as sr, AgentWidgetHistoryFeature as st, AgentConfig as t, VoiceClientToolsSnapshot as ta, HistoryConversationPatch as ti, AgentWidgetStorageAdapter as tn, ArtifactTabTokens as to, ClientVisitorGrant as tr, AgentWidgetExpansionConfig as tt, AgentWidgetActionHandler as u, VoicePriorToolResult as ua, ImageContentPart as ui, AgentWidgetStreamParser as un, ComposerOverflowMenuTokens as uo, ComposerActionVisibility as ur, AgentWidgetInitOptions as ut, AgentWidgetArtifactsLayoutConfig as v, WebMcpToolResult as va, LoadingLabelAnimationHandle as vi, AgentWidgetSuggestionVariant as vn, RadiusScale as vo, ComposerMenuItem as vr, AgentWidgetMarkdownOptions as vt, AgentWidgetAvatarConfig as w, IconName as wa, PersonaArtifactDisplayMode as wi, AgentWidgetTurnActivityConfig as wn, ShadowScale as wo, ComposerModeGroupPresentation as wr, AgentWidgetMessageActionsConfig as wt, AgentWidgetAttachmentAdapter as x, WidgetLayoutSlot as xa, PcmStreamPlayer as xi, AgentWidgetToolCallLoadingAnimation as xn, SemanticSpacing as xo, ComposerMode as xr, AgentWidgetMentionTriggerChannel as xt, AgentWidgetAskUserQuestionFeature as y, WidgetArtifactLayoutPreference as ya, MessageContent as yi, AgentWidgetSuggestionsConfig as yn, ResolvedToken as yo, ComposerMenuRenderContext as yr, AgentWidgetMarkdownRendererOverrides as yt, AgentWidgetContextMentionPayload as z, TargetResolver as za, SSEEventRecord as zi, AskUserQuestionPrompt as zn, ariaCombo as zo, ConversationExecutionState as zr, AgentWidgetRevealToolCallOptions as zt };
12342
12349
  export {}
@@ -6511,6 +6511,13 @@ type AgentWidgetOpenConversationOptions = {
6511
6511
  /** Default "reject"; "stop" stops locally; "background" requires backgroundConversations. */
6512
6512
  busy?: "reject" | "stop" | "background";
6513
6513
  };
6514
+ /** Options for `controller.revealToolCall()`. */
6515
+ type AgentWidgetRevealToolCallOptions = {
6516
+ /** Expand the tool's details. Default true. */
6517
+ expand?: boolean;
6518
+ /** How long the bubble keeps `data-persona-revealed`, in ms; 0 skips the mark. Default 2000. */
6519
+ highlightMs?: number;
6520
+ };
6514
6521
  /** The single in-flight history operation, or `null` when idle. */
6515
6522
  type HistoryPendingAction = {
6516
6523
  kind: "refresh" | "load-more" | "start-new" | "clear" | "reset";
@@ -12338,5 +12345,5 @@ type AgentWidgetInitOptions = {
12338
12345
  debugTools?: boolean;
12339
12346
  };
12340
12347
  //#endregion
12341
- export { AgentWidgetEvent as $, ArtifactPaneTokens as $a, VoiceClientToolsSession as $i, ClientToolsFrame as $n, HistoryConversationPage as $r, AgentWidgetStateSnapshot as $t, AgentWidgetConfigPatch as A, HistoryPageOptions as Aa, PersonaArtifactPresentation as Ai, AgentWidgetWelcomeDismiss as An, TypographyScale as Ao, ComposerQuote as Ar, AgentWidgetReadAloudEvent as At, AgentWidgetContextMentionRef as B, RuntypeClientChatStreamEvent as Ba, SlotRenderResult as Bi, AttachmentPreviewRenderContext as Bn, parseCombo as Bo, DictationProviderConfig as Br, AgentWidgetRunStartedEvent as Bt, AgentWidgetAttachmentsConfig as C, IconName as Ca, PersonaArtifactDisplayMode as Ci, AgentWidgetTurnActivityConfig as Cn, ShadowScale as Co, ComposerModeGroupPresentation as Cr, AgentWidgetMessage as Ct, AgentWidgetComponentRenderer as D, HistoryListOptions as Da, PersonaArtifactFilesDisplayRules as Di, AgentWidgetWebMcpConfig as Dn, ThemeValidationResult as Do, ComposerOptionsPayload as Dr, AgentWidgetMessageRoleLayout as Dt, AgentWidgetComponentRenderHandle as E, HistoryDeleteAllOptions as Ea, PersonaArtifactFileMeta as Ei, AgentWidgetVoiceStatusEvent as En, ThemeValidationError as Eo, ComposerModelPickerPresentation as Er, AgentWidgetMessageLayoutConfig as Et, AgentWidgetContextMentionConfig as F, PreparedHistoryActivation as Fa, ResolvedHistoryCopy as Fi, ArtifactConfigPayload as Fn, AgentWidgetRenderWelcomeContext as Fo, ComposerSubmissionSnapshot as Fr, AgentWidgetRenderHistoryStateContext as Ft, AgentWidgetContextProvider as G, RuntypeClientInitResponse as Ga, StreamAnimationContext as Gi, ClientChatRequest as Gn, EventStreamBadgeColor as Gr, AgentWidgetScrollRestorePosition as Gt, AgentWidgetContextMentionSearchContext as H, RuntypeClientFeedbackResponse as Ha, SpeechCallbacks as Hi, AttachmentPreviewState as Hn, ResolvedWelcomeConfig as Ho, DictationRenderHandle as Hr, AgentWidgetSSEEventResult as Ht, AgentWidgetContextMentionItem as I, isHistoryProviderError as Ia, ResolvedHistoryPresentation as Ii, AskUserQuestionOption as In, AgentWidgetSuggestionSelectContext as Io, ComposerSubmitKey as Ir, AgentWidgetRenderHistoryViewContext as It, AgentWidgetCustomFetch as J, RuntypeExecutionStreamEvent as Ja, ToolAnnotations as Ji, ClientInitResponse as Jn, EventStreamRowRenderContext as Jr, AgentWidgetScrollToBottomIconHandle as Jt, AgentWidgetContextProviderContext as K, RuntypeClientResumeRequest as Ka, StreamAnimationPlugin as Ki, ClientFeedbackRequest as Kn, EventStreamConfig as Kr, AgentWidgetScrollToBottomFeature as Kt, AgentWidgetContextMentionItemRenderContext as L, ResolvedTarget as La, ResumableHandle as Li, AskUserQuestionPayload as Ln, AgentWidgetTransformSuggestionsContext as Lo, ContentPart as Lr, AgentWidgetRequestPayload as Lt, AgentWidgetContextMentionChipRenderContext as M, HistoryProvider as Ma, PersonaArtifactStatusLabelContext as Mi, AgentWidgetWelcomeIconBase as Mn, AgentWidgetRailSection as Mo, ComposerState as Mr, AgentWidgetRenderHistoryConversationContext as Mt, AgentWidgetContextMentionCommandContext as N, HistoryProviderError as Na, PreparedClientSession as Ni, AgentWidgetWelcomeIconPlacement as Nn, AgentWidgetRailSectionContext as No, ComposerStreamingSubmitBehavior as Nr, AgentWidgetRenderHistoryHeaderContext as Nt, AgentWidgetComposerConfig as O, HistoryListResult as Oa, PersonaArtifactKind as Oi, AgentWidgetWelcomeAlign as On, ToggleGroupTokens as Oo, ComposerOverflowMenuConfig as Or, AgentWidgetOpenConversationOptions as Ot, AgentWidgetContextMentionComposerCapability as P, HistoryProviderErrorCode as Pa, ReadAloudState as Pi, AgentWidgetWelcomeVariant as Pn, AgentWidgetRenderSuggestionContext as Po, ComposerSubmissionOptions as Pr, AgentWidgetRenderHistoryOpenErrorContext as Pt, AgentWidgetDockConfig as Q, RuntypeTurnCompleteEvent as Qa, VoiceClientToolsChannel as Qi, ClientToolResultFrame as Qn, HistoryConversationDetail as Qr, AgentWidgetStarterSuggestionsConfig as Qt, AgentWidgetContextMentionMenuRenderContext as R, TargetResolver as Ra, SSEEventRecord as Ri, AskUserQuestionPrompt as Rn, ariaCombo as Ro, ConversationExecutionState as Rr, AgentWidgetResolvedSuggestion as Rt, AgentWidgetAttachmentPreviewConfig as S, WidgetPreferenceSlice as Sa, PersonaArtifactCustomAction as Si, AgentWidgetTurnActivity as Sn, SemanticTypography as So, ComposerModeGroup as Sr, AgentWidgetMentionTriggerPosition as St, AgentWidgetComponentRenderContext as T, renderLucideIcon as Ta, PersonaArtifactDisplayRules as Ti, AgentWidgetVoicePrewarmTrigger as Tn, TextStyleTokens as To, ComposerModelPickerConfig as Tr, AgentWidgetMessageFeedback as Tt, AgentWidgetContextMentionSource as U, RuntypeClientFeedbackType as Ua, SpeechEngine as Ui, AttachmentUploadContext as Un, isWelcomeVisible as Uo, DictationState as Ur, AgentWidgetScrollBehaviorFeature as Ut, AgentWidgetContextMentionResolveContext as V, RuntypeClientFeedbackRequest as Va, SlotRenderer as Vi, AttachmentPreviewRenderHandle as Vn, AgentWidgetPluginStorage as Vo, DictationRenderContext as Vr, AgentWidgetSSEEventParser as Vt, AgentWidgetContextMentionTokenRenderContext as W, RuntypeClientInitRequest as Wa, SpeechRequest as Wi, BackgroundConversationAdapter as Wn, resolveWelcomeConfig as Wo, DictationStateEvent as Wr, AgentWidgetScrollMode as Wt, AgentWidgetCustomMessageActionRole as X, RuntypeStopReasonKind as Xa, VoiceClientToolStatus as Xi, ClientToolCallFrame as Xn, EventStreamViewRenderContext as Xr, AgentWidgetSessionInitHook as Xt, AgentWidgetCustomMessageAction as Y, RuntypeStepCompleteEvent as Ya, VoiceClientToolOutcome as Yi, ClientSession as Yn, EventStreamToolbarRenderContext as Yr, AgentWidgetScrollToBottomIconState as Yt, AgentWidgetDictationConfig as Z, RuntypeStreamEventOf as Za, VoiceClientTools as Zi, ClientToolDefinition as Zn, HeaderRenderContext as Zr, AgentWidgetSessionInitTrigger as Zt, AgentWidgetArtifactsFeature as _, WebMcpToolResult as _a, LoadingLabelAnimationHandle as _i, AgentWidgetSuggestionVariant as _n, RadiusScale as _o, ComposerMenuItem as _r, AgentWidgetMarkdownConfig as _t, AgentMessagePhase as a, VoiceDelegationStatus as aa, HistoryReturnSurface as ai, AgentWidgetStreamAnimationFeature as an, BrandConfig as ao, ComposerActionOverflowConfig as ar, AgentWidgetHeadersFunction as at, AgentWidgetAskUserQuestionStyles as b, WidgetLayoutSlot as ba, PcmStreamPlayer as bi, AgentWidgetToolCallLoadingAnimation as bn, SemanticSpacing as bo, ComposerMode as br, AgentWidgetMentionLlmEntry as bt, AgentWidgetActionContext as c, VoicePlaybackEngine as ca, IdleIndicatorRenderContext as ci, AgentWidgetStreamCheckpoint as cn, ComponentTokens as co, ComposerActionRenderContext as cr, AgentWidgetHistoryListAction as ct, AgentWidgetActionHandlerResult as d, VoiceResult as da, InjectComponentDirectiveOptions as di, AgentWidgetSuggestion as dn, DeepPartial as do, ComposerBeforeSendResult as dr, AgentWidgetLauncherConfig as dt, VoiceClientToolsSnapshot as ea, HistoryConversationPatch as ei, AgentWidgetStorageAdapter as en, ArtifactTabTokens as eo, ClientVisitorGrant as er, AgentWidgetEventContext as et, AgentWidgetActionParser as f, VoiceSessionBridge as fa, InjectMessageOptions as fi, AgentWidgetSuggestionBehavior as fn, IconButtonTokens as fo, ComposerButtonAction as fr, AgentWidgetLauncherTeaserConfig as ft, AgentWidgetApprovalDecisionOptions as g, WebMcpConfirmInfo as ga, LoadingLabelAnimationContext as gi, AgentWidgetSuggestionSurfaceConfig as gn, PersonaThemePlugin as go, ComposerLayout as gr, AgentWidgetLoadingLabelConfig as gt, AgentWidgetApprovalConfig as h, WebMcpConfirmHandler as ha, LoadingIndicatorRenderContext as hi, AgentWidgetSuggestionSurface as hn, PersonaTheme as ho, ComposerInputAttributes as hr, AgentWidgetLoadingIndicatorConfig as ht, AgentMessageMetadata as i, VoiceDelegationResult as ia, HistoryPendingAction as ii, AgentWidgetStreamAnimationBuiltinType as in, BorderScale as io, ComposerActionContributionContext as ir, AgentWidgetHeaderLayoutConfig as it, AgentWidgetContentSegment as j, HistoryPageResult as ja, PersonaArtifactRecord as ji, AgentWidgetWelcomeIcon as jn, AgentWidgetPlugin as jo, ComposerResubmitOptions as jr, AgentWidgetReasoning as jt, AgentWidgetConfig as k, HistoryOperationContext as ka, PersonaArtifactManualUpsert as ki, AgentWidgetWelcomeConfig as kn, TokenReference as ko, ComposerPhase as kr, AgentWidgetParsedAction as kt, AgentWidgetActionEventPayload as l, VoicePriorToolResult as la, ImageContentPart as li, AgentWidgetStreamParser as ln, ComposerOverflowMenuTokens as lo, ComposerActionVisibility as lr, AgentWidgetHistoryRenderActions as lt, AgentWidgetApproval as m, VoiceTranscriptMetadata as ma, InjectUserMessageOptions as mi, AgentWidgetSuggestionSource as mn, MessageGeometryTokens as mo, ComposerDisabledOption as mr, AgentWidgetLinkClickContext as mt, AgentExecutionState as n, VoiceDelegationFollowUp as na, HistoryDisplayProjection as ni, AgentWidgetStoredState as nn, AttachmentRemoveTokens as no, ComposerActionBase as nr, AgentWidgetFeatureFlags as nt, AgentRequestOptions as o, VoiceDirectTurn as oa, HistoryScope as oi, AgentWidgetStreamAnimationPlaceholder as on, ColorPalette as oo, ComposerActionPlacement as or, AgentWidgetHistoryCopy as ot, AgentWidgetAgentRequestPayload as p, VoiceStatus as pa, InjectSystemMessageOptions as pi, AgentWidgetSuggestionChipsConfig as pn, LabelButtonTokens as po, ComposerCustomAction as pr, AgentWidgetLayoutConfig as pt, AgentWidgetControllerEventMap as q, RuntypeClientResumeStreamEvent as qa, TextContentPart as qi, ClientFeedbackType as qn, EventStreamPayloadRenderContext as qr, AgentWidgetScrollToBottomIconContext as qt, AgentLoopConfig as r, VoiceDelegationRequest as ra, HistoryIdentityStatus as ri, AgentWidgetStreamAnimationBuffer as rn, AttachmentTokens as ro, ComposerActionContext as rr, AgentWidgetFollowUpSuggestionsConfig as rt, AgentToolsConfig as s, VoiceMetrics as sa, HistoryViewState as si, AgentWidgetStreamAnimationType as sn, ColorShade as so, ComposerActionPresentation as sr, AgentWidgetHistoryFeature as st, AgentConfig as t, VoiceConfig as ta, HistoryConversationSummary as ti, AgentWidgetStoredDraft as tn, ArtifactToolbarTokens as to, ComposerAction as tr, AgentWidgetExpansionConfig as tt, AgentWidgetActionHandler as u, VoiceProvider as ua, InjectAssistantMessageOptions as ui, AgentWidgetStreamParserResult as un, CreateThemeOptions as uo, ComposerAttachmentState as ur, AgentWidgetInitOptions as ut, AgentWidgetArtifactsLayoutConfig as v, WidgetArtifactLayoutPreference as va, MessageContent as vi, AgentWidgetSuggestionsConfig as vn, ResolvedToken as vo, ComposerMenuRenderContext as vr, AgentWidgetMarkdownOptions as vt, AgentWidgetAvatarConfig as w, registerIcons as wa, PersonaArtifactDisplayModeInput as wi, AgentWidgetVoicePrewarmHook as wn, SpacingScale as wo, ComposerModel as wr, AgentWidgetMessageActionsConfig as wt, AgentWidgetAttachmentAdapter as x, WidgetPreferenceCapabilities as xa, PersonaArtifactActionContext as xi, AgentWidgetTooltipConfig as xn, SemanticTokens as xo, ComposerModeChipVisibility as xr, AgentWidgetMentionTriggerChannel as xt, AgentWidgetAskUserQuestionFeature as y, WidgetHistoryInternals as ya, MessageRenderContext as yi, AgentWidgetTimestampConfig as yn, SemanticColors as yo, ComposerMenuRenderHandle as yr, AgentWidgetMarkdownRendererOverrides as yt, AgentWidgetContextMentionPayload as z, RuntypeClientChatRequest as za, SlotRenderContext as zi, AttachmentPreviewRemoveConfig as zn, formatCombo as zo, DictationPhase as zr, AgentWidgetRunFinishedEvent as zt };
12348
+ export { AgentWidgetEvent as $, RuntypeTurnCompleteEvent as $a, VoiceClientToolsChannel as $i, ClientToolResultFrame as $n, HistoryConversationDetail as $r, AgentWidgetStarterSuggestionsConfig as $t, AgentWidgetConfigPatch as A, HistoryOperationContext as Aa, PersonaArtifactManualUpsert as Ai, AgentWidgetWelcomeConfig as An, TokenReference as Ao, ComposerPhase as Ar, AgentWidgetReadAloudEvent as At, AgentWidgetContextMentionRef as B, RuntypeClientChatRequest as Ba, SlotRenderContext as Bi, AttachmentPreviewRemoveConfig as Bn, formatCombo as Bo, DictationPhase as Br, AgentWidgetRunFinishedEvent as Bt, AgentWidgetAttachmentsConfig as C, WidgetPreferenceSlice as Ca, PersonaArtifactCustomAction as Ci, AgentWidgetTurnActivity as Cn, SemanticTypography as Co, ComposerModeGroup as Cr, AgentWidgetMessage as Ct, AgentWidgetComponentRenderer as D, HistoryDeleteAllOptions as Da, PersonaArtifactFileMeta as Di, AgentWidgetVoiceStatusEvent as Dn, ThemeValidationError as Do, ComposerModelPickerPresentation as Dr, AgentWidgetMessageRoleLayout as Dt, AgentWidgetComponentRenderHandle as E, renderLucideIcon as Ea, PersonaArtifactDisplayRules as Ei, AgentWidgetVoicePrewarmTrigger as En, TextStyleTokens as Eo, ComposerModelPickerConfig as Er, AgentWidgetMessageLayoutConfig as Et, AgentWidgetContextMentionConfig as F, HistoryProviderErrorCode as Fa, ReadAloudState as Fi, AgentWidgetWelcomeVariant as Fn, AgentWidgetRenderSuggestionContext as Fo, ComposerSubmissionOptions as Fr, AgentWidgetRenderHistoryStateContext as Ft, AgentWidgetContextProvider as G, RuntypeClientInitRequest as Ga, SpeechRequest as Gi, BackgroundConversationAdapter as Gn, resolveWelcomeConfig as Go, DictationStateEvent as Gr, AgentWidgetScrollMode as Gt, AgentWidgetContextMentionSearchContext as H, RuntypeClientFeedbackRequest as Ha, SlotRenderer as Hi, AttachmentPreviewRenderHandle as Hn, AgentWidgetPluginStorage as Ho, DictationRenderContext as Hr, AgentWidgetSSEEventParser as Ht, AgentWidgetContextMentionItem as I, PreparedHistoryActivation as Ia, ResolvedHistoryCopy as Ii, ArtifactConfigPayload as In, AgentWidgetRenderWelcomeContext as Io, ComposerSubmissionSnapshot as Ir, AgentWidgetRenderHistoryViewContext as It, AgentWidgetCustomFetch as J, RuntypeClientResumeStreamEvent as Ja, TextContentPart as Ji, ClientFeedbackType as Jn, EventStreamPayloadRenderContext as Jr, AgentWidgetScrollToBottomIconContext as Jt, AgentWidgetContextProviderContext as K, RuntypeClientInitResponse as Ka, StreamAnimationContext as Ki, ClientChatRequest as Kn, EventStreamBadgeColor as Kr, AgentWidgetScrollRestorePosition as Kt, AgentWidgetContextMentionItemRenderContext as L, isHistoryProviderError as La, ResolvedHistoryPresentation as Li, AskUserQuestionOption as Ln, AgentWidgetSuggestionSelectContext as Lo, ComposerSubmitKey as Lr, AgentWidgetRequestPayload as Lt, AgentWidgetContextMentionChipRenderContext as M, HistoryPageResult as Ma, PersonaArtifactRecord as Mi, AgentWidgetWelcomeIcon as Mn, AgentWidgetPlugin as Mo, ComposerResubmitOptions as Mr, AgentWidgetRenderHistoryConversationContext as Mt, AgentWidgetContextMentionCommandContext as N, HistoryProvider as Na, PersonaArtifactStatusLabelContext as Ni, AgentWidgetWelcomeIconBase as Nn, AgentWidgetRailSection as No, ComposerState as Nr, AgentWidgetRenderHistoryHeaderContext as Nt, AgentWidgetComposerConfig as O, HistoryListOptions as Oa, PersonaArtifactFilesDisplayRules as Oi, AgentWidgetWebMcpConfig as On, ThemeValidationResult as Oo, ComposerOptionsPayload as Or, AgentWidgetOpenConversationOptions as Ot, AgentWidgetContextMentionComposerCapability as P, HistoryProviderError as Pa, PreparedClientSession as Pi, AgentWidgetWelcomeIconPlacement as Pn, AgentWidgetRailSectionContext as Po, ComposerStreamingSubmitBehavior as Pr, AgentWidgetRenderHistoryOpenErrorContext as Pt, AgentWidgetDockConfig as Q, RuntypeStreamEventOf as Qa, VoiceClientTools as Qi, ClientToolDefinition as Qn, HeaderRenderContext as Qr, AgentWidgetSessionInitTrigger as Qt, AgentWidgetContextMentionMenuRenderContext as R, ResolvedTarget as Ra, ResumableHandle as Ri, AskUserQuestionPayload as Rn, AgentWidgetTransformSuggestionsContext as Ro, ContentPart as Rr, AgentWidgetResolvedSuggestion as Rt, AgentWidgetAttachmentPreviewConfig as S, WidgetPreferenceCapabilities as Sa, PersonaArtifactActionContext as Si, AgentWidgetTooltipConfig as Sn, SemanticTokens as So, ComposerModeChipVisibility as Sr, AgentWidgetMentionTriggerPosition as St, AgentWidgetComponentRenderContext as T, registerIcons as Ta, PersonaArtifactDisplayModeInput as Ti, AgentWidgetVoicePrewarmHook as Tn, SpacingScale as To, ComposerModel as Tr, AgentWidgetMessageFeedback as Tt, AgentWidgetContextMentionSource as U, RuntypeClientFeedbackResponse as Ua, SpeechCallbacks as Ui, AttachmentPreviewState as Un, ResolvedWelcomeConfig as Uo, DictationRenderHandle as Ur, AgentWidgetSSEEventResult as Ut, AgentWidgetContextMentionResolveContext as V, RuntypeClientChatStreamEvent as Va, SlotRenderResult as Vi, AttachmentPreviewRenderContext as Vn, parseCombo as Vo, DictationProviderConfig as Vr, AgentWidgetRunStartedEvent as Vt, AgentWidgetContextMentionTokenRenderContext as W, RuntypeClientFeedbackType as Wa, SpeechEngine as Wi, AttachmentUploadContext as Wn, isWelcomeVisible as Wo, DictationState as Wr, AgentWidgetScrollBehaviorFeature as Wt, AgentWidgetCustomMessageActionRole as X, RuntypeStepCompleteEvent as Xa, VoiceClientToolOutcome as Xi, ClientSession as Xn, EventStreamToolbarRenderContext as Xr, AgentWidgetScrollToBottomIconState as Xt, AgentWidgetCustomMessageAction as Y, RuntypeExecutionStreamEvent as Ya, ToolAnnotations as Yi, ClientInitResponse as Yn, EventStreamRowRenderContext as Yr, AgentWidgetScrollToBottomIconHandle as Yt, AgentWidgetDictationConfig as Z, RuntypeStopReasonKind as Za, VoiceClientToolStatus as Zi, ClientToolCallFrame as Zn, EventStreamViewRenderContext as Zr, AgentWidgetSessionInitHook as Zt, AgentWidgetArtifactsFeature as _, WebMcpConfirmInfo as _a, LoadingLabelAnimationContext as _i, AgentWidgetSuggestionSurfaceConfig as _n, PersonaThemePlugin as _o, ComposerLayout as _r, AgentWidgetMarkdownConfig as _t, AgentMessagePhase as a, VoiceDelegationResult as aa, HistoryPendingAction as ai, AgentWidgetStreamAnimationBuiltinType as an, BorderScale as ao, ComposerActionContributionContext as ar, AgentWidgetHeadersFunction as at, AgentWidgetAskUserQuestionStyles as b, WidgetHistoryInternals as ba, MessageRenderContext as bi, AgentWidgetTimestampConfig as bn, SemanticColors as bo, ComposerMenuRenderHandle as br, AgentWidgetMentionLlmEntry as bt, AgentWidgetActionContext as c, VoiceMetrics as ca, HistoryViewState as ci, AgentWidgetStreamAnimationType as cn, ColorShade as co, ComposerActionPresentation as cr, AgentWidgetHistoryListAction as ct, AgentWidgetActionHandlerResult as d, VoiceProvider as da, InjectAssistantMessageOptions as di, AgentWidgetStreamParserResult as dn, CreateThemeOptions as do, ComposerAttachmentState as dr, AgentWidgetLauncherConfig as dt, VoiceClientToolsSession as ea, HistoryConversationPage as ei, AgentWidgetStateSnapshot as en, ArtifactPaneTokens as eo, ClientToolsFrame as er, AgentWidgetEventContext as et, AgentWidgetActionParser as f, VoiceResult as fa, InjectComponentDirectiveOptions as fi, AgentWidgetSuggestion as fn, DeepPartial as fo, ComposerBeforeSendResult as fr, AgentWidgetLauncherTeaserConfig as ft, AgentWidgetApprovalDecisionOptions as g, WebMcpConfirmHandler as ga, LoadingIndicatorRenderContext as gi, AgentWidgetSuggestionSurface as gn, PersonaTheme as go, ComposerInputAttributes as gr, AgentWidgetLoadingLabelConfig as gt, AgentWidgetApprovalConfig as h, VoiceTranscriptMetadata as ha, InjectUserMessageOptions as hi, AgentWidgetSuggestionSource as hn, MessageGeometryTokens as ho, ComposerDisabledOption as hr, AgentWidgetLoadingIndicatorConfig as ht, AgentMessageMetadata as i, VoiceDelegationRequest as ia, HistoryIdentityStatus as ii, AgentWidgetStreamAnimationBuffer as in, AttachmentTokens as io, ComposerActionContext as ir, AgentWidgetHeaderLayoutConfig as it, AgentWidgetContentSegment as j, HistoryPageOptions as ja, PersonaArtifactPresentation as ji, AgentWidgetWelcomeDismiss as jn, TypographyScale as jo, ComposerQuote as jr, AgentWidgetReasoning as jt, AgentWidgetConfig as k, HistoryListResult as ka, PersonaArtifactKind as ki, AgentWidgetWelcomeAlign as kn, ToggleGroupTokens as ko, ComposerOverflowMenuConfig as kr, AgentWidgetParsedAction as kt, AgentWidgetActionEventPayload as l, VoicePlaybackEngine as la, IdleIndicatorRenderContext as li, AgentWidgetStreamCheckpoint as ln, ComponentTokens as lo, ComposerActionRenderContext as lr, AgentWidgetHistoryRenderActions as lt, AgentWidgetApproval as m, VoiceStatus as ma, InjectSystemMessageOptions as mi, AgentWidgetSuggestionChipsConfig as mn, LabelButtonTokens as mo, ComposerCustomAction as mr, AgentWidgetLinkClickContext as mt, AgentExecutionState as n, VoiceConfig as na, HistoryConversationSummary as ni, AgentWidgetStoredDraft as nn, ArtifactToolbarTokens as no, ComposerAction as nr, AgentWidgetFeatureFlags as nt, AgentRequestOptions as o, VoiceDelegationStatus as oa, HistoryReturnSurface as oi, AgentWidgetStreamAnimationFeature as on, BrandConfig as oo, ComposerActionOverflowConfig as or, AgentWidgetHistoryCopy as ot, AgentWidgetAgentRequestPayload as p, VoiceSessionBridge as pa, InjectMessageOptions as pi, AgentWidgetSuggestionBehavior as pn, IconButtonTokens as po, ComposerButtonAction as pr, AgentWidgetLayoutConfig as pt, AgentWidgetControllerEventMap as q, RuntypeClientResumeRequest as qa, StreamAnimationPlugin as qi, ClientFeedbackRequest as qn, EventStreamConfig as qr, AgentWidgetScrollToBottomFeature as qt, AgentLoopConfig as r, VoiceDelegationFollowUp as ra, HistoryDisplayProjection as ri, AgentWidgetStoredState as rn, AttachmentRemoveTokens as ro, ComposerActionBase as rr, AgentWidgetFollowUpSuggestionsConfig as rt, AgentToolsConfig as s, VoiceDirectTurn as sa, HistoryScope as si, AgentWidgetStreamAnimationPlaceholder as sn, ColorPalette as so, ComposerActionPlacement as sr, AgentWidgetHistoryFeature as st, AgentConfig as t, VoiceClientToolsSnapshot as ta, HistoryConversationPatch as ti, AgentWidgetStorageAdapter as tn, ArtifactTabTokens as to, ClientVisitorGrant as tr, AgentWidgetExpansionConfig as tt, AgentWidgetActionHandler as u, VoicePriorToolResult as ua, ImageContentPart as ui, AgentWidgetStreamParser as un, ComposerOverflowMenuTokens as uo, ComposerActionVisibility as ur, AgentWidgetInitOptions as ut, AgentWidgetArtifactsLayoutConfig as v, WebMcpToolResult as va, LoadingLabelAnimationHandle as vi, AgentWidgetSuggestionVariant as vn, RadiusScale as vo, ComposerMenuItem as vr, AgentWidgetMarkdownOptions as vt, AgentWidgetAvatarConfig as w, IconName as wa, PersonaArtifactDisplayMode as wi, AgentWidgetTurnActivityConfig as wn, ShadowScale as wo, ComposerModeGroupPresentation as wr, AgentWidgetMessageActionsConfig as wt, AgentWidgetAttachmentAdapter as x, WidgetLayoutSlot as xa, PcmStreamPlayer as xi, AgentWidgetToolCallLoadingAnimation as xn, SemanticSpacing as xo, ComposerMode as xr, AgentWidgetMentionTriggerChannel as xt, AgentWidgetAskUserQuestionFeature as y, WidgetArtifactLayoutPreference as ya, MessageContent as yi, AgentWidgetSuggestionsConfig as yn, ResolvedToken as yo, ComposerMenuRenderContext as yr, AgentWidgetMarkdownRendererOverrides as yt, AgentWidgetContextMentionPayload as z, TargetResolver as za, SSEEventRecord as zi, AskUserQuestionPrompt as zn, ariaCombo as zo, ConversationExecutionState as zr, AgentWidgetRevealToolCallOptions as zt };
12342
12349
  export {}
@@ -1,4 +1,4 @@
1
- import { $i as VoiceClientToolsSession, Qi as VoiceClientToolsChannel, Zi as VoiceClientTools, Zn as ClientToolDefinition } from "./types-CSXHl5cN.cjs";
1
+ import { $i as VoiceClientToolsChannel, Qi as VoiceClientTools, Qn as ClientToolDefinition, ea as VoiceClientToolsSession } from "./types-BOZHQIk0.cjs";
2
2
  //#region src/voice/voice-client-tools-session.d.ts
3
3
  /** The name the server calls a client tool back with: `webmcp:` prefixed for page tools. */
4
4
  export declare function voiceClientToolName(tool: ClientToolDefinition): string;
@@ -1,4 +1,4 @@
1
- import { $i as VoiceClientToolsSession, Qi as VoiceClientToolsChannel, Zi as VoiceClientTools, Zn as ClientToolDefinition } from "./types-CSXHl5cN.js";
1
+ import { $i as VoiceClientToolsChannel, Qi as VoiceClientTools, Qn as ClientToolDefinition, ea as VoiceClientToolsSession } from "./types-BOZHQIk0.js";
2
2
  //#region src/voice/voice-client-tools-session.d.ts
3
3
  /** The name the server calls a client tool back with: `webmcp:` prefixed for page tools. */
4
4
  export declare function voiceClientToolName(tool: ClientToolDefinition): string;
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=class{#e=null;#t=0;#n=[];#r=[];#i=[];#a=!1;#o=!1;#s=0;#c=!1;#l=!1;#u;#d=[];#f=0;#p=!1;#m;#h;#g;#_=null;constructor(e=24e3,t={}){this.#h=e;let n=Math.max(0,t.prebufferMs??0);this.#g=Math.round(e*n/1e3),this.#u=this.#g>0}#v(){if(!this.#e){let e=typeof window<`u`?window:void 0;if(!e)throw Error(`AudioPlaybackManager requires a browser environment`);let t=e.AudioContext||e.webkitAudioContext;this.#e=new t({sampleRate:this.#h})}let e=this.#e;return e.state===`suspended`&&!this.#l&&e.resume(),e}enqueue(e){if(e.length===0)return;let t=e;if(this.#_){let n=new Uint8Array(this.#_.length+e.length);n.set(this.#_),n.set(e,this.#_.length),t=n,this.#_=null}if(t.length%2!=0&&(this.#_=new Uint8Array([t[t.length-1]]),t=t.subarray(0,t.length-1)),t.length===0)return;let n=this.#S(t);n.length!==0&&(this.#u?(this.#d.push(n),this.#f+=n.length,clearTimeout(this.#m),this.#f>=this.#g?this.#y():this.#p&&(this.#m=setTimeout(()=>this.#y(),this.#g/this.#h*1e3))):this.#b(n))}markStreamEnd(){this.#d.length>0&&this.#y(),this.#o=!0,this.#x()}flush(){for(let e of this.#n){e.onended=null;try{e.stop(),e.disconnect()}catch{}}this.#n=[],this.#s=0,this.#t=0,this.#a=!1,this.#o=!1,this.#r=[],this.#i=[],this.#_=null,this.#d=[],this.#f=0,this.#u=this.#g>0,this.#c=!1,clearTimeout(this.#m)}setContinuousMode(e){this.#p=e}isPlaying(){return this.#a}onFinished(e){this.#r.push(e)}onStarted(e){this.#i.push(e)}pause(){this.#l=!0,this.#e&&this.#e.state===`running`&&this.#e.suspend()}resume(){this.#l=!1,this.#e&&this.#e.state===`suspended`&&this.#e.resume()}async destroy(){this.flush(),this.#e&&=(await this.#e.close(),null)}#y(){this.#u=!1;let e=this.#d;this.#d=[],this.#f=0;for(let t of e)this.#b(t)}#b(e){if(e.length===0)return;let t=this.#v(),n=t.createBuffer(1,e.length,this.#h);n.getChannelData(0).set(e);let r=t.createBufferSource();r.buffer=n,r.connect(t.destination);let i=t.currentTime;if(this.#t===0?this.#t=i:this.#t<i&&(this.#t=i,this.#g>0&&(this.#u=!0)),r.start(this.#t),this.#t+=n.duration,this.#n.push(r),this.#s++,this.#a=!0,!this.#c){this.#c=!0;let e=this.#i.slice();this.#i=[];for(let t of e)t()}r.onended=()=>{let e=this.#n.indexOf(r);e!==-1&&(this.#n.splice(e,1),this.#s--,this.#x())}}#x(){if(this.#o&&this.#s<=0&&this.#d.length===0){this.#a=!1,this.#o=!1;let e=this.#r.slice();this.#r=[];for(let t of e)t()}}#S(e){let t=Math.floor(e.length/2),n=new Float32Array(t),r=new DataView(e.buffer,e.byteOffset,e.byteLength);for(let e=0;e<t;e++){let t=r.getInt16(e*2,!0);n[e]=t/32768}return n}};const t=16e3,n=/* @__PURE__ */ new Map([[`idle_timeout`,`Voice call ended after a quiet period.`],[`max_duration`,`This voice call reached its time limit.`],[`provider_ended`,`The voice session ended.`],[`quota`,`Voice is unavailable right now.`],[`auth_expired`,`Voice session expired. Tap the mic to reconnect.`]]),r=[`provider_error`,`server_restart`],i=`Voice connection lost.`;function a(e,t){let n=t.slice(0,4e3).trim(),r=8e3-(n?n.length+2:0)-20,i=[];for(let t of e.slice(-12).reverse()){let e=t.content.replace(/\s+/g,` `).trim();if(!e)continue;e.length>2e3&&(e=`${e.slice(0,1999)}…`);let n=`${t.role===`user`?`User`:`Assistant`}: ${e}`;if(n.length+1>r)break;r-=n.length+1,i.unshift(n)}let a=i.length>0?[`Conversation so far:\n${i.join(`
2
2
  `)}`]:[];return n&&a.push(n),a.join(`
3
3
 
4
- `)}function o(e){return e.byteLength>=44&&new DataView(e).getUint32(0,!1)===1380533830?new Uint8Array(e,44):new Uint8Array(e)}function s(e){let t=e.replace(/\/+$/,``);return/^wss?:\/\//i.test(t)?t:/^https?:\/\//i.test(t)?t.replace(/^http/i,`ws`):`${typeof window<`u`&&window.location?.protocol===`https:`?`wss:`:`ws:`}//${t}`}function c(e){return s(e).replace(/^ws/i,`http`)}function l(e){return typeof e!=`number`||!Number.isFinite(e)?3e4:Math.min(6e5,Math.max(3e4,Math.round(e)))}var u=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m;#h;#g;#_;#v;#y;#b;#x;#S;#C;#w;#T;#E;#D;#O;#k;#A;#j;#M;#N;#P;#F;#I;#L;#R;#z;#B;#V;#H;#U;#W;#G;#K;#q;#J;#Y;constructor(e){this.config=e,this.type=`runtype`,this.#e=null,this.#t=null,this.#n=[],this.#r=null,this.#i=null,this.#a=null,this.#o=[],this.#s=0,this.#c=null,this.#l=!1,this.#u=!1,this.#d=0,this.#f=!1,this.#p=-1/0,this.#m=null,this.#h=!1,this.#g=!1,this.#_=0,this.#v=0,this.#b=!1,this.bridge=null,this.#x=!1,this.#S=/* @__PURE__ */ new Set,this.#C=/* @__PURE__ */ new Map,this.#w=/* @__PURE__ */ new Set,this.#E=null,this.#D=null,this.#k=!1,this.#A=!1,this.#j=!1,this.#M=null,this.#N=null,this.#P=Promise.resolve(),this.#F=/* @__PURE__ */ new Set,this.#I=/* @__PURE__ */ new Set,this.#L=null,this.#R=!1,this.#z=/* @__PURE__ */ new Set,this.#B=/* @__PURE__ */ new Set,this.#V=null,this.#H=/* @__PURE__ */ new Set,this.#U=null,this.#W=/* @__PURE__ */ new Map,this.#G=[],this.#K=[],this.#q=[],this.#J=[],this.#Y=[]}async connect(){}setSessionBridge(e){this.bridge=e}prewarm(){if(this.#l||this.#m)return;let e=this.config?.agentId,t=this.config?.clientToken,n=this.config?.host;if(!e||!t||!n)return;let r=Date.now();if(!(r-this.#p<3e4)){this.#p=r;try{this.config?.prewarmMode===`attach`?this.#Z(n,e,t):this.#X(n,e,t)}catch{}}}#X(e,t,n){if(typeof fetch!=`function`)return;let r=`${c(e)}/v1/client/agents/${encodeURIComponent(t)}/voice/prewarm`;fetch(r,{method:`POST`,headers:{Authorization:`Bearer ${n}`},keepalive:!0}).catch(()=>{})}#Z(e,t,n){let r=new URLSearchParams,i=this.config?.attachIdleMs,a=l(i);i!==void 0&&r.set(`attachIdleMs`,String(a));let o=new WebSocket(this.#te(e,t,r),[`runtype.bearer`,`runtype.attach`,n]);o.binaryType=`arraybuffer`;let s=()=>{},c={ws:o,state:`connecting`,ready:new Promise(e=>{s=e}),settle:s,openedAt:0,idleTimer:void 0};this.#m=c,o.onopen=()=>{this.#m===c&&(c.state=o.protocol===`runtype.attach`?`attached`:`live`,c.openedAt=Date.now(),this.#Q(c,a),c.state===`attached`&&o.send(`{"type":"ping"}`),c.settle())},o.onmessage=e=>{if(this.#m!==c||typeof e.data!=`string`)return;let t;try{t=JSON.parse(e.data)}catch{return}t.type===`attached`&&typeof t.idleMs==`number`&&this.#Q(c,t.idleMs-(Date.now()-c.openedAt))},o.onerror=()=>{},o.onclose=()=>{this.#m===c&&this.#$()}}#Q(e,t){clearTimeout(e.idleTimer),e.idleTimer=setTimeout(()=>{this.#m===e&&this.#$()},Math.max(0,t))}#$(){let e=this.#m;if(!e)return;this.#m=null,clearTimeout(e.idleTimer);let{ws:t}=e;if(t.onopen=null,t.onmessage=null,t.onerror=null,t.onclose=null,e.settle(),t.readyState===WebSocket.CONNECTING||t.readyState===WebSocket.OPEN)try{t.close(1e3,`prewarm released`)}catch{}}async#ee(){let e=this.#m;if(!e)return null;if(e.state===`connecting`){let t;await Promise.race([e.ready,new Promise(e=>{t=setTimeout(e,5e3)})]),clearTimeout(t)}return this.#m===e?e.state===`connecting`||e.ws.readyState!==WebSocket.OPEN?(this.#$(),null):(this.#m=null,clearTimeout(e.idleTimer),{ws:e.ws,live:e.state===`live`}):null}#te(e,t,n){let r=`partial_transcript,context`;this.bridge&&this.config?.clientDelegation!==!1&&(r+=`,client_delegation,delegation_update,delegation_read_back,delegation_stream`,this.bridge.clientTools?.()&&(r+=`,client_tools,prior_tool_results`)),n&&(r=`attach,${r}`);let i=new URLSearchParams({voiceProtocol:`runtype-browser-v1`,clientVersion:`persona/4.31.0`,voiceCapabilities:`full-duplex-v1`,clientCapabilities:r});return n?.forEach((e,t)=>i.set(t,e)),`${s(e)}/ws/agents/${encodeURIComponent(t)}/voice?${i}`}async startListening(){if(this.#l)return;let n=this.#A;n||(this.#k=!1,this.#D=null),this.#A=!1;let r=this.config?.agentId,a=this.config?.clientToken,o=this.config?.host;if(!r)throw Error(`Runtype voice requires an agentId`);if(!a)throw Error(`Runtype voice requires a clientToken`);if(!o)throw Error(`Runtype voice requires a host (or widget apiUrl)`);let s=++this.#d;this.#f=!1,this.#l=!0;try{let c=await navigator.mediaDevices.getUserMedia({audio:{sampleRate:t,channelCount:1,echoCancellation:!0}});if(s!==this.#d){c.getTracks().forEach(e=>e.stop());return}this.#r=c;let l=new(window.AudioContext||window.webkitAudioContext)({sampleRate:t});if(this.#t=l,l.state===`suspended`){if(await Promise.race([l.resume().catch(()=>{}),new Promise(e=>setTimeout(e,n?500:1e3))]),s!==this.#d)return;if(l.state!==`running`)throw Error(n?this.#D=`${i} Tap the mic to reconnect.`:`Audio blocked until a tap`)}let u=this.config?.createPlaybackEngine?await this.config.createPlaybackEngine():new e(24e3);if(s!==this.#d){u.destroy(),c.getTracks().forEach(e=>e.stop()),l.close().catch(()=>{});return}this.#c=u,this.#he(),this.#ie(l,c,s);let d=await this.#ee();if(s!==this.#d){d?.ws.close(1e3,`client ended call`);return}if(d){let{ws:e}=d;this.#e=e,this.#ne(e,s),d.live||e.send(`{"type":"start"}`),this.#ae(e),this.#be(`listening`);return}let f=new WebSocket(this.#te(o,r),[`runtype.bearer`,a]);f.binaryType=`arraybuffer`,this.#e=f,f.onopen=()=>{s===this.#d&&(this.#ae(f),this.#be(`listening`))},this.#ne(f,s)}catch(e){throw this.#ye(),this.#xe(e),this.#be(`error`),e}}#ne(e,t){e.onmessage=e=>this.#oe(e,t),e.onerror=()=>{t!==this.#d||this.#E||(this.#xe(/* @__PURE__ */ Error(`Voice connection failed`)),this.#be(`error`),this.#ye())},e.onclose=e=>{if(this.#f){this.#f=!1;return}if(t!==this.#d)return;let n=this.#E??(e.code===4408?{reason:`idle_timeout`}:null);if(n)this.#re(n.reason,n.message);else{if(e.code!==1e3){let t=e.code?` (code ${e.code})`:``;this.#xe(/* @__PURE__ */ Error(`Voice connection closed${t}`)),this.#be(`error`)}else this.#be(`idle`);this.#ye()}}}#re(e,t){let a=r.includes(e)&&!this.#k;if(this.#ye(),a)this.#k=!0,this.#l=!0,this.#D=e===`provider_error`?`${i} Reconnecting…`:`Reconnecting…`,this.#O=setTimeout(()=>{this.#l=!1,this.#A=!0,this.startListening().catch(()=>{})},1e3+Math.random()*1e3),this.#be(`idle`);else{if(r.includes(e))return this.#D=i,this.#xe(/* @__PURE__ */ Error(i)),this.#be(`error`);if(e===`error`)return this.#be(`error`);this.#D=e===`quota`&&t||n.get(e)||null,this.#be(`idle`)}}takeNotice(){let e=this.#D;return this.#D=null,e}getDisclosure(){let e=this.config?.disclosureText;return this.#l&&this.#h&&e!==!1?e||`You're talking to an AI assistant. Voice is processed by OpenAI.`:null}async stopListening(){this.#ye(),this.#be(`idle`)}async disconnect(){this.#ye(),this.#be(`disconnected`),this.#G=[],this.#K=[],this.#q=[],this.#J=[],this.#Y=[]}stopPlayback(){this.#ve();let e=this.#e;e&&e.readyState===WebSocket.OPEN&&(this.#h&&(this.#_=Date.now()+2e3,e.send(`{"type":"cancel"}`)),this.#be(`listening`))}getInterruptionMode(){return`barge-in`}isBargeInActive(){return this.#l}onLevel(e){this.#n.push(e)}async deactivateBargeIn(){this.#ye(),this.#be(`idle`)}#ie(e,t,n){let r=e.createMediaStreamSource(t);this.#i=r;let i=e.createScriptProcessor(4096,1,1);this.#a=i,i.onaudioprocess=e=>{if(n!==this.#d)return;let t=this.#e,r=t?.readyState===WebSocket.OPEN;if(t&&!r&&t.readyState!==WebSocket.CONNECTING)return;let i=e.inputBuffer.getChannelData(0),a=new Int16Array(i.length),o=0;for(let e=0;e<i.length;e++){let t=Math.max(-1,Math.min(1,i[e]));o+=t*t,a[e]=t<0?t*32768:t*32767}if(t&&r)this.#ae(t),t.send(a.buffer);else for(this.#o.push(a.buffer),this.#s+=a.byteLength;this.#s>256e3;)this.#s-=this.#o.shift().byteLength;if(this.#n.length>0){let e=Math.sqrt(o/i.length),t=Math.max(0,Math.min(1,e*4));for(let e of this.#n)e(t)}},r.connect(i),i.connect(e.destination)}#ae(e){for(let t of this.#o)e.send(t);this.#o=[],this.#s=0}#oe(e,t){if(t!==this.#d)return;if(e.data instanceof ArrayBuffer){this.#pe(e.data,t);return}let n;try{n=JSON.parse(e.data)}catch{return}switch(n.type){case`session_config`:n.speechMode&&(this.#h=n.speechMode===`speech_to_speech`,this.#c?.setContinuousMode?.(this.#h)),Array.isArray(n.capabilities)&&(this.#S=new Set(n.capabilities)),typeof n.callId==`string`&&(this.#T=n.callId),this.#x=this.#h&&this.#S.has(`client_delegation`)&&!!this.bridge,this.#h&&!this.#u&&this.#be(`listening`),this.#S.has(`context`)&&!this.#j&&(this.#j=!0,this.#M=this.#se()),this.#x&&this.#S.has(`client_tools`)&&!this.#V&&(this.#V=this.bridge.clientTools?.()?.open({send:e=>{let n=this.#e;return t!==this.#d||n?.readyState!==WebSocket.OPEN?!1:(n.send(JSON.stringify(e)),!0)},cancelled:e=>this.#w.has(e)}).catch(()=>null)??null);break;case`client_tool_call`:{let e=String(n.delegationId);this.#V&&!this.#W.has(e)&&(this.#W.set(e,this.#U),this.#F.add(e)),this.#V?.then(e=>e?.call(n));break}case`transcript_update`:{let e=n.role===`assistant`?`assistant`:`user`,r=n.utteranceId??n.turnId;if(!r||e===`assistant`&&this.#me())break;let i=String(r);if(e===`user`)n.final===!0&&(this.#ce(t),this.#U={id:i,text:String(n.text??``)}),this.#R=!1;else{if(this.#S.has(`delegation_read_back`)){let e=n.delegationId;(typeof e==`string`&&this.#F.has(e)&&!this.#z.has(i)||this.#R&&!this.#z.has(i))&&(this.#B.add(i),this.#R=!1)}else this.#R&&!this.#z.has(i)&&(this.#B.add(i),this.#R=!1);if(this.#z.add(i),this.#B.has(i))break}this.#Se(e,n.text??``,n.final===!0,{turnId:i,...typeof n.startMs==`number`&&{startMs:n.startMs},...typeof n.endMs==`number`&&{endMs:n.endMs},...this.#x&&{caption:!0}});break}case`delegation_started`:case`delegation_completed`:{let e=String(n.delegationId??n.turnId);if(n.type===`delegation_started`){this.#ce(t),this.#H.add(e),this.#F.delete(e),this.#W.delete(e)&&this.#V?.then(t=>t?.abort(e));let r=n.input;this.#x&&r&&this.#fe(e,{delegationId:e,userText:String(r.text??``),userUtteranceIds:Array.isArray(r.userUtteranceIds)?r.userUtteranceIds.filter(e=>typeof e==`string`):[],messages:Array.isArray(r.messages)?r.messages:[],priorToolResults:r.priorToolResults},t)}else if(n.route===`direct`&&this.#V&&!this.#H.has(e)){let t=this.#W.get(e)??this.#U;this.#W.delete(e),this.#H.add(e),this.#F.add(e),this.bridge?.recordDirectTurn?.({delegationId:e,userText:t?.text??``,userUtteranceIds:t?[t.id]:[],assistantText:typeof n.text==`string`?n.text:``})}n.type===`delegation_completed`&&n.speak!==!1&&this.#F.has(e)&&!this.#I.delete(e)&&!this.#S.has(`delegation_read_back`)&&this.#ue(e),this.#g=n.type===`delegation_started`,!this.#u&&!this.#me()&&this.#be(this.#g?`processing`:`listening`);break}case`delegation_progress`:{let e=String(n.delegationId);this.#F.has(e)&&!this.#I.has(e)&&!this.#w.has(e)&&(this.#I.add(e),this.#ue(e));break}case`delegation_cancelled`:this.#de(String(n.delegationId),n.reason!==`session_ending`&&n.reason!==`provider_cancelled`);break;case`warning`:console.warn(`[Persona voice] ${n.code}: ${n.message??``}`,this.#T??``),n.delegationId&&(n.code===`UNKNOWN_DELEGATION`||n.code===`LATE_RESULT_LIMIT`)&&this.#de(String(n.delegationId));break;case`audio_clear`:this.#ve(),this.#_=0,this.#be(`listening`);break;case`transcript_interim`:this.#be(`listening`),this.#Se(`user`,n.text??``,!1);break;case`transcript_final`:{let e=n.role===`assistant`?`assistant`:`user`;this.#be(e===`user`?`processing`:`speaking`),this.#Se(e,n.text??``,!0);break}case`audio_end`:this.#c?this.#c.markStreamEnd():(this.#u=!1,this.#be(`listening`));break;case`metrics`:this.#Ce({llmMs:n.llm_ms,ttsMs:n.tts_ms,firstAudioMs:n.first_audio_ms,totalMs:n.total_ms});break;case`error`:this.#xe(Error(n.error||`Voice error`)),this.#be(`error`);break;case`session_end`:this.#E={reason:String(n.reason),...typeof n.message==`string`&&{message:n.message}}}}async#se(){let e=this.bridge?.getHistory()??[],t=``;try{let e=this.config?.callContext;t=String((typeof e==`function`?await e():e)??``)}catch{}return a(e,t)}#ce(e){let t=this.#M;if(!t)return;this.#M=null;let n=!1,r=t.then(t=>{let r=this.#e;!n&&t&&e===this.#d&&r?.readyState===WebSocket.OPEN&&r.send(JSON.stringify({type:`context`,text:t}))});this.#N={done:r,drop:()=>n=!0}}async#le(){let e=this.#N;if(!e)return;let t,n=await Promise.race([e.done.then(()=>!1),new Promise(e=>{t=setTimeout(()=>e(!0),2e3)})]);clearTimeout(t),n&&e.drop()}#ue(e){this.#R=!0,this.#L=e}#de(e,t=!1){this.#w.add(e),this.#L===e&&(this.#R=!1),this.#I.delete(e),this.#H.has(e)||this.#F.delete(e),this.#V?.then(t=>t?.abort(e)),this.bridge?.dropDelegation?.(e,t),this.#C.get(e)?.abort()}#fe(e,t,n){let r=this.bridge,i=({type:t,...r})=>{let i=this.#e;return n!==this.#d||i?.readyState!==WebSocket.OPEN||this.#w.has(e)?!1:(i.send(JSON.stringify({type:t,delegationId:e,...r})),!0)},a=(e,t,n,r=0)=>i({type:e,status:t,text:n,...r>0&&{streamedChars:r}});this.#P=this.#P.then(async()=>{if(n!==this.#d||this.#w.has(e))return;let o=null,s=this.#S.has(`delegation_stream`)&&this.#S.has(`delegation_read_back`),c=t=>{o=(o??this.#le()).then(()=>{i({type:`delegation_delta`,text:t})&&this.#F.add(e)})},l=await r.runDelegatedTurn(s?{...t,stream:c}:t).catch(()=>({status:`failed`,text:``}));await this.#le(),await o;let u=s?l.streamedChars??0:0,d=!!l.followUp,f=d&&this.#S.has(`delegation_update`);if(!a(f?`delegation_update`:`delegation_result`,d&&!f?`completed`:l.status,l.text,u)||(l.status!==`failed`&&l.inChat!==!1&&this.#F.add(e),!l.followUp))return;let p=new AbortController;this.#C.set(e,p),l.followUp({signal:p.signal,approvalTimeoutMs:this.config?.approvalTimeoutMs&&Math.min(this.config.approvalTimeoutMs,54e4),readBack:f,onUpdate:e=>a(`delegation_update`,`pending_approval`,e)}).then(t=>{this.#C.delete(e),f&&t&&!p.signal.aborted&&a(`delegation_result`,t.status,t.text)})})}#pe(e,t){if(t!==this.#d||!this.#c||this.#me())return;let n=o(e);n.length!==0&&(this.#u||(this.#u=!0,this.#be(`speaking`)),this.#he(),this.#c.enqueue(n),this.#h&&this.#ge(n.length))}#me(){return Date.now()<this.#_}#he(){if(this.#b||!this.#c)return;this.#b=!0;let e=this.#d;this.#c.onFinished(()=>{e===this.#d&&(this.#b=!1,this.#_e())})}#ge(e){let t=Date.now();this.#v=Math.max(t,this.#v)+e/48,clearTimeout(this.#y),this.#y=setTimeout(()=>this.#_e(),this.#v-t+300)}#_e(){this.#u=!1,this.#v=0,this.#e&&this.#e.readyState===WebSocket.OPEN&&this.#be(this.#g?`processing`:`listening`)}#ve(){this.#c?.flush(),this.#b=!1,this.#he(),this.#u=!1,this.#v=0,clearTimeout(this.#y)}#ye(){this.#d+=1,this.#l=!1,this.#u=!1,this.#$(),this.#h=!1,this.#g=!1,this.#x=!1,this.#S=/* @__PURE__ */ new Set;for(let e of this.#C.values())e.abort();if(this.#C.clear(),this.#w.clear(),this.#T=void 0,this.#E=null,clearTimeout(this.#O),this.#j=!1,this.#M=null,this.#N=null,this.#P=Promise.resolve(),this.#F.clear(),this.#I.clear(),this.#L=null,this.#R=!1,this.#z.clear(),this.#B.clear(),this.#V?.then(e=>e?.close()),this.#V=null,this.#H.clear(),this.#W.clear(),this.#U=null,this.#b=!1,this.#_=0,this.#v=0,clearTimeout(this.#y),this.#o=[],this.#s=0,this.#a&&=(this.#a.onaudioprocess=null,this.#a.disconnect(),null),this.#i&&=(this.#i.disconnect(),null),this.#r&&=(this.#r.getTracks().forEach(e=>e.stop()),null),this.#t&&=(this.#t.close().catch(()=>{}),null),this.#c&&=(this.#c.destroy(),null),this.#e){this.#f=!0;try{this.#e.close(1e3,`client ended call`)}catch{}this.#e=null}}onResult(e){this.#G.push(e)}onError(e){this.#K.push(e)}onStatusChange(e){this.#q.push(e)}onTranscript(e){this.#J.push(e)}onMetrics(e){this.#Y.push(e)}#be(e){this.#q.forEach(t=>t(e))}#xe(e){this.#K.forEach(t=>t(e))}#Se(e,t,n,r){this.#J.forEach(i=>i(e,t,n,r))}#Ce(e){this.#Y.forEach(t=>t(e))}},d=class{#e;#t;#n;#r;#i;#a;constructor(e={}){this.config=e,this.type=`browser`,this.#e=null,this.#t=[],this.#n=[],this.#r=[],this.#i=!1,this.#a=typeof window<`u`?window:void 0}async connect(){this.#r.forEach(e=>e(`connected`))}async startListening(){try{if(this.#i)throw Error(`Already listening`);if(!this.#a)throw Error(`Window object not available`);let e=this.#a.SpeechRecognition||this.#a.webkitSpeechRecognition;if(!e)throw Error(`Browser speech recognition not supported`);this.#e=new e,this.#e.lang=this.config?.language||`en-US`,this.#e.continuous=this.config?.continuous||!1,this.#e.interimResults=!0,this.#e.onresult=e=>{let t=Array.from(e.results).map(e=>e[0]).map(e=>e.transcript).join(``),n=e.results[e.results.length-1].isFinal;this.#t.forEach(e=>e({text:t,confidence:n?.8:.5,provider:`browser`})),n&&!this.config?.continuous&&this.stopListening()},this.#e.onerror=e=>{this.#n.forEach(t=>t(Error(e.error))),this.#r.forEach(e=>e(`error`))},this.#e.onstart=()=>{this.#i=!0,this.#r.forEach(e=>e(`listening`))},this.#e.onend=()=>{this.#i=!1,this.#r.forEach(e=>e(`idle`))},this.#e.start()}catch(e){throw this.#n.forEach(t=>t(e)),this.#r.forEach(e=>e(`error`)),e}}async stopListening(){this.#e&&=(this.#e.stop(),null),this.#i=!1,this.#r.forEach(e=>e(`idle`))}onResult(e){this.#t.push(e)}onError(e){this.#n.push(e)}onStatusChange(e){this.#r.push(e)}async disconnect(){await this.stopListening(),this.#r.forEach(e=>e(`disconnected`))}static isSupported(){return`SpeechRecognition`in window||`webkitSpeechRecognition`in window}};function f(e){switch(e.type){case`runtype`:if(!e.runtype)throw Error(`Runtype voice provider requires configuration`);return new u(e.runtype);case`browser`:if(!d.isSupported())throw Error(`Browser speech recognition not supported`);return new d(e.browser||{});case`custom`:{let t=e.custom;if(!t)throw Error("Custom voice provider requires a `custom` provider instance or factory");let n=typeof t==`function`?t():t;if(!n||typeof n.startListening!=`function`)throw Error("Custom voice provider `custom` must be a VoiceProvider (or a factory returning one)");return n}default:throw Error(`Unknown voice provider type: ${e.type}`)}}function p(e){if(e?.type===`custom`&&e.custom)return f({type:`custom`,custom:e.custom});if(e?.type===`runtype`&&e.runtype)return f({type:`runtype`,runtype:e.runtype});if(d.isSupported())return f({type:`browser`,browser:e?.browser||{language:`en-US`}});throw Error(`No supported voice providers available`)}function m(e){try{return p(e),!0}catch{return!1}}const h=e=>e.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,``);var g=class{constructor(e){this.host=e,this.turns=/* @__PURE__ */ new Map,this.latestId=null,this.cancelled=/* @__PURE__ */ new Set}apply(e,t,n,r,i,a){let o=this.host;t=t.trim();let s=this.turns.get(r);if(s||(s={},this.turns.set(r,s),this.latestId=r),e===`user`){s.userFinal=n;let e=s.userId?o.find(s.userId):void 0;if(e){let r=s.userStartMs===void 0&&i!==void 0;r&&(s.userStartMs=i),o.upsert({...e,content:t,voiceProcessing:!n,...r&&this.placeBefore(this.startedAfter(i))})}else{s.userStartMs=i;let e=s.assistantId?o.find(s.assistantId):void 0;s.userId=o.inject({role:`user`,content:t,streaming:!1,voiceProcessing:!n,voiceCaption:a,...this.placeBefore(this.startedAfter(i)??e)}).id}}else if(!this.cancelled.has(r)){s.assistantFinal=n;let e=s.assistantId?o.find(s.assistantId):void 0;if(e){let r=s.assistantStartMs===void 0&&i!==void 0;r&&(s.assistantStartMs=i),o.upsert({...e,content:t,streaming:!n,voiceProcessing:!n,...r&&this.placeBefore(this.startedAfter(i))})}else t&&(s.assistantStartMs=i,s.assistantId=o.inject({role:`assistant`,content:t,streaming:!n,voiceProcessing:!n,voiceCaption:a,...this.placeBefore(this.startedAfter(i))}).id);n&&s.assistantId&&o.markSpoken(s.assistantId)}this.sync()}claimUserTurn(e,t=[]){let n=t[t.length-1];for(let e of t)e!==n&&(this.turns.has(e)||this.turns.set(e,{}),this.turns.get(e).claimed=!0);let r;if(n){if(r=this.turns.get(n),r||(r={},this.turns.set(n,r)),r.claimed)return null;(!r.userId||!this.host.find(r.userId))&&(r.userFinal=!0,r.userId=this.host.inject({role:`user`,content:e.trim()}).id)}else{let t=h(e),n=[...this.turns.values()].reverse().flatMap(e=>{let t=e.userId&&!e.claimed?this.host.find(e.userId):void 0;return t?[{turn:e,text:h(t.content)}]:[]}).filter(({text:e})=>e&&t);r=(n.find(({text:e})=>e===t)??n.find(({text:e})=>e.startsWith(t)||t.startsWith(e)))?.turn}return r?(r.claimed=!0,r.userId):null}cancel(){let e=this.inFlight();if(e.length===0){let t=this.awaiting();if(!t)return;e=[t]}for(let t of e)this.cancelled.add(t);this.closeReplies(e),this.sync()}fail(e){let t=this.awaiting(),n=this.inFlight();if(!t&&n.length===0)return;for(let e of n)this.turns.get(e).assistantFinal=!0;this.closeReplies(n);let r=this.host.inject({role:`assistant`,content:e,streaming:!1,voiceProcessing:!1}),i=t?this.turns.get(t):void 0;i&&(i.assistantId=r.id,i.assistantFinal=!0),this.sync()}settle(){if(this.turns.size===0)return;let e=this.pending(),t=/* @__PURE__ */ new Set;for(let e of this.turns.values())e.userId&&t.add(e.userId),e.assistantId&&(t.add(e.assistantId),this.host.markSpoken(e.assistantId));this.turns.clear(),this.latestId=null,this.host.settle(t),e&&this.host.setStreaming(!1)}startedAfter(e){if(e===void 0)return;let t;for(let n of this.turns.values())for(let[r,i]of[[n.userId,n.userStartMs],[n.assistantId,n.assistantStartMs]])r&&i!==void 0&&i>e&&(!t||i<t.start)&&(t={start:i,id:r});return t&&this.host.find(t.id)}placeBefore(e){if(!e)return;let t=e.sequence??0,n=t-1;for(let r of this.turns.values())for(let i of[r.userId,r.assistantId]){let r=i?this.host.find(i):void 0,a=r?.sequence;r?.createdAt===e.createdAt&&a!==void 0&&a>n&&a<t&&(n=a)}return{createdAt:e.createdAt,sequence:(n+t)/2}}closeReplies(e){let t=/* @__PURE__ */ new Set;for(let n of e){let e=this.turns.get(n)?.assistantId;e&&(t.add(e),this.host.markSpoken(e))}t.size>0&&this.host.settle(t)}inFlight(){let e=[];for(let[t,n]of this.turns)n.assistantId&&!n.assistantFinal&&!this.cancelled.has(t)&&e.push(t);return e}awaiting(){let e=this.latestId;if(!e)return null;let t=this.turns.get(e);return t?.userFinal&&!t.assistantId&&!t.claimed&&!this.cancelled.has(e)?e:null}pending(){return this.awaiting()!==null||this.inFlight().length>0}sync(){this.host.setStreaming(this.pending())}};const _=/* @__PURE__ */ new Set(/* @__PURE__ */ `mr,mrs,ms,dr,prof,sr,jr,st,mt,vs,etc,approx,inc,ltd,co,corp,no,nos,fig,ft,dept,est,min,max,e.g,i.e,a.m,p.m,u.s,u.k`.split(`,`)),v=/([.!?]+|[,;:])(["'”’)\]*_]*)(\s+)|\n\s*/g;function y(e){let t=/(\S+)$/.exec(e)?.[1];if(!t)return!1;let n=t.replace(/^[("'“‘[*_]+/,``).toLowerCase();if(_.has(n)||/^[a-z](?:\.[a-z])*$/.test(n))return!0;if(/^\d+$/.test(t)){let n=e.length-t.length;return n===0||/\n\s*$/.test(e.slice(0,n))}return!1}function*b(e,t){let n=new RegExp(v.source,`g`);for(let r=n.exec(e);r;r=n.exec(e)){let n=r[1];if(!e.slice(0,r.index+(n?.length??0)).trim()||n!==void 0&&(/^[,;:]$/.test(n)&&!t||n===`.`&&y(e.slice(0,r.index))))continue;let i=r.index+r[0].length;i<e.length&&(yield i)}}function x(e,t){let n=e.slice(0,t),r=0;for(let e of n.matchAll(/\s+/g))n.slice(0,e.index).trim()&&(r=e.index+e[0].length);return r}function S(e){let t=0;for(let n of b(e.slice(0,220),!0))t=n;if(t)return t;let n=x(e,220);if(n)return n;let r=e.charCodeAt(219);return r>=55296&&r<=56319?219:220}var C=class{#e=``;#t=!0;push(e){return this.#e+=e,this.#n()}flush(){let e=this.#n(),t=this.#e;if(this.#e=``,t.trim()){for(let n=0;n<t.length;){let r=t.slice(n),i=r.length>220?S(r):r.length;e.push(r.slice(0,i)),n+=i}this.#t=!1}return e}idle(){let e=this.#e;if(!e.trim()||!/(?:[.!?…]["'”’)\]*_]*|\n)\s*$/.test(e))return[];this.#e=``,this.#t=!1;let t=[];for(let n=0;n<e.length;){let r=e.slice(n),i=r.length>220?S(r):r.length;t.push(r.slice(0,i)),n+=i}return t}#n(){let e=[];for(let t=this.#r();t>0;t=this.#r())e.push(this.#e.slice(0,t)),this.#e=this.#e.slice(t),this.#t=!1;return e}#r(){let e=this.#e;if(!e.trim())return 0;let t=b(e,this.#t).next().value??0;if(t&&t<=220)return t;let n=/[.!?]["'”’)\]*_]*$/.test(e);if(this.#t&&!n){let t=e.match(/\S+\s+/g)?.length??0;if(e.trim().length>=30||t>=6){let t=x(e,220);if(t)return t}}return e.length>220?S(e):0}};const w=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n+=1;return n},T=`no|nope|never ?mind|decline(?: it| that)?|cancel(?: it| that| this)?(?: (?:the|my|that|this) (?:[a-z]+ )?(?:order|request))?|don'?t (?:do|place) (?:it|that|the (?:[a-z]+ )?order)`,E=RegExp(`^(?:${T})(?: (?:${T}))?(?: thanks| thank you)?$`),D=e=>E.test(e.toLowerCase().replace(/[^a-z' ]+/g,` `).replace(/\s+/g,` `).trim()),O=()=>new Promise(e=>setTimeout(e,50)),k=(e,t)=>e.length>t?`${e.slice(0,t-1).trimEnd()}…`:e,A=e=>e.replace(/^webmcp:/,``).replace(/([a-z\d])([A-Z])/g,`$1 $2`).replace(/[_\-.]+/g,` `).trim().toLowerCase();function j(e,t=0){if(e==null||e===``)return``;if(typeof e!=`object`)return String(e);if(t>2)return``;if(Array.isArray(e))return e.map(e=>j(e,t+1)).filter(Boolean).join(`, `);let n=e,r=n.quantity??n.qty??n.count,i=n.name??n.item??n.product??n.title;return r!=null&&i!=null&&typeof i!=`object`?`${r} ${i}`:Object.entries(n).filter(([e])=>!e.startsWith(`_`)).map(([e,n])=>{let r=j(n,t+1);return r&&(t?`${A(e)} ${r}`:`${A(e)}: ${r}`)}).filter(Boolean).join(t?`, `:`; `)}function M(e){let t=e.length>1?`These actions need the user's approval in the chat before they happen:`:`This action needs the user's approval in the chat before it happens:`,n=1e3-t.length-119-2;return`${t}\n${e.map(t=>{let r=[A(t.toolName)];t.description&&r.push(`(${k(t.description.trim(),160)})`);let i=j(t.parameters);return i&&r.push(`with ${i}`),t.reason&&r.push(`because: ${k(t.reason.trim(),160)}`),k(`- ${r.join(` `)}`,Math.floor(n/e.length)-1)}).join(`
4
+ `)}function o(e){return e.byteLength>=44&&new DataView(e).getUint32(0,!1)===1380533830?new Uint8Array(e,44):new Uint8Array(e)}function s(e){let t=e.replace(/\/+$/,``);return/^wss?:\/\//i.test(t)?t:/^https?:\/\//i.test(t)?t.replace(/^http/i,`ws`):`${typeof window<`u`&&window.location?.protocol===`https:`?`wss:`:`ws:`}//${t}`}function c(e){return s(e).replace(/^ws/i,`http`)}function l(e){return typeof e!=`number`||!Number.isFinite(e)?3e4:Math.min(6e5,Math.max(3e4,Math.round(e)))}var u=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m;#h;#g;#_;#v;#y;#b;#x;#S;#C;#w;#T;#E;#D;#O;#k;#A;#j;#M;#N;#P;#F;#I;#L;#R;#z;#B;#V;#H;#U;#W;#G;#K;#q;#J;#Y;constructor(e){this.config=e,this.type=`runtype`,this.#e=null,this.#t=null,this.#n=[],this.#r=null,this.#i=null,this.#a=null,this.#o=[],this.#s=0,this.#c=null,this.#l=!1,this.#u=!1,this.#d=0,this.#f=!1,this.#p=-1/0,this.#m=null,this.#h=!1,this.#g=!1,this.#_=0,this.#v=0,this.#b=!1,this.bridge=null,this.#x=!1,this.#S=/* @__PURE__ */ new Set,this.#C=/* @__PURE__ */ new Map,this.#w=/* @__PURE__ */ new Set,this.#E=null,this.#D=null,this.#k=!1,this.#A=!1,this.#j=!1,this.#M=null,this.#N=null,this.#P=Promise.resolve(),this.#F=/* @__PURE__ */ new Set,this.#I=/* @__PURE__ */ new Set,this.#L=null,this.#R=!1,this.#z=/* @__PURE__ */ new Set,this.#B=/* @__PURE__ */ new Set,this.#V=null,this.#H=/* @__PURE__ */ new Set,this.#U=null,this.#W=/* @__PURE__ */ new Map,this.#G=[],this.#K=[],this.#q=[],this.#J=[],this.#Y=[]}async connect(){}setSessionBridge(e){this.bridge=e}prewarm(){if(this.#l||this.#m)return;let e=this.config?.agentId,t=this.config?.clientToken,n=this.config?.host;if(!e||!t||!n)return;let r=Date.now();if(!(r-this.#p<3e4)){this.#p=r;try{this.config?.prewarmMode===`attach`?this.#Z(n,e,t):this.#X(n,e,t)}catch{}}}#X(e,t,n){if(typeof fetch!=`function`)return;let r=`${c(e)}/v1/client/agents/${encodeURIComponent(t)}/voice/prewarm`;fetch(r,{method:`POST`,headers:{Authorization:`Bearer ${n}`},keepalive:!0}).catch(()=>{})}#Z(e,t,n){let r=new URLSearchParams,i=this.config?.attachIdleMs,a=l(i);i!==void 0&&r.set(`attachIdleMs`,String(a));let o=new WebSocket(this.#te(e,t,r),[`runtype.bearer`,`runtype.attach`,n]);o.binaryType=`arraybuffer`;let s=()=>{},c={ws:o,state:`connecting`,ready:new Promise(e=>{s=e}),settle:s,openedAt:0,idleTimer:void 0};this.#m=c,o.onopen=()=>{this.#m===c&&(c.state=o.protocol===`runtype.attach`?`attached`:`live`,c.openedAt=Date.now(),this.#Q(c,a),c.state===`attached`&&o.send(`{"type":"ping"}`),c.settle())},o.onmessage=e=>{if(this.#m!==c||typeof e.data!=`string`)return;let t;try{t=JSON.parse(e.data)}catch{return}t.type===`attached`&&typeof t.idleMs==`number`&&this.#Q(c,t.idleMs-(Date.now()-c.openedAt))},o.onerror=()=>{},o.onclose=()=>{this.#m===c&&this.#$()}}#Q(e,t){clearTimeout(e.idleTimer),e.idleTimer=setTimeout(()=>{this.#m===e&&this.#$()},Math.max(0,t))}#$(){let e=this.#m;if(!e)return;this.#m=null,clearTimeout(e.idleTimer);let{ws:t}=e;if(t.onopen=null,t.onmessage=null,t.onerror=null,t.onclose=null,e.settle(),t.readyState===WebSocket.CONNECTING||t.readyState===WebSocket.OPEN)try{t.close(1e3,`prewarm released`)}catch{}}async#ee(){let e=this.#m;if(!e)return null;if(e.state===`connecting`){let t;await Promise.race([e.ready,new Promise(e=>{t=setTimeout(e,5e3)})]),clearTimeout(t)}return this.#m===e?e.state===`connecting`||e.ws.readyState!==WebSocket.OPEN?(this.#$(),null):(this.#m=null,clearTimeout(e.idleTimer),{ws:e.ws,live:e.state===`live`}):null}#te(e,t,n){let r=`partial_transcript,context`;this.bridge&&this.config?.clientDelegation!==!1&&(r+=`,client_delegation,delegation_update,delegation_read_back,delegation_stream`,this.bridge.clientTools?.()&&(r+=`,client_tools,prior_tool_results`)),n&&(r=`attach,${r}`);let i=new URLSearchParams({voiceProtocol:`runtype-browser-v1`,clientVersion:`persona/4.32.1`,voiceCapabilities:`full-duplex-v1`,clientCapabilities:r});return n?.forEach((e,t)=>i.set(t,e)),`${s(e)}/ws/agents/${encodeURIComponent(t)}/voice?${i}`}async startListening(){if(this.#l)return;let n=this.#A;n||(this.#k=!1,this.#D=null),this.#A=!1;let r=this.config?.agentId,a=this.config?.clientToken,o=this.config?.host;if(!r)throw Error(`Runtype voice requires an agentId`);if(!a)throw Error(`Runtype voice requires a clientToken`);if(!o)throw Error(`Runtype voice requires a host (or widget apiUrl)`);let s=++this.#d;this.#f=!1,this.#l=!0;try{let c=await navigator.mediaDevices.getUserMedia({audio:{sampleRate:t,channelCount:1,echoCancellation:!0}});if(s!==this.#d){c.getTracks().forEach(e=>e.stop());return}this.#r=c;let l=new(window.AudioContext||window.webkitAudioContext)({sampleRate:t});if(this.#t=l,l.state===`suspended`){if(await Promise.race([l.resume().catch(()=>{}),new Promise(e=>setTimeout(e,n?500:1e3))]),s!==this.#d)return;if(l.state!==`running`)throw Error(n?this.#D=`${i} Tap the mic to reconnect.`:`Audio blocked until a tap`)}let u=this.config?.createPlaybackEngine?await this.config.createPlaybackEngine():new e(24e3);if(s!==this.#d){u.destroy(),c.getTracks().forEach(e=>e.stop()),l.close().catch(()=>{});return}this.#c=u,this.#he(),this.#ie(l,c,s);let d=await this.#ee();if(s!==this.#d){d?.ws.close(1e3,`client ended call`);return}if(d){let{ws:e}=d;this.#e=e,this.#ne(e,s),d.live||e.send(`{"type":"start"}`),this.#ae(e),this.#be(`listening`);return}let f=new WebSocket(this.#te(o,r),[`runtype.bearer`,a]);f.binaryType=`arraybuffer`,this.#e=f,f.onopen=()=>{s===this.#d&&(this.#ae(f),this.#be(`listening`))},this.#ne(f,s)}catch(e){throw this.#ye(),this.#xe(e),this.#be(`error`),e}}#ne(e,t){e.onmessage=e=>this.#oe(e,t),e.onerror=()=>{t!==this.#d||this.#E||(this.#xe(/* @__PURE__ */ Error(`Voice connection failed`)),this.#be(`error`),this.#ye())},e.onclose=e=>{if(this.#f){this.#f=!1;return}if(t!==this.#d)return;let n=this.#E??(e.code===4408?{reason:`idle_timeout`}:null);if(n)this.#re(n.reason,n.message);else{if(e.code!==1e3){let t=e.code?` (code ${e.code})`:``;this.#xe(/* @__PURE__ */ Error(`Voice connection closed${t}`)),this.#be(`error`)}else this.#be(`idle`);this.#ye()}}}#re(e,t){let a=r.includes(e)&&!this.#k;if(this.#ye(),a)this.#k=!0,this.#l=!0,this.#D=e===`provider_error`?`${i} Reconnecting…`:`Reconnecting…`,this.#O=setTimeout(()=>{this.#l=!1,this.#A=!0,this.startListening().catch(()=>{})},1e3+Math.random()*1e3),this.#be(`idle`);else{if(r.includes(e))return this.#D=i,this.#xe(/* @__PURE__ */ Error(i)),this.#be(`error`);if(e===`error`)return this.#be(`error`);this.#D=e===`quota`&&t||n.get(e)||null,this.#be(`idle`)}}takeNotice(){let e=this.#D;return this.#D=null,e}getDisclosure(){let e=this.config?.disclosureText;return this.#l&&this.#h&&e!==!1?e||`You're talking to an AI assistant. Voice is processed by OpenAI.`:null}async stopListening(){this.#ye(),this.#be(`idle`)}async disconnect(){this.#ye(),this.#be(`disconnected`),this.#G=[],this.#K=[],this.#q=[],this.#J=[],this.#Y=[]}stopPlayback(){this.#ve();let e=this.#e;e&&e.readyState===WebSocket.OPEN&&(this.#h&&(this.#_=Date.now()+2e3,e.send(`{"type":"cancel"}`)),this.#be(`listening`))}getInterruptionMode(){return`barge-in`}isBargeInActive(){return this.#l}onLevel(e){this.#n.push(e)}async deactivateBargeIn(){this.#ye(),this.#be(`idle`)}#ie(e,t,n){let r=e.createMediaStreamSource(t);this.#i=r;let i=e.createScriptProcessor(4096,1,1);this.#a=i,i.onaudioprocess=e=>{if(n!==this.#d)return;let t=this.#e,r=t?.readyState===WebSocket.OPEN;if(t&&!r&&t.readyState!==WebSocket.CONNECTING)return;let i=e.inputBuffer.getChannelData(0),a=new Int16Array(i.length),o=0;for(let e=0;e<i.length;e++){let t=Math.max(-1,Math.min(1,i[e]));o+=t*t,a[e]=t<0?t*32768:t*32767}if(t&&r)this.#ae(t),t.send(a.buffer);else for(this.#o.push(a.buffer),this.#s+=a.byteLength;this.#s>256e3;)this.#s-=this.#o.shift().byteLength;if(this.#n.length>0){let e=Math.sqrt(o/i.length),t=Math.max(0,Math.min(1,e*4));for(let e of this.#n)e(t)}},r.connect(i),i.connect(e.destination)}#ae(e){for(let t of this.#o)e.send(t);this.#o=[],this.#s=0}#oe(e,t){if(t!==this.#d)return;if(e.data instanceof ArrayBuffer){this.#pe(e.data,t);return}let n;try{n=JSON.parse(e.data)}catch{return}switch(n.type){case`session_config`:n.speechMode&&(this.#h=n.speechMode===`speech_to_speech`,this.#c?.setContinuousMode?.(this.#h)),Array.isArray(n.capabilities)&&(this.#S=new Set(n.capabilities)),typeof n.callId==`string`&&(this.#T=n.callId),this.#x=this.#h&&this.#S.has(`client_delegation`)&&!!this.bridge,this.#h&&!this.#u&&this.#be(`listening`),this.#S.has(`context`)&&!this.#j&&(this.#j=!0,this.#M=this.#se()),this.#x&&this.#S.has(`client_tools`)&&!this.#V&&(this.#V=this.bridge.clientTools?.()?.open({send:e=>{let n=this.#e;return t!==this.#d||n?.readyState!==WebSocket.OPEN?!1:(n.send(JSON.stringify(e)),!0)},cancelled:e=>this.#w.has(e)}).catch(()=>null)??null);break;case`client_tool_call`:{let e=String(n.delegationId);this.#V&&!this.#W.has(e)&&(this.#W.set(e,this.#U),this.#F.add(e)),this.#V?.then(e=>e?.call(n));break}case`transcript_update`:{let e=n.role===`assistant`?`assistant`:`user`,r=n.utteranceId??n.turnId;if(!r||e===`assistant`&&this.#me())break;let i=String(r);if(e===`user`)n.final===!0&&(this.#ce(t),this.#U={id:i,text:String(n.text??``)}),this.#R=!1;else{if(this.#S.has(`delegation_read_back`)){let e=n.delegationId;(typeof e==`string`&&this.#F.has(e)&&!this.#z.has(i)||this.#R&&!this.#z.has(i))&&(this.#B.add(i),this.#R=!1)}else this.#R&&!this.#z.has(i)&&(this.#B.add(i),this.#R=!1);if(this.#z.add(i),this.#B.has(i))break}this.#Se(e,n.text??``,n.final===!0,{turnId:i,...typeof n.startMs==`number`&&{startMs:n.startMs},...typeof n.endMs==`number`&&{endMs:n.endMs},...this.#x&&{caption:!0}});break}case`delegation_started`:case`delegation_completed`:{let e=String(n.delegationId??n.turnId);if(n.type===`delegation_started`){this.#ce(t),this.#H.add(e),this.#F.delete(e),this.#W.delete(e)&&this.#V?.then(t=>t?.abort(e));let r=n.input;this.#x&&r&&this.#fe(e,{delegationId:e,userText:String(r.text??``),userUtteranceIds:Array.isArray(r.userUtteranceIds)?r.userUtteranceIds.filter(e=>typeof e==`string`):[],messages:Array.isArray(r.messages)?r.messages:[],priorToolResults:r.priorToolResults},t)}else if(n.route===`direct`&&this.#V&&!this.#H.has(e)){let t=this.#W.get(e)??this.#U;this.#W.delete(e),this.#H.add(e),this.#F.add(e),this.bridge?.recordDirectTurn?.({delegationId:e,userText:t?.text??``,userUtteranceIds:t?[t.id]:[],assistantText:typeof n.text==`string`?n.text:``})}n.type===`delegation_completed`&&n.speak!==!1&&this.#F.has(e)&&!this.#I.delete(e)&&!this.#S.has(`delegation_read_back`)&&this.#ue(e),this.#g=n.type===`delegation_started`,!this.#u&&!this.#me()&&this.#be(this.#g?`processing`:`listening`);break}case`delegation_progress`:{let e=String(n.delegationId);this.#F.has(e)&&!this.#I.has(e)&&!this.#w.has(e)&&(this.#I.add(e),this.#ue(e));break}case`delegation_cancelled`:this.#de(String(n.delegationId),n.reason!==`session_ending`&&n.reason!==`provider_cancelled`);break;case`warning`:console.warn(`[Persona voice] ${n.code}: ${n.message??``}`,this.#T??``),n.delegationId&&(n.code===`UNKNOWN_DELEGATION`||n.code===`LATE_RESULT_LIMIT`)&&this.#de(String(n.delegationId));break;case`audio_clear`:this.#ve(),this.#_=0,this.#be(`listening`);break;case`transcript_interim`:this.#be(`listening`),this.#Se(`user`,n.text??``,!1);break;case`transcript_final`:{let e=n.role===`assistant`?`assistant`:`user`;this.#be(e===`user`?`processing`:`speaking`),this.#Se(e,n.text??``,!0);break}case`audio_end`:this.#c?this.#c.markStreamEnd():(this.#u=!1,this.#be(`listening`));break;case`metrics`:this.#Ce({llmMs:n.llm_ms,ttsMs:n.tts_ms,firstAudioMs:n.first_audio_ms,totalMs:n.total_ms});break;case`error`:this.#xe(Error(n.error||`Voice error`)),this.#be(`error`);break;case`session_end`:this.#E={reason:String(n.reason),...typeof n.message==`string`&&{message:n.message}}}}async#se(){let e=this.bridge?.getHistory()??[],t=``;try{let e=this.config?.callContext;t=String((typeof e==`function`?await e():e)??``)}catch{}return a(e,t)}#ce(e){let t=this.#M;if(!t)return;this.#M=null;let n=!1,r=t.then(t=>{let r=this.#e;!n&&t&&e===this.#d&&r?.readyState===WebSocket.OPEN&&r.send(JSON.stringify({type:`context`,text:t}))});this.#N={done:r,drop:()=>n=!0}}async#le(){let e=this.#N;if(!e)return;let t,n=await Promise.race([e.done.then(()=>!1),new Promise(e=>{t=setTimeout(()=>e(!0),2e3)})]);clearTimeout(t),n&&e.drop()}#ue(e){this.#R=!0,this.#L=e}#de(e,t=!1){this.#w.add(e),this.#L===e&&(this.#R=!1),this.#I.delete(e),this.#H.has(e)||this.#F.delete(e),this.#V?.then(t=>t?.abort(e)),this.bridge?.dropDelegation?.(e,t),this.#C.get(e)?.abort()}#fe(e,t,n){let r=this.bridge,i=({type:t,...r})=>{let i=this.#e;return n!==this.#d||i?.readyState!==WebSocket.OPEN||this.#w.has(e)?!1:(i.send(JSON.stringify({type:t,delegationId:e,...r})),!0)},a=(e,t,n,r=0)=>i({type:e,status:t,text:n,...r>0&&{streamedChars:r}});this.#P=this.#P.then(async()=>{if(n!==this.#d||this.#w.has(e))return;let o=null,s=this.#S.has(`delegation_stream`)&&this.#S.has(`delegation_read_back`),c=t=>{o=(o??this.#le()).then(()=>{i({type:`delegation_delta`,text:t})&&this.#F.add(e)})},l=await r.runDelegatedTurn(s?{...t,stream:c}:t).catch(()=>({status:`failed`,text:``}));await this.#le(),await o;let u=s?l.streamedChars??0:0,d=!!l.followUp,f=d&&this.#S.has(`delegation_update`);if(!a(f?`delegation_update`:`delegation_result`,d&&!f?`completed`:l.status,l.text,u)||(l.status!==`failed`&&l.inChat!==!1&&this.#F.add(e),!l.followUp))return;let p=new AbortController;this.#C.set(e,p),l.followUp({signal:p.signal,approvalTimeoutMs:this.config?.approvalTimeoutMs&&Math.min(this.config.approvalTimeoutMs,54e4),readBack:f,onUpdate:e=>a(`delegation_update`,`pending_approval`,e)}).then(t=>{this.#C.delete(e),f&&t&&!p.signal.aborted&&a(`delegation_result`,t.status,t.text)})})}#pe(e,t){if(t!==this.#d||!this.#c||this.#me())return;let n=o(e);n.length!==0&&(this.#u||(this.#u=!0,this.#be(`speaking`)),this.#he(),this.#c.enqueue(n),this.#h&&this.#ge(n.length))}#me(){return Date.now()<this.#_}#he(){if(this.#b||!this.#c)return;this.#b=!0;let e=this.#d;this.#c.onFinished(()=>{e===this.#d&&(this.#b=!1,this.#_e())})}#ge(e){let t=Date.now();this.#v=Math.max(t,this.#v)+e/48,clearTimeout(this.#y),this.#y=setTimeout(()=>this.#_e(),this.#v-t+300)}#_e(){this.#u=!1,this.#v=0,this.#e&&this.#e.readyState===WebSocket.OPEN&&this.#be(this.#g?`processing`:`listening`)}#ve(){this.#c?.flush(),this.#b=!1,this.#he(),this.#u=!1,this.#v=0,clearTimeout(this.#y)}#ye(){this.#d+=1,this.#l=!1,this.#u=!1,this.#$(),this.#h=!1,this.#g=!1,this.#x=!1,this.#S=/* @__PURE__ */ new Set;for(let e of this.#C.values())e.abort();if(this.#C.clear(),this.#w.clear(),this.#T=void 0,this.#E=null,clearTimeout(this.#O),this.#j=!1,this.#M=null,this.#N=null,this.#P=Promise.resolve(),this.#F.clear(),this.#I.clear(),this.#L=null,this.#R=!1,this.#z.clear(),this.#B.clear(),this.#V?.then(e=>e?.close()),this.#V=null,this.#H.clear(),this.#W.clear(),this.#U=null,this.#b=!1,this.#_=0,this.#v=0,clearTimeout(this.#y),this.#o=[],this.#s=0,this.#a&&=(this.#a.onaudioprocess=null,this.#a.disconnect(),null),this.#i&&=(this.#i.disconnect(),null),this.#r&&=(this.#r.getTracks().forEach(e=>e.stop()),null),this.#t&&=(this.#t.close().catch(()=>{}),null),this.#c&&=(this.#c.destroy(),null),this.#e){this.#f=!0;try{this.#e.close(1e3,`client ended call`)}catch{}this.#e=null}}onResult(e){this.#G.push(e)}onError(e){this.#K.push(e)}onStatusChange(e){this.#q.push(e)}onTranscript(e){this.#J.push(e)}onMetrics(e){this.#Y.push(e)}#be(e){this.#q.forEach(t=>t(e))}#xe(e){this.#K.forEach(t=>t(e))}#Se(e,t,n,r){this.#J.forEach(i=>i(e,t,n,r))}#Ce(e){this.#Y.forEach(t=>t(e))}},d=class{#e;#t;#n;#r;#i;#a;constructor(e={}){this.config=e,this.type=`browser`,this.#e=null,this.#t=[],this.#n=[],this.#r=[],this.#i=!1,this.#a=typeof window<`u`?window:void 0}async connect(){this.#r.forEach(e=>e(`connected`))}async startListening(){try{if(this.#i)throw Error(`Already listening`);if(!this.#a)throw Error(`Window object not available`);let e=this.#a.SpeechRecognition||this.#a.webkitSpeechRecognition;if(!e)throw Error(`Browser speech recognition not supported`);this.#e=new e,this.#e.lang=this.config?.language||`en-US`,this.#e.continuous=this.config?.continuous||!1,this.#e.interimResults=!0,this.#e.onresult=e=>{let t=Array.from(e.results).map(e=>e[0]).map(e=>e.transcript).join(``),n=e.results[e.results.length-1].isFinal;this.#t.forEach(e=>e({text:t,confidence:n?.8:.5,provider:`browser`})),n&&!this.config?.continuous&&this.stopListening()},this.#e.onerror=e=>{this.#n.forEach(t=>t(Error(e.error))),this.#r.forEach(e=>e(`error`))},this.#e.onstart=()=>{this.#i=!0,this.#r.forEach(e=>e(`listening`))},this.#e.onend=()=>{this.#i=!1,this.#r.forEach(e=>e(`idle`))},this.#e.start()}catch(e){throw this.#n.forEach(t=>t(e)),this.#r.forEach(e=>e(`error`)),e}}async stopListening(){this.#e&&=(this.#e.stop(),null),this.#i=!1,this.#r.forEach(e=>e(`idle`))}onResult(e){this.#t.push(e)}onError(e){this.#n.push(e)}onStatusChange(e){this.#r.push(e)}async disconnect(){await this.stopListening(),this.#r.forEach(e=>e(`disconnected`))}static isSupported(){return`SpeechRecognition`in window||`webkitSpeechRecognition`in window}};function f(e){switch(e.type){case`runtype`:if(!e.runtype)throw Error(`Runtype voice provider requires configuration`);return new u(e.runtype);case`browser`:if(!d.isSupported())throw Error(`Browser speech recognition not supported`);return new d(e.browser||{});case`custom`:{let t=e.custom;if(!t)throw Error("Custom voice provider requires a `custom` provider instance or factory");let n=typeof t==`function`?t():t;if(!n||typeof n.startListening!=`function`)throw Error("Custom voice provider `custom` must be a VoiceProvider (or a factory returning one)");return n}default:throw Error(`Unknown voice provider type: ${e.type}`)}}function p(e){if(e?.type===`custom`&&e.custom)return f({type:`custom`,custom:e.custom});if(e?.type===`runtype`&&e.runtype)return f({type:`runtype`,runtype:e.runtype});if(d.isSupported())return f({type:`browser`,browser:e?.browser||{language:`en-US`}});throw Error(`No supported voice providers available`)}function m(e){try{return p(e),!0}catch{return!1}}const h=e=>e.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,``);var g=class{constructor(e){this.host=e,this.turns=/* @__PURE__ */ new Map,this.latestId=null,this.cancelled=/* @__PURE__ */ new Set}apply(e,t,n,r,i,a){let o=this.host;t=t.trim();let s=this.turns.get(r);if(s||(s={},this.turns.set(r,s),this.latestId=r),e===`user`){s.userFinal=n;let e=s.userId?o.find(s.userId):void 0;if(e){let r=s.userStartMs===void 0&&i!==void 0;r&&(s.userStartMs=i),o.upsert({...e,content:t,voiceProcessing:!n,...r&&this.placeBefore(this.startedAfter(i))})}else{s.userStartMs=i;let e=s.assistantId?o.find(s.assistantId):void 0;s.userId=o.inject({role:`user`,content:t,streaming:!1,voiceProcessing:!n,voiceCaption:a,...this.placeBefore(this.startedAfter(i)??e)}).id}}else if(!this.cancelled.has(r)){s.assistantFinal=n;let e=s.assistantId?o.find(s.assistantId):void 0;if(e){let r=s.assistantStartMs===void 0&&i!==void 0;r&&(s.assistantStartMs=i),o.upsert({...e,content:t,streaming:!n,voiceProcessing:!n,...r&&this.placeBefore(this.startedAfter(i))})}else t&&(s.assistantStartMs=i,s.assistantId=o.inject({role:`assistant`,content:t,streaming:!n,voiceProcessing:!n,voiceCaption:a,...this.placeBefore(this.startedAfter(i))}).id);n&&s.assistantId&&o.markSpoken(s.assistantId)}this.sync()}claimUserTurn(e,t=[]){let n=t[t.length-1];for(let e of t)e!==n&&(this.turns.has(e)||this.turns.set(e,{}),this.turns.get(e).claimed=!0);let r;if(n){if(r=this.turns.get(n),r||(r={},this.turns.set(n,r)),r.claimed)return null;(!r.userId||!this.host.find(r.userId))&&(r.userFinal=!0,r.userId=this.host.inject({role:`user`,content:e.trim()}).id)}else{let t=h(e),n=[...this.turns.values()].reverse().flatMap(e=>{let t=e.userId&&!e.claimed?this.host.find(e.userId):void 0;return t?[{turn:e,text:h(t.content)}]:[]}).filter(({text:e})=>e&&t);r=(n.find(({text:e})=>e===t)??n.find(({text:e})=>e.startsWith(t)||t.startsWith(e)))?.turn}return r?(r.claimed=!0,r.userId):null}cancel(){let e=this.inFlight();if(e.length===0){let t=this.awaiting();if(!t)return;e=[t]}for(let t of e)this.cancelled.add(t);this.closeReplies(e),this.sync()}fail(e){let t=this.awaiting(),n=this.inFlight();if(!t&&n.length===0)return;for(let e of n)this.turns.get(e).assistantFinal=!0;this.closeReplies(n);let r=this.host.inject({role:`assistant`,content:e,streaming:!1,voiceProcessing:!1}),i=t?this.turns.get(t):void 0;i&&(i.assistantId=r.id,i.assistantFinal=!0),this.sync()}settle(){if(this.turns.size===0)return;let e=this.pending(),t=/* @__PURE__ */ new Set;for(let e of this.turns.values())e.userId&&t.add(e.userId),e.assistantId&&(t.add(e.assistantId),this.host.markSpoken(e.assistantId));this.turns.clear(),this.latestId=null,this.host.settle(t),e&&this.host.setStreaming(!1)}startedAfter(e){if(e===void 0)return;let t;for(let n of this.turns.values())for(let[r,i]of[[n.userId,n.userStartMs],[n.assistantId,n.assistantStartMs]])r&&i!==void 0&&i>e&&(!t||i<t.start)&&(t={start:i,id:r});return t&&this.host.find(t.id)}placeBefore(e){if(!e)return;let t=e.sequence??0,n=t-1;for(let r of this.turns.values())for(let i of[r.userId,r.assistantId]){let r=i?this.host.find(i):void 0,a=r?.sequence;r?.createdAt===e.createdAt&&a!==void 0&&a>n&&a<t&&(n=a)}return{createdAt:e.createdAt,sequence:(n+t)/2}}closeReplies(e){let t=/* @__PURE__ */ new Set;for(let n of e){let e=this.turns.get(n)?.assistantId;e&&(t.add(e),this.host.markSpoken(e))}t.size>0&&this.host.settle(t)}inFlight(){let e=[];for(let[t,n]of this.turns)n.assistantId&&!n.assistantFinal&&!this.cancelled.has(t)&&e.push(t);return e}awaiting(){let e=this.latestId;if(!e)return null;let t=this.turns.get(e);return t?.userFinal&&!t.assistantId&&!t.claimed&&!this.cancelled.has(e)?e:null}pending(){return this.awaiting()!==null||this.inFlight().length>0}sync(){this.host.setStreaming(this.pending())}};const _=/* @__PURE__ */ new Set(/* @__PURE__ */ `mr,mrs,ms,dr,prof,sr,jr,st,mt,vs,etc,approx,inc,ltd,co,corp,no,nos,fig,ft,dept,est,min,max,e.g,i.e,a.m,p.m,u.s,u.k`.split(`,`)),v=/([.!?]+|[,;:])(["'”’)\]*_]*)(\s+)|\n\s*/g;function y(e){let t=/(\S+)$/.exec(e)?.[1];if(!t)return!1;let n=t.replace(/^[("'“‘[*_]+/,``).toLowerCase();if(_.has(n)||/^[a-z](?:\.[a-z])*$/.test(n))return!0;if(/^\d+$/.test(t)){let n=e.length-t.length;return n===0||/\n\s*$/.test(e.slice(0,n))}return!1}function*b(e,t){let n=new RegExp(v.source,`g`);for(let r=n.exec(e);r;r=n.exec(e)){let n=r[1];if(!e.slice(0,r.index+(n?.length??0)).trim()||n!==void 0&&(/^[,;:]$/.test(n)&&!t||n===`.`&&y(e.slice(0,r.index))))continue;let i=r.index+r[0].length;i<e.length&&(yield i)}}function x(e,t){let n=e.slice(0,t),r=0;for(let e of n.matchAll(/\s+/g))n.slice(0,e.index).trim()&&(r=e.index+e[0].length);return r}function S(e){let t=0;for(let n of b(e.slice(0,220),!0))t=n;if(t)return t;let n=x(e,220);if(n)return n;let r=e.charCodeAt(219);return r>=55296&&r<=56319?219:220}var C=class{#e=``;#t=!0;push(e){return this.#e+=e,this.#n()}flush(){let e=this.#n(),t=this.#e;if(this.#e=``,t.trim()){for(let n=0;n<t.length;){let r=t.slice(n),i=r.length>220?S(r):r.length;e.push(r.slice(0,i)),n+=i}this.#t=!1}return e}idle(){let e=this.#e;if(!e.trim()||!/(?:[.!?…]["'”’)\]*_]*|\n)\s*$/.test(e))return[];this.#e=``,this.#t=!1;let t=[];for(let n=0;n<e.length;){let r=e.slice(n),i=r.length>220?S(r):r.length;t.push(r.slice(0,i)),n+=i}return t}#n(){let e=[];for(let t=this.#r();t>0;t=this.#r())e.push(this.#e.slice(0,t)),this.#e=this.#e.slice(t),this.#t=!1;return e}#r(){let e=this.#e;if(!e.trim())return 0;let t=b(e,this.#t).next().value??0;if(t&&t<=220)return t;let n=/[.!?]["'”’)\]*_]*$/.test(e);if(this.#t&&!n){let t=e.match(/\S+\s+/g)?.length??0;if(e.trim().length>=30||t>=6){let t=x(e,220);if(t)return t}}return e.length>220?S(e):0}};const w=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n+=1;return n},T=`no|nope|never ?mind|decline(?: it| that)?|cancel(?: it| that| this)?(?: (?:the|my|that|this) (?:[a-z]+ )?(?:order|request))?|don'?t (?:do|place) (?:it|that|the (?:[a-z]+ )?order)`,E=RegExp(`^(?:${T})(?: (?:${T}))?(?: thanks| thank you)?$`),D=e=>E.test(e.toLowerCase().replace(/[^a-z' ]+/g,` `).replace(/\s+/g,` `).trim()),O=()=>new Promise(e=>setTimeout(e,50)),k=(e,t)=>e.length>t?`${e.slice(0,t-1).trimEnd()}…`:e,A=e=>e.replace(/^webmcp:/,``).replace(/([a-z\d])([A-Z])/g,`$1 $2`).replace(/[_\-.]+/g,` `).trim().toLowerCase();function j(e,t=0){if(e==null||e===``)return``;if(typeof e!=`object`)return String(e);if(t>2)return``;if(Array.isArray(e))return e.map(e=>j(e,t+1)).filter(Boolean).join(`, `);let n=e,r=n.quantity??n.qty??n.count,i=n.name??n.item??n.product??n.title;return r!=null&&i!=null&&typeof i!=`object`?`${r} ${i}`:Object.entries(n).filter(([e])=>!e.startsWith(`_`)).map(([e,n])=>{let r=j(n,t+1);return r&&(t?`${A(e)} ${r}`:`${A(e)}: ${r}`)}).filter(Boolean).join(t?`, `:`; `)}function M(e){let t=e.length>1?`These actions need the user's approval in the chat before they happen:`:`This action needs the user's approval in the chat before it happens:`,n=1e3-t.length-119-2;return`${t}\n${e.map(t=>{let r=[A(t.toolName)];t.description&&r.push(`(${k(t.description.trim(),160)})`);let i=j(t.parameters);return i&&r.push(`with ${i}`),t.reason&&r.push(`because: ${k(t.reason.trim(),160)}`),k(`- ${r.join(` `)}`,Math.floor(n/e.length)-1)}).join(`
5
5
  `)}\n\nBriefly tell the user what you're about to do and ask them to approve or decline it in the chat. Don't claim it's done.`}const N=e=>e.variant===`approval`&&e.approval?.status===`pending`;function P(e){let t=null,n=null,r=()=>e.track(t??n),i=[],a=/* @__PURE__ */ new Map,o=/* @__PURE__ */ new Map,s=(e,t)=>{a.set(e,[...a.get(e)??[],t]),a.size>32&&a.delete(a.keys().next().value)},c=t=>e.messages().find(e=>e.id===t),l=e=>e.approvals.filter(e=>c(e)?.approval?.status===`pending`),u=e=>A(c(e)?.approval?.toolName??``),d=(t,n,r)=>{t.outcome={status:n,text:r};for(let n of l(t))e.decide(n)},f=t=>t.flatMap(t=>e.messages().find(e=>e.id===t)??[]).filter(e=>!e.variant&&e.content.trim()).map(e=>e.content.trim()).join(`
6
6
 
7
7
  `),p=async t=>{do await O();while(e.busy()&&!(t&&(e.parked()||t.failed)))};return{clientTools:e.clientTools,recordDirectTurn:e.recordDirect,getHistory:()=>{let t=e.messages().filter(e=>(e.role===`user`||e.role===`assistant`)&&!e.variant&&!e.voiceProcessing&&!e.streaming&&e.content),n=!1,r=[];for(let e=t.length-1;e>=0;--e){let i=t[e];if(i.role===`user`)n=!1;else if(!i.voiceCaption)n=!0;else if(n)continue;r.unshift({role:i.role,content:i.content})}return r},dropDelegation(t,n){o.set(t,!!n),o.size>32&&o.delete(o.keys().next().value);let r=n&&i.find(e=>e.delegationId===t);r&&!r.outcome&&d(r,`timeout`,``);for(let n of a.get(t)??[])n.stopStream?.(),n.dropped=!0,n.ids.length&&e.unspoken(n.ids)},async runDelegatedTurn({delegationId:m,userText:h,userUtteranceIds:g,stream:_,priorToolResults:v}){let y=i.filter(e=>l(e).length),b=y.flatMap(l);if(b.length===1&&D(h)){let e=u(b[0]);return d(y[0],`denied`,``),{status:`denied`,text:`Okay, I cancelled the ${e} request. Nothing was done.`,inChat:!1}}let x=e.parked()&&e.messages().every(e=>!N(e)||b.includes(e.id));e.busy()&&!x&&await p();let S=new Set(e.messages().map(e=>e.id)),T=()=>e.messages().filter(e=>!S.has(e.id)&&e.variant===`approval`),E={ids:[],failed:!1},k=_?new C:null,j=``,P=``,F=!1,I=e=>{for(let t of e)P+=t,_(t)},L;k&&(E.onUpdate=()=>{if(F)return;let e=f(E.ids);if(!e.startsWith(j)){F=!0,clearTimeout(L);return}if(e.length===j.length)return;let t=e.slice(j.length);j=e,I(k.push(t)),clearTimeout(L),L=setTimeout(()=>{F||I(k.idle())},200)},E.stopStream=()=>{clearTimeout(L),F=!0,E.onUpdate=void 0}),s(m,E),t=E,r();try{await e.send(h,{userMessageId:e.claim(h,g),priorToolResults:v}),await p(E)}catch{E.failed=!0}finally{t=null,r()}k&&(E.onUpdate?.(),clearTimeout(L),F||I(k.flush()),E.onUpdate=void 0,E.stopStream=void 0);let R=e=>{let t=w(P,e);return t>0?{streamedChars:t}:{}},z=E.ids.flatMap(t=>e.messages().find(e=>e.id===t)??[]),B=f(E.ids),V=E.failed?[]:T().filter(N),H=new Set(V.map(e=>A(e.approval.toolName)));for(let t of y){if(t.outcome)continue;for(let n of l(t).filter(e=>H.has(u(e))))t.replaced.add(n),e.decide(n);let n=u(t.approvals[0]);(t.approvals.every(e=>t.replaced.has(e))||x&&t.approvals.every(e=>c(e)?.approval?.status===`denied`))&&(t.outcome={status:`cancelled`,text:`The earlier ${n} request was replaced by the new one; it was not done.`})}if(V.length){let c=new Set(V.map(e=>e.id)),p={delegationId:m,approvals:[...c],at:Date.now(),replaced:/* @__PURE__ */ new Set};return i.push(p),o.get(m)&&d(p,`timeout`,``),B=`${B}\n\n${M(V.map(e=>e.approval))}`.trim(),{status:`pending_approval`,text:B,...R(B),followUp:async({signal:o,approvalTimeoutMs:h=3e5,readBack:g=!0,onUpdate:_})=>{let v={ids:[],failed:!1};a.delete(m),s(m,v);let y=()=>T().filter(e=>c.has(e.id)||v.ids.includes(e.id)),b=()=>T().filter(e=>N(e)&&!c.has(e.id)&&!i.some(t=>t.approvals.includes(e.id))&&(v.ids.includes(e.id)||e.approval?.toolType===`webmcp`&&n===v)),x=()=>{n=v,r()};g&&x();try{for(;!o.aborted&&!p.outcome&&(t||e.busy()||y().some(N));){g&&n!==v&&!l(p).length&&x();let t=b();if(t.length){for(let e of t)c.add(e.id),p.approvals.push(e.id);p.at=Date.now(),_?.(M(t.map(e=>e.approval)))}if(Date.now()-p.at>=h&&l(p).length&&(!e.busy()||e.parked())){d(p,`timeout`,`That ${u(p.approvals[0])} request expired, so nothing was done.`);break}await O()}}finally{n===v&&(n=null,r()),i.splice(i.indexOf(p),1)}if(o.aborted)return null;if(p.outcome)return p.outcome;if(v.failed)return{status:`failed`,text:`The ${u(p.approvals[0])} request didn't complete.`};let S=y(),C=e=>S.filter(e).map(e=>A(e.approval.toolName)).join(`, `),w=S.some(e=>e.approval?.status===`approved`),E=C(e=>e.approval?.status===`denied`&&!p.replaced.has(e.id)),D=C(e=>p.replaced.has(e.id)),k=C(e=>e.approval?.status===`timeout`),j=[w?f(v.ids):``,E&&`The user declined the ${E} request in the chat, so ${w?`that part was not done`:`nothing was done`}.`,D&&`The earlier ${D} request was replaced by the new one; it was not done.`,k&&`The ${k} request timed out, so it was not done.`].filter(Boolean).join(`
@@ -1,5 +1,5 @@
1
- import { Ct as AgentWidgetMessage, Zi as VoiceClientTools, fa as VoiceSessionBridge, fi as InjectMessageOptions, k as AgentWidgetConfig, oa as VoiceDirectTurn, pa as VoiceStatus, ua as VoiceProvider } from "./types-CSXHl5cN.cjs";
2
- import { $ as BrowserVoiceProvider, Q as isVoiceSupported, X as createBestAvailableVoiceProvider, Z as createVoiceProvider, et as RuntypeVoiceProvider, t as AgentWidgetSession } from "./session-Dj4bOm5y.cjs";
1
+ import { Ct as AgentWidgetMessage, Qi as VoiceClientTools, da as VoiceProvider, k as AgentWidgetConfig, ma as VoiceStatus, pa as VoiceSessionBridge, pi as InjectMessageOptions, sa as VoiceDirectTurn } from "./types-BOZHQIk0.cjs";
2
+ import { $ as BrowserVoiceProvider, Q as isVoiceSupported, X as createBestAvailableVoiceProvider, Z as createVoiceProvider, et as RuntypeVoiceProvider, t as AgentWidgetSession } from "./session-Baxp9iRK.cjs";
3
3
  //#region src/voice/keyed-voice-transcript.d.ts
4
4
  /** The session surface the keyed reconciler drives. */
5
5
  interface KeyedVoiceTranscriptHost {
@@ -1,5 +1,5 @@
1
- import { Ct as AgentWidgetMessage, Zi as VoiceClientTools, fa as VoiceSessionBridge, fi as InjectMessageOptions, k as AgentWidgetConfig, oa as VoiceDirectTurn, pa as VoiceStatus, ua as VoiceProvider } from "./types-CSXHl5cN.js";
2
- import { $ as BrowserVoiceProvider, Q as isVoiceSupported, X as createBestAvailableVoiceProvider, Z as createVoiceProvider, et as RuntypeVoiceProvider, t as AgentWidgetSession } from "./session-Dj4bOm5y.js";
1
+ import { Ct as AgentWidgetMessage, Qi as VoiceClientTools, da as VoiceProvider, k as AgentWidgetConfig, ma as VoiceStatus, pa as VoiceSessionBridge, pi as InjectMessageOptions, sa as VoiceDirectTurn } from "./types-BOZHQIk0.js";
2
+ import { $ as BrowserVoiceProvider, Q as isVoiceSupported, X as createBestAvailableVoiceProvider, Z as createVoiceProvider, et as RuntypeVoiceProvider, t as AgentWidgetSession } from "./session-Baxp9iRK.js";
3
3
  //#region src/voice/keyed-voice-transcript.d.ts
4
4
  /** The session surface the keyed reconciler drives. */
5
5
  interface KeyedVoiceTranscriptHost {
@@ -1,4 +1,4 @@
1
- var e=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},t,n=e((()=>{t=class{#e=null;#t=0;#n=[];#r=[];#i=[];#a=!1;#o=!1;#s=0;#c=!1;#l=!1;#u;#d=[];#f=0;#p=!1;#m;#h;#g;#_=null;constructor(e=24e3,t={}){this.#h=e;let n=Math.max(0,t.prebufferMs??0);this.#g=Math.round(e*n/1e3),this.#u=this.#g>0}#v(){if(!this.#e){let e=typeof window<`u`?window:void 0;if(!e)throw Error(`AudioPlaybackManager requires a browser environment`);let t=e.AudioContext||e.webkitAudioContext;this.#e=new t({sampleRate:this.#h})}let e=this.#e;return e.state===`suspended`&&!this.#l&&e.resume(),e}enqueue(e){if(e.length===0)return;let t=e;if(this.#_){let n=new Uint8Array(this.#_.length+e.length);n.set(this.#_),n.set(e,this.#_.length),t=n,this.#_=null}if(t.length%2!=0&&(this.#_=new Uint8Array([t[t.length-1]]),t=t.subarray(0,t.length-1)),t.length===0)return;let n=this.#S(t);n.length!==0&&(this.#u?(this.#d.push(n),this.#f+=n.length,clearTimeout(this.#m),this.#f>=this.#g?this.#y():this.#p&&(this.#m=setTimeout(()=>this.#y(),this.#g/this.#h*1e3))):this.#b(n))}markStreamEnd(){this.#d.length>0&&this.#y(),this.#o=!0,this.#x()}flush(){for(let e of this.#n){e.onended=null;try{e.stop(),e.disconnect()}catch{}}this.#n=[],this.#s=0,this.#t=0,this.#a=!1,this.#o=!1,this.#r=[],this.#i=[],this.#_=null,this.#d=[],this.#f=0,this.#u=this.#g>0,this.#c=!1,clearTimeout(this.#m)}setContinuousMode(e){this.#p=e}isPlaying(){return this.#a}onFinished(e){this.#r.push(e)}onStarted(e){this.#i.push(e)}pause(){this.#l=!0,this.#e&&this.#e.state===`running`&&this.#e.suspend()}resume(){this.#l=!1,this.#e&&this.#e.state===`suspended`&&this.#e.resume()}async destroy(){this.flush(),this.#e&&=(await this.#e.close(),null)}#y(){this.#u=!1;let e=this.#d;this.#d=[],this.#f=0;for(let t of e)this.#b(t)}#b(e){if(e.length===0)return;let t=this.#v(),n=t.createBuffer(1,e.length,this.#h);n.getChannelData(0).set(e);let r=t.createBufferSource();r.buffer=n,r.connect(t.destination);let i=t.currentTime;if(this.#t===0?this.#t=i:this.#t<i&&(this.#t=i,this.#g>0&&(this.#u=!0)),r.start(this.#t),this.#t+=n.duration,this.#n.push(r),this.#s++,this.#a=!0,!this.#c){this.#c=!0;let e=this.#i.slice();this.#i=[];for(let t of e)t()}r.onended=()=>{let e=this.#n.indexOf(r);e!==-1&&(this.#n.splice(e,1),this.#s--,this.#x())}}#x(){if(this.#o&&this.#s<=0&&this.#d.length===0){this.#a=!1,this.#o=!1;let e=this.#r.slice();this.#r=[];for(let t of e)t()}}#S(e){let t=Math.floor(e.length/2),n=new Float32Array(t),r=new DataView(e.buffer,e.byteOffset,e.byteLength);for(let e=0;e<t;e++){let t=r.getInt16(e*2,!0);n[e]=t/32768}return n}}})),r=`4.31.0`,i,a=e((()=>{i=r}));function o(e,t){let n=t.slice(0,P).trim(),r=N-(n?n.length+2:0)-20,i=[];for(let t of e.slice(-12).reverse()){let e=t.content.replace(/\s+/g,` `).trim();if(!e)continue;e.length>F&&(e=`${e.slice(0,1999)}…`);let n=`${t.role===`user`?`User`:`Assistant`}: ${e}`;if(n.length+1>r)break;r-=n.length+1,i.unshift(n)}let a=i.length>0?[`Conversation so far:\n${i.join(`
1
+ var e=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},t,n=e((()=>{t=class{#e=null;#t=0;#n=[];#r=[];#i=[];#a=!1;#o=!1;#s=0;#c=!1;#l=!1;#u;#d=[];#f=0;#p=!1;#m;#h;#g;#_=null;constructor(e=24e3,t={}){this.#h=e;let n=Math.max(0,t.prebufferMs??0);this.#g=Math.round(e*n/1e3),this.#u=this.#g>0}#v(){if(!this.#e){let e=typeof window<`u`?window:void 0;if(!e)throw Error(`AudioPlaybackManager requires a browser environment`);let t=e.AudioContext||e.webkitAudioContext;this.#e=new t({sampleRate:this.#h})}let e=this.#e;return e.state===`suspended`&&!this.#l&&e.resume(),e}enqueue(e){if(e.length===0)return;let t=e;if(this.#_){let n=new Uint8Array(this.#_.length+e.length);n.set(this.#_),n.set(e,this.#_.length),t=n,this.#_=null}if(t.length%2!=0&&(this.#_=new Uint8Array([t[t.length-1]]),t=t.subarray(0,t.length-1)),t.length===0)return;let n=this.#S(t);n.length!==0&&(this.#u?(this.#d.push(n),this.#f+=n.length,clearTimeout(this.#m),this.#f>=this.#g?this.#y():this.#p&&(this.#m=setTimeout(()=>this.#y(),this.#g/this.#h*1e3))):this.#b(n))}markStreamEnd(){this.#d.length>0&&this.#y(),this.#o=!0,this.#x()}flush(){for(let e of this.#n){e.onended=null;try{e.stop(),e.disconnect()}catch{}}this.#n=[],this.#s=0,this.#t=0,this.#a=!1,this.#o=!1,this.#r=[],this.#i=[],this.#_=null,this.#d=[],this.#f=0,this.#u=this.#g>0,this.#c=!1,clearTimeout(this.#m)}setContinuousMode(e){this.#p=e}isPlaying(){return this.#a}onFinished(e){this.#r.push(e)}onStarted(e){this.#i.push(e)}pause(){this.#l=!0,this.#e&&this.#e.state===`running`&&this.#e.suspend()}resume(){this.#l=!1,this.#e&&this.#e.state===`suspended`&&this.#e.resume()}async destroy(){this.flush(),this.#e&&=(await this.#e.close(),null)}#y(){this.#u=!1;let e=this.#d;this.#d=[],this.#f=0;for(let t of e)this.#b(t)}#b(e){if(e.length===0)return;let t=this.#v(),n=t.createBuffer(1,e.length,this.#h);n.getChannelData(0).set(e);let r=t.createBufferSource();r.buffer=n,r.connect(t.destination);let i=t.currentTime;if(this.#t===0?this.#t=i:this.#t<i&&(this.#t=i,this.#g>0&&(this.#u=!0)),r.start(this.#t),this.#t+=n.duration,this.#n.push(r),this.#s++,this.#a=!0,!this.#c){this.#c=!0;let e=this.#i.slice();this.#i=[];for(let t of e)t()}r.onended=()=>{let e=this.#n.indexOf(r);e!==-1&&(this.#n.splice(e,1),this.#s--,this.#x())}}#x(){if(this.#o&&this.#s<=0&&this.#d.length===0){this.#a=!1,this.#o=!1;let e=this.#r.slice();this.#r=[];for(let t of e)t()}}#S(e){let t=Math.floor(e.length/2),n=new Float32Array(t),r=new DataView(e.buffer,e.byteOffset,e.byteLength);for(let e=0;e<t;e++){let t=r.getInt16(e*2,!0);n[e]=t/32768}return n}}})),r=`4.32.1`,i,a=e((()=>{i=r}));function o(e,t){let n=t.slice(0,P).trim(),r=N-(n?n.length+2:0)-20,i=[];for(let t of e.slice(-12).reverse()){let e=t.content.replace(/\s+/g,` `).trim();if(!e)continue;e.length>F&&(e=`${e.slice(0,1999)}…`);let n=`${t.role===`user`?`User`:`Assistant`}: ${e}`;if(n.length+1>r)break;r-=n.length+1,i.unshift(n)}let a=i.length>0?[`Conversation so far:\n${i.join(`
2
2
  `)}`]:[];return n&&a.push(n),a.join(`
3
3
 
4
4
  `)}function s(e){return e.byteLength>=44&&new DataView(e).getUint32(0,!1)===g?new Uint8Array(e,44):new Uint8Array(e)}function c(e){let t=e.replace(/\/+$/,``);return/^wss?:\/\//i.test(t)?t:/^https?:\/\//i.test(t)?t.replace(/^http/i,`ws`):`${typeof window<`u`&&window.location?.protocol===`https:`?`wss:`:`ws:`}//${t}`}function l(e){return c(e).replace(/^ws/i,`http`)}function u(e){return typeof e!=`number`||!Number.isFinite(e)?b:Math.min(S,Math.max(x,Math.round(e)))}var d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M,N,P,F,I,ee=e((()=>{n(),a(),d=16e3,f=24e3,p=4096,m=d*2*8,h=4,g=1380533830,_=3e4,v=1e3,y=5e3,b=3e4,x=3e4,S=6e5,C=`full-duplex-v1`,w=300,T=2e3,E=2e3,D=`runtype-browser-v1`,O=54e4,k=`You're talking to an AI assistant. Voice is processed by OpenAI.`,A=/* @__PURE__ */ new Map([[`idle_timeout`,`Voice call ended after a quiet period.`],[`max_duration`,`This voice call reached its time limit.`],[`provider_ended`,`The voice session ended.`],[`quota`,`Voice is unavailable right now.`],[`auth_expired`,`Voice session expired. Tap the mic to reconnect.`]]),j=[`provider_error`,`server_restart`],M=`Voice connection lost.`,N=8e3,P=4e3,F=2e3,I=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m;#h;#g;#_;#v;#y;#b;#x;#S;#C;#w;#T;#E;#D;#O;#k;#A;#j;#M;#N;#P;#F;#I;#L;#R;#z;#B;#V;#H;#U;#W;#G;#K;#q;#J;#Y;constructor(e){this.config=e,this.type=`runtype`,this.#e=null,this.#t=null,this.#n=[],this.#r=null,this.#i=null,this.#a=null,this.#o=[],this.#s=0,this.#c=null,this.#l=!1,this.#u=!1,this.#d=0,this.#f=!1,this.#p=-1/0,this.#m=null,this.#h=!1,this.#g=!1,this.#_=0,this.#v=0,this.#b=!1,this.bridge=null,this.#x=!1,this.#S=/* @__PURE__ */ new Set,this.#C=/* @__PURE__ */ new Map,this.#w=/* @__PURE__ */ new Set,this.#E=null,this.#D=null,this.#k=!1,this.#A=!1,this.#j=!1,this.#M=null,this.#N=null,this.#P=Promise.resolve(),this.#F=/* @__PURE__ */ new Set,this.#I=/* @__PURE__ */ new Set,this.#L=null,this.#R=!1,this.#z=/* @__PURE__ */ new Set,this.#B=/* @__PURE__ */ new Set,this.#V=null,this.#H=/* @__PURE__ */ new Set,this.#U=null,this.#W=/* @__PURE__ */ new Map,this.#G=[],this.#K=[],this.#q=[],this.#J=[],this.#Y=[]}async connect(){}setSessionBridge(e){this.bridge=e}prewarm(){if(this.#l||this.#m)return;let e=this.config?.agentId,t=this.config?.clientToken,n=this.config?.host;if(!e||!t||!n)return;let r=Date.now();if(!(r-this.#p<_)){this.#p=r;try{this.config?.prewarmMode===`attach`?this.#Z(n,e,t):this.#X(n,e,t)}catch{}}}#X(e,t,n){if(typeof fetch!=`function`)return;let r=`${l(e)}/v1/client/agents/${encodeURIComponent(t)}/voice/prewarm`;fetch(r,{method:`POST`,headers:{Authorization:`Bearer ${n}`},keepalive:!0}).catch(()=>{})}#Z(e,t,n){let r=new URLSearchParams,i=this.config?.attachIdleMs,a=u(i);i!==void 0&&r.set(`attachIdleMs`,String(a));let o=new WebSocket(this.#te(e,t,r),[`runtype.bearer`,`runtype.attach`,n]);o.binaryType=`arraybuffer`;let s=()=>{},c={ws:o,state:`connecting`,ready:new Promise(e=>{s=e}),settle:s,openedAt:0,idleTimer:void 0};this.#m=c,o.onopen=()=>{this.#m===c&&(c.state=o.protocol===`runtype.attach`?`attached`:`live`,c.openedAt=Date.now(),this.#Q(c,a),c.state===`attached`&&o.send(`{"type":"ping"}`),c.settle())},o.onmessage=e=>{if(this.#m!==c||typeof e.data!=`string`)return;let t;try{t=JSON.parse(e.data)}catch{return}t.type===`attached`&&typeof t.idleMs==`number`&&this.#Q(c,t.idleMs-(Date.now()-c.openedAt))},o.onerror=()=>{},o.onclose=()=>{this.#m===c&&this.#$()}}#Q(e,t){clearTimeout(e.idleTimer),e.idleTimer=setTimeout(()=>{this.#m===e&&this.#$()},Math.max(0,t))}#$(){let e=this.#m;if(!e)return;this.#m=null,clearTimeout(e.idleTimer);let{ws:t}=e;if(t.onopen=null,t.onmessage=null,t.onerror=null,t.onclose=null,e.settle(),t.readyState===WebSocket.CONNECTING||t.readyState===WebSocket.OPEN)try{t.close(1e3,`prewarm released`)}catch{}}async#ee(){let e=this.#m;if(!e)return null;if(e.state===`connecting`){let t;await Promise.race([e.ready,new Promise(e=>{t=setTimeout(e,y)})]),clearTimeout(t)}return this.#m===e?e.state===`connecting`||e.ws.readyState!==WebSocket.OPEN?(this.#$(),null):(this.#m=null,clearTimeout(e.idleTimer),{ws:e.ws,live:e.state===`live`}):null}#te(e,t,n){let r=`partial_transcript,context`;this.bridge&&this.config?.clientDelegation!==!1&&(r+=`,client_delegation,delegation_update,delegation_read_back,delegation_stream`,this.bridge.clientTools?.()&&(r+=`,client_tools,prior_tool_results`)),n&&(r=`attach,${r}`);let a=new URLSearchParams({voiceProtocol:D,clientVersion:`persona/${i}`,voiceCapabilities:C,clientCapabilities:r});return n?.forEach((e,t)=>a.set(t,e)),`${c(e)}/ws/agents/${encodeURIComponent(t)}/voice?${a}`}async startListening(){if(this.#l)return;let e=this.#A;e||(this.#k=!1,this.#D=null),this.#A=!1;let n=this.config?.agentId,r=this.config?.clientToken,i=this.config?.host;if(!n)throw Error(`Runtype voice requires an agentId`);if(!r)throw Error(`Runtype voice requires a clientToken`);if(!i)throw Error(`Runtype voice requires a host (or widget apiUrl)`);let a=++this.#d;this.#f=!1,this.#l=!0;try{let o=await navigator.mediaDevices.getUserMedia({audio:{sampleRate:d,channelCount:1,echoCancellation:!0}});if(a!==this.#d){o.getTracks().forEach(e=>e.stop());return}this.#r=o;let s=new(window.AudioContext||window.webkitAudioContext)({sampleRate:d});if(this.#t=s,s.state===`suspended`){if(await Promise.race([s.resume().catch(()=>{}),new Promise(t=>setTimeout(t,e?500:v))]),a!==this.#d)return;if(s.state!==`running`)throw Error(e?this.#D=`${M} Tap the mic to reconnect.`:`Audio blocked until a tap`)}let c=this.config?.createPlaybackEngine?await this.config.createPlaybackEngine():new t(f);if(a!==this.#d){c.destroy(),o.getTracks().forEach(e=>e.stop()),s.close().catch(()=>{});return}this.#c=c,this.#he(),this.#ie(s,o,a);let l=await this.#ee();if(a!==this.#d){l?.ws.close(1e3,`client ended call`);return}if(l){let{ws:e}=l;this.#e=e,this.#ne(e,a),l.live||e.send(`{"type":"start"}`),this.#ae(e),this.#be(`listening`);return}let u=new WebSocket(this.#te(i,n),[`runtype.bearer`,r]);u.binaryType=`arraybuffer`,this.#e=u,u.onopen=()=>{a===this.#d&&(this.#ae(u),this.#be(`listening`))},this.#ne(u,a)}catch(e){throw this.#ye(),this.#xe(e),this.#be(`error`),e}}#ne(e,t){e.onmessage=e=>this.#oe(e,t),e.onerror=()=>{t!==this.#d||this.#E||(this.#xe(/* @__PURE__ */ Error(`Voice connection failed`)),this.#be(`error`),this.#ye())},e.onclose=e=>{if(this.#f){this.#f=!1;return}if(t!==this.#d)return;let n=this.#E??(e.code===4408?{reason:`idle_timeout`}:null);if(n)this.#re(n.reason,n.message);else{if(e.code!==1e3){let t=e.code?` (code ${e.code})`:``;this.#xe(/* @__PURE__ */ Error(`Voice connection closed${t}`)),this.#be(`error`)}else this.#be(`idle`);this.#ye()}}}#re(e,t){let n=j.includes(e)&&!this.#k;if(this.#ye(),n)this.#k=!0,this.#l=!0,this.#D=e===`provider_error`?`${M} Reconnecting…`:`Reconnecting…`,this.#O=setTimeout(()=>{this.#l=!1,this.#A=!0,this.startListening().catch(()=>{})},1e3+Math.random()*1e3),this.#be(`idle`);else{if(j.includes(e))return this.#D=M,this.#xe(/* @__PURE__ */ Error(M)),this.#be(`error`);if(e===`error`)return this.#be(`error`);this.#D=e===`quota`&&t||A.get(e)||null,this.#be(`idle`)}}takeNotice(){let e=this.#D;return this.#D=null,e}getDisclosure(){let e=this.config?.disclosureText;return this.#l&&this.#h&&e!==!1?e||k:null}async stopListening(){this.#ye(),this.#be(`idle`)}async disconnect(){this.#ye(),this.#be(`disconnected`),this.#G=[],this.#K=[],this.#q=[],this.#J=[],this.#Y=[]}stopPlayback(){this.#ve();let e=this.#e;e&&e.readyState===WebSocket.OPEN&&(this.#h&&(this.#_=Date.now()+T,e.send(`{"type":"cancel"}`)),this.#be(`listening`))}getInterruptionMode(){return`barge-in`}isBargeInActive(){return this.#l}onLevel(e){this.#n.push(e)}async deactivateBargeIn(){this.#ye(),this.#be(`idle`)}#ie(e,t,n){let r=e.createMediaStreamSource(t);this.#i=r;let i=e.createScriptProcessor(p,1,1);this.#a=i,i.onaudioprocess=e=>{if(n!==this.#d)return;let t=this.#e,r=t?.readyState===WebSocket.OPEN;if(t&&!r&&t.readyState!==WebSocket.CONNECTING)return;let i=e.inputBuffer.getChannelData(0),a=new Int16Array(i.length),o=0;for(let e=0;e<i.length;e++){let t=Math.max(-1,Math.min(1,i[e]));o+=t*t,a[e]=t<0?t*32768:t*32767}if(t&&r)this.#ae(t),t.send(a.buffer);else for(this.#o.push(a.buffer),this.#s+=a.byteLength;this.#s>m;)this.#s-=this.#o.shift().byteLength;if(this.#n.length>0){let e=Math.sqrt(o/i.length),t=Math.max(0,Math.min(1,e*h));for(let e of this.#n)e(t)}},r.connect(i),i.connect(e.destination)}#ae(e){for(let t of this.#o)e.send(t);this.#o=[],this.#s=0}#oe(e,t){if(t!==this.#d)return;if(e.data instanceof ArrayBuffer){this.#pe(e.data,t);return}let n;try{n=JSON.parse(e.data)}catch{return}switch(n.type){case`session_config`:n.speechMode&&(this.#h=n.speechMode===`speech_to_speech`,this.#c?.setContinuousMode?.(this.#h)),Array.isArray(n.capabilities)&&(this.#S=new Set(n.capabilities)),typeof n.callId==`string`&&(this.#T=n.callId),this.#x=this.#h&&this.#S.has(`client_delegation`)&&!!this.bridge,this.#h&&!this.#u&&this.#be(`listening`),this.#S.has(`context`)&&!this.#j&&(this.#j=!0,this.#M=this.#se()),this.#x&&this.#S.has(`client_tools`)&&!this.#V&&(this.#V=this.bridge.clientTools?.()?.open({send:e=>{let n=this.#e;return t!==this.#d||n?.readyState!==WebSocket.OPEN?!1:(n.send(JSON.stringify(e)),!0)},cancelled:e=>this.#w.has(e)}).catch(()=>null)??null);break;case`client_tool_call`:{let e=String(n.delegationId);this.#V&&!this.#W.has(e)&&(this.#W.set(e,this.#U),this.#F.add(e)),this.#V?.then(e=>e?.call(n));break}case`transcript_update`:{let e=n.role===`assistant`?`assistant`:`user`,r=n.utteranceId??n.turnId;if(!r||e===`assistant`&&this.#me())break;let i=String(r);if(e===`user`)n.final===!0&&(this.#ce(t),this.#U={id:i,text:String(n.text??``)}),this.#R=!1;else{if(this.#S.has(`delegation_read_back`)){let e=n.delegationId;(typeof e==`string`&&this.#F.has(e)&&!this.#z.has(i)||this.#R&&!this.#z.has(i))&&(this.#B.add(i),this.#R=!1)}else this.#R&&!this.#z.has(i)&&(this.#B.add(i),this.#R=!1);if(this.#z.add(i),this.#B.has(i))break}this.#Se(e,n.text??``,n.final===!0,{turnId:i,...typeof n.startMs==`number`&&{startMs:n.startMs},...typeof n.endMs==`number`&&{endMs:n.endMs},...this.#x&&{caption:!0}});break}case`delegation_started`:case`delegation_completed`:{let e=String(n.delegationId??n.turnId);if(n.type===`delegation_started`){this.#ce(t),this.#H.add(e),this.#F.delete(e),this.#W.delete(e)&&this.#V?.then(t=>t?.abort(e));let r=n.input;this.#x&&r&&this.#fe(e,{delegationId:e,userText:String(r.text??``),userUtteranceIds:Array.isArray(r.userUtteranceIds)?r.userUtteranceIds.filter(e=>typeof e==`string`):[],messages:Array.isArray(r.messages)?r.messages:[],priorToolResults:r.priorToolResults},t)}else if(n.route===`direct`&&this.#V&&!this.#H.has(e)){let t=this.#W.get(e)??this.#U;this.#W.delete(e),this.#H.add(e),this.#F.add(e),this.bridge?.recordDirectTurn?.({delegationId:e,userText:t?.text??``,userUtteranceIds:t?[t.id]:[],assistantText:typeof n.text==`string`?n.text:``})}n.type===`delegation_completed`&&n.speak!==!1&&this.#F.has(e)&&!this.#I.delete(e)&&!this.#S.has(`delegation_read_back`)&&this.#ue(e),this.#g=n.type===`delegation_started`,!this.#u&&!this.#me()&&this.#be(this.#g?`processing`:`listening`);break}case`delegation_progress`:{let e=String(n.delegationId);this.#F.has(e)&&!this.#I.has(e)&&!this.#w.has(e)&&(this.#I.add(e),this.#ue(e));break}case`delegation_cancelled`:this.#de(String(n.delegationId),n.reason!==`session_ending`&&n.reason!==`provider_cancelled`);break;case`warning`:console.warn(`[Persona voice] ${n.code}: ${n.message??``}`,this.#T??``),n.delegationId&&(n.code===`UNKNOWN_DELEGATION`||n.code===`LATE_RESULT_LIMIT`)&&this.#de(String(n.delegationId));break;case`audio_clear`:this.#ve(),this.#_=0,this.#be(`listening`);break;case`transcript_interim`:this.#be(`listening`),this.#Se(`user`,n.text??``,!1);break;case`transcript_final`:{let e=n.role===`assistant`?`assistant`:`user`;this.#be(e===`user`?`processing`:`speaking`),this.#Se(e,n.text??``,!0);break}case`audio_end`:this.#c?this.#c.markStreamEnd():(this.#u=!1,this.#be(`listening`));break;case`metrics`:this.#Ce({llmMs:n.llm_ms,ttsMs:n.tts_ms,firstAudioMs:n.first_audio_ms,totalMs:n.total_ms});break;case`error`:this.#xe(Error(n.error||`Voice error`)),this.#be(`error`);break;case`session_end`:this.#E={reason:String(n.reason),...typeof n.message==`string`&&{message:n.message}}}}async#se(){let e=this.bridge?.getHistory()??[],t=``;try{let e=this.config?.callContext;t=String((typeof e==`function`?await e():e)??``)}catch{}return o(e,t)}#ce(e){let t=this.#M;if(!t)return;this.#M=null;let n=!1,r=t.then(t=>{let r=this.#e;!n&&t&&e===this.#d&&r?.readyState===WebSocket.OPEN&&r.send(JSON.stringify({type:`context`,text:t}))});this.#N={done:r,drop:()=>n=!0}}async#le(){let e=this.#N;if(!e)return;let t,n=await Promise.race([e.done.then(()=>!1),new Promise(e=>{t=setTimeout(()=>e(!0),E)})]);clearTimeout(t),n&&e.drop()}#ue(e){this.#R=!0,this.#L=e}#de(e,t=!1){this.#w.add(e),this.#L===e&&(this.#R=!1),this.#I.delete(e),this.#H.has(e)||this.#F.delete(e),this.#V?.then(t=>t?.abort(e)),this.bridge?.dropDelegation?.(e,t),this.#C.get(e)?.abort()}#fe(e,t,n){let r=this.bridge,i=({type:t,...r})=>{let i=this.#e;return n!==this.#d||i?.readyState!==WebSocket.OPEN||this.#w.has(e)?!1:(i.send(JSON.stringify({type:t,delegationId:e,...r})),!0)},a=(e,t,n,r=0)=>i({type:e,status:t,text:n,...r>0&&{streamedChars:r}});this.#P=this.#P.then(async()=>{if(n!==this.#d||this.#w.has(e))return;let o=null,s=this.#S.has(`delegation_stream`)&&this.#S.has(`delegation_read_back`),c=t=>{o=(o??this.#le()).then(()=>{i({type:`delegation_delta`,text:t})&&this.#F.add(e)})},l=await r.runDelegatedTurn(s?{...t,stream:c}:t).catch(()=>({status:`failed`,text:``}));await this.#le(),await o;let u=s?l.streamedChars??0:0,d=!!l.followUp,f=d&&this.#S.has(`delegation_update`);if(!a(f?`delegation_update`:`delegation_result`,d&&!f?`completed`:l.status,l.text,u)||(l.status!==`failed`&&l.inChat!==!1&&this.#F.add(e),!l.followUp))return;let p=new AbortController;this.#C.set(e,p),l.followUp({signal:p.signal,approvalTimeoutMs:this.config?.approvalTimeoutMs&&Math.min(this.config.approvalTimeoutMs,O),readBack:f,onUpdate:e=>a(`delegation_update`,`pending_approval`,e)}).then(t=>{this.#C.delete(e),f&&t&&!p.signal.aborted&&a(`delegation_result`,t.status,t.text)})})}#pe(e,t){if(t!==this.#d||!this.#c||this.#me())return;let n=s(e);n.length!==0&&(this.#u||(this.#u=!0,this.#be(`speaking`)),this.#he(),this.#c.enqueue(n),this.#h&&this.#ge(n.length))}#me(){return Date.now()<this.#_}#he(){if(this.#b||!this.#c)return;this.#b=!0;let e=this.#d;this.#c.onFinished(()=>{e===this.#d&&(this.#b=!1,this.#_e())})}#ge(e){let t=Date.now();this.#v=Math.max(t,this.#v)+e/48,clearTimeout(this.#y),this.#y=setTimeout(()=>this.#_e(),this.#v-t+w)}#_e(){this.#u=!1,this.#v=0,this.#e&&this.#e.readyState===WebSocket.OPEN&&this.#be(this.#g?`processing`:`listening`)}#ve(){this.#c?.flush(),this.#b=!1,this.#he(),this.#u=!1,this.#v=0,clearTimeout(this.#y)}#ye(){this.#d+=1,this.#l=!1,this.#u=!1,this.#$(),this.#h=!1,this.#g=!1,this.#x=!1,this.#S=/* @__PURE__ */ new Set;for(let e of this.#C.values())e.abort();if(this.#C.clear(),this.#w.clear(),this.#T=void 0,this.#E=null,clearTimeout(this.#O),this.#j=!1,this.#M=null,this.#N=null,this.#P=Promise.resolve(),this.#F.clear(),this.#I.clear(),this.#L=null,this.#R=!1,this.#z.clear(),this.#B.clear(),this.#V?.then(e=>e?.close()),this.#V=null,this.#H.clear(),this.#W.clear(),this.#U=null,this.#b=!1,this.#_=0,this.#v=0,clearTimeout(this.#y),this.#o=[],this.#s=0,this.#a&&=(this.#a.onaudioprocess=null,this.#a.disconnect(),null),this.#i&&=(this.#i.disconnect(),null),this.#r&&=(this.#r.getTracks().forEach(e=>e.stop()),null),this.#t&&=(this.#t.close().catch(()=>{}),null),this.#c&&=(this.#c.destroy(),null),this.#e){this.#f=!0;try{this.#e.close(1e3,`client ended call`)}catch{}this.#e=null}}onResult(e){this.#G.push(e)}onError(e){this.#K.push(e)}onStatusChange(e){this.#q.push(e)}onTranscript(e){this.#J.push(e)}onMetrics(e){this.#Y.push(e)}#be(e){this.#q.forEach(t=>t(e))}#xe(e){this.#K.forEach(t=>t(e))}#Se(e,t,n,r){this.#J.forEach(i=>i(e,t,n,r))}#Ce(e){this.#Y.forEach(t=>t(e))}}})),L,te=e((()=>{L=class{#e;#t;#n;#r;#i;#a;constructor(e={}){this.config=e,this.type=`browser`,this.#e=null,this.#t=[],this.#n=[],this.#r=[],this.#i=!1,this.#a=typeof window<`u`?window:void 0}async connect(){this.#r.forEach(e=>e(`connected`))}async startListening(){try{if(this.#i)throw Error(`Already listening`);if(!this.#a)throw Error(`Window object not available`);let e=this.#a.SpeechRecognition||this.#a.webkitSpeechRecognition;if(!e)throw Error(`Browser speech recognition not supported`);this.#e=new e,this.#e.lang=this.config?.language||`en-US`,this.#e.continuous=this.config?.continuous||!1,this.#e.interimResults=!0,this.#e.onresult=e=>{let t=Array.from(e.results).map(e=>e[0]).map(e=>e.transcript).join(``),n=e.results[e.results.length-1].isFinal;this.#t.forEach(e=>e({text:t,confidence:n?.8:.5,provider:`browser`})),n&&!this.config?.continuous&&this.stopListening()},this.#e.onerror=e=>{this.#n.forEach(t=>t(Error(e.error))),this.#r.forEach(e=>e(`error`))},this.#e.onstart=()=>{this.#i=!0,this.#r.forEach(e=>e(`listening`))},this.#e.onend=()=>{this.#i=!1,this.#r.forEach(e=>e(`idle`))},this.#e.start()}catch(e){throw this.#n.forEach(t=>t(e)),this.#r.forEach(e=>e(`error`)),e}}async stopListening(){this.#e&&=(this.#e.stop(),null),this.#i=!1,this.#r.forEach(e=>e(`idle`))}onResult(e){this.#t.push(e)}onError(e){this.#n.push(e)}onStatusChange(e){this.#r.push(e)}async disconnect(){await this.stopListening(),this.#r.forEach(e=>e(`disconnected`))}static isSupported(){return`SpeechRecognition`in window||`webkitSpeechRecognition`in window}}}));function R(e){switch(e.type){case`runtype`:if(!e.runtype)throw Error(`Runtype voice provider requires configuration`);return new I(e.runtype);case`browser`:if(!L.isSupported())throw Error(`Browser speech recognition not supported`);return new L(e.browser||{});case`custom`:{let t=e.custom;if(!t)throw Error("Custom voice provider requires a `custom` provider instance or factory");let n=typeof t==`function`?t():t;if(!n||typeof n.startListening!=`function`)throw Error("Custom voice provider `custom` must be a VoiceProvider (or a factory returning one)");return n}default:throw Error(`Unknown voice provider type: ${e.type}`)}}function ne(e){if(e?.type===`custom`&&e.custom)return R({type:`custom`,custom:e.custom});if(e?.type===`runtype`&&e.runtype)return R({type:`runtype`,runtype:e.runtype});if(L.isSupported())return R({type:`browser`,browser:e?.browser||{language:`en-US`}});throw Error(`No supported voice providers available`)}function re(e){try{return ne(e),!0}catch{return!1}}var ie=e((()=>{ee(),te()})),z,ae,oe=e((()=>{z=e=>e.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,``),ae=class{constructor(e){this.host=e,this.turns=/* @__PURE__ */ new Map,this.latestId=null,this.cancelled=/* @__PURE__ */ new Set}apply(e,t,n,r,i,a){let o=this.host;t=t.trim();let s=this.turns.get(r);if(s||(s={},this.turns.set(r,s),this.latestId=r),e===`user`){s.userFinal=n;let e=s.userId?o.find(s.userId):void 0;if(e){let r=s.userStartMs===void 0&&i!==void 0;r&&(s.userStartMs=i),o.upsert({...e,content:t,voiceProcessing:!n,...r&&this.placeBefore(this.startedAfter(i))})}else{s.userStartMs=i;let e=s.assistantId?o.find(s.assistantId):void 0;s.userId=o.inject({role:`user`,content:t,streaming:!1,voiceProcessing:!n,voiceCaption:a,...this.placeBefore(this.startedAfter(i)??e)}).id}}else if(!this.cancelled.has(r)){s.assistantFinal=n;let e=s.assistantId?o.find(s.assistantId):void 0;if(e){let r=s.assistantStartMs===void 0&&i!==void 0;r&&(s.assistantStartMs=i),o.upsert({...e,content:t,streaming:!n,voiceProcessing:!n,...r&&this.placeBefore(this.startedAfter(i))})}else t&&(s.assistantStartMs=i,s.assistantId=o.inject({role:`assistant`,content:t,streaming:!n,voiceProcessing:!n,voiceCaption:a,...this.placeBefore(this.startedAfter(i))}).id);n&&s.assistantId&&o.markSpoken(s.assistantId)}this.sync()}claimUserTurn(e,t=[]){let n=t[t.length-1];for(let e of t)e!==n&&(this.turns.has(e)||this.turns.set(e,{}),this.turns.get(e).claimed=!0);let r;if(n){if(r=this.turns.get(n),r||(r={},this.turns.set(n,r)),r.claimed)return null;(!r.userId||!this.host.find(r.userId))&&(r.userFinal=!0,r.userId=this.host.inject({role:`user`,content:e.trim()}).id)}else{let t=z(e),n=[...this.turns.values()].reverse().flatMap(e=>{let t=e.userId&&!e.claimed?this.host.find(e.userId):void 0;return t?[{turn:e,text:z(t.content)}]:[]}).filter(({text:e})=>e&&t);r=(n.find(({text:e})=>e===t)??n.find(({text:e})=>e.startsWith(t)||t.startsWith(e)))?.turn}return r?(r.claimed=!0,r.userId):null}cancel(){let e=this.inFlight();if(e.length===0){let t=this.awaiting();if(!t)return;e=[t]}for(let t of e)this.cancelled.add(t);this.closeReplies(e),this.sync()}fail(e){let t=this.awaiting(),n=this.inFlight();if(!t&&n.length===0)return;for(let e of n)this.turns.get(e).assistantFinal=!0;this.closeReplies(n);let r=this.host.inject({role:`assistant`,content:e,streaming:!1,voiceProcessing:!1}),i=t?this.turns.get(t):void 0;i&&(i.assistantId=r.id,i.assistantFinal=!0),this.sync()}settle(){if(this.turns.size===0)return;let e=this.pending(),t=/* @__PURE__ */ new Set;for(let e of this.turns.values())e.userId&&t.add(e.userId),e.assistantId&&(t.add(e.assistantId),this.host.markSpoken(e.assistantId));this.turns.clear(),this.latestId=null,this.host.settle(t),e&&this.host.setStreaming(!1)}startedAfter(e){if(e===void 0)return;let t;for(let n of this.turns.values())for(let[r,i]of[[n.userId,n.userStartMs],[n.assistantId,n.assistantStartMs]])r&&i!==void 0&&i>e&&(!t||i<t.start)&&(t={start:i,id:r});return t&&this.host.find(t.id)}placeBefore(e){if(!e)return;let t=e.sequence??0,n=t-1;for(let r of this.turns.values())for(let i of[r.userId,r.assistantId]){let r=i?this.host.find(i):void 0,a=r?.sequence;r?.createdAt===e.createdAt&&a!==void 0&&a>n&&a<t&&(n=a)}return{createdAt:e.createdAt,sequence:(n+t)/2}}closeReplies(e){let t=/* @__PURE__ */ new Set;for(let n of e){let e=this.turns.get(n)?.assistantId;e&&(t.add(e),this.host.markSpoken(e))}t.size>0&&this.host.settle(t)}inFlight(){let e=[];for(let[t,n]of this.turns)n.assistantId&&!n.assistantFinal&&!this.cancelled.has(t)&&e.push(t);return e}awaiting(){let e=this.latestId;if(!e)return null;let t=this.turns.get(e);return t?.userFinal&&!t.assistantId&&!t.claimed&&!this.cancelled.has(e)?e:null}pending(){return this.awaiting()!==null||this.inFlight().length>0}sync(){this.host.setStreaming(this.pending())}}}));function se(e){let t=/(\S+)$/.exec(e)?.[1];if(!t)return!1;let n=t.replace(/^[("'“‘[*_]+/,``).toLowerCase();if(W.has(n)||/^[a-z](?:\.[a-z])*$/.test(n))return!0;if(/^\d+$/.test(t)){let n=e.length-t.length;return n===0||/\n\s*$/.test(e.slice(0,n))}return!1}function*ce(e,t){let n=new RegExp(G.source,`g`);for(let r=n.exec(e);r;r=n.exec(e)){let n=r[1];if(!e.slice(0,r.index+(n?.length??0)).trim()||n!==void 0&&(/^[,;:]$/.test(n)&&!t||n===`.`&&se(e.slice(0,r.index))))continue;let i=r.index+r[0].length;i<e.length&&(yield i)}}function B(e,t){let n=e.slice(0,t),r=0;for(let e of n.matchAll(/\s+/g))n.slice(0,e.index).trim()&&(r=e.index+e[0].length);return r}function V(e){let t=0;for(let n of ce(e.slice(0,220),!0))t=n;if(t)return t;let n=B(e,220);if(n)return n;let r=e.charCodeAt(219);return r>=55296&&r<=56319?219:220}var H,U,W,G,K,le=e((()=>{H=30,U=6,W=/* @__PURE__ */ new Set(/* @__PURE__ */ `mr,mrs,ms,dr,prof,sr,jr,st,mt,vs,etc,approx,inc,ltd,co,corp,no,nos,fig,ft,dept,est,min,max,e.g,i.e,a.m,p.m,u.s,u.k`.split(`,`)),G=/([.!?]+|[,;:])(["'”’)\]*_]*)(\s+)|\n\s*/g,K=class{#e=``;#t=!0;push(e){return this.#e+=e,this.#n()}flush(){let e=this.#n(),t=this.#e;if(this.#e=``,t.trim()){for(let n=0;n<t.length;){let r=t.slice(n),i=r.length>220?V(r):r.length;e.push(r.slice(0,i)),n+=i}this.#t=!1}return e}idle(){let e=this.#e;if(!e.trim()||!/(?:[.!?…]["'”’)\]*_]*|\n)\s*$/.test(e))return[];this.#e=``,this.#t=!1;let t=[];for(let n=0;n<e.length;){let r=e.slice(n),i=r.length>220?V(r):r.length;t.push(r.slice(0,i)),n+=i}return t}#n(){let e=[];for(let t=this.#r();t>0;t=this.#r())e.push(this.#e.slice(0,t)),this.#e=this.#e.slice(t),this.#t=!1;return e}#r(){let e=this.#e;if(!e.trim())return 0;let t=ce(e,this.#t).next().value??0;if(t&&t<=220)return t;let n=/[.!?]["'”’)\]*_]*$/.test(e);if(this.#t&&!n){let t=e.match(/\S+\s+/g)?.length??0;if(e.trim().length>=H||t>=U){let t=B(e,220);if(t)return t}}return e.length>220?V(e):0}}}));function q(e,t=0){if(e==null||e===``)return``;if(typeof e!=`object`)return String(e);if(t>2)return``;if(Array.isArray(e))return e.map(e=>q(e,t+1)).filter(Boolean).join(`, `);let n=e,r=n.quantity??n.qty??n.count,i=n.name??n.item??n.product??n.title;return r!=null&&i!=null&&typeof i!=`object`?`${r} ${i}`:Object.entries(n).filter(([e])=>!e.startsWith(`_`)).map(([e,n])=>{let r=q(n,t+1);return r&&(t?`${Q(e)} ${r}`:`${Q(e)}: ${r}`)}).filter(Boolean).join(t?`, `:`; `)}function ue(e){let t=e.length>1?`These actions need the user's approval in the chat before they happen:`:`This action needs the user's approval in the chat before it happens:`,n=ge-t.length-119-2;return`${t}\n${e.map(t=>{let r=[Q(t.toolName)];t.description&&r.push(`(${Z(t.description.trim(),160)})`);let i=q(t.parameters);return i&&r.push(`with ${i}`),t.reason&&r.push(`because: ${Z(t.reason.trim(),160)}`),Z(`- ${r.join(` `)}`,Math.floor(n/e.length)-1)}).join(`
@@ -1,5 +1,5 @@
1
- import { Hi as SpeechCallbacks, Ui as SpeechEngine, Wi as SpeechRequest, bi as PcmStreamPlayer, ca as VoicePlaybackEngine } from "./types-CSXHl5cN.cjs";
2
- import { n as FallbackSpeechEngineOptions, t as FallbackSpeechEngine } from "./fallback-speech-engine-DZ6Of7VU.cjs";
1
+ import { Gi as SpeechRequest, Ui as SpeechCallbacks, Wi as SpeechEngine, la as VoicePlaybackEngine, xi as PcmStreamPlayer } from "./types-BOZHQIk0.cjs";
2
+ import { n as FallbackSpeechEngineOptions, t as FallbackSpeechEngine } from "./fallback-speech-engine-DmF7MczI.cjs";
3
3
  //#region src/voice/worklet-playback-engine.d.ts
4
4
  interface PcmStreamPlayerOptions {
5
5
  /**
@@ -1,5 +1,5 @@
1
- import { Hi as SpeechCallbacks, Ui as SpeechEngine, Wi as SpeechRequest, bi as PcmStreamPlayer, ca as VoicePlaybackEngine } from "./types-CSXHl5cN.js";
2
- import { n as FallbackSpeechEngineOptions, t as FallbackSpeechEngine } from "./fallback-speech-engine-DZ6Of7VU.js";
1
+ import { Gi as SpeechRequest, Ui as SpeechCallbacks, Wi as SpeechEngine, la as VoicePlaybackEngine, xi as PcmStreamPlayer } from "./types-BOZHQIk0.js";
2
+ import { n as FallbackSpeechEngineOptions, t as FallbackSpeechEngine } from "./fallback-speech-engine-DmF7MczI.js";
3
3
  //#region src/voice/worklet-playback-engine.d.ts
4
4
  interface PcmStreamPlayerOptions {
5
5
  /**
@@ -1,4 +1,4 @@
1
- import { Dn as AgentWidgetWebMcpConfig, Yi as VoiceClientToolOutcome, Zn as ClientToolDefinition, _a as WebMcpToolResult, ha as WebMcpConfirmHandler } from "./types-CSXHl5cN.cjs";
1
+ import { On as AgentWidgetWebMcpConfig, Qn as ClientToolDefinition, Xi as VoiceClientToolOutcome, ga as WebMcpConfirmHandler, va as WebMcpToolResult } from "./types-BOZHQIk0.cjs";
2
2
  //#region src/webmcp-bridge.d.ts
3
3
  /** Server-applied wire prefix; strip when looking up registry entries. */
4
4
  declare const WEBMCP_TOOL_PREFIX = "webmcp:";
@@ -1,4 +1,4 @@
1
- import { Dn as AgentWidgetWebMcpConfig, Yi as VoiceClientToolOutcome, Zn as ClientToolDefinition, _a as WebMcpToolResult, ha as WebMcpConfirmHandler } from "./types-CSXHl5cN.js";
1
+ import { On as AgentWidgetWebMcpConfig, Qn as ClientToolDefinition, Xi as VoiceClientToolOutcome, ga as WebMcpConfirmHandler, va as WebMcpToolResult } from "./types-BOZHQIk0.js";
2
2
  //#region src/webmcp-bridge.d.ts
3
3
  /** Server-applied wire prefix; strip when looking up registry entries. */
4
4
  declare const WEBMCP_TOOL_PREFIX = "webmcp:";
@@ -1,3 +1,3 @@
1
- import { n as WebMcpBridgeDeps, t as WebMcpBridge } from "./webmcp-runtime-entry-DpDN6k-6.cjs";
1
+ import { n as WebMcpBridgeDeps, t as WebMcpBridge } from "./webmcp-runtime-entry-DuAG1_yF.cjs";
2
2
  export { WebMcpBridge, type WebMcpBridgeDeps };
3
3
  export {}
@@ -1,3 +1,3 @@
1
- import { n as WebMcpBridgeDeps, t as WebMcpBridge } from "./webmcp-runtime-entry-DpDN6k-6.js";
1
+ import { n as WebMcpBridgeDeps, t as WebMcpBridge } from "./webmcp-runtime-entry-DuAG1_yF.js";
2
2
  export { WebMcpBridge, type WebMcpBridgeDeps };
3
3
  export {}