@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
@@ -1,931 +0,0 @@
1
- "use strict";
2
- "use client";
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
- }) : function(o, v) {
17
- o["default"] = v;
18
- });
19
- var __importStar = (this && this.__importStar) || (function () {
20
- var ownKeys = function(o) {
21
- ownKeys = Object.getOwnPropertyNames || function (o) {
22
- var ar = [];
23
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
- return ar;
25
- };
26
- return ownKeys(o);
27
- };
28
- return function (mod) {
29
- if (mod && mod.__esModule) return mod;
30
- var result = {};
31
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
- __setModuleDefault(result, mod);
33
- return result;
34
- };
35
- })();
36
- Object.defineProperty(exports, "__esModule", { value: true });
37
- exports.useTamboThread = exports.useTamboGenerationStage = exports.TamboThreadProvider = exports.TamboThreadContext = exports.PLACEHOLDER_THREAD = exports.TamboGenerationStageProvider = void 0;
38
- const typescript_sdk_1 = require("@tambo-ai/typescript-sdk");
39
- const react_1 = __importStar(require("react"));
40
- const generate_component_response_1 = require("../model/generate-component-response");
41
- const content_parts_1 = require("../util/content-parts");
42
- const generate_component_1 = require("../util/generate-component");
43
- const registry_1 = require("../util/registry");
44
- const tool_caller_1 = require("../util/tool-caller");
45
- const tambo_client_provider_1 = require("./tambo-client-provider");
46
- const tambo_context_helpers_provider_1 = require("./tambo-context-helpers-provider");
47
- const tambo_registry_provider_1 = require("./tambo-registry-provider");
48
- const TamboGenerationStageContext = (0, react_1.createContext)(undefined);
49
- /**
50
- *
51
- * This provider is used to provide the generation stage context to the descendants of the provider.
52
- * @param props - The props for the GenerationStageProvider
53
- * @param props.children - The children to wrap
54
- * @param props.generationStage - The generation stage to provide
55
- * @param props.statusMessage - The status message to provide
56
- * @returns The GenerationStageProvider component
57
- */
58
- const TamboGenerationStageProvider = ({ children, generationStage, statusMessage }) => {
59
- const isIdle = (0, generate_component_response_1.isIdleStage)(generationStage);
60
- const contextValue = (0, react_1.useMemo)(() => {
61
- return {
62
- generationStage,
63
- generationStatusMessage: statusMessage,
64
- isIdle,
65
- };
66
- }, [generationStage, statusMessage, isIdle]);
67
- return (react_1.default.createElement(TamboGenerationStageContext.Provider, { value: contextValue }, children));
68
- };
69
- exports.TamboGenerationStageProvider = TamboGenerationStageProvider;
70
- /**
71
- * This is a stub entry for when the thread is not yet created, the first time
72
- * the user sends a message
73
- *
74
- * Note that the consumer needs to be careful never to send `PLACEHOLDER_THREAD.id` to the server,
75
- * as this doesn't really exist on the server side.
76
- */
77
- exports.PLACEHOLDER_THREAD = {
78
- id: "placeholder",
79
- messages: [],
80
- createdAt: "",
81
- projectId: "",
82
- updatedAt: "",
83
- metadata: {},
84
- };
85
- exports.TamboThreadContext = (0, react_1.createContext)({
86
- thread: exports.PLACEHOLDER_THREAD,
87
- currentThreadId: exports.PLACEHOLDER_THREAD.id,
88
- currentThread: exports.PLACEHOLDER_THREAD,
89
- threadMap: { [exports.PLACEHOLDER_THREAD.id]: exports.PLACEHOLDER_THREAD },
90
- setThreadMap: () => {
91
- throw new Error("setThreadMap not implemented");
92
- },
93
- /**
94
- *
95
- */
96
- switchCurrentThread: () => {
97
- throw new Error("switchCurrentThread not implemented");
98
- },
99
- /**
100
- *
101
- */
102
- startNewThread: () => {
103
- throw new Error("startNewThread not implemented");
104
- },
105
- /**
106
- *
107
- */
108
- updateThreadName: () => {
109
- throw new Error("updateThreadName not implemented");
110
- },
111
- /**
112
- *
113
- */
114
- generateThreadName: () => {
115
- throw new Error("generateThreadName not implemented");
116
- },
117
- /**
118
- *
119
- */
120
- addThreadMessage: () => {
121
- throw new Error("updateThreadMessageHistory not implemented");
122
- },
123
- streaming: true,
124
- /**
125
- *
126
- */
127
- updateThreadMessage: () => {
128
- throw new Error("updateThreadMessage not implemented");
129
- },
130
- /**
131
- *
132
- */
133
- sendThreadMessage: () => {
134
- throw new Error("sendThreadMessage not implemented");
135
- },
136
- /**
137
- *
138
- */
139
- cancel: () => {
140
- throw new Error("cancel not implemented");
141
- },
142
- });
143
- /**
144
- * The TamboThreadProvider is a React provider that provides a thread context
145
- * to the descendants of the provider.
146
- * @param props - The props for the TamboThreadProvider
147
- * @param props.children - The children to wrap
148
- * @param props.streaming - Whether to stream the response by default. Defaults to true.
149
- * @param props.initialMessages - Initial messages to be included in new threads
150
- * @param props.autoGenerateThreadName - Whether to automatically generate thread names. Defaults to true.
151
- * @param props.autoGenerateNameThreshold - The message count threshold at which the thread name will be auto-generated. Defaults to 3.
152
- * @param props.contextKey - The context key to use for thread isolation
153
- * @returns The TamboThreadProvider component
154
- */
155
- const TamboThreadProvider = ({ children, streaming = true, initialMessages = [], autoGenerateThreadName = true, autoGenerateNameThreshold = 3, contextKey, }) => {
156
- // Create placeholder thread with initial messages
157
- const placeholderThread = (0, react_1.useMemo)(() => ({
158
- id: "placeholder",
159
- messages: initialMessages.map((msg) => ({
160
- ...msg,
161
- id: msg.id ?? crypto.randomUUID(),
162
- threadId: "placeholder",
163
- createdAt: msg.createdAt ?? new Date().toISOString(),
164
- componentState: msg.componentState ?? {},
165
- })),
166
- createdAt: "",
167
- projectId: "",
168
- updatedAt: "",
169
- metadata: {},
170
- contextKey,
171
- }), [contextKey, initialMessages]);
172
- const [threadMap, setThreadMap] = (0, react_1.useState)({
173
- [placeholderThread.id]: placeholderThread,
174
- });
175
- const client = (0, tambo_client_provider_1.useTamboClient)();
176
- const queryClient = (0, tambo_client_provider_1.useTamboQueryClient)();
177
- const { componentList, toolRegistry, componentToolAssociations, onCallUnregisteredTool, } = (0, tambo_registry_provider_1.useTamboRegistry)();
178
- const { getAdditionalContext } = (0, tambo_context_helpers_provider_1.useTamboContextHelpers)();
179
- const [ignoreResponse, setIgnoreResponse] = (0, react_1.useState)(false);
180
- const ignoreResponseRef = (0, react_1.useRef)(ignoreResponse);
181
- const [currentThreadId, setCurrentThreadId] = (0, react_1.useState)(placeholderThread.id);
182
- const currentThread = threadMap[currentThreadId];
183
- // Generation stage props for GenerationStageProvider
184
- const currentGenerationStage = currentThread?.generationStage ?? generate_component_response_1.GenerationStage.IDLE;
185
- const currentStatusMessage = currentThread?.statusMessage ?? "";
186
- // Use existing messages from the current thread to avoid re-generating any components
187
- const currentMessageCache = (0, react_1.useMemo)(() => {
188
- const messageCache = new Map();
189
- if (currentThread) {
190
- for (const message of currentThread.messages) {
191
- messageCache.set(message.id, message);
192
- }
193
- }
194
- return messageCache;
195
- }, [currentThread]);
196
- (0, react_1.useEffect)(() => {
197
- ignoreResponseRef.current = ignoreResponse;
198
- }, [ignoreResponse]);
199
- const updateThreadsCache = (0, react_1.useCallback)(async (updateFn, contextKey) => {
200
- try {
201
- const currentProject = await client.beta.projects.getCurrent();
202
- queryClient.setQueryData(["threads", currentProject.id, contextKey], updateFn);
203
- await queryClient.invalidateQueries({
204
- queryKey: ["threads"],
205
- });
206
- }
207
- catch (error) {
208
- console.warn("Failed to update threads cache:", error);
209
- }
210
- }, [client.beta.projects, queryClient]);
211
- const addThreadToCache = (0, react_1.useCallback)(async (threadId, contextKey) => {
212
- const optimisticThread = {
213
- ...exports.PLACEHOLDER_THREAD,
214
- id: threadId,
215
- createdAt: new Date().toISOString(),
216
- updatedAt: new Date().toISOString(),
217
- };
218
- await updateThreadsCache((old) => {
219
- if (!old)
220
- return old;
221
- return {
222
- ...old,
223
- items: [optimisticThread, ...(old.items ?? [])],
224
- total: (old.total ?? 0) + 1,
225
- count: (old.count ?? 0) + 1,
226
- };
227
- }, contextKey);
228
- }, [updateThreadsCache]);
229
- const updateThreadInCache = (0, react_1.useCallback)(async (threadId, updateFn, contextKey) => {
230
- await updateThreadsCache((old) => {
231
- if (!old?.items)
232
- return old;
233
- return {
234
- ...old,
235
- items: old.items.map((thread) => thread.id === threadId ? updateFn(thread) : thread),
236
- total: old.total,
237
- count: old.count,
238
- };
239
- }, contextKey);
240
- }, [updateThreadsCache]);
241
- const fetchThread = (0, react_1.useCallback)(async (threadId) => {
242
- const thread = await client.beta.threads.retrieve(threadId);
243
- const threadWithRenderedComponents = {
244
- ...thread,
245
- messages: thread.messages.map((message) => {
246
- if (currentMessageCache.has(message.id)) {
247
- const renderedMessage = currentMessageCache.get(message.id);
248
- return {
249
- ...renderedMessage,
250
- ...message,
251
- };
252
- }
253
- if (message.component?.componentName) {
254
- const messageWithComponent = (0, generate_component_1.renderComponentIntoMessage)(message, componentList);
255
- return messageWithComponent;
256
- }
257
- return message;
258
- }),
259
- };
260
- setThreadMap((prevMap) => {
261
- const updatedThreadMap = {
262
- ...prevMap,
263
- [threadId]: threadWithRenderedComponents,
264
- };
265
- return updatedThreadMap;
266
- });
267
- }, [client.beta.threads, componentList, currentMessageCache]);
268
- (0, react_1.useEffect)(() => {
269
- async function loadThread() {
270
- try {
271
- await fetchThread(currentThreadId);
272
- }
273
- catch (error) {
274
- console.error("Failed to fetch thread:", error);
275
- }
276
- }
277
- if (currentThreadId &&
278
- currentThreadId !== placeholderThread.id &&
279
- !threadMap[currentThreadId]) {
280
- loadThread().catch((err) => {
281
- console.error("Unexpected error in loadThread:", err);
282
- });
283
- }
284
- }, [currentThreadId, fetchThread, threadMap, placeholderThread.id]);
285
- const addThreadMessage = (0, react_1.useCallback)(async (message, sendToServer = true, createdAt = new Date().toISOString()) => {
286
- if (!currentThread) {
287
- console.warn("Cannot add messages if we do not have a current thread");
288
- return [];
289
- }
290
- const chatMessage = {
291
- ...message,
292
- createdAt,
293
- };
294
- const threadId = message.threadId;
295
- const messageId = chatMessage.id;
296
- // optimistically update the thread in the local state
297
- setThreadMap((prevMap) => {
298
- if (!threadId) {
299
- return prevMap;
300
- }
301
- const prevMessages = prevMap[threadId]?.messages || [];
302
- const haveMessage = prevMessages.find((msg) => msg.id === messageId);
303
- // Update in place if the message already exists
304
- const updatedMessages = haveMessage
305
- ? prevMessages.map((msg) => {
306
- if (msg.id === messageId) {
307
- return chatMessage;
308
- }
309
- return msg;
310
- })
311
- : [...prevMessages, chatMessage];
312
- const updatedThreadMap = {
313
- ...prevMap,
314
- [threadId]: {
315
- ...prevMap[threadId],
316
- messages: updatedMessages,
317
- },
318
- };
319
- return updatedThreadMap;
320
- });
321
- if (sendToServer) {
322
- try {
323
- await client.beta.threads.messages.create(message.threadId, {
324
- content: message.content,
325
- role: message.role,
326
- additionalContext: chatMessage.additionalContext,
327
- });
328
- }
329
- catch (error) {
330
- console.error("Failed to add message to server", error);
331
- // Revert optimistic local state update
332
- setThreadMap((prev) => {
333
- const prevMessages = prev[threadId]?.messages || [];
334
- // addThreadMessage -> for new messages or simple updates
335
- // On Fail -> remove the added/updated message (no prev state)
336
- const updatedMessages = prevMessages.filter((msg) => msg.id !== messageId);
337
- return {
338
- ...prev,
339
- [threadId]: {
340
- ...prev[threadId],
341
- messages: updatedMessages,
342
- },
343
- };
344
- });
345
- throw error;
346
- }
347
- }
348
- return threadMap[threadId]?.messages || [];
349
- }, [client.beta.threads.messages, currentThread, threadMap]);
350
- const updateThreadMessage = (0, react_1.useCallback)(async (id, message, sendToServer = true, createdAt = new Date().toISOString()) => {
351
- setThreadMap((prevMap) => {
352
- const prevMessages = prevMap[message.threadId]?.messages || [];
353
- const updatedMessages = prevMessages.map((msg) => {
354
- if (msg.id === id) {
355
- // Merge the partial update with the existing message
356
- const updatedMessage = {
357
- ...msg,
358
- ...message,
359
- id: msg.id,
360
- createdAt: message.createdAt ?? msg.createdAt ?? createdAt,
361
- };
362
- return updatedMessage;
363
- }
364
- return msg;
365
- });
366
- return {
367
- ...prevMap,
368
- [message.threadId]: {
369
- ...prevMap[message.threadId],
370
- messages: updatedMessages,
371
- },
372
- };
373
- });
374
- if (sendToServer && message.content && message.role) {
375
- try {
376
- await client.beta.threads.messages.create(message.threadId, {
377
- content: message.content,
378
- role: message.role,
379
- additionalContext: message.additionalContext,
380
- });
381
- }
382
- catch (error) {
383
- console.error("Failed to update message on server", error);
384
- // Revert local state update by removing the optimistic message
385
- setThreadMap((prev) => {
386
- const updatedMessages = prev[message.threadId]?.messages?.filter((msg) => msg.id !== id);
387
- return {
388
- ...prev,
389
- [message.threadId]: {
390
- ...prev[message.threadId],
391
- messages: updatedMessages,
392
- },
393
- };
394
- });
395
- throw error;
396
- }
397
- }
398
- }, [client.beta.threads.messages]);
399
- const generateThreadName = (0, react_1.useCallback)(async (threadId, contextKey) => {
400
- threadId ??= currentThreadId;
401
- if (threadId === placeholderThread.id) {
402
- console.warn("Cannot generate name for empty thread");
403
- return threadMap[threadId];
404
- }
405
- const threadWithGeneratedName = await client.beta.threads.generateName(threadId);
406
- // Update local thread state
407
- setThreadMap((prevMap) => {
408
- if (!prevMap[threadId]) {
409
- return prevMap;
410
- }
411
- return {
412
- ...prevMap,
413
- [threadId]: {
414
- ...prevMap[threadId],
415
- name: threadWithGeneratedName.name,
416
- },
417
- };
418
- });
419
- // Update threads cache to reflect the new name in the UI
420
- await updateThreadInCache(threadId, (thread) => ({
421
- ...thread,
422
- name: threadWithGeneratedName.name,
423
- }), contextKey);
424
- return threadWithGeneratedName;
425
- }, [
426
- client.beta.threads,
427
- currentThreadId,
428
- threadMap,
429
- placeholderThread.id,
430
- updateThreadInCache,
431
- ]);
432
- const maybeAutoGenerateThreadName = (0, react_1.useCallback)((threadId, contextKey) => {
433
- // Use setThreadMap to access the latest state
434
- setThreadMap((map) => {
435
- const thread = map[threadId];
436
- if (!thread || !autoGenerateThreadName) {
437
- return map;
438
- }
439
- if (autoGenerateNameThreshold == null ||
440
- thread.id === placeholderThread.id) {
441
- return map;
442
- }
443
- const messageCount = thread.messages.length;
444
- // Only auto-generate if thread has no name and threshold is met
445
- if (!thread.name && messageCount >= autoGenerateNameThreshold) {
446
- // Generating a thread name is not critical, so we can fire-and-forget
447
- void generateThreadName(threadId, contextKey).catch((error) => {
448
- console.error("Failed to generate thread name:", error);
449
- });
450
- }
451
- return map;
452
- });
453
- }, [
454
- autoGenerateThreadName,
455
- autoGenerateNameThreshold,
456
- placeholderThread.id,
457
- generateThreadName,
458
- ]);
459
- const startNewThread = (0, react_1.useCallback)(() => {
460
- setCurrentThreadId(placeholderThread.id);
461
- setThreadMap((prevMap) => {
462
- return {
463
- ...prevMap,
464
- [placeholderThread.id]: placeholderThread,
465
- };
466
- });
467
- }, [placeholderThread]);
468
- const updateThreadName = (0, react_1.useCallback)(async (name, threadId) => {
469
- threadId ??= currentThreadId;
470
- const previousName = threadMap[threadId]?.name;
471
- setThreadMap((prevMap) => {
472
- if (!prevMap[threadId]) {
473
- return prevMap;
474
- }
475
- return { ...prevMap, [threadId]: { ...prevMap[threadId], name } };
476
- });
477
- if (threadId !== placeholderThread.id) {
478
- try {
479
- const currentProject = await client.beta.projects.getCurrent();
480
- await client.beta.threads.update(threadId, {
481
- name,
482
- projectId: currentProject.id,
483
- });
484
- }
485
- catch (error) {
486
- console.error("Failed to update thread name on server", error);
487
- // Revert local state update
488
- setThreadMap((prevMap) => {
489
- if (!prevMap[threadId]) {
490
- return prevMap;
491
- }
492
- return {
493
- ...prevMap,
494
- [threadId]: { ...prevMap[threadId], name: previousName },
495
- };
496
- });
497
- throw error;
498
- }
499
- }
500
- }, [
501
- currentThreadId,
502
- client.beta.projects,
503
- client.beta.threads,
504
- placeholderThread.id,
505
- threadMap,
506
- ]);
507
- const switchCurrentThread = (0, react_1.useCallback)(async (threadId, fetch = true) => {
508
- if (threadId === placeholderThread.id) {
509
- console.warn("Switching to placeholder thread, may be a bug.");
510
- return;
511
- }
512
- setCurrentThreadId(threadId);
513
- setThreadMap((prevMap) => {
514
- if (prevMap[threadId]) {
515
- return prevMap;
516
- }
517
- // If this is a new thread, add placeholder thread messages to the thread
518
- const updatedThreadMap = {
519
- ...prevMap,
520
- [threadId]: {
521
- ...prevMap[placeholderThread.id],
522
- id: threadId,
523
- },
524
- };
525
- return updatedThreadMap;
526
- });
527
- if (fetch) {
528
- await fetchThread(threadId);
529
- }
530
- }, [fetchThread, placeholderThread]);
531
- const updateThreadStatus = (0, react_1.useCallback)((threadId, stage, statusMessage) => {
532
- setThreadMap((prevMap) => {
533
- const updatedThreadMap = {
534
- ...prevMap,
535
- [threadId]: {
536
- ...prevMap[threadId],
537
- generationStage: stage,
538
- statusMessage: statusMessage,
539
- },
540
- };
541
- return updatedThreadMap;
542
- });
543
- }, []);
544
- const cancel = (0, react_1.useCallback)(async (threadId) => {
545
- threadId ??= currentThreadId;
546
- const currentGenerationStage = currentThread?.generationStage ?? generate_component_response_1.GenerationStage.IDLE;
547
- if ((0, generate_component_response_1.isIdleStage)(currentGenerationStage)) {
548
- return;
549
- }
550
- setIgnoreResponse(true);
551
- setThreadMap((prevMap) => {
552
- if (!prevMap[threadId]) {
553
- return prevMap;
554
- }
555
- return {
556
- ...prevMap,
557
- [threadId]: {
558
- ...prevMap[threadId],
559
- generationStage: generate_component_response_1.GenerationStage.CANCELLED,
560
- messages: prevMap[threadId].messages.map((message) => {
561
- if (message.id ===
562
- prevMap[threadId].messages[prevMap[threadId].messages.length - 1].id) {
563
- return {
564
- ...message,
565
- isCancelled: true,
566
- };
567
- }
568
- return message;
569
- }),
570
- },
571
- };
572
- });
573
- await client.beta.threads.cancel(threadId);
574
- }, [client.beta.threads, currentThreadId, currentThread?.generationStage]);
575
- const handleAdvanceStream = (0, react_1.useCallback)(async (stream, params, threadId, contextKey) => {
576
- if (ignoreResponseRef.current) {
577
- setIgnoreResponse(false);
578
- return createEmptyMessage(threadId);
579
- }
580
- let finalMessage;
581
- let hasSetThreadId = false;
582
- updateThreadStatus(threadId, generate_component_response_1.GenerationStage.STREAMING_RESPONSE);
583
- for await (const chunk of stream) {
584
- // Store MCP access token in thread data
585
- if (chunk.mcpAccessToken) {
586
- // note that we're only setting it positively during streaming, because it might
587
- // not have been set yet in the chunk (i.e. we're not unsetting it in the chunk)
588
- setThreadMap((prev) => {
589
- const thread = prev[threadId];
590
- if (thread) {
591
- return {
592
- ...prev,
593
- [threadId]: {
594
- ...thread,
595
- mcpAccessToken: chunk.mcpAccessToken,
596
- },
597
- };
598
- }
599
- return prev;
600
- });
601
- }
602
- if (chunk.responseMessageDto.toolCallRequest) {
603
- const toolName = chunk.responseMessageDto.toolCallRequest.toolName;
604
- updateThreadStatus(chunk.responseMessageDto.threadId, generate_component_response_1.GenerationStage.FETCHING_CONTEXT);
605
- await updateThreadMessage(chunk.responseMessageDto.id, {
606
- ...chunk.responseMessageDto,
607
- }, false);
608
- const toolCallResponse = await (0, tool_caller_1.handleToolCall)(chunk.responseMessageDto.toolCallRequest, toolRegistry, onCallUnregisteredTool);
609
- if (ignoreResponseRef.current) {
610
- setIgnoreResponse(false);
611
- return createEmptyMessage(threadId);
612
- }
613
- const contentParts = await convertToolResponse(toolCallResponse);
614
- const toolCallResponseParams = {
615
- ...params,
616
- // Exclude initialMessages from tool response since thread already exists
617
- initialMessages: undefined,
618
- ...(toolName
619
- ? {
620
- toolCallCounts: {
621
- ...(params.toolCallCounts ?? {}),
622
- [toolName]: (params.toolCallCounts?.[toolName] ?? 0) + 1,
623
- },
624
- }
625
- : {}),
626
- messageToAppend: {
627
- content: contentParts,
628
- role: "tool",
629
- actionType: "tool_response",
630
- component: chunk.responseMessageDto.component,
631
- tool_call_id: chunk.responseMessageDto.tool_call_id,
632
- error: toolCallResponse.error,
633
- },
634
- };
635
- await updateThreadMessage(chunk.responseMessageDto.id, {
636
- ...chunk.responseMessageDto,
637
- error: toolCallResponse.error,
638
- }, false);
639
- await addThreadMessage({
640
- threadId: chunk.responseMessageDto.threadId,
641
- content: contentParts,
642
- role: "tool",
643
- id: crypto.randomUUID(),
644
- createdAt: new Date().toISOString(),
645
- componentState: {},
646
- actionType: "tool_response",
647
- tool_call_id: chunk.responseMessageDto.tool_call_id,
648
- error: toolCallResponse.error,
649
- }, false);
650
- updateThreadStatus(chunk.responseMessageDto.threadId, generate_component_response_1.GenerationStage.STREAMING_RESPONSE);
651
- const toolCallResponseStream = await (0, typescript_sdk_1.advanceStream)(client, toolCallResponseParams, chunk.responseMessageDto.threadId);
652
- return await handleAdvanceStream(toolCallResponseStream, toolCallResponseParams, chunk.responseMessageDto.threadId, contextKey);
653
- }
654
- else {
655
- if (ignoreResponseRef.current) {
656
- setIgnoreResponse(false);
657
- return finalMessage ?? createEmptyMessage(threadId);
658
- }
659
- if (!hasSetThreadId &&
660
- chunk.responseMessageDto.threadId &&
661
- chunk.responseMessageDto.threadId !== currentThread?.id) {
662
- hasSetThreadId = true;
663
- const wasPlaceholderThread = currentThreadId === exports.PLACEHOLDER_THREAD.id;
664
- await switchCurrentThread(chunk.responseMessageDto.threadId, false);
665
- // If we're switching from placeholder to a real thread
666
- // this means a new thread was created, so add it to cache
667
- if (wasPlaceholderThread) {
668
- await addThreadToCache(chunk.responseMessageDto.threadId, contextKey);
669
- // Check if we should auto-generate name for the newly created thread
670
- maybeAutoGenerateThreadName(chunk.responseMessageDto.threadId, contextKey);
671
- }
672
- }
673
- if (!finalMessage) {
674
- finalMessage = chunk.responseMessageDto.component?.componentName
675
- ? (0, generate_component_1.renderComponentIntoMessage)(chunk.responseMessageDto, componentList)
676
- : chunk.responseMessageDto;
677
- await addThreadMessage(finalMessage, false);
678
- }
679
- else {
680
- // Handle streaming tool calls
681
- if (chunk.responseMessageDto.component?.toolCallRequest) {
682
- const { toolName } = chunk.responseMessageDto.component.toolCallRequest;
683
- const tool = toolName ? toolRegistry[toolName] : undefined;
684
- // if there is a tool call request on a component in a streaming chunk, and the tool
685
- // is marked as streamable by the correct annotation, handle it
686
- const isStreamable = tool?.annotations?.tamboStreamableHint ?? false;
687
- if (isStreamable) {
688
- // We're not paying attention to the tool call response here - we only want the
689
- // final tool call which is handled by the presence of a toolCallRequest on the
690
- // top-level responseMessageDto
691
- // see above: `if (chunk.responseMessageDto.toolCallRequest) { ... }`
692
- void (await (0, tool_caller_1.handleToolCall)(chunk.responseMessageDto.component.toolCallRequest, toolRegistry, onCallUnregisteredTool));
693
- }
694
- }
695
- // Capture previous message ID before updating finalMessage
696
- const previousMessageId = finalMessage.id;
697
- if (chunk.responseMessageDto.component?.componentName) {
698
- finalMessage = (0, generate_component_1.renderComponentIntoMessage)(chunk.responseMessageDto, componentList);
699
- }
700
- else {
701
- finalMessage = chunk.responseMessageDto;
702
- }
703
- // if we start getting a new message mid-stream, put the previous one on screen
704
- const isNewMessage = chunk.responseMessageDto.id !== previousMessageId;
705
- if (isNewMessage) {
706
- await addThreadMessage(finalMessage, false);
707
- }
708
- else {
709
- await updateThreadMessage(finalMessage.id, finalMessage, false);
710
- }
711
- }
712
- }
713
- }
714
- const completedThreadId = finalMessage?.threadId ?? threadId;
715
- updateThreadStatus(completedThreadId, generate_component_response_1.GenerationStage.COMPLETE);
716
- maybeAutoGenerateThreadName(completedThreadId, contextKey);
717
- return (finalMessage ?? {
718
- ...createEmptyMessage(completedThreadId),
719
- content: [{ type: "text", text: "Error processing stream" }],
720
- });
721
- }, [
722
- addThreadMessage,
723
- addThreadToCache,
724
- maybeAutoGenerateThreadName,
725
- client,
726
- componentList,
727
- currentThread?.id,
728
- currentThreadId,
729
- onCallUnregisteredTool,
730
- switchCurrentThread,
731
- toolRegistry,
732
- updateThreadMessage,
733
- updateThreadStatus,
734
- ]);
735
- const sendThreadMessage = (0, react_1.useCallback)(async (message, options = {}) => {
736
- setIgnoreResponse(false);
737
- const { threadId = currentThreadId ?? placeholderThread.id, streamResponse = streaming, forceToolChoice, contextKey, additionalContext, content, } = options;
738
- if (!streamResponse) {
739
- throw new Error("Non-streaming mode is deprecated. Use streaming mode instead.");
740
- }
741
- updateThreadStatus(threadId, generate_component_response_1.GenerationStage.FETCHING_CONTEXT);
742
- // Get additional context from enabled helpers
743
- const helperContexts = await getAdditionalContext();
744
- // Combine all contexts
745
- const combinedContext = {
746
- ...(additionalContext ?? {}),
747
- };
748
- // Add helper contexts to combinedContext
749
- for (const helperContext of helperContexts) {
750
- combinedContext[helperContext.name] = helperContext.context;
751
- }
752
- // Build and optimistically add user message (for revert on fail)
753
- const optimiticMessageId = crypto.randomUUID();
754
- const messageContent = content ?? [
755
- { type: "text", text: message },
756
- ];
757
- await addThreadMessage({
758
- content: messageContent,
759
- renderedComponent: null,
760
- role: "user",
761
- threadId: threadId,
762
- id: optimiticMessageId,
763
- createdAt: new Date().toISOString(),
764
- componentState: {},
765
- additionalContext: combinedContext,
766
- }, false);
767
- maybeAutoGenerateThreadName(threadId, contextKey);
768
- const availableComponents = (0, registry_1.getAvailableComponents)(componentList, toolRegistry, componentToolAssociations);
769
- const unassociatedTools = (0, registry_1.getUnassociatedTools)(toolRegistry, componentToolAssociations);
770
- // Track tool call counts for this message processing
771
- const toolCallCounts = {};
772
- const params = {
773
- messageToAppend: {
774
- content: messageContent,
775
- role: "user",
776
- additionalContext: combinedContext,
777
- },
778
- contextKey,
779
- availableComponents: availableComponents,
780
- clientTools: unassociatedTools.map((tool) => (0, registry_1.mapTamboToolToContextTool)(tool)),
781
- forceToolChoice: forceToolChoice,
782
- toolCallCounts,
783
- ...(threadId === placeholderThread.id &&
784
- initialMessages.length > 0 && {
785
- initialMessages: initialMessages.map((msg) => ({
786
- content: msg.content,
787
- role: msg.role,
788
- additionalContext: msg.additionalContext,
789
- })),
790
- }),
791
- };
792
- let advanceStreamResponse;
793
- try {
794
- advanceStreamResponse = await (0, typescript_sdk_1.advanceStream)(client, params, threadId === placeholderThread.id ? undefined : threadId);
795
- }
796
- catch (error) {
797
- updateThreadStatus(threadId, generate_component_response_1.GenerationStage.ERROR);
798
- // Rollback the optimistic user message
799
- setThreadMap((prev) => {
800
- const thread = prev[threadId];
801
- if (!thread)
802
- return prev;
803
- return {
804
- ...prev,
805
- [threadId]: {
806
- ...thread,
807
- messages: thread.messages.filter((msg) => msg.id !== optimiticMessageId),
808
- },
809
- };
810
- });
811
- throw error;
812
- }
813
- try {
814
- const result = await handleAdvanceStream(advanceStreamResponse, params, threadId, contextKey);
815
- return result;
816
- }
817
- catch (error) {
818
- updateThreadStatus(threadId, generate_component_response_1.GenerationStage.ERROR);
819
- // Rollback the optimistic user message
820
- setThreadMap((prev) => {
821
- const thread = prev[threadId];
822
- if (!thread)
823
- return prev;
824
- return {
825
- ...prev,
826
- [threadId]: {
827
- ...thread,
828
- messages: thread.messages.filter((msg) => msg.id !== optimiticMessageId),
829
- },
830
- };
831
- });
832
- throw error;
833
- }
834
- }, [
835
- componentList,
836
- toolRegistry,
837
- componentToolAssociations,
838
- currentThreadId,
839
- addThreadMessage,
840
- client,
841
- updateThreadStatus,
842
- handleAdvanceStream,
843
- streaming,
844
- getAdditionalContext,
845
- placeholderThread.id,
846
- initialMessages,
847
- maybeAutoGenerateThreadName,
848
- ]);
849
- return (react_1.default.createElement(exports.TamboThreadContext.Provider, { value: {
850
- thread: currentThread,
851
- currentThreadId,
852
- currentThread,
853
- threadMap,
854
- setThreadMap,
855
- switchCurrentThread,
856
- startNewThread,
857
- updateThreadName,
858
- generateThreadName,
859
- addThreadMessage,
860
- updateThreadMessage,
861
- streaming,
862
- cancel,
863
- sendThreadMessage,
864
- contextKey,
865
- } },
866
- react_1.default.createElement(exports.TamboGenerationStageProvider, { generationStage: currentGenerationStage, statusMessage: currentStatusMessage }, children)));
867
- };
868
- exports.TamboThreadProvider = TamboThreadProvider;
869
- /**
870
- * The useTamboGenerationStage hook provides access to the generation stage context
871
- * to the descendants of the TamboThreadProvider.
872
- * @returns The generation stage context
873
- */
874
- const useTamboGenerationStage = () => {
875
- const generationStageContext = (0, react_1.useContext)(TamboGenerationStageContext);
876
- if (generationStageContext === undefined) {
877
- throw new Error("useTamboGenerationStage must be used within a TamboThreadProvider");
878
- }
879
- return generationStageContext;
880
- };
881
- exports.useTamboGenerationStage = useTamboGenerationStage;
882
- /**
883
- * The useTamboThread hook provides access to the current thread context
884
- * to the descendants of the TamboThreadProvider.
885
- * @returns All state and actions for the current thread
886
- */
887
- const useTamboThread = () => {
888
- const threadContext = (0, react_1.useContext)(exports.TamboThreadContext);
889
- const generationStageContext = (0, react_1.useContext)(TamboGenerationStageContext);
890
- if (threadContext === undefined) {
891
- throw new Error("useTamboThread must be used within a TamboThreadProvider");
892
- }
893
- if (generationStageContext === undefined) {
894
- throw new Error("useTamboThread must be used within a TamboThreadProvider");
895
- }
896
- return {
897
- ...threadContext,
898
- ...generationStageContext,
899
- };
900
- };
901
- exports.useTamboThread = useTamboThread;
902
- async function convertToolResponse(toolCallResponse) {
903
- // If the tool call errored, surface that as text so the model reliably sees the error
904
- if (toolCallResponse.error) {
905
- return [{ type: "text", text: (0, content_parts_1.toText)(toolCallResponse.result) }];
906
- }
907
- // Use custom transform when available
908
- if (toolCallResponse.tamboTool?.transformToContent) {
909
- return await toolCallResponse.tamboTool.transformToContent(
910
- // result shape is user-defined; let the transform decide how to handle it
911
- toolCallResponse.result);
912
- }
913
- // Default fallback to stringified text
914
- return [{ type: "text", text: (0, content_parts_1.toText)(toolCallResponse.result) }];
915
- }
916
- /**
917
- * Create a placeholder/cancelled message with default values
918
- * @param threadId - ID of the thread the message belongs to
919
- * @returns An empty TamboThreadMessage
920
- */
921
- function createEmptyMessage(threadId) {
922
- return {
923
- threadId,
924
- content: [{ type: "text", text: "" }],
925
- role: "assistant",
926
- createdAt: new Date().toISOString(),
927
- id: crypto.randomUUID(),
928
- componentState: {},
929
- };
930
- }
931
- //# sourceMappingURL=tambo-thread-provider.js.map