@moureau/pipeflow 0.0.1 → 0.0.2

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 (311) hide show
  1. package/README.md +245 -117
  2. package/dist/cjs/agents/agent.js +1 -1
  3. package/dist/cjs/agents/agent.js.map +3 -3
  4. package/dist/cjs/agents/tools/tools.js +1 -1
  5. package/dist/cjs/agents/tools/tools.js.map +3 -3
  6. package/dist/cjs/conversations/conversation/conversation.js +1 -1
  7. package/dist/cjs/conversations/conversation/conversation.js.map +3 -3
  8. package/dist/cjs/conversations/conversations.js +1 -1
  9. package/dist/cjs/conversations/conversations.js.map +3 -3
  10. package/dist/cjs/conversations/index.js +1 -1
  11. package/dist/cjs/conversations/index.js.map +3 -3
  12. package/dist/cjs/conversations/orchestration/coordination/coordination.js +10 -0
  13. package/dist/cjs/conversations/orchestration/coordination/coordination.js.map +7 -0
  14. package/dist/cjs/conversations/orchestration/coordination/index.js +2 -0
  15. package/dist/cjs/conversations/orchestration/coordination/index.js.map +7 -0
  16. package/dist/cjs/conversations/orchestration/orchestrator/coordination-runner/coordination-runner.js +4 -0
  17. package/dist/cjs/conversations/orchestration/orchestrator/coordination-runner/coordination-runner.js.map +7 -0
  18. package/dist/cjs/conversations/orchestration/orchestrator/coordination-runner/index.js +2 -0
  19. package/dist/cjs/conversations/orchestration/orchestrator/coordination-runner/index.js.map +7 -0
  20. package/dist/cjs/conversations/orchestration/orchestrator/generation/generation.js +2 -0
  21. package/dist/cjs/conversations/orchestration/orchestrator/generation/generation.js.map +7 -0
  22. package/dist/cjs/conversations/orchestration/orchestrator/generation/index.js +2 -0
  23. package/dist/cjs/conversations/orchestration/orchestrator/generation/index.js.map +7 -0
  24. package/dist/cjs/conversations/orchestration/orchestrator/history/history.js +4 -0
  25. package/dist/cjs/conversations/orchestration/orchestrator/history/history.js.map +7 -0
  26. package/dist/cjs/conversations/orchestration/orchestrator/history/index.js +2 -0
  27. package/dist/cjs/conversations/orchestration/orchestrator/history/index.js.map +7 -0
  28. package/dist/cjs/conversations/orchestration/orchestrator/index.js +1 -1
  29. package/dist/cjs/conversations/orchestration/orchestrator/index.js.map +3 -3
  30. package/dist/cjs/conversations/orchestration/orchestrator/orchestrator.js +1 -2
  31. package/dist/cjs/conversations/orchestration/orchestrator/orchestrator.js.map +3 -3
  32. package/dist/cjs/conversations/orchestration/orchestrator/routing/index.js +2 -0
  33. package/dist/cjs/conversations/orchestration/orchestrator/routing/index.js.map +7 -0
  34. package/dist/cjs/conversations/orchestration/orchestrator/routing/routing.js +23 -0
  35. package/dist/cjs/conversations/orchestration/orchestrator/routing/routing.js.map +7 -0
  36. package/dist/cjs/conversations/orchestration/orchestrator/speech/index.js +2 -0
  37. package/dist/cjs/conversations/orchestration/orchestrator/speech/index.js.map +7 -0
  38. package/dist/cjs/conversations/orchestration/orchestrator/speech/speech.js +2 -0
  39. package/dist/cjs/conversations/orchestration/orchestrator/speech/speech.js.map +7 -0
  40. package/dist/cjs/conversations/orchestration/orchestrator/tools/index.js +2 -0
  41. package/dist/cjs/conversations/orchestration/orchestrator/tools/index.js.map +7 -0
  42. package/dist/cjs/conversations/orchestration/orchestrator/tools/tools.js +2 -0
  43. package/dist/cjs/conversations/orchestration/orchestrator/tools/tools.js.map +7 -0
  44. package/dist/cjs/conversations/orchestration/test-harness.js +2 -0
  45. package/dist/cjs/conversations/orchestration/test-harness.js.map +7 -0
  46. package/dist/cjs/conversations/orchestration/text-chunker/index.js +2 -0
  47. package/dist/cjs/conversations/orchestration/text-chunker/index.js.map +7 -0
  48. package/dist/cjs/conversations/orchestration/text-chunker/text-chunker.js +3 -0
  49. package/dist/cjs/conversations/orchestration/text-chunker/text-chunker.js.map +7 -0
  50. package/dist/cjs/conversations/stream/conversation-stream.js +2 -0
  51. package/dist/cjs/conversations/stream/conversation-stream.js.map +7 -0
  52. package/dist/cjs/conversations/stream/index.js +2 -0
  53. package/dist/cjs/conversations/stream/index.js.map +7 -0
  54. package/dist/cjs/conversations/types.js +1 -1
  55. package/dist/cjs/conversations/types.js.map +2 -2
  56. package/dist/cjs/index.js +1 -1
  57. package/dist/cjs/index.js.map +3 -3
  58. package/dist/cjs/persistence/adapters/sqlite/sqlite.js +18 -14
  59. package/dist/cjs/persistence/adapters/sqlite/sqlite.js.map +3 -3
  60. package/dist/cjs/pipeflow/index.js +2 -0
  61. package/dist/cjs/pipeflow/index.js.map +7 -0
  62. package/dist/cjs/pipeflow/pipeflow.js +2 -0
  63. package/dist/cjs/pipeflow/pipeflow.js.map +7 -0
  64. package/dist/cjs/providers/index.js +1 -1
  65. package/dist/cjs/providers/index.js.map +2 -2
  66. package/dist/cjs/providers/llm/adapters/claude/claude.js +5 -0
  67. package/dist/cjs/providers/llm/adapters/claude/claude.js.map +7 -0
  68. package/dist/cjs/providers/llm/adapters/claude/index.js +2 -0
  69. package/dist/cjs/providers/llm/adapters/claude/index.js.map +7 -0
  70. package/dist/cjs/providers/llm/adapters/deepseek/deepseek.js +1 -1
  71. package/dist/cjs/providers/llm/adapters/deepseek/deepseek.js.map +3 -3
  72. package/dist/cjs/providers/llm/adapters/index.js +1 -1
  73. package/dist/cjs/providers/llm/adapters/index.js.map +3 -3
  74. package/dist/cjs/providers/llm/adapters/openai/index.js +2 -0
  75. package/dist/cjs/providers/llm/adapters/openai/index.js.map +7 -0
  76. package/dist/cjs/providers/llm/adapters/openai/openai.js +2 -0
  77. package/dist/cjs/providers/llm/adapters/openai/openai.js.map +7 -0
  78. package/dist/cjs/providers/llm/adapters/openai-compatible.js +10 -0
  79. package/dist/cjs/providers/llm/adapters/openai-compatible.js.map +7 -0
  80. package/dist/cjs/providers/llm/adapters/openrouter/index.js +2 -0
  81. package/dist/cjs/providers/llm/adapters/openrouter/index.js.map +7 -0
  82. package/dist/cjs/providers/llm/adapters/openrouter/openrouter.js +2 -0
  83. package/dist/cjs/providers/llm/adapters/openrouter/openrouter.js.map +7 -0
  84. package/dist/cjs/providers/llm/index.js +1 -1
  85. package/dist/cjs/providers/llm/index.js.map +3 -3
  86. package/dist/cjs/providers/llm/toolmode/index.js +2 -0
  87. package/dist/cjs/providers/llm/toolmode/index.js.map +7 -0
  88. package/dist/cjs/providers/llm/toolmode/toolmode.js +2 -0
  89. package/dist/cjs/providers/llm/toolmode/toolmode.js.map +7 -0
  90. package/dist/cjs/providers/llm/types.js +1 -1
  91. package/dist/cjs/providers/llm/types.js.map +3 -3
  92. package/dist/cjs/providers/stt/adapters/deepgram/deepgram.js +1 -1
  93. package/dist/cjs/providers/stt/adapters/deepgram/deepgram.js.map +3 -3
  94. package/dist/cjs/providers/stt/adapters/index.js +1 -1
  95. package/dist/cjs/providers/stt/adapters/index.js.map +3 -3
  96. package/dist/cjs/providers/stt/adapters/openrouter/index.js +2 -0
  97. package/dist/cjs/providers/stt/adapters/openrouter/index.js.map +7 -0
  98. package/dist/cjs/providers/stt/adapters/openrouter/openrouter.js +2 -0
  99. package/dist/cjs/providers/stt/adapters/openrouter/openrouter.js.map +7 -0
  100. package/dist/cjs/providers/tts/adapters/index.js +1 -1
  101. package/dist/cjs/providers/tts/adapters/index.js.map +3 -3
  102. package/dist/cjs/providers/tts/adapters/kokoro/kokoro.js +4 -1
  103. package/dist/cjs/providers/tts/adapters/kokoro/kokoro.js.map +3 -3
  104. package/dist/cjs/providers/tts/adapters/openrouter/index.js +2 -0
  105. package/dist/cjs/providers/tts/adapters/openrouter/index.js.map +7 -0
  106. package/dist/cjs/providers/tts/adapters/openrouter/openrouter.js +2 -0
  107. package/dist/cjs/providers/tts/adapters/openrouter/openrouter.js.map +7 -0
  108. package/dist/cjs/transport/streamobject/field-stream/field-stream.js +2 -0
  109. package/dist/cjs/transport/streamobject/field-stream/field-stream.js.map +7 -0
  110. package/dist/cjs/transport/streamobject/field-stream/index.js +2 -0
  111. package/dist/cjs/transport/streamobject/field-stream/index.js.map +7 -0
  112. package/dist/cjs/transport/streamobject/index.js +2 -0
  113. package/dist/cjs/transport/streamobject/index.js.map +7 -0
  114. package/dist/cjs/transport/streamobject/json-adapter/index.js +2 -0
  115. package/dist/cjs/transport/streamobject/json-adapter/index.js.map +7 -0
  116. package/dist/cjs/transport/streamobject/json-adapter/json-adapter.js +4 -0
  117. package/dist/cjs/transport/streamobject/json-adapter/json-adapter.js.map +7 -0
  118. package/dist/cjs/transport/streamobject/reference/index.js +2 -0
  119. package/dist/cjs/transport/streamobject/reference/index.js.map +7 -0
  120. package/dist/cjs/transport/streamobject/reference/reference.js +2 -0
  121. package/dist/cjs/transport/streamobject/reference/reference.js.map +7 -0
  122. package/dist/cjs/transport/streamobject/stream-object/index.js +2 -0
  123. package/dist/cjs/transport/streamobject/stream-object/index.js.map +7 -0
  124. package/dist/cjs/transport/streamobject/stream-object/stream-object.js +2 -0
  125. package/dist/cjs/transport/streamobject/stream-object/stream-object.js.map +7 -0
  126. package/dist/esm/agents/agent.js +1 -1
  127. package/dist/esm/agents/agent.js.map +3 -3
  128. package/dist/esm/agents/tools/tools.js +1 -1
  129. package/dist/esm/agents/tools/tools.js.map +3 -3
  130. package/dist/esm/conversations/conversation/conversation.js +1 -1
  131. package/dist/esm/conversations/conversation/conversation.js.map +3 -3
  132. package/dist/esm/conversations/conversations.js +1 -1
  133. package/dist/esm/conversations/conversations.js.map +3 -3
  134. package/dist/esm/conversations/index.js +1 -1
  135. package/dist/esm/conversations/index.js.map +3 -3
  136. package/dist/esm/conversations/orchestration/coordination/coordination.js +10 -0
  137. package/dist/esm/conversations/orchestration/coordination/coordination.js.map +7 -0
  138. package/dist/esm/conversations/orchestration/coordination/index.js +2 -0
  139. package/dist/esm/conversations/orchestration/coordination/index.js.map +7 -0
  140. package/dist/esm/conversations/orchestration/orchestrator/coordination-runner/coordination-runner.js +4 -0
  141. package/dist/esm/conversations/orchestration/orchestrator/coordination-runner/coordination-runner.js.map +7 -0
  142. package/dist/esm/conversations/orchestration/orchestrator/coordination-runner/index.js +2 -0
  143. package/dist/esm/conversations/orchestration/orchestrator/coordination-runner/index.js.map +7 -0
  144. package/dist/esm/conversations/orchestration/orchestrator/generation/generation.js +2 -0
  145. package/dist/esm/conversations/orchestration/orchestrator/generation/generation.js.map +7 -0
  146. package/dist/esm/conversations/orchestration/orchestrator/generation/index.js +2 -0
  147. package/dist/esm/conversations/orchestration/orchestrator/generation/index.js.map +7 -0
  148. package/dist/esm/conversations/orchestration/orchestrator/history/history.js +4 -0
  149. package/dist/esm/conversations/orchestration/orchestrator/history/history.js.map +7 -0
  150. package/dist/esm/conversations/orchestration/orchestrator/history/index.js +2 -0
  151. package/dist/esm/conversations/orchestration/orchestrator/history/index.js.map +7 -0
  152. package/dist/esm/conversations/orchestration/orchestrator/index.js +1 -1
  153. package/dist/esm/conversations/orchestration/orchestrator/index.js.map +3 -3
  154. package/dist/esm/conversations/orchestration/orchestrator/orchestrator.js +1 -2
  155. package/dist/esm/conversations/orchestration/orchestrator/orchestrator.js.map +3 -3
  156. package/dist/esm/conversations/orchestration/orchestrator/routing/index.js +2 -0
  157. package/dist/esm/conversations/orchestration/orchestrator/routing/index.js.map +7 -0
  158. package/dist/esm/conversations/orchestration/orchestrator/routing/routing.js +23 -0
  159. package/dist/esm/conversations/orchestration/orchestrator/routing/routing.js.map +7 -0
  160. package/dist/esm/conversations/orchestration/orchestrator/speech/index.js +2 -0
  161. package/dist/esm/conversations/orchestration/orchestrator/speech/index.js.map +7 -0
  162. package/dist/esm/conversations/orchestration/orchestrator/speech/speech.js +2 -0
  163. package/dist/esm/conversations/orchestration/orchestrator/speech/speech.js.map +7 -0
  164. package/dist/esm/conversations/orchestration/orchestrator/tools/index.js +2 -0
  165. package/dist/esm/conversations/orchestration/orchestrator/tools/index.js.map +7 -0
  166. package/dist/esm/conversations/orchestration/orchestrator/tools/tools.js +2 -0
  167. package/dist/esm/conversations/orchestration/orchestrator/tools/tools.js.map +7 -0
  168. package/dist/esm/conversations/orchestration/test-harness.js +2 -0
  169. package/dist/esm/conversations/orchestration/test-harness.js.map +7 -0
  170. package/dist/esm/conversations/orchestration/text-chunker/index.js +2 -0
  171. package/dist/esm/conversations/orchestration/text-chunker/index.js.map +7 -0
  172. package/dist/esm/conversations/orchestration/text-chunker/text-chunker.js +3 -0
  173. package/dist/esm/conversations/orchestration/text-chunker/text-chunker.js.map +7 -0
  174. package/dist/esm/conversations/stream/conversation-stream.js +2 -0
  175. package/dist/esm/conversations/stream/conversation-stream.js.map +7 -0
  176. package/dist/esm/conversations/stream/index.js +2 -0
  177. package/dist/esm/conversations/stream/index.js.map +7 -0
  178. package/dist/esm/conversations/types.js +1 -1
  179. package/dist/esm/conversations/types.js.map +2 -2
  180. package/dist/esm/index.js +1 -1
  181. package/dist/esm/index.js.map +3 -3
  182. package/dist/esm/persistence/adapters/sqlite/sqlite.js +18 -14
  183. package/dist/esm/persistence/adapters/sqlite/sqlite.js.map +3 -3
  184. package/dist/esm/pipeflow/index.js +2 -0
  185. package/dist/esm/pipeflow/index.js.map +7 -0
  186. package/dist/esm/pipeflow/pipeflow.js +2 -0
  187. package/dist/esm/pipeflow/pipeflow.js.map +7 -0
  188. package/dist/esm/providers/index.js +1 -1
  189. package/dist/esm/providers/index.js.map +3 -3
  190. package/dist/esm/providers/llm/adapters/claude/claude.js +5 -0
  191. package/dist/esm/providers/llm/adapters/claude/claude.js.map +7 -0
  192. package/dist/esm/providers/llm/adapters/claude/index.js +2 -0
  193. package/dist/esm/providers/llm/adapters/claude/index.js.map +7 -0
  194. package/dist/esm/providers/llm/adapters/deepseek/deepseek.js +1 -1
  195. package/dist/esm/providers/llm/adapters/deepseek/deepseek.js.map +3 -3
  196. package/dist/esm/providers/llm/adapters/index.js +1 -1
  197. package/dist/esm/providers/llm/adapters/index.js.map +3 -3
  198. package/dist/esm/providers/llm/adapters/openai/index.js +2 -0
  199. package/dist/esm/providers/llm/adapters/openai/index.js.map +7 -0
  200. package/dist/esm/providers/llm/adapters/openai/openai.js +2 -0
  201. package/dist/esm/providers/llm/adapters/openai/openai.js.map +7 -0
  202. package/dist/esm/providers/llm/adapters/openai-compatible.js +10 -0
  203. package/dist/esm/providers/llm/adapters/openai-compatible.js.map +7 -0
  204. package/dist/esm/providers/llm/adapters/openrouter/index.js +2 -0
  205. package/dist/esm/providers/llm/adapters/openrouter/index.js.map +7 -0
  206. package/dist/esm/providers/llm/adapters/openrouter/openrouter.js +2 -0
  207. package/dist/esm/providers/llm/adapters/openrouter/openrouter.js.map +7 -0
  208. package/dist/esm/providers/llm/index.js +1 -1
  209. package/dist/esm/providers/llm/index.js.map +3 -3
  210. package/dist/esm/providers/llm/toolmode/index.js +2 -0
  211. package/dist/esm/providers/llm/toolmode/index.js.map +7 -0
  212. package/dist/esm/providers/llm/toolmode/toolmode.js +2 -0
  213. package/dist/esm/providers/llm/toolmode/toolmode.js.map +7 -0
  214. package/dist/esm/providers/llm/types.js +1 -0
  215. package/dist/esm/providers/llm/types.js.map +4 -4
  216. package/dist/esm/providers/stt/adapters/deepgram/deepgram.js +1 -1
  217. package/dist/esm/providers/stt/adapters/deepgram/deepgram.js.map +3 -3
  218. package/dist/esm/providers/stt/adapters/index.js +1 -1
  219. package/dist/esm/providers/stt/adapters/index.js.map +3 -3
  220. package/dist/esm/providers/stt/adapters/openrouter/index.js +2 -0
  221. package/dist/esm/providers/stt/adapters/openrouter/index.js.map +7 -0
  222. package/dist/esm/providers/stt/adapters/openrouter/openrouter.js +2 -0
  223. package/dist/esm/providers/stt/adapters/openrouter/openrouter.js.map +7 -0
  224. package/dist/esm/providers/tts/adapters/index.js +1 -1
  225. package/dist/esm/providers/tts/adapters/index.js.map +3 -3
  226. package/dist/esm/providers/tts/adapters/kokoro/kokoro.js +4 -1
  227. package/dist/esm/providers/tts/adapters/kokoro/kokoro.js.map +3 -3
  228. package/dist/esm/providers/tts/adapters/openrouter/index.js +2 -0
  229. package/dist/esm/providers/tts/adapters/openrouter/index.js.map +7 -0
  230. package/dist/esm/providers/tts/adapters/openrouter/openrouter.js +2 -0
  231. package/dist/esm/providers/tts/adapters/openrouter/openrouter.js.map +7 -0
  232. package/dist/esm/transport/streamobject/field-stream/field-stream.js +2 -0
  233. package/dist/esm/transport/streamobject/field-stream/field-stream.js.map +7 -0
  234. package/dist/esm/transport/streamobject/field-stream/index.js +2 -0
  235. package/dist/esm/transport/streamobject/field-stream/index.js.map +7 -0
  236. package/dist/esm/transport/streamobject/index.js +2 -0
  237. package/dist/esm/transport/streamobject/index.js.map +7 -0
  238. package/dist/esm/transport/streamobject/json-adapter/index.js +2 -0
  239. package/dist/esm/transport/streamobject/json-adapter/index.js.map +7 -0
  240. package/dist/esm/transport/streamobject/json-adapter/json-adapter.js +4 -0
  241. package/dist/esm/transport/streamobject/json-adapter/json-adapter.js.map +7 -0
  242. package/dist/esm/transport/streamobject/reference/index.js +2 -0
  243. package/dist/esm/transport/streamobject/reference/index.js.map +7 -0
  244. package/dist/esm/transport/streamobject/reference/reference.js +2 -0
  245. package/dist/esm/transport/streamobject/reference/reference.js.map +7 -0
  246. package/dist/esm/transport/streamobject/stream-object/index.js +2 -0
  247. package/dist/esm/transport/streamobject/stream-object/index.js.map +7 -0
  248. package/dist/esm/transport/streamobject/stream-object/stream-object.js +2 -0
  249. package/dist/esm/transport/streamobject/stream-object/stream-object.js.map +7 -0
  250. package/dist/types/agents/agent.d.ts +3 -0
  251. package/dist/types/agents/tools/tools.d.ts +28 -6
  252. package/dist/types/conversations/conversation/conversation.d.ts +85 -6
  253. package/dist/types/conversations/conversations.d.ts +11 -1
  254. package/dist/types/conversations/index.d.ts +2 -1
  255. package/dist/types/conversations/orchestration/coordination/coordination.d.ts +192 -0
  256. package/dist/types/conversations/orchestration/coordination/index.d.ts +2 -0
  257. package/dist/types/conversations/orchestration/orchestrator/coordination-runner/coordination-runner.d.ts +108 -0
  258. package/dist/types/conversations/orchestration/orchestrator/coordination-runner/index.d.ts +2 -0
  259. package/dist/types/conversations/orchestration/orchestrator/generation/generation.d.ts +43 -0
  260. package/dist/types/conversations/orchestration/orchestrator/generation/index.d.ts +2 -0
  261. package/dist/types/conversations/orchestration/orchestrator/history/history.d.ts +62 -0
  262. package/dist/types/conversations/orchestration/orchestrator/history/index.d.ts +1 -0
  263. package/dist/types/conversations/orchestration/orchestrator/index.d.ts +10 -0
  264. package/dist/types/conversations/orchestration/orchestrator/orchestrator.d.ts +45 -27
  265. package/dist/types/conversations/orchestration/orchestrator/routing/index.d.ts +1 -0
  266. package/dist/types/conversations/orchestration/orchestrator/routing/routing.d.ts +19 -0
  267. package/dist/types/conversations/orchestration/orchestrator/speech/index.d.ts +2 -0
  268. package/dist/types/conversations/orchestration/orchestrator/speech/speech.d.ts +49 -0
  269. package/dist/types/conversations/orchestration/orchestrator/tools/index.d.ts +2 -0
  270. package/dist/types/conversations/orchestration/orchestrator/tools/tools.d.ts +31 -0
  271. package/dist/types/conversations/orchestration/test-harness.d.ts +96 -0
  272. package/dist/types/conversations/orchestration/text-chunker/index.d.ts +1 -0
  273. package/dist/types/conversations/orchestration/text-chunker/text-chunker.d.ts +39 -0
  274. package/dist/types/conversations/stream/conversation-stream.d.ts +42 -0
  275. package/dist/types/conversations/stream/index.d.ts +1 -0
  276. package/dist/types/conversations/types.d.ts +32 -0
  277. package/dist/types/index.d.ts +5 -38
  278. package/dist/types/pipeflow/index.d.ts +2 -0
  279. package/dist/types/pipeflow/pipeflow.d.ts +35 -0
  280. package/dist/types/providers/index.d.ts +1 -1
  281. package/dist/types/providers/llm/adapters/claude/claude.d.ts +45 -0
  282. package/dist/types/providers/llm/adapters/claude/index.d.ts +2 -0
  283. package/dist/types/providers/llm/adapters/deepseek/deepseek.d.ts +23 -2
  284. package/dist/types/providers/llm/adapters/index.d.ts +3 -0
  285. package/dist/types/providers/llm/adapters/openai/index.d.ts +2 -0
  286. package/dist/types/providers/llm/adapters/openai/openai.d.ts +45 -0
  287. package/dist/types/providers/llm/adapters/openai-compatible.d.ts +44 -0
  288. package/dist/types/providers/llm/adapters/openrouter/index.d.ts +2 -0
  289. package/dist/types/providers/llm/adapters/openrouter/openrouter.d.ts +60 -0
  290. package/dist/types/providers/llm/index.d.ts +5 -2
  291. package/dist/types/providers/llm/toolmode/index.d.ts +2 -0
  292. package/dist/types/providers/llm/toolmode/toolmode.d.ts +99 -0
  293. package/dist/types/providers/llm/types.d.ts +62 -0
  294. package/dist/types/providers/stt/adapters/deepgram/deepgram.d.ts +4 -1
  295. package/dist/types/providers/stt/adapters/index.d.ts +1 -0
  296. package/dist/types/providers/stt/adapters/openrouter/index.d.ts +2 -0
  297. package/dist/types/providers/stt/adapters/openrouter/openrouter.d.ts +94 -0
  298. package/dist/types/providers/tts/adapters/index.d.ts +1 -0
  299. package/dist/types/providers/tts/adapters/kokoro/kokoro.d.ts +17 -2
  300. package/dist/types/providers/tts/adapters/openrouter/index.d.ts +2 -0
  301. package/dist/types/providers/tts/adapters/openrouter/openrouter.d.ts +45 -0
  302. package/dist/types/transport/streamobject/field-stream/field-stream.d.ts +85 -0
  303. package/dist/types/transport/streamobject/field-stream/index.d.ts +2 -0
  304. package/dist/types/transport/streamobject/index.d.ts +8 -0
  305. package/dist/types/transport/streamobject/json-adapter/index.d.ts +2 -0
  306. package/dist/types/transport/streamobject/json-adapter/json-adapter.d.ts +65 -0
  307. package/dist/types/transport/streamobject/reference/index.d.ts +2 -0
  308. package/dist/types/transport/streamobject/reference/reference.d.ts +127 -0
  309. package/dist/types/transport/streamobject/stream-object/index.d.ts +2 -0
  310. package/dist/types/transport/streamobject/stream-object/stream-object.d.ts +31 -0
  311. package/package.json +23 -2
