@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
|
@@ -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
|
// ---------------------------------------------------------------------------
|
|
32
47
|
// VoiceTransportAdapter
|
|
@@ -34,19 +49,38 @@
|
|
|
34
49
|
/**
|
|
35
50
|
* Adapts a compiled graph's I/O cycle to the real-time voice pipeline.
|
|
36
51
|
*
|
|
37
|
-
* Lifecycle
|
|
52
|
+
* ## Lifecycle
|
|
53
|
+
*
|
|
38
54
|
* 1. Construct with {@link VoiceTransportConfig}, an `IStreamTransport`, and an
|
|
39
55
|
* event sink callback.
|
|
40
|
-
* 2. Call `init()` once before the graph starts running.
|
|
56
|
+
* 2. Call `init()` once before the graph starts running. This injects the
|
|
57
|
+
* transport into `state.scratch.voiceTransport` and emits a `voice_session`
|
|
58
|
+
* started event.
|
|
41
59
|
* 3. Use `getNodeInput()` to obtain the user's transcribed speech for a node.
|
|
60
|
+
* Blocks until the transport emits a `turn_complete` event.
|
|
42
61
|
* 4. Use `deliverNodeOutput()` to send the node's response to TTS.
|
|
43
62
|
* 5. Call `dispose()` to clean up resources when the session ends.
|
|
63
|
+
*
|
|
64
|
+
* ## Error handling
|
|
65
|
+
*
|
|
66
|
+
* Both `getNodeInput()` and `deliverNodeOutput()` throw `Error` if called
|
|
67
|
+
* before `init()`. After `dispose()`, the adapter is marked as uninitialised
|
|
68
|
+
* so subsequent calls also throw.
|
|
69
|
+
*
|
|
70
|
+
* @see {@link VoiceTransportConfig} -- the config shape forwarded to the pipeline.
|
|
71
|
+
* See `VoiceNodeExecutor` for the executor that interacts with the transport.
|
|
44
72
|
*/
|
|
45
73
|
export class VoiceTransportAdapter {
|
|
46
74
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* @param
|
|
75
|
+
* Creates a new VoiceTransportAdapter.
|
|
76
|
+
*
|
|
77
|
+
* @param config - Voice pipeline configuration knobs. Forwarded to the
|
|
78
|
+
* pipeline when it is initialised.
|
|
79
|
+
* @param transport - Bidirectional audio/control stream transport
|
|
80
|
+
* (`IStreamTransport`). Must be an EventEmitter that
|
|
81
|
+
* emits `turn_complete` events for `getNodeInput()`.
|
|
82
|
+
* @param eventSink - Callback receiving all `GraphEvent` values emitted by
|
|
83
|
+
* this adapter. Must not throw.
|
|
50
84
|
*/
|
|
51
85
|
constructor(config, transport, // IStreamTransport
|
|
52
86
|
eventSink) {
|
|
@@ -59,7 +93,10 @@ export class VoiceTransportAdapter {
|
|
|
59
93
|
* In a full implementation this would be `VoicePipelineOrchestrator | null`.
|
|
60
94
|
*/
|
|
61
95
|
this.pipeline = null; // VoicePipelineOrchestrator (lazy)
|
|
62
|
-
/**
|
|
96
|
+
/**
|
|
97
|
+
* Tracks whether `init()` has been called successfully.
|
|
98
|
+
* Set to `false` by `dispose()` to prevent use-after-teardown.
|
|
99
|
+
*/
|
|
63
100
|
this.initialized = false;
|
|
64
101
|
}
|
|
65
102
|
// -------------------------------------------------------------------------
|
|
@@ -68,19 +105,22 @@ export class VoiceTransportAdapter {
|
|
|
68
105
|
/**
|
|
69
106
|
* Initialise the adapter.
|
|
70
107
|
*
|
|
71
|
-
* Injects the `IStreamTransport` instance into `state.scratch.voiceTransport`
|
|
72
|
-
* that graph nodes
|
|
73
|
-
*
|
|
108
|
+
* Injects the `IStreamTransport` instance into `state.scratch.voiceTransport`
|
|
109
|
+
* so that voice graph nodes (specifically `VoiceNodeExecutor`) can access
|
|
110
|
+
* the transport for session event subscription. Then emits a `voice_session`
|
|
111
|
+
* started event to signal that the voice session is live.
|
|
74
112
|
*
|
|
75
|
-
* Must be called exactly once before
|
|
76
|
-
*
|
|
113
|
+
* Must be called exactly once before `getNodeInput()` or
|
|
114
|
+
* `deliverNodeOutput()`. Calling `init()` multiple times is safe but
|
|
115
|
+
* redundant -- the transport reference is simply overwritten.
|
|
77
116
|
*
|
|
78
117
|
* @param state - Mutable `GraphState` (or partial) for the current run.
|
|
79
118
|
* `state.scratch` is created lazily if absent.
|
|
80
119
|
*/
|
|
81
120
|
async init(state) {
|
|
82
121
|
var _a;
|
|
83
|
-
// Lazily create the scratch bag if the caller passed a partial state
|
|
122
|
+
// Lazily create the scratch bag if the caller passed a partial state
|
|
123
|
+
// without a pre-existing scratch object.
|
|
84
124
|
const scratch = ((_a = state).scratch ?? (_a.scratch = {}));
|
|
85
125
|
scratch.voiceTransport = this.transport;
|
|
86
126
|
this.initialized = true;
|
|
@@ -94,25 +134,29 @@ export class VoiceTransportAdapter {
|
|
|
94
134
|
* Wait for the user's next speech turn and return the transcript text.
|
|
95
135
|
*
|
|
96
136
|
* In a full production implementation this delegates to
|
|
97
|
-
* `VoicePipelineOrchestrator.waitForUserTurn()`.
|
|
137
|
+
* `VoicePipelineOrchestrator.waitForUserTurn()`. In the current implementation
|
|
98
138
|
* it listens for a single `'turn_complete'` event from the underlying transport
|
|
99
139
|
* and resolves with the transcript text.
|
|
100
140
|
*
|
|
101
141
|
* Also emits a {@link GraphEvent} of type `voice_turn_complete` so that the
|
|
102
|
-
* runtime event bus stays in sync.
|
|
142
|
+
* runtime event bus stays in sync with the transport-level turn lifecycle.
|
|
103
143
|
*
|
|
104
|
-
* @param nodeId - The id of the graph node requesting input; used to tag the
|
|
144
|
+
* @param nodeId - The id of the graph node requesting input; used to tag the
|
|
145
|
+
* emitted event for downstream filtering.
|
|
105
146
|
* @returns Resolved transcript string from the user's speech turn.
|
|
106
|
-
* @throws {Error} If called before `init()`.
|
|
147
|
+
* @throws {Error} If called before `init()` or after `dispose()`.
|
|
107
148
|
*/
|
|
108
149
|
async getNodeInput(nodeId) {
|
|
109
150
|
if (!this.initialized) {
|
|
110
151
|
throw new Error('VoiceTransportAdapter not initialized');
|
|
111
152
|
}
|
|
112
|
-
// In
|
|
113
|
-
//
|
|
153
|
+
// In the full implementation this would delegate to:
|
|
154
|
+
// this.pipeline.waitForUserTurn()
|
|
155
|
+
// For now, listen directly to transport events for the next turn.
|
|
114
156
|
return new Promise((resolve) => {
|
|
115
157
|
this.transport.once('turn_complete', (evt) => {
|
|
158
|
+
// Accept both `transcript` and `text` fields for compatibility
|
|
159
|
+
// with different transport implementations.
|
|
116
160
|
const transcript = evt?.transcript ?? evt?.text ?? '';
|
|
117
161
|
this.eventSink({
|
|
118
162
|
type: 'voice_turn_complete',
|
|
@@ -129,21 +173,25 @@ export class VoiceTransportAdapter {
|
|
|
129
173
|
* Deliver a node's text output to the TTS engine.
|
|
130
174
|
*
|
|
131
175
|
* Accepts either a plain `string` or an `AsyncIterable<string>` of token
|
|
132
|
-
* chunks (e.g. a streaming LLM response).
|
|
176
|
+
* chunks (e.g. a streaming LLM response). In a full production implementation
|
|
133
177
|
* this delegates to `VoicePipelineOrchestrator.pushToTTS(output)`.
|
|
134
178
|
*
|
|
135
179
|
* Emits a {@link GraphEvent} of type `voice_audio` (direction `'outbound'`)
|
|
136
180
|
* so that the runtime event bus records the TTS delivery.
|
|
137
181
|
*
|
|
138
|
-
* @param nodeId - The id of the graph node delivering the output
|
|
139
|
-
*
|
|
140
|
-
* @
|
|
182
|
+
* @param nodeId - The id of the graph node delivering the output; tags the
|
|
183
|
+
* emitted event for downstream filtering.
|
|
184
|
+
* @param _output - Text or async token stream to synthesise as speech.
|
|
185
|
+
* The underscore prefix indicates it is not yet consumed
|
|
186
|
+
* in the v1 stub implementation.
|
|
187
|
+
* @throws {Error} If called before `init()` or after `dispose()`.
|
|
141
188
|
*/
|
|
142
189
|
async deliverNodeOutput(nodeId, _output) {
|
|
143
190
|
if (!this.initialized) {
|
|
144
191
|
throw new Error('VoiceTransportAdapter not initialized');
|
|
145
192
|
}
|
|
146
|
-
// In
|
|
193
|
+
// In the full implementation this would delegate to:
|
|
194
|
+
// this.pipeline.pushToTTS(output)
|
|
147
195
|
// For now, emit the event to signal delivery.
|
|
148
196
|
this.eventSink({
|
|
149
197
|
type: 'voice_audio',
|
|
@@ -160,8 +208,11 @@ export class VoiceTransportAdapter {
|
|
|
160
208
|
* Handle a user barge-in at the transport level.
|
|
161
209
|
*
|
|
162
210
|
* Should be called by the runtime or transport layer when the user starts
|
|
163
|
-
* speaking while the agent is mid-utterance.
|
|
164
|
-
* so that graph event consumers can react (e.g. cancel pending tool calls
|
|
211
|
+
* speaking while the agent is mid-utterance. Emits a `voice_barge_in` event
|
|
212
|
+
* so that graph event consumers can react (e.g. cancel pending tool calls,
|
|
213
|
+
* stop TTS playback, or reroute the graph).
|
|
214
|
+
*
|
|
215
|
+
* @see {@link VoiceInterruptError} -- the structured error used inside the graph executor.
|
|
165
216
|
*/
|
|
166
217
|
handleBargeIn() {
|
|
167
218
|
this.eventSink({
|
|
@@ -179,6 +230,9 @@ export class VoiceTransportAdapter {
|
|
|
179
230
|
*
|
|
180
231
|
* Marks the adapter as uninitialised so subsequent calls to `getNodeInput()`
|
|
181
232
|
* or `deliverNodeOutput()` will throw, preventing accidental use after teardown.
|
|
233
|
+
*
|
|
234
|
+
* This method is idempotent -- calling it multiple times simply re-emits the
|
|
235
|
+
* ended event and re-sets the initialised flag.
|
|
182
236
|
*/
|
|
183
237
|
async dispose() {
|
|
184
238
|
this.eventSink({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VoiceTransportAdapter.js","sourceRoot":"","sources":["../../../src/orchestration/runtime/VoiceTransportAdapter.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"VoiceTransportAdapter.js","sourceRoot":"","sources":["../../../src/orchestration/runtime/VoiceTransportAdapter.ts"],"names":[],"mappings":"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"}
|
|
@@ -3,39 +3,61 @@
|
|
|
3
3
|
* @description Subscribes to voice pipeline session events and maintains a
|
|
4
4
|
* running transcript buffer, turn counter, and last-speaker tracker.
|
|
5
5
|
*
|
|
6
|
+
* ## Event bridging strategy
|
|
7
|
+
*
|
|
6
8
|
* The collector bridges the raw EventEmitter-based voice pipeline session into
|
|
7
9
|
* the typed `GraphEvent` stream consumed by the graph runtime. Four session
|
|
8
10
|
* events are handled:
|
|
9
11
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
12
|
+
* | Session event | GraphEvent emitted | Buffered? | Why |
|
|
13
|
+
* |----------------------|--------------------------|-----------|--------------------------------------------------------|
|
|
14
|
+
* | `interim_transcript` | `voice_transcript` | No | Partials are noisy and would duplicate final entries. |
|
|
15
|
+
* | `final_transcript` | `voice_transcript` | Yes | Confirmed utterances form the canonical transcript. |
|
|
16
|
+
* | `turn_complete` | `voice_turn_complete` | N/A | Marks endpoint detection; advances the turn counter. |
|
|
17
|
+
* | `barge_in` | `voice_barge_in` | N/A | Signals user interruption for downstream handlers. |
|
|
18
|
+
*
|
|
19
|
+
* ## Checkpoint restore
|
|
18
20
|
*
|
|
19
21
|
* The `initialTurnCount` constructor parameter enables checkpoint restore:
|
|
20
22
|
* pass the previously persisted count so that `turnIndex` values continue
|
|
21
|
-
* from where the session left off rather than resetting to zero.
|
|
23
|
+
* from where the session left off rather than resetting to zero. This is
|
|
24
|
+
* critical for `maxTurns` enforcement across graph suspensions.
|
|
25
|
+
*
|
|
26
|
+
* See `VoiceNodeExecutor` for the owner of this collector during voice node execution.
|
|
27
|
+
* @see {@link VoiceNodeCheckpoint} -- persists `turnIndex` and `transcript` across suspensions.
|
|
22
28
|
*/
|
|
23
29
|
import { EventEmitter } from 'events';
|
|
24
30
|
import type { GraphEvent } from '../events/GraphEvent.js';
|
|
25
31
|
/**
|
|
26
32
|
* A single confirmed (final) utterance captured from the voice pipeline.
|
|
27
33
|
*
|
|
28
|
-
* Only `final_transcript` events populate
|
|
29
|
-
* discarded to keep the transcript clean and avoid duplicate
|
|
34
|
+
* Only `final_transcript` events populate the transcript buffer -- interim
|
|
35
|
+
* partials are discarded to keep the transcript clean and avoid duplicate
|
|
36
|
+
* entries that would corrupt downstream summarisation.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* const entry: TranscriptEntry = {
|
|
41
|
+
* speaker: 'Speaker_0',
|
|
42
|
+
* text: 'Hello, how can I help you?',
|
|
43
|
+
* timestamp: Date.now(),
|
|
44
|
+
* };
|
|
45
|
+
* ```
|
|
30
46
|
*/
|
|
31
47
|
export interface TranscriptEntry {
|
|
32
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* Speaker identifier as reported by the STT service (e.g. `"Speaker_0"`).
|
|
50
|
+
* Defaults to `"user"` when the STT service does not provide diarization labels.
|
|
51
|
+
*/
|
|
33
52
|
speaker: string;
|
|
34
53
|
/** Recognised text for this utterance. */
|
|
35
54
|
text: string;
|
|
36
55
|
/**
|
|
37
56
|
* Wall-clock timestamp (milliseconds since Unix epoch) recorded at the
|
|
38
|
-
* moment the `final_transcript` event was processed.
|
|
57
|
+
* moment the `final_transcript` event was processed by the collector.
|
|
58
|
+
*
|
|
59
|
+
* This is the collector's receive time, not the STT service's recognition
|
|
60
|
+
* time, so it includes any event loop latency between STT and the collector.
|
|
39
61
|
*/
|
|
40
62
|
timestamp: number;
|
|
41
63
|
}
|
|
@@ -43,6 +65,11 @@ export interface TranscriptEntry {
|
|
|
43
65
|
* Stateful collector that subscribes to a voice pipeline session and routes
|
|
44
66
|
* session events into the AgentOS `GraphEvent` stream.
|
|
45
67
|
*
|
|
68
|
+
* The collector is designed to be short-lived -- created at the start of a
|
|
69
|
+
* voice node execution and discarded when the node completes. Its state
|
|
70
|
+
* (transcript, turn count, last speaker) is captured into a
|
|
71
|
+
* {@link VoiceNodeCheckpoint} by the executor before disposal.
|
|
72
|
+
*
|
|
46
73
|
* @example
|
|
47
74
|
* ```ts
|
|
48
75
|
* const collector = new VoiceTurnCollector(
|
|
@@ -56,39 +83,65 @@ export interface TranscriptEntry {
|
|
|
56
83
|
* console.log(collector.getTranscript()); // full buffered transcript
|
|
57
84
|
* console.log(collector.getLastSpeaker()); // last identified speaker
|
|
58
85
|
* ```
|
|
86
|
+
*
|
|
87
|
+
* @see {@link TranscriptEntry} -- shape of each buffered transcript entry.
|
|
88
|
+
* See `VoiceNodeExecutor` for the executor that creates and queries the collector.
|
|
59
89
|
*/
|
|
60
90
|
export declare class VoiceTurnCollector {
|
|
61
91
|
private readonly eventSink;
|
|
62
92
|
private readonly nodeId;
|
|
63
|
-
/** Buffered confirmed utterances in chronological order. */
|
|
93
|
+
/** Buffered confirmed utterances in chronological order. Append-only. */
|
|
64
94
|
private transcript;
|
|
65
95
|
/** Running count of completed turns (endpoint-detected). */
|
|
66
96
|
private turnCount;
|
|
67
|
-
/**
|
|
97
|
+
/**
|
|
98
|
+
* Speaker identifier from the most recent `final_transcript` event.
|
|
99
|
+
* Empty string until the first final transcript arrives.
|
|
100
|
+
*/
|
|
68
101
|
private lastSpeaker;
|
|
69
102
|
/**
|
|
103
|
+
* Creates a new VoiceTurnCollector and immediately subscribes to session events.
|
|
104
|
+
*
|
|
105
|
+
* Subscription is performed in the constructor (rather than a separate `init()`
|
|
106
|
+
* method) because the collector has no meaningful state before subscription and
|
|
107
|
+
* there is no cleanup/unsubscribe lifecycle -- the session EventEmitter is
|
|
108
|
+
* short-lived and garbage-collected with the collector.
|
|
109
|
+
*
|
|
70
110
|
* @param session - The voice pipeline `EventEmitter` to subscribe to.
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* @param
|
|
74
|
-
*
|
|
111
|
+
* Must emit `interim_transcript`, `final_transcript`,
|
|
112
|
+
* `turn_complete`, and `barge_in` events.
|
|
113
|
+
* @param eventSink - Callback invoked synchronously for every emitted
|
|
114
|
+
* `GraphEvent`. Must not throw -- exceptions would
|
|
115
|
+
* propagate into the session event loop.
|
|
116
|
+
* @param nodeId - Identifies the owning graph node in every emitted
|
|
117
|
+
* event, enabling consumers to filter events by node.
|
|
118
|
+
* @param initialTurnCount - Seed value for `turnCount`; pass a persisted value
|
|
119
|
+
* to resume from a checkpoint rather than starting at
|
|
120
|
+
* zero. Defaults to `0`.
|
|
75
121
|
*/
|
|
76
122
|
constructor(session: EventEmitter, eventSink: (event: GraphEvent) => void, nodeId: string, initialTurnCount?: number);
|
|
77
123
|
/**
|
|
78
124
|
* Returns the total number of completed turns since construction (or since the
|
|
79
125
|
* provided `initialTurnCount` when restoring from a checkpoint).
|
|
126
|
+
*
|
|
127
|
+
* @returns The current turn count. Always >= `initialTurnCount`.
|
|
80
128
|
*/
|
|
81
129
|
getTurnCount(): number;
|
|
82
130
|
/**
|
|
83
131
|
* Returns a shallow copy of the buffered transcript entries.
|
|
84
132
|
*
|
|
85
133
|
* A copy is returned to prevent external callers from mutating the internal
|
|
86
|
-
* buffer
|
|
134
|
+
* buffer -- entries are append-only and must remain in chronological order
|
|
135
|
+
* for correct checkpoint persistence.
|
|
136
|
+
*
|
|
137
|
+
* @returns A new array containing all confirmed transcript entries in order.
|
|
87
138
|
*/
|
|
88
139
|
getTranscript(): TranscriptEntry[];
|
|
89
140
|
/**
|
|
90
141
|
* Returns the speaker identifier from the most recent `final_transcript` event,
|
|
91
142
|
* or an empty string if no final transcript has been received yet.
|
|
143
|
+
*
|
|
144
|
+
* @returns The last speaker label, or `''` if none.
|
|
92
145
|
*/
|
|
93
146
|
getLastSpeaker(): string;
|
|
94
147
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VoiceTurnCollector.d.ts","sourceRoot":"","sources":["../../../src/orchestration/runtime/VoiceTurnCollector.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"VoiceTurnCollector.d.ts","sourceRoot":"","sources":["../../../src/orchestration/runtime/VoiceTurnCollector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAM1D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IAEb;;;;;;OAMG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,kBAAkB;IAmC3B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM;IAnCzB,yEAAyE;IACzE,OAAO,CAAC,UAAU,CAAyB;IAE3C,4DAA4D;IAC5D,OAAO,CAAC,SAAS,CAAS;IAE1B;;;OAGG;IACH,OAAO,CAAC,WAAW,CAAM;IAEzB;;;;;;;;;;;;;;;;;;;OAmBG;gBAED,OAAO,EAAE,YAAY,EACJ,SAAS,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,EACtC,MAAM,EAAE,MAAM,EAC/B,gBAAgB,SAAI;IAqGtB;;;;;OAKG;IACH,YAAY,IAAI,MAAM;IAItB;;;;;;;;OAQG;IACH,aAAa,IAAI,eAAe,EAAE;IAIlC;;;;;OAKG;IACH,cAAc,IAAI,MAAM;CAGzB"}
|
|
@@ -3,22 +3,28 @@
|
|
|
3
3
|
* @description Subscribes to voice pipeline session events and maintains a
|
|
4
4
|
* running transcript buffer, turn counter, and last-speaker tracker.
|
|
5
5
|
*
|
|
6
|
+
* ## Event bridging strategy
|
|
7
|
+
*
|
|
6
8
|
* The collector bridges the raw EventEmitter-based voice pipeline session into
|
|
7
9
|
* the typed `GraphEvent` stream consumed by the graph runtime. Four session
|
|
8
10
|
* events are handled:
|
|
9
11
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
12
|
+
* | Session event | GraphEvent emitted | Buffered? | Why |
|
|
13
|
+
* |----------------------|--------------------------|-----------|--------------------------------------------------------|
|
|
14
|
+
* | `interim_transcript` | `voice_transcript` | No | Partials are noisy and would duplicate final entries. |
|
|
15
|
+
* | `final_transcript` | `voice_transcript` | Yes | Confirmed utterances form the canonical transcript. |
|
|
16
|
+
* | `turn_complete` | `voice_turn_complete` | N/A | Marks endpoint detection; advances the turn counter. |
|
|
17
|
+
* | `barge_in` | `voice_barge_in` | N/A | Signals user interruption for downstream handlers. |
|
|
18
|
+
*
|
|
19
|
+
* ## Checkpoint restore
|
|
18
20
|
*
|
|
19
21
|
* The `initialTurnCount` constructor parameter enables checkpoint restore:
|
|
20
22
|
* pass the previously persisted count so that `turnIndex` values continue
|
|
21
|
-
* from where the session left off rather than resetting to zero.
|
|
23
|
+
* from where the session left off rather than resetting to zero. This is
|
|
24
|
+
* critical for `maxTurns` enforcement across graph suspensions.
|
|
25
|
+
*
|
|
26
|
+
* See `VoiceNodeExecutor` for the owner of this collector during voice node execution.
|
|
27
|
+
* @see {@link VoiceNodeCheckpoint} -- persists `turnIndex` and `transcript` across suspensions.
|
|
22
28
|
*/
|
|
23
29
|
// ---------------------------------------------------------------------------
|
|
24
30
|
// VoiceTurnCollector
|
|
@@ -27,6 +33,11 @@
|
|
|
27
33
|
* Stateful collector that subscribes to a voice pipeline session and routes
|
|
28
34
|
* session events into the AgentOS `GraphEvent` stream.
|
|
29
35
|
*
|
|
36
|
+
* The collector is designed to be short-lived -- created at the start of a
|
|
37
|
+
* voice node execution and discarded when the node completes. Its state
|
|
38
|
+
* (transcript, turn count, last speaker) is captured into a
|
|
39
|
+
* {@link VoiceNodeCheckpoint} by the executor before disposal.
|
|
40
|
+
*
|
|
30
41
|
* @example
|
|
31
42
|
* ```ts
|
|
32
43
|
* const collector = new VoiceTurnCollector(
|
|
@@ -40,25 +51,49 @@
|
|
|
40
51
|
* console.log(collector.getTranscript()); // full buffered transcript
|
|
41
52
|
* console.log(collector.getLastSpeaker()); // last identified speaker
|
|
42
53
|
* ```
|
|
54
|
+
*
|
|
55
|
+
* @see {@link TranscriptEntry} -- shape of each buffered transcript entry.
|
|
56
|
+
* See `VoiceNodeExecutor` for the executor that creates and queries the collector.
|
|
43
57
|
*/
|
|
44
58
|
export class VoiceTurnCollector {
|
|
45
59
|
/**
|
|
60
|
+
* Creates a new VoiceTurnCollector and immediately subscribes to session events.
|
|
61
|
+
*
|
|
62
|
+
* Subscription is performed in the constructor (rather than a separate `init()`
|
|
63
|
+
* method) because the collector has no meaningful state before subscription and
|
|
64
|
+
* there is no cleanup/unsubscribe lifecycle -- the session EventEmitter is
|
|
65
|
+
* short-lived and garbage-collected with the collector.
|
|
66
|
+
*
|
|
46
67
|
* @param session - The voice pipeline `EventEmitter` to subscribe to.
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* @param
|
|
50
|
-
*
|
|
68
|
+
* Must emit `interim_transcript`, `final_transcript`,
|
|
69
|
+
* `turn_complete`, and `barge_in` events.
|
|
70
|
+
* @param eventSink - Callback invoked synchronously for every emitted
|
|
71
|
+
* `GraphEvent`. Must not throw -- exceptions would
|
|
72
|
+
* propagate into the session event loop.
|
|
73
|
+
* @param nodeId - Identifies the owning graph node in every emitted
|
|
74
|
+
* event, enabling consumers to filter events by node.
|
|
75
|
+
* @param initialTurnCount - Seed value for `turnCount`; pass a persisted value
|
|
76
|
+
* to resume from a checkpoint rather than starting at
|
|
77
|
+
* zero. Defaults to `0`.
|
|
51
78
|
*/
|
|
52
79
|
constructor(session, eventSink, nodeId, initialTurnCount = 0) {
|
|
53
80
|
this.eventSink = eventSink;
|
|
54
81
|
this.nodeId = nodeId;
|
|
55
|
-
/** Buffered confirmed utterances in chronological order. */
|
|
82
|
+
/** Buffered confirmed utterances in chronological order. Append-only. */
|
|
56
83
|
this.transcript = [];
|
|
57
|
-
/**
|
|
84
|
+
/**
|
|
85
|
+
* Speaker identifier from the most recent `final_transcript` event.
|
|
86
|
+
* Empty string until the first final transcript arrives.
|
|
87
|
+
*/
|
|
58
88
|
this.lastSpeaker = '';
|
|
59
89
|
this.turnCount = initialTurnCount;
|
|
60
90
|
// ------------------------------------------------------------------
|
|
61
|
-
// interim_transcript
|
|
91
|
+
// interim_transcript -- partial STT result, forwarded but NOT buffered.
|
|
92
|
+
//
|
|
93
|
+
// Why not buffer? Interim transcripts are speculative and frequently
|
|
94
|
+
// revised by the STT engine. Buffering them would produce duplicate
|
|
95
|
+
// or contradictory entries. They are forwarded as events so that UIs
|
|
96
|
+
// can show live typing indicators.
|
|
62
97
|
// ------------------------------------------------------------------
|
|
63
98
|
session.on('interim_transcript', (evt) => {
|
|
64
99
|
this.eventSink({
|
|
@@ -71,17 +106,26 @@ export class VoiceTurnCollector {
|
|
|
71
106
|
});
|
|
72
107
|
});
|
|
73
108
|
// ------------------------------------------------------------------
|
|
74
|
-
// final_transcript
|
|
109
|
+
// final_transcript -- confirmed utterance, buffered AND forwarded.
|
|
110
|
+
//
|
|
111
|
+
// This is the canonical source of truth for what was said. Every
|
|
112
|
+
// confirmed utterance is appended to the transcript buffer and the
|
|
113
|
+
// last-speaker tracker is updated.
|
|
75
114
|
// ------------------------------------------------------------------
|
|
76
115
|
session.on('final_transcript', (evt) => {
|
|
116
|
+
// Default speaker to 'user' when the STT service doesn't provide
|
|
117
|
+
// diarization labels. This matches the most common single-speaker
|
|
118
|
+
// scenario where the only speaker is the human user.
|
|
77
119
|
const speaker = evt.speaker ?? 'user';
|
|
78
|
-
// Buffer the confirmed entry for downstream consumers
|
|
120
|
+
// Buffer the confirmed entry for downstream consumers (checkpoint,
|
|
121
|
+
// summarisation, analytics).
|
|
79
122
|
this.transcript.push({
|
|
80
123
|
speaker,
|
|
81
124
|
text: evt.text ?? '',
|
|
82
125
|
timestamp: Date.now(),
|
|
83
126
|
});
|
|
84
|
-
// Track the most recent speaker for quick access without iterating
|
|
127
|
+
// Track the most recent speaker for quick access without iterating
|
|
128
|
+
// the entire buffer. Used by the executor to populate the result.
|
|
85
129
|
this.lastSpeaker = speaker;
|
|
86
130
|
this.eventSink({
|
|
87
131
|
type: 'voice_transcript',
|
|
@@ -93,10 +137,14 @@ export class VoiceTurnCollector {
|
|
|
93
137
|
});
|
|
94
138
|
});
|
|
95
139
|
// ------------------------------------------------------------------
|
|
96
|
-
// turn_complete
|
|
140
|
+
// turn_complete -- endpoint detection fired; advance the turn counter.
|
|
141
|
+
//
|
|
142
|
+
// The counter is incremented BEFORE emitting the event so that the
|
|
143
|
+
// turnIndex in the emitted event reflects the new (post-increment)
|
|
144
|
+
// count. This matches the semantics expected by VoiceNodeExecutor's
|
|
145
|
+
// maxTurns check, which reads getTurnCount() after the event fires.
|
|
97
146
|
// ------------------------------------------------------------------
|
|
98
147
|
session.on('turn_complete', (evt) => {
|
|
99
|
-
// Increment before emitting so that turnIndex reflects the new count.
|
|
100
148
|
this.turnCount++;
|
|
101
149
|
this.eventSink({
|
|
102
150
|
type: 'voice_turn_complete',
|
|
@@ -107,7 +155,13 @@ export class VoiceTurnCollector {
|
|
|
107
155
|
});
|
|
108
156
|
});
|
|
109
157
|
// ------------------------------------------------------------------
|
|
110
|
-
// barge_in
|
|
158
|
+
// barge_in -- user interrupted agent mid-speech.
|
|
159
|
+
//
|
|
160
|
+
// This event does not affect the turn count or transcript buffer
|
|
161
|
+
// because the interruption itself is not a complete utterance. The
|
|
162
|
+
// interrupted text (what the agent was saying) and the user's speech
|
|
163
|
+
// (what triggered the interruption) are forwarded for downstream
|
|
164
|
+
// handlers to process.
|
|
111
165
|
// ------------------------------------------------------------------
|
|
112
166
|
session.on('barge_in', (evt) => {
|
|
113
167
|
this.eventSink({
|
|
@@ -124,6 +178,8 @@ export class VoiceTurnCollector {
|
|
|
124
178
|
/**
|
|
125
179
|
* Returns the total number of completed turns since construction (or since the
|
|
126
180
|
* provided `initialTurnCount` when restoring from a checkpoint).
|
|
181
|
+
*
|
|
182
|
+
* @returns The current turn count. Always >= `initialTurnCount`.
|
|
127
183
|
*/
|
|
128
184
|
getTurnCount() {
|
|
129
185
|
return this.turnCount;
|
|
@@ -132,7 +188,10 @@ export class VoiceTurnCollector {
|
|
|
132
188
|
* Returns a shallow copy of the buffered transcript entries.
|
|
133
189
|
*
|
|
134
190
|
* A copy is returned to prevent external callers from mutating the internal
|
|
135
|
-
* buffer
|
|
191
|
+
* buffer -- entries are append-only and must remain in chronological order
|
|
192
|
+
* for correct checkpoint persistence.
|
|
193
|
+
*
|
|
194
|
+
* @returns A new array containing all confirmed transcript entries in order.
|
|
136
195
|
*/
|
|
137
196
|
getTranscript() {
|
|
138
197
|
return [...this.transcript];
|
|
@@ -140,6 +199,8 @@ export class VoiceTurnCollector {
|
|
|
140
199
|
/**
|
|
141
200
|
* Returns the speaker identifier from the most recent `final_transcript` event,
|
|
142
201
|
* or an empty string if no final transcript has been received yet.
|
|
202
|
+
*
|
|
203
|
+
* @returns The last speaker label, or `''` if none.
|
|
143
204
|
*/
|
|
144
205
|
getLastSpeaker() {
|
|
145
206
|
return this.lastSpeaker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VoiceTurnCollector.js","sourceRoot":"","sources":["../../../src/orchestration/runtime/VoiceTurnCollector.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"VoiceTurnCollector.js","sourceRoot":"","sources":["../../../src/orchestration/runtime/VoiceTurnCollector.ts"],"names":[],"mappings":"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"}
|