@moureau/pipeflow 0.0.1 → 0.0.3

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 (336) hide show
  1. package/README.md +280 -130
  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/client/client.js +2 -0
  7. package/dist/cjs/client/client.js.map +7 -0
  8. package/dist/cjs/client/index.js +2 -0
  9. package/dist/cjs/client/index.js.map +7 -0
  10. package/dist/cjs/client/json.js +2 -0
  11. package/dist/cjs/client/json.js.map +7 -0
  12. package/dist/cjs/client/protocol/websocket.js +2 -0
  13. package/dist/cjs/client/protocol/websocket.js.map +7 -0
  14. package/dist/cjs/client/protocol.js +2 -0
  15. package/dist/cjs/client/protocol.js.map +7 -0
  16. package/dist/cjs/conversations/conversation/conversation.js +1 -1
  17. package/dist/cjs/conversations/conversation/conversation.js.map +3 -3
  18. package/dist/cjs/conversations/conversations.js +1 -1
  19. package/dist/cjs/conversations/conversations.js.map +3 -3
  20. package/dist/cjs/conversations/index.js +1 -1
  21. package/dist/cjs/conversations/index.js.map +3 -3
  22. package/dist/cjs/conversations/orchestration/coordination/coordination.js +10 -0
  23. package/dist/cjs/conversations/orchestration/coordination/coordination.js.map +7 -0
  24. package/dist/cjs/conversations/orchestration/coordination/index.js +2 -0
  25. package/dist/cjs/conversations/orchestration/coordination/index.js.map +7 -0
  26. package/dist/cjs/conversations/orchestration/orchestrator/coordination-runner/coordination-runner.js +4 -0
  27. package/dist/cjs/conversations/orchestration/orchestrator/coordination-runner/coordination-runner.js.map +7 -0
  28. package/dist/cjs/conversations/orchestration/orchestrator/coordination-runner/index.js +2 -0
  29. package/dist/cjs/conversations/orchestration/orchestrator/coordination-runner/index.js.map +7 -0
  30. package/dist/cjs/conversations/orchestration/orchestrator/generation/generation.js +2 -0
  31. package/dist/cjs/conversations/orchestration/orchestrator/generation/generation.js.map +7 -0
  32. package/dist/cjs/conversations/orchestration/orchestrator/generation/index.js +2 -0
  33. package/dist/cjs/conversations/orchestration/orchestrator/generation/index.js.map +7 -0
  34. package/dist/cjs/conversations/orchestration/orchestrator/history/history.js +4 -0
  35. package/dist/cjs/conversations/orchestration/orchestrator/history/history.js.map +7 -0
  36. package/dist/cjs/conversations/orchestration/orchestrator/history/index.js +2 -0
  37. package/dist/cjs/conversations/orchestration/orchestrator/history/index.js.map +7 -0
  38. package/dist/cjs/conversations/orchestration/orchestrator/index.js +1 -1
  39. package/dist/cjs/conversations/orchestration/orchestrator/index.js.map +3 -3
  40. package/dist/cjs/conversations/orchestration/orchestrator/orchestrator.js +1 -2
  41. package/dist/cjs/conversations/orchestration/orchestrator/orchestrator.js.map +3 -3
  42. package/dist/cjs/conversations/orchestration/orchestrator/routing/index.js +2 -0
  43. package/dist/cjs/conversations/orchestration/orchestrator/routing/index.js.map +7 -0
  44. package/dist/cjs/conversations/orchestration/orchestrator/routing/routing.js +23 -0
  45. package/dist/cjs/conversations/orchestration/orchestrator/routing/routing.js.map +7 -0
  46. package/dist/cjs/conversations/orchestration/orchestrator/speech/index.js +2 -0
  47. package/dist/cjs/conversations/orchestration/orchestrator/speech/index.js.map +7 -0
  48. package/dist/cjs/conversations/orchestration/orchestrator/speech/speech.js +2 -0
  49. package/dist/cjs/conversations/orchestration/orchestrator/speech/speech.js.map +7 -0
  50. package/dist/cjs/conversations/orchestration/orchestrator/tools/index.js +2 -0
  51. package/dist/cjs/conversations/orchestration/orchestrator/tools/index.js.map +7 -0
  52. package/dist/cjs/conversations/orchestration/orchestrator/tools/tools.js +2 -0
  53. package/dist/cjs/conversations/orchestration/orchestrator/tools/tools.js.map +7 -0
  54. package/dist/cjs/conversations/orchestration/test-harness.js +2 -0
  55. package/dist/cjs/conversations/orchestration/test-harness.js.map +7 -0
  56. package/dist/cjs/conversations/orchestration/text-chunker/index.js +2 -0
  57. package/dist/cjs/conversations/orchestration/text-chunker/index.js.map +7 -0
  58. package/dist/cjs/conversations/orchestration/text-chunker/text-chunker.js +3 -0
  59. package/dist/cjs/conversations/orchestration/text-chunker/text-chunker.js.map +7 -0
  60. package/dist/cjs/conversations/stream/conversation-stream.js +2 -0
  61. package/dist/cjs/conversations/stream/conversation-stream.js.map +7 -0
  62. package/dist/cjs/conversations/stream/index.js +2 -0
  63. package/dist/cjs/conversations/stream/index.js.map +7 -0
  64. package/dist/cjs/conversations/types.js +1 -1
  65. package/dist/cjs/conversations/types.js.map +2 -2
  66. package/dist/cjs/index.js +1 -1
  67. package/dist/cjs/index.js.map +3 -3
  68. package/dist/cjs/persistence/adapters/sqlite/sqlite.js +18 -14
  69. package/dist/cjs/persistence/adapters/sqlite/sqlite.js.map +3 -3
  70. package/dist/cjs/pipeflow/index.js +2 -0
  71. package/dist/cjs/pipeflow/index.js.map +7 -0
  72. package/dist/cjs/pipeflow/pipeflow.js +2 -0
  73. package/dist/cjs/pipeflow/pipeflow.js.map +7 -0
  74. package/dist/cjs/providers/index.js +1 -1
  75. package/dist/cjs/providers/index.js.map +2 -2
  76. package/dist/cjs/providers/llm/adapters/claude/claude.js +5 -0
  77. package/dist/cjs/providers/llm/adapters/claude/claude.js.map +7 -0
  78. package/dist/cjs/providers/llm/adapters/claude/index.js +2 -0
  79. package/dist/cjs/providers/llm/adapters/claude/index.js.map +7 -0
  80. package/dist/cjs/providers/llm/adapters/deepseek/deepseek.js +1 -1
  81. package/dist/cjs/providers/llm/adapters/deepseek/deepseek.js.map +3 -3
  82. package/dist/cjs/providers/llm/adapters/index.js +1 -1
  83. package/dist/cjs/providers/llm/adapters/index.js.map +3 -3
  84. package/dist/cjs/providers/llm/adapters/openai/index.js +2 -0
  85. package/dist/cjs/providers/llm/adapters/openai/index.js.map +7 -0
  86. package/dist/cjs/providers/llm/adapters/openai/openai.js +2 -0
  87. package/dist/cjs/providers/llm/adapters/openai/openai.js.map +7 -0
  88. package/dist/cjs/providers/llm/adapters/openai-compatible.js +10 -0
  89. package/dist/cjs/providers/llm/adapters/openai-compatible.js.map +7 -0
  90. package/dist/cjs/providers/llm/adapters/openrouter/index.js +2 -0
  91. package/dist/cjs/providers/llm/adapters/openrouter/index.js.map +7 -0
  92. package/dist/cjs/providers/llm/adapters/openrouter/openrouter.js +2 -0
  93. package/dist/cjs/providers/llm/adapters/openrouter/openrouter.js.map +7 -0
  94. package/dist/cjs/providers/llm/index.js +1 -1
  95. package/dist/cjs/providers/llm/index.js.map +3 -3
  96. package/dist/cjs/providers/llm/toolmode/index.js +2 -0
  97. package/dist/cjs/providers/llm/toolmode/index.js.map +7 -0
  98. package/dist/cjs/providers/llm/toolmode/toolmode.js +2 -0
  99. package/dist/cjs/providers/llm/toolmode/toolmode.js.map +7 -0
  100. package/dist/cjs/providers/llm/types.js +1 -1
  101. package/dist/cjs/providers/llm/types.js.map +3 -3
  102. package/dist/cjs/providers/stt/adapters/deepgram/deepgram.js +1 -1
  103. package/dist/cjs/providers/stt/adapters/deepgram/deepgram.js.map +3 -3
  104. package/dist/cjs/providers/stt/adapters/index.js +1 -1
  105. package/dist/cjs/providers/stt/adapters/index.js.map +3 -3
  106. package/dist/cjs/providers/stt/adapters/openrouter/index.js +2 -0
  107. package/dist/cjs/providers/stt/adapters/openrouter/index.js.map +7 -0
  108. package/dist/cjs/providers/stt/adapters/openrouter/openrouter.js +2 -0
  109. package/dist/cjs/providers/stt/adapters/openrouter/openrouter.js.map +7 -0
  110. package/dist/cjs/providers/tts/adapters/index.js +1 -1
  111. package/dist/cjs/providers/tts/adapters/index.js.map +3 -3
  112. package/dist/cjs/providers/tts/adapters/kokoro/kokoro.js +4 -1
  113. package/dist/cjs/providers/tts/adapters/kokoro/kokoro.js.map +3 -3
  114. package/dist/cjs/providers/tts/adapters/openrouter/index.js +2 -0
  115. package/dist/cjs/providers/tts/adapters/openrouter/index.js.map +7 -0
  116. package/dist/cjs/providers/tts/adapters/openrouter/openrouter.js +2 -0
  117. package/dist/cjs/providers/tts/adapters/openrouter/openrouter.js.map +7 -0
  118. package/dist/cjs/transport/streamobject/field-stream/field-stream.js +2 -0
  119. package/dist/cjs/transport/streamobject/field-stream/field-stream.js.map +7 -0
  120. package/dist/cjs/transport/streamobject/field-stream/index.js +2 -0
  121. package/dist/cjs/transport/streamobject/field-stream/index.js.map +7 -0
  122. package/dist/cjs/transport/streamobject/index.js +2 -0
  123. package/dist/cjs/transport/streamobject/index.js.map +7 -0
  124. package/dist/cjs/transport/streamobject/json-adapter/index.js +2 -0
  125. package/dist/cjs/transport/streamobject/json-adapter/index.js.map +7 -0
  126. package/dist/cjs/transport/streamobject/json-adapter/json-adapter.js +4 -0
  127. package/dist/cjs/transport/streamobject/json-adapter/json-adapter.js.map +7 -0
  128. package/dist/cjs/transport/streamobject/reference/index.js +2 -0
  129. package/dist/cjs/transport/streamobject/reference/index.js.map +7 -0
  130. package/dist/cjs/transport/streamobject/reference/reference.js +2 -0
  131. package/dist/cjs/transport/streamobject/reference/reference.js.map +7 -0
  132. package/dist/cjs/transport/streamobject/stream-object/index.js +2 -0
  133. package/dist/cjs/transport/streamobject/stream-object/index.js.map +7 -0
  134. package/dist/cjs/transport/streamobject/stream-object/stream-object.js +2 -0
  135. package/dist/cjs/transport/streamobject/stream-object/stream-object.js.map +7 -0
  136. package/dist/esm/agents/agent.js +1 -1
  137. package/dist/esm/agents/agent.js.map +3 -3
  138. package/dist/esm/agents/tools/tools.js +1 -1
  139. package/dist/esm/agents/tools/tools.js.map +3 -3
  140. package/dist/esm/client/client.js +2 -0
  141. package/dist/esm/client/client.js.map +7 -0
  142. package/dist/esm/client/index.js +2 -0
  143. package/dist/esm/client/index.js.map +7 -0
  144. package/dist/esm/client/json.js +2 -0
  145. package/dist/esm/client/json.js.map +7 -0
  146. package/dist/esm/client/protocol/websocket.js +2 -0
  147. package/dist/esm/client/protocol/websocket.js.map +7 -0
  148. package/dist/esm/client/protocol.js +1 -0
  149. package/dist/esm/client/protocol.js.map +7 -0
  150. package/dist/esm/conversations/conversation/conversation.js +1 -1
  151. package/dist/esm/conversations/conversation/conversation.js.map +3 -3
  152. package/dist/esm/conversations/conversations.js +1 -1
  153. package/dist/esm/conversations/conversations.js.map +3 -3
  154. package/dist/esm/conversations/index.js +1 -1
  155. package/dist/esm/conversations/index.js.map +3 -3
  156. package/dist/esm/conversations/orchestration/coordination/coordination.js +10 -0
  157. package/dist/esm/conversations/orchestration/coordination/coordination.js.map +7 -0
  158. package/dist/esm/conversations/orchestration/coordination/index.js +2 -0
  159. package/dist/esm/conversations/orchestration/coordination/index.js.map +7 -0
  160. package/dist/esm/conversations/orchestration/orchestrator/coordination-runner/coordination-runner.js +4 -0
  161. package/dist/esm/conversations/orchestration/orchestrator/coordination-runner/coordination-runner.js.map +7 -0
  162. package/dist/esm/conversations/orchestration/orchestrator/coordination-runner/index.js +2 -0
  163. package/dist/esm/conversations/orchestration/orchestrator/coordination-runner/index.js.map +7 -0
  164. package/dist/esm/conversations/orchestration/orchestrator/generation/generation.js +2 -0
  165. package/dist/esm/conversations/orchestration/orchestrator/generation/generation.js.map +7 -0
  166. package/dist/esm/conversations/orchestration/orchestrator/generation/index.js +2 -0
  167. package/dist/esm/conversations/orchestration/orchestrator/generation/index.js.map +7 -0
  168. package/dist/esm/conversations/orchestration/orchestrator/history/history.js +4 -0
  169. package/dist/esm/conversations/orchestration/orchestrator/history/history.js.map +7 -0
  170. package/dist/esm/conversations/orchestration/orchestrator/history/index.js +2 -0
  171. package/dist/esm/conversations/orchestration/orchestrator/history/index.js.map +7 -0
  172. package/dist/esm/conversations/orchestration/orchestrator/index.js +1 -1
  173. package/dist/esm/conversations/orchestration/orchestrator/index.js.map +3 -3
  174. package/dist/esm/conversations/orchestration/orchestrator/orchestrator.js +1 -2
  175. package/dist/esm/conversations/orchestration/orchestrator/orchestrator.js.map +3 -3
  176. package/dist/esm/conversations/orchestration/orchestrator/routing/index.js +2 -0
  177. package/dist/esm/conversations/orchestration/orchestrator/routing/index.js.map +7 -0
  178. package/dist/esm/conversations/orchestration/orchestrator/routing/routing.js +23 -0
  179. package/dist/esm/conversations/orchestration/orchestrator/routing/routing.js.map +7 -0
  180. package/dist/esm/conversations/orchestration/orchestrator/speech/index.js +2 -0
  181. package/dist/esm/conversations/orchestration/orchestrator/speech/index.js.map +7 -0
  182. package/dist/esm/conversations/orchestration/orchestrator/speech/speech.js +2 -0
  183. package/dist/esm/conversations/orchestration/orchestrator/speech/speech.js.map +7 -0
  184. package/dist/esm/conversations/orchestration/orchestrator/tools/index.js +2 -0
  185. package/dist/esm/conversations/orchestration/orchestrator/tools/index.js.map +7 -0
  186. package/dist/esm/conversations/orchestration/orchestrator/tools/tools.js +2 -0
  187. package/dist/esm/conversations/orchestration/orchestrator/tools/tools.js.map +7 -0
  188. package/dist/esm/conversations/orchestration/test-harness.js +2 -0
  189. package/dist/esm/conversations/orchestration/test-harness.js.map +7 -0
  190. package/dist/esm/conversations/orchestration/text-chunker/index.js +2 -0
  191. package/dist/esm/conversations/orchestration/text-chunker/index.js.map +7 -0
  192. package/dist/esm/conversations/orchestration/text-chunker/text-chunker.js +3 -0
  193. package/dist/esm/conversations/orchestration/text-chunker/text-chunker.js.map +7 -0
  194. package/dist/esm/conversations/stream/conversation-stream.js +2 -0
  195. package/dist/esm/conversations/stream/conversation-stream.js.map +7 -0
  196. package/dist/esm/conversations/stream/index.js +2 -0
  197. package/dist/esm/conversations/stream/index.js.map +7 -0
  198. package/dist/esm/conversations/types.js +1 -1
  199. package/dist/esm/conversations/types.js.map +2 -2
  200. package/dist/esm/index.js +1 -1
  201. package/dist/esm/index.js.map +3 -3
  202. package/dist/esm/persistence/adapters/sqlite/sqlite.js +18 -14
  203. package/dist/esm/persistence/adapters/sqlite/sqlite.js.map +3 -3
  204. package/dist/esm/pipeflow/index.js +2 -0
  205. package/dist/esm/pipeflow/index.js.map +7 -0
  206. package/dist/esm/pipeflow/pipeflow.js +2 -0
  207. package/dist/esm/pipeflow/pipeflow.js.map +7 -0
  208. package/dist/esm/providers/index.js +1 -1
  209. package/dist/esm/providers/index.js.map +3 -3
  210. package/dist/esm/providers/llm/adapters/claude/claude.js +5 -0
  211. package/dist/esm/providers/llm/adapters/claude/claude.js.map +7 -0
  212. package/dist/esm/providers/llm/adapters/claude/index.js +2 -0
  213. package/dist/esm/providers/llm/adapters/claude/index.js.map +7 -0
  214. package/dist/esm/providers/llm/adapters/deepseek/deepseek.js +1 -1
  215. package/dist/esm/providers/llm/adapters/deepseek/deepseek.js.map +3 -3
  216. package/dist/esm/providers/llm/adapters/index.js +1 -1
  217. package/dist/esm/providers/llm/adapters/index.js.map +3 -3
  218. package/dist/esm/providers/llm/adapters/openai/index.js +2 -0
  219. package/dist/esm/providers/llm/adapters/openai/index.js.map +7 -0
  220. package/dist/esm/providers/llm/adapters/openai/openai.js +2 -0
  221. package/dist/esm/providers/llm/adapters/openai/openai.js.map +7 -0
  222. package/dist/esm/providers/llm/adapters/openai-compatible.js +10 -0
  223. package/dist/esm/providers/llm/adapters/openai-compatible.js.map +7 -0
  224. package/dist/esm/providers/llm/adapters/openrouter/index.js +2 -0
  225. package/dist/esm/providers/llm/adapters/openrouter/index.js.map +7 -0
  226. package/dist/esm/providers/llm/adapters/openrouter/openrouter.js +2 -0
  227. package/dist/esm/providers/llm/adapters/openrouter/openrouter.js.map +7 -0
  228. package/dist/esm/providers/llm/index.js +1 -1
  229. package/dist/esm/providers/llm/index.js.map +3 -3
  230. package/dist/esm/providers/llm/toolmode/index.js +2 -0
  231. package/dist/esm/providers/llm/toolmode/index.js.map +7 -0
  232. package/dist/esm/providers/llm/toolmode/toolmode.js +2 -0
  233. package/dist/esm/providers/llm/toolmode/toolmode.js.map +7 -0
  234. package/dist/esm/providers/llm/types.js +1 -0
  235. package/dist/esm/providers/llm/types.js.map +4 -4
  236. package/dist/esm/providers/stt/adapters/deepgram/deepgram.js +1 -1
  237. package/dist/esm/providers/stt/adapters/deepgram/deepgram.js.map +3 -3
  238. package/dist/esm/providers/stt/adapters/index.js +1 -1
  239. package/dist/esm/providers/stt/adapters/index.js.map +3 -3
  240. package/dist/esm/providers/stt/adapters/openrouter/index.js +2 -0
  241. package/dist/esm/providers/stt/adapters/openrouter/index.js.map +7 -0
  242. package/dist/esm/providers/stt/adapters/openrouter/openrouter.js +2 -0
  243. package/dist/esm/providers/stt/adapters/openrouter/openrouter.js.map +7 -0
  244. package/dist/esm/providers/tts/adapters/index.js +1 -1
  245. package/dist/esm/providers/tts/adapters/index.js.map +3 -3
  246. package/dist/esm/providers/tts/adapters/kokoro/kokoro.js +4 -1
  247. package/dist/esm/providers/tts/adapters/kokoro/kokoro.js.map +3 -3
  248. package/dist/esm/providers/tts/adapters/openrouter/index.js +2 -0
  249. package/dist/esm/providers/tts/adapters/openrouter/index.js.map +7 -0
  250. package/dist/esm/providers/tts/adapters/openrouter/openrouter.js +2 -0
  251. package/dist/esm/providers/tts/adapters/openrouter/openrouter.js.map +7 -0
  252. package/dist/esm/transport/streamobject/field-stream/field-stream.js +2 -0
  253. package/dist/esm/transport/streamobject/field-stream/field-stream.js.map +7 -0
  254. package/dist/esm/transport/streamobject/field-stream/index.js +2 -0
  255. package/dist/esm/transport/streamobject/field-stream/index.js.map +7 -0
  256. package/dist/esm/transport/streamobject/index.js +2 -0
  257. package/dist/esm/transport/streamobject/index.js.map +7 -0
  258. package/dist/esm/transport/streamobject/json-adapter/index.js +2 -0
  259. package/dist/esm/transport/streamobject/json-adapter/index.js.map +7 -0
  260. package/dist/esm/transport/streamobject/json-adapter/json-adapter.js +4 -0
  261. package/dist/esm/transport/streamobject/json-adapter/json-adapter.js.map +7 -0
  262. package/dist/esm/transport/streamobject/reference/index.js +2 -0
  263. package/dist/esm/transport/streamobject/reference/index.js.map +7 -0
  264. package/dist/esm/transport/streamobject/reference/reference.js +2 -0
  265. package/dist/esm/transport/streamobject/reference/reference.js.map +7 -0
  266. package/dist/esm/transport/streamobject/stream-object/index.js +2 -0
  267. package/dist/esm/transport/streamobject/stream-object/index.js.map +7 -0
  268. package/dist/esm/transport/streamobject/stream-object/stream-object.js +2 -0
  269. package/dist/esm/transport/streamobject/stream-object/stream-object.js.map +7 -0
  270. package/dist/types/agents/agent.d.ts +3 -0
  271. package/dist/types/agents/tools/tools.d.ts +28 -6
  272. package/dist/types/client/client.d.ts +186 -0
  273. package/dist/types/client/index.d.ts +31 -0
  274. package/dist/types/client/json.d.ts +13 -0
  275. package/dist/types/client/protocol/websocket.d.ts +56 -0
  276. package/dist/types/client/protocol.d.ts +46 -0
  277. package/dist/types/conversations/conversation/conversation.d.ts +130 -6
  278. package/dist/types/conversations/conversations.d.ts +35 -1
  279. package/dist/types/conversations/index.d.ts +2 -1
  280. package/dist/types/conversations/orchestration/coordination/coordination.d.ts +192 -0
  281. package/dist/types/conversations/orchestration/coordination/index.d.ts +2 -0
  282. package/dist/types/conversations/orchestration/orchestrator/coordination-runner/coordination-runner.d.ts +108 -0
  283. package/dist/types/conversations/orchestration/orchestrator/coordination-runner/index.d.ts +2 -0
  284. package/dist/types/conversations/orchestration/orchestrator/generation/generation.d.ts +60 -0
  285. package/dist/types/conversations/orchestration/orchestrator/generation/index.d.ts +2 -0
  286. package/dist/types/conversations/orchestration/orchestrator/history/history.d.ts +62 -0
  287. package/dist/types/conversations/orchestration/orchestrator/history/index.d.ts +1 -0
  288. package/dist/types/conversations/orchestration/orchestrator/index.d.ts +10 -0
  289. package/dist/types/conversations/orchestration/orchestrator/orchestrator.d.ts +68 -31
  290. package/dist/types/conversations/orchestration/orchestrator/routing/index.d.ts +1 -0
  291. package/dist/types/conversations/orchestration/orchestrator/routing/routing.d.ts +19 -0
  292. package/dist/types/conversations/orchestration/orchestrator/speech/index.d.ts +2 -0
  293. package/dist/types/conversations/orchestration/orchestrator/speech/speech.d.ts +78 -0
  294. package/dist/types/conversations/orchestration/orchestrator/tools/index.d.ts +2 -0
  295. package/dist/types/conversations/orchestration/orchestrator/tools/tools.d.ts +65 -0
  296. package/dist/types/conversations/orchestration/test-harness.d.ts +100 -0
  297. package/dist/types/conversations/orchestration/text-chunker/index.d.ts +1 -0
  298. package/dist/types/conversations/orchestration/text-chunker/text-chunker.d.ts +39 -0
  299. package/dist/types/conversations/stream/conversation-stream.d.ts +42 -0
  300. package/dist/types/conversations/stream/index.d.ts +1 -0
  301. package/dist/types/conversations/types.d.ts +32 -0
  302. package/dist/types/index.d.ts +5 -38
  303. package/dist/types/pipeflow/index.d.ts +2 -0
  304. package/dist/types/pipeflow/pipeflow.d.ts +43 -0
  305. package/dist/types/providers/index.d.ts +1 -1
  306. package/dist/types/providers/llm/adapters/claude/claude.d.ts +45 -0
  307. package/dist/types/providers/llm/adapters/claude/index.d.ts +2 -0
  308. package/dist/types/providers/llm/adapters/deepseek/deepseek.d.ts +23 -2
  309. package/dist/types/providers/llm/adapters/index.d.ts +3 -0
  310. package/dist/types/providers/llm/adapters/openai/index.d.ts +2 -0
  311. package/dist/types/providers/llm/adapters/openai/openai.d.ts +45 -0
  312. package/dist/types/providers/llm/adapters/openai-compatible.d.ts +44 -0
  313. package/dist/types/providers/llm/adapters/openrouter/index.d.ts +2 -0
  314. package/dist/types/providers/llm/adapters/openrouter/openrouter.d.ts +60 -0
  315. package/dist/types/providers/llm/index.d.ts +5 -2
  316. package/dist/types/providers/llm/toolmode/index.d.ts +2 -0
  317. package/dist/types/providers/llm/toolmode/toolmode.d.ts +99 -0
  318. package/dist/types/providers/llm/types.d.ts +65 -0
  319. package/dist/types/providers/stt/adapters/deepgram/deepgram.d.ts +4 -1
  320. package/dist/types/providers/stt/adapters/index.d.ts +1 -0
  321. package/dist/types/providers/stt/adapters/openrouter/index.d.ts +2 -0
  322. package/dist/types/providers/stt/adapters/openrouter/openrouter.d.ts +196 -0
  323. package/dist/types/providers/tts/adapters/index.d.ts +1 -0
  324. package/dist/types/providers/tts/adapters/kokoro/kokoro.d.ts +18 -3
  325. package/dist/types/providers/tts/adapters/openrouter/index.d.ts +2 -0
  326. package/dist/types/providers/tts/adapters/openrouter/openrouter.d.ts +64 -0
  327. package/dist/types/transport/streamobject/field-stream/field-stream.d.ts +85 -0
  328. package/dist/types/transport/streamobject/field-stream/index.d.ts +2 -0
  329. package/dist/types/transport/streamobject/index.d.ts +8 -0
  330. package/dist/types/transport/streamobject/json-adapter/index.d.ts +2 -0
  331. package/dist/types/transport/streamobject/json-adapter/json-adapter.d.ts +65 -0
  332. package/dist/types/transport/streamobject/reference/index.d.ts +2 -0
  333. package/dist/types/transport/streamobject/reference/reference.d.ts +127 -0
  334. package/dist/types/transport/streamobject/stream-object/index.d.ts +2 -0
  335. package/dist/types/transport/streamobject/stream-object/stream-object.d.ts +31 -0
  336. package/package.json +29 -2