@@ -0,0 +1,108 @@
1
+ import type { Agent } from "../../../../agents/agent.js";
2
+ import type { Conversation } from "../../../conversation/conversation.js";
3
+ import type { LLM } from "../../../../providers/llm/types.js";
4
+ import type { Turn } from "../../../types.js";
5
+ import { Coordination, type CoordinationRegistration, type CoordinationRuntime } from "../../coordination/coordination.js";
6
+ import { ConversationHistory } from "../history/history.js";
7
+ import type { GenerationRunner } from "../generation/generation.js";
8
+ import type { SpeechPipeline } from "../speech/speech.js";
9
+ import type { ToolCallManager } from "../tools/tools.js";
10
+ export interface CoordinationRunnerOptions {
11
+ conversation: Conversation;
12
+ /** Live roster accessor (read at coordination-run time). */
13
+ agents(): Agent[];
14
+ /** Live shared-LLM accessor (undefined in transcription-only mode). */
15
+ llm(): LLM | undefined;
16
+ /** The conversation's message log, seeded into fresh coordination runs. */
17
+ history: ConversationHistory;
18
+ historyWindow: Parameters<ConversationHistory["windowed"]>[0];
19
+ speech: SpeechPipeline;
20
+ generation: GenerationRunner;
21
+ tools: ToolCallManager;
22
+ /** Safety bound on LLM reasoning steps per coordination execution. */
23
+ maxCoordinationSteps: number;
24
+ maxToolIterations: number;
25
+ temperature?: number;
26
+ maxTokens?: number;
27
+ /** The orchestrator's current generation epoch (bumped on interrupt/stop). */
28
+ currentEpoch(): number;
29
+ /** True while the orchestrator is started and the epoch is current. */
30
+ isCurrent(epoch: number): boolean;
31
+ }
32
+ /**
33
+ * The application-specific execution of coordinations: binds the generic
34
+ * `Coordination` primitives to the orchestrator's machinery (roster, shared
35
+ * LLM, history, speech, delegation, budgets, cancellation) and owns the
36
+ * suspension/resume lifecycle — the parked frame stack, the step budget, and
37
+ * the coordination generation records.
38
+ */
39
+ export declare class CoordinationRunner {
40
+ /** Coordinations registered by name (the key is the coordination's name). */
41
+ readonly coordinations: Record<string, Coordination>;
42
+ /** The built-in `understand` coordination, when one is active. */
43
+ understand: Coordination | null;
44
+ private readonly conversation;
45
+ private readonly agents;
46
+ private readonly llm;
47
+ private readonly history;
48
+ private readonly historyWindow;
49
+ private readonly speech;
50
+ private readonly generation;
51
+ private readonly tools;
52
+ private readonly maxCoordinationSteps;
53
+ private readonly maxToolIterations;
54
+ private readonly temperature;
55
+ private readonly maxTokens;
56
+ private readonly currentEpoch;
57
+ private readonly isCurrent;
58
+ private coordinationEpoch;
59
+ private coordinationStepCount;
60
+ private coordinationRunId;
61
+ private pendingExecution;
62
+ constructor(options: CoordinationRunnerOptions);
63
+ /**
64
+ * Register coordinations by name. The built-in `understand` runs unaddressed
65
+ * turns: it decides whether to delegate to agents, ask the user, or answer
66
+ * directly. Apps can override it by registering their own "understand" key,
67
+ * and add their own (e.g. clarify, review).
68
+ */
69
+ register(registrations: Record<string, CoordinationRegistration>, agents: readonly Agent[]): void;
70
+ /** True while a coordination is parked waiting for the user to answer. */
71
+ hasPending(): boolean;
72
+ /** Drop a parked execution (interrupt, stop). */
73
+ cancel(): void;
74
+ /**
75
+ * Run the built-in `understand` coordination on an unaddressed turn. A
76
+ * streaming generation is opened for the conversation's default agent; the
77
+ * coordination's final answer (or question) completes it.
78
+ */
79
+ runDefault(turn: Turn): Promise<void>;
80
+ /**
81
+ * Resume a parked coordination with the user's answer, propagating the
82
+ * result back up the frame stack to the outermost coordination.
83
+ */
84
+ resume(turn: Turn): Promise<void>;
85
+ /**
86
+ * The runtime the coordinations reason against. Binds the coordination
87
+ * primitives (delegate to agents, ask the user, speech, budget, cancellation)
88
+ * to the runner's machinery without coupling `Coordination` to it.
89
+ */
90
+ runtime(): CoordinationRuntime;
91
+ /** Complete the current generation and record the coordination's answer. */
92
+ private finalizeOutput;
93
+ /** Park a suspended coordination: record the question and store the stack. */
94
+ private recordSuspension;
95
+ /** Throw the suspension that parks a coordination waiting for the user. */
96
+ private askUser;
97
+ /** Enforce the per-execution reasoning step budget. */
98
+ private checkBudget;
99
+ private emitError;
100
+ /** Run delegated agent tasks in parallel and surface their work. */
101
+ private delegateAgentTasks;
102
+ /**
103
+ * Execute one dispatched task as a sub-generation: the target agent's own
104
+ * LLM, context, and tools, running text-only (no TTS). The final text is
105
+ * returned so the coordinator can merge it into the spoken answer.
106
+ */
107
+ private runSubGeneration;
108
+ }
@@ -0,0 +1,2 @@
1
+ export { CoordinationRunner } from "./coordination-runner.js";
2
+ export type { CoordinationRunnerOptions } from "./coordination-runner.js";
@@ -0,0 +1,43 @@
1
+ import type { LLM, LLMToolCall, LLMToolDefinition, LLMMessage } from "../../../../providers/llm/types.js";
2
+ import type { ResolvedToolCall } from "../tools/tools.js";
3
+ export interface GenerationRequest {
4
+ /** Display name stamped on assistant tool-call messages. */
5
+ agentName: string;
6
+ llm: LLM;
7
+ /**
8
+ * The conversation messages; the loop appends the assistant tool-call
9
+ * message and the resolved tool results onto this array.
10
+ */
11
+ messages: LLMMessage[];
12
+ tools: LLMToolDefinition[];
13
+ temperature?: number;
14
+ maxTokens?: number;
15
+ /** Safety bound on tool-call round trips per generation. */
16
+ maxToolIterations: number;
17
+ /** False once the run is stale (interrupt/stop); aborts the loop. */
18
+ isCurrent(): boolean;
19
+ /** Streamed text; `textBefore` is the running text prior to this delta. */
20
+ onDelta?(delta: string, textBefore: string): void;
21
+ /** Hand tool calls to the application and resolve their results. */
22
+ resolveToolCalls(calls: LLMToolCall[]): Promise<ResolvedToolCall[]>;
23
+ }
24
+ export type GenerationStatus = "done" | "interrupted" | "error";
25
+ export interface GenerationOutcome {
26
+ /** Everything the model produced (or produced before failing). */
27
+ text: string;
28
+ status: GenerationStatus;
29
+ /** The provider error, when `status` is "error". */
30
+ error?: unknown;
31
+ }
32
+ /**
33
+ * Owns the LLM tool loop shared by top-level generations and delegated
34
+ * sub-generations: stream deltas, collect tool calls, resolve them through
35
+ * the application, and repeat up to `maxToolIterations`.
36
+ *
37
+ * It is deliberately ignorant of the conversation lifecycle — persistence,
38
+ * transcripts, speech, and history are the caller's concern, decided from
39
+ * the returned `GenerationOutcome`.
40
+ */
41
+ export declare class GenerationRunner {
42
+ run(request: GenerationRequest): Promise<GenerationOutcome>;
43
+ }
@@ -0,0 +1,2 @@
1
+ export { GenerationRunner } from "./generation.js";
2
+ export type { GenerationOutcome, GenerationRequest, GenerationStatus, } from "./generation.js";
@@ -0,0 +1,62 @@
1
+ import type { Conversation } from "../../../conversation/conversation.js";
2
+ import type { Generation, Participant, Turn } from "../../../types.js";
3
+ import type { LLMMessage } from "../../../../providers/llm/types.js";
4
+ /**
5
+ * A human-readable "now" stamp appended to dispatched prompts so
6
+ * time-sensitive tasks (flights, meetings, deadlines) have temporal context.
7
+ */
8
+ export declare function formatTimeContext(date?: Date): string;
9
+ /**
10
+ * A short context suffix appended automatically to every user turn, so the
11
+ * model knows the time and who is speaking (and who else is in the
12
+ * conversation) — e.g. "enhance the message I just sent" resolves to a real
13
+ * user id. Applied once, when the turn enters history; every generation path
14
+ * (direct, coordination, delegated) seeds from that history.
15
+ */
16
+ export declare function formatTurnContext(participant: Participant, participants: readonly Participant[], date?: Date): string;
17
+ /** How much conversational history an LLM request may carry. */
18
+ export interface HistoryWindow {
19
+ /** Keep at most this many user turns (the current turn is always kept). */
20
+ maxTurns: number;
21
+ /** Drop oldest whole messages until the window fits this many characters. */
22
+ maxChars: number;
23
+ }
24
+ /**
25
+ * Bounds conversation history for an LLM request: keep the most recent
26
+ * `maxTurns` user turns (plus anything after them), then drop oldest whole
27
+ * messages until the window fits `maxChars`. The current turn is the last
28
+ * user message and always survives. Provider TTFT grows with input size, so
29
+ * a bounded window keeps requests in the fast regime.
30
+ */
31
+ export declare function windowHistory(history: LLMMessage[], { maxTurns, maxChars }: HistoryWindow): LLMMessage[];
32
+ /**
33
+ * The conversation's LLM message log: every user turn and agent reply, plus
34
+ * the turn-context formatting and windowing applied when a request is built.
35
+ * The orchestrator's `Conversation` remains the source of truth for turns,
36
+ * transcripts, and generations — this is the derived prompt log only.
37
+ */
38
+ export declare class ConversationHistory {
39
+ private readonly messages;
40
+ /**
41
+ * The user-message form of a turn: display name, text, and the automatic
42
+ * context suffix (time + speaker + roster) baked in at history time.
43
+ */
44
+ turnMessage(turn: Turn, conversation: Conversation): string;
45
+ /** Append a participant turn as a user message. */
46
+ addUserTurn(turn: Turn, conversation: Conversation): void;
47
+ /** Append an agent reply as an assistant message. */
48
+ addAssistant(agentName: string, text: string): void;
49
+ /**
50
+ * Rehydrate from persisted turns and completed top-level generations.
51
+ * Sub-generations are summarized inside the coordinator's own answer, so
52
+ * only top-level responses rehydrate into history.
53
+ */
54
+ rehydrate(turns: readonly Turn[], generations: readonly Generation[], conversation: Conversation): void;
55
+ /** The full message log. */
56
+ get all(): readonly LLMMessage[];
57
+ /**
58
+ * The message log bounded for an LLM request: the full log when `window`
59
+ * is `false`, otherwise the bounded window.
60
+ */
61
+ windowed(window: HistoryWindow | false): LLMMessage[];
62
+ }
@@ -0,0 +1 @@
1
+ export { ConversationHistory, formatTimeContext, formatTurnContext, windowHistory, type HistoryWindow, } from "./history.js";
@@ -1,2 +1,12 @@
1
1
  export { Orchestrator } from "./orchestrator.js";
