@tambo-ai/react 0.74.1 → 1.0.0-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (693) hide show
  1. package/README.md +46 -449
  2. package/dist/hoc/with-tambo-interactable.d.ts +8 -0
  3. package/dist/hoc/with-tambo-interactable.d.ts.map +1 -1
  4. package/dist/hoc/with-tambo-interactable.js +16 -13
  5. package/dist/hoc/with-tambo-interactable.js.map +1 -1
  6. package/dist/hoc/with-tambo-interactable.test.js +15 -3
  7. package/dist/hoc/with-tambo-interactable.test.js.map +1 -1
  8. package/dist/hooks/use-tambo-voice.test.js +3 -0
  9. package/dist/hooks/use-tambo-voice.test.js.map +1 -1
  10. package/dist/index.d.ts +7 -25
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +7 -59
  13. package/dist/index.js.map +1 -1
  14. package/dist/mcp/mcp-hooks.js +5 -5
  15. package/dist/mcp/mcp-hooks.js.map +1 -1
  16. package/dist/mcp/mcp-hooks.test.js +69 -0
  17. package/dist/mcp/mcp-hooks.test.js.map +1 -1
  18. package/dist/mcp/tambo-mcp-provider.test.js +24 -0
  19. package/dist/mcp/tambo-mcp-provider.test.js.map +1 -1
  20. package/dist/mcp/use-mcp-servers.test.js +9 -0
  21. package/dist/mcp/use-mcp-servers.test.js.map +1 -1
  22. package/dist/model/component-metadata.d.ts +4 -4
  23. package/dist/model/component-metadata.js.map +1 -1
  24. package/dist/providers/tambo-client-provider.d.ts +12 -0
  25. package/dist/providers/tambo-client-provider.d.ts.map +1 -1
  26. package/dist/providers/tambo-client-provider.js +8 -3
  27. package/dist/providers/tambo-client-provider.js.map +1 -1
  28. package/dist/providers/tambo-interactable-provider.d.ts +1 -1
  29. package/dist/providers/tambo-interactable-provider.d.ts.map +1 -1
  30. package/dist/providers/tambo-interactable-provider.js +8 -0
  31. package/dist/providers/tambo-interactable-provider.js.map +1 -1
  32. package/dist/providers/tambo-interactable-provider.test.js +47 -0
  33. package/dist/providers/tambo-interactable-provider.test.js.map +1 -1
  34. package/dist/providers/tambo-interactables-additional-context-edge-cases.test.js +2 -10
  35. package/dist/providers/tambo-interactables-additional-context-edge-cases.test.js.map +1 -1
  36. package/dist/providers/tambo-interactables-additional-context.test.js +3 -19
  37. package/dist/providers/tambo-interactables-additional-context.test.js.map +1 -1
  38. package/dist/providers/tambo-mcp-token-provider.d.ts +8 -17
  39. package/dist/providers/tambo-mcp-token-provider.d.ts.map +1 -1
  40. package/dist/providers/tambo-mcp-token-provider.js +20 -97
  41. package/dist/providers/tambo-mcp-token-provider.js.map +1 -1
  42. package/dist/testing/tools.d.ts +3 -3
  43. package/dist/testing/tools.d.ts.map +1 -1
  44. package/dist/testing/tools.js.map +1 -1
  45. package/dist/util/registry-validators.js +1 -1
  46. package/dist/util/registry-validators.js.map +1 -1
  47. package/dist/util/resource-content-resolver.test.js +1 -1
  48. package/dist/util/resource-content-resolver.test.js.map +1 -1
  49. package/dist/v1/__tests__/v1-interactables.test.js +1 -1
  50. package/dist/v1/__tests__/v1-interactables.test.js.map +1 -1
  51. package/dist/v1/components/v1-component-renderer.d.ts +9 -9
  52. package/dist/v1/components/v1-component-renderer.d.ts.map +1 -1
  53. package/dist/v1/components/v1-component-renderer.js +13 -13
  54. package/dist/v1/components/v1-component-renderer.js.map +1 -1
  55. package/dist/v1/components/v1-component-renderer.test.js +15 -15
  56. package/dist/v1/components/v1-component-renderer.test.js.map +1 -1
  57. package/{esm/hooks/use-current-message.d.ts → dist/v1/hooks/use-tambo-current-message.d.ts} +30 -9
  58. package/dist/v1/hooks/use-tambo-current-message.d.ts.map +1 -0
  59. package/dist/{hooks/use-current-message.js → v1/hooks/use-tambo-current-message.js} +13 -8
  60. package/dist/v1/hooks/use-tambo-current-message.js.map +1 -0
  61. package/dist/v1/hooks/use-tambo-v1-auth-state.d.ts +11 -0
  62. package/dist/v1/hooks/use-tambo-v1-auth-state.d.ts.map +1 -0
  63. package/dist/v1/hooks/use-tambo-v1-auth-state.js +48 -0
  64. package/dist/v1/hooks/use-tambo-v1-auth-state.js.map +1 -0
  65. package/dist/v1/hooks/use-tambo-v1-auth-state.test.d.ts +2 -0
  66. package/dist/v1/hooks/use-tambo-v1-auth-state.test.d.ts.map +1 -0
  67. package/dist/v1/hooks/use-tambo-v1-auth-state.test.js +105 -0
  68. package/dist/v1/hooks/use-tambo-v1-auth-state.test.js.map +1 -0
  69. package/dist/v1/hooks/use-tambo-v1-component-state.d.ts +7 -6
  70. package/dist/v1/hooks/use-tambo-v1-component-state.d.ts.map +1 -1
  71. package/dist/v1/hooks/use-tambo-v1-component-state.js +101 -28
  72. package/dist/v1/hooks/use-tambo-v1-component-state.js.map +1 -1
  73. package/dist/v1/hooks/use-tambo-v1-component-state.test.js +150 -25
  74. package/dist/v1/hooks/use-tambo-v1-component-state.test.js.map +1 -1
  75. package/dist/v1/hooks/use-tambo-v1-messages.d.ts +9 -9
  76. package/dist/v1/hooks/use-tambo-v1-messages.d.ts.map +1 -1
  77. package/dist/v1/hooks/use-tambo-v1-messages.js +4 -4
  78. package/dist/v1/hooks/use-tambo-v1-messages.js.map +1 -1
  79. package/dist/v1/hooks/use-tambo-v1-messages.test.js +14 -6
  80. package/dist/v1/hooks/use-tambo-v1-messages.test.js.map +1 -1
  81. package/dist/v1/hooks/use-tambo-v1-send-message.d.ts +21 -3
  82. package/dist/v1/hooks/use-tambo-v1-send-message.d.ts.map +1 -1
  83. package/dist/v1/hooks/use-tambo-v1-send-message.js +92 -17
  84. package/dist/v1/hooks/use-tambo-v1-send-message.js.map +1 -1
  85. package/dist/v1/hooks/use-tambo-v1-send-message.test.js +315 -42
  86. package/dist/v1/hooks/use-tambo-v1-send-message.test.js.map +1 -1
  87. package/dist/v1/hooks/use-tambo-v1-stream-status.d.ts +7 -7
  88. package/dist/v1/hooks/use-tambo-v1-stream-status.d.ts.map +1 -1
  89. package/dist/v1/hooks/use-tambo-v1-stream-status.js +14 -16
  90. package/dist/v1/hooks/use-tambo-v1-stream-status.js.map +1 -1
  91. package/dist/v1/hooks/use-tambo-v1-stream-status.test.js +30 -30
  92. package/dist/v1/hooks/use-tambo-v1-stream-status.test.js.map +1 -1
  93. package/dist/v1/hooks/use-tambo-v1-suggestions.d.ts +7 -7
  94. package/dist/v1/hooks/use-tambo-v1-suggestions.d.ts.map +1 -1
  95. package/dist/v1/hooks/use-tambo-v1-suggestions.js +9 -9
  96. package/dist/v1/hooks/use-tambo-v1-suggestions.js.map +1 -1
  97. package/dist/v1/hooks/use-tambo-v1-suggestions.test.js +44 -44
  98. package/dist/v1/hooks/use-tambo-v1-suggestions.test.js.map +1 -1
  99. package/dist/v1/hooks/use-tambo-v1-thread-input.d.ts +3 -3
  100. package/dist/v1/hooks/use-tambo-v1-thread-input.d.ts.map +1 -1
  101. package/dist/v1/hooks/use-tambo-v1-thread-input.js +4 -4
  102. package/dist/v1/hooks/use-tambo-v1-thread-input.js.map +1 -1
  103. package/dist/v1/hooks/use-tambo-v1-thread-input.test.js +40 -27
  104. package/dist/v1/hooks/use-tambo-v1-thread-input.test.js.map +1 -1
  105. package/dist/v1/hooks/use-tambo-v1-thread-list.d.ts +4 -4
  106. package/dist/v1/hooks/use-tambo-v1-thread-list.d.ts.map +1 -1
  107. package/dist/v1/hooks/use-tambo-v1-thread-list.js +8 -4
  108. package/dist/v1/hooks/use-tambo-v1-thread-list.js.map +1 -1
  109. package/dist/v1/hooks/use-tambo-v1-thread-list.test.js +18 -16
  110. package/dist/v1/hooks/use-tambo-v1-thread-list.test.js.map +1 -1
  111. package/dist/v1/hooks/use-tambo-v1-thread.d.ts +3 -3
  112. package/dist/v1/hooks/use-tambo-v1-thread.d.ts.map +1 -1
  113. package/dist/v1/hooks/use-tambo-v1-thread.js +7 -3
  114. package/dist/v1/hooks/use-tambo-v1-thread.js.map +1 -1
  115. package/dist/v1/hooks/use-tambo-v1-thread.test.js +10 -4
  116. package/dist/v1/hooks/use-tambo-v1-thread.test.js.map +1 -1
  117. package/dist/v1/hooks/use-tambo-v1.d.ts +16 -5
  118. package/dist/v1/hooks/use-tambo-v1.d.ts.map +1 -1
  119. package/dist/v1/hooks/use-tambo-v1.js +14 -6
  120. package/dist/v1/hooks/use-tambo-v1.js.map +1 -1
  121. package/dist/v1/hooks/use-tambo-v1.test.js +65 -43
  122. package/dist/v1/hooks/use-tambo-v1.test.js.map +1 -1
  123. package/dist/v1/index.d.ts +34 -27
  124. package/dist/v1/index.d.ts.map +1 -1
  125. package/dist/v1/index.js +48 -35
  126. package/dist/v1/index.js.map +1 -1
  127. package/dist/v1/providers/tambo-v1-provider.d.ts +35 -20
  128. package/dist/v1/providers/tambo-v1-provider.d.ts.map +1 -1
  129. package/dist/v1/providers/tambo-v1-provider.js +63 -26
  130. package/dist/v1/providers/tambo-v1-provider.js.map +1 -1
  131. package/dist/v1/providers/tambo-v1-provider.test.js +40 -23
  132. package/dist/v1/providers/tambo-v1-provider.test.js.map +1 -1
  133. package/dist/v1/providers/tambo-v1-stream-context.d.ts +21 -15
  134. package/dist/v1/providers/tambo-v1-stream-context.d.ts.map +1 -1
  135. package/dist/v1/providers/tambo-v1-stream-context.js +66 -27
  136. package/dist/v1/providers/tambo-v1-stream-context.js.map +1 -1
  137. package/dist/v1/providers/tambo-v1-stream-context.test.js +14 -5
  138. package/dist/v1/providers/tambo-v1-stream-context.test.js.map +1 -1
  139. package/dist/v1/providers/tambo-v1-stub-provider.d.ts +9 -9
  140. package/dist/v1/providers/tambo-v1-stub-provider.d.ts.map +1 -1
  141. package/dist/v1/providers/tambo-v1-stub-provider.js +11 -7
  142. package/dist/v1/providers/tambo-v1-stub-provider.js.map +1 -1
  143. package/dist/v1/providers/tambo-v1-stub-provider.test.js +25 -25
  144. package/dist/v1/providers/tambo-v1-stub-provider.test.js.map +1 -1
  145. package/dist/v1/providers/tambo-v1-thread-input-provider.d.ts +20 -9
  146. package/dist/v1/providers/tambo-v1-thread-input-provider.d.ts.map +1 -1
  147. package/dist/v1/providers/tambo-v1-thread-input-provider.js +25 -16
  148. package/dist/v1/providers/tambo-v1-thread-input-provider.js.map +1 -1
  149. package/dist/v1/types/auth.d.ts +24 -0
  150. package/dist/v1/types/auth.d.ts.map +1 -0
  151. package/dist/{model/tambo-thread.js → v1/types/auth.js} +1 -1
  152. package/dist/v1/types/auth.js.map +1 -0
  153. package/dist/v1/types/component.d.ts +3 -3
  154. package/dist/v1/types/component.d.ts.map +1 -1
  155. package/dist/v1/types/component.js +2 -2
  156. package/dist/v1/types/component.js.map +1 -1
  157. package/dist/v1/types/event.d.ts +1 -1
  158. package/dist/v1/types/event.js +1 -1
  159. package/dist/v1/types/event.js.map +1 -1
  160. package/dist/v1/types/message.d.ts +19 -12
  161. package/dist/v1/types/message.d.ts.map +1 -1
  162. package/dist/v1/types/message.js +1 -1
  163. package/dist/v1/types/message.js.map +1 -1
  164. package/dist/v1/types/thread.d.ts +8 -6
  165. package/dist/v1/types/thread.d.ts.map +1 -1
  166. package/dist/v1/types/thread.js +1 -1
  167. package/dist/v1/types/thread.js.map +1 -1
  168. package/dist/v1/types/tool-choice.d.ts +8 -0
  169. package/dist/v1/types/tool-choice.d.ts.map +1 -0
  170. package/dist/v1/types/tool-choice.js +3 -0
  171. package/dist/v1/types/tool-choice.js.map +1 -0
  172. package/dist/v1/utils/component-renderer.d.ts +11 -5
  173. package/dist/v1/utils/component-renderer.d.ts.map +1 -1
  174. package/dist/v1/utils/component-renderer.js +16 -7
  175. package/dist/v1/utils/component-renderer.js.map +1 -1
  176. package/dist/v1/utils/component-renderer.test.js +7 -7
  177. package/dist/v1/utils/component-renderer.test.js.map +1 -1
  178. package/dist/v1/utils/event-accumulator.d.ts +34 -8
  179. package/dist/v1/utils/event-accumulator.d.ts.map +1 -1
  180. package/dist/v1/utils/event-accumulator.js +90 -27
  181. package/dist/v1/utils/event-accumulator.js.map +1 -1
  182. package/dist/v1/utils/event-accumulator.test.js +149 -8
  183. package/dist/v1/utils/event-accumulator.test.js.map +1 -1
  184. package/dist/v1/utils/keyed-throttle.d.ts +42 -0
  185. package/dist/v1/utils/keyed-throttle.d.ts.map +1 -0
  186. package/dist/v1/utils/keyed-throttle.js +86 -0
  187. package/dist/v1/utils/keyed-throttle.js.map +1 -0
  188. package/dist/v1/utils/keyed-throttle.test.d.ts +2 -0
  189. package/dist/v1/utils/keyed-throttle.test.d.ts.map +1 -0
  190. package/dist/v1/utils/keyed-throttle.test.js +147 -0
  191. package/dist/v1/utils/keyed-throttle.test.js.map +1 -0
  192. package/dist/v1/utils/registry-conversion.d.ts +18 -18
  193. package/dist/v1/utils/registry-conversion.d.ts.map +1 -1
  194. package/dist/v1/utils/registry-conversion.js +25 -23
  195. package/dist/v1/utils/registry-conversion.js.map +1 -1
  196. package/dist/v1/utils/registry-conversion.test.js +23 -0
  197. package/dist/v1/utils/registry-conversion.test.js.map +1 -1
  198. package/dist/v1/utils/stream-handler.d.ts +1 -1
  199. package/dist/v1/utils/stream-handler.js +1 -1
  200. package/dist/v1/utils/stream-handler.js.map +1 -1
  201. package/dist/v1/utils/thread-utils.d.ts +2 -2
  202. package/dist/v1/utils/thread-utils.d.ts.map +1 -1
  203. package/dist/v1/utils/thread-utils.js.map +1 -1
  204. package/dist/v1/utils/tool-call-tracker.d.ts +11 -1
  205. package/dist/v1/utils/tool-call-tracker.d.ts.map +1 -1
  206. package/dist/v1/utils/tool-call-tracker.js +14 -1
  207. package/dist/v1/utils/tool-call-tracker.js.map +1 -1
  208. package/dist/v1/utils/tool-call-tracker.test.d.ts +2 -0
  209. package/dist/v1/utils/tool-call-tracker.test.d.ts.map +1 -0
  210. package/dist/v1/utils/tool-call-tracker.test.js +67 -0
  211. package/dist/v1/utils/tool-call-tracker.test.js.map +1 -0
  212. package/dist/v1/utils/tool-executor.d.ts +35 -1
  213. package/dist/v1/utils/tool-executor.d.ts.map +1 -1
  214. package/dist/v1/utils/tool-executor.js +57 -2
  215. package/dist/v1/utils/tool-executor.js.map +1 -1
  216. package/dist/v1/utils/tool-executor.test.js +211 -0
  217. package/dist/v1/utils/tool-executor.test.js.map +1 -1
  218. package/esm/hoc/with-tambo-interactable.d.ts +8 -0
  219. package/esm/hoc/with-tambo-interactable.d.ts.map +1 -1
  220. package/esm/hoc/with-tambo-interactable.js +15 -12
  221. package/esm/hoc/with-tambo-interactable.js.map +1 -1
  222. package/esm/hoc/with-tambo-interactable.test.js +13 -1
  223. package/esm/hoc/with-tambo-interactable.test.js.map +1 -1
  224. package/esm/hooks/use-tambo-voice.test.js +3 -0
  225. package/esm/hooks/use-tambo-voice.test.js.map +1 -1
  226. package/esm/index.d.ts +7 -25
  227. package/esm/index.d.ts.map +1 -1
  228. package/esm/index.js +7 -21
  229. package/esm/index.js.map +1 -1
  230. package/esm/mcp/mcp-hooks.js +1 -1
  231. package/esm/mcp/mcp-hooks.js.map +1 -1
  232. package/esm/mcp/mcp-hooks.test.js +69 -0
  233. package/esm/mcp/mcp-hooks.test.js.map +1 -1
  234. package/esm/mcp/tambo-mcp-provider.test.js +24 -0
  235. package/esm/mcp/tambo-mcp-provider.test.js.map +1 -1
  236. package/esm/mcp/use-mcp-servers.test.js +9 -0
  237. package/esm/mcp/use-mcp-servers.test.js.map +1 -1
  238. package/esm/model/component-metadata.d.ts +4 -4
  239. package/esm/model/component-metadata.js.map +1 -1
  240. package/esm/providers/tambo-client-provider.d.ts +12 -0
  241. package/esm/providers/tambo-client-provider.d.ts.map +1 -1
  242. package/esm/providers/tambo-client-provider.js +8 -3
  243. package/esm/providers/tambo-client-provider.js.map +1 -1
  244. package/esm/providers/tambo-interactable-provider.d.ts +1 -1
  245. package/esm/providers/tambo-interactable-provider.d.ts.map +1 -1
  246. package/esm/providers/tambo-interactable-provider.js +8 -0
  247. package/esm/providers/tambo-interactable-provider.js.map +1 -1
  248. package/esm/providers/tambo-interactable-provider.test.js +47 -0
  249. package/esm/providers/tambo-interactable-provider.test.js.map +1 -1
  250. package/esm/providers/tambo-interactables-additional-context-edge-cases.test.js +2 -10
  251. package/esm/providers/tambo-interactables-additional-context-edge-cases.test.js.map +1 -1
  252. package/esm/providers/tambo-interactables-additional-context.test.js +3 -19
  253. package/esm/providers/tambo-interactables-additional-context.test.js.map +1 -1
  254. package/esm/providers/tambo-mcp-token-provider.d.ts +8 -17
  255. package/esm/providers/tambo-mcp-token-provider.d.ts.map +1 -1
  256. package/esm/providers/tambo-mcp-token-provider.js +20 -97
  257. package/esm/providers/tambo-mcp-token-provider.js.map +1 -1
  258. package/esm/testing/tools.d.ts +3 -3
  259. package/esm/testing/tools.d.ts.map +1 -1
  260. package/esm/testing/tools.js.map +1 -1
  261. package/esm/util/registry-validators.js +1 -1
  262. package/esm/util/registry-validators.js.map +1 -1
  263. package/esm/util/resource-content-resolver.test.js +1 -1
  264. package/esm/util/resource-content-resolver.test.js.map +1 -1
  265. package/esm/v1/__tests__/v1-interactables.test.js +1 -1
  266. package/esm/v1/__tests__/v1-interactables.test.js.map +1 -1
  267. package/esm/v1/components/v1-component-renderer.d.ts +9 -9
  268. package/esm/v1/components/v1-component-renderer.d.ts.map +1 -1
  269. package/esm/v1/components/v1-component-renderer.js +12 -12
  270. package/esm/v1/components/v1-component-renderer.js.map +1 -1
  271. package/esm/v1/components/v1-component-renderer.test.js +16 -16
  272. package/esm/v1/components/v1-component-renderer.test.js.map +1 -1
  273. package/{dist/hooks/use-current-message.d.ts → esm/v1/hooks/use-tambo-current-message.d.ts} +30 -9
  274. package/esm/v1/hooks/use-tambo-current-message.d.ts.map +1 -0
  275. package/esm/{hooks/use-current-message.js → v1/hooks/use-tambo-current-message.js} +13 -8
  276. package/esm/v1/hooks/use-tambo-current-message.js.map +1 -0
  277. package/esm/v1/hooks/use-tambo-v1-auth-state.d.ts +11 -0
  278. package/esm/v1/hooks/use-tambo-v1-auth-state.d.ts.map +1 -0
  279. package/esm/v1/hooks/use-tambo-v1-auth-state.js +45 -0
  280. package/esm/v1/hooks/use-tambo-v1-auth-state.js.map +1 -0
  281. package/esm/v1/hooks/use-tambo-v1-auth-state.test.d.ts +2 -0
  282. package/esm/v1/hooks/use-tambo-v1-auth-state.test.d.ts.map +1 -0
  283. package/esm/v1/hooks/use-tambo-v1-auth-state.test.js +100 -0
  284. package/esm/v1/hooks/use-tambo-v1-auth-state.test.js.map +1 -0
  285. package/esm/v1/hooks/use-tambo-v1-component-state.d.ts +7 -6
  286. package/esm/v1/hooks/use-tambo-v1-component-state.d.ts.map +1 -1
  287. package/esm/v1/hooks/use-tambo-v1-component-state.js +101 -28
  288. package/esm/v1/hooks/use-tambo-v1-component-state.js.map +1 -1
  289. package/esm/v1/hooks/use-tambo-v1-component-state.test.js +152 -27
  290. package/esm/v1/hooks/use-tambo-v1-component-state.test.js.map +1 -1
  291. package/esm/v1/hooks/use-tambo-v1-messages.d.ts +9 -9
  292. package/esm/v1/hooks/use-tambo-v1-messages.d.ts.map +1 -1
  293. package/esm/v1/hooks/use-tambo-v1-messages.js +3 -3
  294. package/esm/v1/hooks/use-tambo-v1-messages.js.map +1 -1
  295. package/esm/v1/hooks/use-tambo-v1-messages.test.js +16 -8
  296. package/esm/v1/hooks/use-tambo-v1-messages.test.js.map +1 -1
  297. package/esm/v1/hooks/use-tambo-v1-send-message.d.ts +21 -3
  298. package/esm/v1/hooks/use-tambo-v1-send-message.d.ts.map +1 -1
  299. package/esm/v1/hooks/use-tambo-v1-send-message.js +93 -18
  300. package/esm/v1/hooks/use-tambo-v1-send-message.js.map +1 -1
  301. package/esm/v1/hooks/use-tambo-v1-send-message.test.js +318 -45
  302. package/esm/v1/hooks/use-tambo-v1-send-message.test.js.map +1 -1
  303. package/esm/v1/hooks/use-tambo-v1-stream-status.d.ts +7 -7
  304. package/esm/v1/hooks/use-tambo-v1-stream-status.d.ts.map +1 -1
  305. package/esm/v1/hooks/use-tambo-v1-stream-status.js +14 -16
  306. package/esm/v1/hooks/use-tambo-v1-stream-status.js.map +1 -1
  307. package/esm/v1/hooks/use-tambo-v1-stream-status.test.js +32 -32
  308. package/esm/v1/hooks/use-tambo-v1-stream-status.test.js.map +1 -1
  309. package/esm/v1/hooks/use-tambo-v1-suggestions.d.ts +7 -7
  310. package/esm/v1/hooks/use-tambo-v1-suggestions.d.ts.map +1 -1
  311. package/esm/v1/hooks/use-tambo-v1-suggestions.js +11 -11
  312. package/esm/v1/hooks/use-tambo-v1-suggestions.js.map +1 -1
  313. package/esm/v1/hooks/use-tambo-v1-suggestions.test.js +48 -48
  314. package/esm/v1/hooks/use-tambo-v1-suggestions.test.js.map +1 -1
  315. package/esm/v1/hooks/use-tambo-v1-thread-input.d.ts +3 -3
  316. package/esm/v1/hooks/use-tambo-v1-thread-input.d.ts.map +1 -1
  317. package/esm/v1/hooks/use-tambo-v1-thread-input.js +3 -3
  318. package/esm/v1/hooks/use-tambo-v1-thread-input.js.map +1 -1
  319. package/esm/v1/hooks/use-tambo-v1-thread-input.test.js +43 -30
  320. package/esm/v1/hooks/use-tambo-v1-thread-input.test.js.map +1 -1
  321. package/esm/v1/hooks/use-tambo-v1-thread-list.d.ts +4 -4
  322. package/esm/v1/hooks/use-tambo-v1-thread-list.d.ts.map +1 -1
  323. package/esm/v1/hooks/use-tambo-v1-thread-list.js +8 -4
  324. package/esm/v1/hooks/use-tambo-v1-thread-list.js.map +1 -1
  325. package/esm/v1/hooks/use-tambo-v1-thread-list.test.js +20 -18
  326. package/esm/v1/hooks/use-tambo-v1-thread-list.test.js.map +1 -1
  327. package/esm/v1/hooks/use-tambo-v1-thread.d.ts +3 -3
  328. package/esm/v1/hooks/use-tambo-v1-thread.d.ts.map +1 -1
  329. package/esm/v1/hooks/use-tambo-v1-thread.js +6 -2
  330. package/esm/v1/hooks/use-tambo-v1-thread.js.map +1 -1
  331. package/esm/v1/hooks/use-tambo-v1-thread.test.js +11 -5
  332. package/esm/v1/hooks/use-tambo-v1-thread.test.js.map +1 -1
  333. package/esm/v1/hooks/use-tambo-v1.d.ts +16 -5
  334. package/esm/v1/hooks/use-tambo-v1.d.ts.map +1 -1
  335. package/esm/v1/hooks/use-tambo-v1.js +14 -6
  336. package/esm/v1/hooks/use-tambo-v1.js.map +1 -1
  337. package/esm/v1/hooks/use-tambo-v1.test.js +67 -45
  338. package/esm/v1/hooks/use-tambo-v1.test.js.map +1 -1
  339. package/esm/v1/index.d.ts +34 -27
  340. package/esm/v1/index.d.ts.map +1 -1
  341. package/esm/v1/index.js +40 -33
  342. package/esm/v1/index.js.map +1 -1
  343. package/esm/v1/providers/tambo-v1-provider.d.ts +35 -20
  344. package/esm/v1/providers/tambo-v1-provider.d.ts.map +1 -1
  345. package/esm/v1/providers/tambo-v1-provider.js +63 -26
  346. package/esm/v1/providers/tambo-v1-provider.js.map +1 -1
  347. package/esm/v1/providers/tambo-v1-provider.test.js +41 -24
  348. package/esm/v1/providers/tambo-v1-provider.test.js.map +1 -1
  349. package/esm/v1/providers/tambo-v1-stream-context.d.ts +21 -15
  350. package/esm/v1/providers/tambo-v1-stream-context.d.ts.map +1 -1
  351. package/esm/v1/providers/tambo-v1-stream-context.js +66 -27
  352. package/esm/v1/providers/tambo-v1-stream-context.js.map +1 -1
  353. package/esm/v1/providers/tambo-v1-stream-context.test.js +15 -6
  354. package/esm/v1/providers/tambo-v1-stream-context.test.js.map +1 -1
  355. package/esm/v1/providers/tambo-v1-stub-provider.d.ts +9 -9
  356. package/esm/v1/providers/tambo-v1-stub-provider.d.ts.map +1 -1
  357. package/esm/v1/providers/tambo-v1-stub-provider.js +13 -9
  358. package/esm/v1/providers/tambo-v1-stub-provider.js.map +1 -1
  359. package/esm/v1/providers/tambo-v1-stub-provider.test.js +28 -28
  360. package/esm/v1/providers/tambo-v1-stub-provider.test.js.map +1 -1
  361. package/esm/v1/providers/tambo-v1-thread-input-provider.d.ts +20 -9
  362. package/esm/v1/providers/tambo-v1-thread-input-provider.d.ts.map +1 -1
  363. package/esm/v1/providers/tambo-v1-thread-input-provider.js +23 -14
  364. package/esm/v1/providers/tambo-v1-thread-input-provider.js.map +1 -1
  365. package/esm/v1/types/auth.d.ts +24 -0
  366. package/esm/v1/types/auth.d.ts.map +1 -0
  367. package/esm/v1/types/auth.js +2 -0
  368. package/esm/v1/types/auth.js.map +1 -0
  369. package/esm/v1/types/component.d.ts +3 -3
  370. package/esm/v1/types/component.d.ts.map +1 -1
  371. package/esm/v1/types/component.js +2 -2
  372. package/esm/v1/types/component.js.map +1 -1
  373. package/esm/v1/types/event.d.ts +1 -1
  374. package/esm/v1/types/event.js +1 -1
  375. package/esm/v1/types/event.js.map +1 -1
  376. package/esm/v1/types/message.d.ts +19 -12
  377. package/esm/v1/types/message.d.ts.map +1 -1
  378. package/esm/v1/types/message.js +1 -1
  379. package/esm/v1/types/message.js.map +1 -1
  380. package/esm/v1/types/thread.d.ts +8 -6
  381. package/esm/v1/types/thread.d.ts.map +1 -1
  382. package/esm/v1/types/thread.js +1 -1
  383. package/esm/v1/types/thread.js.map +1 -1
  384. package/esm/v1/types/tool-choice.d.ts +8 -0
  385. package/esm/v1/types/tool-choice.d.ts.map +1 -0
  386. package/esm/v1/types/tool-choice.js +2 -0
  387. package/esm/v1/types/tool-choice.js.map +1 -0
  388. package/esm/v1/utils/component-renderer.d.ts +11 -5
  389. package/esm/v1/utils/component-renderer.d.ts.map +1 -1
  390. package/esm/v1/utils/component-renderer.js +13 -5
  391. package/esm/v1/utils/component-renderer.js.map +1 -1
  392. package/esm/v1/utils/component-renderer.test.js +8 -8
  393. package/esm/v1/utils/component-renderer.test.js.map +1 -1
  394. package/esm/v1/utils/event-accumulator.d.ts +34 -8
  395. package/esm/v1/utils/event-accumulator.d.ts.map +1 -1
  396. package/esm/v1/utils/event-accumulator.js +89 -27
  397. package/esm/v1/utils/event-accumulator.js.map +1 -1
  398. package/esm/v1/utils/event-accumulator.test.js +149 -8
  399. package/esm/v1/utils/event-accumulator.test.js.map +1 -1
  400. package/esm/v1/utils/keyed-throttle.d.ts +42 -0
  401. package/esm/v1/utils/keyed-throttle.d.ts.map +1 -0
  402. package/esm/v1/utils/keyed-throttle.js +83 -0
  403. package/esm/v1/utils/keyed-throttle.js.map +1 -0
  404. package/esm/v1/utils/keyed-throttle.test.d.ts +2 -0
  405. package/esm/v1/utils/keyed-throttle.test.d.ts.map +1 -0
  406. package/esm/v1/utils/keyed-throttle.test.js +145 -0
  407. package/esm/v1/utils/keyed-throttle.test.js.map +1 -0
  408. package/esm/v1/utils/registry-conversion.d.ts +18 -18
  409. package/esm/v1/utils/registry-conversion.d.ts.map +1 -1
  410. package/esm/v1/utils/registry-conversion.js +25 -23
  411. package/esm/v1/utils/registry-conversion.js.map +1 -1
  412. package/esm/v1/utils/registry-conversion.test.js +23 -0
  413. package/esm/v1/utils/registry-conversion.test.js.map +1 -1
  414. package/esm/v1/utils/stream-handler.d.ts +1 -1
  415. package/esm/v1/utils/stream-handler.js +1 -1
  416. package/esm/v1/utils/stream-handler.js.map +1 -1
  417. package/esm/v1/utils/thread-utils.d.ts +2 -2
  418. package/esm/v1/utils/thread-utils.d.ts.map +1 -1
  419. package/esm/v1/utils/thread-utils.js.map +1 -1
  420. package/esm/v1/utils/tool-call-tracker.d.ts +11 -1
  421. package/esm/v1/utils/tool-call-tracker.d.ts.map +1 -1
  422. package/esm/v1/utils/tool-call-tracker.js +14 -1
  423. package/esm/v1/utils/tool-call-tracker.js.map +1 -1
  424. package/esm/v1/utils/tool-call-tracker.test.d.ts +2 -0
  425. package/esm/v1/utils/tool-call-tracker.test.d.ts.map +1 -0
  426. package/esm/v1/utils/tool-call-tracker.test.js +65 -0
  427. package/esm/v1/utils/tool-call-tracker.test.js.map +1 -0
  428. package/esm/v1/utils/tool-executor.d.ts +35 -1
  429. package/esm/v1/utils/tool-executor.d.ts.map +1 -1
  430. package/esm/v1/utils/tool-executor.js +55 -2
  431. package/esm/v1/utils/tool-executor.js.map +1 -1
  432. package/esm/v1/utils/tool-executor.test.js +212 -1
  433. package/esm/v1/utils/tool-executor.test.js.map +1 -1
  434. package/package.json +5 -10
  435. package/dist/hooks/index.d.ts +0 -9
  436. package/dist/hooks/index.d.ts.map +0 -1
  437. package/dist/hooks/index.js +0 -34
  438. package/dist/hooks/index.js.map +0 -1
  439. package/dist/hooks/use-component-state.d.ts +0 -30
  440. package/dist/hooks/use-component-state.d.ts.map +0 -1
  441. package/dist/hooks/use-component-state.js +0 -139
  442. package/dist/hooks/use-component-state.js.map +0 -1
  443. package/dist/hooks/use-component-state.test.d.ts +0 -2
  444. package/dist/hooks/use-component-state.test.d.ts.map +0 -1
  445. package/dist/hooks/use-component-state.test.js +0 -406
  446. package/dist/hooks/use-component-state.test.js.map +0 -1
  447. package/dist/hooks/use-current-message.d.ts.map +0 -1
  448. package/dist/hooks/use-current-message.js.map +0 -1
  449. package/dist/hooks/use-current-message.test.d.ts +0 -2
  450. package/dist/hooks/use-current-message.test.d.ts.map +0 -1
  451. package/dist/hooks/use-current-message.test.js +0 -269
  452. package/dist/hooks/use-current-message.test.js.map +0 -1
  453. package/dist/hooks/use-streaming-props.d.ts +0 -11
  454. package/dist/hooks/use-streaming-props.d.ts.map +0 -1
  455. package/dist/hooks/use-streaming-props.js +0 -37
  456. package/dist/hooks/use-streaming-props.js.map +0 -1
  457. package/dist/hooks/use-suggestions.d.ts +0 -46
  458. package/dist/hooks/use-suggestions.d.ts.map +0 -1
  459. package/dist/hooks/use-suggestions.js +0 -118
  460. package/dist/hooks/use-suggestions.js.map +0 -1
  461. package/dist/hooks/use-suggestions.test.d.ts +0 -2
  462. package/dist/hooks/use-suggestions.test.d.ts.map +0 -1
  463. package/dist/hooks/use-suggestions.test.js +0 -247
  464. package/dist/hooks/use-suggestions.test.js.map +0 -1
  465. package/dist/hooks/use-tambo-stream-status.d.ts +0 -90
  466. package/dist/hooks/use-tambo-stream-status.d.ts.map +0 -1
  467. package/dist/hooks/use-tambo-stream-status.js +0 -213
  468. package/dist/hooks/use-tambo-stream-status.js.map +0 -1
  469. package/dist/hooks/use-tambo-stream-status.test.d.ts +0 -2
  470. package/dist/hooks/use-tambo-stream-status.test.d.ts.map +0 -1
  471. package/dist/hooks/use-tambo-stream-status.test.js +0 -378
  472. package/dist/hooks/use-tambo-stream-status.test.js.map +0 -1
  473. package/dist/hooks/use-tambo-threads.d.ts +0 -158
  474. package/dist/hooks/use-tambo-threads.d.ts.map +0 -1
  475. package/dist/hooks/use-tambo-threads.js +0 -45
  476. package/dist/hooks/use-tambo-threads.js.map +0 -1
  477. package/dist/hooks/use-tambo-threads.test.d.ts +0 -2
  478. package/dist/hooks/use-tambo-threads.test.d.ts.map +0 -1
  479. package/dist/hooks/use-tambo-threads.test.js +0 -214
  480. package/dist/hooks/use-tambo-threads.test.js.map +0 -1
  481. package/dist/model/generate-component-response.d.ts +0 -37
  482. package/dist/model/generate-component-response.d.ts.map +0 -1
  483. package/dist/model/generate-component-response.js +0 -29
  484. package/dist/model/generate-component-response.js.map +0 -1
  485. package/dist/model/tambo-thread.d.ts +0 -15
  486. package/dist/model/tambo-thread.d.ts.map +0 -1
  487. package/dist/model/tambo-thread.js.map +0 -1
  488. package/dist/providers/__tests__/thread-input-resource-resolution.test.d.ts +0 -2
  489. package/dist/providers/__tests__/thread-input-resource-resolution.test.d.ts.map +0 -1
  490. package/dist/providers/__tests__/thread-input-resource-resolution.test.js +0 -592
  491. package/dist/providers/__tests__/thread-input-resource-resolution.test.js.map +0 -1
  492. package/dist/providers/index.d.ts +0 -13
  493. package/dist/providers/index.d.ts.map +0 -1
  494. package/dist/providers/index.js +0 -41
  495. package/dist/providers/index.js.map +0 -1
  496. package/dist/providers/tambo-component-provider.d.ts +0 -23
  497. package/dist/providers/tambo-component-provider.d.ts.map +0 -1
  498. package/dist/providers/tambo-component-provider.js +0 -88
  499. package/dist/providers/tambo-component-provider.js.map +0 -1
  500. package/dist/providers/tambo-prop-stream-provider/index.d.ts +0 -19
  501. package/dist/providers/tambo-prop-stream-provider/index.d.ts.map +0 -1
  502. package/dist/providers/tambo-prop-stream-provider/index.js +0 -43
  503. package/dist/providers/tambo-prop-stream-provider/index.js.map +0 -1
  504. package/dist/providers/tambo-prop-stream-provider/pending.d.ts +0 -12
  505. package/dist/providers/tambo-prop-stream-provider/pending.d.ts.map +0 -1
  506. package/dist/providers/tambo-prop-stream-provider/pending.js +0 -31
  507. package/dist/providers/tambo-prop-stream-provider/pending.js.map +0 -1
  508. package/dist/providers/tambo-prop-stream-provider/provider.d.ts +0 -17
  509. package/dist/providers/tambo-prop-stream-provider/provider.d.ts.map +0 -1
  510. package/dist/providers/tambo-prop-stream-provider/provider.js +0 -107
  511. package/dist/providers/tambo-prop-stream-provider/provider.js.map +0 -1
  512. package/dist/providers/tambo-prop-stream-provider/streaming.d.ts +0 -12
  513. package/dist/providers/tambo-prop-stream-provider/streaming.d.ts.map +0 -1
  514. package/dist/providers/tambo-prop-stream-provider/streaming.js +0 -28
  515. package/dist/providers/tambo-prop-stream-provider/streaming.js.map +0 -1
  516. package/dist/providers/tambo-prop-stream-provider/success.d.ts +0 -12
  517. package/dist/providers/tambo-prop-stream-provider/success.d.ts.map +0 -1
  518. package/dist/providers/tambo-prop-stream-provider/success.js +0 -28
  519. package/dist/providers/tambo-prop-stream-provider/success.js.map +0 -1
  520. package/dist/providers/tambo-prop-stream-provider/types.d.ts +0 -25
  521. package/dist/providers/tambo-prop-stream-provider/types.d.ts.map +0 -1
  522. package/dist/providers/tambo-prop-stream-provider/types.js +0 -6
  523. package/dist/providers/tambo-prop-stream-provider/types.js.map +0 -1
  524. package/dist/providers/tambo-prop-stream-provider.test.d.ts +0 -2
  525. package/dist/providers/tambo-prop-stream-provider.test.d.ts.map +0 -1
  526. package/dist/providers/tambo-prop-stream-provider.test.js +0 -275
  527. package/dist/providers/tambo-prop-stream-provider.test.js.map +0 -1
  528. package/dist/providers/tambo-provider.d.ts +0 -53
  529. package/dist/providers/tambo-provider.d.ts.map +0 -1
  530. package/dist/providers/tambo-provider.js +0 -130
  531. package/dist/providers/tambo-provider.js.map +0 -1
  532. package/dist/providers/tambo-stubs.d.ts +0 -89
  533. package/dist/providers/tambo-stubs.d.ts.map +0 -1
  534. package/dist/providers/tambo-stubs.js +0 -276
  535. package/dist/providers/tambo-stubs.js.map +0 -1
  536. package/dist/providers/tambo-stubs.test.d.ts +0 -2
  537. package/dist/providers/tambo-stubs.test.d.ts.map +0 -1
  538. package/dist/providers/tambo-stubs.test.js +0 -97
  539. package/dist/providers/tambo-stubs.test.js.map +0 -1
  540. package/dist/providers/tambo-thread-input-provider.d.ts +0 -65
  541. package/dist/providers/tambo-thread-input-provider.d.ts.map +0 -1
  542. package/dist/providers/tambo-thread-input-provider.js +0 -179
  543. package/dist/providers/tambo-thread-input-provider.js.map +0 -1
  544. package/dist/providers/tambo-thread-provider-initial-messages.test.d.ts +0 -2
  545. package/dist/providers/tambo-thread-provider-initial-messages.test.d.ts.map +0 -1
  546. package/dist/providers/tambo-thread-provider-initial-messages.test.js +0 -275
  547. package/dist/providers/tambo-thread-provider-initial-messages.test.js.map +0 -1
  548. package/dist/providers/tambo-thread-provider.d.ts +0 -126
  549. package/dist/providers/tambo-thread-provider.d.ts.map +0 -1
  550. package/dist/providers/tambo-thread-provider.js +0 -931
  551. package/dist/providers/tambo-thread-provider.js.map +0 -1
  552. package/dist/providers/tambo-thread-provider.test.d.ts +0 -2
  553. package/dist/providers/tambo-thread-provider.test.d.ts.map +0 -1
  554. package/dist/providers/tambo-thread-provider.test.js +0 -1588
  555. package/dist/providers/tambo-thread-provider.test.js.map +0 -1
  556. package/dist/util/generate-component.d.ts +0 -12
  557. package/dist/util/generate-component.d.ts.map +0 -1
  558. package/dist/util/generate-component.js +0 -58
  559. package/dist/util/generate-component.js.map +0 -1
  560. package/dist/util/generate-component.test.d.ts +0 -2
  561. package/dist/util/generate-component.test.d.ts.map +0 -1
  562. package/dist/util/generate-component.test.js +0 -340
  563. package/dist/util/generate-component.test.js.map +0 -1
  564. package/esm/hooks/index.d.ts +0 -9
  565. package/esm/hooks/index.d.ts.map +0 -1
  566. package/esm/hooks/index.js +0 -10
  567. package/esm/hooks/index.js.map +0 -1
  568. package/esm/hooks/use-component-state.d.ts +0 -30
  569. package/esm/hooks/use-component-state.d.ts.map +0 -1
  570. package/esm/hooks/use-component-state.js +0 -136
  571. package/esm/hooks/use-component-state.js.map +0 -1
  572. package/esm/hooks/use-component-state.test.d.ts +0 -2
  573. package/esm/hooks/use-component-state.test.d.ts.map +0 -1
  574. package/esm/hooks/use-component-state.test.js +0 -401
  575. package/esm/hooks/use-component-state.test.js.map +0 -1
  576. package/esm/hooks/use-current-message.d.ts.map +0 -1
  577. package/esm/hooks/use-current-message.js.map +0 -1
  578. package/esm/hooks/use-current-message.test.d.ts +0 -2
  579. package/esm/hooks/use-current-message.test.d.ts.map +0 -1
  580. package/esm/hooks/use-current-message.test.js +0 -264
  581. package/esm/hooks/use-current-message.test.js.map +0 -1
  582. package/esm/hooks/use-streaming-props.d.ts +0 -11
  583. package/esm/hooks/use-streaming-props.d.ts.map +0 -1
  584. package/esm/hooks/use-streaming-props.js +0 -34
  585. package/esm/hooks/use-streaming-props.js.map +0 -1
  586. package/esm/hooks/use-suggestions.d.ts +0 -46
  587. package/esm/hooks/use-suggestions.d.ts.map +0 -1
  588. package/esm/hooks/use-suggestions.js +0 -115
  589. package/esm/hooks/use-suggestions.js.map +0 -1
  590. package/esm/hooks/use-suggestions.test.d.ts +0 -2
  591. package/esm/hooks/use-suggestions.test.d.ts.map +0 -1
  592. package/esm/hooks/use-suggestions.test.js +0 -245
  593. package/esm/hooks/use-suggestions.test.js.map +0 -1
  594. package/esm/hooks/use-tambo-stream-status.d.ts +0 -90
  595. package/esm/hooks/use-tambo-stream-status.d.ts.map +0 -1
  596. package/esm/hooks/use-tambo-stream-status.js +0 -210
  597. package/esm/hooks/use-tambo-stream-status.js.map +0 -1
  598. package/esm/hooks/use-tambo-stream-status.test.d.ts +0 -2
  599. package/esm/hooks/use-tambo-stream-status.test.d.ts.map +0 -1
  600. package/esm/hooks/use-tambo-stream-status.test.js +0 -376
  601. package/esm/hooks/use-tambo-stream-status.test.js.map +0 -1
  602. package/esm/hooks/use-tambo-threads.d.ts +0 -158
  603. package/esm/hooks/use-tambo-threads.d.ts.map +0 -1
  604. package/esm/hooks/use-tambo-threads.js +0 -42
  605. package/esm/hooks/use-tambo-threads.js.map +0 -1
  606. package/esm/hooks/use-tambo-threads.test.d.ts +0 -2
  607. package/esm/hooks/use-tambo-threads.test.d.ts.map +0 -1
  608. package/esm/hooks/use-tambo-threads.test.js +0 -212
  609. package/esm/hooks/use-tambo-threads.test.js.map +0 -1
  610. package/esm/model/generate-component-response.d.ts +0 -37
  611. package/esm/model/generate-component-response.d.ts.map +0 -1
  612. package/esm/model/generate-component-response.js +0 -25
  613. package/esm/model/generate-component-response.js.map +0 -1
  614. package/esm/model/tambo-thread.d.ts +0 -15
  615. package/esm/model/tambo-thread.d.ts.map +0 -1
  616. package/esm/model/tambo-thread.js +0 -2
  617. package/esm/model/tambo-thread.js.map +0 -1
  618. package/esm/providers/__tests__/thread-input-resource-resolution.test.d.ts +0 -2
  619. package/esm/providers/__tests__/thread-input-resource-resolution.test.d.ts.map +0 -1
  620. package/esm/providers/__tests__/thread-input-resource-resolution.test.js +0 -587
  621. package/esm/providers/__tests__/thread-input-resource-resolution.test.js.map +0 -1
  622. package/esm/providers/index.d.ts +0 -13
  623. package/esm/providers/index.d.ts.map +0 -1
  624. package/esm/providers/index.js +0 -11
  625. package/esm/providers/index.js.map +0 -1
  626. package/esm/providers/tambo-component-provider.d.ts +0 -23
  627. package/esm/providers/tambo-component-provider.d.ts.map +0 -1
  628. package/esm/providers/tambo-component-provider.js +0 -50
  629. package/esm/providers/tambo-component-provider.js.map +0 -1
  630. package/esm/providers/tambo-prop-stream-provider/index.d.ts +0 -19
  631. package/esm/providers/tambo-prop-stream-provider/index.d.ts.map +0 -1
  632. package/esm/providers/tambo-prop-stream-provider/index.js +0 -22
  633. package/esm/providers/tambo-prop-stream-provider/index.js.map +0 -1
  634. package/esm/providers/tambo-prop-stream-provider/pending.d.ts +0 -12
  635. package/esm/providers/tambo-prop-stream-provider/pending.d.ts.map +0 -1
  636. package/esm/providers/tambo-prop-stream-provider/pending.js +0 -24
  637. package/esm/providers/tambo-prop-stream-provider/pending.js.map +0 -1
  638. package/esm/providers/tambo-prop-stream-provider/provider.d.ts +0 -17
  639. package/esm/providers/tambo-prop-stream-provider/provider.d.ts.map +0 -1
  640. package/esm/providers/tambo-prop-stream-provider/provider.js +0 -70
  641. package/esm/providers/tambo-prop-stream-provider/provider.js.map +0 -1
  642. package/esm/providers/tambo-prop-stream-provider/streaming.d.ts +0 -12
  643. package/esm/providers/tambo-prop-stream-provider/streaming.d.ts.map +0 -1
  644. package/esm/providers/tambo-prop-stream-provider/streaming.js +0 -21
  645. package/esm/providers/tambo-prop-stream-provider/streaming.js.map +0 -1
  646. package/esm/providers/tambo-prop-stream-provider/success.d.ts +0 -12
  647. package/esm/providers/tambo-prop-stream-provider/success.d.ts.map +0 -1
  648. package/esm/providers/tambo-prop-stream-provider/success.js +0 -21
  649. package/esm/providers/tambo-prop-stream-provider/success.js.map +0 -1
  650. package/esm/providers/tambo-prop-stream-provider/types.d.ts +0 -25
  651. package/esm/providers/tambo-prop-stream-provider/types.d.ts.map +0 -1
  652. package/esm/providers/tambo-prop-stream-provider/types.js +0 -3
  653. package/esm/providers/tambo-prop-stream-provider/types.js.map +0 -1
  654. package/esm/providers/tambo-prop-stream-provider.test.d.ts +0 -2
  655. package/esm/providers/tambo-prop-stream-provider.test.d.ts.map +0 -1
  656. package/esm/providers/tambo-prop-stream-provider.test.js +0 -270
  657. package/esm/providers/tambo-prop-stream-provider.test.js.map +0 -1
  658. package/esm/providers/tambo-provider.d.ts +0 -53
  659. package/esm/providers/tambo-provider.d.ts.map +0 -1
  660. package/esm/providers/tambo-provider.js +0 -91
  661. package/esm/providers/tambo-provider.js.map +0 -1
  662. package/esm/providers/tambo-stubs.d.ts +0 -89
  663. package/esm/providers/tambo-stubs.d.ts.map +0 -1
  664. package/esm/providers/tambo-stubs.js +0 -239
  665. package/esm/providers/tambo-stubs.js.map +0 -1
  666. package/esm/providers/tambo-stubs.test.d.ts +0 -2
  667. package/esm/providers/tambo-stubs.test.d.ts.map +0 -1
  668. package/esm/providers/tambo-stubs.test.js +0 -62
  669. package/esm/providers/tambo-stubs.test.js.map +0 -1
  670. package/esm/providers/tambo-thread-input-provider.d.ts +0 -65
  671. package/esm/providers/tambo-thread-input-provider.d.ts.map +0 -1
  672. package/esm/providers/tambo-thread-input-provider.js +0 -141
  673. package/esm/providers/tambo-thread-input-provider.js.map +0 -1
  674. package/esm/providers/tambo-thread-provider-initial-messages.test.d.ts +0 -2
  675. package/esm/providers/tambo-thread-provider-initial-messages.test.d.ts.map +0 -1
  676. package/esm/providers/tambo-thread-provider-initial-messages.test.js +0 -270
  677. package/esm/providers/tambo-thread-provider-initial-messages.test.js.map +0 -1
  678. package/esm/providers/tambo-thread-provider.d.ts +0 -126
  679. package/esm/providers/tambo-thread-provider.d.ts.map +0 -1
  680. package/esm/providers/tambo-thread-provider.js +0 -891
  681. package/esm/providers/tambo-thread-provider.js.map +0 -1
  682. package/esm/providers/tambo-thread-provider.test.d.ts +0 -2
  683. package/esm/providers/tambo-thread-provider.test.d.ts.map +0 -1
  684. package/esm/providers/tambo-thread-provider.test.js +0 -1550
  685. package/esm/providers/tambo-thread-provider.test.js.map +0 -1
  686. package/esm/util/generate-component.d.ts +0 -12
  687. package/esm/util/generate-component.d.ts.map +0 -1
  688. package/esm/util/generate-component.js +0 -52
  689. package/esm/util/generate-component.js.map +0 -1
  690. package/esm/util/generate-component.test.d.ts +0 -2
  691. package/esm/util/generate-component.test.d.ts.map +0 -1
  692. package/esm/util/generate-component.test.js +0 -302
  693. package/esm/util/generate-component.test.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"registry-conversion.test.js","sourceRoot":"","sources":["../../../src/v1/utils/registry-conversion.test.ts"],"names":[],"mappings":";;AAAA,6BAAwB;AAKxB,+DAK+B;AAE/B,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;QACpC,EAAE,CAAC,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,EAAE,CAAC,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,CAAC;oBACxC,YAAY,EAAE,OAAC,CAAC,GAAG,EAAE;iBACtB;gBACD,OAAO,EAAE;oBACP,IAAI,EAAE,SAAS;oBACf,WAAW,EAAE,gBAAgB;oBAC7B,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI;iBACC;aAC1B,CAAC;YAEF,MAAM,MAAM,GAAG,IAAA,sCAAgB,EAAC,KAAK,CAAC,CAAC;YAEvC,MAAM,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YAC/B,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACrC,MAAM,CAAC,OAAO,CAAC,CAAC,oBAAoB,CAClC,MAAM,CAAC,gBAAgB,CAAC,yBAAyB,CAAC,CACnD,CAAC;YAEF,OAAO,CAAC,WAAW,EAAE,CAAC;QACxB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { z } from \"zod\";\nimport type {\n RegisteredComponent,\n TamboTool,\n} from \"../../model/component-metadata\";\nimport {\n toAvailableComponent,\n toAvailableComponents,\n toAvailableTool,\n toAvailableTools,\n} from \"./registry-conversion\";\n\ndescribe(\"registry-conversion\", () => {\n describe(\"toAvailableComponent\", () => {\n it(\"converts a component with props (JSON Schema)\", () => {\n // RegisteredComponent has props already converted to JSON Schema\n const component: RegisteredComponent = {\n name: \"WeatherCard\",\n description: \"Displays weather information\",\n component: () => null,\n props: {\n type: \"object\",\n properties: {\n city: { type: \"string\" },\n temperature: { type: \"number\" },\n },\n required: [\"city\", \"temperature\"],\n },\n contextTools: [],\n };\n\n const result = toAvailableComponent(component);\n\n expect(result.name).toBe(\"WeatherCard\");\n expect(result.description).toBe(\"Displays weather information\");\n expect(result.propsSchema).toBeDefined();\n expect((result.propsSchema as Record<string, unknown>).type).toBe(\n \"object\",\n );\n });\n\n it(\"throws when props is missing\", () => {\n const component = {\n name: \"BadComponent\",\n description: \"Missing schema\",\n component: () => null,\n contextTools: [],\n } as unknown as RegisteredComponent;\n\n expect(() => toAvailableComponent(component)).toThrow(\n 'Component \"BadComponent\" missing props',\n );\n });\n });\n\n describe(\"toAvailableComponents\", () => {\n it(\"converts a Record of components\", () => {\n const components: Record<string, RegisteredComponent> = {\n Card: {\n name: \"Card\",\n description: \"A card component\",\n component: () => null,\n props: {\n type: \"object\",\n properties: { title: { type: \"string\" } },\n required: [\"title\"],\n },\n contextTools: [],\n },\n Button: {\n name: \"Button\",\n description: \"A button component\",\n component: () => null,\n props: {\n type: \"object\",\n properties: { label: { type: \"string\" } },\n required: [\"label\"],\n },\n contextTools: [],\n },\n };\n\n const result = toAvailableComponents(components);\n\n expect(result).toHaveLength(2);\n expect(result.map((c) => c.name)).toContain(\"Card\");\n expect(result.map((c) => c.name)).toContain(\"Button\");\n });\n\n it(\"converts a Map of components\", () => {\n const components = new Map<string, RegisteredComponent>([\n [\n \"Card\",\n {\n name: \"Card\",\n description: \"A card\",\n component: () => null,\n props: {\n type: \"object\",\n properties: { title: { type: \"string\" } },\n required: [\"title\"],\n },\n contextTools: [],\n },\n ],\n ]);\n\n const result = toAvailableComponents(components);\n\n expect(result).toHaveLength(1);\n expect(result[0].name).toBe(\"Card\");\n });\n\n it(\"skips invalid components and logs warning\", () => {\n const warnSpy = jest.spyOn(console, \"warn\").mockImplementation(() => {});\n\n const components: Record<string, RegisteredComponent> = {\n Valid: {\n name: \"Valid\",\n description: \"Valid component\",\n component: () => null,\n props: {\n type: \"object\",\n properties: { x: { type: \"string\" } },\n required: [\"x\"],\n },\n contextTools: [],\n },\n Invalid: {\n name: \"Invalid\",\n description: \"Missing schema\",\n component: () => null,\n contextTools: [],\n } as unknown as RegisteredComponent,\n };\n\n const result = toAvailableComponents(components);\n\n expect(result).toHaveLength(1);\n expect(result[0].name).toBe(\"Valid\");\n expect(warnSpy).toHaveBeenCalledWith(\n expect.stringContaining('Skipping component \"Invalid\"'),\n );\n\n warnSpy.mockRestore();\n });\n });\n\n describe(\"toAvailableTool\", () => {\n it(\"converts a tool with inputSchema\", () => {\n const tool: TamboTool = {\n name: \"get_weather\",\n description: \"Gets weather for a city\",\n tool: async () => ({ temp: 72 }),\n inputSchema: z.object({ city: z.string() }),\n outputSchema: z.any(),\n };\n\n const result = toAvailableTool(tool);\n\n expect(result.name).toBe(\"get_weather\");\n expect(result.description).toBe(\"Gets weather for a city\");\n expect(result.inputSchema).toBeDefined();\n expect((result.inputSchema as Record<string, unknown>).type).toBe(\n \"object\",\n );\n });\n\n it(\"throws when schema is missing\", () => {\n const tool = {\n name: \"bad_tool\",\n description: \"Missing schema\",\n tool: async () => ({}),\n } as unknown as TamboTool;\n\n expect(() => toAvailableTool(tool)).toThrow(\n 'Tool \"bad_tool\" missing inputSchema or toolSchema',\n );\n });\n });\n\n describe(\"toAvailableTools\", () => {\n it(\"converts a Record of tools\", () => {\n const tools: Record<string, TamboTool> = {\n search: {\n name: \"search\",\n description: \"Search the web\",\n tool: async () => [],\n inputSchema: z.object({ query: z.string() }),\n outputSchema: z.any(),\n },\n calculate: {\n name: \"calculate\",\n description: \"Calculate expression\",\n tool: async () => 0,\n inputSchema: z.object({ expr: z.string() }),\n outputSchema: z.any(),\n },\n };\n\n const result = toAvailableTools(tools);\n\n expect(result).toHaveLength(2);\n expect(result.map((t) => t.name)).toContain(\"search\");\n expect(result.map((t) => t.name)).toContain(\"calculate\");\n });\n\n it(\"converts a Map of tools\", () => {\n const tools = new Map<string, TamboTool>([\n [\n \"fetch\",\n {\n name: \"fetch\",\n description: \"Fetch data\",\n tool: async () => null,\n inputSchema: z.object({ url: z.string() }),\n outputSchema: z.any(),\n },\n ],\n ]);\n\n const result = toAvailableTools(tools);\n\n expect(result).toHaveLength(1);\n expect(result[0].name).toBe(\"fetch\");\n });\n\n it(\"skips invalid tools and logs warning\", () => {\n const warnSpy = jest.spyOn(console, \"warn\").mockImplementation(() => {});\n\n const tools: Record<string, TamboTool> = {\n valid: {\n name: \"valid\",\n description: \"Valid tool\",\n tool: async () => null,\n inputSchema: z.object({ x: z.number() }),\n outputSchema: z.any(),\n },\n invalid: {\n name: \"invalid\",\n description: \"Missing schema\",\n tool: async () => null,\n } as unknown as TamboTool,\n };\n\n const result = toAvailableTools(tools);\n\n expect(result).toHaveLength(1);\n expect(result[0].name).toBe(\"valid\");\n expect(warnSpy).toHaveBeenCalledWith(\n expect.stringContaining('Skipping tool \"invalid\"'),\n );\n\n warnSpy.mockRestore();\n });\n });\n});\n"]}
