@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,8 +1,8 @@
1
1
  /**
2
- * Return type for useTamboV1ComponentState hook.
2
+ * Return type for useTamboComponentState hook.
3
3
  * Similar to useState but with additional metadata.
4
4
  */
5
- export type UseTamboV1ComponentStateReturn<S> = [
5
+ export type UseTamboComponentStateReturn<S> = [
6
6
  currentState: S,
7
7
  setState: (newState: S | ((prev: S) => S)) => void,
8
8
  meta: {
@@ -18,7 +18,8 @@ export type UseTamboV1ComponentStateReturn<S> = [
18
18
  * to the Tambo backend. Server-side state updates are also reflected
19
19
  * in the component.
20
20
  *
21
- * Must be used within a component rendered via the component renderer.
21
+ * Can be used within rendered components, interactable components, or
22
+ * components awaiting provider context (acts as plain useState until context is available).
22
23
  * @param keyName - The unique key to identify this state value within the component's state
23
24
  * @param initialValue - Initial value for the state (used if no server state exists)
24
25
  * @param debounceTime - Debounce time in milliseconds (default: 500ms)
@@ -26,7 +27,7 @@ export type UseTamboV1ComponentStateReturn<S> = [
26
27
  * @example
27
28
  * ```tsx
28
29
  * function Counter() {
29
- * const [count, setCount, { isPending }] = useTamboV1ComponentState('count', 0);
30
+ * const [count, setCount, { isPending }] = useTamboComponentState('count', 0);
30
31
  *
31
32
  * return (
32
33
  * <div>
@@ -39,6 +40,6 @@ export type UseTamboV1ComponentStateReturn<S> = [
39
40
  * }
40
41
  * ```
41
42
  */
42
- export declare function useTamboV1ComponentState<S = undefined>(keyName: string, initialValue?: S, debounceTime?: number): UseTamboV1ComponentStateReturn<S | undefined>;
43
- export declare function useTamboV1ComponentState<S>(keyName: string, initialValue: S, debounceTime?: number): UseTamboV1ComponentStateReturn<S>;
43
+ export declare function useTamboComponentState<S = undefined>(keyName: string, initialValue?: S, debounceTime?: number): UseTamboComponentStateReturn<S | undefined>;
44
+ export declare function useTamboComponentState<S>(keyName: string, initialValue: S, debounceTime?: number): UseTamboComponentStateReturn<S>;
44
45
  //# sourceMappingURL=use-tambo-v1-component-state.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-tambo-v1-component-state.d.ts","sourceRoot":"","sources":["../../../src/v1/hooks/use-tambo-v1-component-state.ts"],"names":[],"mappings":"AAqBA;;;GAGG;AACH,MAAM,MAAM,8BAA8B,CAAC,CAAC,IAAI;IAC9C,YAAY,EAAE,CAAC;IACf,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,IAAI;IAClD,IAAI,EAAE;QACJ,SAAS,EAAE,OAAO,CAAC;QACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;QACpB,KAAK,EAAE,MAAM,IAAI,CAAC;KACnB;CACF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,GAAG,SAAS,EACpD,OAAO,EAAE,MAAM,EACf,YAAY,CAAC,EAAE,CAAC,EAChB,YAAY,CAAC,EAAE,MAAM,GACpB,8BAA8B,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;AACjD,wBAAgB,wBAAwB,CAAC,CAAC,EACxC,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,CAAC,EACf,YAAY,CAAC,EAAE,MAAM,GACpB,8BAA8B,CAAC,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"use-tambo-v1-component-state.d.ts","sourceRoot":"","sources":["../../../src/v1/hooks/use-tambo-v1-component-state.ts"],"names":[],"mappings":"AA0BA;;;GAGG;AACH,MAAM,MAAM,4BAA4B,CAAC,CAAC,IAAI;IAC5C,YAAY,EAAE,CAAC;IACf,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,IAAI;IAClD,IAAI,EAAE;QACJ,SAAS,EAAE,OAAO,CAAC;QACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;QACpB,KAAK,EAAE,MAAM,IAAI,CAAC;KACnB;CACF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,GAAG,SAAS,EAClD,OAAO,EAAE,MAAM,EACf,YAAY,CAAC,EAAE,CAAC,EAChB,YAAY,CAAC,EAAE,MAAM,GACpB,4BAA4B,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;AAC/C,wBAAgB,sBAAsB,CAAC,CAAC,EACtC,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,CAAC,EACf,YAAY,CAAC,EAAE,MAAM,GACpB,4BAA4B,CAAC,CAAC,CAAC,CAAC"}
@@ -1,15 +1,19 @@
1
1
  "use strict";
2
2
  "use client";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.useTamboV1ComponentState = useTamboV1ComponentState;
4
+ exports.useTamboComponentState = useTamboComponentState;
5
5
  /**
6
- * useTamboV1ComponentState - Component State Hook for v1 API
6
+ * useTamboComponentState - Component State Hook
7
7
  *
8
8
  * Provides bidirectional state synchronization between React components
9
9
  * and the Tambo backend. State changes are debounced before syncing to
10
10
  * the server, and server state updates are reflected in the component.
11
11
  *
12
- * Must be used within a component rendered via the component renderer.
12
+ * Works in three modes:
13
+ * - **Rendered components**: syncs state bidirectionally with the server
14
+ * - **Interactable components**: syncs state via the interactable provider
15
+ * - **No context yet**: acts as plain useState (no side effects) until a
16
+ * provider wraps the component (e.g., first render before withTamboInteractable)
13
17
  */
14
18
  const react_1 = require("react");
15
19
  const use_debounce_1 = require("use-debounce");
@@ -17,20 +21,30 @@ const fast_equals_1 = require("fast-equals");
17
21
  const tambo_client_provider_1 = require("../../providers/tambo-client-provider");
18
22
  const tambo_interactable_provider_1 = require("../../providers/tambo-interactable-provider");
19
23
  const component_renderer_1 = require("../utils/component-renderer");
24
+ const tambo_v1_provider_1 = require("../providers/tambo-v1-provider");
20
25
  const tambo_v1_stream_context_1 = require("../providers/tambo-v1-stream-context");
21
26
  const thread_utils_1 = require("../utils/thread-utils");
22
- function useTamboV1ComponentState(keyName, initialValue, debounceTime = 500) {
27
+ function useTamboComponentState(keyName, initialValue, debounceTime = 500) {
23
28
  const client = (0, tambo_client_provider_1.useTamboClient)();
24
- const { componentId, threadId } = (0, component_renderer_1.useV1ComponentContent)();
29
+ const { userKey } = (0, tambo_v1_provider_1.useTamboConfig)();
30
+ const componentContent = (0, component_renderer_1.useComponentContentOptional)();
25
31
  const streamState = (0, tambo_v1_stream_context_1.useStreamState)();
26
32
  const { setInteractableState, getInteractableComponentState } = (0, tambo_interactable_provider_1.useTamboInteractable)();
27
- // Interactable components use threadId="" (set by withTamboInteractable)
28
- const isInteractable = threadId === "";
29
- // Find the component content to get server state (only for v1-rendered components)
30
- const componentContent = isInteractable
33
+ // componentContent is null on the first render of interactable components
34
+ // (before withTamboInteractable sets the interactableId and wraps with provider).
35
+ // When null, we act as plain useState with no side effects.
36
+ const isContextAvailable = componentContent !== null;
37
+ const componentId = componentContent?.componentId ?? "";
38
+ const threadId = componentContent?.threadId ?? "";
39
+ // Only treat as interactable when we have real context with threadId=""
40
+ // (set by withTamboInteractable). When context is missing entirely,
41
+ // neither interactable nor server-sync paths should run.
42
+ const isInteractable = isContextAvailable && threadId === "";
43
+ // Find the component content to get server state (only for rendered components)
44
+ const renderedContent = isInteractable
31
45
  ? undefined
32
46
  : (0, thread_utils_1.findComponentContent)(streamState, threadId, componentId);
33
- const serverState = componentContent?.state;
47
+ const serverState = renderedContent?.state;
34
48
  const serverValue = serverState?.[keyName];
35
49
  // For interactable components, read state from the interactable provider
36
50
  const interactableState = isInteractable
@@ -47,9 +61,9 @@ function useTamboV1ComponentState(keyName, initialValue, debounceTime = 500) {
47
61
  const hasPendingLocalChangeRef = (0, react_1.useRef)(false);
48
62
  // Track in-flight sync requests to avoid stale completions clearing pending state
49
63
  const syncSeqRef = (0, react_1.useRef)(0);
50
- // Debounced function to sync state to server (only used for v1-rendered components)
64
+ // Debounced function to sync state to server (only used for rendered components)
51
65
  const syncToServer = (0, use_debounce_1.useDebouncedCallback)(async (newState) => {
52
- if (isInteractable)
66
+ if (!isContextAvailable || isInteractable)
53
67
  return;
54
68
  const seq = ++syncSeqRef.current;
55
69
  setIsPending(true);
@@ -59,6 +73,7 @@ function useTamboV1ComponentState(keyName, initialValue, debounceTime = 500) {
59
73
  await client.threads.state.updateState(componentId, {
60
74
  threadId,
61
75
  state: { [keyName]: newState },
76
+ userKey,
62
77
  });
63
78
  // Clear pending flag after successful sync
64
79
  hasPendingLocalChangeRef.current = false;
@@ -68,7 +83,7 @@ function useTamboV1ComponentState(keyName, initialValue, debounceTime = 500) {
68
83
  hasPendingLocalChangeRef.current = false;
69
84
  const syncError = err instanceof Error ? err : new Error(String(err));
70
85
  setError(syncError);
71
- console.error(`[useTamboV1ComponentState] Failed to sync state for ${componentId}:`, syncError);
86
+ console.error(`[useTamboComponentState] Failed to sync state for ${componentId}:`, syncError);
72
87
  }
73
88
  finally {
74
89
  // Only clear isPending if this is the most recent request
@@ -83,18 +98,29 @@ function useTamboV1ComponentState(keyName, initialValue, debounceTime = 500) {
83
98
  const nextState = typeof newState === "function"
84
99
  ? newState(prev)
85
100
  : newState;
101
+ // No side effects when context isn't available yet (local-only update)
102
+ if (!isContextAvailable) {
103
+ return nextState;
104
+ }
86
105
  if (isInteractable) {
87
106
  // For interactable components, update the interactable provider's state
88
107
  setInteractableState(componentId, keyName, nextState);
89
108
  }
90
109
  else {
91
- // For v1-rendered components, trigger debounced sync to server
110
+ // For rendered components, trigger debounced sync to server
92
111
  hasPendingLocalChangeRef.current = true;
93
112
  void syncToServer(nextState);
94
113
  }
95
114
  return nextState;
96
115
  });
97
- }, [isInteractable, syncToServer, setInteractableState, componentId, keyName]);
116
+ }, [
117
+ isContextAvailable,
118
+ isInteractable,
119
+ syncToServer,
120
+ setInteractableState,
121
+ componentId,
122
+ keyName,
123
+ ]);
98
124
  // Set initial value in interactable state on mount if no existing state
99
125
  const existingInteractableState = isInteractable
100
126
  ? getInteractableComponentState(componentId)?.[keyName]
@@ -121,9 +147,9 @@ function useTamboV1ComponentState(keyName, initialValue, debounceTime = 500) {
121
147
  return;
122
148
  setLocalState((prev) => (0, fast_equals_1.deepEqual)(prev, interactableState) ? prev : interactableState);
123
149
  }, [isInteractable, interactableState]);
124
- // Sync from server state when it changes (e.g., from streaming events) - v1-rendered only
150
+ // Sync from server state when it changes (e.g., from streaming events) - rendered components only
125
151
  (0, react_1.useEffect)(() => {
126
- if (isInteractable)
152
+ if (!isContextAvailable || isInteractable)
127
153
  return;
128
154
  if (serverValue === undefined)
129
155
  return;
@@ -138,21 +164,21 @@ function useTamboV1ComponentState(keyName, initialValue, debounceTime = 500) {
138
164
  }
139
165
  // Use functional update to avoid localState in deps
140
166
  setLocalState((prev) => (0, fast_equals_1.deepEqual)(serverValue, prev) ? prev : serverValue);
141
- }, [isInteractable, serverValue]);
142
- // Flush pending updates on unmount (only for v1-rendered components)
167
+ }, [isContextAvailable, isInteractable, serverValue]);
168
+ // Flush pending updates on unmount (only for rendered components)
143
169
  (0, react_1.useEffect)(() => {
144
- if (isInteractable)
170
+ if (!isContextAvailable || isInteractable)
145
171
  return;
146
172
  return () => {
147
173
  void syncToServer.flush();
148
174
  };
149
- }, [isInteractable, syncToServer]);
150
- // Flush function for immediate sync (noop for interactable)
175
+ }, [isContextAvailable, isInteractable, syncToServer]);
176
+ // Flush function for immediate sync (noop when context is unavailable or interactable)
151
177
  const flush = (0, react_1.useCallback)(() => {
152
- if (isInteractable)
178
+ if (!isContextAvailable || isInteractable)
153
179
  return;
154
180
  void syncToServer.flush();
155
- }, [isInteractable, syncToServer]);
181
+ }, [isContextAvailable, isInteractable, syncToServer]);
156
182
  return [localState, setState, { isPending, error, flush }];
