@absolutejs/voice 0.0.22-beta.67 → 0.0.22-beta.670
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/LICENSE +88 -0
- package/README.md +4562 -1179
- package/dist/angular/index.d.ts +36 -8
- package/dist/angular/index.js +4362 -537
- package/dist/angular/voice-agent-squad-status.service.d.ts +12 -0
- package/dist/angular/voice-call-debugger.service.d.ts +12 -0
- package/dist/angular/voice-call-player.service.d.ts +19 -0
- package/dist/angular/voice-campaign-dialer-proof.service.d.ts +14 -0
- package/dist/angular/voice-controller.service.d.ts +4 -1
- package/dist/angular/voice-cost-dashboard.service.d.ts +15 -0
- package/dist/angular/voice-delivery-runtime.service.d.ts +16 -0
- package/dist/angular/voice-live-agent-console.service.d.ts +16 -0
- package/dist/angular/voice-live-call-viewer.service.d.ts +16 -0
- package/dist/angular/voice-live-ops.service.d.ts +11 -0
- package/dist/angular/voice-ops-action-center.service.d.ts +13 -0
- package/dist/angular/voice-ops-status.service.d.ts +12 -0
- package/dist/angular/voice-platform-coverage.service.d.ts +12 -0
- package/dist/angular/voice-profile-comparison.service.d.ts +12 -0
- package/dist/angular/voice-proof-trends.service.d.ts +12 -0
- package/dist/angular/voice-provider-capabilities.service.d.ts +2 -2
- package/dist/angular/voice-provider-contracts.service.d.ts +12 -0
- package/dist/angular/voice-provider-status.service.d.ts +2 -2
- package/dist/angular/voice-readiness-failures.service.d.ts +13 -0
- package/dist/angular/voice-reconnect-profile-evidence.service.d.ts +12 -0
- package/dist/angular/voice-replay-timeline.service.d.ts +13 -0
- package/dist/angular/voice-routing-status.service.d.ts +1 -1
- package/dist/angular/voice-session-observability.service.d.ts +12 -0
- package/dist/angular/voice-session-snapshot.service.d.ts +13 -0
- package/dist/angular/voice-stream.service.d.ts +6 -2
- package/dist/angular/voice-trace-timeline.service.d.ts +12 -0
- package/dist/angular/voice-turn-latency.service.d.ts +13 -0
- package/dist/angular/voice-turn-quality.service.d.ts +2 -2
- package/dist/angular/voice-widget.service.d.ts +18 -0
- package/dist/angular/voice-workflow-status.service.d.ts +2 -2
- package/dist/client/actions.d.ts +201 -2
- package/dist/client/agentSquadStatus.d.ts +37 -0
- package/dist/client/agentSquadStatusWidget.d.ts +24 -0
- package/dist/client/audioPlayer.d.ts +12 -2
- package/dist/client/bargeInMonitor.d.ts +7 -0
- package/dist/client/browserMedia.d.ts +8 -0
- package/dist/client/browserNoiseSuppression.d.ts +42 -0
- package/dist/client/browserVoiceSupport.d.ts +22 -0
- package/dist/client/callDebugger.d.ts +21 -0
- package/dist/client/callDebuggerWidget.d.ts +30 -0
- package/dist/client/callPlayer.d.ts +41 -0
- package/dist/client/campaignDialerProof.d.ts +25 -0
- package/dist/client/connection.d.ts +13 -4
- package/dist/client/controller.d.ts +1 -1
- package/dist/client/conversationAnalytics.d.ts +30 -0
- package/dist/client/costDashboard.d.ts +27 -0
- package/dist/client/createVoiceStream.d.ts +1 -1
- package/dist/client/deliveryRuntime.d.ts +36 -0
- package/dist/client/deliveryRuntimeWidget.d.ts +37 -0
- package/dist/client/duplex.d.ts +2 -2
- package/dist/client/htmx.d.ts +1 -1
- package/dist/client/htmxAttributes.d.ts +24 -0
- package/dist/client/htmxBootstrap.js +1808 -159
- package/dist/client/htmxDashboardRenderers.d.ts +71 -0
- package/dist/client/index.d.ts +109 -33
- package/dist/client/index.js +10799 -646
- package/dist/client/liveAgentConsole.d.ts +28 -0
- package/dist/client/liveCallViewer.d.ts +42 -0
- package/dist/client/liveOps.d.ts +22 -0
- package/dist/client/liveOpsWidget.d.ts +23 -0
- package/dist/client/liveTurnLatency.d.ts +41 -0
- package/dist/client/microphone.d.ts +5 -4
- package/dist/client/opsActionCenter.d.ts +56 -0
- package/dist/client/opsActionCenterWidget.d.ts +29 -0
- package/dist/client/opsActionHistory.d.ts +21 -0
- package/dist/client/opsActionHistoryWidget.d.ts +11 -0
- package/dist/client/opsStatus.d.ts +21 -0
- package/dist/client/opsStatusWidget.d.ts +10 -10
- package/dist/client/platformCoverage.d.ts +21 -0
- package/dist/client/platformCoverageWidget.d.ts +38 -0
- package/dist/client/profileComparison.d.ts +21 -0
- package/dist/client/profileComparisonWidget.d.ts +41 -0
- package/dist/client/profileSwitchRecommendation.d.ts +21 -0
- package/dist/client/profileSwitchRecommendationWidget.d.ts +12 -0
- package/dist/client/proofTrends.d.ts +21 -0
- package/dist/client/proofTrendsWidget.d.ts +38 -0
- package/dist/client/providerCapabilities.d.ts +5 -3
- package/dist/client/providerCapabilitiesWidget.d.ts +6 -6
- package/dist/client/providerContracts.d.ts +21 -0
- package/dist/client/providerContractsWidget.d.ts +37 -0
- package/dist/client/providerSimulationControls.d.ts +3 -3
- package/dist/client/providerSimulationControlsWidget.d.ts +5 -5
- package/dist/client/providerStatus.d.ts +5 -3
- package/dist/client/providerStatusWidget.d.ts +6 -6
- package/dist/client/reactiveSource.d.ts +8 -0
- package/dist/client/readinessFailures.d.ts +21 -0
- package/dist/client/readinessFailuresWidget.d.ts +42 -0
- package/dist/client/reconnectProfileEvidence.d.ts +21 -0
- package/dist/client/reconnectProfileEvidenceWidget.d.ts +39 -0
- package/dist/client/replayTimeline.d.ts +26 -0
- package/dist/client/routingStatus.d.ts +5 -3
- package/dist/client/routingStatusWidget.d.ts +10 -6
- package/dist/client/sessionObservability.d.ts +21 -0
- package/dist/client/sessionObservabilityWidget.d.ts +31 -0
- package/dist/client/sessionSnapshot.d.ts +23 -0
- package/dist/client/sessionSnapshotWidget.d.ts +33 -0
- package/dist/client/store.d.ts +1 -1
- package/dist/client/timeStretch.d.ts +5 -0
- package/dist/client/traceTimeline.d.ts +21 -0
- package/dist/client/traceTimelineWidget.d.ts +36 -0
- package/dist/client/turnLatency.d.ts +24 -0
- package/dist/client/turnLatencyWidget.d.ts +33 -0
- package/dist/client/turnQuality.d.ts +5 -3
- package/dist/client/turnQualityWidget.d.ts +6 -6
- package/dist/client/voiceWidgetView.d.ts +48 -0
- package/dist/client/workflowStatus.d.ts +5 -3
- package/dist/core/agent.d.ts +251 -0
- package/dist/core/agentPerformanceReport.d.ts +40 -0
- package/dist/core/agentSquadContract.d.ts +98 -0
- package/dist/core/agentState.d.ts +12 -0
- package/dist/core/agentTools.d.ts +132 -0
- package/dist/core/aiScorecard.d.ts +32 -0
- package/dist/core/aiVoiceModel.d.ts +15 -0
- package/dist/core/amdDetector.d.ts +25 -0
- package/dist/{assistant.d.ts → core/assistant.d.ts} +24 -14
- package/dist/core/assistantExperiment.d.ts +42 -0
- package/dist/{assistantHealth.d.ts → core/assistantHealth.d.ts} +9 -9
- package/dist/{assistantMemory.d.ts → core/assistantMemory.d.ts} +10 -10
- package/dist/core/assistantMode.d.ts +22 -0
- package/dist/{audioConditioning.d.ts → core/audioConditioning.d.ts} +2 -2
- package/dist/core/audit.d.ts +131 -0
- package/dist/core/auditDeliveryRoutes.d.ts +85 -0
- package/dist/core/auditExport.d.ts +34 -0
- package/dist/core/auditRoutes.d.ts +66 -0
- package/dist/core/auditSinks.d.ts +151 -0
- package/dist/core/backchannel.d.ts +25 -0
- package/dist/core/bargeInDetector.d.ts +51 -0
- package/dist/core/bargeInRoutes.d.ts +56 -0
- package/dist/core/bookingFlow.d.ts +43 -0
- package/dist/core/browserCallProfiles.d.ts +120 -0
- package/dist/core/browserMediaRoutes.d.ts +62 -0
- package/dist/core/cachedTTS.d.ts +54 -0
- package/dist/core/calendarAdapter.d.ts +47 -0
- package/dist/core/calendarSlots.d.ts +35 -0
- package/dist/core/callDebugger.d.ts +66 -0
- package/dist/core/callDisposition.d.ts +38 -0
- package/dist/core/callQuota.d.ts +54 -0
- package/dist/core/callScorecard.d.ts +53 -0
- package/dist/core/callerCRMLinker.d.ts +29 -0
- package/dist/core/callerMemory.d.ts +37 -0
- package/dist/core/callingWindow.d.ts +26 -0
- package/dist/core/campaign.d.ts +795 -0
- package/dist/core/campaignControls.d.ts +37 -0
- package/dist/core/campaignDialers.d.ts +111 -0
- package/dist/core/campaignTemplate.d.ts +16 -0
- package/dist/core/competitiveCoverage.d.ts +141 -0
- package/dist/core/conversationSimulator.d.ts +73 -0
- package/dist/{correction.d.ts → core/correction.d.ts} +5 -4
- package/dist/core/costAccounting.d.ts +90 -0
- package/dist/core/costPredictor.d.ts +74 -0
- package/dist/core/crmCallLogger.d.ts +37 -0
- package/dist/core/crmContract.d.ts +70 -0
- package/dist/core/dataControl.d.ts +180 -0
- package/dist/core/debugTiming.d.ts +11 -0
- package/dist/core/defineVoiceAssistant.d.ts +68 -0
- package/dist/core/deliveryRuntime.d.ts +159 -0
- package/dist/core/deliverySinkRoutes.d.ts +117 -0
- package/dist/core/demoReadyRoutes.d.ts +98 -0
- package/dist/{diagnosticsRoutes.d.ts → core/diagnosticsRoutes.d.ts} +2 -2
- package/dist/core/dncRegistry.d.ts +38 -0
- package/dist/core/dtmfCollector.d.ts +37 -0
- package/dist/{evalRoutes.d.ts → core/evalRoutes.d.ts} +26 -20
- package/dist/{fileStore.d.ts → core/fileStore.d.ts} +34 -20
- package/dist/core/guardrails.d.ts +128 -0
- package/dist/{handoff.d.ts → core/handoff.d.ts} +10 -10
- package/dist/{handoffHealth.d.ts → core/handoffHealth.d.ts} +9 -9
- package/dist/core/hardenedFetch.d.ts +1 -0
- package/dist/core/holdAudio.d.ts +23 -0
- package/dist/{htmx.d.ts → core/htmx.d.ts} +2 -2
- package/dist/core/htmxDashboardRoutes.d.ts +250 -0
- package/dist/core/iceServers.d.ts +34 -0
- package/dist/core/incidentBundle.d.ts +119 -0
- package/dist/core/incidentTimeline.d.ts +260 -0
- package/dist/core/ivrPlan.d.ts +40 -0
- package/dist/core/latencySlo.d.ts +56 -0
- package/dist/core/liveCoach.d.ts +43 -0
- package/dist/core/liveLatency.d.ts +78 -0
- package/dist/core/liveOps.d.ts +190 -0
- package/dist/core/llmJudge.d.ts +45 -0
- package/dist/{logger.d.ts → core/logger.d.ts} +1 -2
- package/dist/core/mcpToolset.d.ts +58 -0
- package/dist/core/mediaPipelineRoutes.d.ts +171 -0
- package/dist/core/mediaPipelineSurfaces.d.ts +48 -0
- package/dist/{memoryStore.d.ts → core/memoryStore.d.ts} +1 -1
- package/dist/core/midCallSummary.d.ts +27 -0
- package/dist/{modelAdapters.d.ts → core/modelAdapters.d.ts} +64 -7
- package/dist/core/monitor.d.ts +148 -0
- package/dist/core/multilingualProof.d.ts +77 -0
- package/dist/core/noShowPredictor.d.ts +46 -0
- package/dist/core/numberNormalizer.d.ts +1 -0
- package/dist/core/oauth2TokenSource.d.ts +21 -0
- package/dist/core/observabilityExport.d.ts +501 -0
- package/dist/core/openaiTTS.d.ts +18 -0
- package/dist/core/operationalStatus.d.ts +87 -0
- package/dist/core/operationsRecord.d.ts +371 -0
- package/dist/{ops.d.ts → core/ops.d.ts} +70 -70
- package/dist/core/opsActionAuditRoutes.d.ts +99 -0
- package/dist/{opsConsoleRoutes.d.ts → core/opsConsoleRoutes.d.ts} +11 -8
- package/dist/{opsPresets.d.ts → core/opsPresets.d.ts} +2 -2
- package/dist/core/opsRecovery.d.ts +137 -0
- package/dist/{opsRuntime.d.ts → core/opsRuntime.d.ts} +6 -6
- package/dist/{opsSinks.d.ts → core/opsSinks.d.ts} +19 -19
- package/dist/core/opsStatus.d.ts +76 -0
- package/dist/core/opsStatusRoutes.d.ts +33 -0
- package/dist/{opsWebhook.d.ts → core/opsWebhook.d.ts} +15 -15
- package/dist/core/otelExporter.d.ts +83 -0
- package/dist/core/outcomeContract.d.ts +146 -0
- package/dist/{outcomeRecipes.d.ts → core/outcomeRecipes.d.ts} +4 -4
- package/dist/core/pathway.d.ts +94 -0
- package/dist/core/pathwayCompiler.d.ts +31 -0
- package/dist/core/pathwayGenerator.d.ts +27 -0
- package/dist/core/pathwayRuntime.d.ts +57 -0
- package/dist/core/pathwaySlotCollector.d.ts +29 -0
- package/dist/core/pathwayVisualizer.d.ts +8 -0
- package/dist/core/phoneAgent.d.ts +139 -0
- package/dist/core/phoneAgentProductionSmoke.d.ts +115 -0
- package/dist/core/phoneProvisioning.d.ts +29 -0
- package/dist/core/platformCoverage.d.ts +91 -0
- package/dist/{plugin.d.ts → core/plugin.d.ts} +11 -8
- package/dist/core/postCallAnalysis.d.ts +98 -0
- package/dist/core/postCallSurvey.d.ts +41 -0
- package/dist/{postgresStore.d.ts → core/postgresStore.d.ts} +20 -9
- package/dist/{presets.d.ts → core/presets.d.ts} +3 -3
- package/dist/core/productionReadiness.d.ts +757 -0
- package/dist/core/profileSwitchRecommendation.d.ts +350 -0
- package/dist/core/promptInjectionGuard.d.ts +30 -0
- package/dist/core/proofAssertions.d.ts +32 -0
- package/dist/core/proofPack.d.ts +211 -0
- package/dist/core/proofRunner.d.ts +79 -0
- package/dist/core/proofTrends.d.ts +966 -0
- package/dist/{providerAdapters.d.ts → core/providerAdapters.d.ts} +5 -5
- package/dist/{providerCapabilities.d.ts → core/providerCapabilities.d.ts} +9 -9
- package/dist/core/providerDecisionTraces.d.ts +130 -0
- package/dist/{providerHealth.d.ts → core/providerHealth.d.ts} +15 -5
- package/dist/core/providerOrchestration.d.ts +109 -0
- package/dist/core/providerRouterTraces.d.ts +35 -0
- package/dist/core/providerRoutingContract.d.ts +71 -0
- package/dist/core/providerSlo.d.ts +142 -0
- package/dist/core/providerStackRecommendations.d.ts +188 -0
- package/dist/core/qualityDriftDetector.d.ts +44 -0
- package/dist/{qualityRoutes.d.ts → core/qualityRoutes.d.ts} +7 -7
- package/dist/{queue.d.ts → core/queue.d.ts} +48 -39
- package/dist/core/ragTool.d.ts +52 -0
- package/dist/core/readinessProfiles.d.ts +45 -0
- package/dist/core/realtimeChannel.d.ts +136 -0
- package/dist/core/realtimeProviderContracts.d.ts +133 -0
- package/dist/core/reconnectContract.d.ts +177 -0
- package/dist/core/recordingRedaction.d.ts +47 -0
- package/dist/core/recordingStore.d.ts +60 -0
- package/dist/core/redaction.d.ts +13 -0
- package/dist/core/reminderScheduler.d.ts +43 -0
- package/dist/{resilienceRoutes.d.ts → core/resilienceRoutes.d.ts} +34 -5
- package/dist/core/retention.d.ts +37 -0
- package/dist/core/retryPolicy.d.ts +38 -0
- package/dist/core/routeAuth.d.ts +58 -0
- package/dist/{routing.d.ts → core/routing.d.ts} +2 -2
- package/dist/{runtimeOps.d.ts → core/runtimeOps.d.ts} +3 -3
- package/dist/{s3Store.d.ts → core/s3Store.d.ts} +12 -3
- package/dist/core/scorecardCalibration.d.ts +31 -0
- package/dist/core/scribe.d.ts +50 -0
- package/dist/core/semanticTurn.d.ts +37 -0
- package/dist/{session.d.ts → core/session.d.ts} +1 -1
- package/dist/core/sessionObservability.d.ts +145 -0
- package/dist/{sessionReplay.d.ts → core/sessionReplay.d.ts} +31 -19
- package/dist/core/sessionSnapshot.d.ts +109 -0
- package/dist/core/simulationSuite.d.ts +144 -0
- package/dist/core/sloCalibration.d.ts +185 -0
- package/dist/{sqliteStore.d.ts → core/sqliteStore.d.ts} +20 -9
- package/dist/{store.d.ts → core/store.d.ts} +1 -1
- package/dist/core/supervisorPermissions.d.ts +33 -0
- package/dist/core/supervisorPresence.d.ts +49 -0
- package/dist/core/telephonyMediaRoutes.d.ts +72 -0
- package/dist/core/telephonyOutcome.d.ts +269 -0
- package/dist/{toolContract.d.ts → core/toolContract.d.ts} +46 -15
- package/dist/{toolRuntime.d.ts → core/toolRuntime.d.ts} +4 -4
- package/dist/{trace.d.ts → core/trace.d.ts} +61 -22
- package/dist/core/traceDeliveryRoutes.d.ts +86 -0
- package/dist/core/traceTimeline.d.ts +97 -0
- package/dist/core/transcriptAnnotator.d.ts +41 -0
- package/dist/{turnDetection.d.ts → core/turnDetection.d.ts} +2 -1
- package/dist/core/turnLatency.d.ts +95 -0
- package/dist/core/turnProfiles.d.ts +3 -0
- package/dist/{turnQuality.d.ts → core/turnQuality.d.ts} +9 -9
- package/dist/core/types.d.ts +1786 -0
- package/dist/core/vapiAdapter.d.ts +160 -0
- package/dist/core/variableAnalytics.d.ts +47 -0
- package/dist/core/voiceConfiguration.d.ts +8 -0
- package/dist/core/voiceMonitoring.d.ts +444 -0
- package/dist/core/webhookFanout.d.ts +48 -0
- package/dist/core/webhookVerification.d.ts +27 -0
- package/dist/core/whisperChannel.d.ts +50 -0
- package/dist/{workflowContract.d.ts → core/workflowContract.d.ts} +21 -21
- package/dist/core/writeBehindStore.d.ts +41 -0
- package/dist/core/zeroDataRetention.d.ts +31 -0
- package/dist/drizzle/assistantMemory.d.ts +100 -0
- package/dist/drizzle/eval.d.ts +55 -0
- package/dist/drizzle/handoff.d.ts +56 -0
- package/dist/drizzle/incidentBundle.d.ts +55 -0
- package/dist/drizzle/index.d.ts +991 -0
- package/dist/drizzle/index.js +3060 -0
- package/dist/drizzle/observabilityExport.d.ts +55 -0
- package/dist/drizzle/proofTrends.d.ts +114 -0
- package/dist/drizzle/runtimeStorage.d.ts +1183 -0
- package/dist/drizzle/shared.d.ts +69 -0
- package/dist/embed/index.d.ts +38 -0
- package/dist/embed/index.js +2100 -0
- package/dist/embed/voice-widget.js +10 -0
- package/dist/index.d.ts +379 -82
- package/dist/index.js +48514 -8241
- package/dist/internal/evidence.d.ts +10 -0
- package/dist/internal/html.d.ts +6 -0
- package/dist/internal/status.d.ts +7 -0
- package/dist/manifest.d.ts +17 -0
- package/dist/manifest.js +424 -0
- package/dist/manifest.json +427 -0
- package/dist/react/VoiceAgentSquadStatus.d.ts +5 -0
- package/dist/react/VoiceCallDebuggerLaunch.d.ts +6 -0
- package/dist/react/VoiceCallPlayer.d.ts +11 -0
- package/dist/react/VoiceCostDashboard.d.ts +10 -0
- package/dist/react/VoiceDeliveryRuntime.d.ts +7 -0
- package/dist/react/VoiceLiveAgentConsole.d.ts +11 -0
- package/dist/react/VoiceLiveCallViewer.d.ts +9 -0
- package/dist/react/VoiceOpsActionCenter.d.ts +5 -0
- package/dist/react/VoiceOpsStatus.d.ts +1 -1
- package/dist/react/VoicePlatformCoverage.d.ts +6 -0
- package/dist/react/VoiceProfileComparison.d.ts +6 -0
- package/dist/react/VoiceProfileSwitchRecommendation.d.ts +6 -0
- package/dist/react/VoiceProofTrends.d.ts +6 -0
- package/dist/react/VoiceProviderCapabilities.d.ts +1 -1
- package/dist/react/VoiceProviderContracts.d.ts +6 -0
- package/dist/react/VoiceProviderSimulationControls.d.ts +1 -1
- package/dist/react/VoiceProviderStatus.d.ts +1 -1
- package/dist/react/VoiceReadinessFailures.d.ts +6 -0
- package/dist/react/VoiceReconnectProfileEvidence.d.ts +6 -0
- package/dist/react/VoiceReplayTimeline.d.ts +6 -0
- package/dist/react/VoiceRoutingStatus.d.ts +1 -1
- package/dist/react/VoiceSessionObservability.d.ts +6 -0
- package/dist/react/VoiceSessionSnapshot.d.ts +6 -0
- package/dist/react/VoiceTraceTimeline.d.ts +6 -0
- package/dist/react/VoiceTurnLatency.d.ts +6 -0
- package/dist/react/VoiceTurnQuality.d.ts +1 -1
- package/dist/react/VoiceWidget.d.ts +13 -0
- package/dist/react/index.d.ts +80 -15
- package/dist/react/index.js +13740 -2052
- package/dist/react/useVoiceAgentSquadStatus.d.ts +8 -0
- package/dist/react/useVoiceCallDebugger.d.ts +8 -0
- package/dist/react/useVoiceCampaignDialerProof.d.ts +10 -0
- package/dist/react/useVoiceController.d.ts +9 -2
- package/dist/react/useVoiceDeliveryRuntime.d.ts +13 -0
- package/dist/react/useVoiceLiveOps.d.ts +9 -0
- package/dist/react/useVoiceOpsActionCenter.d.ts +11 -0
- package/dist/react/useVoiceOpsStatus.d.ts +8 -0
- package/dist/react/useVoicePlatformCoverage.d.ts +8 -0
- package/dist/react/useVoiceProfileComparison.d.ts +8 -0
- package/dist/react/useVoiceProfileSwitchRecommendation.d.ts +8 -0
- package/dist/react/useVoiceProofTrends.d.ts +8 -0
- package/dist/react/useVoiceProviderCapabilities.d.ts +1 -1
- package/dist/react/useVoiceProviderContracts.d.ts +8 -0
- package/dist/react/useVoiceProviderSimulationControls.d.ts +1 -1
- package/dist/react/useVoiceProviderStatus.d.ts +1 -1
- package/dist/react/useVoiceReadinessFailures.d.ts +8 -0
- package/dist/react/useVoiceReconnectProfileEvidence.d.ts +8 -0
- package/dist/react/useVoiceRoutingStatus.d.ts +1 -1
- package/dist/react/useVoiceSessionObservability.d.ts +8 -0
- package/dist/react/useVoiceSessionSnapshot.d.ts +9 -0
- package/dist/react/useVoiceStream.d.ts +9 -2
- package/dist/react/useVoiceTraceTimeline.d.ts +8 -0
- package/dist/react/useVoiceTurnLatency.d.ts +9 -0
- package/dist/react/useVoiceTurnQuality.d.ts +1 -1
- package/dist/react/useVoiceWorkflowStatus.d.ts +1 -1
- package/dist/svelte/createVoiceAgentSquadStatus.d.ts +9 -0
- package/dist/svelte/createVoiceCallDebugger.d.ts +10 -0
- package/dist/svelte/createVoiceCallPlayer.d.ts +33 -0
- package/dist/svelte/createVoiceCampaignDialerProof.d.ts +9 -0
- package/dist/svelte/createVoiceCostDashboard.d.ts +13 -0
- package/dist/svelte/createVoiceDeliveryRuntime.d.ts +11 -0
- package/dist/svelte/createVoiceLiveAgentConsole.d.ts +23 -0
- package/dist/svelte/createVoiceLiveCallViewer.d.ts +26 -0
- package/dist/svelte/createVoiceLiveOps.d.ts +13 -0
- package/dist/svelte/createVoiceOpsActionCenter.d.ts +10 -0
- package/dist/svelte/createVoiceOpsStatus.d.ts +4 -4
- package/dist/svelte/createVoicePlatformCoverage.d.ts +7 -0
- package/dist/svelte/createVoiceProfileComparison.d.ts +7 -0
- package/dist/svelte/createVoiceProofTrends.d.ts +7 -0
- package/dist/svelte/createVoiceProviderCapabilities.d.ts +2 -2
- package/dist/svelte/createVoiceProviderContracts.d.ts +10 -0
- package/dist/svelte/createVoiceProviderSimulationControls.d.ts +2 -2
- package/dist/svelte/createVoiceProviderStatus.d.ts +2 -2
- package/dist/svelte/createVoiceReadinessFailures.d.ts +7 -0
- package/dist/svelte/createVoiceReconnectProfileEvidence.d.ts +7 -0
- package/dist/svelte/createVoiceReplayTimeline.d.ts +13 -0
- package/dist/svelte/createVoiceRoutingStatus.d.ts +2 -2
- package/dist/svelte/createVoiceSessionObservability.d.ts +10 -0
- package/dist/svelte/createVoiceSessionSnapshot.d.ts +11 -0
- package/dist/svelte/createVoiceStream.d.ts +1 -1
- package/dist/svelte/createVoiceTraceTimeline.d.ts +10 -0
- package/dist/svelte/createVoiceTurnLatency.d.ts +11 -0
- package/dist/svelte/createVoiceTurnQuality.d.ts +2 -2
- package/dist/svelte/createVoiceWidget.d.ts +19 -0
- package/dist/svelte/createVoiceWorkflowStatus.d.ts +2 -2
- package/dist/svelte/index.d.ts +37 -10
- package/dist/svelte/index.js +7465 -1676
- package/dist/telephony/contract.d.ts +61 -0
- package/dist/telephony/matrix.d.ts +97 -0
- package/dist/telephony/plivo.d.ts +302 -0
- package/dist/telephony/response.d.ts +1 -1
- package/dist/telephony/security.d.ts +182 -0
- package/dist/telephony/telnyx.d.ts +290 -0
- package/dist/telephony/twilio.d.ts +164 -15
- package/dist/testing/accuracy.d.ts +18 -1
- package/dist/testing/audioMatrix.d.ts +22 -0
- package/dist/testing/benchmark.d.ts +24 -15
- package/dist/testing/confidenceCalibration.d.ts +19 -0
- package/dist/testing/conformance.d.ts +11 -0
- package/dist/testing/corrected.d.ts +9 -9
- package/dist/testing/criticalFields.d.ts +22 -0
- package/dist/testing/duplex.d.ts +5 -5
- package/dist/testing/fixtures.d.ts +7 -4
- package/dist/testing/index.d.ts +21 -13
- package/dist/testing/index.js +9171 -1290
- package/dist/testing/ioProviderSimulator.d.ts +5 -5
- package/dist/testing/outcomes.d.ts +12 -0
- package/dist/testing/provenance.d.ts +44 -0
- package/dist/testing/providerSimulator.d.ts +5 -5
- package/dist/testing/review.d.ts +8 -8
- package/dist/testing/routingBenchmark.d.ts +16 -0
- package/dist/testing/sessionBenchmark.d.ts +13 -13
- package/dist/testing/statistics.d.ts +30 -0
- package/dist/testing/stt.d.ts +3 -3
- package/dist/testing/telephony.d.ts +27 -2
- package/dist/testing/tts.d.ts +2 -2
- package/dist/vue/VoiceCallDebuggerLaunch.d.ts +72 -0
- package/dist/vue/VoiceCallPlayer.d.ts +40 -0
- package/dist/vue/VoiceCostDashboard.d.ts +57 -0
- package/dist/vue/VoiceDeliveryRuntime.d.ts +34 -0
- package/dist/vue/VoiceLiveAgentConsole.d.ts +50 -0
- package/dist/vue/VoiceLiveCallViewer.d.ts +35 -0
- package/dist/vue/VoiceOpsActionCenter.d.ts +13 -0
- package/dist/vue/VoiceOpsStatus.d.ts +4 -0
- package/dist/vue/VoicePlatformCoverage.d.ts +27 -0
- package/dist/vue/VoiceProofTrends.d.ts +25 -0
- package/dist/vue/VoiceProviderCapabilities.d.ts +4 -0
- package/dist/vue/VoiceProviderContracts.d.ts +25 -0
- package/dist/vue/VoiceProviderSimulationControls.d.ts +3 -3
- package/dist/vue/VoiceProviderStatus.d.ts +4 -0
- package/dist/vue/VoiceReadinessFailures.d.ts +25 -0
- package/dist/vue/VoiceReconnectProfileEvidence.d.ts +25 -0
- package/dist/vue/VoiceReplayTimeline.d.ts +17 -0
- package/dist/vue/VoiceRoutingStatus.d.ts +4 -0
- package/dist/vue/VoiceSessionObservability.d.ts +27 -0
- package/dist/vue/VoiceSessionSnapshot.d.ts +72 -0
- package/dist/vue/VoiceTurnLatency.d.ts +73 -0
- package/dist/vue/VoiceTurnQuality.d.ts +4 -0
- package/dist/vue/VoiceWidget.d.ts +77 -0
- package/dist/vue/index.d.ts +49 -15
- package/dist/vue/index.js +13097 -2219
- package/dist/vue/useVoiceAgentSquadStatus.d.ts +9 -0
- package/dist/vue/useVoiceCallDebugger.d.ts +10 -0
- package/dist/vue/useVoiceCampaignDialerProof.d.ts +11 -0
- package/dist/vue/useVoiceController.d.ts +10 -7
- package/dist/vue/useVoiceDeliveryRuntime.d.ts +13 -0
- package/dist/vue/useVoiceLiveOps.d.ts +9 -0
- package/dist/vue/useVoiceOpsActionCenter.d.ts +11 -0
- package/dist/vue/useVoiceOpsStatus.d.ts +9 -0
- package/dist/vue/useVoicePlatformCoverage.d.ts +9 -0
- package/dist/vue/useVoiceProfileComparison.d.ts +9 -0
- package/dist/vue/useVoiceProofTrends.d.ts +9 -0
- package/dist/vue/useVoiceProviderCapabilities.d.ts +3 -3
- package/dist/vue/useVoiceProviderContracts.d.ts +9 -0
- package/dist/vue/useVoiceProviderSimulationControls.d.ts +2 -2
- package/dist/vue/useVoiceProviderStatus.d.ts +3 -3
- package/dist/vue/useVoiceReadinessFailures.d.ts +959 -0
- package/dist/vue/useVoiceReconnectProfileEvidence.d.ts +9 -0
- package/dist/vue/useVoiceRoutingStatus.d.ts +2 -2
- package/dist/vue/useVoiceSessionObservability.d.ts +9 -0
- package/dist/vue/useVoiceSessionSnapshot.d.ts +10 -0
- package/dist/vue/useVoiceStream.d.ts +10 -6
- package/dist/vue/useVoiceTraceTimeline.d.ts +9 -0
- package/dist/vue/useVoiceTurnLatency.d.ts +10 -0
- package/dist/vue/useVoiceTurnQuality.d.ts +3 -3
- package/dist/vue/useVoiceWorkflowStatus.d.ts +3 -3
- package/package.json +247 -256
- package/dist/agent.d.ts +0 -115
- package/dist/angular/voice-app-kit-status.service.d.ts +0 -12
- package/dist/angular/voice-ops-status.component.d.ts +0 -15
- package/dist/appKit.d.ts +0 -94
- package/dist/client/appKitStatus.d.ts +0 -19
- package/dist/react/useVoiceAppKitStatus.d.ts +0 -8
- package/dist/svelte/createVoiceAppKitStatus.d.ts +0 -8
- package/dist/turnProfiles.d.ts +0 -6
- package/dist/types.d.ts +0 -968
- package/dist/vue/useVoiceAppKitStatus.d.ts +0 -9
- package/fixtures/README.md +0 -57
- package/fixtures/manifest.json +0 -199
- package/fixtures/pcm/dialogue-three-clean.pcm +0 -0
- package/fixtures/pcm/dialogue-three-mixed.pcm +0 -0
- package/fixtures/pcm/dialogue-two-clean.pcm +0 -0
- package/fixtures/pcm/dialogue-two-noisy.pcm +0 -0
- package/fixtures/pcm/multiturn-three-mixed.pcm +0 -0
- package/fixtures/pcm/multiturn-two-clean.pcm +0 -0
- package/fixtures/pcm/quietly-alone-clean.pcm +0 -0
- package/fixtures/pcm/rainstorms-noisy.pcm +0 -0
- package/fixtures/pcm/stella-bulgaria-bulgarian20.pcm +0 -0
- package/fixtures/pcm/stella-ghana-english507.pcm +0 -0
- package/fixtures/pcm/stella-india-english37.pcm +0 -0
- package/fixtures/pcm/stella-jamaica-jamaican-creole-english1.pcm +0 -0
- package/fixtures/pcm/stella-liberia-liberian-pidgin-english2.pcm +0 -0
- package/fixtures/pcm/stella-pakistan-english519.pcm +0 -0
- package/fixtures/pcm/stella-sierra-leone-krio5.pcm +0 -0
- package/fixtures/pcm/stella-singapore-english655.pcm +0 -0
- package/fixtures/pcm/traveled-back-route-clean.pcm +0 -0
|
@@ -0,0 +1,1786 @@
|
|
|
1
|
+
import type { MediaWebRTCStatsCollector, MediaWebRTCStatsReport, MediaWebRTCStatsReportInput, MediaWebRTCStreamContinuityInput, MediaWebRTCStreamContinuityReport } from "@absolutejs/media";
|
|
2
|
+
import type { VoiceOpsDispositionTaskPolicies, VoiceOpsTaskAssignmentRule, VoiceOpsTaskAssignmentRules, VoiceIntegrationWebhookConfig, StoredVoiceIntegrationEvent, StoredVoiceOpsTask, VoiceIntegrationEventStore, VoiceOpsTaskPolicy, VoiceOpsTask, VoiceOpsTaskStore } from "./ops";
|
|
3
|
+
import type { VoiceIntegrationSink } from "./opsSinks";
|
|
4
|
+
import type { StoredVoiceCallReviewArtifact, VoiceCallReviewArtifact, VoiceCallReviewStore } from "../testing/review";
|
|
5
|
+
import type { VoiceTraceEventStore } from "./trace";
|
|
6
|
+
import type { VoiceLiveOpsControlState } from "./liveOps";
|
|
7
|
+
import type { VoiceAuditActor, VoiceAuditEventStore } from "./audit";
|
|
8
|
+
import type { VoiceProfileSwitchGuardDecision, VoiceProfileSwitchGuardMode, VoiceProfileSwitchObservedSignals } from "./profileSwitchRecommendation";
|
|
9
|
+
import type { VoiceRealCallProfileDefaultsReport, VoiceRealCallProfileHistoryReport } from "./proofTrends";
|
|
10
|
+
export type AudioFormat = {
|
|
11
|
+
container: "raw";
|
|
12
|
+
encoding: "alaw" | "mulaw" | "pcm_s16le";
|
|
13
|
+
sampleRateHz: number;
|
|
14
|
+
channels: 1 | 2;
|
|
15
|
+
};
|
|
16
|
+
export type AudioChunk = ArrayBuffer | ArrayBufferView;
|
|
17
|
+
/**
|
|
18
|
+
* Structural contract for an inbound noise suppressor applied before STT.
|
|
19
|
+
* Matches `@absolutejs/media`'s `NoiseSuppressor`, so any media suppressor
|
|
20
|
+
* (`createFFmpegNoiseSuppressor`, `createEnergyGateNoiseSuppressor`, a Krisp
|
|
21
|
+
* adapter, etc.) satisfies it without a hard import.
|
|
22
|
+
*/
|
|
23
|
+
export type VoiceNoiseSuppressor = {
|
|
24
|
+
readonly kind: string;
|
|
25
|
+
process: (input: {
|
|
26
|
+
format: AudioFormat;
|
|
27
|
+
pcm: ArrayBuffer | ArrayBufferView;
|
|
28
|
+
}) => Promise<{
|
|
29
|
+
bytes: Uint8Array;
|
|
30
|
+
format: AudioFormat;
|
|
31
|
+
}> | {
|
|
32
|
+
bytes: Uint8Array;
|
|
33
|
+
format: AudioFormat;
|
|
34
|
+
};
|
|
35
|
+
close?: () => Promise<void> | void;
|
|
36
|
+
};
|
|
37
|
+
export type VoiceLanguageStrategy = {
|
|
38
|
+
mode: "auto-detect";
|
|
39
|
+
allowedLanguages?: string[];
|
|
40
|
+
} | {
|
|
41
|
+
mode: "fixed";
|
|
42
|
+
primaryLanguage: string;
|
|
43
|
+
secondaryLanguages?: string[];
|
|
44
|
+
} | {
|
|
45
|
+
mode: "allow-switching";
|
|
46
|
+
primaryLanguage?: string;
|
|
47
|
+
secondaryLanguages: string[];
|
|
48
|
+
};
|
|
49
|
+
export type VoiceLanguageStrategyResolver<TContext = unknown> = (input: {
|
|
50
|
+
context: TContext;
|
|
51
|
+
scenarioId?: string;
|
|
52
|
+
sessionId: string;
|
|
53
|
+
}) => Promise<VoiceLanguageStrategy | void> | VoiceLanguageStrategy | void;
|
|
54
|
+
export type VoicePhraseHint = {
|
|
55
|
+
text: string;
|
|
56
|
+
aliases?: string[];
|
|
57
|
+
boost?: number;
|
|
58
|
+
metadata?: Record<string, unknown>;
|
|
59
|
+
};
|
|
60
|
+
export type VoiceCorrectionRiskTier = "safe" | "balanced" | "risky";
|
|
61
|
+
export type VoiceDomainTerm = {
|
|
62
|
+
text: string;
|
|
63
|
+
aliases?: string[];
|
|
64
|
+
boost?: number;
|
|
65
|
+
language?: string;
|
|
66
|
+
metadata?: Record<string, unknown>;
|
|
67
|
+
pronunciation?: string;
|
|
68
|
+
};
|
|
69
|
+
export type VoiceLexiconEntry = {
|
|
70
|
+
text: string;
|
|
71
|
+
aliases?: string[];
|
|
72
|
+
language?: string;
|
|
73
|
+
metadata?: Record<string, unknown>;
|
|
74
|
+
pronunciation?: string;
|
|
75
|
+
};
|
|
76
|
+
export type VoiceTranscriptSentiment = {
|
|
77
|
+
label: "negative" | "neutral" | "positive" | (string & {});
|
|
78
|
+
metadata?: Record<string, unknown>;
|
|
79
|
+
score?: number;
|
|
80
|
+
};
|
|
81
|
+
/** A provider-normalized word hypothesis. Keeping this evidence attached to the
|
|
82
|
+
* transcript lets applications detect a single risky name or number that would
|
|
83
|
+
* otherwise disappear inside a high turn-level average confidence. */
|
|
84
|
+
export type TranscriptWord = {
|
|
85
|
+
confidence?: number;
|
|
86
|
+
endedAtMs?: number;
|
|
87
|
+
language?: string;
|
|
88
|
+
punctuatedText?: string;
|
|
89
|
+
speaker?: string | number;
|
|
90
|
+
startedAtMs?: number;
|
|
91
|
+
text: string;
|
|
92
|
+
};
|
|
93
|
+
/** Provider token evidence. Tokens are intentionally kept separate from words:
|
|
94
|
+
* subword log probabilities are useful for calibration and routing, but are not
|
|
95
|
+
* word-level timestamps or confidence scores. */
|
|
96
|
+
export type TranscriptToken = {
|
|
97
|
+
bytes?: number[];
|
|
98
|
+
confidence?: number;
|
|
99
|
+
logProbability?: number;
|
|
100
|
+
text: string;
|
|
101
|
+
};
|
|
102
|
+
export type Transcript = {
|
|
103
|
+
id: string;
|
|
104
|
+
text: string;
|
|
105
|
+
isFinal: boolean;
|
|
106
|
+
confidence?: number;
|
|
107
|
+
language?: string;
|
|
108
|
+
sentiment?: VoiceTranscriptSentiment;
|
|
109
|
+
speaker?: string | number;
|
|
110
|
+
startedAtMs?: number;
|
|
111
|
+
endedAtMs?: number;
|
|
112
|
+
vendor?: string;
|
|
113
|
+
tokens?: TranscriptToken[];
|
|
114
|
+
words?: TranscriptWord[];
|
|
115
|
+
};
|
|
116
|
+
export type VoiceSTTSessionConfiguration = {
|
|
117
|
+
languageHints?: string[];
|
|
118
|
+
lexicon?: VoiceLexiconEntry[];
|
|
119
|
+
phraseHints?: VoicePhraseHint[];
|
|
120
|
+
turnDetection?: Partial<VoiceTurnDetectionConfig>;
|
|
121
|
+
};
|
|
122
|
+
export type VoiceTranscriptQuality = {
|
|
123
|
+
averageConfidence?: number;
|
|
124
|
+
confidenceSampleCount: number;
|
|
125
|
+
correction?: VoiceTurnCorrectionDiagnostics;
|
|
126
|
+
cost?: VoiceTurnCostEstimate;
|
|
127
|
+
fallbackUsed: boolean;
|
|
128
|
+
finalTranscriptCount: number;
|
|
129
|
+
fallback?: VoiceFallbackDiagnostics;
|
|
130
|
+
partialTranscriptCount: number;
|
|
131
|
+
selectedTranscriptCount: number;
|
|
132
|
+
source: "fallback" | "primary";
|
|
133
|
+
lowestWordConfidence?: number;
|
|
134
|
+
wordConfidenceSampleCount?: number;
|
|
135
|
+
};
|
|
136
|
+
export type VoiceTurnCorrectionDiagnostics = {
|
|
137
|
+
attempted: boolean;
|
|
138
|
+
changed: boolean;
|
|
139
|
+
correctedText: string;
|
|
140
|
+
metadata?: Record<string, unknown>;
|
|
141
|
+
originalText: string;
|
|
142
|
+
provider?: string;
|
|
143
|
+
reason?: string;
|
|
144
|
+
};
|
|
145
|
+
export type VoiceTurnCostEstimate = {
|
|
146
|
+
estimatedRelativeCostUnits: number;
|
|
147
|
+
fallbackAttemptCount: number;
|
|
148
|
+
fallbackReplayAudioMs: number;
|
|
149
|
+
primaryAudioMs: number;
|
|
150
|
+
totalBillableAudioMs: number;
|
|
151
|
+
};
|
|
152
|
+
export type VoiceFallbackSelectionReason = "fallback-empty" | "primary-empty" | "word-count-margin" | "confidence-margin" | "word-count-tiebreak" | "policy-preference" | "kept-primary";
|
|
153
|
+
export type VoiceFallbackDiagnostics = {
|
|
154
|
+
attempted: boolean;
|
|
155
|
+
fallbackConfidence?: number;
|
|
156
|
+
fallbackText?: string;
|
|
157
|
+
fallbackWordCount?: number;
|
|
158
|
+
primaryConfidence: number;
|
|
159
|
+
primaryText: string;
|
|
160
|
+
primaryWordCount: number;
|
|
161
|
+
selected: boolean;
|
|
162
|
+
selectionReason: VoiceFallbackSelectionReason;
|
|
163
|
+
trigger: "empty-turn" | "low-confidence" | "empty-or-low-confidence" | "always";
|
|
164
|
+
triggerReason?: VoiceFallbackTriggerReason;
|
|
165
|
+
};
|
|
166
|
+
export type VoicePartialEvent = {
|
|
167
|
+
type: "partial";
|
|
168
|
+
transcript: Transcript;
|
|
169
|
+
receivedAt: number;
|
|
170
|
+
};
|
|
171
|
+
export type VoiceFinalEvent = {
|
|
172
|
+
type: "final";
|
|
173
|
+
transcript: Transcript;
|
|
174
|
+
receivedAt: number;
|
|
175
|
+
};
|
|
176
|
+
export type VoiceEndOfTurnEvent = {
|
|
177
|
+
type: "endOfTurn";
|
|
178
|
+
reason: "vendor" | "silence" | "manual";
|
|
179
|
+
receivedAt: number;
|
|
180
|
+
};
|
|
181
|
+
export type VoiceErrorEvent = {
|
|
182
|
+
type: "error";
|
|
183
|
+
error: Error;
|
|
184
|
+
recoverable: boolean;
|
|
185
|
+
code?: string;
|
|
186
|
+
};
|
|
187
|
+
export type VoiceCloseEvent = {
|
|
188
|
+
type: "close";
|
|
189
|
+
code?: number;
|
|
190
|
+
reason?: string;
|
|
191
|
+
recoverable?: boolean;
|
|
192
|
+
};
|
|
193
|
+
export type STTSessionEventMap = {
|
|
194
|
+
partial: VoicePartialEvent;
|
|
195
|
+
final: VoiceFinalEvent;
|
|
196
|
+
endOfTurn: VoiceEndOfTurnEvent;
|
|
197
|
+
error: VoiceErrorEvent;
|
|
198
|
+
close: VoiceCloseEvent;
|
|
199
|
+
};
|
|
200
|
+
export type STTAdapterSession = {
|
|
201
|
+
on: <K extends keyof STTSessionEventMap>(event: K, handler: (payload: STTSessionEventMap[K]) => void | Promise<void>) => () => void;
|
|
202
|
+
send: (audio: AudioChunk) => Promise<void>;
|
|
203
|
+
/** Update provider-supported STT context without restarting the stream. */
|
|
204
|
+
configure?: (configuration: VoiceSTTSessionConfiguration) => Promise<void>;
|
|
205
|
+
close: (reason?: string) => Promise<void>;
|
|
206
|
+
};
|
|
207
|
+
export type STTAdapterOpenOptions = {
|
|
208
|
+
sessionId: string;
|
|
209
|
+
format: AudioFormat;
|
|
210
|
+
languageStrategy?: VoiceLanguageStrategy;
|
|
211
|
+
lexicon?: VoiceLexiconEntry[];
|
|
212
|
+
phraseHints?: VoicePhraseHint[];
|
|
213
|
+
signal?: AbortSignal;
|
|
214
|
+
};
|
|
215
|
+
export type STTAdapter<TOptions extends STTAdapterOpenOptions = STTAdapterOpenOptions> = {
|
|
216
|
+
kind: "stt";
|
|
217
|
+
open: (options: TOptions) => Promise<STTAdapterSession> | STTAdapterSession;
|
|
218
|
+
};
|
|
219
|
+
export type TTSAudioEvent = {
|
|
220
|
+
type: "audio";
|
|
221
|
+
chunk: AudioChunk;
|
|
222
|
+
format: AudioFormat;
|
|
223
|
+
receivedAt: number;
|
|
224
|
+
};
|
|
225
|
+
export type TTSSessionEventMap = {
|
|
226
|
+
audio: TTSAudioEvent;
|
|
227
|
+
error: VoiceErrorEvent;
|
|
228
|
+
close: VoiceCloseEvent;
|
|
229
|
+
};
|
|
230
|
+
export type TTSAdapterSession = {
|
|
231
|
+
on: <K extends keyof TTSSessionEventMap>(event: K, handler: (payload: TTSSessionEventMap[K]) => void | Promise<void>) => () => void;
|
|
232
|
+
send: (text: string) => Promise<void>;
|
|
233
|
+
cancel?: (reason?: string) => Promise<void>;
|
|
234
|
+
close: (reason?: string) => Promise<void>;
|
|
235
|
+
};
|
|
236
|
+
export declare const ttsAdapterSessionCanCancel: (session: TTSAdapterSession) => session is TTSAdapterSession & {
|
|
237
|
+
cancel: (reason?: string) => Promise<void>;
|
|
238
|
+
};
|
|
239
|
+
export type VoiceTTSProsody = {
|
|
240
|
+
emphasis?: number;
|
|
241
|
+
pitch?: number;
|
|
242
|
+
speed?: number;
|
|
243
|
+
style?: string;
|
|
244
|
+
};
|
|
245
|
+
export type TTSAdapterOpenOptions = {
|
|
246
|
+
sessionId: string;
|
|
247
|
+
lexicon?: VoiceLexiconEntry[];
|
|
248
|
+
prosody?: VoiceTTSProsody;
|
|
249
|
+
signal?: AbortSignal;
|
|
250
|
+
};
|
|
251
|
+
export type TTSAdapter<TOptions extends TTSAdapterOpenOptions = TTSAdapterOpenOptions> = {
|
|
252
|
+
kind: "tts";
|
|
253
|
+
open: (options: TOptions) => Promise<TTSAdapterSession> | TTSAdapterSession;
|
|
254
|
+
};
|
|
255
|
+
export type RealtimeSessionEventMap = STTSessionEventMap & {
|
|
256
|
+
audio: TTSAudioEvent;
|
|
257
|
+
};
|
|
258
|
+
export type RealtimeAdapterSession = {
|
|
259
|
+
on: <K extends keyof RealtimeSessionEventMap>(event: K, handler: (payload: RealtimeSessionEventMap[K]) => void | Promise<void>) => () => void;
|
|
260
|
+
send: (input: AudioChunk | string) => Promise<void>;
|
|
261
|
+
/** Update provider-supported input transcription context in place. */
|
|
262
|
+
configure?: (configuration: VoiceSTTSessionConfiguration) => Promise<void>;
|
|
263
|
+
close: (reason?: string) => Promise<void>;
|
|
264
|
+
};
|
|
265
|
+
export type RealtimeAdapterOpenOptions = {
|
|
266
|
+
sessionId: string;
|
|
267
|
+
format: AudioFormat;
|
|
268
|
+
languageStrategy?: VoiceLanguageStrategy;
|
|
269
|
+
lexicon?: VoiceLexiconEntry[];
|
|
270
|
+
modalities?: ReadonlyArray<"audio" | "text">;
|
|
271
|
+
phraseHints?: VoicePhraseHint[];
|
|
272
|
+
promptCacheKey?: string;
|
|
273
|
+
semanticVAD?: import("./assistantMode").VoiceSemanticVADConfig;
|
|
274
|
+
signal?: AbortSignal;
|
|
275
|
+
};
|
|
276
|
+
export type RealtimeAdapter<TOptions extends RealtimeAdapterOpenOptions = RealtimeAdapterOpenOptions> = {
|
|
277
|
+
kind: "realtime";
|
|
278
|
+
open: (options: TOptions) => Promise<RealtimeAdapterSession> | RealtimeAdapterSession;
|
|
279
|
+
};
|
|
280
|
+
export type VoiceSessionStatus = "active" | "reconnecting" | "completed" | "failed";
|
|
281
|
+
export type VoiceReconnectClientStatus = "idle" | "reconnecting" | "resumed" | "exhausted";
|
|
282
|
+
export type VoiceReconnectClientState = {
|
|
283
|
+
attempts: number;
|
|
284
|
+
lastDisconnectAt?: number;
|
|
285
|
+
lastResumedAt?: number;
|
|
286
|
+
maxAttempts: number;
|
|
287
|
+
nextAttemptAt?: number;
|
|
288
|
+
status: VoiceReconnectClientStatus;
|
|
289
|
+
};
|
|
290
|
+
export type VoiceTurnCitation = {
|
|
291
|
+
chunkId: string;
|
|
292
|
+
score: number;
|
|
293
|
+
source?: string;
|
|
294
|
+
title?: string;
|
|
295
|
+
};
|
|
296
|
+
export type VoiceTurnRecord<TResult = unknown> = {
|
|
297
|
+
id: string;
|
|
298
|
+
text: string;
|
|
299
|
+
quality?: VoiceTranscriptQuality;
|
|
300
|
+
transcripts: Transcript[];
|
|
301
|
+
assistantText?: string;
|
|
302
|
+
attachments?: import("./agent").VoiceAgentMessageAttachment[];
|
|
303
|
+
citations?: VoiceTurnCitation[];
|
|
304
|
+
committedAt: number;
|
|
305
|
+
result?: TResult;
|
|
306
|
+
};
|
|
307
|
+
export type VoiceCostTelemetryConfig<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
|
|
308
|
+
fallbackPassCostUnit?: number;
|
|
309
|
+
onTurnCost?: (input: {
|
|
310
|
+
api: VoiceSessionHandle<TContext, TSession, TResult>;
|
|
311
|
+
context: TContext;
|
|
312
|
+
estimate: VoiceTurnCostEstimate;
|
|
313
|
+
session: TSession;
|
|
314
|
+
turn: VoiceTurnRecord<TResult>;
|
|
315
|
+
}) => Promise<void> | void;
|
|
316
|
+
primaryPassCostUnit?: number;
|
|
317
|
+
};
|
|
318
|
+
export type VoiceSessionRecord<TMeta = Record<string, never>, TResult = unknown> = {
|
|
319
|
+
id: string;
|
|
320
|
+
createdAt: number;
|
|
321
|
+
/** Persisted before the initial assistant greeting is emitted so reconnects
|
|
322
|
+
* cannot replay the full introduction when the caller has not answered yet. */
|
|
323
|
+
greetingDeliveredAt?: number;
|
|
324
|
+
lastActivityAt?: number;
|
|
325
|
+
status: VoiceSessionStatus;
|
|
326
|
+
transcripts: Transcript[];
|
|
327
|
+
currentTurn: {
|
|
328
|
+
transcripts: Transcript[];
|
|
329
|
+
partialText: string;
|
|
330
|
+
partialStartedAt?: number;
|
|
331
|
+
partialEndedAt?: number;
|
|
332
|
+
finalText: string;
|
|
333
|
+
lastAudioAt?: number;
|
|
334
|
+
lastSpeechAt?: number;
|
|
335
|
+
lastTranscriptAt?: number;
|
|
336
|
+
silenceStartedAt?: number;
|
|
337
|
+
};
|
|
338
|
+
turns: VoiceTurnRecord<TResult>[];
|
|
339
|
+
committedTurnIds: string[];
|
|
340
|
+
reconnect: {
|
|
341
|
+
attempts: number;
|
|
342
|
+
lastDisconnectAt?: number;
|
|
343
|
+
};
|
|
344
|
+
/** Durable caller pause state so a reconnect or process replacement restores
|
|
345
|
+
* the remaining pause window instead of rearming conversation watchdogs. */
|
|
346
|
+
pause?: {
|
|
347
|
+
expiresAt: number;
|
|
348
|
+
pausedAt: number;
|
|
349
|
+
};
|
|
350
|
+
lastCommittedTurn?: {
|
|
351
|
+
signature: string;
|
|
352
|
+
text: string;
|
|
353
|
+
transcriptIds: string[];
|
|
354
|
+
committedAt: number;
|
|
355
|
+
};
|
|
356
|
+
call?: VoiceCallLifecycleState;
|
|
357
|
+
metadata?: TMeta;
|
|
358
|
+
scenarioId?: string;
|
|
359
|
+
};
|
|
360
|
+
export type VoiceSessionSummary = {
|
|
361
|
+
id: string;
|
|
362
|
+
createdAt: number;
|
|
363
|
+
lastActivityAt?: number;
|
|
364
|
+
status: VoiceSessionStatus;
|
|
365
|
+
turnCount: number;
|
|
366
|
+
};
|
|
367
|
+
export type VoiceCallDisposition = "completed" | "transferred" | "escalated" | "voicemail" | "no-answer" | "failed" | "silence-timeout" | "closed";
|
|
368
|
+
export type VoiceCallLifecycleEvent = {
|
|
369
|
+
at: number;
|
|
370
|
+
type: "start" | "end" | "transfer" | "escalation" | "voicemail" | "no-answer";
|
|
371
|
+
disposition?: VoiceCallDisposition;
|
|
372
|
+
metadata?: Record<string, unknown>;
|
|
373
|
+
reason?: string;
|
|
374
|
+
target?: string;
|
|
375
|
+
};
|
|
376
|
+
export type VoiceCallLifecycleState = {
|
|
377
|
+
disposition?: VoiceCallDisposition;
|
|
378
|
+
endedAt?: number;
|
|
379
|
+
events: VoiceCallLifecycleEvent[];
|
|
380
|
+
lastEventAt: number;
|
|
381
|
+
startedAt: number;
|
|
382
|
+
};
|
|
383
|
+
export type VoiceHandoffAction = "escalate" | "no-answer" | "transfer" | "voicemail";
|
|
384
|
+
export type VoiceHandoffStatus = "delivered" | "failed" | "skipped";
|
|
385
|
+
export type VoiceHandoffResult = {
|
|
386
|
+
deliveredAt?: number;
|
|
387
|
+
deliveredTo?: string;
|
|
388
|
+
error?: string;
|
|
389
|
+
metadata?: Record<string, unknown>;
|
|
390
|
+
status: VoiceHandoffStatus;
|
|
391
|
+
};
|
|
392
|
+
export type VoiceHandoffDeliveryQueueStatus = VoiceHandoffStatus | "pending";
|
|
393
|
+
export type StoredVoiceHandoffDelivery<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
|
|
394
|
+
action: VoiceHandoffAction;
|
|
395
|
+
context: TContext;
|
|
396
|
+
createdAt: number;
|
|
397
|
+
deliveredAt?: number;
|
|
398
|
+
deliveries?: Record<string, VoiceHandoffResult & {
|
|
399
|
+
adapterId: string;
|
|
400
|
+
adapterKind?: string;
|
|
401
|
+
}>;
|
|
402
|
+
deliveryAttempts?: number;
|
|
403
|
+
deliveryError?: string;
|
|
404
|
+
deliveryStatus: VoiceHandoffDeliveryQueueStatus;
|
|
405
|
+
id: string;
|
|
406
|
+
metadata?: Record<string, unknown>;
|
|
407
|
+
reason?: string;
|
|
408
|
+
result?: TResult;
|
|
409
|
+
session: TSession;
|
|
410
|
+
sessionId: string;
|
|
411
|
+
target?: string;
|
|
412
|
+
updatedAt: number;
|
|
413
|
+
};
|
|
414
|
+
export type VoiceHandoffDeliveryStore<TDelivery extends StoredVoiceHandoffDelivery = StoredVoiceHandoffDelivery> = {
|
|
415
|
+
get: (id: string) => Promise<TDelivery | undefined> | TDelivery | undefined;
|
|
416
|
+
list: () => Promise<TDelivery[]> | TDelivery[];
|
|
417
|
+
remove: (id: string) => Promise<void> | void;
|
|
418
|
+
set: (id: string, delivery: TDelivery) => Promise<void> | void;
|
|
419
|
+
};
|
|
420
|
+
export type VoiceHandoffInput<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
|
|
421
|
+
action: VoiceHandoffAction;
|
|
422
|
+
api: VoiceSessionHandle<TContext, TSession, TResult>;
|
|
423
|
+
context: TContext;
|
|
424
|
+
metadata?: Record<string, unknown>;
|
|
425
|
+
reason?: string;
|
|
426
|
+
result?: TResult;
|
|
427
|
+
session: TSession;
|
|
428
|
+
target?: string;
|
|
429
|
+
};
|
|
430
|
+
export type VoiceHandoffAdapter<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
|
|
431
|
+
actions?: VoiceHandoffAction[];
|
|
432
|
+
handoff: (input: VoiceHandoffInput<TContext, TSession, TResult>) => Promise<VoiceHandoffResult> | VoiceHandoffResult;
|
|
433
|
+
id: string;
|
|
434
|
+
kind?: string;
|
|
435
|
+
};
|
|
436
|
+
export type VoiceHandoffConfig<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
|
|
437
|
+
adapters: VoiceHandoffAdapter<TContext, TSession, TResult>[];
|
|
438
|
+
deliveryQueue?: VoiceHandoffDeliveryStore<StoredVoiceHandoffDelivery<TContext, TSession, TResult>>;
|
|
439
|
+
enqueueOnly?: boolean;
|
|
440
|
+
failMode?: "record" | "throw";
|
|
441
|
+
};
|
|
442
|
+
export type VoiceSessionStore<TSession extends VoiceSessionRecord = VoiceSessionRecord> = {
|
|
443
|
+
get: (id: string) => Promise<TSession | undefined>;
|
|
444
|
+
getOrCreate: (id: string) => Promise<TSession>;
|
|
445
|
+
set: (id: string, value: TSession) => Promise<void>;
|
|
446
|
+
list: () => Promise<VoiceSessionSummary[]>;
|
|
447
|
+
remove: (id: string) => Promise<void>;
|
|
448
|
+
};
|
|
449
|
+
export type VoiceLogger = {
|
|
450
|
+
debug?: (message: string, meta?: Record<string, unknown>) => void;
|
|
451
|
+
info?: (message: string, meta?: Record<string, unknown>) => void;
|
|
452
|
+
warn?: (message: string, meta?: Record<string, unknown>) => void;
|
|
453
|
+
error?: (message: string, meta?: Record<string, unknown>) => void;
|
|
454
|
+
};
|
|
455
|
+
export type VoiceReconnectConfig = {
|
|
456
|
+
strategy?: "resume-last-turn" | "restart" | "fail";
|
|
457
|
+
timeout?: number;
|
|
458
|
+
maxAttempts?: number;
|
|
459
|
+
};
|
|
460
|
+
export type VoiceRuntimePreset = "default" | "chat" | "guided-intake" | "dictation" | "noisy-room" | "pstn-balanced" | "pstn-fast" | "reliability";
|
|
461
|
+
export type VoiceSTTLifecycle = "continuous" | "turn-scoped";
|
|
462
|
+
export type VoiceTurnProfile = "fast" | "balanced" | "long-form";
|
|
463
|
+
export type VoiceTurnQualityProfile = "general" | "accent-heavy" | "noisy-room" | "short-command";
|
|
464
|
+
export type VoiceTurnFallbackTrigger = "empty-turn" | "low-confidence" | "empty-or-low-confidence" | "always";
|
|
465
|
+
export type VoiceFallbackTriggerReason = "always" | "empty-turn" | "risk-policy" | "transcript-confidence" | "word-confidence";
|
|
466
|
+
export type VoiceSTTFallbackCandidate = {
|
|
467
|
+
averageConfidence: number;
|
|
468
|
+
lowestWordConfidence?: number;
|
|
469
|
+
text: string;
|
|
470
|
+
transcripts: Transcript[];
|
|
471
|
+
wordCount: number;
|
|
472
|
+
words: TranscriptWord[];
|
|
473
|
+
};
|
|
474
|
+
export type VoiceSTTFallbackRiskPolicy = (candidate: VoiceSTTFallbackCandidate) => boolean;
|
|
475
|
+
export type VoiceSTTFallbackConfig = {
|
|
476
|
+
adapter: STTAdapter;
|
|
477
|
+
trigger?: VoiceTurnFallbackTrigger;
|
|
478
|
+
confidenceThreshold?: number;
|
|
479
|
+
minTextLength?: number;
|
|
480
|
+
replayWindowMs?: number;
|
|
481
|
+
settleMs?: number;
|
|
482
|
+
completionTimeoutMs?: number;
|
|
483
|
+
maxAttemptsPerTurn?: number;
|
|
484
|
+
/** Run the fallback when any provider word falls below this value. */
|
|
485
|
+
wordConfidenceThreshold?: number;
|
|
486
|
+
/** Application-specific routing for high-value turns, entities, or correction
|
|
487
|
+
* language that should receive a second transcription pass regardless of the
|
|
488
|
+
* aggregate confidence. */
|
|
489
|
+
riskPolicy?: VoiceSTTFallbackRiskPolicy;
|
|
490
|
+
/** Prefer a non-empty independent fallback for these audited trigger reasons,
|
|
491
|
+
* including providers that do not expose comparable confidence scores. */
|
|
492
|
+
preferFallbackOn?: VoiceFallbackTriggerReason[];
|
|
493
|
+
};
|
|
494
|
+
export type VoiceResolvedSTTFallbackConfig = {
|
|
495
|
+
adapter: STTAdapter;
|
|
496
|
+
trigger: VoiceTurnFallbackTrigger;
|
|
497
|
+
confidenceThreshold: number;
|
|
498
|
+
minTextLength: number;
|
|
499
|
+
replayWindowMs: number;
|
|
500
|
+
settleMs: number;
|
|
501
|
+
completionTimeoutMs: number;
|
|
502
|
+
maxAttemptsPerTurn: number;
|
|
503
|
+
wordConfidenceThreshold?: number;
|
|
504
|
+
riskPolicy?: VoiceSTTFallbackRiskPolicy;
|
|
505
|
+
preferFallbackOn?: VoiceFallbackTriggerReason[];
|
|
506
|
+
};
|
|
507
|
+
export type VoiceTurnDetectionConfig = {
|
|
508
|
+
profile?: VoiceTurnProfile;
|
|
509
|
+
qualityProfile?: VoiceTurnQualityProfile;
|
|
510
|
+
silenceMs?: number;
|
|
511
|
+
minSilenceMs?: number;
|
|
512
|
+
speechThreshold?: number;
|
|
513
|
+
transcriptStabilityMs?: number;
|
|
514
|
+
};
|
|
515
|
+
export type VoiceResolvedTurnDetectionConfig = {
|
|
516
|
+
qualityProfile: VoiceTurnQualityProfile;
|
|
517
|
+
profile: VoiceTurnProfile;
|
|
518
|
+
silenceMs: number;
|
|
519
|
+
minSilenceMs: number;
|
|
520
|
+
speechThreshold: number;
|
|
521
|
+
transcriptStabilityMs: number;
|
|
522
|
+
};
|
|
523
|
+
export type VoiceAudioConditioningConfig = {
|
|
524
|
+
enabled?: boolean;
|
|
525
|
+
targetLevel?: number;
|
|
526
|
+
maxGain?: number;
|
|
527
|
+
noiseGateThreshold?: number;
|
|
528
|
+
noiseGateAttenuation?: number;
|
|
529
|
+
};
|
|
530
|
+
export type VoiceResolvedAudioConditioningConfig = {
|
|
531
|
+
enabled: true;
|
|
532
|
+
targetLevel: number;
|
|
533
|
+
maxGain: number;
|
|
534
|
+
noiseGateThreshold: number;
|
|
535
|
+
noiseGateAttenuation: number;
|
|
536
|
+
};
|
|
537
|
+
export type VoiceSocket = {
|
|
538
|
+
send: (data: string | Uint8Array | ArrayBuffer) => void | Promise<void>;
|
|
539
|
+
close: (code?: number, reason?: string) => void | Promise<void>;
|
|
540
|
+
/**
|
|
541
|
+
* Discard any audio already buffered downstream (e.g. a telephony carrier's
|
|
542
|
+
* outbound media buffer). Called on barge-in so the caller stops hearing the
|
|
543
|
+
* assistant immediately, even when frames have already been flushed to the
|
|
544
|
+
* transport. Optional: transports without a flush concept omit it.
|
|
545
|
+
*/
|
|
546
|
+
clear?: () => void | Promise<void>;
|
|
547
|
+
};
|
|
548
|
+
export type VoiceMonitorRuntimeSessionBinding = {
|
|
549
|
+
deregister: (reason?: string) => void;
|
|
550
|
+
emitAudio: (chunk: Uint8Array | ArrayBuffer, options?: {
|
|
551
|
+
source?: "assistant" | "caller" | (string & {});
|
|
552
|
+
}) => void;
|
|
553
|
+
};
|
|
554
|
+
export type VoiceMonitorRuntimeRegisterInput = {
|
|
555
|
+
handle: VoiceSessionHandle<unknown, VoiceSessionRecord, unknown>;
|
|
556
|
+
metadata?: Record<string, unknown>;
|
|
557
|
+
sessionId: string;
|
|
558
|
+
};
|
|
559
|
+
export type VoiceMonitorRuntimeBinding = {
|
|
560
|
+
registerSession: (input: VoiceMonitorRuntimeRegisterInput) => VoiceMonitorRuntimeSessionBinding;
|
|
561
|
+
};
|
|
562
|
+
export type VoiceSessionHandle<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
|
|
563
|
+
id: string;
|
|
564
|
+
connect: (socket: VoiceSocket) => Promise<void>;
|
|
565
|
+
receiveAudio: (audio: AudioChunk) => Promise<void>;
|
|
566
|
+
attachUserMedia: (attachment: import("./agent").VoiceAgentMessageAttachment) => Promise<void>;
|
|
567
|
+
commitTurn: (reason?: VoiceEndOfTurnEvent["reason"]) => Promise<void>;
|
|
568
|
+
disconnect: (event?: VoiceCloseEvent) => Promise<void>;
|
|
569
|
+
complete: (result?: TResult) => Promise<void>;
|
|
570
|
+
escalate: (input: {
|
|
571
|
+
metadata?: Record<string, unknown>;
|
|
572
|
+
reason: string;
|
|
573
|
+
result?: TResult;
|
|
574
|
+
}) => Promise<void>;
|
|
575
|
+
fail: (error: unknown) => Promise<void>;
|
|
576
|
+
markNoAnswer: (input?: {
|
|
577
|
+
metadata?: Record<string, unknown>;
|
|
578
|
+
result?: TResult;
|
|
579
|
+
}) => Promise<void>;
|
|
580
|
+
markVoicemail: (input?: {
|
|
581
|
+
metadata?: Record<string, unknown>;
|
|
582
|
+
result?: TResult;
|
|
583
|
+
}) => Promise<void>;
|
|
584
|
+
transfer: (input: {
|
|
585
|
+
metadata?: Record<string, unknown>;
|
|
586
|
+
reason?: string;
|
|
587
|
+
result?: TResult;
|
|
588
|
+
target: string;
|
|
589
|
+
transferMode?: "cold" | "warm";
|
|
590
|
+
}) => Promise<void>;
|
|
591
|
+
close: (reason?: string) => Promise<void>;
|
|
592
|
+
/**
|
|
593
|
+
* Caller-driven in-call pause: the session stays LIVE (socket, state,
|
|
594
|
+
* transcript) but every idle/silence watchdog is suspended and turn
|
|
595
|
+
* processing is skipped, so a paused caller is never nudged or hung up on.
|
|
596
|
+
* Past `pause.maxMs` (default 10 min) the session closes gracefully with
|
|
597
|
+
* reason "pause-timeout" — completed turns stay durably persisted, so the
|
|
598
|
+
* host's normal draft/resume path takes over.
|
|
599
|
+
*/
|
|
600
|
+
pause: () => Promise<void>;
|
|
601
|
+
/** Lift a caller-driven pause: watchdogs re-arm and turns process again. */
|
|
602
|
+
resume: () => Promise<void>;
|
|
603
|
+
snapshot: () => Promise<TSession>;
|
|
604
|
+
/** Ask connected browser clients to change assistant-audio playback speed. */
|
|
605
|
+
setPlaybackRate: (rate: number) => Promise<number>;
|
|
606
|
+
/**
|
|
607
|
+
* Mutate the live turn-detection config for this session — useful when a
|
|
608
|
+
* tool call wants to dial silenceMs up ("the caller asked for more time")
|
|
609
|
+
* or down. The change takes effect on the NEXT silence-timer schedule, so
|
|
610
|
+
* an in-flight commit isn't cancelled. Returns the merged config so the
|
|
611
|
+
* caller can confirm.
|
|
612
|
+
*/
|
|
613
|
+
setTurnDetection: (patch: Partial<VoiceTurnDetectionConfig>) => Promise<{
|
|
614
|
+
silenceMs: number;
|
|
615
|
+
speechThreshold: number;
|
|
616
|
+
transcriptStabilityMs: number;
|
|
617
|
+
}>;
|
|
618
|
+
/** Refresh vocabulary, language hints, or provider turn settings while a
|
|
619
|
+
* call is active. Unsupported fields are ignored by the active adapter. */
|
|
620
|
+
configureSTT: (configuration: VoiceSTTSessionConfiguration) => Promise<void>;
|
|
621
|
+
};
|
|
622
|
+
export type VoiceLLMUsage = {
|
|
623
|
+
provider?: string;
|
|
624
|
+
model?: string;
|
|
625
|
+
inputTokens?: number;
|
|
626
|
+
outputTokens?: number;
|
|
627
|
+
cachedInputTokens?: number;
|
|
628
|
+
};
|
|
629
|
+
export type VoiceRouteResult<TResult = unknown> = {
|
|
630
|
+
complete?: boolean;
|
|
631
|
+
result?: TResult;
|
|
632
|
+
assistantText?: string;
|
|
633
|
+
usage?: VoiceLLMUsage;
|
|
634
|
+
citations?: ReadonlyArray<VoiceTurnCitation>;
|
|
635
|
+
transfer?: {
|
|
636
|
+
metadata?: Record<string, unknown>;
|
|
637
|
+
reason?: string;
|
|
638
|
+
target: string;
|
|
639
|
+
transferMode?: "cold" | "warm";
|
|
640
|
+
};
|
|
641
|
+
escalate?: {
|
|
642
|
+
metadata?: Record<string, unknown>;
|
|
643
|
+
reason: string;
|
|
644
|
+
};
|
|
645
|
+
voicemail?: {
|
|
646
|
+
metadata?: Record<string, unknown>;
|
|
647
|
+
};
|
|
648
|
+
noAnswer?: {
|
|
649
|
+
metadata?: Record<string, unknown>;
|
|
650
|
+
};
|
|
651
|
+
};
|
|
652
|
+
export type VoiceTurnCorrectionResult = string | {
|
|
653
|
+
text: string;
|
|
654
|
+
reason?: string;
|
|
655
|
+
provider?: string;
|
|
656
|
+
metadata?: Record<string, unknown>;
|
|
657
|
+
};
|
|
658
|
+
export type VoiceTurnCorrectionHandler<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = (input: {
|
|
659
|
+
api: VoiceSessionHandle<TContext, TSession, TResult>;
|
|
660
|
+
context: TContext;
|
|
661
|
+
fallback?: VoiceFallbackDiagnostics;
|
|
662
|
+
lexicon: VoiceLexiconEntry[];
|
|
663
|
+
phraseHints: VoicePhraseHint[];
|
|
664
|
+
session: TSession;
|
|
665
|
+
text: string;
|
|
666
|
+
transcripts: Transcript[];
|
|
667
|
+
}) => Promise<VoiceTurnCorrectionResult | void> | VoiceTurnCorrectionResult | void;
|
|
668
|
+
export type VoicePhraseHintResolver<TContext = unknown> = (input: {
|
|
669
|
+
context: TContext;
|
|
670
|
+
scenarioId?: string;
|
|
671
|
+
sessionId: string;
|
|
672
|
+
}) => Promise<VoicePhraseHint[] | void> | VoicePhraseHint[] | void;
|
|
673
|
+
export type VoiceLexiconResolver<TContext = unknown> = (input: {
|
|
674
|
+
context: TContext;
|
|
675
|
+
scenarioId?: string;
|
|
676
|
+
sessionId: string;
|
|
677
|
+
}) => Promise<VoiceLexiconEntry[] | void> | VoiceLexiconEntry[] | void;
|
|
678
|
+
export type VoiceOnTurnObjectHandler<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = (input: {
|
|
679
|
+
context: TContext;
|
|
680
|
+
liveOps?: {
|
|
681
|
+
control: VoiceLiveOpsControlState;
|
|
682
|
+
injectedInstruction?: string;
|
|
683
|
+
};
|
|
684
|
+
onTextDelta?: (delta: string) => void;
|
|
685
|
+
session: TSession;
|
|
686
|
+
turn: VoiceTurnRecord;
|
|
687
|
+
api: VoiceSessionHandle<TContext, TSession, TResult>;
|
|
688
|
+
speculativeReply?: {
|
|
689
|
+
text: string;
|
|
690
|
+
};
|
|
691
|
+
}) => Promise<VoiceRouteResult<TResult> | void> | VoiceRouteResult<TResult> | void;
|
|
692
|
+
export type VoiceOnTurnHandler<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = VoiceOnTurnObjectHandler<TContext, TSession, TResult> | ((session: TSession, turn: VoiceTurnRecord, api: VoiceSessionHandle<TContext, TSession, TResult>, context: TContext) => Promise<VoiceRouteResult<TResult> | void> | VoiceRouteResult<TResult> | void);
|
|
693
|
+
export type VoiceRouteConfig<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
|
|
694
|
+
onCallStart?: (input: {
|
|
695
|
+
context: TContext;
|
|
696
|
+
session: TSession;
|
|
697
|
+
api: VoiceSessionHandle<TContext, TSession, TResult>;
|
|
698
|
+
}) => Promise<void> | void;
|
|
699
|
+
onCallEnd?: (input: {
|
|
700
|
+
api: VoiceSessionHandle<TContext, TSession, TResult>;
|
|
701
|
+
context: TContext;
|
|
702
|
+
disposition: VoiceCallDisposition;
|
|
703
|
+
metadata?: Record<string, unknown>;
|
|
704
|
+
reason?: string;
|
|
705
|
+
session: TSession;
|
|
706
|
+
target?: string;
|
|
707
|
+
}) => Promise<void> | void;
|
|
708
|
+
onSession?: (input: {
|
|
709
|
+
context: TContext;
|
|
710
|
+
session: TSession;
|
|
711
|
+
api: VoiceSessionHandle<TContext, TSession, TResult>;
|
|
712
|
+
}) => Promise<void> | void;
|
|
713
|
+
/** Fires when a connect RESUMES an existing session (a reconnect, or a fresh
|
|
714
|
+
* process after a restart finding the session in a persistent store) instead
|
|
715
|
+
* of starting a new call — onCallStart/onSession do NOT fire on a resume.
|
|
716
|
+
* Use it to rebuild any per-session in-memory state (caller context, paced
|
|
717
|
+
* flags) that didn't survive the process, so the resumed call keeps the
|
|
718
|
+
* personalization the original had. Runs before the resume re-greeting. */
|
|
719
|
+
onResume?: (input: {
|
|
720
|
+
context: TContext;
|
|
721
|
+
session: TSession;
|
|
722
|
+
api: VoiceSessionHandle<TContext, TSession, TResult>;
|
|
723
|
+
}) => Promise<void> | void;
|
|
724
|
+
correctTurn?: VoiceTurnCorrectionHandler<TContext, TSession, TResult>;
|
|
725
|
+
speculate?: (input: {
|
|
726
|
+
api: VoiceSessionHandle<TContext, TSession, TResult>;
|
|
727
|
+
context: TContext;
|
|
728
|
+
session: TSession;
|
|
729
|
+
turn: VoiceTurnRecord;
|
|
730
|
+
signal?: AbortSignal;
|
|
731
|
+
}) => Promise<{
|
|
732
|
+
text: string;
|
|
733
|
+
} | null | void>;
|
|
734
|
+
onTurn: VoiceOnTurnHandler<TContext, TSession, TResult>;
|
|
735
|
+
onComplete: (input: {
|
|
736
|
+
context: TContext;
|
|
737
|
+
session: TSession;
|
|
738
|
+
api: VoiceSessionHandle<TContext, TSession, TResult>;
|
|
739
|
+
}) => Promise<void> | void;
|
|
740
|
+
onError?: (input: {
|
|
741
|
+
context: TContext;
|
|
742
|
+
sessionId: string;
|
|
743
|
+
session?: TSession;
|
|
744
|
+
error: unknown;
|
|
745
|
+
api?: VoiceSessionHandle<TContext, TSession, TResult>;
|
|
746
|
+
}) => Promise<void> | void;
|
|
747
|
+
onEscalation?: (input: {
|
|
748
|
+
api: VoiceSessionHandle<TContext, TSession, TResult>;
|
|
749
|
+
context: TContext;
|
|
750
|
+
metadata?: Record<string, unknown>;
|
|
751
|
+
reason: string;
|
|
752
|
+
session: TSession;
|
|
753
|
+
}) => Promise<void> | void;
|
|
754
|
+
onNoAnswer?: (input: {
|
|
755
|
+
api: VoiceSessionHandle<TContext, TSession, TResult>;
|
|
756
|
+
context: TContext;
|
|
757
|
+
metadata?: Record<string, unknown>;
|
|
758
|
+
session: TSession;
|
|
759
|
+
}) => Promise<void> | void;
|
|
760
|
+
onTransfer?: (input: {
|
|
761
|
+
api: VoiceSessionHandle<TContext, TSession, TResult>;
|
|
762
|
+
context: TContext;
|
|
763
|
+
metadata?: Record<string, unknown>;
|
|
764
|
+
reason?: string;
|
|
765
|
+
session: TSession;
|
|
766
|
+
target: string;
|
|
767
|
+
}) => Promise<void> | void;
|
|
768
|
+
onVoicemail?: (input: {
|
|
769
|
+
api: VoiceSessionHandle<TContext, TSession, TResult>;
|
|
770
|
+
context: TContext;
|
|
771
|
+
metadata?: Record<string, unknown>;
|
|
772
|
+
session: TSession;
|
|
773
|
+
}) => Promise<void> | void;
|
|
774
|
+
};
|
|
775
|
+
export type VoiceRuntimeOpsConfig<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
|
|
776
|
+
buildReview?: (input: {
|
|
777
|
+
api: VoiceSessionHandle<TContext, TSession, TResult>;
|
|
778
|
+
context: TContext;
|
|
779
|
+
disposition: VoiceCallDisposition;
|
|
780
|
+
metadata?: Record<string, unknown>;
|
|
781
|
+
reason?: string;
|
|
782
|
+
result?: TResult;
|
|
783
|
+
session: TSession;
|
|
784
|
+
target?: string;
|
|
785
|
+
}) => Promise<VoiceCallReviewArtifact | StoredVoiceCallReviewArtifact | void> | VoiceCallReviewArtifact | StoredVoiceCallReviewArtifact | void;
|
|
786
|
+
createTaskFromReview?: (input: {
|
|
787
|
+
api: VoiceSessionHandle<TContext, TSession, TResult>;
|
|
788
|
+
context: TContext;
|
|
789
|
+
disposition: VoiceCallDisposition;
|
|
790
|
+
review: StoredVoiceCallReviewArtifact;
|
|
791
|
+
session: TSession;
|
|
792
|
+
}) => Promise<Omit<VoiceOpsTask, "id"> | VoiceOpsTask | StoredVoiceOpsTask | null | void> | Omit<VoiceOpsTask, "id"> | VoiceOpsTask | StoredVoiceOpsTask | null | void;
|
|
793
|
+
resolveTaskPolicy?: (input: {
|
|
794
|
+
api: VoiceSessionHandle<TContext, TSession, TResult>;
|
|
795
|
+
context: TContext;
|
|
796
|
+
disposition: VoiceCallDisposition;
|
|
797
|
+
metadata?: Record<string, unknown>;
|
|
798
|
+
reason?: string;
|
|
799
|
+
review?: StoredVoiceCallReviewArtifact;
|
|
800
|
+
session: TSession;
|
|
801
|
+
target?: string;
|
|
802
|
+
task: StoredVoiceOpsTask;
|
|
803
|
+
}) => Promise<VoiceOpsTaskPolicy | void> | VoiceOpsTaskPolicy | void;
|
|
804
|
+
resolveTaskAssignment?: (input: {
|
|
805
|
+
api: VoiceSessionHandle<TContext, TSession, TResult>;
|
|
806
|
+
context: TContext;
|
|
807
|
+
disposition: VoiceCallDisposition;
|
|
808
|
+
metadata?: Record<string, unknown>;
|
|
809
|
+
reason?: string;
|
|
810
|
+
review?: StoredVoiceCallReviewArtifact;
|
|
811
|
+
session: TSession;
|
|
812
|
+
target?: string;
|
|
813
|
+
task: StoredVoiceOpsTask;
|
|
814
|
+
}) => Promise<VoiceOpsTaskAssignmentRule | void> | VoiceOpsTaskAssignmentRule | void;
|
|
815
|
+
taskAssignmentRules?: VoiceOpsTaskAssignmentRules;
|
|
816
|
+
taskPolicies?: VoiceOpsDispositionTaskPolicies;
|
|
817
|
+
events?: VoiceIntegrationEventStore;
|
|
818
|
+
onEvent?: (input: {
|
|
819
|
+
api: VoiceSessionHandle<TContext, TSession, TResult>;
|
|
820
|
+
context: TContext;
|
|
821
|
+
event: StoredVoiceIntegrationEvent;
|
|
822
|
+
session: TSession;
|
|
823
|
+
}) => Promise<void> | void;
|
|
824
|
+
reviews?: VoiceCallReviewStore;
|
|
825
|
+
sinks?: VoiceIntegrationSink[];
|
|
826
|
+
tasks?: VoiceOpsTaskStore;
|
|
827
|
+
webhook?: VoiceIntegrationWebhookConfig;
|
|
828
|
+
};
|
|
829
|
+
export type VoiceLiveOpsRuntimeConfig = {
|
|
830
|
+
getControl: (sessionId: string) => Promise<VoiceLiveOpsControlState | null | undefined> | VoiceLiveOpsControlState | null | undefined;
|
|
831
|
+
};
|
|
832
|
+
export type VoiceProfileSwitchGuardResolverInput<TContext = unknown> = {
|
|
833
|
+
context: TContext;
|
|
834
|
+
scenarioId?: string;
|
|
835
|
+
sessionId: string;
|
|
836
|
+
};
|
|
837
|
+
export type VoicePluginProfileSwitchGuardConfig<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
|
|
838
|
+
actor?: VoiceAuditActor;
|
|
839
|
+
allowedProfileIds?: string[] | ((input: VoiceProfileSwitchGuardResolverInput<TContext>) => Promise<string[] | undefined> | string[] | undefined);
|
|
840
|
+
audit?: VoiceAuditEventStore;
|
|
841
|
+
blockedProfileIds?: string[] | ((input: VoiceProfileSwitchGuardResolverInput<TContext>) => Promise<string[] | undefined> | string[] | undefined);
|
|
842
|
+
currentProfileId?: string | ((input: VoiceProfileSwitchGuardResolverInput<TContext>) => Promise<string | undefined> | string | undefined);
|
|
843
|
+
defaultProfileId?: string;
|
|
844
|
+
defaults: VoiceRealCallProfileDefaultsReport | VoiceRealCallProfileHistoryReport | ((input: VoiceProfileSwitchGuardResolverInput<TContext>) => Promise<VoiceRealCallProfileDefaultsReport | VoiceRealCallProfileHistoryReport> | VoiceRealCallProfileDefaultsReport | VoiceRealCallProfileHistoryReport);
|
|
845
|
+
metadata?: Record<string, unknown> | ((input: VoiceProfileSwitchGuardResolverInput<TContext>) => Promise<Record<string, unknown> | undefined> | Record<string, unknown> | undefined);
|
|
846
|
+
minConfidence?: number | ((input: VoiceProfileSwitchGuardResolverInput<TContext>) => Promise<number | undefined> | number | undefined);
|
|
847
|
+
maxAutoSwitchesPerSession?: number | ((input: VoiceProfileSwitchGuardResolverInput<TContext>) => Promise<number | undefined> | number | undefined);
|
|
848
|
+
mode?: VoiceProfileSwitchGuardMode | ((input: VoiceProfileSwitchGuardResolverInput<TContext>) => Promise<VoiceProfileSwitchGuardMode | undefined> | VoiceProfileSwitchGuardMode | undefined);
|
|
849
|
+
observed?: VoiceProfileSwitchObservedSignals | ((input: VoiceProfileSwitchGuardResolverInput<TContext>) => Promise<VoiceProfileSwitchObservedSignals | undefined> | VoiceProfileSwitchObservedSignals | undefined);
|
|
850
|
+
onDecision?: (input: {
|
|
851
|
+
context: TContext;
|
|
852
|
+
decision: VoiceProfileSwitchGuardDecision;
|
|
853
|
+
scenarioId?: string;
|
|
854
|
+
sessionId: string;
|
|
855
|
+
}) => Promise<void> | void;
|
|
856
|
+
sessionMetadataKey?: string | false;
|
|
857
|
+
trace?: false | VoiceTraceEventStore;
|
|
858
|
+
};
|
|
859
|
+
export type VoiceNormalizedRouteConfig<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = Omit<VoiceRouteConfig<TContext, TSession, TResult>, "onTurn"> & {
|
|
860
|
+
onTurn: VoiceOnTurnObjectHandler<TContext, TSession, TResult>;
|
|
861
|
+
};
|
|
862
|
+
export type VoiceScenario = {
|
|
863
|
+
id: string;
|
|
864
|
+
name?: string;
|
|
865
|
+
description?: string;
|
|
866
|
+
metadata?: Record<string, unknown>;
|
|
867
|
+
};
|
|
868
|
+
export type VoiceExpectedSpeakerTurn = {
|
|
869
|
+
speaker: string;
|
|
870
|
+
text: string;
|
|
871
|
+
};
|
|
872
|
+
/**
|
|
873
|
+
* Configures one of the plugin's optional route surfaces. Pass that surface's
|
|
874
|
+
* options object to mount it, `false` (or omit) to leave it off. Surfaces whose
|
|
875
|
+
* options are entirely optional may also be enabled with `true` for defaults.
|
|
876
|
+
*/
|
|
877
|
+
export type VoiceSurfaceConfig<O> = false | O | (Record<string, never> extends O ? true : never);
|
|
878
|
+
export type VoicePluginConfig<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
|
|
879
|
+
costAccountant?: import("./costAccounting").VoiceCostAccountant;
|
|
880
|
+
costTelephony?: {
|
|
881
|
+
provider?: string;
|
|
882
|
+
};
|
|
883
|
+
costTelemetry?: VoiceCostTelemetryConfig<TContext, TSession, TResult>;
|
|
884
|
+
path: string;
|
|
885
|
+
/**
|
|
886
|
+
* Authorize a WebSocket before the plugin supersedes an existing session or
|
|
887
|
+
* creates provider-backed resources. Return false to close it with 4401.
|
|
888
|
+
* Applications can validate a short-lived admission credential from `query`
|
|
889
|
+
* without coupling Voice to a particular authentication implementation.
|
|
890
|
+
*/
|
|
891
|
+
authorizeConnection?: (input: {
|
|
892
|
+
context: TContext;
|
|
893
|
+
headers: Headers;
|
|
894
|
+
path: string;
|
|
895
|
+
query: Record<string, unknown>;
|
|
896
|
+
scenarioId?: string;
|
|
897
|
+
sessionId: string;
|
|
898
|
+
}) => boolean | Promise<boolean>;
|
|
899
|
+
greeting?: string | ((input: {
|
|
900
|
+
session: TSession;
|
|
901
|
+
}) => string | Promise<string>);
|
|
902
|
+
resumeGreeting?: string | ((input: {
|
|
903
|
+
session: TSession;
|
|
904
|
+
}) => string | Promise<string>);
|
|
905
|
+
sttRecoveryLine?: string | ((input: {
|
|
906
|
+
session: TSession;
|
|
907
|
+
}) => string | Promise<string>);
|
|
908
|
+
stuckCallClose?: {
|
|
909
|
+
afterMs: number;
|
|
910
|
+
/** Whether this fault-driven close invokes the route completion hook.
|
|
911
|
+
* Defaults to true for backward compatibility. Set false when an
|
|
912
|
+
* interrupted conversation must remain resumable. */
|
|
913
|
+
invokeOnComplete?: boolean;
|
|
914
|
+
line?: string | ((input: {
|
|
915
|
+
session: TSession;
|
|
916
|
+
}) => string | Promise<string>);
|
|
917
|
+
reason?: string;
|
|
918
|
+
};
|
|
919
|
+
/** Gentle re-engagement before a silent call is given up on. When the caller
|
|
920
|
+
* makes no progress (no committed turn / user partial) for `afterMs`, the
|
|
921
|
+
* assistant speaks `line` ("still there?") instead of ending, and the close
|
|
922
|
+
* deadline (stuckCallClose) is pushed out — up to `maxReprompts` times (default
|
|
923
|
+
* 1). After the budget is spent the normal close path runs. Caller speech
|
|
924
|
+
* resets the budget. Assistant speech does NOT, so this can only extend a
|
|
925
|
+
* bounded amount. `afterMs` should be < stuckCallClose.afterMs so the nudge
|
|
926
|
+
* fires first. */
|
|
927
|
+
idleReprompt?: {
|
|
928
|
+
afterMs: number;
|
|
929
|
+
line: string | ((input: {
|
|
930
|
+
session: TSession;
|
|
931
|
+
}) => string | Promise<string>);
|
|
932
|
+
maxReprompts?: number;
|
|
933
|
+
};
|
|
934
|
+
languageStrategy?: VoiceLanguageStrategy | VoiceLanguageStrategyResolver<TContext>;
|
|
935
|
+
lexicon?: VoiceLexiconEntry[] | VoiceLexiconResolver<TContext>;
|
|
936
|
+
phraseHints?: VoicePhraseHint[] | VoicePhraseHintResolver<TContext>;
|
|
937
|
+
preset?: VoiceRuntimePreset;
|
|
938
|
+
stt?: STTAdapter;
|
|
939
|
+
sttFallback?: VoiceSTTFallbackConfig;
|
|
940
|
+
sttLifecycle?: VoiceSTTLifecycle;
|
|
941
|
+
realtime?: RealtimeAdapter;
|
|
942
|
+
realtimeInputFormat?: AudioFormat;
|
|
943
|
+
recording?: VoiceSessionRecordingConfig;
|
|
944
|
+
tts?: TTSAdapter;
|
|
945
|
+
session: VoiceSessionStore<NoInfer<TSession>>;
|
|
946
|
+
reconnect?: VoiceReconnectConfig;
|
|
947
|
+
turnDetection?: VoiceTurnDetectionConfig;
|
|
948
|
+
semanticTurnDetector?: import("./semanticTurn").VoiceSemanticTurnDetector;
|
|
949
|
+
bargeInDetector?: import("./bargeInDetector").VoiceBargeInDetector;
|
|
950
|
+
bargeInMinPartialWords?: number;
|
|
951
|
+
/**
|
|
952
|
+
* When true, a pure listening cue ("mm-hm", "yeah", "right", "got it") spoken
|
|
953
|
+
* WHILE the assistant is talking does NOT barge-in — the assistant keeps going
|
|
954
|
+
* and the cue is dropped so it never becomes the caller's next turn. A bare
|
|
955
|
+
* "yeah" said AFTER the assistant finishes is a normal answer, unaffected.
|
|
956
|
+
* Default false (any in-speech words interrupt, the prior behavior).
|
|
957
|
+
*/
|
|
958
|
+
backchannelBargeInGuard?: boolean;
|
|
959
|
+
fillerPhrases?: ReadonlyArray<string>;
|
|
960
|
+
fillerDelayMs?: number;
|
|
961
|
+
fillerFor?: (input: {
|
|
962
|
+
sessionId: string;
|
|
963
|
+
turnId: string;
|
|
964
|
+
userText: string;
|
|
965
|
+
}) => Promise<string | null>;
|
|
966
|
+
fillerForTimeoutMs?: number;
|
|
967
|
+
backchannel?: import("./backchannel").VoiceBackchannelConfig;
|
|
968
|
+
defaultSilentTurnAck?: string;
|
|
969
|
+
routeOnTurnTimeoutMs?: number;
|
|
970
|
+
audioConditioning?: VoiceAudioConditioningConfig;
|
|
971
|
+
normalizeNumbers?: boolean;
|
|
972
|
+
noiseSuppressor?: VoiceNoiseSuppressor;
|
|
973
|
+
noiseSuppressorFormat?: AudioFormat;
|
|
974
|
+
logger?: VoiceLogger;
|
|
975
|
+
htmx?: boolean | VoiceHTMXConfig<TSession, NoInfer<TResult>>;
|
|
976
|
+
handoff?: VoiceHandoffConfig<TContext, TSession, TResult>;
|
|
977
|
+
ops?: VoiceRuntimeOpsConfig<TContext, TSession, TResult>;
|
|
978
|
+
liveOps?: VoiceLiveOpsRuntimeConfig;
|
|
979
|
+
monitor?: VoiceMonitorRuntimeBinding;
|
|
980
|
+
profileSwitchGuard?: VoicePluginProfileSwitchGuardConfig<TContext, TSession, TResult>;
|
|
981
|
+
trace?: VoiceTraceEventStore;
|
|
982
|
+
assistantHealth?: VoiceSurfaceConfig<import("./assistantHealth").VoiceAssistantHealthRoutesOptions>;
|
|
983
|
+
auditDelivery?: VoiceSurfaceConfig<import("./auditDeliveryRoutes").VoiceAuditDeliveryRoutesOptions>;
|
|
984
|
+
auditTrail?: VoiceSurfaceConfig<import("./auditRoutes").VoiceAuditTrailRoutesOptions>;
|
|
985
|
+
bargeIn?: VoiceSurfaceConfig<import("./bargeInRoutes").VoiceBargeInRoutesOptions>;
|
|
986
|
+
browserCallProfile?: VoiceSurfaceConfig<import("./browserCallProfiles").VoiceBrowserCallProfileRoutesOptions>;
|
|
987
|
+
browserMedia?: VoiceSurfaceConfig<import("./browserMediaRoutes").VoiceBrowserMediaRoutesOptions>;
|
|
988
|
+
callDebugger?: VoiceSurfaceConfig<import("./callDebugger").VoiceCallDebuggerRoutesOptions>;
|
|
989
|
+
campaign?: VoiceSurfaceConfig<import("./campaign").VoiceCampaignRoutesOptions>;
|
|
990
|
+
competitiveCoverage?: VoiceSurfaceConfig<import("./competitiveCoverage").VoiceCompetitiveCoverageRoutesOptions>;
|
|
991
|
+
dataControl?: VoiceSurfaceConfig<import("./dataControl").VoiceDataControlRoutesOptions>;
|
|
992
|
+
deliveryRuntime?: VoiceSurfaceConfig<import("./deliveryRuntime").VoiceDeliveryRuntimeRoutesOptions>;
|
|
993
|
+
deliverySink?: VoiceSurfaceConfig<import("./deliverySinkRoutes").VoiceDeliverySinkRoutesOptions>;
|
|
994
|
+
demoReady?: VoiceSurfaceConfig<import("./demoReadyRoutes").VoiceDemoReadyRoutesOptions>;
|
|
995
|
+
diagnostics?: VoiceSurfaceConfig<import("./diagnosticsRoutes").VoiceDiagnosticsRoutesOptions>;
|
|
996
|
+
eval?: VoiceSurfaceConfig<import("./evalRoutes").VoiceEvalRoutesOptions>;
|
|
997
|
+
guardrail?: VoiceSurfaceConfig<import("./guardrails").VoiceGuardrailRoutesOptions>;
|
|
998
|
+
handoffHealth?: VoiceSurfaceConfig<import("./handoffHealth").VoiceHandoffHealthRoutesOptions>;
|
|
999
|
+
htmxDashboard?: VoiceSurfaceConfig<import("./htmxDashboardRoutes").VoiceHTMXDashboardRoutesOptions>;
|
|
1000
|
+
incidentBundle?: VoiceSurfaceConfig<import("./incidentBundle").VoiceIncidentBundleRoutesOptions>;
|
|
1001
|
+
incidentTimeline?: VoiceSurfaceConfig<import("./incidentTimeline").VoiceIncidentTimelineRoutesOptions>;
|
|
1002
|
+
liveLatency?: VoiceSurfaceConfig<import("./liveLatency").VoiceLiveLatencyRoutesOptions>;
|
|
1003
|
+
liveMonitor?: VoiceSurfaceConfig<import("./monitor").VoiceLiveMonitorRoutesOptions>;
|
|
1004
|
+
liveOpsConsole?: VoiceSurfaceConfig<import("./liveOps").VoiceLiveOpsRoutesOptions>;
|
|
1005
|
+
mediaPipeline?: VoiceSurfaceConfig<import("./mediaPipelineRoutes").VoiceMediaPipelineRoutesOptions>;
|
|
1006
|
+
monitorReport?: VoiceSurfaceConfig<import("./voiceMonitoring").VoiceMonitorRoutesOptions>;
|
|
1007
|
+
monitorRunner?: VoiceSurfaceConfig<import("./voiceMonitoring").VoiceMonitorRunnerRoutesOptions>;
|
|
1008
|
+
observabilityExport?: VoiceSurfaceConfig<import("./observabilityExport").VoiceObservabilityExportRoutesOptions>;
|
|
1009
|
+
observabilityExportReplay?: VoiceSurfaceConfig<import("./observabilityExport").VoiceObservabilityExportReplayRoutesOptions>;
|
|
1010
|
+
operationalStatus?: VoiceSurfaceConfig<import("./operationalStatus").VoiceOperationalStatusRoutesOptions>;
|
|
1011
|
+
operationsRecord?: VoiceSurfaceConfig<import("./operationsRecord").VoiceOperationsRecordRoutesOptions>;
|
|
1012
|
+
opsActionAudit?: VoiceSurfaceConfig<import("./opsActionAuditRoutes").VoiceOpsActionAuditRoutesOptions>;
|
|
1013
|
+
opsConsole?: VoiceSurfaceConfig<import("./opsConsoleRoutes").VoiceOpsConsoleRoutesOptions>;
|
|
1014
|
+
opsRecovery?: VoiceSurfaceConfig<import("./opsRecovery").VoiceOpsRecoveryRoutesOptions>;
|
|
1015
|
+
opsStatus?: VoiceSurfaceConfig<import("./opsStatus").VoiceOpsStatusRoutesOptions>;
|
|
1016
|
+
opsWebhookReceiver?: VoiceSurfaceConfig<import("./opsWebhook").VoiceOpsWebhookReceiverRoutesOptions>;
|
|
1017
|
+
outcomeContract?: VoiceSurfaceConfig<import("./outcomeContract").VoiceOutcomeContractRoutesOptions>;
|
|
1018
|
+
phoneAgentProductionSmoke?: VoiceSurfaceConfig<import("./phoneAgentProductionSmoke").VoicePhoneAgentProductionSmokeRoutesOptions>;
|
|
1019
|
+
platformCoverage?: VoiceSurfaceConfig<import("./platformCoverage").VoicePlatformCoverageRoutesOptions>;
|
|
1020
|
+
postCallAnalysis?: VoiceSurfaceConfig<import("./postCallAnalysis").VoicePostCallAnalysisRoutesOptions>;
|
|
1021
|
+
productionReadiness?: VoiceSurfaceConfig<import("./productionReadiness").VoiceProductionReadinessRoutesOptions>;
|
|
1022
|
+
profileSwitchLiveDecision?: VoiceSurfaceConfig<import("./profileSwitchRecommendation").VoiceProfileSwitchLiveDecisionRoutesOptions>;
|
|
1023
|
+
profileSwitchPolicyProof?: VoiceSurfaceConfig<import("./profileSwitchRecommendation").VoiceProfileSwitchPolicyProofRoutesOptions>;
|
|
1024
|
+
profileSwitchReadiness?: VoiceSurfaceConfig<import("./profileSwitchRecommendation").VoiceProfileSwitchReadinessRoutesOptions>;
|
|
1025
|
+
proofPack?: VoiceSurfaceConfig<import("./proofPack").VoiceProofPackRoutesOptions>;
|
|
1026
|
+
proofTrend?: VoiceSurfaceConfig<import("./proofTrends").VoiceProofTrendRoutesOptions>;
|
|
1027
|
+
proofTrendRecommendation?: VoiceSurfaceConfig<import("./proofTrends").VoiceProofTrendRecommendationRoutesOptions>;
|
|
1028
|
+
providerCapability?: VoiceSurfaceConfig<import("./providerCapabilities").VoiceProviderCapabilityRoutesOptions>;
|
|
1029
|
+
providerContractMatrix?: VoiceSurfaceConfig<import("./providerStackRecommendations").VoiceProviderContractMatrixRoutesOptions>;
|
|
1030
|
+
providerDecisionTrace?: VoiceSurfaceConfig<import("./providerDecisionTraces").VoiceProviderDecisionTraceRoutesOptions>;
|
|
1031
|
+
providerHealth?: VoiceSurfaceConfig<import("./providerHealth").VoiceProviderHealthRoutesOptions>;
|
|
1032
|
+
providerOrchestration?: VoiceSurfaceConfig<import("./providerOrchestration").VoiceProviderOrchestrationRoutesOptions>;
|
|
1033
|
+
providerSlo?: VoiceSurfaceConfig<import("./providerSlo").VoiceProviderSloRoutesOptions>;
|
|
1034
|
+
quality?: VoiceSurfaceConfig<import("./qualityRoutes").VoiceQualityRoutesOptions>;
|
|
1035
|
+
realCallEvidenceRuntime?: VoiceSurfaceConfig<import("./proofTrends").VoiceRealCallEvidenceRuntimeRoutesOptions>;
|
|
1036
|
+
realCallProfileHistory?: VoiceSurfaceConfig<import("./proofTrends").VoiceRealCallProfileHistoryRoutesOptions>;
|
|
1037
|
+
realCallProfileRecoveryAction?: VoiceSurfaceConfig<import("./proofTrends").VoiceRealCallProfileRecoveryActionRoutesOptions>;
|
|
1038
|
+
realtimeChannel?: VoiceSurfaceConfig<import("./realtimeChannel").VoiceRealtimeChannelRoutesOptions>;
|
|
1039
|
+
realtimeProviderContract?: VoiceSurfaceConfig<import("./realtimeProviderContracts").VoiceRealtimeProviderContractRoutesOptions>;
|
|
1040
|
+
reconnectContract?: VoiceSurfaceConfig<import("./reconnectContract").VoiceReconnectContractRoutesOptions>;
|
|
1041
|
+
reconnectProof?: VoiceSurfaceConfig<import("./reconnectContract").VoiceReconnectProofRoutesOptions>;
|
|
1042
|
+
resilience?: VoiceSurfaceConfig<import("./resilienceRoutes").VoiceResilienceRoutesOptions>;
|
|
1043
|
+
sessionList?: VoiceSurfaceConfig<import("./sessionReplay").VoiceSessionListRoutesOptions>;
|
|
1044
|
+
sessionObservability?: VoiceSurfaceConfig<import("./sessionObservability").VoiceSessionObservabilityRoutesOptions>;
|
|
1045
|
+
sessionReplay?: VoiceSurfaceConfig<import("./sessionReplay").VoiceSessionReplayRoutesOptions>;
|
|
1046
|
+
sessionSnapshot?: VoiceSurfaceConfig<import("./sessionSnapshot").VoiceSessionSnapshotRoutesOptions>;
|
|
1047
|
+
simulationSuite?: VoiceSurfaceConfig<import("./simulationSuite").VoiceSimulationSuiteRoutesOptions>;
|
|
1048
|
+
sloCalibration?: VoiceSurfaceConfig<import("./sloCalibration").VoiceSloCalibrationRoutesOptions>;
|
|
1049
|
+
sloReadinessThreshold?: VoiceSurfaceConfig<import("./sloCalibration").VoiceSloReadinessThresholdRoutesOptions>;
|
|
1050
|
+
telephonyCarrierMatrix?: VoiceSurfaceConfig<import("../telephony/matrix").VoiceTelephonyCarrierMatrixRoutesOptions>;
|
|
1051
|
+
telephonyMedia?: VoiceSurfaceConfig<import("./telephonyMediaRoutes").VoiceTelephonyMediaRoutesOptions>;
|
|
1052
|
+
telephonyWebhook?: VoiceSurfaceConfig<import("./telephonyOutcome").VoiceTelephonyWebhookRoutesOptions>;
|
|
1053
|
+
telephonyWebhookSecurity?: VoiceSurfaceConfig<import("../telephony/security").VoiceTelephonyWebhookSecurityRoutesOptions>;
|
|
1054
|
+
toolContract?: VoiceSurfaceConfig<import("./toolContract").VoiceToolContractRoutesOptions>;
|
|
1055
|
+
traceDelivery?: VoiceSurfaceConfig<import("./traceDeliveryRoutes").VoiceTraceDeliveryRoutesOptions>;
|
|
1056
|
+
traceTimeline?: VoiceSurfaceConfig<import("./traceTimeline").VoiceTraceTimelineRoutesOptions>;
|
|
1057
|
+
turnLatency?: VoiceSurfaceConfig<import("./turnLatency").VoiceTurnLatencyRoutesOptions>;
|
|
1058
|
+
turnQuality?: VoiceSurfaceConfig<import("./turnQuality").VoiceTurnQualityRoutesOptions>;
|
|
1059
|
+
} & VoiceRouteConfig<TContext, TSession, TResult>;
|
|
1060
|
+
export type VoiceSessionRecordingConfig = {
|
|
1061
|
+
channels?: ReadonlyArray<"assistant" | "user">;
|
|
1062
|
+
maxBytesPerChannel?: number;
|
|
1063
|
+
store: import("./recordingStore").VoiceRecordingStore;
|
|
1064
|
+
userInputFormat?: AudioFormat;
|
|
1065
|
+
};
|
|
1066
|
+
export type CreateVoiceSessionOptions<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
|
|
1067
|
+
costTelemetry?: VoiceCostTelemetryConfig<TContext, TSession, TResult>;
|
|
1068
|
+
id: string;
|
|
1069
|
+
context: TContext;
|
|
1070
|
+
socket: VoiceSocket;
|
|
1071
|
+
greeting?: string | ((input: {
|
|
1072
|
+
session: TSession;
|
|
1073
|
+
}) => string | Promise<string>);
|
|
1074
|
+
/** Spoken on a RESUME (reconnect / restart) of a call that already had at
|
|
1075
|
+
* least one committed turn — a short re-orientation ("Sorry, you cut out —
|
|
1076
|
+
* you were telling me about X; go on") so the caller knows they're back,
|
|
1077
|
+
* since the in-flight assistant audio didn't survive. Receives the session so
|
|
1078
|
+
* it can reference the last turn. No resume greeting fires if unset. */
|
|
1079
|
+
resumeGreeting?: string | ((input: {
|
|
1080
|
+
session: TSession;
|
|
1081
|
+
}) => string | Promise<string>);
|
|
1082
|
+
/** Spoken when the STT-health watchdog detects the stream has gone DEAF
|
|
1083
|
+
* mid-call (continuous speech energy, no transcripts landing — see
|
|
1084
|
+
* STT_HEALTH_STALE_MS). A short re-prompt ("Sorry, I think I missed that — go
|
|
1085
|
+
* ahead?") so the caller repeats into the freshly reconnected stream instead
|
|
1086
|
+
* of talking into a silently dead call. Cooldown-guarded to fire at most once
|
|
1087
|
+
* per stale episode. Receives the session. Unset = silent reconnect only. */
|
|
1088
|
+
sttRecoveryLine?: string | ((input: {
|
|
1089
|
+
session: TSession;
|
|
1090
|
+
}) => string | Promise<string>);
|
|
1091
|
+
/** Last-resort GRACEFUL terminal close for a wedged call. If no caller-side
|
|
1092
|
+
* progress (committed turn / user partial) lands for `afterMs` on a live call
|
|
1093
|
+
* — STT permanently deaf, or the caller left — the assistant speaks `line` and
|
|
1094
|
+
* the session COMPLETES (disposition "completed") so onComplete still saves and
|
|
1095
|
+
* the call ends with a real goodbye instead of dead air + "abandoned". Reset by
|
|
1096
|
+
* real progress (committed turn / user partial / (re)connect), NOT by the
|
|
1097
|
+
* assistant's own speech, so STT recovery re-prompts can't defer it forever. */
|
|
1098
|
+
stuckCallClose?: {
|
|
1099
|
+
afterMs: number;
|
|
1100
|
+
/** Whether this fault-driven close invokes the route completion hook.
|
|
1101
|
+
* Defaults to true for backward compatibility. */
|
|
1102
|
+
invokeOnComplete?: boolean;
|
|
1103
|
+
line?: string | ((input: {
|
|
1104
|
+
session: TSession;
|
|
1105
|
+
}) => string | Promise<string>);
|
|
1106
|
+
reason?: string;
|
|
1107
|
+
};
|
|
1108
|
+
/** Gentle re-engagement before a silent call is given up on. When the caller
|
|
1109
|
+
* makes no progress (no committed turn / user partial) for `afterMs`, the
|
|
1110
|
+
* assistant speaks `line` ("still there?") instead of ending, and the close
|
|
1111
|
+
* deadline (stuckCallClose) is pushed out — up to `maxReprompts` times (default
|
|
1112
|
+
* 1). After the budget is spent the normal close path runs. Caller speech
|
|
1113
|
+
* resets the budget. Assistant speech does NOT, so this can only extend a
|
|
1114
|
+
* bounded amount. `afterMs` should be < stuckCallClose.afterMs so the nudge
|
|
1115
|
+
* fires first. */
|
|
1116
|
+
idleReprompt?: {
|
|
1117
|
+
afterMs: number;
|
|
1118
|
+
line: string | ((input: {
|
|
1119
|
+
session: TSession;
|
|
1120
|
+
}) => string | Promise<string>);
|
|
1121
|
+
maxReprompts?: number;
|
|
1122
|
+
};
|
|
1123
|
+
/** Caller-driven in-call pause (VoiceSessionHandle.pause/resume). `maxMs`
|
|
1124
|
+
* bounds how long a session may sit paused before it closes gracefully
|
|
1125
|
+
* with reason "pause-timeout" (default 10 minutes). */
|
|
1126
|
+
pause?: {
|
|
1127
|
+
maxMs?: number;
|
|
1128
|
+
};
|
|
1129
|
+
stt?: STTAdapter;
|
|
1130
|
+
realtime?: RealtimeAdapter;
|
|
1131
|
+
realtimeInputFormat?: AudioFormat;
|
|
1132
|
+
tts?: TTSAdapter;
|
|
1133
|
+
languageStrategy?: VoiceLanguageStrategy;
|
|
1134
|
+
lexicon?: VoiceLexiconEntry[];
|
|
1135
|
+
sttFallback?: VoiceResolvedSTTFallbackConfig;
|
|
1136
|
+
store: VoiceSessionStore<TSession>;
|
|
1137
|
+
trace?: VoiceTraceEventStore;
|
|
1138
|
+
recording?: VoiceSessionRecordingConfig;
|
|
1139
|
+
callSilenceTimeoutMs?: number;
|
|
1140
|
+
amd?: import("./amdDetector").VoiceAMDDetector<TContext, TSession, TResult>;
|
|
1141
|
+
costAccountant?: import("./costAccounting").VoiceCostAccountant;
|
|
1142
|
+
costTelephony?: {
|
|
1143
|
+
provider?: string;
|
|
1144
|
+
};
|
|
1145
|
+
redact?: import("./redaction").VoiceTranscriptRedactor;
|
|
1146
|
+
semanticTurnDetector?: import("./semanticTurn").VoiceSemanticTurnDetector;
|
|
1147
|
+
bargeInDetector?: import("./bargeInDetector").VoiceBargeInDetector;
|
|
1148
|
+
/**
|
|
1149
|
+
* Pre-rendered filler phrases the runtime plays in the gap between
|
|
1150
|
+
* user-turn-commit and real assistant audio (typically 800-1500ms). The
|
|
1151
|
+
* caller hears something within ~150-300ms of stopping speaking, so the
|
|
1152
|
+
* LLM/TTS latency feels like the bot thinking instead of dead air. Boardy's
|
|
1153
|
+
* killer UX feature.
|
|
1154
|
+
*
|
|
1155
|
+
* Behavior:
|
|
1156
|
+
* - After a turn commits, a timer fires at `fillerDelayMs` (default
|
|
1157
|
+
* 250ms). At that point, if the real assistant audio for this turn
|
|
1158
|
+
* hasn't started flowing yet, a random phrase is rendered via the
|
|
1159
|
+
* configured `tts` adapter and pushed to the socket.
|
|
1160
|
+
* - When the real assistant audio's first chunk arrives, any in-flight
|
|
1161
|
+
* filler is cancelled (`cancelActiveTTS` clears the carrier buffer).
|
|
1162
|
+
* - Cooldown protects against double-fillers per turn.
|
|
1163
|
+
*
|
|
1164
|
+
* Set `fillerPhrases: []` (or omit) to disable. Reasonable defaults if
|
|
1165
|
+
* you enable: `["Hmm.", "Got it.", "Right.", "Mm-hm.", "Let me think.", "Okay."]`.
|
|
1166
|
+
*/
|
|
1167
|
+
/**
|
|
1168
|
+
* Minimum word count in an STT partial transcript before speech-gated
|
|
1169
|
+
* barge-in cancels the in-flight assistant TTS. Default 1 (any non-empty
|
|
1170
|
+
* partial triggers barge-in — backwards-compatible).
|
|
1171
|
+
*
|
|
1172
|
+
* Set to 2 (or higher) on phone routes where the caller's brief
|
|
1173
|
+
* acknowledgements ("yeah", "uh-huh", "you", "am i") would otherwise
|
|
1174
|
+
* cut the bot off mid-question. Each extra word added typically delays
|
|
1175
|
+
* barge-in by ~100-200ms (one extra STT partial cycle) — cheap compared
|
|
1176
|
+
* to losing the bot's response.
|
|
1177
|
+
*
|
|
1178
|
+
* Word splitting is whitespace-based. Punctuation is left attached.
|
|
1179
|
+
*/
|
|
1180
|
+
bargeInMinPartialWords?: number;
|
|
1181
|
+
/**
|
|
1182
|
+
* When true, a pure listening cue ("mm-hm", "yeah", "right", "got it") spoken
|
|
1183
|
+
* WHILE the assistant is talking does NOT barge-in — the assistant keeps going
|
|
1184
|
+
* and the cue is dropped so it never becomes the caller's next turn. A bare
|
|
1185
|
+
* "yeah" said AFTER the assistant finishes is a normal answer, unaffected.
|
|
1186
|
+
* Default false (any in-speech words interrupt, the prior behavior).
|
|
1187
|
+
*/
|
|
1188
|
+
backchannelBargeInGuard?: boolean;
|
|
1189
|
+
fillerPhrases?: ReadonlyArray<string>;
|
|
1190
|
+
/** Milliseconds after turn-commit before the filler fires. Default 250ms — short enough to feel instant, long enough to skip if the LLM is very fast. */
|
|
1191
|
+
fillerDelayMs?: number;
|
|
1192
|
+
/**
|
|
1193
|
+
* Latency Theater — content-aware filler (Boardy parity move). When
|
|
1194
|
+
* defined, the runtime calls `fillerFor({ userText, ... })` in parallel
|
|
1195
|
+
* with the main LLM call to generate a brief acknowledgement of what the
|
|
1196
|
+
* caller just said ("Freelance CFOs — interesting.", "Yeah, I hear you.").
|
|
1197
|
+
* The runtime races the promise against `fillerForTimeoutMs` (default
|
|
1198
|
+
* 600ms). If `fillerFor` returns a non-empty string in time, it's spoken
|
|
1199
|
+
* INSTEAD of a random `fillerPhrases` entry. On timeout or null return,
|
|
1200
|
+
* the runtime falls back to a static random phrase, so a slow / failed
|
|
1201
|
+
* acknowledgement call never costs you the filler entirely.
|
|
1202
|
+
*
|
|
1203
|
+
* Return `null` (or an empty string) to explicitly skip filler for this
|
|
1204
|
+
* turn — useful when `userText` is so short ("yes", "no", "okay") that
|
|
1205
|
+
* acknowledging it back sounds robotic. Return throws are caught and
|
|
1206
|
+
* treated as null.
|
|
1207
|
+
*
|
|
1208
|
+
* Cost-aware: callers typically wire this to a cheap nano/haiku model
|
|
1209
|
+
* (gpt-4.1-nano, claude-haiku-4-5) that returns 2–5 words.
|
|
1210
|
+
*/
|
|
1211
|
+
fillerFor?: (input: {
|
|
1212
|
+
sessionId: string;
|
|
1213
|
+
turnId: string;
|
|
1214
|
+
userText: string;
|
|
1215
|
+
}) => Promise<string | null>;
|
|
1216
|
+
/** Ceiling for the `fillerFor` call before we fall back to a static phrase. Default 600ms. */
|
|
1217
|
+
fillerForTimeoutMs?: number;
|
|
1218
|
+
/**
|
|
1219
|
+
* Backchannel cues — short "mm-hm"/"right" acknowledgements played while the
|
|
1220
|
+
* CALLER is mid-turn (a long answer) so they feel heard, the way a human
|
|
1221
|
+
* listener interjects. Plays on the same non-turn TTS path as fillers, so it
|
|
1222
|
+
* never registers as the assistant's turn or trips barge-in. Off unless
|
|
1223
|
+
* `enabled` is set. Fires only while the assistant is silent.
|
|
1224
|
+
*/
|
|
1225
|
+
backchannel?: import("./backchannel").VoiceBackchannelConfig;
|
|
1226
|
+
/**
|
|
1227
|
+
* Default spoken ack if the model returns ONLY tool calls (no text) and the
|
|
1228
|
+
* turn isn't ending. Without this, the caller hears total silence after
|
|
1229
|
+
* their turn and assumes the line dropped. Default is "Sorry, one moment."
|
|
1230
|
+
* Set to "" to opt out entirely.
|
|
1231
|
+
*/
|
|
1232
|
+
defaultSilentTurnAck?: string;
|
|
1233
|
+
/**
|
|
1234
|
+
* Hard timeout on a single `route.onTurn` call. If onTurn hasn't resolved
|
|
1235
|
+
* in this many ms, it's rejected with a hard-timeout error which falls
|
|
1236
|
+
* through to defaultSilentTurnAck. Default 45s — generous for normal
|
|
1237
|
+
* conversational LLM calls (1-3s typical), but catches hangs where the
|
|
1238
|
+
* model adapter's own timeout doesn't fire. Set to 0 to disable.
|
|
1239
|
+
*/
|
|
1240
|
+
routeOnTurnTimeoutMs?: number;
|
|
1241
|
+
assistantMode?: import("./assistantMode").VoiceAssistantMode;
|
|
1242
|
+
modalities?: ReadonlyArray<"audio" | "text">;
|
|
1243
|
+
prosody?: VoiceTTSProsody;
|
|
1244
|
+
reconnect: Required<VoiceReconnectConfig>;
|
|
1245
|
+
phraseHints?: VoicePhraseHint[];
|
|
1246
|
+
sessionMetadata?: Record<string, unknown>;
|
|
1247
|
+
scenarioId?: string;
|
|
1248
|
+
sttLifecycle: VoiceSTTLifecycle;
|
|
1249
|
+
turnDetection: VoiceResolvedTurnDetectionConfig;
|
|
1250
|
+
audioConditioning?: VoiceResolvedAudioConditioningConfig;
|
|
1251
|
+
normalizeNumbers?: boolean;
|
|
1252
|
+
noiseSuppressor?: VoiceNoiseSuppressor;
|
|
1253
|
+
noiseSuppressorFormat?: AudioFormat;
|
|
1254
|
+
handoff?: VoiceHandoffConfig<TContext, TSession, TResult>;
|
|
1255
|
+
liveOps?: VoiceLiveOpsRuntimeConfig;
|
|
1256
|
+
route: VoiceNormalizedRouteConfig<TContext, TSession, TResult>;
|
|
1257
|
+
logger?: VoiceLogger;
|
|
1258
|
+
};
|
|
1259
|
+
export type CreateVoiceSession = <TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown>(options: CreateVoiceSessionOptions<TContext, TSession, TResult>) => VoiceSessionHandle<TContext, TSession, TResult>;
|
|
1260
|
+
export type VoiceClientStartMessage = {
|
|
1261
|
+
type: "start";
|
|
1262
|
+
sessionId?: string;
|
|
1263
|
+
scenarioId?: string;
|
|
1264
|
+
};
|
|
1265
|
+
export type VoiceClientEndTurnMessage = {
|
|
1266
|
+
type: "end_turn";
|
|
1267
|
+
};
|
|
1268
|
+
export type VoiceClientCloseMessage = {
|
|
1269
|
+
type: "close";
|
|
1270
|
+
reason?: string;
|
|
1271
|
+
};
|
|
1272
|
+
export type VoiceClientCallControlMessage = {
|
|
1273
|
+
type: "call_control";
|
|
1274
|
+
requestId?: string;
|
|
1275
|
+
action: "complete" | "escalate" | "no-answer" | "pause" | "resume" | "transfer" | "voicemail";
|
|
1276
|
+
metadata?: Record<string, unknown>;
|
|
1277
|
+
reason?: string;
|
|
1278
|
+
target?: string;
|
|
1279
|
+
};
|
|
1280
|
+
export type VoiceServerCallControlAckMessage = {
|
|
1281
|
+
type: "call_control_ack";
|
|
1282
|
+
action: VoiceClientCallControlMessage["action"];
|
|
1283
|
+
message?: string;
|
|
1284
|
+
ok: boolean;
|
|
1285
|
+
requestId: string;
|
|
1286
|
+
};
|
|
1287
|
+
export type VoiceClientPingMessage = {
|
|
1288
|
+
type: "ping";
|
|
1289
|
+
};
|
|
1290
|
+
export type VoiceClientMessage = VoiceClientStartMessage | VoiceClientEndTurnMessage | VoiceClientCloseMessage | VoiceClientCallControlMessage | VoiceClientPingMessage;
|
|
1291
|
+
export type VoiceServerSessionMessage = {
|
|
1292
|
+
type: "session";
|
|
1293
|
+
paused?: boolean;
|
|
1294
|
+
pauseExpiresAt?: number;
|
|
1295
|
+
sessionId: string;
|
|
1296
|
+
status: VoiceSessionStatus;
|
|
1297
|
+
scenarioId?: string;
|
|
1298
|
+
sessionMetadata?: Record<string, unknown>;
|
|
1299
|
+
};
|
|
1300
|
+
export type VoiceServerReplayMessage<TResult = unknown> = {
|
|
1301
|
+
type: "replay";
|
|
1302
|
+
assistantTexts: string[];
|
|
1303
|
+
call?: VoiceCallLifecycleState;
|
|
1304
|
+
partial: string;
|
|
1305
|
+
scenarioId?: string;
|
|
1306
|
+
sessionId: string;
|
|
1307
|
+
sessionMetadata?: Record<string, unknown>;
|
|
1308
|
+
status: VoiceSessionStatus;
|
|
1309
|
+
turns: VoiceTurnRecord<TResult>[];
|
|
1310
|
+
};
|
|
1311
|
+
export type VoiceServerPartialMessage = {
|
|
1312
|
+
type: "partial";
|
|
1313
|
+
transcript: Transcript;
|
|
1314
|
+
};
|
|
1315
|
+
export type VoiceServerFinalMessage = {
|
|
1316
|
+
type: "final";
|
|
1317
|
+
transcript: Transcript;
|
|
1318
|
+
};
|
|
1319
|
+
export type VoiceServerTurnMessage<TResult = unknown> = {
|
|
1320
|
+
type: "turn";
|
|
1321
|
+
turn: VoiceTurnRecord<TResult>;
|
|
1322
|
+
};
|
|
1323
|
+
export type VoiceServerAssistantMessage = {
|
|
1324
|
+
type: "assistant";
|
|
1325
|
+
text: string;
|
|
1326
|
+
turnId?: string;
|
|
1327
|
+
};
|
|
1328
|
+
export type VoiceServerAssistantDeltaMessage = {
|
|
1329
|
+
type: "assistant_delta";
|
|
1330
|
+
delta: string;
|
|
1331
|
+
turnId?: string;
|
|
1332
|
+
};
|
|
1333
|
+
export type VoiceServerAudioMessage = {
|
|
1334
|
+
type: "audio";
|
|
1335
|
+
chunkBase64: string;
|
|
1336
|
+
format: AudioFormat;
|
|
1337
|
+
receivedAt: number;
|
|
1338
|
+
turnId?: string;
|
|
1339
|
+
};
|
|
1340
|
+
/** Requests a live assistant-audio playback-rate change in browser clients. */
|
|
1341
|
+
export type VoiceServerPlaybackRateMessage = {
|
|
1342
|
+
type: "playback_rate";
|
|
1343
|
+
rate: number;
|
|
1344
|
+
};
|
|
1345
|
+
export type VoiceServerCompleteMessage = {
|
|
1346
|
+
type: "complete";
|
|
1347
|
+
sessionId: string;
|
|
1348
|
+
};
|
|
1349
|
+
export type VoiceServerCallLifecycleMessage = {
|
|
1350
|
+
type: "call_lifecycle";
|
|
1351
|
+
event: VoiceCallLifecycleEvent;
|
|
1352
|
+
sessionId: string;
|
|
1353
|
+
};
|
|
1354
|
+
export type VoiceServerErrorMessage = {
|
|
1355
|
+
type: "error";
|
|
1356
|
+
message: string;
|
|
1357
|
+
recoverable?: boolean;
|
|
1358
|
+
};
|
|
1359
|
+
export type VoiceServerPongMessage = {
|
|
1360
|
+
type: "pong";
|
|
1361
|
+
};
|
|
1362
|
+
export type VoiceServerConnectionMessage = {
|
|
1363
|
+
type: "connection";
|
|
1364
|
+
reconnect: VoiceReconnectClientState;
|
|
1365
|
+
};
|
|
1366
|
+
export type VoiceServerMessage<TResult = unknown> = VoiceServerSessionMessage | VoiceServerReplayMessage<TResult> | VoiceServerPartialMessage | VoiceServerFinalMessage | VoiceServerTurnMessage<TResult> | VoiceServerAssistantMessage | VoiceServerAssistantDeltaMessage | VoiceServerAudioMessage | VoiceServerPlaybackRateMessage | VoiceServerCallControlAckMessage | VoiceServerCallLifecycleMessage | VoiceServerCompleteMessage | VoiceServerErrorMessage | VoiceServerPongMessage | VoiceServerConnectionMessage;
|
|
1367
|
+
export type VoiceConnectionOptions = {
|
|
1368
|
+
browserMedia?: false | VoiceBrowserMediaReporterOptions;
|
|
1369
|
+
protocols?: string[];
|
|
1370
|
+
scenarioId?: string;
|
|
1371
|
+
reconnect?: boolean;
|
|
1372
|
+
reconnectReportPath?: string;
|
|
1373
|
+
maxReconnectAttempts?: number;
|
|
1374
|
+
/** Cap on the exponential reconnect backoff (ms). The delay doubles from 500ms
|
|
1375
|
+
* up to this ceiling each attempt, so the total retry window is roughly
|
|
1376
|
+
* maxReconnectAttempts spread across it. Default 8000 — with the default 15
|
|
1377
|
+
* attempts that's a ~95s window, enough to ride out a server redeploy without
|
|
1378
|
+
* the caller losing the call. */
|
|
1379
|
+
reconnectMaxDelayMs?: number;
|
|
1380
|
+
/** A reconnected socket must remain open this long before its retry budget is
|
|
1381
|
+
* reset. This prevents a server that accepts and immediately drops sockets
|
|
1382
|
+
* from creating an unbounded reconnect loop. Default 30000. */
|
|
1383
|
+
reconnectResetAfterMs?: number;
|
|
1384
|
+
/** Refresh application-owned admission state before each reconnect attempt.
|
|
1385
|
+
* Throwing keeps the transport disconnected and consumes one bounded retry
|
|
1386
|
+
* attempt instead of opening a socket with stale credentials. */
|
|
1387
|
+
prepareReconnect?: (input: {
|
|
1388
|
+
attempt: number;
|
|
1389
|
+
path: string;
|
|
1390
|
+
scenarioId: string | null;
|
|
1391
|
+
sessionId: string;
|
|
1392
|
+
signal: AbortSignal;
|
|
1393
|
+
}) => Promise<void> | void;
|
|
1394
|
+
/** Maximum time allowed for one prepareReconnect hook. A hook that exceeds
|
|
1395
|
+
* this deadline is aborted and consumes the attempt. Default 10000. */
|
|
1396
|
+
prepareReconnectTimeoutMs?: number;
|
|
1397
|
+
pingInterval?: number;
|
|
1398
|
+
/** Additional query values sent on every initial or reconnecting socket. */
|
|
1399
|
+
query?: Record<string, string>;
|
|
1400
|
+
sessionId?: string;
|
|
1401
|
+
};
|
|
1402
|
+
export type VoiceBrowserMediaReportPayload = {
|
|
1403
|
+
at: number;
|
|
1404
|
+
continuity?: MediaWebRTCStreamContinuityReport;
|
|
1405
|
+
report: MediaWebRTCStatsReport;
|
|
1406
|
+
scenarioId?: string | null;
|
|
1407
|
+
sessionId?: string | null;
|
|
1408
|
+
};
|
|
1409
|
+
export type VoiceBrowserMediaReporterOptions = Omit<MediaWebRTCStatsReportInput, "peerConnection"> & {
|
|
1410
|
+
fetch?: typeof fetch;
|
|
1411
|
+
getPeerConnection?: (() => MediaWebRTCStatsCollector | null | undefined) | (() => Promise<MediaWebRTCStatsCollector | null | undefined>);
|
|
1412
|
+
getScenarioId?: () => string | null | undefined;
|
|
1413
|
+
getSessionId?: () => string | null | undefined;
|
|
1414
|
+
intervalMs?: number;
|
|
1415
|
+
continuity?: false | Omit<MediaWebRTCStreamContinuityInput, "previousStats" | "stats">;
|
|
1416
|
+
onError?: (error: unknown) => void;
|
|
1417
|
+
onReport?: (payload: VoiceBrowserMediaReportPayload) => void;
|
|
1418
|
+
path?: string;
|
|
1419
|
+
peerConnection?: MediaWebRTCStatsCollector;
|
|
1420
|
+
};
|
|
1421
|
+
export type VoiceCaptureOptions = {
|
|
1422
|
+
channelCount?: 1 | 2;
|
|
1423
|
+
onAudio?: (audio: Uint8Array | ArrayBuffer, sendAudio: (audio: Uint8Array | ArrayBuffer) => void) => void;
|
|
1424
|
+
onLevel?: (level: number) => void;
|
|
1425
|
+
sampleRateHz?: number;
|
|
1426
|
+
/**
|
|
1427
|
+
* A pre-acquired microphone MediaStream. When set, capture uses it instead of
|
|
1428
|
+
* calling getUserMedia — so a host that requested permission UP FRONT (before
|
|
1429
|
+
* connecting, so the prompt can't interrupt the assistant's greeting) can hand
|
|
1430
|
+
* the SAME stream in rather than release-and-reacquire (a second getUserMedia
|
|
1431
|
+
* + a track stop can trigger an audio-device change that suspends playback and
|
|
1432
|
+
* cuts the greeting). Capture owns it after handoff and stops it on close.
|
|
1433
|
+
*/
|
|
1434
|
+
stream?: MediaStream;
|
|
1435
|
+
};
|
|
1436
|
+
export type VoiceControllerOptions = {
|
|
1437
|
+
preset?: VoiceRuntimePreset;
|
|
1438
|
+
connection?: VoiceConnectionOptions;
|
|
1439
|
+
capture?: VoiceCaptureOptions;
|
|
1440
|
+
autoStopOnComplete?: boolean;
|
|
1441
|
+
};
|
|
1442
|
+
export type VoiceBargeInOptions = {
|
|
1443
|
+
enabled?: boolean;
|
|
1444
|
+
interruptOnPartial?: boolean;
|
|
1445
|
+
interruptThreshold?: number;
|
|
1446
|
+
monitor?: VoiceBargeInMonitor;
|
|
1447
|
+
};
|
|
1448
|
+
export type VoiceBargeInTriggerReason = "input-level" | "manual-audio" | "manual-interrupt" | "partial-transcript";
|
|
1449
|
+
export type VoiceBargeInMonitorEvent = {
|
|
1450
|
+
at: number;
|
|
1451
|
+
id: string;
|
|
1452
|
+
latencyMs?: number;
|
|
1453
|
+
playbackStopLatencyMs?: number;
|
|
1454
|
+
reason: VoiceBargeInTriggerReason;
|
|
1455
|
+
sessionId?: string | null;
|
|
1456
|
+
status: "requested" | "stopped" | "skipped";
|
|
1457
|
+
thresholdMs?: number;
|
|
1458
|
+
};
|
|
1459
|
+
export type VoiceBargeInMonitorSnapshot = {
|
|
1460
|
+
averageLatencyMs?: number;
|
|
1461
|
+
events: VoiceBargeInMonitorEvent[];
|
|
1462
|
+
failed: number;
|
|
1463
|
+
lastEvent?: VoiceBargeInMonitorEvent;
|
|
1464
|
+
passed: number;
|
|
1465
|
+
status: "empty" | "fail" | "pass" | "warn";
|
|
1466
|
+
thresholdMs: number;
|
|
1467
|
+
total: number;
|
|
1468
|
+
};
|
|
1469
|
+
export type VoiceBargeInMonitor = {
|
|
1470
|
+
getSnapshot: () => VoiceBargeInMonitorSnapshot;
|
|
1471
|
+
recordRequested: (input: {
|
|
1472
|
+
reason: VoiceBargeInTriggerReason;
|
|
1473
|
+
sessionId?: string | null;
|
|
1474
|
+
}) => VoiceBargeInMonitorEvent;
|
|
1475
|
+
recordSkipped: (input: {
|
|
1476
|
+
reason: VoiceBargeInTriggerReason;
|
|
1477
|
+
sessionId?: string | null;
|
|
1478
|
+
}) => VoiceBargeInMonitorEvent;
|
|
1479
|
+
recordStopped: (input: {
|
|
1480
|
+
latencyMs?: number;
|
|
1481
|
+
playbackStopLatencyMs?: number;
|
|
1482
|
+
reason: VoiceBargeInTriggerReason;
|
|
1483
|
+
sessionId?: string | null;
|
|
1484
|
+
}) => VoiceBargeInMonitorEvent;
|
|
1485
|
+
subscribe: (subscriber: () => void) => () => void;
|
|
1486
|
+
};
|
|
1487
|
+
export type VoiceAudioPlayerOptions = {
|
|
1488
|
+
autoStart?: boolean;
|
|
1489
|
+
createAudioContext?: () => AudioContext;
|
|
1490
|
+
lookaheadMs?: number;
|
|
1491
|
+
/**
|
|
1492
|
+
* Playback speed multiplier for the assistant's speech. 1 = normal. Clamped
|
|
1493
|
+
* to [0.5, 2]. Pitch shifts with the rate (Web Audio playbackRate), so keep
|
|
1494
|
+
* UI ranges modest (≈0.85–1.25) to stay natural. Can be changed live via
|
|
1495
|
+
* setPlaybackRate — already-scheduled chunks keep their rate; new chunks
|
|
1496
|
+
* adopt the new one.
|
|
1497
|
+
*/
|
|
1498
|
+
playbackRate?: number;
|
|
1499
|
+
volume?: number;
|
|
1500
|
+
};
|
|
1501
|
+
export type VoiceDuplexControllerOptions = VoiceControllerOptions & {
|
|
1502
|
+
audioPlayer?: VoiceAudioPlayerOptions;
|
|
1503
|
+
bargeIn?: VoiceBargeInOptions;
|
|
1504
|
+
};
|
|
1505
|
+
export type VoiceSTTRoutingGoal = "best" | "low-cost";
|
|
1506
|
+
export type VoiceSTTRoutingCorrectionMode = "generic" | "none" | "risky-turn";
|
|
1507
|
+
export type VoiceSTTRoutingStrategy = {
|
|
1508
|
+
benchmarkSessionTarget: "deepgram-corrected" | "deepgram-flux";
|
|
1509
|
+
correctionMode: VoiceSTTRoutingCorrectionMode;
|
|
1510
|
+
goal: VoiceSTTRoutingGoal;
|
|
1511
|
+
notes: string[];
|
|
1512
|
+
preset: VoiceRuntimePreset;
|
|
1513
|
+
sttLifecycle: VoiceSTTLifecycle;
|
|
1514
|
+
};
|
|
1515
|
+
export type VoiceHTMXRenderInput<TResult = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord> = {
|
|
1516
|
+
assistantTexts: string[];
|
|
1517
|
+
partial: string;
|
|
1518
|
+
scenarioId?: string;
|
|
1519
|
+
result?: TResult;
|
|
1520
|
+
session?: TSession;
|
|
1521
|
+
sessionId?: string;
|
|
1522
|
+
status: VoiceSessionStatus | "idle";
|
|
1523
|
+
turnCount: number;
|
|
1524
|
+
turns: VoiceTurnRecord<TResult>[];
|
|
1525
|
+
};
|
|
1526
|
+
export type VoiceHTMXRenderConfig<TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
|
|
1527
|
+
metrics?: (input: VoiceHTMXRenderInput<TResult, TSession>) => string;
|
|
1528
|
+
status?: (input: VoiceHTMXRenderInput<TResult, TSession>) => string;
|
|
1529
|
+
turns?: (input: VoiceHTMXRenderInput<TResult, TSession>) => string;
|
|
1530
|
+
assistant?: (input: VoiceHTMXRenderInput<TResult, TSession>) => string;
|
|
1531
|
+
result?: (input: VoiceHTMXRenderInput<TResult, TSession>) => string;
|
|
1532
|
+
emptyState?: (kind: keyof VoiceHTMXTargets, input: VoiceHTMXRenderInput<TResult, TSession>) => string;
|
|
1533
|
+
};
|
|
1534
|
+
export type VoiceHTMXRenderer<TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = (input: VoiceHTMXRenderInput<TResult, TSession>) => string;
|
|
1535
|
+
export type VoiceHTMXTargets = {
|
|
1536
|
+
assistant: string;
|
|
1537
|
+
metrics: string;
|
|
1538
|
+
result: string;
|
|
1539
|
+
status: string;
|
|
1540
|
+
turns: string;
|
|
1541
|
+
};
|
|
1542
|
+
export type VoiceHTMXOptions<TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = VoiceHTMXRenderConfig<TSession, TResult> & {
|
|
1543
|
+
bootstrapRoute?: string;
|
|
1544
|
+
route?: string;
|
|
1545
|
+
targets?: Partial<VoiceHTMXTargets>;
|
|
1546
|
+
};
|
|
1547
|
+
export type VoiceHTMXConfig<TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = VoiceHTMXRenderer<TSession, TResult> | VoiceHTMXOptions<TSession, TResult>;
|
|
1548
|
+
export type VoiceStreamState<TResult = unknown> = {
|
|
1549
|
+
call: VoiceCallLifecycleState | null;
|
|
1550
|
+
paused: boolean;
|
|
1551
|
+
pauseExpiresAt?: number;
|
|
1552
|
+
sessionMetadata: Record<string, unknown> | null;
|
|
1553
|
+
sessionId: string | null;
|
|
1554
|
+
scenarioId: string | null;
|
|
1555
|
+
status: VoiceSessionStatus | "idle";
|
|
1556
|
+
reconnect: VoiceReconnectClientState;
|
|
1557
|
+
partial: string;
|
|
1558
|
+
turns: VoiceTurnRecord<TResult>[];
|
|
1559
|
+
assistantTexts: string[];
|
|
1560
|
+
assistantStreamingText: string;
|
|
1561
|
+
assistantAudio: Array<{
|
|
1562
|
+
chunk: Uint8Array;
|
|
1563
|
+
format: AudioFormat;
|
|
1564
|
+
receivedAt: number;
|
|
1565
|
+
turnId?: string;
|
|
1566
|
+
}>;
|
|
1567
|
+
error: string | null;
|
|
1568
|
+
isConnected: boolean;
|
|
1569
|
+
/** Latest server-requested assistant playback rate, or null if unchanged. */
|
|
1570
|
+
playbackRate: number | null;
|
|
1571
|
+
};
|
|
1572
|
+
export type VoiceStream<TResult = unknown> = {
|
|
1573
|
+
call: VoiceCallLifecycleState | null;
|
|
1574
|
+
paused: boolean;
|
|
1575
|
+
pauseExpiresAt?: number;
|
|
1576
|
+
callControl: (message: Omit<VoiceClientCallControlMessage, "requestId" | "type">) => Promise<void>;
|
|
1577
|
+
close: (reason?: string) => void;
|
|
1578
|
+
/** Release the transport without terminally completing the server session. */
|
|
1579
|
+
disconnect: () => void;
|
|
1580
|
+
start: (input?: {
|
|
1581
|
+
scenarioId?: string;
|
|
1582
|
+
sessionId?: string;
|
|
1583
|
+
}) => Promise<void>;
|
|
1584
|
+
endTurn: () => void;
|
|
1585
|
+
error: string | null;
|
|
1586
|
+
getServerSnapshot: () => VoiceStreamState<TResult>;
|
|
1587
|
+
getSnapshot: () => VoiceStreamState<TResult>;
|
|
1588
|
+
isConnected: boolean;
|
|
1589
|
+
partial: string;
|
|
1590
|
+
playbackRate: number | null;
|
|
1591
|
+
reconnect: VoiceReconnectClientState;
|
|
1592
|
+
sendAudio: (audio: Uint8Array | ArrayBuffer) => void;
|
|
1593
|
+
simulateDisconnect: () => void;
|
|
1594
|
+
sessionId: string | null;
|
|
1595
|
+
sessionMetadata: Record<string, unknown> | null;
|
|
1596
|
+
scenarioId: string | null;
|
|
1597
|
+
status: VoiceSessionStatus | "idle";
|
|
1598
|
+
subscribe: (subscriber: () => void) => () => void;
|
|
1599
|
+
turns: VoiceTurnRecord<TResult>[];
|
|
1600
|
+
assistantTexts: string[];
|
|
1601
|
+
assistantStreamingText: string;
|
|
1602
|
+
assistantAudio: Array<{
|
|
1603
|
+
chunk: Uint8Array;
|
|
1604
|
+
format: AudioFormat;
|
|
1605
|
+
receivedAt: number;
|
|
1606
|
+
turnId?: string;
|
|
1607
|
+
}>;
|
|
1608
|
+
};
|
|
1609
|
+
export type VoiceControllerState<TResult = unknown> = VoiceStreamState<TResult> & {
|
|
1610
|
+
isRecording: boolean;
|
|
1611
|
+
recordingError: string | null;
|
|
1612
|
+
};
|
|
1613
|
+
export type VoiceAudioPlayerState = {
|
|
1614
|
+
activeSourceCount: number;
|
|
1615
|
+
error: string | null;
|
|
1616
|
+
isActive: boolean;
|
|
1617
|
+
isPlaying: boolean;
|
|
1618
|
+
lastInterruptLatencyMs?: number;
|
|
1619
|
+
lastPlaybackStopLatencyMs?: number;
|
|
1620
|
+
processedChunkCount: number;
|
|
1621
|
+
queuedChunkCount: number;
|
|
1622
|
+
};
|
|
1623
|
+
export type VoiceAudioPlayerSource = {
|
|
1624
|
+
assistantAudio: VoiceStreamState["assistantAudio"];
|
|
1625
|
+
subscribe: (subscriber: () => void) => () => void;
|
|
1626
|
+
};
|
|
1627
|
+
/** Post-call playback integrity, for verifying the assistant audio actually
|
|
1628
|
+
* played cleanly (no overlap, no dropped/stalled packets) — emit it as a trace
|
|
1629
|
+
* so a garbled call is provable, not guessed. `ok` is the all-clear roll-up. */
|
|
1630
|
+
export type VoiceAudioIntegrity = {
|
|
1631
|
+
ok: boolean;
|
|
1632
|
+
chunksReceived: number;
|
|
1633
|
+
chunksScheduled: number;
|
|
1634
|
+
scheduledDurationMs: number;
|
|
1635
|
+
gapCount: number;
|
|
1636
|
+
totalGapMs: number;
|
|
1637
|
+
maxGapMs: number;
|
|
1638
|
+
maxConcurrentPlayers: number;
|
|
1639
|
+
errorCount: number;
|
|
1640
|
+
};
|
|
1641
|
+
export type VoiceAudioPlayer = {
|
|
1642
|
+
close: () => Promise<void>;
|
|
1643
|
+
error: string | null;
|
|
1644
|
+
/** Instantaneous RMS amplitude (0..1) of the assistant's audio output — for
|
|
1645
|
+
* driving a visualizer from the actual voice. 0 when idle / no analyser. */
|
|
1646
|
+
getOutputLevel: () => number;
|
|
1647
|
+
getSnapshot: () => VoiceAudioPlayerState;
|
|
1648
|
+
/** Post-call playback-integrity roll-up (overlap, gaps, drops). */
|
|
1649
|
+
getIntegritySummary: () => VoiceAudioIntegrity;
|
|
1650
|
+
activeSourceCount: number;
|
|
1651
|
+
isActive: boolean;
|
|
1652
|
+
isPlaying: boolean;
|
|
1653
|
+
interrupt: () => Promise<void>;
|
|
1654
|
+
lastInterruptLatencyMs?: number;
|
|
1655
|
+
lastPlaybackStopLatencyMs?: number;
|
|
1656
|
+
pause: () => Promise<void>;
|
|
1657
|
+
playbackRate: number;
|
|
1658
|
+
processedChunkCount: number;
|
|
1659
|
+
queuedChunkCount: number;
|
|
1660
|
+
setPlaybackRate: (rate: number) => void;
|
|
1661
|
+
setVolume: (volume: number) => void;
|
|
1662
|
+
start: () => Promise<void>;
|
|
1663
|
+
subscribe: (subscriber: () => void) => () => void;
|
|
1664
|
+
volume: number;
|
|
1665
|
+
};
|
|
1666
|
+
export type VoiceBargeInBinding = {
|
|
1667
|
+
close: () => void;
|
|
1668
|
+
handleLevel: (level: number) => void;
|
|
1669
|
+
sendAudio: (audio: Uint8Array | ArrayBuffer) => void;
|
|
1670
|
+
};
|
|
1671
|
+
export type VoiceController<TResult = unknown> = {
|
|
1672
|
+
bindHTMX: (options: VoiceHTMXBindingOptions) => () => void;
|
|
1673
|
+
call: VoiceCallLifecycleState | null;
|
|
1674
|
+
paused: boolean;
|
|
1675
|
+
pauseExpiresAt?: number;
|
|
1676
|
+
callControl: (message: Omit<VoiceClientCallControlMessage, "requestId" | "type">) => Promise<void>;
|
|
1677
|
+
close: (reason?: string) => void;
|
|
1678
|
+
/** Release the transport while leaving the server session resumable. */
|
|
1679
|
+
disconnect: () => void;
|
|
1680
|
+
endTurn: () => void;
|
|
1681
|
+
start: (input?: {
|
|
1682
|
+
scenarioId?: string;
|
|
1683
|
+
sessionId?: string;
|
|
1684
|
+
}) => Promise<void>;
|
|
1685
|
+
error: string | null;
|
|
1686
|
+
getServerSnapshot: () => VoiceControllerState<TResult>;
|
|
1687
|
+
getSnapshot: () => VoiceControllerState<TResult>;
|
|
1688
|
+
isConnected: boolean;
|
|
1689
|
+
isRecording: boolean;
|
|
1690
|
+
partial: string;
|
|
1691
|
+
playbackRate: number | null;
|
|
1692
|
+
reconnect: VoiceReconnectClientState;
|
|
1693
|
+
recordingError: string | null;
|
|
1694
|
+
sendAudio: (audio: Uint8Array | ArrayBuffer) => void;
|
|
1695
|
+
simulateDisconnect: () => void;
|
|
1696
|
+
sessionId: string | null;
|
|
1697
|
+
sessionMetadata: Record<string, unknown> | null;
|
|
1698
|
+
scenarioId: string | null;
|
|
1699
|
+
startRecording: () => Promise<void>;
|
|
1700
|
+
status: VoiceSessionStatus | "idle";
|
|
1701
|
+
stopRecording: () => void;
|
|
1702
|
+
subscribe: (subscriber: () => void) => () => void;
|
|
1703
|
+
toggleRecording: () => Promise<void>;
|
|
1704
|
+
turns: VoiceTurnRecord<TResult>[];
|
|
1705
|
+
assistantTexts: string[];
|
|
1706
|
+
assistantStreamingText: string;
|
|
1707
|
+
assistantAudio: Array<{
|
|
1708
|
+
chunk: Uint8Array;
|
|
1709
|
+
format: AudioFormat;
|
|
1710
|
+
receivedAt: number;
|
|
1711
|
+
turnId?: string;
|
|
1712
|
+
}>;
|
|
1713
|
+
};
|
|
1714
|
+
export type VoiceDuplexController<TResult = unknown> = VoiceController<TResult> & {
|
|
1715
|
+
audioPlayer: VoiceAudioPlayer;
|
|
1716
|
+
interruptAssistant: () => Promise<void>;
|
|
1717
|
+
};
|
|
1718
|
+
export type VoiceHTMXBindingOptions = {
|
|
1719
|
+
element: Element | string;
|
|
1720
|
+
eventName?: string;
|
|
1721
|
+
route?: string;
|
|
1722
|
+
sessionQueryParam?: string;
|
|
1723
|
+
};
|
|
1724
|
+
export type VoiceStoreAction<TResult = unknown> = {
|
|
1725
|
+
type: "session";
|
|
1726
|
+
paused?: boolean;
|
|
1727
|
+
pauseExpiresAt?: number;
|
|
1728
|
+
sessionId: string;
|
|
1729
|
+
sessionMetadata?: Record<string, unknown>;
|
|
1730
|
+
scenarioId?: string;
|
|
1731
|
+
status: VoiceSessionStatus;
|
|
1732
|
+
} | {
|
|
1733
|
+
type: "replay";
|
|
1734
|
+
assistantTexts: string[];
|
|
1735
|
+
call?: VoiceCallLifecycleState;
|
|
1736
|
+
partial: string;
|
|
1737
|
+
scenarioId?: string;
|
|
1738
|
+
sessionId: string;
|
|
1739
|
+
sessionMetadata?: Record<string, unknown>;
|
|
1740
|
+
status: VoiceSessionStatus;
|
|
1741
|
+
turns: VoiceTurnRecord<TResult>[];
|
|
1742
|
+
} | {
|
|
1743
|
+
type: "call_lifecycle";
|
|
1744
|
+
event: VoiceCallLifecycleEvent;
|
|
1745
|
+
sessionId: string;
|
|
1746
|
+
} | {
|
|
1747
|
+
type: "partial";
|
|
1748
|
+
transcript: Transcript;
|
|
1749
|
+
} | {
|
|
1750
|
+
type: "final";
|
|
1751
|
+
transcript: Transcript;
|
|
1752
|
+
} | {
|
|
1753
|
+
type: "turn";
|
|
1754
|
+
turn: VoiceTurnRecord<TResult>;
|
|
1755
|
+
} | {
|
|
1756
|
+
type: "assistant";
|
|
1757
|
+
text: string;
|
|
1758
|
+
turnId?: string;
|
|
1759
|
+
} | {
|
|
1760
|
+
type: "assistant_delta";
|
|
1761
|
+
delta: string;
|
|
1762
|
+
turnId?: string;
|
|
1763
|
+
} | {
|
|
1764
|
+
type: "audio";
|
|
1765
|
+
chunk: Uint8Array;
|
|
1766
|
+
format: AudioFormat;
|
|
1767
|
+
receivedAt: number;
|
|
1768
|
+
turnId?: string;
|
|
1769
|
+
} | {
|
|
1770
|
+
type: "complete";
|
|
1771
|
+
sessionId: string;
|
|
1772
|
+
} | {
|
|
1773
|
+
type: "error";
|
|
1774
|
+
message: string;
|
|
1775
|
+
recoverable?: boolean;
|
|
1776
|
+
} | {
|
|
1777
|
+
type: "playback_rate";
|
|
1778
|
+
rate: number;
|
|
1779
|
+
} | {
|
|
1780
|
+
type: "connected";
|
|
1781
|
+
} | {
|
|
1782
|
+
type: "connection";
|
|
1783
|
+
reconnect: VoiceReconnectClientState;
|
|
1784
|
+
} | {
|
|
1785
|
+
type: "disconnected";
|
|
1786
|
+
};
|