@tambo-ai/react 0.75.0 → 1.0.0-rc.4

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 (613) hide show
  1. package/dist/hoc/with-tambo-interactable.d.ts.map +1 -1
  2. package/dist/hoc/with-tambo-interactable.js +13 -13
  3. package/dist/hoc/with-tambo-interactable.js.map +1 -1
  4. package/dist/hoc/with-tambo-interactable.test.js +3 -3
  5. package/dist/hoc/with-tambo-interactable.test.js.map +1 -1
  6. package/dist/index.d.ts +7 -25
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +7 -59
  9. package/dist/index.js.map +1 -1
  10. package/dist/mcp/mcp-hooks.js +5 -5
  11. package/dist/mcp/mcp-hooks.js.map +1 -1
  12. package/dist/model/component-metadata.d.ts +4 -4
  13. package/dist/model/component-metadata.js.map +1 -1
  14. package/dist/providers/tambo-client-provider.d.ts +6 -0
  15. package/dist/providers/tambo-client-provider.d.ts.map +1 -1
  16. package/dist/providers/tambo-client-provider.js +4 -2
  17. package/dist/providers/tambo-client-provider.js.map +1 -1
  18. package/dist/providers/tambo-interactable-provider.d.ts +1 -1
  19. package/dist/providers/tambo-interactables-additional-context-edge-cases.test.js +2 -10
  20. package/dist/providers/tambo-interactables-additional-context-edge-cases.test.js.map +1 -1
  21. package/dist/providers/tambo-interactables-additional-context.test.js +3 -19
  22. package/dist/providers/tambo-interactables-additional-context.test.js.map +1 -1
  23. package/dist/providers/tambo-mcp-token-provider.d.ts +8 -17
  24. package/dist/providers/tambo-mcp-token-provider.d.ts.map +1 -1
  25. package/dist/providers/tambo-mcp-token-provider.js +20 -97
  26. package/dist/providers/tambo-mcp-token-provider.js.map +1 -1
  27. package/dist/testing/tools.d.ts +3 -3
  28. package/dist/testing/tools.d.ts.map +1 -1
  29. package/dist/testing/tools.js.map +1 -1
  30. package/dist/util/registry-validators.js +1 -1
  31. package/dist/util/registry-validators.js.map +1 -1
  32. package/dist/v1/__tests__/v1-interactables.test.js +1 -1
  33. package/dist/v1/__tests__/v1-interactables.test.js.map +1 -1
  34. package/dist/v1/components/v1-component-renderer.d.ts +9 -9
  35. package/dist/v1/components/v1-component-renderer.d.ts.map +1 -1
  36. package/dist/v1/components/v1-component-renderer.js +13 -13
  37. package/dist/v1/components/v1-component-renderer.js.map +1 -1
  38. package/dist/v1/components/v1-component-renderer.test.js +15 -15
  39. package/dist/v1/components/v1-component-renderer.test.js.map +1 -1
  40. package/{esm/hooks/use-current-message.d.ts → dist/v1/hooks/use-tambo-current-message.d.ts} +30 -9
  41. package/dist/v1/hooks/use-tambo-current-message.d.ts.map +1 -0
  42. package/dist/{hooks/use-current-message.js → v1/hooks/use-tambo-current-message.js} +13 -8
  43. package/dist/v1/hooks/use-tambo-current-message.js.map +1 -0
  44. package/dist/v1/hooks/use-tambo-v1-auth-state.d.ts +5 -5
  45. package/dist/v1/hooks/use-tambo-v1-auth-state.d.ts.map +1 -1
  46. package/dist/v1/hooks/use-tambo-v1-auth-state.js +8 -8
  47. package/dist/v1/hooks/use-tambo-v1-auth-state.js.map +1 -1
  48. package/dist/v1/hooks/use-tambo-v1-auth-state.test.js +12 -12
  49. package/dist/v1/hooks/use-tambo-v1-auth-state.test.js.map +1 -1
  50. package/dist/v1/hooks/use-tambo-v1-component-state.d.ts +7 -6
  51. package/dist/v1/hooks/use-tambo-v1-component-state.d.ts.map +1 -1
  52. package/dist/v1/hooks/use-tambo-v1-component-state.js +50 -24
  53. package/dist/v1/hooks/use-tambo-v1-component-state.js.map +1 -1
  54. package/dist/v1/hooks/use-tambo-v1-component-state.test.js +60 -35
  55. package/dist/v1/hooks/use-tambo-v1-component-state.test.js.map +1 -1
  56. package/dist/v1/hooks/use-tambo-v1-messages.d.ts +9 -9
  57. package/dist/v1/hooks/use-tambo-v1-messages.d.ts.map +1 -1
  58. package/dist/v1/hooks/use-tambo-v1-messages.js +4 -4
  59. package/dist/v1/hooks/use-tambo-v1-messages.js.map +1 -1
  60. package/dist/v1/hooks/use-tambo-v1-messages.test.js +7 -7
  61. package/dist/v1/hooks/use-tambo-v1-messages.test.js.map +1 -1
  62. package/dist/v1/hooks/use-tambo-v1-send-message.d.ts +3 -3
  63. package/dist/v1/hooks/use-tambo-v1-send-message.d.ts.map +1 -1
  64. package/dist/v1/hooks/use-tambo-v1-send-message.js +20 -22
  65. package/dist/v1/hooks/use-tambo-v1-send-message.js.map +1 -1
  66. package/dist/v1/hooks/use-tambo-v1-send-message.test.js +51 -51
  67. package/dist/v1/hooks/use-tambo-v1-send-message.test.js.map +1 -1
  68. package/dist/v1/hooks/use-tambo-v1-stream-status.d.ts +5 -5
  69. package/dist/v1/hooks/use-tambo-v1-stream-status.d.ts.map +1 -1
  70. package/dist/v1/hooks/use-tambo-v1-stream-status.js +12 -14
  71. package/dist/v1/hooks/use-tambo-v1-stream-status.js.map +1 -1
  72. package/dist/v1/hooks/use-tambo-v1-stream-status.test.js +19 -19
  73. package/dist/v1/hooks/use-tambo-v1-stream-status.test.js.map +1 -1
  74. package/dist/v1/hooks/use-tambo-v1-suggestions.d.ts +7 -7
  75. package/dist/v1/hooks/use-tambo-v1-suggestions.d.ts.map +1 -1
  76. package/dist/v1/hooks/use-tambo-v1-suggestions.js +9 -9
  77. package/dist/v1/hooks/use-tambo-v1-suggestions.js.map +1 -1
  78. package/dist/v1/hooks/use-tambo-v1-suggestions.test.js +44 -44
  79. package/dist/v1/hooks/use-tambo-v1-suggestions.test.js.map +1 -1
  80. package/dist/v1/hooks/use-tambo-v1-thread-input.d.ts +3 -3
  81. package/dist/v1/hooks/use-tambo-v1-thread-input.d.ts.map +1 -1
  82. package/dist/v1/hooks/use-tambo-v1-thread-input.js +4 -4
  83. package/dist/v1/hooks/use-tambo-v1-thread-input.js.map +1 -1
  84. package/dist/v1/hooks/use-tambo-v1-thread-input.test.js +29 -29
  85. package/dist/v1/hooks/use-tambo-v1-thread-input.test.js.map +1 -1
  86. package/dist/v1/hooks/use-tambo-v1-thread-list.d.ts +4 -4
  87. package/dist/v1/hooks/use-tambo-v1-thread-list.d.ts.map +1 -1
  88. package/dist/v1/hooks/use-tambo-v1-thread-list.js +5 -5
  89. package/dist/v1/hooks/use-tambo-v1-thread-list.js.map +1 -1
  90. package/dist/v1/hooks/use-tambo-v1-thread-list.test.js +13 -17
  91. package/dist/v1/hooks/use-tambo-v1-thread-list.test.js.map +1 -1
  92. package/dist/v1/hooks/use-tambo-v1-thread.d.ts +3 -3
  93. package/dist/v1/hooks/use-tambo-v1-thread.d.ts.map +1 -1
  94. package/dist/v1/hooks/use-tambo-v1-thread.js +4 -4
  95. package/dist/v1/hooks/use-tambo-v1-thread.js.map +1 -1
  96. package/dist/v1/hooks/use-tambo-v1-thread.test.js +5 -5
  97. package/dist/v1/hooks/use-tambo-v1-thread.test.js.map +1 -1
  98. package/dist/v1/hooks/use-tambo-v1.d.ts +16 -7
  99. package/dist/v1/hooks/use-tambo-v1.d.ts.map +1 -1
  100. package/dist/v1/hooks/use-tambo-v1.js +41 -10
  101. package/dist/v1/hooks/use-tambo-v1.js.map +1 -1
  102. package/dist/v1/hooks/use-tambo-v1.test.js +176 -48
  103. package/dist/v1/hooks/use-tambo-v1.test.js.map +1 -1
  104. package/dist/v1/index.d.ts +31 -27
  105. package/dist/v1/index.d.ts.map +1 -1
  106. package/dist/v1/index.js +45 -35
  107. package/dist/v1/index.js.map +1 -1
  108. package/dist/v1/providers/tambo-v1-provider.d.ts +20 -20
  109. package/dist/v1/providers/tambo-v1-provider.d.ts.map +1 -1
  110. package/dist/v1/providers/tambo-v1-provider.js +32 -32
  111. package/dist/v1/providers/tambo-v1-provider.js.map +1 -1
  112. package/dist/v1/providers/tambo-v1-provider.test.js +22 -22
  113. package/dist/v1/providers/tambo-v1-provider.test.js.map +1 -1
  114. package/dist/v1/providers/tambo-v1-stream-context.d.ts +15 -15
  115. package/dist/v1/providers/tambo-v1-stream-context.d.ts.map +1 -1
  116. package/dist/v1/providers/tambo-v1-stream-context.js +17 -17
  117. package/dist/v1/providers/tambo-v1-stream-context.js.map +1 -1
  118. package/dist/v1/providers/tambo-v1-stream-context.test.js +9 -9
  119. package/dist/v1/providers/tambo-v1-stream-context.test.js.map +1 -1
  120. package/dist/v1/providers/tambo-v1-stub-provider.d.ts +9 -9
  121. package/dist/v1/providers/tambo-v1-stub-provider.d.ts.map +1 -1
  122. package/dist/v1/providers/tambo-v1-stub-provider.js +7 -7
  123. package/dist/v1/providers/tambo-v1-stub-provider.js.map +1 -1
  124. package/dist/v1/providers/tambo-v1-stub-provider.test.js +25 -25
  125. package/dist/v1/providers/tambo-v1-stub-provider.test.js.map +1 -1
  126. package/dist/v1/providers/tambo-v1-thread-input-provider.d.ts +9 -9
  127. package/dist/v1/providers/tambo-v1-thread-input-provider.d.ts.map +1 -1
  128. package/dist/v1/providers/tambo-v1-thread-input-provider.js +16 -16
  129. package/dist/v1/providers/tambo-v1-thread-input-provider.js.map +1 -1
  130. package/dist/v1/types/auth.d.ts +2 -2
  131. package/dist/v1/types/auth.d.ts.map +1 -1
  132. package/dist/v1/types/auth.js.map +1 -1
  133. package/dist/v1/types/component.d.ts +3 -3
  134. package/dist/v1/types/component.d.ts.map +1 -1
  135. package/dist/v1/types/component.js +2 -2
  136. package/dist/v1/types/component.js.map +1 -1
  137. package/dist/v1/types/event.d.ts +1 -1
  138. package/dist/v1/types/event.js +1 -1
  139. package/dist/v1/types/event.js.map +1 -1
  140. package/dist/v1/types/message.d.ts +17 -24
  141. package/dist/v1/types/message.d.ts.map +1 -1
  142. package/dist/v1/types/message.js +1 -1
  143. package/dist/v1/types/message.js.map +1 -1
  144. package/dist/v1/types/thread.d.ts +10 -8
  145. package/dist/v1/types/thread.d.ts.map +1 -1
  146. package/dist/v1/types/thread.js +1 -1
  147. package/dist/v1/types/thread.js.map +1 -1
  148. package/dist/v1/types/tool-choice.d.ts +1 -1
  149. package/dist/v1/types/tool-choice.js.map +1 -1
  150. package/dist/v1/utils/component-renderer.d.ts +11 -5
  151. package/dist/v1/utils/component-renderer.d.ts.map +1 -1
  152. package/dist/v1/utils/component-renderer.js +16 -7
  153. package/dist/v1/utils/component-renderer.js.map +1 -1
  154. package/dist/v1/utils/component-renderer.test.js +7 -7
  155. package/dist/v1/utils/component-renderer.test.js.map +1 -1
  156. package/dist/v1/utils/event-accumulator.d.ts +13 -13
  157. package/dist/v1/utils/event-accumulator.d.ts.map +1 -1
  158. package/dist/v1/utils/event-accumulator.js +26 -15
  159. package/dist/v1/utils/event-accumulator.js.map +1 -1
  160. package/dist/v1/utils/event-accumulator.test.js +54 -19
  161. package/dist/v1/utils/event-accumulator.test.js.map +1 -1
  162. package/dist/v1/utils/registry-conversion.d.ts +18 -18
  163. package/dist/v1/utils/registry-conversion.js +23 -23
  164. package/dist/v1/utils/registry-conversion.js.map +1 -1
  165. package/dist/v1/utils/stream-handler.d.ts +1 -1
  166. package/dist/v1/utils/stream-handler.js +1 -1
  167. package/dist/v1/utils/stream-handler.js.map +1 -1
  168. package/dist/v1/utils/thread-utils.d.ts +2 -2
  169. package/dist/v1/utils/thread-utils.d.ts.map +1 -1
  170. package/dist/v1/utils/thread-utils.js.map +1 -1
  171. package/dist/v1/utils/tool-call-tracker.d.ts +1 -1
  172. package/dist/v1/utils/tool-call-tracker.js +1 -1
  173. package/dist/v1/utils/tool-call-tracker.js.map +1 -1
  174. package/dist/v1/utils/tool-executor.d.ts +1 -1
  175. package/dist/v1/utils/tool-executor.js +2 -2
  176. package/dist/v1/utils/tool-executor.js.map +1 -1
  177. package/esm/hoc/with-tambo-interactable.d.ts.map +1 -1
  178. package/esm/hoc/with-tambo-interactable.js +13 -13
  179. package/esm/hoc/with-tambo-interactable.js.map +1 -1
  180. package/esm/hoc/with-tambo-interactable.test.js +1 -1
  181. package/esm/hoc/with-tambo-interactable.test.js.map +1 -1
  182. package/esm/index.d.ts +7 -25
  183. package/esm/index.d.ts.map +1 -1
  184. package/esm/index.js +7 -21
  185. package/esm/index.js.map +1 -1
  186. package/esm/mcp/mcp-hooks.js +1 -1
  187. package/esm/mcp/mcp-hooks.js.map +1 -1
  188. package/esm/model/component-metadata.d.ts +4 -4
  189. package/esm/model/component-metadata.js.map +1 -1
  190. package/esm/providers/tambo-client-provider.d.ts +6 -0
  191. package/esm/providers/tambo-client-provider.d.ts.map +1 -1
  192. package/esm/providers/tambo-client-provider.js +4 -2
  193. package/esm/providers/tambo-client-provider.js.map +1 -1
  194. package/esm/providers/tambo-interactable-provider.d.ts +1 -1
  195. package/esm/providers/tambo-interactables-additional-context-edge-cases.test.js +2 -10
  196. package/esm/providers/tambo-interactables-additional-context-edge-cases.test.js.map +1 -1
  197. package/esm/providers/tambo-interactables-additional-context.test.js +3 -19
  198. package/esm/providers/tambo-interactables-additional-context.test.js.map +1 -1
  199. package/esm/providers/tambo-mcp-token-provider.d.ts +8 -17
  200. package/esm/providers/tambo-mcp-token-provider.d.ts.map +1 -1
  201. package/esm/providers/tambo-mcp-token-provider.js +20 -97
  202. package/esm/providers/tambo-mcp-token-provider.js.map +1 -1
  203. package/esm/testing/tools.d.ts +3 -3
  204. package/esm/testing/tools.d.ts.map +1 -1
  205. package/esm/testing/tools.js.map +1 -1
  206. package/esm/util/registry-validators.js +1 -1
  207. package/esm/util/registry-validators.js.map +1 -1
  208. package/esm/v1/__tests__/v1-interactables.test.js +1 -1
  209. package/esm/v1/__tests__/v1-interactables.test.js.map +1 -1
  210. package/esm/v1/components/v1-component-renderer.d.ts +9 -9
  211. package/esm/v1/components/v1-component-renderer.d.ts.map +1 -1
  212. package/esm/v1/components/v1-component-renderer.js +12 -12
  213. package/esm/v1/components/v1-component-renderer.js.map +1 -1
  214. package/esm/v1/components/v1-component-renderer.test.js +16 -16
  215. package/esm/v1/components/v1-component-renderer.test.js.map +1 -1
  216. package/{dist/hooks/use-current-message.d.ts → esm/v1/hooks/use-tambo-current-message.d.ts} +30 -9
  217. package/esm/v1/hooks/use-tambo-current-message.d.ts.map +1 -0
  218. package/esm/{hooks/use-current-message.js → v1/hooks/use-tambo-current-message.js} +13 -8
  219. package/esm/v1/hooks/use-tambo-current-message.js.map +1 -0
  220. package/esm/v1/hooks/use-tambo-v1-auth-state.d.ts +5 -5
  221. package/esm/v1/hooks/use-tambo-v1-auth-state.d.ts.map +1 -1
  222. package/esm/v1/hooks/use-tambo-v1-auth-state.js +8 -8
  223. package/esm/v1/hooks/use-tambo-v1-auth-state.js.map +1 -1
  224. package/esm/v1/hooks/use-tambo-v1-auth-state.test.js +14 -14
  225. package/esm/v1/hooks/use-tambo-v1-auth-state.test.js.map +1 -1
  226. package/esm/v1/hooks/use-tambo-v1-component-state.d.ts +7 -6
  227. package/esm/v1/hooks/use-tambo-v1-component-state.d.ts.map +1 -1
  228. package/esm/v1/hooks/use-tambo-v1-component-state.js +50 -24
  229. package/esm/v1/hooks/use-tambo-v1-component-state.js.map +1 -1
  230. package/esm/v1/hooks/use-tambo-v1-component-state.test.js +62 -37
  231. package/esm/v1/hooks/use-tambo-v1-component-state.test.js.map +1 -1
  232. package/esm/v1/hooks/use-tambo-v1-messages.d.ts +9 -9
  233. package/esm/v1/hooks/use-tambo-v1-messages.d.ts.map +1 -1
  234. package/esm/v1/hooks/use-tambo-v1-messages.js +3 -3
  235. package/esm/v1/hooks/use-tambo-v1-messages.js.map +1 -1
  236. package/esm/v1/hooks/use-tambo-v1-messages.test.js +9 -9
  237. package/esm/v1/hooks/use-tambo-v1-messages.test.js.map +1 -1
  238. package/esm/v1/hooks/use-tambo-v1-send-message.d.ts +3 -3
  239. package/esm/v1/hooks/use-tambo-v1-send-message.d.ts.map +1 -1
  240. package/esm/v1/hooks/use-tambo-v1-send-message.js +21 -23
  241. package/esm/v1/hooks/use-tambo-v1-send-message.js.map +1 -1
  242. package/esm/v1/hooks/use-tambo-v1-send-message.test.js +54 -54
  243. package/esm/v1/hooks/use-tambo-v1-send-message.test.js.map +1 -1
  244. package/esm/v1/hooks/use-tambo-v1-stream-status.d.ts +5 -5
  245. package/esm/v1/hooks/use-tambo-v1-stream-status.d.ts.map +1 -1
  246. package/esm/v1/hooks/use-tambo-v1-stream-status.js +12 -14
  247. package/esm/v1/hooks/use-tambo-v1-stream-status.js.map +1 -1
  248. package/esm/v1/hooks/use-tambo-v1-stream-status.test.js +21 -21
  249. package/esm/v1/hooks/use-tambo-v1-stream-status.test.js.map +1 -1
  250. package/esm/v1/hooks/use-tambo-v1-suggestions.d.ts +7 -7
  251. package/esm/v1/hooks/use-tambo-v1-suggestions.d.ts.map +1 -1
  252. package/esm/v1/hooks/use-tambo-v1-suggestions.js +11 -11
  253. package/esm/v1/hooks/use-tambo-v1-suggestions.js.map +1 -1
  254. package/esm/v1/hooks/use-tambo-v1-suggestions.test.js +48 -48
  255. package/esm/v1/hooks/use-tambo-v1-suggestions.test.js.map +1 -1
  256. package/esm/v1/hooks/use-tambo-v1-thread-input.d.ts +3 -3
  257. package/esm/v1/hooks/use-tambo-v1-thread-input.d.ts.map +1 -1
  258. package/esm/v1/hooks/use-tambo-v1-thread-input.js +3 -3
  259. package/esm/v1/hooks/use-tambo-v1-thread-input.js.map +1 -1
  260. package/esm/v1/hooks/use-tambo-v1-thread-input.test.js +32 -32
  261. package/esm/v1/hooks/use-tambo-v1-thread-input.test.js.map +1 -1
  262. package/esm/v1/hooks/use-tambo-v1-thread-list.d.ts +4 -4
  263. package/esm/v1/hooks/use-tambo-v1-thread-list.d.ts.map +1 -1
  264. package/esm/v1/hooks/use-tambo-v1-thread-list.js +6 -6
  265. package/esm/v1/hooks/use-tambo-v1-thread-list.js.map +1 -1
  266. package/esm/v1/hooks/use-tambo-v1-thread-list.test.js +15 -19
  267. package/esm/v1/hooks/use-tambo-v1-thread-list.test.js.map +1 -1
  268. package/esm/v1/hooks/use-tambo-v1-thread.d.ts +3 -3
  269. package/esm/v1/hooks/use-tambo-v1-thread.d.ts.map +1 -1
  270. package/esm/v1/hooks/use-tambo-v1-thread.js +4 -4
  271. package/esm/v1/hooks/use-tambo-v1-thread.js.map +1 -1
  272. package/esm/v1/hooks/use-tambo-v1-thread.test.js +6 -6
  273. package/esm/v1/hooks/use-tambo-v1-thread.test.js.map +1 -1
  274. package/esm/v1/hooks/use-tambo-v1.d.ts +16 -7
  275. package/esm/v1/hooks/use-tambo-v1.d.ts.map +1 -1
  276. package/esm/v1/hooks/use-tambo-v1.js +43 -12
  277. package/esm/v1/hooks/use-tambo-v1.js.map +1 -1
  278. package/esm/v1/hooks/use-tambo-v1.test.js +178 -50
  279. package/esm/v1/hooks/use-tambo-v1.test.js.map +1 -1
  280. package/esm/v1/index.d.ts +31 -27
  281. package/esm/v1/index.d.ts.map +1 -1
  282. package/esm/v1/index.js +38 -33
  283. package/esm/v1/index.js.map +1 -1
  284. package/esm/v1/providers/tambo-v1-provider.d.ts +20 -20
  285. package/esm/v1/providers/tambo-v1-provider.d.ts.map +1 -1
  286. package/esm/v1/providers/tambo-v1-provider.js +32 -32
  287. package/esm/v1/providers/tambo-v1-provider.js.map +1 -1
  288. package/esm/v1/providers/tambo-v1-provider.test.js +23 -23
  289. package/esm/v1/providers/tambo-v1-provider.test.js.map +1 -1
  290. package/esm/v1/providers/tambo-v1-stream-context.d.ts +15 -15
  291. package/esm/v1/providers/tambo-v1-stream-context.d.ts.map +1 -1
  292. package/esm/v1/providers/tambo-v1-stream-context.js +17 -17
  293. package/esm/v1/providers/tambo-v1-stream-context.js.map +1 -1
  294. package/esm/v1/providers/tambo-v1-stream-context.test.js +10 -10
  295. package/esm/v1/providers/tambo-v1-stream-context.test.js.map +1 -1
  296. package/esm/v1/providers/tambo-v1-stub-provider.d.ts +9 -9
  297. package/esm/v1/providers/tambo-v1-stub-provider.d.ts.map +1 -1
  298. package/esm/v1/providers/tambo-v1-stub-provider.js +9 -9
  299. package/esm/v1/providers/tambo-v1-stub-provider.js.map +1 -1
  300. package/esm/v1/providers/tambo-v1-stub-provider.test.js +28 -28
  301. package/esm/v1/providers/tambo-v1-stub-provider.test.js.map +1 -1
  302. package/esm/v1/providers/tambo-v1-thread-input-provider.d.ts +9 -9
  303. package/esm/v1/providers/tambo-v1-thread-input-provider.d.ts.map +1 -1
  304. package/esm/v1/providers/tambo-v1-thread-input-provider.js +15 -15
  305. package/esm/v1/providers/tambo-v1-thread-input-provider.js.map +1 -1
  306. package/esm/v1/types/auth.d.ts +2 -2
  307. package/esm/v1/types/auth.d.ts.map +1 -1
  308. package/esm/v1/types/auth.js.map +1 -1
  309. package/esm/v1/types/component.d.ts +3 -3
  310. package/esm/v1/types/component.d.ts.map +1 -1
  311. package/esm/v1/types/component.js +2 -2
  312. package/esm/v1/types/component.js.map +1 -1
  313. package/esm/v1/types/event.d.ts +1 -1
  314. package/esm/v1/types/event.js +1 -1
  315. package/esm/v1/types/event.js.map +1 -1
  316. package/esm/v1/types/message.d.ts +17 -24
  317. package/esm/v1/types/message.d.ts.map +1 -1
  318. package/esm/v1/types/message.js +1 -1
  319. package/esm/v1/types/message.js.map +1 -1
  320. package/esm/v1/types/thread.d.ts +10 -8
  321. package/esm/v1/types/thread.d.ts.map +1 -1
  322. package/esm/v1/types/thread.js +1 -1
  323. package/esm/v1/types/thread.js.map +1 -1
  324. package/esm/v1/types/tool-choice.d.ts +1 -1
  325. package/esm/v1/types/tool-choice.js.map +1 -1
  326. package/esm/v1/utils/component-renderer.d.ts +11 -5
  327. package/esm/v1/utils/component-renderer.d.ts.map +1 -1
  328. package/esm/v1/utils/component-renderer.js +13 -5
  329. package/esm/v1/utils/component-renderer.js.map +1 -1
  330. package/esm/v1/utils/component-renderer.test.js +8 -8
  331. package/esm/v1/utils/component-renderer.test.js.map +1 -1
  332. package/esm/v1/utils/event-accumulator.d.ts +13 -13
  333. package/esm/v1/utils/event-accumulator.d.ts.map +1 -1
  334. package/esm/v1/utils/event-accumulator.js +26 -15
  335. package/esm/v1/utils/event-accumulator.js.map +1 -1
  336. package/esm/v1/utils/event-accumulator.test.js +54 -19
  337. package/esm/v1/utils/event-accumulator.test.js.map +1 -1
  338. package/esm/v1/utils/registry-conversion.d.ts +18 -18
  339. package/esm/v1/utils/registry-conversion.js +23 -23
  340. package/esm/v1/utils/registry-conversion.js.map +1 -1
  341. package/esm/v1/utils/stream-handler.d.ts +1 -1
  342. package/esm/v1/utils/stream-handler.js +1 -1
  343. package/esm/v1/utils/stream-handler.js.map +1 -1
  344. package/esm/v1/utils/thread-utils.d.ts +2 -2
  345. package/esm/v1/utils/thread-utils.d.ts.map +1 -1
  346. package/esm/v1/utils/thread-utils.js.map +1 -1
  347. package/esm/v1/utils/tool-call-tracker.d.ts +1 -1
  348. package/esm/v1/utils/tool-call-tracker.js +1 -1
  349. package/esm/v1/utils/tool-call-tracker.js.map +1 -1
  350. package/esm/v1/utils/tool-executor.d.ts +1 -1
  351. package/esm/v1/utils/tool-executor.js +2 -2
  352. package/esm/v1/utils/tool-executor.js.map +1 -1
  353. package/package.json +4 -9
  354. package/dist/hooks/index.d.ts +0 -9
  355. package/dist/hooks/index.d.ts.map +0 -1
  356. package/dist/hooks/index.js +0 -34
  357. package/dist/hooks/index.js.map +0 -1
  358. package/dist/hooks/use-component-state.d.ts +0 -30
  359. package/dist/hooks/use-component-state.d.ts.map +0 -1
  360. package/dist/hooks/use-component-state.js +0 -139
  361. package/dist/hooks/use-component-state.js.map +0 -1
  362. package/dist/hooks/use-component-state.test.d.ts +0 -2
  363. package/dist/hooks/use-component-state.test.d.ts.map +0 -1
  364. package/dist/hooks/use-component-state.test.js +0 -406
  365. package/dist/hooks/use-component-state.test.js.map +0 -1
  366. package/dist/hooks/use-current-message.d.ts.map +0 -1
  367. package/dist/hooks/use-current-message.js.map +0 -1
  368. package/dist/hooks/use-current-message.test.d.ts +0 -2
  369. package/dist/hooks/use-current-message.test.d.ts.map +0 -1
  370. package/dist/hooks/use-current-message.test.js +0 -269
  371. package/dist/hooks/use-current-message.test.js.map +0 -1
  372. package/dist/hooks/use-streaming-props.d.ts +0 -11
  373. package/dist/hooks/use-streaming-props.d.ts.map +0 -1
  374. package/dist/hooks/use-streaming-props.js +0 -37
  375. package/dist/hooks/use-streaming-props.js.map +0 -1
  376. package/dist/hooks/use-suggestions.d.ts +0 -46
  377. package/dist/hooks/use-suggestions.d.ts.map +0 -1
  378. package/dist/hooks/use-suggestions.js +0 -118
  379. package/dist/hooks/use-suggestions.js.map +0 -1
  380. package/dist/hooks/use-suggestions.test.d.ts +0 -2
  381. package/dist/hooks/use-suggestions.test.d.ts.map +0 -1
  382. package/dist/hooks/use-suggestions.test.js +0 -247
  383. package/dist/hooks/use-suggestions.test.js.map +0 -1
  384. package/dist/hooks/use-tambo-stream-status.d.ts +0 -90
  385. package/dist/hooks/use-tambo-stream-status.d.ts.map +0 -1
  386. package/dist/hooks/use-tambo-stream-status.js +0 -213
  387. package/dist/hooks/use-tambo-stream-status.js.map +0 -1
  388. package/dist/hooks/use-tambo-stream-status.test.d.ts +0 -2
  389. package/dist/hooks/use-tambo-stream-status.test.d.ts.map +0 -1
  390. package/dist/hooks/use-tambo-stream-status.test.js +0 -378
  391. package/dist/hooks/use-tambo-stream-status.test.js.map +0 -1
  392. package/dist/hooks/use-tambo-threads.d.ts +0 -158
  393. package/dist/hooks/use-tambo-threads.d.ts.map +0 -1
  394. package/dist/hooks/use-tambo-threads.js +0 -45
  395. package/dist/hooks/use-tambo-threads.js.map +0 -1
  396. package/dist/hooks/use-tambo-threads.test.d.ts +0 -2
  397. package/dist/hooks/use-tambo-threads.test.d.ts.map +0 -1
  398. package/dist/hooks/use-tambo-threads.test.js +0 -214
  399. package/dist/hooks/use-tambo-threads.test.js.map +0 -1
  400. package/dist/model/generate-component-response.d.ts +0 -37
  401. package/dist/model/generate-component-response.d.ts.map +0 -1
  402. package/dist/model/generate-component-response.js +0 -29
  403. package/dist/model/generate-component-response.js.map +0 -1
  404. package/dist/model/tambo-thread.d.ts +0 -15
  405. package/dist/model/tambo-thread.d.ts.map +0 -1
  406. package/dist/model/tambo-thread.js +0 -3
  407. package/dist/model/tambo-thread.js.map +0 -1
  408. package/dist/providers/__tests__/thread-input-resource-resolution.test.d.ts +0 -2
  409. package/dist/providers/__tests__/thread-input-resource-resolution.test.d.ts.map +0 -1
  410. package/dist/providers/__tests__/thread-input-resource-resolution.test.js +0 -592
  411. package/dist/providers/__tests__/thread-input-resource-resolution.test.js.map +0 -1
  412. package/dist/providers/index.d.ts +0 -13
  413. package/dist/providers/index.d.ts.map +0 -1
  414. package/dist/providers/index.js +0 -41
  415. package/dist/providers/index.js.map +0 -1
  416. package/dist/providers/tambo-component-provider.d.ts +0 -23
  417. package/dist/providers/tambo-component-provider.d.ts.map +0 -1
  418. package/dist/providers/tambo-component-provider.js +0 -88
  419. package/dist/providers/tambo-component-provider.js.map +0 -1
  420. package/dist/providers/tambo-prop-stream-provider/index.d.ts +0 -19
  421. package/dist/providers/tambo-prop-stream-provider/index.d.ts.map +0 -1
  422. package/dist/providers/tambo-prop-stream-provider/index.js +0 -43
  423. package/dist/providers/tambo-prop-stream-provider/index.js.map +0 -1
  424. package/dist/providers/tambo-prop-stream-provider/pending.d.ts +0 -12
  425. package/dist/providers/tambo-prop-stream-provider/pending.d.ts.map +0 -1
  426. package/dist/providers/tambo-prop-stream-provider/pending.js +0 -31
  427. package/dist/providers/tambo-prop-stream-provider/pending.js.map +0 -1
  428. package/dist/providers/tambo-prop-stream-provider/provider.d.ts +0 -17
  429. package/dist/providers/tambo-prop-stream-provider/provider.d.ts.map +0 -1
  430. package/dist/providers/tambo-prop-stream-provider/provider.js +0 -107
  431. package/dist/providers/tambo-prop-stream-provider/provider.js.map +0 -1
  432. package/dist/providers/tambo-prop-stream-provider/streaming.d.ts +0 -12
  433. package/dist/providers/tambo-prop-stream-provider/streaming.d.ts.map +0 -1
  434. package/dist/providers/tambo-prop-stream-provider/streaming.js +0 -28
  435. package/dist/providers/tambo-prop-stream-provider/streaming.js.map +0 -1
  436. package/dist/providers/tambo-prop-stream-provider/success.d.ts +0 -12
  437. package/dist/providers/tambo-prop-stream-provider/success.d.ts.map +0 -1
  438. package/dist/providers/tambo-prop-stream-provider/success.js +0 -28
  439. package/dist/providers/tambo-prop-stream-provider/success.js.map +0 -1
  440. package/dist/providers/tambo-prop-stream-provider/types.d.ts +0 -25
  441. package/dist/providers/tambo-prop-stream-provider/types.d.ts.map +0 -1
  442. package/dist/providers/tambo-prop-stream-provider/types.js +0 -6
  443. package/dist/providers/tambo-prop-stream-provider/types.js.map +0 -1
  444. package/dist/providers/tambo-prop-stream-provider.test.d.ts +0 -2
  445. package/dist/providers/tambo-prop-stream-provider.test.d.ts.map +0 -1
  446. package/dist/providers/tambo-prop-stream-provider.test.js +0 -275
  447. package/dist/providers/tambo-prop-stream-provider.test.js.map +0 -1
  448. package/dist/providers/tambo-provider.d.ts +0 -53
  449. package/dist/providers/tambo-provider.d.ts.map +0 -1
  450. package/dist/providers/tambo-provider.js +0 -133
  451. package/dist/providers/tambo-provider.js.map +0 -1
  452. package/dist/providers/tambo-stubs.d.ts +0 -89
  453. package/dist/providers/tambo-stubs.d.ts.map +0 -1
  454. package/dist/providers/tambo-stubs.js +0 -279
  455. package/dist/providers/tambo-stubs.js.map +0 -1
  456. package/dist/providers/tambo-stubs.test.d.ts +0 -2
  457. package/dist/providers/tambo-stubs.test.d.ts.map +0 -1
  458. package/dist/providers/tambo-stubs.test.js +0 -97
  459. package/dist/providers/tambo-stubs.test.js.map +0 -1
  460. package/dist/providers/tambo-thread-input-provider.d.ts +0 -65
  461. package/dist/providers/tambo-thread-input-provider.d.ts.map +0 -1
  462. package/dist/providers/tambo-thread-input-provider.js +0 -179
  463. package/dist/providers/tambo-thread-input-provider.js.map +0 -1
  464. package/dist/providers/tambo-thread-provider-initial-messages.test.d.ts +0 -2
  465. package/dist/providers/tambo-thread-provider-initial-messages.test.d.ts.map +0 -1
  466. package/dist/providers/tambo-thread-provider-initial-messages.test.js +0 -278
  467. package/dist/providers/tambo-thread-provider-initial-messages.test.js.map +0 -1
  468. package/dist/providers/tambo-thread-provider.d.ts +0 -126
  469. package/dist/providers/tambo-thread-provider.d.ts.map +0 -1
  470. package/dist/providers/tambo-thread-provider.js +0 -931
  471. package/dist/providers/tambo-thread-provider.js.map +0 -1
  472. package/dist/providers/tambo-thread-provider.test.d.ts +0 -2
  473. package/dist/providers/tambo-thread-provider.test.d.ts.map +0 -1
  474. package/dist/providers/tambo-thread-provider.test.js +0 -1591
  475. package/dist/providers/tambo-thread-provider.test.js.map +0 -1
  476. package/dist/util/generate-component.d.ts +0 -12
  477. package/dist/util/generate-component.d.ts.map +0 -1
  478. package/dist/util/generate-component.js +0 -58
  479. package/dist/util/generate-component.js.map +0 -1
  480. package/dist/util/generate-component.test.d.ts +0 -2
  481. package/dist/util/generate-component.test.d.ts.map +0 -1
  482. package/dist/util/generate-component.test.js +0 -340
  483. package/dist/util/generate-component.test.js.map +0 -1
  484. package/esm/hooks/index.d.ts +0 -9
  485. package/esm/hooks/index.d.ts.map +0 -1
  486. package/esm/hooks/index.js +0 -10
  487. package/esm/hooks/index.js.map +0 -1
  488. package/esm/hooks/use-component-state.d.ts +0 -30
  489. package/esm/hooks/use-component-state.d.ts.map +0 -1
  490. package/esm/hooks/use-component-state.js +0 -136
  491. package/esm/hooks/use-component-state.js.map +0 -1
  492. package/esm/hooks/use-component-state.test.d.ts +0 -2
  493. package/esm/hooks/use-component-state.test.d.ts.map +0 -1
  494. package/esm/hooks/use-component-state.test.js +0 -401
  495. package/esm/hooks/use-component-state.test.js.map +0 -1
  496. package/esm/hooks/use-current-message.d.ts.map +0 -1
  497. package/esm/hooks/use-current-message.js.map +0 -1
  498. package/esm/hooks/use-current-message.test.d.ts +0 -2
  499. package/esm/hooks/use-current-message.test.d.ts.map +0 -1
  500. package/esm/hooks/use-current-message.test.js +0 -264
  501. package/esm/hooks/use-current-message.test.js.map +0 -1
  502. package/esm/hooks/use-streaming-props.d.ts +0 -11
  503. package/esm/hooks/use-streaming-props.d.ts.map +0 -1
  504. package/esm/hooks/use-streaming-props.js +0 -34
  505. package/esm/hooks/use-streaming-props.js.map +0 -1
  506. package/esm/hooks/use-suggestions.d.ts +0 -46
  507. package/esm/hooks/use-suggestions.d.ts.map +0 -1
  508. package/esm/hooks/use-suggestions.js +0 -115
  509. package/esm/hooks/use-suggestions.js.map +0 -1
  510. package/esm/hooks/use-suggestions.test.d.ts +0 -2
  511. package/esm/hooks/use-suggestions.test.d.ts.map +0 -1
  512. package/esm/hooks/use-suggestions.test.js +0 -245
  513. package/esm/hooks/use-suggestions.test.js.map +0 -1
  514. package/esm/hooks/use-tambo-stream-status.d.ts +0 -90
  515. package/esm/hooks/use-tambo-stream-status.d.ts.map +0 -1
  516. package/esm/hooks/use-tambo-stream-status.js +0 -210
  517. package/esm/hooks/use-tambo-stream-status.js.map +0 -1
  518. package/esm/hooks/use-tambo-stream-status.test.d.ts +0 -2
  519. package/esm/hooks/use-tambo-stream-status.test.d.ts.map +0 -1
  520. package/esm/hooks/use-tambo-stream-status.test.js +0 -376
  521. package/esm/hooks/use-tambo-stream-status.test.js.map +0 -1
  522. package/esm/hooks/use-tambo-threads.d.ts +0 -158
  523. package/esm/hooks/use-tambo-threads.d.ts.map +0 -1
  524. package/esm/hooks/use-tambo-threads.js +0 -42
  525. package/esm/hooks/use-tambo-threads.js.map +0 -1
  526. package/esm/hooks/use-tambo-threads.test.d.ts +0 -2
  527. package/esm/hooks/use-tambo-threads.test.d.ts.map +0 -1
  528. package/esm/hooks/use-tambo-threads.test.js +0 -212
  529. package/esm/hooks/use-tambo-threads.test.js.map +0 -1
  530. package/esm/model/generate-component-response.d.ts +0 -37
  531. package/esm/model/generate-component-response.d.ts.map +0 -1
  532. package/esm/model/generate-component-response.js +0 -25
  533. package/esm/model/generate-component-response.js.map +0 -1
  534. package/esm/model/tambo-thread.d.ts +0 -15
  535. package/esm/model/tambo-thread.d.ts.map +0 -1
  536. package/esm/model/tambo-thread.js +0 -2
  537. package/esm/model/tambo-thread.js.map +0 -1
  538. package/esm/providers/__tests__/thread-input-resource-resolution.test.d.ts +0 -2
  539. package/esm/providers/__tests__/thread-input-resource-resolution.test.d.ts.map +0 -1
  540. package/esm/providers/__tests__/thread-input-resource-resolution.test.js +0 -587
  541. package/esm/providers/__tests__/thread-input-resource-resolution.test.js.map +0 -1
  542. package/esm/providers/index.d.ts +0 -13
  543. package/esm/providers/index.d.ts.map +0 -1
  544. package/esm/providers/index.js +0 -11
  545. package/esm/providers/index.js.map +0 -1
  546. package/esm/providers/tambo-component-provider.d.ts +0 -23
  547. package/esm/providers/tambo-component-provider.d.ts.map +0 -1
  548. package/esm/providers/tambo-component-provider.js +0 -50
  549. package/esm/providers/tambo-component-provider.js.map +0 -1
  550. package/esm/providers/tambo-prop-stream-provider/index.d.ts +0 -19
  551. package/esm/providers/tambo-prop-stream-provider/index.d.ts.map +0 -1
  552. package/esm/providers/tambo-prop-stream-provider/index.js +0 -22
  553. package/esm/providers/tambo-prop-stream-provider/index.js.map +0 -1
  554. package/esm/providers/tambo-prop-stream-provider/pending.d.ts +0 -12
  555. package/esm/providers/tambo-prop-stream-provider/pending.d.ts.map +0 -1
  556. package/esm/providers/tambo-prop-stream-provider/pending.js +0 -24
  557. package/esm/providers/tambo-prop-stream-provider/pending.js.map +0 -1
  558. package/esm/providers/tambo-prop-stream-provider/provider.d.ts +0 -17
  559. package/esm/providers/tambo-prop-stream-provider/provider.d.ts.map +0 -1
  560. package/esm/providers/tambo-prop-stream-provider/provider.js +0 -70
  561. package/esm/providers/tambo-prop-stream-provider/provider.js.map +0 -1
  562. package/esm/providers/tambo-prop-stream-provider/streaming.d.ts +0 -12
  563. package/esm/providers/tambo-prop-stream-provider/streaming.d.ts.map +0 -1
  564. package/esm/providers/tambo-prop-stream-provider/streaming.js +0 -21
  565. package/esm/providers/tambo-prop-stream-provider/streaming.js.map +0 -1
  566. package/esm/providers/tambo-prop-stream-provider/success.d.ts +0 -12
  567. package/esm/providers/tambo-prop-stream-provider/success.d.ts.map +0 -1
  568. package/esm/providers/tambo-prop-stream-provider/success.js +0 -21
  569. package/esm/providers/tambo-prop-stream-provider/success.js.map +0 -1
  570. package/esm/providers/tambo-prop-stream-provider/types.d.ts +0 -25
  571. package/esm/providers/tambo-prop-stream-provider/types.d.ts.map +0 -1
  572. package/esm/providers/tambo-prop-stream-provider/types.js +0 -3
  573. package/esm/providers/tambo-prop-stream-provider/types.js.map +0 -1
  574. package/esm/providers/tambo-prop-stream-provider.test.d.ts +0 -2
  575. package/esm/providers/tambo-prop-stream-provider.test.d.ts.map +0 -1
  576. package/esm/providers/tambo-prop-stream-provider.test.js +0 -270
  577. package/esm/providers/tambo-prop-stream-provider.test.js.map +0 -1
  578. package/esm/providers/tambo-provider.d.ts +0 -53
  579. package/esm/providers/tambo-provider.d.ts.map +0 -1
  580. package/esm/providers/tambo-provider.js +0 -94
  581. package/esm/providers/tambo-provider.js.map +0 -1
  582. package/esm/providers/tambo-stubs.d.ts +0 -89
  583. package/esm/providers/tambo-stubs.d.ts.map +0 -1
  584. package/esm/providers/tambo-stubs.js +0 -242
  585. package/esm/providers/tambo-stubs.js.map +0 -1
  586. package/esm/providers/tambo-stubs.test.d.ts +0 -2
  587. package/esm/providers/tambo-stubs.test.d.ts.map +0 -1
  588. package/esm/providers/tambo-stubs.test.js +0 -62
  589. package/esm/providers/tambo-stubs.test.js.map +0 -1
  590. package/esm/providers/tambo-thread-input-provider.d.ts +0 -65
  591. package/esm/providers/tambo-thread-input-provider.d.ts.map +0 -1
  592. package/esm/providers/tambo-thread-input-provider.js +0 -141
  593. package/esm/providers/tambo-thread-input-provider.js.map +0 -1
  594. package/esm/providers/tambo-thread-provider-initial-messages.test.d.ts +0 -2
  595. package/esm/providers/tambo-thread-provider-initial-messages.test.d.ts.map +0 -1
  596. package/esm/providers/tambo-thread-provider-initial-messages.test.js +0 -273
  597. package/esm/providers/tambo-thread-provider-initial-messages.test.js.map +0 -1
  598. package/esm/providers/tambo-thread-provider.d.ts +0 -126
  599. package/esm/providers/tambo-thread-provider.d.ts.map +0 -1
  600. package/esm/providers/tambo-thread-provider.js +0 -891
  601. package/esm/providers/tambo-thread-provider.js.map +0 -1
  602. package/esm/providers/tambo-thread-provider.test.d.ts +0 -2
  603. package/esm/providers/tambo-thread-provider.test.d.ts.map +0 -1
  604. package/esm/providers/tambo-thread-provider.test.js +0 -1553
  605. package/esm/providers/tambo-thread-provider.test.js.map +0 -1
  606. package/esm/util/generate-component.d.ts +0 -12
  607. package/esm/util/generate-component.d.ts.map +0 -1
  608. package/esm/util/generate-component.js +0 -52
  609. package/esm/util/generate-component.js.map +0 -1
  610. package/esm/util/generate-component.test.d.ts +0 -2
  611. package/esm/util/generate-component.test.d.ts.map +0 -1
  612. package/esm/util/generate-component.test.js +0 -302
  613. package/esm/util/generate-component.test.js.map +0 -1