@@ -0,0 +1,44 @@
1
+ import type { LLMEvent, LLMRequest, LLMStreamTimingCallback, LLMUsageCallback, ToolMode } from "../types.js";
2
+ import type { FetchLike } from "../../shared.js";
3
+ export interface OpenAICompatibleStreamParams {
4
+ /** Provider base URL, e.g. `https://openrouter.ai/api/v1`. */
5
+ baseUrl: string;
6
+ apiKey: string;
7
+ model: string;
8
+ /** Injectable fetch implementation, mainly for tests. */
9
+ fetchImpl: FetchLike;
10
+ request: LLMRequest;
11
+ signal: AbortSignal;
12
+ /** Extra headers merged into the request (e.g. attribution headers). */
13
+ extraHeaders?: Record<string, string>;
14
+ /** Extra body fields merged after the standard ones. */
15
+ extraBody?: Record<string, unknown>;
16
+ /** Provider name used in error messages. */
17
+ label: string;
18
+ /** Optional provider-timeline hook (see `LLMStreamTimingPoint`). */
19
+ onTiming?: LLMStreamTimingCallback;
20
+ /**
21
+ * Default tool encoding for requests that do not set `toolMode`
22
+ * themselves (the request's `toolMode` wins when present). Useful for
23
+ * models whose endpoints lack native tool calling.
24
+ */
25
+ toolMode?: ToolMode;
26
+ /**
27
+ * Abort the stream if no data arrives for this long (default 8000ms).
28
+ * Protects against providers whose connection goes silent after the model
29
+ * has already produced its output (e.g. a tool call that is never followed
30
+ * by a terminating frame).
31
+ */
32
+ idleTimeoutMs?: number;
33
+ /**
34
+ * Called with the provider-reported token usage when the stream includes
35
+ * it (OpenRouter sends usage in the final chunk).
36
+ */
37
+ onUsage?: LLMUsageCallback;
38
+ }
39
+ /**
40
+ * Stream a request through any OpenAI-compatible `/chat/completions`
41
+ * endpoint, reassembling fragmented tool calls and normalizing the SSE
42
+ * stream into `LLMEvent`s. Shared by the DeepSeek and OpenRouter adapters.
43
+ */
44
+ export declare function openAICompatibleStream(params: OpenAICompatibleStreamParams): AsyncGenerator<LLMEvent>;
@@ -0,0 +1,2 @@
1
+ export { OpenRouterLLM } from "./openrouter.js";
2
+ export type { OpenRouterOptions } from "./openrouter.js";
@@ -0,0 +1,60 @@
1
+ import type { FavoriteModel, LLM, LLMEvent, LLMRequest, LLMStreamTimingCallback, LLMUsageCallback, ToolMode } from "../../types.js";
2
+ import type { FetchLike } from "../../../shared.js";
3
+ export interface OpenRouterOptions {
4
+ apiKey: string;
5
+ /**
6
+ * Any model hosted on OpenRouter, e.g. `anthropic/claude-sonnet-4`.
7
+ * Defaults to `openrouter/auto`, which routes the request to the best
8
+ * available model for its shape. The measured `FAVORITE_MODELS`
9
+ * autocomplete; any model id is accepted.
10
+ */
11
+ model?: FavoriteModel;
12
+ /** Defaults to `https://openrouter.ai/api/v1`. */
13
+ baseUrl?: string;
14
+ /**
15
+ * The site that credits the app on OpenRouter's leaderboard via
16
+ * `HTTP-Referer`. Defaults to `https://moureau.dev`.
17
+ */
18
+ appUrl?: string;
19
+ /** Injectable fetch implementation, mainly for tests. */
20
+ fetch?: FetchLike;
21
+ /** Provider-timeline hook: request-start / headers / first-chunk. */
22
+ onTiming?: LLMStreamTimingCallback;
23
+ /**
24
+ * Abort a stream that delivers no data for this long (default 8000ms) —
25
+ * protects against provider connections that go silent after the model
26
+ * already produced its output. Raise it for providers with slow TTFT.
27
+ */
28
+ idleTimeoutMs?: number;
29
+ /** Called with the provider-reported token usage (when included). */
30
+ onUsage?: LLMUsageCallback;
31
+ /**
32
+ * Default tool encoding for requests that don't set `toolMode` (the
33
+ * request's `toolMode` wins). For models whose endpoints lack native tool
34
+ * calling — e.g. `sao10k/l3-lunaris-8b` -> `"envelope"`.
35
+ */
36
+ toolMode?: ToolMode;
37
+ }
38
+ /**
39
+ * OpenRouter LLM adapter (OpenAI-compatible chat completions over SSE).
40
+ *
41
+ * OpenRouter is a gateway: one API key and one wire format for hundreds of
42
+ * models from different vendors, so this adapter is a thin wrapper around
43
+ * the shared OpenAI-compatible streaming engine.
44
+ */
45
+ export declare class OpenRouterLLM implements LLM {
46
+ private readonly apiKey;
47
+ private readonly model;
48
+ private readonly baseUrl;
49
+ private readonly appUrl;
50
+ private readonly fetchImpl;
51
+ private readonly onTiming;
52
+ private readonly idleTimeoutMs;
53
+ private readonly onUsage;
54
+ private readonly toolMode;
55
+ private readonly streams;
56
+ constructor(options: OpenRouterOptions);
57
+ /** Cancel every in-flight stream (parallel sub-generations included). */
58
+ stop(): void;
59
+ stream(request: LLMRequest): AsyncGenerator<LLMEvent>;
60
+ }
@@ -1,5 +1,6 @@
1
1
  import type { LLM, LLMRequest } from "./types.js";
