@tambo-ai/react 0.67.1 → 0.69.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 (424) hide show
  1. package/README.md +3 -5
  2. package/dist/context-helpers/context-helpers.test.js +16 -4
  3. package/dist/context-helpers/context-helpers.test.js.map +1 -1
  4. package/dist/context-helpers/current-interactables-context-helper.d.ts +2 -2
  5. package/dist/context-helpers/current-interactables-context-helper.d.ts.map +1 -1
  6. package/dist/context-helpers/current-interactables-context-helper.js +31 -12
  7. package/dist/context-helpers/current-interactables-context-helper.js.map +1 -1
  8. package/dist/context-helpers/registry.d.ts +2 -2
  9. package/dist/context-helpers/registry.d.ts.map +1 -1
  10. package/dist/context-helpers/registry.js.map +1 -1
  11. package/dist/context-helpers/types.d.ts +2 -2
  12. package/dist/context-helpers/types.d.ts.map +1 -1
  13. package/dist/context-helpers/types.js.map +1 -1
  14. package/dist/hoc/with-tambo-interactable.d.ts +50 -4
  15. package/dist/hoc/with-tambo-interactable.d.ts.map +1 -1
  16. package/dist/hoc/with-tambo-interactable.js +20 -5
  17. package/dist/hoc/with-tambo-interactable.js.map +1 -1
  18. package/dist/hooks/use-component-state.d.ts +3 -8
  19. package/dist/hooks/use-component-state.d.ts.map +1 -1
  20. package/dist/hooks/use-component-state.js +8 -0
  21. package/dist/hooks/use-component-state.js.map +1 -1
  22. package/dist/hooks/use-component-state.test.js +37 -0
  23. package/dist/hooks/use-component-state.test.js.map +1 -1
  24. package/dist/hooks/use-message-images.test.js +174 -37
  25. package/dist/hooks/use-message-images.test.js.map +1 -1
  26. package/dist/hooks/use-tambo-threads.js +1 -1
  27. package/dist/hooks/use-tambo-threads.js.map +1 -1
  28. package/dist/hooks/use-tambo-voice.d.ts +1 -1
  29. package/dist/hooks/use-tambo-voice.js +1 -1
  30. package/dist/hooks/use-tambo-voice.js.map +1 -1
  31. package/dist/hooks/use-tambo-voice.test.d.ts +2 -0
  32. package/dist/hooks/use-tambo-voice.test.d.ts.map +1 -0
  33. package/dist/hooks/use-tambo-voice.test.js +239 -0
  34. package/dist/hooks/use-tambo-voice.test.js.map +1 -0
  35. package/dist/index.d.ts +2 -2
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js.map +1 -1
  38. package/dist/mcp/elicitation.d.ts.map +1 -1
  39. package/dist/mcp/elicitation.js +12 -0
  40. package/dist/mcp/elicitation.js.map +1 -1
  41. package/dist/mcp/elicitation.test.js +8 -1
  42. package/dist/mcp/elicitation.test.js.map +1 -1
  43. package/dist/mcp/mcp-client.d.ts +6 -10
  44. package/dist/mcp/mcp-client.d.ts.map +1 -1
  45. package/dist/mcp/mcp-client.js.map +1 -1
  46. package/dist/mcp/mcp-constants.d.ts +19 -0
  47. package/dist/mcp/mcp-constants.d.ts.map +1 -0
  48. package/dist/mcp/mcp-constants.js +21 -0
  49. package/dist/mcp/mcp-constants.js.map +1 -0
  50. package/dist/mcp/mcp-hooks.d.ts +21 -40
  51. package/dist/mcp/mcp-hooks.d.ts.map +1 -1
  52. package/dist/mcp/mcp-hooks.js +130 -39
  53. package/dist/mcp/mcp-hooks.js.map +1 -1
  54. package/dist/mcp/mcp-hooks.test.js +431 -5
  55. package/dist/mcp/mcp-hooks.test.js.map +1 -1
  56. package/dist/mcp/tambo-mcp-provider.d.ts +7 -0
  57. package/dist/mcp/tambo-mcp-provider.d.ts.map +1 -1
  58. package/dist/mcp/tambo-mcp-provider.js +205 -155
  59. package/dist/mcp/tambo-mcp-provider.js.map +1 -1
  60. package/dist/mcp/tambo-mcp-provider.test.js +37 -0
  61. package/dist/mcp/tambo-mcp-provider.test.js.map +1 -1
  62. package/dist/model/component-metadata.d.ts +54 -21
  63. package/dist/model/component-metadata.d.ts.map +1 -1
  64. package/dist/model/component-metadata.js.map +1 -1
  65. package/dist/model/tambo-interactable.d.ts +13 -5
  66. package/dist/model/tambo-interactable.d.ts.map +1 -1
  67. package/dist/model/tambo-interactable.js.map +1 -1
  68. package/dist/providers/__tests__/thread-input-resource-resolution.test.d.ts +2 -0
  69. package/dist/providers/__tests__/thread-input-resource-resolution.test.d.ts.map +1 -0
  70. package/dist/providers/__tests__/thread-input-resource-resolution.test.js +592 -0
  71. package/dist/providers/__tests__/thread-input-resource-resolution.test.js.map +1 -0
  72. package/dist/providers/index.d.ts +1 -1
  73. package/dist/providers/index.d.ts.map +1 -1
  74. package/dist/providers/index.js.map +1 -1
  75. package/dist/providers/tambo-client-provider.d.ts +8 -0
  76. package/dist/providers/tambo-client-provider.d.ts.map +1 -1
  77. package/dist/providers/tambo-client-provider.js +10 -11
  78. package/dist/providers/tambo-client-provider.js.map +1 -1
  79. package/dist/providers/tambo-client-provider.test.d.ts +2 -0
  80. package/dist/providers/tambo-client-provider.test.d.ts.map +1 -0
  81. package/dist/providers/tambo-client-provider.test.js +208 -0
  82. package/dist/providers/tambo-client-provider.test.js.map +1 -0
  83. package/dist/providers/tambo-context-attachment-provider.d.ts +34 -92
  84. package/dist/providers/tambo-context-attachment-provider.d.ts.map +1 -1
  85. package/dist/providers/tambo-context-attachment-provider.js +62 -105
  86. package/dist/providers/tambo-context-attachment-provider.js.map +1 -1
  87. package/dist/providers/tambo-context-attachment-provider.test.js +229 -463
  88. package/dist/providers/tambo-context-attachment-provider.test.js.map +1 -1
  89. package/dist/providers/tambo-interactable-provider-partial-updates.test.js +22 -21
  90. package/dist/providers/tambo-interactable-provider-partial-updates.test.js.map +1 -1
  91. package/dist/providers/tambo-interactable-provider.d.ts +5 -2
  92. package/dist/providers/tambo-interactable-provider.d.ts.map +1 -1
  93. package/dist/providers/tambo-interactable-provider.js +126 -17
  94. package/dist/providers/tambo-interactable-provider.js.map +1 -1
  95. package/dist/providers/tambo-interactable-provider.test.js +242 -0
  96. package/dist/providers/tambo-interactable-provider.test.js.map +1 -1
  97. package/dist/providers/tambo-interactables-additional-context.test.js +2 -5
  98. package/dist/providers/tambo-interactables-additional-context.test.js.map +1 -1
  99. package/dist/providers/tambo-provider.d.ts +2 -3
  100. package/dist/providers/tambo-provider.d.ts.map +1 -1
  101. package/dist/providers/tambo-provider.js +6 -5
  102. package/dist/providers/tambo-provider.js.map +1 -1
  103. package/dist/providers/tambo-registry-provider.test.js +16 -0
  104. package/dist/providers/tambo-registry-provider.test.js.map +1 -1
  105. package/dist/providers/tambo-registry-schema-compat.test.js +31 -0
  106. package/dist/providers/tambo-registry-schema-compat.test.js.map +1 -1
  107. package/dist/providers/tambo-thread-input-provider.d.ts +1 -1
  108. package/dist/providers/tambo-thread-input-provider.d.ts.map +1 -1
  109. package/dist/providers/tambo-thread-input-provider.js +26 -4
  110. package/dist/providers/tambo-thread-input-provider.js.map +1 -1
  111. package/dist/providers/tambo-thread-provider-initial-messages.test.js +84 -2
  112. package/dist/providers/tambo-thread-provider-initial-messages.test.js.map +1 -1
  113. package/dist/providers/tambo-thread-provider.d.ts.map +1 -1
  114. package/dist/providers/tambo-thread-provider.js +53 -42
  115. package/dist/providers/tambo-thread-provider.js.map +1 -1
  116. package/dist/providers/tambo-thread-provider.test.js +368 -262
  117. package/dist/providers/tambo-thread-provider.test.js.map +1 -1
  118. package/dist/schema/index.d.ts +1 -1
  119. package/dist/schema/index.d.ts.map +1 -1
  120. package/dist/schema/index.js +2 -1
  121. package/dist/schema/index.js.map +1 -1
  122. package/dist/schema/json-schema.d.ts +7 -0
  123. package/dist/schema/json-schema.d.ts.map +1 -1
  124. package/dist/schema/json-schema.js +40 -29
  125. package/dist/schema/json-schema.js.map +1 -1
  126. package/dist/schema/json-schema.test.d.ts +2 -0
  127. package/dist/schema/json-schema.test.d.ts.map +1 -0
  128. package/dist/schema/json-schema.test.js +204 -0
  129. package/dist/schema/json-schema.test.js.map +1 -0
  130. package/dist/schema/schema.test.js +237 -0
  131. package/dist/schema/schema.test.js.map +1 -1
  132. package/dist/schema/standard-schema.d.ts +1 -0
  133. package/dist/schema/standard-schema.d.ts.map +1 -1
  134. package/dist/schema/standard-schema.js +18 -13
  135. package/dist/schema/standard-schema.js.map +1 -1
  136. package/dist/schema/standard-schema.test.d.ts +2 -0
  137. package/dist/schema/standard-schema.test.d.ts.map +1 -0
  138. package/dist/schema/standard-schema.test.js +165 -0
  139. package/dist/schema/standard-schema.test.js.map +1 -0
  140. package/dist/schema/validate.test.js +149 -0
  141. package/dist/schema/validate.test.js.map +1 -1
  142. package/dist/schema/zod.d.ts +7 -4
  143. package/dist/schema/zod.d.ts.map +1 -1
  144. package/dist/schema/zod.js +65 -22
  145. package/dist/schema/zod.js.map +1 -1
  146. package/dist/schema/zod.test.js +112 -0
  147. package/dist/schema/zod.test.js.map +1 -1
  148. package/dist/setupTests.js +3 -0
  149. package/dist/setupTests.js.map +1 -1
  150. package/dist/testing/tools.d.ts +4 -1
  151. package/dist/testing/tools.d.ts.map +1 -1
  152. package/dist/testing/tools.js +6 -1
  153. package/dist/testing/tools.js.map +1 -1
  154. package/dist/util/generate-component.d.ts.map +1 -1
  155. package/dist/util/generate-component.js +18 -3
  156. package/dist/util/generate-component.js.map +1 -1
  157. package/dist/util/generate-component.test.d.ts +2 -0
  158. package/dist/util/generate-component.test.d.ts.map +1 -0
  159. package/dist/util/generate-component.test.js +340 -0
  160. package/dist/util/generate-component.test.js.map +1 -0
  161. package/dist/util/is-promise.d.ts +9 -0
  162. package/dist/util/is-promise.d.ts.map +1 -0
  163. package/dist/util/is-promise.js +20 -0
  164. package/dist/util/is-promise.js.map +1 -0
  165. package/dist/util/is-promise.test.d.ts +2 -0
  166. package/dist/util/is-promise.test.d.ts.map +1 -0
  167. package/dist/util/is-promise.test.js +48 -0
  168. package/dist/util/is-promise.test.js.map +1 -0
  169. package/dist/util/message-builder.d.ts +3 -1
  170. package/dist/util/message-builder.d.ts.map +1 -1
  171. package/dist/util/message-builder.js +20 -3
  172. package/dist/util/message-builder.js.map +1 -1
  173. package/dist/util/message-builder.test.js +269 -0
  174. package/dist/util/message-builder.test.js.map +1 -1
  175. package/dist/util/query-utils.test.d.ts +2 -0
  176. package/dist/util/query-utils.test.d.ts.map +1 -0
  177. package/dist/util/query-utils.test.js +382 -0
  178. package/dist/util/query-utils.test.js.map +1 -0
  179. package/dist/util/registry-validators.d.ts.map +1 -1
  180. package/dist/util/registry-validators.js +7 -0
  181. package/dist/util/registry-validators.js.map +1 -1
  182. package/dist/util/registry-validators.test.js +57 -0
  183. package/dist/util/registry-validators.test.js.map +1 -1
  184. package/dist/util/registry.d.ts.map +1 -1
  185. package/dist/util/registry.js +9 -0
  186. package/dist/util/registry.js.map +1 -1
  187. package/dist/util/registry.test.js +323 -1
  188. package/dist/util/registry.test.js.map +1 -1
  189. package/dist/util/resource-content-resolver.d.ts +20 -0
  190. package/dist/util/resource-content-resolver.d.ts.map +1 -0
  191. package/dist/util/resource-content-resolver.js +93 -0
  192. package/dist/util/resource-content-resolver.js.map +1 -0
  193. package/dist/util/resource-content-resolver.test.d.ts +2 -0
  194. package/dist/util/resource-content-resolver.test.d.ts.map +1 -0
  195. package/dist/util/resource-content-resolver.test.js +254 -0
  196. package/dist/util/resource-content-resolver.test.js.map +1 -0
  197. package/dist/util/resource-validators.test.d.ts +2 -0
  198. package/dist/util/resource-validators.test.d.ts.map +1 -0
  199. package/dist/util/resource-validators.test.js +90 -0
  200. package/dist/util/resource-validators.test.js.map +1 -0
  201. package/dist/util/tool-caller.d.ts +2 -2
  202. package/dist/util/tool-caller.d.ts.map +1 -1
  203. package/dist/util/tool-caller.js +8 -8
  204. package/dist/util/tool-caller.js.map +1 -1
  205. package/dist/util/validate-component-name.test.d.ts +2 -0
  206. package/dist/util/validate-component-name.test.d.ts.map +1 -0
  207. package/dist/util/validate-component-name.test.js +35 -0
  208. package/dist/util/validate-component-name.test.js.map +1 -0
  209. package/esm/context-helpers/context-helpers.test.js +16 -4
  210. package/esm/context-helpers/context-helpers.test.js.map +1 -1
  211. package/esm/context-helpers/current-interactables-context-helper.d.ts +2 -2
  212. package/esm/context-helpers/current-interactables-context-helper.d.ts.map +1 -1
  213. package/esm/context-helpers/current-interactables-context-helper.js +31 -12
  214. package/esm/context-helpers/current-interactables-context-helper.js.map +1 -1
  215. package/esm/context-helpers/registry.d.ts +2 -2
  216. package/esm/context-helpers/registry.d.ts.map +1 -1
  217. package/esm/context-helpers/registry.js.map +1 -1
  218. package/esm/context-helpers/types.d.ts +2 -2
  219. package/esm/context-helpers/types.d.ts.map +1 -1
  220. package/esm/context-helpers/types.js.map +1 -1
  221. package/esm/hoc/with-tambo-interactable.d.ts +50 -4
  222. package/esm/hoc/with-tambo-interactable.d.ts.map +1 -1
  223. package/esm/hoc/with-tambo-interactable.js +20 -5
  224. package/esm/hoc/with-tambo-interactable.js.map +1 -1
  225. package/esm/hooks/use-component-state.d.ts +3 -8
  226. package/esm/hooks/use-component-state.d.ts.map +1 -1
  227. package/esm/hooks/use-component-state.js +8 -0
  228. package/esm/hooks/use-component-state.js.map +1 -1
  229. package/esm/hooks/use-component-state.test.js +37 -0
  230. package/esm/hooks/use-component-state.test.js.map +1 -1
  231. package/esm/hooks/use-message-images.test.js +174 -37
  232. package/esm/hooks/use-message-images.test.js.map +1 -1
  233. package/esm/hooks/use-tambo-threads.js +1 -1
  234. package/esm/hooks/use-tambo-threads.js.map +1 -1
  235. package/esm/hooks/use-tambo-voice.d.ts +1 -1
  236. package/esm/hooks/use-tambo-voice.js +1 -1
  237. package/esm/hooks/use-tambo-voice.js.map +1 -1
  238. package/esm/hooks/use-tambo-voice.test.d.ts +2 -0
  239. package/esm/hooks/use-tambo-voice.test.d.ts.map +1 -0
  240. package/esm/hooks/use-tambo-voice.test.js +234 -0
  241. package/esm/hooks/use-tambo-voice.test.js.map +1 -0
  242. package/esm/index.d.ts +2 -2
  243. package/esm/index.d.ts.map +1 -1
  244. package/esm/index.js.map +1 -1
  245. package/esm/mcp/elicitation.d.ts.map +1 -1
  246. package/esm/mcp/elicitation.js +12 -0
  247. package/esm/mcp/elicitation.js.map +1 -1
  248. package/esm/mcp/elicitation.test.js +8 -1
  249. package/esm/mcp/elicitation.test.js.map +1 -1
  250. package/esm/mcp/mcp-client.d.ts +6 -10
  251. package/esm/mcp/mcp-client.d.ts.map +1 -1
  252. package/esm/mcp/mcp-client.js.map +1 -1
  253. package/esm/mcp/mcp-constants.d.ts +19 -0
  254. package/esm/mcp/mcp-constants.d.ts.map +1 -0
  255. package/esm/mcp/mcp-constants.js +18 -0
  256. package/esm/mcp/mcp-constants.js.map +1 -0
  257. package/esm/mcp/mcp-hooks.d.ts +21 -40
  258. package/esm/mcp/mcp-hooks.d.ts.map +1 -1
  259. package/esm/mcp/mcp-hooks.js +97 -40
  260. package/esm/mcp/mcp-hooks.js.map +1 -1
  261. package/esm/mcp/mcp-hooks.test.js +431 -5
  262. package/esm/mcp/mcp-hooks.test.js.map +1 -1
  263. package/esm/mcp/tambo-mcp-provider.d.ts +7 -0
  264. package/esm/mcp/tambo-mcp-provider.d.ts.map +1 -1
  265. package/esm/mcp/tambo-mcp-provider.js +204 -154
  266. package/esm/mcp/tambo-mcp-provider.js.map +1 -1
  267. package/esm/mcp/tambo-mcp-provider.test.js +37 -0
  268. package/esm/mcp/tambo-mcp-provider.test.js.map +1 -1
  269. package/esm/model/component-metadata.d.ts +54 -21
  270. package/esm/model/component-metadata.d.ts.map +1 -1
  271. package/esm/model/component-metadata.js.map +1 -1
  272. package/esm/model/tambo-interactable.d.ts +13 -5
  273. package/esm/model/tambo-interactable.d.ts.map +1 -1
  274. package/esm/model/tambo-interactable.js.map +1 -1
  275. package/esm/providers/__tests__/thread-input-resource-resolution.test.d.ts +2 -0
  276. package/esm/providers/__tests__/thread-input-resource-resolution.test.d.ts.map +1 -0
  277. package/esm/providers/__tests__/thread-input-resource-resolution.test.js +587 -0
  278. package/esm/providers/__tests__/thread-input-resource-resolution.test.js.map +1 -0
  279. package/esm/providers/index.d.ts +1 -1
  280. package/esm/providers/index.d.ts.map +1 -1
  281. package/esm/providers/index.js.map +1 -1
  282. package/esm/providers/tambo-client-provider.d.ts +8 -0
  283. package/esm/providers/tambo-client-provider.d.ts.map +1 -1
  284. package/esm/providers/tambo-client-provider.js +11 -12
  285. package/esm/providers/tambo-client-provider.js.map +1 -1
  286. package/esm/providers/tambo-client-provider.test.d.ts +2 -0
  287. package/esm/providers/tambo-client-provider.test.d.ts.map +1 -0
  288. package/esm/providers/tambo-client-provider.test.js +203 -0
  289. package/esm/providers/tambo-client-provider.test.js.map +1 -0
  290. package/esm/providers/tambo-context-attachment-provider.d.ts +34 -92
  291. package/esm/providers/tambo-context-attachment-provider.d.ts.map +1 -1
  292. package/esm/providers/tambo-context-attachment-provider.js +63 -106
  293. package/esm/providers/tambo-context-attachment-provider.js.map +1 -1
  294. package/esm/providers/tambo-context-attachment-provider.test.js +230 -464
  295. package/esm/providers/tambo-context-attachment-provider.test.js.map +1 -1
  296. package/esm/providers/tambo-interactable-provider-partial-updates.test.js +22 -21
  297. package/esm/providers/tambo-interactable-provider-partial-updates.test.js.map +1 -1
  298. package/esm/providers/tambo-interactable-provider.d.ts +5 -2
  299. package/esm/providers/tambo-interactable-provider.d.ts.map +1 -1
  300. package/esm/providers/tambo-interactable-provider.js +126 -17
  301. package/esm/providers/tambo-interactable-provider.js.map +1 -1
  302. package/esm/providers/tambo-interactable-provider.test.js +242 -0
  303. package/esm/providers/tambo-interactable-provider.test.js.map +1 -1
  304. package/esm/providers/tambo-interactables-additional-context.test.js +2 -5
  305. package/esm/providers/tambo-interactables-additional-context.test.js.map +1 -1
  306. package/esm/providers/tambo-provider.d.ts +2 -3
  307. package/esm/providers/tambo-provider.d.ts.map +1 -1
  308. package/esm/providers/tambo-provider.js +6 -5
  309. package/esm/providers/tambo-provider.js.map +1 -1
  310. package/esm/providers/tambo-registry-provider.test.js +16 -0
  311. package/esm/providers/tambo-registry-provider.test.js.map +1 -1
  312. package/esm/providers/tambo-registry-schema-compat.test.js +31 -0
  313. package/esm/providers/tambo-registry-schema-compat.test.js.map +1 -1
  314. package/esm/providers/tambo-thread-input-provider.d.ts +1 -1
  315. package/esm/providers/tambo-thread-input-provider.d.ts.map +1 -1
  316. package/esm/providers/tambo-thread-input-provider.js +26 -4
  317. package/esm/providers/tambo-thread-input-provider.js.map +1 -1
  318. package/esm/providers/tambo-thread-provider-initial-messages.test.js +84 -2
  319. package/esm/providers/tambo-thread-provider-initial-messages.test.js.map +1 -1
  320. package/esm/providers/tambo-thread-provider.d.ts.map +1 -1
  321. package/esm/providers/tambo-thread-provider.js +53 -42
  322. package/esm/providers/tambo-thread-provider.js.map +1 -1
  323. package/esm/providers/tambo-thread-provider.test.js +368 -262
  324. package/esm/providers/tambo-thread-provider.test.js.map +1 -1
  325. package/esm/schema/index.d.ts +1 -1
  326. package/esm/schema/index.d.ts.map +1 -1
  327. package/esm/schema/index.js +1 -1
  328. package/esm/schema/index.js.map +1 -1
  329. package/esm/schema/json-schema.d.ts +7 -0
  330. package/esm/schema/json-schema.d.ts.map +1 -1
  331. package/esm/schema/json-schema.js +11 -1
  332. package/esm/schema/json-schema.js.map +1 -1
  333. package/esm/schema/json-schema.test.d.ts +2 -0
  334. package/esm/schema/json-schema.test.d.ts.map +1 -0
  335. package/esm/schema/json-schema.test.js +202 -0
  336. package/esm/schema/json-schema.test.js.map +1 -0
  337. package/esm/schema/schema.test.js +238 -1
  338. package/esm/schema/schema.test.js.map +1 -1
  339. package/esm/schema/standard-schema.d.ts +1 -0
  340. package/esm/schema/standard-schema.d.ts.map +1 -1
  341. package/esm/schema/standard-schema.js +18 -13
  342. package/esm/schema/standard-schema.js.map +1 -1
  343. package/esm/schema/standard-schema.test.d.ts +2 -0
  344. package/esm/schema/standard-schema.test.d.ts.map +1 -0
  345. package/esm/schema/standard-schema.test.js +130 -0
  346. package/esm/schema/standard-schema.test.js.map +1 -0
  347. package/esm/schema/validate.test.js +149 -0
  348. package/esm/schema/validate.test.js.map +1 -1
  349. package/esm/schema/zod.d.ts +7 -4
  350. package/esm/schema/zod.d.ts.map +1 -1
  351. package/esm/schema/zod.js +65 -22
  352. package/esm/schema/zod.js.map +1 -1
  353. package/esm/schema/zod.test.js +113 -1
  354. package/esm/schema/zod.test.js.map +1 -1
  355. package/esm/setupTests.js +3 -0
  356. package/esm/setupTests.js.map +1 -1
  357. package/esm/testing/tools.d.ts +4 -1
  358. package/esm/testing/tools.d.ts.map +1 -1
  359. package/esm/testing/tools.js +6 -1
  360. package/esm/testing/tools.js.map +1 -1
  361. package/esm/util/generate-component.d.ts.map +1 -1
  362. package/esm/util/generate-component.js +18 -3
  363. package/esm/util/generate-component.js.map +1 -1
  364. package/esm/util/generate-component.test.d.ts +2 -0
  365. package/esm/util/generate-component.test.d.ts.map +1 -0
  366. package/esm/util/generate-component.test.js +302 -0
  367. package/esm/util/generate-component.test.js.map +1 -0
  368. package/esm/util/is-promise.d.ts +9 -0
  369. package/esm/util/is-promise.d.ts.map +1 -0
  370. package/esm/util/is-promise.js +17 -0
  371. package/esm/util/is-promise.js.map +1 -0
  372. package/esm/util/is-promise.test.d.ts +2 -0
  373. package/esm/util/is-promise.test.d.ts.map +1 -0
  374. package/esm/util/is-promise.test.js +46 -0
  375. package/esm/util/is-promise.test.js.map +1 -0
  376. package/esm/util/message-builder.d.ts +3 -1
  377. package/esm/util/message-builder.d.ts.map +1 -1
  378. package/esm/util/message-builder.js +20 -3
  379. package/esm/util/message-builder.js.map +1 -1
  380. package/esm/util/message-builder.test.js +269 -0
  381. package/esm/util/message-builder.test.js.map +1 -1
  382. package/esm/util/query-utils.test.d.ts +2 -0
  383. package/esm/util/query-utils.test.d.ts.map +1 -0
  384. package/esm/util/query-utils.test.js +380 -0
  385. package/esm/util/query-utils.test.js.map +1 -0
  386. package/esm/util/registry-validators.d.ts.map +1 -1
  387. package/esm/util/registry-validators.js +7 -0
  388. package/esm/util/registry-validators.js.map +1 -1
  389. package/esm/util/registry-validators.test.js +57 -0
  390. package/esm/util/registry-validators.test.js.map +1 -1
  391. package/esm/util/registry.d.ts.map +1 -1
  392. package/esm/util/registry.js +9 -0
  393. package/esm/util/registry.js.map +1 -1
  394. package/esm/util/registry.test.js +324 -2
  395. package/esm/util/registry.test.js.map +1 -1
  396. package/esm/util/resource-content-resolver.d.ts +20 -0
  397. package/esm/util/resource-content-resolver.d.ts.map +1 -0
  398. package/esm/util/resource-content-resolver.js +89 -0
  399. package/esm/util/resource-content-resolver.js.map +1 -0
  400. package/esm/util/resource-content-resolver.test.d.ts +2 -0
  401. package/esm/util/resource-content-resolver.test.d.ts.map +1 -0
  402. package/esm/util/resource-content-resolver.test.js +252 -0
  403. package/esm/util/resource-content-resolver.test.js.map +1 -0
  404. package/esm/util/resource-validators.test.d.ts +2 -0
  405. package/esm/util/resource-validators.test.d.ts.map +1 -0
  406. package/esm/util/resource-validators.test.js +88 -0
  407. package/esm/util/resource-validators.test.js.map +1 -0
  408. package/esm/util/tool-caller.d.ts +2 -2
  409. package/esm/util/tool-caller.d.ts.map +1 -1
  410. package/esm/util/tool-caller.js +8 -8
  411. package/esm/util/tool-caller.js.map +1 -1
  412. package/esm/util/validate-component-name.test.d.ts +2 -0
  413. package/esm/util/validate-component-name.test.d.ts.map +1 -0
  414. package/esm/util/validate-component-name.test.js +33 -0
  415. package/esm/util/validate-component-name.test.js.map +1 -0
  416. package/package.json +15 -23
  417. package/dist/schema/alias.d.ts +0 -3
  418. package/dist/schema/alias.d.ts.map +0 -1
  419. package/dist/schema/alias.js +0 -6
  420. package/dist/schema/alias.js.map +0 -1
  421. package/esm/schema/alias.d.ts +0 -3
  422. package/esm/schema/alias.d.ts.map +0 -1
  423. package/esm/schema/alias.js +0 -13
  424. package/esm/schema/alias.js.map +0 -1