1
+ {"version":3,"file":"registry-conversion.test.js","sourceRoot":"","sources":["../../../src/v1/utils/registry-conversion.test.ts"],"names":[],"mappings":";;AAAA,6BAAwB;AAKxB,+DAK+B;AAE/B,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;QACpC,EAAE,CAAC,+CAA+C,EAAE,GAAG,EAAE;YACvD,iEAAiE;YACjE,MAAM,SAAS,GAAwB;gBACrC,IAAI,EAAE,aAAa;gBACnB,WAAW,EAAE,8BAA8B;gBAC3C,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI;gBACrB,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;wBACxB,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;qBAChC;oBACD,QAAQ,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC;iBAClC;gBACD,YAAY,EAAE,EAAE;aACjB,CAAC;YAEF,MAAM,MAAM,GAAG,IAAA,0CAAoB,EAAC,SAAS,CAAC,CAAC;YAE/C,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YACxC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,I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AI,CAAC,OAAO,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;YAC9C,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,kBAAkB,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;YAEzE,MAAM,KAAK,GAA8B;gBACvC,KAAK,EAAE;oBACL,IAAI,EAAE,OAAO;oBACb,WAAW,EAAE,YAAY;oBACzB,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI;oBACtB,WAAW,EAAE,OAAC,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,CAAC;oBACxC,YAAY,EAAE,OAAC,CAAC,GAAG,EAAE;iBACtB;gBACD,OAAO,EAAE;oBACP,IAAI,EAAE,SAAS;oBACf,WAAW,EAAE,gBAAgB;oBAC7B,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI;iBACC;aAC1B,CAAC;YAEF,MAAM,MAAM,GAAG,IAAA,sCAAgB,EAAC,KAAK,CAAC,CAAC;YAEvC,MAAM,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YAC/B,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACrC,MAAM,CAAC,OAAO,CAAC,CAAC,oBAAoB,CAClC,MAAM,CAAC,gBAAgB,CAAC,yBAAyB,CAAC,CACnD,CAAC;YAEF,OAAO,CAAC,WAAW,EAAE,CAAC;QACxB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { z } from \"zod\";\nimport type {\n RegisteredComponent,\n TamboTool,\n} from \"../../model/component-metadata\";\nimport {\n toAvailableComponent,\n toAvailableComponents,\n toAvailableTool,\n toAvailableTools,\n} from \"./registry-conversion\";\n\ndescribe(\"registry-conversion\", () => {\n describe(\"toAvailableComponent\", () => {\n it(\"converts a component with props (JSON Schema)\", () => {\n // RegisteredComponent has props already converted to JSON Schema\n const component: RegisteredComponent = {\n name: \"WeatherCard\",\n description: \"Displays weather information\",\n component: () => null,\n props: {\n type: \"object\",\n properties: {\n city: { type: \"string\" },\n temperature: { type: \"number\" },\n },\n required: [\"city\", \"temperature\"],\n },\n contextTools: [],\n };\n\n const result = toAvailableComponent(component);\n\n expect(result.name).toBe(\"WeatherCard\");\n expect(result.description).toBe(\"Displays weather information\");\n expect(result.propsSchema).toBeDefined();\n expect((result.propsSchema as Record<string, unknown>).type).toBe(\n \"object\",\n );\n });\n\n it(\"throws when props is missing\", () => {\n const component = {\n name: \"BadComponent\",\n description: \"Missing schema\",\n component: () => null,\n contextTools: [],\n } as unknown as RegisteredComponent;\n\n expect(() => toAvailableComponent(component)).toThrow(\n 'Component \"BadComponent\" missing props',\n );\n });\n });\n\n describe(\"toAvailableComponents\", () => {\n it(\"converts a Record of components\", () => {\n const components: Record<string, RegisteredComponent> = {\n Card: {\n name: \"Card\",\n description: \"A card component\",\n component: () => null,\n props: {\n type: \"object\",\n properties: { title: { type: \"string\" } },\n required: [\"title\"],\n },\n contextTools: [],\n },\n Button: {\n name: \"Button\",\n description: \"A button component\",\n component: () => null,\n props: {\n type: \"object\",\n properties: { label: { type: \"string\" } },\n required: [\"label\"],\n },\n contextTools: [],\n },\n };\n\n const result = toAvailableComponents(components);\n\n expect(result).toHaveLength(2);\n expect(result.map((c) => c.name)).toContain(\"Card\");\n expect(result.map((c) => c.name)).toContain(\"Button\");\n });\n\n it(\"converts a Map of components\", () => {\n const components = new Map<string, RegisteredComponent>([\n [\n \"Card\",\n {\n name: \"Card\",\n description: \"A card\",\n component: () => null,\n props: {\n type: \"object\",\n properties: { title: { type: \"string\" } },\n required: [\"title\"],\n },\n contextTools: [],\n },\n ],\n ]);\n\n const result = toAvailableComponents(components);\n\n expect(result).toHaveLength(1);\n expect(result[0].name).toBe(\"Card\");\n });\n\n it(\"skips invalid components and logs warning\", () => {\n const warnSpy = jest.spyOn(console, \"warn\").mockImplementation(() => {});\n\n const components: Record<string, RegisteredComponent> = {\n Valid: {\n name: \"Valid\",\n description: \"Valid component\",\n component: () => null,\n props: {\n type: \"object\",\n properties: { x: { type: \"string\" } },\n required: [\"x\"],\n },\n contextTools: [],\n },\n Invalid: {\n name: \"Invalid\",\n description: \"Missing schema\",\n component: () => null,\n contextTools: [],\n } as unknown as RegisteredComponent,\n };\n\n const result = toAvailableComponents(components);\n\n expect(result).toHaveLength(1);\n expect(result[0].name).toBe(\"Valid\");\n expect(warnSpy).toHaveBeenCalledWith(\n expect.stringContaining('Skipping component \"Invalid\"'),\n );\n\n warnSpy.mockRestore();\n });\n });\n\n describe(\"toAvailableTool\", () => {\n it(\"converts a tool with inputSchema\", () => {\n const tool: TamboTool = {\n name: \"get_weather\",\n description: \"Gets weather for a city\",\n tool: async () => ({ temp: 72 }),\n inputSchema: z.object({ city: z.string() }),\n outputSchema: z.any(),\n };\n\n const result = toAvailableTool(tool);\n\n expect(result.name).toBe(\"get_weather\");\n expect(result.description).toBe(\"Gets weather for a city\");\n expect(result.inputSchema).toBeDefined();\n expect((result.inputSchema as Record<string, unknown>).type).toBe(\n \"object\",\n );\n });\n\n it(\"includes maxCalls when set\", () => {\n const tool: TamboTool = {\n name: \"limited_tool\",\n description: \"Tool with call limit\",\n tool: async () => ({}),\n inputSchema: z.object({ x: z.string() }),\n outputSchema: z.any(),\n maxCalls: 3,\n };\n\n const result = toAvailableTool(tool);\n\n expect(result.maxCalls).toBe(3);\n });\n\n it(\"omits maxCalls when not set\", () => {\n const tool: TamboTool = {\n name: \"unlimited_tool\",\n description: \"Tool without call limit\",\n tool: async () => ({}),\n inputSchema: z.object({ x: z.string() }),\n outputSchema: z.any(),\n };\n\n const result = toAvailableTool(tool);\n\n expect(result).not.toHaveProperty(\"maxCalls\");\n });\n\n it(\"throws when schema is missing\", () => {\n const tool = {\n name: \"bad_tool\",\n description: \"Missing schema\",\n tool: async () => ({}),\n } as unknown as TamboTool;\n\n expect(() => toAvailableTool(tool)).toThrow(\n 'Tool \"bad_tool\" missing inputSchema or toolSchema',\n );\n });\n });\n\n describe(\"toAvailableTools\", () => {\n it(\"converts a Record of tools\", () => {\n const tools: Record<string, TamboTool> = {\n search: {\n name: \"search\",\n description: \"Search the web\",\n tool: async () => [],\n inputSchema: z.object({ query: z.string() }),\n outputSchema: z.any(),\n },\n calculate: {\n name: \"calculate\",\n description: \"Calculate expression\",\n tool: async () => 0,\n inputSchema: z.object({ expr: z.string() }),\n outputSchema: z.any(),\n },\n };\n\n const result = toAvailableTools(tools);\n\n expect(result).toHaveLength(2);\n expect(result.map((t) => t.name)).toContain(\"search\");\n expect(result.map((t) => t.name)).toContain(\"calculate\");\n });\n\n it(\"converts a Map of tools\", () => {\n const tools = new Map<string, TamboTool>([\n [\n \"fetch\",\n {\n name: \"fetch\",\n description: \"Fetch data\",\n tool: async () => null,\n inputSchema: z.object({ url: z.string() }),\n outputSchema: z.any(),\n },\n ],\n ]);\n\n const result = toAvailableTools(tools);\n\n expect(result).toHaveLength(1);\n expect(result[0].name).toBe(\"fetch\");\n });\n\n it(\"skips invalid tools and logs warning\", () => {\n const warnSpy = jest.spyOn(console, \"warn\").mockImplementation(() => {});\n\n const tools: Record<string, TamboTool> = {\n valid: {\n name: \"valid\",\n description: \"Valid tool\",\n tool: async () => null,\n inputSchema: z.object({ x: z.number() }),\n outputSchema: z.any(),\n },\n invalid: {\n name: \"invalid\",\n description: \"Missing schema\",\n tool: async () => null,\n } as unknown as TamboTool,\n };\n\n const result = toAvailableTools(tools);\n\n expect(result).toHaveLength(1);\n expect(result[0].name).toBe(\"valid\");\n expect(warnSpy).toHaveBeenCalledWith(\n expect.stringContaining('Skipping tool \"invalid\"'),\n );\n\n warnSpy.mockRestore();\n });\n });\n});\n"]}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Stream Handler for v1 Streaming API
2
+ * Stream Handler for Streaming API
3
3
  *