@@ -207,7 +207,7 @@ export type TamboToolStandardSchema<Input extends StandardSchemaV1 = StandardSch
207
207
  * inputSchema and outputSchema with either Standard Schema compliant validators
208
208
  * (like Zod 3.25.76, Zod 4.x) or raw JSON Schema objects.
209
209
  * @deprecated replace `toolSchema` with `inputSchema` and `outputSchema` instead.
210
- * @see {@link https://docs.tambo.co/reference/react-sdk/migration/toolschema}
210
+ * @see {@link https://docs.tambo.co/reference/react-sdk/migration}
211
211
  */
212
212
  export type UnsupportedSchemaTamboTool = Omit<TamboTool, "tool" | "inputSchema" | "outputSchema"> & {
213
213
  /**
@@ -297,7 +297,7 @@ type OptionalSchemaProps<T> = Omit<T, "inputSchema" | "outputSchema"> & {
297
297
  */
298
298
  export interface RegisterToolsFn {
299
299
  /**
300
- * @deprecated Follow the {@link https://docs.tambo.co/reference/react-sdk/migration/toolschema | Migration Guide} to update
300
+ * @deprecated Follow the {@link https://docs.tambo.co/reference/react-sdk/migration | Migration Guide} to update
301
301
  * your tool definitions to use `inputSchema` and `outputSchema` instead.
302
302
  */
303
303
  (tools: UnsupportedSchemaTamboTool[], warnOnOverwrite?: boolean): void;
@@ -328,7 +328,7 @@ export interface RegisterToolFn {
328
328
  (tool: TamboToolUnknown, warnOnOverwrite?: boolean): void;
329
329
  (tool: TamboTool, warnOnOverwrite?: boolean): void;
330
330
  /**
331
- * @deprecated Follow the {@link https://docs.tambo.co/reference/react-sdk/migration/toolschema | Migration Guide} to update
331
+ * @deprecated Follow the {@link https://docs.tambo.co/reference/react-sdk/migration | Migration Guide} to update
332
332
  * your tool definitions to use `inputSchema` and `outputSchema` instead.
333
333
  * @param tool - The unsupported schema Tambo tool to register
334
334
  * @param warnOnOverwrite - Whether to warn if the tool is being overwritten
@@ -341,7 +341,7 @@ export interface RegisterToolFn {
341
341
  */
342
342
  export interface DefineToolFn {
343
343
  /**
344
- * @deprecated Follow the {@link https://docs.tambo.co/reference/react-sdk/migration/toolschema | Migration Guide} to update
344
+ * @deprecated Follow the {@link https://docs.tambo.co/reference/react-sdk/migration | Migration Guide} to update
345
345
  * your tool definitions to use `inputSchema` and `outputSchema` instead.
346
346
  * @param tool The tool definition to register
347
347
  * @returns The registered tool definition
@@ -1 +1 @@
1
- {"version":3,"file":"component-metadata.js","sourceRoot":"","sources":["../../src/model/component-metadata.ts"],"names":[],"mappings":"","sourcesContent":["import type { ToolAnnotations as MCPToolAnnotations } from \"@modelcontextprotocol/sdk/types.js\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport TamboAI from \"@tambo-ai/typescript-sdk\";\nimport { JSONSchema7 } from \"json-schema\";\nimport { ComponentType } from \"react\";\n\n/**\n * A schema type that accepts either a Standard Schema compliant validator\n * (e.g., Zod, Valibot, ArkType) or a raw JSON Schema object.\n *\n * Standard Schema is a specification that provides a unified interface for\n * TypeScript validation libraries. Libraries like Zod implement this spec,\n * allowing us to accept any compliant validator without depending on a specific library.\n * @see https://standardschema.dev/\n */\nexport type SupportedSchema<Input = unknown, Output = Input> =\n | StandardSchemaV1<Input, Output>\n | JSONSchema7;\n\n/**\n * Annotations describing a tool's behavior, aligned with the MCP (Model Context Protocol)\n * specification. These hints help clients understand how tools behave and can be used\n * to optimize tool execution strategies.\n * @see https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations\n */\nexport type ToolAnnotations = MCPToolAnnotations & {\n /**\n * Indicates that the tool is safe to be called repeatedly while a response is\n * being streamed. This is typically used for read-only tools that do not\n * cause side effects.\n */\n tamboStreamableHint?: boolean;\n};\n\n/** Extension of the ToolParameters interface from Tambo AI to include JSONSchema definition */\nexport type ParameterSpec = TamboAI.ToolParameters & {\n schema?: JSONSchema7;\n};\n\n/**\n * Extends the base ContextTool interface from Tambo AI to include schema information\n * for parameter validation.\n */\nexport interface ComponentContextToolMetadata\n extends TamboAI.ComponentContextToolMetadata {\n parameters: ParameterSpec[];\n /**\n * Optional per-tool call limit. When set, this overrides the project's\n * global tool call limit for this specific tool.\n *\n * This is useful for tools that should only be called once or twice\n * regardless of the project's global limit.\n */\n maxCalls?: number;\n /**\n * Annotations describing the tool's behavior. See {@link ToolAnnotations}.\n */\n annotations?: ToolAnnotations;\n}\n\nexport interface ComponentContextTool {\n getComponentContext: (...args: any[]) => Promise<any>;\n definition: ComponentContextToolMetadata;\n}\n\nexport interface RegisteredComponent extends TamboAI.AvailableComponent {\n component: ComponentType<any>;\n loadingComponent?: ComponentType<any>;\n}\n\nexport type ComponentRegistry = Record<string, RegisteredComponent>;\n\nexport type TamboToolRegistry = Record<string, TamboTool>;\n\n/**\n * A JSON Schema that is compatible with the MCP.\n * This is a simplified JSON Schema that is compatible with the MCPClient and the tool's inputSchema.\n *\n * Do not export this type from the SDK.\n */\nexport type JSONSchemaLite = JSONSchema7 & {\n description?: string;\n};\n\ntype MaybeAsync<T> = T | Promise<T>;\n\n/**\n * TamboTool is a type that represents a tool that can be registered with Tambo.\n *\n * It is preferable to use the `defineTool` helper function to create tools, as\n * it provides better type inference and safety.\n * @example\n * ```ts\n * import { TamboTool, defineTool } from \"@tambo-ai/react\";\n * import { z } from \"zod\";\n *\n * const locationToLatLon = defineTool({\n * name: \"location_to_latlon\",\n * description:\n * \"Fetch latitude and longitude from a location string. Returns an object with 'lat' and 'lon' properties.\",\n * tool: async ({ location }) => getLatLonFromLocation(location),\n * inputSchema: z.object({\n * location: z.string(),\n * }),\n * outputSchema: z.object({\n * lat: z.number(),\n * lon: z.number(),\n * }),\n * });\n * ```\n */\nexport interface TamboTool<\n Params = any,\n Returns = any,\n Rest extends any[] = [],\n> {\n /**\n * Unique identifier for the tool\n */\n name: string;\n /**\n * Description of what the tool does - used by AI to determine when to use it\n */\n description: string;\n /**\n * Optional human-readable name of the tool for display purposes.\n */\n title?: string;\n /**\n * Optional limit for how many times this tool may be called while\n * generating a single response. If present, this value overrides the\n * project's global `maxToolCallLimit` for this tool.\n * @example 1\n */\n maxCalls?: number;\n /**\n * Annotations describing the tool's behavior, aligned with the MCP specification.\n * Use `tamboStreamableHint: true` to enable streaming execution of partial tool calls.\n * @see {@link ToolAnnotations}\n * @example\n * ```ts\n * const setTextTool: TamboTool<{ text: string }> = {\n * name: \"set_text\",\n * description: \"Set the displayed text\",\n * annotations: {\n * tamboStreamableHint: true, // tool is safe for streaming calls\n * },\n * tool: ({ text }) => setText(text),\n * inputSchema: z.object({ text: z.string() }),\n * outputSchema: z.void(),\n * };\n * ```\n */\n annotations?: ToolAnnotations;\n\n /**\n * The function that implements the tool's logic. This function will be called\n * by Tambo when the model decides to invoke the tool.\n * @param params - The input parameters for the tool. These are validated\n * against the inputSchema before being passed so are guaranteed to be correct\n * when called by the model.\n * @returns The result of the tool execution, which can be a value or a\n * Promise resolving to a value\n */\n tool: (params: Params, ...rest: Rest) => MaybeAsync<Returns>;\n\n /**\n * The schema for the tool's input parameters. This can be a validator from\n * any Standard Schema compliant library (Zod 3.24+, Zod 4.x) or a\n * raw JSON Schema object.\n *\n * This schema is used to validate and parse the parameters before passing\n * them to the tool function.\n */\n inputSchema: SupportedSchema<Params>;\n\n /**\n * The schema for the tool's output/return value. This can be any Standard Schema\n * compliant validator (Zod 3.24+, Zod 4.x) or a raw JSON Schema object.\n *\n * This is used to inform the model about the structure of the tool's return value\n * and is not used for runtime validation at this stage.\n */\n outputSchema: SupportedSchema<Returns>;\n\n /**\n * Optional function to transform the tool's return value into an array of content parts.\n * If not provided, the return value will be converted to a string and wrapped in a text content part.\n * @param result - The result returned by the tool function\n * @returns An array of content parts to be sent back to the AI\n */\n transformToContent?: (\n result: any,\n ) =>\n | Promise<TamboAI.Beta.Threads.ChatCompletionContentPart[]>\n | TamboAI.Beta.Threads.ChatCompletionContentPart[];\n}\n\n/**\n * A tool that uses JSON Schema compliant input and output schemas.\n * This does not provide type safety for the tool's parameters and return value.\n * @internal\n */\nexport type TamboToolJSONSchema<\n Args extends unknown[] = unknown[],\n Returns = unknown,\n> = Omit<TamboTool<Args, Returns>, \"tool\" | \"inputSchema\" | \"outputSchema\"> & {\n tool: (...args: Args) => MaybeAsync<Returns>;\n inputSchema: JSONSchemaLite;\n outputSchema: JSONSchemaLite;\n};\n\n/**\n * A tool that could not be matched to any known schema types.\n * This means type safety cannot be guaranteed.\n * @internal\n */\nexport type TamboToolUnknown = Omit<\n TamboTool,\n \"tool\" | \"inputSchema\" | \"outputSchema\"\n> & {\n tool: (...args: unknown[]) => MaybeAsync<unknown>;\n inputSchema: SupportedSchema;\n outputSchema: SupportedSchema;\n};\n\n/**\n * A tool that uses Standard Schema compliant input and output schemas.\n * This provides full type safety for the tool's parameters and return value.\n * @internal\n */\nexport type TamboToolStandardSchema<\n Input extends StandardSchemaV1 = StandardSchemaV1,\n Output extends StandardSchemaV1 = StandardSchemaV1,\n> = Omit<\n TamboTool<\n StandardSchemaV1.InferOutput<Input>,\n StandardSchemaV1.InferOutput<Output>\n >,\n \"tool\" | \"inputSchema\" | \"outputSchema\"\n> & {\n tool: (\n ...args: [StandardSchemaV1.InferOutput<Input>]\n ) => MaybeAsync<StandardSchemaV1.InferOutput<Output>>;\n inputSchema: Input;\n outputSchema: Output;\n};\n\n/**\n * If you're seeing this type, it means that you are using a deprecated and now\n * unsupported schema type for defining Tambo tools.\n *\n * Follow the migration guide to update your tool definitions to use\n * inputSchema and outputSchema with either Standard Schema compliant validators\n * (like Zod 3.25.76, Zod 4.x) or raw JSON Schema objects.\n * @deprecated replace `toolSchema` with `inputSchema` and `outputSchema` instead.\n * @see {@link https://docs.tambo.co/reference/react-sdk/migration/toolschema}\n */\nexport type UnsupportedSchemaTamboTool = Omit<\n TamboTool,\n \"tool\" | \"inputSchema\" | \"outputSchema\"\n> & {\n /**\n * @deprecated replace `toolSchema` with `inputSchema` and `outputSchema` instead.\n */\n toolSchema: any;\n tool: (...args: any[]) => MaybeAsync<any>;\n inputSchema?: never;\n outputSchema?: never;\n};\n\nexport type TamboToolAssociations = Record<string, string[]>;\n/**\n * A component that can be registered with the TamboRegistryProvider.\n */\n\nexport interface TamboComponent {\n /** The name of the component */\n name: string;\n /** The description of the component */\n description: string;\n /**\n * The React component to render.\n *\n * Make sure to pass the Component itself, not an instance of the component. For example,\n * if you have a component like this:\n *\n * ```tsx\n * const MyComponent = () => {\n * return <div>My Component</div>;\n * };\n * ```\n *\n * You should pass the `Component`:\n *\n * ```tsx\n * const components = [MyComponent];\n * <TamboRegistryProvider components={components} />\n * ```\n */\n component: ComponentType<any>;\n\n /**\n * Schema describing the component's props. Accepts any Standard Schema\n * compliant validator (Zod, Valibot, ArkType, etc.) or a raw JSON Schema\n * object.\n *\n * Either this or propsDefinition must be provided, but not both.\n * @example\n * ```typescript\n * import { z } from \"zod/v4\";\n *\n * const component: TamboComponent = {\n * name: \"MyComponent\",\n * description: \"A sample component\",\n * component: MyComponent,\n * propsSchema: z.object({\n * title: z.string(),\n * count: z.number().optional()\n * })\n * };\n * ```\n */\n propsSchema?: SupportedSchema;\n /**\n * The props definition of the component as a JSON object.\n * Either this or propsSchema must be provided, but not both.\n * @deprecated Use propsSchema instead.\n */\n propsDefinition?: any;\n /** The loading component to render while the component is loading */\n loadingComponent?: ComponentType<any>;\n /** The tools that are associated with the component */\n associatedTools?: TamboTool[];\n /** Annotations describing the component's behavior. */\n annotations?: ToolAnnotations;\n}\n\ntype OptionalSchemaProps<T> = Omit<T, \"inputSchema\" | \"outputSchema\"> & {\n inputSchema?: T extends { inputSchema: infer I } ? I : never;\n outputSchema?: T extends { outputSchema: infer O } ? O : never;\n};\n\n/**\n * Registers one or more Tambo tools.\n * @param tools - An array of Tambo tools to register\n * @param warnOnOverwrite - Whether to warn if any tool is being overwritten\n */\nexport interface RegisterToolsFn {\n /**\n * @deprecated Follow the {@link https://docs.tambo.co/reference/react-sdk/migration/toolschema | Migration Guide} to update\n * your tool definitions to use `inputSchema` and `outputSchema` instead.\n */\n (tools: UnsupportedSchemaTamboTool[], warnOnOverwrite?: boolean): void;\n /**\n * Register one or more Tambo tools. For better type inference, consider registering tools individually using the\n * `registerTool` function or use the `defineTool` helper when defining your tools.\n * @example\n * ```typescript\n * import { defineTool } from \"@tambo-ai/react\";\n * const tools = [\n * defineTool({...});\n * defineTool({...});\n * ];\n * registerTools(tools);\n * @param tools - An array of Tambo tools to register\n * @param warnOnOverwrite - Whether to warn if any tool is being overwritten\n */\n (tools: TamboTool[], warnOnOverwrite?: boolean): void;\n}\n\n/**\n * Function interface for registering a Tambo tool with full type inference.\n * This function has multiple overloads to handle different schema types. This\n * is a utility function and does not perform any runtime logic.\n */\nexport interface RegisterToolFn {\n <Args extends StandardSchemaV1, Returns extends StandardSchemaV1>(\n tool: TamboToolStandardSchema<Args, Returns>,\n warnOnOverwrite?: boolean,\n ): void;\n <Args extends any[], Returns = any>(\n tool: TamboToolJSONSchema<Args, Returns>,\n warnOnOverwrite?: boolean,\n ): void;\n (tool: TamboToolUnknown, warnOnOverwrite?: boolean): void;\n (tool: TamboTool, warnOnOverwrite?: boolean): void;\n /**\n * @deprecated Follow the {@link https://docs.tambo.co/reference/react-sdk/migration/toolschema | Migration Guide} to update\n * your tool definitions to use `inputSchema` and `outputSchema` instead.\n * @param tool - The unsupported schema Tambo tool to register\n * @param warnOnOverwrite - Whether to warn if the tool is being overwritten\n */\n (tool: UnsupportedSchemaTamboTool, warnOnOverwrite?: boolean): void;\n}\n\n/**\n * Function interface for defining a Tambo tool with full type inference. This function has multiple overloads to handle\n * different schema types. This is a utility function and does not perform any runtime logic.\n */\nexport interface DefineToolFn {\n /**\n * @deprecated Follow the {@link https://docs.tambo.co/reference/react-sdk/migration/toolschema | Migration Guide} to update\n * your tool definitions to use `inputSchema` and `outputSchema` instead.\n * @param tool The tool definition to register\n * @returns The registered tool definition\n */\n (tool: UnsupportedSchemaTamboTool): typeof tool;\n /**\n * Provides type safety for defining a Tambo Tool.\n *\n * Tambo uses the [standard-schema.dev](https://standard-schema.dev) spec which means you can use any Standard Schema\n * compliant validator (Zod 3.24+, Zod 4.x). This definition ensures the input and output types are correctly\n * inferred from the provided schemas.\n * @example\n * ```typescript\n * import { z } from \"zod/v4\";\n *\n * const myTool = defineTool({\n * name: \"myTool\",\n * description: \"An example tool\",\n * inputSchema: z.object({\n * input: z.string().describe(\"Input description\")\n * }),\n * outputSchema: z.number().describe(\"Result description\"),\n * tool: ({ input }) => input.length,\n * });\n * ```\n * @see {@link https://standard-schema.dev/}\n * @param tool The tool definition to register\n * @returns The registered tool definition\n */\n <Input extends StandardSchemaV1, Output extends StandardSchemaV1>(\n tool: OptionalSchemaProps<TamboToolStandardSchema<Input, Output>>,\n ): TamboToolStandardSchema<Input, Output>;\n /**\n * Provides type safety for defining a Tambo Tool with JSON Schema input and output.\n *\n * This overload is used when providing raw JSON Schema objects instead of StandardSchema validators.\n * Type inference is limited when using raw JSON Schema.\n * @see {@link https://standard-schema.dev/}\n * @param tool The tool definition to register\n * @returns The registered tool definition\n */\n <I extends any[], O = any>(\n tool: OptionalSchemaProps<TamboToolJSONSchema<I, O>>,\n ): TamboToolJSONSchema<I, O>;\n /**\n * Provides type safety for defining a Tambo Tool.\n *\n * This overload is used when the schema types could not be matched to known types.\n * Type safety cannot be guaranteed.\n * @param tool The tool definition to register\n * @returns The registered tool definition\n */\n (tool: OptionalSchemaProps<TamboToolUnknown>): TamboToolUnknown;\n /**\n * Provides type safety for defining a Tambo Tool.\n *\n * This overload is used when providing a fully defined TamboTool.\n * @param tool The tool definition to register\n * @returns The registered tool definition\n */\n (tool: OptionalSchemaProps<TamboTool>): TamboTool;\n}\n"]}
1
+ {"version":3,"file":"component-metadata.js","sourceRoot":"","sources":["../../src/model/component-metadata.ts"],"names":[],"mappings":"","sourcesContent":["import type { ToolAnnotations as MCPToolAnnotations } from \"@modelcontextprotocol/sdk/types.js\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport TamboAI from \"@tambo-ai/typescript-sdk\";\nimport { JSONSchema7 } from \"json-schema\";\nimport { ComponentType } from \"react\";\n\n/**\n * A schema type that accepts either a Standard Schema compliant validator\n * (e.g., Zod, Valibot, ArkType) or a raw JSON Schema object.\n *\n * Standard Schema is a specification that provides a unified interface for\n * TypeScript validation libraries. Libraries like Zod implement this spec,\n * allowing us to accept any compliant validator without depending on a specific library.\n * @see https://standardschema.dev/\n */\nexport type SupportedSchema<Input = unknown, Output = Input> =\n | StandardSchemaV1<Input, Output>\n | JSONSchema7;\n\n/**\n * Annotations describing a tool's behavior, aligned with the MCP (Model Context Protocol)\n * specification. These hints help clients understand how tools behave and can be used\n * to optimize tool execution strategies.\n * @see https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations\n */\nexport type ToolAnnotations = MCPToolAnnotations & {\n /**\n * Indicates that the tool is safe to be called repeatedly while a response is\n * being streamed. This is typically used for read-only tools that do not\n * cause side effects.\n */\n tamboStreamableHint?: boolean;\n};\n\n/** Extension of the ToolParameters interface from Tambo AI to include JSONSchema definition */\nexport type ParameterSpec = TamboAI.ToolParameters & {\n schema?: JSONSchema7;\n};\n\n/**\n * Extends the base ContextTool interface from Tambo AI to include schema information\n * for parameter validation.\n */\nexport interface ComponentContextToolMetadata\n extends TamboAI.ComponentContextToolMetadata {\n parameters: ParameterSpec[];\n /**\n * Optional per-tool call limit. When set, this overrides the project's\n * global tool call limit for this specific tool.\n *\n * This is useful for tools that should only be called once or twice\n * regardless of the project's global limit.\n */\n maxCalls?: number;\n /**\n * Annotations describing the tool's behavior. See {@link ToolAnnotations}.\n */\n annotations?: ToolAnnotations;\n}\n\nexport interface ComponentContextTool {\n getComponentContext: (...args: any[]) => Promise<any>;\n definition: ComponentContextToolMetadata;\n}\n\nexport interface RegisteredComponent extends TamboAI.AvailableComponent {\n component: ComponentType<any>;\n loadingComponent?: ComponentType<any>;\n}\n\nexport type ComponentRegistry = Record<string, RegisteredComponent>;\n\nexport type TamboToolRegistry = Record<string, TamboTool>;\n\n/**\n * A JSON Schema that is compatible with the MCP.\n * This is a simplified JSON Schema that is compatible with the MCPClient and the tool's inputSchema.\n *\n * Do not export this type from the SDK.\n */\nexport type JSONSchemaLite = JSONSchema7 & {\n description?: string;\n};\n\ntype MaybeAsync<T> = T | Promise<T>;\n\n/**\n * TamboTool is a type that represents a tool that can be registered with Tambo.\n *\n * It is preferable to use the `defineTool` helper function to create tools, as\n * it provides better type inference and safety.\n * @example\n * ```ts\n * import { TamboTool, defineTool } from \"@tambo-ai/react\";\n * import { z } from \"zod\";\n *\n * const locationToLatLon = defineTool({\n * name: \"location_to_latlon\",\n * description:\n * \"Fetch latitude and longitude from a location string. Returns an object with 'lat' and 'lon' properties.\",\n * tool: async ({ location }) => getLatLonFromLocation(location),\n * inputSchema: z.object({\n * location: z.string(),\n * }),\n * outputSchema: z.object({\n * lat: z.number(),\n * lon: z.number(),\n * }),\n * });\n * ```\n */\nexport interface TamboTool<\n Params = any,\n Returns = any,\n Rest extends any[] = [],\n> {\n /**\n * Unique identifier for the tool\n */\n name: string;\n /**\n * Description of what the tool does - used by AI to determine when to use it\n */\n description: string;\n /**\n * Optional human-readable name of the tool for display purposes.\n */\n title?: string;\n /**\n * Optional limit for how many times this tool may be called while\n * generating a single response. If present, this value overrides the\n * project's global `maxToolCallLimit` for this tool.\n * @example 1\n */\n maxCalls?: number;\n /**\n * Annotations describing the tool's behavior, aligned with the MCP specification.\n * Use `tamboStreamableHint: true` to enable streaming execution of partial tool calls.\n * @see {@link ToolAnnotations}\n * @example\n * ```ts\n * const setTextTool: TamboTool<{ text: string }> = {\n * name: \"set_text\",\n * description: \"Set the displayed text\",\n * annotations: {\n * tamboStreamableHint: true, // tool is safe for streaming calls\n * },\n * tool: ({ text }) => setText(text),\n * inputSchema: z.object({ text: z.string() }),\n * outputSchema: z.void(),\n * };\n * ```\n */\n annotations?: ToolAnnotations;\n\n /**\n * The function that implements the tool's logic. This function will be called\n * by Tambo when the model decides to invoke the tool.\n * @param params - The input parameters for the tool. These are validated\n * against the inputSchema before being passed so are guaranteed to be correct\n * when called by the model.\n * @returns The result of the tool execution, which can be a value or a\n * Promise resolving to a value\n */\n tool: (params: Params, ...rest: Rest) => MaybeAsync<Returns>;\n\n /**\n * The schema for the tool's input parameters. This can be a validator from\n * any Standard Schema compliant library (Zod 3.24+, Zod 4.x) or a\n * raw JSON Schema object.\n *\n * This schema is used to validate and parse the parameters before passing\n * them to the tool function.\n */\n inputSchema: SupportedSchema<Params>;\n\n /**\n * The schema for the tool's output/return value. This can be any Standard Schema\n * compliant validator (Zod 3.24+, Zod 4.x) or a raw JSON Schema object.\n *\n * This is used to inform the model about the structure of the tool's return value\n * and is not used for runtime validation at this stage.\n */\n outputSchema: SupportedSchema<Returns>;\n\n /**\n * Optional function to transform the tool's return value into an array of content parts.\n * If not provided, the return value will be converted to a string and wrapped in a text content part.\n * @param result - The result returned by the tool function\n * @returns An array of content parts to be sent back to the AI\n */\n transformToContent?: (\n result: any,\n ) =>\n | Promise<TamboAI.Beta.Threads.ChatCompletionContentPart[]>\n | TamboAI.Beta.Threads.ChatCompletionContentPart[];\n}\n\n/**\n * A tool that uses JSON Schema compliant input and output schemas.\n * This does not provide type safety for the tool's parameters and return value.\n * @internal\n */\nexport type TamboToolJSONSchema<\n Args extends unknown[] = unknown[],\n Returns = unknown,\n> = Omit<TamboTool<Args, Returns>, \"tool\" | \"inputSchema\" | \"outputSchema\"> & {\n tool: (...args: Args) => MaybeAsync<Returns>;\n inputSchema: JSONSchemaLite;\n outputSchema: JSONSchemaLite;\n};\n\n/**\n * A tool that could not be matched to any known schema types.\n * This means type safety cannot be guaranteed.\n * @internal\n */\nexport type TamboToolUnknown = Omit<\n TamboTool,\n \"tool\" | \"inputSchema\" | \"outputSchema\"\n> & {\n tool: (...args: unknown[]) => MaybeAsync<unknown>;\n inputSchema: SupportedSchema;\n outputSchema: SupportedSchema;\n};\n\n/**\n * A tool that uses Standard Schema compliant input and output schemas.\n * This provides full type safety for the tool's parameters and return value.\n * @internal\n */\nexport type TamboToolStandardSchema<\n Input extends StandardSchemaV1 = StandardSchemaV1,\n Output extends StandardSchemaV1 = StandardSchemaV1,\n> = Omit<\n TamboTool<\n StandardSchemaV1.InferOutput<Input>,\n StandardSchemaV1.InferOutput<Output>\n >,\n \"tool\" | \"inputSchema\" | \"outputSchema\"\n> & {\n tool: (\n ...args: [StandardSchemaV1.InferOutput<Input>]\n ) => MaybeAsync<StandardSchemaV1.InferOutput<Output>>;\n inputSchema: Input;\n outputSchema: Output;\n};\n\n/**\n * If you're seeing this type, it means that you are using a deprecated and now\n * unsupported schema type for defining Tambo tools.\n *\n * Follow the migration guide to update your tool definitions to use\n * inputSchema and outputSchema with either Standard Schema compliant validators\n * (like Zod 3.25.76, Zod 4.x) or raw JSON Schema objects.\n * @deprecated replace `toolSchema` with `inputSchema` and `outputSchema` instead.\n * @see {@link https://docs.tambo.co/reference/react-sdk/migration}\n */\nexport type UnsupportedSchemaTamboTool = Omit<\n TamboTool,\n \"tool\" | \"inputSchema\" | \"outputSchema\"\n> & {\n /**\n * @deprecated replace `toolSchema` with `inputSchema` and `outputSchema` instead.\n */\n toolSchema: any;\n tool: (...args: any[]) => MaybeAsync<any>;\n inputSchema?: never;\n outputSchema?: never;\n};\n\nexport type TamboToolAssociations = Record<string, string[]>;\n/**\n * A component that can be registered with the TamboRegistryProvider.\n */\n\nexport interface TamboComponent {\n /** The name of the component */\n name: string;\n /** The description of the component */\n description: string;\n /**\n * The React component to render.\n *\n * Make sure to pass the Component itself, not an instance of the component. For example,\n * if you have a component like this:\n *\n * ```tsx\n * const MyComponent = () => {\n * return <div>My Component</div>;\n * };\n * ```\n *\n * You should pass the `Component`:\n *\n * ```tsx\n * const components = [MyComponent];\n * <TamboRegistryProvider components={components} />\n * ```\n */\n component: ComponentType<any>;\n\n /**\n * Schema describing the component's props. Accepts any Standard Schema\n * compliant validator (Zod, Valibot, ArkType, etc.) or a raw JSON Schema\n * object.\n *\n * Either this or propsDefinition must be provided, but not both.\n * @example\n * ```typescript\n * import { z } from \"zod/v4\";\n *\n * const component: TamboComponent = {\n * name: \"MyComponent\",\n * description: \"A sample component\",\n * component: MyComponent,\n * propsSchema: z.object({\n * title: z.string(),\n * count: z.number().optional()\n * })\n * };\n * ```\n */\n propsSchema?: SupportedSchema;\n /**\n * The props definition of the component as a JSON object.\n * Either this or propsSchema must be provided, but not both.\n * @deprecated Use propsSchema instead.\n */\n propsDefinition?: any;\n /** The loading component to render while the component is loading */\n loadingComponent?: ComponentType<any>;\n /** The tools that are associated with the component */\n associatedTools?: TamboTool[];\n /** Annotations describing the component's behavior. */\n annotations?: ToolAnnotations;\n}\n\ntype OptionalSchemaProps<T> = Omit<T, \"inputSchema\" | \"outputSchema\"> & {\n inputSchema?: T extends { inputSchema: infer I } ? I : never;\n outputSchema?: T extends { outputSchema: infer O } ? O : never;\n};\n\n/**\n * Registers one or more Tambo tools.\n * @param tools - An array of Tambo tools to register\n * @param warnOnOverwrite - Whether to warn if any tool is being overwritten\n */\nexport interface RegisterToolsFn {\n /**\n * @deprecated Follow the {@link https://docs.tambo.co/reference/react-sdk/migration | Migration Guide} to update\n * your tool definitions to use `inputSchema` and `outputSchema` instead.\n */\n (tools: UnsupportedSchemaTamboTool[], warnOnOverwrite?: boolean): void;\n /**\n * Register one or more Tambo tools. For better type inference, consider registering tools individually using the\n * `registerTool` function or use the `defineTool` helper when defining your tools.\n * @example\n * ```typescript\n * import { defineTool } from \"@tambo-ai/react\";\n * const tools = [\n * defineTool({...});\n * defineTool({...});\n * ];\n * registerTools(tools);\n * @param tools - An array of Tambo tools to register\n * @param warnOnOverwrite - Whether to warn if any tool is being overwritten\n */\n (tools: TamboTool[], warnOnOverwrite?: boolean): void;\n}\n\n/**\n * Function interface for registering a Tambo tool with full type inference.\n * This function has multiple overloads to handle different schema types. This\n * is a utility function and does not perform any runtime logic.\n */\nexport interface RegisterToolFn {\n <Args extends StandardSchemaV1, Returns extends StandardSchemaV1>(\n tool: TamboToolStandardSchema<Args, Returns>,\n warnOnOverwrite?: boolean,\n ): void;\n <Args extends any[], Returns = any>(\n tool: TamboToolJSONSchema<Args, Returns>,\n warnOnOverwrite?: boolean,\n ): void;\n (tool: TamboToolUnknown, warnOnOverwrite?: boolean): void;\n (tool: TamboTool, warnOnOverwrite?: boolean): void;\n /**\n * @deprecated Follow the {@link https://docs.tambo.co/reference/react-sdk/migration | Migration Guide} to update\n * your tool definitions to use `inputSchema` and `outputSchema` instead.\n * @param tool - The unsupported schema Tambo tool to register\n * @param warnOnOverwrite - Whether to warn if the tool is being overwritten\n */\n (tool: UnsupportedSchemaTamboTool, warnOnOverwrite?: boolean): void;\n}\n\n/**\n * Function interface for defining a Tambo tool with full type inference. This function has multiple overloads to handle\n * different schema types. This is a utility function and does not perform any runtime logic.\n */\nexport interface DefineToolFn {\n /**\n * @deprecated Follow the {@link https://docs.tambo.co/reference/react-sdk/migration | Migration Guide} to update\n * your tool definitions to use `inputSchema` and `outputSchema` instead.\n * @param tool The tool definition to register\n * @returns The registered tool definition\n */\n (tool: UnsupportedSchemaTamboTool): typeof tool;\n /**\n * Provides type safety for defining a Tambo Tool.\n *\n * Tambo uses the [standard-schema.dev](https://standard-schema.dev) spec which means you can use any Standard Schema\n * compliant validator (Zod 3.24+, Zod 4.x). This definition ensures the input and output types are correctly\n * inferred from the provided schemas.\n * @example\n * ```typescript\n * import { z } from \"zod/v4\";\n *\n * const myTool = defineTool({\n * name: \"myTool\",\n * description: \"An example tool\",\n * inputSchema: z.object({\n * input: z.string().describe(\"Input description\")\n * }),\n * outputSchema: z.number().describe(\"Result description\"),\n * tool: ({ input }) => input.length,\n * });\n * ```\n * @see {@link https://standard-schema.dev/}\n * @param tool The tool definition to register\n * @returns The registered tool definition\n */\n <Input extends StandardSchemaV1, Output extends StandardSchemaV1>(\n tool: OptionalSchemaProps<TamboToolStandardSchema<Input, Output>>,\n ): TamboToolStandardSchema<Input, Output>;\n /**\n * Provides type safety for defining a Tambo Tool with JSON Schema input and output.\n *\n * This overload is used when providing raw JSON Schema objects instead of StandardSchema validators.\n * Type inference is limited when using raw JSON Schema.\n * @see {@link https://standard-schema.dev/}\n * @param tool The tool definition to register\n * @returns The registered tool definition\n */\n <I extends any[], O = any>(\n tool: OptionalSchemaProps<TamboToolJSONSchema<I, O>>,\n ): TamboToolJSONSchema<I, O>;\n /**\n * Provides type safety for defining a Tambo Tool.\n *\n * This overload is used when the schema types could not be matched to known types.\n * Type safety cannot be guaranteed.\n * @param tool The tool definition to register\n * @returns The registered tool definition\n */\n (tool: OptionalSchemaProps<TamboToolUnknown>): TamboToolUnknown;\n /**\n * Provides type safety for defining a Tambo Tool.\n *\n * This overload is used when providing a fully defined TamboTool.\n * @param tool The tool definition to register\n * @returns The registered tool definition\n */\n (tool: OptionalSchemaProps<TamboTool>): TamboTool;\n}\n"]}
@@ -27,6 +27,11 @@ export interface TamboClientProviderProps {
27
27
  * These will be merged with the default headers.
28
28
  */
29
29
  additionalHeaders?: Record<string, string>;
30
+ /**
31
+ * User key sent as a default query parameter on all API requests.
32
+ * Required if no bearer token (userToken) is provided.
33
+ */
34
+ userKey?: string;
30
35
  }
31
36
  export interface TamboClientContextProps {
32
37
  /** The TamboAI client */
@@ -55,6 +60,7 @@ export declare const TamboClientContext: React.Context<TamboClientContextProps |
55
60
  * @param props.environment - The environment to use for the Tambo API
56
61
  * @param props.userToken - The oauth access token to use to identify the user in the Tambo API
57
62
  * @param props.additionalHeaders - Additional headers to include in all requests
63
+ * @param props.userKey - User key sent as a default query parameter on all API requests
58
64
  * @returns The TamboClientProvider component
59
65
  */
60
66
  export declare const TamboClientProvider: React.FC<PropsWithChildren<TamboClientProviderProps>>;
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-client-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-client-provider.tsx"],"names":[],"mappings":"AACA,OAAO,OAA0B,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,EAAiB,iBAAiB,EAAW,MAAM,OAAO,CAAC;AAIzE,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,WAAW,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;IAEvC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5C;AAED,MAAM,WAAW,uBAAuB;IACtC,yBAAyB;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,sCAAsC;IACtC,WAAW,EAAE,WAAW,CAAC;IACzB,2DAA2D;IAC3D,eAAe,EAAE,OAAO,CAAC;IACzB,oDAAoD;IACpD,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,wCAAwC;IACxC,kBAAkB,EAAE,KAAK,GAAG,IAAI,CAAC;IACjC,qDAAqD;IACrD,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,2CAA2C;IAC3C,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,eAAO,MAAM,kBAAkB,oDAEnB,CAAC;AAEb;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CACxC,iBAAiB,CAAC,wBAAwB,CAAC,CAgD5C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,eAM1B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,mBAQ/B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,uBAAuB,eAQnC,CAAC"}
1
+ {"version":3,"file":"tambo-client-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-client-provider.tsx"],"names":[],"mappings":"AACA,OAAO,OAA0B,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,EAAiB,iBAAiB,EAAW,MAAM,OAAO,CAAC;AAIzE,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,WAAW,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;IAEvC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE3C;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,uBAAuB;IACtC,yBAAyB;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,sCAAsC;IACtC,WAAW,EAAE,WAAW,CAAC;IACzB,2DAA2D;IAC3D,eAAe,EAAE,OAAO,CAAC;IACzB,oDAAoD;IACpD,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,wCAAwC;IACxC,kBAAkB,EAAE,KAAK,GAAG,IAAI,CAAC;IACjC,qDAAqD;IACrD,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,2CAA2C;IAC3C,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,eAAO,MAAM,kBAAkB,oDAEnB,CAAC;AAEb;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CACxC,iBAAiB,CAAC,wBAAwB,CAAC,CAkD5C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,eAM1B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,mBAQ/B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,uBAAuB,eAQnC,CAAC"}
@@ -54,18 +54,20 @@ exports.TamboClientContext = (0, react_1.createContext)(undefined);
54
54
  * @param props.environment - The environment to use for the Tambo API
55
55
  * @param props.userToken - The oauth access token to use to identify the user in the Tambo API
56
56
  * @param props.additionalHeaders - Additional headers to include in all requests
57
+ * @param props.userKey - User key sent as a default query parameter on all API requests
57
58
  * @returns The TamboClientProvider component
58
59
  */
59
- const TamboClientProvider = ({ children, tamboUrl, apiKey, environment, userToken, additionalHeaders, }) => {
60
+ const TamboClientProvider = ({ children, tamboUrl, apiKey, environment, userToken, additionalHeaders, userKey, }) => {
60
61
  const tamboConfig = (0, react_1.useMemo)(() => ({
61
62
  apiKey,
62
63
  defaultHeaders: {
63
64
  "X-Tambo-React-Version": package_json_1.default.version,
64
65
  ...additionalHeaders,
65
66
  },
67
+ defaultQuery: userKey ? { userKey } : undefined,
66
68
  baseURL: tamboUrl ?? undefined,
67
69
  environment: environment ?? undefined,
68
- }), [additionalHeaders, apiKey, tamboUrl, environment]);
70
+ }), [additionalHeaders, apiKey, tamboUrl, environment, userKey]);
69
71
  const client = (0, react_1.useMemo)(() => new typescript_sdk_1.default(tamboConfig), [tamboConfig]);
70
72
  const queryClient = (0, react_1.useMemo)(() => new react_query_1.QueryClient(), []);
71
73
  // Keep the session token updated and get the updating state
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-client-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-client-provider.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACb,8EAAkE;AAClE,uDAAoD;AACpD,+CAAyE;AACzE,sEAA6C;AAC7C,6EAAuE;AA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AC;AAjDW,QAAA,mBAAmB,uBAiD9B;AAEF;;;;GAIG;AACI,MAAM,cAAc,GAAG,GAAG,EAAE;IACjC,MAAM,OAAO,GAAG,eAAK,CAAC,UAAU,CAAC,0BAAkB,CAAC,CAAC;IACrD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;IAC9E,CAAC;IACD,OAAO,OAAO,CAAC,MAAM,CAAC;AACxB,CAAC,CAAC;AANW,QAAA,cAAc,kBAMzB;AAEF;;;;;GAKG;AACI,MAAM,mBAAmB,GAAG,GAAG,EAAE;IACtC,MAAM,OAAO,GAAG,eAAK,CAAC,UAAU,CAAC,0BAAkB,CAAC,CAAC;IACrD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CACb,+DAA+D,CAChE,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC,WAAW,CAAC;AAC7B,CAAC,CAAC;AARW,QAAA,mBAAmB,uBAQ9B;AAEF;;;GAGG;AACI,MAAM,uBAAuB,GAAG,GAAG,EAAE;IAC1C,MAAM,OAAO,GAAG,eAAK,CAAC,UAAU,CAAC,0BAAkB,CAAC,CAAC;IACrD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CACb,mEAAmE,CACpE,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC,eAAe,CAAC;AACjC,CAAC,CAAC;AARW,QAAA,uBAAuB,2BAQlC","sourcesContent":["\"use client\";\nimport TamboAI, { ClientOptions } from \"@tambo-ai/typescript-sdk\";\nimport { QueryClient } from \"@tanstack/react-query\";\nimport React, { createContext, PropsWithChildren, useMemo } from \"react\";\nimport packageJson from \"../../package.json\";\nimport { useTamboSessionToken } from \"./hooks/use-tambo-session-token\";\n\nexport interface TamboClientProviderProps {\n /**\n * The URL of the Tambo API (only used for local development and debugging)\n */\n tamboUrl?: string;\n /**\n * The API key for the Tambo API. This typically comes from a variable like\n * `process.env.NEXT_PUBLIC_TAMBO_API_KEY`\n */\n apiKey: string;\n /**\n * The environment to use for the Tambo API\n */\n environment?: \"production\" | \"staging\";\n\n /**\n * The user token to use to identify the user in the Tambo API. This token is\n * a 3rd party token like a Google or GitHub access token, exchanged with the\n * Tambo API to get a session token. This is used to securely identify the\n * user when calling the Tambo API.\n */\n userToken?: string;\n\n /**\n * Additional headers to include in all requests to the Tambo API.\n * These will be merged with the default headers.\n */\n additionalHeaders?: Record<string, string>;\n}\n\nexport interface TamboClientContextProps {\n /** The TamboAI client */\n client: TamboAI;\n /** The tambo-specific query client */\n queryClient: QueryClient;\n /** Whether the session token is currently being updated */\n isUpdatingToken: boolean;\n /** Additional headers to include in all requests */\n additionalHeaders?: Record<string, string>;\n /** Error from token exchange, if any */\n tokenExchangeError: Error | null;\n /** The raw userToken value passed to the provider */\n userToken: string | undefined;\n /** Whether the token exchange succeeded */\n hasValidToken: boolean;\n}\n\nexport const TamboClientContext = createContext<\n TamboClientContextProps | undefined\n>(undefined);\n\n/**\n * The TamboClientProvider is a React provider that provides a TamboAI client\n * and a query client to the descendants of the provider.\n * @param props - The props for the TamboClientProvider\n * @param props.children - The children to wrap\n * @param props.tamboUrl - The URL of the Tambo API\n * @param props.apiKey - The API key for the Tambo API\n * @param props.environment - The environment to use for the Tambo API\n * @param props.userToken - The oauth access token to use to identify the user in the Tambo API\n * @param props.additionalHeaders - Additional headers to include in all requests\n * @returns The TamboClientProvider component\n */\nexport const TamboClientProvider: React.FC<\n PropsWithChildren<TamboClientProviderProps>\n> = ({\n children,\n tamboUrl,\n apiKey,\n environment,\n userToken,\n additionalHeaders,\n}) => {\n const tamboConfig = useMemo(\n () =>\n ({\n apiKey,\n defaultHeaders: {\n \"X-Tambo-React-Version\": packageJson.version,\n ...additionalHeaders,\n },\n baseURL: tamboUrl ?? undefined,\n environment: environment ?? undefined,\n }) satisfies ClientOptions,\n [additionalHeaders, apiKey, tamboUrl, environment],\n );\n\n const client = useMemo(() => new TamboAI(tamboConfig), [tamboConfig]);\n const queryClient = useMemo(() => new QueryClient(), []);\n\n // Keep the session token updated and get the updating state\n const {\n isFetching: isUpdatingToken,\n error: tokenExchangeError,\n data: tokenData,\n } = useTamboSessionToken(client, queryClient, userToken);\n\n return (\n <TamboClientContext.Provider\n value={{\n client,\n queryClient,\n isUpdatingToken,\n additionalHeaders: tamboConfig.defaultHeaders,\n tokenExchangeError: tokenExchangeError ?? null,\n userToken,\n hasValidToken: !!tokenData?.access_token,\n }}\n >\n {children}\n </TamboClientContext.Provider>\n );\n};\n\n/**\n * The useTamboClient hook provides access to the TamboAI client\n * to the descendants of the TamboClientProvider.\n * @returns The TamboAI client\n */\nexport const useTamboClient = () => {\n const context = React.useContext(TamboClientContext);\n if (context === undefined) {\n throw new Error(\"useTamboClient must be used within a TamboClientProvider\");\n }\n return context.client;\n};\n\n/**\n * The useTamboQueryClient hook provides access to the tambo-specific query client\n * to the descendants of the TamboClientProvider.\n * @returns The tambo-specific query client\n * @private\n */\nexport const useTamboQueryClient = () => {\n const context = React.useContext(TamboClientContext);\n if (context === undefined) {\n throw new Error(\n \"useTamboQueryClient must be used within a TamboClientProvider\",\n );\n }\n return context.queryClient;\n};\n\n/**\n * Hook to check if the session token is currently being updated\n * @returns true if the token is being refreshed, false otherwise\n */\nexport const useIsTamboTokenUpdating = () => {\n const context = React.useContext(TamboClientContext);\n if (context === undefined) {\n throw new Error(\n \"useIsTamboTokenUpdating must be used within a TamboClientProvider\",\n );\n }\n return context.isUpdatingToken;\n};\n"]}
1
+ {"version":3,"file":"tambo-client-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-client-provider.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACb,8EAAkE;AAClE,uDAAoD;AACpD,+CAAyE;AACzE,sEAA6C;AAC7C,6EAAuE;AAuD1D,QAAA,kBAAkB,GAAG,IAAA,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,CAAC,SAAS,EAAE,YAAY;SACzC,IAEA,QAAQ,CACmB,CAC/B,CAAC;AACJ,CAAC,CAAC;AAnDW,QAAA,mBAAmB,uBAmD9B;AAEF;;;;GAIG;AACI,MAAM,cAAc,GAAG,GAAG,EAAE;IACjC,MAAM,OAAO,GAAG,eAAK,CAAC,UAAU,CAAC,0BAAkB,CAAC,CAAC;IACrD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;IAC9E,CAAC;IACD,OAAO,OAAO,CAAC,MAAM,CAAC;AACxB,CAAC,CAAC;AANW,QAAA,cAAc,kBAMzB;AAEF;;;;;GAKG;AACI,MAAM,mBAAmB,GAAG,GAAG,EAAE;IACtC,MAAM,OAAO,GAAG,eAAK,CAAC,UAAU,CAAC,0BAAkB,CAAC,CAAC;IACrD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CACb,+DAA+D,CAChE,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC,WAAW,CAAC;AAC7B,CAAC,CAAC;AARW,QAAA,mBAAmB,uBAQ9B;AAEF;;;GAGG;AACI,MAAM,uBAAuB,GAAG,GAAG,EAAE;IAC1C,MAAM,OAAO,GAAG,eAAK,CAAC,UAAU,CAAC,0BAAkB,CAAC,CAAC;IACrD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CACb,mEAAmE,CACpE,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC,eAAe,CAAC;AACjC,CAAC,CAAC;AARW,QAAA,uBAAuB,2BAQlC","sourcesContent":["\"use client\";\nimport TamboAI, { ClientOptions } from \"@tambo-ai/typescript-sdk\";\nimport { QueryClient } from \"@tanstack/react-query\";\nimport React, { createContext, PropsWithChildren, useMemo } from \"react\";\nimport packageJson from \"../../package.json\";\nimport { useTamboSessionToken } from \"./hooks/use-tambo-session-token\";\n\nexport interface TamboClientProviderProps {\n /**\n * The URL of the Tambo API (only used for local development and debugging)\n */\n tamboUrl?: string;\n /**\n * The API key for the Tambo API. This typically comes from a variable like\n * `process.env.NEXT_PUBLIC_TAMBO_API_KEY`\n */\n apiKey: string;\n /**\n * The environment to use for the Tambo API\n */\n environment?: \"production\" | \"staging\";\n\n /**\n * The user token to use to identify the user in the Tambo API. This token is\n * a 3rd party token like a Google or GitHub access token, exchanged with the\n * Tambo API to get a session token. This is used to securely identify the\n * user when calling the Tambo API.\n */\n userToken?: string;\n\n /**\n * Additional headers to include in all requests to the Tambo API.\n * These will be merged with the default headers.\n */\n additionalHeaders?: Record<string, string>;\n\n /**\n * User key sent as a default query parameter on all API requests.\n * Required if no bearer token (userToken) is provided.\n */\n userKey?: string;\n}\n\nexport interface TamboClientContextProps {\n /** The TamboAI client */\n client: TamboAI;\n /** The tambo-specific query client */\n queryClient: QueryClient;\n /** Whether the session token is currently being updated */\n isUpdatingToken: boolean;\n /** Additional headers to include in all requests */\n additionalHeaders?: Record<string, string>;\n /** Error from token exchange, if any */\n tokenExchangeError: Error | null;\n /** The raw userToken value passed to the provider */\n userToken: string | undefined;\n /** Whether the token exchange succeeded */\n hasValidToken: boolean;\n}\n\nexport const TamboClientContext = createContext<\n TamboClientContextProps | undefined\n>(undefined);\n\n/**\n * The TamboClientProvider is a React provider that provides a TamboAI client\n * and a query client to the descendants of the provider.\n * @param props - The props for the TamboClientProvider\n * @param props.children - The children to wrap\n * @param props.tamboUrl - The URL of the Tambo API\n * @param props.apiKey - The API key for the Tambo API\n * @param props.environment - The environment to use for the Tambo API\n * @param props.userToken - The oauth access token to use to identify the user in the Tambo API\n * @param props.additionalHeaders - Additional headers to include in all requests\n * @param props.userKey - User key sent as a default query parameter on all API requests\n * @returns The TamboClientProvider component\n */\nexport const TamboClientProvider: React.FC<\n PropsWithChildren<TamboClientProviderProps>\n> = ({\n children,\n tamboUrl,\n apiKey,\n environment,\n userToken,\n additionalHeaders,\n userKey,\n}) => {\n const tamboConfig = useMemo(\n () =>\n ({\n apiKey,\n defaultHeaders: {\n \"X-Tambo-React-Version\": packageJson.version,\n ...additionalHeaders,\n },\n defaultQuery: userKey ? { userKey } : undefined,\n baseURL: tamboUrl ?? undefined,\n environment: environment ?? undefined,\n }) satisfies ClientOptions,\n [additionalHeaders, apiKey, tamboUrl, environment, userKey],\n );\n\n const client = useMemo(() => new TamboAI(tamboConfig), [tamboConfig]);\n const queryClient = useMemo(() => new QueryClient(), []);\n\n // Keep the session token updated and get the updating state\n const {\n isFetching: isUpdatingToken,\n error: tokenExchangeError,\n data: tokenData,\n } = useTamboSessionToken(client, queryClient, userToken);\n\n return (\n <TamboClientContext.Provider\n value={{\n client,\n queryClient,\n isUpdatingToken,\n additionalHeaders: tamboConfig.defaultHeaders,\n tokenExchangeError: tokenExchangeError ?? null,\n userToken,\n hasValidToken: !!tokenData?.access_token,\n }}\n >\n {children}\n </TamboClientContext.Provider>\n );\n};\n\n/**\n * The useTamboClient hook provides access to the TamboAI client\n * to the descendants of the TamboClientProvider.\n * @returns The TamboAI client\n */\nexport const useTamboClient = () => {\n const context = React.useContext(TamboClientContext);\n if (context === undefined) {\n throw new Error(\"useTamboClient must be used within a TamboClientProvider\");\n }\n return context.client;\n};\n\n/**\n * The useTamboQueryClient hook provides access to the tambo-specific query client\n * to the descendants of the TamboClientProvider.\n * @returns The tambo-specific query client\n * @private\n */\nexport const useTamboQueryClient = () => {\n const context = React.useContext(TamboClientContext);\n if (context === undefined) {\n throw new Error(\n \"useTamboQueryClient must be used within a TamboClientProvider\",\n );\n }\n return context.queryClient;\n};\n\n/**\n * Hook to check if the session token is currently being updated\n * @returns true if the token is being refreshed, false otherwise\n */\nexport const useIsTamboTokenUpdating = () => {\n const context = React.useContext(TamboClientContext);\n if (context === undefined) {\n throw new Error(\n \"useIsTamboTokenUpdating must be used within a TamboClientProvider\",\n );\n }\n return context.isUpdatingToken;\n};\n"]}
@@ -36,7 +36,7 @@ export declare const useCurrentInteractablesSnapshot: () => {
36
36
  propsSchema?: import("../schema").SupportedSchema;
37
37
  propsDefinition?: any;
38
38
  loadingComponent?: React.ComponentType<any>;
39
- associatedTools?: import(".").TamboTool[];
39
+ associatedTools?: import("..").TamboTool[];
40
40
  annotations?: import("..").ToolAnnotations;
41
41
  }[];
42
42
  export {};
@@ -9,17 +9,9 @@ const v4_1 = require("zod/v4");
9
9
  const with_tambo_interactable_1 = require("../hoc/with-tambo-interactable");
10
10
  const tambo_context_helpers_provider_1 = require("./tambo-context-helpers-provider");
11
11
  const tambo_interactable_provider_1 = require("./tambo-interactable-provider");
12
- const tambo_stubs_1 = require("./tambo-stubs");
12
+ const tambo_v1_stub_provider_1 = require("../v1/providers/tambo-v1-stub-provider");
13
13
  function wrapperWithProviders(children) {
14
- const thread = {
15
- id: "t-1",
16
- projectId: "p-1",
17
- createdAt: new Date().toISOString(),
18
- updatedAt: new Date().toISOString(),
19
- messages: [],
20
- metadata: {},
21
- };
22
- return (react_2.default.createElement(tambo_stubs_1.TamboStubProvider, { thread: thread, registerTool: () => { }, registerTools: () => { }, registerComponent: () => { }, addToolAssociation: () => { } },
14
+ return (react_2.default.createElement(tambo_v1_stub_provider_1.TamboStubProvider, null,
23
15
  react_2.default.createElement(tambo_context_helpers_provider_1.TamboContextHelpersProvider, null, children)));
24
16
  }
25
17
  describe("Interactables AdditionalContext - Edge Cases & Advanced Scenarios", () => {
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-interactables-additional-context-edge-cases.test.js","sourceRoot":"","sources":["../../src/providers/tambo-interactables-additional-context-edge-cases.test.tsx"],"names":[],"mappings":";;;;;AAAA,kDAAyD;AACzD,kDAA0B;AAC1B,+BAA2B;AAC3B,4EAAuE;AACvE,qFAG0C;AAC1C,+EAA0E;AAC1E,+CAAkD;AAElD,SAAS,oBAAoB,CAAC,QAAyB;IACrD,MAAM,MAAM,GAAG;QACb,EAAE,EAAE,KAAK;QACT,SAAS,EAAE,KAAK;QAChB,SAAS,EAAE,IAA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AE,CAAC;YAE5B,oDAAoD;YACpD,MAAM,UAAU,GAAG,gBAAgB,CAAC,IAAI,CACtC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,aAAa,CACrC,CAAC;YACF,MAAM,CAAC,UAAU,CAAC,CAAC,aAAa,EAAE,CAAC;QACrC,CAAC,CAAC,CAAC;QAEH,UAAU,CAAC,WAAW,EAAE,CAAC;IAC3B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { render, waitFor } from \"@testing-library/react\";\nimport React from \"react\";\nimport { z } from \"zod/v4\";\nimport { withTamboInteractable } from \"../hoc/with-tambo-interactable\";\nimport {\n TamboContextHelpersProvider,\n useTamboContextHelpers,\n} from \"./tambo-context-helpers-provider\";\nimport { TamboInteractableProvider } from \"./tambo-interactable-provider\";\nimport { TamboStubProvider } from \"./tambo-stubs\";\n\nfunction wrapperWithProviders(children: React.ReactNode) {\n const thread = {\n id: \"t-1\",\n projectId: \"p-1\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n messages: [],\n metadata: {},\n } as any;\n\n return (\n <TamboStubProvider\n thread={thread}\n registerTool={() => {}}\n registerTools={() => {}}\n registerComponent={() => {}}\n addToolAssociation={() => {}}\n >\n <TamboContextHelpersProvider>{children}</TamboContextHelpersProvider>\n </TamboStubProvider>\n );\n}\n\ndescribe(\"Interactables AdditionalContext - Edge Cases & Advanced Scenarios\", () => {\n test(\"handles components without propsSchema gracefully\", async () => {\n const SimpleComponent: React.FC<{ text: string }> = ({ text }) => (\n <div>{text}</div>\n );\n\n const InteractableSimpleComponent = withTamboInteractable(SimpleComponent, {\n componentName: \"SimpleComponent\",\n description: \"A component without schema\",\n // No propsSchema provided\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableSimpleComponent text=\"test\" />\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry).toBeDefined();\n const component = entry!.context.components[0];\n expect(component.propsSchema).toBe(\"Not specified\");\n });\n });\n\n test(\"handles component unmounting and remounting correctly\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n const interval = setInterval(() => {\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n }, 50);\n return () => {\n mounted = false;\n clearInterval(interval);\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const Host = () => {\n const [showNote, setShowNote] = React.useState(true);\n\n React.useEffect(() => {\n // Toggle the note on/off to test unmounting\n const timeout = setTimeout(() => setShowNote(false), 100);\n const timeout2 = setTimeout(() => setShowNote(true), 200);\n return () => {\n clearTimeout(timeout);\n clearTimeout(timeout2);\n };\n }, []);\n\n return (\n <TamboInteractableProvider>\n {showNote && <InteractableNote title=\"dynamic note\" />}\n <TestComponent />\n </TamboInteractableProvider>\n );\n };\n\n const { getByTestId } = render(wrapperWithProviders(<Host />));\n\n await waitFor(\n () => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n },\n { timeout: 1000 },\n );\n\n // Eventually should show the note again\n await waitFor(\n () => {\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry?.context?.components).toHaveLength(1);\n },\n { timeout: 1000 },\n );\n });\n\n test(\"context helper updates when props change from parent\", async () => {\n const Counter: React.FC<{ count: number; label?: string }> = ({\n count,\n label = \"Count\",\n }) => (\n <div>\n {label}: {count}\n </div>\n );\n\n const InteractableCounter = withTamboInteractable(Counter, {\n componentName: \"Counter\",\n description: \"A counter component\",\n propsSchema: z.object({\n count: z.number(),\n label: z.string().optional(),\n }),\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n const interval = setInterval(() => {\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n }, 50);\n return () => {\n mounted = false;\n clearInterval(interval);\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const Host = () => {\n const [count, setCount] = React.useState(0);\n const [label, setLabel] = React.useState(\"Items\");\n\n React.useEffect(() => {\n const timeout1 = setTimeout(() => setCount(5), 100);\n const timeout2 = setTimeout(() => setLabel(\"Updated Items\"), 200);\n return () => {\n clearTimeout(timeout1);\n clearTimeout(timeout2);\n };\n }, []);\n\n return (\n <TamboInteractableProvider>\n <InteractableCounter count={count} label={label} />\n <TestComponent />\n </TamboInteractableProvider>\n );\n };\n\n const { getByTestId } = render(wrapperWithProviders(<Host />));\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n });\n\n // Wait for updates to propagate\n await waitFor(\n () => {\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n if (entry?.context?.components?.[0]) {\n const props = entry.context.components[0].props;\n expect(props.count).toBe(5);\n expect(props.label).toBe(\"Updated Items\");\n }\n },\n { timeout: 1000 },\n );\n });\n\n test(\"multiple providers with nested context helpers work correctly\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n let outerContexts: any[] = [];\n let innerContexts: any[] = [];\n\n const OuterTestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n outerContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"outer-ready\">outer ready</div>;\n };\n\n const InnerTestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n innerContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"inner-ready\">inner ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableNote title=\"outer note\" />\n <OuterTestComponent />\n <TamboContextHelpersProvider\n contextHelpers={{\n customContext: () => ({ custom: \"inner\" }),\n }}\n >\n <TamboInteractableProvider>\n <InteractableNote title=\"inner note\" />\n <InnerTestComponent />\n </TamboInteractableProvider>\n </TamboContextHelpersProvider>\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"outer-ready\")).toBeInTheDocument();\n expect(getByTestId(\"inner-ready\")).toBeInTheDocument();\n });\n\n await waitFor(() => {\n // Outer context should have outer note\n const outerEntry = outerContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(outerEntry?.context?.components).toHaveLength(1);\n expect(outerEntry?.context?.components[0]?.props?.title).toBe(\n \"outer note\",\n );\n\n // Inner context should have inner note and custom context\n const innerEntry = innerContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(innerEntry?.context?.components).toHaveLength(1);\n expect(innerEntry?.context?.components[0]?.props?.title).toBe(\n \"inner note\",\n );\n\n const customEntry = innerContexts.find(\n (c: any) => c.name === \"customContext\",\n );\n expect(customEntry?.context).toEqual({ custom: \"inner\" });\n });\n });\n\n test(\"provider cleanup removes helper when last provider unmounts\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n const interval = setInterval(() => {\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n }, 50);\n return () => {\n mounted = false;\n clearInterval(interval);\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const Host = () => {\n const [showProvider, setShowProvider] = React.useState(true);\n\n React.useEffect(() => {\n const timeout = setTimeout(() => setShowProvider(false), 200);\n return () => clearTimeout(timeout);\n }, []);\n\n return (\n <>\n {showProvider && (\n <TamboInteractableProvider>\n <InteractableNote title=\"will disappear\" />\n </TamboInteractableProvider>\n )}\n <TestComponent />\n </>\n );\n };\n\n const { getByTestId } = render(wrapperWithProviders(<Host />));\n\n // Initially should have the context\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry).toBeDefined();\n });\n\n // After provider unmounts, context should be gone\n await waitFor(\n () => {\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry).toBeUndefined();\n },\n { timeout: 1000 },\n );\n });\n\n test(\"helper error handling doesn't crash the system\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n // Mock console.error to capture error logs\n const consoleSpy = jest\n .spyOn(console, \"error\")\n .mockImplementation(() => {});\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext, addContextHelper } =\n useTamboContextHelpers();\n\n React.useEffect(() => {\n // Add a helper that throws an error\n addContextHelper(\"errorHelper\", () => {\n throw new Error(\"Test error in helper\");\n });\n }, [addContextHelper]);\n\n React.useEffect(() => {\n let mounted = true;\n getAdditionalContext()\n .then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n })\n .catch(() => {\n // Should not reach here - errors should be handled gracefully\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableNote title=\"test\" />\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n // Should still have the interactables context despite the error\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry).toBeDefined();\n\n // Error helper should not be present (filtered out)\n const errorEntry = capturedContexts.find(\n (c: any) => c.name === \"errorHelper\",\n );\n expect(errorEntry).toBeUndefined();\n });\n\n consoleSpy.mockRestore();\n });\n});\n"]}
1
+ {"version":3,"file":"tambo-interactables-additional-context-edge-cases.test.js","sourceRoot":"","sources":["../../src/providers/tambo-interactables-additional-context-edge-cases.test.tsx"],"names":[],"mappings":";;;;;AAAA,kDAAyD;AACzD,kDAA0B;AAC1B,+BAA2B;AAC3B,4EAAuE;AACvE,qFAG0C;AAC1C,+EAA0E;AAC1E,mFAA2E;AAE3E,SAAS,oBAAoB,CAAC,QAAyB;IACrD,OAAO,CACL,8BAAC,0CAAiB;QAChB,8BAAC,4DAA2B,QAAE,QAAQ,CAA+B,CACnD,CACrB,CAAC;AACJ,CAAC;AAED,QAAQ,CAAC,mEAAmE,EAAE,GAAG,EAAE;IACjF,IAAI,CAAC,mDAAmD,EAAE,KAAK,IAAI,EAAE;QACnE,MAAM,eAAe,GAA+B,CAAC,EAAE,IAAI,EA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oBACV,OAAO,GAAG,KAAK,CAAC;gBAClB,CAAC,CAAC;YACJ,CAAC,EAAE,CAAC,oBAAoB,CAAC,CAAC,CAAC;YAE3B,OAAO,sDAAiB,OAAO,YAAY,CAAC;QAC9C,CAAC,CAAC;QAEF,MAAM,EAAE,WAAW,EAAE,GAAG,IAAA,cAAM,EAC5B,oBAAoB,CAClB,8BAAC,uDAAyB;YACxB,8BAAC,gBAAgB,IAAC,KAAK,EAAC,MAAM,GAAG;YACjC,8BAAC,aAAa,OAAG,CACS,CAC7B,CACF,CAAC;QAEF,MAAM,IAAA,eAAO,EAAC,GAAG,EAAE;YACjB,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;YACjD,gEAAgE;YAChE,MAAM,KAAK,GAAG,gBAAgB,CAAC,IAAI,CACjC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,eAAe,CACvC,CAAC;YACF,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;YAE5B,oDAAoD;YACpD,MAAM,UAAU,GAAG,gBAAgB,CAAC,IAAI,CACtC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,aAAa,CACrC,CAAC;YACF,MAAM,CAAC,UAAU,CAAC,CAAC,aAAa,EAAE,CAAC;QACrC,CAAC,CAAC,CAAC;QAEH,UAAU,CAAC,WAAW,EAAE,CAAC;IAC3B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { render, waitFor } from \"@testing-library/react\";\nimport React from \"react\";\nimport { z } from \"zod/v4\";\nimport { withTamboInteractable } from \"../hoc/with-tambo-interactable\";\nimport {\n TamboContextHelpersProvider,\n useTamboContextHelpers,\n} from \"./tambo-context-helpers-provider\";\nimport { TamboInteractableProvider } from \"./tambo-interactable-provider\";\nimport { TamboStubProvider } from \"../v1/providers/tambo-v1-stub-provider\";\n\nfunction wrapperWithProviders(children: React.ReactNode) {\n return (\n <TamboStubProvider>\n <TamboContextHelpersProvider>{children}</TamboContextHelpersProvider>\n </TamboStubProvider>\n );\n}\n\ndescribe(\"Interactables AdditionalContext - Edge Cases & Advanced Scenarios\", () => {\n test(\"handles components without propsSchema gracefully\", async () => {\n const SimpleComponent: React.FC<{ text: string }> = ({ text }) => (\n <div>{text}</div>\n );\n\n const InteractableSimpleComponent = withTamboInteractable(SimpleComponent, {\n componentName: \"SimpleComponent\",\n description: \"A component without schema\",\n // No propsSchema provided\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableSimpleComponent text=\"test\" />\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry).toBeDefined();\n const component = entry!.context.components[0];\n expect(component.propsSchema).toBe(\"Not specified\");\n });\n });\n\n test(\"handles component unmounting and remounting correctly\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n const interval = setInterval(() => {\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n }, 50);\n return () => {\n mounted = false;\n clearInterval(interval);\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const Host = () => {\n const [showNote, setShowNote] = React.useState(true);\n\n React.useEffect(() => {\n // Toggle the note on/off to test unmounting\n const timeout = setTimeout(() => setShowNote(false), 100);\n const timeout2 = setTimeout(() => setShowNote(true), 200);\n return () => {\n clearTimeout(timeout);\n clearTimeout(timeout2);\n };\n }, []);\n\n return (\n <TamboInteractableProvider>\n {showNote && <InteractableNote title=\"dynamic note\" />}\n <TestComponent />\n </TamboInteractableProvider>\n );\n };\n\n const { getByTestId } = render(wrapperWithProviders(<Host />));\n\n await waitFor(\n () => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n },\n { timeout: 1000 },\n );\n\n // Eventually should show the note again\n await waitFor(\n () => {\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry?.context?.components).toHaveLength(1);\n },\n { timeout: 1000 },\n );\n });\n\n test(\"context helper updates when props change from parent\", async () => {\n const Counter: React.FC<{ count: number; label?: string }> = ({\n count,\n label = \"Count\",\n }) => (\n <div>\n {label}: {count}\n </div>\n );\n\n const InteractableCounter = withTamboInteractable(Counter, {\n componentName: \"Counter\",\n description: \"A counter component\",\n propsSchema: z.object({\n count: z.number(),\n label: z.string().optional(),\n }),\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n const interval = setInterval(() => {\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n }, 50);\n return () => {\n mounted = false;\n clearInterval(interval);\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const Host = () => {\n const [count, setCount] = React.useState(0);\n const [label, setLabel] = React.useState(\"Items\");\n\n React.useEffect(() => {\n const timeout1 = setTimeout(() => setCount(5), 100);\n const timeout2 = setTimeout(() => setLabel(\"Updated Items\"), 200);\n return () => {\n clearTimeout(timeout1);\n clearTimeout(timeout2);\n };\n }, []);\n\n return (\n <TamboInteractableProvider>\n <InteractableCounter count={count} label={label} />\n <TestComponent />\n </TamboInteractableProvider>\n );\n };\n\n const { getByTestId } = render(wrapperWithProviders(<Host />));\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n });\n\n // Wait for updates to propagate\n await waitFor(\n () => {\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n if (entry?.context?.components?.[0]) {\n const props = entry.context.components[0].props;\n expect(props.count).toBe(5);\n expect(props.label).toBe(\"Updated Items\");\n }\n },\n { timeout: 1000 },\n );\n });\n\n test(\"multiple providers with nested context helpers work correctly\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n let outerContexts: any[] = [];\n let innerContexts: any[] = [];\n\n const OuterTestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n outerContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"outer-ready\">outer ready</div>;\n };\n\n const InnerTestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n innerContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"inner-ready\">inner ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableNote title=\"outer note\" />\n <OuterTestComponent />\n <TamboContextHelpersProvider\n contextHelpers={{\n customContext: () => ({ custom: \"inner\" }),\n }}\n >\n <TamboInteractableProvider>\n <InteractableNote title=\"inner note\" />\n <InnerTestComponent />\n </TamboInteractableProvider>\n </TamboContextHelpersProvider>\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"outer-ready\")).toBeInTheDocument();\n expect(getByTestId(\"inner-ready\")).toBeInTheDocument();\n });\n\n await waitFor(() => {\n // Outer context should have outer note\n const outerEntry = outerContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(outerEntry?.context?.components).toHaveLength(1);\n expect(outerEntry?.context?.components[0]?.props?.title).toBe(\n \"outer note\",\n );\n\n // Inner context should have inner note and custom context\n const innerEntry = innerContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(innerEntry?.context?.components).toHaveLength(1);\n expect(innerEntry?.context?.components[0]?.props?.title).toBe(\n \"inner note\",\n );\n\n const customEntry = innerContexts.find(\n (c: any) => c.name === \"customContext\",\n );\n expect(customEntry?.context).toEqual({ custom: \"inner\" });\n });\n });\n\n test(\"provider cleanup removes helper when last provider unmounts\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n const interval = setInterval(() => {\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n }, 50);\n return () => {\n mounted = false;\n clearInterval(interval);\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const Host = () => {\n const [showProvider, setShowProvider] = React.useState(true);\n\n React.useEffect(() => {\n const timeout = setTimeout(() => setShowProvider(false), 200);\n return () => clearTimeout(timeout);\n }, []);\n\n return (\n <>\n {showProvider && (\n <TamboInteractableProvider>\n <InteractableNote title=\"will disappear\" />\n </TamboInteractableProvider>\n )}\n <TestComponent />\n </>\n );\n };\n\n const { getByTestId } = render(wrapperWithProviders(<Host />));\n\n // Initially should have the context\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry).toBeDefined();\n });\n\n // After provider unmounts, context should be gone\n await waitFor(\n () => {\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry).toBeUndefined();\n },\n { timeout: 1000 },\n );\n });\n\n test(\"helper error handling doesn't crash the system\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n // Mock console.error to capture error logs\n const consoleSpy = jest\n .spyOn(console, \"error\")\n .mockImplementation(() => {});\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext, addContextHelper } =\n useTamboContextHelpers();\n\n React.useEffect(() => {\n // Add a helper that throws an error\n addContextHelper(\"errorHelper\", () => {\n throw new Error(\"Test error in helper\");\n });\n }, [addContextHelper]);\n\n React.useEffect(() => {\n let mounted = true;\n getAdditionalContext()\n .then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n })\n .catch(() => {\n // Should not reach here - errors should be handled gracefully\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableNote title=\"test\" />\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n // Should still have the interactables context despite the error\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry).toBeDefined();\n\n // Error helper should not be present (filtered out)\n const errorEntry = capturedContexts.find(\n (c: any) => c.name === \"errorHelper\",\n );\n expect(errorEntry).toBeUndefined();\n });\n\n consoleSpy.mockRestore();\n });\n});\n"]}
@@ -9,17 +9,9 @@ const v4_1 = require("zod/v4");
9
9
  const with_tambo_interactable_1 = require("../hoc/with-tambo-interactable");
10
10
  const tambo_context_helpers_provider_1 = require("./tambo-context-helpers-provider");
11
11
  const tambo_interactable_provider_1 = require("./tambo-interactable-provider");
12
- const tambo_stubs_1 = require("./tambo-stubs");
12
+ const tambo_v1_stub_provider_1 = require("../v1/providers/tambo-v1-stub-provider");
13
13
  function wrapperWithProviders(children) {
14
- const thread = {
15
- id: "t-1",
16
- projectId: "p-1",
17
- createdAt: new Date().toISOString(),
18
- updatedAt: new Date().toISOString(),
19
- messages: [],
20
- metadata: {},
21
- };
22
- return (react_2.default.createElement(tambo_stubs_1.TamboStubProvider, { thread: thread, registerTool: () => { }, registerTools: () => { }, registerComponent: () => { }, addToolAssociation: () => { } },
14
+ return (react_2.default.createElement(tambo_v1_stub_provider_1.TamboStubProvider, null,
23
15
  react_2.default.createElement(tambo_context_helpers_provider_1.TamboContextHelpersProvider, null, children)));
24
16
  }
25
17
  describe("Interactables AdditionalContext (provider-based)", () => {
@@ -273,15 +265,7 @@ describe("Interactables AdditionalContext (provider-based)", () => {
273
265
  }, [getAdditionalContext]);
274
266
  return react_2.default.createElement("div", { "data-testid": "ready" }, "ready");
275
267
  };
276
- const thread = {
277
- id: "t-1",
278
- projectId: "p-1",
279
- createdAt: new Date().toISOString(),
280
- updatedAt: new Date().toISOString(),
281
- messages: [],
282
- metadata: {},
283
- };
284
- const { getByTestId } = (0, react_1.render)(react_2.default.createElement(tambo_stubs_1.TamboStubProvider, { thread: thread, registerTool: () => { }, registerTools: () => { }, registerComponent: () => { }, addToolAssociation: () => { } },
268
+ const { getByTestId } = (0, react_1.render)(react_2.default.createElement(tambo_v1_stub_provider_1.TamboStubProvider, null,
285
269
  react_2.default.createElement(DisabledContextHelpers, null,
286
270
  react_2.default.createElement(tambo_interactable_provider_1.TamboInteractableProvider, null,
287
271
  react_2.default.createElement(InteractableNote, { title: "should not appear" }),
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-interactables-additional-context.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C;YACF,MAAM,CAAC,KAAK,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC,kDAAkD;QACnF,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { render, waitFor } from \"@testing-library/react\";\nimport React from \"react\";\nimport { z } from \"zod/v4\";\nimport { withTamboInteractable } from \"../hoc/with-tambo-interactable\";\nimport {\n TamboContextHelpersProvider,\n useTamboContextHelpers,\n} from \"./tambo-context-helpers-provider\";\nimport {\n TamboInteractableProvider,\n useCurrentInteractablesSnapshot,\n} from \"./tambo-interactable-provider\";\nimport { TamboStubProvider } from \"./tambo-stubs\";\n\nfunction wrapperWithProviders(children: React.ReactNode) {\n const thread = {\n id: \"t-1\",\n projectId: \"p-1\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n messages: [],\n metadata: {},\n } as any;\n\n return (\n <TamboStubProvider\n thread={thread}\n registerTool={() => {}}\n registerTools={() => {}}\n registerComponent={() => {}}\n addToolAssociation={() => {}}\n >\n <TamboContextHelpersProvider>{children}</TamboContextHelpersProvider>\n </TamboStubProvider>\n );\n}\n\ndescribe(\"Interactables AdditionalContext (provider-based)\", () => {\n test(\"registers default helper and returns payload with description and components\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableNote title=\"hello\" />\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry).toBeDefined();\n expect(Array.isArray(entry?.context?.components)).toBe(true);\n const comp = entry!.context.components[0];\n expect(comp.componentName).toBe(\"Note\");\n expect(comp.props).toEqual({ title: \"hello\" });\n });\n });\n\n test(\"returns null when no interactable components are present\", async () => {\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <div>No interactables here</div>\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry).toBeUndefined(); // Should be filtered out when helper returns null\n });\n });\n\n test(\"context includes proper AI prompt with clear instructions\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A simple note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableNote title=\"test\" />\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry).toBeDefined();\n expect(Array.isArray(entry?.context?.components)).toBe(true);\n });\n });\n\n test(\"includes component metadata in expected format\", async () => {\n const Note: React.FC<{ title: string; color?: string }> = ({\n title,\n color = \"white\",\n }) => <div className={`note-${color}`}>{title}</div>;\n\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A colorful note component\",\n propsSchema: z.object({\n title: z.string(),\n color: z.string().optional(),\n }),\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableNote title=\"test note\" color=\"blue\" />\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n const component = entry!.context.components[0];\n\n expect(component).toMatchObject({\n id: expect.any(String),\n componentName: \"Note\",\n description: \"A colorful note component\",\n props: { title: \"test note\", color: \"blue\" },\n propsSchema: \"Available - use component-specific update tools\",\n });\n });\n });\n\n test(\"snapshot hook returns immutable copies\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n const TestComponent = () => {\n const snapshot = useCurrentInteractablesSnapshot();\n const [testResult, setTestResult] = React.useState<string>(\"pending\");\n\n React.useEffect(() => {\n if (snapshot.length > 0) {\n const originalLength = snapshot.length;\n\n // Try to mutate the returned array and props\n snapshot.push({\n id: \"fake\",\n name: \"Fake\",\n description: \"\",\n component: () => null,\n props: {},\n } as any);\n (snapshot[0].props as any).title = \"MUTATED\";\n\n // The mutations should succeed on the returned copy, proving it's a separate object\n if (\n snapshot.length === originalLength + 1 &&\n snapshot[0].props.title === \"MUTATED\"\n ) {\n setTestResult(\"mutation-successful-but-isolated\");\n } else {\n setTestResult(\"mutation-failed\");\n }\n }\n }, [snapshot]);\n\n return <div data-testid=\"test-result\">{testResult}</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableNote title=\"immutable test\" />\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n const result = getByTestId(\"test-result\").textContent;\n expect(result).toBe(\"mutation-successful-but-isolated\");\n });\n });\n\n test(\"multiple interactables from same provider appear in context\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const Counter: React.FC<{ count: number }> = ({ count }) => (\n <div>{count}</div>\n );\n\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n const InteractableCounter = withTamboInteractable(Counter, {\n componentName: \"Counter\",\n description: \"A counter\",\n propsSchema: z.object({ count: z.number() }),\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableNote title=\"first\" />\n <InteractableCounter count={42} />\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry?.context?.components).toHaveLength(2);\n\n const components = entry!.context.components;\n expect(components[0].componentName).toBe(\"Note\");\n expect(components[0].props).toEqual({ title: \"first\" });\n expect(components[1].componentName).toBe(\"Counter\");\n expect(components[1].props).toEqual({ count: 42 });\n });\n });\n\n test(\"can be disabled by returning null\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n // Create a context helpers provider with a disabled interactables helper\n const DisabledContextHelpers = ({\n children,\n }: {\n children: React.ReactNode;\n }) => (\n <TamboContextHelpersProvider\n contextHelpers={{\n [\"interactables\"]: () => null,\n }}\n >\n {children}\n </TamboContextHelpersProvider>\n );\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const thread = {\n id: \"t-1\",\n projectId: \"p-1\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n messages: [],\n metadata: {},\n } as any;\n\n const { getByTestId } = render(\n <TamboStubProvider\n thread={thread}\n registerTool={() => {}}\n registerTools={() => {}}\n registerComponent={() => {}}\n addToolAssociation={() => {}}\n >\n <DisabledContextHelpers>\n <TamboInteractableProvider>\n <InteractableNote title=\"should not appear\" />\n <TestComponent />\n </TamboInteractableProvider>\n </DisabledContextHelpers>\n </TamboStubProvider>,\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry).toBeUndefined(); // Should be filtered out when helper returns null\n });\n });\n});\n"]}
1
+ {"version":3,"file":"tambo-interactables-additional-context.test.js","sourceRoot":"","sources":["../../src/providers/tambo-interactables-additional-context.test.tsx"],"names":[],"mappings":";;;;;AAAA,kDAAyD;AACzD,kDAA0B;AAC1B,+BAA2B;AAC3B,4EAAuE;AACvE,qFAG0C;AAC1C,+EAGuC;AACvC,mFAA2E;AAE3E,SAAS,oBAAoB,CAAC,QAAyB;IACrD,OAAO,CACL,8BAAC,0CAAiB;QAChB,8BAAC,4DAA2B,QAAE,QAAQ,CAA+B,CACnD,CACrB,CAAC;AACJ,CAAC;AAED,QAAQ,CAAC,kDAAkD,EAAE,GAAG,EAAE;IAChE,IAAI,CAAC,8EAA8E,EAAE,KAAK,IAAI,EAAE;QAC9F,MAAM,IAAI,GAAgC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,2CAAM,KAAK,CAAO,CAAC;QAE5E,MAAM,gBAAgB,GAAG,IAAA,+CAAqB,EAAC,IAAI,EAAE;YACnD,aAAa,EAAE,MAAM;YACrB,WAAW,EAAE,QAAQ;YACrB,WAAW,EAAE,MAAC,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,MAAC,CAAC,MAAM,EAAE,EAAE,CAAC;SAC7C,CAAC,CAAC;QAEH,IAAI,gBAAgB,GAAU,EAAE,CAAC;QACjC,MAAM,aAAa,GAAG,GAAG,EAAE;YACzB,MAAM,EAAE,oBAAoB,EAAE,GAAG,IAAA,uDAAsB,GAAE,CAAC;YAE1D,eAAK,CAAC,SAAS,CAAC,GAAG,EAAE;gBACnB,IAAI,OAAO,GAAG,IAAI,CAAC;gBACnB,KAAK,oBAAoB,EAAE,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;oBAC5C,IAAI,OAAO,EAAE,CAAC;wBACZ,gBAAgB,GAAG,QAAQ,CAAC;oBAC9B,CAAC;gBACH,CAAC,CAAC,CAAC;gBACH,OAAO,GAAG,EAAE;oBACV,OAAO,GAAG,KAAK,CAAC;gBAClB,CAAC,CAAC;YACJ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B,8BAAC,sBAAsB;gBACrB,8BAAC,uDAAyB;oBACxB,8BAAC,gBAAgB,IAAC,KAAK,EAAC,mBAAmB,GAAG;oBAC9C,8BAAC,aAAa,OAAG,CACS,CACL,CACP,CACrB,CAAC;QAEF,MAAM,IAAA,eAAO,EAAC,GAAG,EAAE;YACjB,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;YACjD,MAAM,KAAK,GAAG,gBAAgB,CAAC,IAAI,CACjC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,eAAe,CACvC,CAAC;YACF,MAAM,CAAC,KAAK,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC,kDAAkD;QACnF,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { render, waitFor } from \"@testing-library/react\";\nimport React from \"react\";\nimport { z } from \"zod/v4\";\nimport { withTamboInteractable } from \"../hoc/with-tambo-interactable\";\nimport {\n TamboContextHelpersProvider,\n useTamboContextHelpers,\n} from \"./tambo-context-helpers-provider\";\nimport {\n TamboInteractableProvider,\n useCurrentInteractablesSnapshot,\n} from \"./tambo-interactable-provider\";\nimport { TamboStubProvider } from \"../v1/providers/tambo-v1-stub-provider\";\n\nfunction wrapperWithProviders(children: React.ReactNode) {\n return (\n <TamboStubProvider>\n <TamboContextHelpersProvider>{children}</TamboContextHelpersProvider>\n </TamboStubProvider>\n );\n}\n\ndescribe(\"Interactables AdditionalContext (provider-based)\", () => {\n test(\"registers default helper and returns payload with description and components\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableNote title=\"hello\" />\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry).toBeDefined();\n expect(Array.isArray(entry?.context?.components)).toBe(true);\n const comp = entry!.context.components[0];\n expect(comp.componentName).toBe(\"Note\");\n expect(comp.props).toEqual({ title: \"hello\" });\n });\n });\n\n test(\"returns null when no interactable components are present\", async () => {\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <div>No interactables here</div>\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry).toBeUndefined(); // Should be filtered out when helper returns null\n });\n });\n\n test(\"context includes proper AI prompt with clear instructions\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A simple note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableNote title=\"test\" />\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry).toBeDefined();\n expect(Array.isArray(entry?.context?.components)).toBe(true);\n });\n });\n\n test(\"includes component metadata in expected format\", async () => {\n const Note: React.FC<{ title: string; color?: string }> = ({\n title,\n color = \"white\",\n }) => <div className={`note-${color}`}>{title}</div>;\n\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A colorful note component\",\n propsSchema: z.object({\n title: z.string(),\n color: z.string().optional(),\n }),\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableNote title=\"test note\" color=\"blue\" />\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n const component = entry!.context.components[0];\n\n expect(component).toMatchObject({\n id: expect.any(String),\n componentName: \"Note\",\n description: \"A colorful note component\",\n props: { title: \"test note\", color: \"blue\" },\n propsSchema: \"Available - use component-specific update tools\",\n });\n });\n });\n\n test(\"snapshot hook returns immutable copies\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n const TestComponent = () => {\n const snapshot = useCurrentInteractablesSnapshot();\n const [testResult, setTestResult] = React.useState<string>(\"pending\");\n\n React.useEffect(() => {\n if (snapshot.length > 0) {\n const originalLength = snapshot.length;\n\n // Try to mutate the returned array and props\n snapshot.push({\n id: \"fake\",\n name: \"Fake\",\n description: \"\",\n component: () => null,\n props: {},\n } as any);\n (snapshot[0].props as any).title = \"MUTATED\";\n\n // The mutations should succeed on the returned copy, proving it's a separate object\n if (\n snapshot.length === originalLength + 1 &&\n snapshot[0].props.title === \"MUTATED\"\n ) {\n setTestResult(\"mutation-successful-but-isolated\");\n } else {\n setTestResult(\"mutation-failed\");\n }\n }\n }, [snapshot]);\n\n return <div data-testid=\"test-result\">{testResult}</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableNote title=\"immutable test\" />\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n const result = getByTestId(\"test-result\").textContent;\n expect(result).toBe(\"mutation-successful-but-isolated\");\n });\n });\n\n test(\"multiple interactables from same provider appear in context\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const Counter: React.FC<{ count: number }> = ({ count }) => (\n <div>{count}</div>\n );\n\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n const InteractableCounter = withTamboInteractable(Counter, {\n componentName: \"Counter\",\n description: \"A counter\",\n propsSchema: z.object({ count: z.number() }),\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableNote title=\"first\" />\n <InteractableCounter count={42} />\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry?.context?.components).toHaveLength(2);\n\n const components = entry!.context.components;\n expect(components[0].componentName).toBe(\"Note\");\n expect(components[0].props).toEqual({ title: \"first\" });\n expect(components[1].componentName).toBe(\"Counter\");\n expect(components[1].props).toEqual({ count: 42 });\n });\n });\n\n test(\"can be disabled by returning null\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n // Create a context helpers provider with a disabled interactables helper\n const DisabledContextHelpers = ({\n children,\n }: {\n children: React.ReactNode;\n }) => (\n <TamboContextHelpersProvider\n contextHelpers={{\n [\"interactables\"]: () => null,\n }}\n >\n {children}\n </TamboContextHelpersProvider>\n );\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n void getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const { getByTestId } = render(\n <TamboStubProvider>\n <DisabledContextHelpers>\n <TamboInteractableProvider>\n <InteractableNote title=\"should not appear\" />\n <TestComponent />\n </TamboInteractableProvider>\n </DisabledContextHelpers>\n </TamboStubProvider>,\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry).toBeUndefined(); // Should be filtered out when helper returns null\n });\n });\n});\n"]}
@@ -1,8 +1,7 @@
1
- import React, { PropsWithChildren } from "react";
1
+ import React, { type PropsWithChildren } from "react";
2
2
  export interface TamboMcpTokenContextProps {
3
3
  /**
4
4
  * The current MCP access token for the internal Tambo MCP server.
5
- * Prefers thread-specific token over threadless token.
6
5
  */
7
6
  mcpAccessToken: string | null;
8
7
  /**
@@ -15,15 +14,8 @@ export interface TamboMcpTokenContextProps {
15
14
  * Provider for managing the MCP access token that is returned by the Tambo API.
16
15
  * This token is used to authenticate with the internal Tambo MCP server.
17
16
  *
18
- * Token selection logic:
19
- * - Returns the current thread's mcpAccessToken if available
20
- * - Returns null if no thread or thread has no token
21
- *
22
- * Token fetching:
23
- * - Thread-specific token: always fetched when switching to thread without token
24
- * - Tokens are fetched regardless of client-side MCP server configuration
25
- * to support server-side MCP servers that are not visible to the provider
26
- * - Threadless tokens must be fetched by individual hooks/callbacks using contextKey
17
+ * Exposes the base URL and a null token by default. Token fetching is handled
18
+ * by the useTamboMcpToken hook which supports contextKey-based token retrieval.
27
19
  * @internal
28
20
  * @param props - The provider props
29
21
  * @param props.children - The children to wrap
@@ -31,13 +23,12 @@ export interface TamboMcpTokenContextProps {
31
23
  */
32
24
  export declare const TamboMcpTokenProvider: React.FC<PropsWithChildren>;
33
25
  /**
34
- * Hook to access the current MCP access token with optional threadless token fetching.
26
+ * Hook to access the current MCP access token with optional token fetching.
35
27
  *
36
- * Token selection logic:
37
- * 1. If current thread has mcpAccessToken use thread-specific token
38
- * 2. Else if contextKey provided and no thread (or placeholder thread) fetch and use threadless token
39
- * 3. Else null
40
- * @param contextKey - Optional context key for fetching threadless tokens when not in a thread
28
+ * Token fetching logic:
29
+ * - If contextKey is providedfetches a token using that contextKey
30
+ * - Otherwisereturns null
31
+ * @param contextKey - Optional context key for fetching tokens
41
32
  * @returns The current MCP access token and base URL
42
33
  */
43
34
  export declare const useTamboMcpToken: (contextKey?: string) => TamboMcpTokenContextProps;