@@ -1,8 +1,10 @@
1
1
  // react-sdk/src/providers/tambo-interactable-provider.tsx
2
2
  "use client";
3
+ import { deepEqual } from "fast-equals";
3
4
  import React, { createContext, useCallback, useContext, useEffect, useMemo, useState, } from "react";
4
5
  import { z } from "zod/v3";
5
6
  import { createInteractablesContextHelper } from "../context-helpers/current-interactables-context-helper";
7
+ import { makeJsonSchemaPartial, schemaToJsonSchema } from "../schema";
6
8
  import { assertValidName } from "../util/validate-component-name";
7
9
  import { useTamboComponent } from "./tambo-component-provider";
8
10
  import { useTamboContextHelpers } from "./tambo-context-helpers-provider";
@@ -16,6 +18,8 @@ const TamboInteractableContext = createContext({
16
18
  clearAllInteractableComponents: () => { },
17
19
  setInteractableState: () => { },
18
20
  getInteractableComponentState: () => undefined,
21
+ setInteractableSelected: () => { },
22
+ clearInteractableSelections: () => { },
19
23
  });
20
24
  /**
21
25
  * The TamboInteractableProvider manages a list of components that are currently
@@ -169,32 +173,110 @@ export const TamboInteractableProvider = ({ children, }) => {
169
173
  });
170
174
  return "Updated successfully";
171
175
  }, []);
172
- const registerInteractableComponentUpdateTool = useCallback((component, maxNameLength = 60) => {
173
- const tamboToolNamePart = `update_component_`;
176
+ const updateInteractableComponentState = useCallback((componentId, newState) => {
177
+ if (!newState || Object.keys(newState).length === 0) {
178
+ return `Warning: No state values provided for component with ID ${componentId}.`;
179
+ }
180
+ setInteractableComponents((components = []) => {
181
+ const component = components.find((c) => c.id === componentId);
182
+ if (!component)
183
+ return components;
184
+ const prevState = component.state ?? {};
185
+ const updatedState = { ...prevState, ...newState };
186
+ if (deepEqual(prevState, updatedState))
187
+ return components;
188
+ // TODO(lachieh): validate state against schema?
189
+ const updated = {
190
+ ...component,
191
+ state: updatedState,
192
+ };
193
+ return components.map((c) => (c.id === componentId ? updated : c));
194
+ });
195
+ return "Updated successfully";
196
+ }, []);
197
+ const registerInteractableComponentPropsUpdateTool = useCallback((component, maxNameLength = 60) => {
198
+ const tamboToolNamePart = `update_component_props_`;
174
199
  const availableLength = maxNameLength - tamboToolNamePart.length;
175
200
  if (component.id.length > availableLength) {
176
201
  throw new Error(`Interactable component id ${component.id} is too long. It must be less than ${availableLength} characters.`);
177
202
  }
178
- const schemaForArgs = typeof component.propsSchema === "object" &&
179
- "describe" in component.propsSchema &&
180
- "partial" in component.propsSchema
181
- ? component.propsSchema.partial()
182
- : z.object({});
203
+ // Build newProps schema as JSON Schema
204
+ let newPropsSchema;
205
+ if (component.propsSchema) {
206
+ // Convert any supported schema to JSON Schema, then make partial
207
+ const fullSchema = schemaToJsonSchema(component.propsSchema);
208
+ newPropsSchema = makeJsonSchemaPartial(fullSchema);
209
+ }
210
+ else {
211
+ // No schema - allow any properties
212
+ newPropsSchema = { type: "object", additionalProperties: true };
213
+ }
214
+ // Build the full input schema as JSON Schema
215
+ const inputSchema = {
216
+ type: "object",
217
+ properties: {
218
+ componentId: {
219
+ type: "string",
220
+ description: "The ID of the interactable component to update",
221
+ },
222
+ newProps: {
223
+ ...newPropsSchema,
224
+ description: "The props to update. Provide only the props you want to change.",
225
+ },
226
+ },
227
+ required: ["componentId", "newProps"],
228
+ };
183
229
  registerTool({
184
230
  name: `${tamboToolNamePart}${component.id}`,
185
- description: `Update the props of interactable component ${component.id} (${component.name}). You can provide partial props (only the props you want to change) or complete props (all props). Only the props you specify will be updated.`,
231
+ description: `Update the props of interactable component ${component.id} (${component.name}). Provide partial props (only props to change).`,
186
232
  tool: ({ componentId, newProps }) => {
187
233
  return updateInteractableComponentProps(componentId, newProps);
188
234
  },
189
- inputSchema: z.object({
190
- componentId: z
191
- .string()
192
- .describe("The ID of the interactable component to update"),
193
- newProps: schemaForArgs.describe("The props to update the component with. You can provide partial props (only the props you want to change) or complete props (all props). Only the props you specify will be updated."),
194
- }),
235
+ inputSchema,
195
236
  outputSchema: z.string(),
196
237
  });
197
238
  }, [registerTool, updateInteractableComponentProps]);
239
+ const registerInteractableComponentStateUpdateTool = useCallback((component, maxNameLength = 60) => {
240
+ const tamboToolNamePart = `update_component_state_`;
241
+ const availableLength = maxNameLength - tamboToolNamePart.length;
242
+ if (component.id.length > availableLength) {
243
+ throw new Error(`Interactable component id ${component.id} is too long. It must be less than ${availableLength} characters.`);
244
+ }
245
+ // Build newState schema as JSON Schema
246
+ let newStateSchema = {
247
+ type: "object",
248
+ additionalProperties: true,
249
+ };
250
+ if (component.stateSchema) {
251
+ // Convert any supported schema to JSON Schema, then make partial
252
+ const fullSchema = schemaToJsonSchema(component.stateSchema);
253
+ newStateSchema = makeJsonSchemaPartial(fullSchema);
254
+ }
255
+ // Build the full input schema as JSON Schema
256
+ const inputSchema = {
257
+ type: "object",
258
+ properties: {
259
+ componentId: {
260
+ type: "string",
261
+ description: "The ID of the interactable component to update",
262
+ },
263
+ newState: {
264
+ ...newStateSchema,
265
+ description: "The state values to update. Provide only the keys you want to change.",
266
+ },
267
+ },
268
+ required: ["componentId", "newState"],
269
+ };
270
+ registerTool({
271
+ name: `${tamboToolNamePart}${component.id}`,
272
+ description: `Update the state of interactable component ${component.id} (${component.name}). You may provide partial state (only keys to change).`,
273
+ tool: ({ componentId, newState }) => {
274
+ return updateInteractableComponentState(componentId, newState);
275
+ },
276
+ inputSchema,
277
+ outputSchema: z.string(),
278
+ });
279
+ }, [registerTool, updateInteractableComponentState]);
198
280
  const addInteractableComponent = useCallback((component) => {
199
281
  // Validate component name
200
282
  assertValidName(component.name, "component");
@@ -206,12 +288,16 @@ export const TamboInteractableProvider = ({ children, }) => {
206
288
  id,
207
289
  state: component.state ?? {},
208
290
  };
209
- registerInteractableComponentUpdateTool(newComponent);
291
+ registerInteractableComponentPropsUpdateTool(newComponent);
292
+ registerInteractableComponentStateUpdateTool(newComponent);
210
293
  setInteractableComponents((prev) => {
211
294
  return [...prev, newComponent];
212
295
  });
213
296
  return id;
214
- }, [registerInteractableComponentUpdateTool]);
297
+ }, [
298
+ registerInteractableComponentPropsUpdateTool,
299
+ registerInteractableComponentStateUpdateTool,
300
+ ]);
215
301
  const removeInteractableComponent = useCallback((id) => {
216
302
  setInteractableComponents((prev) => prev.filter((c) => c.id !== id));
217
303
  }, []);
@@ -234,7 +320,7 @@ export const TamboInteractableProvider = ({ children, }) => {
234
320
  const updated = {
235
321
  ...component,
236
322
  state: {
237
- ...(component.state ?? {}),
323
+ ...component.state,
238
324
  [key]: value,
239
325
  },
240
326
  };
@@ -251,6 +337,27 @@ export const TamboInteractableProvider = ({ children, }) => {
251
337
  const component = interactableComponents.find((c) => c.id === componentId);
252
338
  return component?.state;
253
339
  }, [interactableComponents]);
340
+ const setInteractableSelected = useCallback((componentId, isSelected) => {
341
+ setInteractableComponents((prev) => {
342
+ let found = false;
343
+ const next = prev.map((component) => {
344
+ if (component.id !== componentId)
345
+ return component;
346
+ found = true;
347
+ return component.isSelected === isSelected
348
+ ? component
349
+ : { ...component, isSelected: isSelected };
350
+ });
351
+ return found ? next : prev;
352
+ });
353
+ }, []);
354
+ const clearInteractableSelections = useCallback(() => {
355
+ setInteractableComponents((prev) => {
356
+ if (!prev.some((c) => c.isSelected))
357
+ return prev;
358
+ return prev.map((c) => (c.isSelected ? { ...c, isSelected: false } : c));
359
+ });
360
+ }, []);
254
361
  const value = {
255
362
  interactableComponents,
256
363
  addInteractableComponent,
@@ -261,6 +368,8 @@ export const TamboInteractableProvider = ({ children, }) => {
261
368
  clearAllInteractableComponents,
262
369
  setInteractableState: setInteractableStateValue,
263
370
  getInteractableComponentState,
371
+ setInteractableSelected,
372
+ clearInteractableSelections,
264
373
  };
265
374
  return (React.createElement(TamboInteractableContext.Provider, { value: value }, children));
266
375
  };
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-interactable-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-interactable-provider.tsx"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,YAAY,CAAC;AACb,OAAO,KAAK,EAAE,EACZ,aAAa,EAEb,WAAW,EACX,UAAU,EACV,SAAS,EACT,OAAO,EACP,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,gCAAgC,EAAE,MAAM,yDAAyD,CAAC;AAK3G,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAE1E,MAAM,wBAAwB,GAAG,aAAa,CAA2B;IACvE,sBAAsB,EAAE,E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F,OAAO,SAAS,EAAE,KAAK,CAAC;IAC1B,CAAC,EACD,CAAC,sBAAsB,CAAC,CACzB,CAAC;IAEF,MAAM,KAAK,GAA6B;QACtC,sBAAsB;QACtB,wBAAwB;QACxB,2BAA2B;QAC3B,gCAAgC;QAChC,wBAAwB;QACxB,+BAA+B;QAC/B,8BAA8B;QAC9B,oBAAoB,EAAE,yBAAyB;QAC/C,6BAA6B;KAC9B,CAAC;IAEF,OAAO,CACL,oBAAC,wBAAwB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IAC5C,QAAQ,CACyB,CACrC,CAAC;AACJ,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,EAAE;IACvC,OAAO,UAAU,CAAC,wBAAwB,CAAC,CAAC;AAC9C,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,GAAG,EAAE;IAClD,MAAM,EAAE,sBAAsB,EAAE,GAAG,oBAAoB,EAAE,CAAC;IAC1D,0DAA0D;IAC1D,MAAM,IAAI,GAAG,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC9C,GAAG,CAAC;QACJ,KAAK,EAAE,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE;KACtB,CAAC,CAAC,CAAC;IAEJ,OAAO,IAAI,CAAC;AACd,CAAC,CAAC","sourcesContent":["// react-sdk/src/providers/tambo-interactable-provider.tsx\n\"use client\";\nimport React, {\n createContext,\n PropsWithChildren,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useState,\n} from \"react\";\nimport { z } from \"zod/v3\";\nimport { createInteractablesContextHelper } from \"../context-helpers/current-interactables-context-helper\";\nimport {\n TamboInteractableComponent,\n type TamboInteractableContext,\n} from \"../model/tambo-interactable\";\nimport { assertValidName } from \"../util/validate-component-name\";\nimport { useTamboComponent } from \"./tambo-component-provider\";\nimport { useTamboContextHelpers } from \"./tambo-context-helpers-provider\";\n\nconst TamboInteractableContext = createContext<TamboInteractableContext>({\n interactableComponents: [],\n addInteractableComponent: () => \"\",\n removeInteractableComponent: () => {},\n updateInteractableComponentProps: () => \"\",\n getInteractableComponent: () => undefined,\n getInteractableComponentsByName: () => [],\n clearAllInteractableComponents: () => {},\n setInteractableState: () => {},\n getInteractableComponentState: () => undefined,\n});\n\n/**\n * The TamboInteractableProvider manages a list of components that are currently\n * interactable, allowing tambo to interact with them by updating their props. It also registers tools\n * for Tambo to perform CRUD operations on the components list.\n * @param props - The props for the TamboInteractableProvider\n * @param props.children - The children to wrap\n * @returns The TamboInteractableProvider component\n */\nexport const TamboInteractableProvider: React.FC<PropsWithChildren> = ({\n children,\n}) => {\n const [interactableComponents, setInteractableComponents] = useState<\n TamboInteractableComponent[]\n >([]);\n const { registerTool } = useTamboComponent();\n const { addContextHelper, removeContextHelper } = useTamboContextHelpers();\n\n // Create a stable context helper function for interactable components\n const interactablesContextHelper = useMemo(\n () => createInteractablesContextHelper(interactableComponents),\n [interactableComponents],\n );\n\n // Register the interactables context helper\n useEffect(() => {\n addContextHelper(\"interactables\", interactablesContextHelper);\n\n return () => {\n removeContextHelper(\"interactables\");\n };\n }, [interactablesContextHelper, addContextHelper, removeContextHelper]);\n\n useEffect(() => {\n if (interactableComponents.length > 0) {\n registerTool({\n name: \"get_all_interactable_components\",\n description:\n \"Only use this tool if the user is asking about interactable components.Get all currently interactable components with their details including their current props. These are components that you can interact with on behalf of the user.\",\n tool: () => {\n return {\n components: interactableComponents,\n };\n },\n inputSchema: z.object({}),\n outputSchema: z.object({\n components: z.array(\n z.object({\n id: z.string(),\n name: z.string(),\n props: z.record(z.string(), z.any()),\n propsSchema: z.record(z.string(), z.any()).optional(),\n }),\n ),\n }),\n });\n\n registerTool({\n name: \"get_interactable_component_by_id\",\n description: \"Get a specific interactable component by its ID\",\n tool: ({ componentId }) => {\n const component = interactableComponents.find(\n (c) => c.id === componentId,\n );\n\n if (!component) {\n return {\n success: false,\n error: `Component with ID ${componentId} not found`,\n } as const;\n }\n\n return {\n success: true,\n component: {\n id: component.id,\n componentName: component.name,\n props: component.props,\n },\n } as const;\n },\n inputSchema: z.object({\n componentId: z.string().describe(\"The ID of the component\"),\n }),\n outputSchema: z.discriminatedUnion(\"success\", [\n z.object({\n success: z.literal(true),\n component: z\n .object({\n id: z.string(),\n componentName: z.string(),\n props: z.record(z.string(), z.any()),\n })\n .optional(),\n }),\n z.object({\n success: z.literal(false),\n error: z.string(),\n }),\n ]),\n });\n\n registerTool({\n name: \"remove_interactable_component\",\n description: \"Remove an interactable component from the system\",\n tool: ({ componentId }) => {\n const component = interactableComponents.find(\n (c) => c.id === componentId,\n );\n\n if (!component) {\n return {\n success: false,\n error: `Component with ID ${componentId} not found`,\n } as const;\n }\n\n setInteractableComponents((prev) =>\n prev.filter((c) => c.id !== componentId),\n );\n\n return {\n success: true,\n componentId,\n removedComponent: {\n id: component.id,\n componentName: component.name,\n props: component.props,\n },\n } as const;\n },\n inputSchema: z.object({\n componentId: z.string().describe(\"The ID of the component\"),\n }),\n outputSchema: z.discriminatedUnion(\"success\", [\n z.object({\n success: z.literal(true),\n componentId: z.string(),\n removedComponent: z.object({\n id: z.string(),\n componentName: z.string(),\n props: z.record(z.string(), z.any()),\n }),\n }),\n z.object({\n success: z.literal(false),\n error: z.string(),\n }),\n ]),\n });\n }\n }, [interactableComponents, registerTool]);\n\n const updateInteractableComponentProps = useCallback(\n (id: string, newProps: Record<string, any>): string => {\n if (!newProps || Object.keys(newProps).length === 0) {\n return `Warning: No props provided for component with ID ${id}.`;\n }\n\n setInteractableComponents((prev) => {\n const component = prev.find((c) => c.id === id);\n if (!component) {\n return prev;\n }\n\n // Compare props shallowly\n const propsChanged = Object.entries(newProps).some(([key, value]) => {\n return component.props[key] !== value;\n });\n\n if (!propsChanged) {\n return prev; // unchanged\n }\n\n // Apply partial update\n const updated = {\n ...component,\n props: { ...component.props, ...newProps },\n };\n\n const updatedComponents = [...prev];\n const idx = prev.findIndex((c) => c.id === id);\n updatedComponents[idx] = updated;\n\n return updatedComponents;\n });\n\n return \"Updated successfully\";\n },\n [],\n );\n\n const registerInteractableComponentUpdateTool = useCallback(\n (component: TamboInteractableComponent, maxNameLength = 60) => {\n const tamboToolNamePart = `update_component_`;\n const availableLength = maxNameLength - tamboToolNamePart.length;\n if (component.id.length > availableLength) {\n throw new Error(\n `Interactable component id ${component.id} is too long. It must be less than ${availableLength} characters.`,\n );\n }\n\n const schemaForArgs =\n typeof component.propsSchema === \"object\" &&\n \"describe\" in component.propsSchema &&\n \"partial\" in component.propsSchema\n ? (component.propsSchema as any).partial()\n : z.object({});\n\n registerTool({\n name: `${tamboToolNamePart}${component.id}`,\n description: `Update the props of interactable component ${component.id} (${component.name}). You can provide partial props (only the props you want to change) or complete props (all props). Only the props you specify will be updated.`,\n tool: ({ componentId, newProps }) => {\n return updateInteractableComponentProps(componentId, newProps);\n },\n inputSchema: z.object({\n componentId: z\n .string()\n .describe(\"The ID of the interactable component to update\"),\n newProps: schemaForArgs.describe(\n \"The props to update the component with. You can provide partial props (only the props you want to change) or complete props (all props). Only the props you specify will be updated.\",\n ),\n }),\n outputSchema: z.string(),\n });\n },\n [registerTool, updateInteractableComponentProps],\n );\n\n const addInteractableComponent = useCallback(\n (\n component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\">,\n ): string => {\n // Validate component name\n assertValidName(component.name, \"component\");\n\n // Add a random part to the component name to make it unique when using multiple instances of the same component.\n const tamboGeneratedNamePart = `-${Math.random().toString(36).slice(2, 5)}`;\n const id = `${component.name}${tamboGeneratedNamePart}`;\n const newComponent: TamboInteractableComponent = {\n ...component,\n id,\n state: component.state ?? {},\n };\n\n registerInteractableComponentUpdateTool(newComponent);\n\n setInteractableComponents((prev) => {\n return [...prev, newComponent];\n });\n\n return id;\n },\n [registerInteractableComponentUpdateTool],\n );\n\n const removeInteractableComponent = useCallback((id: string) => {\n setInteractableComponents((prev) => prev.filter((c) => c.id !== id));\n }, []);\n\n const getInteractableComponent = useCallback(\n (id: string) => {\n return interactableComponents.find((c) => c.id === id);\n },\n [interactableComponents],\n );\n\n const getInteractableComponentsByName = useCallback(\n (componentName: string) => {\n return interactableComponents.filter((c) => c.name === componentName);\n },\n [interactableComponents],\n );\n\n const clearAllInteractableComponents = useCallback(() => {\n setInteractableComponents([]);\n }, []);\n\n const setInteractableStateValue = useCallback(\n (componentId: string, key: string, value: unknown) => {\n setInteractableComponents((prev) => {\n const component = prev.find((c) => c.id === componentId);\n if (!component) {\n console.warn(\n `Tried to update state for component ${componentId} but it was not found.`,\n );\n return prev;\n }\n\n const updated = {\n ...component,\n state: {\n ...(component.state ?? {}),\n [key]: value,\n },\n };\n\n const updatedComponents = prev.map((component) => {\n if (component.id === componentId) {\n return updated;\n }\n return component;\n });\n\n return updatedComponents;\n });\n },\n [],\n );\n\n const getInteractableComponentState = useCallback(\n (componentId: string) => {\n const component = interactableComponents.find(\n (c) => c.id === componentId,\n );\n return component?.state;\n },\n [interactableComponents],\n );\n\n const value: TamboInteractableContext = {\n interactableComponents,\n addInteractableComponent,\n removeInteractableComponent,\n updateInteractableComponentProps,\n getInteractableComponent,\n getInteractableComponentsByName,\n clearAllInteractableComponents,\n setInteractableState: setInteractableStateValue,\n getInteractableComponentState,\n };\n\n return (\n <TamboInteractableContext.Provider value={value}>\n {children}\n </TamboInteractableContext.Provider>\n );\n};\n\n/**\n * The useTamboInteractable hook provides access to the interactable component\n * management functions.\n * @returns The interactable component management functions\n */\nexport const useTamboInteractable = () => {\n return useContext(TamboInteractableContext);\n};\n\n/**\n * Hook to get a cloned snapshot of the current interactables.\n * Returns a shallow copy of the array with cloned items and props to prevent\n * external mutation from affecting internal state.\n * @returns The current interactables snapshot (cloned).\n */\nexport const useCurrentInteractablesSnapshot = () => {\n const { interactableComponents } = useTamboInteractable();\n // Clone the array and each item/props to prevent mutation\n const copy = interactableComponents.map((c) => ({\n ...c,\n props: { ...c.props },\n }));\n\n return copy;\n};\n"]}
1
+ {"version":3,"file":"tambo-interactable-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-interactable-provider.tsx"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,YAAY,CAAC;AACb,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,KAAK,EAAE,EACZ,aAAa,EAEb,WAAW,EACX,UAAU,EACV,SAAS,EACT,OAAO,EACP,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,gCAAgC,EAAE,MAAM,yDAAyD,CAAC;AAK3G,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAE1E,MAAM,wBAAwB,GAAG,aAAa,CAA2B;IACvE,sBAAsB,EAAE,EAAE;IAC1B,wBAAwB,EAAE,GAAG,EAAE,CAAC,EAAE;IAClC,2BAA2B,EAAE,GAAG,EAAE,GAAE,CAAC;IACrC,gCAAgC,EAAE,GAAG,EAAE,CAAC,EAAE;IAC1C,wBAAwB,EAAE,GAAG,EAAE,CAAC,SAAS;IACzC,+BAA+B,EAAE,GAAG,EAAE,CAAC,EAAE;IACzC,8BAA8B,EAAE,GAAG,EAAE,GAAE,CAAC;IACxC,oBAAoB,EAAE,GAAG,EAAE,GAAE,CAAC;IAC9B,6BAA6B,EAAE,GAAG,EAAE,CAAC,SAAS;IAC9C,uBAAuB,EAAE,GAAG,EAAE,GAAE,CAAC;IACjC,2BAA2B,EAAE,GAAG,EAAE,GAAE,CAAC;CACtC,CAAC,CAAC;AAEH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAgC,CAAC,EACrE,QAAQ,GACT,EAAE,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GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,EAAE;IACvC,OAAO,UAAU,CAAC,wBAAwB,CAAC,CAAC;AAC9C,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,GAAG,EAAE;IAClD,MAAM,EAAE,sBAAsB,EAAE,GAAG,oBAAoB,EAAE,CAAC;IAC1D,0DAA0D;IAC1D,MAAM,IAAI,GAAG,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC9C,GAAG,CAAC;QACJ,KAAK,EAAE,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE;KACtB,CAAC,CAAC,CAAC;IAEJ,OAAO,IAAI,CAAC;AACd,CAAC,CAAC","sourcesContent":["// react-sdk/src/providers/tambo-interactable-provider.tsx\n\"use client\";\nimport { deepEqual } from \"fast-equals\";\nimport { JSONSchema7 } from \"json-schema\";\nimport React, {\n createContext,\n PropsWithChildren,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useState,\n} from \"react\";\nimport { z } from \"zod/v3\";\nimport { createInteractablesContextHelper } from \"../context-helpers/current-interactables-context-helper\";\nimport {\n TamboInteractableComponent,\n type TamboInteractableContext,\n} from \"../model/tambo-interactable\";\nimport { makeJsonSchemaPartial, schemaToJsonSchema } from \"../schema\";\nimport { assertValidName } from \"../util/validate-component-name\";\nimport { useTamboComponent } from \"./tambo-component-provider\";\nimport { useTamboContextHelpers } from \"./tambo-context-helpers-provider\";\n\nconst TamboInteractableContext = createContext<TamboInteractableContext>({\n interactableComponents: [],\n addInteractableComponent: () => \"\",\n removeInteractableComponent: () => {},\n updateInteractableComponentProps: () => \"\",\n getInteractableComponent: () => undefined,\n getInteractableComponentsByName: () => [],\n clearAllInteractableComponents: () => {},\n setInteractableState: () => {},\n getInteractableComponentState: () => undefined,\n setInteractableSelected: () => {},\n clearInteractableSelections: () => {},\n});\n\n/**\n * The TamboInteractableProvider manages a list of components that are currently\n * interactable, allowing tambo to interact with them by updating their props. It also registers tools\n * for Tambo to perform CRUD operations on the components list.\n * @param props - The props for the TamboInteractableProvider\n * @param props.children - The children to wrap\n * @returns The TamboInteractableProvider component\n */\nexport const TamboInteractableProvider: React.FC<PropsWithChildren> = ({\n children,\n}) => {\n const [interactableComponents, setInteractableComponents] = useState<\n TamboInteractableComponent[]\n >([]);\n const { registerTool } = useTamboComponent();\n const { addContextHelper, removeContextHelper } = useTamboContextHelpers();\n\n // Create a stable context helper function for interactable components\n const interactablesContextHelper = useMemo(\n () => createInteractablesContextHelper(interactableComponents),\n [interactableComponents],\n );\n\n // Register the interactables context helper\n useEffect(() => {\n addContextHelper(\"interactables\", interactablesContextHelper);\n\n return () => {\n removeContextHelper(\"interactables\");\n };\n }, [interactablesContextHelper, addContextHelper, removeContextHelper]);\n\n useEffect(() => {\n if (interactableComponents.length > 0) {\n registerTool({\n name: \"get_all_interactable_components\",\n description:\n \"Only use this tool if the user is asking about interactable components.Get all currently interactable components with their details including their current props. These are components that you can interact with on behalf of the user.\",\n tool: () => {\n return {\n components: interactableComponents,\n };\n },\n inputSchema: z.object({}),\n outputSchema: z.object({\n components: z.array(\n z.object({\n id: z.string(),\n name: z.string(),\n props: z.record(z.string(), z.any()),\n propsSchema: z.record(z.string(), z.any()).optional(),\n }),\n ),\n }),\n });\n\n registerTool({\n name: \"get_interactable_component_by_id\",\n description: \"Get a specific interactable component by its ID\",\n tool: ({ componentId }) => {\n const component = interactableComponents.find(\n (c) => c.id === componentId,\n );\n\n if (!component) {\n return {\n success: false,\n error: `Component with ID ${componentId} not found`,\n } as const;\n }\n\n return {\n success: true,\n component: {\n id: component.id,\n componentName: component.name,\n props: component.props,\n },\n } as const;\n },\n inputSchema: z.object({\n componentId: z.string().describe(\"The ID of the component\"),\n }),\n outputSchema: z.discriminatedUnion(\"success\", [\n z.object({\n success: z.literal(true),\n component: z\n .object({\n id: z.string(),\n componentName: z.string(),\n props: z.record(z.string(), z.any()),\n })\n .optional(),\n }),\n z.object({\n success: z.literal(false),\n error: z.string(),\n }),\n ]),\n });\n\n registerTool({\n name: \"remove_interactable_component\",\n description: \"Remove an interactable component from the system\",\n tool: ({ componentId }) => {\n const component = interactableComponents.find(\n (c) => c.id === componentId,\n );\n\n if (!component) {\n return {\n success: false,\n error: `Component with ID ${componentId} not found`,\n } as const;\n }\n\n setInteractableComponents((prev) =>\n prev.filter((c) => c.id !== componentId),\n );\n\n return {\n success: true,\n componentId,\n removedComponent: {\n id: component.id,\n componentName: component.name,\n props: component.props,\n },\n } as const;\n },\n inputSchema: z.object({\n componentId: z.string().describe(\"The ID of the component\"),\n }),\n outputSchema: z.discriminatedUnion(\"success\", [\n z.object({\n success: z.literal(true),\n componentId: z.string(),\n removedComponent: z.object({\n id: z.string(),\n componentName: z.string(),\n props: z.record(z.string(), z.any()),\n }),\n }),\n z.object({\n success: z.literal(false),\n error: z.string(),\n }),\n ]),\n });\n }\n }, [interactableComponents, registerTool]);\n\n const updateInteractableComponentProps = useCallback(\n (id: string, newProps: Record<string, any>): string => {\n if (!newProps || Object.keys(newProps).length === 0) {\n return `Warning: No props provided for component with ID ${id}.`;\n }\n\n setInteractableComponents((prev) => {\n const component = prev.find((c) => c.id === id);\n if (!component) {\n return prev;\n }\n\n // Compare props shallowly\n const propsChanged = Object.entries(newProps).some(([key, value]) => {\n return component.props[key] !== value;\n });\n\n if (!propsChanged) {\n return prev; // unchanged\n }\n\n // Apply partial update\n const updated = {\n ...component,\n props: { ...component.props, ...newProps },\n };\n\n const updatedComponents = [...prev];\n const idx = prev.findIndex((c) => c.id === id);\n updatedComponents[idx] = updated;\n\n return updatedComponents;\n });\n\n return \"Updated successfully\";\n },\n [],\n );\n\n const updateInteractableComponentState = useCallback(\n (componentId: string, newState: Record<string, unknown>): string => {\n if (!newState || Object.keys(newState).length === 0) {\n return `Warning: No state values provided for component with ID ${componentId}.`;\n }\n\n setInteractableComponents((components = []) => {\n const component = components.find((c) => c.id === componentId);\n if (!component) return components;\n\n const prevState = component.state ?? {};\n const updatedState = { ...prevState, ...newState };\n if (deepEqual(prevState, updatedState)) return components;\n\n // TODO(lachieh): validate state against schema?\n\n const updated = {\n ...component,\n state: updatedState,\n };\n\n return components.map((c) => (c.id === componentId ? updated : c));\n });\n\n return \"Updated successfully\";\n },\n [],\n );\n\n const registerInteractableComponentPropsUpdateTool = useCallback(\n (component: TamboInteractableComponent, maxNameLength = 60) => {\n const tamboToolNamePart = `update_component_props_`;\n const availableLength = maxNameLength - tamboToolNamePart.length;\n if (component.id.length > availableLength) {\n throw new Error(\n `Interactable component id ${component.id} is too long. It must be less than ${availableLength} characters.`,\n );\n }\n\n // Build newProps schema as JSON Schema\n let newPropsSchema: JSONSchema7;\n if (component.propsSchema) {\n // Convert any supported schema to JSON Schema, then make partial\n const fullSchema = schemaToJsonSchema(component.propsSchema);\n newPropsSchema = makeJsonSchemaPartial(fullSchema);\n } else {\n // No schema - allow any properties\n newPropsSchema = { type: \"object\", additionalProperties: true };\n }\n\n // Build the full input schema as JSON Schema\n const inputSchema: JSONSchema7 = {\n type: \"object\",\n properties: {\n componentId: {\n type: \"string\",\n description: \"The ID of the interactable component to update\",\n },\n newProps: {\n ...newPropsSchema,\n description:\n \"The props to update. Provide only the props you want to change.\",\n },\n },\n required: [\"componentId\", \"newProps\"],\n };\n\n registerTool({\n name: `${tamboToolNamePart}${component.id}`,\n description: `Update the props of interactable component ${component.id} (${component.name}). Provide partial props (only props to change).`,\n tool: ({ componentId, newProps }) => {\n return updateInteractableComponentProps(componentId, newProps);\n },\n inputSchema,\n outputSchema: z.string(),\n });\n },\n [registerTool, updateInteractableComponentProps],\n );\n\n const registerInteractableComponentStateUpdateTool = useCallback(\n (component: TamboInteractableComponent, maxNameLength = 60) => {\n const tamboToolNamePart = `update_component_state_`;\n const availableLength = maxNameLength - tamboToolNamePart.length;\n if (component.id.length > availableLength) {\n throw new Error(\n `Interactable component id ${component.id} is too long. It must be less than ${availableLength} characters.`,\n );\n }\n\n // Build newState schema as JSON Schema\n let newStateSchema: JSONSchema7 = {\n type: \"object\",\n additionalProperties: true,\n };\n if (component.stateSchema) {\n // Convert any supported schema to JSON Schema, then make partial\n const fullSchema = schemaToJsonSchema(component.stateSchema);\n newStateSchema = makeJsonSchemaPartial(fullSchema);\n }\n\n // Build the full input schema as JSON Schema\n const inputSchema: JSONSchema7 = {\n type: \"object\",\n properties: {\n componentId: {\n type: \"string\",\n description: \"The ID of the interactable component to update\",\n },\n newState: {\n ...newStateSchema,\n description:\n \"The state values to update. Provide only the keys you want to change.\",\n },\n },\n required: [\"componentId\", \"newState\"],\n };\n\n registerTool({\n name: `${tamboToolNamePart}${component.id}`,\n description: `Update the state of interactable component ${component.id} (${component.name}). You may provide partial state (only keys to change).`,\n tool: ({ componentId, newState }) => {\n return updateInteractableComponentState(componentId, newState);\n },\n inputSchema,\n outputSchema: z.string(),\n });\n },\n [registerTool, updateInteractableComponentState],\n );\n\n const addInteractableComponent = useCallback(\n (\n component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\">,\n ): string => {\n // Validate component name\n assertValidName(component.name, \"component\");\n\n // Add a random part to the component name to make it unique when using multiple instances of the same component.\n const tamboGeneratedNamePart = `-${Math.random().toString(36).slice(2, 5)}`;\n const id = `${component.name}${tamboGeneratedNamePart}`;\n const newComponent: TamboInteractableComponent = {\n ...component,\n id,\n state: component.state ?? {},\n };\n\n registerInteractableComponentPropsUpdateTool(newComponent);\n registerInteractableComponentStateUpdateTool(newComponent);\n\n setInteractableComponents((prev) => {\n return [...prev, newComponent];\n });\n\n return id;\n },\n [\n registerInteractableComponentPropsUpdateTool,\n registerInteractableComponentStateUpdateTool,\n ],\n );\n\n const removeInteractableComponent = useCallback((id: string) => {\n setInteractableComponents((prev) => prev.filter((c) => c.id !== id));\n }, []);\n\n const getInteractableComponent = useCallback(\n <P, S>(id: string): TamboInteractableComponent<P, S> | undefined => {\n return interactableComponents.find((c) => c.id === id) as\n | TamboInteractableComponent<P, S>\n | undefined;\n },\n [interactableComponents],\n );\n\n const getInteractableComponentsByName = useCallback(\n (componentName: string) => {\n return interactableComponents.filter((c) => c.name === componentName);\n },\n [interactableComponents],\n );\n\n const clearAllInteractableComponents = useCallback(() => {\n setInteractableComponents([]);\n }, []);\n\n const setInteractableStateValue = useCallback(\n (componentId: string, key: string, value: unknown) => {\n setInteractableComponents((prev) => {\n const component = prev.find((c) => c.id === componentId);\n if (!component) {\n console.warn(\n `Tried to update state for component ${componentId} but it was not found.`,\n );\n return prev;\n }\n\n const updated = {\n ...component,\n state: {\n ...component.state,\n [key]: value,\n },\n };\n\n const updatedComponents = prev.map((component) => {\n if (component.id === componentId) {\n return updated;\n }\n return component;\n });\n\n return updatedComponents;\n });\n },\n [],\n );\n\n const getInteractableComponentState = useCallback(\n (componentId: string) => {\n const component = interactableComponents.find(\n (c) => c.id === componentId,\n );\n return component?.state;\n },\n [interactableComponents],\n );\n\n const setInteractableSelected = useCallback(\n (componentId: string, isSelected: boolean) => {\n setInteractableComponents((prev) => {\n let found = false;\n const next = prev.map((component) => {\n if (component.id !== componentId) return component;\n found = true;\n return component.isSelected === isSelected\n ? component\n : { ...component, isSelected: isSelected };\n });\n return found ? next : prev;\n });\n },\n [],\n );\n\n const clearInteractableSelections = useCallback(() => {\n setInteractableComponents((prev) => {\n if (!prev.some((c) => c.isSelected)) return prev;\n return prev.map((c) => (c.isSelected ? { ...c, isSelected: false } : c));\n });\n }, []);\n\n const value: TamboInteractableContext = {\n interactableComponents,\n addInteractableComponent,\n removeInteractableComponent,\n updateInteractableComponentProps,\n getInteractableComponent,\n getInteractableComponentsByName,\n clearAllInteractableComponents,\n setInteractableState: setInteractableStateValue,\n getInteractableComponentState,\n setInteractableSelected,\n clearInteractableSelections,\n };\n\n return (\n <TamboInteractableContext.Provider value={value}>\n {children}\n </TamboInteractableContext.Provider>\n );\n};\n\n/**\n * The useTamboInteractable hook provides access to the interactable component\n * management functions.\n * @returns The interactable component management functions\n */\nexport const useTamboInteractable = () => {\n return useContext(TamboInteractableContext);\n};\n\n/**\n * Hook to get a cloned snapshot of the current interactables.\n * Returns a shallow copy of the array with cloned items and props to prevent\n * external mutation from affecting internal state.\n * @returns The current interactables snapshot (cloned).\n */\nexport const useCurrentInteractablesSnapshot = () => {\n const { interactableComponents } = useTamboInteractable();\n // Clone the array and each item/props to prevent mutation\n const copy = interactableComponents.map((c) => ({\n ...c,\n props: { ...c.props },\n }));\n\n return copy;\n};\n"]}
@@ -54,4 +54,246 @@ describe("TamboInteractableProvider - State Tracking", () => {
54
54
  expect(state).toEqual({ count: 10 });
55
55
  });
56
56
  });
