@pipedog/core 0.0.0 → 0.1.0

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 (698) hide show
  1. package/LICENSE +25 -0
  2. package/NOTICE +9 -0
  3. package/dist/adapters/base_llm_adapter.d.ts +266 -0
  4. package/dist/adapters/base_llm_adapter.js +489 -0
  5. package/dist/adapters/index.d.ts +2 -0
  6. package/dist/adapters/index.js +8 -0
  7. package/dist/adapters/schemas/direct_function.d.ts +202 -0
  8. package/dist/adapters/schemas/direct_function.js +302 -0
  9. package/dist/adapters/schemas/function_schema.d.ts +67 -0
  10. package/dist/adapters/schemas/function_schema.js +72 -0
  11. package/dist/adapters/schemas/index.d.ts +2 -0
  12. package/dist/adapters/schemas/index.js +8 -0
  13. package/dist/adapters/schemas/tools_schema.d.ts +57 -0
  14. package/dist/adapters/schemas/tools_schema.js +79 -0
  15. package/dist/adapters/services/index.d.ts +2 -0
  16. package/dist/adapters/services/index.js +8 -0
  17. package/dist/adapters/services/open_ai_adapter.d.ts +147 -0
  18. package/dist/adapters/services/open_ai_adapter.js +250 -0
  19. package/dist/audio/dtmf/dtmf_data.d.ts +3 -0
  20. package/dist/audio/dtmf/dtmf_data.js +22 -0
  21. package/dist/audio/dtmf/index.d.ts +2 -0
  22. package/dist/audio/dtmf/index.js +8 -0
  23. package/dist/audio/dtmf/types.d.ts +31 -0
  24. package/dist/audio/dtmf/types.js +35 -0
  25. package/dist/audio/dtmf/utils.d.ts +13 -0
  26. package/dist/audio/dtmf/utils.js +62 -0
  27. package/dist/audio/filters/base_audio_filter.d.ts +51 -0
  28. package/dist/audio/filters/base_audio_filter.js +17 -0
  29. package/dist/audio/filters/index.d.ts +2 -0
  30. package/dist/audio/filters/index.js +8 -0
  31. package/dist/audio/index.d.ts +2 -0
  32. package/dist/audio/index.js +8 -0
  33. package/dist/audio/krisp_instance.d.ts +95 -0
  34. package/dist/audio/krisp_instance.js +229 -0
  35. package/dist/audio/mixers/base_audio_mixer.d.ts +56 -0
  36. package/dist/audio/mixers/base_audio_mixer.js +16 -0
  37. package/dist/audio/mixers/index.d.ts +2 -0
  38. package/dist/audio/mixers/index.js +8 -0
  39. package/dist/audio/resamplers/base_audio_resampler.d.ts +46 -0
  40. package/dist/audio/resamplers/base_audio_resampler.js +35 -0
  41. package/dist/audio/resamplers/index.d.ts +2 -0
  42. package/dist/audio/resamplers/index.js +8 -0
  43. package/dist/audio/resamplers/resampy_resampler.d.ts +10 -0
  44. package/dist/audio/resamplers/resampy_resampler.js +15 -0
  45. package/dist/audio/resamplers/soxr_resampler.d.ts +54 -0
  46. package/dist/audio/resamplers/soxr_resampler.js +69 -0
  47. package/dist/audio/resamplers/soxr_stream_resampler.d.ts +75 -0
  48. package/dist/audio/resamplers/soxr_stream_resampler.js +146 -0
  49. package/dist/audio/turn/base_turn_analyzer.d.ts +84 -0
  50. package/dist/audio/turn/base_turn_analyzer.js +61 -0
  51. package/dist/audio/turn/index.d.ts +2 -0
  52. package/dist/audio/turn/index.js +8 -0
  53. package/dist/audio/turn/smart_turn/_whisper_features.d.ts +30 -0
  54. package/dist/audio/turn/smart_turn/_whisper_features.js +225 -0
  55. package/dist/audio/turn/smart_turn/base_smart_turn.d.ts +94 -0
  56. package/dist/audio/turn/smart_turn/base_smart_turn.js +239 -0
  57. package/dist/audio/turn/smart_turn/local_smart_turn_v3.d.ts +76 -0
  58. package/dist/audio/turn/smart_turn/local_smart_turn_v3.js +143 -0
  59. package/dist/audio/utils.d.ts +224 -0
  60. package/dist/audio/utils.js +634 -0
  61. package/dist/audio/vad/data/index.d.ts +2 -0
  62. package/dist/audio/vad/data/index.js +8 -0
  63. package/dist/audio/vad/index.d.ts +2 -0
  64. package/dist/audio/vad/index.js +8 -0
  65. package/dist/audio/vad/vad_analyzer.d.ts +126 -0
  66. package/dist/audio/vad/vad_analyzer.js +211 -0
  67. package/dist/audio/vad/vad_controller.d.ts +143 -0
  68. package/dist/audio/vad/vad_controller.js +228 -0
  69. package/dist/audio/volume.d.ts +38 -0
  70. package/dist/audio/volume.js +75 -0
  71. package/dist/bus/adapters/base.d.ts +35 -0
  72. package/dist/bus/adapters/base.js +19 -0
  73. package/dist/bus/adapters/index.d.ts +10 -0
  74. package/dist/bus/adapters/index.js +15 -0
  75. package/dist/bus/adapters/llm_context_adapter.d.ts +36 -0
  76. package/dist/bus/adapters/llm_context_adapter.js +82 -0
  77. package/dist/bus/adapters/tools_schema_adapter.d.ts +25 -0
  78. package/dist/bus/adapters/tools_schema_adapter.js +70 -0
  79. package/dist/bus/bridge_processor.d.ts +111 -0
  80. package/dist/bus/bridge_processor.js +166 -0
  81. package/dist/bus/bus.d.ts +110 -0
  82. package/dist/bus/bus.js +200 -0
  83. package/dist/bus/index.d.ts +22 -0
  84. package/dist/bus/index.js +27 -0
  85. package/dist/bus/local/async_queue.d.ts +12 -0
  86. package/dist/bus/local/async_queue.js +21 -0
  87. package/dist/bus/local/index.d.ts +3 -0
  88. package/dist/bus/local/index.js +8 -0
  89. package/dist/bus/messages.d.ts +378 -0
  90. package/dist/bus/messages.js +357 -0
  91. package/dist/bus/network/index.d.ts +16 -0
  92. package/dist/bus/network/index.js +21 -0
  93. package/dist/bus/queue.d.ts +27 -0
  94. package/dist/bus/queue.js +51 -0
  95. package/dist/bus/serializers/base.d.ts +25 -0
  96. package/dist/bus/serializers/base.js +14 -0
  97. package/dist/bus/serializers/index.d.ts +9 -0
  98. package/dist/bus/serializers/index.js +14 -0
  99. package/dist/bus/serializers/json.d.ts +77 -0
  100. package/dist/bus/serializers/json.js +367 -0
  101. package/dist/bus/subscriber.d.ts +46 -0
  102. package/dist/bus/subscriber.js +27 -0
  103. package/dist/bus/ui/index.d.ts +3 -0
  104. package/dist/bus/ui/index.js +8 -0
  105. package/dist/bus/ui/messages.d.ts +186 -0
  106. package/dist/bus/ui/messages.js +171 -0
  107. package/dist/classifiers/base_classifier.d.ts +263 -0
  108. package/dist/classifiers/base_classifier.js +346 -0
  109. package/dist/classifiers/cloudflare/clef/classifier.d.ts +70 -0
  110. package/dist/classifiers/cloudflare/clef/classifier.js +204 -0
  111. package/dist/classifiers/cloudflare/clef/client.d.ts +104 -0
  112. package/dist/classifiers/cloudflare/clef/client.js +234 -0
  113. package/dist/classifiers/cloudflare/clef/index.d.ts +2 -0
  114. package/dist/classifiers/cloudflare/clef/index.js +8 -0
  115. package/dist/classifiers/cloudflare/index.d.ts +2 -0
  116. package/dist/classifiers/cloudflare/index.js +8 -0
  117. package/dist/classifiers/http_client.d.ts +70 -0
  118. package/dist/classifiers/http_client.js +161 -0
  119. package/dist/classifiers/index.d.ts +2 -0
  120. package/dist/classifiers/index.js +8 -0
  121. package/dist/classifiers/jev/classifier.d.ts +8 -0
  122. package/dist/classifiers/jev/classifier.js +13 -0
  123. package/dist/classifiers/jev/client.d.ts +8 -0
  124. package/dist/classifiers/jev/client.js +13 -0
  125. package/dist/classifiers/jev/index.d.ts +2 -0
  126. package/dist/classifiers/jev/index.js +8 -0
  127. package/dist/classifiers/llm/classifier.d.ts +72 -0
  128. package/dist/classifiers/llm/classifier.js +304 -0
  129. package/dist/classifiers/llm/index.d.ts +2 -0
  130. package/dist/classifiers/llm/index.js +8 -0
  131. package/dist/classifiers/openai/decisions/classifier.d.ts +77 -0
  132. package/dist/classifiers/openai/decisions/classifier.js +241 -0
  133. package/dist/classifiers/openai/decisions/client.d.ts +108 -0
  134. package/dist/classifiers/openai/decisions/client.js +234 -0
  135. package/dist/classifiers/openai/decisions/index.d.ts +2 -0
  136. package/dist/classifiers/openai/decisions/index.js +8 -0
  137. package/dist/classifiers/openai/index.d.ts +2 -0
  138. package/dist/classifiers/openai/index.js +8 -0
  139. package/dist/classifiers/typesafe/index.d.ts +2 -0
  140. package/dist/classifiers/typesafe/index.js +8 -0
  141. package/dist/classifiers/typesafe/jev/classifier.d.ts +70 -0
  142. package/dist/classifiers/typesafe/jev/classifier.js +220 -0
  143. package/dist/classifiers/typesafe/jev/client.d.ts +105 -0
  144. package/dist/classifiers/typesafe/jev/client.js +233 -0
  145. package/dist/classifiers/typesafe/jev/index.d.ts +2 -0
  146. package/dist/classifiers/typesafe/jev/index.js +8 -0
  147. package/dist/clocks/base_clock.d.ts +13 -0
  148. package/dist/clocks/base_clock.js +14 -0
  149. package/dist/clocks/index.d.ts +2 -0
  150. package/dist/clocks/index.js +8 -0
  151. package/dist/clocks/system_clock.d.ts +15 -0
  152. package/dist/clocks/system_clock.js +25 -0
  153. package/dist/frames/frames.d.ts +2533 -0
  154. package/dist/frames/frames.js +2485 -0
  155. package/dist/frames/index.d.ts +2 -0
  156. package/dist/frames/index.js +8 -0
  157. package/dist/frames/protobufs/frames_pb2.d.ts +229 -0
  158. package/dist/frames/protobufs/frames_pb2.js +466 -0
  159. package/dist/index.d.ts +11 -0
  160. package/dist/index.js +56 -0
  161. package/dist/metrics/index.d.ts +2 -0
  162. package/dist/metrics/index.js +8 -0
  163. package/dist/metrics/metrics.d.ts +276 -0
  164. package/dist/metrics/metrics.js +254 -0
  165. package/dist/observers/base_observer.d.ts +173 -0
  166. package/dist/observers/base_observer.js +151 -0
  167. package/dist/observers/error_observer.d.ts +75 -0
  168. package/dist/observers/error_observer.js +87 -0
  169. package/dist/observers/function_call_observer.d.ts +157 -0
  170. package/dist/observers/function_call_observer.js +222 -0
  171. package/dist/observers/index.d.ts +2 -0
  172. package/dist/observers/index.js +8 -0
  173. package/dist/observers/loggers/debug_log_observer.d.ts +91 -0
  174. package/dist/observers/loggers/debug_log_observer.js +228 -0
  175. package/dist/observers/loggers/index.d.ts +2 -0
  176. package/dist/observers/loggers/index.js +8 -0
  177. package/dist/observers/loggers/llm_log_observer.d.ts +24 -0
  178. package/dist/observers/loggers/llm_log_observer.js +110 -0
  179. package/dist/observers/loggers/metrics_log_observer.d.ts +85 -0
  180. package/dist/observers/loggers/metrics_log_observer.js +186 -0
  181. package/dist/observers/loggers/transcription_log_observer.d.ts +23 -0
  182. package/dist/observers/loggers/transcription_log_observer.js +74 -0
  183. package/dist/observers/service_metrics_observer.d.ts +168 -0
  184. package/dist/observers/service_metrics_observer.js +236 -0
  185. package/dist/observers/speaking_observer.d.ts +104 -0
  186. package/dist/observers/speaking_observer.js +150 -0
  187. package/dist/observers/startup_timing_observer.d.ts +221 -0
  188. package/dist/observers/startup_timing_observer.js +365 -0
  189. package/dist/observers/turn_tracking_observer.d.ts +78 -0
  190. package/dist/observers/turn_tracking_observer.js +189 -0
  191. package/dist/observers/user_bot_latency_observer.d.ts +411 -0
  192. package/dist/observers/user_bot_latency_observer.js +974 -0
  193. package/dist/pipeline/base_pipeline.d.ts +49 -0
  194. package/dist/pipeline/base_pipeline.js +101 -0
  195. package/dist/pipeline/capabilities.d.ts +76 -0
  196. package/dist/pipeline/capabilities.js +97 -0
  197. package/dist/pipeline/index.d.ts +2 -0
  198. package/dist/pipeline/index.js +8 -0
  199. package/dist/pipeline/job_context.d.ts +317 -0
  200. package/dist/pipeline/job_context.js +450 -0
  201. package/dist/pipeline/job_decorator.d.ts +54 -0
  202. package/dist/pipeline/job_decorator.js +92 -0
  203. package/dist/pipeline/llm_switcher.d.ts +84 -0
  204. package/dist/pipeline/llm_switcher.js +107 -0
  205. package/dist/pipeline/llm_with_backend.d.ts +435 -0
  206. package/dist/pipeline/llm_with_backend.js +806 -0
  207. package/dist/pipeline/parallel_pipeline.d.ts +83 -0
  208. package/dist/pipeline/parallel_pipeline.js +200 -0
  209. package/dist/pipeline/pipeline.d.ts +126 -0
  210. package/dist/pipeline/pipeline.js +196 -0
  211. package/dist/pipeline/service_switcher.d.ts +287 -0
  212. package/dist/pipeline/service_switcher.js +509 -0
  213. package/dist/pipeline/sync_parallel_pipeline.d.ts +192 -0
  214. package/dist/pipeline/sync_parallel_pipeline.js +387 -0
  215. package/dist/pipeline/worker.d.ts +814 -0
  216. package/dist/pipeline/worker.js +1639 -0
  217. package/dist/pipeline/worker_observer.d.ts +131 -0
  218. package/dist/pipeline/worker_observer.js +274 -0
  219. package/dist/pipeline/worker_ready_decorator.d.ts +45 -0
  220. package/dist/pipeline/worker_ready_decorator.js +76 -0
  221. package/dist/processors/aggregators/async_tool_messages.d.ts +146 -0
  222. package/dist/processors/aggregators/async_tool_messages.js +291 -0
  223. package/dist/processors/aggregators/dtmf_aggregator.d.ts +61 -0
  224. package/dist/processors/aggregators/dtmf_aggregator.js +144 -0
  225. package/dist/processors/aggregators/gated.d.ts +43 -0
  226. package/dist/processors/aggregators/gated.js +86 -0
  227. package/dist/processors/aggregators/gated_llm_context.d.ts +42 -0
  228. package/dist/processors/aggregators/gated_llm_context.js +86 -0
  229. package/dist/processors/aggregators/index.d.ts +2 -0
  230. package/dist/processors/aggregators/index.js +8 -0
  231. package/dist/processors/aggregators/llm_context.d.ts +370 -0
  232. package/dist/processors/aggregators/llm_context.js +580 -0
  233. package/dist/processors/aggregators/llm_context_summarizer.d.ts +219 -0
  234. package/dist/processors/aggregators/llm_context_summarizer.js +447 -0
  235. package/dist/processors/aggregators/llm_response.d.ts +37 -0
  236. package/dist/processors/aggregators/llm_response.js +71 -0
  237. package/dist/processors/aggregators/llm_response_universal.d.ts +966 -0
  238. package/dist/processors/aggregators/llm_response_universal.js +2394 -0
  239. package/dist/processors/aggregators/llm_text_processor.d.ts +53 -0
  240. package/dist/processors/aggregators/llm_text_processor.js +102 -0
  241. package/dist/processors/aggregators/sentence.d.ts +39 -0
  242. package/dist/processors/aggregators/sentence.js +69 -0
  243. package/dist/processors/async_generator.d.ts +42 -0
  244. package/dist/processors/async_generator.js +76 -0
  245. package/dist/processors/audio/audio_buffer_processor.d.ts +241 -0
  246. package/dist/processors/audio/audio_buffer_processor.js +565 -0
  247. package/dist/processors/audio/index.d.ts +2 -0
  248. package/dist/processors/audio/index.js +8 -0
  249. package/dist/processors/audio/vad_processor.d.ts +67 -0
  250. package/dist/processors/audio/vad_processor.js +103 -0
  251. package/dist/processors/consumer_processor.d.ts +49 -0
  252. package/dist/processors/consumer_processor.js +85 -0
  253. package/dist/processors/filters/frame_filter.d.ts +39 -0
  254. package/dist/processors/filters/frame_filter.js +52 -0
  255. package/dist/processors/filters/function_filter.d.ts +59 -0
  256. package/dist/processors/filters/function_filter.js +78 -0
  257. package/dist/processors/filters/identity_filter.d.ts +33 -0
  258. package/dist/processors/filters/identity_filter.js +37 -0
  259. package/dist/processors/filters/index.d.ts +2 -0
  260. package/dist/processors/filters/index.js +8 -0
  261. package/dist/processors/filters/null_filter.d.ts +34 -0
  262. package/dist/processors/filters/null_filter.js +47 -0
  263. package/dist/processors/filters/wake_notifier_filter.d.ts +48 -0
  264. package/dist/processors/filters/wake_notifier_filter.js +49 -0
  265. package/dist/processors/frame_processor.d.ts +360 -0
  266. package/dist/processors/frame_processor.js +932 -0
  267. package/dist/processors/frameworks/index.d.ts +2 -0
  268. package/dist/processors/frameworks/index.js +8 -0
  269. package/dist/processors/frameworks/rtvi/frames.d.ts +241 -0
  270. package/dist/processors/frameworks/rtvi/frames.js +259 -0
  271. package/dist/processors/frameworks/rtvi/index.d.ts +6 -0
  272. package/dist/processors/frameworks/rtvi/index.js +11 -0
  273. package/dist/processors/frameworks/rtvi/models.d.ts +1741 -0
  274. package/dist/processors/frameworks/rtvi/models.js +1807 -0
  275. package/dist/processors/frameworks/rtvi/observer.d.ts +340 -0
  276. package/dist/processors/frameworks/rtvi/observer.js +1113 -0
  277. package/dist/processors/frameworks/rtvi/processor.d.ts +182 -0
  278. package/dist/processors/frameworks/rtvi/processor.js +676 -0
  279. package/dist/processors/idle_frame_processor.d.ts +44 -0
  280. package/dist/processors/idle_frame_processor.js +86 -0
  281. package/dist/processors/index.d.ts +2 -0
  282. package/dist/processors/index.js +8 -0
  283. package/dist/processors/logger.d.ts +42 -0
  284. package/dist/processors/logger.js +87 -0
  285. package/dist/processors/metrics/frame_processor_metrics.d.ts +172 -0
  286. package/dist/processors/metrics/frame_processor_metrics.js +372 -0
  287. package/dist/processors/metrics/index.d.ts +2 -0
  288. package/dist/processors/metrics/index.js +8 -0
  289. package/dist/processors/producer_processor.d.ts +68 -0
  290. package/dist/processors/producer_processor.js +78 -0
  291. package/dist/processors/text_transformer.d.ts +30 -0
  292. package/dist/processors/text_transformer.js +48 -0
  293. package/dist/registry/index.d.ts +3 -0
  294. package/dist/registry/index.js +8 -0
  295. package/dist/registry/registry.d.ts +69 -0
  296. package/dist/registry/registry.js +149 -0
  297. package/dist/registry/types.d.ts +47 -0
  298. package/dist/registry/types.js +39 -0
  299. package/dist/serializers/base_serializer.d.ts +94 -0
  300. package/dist/serializers/base_serializer.js +82 -0
  301. package/dist/serializers/index.d.ts +2 -0
  302. package/dist/serializers/index.js +8 -0
  303. package/dist/services/ai_service.d.ts +145 -0
  304. package/dist/services/ai_service.js +262 -0
  305. package/dist/services/anthropic/index.d.ts +2 -0
  306. package/dist/services/anthropic/index.js +7 -0
  307. package/dist/services/assemblyai/index.d.ts +2 -0
  308. package/dist/services/assemblyai/index.js +7 -0
  309. package/dist/services/asyncai/index.d.ts +2 -0
  310. package/dist/services/asyncai/index.js +7 -0
  311. package/dist/services/aws/index.d.ts +2 -0
  312. package/dist/services/aws/index.js +7 -0
  313. package/dist/services/azure/index.d.ts +2 -0
  314. package/dist/services/azure/index.js +7 -0
  315. package/dist/services/baseten/index.d.ts +2 -0
  316. package/dist/services/baseten/index.js +7 -0
  317. package/dist/services/bland/index.d.ts +2 -0
  318. package/dist/services/bland/index.js +7 -0
  319. package/dist/services/camb/index.d.ts +2 -0
  320. package/dist/services/camb/index.js +7 -0
  321. package/dist/services/cartesia/index.d.ts +2 -0
  322. package/dist/services/cartesia/index.js +7 -0
  323. package/dist/services/cerebras/index.d.ts +2 -0
  324. package/dist/services/cerebras/index.js +7 -0
  325. package/dist/services/crusoe/index.d.ts +2 -0
  326. package/dist/services/crusoe/index.js +7 -0
  327. package/dist/services/deepgram/index.d.ts +2 -0
  328. package/dist/services/deepgram/index.js +7 -0
  329. package/dist/services/deepseek/index.d.ts +2 -0
  330. package/dist/services/deepseek/index.js +7 -0
  331. package/dist/services/elevenlabs/index.d.ts +2 -0
  332. package/dist/services/elevenlabs/index.js +7 -0
  333. package/dist/services/fal/index.d.ts +2 -0
  334. package/dist/services/fal/index.js +7 -0
  335. package/dist/services/fireworks/index.d.ts +2 -0
  336. package/dist/services/fireworks/index.js +7 -0
  337. package/dist/services/fish/index.d.ts +2 -0
  338. package/dist/services/fish/index.js +7 -0
  339. package/dist/services/funasr/index.d.ts +3 -0
  340. package/dist/services/funasr/index.js +8 -0
  341. package/dist/services/gladia/index.d.ts +2 -0
  342. package/dist/services/gladia/index.js +7 -0
  343. package/dist/services/google/index.d.ts +2 -0
  344. package/dist/services/google/index.js +7 -0
  345. package/dist/services/gradium/index.d.ts +2 -0
  346. package/dist/services/gradium/index.js +7 -0
  347. package/dist/services/grok/index.d.ts +2 -0
  348. package/dist/services/grok/index.js +7 -0
  349. package/dist/services/groq/index.d.ts +2 -0
  350. package/dist/services/groq/index.js +7 -0
  351. package/dist/services/heygen/index.d.ts +2 -0
  352. package/dist/services/heygen/index.js +7 -0
  353. package/dist/services/hume/index.d.ts +2 -0
  354. package/dist/services/hume/index.js +7 -0
  355. package/dist/services/image_service.d.ts +52 -0
  356. package/dist/services/image_service.js +60 -0
  357. package/dist/services/inception/index.d.ts +2 -0
  358. package/dist/services/inception/index.js +7 -0
  359. package/dist/services/index.d.ts +2 -0
  360. package/dist/services/index.js +8 -0
  361. package/dist/services/inworld/index.d.ts +2 -0
  362. package/dist/services/inworld/index.js +7 -0
  363. package/dist/services/keenable/index.d.ts +2 -0
  364. package/dist/services/keenable/index.js +7 -0
  365. package/dist/services/kokoro/index.d.ts +2 -0
  366. package/dist/services/kokoro/index.js +7 -0
  367. package/dist/services/llm_service.d.ts +1106 -0
  368. package/dist/services/llm_service.js +2231 -0
  369. package/dist/services/mem0/index.d.ts +2 -0
  370. package/dist/services/mem0/index.js +7 -0
  371. package/dist/services/meta/index.d.ts +2 -0
  372. package/dist/services/meta/index.js +7 -0
  373. package/dist/services/minimax/index.d.ts +2 -0
  374. package/dist/services/minimax/index.js +7 -0
  375. package/dist/services/mistral/index.d.ts +2 -0
  376. package/dist/services/mistral/index.js +7 -0
  377. package/dist/services/moondream/index.d.ts +2 -0
  378. package/dist/services/moondream/index.js +7 -0
  379. package/dist/services/moonshine/index.d.ts +2 -0
  380. package/dist/services/moonshine/index.js +7 -0
  381. package/dist/services/nebius/index.d.ts +2 -0
  382. package/dist/services/nebius/index.js +7 -0
  383. package/dist/services/neuphonic/index.d.ts +2 -0
  384. package/dist/services/neuphonic/index.js +7 -0
  385. package/dist/services/novita/index.d.ts +2 -0
  386. package/dist/services/novita/index.js +7 -0
  387. package/dist/services/nvidia/index.d.ts +2 -0
  388. package/dist/services/nvidia/index.js +11 -0
  389. package/dist/services/ollama/index.d.ts +2 -0
  390. package/dist/services/ollama/index.js +7 -0
  391. package/dist/services/openai/index.d.ts +2 -0
  392. package/dist/services/openai/index.js +7 -0
  393. package/dist/services/openclaw/index.d.ts +14 -0
  394. package/dist/services/openclaw/index.js +19 -0
  395. package/dist/services/openrouter/index.d.ts +2 -0
  396. package/dist/services/openrouter/index.js +7 -0
  397. package/dist/services/perplexity/index.d.ts +2 -0
  398. package/dist/services/perplexity/index.js +7 -0
  399. package/dist/services/piper/index.d.ts +2 -0
  400. package/dist/services/piper/index.js +7 -0
  401. package/dist/services/pocket_tts/index.d.ts +2 -0
  402. package/dist/services/pocket_tts/index.js +7 -0
  403. package/dist/services/qwen/index.d.ts +2 -0
  404. package/dist/services/qwen/index.js +7 -0
  405. package/dist/services/resembleai/index.d.ts +2 -0
  406. package/dist/services/resembleai/index.js +7 -0
  407. package/dist/services/rime/index.d.ts +2 -0
  408. package/dist/services/rime/index.js +7 -0
  409. package/dist/services/sambanova/index.d.ts +2 -0
  410. package/dist/services/sambanova/index.js +7 -0
  411. package/dist/services/sarvam/index.d.ts +2 -0
  412. package/dist/services/sarvam/index.js +7 -0
  413. package/dist/services/settings.d.ts +356 -0
  414. package/dist/services/settings.js +437 -0
  415. package/dist/services/simli/index.d.ts +2 -0
  416. package/dist/services/simli/index.js +7 -0
  417. package/dist/services/smallest/index.d.ts +2 -0
  418. package/dist/services/smallest/index.js +7 -0
  419. package/dist/services/soniox/index.d.ts +2 -0
  420. package/dist/services/soniox/index.js +7 -0
  421. package/dist/services/speechify/index.d.ts +2 -0
  422. package/dist/services/speechify/index.js +7 -0
  423. package/dist/services/speechmatics/index.d.ts +2 -0
  424. package/dist/services/speechmatics/index.js +7 -0
  425. package/dist/services/stt_latency.d.ts +62 -0
  426. package/dist/services/stt_latency.js +71 -0
  427. package/dist/services/stt_service.d.ts +601 -0
  428. package/dist/services/stt_service.js +1044 -0
  429. package/dist/services/tavus/index.d.ts +2 -0
  430. package/dist/services/tavus/index.js +7 -0
  431. package/dist/services/together/index.d.ts +2 -0
  432. package/dist/services/together/index.js +7 -0
  433. package/dist/services/tts_service.d.ts +909 -0
  434. package/dist/services/tts_service.js +2018 -0
  435. package/dist/services/ultravox/index.d.ts +2 -0
  436. package/dist/services/ultravox/index.js +9 -0
  437. package/dist/services/vision_service.d.ts +56 -0
  438. package/dist/services/vision_service.js +62 -0
  439. package/dist/services/websocket_service.d.ts +213 -0
  440. package/dist/services/websocket_service.js +654 -0
  441. package/dist/services/whisper/index.d.ts +2 -0
  442. package/dist/services/whisper/index.js +9 -0
  443. package/dist/services/xai/index.d.ts +2 -0
  444. package/dist/services/xai/index.js +9 -0
  445. package/dist/services/xtts/index.d.ts +2 -0
  446. package/dist/services/xtts/index.js +9 -0
  447. package/dist/tests/index.d.ts +2 -0
  448. package/dist/tests/index.js +8 -0
  449. package/dist/tests/utils.d.ts +123 -0
  450. package/dist/tests/utils.js +212 -0
  451. package/dist/transcriptions/index.d.ts +2 -0
  452. package/dist/transcriptions/index.js +8 -0
  453. package/dist/transcriptions/language.d.ts +376 -0
  454. package/dist/transcriptions/language.js +543 -0
  455. package/dist/transports/base_input.d.ts +149 -0
  456. package/dist/transports/base_input.js +338 -0
  457. package/dist/transports/base_output.d.ts +432 -0
  458. package/dist/transports/base_output.js +1231 -0
  459. package/dist/transports/base_transport.d.ts +223 -0
  460. package/dist/transports/base_transport.js +167 -0
  461. package/dist/transports/daily/index.d.ts +2 -0
  462. package/dist/transports/daily/index.js +9 -0
  463. package/dist/transports/heygen/index.d.ts +2 -0
  464. package/dist/transports/heygen/index.js +9 -0
  465. package/dist/transports/index.d.ts +2 -0
  466. package/dist/transports/index.js +8 -0
  467. package/dist/transports/lemonslice/index.d.ts +2 -0
  468. package/dist/transports/lemonslice/index.js +9 -0
  469. package/dist/transports/livekit/index.d.ts +2 -0
  470. package/dist/transports/livekit/index.js +9 -0
  471. package/dist/transports/local/index.d.ts +2 -0
  472. package/dist/transports/local/index.js +9 -0
  473. package/dist/transports/moq/index.d.ts +2 -0
  474. package/dist/transports/moq/index.js +9 -0
  475. package/dist/transports/smallwebrtc/index.d.ts +2 -0
  476. package/dist/transports/smallwebrtc/index.js +9 -0
  477. package/dist/transports/tavus/index.d.ts +2 -0
  478. package/dist/transports/tavus/index.js +9 -0
  479. package/dist/transports/video_in_sampler.d.ts +157 -0
  480. package/dist/transports/video_in_sampler.js +258 -0
  481. package/dist/transports/vonage/index.d.ts +2 -0
  482. package/dist/transports/vonage/index.js +9 -0
  483. package/dist/transports/websocket/index.d.ts +2 -0
  484. package/dist/transports/websocket/index.js +9 -0
  485. package/dist/transports/whatsapp/index.d.ts +2 -0
  486. package/dist/transports/whatsapp/index.js +9 -0
  487. package/dist/turns/eager_end_of_turn_mixin.d.ts +70 -0
  488. package/dist/turns/eager_end_of_turn_mixin.js +122 -0
  489. package/dist/turns/empty_user_turn.d.ts +55 -0
  490. package/dist/turns/empty_user_turn.js +53 -0
  491. package/dist/turns/index.d.ts +2 -0
  492. package/dist/turns/index.js +8 -0
  493. package/dist/turns/speculation_gate.d.ts +169 -0
  494. package/dist/turns/speculation_gate.js +294 -0
  495. package/dist/turns/types.d.ts +33 -0
  496. package/dist/turns/types.js +35 -0
  497. package/dist/turns/user_idle_controller.d.ts +94 -0
  498. package/dist/turns/user_idle_controller.js +187 -0
  499. package/dist/turns/user_mute/always_user_mute_strategy.d.ts +15 -0
  500. package/dist/turns/user_mute/always_user_mute_strategy.js +29 -0
  501. package/dist/turns/user_mute/base_user_mute_strategy.d.ts +39 -0
  502. package/dist/turns/user_mute/base_user_mute_strategy.js +45 -0
  503. package/dist/turns/user_mute/first_speech_user_mute_strategy.d.ts +28 -0
  504. package/dist/turns/user_mute/first_speech_user_mute_strategy.js +52 -0
  505. package/dist/turns/user_mute/function_call_user_mute_strategy.d.ts +25 -0
  506. package/dist/turns/user_mute/function_call_user_mute_strategy.js +50 -0
  507. package/dist/turns/user_mute/index.d.ts +6 -0
  508. package/dist/turns/user_mute/index.js +11 -0
  509. package/dist/turns/user_mute/mute_until_first_bot_complete_user_mute_strategy.d.ts +43 -0
  510. package/dist/turns/user_mute/mute_until_first_bot_complete_user_mute_strategy.js +76 -0
  511. package/dist/turns/user_start/base_user_turn_start_strategy.d.ts +135 -0
  512. package/dist/turns/user_start/base_user_turn_start_strategy.js +134 -0
  513. package/dist/turns/user_start/external_user_turn_start_strategy.d.ts +45 -0
  514. package/dist/turns/user_start/external_user_turn_start_strategy.js +64 -0
  515. package/dist/turns/user_start/index.d.ts +8 -0
  516. package/dist/turns/user_start/index.js +16 -0
  517. package/dist/turns/user_start/krisp_viva_ip_user_turn_start_strategy.d.ts +133 -0
  518. package/dist/turns/user_start/krisp_viva_ip_user_turn_start_strategy.js +243 -0
  519. package/dist/turns/user_start/min_words_user_turn_start_strategy.d.ts +60 -0
  520. package/dist/turns/user_start/min_words_user_turn_start_strategy.js +102 -0
  521. package/dist/turns/user_start/transcription_user_turn_start_strategy.d.ts +29 -0
  522. package/dist/turns/user_start/transcription_user_turn_start_strategy.js +43 -0
  523. package/dist/turns/user_start/vad_user_turn_start_strategy.d.ts +20 -0
  524. package/dist/turns/user_start/vad_user_turn_start_strategy.js +31 -0
  525. package/dist/turns/user_start/wake_phrase_user_turn_start_strategy.d.ts +141 -0
  526. package/dist/turns/user_start/wake_phrase_user_turn_start_strategy.js +238 -0
  527. package/dist/turns/user_stop/base_user_turn_stop_strategy.d.ts +174 -0
  528. package/dist/turns/user_stop/base_user_turn_stop_strategy.js +170 -0
  529. package/dist/turns/user_stop/deferred_user_turn_stop_strategy.d.ts +81 -0
  530. package/dist/turns/user_stop/deferred_user_turn_stop_strategy.js +107 -0
  531. package/dist/turns/user_stop/eager_match_policy.d.ts +36 -0
  532. package/dist/turns/user_stop/eager_match_policy.js +50 -0
  533. package/dist/turns/user_stop/eager_user_turn_stop_strategy.d.ts +84 -0
  534. package/dist/turns/user_stop/eager_user_turn_stop_strategy.js +154 -0
  535. package/dist/turns/user_stop/external_user_turn_completion_stop_strategy.d.ts +45 -0
  536. package/dist/turns/user_stop/external_user_turn_completion_stop_strategy.js +55 -0
  537. package/dist/turns/user_stop/external_user_turn_stop_strategy.d.ts +115 -0
  538. package/dist/turns/user_stop/external_user_turn_stop_strategy.js +205 -0
  539. package/dist/turns/user_stop/index.d.ts +10 -0
  540. package/dist/turns/user_stop/index.js +15 -0
  541. package/dist/turns/user_stop/llm_turn_completion_user_turn_stop_strategy.d.ts +44 -0
  542. package/dist/turns/user_stop/llm_turn_completion_user_turn_stop_strategy.js +59 -0
  543. package/dist/turns/user_stop/speech_timeout_user_turn_stop_strategy.d.ts +140 -0
  544. package/dist/turns/user_stop/speech_timeout_user_turn_stop_strategy.js +303 -0
  545. package/dist/turns/user_stop/turn_analyzer_user_turn_stop_strategy.d.ts +135 -0
  546. package/dist/turns/user_stop/turn_analyzer_user_turn_stop_strategy.js +332 -0
  547. package/dist/turns/user_turn_completion_mixin.d.ts +147 -0
  548. package/dist/turns/user_turn_completion_mixin.js +591 -0
  549. package/dist/turns/user_turn_controller.d.ts +134 -0
  550. package/dist/turns/user_turn_controller.js +335 -0
  551. package/dist/turns/user_turn_processor.d.ts +87 -0
  552. package/dist/turns/user_turn_processor.js +180 -0
  553. package/dist/turns/user_turn_strategies.d.ts +187 -0
  554. package/dist/turns/user_turn_strategies.js +222 -0
  555. package/dist/utils/async_tool_cancellation.d.ts +35 -0
  556. package/dist/utils/async_tool_cancellation.js +78 -0
  557. package/dist/utils/asyncio/index.d.ts +2 -0
  558. package/dist/utils/asyncio/index.js +7 -0
  559. package/dist/utils/asyncio/task_manager.d.ts +49 -0
  560. package/dist/utils/asyncio/task_manager.js +105 -0
  561. package/dist/utils/base_object.d.ts +76 -0
  562. package/dist/utils/base_object.js +154 -0
  563. package/dist/utils/context/aggregated_frame_sequencer.d.ts +491 -0
  564. package/dist/utils/context/aggregated_frame_sequencer.js +803 -0
  565. package/dist/utils/context/audio_context_manager.d.ts +131 -0
  566. package/dist/utils/context/audio_context_manager.js +233 -0
  567. package/dist/utils/context/index.d.ts +2 -0
  568. package/dist/utils/context/index.js +7 -0
  569. package/dist/utils/context/llm_context_summarization.d.ts +258 -0
  570. package/dist/utils/context/llm_context_summarization.js +511 -0
  571. package/dist/utils/context/text_segment_map.d.ts +611 -0
  572. package/dist/utils/context/text_segment_map.js +1132 -0
  573. package/dist/utils/context/word_completion_tracker.d.ts +273 -0
  574. package/dist/utils/context/word_completion_tracker.js +441 -0
  575. package/dist/utils/context/word_timestamp_tracker.d.ts +72 -0
  576. package/dist/utils/context/word_timestamp_tracker.js +98 -0
  577. package/dist/utils/deprecation.d.ts +28 -0
  578. package/dist/utils/deprecation.js +75 -0
  579. package/dist/utils/env.d.ts +38 -0
  580. package/dist/utils/env.js +62 -0
  581. package/dist/utils/errors.d.ts +75 -0
  582. package/dist/utils/errors.js +202 -0
  583. package/dist/utils/file_resolver.d.ts +126 -0
  584. package/dist/utils/file_resolver.js +314 -0
  585. package/dist/utils/file_storage.d.ts +99 -0
  586. package/dist/utils/file_storage.js +100 -0
  587. package/dist/utils/frame_queue.d.ts +36 -0
  588. package/dist/utils/frame_queue.js +66 -0
  589. package/dist/utils/http.d.ts +39 -0
  590. package/dist/utils/http.js +53 -0
  591. package/dist/utils/image.d.ts +15 -0
  592. package/dist/utils/image.js +30 -0
  593. package/dist/utils/index.d.ts +2 -0
  594. package/dist/utils/index.js +8 -0
  595. package/dist/utils/log_config.d.ts +34 -0
  596. package/dist/utils/log_config.js +76 -0
  597. package/dist/utils/logger.d.ts +40 -0
  598. package/dist/utils/logger.js +91 -0
  599. package/dist/utils/mixin.d.ts +14 -0
  600. package/dist/utils/mixin.js +63 -0
  601. package/dist/utils/network.d.ts +73 -0
  602. package/dist/utils/network.js +90 -0
  603. package/dist/utils/security/allowed_origins.d.ts +16 -0
  604. package/dist/utils/security/allowed_origins.js +34 -0
  605. package/dist/utils/security/index.d.ts +2 -0
  606. package/dist/utils/security/index.js +7 -0
  607. package/dist/utils/security/redaction.d.ts +27 -0
  608. package/dist/utils/security/redaction.js +123 -0
  609. package/dist/utils/security/ssrf.d.ts +79 -0
  610. package/dist/utils/security/ssrf.js +327 -0
  611. package/dist/utils/shared.d.ts +35 -0
  612. package/dist/utils/shared.js +136 -0
  613. package/dist/utils/startup.d.ts +17 -0
  614. package/dist/utils/startup.js +130 -0
  615. package/dist/utils/string.d.ts +116 -0
  616. package/dist/utils/string.js +460 -0
  617. package/dist/utils/sync/base_notifier.d.ts +25 -0
  618. package/dist/utils/sync/base_notifier.js +16 -0
  619. package/dist/utils/sync/event_notifier.d.ts +38 -0
  620. package/dist/utils/sync/event_notifier.js +51 -0
  621. package/dist/utils/sync/index.d.ts +2 -0
  622. package/dist/utils/sync/index.js +7 -0
  623. package/dist/utils/text/alnum_utils.d.ts +109 -0
  624. package/dist/utils/text/alnum_utils.js +262 -0
  625. package/dist/utils/text/base_text_aggregator.d.ts +146 -0
  626. package/dist/utils/text/base_text_aggregator.js +102 -0
  627. package/dist/utils/text/base_text_filter.d.ts +54 -0
  628. package/dist/utils/text/base_text_filter.js +50 -0
  629. package/dist/utils/text/index.d.ts +2 -0
  630. package/dist/utils/text/index.js +7 -0
  631. package/dist/utils/text/markdown_text_filter.d.ts +147 -0
  632. package/dist/utils/text/markdown_text_filter.js +522 -0
  633. package/dist/utils/text/markup_utils.d.ts +54 -0
  634. package/dist/utils/text/markup_utils.js +156 -0
  635. package/dist/utils/text/pattern_pair_aggregator.d.ts +251 -0
  636. package/dist/utils/text/pattern_pair_aggregator.js +478 -0
  637. package/dist/utils/text/phonemes.d.ts +60 -0
  638. package/dist/utils/text/phonemes.js +172 -0
  639. package/dist/utils/text/simple_text_aggregator.d.ts +135 -0
  640. package/dist/utils/text/simple_text_aggregator.js +254 -0
  641. package/dist/utils/text/skip_tags_aggregator.d.ts +85 -0
  642. package/dist/utils/text/skip_tags_aggregator.js +147 -0
  643. package/dist/utils/text/transforms/pronunciations.d.ts +65 -0
  644. package/dist/utils/text/transforms/pronunciations.js +111 -0
  645. package/dist/utils/text/word_timestamp_utils.d.ts +26 -0
  646. package/dist/utils/text/word_timestamp_utils.js +52 -0
  647. package/dist/utils/time.d.ts +13 -0
  648. package/dist/utils/time.js +31 -0
  649. package/dist/utils/tracing/index.d.ts +3 -0
  650. package/dist/utils/tracing/index.js +8 -0
  651. package/dist/utils/tracing/service_attributes.d.ts +198 -0
  652. package/dist/utils/tracing/service_attributes.js +434 -0
  653. package/dist/utils/tracing/service_decorators.d.ts +214 -0
  654. package/dist/utils/tracing/service_decorators.js +1662 -0
  655. package/dist/utils/tracing/setup.d.ts +95 -0
  656. package/dist/utils/tracing/setup.js +110 -0
  657. package/dist/utils/tracing/tracing_context.d.ts +55 -0
  658. package/dist/utils/tracing/tracing_context.js +97 -0
  659. package/dist/utils/tracing/turn_trace_observer.d.ts +90 -0
  660. package/dist/utils/tracing/turn_trace_observer.js +219 -0
  661. package/dist/utils/types.d.ts +80 -0
  662. package/dist/utils/types.js +108 -0
  663. package/dist/utils/utils.d.ts +5 -0
  664. package/dist/utils/utils.js +22 -0
  665. package/dist/utils/yaml.d.ts +64 -0
  666. package/dist/utils/yaml.js +41 -0
  667. package/dist/version.d.ts +3 -0
  668. package/dist/version.js +7 -0
  669. package/dist/workers/base_worker.d.ts +772 -0
  670. package/dist/workers/base_worker.js +1298 -0
  671. package/dist/workers/index.d.ts +2 -0
  672. package/dist/workers/index.js +8 -0
  673. package/dist/workers/llm/backend_llm_worker.d.ts +552 -0
  674. package/dist/workers/llm/backend_llm_worker.js +1055 -0
  675. package/dist/workers/llm/index.d.ts +6 -0
  676. package/dist/workers/llm/index.js +11 -0
  677. package/dist/workers/llm/llm_context_worker.d.ts +66 -0
  678. package/dist/workers/llm/llm_context_worker.js +72 -0
  679. package/dist/workers/llm/llm_worker.d.ts +180 -0
  680. package/dist/workers/llm/llm_worker.js +323 -0
  681. package/dist/workers/llm/tool_decorator.d.ts +68 -0
  682. package/dist/workers/llm/tool_decorator.js +60 -0
  683. package/dist/workers/runner.d.ts +268 -0
  684. package/dist/workers/runner.js +489 -0
  685. package/dist/workers/ui/index.d.ts +22 -0
  686. package/dist/workers/ui/index.js +27 -0
  687. package/dist/workers/ui/ui_event_decorator.d.ts +43 -0
  688. package/dist/workers/ui/ui_event_decorator.js +75 -0
  689. package/dist/workers/ui/ui_job_context.d.ts +12 -0
  690. package/dist/workers/ui/ui_job_context.js +17 -0
  691. package/dist/workers/ui/ui_prompts.d.ts +21 -0
  692. package/dist/workers/ui/ui_prompts.js +41 -0
  693. package/dist/workers/ui/ui_tools.d.ts +32 -0
  694. package/dist/workers/ui/ui_tools.js +112 -0
  695. package/dist/workers/ui/ui_worker.d.ts +571 -0
  696. package/dist/workers/ui/ui_worker.js +1156 -0
  697. package/package.json +46 -3
  698. package/README.md +0 -5
