@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.
Files changed (552) hide show
  1. package/README.md +39 -5
  2. package/dist/api/AgentOS.d.ts +45 -12
  3. package/dist/api/AgentOS.d.ts.map +1 -1
  4. package/dist/api/AgentOS.js +225 -78
  5. package/dist/api/AgentOS.js.map +1 -1
  6. package/dist/api/AgentOSOrchestrator.d.ts +8 -0
  7. package/dist/api/AgentOSOrchestrator.d.ts.map +1 -1
  8. package/dist/api/AgentOSOrchestrator.js +350 -59
  9. package/dist/api/AgentOSOrchestrator.js.map +1 -1
  10. package/dist/api/StreamChunkEmitter.d.ts.map +1 -1
  11. package/dist/api/StreamChunkEmitter.js +2 -0
  12. package/dist/api/StreamChunkEmitter.js.map +1 -1
  13. package/dist/api/agency.d.ts.map +1 -1
  14. package/dist/api/agency.js +47 -1
  15. package/dist/api/agency.js.map +1 -1
  16. package/dist/api/agent.d.ts +18 -5
  17. package/dist/api/agent.d.ts.map +1 -1
  18. package/dist/api/agent.js +48 -9
  19. package/dist/api/agent.js.map +1 -1
  20. package/dist/api/agentExport.d.ts +202 -0
  21. package/dist/api/agentExport.d.ts.map +1 -0
  22. package/dist/api/agentExport.js +323 -0
  23. package/dist/api/agentExport.js.map +1 -0
  24. package/dist/api/editImage.d.ts +119 -0
  25. package/dist/api/editImage.d.ts.map +1 -0
  26. package/dist/api/editImage.js +150 -0
  27. package/dist/api/editImage.js.map +1 -0
  28. package/dist/api/embedText.d.ts +137 -0
  29. package/dist/api/embedText.d.ts.map +1 -0
  30. package/dist/api/embedText.js +229 -0
  31. package/dist/api/embedText.js.map +1 -0
  32. package/dist/api/externalToolRegistry.d.ts +44 -0
  33. package/dist/api/externalToolRegistry.d.ts.map +1 -0
  34. package/dist/api/externalToolRegistry.js +245 -0
  35. package/dist/api/externalToolRegistry.js.map +1 -0
  36. package/dist/api/generateImage.d.ts +1 -1
  37. package/dist/api/generateImage.d.ts.map +1 -1
  38. package/dist/api/generateImage.js +17 -13
  39. package/dist/api/generateImage.js.map +1 -1
  40. package/dist/api/generateObject.d.ts +185 -0
  41. package/dist/api/generateObject.d.ts.map +1 -0
  42. package/dist/api/generateObject.js +249 -0
  43. package/dist/api/generateObject.js.map +1 -0
  44. package/dist/api/generateText.d.ts +13 -3
  45. package/dist/api/generateText.d.ts.map +1 -1
  46. package/dist/api/generateText.js +20 -5
  47. package/dist/api/generateText.js.map +1 -1
  48. package/dist/api/interfaces/IAgentOS.d.ts +29 -1
  49. package/dist/api/interfaces/IAgentOS.d.ts.map +1 -1
  50. package/dist/api/model.d.ts +7 -7
  51. package/dist/api/model.d.ts.map +1 -1
  52. package/dist/api/model.js +22 -16
  53. package/dist/api/model.js.map +1 -1
  54. package/dist/api/processRequestWithExternalTools.d.ts +26 -0
  55. package/dist/api/processRequestWithExternalTools.d.ts.map +1 -0
  56. package/dist/api/processRequestWithExternalTools.js +52 -0
  57. package/dist/api/processRequestWithExternalTools.js.map +1 -0
  58. package/dist/api/processRequestWithRegisteredTools.d.ts +56 -0
  59. package/dist/api/processRequestWithRegisteredTools.d.ts.map +1 -0
  60. package/dist/api/processRequestWithRegisteredTools.js +125 -0
  61. package/dist/api/processRequestWithRegisteredTools.js.map +1 -0
  62. package/dist/api/provider-defaults.d.ts.map +1 -1
  63. package/dist/api/provider-defaults.js +28 -0
  64. package/dist/api/provider-defaults.js.map +1 -1
  65. package/dist/api/resumeExternalToolRequestWithRegisteredTools.d.ts +71 -0
  66. package/dist/api/resumeExternalToolRequestWithRegisteredTools.d.ts.map +1 -0
  67. package/dist/api/resumeExternalToolRequestWithRegisteredTools.js +159 -0
  68. package/dist/api/resumeExternalToolRequestWithRegisteredTools.js.map +1 -0
  69. package/dist/api/strategies/agentGraphBuilder.d.ts +170 -0
  70. package/dist/api/strategies/agentGraphBuilder.d.ts.map +1 -0
  71. package/dist/api/strategies/agentGraphBuilder.js +299 -0
  72. package/dist/api/strategies/agentGraphBuilder.js.map +1 -0
  73. package/dist/api/strategies/debate.d.ts +12 -1
  74. package/dist/api/strategies/debate.d.ts.map +1 -1
  75. package/dist/api/strategies/debate.js +41 -5
  76. package/dist/api/strategies/debate.js.map +1 -1
  77. package/dist/api/strategies/graphCompiler.d.ts +84 -0
  78. package/dist/api/strategies/graphCompiler.d.ts.map +1 -0
  79. package/dist/api/strategies/graphCompiler.js +617 -0
  80. package/dist/api/strategies/graphCompiler.js.map +1 -0
  81. package/dist/api/strategies/hierarchical.d.ts +15 -1
  82. package/dist/api/strategies/hierarchical.d.ts.map +1 -1
  83. package/dist/api/strategies/hierarchical.js +53 -8
  84. package/dist/api/strategies/hierarchical.js.map +1 -1
  85. package/dist/api/strategies/index.d.ts +29 -4
  86. package/dist/api/strategies/index.d.ts.map +1 -1
  87. package/dist/api/strategies/index.js +28 -4
  88. package/dist/api/strategies/index.js.map +1 -1
  89. package/dist/api/strategies/parallel.d.ts +15 -4
  90. package/dist/api/strategies/parallel.d.ts.map +1 -1
  91. package/dist/api/strategies/parallel.js +53 -16
  92. package/dist/api/strategies/parallel.js.map +1 -1
  93. package/dist/api/strategies/review-loop.d.ts +15 -1
  94. package/dist/api/strategies/review-loop.d.ts.map +1 -1
  95. package/dist/api/strategies/review-loop.js +36 -10
  96. package/dist/api/strategies/review-loop.js.map +1 -1
  97. package/dist/api/strategies/sequential.d.ts +11 -1
  98. package/dist/api/strategies/sequential.d.ts.map +1 -1
  99. package/dist/api/strategies/sequential.js +39 -8
  100. package/dist/api/strategies/sequential.js.map +1 -1
  101. package/dist/api/strategies/shared.d.ts +72 -8
  102. package/dist/api/strategies/shared.d.ts.map +1 -1
  103. package/dist/api/strategies/shared.js +92 -12
  104. package/dist/api/strategies/shared.js.map +1 -1
  105. package/dist/api/streamObject.d.ts +166 -0
  106. package/dist/api/streamObject.d.ts.map +1 -0
  107. package/dist/api/streamObject.js +268 -0
  108. package/dist/api/streamObject.js.map +1 -0
  109. package/dist/api/streamText.d.ts +1 -1
  110. package/dist/api/streamText.d.ts.map +1 -1
  111. package/dist/api/streamText.js +26 -8
  112. package/dist/api/streamText.js.map +1 -1
  113. package/dist/api/toolAdapter.d.ts +44 -8
  114. package/dist/api/toolAdapter.d.ts.map +1 -1
  115. package/dist/api/toolAdapter.js +224 -45
  116. package/dist/api/toolAdapter.js.map +1 -1
  117. package/dist/api/types/AgentOSExternalToolRequest.d.ts +35 -0
  118. package/dist/api/types/AgentOSExternalToolRequest.d.ts.map +1 -0
  119. package/dist/api/types/AgentOSExternalToolRequest.js +2 -0
  120. package/dist/api/types/AgentOSExternalToolRequest.js.map +1 -0
  121. package/dist/api/types/AgentOSResponse.d.ts +25 -0
  122. package/dist/api/types/AgentOSResponse.d.ts.map +1 -1
  123. package/dist/api/types/AgentOSResponse.js +20 -0
  124. package/dist/api/types/AgentOSResponse.js.map +1 -1
  125. package/dist/api/types/AgentOSToolResult.d.ts +11 -0
  126. package/dist/api/types/AgentOSToolResult.d.ts.map +1 -0
  127. package/dist/api/types/AgentOSToolResult.js +2 -0
  128. package/dist/api/types/AgentOSToolResult.js.map +1 -0
  129. package/dist/api/types.d.ts +81 -4
  130. package/dist/api/types.d.ts.map +1 -1
  131. package/dist/api/types.js.map +1 -1
  132. package/dist/api/upscaleImage.d.ts +92 -0
  133. package/dist/api/upscaleImage.d.ts.map +1 -0
  134. package/dist/api/upscaleImage.js +133 -0
  135. package/dist/api/upscaleImage.js.map +1 -0
  136. package/dist/api/variateImage.d.ts +102 -0
  137. package/dist/api/variateImage.d.ts.map +1 -0
  138. package/dist/api/variateImage.js +154 -0
  139. package/dist/api/variateImage.js.map +1 -0
  140. package/dist/cognitive_substrate/GMI.d.ts +16 -2
  141. package/dist/cognitive_substrate/GMI.d.ts.map +1 -1
  142. package/dist/cognitive_substrate/GMI.js +188 -56
  143. package/dist/cognitive_substrate/GMI.js.map +1 -1
  144. package/dist/cognitive_substrate/IGMI.d.ts +10 -0
  145. package/dist/cognitive_substrate/IGMI.d.ts.map +1 -1
  146. package/dist/cognitive_substrate/IGMI.js.map +1 -1
  147. package/dist/config/AgentOSConfig.d.ts +19 -2
  148. package/dist/config/AgentOSConfig.d.ts.map +1 -1
  149. package/dist/config/AgentOSConfig.js +46 -29
  150. package/dist/config/AgentOSConfig.js.map +1 -1
  151. package/dist/core/guardrails/IGuardrailService.d.ts +1 -1
  152. package/dist/core/images/IImageProvider.d.ts +93 -0
  153. package/dist/core/images/IImageProvider.d.ts.map +1 -1
  154. package/dist/core/images/IImageProvider.js.map +1 -1
  155. package/dist/core/images/ImageOperationError.d.ts +52 -0
  156. package/dist/core/images/ImageOperationError.d.ts.map +1 -0
  157. package/dist/core/images/ImageOperationError.js +58 -0
  158. package/dist/core/images/ImageOperationError.js.map +1 -0
  159. package/dist/core/images/imageToBuffer.d.ts +41 -0
  160. package/dist/core/images/imageToBuffer.d.ts.map +1 -0
  161. package/dist/core/images/imageToBuffer.js +95 -0
  162. package/dist/core/images/imageToBuffer.js.map +1 -0
  163. package/dist/core/images/index.d.ts +4 -0
  164. package/dist/core/images/index.d.ts.map +1 -1
  165. package/dist/core/images/index.js +8 -0
  166. package/dist/core/images/index.js.map +1 -1
  167. package/dist/core/images/providers/FalImageProvider.d.ts +208 -0
  168. package/dist/core/images/providers/FalImageProvider.d.ts.map +1 -0
  169. package/dist/core/images/providers/FalImageProvider.js +301 -0
  170. package/dist/core/images/providers/FalImageProvider.js.map +1 -0
  171. package/dist/core/images/providers/FluxImageProvider.d.ts +197 -0
  172. package/dist/core/images/providers/FluxImageProvider.d.ts.map +1 -0
  173. package/dist/core/images/providers/FluxImageProvider.js +271 -0
  174. package/dist/core/images/providers/FluxImageProvider.js.map +1 -0
  175. package/dist/core/images/providers/OpenAIImageProvider.d.ts +33 -1
  176. package/dist/core/images/providers/OpenAIImageProvider.d.ts.map +1 -1
  177. package/dist/core/images/providers/OpenAIImageProvider.js +125 -0
  178. package/dist/core/images/providers/OpenAIImageProvider.js.map +1 -1
  179. package/dist/core/images/providers/ReplicateImageProvider.d.ts +26 -1
  180. package/dist/core/images/providers/ReplicateImageProvider.d.ts.map +1 -1
  181. package/dist/core/images/providers/ReplicateImageProvider.js +118 -0
  182. package/dist/core/images/providers/ReplicateImageProvider.js.map +1 -1
  183. package/dist/core/images/providers/StabilityImageProvider.d.ts +41 -1
  184. package/dist/core/images/providers/StabilityImageProvider.d.ts.map +1 -1
  185. package/dist/core/images/providers/StabilityImageProvider.js +180 -7
  186. package/dist/core/images/providers/StabilityImageProvider.js.map +1 -1
  187. package/dist/core/images/providers/StableDiffusionLocalProvider.d.ts +29 -1
  188. package/dist/core/images/providers/StableDiffusionLocalProvider.d.ts.map +1 -1
  189. package/dist/core/images/providers/StableDiffusionLocalProvider.js +124 -0
  190. package/dist/core/images/providers/StableDiffusionLocalProvider.js.map +1 -1
  191. package/dist/core/llm/IPromptEngine.d.ts +2 -2
  192. package/dist/core/llm/IPromptEngine.d.ts.map +1 -1
  193. package/dist/core/llm/IPromptEngine.js +2 -2
  194. package/dist/core/llm/IPromptEngine.js.map +1 -1
  195. package/dist/core/llm/providers/AIModelProviderManager.d.ts +7 -1
  196. package/dist/core/llm/providers/AIModelProviderManager.d.ts.map +1 -1
  197. package/dist/core/llm/providers/AIModelProviderManager.js +24 -0
  198. package/dist/core/llm/providers/AIModelProviderManager.js.map +1 -1
  199. package/dist/core/llm/providers/errors/AnthropicProviderError.d.ts +42 -0
  200. package/dist/core/llm/providers/errors/AnthropicProviderError.d.ts.map +1 -0
  201. package/dist/core/llm/providers/errors/AnthropicProviderError.js +45 -0
  202. package/dist/core/llm/providers/errors/AnthropicProviderError.js.map +1 -0
  203. package/dist/core/llm/providers/errors/GeminiProviderError.d.ts +45 -0
  204. package/dist/core/llm/providers/errors/GeminiProviderError.d.ts.map +1 -0
  205. package/dist/core/llm/providers/errors/GeminiProviderError.js +46 -0
  206. package/dist/core/llm/providers/errors/GeminiProviderError.js.map +1 -0
  207. package/dist/core/llm/providers/errors/OllamaProviderError.d.ts +1 -1
  208. package/dist/core/llm/providers/errors/OllamaProviderError.d.ts.map +1 -1
  209. package/dist/core/llm/providers/errors/OllamaProviderError.js +1 -1
  210. package/dist/core/llm/providers/errors/OllamaProviderError.js.map +1 -1
  211. package/dist/core/llm/providers/errors/OpenAIProviderError.d.ts +1 -1
  212. package/dist/core/llm/providers/errors/OpenAIProviderError.js +1 -1
  213. package/dist/core/llm/providers/errors/OpenRouterProviderError.d.ts +1 -1
  214. package/dist/core/llm/providers/errors/OpenRouterProviderError.js +1 -1
  215. package/dist/core/llm/providers/implementations/AnthropicProvider.d.ts +340 -0
  216. package/dist/core/llm/providers/implementations/AnthropicProvider.d.ts.map +1 -0
  217. package/dist/core/llm/providers/implementations/AnthropicProvider.js +959 -0
  218. package/dist/core/llm/providers/implementations/AnthropicProvider.js.map +1 -0
  219. package/dist/core/llm/providers/implementations/GeminiProvider.d.ts +339 -0
  220. package/dist/core/llm/providers/implementations/GeminiProvider.d.ts.map +1 -0
  221. package/dist/core/llm/providers/implementations/GeminiProvider.js +1004 -0
  222. package/dist/core/llm/providers/implementations/GeminiProvider.js.map +1 -0
  223. package/dist/core/llm/providers/implementations/GroqProvider.d.ts +105 -0
  224. package/dist/core/llm/providers/implementations/GroqProvider.d.ts.map +1 -0
  225. package/dist/core/llm/providers/implementations/GroqProvider.js +134 -0
  226. package/dist/core/llm/providers/implementations/GroqProvider.js.map +1 -0
  227. package/dist/core/llm/providers/implementations/MistralProvider.d.ts +105 -0
  228. package/dist/core/llm/providers/implementations/MistralProvider.d.ts.map +1 -0
  229. package/dist/core/llm/providers/implementations/MistralProvider.js +146 -0
  230. package/dist/core/llm/providers/implementations/MistralProvider.js.map +1 -0
  231. package/dist/core/llm/providers/implementations/TogetherProvider.d.ts +107 -0
  232. package/dist/core/llm/providers/implementations/TogetherProvider.d.ts.map +1 -0
  233. package/dist/core/llm/providers/implementations/TogetherProvider.js +138 -0
  234. package/dist/core/llm/providers/implementations/TogetherProvider.js.map +1 -0
  235. package/dist/core/llm/providers/implementations/XAIProvider.d.ts +102 -0
  236. package/dist/core/llm/providers/implementations/XAIProvider.d.ts.map +1 -0
  237. package/dist/core/llm/providers/implementations/XAIProvider.js +123 -0
  238. package/dist/core/llm/providers/implementations/XAIProvider.js.map +1 -0
  239. package/dist/core/orchestration/AgentOrchestrator.d.ts.map +1 -1
  240. package/dist/core/orchestration/AgentOrchestrator.js +26 -5
  241. package/dist/core/orchestration/AgentOrchestrator.js.map +1 -1
  242. package/dist/core/tools/IToolOrchestrator.d.ts +2 -2
  243. package/dist/core/tools/IToolOrchestrator.d.ts.map +1 -1
  244. package/dist/core/tools/ToolExecutor.d.ts +3 -0
  245. package/dist/core/tools/ToolExecutor.d.ts.map +1 -1
  246. package/dist/core/tools/ToolExecutor.js +2 -1
  247. package/dist/core/tools/ToolExecutor.js.map +1 -1
  248. package/dist/core/tools/ToolOrchestrator.d.ts +7 -7
  249. package/dist/core/tools/ToolOrchestrator.d.ts.map +1 -1
  250. package/dist/core/tools/ToolOrchestrator.js +135 -36
  251. package/dist/core/tools/ToolOrchestrator.js.map +1 -1
  252. package/dist/core/tools/permissions/ToolPermissionManager.d.ts +6 -5
  253. package/dist/core/tools/permissions/ToolPermissionManager.d.ts.map +1 -1
  254. package/dist/core/tools/permissions/ToolPermissionManager.js +47 -21
  255. package/dist/core/tools/permissions/ToolPermissionManager.js.map +1 -1
  256. package/dist/core/vision/VisionPipeline.d.ts +437 -0
  257. package/dist/core/vision/VisionPipeline.d.ts.map +1 -0
  258. package/dist/core/vision/VisionPipeline.js +1113 -0
  259. package/dist/core/vision/VisionPipeline.js.map +1 -0
  260. package/dist/core/vision/index.d.ts +97 -0
  261. package/dist/core/vision/index.d.ts.map +1 -0
  262. package/dist/core/vision/index.js +182 -0
  263. package/dist/core/vision/index.js.map +1 -0
  264. package/dist/core/vision/providers/LLMVisionProvider.d.ts +135 -0
  265. package/dist/core/vision/providers/LLMVisionProvider.d.ts.map +1 -0
  266. package/dist/core/vision/providers/LLMVisionProvider.js +136 -0
  267. package/dist/core/vision/providers/LLMVisionProvider.js.map +1 -0
  268. package/dist/core/vision/providers/PipelineVisionProvider.d.ts +154 -0
  269. package/dist/core/vision/providers/PipelineVisionProvider.d.ts.map +1 -0
  270. package/dist/core/vision/providers/PipelineVisionProvider.js +160 -0
  271. package/dist/core/vision/providers/PipelineVisionProvider.js.map +1 -0
  272. package/dist/core/vision/types.d.ts +286 -0
  273. package/dist/core/vision/types.d.ts.map +1 -0
  274. package/dist/core/vision/types.js +24 -0
  275. package/dist/core/vision/types.js.map +1 -0
  276. package/dist/discovery/CapabilityDiscoveryEngine.d.ts +1 -1
  277. package/dist/discovery/CapabilityDiscoveryEngine.d.ts.map +1 -1
  278. package/dist/discovery/CapabilityDiscoveryEngine.js +1 -1
  279. package/dist/discovery/CapabilityDiscoveryEngine.js.map +1 -1
  280. package/dist/emergent/ComposableToolBuilder.d.ts +15 -4
  281. package/dist/emergent/ComposableToolBuilder.d.ts.map +1 -1
  282. package/dist/emergent/ComposableToolBuilder.js +29 -14
  283. package/dist/emergent/ComposableToolBuilder.js.map +1 -1
  284. package/dist/emergent/EmergentCapabilityEngine.d.ts +3 -3
  285. package/dist/emergent/EmergentCapabilityEngine.d.ts.map +1 -1
  286. package/dist/emergent/EmergentCapabilityEngine.js +15 -12
  287. package/dist/emergent/EmergentCapabilityEngine.js.map +1 -1
  288. package/dist/emergent/EmergentJudge.d.ts +20 -0
  289. package/dist/emergent/EmergentJudge.d.ts.map +1 -1
  290. package/dist/emergent/EmergentJudge.js +121 -26
  291. package/dist/emergent/EmergentJudge.js.map +1 -1
  292. package/dist/emergent/EmergentToolRegistry.d.ts +17 -0
  293. package/dist/emergent/EmergentToolRegistry.d.ts.map +1 -1
  294. package/dist/emergent/EmergentToolRegistry.js +26 -0
  295. package/dist/emergent/EmergentToolRegistry.js.map +1 -1
  296. package/dist/emergent/ForgeToolMetaTool.d.ts +1 -1
  297. package/dist/emergent/ForgeToolMetaTool.d.ts.map +1 -1
  298. package/dist/emergent/ForgeToolMetaTool.js +15 -2
  299. package/dist/emergent/ForgeToolMetaTool.js.map +1 -1
  300. package/dist/emergent/SandboxedToolForge.d.ts +2 -2
  301. package/dist/emergent/SandboxedToolForge.d.ts.map +1 -1
  302. package/dist/emergent/SandboxedToolForge.js +13 -23
  303. package/dist/emergent/SandboxedToolForge.js.map +1 -1
  304. package/dist/emergent/SkillExporter.d.ts +119 -0
  305. package/dist/emergent/SkillExporter.d.ts.map +1 -0
  306. package/dist/emergent/SkillExporter.js +344 -0
  307. package/dist/emergent/SkillExporter.js.map +1 -0
  308. package/dist/emergent/index.d.ts +1 -0
  309. package/dist/emergent/index.d.ts.map +1 -1
  310. package/dist/emergent/index.js +1 -0
  311. package/dist/emergent/index.js.map +1 -1
  312. package/dist/emergent/types.d.ts +4 -4
  313. package/dist/index.d.ts +30 -5
  314. package/dist/index.d.ts.map +1 -1
  315. package/dist/index.js +19 -2
  316. package/dist/index.js.map +1 -1
  317. package/dist/memory/facade/Memory.d.ts.map +1 -1
  318. package/dist/memory/facade/Memory.js +8 -0
  319. package/dist/memory/facade/Memory.js.map +1 -1
  320. package/dist/memory/facade/types.d.ts +10 -0
  321. package/dist/memory/facade/types.d.ts.map +1 -1
  322. package/dist/memory/index.d.ts +15 -7
  323. package/dist/memory/index.d.ts.map +1 -1
  324. package/dist/memory/index.js +7 -0
  325. package/dist/memory/index.js.map +1 -1
  326. package/dist/memory/ingestion/DoclingLoader.d.ts +3 -3
  327. package/dist/memory/ingestion/DoclingLoader.d.ts.map +1 -1
  328. package/dist/memory/ingestion/DoclingLoader.js +12 -8
  329. package/dist/memory/ingestion/DoclingLoader.js.map +1 -1
  330. package/dist/memory/ingestion/FolderScanner.d.ts +7 -7
  331. package/dist/memory/ingestion/FolderScanner.d.ts.map +1 -1
  332. package/dist/memory/ingestion/FolderScanner.js +6 -6
  333. package/dist/memory/ingestion/FolderScanner.js.map +1 -1
  334. package/dist/memory/ingestion/LoaderRegistry.d.ts +8 -8
  335. package/dist/memory/ingestion/LoaderRegistry.d.ts.map +1 -1
  336. package/dist/memory/ingestion/LoaderRegistry.js +9 -11
  337. package/dist/memory/ingestion/LoaderRegistry.js.map +1 -1
  338. package/dist/memory/ingestion/MultimodalAggregator.d.ts +1 -1
  339. package/dist/memory/ingestion/MultimodalAggregator.js +1 -1
  340. package/dist/memory/ingestion/OcrPdfLoader.d.ts +2 -2
  341. package/dist/memory/ingestion/OcrPdfLoader.d.ts.map +1 -1
  342. package/dist/memory/ingestion/OcrPdfLoader.js +12 -8
  343. package/dist/memory/ingestion/OcrPdfLoader.js.map +1 -1
  344. package/dist/memory/ingestion/PdfLoader.d.ts +8 -8
  345. package/dist/memory/ingestion/PdfLoader.d.ts.map +1 -1
  346. package/dist/memory/ingestion/PdfLoader.js +13 -10
  347. package/dist/memory/ingestion/PdfLoader.js.map +1 -1
  348. package/dist/memory/io/MarkdownExporter.d.ts +1 -1
  349. package/dist/memory/io/MarkdownExporter.d.ts.map +1 -1
  350. package/dist/memory/io/MarkdownExporter.js +1 -1
  351. package/dist/memory/io/MarkdownExporter.js.map +1 -1
  352. package/dist/memory/observation/MemoryObserver.d.ts +63 -1
  353. package/dist/memory/observation/MemoryObserver.d.ts.map +1 -1
  354. package/dist/memory/observation/MemoryObserver.js +115 -4
  355. package/dist/memory/observation/MemoryObserver.js.map +1 -1
  356. package/dist/memory/observation/ObservationCompressor.d.ts +88 -0
  357. package/dist/memory/observation/ObservationCompressor.d.ts.map +1 -0
  358. package/dist/memory/observation/ObservationCompressor.js +207 -0
  359. package/dist/memory/observation/ObservationCompressor.js.map +1 -0
  360. package/dist/memory/observation/ObservationReflector.d.ts +82 -0
  361. package/dist/memory/observation/ObservationReflector.d.ts.map +1 -0
  362. package/dist/memory/observation/ObservationReflector.js +212 -0
  363. package/dist/memory/observation/ObservationReflector.js.map +1 -0
  364. package/dist/memory/observation/temporal.d.ts +54 -0
  365. package/dist/memory/observation/temporal.d.ts.map +1 -0
  366. package/dist/memory/observation/temporal.js +115 -0
  367. package/dist/memory/observation/temporal.js.map +1 -0
  368. package/dist/memory/tools/MemoryAddTool.d.ts +2 -2
  369. package/dist/memory/tools/MemoryAddTool.d.ts.map +1 -1
  370. package/dist/memory/tools/MemoryAddTool.js +8 -3
  371. package/dist/memory/tools/MemoryAddTool.js.map +1 -1
  372. package/dist/memory/tools/MemorySearchTool.d.ts +3 -3
  373. package/dist/memory/tools/MemorySearchTool.d.ts.map +1 -1
  374. package/dist/memory/tools/MemorySearchTool.js +11 -9
  375. package/dist/memory/tools/MemorySearchTool.js.map +1 -1
  376. package/dist/memory/tools/scopeContext.d.ts +11 -0
  377. package/dist/memory/tools/scopeContext.d.ts.map +1 -0
  378. package/dist/memory/tools/scopeContext.js +46 -0
  379. package/dist/memory/tools/scopeContext.js.map +1 -0
  380. package/dist/orchestration/builders/AgentGraph.d.ts +12 -11
  381. package/dist/orchestration/builders/AgentGraph.d.ts.map +1 -1
  382. package/dist/orchestration/builders/AgentGraph.js +12 -11
  383. package/dist/orchestration/builders/AgentGraph.js.map +1 -1
  384. package/dist/orchestration/builders/VoiceNodeBuilder.d.ts +82 -25
  385. package/dist/orchestration/builders/VoiceNodeBuilder.d.ts.map +1 -1
  386. package/dist/orchestration/builders/VoiceNodeBuilder.js +86 -26
  387. package/dist/orchestration/builders/VoiceNodeBuilder.js.map +1 -1
  388. package/dist/orchestration/builders/WorkflowBuilder.d.ts +1 -1
  389. package/dist/orchestration/builders/WorkflowBuilder.d.ts.map +1 -1
  390. package/dist/orchestration/builders/WorkflowBuilder.js +1 -1
  391. package/dist/orchestration/builders/WorkflowBuilder.js.map +1 -1
  392. package/dist/orchestration/checkpoint/InMemoryCheckpointStore.d.ts +7 -54
  393. package/dist/orchestration/checkpoint/InMemoryCheckpointStore.d.ts.map +1 -1
  394. package/dist/orchestration/checkpoint/InMemoryCheckpointStore.js +8 -56
  395. package/dist/orchestration/checkpoint/InMemoryCheckpointStore.js.map +1 -1
  396. package/dist/orchestration/events/GraphEvent.d.ts +67 -5
  397. package/dist/orchestration/events/GraphEvent.d.ts.map +1 -1
  398. package/dist/orchestration/events/GraphEvent.js.map +1 -1
  399. package/dist/orchestration/runtime/GraphRuntime.d.ts.map +1 -1
  400. package/dist/orchestration/runtime/GraphRuntime.js +151 -1
  401. package/dist/orchestration/runtime/GraphRuntime.js.map +1 -1
  402. package/dist/orchestration/runtime/LoopController.d.ts +3 -3
  403. package/dist/orchestration/runtime/LoopController.d.ts.map +1 -1
  404. package/dist/orchestration/runtime/LoopController.js.map +1 -1
  405. package/dist/orchestration/runtime/StateManager.d.ts +3 -3
  406. package/dist/orchestration/runtime/StateManager.js +3 -3
  407. package/dist/orchestration/runtime/VoiceNodeExecutor.d.ts +103 -26
  408. package/dist/orchestration/runtime/VoiceNodeExecutor.d.ts.map +1 -1
  409. package/dist/orchestration/runtime/VoiceNodeExecutor.js +155 -43
  410. package/dist/orchestration/runtime/VoiceNodeExecutor.js.map +1 -1
  411. package/dist/orchestration/runtime/VoiceTransportAdapter.d.ts +95 -33
  412. package/dist/orchestration/runtime/VoiceTransportAdapter.d.ts.map +1 -1
  413. package/dist/orchestration/runtime/VoiceTransportAdapter.js +83 -29
  414. package/dist/orchestration/runtime/VoiceTransportAdapter.js.map +1 -1
  415. package/dist/orchestration/runtime/VoiceTurnCollector.d.ts +73 -20
  416. package/dist/orchestration/runtime/VoiceTurnCollector.d.ts.map +1 -1
  417. package/dist/orchestration/runtime/VoiceTurnCollector.js +84 -23
  418. package/dist/orchestration/runtime/VoiceTurnCollector.js.map +1 -1
  419. package/dist/query-router/KeywordFallback.d.ts +70 -0
  420. package/dist/query-router/KeywordFallback.d.ts.map +1 -0
  421. package/dist/query-router/KeywordFallback.js +132 -0
  422. package/dist/query-router/KeywordFallback.js.map +1 -0
  423. package/dist/query-router/QueryClassifier.d.ts +140 -0
  424. package/dist/query-router/QueryClassifier.d.ts.map +1 -0
  425. package/dist/query-router/QueryClassifier.js +223 -0
  426. package/dist/query-router/QueryClassifier.js.map +1 -0
  427. package/dist/query-router/QueryDispatcher.d.ts +139 -0
  428. package/dist/query-router/QueryDispatcher.d.ts.map +1 -0
  429. package/dist/query-router/QueryDispatcher.js +297 -0
  430. package/dist/query-router/QueryDispatcher.js.map +1 -0
  431. package/dist/query-router/QueryGenerator.d.ts +184 -0
  432. package/dist/query-router/QueryGenerator.d.ts.map +1 -0
  433. package/dist/query-router/QueryGenerator.js +241 -0
  434. package/dist/query-router/QueryGenerator.js.map +1 -0
  435. package/dist/query-router/QueryRouter.d.ts +292 -0
  436. package/dist/query-router/QueryRouter.d.ts.map +1 -0
  437. package/dist/query-router/QueryRouter.js +803 -0
  438. package/dist/query-router/QueryRouter.js.map +1 -0
  439. package/dist/query-router/TopicExtractor.d.ts +73 -0
  440. package/dist/query-router/TopicExtractor.d.ts.map +1 -0
  441. package/dist/query-router/TopicExtractor.js +95 -0
  442. package/dist/query-router/TopicExtractor.js.map +1 -0
  443. package/dist/query-router/index.d.ts +40 -0
  444. package/dist/query-router/index.d.ts.map +1 -0
  445. package/dist/query-router/index.js +46 -0
  446. package/dist/query-router/index.js.map +1 -0
  447. package/dist/query-router/types.d.ts +508 -0
  448. package/dist/query-router/types.d.ts.map +1 -0
  449. package/dist/query-router/types.js +39 -0
  450. package/dist/query-router/types.js.map +1 -0
  451. package/dist/rag/index.d.ts +5 -0
  452. package/dist/rag/index.d.ts.map +1 -1
  453. package/dist/rag/index.js +7 -0
  454. package/dist/rag/index.js.map +1 -1
  455. package/dist/rag/multimodal/LLMVisionAdapter.d.ts +43 -0
  456. package/dist/rag/multimodal/LLMVisionAdapter.d.ts.map +1 -0
  457. package/dist/rag/multimodal/LLMVisionAdapter.js +46 -0
  458. package/dist/rag/multimodal/LLMVisionAdapter.js.map +1 -0
  459. package/dist/rag/multimodal/MultimodalIndexer.d.ts +244 -0
  460. package/dist/rag/multimodal/MultimodalIndexer.d.ts.map +1 -0
  461. package/dist/rag/multimodal/MultimodalIndexer.js +411 -0
  462. package/dist/rag/multimodal/MultimodalIndexer.js.map +1 -0
  463. package/dist/rag/multimodal/MultimodalMemoryBridge.d.ts +448 -0
  464. package/dist/rag/multimodal/MultimodalMemoryBridge.d.ts.map +1 -0
  465. package/dist/rag/multimodal/MultimodalMemoryBridge.js +941 -0
  466. package/dist/rag/multimodal/MultimodalMemoryBridge.js.map +1 -0
  467. package/dist/rag/multimodal/SpeechProviderAdapter.d.ts +139 -0
  468. package/dist/rag/multimodal/SpeechProviderAdapter.d.ts.map +1 -0
  469. package/dist/rag/multimodal/SpeechProviderAdapter.js +143 -0
  470. package/dist/rag/multimodal/SpeechProviderAdapter.js.map +1 -0
  471. package/dist/rag/multimodal/createMultimodalIndexerFromResolver.d.ts +172 -0
  472. package/dist/rag/multimodal/createMultimodalIndexerFromResolver.d.ts.map +1 -0
  473. package/dist/rag/multimodal/createMultimodalIndexerFromResolver.js +152 -0
  474. package/dist/rag/multimodal/createMultimodalIndexerFromResolver.js.map +1 -0
  475. package/dist/rag/multimodal/index.d.ts +44 -0
  476. package/dist/rag/multimodal/index.d.ts.map +1 -0
  477. package/dist/rag/multimodal/index.js +42 -0
  478. package/dist/rag/multimodal/index.js.map +1 -0
  479. package/dist/rag/multimodal/types.d.ts +276 -0
  480. package/dist/rag/multimodal/types.d.ts.map +1 -0
  481. package/dist/rag/multimodal/types.js +26 -0
  482. package/dist/rag/multimodal/types.js.map +1 -0
  483. package/dist/social-posting/SocialPostManager.d.ts +3 -3
  484. package/dist/social-posting/SocialPostManager.d.ts.map +1 -1
  485. package/dist/social-posting/SocialPostManager.js +3 -5
  486. package/dist/social-posting/SocialPostManager.js.map +1 -1
  487. package/dist/speech/FallbackProxy.d.ts +6 -6
  488. package/dist/speech/FallbackProxy.d.ts.map +1 -1
  489. package/dist/speech/FallbackProxy.js +3 -3
  490. package/dist/speech/FallbackProxy.js.map +1 -1
  491. package/dist/speech/SpeechProviderResolver.d.ts +8 -8
  492. package/dist/speech/SpeechProviderResolver.d.ts.map +1 -1
  493. package/dist/speech/SpeechProviderResolver.js +22 -11
  494. package/dist/speech/SpeechProviderResolver.js.map +1 -1
  495. package/dist/speech/SpeechRuntime.d.ts +1 -5
  496. package/dist/speech/SpeechRuntime.d.ts.map +1 -1
  497. package/dist/speech/SpeechRuntime.js +17 -9
  498. package/dist/speech/SpeechRuntime.js.map +1 -1
  499. package/dist/speech/providers/AssemblyAISTTProvider.d.ts +4 -4
  500. package/dist/speech/providers/AssemblyAISTTProvider.js +4 -4
  501. package/dist/speech/providers/AzureSpeechTTSProvider.d.ts +3 -3
  502. package/dist/speech/providers/AzureSpeechTTSProvider.js +2 -2
  503. package/dist/speech/providers/AzureSpeechTTSProvider.js.map +1 -1
  504. package/dist/speech/providers/BuiltInAdaptiveVadProvider.d.ts +9 -9
  505. package/dist/speech/providers/BuiltInAdaptiveVadProvider.d.ts.map +1 -1
  506. package/dist/speech/providers/BuiltInAdaptiveVadProvider.js +5 -5
  507. package/dist/speech/providers/BuiltInAdaptiveVadProvider.js.map +1 -1
  508. package/dist/speech/providers/DeepgramBatchSTTProvider.d.ts +2 -2
  509. package/dist/speech/providers/DeepgramBatchSTTProvider.js +2 -2
  510. package/dist/speech/providers/OpenAITextToSpeechProvider.d.ts +3 -3
  511. package/dist/speech/providers/OpenAITextToSpeechProvider.js +2 -2
  512. package/dist/speech/providers/OpenAIWhisperSpeechToTextProvider.d.ts +1 -1
  513. package/dist/speech/providers/OpenAIWhisperSpeechToTextProvider.d.ts.map +1 -1
  514. package/dist/speech/providers/OpenAIWhisperSpeechToTextProvider.js +1 -1
  515. package/dist/speech/providers/OpenAIWhisperSpeechToTextProvider.js.map +1 -1
  516. package/dist/voice/TelephonyStreamTransport.d.ts +6 -6
  517. package/dist/voice/TelephonyStreamTransport.d.ts.map +1 -1
  518. package/dist/voice/TelephonyStreamTransport.js +5 -5
  519. package/dist/voice/TelephonyStreamTransport.js.map +1 -1
  520. package/dist/voice-pipeline/AcousticEndpointDetector.d.ts +4 -4
  521. package/dist/voice-pipeline/AcousticEndpointDetector.d.ts.map +1 -1
  522. package/dist/voice-pipeline/AcousticEndpointDetector.js +4 -4
  523. package/dist/voice-pipeline/AcousticEndpointDetector.js.map +1 -1
  524. package/dist/voice-pipeline/HardCutBargeinHandler.d.ts +3 -3
  525. package/dist/voice-pipeline/HardCutBargeinHandler.js +3 -3
  526. package/dist/voice-pipeline/HeuristicEndpointDetector.d.ts +3 -3
  527. package/dist/voice-pipeline/HeuristicEndpointDetector.d.ts.map +1 -1
  528. package/dist/voice-pipeline/HeuristicEndpointDetector.js +3 -3
  529. package/dist/voice-pipeline/HeuristicEndpointDetector.js.map +1 -1
  530. package/dist/voice-pipeline/SoftFadeBargeinHandler.d.ts +5 -5
  531. package/dist/voice-pipeline/SoftFadeBargeinHandler.js +1 -1
  532. package/dist/voice-pipeline/VoiceInterruptError.d.ts +6 -6
  533. package/dist/voice-pipeline/VoiceInterruptError.d.ts.map +1 -1
  534. package/dist/voice-pipeline/VoiceInterruptError.js +4 -4
  535. package/dist/voice-pipeline/VoiceInterruptError.js.map +1 -1
  536. package/dist/voice-pipeline/VoicePipelineOrchestrator.d.ts +9 -9
  537. package/dist/voice-pipeline/VoicePipelineOrchestrator.d.ts.map +1 -1
  538. package/dist/voice-pipeline/VoicePipelineOrchestrator.js +8 -8
  539. package/dist/voice-pipeline/VoicePipelineOrchestrator.js.map +1 -1
  540. package/dist/voice-pipeline/WebRTCStreamTransport.d.ts +421 -0
  541. package/dist/voice-pipeline/WebRTCStreamTransport.d.ts.map +1 -0
  542. package/dist/voice-pipeline/WebRTCStreamTransport.js +573 -0
  543. package/dist/voice-pipeline/WebRTCStreamTransport.js.map +1 -0
  544. package/dist/voice-pipeline/WebSocketStreamTransport.d.ts +8 -8
  545. package/dist/voice-pipeline/WebSocketStreamTransport.js +5 -5
  546. package/dist/voice-pipeline/index.d.ts +1 -0
  547. package/dist/voice-pipeline/index.d.ts.map +1 -1
  548. package/dist/voice-pipeline/index.js +2 -0
  549. package/dist/voice-pipeline/index.js.map +1 -1
  550. package/dist/voice-pipeline/types.d.ts +43 -43
  551. package/dist/voice-pipeline/types.d.ts.map +1 -1
  552. 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 {@link VoiceTurnCollector}, and racing
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}. It creates an internal `AbortController` for barge-in
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` the bidirectional transport EventEmitter (emits `close` / `disconnected`).
14
- * - `voiceTransport._voiceSession` the voice pipeline session EventEmitter that fires
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** transport emits `close` or `disconnected`.
33
- * - **Turns exhausted** session emits `turn_complete` and the collector's count
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** a `final_transcript` event contains one of `config.exitKeywords`.
36
- * - **Silence timeout** no speech activity for 30 seconds (when `exitOn: 'silence-timeout'`).
37
- * - **Abort/barge-in** the internal `AbortController` is signalled, either by a
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); // 'turns-exhausted' | 'hangup' | 'keyword:goodbye' | ...
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
- * Creates an internal `AbortController` for barge-in, wires up a
60
- * {@link VoiceTurnCollector} on the session, and races exit conditions to
61
- * determine when the node completes.
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
- // Internal AbortController for barge-in or parent cancellation.
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, forward its abort to ours.
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), { once: true });
121
+ parentSignal.addEventListener('abort', () => controller.abort(parentSignal.reason), {
122
+ once: true,
123
+ });
79
124
  }
80
- // Voice transport must be pre-placed in state.scratch by the graph runtime.
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 continue from a prior turn index.
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
- // Emit session lifecycle event: started.
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 plain EventEmitter.
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 it subscribes to session events and buffers transcript.
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
- // Resolve exitReason routeTarget from node edges.
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 for scratch so the runtime can persist/restore later.
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
- // Emit session lifecycle event: ended.
110
- this.eventSink({ type: 'voice_session', nodeId: node.id, action: 'ended', exitReason: result.reason });
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 treat as a successful exit
126
- // with exitReason: 'interrupted' so the graph can route accordingly.
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({ type: 'voice_session', nodeId: node.id, action: 'ended', exitReason: 'interrupted' });
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 surface as a failed result.
144
- this.eventSink({ type: 'voice_session', nodeId: node.id, action: 'ended', exitReason: 'error' });
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
- * Listeners are attached to the session and transport EventEmitters. The
156
- * `AbortController` signal is also monitored — if it fires with a
157
- * {@link VoiceInterruptError} the Promise rejects (handled by the caller),
158
- * otherwise it resolves with `{ reason: 'interrupted' }`.
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
- * @param collector - Active turn collector tracking turn count.
162
- * @param config - Voice node configuration with exit settings.
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
- /** Prevent double-resolution from multiple conditions firing simultaneously. */
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
- * @param result - The exit condition result.
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 called on any speech activity. */
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;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAItC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;AA0BlF,8EAA8E;AAC9E,oBAAoB;AACpB,8EAA8E;AAE9E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,OAAO,iBAAiB;IAC5B;;;OAGG;IACH,YACmB,SAAsC;QAAtC,cAAS,GAAT,SAAS,CAA6B;IACtD,CAAC;IAEJ;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,OAAO,CACX,IAAe,EACf,KAA0B;QAE1B,MAAM,MAAM,GAAG,IAAI,CAAC,cAAc,CAAC;QACnC,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC5B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,2CAA2C,EAAE,CAAC;QAChF,CAAC;QACD,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;QAEvC,gEAAgE;QAChE,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;QAEzC,yEAAyE;QACzE,MAAM,YAAY,GAAI,KAAa,EAAE,OAAO,EAAE,WAAsC,CAAC;QACrF,IAAI,YAAY,EAAE,CAAC;YACjB,YAAY,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAA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AAU,CAAC,MAAM,CAAC,MAAM,CAAC;gBACxC,IAAI,MAAM,YAAY,mBAAmB,EAAE,CAAC;oBAC1C,MAAM,CAAC,MAAM,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
- * The adapter is lazy — it does not create a `VoicePipelineOrchestrator` until
13
- * `init()` is called. The pipeline reference is `any` typed to avoid a hard
14
- * import cycle with the voice subsystem; callers that want stronger types may
15
- * cast.
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 defaults are resolved from agent.config.json or
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'` interrupt TTS immediately when speech is detected.
50
- * - `'soft-fade'` ramp TTS volume down before cutting.
51
- * - `'disabled'` ignore user speech while the agent is speaking.
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'` energy/VAD-based detection.
57
- * - `'heuristic'` punctuation + silence heuristics.
58
- * - `'semantic'` LLM-assisted turn boundary detection.
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
- /** Tracks whether `init()` has been called successfully. */
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
- * @param config - Voice pipeline configuration knobs.
91
- * @param transport - Bidirectional audio/control stream transport (`IStreamTransport`).
92
- * @param eventSink - Callback receiving all `GraphEvent` values emitted by this adapter.
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` so
100
- * that graph nodes can access it if needed, then emits a `voice_session` started
101
- * event to signal that the voice session is live.
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 {@link getNodeInput} or
104
- * {@link deliverNodeOutput}.
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()`. In the current implementation
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 emitted event.
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). In a full production implementation
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
- * @param output - Text or async token stream to synthesise as speech.
138
- * @throws {Error} If called before `init()`.
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. Emits a `voice_barge_in` event
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAM1D;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACnC,+DAA+D;IAC/D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,iEAAiE;IACjE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,0DAA0D;IAC1D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wEAAwE;IACxE,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAMD;;;;;;;;;;GAUG;AACH,qBAAa,qBAAqB;IAiB9B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAlB5B;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAoB;IAEpC,4DAA4D;IAC5D,OAAO,CAAC,WAAW,CAAS;IAE5B;;;;OAIG;gBAEgB,MAAM,EAAE,oBAA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