57
+ describe("TamboInteractableProvider - State Update Tool Registration", () => {
58
+ beforeEach(() => {
59
+ jest.clearAllMocks();
60
+ });
61
+ const wrapper = ({ children }) => (React.createElement(TamboInteractableProvider, null, children));
62
+ it("should register both prop and state update tools when component is added", () => {
63
+ const { result } = renderHook(() => useTamboInteractable(), { wrapper });
64
+ const component = {
65
+ name: "TestComponent",
66
+ description: "A test component",
67
+ component: () => React.createElement("div", null, "Test"),
68
+ props: { title: "Test" },
69
+ propsSchema: z.object({ title: z.string() }),
70
+ };
71
+ let componentId = "";
72
+ act(() => {
73
+ componentId = result.current.addInteractableComponent(component);
74
+ });
75
+ // Should register both update_component_ and update_component_state_ tools
76
+ const registeredToolNames = mockRegisterTool.mock.calls.map((call) => call[0].name);
77
+ expect(registeredToolNames).toContain(`update_component_props_${componentId}`);
78
+ expect(registeredToolNames).toContain(`update_component_state_${componentId}`);
79
+ });
80
+ it("should register state update tool with correct description", () => {
81
+ const { result } = renderHook(() => useTamboInteractable(), { wrapper });
82
+ const component = {
83
+ name: "MyComponent",
84
+ description: "A test component",
85
+ component: () => React.createElement("div", null, "Test"),
86
+ props: {},
87
+ };
88
+ let componentId = "";
89
+ act(() => {
90
+ componentId = result.current.addInteractableComponent(component);
91
+ });
92
+ const stateToolCall = mockRegisterTool.mock.calls.find((call) => call[0].name.startsWith("update_component_state_"));
93
+ expect(stateToolCall).toBeDefined();
94
+ expect(stateToolCall[0].description).toContain(componentId);
95
+ expect(stateToolCall[0].description).toContain("MyComponent");
96
+ });
97
+ it("should allow state update tool to update multiple state values", () => {
98
+ const { result } = renderHook(() => useTamboInteractable(), { wrapper });
99
+ const component = {
100
+ name: "TestComponent",
101
+ description: "A test component",
102
+ component: () => React.createElement("div", null, "Test"),
103
+ props: {},
104
+ };
105
+ let componentId = "";
106
+ act(() => {
107
+ componentId = result.current.addInteractableComponent(component);
108
+ });
109
+ // Find the state update tool and call it
110
+ const stateToolCall = mockRegisterTool.mock.calls.find((call) => call[0].name.startsWith("update_component_state_"));
111
+ const toolFn = stateToolCall[0].tool;
112
+ act(() => {
113
+ toolFn({ componentId, newState: { count: 5, name: "test" } });
114
+ });
115
+ const state = result.current.getInteractableComponentState(componentId);
116
+ expect(state).toEqual({ count: 5, name: "test" });
117
+ });
118
+ it("should preserve existing state when updating partial state", () => {
119
+ const { result } = renderHook(() => useTamboInteractable(), { wrapper });
120
+ const component = {
121
+ name: "TestComponent",
122
+ description: "A test component",
123
+ component: () => React.createElement("div", null, "Test"),
124
+ props: {},
125
+ };
126
+ let componentId = "";
127
+ act(() => {
128
+ componentId = result.current.addInteractableComponent(component);
129
+ });
130
+ // Set initial state
131
+ act(() => {
132
+ result.current.setInteractableState(componentId, "existingKey", "value1");
133
+ });
134
+ // Find the state update tool and call it with a new key
135
+ const stateToolCall = mockRegisterTool.mock.calls.find((call) => call[0].name.startsWith("update_component_state_"));
136
+ const toolFn = stateToolCall[0].tool;
137
+ act(() => {
138
+ toolFn({ componentId, newState: { newKey: "value2" } });
139
+ });
140
+ const state = result.current.getInteractableComponentState(componentId);
141
+ expect(state).toEqual({ existingKey: "value1", newKey: "value2" });
142
+ });
143
+ it("should use stateSchema when provided for tool registration", () => {
144
+ const { result } = renderHook(() => useTamboInteractable(), { wrapper });
145
+ const stateSchema = z.object({
146
+ count: z.number(),
147
+ name: z.string(),
148
+ });
149
+ const component = {
150
+ name: "TestComponent",
151
+ description: "A test component",
152
+ component: () => React.createElement("div", null, "Test"),
153
+ props: {},
154
+ stateSchema,
155
+ };
156
+ act(() => {
157
+ result.current.addInteractableComponent(component);
158
+ });
159
+ // Find the state update tool
160
+ const stateToolCall = mockRegisterTool.mock.calls.find((call) => call[0].name.startsWith("update_component_state_"));
161
+ expect(stateToolCall).toBeDefined();
162
+ // The inputSchema should contain the partial stateSchema
163
+ expect(stateToolCall[0].inputSchema).toBeDefined();
164
+ });
165
+ it("should return warning when updating state with empty object", () => {
166
+ const { result } = renderHook(() => useTamboInteractable(), { wrapper });
167
+ const component = {
168
+ name: "TestComponent",
169
+ description: "A test component",
170
+ component: () => React.createElement("div", null, "Test"),
171
+ props: {},
172
+ };
173
+ let componentId = "";
174
+ act(() => {
175
+ componentId = result.current.addInteractableComponent(component);
176
+ });
177
+ // Find the state update tool and call it with empty state
178
+ const stateToolCall = mockRegisterTool.mock.calls.find((call) => call[0].name.startsWith("update_component_state_"));
179
+ const toolFn = stateToolCall[0].tool;
180
+ let updateResult = "";
181
+ act(() => {
182
+ updateResult = toolFn({ componentId, newState: {} });
183
+ });
184
+ expect(updateResult).toContain("Warning");
185
+ expect(updateResult).toContain("No state values provided");
186
+ });
187
+ it("should preserve stateSchema in interactable component", () => {
188
+ const { result } = renderHook(() => useTamboInteractable(), { wrapper });
189
+ const stateSchema = z.object({
190
+ count: z.number(),
191
+ });
192
+ const component = {
193
+ name: "TestComponent",
194
+ description: "A test component",
195
+ component: () => React.createElement("div", null, "Test"),
196
+ props: {},
197
+ stateSchema,
198
+ };
199
+ let componentId = "";
200
+ act(() => {
201
+ componentId = result.current.addInteractableComponent(component);
202
+ });
203
+ const interactable = result.current.getInteractableComponent(componentId);
204
+ expect(interactable?.stateSchema).toBe(stateSchema);
205
+ });
206
+ it("should convert stateSchema to partial JSON Schema (no required fields)", () => {
207
+ const { result } = renderHook(() => useTamboInteractable(), { wrapper });
208
+ const stateSchema = z.object({
209
+ count: z.number(),
210
+ name: z.string(),
211
+ });
212
+ const component = {
213
+ name: "TestComponent",
214
+ description: "A test component",
215
+ component: () => React.createElement("div", null, "Test"),
216
+ props: {},
217
+ stateSchema,
218
+ };
219
+ act(() => {
220
+ result.current.addInteractableComponent(component);
221
+ });
222
+ // Find the state update tool
223
+ const stateToolCall = mockRegisterTool.mock.calls.find((call) => call[0].name.startsWith("update_component_state_"));
224
+ expect(stateToolCall).toBeDefined();
225
+ const inputSchema = stateToolCall[0].inputSchema;
226
+ // The newState property should not have required fields (partial schema)
227
+ expect(inputSchema.properties.newState).toBeDefined();
228
+ expect(inputSchema.properties.newState.required).toBeUndefined();
229
+ // But it should have the properties from the schema
230
+ expect(inputSchema.properties.newState.properties).toBeDefined();
231
+ });
232
+ it("should use additionalProperties when no stateSchema provided", () => {
233
+ const { result } = renderHook(() => useTamboInteractable(), { wrapper });
234
+ const component = {
235
+ name: "TestComponent",
236
+ description: "A test component",
237
+ component: () => React.createElement("div", null, "Test"),
238
+ props: {},
239
+ // No stateSchema
240
+ };
241
+ act(() => {
242
+ result.current.addInteractableComponent(component);
243
+ });
244
+ // Find the state update tool
245
+ const stateToolCall = mockRegisterTool.mock.calls.find((call) => call[0].name.startsWith("update_component_state_"));
246
+ expect(stateToolCall).toBeDefined();
247
+ const inputSchema = stateToolCall[0].inputSchema;
248
+ // The newState property should allow additional properties
249
+ expect(inputSchema.properties.newState.additionalProperties).toBe(true);
250
+ });
251
+ it("should convert propsSchema to partial JSON Schema for props update tool", () => {
252
+ const { result } = renderHook(() => useTamboInteractable(), { wrapper });
253
+ const propsSchema = z.object({
254
+ title: z.string(),
255
+ count: z.number(),
256
+ });
257
+ const component = {
258
+ name: "TestComponent",
259
+ description: "A test component",
260
+ component: () => React.createElement("div", null, "Test"),
261
+ props: { title: "test", count: 0 },
262
+ propsSchema,
263
+ };
264
+ act(() => {
265
+ result.current.addInteractableComponent(component);
266
+ });
267
+ // Find the props update tool (not the state one)
268
+ const propsToolCall = mockRegisterTool.mock.calls.find((call) => call[0].name.startsWith("update_component_") &&
269
+ !call[0].name.includes("state"));
270
+ expect(propsToolCall).toBeDefined();
271
+ const inputSchema = propsToolCall[0].inputSchema;
272
+ // The newProps property should not have required fields (partial schema)
273
+ expect(inputSchema.properties.newProps).toBeDefined();
274
+ expect(inputSchema.properties.newProps.required).toBeUndefined();
275
+ // But it should have the properties from the schema
276
+ expect(inputSchema.properties.newProps.properties).toBeDefined();
277
+ });
278
+ it("should use additionalProperties when no propsSchema provided", () => {
279
+ const { result } = renderHook(() => useTamboInteractable(), { wrapper });
280
+ const component = {
281
+ name: "TestComponent",
282
+ description: "A test component",
283
+ component: () => React.createElement("div", null, "Test"),
284
+ props: { title: "test" },
285
+ // No propsSchema
286
+ };
287
+ act(() => {
288
+ result.current.addInteractableComponent(component);
289
+ });
290
+ // Find the props update tool
291
+ const propsToolCall = mockRegisterTool.mock.calls.find((call) => call[0].name.startsWith("update_component_") &&
292
+ !call[0].name.includes("state"));
293
+ expect(propsToolCall).toBeDefined();
294
+ const inputSchema = propsToolCall[0].inputSchema;
295
+ // The newProps property should allow additional properties
296
+ expect(inputSchema.properties.newProps.additionalProperties).toBe(true);
297
+ });
298
+ });
57
299
  //# sourceMappingURL=tambo-interactable-provider.test.js.map