2
- export type { LLM, LLMEvent, LLMMessage, LLMRole, LLMToolCall, LLMToolDefinition, LLMRequest, } from "./types.js";
2
+ export type { FavoriteModel, LLM, LLMEvent, LLMMessage, LLMRole, LLMToolCall, LLMToolDefinition, LLMRequest, StringOr, } from "./types.js";
3
+ export { FAVORITE_MODELS } from "./types.js";
3
4
  /**
4
5
  * Stream only the text deltas of an LLM generation, rethrowing any
5
6
  * streamed error.
@@ -7,4 +8,6 @@ export type { LLM, LLMEvent, LLMMessage, LLMRole, LLMToolCall, LLMToolDefinition
7
8
  export declare function streamText(llm: LLM, request: LLMRequest): AsyncGenerator<string>;
8
9
  /** Collect an entire LLM generation into a single string. */
9
10
  export declare function complete(llm: LLM, request: LLMRequest): Promise<string>;
10
- export { DeepSeekLLM } from "./adapters/index.js";
11
+ export { ClaudeLLM, DeepSeekLLM, OpenAILLM, OpenRouterLLM } from "./adapters/index.js";
12
+ export { ToolModeBenchmark } from "./toolmode.js";
13
+ export type { ToolModeBenchmarkOptions, ToolModeBenchmarkResult, ToolModeBenchmarkRun, ToolModeReportEntry, ToolModeTiming, } from "./toolmode.js";
@@ -0,0 +1,2 @@
1
+ export { ToolModeBenchmark } from "./toolmode.js";
2
+ export type { ToolModeBenchmarkOptions, ToolModeBenchmarkResult, ToolModeBenchmarkRun, ToolModeReportEntry, ToolModeTiming, } from "./toolmode.js";
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Tool-mode benchmark: measures availability, latency (percentiles), and cost
3
+ * of each tool-call encoding (`native` | `envelope` | `prompted`) for a
4
+ * model, through the real adapter path (`llm.stream({ toolMode })`). A
5
+ * diagnostic utility for onboarding models — the runtime never calls it.
6
+ *
7
+ * ```ts
8
+ * const bench = new ToolModeBenchmark({ apiKey, model: "..." });
9
+ * const { fastest, cheapest, report } = await bench.run();
10
+ * console.log(report.envelope.time.p50);
11
+ * ```
12
+ */
13
+ import { z } from "zod";
14
+ import type { FetchLike } from "../../shared.js";
15
+ import type { LLMMessage, LLMToolDefinition, ToolMode } from "../types.js";
16
+ export interface ToolModeBenchmarkOptions {
17
+ apiKey: string;
18
+ model: string;
19
+ /** Override the OpenRouter base URL. */
20
+ baseUrl?: string;
21
+ /** Runs per mode (default 3). */
22
+ runs?: number;
23
+ /** Probe messages (default: a weather question). */
24
+ messages?: LLMMessage[];
25
+ /** Probe tool (default: get_weather). */
26
+ tools?: LLMToolDefinition[];
27
+ /**
28
+ * Validates each emitted tool call's arguments to count `correct` runs — a
29
+ * call that succeeds with garbage arguments (e.g. `{ "city": "?" }`) is a
30
+ * failed decision. Defaults to the weather probe's schema.
31
+ */
32
+ correctnessSchema?: z.ZodType;
33
+ /** Injectable fetch implementation, mainly for tests. */
34
+ fetch?: FetchLike;
35
+ }
36
+ export interface ToolModeBenchmarkRun {
37
+ /** ms to the tool call (decision latency), or to stream end when none. */
38
+ latencyMs?: number;
39
+ toolCall: boolean;
40
+ /** Every emitted call's arguments parsed cleanly and validated. */
41
+ correct?: boolean;
42
+ prompt?: number;
43
+ completion?: number;
44
+ error?: string;
45
+ }
46
+ /** Latency percentiles over the runs that produced a tool call. */
47
+ export interface ToolModeTiming {
48
+ p50: number;
49
+ p95: number;
50
+ p99: number;
51
+ }
52
+ export interface ToolModeReportEntry {
53
+ /** Median cost ($) per decision over runs with provider usage. */
54
+ cost?: number;
55
+ /** Decision-latency percentiles; absent when no run emitted a tool call. */
56
+ time?: ToolModeTiming;
57
+ /** How many runs produced a tool call. */
58
+ toolCalls: number;
59
+ /**
60
+ * How many runs emitted only schema-valid calls (undefined when no
61
+ * `correctnessSchema` was provided).
62
+ */
63
+ correct: number | undefined;
64
+ /** Cost per decision that was actually correct: `cost / (correct / runs)`. */
65
+ effectiveCost?: number;
66
+ /** How many runs failed outright (transport, envelope parse, …). */
67
+ errors: number;
68
+ /** The first run's error, when every run failed. */
69
+ error?: string;
70
+ /** Raw per-run rows, for diagnostics. */
71
+ runs: ToolModeBenchmarkRun[];
72
+ }
73
+ export interface ToolModeBenchmarkResult {
74
+ model: string;
75
+ /** Prompt/completion prices ($/token) from the registry, when available. */
76
+ pricing: {
77
+ in: number;
78
+ out: number;
79
+ } | undefined;
80
+ report: Record<ToolMode, ToolModeReportEntry>;
81
+ /** Fastest mode that actually emitted a tool call. */
82
+ fastest: ToolMode | null;
83
+ /** Cheapest mode that actually emitted a tool call. */
84
+ cheapest: ToolMode | null;
85
+ }
86
+ export declare class ToolModeBenchmark {
87
+ private readonly apiKey;
88
+ private readonly model;
89
+ private readonly baseUrl;
90
+ private readonly runs;
91
+ private readonly messages;
92
+ private readonly tools;
93
+ private readonly correctnessSchema;
94
+ private readonly fetchImpl;
95
+ constructor(options: ToolModeBenchmarkOptions);
96
+ /** Benchmark every mode and return the structured report. */
97
+ run(): Promise<ToolModeBenchmarkResult>;
98
+ private benchmarkMode;
99
+ }
@@ -21,15 +21,80 @@ export interface LLMToolDefinition {
21
21
  /** JSON schema describing the tool arguments. */
22
22
  parameters: Record<string, unknown>;
23
23
  }
