@tambo-ai/react 0.73.0 → 0.74.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (419) hide show
  1. package/README.md +12 -12
  2. package/dist/hooks/use-component-state.d.ts +1 -1
  3. package/dist/hooks/use-component-state.js.map +1 -1
  4. package/dist/hooks/use-streaming-props.d.ts +1 -1
  5. package/dist/hooks/use-streaming-props.js +1 -1
  6. package/dist/hooks/use-streaming-props.js.map +1 -1
  7. package/dist/hooks/use-tambo-stream-status.d.ts +1 -1
  8. package/dist/hooks/use-tambo-stream-status.js +1 -1
  9. package/dist/hooks/use-tambo-stream-status.js.map +1 -1
  10. package/dist/mcp/mcp-hooks.d.ts +4 -0
  11. package/dist/mcp/mcp-hooks.d.ts.map +1 -1
  12. package/dist/mcp/mcp-hooks.js +4 -0
  13. package/dist/mcp/mcp-hooks.js.map +1 -1
  14. package/dist/providers/tambo-interactable-provider-partial-updates.test.js +3 -3
  15. package/dist/providers/tambo-interactable-provider-partial-updates.test.js.map +1 -1
  16. package/dist/providers/tambo-interactable-provider.js +2 -2
  17. package/dist/providers/tambo-interactable-provider.js.map +1 -1
  18. package/dist/providers/tambo-interactable-provider.test.js +3 -3
  19. package/dist/providers/tambo-interactable-provider.test.js.map +1 -1
  20. package/dist/providers/tambo-provider.d.ts +3 -0
  21. package/dist/providers/tambo-provider.d.ts.map +1 -1
  22. package/dist/providers/tambo-provider.js +3 -0
  23. package/dist/providers/tambo-provider.js.map +1 -1
  24. package/dist/providers/tambo-thread-input-provider.d.ts.map +1 -1
  25. package/dist/providers/tambo-thread-input-provider.js +1 -0
  26. package/dist/providers/tambo-thread-input-provider.js.map +1 -1
  27. package/dist/util/resource-content-resolver.d.ts.map +1 -1
  28. package/dist/util/resource-content-resolver.js +2 -0
  29. package/dist/util/resource-content-resolver.js.map +1 -1
  30. package/dist/v1/__tests__/v1-interactables.test.d.ts +2 -0
  31. package/dist/v1/__tests__/v1-interactables.test.d.ts.map +1 -0
  32. package/dist/v1/__tests__/v1-interactables.test.js +135 -0
  33. package/dist/v1/__tests__/v1-interactables.test.js.map +1 -0
  34. package/dist/v1/components/v1-component-renderer.d.ts +48 -0
  35. package/dist/v1/components/v1-component-renderer.d.ts.map +1 -0
  36. package/dist/v1/components/v1-component-renderer.js +137 -0
  37. package/dist/v1/components/v1-component-renderer.js.map +1 -0
  38. package/dist/v1/components/v1-component-renderer.test.d.ts +2 -0
  39. package/dist/v1/components/v1-component-renderer.test.d.ts.map +1 -0
  40. package/dist/v1/components/v1-component-renderer.test.js +270 -0
  41. package/dist/v1/components/v1-component-renderer.test.js.map +1 -0
  42. package/dist/v1/hooks/use-tambo-v1-component-state.d.ts.map +1 -1
  43. package/dist/v1/hooks/use-tambo-v1-component-state.js +2 -25
  44. package/dist/v1/hooks/use-tambo-v1-component-state.js.map +1 -1
  45. package/dist/v1/hooks/use-tambo-v1-component-state.test.js +2 -1
  46. package/dist/v1/hooks/use-tambo-v1-component-state.test.js.map +1 -1
  47. package/dist/v1/hooks/use-tambo-v1-messages.test.js +25 -1
  48. package/dist/v1/hooks/use-tambo-v1-messages.test.js.map +1 -1
  49. package/dist/v1/hooks/use-tambo-v1-send-message.d.ts +18 -0
  50. package/dist/v1/hooks/use-tambo-v1-send-message.d.ts.map +1 -1
  51. package/dist/v1/hooks/use-tambo-v1-send-message.js +204 -17
  52. package/dist/v1/hooks/use-tambo-v1-send-message.js.map +1 -1
  53. package/dist/v1/hooks/use-tambo-v1-send-message.test.js +261 -7
  54. package/dist/v1/hooks/use-tambo-v1-send-message.test.js.map +1 -1
  55. package/dist/v1/hooks/use-tambo-v1-stream-status.d.ts +90 -0
  56. package/dist/v1/hooks/use-tambo-v1-stream-status.d.ts.map +1 -0
  57. package/dist/v1/hooks/use-tambo-v1-stream-status.js +179 -0
  58. package/dist/v1/hooks/use-tambo-v1-stream-status.js.map +1 -0
  59. package/dist/v1/hooks/use-tambo-v1-stream-status.test.d.ts +2 -0
  60. package/dist/v1/hooks/use-tambo-v1-stream-status.test.d.ts.map +1 -0
  61. package/dist/v1/hooks/use-tambo-v1-stream-status.test.js +371 -0
  62. package/dist/v1/hooks/use-tambo-v1-stream-status.test.js.map +1 -0
  63. package/dist/v1/hooks/use-tambo-v1-suggestions.d.ts +78 -54
  64. package/dist/v1/hooks/use-tambo-v1-suggestions.d.ts.map +1 -1
  65. package/dist/v1/hooks/use-tambo-v1-suggestions.js +153 -87
  66. package/dist/v1/hooks/use-tambo-v1-suggestions.js.map +1 -1
  67. package/dist/v1/hooks/use-tambo-v1-suggestions.test.js +213 -134
  68. package/dist/v1/hooks/use-tambo-v1-suggestions.test.js.map +1 -1
  69. package/dist/v1/hooks/use-tambo-v1-thread-input.test.js +148 -13
  70. package/dist/v1/hooks/use-tambo-v1-thread-input.test.js.map +1 -1
  71. package/dist/v1/hooks/use-tambo-v1-thread-list.d.ts +8 -21
  72. package/dist/v1/hooks/use-tambo-v1-thread-list.d.ts.map +1 -1
  73. package/dist/v1/hooks/use-tambo-v1-thread-list.js +11 -10
  74. package/dist/v1/hooks/use-tambo-v1-thread-list.js.map +1 -1
  75. package/dist/v1/hooks/use-tambo-v1-thread-list.test.js +37 -2
  76. package/dist/v1/hooks/use-tambo-v1-thread-list.test.js.map +1 -1
  77. package/dist/v1/hooks/use-tambo-v1-thread.d.ts +1 -1
  78. package/dist/v1/hooks/use-tambo-v1-thread.d.ts.map +1 -1
  79. package/dist/v1/hooks/use-tambo-v1-thread.js +2 -7
  80. package/dist/v1/hooks/use-tambo-v1-thread.js.map +1 -1
  81. package/dist/v1/hooks/use-tambo-v1-thread.test.js +2 -0
  82. package/dist/v1/hooks/use-tambo-v1-thread.test.js.map +1 -1
  83. package/dist/v1/hooks/use-tambo-v1.d.ts +12 -28
  84. package/dist/v1/hooks/use-tambo-v1.d.ts.map +1 -1
  85. package/dist/v1/hooks/use-tambo-v1.js +164 -31
  86. package/dist/v1/hooks/use-tambo-v1.js.map +1 -1
  87. package/dist/v1/hooks/use-tambo-v1.test.js +891 -18
  88. package/dist/v1/hooks/use-tambo-v1.test.js.map +1 -1
  89. package/dist/v1/index.d.ts +7 -1
  90. package/dist/v1/index.d.ts.map +1 -1
  91. package/dist/v1/index.js +18 -1
  92. package/dist/v1/index.js.map +1 -1
  93. package/dist/v1/providers/tambo-v1-provider.d.ts +16 -6
  94. package/dist/v1/providers/tambo-v1-provider.d.ts.map +1 -1
  95. package/dist/v1/providers/tambo-v1-provider.js +14 -19
  96. package/dist/v1/providers/tambo-v1-provider.js.map +1 -1
  97. package/dist/v1/providers/tambo-v1-provider.test.js +34 -20
  98. package/dist/v1/providers/tambo-v1-provider.test.js.map +1 -1
  99. package/dist/v1/providers/tambo-v1-stream-context.d.ts +3 -3
  100. package/dist/v1/providers/tambo-v1-stream-context.d.ts.map +1 -1
  101. package/dist/v1/providers/tambo-v1-stream-context.js +60 -12
  102. package/dist/v1/providers/tambo-v1-stream-context.js.map +1 -1
  103. package/dist/v1/providers/tambo-v1-stream-context.test.js +49 -20
  104. package/dist/v1/providers/tambo-v1-stream-context.test.js.map +1 -1
  105. package/dist/v1/providers/tambo-v1-stub-provider.d.ts.map +1 -1
  106. package/dist/v1/providers/tambo-v1-stub-provider.js +2 -0
  107. package/dist/v1/providers/tambo-v1-stub-provider.js.map +1 -1
  108. package/dist/v1/providers/tambo-v1-stub-provider.test.js +7 -6
  109. package/dist/v1/providers/tambo-v1-stub-provider.test.js.map +1 -1
  110. package/dist/v1/providers/tambo-v1-thread-input-provider.d.ts +1 -6
  111. package/dist/v1/providers/tambo-v1-thread-input-provider.d.ts.map +1 -1
  112. package/dist/v1/providers/tambo-v1-thread-input-provider.js +14 -12
  113. package/dist/v1/providers/tambo-v1-thread-input-provider.js.map +1 -1
  114. package/dist/v1/types/event.d.ts +9 -1
  115. package/dist/v1/types/event.d.ts.map +1 -1
  116. package/dist/v1/types/event.js.map +1 -1
  117. package/dist/v1/types/event.test.js +5 -1
  118. package/dist/v1/types/event.test.js.map +1 -1
  119. package/dist/v1/types/message.d.ts +65 -7
  120. package/dist/v1/types/message.d.ts.map +1 -1
  121. package/dist/v1/types/message.js.map +1 -1
  122. package/dist/v1/types/thread.d.ts +4 -0
  123. package/dist/v1/types/thread.d.ts.map +1 -1
  124. package/dist/v1/types/thread.js.map +1 -1
  125. package/dist/v1/utils/event-accumulator.d.ts +40 -4
  126. package/dist/v1/utils/event-accumulator.d.ts.map +1 -1
  127. package/dist/v1/utils/event-accumulator.js +444 -35
  128. package/dist/v1/utils/event-accumulator.js.map +1 -1
  129. package/dist/v1/utils/event-accumulator.test.js +1041 -28
  130. package/dist/v1/utils/event-accumulator.test.js.map +1 -1
  131. package/dist/v1/utils/registry-conversion.d.ts +9 -9
  132. package/dist/v1/utils/registry-conversion.d.ts.map +1 -1
  133. package/dist/v1/utils/registry-conversion.js +10 -11
  134. package/dist/v1/utils/registry-conversion.js.map +1 -1
  135. package/dist/v1/utils/registry-conversion.test.js +39 -11
  136. package/dist/v1/utils/registry-conversion.test.js.map +1 -1
  137. package/dist/v1/utils/thread-utils.d.ts +16 -0
  138. package/dist/v1/utils/thread-utils.d.ts.map +1 -0
  139. package/dist/v1/utils/thread-utils.js +34 -0
  140. package/dist/v1/utils/thread-utils.js.map +1 -0
  141. package/dist/v1/utils/tool-executor.d.ts.map +1 -1
  142. package/dist/v1/utils/tool-executor.js +2 -0
  143. package/dist/v1/utils/tool-executor.js.map +1 -1
  144. package/dist/v1/utils/tool-executor.test.js +5 -0
  145. package/dist/v1/utils/tool-executor.test.js.map +1 -1
  146. package/esm/context-helpers/context-helpers-provider.test.js +2 -2
  147. package/esm/context-helpers/context-helpers.test.js +1 -1
  148. package/esm/context-helpers/current-interactables-context-helper.d.ts +1 -1
  149. package/esm/context-helpers/current-page-context-helper.d.ts +1 -1
  150. package/esm/context-helpers/current-time-context-helper.d.ts +1 -1
  151. package/esm/context-helpers/index.d.ts +4 -4
  152. package/esm/context-helpers/index.js +4 -4
  153. package/esm/hoc/with-tambo-interactable.d.ts +1 -1
  154. package/esm/hoc/with-tambo-interactable.js +2 -2
  155. package/esm/hoc/with-tambo-interactable.test.js +3 -3
  156. package/esm/hooks/index.d.ts +8 -8
  157. package/esm/hooks/index.js +8 -8
  158. package/esm/hooks/react-query-hooks.js +1 -1
  159. package/esm/hooks/use-component-state.d.ts +1 -1
  160. package/esm/hooks/use-component-state.js +3 -3
  161. package/esm/hooks/use-component-state.js.map +1 -1
  162. package/esm/hooks/use-component-state.test.js +5 -5
  163. package/esm/hooks/use-current-message.d.ts +1 -1
  164. package/esm/hooks/use-current-message.test.js +1 -1
  165. package/esm/hooks/use-message-images.test.js +1 -1
  166. package/esm/hooks/use-streaming-props.d.ts +1 -1
  167. package/esm/hooks/use-streaming-props.js +1 -1
  168. package/esm/hooks/use-streaming-props.js.map +1 -1
  169. package/esm/hooks/use-suggestions.d.ts +2 -2
  170. package/esm/hooks/use-suggestions.js +10 -10
  171. package/esm/hooks/use-suggestions.test.js +7 -7
  172. package/esm/hooks/use-tambo-stream-status.d.ts +1 -1
  173. package/esm/hooks/use-tambo-stream-status.js +4 -4
  174. package/esm/hooks/use-tambo-stream-status.js.map +1 -1
  175. package/esm/hooks/use-tambo-stream-status.test.js +4 -4
  176. package/esm/hooks/use-tambo-threads.js +3 -3
  177. package/esm/hooks/use-tambo-threads.test.js +3 -3
  178. package/esm/hooks/use-tambo-voice.js +2 -2
  179. package/esm/hooks/use-tambo-voice.test.js +3 -3
  180. package/esm/index.d.ts +22 -22
  181. package/esm/index.js +15 -15
  182. package/esm/mcp/elicitation.d.ts +1 -1
  183. package/esm/mcp/elicitation.test.js +1 -1
  184. package/esm/mcp/index.d.ts +7 -7
  185. package/esm/mcp/index.js +3 -3
  186. package/esm/mcp/mcp-client.d.ts +1 -1
  187. package/esm/mcp/mcp-client.js +1 -1
  188. package/esm/mcp/mcp-client.test.js +1 -1
  189. package/esm/mcp/mcp-hooks.d.ts +5 -1
  190. package/esm/mcp/mcp-hooks.d.ts.map +1 -1
  191. package/esm/mcp/mcp-hooks.js +8 -4
  192. package/esm/mcp/mcp-hooks.js.map +1 -1
  193. package/esm/mcp/mcp-hooks.test.js +6 -6
  194. package/esm/mcp/tambo-mcp-provider.d.ts +4 -4
  195. package/esm/mcp/tambo-mcp-provider.js +7 -7
  196. package/esm/mcp/tambo-mcp-provider.test.js +5 -5
  197. package/esm/mcp/use-mcp-servers.test.js +4 -4
  198. package/esm/model/generate-component-response.d.ts +1 -1
  199. package/esm/model/tambo-interactable.d.ts +1 -1
  200. package/esm/model/tambo-thread.d.ts +1 -1
  201. package/esm/providers/__tests__/thread-input-resource-resolution.test.js +3 -3
  202. package/esm/providers/hooks/use-tambo-session-token.test.js +1 -1
  203. package/esm/providers/index.d.ts +12 -12
  204. package/esm/providers/index.js +10 -10
  205. package/esm/providers/tambo-client-provider.js +1 -1
  206. package/esm/providers/tambo-client-provider.test.js +2 -2
  207. package/esm/providers/tambo-component-provider.d.ts +1 -1
  208. package/esm/providers/tambo-component-provider.js +2 -2
  209. package/esm/providers/tambo-context-attachment-provider.js +1 -1
  210. package/esm/providers/tambo-context-attachment-provider.test.js +2 -2
  211. package/esm/providers/tambo-context-helpers-provider.d.ts +1 -1
  212. package/esm/providers/tambo-context-helpers-provider.js +1 -1
  213. package/esm/providers/tambo-context-helpers-provider.test.js +2 -2
  214. package/esm/providers/tambo-interactable-provider-partial-updates.test.js +4 -4
  215. package/esm/providers/tambo-interactable-provider-partial-updates.test.js.map +1 -1
  216. package/esm/providers/tambo-interactable-provider.d.ts +5 -5
  217. package/esm/providers/tambo-interactable-provider.js +6 -6
  218. package/esm/providers/tambo-interactable-provider.js.map +1 -1
  219. package/esm/providers/tambo-interactable-provider.test.js +4 -4
  220. package/esm/providers/tambo-interactable-provider.test.js.map +1 -1
  221. package/esm/providers/tambo-interactables-additional-context-edge-cases.test.js +4 -4
  222. package/esm/providers/tambo-interactables-additional-context.test.js +4 -4
  223. package/esm/providers/tambo-mcp-token-provider.js +2 -2
  224. package/esm/providers/tambo-prop-stream-provider/index.d.ts +8 -8
  225. package/esm/providers/tambo-prop-stream-provider/index.js +9 -9
  226. package/esm/providers/tambo-prop-stream-provider/pending.d.ts +1 -1
  227. package/esm/providers/tambo-prop-stream-provider/pending.js +2 -2
  228. package/esm/providers/tambo-prop-stream-provider/provider.d.ts +1 -1
  229. package/esm/providers/tambo-prop-stream-provider/provider.js +2 -2
  230. package/esm/providers/tambo-prop-stream-provider/streaming.d.ts +1 -1
  231. package/esm/providers/tambo-prop-stream-provider/streaming.js +2 -2
  232. package/esm/providers/tambo-prop-stream-provider/success.d.ts +1 -1
  233. package/esm/providers/tambo-prop-stream-provider/success.js +2 -2
  234. package/esm/providers/tambo-prop-stream-provider/types.d.ts +1 -1
  235. package/esm/providers/tambo-prop-stream-provider.test.js +4 -4
  236. package/esm/providers/tambo-provider.d.ts +10 -7
  237. package/esm/providers/tambo-provider.d.ts.map +1 -1
  238. package/esm/providers/tambo-provider.js +13 -10
  239. package/esm/providers/tambo-provider.js.map +1 -1
  240. package/esm/providers/tambo-registry-provider.d.ts +3 -3
  241. package/esm/providers/tambo-registry-provider.js +3 -3
  242. package/esm/providers/tambo-registry-provider.test.js +2 -2
  243. package/esm/providers/tambo-registry-schema-compat.test.js +2 -2
  244. package/esm/providers/tambo-stubs.d.ts +4 -4
  245. package/esm/providers/tambo-stubs.js +9 -9
  246. package/esm/providers/tambo-stubs.test.js +2 -2
  247. package/esm/providers/tambo-thread-input-provider.d.ts +2 -2
  248. package/esm/providers/tambo-thread-input-provider.d.ts.map +1 -1
  249. package/esm/providers/tambo-thread-input-provider.js +11 -10
  250. package/esm/providers/tambo-thread-input-provider.js.map +1 -1
  251. package/esm/providers/tambo-thread-provider-initial-messages.test.js +6 -6
  252. package/esm/providers/tambo-thread-provider.d.ts +2 -2
  253. package/esm/providers/tambo-thread-provider.js +8 -8
  254. package/esm/providers/tambo-thread-provider.test.js +7 -7
  255. package/esm/schema/index.d.ts +4 -4
  256. package/esm/schema/index.js +4 -4
  257. package/esm/schema/json-schema.test.js +1 -1
  258. package/esm/schema/schema.d.ts +1 -1
  259. package/esm/schema/schema.js +2 -2
  260. package/esm/schema/schema.test.js +3 -3
  261. package/esm/schema/standard-schema.test.js +1 -1
  262. package/esm/schema/validate.js +2 -2
  263. package/esm/schema/validate.test.js +1 -1
  264. package/esm/testing/tools.d.ts +3 -3
  265. package/esm/testing/tools.js +2 -2
  266. package/esm/util/content-parts.test.js +1 -1
  267. package/esm/util/generate-component.d.ts +2 -2
  268. package/esm/util/generate-component.js +4 -4
  269. package/esm/util/generate-component.test.js +2 -2
  270. package/esm/util/is-promise.test.js +1 -1
  271. package/esm/util/mcp-server-utils.d.ts +1 -1
  272. package/esm/util/mcp-server-utils.js +1 -1
  273. package/esm/util/mcp-server-utils.test.js +2 -2
  274. package/esm/util/message-builder.d.ts +1 -1
  275. package/esm/util/message-builder.test.js +1 -1
  276. package/esm/util/query-utils.test.js +1 -1
  277. package/esm/util/registry-validators.d.ts +1 -1
  278. package/esm/util/registry-validators.js +2 -2
  279. package/esm/util/registry-validators.test.js +1 -1
  280. package/esm/util/registry.d.ts +1 -1
  281. package/esm/util/registry.js +1 -1
  282. package/esm/util/registry.test.js +2 -2
  283. package/esm/util/resource-content-resolver.d.ts +2 -2
  284. package/esm/util/resource-content-resolver.d.ts.map +1 -1
  285. package/esm/util/resource-content-resolver.js +3 -1
  286. package/esm/util/resource-content-resolver.js.map +1 -1
  287. package/esm/util/resource-content-resolver.test.js +3 -3
  288. package/esm/util/resource-validators.d.ts +1 -1
  289. package/esm/util/resource-validators.test.js +1 -1
  290. package/esm/util/tool-caller.d.ts +1 -1
  291. package/esm/util/tool-caller.js +1 -1
  292. package/esm/util/validate-component-name.test.js +1 -1
  293. package/esm/v1/__tests__/v1-interactables.test.d.ts +2 -0
  294. package/esm/v1/__tests__/v1-interactables.test.d.ts.map +1 -0
  295. package/esm/v1/__tests__/v1-interactables.test.js +130 -0
  296. package/esm/v1/__tests__/v1-interactables.test.js.map +1 -0
  297. package/esm/v1/components/v1-component-renderer.d.ts +48 -0
  298. package/esm/v1/components/v1-component-renderer.d.ts.map +1 -0
  299. package/esm/v1/components/v1-component-renderer.js +100 -0
  300. package/esm/v1/components/v1-component-renderer.js.map +1 -0
  301. package/esm/v1/components/v1-component-renderer.test.d.ts +2 -0
  302. package/esm/v1/components/v1-component-renderer.test.d.ts.map +1 -0
  303. package/esm/v1/components/v1-component-renderer.test.js +265 -0
  304. package/esm/v1/components/v1-component-renderer.test.js.map +1 -0
  305. package/esm/v1/hooks/use-tambo-v1-component-state.d.ts.map +1 -1
  306. package/esm/v1/hooks/use-tambo-v1-component-state.js +4 -27
  307. package/esm/v1/hooks/use-tambo-v1-component-state.js.map +1 -1
  308. package/esm/v1/hooks/use-tambo-v1-component-state.test.js +6 -5
  309. package/esm/v1/hooks/use-tambo-v1-component-state.test.js.map +1 -1
  310. package/esm/v1/hooks/use-tambo-v1-messages.d.ts +1 -1
  311. package/esm/v1/hooks/use-tambo-v1-messages.js +1 -1
  312. package/esm/v1/hooks/use-tambo-v1-messages.test.js +27 -3
  313. package/esm/v1/hooks/use-tambo-v1-messages.test.js.map +1 -1
  314. package/esm/v1/hooks/use-tambo-v1-send-message.d.ts +20 -2
  315. package/esm/v1/hooks/use-tambo-v1-send-message.d.ts.map +1 -1
  316. package/esm/v1/hooks/use-tambo-v1-send-message.js +213 -26
  317. package/esm/v1/hooks/use-tambo-v1-send-message.js.map +1 -1
  318. package/esm/v1/hooks/use-tambo-v1-send-message.test.js +266 -12
  319. package/esm/v1/hooks/use-tambo-v1-send-message.test.js.map +1 -1
  320. package/esm/v1/hooks/use-tambo-v1-stream-status.d.ts +90 -0
  321. package/esm/v1/hooks/use-tambo-v1-stream-status.d.ts.map +1 -0
  322. package/esm/v1/hooks/use-tambo-v1-stream-status.js +176 -0
  323. package/esm/v1/hooks/use-tambo-v1-stream-status.js.map +1 -0
  324. package/esm/v1/hooks/use-tambo-v1-stream-status.test.d.ts +2 -0
  325. package/esm/v1/hooks/use-tambo-v1-stream-status.test.d.ts.map +1 -0
  326. package/esm/v1/hooks/use-tambo-v1-stream-status.test.js +369 -0
  327. package/esm/v1/hooks/use-tambo-v1-stream-status.test.js.map +1 -0
  328. package/esm/v1/hooks/use-tambo-v1-suggestions.d.ts +78 -54
  329. package/esm/v1/hooks/use-tambo-v1-suggestions.d.ts.map +1 -1
  330. package/esm/v1/hooks/use-tambo-v1-suggestions.js +157 -91
  331. package/esm/v1/hooks/use-tambo-v1-suggestions.js.map +1 -1
  332. package/esm/v1/hooks/use-tambo-v1-suggestions.test.js +218 -139
  333. package/esm/v1/hooks/use-tambo-v1-suggestions.test.js.map +1 -1
  334. package/esm/v1/hooks/use-tambo-v1-thread-input.d.ts +1 -1
  335. package/esm/v1/hooks/use-tambo-v1-thread-input.js +1 -1
  336. package/esm/v1/hooks/use-tambo-v1-thread-input.test.js +151 -16
  337. package/esm/v1/hooks/use-tambo-v1-thread-input.test.js.map +1 -1
  338. package/esm/v1/hooks/use-tambo-v1-thread-list.d.ts +8 -21
  339. package/esm/v1/hooks/use-tambo-v1-thread-list.d.ts.map +1 -1
  340. package/esm/v1/hooks/use-tambo-v1-thread-list.js +12 -11
  341. package/esm/v1/hooks/use-tambo-v1-thread-list.js.map +1 -1
  342. package/esm/v1/hooks/use-tambo-v1-thread-list.test.js +39 -4
  343. package/esm/v1/hooks/use-tambo-v1-thread-list.test.js.map +1 -1
  344. package/esm/v1/hooks/use-tambo-v1-thread.d.ts +1 -1
  345. package/esm/v1/hooks/use-tambo-v1-thread.d.ts.map +1 -1
  346. package/esm/v1/hooks/use-tambo-v1-thread.js +3 -8
  347. package/esm/v1/hooks/use-tambo-v1-thread.js.map +1 -1
  348. package/esm/v1/hooks/use-tambo-v1-thread.test.js +4 -2
  349. package/esm/v1/hooks/use-tambo-v1-thread.test.js.map +1 -1
  350. package/esm/v1/hooks/use-tambo-v1.d.ts +15 -31
  351. package/esm/v1/hooks/use-tambo-v1.d.ts.map +1 -1
  352. package/esm/v1/hooks/use-tambo-v1.js +134 -34
  353. package/esm/v1/hooks/use-tambo-v1.js.map +1 -1
  354. package/esm/v1/hooks/use-tambo-v1.test.js +862 -19
  355. package/esm/v1/hooks/use-tambo-v1.test.js.map +1 -1
  356. package/esm/v1/index.d.ts +28 -22
  357. package/esm/v1/index.d.ts.map +1 -1
  358. package/esm/v1/index.js +30 -18
  359. package/esm/v1/index.js.map +1 -1
  360. package/esm/v1/providers/tambo-v1-provider.d.ts +21 -11
  361. package/esm/v1/providers/tambo-v1-provider.d.ts.map +1 -1
  362. package/esm/v1/providers/tambo-v1-provider.js +20 -25
  363. package/esm/v1/providers/tambo-v1-provider.js.map +1 -1
  364. package/esm/v1/providers/tambo-v1-provider.test.js +40 -26
  365. package/esm/v1/providers/tambo-v1-provider.test.js.map +1 -1
  366. package/esm/v1/providers/tambo-v1-stream-context.d.ts +4 -4
  367. package/esm/v1/providers/tambo-v1-stream-context.d.ts.map +1 -1
  368. package/esm/v1/providers/tambo-v1-stream-context.js +62 -14
  369. package/esm/v1/providers/tambo-v1-stream-context.js.map +1 -1
  370. package/esm/v1/providers/tambo-v1-stream-context.test.js +50 -21
  371. package/esm/v1/providers/tambo-v1-stream-context.test.js.map +1 -1
  372. package/esm/v1/providers/tambo-v1-stub-provider.d.ts +3 -3
  373. package/esm/v1/providers/tambo-v1-stub-provider.d.ts.map +1 -1
  374. package/esm/v1/providers/tambo-v1-stub-provider.js +7 -5
  375. package/esm/v1/providers/tambo-v1-stub-provider.js.map +1 -1
  376. package/esm/v1/providers/tambo-v1-stub-provider.test.js +12 -11
  377. package/esm/v1/providers/tambo-v1-stub-provider.test.js.map +1 -1
  378. package/esm/v1/providers/tambo-v1-thread-input-provider.d.ts +3 -8
  379. package/esm/v1/providers/tambo-v1-thread-input-provider.d.ts.map +1 -1
  380. package/esm/v1/providers/tambo-v1-thread-input-provider.js +18 -16
  381. package/esm/v1/providers/tambo-v1-thread-input-provider.js.map +1 -1
  382. package/esm/v1/types/event.d.ts +9 -1
  383. package/esm/v1/types/event.d.ts.map +1 -1
  384. package/esm/v1/types/event.js.map +1 -1
  385. package/esm/v1/types/event.test.js +6 -2
  386. package/esm/v1/types/event.test.js.map +1 -1
  387. package/esm/v1/types/message.d.ts +65 -7
  388. package/esm/v1/types/message.d.ts.map +1 -1
  389. package/esm/v1/types/message.js.map +1 -1
  390. package/esm/v1/types/thread.d.ts +5 -1
  391. package/esm/v1/types/thread.d.ts.map +1 -1
  392. package/esm/v1/types/thread.js.map +1 -1
  393. package/esm/v1/utils/component-renderer.test.js +1 -1
  394. package/esm/v1/utils/event-accumulator.d.ts +41 -5
  395. package/esm/v1/utils/event-accumulator.d.ts.map +1 -1
  396. package/esm/v1/utils/event-accumulator.js +444 -36
  397. package/esm/v1/utils/event-accumulator.js.map +1 -1
  398. package/esm/v1/utils/event-accumulator.test.js +1042 -29
  399. package/esm/v1/utils/event-accumulator.test.js.map +1 -1
  400. package/esm/v1/utils/json-patch.test.js +1 -1
  401. package/esm/v1/utils/registry-conversion.d.ts +9 -9
  402. package/esm/v1/utils/registry-conversion.d.ts.map +1 -1
  403. package/esm/v1/utils/registry-conversion.js +11 -12
  404. package/esm/v1/utils/registry-conversion.js.map +1 -1
  405. package/esm/v1/utils/registry-conversion.test.js +40 -12
  406. package/esm/v1/utils/registry-conversion.test.js.map +1 -1
  407. package/esm/v1/utils/stream-handler.test.js +1 -1
  408. package/esm/v1/utils/thread-utils.d.ts +16 -0
  409. package/esm/v1/utils/thread-utils.d.ts.map +1 -0
  410. package/esm/v1/utils/thread-utils.js +31 -0
  411. package/esm/v1/utils/thread-utils.js.map +1 -0
  412. package/esm/v1/utils/tool-call-tracker.d.ts +1 -1
  413. package/esm/v1/utils/tool-executor.d.ts +1 -1
  414. package/esm/v1/utils/tool-executor.d.ts.map +1 -1
  415. package/esm/v1/utils/tool-executor.js +2 -0
  416. package/esm/v1/utils/tool-executor.js.map +1 -1
  417. package/esm/v1/utils/tool-executor.test.js +6 -1
  418. package/esm/v1/utils/tool-executor.test.js.map +1 -1
  419. package/package.json +11 -10
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-tambo-v1-stream-status.test.d.ts","sourceRoot":"","sources":["../../../src/v1/hooks/use-tambo-v1-stream-status.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,371 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const react_1 = require("@testing-library/react");
4
+ const use_tambo_v1_stream_status_1 = require("./use-tambo-v1-stream-status");
5
+ // Mock the required hooks
6
+ jest.mock("../utils/component-renderer", () => ({
7
+ useV1ComponentContent: jest.fn(),
8
+ }));
9
+ jest.mock("../providers/tambo-v1-stream-context", () => ({
10
+ useStreamState: jest.fn(),
11
+ }));
12
+ // Import the mocked functions
13
+ const component_renderer_1 = require("../utils/component-renderer");
14
+ const tambo_v1_stream_context_1 = require("../providers/tambo-v1-stream-context");
15
+ // Mock window for SSR tests
16
+ const originalWindow = global.window;
17
+ // Get the mocked functions
18
+ const mockUseV1ComponentContent = jest.mocked(component_renderer_1.useV1ComponentContent);
19
+ const mockUseStreamState = jest.mocked(tambo_v1_stream_context_1.useStreamState);
20
+ /**
21
+ * Helper to create a component content block
22
+ */
23
+ function createComponentContent(overrides = {}) {
24
+ return {
25
+ type: "component",
26
+ id: "test-component",
27
+ name: "TestComponent",
28
+ props: {},
29
+ streamingState: "started",
30
+ ...overrides,
31
+ };
32
+ }
33
+ /**
34
+ * Helper to create a message with a component
35
+ */
36
+ function createMessage(componentContent, overrides = {}) {
37
+ return {
38
+ id: "test-message",
39
+ role: "assistant",
40
+ content: [componentContent],
41
+ createdAt: new Date().toISOString(),
42
+ ...overrides,
43
+ };
44
+ }
45
+ /**
46
+ * Helper to create a thread state
47
+ */
48
+ function createThreadState(messages, overrides = {}) {
49
+ return {
50
+ thread: {
51
+ id: "test-thread",
52
+ messages,
53
+ status: "idle",
54
+ createdAt: new Date().toISOString(),
55
+ updatedAt: new Date().toISOString(),
56
+ lastRunCancelled: false,
57
+ },
58
+ streaming: {
59
+ status: "idle",
60
+ },
61
+ accumulatingToolArgs: new Map(),
62
+ ...overrides,
63
+ };
64
+ }
65
+ /**
66
+ * Helper to create a stream state
67
+ */
68
+ function createStreamState(threadState, threadId = "test-thread") {
69
+ return {
70
+ threadMap: {
71
+ [threadId]: threadState,
72
+ },
73
+ currentThreadId: threadId,
74
+ };
75
+ }
76
+ describe("useTamboV1StreamStatus", () => {
77
+ beforeEach(() => {
78
+ // Restore window for client-side tests
79
+ global.window = originalWindow;
80
+ // Default mock implementations
81
+ mockUseV1ComponentContent.mockReturnValue({
82
+ componentId: "test-component",
83
+ threadId: "test-thread",
84
+ messageId: "test-message",
85
+ componentName: "TestComponent",
86
+ });
87
+ const componentContent = createComponentContent({ props: {} });
88
+ const message = createMessage(componentContent);
89
+ const threadState = createThreadState([message]);
90
+ mockUseStreamState.mockReturnValue(createStreamState(threadState));
91
+ });
92
+ afterEach(() => {
93
+ jest.clearAllMocks();
94
+ // Restore window after each test
95
+ global.window = originalWindow;
96
+ });
97
+ describe("Initial State", () => {
98
+ it("should start with all flags as pending when component streaming is 'started' and no props", () => {
99
+ const componentContent = createComponentContent({
100
+ props: { title: "", body: "" },
101
+ streamingState: "started",
102
+ });
103
+ const message = createMessage(componentContent);
104
+ const threadState = createThreadState([message]);
105
+ mockUseStreamState.mockReturnValue(createStreamState(threadState));
106
+ const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_stream_status_1.useTamboV1StreamStatus)());
107
+ expect(result.current.streamStatus).toEqual({
108
+ isPending: true,
109
+ isStreaming: false,
110
+ isSuccess: false,
111
+ isError: false,
112
+ streamError: undefined,
113
+ });
114
+ expect(result.current.propStatus.title).toEqual({
115
+ isPending: true,
116
+ isStreaming: false,
117
+ isSuccess: false,
118
+ error: undefined,
119
+ });
120
+ expect(result.current.propStatus.body).toEqual({
121
+ isPending: true,
122
+ isStreaming: false,
123
+ isSuccess: false,
124
+ error: undefined,
125
+ });
126
+ });
127
+ });
128
+ describe("Streaming State Transitions", () => {
129
+ it("should show isStreaming when component is streaming even before props receive content", () => {
130
+ // Component is streaming but props are still empty
131
+ const componentContent = createComponentContent({
132
+ props: { title: "", body: "" },
133
+ streamingState: "streaming",
134
+ });
135
+ const message = createMessage(componentContent);
136
+ const threadState = createThreadState([message]);
137
+ mockUseStreamState.mockReturnValue(createStreamState(threadState));
138
+ const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_stream_status_1.useTamboV1StreamStatus)());
139
+ // Global should be streaming even though no props have content yet
140
+ expect(result.current.streamStatus.isStreaming).toBe(true);
141
+ expect(result.current.streamStatus.isPending).toBe(false);
142
+ // Individual props should still be pending
143
+ expect(result.current.propStatus.title.isPending).toBe(true);
144
+ expect(result.current.propStatus.title.isStreaming).toBe(false);
145
+ });
146
+ it("should show prop streaming when props receive content during streaming", () => {
147
+ const componentContent = createComponentContent({
148
+ props: { title: "Hello", body: "" },
149
+ streamingState: "streaming",
150
+ });
151
+ const message = createMessage(componentContent);
152
+ const threadState = createThreadState([message]);
153
+ mockUseStreamState.mockReturnValue(createStreamState(threadState));
154
+ const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_stream_status_1.useTamboV1StreamStatus)());
155
+ // Title prop should be streaming since it has content
156
+ expect(result.current.propStatus.title.isStreaming).toBe(true);
157
+ expect(result.current.propStatus.title.isPending).toBe(false);
158
+ // Body prop should still be pending since it has no content
159
+ expect(result.current.propStatus.body.isStreaming).toBe(false);
160
+ expect(result.current.propStatus.body.isPending).toBe(true);
161
+ // Global should be streaming because at least one prop is streaming
162
+ expect(result.current.streamStatus.isStreaming).toBe(true);
163
+ });
164
+ it("should transition through Init -> Streaming -> Success lifecycle", () => {
165
+ // Start with "started" (Init phase)
166
+ const componentContent = createComponentContent({
167
+ props: { title: "", body: "" },
168
+ streamingState: "started",
169
+ });
170
+ const message = createMessage(componentContent);
171
+ let threadState = createThreadState([message]);
172
+ mockUseStreamState.mockReturnValue(createStreamState(threadState));
173
+ const { result, rerender } = (0, react_1.renderHook)(() => (0, use_tambo_v1_stream_status_1.useTamboV1StreamStatus)());
174
+ // Phase 1: Init - isPending = true
175
+ expect(result.current.streamStatus.isPending).toBe(true);
176
+ expect(result.current.streamStatus.isStreaming).toBe(false);
177
+ expect(result.current.streamStatus.isSuccess).toBe(false);
178
+ // Phase 2: Streaming - move to "streaming" with content
179
+ const streamingComponent = createComponentContent({
180
+ props: { title: "Hello World", body: "Some content" },
181
+ streamingState: "streaming",
182
+ });
183
+ const streamingMessage = createMessage(streamingComponent);
184
+ threadState = createThreadState([streamingMessage]);
185
+ mockUseStreamState.mockReturnValue(createStreamState(threadState));
186
+ rerender();
187
+ expect(result.current.streamStatus.isPending).toBe(false);
188
+ expect(result.current.streamStatus.isStreaming).toBe(true);
189
+ expect(result.current.streamStatus.isSuccess).toBe(false);
190
+ // Phase 3: Complete - move to "done"
191
+ const doneComponent = createComponentContent({
192
+ props: { title: "Hello World", body: "Some content" },
193
+ streamingState: "done",
194
+ });
195
+ const doneMessage = createMessage(doneComponent);
196
+ threadState = createThreadState([doneMessage]);
197
+ mockUseStreamState.mockReturnValue(createStreamState(threadState));
198
+ rerender();
199
+ expect(result.current.streamStatus.isPending).toBe(false);
200
+ expect(result.current.streamStatus.isStreaming).toBe(false);
201
+ expect(result.current.streamStatus.isSuccess).toBe(true);
202
+ });
203
+ });
204
+ describe("Error Handling", () => {
205
+ it("should handle error state correctly", () => {
206
+ const componentContent = createComponentContent({
207
+ props: { title: "", body: "" },
208
+ streamingState: "started",
209
+ });
210
+ const message = createMessage(componentContent);
211
+ const threadState = createThreadState([message], {
212
+ streaming: {
213
+ status: "error",
214
+ error: { message: "Generation failed", code: "GENERATION_ERROR" },
215
+ },
216
+ });
217
+ mockUseStreamState.mockReturnValue(createStreamState(threadState));
218
+ const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_stream_status_1.useTamboV1StreamStatus)());
219
+ // Error state: isPending=false (error overrides pending), isStreaming=false (error stops streaming)
220
+ expect(result.current.streamStatus.isPending).toBe(false);
221
+ expect(result.current.streamStatus.isStreaming).toBe(false);
222
+ expect(result.current.streamStatus.isSuccess).toBe(false);
223
+ expect(result.current.streamStatus.isError).toBe(true);
224
+ expect(result.current.streamStatus.streamError?.message).toBe("Generation failed");
225
+ });
226
+ });
227
+ describe("Derivation Rules", () => {
228
+ it("should derive isPending correctly (no streaming activity AND all props pending)", () => {
229
+ const componentContent = createComponentContent({
230
+ props: { title: "", body: "", footer: "" },
231
+ streamingState: "started",
232
+ });
233
+ const message = createMessage(componentContent);
234
+ const threadState = createThreadState([message]);
235
+ mockUseStreamState.mockReturnValue(createStreamState(threadState));
236
+ const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_stream_status_1.useTamboV1StreamStatus)());
237
+ // All props are pending and no streaming activity
238
+ expect(result.current.streamStatus.isPending).toBe(true);
239
+ expect(result.current.propStatus.title.isPending).toBe(true);
240
+ expect(result.current.propStatus.body.isPending).toBe(true);
241
+ expect(result.current.propStatus.footer.isPending).toBe(true);
242
+ });
243
+ it("should derive isSuccess correctly (streaming done AND all props successful)", () => {
244
+ // Step 1: Start with streaming, props empty
245
+ const startComponent = createComponentContent({
246
+ props: { title: "", body: "" },
247
+ streamingState: "streaming",
248
+ });
249
+ const startMessage = createMessage(startComponent);
250
+ let threadState = createThreadState([startMessage]);
251
+ mockUseStreamState.mockReturnValue(createStreamState(threadState));
252
+ const { result, rerender } = (0, react_1.renderHook)(() => (0, use_tambo_v1_stream_status_1.useTamboV1StreamStatus)());
253
+ // Step 2: Simulate streaming in title
254
+ const titleComponent = createComponentContent({
255
+ props: { title: "Complete Title", body: "" },
256
+ streamingState: "streaming",
257
+ });
258
+ const titleMessage = createMessage(titleComponent);
259
+ threadState = createThreadState([titleMessage]);
260
+ mockUseStreamState.mockReturnValue(createStreamState(threadState));
261
+ rerender();
262
+ // Step 3: Simulate streaming in body
263
+ const bodyComponent = createComponentContent({
264
+ props: { title: "Complete Title", body: "Complete Body" },
265
+ streamingState: "streaming",
266
+ });
267
+ const bodyMessage = createMessage(bodyComponent);
268
+ threadState = createThreadState([bodyMessage]);
269
+ mockUseStreamState.mockReturnValue(createStreamState(threadState));
270
+ rerender();
271
+ // Step 4: Component streaming done
272
+ const doneComponent = createComponentContent({
273
+ props: { title: "Complete Title", body: "Complete Body" },
274
+ streamingState: "done",
275
+ });
276
+ const doneMessage = createMessage(doneComponent);
277
+ threadState = createThreadState([doneMessage]);
278
+ mockUseStreamState.mockReturnValue(createStreamState(threadState));
279
+ rerender();
280
+ // Now both props should be successful
281
+ expect(result.current.propStatus.title.isSuccess).toBe(true);
282
+ expect(result.current.propStatus.body.isSuccess).toBe(true);
283
+ expect(result.current.streamStatus.isSuccess).toBe(true);
284
+ });
285
+ });
286
+ describe("Type Safety", () => {
287
+ it("should provide strongly typed prop status based on generic", () => {
288
+ const componentContent = createComponentContent({
289
+ props: { title: "Test", description: "Test desc", count: 42 },
290
+ streamingState: "done",
291
+ });
292
+ const message = createMessage(componentContent);
293
+ const threadState = createThreadState([message]);
294
+ mockUseStreamState.mockReturnValue(createStreamState(threadState));
295
+ const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_stream_status_1.useTamboV1StreamStatus)());
296
+ // TypeScript should infer these keys correctly
297
+ expect(result.current.propStatus.title).toBeDefined();
298
+ expect(result.current.propStatus.description).toBeDefined();
299
+ expect(result.current.propStatus.count).toBeDefined();
300
+ });
301
+ it("should work without generic type parameter", () => {
302
+ const componentContent = createComponentContent({
303
+ props: { dynamicProp: "value" },
304
+ streamingState: "done",
305
+ });
306
+ const message = createMessage(componentContent);
307
+ const threadState = createThreadState([message]);
308
+ mockUseStreamState.mockReturnValue(createStreamState(threadState));
309
+ const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_stream_status_1.useTamboV1StreamStatus)());
310
+ expect(result.current.streamStatus).toBeDefined();
311
+ expect(result.current.propStatus).toBeDefined();
312
+ });
313
+ });
314
+ describe("Edge Cases", () => {
315
+ it("should handle missing component gracefully", () => {
316
+ const threadState = createThreadState([
317
+ {
318
+ id: "test-message",
319
+ role: "assistant",
320
+ content: [{ type: "text", text: "Hello" }],
321
+ createdAt: new Date().toISOString(),
322
+ },
323
+ ]);
324
+ mockUseStreamState.mockReturnValue(createStreamState(threadState));
325
+ const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_stream_status_1.useTamboV1StreamStatus)());
326
+ expect(result.current.streamStatus.isPending).toBe(true);
327
+ expect(result.current.propStatus).toEqual({});
328
+ });
329
+ it("should handle missing thread gracefully", () => {
330
+ mockUseStreamState.mockReturnValue({
331
+ threadMap: {},
332
+ currentThreadId: "non-existent",
333
+ });
334
+ const { result } = (0, react_1.renderHook)(() => (0, use_tambo_v1_stream_status_1.useTamboV1StreamStatus)());
335
+ expect(result.current.streamStatus.isPending).toBe(true);
336
+ expect(result.current.propStatus).toEqual({});
337
+ });
338
+ it("should error when component ID changes unexpectedly", () => {
339
+ const consoleSpy = jest.spyOn(console, "error").mockImplementation();
340
+ const componentContent = createComponentContent({
341
+ id: "first-component",
342
+ props: { title: "Title" },
343
+ streamingState: "streaming",
344
+ });
345
+ const message = createMessage(componentContent);
346
+ const threadState = createThreadState([message]);
347
+ mockUseStreamState.mockReturnValue(createStreamState(threadState));
348
+ mockUseV1ComponentContent.mockReturnValue({
349
+ componentId: "first-component",
350
+ threadId: "test-thread",
351
+ messageId: "test-message",
352
+ componentName: "TestComponent",
353
+ });
354
+ const { rerender } = (0, react_1.renderHook)(() => (0, use_tambo_v1_stream_status_1.useTamboV1StreamStatus)());
355
+ // No error initially
356
+ expect(consoleSpy).not.toHaveBeenCalled();
357
+ // Change componentId (this should not happen in practice)
358
+ mockUseV1ComponentContent.mockReturnValue({
359
+ componentId: "second-component",
360
+ threadId: "test-thread",
361
+ messageId: "test-message",
362
+ componentName: "TestComponent",
363
+ });
364
+ rerender();
365
+ // Should log an error indicating incorrect provider usage
366
+ expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining("componentId changed"));
367
+ consoleSpy.mockRestore();
368
+ });
369
+ });
370
+ });
371
+ //# sourceMappingURL=use-tambo-v1-stream-status.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-tambo-v1-stream-status.test.js","sourceRoot":"","sources":["../../../src/v1/hooks/use-tambo-v1-stream-status.test.tsx"],"names":[],"mappings":";;AAAA,kDAAoD;AACpD,6EAAsE;AAEtE,0BAA0B;AAC1B,IAAI,CAAC,IAAI,CAAC,6BAA6B,EAAE,GAAG,EAAE,CAAC,CAAC;IAC9C,qBAAqB,EAAE,IAAI,CAAC,EAAE,EAAE;CACjC,CAAC,CAAC,CAAC;AAEJ,IAAI,CAAC,IAAI,CAAC,sCAAsC,EAAE,GAAG,EAAE,CAAC,CAAC;IACvD,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE;CAC1B,CAAC,CAAC,CAAC;AAEJ,8BAA8B;AAC9B,oEAAoE;AACpE,kFAAsE;AAItE,4BAA4B;AAC5B,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC;AAErC,2BAA2B;AAC3B,MAAM,yBAAyB,GAAG,IAAI,CAAC,MAAM,CAAC,0CAAqB,CAAC,CAAC;AACrE,MAAM,kBAAkB,GAAG,IAAI,CAAC,MAAM,CAAC,wCAAc,CAAC,CAAC;AAEvD;;GAEG;AACH,SAAS,sBAAsB,CAC7B,YAAyC,EAAE;IAE3C,OAAO;QACL,IAAI,EAAE,WAAW;QACjB,EAAE,EAAE,gBAAgB;QACpB,IAAI,EAAE,eAAe;QACrB,KAAK,EAAE,EAAE;QACT,cAAc,EAAE,SAAS;QACzB,GAAG,SAAS;KACb,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,aAAa,CACpB,gBAAoC,EACpC,YAAqC,EAAE;IAEvC,OAAO;QACL,EAAE,EAAE,cAAc;QAClB,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,CAAC,gBAAgB,CAAC;QAC3B,SAAS,EAAE,IAAI,IAAI,EAAE,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B,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;YACjD,kBAAkB,CAAC,eAAe,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC,CAAC;YAEnE,yBAAyB,CAAC,eAAe,CAAC;gBACxC,WAAW,EAAE,iBAAiB;gBAC9B,QAAQ,EAAE,aAAa;gBACvB,SAAS,EAAE,cAAc;gBACzB,aAAa,EAAE,eAAe;aAC/B,CAAC,CAAC;YAEH,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAA,kBAAU,EAAC,GAAG,EAAE,CACnC,IAAA,mDAAsB,GAAqB,CAC5C,CAAC;YAEF,qBAAqB;YACrB,MAAM,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;YAE1C,0DAA0D;YAC1D,yBAAyB,CAAC,eAAe,CAAC;gBACxC,WAAW,EAAE,kBAAkB;gBAC/B,QAAQ,EAAE,aAAa;gBACvB,SAAS,EAAE,cAAc;gBACzB,aAAa,EAAE,eAAe;aAC/B,CAAC,CAAC;YAEH,QAAQ,EAAE,CAAC;YAEX,0DAA0D;YAC1D,MAAM,CAAC,UAAU,CAAC,CAAC,oBAAoB,CACrC,MAAM,CAAC,gBAAgB,CAAC,qBAAqB,CAAC,CAC/C,CAAC;YAEF,UAAU,CAAC,WAAW,EAAE,CAAC;QAC3B,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { renderHook } from \"@testing-library/react\";\nimport { useTamboV1StreamStatus } from \"./use-tambo-v1-stream-status\";\n\n// Mock the required hooks\njest.mock(\"../utils/component-renderer\", () => ({\n useV1ComponentContent: jest.fn(),\n}));\n\njest.mock(\"../providers/tambo-v1-stream-context\", () => ({\n useStreamState: jest.fn(),\n}));\n\n// Import the mocked functions\nimport { useV1ComponentContent } from \"../utils/component-renderer\";\nimport { useStreamState } from \"../providers/tambo-v1-stream-context\";\nimport type { StreamState, ThreadState } from \"../utils/event-accumulator\";\nimport type { V1ComponentContent, TamboV1Message } from \"../types/message\";\n\n// Mock window for SSR tests\nconst originalWindow = global.window;\n\n// Get the mocked functions\nconst mockUseV1ComponentContent = jest.mocked(useV1ComponentContent);\nconst mockUseStreamState = jest.mocked(useStreamState);\n\n/**\n * Helper to create a component content block\n */\nfunction createComponentContent(\n overrides: Partial<V1ComponentContent> = {},\n): V1ComponentContent {\n return {\n type: \"component\",\n id: \"test-component\",\n name: \"TestComponent\",\n props: {},\n streamingState: \"started\",\n ...overrides,\n };\n}\n\n/**\n * Helper to create a message with a component\n */\nfunction createMessage(\n componentContent: V1ComponentContent,\n overrides: Partial<TamboV1Message> = {},\n): TamboV1Message {\n return {\n id: \"test-message\",\n role: \"assistant\",\n content: [componentContent],\n createdAt: new Date().toISOString(),\n ...overrides,\n };\n}\n\n/**\n * Helper to create a thread state\n */\nfunction createThreadState(\n messages: TamboV1Message[],\n overrides: Partial<ThreadState> = {},\n): ThreadState {\n return {\n thread: {\n id: \"test-thread\",\n messages,\n status: \"idle\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: {\n status: \"idle\",\n },\n accumulatingToolArgs: new Map(),\n ...overrides,\n };\n}\n\n/**\n * Helper to create a stream state\n */\nfunction createStreamState(\n threadState: ThreadState,\n threadId = \"test-thread\",\n): StreamState {\n return {\n threadMap: {\n [threadId]: threadState,\n },\n currentThreadId: threadId,\n };\n}\n\ndescribe(\"useTamboV1StreamStatus\", () => {\n beforeEach(() => {\n // Restore window for client-side tests\n global.window = originalWindow;\n\n // Default mock implementations\n mockUseV1ComponentContent.mockReturnValue({\n componentId: \"test-component\",\n threadId: \"test-thread\",\n messageId: \"test-message\",\n componentName: \"TestComponent\",\n });\n\n const componentContent = createComponentContent({ props: {} });\n const message = createMessage(componentContent);\n const threadState = createThreadState([message]);\n mockUseStreamState.mockReturnValue(createStreamState(threadState));\n });\n\n afterEach(() => {\n jest.clearAllMocks();\n // Restore window after each test\n global.window = originalWindow;\n });\n\n describe(\"Initial State\", () => {\n it(\"should start with all flags as pending when component streaming is 'started' and no props\", () => {\n const componentContent = createComponentContent({\n props: { title: \"\", body: \"\" },\n streamingState: \"started\",\n });\n const message = createMessage(componentContent);\n const threadState = createThreadState([message]);\n mockUseStreamState.mockReturnValue(createStreamState(threadState));\n\n const { result } = renderHook(() =>\n useTamboV1StreamStatus<{ title: string; body: string }>(),\n );\n\n expect(result.current.streamStatus).toEqual({\n isPending: true,\n isStreaming: false,\n isSuccess: false,\n isError: false,\n streamError: undefined,\n });\n\n expect(result.current.propStatus.title).toEqual({\n isPending: true,\n isStreaming: false,\n isSuccess: false,\n error: undefined,\n });\n\n expect(result.current.propStatus.body).toEqual({\n isPending: true,\n isStreaming: false,\n isSuccess: false,\n error: undefined,\n });\n });\n });\n\n describe(\"Streaming State Transitions\", () => {\n it(\"should show isStreaming when component is streaming even before props receive content\", () => {\n // Component is streaming but props are still empty\n const componentContent = createComponentContent({\n props: { title: \"\", body: \"\" },\n streamingState: \"streaming\",\n });\n const message = createMessage(componentContent);\n const threadState = createThreadState([message]);\n mockUseStreamState.mockReturnValue(createStreamState(threadState));\n\n const { result } = renderHook(() =>\n useTamboV1StreamStatus<{ title: string; body: string }>(),\n );\n\n // Global should be streaming even though no props have content yet\n expect(result.current.streamStatus.isStreaming).toBe(true);\n expect(result.current.streamStatus.isPending).toBe(false);\n\n // Individual props should still be pending\n expect(result.current.propStatus.title.isPending).toBe(true);\n expect(result.current.propStatus.title.isStreaming).toBe(false);\n });\n\n it(\"should show prop streaming when props receive content during streaming\", () => {\n const componentContent = createComponentContent({\n props: { title: \"Hello\", body: \"\" },\n streamingState: \"streaming\",\n });\n const message = createMessage(componentContent);\n const threadState = createThreadState([message]);\n mockUseStreamState.mockReturnValue(createStreamState(threadState));\n\n const { result } = renderHook(() =>\n useTamboV1StreamStatus<{ title: string; body: string }>(),\n );\n\n // Title prop should be streaming since it has content\n expect(result.current.propStatus.title.isStreaming).toBe(true);\n expect(result.current.propStatus.title.isPending).toBe(false);\n\n // Body prop should still be pending since it has no content\n expect(result.current.propStatus.body.isStreaming).toBe(false);\n expect(result.current.propStatus.body.isPending).toBe(true);\n\n // Global should be streaming because at least one prop is streaming\n expect(result.current.streamStatus.isStreaming).toBe(true);\n });\n\n it(\"should transition through Init -> Streaming -> Success lifecycle\", () => {\n // Start with \"started\" (Init phase)\n const componentContent = createComponentContent({\n props: { title: \"\", body: \"\" },\n streamingState: \"started\",\n });\n const message = createMessage(componentContent);\n let threadState = createThreadState([message]);\n mockUseStreamState.mockReturnValue(createStreamState(threadState));\n\n const { result, rerender } = renderHook(() =>\n useTamboV1StreamStatus<{ title: string; body: string }>(),\n );\n\n // Phase 1: Init - isPending = true\n expect(result.current.streamStatus.isPending).toBe(true);\n expect(result.current.streamStatus.isStreaming).toBe(false);\n expect(result.current.streamStatus.isSuccess).toBe(false);\n\n // Phase 2: Streaming - move to \"streaming\" with content\n const streamingComponent = createComponentContent({\n props: { title: \"Hello World\", body: \"Some content\" },\n streamingState: \"streaming\",\n });\n const streamingMessage = createMessage(streamingComponent);\n threadState = createThreadState([streamingMessage]);\n mockUseStreamState.mockReturnValue(createStreamState(threadState));\n\n rerender();\n\n expect(result.current.streamStatus.isPending).toBe(false);\n expect(result.current.streamStatus.isStreaming).toBe(true);\n expect(result.current.streamStatus.isSuccess).toBe(false);\n\n // Phase 3: Complete - move to \"done\"\n const doneComponent = createComponentContent({\n props: { title: \"Hello World\", body: \"Some content\" },\n streamingState: \"done\",\n });\n const doneMessage = createMessage(doneComponent);\n threadState = createThreadState([doneMessage]);\n mockUseStreamState.mockReturnValue(createStreamState(threadState));\n\n rerender();\n\n expect(result.current.streamStatus.isPending).toBe(false);\n expect(result.current.streamStatus.isStreaming).toBe(false);\n expect(result.current.streamStatus.isSuccess).toBe(true);\n });\n });\n\n describe(\"Error Handling\", () => {\n it(\"should handle error state correctly\", () => {\n const componentContent = createComponentContent({\n props: { title: \"\", body: \"\" },\n streamingState: \"started\",\n });\n const message = createMessage(componentContent);\n const threadState = createThreadState([message], {\n streaming: {\n status: \"error\",\n error: { message: \"Generation failed\", code: \"GENERATION_ERROR\" },\n },\n });\n mockUseStreamState.mockReturnValue(createStreamState(threadState));\n\n const { result } = renderHook(() =>\n useTamboV1StreamStatus<{ title: string; body: string }>(),\n );\n\n // Error state: isPending=false (error overrides pending), isStreaming=false (error stops streaming)\n expect(result.current.streamStatus.isPending).toBe(false);\n expect(result.current.streamStatus.isStreaming).toBe(false);\n expect(result.current.streamStatus.isSuccess).toBe(false);\n expect(result.current.streamStatus.isError).toBe(true);\n expect(result.current.streamStatus.streamError?.message).toBe(\n \"Generation failed\",\n );\n });\n });\n\n describe(\"Derivation Rules\", () => {\n it(\"should derive isPending correctly (no streaming activity AND all props pending)\", () => {\n const componentContent = createComponentContent({\n props: { title: \"\", body: \"\", footer: \"\" },\n streamingState: \"started\",\n });\n const message = createMessage(componentContent);\n const threadState = createThreadState([message]);\n mockUseStreamState.mockReturnValue(createStreamState(threadState));\n\n const { result } = renderHook(() =>\n useTamboV1StreamStatus<{\n title: string;\n body: string;\n footer: string;\n }>(),\n );\n\n // All props are pending and no streaming activity\n expect(result.current.streamStatus.isPending).toBe(true);\n expect(result.current.propStatus.title.isPending).toBe(true);\n expect(result.current.propStatus.body.isPending).toBe(true);\n expect(result.current.propStatus.footer.isPending).toBe(true);\n });\n\n it(\"should derive isSuccess correctly (streaming done AND all props successful)\", () => {\n // Step 1: Start with streaming, props empty\n const startComponent = createComponentContent({\n props: { title: \"\", body: \"\" },\n streamingState: \"streaming\",\n });\n const startMessage = createMessage(startComponent);\n let threadState = createThreadState([startMessage]);\n mockUseStreamState.mockReturnValue(createStreamState(threadState));\n\n const { result, rerender } = renderHook(() =>\n useTamboV1StreamStatus<{ title: string; body: string }>(),\n );\n\n // Step 2: Simulate streaming in title\n const titleComponent = createComponentContent({\n props: { title: \"Complete Title\", body: \"\" },\n streamingState: \"streaming\",\n });\n const titleMessage = createMessage(titleComponent);\n threadState = createThreadState([titleMessage]);\n mockUseStreamState.mockReturnValue(createStreamState(threadState));\n rerender();\n\n // Step 3: Simulate streaming in body\n const bodyComponent = createComponentContent({\n props: { title: \"Complete Title\", body: \"Complete Body\" },\n streamingState: \"streaming\",\n });\n const bodyMessage = createMessage(bodyComponent);\n threadState = createThreadState([bodyMessage]);\n mockUseStreamState.mockReturnValue(createStreamState(threadState));\n rerender();\n\n // Step 4: Component streaming done\n const doneComponent = createComponentContent({\n props: { title: \"Complete Title\", body: \"Complete Body\" },\n streamingState: \"done\",\n });\n const doneMessage = createMessage(doneComponent);\n threadState = createThreadState([doneMessage]);\n mockUseStreamState.mockReturnValue(createStreamState(threadState));\n rerender();\n\n // Now both props should be successful\n expect(result.current.propStatus.title.isSuccess).toBe(true);\n expect(result.current.propStatus.body.isSuccess).toBe(true);\n expect(result.current.streamStatus.isSuccess).toBe(true);\n });\n });\n\n describe(\"Type Safety\", () => {\n it(\"should provide strongly typed prop status based on generic\", () => {\n interface TestProps {\n title: string;\n description: string;\n count: number;\n }\n\n const componentContent = createComponentContent({\n props: { title: \"Test\", description: \"Test desc\", count: 42 },\n streamingState: \"done\",\n });\n const message = createMessage(componentContent);\n const threadState = createThreadState([message]);\n mockUseStreamState.mockReturnValue(createStreamState(threadState));\n\n const { result } = renderHook(() => useTamboV1StreamStatus<TestProps>());\n\n // TypeScript should infer these keys correctly\n expect(result.current.propStatus.title).toBeDefined();\n expect(result.current.propStatus.description).toBeDefined();\n expect(result.current.propStatus.count).toBeDefined();\n });\n\n it(\"should work without generic type parameter\", () => {\n const componentContent = createComponentContent({\n props: { dynamicProp: \"value\" },\n streamingState: \"done\",\n });\n const message = createMessage(componentContent);\n const threadState = createThreadState([message]);\n mockUseStreamState.mockReturnValue(createStreamState(threadState));\n\n const { result } = renderHook(() => useTamboV1StreamStatus());\n\n expect(result.current.streamStatus).toBeDefined();\n expect(result.current.propStatus).toBeDefined();\n });\n });\n\n describe(\"Edge Cases\", () => {\n it(\"should handle missing component gracefully\", () => {\n const threadState = createThreadState([\n {\n id: \"test-message\",\n role: \"assistant\",\n content: [{ type: \"text\", text: \"Hello\" }],\n createdAt: new Date().toISOString(),\n },\n ]);\n mockUseStreamState.mockReturnValue(createStreamState(threadState));\n\n const { result } = renderHook(() => useTamboV1StreamStatus());\n\n expect(result.current.streamStatus.isPending).toBe(true);\n expect(result.current.propStatus).toEqual({});\n });\n\n it(\"should handle missing thread gracefully\", () => {\n mockUseStreamState.mockReturnValue({\n threadMap: {},\n currentThreadId: \"non-existent\",\n });\n\n const { result } = renderHook(() => useTamboV1StreamStatus());\n\n expect(result.current.streamStatus.isPending).toBe(true);\n expect(result.current.propStatus).toEqual({});\n });\n\n it(\"should error when component ID changes unexpectedly\", () => {\n const consoleSpy = jest.spyOn(console, \"error\").mockImplementation();\n\n const componentContent = createComponentContent({\n id: \"first-component\",\n props: { title: \"Title\" },\n streamingState: \"streaming\",\n });\n const message = createMessage(componentContent);\n const threadState = createThreadState([message]);\n mockUseStreamState.mockReturnValue(createStreamState(threadState));\n\n mockUseV1ComponentContent.mockReturnValue({\n componentId: \"first-component\",\n threadId: \"test-thread\",\n messageId: \"test-message\",\n componentName: \"TestComponent\",\n });\n\n const { rerender } = renderHook(() =>\n useTamboV1StreamStatus<{ title: string }>(),\n );\n\n // No error initially\n expect(consoleSpy).not.toHaveBeenCalled();\n\n // Change componentId (this should not happen in practice)\n mockUseV1ComponentContent.mockReturnValue({\n componentId: \"second-component\",\n threadId: \"test-thread\",\n messageId: \"test-message\",\n componentName: \"TestComponent\",\n });\n\n rerender();\n\n // Should log an error indicating incorrect provider usage\n expect(consoleSpy).toHaveBeenCalledWith(\n expect.stringContaining(\"componentId changed\"),\n );\n\n consoleSpy.mockRestore();\n });\n });\n});\n"]}
@@ -1,91 +1,115 @@
1
+ import type { UseQueryOptions } from "@tanstack/react-query";
2
+ import type { SuggestionCreateResponse, SuggestionListResponse } from "@tambo-ai/typescript-sdk/resources/threads/suggestions";
3
+ import type { Suggestion } from "@tambo-ai/typescript-sdk/resources/beta/threads/suggestions";
1
4
  /**
2
- * useTamboV1Suggestions - Suggestions Hook for v1 API
3
- *
4
- * Provides AI-generated suggestions based on the current thread state.
5
- * Uses the shared thread input context so accepting a suggestion
6
- * automatically updates the input field.
5
+ * Response type for suggestions queries (union of list and create responses)
7
6
  */
