@framers/agentos 0.1.112 → 0.1.114
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/README.md +39 -5
- package/dist/api/AgentOS.d.ts +45 -12
- package/dist/api/AgentOS.d.ts.map +1 -1
- package/dist/api/AgentOS.js +225 -78
- package/dist/api/AgentOS.js.map +1 -1
- package/dist/api/AgentOSOrchestrator.d.ts +8 -0
- package/dist/api/AgentOSOrchestrator.d.ts.map +1 -1
- package/dist/api/AgentOSOrchestrator.js +350 -59
- package/dist/api/AgentOSOrchestrator.js.map +1 -1
- package/dist/api/StreamChunkEmitter.d.ts.map +1 -1
- package/dist/api/StreamChunkEmitter.js +2 -0
- package/dist/api/StreamChunkEmitter.js.map +1 -1
- package/dist/api/agency.d.ts.map +1 -1
- package/dist/api/agency.js +47 -1
- package/dist/api/agency.js.map +1 -1
- package/dist/api/agent.d.ts +18 -5
- package/dist/api/agent.d.ts.map +1 -1
- package/dist/api/agent.js +48 -9
- package/dist/api/agent.js.map +1 -1
- package/dist/api/agentExport.d.ts +202 -0
- package/dist/api/agentExport.d.ts.map +1 -0
- package/dist/api/agentExport.js +323 -0
- package/dist/api/agentExport.js.map +1 -0
- package/dist/api/editImage.d.ts +119 -0
- package/dist/api/editImage.d.ts.map +1 -0
- package/dist/api/editImage.js +150 -0
- package/dist/api/editImage.js.map +1 -0
- package/dist/api/embedText.d.ts +137 -0
- package/dist/api/embedText.d.ts.map +1 -0
- package/dist/api/embedText.js +229 -0
- package/dist/api/embedText.js.map +1 -0
- package/dist/api/externalToolRegistry.d.ts +44 -0
- package/dist/api/externalToolRegistry.d.ts.map +1 -0
- package/dist/api/externalToolRegistry.js +245 -0
- package/dist/api/externalToolRegistry.js.map +1 -0
- package/dist/api/generateImage.d.ts +1 -1
- package/dist/api/generateImage.d.ts.map +1 -1
- package/dist/api/generateImage.js +17 -13
- package/dist/api/generateImage.js.map +1 -1
- package/dist/api/generateObject.d.ts +185 -0
- package/dist/api/generateObject.d.ts.map +1 -0
- package/dist/api/generateObject.js +249 -0
- package/dist/api/generateObject.js.map +1 -0
- package/dist/api/generateText.d.ts +13 -3
- package/dist/api/generateText.d.ts.map +1 -1
- package/dist/api/generateText.js +20 -5
- package/dist/api/generateText.js.map +1 -1
- package/dist/api/interfaces/IAgentOS.d.ts +29 -1
- package/dist/api/interfaces/IAgentOS.d.ts.map +1 -1
- package/dist/api/model.d.ts +7 -7
- package/dist/api/model.d.ts.map +1 -1
- package/dist/api/model.js +22 -16
- package/dist/api/model.js.map +1 -1
- package/dist/api/processRequestWithExternalTools.d.ts +26 -0
- package/dist/api/processRequestWithExternalTools.d.ts.map +1 -0
- package/dist/api/processRequestWithExternalTools.js +52 -0
- package/dist/api/processRequestWithExternalTools.js.map +1 -0
- package/dist/api/processRequestWithRegisteredTools.d.ts +56 -0
- package/dist/api/processRequestWithRegisteredTools.d.ts.map +1 -0
- package/dist/api/processRequestWithRegisteredTools.js +125 -0
- package/dist/api/processRequestWithRegisteredTools.js.map +1 -0
- package/dist/api/provider-defaults.d.ts.map +1 -1
- package/dist/api/provider-defaults.js +28 -0
- package/dist/api/provider-defaults.js.map +1 -1
- package/dist/api/resumeExternalToolRequestWithRegisteredTools.d.ts +71 -0
- package/dist/api/resumeExternalToolRequestWithRegisteredTools.d.ts.map +1 -0
- package/dist/api/resumeExternalToolRequestWithRegisteredTools.js +159 -0
- package/dist/api/resumeExternalToolRequestWithRegisteredTools.js.map +1 -0
- package/dist/api/strategies/agentGraphBuilder.d.ts +170 -0
- package/dist/api/strategies/agentGraphBuilder.d.ts.map +1 -0
- package/dist/api/strategies/agentGraphBuilder.js +299 -0
- package/dist/api/strategies/agentGraphBuilder.js.map +1 -0
- package/dist/api/strategies/debate.d.ts +12 -1
- package/dist/api/strategies/debate.d.ts.map +1 -1
- package/dist/api/strategies/debate.js +41 -5
- package/dist/api/strategies/debate.js.map +1 -1
- package/dist/api/strategies/graphCompiler.d.ts +84 -0
- package/dist/api/strategies/graphCompiler.d.ts.map +1 -0
- package/dist/api/strategies/graphCompiler.js +617 -0
- package/dist/api/strategies/graphCompiler.js.map +1 -0
- package/dist/api/strategies/hierarchical.d.ts +15 -1
- package/dist/api/strategies/hierarchical.d.ts.map +1 -1
- package/dist/api/strategies/hierarchical.js +53 -8
- package/dist/api/strategies/hierarchical.js.map +1 -1
- package/dist/api/strategies/index.d.ts +29 -4
- package/dist/api/strategies/index.d.ts.map +1 -1
- package/dist/api/strategies/index.js +28 -4
- package/dist/api/strategies/index.js.map +1 -1
- package/dist/api/strategies/parallel.d.ts +15 -4
- package/dist/api/strategies/parallel.d.ts.map +1 -1
- package/dist/api/strategies/parallel.js +53 -16
- package/dist/api/strategies/parallel.js.map +1 -1
- package/dist/api/strategies/review-loop.d.ts +15 -1
- package/dist/api/strategies/review-loop.d.ts.map +1 -1
- package/dist/api/strategies/review-loop.js +36 -10
- package/dist/api/strategies/review-loop.js.map +1 -1
- package/dist/api/strategies/sequential.d.ts +11 -1
- package/dist/api/strategies/sequential.d.ts.map +1 -1
- package/dist/api/strategies/sequential.js +39 -8
- package/dist/api/strategies/sequential.js.map +1 -1
- package/dist/api/strategies/shared.d.ts +72 -8
- package/dist/api/strategies/shared.d.ts.map +1 -1
- package/dist/api/strategies/shared.js +92 -12
- package/dist/api/strategies/shared.js.map +1 -1
- package/dist/api/streamObject.d.ts +166 -0
- package/dist/api/streamObject.d.ts.map +1 -0
- package/dist/api/streamObject.js +268 -0
- package/dist/api/streamObject.js.map +1 -0
- package/dist/api/streamText.d.ts +1 -1
- package/dist/api/streamText.d.ts.map +1 -1
- package/dist/api/streamText.js +26 -8
- package/dist/api/streamText.js.map +1 -1
- package/dist/api/toolAdapter.d.ts +44 -8
- package/dist/api/toolAdapter.d.ts.map +1 -1
- package/dist/api/toolAdapter.js +224 -45
- package/dist/api/toolAdapter.js.map +1 -1
- package/dist/api/types/AgentOSExternalToolRequest.d.ts +35 -0
- package/dist/api/types/AgentOSExternalToolRequest.d.ts.map +1 -0
- package/dist/api/types/AgentOSExternalToolRequest.js +2 -0
- package/dist/api/types/AgentOSExternalToolRequest.js.map +1 -0
- package/dist/api/types/AgentOSResponse.d.ts +25 -0
- package/dist/api/types/AgentOSResponse.d.ts.map +1 -1
- package/dist/api/types/AgentOSResponse.js +20 -0
- package/dist/api/types/AgentOSResponse.js.map +1 -1
- package/dist/api/types/AgentOSToolResult.d.ts +11 -0
- package/dist/api/types/AgentOSToolResult.d.ts.map +1 -0
- package/dist/api/types/AgentOSToolResult.js +2 -0
- package/dist/api/types/AgentOSToolResult.js.map +1 -0
- package/dist/api/types.d.ts +81 -4
- package/dist/api/types.d.ts.map +1 -1
- package/dist/api/types.js.map +1 -1
- package/dist/api/upscaleImage.d.ts +92 -0
- package/dist/api/upscaleImage.d.ts.map +1 -0
- package/dist/api/upscaleImage.js +133 -0
- package/dist/api/upscaleImage.js.map +1 -0
- package/dist/api/variateImage.d.ts +102 -0
- package/dist/api/variateImage.d.ts.map +1 -0
- package/dist/api/variateImage.js +154 -0
- package/dist/api/variateImage.js.map +1 -0
- package/dist/cognitive_substrate/GMI.d.ts +16 -2
- package/dist/cognitive_substrate/GMI.d.ts.map +1 -1
- package/dist/cognitive_substrate/GMI.js +188 -56
- package/dist/cognitive_substrate/GMI.js.map +1 -1
- package/dist/cognitive_substrate/IGMI.d.ts +10 -0
- package/dist/cognitive_substrate/IGMI.d.ts.map +1 -1
- package/dist/cognitive_substrate/IGMI.js.map +1 -1
- package/dist/config/AgentOSConfig.d.ts +19 -2
- package/dist/config/AgentOSConfig.d.ts.map +1 -1
- package/dist/config/AgentOSConfig.js +46 -29
- package/dist/config/AgentOSConfig.js.map +1 -1
- package/dist/core/guardrails/IGuardrailService.d.ts +1 -1
- package/dist/core/images/IImageProvider.d.ts +93 -0
- package/dist/core/images/IImageProvider.d.ts.map +1 -1
- package/dist/core/images/IImageProvider.js.map +1 -1
- package/dist/core/images/ImageOperationError.d.ts +52 -0
- package/dist/core/images/ImageOperationError.d.ts.map +1 -0
- package/dist/core/images/ImageOperationError.js +58 -0
- package/dist/core/images/ImageOperationError.js.map +1 -0
- package/dist/core/images/imageToBuffer.d.ts +41 -0
- package/dist/core/images/imageToBuffer.d.ts.map +1 -0
- package/dist/core/images/imageToBuffer.js +95 -0
- package/dist/core/images/imageToBuffer.js.map +1 -0
- package/dist/core/images/index.d.ts +4 -0
- package/dist/core/images/index.d.ts.map +1 -1
- package/dist/core/images/index.js +8 -0
- package/dist/core/images/index.js.map +1 -1
- package/dist/core/images/providers/FalImageProvider.d.ts +208 -0
- package/dist/core/images/providers/FalImageProvider.d.ts.map +1 -0
- package/dist/core/images/providers/FalImageProvider.js +301 -0
- package/dist/core/images/providers/FalImageProvider.js.map +1 -0
- package/dist/core/images/providers/FluxImageProvider.d.ts +197 -0
- package/dist/core/images/providers/FluxImageProvider.d.ts.map +1 -0
- package/dist/core/images/providers/FluxImageProvider.js +271 -0
- package/dist/core/images/providers/FluxImageProvider.js.map +1 -0
- package/dist/core/images/providers/OpenAIImageProvider.d.ts +33 -1
- package/dist/core/images/providers/OpenAIImageProvider.d.ts.map +1 -1
- package/dist/core/images/providers/OpenAIImageProvider.js +125 -0
- package/dist/core/images/providers/OpenAIImageProvider.js.map +1 -1
- package/dist/core/images/providers/ReplicateImageProvider.d.ts +26 -1
- package/dist/core/images/providers/ReplicateImageProvider.d.ts.map +1 -1
- package/dist/core/images/providers/ReplicateImageProvider.js +118 -0
- package/dist/core/images/providers/ReplicateImageProvider.js.map +1 -1
- package/dist/core/images/providers/StabilityImageProvider.d.ts +41 -1
- package/dist/core/images/providers/StabilityImageProvider.d.ts.map +1 -1
- package/dist/core/images/providers/StabilityImageProvider.js +180 -7
- package/dist/core/images/providers/StabilityImageProvider.js.map +1 -1
- package/dist/core/images/providers/StableDiffusionLocalProvider.d.ts +29 -1
- package/dist/core/images/providers/StableDiffusionLocalProvider.d.ts.map +1 -1
- package/dist/core/images/providers/StableDiffusionLocalProvider.js +124 -0
- package/dist/core/images/providers/StableDiffusionLocalProvider.js.map +1 -1
- package/dist/core/llm/IPromptEngine.d.ts +2 -2
- package/dist/core/llm/IPromptEngine.d.ts.map +1 -1
- package/dist/core/llm/IPromptEngine.js +2 -2
- package/dist/core/llm/IPromptEngine.js.map +1 -1
- package/dist/core/llm/providers/AIModelProviderManager.d.ts +7 -1
- package/dist/core/llm/providers/AIModelProviderManager.d.ts.map +1 -1
- package/dist/core/llm/providers/AIModelProviderManager.js +24 -0
- package/dist/core/llm/providers/AIModelProviderManager.js.map +1 -1
- package/dist/core/llm/providers/errors/AnthropicProviderError.d.ts +42 -0
- package/dist/core/llm/providers/errors/AnthropicProviderError.d.ts.map +1 -0
- package/dist/core/llm/providers/errors/AnthropicProviderError.js +45 -0
- package/dist/core/llm/providers/errors/AnthropicProviderError.js.map +1 -0
- package/dist/core/llm/providers/errors/GeminiProviderError.d.ts +45 -0
- package/dist/core/llm/providers/errors/GeminiProviderError.d.ts.map +1 -0
- package/dist/core/llm/providers/errors/GeminiProviderError.js +46 -0
- package/dist/core/llm/providers/errors/GeminiProviderError.js.map +1 -0
- package/dist/core/llm/providers/errors/OllamaProviderError.d.ts +1 -1
- package/dist/core/llm/providers/errors/OllamaProviderError.d.ts.map +1 -1
- package/dist/core/llm/providers/errors/OllamaProviderError.js +1 -1
- package/dist/core/llm/providers/errors/OllamaProviderError.js.map +1 -1
- package/dist/core/llm/providers/errors/OpenAIProviderError.d.ts +1 -1
- package/dist/core/llm/providers/errors/OpenAIProviderError.js +1 -1
- package/dist/core/llm/providers/errors/OpenRouterProviderError.d.ts +1 -1
- package/dist/core/llm/providers/errors/OpenRouterProviderError.js +1 -1
- package/dist/core/llm/providers/implementations/AnthropicProvider.d.ts +340 -0
- package/dist/core/llm/providers/implementations/AnthropicProvider.d.ts.map +1 -0
- package/dist/core/llm/providers/implementations/AnthropicProvider.js +959 -0
- package/dist/core/llm/providers/implementations/AnthropicProvider.js.map +1 -0
- package/dist/core/llm/providers/implementations/GeminiProvider.d.ts +339 -0
- package/dist/core/llm/providers/implementations/GeminiProvider.d.ts.map +1 -0
- package/dist/core/llm/providers/implementations/GeminiProvider.js +1004 -0
- package/dist/core/llm/providers/implementations/GeminiProvider.js.map +1 -0
- package/dist/core/llm/providers/implementations/GroqProvider.d.ts +105 -0
- package/dist/core/llm/providers/implementations/GroqProvider.d.ts.map +1 -0
- package/dist/core/llm/providers/implementations/GroqProvider.js +134 -0
- package/dist/core/llm/providers/implementations/GroqProvider.js.map +1 -0
- package/dist/core/llm/providers/implementations/MistralProvider.d.ts +105 -0
- package/dist/core/llm/providers/implementations/MistralProvider.d.ts.map +1 -0
- package/dist/core/llm/providers/implementations/MistralProvider.js +146 -0
- package/dist/core/llm/providers/implementations/MistralProvider.js.map +1 -0
- package/dist/core/llm/providers/implementations/TogetherProvider.d.ts +107 -0
- package/dist/core/llm/providers/implementations/TogetherProvider.d.ts.map +1 -0
- package/dist/core/llm/providers/implementations/TogetherProvider.js +138 -0
- package/dist/core/llm/providers/implementations/TogetherProvider.js.map +1 -0
- package/dist/core/llm/providers/implementations/XAIProvider.d.ts +102 -0
- package/dist/core/llm/providers/implementations/XAIProvider.d.ts.map +1 -0
- package/dist/core/llm/providers/implementations/XAIProvider.js +123 -0
- package/dist/core/llm/providers/implementations/XAIProvider.js.map +1 -0
- package/dist/core/orchestration/AgentOrchestrator.d.ts.map +1 -1
- package/dist/core/orchestration/AgentOrchestrator.js +26 -5
- package/dist/core/orchestration/AgentOrchestrator.js.map +1 -1
- package/dist/core/tools/IToolOrchestrator.d.ts +2 -2
- package/dist/core/tools/IToolOrchestrator.d.ts.map +1 -1
- package/dist/core/tools/ToolExecutor.d.ts +3 -0
- package/dist/core/tools/ToolExecutor.d.ts.map +1 -1
- package/dist/core/tools/ToolExecutor.js +2 -1
- package/dist/core/tools/ToolExecutor.js.map +1 -1
- package/dist/core/tools/ToolOrchestrator.d.ts +7 -7
- package/dist/core/tools/ToolOrchestrator.d.ts.map +1 -1
- package/dist/core/tools/ToolOrchestrator.js +135 -36
- package/dist/core/tools/ToolOrchestrator.js.map +1 -1
- package/dist/core/tools/permissions/ToolPermissionManager.d.ts +6 -5
- package/dist/core/tools/permissions/ToolPermissionManager.d.ts.map +1 -1
- package/dist/core/tools/permissions/ToolPermissionManager.js +47 -21
- package/dist/core/tools/permissions/ToolPermissionManager.js.map +1 -1
- package/dist/core/vision/VisionPipeline.d.ts +437 -0
- package/dist/core/vision/VisionPipeline.d.ts.map +1 -0
- package/dist/core/vision/VisionPipeline.js +1113 -0
- package/dist/core/vision/VisionPipeline.js.map +1 -0
- package/dist/core/vision/index.d.ts +97 -0
- package/dist/core/vision/index.d.ts.map +1 -0
- package/dist/core/vision/index.js +182 -0
- package/dist/core/vision/index.js.map +1 -0
- package/dist/core/vision/providers/LLMVisionProvider.d.ts +135 -0
- package/dist/core/vision/providers/LLMVisionProvider.d.ts.map +1 -0
- package/dist/core/vision/providers/LLMVisionProvider.js +136 -0
- package/dist/core/vision/providers/LLMVisionProvider.js.map +1 -0
- package/dist/core/vision/providers/PipelineVisionProvider.d.ts +154 -0
- package/dist/core/vision/providers/PipelineVisionProvider.d.ts.map +1 -0
- package/dist/core/vision/providers/PipelineVisionProvider.js +160 -0
- package/dist/core/vision/providers/PipelineVisionProvider.js.map +1 -0
- package/dist/core/vision/types.d.ts +286 -0
- package/dist/core/vision/types.d.ts.map +1 -0
- package/dist/core/vision/types.js +24 -0
- package/dist/core/vision/types.js.map +1 -0
- package/dist/discovery/CapabilityDiscoveryEngine.d.ts +1 -1
- package/dist/discovery/CapabilityDiscoveryEngine.d.ts.map +1 -1
- package/dist/discovery/CapabilityDiscoveryEngine.js +1 -1
- package/dist/discovery/CapabilityDiscoveryEngine.js.map +1 -1
- package/dist/emergent/ComposableToolBuilder.d.ts +15 -4
- package/dist/emergent/ComposableToolBuilder.d.ts.map +1 -1
- package/dist/emergent/ComposableToolBuilder.js +29 -14
- package/dist/emergent/ComposableToolBuilder.js.map +1 -1
- package/dist/emergent/EmergentCapabilityEngine.d.ts +3 -3
- package/dist/emergent/EmergentCapabilityEngine.d.ts.map +1 -1
- package/dist/emergent/EmergentCapabilityEngine.js +15 -12
- package/dist/emergent/EmergentCapabilityEngine.js.map +1 -1
- package/dist/emergent/EmergentJudge.d.ts +20 -0
- package/dist/emergent/EmergentJudge.d.ts.map +1 -1
- package/dist/emergent/EmergentJudge.js +121 -26
- package/dist/emergent/EmergentJudge.js.map +1 -1
- package/dist/emergent/EmergentToolRegistry.d.ts +17 -0
- package/dist/emergent/EmergentToolRegistry.d.ts.map +1 -1
- package/dist/emergent/EmergentToolRegistry.js +26 -0
- package/dist/emergent/EmergentToolRegistry.js.map +1 -1
- package/dist/emergent/ForgeToolMetaTool.d.ts +1 -1
- package/dist/emergent/ForgeToolMetaTool.d.ts.map +1 -1
- package/dist/emergent/ForgeToolMetaTool.js +15 -2
- package/dist/emergent/ForgeToolMetaTool.js.map +1 -1
- package/dist/emergent/SandboxedToolForge.d.ts +2 -2
- package/dist/emergent/SandboxedToolForge.d.ts.map +1 -1
- package/dist/emergent/SandboxedToolForge.js +13 -23
- package/dist/emergent/SandboxedToolForge.js.map +1 -1
- package/dist/emergent/SkillExporter.d.ts +119 -0
- package/dist/emergent/SkillExporter.d.ts.map +1 -0
- package/dist/emergent/SkillExporter.js +344 -0
- package/dist/emergent/SkillExporter.js.map +1 -0
- package/dist/emergent/index.d.ts +1 -0
- package/dist/emergent/index.d.ts.map +1 -1
- package/dist/emergent/index.js +1 -0
- package/dist/emergent/index.js.map +1 -1
- package/dist/emergent/types.d.ts +4 -4
- package/dist/index.d.ts +30 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -2
- package/dist/index.js.map +1 -1
- package/dist/memory/facade/Memory.d.ts.map +1 -1
- package/dist/memory/facade/Memory.js +8 -0
- package/dist/memory/facade/Memory.js.map +1 -1
- package/dist/memory/facade/types.d.ts +10 -0
- package/dist/memory/facade/types.d.ts.map +1 -1
- package/dist/memory/index.d.ts +15 -7
- package/dist/memory/index.d.ts.map +1 -1
- package/dist/memory/index.js +7 -0
- package/dist/memory/index.js.map +1 -1
- package/dist/memory/ingestion/DoclingLoader.d.ts +3 -3
- package/dist/memory/ingestion/DoclingLoader.d.ts.map +1 -1
- package/dist/memory/ingestion/DoclingLoader.js +12 -8
- package/dist/memory/ingestion/DoclingLoader.js.map +1 -1
- package/dist/memory/ingestion/FolderScanner.d.ts +7 -7
- package/dist/memory/ingestion/FolderScanner.d.ts.map +1 -1
- package/dist/memory/ingestion/FolderScanner.js +6 -6
- package/dist/memory/ingestion/FolderScanner.js.map +1 -1
- package/dist/memory/ingestion/LoaderRegistry.d.ts +8 -8
- package/dist/memory/ingestion/LoaderRegistry.d.ts.map +1 -1
- package/dist/memory/ingestion/LoaderRegistry.js +9 -11
- package/dist/memory/ingestion/LoaderRegistry.js.map +1 -1
- package/dist/memory/ingestion/MultimodalAggregator.d.ts +1 -1
- package/dist/memory/ingestion/MultimodalAggregator.js +1 -1
- package/dist/memory/ingestion/OcrPdfLoader.d.ts +2 -2
- package/dist/memory/ingestion/OcrPdfLoader.d.ts.map +1 -1
- package/dist/memory/ingestion/OcrPdfLoader.js +12 -8
- package/dist/memory/ingestion/OcrPdfLoader.js.map +1 -1
- package/dist/memory/ingestion/PdfLoader.d.ts +8 -8
- package/dist/memory/ingestion/PdfLoader.d.ts.map +1 -1
- package/dist/memory/ingestion/PdfLoader.js +13 -10
- package/dist/memory/ingestion/PdfLoader.js.map +1 -1
- package/dist/memory/io/MarkdownExporter.d.ts +1 -1
- package/dist/memory/io/MarkdownExporter.d.ts.map +1 -1
- package/dist/memory/io/MarkdownExporter.js +1 -1
- package/dist/memory/io/MarkdownExporter.js.map +1 -1
- package/dist/memory/observation/MemoryObserver.d.ts +63 -1
- package/dist/memory/observation/MemoryObserver.d.ts.map +1 -1
- package/dist/memory/observation/MemoryObserver.js +115 -4
- package/dist/memory/observation/MemoryObserver.js.map +1 -1
- package/dist/memory/observation/ObservationCompressor.d.ts +88 -0
- package/dist/memory/observation/ObservationCompressor.d.ts.map +1 -0
- package/dist/memory/observation/ObservationCompressor.js +207 -0
- package/dist/memory/observation/ObservationCompressor.js.map +1 -0
- package/dist/memory/observation/ObservationReflector.d.ts +82 -0
- package/dist/memory/observation/ObservationReflector.d.ts.map +1 -0
- package/dist/memory/observation/ObservationReflector.js +212 -0
- package/dist/memory/observation/ObservationReflector.js.map +1 -0
- package/dist/memory/observation/temporal.d.ts +54 -0
- package/dist/memory/observation/temporal.d.ts.map +1 -0
- package/dist/memory/observation/temporal.js +115 -0
- package/dist/memory/observation/temporal.js.map +1 -0
- package/dist/memory/tools/MemoryAddTool.d.ts +2 -2
- package/dist/memory/tools/MemoryAddTool.d.ts.map +1 -1
- package/dist/memory/tools/MemoryAddTool.js +8 -3
- package/dist/memory/tools/MemoryAddTool.js.map +1 -1
- package/dist/memory/tools/MemorySearchTool.d.ts +3 -3
- package/dist/memory/tools/MemorySearchTool.d.ts.map +1 -1
- package/dist/memory/tools/MemorySearchTool.js +11 -9
- package/dist/memory/tools/MemorySearchTool.js.map +1 -1
- package/dist/memory/tools/scopeContext.d.ts +11 -0
- package/dist/memory/tools/scopeContext.d.ts.map +1 -0
- package/dist/memory/tools/scopeContext.js +46 -0
- package/dist/memory/tools/scopeContext.js.map +1 -0
- package/dist/orchestration/builders/AgentGraph.d.ts +12 -11
- package/dist/orchestration/builders/AgentGraph.d.ts.map +1 -1
- package/dist/orchestration/builders/AgentGraph.js +12 -11
- package/dist/orchestration/builders/AgentGraph.js.map +1 -1
- package/dist/orchestration/builders/VoiceNodeBuilder.d.ts +82 -25
- package/dist/orchestration/builders/VoiceNodeBuilder.d.ts.map +1 -1
- package/dist/orchestration/builders/VoiceNodeBuilder.js +86 -26
- package/dist/orchestration/builders/VoiceNodeBuilder.js.map +1 -1
- package/dist/orchestration/builders/WorkflowBuilder.d.ts +1 -1
- package/dist/orchestration/builders/WorkflowBuilder.d.ts.map +1 -1
- package/dist/orchestration/builders/WorkflowBuilder.js +1 -1
- package/dist/orchestration/builders/WorkflowBuilder.js.map +1 -1
- package/dist/orchestration/checkpoint/InMemoryCheckpointStore.d.ts +7 -54
- package/dist/orchestration/checkpoint/InMemoryCheckpointStore.d.ts.map +1 -1
- package/dist/orchestration/checkpoint/InMemoryCheckpointStore.js +8 -56
- package/dist/orchestration/checkpoint/InMemoryCheckpointStore.js.map +1 -1
- package/dist/orchestration/events/GraphEvent.d.ts +67 -5
- package/dist/orchestration/events/GraphEvent.d.ts.map +1 -1
- package/dist/orchestration/events/GraphEvent.js.map +1 -1
- package/dist/orchestration/runtime/GraphRuntime.d.ts.map +1 -1
- package/dist/orchestration/runtime/GraphRuntime.js +151 -1
- package/dist/orchestration/runtime/GraphRuntime.js.map +1 -1
- package/dist/orchestration/runtime/LoopController.d.ts +3 -3
- package/dist/orchestration/runtime/LoopController.d.ts.map +1 -1
- package/dist/orchestration/runtime/LoopController.js.map +1 -1
- package/dist/orchestration/runtime/StateManager.d.ts +3 -3
- package/dist/orchestration/runtime/StateManager.js +3 -3
- package/dist/orchestration/runtime/VoiceNodeExecutor.d.ts +103 -26
- package/dist/orchestration/runtime/VoiceNodeExecutor.d.ts.map +1 -1
- package/dist/orchestration/runtime/VoiceNodeExecutor.js +155 -43
- package/dist/orchestration/runtime/VoiceNodeExecutor.js.map +1 -1
- package/dist/orchestration/runtime/VoiceTransportAdapter.d.ts +95 -33
- package/dist/orchestration/runtime/VoiceTransportAdapter.d.ts.map +1 -1
- package/dist/orchestration/runtime/VoiceTransportAdapter.js +83 -29
- package/dist/orchestration/runtime/VoiceTransportAdapter.js.map +1 -1
- package/dist/orchestration/runtime/VoiceTurnCollector.d.ts +73 -20
- package/dist/orchestration/runtime/VoiceTurnCollector.d.ts.map +1 -1
- package/dist/orchestration/runtime/VoiceTurnCollector.js +84 -23
- package/dist/orchestration/runtime/VoiceTurnCollector.js.map +1 -1
- package/dist/query-router/KeywordFallback.d.ts +70 -0
- package/dist/query-router/KeywordFallback.d.ts.map +1 -0
- package/dist/query-router/KeywordFallback.js +132 -0
- package/dist/query-router/KeywordFallback.js.map +1 -0
- package/dist/query-router/QueryClassifier.d.ts +140 -0
- package/dist/query-router/QueryClassifier.d.ts.map +1 -0
- package/dist/query-router/QueryClassifier.js +223 -0
- package/dist/query-router/QueryClassifier.js.map +1 -0
- package/dist/query-router/QueryDispatcher.d.ts +139 -0
- package/dist/query-router/QueryDispatcher.d.ts.map +1 -0
- package/dist/query-router/QueryDispatcher.js +297 -0
- package/dist/query-router/QueryDispatcher.js.map +1 -0
- package/dist/query-router/QueryGenerator.d.ts +184 -0
- package/dist/query-router/QueryGenerator.d.ts.map +1 -0
- package/dist/query-router/QueryGenerator.js +241 -0
- package/dist/query-router/QueryGenerator.js.map +1 -0
- package/dist/query-router/QueryRouter.d.ts +292 -0
- package/dist/query-router/QueryRouter.d.ts.map +1 -0
- package/dist/query-router/QueryRouter.js +803 -0
- package/dist/query-router/QueryRouter.js.map +1 -0
- package/dist/query-router/TopicExtractor.d.ts +73 -0
- package/dist/query-router/TopicExtractor.d.ts.map +1 -0
- package/dist/query-router/TopicExtractor.js +95 -0
- package/dist/query-router/TopicExtractor.js.map +1 -0
- package/dist/query-router/index.d.ts +40 -0
- package/dist/query-router/index.d.ts.map +1 -0
- package/dist/query-router/index.js +46 -0
- package/dist/query-router/index.js.map +1 -0
- package/dist/query-router/types.d.ts +508 -0
- package/dist/query-router/types.d.ts.map +1 -0
- package/dist/query-router/types.js +39 -0
- package/dist/query-router/types.js.map +1 -0
- package/dist/rag/index.d.ts +5 -0
- package/dist/rag/index.d.ts.map +1 -1
- package/dist/rag/index.js +7 -0
- package/dist/rag/index.js.map +1 -1
- package/dist/rag/multimodal/LLMVisionAdapter.d.ts +43 -0
- package/dist/rag/multimodal/LLMVisionAdapter.d.ts.map +1 -0
- package/dist/rag/multimodal/LLMVisionAdapter.js +46 -0
- package/dist/rag/multimodal/LLMVisionAdapter.js.map +1 -0
- package/dist/rag/multimodal/MultimodalIndexer.d.ts +244 -0
- package/dist/rag/multimodal/MultimodalIndexer.d.ts.map +1 -0
- package/dist/rag/multimodal/MultimodalIndexer.js +411 -0
- package/dist/rag/multimodal/MultimodalIndexer.js.map +1 -0
- package/dist/rag/multimodal/MultimodalMemoryBridge.d.ts +448 -0
- package/dist/rag/multimodal/MultimodalMemoryBridge.d.ts.map +1 -0
- package/dist/rag/multimodal/MultimodalMemoryBridge.js +941 -0
- package/dist/rag/multimodal/MultimodalMemoryBridge.js.map +1 -0
- package/dist/rag/multimodal/SpeechProviderAdapter.d.ts +139 -0
- package/dist/rag/multimodal/SpeechProviderAdapter.d.ts.map +1 -0
- package/dist/rag/multimodal/SpeechProviderAdapter.js +143 -0
- package/dist/rag/multimodal/SpeechProviderAdapter.js.map +1 -0
- package/dist/rag/multimodal/createMultimodalIndexerFromResolver.d.ts +172 -0
- package/dist/rag/multimodal/createMultimodalIndexerFromResolver.d.ts.map +1 -0
- package/dist/rag/multimodal/createMultimodalIndexerFromResolver.js +152 -0
- package/dist/rag/multimodal/createMultimodalIndexerFromResolver.js.map +1 -0
- package/dist/rag/multimodal/index.d.ts +44 -0
- package/dist/rag/multimodal/index.d.ts.map +1 -0
- package/dist/rag/multimodal/index.js +42 -0
- package/dist/rag/multimodal/index.js.map +1 -0
- package/dist/rag/multimodal/types.d.ts +276 -0
- package/dist/rag/multimodal/types.d.ts.map +1 -0
- package/dist/rag/multimodal/types.js +26 -0
- package/dist/rag/multimodal/types.js.map +1 -0
- package/dist/social-posting/SocialPostManager.d.ts +3 -3
- package/dist/social-posting/SocialPostManager.d.ts.map +1 -1
- package/dist/social-posting/SocialPostManager.js +3 -5
- package/dist/social-posting/SocialPostManager.js.map +1 -1
- package/dist/speech/FallbackProxy.d.ts +6 -6
- package/dist/speech/FallbackProxy.d.ts.map +1 -1
- package/dist/speech/FallbackProxy.js +3 -3
- package/dist/speech/FallbackProxy.js.map +1 -1
- package/dist/speech/SpeechProviderResolver.d.ts +8 -8
- package/dist/speech/SpeechProviderResolver.d.ts.map +1 -1
- package/dist/speech/SpeechProviderResolver.js +22 -11
- package/dist/speech/SpeechProviderResolver.js.map +1 -1
- package/dist/speech/SpeechRuntime.d.ts +1 -5
- package/dist/speech/SpeechRuntime.d.ts.map +1 -1
- package/dist/speech/SpeechRuntime.js +17 -9
- package/dist/speech/SpeechRuntime.js.map +1 -1
- package/dist/speech/providers/AssemblyAISTTProvider.d.ts +4 -4
- package/dist/speech/providers/AssemblyAISTTProvider.js +4 -4
- package/dist/speech/providers/AzureSpeechTTSProvider.d.ts +3 -3
- package/dist/speech/providers/AzureSpeechTTSProvider.js +2 -2
- package/dist/speech/providers/AzureSpeechTTSProvider.js.map +1 -1
- package/dist/speech/providers/BuiltInAdaptiveVadProvider.d.ts +9 -9
- package/dist/speech/providers/BuiltInAdaptiveVadProvider.d.ts.map +1 -1
- package/dist/speech/providers/BuiltInAdaptiveVadProvider.js +5 -5
- package/dist/speech/providers/BuiltInAdaptiveVadProvider.js.map +1 -1
- package/dist/speech/providers/DeepgramBatchSTTProvider.d.ts +2 -2
- package/dist/speech/providers/DeepgramBatchSTTProvider.js +2 -2
- package/dist/speech/providers/OpenAITextToSpeechProvider.d.ts +3 -3
- package/dist/speech/providers/OpenAITextToSpeechProvider.js +2 -2
- package/dist/speech/providers/OpenAIWhisperSpeechToTextProvider.d.ts +1 -1
- package/dist/speech/providers/OpenAIWhisperSpeechToTextProvider.d.ts.map +1 -1
- package/dist/speech/providers/OpenAIWhisperSpeechToTextProvider.js +1 -1
- package/dist/speech/providers/OpenAIWhisperSpeechToTextProvider.js.map +1 -1
- package/dist/voice/TelephonyStreamTransport.d.ts +6 -6
- package/dist/voice/TelephonyStreamTransport.d.ts.map +1 -1
- package/dist/voice/TelephonyStreamTransport.js +5 -5
- package/dist/voice/TelephonyStreamTransport.js.map +1 -1
- package/dist/voice-pipeline/AcousticEndpointDetector.d.ts +4 -4
- package/dist/voice-pipeline/AcousticEndpointDetector.d.ts.map +1 -1
- package/dist/voice-pipeline/AcousticEndpointDetector.js +4 -4
- package/dist/voice-pipeline/AcousticEndpointDetector.js.map +1 -1
- package/dist/voice-pipeline/HardCutBargeinHandler.d.ts +3 -3
- package/dist/voice-pipeline/HardCutBargeinHandler.js +3 -3
- package/dist/voice-pipeline/HeuristicEndpointDetector.d.ts +3 -3
- package/dist/voice-pipeline/HeuristicEndpointDetector.d.ts.map +1 -1
- package/dist/voice-pipeline/HeuristicEndpointDetector.js +3 -3
- package/dist/voice-pipeline/HeuristicEndpointDetector.js.map +1 -1
- package/dist/voice-pipeline/SoftFadeBargeinHandler.d.ts +5 -5
- package/dist/voice-pipeline/SoftFadeBargeinHandler.js +1 -1
- package/dist/voice-pipeline/VoiceInterruptError.d.ts +6 -6
- package/dist/voice-pipeline/VoiceInterruptError.d.ts.map +1 -1
- package/dist/voice-pipeline/VoiceInterruptError.js +4 -4
- package/dist/voice-pipeline/VoiceInterruptError.js.map +1 -1
- package/dist/voice-pipeline/VoicePipelineOrchestrator.d.ts +9 -9
- package/dist/voice-pipeline/VoicePipelineOrchestrator.d.ts.map +1 -1
- package/dist/voice-pipeline/VoicePipelineOrchestrator.js +8 -8
- package/dist/voice-pipeline/VoicePipelineOrchestrator.js.map +1 -1
- package/dist/voice-pipeline/WebRTCStreamTransport.d.ts +421 -0
- package/dist/voice-pipeline/WebRTCStreamTransport.d.ts.map +1 -0
- package/dist/voice-pipeline/WebRTCStreamTransport.js +573 -0
- package/dist/voice-pipeline/WebRTCStreamTransport.js.map +1 -0
- package/dist/voice-pipeline/WebSocketStreamTransport.d.ts +8 -8
- package/dist/voice-pipeline/WebSocketStreamTransport.js +5 -5
- package/dist/voice-pipeline/index.d.ts +1 -0
- package/dist/voice-pipeline/index.d.ts.map +1 -1
- package/dist/voice-pipeline/index.js +2 -0
- package/dist/voice-pipeline/index.js.map +1 -1
- package/dist/voice-pipeline/types.d.ts +43 -43
- package/dist/voice-pipeline/types.d.ts.map +1 -1
- package/package.json +19 -1
|
@@ -1,22 +1,35 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file VoiceNodeExecutor.ts
|
|
3
3
|
* @description Executes voice nodes in the orchestration graph by managing a voice
|
|
4
|
-
* pipeline session, collecting turns via
|
|
4
|
+
* pipeline session, collecting turns via `VoiceTurnCollector`, and racing
|
|
5
5
|
* multiple exit conditions (hangup, turns exhausted, keyword, silence timeout,
|
|
6
6
|
* barge-in abort) to determine when the voice node completes.
|
|
7
7
|
*
|
|
8
|
+
* ## Design rationale
|
|
9
|
+
*
|
|
8
10
|
* The executor follows the standard 2-arg `execute(node, state)` contract used by
|
|
9
|
-
* {@link NodeExecutor}.
|
|
11
|
+
* {@link NodeExecutor}. Internally it creates an `AbortController` for barge-in
|
|
10
12
|
* support and optionally merges a parent abort signal from `state.scratch.abortSignal`.
|
|
11
13
|
*
|
|
14
|
+
* Exit conditions are modelled as a **single `Promise.race`** rather than a state
|
|
15
|
+
* machine because the conditions are orthogonal and any one of them can fire at any
|
|
16
|
+
* time. The `settled` flag inside {@link raceExitConditions} guards against
|
|
17
|
+
* double-resolution when two conditions fire within the same microtask.
|
|
18
|
+
*
|
|
19
|
+
* ## State contract
|
|
20
|
+
*
|
|
12
21
|
* Voice transport and session references are expected in `state.scratch`:
|
|
13
|
-
* - `voiceTransport`
|
|
14
|
-
* - `voiceTransport._voiceSession`
|
|
22
|
+
* - `voiceTransport` -- the bidirectional transport EventEmitter (emits `close` / `disconnected`).
|
|
23
|
+
* - `voiceTransport._voiceSession` -- the voice pipeline session EventEmitter that fires
|
|
15
24
|
* `final_transcript`, `turn_complete`, `speech_start`, and `barge_in` events.
|
|
16
25
|
*
|
|
17
26
|
* Checkpoint data is stored in `state.scratch[nodeId]` as a {@link VoiceNodeCheckpoint},
|
|
18
27
|
* enabling the graph runtime to resume a voice session from the exact turn index where
|
|
19
28
|
* it was previously suspended.
|
|
29
|
+
*
|
|
30
|
+
* See `VoiceTurnCollector` for transcript buffering and event bridging.
|
|
31
|
+
* See `VoiceTransportAdapter` for how graph I/O is wrapped at the transport level.
|
|
32
|
+
* @see {@link VoiceInterruptError} for the structured barge-in error type.
|
|
20
33
|
*/
|
|
21
34
|
import { EventEmitter } from 'events';
|
|
22
35
|
import { VoiceTurnCollector } from './VoiceTurnCollector.js';
|
|
@@ -29,25 +42,33 @@ import { VoiceInterruptError } from '../../voice-pipeline/VoiceInterruptError.js
|
|
|
29
42
|
* multiple exit conditions to determine when the node is done.
|
|
30
43
|
*
|
|
31
44
|
* Exit conditions are evaluated concurrently via a single `Promise` race:
|
|
32
|
-
* - **Hangup**
|
|
33
|
-
* - **Turns exhausted**
|
|
45
|
+
* - **Hangup** -- transport emits `close` or `disconnected`.
|
|
46
|
+
* - **Turns exhausted** -- session emits `turn_complete` and the collector's count
|
|
34
47
|
* reaches `config.maxTurns`.
|
|
35
|
-
* - **Keyword**
|
|
36
|
-
* - **Silence timeout**
|
|
37
|
-
* - **Abort/barge-in**
|
|
48
|
+
* - **Keyword** -- a `final_transcript` event contains one of `config.exitKeywords`.
|
|
49
|
+
* - **Silence timeout** -- no speech activity for 30 seconds (when `exitOn: 'silence-timeout'`).
|
|
50
|
+
* - **Abort/barge-in** -- the internal `AbortController` is signalled, either by a
|
|
38
51
|
* parent abort signal or a `VoiceInterruptError`.
|
|
39
52
|
*
|
|
40
53
|
* @example
|
|
41
54
|
* ```ts
|
|
42
55
|
* const executor = new VoiceNodeExecutor((event) => emitter.emit(event));
|
|
43
56
|
* const result = await executor.execute(voiceNode, graphState);
|
|
44
|
-
* console.log(result.output.exitReason);
|
|
57
|
+
* console.log(result.output.exitReason);
|
|
58
|
+
* // 'turns-exhausted' | 'hangup' | 'keyword:goodbye' | 'silence-timeout' | 'interrupted'
|
|
45
59
|
* ```
|
|
60
|
+
*
|
|
61
|
+
* See `VoiceTurnCollector` for session subscription and transcript buffering.
|
|
62
|
+
* @see {@link VoiceInterruptError} -- structured barge-in error that triggers the `interrupted` path.
|
|
46
63
|
*/
|
|
47
64
|
export class VoiceNodeExecutor {
|
|
48
65
|
/**
|
|
66
|
+
* Creates a new VoiceNodeExecutor.
|
|
67
|
+
*
|
|
49
68
|
* @param eventSink - Callback invoked synchronously for every emitted {@link GraphEvent}.
|
|
50
|
-
* Typically bound to the graph runtime's event emitter
|
|
69
|
+
* Typically bound to the graph runtime's event emitter so that
|
|
70
|
+
* voice lifecycle events (`voice_session`, `voice_transcript`, etc.)
|
|
71
|
+
* are visible to all graph event consumers.
|
|
51
72
|
*/
|
|
52
73
|
constructor(eventSink) {
|
|
53
74
|
this.eventSink = eventSink;
|
|
@@ -56,49 +77,87 @@ export class VoiceNodeExecutor {
|
|
|
56
77
|
* Execute a voice node. Matches the standard 2-arg `execute(node, state)` signature
|
|
57
78
|
* used throughout the orchestration runtime.
|
|
58
79
|
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
80
|
+
* ## Lifecycle
|
|
81
|
+
*
|
|
82
|
+
* 1. Validates that `node.executorConfig.type` is `'voice'`.
|
|
83
|
+
* 2. Creates an internal `AbortController` for barge-in, wiring it to any parent
|
|
84
|
+
* abort signal in `state.scratch.abortSignal`.
|
|
85
|
+
* 3. Extracts the `voiceTransport` from `state.scratch` (must be pre-placed by
|
|
86
|
+
* the graph runtime or `VoiceTransportAdapter`).
|
|
87
|
+
* 4. Checks for a {@link VoiceNodeCheckpoint} to resume from.
|
|
88
|
+
* 5. Emits a `voice_session` started event.
|
|
89
|
+
* 6. Wires a `VoiceTurnCollector` onto the session and races exit conditions.
|
|
90
|
+
* 7. Resolves the exit reason to a route target via the node's edge map.
|
|
91
|
+
* 8. Returns a {@link NodeExecutionResult} with transcript, exit reason, checkpoint,
|
|
92
|
+
* and optional route target.
|
|
62
93
|
*
|
|
63
94
|
* @param node - Immutable voice node descriptor from the compiled graph IR.
|
|
95
|
+
* Must have `executorConfig.type === 'voice'`.
|
|
64
96
|
* @param state - Current (partial) graph state threaded from the runtime.
|
|
97
|
+
* Must contain `scratch.voiceTransport` for the voice session.
|
|
65
98
|
* @returns A {@link NodeExecutionResult} with transcript, exit reason, and optional route target.
|
|
99
|
+
* On success, `output` contains `{ transcript, turns, exitReason, lastSpeaker, interruptedText }`.
|
|
100
|
+
* `scratchUpdate` carries the {@link VoiceNodeCheckpoint} keyed by node id.
|
|
101
|
+
* @throws Never -- all errors are caught and returned as `{ success: false, error }`.
|
|
102
|
+
* {@link VoiceInterruptError} is caught and mapped to `exitReason: 'interrupted'`.
|
|
103
|
+
*
|
|
104
|
+
* @see {@link raceExitConditions} for the concurrent exit condition implementation.
|
|
66
105
|
*/
|
|
67
106
|
async execute(node, state) {
|
|
68
107
|
const config = node.executorConfig;
|
|
108
|
+
// Guard: only voice nodes should reach this executor.
|
|
69
109
|
if (config.type !== 'voice') {
|
|
70
110
|
return { success: false, error: 'VoiceNodeExecutor received non-voice node' };
|
|
71
111
|
}
|
|
72
112
|
const voiceConfig = config.voiceConfig;
|
|
73
|
-
//
|
|
113
|
+
// Create an internal AbortController so barge-in events or parent cancellation
|
|
114
|
+
// can terminate the exit condition race without waiting for a session event.
|
|
74
115
|
const controller = new AbortController();
|
|
75
|
-
// If a parent abort signal exists in scratch
|
|
116
|
+
// If a parent abort signal exists in scratch (e.g. from a graph-level timeout
|
|
117
|
+
// or manual cancellation), forward its abort to our internal controller so that
|
|
118
|
+
// the voice session is cancelled when the parent cancels.
|
|
76
119
|
const parentSignal = state?.scratch?.abortSignal;
|
|
77
120
|
if (parentSignal) {
|
|
78
|
-
parentSignal.addEventListener('abort', () => controller.abort(parentSignal.reason), {
|
|
121
|
+
parentSignal.addEventListener('abort', () => controller.abort(parentSignal.reason), {
|
|
122
|
+
once: true,
|
|
123
|
+
});
|
|
79
124
|
}
|
|
80
|
-
//
|
|
125
|
+
// The voice transport must be pre-placed in state.scratch by the graph runtime
|
|
126
|
+
// or VoiceTransportAdapter before executing a voice node. Without it we cannot
|
|
127
|
+
// receive session events or detect hangup.
|
|
81
128
|
const transport = state?.scratch?.voiceTransport;
|
|
82
129
|
if (!transport) {
|
|
83
130
|
return { success: false, error: 'Voice node requires voiceTransport in state.scratch' };
|
|
84
131
|
}
|
|
85
|
-
// Check for checkpoint restore
|
|
132
|
+
// Check for checkpoint restore -- if the node was previously executed and the
|
|
133
|
+
// graph was suspended/restored, the prior turn count is in the checkpoint.
|
|
134
|
+
// This lets the turn counter continue from where it left off rather than
|
|
135
|
+
// resetting to zero, which would cause premature exits on maxTurns.
|
|
86
136
|
const checkpoint = state?.scratch?.[node.id];
|
|
87
137
|
const initialTurnCount = checkpoint?.turnIndex ?? 0;
|
|
88
|
-
//
|
|
138
|
+
// Signal that the voice session is now active for this node.
|
|
89
139
|
this.eventSink({ type: 'voice_session', nodeId: node.id, action: 'started' });
|
|
90
140
|
try {
|
|
91
141
|
// The voice session EventEmitter is expected on transport._voiceSession.
|
|
92
|
-
// In production this is the VoicePipelineSession; in tests it can be a
|
|
142
|
+
// In production this is the VoicePipelineSession; in tests it can be a
|
|
143
|
+
// plain EventEmitter. Fallback to a fresh emitter avoids null dereferences
|
|
144
|
+
// when the transport doesn't have an attached session.
|
|
93
145
|
const session = transport._voiceSession ?? new EventEmitter();
|
|
94
|
-
// Create the turn collector
|
|
146
|
+
// Create the turn collector -- it subscribes to session events (interim_transcript,
|
|
147
|
+
// final_transcript, turn_complete, barge_in) and bridges them into GraphEvents
|
|
148
|
+
// while maintaining a running transcript buffer and turn counter.
|
|
95
149
|
const collector = new VoiceTurnCollector(session, this.eventSink, node.id, initialTurnCount);
|
|
96
|
-
// Race all exit conditions against each other.
|
|
150
|
+
// Race all exit conditions against each other. The first condition to fire
|
|
151
|
+
// determines exitReason and ends the voice node.
|
|
97
152
|
const result = await this.raceExitConditions(session, collector, voiceConfig, controller, transport);
|
|
98
|
-
//
|
|
153
|
+
// Map the exitReason string to a target node id using the edge map.
|
|
154
|
+
// This is how voice nodes implement conditional routing: different exit
|
|
155
|
+
// conditions route to different downstream nodes.
|
|
99
156
|
const edges = node.edges ?? {};
|
|
100
157
|
const routeTarget = typeof edges === 'object' ? edges[result.reason] : undefined;
|
|
101
|
-
// Build checkpoint
|
|
158
|
+
// Build the checkpoint so the runtime can persist and restore later.
|
|
159
|
+
// This is written into scratchUpdate and merged back into state.scratch
|
|
160
|
+
// by the graph runtime after execution completes.
|
|
102
161
|
const voiceCheckpoint = {
|
|
103
162
|
turnIndex: collector.getTurnCount(),
|
|
104
163
|
transcript: collector.getTranscript(),
|
|
@@ -106,8 +165,13 @@ export class VoiceNodeExecutor {
|
|
|
106
165
|
speakerMap: {},
|
|
107
166
|
sessionConfig: voiceConfig,
|
|
108
167
|
};
|
|
109
|
-
//
|
|
110
|
-
this.eventSink({
|
|
168
|
+
// Signal that the voice session has ended for this node.
|
|
169
|
+
this.eventSink({
|
|
170
|
+
type: 'voice_session',
|
|
171
|
+
nodeId: node.id,
|
|
172
|
+
action: 'ended',
|
|
173
|
+
exitReason: result.reason,
|
|
174
|
+
});
|
|
111
175
|
return {
|
|
112
176
|
success: true,
|
|
113
177
|
output: {
|
|
@@ -122,12 +186,19 @@ export class VoiceNodeExecutor {
|
|
|
122
186
|
};
|
|
123
187
|
}
|
|
124
188
|
catch (err) {
|
|
125
|
-
// VoiceInterruptError is a structured barge-in
|
|
126
|
-
//
|
|
189
|
+
// VoiceInterruptError is a structured barge-in -- the user spoke over the
|
|
190
|
+
// agent. This is not an error condition; it's a valid exit path that the
|
|
191
|
+
// graph should be able to route on. We convert it to a successful result
|
|
192
|
+
// with exitReason: 'interrupted' so edge routing works as expected.
|
|
127
193
|
if (err instanceof VoiceInterruptError) {
|
|
128
194
|
const edges = node.edges ?? {};
|
|
129
195
|
const routeTarget = edges['interrupted'];
|
|
130
|
-
this.eventSink({
|
|
196
|
+
this.eventSink({
|
|
197
|
+
type: 'voice_session',
|
|
198
|
+
nodeId: node.id,
|
|
199
|
+
action: 'ended',
|
|
200
|
+
exitReason: 'interrupted',
|
|
201
|
+
});
|
|
131
202
|
return {
|
|
132
203
|
success: true,
|
|
133
204
|
output: {
|
|
@@ -140,8 +211,14 @@ export class VoiceNodeExecutor {
|
|
|
140
211
|
routeTarget,
|
|
141
212
|
};
|
|
142
213
|
}
|
|
143
|
-
// Unhandled error
|
|
144
|
-
|
|
214
|
+
// Unhandled error -- surface as a failed result so the graph runtime can
|
|
215
|
+
// decide whether to retry, reroute, or halt.
|
|
216
|
+
this.eventSink({
|
|
217
|
+
type: 'voice_session',
|
|
218
|
+
nodeId: node.id,
|
|
219
|
+
action: 'ended',
|
|
220
|
+
exitReason: 'error',
|
|
221
|
+
});
|
|
145
222
|
return { success: false, error: String(err) };
|
|
146
223
|
}
|
|
147
224
|
}
|
|
@@ -152,25 +229,42 @@ export class VoiceNodeExecutor {
|
|
|
152
229
|
* Races all configured exit conditions against each other and resolves with
|
|
153
230
|
* the first one that fires.
|
|
154
231
|
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
232
|
+
* ## How it works
|
|
233
|
+
*
|
|
234
|
+
* Each exit condition is wired as a listener on either the `session` or
|
|
235
|
+
* `transport` EventEmitter. All listeners call a shared `settleWith()` helper
|
|
236
|
+
* that resolves the outer Promise exactly once (guarded by a `settled` boolean).
|
|
237
|
+
*
|
|
238
|
+
* The `AbortController` signal is also monitored -- if it fires with a
|
|
239
|
+
* {@link VoiceInterruptError} the Promise rejects (handled by the caller's
|
|
240
|
+
* catch block), otherwise it resolves with `{ reason: 'interrupted' }`.
|
|
241
|
+
*
|
|
242
|
+
* ## Why a Promise race instead of a state machine?
|
|
243
|
+
*
|
|
244
|
+
* The exit conditions are independent and asynchronous. A Promise-based race
|
|
245
|
+
* avoids complex state transitions and lets each condition be a simple
|
|
246
|
+
* event listener. The `settled` guard handles the only tricky case: two
|
|
247
|
+
* conditions firing in the same microtask.
|
|
159
248
|
*
|
|
160
|
-
* @param session - Voice pipeline session EventEmitter
|
|
161
|
-
*
|
|
162
|
-
* @param
|
|
249
|
+
* @param session - Voice pipeline session EventEmitter that fires
|
|
250
|
+
* `turn_complete`, `final_transcript`, `speech_start`, `barge_in`.
|
|
251
|
+
* @param collector - Active turn collector tracking turn count and transcript.
|
|
252
|
+
* @param config - Voice node configuration with exit settings (`maxTurns`,
|
|
253
|
+
* `exitOn`, `exitKeywords`).
|
|
163
254
|
* @param controller - Internal AbortController for barge-in signalling.
|
|
164
|
-
* @param transport - Bidirectional transport EventEmitter
|
|
255
|
+
* @param transport - Bidirectional transport EventEmitter that fires `close`
|
|
256
|
+
* and `disconnected` on hangup.
|
|
165
257
|
* @returns The winning exit condition's reason string and optional interrupted text.
|
|
166
258
|
*/
|
|
167
259
|
async raceExitConditions(session, collector, config, controller, transport) {
|
|
168
260
|
return new Promise((resolve, reject) => {
|
|
169
|
-
/**
|
|
261
|
+
/** Prevents double-resolution when multiple conditions fire simultaneously. */
|
|
170
262
|
let settled = false;
|
|
171
263
|
/**
|
|
172
264
|
* Settle the promise with a resolve value, guarding against double-settle.
|
|
173
|
-
*
|
|
265
|
+
* Every exit condition calls this instead of `resolve()` directly.
|
|
266
|
+
*
|
|
267
|
+
* @param result - The exit condition result containing the reason string.
|
|
174
268
|
*/
|
|
175
269
|
const settleWith = (result) => {
|
|
176
270
|
if (settled)
|
|
@@ -179,10 +273,16 @@ export class VoiceNodeExecutor {
|
|
|
179
273
|
resolve(result);
|
|
180
274
|
};
|
|
181
275
|
// -- Hangup: transport disconnects -----------------------------------
|
|
276
|
+
// Both `close` and `disconnected` events indicate the transport is gone.
|
|
277
|
+
// We listen for both because different transport implementations emit
|
|
278
|
+
// different event names (WebSocket uses `close`, telephony uses `disconnected`).
|
|
182
279
|
const onDisconnect = () => settleWith({ reason: 'hangup' });
|
|
183
280
|
transport.on('close', onDisconnect);
|
|
184
281
|
transport.on('disconnected', onDisconnect);
|
|
185
282
|
// -- Turns exhausted -------------------------------------------------
|
|
283
|
+
// Only armed when maxTurns is a positive number. We check the collector's
|
|
284
|
+
// count (not a local counter) because the collector may have been seeded
|
|
285
|
+
// with an initialTurnCount from a checkpoint restore.
|
|
186
286
|
if (config.maxTurns && config.maxTurns > 0) {
|
|
187
287
|
session.on('turn_complete', () => {
|
|
188
288
|
if (collector.getTurnCount() >= config.maxTurns) {
|
|
@@ -191,6 +291,9 @@ export class VoiceNodeExecutor {
|
|
|
191
291
|
});
|
|
192
292
|
}
|
|
193
293
|
// -- Keyword detection -----------------------------------------------
|
|
294
|
+
// Only armed when exitOn is 'keyword' and at least one keyword is provided.
|
|
295
|
+
// The keyword check is case-insensitive and uses substring matching so that
|
|
296
|
+
// "goodbye" matches "okay goodbye then".
|
|
194
297
|
if (config.exitOn === 'keyword' && config.exitKeywords?.length) {
|
|
195
298
|
session.on('final_transcript', (evt) => {
|
|
196
299
|
const text = (evt.text ?? '').toLowerCase();
|
|
@@ -203,20 +306,29 @@ export class VoiceNodeExecutor {
|
|
|
203
306
|
});
|
|
204
307
|
}
|
|
205
308
|
// -- Silence timeout (default 30 s) ----------------------------------
|
|
309
|
+
// Only armed when exitOn is 'silence-timeout'. A watchdog timer is reset
|
|
310
|
+
// on every speech activity event. If the timer fires without being reset,
|
|
311
|
+
// the user has been silent for too long and the session ends.
|
|
206
312
|
if (config.exitOn === 'silence-timeout') {
|
|
207
313
|
let silenceTimer = null;
|
|
208
314
|
const timeoutMs = 30000;
|
|
209
|
-
/** Reset the silence watchdog
|
|
315
|
+
/** Reset the silence watchdog -- called on any speech activity. */
|
|
210
316
|
const resetTimer = () => {
|
|
211
317
|
if (silenceTimer)
|
|
212
318
|
clearTimeout(silenceTimer);
|
|
213
319
|
silenceTimer = setTimeout(() => settleWith({ reason: 'silence-timeout' }), timeoutMs);
|
|
214
320
|
};
|
|
321
|
+
// Reset on both speech_start (user began talking) and turn_complete
|
|
322
|
+
// (user finished a turn) to cover all speech activity signals.
|
|
215
323
|
session.on('speech_start', resetTimer);
|
|
216
324
|
session.on('turn_complete', resetTimer);
|
|
217
325
|
resetTimer(); // Start the initial timer immediately.
|
|
218
326
|
}
|
|
219
327
|
// -- Abort signal (barge-in or parent cancellation) ------------------
|
|
328
|
+
// If the abort reason is a VoiceInterruptError, we reject the Promise
|
|
329
|
+
// (the caller's catch block converts it to exitReason: 'interrupted').
|
|
330
|
+
// For any other abort reason (e.g. parent timeout), we resolve normally
|
|
331
|
+
// with reason: 'interrupted'.
|
|
220
332
|
controller.signal.addEventListener('abort', () => {
|
|
221
333
|
const reason = controller.signal.reason;
|
|
222
334
|
if (reason instanceof VoiceInterruptError) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VoiceNodeExecutor.js","sourceRoot":"","sources":["../../../src/orchestration/runtime/VoiceNodeExecutor.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"VoiceNodeExecutor.js","sourceRoot":"","sources":["../../../src/orchestration/runtime/VoiceNodeExecutor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAItC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;AAqDlF,8EAA8E;AAC9E,oBAAoB;AACpB,8EAA8E;AAE9E;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,OAAO,iBAAiB;IAC5B;;;;;;;OAOG;IACH,YAA6B,SAAsC;QAAtC,cAAS,GAAT,SAAS,CAA6B;IAAG,CAAC;IAEvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,KAAK,CAAC,OAAO,CAAC,IAAe,EAAE,KAA0B;QACvD,MAAM,MAAM,GAAG,IAAI,CAAC,cAAc,CAAC;QAEnC,sDAAsD;QACtD,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC5B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,2CAA2C,EAAE,CAAC;QAChF,CAAC;QAED,MAAM,WAAW,GAAG,MAAM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,CAAC,CAAC;gBACjB,CAAC;qBAAM,CAAC;oBACN,UAAU,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC;gBACxC,CAAC;YACH,CAAC,EACD,EAAE,IAAI,EAAE,IAAI,EAAE,CACf,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -3,16 +3,28 @@
|
|
|
3
3
|
* @description Bridges graph I/O to the voice pipeline when a workflow runs in
|
|
4
4
|
* voice transport mode.
|
|
5
5
|
*
|
|
6
|
+
* ## Purpose
|
|
7
|
+
*
|
|
6
8
|
* `VoiceTransportAdapter` wraps a graph's input/output cycle so that:
|
|
7
9
|
* - **Node input** is obtained by waiting for the user's next speech turn
|
|
8
10
|
* (`waitForUserTurn()` on the underlying `VoicePipelineOrchestrator`).
|
|
9
11
|
* - **Node output** is delivered to the TTS engine (`pushToTTS()` on the
|
|
10
12
|
* underlying `VoicePipelineOrchestrator`).
|
|
11
13
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
14
|
+
* ## `getNodeInput` / `deliverNodeOutput` contract
|
|
15
|
+
*
|
|
16
|
+
* - `getNodeInput(nodeId)` blocks until the transport emits a `turn_complete`
|
|
17
|
+
* event, then resolves with the transcript string. It also emits a
|
|
18
|
+
* `voice_turn_complete` GraphEvent so the runtime event bus stays in sync.
|
|
19
|
+
* - `deliverNodeOutput(nodeId, output)` sends text (or a streaming async
|
|
20
|
+
* iterable) to TTS and emits a `voice_audio` outbound GraphEvent.
|
|
21
|
+
* - Both methods throw if called before `init()`.
|
|
22
|
+
*
|
|
23
|
+
* ## Lazy initialisation
|
|
24
|
+
*
|
|
25
|
+
* The adapter is lazy -- it does not create a `VoicePipelineOrchestrator` until
|
|
26
|
+
* `init()` is called. The pipeline reference is `any` typed to avoid a hard
|
|
27
|
+
* import cycle with the voice subsystem; callers that want stronger types may cast.
|
|
16
28
|
*
|
|
17
29
|
* @example
|
|
18
30
|
* ```typescript
|
|
@@ -27,6 +39,9 @@
|
|
|
27
39
|
* await adapter.deliverNodeOutput('greet', 'Hello, how can I help you today?');
|
|
28
40
|
* await adapter.dispose();
|
|
29
41
|
* ```
|
|
42
|
+
*
|
|
43
|
+
* See `VoiceNodeExecutor` for the executor that consumes this adapter's events.
|
|
44
|
+
* @see {@link VoiceTransportConfig} -- configuration knobs forwarded to the pipeline.
|
|
30
45
|
*/
|
|
31
46
|
import type { GraphState } from '../ir/types.js';
|
|
32
47
|
import type { GraphEvent } from '../events/GraphEvent.js';
|
|
@@ -34,8 +49,21 @@ import type { GraphEvent } from '../events/GraphEvent.js';
|
|
|
34
49
|
* Configuration knobs forwarded to the voice pipeline when the adapter
|
|
35
50
|
* initialises its internal `VoicePipelineOrchestrator` instance.
|
|
36
51
|
*
|
|
37
|
-
* All fields are optional
|
|
38
|
-
* sensible library defaults.
|
|
52
|
+
* All fields are optional -- defaults are resolved from agent.config.json or
|
|
53
|
+
* sensible library defaults within the voice pipeline itself.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* const config: VoiceTransportConfig = {
|
|
58
|
+
* stt: 'deepgram',
|
|
59
|
+
* tts: 'elevenlabs',
|
|
60
|
+
* voice: 'rachel',
|
|
61
|
+
* bargeIn: 'hard-cut',
|
|
62
|
+
* endpointing: 'semantic',
|
|
63
|
+
* diarization: true,
|
|
64
|
+
* language: 'en-US',
|
|
65
|
+
* };
|
|
66
|
+
* ```
|
|
39
67
|
*/
|
|
40
68
|
export interface VoiceTransportConfig {
|
|
41
69
|
/** STT provider identifier (e.g. `'deepgram'`, `'openai'`). */
|
|
@@ -46,16 +74,16 @@ export interface VoiceTransportConfig {
|
|
|
46
74
|
voice?: string;
|
|
47
75
|
/**
|
|
48
76
|
* Barge-in handling strategy.
|
|
49
|
-
* - `'hard-cut'`
|
|
50
|
-
* - `'soft-fade'`
|
|
51
|
-
* - `'disabled'`
|
|
77
|
+
* - `'hard-cut'` -- interrupt TTS immediately when speech is detected.
|
|
78
|
+
* - `'soft-fade'` -- ramp TTS volume down before cutting.
|
|
79
|
+
* - `'disabled'` -- ignore user speech while the agent is speaking.
|
|
52
80
|
*/
|
|
53
81
|
bargeIn?: string;
|
|
54
82
|
/**
|
|
55
83
|
* Endpoint detection mode used to decide when the user has finished speaking.
|
|
56
|
-
* - `'acoustic'`
|
|
57
|
-
* - `'heuristic'`
|
|
58
|
-
* - `'semantic'`
|
|
84
|
+
* - `'acoustic'` -- energy/VAD-based detection.
|
|
85
|
+
* - `'heuristic'` -- punctuation + silence heuristics.
|
|
86
|
+
* - `'semantic'` -- LLM-assisted turn boundary detection.
|
|
59
87
|
*/
|
|
60
88
|
endpointing?: string;
|
|
61
89
|
/** Whether to enable speaker diarization for multi-speaker sessions. */
|
|
@@ -66,13 +94,26 @@ export interface VoiceTransportConfig {
|
|
|
66
94
|
/**
|
|
67
95
|
* Adapts a compiled graph's I/O cycle to the real-time voice pipeline.
|
|
68
96
|
*
|
|
69
|
-
* Lifecycle
|
|
97
|
+
* ## Lifecycle
|
|
98
|
+
*
|
|
70
99
|
* 1. Construct with {@link VoiceTransportConfig}, an `IStreamTransport`, and an
|
|
71
100
|
* event sink callback.
|
|
72
|
-
* 2. Call `init()` once before the graph starts running.
|
|
101
|
+
* 2. Call `init()` once before the graph starts running. This injects the
|
|
102
|
+
* transport into `state.scratch.voiceTransport` and emits a `voice_session`
|
|
103
|
+
* started event.
|
|
73
104
|
* 3. Use `getNodeInput()` to obtain the user's transcribed speech for a node.
|
|
105
|
+
* Blocks until the transport emits a `turn_complete` event.
|
|
74
106
|
* 4. Use `deliverNodeOutput()` to send the node's response to TTS.
|
|
75
107
|
* 5. Call `dispose()` to clean up resources when the session ends.
|
|
108
|
+
*
|
|
109
|
+
* ## Error handling
|
|
110
|
+
*
|
|
111
|
+
* Both `getNodeInput()` and `deliverNodeOutput()` throw `Error` if called
|
|
112
|
+
* before `init()`. After `dispose()`, the adapter is marked as uninitialised
|
|
113
|
+
* so subsequent calls also throw.
|
|
114
|
+
*
|
|
115
|
+
* @see {@link VoiceTransportConfig} -- the config shape forwarded to the pipeline.
|
|
116
|
+
* See `VoiceNodeExecutor` for the executor that interacts with the transport.
|
|
76
117
|
*/
|
|
77
118
|
export declare class VoiceTransportAdapter {
|
|
78
119
|
private readonly config;
|
|
@@ -84,24 +125,35 @@ export declare class VoiceTransportAdapter {
|
|
|
84
125
|
* In a full implementation this would be `VoicePipelineOrchestrator | null`.
|
|
85
126
|
*/
|
|
86
127
|
private pipeline;
|
|
87
|
-
/**
|
|
128
|
+
/**
|
|
129
|
+
* Tracks whether `init()` has been called successfully.
|
|
130
|
+
* Set to `false` by `dispose()` to prevent use-after-teardown.
|
|
131
|
+
*/
|
|
88
132
|
private initialized;
|
|
89
133
|
/**
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* @param
|
|
134
|
+
* Creates a new VoiceTransportAdapter.
|
|
135
|
+
*
|
|
136
|
+
* @param config - Voice pipeline configuration knobs. Forwarded to the
|
|
137
|
+
* pipeline when it is initialised.
|
|
138
|
+
* @param transport - Bidirectional audio/control stream transport
|
|
139
|
+
* (`IStreamTransport`). Must be an EventEmitter that
|
|
140
|
+
* emits `turn_complete` events for `getNodeInput()`.
|
|
141
|
+
* @param eventSink - Callback receiving all `GraphEvent` values emitted by
|
|
142
|
+
* this adapter. Must not throw.
|
|
93
143
|
*/
|
|
94
144
|
constructor(config: VoiceTransportConfig, transport: any, // IStreamTransport
|
|
95
145
|
eventSink: (event: GraphEvent) => void);
|
|
96
146
|
/**
|
|
97
147
|
* Initialise the adapter.
|
|
98
148
|
*
|
|
99
|
-
* Injects the `IStreamTransport` instance into `state.scratch.voiceTransport`
|
|
100
|
-
* that graph nodes
|
|
101
|
-
*
|
|
149
|
+
* Injects the `IStreamTransport` instance into `state.scratch.voiceTransport`
|
|
150
|
+
* so that voice graph nodes (specifically `VoiceNodeExecutor`) can access
|
|
151
|
+
* the transport for session event subscription. Then emits a `voice_session`
|
|
152
|
+
* started event to signal that the voice session is live.
|
|
102
153
|
*
|
|
103
|
-
* Must be called exactly once before
|
|
104
|
-
*
|
|
154
|
+
* Must be called exactly once before `getNodeInput()` or
|
|
155
|
+
* `deliverNodeOutput()`. Calling `init()` multiple times is safe but
|
|
156
|
+
* redundant -- the transport reference is simply overwritten.
|
|
105
157
|
*
|
|
106
158
|
* @param state - Mutable `GraphState` (or partial) for the current run.
|
|
107
159
|
* `state.scratch` is created lazily if absent.
|
|
@@ -111,39 +163,46 @@ export declare class VoiceTransportAdapter {
|
|
|
111
163
|
* Wait for the user's next speech turn and return the transcript text.
|
|
112
164
|
*
|
|
113
165
|
* In a full production implementation this delegates to
|
|
114
|
-
* `VoicePipelineOrchestrator.waitForUserTurn()`.
|
|
166
|
+
* `VoicePipelineOrchestrator.waitForUserTurn()`. In the current implementation
|
|
115
167
|
* it listens for a single `'turn_complete'` event from the underlying transport
|
|
116
168
|
* and resolves with the transcript text.
|
|
117
169
|
*
|
|
118
170
|
* Also emits a {@link GraphEvent} of type `voice_turn_complete` so that the
|
|
119
|
-
* runtime event bus stays in sync.
|
|
171
|
+
* runtime event bus stays in sync with the transport-level turn lifecycle.
|
|
120
172
|
*
|
|
121
|
-
* @param nodeId - The id of the graph node requesting input; used to tag the
|
|
173
|
+
* @param nodeId - The id of the graph node requesting input; used to tag the
|
|
174
|
+
* emitted event for downstream filtering.
|
|
122
175
|
* @returns Resolved transcript string from the user's speech turn.
|
|
123
|
-
* @throws {Error} If called before `init()`.
|
|
176
|
+
* @throws {Error} If called before `init()` or after `dispose()`.
|
|
124
177
|
*/
|
|
125
178
|
getNodeInput(nodeId: string): Promise<string>;
|
|
126
179
|
/**
|
|
127
180
|
* Deliver a node's text output to the TTS engine.
|
|
128
181
|
*
|
|
129
182
|
* Accepts either a plain `string` or an `AsyncIterable<string>` of token
|
|
130
|
-
* chunks (e.g. a streaming LLM response).
|
|
183
|
+
* chunks (e.g. a streaming LLM response). In a full production implementation
|
|
131
184
|
* this delegates to `VoicePipelineOrchestrator.pushToTTS(output)`.
|
|
132
185
|
*
|
|
133
186
|
* Emits a {@link GraphEvent} of type `voice_audio` (direction `'outbound'`)
|
|
134
187
|
* so that the runtime event bus records the TTS delivery.
|
|
135
188
|
*
|
|
136
|
-
* @param nodeId - The id of the graph node delivering the output
|
|
137
|
-
*
|
|
138
|
-
* @
|
|
189
|
+
* @param nodeId - The id of the graph node delivering the output; tags the
|
|
190
|
+
* emitted event for downstream filtering.
|
|
191
|
+
* @param _output - Text or async token stream to synthesise as speech.
|
|
192
|
+
* The underscore prefix indicates it is not yet consumed
|
|
193
|
+
* in the v1 stub implementation.
|
|
194
|
+
* @throws {Error} If called before `init()` or after `dispose()`.
|
|
139
195
|
*/
|
|
140
196
|
deliverNodeOutput(nodeId: string, _output: string | AsyncIterable<string>): Promise<void>;
|
|
141
197
|
/**
|
|
142
198
|
* Handle a user barge-in at the transport level.
|
|
143
199
|
*
|
|
144
200
|
* Should be called by the runtime or transport layer when the user starts
|
|
145
|
-
* speaking while the agent is mid-utterance.
|
|
146
|
-
* so that graph event consumers can react (e.g. cancel pending tool calls
|
|
201
|
+
* speaking while the agent is mid-utterance. Emits a `voice_barge_in` event
|
|
202
|
+
* so that graph event consumers can react (e.g. cancel pending tool calls,
|
|
203
|
+
* stop TTS playback, or reroute the graph).
|
|
204
|
+
*
|
|
205
|
+
* @see {@link VoiceInterruptError} -- the structured error used inside the graph executor.
|
|
147
206
|
*/
|
|
148
207
|
handleBargeIn(): void;
|
|
149
208
|
/**
|
|
@@ -151,6 +210,9 @@ export declare class VoiceTransportAdapter {
|
|
|
151
210
|
*
|
|
152
211
|
* Marks the adapter as uninitialised so subsequent calls to `getNodeInput()`
|
|
153
212
|
* or `deliverNodeOutput()` will throw, preventing accidental use after teardown.
|
|
213
|
+
*
|
|
214
|
+
* This method is idempotent -- calling it multiple times simply re-emits the
|
|
215
|
+
* ended event and re-sets the initialised flag.
|
|
154
216
|
*/
|
|
155
217
|
dispose(): Promise<void>;
|
|
156
218
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VoiceTransportAdapter.d.ts","sourceRoot":"","sources":["../../../src/orchestration/runtime/VoiceTransportAdapter.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"VoiceTransportAdapter.d.ts","sourceRoot":"","sources":["../../../src/orchestration/runtime/VoiceTransportAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAM1D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,oBAAoB;IACnC,+DAA+D;IAC/D,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,iEAAiE;IACjE,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,0DAA0D;IAC1D,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,wEAAwE;IACxE,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAMD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,qBAAqB;IA0B9B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,SAAS;IA3B5B;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAoB;IAEpC;;;OAGG;IACH,OAAO,CAAC,WAAW,CAAS;IAE5B;;;;;;;;;;OAUG;gBAEgB,MAAM,EAAE,oBAAoB,EAC5B,SAAS,EAA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