24
+ /**
25
+ * How tool calls are encoded on the wire. The semantic contract is the same
26
+ * in every mode — callers still pass `tools` and consume `tool_call` events —
27
+ * only the encoding differs. The right mode is a property of the model's
28
+ * endpoints, not the caller: use `ToolModeBenchmark` to measure a model and
29
+ * set the mode once at adapter construction.
30
+ *
31
+ * - `native` (default) — the provider's tool-calling contract: `tools` in
32
+ * the request, `tool_calls` in the stream. Streaming deltas and
33
+ * provider-enforced argument schemas, at the price of wire overhead: the
34
+ * provider expands the schema into its native tool format, which bills
35
+ * measurably more prompt tokens (often 5-10x the cost of the modes below).
36
+ * - `envelope` — no `tools`; `response_format` forces the model to emit a
37
+ * JSON envelope (`{ answer?, calls: [{ name, arguments }] }`) that the
38
+ * adapter translates back into `tool_call` events. Endpoint-guaranteed
39
+ * JSON and a lean prompt (dramatically cheaper per decision), but nothing
40
+ * is actionable until the whole envelope arrives — no streaming deltas.
41
+ * Only for endpoints that support structured outputs.
42
+ * - `prompted` — no `tools`; the same envelope is requested by appending an
43
+ * instruction to the last user message. The universal fallback: works on
44
+ * any chat model, at the cost of extraction/repair/retry, higher token
45
+ * use, and tail-latency risk. Because nothing constrains the output, a
46
+ * model that ignores the envelope and replies in plain prose is answered
47
+ * directly — its text is treated as the reply rather than failing the
48
+ * generation.
49
+ */
50
+ export type ToolMode = "native" | "envelope" | "prompted";
51
+ /**
52
+ * A string that may also be one of the branded literal values — e.g. any
53
+ * model id, with the favorites offered for autocomplete. The `& {}` on the
54
+ * string side stops TypeScript from absorbing the literals into `string`
55
+ * (the reverse arrangement — `string | (T & {})` — collapses and loses the
56
+ * literals).
57
+ */
58
+ export type StringOr<T extends string> = T | (string & {});
59
+ /** Models measured as usable; offered for autocomplete where a model id is taken. */
60
+ export declare const FAVORITE_MODELS: readonly ["meta-llama/llama-4-scout", "google/gemini-2.5-flash-lite", "amazon/nova-micro-v1", "amazon/nova-lite-v1", "inclusionai/ling-3.0-flash", "sao10k/l3-lunaris-8b", "openai/gpt-oss-20b"];
61
+ /** Any model id, with the favorites offered for autocomplete. */
62
+ export type FavoriteModel = StringOr<(typeof FAVORITE_MODELS)[number]>;
24
63
  export interface LLMRequest {
25
64
  messages: LLMMessage[];
26
65
  tools?: LLMToolDefinition[];
27
66
  temperature?: number;
28
67
  maxTokens?: number;
68
+ /** How tools are encoded on the wire. Default `native`. */
69
+ toolMode?: ToolMode;
70
+ }
71
+ /**
72
+ * Moments in the provider round trip that separate application delay from
73
+ * network/queue delay from model latency. The callback is invoked
74
+ * synchronously at each point, so `performance.now()` taken inside it is the
75
+ * event time.
76
+ *
77
+ * - `request-start` — immediately before the HTTP request is issued.
78
+ * - `headers` — the response headers arrived (2xx).
79
+ * - `first-chunk` — the first SSE chunk was parsed.
80
+ */
81
+ export type LLMStreamTimingPoint = "request-start" | "headers" | "first-chunk";
82
+ export type LLMStreamTimingCallback = (point: LLMStreamTimingPoint) => void;
83
+ /** Token usage reported by the provider (when it includes usage in the stream). */
84
+ export interface LLMUsage {
85
+ promptTokens: number;
86
+ completionTokens: number;
29
87
  }
