@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,42 @@
1
+ /**
2
+ * ConversationStream — the conversation's semantic reply stream.
3
+ *
4
+ * Turns a Conversation's event stream (LLM text fragments + generation
5
+ * completion) into FieldStream completion events: consumers act on partial
6
+ * reply text without waiting for the reply to finish.
7
+ *
8
+ * const replies = new ConversationStream(conversation);
9
+ * replies.whenItem("text", (fragment, i) => render(fragment));
10
+ * replies.when("agent", (agent) => showSpeaker(agent));
11
+ * replies.whenObjectDone((reply) => finalize(reply));
12
+ * replies.cancel(); // aborts the current generation (interrupts the LLM)
13
+ *
14
+ * One semantic object per top-level generation (agent or coordination
15
+ * reply). The `text` field is an ordered sequence of completed text
16
+ * fragments — semantically "the next fragment of the reply arrived", not
17
+ * "whatever happened to be inside a provider SSE packet". Fragment sizes are
18
+ * an implementation detail of the producer and may be coalesced later.
19
+ *
20
+ * Lifecycle per reply:
21
+ *
22
+ * first fragment ──▶ STREAMING ──generation-complete──▶ DONE
23
+ * ├──cancel()/interrupt──▶ CANCELLED
24
+ * └──provider error──────▶ FAILED
25
+ *
26
+ * Each boundary fires at most once; no completion event fires after a
27
+ * terminal state. Interruptions and errors leave already-delivered fragments
28
+ * as valid partial state. Delegated sub-generation results do not terminate
29
+ * the top-level reply — only the top-level generation's completion does.
30
+ */
31
+ import { FieldStream } from "../../transport/streamobject/field-stream/field-stream.js";
32
+ import type { Conversation } from "../conversation/conversation.js";
33
+ export declare class ConversationStream extends FieldStream {
34
+ private readonly unsubscribers;
35
+ private active;
36
+ constructor(conversation: Conversation);
37
+ /** Stop listening to the conversation. */
38
+ dispose(): void;
39
+ private onDelta;
40
+ private completeReply;
41
+ private abortReply;
42
+ }
@@ -0,0 +1 @@
1
+ export { ConversationStream } from "./conversation-stream.js";
@@ -24,6 +24,29 @@ export interface Turn {
24
24
  endedAt: number;
25
25
  }
26
26
  export type GenerationStatus = "streaming" | "completed" | "cancelled";