2
2
  export type { OrchestratorOptions } from "./orchestrator.js";
3
+ export { ConversationHistory, formatTimeContext, formatTurnContext, windowHistory, type HistoryWindow, } from "./history.js";
4
+ export { buildUnderstandPrompt, findAddressedAgent, findAgentByName, pickAgent } from "./routing.js";
5
+ export { GenerationRunner } from "./generation.js";
6
+ export type { GenerationOutcome, GenerationRequest, GenerationStatus } from "./generation.js";
7
+ export { SpeechPipeline } from "./speech.js";
8
+ export type { SpeechPipelineOptions } from "./speech.js";
9
+ export { ToolCallManager } from "./tools.js";
10
+ export type { ResolvedToolCall } from "./tools.js";
11
+ export { CoordinationRunner } from "./coordination-runner.js";
12
+ export type { CoordinationRunnerOptions } from "./coordination-runner.js";
@@ -4,17 +4,23 @@ import type { Persistence } from "../../../persistence/persistence.js";
4
4
  import type { LLM } from "../../../providers/llm/types.js";
5
5
  import type { STT } from "../../../providers/stt/types.js";
6
6
  import type { TTS } from "../../../providers/tts/types.js";
7
+ import type { CoordinationRegistration } from "../coordination/coordination.js";
8
+ import { type HistoryWindow } from "./history/history.js";
7
9
  export interface OrchestratorOptions {
8
10
  conversation: Conversation;
9
11
  /**
10
- * The agent driving the realtime loop. Omit it for transcription-only
11
- * mode (audio in, turns and transcripts out no LLM or TTS required).
12
+ * The agents the orchestrator routes turns to. With more than one agent,
13
+ * unaddressed turns run through the built-in `understand` coordination,
14
+ * which can delegate to agents, ask the user, or answer directly. Omit
15
+ * for transcription-only mode (audio in, turns and transcripts out — no
16
+ * LLM or TTS required).
12
17
  */
13
- agent?: Agent;
14
- /** Defaults to the agent's LLM. */
18
+ agents?: Agent[];
19
+ /** Defaults to the first agent's LLM. */
15
20
  llm?: LLM;
16
- stt: STT;
17
- /** Required when an agent is attached. */
21
+ /** STT for voice turns. Omit for text-only conversations (`send()`). */
22
+ stt?: STT;
23
+ /** TTS for spoken output. Not required for text-only conversations. */
18
24
  tts?: TTS;
19
25
  /** Used to rehydrate conversation history on start. */
20
26
  persistence?: Persistence;
@@ -22,18 +28,35 @@ export interface OrchestratorOptions {
22
28
  toolTimeoutMs?: number;
23
29
  /** Safety bound on tool-call round trips per generation. */
24
30
  maxToolIterations?: number;
31
+ /**
32
+ * Additional coordinations the runtime can delegate to, registered by
33
+ * name (the key is the coordination's name).
34
+ */
35
+ coordinations?: Record<string, CoordinationRegistration>;
36
+ /** Safety bound on LLM reasoning steps per coordination execution. */
37
+ maxCoordinationSteps?: number;
25
38
  temperature?: number;
26
39
  maxTokens?: number;
40
+ /**
41
+ * Bounds how much conversation history each LLM request carries (default
42
+ * `{ maxTurns: 5, maxChars: 4000 }` — provider TTFT grows with input size,
43
+ * and a bounded window keeps requests in the fast regime). Pass `false` to
44
+ * always send the full history.
45
+ */
46
+ historyWindow?: HistoryWindow | false;
27
47
  }
28
48
  /**
29
- * The realtime conversation state machine.
49
+ * The realtime conversation state machine and multi-agent coordinator.
30
50
  *
31
- * Wires the conversation to the providers:
51
+ * Wires the conversation to the providers and routes each turn to an agent.
52
+ * The heavy machinery lives in focused collaborators — history, routing,
53
+ * generation, speech, tools, and coordination — so this class owns only the
54
+ * lifecycle and event wiring:
32
55
  *
33
56
  * ```text
34
- * audio-in ──► STT ──► turn ──► LLM ──► TTS ──► audio-out
35
- *
36
- * └─► tool-call ──► app resolves ──► resume
57
+ * audio-in ──► STT ──► turn ──► coordinator ──► agent ──► LLM ──► TTS ──► audio-out
58
+ *
59
+ * └─► tool-call ──► app resolves ──► resume
37
60
  * ```
38
61
  *
39
62
  * Deltas stream to TTS immediately (so the agent can narrate while a tool
@@ -43,28 +66,28 @@ export interface OrchestratorOptions {
43
66
  */
44
67
  export declare class Orchestrator {
45
68
  private readonly conversation;
46
- private readonly agent;
69
+ private readonly agents;
47
70
  private readonly llm;
48
71
  private readonly stt;
49
72
  private readonly tts;
50
73
  private readonly persistence;
51
- private readonly toolTimeoutMs;
52
74
  private readonly maxToolIterations;
75
+ private readonly historyWindow;
53
76
  private readonly temperature;
54
77
  private readonly maxTokens;
78
+ private readonly history;
79
+ private readonly speech;
80
+ private readonly tools;
81
+ private readonly generation;
82
+ private readonly coordination;
55
83
  private started;
56
84
  private generating;
57
85
  private epoch;
86
+ private generationChain;
58
87
  private readonly unsubscribers;
59
88
  private readonly sttSessions;
60
- private readonly history;
61
- private readonly toolWaiters;
62
- private generationChain;
63
- private speechChain;
64
- private speechBuffer;
65
89
  private pendingTurns;
66
90
  private pendingGenerations;
67
- private audioSequence;
68
91
  private turnSequence;
69
92
  constructor(options: OrchestratorOptions);
70
93
  /**
@@ -83,16 +106,11 @@ export declare class Orchestrator {
83
106
  private onFinal;
84
107
  private processTurn;
85
108
  private onInterrupt;
86
- private onToolCallResult;
109
+ /** Cancel every LLM in play: the shared one and each agent's own. */
110
+ private stopLlms;
87
111
  private onProviderError;
88
112
  private queueGeneration;
89
113
  private generate;
90
114
  private runGeneration;
91
- private resolveToolCalls;
92
- private waitForToolResult;
93
- private cancelToolWaiters;
94
- private feedDelta;
95
- private flushSpeech;
96
- /** Synthesize a sentence and push the audio chunks out to the app. */
97
- private speak;
115
+ private enqueueCoordinationRun;
98
116
  }
@@ -0,0 +1 @@
1
+ export { buildUnderstandPrompt, findAddressedAgent, findAgentByName, pickAgent, } from "./routing.js";
@@ -0,0 +1,19 @@
1
+ import type { Agent } from "../../../../agents/agent.js";
2
+ /**
3
+ * Pick the agent that should handle a turn.
4
+ *
5
+ * The first agent whose name or alias appears in the turn text wins;
6
+ * otherwise the first agent in the roster is the default. Matching is
7
+ * case-insensitive substring matching, so "ask the technical specialist"
8
+ * addresses an agent named "Technical Specialist" (or aliased "tech").
9
+ */
10
+ export declare function pickAgent(agents: readonly Agent[], text: string): Agent | null;
11
+ /**
12
+ * Like `pickAgent` but without the default: only returns an agent the turn
13
+ * explicitly addresses by name or alias.
14
+ */
15
+ export declare function findAddressedAgent(agents: readonly Agent[], text: string): Agent | null;
16
+ /** Resolve a task's agent by exact name or alias (case-insensitive). */
17
+ export declare function findAgentByName(agents: readonly Agent[], nameOrAlias: string): Agent | null;
18
+ /** The built-in coordinator: understands the request and decides what's next. */
19
+ export declare function buildUnderstandPrompt(agents: readonly Agent[]): string;
@@ -0,0 +1,2 @@
1
+ export { SpeechPipeline } from "./speech.js";
2
+ export type { SpeechPipelineOptions } from "./speech.js";
@@ -0,0 +1,49 @@
1
+ import type { Conversation } from "../../../conversation/conversation.js";
2
+ import type { TTS } from "../../../../providers/tts/types.js";
3
+ export interface SpeechPipelineOptions {
4
+ /** TTS provider; omitted for text-only conversations. */
5
+ tts?: TTS;
6
+ conversation: Conversation;
7
+ /**
8
+ * True while the generation that produced the speech is still current.
9
+ * The captured generation epoch is passed back in, so an interrupt (epoch
10
+ * bump) or a stop drops queued and in-flight synthesis.
11
+ */
12
+ isCurrent(epoch: number): boolean;
13
+ }
14
+ /**
15
+ * Turns the LLM delta stream into speakable audio: expose the text stream
16
+ * semantically (`text-delta`), buffer sentences through the `TextChunker`,
17
+ * and synthesize each chunk through the TTS provider on a serial chain.
18
+ *
19
+ * Owns the chunker, the speech epoch (bumped by `stop()`), the synthesis
20
+ * chain, and the audio sequence — the orchestrator only decides *when*
21
+ * speech is current.
22
+ */
23
+ export declare class SpeechPipeline {
24
+ private readonly tts;
25
+ private readonly conversation;
26
+ private readonly isCurrent;
27
+ private readonly chunker;
28
+ private speechEpoch;
29
+ private chain;
30
+ private audioSequence;
31
+ constructor(options: SpeechPipelineOptions);
32
+ /**
33
+ * Stream an LLM delta to the application and the TTS pipeline. Empty
34
+ * deltas (reasoning-only frames) are skipped so they never reach the
35
+ * text-delta event or the chunker.
36
+ */
37
+ feed(delta: string, epoch: number): void;
38
+ /** Speak any remaining buffered text as a final chunk. */
39
+ flush(epoch: number): void;
40
+ /** Synthesize a sentence and push the audio chunks out to the app. */
41
+ speak(sentence: string, epoch: number): void;
42
+ /**
43
+ * Stop the current TTS playback and drop buffered text without cancelling
44
+ * the generation (barge-in, interrupt, stop).
45
+ */
46
+ stop(): void;
47
+ /** Resolve when queued TTS synthesis has settled. */
48
+ waitForIdle(): Promise<void>;
49
+ }
@@ -0,0 +1,2 @@
1
+ export { ToolCallManager } from "./tools.js";
2
+ export type { ResolvedToolCall } from "./tools.js";
@@ -0,0 +1,31 @@
1
+ import type { Conversation } from "../../../conversation/conversation.js";
2
+ import type { LLMToolCall } from "../../../../providers/llm/types.js";
3
+ import type { ToolCallResult } from "../../../types.js";
4
+ export interface ResolvedToolCall {
5
+ id: string;
6
+ name: string;
7
+ result?: unknown;
8
+ error?: string;
9
+ }
10
+ /**
11
+ * Tracks tool calls handed to the application and resolves them once the
12
+ * application reports back (or a timeout fires). Stale results — timed out,
13
+ * already resolved, or superseded by an interrupt — are dropped.
14
+ */
15
+ export declare class ToolCallManager {
16
+ private readonly conversation;
17
+ private readonly timeoutMs;
18
+ private readonly waiters;
19
+ constructor(conversation: Conversation, timeoutMs: number);
20
+ /**
21
+ * Hand the calls to the application and resolve each one once it is
22
+ * answered or times out. Returns them in call order, with either a result
23
+ * or an error string.
24
+ */
25
+ resolveCalls(calls: LLMToolCall[]): Promise<ResolvedToolCall[]>;
26
+ /** Resolve a waiter from a `tool-call-result` event; stale results drop. */
27
+ handleResult(result: ToolCallResult): void;
28
+ /** Force-resolve every pending call (interrupt, stop). */
29
+ cancelAll(reason: string): void;
30
+ private wait;
31
+ }
@@ -0,0 +1,96 @@
1
+ import { Tool } from "../../agents/tools/tools.js";
2
+ import { Conversation } from "../conversation/conversation.js";
3
+ import { MemoryPersistence } from "../../persistence/adapters/memory/memory.js";
4
+ import { Orchestrator } from "./orchestrator/orchestrator.js";
5
+ import type { HistoryWindow } from "./orchestrator/history/history.js";
6
+ import type { LLM, LLMEvent, LLMRequest } from "../../providers/llm/types.js";
7
+ import type { STT, STTOptions, STTSession } from "../../providers/stt/types.js";
8
+ import type { TTS, TTSRequest } from "../../providers/tts/types.js";
9
+ export type LLMScript = (request: LLMRequest, signal: AbortSignal) => AsyncIterable<LLMEvent>;
10
+ export declare class FakeLLM implements LLM {
11
+ private readonly script;
12
+ readonly requests: LLMRequest[];
13
+ readonly stopCalls: number[];
14
+ private readonly controllers;
15
+ constructor(script: LLMScript);
16
+ stream(request: LLMRequest): AsyncGenerator<LLMEvent>;
17
+ stop(): void;
18
+ }
19
+ export declare class FakeSTT implements STT {
20
+ readonly sessions: FakeSTTSession[];
21
+ readonly startOptions: STTOptions[];
22
+ start(options?: STTOptions): FakeSTTSession;
23
+ cancel(): void;
24
+ }
25
+ export type FakeSessionEvent = "partial" | "final" | "error";
26
+ export declare class FakeSTTSession implements STTSession {
27
+ readonly written: Uint8Array[];
28
+ ended: number;
29
+ private readonly listeners;
30
+ write(audio: Uint8Array): void;
31
+ end(): Promise<void>;
32
+ on(event: "partial", listener: (transcript: string) => void): void;
33
+ on(event: "final", listener: (transcript: string) => void): void;
34
+ on(event: "error", listener: (error: Error) => void): void;
35
+ emitPartial(text: string): void;
36
+ emitFinal(text: string): void;
37
+ emitError(error: Error): void;
38
+ }
39
+ export declare class FakeTTS implements TTS {
40
+ private readonly chunksFor;
41
+ readonly requests: TTSRequest[];
42
+ private readonly controllers;
43
+ constructor(chunksFor: (text: string) => Uint8Array[]);
44
+ stream(request: TTSRequest): AsyncGenerator<Uint8Array>;
45
+ stop(): void;
46
+ }
47
+ /**
48
+ * A TTS that streams one chunk at a time with a delay, so audio is still
49
+ * mid-flight when an interrupt arrives.
50
+ */
51
+ export declare class SlowTTS implements TTS {
52
+ private readonly chunksFor;
53
+ private readonly delayMs;
54
+ readonly requests: TTSRequest[];
55
+ private readonly controllers;
56
+ constructor(chunksFor: (text: string) => Uint8Array[], delayMs?: number);
57
+ stream(request: TTSRequest): AsyncGenerator<Uint8Array>;
58
+ stop(): void;
59
+ }
60
+ export type TtsHarness = FakeTTS | SlowTTS;
61
+ export interface Harness {
62
+ conversation: Conversation;
63
+ orchestrator: Orchestrator;
64
+ llm: FakeLLM;
65
+ stt: FakeSTT;
66
+ tts: TtsHarness;
67
+ persistence: MemoryPersistence;
68
+ }
69
+ export declare function setup(options: {
70
+ script: LLMScript;
71
+ ttsChunks?: (text: string) => Uint8Array[];
72
+ tts?: TtsHarness;
73
+ tools?: Tool<never, unknown>[];
74
+ toolTimeoutMs?: number;
75
+ context?: string;
76
+ /** Inject a real LLM (e.g. an adapter over a mocked fetch) instead of a scripted fake. */
77
+ llm?: LLM;
78
+ /** Override the conversation-history window (default 5 turns / 4k chars). */
79
+ historyWindow?: HistoryWindow | false;
80
+ }): Promise<Harness>;
81
+ export declare function waitFor(condition: () => boolean, timeoutMs?: number): Promise<void>;
82
+ export declare function speak(harness: Harness, userId: string, text: string): Promise<void>;
83
+ export declare function respond(text: string): LLMScript;
84
+ export type RosterHarness = Harness & {
85
+ llms: Map<string, FakeLLM>;
86
+ };
87
+ export declare function setupRoster(options: {
88
+ coordinatorScript: LLMScript;
89
+ scripts: Record<string, LLMScript>;
90
+ tools?: Record<string, Tool<never, unknown>[]>;
91
+ coordinations?: Record<string, {
92
+ prompt: string;
93
+ llm: FakeLLM;
94
+ }>;
95
+ maxCoordinationSteps?: number;
96
+ }): Promise<RosterHarness>;
@@ -0,0 +1 @@
1
+ export * from './text-chunker.js';
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Streaming text segmenter for speech.
3
+ *
4
+ * Turns an incremental LLM token stream into speakable chunks with a boundary
5
+ * hierarchy, so TTS never waits indefinitely for punctuation:
6
+ *
7
+ * 1. **Strong boundary** — `. ! ? \n` flush immediately (sentence end).
8
+ * 2. **Soft boundary** — once the buffer is long enough, split at the last
9
+ * `, ; :` that yields a chunk of at least `minSoftLength` characters.
10
+ * 3. **Hard cap** — at `maxLength` the buffer flushes regardless of
11
+ * punctuation.
12
+ *
13
+ * The heuristics are intentionally internal and benchmark-driven rather than
14
+ * configurable through the public API.
15
+ */
16
+ export interface TextChunkerOptions {
17
+ /** Buffer length at which a soft boundary becomes eligible. Default 80. */
18
+ targetLength?: number;
19
+ /** Hard cap before an unconditional flush. Default 140. */
20
+ maxLength?: number;
21
+ /** Smallest chunk a soft boundary may produce. Default 40. */
22
+ minSoftLength?: number;
23
+ }
24
+ export declare class TextChunker {
25
+ private readonly targetLength;
26
+ private readonly maxLength;
27
+ private readonly minSoftLength;
28
+ private buffer;
29
+ constructor(options?: TextChunkerOptions);
30
+ /** Feed tokens; returns zero or more complete chunks to synthesize. */
31
+ push(delta: string): string[];
32
+ /** Flush any remaining buffered text as a final chunk (or null). */
33
+ flush(): string | null;
34
+ /** Drop the buffer (interrupt, stop). */
35
+ clear(): void;
36
+ private takeNext;
37
+ /** Cut the buffer through index `i` (inclusive) and return the text. */
38
+ private takeThrough;
39
+ }