@livekit/agents 1.0.47 → 1.1.0-dev.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 (444) hide show
  1. package/dist/beta/index.cjs +29 -0
  2. package/dist/beta/index.cjs.map +1 -0
  3. package/dist/beta/index.d.cts +2 -0
  4. package/dist/beta/index.d.ts +2 -0
  5. package/dist/beta/index.d.ts.map +1 -0
  6. package/dist/beta/index.js +7 -0
  7. package/dist/beta/index.js.map +1 -0
  8. package/dist/beta/workflows/index.cjs +29 -0
  9. package/dist/beta/workflows/index.cjs.map +1 -0
  10. package/dist/beta/workflows/index.d.cts +2 -0
  11. package/dist/beta/workflows/index.d.ts +2 -0
  12. package/dist/beta/workflows/index.d.ts.map +1 -0
  13. package/dist/beta/workflows/index.js +7 -0
  14. package/dist/beta/workflows/index.js.map +1 -0
  15. package/dist/beta/workflows/task_group.cjs +162 -0
  16. package/dist/beta/workflows/task_group.cjs.map +1 -0
  17. package/dist/beta/workflows/task_group.d.cts +32 -0
  18. package/dist/beta/workflows/task_group.d.ts +32 -0
  19. package/dist/beta/workflows/task_group.d.ts.map +1 -0
  20. package/dist/beta/workflows/task_group.js +138 -0
  21. package/dist/beta/workflows/task_group.js.map +1 -0
  22. package/dist/constants.cjs +27 -0
  23. package/dist/constants.cjs.map +1 -1
  24. package/dist/constants.d.cts +9 -0
  25. package/dist/constants.d.ts +9 -0
  26. package/dist/constants.d.ts.map +1 -1
  27. package/dist/constants.js +18 -0
  28. package/dist/constants.js.map +1 -1
  29. package/dist/index.cjs +3 -0
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.d.cts +2 -1
  32. package/dist/index.d.ts +2 -1
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +2 -0
  35. package/dist/index.js.map +1 -1
  36. package/dist/inference/api_protos.d.cts +12 -12
  37. package/dist/inference/api_protos.d.ts +12 -12
  38. package/dist/inference/interruption/defaults.cjs +81 -0
  39. package/dist/inference/interruption/defaults.cjs.map +1 -0
  40. package/dist/inference/interruption/defaults.d.cts +19 -0
  41. package/dist/inference/interruption/defaults.d.ts +19 -0
  42. package/dist/inference/interruption/defaults.d.ts.map +1 -0
  43. package/dist/inference/interruption/defaults.js +46 -0
  44. package/dist/inference/interruption/defaults.js.map +1 -0
  45. package/dist/inference/interruption/errors.cjs +44 -0
  46. package/dist/inference/interruption/errors.cjs.map +1 -0
  47. package/dist/inference/interruption/errors.d.cts +12 -0
  48. package/dist/inference/interruption/errors.d.ts +12 -0
  49. package/dist/inference/interruption/errors.d.ts.map +1 -0
  50. package/dist/inference/interruption/errors.js +20 -0
  51. package/dist/inference/interruption/errors.js.map +1 -0
  52. package/dist/inference/interruption/http_transport.cjs +147 -0
  53. package/dist/inference/interruption/http_transport.cjs.map +1 -0
  54. package/dist/inference/interruption/http_transport.d.cts +63 -0
  55. package/dist/inference/interruption/http_transport.d.ts +63 -0
  56. package/dist/inference/interruption/http_transport.d.ts.map +1 -0
  57. package/dist/inference/interruption/http_transport.js +121 -0
  58. package/dist/inference/interruption/http_transport.js.map +1 -0
  59. package/dist/inference/interruption/interruption_cache_entry.cjs +58 -0
  60. package/dist/inference/interruption/interruption_cache_entry.cjs.map +1 -0
  61. package/dist/inference/interruption/interruption_cache_entry.d.cts +30 -0
  62. package/dist/inference/interruption/interruption_cache_entry.d.ts +30 -0
  63. package/dist/inference/interruption/interruption_cache_entry.d.ts.map +1 -0
  64. package/dist/inference/interruption/interruption_cache_entry.js +34 -0
  65. package/dist/inference/interruption/interruption_cache_entry.js.map +1 -0
  66. package/dist/inference/interruption/interruption_detector.cjs +181 -0
  67. package/dist/inference/interruption/interruption_detector.cjs.map +1 -0
  68. package/dist/inference/interruption/interruption_detector.d.cts +59 -0
  69. package/dist/inference/interruption/interruption_detector.d.ts +59 -0
  70. package/dist/inference/interruption/interruption_detector.d.ts.map +1 -0
  71. package/dist/inference/interruption/interruption_detector.js +147 -0
  72. package/dist/inference/interruption/interruption_detector.js.map +1 -0
  73. package/dist/inference/interruption/interruption_stream.cjs +368 -0
  74. package/dist/inference/interruption/interruption_stream.cjs.map +1 -0
  75. package/dist/inference/interruption/interruption_stream.d.cts +46 -0
  76. package/dist/inference/interruption/interruption_stream.d.ts +46 -0
  77. package/dist/inference/interruption/interruption_stream.d.ts.map +1 -0
  78. package/dist/inference/interruption/interruption_stream.js +344 -0
  79. package/dist/inference/interruption/interruption_stream.js.map +1 -0
  80. package/dist/inference/interruption/types.cjs +17 -0
  81. package/dist/inference/interruption/types.cjs.map +1 -0
  82. package/dist/inference/interruption/types.d.cts +66 -0
  83. package/dist/inference/interruption/types.d.ts +66 -0
  84. package/dist/inference/interruption/types.d.ts.map +1 -0
  85. package/dist/inference/interruption/types.js +1 -0
  86. package/dist/inference/interruption/types.js.map +1 -0
  87. package/dist/inference/interruption/utils.cjs +130 -0
  88. package/dist/inference/interruption/utils.cjs.map +1 -0
  89. package/dist/inference/interruption/utils.d.cts +41 -0
  90. package/dist/inference/interruption/utils.d.ts +41 -0
  91. package/dist/inference/interruption/utils.d.ts.map +1 -0
  92. package/dist/inference/interruption/utils.js +105 -0
  93. package/dist/inference/interruption/utils.js.map +1 -0
  94. package/dist/inference/interruption/utils.test.cjs +105 -0
  95. package/dist/inference/interruption/utils.test.cjs.map +1 -0
  96. package/dist/inference/interruption/utils.test.js +104 -0
  97. package/dist/inference/interruption/utils.test.js.map +1 -0
  98. package/dist/inference/interruption/ws_transport.cjs +329 -0
  99. package/dist/inference/interruption/ws_transport.cjs.map +1 -0
  100. package/dist/inference/interruption/ws_transport.d.cts +33 -0
  101. package/dist/inference/interruption/ws_transport.d.ts +33 -0
  102. package/dist/inference/interruption/ws_transport.d.ts.map +1 -0
  103. package/dist/inference/interruption/ws_transport.js +295 -0
  104. package/dist/inference/interruption/ws_transport.js.map +1 -0
  105. package/dist/inference/llm.cjs +14 -10
  106. package/dist/inference/llm.cjs.map +1 -1
  107. package/dist/inference/llm.d.cts +2 -1
  108. package/dist/inference/llm.d.ts +2 -1
  109. package/dist/inference/llm.d.ts.map +1 -1
  110. package/dist/inference/llm.js +8 -10
  111. package/dist/inference/llm.js.map +1 -1
  112. package/dist/inference/stt.cjs +7 -2
  113. package/dist/inference/stt.cjs.map +1 -1
  114. package/dist/inference/stt.d.cts +2 -0
  115. package/dist/inference/stt.d.ts +2 -0
  116. package/dist/inference/stt.d.ts.map +1 -1
  117. package/dist/inference/stt.js +8 -3
  118. package/dist/inference/stt.js.map +1 -1
  119. package/dist/inference/tts.cjs +7 -2
  120. package/dist/inference/tts.cjs.map +1 -1
  121. package/dist/inference/tts.d.cts +2 -0
  122. package/dist/inference/tts.d.ts +2 -0
  123. package/dist/inference/tts.d.ts.map +1 -1
  124. package/dist/inference/tts.js +8 -3
  125. package/dist/inference/tts.js.map +1 -1
  126. package/dist/inference/utils.cjs +26 -7
  127. package/dist/inference/utils.cjs.map +1 -1
  128. package/dist/inference/utils.d.cts +13 -0
  129. package/dist/inference/utils.d.ts +13 -0
  130. package/dist/inference/utils.d.ts.map +1 -1
  131. package/dist/inference/utils.js +18 -2
  132. package/dist/inference/utils.js.map +1 -1
  133. package/dist/llm/chat_context.cjs +108 -2
  134. package/dist/llm/chat_context.cjs.map +1 -1
  135. package/dist/llm/chat_context.d.cts +28 -1
  136. package/dist/llm/chat_context.d.ts +28 -1
  137. package/dist/llm/chat_context.d.ts.map +1 -1
  138. package/dist/llm/chat_context.js +108 -2
  139. package/dist/llm/chat_context.js.map +1 -1
  140. package/dist/llm/chat_context.test.cjs +43 -0
  141. package/dist/llm/chat_context.test.cjs.map +1 -1
  142. package/dist/llm/chat_context.test.js +43 -0
  143. package/dist/llm/chat_context.test.js.map +1 -1
  144. package/dist/llm/index.cjs +2 -0
  145. package/dist/llm/index.cjs.map +1 -1
  146. package/dist/llm/index.d.cts +2 -2
  147. package/dist/llm/index.d.ts +2 -2
  148. package/dist/llm/index.d.ts.map +1 -1
  149. package/dist/llm/index.js +3 -1
  150. package/dist/llm/index.js.map +1 -1
  151. package/dist/llm/llm.cjs +16 -1
  152. package/dist/llm/llm.cjs.map +1 -1
  153. package/dist/llm/llm.d.cts +9 -0
  154. package/dist/llm/llm.d.ts +9 -0
  155. package/dist/llm/llm.d.ts.map +1 -1
  156. package/dist/llm/llm.js +16 -1
  157. package/dist/llm/llm.js.map +1 -1
  158. package/dist/llm/provider_format/index.d.cts +1 -1
  159. package/dist/llm/provider_format/index.d.ts +1 -1
  160. package/dist/llm/realtime.cjs +3 -0
  161. package/dist/llm/realtime.cjs.map +1 -1
  162. package/dist/llm/realtime.d.cts +1 -0
  163. package/dist/llm/realtime.d.ts +1 -0
  164. package/dist/llm/realtime.d.ts.map +1 -1
  165. package/dist/llm/realtime.js +3 -0
  166. package/dist/llm/realtime.js.map +1 -1
  167. package/dist/llm/tool_context.cjs +7 -0
  168. package/dist/llm/tool_context.cjs.map +1 -1
  169. package/dist/llm/tool_context.d.cts +10 -2
  170. package/dist/llm/tool_context.d.ts +10 -2
  171. package/dist/llm/tool_context.d.ts.map +1 -1
  172. package/dist/llm/tool_context.js +6 -0
  173. package/dist/llm/tool_context.js.map +1 -1
  174. package/dist/metrics/base.cjs.map +1 -1
  175. package/dist/metrics/base.d.cts +45 -1
  176. package/dist/metrics/base.d.ts +45 -1
  177. package/dist/metrics/base.d.ts.map +1 -1
  178. package/dist/metrics/index.cjs +5 -0
  179. package/dist/metrics/index.cjs.map +1 -1
  180. package/dist/metrics/index.d.cts +2 -1
  181. package/dist/metrics/index.d.ts +2 -1
  182. package/dist/metrics/index.d.ts.map +1 -1
  183. package/dist/metrics/index.js +6 -0
  184. package/dist/metrics/index.js.map +1 -1
  185. package/dist/metrics/model_usage.cjs +189 -0
  186. package/dist/metrics/model_usage.cjs.map +1 -0
  187. package/dist/metrics/model_usage.d.cts +92 -0
  188. package/dist/metrics/model_usage.d.ts +92 -0
  189. package/dist/metrics/model_usage.d.ts.map +1 -0
  190. package/dist/metrics/model_usage.js +164 -0
  191. package/dist/metrics/model_usage.js.map +1 -0
  192. package/dist/metrics/model_usage.test.cjs +474 -0
  193. package/dist/metrics/model_usage.test.cjs.map +1 -0
  194. package/dist/metrics/model_usage.test.js +476 -0
  195. package/dist/metrics/model_usage.test.js.map +1 -0
  196. package/dist/metrics/usage_collector.cjs +3 -0
  197. package/dist/metrics/usage_collector.cjs.map +1 -1
  198. package/dist/metrics/usage_collector.d.cts +9 -0
  199. package/dist/metrics/usage_collector.d.ts +9 -0
  200. package/dist/metrics/usage_collector.d.ts.map +1 -1
  201. package/dist/metrics/usage_collector.js +3 -0
  202. package/dist/metrics/usage_collector.js.map +1 -1
  203. package/dist/metrics/utils.cjs +9 -0
  204. package/dist/metrics/utils.cjs.map +1 -1
  205. package/dist/metrics/utils.d.ts.map +1 -1
  206. package/dist/metrics/utils.js +9 -0
  207. package/dist/metrics/utils.js.map +1 -1
  208. package/dist/stream/multi_input_stream.test.cjs +4 -0
  209. package/dist/stream/multi_input_stream.test.cjs.map +1 -1
  210. package/dist/stream/multi_input_stream.test.js +5 -1
  211. package/dist/stream/multi_input_stream.test.js.map +1 -1
  212. package/dist/stream/stream_channel.cjs +31 -0
  213. package/dist/stream/stream_channel.cjs.map +1 -1
  214. package/dist/stream/stream_channel.d.cts +4 -2
  215. package/dist/stream/stream_channel.d.ts +4 -2
  216. package/dist/stream/stream_channel.d.ts.map +1 -1
  217. package/dist/stream/stream_channel.js +31 -0
  218. package/dist/stream/stream_channel.js.map +1 -1
  219. package/dist/stt/stt.cjs +34 -2
  220. package/dist/stt/stt.cjs.map +1 -1
  221. package/dist/stt/stt.d.cts +22 -0
  222. package/dist/stt/stt.d.ts +22 -0
  223. package/dist/stt/stt.d.ts.map +1 -1
  224. package/dist/stt/stt.js +34 -2
  225. package/dist/stt/stt.js.map +1 -1
  226. package/dist/telemetry/otel_http_exporter.cjs +24 -5
  227. package/dist/telemetry/otel_http_exporter.cjs.map +1 -1
  228. package/dist/telemetry/otel_http_exporter.d.cts +1 -0
  229. package/dist/telemetry/otel_http_exporter.d.ts +1 -0
  230. package/dist/telemetry/otel_http_exporter.d.ts.map +1 -1
  231. package/dist/telemetry/otel_http_exporter.js +24 -5
  232. package/dist/telemetry/otel_http_exporter.js.map +1 -1
  233. package/dist/telemetry/trace_types.cjs +5 -5
  234. package/dist/telemetry/trace_types.cjs.map +1 -1
  235. package/dist/telemetry/trace_types.d.cts +9 -5
  236. package/dist/telemetry/trace_types.d.ts +9 -5
  237. package/dist/telemetry/trace_types.d.ts.map +1 -1
  238. package/dist/telemetry/trace_types.js +5 -5
  239. package/dist/telemetry/trace_types.js.map +1 -1
  240. package/dist/telemetry/traces.cjs +47 -8
  241. package/dist/telemetry/traces.cjs.map +1 -1
  242. package/dist/telemetry/traces.d.ts.map +1 -1
  243. package/dist/telemetry/traces.js +47 -8
  244. package/dist/telemetry/traces.js.map +1 -1
  245. package/dist/tts/tts.cjs +64 -2
  246. package/dist/tts/tts.cjs.map +1 -1
  247. package/dist/tts/tts.d.cts +34 -0
  248. package/dist/tts/tts.d.ts +34 -0
  249. package/dist/tts/tts.d.ts.map +1 -1
  250. package/dist/tts/tts.js +64 -2
  251. package/dist/tts/tts.js.map +1 -1
  252. package/dist/utils.cjs +1 -0
  253. package/dist/utils.cjs.map +1 -1
  254. package/dist/utils.d.ts.map +1 -1
  255. package/dist/utils.js +1 -0
  256. package/dist/utils.js.map +1 -1
  257. package/dist/version.cjs +1 -1
  258. package/dist/version.js +1 -1
  259. package/dist/voice/agent.cjs +34 -4
  260. package/dist/voice/agent.cjs.map +1 -1
  261. package/dist/voice/agent.d.cts +11 -2
  262. package/dist/voice/agent.d.ts +11 -2
  263. package/dist/voice/agent.d.ts.map +1 -1
  264. package/dist/voice/agent.js +34 -4
  265. package/dist/voice/agent.js.map +1 -1
  266. package/dist/voice/agent_activity.cjs +292 -44
  267. package/dist/voice/agent_activity.cjs.map +1 -1
  268. package/dist/voice/agent_activity.d.cts +27 -6
  269. package/dist/voice/agent_activity.d.ts +27 -6
  270. package/dist/voice/agent_activity.d.ts.map +1 -1
  271. package/dist/voice/agent_activity.js +293 -45
  272. package/dist/voice/agent_activity.js.map +1 -1
  273. package/dist/voice/agent_session.cjs +105 -48
  274. package/dist/voice/agent_session.cjs.map +1 -1
  275. package/dist/voice/agent_session.d.cts +90 -20
  276. package/dist/voice/agent_session.d.ts +90 -20
  277. package/dist/voice/agent_session.d.ts.map +1 -1
  278. package/dist/voice/agent_session.js +105 -46
  279. package/dist/voice/agent_session.js.map +1 -1
  280. package/dist/voice/audio_recognition.cjs +287 -6
  281. package/dist/voice/audio_recognition.cjs.map +1 -1
  282. package/dist/voice/audio_recognition.d.cts +42 -3
  283. package/dist/voice/audio_recognition.d.ts +42 -3
  284. package/dist/voice/audio_recognition.d.ts.map +1 -1
  285. package/dist/voice/audio_recognition.js +289 -7
  286. package/dist/voice/audio_recognition.js.map +1 -1
  287. package/dist/voice/client_events.cjs +554 -0
  288. package/dist/voice/client_events.cjs.map +1 -0
  289. package/dist/voice/client_events.d.cts +195 -0
  290. package/dist/voice/client_events.d.ts +195 -0
  291. package/dist/voice/client_events.d.ts.map +1 -0
  292. package/dist/voice/client_events.js +548 -0
  293. package/dist/voice/client_events.js.map +1 -0
  294. package/dist/voice/events.cjs +1 -0
  295. package/dist/voice/events.cjs.map +1 -1
  296. package/dist/voice/events.d.cts +8 -5
  297. package/dist/voice/events.d.ts +8 -5
  298. package/dist/voice/events.d.ts.map +1 -1
  299. package/dist/voice/events.js +1 -0
  300. package/dist/voice/events.js.map +1 -1
  301. package/dist/voice/generation.cjs +43 -8
  302. package/dist/voice/generation.cjs.map +1 -1
  303. package/dist/voice/generation.d.cts +3 -3
  304. package/dist/voice/generation.d.ts +3 -3
  305. package/dist/voice/generation.d.ts.map +1 -1
  306. package/dist/voice/generation.js +43 -8
  307. package/dist/voice/generation.js.map +1 -1
  308. package/dist/voice/index.cjs +1 -0
  309. package/dist/voice/index.cjs.map +1 -1
  310. package/dist/voice/index.d.cts +1 -0
  311. package/dist/voice/index.d.ts +1 -0
  312. package/dist/voice/index.d.ts.map +1 -1
  313. package/dist/voice/index.js +1 -0
  314. package/dist/voice/index.js.map +1 -1
  315. package/dist/voice/report.cjs +20 -8
  316. package/dist/voice/report.cjs.map +1 -1
  317. package/dist/voice/report.d.cts +5 -0
  318. package/dist/voice/report.d.ts +5 -0
  319. package/dist/voice/report.d.ts.map +1 -1
  320. package/dist/voice/report.js +20 -8
  321. package/dist/voice/report.js.map +1 -1
  322. package/dist/voice/report.test.cjs +106 -0
  323. package/dist/voice/report.test.cjs.map +1 -0
  324. package/dist/voice/report.test.js +105 -0
  325. package/dist/voice/report.test.js.map +1 -0
  326. package/dist/voice/room_io/room_io.cjs +16 -41
  327. package/dist/voice/room_io/room_io.cjs.map +1 -1
  328. package/dist/voice/room_io/room_io.d.cts +4 -9
  329. package/dist/voice/room_io/room_io.d.ts +4 -9
  330. package/dist/voice/room_io/room_io.d.ts.map +1 -1
  331. package/dist/voice/room_io/room_io.js +17 -43
  332. package/dist/voice/room_io/room_io.js.map +1 -1
  333. package/dist/voice/testing/fake_llm.cjs +127 -0
  334. package/dist/voice/testing/fake_llm.cjs.map +1 -0
  335. package/dist/voice/testing/fake_llm.d.cts +30 -0
  336. package/dist/voice/testing/fake_llm.d.ts +30 -0
  337. package/dist/voice/testing/fake_llm.d.ts.map +1 -0
  338. package/dist/voice/testing/fake_llm.js +103 -0
  339. package/dist/voice/testing/fake_llm.js.map +1 -0
  340. package/dist/voice/testing/index.cjs +3 -0
  341. package/dist/voice/testing/index.cjs.map +1 -1
  342. package/dist/voice/testing/index.d.cts +1 -0
  343. package/dist/voice/testing/index.d.ts +1 -0
  344. package/dist/voice/testing/index.d.ts.map +1 -1
  345. package/dist/voice/testing/index.js +2 -0
  346. package/dist/voice/testing/index.js.map +1 -1
  347. package/dist/voice/turn_config/endpointing.cjs +33 -0
  348. package/dist/voice/turn_config/endpointing.cjs.map +1 -0
  349. package/dist/voice/turn_config/endpointing.d.cts +30 -0
  350. package/dist/voice/turn_config/endpointing.d.ts +30 -0
  351. package/dist/voice/turn_config/endpointing.d.ts.map +1 -0
  352. package/dist/voice/turn_config/endpointing.js +9 -0
  353. package/dist/voice/turn_config/endpointing.js.map +1 -0
  354. package/dist/voice/turn_config/interruption.cjs +37 -0
  355. package/dist/voice/turn_config/interruption.cjs.map +1 -0
  356. package/dist/voice/turn_config/interruption.d.cts +53 -0
  357. package/dist/voice/turn_config/interruption.d.ts +53 -0
  358. package/dist/voice/turn_config/interruption.d.ts.map +1 -0
  359. package/dist/voice/turn_config/interruption.js +13 -0
  360. package/dist/voice/turn_config/interruption.js.map +1 -0
  361. package/dist/voice/turn_config/turn_handling.cjs +35 -0
  362. package/dist/voice/turn_config/turn_handling.cjs.map +1 -0
  363. package/dist/voice/turn_config/turn_handling.d.cts +36 -0
  364. package/dist/voice/turn_config/turn_handling.d.ts +36 -0
  365. package/dist/voice/turn_config/turn_handling.d.ts.map +1 -0
  366. package/dist/voice/turn_config/turn_handling.js +11 -0
  367. package/dist/voice/turn_config/turn_handling.js.map +1 -0
  368. package/dist/voice/turn_config/utils.cjs +97 -0
  369. package/dist/voice/turn_config/utils.cjs.map +1 -0
  370. package/dist/voice/turn_config/utils.d.cts +25 -0
  371. package/dist/voice/turn_config/utils.d.ts +25 -0
  372. package/dist/voice/turn_config/utils.d.ts.map +1 -0
  373. package/dist/voice/turn_config/utils.js +73 -0
  374. package/dist/voice/turn_config/utils.js.map +1 -0
  375. package/dist/voice/turn_config/utils.test.cjs +86 -0
  376. package/dist/voice/turn_config/utils.test.cjs.map +1 -0
  377. package/dist/voice/turn_config/utils.test.js +85 -0
  378. package/dist/voice/turn_config/utils.test.js.map +1 -0
  379. package/dist/voice/wire_format.cjs +798 -0
  380. package/dist/voice/wire_format.cjs.map +1 -0
  381. package/dist/voice/wire_format.d.cts +5503 -0
  382. package/dist/voice/wire_format.d.ts +5503 -0
  383. package/dist/voice/wire_format.d.ts.map +1 -0
  384. package/dist/voice/wire_format.js +728 -0
  385. package/dist/voice/wire_format.js.map +1 -0
  386. package/package.json +2 -1
  387. package/src/beta/index.ts +9 -0
  388. package/src/beta/workflows/index.ts +9 -0
  389. package/src/beta/workflows/task_group.ts +194 -0
  390. package/src/constants.ts +13 -0
  391. package/src/index.ts +2 -1
  392. package/src/inference/interruption/defaults.ts +51 -0
  393. package/src/inference/interruption/errors.ts +25 -0
  394. package/src/inference/interruption/http_transport.ts +187 -0
  395. package/src/inference/interruption/interruption_cache_entry.ts +50 -0
  396. package/src/inference/interruption/interruption_detector.ts +188 -0
  397. package/src/inference/interruption/interruption_stream.ts +467 -0
  398. package/src/inference/interruption/types.ts +84 -0
  399. package/src/inference/interruption/utils.test.ts +132 -0
  400. package/src/inference/interruption/utils.ts +137 -0
  401. package/src/inference/interruption/ws_transport.ts +402 -0
  402. package/src/inference/llm.ts +9 -12
  403. package/src/inference/stt.ts +10 -3
  404. package/src/inference/tts.ts +10 -3
  405. package/src/inference/utils.ts +29 -1
  406. package/src/llm/chat_context.test.ts +48 -0
  407. package/src/llm/chat_context.ts +161 -0
  408. package/src/llm/index.ts +2 -0
  409. package/src/llm/llm.ts +16 -0
  410. package/src/llm/realtime.ts +4 -0
  411. package/src/llm/tool_context.ts +14 -0
  412. package/src/metrics/base.ts +48 -1
  413. package/src/metrics/index.ts +11 -0
  414. package/src/metrics/model_usage.test.ts +545 -0
  415. package/src/metrics/model_usage.ts +262 -0
  416. package/src/metrics/usage_collector.ts +11 -0
  417. package/src/metrics/utils.ts +11 -0
  418. package/src/stream/multi_input_stream.test.ts +6 -1
  419. package/src/stream/stream_channel.ts +34 -2
  420. package/src/stt/stt.ts +38 -0
  421. package/src/telemetry/otel_http_exporter.ts +28 -5
  422. package/src/telemetry/trace_types.ts +11 -8
  423. package/src/telemetry/traces.ts +111 -54
  424. package/src/tts/tts.ts +69 -1
  425. package/src/utils.ts +5 -0
  426. package/src/voice/agent.ts +41 -3
  427. package/src/voice/agent_activity.ts +371 -34
  428. package/src/voice/agent_session.ts +207 -59
  429. package/src/voice/audio_recognition.ts +385 -9
  430. package/src/voice/client_events.ts +838 -0
  431. package/src/voice/events.ts +14 -4
  432. package/src/voice/generation.ts +52 -9
  433. package/src/voice/index.ts +1 -0
  434. package/src/voice/report.test.ts +117 -0
  435. package/src/voice/report.ts +29 -6
  436. package/src/voice/room_io/room_io.ts +21 -64
  437. package/src/voice/testing/fake_llm.ts +138 -0
  438. package/src/voice/testing/index.ts +2 -0
  439. package/src/voice/turn_config/endpointing.ts +33 -0
  440. package/src/voice/turn_config/interruption.ts +56 -0
  441. package/src/voice/turn_config/turn_handling.ts +45 -0
  442. package/src/voice/turn_config/utils.test.ts +100 -0
  443. package/src/voice/turn_config/utils.ts +103 -0
  444. package/src/voice/wire_format.ts +827 -0