157
183
  }
158
184
  //# sourceMappingURL=use-tambo-v1-component-state.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-tambo-v1-component-state.js","sourceRoot":"","sources":["../../../src/v1/hooks/use-tambo-v1-component-state.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;AAyEb,4DA0KC;AAjPD;;;;;;;;GAQG;AAEH,iCAAiE;AACjE,+CAAoD;AACpD,6CAAwC;AACxC,iFAAuE;AACvE,6FAAmF;AACnF,oEAAoE;AACpE,kFAAsE;AACtE,wDAA6D;AAsD7D,SAAgB,wBAAwB,CACtC,OAAe,EACf,YAAgB,EAChB,YAAY,GAAG,GAAG;IAElB,MAAM,MAAM,GAAG,IAAA,sCAAc,GAAE,CAAC;IAChC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,IAAA,0CAAqB,GAAE,CAAC;IAC1D,MAAM,WAAW,GAAG,IAAA,wCAAc,GAAE,CAAC;IACrC,MAAM,EAAE,oBAAoB,EAAE,6BAA6B,EAAE,GAC3D,IAAA,kDAAoB,GAAE,CAAC;IAEzB,yEAAyE;IACzE,MAAM,cAAc,GAAG,QAAQ,KAAK,EAAE,CAAC;IAEvC,mFAAmF;IACnF,MAAM,gBAAgB,GAAG,cAAc;QACrC,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,IAAA,mCAAoB,EAAC,WAAW,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;IAC7D,MAAM,WAAW,GAAG,gBAAgB,EAAE,KAEzB,CAAC;IACd,MAAM,WAAW,GAAG,WAAW,EAAE,CAAC,OAAO,CAAkB,CAAC;IAE5D,yEAAyE;IACzE,MAAM,iBAAiB,GAAG,cAAc;QACtC,CAAC,CAAE,6BA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AAC,CAAC,CAAC,WAAW,CAClD,CAAC;IACJ,CAAC,EAAE,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC,CAAC;IAElC,qEAAqE;IACrE,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,cAAc;YAAE,OAAO;QAC3B,OAAO,GAAG,EAAE;YACV,KAAK,YAAY,CAAC,KAAK,EAAE,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC,CAAC;IAEnC,4DAA4D;IAC5D,MAAM,KAAK,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE;QAC7B,IAAI,cAAc;YAAE,OAAO;QAC3B,KAAK,YAAY,CAAC,KAAK,EAAE,CAAC;IAC5B,CAAC,EAAE,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC,CAAC;IAEnC,OAAO,CAAC,UAAU,EAAE,QAAQ,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;AAC7D,CAAC","sourcesContent":["\"use client\";\n\n/**\n * useTamboV1ComponentState - Component State Hook for v1 API\n *\n * Provides bidirectional state synchronization between React components\n * and the Tambo backend. State changes are debounced before syncing to\n * the server, and server state updates are reflected in the component.\n *\n * Must be used within a component rendered via the component renderer.\n */\n\nimport { useCallback, useEffect, useState, useRef } from \"react\";\nimport { useDebouncedCallback } from \"use-debounce\";\nimport { deepEqual } from \"fast-equals\";\nimport { useTamboClient } from \"../../providers/tambo-client-provider\";\nimport { useTamboInteractable } from \"../../providers/tambo-interactable-provider\";\nimport { useV1ComponentContent } from \"../utils/component-renderer\";\nimport { useStreamState } from \"../providers/tambo-v1-stream-context\";\nimport { findComponentContent } from \"../utils/thread-utils\";\n\n/**\n * Return type for useTamboV1ComponentState hook.\n * Similar to useState but with additional metadata.\n */\nexport type UseTamboV1ComponentStateReturn<S> = [\n currentState: S,\n setState: (newState: S | ((prev: S) => S)) => void,\n meta: {\n isPending: boolean;\n error: Error | null;\n flush: () => void;\n },\n];\n\n/**\n * Hook for managing component state with bidirectional server sync.\n *\n * This hook acts like useState but automatically syncs state changes\n * to the Tambo backend. Server-side state updates are also reflected\n * in the component.\n *\n * Must be used within a component rendered via the component renderer.\n * @param keyName - The unique key to identify this state value within the component's state\n * @param initialValue - Initial value for the state (used if no server state exists)\n * @param debounceTime - Debounce time in milliseconds (default: 500ms)\n * @returns Tuple of [currentState, setState, meta]\n * @example\n * ```tsx\n * function Counter() {\n * const [count, setCount, { isPending }] = useTamboV1ComponentState('count', 0);\n *\n * return (\n * <div>\n * <span>{count}</span>\n * <button onClick={() => setCount(c => c + 1)} disabled={isPending}>\n * Increment\n * </button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useTamboV1ComponentState<S = undefined>(\n keyName: string,\n initialValue?: S,\n debounceTime?: number,\n): UseTamboV1ComponentStateReturn<S | undefined>;\nexport function useTamboV1ComponentState<S>(\n keyName: string,\n initialValue: S,\n debounceTime?: number,\n): UseTamboV1ComponentStateReturn<S>;\nexport function useTamboV1ComponentState<S>(\n keyName: string,\n initialValue?: S,\n debounceTime = 500,\n): UseTamboV1ComponentStateReturn<S> {\n const client = useTamboClient();\n const { componentId, threadId } = useV1ComponentContent();\n const streamState = useStreamState();\n const { setInteractableState, getInteractableComponentState } =\n useTamboInteractable();\n\n // Interactable components use threadId=\"\" (set by withTamboInteractable)\n const isInteractable = threadId === \"\";\n\n // Find the component content to get server state (only for v1-rendered components)\n const componentContent = isInteractable\n ? undefined\n : findComponentContent(streamState, threadId, componentId);\n const serverState = componentContent?.state as\n | Record<string, unknown>\n | undefined;\n const serverValue = serverState?.[keyName] as S | undefined;\n\n // For interactable components, read state from the interactable provider\n const interactableState = isInteractable\n ? (getInteractableComponentState(componentId)?.[keyName] as S | undefined)\n : undefined;\n\n // Local state - initialized from interactable state, server state, or initial value\n const [localState, setLocalState] = useState<S>(\n () => interactableState ?? serverValue ?? (initialValue as S),\n );\n\n // Track pending state and errors\n const [isPending, setIsPending] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n\n // Track the last value we sent to avoid overwriting with stale server state\n const lastSentValueRef = useRef<S | undefined>(undefined);\n\n // Track whether there's a pending local change that hasn't synced yet\n const hasPendingLocalChangeRef = useRef(false);\n\n // Track in-flight sync requests to avoid stale completions clearing pending state\n const syncSeqRef = useRef(0);\n\n // Debounced function to sync state to server (only used for v1-rendered components)\n const syncToServer = useDebouncedCallback(async (newState: S) => {\n if (isInteractable) return;\n\n const seq = ++syncSeqRef.current;\n setIsPending(true);\n setError(null);\n lastSentValueRef.current = newState;\n\n try {\n await client.threads.state.updateState(componentId, {\n threadId,\n state: { [keyName]: newState },\n });\n // Clear pending flag after successful sync\n hasPendingLocalChangeRef.current = false;\n } catch (err) {\n // Clear pending flag on error to allow server reconciliation\n hasPendingLocalChangeRef.current = false;\n const syncError = err instanceof Error ? err : new Error(String(err));\n setError(syncError);\n console.error(\n `[useTamboV1ComponentState] Failed to sync state for ${componentId}:`,\n syncError,\n );\n } finally {\n // Only clear isPending if this is the most recent request\n if (seq === syncSeqRef.current) {\n setIsPending(false);\n }\n }\n }, debounceTime);\n\n // setState function that updates local state and syncs appropriately\n const setState = useCallback(\n (newState: S | ((prev: S) => S)) => {\n setLocalState((prev) => {\n const nextState =\n typeof newState === \"function\"\n ? (newState as (prev: S) => S)(prev)\n : newState;\n\n if (isInteractable) {\n // For interactable components, update the interactable provider's state\n setInteractableState(componentId, keyName, nextState);\n } else {\n // For v1-rendered components, trigger debounced sync to server\n hasPendingLocalChangeRef.current = true;\n void syncToServer(nextState);\n }\n\n return nextState;\n });\n },\n [isInteractable, syncToServer, setInteractableState, componentId, keyName],\n );\n\n // Set initial value in interactable state on mount if no existing state\n const existingInteractableState = isInteractable\n ? getInteractableComponentState(componentId)?.[keyName]\n : undefined;\n const shouldUpdateInteractableInitial =\n isInteractable &&\n existingInteractableState === undefined &&\n initialValue !== undefined;\n\n useEffect(() => {\n if (!shouldUpdateInteractableInitial) return;\n setInteractableState(componentId, keyName, initialValue!);\n }, [\n shouldUpdateInteractableInitial,\n componentId,\n keyName,\n initialValue,\n setInteractableState,\n ]);\n\n // Sync from interactable provider when state changes externally (e.g., from AI tool call)\n useEffect(() => {\n if (!isInteractable) return;\n if (interactableState === undefined) return;\n setLocalState((prev) =>\n deepEqual(prev, interactableState) ? prev : (interactableState as S),\n );\n }, [isInteractable, interactableState]);\n\n // Sync from server state when it changes (e.g., from streaming events) - v1-rendered only\n useEffect(() => {\n if (isInteractable) return;\n if (serverValue === undefined) return;\n\n // Don't overwrite local changes that haven't synced yet\n if (hasPendingLocalChangeRef.current) return;\n\n // Only sync if the server value is different from what we last sent\n // This prevents overwriting local state with stale server values\n if (\n lastSentValueRef.current !== undefined &&\n deepEqual(serverValue, lastSentValueRef.current)\n ) {\n return;\n }\n\n // Use functional update to avoid localState in deps\n setLocalState((prev) =>\n deepEqual(serverValue, prev) ? prev : serverValue,\n );\n }, [isInteractable, serverValue]);\n\n // Flush pending updates on unmount (only for v1-rendered components)\n useEffect(() => {\n if (isInteractable) return;\n return () => {\n void syncToServer.flush();\n };\n }, [isInteractable, syncToServer]);\n\n // Flush function for immediate sync (noop for interactable)\n const flush = useCallback(() => {\n if (isInteractable) return;\n void syncToServer.flush();\n }, [isInteractable, syncToServer]);\n\n return [localState, setState, { isPending, error, flush }];\n}\n"]}
