@tambo-ai/react 0.70.0 → 0.72.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (305) hide show
  1. package/dist/v1/hooks/use-tambo-v1-component-state.d.ts +44 -0
  2. package/dist/v1/hooks/use-tambo-v1-component-state.d.ts.map +1 -0
  3. package/dist/v1/hooks/use-tambo-v1-component-state.js +134 -0
  4. package/dist/v1/hooks/use-tambo-v1-component-state.js.map +1 -0
  5. package/dist/v1/hooks/use-tambo-v1-component-state.test.d.ts +2 -0
  6. package/dist/v1/hooks/use-tambo-v1-component-state.test.d.ts.map +1 -0
  7. package/dist/v1/hooks/use-tambo-v1-component-state.test.js +292 -0
  8. package/dist/v1/hooks/use-tambo-v1-component-state.test.js.map +1 -0
  9. package/dist/v1/hooks/use-tambo-v1-messages.d.ts +58 -0
  10. package/dist/v1/hooks/use-tambo-v1-messages.d.ts.map +1 -0
  11. package/dist/v1/hooks/use-tambo-v1-messages.js +54 -0
  12. package/dist/v1/hooks/use-tambo-v1-messages.js.map +1 -0
  13. package/dist/v1/hooks/use-tambo-v1-messages.test.d.ts +2 -0
  14. package/dist/v1/hooks/use-tambo-v1-messages.test.d.ts.map +1 -0
  15. package/dist/v1/hooks/use-tambo-v1-messages.test.js +137 -0
  16. package/dist/v1/hooks/use-tambo-v1-messages.test.js.map +1 -0
  17. package/dist/v1/hooks/use-tambo-v1-send-message.d.ts +96 -0
  18. package/dist/v1/hooks/use-tambo-v1-send-message.d.ts.map +1 -0
  19. package/dist/v1/hooks/use-tambo-v1-send-message.js +227 -0
  20. package/dist/v1/hooks/use-tambo-v1-send-message.js.map +1 -0
  21. package/dist/v1/hooks/use-tambo-v1-send-message.test.d.ts +2 -0
  22. package/dist/v1/hooks/use-tambo-v1-send-message.test.d.ts.map +1 -0
  23. package/dist/v1/hooks/use-tambo-v1-send-message.test.js +827 -0
  24. package/dist/v1/hooks/use-tambo-v1-send-message.test.js.map +1 -0
  25. package/dist/v1/hooks/use-tambo-v1-thread-input.d.ts +62 -0
  26. package/dist/v1/hooks/use-tambo-v1-thread-input.d.ts.map +1 -0
  27. package/dist/v1/hooks/use-tambo-v1-thread-input.js +76 -0
  28. package/dist/v1/hooks/use-tambo-v1-thread-input.js.map +1 -0
  29. package/dist/v1/hooks/use-tambo-v1-thread-input.test.d.ts +2 -0
  30. package/dist/v1/hooks/use-tambo-v1-thread-input.test.d.ts.map +1 -0
  31. package/dist/v1/hooks/use-tambo-v1-thread-input.test.js +168 -0
  32. package/dist/v1/hooks/use-tambo-v1-thread-input.test.js.map +1 -0
  33. package/dist/v1/hooks/use-tambo-v1-thread-list.d.ts +61 -0
  34. package/dist/v1/hooks/use-tambo-v1-thread-list.d.ts.map +1 -0
  35. package/dist/v1/hooks/use-tambo-v1-thread-list.js +56 -0
  36. package/dist/v1/hooks/use-tambo-v1-thread-list.js.map +1 -0
  37. package/dist/v1/hooks/use-tambo-v1-thread-list.test.d.ts +2 -0
  38. package/dist/v1/hooks/use-tambo-v1-thread-list.test.d.ts.map +1 -0
  39. package/dist/v1/hooks/use-tambo-v1-thread-list.test.js +98 -0
  40. package/dist/v1/hooks/use-tambo-v1-thread-list.test.js.map +1 -0
  41. package/dist/v1/hooks/use-tambo-v1-thread.d.ts +37 -0
  42. package/dist/v1/hooks/use-tambo-v1-thread.d.ts.map +1 -0
  43. package/dist/v1/hooks/use-tambo-v1-thread.js +49 -0
  44. package/dist/v1/hooks/use-tambo-v1-thread.js.map +1 -0
  45. package/dist/v1/hooks/use-tambo-v1-thread.test.d.ts +2 -0
  46. package/dist/v1/hooks/use-tambo-v1-thread.test.d.ts.map +1 -0
  47. package/dist/v1/hooks/use-tambo-v1-thread.test.js +83 -0
  48. package/dist/v1/hooks/use-tambo-v1-thread.test.js.map +1 -0
  49. package/dist/v1/hooks/use-tambo-v1.d.ts +107 -0
  50. package/dist/v1/hooks/use-tambo-v1.d.ts.map +1 -0
  51. package/dist/v1/hooks/use-tambo-v1.js +87 -0
  52. package/dist/v1/hooks/use-tambo-v1.js.map +1 -0
  53. package/dist/v1/hooks/use-tambo-v1.test.d.ts +2 -0
  54. package/dist/v1/hooks/use-tambo-v1.test.d.ts.map +1 -0
  55. package/dist/v1/hooks/use-tambo-v1.test.js +150 -0
  56. package/dist/v1/hooks/use-tambo-v1.test.js.map +1 -0
  57. package/dist/v1/index.d.ts +65 -16
  58. package/dist/v1/index.d.ts.map +1 -1
  59. package/dist/v1/index.js +119 -26
  60. package/dist/v1/index.js.map +1 -1
  61. package/dist/v1/providers/tambo-v1-provider.d.ts +133 -0
  62. package/dist/v1/providers/tambo-v1-provider.d.ts.map +1 -0
  63. package/dist/v1/providers/tambo-v1-provider.js +131 -0
  64. package/dist/v1/providers/tambo-v1-provider.js.map +1 -0
  65. package/dist/v1/providers/tambo-v1-provider.test.d.ts +2 -0
  66. package/dist/v1/providers/tambo-v1-provider.test.d.ts.map +1 -0
  67. package/dist/v1/providers/tambo-v1-provider.test.js +181 -0
  68. package/dist/v1/providers/tambo-v1-provider.test.js.map +1 -0
  69. package/dist/v1/providers/tambo-v1-stream-context.d.ts +136 -0
  70. package/dist/v1/providers/tambo-v1-stream-context.d.ts.map +1 -0
  71. package/dist/v1/providers/tambo-v1-stream-context.js +230 -0
  72. package/dist/v1/providers/tambo-v1-stream-context.js.map +1 -0
  73. package/dist/v1/providers/tambo-v1-stream-context.test.d.ts +2 -0
  74. package/dist/v1/providers/tambo-v1-stream-context.test.d.ts.map +1 -0
  75. package/dist/v1/providers/tambo-v1-stream-context.test.js +85 -0
  76. package/dist/v1/providers/tambo-v1-stream-context.test.js.map +1 -0
  77. package/dist/v1/types/component.d.ts +5 -2
  78. package/dist/v1/types/component.d.ts.map +1 -1
  79. package/dist/v1/types/component.js +5 -2
  80. package/dist/v1/types/component.js.map +1 -1
  81. package/dist/v1/types/event.d.ts +21 -12
  82. package/dist/v1/types/event.d.ts.map +1 -1
  83. package/dist/v1/types/event.js +46 -1
  84. package/dist/v1/types/event.js.map +1 -1
  85. package/dist/v1/types/event.test.d.ts +2 -0
  86. package/dist/v1/types/event.test.d.ts.map +1 -0
  87. package/dist/v1/types/event.test.js +70 -0
  88. package/dist/v1/types/event.test.js.map +1 -0
  89. package/dist/v1/types/message.d.ts +30 -9
  90. package/dist/v1/types/message.d.ts.map +1 -1
  91. package/dist/v1/types/message.js +1 -1
  92. package/dist/v1/types/message.js.map +1 -1
  93. package/dist/v1/types/thread.d.ts +1 -3
  94. package/dist/v1/types/thread.d.ts.map +1 -1
  95. package/dist/v1/types/thread.js +1 -1
  96. package/dist/v1/types/thread.js.map +1 -1
  97. package/dist/v1/utils/component-renderer.d.ts +89 -0
  98. package/dist/v1/utils/component-renderer.d.ts.map +1 -0
  99. package/dist/v1/utils/component-renderer.js +216 -0
  100. package/dist/v1/utils/component-renderer.js.map +1 -0
  101. package/dist/v1/utils/component-renderer.test.d.ts +2 -0
  102. package/dist/v1/utils/component-renderer.test.d.ts.map +1 -0
  103. package/dist/v1/utils/component-renderer.test.js +380 -0
  104. package/dist/v1/utils/component-renderer.test.js.map +1 -0
  105. package/dist/v1/utils/event-accumulator.d.ts +100 -0
  106. package/dist/v1/utils/event-accumulator.d.ts.map +1 -0
  107. package/dist/v1/utils/event-accumulator.js +735 -0
  108. package/dist/v1/utils/event-accumulator.js.map +1 -0
  109. package/dist/v1/utils/event-accumulator.test.d.ts +2 -0
  110. package/dist/v1/utils/event-accumulator.test.d.ts.map +1 -0
  111. package/dist/v1/utils/event-accumulator.test.js +1205 -0
  112. package/dist/v1/utils/event-accumulator.test.js.map +1 -0
  113. package/dist/v1/utils/json-patch.d.ts +18 -0
  114. package/dist/v1/utils/json-patch.d.ts.map +1 -0
  115. package/dist/v1/utils/json-patch.js +35 -0
  116. package/dist/v1/utils/json-patch.js.map +1 -0
  117. package/dist/v1/utils/json-patch.test.d.ts +2 -0
  118. package/dist/v1/utils/json-patch.test.d.ts.map +1 -0
  119. package/dist/v1/utils/json-patch.test.js +28 -0
  120. package/dist/v1/utils/json-patch.test.js.map +1 -0
  121. package/dist/v1/utils/registry-conversion.d.ts +53 -0
  122. package/dist/v1/utils/registry-conversion.d.ts.map +1 -0
  123. package/dist/v1/utils/registry-conversion.js +114 -0
  124. package/dist/v1/utils/registry-conversion.js.map +1 -0
  125. package/dist/v1/utils/registry-conversion.test.d.ts +2 -0
  126. package/dist/v1/utils/registry-conversion.test.d.ts.map +1 -0
  127. package/dist/v1/utils/registry-conversion.test.js +179 -0
  128. package/dist/v1/utils/registry-conversion.test.js.map +1 -0
  129. package/dist/v1/utils/stream-handler.d.ts +45 -0
  130. package/dist/v1/utils/stream-handler.d.ts.map +1 -0
  131. package/dist/v1/utils/stream-handler.js +47 -0
  132. package/dist/v1/utils/stream-handler.js.map +1 -0
  133. package/dist/v1/utils/stream-handler.test.d.ts +2 -0
  134. package/dist/v1/utils/stream-handler.test.d.ts.map +1 -0
  135. package/dist/v1/utils/stream-handler.test.js +74 -0
  136. package/dist/v1/utils/stream-handler.test.js.map +1 -0
  137. package/dist/v1/utils/tool-call-tracker.d.ts +41 -0
  138. package/dist/v1/utils/tool-call-tracker.d.ts.map +1 -0
  139. package/dist/v1/utils/tool-call-tracker.js +90 -0
  140. package/dist/v1/utils/tool-call-tracker.js.map +1 -0
  141. package/dist/v1/utils/tool-executor.d.ts +33 -0
  142. package/dist/v1/utils/tool-executor.d.ts.map +1 -0
  143. package/dist/v1/utils/tool-executor.js +103 -0
  144. package/dist/v1/utils/tool-executor.js.map +1 -0
  145. package/dist/v1/utils/tool-executor.test.d.ts +2 -0
  146. package/dist/v1/utils/tool-executor.test.d.ts.map +1 -0
  147. package/dist/v1/utils/tool-executor.test.js +222 -0
  148. package/dist/v1/utils/tool-executor.test.js.map +1 -0
  149. package/esm/v1/hooks/use-tambo-v1-component-state.d.ts +44 -0
  150. package/esm/v1/hooks/use-tambo-v1-component-state.d.ts.map +1 -0
  151. package/esm/v1/hooks/use-tambo-v1-component-state.js +131 -0
  152. package/esm/v1/hooks/use-tambo-v1-component-state.js.map +1 -0
  153. package/esm/v1/hooks/use-tambo-v1-component-state.test.d.ts +2 -0
  154. package/esm/v1/hooks/use-tambo-v1-component-state.test.d.ts.map +1 -0
  155. package/esm/v1/hooks/use-tambo-v1-component-state.test.js +290 -0
  156. package/esm/v1/hooks/use-tambo-v1-component-state.test.js.map +1 -0
  157. package/esm/v1/hooks/use-tambo-v1-messages.d.ts +58 -0
  158. package/esm/v1/hooks/use-tambo-v1-messages.d.ts.map +1 -0
  159. package/esm/v1/hooks/use-tambo-v1-messages.js +51 -0
  160. package/esm/v1/hooks/use-tambo-v1-messages.js.map +1 -0
  161. package/esm/v1/hooks/use-tambo-v1-messages.test.d.ts +2 -0
  162. package/esm/v1/hooks/use-tambo-v1-messages.test.d.ts.map +1 -0
  163. package/esm/v1/hooks/use-tambo-v1-messages.test.js +132 -0
  164. package/esm/v1/hooks/use-tambo-v1-messages.test.js.map +1 -0
  165. package/esm/v1/hooks/use-tambo-v1-send-message.d.ts +96 -0
  166. package/esm/v1/hooks/use-tambo-v1-send-message.d.ts.map +1 -0
  167. package/esm/v1/hooks/use-tambo-v1-send-message.js +223 -0
  168. package/esm/v1/hooks/use-tambo-v1-send-message.js.map +1 -0
  169. package/esm/v1/hooks/use-tambo-v1-send-message.test.d.ts +2 -0
  170. package/esm/v1/hooks/use-tambo-v1-send-message.test.d.ts.map +1 -0
  171. package/esm/v1/hooks/use-tambo-v1-send-message.test.js +822 -0
  172. package/esm/v1/hooks/use-tambo-v1-send-message.test.js.map +1 -0
  173. package/esm/v1/hooks/use-tambo-v1-thread-input.d.ts +62 -0
  174. package/esm/v1/hooks/use-tambo-v1-thread-input.d.ts.map +1 -0
  175. package/esm/v1/hooks/use-tambo-v1-thread-input.js +73 -0
  176. package/esm/v1/hooks/use-tambo-v1-thread-input.js.map +1 -0
  177. package/esm/v1/hooks/use-tambo-v1-thread-input.test.d.ts +2 -0
  178. package/esm/v1/hooks/use-tambo-v1-thread-input.test.d.ts.map +1 -0
  179. package/esm/v1/hooks/use-tambo-v1-thread-input.test.js +166 -0
  180. package/esm/v1/hooks/use-tambo-v1-thread-input.test.js.map +1 -0
  181. package/esm/v1/hooks/use-tambo-v1-thread-list.d.ts +61 -0
  182. package/esm/v1/hooks/use-tambo-v1-thread-list.d.ts.map +1 -0
  183. package/esm/v1/hooks/use-tambo-v1-thread-list.js +53 -0
  184. package/esm/v1/hooks/use-tambo-v1-thread-list.js.map +1 -0
  185. package/esm/v1/hooks/use-tambo-v1-thread-list.test.d.ts +2 -0
  186. package/esm/v1/hooks/use-tambo-v1-thread-list.test.d.ts.map +1 -0
  187. package/esm/v1/hooks/use-tambo-v1-thread-list.test.js +93 -0
  188. package/esm/v1/hooks/use-tambo-v1-thread-list.test.js.map +1 -0
  189. package/esm/v1/hooks/use-tambo-v1-thread.d.ts +37 -0
  190. package/esm/v1/hooks/use-tambo-v1-thread.d.ts.map +1 -0
  191. package/esm/v1/hooks/use-tambo-v1-thread.js +46 -0
  192. package/esm/v1/hooks/use-tambo-v1-thread.js.map +1 -0
  193. package/esm/v1/hooks/use-tambo-v1-thread.test.d.ts +2 -0
  194. package/esm/v1/hooks/use-tambo-v1-thread.test.d.ts.map +1 -0
  195. package/esm/v1/hooks/use-tambo-v1-thread.test.js +78 -0
  196. package/esm/v1/hooks/use-tambo-v1-thread.test.js.map +1 -0
  197. package/esm/v1/hooks/use-tambo-v1.d.ts +107 -0
  198. package/esm/v1/hooks/use-tambo-v1.d.ts.map +1 -0
  199. package/esm/v1/hooks/use-tambo-v1.js +84 -0
  200. package/esm/v1/hooks/use-tambo-v1.js.map +1 -0
  201. package/esm/v1/hooks/use-tambo-v1.test.d.ts +2 -0
  202. package/esm/v1/hooks/use-tambo-v1.test.d.ts.map +1 -0
  203. package/esm/v1/hooks/use-tambo-v1.test.js +145 -0
  204. package/esm/v1/hooks/use-tambo-v1.test.js.map +1 -0
  205. package/esm/v1/index.d.ts +65 -16
  206. package/esm/v1/index.d.ts.map +1 -1
  207. package/esm/v1/index.js +83 -27
  208. package/esm/v1/index.js.map +1 -1
  209. package/esm/v1/providers/tambo-v1-provider.d.ts +133 -0
  210. package/esm/v1/providers/tambo-v1-provider.d.ts.map +1 -0
  211. package/esm/v1/providers/tambo-v1-provider.js +94 -0
  212. package/esm/v1/providers/tambo-v1-provider.js.map +1 -0
  213. package/esm/v1/providers/tambo-v1-provider.test.d.ts +2 -0
  214. package/esm/v1/providers/tambo-v1-provider.test.d.ts.map +1 -0
  215. package/esm/v1/providers/tambo-v1-provider.test.js +176 -0
  216. package/esm/v1/providers/tambo-v1-provider.test.js.map +1 -0
  217. package/esm/v1/providers/tambo-v1-stream-context.d.ts +136 -0
  218. package/esm/v1/providers/tambo-v1-stream-context.d.ts.map +1 -0
  219. package/esm/v1/providers/tambo-v1-stream-context.js +191 -0
  220. package/esm/v1/providers/tambo-v1-stream-context.js.map +1 -0
  221. package/esm/v1/providers/tambo-v1-stream-context.test.d.ts +2 -0
  222. package/esm/v1/providers/tambo-v1-stream-context.test.d.ts.map +1 -0
  223. package/esm/v1/providers/tambo-v1-stream-context.test.js +80 -0
  224. package/esm/v1/providers/tambo-v1-stream-context.test.js.map +1 -0
  225. package/esm/v1/types/component.d.ts +5 -2
  226. package/esm/v1/types/component.d.ts.map +1 -1
  227. package/esm/v1/types/component.js +5 -2
  228. package/esm/v1/types/component.js.map +1 -1
  229. package/esm/v1/types/event.d.ts +21 -12
  230. package/esm/v1/types/event.d.ts.map +1 -1
  231. package/esm/v1/types/event.js +44 -2
  232. package/esm/v1/types/event.js.map +1 -1
  233. package/esm/v1/types/event.test.d.ts +2 -0
  234. package/esm/v1/types/event.test.d.ts.map +1 -0
  235. package/esm/v1/types/event.test.js +68 -0
  236. package/esm/v1/types/event.test.js.map +1 -0
  237. package/esm/v1/types/message.d.ts +30 -9
  238. package/esm/v1/types/message.d.ts.map +1 -1
  239. package/esm/v1/types/message.js +1 -1
  240. package/esm/v1/types/message.js.map +1 -1
  241. package/esm/v1/types/thread.d.ts +1 -3
  242. package/esm/v1/types/thread.d.ts.map +1 -1
  243. package/esm/v1/types/thread.js +1 -1
  244. package/esm/v1/types/thread.js.map +1 -1
  245. package/esm/v1/utils/component-renderer.d.ts +89 -0
  246. package/esm/v1/utils/component-renderer.d.ts.map +1 -0
  247. package/esm/v1/utils/component-renderer.js +175 -0
  248. package/esm/v1/utils/component-renderer.js.map +1 -0
  249. package/esm/v1/utils/component-renderer.test.d.ts +2 -0
  250. package/esm/v1/utils/component-renderer.test.d.ts.map +1 -0
  251. package/esm/v1/utils/component-renderer.test.js +375 -0
  252. package/esm/v1/utils/component-renderer.test.js.map +1 -0
  253. package/esm/v1/utils/event-accumulator.d.ts +100 -0
  254. package/esm/v1/utils/event-accumulator.d.ts.map +1 -0
  255. package/esm/v1/utils/event-accumulator.js +728 -0
  256. package/esm/v1/utils/event-accumulator.js.map +1 -0
  257. package/esm/v1/utils/event-accumulator.test.d.ts +2 -0
  258. package/esm/v1/utils/event-accumulator.test.d.ts.map +1 -0
  259. package/esm/v1/utils/event-accumulator.test.js +1203 -0
  260. package/esm/v1/utils/event-accumulator.test.js.map +1 -0
  261. package/esm/v1/utils/json-patch.d.ts +18 -0
  262. package/esm/v1/utils/json-patch.d.ts.map +1 -0
  263. package/esm/v1/utils/json-patch.js +32 -0
  264. package/esm/v1/utils/json-patch.js.map +1 -0
  265. package/esm/v1/utils/json-patch.test.d.ts +2 -0
  266. package/esm/v1/utils/json-patch.test.d.ts.map +1 -0
  267. package/esm/v1/utils/json-patch.test.js +26 -0
  268. package/esm/v1/utils/json-patch.test.js.map +1 -0
  269. package/esm/v1/utils/registry-conversion.d.ts +53 -0
  270. package/esm/v1/utils/registry-conversion.d.ts.map +1 -0
  271. package/esm/v1/utils/registry-conversion.js +108 -0
  272. package/esm/v1/utils/registry-conversion.js.map +1 -0
  273. package/esm/v1/utils/registry-conversion.test.d.ts +2 -0
  274. package/esm/v1/utils/registry-conversion.test.d.ts.map +1 -0
  275. package/esm/v1/utils/registry-conversion.test.js +177 -0
  276. package/esm/v1/utils/registry-conversion.test.js.map +1 -0
  277. package/esm/v1/utils/stream-handler.d.ts +45 -0
  278. package/esm/v1/utils/stream-handler.d.ts.map +1 -0
  279. package/esm/v1/utils/stream-handler.js +44 -0
  280. package/esm/v1/utils/stream-handler.js.map +1 -0
  281. package/esm/v1/utils/stream-handler.test.d.ts +2 -0
  282. package/esm/v1/utils/stream-handler.test.d.ts.map +1 -0
  283. package/esm/v1/utils/stream-handler.test.js +72 -0
  284. package/esm/v1/utils/stream-handler.test.js.map +1 -0
  285. package/esm/v1/utils/tool-call-tracker.d.ts +41 -0
  286. package/esm/v1/utils/tool-call-tracker.d.ts.map +1 -0
  287. package/esm/v1/utils/tool-call-tracker.js +86 -0
  288. package/esm/v1/utils/tool-call-tracker.js.map +1 -0
  289. package/esm/v1/utils/tool-executor.d.ts +33 -0
  290. package/esm/v1/utils/tool-executor.d.ts.map +1 -0
  291. package/esm/v1/utils/tool-executor.js +99 -0
  292. package/esm/v1/utils/tool-executor.js.map +1 -0
  293. package/esm/v1/utils/tool-executor.test.d.ts +2 -0
  294. package/esm/v1/utils/tool-executor.test.d.ts.map +1 -0
  295. package/esm/v1/utils/tool-executor.test.js +220 -0
  296. package/esm/v1/utils/tool-executor.test.js.map +1 -0
  297. package/package.json +7 -6
  298. package/dist/v1/types/tool.d.ts +0 -52
  299. package/dist/v1/types/tool.d.ts.map +0 -1
  300. package/dist/v1/types/tool.js +0 -11
  301. package/dist/v1/types/tool.js.map +0 -1
  302. package/esm/v1/types/tool.d.ts +0 -52
  303. package/esm/v1/types/tool.d.ts.map +0 -1
  304. package/esm/v1/types/tool.js +0 -10
  305. package/esm/v1/types/tool.js.map +0 -1
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Tool Executor for v1 API
3
+ *
4
+ * Handles automatic execution of client-side tools when the model
5
+ * requests them via `tambo.run.awaiting_input` events.
6
+ */
7
+ /**
8
+ * Execute a single client-side tool and return the result.
9
+ * @param tool - The tool definition from the registry
10
+ * @param toolCallId - The ID of the tool call to respond to
11
+ * @param args - The parsed arguments for the tool
12
+ * @returns ToolResultContent with the execution result or error
13
+ */
14
+ export async function executeClientTool(tool, toolCallId, args) {
15
+ try {
16
+ const result = await tool.tool(args);
17
+ // Transform result to content if transformer provided
18
+ let content;
19
+ if (tool.transformToContent) {
20
+ // transformToContent may return content parts in beta format
21
+ // Convert to v1 format (TextContent | ResourceContent)
22
+ const transformed = await tool.transformToContent(result);
23
+ content = transformed.map((part) => {
24
+ if (part.type === "text" && "text" in part && part.text) {
25
+ return { type: "text", text: part.text };
26
+ }
27
+ // For other types, stringify as text
28
+ return {
29
+ type: "text",
30
+ text: JSON.stringify(part),
31
+ };
32
+ });
33
+ }
34
+ else {
35
+ // Default: stringify result as text
36
+ content = [
37
+ {
38
+ type: "text",
39
+ text: typeof result === "string" ? result : JSON.stringify(result),
40
+ },
41
+ ];
42
+ }
43
+ return {
44
+ type: "tool_result",
45
+ toolUseId: toolCallId,
46
+ content,
47
+ };
48
+ }
49
+ catch (error) {
50
+ return {
51
+ type: "tool_result",
52
+ toolUseId: toolCallId,
53
+ content: [
54
+ {
55
+ type: "text",
56
+ text: error instanceof Error ? error.message : "Tool execution failed",
57
+ },
58
+ ],
59
+ };
60
+ }
61
+ }
62
+ /**
63
+ * Execute all pending tool calls and return their results.
64
+ * Tools are executed sequentially to avoid race conditions when
65
+ * tools may have side effects that depend on each other.
66
+ * @param toolCalls - Map of tool call IDs to their call details
67
+ * @param registry - Registry of tool names to their definitions (Map or Record)
68
+ * @returns Array of ToolResultContent for all executed tools
69
+ */
70
+ export async function executeAllPendingTools(toolCalls, registry) {
71
+ const results = [];
72
+ // Normalize registry to allow lookup regardless of Map or Record
73
+ const getTool = (name) => {
74
+ if (registry instanceof Map) {
75
+ return registry.get(name);
76
+ }
77
+ return registry[name];
78
+ };
79
+ for (const [toolCallId, { name, input }] of toolCalls) {
80
+ const tool = getTool(name);
81
+ if (!tool) {
82
+ results.push({
83
+ type: "tool_result",
84
+ toolUseId: toolCallId,
85
+ content: [
86
+ {
87
+ type: "text",
88
+ text: `Tool "${name}" not found in registry`,
89
+ },
90
+ ],
91
+ });
92
+ continue;
93
+ }
94
+ const result = await executeClientTool(tool, toolCallId, input);
95
+ results.push(result);
96
+ }
97
+ return results;
98
+ }
99
+ //# sourceMappingURL=tool-executor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-executor.js","sourceRoot":"","sources":["../../../src/v1/utils/tool-executor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAiBH;;;;;;GAMG;AACH,MAAM,CAAC,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,CAAC,IAAI,EAAE,CAAC;gBACpD,CAAC;gBACD,qCAAqC;gBACrC,OAAO;oBACL,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;iBAC3B,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,oCAAoC;YACpC,OAAO,GAAG;gBACR;oBACE,IAAI,EAAE,MAAe;oBACrB,IAAI,EAA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BACF;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 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 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"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=tool-executor.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-executor.test.d.ts","sourceRoot":"","sources":["../../../src/v1/utils/tool-executor.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,220 @@
1
+ import { z } from "zod";
2
+ import { executeClientTool, executeAllPendingTools, } from "./tool-executor";
3
+ describe("tool-executor", () => {
4
+ describe("executeClientTool", () => {
5
+ it("executes a tool and returns text result", async () => {
6
+ const tool = {
7
+ name: "get_weather",
8
+ description: "Gets weather",
9
+ tool: async ({ city }) => `Weather in ${city} is sunny`,
10
+ inputSchema: z.object({ city: z.string() }),
11
+ outputSchema: z.string(),
12
+ };
13
+ const result = await executeClientTool(tool, "call-1", {
14
+ city: "Seattle",
15
+ });
16
+ expect(result).toEqual({
17
+ type: "tool_result",
18
+ toolUseId: "call-1",
19
+ content: [{ type: "text", text: "Weather in Seattle is sunny" }],
20
+ });
21
+ });
22
+ it("stringifies non-string results", async () => {
23
+ const tool = {
24
+ name: "get_data",
25
+ description: "Gets data",
26
+ tool: async () => ({ value: 42 }),
27
+ inputSchema: z.object({}),
28
+ outputSchema: z.object({ value: z.number() }),
29
+ };
30
+ const result = await executeClientTool(tool, "call-2", {});
31
+ expect(result).toEqual({
32
+ type: "tool_result",
33
+ toolUseId: "call-2",
34
+ content: [{ type: "text", text: '{"value":42}' }],
35
+ });
36
+ });
37
+ it("uses transformToContent when provided", async () => {
38
+ const tool = {
39
+ name: "custom_tool",
40
+ description: "Custom tool",
41
+ tool: async () => "custom result",
42
+ inputSchema: z.object({}),
43
+ outputSchema: z.string(),
44
+ transformToContent: (result) => [
45
+ { type: "text", text: `Transformed: ${result}` },
46
+ ],
47
+ };
48
+ const result = await executeClientTool(tool, "call-3", {});
49
+ expect(result).toEqual({
50
+ type: "tool_result",
51
+ toolUseId: "call-3",
52
+ content: [{ type: "text", text: "Transformed: custom result" }],
53
+ });
54
+ });
55
+ it("handles transformToContent with non-text types by stringifying", async () => {
56
+ const tool = {
57
+ name: "image_tool",
58
+ description: "Image tool",
59
+ tool: async () => "image data",
60
+ inputSchema: z.object({}),
61
+ outputSchema: z.string(),
62
+ transformToContent: () => [
63
+ {
64
+ type: "image_url",
65
+ image_url: { url: "https://example.com/image.png" },
66
+ },
67
+ ],
68
+ };
69
+ const result = await executeClientTool(tool, "call-4", {});
70
+ expect(result).toEqual({
71
+ type: "tool_result",
72
+ toolUseId: "call-4",
73
+ content: [
74
+ {
75
+ type: "text",
76
+ text: '{"type":"image_url","image_url":{"url":"https://example.com/image.png"}}',
77
+ },
78
+ ],
79
+ });
80
+ });
81
+ it("handles tool execution errors gracefully", async () => {
82
+ const tool = {
83
+ name: "failing_tool",
84
+ description: "A tool that fails",
85
+ tool: async () => {
86
+ throw new Error("Tool failed!");
87
+ },
88
+ inputSchema: z.object({}),
89
+ outputSchema: z.void(),
90
+ };
91
+ const result = await executeClientTool(tool, "call-5", {});
92
+ expect(result).toEqual({
93
+ type: "tool_result",
94
+ toolUseId: "call-5",
95
+ content: [{ type: "text", text: "Tool failed!" }],
96
+ });
97
+ });
98
+ it("handles non-Error throws gracefully", async () => {
99
+ const tool = {
100
+ name: "throwing_tool",
101
+ description: "A tool that throws a string",
102
+ tool: async () => {
103
+ throw "string error";
104
+ },
105
+ inputSchema: z.object({}),
106
+ outputSchema: z.void(),
107
+ };
108
+ const result = await executeClientTool(tool, "call-6", {});
109
+ expect(result).toEqual({
110
+ type: "tool_result",
111
+ toolUseId: "call-6",
112
+ content: [{ type: "text", text: "Tool execution failed" }],
113
+ });
114
+ });
115
+ });
116
+ describe("executeAllPendingTools", () => {
117
+ it("executes multiple tools with Map registry", async () => {
118
+ const registry = new Map([
119
+ [
120
+ "add",
121
+ {
122
+ name: "add",
123
+ description: "Adds numbers",
124
+ tool: async ({ a, b }) => a + b,
125
+ inputSchema: z.object({ a: z.number(), b: z.number() }),
126
+ outputSchema: z.number(),
127
+ },
128
+ ],
129
+ [
130
+ "multiply",
131
+ {
132
+ name: "multiply",
133
+ description: "Multiplies numbers",
134
+ tool: async ({ a, b }) => a * b,
135
+ inputSchema: z.object({ a: z.number(), b: z.number() }),
136
+ outputSchema: z.number(),
137
+ },
138
+ ],
139
+ ]);
140
+ const toolCalls = new Map([
141
+ ["call-1", { name: "add", input: { a: 2, b: 3 } }],
142
+ ["call-2", { name: "multiply", input: { a: 4, b: 5 } }],
143
+ ]);
144
+ const results = await executeAllPendingTools(toolCalls, registry);
145
+ expect(results).toHaveLength(2);
146
+ expect(results[0]).toEqual({
147
+ type: "tool_result",
148
+ toolUseId: "call-1",
149
+ content: [{ type: "text", text: "5" }],
150
+ });
151
+ expect(results[1]).toEqual({
152
+ type: "tool_result",
153
+ toolUseId: "call-2",
154
+ content: [{ type: "text", text: "20" }],
155
+ });
156
+ });
157
+ it("executes tools with Record registry", async () => {
158
+ const registry = {
159
+ greet: {
160
+ name: "greet",
161
+ description: "Greets user",
162
+ tool: async ({ name }) => `Hello, ${name}!`,
163
+ inputSchema: z.object({ name: z.string() }),
164
+ outputSchema: z.string(),
165
+ },
166
+ };
167
+ const toolCalls = new Map([
168
+ ["call-1", { name: "greet", input: { name: "World" } }],
169
+ ]);
170
+ const results = await executeAllPendingTools(toolCalls, registry);
171
+ expect(results).toHaveLength(1);
172
+ expect(results[0]).toEqual({
173
+ type: "tool_result",
174
+ toolUseId: "call-1",
175
+ content: [{ type: "text", text: "Hello, World!" }],
176
+ });
177
+ });
178
+ it("returns error result for unknown tools", async () => {
179
+ const registry = new Map();
180
+ const toolCalls = new Map([
181
+ ["call-1", { name: "unknown_tool", input: {} }],
182
+ ]);
183
+ const results = await executeAllPendingTools(toolCalls, registry);
184
+ expect(results).toHaveLength(1);
185
+ expect(results[0]).toEqual({
186
+ type: "tool_result",
187
+ toolUseId: "call-1",
188
+ content: [
189
+ { type: "text", text: 'Tool "unknown_tool" not found in registry' },
190
+ ],
191
+ });
192
+ });
193
+ it("handles mixed known and unknown tools", async () => {
194
+ const registry = new Map([
195
+ [
196
+ "known",
197
+ {
198
+ name: "known",
199
+ description: "Known tool",
200
+ tool: async () => "success",
201
+ inputSchema: z.object({}),
202
+ outputSchema: z.string(),
203
+ },
204
+ ],
205
+ ]);
206
+ const toolCalls = new Map([
207
+ ["call-1", { name: "known", input: {} }],
208
+ ["call-2", { name: "unknown", input: {} }],
209
+ ]);
210
+ const results = await executeAllPendingTools(toolCalls, registry);
211
+ expect(results).toHaveLength(2);
212
+ expect(results[0].content[0]).toEqual({ type: "text", text: "success" });
213
+ expect(results[1].content[0]).toEqual({
214
+ type: "text",
215
+ text: 'Tool "unknown" not found in registry',
216
+ });
217
+ });
218
+ });
219
+ });
220
+ //# sourceMappingURL=tool-executor.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-executor.test.js","sourceRoot":"","sources":["../../../src/v1/utils/tool-executor.test.ts"],"names":[],"mappings":"AAAA,OAAO,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AO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;YACzE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;gBACpC,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,sCAAsC;aAC7C,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { z } from \"zod\";\nimport type { TamboTool } from \"../../model/component-metadata\";\nimport {\n executeClientTool,\n executeAllPendingTools,\n type PendingToolCall,\n} from \"./tool-executor\";\n\ndescribe(\"tool-executor\", () => {\n describe(\"executeClientTool\", () => {\n it(\"executes a tool and returns text result\", async () => {\n const tool: TamboTool = {\n name: \"get_weather\",\n description: \"Gets weather\",\n tool: async ({ city }: { city: string }) =>\n `Weather in ${city} is sunny`,\n inputSchema: z.object({ city: z.string() }),\n outputSchema: z.string(),\n };\n\n const result = await executeClientTool(tool, \"call-1\", {\n city: \"Seattle\",\n });\n\n expect(result).toEqual({\n type: \"tool_result\",\n toolUseId: \"call-1\",\n content: [{ type: \"text\", text: \"Weather in Seattle is sunny\" }],\n });\n });\n\n it(\"stringifies non-string results\", async () => {\n const tool: TamboTool = {\n name: \"get_data\",\n description: \"Gets data\",\n tool: async () => ({ value: 42 }),\n inputSchema: z.object({}),\n outputSchema: z.object({ value: z.number() }),\n };\n\n const result = await executeClientTool(tool, \"call-2\", {});\n\n expect(result).toEqual({\n type: \"tool_result\",\n toolUseId: \"call-2\",\n content: [{ type: \"text\", text: '{\"value\":42}' }],\n });\n });\n\n it(\"uses transformToContent when provided\", async () => {\n const tool: TamboTool = {\n name: \"custom_tool\",\n description: \"Custom tool\",\n tool: async () => \"custom result\",\n inputSchema: z.object({}),\n outputSchema: z.string(),\n transformToContent: (result) => [\n { type: \"text\", text: `Transformed: ${result}` },\n ],\n };\n\n const result = await executeClientTool(tool, \"call-3\", {});\n\n expect(result).toEqual({\n type: \"tool_result\",\n toolUseId: \"call-3\",\n content: [{ type: \"text\", text: \"Transformed: custom result\" }],\n });\n });\n\n it(\"handles transformToContent with non-text types by stringifying\", async () => {\n const tool: TamboTool = {\n name: \"image_tool\",\n description: \"Image tool\",\n tool: async () => \"image data\",\n inputSchema: z.object({}),\n outputSchema: z.string(),\n transformToContent: () => [\n {\n type: \"image_url\",\n image_url: { url: \"https://example.com/image.png\" },\n },\n ],\n };\n\n const result = await executeClientTool(tool, \"call-4\", {});\n\n expect(result).toEqual({\n type: \"tool_result\",\n toolUseId: \"call-4\",\n content: [\n {\n type: \"text\",\n text: '{\"type\":\"image_url\",\"image_url\":{\"url\":\"https://example.com/image.png\"}}',\n },\n ],\n });\n });\n\n it(\"handles tool execution errors gracefully\", async () => {\n const tool: TamboTool = {\n name: \"failing_tool\",\n description: \"A tool that fails\",\n tool: async () => {\n throw new Error(\"Tool failed!\");\n },\n inputSchema: z.object({}),\n outputSchema: z.void(),\n };\n\n const result = await executeClientTool(tool, \"call-5\", {});\n\n expect(result).toEqual({\n type: \"tool_result\",\n toolUseId: \"call-5\",\n content: [{ type: \"text\", text: \"Tool failed!\" }],\n });\n });\n\n it(\"handles non-Error throws gracefully\", async () => {\n const tool: TamboTool = {\n name: \"throwing_tool\",\n description: \"A tool that throws a string\",\n tool: async () => {\n throw \"string error\";\n },\n inputSchema: z.object({}),\n outputSchema: z.void(),\n };\n\n const result = await executeClientTool(tool, \"call-6\", {});\n\n expect(result).toEqual({\n type: \"tool_result\",\n toolUseId: \"call-6\",\n content: [{ type: \"text\", text: \"Tool execution failed\" }],\n });\n });\n });\n\n describe(\"executeAllPendingTools\", () => {\n it(\"executes multiple tools with Map registry\", async () => {\n const registry = new Map<string, TamboTool>([\n [\n \"add\",\n {\n name: \"add\",\n description: \"Adds numbers\",\n tool: async ({ a, b }: { a: number; b: number }) => a + b,\n inputSchema: z.object({ a: z.number(), b: z.number() }),\n outputSchema: z.number(),\n },\n ],\n [\n \"multiply\",\n {\n name: \"multiply\",\n description: \"Multiplies numbers\",\n tool: async ({ a, b }: { a: number; b: number }) => a * b,\n inputSchema: z.object({ a: z.number(), b: z.number() }),\n outputSchema: z.number(),\n },\n ],\n ]);\n\n const toolCalls = new Map<string, PendingToolCall>([\n [\"call-1\", { name: \"add\", input: { a: 2, b: 3 } }],\n [\"call-2\", { name: \"multiply\", input: { a: 4, b: 5 } }],\n ]);\n\n const results = await executeAllPendingTools(toolCalls, registry);\n\n expect(results).toHaveLength(2);\n expect(results[0]).toEqual({\n type: \"tool_result\",\n toolUseId: \"call-1\",\n content: [{ type: \"text\", text: \"5\" }],\n });\n expect(results[1]).toEqual({\n type: \"tool_result\",\n toolUseId: \"call-2\",\n content: [{ type: \"text\", text: \"20\" }],\n });\n });\n\n it(\"executes tools with Record registry\", async () => {\n const registry: Record<string, TamboTool> = {\n greet: {\n name: \"greet\",\n description: \"Greets user\",\n tool: async ({ name }: { name: string }) => `Hello, ${name}!`,\n inputSchema: z.object({ name: z.string() }),\n outputSchema: z.string(),\n },\n };\n\n const toolCalls = new Map<string, PendingToolCall>([\n [\"call-1\", { name: \"greet\", input: { name: \"World\" } }],\n ]);\n\n const results = await executeAllPendingTools(toolCalls, registry);\n\n expect(results).toHaveLength(1);\n expect(results[0]).toEqual({\n type: \"tool_result\",\n toolUseId: \"call-1\",\n content: [{ type: \"text\", text: \"Hello, World!\" }],\n });\n });\n\n it(\"returns error result for unknown tools\", async () => {\n const registry = new Map<string, TamboTool>();\n\n const toolCalls = new Map<string, PendingToolCall>([\n [\"call-1\", { name: \"unknown_tool\", input: {} }],\n ]);\n\n const results = await executeAllPendingTools(toolCalls, registry);\n\n expect(results).toHaveLength(1);\n expect(results[0]).toEqual({\n type: \"tool_result\",\n toolUseId: \"call-1\",\n content: [\n { type: \"text\", text: 'Tool \"unknown_tool\" not found in registry' },\n ],\n });\n });\n\n it(\"handles mixed known and unknown tools\", async () => {\n const registry = new Map<string, TamboTool>([\n [\n \"known\",\n {\n name: \"known\",\n description: \"Known tool\",\n tool: async () => \"success\",\n inputSchema: z.object({}),\n outputSchema: z.string(),\n },\n ],\n ]);\n\n const toolCalls = new Map<string, PendingToolCall>([\n [\"call-1\", { name: \"known\", input: {} }],\n [\"call-2\", { name: \"unknown\", input: {} }],\n ]);\n\n const results = await executeAllPendingTools(toolCalls, registry);\n\n expect(results).toHaveLength(2);\n expect(results[0].content[0]).toEqual({ type: \"text\", text: \"success\" });\n expect(results[1].content[0]).toEqual({\n type: \"text\",\n text: 'Tool \"unknown\" not found in registry',\n });\n });\n });\n});\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tambo-ai/react",
3
- "version": "0.70.0",
3
+ "version": "0.72.0",
4
4
  "description": "React client package for Tambo AI",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -81,13 +81,14 @@