88
+ export type LLMUsageCallback = (usage: LLMUsage) => void;
30
89
  export type LLMEvent = {
31
90
  type: "delta";
32
91
  content: string;
92
+ /**
93
+ * Reasoning/thinking tokens, when the provider streams them separately
94
+ * from content (OpenRouter `reasoning`, DeepSeek `reasoning_content`).
95
+ * Omitted when the model does not emit reasoning.
96
+ */
97
+ reasoning?: string;
33
98
  } | {
34
99
  type: "tool_call";
35
100
  id: string;
@@ -13,7 +13,10 @@ export interface STTSocket {
13
13
  }
14
14
  export interface DeepgramOptions extends STTOptions {
15
15
  apiKey: string;
16
- /** Defaults to `wss://api.deepgram.com/v1/listen`. */
16
+ /**
17
+ * Overrides the listen endpoint. Defaults to `wss://api.deepgram.com/v2/listen`
18
+ * for Flux models (`flux-*`) and `wss://api.deepgram.com/v1/listen` otherwise.
19
+ */
17
20
  endpoint?: string;
18
21
  /** Injectable socket factory, mainly for tests. */
19
22
  createSocket?: (url: string) => STTSocket;
@@ -1 +1,2 @@
1
1
  export { DeepgramSTT } from "./deepgram/deepgram.js";
2
+ export { OpenRouterSTT } from "./openrouter/openrouter.js";
@@ -0,0 +1,2 @@
1
+ export { OpenRouterSTT, OpenRouterSession, toWav } from "./openrouter.js";
2
+ export type { OpenRouterAudioFormat, OpenRouterSTTOptions } from "./openrouter.js";
@@ -0,0 +1,196 @@
1
+ import type { STT, STTOptions, STTSession } from "../../types.js";
2
+ import type { FetchLike } from "../../../shared.js";
3
+ /** Audio formats the OpenRouter transcription endpoint accepts. */
4
+ export type OpenRouterAudioFormat = "pcm" | "mp3" | "flac" | "m4a" | "ogg" | "webm" | "aac";
5
+ export interface OpenRouterSTTOptions extends STTOptions {
6
+ apiKey: string;
7
+ /** Defaults to `https://openrouter.ai/api/v1`. */
8
+ baseUrl?: string;
9
+ /** The STT model. Defaults to `openai/whisper-large-v3-turbo`. */
10
+ model?: string;
11
+ /**
12
+ * Silence (ms) that ends an utterance. OpenRouter's transcription endpoint
13
+ * is batch-only (one request per audio clip), so the adapter segments the
14
+ * incoming stream client-side and transcribes a clip once this much silence
15
+ * has elapsed since the last audio. Default 800.
16
+ */
17
+ silenceMs?: number;
18
+ /**
19
+ * Format of the audio written to the session. `"pcm"` (the default)
20
+ * assumes raw linear16 samples at `sampleRate` and wraps each clip in a
21
+ * WAV container. Pass the actual encoding (e.g. `"mp3"`, `"ogg"`, …) when
22
+ * feeding pre-encoded audio — those formats are self-describing and are
23
+ * sent as-is.
24
+ */
25
+ audioFormat?: OpenRouterAudioFormat;
26
+ /**
27
+ * Strip common whisper hallucinations from transcripts: asterisk stage
28
+ * directions ("*Dramatic music*"), repeated filler phrases ("Thank you.
29
+ * Thank you."), and pure-filler clips whisper emits on near-silence
30
+ * ("Thank you.", "E aí.", "Bye.", …). Set `false` to pass transcripts
31
+ * through untouched. Default `true`.
32
+ */
33
+ filterHallucinations?: boolean;
34
+ /**
35
+ * Extra phrases (lowercased) treated as hallucinations on top of the
36
+ * built-in multilingual filler list — for fillers whisper "hears" in the
37
+ * languages you deploy. A transcript that is *entirely* built from known
38
+ * fillers is dropped. Default none.
39
+ */
40
+ fillerPhrases?: string[];
41
+ /**
42
+ * Energy floor (0–1 RMS, on the raw sample range) for transcribing a
43
+ * buffered `pcm` clip. Near-silence clips — the ones whisper hallucinates
44
+ * "E aí." / "Thank you." / *stage directions* on — are skipped entirely
45
+ * (no transcription request, no `final`), instead of being filtered after
46
+ * the fact. Real speech sits far above any reasonable floor; start around
47
+ * `0.01`–`0.02` and raise it if artifacts persist. Only applies to
48
+ * `audioFormat: "pcm"` (the only format whose samples are measurable).
49
+ * Default: no floor (transcribe everything the client sends).
50
+ */
51
+ minClipRms?: number;
52
+ /**
53
+ * Called for every buffered `pcm` clip with its measured mean RMS and
54
+ * whether it was transcribed — for logging the real distribution and
55
+ * tuning `minClipRms` against it (speech clips sit far above artifact
56
+ * clips). Fires when this callback or `minClipRms` is set.
57
+ */
58
+ onClipEnergy?: (rms: number, transcribed: boolean) => void;
59
+ /**
60
+ * Abort a transcription request that produces no response within this
61
+ * long (default 30000ms). Transcriptions are serialized on one session
62
+ * chain, so a hung provider request would otherwise block every later
63
+ * clip (each turn silently waits) until the server restarts. Raise it for
64
+ * very long clips or slow providers.
65
+ */
66
+ transcriptionTimeoutMs?: number;
67
+ /**
68
+ * Sampling temperature (0–1) for transcription. Lower is more
69
+ * deterministic; whisper's API default is already 0, so this is rarely the
70
+ * lever for hallucinations.
71
+ */
72
+ temperature?: number;
73
+ /**
74
+ * Provider-specific passthrough, serialized as the `provider` multipart
75
+ * field. OpenRouter ignores the top-level `prompt` field ("accepted but
76
+ * ignored"), so the only way to reach whisper's prompt — vocabulary /
77
+ * context steering — is per-provider:
78
+ *
79
+ * ```ts
80
+ * providerOptions: { options: { groq: { prompt: "Transcribe exactly what is said." } } }
81
+ * ```
82
+ *
83
+ * Only the options for the provider that actually serves the request are
84
+ * forwarded, so the key must match the serving provider (openai, groq,
85
+ * together, …).
86
+ */
87
+ providerOptions?: Record<string, unknown>;
88
+ /** Injectable fetch, mainly for tests. */
89
+ fetch?: FetchLike;
90
+ }
91
+ /**
92
+ * OpenRouter batch STT adapter (`POST /api/v1/audio/transcriptions`).
93
+ *
94
+ * OpenRouter does not stream transcripts — it transcribes a complete audio
95
+ * clip and returns the text. The adapter therefore buffers the raw audio
96
+ * written by `write()`, assumes linear16 PCM (mono, `sampleRate`, default
97
+ * 16 kHz — matching the Deepgram adapter's defaults), wraps each utterance
98
+ * in a WAV header, and posts it after `silenceMs` of silence. Interim
99
+ * results are unavailable, so no `partial` events are ever emitted: a turn
100
+ * arrives whole at the `final` event once its clip has been transcribed.
101
+ *
102
+ * `language` accepts an ISO-639-1 code to force a language (which whisper
103
+ * docs say improves accuracy and latency); omitting it — or passing `"auto"`,
104
+ * the whisper convention, which is normalized to "omit" — leaves detection to
105
+ * the provider, matching OpenRouter's "auto-detected if omitted" contract.
106
+ *
107
+ * By default the written audio is treated as raw linear16 PCM and wrapped in
108
+ * a WAV container; set `audioFormat` to the real encoding (e.g. `"mp3"`) to
109
+ * send pre-encoded audio as-is instead.
110
+ *
111
+ * `end()` transcribes any remaining buffered audio; `cancel()` drops
112
+ * buffered audio and aborts in-flight requests.
113
+ */
114
+ export declare class OpenRouterSTT implements STT {
115
+ private readonly options;
116
+ private readonly sessions;
117
+ constructor(options: OpenRouterSTTOptions);
118
+ start(options?: STTOptions): STTSession;
119
+ /**
120
+ * Live-tunable energy floor (0–1 RMS) for `pcm` clips: raise it to skip
121
+ * more near-silence clips (the whisper hallucinations), lower it to keep
122
+ * quieter speech. Applies to all sessions immediately.
123
+ */
124
+ set minClipRms(value: number | undefined);
125
+ get minClipRms(): number | undefined;
126
+ cancel(): void;
127
+ }
128
+ export declare class OpenRouterSession implements STTSession {
129
+ private readonly listeners;
130
+ private readonly apiKey;
131
+ private readonly baseUrl;
132
+ private readonly model;
133
+ private readonly language;
134
+ private readonly sampleRate;
135
+ private readonly silenceMs;
136
+ private readonly audioFormat;
137
+ private readonly filterHallucinations;
138
+ private readonly fillerPhrases;
139
+ private readonly onClipEnergy;
140
+ private readonly transcriptionTimeoutMs;
141
+ private readonly temperature;
142
+ private readonly providerOptions;
143
+ private readonly fetchImpl;
144
+ /** The adapter's live options object; live-tunable fields are read here. */
145
+ private readonly liveOptions;
146
+ /** Live-tunable energy floor, read through the adapter (not a snapshot). */
147
+ private get minClipRms();
148
+ private chunks;
149
+ private timer;
150
+ private chain;
151
+ private readonly controllers;
152
+ private ended;
153
+ private aborted;
154
+ constructor(options: OpenRouterSTTOptions, liveOptions: OpenRouterSTTOptions);
155
+ write(audio: Uint8Array): void;
156
+ end(): Promise<void>;
157
+ /** Drop buffered audio and abort in-flight requests (cancel). */
158
+ abort(): void;
159
+ on(event: "partial", listener: (transcript: string) => void): void;
160
+ on(event: "final", listener: (transcript: string) => void): void;
161
+ on(event: "error", listener: (error: Error) => void): void;
162
+ on(event: "close", listener: () => void): void;
163
+ /** Queue a transcription of whatever audio is buffered (serialized). */
164
+ /**
165
+ * Queue a transcription of whatever audio is buffered (serialized). The
166
+ * clip boundary is frozen *now* — the moment the trailing silence was
167
+ * detected — so audio that arrives while this transcription is queued or
168
+ * in flight starts the next clip instead of being swept into this one.
169
+ */
170
+ private flush;
171
+ private takeBuffer;
172
+ private transcribe;
173
+ private emit;
174
+ }
175
+ /**
176
+ * Wrap linear16 PCM (mono) in a minimal WAV container so whisper can read it.
177
+ * The header is the standard 44-byte RIFF/WAVE layout.
178
+ */
179
+ export declare function toWav(pcm: Uint8Array, sampleRate: number): Uint8Array;
180
+ /**
181
+ * Mean RMS of linear16 PCM (mono), in the 0–1 sample range. Used as the
182
+ * clip-level energy floor: near-silence clips sit far below real speech.
183
+ */
184
+ export declare function pcmRms(pcm: Uint8Array): number;
185
+ /**
186
+ * Clean a whisper transcript of its most common hallucinations, returning
187
+ * "" when nothing worth speaking remains:
188
+ *
189
+ * 1. Asterisk stage directions ("*Dramatic music*", "*laughs*") are
190
+ * dropped — whisper transcribes background noise as stage notes.
191
+ * 2. Consecutive repeated sentences ("Thank you. Thank you.") collapse to
192
+ * one — a doubled filler is a classic near-silence artifact.
193
+ * 3. A transcript built entirely from filler phrases (the built-in
194
+ * multilingual list plus `extraFillers`) is dropped.
195
+ */
196
+ export declare function cleanTranscript(text: string, extraFillers?: string[]): string;
@@ -1 +1,2 @@
1
1
  export { KokoroTTS } from "./kokoro/kokoro.js";
2
+ export { OpenRouterTTS } from "./openrouter/openrouter.js";
@@ -4,21 +4,35 @@ export interface KokoroOptions {
4
4
  /**
5
5
  * Base URL of a Kokoro TTS server exposing the OpenAI-compatible
6
6
  * `/v1/audio/speech` endpoint. Defaults to a local kokoro-fastapi server.
7
+ * For Together AI use `https://api.together.ai`.
7
8
  */
8
9
  baseUrl?: string;
9
10
  /** Default voice, e.g. `af_heart`. */
10
11
  voice?: string;
12
+ /**
13
+ * Model name. Defaults to `kokoro` (local kokoro-fastapi); Together AI
14
+ * serves the model as `hexgrad/Kokoro-82M`.
15
+ */
11
16
  model?: string;
12
17
  apiKey?: string;
13
18
  /** Size of the audio chunks yielded from the response stream. */
14
19
  chunkSize?: number;
20
+ /**
21
+ * Ask the server for progressive (streaming) synthesis. Local
22
+ * kokoro-fastapi streams by default; hosted endpoints such as Together AI
23
+ * require this flag. Together AI responds with server-sent events carrying
24
+ * base64-encoded audio deltas (pcm_s16le, 24 kHz for Kokoro) terminated by
25
+ * `data: [DONE]`; the adapter decodes them into raw audio chunks. wav/mp3
26
+ * formats are not streamable.
27
+ */
28
+ stream?: boolean;
15
29
  /** Injectable fetch implementation, mainly for tests. */
16
30
  fetch?: FetchLike;
17
31
  }
18
32
  /**
19
33
  * Kokoro TTS adapter. Consumes a Kokoro server's OpenAI-compatible speech
20
- * endpoint and re-chunks the returned audio so it can be played as it
21
- * arrives.
34
+ * endpoint (local kokoro-fastapi or a hosted service such as Together AI)
35
+ * and re-chunks the returned audio so it can be played as it arrives.
22
36
  */
23
37
  export declare class KokoroTTS implements TTS {
24
38
  private readonly baseUrl;
@@ -26,8 +40,9 @@ export declare class KokoroTTS implements TTS {
26
40
  private readonly model;
27
41
  private readonly apiKey;
28
42
  private readonly chunkSize;
43
+ private readonly streaming;
29
44
  private readonly fetchImpl;
30
- private abort;
45
+ private readonly streams;
31
46
  constructor(options?: KokoroOptions);
32
47
  stop(): void;
33
48
  stream(request: TTSRequest): AsyncGenerator<Uint8Array>;
@@ -0,0 +1,2 @@
1
+ export { OpenRouterTTS } from "./openrouter.js";
2
+ export type { OpenRouterTTSOptions } from "./openrouter.js";
@@ -0,0 +1,64 @@
1
+ import type { TTS, TTSRequest } from "../../types.js";
2
+ import type { FetchLike } from "../../../shared.js";
3
+ export interface OpenRouterTTSOptions {
4
+ apiKey: string;
5
+ /** Defaults to `https://openrouter.ai/api/v1`. */
6
+ baseUrl?: string;
7
+ /**
8
+ * TTS model. Defaults to the free `fish-audio/s2.1-pro-free:free` variant —
9
+ * fast, per-character priced. Pass `fish-audio/s2.1-pro` for the paid tier
10
+ * (no free-variant rate limits). Note the free variant is intermittently
11
+ * unavailable on OpenRouter (404 "No endpoints found").
12
+ */
13
+ model?: string;
14
+ /**
15
+ * Default voice, sent when the request carries none. Set it for a
16
+ * consistent voice: the default fish model accepts exactly `"alloy"` and
17
+ * rejects other names, and omitting `voice` lets the free variant vary the
18
+ * voice per request. Models like OpenAI TTS require a voice. Voice support
19
+ * varies by model and provider.
20
+ */
21
+ voice?: string;
22
+ /**
23
+ * Output format used when the request doesn't specify one. `"pcm"` (the
24
+ * default) is the lowest-latency realtime format, but its sample rate is
25
+ * provider-defined and opaque — clients must know it. `"mp3"` is
26
+ * self-describing: decoders read the real rate from the stream.
27
+ */
28
+ format?: "pcm" | "mp3";
29
+ /** Size of the audio chunks yielded from the response stream. Default 8192. */
30
+ chunkSize?: number;
31
+ /**
32
+ * Abort a synthesis that delivers no audio bytes for this long (default
33
+ * 15000ms). A provider connection that goes silent — or never responds —
34
+ * would otherwise wedge the speech pipeline forever, since the pipeline
35
+ * holds one synthesis slot and its delivery chain until the stream ends.
36
+ * Any byte resets the clock; a genuinely slow synthesis just needs a
37
+ * response within this window.
38
+ */
39
+ idleTimeoutMs?: number;
40
+ /** Injectable fetch, mainly for tests. */
41
+ fetch?: FetchLike;
42
+ }
43
+ /**
44
+ * OpenRouter TTS adapter (`POST /api/v1/audio/speech`, OpenAI-compatible).
45
+ *
46
+ * The endpoint returns raw audio bytes (not JSON) in `mp3` or `pcm` format.
47
+ * The adapter re-chunks the response stream so audio can be played as it
48
+ * arrives; `stop()` aborts the in-flight synthesis. `pcm` is the default
49
+ * output (OpenRouter's own recommendation for realtime pipelines).
50
+ */
51
+ export declare class OpenRouterTTS implements TTS {
52
+ private readonly apiKey;
53
+ private readonly baseUrl;
54
+ private readonly model;
55
+ private readonly voice;
56
+ private readonly format;
57
+ private readonly chunkSize;
58
+ private readonly idleTimeoutMs;
59
+ private readonly fetchImpl;
60
+ private readonly streams;
61
+ constructor(options: OpenRouterTTSOptions);
62
+ stop(): void;
63
+ stream(request: TTSRequest): AsyncGenerator<Uint8Array>;
64
+ }