8
- import TamboAI from "@tambo-ai/typescript-sdk";
9
- import { type UseTamboMutationResult, type UseTamboQueryResult } from "../../hooks/react-query-hooks";
10
- import { CombinedMutationResult } from "../../util/query-utils";
11
- type Suggestion = TamboAI.Beta.Threads.Suggestion;
12
- type SuggestionGenerateResponse = TamboAI.Beta.Threads.Suggestions.SuggestionGenerateResponse;
13
- type SuggestionsMutationData = void | SuggestionGenerateResponse;
7
+ type SuggestionsQueryResponse = SuggestionListResponse | SuggestionCreateResponse;
14
8
  /**
15
9
  * Configuration options for the useTamboV1Suggestions hook
16
10
  */
17
11
  export interface UseTamboV1SuggestionsOptions {
18
12
  /** Maximum number of suggestions to generate (1-10, default 3) */
19
13
  maxSuggestions?: number;
14
+ /**
15
+ * Whether to automatically generate suggestions when the latest message is from the assistant.
16
+ * Default: true
17
+ */
18
+ autoGenerate?: boolean;
19
+ /**
20
+ * Additional React Query options for the suggestions query.
21
+ * Allows customizing caching, refetching behavior, etc.
22
+ */
23
+ queryOptions?: Omit<UseQueryOptions<SuggestionsQueryResponse>, "queryKey" | "queryFn" | "enabled">;
20
24
  }