1
+ {"version":3,"file":"use-tambo-v1-component-state.js","sourceRoot":"","sources":["../../../src/v1/hooks/use-tambo-v1-component-state.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;AA+Eb,wDAiMC;AA9QD;;;;;;;;;;;;GAYG;AAEH,iCAAiE;AACjE,+CAAoD;AACpD,6CAAwC;AACxC,iFAAuE;AACvE,6FAAmF;AACnF,oEAA0E;AAC1E,sEAAgE;AAChE,kFAAsE;AACtE,wDAA6D;AAuD7D,SAAgB,sBAAsB,CACpC,OAAe,EACf,YAAgB,EAChB,YAAY,GAAG,GAAG;IAElB,MAAM,MAAM,GAAG,IAAA,sCA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QACb,IAAI,CAAC,kBAAkB,IAAI,cAAc;YAAE,OAAO;QAClD,OAAO,GAAG,EAAE;YACV,KAAK,YAAY,CAAC,KAAK,EAAE,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,kBAAkB,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC,CAAC;IAEvD,uFAAuF;IACvF,MAAM,KAAK,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE;QAC7B,IAAI,CAAC,kBAAkB,IAAI,cAAc;YAAE,OAAO;QAClD,KAAK,YAAY,CAAC,KAAK,EAAE,CAAC;IAC5B,CAAC,EAAE,CAAC,kBAAkB,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC,CAAC;IAEvD,OAAO,CAAC,UAAU,EAAE,QAAQ,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;AAC7D,CAAC","sourcesContent":["\"use client\";\n\n/**\n * useTamboComponentState - Component State Hook\n *\n * Provides bidirectional state synchronization between React components\n * and the Tambo backend. State changes are debounced before syncing to\n * the server, and server state updates are reflected in the component.\n *\n * Works in three modes:\n * - **Rendered components**: syncs state bidirectionally with the server\n * - **Interactable components**: syncs state via the interactable provider\n * - **No context yet**: acts as plain useState (no side effects) until a\n * provider wraps the component (e.g., first render before withTamboInteractable)\n */\n\nimport { useCallback, useEffect, useState, useRef } from \"react\";\nimport { useDebouncedCallback } from \"use-debounce\";\nimport { deepEqual } from \"fast-equals\";\nimport { useTamboClient } from \"../../providers/tambo-client-provider\";\nimport { useTamboInteractable } from \"../../providers/tambo-interactable-provider\";\nimport { useComponentContentOptional } from \"../utils/component-renderer\";\nimport { useTamboConfig } from \"../providers/tambo-v1-provider\";\nimport { useStreamState } from \"../providers/tambo-v1-stream-context\";\nimport { findComponentContent } from \"../utils/thread-utils\";\n\n/**\n * Return type for useTamboComponentState hook.\n * Similar to useState but with additional metadata.\n */\nexport type UseTamboComponentStateReturn<S> = [\n currentState: S,\n setState: (newState: S | ((prev: S) => S)) => void,\n meta: {\n isPending: boolean;\n error: Error | null;\n flush: () => void;\n },\n];\n\n/**\n * Hook for managing component state with bidirectional server sync.\n *\n * This hook acts like useState but automatically syncs state changes\n * to the Tambo backend. Server-side state updates are also reflected\n * in the component.\n *\n * Can be used within rendered components, interactable components, or\n * components awaiting provider context (acts as plain useState until context is available).\n * @param keyName - The unique key to identify this state value within the component's state\n * @param initialValue - Initial value for the state (used if no server state exists)\n * @param debounceTime - Debounce time in milliseconds (default: 500ms)\n * @returns Tuple of [currentState, setState, meta]\n * @example\n * ```tsx\n * function Counter() {\n * const [count, setCount, { isPending }] = useTamboComponentState('count', 0);\n *\n * return (\n * <div>\n * <span>{count}</span>\n * <button onClick={() => setCount(c => c + 1)} disabled={isPending}>\n * Increment\n * </button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useTamboComponentState<S = undefined>(\n keyName: string,\n initialValue?: S,\n debounceTime?: number,\n): UseTamboComponentStateReturn<S | undefined>;\nexport function useTamboComponentState<S>(\n keyName: string,\n initialValue: S,\n debounceTime?: number,\n): UseTamboComponentStateReturn<S>;\nexport function useTamboComponentState<S>(\n keyName: string,\n initialValue?: S,\n debounceTime = 500,\n): UseTamboComponentStateReturn<S> {\n const client = useTamboClient();\n const { userKey } = useTamboConfig();\n const componentContent = useComponentContentOptional();\n const streamState = useStreamState();\n const { setInteractableState, getInteractableComponentState } =\n useTamboInteractable();\n\n // componentContent is null on the first render of interactable components\n // (before withTamboInteractable sets the interactableId and wraps with provider).\n // When null, we act as plain useState with no side effects.\n const isContextAvailable = componentContent !== null;\n const componentId = componentContent?.componentId ?? \"\";\n const threadId = componentContent?.threadId ?? \"\";\n\n // Only treat as interactable when we have real context with threadId=\"\"\n // (set by withTamboInteractable). When context is missing entirely,\n // neither interactable nor server-sync paths should run.\n const isInteractable = isContextAvailable && threadId === \"\";\n\n // Find the component content to get server state (only for rendered components)\n const renderedContent = isInteractable\n ? undefined\n : findComponentContent(streamState, threadId, componentId);\n const serverState = renderedContent?.state as\n | Record<string, unknown>\n | undefined;\n const serverValue = serverState?.[keyName] as S | undefined;\n\n // For interactable components, read state from the interactable provider\n const interactableState = isInteractable\n ? (getInteractableComponentState(componentId)?.[keyName] as S | undefined)\n : undefined;\n\n // Local state - initialized from interactable state, server state, or initial value\n const [localState, setLocalState] = useState<S>(\n () => interactableState ?? serverValue ?? (initialValue as S),\n );\n\n // Track pending state and errors\n const [isPending, setIsPending] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n\n // Track the last value we sent to avoid overwriting with stale server state\n const lastSentValueRef = useRef<S | undefined>(undefined);\n\n // Track whether there's a pending local change that hasn't synced yet\n const hasPendingLocalChangeRef = useRef(false);\n\n // Track in-flight sync requests to avoid stale completions clearing pending state\n const syncSeqRef = useRef(0);\n\n // Debounced function to sync state to server (only used for rendered components)\n const syncToServer = useDebouncedCallback(async (newState: S) => {\n if (!isContextAvailable || isInteractable) return;\n\n const seq = ++syncSeqRef.current;\n setIsPending(true);\n setError(null);\n lastSentValueRef.current = newState;\n\n try {\n await client.threads.state.updateState(componentId, {\n threadId,\n state: { [keyName]: newState },\n userKey,\n });\n // Clear pending flag after successful sync\n hasPendingLocalChangeRef.current = false;\n } catch (err) {\n // Clear pending flag on error to allow server reconciliation\n hasPendingLocalChangeRef.current = false;\n const syncError = err instanceof Error ? err : new Error(String(err));\n setError(syncError);\n console.error(\n `[useTamboComponentState] Failed to sync state for ${componentId}:`,\n syncError,\n );\n } finally {\n // Only clear isPending if this is the most recent request\n if (seq === syncSeqRef.current) {\n setIsPending(false);\n }\n }\n }, debounceTime);\n\n // setState function that updates local state and syncs appropriately\n const setState = useCallback(\n (newState: S | ((prev: S) => S)) => {\n setLocalState((prev) => {\n const nextState =\n typeof newState === \"function\"\n ? (newState as (prev: S) => S)(prev)\n : newState;\n\n // No side effects when context isn't available yet (local-only update)\n if (!isContextAvailable) {\n return nextState;\n }\n\n if (isInteractable) {\n // For interactable components, update the interactable provider's state\n setInteractableState(componentId, keyName, nextState);\n } else {\n // For rendered components, trigger debounced sync to server\n hasPendingLocalChangeRef.current = true;\n void syncToServer(nextState);\n }\n\n return nextState;\n });\n },\n [\n isContextAvailable,\n isInteractable,\n syncToServer,\n setInteractableState,\n componentId,\n keyName,\n ],\n );\n\n // Set initial value in interactable state on mount if no existing state\n const existingInteractableState = isInteractable\n ? getInteractableComponentState(componentId)?.[keyName]\n : undefined;\n const shouldUpdateInteractableInitial =\n isInteractable &&\n existingInteractableState === undefined &&\n initialValue !== undefined;\n\n useEffect(() => {\n if (!shouldUpdateInteractableInitial) return;\n setInteractableState(componentId, keyName, initialValue!);\n }, [\n shouldUpdateInteractableInitial,\n componentId,\n keyName,\n initialValue,\n setInteractableState,\n ]);\n\n // Sync from interactable provider when state changes externally (e.g., from AI tool call)\n useEffect(() => {\n if (!isInteractable) return;\n if (interactableState === undefined) return;\n setLocalState((prev) =>\n deepEqual(prev, interactableState) ? prev : (interactableState as S),\n );\n }, [isInteractable, interactableState]);\n\n // Sync from server state when it changes (e.g., from streaming events) - rendered components only\n useEffect(() => {\n if (!isContextAvailable || isInteractable) return;\n if (serverValue === undefined) return;\n\n // Don't overwrite local changes that haven't synced yet\n if (hasPendingLocalChangeRef.current) return;\n\n // Only sync if the server value is different from what we last sent\n // This prevents overwriting local state with stale server values\n if (\n lastSentValueRef.current !== undefined &&\n deepEqual(serverValue, lastSentValueRef.current)\n ) {\n return;\n }\n\n // Use functional update to avoid localState in deps\n setLocalState((prev) =>\n deepEqual(serverValue, prev) ? prev : serverValue,\n );\n }, [isContextAvailable, isInteractable, serverValue]);\n\n // Flush pending updates on unmount (only for rendered components)\n useEffect(() => {\n if (!isContextAvailable || isInteractable) return;\n return () => {\n void syncToServer.flush();\n };\n }, [isContextAvailable, isInteractable, syncToServer]);\n\n // Flush function for immediate sync (noop when context is unavailable or interactable)\n const flush = useCallback(() => {\n if (!isContextAvailable || isInteractable) return;\n void syncToServer.flush();\n }, [isContextAvailable, isInteractable, syncToServer]);\n\n return [localState, setState, { isPending, error, flush }];\n}\n"]}
@@ -10,10 +10,13 @@ jest.mock("../providers/tambo-v1-stream-context", () => ({
10
10
  useStreamState: jest.fn(),
11
11
  }));
12
12
  jest.mock("../utils/component-renderer", () => ({
13
- useV1ComponentContent: jest.fn(),
13
+ useComponentContentOptional: jest.fn(),
14
14
  }));
15
15
  const mockSetInteractableState = jest.fn();
16
16
  const mockGetInteractableComponentState = jest.fn(() => undefined);
17
+ jest.mock("../providers/tambo-v1-provider", () => ({
18
+ useTamboConfig: jest.fn(() => ({})),
19
+ }));
17
20
  jest.mock("../../providers/tambo-interactable-provider", () => ({
18
21
  useTamboInteractable: () => ({
19
22
  interactableComponents: [],
@@ -43,10 +46,11 @@ jest.mock("use-debounce", () => ({
43
46
  }));
44
47
  // Import the mocked modules
45
48
  const tambo_client_provider_1 = require("../../providers/tambo-client-provider");
49
+ const tambo_v1_provider_1 = require("../providers/tambo-v1-provider");
46
50
  const tambo_v1_stream_context_1 = require("../providers/tambo-v1-stream-context");
47
51
  const component_renderer_1 = require("../utils/component-renderer");
48
52
  const use_debounce_1 = require("use-debounce");
49
- describe("useTamboV1ComponentState", () => {
53
+ describe("useTamboComponentState", () => {
50
54
  const mockUpdateState = jest.fn();
51
55
  const mockComponentId = "comp_test123";
52
56
  const mockThreadId = "thread_abc";
@@ -87,6 +91,7 @@ describe("useTamboV1ComponentState", () => {
87
91
  });
88
92
  beforeEach(() => {
89
93
  jest.clearAllMocks();
94
+ jest.mocked(tambo_v1_provider_1.useTamboConfig).mockReturnValue({});
90
95
  // Setup default mocks
91
96
  jest.mocked(tambo_client_provider_1.useTamboClient).mockReturnValue({
92
97
  threads: {
@@ -95,7 +100,7 @@ describe("useTamboV1ComponentState", () => {
95
100
  },
96
101
  },
97
102
  });
98
- jest.mocked(component_renderer_1.useV1ComponentContent).mockReturnValue({
103
+ jest.mocked(component_renderer_1.useComponentContentOptional).mockReturnValue({
99
104
  componentId: mockComponentId,
100
105
  threadId: mockThreadId,
101
106
  messageId: mockMessageId,
@@ -118,7 +123,7 @@ describe("useTamboV1ComponentState", () => {
118
123
  it("should initialize with initialValue when no server state exists", () => {
119
124
  const initialValue = "test-initial";
120
125
  jest.mocked(tambo_v1_stream_context_1.useStreamState).mockReturnValue(createMockStreamState({}));
121
- const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboV1ComponentState)("testKey", initialValue));
126
+ const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboComponentState)("testKey", initialValue));
122
127
  expect(result.current[0]).toBe(initialValue);
123
128
  });
124
129
  it("should use server state over initialValue", () => {
@@ -127,12 +132,12 @@ describe("useTamboV1ComponentState", () => {
127
132
  jest
128
133
  .mocked(tambo_v1_stream_context_1.useStreamState)
129
134
  .mockReturnValue(createMockStreamState({ testKey: serverValue }));
130
- const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboV1ComponentState)("testKey", initialValue));
135
+ const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboComponentState)("testKey", initialValue));
131
136
  expect(result.current[0]).toBe(serverValue);
132
137
  });
133
138
  it("should handle undefined initialValue gracefully", () => {
134
139
  jest.mocked(tambo_v1_stream_context_1.useStreamState).mockReturnValue(createMockStreamState({}));
135
- const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboV1ComponentState)("testKey"));
140
+ const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboComponentState)("testKey"));
136
141
  expect(result.current[0]).toBeUndefined();
137
142
  });
138
143
  it("should handle different data types correctly", () => {
@@ -147,7 +152,7 @@ describe("useTamboV1ComponentState", () => {
147
152
  jest
148
153
  .mocked(tambo_v1_stream_context_1.useStreamState)
149
154
  .mockReturnValue(createMockStreamState({ testKey: value }));
150
- const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboV1ComponentState)("testKey", value));
155
+ const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboComponentState)("testKey", value));
151
156
  expect(result.current[0]).toEqual(value);
152
157
  });
153
158
  });
@@ -158,7 +163,7 @@ describe("useTamboV1ComponentState", () => {
158
163
  jest
159
164
  .mocked(tambo_v1_stream_context_1.useStreamState)
160
165
  .mockReturnValue(createMockStreamState({ testKey: initialValue }));
161
- const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboV1ComponentState)("testKey", initialValue));
166
+ const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboComponentState)("testKey", initialValue));
162
167
  const newValue = "updated";
163
168
  (0, react_1.act)(() => {
164
169
  result.current[1](newValue);
@@ -170,7 +175,7 @@ describe("useTamboV1ComponentState", () => {
170
175
  jest
171
176
  .mocked(tambo_v1_stream_context_1.useStreamState)
172
177
  .mockReturnValue(createMockStreamState({ counter: initialValue }));
173
- const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboV1ComponentState)("counter", initialValue));
178
+ const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboComponentState)("counter", initialValue));
174
179
  (0, react_1.act)(() => {
175
180
  result.current[1]((prev) => (prev ?? 0) + 1);
176
181
  });
@@ -181,7 +186,7 @@ describe("useTamboV1ComponentState", () => {
181
186
  jest
182
187
  .mocked(tambo_v1_stream_context_1.useStreamState)
183
188
  .mockReturnValue(createMockStreamState({ testKey: initialValue }));
184
- const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboV1ComponentState)("testKey", initialValue));
189
+ const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboComponentState)("testKey", initialValue));
185
190
  const newValue = "updated";
186
191
  (0, react_1.act)(() => {
187
192
  result.current[1](newValue);
@@ -190,6 +195,7 @@ describe("useTamboV1ComponentState", () => {
190
195
  expect(mockUpdateState).toHaveBeenCalledWith(mockComponentId, {
191
196
  threadId: mockThreadId,
192
197
  state: { testKey: newValue },
198
+ userKey: undefined,
193
199
  });
194
200
  });
195
201
  it("should work with complex objects", () => {
@@ -197,7 +203,7 @@ describe("useTamboV1ComponentState", () => {
197
203
  jest
198
204
  .mocked(tambo_v1_stream_context_1.useStreamState)
199
205
  .mockReturnValue(createMockStreamState({ data: initialValue }));
200
- const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboV1ComponentState)("data", initialValue));
206
+ const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboComponentState)("data", initialValue));
201
207
  const newValue = { name: "updated", items: [4, 5, 6] };
202
208
  (0, react_1.act)(() => {
203
209
  result.current[1](newValue);
@@ -208,7 +214,7 @@ describe("useTamboV1ComponentState", () => {
208
214
  describe("Metadata", () => {
209
215
  it("should return isPending and error in meta", () => {
210
216
  jest.mocked(tambo_v1_stream_context_1.useStreamState).mockReturnValue(createMockStreamState({}));
211
- const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboV1ComponentState)("testKey", "initial"));
217
+ const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboComponentState)("testKey", "initial"));
212
218
  expect(result.current[2]).toEqual({
213
219
  isPending: false,
214
220
  error: null,
@@ -221,7 +227,7 @@ describe("useTamboV1ComponentState", () => {
221
227
  mockDebouncedFn.flush = mockFlush;
222
228
  jest.mocked(use_debounce_1.useDebouncedCallback).mockReturnValue(mockDebouncedFn);
223
229
  jest.mocked(tambo_v1_stream_context_1.useStreamState).mockReturnValue(createMockStreamState({}));
224
- const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboV1ComponentState)("testKey", "initial"));
230
+ const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboComponentState)("testKey", "initial"));
225
231
  (0, react_1.act)(() => {
226
232
  result.current[2].flush();
227
233
  });
@@ -231,13 +237,13 @@ describe("useTamboV1ComponentState", () => {
231
237
  describe("Debouncing Behavior", () => {
232
238
  it("should use default debounce time of 500ms", () => {
233
239
  jest.mocked(tambo_v1_stream_context_1.useStreamState).mockReturnValue(createMockStreamState({}));
234
- (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboV1ComponentState)("testKey", "initial"));
240
+ (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboComponentState)("testKey", "initial"));
235
241
  expect(use_debounce_1.useDebouncedCallback).toHaveBeenCalledWith(expect.any(Function), 500);
236
242
  });
237
243
  it("should use custom debounce time when provided", () => {
238
244
  jest.mocked(tambo_v1_stream_context_1.useStreamState).mockReturnValue(createMockStreamState({}));
239
245
  const customDebounceTime = 1000;
240
- (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboV1ComponentState)("testKey", "initial", customDebounceTime));
246
+ (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboComponentState)("testKey", "initial", customDebounceTime));
241
247
  expect(use_debounce_1.useDebouncedCallback).toHaveBeenCalledWith(expect.any(Function), customDebounceTime);
242
248
  });
243
249
  it("should flush debounced callback on unmount", () => {
@@ -246,7 +252,7 @@ describe("useTamboV1ComponentState", () => {
246
252
  mockDebouncedFn.flush = mockFlush;
247
253
  jest.mocked(use_debounce_1.useDebouncedCallback).mockReturnValue(mockDebouncedFn);
248
254
  jest.mocked(tambo_v1_stream_context_1.useStreamState).mockReturnValue(createMockStreamState({}));
249
- const { unmount } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboV1ComponentState)("testKey", "initial"));
255
+ const { unmount } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboComponentState)("testKey", "initial"));
250
256
  unmount();
251
257
  expect(mockFlush).toHaveBeenCalled();
252
258
  });
@@ -255,7 +261,7 @@ describe("useTamboV1ComponentState", () => {
255
261
  it("should sync with server state changes from streaming", () => {
256
262
  const streamState = createMockStreamState({ testKey: "initial" });
257
263
  jest.mocked(tambo_v1_stream_context_1.useStreamState).mockReturnValue(streamState);
258
- const { result, rerender } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboV1ComponentState)("testKey", "initial"));
264
+ const { result, rerender } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboComponentState)("testKey", "initial"));
259
265
  expect(result.current[0]).toBe("initial");
260
266
  // Simulate server state change from streaming
261
267
  const updatedStreamState = createMockStreamState({
@@ -271,7 +277,7 @@ describe("useTamboV1ComponentState", () => {
271
277
  threadMap: {},
272
278
  currentThreadId: "placeholder",
273
279
  });
274
- const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboV1ComponentState)("testKey", "default"));
280
+ const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboComponentState)("testKey", "default"));
275
281
  expect(result.current[0]).toBe("default");
276
282
  });
277
283
  });