27
+ /**
28
+ * Latency instrumentation for a generation. Times are epoch milliseconds;
29
+ * only `startedAt` is always present. The chain distinguishes each hop:
30
+ *
31
+ * ```text
32
+ * turn → first LLM token → first TTS text (buffering flush)
33
+ * → TTS requested → TTS first audio → audio delivered → completed
34
+ * ```
35
+ */
36
+ export interface GenerationTiming {
37
+ startedAt: number;
38
+ /** First LLM delta of this generation (first-token latency). */
39
+ firstTokenAt?: number;
40
+ /** First sentence flushed to TTS (text buffering latency). */
41
+ firstTtsTextAt?: number;
42
+ /** First TTS stream request issued (queue latency). */
43
+ firstTtsRequestAt?: number;
44
+ /** First audio chunk produced by the TTS provider (provider latency). */
45
+ firstTtsAudioAt?: number;
46
+ /** First TTS audio chunk delivered to the application (transport latency). */
47
+ firstAudioAt?: number;
48
+ completedAt?: number;
49
+ }
27
50
  export interface Generation {
28
51
  id: string;
29
52
  conversationId: ConversationId;
@@ -32,6 +55,15 @@ export interface Generation {
32
55
  status: GenerationStatus;
33
56
  startedAt: number;
34
57
  endedAt?: number;
58
+ /**
59
+ * "sub" marks a task dispatched to another agent by the coordinator.
60
+ * Regular agent replies omit this field.
61
+ */
62
+ kind?: "sub";
63
+ /** For sub-generations: the id of the coordinator generation that dispatched them. */
64
+ parentGenerationId?: string;
65
+ /** Latency instrumentation, recorded as the generation streams. */
66
+ timing?: GenerationTiming;
35
67
  }
36
68
  export interface ToolCall {
37
69
  id: string;
@@ -1,44 +1,11 @@
1
- import { Agent, type AgentOptions } from "./agents/agent.js";
2
- import { Conversations } from "./conversations/conversations.js";
3
- import type { Persistence } from "./persistence/persistence.js";
4
- import type { LLM } from "./providers/llm/types.js";
5
- import type { STT } from "./providers/stt/types.js";
6
- import type { TTS } from "./providers/tts/types.js";
7
- export interface PipeflowOptions {
8
- llm?: LLM;
9
- stt?: STT;
10
- tts?: TTS;
11
- persistence?: Persistence;
12
- }
13
- /**
14
- * The Pipeflow entry point.
15
- *
16
- * ```ts
17
- * const pipeflow = new Pipeflow({ llm });
18
- * const agent = pipeflow.agent({ name: "Jarvis", context: "..." });
19
- * const conversation = await pipeflow.conversations.create({ agents: [agent] });
20
- * ```
21
- */
22
- export declare class Pipeflow {
23
- readonly llm: LLM | undefined;
24
- readonly stt: STT | undefined;
25
- readonly tts: TTS | undefined;
26
- readonly conversations: Conversations;
27
- constructor(options?: PipeflowOptions);
28
- /**
29
- * Create an agent. Agents inherit the Pipeflow instance's LLM provider so
30
- * `agent.run()` works out of the box.
31
- */
32
- agent(options: Omit<AgentOptions, "llm"> & {
33
- llm?: LLM;
34
- }): Agent;
35
- }
36
- export { Agent };
1
+ export { Pipeflow } from "./pipeflow.js";
2
+ export type { PipeflowOptions } from "./pipeflow.js";
3
+ export { Agent } from "./agents/agent.js";
37
4
  export type { AgentOptions, AgentRunRequest, AgentRunResult, ExecutedToolCall, } from "./agents/agent.js";
38
5
  export { Tool, Tool as PipeflowTool } from "./agents/tools/tools.js";
39
6
  export type { ToolOptions } from "./agents/tools/tools.js";
40
- export { Conversation, Conversations, Orchestrator, Transcription, TranscriptEntry, } from "./conversations/index.js";
41
- export type { AudioChunk, ConversationEvents, ConversationId, ConversationOptions, ConversationState, ConversationStatus, CreateConversationOptions, Generation, GenerationStatus, OrchestratorOptions, Participant, ParticipantInput, ToolCall, ToolCallResult, TranscriptEntryInput, TranscriptSpeakerKind, Turn, TurnId, UserId, } from "./conversations/index.js";
7
+ export { Conversation, Conversations, Transcription, TranscriptEntry, } from "./conversations/index.js";
8
+ export type { AudioChunk, ConversationEvents, ConversationId, ConversationOptions, ConversationState, ConversationStatus, CreateConversationOptions, Generation, GenerationStatus, Participant, ParticipantInput, ToolCall, ToolCallResult, TranscriptEntryInput, TranscriptSpeakerKind, Turn, TurnId, UserId, } from "./conversations/index.js";
42
9
  export type { LLM, LLMMessage } from "./providers/llm/types.js";
43
10
  export type { STT } from "./providers/stt/types.js";
44
11
  export type { TTS } from "./providers/tts/types.js";
@@ -0,0 +1,2 @@
1
+ export { Pipeflow } from "./pipeflow.js";
2
+ export type { PipeflowOptions } from "./pipeflow.js";
@@ -0,0 +1,35 @@
1
+ import { Agent, type AgentOptions } from "../agents/agent.js";
2
+ import { Conversations } from "../conversations/conversations.js";
3
+ import type { Persistence } from "../persistence/persistence.js";
4
+ import type { LLM } from "../providers/llm/types.js";
5
+ import type { STT } from "../providers/stt/types.js";
6
+ import type { TTS } from "../providers/tts/types.js";
7
+ export interface PipeflowOptions {
8
+ llm?: LLM;
9
+ stt?: STT;
10
+ tts?: TTS;
11
+ persistence?: Persistence;
12
+ }
13
+ /**
14
+ * The Pipeflow entry point.
15
+ *
16
+ * ```ts
17
+ * const pipeflow = new Pipeflow({ llm });
18
+ * const agent = pipeflow.agent({ name: "Jarvis", context: "..." });
19
+ * const conversation = await pipeflow.conversations.create({ agents: [agent] });
20
+ * ```
21
+ */
22
+ export declare class Pipeflow {
23
+ readonly llm: LLM | undefined;
24
+ readonly stt: STT | undefined;
25
+ readonly tts: TTS | undefined;
26
+ readonly conversations: Conversations;
27
+ constructor(options?: PipeflowOptions);
28
+ /**
29
+ * Create an agent. Agents inherit the Pipeflow instance's LLM provider so
30
+ * `agent.run()` works out of the box.
31
+ */
32
+ agent(options: Omit<AgentOptions, "llm"> & {
33
+ llm?: LLM;
34
+ }): Agent;
35
+ }
@@ -1,6 +1,6 @@
1
1
  export type { LLM, LLMEvent, LLMMessage, LLMRole, LLMToolCall, LLMToolDefinition, LLMRequest } from "./llm/index.js";
2
2
  export type { STT, STTOptions, STTSession } from "./stt/index.js";
3
3
  export type { TTS, TTSRequest } from "./tts/index.js";
4
- export { complete, streamText, DeepSeekLLM } from "./llm/index.js";
4
+ export { complete, streamText, DeepSeekLLM, OpenRouterLLM } from "./llm/index.js";
5
5
  export { DeepgramSTT } from "./stt/index.js";
6
6
  export { KokoroTTS } from "./tts/index.js";
@@ -0,0 +1,45 @@
1
+ import type { LLM, LLMEvent, LLMRequest, LLMStreamTimingCallback, LLMUsageCallback } from "../../types.js";
2
+ import type { FetchLike } from "../../../shared.js";
3
+ export interface ClaudeOptions {
4
+ apiKey: string;
5
+ /** Defaults to `claude-sonnet-4-5`. */
6
+ model?: string;
7
+ /** Defaults to `https://api.anthropic.com/v1`. */
8
+ baseUrl?: string;
9
+ /** Injectable fetch implementation, mainly for tests. */
10
+ fetch?: FetchLike;
11
+ /** Provider-timeline hook: request-start / headers / first-chunk. */
12
+ onTiming?: LLMStreamTimingCallback;
13
+ /**
14
+ * Abort a stream that delivers no data for this long (default 8000ms) —
15
+ * protects against provider connections that go silent after the model
16
+ * already produced its output. Raise it for providers with slow TTFT.
17
+ */
18
+ idleTimeoutMs?: number;
19
+ /** Called with the provider-reported token usage (when included). */
20
+ onUsage?: LLMUsageCallback;
21
+ }
22
+ /**
23
+ * Claude LLM adapter (Anthropic Messages API over SSE).
24
+ *
25
+ * The wire format differs from the OpenAI-compatible adapters: tools are
26
+ * `input_schema` blocks, tool calls arrive as `tool_use` content blocks with
27
+ * `input_json_delta` fragments (reassembled here into `tool_call` events),
28
+ * tool results are `tool_result` blocks inside user messages, and `max_tokens`
29
+ * is required. There is no `response_format`, so `toolMode` is not supported —
30
+ * tool calling is always native.
31
+ */
32
+ export declare class ClaudeLLM implements LLM {
33
+ private readonly apiKey;
34
+ private readonly model;
35
+ private readonly baseUrl;
36
+ private readonly fetchImpl;
37
+ private readonly onTiming;
38
+ private readonly idleTimeoutMs;
39
+ private readonly onUsage;
40
+ private readonly streams;
41
+ constructor(options: ClaudeOptions);
42
+ /** Cancel every in-flight stream (parallel sub-generations included). */
43
+ stop(): void;
44
+ stream(request: LLMRequest): AsyncGenerator<LLMEvent>;
45
+ }
@@ -0,0 +1,2 @@
1
+ export { ClaudeLLM } from "./claude.js";
2
+ export type { ClaudeOptions } from "./claude.js";
@@ -1,4 +1,4 @@
1
- import type { LLM, LLMEvent, LLMRequest } from "../../types.js";
1
+ import type { LLM, LLMEvent, LLMRequest, LLMStreamTimingCallback, LLMUsageCallback, ToolMode } from "../../types.js";
2
2
  import type { FetchLike } from "../../../shared.js";
3
3
  export interface DeepSeekOptions {
4
4
  apiKey: string;
@@ -8,6 +8,22 @@ export interface DeepSeekOptions {
8
8
  baseUrl?: string;
9
9
  /** Injectable fetch implementation, mainly for tests. */
10
10
  fetch?: FetchLike;
11
+ /** Provider-timeline hook: request-start / headers / first-chunk. */
12
+ onTiming?: LLMStreamTimingCallback;
13
+ /**
14
+ * Abort a stream that delivers no data for this long (default 8000ms) —
15
+ * protects against provider connections that go silent after the model
16
+ * already produced its output. Raise it for providers with slow TTFT.
17
+ */
18
+ idleTimeoutMs?: number;
19
+ /** Called with the provider-reported token usage (when included). */
20
+ onUsage?: LLMUsageCallback;
21
+ /**
22
+ * Default tool encoding for requests that don't set `toolMode` (the
23
+ * request's `toolMode` wins). For models whose endpoints lack native tool
24
+ * calling.
25
+ */
26
+ toolMode?: ToolMode;
11
27
  }
12
28
  /**
13
29
  * DeepSeek LLM adapter (OpenAI-compatible chat completions over SSE).
@@ -17,8 +33,13 @@ export declare class DeepSeekLLM implements LLM {
17
33
  private readonly model;
18
34
  private readonly baseUrl;
19
35
  private readonly fetchImpl;
20
- private abort;
36
+ private readonly onTiming;
37
+ private readonly idleTimeoutMs;
38
+ private readonly onUsage;
39
+ private readonly toolMode;
40
+ private readonly streams;
21
41
  constructor(options: DeepSeekOptions);
42
+ /** Cancel every in-flight stream (parallel sub-generations included). */
22
43
  stop(): void;
23
44
  stream(request: LLMRequest): AsyncGenerator<LLMEvent>;
24
45
  }
@@ -1 +1,4 @@
1
1
  export { DeepSeekLLM } from "./deepseek/deepseek.js";
2
+ export { OpenRouterLLM } from "./openrouter/openrouter.js";
3
+ export { OpenAILLM } from "./openai/openai.js";
4
+ export { ClaudeLLM } from "./claude/claude.js";
@@ -0,0 +1,2 @@
1
+ export { OpenAILLM } from "./openai.js";
2
+ export type { OpenAIOptions } from "./openai.js";
@@ -0,0 +1,45 @@
1
+ import type { LLM, LLMEvent, LLMRequest, LLMStreamTimingCallback, LLMUsageCallback, ToolMode } from "../../types.js";
2
+ import type { FetchLike } from "../../../shared.js";
3
+ export interface OpenAIOptions {
4
+ apiKey: string;
5
+ /** Defaults to `gpt-4o-mini`. */
6
+ model?: string;
7
+ /** Defaults to `https://api.openai.com/v1`. */
8
+ baseUrl?: string;
9
+ /** Injectable fetch implementation, mainly for tests. */
10
+ fetch?: FetchLike;
11
+ /** Provider-timeline hook: request-start / headers / first-chunk. */
12
+ onTiming?: LLMStreamTimingCallback;
13
+ /**
14
+ * Abort a stream that delivers no data for this long (default 8000ms) —
15
+ * protects against provider connections that go silent after the model
16
+ * already produced its output. Raise it for providers with slow TTFT.
17
+ */
18
+ idleTimeoutMs?: number;
19
+ /** Called with the provider-reported token usage (when included). */
20
+ onUsage?: LLMUsageCallback;
21
+ /**
22
+ * Default tool encoding for requests that don't set `toolMode` (the
23
+ * request's `toolMode` wins). For models whose endpoints lack native tool
24
+ * calling.
25
+ */
26
+ toolMode?: ToolMode;
27
+ }
28
+ /**
29
+ * OpenAI LLM adapter (OpenAI-compatible chat completions over SSE).
30
+ */
31
+ export declare class OpenAILLM implements LLM {
32
+ private readonly apiKey;
33
+ private readonly model;
34
+ private readonly baseUrl;
35
+ private readonly fetchImpl;
36
+ private readonly onTiming;
37
+ private readonly idleTimeoutMs;
38
+ private readonly onUsage;
39
+ private readonly toolMode;
40
+ private readonly streams;
41
+ constructor(options: OpenAIOptions);
42
+ /** Cancel every in-flight stream (parallel sub-generations included). */
43
+ stop(): void;
44
+ stream(request: LLMRequest): AsyncGenerator<LLMEvent>;
45
+ }
@@ -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,77 @@ 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.
46
+ */
47
+ export type ToolMode = "native" | "envelope" | "prompted";
48
+ /**
49
+ * A string that may also be one of the branded literal values — e.g. any
50
+ * model id, with the favorites offered for autocomplete. The `& {}` on the
51
+ * string side stops TypeScript from absorbing the literals into `string`
52
+ * (the reverse arrangement — `string | (T & {})` — collapses and loses the
53
+ * literals).
54
+ */
55
+ export type StringOr<T extends string> = T | (string & {});
56
+ /** Models measured as usable; offered for autocomplete where a model id is taken. */
57
+ 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"];
58
+ /** Any model id, with the favorites offered for autocomplete. */
59
+ export type FavoriteModel = StringOr<(typeof FAVORITE_MODELS)[number]>;
24
60
  export interface LLMRequest {
25
61
  messages: LLMMessage[];
26
62
  tools?: LLMToolDefinition[];
27
63
  temperature?: number;
28
64
  maxTokens?: number;
65
+ /** How tools are encoded on the wire. Default `native`. */
66
+ toolMode?: ToolMode;
67
+ }
68
+ /**
69
+ * Moments in the provider round trip that separate application delay from
70
+ * network/queue delay from model latency. The callback is invoked
71
+ * synchronously at each point, so `performance.now()` taken inside it is the
72
+ * event time.
73
+ *
74
+ * - `request-start` — immediately before the HTTP request is issued.
75
+ * - `headers` — the response headers arrived (2xx).
76
+ * - `first-chunk` — the first SSE chunk was parsed.
77
+ */
78
+ export type LLMStreamTimingPoint = "request-start" | "headers" | "first-chunk";
79
+ export type LLMStreamTimingCallback = (point: LLMStreamTimingPoint) => void;
80
+ /** Token usage reported by the provider (when it includes usage in the stream). */
81
+ export interface LLMUsage {
82
+ promptTokens: number;
83
+ completionTokens: number;
29
84
  }
85
+ export type LLMUsageCallback = (usage: LLMUsage) => void;
30
86
  export type LLMEvent = {
31
87
  type: "delta";
32
88
  content: string;
89
+ /**
90
+ * Reasoning/thinking tokens, when the provider streams them separately
91
+ * from content (OpenRouter `reasoning`, DeepSeek `reasoning_content`).
92
+ * Omitted when the model does not emit reasoning.
93
+ */
94
+ reasoning?: string;
33
95
  } | {
34
96
  type: "tool_call";
35
97
  id: string;