@livekit/agents 1.1.0 → 1.2.1

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 (959) hide show
  1. package/dist/_exceptions.cjs.map +1 -1
  2. package/dist/_exceptions.d.ts.map +1 -1
  3. package/dist/_exceptions.js.map +1 -1
  4. package/dist/audio.cjs +89 -3
  5. package/dist/audio.cjs.map +1 -1
  6. package/dist/audio.d.cts +36 -1
  7. package/dist/audio.d.ts +36 -1
  8. package/dist/audio.d.ts.map +1 -1
  9. package/dist/audio.js +76 -2
  10. package/dist/audio.js.map +1 -1
  11. package/dist/beta/index.cjs +29 -0
  12. package/dist/beta/index.cjs.map +1 -0
  13. package/dist/beta/index.d.cts +2 -0
  14. package/dist/beta/index.d.ts +2 -0
  15. package/dist/beta/index.d.ts.map +1 -0
  16. package/dist/beta/index.js +7 -0
  17. package/dist/beta/index.js.map +1 -0
  18. package/dist/beta/workflows/index.cjs +29 -0
  19. package/dist/beta/workflows/index.cjs.map +1 -0
  20. package/dist/beta/workflows/index.d.cts +2 -0
  21. package/dist/beta/workflows/index.d.ts +2 -0
  22. package/dist/beta/workflows/index.d.ts.map +1 -0
  23. package/dist/beta/workflows/index.js +7 -0
  24. package/dist/beta/workflows/index.js.map +1 -0
  25. package/dist/beta/workflows/task_group.cjs +165 -0
  26. package/dist/beta/workflows/task_group.cjs.map +1 -0
  27. package/dist/beta/workflows/task_group.d.cts +32 -0
  28. package/dist/beta/workflows/task_group.d.ts +32 -0
  29. package/dist/beta/workflows/task_group.d.ts.map +1 -0
  30. package/dist/beta/workflows/task_group.js +141 -0
  31. package/dist/beta/workflows/task_group.js.map +1 -0
  32. package/dist/cli.cjs +44 -46
  33. package/dist/cli.cjs.map +1 -1
  34. package/dist/cli.d.cts +3 -3
  35. package/dist/cli.d.ts +3 -3
  36. package/dist/cli.d.ts.map +1 -1
  37. package/dist/cli.js +45 -47
  38. package/dist/cli.js.map +1 -1
  39. package/dist/connection_pool.cjs +242 -0
  40. package/dist/connection_pool.cjs.map +1 -0
  41. package/dist/connection_pool.d.cts +123 -0
  42. package/dist/connection_pool.d.ts +123 -0
  43. package/dist/connection_pool.d.ts.map +1 -0
  44. package/dist/connection_pool.js +218 -0
  45. package/dist/connection_pool.js.map +1 -0
  46. package/dist/connection_pool.test.cjs +256 -0
  47. package/dist/connection_pool.test.cjs.map +1 -0
  48. package/dist/connection_pool.test.js +255 -0
  49. package/dist/connection_pool.test.js.map +1 -0
  50. package/dist/constants.cjs +30 -0
  51. package/dist/constants.cjs.map +1 -1
  52. package/dist/constants.d.cts +10 -0
  53. package/dist/constants.d.ts +10 -0
  54. package/dist/constants.d.ts.map +1 -1
  55. package/dist/constants.js +20 -0
  56. package/dist/constants.js.map +1 -1
  57. package/dist/cpu.cjs +189 -0
  58. package/dist/cpu.cjs.map +1 -0
  59. package/dist/cpu.d.cts +24 -0
  60. package/dist/cpu.d.ts +24 -0
  61. package/dist/cpu.d.ts.map +1 -0
  62. package/dist/cpu.js +152 -0
  63. package/dist/cpu.js.map +1 -0
  64. package/dist/cpu.test.cjs +227 -0
  65. package/dist/cpu.test.cjs.map +1 -0
  66. package/dist/cpu.test.js +204 -0
  67. package/dist/cpu.test.js.map +1 -0
  68. package/dist/http_server.cjs +9 -6
  69. package/dist/http_server.cjs.map +1 -1
  70. package/dist/http_server.d.cts +5 -1
  71. package/dist/http_server.d.ts +5 -1
  72. package/dist/http_server.d.ts.map +1 -1
  73. package/dist/http_server.js +9 -6
  74. package/dist/http_server.js.map +1 -1
  75. package/dist/index.cjs +24 -9
  76. package/dist/index.cjs.map +1 -1
  77. package/dist/index.d.cts +15 -11
  78. package/dist/index.d.ts +15 -11
  79. package/dist/index.d.ts.map +1 -1
  80. package/dist/index.js +18 -9
  81. package/dist/index.js.map +1 -1
  82. package/dist/inference/api_protos.cjs +70 -2
  83. package/dist/inference/api_protos.cjs.map +1 -1
  84. package/dist/inference/api_protos.d.cts +373 -32
  85. package/dist/inference/api_protos.d.ts +373 -32
  86. package/dist/inference/api_protos.d.ts.map +1 -1
  87. package/dist/inference/api_protos.js +62 -2
  88. package/dist/inference/api_protos.js.map +1 -1
  89. package/dist/inference/index.cjs +8 -0
  90. package/dist/inference/index.cjs.map +1 -1
  91. package/dist/inference/index.d.cts +3 -4
  92. package/dist/inference/index.d.ts +3 -4
  93. package/dist/inference/index.d.ts.map +1 -1
  94. package/dist/inference/index.js +18 -3
  95. package/dist/inference/index.js.map +1 -1
  96. package/dist/inference/interruption/defaults.cjs +81 -0
  97. package/dist/inference/interruption/defaults.cjs.map +1 -0
  98. package/dist/inference/interruption/defaults.d.cts +19 -0
  99. package/dist/inference/interruption/defaults.d.ts +19 -0
  100. package/dist/inference/interruption/defaults.d.ts.map +1 -0
  101. package/dist/inference/interruption/defaults.js +46 -0
  102. package/dist/inference/interruption/defaults.js.map +1 -0
  103. package/dist/inference/interruption/errors.cjs +44 -0
  104. package/dist/inference/interruption/errors.cjs.map +1 -0
  105. package/dist/inference/interruption/errors.d.cts +12 -0
  106. package/dist/inference/interruption/errors.d.ts +12 -0
  107. package/dist/inference/interruption/errors.d.ts.map +1 -0
  108. package/dist/inference/interruption/errors.js +20 -0
  109. package/dist/inference/interruption/errors.js.map +1 -0
  110. package/dist/inference/interruption/http_transport.cjs +163 -0
  111. package/dist/inference/interruption/http_transport.cjs.map +1 -0
  112. package/dist/inference/interruption/http_transport.d.cts +65 -0
  113. package/dist/inference/interruption/http_transport.d.ts +65 -0
  114. package/dist/inference/interruption/http_transport.d.ts.map +1 -0
  115. package/dist/inference/interruption/http_transport.js +137 -0
  116. package/dist/inference/interruption/http_transport.js.map +1 -0
  117. package/dist/inference/interruption/interruption_cache_entry.cjs +58 -0
  118. package/dist/inference/interruption/interruption_cache_entry.cjs.map +1 -0
  119. package/dist/inference/interruption/interruption_cache_entry.d.cts +30 -0
  120. package/dist/inference/interruption/interruption_cache_entry.d.ts +30 -0
  121. package/dist/inference/interruption/interruption_cache_entry.d.ts.map +1 -0
  122. package/dist/inference/interruption/interruption_cache_entry.js +34 -0
  123. package/dist/inference/interruption/interruption_cache_entry.js.map +1 -0
  124. package/dist/inference/interruption/interruption_detector.cjs +198 -0
  125. package/dist/inference/interruption/interruption_detector.cjs.map +1 -0
  126. package/dist/inference/interruption/interruption_detector.d.cts +59 -0
  127. package/dist/inference/interruption/interruption_detector.d.ts +59 -0
  128. package/dist/inference/interruption/interruption_detector.d.ts.map +1 -0
  129. package/dist/inference/interruption/interruption_detector.js +164 -0
  130. package/dist/inference/interruption/interruption_detector.js.map +1 -0
  131. package/dist/inference/interruption/interruption_stream.cjs +368 -0
  132. package/dist/inference/interruption/interruption_stream.cjs.map +1 -0
  133. package/dist/inference/interruption/interruption_stream.d.cts +46 -0
  134. package/dist/inference/interruption/interruption_stream.d.ts +46 -0
  135. package/dist/inference/interruption/interruption_stream.d.ts.map +1 -0
  136. package/dist/inference/interruption/interruption_stream.js +344 -0
  137. package/dist/inference/interruption/interruption_stream.js.map +1 -0
  138. package/dist/inference/interruption/types.cjs +17 -0
  139. package/dist/inference/interruption/types.cjs.map +1 -0
  140. package/dist/inference/interruption/types.d.cts +66 -0
  141. package/dist/inference/interruption/types.d.ts +66 -0
  142. package/dist/inference/interruption/types.d.ts.map +1 -0
  143. package/dist/inference/interruption/types.js +1 -0
  144. package/dist/inference/interruption/types.js.map +1 -0
  145. package/dist/inference/interruption/utils.cjs +130 -0
  146. package/dist/inference/interruption/utils.cjs.map +1 -0
  147. package/dist/inference/interruption/utils.d.cts +41 -0
  148. package/dist/inference/interruption/utils.d.ts +41 -0
  149. package/dist/inference/interruption/utils.d.ts.map +1 -0
  150. package/dist/inference/interruption/utils.js +105 -0
  151. package/dist/inference/interruption/utils.js.map +1 -0
  152. package/dist/inference/interruption/utils.test.cjs +105 -0
  153. package/dist/inference/interruption/utils.test.cjs.map +1 -0
  154. package/dist/inference/interruption/utils.test.js +104 -0
  155. package/dist/inference/interruption/utils.test.js.map +1 -0
  156. package/dist/inference/interruption/ws_transport.cjs +347 -0
  157. package/dist/inference/interruption/ws_transport.cjs.map +1 -0
  158. package/dist/inference/interruption/ws_transport.d.cts +33 -0
  159. package/dist/inference/interruption/ws_transport.d.ts +33 -0
  160. package/dist/inference/interruption/ws_transport.d.ts.map +1 -0
  161. package/dist/inference/interruption/ws_transport.js +313 -0
  162. package/dist/inference/interruption/ws_transport.js.map +1 -0
  163. package/dist/inference/llm.cjs +106 -66
  164. package/dist/inference/llm.cjs.map +1 -1
  165. package/dist/inference/llm.d.cts +65 -43
  166. package/dist/inference/llm.d.ts +65 -43
  167. package/dist/inference/llm.d.ts.map +1 -1
  168. package/dist/inference/llm.js +100 -66
  169. package/dist/inference/llm.js.map +1 -1
  170. package/dist/inference/stt.cjs +319 -170
  171. package/dist/inference/stt.cjs.map +1 -1
  172. package/dist/inference/stt.d.cts +64 -15
  173. package/dist/inference/stt.d.ts +64 -15
  174. package/dist/inference/stt.d.ts.map +1 -1
  175. package/dist/inference/stt.js +319 -170
  176. package/dist/inference/stt.js.map +1 -1
  177. package/dist/inference/stt.test.cjs +218 -0
  178. package/dist/inference/stt.test.cjs.map +1 -0
  179. package/dist/inference/stt.test.js +217 -0
  180. package/dist/inference/stt.test.js.map +1 -0
  181. package/dist/inference/tts.cjs +249 -71
  182. package/dist/inference/tts.cjs.map +1 -1
  183. package/dist/inference/tts.d.cts +94 -17
  184. package/dist/inference/tts.d.ts +94 -17
  185. package/dist/inference/tts.d.ts.map +1 -1
  186. package/dist/inference/tts.js +249 -77
  187. package/dist/inference/tts.js.map +1 -1
  188. package/dist/inference/tts.test.cjs +305 -0
  189. package/dist/inference/tts.test.cjs.map +1 -0
  190. package/dist/inference/tts.test.js +304 -0
  191. package/dist/inference/tts.test.js.map +1 -0
  192. package/dist/inference/utils.cjs +26 -7
  193. package/dist/inference/utils.cjs.map +1 -1
  194. package/dist/inference/utils.d.cts +14 -1
  195. package/dist/inference/utils.d.ts +14 -1
  196. package/dist/inference/utils.d.ts.map +1 -1
  197. package/dist/inference/utils.js +18 -2
  198. package/dist/inference/utils.js.map +1 -1
  199. package/dist/ipc/inference_proc_executor.cjs +6 -3
  200. package/dist/ipc/inference_proc_executor.cjs.map +1 -1
  201. package/dist/ipc/inference_proc_executor.d.ts.map +1 -1
  202. package/dist/ipc/inference_proc_executor.js +6 -3
  203. package/dist/ipc/inference_proc_executor.js.map +1 -1
  204. package/dist/ipc/inference_proc_lazy_main.cjs +13 -1
  205. package/dist/ipc/inference_proc_lazy_main.cjs.map +1 -1
  206. package/dist/ipc/inference_proc_lazy_main.js +13 -1
  207. package/dist/ipc/inference_proc_lazy_main.js.map +1 -1
  208. package/dist/ipc/job_proc_executor.cjs +6 -1
  209. package/dist/ipc/job_proc_executor.cjs.map +1 -1
  210. package/dist/ipc/job_proc_executor.d.ts.map +1 -1
  211. package/dist/ipc/job_proc_executor.js +6 -1
  212. package/dist/ipc/job_proc_executor.js.map +1 -1
  213. package/dist/ipc/job_proc_lazy_main.cjs +89 -17
  214. package/dist/ipc/job_proc_lazy_main.cjs.map +1 -1
  215. package/dist/ipc/job_proc_lazy_main.js +68 -18
  216. package/dist/ipc/job_proc_lazy_main.js.map +1 -1
  217. package/dist/ipc/supervised_proc.cjs +34 -8
  218. package/dist/ipc/supervised_proc.cjs.map +1 -1
  219. package/dist/ipc/supervised_proc.d.cts +8 -0
  220. package/dist/ipc/supervised_proc.d.ts +8 -0
  221. package/dist/ipc/supervised_proc.d.ts.map +1 -1
  222. package/dist/ipc/supervised_proc.js +34 -8
  223. package/dist/ipc/supervised_proc.js.map +1 -1
  224. package/dist/ipc/supervised_proc.test.cjs +145 -0
  225. package/dist/ipc/supervised_proc.test.cjs.map +1 -0
  226. package/dist/ipc/supervised_proc.test.js +122 -0
  227. package/dist/ipc/supervised_proc.test.js.map +1 -0
  228. package/dist/job.cjs +109 -1
  229. package/dist/job.cjs.map +1 -1
  230. package/dist/job.d.cts +14 -0
  231. package/dist/job.d.ts +14 -0
  232. package/dist/job.d.ts.map +1 -1
  233. package/dist/job.js +99 -1
  234. package/dist/job.js.map +1 -1
  235. package/dist/language.cjs +394 -0
  236. package/dist/language.cjs.map +1 -0
  237. package/dist/language.d.cts +15 -0
  238. package/dist/language.d.ts +15 -0
  239. package/dist/language.d.ts.map +1 -0
  240. package/dist/language.js +363 -0
  241. package/dist/language.js.map +1 -0
  242. package/dist/language.test.cjs +43 -0
  243. package/dist/language.test.cjs.map +1 -0
  244. package/dist/language.test.js +49 -0
  245. package/dist/language.test.js.map +1 -0
  246. package/dist/llm/chat_context.cjs +345 -3
  247. package/dist/llm/chat_context.cjs.map +1 -1
  248. package/dist/llm/chat_context.d.cts +86 -2
  249. package/dist/llm/chat_context.d.ts +86 -2
  250. package/dist/llm/chat_context.d.ts.map +1 -1
  251. package/dist/llm/chat_context.js +344 -3
  252. package/dist/llm/chat_context.js.map +1 -1
  253. package/dist/llm/chat_context.test.cjs +692 -0
  254. package/dist/llm/chat_context.test.cjs.map +1 -1
  255. package/dist/llm/chat_context.test.js +692 -0
  256. package/dist/llm/chat_context.test.js.map +1 -1
  257. package/dist/llm/fallback_adapter.cjs +280 -0
  258. package/dist/llm/fallback_adapter.cjs.map +1 -0
  259. package/dist/llm/fallback_adapter.d.cts +73 -0
  260. package/dist/llm/fallback_adapter.d.ts +73 -0
  261. package/dist/llm/fallback_adapter.d.ts.map +1 -0
  262. package/dist/llm/fallback_adapter.js +256 -0
  263. package/dist/llm/fallback_adapter.js.map +1 -0
  264. package/dist/llm/fallback_adapter.test.cjs +176 -0
  265. package/dist/llm/fallback_adapter.test.cjs.map +1 -0
  266. package/dist/llm/fallback_adapter.test.js +175 -0
  267. package/dist/llm/fallback_adapter.test.js.map +1 -0
  268. package/dist/llm/index.cjs +11 -0
  269. package/dist/llm/index.cjs.map +1 -1
  270. package/dist/llm/index.d.cts +4 -3
  271. package/dist/llm/index.d.ts +4 -3
  272. package/dist/llm/index.d.ts.map +1 -1
  273. package/dist/llm/index.js +13 -1
  274. package/dist/llm/index.js.map +1 -1
  275. package/dist/llm/llm.cjs +65 -11
  276. package/dist/llm/llm.cjs.map +1 -1
  277. package/dist/llm/llm.d.cts +13 -2
  278. package/dist/llm/llm.d.ts +13 -2
  279. package/dist/llm/llm.d.ts.map +1 -1
  280. package/dist/llm/llm.js +65 -11
  281. package/dist/llm/llm.js.map +1 -1
  282. package/dist/llm/provider_format/google.cjs +6 -2
  283. package/dist/llm/provider_format/google.cjs.map +1 -1
  284. package/dist/llm/provider_format/google.d.cts +1 -1
  285. package/dist/llm/provider_format/google.d.ts +1 -1
  286. package/dist/llm/provider_format/google.d.ts.map +1 -1
  287. package/dist/llm/provider_format/google.js +6 -2
  288. package/dist/llm/provider_format/google.js.map +1 -1
  289. package/dist/llm/provider_format/google.test.cjs +48 -0
  290. package/dist/llm/provider_format/google.test.cjs.map +1 -1
  291. package/dist/llm/provider_format/google.test.js +54 -1
  292. package/dist/llm/provider_format/google.test.js.map +1 -1
  293. package/dist/llm/provider_format/index.cjs +2 -0
  294. package/dist/llm/provider_format/index.cjs.map +1 -1
  295. package/dist/llm/provider_format/index.d.cts +2 -2
  296. package/dist/llm/provider_format/index.d.ts +2 -2
  297. package/dist/llm/provider_format/index.d.ts.map +1 -1
  298. package/dist/llm/provider_format/index.js +6 -1
  299. package/dist/llm/provider_format/index.js.map +1 -1
  300. package/dist/llm/provider_format/openai.cjs +126 -24
  301. package/dist/llm/provider_format/openai.cjs.map +1 -1
  302. package/dist/llm/provider_format/openai.d.cts +1 -0
  303. package/dist/llm/provider_format/openai.d.ts +1 -0
  304. package/dist/llm/provider_format/openai.d.ts.map +1 -1
  305. package/dist/llm/provider_format/openai.js +124 -23
  306. package/dist/llm/provider_format/openai.js.map +1 -1
  307. package/dist/llm/provider_format/openai.test.cjs +393 -0
  308. package/dist/llm/provider_format/openai.test.cjs.map +1 -1
  309. package/dist/llm/provider_format/openai.test.js +400 -2
  310. package/dist/llm/provider_format/openai.test.js.map +1 -1
  311. package/dist/llm/provider_format/utils.cjs +5 -4
  312. package/dist/llm/provider_format/utils.cjs.map +1 -1
  313. package/dist/llm/provider_format/utils.d.ts.map +1 -1
  314. package/dist/llm/provider_format/utils.js +5 -4
  315. package/dist/llm/provider_format/utils.js.map +1 -1
  316. package/dist/llm/realtime.cjs +3 -0
  317. package/dist/llm/realtime.cjs.map +1 -1
  318. package/dist/llm/realtime.d.cts +15 -1
  319. package/dist/llm/realtime.d.ts +15 -1
  320. package/dist/llm/realtime.d.ts.map +1 -1
  321. package/dist/llm/realtime.js +3 -0
  322. package/dist/llm/realtime.js.map +1 -1
  323. package/dist/llm/remote_chat_context.cjs.map +1 -1
  324. package/dist/llm/remote_chat_context.d.cts +2 -0
  325. package/dist/llm/remote_chat_context.d.ts +2 -0
  326. package/dist/llm/remote_chat_context.d.ts.map +1 -1
  327. package/dist/llm/remote_chat_context.js.map +1 -1
  328. package/dist/llm/tool_context.cjs +50 -2
  329. package/dist/llm/tool_context.cjs.map +1 -1
  330. package/dist/llm/tool_context.d.cts +47 -11
  331. package/dist/llm/tool_context.d.ts +47 -11
  332. package/dist/llm/tool_context.d.ts.map +1 -1
  333. package/dist/llm/tool_context.js +48 -3
  334. package/dist/llm/tool_context.js.map +1 -1
  335. package/dist/llm/tool_context.test.cjs +197 -0
  336. package/dist/llm/tool_context.test.cjs.map +1 -1
  337. package/dist/llm/tool_context.test.js +175 -0
  338. package/dist/llm/tool_context.test.js.map +1 -1
  339. package/dist/llm/utils.cjs +107 -12
  340. package/dist/llm/utils.cjs.map +1 -1
  341. package/dist/llm/utils.d.cts +10 -3
  342. package/dist/llm/utils.d.ts +10 -3
  343. package/dist/llm/utils.d.ts.map +1 -1
  344. package/dist/llm/utils.js +106 -12
  345. package/dist/llm/utils.js.map +1 -1
  346. package/dist/llm/utils.test.cjs +90 -0
  347. package/dist/llm/utils.test.cjs.map +1 -1
  348. package/dist/llm/utils.test.js +98 -2
  349. package/dist/llm/utils.test.js.map +1 -1
  350. package/dist/llm/zod-utils.cjs +102 -0
  351. package/dist/llm/zod-utils.cjs.map +1 -0
  352. package/dist/llm/zod-utils.d.cts +65 -0
  353. package/dist/llm/zod-utils.d.ts +65 -0
  354. package/dist/llm/zod-utils.d.ts.map +1 -0
  355. package/dist/llm/zod-utils.js +64 -0
  356. package/dist/llm/zod-utils.js.map +1 -0
  357. package/dist/llm/zod-utils.test.cjs +472 -0
  358. package/dist/llm/zod-utils.test.cjs.map +1 -0
  359. package/dist/llm/zod-utils.test.js +455 -0
  360. package/dist/llm/zod-utils.test.js.map +1 -0
  361. package/dist/log.cjs +45 -14
  362. package/dist/log.cjs.map +1 -1
  363. package/dist/log.d.cts +8 -1
  364. package/dist/log.d.ts +8 -1
  365. package/dist/log.d.ts.map +1 -1
  366. package/dist/log.js +45 -15
  367. package/dist/log.js.map +1 -1
  368. package/dist/metrics/base.cjs.map +1 -1
  369. package/dist/metrics/base.d.cts +75 -19
  370. package/dist/metrics/base.d.ts +75 -19
  371. package/dist/metrics/base.d.ts.map +1 -1
  372. package/dist/metrics/index.cjs +5 -0
  373. package/dist/metrics/index.cjs.map +1 -1
  374. package/dist/metrics/index.d.cts +2 -1
  375. package/dist/metrics/index.d.ts +2 -1
  376. package/dist/metrics/index.d.ts.map +1 -1
  377. package/dist/metrics/index.js +6 -0
  378. package/dist/metrics/index.js.map +1 -1
  379. package/dist/metrics/model_usage.cjs +189 -0
  380. package/dist/metrics/model_usage.cjs.map +1 -0
  381. package/dist/metrics/model_usage.d.cts +92 -0
  382. package/dist/metrics/model_usage.d.ts +92 -0
  383. package/dist/metrics/model_usage.d.ts.map +1 -0
  384. package/dist/metrics/model_usage.js +164 -0
  385. package/dist/metrics/model_usage.js.map +1 -0
  386. package/dist/metrics/model_usage.test.cjs +474 -0
  387. package/dist/metrics/model_usage.test.cjs.map +1 -0
  388. package/dist/metrics/model_usage.test.js +476 -0
  389. package/dist/metrics/model_usage.test.js.map +1 -0
  390. package/dist/metrics/usage_collector.cjs +5 -2
  391. package/dist/metrics/usage_collector.cjs.map +1 -1
  392. package/dist/metrics/usage_collector.d.cts +10 -1
  393. package/dist/metrics/usage_collector.d.ts +10 -1
  394. package/dist/metrics/usage_collector.d.ts.map +1 -1
  395. package/dist/metrics/usage_collector.js +5 -2
  396. package/dist/metrics/usage_collector.js.map +1 -1
  397. package/dist/metrics/utils.cjs +23 -7
  398. package/dist/metrics/utils.cjs.map +1 -1
  399. package/dist/metrics/utils.d.ts.map +1 -1
  400. package/dist/metrics/utils.js +23 -7
  401. package/dist/metrics/utils.js.map +1 -1
  402. package/dist/stream/deferred_stream.cjs +31 -10
  403. package/dist/stream/deferred_stream.cjs.map +1 -1
  404. package/dist/stream/deferred_stream.d.cts +6 -1
  405. package/dist/stream/deferred_stream.d.ts +6 -1
  406. package/dist/stream/deferred_stream.d.ts.map +1 -1
  407. package/dist/stream/deferred_stream.js +31 -10
  408. package/dist/stream/deferred_stream.js.map +1 -1
  409. package/dist/stream/deferred_stream.test.cjs +2 -2
  410. package/dist/stream/deferred_stream.test.cjs.map +1 -1
  411. package/dist/stream/deferred_stream.test.js +2 -2
  412. package/dist/stream/deferred_stream.test.js.map +1 -1
  413. package/dist/stream/index.cjs +3 -0
  414. package/dist/stream/index.cjs.map +1 -1
  415. package/dist/stream/index.d.cts +1 -0
  416. package/dist/stream/index.d.ts +1 -0
  417. package/dist/stream/index.d.ts.map +1 -1
  418. package/dist/stream/index.js +2 -0
  419. package/dist/stream/index.js.map +1 -1
  420. package/dist/stream/multi_input_stream.cjs +139 -0
  421. package/dist/stream/multi_input_stream.cjs.map +1 -0
  422. package/dist/stream/multi_input_stream.d.cts +55 -0
  423. package/dist/stream/multi_input_stream.d.ts +55 -0
  424. package/dist/stream/multi_input_stream.d.ts.map +1 -0
  425. package/dist/stream/multi_input_stream.js +115 -0
  426. package/dist/stream/multi_input_stream.js.map +1 -0
  427. package/dist/stream/multi_input_stream.test.cjs +344 -0
  428. package/dist/stream/multi_input_stream.test.cjs.map +1 -0
  429. package/dist/stream/multi_input_stream.test.js +343 -0
  430. package/dist/stream/multi_input_stream.test.js.map +1 -0
  431. package/dist/stream/stream_channel.cjs +39 -1
  432. package/dist/stream/stream_channel.cjs.map +1 -1
  433. package/dist/stream/stream_channel.d.cts +5 -2
  434. package/dist/stream/stream_channel.d.ts +5 -2
  435. package/dist/stream/stream_channel.d.ts.map +1 -1
  436. package/dist/stream/stream_channel.js +39 -1
  437. package/dist/stream/stream_channel.js.map +1 -1
  438. package/dist/stream/stream_channel.test.cjs +27 -0
  439. package/dist/stream/stream_channel.test.cjs.map +1 -1
  440. package/dist/stream/stream_channel.test.js +27 -0
  441. package/dist/stream/stream_channel.test.js.map +1 -1
  442. package/dist/stt/stream_adapter.cjs +24 -9
  443. package/dist/stt/stream_adapter.cjs.map +1 -1
  444. package/dist/stt/stream_adapter.d.cts +7 -3
  445. package/dist/stt/stream_adapter.d.ts +7 -3
  446. package/dist/stt/stream_adapter.d.ts.map +1 -1
  447. package/dist/stt/stream_adapter.js +24 -9
  448. package/dist/stt/stream_adapter.js.map +1 -1
  449. package/dist/stt/stt.cjs +94 -19
  450. package/dist/stt/stt.cjs.map +1 -1
  451. package/dist/stt/stt.d.cts +68 -5
  452. package/dist/stt/stt.d.ts +68 -5
  453. package/dist/stt/stt.d.ts.map +1 -1
  454. package/dist/stt/stt.js +96 -21
  455. package/dist/stt/stt.js.map +1 -1
  456. package/dist/telemetry/index.cjs +72 -0
  457. package/dist/telemetry/index.cjs.map +1 -0
  458. package/dist/telemetry/index.d.cts +7 -0
  459. package/dist/telemetry/index.d.ts +7 -0
  460. package/dist/telemetry/index.d.ts.map +1 -0
  461. package/dist/telemetry/index.js +37 -0
  462. package/dist/telemetry/index.js.map +1 -0
  463. package/dist/telemetry/logging.cjs +65 -0
  464. package/dist/telemetry/logging.cjs.map +1 -0
  465. package/dist/telemetry/logging.d.cts +21 -0
  466. package/dist/telemetry/logging.d.ts +21 -0
  467. package/dist/telemetry/logging.d.ts.map +1 -0
  468. package/dist/telemetry/logging.js +40 -0
  469. package/dist/telemetry/logging.js.map +1 -0
  470. package/dist/telemetry/otel_http_exporter.cjs +166 -0
  471. package/dist/telemetry/otel_http_exporter.cjs.map +1 -0
  472. package/dist/telemetry/otel_http_exporter.d.cts +63 -0
  473. package/dist/telemetry/otel_http_exporter.d.ts +63 -0
  474. package/dist/telemetry/otel_http_exporter.d.ts.map +1 -0
  475. package/dist/telemetry/otel_http_exporter.js +142 -0
  476. package/dist/telemetry/otel_http_exporter.js.map +1 -0
  477. package/dist/telemetry/pino_otel_transport.cjs +217 -0
  478. package/dist/telemetry/pino_otel_transport.cjs.map +1 -0
  479. package/dist/telemetry/pino_otel_transport.d.cts +58 -0
  480. package/dist/telemetry/pino_otel_transport.d.ts +58 -0
  481. package/dist/telemetry/pino_otel_transport.d.ts.map +1 -0
  482. package/dist/telemetry/pino_otel_transport.js +189 -0
  483. package/dist/telemetry/pino_otel_transport.js.map +1 -0
  484. package/dist/telemetry/trace_types.cjs +233 -0
  485. package/dist/telemetry/trace_types.cjs.map +1 -0
  486. package/dist/telemetry/trace_types.d.cts +74 -0
  487. package/dist/telemetry/trace_types.d.ts +74 -0
  488. package/dist/telemetry/trace_types.d.ts.map +1 -0
  489. package/dist/telemetry/trace_types.js +141 -0
  490. package/dist/telemetry/trace_types.js.map +1 -0
  491. package/dist/telemetry/traces.cjs +484 -0
  492. package/dist/telemetry/traces.cjs.map +1 -0
  493. package/dist/telemetry/traces.d.cts +116 -0
  494. package/dist/telemetry/traces.d.ts +116 -0
  495. package/dist/telemetry/traces.d.ts.map +1 -0
  496. package/dist/telemetry/traces.js +449 -0
  497. package/dist/telemetry/traces.js.map +1 -0
  498. package/dist/telemetry/utils.cjs +86 -0
  499. package/dist/telemetry/utils.cjs.map +1 -0
  500. package/dist/telemetry/utils.d.cts +5 -0
  501. package/dist/telemetry/utils.d.ts +5 -0
  502. package/dist/telemetry/utils.d.ts.map +1 -0
  503. package/dist/telemetry/utils.js +51 -0
  504. package/dist/telemetry/utils.js.map +1 -0
  505. package/dist/tokenize/basic/sentence.cjs +3 -3
  506. package/dist/tokenize/basic/sentence.cjs.map +1 -1
  507. package/dist/tokenize/basic/sentence.js +3 -3
  508. package/dist/tokenize/basic/sentence.js.map +1 -1
  509. package/dist/tokenize/tokenizer.test.cjs +3 -1
  510. package/dist/tokenize/tokenizer.test.cjs.map +1 -1
  511. package/dist/tokenize/tokenizer.test.js +3 -1
  512. package/dist/tokenize/tokenizer.test.js.map +1 -1
  513. package/dist/transcription.cjs.map +1 -1
  514. package/dist/transcription.d.cts +6 -0
  515. package/dist/transcription.d.ts +6 -0
  516. package/dist/transcription.d.ts.map +1 -1
  517. package/dist/transcription.js.map +1 -1
  518. package/dist/tts/fallback_adapter.cjs +472 -0
  519. package/dist/tts/fallback_adapter.cjs.map +1 -0
  520. package/dist/tts/fallback_adapter.d.cts +110 -0
  521. package/dist/tts/fallback_adapter.d.ts +110 -0
  522. package/dist/tts/fallback_adapter.d.ts.map +1 -0
  523. package/dist/tts/fallback_adapter.js +448 -0
  524. package/dist/tts/fallback_adapter.js.map +1 -0
  525. package/dist/tts/index.cjs +3 -0
  526. package/dist/tts/index.cjs.map +1 -1
  527. package/dist/tts/index.d.cts +1 -0
  528. package/dist/tts/index.d.ts +1 -0
  529. package/dist/tts/index.d.ts.map +1 -1
  530. package/dist/tts/index.js +2 -0
  531. package/dist/tts/index.js.map +1 -1
  532. package/dist/tts/stream_adapter.cjs +25 -8
  533. package/dist/tts/stream_adapter.cjs.map +1 -1
  534. package/dist/tts/stream_adapter.d.cts +6 -3
  535. package/dist/tts/stream_adapter.d.ts +6 -3
  536. package/dist/tts/stream_adapter.d.ts.map +1 -1
  537. package/dist/tts/stream_adapter.js +25 -8
  538. package/dist/tts/stream_adapter.js.map +1 -1
  539. package/dist/tts/tts.cjs +189 -57
  540. package/dist/tts/tts.cjs.map +1 -1
  541. package/dist/tts/tts.d.cts +58 -6
  542. package/dist/tts/tts.d.ts +58 -6
  543. package/dist/tts/tts.d.ts.map +1 -1
  544. package/dist/tts/tts.js +191 -59
  545. package/dist/tts/tts.js.map +1 -1
  546. package/dist/typed_promise.cjs +48 -0
  547. package/dist/typed_promise.cjs.map +1 -0
  548. package/dist/typed_promise.d.cts +24 -0
  549. package/dist/typed_promise.d.ts +24 -0
  550. package/dist/typed_promise.d.ts.map +1 -0
  551. package/dist/typed_promise.js +28 -0
  552. package/dist/typed_promise.js.map +1 -0
  553. package/dist/types.cjs +24 -32
  554. package/dist/types.cjs.map +1 -1
  555. package/dist/types.d.cts +45 -10
  556. package/dist/types.d.ts +45 -10
  557. package/dist/types.d.ts.map +1 -1
  558. package/dist/types.js +20 -30
  559. package/dist/types.js.map +1 -1
  560. package/dist/utils.cjs +124 -28
  561. package/dist/utils.cjs.map +1 -1
  562. package/dist/utils.d.cts +41 -1
  563. package/dist/utils.d.ts +41 -1
  564. package/dist/utils.d.ts.map +1 -1
  565. package/dist/utils.js +119 -27
  566. package/dist/utils.js.map +1 -1
  567. package/dist/utils.test.cjs +73 -1
  568. package/dist/utils.test.cjs.map +1 -1
  569. package/dist/utils.test.js +74 -10
  570. package/dist/utils.test.js.map +1 -1
  571. package/dist/vad.cjs +35 -15
  572. package/dist/vad.cjs.map +1 -1
  573. package/dist/vad.d.cts +15 -5
  574. package/dist/vad.d.ts +15 -5
  575. package/dist/vad.d.ts.map +1 -1
  576. package/dist/vad.js +35 -15
  577. package/dist/vad.js.map +1 -1
  578. package/dist/version.cjs +1 -1
  579. package/dist/version.cjs.map +1 -1
  580. package/dist/version.d.cts +1 -1
  581. package/dist/version.d.ts +1 -1
  582. package/dist/version.d.ts.map +1 -1
  583. package/dist/version.js +1 -1
  584. package/dist/version.js.map +1 -1
  585. package/dist/voice/agent.cjs +258 -35
  586. package/dist/voice/agent.cjs.map +1 -1
  587. package/dist/voice/agent.d.cts +54 -13
  588. package/dist/voice/agent.d.ts +54 -13
  589. package/dist/voice/agent.d.ts.map +1 -1
  590. package/dist/voice/agent.js +254 -34
  591. package/dist/voice/agent.js.map +1 -1
  592. package/dist/voice/agent.test.cjs +314 -0
  593. package/dist/voice/agent.test.cjs.map +1 -1
  594. package/dist/voice/agent.test.js +316 -2
  595. package/dist/voice/agent.test.js.map +1 -1
  596. package/dist/voice/agent_activity.cjs +1116 -385
  597. package/dist/voice/agent_activity.cjs.map +1 -1
  598. package/dist/voice/agent_activity.d.cts +72 -11
  599. package/dist/voice/agent_activity.d.ts +72 -11
  600. package/dist/voice/agent_activity.d.ts.map +1 -1
  601. package/dist/voice/agent_activity.js +1119 -383
  602. package/dist/voice/agent_activity.js.map +1 -1
  603. package/dist/voice/agent_activity.test.cjs +135 -0
  604. package/dist/voice/agent_activity.test.cjs.map +1 -0
  605. package/dist/voice/agent_activity.test.js +134 -0
  606. package/dist/voice/agent_activity.test.js.map +1 -0
  607. package/dist/voice/agent_session.cjs +550 -90
  608. package/dist/voice/agent_session.cjs.map +1 -1
  609. package/dist/voice/agent_session.d.cts +185 -25
  610. package/dist/voice/agent_session.d.ts +185 -25
  611. package/dist/voice/agent_session.d.ts.map +1 -1
  612. package/dist/voice/agent_session.js +556 -91
  613. package/dist/voice/agent_session.js.map +1 -1
  614. package/dist/voice/audio_recognition.cjs +605 -46
  615. package/dist/voice/audio_recognition.cjs.map +1 -1
  616. package/dist/voice/audio_recognition.d.cts +96 -4
  617. package/dist/voice/audio_recognition.d.ts +96 -4
  618. package/dist/voice/audio_recognition.d.ts.map +1 -1
  619. package/dist/voice/audio_recognition.js +611 -47
  620. package/dist/voice/audio_recognition.js.map +1 -1
  621. package/dist/voice/audio_recognition_span.test.cjs +295 -0
  622. package/dist/voice/audio_recognition_span.test.cjs.map +1 -0
  623. package/dist/voice/audio_recognition_span.test.js +299 -0
  624. package/dist/voice/audio_recognition_span.test.js.map +1 -0
  625. package/dist/voice/avatar/datastream_io.cjs +7 -1
  626. package/dist/voice/avatar/datastream_io.cjs.map +1 -1
  627. package/dist/voice/avatar/datastream_io.d.cts +1 -0
  628. package/dist/voice/avatar/datastream_io.d.ts +1 -0
  629. package/dist/voice/avatar/datastream_io.d.ts.map +1 -1
  630. package/dist/voice/avatar/datastream_io.js +7 -1
  631. package/dist/voice/avatar/datastream_io.js.map +1 -1
  632. package/dist/voice/background_audio.cjs +367 -0
  633. package/dist/voice/background_audio.cjs.map +1 -0
  634. package/dist/voice/background_audio.d.cts +123 -0
  635. package/dist/voice/background_audio.d.ts +123 -0
  636. package/dist/voice/background_audio.d.ts.map +1 -0
  637. package/dist/voice/background_audio.js +343 -0
  638. package/dist/voice/background_audio.js.map +1 -0
  639. package/dist/voice/events.cjs +3 -0
  640. package/dist/voice/events.cjs.map +1 -1
  641. package/dist/voice/events.d.cts +16 -9
  642. package/dist/voice/events.d.ts +16 -9
  643. package/dist/voice/events.d.ts.map +1 -1
  644. package/dist/voice/events.js +3 -0
  645. package/dist/voice/events.js.map +1 -1
  646. package/dist/voice/generation.cjs +205 -41
  647. package/dist/voice/generation.cjs.map +1 -1
  648. package/dist/voice/generation.d.cts +21 -5
  649. package/dist/voice/generation.d.ts +21 -5
  650. package/dist/voice/generation.d.ts.map +1 -1
  651. package/dist/voice/generation.js +215 -43
  652. package/dist/voice/generation.js.map +1 -1
  653. package/dist/voice/generation_tools.test.cjs +236 -0
  654. package/dist/voice/generation_tools.test.cjs.map +1 -0
  655. package/dist/voice/generation_tools.test.js +235 -0
  656. package/dist/voice/generation_tools.test.js.map +1 -0
  657. package/dist/voice/index.cjs +33 -2
  658. package/dist/voice/index.cjs.map +1 -1
  659. package/dist/voice/index.d.cts +8 -2
  660. package/dist/voice/index.d.ts +8 -2
  661. package/dist/voice/index.d.ts.map +1 -1
  662. package/dist/voice/index.js +19 -2
  663. package/dist/voice/index.js.map +1 -1
  664. package/dist/voice/interruption_detection.test.cjs +114 -0
  665. package/dist/voice/interruption_detection.test.cjs.map +1 -0
  666. package/dist/voice/interruption_detection.test.js +113 -0
  667. package/dist/voice/interruption_detection.test.js.map +1 -0
  668. package/dist/voice/io.cjs +66 -6
  669. package/dist/voice/io.cjs.map +1 -1
  670. package/dist/voice/io.d.cts +67 -7
  671. package/dist/voice/io.d.ts +67 -7
  672. package/dist/voice/io.d.ts.map +1 -1
  673. package/dist/voice/io.js +62 -5
  674. package/dist/voice/io.js.map +1 -1
  675. package/dist/voice/recorder_io/index.cjs +23 -0
  676. package/dist/voice/recorder_io/index.cjs.map +1 -0
  677. package/dist/voice/recorder_io/index.d.cts +2 -0
  678. package/dist/voice/recorder_io/index.d.ts +2 -0
  679. package/dist/voice/recorder_io/index.d.ts.map +1 -0
  680. package/dist/voice/recorder_io/index.js +2 -0
  681. package/dist/voice/recorder_io/index.js.map +1 -0
  682. package/dist/voice/recorder_io/recorder_io.cjs +607 -0
  683. package/dist/voice/recorder_io/recorder_io.cjs.map +1 -0
  684. package/dist/voice/recorder_io/recorder_io.d.cts +106 -0
  685. package/dist/voice/recorder_io/recorder_io.d.ts +106 -0
  686. package/dist/voice/recorder_io/recorder_io.d.ts.map +1 -0
  687. package/dist/voice/recorder_io/recorder_io.js +573 -0
  688. package/dist/voice/recorder_io/recorder_io.js.map +1 -0
  689. package/dist/voice/remote_session.cjs +922 -0
  690. package/dist/voice/remote_session.cjs.map +1 -0
  691. package/dist/voice/remote_session.d.cts +108 -0
  692. package/dist/voice/remote_session.d.ts +108 -0
  693. package/dist/voice/remote_session.d.ts.map +1 -0
  694. package/dist/voice/remote_session.js +887 -0
  695. package/dist/voice/remote_session.js.map +1 -0
  696. package/dist/voice/report.cjs +88 -0
  697. package/dist/voice/report.cjs.map +1 -0
  698. package/dist/voice/report.d.cts +49 -0
  699. package/dist/voice/report.d.ts +49 -0
  700. package/dist/voice/report.d.ts.map +1 -0
  701. package/dist/voice/report.js +63 -0
  702. package/dist/voice/report.js.map +1 -0
  703. package/dist/voice/report.test.cjs +121 -0
  704. package/dist/voice/report.test.cjs.map +1 -0
  705. package/dist/voice/report.test.js +120 -0
  706. package/dist/voice/report.test.js.map +1 -0
  707. package/dist/voice/room_io/_input.cjs +40 -7
  708. package/dist/voice/room_io/_input.cjs.map +1 -1
  709. package/dist/voice/room_io/_input.d.cts +5 -2
  710. package/dist/voice/room_io/_input.d.ts +5 -2
  711. package/dist/voice/room_io/_input.d.ts.map +1 -1
  712. package/dist/voice/room_io/_input.js +41 -8
  713. package/dist/voice/room_io/_input.js.map +1 -1
  714. package/dist/voice/room_io/_output.cjs +19 -11
  715. package/dist/voice/room_io/_output.cjs.map +1 -1
  716. package/dist/voice/room_io/_output.d.cts +7 -4
  717. package/dist/voice/room_io/_output.d.ts +7 -4
  718. package/dist/voice/room_io/_output.d.ts.map +1 -1
  719. package/dist/voice/room_io/_output.js +20 -12
  720. package/dist/voice/room_io/_output.js.map +1 -1
  721. package/dist/voice/room_io/room_io.cjs +33 -6
  722. package/dist/voice/room_io/room_io.cjs.map +1 -1
  723. package/dist/voice/room_io/room_io.d.cts +29 -9
  724. package/dist/voice/room_io/room_io.d.ts +29 -9
  725. package/dist/voice/room_io/room_io.d.ts.map +1 -1
  726. package/dist/voice/room_io/room_io.js +33 -7
  727. package/dist/voice/room_io/room_io.js.map +1 -1
  728. package/dist/voice/speech_handle.cjs +22 -4
  729. package/dist/voice/speech_handle.cjs.map +1 -1
  730. package/dist/voice/speech_handle.d.cts +17 -2
  731. package/dist/voice/speech_handle.d.ts +17 -2
  732. package/dist/voice/speech_handle.d.ts.map +1 -1
  733. package/dist/voice/speech_handle.js +21 -4
  734. package/dist/voice/speech_handle.js.map +1 -1
  735. package/dist/voice/testing/fake_llm.cjs +127 -0
  736. package/dist/voice/testing/fake_llm.cjs.map +1 -0
  737. package/dist/voice/testing/fake_llm.d.cts +30 -0
  738. package/dist/voice/testing/fake_llm.d.ts +30 -0
  739. package/dist/voice/testing/fake_llm.d.ts.map +1 -0
  740. package/dist/voice/testing/fake_llm.js +103 -0
  741. package/dist/voice/testing/fake_llm.js.map +1 -0
  742. package/dist/voice/testing/index.cjs +57 -0
  743. package/dist/voice/testing/index.cjs.map +1 -0
  744. package/dist/voice/testing/index.d.cts +21 -0
  745. package/dist/voice/testing/index.d.ts +21 -0
  746. package/dist/voice/testing/index.d.ts.map +1 -0
  747. package/dist/voice/testing/index.js +35 -0
  748. package/dist/voice/testing/index.js.map +1 -0
  749. package/dist/voice/testing/run_result.cjs +817 -0
  750. package/dist/voice/testing/run_result.cjs.map +1 -0
  751. package/dist/voice/testing/run_result.d.cts +385 -0
  752. package/dist/voice/testing/run_result.d.ts +385 -0
  753. package/dist/voice/testing/run_result.d.ts.map +1 -0
  754. package/dist/voice/testing/run_result.js +790 -0
  755. package/dist/voice/testing/run_result.js.map +1 -0
  756. package/dist/voice/testing/types.cjs +46 -0
  757. package/dist/voice/testing/types.cjs.map +1 -0
  758. package/dist/voice/testing/types.d.cts +83 -0
  759. package/dist/voice/testing/types.d.ts +83 -0
  760. package/dist/voice/testing/types.d.ts.map +1 -0
  761. package/dist/voice/testing/types.js +19 -0
  762. package/dist/voice/testing/types.js.map +1 -0
  763. package/dist/voice/transcription/synchronizer.cjs +139 -15
  764. package/dist/voice/transcription/synchronizer.cjs.map +1 -1
  765. package/dist/voice/transcription/synchronizer.d.cts +35 -4
  766. package/dist/voice/transcription/synchronizer.d.ts +35 -4
  767. package/dist/voice/transcription/synchronizer.d.ts.map +1 -1
  768. package/dist/voice/transcription/synchronizer.js +143 -16
  769. package/dist/voice/transcription/synchronizer.js.map +1 -1
  770. package/dist/voice/transcription/synchronizer.test.cjs +151 -0
  771. package/dist/voice/transcription/synchronizer.test.cjs.map +1 -0
  772. package/dist/voice/transcription/synchronizer.test.js +150 -0
  773. package/dist/voice/transcription/synchronizer.test.js.map +1 -0
  774. package/dist/voice/turn_config/endpointing.cjs +33 -0
  775. package/dist/voice/turn_config/endpointing.cjs.map +1 -0
  776. package/dist/voice/turn_config/endpointing.d.cts +30 -0
  777. package/dist/voice/turn_config/endpointing.d.ts +30 -0
  778. package/dist/voice/turn_config/endpointing.d.ts.map +1 -0
  779. package/dist/voice/turn_config/endpointing.js +9 -0
  780. package/dist/voice/turn_config/endpointing.js.map +1 -0
  781. package/dist/voice/turn_config/interruption.cjs +37 -0
  782. package/dist/voice/turn_config/interruption.cjs.map +1 -0
  783. package/dist/voice/turn_config/interruption.d.cts +53 -0
  784. package/dist/voice/turn_config/interruption.d.ts +53 -0
  785. package/dist/voice/turn_config/interruption.d.ts.map +1 -0
  786. package/dist/voice/turn_config/interruption.js +13 -0
  787. package/dist/voice/turn_config/interruption.js.map +1 -0
  788. package/dist/voice/turn_config/turn_handling.cjs +35 -0
  789. package/dist/voice/turn_config/turn_handling.cjs.map +1 -0
  790. package/dist/voice/turn_config/turn_handling.d.cts +36 -0
  791. package/dist/voice/turn_config/turn_handling.d.ts +36 -0
  792. package/dist/voice/turn_config/turn_handling.d.ts.map +1 -0
  793. package/dist/voice/turn_config/turn_handling.js +11 -0
  794. package/dist/voice/turn_config/turn_handling.js.map +1 -0
  795. package/dist/voice/turn_config/utils.cjs +157 -0
  796. package/dist/voice/turn_config/utils.cjs.map +1 -0
  797. package/dist/voice/turn_config/utils.d.cts +37 -0
  798. package/dist/voice/turn_config/utils.d.ts +37 -0
  799. package/dist/voice/turn_config/utils.d.ts.map +1 -0
  800. package/dist/voice/turn_config/utils.js +131 -0
  801. package/dist/voice/turn_config/utils.js.map +1 -0
  802. package/dist/voice/turn_config/utils.test.cjs +128 -0
  803. package/dist/voice/turn_config/utils.test.cjs.map +1 -0
  804. package/dist/voice/turn_config/utils.test.js +127 -0
  805. package/dist/voice/turn_config/utils.test.js.map +1 -0
  806. package/dist/voice/utils.cjs +47 -0
  807. package/dist/voice/utils.cjs.map +1 -0
  808. package/dist/voice/utils.d.cts +4 -0
  809. package/dist/voice/utils.d.ts +4 -0
  810. package/dist/voice/utils.d.ts.map +1 -0
  811. package/dist/voice/utils.js +23 -0
  812. package/dist/voice/utils.js.map +1 -0
  813. package/dist/worker.cjs +44 -52
  814. package/dist/worker.cjs.map +1 -1
  815. package/dist/worker.d.cts +18 -8
  816. package/dist/worker.d.ts +18 -8
  817. package/dist/worker.d.ts.map +1 -1
  818. package/dist/worker.js +43 -43
  819. package/dist/worker.js.map +1 -1
  820. package/package.json +35 -13
  821. package/resources/NOTICE +2 -0
  822. package/resources/keyboard-typing.ogg +0 -0
  823. package/resources/keyboard-typing2.ogg +0 -0
  824. package/resources/office-ambience.ogg +0 -0
  825. package/src/_exceptions.ts +5 -0
  826. package/src/audio.ts +132 -1
  827. package/src/beta/index.ts +9 -0
  828. package/src/beta/workflows/index.ts +9 -0
  829. package/src/beta/workflows/task_group.ts +203 -0
  830. package/src/cli.ts +57 -66
  831. package/src/connection_pool.test.ts +346 -0
  832. package/src/connection_pool.ts +307 -0
  833. package/src/constants.ts +14 -0
  834. package/src/cpu.test.ts +239 -0
  835. package/src/cpu.ts +173 -0
  836. package/src/http_server.ts +18 -6
  837. package/src/index.ts +15 -13
  838. package/src/inference/api_protos.ts +85 -2
  839. package/src/inference/index.ts +32 -4
  840. package/src/inference/interruption/defaults.ts +51 -0
  841. package/src/inference/interruption/errors.ts +25 -0
  842. package/src/inference/interruption/http_transport.ts +207 -0
  843. package/src/inference/interruption/interruption_cache_entry.ts +50 -0
  844. package/src/inference/interruption/interruption_detector.ts +204 -0
  845. package/src/inference/interruption/interruption_stream.ts +467 -0
  846. package/src/inference/interruption/types.ts +84 -0
  847. package/src/inference/interruption/utils.test.ts +132 -0
  848. package/src/inference/interruption/utils.ts +137 -0
  849. package/src/inference/interruption/ws_transport.ts +416 -0
  850. package/src/inference/llm.ts +214 -163
  851. package/src/inference/stt.test.ts +253 -0
  852. package/src/inference/stt.ts +449 -208
  853. package/src/inference/tts.test.ts +354 -0
  854. package/src/inference/tts.ts +417 -115
  855. package/src/inference/utils.ts +30 -2
  856. package/src/ipc/inference_proc_executor.ts +11 -3
  857. package/src/ipc/inference_proc_lazy_main.ts +13 -1
  858. package/src/ipc/job_proc_executor.ts +11 -1
  859. package/src/ipc/job_proc_lazy_main.ts +86 -20
  860. package/src/ipc/supervised_proc.test.ts +153 -0
  861. package/src/ipc/supervised_proc.ts +39 -10
  862. package/src/job.ts +120 -1
  863. package/src/language.test.ts +62 -0
  864. package/src/language.ts +380 -0
  865. package/src/llm/__snapshots__/zod-utils.test.ts.snap +559 -0
  866. package/src/llm/chat_context.test.ts +787 -0
  867. package/src/llm/chat_context.ts +493 -2
  868. package/src/llm/fallback_adapter.test.ts +238 -0
  869. package/src/llm/fallback_adapter.ts +394 -0
  870. package/src/llm/index.ts +13 -0
  871. package/src/llm/llm.ts +77 -12
  872. package/src/llm/provider_format/google.test.ts +72 -1
  873. package/src/llm/provider_format/google.ts +10 -6
  874. package/src/llm/provider_format/index.ts +7 -2
  875. package/src/llm/provider_format/openai.test.ts +480 -2
  876. package/src/llm/provider_format/openai.ts +152 -21
  877. package/src/llm/provider_format/utils.ts +11 -5
  878. package/src/llm/realtime.ts +23 -2
  879. package/src/llm/remote_chat_context.ts +2 -2
  880. package/src/llm/tool_context.test.ts +210 -1
  881. package/src/llm/tool_context.ts +115 -17
  882. package/src/llm/utils.test.ts +103 -2
  883. package/src/llm/utils.ts +152 -16
  884. package/src/llm/zod-utils.test.ts +577 -0
  885. package/src/llm/zod-utils.ts +153 -0
  886. package/src/log.ts +71 -19
  887. package/src/metrics/base.ts +78 -19
  888. package/src/metrics/index.ts +12 -0
  889. package/src/metrics/model_usage.test.ts +545 -0
  890. package/src/metrics/model_usage.ts +262 -0
  891. package/src/metrics/usage_collector.ts +14 -3
  892. package/src/metrics/utils.ts +27 -7
  893. package/src/stream/deferred_stream.test.ts +3 -3
  894. package/src/stream/deferred_stream.ts +43 -11
  895. package/src/stream/index.ts +1 -0
  896. package/src/stream/multi_input_stream.test.ts +545 -0
  897. package/src/stream/multi_input_stream.ts +172 -0
  898. package/src/stream/stream_channel.test.ts +37 -0
  899. package/src/stream/stream_channel.ts +43 -3
  900. package/src/stt/stream_adapter.ts +30 -9
  901. package/src/stt/stt.ts +140 -23
  902. package/src/telemetry/index.ts +28 -0
  903. package/src/telemetry/logging.ts +55 -0
  904. package/src/telemetry/otel_http_exporter.ts +218 -0
  905. package/src/telemetry/pino_otel_transport.ts +265 -0
  906. package/src/telemetry/trace_types.ts +109 -0
  907. package/src/telemetry/traces.ts +673 -0
  908. package/src/telemetry/utils.ts +61 -0
  909. package/src/tokenize/basic/sentence.ts +3 -3
  910. package/src/tokenize/tokenizer.test.ts +4 -0
  911. package/src/transcription.ts +6 -0
  912. package/src/tts/fallback_adapter.ts +586 -0
  913. package/src/tts/index.ts +1 -0
  914. package/src/tts/stream_adapter.ts +38 -8
  915. package/src/tts/tts.ts +245 -62
  916. package/src/typed_promise.ts +67 -0
  917. package/src/types.ts +62 -33
  918. package/src/utils.test.ts +90 -10
  919. package/src/utils.ts +178 -33
  920. package/src/vad.ts +42 -18
  921. package/src/version.ts +1 -1
  922. package/src/voice/agent.test.ts +347 -2
  923. package/src/voice/agent.ts +346 -44
  924. package/src/voice/agent_activity.test.ts +194 -0
  925. package/src/voice/agent_activity.ts +1457 -388
  926. package/src/voice/agent_session.ts +817 -112
  927. package/src/voice/audio_recognition.ts +845 -70
  928. package/src/voice/audio_recognition_span.test.ts +341 -0
  929. package/src/voice/avatar/datastream_io.ts +9 -1
  930. package/src/voice/background_audio.ts +494 -0
  931. package/src/voice/events.ts +27 -7
  932. package/src/voice/generation.ts +310 -56
  933. package/src/voice/generation_tools.test.ts +268 -0
  934. package/src/voice/index.ts +17 -3
  935. package/src/voice/interruption_detection.test.ts +151 -0
  936. package/src/voice/io.ts +115 -12
  937. package/src/voice/recorder_io/index.ts +4 -0
  938. package/src/voice/recorder_io/recorder_io.ts +783 -0
  939. package/src/voice/remote_session.ts +1083 -0
  940. package/src/voice/report.test.ts +136 -0
  941. package/src/voice/report.ts +140 -0
  942. package/src/voice/room_io/_input.ts +45 -10
  943. package/src/voice/room_io/_output.ts +26 -14
  944. package/src/voice/room_io/room_io.ts +67 -22
  945. package/src/voice/speech_handle.ts +38 -6
  946. package/src/voice/testing/fake_llm.ts +138 -0
  947. package/src/voice/testing/index.ts +52 -0
  948. package/src/voice/testing/run_result.ts +995 -0
  949. package/src/voice/testing/types.ts +118 -0
  950. package/src/voice/transcription/synchronizer.test.ts +206 -0
  951. package/src/voice/transcription/synchronizer.ts +204 -19
  952. package/src/voice/turn_config/endpointing.ts +33 -0
  953. package/src/voice/turn_config/interruption.ts +56 -0
  954. package/src/voice/turn_config/turn_handling.ts +45 -0
  955. package/src/voice/turn_config/utils.test.ts +148 -0
  956. package/src/voice/turn_config/utils.ts +167 -0
  957. package/src/voice/utils.ts +29 -0
  958. package/src/worker.ts +92 -78
  959. package/src/llm/__snapshots__/utils.test.ts.snap +0 -65