@@ -290,7 +296,7 @@ describe("useTamboV1ComponentState", () => {
290
296
  });
291
297
  jest.mocked(tambo_v1_stream_context_1.useStreamState).mockReturnValue(createMockStreamState({}));
292
298
  const consoleSpy = jest.spyOn(console, "error").mockImplementation();
293
- const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboV1ComponentState)("testKey", "initial"));
299
+ const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboComponentState)("testKey", "initial"));
294
300
  await (0, react_1.act)(async () => {
295
301
  result.current[1]("new-value");
296
302
  // Wait for async operations
@@ -301,20 +307,39 @@ describe("useTamboV1ComponentState", () => {
301
307
  });
302
308
  });
303
309
  describe("Context Requirements", () => {
304
- it("should throw when used outside component content context", () => {
305
- jest.mocked(component_renderer_1.useV1ComponentContent).mockImplementation(() => {
306
- throw new Error("useV1ComponentContent must be used within a rendered component");
310
+ it("should act as plain useState when component content context is missing", () => {
311
+ jest.mocked(component_renderer_1.useComponentContentOptional).mockReturnValue(null);
312
+ jest.mocked(tambo_v1_stream_context_1.useStreamState).mockReturnValue({
313
+ threadMap: {},
314
+ currentThreadId: "",
315
+ });
316
+ const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboComponentState)("testKey", "initial"));
317
+ expect(result.current[0]).toBe("initial");
318
+ // No side effects when context is missing
319
+ expect(mockSetInteractableState).not.toHaveBeenCalled();
320
+ expect(mockUpdateState).not.toHaveBeenCalled();
321
+ });
322
+ it("should not trigger side effects on setState when context is missing", () => {
323
+ jest.mocked(component_renderer_1.useComponentContentOptional).mockReturnValue(null);
324
+ jest.mocked(tambo_v1_stream_context_1.useStreamState).mockReturnValue({
325
+ threadMap: {},
326
+ currentThreadId: "",
307
327
  });
308
- expect(() => {
309
- (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboV1ComponentState)("testKey", "initial"));
310
- }).toThrow("useV1ComponentContent must be used within a rendered component");
328
+ const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboComponentState)("testKey", "initial"));
329
+ (0, react_1.act)(() => {
330
+ result.current[1]("updated");
331
+ });
332
+ // Local state updates, but no server sync or interactable writes
333
+ expect(result.current[0]).toBe("updated");
334
+ expect(mockSetInteractableState).not.toHaveBeenCalled();
335
+ expect(mockUpdateState).not.toHaveBeenCalled();
311
336
  });
312
337
  });
