@elizaos/app-core 2.0.0-alpha.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +2 -0
- package/LICENSE +21 -0
- package/dist/App.d.ts +5 -0
- package/dist/App.d.ts.map +1 -0
- package/dist/App.js +198 -0
- package/dist/actions/character.d.ts +27 -0
- package/dist/actions/character.d.ts.map +1 -0
- package/dist/actions/character.js +97 -0
- package/dist/actions/chat-helpers.d.ts +47 -0
- package/dist/actions/chat-helpers.d.ts.map +1 -0
- package/dist/actions/chat-helpers.js +79 -0
- package/dist/actions/cloud.d.ts +17 -0
- package/dist/actions/cloud.d.ts.map +1 -0
- package/dist/actions/cloud.js +43 -0
- package/dist/actions/index.d.ts +12 -0
- package/dist/actions/index.d.ts.map +1 -0
- package/dist/actions/index.js +11 -0
- package/dist/actions/lifecycle.d.ts +43 -0
- package/dist/actions/lifecycle.d.ts.map +1 -0
- package/dist/actions/lifecycle.js +118 -0
- package/dist/actions/onboarding.d.ts +12 -0
- package/dist/actions/onboarding.d.ts.map +1 -0
- package/dist/actions/onboarding.js +28 -0
- package/dist/actions/triggers.d.ts +23 -0
- package/dist/actions/triggers.d.ts.map +1 -0
- package/dist/actions/triggers.js +148 -0
- package/dist/api/client.d.ts +2823 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +2392 -0
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +1 -0
- package/dist/autonomy/index.d.ts +48 -0
- package/dist/autonomy/index.d.ts.map +1 -0
- package/dist/autonomy/index.js +330 -0
- package/dist/bridge/capacitor-bridge.d.ts +153 -0
- package/dist/bridge/capacitor-bridge.d.ts.map +1 -0
- package/dist/bridge/capacitor-bridge.js +193 -0
- package/dist/bridge/electrobun-rpc.d.ts +19 -0
- package/dist/bridge/electrobun-rpc.d.ts.map +1 -0
- package/dist/bridge/electrobun-rpc.js +27 -0
- package/dist/bridge/electrobun-runtime.d.ts +3 -0
- package/dist/bridge/electrobun-runtime.d.ts.map +1 -0
- package/dist/bridge/electrobun-runtime.js +17 -0
- package/dist/bridge/index.d.ts +6 -0
- package/dist/bridge/index.d.ts.map +1 -0
- package/dist/bridge/index.js +5 -0
- package/dist/bridge/native-plugins.d.ts +82 -0
- package/dist/bridge/native-plugins.d.ts.map +1 -0
- package/dist/bridge/native-plugins.js +39 -0
- package/dist/bridge/plugin-bridge.d.ts +116 -0
- package/dist/bridge/plugin-bridge.d.ts.map +1 -0
- package/dist/bridge/plugin-bridge.js +203 -0
- package/dist/bridge/storage-bridge.d.ts +39 -0
- package/dist/bridge/storage-bridge.d.ts.map +1 -0
- package/dist/bridge/storage-bridge.js +135 -0
- package/dist/chat/index.d.ts +57 -0
- package/dist/chat/index.d.ts.map +1 -0
- package/dist/chat/index.js +161 -0
- package/dist/coding/index.d.ts +25 -0
- package/dist/coding/index.d.ts.map +1 -0
- package/dist/coding/index.js +25 -0
- package/dist/components/AdvancedPageView.d.ts +17 -0
- package/dist/components/AdvancedPageView.d.ts.map +1 -0
- package/dist/components/AdvancedPageView.js +137 -0
- package/dist/components/AgentActivityBox.d.ts +7 -0
- package/dist/components/AgentActivityBox.d.ts.map +1 -0
- package/dist/components/AgentActivityBox.js +25 -0
- package/dist/components/ApiKeyConfig.d.ts +26 -0
- package/dist/components/ApiKeyConfig.d.ts.map +1 -0
- package/dist/components/ApiKeyConfig.js +121 -0
- package/dist/components/AppsPageView.d.ts +7 -0
- package/dist/components/AppsPageView.d.ts.map +1 -0
- package/dist/components/AppsPageView.js +31 -0
- package/dist/components/AppsView.d.ts +8 -0
- package/dist/components/AppsView.d.ts.map +1 -0
- package/dist/components/AppsView.js +149 -0
- package/dist/components/AvatarLoader.d.ts +9 -0
- package/dist/components/AvatarLoader.d.ts.map +1 -0
- package/dist/components/AvatarLoader.js +45 -0
- package/dist/components/AvatarSelector.d.ts +23 -0
- package/dist/components/AvatarSelector.d.ts.map +1 -0
- package/dist/components/AvatarSelector.js +105 -0
- package/dist/components/BscTradePanel.d.ts +22 -0
- package/dist/components/BscTradePanel.d.ts.map +1 -0
- package/dist/components/BscTradePanel.js +221 -0
- package/dist/components/BugReportModal.d.ts +2 -0
- package/dist/components/BugReportModal.d.ts.map +1 -0
- package/dist/components/BugReportModal.js +218 -0
- package/dist/components/CharacterView.d.ts +8 -0
- package/dist/components/CharacterView.d.ts.map +1 -0
- package/dist/components/CharacterView.js +703 -0
- package/dist/components/ChatAvatar.d.ts +8 -0
- package/dist/components/ChatAvatar.d.ts.map +1 -0
- package/dist/components/ChatAvatar.js +89 -0
- package/dist/components/ChatComposer.d.ts +37 -0
- package/dist/components/ChatComposer.d.ts.map +1 -0
- package/dist/components/ChatComposer.js +136 -0
- package/dist/components/ChatMessage.d.ts +24 -0
- package/dist/components/ChatMessage.d.ts.map +1 -0
- package/dist/components/ChatMessage.js +167 -0
- package/dist/components/ChatModalView.d.ts +10 -0
- package/dist/components/ChatModalView.d.ts.map +1 -0
- package/dist/components/ChatModalView.js +57 -0
- package/dist/components/ChatView.d.ts +14 -0
- package/dist/components/ChatView.d.ts.map +1 -0
- package/dist/components/ChatView.js +511 -0
- package/dist/components/CloudSourceControls.d.ts +13 -0
- package/dist/components/CloudSourceControls.d.ts.map +1 -0
- package/dist/components/CloudSourceControls.js +14 -0
- package/dist/components/CodingAgentSettingsSection.d.ts +2 -0
- package/dist/components/CodingAgentSettingsSection.d.ts.map +1 -0
- package/dist/components/CodingAgentSettingsSection.js +268 -0
- package/dist/components/CommandPalette.d.ts +2 -0
- package/dist/components/CommandPalette.d.ts.map +1 -0
- package/dist/components/CommandPalette.js +181 -0
- package/dist/components/CompanionSceneHost.d.ts +15 -0
- package/dist/components/CompanionSceneHost.d.ts.map +1 -0
- package/dist/components/CompanionSceneHost.js +343 -0
- package/dist/components/CompanionShell.d.ts +17 -0
- package/dist/components/CompanionShell.d.ts.map +1 -0
- package/dist/components/CompanionShell.js +15 -0
- package/dist/components/CompanionView.d.ts +2 -0
- package/dist/components/CompanionView.d.ts.map +1 -0
- package/dist/components/CompanionView.js +22 -0
- package/dist/components/ConfigPageView.d.ts +11 -0
- package/dist/components/ConfigPageView.d.ts.map +1 -0
- package/dist/components/ConfigPageView.js +275 -0
- package/dist/components/ConfigSaveFooter.d.ts +8 -0
- package/dist/components/ConfigSaveFooter.d.ts.map +1 -0
- package/dist/components/ConfigSaveFooter.js +10 -0
- package/dist/components/ConfirmModal.d.ts +61 -0
- package/dist/components/ConfirmModal.d.ts.map +1 -0
- package/dist/components/ConfirmModal.js +164 -0
- package/dist/components/ConnectionFailedBanner.d.ts +6 -0
- package/dist/components/ConnectionFailedBanner.d.ts.map +1 -0
- package/dist/components/ConnectionFailedBanner.js +22 -0
- package/dist/components/ConnectorsPageView.d.ts +7 -0
- package/dist/components/ConnectorsPageView.d.ts.map +1 -0
- package/dist/components/ConnectorsPageView.js +8 -0
- package/dist/components/ConversationsSidebar.d.ts +9 -0
- package/dist/components/ConversationsSidebar.d.ts.map +1 -0
- package/dist/components/ConversationsSidebar.js +116 -0
- package/dist/components/CustomActionEditor.d.ts +10 -0
- package/dist/components/CustomActionEditor.d.ts.map +1 -0
- package/dist/components/CustomActionEditor.js +578 -0
- package/dist/components/CustomActionsPanel.d.ts +9 -0
- package/dist/components/CustomActionsPanel.d.ts.map +1 -0
- package/dist/components/CustomActionsPanel.js +107 -0
- package/dist/components/CustomActionsView.d.ts +2 -0
- package/dist/components/CustomActionsView.d.ts.map +1 -0
- package/dist/components/CustomActionsView.js +134 -0
- package/dist/components/DatabasePageView.d.ts +5 -0
- package/dist/components/DatabasePageView.d.ts.map +1 -0
- package/dist/components/DatabasePageView.js +28 -0
- package/dist/components/DatabaseView.d.ts +9 -0
- package/dist/components/DatabaseView.d.ts.map +1 -0
- package/dist/components/DatabaseView.js +311 -0
- package/dist/components/ElizaCloudDashboard.d.ts +2 -0
- package/dist/components/ElizaCloudDashboard.d.ts.map +1 -0
- package/dist/components/ElizaCloudDashboard.js +657 -0
- package/dist/components/EmotePicker.d.ts +2 -0
- package/dist/components/EmotePicker.d.ts.map +1 -0
- package/dist/components/EmotePicker.js +343 -0
- package/dist/components/ErrorBoundary.d.ts +22 -0
- package/dist/components/ErrorBoundary.d.ts.map +1 -0
- package/dist/components/ErrorBoundary.js +31 -0
- package/dist/components/FineTuningView.d.ts +2 -0
- package/dist/components/FineTuningView.d.ts.map +1 -0
- package/dist/components/FineTuningView.js +433 -0
- package/dist/components/GameView.d.ts +11 -0
- package/dist/components/GameView.d.ts.map +1 -0
- package/dist/components/GameView.js +295 -0
- package/dist/components/GameViewOverlay.d.ts +8 -0
- package/dist/components/GameViewOverlay.d.ts.map +1 -0
- package/dist/components/GameViewOverlay.js +70 -0
- package/dist/components/GlobalEmoteOverlay.d.ts +2 -0
- package/dist/components/GlobalEmoteOverlay.d.ts.map +1 -0
- package/dist/components/GlobalEmoteOverlay.js +112 -0
- package/dist/components/Header.d.ts +8 -0
- package/dist/components/Header.d.ts.map +1 -0
- package/dist/components/Header.js +121 -0
- package/dist/components/HeartbeatsView.d.ts +2 -0
- package/dist/components/HeartbeatsView.d.ts.map +1 -0
- package/dist/components/HeartbeatsView.js +378 -0
- package/dist/components/InventoryView.d.ts +10 -0
- package/dist/components/InventoryView.d.ts.map +1 -0
- package/dist/components/InventoryView.js +162 -0
- package/dist/components/KnowledgeView.d.ts +20 -0
- package/dist/components/KnowledgeView.d.ts.map +1 -0
- package/dist/components/KnowledgeView.js +480 -0
- package/dist/components/LanguageDropdown.d.ts +30 -0
- package/dist/components/LanguageDropdown.d.ts.map +1 -0
- package/dist/components/LanguageDropdown.js +98 -0
- package/dist/components/LifoMonitorPanel.d.ts +21 -0
- package/dist/components/LifoMonitorPanel.d.ts.map +1 -0
- package/dist/components/LifoMonitorPanel.js +24 -0
- package/dist/components/LifoSandboxView.d.ts +5 -0
- package/dist/components/LifoSandboxView.d.ts.map +1 -0
- package/dist/components/LifoSandboxView.js +333 -0
- package/dist/components/LoadingScreen.d.ts +13 -0
- package/dist/components/LoadingScreen.d.ts.map +1 -0
- package/dist/components/LoadingScreen.js +39 -0
- package/dist/components/LogsPageView.d.ts +2 -0
- package/dist/components/LogsPageView.d.ts.map +1 -0
- package/dist/components/LogsPageView.js +7 -0
- package/dist/components/LogsView.d.ts +5 -0
- package/dist/components/LogsView.d.ts.map +1 -0
- package/dist/components/LogsView.js +71 -0
- package/dist/components/MediaGalleryView.d.ts +9 -0
- package/dist/components/MediaGalleryView.d.ts.map +1 -0
- package/dist/components/MediaGalleryView.js +236 -0
- package/dist/components/MediaSettingsSection.d.ts +11 -0
- package/dist/components/MediaSettingsSection.d.ts.map +1 -0
- package/dist/components/MediaSettingsSection.js +329 -0
- package/dist/components/MessageContent.d.ts +51 -0
- package/dist/components/MessageContent.d.ts.map +1 -0
- package/dist/components/MessageContent.js +553 -0
- package/dist/components/OnboardingWizard.d.ts +2 -0
- package/dist/components/OnboardingWizard.d.ts.map +1 -0
- package/dist/components/OnboardingWizard.js +59 -0
- package/dist/components/PairingView.d.ts +5 -0
- package/dist/components/PairingView.d.ts.map +1 -0
- package/dist/components/PairingView.js +28 -0
- package/dist/components/PermissionsSection.d.ts +20 -0
- package/dist/components/PermissionsSection.d.ts.map +1 -0
- package/dist/components/PermissionsSection.js +368 -0
- package/dist/components/PluginsPageView.d.ts +5 -0
- package/dist/components/PluginsPageView.d.ts.map +1 -0
- package/dist/components/PluginsPageView.js +8 -0
- package/dist/components/PluginsView.d.ts +21 -0
- package/dist/components/PluginsView.d.ts.map +1 -0
- package/dist/components/PluginsView.js +1531 -0
- package/dist/components/ProviderSwitcher.d.ts +42 -0
- package/dist/components/ProviderSwitcher.d.ts.map +1 -0
- package/dist/components/ProviderSwitcher.js +480 -0
- package/dist/components/RestartBanner.d.ts +2 -0
- package/dist/components/RestartBanner.d.ts.map +1 -0
- package/dist/components/RestartBanner.js +36 -0
- package/dist/components/RuntimeView.d.ts +10 -0
- package/dist/components/RuntimeView.d.ts.map +1 -0
- package/dist/components/RuntimeView.js +165 -0
- package/dist/components/SaveCommandModal.d.ts +12 -0
- package/dist/components/SaveCommandModal.d.ts.map +1 -0
- package/dist/components/SaveCommandModal.js +84 -0
- package/dist/components/SecretsView.d.ts +9 -0
- package/dist/components/SecretsView.d.ts.map +1 -0
- package/dist/components/SecretsView.js +249 -0
- package/dist/components/SettingsView.d.ts +9 -0
- package/dist/components/SettingsView.d.ts.map +1 -0
- package/dist/components/SettingsView.js +230 -0
- package/dist/components/ShellOverlays.d.ts +8 -0
- package/dist/components/ShellOverlays.d.ts.map +1 -0
- package/dist/components/ShellOverlays.js +10 -0
- package/dist/components/ShortcutsOverlay.d.ts +2 -0
- package/dist/components/ShortcutsOverlay.d.ts.map +1 -0
- package/dist/components/ShortcutsOverlay.js +79 -0
- package/dist/components/SkillsView.d.ts +11 -0
- package/dist/components/SkillsView.d.ts.map +1 -0
- package/dist/components/SkillsView.js +358 -0
- package/dist/components/StartupFailureView.d.ts +8 -0
- package/dist/components/StartupFailureView.d.ts.map +1 -0
- package/dist/components/StartupFailureView.js +15 -0
- package/dist/components/StreamView.d.ts +16 -0
- package/dist/components/StreamView.d.ts.map +1 -0
- package/dist/components/StreamView.js +300 -0
- package/dist/components/StripeEmbeddedCheckout.d.ts +24 -0
- package/dist/components/StripeEmbeddedCheckout.d.ts.map +1 -0
- package/dist/components/StripeEmbeddedCheckout.js +101 -0
- package/dist/components/SubscriptionStatus.d.ts +22 -0
- package/dist/components/SubscriptionStatus.d.ts.map +1 -0
- package/dist/components/SubscriptionStatus.js +301 -0
- package/dist/components/SystemWarningBanner.d.ts +6 -0
- package/dist/components/SystemWarningBanner.d.ts.map +1 -0
- package/dist/components/SystemWarningBanner.js +46 -0
- package/dist/components/ThemeToggle.d.ts +21 -0
- package/dist/components/ThemeToggle.d.ts.map +1 -0
- package/dist/components/ThemeToggle.js +24 -0
- package/dist/components/TrajectoriesView.d.ts +12 -0
- package/dist/components/TrajectoriesView.d.ts.map +1 -0
- package/dist/components/TrajectoriesView.js +183 -0
- package/dist/components/TrajectoryDetailView.d.ts +13 -0
- package/dist/components/TrajectoryDetailView.d.ts.map +1 -0
- package/dist/components/TrajectoryDetailView.js +112 -0
- package/dist/components/TriggersView.d.ts +2 -0
- package/dist/components/TriggersView.d.ts.map +1 -0
- package/dist/components/TriggersView.js +1 -0
- package/dist/components/VectorBrowserView.d.ts +10 -0
- package/dist/components/VectorBrowserView.d.ts.map +1 -0
- package/dist/components/VectorBrowserView.js +997 -0
- package/dist/components/VoiceConfigView.d.ts +11 -0
- package/dist/components/VoiceConfigView.d.ts.map +1 -0
- package/dist/components/VoiceConfigView.js +329 -0
- package/dist/components/VrmStage.d.ts +21 -0
- package/dist/components/VrmStage.d.ts.map +1 -0
- package/dist/components/VrmStage.js +252 -0
- package/dist/components/WhatsAppQrOverlay.d.ts +8 -0
- package/dist/components/WhatsAppQrOverlay.d.ts.map +1 -0
- package/dist/components/WhatsAppQrOverlay.js +63 -0
- package/dist/components/apps/AppDetailPane.d.ts +15 -0
- package/dist/components/apps/AppDetailPane.d.ts.map +1 -0
- package/dist/components/apps/AppDetailPane.js +13 -0
- package/dist/components/apps/AppsCatalogGrid.d.ts +20 -0
- package/dist/components/apps/AppsCatalogGrid.d.ts.map +1 -0
- package/dist/components/apps/AppsCatalogGrid.js +18 -0
- package/dist/components/apps/extensions/HyperscapeAppDetailPanel.d.ts +3 -0
- package/dist/components/apps/extensions/HyperscapeAppDetailPanel.d.ts.map +1 -0
- package/dist/components/apps/extensions/HyperscapeAppDetailPanel.js +253 -0
- package/dist/components/apps/extensions/registry.d.ts +4 -0
- package/dist/components/apps/extensions/registry.d.ts.map +1 -0
- package/dist/components/apps/extensions/registry.js +10 -0
- package/dist/components/apps/extensions/types.d.ts +7 -0
- package/dist/components/apps/extensions/types.d.ts.map +1 -0
- package/dist/components/apps/extensions/types.js +1 -0
- package/dist/components/apps/helpers.d.ts +7 -0
- package/dist/components/apps/helpers.d.ts.map +1 -0
- package/dist/components/apps/helpers.js +46 -0
- package/dist/components/avatar/VrmAnimationLoader.d.ts +30 -0
- package/dist/components/avatar/VrmAnimationLoader.d.ts.map +1 -0
- package/dist/components/avatar/VrmAnimationLoader.js +99 -0
- package/dist/components/avatar/VrmBlinkController.d.ts +37 -0
- package/dist/components/avatar/VrmBlinkController.d.ts.map +1 -0
- package/dist/components/avatar/VrmBlinkController.js +98 -0
- package/dist/components/avatar/VrmCameraManager.d.ts +57 -0
- package/dist/components/avatar/VrmCameraManager.d.ts.map +1 -0
- package/dist/components/avatar/VrmCameraManager.js +277 -0
- package/dist/components/avatar/VrmEngine.d.ts +229 -0
- package/dist/components/avatar/VrmEngine.d.ts.map +1 -0
- package/dist/components/avatar/VrmEngine.js +1950 -0
- package/dist/components/avatar/VrmFootShadow.d.ts +18 -0
- package/dist/components/avatar/VrmFootShadow.d.ts.map +1 -0
- package/dist/components/avatar/VrmFootShadow.js +83 -0
- package/dist/components/avatar/VrmViewer.d.ts +45 -0
- package/dist/components/avatar/VrmViewer.d.ts.map +1 -0
- package/dist/components/avatar/VrmViewer.js +341 -0
- package/dist/components/avatar/mixamoVRMRigMap.d.ts +3 -0
- package/dist/components/avatar/mixamoVRMRigMap.d.ts.map +1 -0
- package/dist/components/avatar/mixamoVRMRigMap.js +56 -0
- package/dist/components/avatar/retargetMixamoFbxToVrm.d.ts +9 -0
- package/dist/components/avatar/retargetMixamoFbxToVrm.d.ts.map +1 -0
- package/dist/components/avatar/retargetMixamoFbxToVrm.js +88 -0
- package/dist/components/avatar/retargetMixamoGltfToVrm.d.ts +11 -0
- package/dist/components/avatar/retargetMixamoGltfToVrm.d.ts.map +1 -0
- package/dist/components/avatar/retargetMixamoGltfToVrm.js +80 -0
- package/dist/components/chainConfig.d.ts +84 -0
- package/dist/components/chainConfig.d.ts.map +1 -0
- package/dist/components/chainConfig.js +268 -0
- package/dist/components/companion/CompanionHeader.d.ts +15 -0
- package/dist/components/companion/CompanionHeader.d.ts.map +1 -0
- package/dist/components/companion/CompanionHeader.js +7 -0
- package/dist/components/companion/CompanionSceneHost.d.ts +2 -0
- package/dist/components/companion/CompanionSceneHost.d.ts.map +1 -0
- package/dist/components/companion/CompanionSceneHost.js +1 -0
- package/dist/components/companion/VrmStage.d.ts +3 -0
- package/dist/components/companion/VrmStage.d.ts.map +1 -0
- package/dist/components/companion/VrmStage.js +1 -0
- package/dist/components/companion/walletUtils.d.ts +95 -0
- package/dist/components/companion/walletUtils.d.ts.map +1 -0
- package/dist/components/companion/walletUtils.js +167 -0
- package/dist/components/companion-shell-styles.d.ts +38 -0
- package/dist/components/companion-shell-styles.d.ts.map +1 -0
- package/dist/components/companion-shell-styles.js +248 -0
- package/dist/components/confirm-delete-control.d.ts +16 -0
- package/dist/components/confirm-delete-control.d.ts.map +1 -0
- package/dist/components/confirm-delete-control.js +12 -0
- package/dist/components/conversations/ConversationListItem.d.ts +31 -0
- package/dist/components/conversations/ConversationListItem.d.ts.map +1 -0
- package/dist/components/conversations/ConversationListItem.js +52 -0
- package/dist/components/conversations/conversation-utils.d.ts +9 -0
- package/dist/components/conversations/conversation-utils.d.ts.map +1 -0
- package/dist/components/conversations/conversation-utils.js +138 -0
- package/dist/components/format.d.ts +54 -0
- package/dist/components/format.d.ts.map +1 -0
- package/dist/components/format.js +82 -0
- package/dist/components/index.d.ts +93 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +92 -0
- package/dist/components/inventory/CopyableAddress.d.ts +8 -0
- package/dist/components/inventory/CopyableAddress.d.ts.map +1 -0
- package/dist/components/inventory/CopyableAddress.js +18 -0
- package/dist/components/inventory/InventoryToolbar.d.ts +25 -0
- package/dist/components/inventory/InventoryToolbar.d.ts.map +1 -0
- package/dist/components/inventory/InventoryToolbar.js +28 -0
- package/dist/components/inventory/NftGrid.d.ts +13 -0
- package/dist/components/inventory/NftGrid.d.ts.map +1 -0
- package/dist/components/inventory/NftGrid.js +29 -0
- package/dist/components/inventory/TokenLogo.d.ts +12 -0
- package/dist/components/inventory/TokenLogo.d.ts.map +1 -0
- package/dist/components/inventory/TokenLogo.js +33 -0
- package/dist/components/inventory/TokensTable.d.ts +24 -0
- package/dist/components/inventory/TokensTable.d.ts.map +1 -0
- package/dist/components/inventory/TokensTable.js +26 -0
- package/dist/components/inventory/constants.d.ts +52 -0
- package/dist/components/inventory/constants.d.ts.map +1 -0
- package/dist/components/inventory/constants.js +121 -0
- package/dist/components/inventory/index.d.ts +9 -0
- package/dist/components/inventory/index.d.ts.map +1 -0
- package/dist/components/inventory/index.js +8 -0
- package/dist/components/inventory/media-url.d.ts +6 -0
- package/dist/components/inventory/media-url.d.ts.map +1 -0
- package/dist/components/inventory/media-url.js +28 -0
- package/dist/components/inventory/useInventoryData.d.ts +53 -0
- package/dist/components/inventory/useInventoryData.d.ts.map +1 -0
- package/dist/components/inventory/useInventoryData.js +332 -0
- package/dist/components/knowledge-upload-image.d.ts +27 -0
- package/dist/components/knowledge-upload-image.d.ts.map +1 -0
- package/dist/components/knowledge-upload-image.js +146 -0
- package/dist/components/labels.d.ts +6 -0
- package/dist/components/labels.d.ts.map +1 -0
- package/dist/components/labels.js +40 -0
- package/dist/components/onboarding/ActivateStep.d.ts +2 -0
- package/dist/components/onboarding/ActivateStep.d.ts.map +1 -0
- package/dist/components/onboarding/ActivateStep.js +6 -0
- package/dist/components/onboarding/ConnectionStep.d.ts +2 -0
- package/dist/components/onboarding/ConnectionStep.d.ts.map +1 -0
- package/dist/components/onboarding/ConnectionStep.js +552 -0
- package/dist/components/onboarding/OnboardingPanel.d.ts +9 -0
- package/dist/components/onboarding/OnboardingPanel.d.ts.map +1 -0
- package/dist/components/onboarding/OnboardingPanel.js +24 -0
- package/dist/components/onboarding/OnboardingStepNav.d.ts +2 -0
- package/dist/components/onboarding/OnboardingStepNav.d.ts.map +1 -0
- package/dist/components/onboarding/OnboardingStepNav.js +14 -0
- package/dist/components/onboarding/PermissionsStep.d.ts +2 -0
- package/dist/components/onboarding/PermissionsStep.d.ts.map +1 -0
- package/dist/components/onboarding/PermissionsStep.js +7 -0
- package/dist/components/onboarding/RpcStep.d.ts +2 -0
- package/dist/components/onboarding/RpcStep.d.ts.map +1 -0
- package/dist/components/onboarding/RpcStep.js +125 -0
- package/dist/components/onboarding/WakeUpStep.d.ts +2 -0
- package/dist/components/onboarding/WakeUpStep.d.ts.map +1 -0
- package/dist/components/onboarding/WakeUpStep.js +82 -0
- package/dist/components/permissions/PermissionIcon.d.ts +4 -0
- package/dist/components/permissions/PermissionIcon.d.ts.map +1 -0
- package/dist/components/permissions/PermissionIcon.js +12 -0
- package/dist/components/permissions/StreamingPermissions.d.ts +20 -0
- package/dist/components/permissions/StreamingPermissions.d.ts.map +1 -0
- package/dist/components/permissions/StreamingPermissions.js +173 -0
- package/dist/components/plugins/showcase-data.d.ts +7 -0
- package/dist/components/plugins/showcase-data.d.ts.map +1 -0
- package/dist/components/plugins/showcase-data.js +464 -0
- package/dist/components/shared/ShellHeaderControls.d.ts +27 -0
- package/dist/components/shared/ShellHeaderControls.d.ts.map +1 -0
- package/dist/components/shared/ShellHeaderControls.js +60 -0
- package/dist/components/skeletons.d.ts +17 -0
- package/dist/components/skeletons.d.ts.map +1 -0
- package/dist/components/skeletons.js +22 -0
- package/dist/components/stream/ActivityFeed.d.ts +5 -0
- package/dist/components/stream/ActivityFeed.d.ts.map +1 -0
- package/dist/components/stream/ActivityFeed.js +57 -0
- package/dist/components/stream/AvatarPip.d.ts +5 -0
- package/dist/components/stream/AvatarPip.d.ts.map +1 -0
- package/dist/components/stream/AvatarPip.js +6 -0
- package/dist/components/stream/ChatContent.d.ts +6 -0
- package/dist/components/stream/ChatContent.d.ts.map +1 -0
- package/dist/components/stream/ChatContent.js +69 -0
- package/dist/components/stream/ChatTicker.d.ts +5 -0
- package/dist/components/stream/ChatTicker.d.ts.map +1 -0
- package/dist/components/stream/ChatTicker.js +34 -0
- package/dist/components/stream/IdleContent.d.ts +5 -0
- package/dist/components/stream/IdleContent.d.ts.map +1 -0
- package/dist/components/stream/IdleContent.js +17 -0
- package/dist/components/stream/StatusBar.d.ts +36 -0
- package/dist/components/stream/StatusBar.d.ts.map +1 -0
- package/dist/components/stream/StatusBar.js +140 -0
- package/dist/components/stream/StreamSettings.d.ts +33 -0
- package/dist/components/stream/StreamSettings.d.ts.map +1 -0
- package/dist/components/stream/StreamSettings.js +99 -0
- package/dist/components/stream/StreamTerminal.d.ts +2 -0
- package/dist/components/stream/StreamTerminal.d.ts.map +1 -0
- package/dist/components/stream/StreamTerminal.js +52 -0
- package/dist/components/stream/StreamVoiceConfig.d.ts +10 -0
- package/dist/components/stream/StreamVoiceConfig.d.ts.map +1 -0
- package/dist/components/stream/StreamVoiceConfig.js +88 -0
- package/dist/components/stream/helpers.d.ts +32 -0
- package/dist/components/stream/helpers.d.ts.map +1 -0
- package/dist/components/stream/helpers.js +110 -0
- package/dist/components/stream/overlays/OverlayLayer.d.ts +20 -0
- package/dist/components/stream/overlays/OverlayLayer.d.ts.map +1 -0
- package/dist/components/stream/overlays/OverlayLayer.js +24 -0
- package/dist/components/stream/overlays/built-in/ActionTickerWidget.d.ts +8 -0
- package/dist/components/stream/overlays/built-in/ActionTickerWidget.d.ts.map +1 -0
- package/dist/components/stream/overlays/built-in/ActionTickerWidget.js +44 -0
- package/dist/components/stream/overlays/built-in/AlertPopupWidget.d.ts +7 -0
- package/dist/components/stream/overlays/built-in/AlertPopupWidget.d.ts.map +1 -0
- package/dist/components/stream/overlays/built-in/AlertPopupWidget.js +62 -0
- package/dist/components/stream/overlays/built-in/BrandingWidget.d.ts +7 -0
- package/dist/components/stream/overlays/built-in/BrandingWidget.d.ts.map +1 -0
- package/dist/components/stream/overlays/built-in/BrandingWidget.js +36 -0
- package/dist/components/stream/overlays/built-in/CustomHtmlWidget.d.ts +26 -0
- package/dist/components/stream/overlays/built-in/CustomHtmlWidget.d.ts.map +1 -0
- package/dist/components/stream/overlays/built-in/CustomHtmlWidget.js +78 -0
- package/dist/components/stream/overlays/built-in/PeonGlassWidget.d.ts +11 -0
- package/dist/components/stream/overlays/built-in/PeonGlassWidget.d.ts.map +1 -0
- package/dist/components/stream/overlays/built-in/PeonGlassWidget.js +188 -0
- package/dist/components/stream/overlays/built-in/PeonHudWidget.d.ts +10 -0
- package/dist/components/stream/overlays/built-in/PeonHudWidget.d.ts.map +1 -0
- package/dist/components/stream/overlays/built-in/PeonHudWidget.js +168 -0
- package/dist/components/stream/overlays/built-in/PeonSakuraWidget.d.ts +11 -0
- package/dist/components/stream/overlays/built-in/PeonSakuraWidget.d.ts.map +1 -0
- package/dist/components/stream/overlays/built-in/PeonSakuraWidget.js +213 -0
- package/dist/components/stream/overlays/built-in/ThoughtBubbleWidget.d.ts +8 -0
- package/dist/components/stream/overlays/built-in/ThoughtBubbleWidget.d.ts.map +1 -0
- package/dist/components/stream/overlays/built-in/ThoughtBubbleWidget.js +59 -0
- package/dist/components/stream/overlays/built-in/ViewerCountWidget.d.ts +7 -0
- package/dist/components/stream/overlays/built-in/ViewerCountWidget.d.ts.map +1 -0
- package/dist/components/stream/overlays/built-in/ViewerCountWidget.js +34 -0
- package/dist/components/stream/overlays/built-in/index.d.ts +13 -0
- package/dist/components/stream/overlays/built-in/index.d.ts.map +1 -0
- package/dist/components/stream/overlays/built-in/index.js +12 -0
- package/dist/components/stream/overlays/registry.d.ts +11 -0
- package/dist/components/stream/overlays/registry.d.ts.map +1 -0
- package/dist/components/stream/overlays/registry.js +16 -0
- package/dist/components/stream/overlays/types.d.ts +67 -0
- package/dist/components/stream/overlays/types.d.ts.map +1 -0
- package/dist/components/stream/overlays/types.js +7 -0
- package/dist/components/stream/overlays/useOverlayLayout.d.ts +27 -0
- package/dist/components/stream/overlays/useOverlayLayout.d.ts.map +1 -0
- package/dist/components/stream/overlays/useOverlayLayout.js +162 -0
- package/dist/components/trajectory-format.d.ts +6 -0
- package/dist/components/trajectory-format.d.ts.map +1 -0
- package/dist/components/trajectory-format.js +43 -0
- package/dist/components/ui-badges.d.ts +23 -0
- package/dist/components/ui-badges.d.ts.map +1 -0
- package/dist/components/ui-badges.js +38 -0
- package/dist/components/ui-switch.d.ts +14 -0
- package/dist/components/ui-switch.d.ts.map +1 -0
- package/dist/components/ui-switch.js +15 -0
- package/dist/components/vector-browser-three.d.ts +4 -0
- package/dist/components/vector-browser-three.d.ts.map +1 -0
- package/dist/components/vector-browser-three.js +19 -0
- package/dist/config/config-catalog.d.ts +376 -0
- package/dist/config/config-catalog.d.ts.map +1 -0
- package/dist/config/config-catalog.js +724 -0
- package/dist/config/config-field.d.ts +68 -0
- package/dist/config/config-field.d.ts.map +1 -0
- package/dist/config/config-field.js +821 -0
- package/dist/config/config-renderer.d.ts +176 -0
- package/dist/config/config-renderer.d.ts.map +1 -0
- package/dist/config/config-renderer.js +403 -0
- package/dist/config/index.d.ts +5 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +4 -0
- package/dist/config/ui-renderer.d.ts +26 -0
- package/dist/config/ui-renderer.d.ts.map +1 -0
- package/dist/config/ui-renderer.js +815 -0
- package/dist/config/ui-spec.d.ts +164 -0
- package/dist/config/ui-spec.d.ts.map +1 -0
- package/dist/config/ui-spec.js +13 -0
- package/dist/events/index.d.ts +42 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +41 -0
- package/dist/hooks/index.d.ts +14 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +13 -0
- package/dist/hooks/useBugReport.d.ts +14 -0
- package/dist/hooks/useBugReport.d.ts.map +1 -0
- package/dist/hooks/useBugReport.js +18 -0
- package/dist/hooks/useCanvasWindow.d.ts +38 -0
- package/dist/hooks/useCanvasWindow.d.ts.map +1 -0
- package/dist/hooks/useCanvasWindow.js +273 -0
- package/dist/hooks/useChatAvatarVoice.d.ts +10 -0
- package/dist/hooks/useChatAvatarVoice.d.ts.map +1 -0
- package/dist/hooks/useChatAvatarVoice.js +71 -0
- package/dist/hooks/useContextMenu.d.ts +17 -0
- package/dist/hooks/useContextMenu.d.ts.map +1 -0
- package/dist/hooks/useContextMenu.js +100 -0
- package/dist/hooks/useKeyboardShortcuts.d.ts +17 -0
- package/dist/hooks/useKeyboardShortcuts.d.ts.map +1 -0
- package/dist/hooks/useKeyboardShortcuts.js +67 -0
- package/dist/hooks/useLifoSync.d.ts +18 -0
- package/dist/hooks/useLifoSync.d.ts.map +1 -0
- package/dist/hooks/useLifoSync.js +113 -0
- package/dist/hooks/useMemoryMonitor.d.ts +87 -0
- package/dist/hooks/useMemoryMonitor.d.ts.map +1 -0
- package/dist/hooks/useMemoryMonitor.js +210 -0
- package/dist/hooks/useRenderGuard.d.ts +17 -0
- package/dist/hooks/useRenderGuard.d.ts.map +1 -0
- package/dist/hooks/useRenderGuard.js +36 -0
- package/dist/hooks/useRetakeCapture.d.ts +12 -0
- package/dist/hooks/useRetakeCapture.d.ts.map +1 -0
- package/dist/hooks/useRetakeCapture.js +59 -0
- package/dist/hooks/useStreamPopoutNavigation.d.ts +3 -0
- package/dist/hooks/useStreamPopoutNavigation.d.ts.map +1 -0
- package/dist/hooks/useStreamPopoutNavigation.js +17 -0
- package/dist/hooks/useTimeout.d.ts +11 -0
- package/dist/hooks/useTimeout.d.ts.map +1 -0
- package/dist/hooks/useTimeout.js +32 -0
- package/dist/hooks/useVoiceChat.d.ts +129 -0
- package/dist/hooks/useVoiceChat.d.ts.map +1 -0
- package/dist/hooks/useVoiceChat.js +1071 -0
- package/dist/hooks/useWhatsAppPairing.d.ts +11 -0
- package/dist/hooks/useWhatsAppPairing.d.ts.map +1 -0
- package/dist/hooks/useWhatsAppPairing.js +95 -0
- package/dist/i18n/index.d.ts +7 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +53 -0
- package/dist/i18n/locales/en.json +1196 -0
- package/dist/i18n/locales/es.json +1196 -0
- package/dist/i18n/locales/ko.json +1196 -0
- package/dist/i18n/locales/pt.json +1196 -0
- package/dist/i18n/locales/zh-CN.json +1196 -0
- package/dist/i18n/messages.d.ts +6 -0
- package/dist/i18n/messages.d.ts.map +1 -0
- package/dist/i18n/messages.js +14 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/navigation/index.d.ts +27 -0
- package/dist/navigation/index.d.ts.map +1 -0
- package/dist/navigation/index.js +230 -0
- package/dist/package.json +161 -0
- package/dist/platform/browser-launch.d.ts +2 -0
- package/dist/platform/browser-launch.d.ts.map +1 -0
- package/dist/platform/browser-launch.js +109 -0
- package/dist/platform/index.d.ts +64 -0
- package/dist/platform/index.d.ts.map +1 -0
- package/dist/platform/index.js +155 -0
- package/dist/platform/init.d.ts +40 -0
- package/dist/platform/init.d.ts.map +1 -0
- package/dist/platform/init.js +158 -0
- package/dist/providers/index.d.ts +13 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +72 -0
- package/dist/state/AppContext.d.ts +11 -0
- package/dist/state/AppContext.d.ts.map +1 -0
- package/dist/state/AppContext.js +4496 -0
- package/dist/state/index.d.ts +7 -0
- package/dist/state/index.d.ts.map +1 -0
- package/dist/state/index.js +6 -0
- package/dist/state/internal.d.ts +6 -0
- package/dist/state/internal.d.ts.map +1 -0
- package/dist/state/internal.js +5 -0
- package/dist/state/parsers.d.ts +26 -0
- package/dist/state/parsers.d.ts.map +1 -0
- package/dist/state/parsers.js +255 -0
- package/dist/state/persistence.d.ts +36 -0
- package/dist/state/persistence.d.ts.map +1 -0
- package/dist/state/persistence.js +254 -0
- package/dist/state/types.d.ts +402 -0
- package/dist/state/types.d.ts.map +1 -0
- package/dist/state/types.js +70 -0
- package/dist/state/ui-preferences.d.ts +3 -0
- package/dist/state/ui-preferences.d.ts.map +1 -0
- package/dist/state/ui-preferences.js +1 -0
- package/dist/state/useApp.d.ts +4 -0
- package/dist/state/useApp.d.ts.map +1 -0
- package/dist/state/useApp.js +22 -0
- package/dist/state/vrm.d.ts +19 -0
- package/dist/state/vrm.d.ts.map +1 -0
- package/dist/state/vrm.js +65 -0
- package/dist/stories/AppMockProvider.d.ts +15 -0
- package/dist/stories/AppMockProvider.d.ts.map +1 -0
- package/dist/stories/AppMockProvider.js +14 -0
- package/dist/styles/anime.css +6324 -0
- package/dist/styles/base.css +196 -0
- package/dist/styles/onboarding-game.css +716 -0
- package/dist/styles/styles.css +2085 -0
- package/dist/styles/xterm.css +241 -0
- package/dist/types/index.d.ts +657 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +1 -0
- package/dist/utils/asset-url.d.ts +26 -0
- package/dist/utils/asset-url.d.ts.map +1 -0
- package/dist/utils/asset-url.js +99 -0
- package/dist/utils/assistant-text.d.ts +2 -0
- package/dist/utils/assistant-text.d.ts.map +1 -0
- package/dist/utils/assistant-text.js +161 -0
- package/dist/utils/clipboard.d.ts +2 -0
- package/dist/utils/clipboard.d.ts.map +1 -0
- package/dist/utils/clipboard.js +38 -0
- package/dist/utils/desktop-dialogs.d.ts +19 -0
- package/dist/utils/desktop-dialogs.d.ts.map +1 -0
- package/dist/utils/desktop-dialogs.js +50 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +6 -0
- package/dist/utils/number-parsing.d.ts +44 -0
- package/dist/utils/number-parsing.d.ts.map +1 -0
- package/dist/utils/number-parsing.js +56 -0
- package/dist/utils/openExternalUrl.d.ts +2 -0
- package/dist/utils/openExternalUrl.d.ts.map +1 -0
- package/dist/utils/openExternalUrl.js +17 -0
- package/dist/utils/spoken-text.d.ts +2 -0
- package/dist/utils/spoken-text.d.ts.map +1 -0
- package/dist/utils/spoken-text.js +56 -0
- package/dist/utils/streaming-text.d.ts +3 -0
- package/dist/utils/streaming-text.d.ts.map +1 -0
- package/dist/utils/streaming-text.js +87 -0
- package/dist/voice/index.d.ts +2 -0
- package/dist/voice/index.d.ts.map +1 -0
- package/dist/voice/index.js +1 -0
- package/dist/voice/types.d.ts +25 -0
- package/dist/voice/types.d.ts.map +1 -0
- package/dist/voice/types.js +166 -0
- package/package.json +86 -0
- package/src/App.tsx +469 -0
- package/src/actions/character.ts +113 -0
- package/src/actions/chat-helpers.ts +100 -0
- package/src/actions/cloud.ts +59 -0
- package/src/actions/index.ts +12 -0
- package/src/actions/lifecycle.ts +175 -0
- package/src/actions/onboarding.ts +46 -0
- package/src/actions/triggers.ts +190 -0
- package/src/ambient.d.ts +16 -0
- package/src/api/client.ts +5616 -0
- package/src/api/index.ts +1 -0
- package/src/autonomy/index.ts +477 -0
- package/src/bridge/capacitor-bridge.ts +295 -0
- package/src/bridge/electrobun-rpc.ts +58 -0
- package/src/bridge/electrobun-runtime.ts +28 -0
- package/src/bridge/index.ts +5 -0
- package/src/bridge/native-plugins.ts +134 -0
- package/src/bridge/plugin-bridge.ts +352 -0
- package/src/bridge/storage-bridge.ts +162 -0
- package/src/chat/index.ts +251 -0
- package/src/coding/index.ts +43 -0
- package/src/components/AdvancedPageView.tsx +362 -0
- package/src/components/AgentActivityBox.tsx +49 -0
- package/src/components/ApiKeyConfig.tsx +224 -0
- package/src/components/AppsPageView.tsx +52 -0
- package/src/components/AppsView.tsx +293 -0
- package/src/components/AvatarLoader.tsx +86 -0
- package/src/components/AvatarSelector.tsx +223 -0
- package/src/components/BscTradePanel.tsx +549 -0
- package/src/components/BugReportModal.tsx +499 -0
- package/src/components/CharacterView.tsx +1623 -0
- package/src/components/ChatAvatar.test.ts +96 -0
- package/src/components/ChatAvatar.tsx +147 -0
- package/src/components/ChatComposer.tsx +330 -0
- package/src/components/ChatMessage.tsx +448 -0
- package/src/components/ChatModalView.test.tsx +118 -0
- package/src/components/ChatModalView.tsx +125 -0
- package/src/components/ChatView.tsx +999 -0
- package/src/components/CloudSourceControls.tsx +80 -0
- package/src/components/CodingAgentSettingsSection.tsx +536 -0
- package/src/components/CommandPalette.tsx +284 -0
- package/src/components/CompanionSceneHost.tsx +498 -0
- package/src/components/CompanionShell.tsx +31 -0
- package/src/components/CompanionView.tsx +109 -0
- package/src/components/ConfigPageView.tsx +722 -0
- package/src/components/ConfigSaveFooter.tsx +41 -0
- package/src/components/ConfirmModal.tsx +379 -0
- package/src/components/ConnectionFailedBanner.tsx +91 -0
- package/src/components/ConnectorsPageView.tsx +13 -0
- package/src/components/ConversationsSidebar.tsx +279 -0
- package/src/components/CustomActionEditor.tsx +1125 -0
- package/src/components/CustomActionsPanel.tsx +288 -0
- package/src/components/CustomActionsView.tsx +322 -0
- package/src/components/DatabasePageView.tsx +55 -0
- package/src/components/DatabaseView.tsx +814 -0
- package/src/components/ElizaCloudDashboard.tsx +1696 -0
- package/src/components/EmotePicker.tsx +529 -0
- package/src/components/ErrorBoundary.tsx +76 -0
- package/src/components/FineTuningView.tsx +1080 -0
- package/src/components/GameView.tsx +551 -0
- package/src/components/GameViewOverlay.tsx +133 -0
- package/src/components/GlobalEmoteOverlay.tsx +152 -0
- package/src/components/Header.test.tsx +413 -0
- package/src/components/Header.tsx +400 -0
- package/src/components/HeartbeatsView.tsx +1002 -0
- package/src/components/InventoryView.tsx +372 -0
- package/src/components/KnowledgeView.tsx +1128 -0
- package/src/components/LanguageDropdown.tsx +187 -0
- package/src/components/LifoMonitorPanel.tsx +196 -0
- package/src/components/LifoSandboxView.tsx +499 -0
- package/src/components/LoadingScreen.tsx +77 -0
- package/src/components/LogsPageView.tsx +17 -0
- package/src/components/LogsView.tsx +239 -0
- package/src/components/MediaGalleryView.tsx +432 -0
- package/src/components/MediaSettingsSection.tsx +893 -0
- package/src/components/MessageContent.tsx +815 -0
- package/src/components/OnboardingWizard.test.tsx +107 -0
- package/src/components/OnboardingWizard.tsx +186 -0
- package/src/components/PairingView.tsx +110 -0
- package/src/components/PermissionsSection.tsx +818 -0
- package/src/components/PluginsPageView.tsx +9 -0
- package/src/components/PluginsView.tsx +3152 -0
- package/src/components/ProviderSwitcher.tsx +874 -0
- package/src/components/RestartBanner.tsx +76 -0
- package/src/components/RuntimeView.tsx +460 -0
- package/src/components/SaveCommandModal.tsx +211 -0
- package/src/components/SecretsView.tsx +569 -0
- package/src/components/SettingsView.tsx +825 -0
- package/src/components/ShellOverlays.tsx +41 -0
- package/src/components/ShortcutsOverlay.tsx +155 -0
- package/src/components/SkillsView.tsx +1435 -0
- package/src/components/StartupFailureView.tsx +63 -0
- package/src/components/StreamView.tsx +483 -0
- package/src/components/StripeEmbeddedCheckout.tsx +155 -0
- package/src/components/SubscriptionStatus.tsx +634 -0
- package/src/components/SystemWarningBanner.tsx +71 -0
- package/src/components/ThemeToggle.tsx +100 -0
- package/src/components/TrajectoriesView.tsx +526 -0
- package/src/components/TrajectoryDetailView.tsx +426 -0
- package/src/components/TriggersView.tsx +1 -0
- package/src/components/VectorBrowserView.tsx +1633 -0
- package/src/components/VoiceConfigView.tsx +674 -0
- package/src/components/VrmStage.test.ts +219 -0
- package/src/components/VrmStage.tsx +432 -0
- package/src/components/WhatsAppQrOverlay.tsx +230 -0
- package/src/components/__tests__/chainConfig.test.ts +220 -0
- package/src/components/apps/AppDetailPane.tsx +242 -0
- package/src/components/apps/AppsCatalogGrid.tsx +137 -0
- package/src/components/apps/extensions/HyperscapeAppDetailPanel.tsx +577 -0
- package/src/components/apps/extensions/registry.ts +16 -0
- package/src/components/apps/extensions/types.ts +9 -0
- package/src/components/apps/helpers.ts +44 -0
- package/src/components/avatar/VrmAnimationLoader.test.ts +164 -0
- package/src/components/avatar/VrmAnimationLoader.ts +151 -0
- package/src/components/avatar/VrmBlinkController.ts +118 -0
- package/src/components/avatar/VrmCameraManager.ts +407 -0
- package/src/components/avatar/VrmEngine.ts +2678 -0
- package/src/components/avatar/VrmFootShadow.ts +96 -0
- package/src/components/avatar/VrmViewer.tsx +421 -0
- package/src/components/avatar/__tests__/VrmCameraManager.test.ts +168 -0
- package/src/components/avatar/__tests__/VrmEngine.test.ts +1574 -0
- package/src/components/avatar/mixamoVRMRigMap.ts +62 -0
- package/src/components/avatar/retargetMixamoFbxToVrm.ts +144 -0
- package/src/components/avatar/retargetMixamoGltfToVrm.ts +119 -0
- package/src/components/chainConfig.ts +380 -0
- package/src/components/companion/CompanionHeader.tsx +47 -0
- package/src/components/companion/CompanionSceneHost.tsx +5 -0
- package/src/components/companion/VrmStage.tsx +2 -0
- package/src/components/companion/__tests__/walletUtils.test.ts +742 -0
- package/src/components/companion/walletUtils.ts +290 -0
- package/src/components/companion-shell-styles.test.ts +146 -0
- package/src/components/companion-shell-styles.ts +270 -0
- package/src/components/confirm-delete-control.tsx +69 -0
- package/src/components/conversations/ConversationListItem.tsx +185 -0
- package/src/components/conversations/conversation-utils.ts +151 -0
- package/src/components/format.ts +131 -0
- package/src/components/index.ts +92 -0
- package/src/components/inventory/CopyableAddress.tsx +41 -0
- package/src/components/inventory/InventoryToolbar.tsx +142 -0
- package/src/components/inventory/NftGrid.tsx +99 -0
- package/src/components/inventory/TokenLogo.tsx +71 -0
- package/src/components/inventory/TokensTable.tsx +216 -0
- package/src/components/inventory/constants.ts +170 -0
- package/src/components/inventory/index.ts +29 -0
- package/src/components/inventory/media-url.test.ts +38 -0
- package/src/components/inventory/media-url.ts +36 -0
- package/src/components/inventory/useInventoryData.ts +460 -0
- package/src/components/knowledge-upload-image.ts +215 -0
- package/src/components/labels.ts +46 -0
- package/src/components/onboarding/ActivateStep.tsx +30 -0
- package/src/components/onboarding/ConnectionStep.tsx +1530 -0
- package/src/components/onboarding/OnboardingPanel.tsx +39 -0
- package/src/components/onboarding/OnboardingStepNav.tsx +31 -0
- package/src/components/onboarding/PermissionsStep.tsx +20 -0
- package/src/components/onboarding/RpcStep.tsx +402 -0
- package/src/components/onboarding/WakeUpStep.tsx +184 -0
- package/src/components/permissions/PermissionIcon.tsx +25 -0
- package/src/components/permissions/StreamingPermissions.tsx +376 -0
- package/src/components/plugins/showcase-data.ts +481 -0
- package/src/components/shared/ShellHeaderControls.tsx +193 -0
- package/src/components/skeletons.tsx +88 -0
- package/src/components/stream/ActivityFeed.tsx +113 -0
- package/src/components/stream/AvatarPip.tsx +10 -0
- package/src/components/stream/ChatContent.tsx +126 -0
- package/src/components/stream/ChatTicker.tsx +55 -0
- package/src/components/stream/IdleContent.tsx +73 -0
- package/src/components/stream/StatusBar.tsx +469 -0
- package/src/components/stream/StreamSettings.tsx +506 -0
- package/src/components/stream/StreamTerminal.tsx +94 -0
- package/src/components/stream/StreamVoiceConfig.tsx +160 -0
- package/src/components/stream/helpers.ts +134 -0
- package/src/components/stream/overlays/OverlayLayer.tsx +75 -0
- package/src/components/stream/overlays/built-in/ActionTickerWidget.tsx +64 -0
- package/src/components/stream/overlays/built-in/AlertPopupWidget.tsx +87 -0
- package/src/components/stream/overlays/built-in/BrandingWidget.tsx +51 -0
- package/src/components/stream/overlays/built-in/CustomHtmlWidget.tsx +105 -0
- package/src/components/stream/overlays/built-in/PeonGlassWidget.tsx +265 -0
- package/src/components/stream/overlays/built-in/PeonHudWidget.tsx +247 -0
- package/src/components/stream/overlays/built-in/PeonSakuraWidget.tsx +278 -0
- package/src/components/stream/overlays/built-in/ThoughtBubbleWidget.tsx +77 -0
- package/src/components/stream/overlays/built-in/ViewerCountWidget.tsx +46 -0
- package/src/components/stream/overlays/built-in/index.ts +13 -0
- package/src/components/stream/overlays/registry.ts +22 -0
- package/src/components/stream/overlays/types.ts +90 -0
- package/src/components/stream/overlays/useOverlayLayout.ts +218 -0
- package/src/components/trajectory-format.ts +50 -0
- package/src/components/ui-badges.tsx +109 -0
- package/src/components/ui-switch.tsx +57 -0
- package/src/components/vector-browser-three.ts +27 -0
- package/src/config/config-catalog.ts +1092 -0
- package/src/config/config-field.tsx +1900 -0
- package/src/config/config-renderer.tsx +730 -0
- package/src/config/index.ts +11 -0
- package/src/config/ui-renderer.tsx +1751 -0
- package/src/config/ui-spec.ts +256 -0
- package/src/events/index.ts +89 -0
- package/src/hooks/index.ts +13 -0
- package/src/hooks/useBugReport.tsx +43 -0
- package/src/hooks/useCanvasWindow.ts +372 -0
- package/src/hooks/useChatAvatarVoice.ts +111 -0
- package/src/hooks/useContextMenu.ts +127 -0
- package/src/hooks/useKeyboardShortcuts.ts +86 -0
- package/src/hooks/useLifoSync.ts +143 -0
- package/src/hooks/useMemoryMonitor.ts +335 -0
- package/src/hooks/useRenderGuard.ts +43 -0
- package/src/hooks/useRetakeCapture.ts +67 -0
- package/src/hooks/useStreamPopoutNavigation.ts +27 -0
- package/src/hooks/useTimeout.ts +37 -0
- package/src/hooks/useVoiceChat.ts +1443 -0
- package/src/hooks/useWhatsAppPairing.ts +123 -0
- package/src/i18n/index.ts +76 -0
- package/src/i18n/locales/en.json +1196 -0
- package/src/i18n/locales/es.json +1196 -0
- package/src/i18n/locales/ko.json +1196 -0
- package/src/i18n/locales/pt.json +1196 -0
- package/src/i18n/locales/zh-CN.json +1196 -0
- package/src/i18n/messages.ts +21 -0
- package/src/index.ts +6 -0
- package/src/navigation/index.ts +282 -0
- package/src/navigation.test.ts +189 -0
- package/src/platform/browser-launch.test.ts +94 -0
- package/src/platform/browser-launch.ts +149 -0
- package/src/platform/index.ts +261 -0
- package/src/platform/init.ts +236 -0
- package/src/providers/index.ts +82 -0
- package/src/state/AppContext.tsx +5737 -0
- package/src/state/index.ts +6 -0
- package/src/state/internal.ts +77 -0
- package/src/state/parsers.test.ts +124 -0
- package/src/state/parsers.ts +309 -0
- package/src/state/persistence.ts +278 -0
- package/src/state/types.ts +694 -0
- package/src/state/ui-preferences.ts +3 -0
- package/src/state/useApp.ts +23 -0
- package/src/state/vrm.ts +76 -0
- package/src/stories/AppMockProvider.tsx +32 -0
- package/src/stories/ChatEmptyState.stories.tsx +27 -0
- package/src/stories/ChatMessage.stories.tsx +115 -0
- package/src/stories/CompanionHeader.stories.tsx +74 -0
- package/src/stories/CompanionView.stories.tsx +33 -0
- package/src/stories/ConversationListItem.stories.tsx +102 -0
- package/src/stories/TypingIndicator.stories.tsx +28 -0
- package/src/styles/anime.css +6324 -0
- package/src/styles/base.css +196 -0
- package/src/styles/onboarding-game.css +716 -0
- package/src/styles/styles.css +2085 -0
- package/src/styles/xterm.css +241 -0
- package/src/types/index.ts +715 -0
- package/src/types/react-test-renderer.d.ts +45 -0
- package/src/utils/asset-url.ts +110 -0
- package/src/utils/assistant-text.ts +172 -0
- package/src/utils/clipboard.ts +41 -0
- package/src/utils/desktop-dialogs.ts +80 -0
- package/src/utils/index.ts +6 -0
- package/src/utils/number-parsing.ts +125 -0
- package/src/utils/openExternalUrl.ts +20 -0
- package/src/utils/spoken-text.ts +65 -0
- package/src/utils/streaming-text.ts +120 -0
- package/src/voice/index.ts +1 -0
- package/src/voice/types.ts +197 -0
- package/test/app/AppContext.pty-sessions.test.tsx +143 -0
- package/test/app/MessageContent.test.tsx +326 -0
- package/test/app/PermissionsOnboarding.test.tsx +216 -0
- package/test/app/PermissionsSection.test.tsx +186 -0
- package/test/app/advanced-trajectory-fine-tuning.e2e.test.ts +397 -0
- package/test/app/agent-activity-box.test.tsx +132 -0
- package/test/app/agent-transfer-lock.test.ts +274 -0
- package/test/app/api-client-electron-fallback.test.ts +139 -0
- package/test/app/api-client-timeout.test.ts +75 -0
- package/test/app/api-client-ws.test.ts +98 -0
- package/test/app/api-client.ws-max-reconnect.test.ts +139 -0
- package/test/app/api-client.ws-reconnect.test.ts +157 -0
- package/test/app/app-context-autonomy-events.test.ts +478 -0
- package/test/app/apps-page-view.test.ts +114 -0
- package/test/app/apps-view.test.ts +769 -0
- package/test/app/autonomous-workflows.e2e.test.ts +765 -0
- package/test/app/autonomy-events.test.ts +150 -0
- package/test/app/avatar-selector.test.tsx +52 -0
- package/test/app/bsc-trade-panel.test.tsx +134 -0
- package/test/app/bug-report-modal.test.tsx +353 -0
- package/test/app/character-customization.e2e.test.ts +1168 -0
- package/test/app/chat-advanced-features.e2e.test.ts +706 -0
- package/test/app/chat-composer.test.tsx +181 -0
- package/test/app/chat-language-header.test.ts +64 -0
- package/test/app/chat-message.test.tsx +222 -0
- package/test/app/chat-modal-view.test.tsx +191 -0
- package/test/app/chat-routine-filter.test.ts +96 -0
- package/test/app/chat-send-lock.test.ts +1302 -0
- package/test/app/chat-stream-api-client.test.tsx +390 -0
- package/test/app/chat-view-game-modal.test.tsx +661 -0
- package/test/app/chat-view.test.tsx +877 -0
- package/test/app/cloud-api.e2e.test.ts +258 -0
- package/test/app/cloud-login-flow.e2e.test.ts +494 -0
- package/test/app/cloud-login-lock.test.ts +411 -0
- package/test/app/command-palette.test.tsx +184 -0
- package/test/app/command-registry.test.ts +75 -0
- package/test/app/companion-greeting-wave.test.tsx +443 -0
- package/test/app/companion-stale-conversation.test.tsx +424 -0
- package/test/app/companion-view.test.tsx +686 -0
- package/test/app/confirm-delete-control.test.ts +79 -0
- package/test/app/confirm-modal.test.tsx +219 -0
- package/test/app/connectors-ui.e2e.test.ts +508 -0
- package/test/app/conversations-sidebar-game-modal.test.tsx +260 -0
- package/test/app/conversations-sidebar.test.tsx +160 -0
- package/test/app/custom-actions-smoke.test.ts +387 -0
- package/test/app/custom-avatar-api-client.test.ts +207 -0
- package/test/app/desktop-utils.test.ts +145 -0
- package/test/app/electrobun-rpc-bridge.test.ts +83 -0
- package/test/app/events.test.ts +88 -0
- package/test/app/export-import-flows.e2e.test.ts +700 -0
- package/test/app/fine-tuning-view.test.ts +471 -0
- package/test/app/game-view-auth-session.test.tsx +186 -0
- package/test/app/game-view.test.ts +444 -0
- package/test/app/global-emote-overlay.test.tsx +106 -0
- package/test/app/header-status.test.tsx +149 -0
- package/test/app/i18n.test.ts +152 -0
- package/test/app/inventory-bsc-view.test.ts +908 -0
- package/test/app/knowledge-ui.e2e.test.ts +762 -0
- package/test/app/knowledge-upload-helpers.test.ts +124 -0
- package/test/app/lifecycle-lock.test.ts +267 -0
- package/test/app/lifo-popout-utils.test.ts +208 -0
- package/test/app/lifo-safe-endpoint.test.ts +34 -0
- package/test/app/loading-screen.test.tsx +45 -0
- package/test/app/memory-monitor.test.ts +332 -0
- package/test/app/navigation.test.tsx +29 -0
- package/test/app/onboarding-finish-lock.test.ts +500 -0
- package/test/app/onboarding-language.test.tsx +161 -0
- package/test/app/onboarding-steps.test.tsx +371 -0
- package/test/app/open-external-url.test.ts +65 -0
- package/test/app/pages-navigation-smoke.e2e.test.ts +633 -0
- package/test/app/pairing-lock.test.ts +260 -0
- package/test/app/pairing-view.test.tsx +74 -0
- package/test/app/permissions-section.test.ts +432 -0
- package/test/app/plugin-bridge.test.ts +109 -0
- package/test/app/plugins-ui.e2e.test.ts +605 -0
- package/test/app/plugins-view-game-modal.test.tsx +650 -0
- package/test/app/plugins-view-toggle-restart.test.ts +129 -0
- package/test/app/provider-dropdown-default.test.tsx +164 -0
- package/test/app/restart-banner.test.tsx +197 -0
- package/test/app/retake-capture.test.ts +84 -0
- package/test/app/sandbox-api-client.test.ts +108 -0
- package/test/app/save-command-modal.test.tsx +109 -0
- package/test/app/secrets-view.test.tsx +92 -0
- package/test/app/settings-control-styles.test.tsx +142 -0
- package/test/app/settings-reset.e2e.test.ts +728 -0
- package/test/app/settings-sections.e2e.test.ts +614 -0
- package/test/app/shared-format.test.ts +44 -0
- package/test/app/shared-switch.test.ts +69 -0
- package/test/app/shell-mode-switching.e2e.test.ts +829 -0
- package/test/app/shell-mode-tab-memory.test.tsx +283 -0
- package/test/app/shell-overlays.test.tsx +50 -0
- package/test/app/shortcuts-overlay.test.tsx +111 -0
- package/test/app/sse-interruption.test.ts +122 -0
- package/test/app/startup-asset-missing.e2e.test.ts +126 -0
- package/test/app/startup-backend-missing.e2e.test.ts +118 -0
- package/test/app/startup-chat.e2e.test.ts +305 -0
- package/test/app/startup-conversation-restore.test.tsx +344 -0
- package/test/app/startup-failure-view.test.tsx +103 -0
- package/test/app/startup-onboarding.e2e.test.ts +612 -0
- package/test/app/startup-timeout.test.tsx +80 -0
- package/test/app/startup-token-401.e2e.test.ts +103 -0
- package/test/app/stream-helpers.test.ts +46 -0
- package/test/app/stream-popout-navigation.test.tsx +41 -0
- package/test/app/stream-status-bar.test.tsx +89 -0
- package/test/app/theme-toggle.test.tsx +33 -0
- package/test/app/training-api-client.test.ts +128 -0
- package/test/app/trajectories-view.test.tsx +220 -0
- package/test/app/triggers-api-client.test.ts +77 -0
- package/test/app/triggers-navigation.test.ts +118 -0
- package/test/app/triggers-view.e2e.test.ts +674 -0
- package/test/app/update-channel-lock.test.ts +259 -0
- package/test/app/vector-browser.async-cleanup.test.tsx +367 -0
- package/test/app/vector-browser.e2e.test.ts +653 -0
- package/test/app/vrm-stage.test.tsx +351 -0
- package/test/app/vrm-viewer.test.tsx +298 -0
- package/test/app/wallet-api-save-lock.test.ts +277 -0
- package/test/app/wallet-hooks.test.ts +405 -0
- package/test/app/wallet-ui-flows.e2e.test.ts +556 -0
- package/test/avatar/asset-url.test.ts +90 -0
- package/test/avatar/avatar-selector.test.ts +173 -0
- package/test/avatar/mixamo-vrm-rig-map.test.ts +111 -0
- package/test/avatar/voice-chat-streaming-text.test.ts +96 -0
- package/test/avatar/voice-chat.test.ts +391 -0
- package/test/ui/command-palette-commands.test.ts +57 -0
- package/test/ui/ui-renderer.test.ts +39 -0
- package/tsconfig.build.json +19 -0
- package/tsconfig.json +21 -0
|
@@ -0,0 +1,1071 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bidirectional voice hook for chat + avatar lip sync.
|
|
3
|
+
*
|
|
4
|
+
* TTS providers (in priority order):
|
|
5
|
+
* 1. ElevenLabs — low-latency streaming endpoint + first-sentence cache.
|
|
6
|
+
* 2. Browser SpeechSynthesis — fallback when ElevenLabs isn't configured.
|
|
7
|
+
*
|
|
8
|
+
* STT: Web Speech API (SpeechRecognition) for user voice input.
|
|
9
|
+
*/
|
|
10
|
+
import { Capacitor } from "@capacitor/core";
|
|
11
|
+
import { useCallback, useEffect, useEffectEvent, useMemo, useRef, useState, } from "react";
|
|
12
|
+
import { getElectrobunRendererRpc } from "../bridge/electrobun-rpc";
|
|
13
|
+
import { getTalkModePlugin, } from "../bridge/native-plugins";
|
|
14
|
+
import { resolveApiUrl } from "../utils";
|
|
15
|
+
import { sanitizeSpeechText } from "../utils/spoken-text";
|
|
16
|
+
import { mergeStreamingText } from "../utils/streaming-text";
|
|
17
|
+
const DEFAULT_ELEVEN_MODEL = "eleven_flash_v2_5";
|
|
18
|
+
const DEFAULT_ELEVEN_VOICE = "EXAVITQu4vr4xnSDxMaL";
|
|
19
|
+
const MAX_SPOKEN_CHARS = 360;
|
|
20
|
+
const MAX_CACHED_SEGMENTS = 128;
|
|
21
|
+
const TALKMODE_STOP_SETTLE_MS = 120;
|
|
22
|
+
const REDACTED_SECRET = "[REDACTED]";
|
|
23
|
+
const MOUTH_OPEN_STEP = 0.02;
|
|
24
|
+
function resolveElevenProxyEndpoint() {
|
|
25
|
+
return resolveApiUrl("/api/tts/elevenlabs");
|
|
26
|
+
}
|
|
27
|
+
function toArrayBuffer(bytes) {
|
|
28
|
+
const out = new Uint8Array(bytes.byteLength);
|
|
29
|
+
out.set(bytes);
|
|
30
|
+
return out.buffer;
|
|
31
|
+
}
|
|
32
|
+
function collapseWhitespace(input) {
|
|
33
|
+
return input.replace(/\s+/g, " ").trim();
|
|
34
|
+
}
|
|
35
|
+
function normalizeMouthOpen(value) {
|
|
36
|
+
const clamped = Math.max(0, Math.min(1, value));
|
|
37
|
+
const stepped = Math.round(clamped / MOUTH_OPEN_STEP) * MOUTH_OPEN_STEP;
|
|
38
|
+
return stepped < MOUTH_OPEN_STEP ? 0 : Math.min(1, stepped);
|
|
39
|
+
}
|
|
40
|
+
export function nextIdleMouthOpen(currentValue) {
|
|
41
|
+
const current = normalizeMouthOpen(currentValue);
|
|
42
|
+
if (current <= MOUTH_OPEN_STEP) {
|
|
43
|
+
return 0;
|
|
44
|
+
}
|
|
45
|
+
return Math.max(0, Math.min(current * 0.85, current - MOUTH_OPEN_STEP));
|
|
46
|
+
}
|
|
47
|
+
function normalizeCacheText(input) {
|
|
48
|
+
// Preserve punctuation while normalizing spacing/casing.
|
|
49
|
+
return collapseWhitespace(input.normalize("NFKC")).toLowerCase();
|
|
50
|
+
}
|
|
51
|
+
function isRedactedSecret(value) {
|
|
52
|
+
return (typeof value === "string" && value.trim().toUpperCase() === REDACTED_SECRET);
|
|
53
|
+
}
|
|
54
|
+
function capSpeechLength(input) {
|
|
55
|
+
if (input.length <= MAX_SPOKEN_CHARS)
|
|
56
|
+
return input;
|
|
57
|
+
const clipped = input.slice(0, MAX_SPOKEN_CHARS);
|
|
58
|
+
const splitAt = clipped.lastIndexOf(" ");
|
|
59
|
+
const body = splitAt > 120 ? clipped.slice(0, splitAt) : clipped;
|
|
60
|
+
return `${body.trim()}...`;
|
|
61
|
+
}
|
|
62
|
+
function toSpeakableText(input) {
|
|
63
|
+
const normalized = sanitizeSpeechText(input);
|
|
64
|
+
if (!normalized)
|
|
65
|
+
return "";
|
|
66
|
+
return capSpeechLength(normalized);
|
|
67
|
+
}
|
|
68
|
+
function splitFirstSentence(text) {
|
|
69
|
+
const value = collapseWhitespace(text);
|
|
70
|
+
if (!value)
|
|
71
|
+
return { complete: false, firstSentence: "", remainder: "" };
|
|
72
|
+
const boundary = /([.!?]+(?:["')\]]+)?)(?:\s|$)/g;
|
|
73
|
+
const match = boundary.exec(value);
|
|
74
|
+
if (match && typeof match.index === "number") {
|
|
75
|
+
const endIndex = match.index + match[0].length;
|
|
76
|
+
const firstSentence = value.slice(0, endIndex).trim();
|
|
77
|
+
const remainder = value.slice(endIndex).trim();
|
|
78
|
+
if (firstSentence.length > 0) {
|
|
79
|
+
return { complete: true, firstSentence, remainder };
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// Fallback for long content with no punctuation yet.
|
|
83
|
+
if (value.length >= 180) {
|
|
84
|
+
const window = value.slice(0, 180);
|
|
85
|
+
const splitAt = window.lastIndexOf(" ");
|
|
86
|
+
if (splitAt > 100) {
|
|
87
|
+
return {
|
|
88
|
+
complete: true,
|
|
89
|
+
firstSentence: window.slice(0, splitAt).trim(),
|
|
90
|
+
remainder: value.slice(splitAt).trim(),
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return { complete: false, firstSentence: value, remainder: "" };
|
|
95
|
+
}
|
|
96
|
+
function remainderAfter(fullText, firstSentence) {
|
|
97
|
+
const full = collapseWhitespace(fullText);
|
|
98
|
+
const first = collapseWhitespace(firstSentence);
|
|
99
|
+
if (!full || !first)
|
|
100
|
+
return full;
|
|
101
|
+
if (full.startsWith(first))
|
|
102
|
+
return full.slice(first.length).trim();
|
|
103
|
+
const lowerFull = full.toLowerCase();
|
|
104
|
+
const lowerFirst = first.toLowerCase();
|
|
105
|
+
if (lowerFull.startsWith(lowerFirst)) {
|
|
106
|
+
return full.slice(first.length).trim();
|
|
107
|
+
}
|
|
108
|
+
const idx = lowerFull.indexOf(lowerFirst);
|
|
109
|
+
if (idx >= 0) {
|
|
110
|
+
return full.slice(idx + first.length).trim();
|
|
111
|
+
}
|
|
112
|
+
return "";
|
|
113
|
+
}
|
|
114
|
+
function queueableSpeechPrefix(text, isFinal) {
|
|
115
|
+
const value = collapseWhitespace(text);
|
|
116
|
+
if (!value)
|
|
117
|
+
return "";
|
|
118
|
+
if (isFinal)
|
|
119
|
+
return value;
|
|
120
|
+
let lastSentenceEnd = 0;
|
|
121
|
+
const boundary = /([.!?]+(?:["')\]]+)?)(?:\s|$)/g;
|
|
122
|
+
let match = null;
|
|
123
|
+
while (true) {
|
|
124
|
+
match = boundary.exec(value);
|
|
125
|
+
if (!match || typeof match.index !== "number")
|
|
126
|
+
break;
|
|
127
|
+
lastSentenceEnd = match.index + match[0].length;
|
|
128
|
+
}
|
|
129
|
+
if (lastSentenceEnd > 0) {
|
|
130
|
+
return value.slice(0, lastSentenceEnd).trim();
|
|
131
|
+
}
|
|
132
|
+
// Fallback for long content with no punctuation yet.
|
|
133
|
+
if (value.length >= 180) {
|
|
134
|
+
const window = value.slice(0, 180);
|
|
135
|
+
const splitAt = window.lastIndexOf(" ");
|
|
136
|
+
if (splitAt > 100) {
|
|
137
|
+
return window.slice(0, splitAt).trim();
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return "";
|
|
141
|
+
}
|
|
142
|
+
function cloneVoiceConfig(config) {
|
|
143
|
+
if (!config)
|
|
144
|
+
return null;
|
|
145
|
+
return {
|
|
146
|
+
...config,
|
|
147
|
+
elevenlabs: config.elevenlabs ? { ...config.elevenlabs } : undefined,
|
|
148
|
+
edge: config.edge ? { ...config.edge } : undefined,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
function resolveEffectiveVoiceConfig(config, options) {
|
|
152
|
+
const cloudConnected = options?.cloudConnected === true;
|
|
153
|
+
const base = cloneVoiceConfig(config) ?? {};
|
|
154
|
+
const provider = base.provider ??
|
|
155
|
+
(base.elevenlabs ? "elevenlabs" : base.edge ? "edge" : undefined) ??
|
|
156
|
+
(cloudConnected ? "elevenlabs" : undefined);
|
|
157
|
+
if (!provider)
|
|
158
|
+
return null;
|
|
159
|
+
if (provider !== "elevenlabs") {
|
|
160
|
+
return { ...base, provider };
|
|
161
|
+
}
|
|
162
|
+
const mode = base.mode ?? (cloudConnected ? "cloud" : "own-key");
|
|
163
|
+
const currentElevenLabs = base.elevenlabs ?? {};
|
|
164
|
+
const elevenlabs = {
|
|
165
|
+
...currentElevenLabs,
|
|
166
|
+
voiceId: currentElevenLabs.voiceId ?? DEFAULT_ELEVEN_VOICE,
|
|
167
|
+
modelId: currentElevenLabs.modelId ?? DEFAULT_ELEVEN_MODEL,
|
|
168
|
+
stability: typeof currentElevenLabs.stability === "number"
|
|
169
|
+
? currentElevenLabs.stability
|
|
170
|
+
: 0.5,
|
|
171
|
+
similarityBoost: typeof currentElevenLabs.similarityBoost === "number"
|
|
172
|
+
? currentElevenLabs.similarityBoost
|
|
173
|
+
: 0.75,
|
|
174
|
+
speed: typeof currentElevenLabs.speed === "number"
|
|
175
|
+
? currentElevenLabs.speed
|
|
176
|
+
: 1.0,
|
|
177
|
+
};
|
|
178
|
+
const apiKey = typeof currentElevenLabs.apiKey === "string"
|
|
179
|
+
? currentElevenLabs.apiKey.trim()
|
|
180
|
+
: "";
|
|
181
|
+
if (mode === "own-key" && apiKey && !isRedactedSecret(apiKey)) {
|
|
182
|
+
elevenlabs.apiKey = currentElevenLabs.apiKey;
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
delete elevenlabs.apiKey;
|
|
186
|
+
}
|
|
187
|
+
return {
|
|
188
|
+
...base,
|
|
189
|
+
provider,
|
|
190
|
+
mode,
|
|
191
|
+
elevenlabs,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
export const __voiceChatInternals = {
|
|
195
|
+
splitFirstSentence,
|
|
196
|
+
remainderAfter,
|
|
197
|
+
queueableSpeechPrefix,
|
|
198
|
+
resolveEffectiveVoiceConfig,
|
|
199
|
+
toSpeakableText,
|
|
200
|
+
};
|
|
201
|
+
function isAbortError(error) {
|
|
202
|
+
if (error instanceof DOMException && error.name === "AbortError")
|
|
203
|
+
return true;
|
|
204
|
+
if (error instanceof Error && error.name === "AbortError")
|
|
205
|
+
return true;
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
function shouldPreferNativeTalkMode() {
|
|
209
|
+
if (typeof window === "undefined")
|
|
210
|
+
return false;
|
|
211
|
+
if (getElectrobunRendererRpc())
|
|
212
|
+
return true;
|
|
213
|
+
return Capacitor.isNativePlatform();
|
|
214
|
+
}
|
|
215
|
+
// ── Hook ──────────────────────────────────────────────────────────────
|
|
216
|
+
export function useVoiceChat(options) {
|
|
217
|
+
const [isListening, setIsListening] = useState(false);
|
|
218
|
+
const [captureMode, setCaptureMode] = useState("idle");
|
|
219
|
+
const [isSpeaking, setIsSpeaking] = useState(false);
|
|
220
|
+
const [mouthOpen, setMouthOpen] = useState(0);
|
|
221
|
+
const [interimTranscript, setInterimTranscript] = useState("");
|
|
222
|
+
const [supported, setSupported] = useState(false);
|
|
223
|
+
const [usingAudioAnalysis, setUsingAudioAnalysis] = useState(false);
|
|
224
|
+
// Refs — stable across renders, read from animation loop & callbacks
|
|
225
|
+
const recognitionRef = useRef(null);
|
|
226
|
+
const sttBackendRef = useRef(null);
|
|
227
|
+
const talkModeHandlesRef = useRef([]);
|
|
228
|
+
const synthRef = useRef(null);
|
|
229
|
+
const utteranceRef = useRef(null);
|
|
230
|
+
const animFrameRef = useRef(0);
|
|
231
|
+
const speakingStartRef = useRef(0);
|
|
232
|
+
const speechTimeoutRef = useRef(null);
|
|
233
|
+
const enabledRef = useRef(false);
|
|
234
|
+
const listeningModeRef = useRef("idle");
|
|
235
|
+
const transcriptBufferRef = useRef("");
|
|
236
|
+
const emitTranscript = useEffectEvent((text) => {
|
|
237
|
+
options.onTranscript(text);
|
|
238
|
+
});
|
|
239
|
+
const emitTranscriptPreview = useEffectEvent((text, event) => {
|
|
240
|
+
options.onTranscriptPreview?.(text, event);
|
|
241
|
+
});
|
|
242
|
+
const emitPlaybackStart = useEffectEvent((event) => {
|
|
243
|
+
options.onPlaybackStart?.(event);
|
|
244
|
+
});
|
|
245
|
+
const effectiveVoiceConfig = useMemo(() => resolveEffectiveVoiceConfig(options.voiceConfig, {
|
|
246
|
+
cloudConnected: options.cloudConnected,
|
|
247
|
+
}), [options.cloudConnected, options.voiceConfig]);
|
|
248
|
+
// Voice config ref (latest value always available to callbacks)
|
|
249
|
+
const voiceConfigRef = useRef(effectiveVoiceConfig);
|
|
250
|
+
voiceConfigRef.current = effectiveVoiceConfig;
|
|
251
|
+
const interruptOnSpeechRef = useRef(options.interruptOnSpeech ?? true);
|
|
252
|
+
interruptOnSpeechRef.current = options.interruptOnSpeech ?? true;
|
|
253
|
+
const interruptSpeechRef = useRef(() => { });
|
|
254
|
+
// ── ElevenLabs Web Audio refs ──────────────────────────────────────
|
|
255
|
+
const audioCtxRef = useRef(null);
|
|
256
|
+
const analyserRef = useRef(null);
|
|
257
|
+
const audioSourceRef = useRef(null);
|
|
258
|
+
const timeDomainDataRef = useRef(null);
|
|
259
|
+
const usingAudioAnalysisRef = useRef(false);
|
|
260
|
+
const mouthOpenRef = useRef(0);
|
|
261
|
+
mouthOpenRef.current = mouthOpen;
|
|
262
|
+
// ── Progressive speech queue state ────────────────────────────────
|
|
263
|
+
const queueRef = useRef([]);
|
|
264
|
+
const queueWorkerRunningRef = useRef(false);
|
|
265
|
+
const generationRef = useRef(0);
|
|
266
|
+
const activeTaskFinishRef = useRef(null);
|
|
267
|
+
const activeFetchAbortRef = useRef(null);
|
|
268
|
+
const assistantSpeechRef = useRef(null);
|
|
269
|
+
const elevenCacheRef = useRef(new Map());
|
|
270
|
+
const clearSpeechTimers = useCallback(() => {
|
|
271
|
+
if (speechTimeoutRef.current) {
|
|
272
|
+
clearTimeout(speechTimeoutRef.current);
|
|
273
|
+
speechTimeoutRef.current = null;
|
|
274
|
+
}
|
|
275
|
+
}, []);
|
|
276
|
+
const rememberCachedSegment = useCallback((key, bytes) => {
|
|
277
|
+
const cache = elevenCacheRef.current;
|
|
278
|
+
cache.delete(key);
|
|
279
|
+
cache.set(key, bytes);
|
|
280
|
+
if (cache.size <= MAX_CACHED_SEGMENTS)
|
|
281
|
+
return;
|
|
282
|
+
const oldest = cache.keys().next().value;
|
|
283
|
+
if (oldest)
|
|
284
|
+
cache.delete(oldest);
|
|
285
|
+
}, []);
|
|
286
|
+
const makeElevenCacheKey = useCallback((text, config) => {
|
|
287
|
+
const voiceId = config.voiceId ?? DEFAULT_ELEVEN_VOICE;
|
|
288
|
+
const modelId = config.modelId ?? DEFAULT_ELEVEN_MODEL;
|
|
289
|
+
const stability = typeof config.stability === "number"
|
|
290
|
+
? config.stability.toFixed(2)
|
|
291
|
+
: "0.50";
|
|
292
|
+
const similarity = typeof config.similarityBoost === "number"
|
|
293
|
+
? config.similarityBoost.toFixed(2)
|
|
294
|
+
: "0.75";
|
|
295
|
+
const speed = typeof config.speed === "number" ? config.speed.toFixed(2) : "1.00";
|
|
296
|
+
return [
|
|
297
|
+
voiceId,
|
|
298
|
+
modelId,
|
|
299
|
+
stability,
|
|
300
|
+
similarity,
|
|
301
|
+
speed,
|
|
302
|
+
normalizeCacheText(text),
|
|
303
|
+
].join("|");
|
|
304
|
+
}, []);
|
|
305
|
+
const updateMouthOpen = useCallback((value) => {
|
|
306
|
+
const previousValue = mouthOpenRef.current;
|
|
307
|
+
const resolvedValue = typeof value === "function" ? value(previousValue) : value;
|
|
308
|
+
const nextValue = normalizeMouthOpen(resolvedValue);
|
|
309
|
+
if (nextValue === previousValue) {
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
mouthOpenRef.current = nextValue;
|
|
313
|
+
setMouthOpen(nextValue);
|
|
314
|
+
}, []);
|
|
315
|
+
// ── Init ──────────────────────────────────────────────────────────
|
|
316
|
+
useEffect(() => {
|
|
317
|
+
const SpeechRecognitionAPI = window.SpeechRecognition ?? window.webkitSpeechRecognition;
|
|
318
|
+
const canUseMicrophone = typeof navigator !== "undefined" &&
|
|
319
|
+
typeof navigator.mediaDevices?.getUserMedia === "function";
|
|
320
|
+
setSupported(shouldPreferNativeTalkMode()
|
|
321
|
+
? canUseMicrophone || !!SpeechRecognitionAPI
|
|
322
|
+
: !!SpeechRecognitionAPI);
|
|
323
|
+
synthRef.current = window.speechSynthesis ?? null;
|
|
324
|
+
}, []);
|
|
325
|
+
useEffect(() => {
|
|
326
|
+
elevenCacheRef.current.clear();
|
|
327
|
+
}, []);
|
|
328
|
+
// ── Mouth animation loop ──────────────────────────────────────────
|
|
329
|
+
useEffect(() => {
|
|
330
|
+
let frameId = 0;
|
|
331
|
+
const animate = () => {
|
|
332
|
+
if (!isSpeaking) {
|
|
333
|
+
const nextMouthOpen = nextIdleMouthOpen(mouthOpenRef.current);
|
|
334
|
+
updateMouthOpen(nextMouthOpen);
|
|
335
|
+
if (nextMouthOpen > 0) {
|
|
336
|
+
frameId = requestAnimationFrame(animate);
|
|
337
|
+
animFrameRef.current = frameId;
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
animFrameRef.current = 0;
|
|
341
|
+
}
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
// ── ElevenLabs: real audio volume analysis ────────────────────
|
|
345
|
+
if (usingAudioAnalysisRef.current) {
|
|
346
|
+
const analyser = analyserRef.current;
|
|
347
|
+
const data = timeDomainDataRef.current;
|
|
348
|
+
if (analyser && data) {
|
|
349
|
+
analyser.getFloatTimeDomainData(data);
|
|
350
|
+
let sum = 0;
|
|
351
|
+
for (let i = 0; i < data.length; i++) {
|
|
352
|
+
const v = data[i] ?? 0;
|
|
353
|
+
sum += v * v;
|
|
354
|
+
}
|
|
355
|
+
const rms = Math.sqrt(sum / data.length);
|
|
356
|
+
const volume = Math.max(0, Math.min(1, 1 / (1 + Math.exp(-(rms * 30 - 2)))));
|
|
357
|
+
updateMouthOpen(volume);
|
|
358
|
+
}
|
|
359
|
+
frameId = requestAnimationFrame(animate);
|
|
360
|
+
animFrameRef.current = frameId;
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
// ── Browser TTS: sine-wave mouth + safety check ──────────────
|
|
364
|
+
const sinceStart = Date.now() - speakingStartRef.current;
|
|
365
|
+
if (sinceStart > 500 &&
|
|
366
|
+
synthRef.current &&
|
|
367
|
+
!synthRef.current.speaking &&
|
|
368
|
+
!synthRef.current.pending) {
|
|
369
|
+
utteranceRef.current = null;
|
|
370
|
+
setIsSpeaking(false);
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
const elapsed = sinceStart / 1000;
|
|
374
|
+
const base = Math.sin(elapsed * 12) * 0.3 + 0.4;
|
|
375
|
+
const detail = Math.sin(elapsed * 18.7) * 0.15;
|
|
376
|
+
const slow = Math.sin(elapsed * 4.2) * 0.1;
|
|
377
|
+
updateMouthOpen(Math.max(0, Math.min(1, base + detail + slow)));
|
|
378
|
+
frameId = requestAnimationFrame(animate);
|
|
379
|
+
animFrameRef.current = frameId;
|
|
380
|
+
};
|
|
381
|
+
if (isSpeaking || mouthOpenRef.current > 0) {
|
|
382
|
+
frameId = requestAnimationFrame(animate);
|
|
383
|
+
animFrameRef.current = frameId;
|
|
384
|
+
}
|
|
385
|
+
else {
|
|
386
|
+
animFrameRef.current = 0;
|
|
387
|
+
}
|
|
388
|
+
return () => {
|
|
389
|
+
cancelAnimationFrame(frameId);
|
|
390
|
+
if (animFrameRef.current === frameId) {
|
|
391
|
+
animFrameRef.current = 0;
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
}, [isSpeaking, updateMouthOpen]);
|
|
395
|
+
// ── STT (Speech Recognition) ──────────────────────────────────────
|
|
396
|
+
const applyTranscriptUpdate = useCallback((transcript, isFinal) => {
|
|
397
|
+
const mode = listeningModeRef.current;
|
|
398
|
+
if (mode === "idle")
|
|
399
|
+
return;
|
|
400
|
+
const normalized = collapseWhitespace(transcript);
|
|
401
|
+
if (!normalized)
|
|
402
|
+
return;
|
|
403
|
+
const nextText = mergeStreamingText(transcriptBufferRef.current, normalized);
|
|
404
|
+
if (nextText === transcriptBufferRef.current)
|
|
405
|
+
return;
|
|
406
|
+
transcriptBufferRef.current = nextText;
|
|
407
|
+
setInterimTranscript(nextText);
|
|
408
|
+
emitTranscriptPreview(nextText, {
|
|
409
|
+
mode,
|
|
410
|
+
isFinal,
|
|
411
|
+
});
|
|
412
|
+
if (interruptOnSpeechRef.current) {
|
|
413
|
+
interruptSpeechRef.current();
|
|
414
|
+
}
|
|
415
|
+
}, []);
|
|
416
|
+
const removeTalkModeListeners = useCallback(async () => {
|
|
417
|
+
const handles = talkModeHandlesRef.current;
|
|
418
|
+
talkModeHandlesRef.current = [];
|
|
419
|
+
await Promise.all(handles.map((handle) => handle.remove().catch(() => {
|
|
420
|
+
/* ignore */
|
|
421
|
+
})));
|
|
422
|
+
}, []);
|
|
423
|
+
const ensureTalkModeListeners = useCallback(async () => {
|
|
424
|
+
if (talkModeHandlesRef.current.length > 0)
|
|
425
|
+
return;
|
|
426
|
+
const talkMode = getTalkModePlugin();
|
|
427
|
+
const transcriptHandle = await talkMode.addListener("transcript", (event) => {
|
|
428
|
+
applyTranscriptUpdate(event.transcript ?? "", event.isFinal === true);
|
|
429
|
+
});
|
|
430
|
+
const errorHandle = await talkMode.addListener("error", (event) => {
|
|
431
|
+
if (event.code === "not-allowed" ||
|
|
432
|
+
event.code === "service-not-allowed") {
|
|
433
|
+
enabledRef.current = false;
|
|
434
|
+
listeningModeRef.current = "idle";
|
|
435
|
+
sttBackendRef.current = null;
|
|
436
|
+
setCaptureMode("idle");
|
|
437
|
+
setIsListening(false);
|
|
438
|
+
}
|
|
439
|
+
});
|
|
440
|
+
const stateHandle = await talkMode.addListener("stateChange", (event) => {
|
|
441
|
+
if (event.state === "error" || event.state === "idle") {
|
|
442
|
+
if (!enabledRef.current) {
|
|
443
|
+
setIsListening(false);
|
|
444
|
+
setCaptureMode("idle");
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
talkModeHandlesRef.current = [transcriptHandle, errorHandle, stateHandle];
|
|
449
|
+
}, [applyTranscriptUpdate]);
|
|
450
|
+
const startBrowserRecognition = useCallback((mode) => {
|
|
451
|
+
const SpeechRecognitionAPI = window.SpeechRecognition ?? window.webkitSpeechRecognition;
|
|
452
|
+
if (!SpeechRecognitionAPI)
|
|
453
|
+
return false;
|
|
454
|
+
const recognition = new SpeechRecognitionAPI();
|
|
455
|
+
recognition.continuous = true;
|
|
456
|
+
recognition.interimResults = true;
|
|
457
|
+
recognition.lang = options.lang ?? "en-US";
|
|
458
|
+
recognition.onresult = (event) => {
|
|
459
|
+
let transcript = "";
|
|
460
|
+
let isFinal = false;
|
|
461
|
+
for (let index = 0; index < event.results.length; index += 1) {
|
|
462
|
+
const result = event.results[index];
|
|
463
|
+
const chunk = result?.[0]?.transcript ?? "";
|
|
464
|
+
if (chunk) {
|
|
465
|
+
transcript = transcript ? `${transcript} ${chunk}` : chunk;
|
|
466
|
+
}
|
|
467
|
+
if (result?.isFinal) {
|
|
468
|
+
isFinal = true;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
applyTranscriptUpdate(transcript, isFinal);
|
|
472
|
+
};
|
|
473
|
+
recognition.onerror = (event) => {
|
|
474
|
+
if (event.error === "not-allowed" ||
|
|
475
|
+
event.error === "service-not-allowed") {
|
|
476
|
+
enabledRef.current = false;
|
|
477
|
+
listeningModeRef.current = "idle";
|
|
478
|
+
sttBackendRef.current = null;
|
|
479
|
+
setCaptureMode("idle");
|
|
480
|
+
setIsListening(false);
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
recognition.onend = () => {
|
|
484
|
+
if (enabledRef.current && listeningModeRef.current === mode) {
|
|
485
|
+
try {
|
|
486
|
+
recognition.start();
|
|
487
|
+
}
|
|
488
|
+
catch {
|
|
489
|
+
/* already started */
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
recognitionRef.current = recognition;
|
|
494
|
+
try {
|
|
495
|
+
recognition.start();
|
|
496
|
+
sttBackendRef.current = "browser";
|
|
497
|
+
enabledRef.current = true;
|
|
498
|
+
listeningModeRef.current = mode;
|
|
499
|
+
setCaptureMode(mode);
|
|
500
|
+
setIsListening(true);
|
|
501
|
+
return true;
|
|
502
|
+
}
|
|
503
|
+
catch {
|
|
504
|
+
recognitionRef.current = null;
|
|
505
|
+
return false;
|
|
506
|
+
}
|
|
507
|
+
}, [applyTranscriptUpdate, options.lang]);
|
|
508
|
+
const startTalkModeRecognition = useCallback(async (mode) => {
|
|
509
|
+
await ensureTalkModeListeners();
|
|
510
|
+
try {
|
|
511
|
+
const talkMode = getTalkModePlugin();
|
|
512
|
+
const permissions = await talkMode.checkPermissions().catch(() => null);
|
|
513
|
+
if (permissions?.microphone === "prompt") {
|
|
514
|
+
await talkMode.requestPermissions().catch(() => {
|
|
515
|
+
/* ignore */
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
const directRpc = getElectrobunRendererRpc();
|
|
519
|
+
const result = await talkMode.start({
|
|
520
|
+
config: {
|
|
521
|
+
stt: {
|
|
522
|
+
...(directRpc ? { engine: "whisper" } : {}),
|
|
523
|
+
language: options.lang ?? "en-US",
|
|
524
|
+
modelSize: "base",
|
|
525
|
+
sampleRate: 16000,
|
|
526
|
+
},
|
|
527
|
+
silenceWindowMs: 350,
|
|
528
|
+
interruptOnSpeech: true,
|
|
529
|
+
},
|
|
530
|
+
});
|
|
531
|
+
if (!result.started) {
|
|
532
|
+
return false;
|
|
533
|
+
}
|
|
534
|
+
enabledRef.current = true;
|
|
535
|
+
listeningModeRef.current = mode;
|
|
536
|
+
sttBackendRef.current = "talkmode";
|
|
537
|
+
setCaptureMode(mode);
|
|
538
|
+
setIsListening(true);
|
|
539
|
+
return true;
|
|
540
|
+
}
|
|
541
|
+
catch {
|
|
542
|
+
return false;
|
|
543
|
+
}
|
|
544
|
+
}, [ensureTalkModeListeners, options.lang]);
|
|
545
|
+
const finalizeRecognition = useCallback((submit) => {
|
|
546
|
+
const transcript = collapseWhitespace(transcriptBufferRef.current);
|
|
547
|
+
if (submit && transcript) {
|
|
548
|
+
emitTranscript(transcript);
|
|
549
|
+
}
|
|
550
|
+
transcriptBufferRef.current = "";
|
|
551
|
+
recognitionRef.current = null;
|
|
552
|
+
sttBackendRef.current = null;
|
|
553
|
+
enabledRef.current = false;
|
|
554
|
+
listeningModeRef.current = "idle";
|
|
555
|
+
setIsListening(false);
|
|
556
|
+
setCaptureMode("idle");
|
|
557
|
+
setInterimTranscript("");
|
|
558
|
+
}, []);
|
|
559
|
+
const startListening = useCallback(async (mode = "compose") => {
|
|
560
|
+
if (enabledRef.current)
|
|
561
|
+
return;
|
|
562
|
+
transcriptBufferRef.current = "";
|
|
563
|
+
setInterimTranscript("");
|
|
564
|
+
if (interruptOnSpeechRef.current) {
|
|
565
|
+
interruptSpeechRef.current();
|
|
566
|
+
}
|
|
567
|
+
if (shouldPreferNativeTalkMode()) {
|
|
568
|
+
const started = await startTalkModeRecognition(mode);
|
|
569
|
+
if (started) {
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
startBrowserRecognition(mode);
|
|
574
|
+
}, [startBrowserRecognition, startTalkModeRecognition]);
|
|
575
|
+
const stopListening = useCallback(async (options) => {
|
|
576
|
+
const mode = listeningModeRef.current;
|
|
577
|
+
if (mode === "idle")
|
|
578
|
+
return;
|
|
579
|
+
const submit = options?.submit === true;
|
|
580
|
+
enabledRef.current = false;
|
|
581
|
+
if (sttBackendRef.current === "talkmode") {
|
|
582
|
+
await getTalkModePlugin()
|
|
583
|
+
.stop()
|
|
584
|
+
.catch(() => {
|
|
585
|
+
/* ignore */
|
|
586
|
+
});
|
|
587
|
+
await new Promise((resolve) => window.setTimeout(resolve, TALKMODE_STOP_SETTLE_MS));
|
|
588
|
+
}
|
|
589
|
+
else {
|
|
590
|
+
recognitionRef.current?.stop();
|
|
591
|
+
await new Promise((resolve) => window.setTimeout(resolve, TALKMODE_STOP_SETTLE_MS));
|
|
592
|
+
}
|
|
593
|
+
finalizeRecognition(submit);
|
|
594
|
+
}, [finalizeRecognition]);
|
|
595
|
+
const toggleListening = useCallback(() => {
|
|
596
|
+
if (enabledRef.current && listeningModeRef.current === "compose") {
|
|
597
|
+
void stopListening();
|
|
598
|
+
return;
|
|
599
|
+
}
|
|
600
|
+
if (enabledRef.current)
|
|
601
|
+
return;
|
|
602
|
+
void startListening("compose");
|
|
603
|
+
}, [startListening, stopListening]);
|
|
604
|
+
// ── Cancel helpers ────────────────────────────────────────────────
|
|
605
|
+
/** Stop all in-progress speech playback/requests but keep assistant queue state. */
|
|
606
|
+
const cancelPlayback = useCallback(() => {
|
|
607
|
+
generationRef.current += 1;
|
|
608
|
+
queueRef.current = [];
|
|
609
|
+
activeFetchAbortRef.current?.abort();
|
|
610
|
+
activeFetchAbortRef.current = null;
|
|
611
|
+
activeTaskFinishRef.current?.();
|
|
612
|
+
activeTaskFinishRef.current = null;
|
|
613
|
+
// Browser TTS
|
|
614
|
+
synthRef.current?.cancel();
|
|
615
|
+
utteranceRef.current = null;
|
|
616
|
+
// ElevenLabs audio
|
|
617
|
+
if (audioSourceRef.current) {
|
|
618
|
+
try {
|
|
619
|
+
audioSourceRef.current.stop();
|
|
620
|
+
}
|
|
621
|
+
catch {
|
|
622
|
+
/* ok */
|
|
623
|
+
}
|
|
624
|
+
try {
|
|
625
|
+
audioSourceRef.current.disconnect();
|
|
626
|
+
}
|
|
627
|
+
catch {
|
|
628
|
+
/* ok */
|
|
629
|
+
}
|
|
630
|
+
audioSourceRef.current = null;
|
|
631
|
+
}
|
|
632
|
+
clearSpeechTimers();
|
|
633
|
+
usingAudioAnalysisRef.current = false;
|
|
634
|
+
setUsingAudioAnalysis(false);
|
|
635
|
+
}, [clearSpeechTimers]);
|
|
636
|
+
const stopSpeaking = useCallback(() => {
|
|
637
|
+
assistantSpeechRef.current = null;
|
|
638
|
+
cancelPlayback();
|
|
639
|
+
setIsSpeaking(false);
|
|
640
|
+
setUsingAudioAnalysis(false);
|
|
641
|
+
}, [cancelPlayback]);
|
|
642
|
+
interruptSpeechRef.current = stopSpeaking;
|
|
643
|
+
// ── ElevenLabs TTS ────────────────────────────────────────────────
|
|
644
|
+
const speakElevenLabs = useCallback(async (text, elConfig, task, generation) => {
|
|
645
|
+
let ctx = audioCtxRef.current;
|
|
646
|
+
if (!ctx) {
|
|
647
|
+
ctx = new AudioContext();
|
|
648
|
+
audioCtxRef.current = ctx;
|
|
649
|
+
}
|
|
650
|
+
if (ctx.state === "suspended") {
|
|
651
|
+
try {
|
|
652
|
+
await ctx.resume();
|
|
653
|
+
}
|
|
654
|
+
catch {
|
|
655
|
+
// Force a fresh context if resume fails
|
|
656
|
+
ctx.close().catch(() => { });
|
|
657
|
+
ctx = new AudioContext();
|
|
658
|
+
audioCtxRef.current = ctx;
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
const voiceId = elConfig.voiceId ?? DEFAULT_ELEVEN_VOICE;
|
|
662
|
+
const modelId = elConfig.modelId ?? DEFAULT_ELEVEN_MODEL;
|
|
663
|
+
const cacheKey = task.cacheKey ?? makeElevenCacheKey(text, elConfig);
|
|
664
|
+
const cachedBytes = elevenCacheRef.current.get(cacheKey);
|
|
665
|
+
let audioBytes = null;
|
|
666
|
+
let cached = false;
|
|
667
|
+
if (cachedBytes) {
|
|
668
|
+
elevenCacheRef.current.delete(cacheKey);
|
|
669
|
+
elevenCacheRef.current.set(cacheKey, cachedBytes);
|
|
670
|
+
audioBytes = cachedBytes.slice();
|
|
671
|
+
cached = true;
|
|
672
|
+
}
|
|
673
|
+
if (!audioBytes) {
|
|
674
|
+
const controller = new AbortController();
|
|
675
|
+
activeFetchAbortRef.current = controller;
|
|
676
|
+
const requestBody = {
|
|
677
|
+
text,
|
|
678
|
+
model_id: modelId,
|
|
679
|
+
apply_text_normalization: "auto",
|
|
680
|
+
voice_settings: {
|
|
681
|
+
stability: elConfig.stability ?? 0.5,
|
|
682
|
+
similarity_boost: elConfig.similarityBoost ?? 0.75,
|
|
683
|
+
speed: elConfig.speed ?? 1.0,
|
|
684
|
+
},
|
|
685
|
+
};
|
|
686
|
+
const apiToken = typeof window !== "undefined" &&
|
|
687
|
+
typeof window.__MILADY_API_TOKEN__ === "string"
|
|
688
|
+
? window.__MILADY_API_TOKEN__.trim()
|
|
689
|
+
: "";
|
|
690
|
+
const fetchViaProxy = async () => {
|
|
691
|
+
return fetch(resolveElevenProxyEndpoint(), {
|
|
692
|
+
method: "POST",
|
|
693
|
+
headers: {
|
|
694
|
+
"Content-Type": "application/json",
|
|
695
|
+
Accept: "audio/mpeg",
|
|
696
|
+
...(apiToken ? { Authorization: `Bearer ${apiToken}` } : {}),
|
|
697
|
+
},
|
|
698
|
+
body: JSON.stringify({
|
|
699
|
+
...requestBody,
|
|
700
|
+
voiceId,
|
|
701
|
+
modelId,
|
|
702
|
+
outputFormat: "mp3_44100_128",
|
|
703
|
+
}),
|
|
704
|
+
signal: controller.signal,
|
|
705
|
+
});
|
|
706
|
+
};
|
|
707
|
+
const trimmedApiKey = typeof elConfig.apiKey === "string" ? elConfig.apiKey.trim() : "";
|
|
708
|
+
const hasDirectKey = trimmedApiKey.length > 0 && !isRedactedSecret(trimmedApiKey);
|
|
709
|
+
let res;
|
|
710
|
+
if (hasDirectKey) {
|
|
711
|
+
try {
|
|
712
|
+
const url = new URL(`https://api.elevenlabs.io/v1/text-to-speech/${encodeURIComponent(voiceId)}/stream`);
|
|
713
|
+
url.searchParams.set("output_format", "mp3_44100_128");
|
|
714
|
+
res = await fetch(url.toString(), {
|
|
715
|
+
method: "POST",
|
|
716
|
+
headers: {
|
|
717
|
+
"xi-api-key": trimmedApiKey,
|
|
718
|
+
"Content-Type": "application/json",
|
|
719
|
+
Accept: "audio/mpeg",
|
|
720
|
+
},
|
|
721
|
+
body: JSON.stringify(requestBody),
|
|
722
|
+
signal: controller.signal,
|
|
723
|
+
});
|
|
724
|
+
}
|
|
725
|
+
catch {
|
|
726
|
+
res = await fetchViaProxy();
|
|
727
|
+
}
|
|
728
|
+
// If the locally-available key is stale, fall back to server-side key.
|
|
729
|
+
if (!res.ok && (res.status === 401 || res.status === 403)) {
|
|
730
|
+
const proxyRes = await fetchViaProxy();
|
|
731
|
+
if (proxyRes.ok) {
|
|
732
|
+
res = proxyRes;
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
else {
|
|
737
|
+
res = await fetchViaProxy();
|
|
738
|
+
}
|
|
739
|
+
if (activeFetchAbortRef.current === controller) {
|
|
740
|
+
activeFetchAbortRef.current = null;
|
|
741
|
+
}
|
|
742
|
+
if (!res.ok) {
|
|
743
|
+
const body = await res.text().catch(() => "");
|
|
744
|
+
throw new Error(`ElevenLabs ${res.status}: ${body.slice(0, 200)}`);
|
|
745
|
+
}
|
|
746
|
+
const audioData = await res.arrayBuffer();
|
|
747
|
+
audioBytes = new Uint8Array(audioData);
|
|
748
|
+
rememberCachedSegment(cacheKey, audioBytes.slice());
|
|
749
|
+
}
|
|
750
|
+
if (generation !== generationRef.current)
|
|
751
|
+
return;
|
|
752
|
+
const audioBuffer = await ctx.decodeAudioData(toArrayBuffer(audioBytes));
|
|
753
|
+
if (generation !== generationRef.current)
|
|
754
|
+
return;
|
|
755
|
+
const analyser = ctx.createAnalyser();
|
|
756
|
+
analyser.fftSize = 2048;
|
|
757
|
+
analyser.smoothingTimeConstant = 0.8;
|
|
758
|
+
analyserRef.current = analyser;
|
|
759
|
+
timeDomainDataRef.current = new Float32Array(new ArrayBuffer(analyser.fftSize * Float32Array.BYTES_PER_ELEMENT));
|
|
760
|
+
const source = ctx.createBufferSource();
|
|
761
|
+
source.buffer = audioBuffer;
|
|
762
|
+
source.connect(analyser);
|
|
763
|
+
analyser.connect(ctx.destination);
|
|
764
|
+
audioSourceRef.current = source;
|
|
765
|
+
await new Promise((resolve) => {
|
|
766
|
+
let finished = false;
|
|
767
|
+
const finish = () => {
|
|
768
|
+
if (finished)
|
|
769
|
+
return;
|
|
770
|
+
finished = true;
|
|
771
|
+
if (activeTaskFinishRef.current === finish) {
|
|
772
|
+
activeTaskFinishRef.current = null;
|
|
773
|
+
}
|
|
774
|
+
if (audioSourceRef.current === source) {
|
|
775
|
+
audioSourceRef.current = null;
|
|
776
|
+
}
|
|
777
|
+
source.onended = null;
|
|
778
|
+
try {
|
|
779
|
+
source.disconnect();
|
|
780
|
+
}
|
|
781
|
+
catch {
|
|
782
|
+
/* ok */
|
|
783
|
+
}
|
|
784
|
+
try {
|
|
785
|
+
analyser.disconnect();
|
|
786
|
+
}
|
|
787
|
+
catch {
|
|
788
|
+
/* ok */
|
|
789
|
+
}
|
|
790
|
+
clearSpeechTimers();
|
|
791
|
+
resolve();
|
|
792
|
+
};
|
|
793
|
+
activeTaskFinishRef.current = finish;
|
|
794
|
+
source.onended = finish;
|
|
795
|
+
speechTimeoutRef.current = setTimeout(finish, Math.max(2500, Math.ceil(audioBuffer.duration * 1000) + 1200));
|
|
796
|
+
source.start(0);
|
|
797
|
+
emitPlaybackStart({
|
|
798
|
+
text,
|
|
799
|
+
segment: task.segment,
|
|
800
|
+
provider: "elevenlabs",
|
|
801
|
+
cached,
|
|
802
|
+
startedAtMs: performance.now(),
|
|
803
|
+
});
|
|
804
|
+
});
|
|
805
|
+
}, [clearSpeechTimers, makeElevenCacheKey, rememberCachedSegment]);
|
|
806
|
+
// ── Browser SpeechSynthesis TTS ───────────────────────────────────
|
|
807
|
+
const speakBrowser = useCallback((text, task, generation) => {
|
|
808
|
+
const synth = synthRef.current;
|
|
809
|
+
const words = text.trim().split(/\s+/).length;
|
|
810
|
+
const estimatedMs = Math.max(1200, (words / 3) * 1000);
|
|
811
|
+
return new Promise((resolve) => {
|
|
812
|
+
let finished = false;
|
|
813
|
+
const finish = () => {
|
|
814
|
+
if (finished)
|
|
815
|
+
return;
|
|
816
|
+
finished = true;
|
|
817
|
+
if (activeTaskFinishRef.current === finish) {
|
|
818
|
+
activeTaskFinishRef.current = null;
|
|
819
|
+
}
|
|
820
|
+
clearSpeechTimers();
|
|
821
|
+
utteranceRef.current = null;
|
|
822
|
+
resolve();
|
|
823
|
+
};
|
|
824
|
+
activeTaskFinishRef.current = finish;
|
|
825
|
+
if (!synth) {
|
|
826
|
+
emitPlaybackStart({
|
|
827
|
+
text,
|
|
828
|
+
segment: task.segment,
|
|
829
|
+
provider: "browser",
|
|
830
|
+
cached: false,
|
|
831
|
+
startedAtMs: performance.now(),
|
|
832
|
+
});
|
|
833
|
+
speechTimeoutRef.current = setTimeout(finish, estimatedMs);
|
|
834
|
+
return;
|
|
835
|
+
}
|
|
836
|
+
const utterance = new SpeechSynthesisUtterance(text.trim());
|
|
837
|
+
utteranceRef.current = utterance;
|
|
838
|
+
utterance.rate = 1.0;
|
|
839
|
+
utterance.pitch = 1.0;
|
|
840
|
+
utterance.onstart = () => {
|
|
841
|
+
if (generation !== generationRef.current)
|
|
842
|
+
return;
|
|
843
|
+
emitPlaybackStart({
|
|
844
|
+
text,
|
|
845
|
+
segment: task.segment,
|
|
846
|
+
provider: "browser",
|
|
847
|
+
cached: false,
|
|
848
|
+
startedAtMs: performance.now(),
|
|
849
|
+
});
|
|
850
|
+
};
|
|
851
|
+
utterance.onend = finish;
|
|
852
|
+
utterance.onerror = finish;
|
|
853
|
+
synth.speak(utterance);
|
|
854
|
+
speechTimeoutRef.current = setTimeout(finish, estimatedMs + 5000);
|
|
855
|
+
});
|
|
856
|
+
}, [clearSpeechTimers]);
|
|
857
|
+
const processQueue = useCallback(() => {
|
|
858
|
+
if (queueWorkerRunningRef.current)
|
|
859
|
+
return;
|
|
860
|
+
queueWorkerRunningRef.current = true;
|
|
861
|
+
const workerGeneration = generationRef.current;
|
|
862
|
+
void (async () => {
|
|
863
|
+
try {
|
|
864
|
+
while (queueRef.current.length > 0) {
|
|
865
|
+
if (workerGeneration !== generationRef.current)
|
|
866
|
+
return;
|
|
867
|
+
const task = queueRef.current.shift();
|
|
868
|
+
if (!task)
|
|
869
|
+
break;
|
|
870
|
+
const config = voiceConfigRef.current;
|
|
871
|
+
const elConfig = config?.elevenlabs;
|
|
872
|
+
const useElevenLabs = config?.provider === "elevenlabs";
|
|
873
|
+
if (useElevenLabs && elConfig) {
|
|
874
|
+
usingAudioAnalysisRef.current = true;
|
|
875
|
+
setUsingAudioAnalysis(true);
|
|
876
|
+
try {
|
|
877
|
+
await speakElevenLabs(task.text, elConfig, task, workerGeneration);
|
|
878
|
+
continue;
|
|
879
|
+
}
|
|
880
|
+
catch (error) {
|
|
881
|
+
if (workerGeneration !== generationRef.current ||
|
|
882
|
+
isAbortError(error)) {
|
|
883
|
+
return;
|
|
884
|
+
}
|
|
885
|
+
console.warn("[useVoiceChat] ElevenLabs TTS failed, falling back to browser:", error instanceof Error
|
|
886
|
+
? `${error.name}: ${error.message}`
|
|
887
|
+
: error);
|
|
888
|
+
usingAudioAnalysisRef.current = false;
|
|
889
|
+
setUsingAudioAnalysis(false);
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
else {
|
|
893
|
+
usingAudioAnalysisRef.current = false;
|
|
894
|
+
setUsingAudioAnalysis(false);
|
|
895
|
+
}
|
|
896
|
+
await speakBrowser(task.text, task, workerGeneration);
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
finally {
|
|
900
|
+
queueWorkerRunningRef.current = false;
|
|
901
|
+
}
|
|
902
|
+
if (workerGeneration !== generationRef.current)
|
|
903
|
+
return;
|
|
904
|
+
if (queueRef.current.length > 0) {
|
|
905
|
+
processQueue();
|
|
906
|
+
return;
|
|
907
|
+
}
|
|
908
|
+
usingAudioAnalysisRef.current = false;
|
|
909
|
+
setUsingAudioAnalysis(false);
|
|
910
|
+
setIsSpeaking(false);
|
|
911
|
+
})();
|
|
912
|
+
}, [speakBrowser, speakElevenLabs]);
|
|
913
|
+
const enqueueSpeech = useCallback((task) => {
|
|
914
|
+
const speakable = toSpeakableText(task.text);
|
|
915
|
+
if (!speakable)
|
|
916
|
+
return;
|
|
917
|
+
if (!task.append) {
|
|
918
|
+
cancelPlayback();
|
|
919
|
+
}
|
|
920
|
+
queueRef.current.push({ ...task, text: speakable });
|
|
921
|
+
speakingStartRef.current = Date.now();
|
|
922
|
+
setIsSpeaking(true);
|
|
923
|
+
processQueue();
|
|
924
|
+
}, [cancelPlayback, processQueue]);
|
|
925
|
+
// ── Public speak APIs ─────────────────────────────────────────────
|
|
926
|
+
const speak = useCallback((text, speakOptions) => {
|
|
927
|
+
assistantSpeechRef.current = null;
|
|
928
|
+
enqueueSpeech({
|
|
929
|
+
text,
|
|
930
|
+
append: Boolean(speakOptions?.append),
|
|
931
|
+
segment: "full",
|
|
932
|
+
});
|
|
933
|
+
}, [enqueueSpeech]);
|
|
934
|
+
const queueAssistantSpeech = useCallback((messageId, text, isFinal) => {
|
|
935
|
+
if (!messageId)
|
|
936
|
+
return;
|
|
937
|
+
const speakable = toSpeakableText(text);
|
|
938
|
+
if (!speakable)
|
|
939
|
+
return;
|
|
940
|
+
const current = assistantSpeechRef.current;
|
|
941
|
+
if (!current || current.messageId !== messageId) {
|
|
942
|
+
assistantSpeechRef.current = {
|
|
943
|
+
messageId,
|
|
944
|
+
lastObservedText: "",
|
|
945
|
+
firstSentenceSpoken: false,
|
|
946
|
+
firstSentenceText: "",
|
|
947
|
+
queuedRemainderText: "",
|
|
948
|
+
finalQueued: false,
|
|
949
|
+
};
|
|
950
|
+
}
|
|
951
|
+
const state = assistantSpeechRef.current;
|
|
952
|
+
if (!state)
|
|
953
|
+
return;
|
|
954
|
+
if (speakable === state.lastObservedText &&
|
|
955
|
+
(!isFinal || state.finalQueued)) {
|
|
956
|
+
return;
|
|
957
|
+
}
|
|
958
|
+
state.lastObservedText = speakable;
|
|
959
|
+
if (!state.firstSentenceSpoken) {
|
|
960
|
+
const split = splitFirstSentence(speakable);
|
|
961
|
+
if (!split.complete && !isFinal)
|
|
962
|
+
return;
|
|
963
|
+
if (split.complete) {
|
|
964
|
+
const firstSentence = split.firstSentence;
|
|
965
|
+
state.firstSentenceSpoken = true;
|
|
966
|
+
state.firstSentenceText = firstSentence;
|
|
967
|
+
const elConfig = voiceConfigRef.current?.elevenlabs;
|
|
968
|
+
const cacheKey = voiceConfigRef.current?.provider === "elevenlabs" && elConfig
|
|
969
|
+
? makeElevenCacheKey(firstSentence, elConfig)
|
|
970
|
+
: undefined;
|
|
971
|
+
enqueueSpeech({
|
|
972
|
+
text: firstSentence,
|
|
973
|
+
append: false,
|
|
974
|
+
segment: "first-sentence",
|
|
975
|
+
cacheKey,
|
|
976
|
+
});
|
|
977
|
+
const queueableRemainder = queueableSpeechPrefix(split.remainder, isFinal);
|
|
978
|
+
if (queueableRemainder) {
|
|
979
|
+
enqueueSpeech({
|
|
980
|
+
text: queueableRemainder,
|
|
981
|
+
append: true,
|
|
982
|
+
segment: "remainder",
|
|
983
|
+
});
|
|
984
|
+
state.queuedRemainderText = queueableRemainder;
|
|
985
|
+
}
|
|
986
|
+
if (isFinal) {
|
|
987
|
+
state.finalQueued = true;
|
|
988
|
+
}
|
|
989
|
+
return;
|
|
990
|
+
}
|
|
991
|
+
enqueueSpeech({
|
|
992
|
+
text: speakable,
|
|
993
|
+
append: false,
|
|
994
|
+
segment: "full",
|
|
995
|
+
});
|
|
996
|
+
state.finalQueued = true;
|
|
997
|
+
return;
|
|
998
|
+
}
|
|
999
|
+
const remainder = remainderAfter(speakable, state.firstSentenceText);
|
|
1000
|
+
const queueableRemainder = queueableSpeechPrefix(remainder, isFinal);
|
|
1001
|
+
const newRemainderDelta = remainderAfter(queueableRemainder, state.queuedRemainderText);
|
|
1002
|
+
if (newRemainderDelta) {
|
|
1003
|
+
enqueueSpeech({
|
|
1004
|
+
text: newRemainderDelta,
|
|
1005
|
+
append: true,
|
|
1006
|
+
segment: "remainder",
|
|
1007
|
+
});
|
|
1008
|
+
state.queuedRemainderText = queueableRemainder;
|
|
1009
|
+
}
|
|
1010
|
+
if (isFinal && !state.finalQueued) {
|
|
1011
|
+
state.finalQueued = true;
|
|
1012
|
+
}
|
|
1013
|
+
}, [enqueueSpeech, makeElevenCacheKey]);
|
|
1014
|
+
// ── Keep ElevenLabs runtime warm for lower startup latency ────────
|
|
1015
|
+
useEffect(() => {
|
|
1016
|
+
const config = effectiveVoiceConfig;
|
|
1017
|
+
if (typeof window === "undefined" ||
|
|
1018
|
+
config?.provider !== "elevenlabs" ||
|
|
1019
|
+
!config.elevenlabs) {
|
|
1020
|
+
return;
|
|
1021
|
+
}
|
|
1022
|
+
const warmAudioContext = () => {
|
|
1023
|
+
if (!audioCtxRef.current) {
|
|
1024
|
+
audioCtxRef.current = new AudioContext();
|
|
1025
|
+
}
|
|
1026
|
+
void audioCtxRef.current.resume().catch(() => {
|
|
1027
|
+
// Ignore until the next gesture or playback attempt.
|
|
1028
|
+
});
|
|
1029
|
+
};
|
|
1030
|
+
const handleUserGesture = () => {
|
|
1031
|
+
window.removeEventListener("pointerdown", handleUserGesture, true);
|
|
1032
|
+
window.removeEventListener("keydown", handleUserGesture, true);
|
|
1033
|
+
warmAudioContext();
|
|
1034
|
+
};
|
|
1035
|
+
window.addEventListener("pointerdown", handleUserGesture, true);
|
|
1036
|
+
window.addEventListener("keydown", handleUserGesture, true);
|
|
1037
|
+
return () => {
|
|
1038
|
+
window.removeEventListener("pointerdown", handleUserGesture, true);
|
|
1039
|
+
window.removeEventListener("keydown", handleUserGesture, true);
|
|
1040
|
+
};
|
|
1041
|
+
}, [effectiveVoiceConfig]);
|
|
1042
|
+
// ── Cleanup on unmount ────────────────────────────────────────────
|
|
1043
|
+
useEffect(() => {
|
|
1044
|
+
return () => {
|
|
1045
|
+
void stopListening();
|
|
1046
|
+
void removeTalkModeListeners();
|
|
1047
|
+
stopSpeaking();
|
|
1048
|
+
if (audioCtxRef.current) {
|
|
1049
|
+
void audioCtxRef.current.close().catch(() => {
|
|
1050
|
+
/* ignore */
|
|
1051
|
+
});
|
|
1052
|
+
audioCtxRef.current = null;
|
|
1053
|
+
}
|
|
1054
|
+
};
|
|
1055
|
+
}, [removeTalkModeListeners, stopListening, stopSpeaking]);
|
|
1056
|
+
return {
|
|
1057
|
+
isListening,
|
|
1058
|
+
captureMode,
|
|
1059
|
+
isSpeaking,
|
|
1060
|
+
mouthOpen,
|
|
1061
|
+
interimTranscript,
|
|
1062
|
+
supported,
|
|
1063
|
+
usingAudioAnalysis,
|
|
1064
|
+
toggleListening,
|
|
1065
|
+
startListening,
|
|
1066
|
+
stopListening,
|
|
1067
|
+
speak,
|
|
1068
|
+
queueAssistantSpeech,
|
|
1069
|
+
stopSpeaking,
|
|
1070
|
+
};
|
|
1071
|
+
}
|