@@ -0,0 +1,1106 @@
1
+ /**
2
+ * Base classes for Large Language Model services with function calling support.
3
+ *
4
+ * Porting notes:
5
+ * - Cancelling a function call cancels the task running its handler. In
6
+ * JavaScript cancellation is delivered at cancellation points (see
7
+ * `@pipedog/asyncio`), so a handler awaiting foreign work (`fetch`, an
8
+ * SDK) should pass `currentSignal()` to it, or wrap the await in
9
+ * `abortable()`, to stop as promptly as the Python handler would.
10
+ * - Deprecated upstream APIs are not ported: `FunctionCallParams.tool_resources`,
11
+ * `register_direct_function()`, `unregister_direct_function()`, the
12
+ * `enable_async_tool_cancellation` option, the warnings for application-set
13
+ * turn-completion settings, and the legacy `LLMUpdateSettingsFrame(settings={...})`
14
+ * dict path.
15
+ */
16
+ import { Queue, type Task } from "@pipedog/asyncio";
17
+ import type { BaseLLMAdapter } from "../adapters/base_llm_adapter.ts";
18
+ import { DirectFunctionWrapper } from "../adapters/schemas/direct_function.ts";
19
+ import { ToolsSchema } from "../adapters/schemas/tools_schema.ts";
20
+ import { type CancelFrame, EagerEndOfTurnCancelFrame, type EndFrame, type ErrorFrame, type Frame, FunctionCallFromLLM, FunctionCallResultProperties, InterruptionFrame, LLMContextSummaryRequestFrame, LLMServiceMetadataFrame, type StartFrame } from "../frames/frames.ts";
21
+ import type { PipelineWorker } from "../pipeline/worker.ts";
22
+ import { LLMContext, type LLMSpecificMessage } from "../processors/aggregators/llm_context.ts";
23
+ import { FrameDirection, type FrameProcessorSetup } from "../processors/frame_processor.ts";
24
+ import { SpeculationGate } from "../turns/speculation_gate.ts";
25
+ import { UserTurnCompletionLLMServiceMixin } from "../turns/user_turn_completion_mixin.ts";
26
+ import { FileResolver } from "../utils/file_resolver.ts";
27
+ import type { WorkerRunner } from "../workers/runner.ts";
28
+ import { AIService, type AIServiceOptions } from "./ai_service.ts";
29
+ import { LLMSettings } from "./settings.ts";
30
+ import { WebsocketService, type WebsocketServiceOptions } from "./websocket_service.ts";
31
+ /**
32
+ * Raised by a method a service doesn't implement (Python's
33
+ * `NotImplementedError`), e.g. `LLMService.runInference()`.
34
+ */
35
+ export declare class NotImplementedError extends Error {
36
+ name: string;
37
+ }
38
+ /** Type alias for a callable that handles LLM function calls. */
39
+ export type FunctionCallHandler = (params: FunctionCallParams) => Promise<void>;
40
+ /**
41
+ * The two roles a service can fill in an `LLMWithBackend`: the conversational
42
+ * frontend, or the LLM inside the backend worker.
43
+ */
44
+ export type LLMWithBackendRole = "frontend" | "backend";
45
+ /**
46
+ * Function call result callback.
47
+ *
48
+ * Used for both final results and intermediate updates. Pass
49
+ * `properties: new FunctionCallResultProperties({ isFinal: false })` to send an
50
+ * intermediate update (only valid for async function calls registered with
51
+ * `cancelOnInterruption: false`).
52
+ *
53
+ * - `result`: the result of the function call, or an intermediate update.
54
+ * - `options.properties`: optional properties. Set `isFinal: false` to send an
55
+ * intermediate update instead of the final result.
56
+ */
57
+ export type FunctionCallResultCallback = (result: unknown, options?: {
58
+ properties?: FunctionCallResultProperties | null;
59
+ }) => Promise<void>;
60
+ export interface FunctionCallParamsOptions {
61
+ functionName: string;
62
+ toolCallId: string;
63
+ arguments: Record<string, unknown>;
64
+ llm: LLMService<any>;
65
+ pipelineWorker: PipelineWorker;
66
+ context: LLMContext;
67
+ resultCallback: FunctionCallResultCallback;
68
+ appResources?: unknown;
69
+ workerRunner?: WorkerRunner | null;
70
+ }
71
+ /**
72
+ * Parameters for a function call.
73
+ *
74
+ * - `functionName`: the name of the function being called.
75
+ * - `toolCallId`: a unique identifier for the function call.
76
+ * - `arguments`: the arguments for the function.
77
+ * - `llm`: the LLMService instance being used.
78
+ * - `pipelineWorker`: the worker running the pipeline this call was made from.
79
+ * Carries worker-scoped state, most notably `pipelineWorker.appResources`.
80
+ * - `context`: the LLM context.
81
+ * - `resultCallback`: callback to deliver the result of the function call.
82
+ * For async function calls (`cancelOnInterruption: false`), call it with
83
+ * `properties: new FunctionCallResultProperties({ isFinal: false })` to push
84
+ * intermediate updates before the final result.
85
+ * - `appResources`: the application-defined resources passed to
86
+ * `new PipelineWorker(..., { appResources })`. Same object — passed by
87
+ * reference, not a copy. Use it to share DB handles, clients, state, feature
88
+ * flags, etc. across all of a session's tool handlers.
89
+ * - `workerRunner`: the runner hosting `pipelineWorker`. Use it to reach
90
+ * another worker on the runner by name, e.g.
91
+ * `params.workerRunner.getWorker("ui-jobs")`. Always set for a call made
92
+ * from a running pipeline; null only when these params were built by hand.
93
+ *
94
+ * A handler runs in its own task and is cancelled on interruption, timeout or
95
+ * an LLM cancel request. Pass `currentSignal()` to `fetch` and other foreign
96
+ * awaits so they stop too.
97
+ */
98
+ export declare class FunctionCallParams {
99
+ functionName: string;
100
+ toolCallId: string;
101
+ arguments: Record<string, unknown>;
102
+ llm: LLMService<any>;
103
+ pipelineWorker: PipelineWorker;
104
+ context: LLMContext;
105
+ resultCallback: FunctionCallResultCallback;
106
+ appResources: unknown;
107
+ workerRunner: WorkerRunner | null;
108
+ constructor(options: FunctionCallParamsOptions);
109
+ }
110
+ export interface FunctionCallRegistryItemOptions {
111
+ functionName: string | null;
112
+ handler: FunctionCallHandler | DirectFunctionWrapper;
113
+ cancelOnInterruption: boolean;
114
+ timeoutSecs?: number | null;
115
+ cancellableByLlm?: boolean;
116
+ autoRegistered?: boolean;
117
+ }
118
+ /**
119
+ * Internal record of a registered function-call handler.
120
+ *
121
+ * Created by the service when a function is registered — directly via
122
+ * `registerFunction`, or automatically from a direct function advertised in
123
+ * an `LLMContext` / `LLMSetToolsFrame`. Application code doesn't construct
124
+ * these.
125
+ *
126
+ * - `functionName`: the name of the function (null for catch-all handler).
127
+ * - `handler`: the handler for processing function call parameters.
128
+ * - `cancelOnInterruption`: whether to cancel the call on interruption. When
129
+ * false the call is treated as asynchronous: the LLM continues the
130
+ * conversation immediately without waiting for the result, and the result
131
+ * is injected later via a developer message.
132
+ * - `timeoutSecs`: optional per-tool timeout in seconds. Overrides the global
133
+ * `functionCallTimeoutSecs` for this specific function. A call that runs
134
+ * past it is cancelled.
135
+ * - `cancellableByLlm`: whether the LLM may cancel this call while it runs.
136
+ * Only meaningful on an async call (`cancelOnInterruption: false`), since a
137
+ * synchronous one holds the LLM until it returns.
138
+ * - `autoRegistered`: true only for a direct function that was auto-registered
139
+ * from an advertised tool set (listed in an `LLMContext` or
140
+ * `LLMSetToolsFrame`). False for every explicitly registered handler —
141
+ * direct or non-direct — and for the catch-all and built-in handlers.
142
+ */
143
+ export declare class FunctionCallRegistryItem {
144
+ functionName: string | null;
145
+ handler: FunctionCallHandler | DirectFunctionWrapper;
146
+ cancelOnInterruption: boolean;
147
+ timeoutSecs: number | null;
148
+ cancellableByLlm: boolean;
149
+ autoRegistered: boolean;
150
+ constructor(options: FunctionCallRegistryItemOptions);
151
+ }
152
+ export interface FunctionCallRunnerItemOptions {
153
+ registryItem: FunctionCallRegistryItem;
154
+ functionName: string;
155
+ toolCallId: string;
156
+ arguments: Record<string, unknown>;
157
+ context: LLMContext;
158
+ runLlm?: boolean | null;
159
+ groupId?: string | null;
160
+ settled?: boolean;
161
+ }
162
+ /**
163
+ * Internal function call entry for the function call runner.
164
+ *
165
+ * The runner executes function calls in order.
166
+ *
167
+ * - `registryItem`: the registry item containing handler information.
168
+ * - `functionName`: the name of the function.
169
+ * - `toolCallId`: a unique identifier for the function call.
170
+ * - `arguments`: the arguments for the function.
171
+ * - `context`: the LLM context.
172
+ * - `runLlm`: optional flag to control LLM execution after function call.
173
+ * - `groupId`: shared identifier for all function calls from the same LLM
174
+ * response batch. Used to trigger the LLM exactly once when the last call in
175
+ * the group completes.
176
+ * - `settled`: whether the call has already reached a terminal state — a final
177
+ * result, a timeout, or a cancellation. Results reported after that are
178
+ * rejected, since the rest of the pipeline has stopped tracking the call.
179
+ */
180
+ export declare class FunctionCallRunnerItem {
181
+ registryItem: FunctionCallRegistryItem;
182
+ functionName: string;
183
+ toolCallId: string;
184
+ arguments: Record<string, unknown>;
185
+ context: LLMContext;
186
+ runLlm: boolean | null;
187
+ groupId: string | null;
188
+ settled: boolean;
189
+ constructor(options: FunctionCallRunnerItemOptions);
190
+ }
191
+ export interface LLMServiceOptions extends AIServiceOptions {
192
+ /** Whether to run function calls in parallel or sequentially. Defaults to true. */
193
+ runInParallel?: boolean;
194
+ /**
195
+ * Whether to group parallel function calls so the LLM is triggered exactly
196
+ * once after all calls in the batch complete. When false, each function
197
+ * call result triggers the LLM independently as it arrives. Defaults to true.
198
+ */
199
+ groupParallelTools?: boolean;
200
+ /**
201
+ * Optional timeout in seconds for function calls. A call that runs past it
202
+ * is cancelled: its handler is cancelled (it gets a `CancelledError`), the
203
+ * call is settled as cancelled, and inference runs so the LLM can report
204
+ * that it didn't complete.
205
+ */
206
+ functionCallTimeoutSecs?: number | null;
207
+ /** The runtime-updatable settings for the LLM service. */
208
+ settings?: LLMSettings | null;
209
+ /**
210
+ * Resolves file URLs in the context that this provider can't fetch itself
211
+ * (see `FileResolver`). Pass one configured with a `fileStorage` to resolve
212
+ * uploaded-file URLs (`new FileResolver({ fileStorage: runnerArgs.fileStorage })`
213
+ * when a runner hosts the bot), and share one instance across services that
214
+ * may consume the same files (e.g. services switched between mid-session)
215
+ * so downloads are reused. Defaults to a resolver that handles `data:` and
216
+ * `http(s)` URLs only.
217
+ */
218
+ fileResolver?: FileResolver | null;
219
+ }
220
+ /** An adapter class `LLMService.adapterClass` can name. */
221
+ export type LLMAdapterClass = new () => BaseLLMAdapter<object>;
222
+ declare const LLMService_base: typeof AIService & import("../utils/mixin.ts").Ctor<UserTurnCompletionLLMServiceMixin>;
223
+ /**
224
+ * Base class for all LLM services.
225
+ *
226
+ * Handles function calling registration and execution with support for both
227
+ * parallel and sequential execution modes. Provides event handlers for
228
+ * completion timeouts and function call lifecycle events.
229
+ *
230
+ * The service supports the following event handlers:
231
+ *
232
+ * - on_completion_timeout: called when an LLM completion timeout occurs
233
+ * - on_function_calls_started: called when function calls are received and
234
+ * execution is about to start. Built-in tools (e.g. a `cancel_<name>` tool)
235
+ * are excluded from this event.
236
+ * - on_function_calls_cancelled: called after one or more async tool calls are
237
+ * cancelled.
238
+ *
239
+ * @example
240
+ * llm.eventHandler("on_completion_timeout", async (service) => {
241
+ * logger.warning("LLM completion timed out");
242
+ * });
243
+ * llm.eventHandler("on_function_calls_started", async (service, functionCalls: FunctionCallFromLLM[]) => {
244
+ * logger.info(`Starting ${functionCalls.length} function calls`);
245
+ * });
246
+ * llm.eventHandler("on_function_calls_cancelled", async (service, functionCalls: FunctionCallFromLLM[]) => {
247
+ * logger.info(`Cancelled ${functionCalls.length} function calls`);
248
+ * });
249
+ *
250
+ * @throws InvalidEnvVarValueError (from the constructor) if
251
+ * `PIPECAT_LOG_LLM_CONTEXT` is set to an unknown mode.
252
+ */
253
+ export declare class LLMService<TAdapter extends BaseLLMAdapter = BaseLLMAdapter> extends LLMService_base {
254
+ #private;
255
+ protected _settings: LLMSettings;
256
+ protected _adapter: TAdapter;
257
+ /**
258
+ * Subclasses should set this to a more specific adapter when necessary.
259
+ * `null` selects OpenAILLMAdapter, which aligns with most LLM
260
+ * implementations.
261
+ */
262
+ static adapterClass: LLMAdapterClass | null;
263
+ /**
264
+ * Returned to the LLM as the tool result when an unavailable function is
265
+ * called. Deliberately neutral about future availability so the LLM can
266
+ * pick the function up again if it returns (e.g. via the
267
+ * `addToolChangeMessages` activation message, or silently on a later
268
+ * inference). `{function_name}` is substituted at runtime.
269
+ */
270
+ static MISSING_FUNCTION_CALL_MESSAGE_TEMPLATE: string;
271
+ /**
272
+ * Returned to the LLM as the tool result when a handler raises. It names
273
+ * the function as the thing that failed. The exception itself is
274
+ * deliberately left out.
275
+ */
276
+ static FUNCTION_CALL_ERROR_MESSAGE_TEMPLATE: string;
277
+ /**
278
+ * Whether the provider can enforce a response schema in `runInference()`.
279
+ *
280
+ * Services whose provider can set this to true. When only some of its
281
+ * models can, they also override `modelSupportsResponseSchema()`.
282
+ */
283
+ static supportsResponseSchema: boolean;
284
+ protected _runInParallel: boolean;
285
+ protected _groupParallelTools: boolean;
286
+ protected _functionCallTimeoutSecs: number | null;
287
+ protected _fileResolver: FileResolver;
288
+ protected _reportsTtfat: boolean | null;
289
+ protected _filterIncompleteUserTurns: boolean;
290
+ protected _loggedThinkingDefaultModel: string | null;
291
+ protected _speculationGate: SpeculationGate;
292
+ protected _cancelToolNames: Set<string>;
293
+ protected _warnedCancelCollisions: Set<string>;
294
+ protected _baseSystemInstruction: string | null;
295
+ protected _appendedSystemInstructions: string[];
296
+ protected _composedSystemInstruction: string | null;
297
+ protected _functions: Map<string | null, FunctionCallRegistryItem>;
298
+ protected _toolCleanups: (() => Promise<void>)[];
299
+ protected _redundantRegistrationWarned: Set<string>;
300
+ protected _explicitlyUnregisteredFunctionNames: Set<string | null>;
301
+ protected _functionCallTasks: Map<Task<unknown> | null, FunctionCallRunnerItem>;
302
+ protected _sequentialRunnerTask: Task<unknown> | null;
303
+ protected _sequentialRunnerQueue: Queue<FunctionCallRunnerItem>;
304
+ protected _skipTts: boolean | null;
305
+ protected _summaryTask: Task<unknown> | null;
306
+ protected _warnedRealtimeServiceNoTurnFrames: boolean;
307
+ constructor(options?: LLMServiceOptions);
308
+ /** Return the adapter class to instantiate for this service. */
309
+ static _resolveAdapterClass(): LLMAdapterClass;
310
+ /**
311
+ * Get the LLM adapter instance.
312
+ *
313
+ * @returns The adapter instance used for LLM communication.
314
+ */
315
+ getLlmAdapter(): TAdapter;
316
+ /**
317
+ * Create an LLM-specific message (as opposed to a standard message) for use
318
+ * in an LLMContext.
319
+ *
320
+ * @param message The message content.
321
+ * @returns A LLMSpecificMessage instance.
322
+ */
323
+ createLlmSpecificMessage(message: unknown): LLMSpecificMessage;
324
+ /**
325
+ * Log that the service is generating a response from the given context.
326
+ *
327
+ * The context is included unless the LLM context log mode is `off`.
328
+ *
329
+ * @param context The context sent with the request.
330
+ */
331
+ protected _logLlmResponse(context: LLMContext): void;
332
+ /**
333
+ * Log that a realtime service is seeding its server-side conversation.
334
+ *
335
+ * Realtime services upload the context once per session (and again after a
336
+ * reset), then send only new items. The context is included unless the LLM
337
+ * context log mode is `off`.
338
+ *
339
+ * @param context The context being uploaded.
340
+ */
341
+ protected _logLlmConversationSetup(context: LLMContext): void;
342
+ protected _logLlmEvent(event: string, context: LLMContext): void;
343
+ /**
344
+ * Run a one-shot, out-of-band (i.e. out-of-pipeline) inference with the
345
+ * given LLM context.
346
+ *
347
+ * Must be implemented by subclasses.
348
+ *
349
+ * @param context The LLM context containing conversation history.
350
+ * @param options.maxTokens Optional maximum number of tokens to generate. If
351
+ * provided, overrides the service's default max_tokens/max_completion_tokens
352
+ * setting.
353
+ * @param options.systemInstruction Optional system instruction to use for
354
+ * this inference. If provided, overrides any system instruction in the
355
+ * context.
356
+ * @param options.responseSchema Optional JSON schema the reply must follow.
357
+ * Services that can have the provider enforce it return JSON text matching
358
+ * the schema. When the service or its current model cannot enforce one
359
+ * (see `supportsResponseSchema`), the schema is ignored with a warning.
360
+ * The schema must satisfy the strictest provider in use: every object
361
+ * lists all its properties as required and sets `additionalProperties` to
362
+ * false.
363
+ * @returns The LLM's response as a string, or null if no response is generated.
364
+ */
365
+ runInference(_context: LLMContext, _options?: {
366
+ maxTokens?: number | null;
367
+ systemInstruction?: string | null;
368
+ responseSchema?: Record<string, unknown> | null;
369
+ }): Promise<string | null>;
370
+ /** The schema to send, or null with a warning if it cannot be enforced. */
371
+ protected _checkResponseSchema(responseSchema: Record<string, unknown> | null | undefined): Record<string, unknown> | null;
372
+ /** Whether this service's provider can enforce a response schema. */
373
+ get supportsResponseSchema(): boolean;
374
+ /**
375
+ * Whether a model can enforce a response schema, on a provider that can.
376
+ *
377
+ * @param model The model name.
378
+ */
379
+ static modelSupportsResponseSchema(_model: string): boolean;
380
+ /**
381
+ * Whether this service reports time-to-first-answer-token.
382
+ *
383
+ * Speech-to-speech services answer in audio, which has no answer token to
384
+ * measure to, so only text-answering services report it. Derived from
385
+ * `serviceMetadataFrame()` and cached, since it is read once per streamed
386
+ * token.
387
+ */
388
+ get reportsTtfat(): boolean;
389
+ /**
390
+ * Whether this service delivers a tool's intermediate results to the model.
391
+ *
392
+ * An intermediate result is one reported with
393
+ * `new FunctionCallResultProperties({ isFinal: false })` while the call keeps
394
+ * running. A text service passes them on as context messages. A
395
+ * speech-to-speech service has to map them onto whatever second channel its
396
+ * provider offers, and not all of them have one.
397
+ */
398
+ get acceptsIntermediateFunctionCallResults(): boolean;
399
+ /**
400
+ * Why this service can't take the given role in an `LLMWithBackend`, if it
401
+ * can't.
402
+ *
403
+ * The composite raises with what this returns, so the objection says what
404
+ * to do instead. Services that work in both roles, which is nearly all of
405
+ * them, say nothing.
406
+ *
407
+ * @param role The role the service is being asked to take.
408
+ * @returns The reason, or null when the service can take the role.
409
+ */
410
+ llmWithBackendRoleObjection(_role: LLMWithBackendRole): string | null;
411
+ /**
412
+ * Send a model the thinking default its service lists, and log it once per
413
+ * model.
414
+ *
415
+ * Services that send each model its lowest thinking setting call this when
416
+ * the request configures no thinking of its own. With
417
+ * `useProviderThinkingDefault` set, the service sends no default. The first
418
+ * request for each model logs the setting sent, or that the model runs at
419
+ * the provider's default, warning when it has no default.
420
+ *
421
+ * @param params The request params, updated in place. Each field of
422
+ * `defaultParams` is merged into the dict already there, if any.
423
+ * @param model The model the request is for.
424
+ * @param defaultParams The request fields to send, or null if the service
425
+ * lists no default for the model.
426
+ * @param options.canThink Whether the model can think, which decides
427
+ * whether a model with no default is warned about.
428
+ * @param options.provider The provider's name, for the log lines.
429
+ * @param options.settingsFields The settings fields that configure thinking,
430
+ * as the log lines name them, such as "`thinking`".
431
+ */
432
+ protected _applyThinkingDefault(params: Record<string, unknown>, model: string, defaultParams: Record<string, Record<string, unknown>> | null, options: {
433
+ canThink: boolean;
434
+ provider: string;
435
+ settingsFields: string;
436
+ }): void;
437
+ /**
438
+ * The metadata frame this LLM service broadcasts at start.
439
+ *
440
+ * The base returns a plain (non-realtime) frame; realtime (speech-to-speech)
441
+ * subclasses override this to set `isRealtimeService: true` and, when their
442
+ * turns are provider-driven, recommend `ExternalUserTurnStrategies` via
443
+ * `userTurnStrategies`.
444
+ *
445
+ * Mostly here for conceptual consistency — today only realtime services
446
+ * need to override it — but it's a natural placeholder for future
447
+ * LLM-service metadata.
448
+ */
449
+ serviceMetadataFrame(): LLMServiceMetadataFrame;
450
+ /**
451
+ * Warn (once) when a realtime service won't emit its own turn frames.
452
+ *
453
+ * Realtime services call this from `serviceMetadataFrame()` at the point
454
+ * they determine whether their turns are provider-driven. When they aren't,
455
+ * downstream processors that expect `UserStarted/StoppedSpeakingFrame`
456
+ * (e.g. RTVI) may need local VAD/turn detection.
457
+ */
458
+ protected _warnIfRealtimeServiceEmitsNoTurnFrames(emitsTurnFrames: boolean): void;
459
+ /**
460
+ * Start the LLM service.
461
+ *
462
+ * @param frame The start frame.
463
+ */
464
+ start(frame: StartFrame): Promise<void>;
465
+ /**
466
+ * Stop the LLM service.
467
+ *
468
+ * @param frame The end frame.
469
+ */
470
+ stop(frame: EndFrame): Promise<void>;
471
+ /**
472
+ * Cancel the LLM service.
473
+ *
474
+ * @param frame The cancel frame.
475
+ */
476
+ cancel(frame: CancelFrame): Promise<void>;
477
+ /**
478
+ * Release LLM service resources at teardown.
479
+ *
480
+ * Besides this service's own tasks, runs any cleanup callables carried by
481
+ * registered tool handlers (e.g. closing an MCP client's connection).
482
+ */
483
+ cleanup(): Promise<void>;
484
+ /**
485
+ * Append durable text to the system instruction, preserving the user's
486
+ * prompt.
487
+ *
488
+ * The text is composed onto the end of the system instruction (joined with
489
+ * a blank line) and re-applied on every inference, so it survives
490
+ * context-message resets (e.g. `new LLMMessagesUpdateFrame({ messages: [] })`).
491
+ * Intended for framework components that own an LLM and need to add
492
+ * standard guidance to a user-provided prompt — for example, `UIWorker`
493
+ * appends the UI wire-format guide. Appended instructions compose after the
494
+ * user's base prompt and alongside the turn-completion and
495
+ * async-tool-cancellation instructions.
496
+ *
497
+ * @param instruction The instruction text to append.
498
+ */
499
+ appendSystemInstruction(instruction: string): void;
500
+ /**
501
+ * Whether any registered tool runs asynchronously.
502
+ *
503
+ * @returns True when a tool is registered with `cancelOnInterruption: false`,
504
+ * which is what makes the async-tool guidance worth composing in. The
505
+ * built-in cancellation tool is registered as a synchronous one, so it
506
+ * never counts on its own.
507
+ */
508
+ protected _hasAsyncTools(): boolean;
509
+ /**
510
+ * Rebuild `systemInstruction` from the base prompt and all active addons.
511
+ *
512
+ * Joins the user's base system instruction (the single source of truth,
513
+ * captured at construction and refreshed on runtime `systemInstruction`
514
+ * updates) with any appended instructions (e.g. the `UIWorker` prompt
515
+ * guide), turn completion instructions (when enabled), and async tool
516
+ * cancellation instructions (when enabled). Safe to call repeatedly — it
517
+ * always rebuilds from the base, so it never compounds, and it logs the
518
+ * result only when it differs from the previous composition.
519
+ */
520
+ protected _composeSystemInstruction(): void;
521
+ /**
522
+ * Apply a settings delta, handling turn-completion fields.
523
+ *
524
+ * @param delta An LLM settings delta.
525
+ * @returns Dict mapping changed field names to their previous values.
526
+ */
527
+ protected _updateSettings(delta: LLMSettings): Promise<Record<string, unknown>>;
528
+ /**
529
+ * Process a frame.
530
+ *
531
+ * @param frame The frame to process.
532
+ * @param direction The direction of frame processing.
533
+ */
534
+ processFrame(frame: Frame, direction: FrameDirection): Promise<void>;
535
+ /**
536
+ * Pushes a frame.
537
+ *
538
+ * @param frame The frame to push.
539
+ * @param direction The direction of frame pushing.
540
+ */
541
+ pushFrame(frame: Frame, direction?: FrameDirection): Promise<void>;
542
+ /**
543
+ * Push LLM text, using turn completion detection if enabled.
544
+ *
545
+ * This helper method simplifies text pushing in LLM implementations by
546
+ * handling the conditional logic for turn completion internally.
547
+ *
548
+ * @param text The text content from the LLM to push.
549
+ */
550
+ protected _pushLlmText(text: string): Promise<void>;
551
+ protected _handleInterruptions(_frame: InterruptionFrame): Promise<void>;
552
+ /**
553
+ * Stop generating a response whose user turn turned out to be unfinished.
554
+ *
555
+ * The tokens are wasted either way; stopping keeps us from paying for the
556
+ * rest of them. Unlike an interruption this leaves the turn open — the bot
557
+ * never spoke, and the user is still mid-turn.
558
+ */
559
+ protected _handleEagerEndOfTurnCancel(_frame: EagerEndOfTurnCancelFrame): Promise<void>;
560
+ /**
561
+ * Handle context summarization request from aggregator.
562
+ *
563
+ * Processes a summarization request by generating a compressed summary of
564
+ * conversation history. Uses the adapter to format the summary according
565
+ * to the provider's requirements. Broadcasts the result back to the
566
+ * aggregator for context reconstruction.
567
+ *
568
+ * @param frame The summary request frame containing context and parameters.
569
+ */
570
+ protected _handleSummaryRequest(frame: LLMContextSummaryRequestFrame): Promise<void>;
571
+ /**
572
+ * Background task to generate summary without blocking the pipeline.
573
+ *
574
+ * @param frame The summary request frame containing context and parameters.
575
+ */
576
+ protected _generateSummaryTask(frame: LLMContextSummaryRequestFrame): Promise<void>;
577
+ /**
578
+ * Generate a compressed summary of conversation context.
579
+ *
580
+ * Uses the message selection logic to identify which messages to
581
+ * summarize, formats them as a transcript, and invokes the LLM to generate
582
+ * a concise summary. The summary is formatted according to the LLM
583
+ * provider's requirements using the adapter.
584
+ *
585
+ * Requires the service to implement `runInference()` for one-shot LLM calls.
586
+ *
587
+ * @param frame The summary request frame containing context and configuration.
588
+ * @returns Tuple of (formatted summary message, lastSummarizedIndex).
589
+ * @throws Error if there are no messages to summarize, the service doesn't
590
+ * support runInference(), or the LLM returns an empty summary.
591
+ */
592
+ protected _generateSummary(frame: LLMContextSummaryRequestFrame): Promise<[string, number]>;
593
+ /**
594
+ * Register a function handler for LLM function calls.
595
+ *
596
+ * Call options resolve with the precedence **explicit argument >
597
+ * `toolOptions()` attributes > default**. `null`/`undefined` (the default)
598
+ * means "not provided" — the option falls back to the `toolOptions()` value
599
+ * on the handler, then to the documented default.
600
+ *
601
+ * @param functionName The name of the function to handle. Use null to handle
602
+ * all function calls with a catch-all handler.
603
+ * @param handler The function handler. Should accept a single
604
+ * FunctionCallParams parameter.
605
+ * @param options.cancelOnInterruption Whether to cancel this function call
606
+ * when an interruption occurs. When false the call is treated as
607
+ * asynchronous: the LLM continues the conversation immediately without
608
+ * waiting for the result, and the result is injected later via a
609
+ * developer message. Defaults to null (fall back to the `toolOptions()`
610
+ * value, then to true). A speech-to-speech service takes intermediate
611
+ * results (reported via `new FunctionCallResultProperties({ isFinal: false })`)
612
+ * on whatever second channel its provider offers; one that can't says so
613
+ * with `acceptsIntermediateFunctionCallResults` and drops them with a
614
+ * warning.
615
+ * @param options.timeoutSecs Optional per-tool timeout in seconds,
616
+ * overriding the global `functionCallTimeoutSecs`. A call that runs past it
617
+ * is cancelled: the handler is cancelled, the call is settled as
618
+ * cancelled, and inference runs so the LLM can report that it didn't
619
+ * complete. The deadline covers the handler's execution as a whole, so
620
+ * reporting an intermediate result neither clears it nor restarts it.
621
+ * Defaults to null (fall back to the `toolOptions()` value, then to the
622
+ * global timeout).
623
+ * @param options.cancellableByLlm Whether the LLM may cancel this call while
624
+ * it runs, through the `cancel_<name>` tool advertised alongside it. Pair
625
+ * it with `cancelOnInterruption: false`; a synchronous call holds the LLM
626
+ * until it returns, so there is no moment at which it could ask for the
627
+ * call to stop. Defaults to null (fall back to the `toolOptions()` value,
628
+ * then to false).
629
+ */
630
+ registerFunction(functionName: string | null, handler: FunctionCallHandler, options?: {
631
+ cancelOnInterruption?: boolean | null;
632
+ timeoutSecs?: number | null;
633
+ cancellableByLlm?: boolean | null;
634
+ }): void;
635
+ /**
636
+ * Track cleanup work a registered tool handler asks to run at teardown.
637
+ *
638
+ * A handler backed by a resource that outlives the call — an MCP server
639
+ * connection, for instance — can carry a zero-argument async callable under
640
+ * `_pipecatCleanup`. It is awaited when this service is cleaned up, the hook
641
+ * the pipeline guarantees to run at teardown, so the resource is released
642
+ * without the developer wiring teardown manually. Handlers sharing a
643
+ * resource carry the same callable, recorded once.
644
+ *
645
+ * Cleanups are kept for the service's lifetime even if their handlers are
646
+ * later unregistered: the resource may outlive any one tool's
647
+ * advertisement, and cleanups are expected to be idempotent.
648
+ */
649
+ protected _recordToolCleanup(handler: unknown): void;
650
+ /** Run recorded tool cleanups; errors are logged, not raised. */
651
+ protected _runToolCleanups(): Promise<void>;
652
+ /**
653
+ * Register a direct function handler.
654
+ *
655
+ * Shared core behind automatic registration (from an `LLMContext` or
656
+ * `LLMSetToolsFrame`). Call options resolve by precedence: explicit
657
+ * argument > `toolOptions()` attributes > default.
658
+ *
659
+ * @param handler The direct function to register.
660
+ * @param options.cancelOnInterruption Explicit override, or null to use the
661
+ * handler's value (then the true default).
662
+ * @param options.timeoutSecs Explicit override, or null to use the handler's
663
+ * value (then the null default, i.e. the global timeout).
664
+ * @param options.cancellableByLlm Explicit override, or null to use the
665
+ * handler's value (then the false default).
666
+ */
667
+ protected _registerDirectFunction(handler: (...args: any[]) => Promise<unknown>, options?: {
668
+ cancelOnInterruption?: boolean | null;
669
+ timeoutSecs?: number | null;
670
+ cancellableByLlm?: boolean | null;
671
+ }): void;
672
+ /**
673
+ * Resolve whether the LLM may cancel a tool's calls.
674
+ *
675
+ * @param functionName The tool's name, for the warning below.
676
+ * @param explicit The value passed to the register call, or null if omitted.
677
+ * @param handler The handler, which may carry a `toolOptions()` value.
678
+ * @param cancelOnInterruption The tool's interruption behaviour, already
679
+ * resolved by the caller — resolving it again here would read past
680
+ * whatever the caller was told explicitly.
681
+ * @returns Whether the LLM may cancel this tool's calls.
682
+ */
683
+ protected _resolveCancellableByLlm(functionName: string | null, explicit: boolean | null | undefined, handler: unknown, cancelOnInterruption: boolean): boolean;
684
+ /**
685
+ * Resolve a tool call option by precedence: explicit > handler attribute >
686
+ * default.
687
+ *
688
+ * An explicit `null` is treated as "not provided" and falls back to the
689
+ * handler's value, then the default — so `null` can't be passed to force a
690
+ * default past a handler value (an intentionally unsupported niche; set
691
+ * `functionCallTimeoutSecs` on the service for that).
692
+ *
693
+ * @param functionName The tool's name, for logging.
694
+ * @param explicit The value passed to the register call, or null if the
695
+ * caller omitted it.
696
+ * @param handler The handler, which may carry `toolOptions()` attributes.
697
+ * @param attr The attribute to read (e.g. `_pipecatTimeoutSecs`).
698
+ * @param options.default The value to use when neither an explicit argument
699
+ * nor a handler value is present.
700
+ * @returns The resolved option value.
701
+ */
702
+ protected _resolveToolOption(functionName: string | null, explicit: unknown, handler: unknown, attr: string, options: {
703
+ default: unknown;
704
+ }): unknown;
705
+ /**
706
+ * Whether an advertised handler differs from the one already registered.
707
+ *
708
+ * Normalizes a `DirectFunctionWrapper` to its underlying `.function` on both
709
+ * sides, then compares by identity. Flows reuses one closure per node across
710
+ * repeated context frames (no change) but builds a fresh closure on
711
+ * transition (a real change), so identity is the right test.
712
+ *
713
+ * @param item The currently registered entry.
714
+ * @param newHandler The advertised handler — a raw callable or a
715
+ * `DirectFunctionWrapper`.
716
+ * @returns True if `newHandler` is a different callable than `item` holds.
717
+ */
718
+ protected _advertisedHandlerChanged(item: FunctionCallRegistryItem, newHandler: unknown): boolean;
719
+ /**
720
+ * Register handlers for any tools in the given set that carry one.
721
+ *
722
+ * A tool carries a handler when it's advertised as a direct function or as
723
+ * a `FunctionSchema` with a `handler` set; either way the handler is
724
+ * registered automatically, so no `registerFunction` call is needed. A
725
+ * `FunctionSchema` without a handler is advertise-only and registers
726
+ * nothing.
727
+ *
728
+ * Accepts whatever `LLMContext` accepts for tools — a `ToolsSchema`, a plain
729
+ * list of direct functions / `FunctionSchema` objects, or `NOT_GIVEN` —
730
+ * normalizing as needed.
731
+ *
732
+ * Explicit `registerFunction` registrations are always left untouched, so
733
+ * explicit registration wins. An auto-registered entry (from a previous
734
+ * advertised set) is rebound when the new set carries a *different* handler
735
+ * for the same name — so a re-declared per-node handler takes effect — and
736
+ * left untouched when the handler is unchanged, so repeated frames don't
737
+ * churn.
738
+ *
739
+ * @param tools The tools to scan for handlers.
740
+ */
741
+ protected _registerAdvertisedToolHandlers(tools: unknown): void;
742
+ /** Mark a registry entry as managed by the advertised tool set. */
743
+ protected _markAutoRegistered(name: string): void;
744
+ /**
745
+ * Warn that a manual registration is unnecessary, once per function.
746
+ *
747
+ * Fires when a tool is registered explicitly via `registerFunction` yet its
748
+ * advertised `FunctionSchema` already carries a handler — the schema alone
749
+ * would register it. An auto-registered entry (e.g. from a same-named
750
+ * direct function) is not a manual registration and is left silent.
751
+ *
752
+ * @param functionName The name shared by the manual registration and the
753
+ * handler-carrying schema. Must already be registered.
754
+ */
755
+ protected _warnIfRedundantManualRegistration(functionName: string): void;
756
+ /**
757
+ * Return the service's own configured tools, if any.
758
+ *
759
+ * Used by the auto-registration mechanism. Tools normally reach a service
760
+ * through the `LLMContext` on each inference. Some services (the realtime
761
+ * services) also accept tools configured directly on the service (e.g. via
762
+ * a constructor option) as an alternative; they override this to return
763
+ * those tools verbatim, in whatever form they hold them — a `ToolsSchema` or
764
+ * a provider-native tool list. When the context advertises no tools,
765
+ * `_syncRegisteredToolHandlers` normalizes the result and registers handlers
766
+ * for any standard tools it contains; provider-native tools carry no
767
+ * handlers, so they contribute nothing to register.
768
+ *
769
+ * A service that overrides this **must follow the auto-registration
770
+ * mechanism's preference rules: context tools, then service-configured
771
+ * tools**.
772
+ *
773
+ * @returns The service's configured tools verbatim (e.g. a `ToolsSchema` or
774
+ * a provider-native tool list), or null when there are none (the default).
775
+ */
776
+ protected _serviceTools(): ToolsSchema | unknown[] | null;
777
+ /**
778
+ * Sync the registered handlers with the handlers advertised in `tools`.
779
+ *
780
+ * Registers handlers for any tools the set advertises with one (direct
781
+ * functions, or `FunctionSchema` objects carrying a `handler`), then drops
782
+ * the handlers we auto-registered for tools it no longer advertises — so
783
+ * the registry matches what the LLM can see.
784
+ *
785
+ * This is the single path for keeping handlers in step with the advertised
786
+ * tools. The base service runs it on every `LLMContextFrame` (the context
787
+ * carries the current tool set on each inference). Realtime services that
788
+ * support runtime tool changes also call it from their own
789
+ * `LLMSetToolsFrame` handling, since they run continuously and don't get a
790
+ * context frame per turn. When the context advertises no tools, handlers
791
+ * fall back to `_serviceTools()` (the service's own configured tools).
792
+ *
793
+ * Explicit registrations (`registerFunction`), the catch-all handler, and
794
+ * built-in tools are never pruned.
795
+ *
796
+ * @param tools The advertised tool set (a `ToolsSchema`, a plain list, or
797
+ * null / `NOT_GIVEN` for "no tools").
798
+ */
799
+ protected _syncRegisteredToolHandlers(tools: unknown): void;
800
+ /**
801
+ * Drop auto-registered handlers for tools no longer advertised.
802
+ *
803
+ * Only entries with `autoRegistered: true` are eligible; explicit
804
+ * registrations, the catch-all handler, and built-in tools are untouched.
805
+ *
806
+ * @param advertised Names of handler-carrying tools in the new advertised set.
807
+ */
808
+ protected _unregisterUnadvertisedToolHandlers(advertised: Set<string | null>): void;
809
+ /**
810
+ * Remove a registered function handler.
811
+ *
812
+ * This removes the handler but does not stop advertising the tool to the
813
+ * LLM. To remove a tool cleanly, prefer an `LLMSetToolsFrame` with the
814
+ * updated tool set — that both stops advertising it and avoids the LLM
815
+ * trying to call a tool that's no longer there.
816
+ *
817
+ * @param functionName The name of the function handler to remove.
818
+ * @throws Error if no handler is registered under that name.
819
+ */
820
+ unregisterFunction(functionName: string | null): void;
821
+ /**
822
+ * Remove a registered direct function handler (internal; no warning).
823
+ *
824
+ * @param handler The direct function handler to remove.
825
+ * @throws Error if no handler is registered under its name.
826
+ */
827
+ protected _unregisterDirectFunction(handler: (...args: any[]) => Promise<unknown>): void;
828
+ /**
829
+ * Check if a function handler is registered.
830
+ *
831
+ * @param functionName The name of the function to check.
832
+ * @returns True if the function is registered or if a catch-all handler
833
+ * (null) is registered.
834
+ */
835
+ hasFunction(functionName: string): boolean;
836
+ /**
837
+ * Whether the named function was registered with cancelOnInterruption=false.
838
+ *
839
+ * Mirrors the registry-lookup pattern in `runFunctionCalls()`: a
840
+ * name-specific entry takes precedence; if there isn't one, fall back to
841
+ * the null-keyed catch-all entry. Returns false if no entry matches.
842
+ */
843
+ protected _functionIsAsync(functionName: string): boolean;
844
+ /**
845
+ * Execute a sequence of function calls from the LLM.
846
+ *
847
+ * Triggers the on_function_calls_started event and executes functions
848
+ * either in parallel or sequentially based on the runInParallel setting.
849
+ *
850
+ * @param functionCalls The function calls to execute.
851
+ */
852
+ runFunctionCalls(functionCalls: readonly FunctionCallFromLLM[]): Promise<void>;
853
+ protected _createSequentialRunnerTask(): Promise<void>;
854
+ protected _cancelSequentialRunnerTask(): Promise<void>;
855
+ protected _cancelSummaryTask(): Promise<void>;
856
+ protected _cancelAllFunctionCallTasks(): Promise<void>;
857
+ protected _sequentialRunnerHandler(): Promise<void>;
858
+ protected _runParallelFunctionCalls(runnerItems: readonly FunctionCallRunnerItem[]): Promise<void>;
859
+ protected _runSequentialFunctionCalls(runnerItems: readonly FunctionCallRunnerItem[]): Promise<void>;
860
+ protected _runFunctionCall(runnerItem: FunctionCallRunnerItem): Promise<void>;
861
+ /** Build a registry item that routes to the missing-function handler. */
862
+ protected _buildMissingFunctionCallRegistryItem(functionName: string): FunctionCallRegistryItem;
863
+ /** Return a terminal tool result when the LLM calls an unknown function. */
864
+ protected _missingFunctionCallHandler(params: FunctionCallParams): Promise<void>;
865
+ /**
866
+ * Return the set of standard-tool names currently advertised to the LLM.
867
+ *
868
+ * Custom (LLM-specific) tools are not included, since they have no
869
+ * consistent name field across adapters.
870
+ */
871
+ static _advertisedToolNames(context: LLMContext | null | undefined): Set<string>;
872
+ /**
873
+ * Log an appropriate message when a tool is called with no handler.
874
+ *
875
+ * Distinguishes two cases:
876
+ *
877
+ * - **Developer error:** the tool is advertised to the LLM but no handler
878
+ * was wired up (a `FunctionSchema` must've been provided with neither
879
+ * `handler` nor accompanying `registerFunction` call). Logged at error
880
+ * level since this almost always indicates a bug.
881
+ * - **Hallucination:** the tool is not in the currently advertised tool
882
+ * set. Logged at warning level since this is model behavior the
883
+ * application can do little about beyond returning a terminal result.
884
+ */
885
+ protected _logMissingFunctionCall(functionName: string, context: unknown): void;
886
+ /**
887
+ * Whether the LLM may cancel calls of a registered tool.
888
+ *
889
+ * The one place that decides it, so what gets advertised and what a cancel
890
+ * tool will actually stop can't drift apart.
891
+ *
892
+ * @param item The registered tool to judge.
893
+ * @returns True if the tool opted in with `cancellableByLlm`.
894
+ */
895
+ protected _isCancellable(item: FunctionCallRegistryItem): boolean;
896
+ /**
897
+ * Names of the registered tools the LLM may cancel.
898
+ *
899
+ * @returns The tools that opted in with `cancellableByLlm: true`.
900
+ */
901
+ protected _cancellableToolNames(): Set<string>;
902
+ /**
903
+ * Match the advertised cancel tools to the tools currently registered.
904
+ *
905
+ * One cancel tool per cancellable tool, named for it, reconciled from a
906
+ * single reading of the registry so the advertised set can never drift from
907
+ * what is actually cancellable. A tool that never opted in has no cancel
908
+ * tool at all, so there is nothing for the LLM to call against it.
909
+ */
910
+ protected _syncCancelTools(): void;
911
+ /**
912
+ * Handle a `cancel_<tool>` invocation from the LLM.
913
+ *
914
+ * Which work to stop comes from the tool the model called, so the common
915
+ * case takes no arguments at all. `tool_call_id` only has to be given to
916
+ * choose between several running calls of the same tool.
917
+ *
918
+ * @param params Function call parameters, optionally carrying `tool_call_id`.
919
+ */
920
+ protected _cancelToolHandler(params: FunctionCallParams): Promise<void>;
921
+ /**
922
+ * Cancel the in-flight function calls selected by a predicate.
923
+ *
924
+ * Cancelling a call cancels its handler's task (delivering a
925
+ * `CancelledError`) so cancel-aware handlers run their cleanup, broadcasts a
926
+ * `FunctionCallCancelFrame` so the rest of the pipeline can settle the
927
+ * call, and notifies application code via `on_function_calls_cancelled`.
928
+ *
929
+ * @param predicate Selects which in-flight calls to cancel.
930
+ * @param options.reason Short description of what triggered the
931
+ * cancellation, included in the log messages.
932
+ * @param options.runLlm Whether inference should run once the cancelled
933
+ * calls are settled in the context.
934
+ * @returns The function calls that were cancelled.
935
+ */
936
+ protected _cancelFunctionCallTasks(predicate: (item: FunctionCallRunnerItem) => boolean, options: {
937
+ reason: string;
938
+ runLlm?: boolean;
939
+ }): Promise<FunctionCallFromLLM[]>;
940
+ /**
941
+ * Settle a cancelled function call downstream.
942
+ *
943
+ * @param runnerItem The function call that was cancelled.
944
+ * @param options.runLlm Whether inference should run once the call is
945
+ * settled in the context.
946
+ * @returns The cancelled call, described for `on_function_calls_cancelled`.
947
+ */
948
+ protected _broadcastFunctionCallCancelled(runnerItem: FunctionCallRunnerItem, options?: {
949
+ runLlm?: boolean;
950
+ }): Promise<FunctionCallFromLLM>;
951
+ /**
952
+ * Cancel a function call that ran past its deadline.
953
+ *
954
+ * The handler usually still owns the call and is cancelled outright. If it
955
+ * happened to finish while the timeout was being processed its task is
956
+ * already gone and there is nothing left to cancel, but the deadline has
957
+ * settled the call, so its result is rejected — the pipeline is told the
958
+ * call is over regardless, or it waits on a result that can never arrive.
959
+ *
960
+ * A deadline is the one cancellation nothing else follows up on, so it asks
961
+ * for inference: without it the LLM never learns the call is over and the
962
+ * user is left waiting on an answer that never comes.
963
+ *
964
+ * @param runnerItem The function call that timed out.
965
+ */
966
+ protected _timeoutFunctionCall(runnerItem: FunctionCallRunnerItem): Promise<void>;
967
+ /**
968
+ * Cancel every function call in flight, whether or not it survives
969
+ * interruptions.
970
+ *
971
+ * Each handler is cancelled, the call is settled downstream as cancelled,
972
+ * and `on_function_calls_cancelled` fires. No inference runs for the
973
+ * cancellations.
974
+ *
975
+ * @param options.reason What triggered the cancellation, for the logs.
976
+ * @returns The calls that were cancelled.
977
+ */
978
+ cancelFunctionCalls(options?: {
979
+ reason?: string;
980
+ }): Promise<FunctionCallFromLLM[]>;
981
+ /**
982
+ * Cancel in-progress function call tasks by their toolCallId.
983
+ *
984
+ * @param toolCallId toolCallId to cancel.
985
+ */
986
+ protected _cancelFunctionCallsByToolCallId(toolCallId: string): Promise<void>;
987
+ protected _cancelFunctionCall(functionName: string | null): Promise<void>;
988
+ protected _functionCallTaskFinished(task: Task<unknown>): void;
989
+ }
990
+ /**
991
+ * Raised by `_wsSend`/`_wsRecv` after a transparent reconnection.
992
+ *
993
+ * Signals that the WebSocket connection was lost and automatically
994
+ * re-established. The current inference should be restarted — any
995
+ * connection-local state on the server (e.g. cached responses) is gone.
996
+ */
997
+ export declare class WebsocketReconnectedError extends Error {
998
+ name: string;
999
+ }
1000
+ export interface WebsocketLLMServiceOptions extends LLMServiceOptions, WebsocketServiceOptions {
1001
+ }
1002
+ declare const WebsocketLLMService_base: typeof LLMService & (abstract new (...args: any[]) => WebsocketService);
1003
+ /**
1004
+ * Base class for websocket-based LLM services.
1005
+ *
1006
+ * Each LLM inference is a discrete request/response exchange: send one
1007
+ * request, receive events inline until a terminal event, then wait for the
1008
+ * next frame to trigger an inference. This contrasts with
1009
+ * `WebsocketTTSService` / `WebsocketSTTService` which stream data
1010
+ * continuously via a background receive loop (`_receiveTaskHandler`). This
1011
+ * class does **not** start a background receive loop.
1012
+ *
1013
+ * Provides connection lifecycle management (connect on setup, disconnect on
1014
+ * stop/cancel), automatic reconnection with exponential backoff, and three
1015
+ * helpers for running each inference:
1016
+ *
1017
+ * 1. `_ensureConnected()` — verify the websocket is alive, reconnect with
1018
+ * exponential backoff if not.
1019
+ * 2. `_wsSend(message)` — send the inference request as JSON.
1020
+ * 3. `_wsRecv()` — receive and parse response events one at a time until the
1021
+ * caller sees a terminal event.
1022
+ *
1023
+ * `_wsSend` and `_wsRecv` catch `ConnectionClosed` transparently,
1024
+ * auto-reconnect via `_tryReconnect`, and raise `WebsocketReconnectedError`
1025
+ * so callers know the inference must be restarted. If reconnection fails,
1026
+ * the original `ConnectionClosed` propagates.
1027
+ *
1028
+ * Subclasses must implement:
1029
+ * - `_connectWebsocket()`: establish the websocket connection.
1030
+ * - `_disconnectWebsocket()`: close the websocket and clean up.
1031
+ *
1032
+ * Event handlers:
1033
+ * - on_connection_error: called when a websocket connection error occurs.
1034
+ *
1035
+ * @example
1036
+ * llm.eventHandler("on_connection_error", async (llm: LLMService, error: string) => {
1037
+ * logger.error(`LLM connection error: ${error}`);
1038
+ * });
1039
+ */
1040
+ export declare abstract class WebsocketLLMService<TAdapter extends BaseLLMAdapter = BaseLLMAdapter> extends WebsocketLLMService_base<TAdapter> {
1041
+ constructor(options?: WebsocketLLMServiceOptions);
1042
+ /** Connect: reset flags and establish the websocket. */
1043
+ _connect(): Promise<void>;
1044
+ /** Disconnect: set flags and close the websocket. */
1045
+ _disconnect(): Promise<void>;
1046
+ /**
1047
+ * Set up the service and connect.
1048
+ *
1049
+ * @param setup Configuration object containing setup parameters.
1050
+ */
1051
+ setup(setup: FrameProcessorSetup): Promise<void>;
1052
+ /**
1053
+ * Stop the service and close WebSocket connection.
1054
+ *
1055
+ * @param frame The end frame triggering service shutdown.
1056
+ */
1057
+ stop(frame: EndFrame): Promise<void>;
1058
+ /**
1059
+ * Cancel the service and close WebSocket connection.
1060
+ *
1061
+ * @param frame The cancel frame triggering service cancellation.
1062
+ */
1063
+ cancel(frame: CancelFrame): Promise<void>;
1064
+ /**
1065
+ * Send a JSON message over the websocket.
1066
+ *
1067
+ * Guards against sends during intentional disconnect. If the send fails
1068
+ * with `ConnectionClosed`, attempts to reconnect and raises
1069
+ * `WebsocketReconnectedError` on success so the caller can restart the
1070
+ * inference. If reconnection fails, the original `ConnectionClosed`
1071
+ * propagates.
1072
+ *
1073
+ * @param message The message dict to serialize and send.
1074
+ */
1075
+ protected _wsSend(message: Record<string, unknown>): Promise<void>;
1076
+ /**
1077
+ * Receive and parse a JSON message from the websocket.
1078
+ *
1079
+ * If the receive fails with `ConnectionClosed`, attempts to reconnect and
1080
+ * raises `WebsocketReconnectedError` on success. If reconnection fails, the
1081
+ * original `ConnectionClosed` propagates.
1082
+ *
1083
+ * @returns The parsed JSON message as a dict.
1084
+ */
1085
+ protected _wsRecv(): Promise<any>;
1086
+ /**
1087
+ * Ensure the websocket is connected, reconnecting if needed.
1088
+ *
1089
+ * Uses `_tryReconnect` with exponential backoff.
1090
+ *
1091
+ * @throws Error if the connection could not be established.
1092
+ */
1093
+ protected _ensureConnected(): Promise<void>;
1094
+ /**
1095
+ * Not used — messages are received inline during each inference.
1096
+ *
1097
+ * This satisfies the `WebsocketService` abstract method but is never called
1098
+ * because `_receiveTaskHandler` is never started.
1099
+ */
1100
+ _receiveMessages(): Promise<void>;
1101
+ protected _reportError(error: ErrorFrame, options?: {
1102
+ forceTreatAsPermanent?: boolean;
1103
+ }): Promise<void>;
1104
+ }
1105
+ export {};
1106
+ //# sourceMappingURL=llm_service.d.ts.map