313
338
  describe("Interactable Component Support", () => {
314
339
  const interactableComponentId = "MyWidget-abc";
315
340
  beforeEach(() => {
316
341
  // Simulate interactable context: threadId="" signals interactable
317
- jest.mocked(component_renderer_1.useV1ComponentContent).mockReturnValue({
342
+ jest.mocked(component_renderer_1.useComponentContentOptional).mockReturnValue({
318
343
  componentId: interactableComponentId,
319
344
  threadId: "",
320
345
  messageId: "",
@@ -328,17 +353,17 @@ describe("useTamboV1ComponentState", () => {
328
353
  });
329
354
  it("should initialize with initialValue when no interactable state exists", () => {
330
355
  mockGetInteractableComponentState.mockReturnValue(undefined);
331
- const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboV1ComponentState)("count", 42));
356
+ const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboComponentState)("count", 42));
332
357
  expect(result.current[0]).toBe(42);
333
358
  });
334
359
  it("should initialize from interactable state when it exists", () => {
335
360
  mockGetInteractableComponentState.mockReturnValue({ count: 99 });
336
- const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboV1ComponentState)("count", 0));
361
+ const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboComponentState)("count", 0));
337
362
  expect(result.current[0]).toBe(99);
338
363
  });
339
364
  it("should call setInteractableState when setState is called", () => {
340
365
  mockGetInteractableComponentState.mockReturnValue(undefined);
341
- const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboV1ComponentState)("count", 0));
366
+ const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboComponentState)("count", 0));
342
367
  (0, react_1.act)(() => {
343
368
  result.current[1](10);
344
369
  });