81
81
  }
82
82
  },
83
83
  "dependencies": {
84
- "@ag-ui/core": "^0.0.42",
84
+ "@ag-ui/core": "^0.0.43",
85
85
  "@modelcontextprotocol/sdk": "^1.25.1",
86
86
  "@standard-community/standard-json": "^0.3.5",
87
87
  "@standard-schema/spec": "^1.1.0",
88
- "@tambo-ai/typescript-sdk": "^0.84.0",
88
+ "@tambo-ai/typescript-sdk": "^0.86.0",
89
89
  "@tanstack/react-query": "^5.90.16",
90
90
  "fast-equals": "^5.3.3",
91
+ "fast-json-patch": "^3.1.1",
91
92
  "partial-json": "^0.1.7",
92
93
  "react-fast-compare": "^3.2.2",
93
94
  "react-media-recorder": "^1.7.2",
@@ -101,7 +102,7 @@
101
102
  "@tambo-ai/eslint-config": "*",
102
103
  "@tambo-ai/typescript-config": "*",
103
104
  "@testing-library/jest-dom": "^6.9.1",
104
- "@testing-library/react": "^16.3.1",
105
+ "@testing-library/react": "^16.3.2",
105
106
  "@types/jest": "^30.0.0",
106
107
  "@types/json-schema": "^7.0.15",
107
108
  "@types/node": "^22.19.5",
@@ -110,13 +111,13 @@
110
111
  "@valibot/to-json-schema": "^1.5.0",
111
112
  "concurrently": "^9.2.1",
112
113
  "eslint": "^9.39.2",
113
- "eslint-plugin-jsdoc": "^62.0.0",
114
+ "eslint-plugin-jsdoc": "^62.3.1",
114
115
  "eslint-plugin-react": "^7.37.5",
115
116
  "eslint-plugin-react-hooks": "^6.1.1",
116
117
  "jest": "^30.2.0",
117
118
  "jest-environment-jsdom": "^30.2.0",
118
119
  "lint-staged": "^16.2.7",
119
- "prettier": "^3.8.0",
120
+ "prettier": "^3.8.1",
120
121
  "prettier-2": "npm:prettier@^2",
121
122
  "react": "^18.3.1",
122
123
  "react-dom": "^18.3.1",
@@ -1,52 +0,0 @@
1
- /**
2
- * Tool Types for v1 API
3
- *
4
- * Defines how client-side tools are registered and executed.
5
- *
6
- * TODO: Once @tambo-ai/typescript-sdk/v1 is released, import Tool
7
- * from the SDK package.
8
- */
9
- import type { Content } from "./message";
10
- /**
11
- * Tool registration metadata for the API
12
- * This is what gets sent to the API in the `available_tools` field
13
- */
14
- export interface Tool {
15
- /** Tool name (must be unique) */
16
- name: string;
17
- /** Human-readable description for the AI */
18
- description: string;
19
- /** JSON Schema describing tool input parameters */
20
- inputSchema: Record<string, unknown>;
21
- }
22
- /**
23
- * Tool implementation function
24
- */
25
- export type ToolFunction<TInput extends Record<string, unknown> = Record<string, unknown>, TOutput = unknown> = (input: TInput) => Promise<TOutput> | TOutput;
26
- /**
27
- * Optional function to transform tool output into content blocks
28
- * Useful for tools that return rich media (images, audio, etc.)
29
- */
30
- export type TransformToContent<TOutput = unknown> = (result: TOutput) => Content[];
31
- /**
32
- * Tool registration for React SDK
33
- * Extends Tool with the actual implementation
34
- */
35
- export interface TamboV1Tool<TInput extends Record<string, unknown> = Record<string, unknown>, TOutput = unknown> extends Tool {
36
- /** The tool implementation */
37
- tool: ToolFunction<TInput, TOutput>;
38
- /** Optional: Transform result to content blocks (default: stringifies to text) */
39
- transformToContent?: TransformToContent<TOutput>;
40
- }
41
- /**
42
- * Tool execution result
43
- */
44
- export interface ToolExecutionResult {
45
- /** Tool call ID */
46
- toolCallId: string;
47
- /** Tool result content blocks */
48
- content: Content[];
49
- /** Whether execution resulted in error */
50
- isError: boolean;
51
- }
52
- //# sourceMappingURL=tool.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../../src/v1/types/tool.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC;;;GAGG;AACH,MAAM,WAAW,IAAI;IACnB,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAC;IAEb,4CAA4C;IAC5C,WAAW,EAAE,MAAM,CAAC;IAEpB,mDAAmD;IACnD,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,CACtB,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChE,OAAO,GAAG,OAAO,IACf,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AAElD;;;GAGG;AACH,MAAM,MAAM,kBAAkB,CAAC,OAAO,GAAG,OAAO,IAAI,CAClD,MAAM,EAAE,OAAO,KACZ,OAAO,EAAE,CAAC;AAEf;;;GAGG;AACH,MAAM,WAAW,WAAW,CAC1B,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChE,OAAO,GAAG,OAAO,CACjB,SAAQ,IAAI;IACZ,8BAA8B;IAC9B,IAAI,EAAE,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEpC,kFAAkF;IAClF,kBAAkB,CAAC,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;CAClD;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,mBAAmB;IACnB,UAAU,EAAE,MAAM,CAAC;IAEnB,iCAAiC;IACjC,OAAO,EAAE,OAAO,EAAE,CAAC;IAEnB,0CAA0C;IAC1C,OAAO,EAAE,OAAO,CAAC;CAClB"}
@@ -1,11 +0,0 @@
1
- "use strict";
2
- /**
3
- * Tool Types for v1 API
4
- *
5
- * Defines how client-side tools are registered and executed.
6
- *
7
- * TODO: Once @tambo-ai/typescript-sdk/v1 is released, import Tool
8
- * from the SDK package.
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- //# sourceMappingURL=tool.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tool.js","sourceRoot":"","sources":["../../../src/v1/types/tool.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG","sourcesContent":["/**\n * Tool Types for v1 API\n *\n * Defines how client-side tools are registered and executed.\n *\n * TODO: Once @tambo-ai/typescript-sdk/v1 is released, import Tool\n * from the SDK package.\n */\n\nimport type { Content } from \"./message\";\n\n/**\n * Tool registration metadata for the API\n * This is what gets sent to the API in the `available_tools` field\n */\nexport interface Tool {\n /** Tool name (must be unique) */\n name: string;\n\n /** Human-readable description for the AI */\n description: string;\n\n /** JSON Schema describing tool input parameters */\n inputSchema: Record<string, unknown>;\n}\n\n/**\n * Tool implementation function\n */\nexport type ToolFunction<\n TInput extends Record<string, unknown> = Record<string, unknown>,\n TOutput = unknown,\n> = (input: TInput) => Promise<TOutput> | TOutput;\n\n/**\n * Optional function to transform tool output into content blocks\n * Useful for tools that return rich media (images, audio, etc.)\n */\nexport type TransformToContent<TOutput = unknown> = (\n result: TOutput,\n) => Content[];\n\n/**\n * Tool registration for React SDK\n * Extends Tool with the actual implementation\n */\nexport interface TamboV1Tool<\n TInput extends Record<string, unknown> = Record<string, unknown>,\n TOutput = unknown,\n> extends Tool {\n /** The tool implementation */\n tool: ToolFunction<TInput, TOutput>;\n\n /** Optional: Transform result to content blocks (default: stringifies to text) */\n transformToContent?: TransformToContent<TOutput>;\n}\n\n/**\n * Tool execution result\n */\nexport interface ToolExecutionResult {\n /** Tool call ID */\n toolCallId: string;\n\n /** Tool result content blocks */\n content: Content[];\n\n /** Whether execution resulted in error */\n isError: boolean;\n}\n"]}
@@ -1,52 +0,0 @@
1
- /**
2
- * Tool Types for v1 API
3
- *
4
- * Defines how client-side tools are registered and executed.
5
- *
6
- * TODO: Once @tambo-ai/typescript-sdk/v1 is released, import Tool
7
- * from the SDK package.
8
- */
9
- import type { Content } from "./message";
10
- /**
11
- * Tool registration metadata for the API
12
- * This is what gets sent to the API in the `available_tools` field
13
- */
14
- export interface Tool {
15
- /** Tool name (must be unique) */
16
- name: string;
17
- /** Human-readable description for the AI */
18
- description: string;
19
- /** JSON Schema describing tool input parameters */
20
- inputSchema: Record<string, unknown>;
21
- }
22
- /**
23
- * Tool implementation function
24
- */
25
- export type ToolFunction<TInput extends Record<string, unknown> = Record<string, unknown>, TOutput = unknown> = (input: TInput) => Promise<TOutput> | TOutput;
26
- /**
27
- * Optional function to transform tool output into content blocks
28
- * Useful for tools that return rich media (images, audio, etc.)
29
- */
30
- export type TransformToContent<TOutput = unknown> = (result: TOutput) => Content[];
31
- /**
32
- * Tool registration for React SDK
33
- * Extends Tool with the actual implementation
34
- */
35
- export interface TamboV1Tool<TInput extends Record<string, unknown> = Record<string, unknown>, TOutput = unknown> extends Tool {
36
- /** The tool implementation */
37
- tool: ToolFunction<TInput, TOutput>;
38
- /** Optional: Transform result to content blocks (default: stringifies to text) */
39
- transformToContent?: TransformToContent<TOutput>;
40
- }
41
- /**
42
- * Tool execution result
43
- */
44
- export interface ToolExecutionResult {
45
- /** Tool call ID */
46
- toolCallId: string;
47
- /** Tool result content blocks */
48
- content: Content[];
49
- /** Whether execution resulted in error */
50
- isError: boolean;
51
- }
52
- //# sourceMappingURL=tool.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../../src/v1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
4
- * Defines how client-side tools are registered and executed.
5
- *
6
- * TODO: Once @tambo-ai/typescript-sdk/v1 is released, import Tool
7
- * from the SDK package.
8
- */
9
- export {};
10
- //# sourceMappingURL=tool.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tool.js","sourceRoot":"","sources":["../../../src/v1/types/tool.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG","sourcesContent":["/**\n * Tool Types for v1 API\n *\n * Defines how client-side tools are registered and executed.\n *\n * TODO: Once @tambo-ai/typescript-sdk/v1 is released, import Tool\n * from the SDK package.\n */\n\nimport type { Content } from \"./message\";\n\n/**\n * Tool registration metadata for the API\n * This is what gets sent to the API in the `available_tools` field\n */\nexport interface Tool {\n /** Tool name (must be unique) */\n name: string;\n\n /** Human-readable description for the AI */\n description: string;\n\n /** JSON Schema describing tool input parameters */\n inputSchema: Record<string, unknown>;\n}\n\n/**\n * Tool implementation function\n */\nexport type ToolFunction<\n TInput extends Record<string, unknown> = Record<string, unknown>,\n TOutput = unknown,\n> = (input: TInput) => Promise<TOutput> | TOutput;\n\n/**\n * Optional function to transform tool output into content blocks\n * Useful for tools that return rich media (images, audio, etc.)\n */\nexport type TransformToContent<TOutput = unknown> = (\n result: TOutput,\n) => Content[];\n\n/**\n * Tool registration for React SDK\n * Extends Tool with the actual implementation\n */\nexport interface TamboV1Tool<\n TInput extends Record<string, unknown> = Record<string, unknown>,\n TOutput = unknown,\n> extends Tool {\n /** The tool implementation */\n tool: ToolFunction<TInput, TOutput>;\n\n /** Optional: Transform result to content blocks (default: stringifies to text) */\n transformToContent?: TransformToContent<TOutput>;\n}\n\n/**\n * Tool execution result\n */\nexport interface ToolExecutionResult {\n /** Tool call ID */\n toolCallId: string;\n\n /** Tool result content blocks */\n content: Content[];\n\n /** Whether execution resulted in error */\n isError: boolean;\n}\n"]}