21
25
  /**
22
- * Return value interface for useTamboV1Suggestions hook
26
+ * Options for accepting a suggestion
23
27
  */
24
- export interface UseTamboV1SuggestionsResultInternal {
25
- /** List of available suggestions */
28
+ export interface AcceptSuggestionOptions {
29
+ /** The suggestion to accept */
30
+ suggestion: Suggestion;
31
+ /** Whether to automatically submit the suggestion after accepting (default: false) */
32
+ shouldSubmit?: boolean;
33
+ }
34
+ /**
35
+ * Return type for useTamboV1Suggestions hook
36
+ */
37
+ export interface UseTamboV1SuggestionsReturn {
38
+ /**
39
+ * The raw response data from the suggestions query.
40
+ * Use this for direct access to the API response shape.
41
+ */
42
+ data: SuggestionsQueryResponse | undefined;
43
+ /** List of available suggestions for the current message (convenience accessor) */
26
44
  suggestions: Suggestion[];
27
- /** ID of the currently selected suggestion */
28
- selectedSuggestionId: string | null;
45
+ /** Whether the suggestions query is loading (first fetch) */
46
+ isLoading: boolean;
47
+ /** Whether suggestions have been successfully loaded */
48
+ isSuccess: boolean;
49
+ /** Whether there was an error loading suggestions */
50
+ isError: boolean;
51
+ /** Error from loading suggestions, if any */
52
+ error: Error | null;
53
+ /** Whether the query is currently fetching (includes background refetches) */
54
+ isFetching: boolean;
55
+ /**
56
+ * Manually generate new suggestions for the current message.
57
+ * Use this when autoGenerate is false or to refresh suggestions.
58
+ */
59
+ generate: () => Promise<SuggestionCreateResponse | undefined>;
60
+ /** Whether suggestions are being generated (mutation pending) */
61
+ isGenerating: boolean;
62
+ /** Error from generating suggestions, if any */
63
+ generateError: Error | null;
29
64
  /**
30
65
  * Accept and apply a suggestion.
31
- * If shouldSubmit is false, updates the shared input context value.
32
- * If shouldSubmit is true, submits the suggestion directly.
33
- * @param suggestion - The suggestion to accept
34
- * @param shouldSubmit - Whether to automatically submit after accepting (default: false)
66
+ * Sets the suggestion text as input value, optionally submitting it.
35
67
  */
36
- accept: (acceptOptions: {
37
- suggestion: Suggestion;
38
- shouldSubmit?: boolean;
39
- }) => Promise<void>;
40
- /** Result and network state for accepting a suggestion */
41
- acceptResult: UseTamboMutationResult<void, Error, {
42
- suggestion: Suggestion;
43
- shouldSubmit?: boolean;
44
- }>;
45
- /** Result and network state for generating suggestions */
46
- generateResult: UseTamboMutationResult<SuggestionGenerateResponse, Error, AbortController>;
47
- /** The full suggestions query object from React Query */
48
- suggestionsResult: UseTamboQueryResult<SuggestionGenerateResponse>;
68
+ accept: (options: AcceptSuggestionOptions) => Promise<void>;
69
+ /** Whether accepting a suggestion is in progress */
70
+ isAccepting: boolean;
71
+ /** Error from accepting a suggestion, if any */
72
+ acceptError: Error | null;
73
+ /** ID of the currently selected suggestion */
74
+ selectedSuggestionId: string | null;
49
75
  }
50
- type UseTamboV1SuggestionsResult = CombinedMutationResult<SuggestionsMutationData, Error> & UseTamboV1SuggestionsResultInternal;
51
76
  /**
52
- * Hook for managing Tambo AI suggestions in a v1 thread.
53
- *
54
- * Automatically generates suggestions when the latest message is from the assistant
55
- * and the thread is idle (not streaming).
77
+ * Hook for managing AI-powered suggestions in a v1 thread.
56
78
  *
57
- * Uses the shared thread input context, so accepting a suggestion without submitting
58
- * will automatically update the input field value for any component using
59
- * useTamboV1ThreadInput.
60
- * @param options - Configuration options for suggestion generation
61
- * @returns Object containing suggestions state and control functions
79
+ * Provides functionality to:
80
+ * - Automatically generate suggestions when an assistant message arrives
81
+ * - Manually generate suggestions on demand
82
+ * - Accept suggestions by setting them as input or auto-submitting
83
+ * @param options - Configuration options
84
+ * @returns Suggestions state and control functions
62
85
  * @example
63
86
  * ```tsx
64
87
  * function SuggestionsPanel() {
65
- * const { suggestions, accept, isPending } = useTamboV1Suggestions();
88
+ * const {
89
+ * suggestions,
90
+ * accept,
91
+ * isLoading,
92
+ * selectedSuggestionId,
93
+ * } = useTamboV1Suggestions();
94
+ *
95
+ * if (isLoading) return <Spinner />;
66
96
  *
67
97
  * return (
68
98
  * <div>
69
- * {suggestions.map(suggestion => (
99
+ * {suggestions.map((suggestion) => (
70
100
  * <button
71
101
  * key={suggestion.id}
72
102
  * onClick={() => accept({ suggestion })}
73
- * disabled={isPending}
103
+ * className={selectedSuggestionId === suggestion.id ? 'selected' : ''}
74
104
  * >
75
- * {suggestion.suggestion}
105
+ * {suggestion.title}
76
106
  * </button>
77
107
  * ))}
78
108
  * </div>
79
109
  * );
80
110
  * }
81
- *
82
- * function ChatInput() {
83
- * // This input will automatically show the accepted suggestion
84
- * const { value, setValue, submit } = useTamboV1ThreadInput();
85
- * return <input value={value} onChange={e => setValue(e.target.value)} />;
86
- * }
87
111
  * ```
88
112
  */
89
- export declare function useTamboV1Suggestions(options?: UseTamboV1SuggestionsOptions): UseTamboV1SuggestionsResult;
113
+ export declare function useTamboV1Suggestions(options?: UseTamboV1SuggestionsOptions): UseTamboV1SuggestionsReturn;
90
114
  export {};
91
115
  //# sourceMappingURL=use-tambo-v1-suggestions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-tambo-v1-suggestions.d.ts","sourceRoot":"","sources":["../../../src/v1/hooks/use-tambo-v1-suggestions.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,OAAO,MAAM,0BAA0B,CAAC;AAK/C,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACzB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,sBAAsB,EAEvB,MAAM,wBAAwB,CAAC;AAIhC,KAAK,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;AAGlD,KAAK,0BAA0B,GAC7B,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,0BAA0B,CAAC;AAE9D,KAAK,uBAAuB,GAAG,IAAI,GAAG,0BAA0B,CAAC;AAkBjE;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,kEAAkE;IAClE,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,mCAAmC;IAClD,oCAAoC;IACpC,WAAW,EAAE,UAAU,EAAE,CAAC;IAE1B,8CAA8C;IAC9C,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;IAEpC;;;;;;OAMG;IACH,MAAM,EAAE,CAAC,aAAa,EAAE;QACtB,UAAU,EAAE,UAAU,CAAC;QACvB,YAAY,CAAC,EAAE,OAAO,CAAC;KACxB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpB,0DAA0D;IAC1D,YAAY,EAAE,sBAAsB,CAClC,IAAI,EACJ,KAAK,EACL;QAAE,UAAU,EAAE,UAAU,CAAC;QAAC,YAAY,CAAC,EAAE,OAAO,CAAA;KAAE,CACnD,CAAC;IAEF,0DAA0D;IAC1D,cAAc,EAAE,sBAAsB,CACpC,0BAA0B,EAC1B,KAAK,EACL,eAAe,CAChB,CAAC;IAEF,yDAAyD;IACzD,iBAAiB,EAAE,mBAAmB,CAAC,0BAA0B,CAAC,CAAC;CACpE;AAED,KAAK,2BAA2B,GAAG,sBAAsB,CACvD,uBAAuB,EACvB,KAAK,CACN,GACC,mCAAmC,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,GAAE,4BAAiC,GACzC,2BAA2B,CA8I7B"}
1
+ {"version":3,"file":"use-tambo-v1-suggestions.d.ts","sourceRoot":"","sources":["../../../src/v1/hooks/use-tambo-v1-suggestions.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EACV,wBAAwB,EACxB,sBAAsB,EACvB,MAAM,wDAAwD,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6DAA6D,CAAC;AAY9F;;GAEG;AACH,KAAK,wBAAwB,GACzB,sBAAsB,GACtB,wBAAwB,CAAC;AAE7B;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,kEAAkE;IAClE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,YAAY,CAAC,EAAE,IAAI,CACjB,eAAe,CAAC,wBAAwB,CAAC,EACzC,UAAU,GAAG,SAAS,GAAG,SAAS,CACnC,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,+BAA+B;IAC/B,UAAU,EAAE,UAAU,CAAC;IACvB,sFAAsF;IACtF,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAK1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