4
4
  * Provides utilities for handling event streams from the TypeScript SDK.
5
5
  * The SDK's client.threads.runs.run() already returns an async iterable,
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * Stream Handler for v1 Streaming API
3
+ * Stream Handler for Streaming API
4
4
  *
5
5
  * Provides utilities for handling event streams from the TypeScript SDK.
6
6
  * The SDK's client.threads.runs.run() already returns an async iterable,
@@ -1 +1 @@
1
- {"version":3,"file":"stream-handler.js","sourceRoot":"","sources":["../../../src/v1/utils/stream-handler.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAwCH,8CAeC;AAxCD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACI,KAAK,SAAS,CAAC,CAAC,iBAAiB,CACtC,MAA8B,EAC9B,OAA8B;IAE9B,MAAM,EAAE,KAAK,GAAG,KAAK,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IAExC,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QACjC,IAAI,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;YACnD,sCAAsC;YACtC,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;QAC/C,CAAC;QAED,qEAAqE;QACrE,MAAM,KAAkB,CAAC;IAC3B,CAAC;AACH,CAAC","sourcesContent":["/**\n * Stream Handler for v1 Streaming API\n *\n * Provides utilities for handling event streams from the TypeScript SDK.\n * The SDK's client.threads.runs.run() already returns an async iterable,\n * so this module just adds optional debug logging.\n */\n\nimport type { AGUIEvent } from \"@ag-ui/core\";\n\n/**\n * Options for stream handling.\n */\nexport interface StreamHandlerOptions {\n /**\n * Enable debug logging (development mode only).\n * Logs all events to console.\n */\n debug?: boolean;\n}\n\n/**\n * Handle an event stream from the TypeScript SDK and yield AG-UI event types.\n *\n * The TypeScript SDK's client.threads.runs.run() and client.threads.runs.create()\n * return async iterables that yield events compatible with AG-UI's AGUIEvent.\n * This function wraps the stream to add optional debug logging and ensures\n * proper typing.\n *\n * Note: SDK events have `type: string` rather than `type: EventType` enum,\n * but the values are compatible with AG-UI event types.\n * @param stream - Async iterable of events from SDK\n * @param options - Optional configuration for stream handling\n * @yields {AGUIEvent} AG-UI event types from the stream\n * @returns Async iterable of AG-UI event types\n * @example\n * ```typescript\n * const stream = await client.threads.runs.run(threadId, {\n * message: { role: \"user\", content: [{ type: \"text\", text: \"hello\" }] },\n * });\n *\n * for await (const event of handleEventStream(stream, { debug: true })) {\n * dispatch({ type: 'EVENT', event }); // Send to reducer\n * }\n * ```\n */\nexport async function* handleEventStream(\n stream: AsyncIterable<unknown>,\n options?: StreamHandlerOptions,\n): AsyncIterable<AGUIEvent> {\n const { debug = false } = options ?? {};\n\n for await (const event of stream) {\n if (debug && process.env.NODE_ENV !== \"production\") {\n // eslint-disable-next-line no-console\n console.log(\"[StreamHandler] Event:\", event);\n }\n\n // SDK events are compatible with AG-UI AGUIEvent discriminated union\n yield event as AGUIEvent;\n }\n}\n"]}
1
+ {"version":3,"file":"stream-handler.js","sourceRoot":"","sources":["../../../src/v1/utils/stream-handler.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAwCH,8CAeC;AAxCD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACI,KAAK,SAAS,CAAC,CAAC,iBAAiB,CACtC,MAA8B,EAC9B,OAA8B;IAE9B,MAAM,EAAE,KAAK,GAAG,KAAK,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IAExC,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QACjC,IAAI,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;YACnD,sCAAsC;YACtC,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;QAC/C,CAAC;QAED,qEAAqE;QACrE,MAAM,KAAkB,CAAC;IAC3B,CAAC;AACH,CAAC","sourcesContent":["/**\n * Stream Handler for Streaming API\n *\n * Provides utilities for handling event streams from the TypeScript SDK.\n * The SDK's client.threads.runs.run() already returns an async iterable,\n * so this module just adds optional debug logging.\n */\n\nimport type { AGUIEvent } from \"@ag-ui/core\";\n\n/**\n * Options for stream handling.\n */\nexport interface StreamHandlerOptions {\n /**\n * Enable debug logging (development mode only).\n * Logs all events to console.\n */\n debug?: boolean;\n}\n\n/**\n * Handle an event stream from the TypeScript SDK and yield AG-UI event types.\n *\n * The TypeScript SDK's client.threads.runs.run() and client.threads.runs.create()\n * return async iterables that yield events compatible with AG-UI's AGUIEvent.\n * This function wraps the stream to add optional debug logging and ensures\n * proper typing.\n *\n * Note: SDK events have `type: string` rather than `type: EventType` enum,\n * but the values are compatible with AG-UI event types.\n * @param stream - Async iterable of events from SDK\n * @param options - Optional configuration for stream handling\n * @yields {AGUIEvent} AG-UI event types from the stream\n * @returns Async iterable of AG-UI event types\n * @example\n * ```typescript\n * const stream = await client.threads.runs.run(threadId, {\n * message: { role: \"user\", content: [{ type: \"text\", text: \"hello\" }] },\n * });\n *\n * for await (const event of handleEventStream(stream, { debug: true })) {\n * dispatch({ type: 'EVENT', event }); // Send to reducer\n * }\n * ```\n */\nexport async function* handleEventStream(\n stream: AsyncIterable<unknown>,\n options?: StreamHandlerOptions,\n): AsyncIterable<AGUIEvent> {\n const { debug = false } = options ?? {};\n\n for await (const event of stream) {\n if (debug && process.env.NODE_ENV !== \"production\") {\n // eslint-disable-next-line no-console\n console.log(\"[StreamHandler] Event:\", event);\n }\n\n // SDK events are compatible with AG-UI AGUIEvent discriminated union\n yield event as AGUIEvent;\n }\n}\n"]}
@@ -2,7 +2,7 @@
2
2
  * Thread utility functions for searching and accessing thread content.
3
3
  */
4
4
  import type { StreamState } from "./event-accumulator";
5
- import type { V1ComponentContent } from "../types/message";
5
+ import type { TamboComponentContent } from "../types/message";
6
6
  /**
7
7
  * Find a component content block by ID in a specific thread.
8
8
  * Searches from most recent messages first since active components are likely near the tail.
@@ -12,5 +12,5 @@ import type { V1ComponentContent } from "../types/message";
12
12
  * @param componentId - The component ID to find
13
13
  * @returns The component content block, or undefined if not found
14
14
  */
15
- export declare function findComponentContent(streamState: StreamState, threadId: string, componentId: string): V1ComponentContent | undefined;
15
+ export declare function findComponentContent(streamState: StreamState, threadId: string, componentId: string): TamboComponentContent | undefined;
16
16
  //# sourceMappingURL=thread-utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"thread-utils.d.ts","sourceRoot":"","sources":["../../../src/v1/utils/thread-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE3D;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,GAClB,kBAAkB,GAAG,SAAS,CAkBhC"}
1
+ {"version":3,"file":"thread-utils.d.ts","sourceRoot":"","sources":["../../../src/v1/utils/thread-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAE9D;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,GAClB,qBAAqB,GAAG,SAAS,CAkBnC"}
@@ -1 +1 @@
1
- {"version":3,"file":"thread-utils.js","sourceRoot":"","sources":["../../../src/v1/utils/thread-utils.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAcH,oDAsBC;AA/BD;;;;;;;;GAQG;AACH,SAAgB,oBAAoB,CAClC,WAAwB,EACxB,QAAgB,EAChB,WAAmB;IAEnB,MAAM,WAAW,GAAG,WAAW,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACpD,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,gEAAgE;IAChE,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC;IAC7C,KAAK,IAAI,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9C,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QACpC,KAAK,IAAI,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC7C,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;YACzB,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,IAAI,KAAK,CAAC,EAAE,KAAK,WAAW,EAAE,CAAC;gBAC3D,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["/**\n * Thread utility functions for searching and accessing thread content.\n */\n\nimport type { StreamState } from \"./event-accumulator\";\nimport type { V1ComponentContent } from \"../types/message\";\n\n/**\n * Find a component content block by ID in a specific thread.\n * Searches from most recent messages first since active components are likely near the tail.\n * Only searches the specified thread to prevent cross-thread data access.\n * @param streamState - The current stream state containing thread data\n * @param threadId - The thread ID to search in\n * @param componentId - The component ID to find\n * @returns The component content block, or undefined if not found\n */\nexport function findComponentContent(\n streamState: StreamState,\n threadId: string,\n componentId: string,\n): V1ComponentContent | undefined {\n const threadState = streamState.threadMap[threadId];\n if (!threadState) {\n return undefined;\n }\n\n // Search from most recent messages first for better performance\n const messages = threadState.thread.messages;\n for (let i = messages.length - 1; i >= 0; i--) {\n const content = messages[i].content;\n for (let j = content.length - 1; j >= 0; j--) {\n const block = content[j];\n if (block.type === \"component\" && block.id === componentId) {\n return block;\n }\n }\n }\n return undefined;\n}\n"]}
1
+ {"version":3,"file":"thread-utils.js","sourceRoot":"","sources":["../../../src/v1/utils/thread-utils.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAcH,oDAsBC;AA/BD;;;;;;;;GAQG;AACH,SAAgB,oBAAoB,CAClC,WAAwB,EACxB,QAAgB,EAChB,WAAmB;IAEnB,MAAM,WAAW,GAAG,WAAW,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACpD,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,gEAAgE;IAChE,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC;IAC7C,KAAK,IAAI,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9C,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QACpC,KAAK,IAAI,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC7C,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;YACzB,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,IAAI,KAAK,CAAC,EAAE,KAAK,WAAW,EAAE,CAAC;gBAC3D,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["/**\n * Thread utility functions for searching and accessing thread content.\n */\n\nimport type { StreamState } from \"./event-accumulator\";\nimport type { TamboComponentContent } from \"../types/message\";\n\n/**\n * Find a component content block by ID in a specific thread.\n * Searches from most recent messages first since active components are likely near the tail.\n * Only searches the specified thread to prevent cross-thread data access.\n * @param streamState - The current stream state containing thread data\n * @param threadId - The thread ID to search in\n * @param componentId - The component ID to find\n * @returns The component content block, or undefined if not found\n */\nexport function findComponentContent(\n streamState: StreamState,\n threadId: string,\n componentId: string,\n): TamboComponentContent | undefined {\n const threadState = streamState.threadMap[threadId];\n if (!threadState) {\n return undefined;\n }\n\n // Search from most recent messages first for better performance\n const messages = threadState.thread.messages;\n for (let i = messages.length - 1; i >= 0; i--) {\n const content = messages[i].content;\n for (let j = content.length - 1; j >= 0; j--) {\n const block = content[j];\n if (block.type === \"component\" && block.id === componentId) {\n return block;\n }\n }\n }\n return undefined;\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Tool Call Tracker for v1 API
2
+ * Tool Call Tracker
3
3
  *
4
4
  * Tracks tool calls during streaming, accumulating arguments until complete.
5
5
  * Used by the send message hook to collect tool call state for execution.
@@ -26,6 +26,16 @@ export declare class ToolCallTracker {
26
26
  * @throws {Error} If JSON parsing fails on TOOL_CALL_END (fail-fast, no silent fallback)
27
27
  */
28
28
  handleEvent(event: AGUIEvent): void;
29
+ /**
30
+ * Gets the name and accumulated args for a tool call that is still accumulating.
31
+ * Used by the event loop to get tool state for partial JSON parsing.
32
+ * @param toolCallId - ID of the tool call to look up
33
+ * @returns The tool name and raw accumulated args string, or undefined if not found
34
+ */
35
+ getAccumulatingToolCall(toolCallId: string): {
36
+ name: string;
37
+ accumulatedArgs: string;
38
+ } | undefined;
29
39
  /**
30
40
  * Gets tool calls for the given IDs, filtered to only those that exist.
31
41
  * @param toolCallIds - IDs of tool calls to retrieve
@@ -1 +1 @@
1
- {"version":3,"file":"tool-call-tracker.d.ts","sourceRoot":"","sources":["../../../src/v1/utils/tool-call-tracker.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD;;;;;;;;;;GAUG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,gBAAgB,CAAsC;IAC9D,OAAO,CAAC,gBAAgB,CAA6B;IAErD;;;;OAIG;IACH,WAAW,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI;IAyCnC;;;;OAIG;IACH,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC;IAWrE;;;OAGG;IACH,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,IAAI;CAM5C"}
1
+ {"version":3,"file":"tool-call-tracker.d.ts","sourceRoot":"","sources":["../../../src/v1/utils/tool-call-tracker.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD;;;;;;;;;;GAUG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,gBAAgB,CAAsC;IAC9D,OAAO,CAAC,gBAAgB,CAA6B;IAErD;;;;OAIG;IACH,WAAW,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI;IAyCnC;;;;;OAKG;IACH,uBAAuB,CACrB,UAAU,EAAE,MAAM,GACjB;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS;IAOxD;;;;OAIG;IACH,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC;IAWrE;;;OAGG;IACH,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,IAAI;CAM5C"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * Tool Call Tracker for v1 API
3
+ * Tool Call Tracker
4
4
  *
5
5
  * Tracks tool calls during streaming, accumulating arguments until complete.
6
6
  * Used by the send message hook to collect tool call state for execution.
@@ -60,6 +60,19 @@ class ToolCallTracker {
60
60
  break;
61
61
  }
62
62
  }
63
+ /**
64
+ * Gets the name and accumulated args for a tool call that is still accumulating.
65
+ * Used by the event loop to get tool state for partial JSON parsing.
66
+ * @param toolCallId - ID of the tool call to look up
67
+ * @returns The tool name and raw accumulated args string, or undefined if not found
68
+ */
69
+ getAccumulatingToolCall(toolCallId) {
70
+ const toolCall = this.pendingToolCalls.get(toolCallId);
71
+ const args = this.accumulatingArgs.get(toolCallId);
72
+ if (!toolCall || args === undefined)
73
+ return undefined;
74
+ return { name: toolCall.name, accumulatedArgs: args };
75
+ }
63
76
  /**
64
77
  * Gets tool calls for the given IDs, filtered to only those that exist.
65
78
  * @param toolCallIds - IDs of tool calls to retrieve
@@ -1 +1 @@
1
- {"version":3,"file":"tool-call-tracker.js","sourceRoot":"","sources":["../../../src/v1/utils/tool-call-tracker.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,sCAAwD;AAGxD;;;;;;;;;;GAUG;AACH,MAAa,eAAe;IAClB,gBAAgB,GAAG,IAAI,GAAG,EAA2B,CAAC;IACtD,gBAAgB,GAAG,IAAI,GAAG,EAAkB,CAAC;IAErD;;;;OAIG;IACH,WAAW,CAAC,KAAgB;QAC1B,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;YACnB,KAAK,gBAAS,CAAC,eAAe;gBAC5B,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,EAAE;oBAC1C,IAAI,EAAE,KAAK,CAAC,YAAY;oBACxB,KAAK,EAAE,EAAE;iBACV,CAAC,CAAC;gBACH,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;gBAChD,MAAM;YAER,KAAK,gBAAS,CAAC,cAAc,CAAC,CAAC,CAAC;gBAC9B,MAAM,OAAO,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,CAA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AAI,QAAQ,EAAE,CAAC;gBACb,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;OAGG;IACH,cAAc,CAAC,WAAqB;QAClC,KAAK,MAAM,EAAE,IAAI,WAAW,EAAE,CAAC;YAC7B,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YACjC,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;CACF;AA5ED,0CA4EC","sourcesContent":["/**\n * Tool Call Tracker for v1 API\n *\n * Tracks tool calls during streaming, accumulating arguments until complete.\n * Used by the send message hook to collect tool call state for execution.\n */\n\nimport { EventType, type AGUIEvent } from \"@ag-ui/core\";\nimport type { PendingToolCall } from \"./tool-executor\";\n\n/**\n * Tracks tool calls during streaming, accumulating arguments until complete.\n *\n * Tool calls arrive as a sequence of events:\n * 1. TOOL_CALL_START - initializes the tool call with name\n * 2. TOOL_CALL_ARGS (multiple) - streams JSON argument fragments\n * 3. TOOL_CALL_END - marks the tool call as complete, triggers JSON parsing\n *\n * This class accumulates these events and provides the complete tool call\n * data when requested for execution.\n */\nexport class ToolCallTracker {\n private pendingToolCalls = new Map<string, PendingToolCall>();\n private accumulatingArgs = new Map<string, string>();\n\n /**\n * Handles a streaming event, tracking tool call state as needed.\n * @param event - The streaming event to process\n * @throws {Error} If JSON parsing fails on TOOL_CALL_END (fail-fast, no silent fallback)\n */\n handleEvent(event: AGUIEvent): void {\n switch (event.type) {\n case EventType.TOOL_CALL_START:\n this.pendingToolCalls.set(event.toolCallId, {\n name: event.toolCallName,\n input: {},\n });\n this.accumulatingArgs.set(event.toolCallId, \"\");\n break;\n\n case EventType.TOOL_CALL_ARGS: {\n const current = this.accumulatingArgs.get(event.toolCallId);\n this.accumulatingArgs.set(\n event.toolCallId,\n (current ?? \"\") + event.delta,\n );\n break;\n }\n\n case EventType.TOOL_CALL_END: {\n const jsonStr = this.accumulatingArgs.get(event.toolCallId);\n const toolCall = this.pendingToolCalls.get(event.toolCallId);\n if (toolCall && jsonStr) {\n try {\n toolCall.input = JSON.parse(jsonStr) as Record<string, unknown>;\n } catch (error) {\n // Fail-fast: don't silently continue with empty input\n throw new Error(\n `Failed to parse tool call arguments for ${event.toolCallId}: ${error instanceof Error ? error.message : \"Unknown error\"}. JSON: ${jsonStr.slice(0, 100)}${jsonStr.length > 100 ? \"...\" : \"\"}`,\n );\n }\n }\n break;\n }\n\n default:\n // Other event types are ignored - only tool call events are tracked\n break;\n }\n }\n\n /**\n * Gets tool calls for the given IDs, filtered to only those that exist.\n * @param toolCallIds - IDs of tool calls to retrieve\n * @returns Map of tool call ID to pending tool call\n */\n getToolCallsById(toolCallIds: string[]): Map<string, PendingToolCall> {\n const result = new Map<string, PendingToolCall>();\n for (const id of toolCallIds) {\n const toolCall = this.pendingToolCalls.get(id);\n if (toolCall) {\n result.set(id, toolCall);\n }\n }\n return result;\n }\n\n /**\n * Clears tracked tool calls for the given IDs.\n * @param toolCallIds - IDs of tool calls to clear\n */\n clearToolCalls(toolCallIds: string[]): void {\n for (const id of toolCallIds) {\n this.pendingToolCalls.delete(id);\n this.accumulatingArgs.delete(id);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"tool-call-tracker.js","sourceRoot":"","sources":["../../../src/v1/utils/tool-call-tracker.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,sCAAwD;AAGxD;;;;;;;;;;GAUG;AACH,MAAa,eAAe;IAClB,gBAAgB,GAAG,IAAI,GAAG,EAA2B,CAAC;IACtD,gBAAgB,GAAG,IAAI,GAAG,EAAkB,CAAC;IAErD;;;;OAIG;IACH,WAAW,CAAC,KAAgB;QAC1B,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;YACnB,KAAK,gBAAS,CAAC,eAAe;gBAC5B,IAAI,CAAC,gBAAgB,CA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AAC,EAAE,EAAE,CAC/L,CAAC;oBACJ,CAAC;gBACH,CAAC;gBACD,MAAM;YACR,CAAC;YAED;gBACE,oEAAoE;gBACpE,MAAM;QACV,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,uBAAuB,CACrB,UAAkB;QAElB,MAAM,QAAQ,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACvD,MAAM,IAAI,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACnD,IAAI,CAAC,QAAQ,IAAI,IAAI,KAAK,SAAS;YAAE,OAAO,SAAS,CAAC;QACtD,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC;IACxD,CAAC;IAED;;;;OAIG;IACH,gBAAgB,CAAC,WAAqB;QACpC,MAAM,MAAM,GAAG,IAAI,GAAG,EAA2B,CAAC;QAClD,KAAK,MAAM,EAAE,IAAI,WAAW,EAAE,CAAC;YAC7B,MAAM,QAAQ,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAC/C,IAAI,QAAQ,EAAE,CAAC;gBACb,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;OAGG;IACH,cAAc,CAAC,WAAqB;QAClC,KAAK,MAAM,EAAE,IAAI,WAAW,EAAE,CAAC;YAC7B,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YACjC,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;CACF;AA3FD,0CA2FC","sourcesContent":["/**\n * Tool Call Tracker\n *\n * Tracks tool calls during streaming, accumulating arguments until complete.\n * Used by the send message hook to collect tool call state for execution.\n */\n\nimport { EventType, type AGUIEvent } from \"@ag-ui/core\";\nimport type { PendingToolCall } from \"./tool-executor\";\n\n/**\n * Tracks tool calls during streaming, accumulating arguments until complete.\n *\n * Tool calls arrive as a sequence of events:\n * 1. TOOL_CALL_START - initializes the tool call with name\n * 2. TOOL_CALL_ARGS (multiple) - streams JSON argument fragments\n * 3. TOOL_CALL_END - marks the tool call as complete, triggers JSON parsing\n *\n * This class accumulates these events and provides the complete tool call\n * data when requested for execution.\n */\nexport class ToolCallTracker {\n private pendingToolCalls = new Map<string, PendingToolCall>();\n private accumulatingArgs = new Map<string, string>();\n\n /**\n * Handles a streaming event, tracking tool call state as needed.\n * @param event - The streaming event to process\n * @throws {Error} If JSON parsing fails on TOOL_CALL_END (fail-fast, no silent fallback)\n */\n handleEvent(event: AGUIEvent): void {\n switch (event.type) {\n case EventType.TOOL_CALL_START:\n this.pendingToolCalls.set(event.toolCallId, {\n name: event.toolCallName,\n input: {},\n });\n this.accumulatingArgs.set(event.toolCallId, \"\");\n break;\n\n case EventType.TOOL_CALL_ARGS: {\n const current = this.accumulatingArgs.get(event.toolCallId);\n this.accumulatingArgs.set(\n event.toolCallId,\n (current ?? \"\") + event.delta,\n );\n break;\n }\n\n case EventType.TOOL_CALL_END: {\n const jsonStr = this.accumulatingArgs.get(event.toolCallId);\n const toolCall = this.pendingToolCalls.get(event.toolCallId);\n if (toolCall && jsonStr) {\n try {\n toolCall.input = JSON.parse(jsonStr) as Record<string, unknown>;\n } catch (error) {\n // Fail-fast: don't silently continue with empty input\n throw new Error(\n `Failed to parse tool call arguments for ${event.toolCallId}: ${error instanceof Error ? error.message : \"Unknown error\"}. JSON: ${jsonStr.slice(0, 100)}${jsonStr.length > 100 ? \"...\" : \"\"}`,\n );\n }\n }\n break;\n }\n\n default:\n // Other event types are ignored - only tool call events are tracked\n break;\n }\n }\n\n /**\n * Gets the name and accumulated args for a tool call that is still accumulating.\n * Used by the event loop to get tool state for partial JSON parsing.\n * @param toolCallId - ID of the tool call to look up\n * @returns The tool name and raw accumulated args string, or undefined if not found\n */\n getAccumulatingToolCall(\n toolCallId: string,\n ): { name: string; accumulatedArgs: string } | undefined {\n const toolCall = this.pendingToolCalls.get(toolCallId);\n const args = this.accumulatingArgs.get(toolCallId);\n if (!toolCall || args === undefined) return undefined;\n return { name: toolCall.name, accumulatedArgs: args };\n }\n\n /**\n * Gets tool calls for the given IDs, filtered to only those that exist.\n * @param toolCallIds - IDs of tool calls to retrieve\n * @returns Map of tool call ID to pending tool call\n */\n getToolCallsById(toolCallIds: string[]): Map<string, PendingToolCall> {\n const result = new Map<string, PendingToolCall>();\n for (const id of toolCallIds) {\n const toolCall = this.pendingToolCalls.get(id);\n if (toolCall) {\n result.set(id, toolCall);\n }\n }\n return result;\n }\n\n /**\n * Clears tracked tool calls for the given IDs.\n * @param toolCallIds - IDs of tool calls to clear\n */\n clearToolCalls(toolCallIds: string[]): void {\n for (const id of toolCallIds) {\n this.pendingToolCalls.delete(id);\n this.accumulatingArgs.delete(id);\n }\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=tool-call-tracker.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-call-tracker.test.d.ts","sourceRoot":"","sources":["../../../src/v1/utils/tool-call-tracker.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@ag-ui/core");
4
+ const tool_call_tracker_1 = require("./tool-call-tracker");
5
+ describe("ToolCallTracker", () => {
6
+ describe("getAccumulatingToolCall", () => {
7
+ it("returns undefined for unknown tool call ID", () => {
8
+ const tracker = new tool_call_tracker_1.ToolCallTracker();
9
+ expect(tracker.getAccumulatingToolCall("nonexistent")).toBeUndefined();
10
+ });
11
+ it("returns name and empty accumulated args after TOOL_CALL_START", () => {
12
+ const tracker = new tool_call_tracker_1.ToolCallTracker();
13
+ tracker.handleEvent({
14
+ type: core_1.EventType.TOOL_CALL_START,
15
+ toolCallId: "call_1",
16
+ toolCallName: "write_story",
17
+ parentMessageId: "msg_1",
18
+ });
19
+ const result = tracker.getAccumulatingToolCall("call_1");
20
+ expect(result).toEqual({ name: "write_story", accumulatedArgs: "" });
21
+ });
22
+ it("returns name and accumulated args after START + ARGS events", () => {
23
+ const tracker = new tool_call_tracker_1.ToolCallTracker();
24
+ tracker.handleEvent({
25
+ type: core_1.EventType.TOOL_CALL_START,
26
+ toolCallId: "call_1",
27
+ toolCallName: "write_story",
28
+ parentMessageId: "msg_1",
29
+ });
30
+ tracker.handleEvent({
31
+ type: core_1.EventType.TOOL_CALL_ARGS,
32
+ toolCallId: "call_1",
33
+ delta: '{"title":"Once',
34
+ });
35
+ const result = tracker.getAccumulatingToolCall("call_1");
36
+ expect(result).toEqual({
37
+ name: "write_story",
38
+ accumulatedArgs: '{"title":"Once',
39
+ });
40
+ });
41
+ it("accumulates multiple ARGS deltas", () => {
42
+ const tracker = new tool_call_tracker_1.ToolCallTracker();
43
+ tracker.handleEvent({
44
+ type: core_1.EventType.TOOL_CALL_START,
45
+ toolCallId: "call_1",
46
+ toolCallName: "write_story",
47
+ parentMessageId: "msg_1",
48
+ });
49
+ tracker.handleEvent({
50
+ type: core_1.EventType.TOOL_CALL_ARGS,
51
+ toolCallId: "call_1",
52
+ delta: '{"title":',
53
+ });
54
+ tracker.handleEvent({
55
+ type: core_1.EventType.TOOL_CALL_ARGS,
56
+ toolCallId: "call_1",
57
+ delta: '"Hello"}',
58
+ });
59
+ const result = tracker.getAccumulatingToolCall("call_1");
60
+ expect(result).toEqual({
61
+ name: "write_story",
62
+ accumulatedArgs: '{"title":"Hello"}',
63
+ });
64
+ });
65
+ });
66
+ });
67
+ //# sourceMappingURL=tool-call-tracker.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-call-tracker.test.js","sourceRoot":"","sources":["../../../src/v1/utils/tool-call-tracker.test.ts"],"names":[],"mappings":";;AAAA,sCAAwC;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QAAQ,CAAC,CAAC;YACzD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;gBACrB,IAAI,EAAE,aAAa;gBACnB,eAAe,EAAE,gBAAgB;aAClC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE;YAC1C,MAAM,OAAO,GAAG,IAAI,mCAAe,EAAE,CAAC;YACtC,OAAO,CAAC,WAAW,CAAC;gBAClB,IAAI,EAAE,gBAAS,CAAC,eAAe;gBAC/B,UAAU,EAAE,QAAQ;gBACpB,YAAY,EAAE,aAAa;gBAC3B,eAAe,EAAE,OAAO;aACzB,CAAC,CAAC;YACH,OAAO,CAAC,WAAW,CAAC;gBAClB,IAAI,EAAE,gBAAS,CAAC,cAAc;gBAC9B,UAAU,EAAE,QAAQ;gBACpB,KAAK,EAAE,WAAW;aACnB,CAAC,CAAC;YACH,OAAO,CAAC,WAAW,CAAC;gBAClB,IAAI,EAAE,gBAAS,CAAC,cAAc;gBAC9B,UAAU,EAAE,QAAQ;gBACpB,KAAK,EAAE,UAAU;aAClB,CAAC,CAAC;YAEH,MAAM,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC,QAAQ,CAAC,CAAC;YACzD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;gBACrB,IAAI,EAAE,aAAa;gBACnB,eAAe,EAAE,mBAAmB;aACrC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { EventType } from \"@ag-ui/core\";\nimport { ToolCallTracker } from \"./tool-call-tracker\";\n\ndescribe(\"ToolCallTracker\", () => {\n describe(\"getAccumulatingToolCall\", () => {\n it(\"returns undefined for unknown tool call ID\", () => {\n const tracker = new ToolCallTracker();\n expect(tracker.getAccumulatingToolCall(\"nonexistent\")).toBeUndefined();\n });\n\n it(\"returns name and empty accumulated args after TOOL_CALL_START\", () => {\n const tracker = new ToolCallTracker();\n tracker.handleEvent({\n type: EventType.TOOL_CALL_START,\n toolCallId: \"call_1\",\n toolCallName: \"write_story\",\n parentMessageId: \"msg_1\",\n });\n\n const result = tracker.getAccumulatingToolCall(\"call_1\");\n expect(result).toEqual({ name: \"write_story\", accumulatedArgs: \"\" });\n });\n\n it(\"returns name and accumulated args after START + ARGS events\", () => {\n const tracker = new ToolCallTracker();\n tracker.handleEvent({\n type: EventType.TOOL_CALL_START,\n toolCallId: \"call_1\",\n toolCallName: \"write_story\",\n parentMessageId: \"msg_1\",\n });\n tracker.handleEvent({\n type: EventType.TOOL_CALL_ARGS,\n toolCallId: \"call_1\",\n delta: '{\"title\":\"Once',\n });\n\n const result = tracker.getAccumulatingToolCall(\"call_1\");\n expect(result).toEqual({\n name: \"write_story\",\n accumulatedArgs: '{\"title\":\"Once',\n });\n });\n\n it(\"accumulates multiple ARGS deltas\", () => {\n const tracker = new ToolCallTracker();\n tracker.handleEvent({\n type: EventType.TOOL_CALL_START,\n toolCallId: \"call_1\",\n toolCallName: \"write_story\",\n parentMessageId: \"msg_1\",\n });\n tracker.handleEvent({\n type: EventType.TOOL_CALL_ARGS,\n toolCallId: \"call_1\",\n delta: '{\"title\":',\n });\n tracker.handleEvent({\n type: EventType.TOOL_CALL_ARGS,\n toolCallId: \"call_1\",\n delta: '\"Hello\"}',\n });\n\n const result = tracker.getAccumulatingToolCall(\"call_1\");\n expect(result).toEqual({\n name: \"write_story\",\n accumulatedArgs: '{\"title\":\"Hello\"}',\n });\n });\n });\n});\n"]}
@@ -1,11 +1,13 @@
1
1
  /**
2
- * Tool Executor for v1 API
2
+ * Tool Executor
3
3
  *
4
4
  * Handles automatic execution of client-side tools when the model
5
5
  * requests them via `tambo.run.awaiting_input` events.
6
6
  */
7
7
  import type { TamboTool } from "../../model/component-metadata";
8
8
  import type { ToolResultContent } from "@tambo-ai/typescript-sdk/resources/threads/threads";
9
+ import type { ToolCallTracker } from "./tool-call-tracker";
10
+ import { type KeyedThrottle } from "./keyed-throttle";
9
11
  /**
10
12
  * Pending tool call from the stream accumulator
11
13
  */
@@ -13,6 +15,38 @@ export interface PendingToolCall {
13
15
  name: string;
14
16
  input: Record<string, unknown>;
15
17
  }
18
+ /**
19
+ * Execute a streamable tool call during streaming with pre-parsed partial args.
20
+ *
21
+ * Called on each TOOL_CALL_ARGS event for tools annotated with
22
+ * `tamboStreamableHint: true`. Enables incremental UI updates while
23
+ * the model is still generating arguments.
24
+ *
25
+ * Errors are caught silently — streaming tool execution is non-fatal since
26
+ * the final execution via `awaiting_input` is what matters.
27
+ * @param toolCallId - The tool call ID being accumulated
28
+ * @param parsedArgs - Pre-parsed partial JSON args
29
+ * @param toolTracker - Tracker holding pending tool call state
30
+ * @param toolRegistry - Record of tool name to tool definition
31
+ */
32
+ export declare function executeStreamableToolCall(toolCallId: string, parsedArgs: Record<string, unknown>, toolTracker: ToolCallTracker, toolRegistry: Record<string, TamboTool>): Promise<void>;
33
+ /**
34
+ * Creates a throttled wrapper around executeStreamableToolCall.
35
+ *
36
+ * Each tool call ID gets its own independent leading+trailing throttle via
37
+ * {@link createKeyedThrottle}. The first call for a tool ID fires immediately
38
+ * (leading edge). Subsequent calls during the cooldown window update the
39
+ * stored args. After `delay` ms, if new args arrived, the tool re-executes
40
+ * with the latest args (trailing edge). This repeats as long as new args
41
+ * keep arriving — roughly one execution per `delay` ms during streaming.
42
+ *
43
+ * Call `flush()` to force-execute all pending trailing calls and reset to idle.
44
+ * @param toolTracker - Tracker holding pending tool call state
45
+ * @param toolRegistry - Record of tool name to tool definition
46
+ * @param delay - Throttle interval in milliseconds
47
+ * @returns Keyed throttle controller (schedule / flush)
48
+ */
49
+ export declare function createThrottledStreamableExecutor(toolTracker: ToolCallTracker, toolRegistry: Record<string, TamboTool>, delay?: number): KeyedThrottle<Record<string, unknown>>;
16
50
  /**
17
51
  * Execute a single client-side tool and return the result.
18
52
  * @param tool - The tool definition from the registry
@@ -1 +1 @@
1
- {"version":3,"file":"tool-executor.d.ts","sourceRoot":"","sources":["../../../src/v1/utils/tool-executor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,KAAK,EACV,iBAAiB,EAGlB,MAAM,oDAAoD,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,SAAS,EACf,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,OAAO,CAAC,iBAAiB,CAAC,CAiD5B;AAED;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAC1C,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,EACvC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAC3D,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAiC9B"}
1
+ {"version":3,"file":"tool-executor.d.ts","sourceRoot":"","sources":["../../../src/v1/utils/tool-executor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,KAAK,EACV,iBAAiB,EAGlB,MAAM,oDAAoD,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAE3E;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,yBAAyB,CAC7C,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACnC,WAAW,EAAE,eAAe,EAC5B,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GACtC,OAAO,CAAC,IAAI,CAAC,CAiBf;AAID;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iCAAiC,CAC/C,WAAW,EAAE,eAAe,EAC5B,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EACvC,KAAK,SAAiC,GACrC,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAIxC;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,SAAS,EACf,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,OAAO,CAAC,iBAAiB,CAAC,CAiD5B;AAED;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAC1C,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,EACvC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAC3D,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAiC9B"}
@@ -1,13 +1,68 @@
1
1
  "use strict";
2
2
  /**
3
- * Tool Executor for v1 API
3
+ * Tool Executor
4
4
  *
5
5
  * Handles automatic execution of client-side tools when the model
6
6
  * requests them via `tambo.run.awaiting_input` events.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.executeStreamableToolCall = executeStreamableToolCall;
10
+ exports.createThrottledStreamableExecutor = createThrottledStreamableExecutor;
9
11
  exports.executeClientTool = executeClientTool;
10
12
  exports.executeAllPendingTools = executeAllPendingTools;
13
+ const keyed_throttle_1 = require("./keyed-throttle");
14
+ /**
15
+ * Execute a streamable tool call during streaming with pre-parsed partial args.
16
+ *
17
+ * Called on each TOOL_CALL_ARGS event for tools annotated with
18
+ * `tamboStreamableHint: true`. Enables incremental UI updates while
19
+ * the model is still generating arguments.
20
+ *
21
+ * Errors are caught silently — streaming tool execution is non-fatal since
22
+ * the final execution via `awaiting_input` is what matters.
23
+ * @param toolCallId - The tool call ID being accumulated
24
+ * @param parsedArgs - Pre-parsed partial JSON args
25
+ * @param toolTracker - Tracker holding pending tool call state
26
+ * @param toolRegistry - Record of tool name to tool definition
27
+ */
28
+ async function executeStreamableToolCall(toolCallId, parsedArgs, toolTracker, toolRegistry) {
29
+ const accumulating = toolTracker.getAccumulatingToolCall(toolCallId);
30
+ if (!accumulating)
31
+ return;
32
+ const tool = toolRegistry[accumulating.name];
33
+ if (!tool?.annotations?.tamboStreamableHint)
34
+ return;
35
+ try {
36
+ await tool.tool(parsedArgs);
37
+ }
38
+ catch (error) {
39
+ console.warn(`[ToolExecutor] Non-fatal error in streamable tool "${accumulating.name}" ` +
40
+ `(toolCallId: ${toolCallId}). This likely indicates a bug in the tool ` +
41
+ `implementation; fix the tool to avoid repeated warnings.`, error);
42
+ }
43
+ }
44
+ const DEFAULT_STREAMABLE_THROTTLE_MS = 100;
45
+ /**
46
+ * Creates a throttled wrapper around executeStreamableToolCall.
47
+ *
48
+ * Each tool call ID gets its own independent leading+trailing throttle via
49
+ * {@link createKeyedThrottle}. The first call for a tool ID fires immediately
50
+ * (leading edge). Subsequent calls during the cooldown window update the
51
+ * stored args. After `delay` ms, if new args arrived, the tool re-executes
52
+ * with the latest args (trailing edge). This repeats as long as new args
53
+ * keep arriving — roughly one execution per `delay` ms during streaming.
54
+ *
55
+ * Call `flush()` to force-execute all pending trailing calls and reset to idle.
56
+ * @param toolTracker - Tracker holding pending tool call state
57
+ * @param toolRegistry - Record of tool name to tool definition
58
+ * @param delay - Throttle interval in milliseconds
59
+ * @returns Keyed throttle controller (schedule / flush)
60
+ */
61
+ function createThrottledStreamableExecutor(toolTracker, toolRegistry, delay = DEFAULT_STREAMABLE_THROTTLE_MS) {
62
+ return (0, keyed_throttle_1.createKeyedThrottle)((toolCallId, args) => {
63
+ void executeStreamableToolCall(toolCallId, args, toolTracker, toolRegistry);
64
+ }, delay);
65
+ }
11
66
  /**
12
67
  * Execute a single client-side tool and return the result.
13
68
  * @param tool - The tool definition from the registry
@@ -22,7 +77,7 @@ async function executeClientTool(tool, toolCallId, args) {
22
77
  let content;
23
78
  if (tool.transformToContent) {
24
79
  // transformToContent may return content parts in beta format
25
- // Convert to v1 format (TextContent | ResourceContent)
80
+ // Convert to content format (TextContent | ResourceContent)
26
81
  const transformed = await tool.transformToContent(result);
27
82
  content = transformed.map((part) => {
28
83
  if (part.type === "text" && "text" in part && part.text) {
@@ -1 +1 @@
1
- {"version":3,"file":"tool-executor.js","sourceRoot":"","sources":["../../../src/v1/utils/tool-executor.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAwBH,8CAqDC;AAUD,wDAoCC;AA1GD;;;;;;GAMG;AACI,KAAK,UAAU,iBAAiB,CACrC,IAAe,EACf,UAAkB,EAClB,IAA6B;IAE7B,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAErC,sDAAsD;QACtD,IAAI,OAA0C,CAAC;QAC/C,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC5B,6DAA6D;YAC7D,uDAAuD;YACvD,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;YAC1D,OAAO,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;gBACjC,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,MAAM,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;oBACxD,OAAO,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,C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,IAAI,SAAS,EAAE,CAAC;QACtD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAC3B,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,CAAC,IAAI,CAAC;gBACX,IAAI,EAAE,aAAa;gBACnB,SAAS,EAAE,UAAU;gBACrB,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,SAAS,IAAI,yBAAyB;qBAC7C;iBACF;aACF,CAAC,CAAC;YACH,SAAS;QACX,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;QAChE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["/**\n * Tool Executor for v1 API\n *\n * Handles automatic execution of client-side tools when the model\n * requests them via `tambo.run.awaiting_input` events.\n */\n\nimport type { TamboTool } from \"../../model/component-metadata\";\nimport type {\n ToolResultContent,\n TextContent,\n ResourceContent,\n} from \"@tambo-ai/typescript-sdk/resources/threads/threads\";\n\n/**\n * Pending tool call from the stream accumulator\n */\nexport interface PendingToolCall {\n name: string;\n input: Record<string, unknown>;\n}\n\n/**\n * Execute a single client-side tool and return the result.\n * @param tool - The tool definition from the registry\n * @param toolCallId - The ID of the tool call to respond to\n * @param args - The parsed arguments for the tool\n * @returns ToolResultContent with the execution result or error\n */\nexport async function executeClientTool(\n tool: TamboTool,\n toolCallId: string,\n args: Record<string, unknown>,\n): Promise<ToolResultContent> {\n try {\n const result = await tool.tool(args);\n\n // Transform result to content if transformer provided\n let content: (TextContent | ResourceContent)[];\n if (tool.transformToContent) {\n // transformToContent may return content parts in beta format\n // Convert to v1 format (TextContent | ResourceContent)\n const transformed = await tool.transformToContent(result);\n content = transformed.map((part) => {\n if (part.type === \"text\" && \"text\" in part && part.text) {\n return { type: \"text\" as const, text: part.text };\n }\n // For other types, stringify as text\n return {\n type: \"text\" as const,\n text: JSON.stringify(part),\n };\n });\n } else {\n // Default: stringify result as text\n content = [\n {\n type: \"text\" as const,\n text: typeof result === \"string\" ? result : JSON.stringify(result),\n },\n ];\n }\n\n return {\n type: \"tool_result\",\n toolUseId: toolCallId,\n content,\n };\n } catch (error) {\n return {\n type: \"tool_result\",\n toolUseId: toolCallId,\n isError: true,\n content: [\n {\n type: \"text\" as const,\n text:\n error instanceof Error ? error.message : \"Tool execution failed\",\n },\n ],\n };\n }\n}\n\n/**\n * Execute all pending tool calls and return their results.\n * Tools are executed sequentially to avoid race conditions when\n * tools may have side effects that depend on each other.\n * @param toolCalls - Map of tool call IDs to their call details\n * @param registry - Registry of tool names to their definitions (Map or Record)\n * @returns Array of ToolResultContent for all executed tools\n */\nexport async function executeAllPendingTools(\n toolCalls: Map<string, PendingToolCall>,\n registry: Map<string, TamboTool> | Record<string, TamboTool>,\n): Promise<ToolResultContent[]> {\n const results: ToolResultContent[] = [];\n\n // Normalize registry to allow lookup regardless of Map or Record\n const getTool = (name: string): TamboTool | undefined => {\n if (registry instanceof Map) {\n return registry.get(name);\n }\n return registry[name];\n };\n\n for (const [toolCallId, { name, input }] of toolCalls) {\n const tool = getTool(name);\n if (!tool) {\n results.push({\n type: \"tool_result\",\n toolUseId: toolCallId,\n isError: true,\n content: [\n {\n type: \"text\" as const,\n text: `Tool \"${name}\" not found in registry`,\n },\n ],\n });\n continue;\n }\n\n const result = await executeClientTool(tool, toolCallId, input);\n results.push(result);\n }\n\n return results;\n}\n"]}
1
+ {"version":3,"file":"tool-executor.js","sourceRoot":"","sources":["../../../src/v1/utils/tool-executor.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAiCH,8DAsBC;AAoBD,8EAQC;AASD,8CAqDC;AAUD,wDAoCC;AAtLD,qDAA2E;AAU3E;;;;;;;;;;;;;GAaG;AACI,KAAK,UAAU,yBAAyB,CAC7C,UAAkB,EAClB,U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QACtD,IAAI,QAAQ,YAAY,GAAG,EAAE,CAAC;YAC5B,OAAO,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC;QACD,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC,CAAC;IAEF,KAAK,MAAM,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,IAAI,SAAS,EAAE,CAAC;QACtD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAC3B,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,CAAC,IAAI,CAAC;gBACX,IAAI,EAAE,aAAa;gBACnB,SAAS,EAAE,UAAU;gBACrB,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,SAAS,IAAI,yBAAyB;qBAC7C;iBACF;aACF,CAAC,CAAC;YACH,SAAS;QACX,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;QAChE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["/**\n * Tool Executor\n *\n * Handles automatic execution of client-side tools when the model\n * requests them via `tambo.run.awaiting_input` events.\n */\n\nimport type { TamboTool } from \"../../model/component-metadata\";\nimport type {\n ToolResultContent,\n TextContent,\n ResourceContent,\n} from \"@tambo-ai/typescript-sdk/resources/threads/threads\";\nimport type { ToolCallTracker } from \"./tool-call-tracker\";\nimport { createKeyedThrottle, type KeyedThrottle } from \"./keyed-throttle\";\n\n/**\n * Pending tool call from the stream accumulator\n */\nexport interface PendingToolCall {\n name: string;\n input: Record<string, unknown>;\n}\n\n/**\n * Execute a streamable tool call during streaming with pre-parsed partial args.\n *\n * Called on each TOOL_CALL_ARGS event for tools annotated with\n * `tamboStreamableHint: true`. Enables incremental UI updates while\n * the model is still generating arguments.\n *\n * Errors are caught silently — streaming tool execution is non-fatal since\n * the final execution via `awaiting_input` is what matters.\n * @param toolCallId - The tool call ID being accumulated\n * @param parsedArgs - Pre-parsed partial JSON args\n * @param toolTracker - Tracker holding pending tool call state\n * @param toolRegistry - Record of tool name to tool definition\n */\nexport async function executeStreamableToolCall(\n toolCallId: string,\n parsedArgs: Record<string, unknown>,\n toolTracker: ToolCallTracker,\n toolRegistry: Record<string, TamboTool>,\n): Promise<void> {\n const accumulating = toolTracker.getAccumulatingToolCall(toolCallId);\n if (!accumulating) return;\n\n const tool = toolRegistry[accumulating.name];\n if (!tool?.annotations?.tamboStreamableHint) return;\n\n try {\n await tool.tool(parsedArgs);\n } catch (error) {\n console.warn(\n `[ToolExecutor] Non-fatal error in streamable tool \"${accumulating.name}\" ` +\n `(toolCallId: ${toolCallId}). This likely indicates a bug in the tool ` +\n `implementation; fix the tool to avoid repeated warnings.`,\n error,\n );\n }\n}\n\nconst DEFAULT_STREAMABLE_THROTTLE_MS = 100;\n\n/**\n * Creates a throttled wrapper around executeStreamableToolCall.\n *\n * Each tool call ID gets its own independent leading+trailing throttle via\n * {@link createKeyedThrottle}. The first call for a tool ID fires immediately\n * (leading edge). Subsequent calls during the cooldown window update the\n * stored args. After `delay` ms, if new args arrived, the tool re-executes\n * with the latest args (trailing edge). This repeats as long as new args\n * keep arriving — roughly one execution per `delay` ms during streaming.\n *\n * Call `flush()` to force-execute all pending trailing calls and reset to idle.\n * @param toolTracker - Tracker holding pending tool call state\n * @param toolRegistry - Record of tool name to tool definition\n * @param delay - Throttle interval in milliseconds\n * @returns Keyed throttle controller (schedule / flush)\n */\nexport function createThrottledStreamableExecutor(\n toolTracker: ToolCallTracker,\n toolRegistry: Record<string, TamboTool>,\n delay = DEFAULT_STREAMABLE_THROTTLE_MS,\n): KeyedThrottle<Record<string, unknown>> {\n return createKeyedThrottle<Record<string, unknown>>((toolCallId, args) => {\n void executeStreamableToolCall(toolCallId, args, toolTracker, toolRegistry);\n }, delay);\n}\n\n/**\n * Execute a single client-side tool and return the result.\n * @param tool - The tool definition from the registry\n * @param toolCallId - The ID of the tool call to respond to\n * @param args - The parsed arguments for the tool\n * @returns ToolResultContent with the execution result or error\n */\nexport async function executeClientTool(\n tool: TamboTool,\n toolCallId: string,\n args: Record<string, unknown>,\n): Promise<ToolResultContent> {\n try {\n const result = await tool.tool(args);\n\n // Transform result to content if transformer provided\n let content: (TextContent | ResourceContent)[];\n if (tool.transformToContent) {\n // transformToContent may return content parts in beta format\n // Convert to content format (TextContent | ResourceContent)\n const transformed = await tool.transformToContent(result);\n content = transformed.map((part) => {\n if (part.type === \"text\" && \"text\" in part && part.text) {\n return { type: \"text\" as const, text: part.text };\n }\n // For other types, stringify as text\n return {\n type: \"text\" as const,\n text: JSON.stringify(part),\n };\n });\n } else {\n // Default: stringify result as text\n content = [\n {\n type: \"text\" as const,\n text: typeof result === \"string\" ? result : JSON.stringify(result),\n },\n ];\n }\n\n return {\n type: \"tool_result\",\n toolUseId: toolCallId,\n content,\n };\n } catch (error) {\n return {\n type: \"tool_result\",\n toolUseId: toolCallId,\n isError: true,\n content: [\n {\n type: \"text\" as const,\n text:\n error instanceof Error ? error.message : \"Tool execution failed\",\n },\n ],\n };\n }\n}\n\n/**\n * Execute all pending tool calls and return their results.\n * Tools are executed sequentially to avoid race conditions when\n * tools may have side effects that depend on each other.\n * @param toolCalls - Map of tool call IDs to their call details\n * @param registry - Registry of tool names to their definitions (Map or Record)\n * @returns Array of ToolResultContent for all executed tools\n */\nexport async function executeAllPendingTools(\n toolCalls: Map<string, PendingToolCall>,\n registry: Map<string, TamboTool> | Record<string, TamboTool>,\n): Promise<ToolResultContent[]> {\n const results: ToolResultContent[] = [];\n\n // Normalize registry to allow lookup regardless of Map or Record\n const getTool = (name: string): TamboTool | undefined => {\n if (registry instanceof Map) {\n return registry.get(name);\n }\n return registry[name];\n };\n\n for (const [toolCallId, { name, input }] of toolCalls) {\n const tool = getTool(name);\n if (!tool) {\n results.push({\n type: \"tool_result\",\n toolUseId: toolCallId,\n isError: true,\n content: [\n {\n type: \"text\" as const,\n text: `Tool \"${name}\" not found in registry`,\n },\n ],\n });\n continue;\n }\n\n const result = await executeClientTool(tool, toolCallId, input);\n results.push(result);\n }\n\n return results;\n}\n"]}