@@ -346,7 +371,7 @@ describe("useTamboV1ComponentState", () => {
346
371
  });
347
372
  it("should NOT call client.threads.state.updateState for interactable components", () => {
348
373
  mockGetInteractableComponentState.mockReturnValue(undefined);
349
- const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboV1ComponentState)("count", 0));
374
+ const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboComponentState)("count", 0));
350
375
  (0, react_1.act)(() => {
351
376
  result.current[1](10);
352
377
  });
@@ -354,7 +379,7 @@ describe("useTamboV1ComponentState", () => {
354
379
  });
355
380
  it("should sync from interactable provider when state changes externally", () => {
356
381
  mockGetInteractableComponentState.mockReturnValue({ count: 0 });
357
- const { result, rerender } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboV1ComponentState)("count", 0));
382
+ const { result, rerender } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboComponentState)("count", 0));
358
383
  expect(result.current[0]).toBe(0);
359
384
  // Simulate external state change (e.g., AI tool call)
360
385
  mockGetInteractableComponentState.mockReturnValue({ count: 77 });
@@ -363,18 +388,18 @@ describe("useTamboV1ComponentState", () => {
363
388
  });
364
389
  it("should have isPending as false in interactable context", () => {
365
390
  mockGetInteractableComponentState.mockReturnValue(undefined);
366
- const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboV1ComponentState)("count", 0));
391
+ const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboComponentState)("count", 0));
367
392
  expect(result.current[2].isPending).toBe(false);