@@ -1,6 +1,17 @@
1
1
  "use strict";
2
2
  var import_vitest = require("vitest");
3
+ var import_log = require("../log.cjs");
4
+ var import_fake_llm = require("../voice/testing/fake_llm.cjs");
3
5
  var import_chat_context = require("./chat_context.cjs");
6
+ (0, import_log.initializeLogger)({ pretty: false, level: "error" });
7
+ const summaryXml = (summary) => ["<chat_history_summary>", summary, "</chat_history_summary>"].join("\n");
8
+ class TrackingFakeLLM extends import_fake_llm.FakeLLM {
9
+ chatCalls = 0;
10
+ chat(...args) {
11
+ this.chatCalls += 1;
12
+ return super.chat(...args);
13
+ }
14
+ }
4
15
  (0, import_vitest.describe)("ChatContext.toJSON", () => {
5
16
  (0, import_vitest.it)("should match snapshot for empty context", () => {
6
17
  const context = new import_chat_context.ChatContext();
@@ -232,6 +243,156 @@ var import_chat_context = require("./chat_context.cjs");
232
243
  ).toMatchSnapshot("message-properties-full");
233
244
  });
234
245
  });
246
+ (0, import_vitest.describe)("ChatContext._summarize", () => {
247
+ (0, import_vitest.it)("includes function calls in the summarization source and keeps chronological order", async () => {
248
+ const ctx = new import_chat_context.ChatContext();
249
+ ctx.addMessage({ role: "system", content: "System prompt", createdAt: 0 });
250
+ ctx.addMessage({ role: "user", content: "hello", createdAt: 1e3 });
251
+ ctx.addMessage({ role: "assistant", content: "hi there", createdAt: 2e3 });
252
+ ctx.insert(
253
+ import_chat_context.FunctionCall.create({
254
+ callId: "call_1",
255
+ name: "lookup",
256
+ args: '{"order":"123"}',
257
+ createdAt: 2500
258
+ })
259
+ );
260
+ ctx.insert(
261
+ new import_chat_context.FunctionCallOutput({
262
+ callId: "call_1",
263
+ name: "lookup",
264
+ output: '{"status":"delivered"}',
265
+ isError: false,
266
+ createdAt: 2600
267
+ })
268
+ );
269
+ ctx.addMessage({ role: "user", content: "my color is blue", createdAt: 3e3 });
270
+ ctx.addMessage({ role: "assistant", content: "noted", createdAt: 4e3 });
271
+ const fake = new import_fake_llm.FakeLLM([
272
+ {
273
+ input: [
274
+ "Conversation to summarize:",
275
+ "",
276
+ "<user>",
277
+ "hello",
278
+ "</user>",
279
+ "<assistant>",
280
+ "hi there",
281
+ "</assistant>",
282
+ '<function_call name="lookup" call_id="call_1">',
283
+ '{"order":"123"}',
284
+ "</function_call>",
285
+ '<function_call_output name="lookup" call_id="call_1">',
286
+ '{"status":"delivered"}',
287
+ "</function_call_output>"
288
+ ].join("\n"),
289
+ content: "condensed head"
290
+ }
291
+ ]);
292
+ await ctx._summarize(fake, { keepLastTurns: 1 });
293
+ const summary = ctx.items.find(
294
+ (item) => {
295
+ var _a;
296
+ return item.type === "message" && item.role === "assistant" && ((_a = item.extra) == null ? void 0 : _a.is_summary) === true;
297
+ }
298
+ );
299
+ (0, import_vitest.expect)(summary).toBeDefined();
300
+ if (!summary || summary.type !== "message") {
301
+ throw new Error("summary message is missing");
302
+ }
303
+ (0, import_vitest.expect)(summary.textContent).toBe(summaryXml("condensed head"));
304
+ (0, import_vitest.expect)(summary.createdAt).toBeCloseTo(2999.999999, 6);
305
+ (0, import_vitest.expect)(ctx.items.filter((item) => item.type === "function_call")).toHaveLength(0);
306
+ (0, import_vitest.expect)(ctx.items.filter((item) => item.type === "function_call_output")).toHaveLength(0);
307
+ const createdAts = ctx.items.map((item) => item.createdAt);
308
+ const sorted = [...createdAts].sort((a, b) => a - b);
309
+ (0, import_vitest.expect)(createdAts).toEqual(sorted);
310
+ });
311
+ (0, import_vitest.it)("preserves interleaved tool items that belong to the recent tail", async () => {
312
+ const ctx = new import_chat_context.ChatContext();
313
+ ctx.addMessage({ role: "system", content: "System prompt", createdAt: 0 });
314
+ ctx.addMessage({ role: "user", content: "my earbuds are broken", createdAt: 1e3 });
315
+ ctx.addMessage({
316
+ role: "assistant",
317
+ content: "Can you share your order number?",
318
+ createdAt: 2e3
319
+ });
320
+ ctx.addMessage({ role: "user", content: "Order #123", createdAt: 3e3 });
321
+ ctx.insert(
322
+ import_chat_context.FunctionCall.create({
323
+ callId: "call_2",
324
+ name: "lookup_order",
325
+ args: '{"order":"123"}',
326
+ createdAt: 3500
327
+ })
328
+ );
329
+ ctx.insert(
330
+ new import_chat_context.FunctionCallOutput({
331
+ callId: "call_2",
332
+ name: "lookup_order",
333
+ output: '{"status":"delivered"}',
334
+ isError: false,
335
+ createdAt: 3600
336
+ })
337
+ );
338
+ ctx.addMessage({
339
+ role: "assistant",
340
+ content: "Found your order. Let me check the warranty.",
341
+ createdAt: 4e3
342
+ });
343
+ ctx.addMessage({ role: "user", content: "Thanks.", createdAt: 5e3 });
344
+ ctx.addMessage({ role: "assistant", content: "You are under warranty.", createdAt: 6e3 });
345
+ const fake = new import_fake_llm.FakeLLM([
346
+ {
347
+ input: [
348
+ "Conversation to summarize:",
349
+ "",
350
+ "<user>",
351
+ "my earbuds are broken",
352
+ "</user>",
353
+ "<assistant>",
354
+ "Can you share your order number?",
355
+ "</assistant>"
356
+ ].join("\n"),
357
+ content: "older summary"
358
+ }
359
+ ]);
360
+ await ctx._summarize(fake, { keepLastTurns: 2 });
361
+ const functionItems = ctx.items.filter(
362
+ (item) => item.type === "function_call" || item.type === "function_call_output"
363
+ );
364
+ (0, import_vitest.expect)(functionItems).toHaveLength(2);
365
+ (0, import_vitest.expect)(functionItems.map((item) => item.createdAt)).toEqual([3500, 3600]);
366
+ const rawTailMessages = ctx.items.filter(
367
+ (item) => {
368
+ var _a;
369
+ return item.type === "message" && (item.role === "user" || item.role === "assistant") && ((_a = item.extra) == null ? void 0 : _a.is_summary) !== true;
370
+ }
371
+ );
372
+ (0, import_vitest.expect)(rawTailMessages).toHaveLength(4);
373
+ (0, import_vitest.expect)(rawTailMessages.map((item) => item.textContent)).toEqual([
374
+ "Order #123",
375
+ "Found your order. Let me check the warranty.",
376
+ "Thanks.",
377
+ "You are under warranty."
378
+ ]);
379
+ const createdAts = ctx.items.map((item) => item.createdAt);
380
+ const sorted = [...createdAts].sort((a, b) => a - b);
381
+ (0, import_vitest.expect)(createdAts).toEqual(sorted);
382
+ });
383
+ (0, import_vitest.it)("skips summarization when the recent-turn budget already covers the history", async () => {
384
+ const ctx = new import_chat_context.ChatContext();
385
+ ctx.addMessage({ role: "system", content: "System prompt", createdAt: 0 });
386
+ ctx.addMessage({ role: "user", content: "hello", createdAt: 1e3 });
387
+ ctx.addMessage({ role: "assistant", content: "hi there", createdAt: 2e3 });
388
+ const llm = new TrackingFakeLLM();
389
+ const originalIds = ctx.items.map((item) => item.id);
390
+ const result = await ctx._summarize(llm, { keepLastTurns: 1 });
391
+ (0, import_vitest.expect)(result).toBe(ctx);
392
+ (0, import_vitest.expect)(llm.chatCalls).toBe(0);
393
+ (0, import_vitest.expect)(ctx.items.map((item) => item.id)).toEqual(originalIds);
394
+ });
395
+ });
235
396
  (0, import_vitest.describe)("ReadonlyChatContext with immutable array", () => {
236
397
  (0, import_vitest.it)("should have readonly property set to true", () => {
237
398
  const items = [
@@ -377,4 +538,535 @@ var import_chat_context = require("./chat_context.cjs");
377
538
  (0, import_vitest.expect)(ids).toEqual(["msg_1", "msg_2"]);
378
539
  });
379
540
  });
541
+ (0, import_vitest.describe)("ChatContext.isEquivalent", () => {
542
+ (0, import_vitest.it)("should return true for same reference", () => {
543
+ const ctx = new import_chat_context.ChatContext();
544
+ ctx.addMessage({
545
+ id: "msg_1",
546
+ role: "user",
547
+ content: "Hello"
548
+ });
549
+ (0, import_vitest.expect)(ctx.isEquivalent(ctx)).toBe(true);
550
+ });
551
+ (0, import_vitest.it)("should return true for identical empty contexts", () => {
552
+ const ctx1 = new import_chat_context.ChatContext();
553
+ const ctx2 = new import_chat_context.ChatContext();
554
+ (0, import_vitest.expect)(ctx1.isEquivalent(ctx2)).toBe(true);
555
+ });
556
+ (0, import_vitest.it)("should return false for contexts with different lengths", () => {
557
+ const ctx1 = new import_chat_context.ChatContext();
558
+ ctx1.addMessage({
559
+ id: "msg_1",
560
+ role: "user",
561
+ content: "Hello"
562
+ });
563
+ const ctx2 = new import_chat_context.ChatContext();
564
+ ctx2.addMessage({
565
+ id: "msg_1",
566
+ role: "user",
567
+ content: "Hello"
568
+ });
569
+ ctx2.addMessage({
570
+ id: "msg_2",
571
+ role: "assistant",
572
+ content: "Hi"
573
+ });
574
+ (0, import_vitest.expect)(ctx1.isEquivalent(ctx2)).toBe(false);
575
+ });
576
+ (0, import_vitest.it)("should return false for contexts with different item IDs", () => {
577
+ const ctx1 = new import_chat_context.ChatContext();
578
+ ctx1.addMessage({
579
+ id: "msg_1",
580
+ role: "user",
581
+ content: "Hello"
582
+ });
583
+ const ctx2 = new import_chat_context.ChatContext();
584
+ ctx2.addMessage({
585
+ id: "msg_2",
586
+ role: "user",
587
+ content: "Hello"
588
+ });
589
+ (0, import_vitest.expect)(ctx1.isEquivalent(ctx2)).toBe(false);
590
+ });
591
+ (0, import_vitest.it)("should return false for contexts with different item types", () => {
592
+ const ctx1 = new import_chat_context.ChatContext();
593
+ ctx1.addMessage({
594
+ id: "msg_1",
595
+ role: "user",
596
+ content: "Hello"
597
+ });
598
+ const ctx2 = new import_chat_context.ChatContext();
599
+ ctx2.insert(
600
+ new import_chat_context.FunctionCall({
601
+ id: "msg_1",
602
+ callId: "call_1",
603
+ name: "test",
604
+ args: "{}"
605
+ })
606
+ );
607
+ (0, import_vitest.expect)(ctx1.isEquivalent(ctx2)).toBe(false);
608
+ });
609
+ (0, import_vitest.describe)("message comparison", () => {
610
+ (0, import_vitest.it)("should return true for identical messages", () => {
611
+ const ctx1 = new import_chat_context.ChatContext();
612
+ ctx1.addMessage({
613
+ id: "msg_1",
614
+ role: "user",
615
+ content: "Hello",
616
+ interrupted: false
617
+ });
618
+ const ctx2 = new import_chat_context.ChatContext();
619
+ ctx2.addMessage({
620
+ id: "msg_1",
621
+ role: "user",
622
+ content: "Hello",
623
+ interrupted: false
624
+ });
625
+ (0, import_vitest.expect)(ctx1.isEquivalent(ctx2)).toBe(true);
626
+ });
627
+ (0, import_vitest.it)("should return false for messages with different roles", () => {
628
+ const ctx1 = new import_chat_context.ChatContext();
629
+ ctx1.addMessage({
630
+ id: "msg_1",
631
+ role: "user",
632
+ content: "Hello"
633
+ });
634
+ const ctx2 = new import_chat_context.ChatContext();
635
+ ctx2.addMessage({
636
+ id: "msg_1",
637
+ role: "assistant",
638
+ content: "Hello"
639
+ });
640
+ (0, import_vitest.expect)(ctx1.isEquivalent(ctx2)).toBe(false);
641
+ });
642
+ (0, import_vitest.it)("should return false for messages with different interrupted flags", () => {
643
+ const ctx1 = new import_chat_context.ChatContext();
644
+ ctx1.addMessage({
645
+ id: "msg_1",
646
+ role: "user",
647
+ content: "Hello",
648
+ interrupted: false
649
+ });
650
+ const ctx2 = new import_chat_context.ChatContext();
651
+ ctx2.addMessage({
652
+ id: "msg_1",
653
+ role: "user",
654
+ content: "Hello",
655
+ interrupted: true
656
+ });
657
+ (0, import_vitest.expect)(ctx1.isEquivalent(ctx2)).toBe(false);
658
+ });
659
+ (0, import_vitest.it)("should return false for messages with different content", () => {
660
+ const ctx1 = new import_chat_context.ChatContext();
661
+ ctx1.addMessage({
662
+ id: "msg_1",
663
+ role: "user",
664
+ content: "Hello"
665
+ });
666
+ const ctx2 = new import_chat_context.ChatContext();
667
+ ctx2.addMessage({
668
+ id: "msg_1",
669
+ role: "user",
670
+ content: "World"
671
+ });
672
+ (0, import_vitest.expect)(ctx1.isEquivalent(ctx2)).toBe(false);
673
+ });
674
+ (0, import_vitest.it)("should return true for messages with identical array content", () => {
675
+ const ctx1 = new import_chat_context.ChatContext();
676
+ ctx1.addMessage({
677
+ id: "msg_1",
678
+ role: "user",
679
+ content: ["Hello", "World"]
680
+ });
681
+ const ctx2 = new import_chat_context.ChatContext();
682
+ ctx2.addMessage({
683
+ id: "msg_1",
684
+ role: "user",
685
+ content: ["Hello", "World"]
686
+ });
687
+ (0, import_vitest.expect)(ctx1.isEquivalent(ctx2)).toBe(true);
688
+ });
689
+ (0, import_vitest.it)("should return false for messages with different array content", () => {
690
+ const ctx1 = new import_chat_context.ChatContext();
691
+ ctx1.addMessage({
692
+ id: "msg_1",
693
+ role: "user",
694
+ content: ["Hello", "World"]
695
+ });
696
+ const ctx2 = new import_chat_context.ChatContext();
697
+ ctx2.addMessage({
698
+ id: "msg_1",
699
+ role: "user",
700
+ content: ["Hello"]
701
+ });
702
+ (0, import_vitest.expect)(ctx1.isEquivalent(ctx2)).toBe(false);
703
+ });
704
+ (0, import_vitest.it)("should return true for messages with identical image content", () => {
705
+ const imageContent = {
706
+ id: "img_1",
707
+ type: "image_content",
708
+ image: "https://example.com/image.jpg",
709
+ inferenceDetail: "high",
710
+ inferenceWidth: 1024,
711
+ inferenceHeight: 768,
712
+ mimeType: "image/jpeg",
713
+ _cache: {}
714
+ };
715
+ const ctx1 = new import_chat_context.ChatContext();
716
+ ctx1.addMessage({
717
+ id: "msg_1",
718
+ role: "user",
719
+ content: ["Check this:", imageContent]
720
+ });
721
+ const ctx2 = new import_chat_context.ChatContext();
722
+ ctx2.addMessage({
723
+ id: "msg_1",
724
+ role: "user",
725
+ content: ["Check this:", { ...imageContent }]
726
+ });
727
+ (0, import_vitest.expect)(ctx1.isEquivalent(ctx2)).toBe(true);
728
+ });
729
+ (0, import_vitest.it)("should return false for messages with different image content", () => {
730
+ const imageContent1 = {
731
+ id: "img_1",
732
+ type: "image_content",
733
+ image: "https://example.com/image1.jpg",
734
+ inferenceDetail: "high",
735
+ _cache: {}
736
+ };
737
+ const imageContent2 = {
738
+ id: "img_2",
739
+ type: "image_content",
740
+ image: "https://example.com/image2.jpg",
741
+ inferenceDetail: "high",
742
+ _cache: {}
743
+ };
744
+ const ctx1 = new import_chat_context.ChatContext();
745
+ ctx1.addMessage({
746
+ id: "msg_1",
747
+ role: "user",
748
+ content: ["Check this:", imageContent1]
749
+ });
750
+ const ctx2 = new import_chat_context.ChatContext();
751
+ ctx2.addMessage({
752
+ id: "msg_1",
753
+ role: "user",
754
+ content: ["Check this:", imageContent2]
755
+ });
756
+ (0, import_vitest.expect)(ctx1.isEquivalent(ctx2)).toBe(false);
757
+ });
758
+ });
759
+ (0, import_vitest.describe)("function call comparison", () => {
760
+ (0, import_vitest.it)("should return true for identical function calls", () => {
761
+ const ctx1 = new import_chat_context.ChatContext();
762
+ ctx1.insert(
763
+ new import_chat_context.FunctionCall({
764
+ id: "func_1",
765
+ callId: "call_1",
766
+ name: "get_weather",
767
+ args: '{"location": "Paris"}'
768
+ })
769
+ );
770
+ const ctx2 = new import_chat_context.ChatContext();
771
+ ctx2.insert(
772
+ new import_chat_context.FunctionCall({
773
+ id: "func_1",
774
+ callId: "call_1",
775
+ name: "get_weather",
776
+ args: '{"location": "Paris"}'
777
+ })
778
+ );
779
+ (0, import_vitest.expect)(ctx1.isEquivalent(ctx2)).toBe(true);
780
+ });
781
+ (0, import_vitest.it)("should return false for function calls with different names", () => {
782
+ const ctx1 = new import_chat_context.ChatContext();
783
+ ctx1.insert(
784
+ new import_chat_context.FunctionCall({
785
+ id: "func_1",
786
+ callId: "call_1",
787
+ name: "get_weather",
788
+ args: "{}"
789
+ })
790
+ );
791
+ const ctx2 = new import_chat_context.ChatContext();
792
+ ctx2.insert(
793
+ new import_chat_context.FunctionCall({
794
+ id: "func_1",
795
+ callId: "call_1",
796
+ name: "get_time",
797
+ args: "{}"
798
+ })
799
+ );
800
+ (0, import_vitest.expect)(ctx1.isEquivalent(ctx2)).toBe(false);
801
+ });
802
+ (0, import_vitest.it)("should return false for function calls with different call IDs", () => {
803
+ const ctx1 = new import_chat_context.ChatContext();
804
+ ctx1.insert(
805
+ new import_chat_context.FunctionCall({
806
+ id: "func_1",
807
+ callId: "call_1",
808
+ name: "get_weather",
809
+ args: "{}"
810
+ })
811
+ );
812
+ const ctx2 = new import_chat_context.ChatContext();
813
+ ctx2.insert(
814
+ new import_chat_context.FunctionCall({
815
+ id: "func_1",
816
+ callId: "call_2",
817
+ name: "get_weather",
818
+ args: "{}"
819
+ })
820
+ );
821
+ (0, import_vitest.expect)(ctx1.isEquivalent(ctx2)).toBe(false);
822
+ });
823
+ (0, import_vitest.it)("should return false for function calls with different arguments", () => {
824
+ const ctx1 = new import_chat_context.ChatContext();
825
+ ctx1.insert(
826
+ new import_chat_context.FunctionCall({
827
+ id: "func_1",
828
+ callId: "call_1",
829
+ name: "get_weather",
830
+ args: '{"location": "Paris"}'
831
+ })
832
+ );
833
+ const ctx2 = new import_chat_context.ChatContext();
834
+ ctx2.insert(
835
+ new import_chat_context.FunctionCall({
836
+ id: "func_1",
837
+ callId: "call_1",
838
+ name: "get_weather",
839
+ args: '{"location": "London"}'
840
+ })
841
+ );
842
+ (0, import_vitest.expect)(ctx1.isEquivalent(ctx2)).toBe(false);
843
+ });
844
+ (0, import_vitest.it)("should ignore timestamps", () => {
845
+ const ctx1 = new import_chat_context.ChatContext();
846
+ ctx1.insert(
847
+ new import_chat_context.FunctionCall({
848
+ id: "func_1",
849
+ callId: "call_1",
850
+ name: "get_weather",
851
+ args: "{}",
852
+ createdAt: 1e3
853
+ })
854
+ );
855
+ const ctx2 = new import_chat_context.ChatContext();
856
+ ctx2.insert(
857
+ new import_chat_context.FunctionCall({
858
+ id: "func_1",
859
+ callId: "call_1",
860
+ name: "get_weather",
861
+ args: "{}",
862
+ createdAt: 2e3
863
+ })
864
+ );
865
+ (0, import_vitest.expect)(ctx1.isEquivalent(ctx2)).toBe(true);
866
+ });
867
+ });
868
+ (0, import_vitest.describe)("function call output comparison", () => {
869
+ (0, import_vitest.it)("should return true for identical function call outputs", () => {
870
+ const ctx1 = new import_chat_context.ChatContext();
871
+ ctx1.insert(
872
+ new import_chat_context.FunctionCallOutput({
873
+ id: "output_1",
874
+ callId: "call_1",
875
+ name: "get_weather",
876
+ output: '{"temperature": 22}',
877
+ isError: false
878
+ })
879
+ );
880
+ const ctx2 = new import_chat_context.ChatContext();
881
+ ctx2.insert(
882
+ new import_chat_context.FunctionCallOutput({
883
+ id: "output_1",
884
+ callId: "call_1",
885
+ name: "get_weather",
886
+ output: '{"temperature": 22}',
887
+ isError: false
888
+ })
889
+ );
890
+ (0, import_vitest.expect)(ctx1.isEquivalent(ctx2)).toBe(true);
891
+ });
892
+ (0, import_vitest.it)("should return false for function call outputs with different names", () => {
893
+ const ctx1 = new import_chat_context.ChatContext();
894
+ ctx1.insert(
895
+ new import_chat_context.FunctionCallOutput({
896
+ id: "output_1",
897
+ callId: "call_1",
898
+ name: "get_weather",
899
+ output: "{}",
900
+ isError: false
901
+ })
902
+ );
903
+ const ctx2 = new import_chat_context.ChatContext();
904
+ ctx2.insert(
905
+ new import_chat_context.FunctionCallOutput({
906
+ id: "output_1",
907
+ callId: "call_1",
908
+ name: "get_time",
909
+ output: "{}",
910
+ isError: false
911
+ })
912
+ );
913
+ (0, import_vitest.expect)(ctx1.isEquivalent(ctx2)).toBe(false);
914
+ });
915
+ (0, import_vitest.it)("should return false for function call outputs with different call IDs", () => {
916
+ const ctx1 = new import_chat_context.ChatContext();
917
+ ctx1.insert(
918
+ new import_chat_context.FunctionCallOutput({
919
+ id: "output_1",
920
+ callId: "call_1",
921
+ name: "get_weather",
922
+ output: "{}",
923
+ isError: false
924
+ })
925
+ );
926
+ const ctx2 = new import_chat_context.ChatContext();
927
+ ctx2.insert(
928
+ new import_chat_context.FunctionCallOutput({
929
+ id: "output_1",
930
+ callId: "call_2",
931
+ name: "get_weather",
932
+ output: "{}",
933
+ isError: false
934
+ })
935
+ );
936
+ (0, import_vitest.expect)(ctx1.isEquivalent(ctx2)).toBe(false);
937
+ });
938
+ (0, import_vitest.it)("should return false for function call outputs with different output values", () => {
939
+ const ctx1 = new import_chat_context.ChatContext();
940
+ ctx1.insert(
941
+ new import_chat_context.FunctionCallOutput({
942
+ id: "output_1",
943
+ callId: "call_1",
944
+ name: "get_weather",
945
+ output: '{"temperature": 22}',
946
+ isError: false
947
+ })
948
+ );
949
+ const ctx2 = new import_chat_context.ChatContext();
950
+ ctx2.insert(
951
+ new import_chat_context.FunctionCallOutput({
952
+ id: "output_1",
953
+ callId: "call_1",
954
+ name: "get_weather",
955
+ output: '{"temperature": 25}',
956
+ isError: false
957
+ })
958
+ );
959
+ (0, import_vitest.expect)(ctx1.isEquivalent(ctx2)).toBe(false);
960
+ });
961
+ (0, import_vitest.it)("should return false for function call outputs with different error flags", () => {
962
+ const ctx1 = new import_chat_context.ChatContext();
963
+ ctx1.insert(
964
+ new import_chat_context.FunctionCallOutput({
965
+ id: "output_1",
966
+ callId: "call_1",
967
+ name: "get_weather",
968
+ output: "Error occurred",
969
+ isError: false
970
+ })
971
+ );
972
+ const ctx2 = new import_chat_context.ChatContext();
973
+ ctx2.insert(
974
+ new import_chat_context.FunctionCallOutput({
975
+ id: "output_1",
976
+ callId: "call_1",
977
+ name: "get_weather",
978
+ output: "Error occurred",
979
+ isError: true
980
+ })
981
+ );
982
+ (0, import_vitest.expect)(ctx1.isEquivalent(ctx2)).toBe(false);
983
+ });
984
+ (0, import_vitest.it)("should ignore timestamps", () => {
985
+ const ctx1 = new import_chat_context.ChatContext();
986
+ ctx1.insert(
987
+ new import_chat_context.FunctionCallOutput({
988
+ id: "output_1",
989
+ callId: "call_1",
990
+ name: "get_weather",
991
+ output: "{}",
992
+ isError: false,
993
+ createdAt: 1e3
994
+ })
995
+ );
996
+ const ctx2 = new import_chat_context.ChatContext();
997
+ ctx2.insert(
998
+ new import_chat_context.FunctionCallOutput({
999
+ id: "output_1",
1000
+ callId: "call_1",
1001
+ name: "get_weather",
1002
+ output: "{}",
1003
+ isError: false,
1004
+ createdAt: 2e3
1005
+ })
1006
+ );
1007
+ (0, import_vitest.expect)(ctx1.isEquivalent(ctx2)).toBe(true);
1008
+ });
1009
+ });
1010
+ (0, import_vitest.describe)("complex context comparison", () => {
1011
+ (0, import_vitest.it)("should return true for identical complex contexts", () => {
1012
+ const ctx1 = new import_chat_context.ChatContext();
1013
+ ctx1.addMessage({
1014
+ id: "msg_1",
1015
+ role: "user",
1016
+ content: "What is the weather?"
1017
+ });
1018
+ ctx1.insert(
1019
+ new import_chat_context.FunctionCall({
1020
+ id: "func_1",
1021
+ callId: "call_1",
1022
+ name: "get_weather",
1023
+ args: '{"location": "Paris"}'
1024
+ })
1025
+ );
1026
+ ctx1.insert(
1027
+ new import_chat_context.FunctionCallOutput({
1028
+ id: "output_1",
1029
+ callId: "call_1",
1030
+ name: "get_weather",
1031
+ output: '{"temperature": 22}',
1032
+ isError: false
1033
+ })
1034
+ );
1035
+ ctx1.addMessage({
1036
+ id: "msg_2",
1037
+ role: "assistant",
1038
+ content: "The weather is 22\xB0C"
1039
+ });
1040
+ const ctx2 = new import_chat_context.ChatContext();
1041
+ ctx2.addMessage({
1042
+ id: "msg_1",
1043
+ role: "user",
1044
+ content: "What is the weather?"
1045
+ });
1046
+ ctx2.insert(
1047
+ new import_chat_context.FunctionCall({
1048
+ id: "func_1",
1049
+ callId: "call_1",
1050
+ name: "get_weather",
1051
+ args: '{"location": "Paris"}'
1052
+ })
1053
+ );
1054
+ ctx2.insert(
1055
+ new import_chat_context.FunctionCallOutput({
1056
+ id: "output_1",
1057
+ callId: "call_1",
1058
+ name: "get_weather",
1059
+ output: '{"temperature": 22}',
1060
+ isError: false
1061
+ })
1062
+ );
1063
+ ctx2.addMessage({
1064
+ id: "msg_2",
1065
+ role: "assistant",
1066
+ content: "The weather is 22\xB0C"
1067
+ });
1068
+ (0, import_vitest.expect)(ctx1.isEquivalent(ctx2)).toBe(true);
1069
+ });
1070
+ });
1071
+ });
380
1072
  //# sourceMappingURL=chat_context.test.cjs.map