@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
@@ -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
  // ---------------------------------------------------------------------------
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
- * @param config - Voice pipeline configuration knobs.
48
- * @param transport - Bidirectional audio/control stream transport (`IStreamTransport`).
49
- * @param eventSink - Callback receiving all `GraphEvent` values emitted by this adapter.
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
- /** Tracks whether `init()` has been called successfully. */
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` so
72
- * that graph nodes can access it if needed, then emits a `voice_session` started
73
- * event to signal that the voice session is live.
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 {@link getNodeInput} or
76
- * {@link deliverNodeOutput}.
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()`. In the current implementation
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 emitted event.
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 real implementation: this.pipeline.waitForUserTurn()
113
- // For now, listen directly to transport events.
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). In a full production implementation
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
- * @param output - Text or async token stream to synthesise as speech.
140
- * @throws {Error} If called before `init()`.
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 real implementation: this.pipeline.pushToTTS(output)
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. Emits a `voice_barge_in` event
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AA2CH,8EAA8E;AAC9E,wBAAwB;AACxB,8EAA8E;AAE9E;;;;;;;;;;GAUG;AACH,MAAM,OAAO,qBAAqB;IAWhC;;;;OAIG;IACH,YACmB,MAA4B,EAC5B,SAAc,EAAE,mBAAmB;IACnC,SAAsC;QAFtC,W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,CAAC;gBAEH,OAAO,CAAC,UAAU,CAAC,CAAC;YACtB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,iBAAiB,CAAC,MAAc,EAAE,OAAuC;QAC7E,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;QAC3D,CAAC;QAED,0DAA0D;QAC1D,8CAA8C;QAC9C,IAAI,CAAC,SAAS,CAAC;YACb,IAAI,EAAE,aAAa;YACnB,MAAM;YACN,SAAS,EAAE,UAAU;YACrB,MAAM,EAAE,KAAK;YACb,UAAU,EAAE,CAAC;SACd,CAAC,CAAC;IACL,CAAC;IAED,4EAA4E;IAC5E,WAAW;IACX,4EAA4E;IAE5E;;;;;;OAMG;IACH,aAAa;QACX,IAAI,CAAC,SAAS,CAAC;YACb,IAAI,EAAE,gBAAgB;YACtB,MAAM,EAAE,eAAe;YACvB,eAAe,EAAE,EAAE;YACnB,UAAU,EAAE,EAAE;SACf,CAAC,CAAC;IACL,CAAC;IAED,4EAA4E;IAC5E,WAAW;IACX,4EAA4E;IAE5E;;;;;OAKG;IACH,KAAK,CAAC,OAAO;QACX,IAAI,CAAC,SAAS,CAAC;YACb,IAAI,EAAE,eAAe;YACrB,MAAM,EAAE,eAAe;YACvB,MAAM,EAAE,OAAO;YACf,UAAU,EAAE,oBAAoB;SACjC,CAAC,CAAC;QACH,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAC3B,CAAC;CACF"}
1
+ {"version":3,"file":"VoiceTransportAdapter.js","sourceRoot":"","sources":["../../../src/orchestration/runtime/VoiceTransportAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AA8DH,8EAA8E;AAC9E,wBAAwB;AACxB,8EAA8E;AAE9E;;;;;;;;;;;;;;;;;;;;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  * @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
- * - `interim_transcript` partial STT result; forwarded as a non-final
11
- * `voice_transcript` GraphEvent but **not** buffered (too noisy).
12
- * - `final_transcript` confirmed STT result; buffered in `transcript` and
13
- * forwarded as a final `voice_transcript` GraphEvent.
14
- * - `turn_complete` endpoint detection fired; increments `turnCount` and
15
- * emits a `voice_turn_complete` GraphEvent.
16
- * - `barge_in` — user interrupted the agent mid-speech; emits a
17
- * `voice_barge_in` GraphEvent.
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 this buffer interim partials are
29
- * discarded to keep the transcript clean and avoid duplicate entries.
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
- /** Speaker identifier as reported by the STT service (e.g. `"Speaker_0"`). */
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
- /** Speaker identifier from the most recent `final_transcript` event. */
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
- * @param eventSink - Callback invoked synchronously for every emitted `GraphEvent`.
72
- * @param nodeId - Identifies the owning graph node in every emitted event.
73
- * @param initialTurnCount - Seed value for `turnCount`; pass a persisted value to
74
- * resume from a checkpoint rather than starting at zero.
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 entries are append-only and must remain ordered.
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;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAM1D;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,8EAA8E;IAC9E,OAAO,EAAE,MAAM,CAAC;IAChB,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB;AAMD;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,kBAAkB;IAmB3B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM;IAnBzB,4DAA4D;IAC5D,OAAO,CAAC,UAAU,CAAyB;IAE3C,4DAA4D;IAC5D,OAAO,CAAC,SAAS,CAAS;IAE1B,wEAAwE;IACxE,OAAO,CAAC,WAAW,CAAM;IAEzB;;;;;;OAMG;gBAED,OAAO,EAAE,YAAY,EACJ,SAAS,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,EACtC,MAAM,EAAE,MAAM,EAC/B,gBAAgB,SAAI;IA6EtB;;;OAGG;IACH,YAAY,IAAI,MAAM;IAItB;;;;;OAKG;IACH,aAAa,IAAI,eAAe,EAAE;IAIlC;;;OAGG;IACH,cAAc,IAAI,MAAM;CAGzB"}
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
- * - `interim_transcript` partial STT result; forwarded as a non-final
11
- * `voice_transcript` GraphEvent but **not** buffered (too noisy).
12
- * - `final_transcript` confirmed STT result; buffered in `transcript` and
13
- * forwarded as a final `voice_transcript` GraphEvent.
14
- * - `turn_complete` endpoint detection fired; increments `turnCount` and
15
- * emits a `voice_turn_complete` GraphEvent.
16
- * - `barge_in` — user interrupted the agent mid-speech; emits a
17
- * `voice_barge_in` GraphEvent.
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
- * @param eventSink - Callback invoked synchronously for every emitted `GraphEvent`.
48
- * @param nodeId - Identifies the owning graph node in every emitted event.
49
- * @param initialTurnCount - Seed value for `turnCount`; pass a persisted value to
50
- * resume from a checkpoint rather than starting at zero.
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
- /** Speaker identifier from the most recent `final_transcript` event. */
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 partial STT result, forwarded but not buffered
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 confirmed utterance, buffered and forwarded
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 the buffer.
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 endpoint detection fired; advance the turn counter
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 user interrupted agent mid-speech
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 entries are append-only and must remain ordered.
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;;;;;;;;;;;;;;;;;;;;;GAqBG;AA2BH,8EAA8E;AAC9E,qBAAqB;AACrB,8EAA8E;AAE9E;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,kBAAkB;IAU7B;;;;;;OAMG;IACH,YACE,OAAqB,EACJ,SAAsC,EACtC,MAAc,EAC/B,gBAAgB,GAAG,CAAC;QAFH,cAAS,GAAT,SAAS,CAA6B;QACtC,WAAM,GAAN,MAAM,CAAQ;QAnBjC,4DAA4D;QACpD,eAAU,GAAsB,EAAE,CAAC;QAK3C,wEAAwE;QAChE,gBAAW,GAAG,EAAE,CAAC;QAevB,IAAI,CAAC,SAAS,GAAG,gBAAgB,CAAC;QAElC,qEAAqE;QACrE,sEAAsE;QACtE,qEAAqE;QACrE,OAAO,CAAC,EAAE,CAAC,oBAAoB,EAAE,CAAC,GAAQ,EAAE,EAAE;YAC5C,IAAI,CAAC,SAAS,CAAC;gBACb,IAAI,EAAE,kBAAkB;gBACxB,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,IAAI,EAAE,GAAG,CAAC,IAAI,IAAI,EAAE;gBACpB,OAAO,EAAE,KAAK;gBACd,OAAO,EAAE,GAAG,CAAC,OAAO;gBACpB,UAAU,EAAE,GAAG,CAAC,UAAU,IAAI,CAAC;aAChC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,qEAAqE;QACrE,iEAAiE;QACjE,qEAAqE;QACrE,OAAO,CAAC,EAAE,CAAC,kBAAkB,EAAE,CAAC,GAAQ,EAAE,EAAE;YAC1C,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,IAAI,MAAM,CAAC;YAEtC,uDAAuD;YACvD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC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;IACL,CAAC;IAED,8EAA8E;IAC9E,YAAY;IACZ,8EAA8E;IAE9E;;;OAGG;IACH,YAAY;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED;;;;;OAKG;IACH,aAAa;QACX,OAAO,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC;IAC9B,CAAC;IAED;;;OAGG;IACH,cAAc;QACZ,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;CACF"}
1
+ {"version":3,"file":"VoiceTurnCollector.js","sourceRoot":"","sources":["../../../src/orchestration/runtime/VoiceTurnCollector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AA6CH,8EAA8E;AAC9E,qBAAqB;AACrB,8EAA8E;AAE9E;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,OAAO,kBAAkB;IAa7B;;;;;;;;;;;;;;;;;;;OAmBG;IACH,YACE,OAAqB,EACJ,SAAsC,EACtC,MAAc,EAC/B,gBAAgB,GAAG,CAAC;QAFH,cAAS,GAAT,SAAS,CAA6B;QACtC,WAAM,GAAN,MAAM,CAAQ;QAnCjC,yEAAyE;QACjE,eAAU,GAAsB,EAAE,CAAC;QAK3C;;;WAGG;QACK,gBAAW,GAAG,EAAE,CAAC;QA4BvB,IAAI,CAAC,SAAS,GAAG,gBAAgB,CAAC;QAElC,qEAAqE;QACrE,wEAAwE;QACxE,EAAE;QACF,qEAAqE;QACrE,oEAAoE;QACpE,qEAAqE;QACrE,mCAAmC;QACnC,qEAAqE;QACrE,OAAO,CAAC,EAAE,CAAC,oBAAoB,EAAE,CAAC,GAAQ,EAAE,EAAE;YAC5C,IAAI,CAAC,SAAS,CAAC;gBACb,IAAI,EAAE,kBAAkB;gBACxB,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,IAAI,EAAE,GAAG,CAAC,IAAI,IAAI,EAAE;gBACpB,OAAO,EAAE,KAAK;gBACd,OAAO,EAAE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