@@ -0,0 +1,798 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var wire_format_exports = {};
20
+ __export(wire_format_exports, {
21
+ agentHandoffToWire: () => agentHandoffToWire,
22
+ agentHandoffWireSchema: () => agentHandoffWireSchema,
23
+ agentMetricsToWire: () => agentMetricsToWire,
24
+ agentMetricsWireSchema: () => agentMetricsWireSchema,
25
+ agentSessionUsageToWire: () => agentSessionUsageToWire,
26
+ agentSessionUsageWireSchema: () => agentSessionUsageWireSchema,
27
+ chatItemToWire: () => chatItemToWire,
28
+ chatItemWireSchema: () => chatItemWireSchema,
29
+ chatMessageToWire: () => chatMessageToWire,
30
+ chatMessageWireSchema: () => chatMessageWireSchema,
31
+ clientAgentStateChangedSchema: () => clientAgentStateChangedSchema,
32
+ clientConversationItemAddedSchema: () => clientConversationItemAddedSchema,
33
+ clientErrorSchema: () => clientErrorSchema,
34
+ clientEventSchema: () => clientEventSchema,
35
+ clientFunctionToolsExecutedSchema: () => clientFunctionToolsExecutedSchema,
36
+ clientMetricsCollectedSchema: () => clientMetricsCollectedSchema,
37
+ clientSessionUsageSchema: () => clientSessionUsageSchema,
38
+ clientUserInputTranscribedSchema: () => clientUserInputTranscribedSchema,
39
+ clientUserOverlappingSpeechSchema: () => clientUserOverlappingSpeechSchema,
40
+ clientUserStateChangedSchema: () => clientUserStateChangedSchema,
41
+ eouMetricsWireSchema: () => eouMetricsWireSchema,
42
+ functionCallOutputToWire: () => functionCallOutputToWire,
43
+ functionCallOutputWireSchema: () => functionCallOutputWireSchema,
44
+ functionCallToWire: () => functionCallToWire,
45
+ functionCallWireSchema: () => functionCallWireSchema,
46
+ getAgentInfoResponseSchema: () => getAgentInfoResponseSchema,
47
+ getChatHistoryResponseSchema: () => getChatHistoryResponseSchema,
48
+ getRTCStatsResponseSchema: () => getRTCStatsResponseSchema,
49
+ getSessionStateResponseSchema: () => getSessionStateResponseSchema,
50
+ getSessionUsageResponseSchema: () => getSessionUsageResponseSchema,
51
+ interruptionMetricsWireSchema: () => interruptionMetricsWireSchema,
52
+ interruptionModelUsageWireSchema: () => interruptionModelUsageWireSchema,
53
+ llmMetricsWireSchema: () => llmMetricsWireSchema,
54
+ llmModelUsageWireSchema: () => llmModelUsageWireSchema,
55
+ modelUsageToWire: () => modelUsageToWire,
56
+ modelUsageWireSchema: () => modelUsageWireSchema,
57
+ msToS: () => msToS,
58
+ realtimeModelMetricsWireSchema: () => realtimeModelMetricsWireSchema,
59
+ sendMessageRequestSchema: () => sendMessageRequestSchema,
60
+ sendMessageResponseSchema: () => sendMessageResponseSchema,
61
+ streamRequestSchema: () => streamRequestSchema,
62
+ streamResponseSchema: () => streamResponseSchema,
63
+ sttMetricsWireSchema: () => sttMetricsWireSchema,
64
+ sttModelUsageWireSchema: () => sttModelUsageWireSchema,
65
+ ttsMetricsWireSchema: () => ttsMetricsWireSchema,
66
+ ttsModelUsageWireSchema: () => ttsModelUsageWireSchema,
67
+ vadMetricsWireSchema: () => vadMetricsWireSchema
68
+ });
69
+ module.exports = __toCommonJS(wire_format_exports);
70
+ var import_zod = require("zod");
71
+ function msToS(ms) {
72
+ return ms / 1e3;
73
+ }
74
+ function omitUndefined(obj) {
75
+ const result = {};
76
+ for (const [k, v] of Object.entries(obj)) {
77
+ if (v !== void 0) {
78
+ result[k] = v;
79
+ }
80
+ }
81
+ return result;
82
+ }
83
+ function imageContentToWire(img) {
84
+ return omitUndefined({
85
+ id: img.id,
86
+ type: img.type,
87
+ image: typeof img.image === "string" ? img.image : void 0,
88
+ inference_detail: img.inferenceDetail,
89
+ inference_width: img.inferenceWidth,
90
+ inference_height: img.inferenceHeight,
91
+ mime_type: img.mimeType
92
+ });
93
+ }
94
+ function audioContentToWire(audio) {
95
+ return omitUndefined({
96
+ type: audio.type,
97
+ transcript: audio.transcript
98
+ });
99
+ }
100
+ function chatContentToWire(content) {
101
+ if (typeof content === "string") return content;
102
+ if (content.type === "image_content") return imageContentToWire(content);
103
+ return audioContentToWire(content);
104
+ }
105
+ function metricsReportToWire(m) {
106
+ return omitUndefined({
107
+ started_speaking_at: m.startedSpeakingAt,
108
+ stopped_speaking_at: m.stoppedSpeakingAt,
109
+ transcription_delay: m.transcriptionDelay,
110
+ end_of_turn_delay: m.endOfTurnDelay,
111
+ on_user_turn_completed_delay: m.onUserTurnCompletedDelay,
112
+ llm_node_ttft: m.llmNodeTtft,
113
+ tts_node_ttfb: m.ttsNodeTtfb,
114
+ e2e_latency: m.e2eLatency
115
+ });
116
+ }
117
+ function chatMessageToWire(msg) {
118
+ const result = {
119
+ id: msg.id,
120
+ type: msg.type,
121
+ role: msg.role,
122
+ content: msg.content.map(chatContentToWire),
123
+ interrupted: msg.interrupted,
124
+ created_at: msToS(msg.createdAt)
125
+ };
126
+ if (msg.transcriptConfidence !== void 0) {
127
+ result.transcript_confidence = msg.transcriptConfidence;
128
+ }
129
+ if (Object.keys(msg.metrics).length > 0) {
130
+ result.metrics = metricsReportToWire(msg.metrics);
131
+ }
132
+ if (Object.keys(msg.extra).length > 0) {
133
+ result.extra = msg.extra;
134
+ }
135
+ return result;
136
+ }
137
+ function functionCallToWire(fc) {
138
+ const result = {
139
+ id: fc.id,
140
+ type: fc.type,
141
+ call_id: fc.callId,
142
+ arguments: fc.args,
143
+ name: fc.name,
144
+ created_at: msToS(fc.createdAt)
145
+ };
146
+ if (Object.keys(fc.extra).length > 0) {
147
+ result.extra = fc.extra;
148
+ }
149
+ if (fc.groupId !== void 0) {
150
+ result.group_id = fc.groupId;
151
+ }
152
+ return result;
153
+ }
154
+ function functionCallOutputToWire(fco) {
155
+ return {
156
+ id: fco.id,
157
+ type: fco.type,
158
+ name: fco.name,
159
+ call_id: fco.callId,
160
+ output: fco.output,
161
+ is_error: fco.isError,
162
+ created_at: msToS(fco.createdAt)
163
+ };
164
+ }
165
+ function agentHandoffToWire(ah) {
166
+ const result = {
167
+ id: ah.id,
168
+ type: ah.type,
169
+ new_agent_id: ah.newAgentId,
170
+ created_at: msToS(ah.createdAt)
171
+ };
172
+ if (ah.oldAgentId !== void 0) {
173
+ result.old_agent_id = ah.oldAgentId;
174
+ }
175
+ return result;
176
+ }
177
+ function chatItemToWire(item) {
178
+ switch (item.type) {
179
+ case "message":
180
+ return chatMessageToWire(item);
181
+ case "function_call":
182
+ return functionCallToWire(item);
183
+ case "function_call_output":
184
+ return functionCallOutputToWire(item);
185
+ case "agent_handoff":
186
+ return agentHandoffToWire(item);
187
+ }
188
+ }
189
+ function metadataToWire(m) {
190
+ if (!m) return null;
191
+ return omitUndefined({
192
+ model_name: m.modelName,
193
+ model_provider: m.modelProvider
194
+ });
195
+ }
196
+ function llmMetricsToWire(m) {
197
+ return omitUndefined({
198
+ type: m.type,
199
+ label: m.label,
200
+ request_id: m.requestId,
201
+ timestamp: msToS(m.timestamp),
202
+ duration: msToS(m.durationMs),
203
+ ttft: msToS(m.ttftMs),
204
+ cancelled: m.cancelled,
205
+ completion_tokens: m.completionTokens,
206
+ prompt_tokens: m.promptTokens,
207
+ prompt_cached_tokens: m.promptCachedTokens,
208
+ total_tokens: m.totalTokens,
209
+ tokens_per_second: m.tokensPerSecond,
210
+ speech_id: m.speechId,
211
+ metadata: metadataToWire(m.metadata)
212
+ });
213
+ }
214
+ function sttMetricsToWire(m) {
215
+ return omitUndefined({
216
+ type: m.type,
217
+ label: m.label,
218
+ request_id: m.requestId,
219
+ timestamp: msToS(m.timestamp),
220
+ duration: msToS(m.durationMs),
221
+ audio_duration: msToS(m.audioDurationMs),
222
+ input_tokens: m.inputTokens,
223
+ output_tokens: m.outputTokens,
224
+ streamed: m.streamed,
225
+ metadata: metadataToWire(m.metadata)
226
+ });
227
+ }
228
+ function ttsMetricsToWire(m) {
229
+ return omitUndefined({
230
+ type: m.type,
231
+ label: m.label,
232
+ request_id: m.requestId,
233
+ timestamp: msToS(m.timestamp),
234
+ ttfb: msToS(m.ttfbMs),
235
+ duration: msToS(m.durationMs),
236
+ audio_duration: msToS(m.audioDurationMs),
237
+ cancelled: m.cancelled,
238
+ characters_count: m.charactersCount,
239
+ input_tokens: m.inputTokens,
240
+ output_tokens: m.outputTokens,
241
+ streamed: m.streamed,
242
+ segment_id: m.segmentId,
243
+ speech_id: m.speechId,
244
+ metadata: metadataToWire(m.metadata)
245
+ });
246
+ }
247
+ function vadMetricsToWire(m) {
248
+ return {
249
+ type: m.type,
250
+ label: m.label,
251
+ timestamp: msToS(m.timestamp),
252
+ idle_time: msToS(m.idleTimeMs),
253
+ inference_duration_total: msToS(m.inferenceDurationTotalMs),
254
+ inference_count: m.inferenceCount
255
+ };
256
+ }
257
+ function eouMetricsToWire(m) {
258
+ return omitUndefined({
259
+ type: m.type,
260
+ timestamp: msToS(m.timestamp),
261
+ end_of_utterance_delay: msToS(m.endOfUtteranceDelayMs),
262
+ transcription_delay: msToS(m.transcriptionDelayMs),
263
+ on_user_turn_completed_delay: msToS(m.onUserTurnCompletedDelayMs),
264
+ speech_id: m.speechId
265
+ });
266
+ }
267
+ function cachedTokenDetailsToWire(d) {
268
+ return {
269
+ audio_tokens: d.audioTokens,
270
+ text_tokens: d.textTokens,
271
+ image_tokens: d.imageTokens
272
+ };
273
+ }
274
+ function inputTokenDetailsToWire(d) {
275
+ return omitUndefined({
276
+ audio_tokens: d.audioTokens,
277
+ text_tokens: d.textTokens,
278
+ image_tokens: d.imageTokens,
279
+ cached_tokens: d.cachedTokens,
280
+ cached_tokens_details: d.cachedTokensDetails ? cachedTokenDetailsToWire(d.cachedTokensDetails) : void 0
281
+ });
282
+ }
283
+ function outputTokenDetailsToWire(d) {
284
+ return {
285
+ text_tokens: d.textTokens,
286
+ audio_tokens: d.audioTokens,
287
+ image_tokens: d.imageTokens
288
+ };
289
+ }
290
+ function realtimeModelMetricsToWire(m) {
291
+ return omitUndefined({
292
+ type: m.type,
293
+ label: m.label,
294
+ request_id: m.requestId,
295
+ timestamp: msToS(m.timestamp),
296
+ duration: msToS(m.durationMs),
297
+ session_duration: m.sessionDurationMs !== void 0 ? msToS(m.sessionDurationMs) : void 0,
298
+ ttft: msToS(m.ttftMs),
299
+ cancelled: m.cancelled,
300
+ input_tokens: m.inputTokens,
301
+ output_tokens: m.outputTokens,
302
+ total_tokens: m.totalTokens,
303
+ tokens_per_second: m.tokensPerSecond,
304
+ input_token_details: inputTokenDetailsToWire(m.inputTokenDetails),
305
+ output_token_details: outputTokenDetailsToWire(m.outputTokenDetails),
306
+ metadata: metadataToWire(m.metadata)
307
+ });
308
+ }
309
+ function interruptionMetricsToWire(m) {
310
+ return omitUndefined({
311
+ type: m.type,
312
+ timestamp: msToS(m.timestamp),
313
+ total_duration: msToS(m.totalDuration),
314
+ prediction_duration: msToS(m.predictionDuration),
315
+ detection_delay: msToS(m.detectionDelay),
316
+ num_interruptions: m.numInterruptions,
317
+ num_backchannels: m.numBackchannels,
318
+ num_requests: m.numRequests,
319
+ metadata: metadataToWire(m.metadata)
320
+ });
321
+ }
322
+ function agentMetricsToWire(m) {
323
+ switch (m.type) {
324
+ case "llm_metrics":
325
+ return llmMetricsToWire(m);
326
+ case "stt_metrics":
327
+ return sttMetricsToWire(m);
328
+ case "tts_metrics":
329
+ return ttsMetricsToWire(m);
330
+ case "vad_metrics":
331
+ return vadMetricsToWire(m);
332
+ case "eou_metrics":
333
+ return eouMetricsToWire(m);
334
+ case "realtime_model_metrics":
335
+ return realtimeModelMetricsToWire(m);
336
+ case "interruption_metrics":
337
+ return interruptionMetricsToWire(m);
338
+ }
339
+ }
340
+ function llmModelUsageToWire(u) {
341
+ return {
342
+ type: u.type,
343
+ provider: u.provider ?? "",
344
+ model: u.model ?? "",
345
+ input_tokens: u.inputTokens ?? 0,
346
+ input_cached_tokens: u.inputCachedTokens ?? 0,
347
+ input_audio_tokens: u.inputAudioTokens ?? 0,
348
+ input_cached_audio_tokens: u.inputCachedAudioTokens ?? 0,
349
+ input_text_tokens: u.inputTextTokens ?? 0,
350
+ input_cached_text_tokens: u.inputCachedTextTokens ?? 0,
351
+ input_image_tokens: u.inputImageTokens ?? 0,
352
+ input_cached_image_tokens: u.inputCachedImageTokens ?? 0,
353
+ output_tokens: u.outputTokens ?? 0,
354
+ output_audio_tokens: u.outputAudioTokens ?? 0,
355
+ output_text_tokens: u.outputTextTokens ?? 0,
356
+ session_duration: msToS(u.sessionDurationMs ?? 0)
357
+ };
358
+ }
359
+ function ttsModelUsageToWire(u) {
360
+ return {
361
+ type: u.type,
362
+ provider: u.provider ?? "",
363
+ model: u.model ?? "",
364
+ input_tokens: u.inputTokens ?? 0,
365
+ output_tokens: u.outputTokens ?? 0,
366
+ characters_count: u.charactersCount ?? 0,
367
+ audio_duration: msToS(u.audioDurationMs ?? 0)
368
+ };
369
+ }
370
+ function sttModelUsageToWire(u) {
371
+ return {
372
+ type: u.type,
373
+ provider: u.provider ?? "",
374
+ model: u.model ?? "",
375
+ input_tokens: u.inputTokens ?? 0,
376
+ output_tokens: u.outputTokens ?? 0,
377
+ audio_duration: msToS(u.audioDurationMs ?? 0)
378
+ };
379
+ }
380
+ function interruptionModelUsageToWire(u) {
381
+ return {
382
+ type: u.type,
383
+ provider: u.provider ?? "",
384
+ model: u.model ?? "",
385
+ total_requests: u.totalRequests ?? 0
386
+ };
387
+ }
388
+ function modelUsageToWire(u) {
389
+ switch (u.type) {
390
+ case "llm_usage":
391
+ return llmModelUsageToWire(u);
392
+ case "tts_usage":
393
+ return ttsModelUsageToWire(u);
394
+ case "stt_usage":
395
+ return sttModelUsageToWire(u);
396
+ case "interruption_usage":
397
+ return interruptionModelUsageToWire(u);
398
+ default:
399
+ return u;
400
+ }
401
+ }
402
+ function agentSessionUsageToWire(u) {
403
+ return {
404
+ model_usage: u.modelUsage.map(modelUsageToWire)
405
+ };
406
+ }
407
+ const imageContentWireSchema = import_zod.z.object({
408
+ id: import_zod.z.string(),
409
+ type: import_zod.z.literal("image_content"),
410
+ image: import_zod.z.string(),
411
+ inference_detail: import_zod.z.enum(["auto", "high", "low"]).optional(),
412
+ inference_width: import_zod.z.number().optional(),
413
+ inference_height: import_zod.z.number().optional(),
414
+ mime_type: import_zod.z.string().optional()
415
+ });
416
+ const audioContentWireSchema = import_zod.z.object({
417
+ type: import_zod.z.literal("audio_content"),
418
+ transcript: import_zod.z.string().nullable().optional()
419
+ });
420
+ const chatContentWireSchema = import_zod.z.union([import_zod.z.string(), imageContentWireSchema, audioContentWireSchema]);
421
+ const metricsReportWireSchema = import_zod.z.object({
422
+ started_speaking_at: import_zod.z.number().optional(),
423
+ stopped_speaking_at: import_zod.z.number().optional(),
424
+ transcription_delay: import_zod.z.number().optional(),
425
+ end_of_turn_delay: import_zod.z.number().optional(),
426
+ on_user_turn_completed_delay: import_zod.z.number().optional(),
427
+ llm_node_ttft: import_zod.z.number().optional(),
428
+ tts_node_ttfb: import_zod.z.number().optional(),
429
+ e2e_latency: import_zod.z.number().optional()
430
+ }).optional();
431
+ const chatMessageWireSchema = import_zod.z.object({
432
+ id: import_zod.z.string(),
433
+ type: import_zod.z.literal("message"),
434
+ role: import_zod.z.enum(["developer", "system", "user", "assistant"]),
435
+ content: import_zod.z.array(chatContentWireSchema),
436
+ interrupted: import_zod.z.boolean(),
437
+ created_at: import_zod.z.number(),
438
+ transcript_confidence: import_zod.z.number().optional(),
439
+ metrics: metricsReportWireSchema,
440
+ extra: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional()
441
+ });
442
+ const functionCallWireSchema = import_zod.z.object({
443
+ id: import_zod.z.string(),
444
+ type: import_zod.z.literal("function_call"),
445
+ call_id: import_zod.z.string(),
446
+ arguments: import_zod.z.string(),
447
+ name: import_zod.z.string(),
448
+ created_at: import_zod.z.number(),
449
+ extra: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional(),
450
+ group_id: import_zod.z.string().optional()
451
+ });
452
+ const functionCallOutputWireSchema = import_zod.z.object({
453
+ id: import_zod.z.string(),
454
+ type: import_zod.z.literal("function_call_output"),
455
+ name: import_zod.z.string(),
456
+ call_id: import_zod.z.string(),
457
+ output: import_zod.z.string(),
458
+ is_error: import_zod.z.boolean(),
459
+ created_at: import_zod.z.number()
460
+ });
461
+ const agentHandoffWireSchema = import_zod.z.object({
462
+ id: import_zod.z.string(),
463
+ type: import_zod.z.literal("agent_handoff"),
464
+ new_agent_id: import_zod.z.string(),
465
+ created_at: import_zod.z.number(),
466
+ old_agent_id: import_zod.z.string().optional()
467
+ });
468
+ const chatItemWireSchema = import_zod.z.discriminatedUnion("type", [
469
+ chatMessageWireSchema,
470
+ functionCallWireSchema,
471
+ functionCallOutputWireSchema,
472
+ agentHandoffWireSchema
473
+ ]);
474
+ const metadataWireSchema = import_zod.z.object({
475
+ model_name: import_zod.z.string().optional(),
476
+ model_provider: import_zod.z.string().optional()
477
+ }).nullable().optional();
478
+ const llmMetricsWireSchema = import_zod.z.object({
479
+ type: import_zod.z.literal("llm_metrics"),
480
+ label: import_zod.z.string(),
481
+ request_id: import_zod.z.string(),
482
+ timestamp: import_zod.z.number(),
483
+ duration: import_zod.z.number(),
484
+ ttft: import_zod.z.number(),
485
+ cancelled: import_zod.z.boolean(),
486
+ completion_tokens: import_zod.z.number(),
487
+ prompt_tokens: import_zod.z.number(),
488
+ prompt_cached_tokens: import_zod.z.number(),
489
+ total_tokens: import_zod.z.number(),
490
+ tokens_per_second: import_zod.z.number(),
491
+ speech_id: import_zod.z.string().nullable().optional(),
492
+ metadata: metadataWireSchema
493
+ });
494
+ const sttMetricsWireSchema = import_zod.z.object({
495
+ type: import_zod.z.literal("stt_metrics"),
496
+ label: import_zod.z.string(),
497
+ request_id: import_zod.z.string(),
498
+ timestamp: import_zod.z.number(),
499
+ duration: import_zod.z.number(),
500
+ audio_duration: import_zod.z.number(),
501
+ input_tokens: import_zod.z.number().optional(),
502
+ output_tokens: import_zod.z.number().optional(),
503
+ streamed: import_zod.z.boolean(),
504
+ metadata: metadataWireSchema
505
+ });
506
+ const ttsMetricsWireSchema = import_zod.z.object({
507
+ type: import_zod.z.literal("tts_metrics"),
508
+ label: import_zod.z.string(),
509
+ request_id: import_zod.z.string(),
510
+ timestamp: import_zod.z.number(),
511
+ ttfb: import_zod.z.number(),
512
+ duration: import_zod.z.number(),
513
+ audio_duration: import_zod.z.number(),
514
+ cancelled: import_zod.z.boolean(),
515
+ characters_count: import_zod.z.number(),
516
+ input_tokens: import_zod.z.number().optional(),
517
+ output_tokens: import_zod.z.number().optional(),
518
+ streamed: import_zod.z.boolean(),
519
+ segment_id: import_zod.z.string().nullable().optional(),
520
+ speech_id: import_zod.z.string().nullable().optional(),
521
+ metadata: metadataWireSchema
522
+ });
523
+ const vadMetricsWireSchema = import_zod.z.object({
524
+ type: import_zod.z.literal("vad_metrics"),
525
+ label: import_zod.z.string(),
526
+ timestamp: import_zod.z.number(),
527
+ idle_time: import_zod.z.number(),
528
+ inference_duration_total: import_zod.z.number(),
529
+ inference_count: import_zod.z.number()
530
+ });
531
+ const eouMetricsWireSchema = import_zod.z.object({
532
+ type: import_zod.z.literal("eou_metrics"),
533
+ timestamp: import_zod.z.number(),
534
+ end_of_utterance_delay: import_zod.z.number(),
535
+ transcription_delay: import_zod.z.number(),
536
+ on_user_turn_completed_delay: import_zod.z.number(),
537
+ speech_id: import_zod.z.string().nullable().optional()
538
+ });
539
+ const cachedTokenDetailsWireSchema = import_zod.z.object({
540
+ audio_tokens: import_zod.z.number(),
541
+ text_tokens: import_zod.z.number(),
542
+ image_tokens: import_zod.z.number()
543
+ });
544
+ const inputTokenDetailsWireSchema = import_zod.z.object({
545
+ audio_tokens: import_zod.z.number(),
546
+ text_tokens: import_zod.z.number(),
547
+ image_tokens: import_zod.z.number(),
548
+ cached_tokens: import_zod.z.number(),
549
+ cached_tokens_details: cachedTokenDetailsWireSchema.nullable().optional()
550
+ });
551
+ const outputTokenDetailsWireSchema = import_zod.z.object({
552
+ text_tokens: import_zod.z.number(),
553
+ audio_tokens: import_zod.z.number(),
554
+ image_tokens: import_zod.z.number()
555
+ });
556
+ const realtimeModelMetricsWireSchema = import_zod.z.object({
557
+ type: import_zod.z.literal("realtime_model_metrics"),
558
+ label: import_zod.z.string(),
559
+ request_id: import_zod.z.string(),
560
+ timestamp: import_zod.z.number(),
561
+ duration: import_zod.z.number(),
562
+ session_duration: import_zod.z.number().optional(),
563
+ ttft: import_zod.z.number(),
564
+ cancelled: import_zod.z.boolean(),
565
+ input_tokens: import_zod.z.number(),
566
+ output_tokens: import_zod.z.number(),
567
+ total_tokens: import_zod.z.number(),
568
+ tokens_per_second: import_zod.z.number(),
569
+ input_token_details: inputTokenDetailsWireSchema,
570
+ output_token_details: outputTokenDetailsWireSchema,
571
+ metadata: metadataWireSchema
572
+ });
573
+ const interruptionMetricsWireSchema = import_zod.z.object({
574
+ type: import_zod.z.literal("interruption_metrics"),
575
+ timestamp: import_zod.z.number(),
576
+ total_duration: import_zod.z.number(),
577
+ prediction_duration: import_zod.z.number(),
578
+ detection_delay: import_zod.z.number(),
579
+ num_interruptions: import_zod.z.number(),
580
+ num_backchannels: import_zod.z.number(),
581
+ num_requests: import_zod.z.number(),
582
+ metadata: metadataWireSchema
583
+ });
584
+ const agentMetricsWireSchema = import_zod.z.discriminatedUnion("type", [
585
+ llmMetricsWireSchema,
586
+ sttMetricsWireSchema,
587
+ ttsMetricsWireSchema,
588
+ vadMetricsWireSchema,
589
+ eouMetricsWireSchema,
590
+ realtimeModelMetricsWireSchema,
591
+ interruptionMetricsWireSchema
592
+ ]);
593
+ const llmModelUsageWireSchema = import_zod.z.object({
594
+ type: import_zod.z.literal("llm_usage"),
595
+ provider: import_zod.z.string().optional(),
596
+ model: import_zod.z.string().optional(),
597
+ input_tokens: import_zod.z.number().optional(),
598
+ input_cached_tokens: import_zod.z.number().optional(),
599
+ input_audio_tokens: import_zod.z.number().optional(),
600
+ input_cached_audio_tokens: import_zod.z.number().optional(),
601
+ input_text_tokens: import_zod.z.number().optional(),
602
+ input_cached_text_tokens: import_zod.z.number().optional(),
603
+ input_image_tokens: import_zod.z.number().optional(),
604
+ input_cached_image_tokens: import_zod.z.number().optional(),
605
+ output_tokens: import_zod.z.number().optional(),
606
+ output_audio_tokens: import_zod.z.number().optional(),
607
+ output_text_tokens: import_zod.z.number().optional(),
608
+ session_duration: import_zod.z.number().optional()
609
+ });
610
+ const ttsModelUsageWireSchema = import_zod.z.object({
611
+ type: import_zod.z.literal("tts_usage"),
612
+ provider: import_zod.z.string().optional(),
613
+ model: import_zod.z.string().optional(),
614
+ input_tokens: import_zod.z.number().optional(),
615
+ output_tokens: import_zod.z.number().optional(),
616
+ characters_count: import_zod.z.number().optional(),
617
+ audio_duration: import_zod.z.number().optional()
618
+ });
619
+ const sttModelUsageWireSchema = import_zod.z.object({
620
+ type: import_zod.z.literal("stt_usage"),
621
+ provider: import_zod.z.string().optional(),
622
+ model: import_zod.z.string().optional(),
623
+ input_tokens: import_zod.z.number().optional(),
624
+ output_tokens: import_zod.z.number().optional(),
625
+ audio_duration: import_zod.z.number().optional()
626
+ });
627
+ const interruptionModelUsageWireSchema = import_zod.z.object({
628
+ type: import_zod.z.literal("interruption_usage"),
629
+ provider: import_zod.z.string().optional(),
630
+ model: import_zod.z.string().optional(),
631
+ total_requests: import_zod.z.number().optional()
632
+ });
633
+ const modelUsageWireSchema = import_zod.z.discriminatedUnion("type", [
634
+ llmModelUsageWireSchema,
635
+ ttsModelUsageWireSchema,
636
+ sttModelUsageWireSchema,
637
+ interruptionModelUsageWireSchema
638
+ ]);
639
+ const agentSessionUsageWireSchema = import_zod.z.object({
640
+ model_usage: import_zod.z.array(modelUsageWireSchema)
641
+ });
642
+ const agentStateSchema = import_zod.z.enum(["initializing", "idle", "listening", "thinking", "speaking"]);
643
+ const userStateSchema = import_zod.z.enum(["speaking", "listening", "away"]);
644
+ const clientAgentStateChangedSchema = import_zod.z.object({
645
+ type: import_zod.z.literal("agent_state_changed"),
646
+ old_state: agentStateSchema,
647
+ new_state: agentStateSchema,
648
+ created_at: import_zod.z.number()
649
+ });
650
+ const clientUserStateChangedSchema = import_zod.z.object({
651
+ type: import_zod.z.literal("user_state_changed"),
652
+ old_state: userStateSchema,
653
+ new_state: userStateSchema,
654
+ created_at: import_zod.z.number()
655
+ });
656
+ const clientConversationItemAddedSchema = import_zod.z.object({
657
+ type: import_zod.z.literal("conversation_item_added"),
658
+ item: chatMessageWireSchema,
659
+ created_at: import_zod.z.number()
660
+ });
661
+ const clientUserInputTranscribedSchema = import_zod.z.object({
662
+ type: import_zod.z.literal("user_input_transcribed"),
663
+ transcript: import_zod.z.string(),
664
+ is_final: import_zod.z.boolean(),
665
+ language: import_zod.z.string().nullable(),
666
+ created_at: import_zod.z.number()
667
+ });
668
+ const clientFunctionToolsExecutedSchema = import_zod.z.object({
669
+ type: import_zod.z.literal("function_tools_executed"),
670
+ function_calls: import_zod.z.array(functionCallWireSchema),
671
+ function_call_outputs: import_zod.z.array(functionCallOutputWireSchema.nullable()),
672
+ created_at: import_zod.z.number()
673
+ });
674
+ const clientMetricsCollectedSchema = import_zod.z.object({
675
+ type: import_zod.z.literal("metrics_collected"),
676
+ metrics: agentMetricsWireSchema,
677
+ created_at: import_zod.z.number()
678
+ });
679
+ const clientErrorSchema = import_zod.z.object({
680
+ type: import_zod.z.literal("error"),
681
+ message: import_zod.z.string(),
682
+ created_at: import_zod.z.number()
683
+ });
684
+ const clientUserOverlappingSpeechSchema = import_zod.z.object({
685
+ type: import_zod.z.literal("user_overlapping_speech"),
686
+ is_interruption: import_zod.z.boolean(),
687
+ created_at: import_zod.z.number(),
688
+ sent_at: import_zod.z.number(),
689
+ detection_delay: import_zod.z.number(),
690
+ overlap_started_at: import_zod.z.number().nullable()
691
+ });
692
+ const clientSessionUsageSchema = import_zod.z.object({
693
+ type: import_zod.z.literal("session_usage"),
694
+ usage: agentSessionUsageWireSchema,
695
+ created_at: import_zod.z.number()
696
+ });
697
+ const clientEventSchema = import_zod.z.discriminatedUnion("type", [
698
+ clientAgentStateChangedSchema,
699
+ clientUserStateChangedSchema,
700
+ clientConversationItemAddedSchema,
701
+ clientUserInputTranscribedSchema,
702
+ clientFunctionToolsExecutedSchema,
703
+ clientMetricsCollectedSchema,
704
+ clientErrorSchema,
705
+ clientUserOverlappingSpeechSchema,
706
+ clientSessionUsageSchema
707
+ ]);
708
+ const sendMessageRequestSchema = import_zod.z.object({
709
+ text: import_zod.z.string()
710
+ });
711
+ const streamRequestSchema = import_zod.z.object({
712
+ request_id: import_zod.z.string(),
713
+ method: import_zod.z.string(),
714
+ payload: import_zod.z.string()
715
+ });
716
+ const streamResponseSchema = import_zod.z.object({
717
+ request_id: import_zod.z.string(),
718
+ payload: import_zod.z.string(),
719
+ error: import_zod.z.string().nullable().optional()
720
+ });
721
+ const getSessionStateResponseSchema = import_zod.z.object({
722
+ agent_state: agentStateSchema,
723
+ user_state: userStateSchema,
724
+ agent_id: import_zod.z.string(),
725
+ options: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()),
726
+ created_at: import_zod.z.number()
727
+ });
728
+ const getChatHistoryResponseSchema = import_zod.z.object({
729
+ items: import_zod.z.array(chatItemWireSchema)
730
+ });
731
+ const getAgentInfoResponseSchema = import_zod.z.object({
732
+ id: import_zod.z.string(),
733
+ instructions: import_zod.z.string().nullable(),
734
+ tools: import_zod.z.array(import_zod.z.string()),
735
+ chat_ctx: import_zod.z.array(chatItemWireSchema)
736
+ });
737
+ const sendMessageResponseSchema = import_zod.z.object({
738
+ items: import_zod.z.array(chatItemWireSchema)
739
+ });
740
+ const getRTCStatsResponseSchema = import_zod.z.object({
741
+ publisher_stats: import_zod.z.array(import_zod.z.record(import_zod.z.string(), import_zod.z.unknown())),
742
+ subscriber_stats: import_zod.z.array(import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()))
743
+ });
744
+ const getSessionUsageResponseSchema = import_zod.z.object({
745
+ usage: agentSessionUsageWireSchema,
746
+ created_at: import_zod.z.number()
747
+ });
748
+ // Annotate the CommonJS export names for ESM import in node:
749
+ 0 && (module.exports = {
750
+ agentHandoffToWire,
751
+ agentHandoffWireSchema,
752
+ agentMetricsToWire,
753
+ agentMetricsWireSchema,
754
+ agentSessionUsageToWire,
755
+ agentSessionUsageWireSchema,
756
+ chatItemToWire,
757
+ chatItemWireSchema,
758
+ chatMessageToWire,
759
+ chatMessageWireSchema,
760
+ clientAgentStateChangedSchema,
761
+ clientConversationItemAddedSchema,
762
+ clientErrorSchema,
763
+ clientEventSchema,
764
+ clientFunctionToolsExecutedSchema,
765
+ clientMetricsCollectedSchema,
766
+ clientSessionUsageSchema,
767
+ clientUserInputTranscribedSchema,
768
+ clientUserOverlappingSpeechSchema,
769
+ clientUserStateChangedSchema,
770
+ eouMetricsWireSchema,
771
+ functionCallOutputToWire,
772
+ functionCallOutputWireSchema,
773
+ functionCallToWire,
774
+ functionCallWireSchema,
775
+ getAgentInfoResponseSchema,
776
+ getChatHistoryResponseSchema,
777
+ getRTCStatsResponseSchema,
778
+ getSessionStateResponseSchema,
779
+ getSessionUsageResponseSchema,
780
+ interruptionMetricsWireSchema,
781
+ interruptionModelUsageWireSchema,
782
+ llmMetricsWireSchema,
783
+ llmModelUsageWireSchema,
784
+ modelUsageToWire,
785
+ modelUsageWireSchema,
786
+ msToS,
787
+ realtimeModelMetricsWireSchema,
788
+ sendMessageRequestSchema,
789
+ sendMessageResponseSchema,
790
+ streamRequestSchema,
791
+ streamResponseSchema,
792
+ sttMetricsWireSchema,
793
+ sttModelUsageWireSchema,
794
+ ttsMetricsWireSchema,
795
+ ttsModelUsageWireSchema,
796
+ vadMetricsWireSchema
797
+ });
798
+ //# sourceMappingURL=wire_format.cjs.map