368
393
  expect(result.current[2].error).toBeNull();
369
394
  });
370
395
  it("should set initial value in interactable state on mount when no existing state", () => {
371
396
  mockGetInteractableComponentState.mockReturnValue(undefined);
372
- (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboV1ComponentState)("count", 42));
397
+ (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboComponentState)("count", 42));
373
398
  expect(mockSetInteractableState).toHaveBeenCalledWith(interactableComponentId, "count", 42);
374
399
  });
375
400
  it("should NOT set initial value in interactable state when state already exists", () => {
376
401
  mockGetInteractableComponentState.mockReturnValue({ count: 99 });
377
- (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboV1ComponentState)("count", 42));
402
+ (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboComponentState)("count", 42));
378
403
  // Should not be called because state already exists
379
404
  expect(mockSetInteractableState).not.toHaveBeenCalled();
380
405
  });
@@ -384,7 +409,7 @@ describe("useTamboV1ComponentState", () => {
384
409
  mockDebouncedFn.flush = mockFlush;
385
410
  jest.mocked(use_debounce_1.useDebouncedCallback).mockReturnValue(mockDebouncedFn);
386
411
  mockGetInteractableComponentState.mockReturnValue(undefined);
387
- const { unmount } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboV1ComponentState)("count", 0));
412
+ const { unmount } = (0, react_1.renderHook)(() => (0, use_tambo_v1_component_state_1.useTamboComponentState)("count", 0));
388
413
  unmount();
389
414
  expect(mockFlush).not.toHaveBeenCalled();
390
415
  });