@tambo-ai/react 1.1.0 → 1.2.1

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 (491) hide show
  1. package/dist/context-helpers/current-interactables-context-helper.d.ts +16 -2
  2. package/dist/context-helpers/current-interactables-context-helper.d.ts.map +1 -1
  3. package/dist/context-helpers/current-interactables-context-helper.js.map +1 -1
  4. package/dist/context-helpers/current-interactables-context-helper.test.d.ts +2 -0
  5. package/dist/context-helpers/current-interactables-context-helper.test.d.ts.map +1 -0
  6. package/dist/context-helpers/current-interactables-context-helper.test.js +70 -0
  7. package/dist/context-helpers/current-interactables-context-helper.test.js.map +1 -0
  8. package/dist/hoc/with-tambo-interactable.d.ts.map +1 -1
  9. package/dist/hoc/with-tambo-interactable.js +11 -2
  10. package/dist/hoc/with-tambo-interactable.js.map +1 -1
  11. package/dist/hoc/with-tambo-interactable.test.js +14 -0
  12. package/dist/hoc/with-tambo-interactable.test.js.map +1 -1
  13. package/dist/mcp/elicitation.d.ts +3 -37
  14. package/dist/mcp/elicitation.d.ts.map +1 -1
  15. package/dist/mcp/elicitation.js +7 -24
  16. package/dist/mcp/elicitation.js.map +1 -1
  17. package/dist/mcp/index.d.ts +4 -4
  18. package/dist/mcp/index.d.ts.map +1 -1
  19. package/dist/mcp/index.js +2 -2
  20. package/dist/mcp/index.js.map +1 -1
  21. package/dist/mcp/mcp-client.test.js +17 -17
  22. package/dist/mcp/mcp-client.test.js.map +1 -1
  23. package/dist/mcp/mcp-hooks.d.ts.map +1 -1
  24. package/dist/mcp/mcp-hooks.js +8 -5
  25. package/dist/mcp/mcp-hooks.js.map +1 -1
  26. package/dist/mcp/mcp-hooks.test.js +30 -29
  27. package/dist/mcp/mcp-hooks.test.js.map +1 -1
  28. package/dist/mcp/tambo-mcp-provider.d.ts +6 -9
  29. package/dist/mcp/tambo-mcp-provider.d.ts.map +1 -1
  30. package/dist/mcp/tambo-mcp-provider.js +9 -13
  31. package/dist/mcp/tambo-mcp-provider.js.map +1 -1
  32. package/dist/mcp/tambo-mcp-provider.test.js +26 -25
  33. package/dist/mcp/tambo-mcp-provider.test.js.map +1 -1
  34. package/dist/mcp/use-mcp-servers.test.js +2 -1
  35. package/dist/mcp/use-mcp-servers.test.js.map +1 -1
  36. package/dist/model/component-metadata.d.ts +7 -372
  37. package/dist/model/component-metadata.d.ts.map +1 -1
  38. package/dist/model/component-metadata.js.map +1 -1
  39. package/dist/model/validate-input.test.d.ts +2 -0
  40. package/dist/model/validate-input.test.d.ts.map +1 -0
  41. package/dist/model/validate-input.test.js +38 -0
  42. package/dist/model/validate-input.test.js.map +1 -0
  43. package/dist/providers/tambo-interactable-provider-partial-updates.test.js +2 -0
  44. package/dist/providers/tambo-interactable-provider-partial-updates.test.js.map +1 -1
  45. package/dist/providers/tambo-interactable-provider.d.ts +7 -7
  46. package/dist/providers/tambo-interactable-provider.d.ts.map +1 -1
  47. package/dist/providers/tambo-interactable-provider.js +26 -4
  48. package/dist/providers/tambo-interactable-provider.js.map +1 -1
  49. package/dist/providers/tambo-interactable-provider.test.js +78 -0
  50. package/dist/providers/tambo-interactable-provider.test.js.map +1 -1
  51. package/dist/providers/tambo-registry-provider.d.ts +2 -1
  52. package/dist/providers/tambo-registry-provider.d.ts.map +1 -1
  53. package/dist/providers/tambo-registry-provider.js +19 -0
  54. package/dist/providers/tambo-registry-provider.js.map +1 -1
  55. package/dist/providers/tambo-registry-provider.test.js +36 -0
  56. package/dist/providers/tambo-registry-provider.test.js.map +1 -1
  57. package/dist/providers/tambo-registry-schema-compat.test.js +4 -4
  58. package/dist/providers/tambo-registry-schema-compat.test.js.map +1 -1
  59. package/dist/schema/index.d.ts +2 -4
  60. package/dist/schema/index.d.ts.map +1 -1
  61. package/dist/schema/index.js +9 -11
  62. package/dist/schema/index.js.map +1 -1
  63. package/dist/schema/json-schema.d.ts +1 -17
  64. package/dist/schema/json-schema.d.ts.map +1 -1
  65. package/dist/schema/json-schema.js +5 -69
  66. package/dist/schema/json-schema.js.map +1 -1
  67. package/dist/schema/schema.test.js +24 -25
  68. package/dist/schema/schema.test.js.map +1 -1
  69. package/dist/schema/standard-schema.test.js +25 -25
  70. package/dist/schema/standard-schema.test.js.map +1 -1
  71. package/dist/schema/validate.test.js +33 -33
  72. package/dist/schema/validate.test.js.map +1 -1
  73. package/dist/testing/tools.d.ts +4 -4
  74. package/dist/testing/tools.test.d.ts +2 -0
  75. package/dist/testing/tools.test.d.ts.map +1 -0
  76. package/dist/testing/tools.test.js +60 -0
  77. package/dist/testing/tools.test.js.map +1 -0
  78. package/dist/util/mcp-server-utils.d.ts +1 -1
  79. package/dist/util/mcp-server-utils.d.ts.map +1 -1
  80. package/dist/util/mcp-server-utils.js +4 -4
  81. package/dist/util/mcp-server-utils.js.map +1 -1
  82. package/dist/util/mcp-server-utils.test.js +27 -27
  83. package/dist/util/mcp-server-utils.test.js.map +1 -1
  84. package/dist/util/registry.js +1 -1
  85. package/dist/util/registry.js.map +1 -1
  86. package/dist/util/resource-content-resolver.js +5 -5
  87. package/dist/util/resource-content-resolver.js.map +1 -1
  88. package/dist/util/resource-content-resolver.test.js +6 -6
  89. package/dist/util/resource-content-resolver.test.js.map +1 -1
  90. package/dist/util/tool-caller.test.d.ts +2 -0
  91. package/dist/util/tool-caller.test.d.ts.map +1 -0
  92. package/dist/util/tool-caller.test.js +71 -0
  93. package/dist/util/tool-caller.test.js.map +1 -0
  94. package/dist/v1/__tests__/v1-interactables.test.js +6 -0
  95. package/dist/v1/__tests__/v1-interactables.test.js.map +1 -1
  96. package/dist/v1/components/v1-component-renderer.test.js +1 -0
  97. package/dist/v1/components/v1-component-renderer.test.js.map +1 -1
  98. package/dist/v1/hooks/use-tambo-v1-auth-state.d.ts +1 -1
  99. package/dist/v1/hooks/use-tambo-v1-auth-state.d.ts.map +1 -1
  100. package/dist/v1/hooks/use-tambo-v1-auth-state.js.map +1 -1
  101. package/dist/v1/hooks/use-tambo-v1-component-state.js +2 -2
  102. package/dist/v1/hooks/use-tambo-v1-component-state.js.map +1 -1
  103. package/dist/v1/hooks/use-tambo-v1-component-state.test.js +1 -1
  104. package/dist/v1/hooks/use-tambo-v1-component-state.test.js.map +1 -1
  105. package/dist/v1/hooks/use-tambo-v1-send-message.d.ts +1 -1
  106. package/dist/v1/hooks/use-tambo-v1-send-message.d.ts.map +1 -1
  107. package/dist/v1/hooks/use-tambo-v1-send-message.js +17 -17
  108. package/dist/v1/hooks/use-tambo-v1-send-message.js.map +1 -1
  109. package/dist/v1/hooks/use-tambo-v1-send-message.test.js +1 -1
  110. package/dist/v1/hooks/use-tambo-v1-send-message.test.js.map +1 -1
  111. package/dist/v1/hooks/use-tambo-v1-stream-status.js +2 -2
  112. package/dist/v1/hooks/use-tambo-v1-stream-status.js.map +1 -1
  113. package/dist/v1/hooks/use-tambo-v1-stream-status.test.js +9 -5
  114. package/dist/v1/hooks/use-tambo-v1-stream-status.test.js.map +1 -1
  115. package/dist/v1/hooks/use-tambo-v1-suggestions.js +2 -2
  116. package/dist/v1/hooks/use-tambo-v1-suggestions.js.map +1 -1
  117. package/dist/v1/hooks/use-tambo-v1-thread-input.test.js +1 -0
  118. package/dist/v1/hooks/use-tambo-v1-thread-input.test.js.map +1 -1
  119. package/dist/v1/hooks/use-tambo-v1.d.ts +7 -6
  120. package/dist/v1/hooks/use-tambo-v1.d.ts.map +1 -1
  121. package/dist/v1/hooks/use-tambo-v1.js +2 -2
  122. package/dist/v1/hooks/use-tambo-v1.js.map +1 -1
  123. package/dist/v1/hooks/use-tambo-v1.test.js +24 -23
  124. package/dist/v1/hooks/use-tambo-v1.test.js.map +1 -1
  125. package/dist/v1/index.d.ts +6 -6
  126. package/dist/v1/index.d.ts.map +1 -1
  127. package/dist/v1/index.js +2 -2
  128. package/dist/v1/index.js.map +1 -1
  129. package/dist/v1/providers/tambo-v1-provider.d.ts +2 -1
  130. package/dist/v1/providers/tambo-v1-provider.d.ts.map +1 -1
  131. package/dist/v1/providers/tambo-v1-provider.js +2 -0
  132. package/dist/v1/providers/tambo-v1-provider.js.map +1 -1
  133. package/dist/v1/providers/tambo-v1-stream-context.d.ts +2 -2
  134. package/dist/v1/providers/tambo-v1-stream-context.d.ts.map +1 -1
  135. package/dist/v1/providers/tambo-v1-stream-context.js +9 -9
  136. package/dist/v1/providers/tambo-v1-stream-context.js.map +1 -1
  137. package/dist/v1/providers/tambo-v1-stream-context.test.js +35 -0
  138. package/dist/v1/providers/tambo-v1-stream-context.test.js.map +1 -1
  139. package/dist/v1/providers/tambo-v1-stub-provider.d.ts +1 -1
  140. package/dist/v1/providers/tambo-v1-stub-provider.d.ts.map +1 -1
  141. package/dist/v1/providers/tambo-v1-stub-provider.js +2 -1
  142. package/dist/v1/providers/tambo-v1-stub-provider.js.map +1 -1
  143. package/dist/v1/providers/tambo-v1-stub-provider.test.js.map +1 -1
  144. package/dist/v1/providers/tambo-v1-thread-input-provider.d.ts +1 -1
  145. package/dist/v1/providers/tambo-v1-thread-input-provider.d.ts.map +1 -1
  146. package/dist/v1/providers/tambo-v1-thread-input-provider.js +2 -2
  147. package/dist/v1/providers/tambo-v1-thread-input-provider.js.map +1 -1
  148. package/dist/v1/types/event.test.js +13 -13
  149. package/dist/v1/types/event.test.js.map +1 -1
  150. package/dist/v1/types/message.d.ts +12 -109
  151. package/dist/v1/types/message.d.ts.map +1 -1
  152. package/dist/v1/types/message.js +0 -7
  153. package/dist/v1/types/message.js.map +1 -1
  154. package/dist/v1/utils/event-accumulator.test.js +183 -184
  155. package/dist/v1/utils/event-accumulator.test.js.map +1 -1
  156. package/dist/v1/utils/json-patch.test.js +4 -4
  157. package/dist/v1/utils/json-patch.test.js.map +1 -1
  158. package/dist/v1/utils/keyed-throttle.test.js +12 -12
  159. package/dist/v1/utils/keyed-throttle.test.js.map +1 -1
  160. package/dist/v1/utils/registry-conversion.test.js +13 -13
  161. package/dist/v1/utils/registry-conversion.test.js.map +1 -1
  162. package/dist/v1/utils/stream-handler.test.js +5 -5
  163. package/dist/v1/utils/stream-handler.test.js.map +1 -1
  164. package/dist/v1/utils/tool-call-tracker.test.js +15 -9
  165. package/dist/v1/utils/tool-call-tracker.test.js.map +1 -1
  166. package/dist/v1/utils/tool-executor.test.js +25 -26
  167. package/dist/v1/utils/tool-executor.test.js.map +1 -1
  168. package/dist/v1/utils/unstrictify.test.js +16 -16
  169. package/dist/v1/utils/unstrictify.test.js.map +1 -1
  170. package/esm/context-helpers/current-interactables-context-helper.d.ts +16 -2
  171. package/esm/context-helpers/current-interactables-context-helper.d.ts.map +1 -1
  172. package/esm/context-helpers/current-interactables-context-helper.js.map +1 -1
  173. package/esm/context-helpers/current-interactables-context-helper.test.d.ts +2 -0
  174. package/esm/context-helpers/current-interactables-context-helper.test.d.ts.map +1 -0
  175. package/esm/context-helpers/current-interactables-context-helper.test.js +68 -0
  176. package/esm/context-helpers/current-interactables-context-helper.test.js.map +1 -0
  177. package/esm/hoc/with-tambo-interactable.d.ts.map +1 -1
  178. package/esm/hoc/with-tambo-interactable.js +11 -2
  179. package/esm/hoc/with-tambo-interactable.js.map +1 -1
  180. package/esm/hoc/with-tambo-interactable.test.js +14 -0
  181. package/esm/hoc/with-tambo-interactable.test.js.map +1 -1
  182. package/esm/mcp/elicitation.d.ts +3 -37
  183. package/esm/mcp/elicitation.d.ts.map +1 -1
  184. package/esm/mcp/elicitation.js +4 -24
  185. package/esm/mcp/elicitation.js.map +1 -1
  186. package/esm/mcp/index.d.ts +4 -4
  187. package/esm/mcp/index.d.ts.map +1 -1
  188. package/esm/mcp/index.js +1 -1
  189. package/esm/mcp/index.js.map +1 -1
  190. package/esm/mcp/mcp-client.test.js +1 -1
  191. package/esm/mcp/mcp-client.test.js.map +1 -1
  192. package/esm/mcp/mcp-hooks.d.ts.map +1 -1
  193. package/esm/mcp/mcp-hooks.js +4 -1
  194. package/esm/mcp/mcp-hooks.js.map +1 -1
  195. package/esm/mcp/mcp-hooks.test.js +3 -2
  196. package/esm/mcp/mcp-hooks.test.js.map +1 -1
  197. package/esm/mcp/tambo-mcp-provider.d.ts +6 -9
  198. package/esm/mcp/tambo-mcp-provider.d.ts.map +1 -1
  199. package/esm/mcp/tambo-mcp-provider.js +4 -8
  200. package/esm/mcp/tambo-mcp-provider.js.map +1 -1
  201. package/esm/mcp/tambo-mcp-provider.test.js +3 -2
  202. package/esm/mcp/tambo-mcp-provider.test.js.map +1 -1
  203. package/esm/mcp/use-mcp-servers.test.js +2 -1
  204. package/esm/mcp/use-mcp-servers.test.js.map +1 -1
  205. package/esm/model/component-metadata.d.ts +7 -372
  206. package/esm/model/component-metadata.d.ts.map +1 -1
  207. package/esm/model/component-metadata.js.map +1 -1
  208. package/esm/model/validate-input.test.d.ts +2 -0
  209. package/esm/model/validate-input.test.d.ts.map +1 -0
  210. package/esm/model/validate-input.test.js +36 -0
  211. package/esm/model/validate-input.test.js.map +1 -0
  212. package/esm/providers/tambo-interactable-provider-partial-updates.test.js +2 -0
  213. package/esm/providers/tambo-interactable-provider-partial-updates.test.js.map +1 -1
  214. package/esm/providers/tambo-interactable-provider.d.ts +7 -7
  215. package/esm/providers/tambo-interactable-provider.d.ts.map +1 -1
  216. package/esm/providers/tambo-interactable-provider.js +26 -4
  217. package/esm/providers/tambo-interactable-provider.js.map +1 -1
  218. package/esm/providers/tambo-interactable-provider.test.js +78 -0
  219. package/esm/providers/tambo-interactable-provider.test.js.map +1 -1
  220. package/esm/providers/tambo-registry-provider.d.ts +2 -1
  221. package/esm/providers/tambo-registry-provider.d.ts.map +1 -1
  222. package/esm/providers/tambo-registry-provider.js +19 -0
  223. package/esm/providers/tambo-registry-provider.js.map +1 -1
  224. package/esm/providers/tambo-registry-provider.test.js +36 -0
  225. package/esm/providers/tambo-registry-provider.test.js.map +1 -1
  226. package/esm/providers/tambo-registry-schema-compat.test.js +4 -4
  227. package/esm/providers/tambo-registry-schema-compat.test.js.map +1 -1
  228. package/esm/schema/index.d.ts +2 -4
  229. package/esm/schema/index.d.ts.map +1 -1
  230. package/esm/schema/index.js +2 -4
  231. package/esm/schema/index.js.map +1 -1
  232. package/esm/schema/json-schema.d.ts +1 -17
  233. package/esm/schema/json-schema.d.ts.map +1 -1
  234. package/esm/schema/json-schema.js +2 -67
  235. package/esm/schema/json-schema.js.map +1 -1
  236. package/esm/schema/schema.test.js +1 -2
  237. package/esm/schema/schema.test.js.map +1 -1
  238. package/esm/schema/standard-schema.test.js +1 -1
  239. package/esm/schema/standard-schema.test.js.map +1 -1
  240. package/esm/schema/validate.test.js +1 -1
  241. package/esm/schema/validate.test.js.map +1 -1
  242. package/esm/testing/tools.d.ts +4 -4
  243. package/esm/testing/tools.test.d.ts +2 -0
  244. package/esm/testing/tools.test.d.ts.map +1 -0
  245. package/esm/testing/tools.test.js +58 -0
  246. package/esm/testing/tools.test.js.map +1 -0
  247. package/esm/util/mcp-server-utils.d.ts +1 -1
  248. package/esm/util/mcp-server-utils.d.ts.map +1 -1
  249. package/esm/util/mcp-server-utils.js +1 -1
  250. package/esm/util/mcp-server-utils.js.map +1 -1
  251. package/esm/util/mcp-server-utils.test.js +1 -1
  252. package/esm/util/mcp-server-utils.test.js.map +1 -1
  253. package/esm/util/registry.js +1 -1
  254. package/esm/util/registry.js.map +1 -1
  255. package/esm/util/resource-content-resolver.js +1 -1
  256. package/esm/util/resource-content-resolver.js.map +1 -1
  257. package/esm/util/resource-content-resolver.test.js +2 -2
  258. package/esm/util/resource-content-resolver.test.js.map +1 -1
  259. package/esm/util/tool-caller.test.d.ts +2 -0
  260. package/esm/util/tool-caller.test.d.ts.map +1 -0
  261. package/esm/util/tool-caller.test.js +69 -0
  262. package/esm/util/tool-caller.test.js.map +1 -0
  263. package/esm/v1/__tests__/v1-interactables.test.js +6 -0
  264. package/esm/v1/__tests__/v1-interactables.test.js.map +1 -1
  265. package/esm/v1/components/v1-component-renderer.test.js +1 -0
  266. package/esm/v1/components/v1-component-renderer.test.js.map +1 -1
  267. package/esm/v1/hooks/use-tambo-v1-auth-state.d.ts +1 -1
  268. package/esm/v1/hooks/use-tambo-v1-auth-state.d.ts.map +1 -1
  269. package/esm/v1/hooks/use-tambo-v1-auth-state.js.map +1 -1
  270. package/esm/v1/hooks/use-tambo-v1-component-state.js +1 -1
  271. package/esm/v1/hooks/use-tambo-v1-component-state.js.map +1 -1
  272. package/esm/v1/hooks/use-tambo-v1-component-state.test.js +1 -1
  273. package/esm/v1/hooks/use-tambo-v1-component-state.test.js.map +1 -1
  274. package/esm/v1/hooks/use-tambo-v1-send-message.d.ts +1 -1
  275. package/esm/v1/hooks/use-tambo-v1-send-message.d.ts.map +1 -1
  276. package/esm/v1/hooks/use-tambo-v1-send-message.js +6 -6
  277. package/esm/v1/hooks/use-tambo-v1-send-message.js.map +1 -1
  278. package/esm/v1/hooks/use-tambo-v1-send-message.test.js +1 -1
  279. package/esm/v1/hooks/use-tambo-v1-send-message.test.js.map +1 -1
  280. package/esm/v1/hooks/use-tambo-v1-stream-status.js +1 -1
  281. package/esm/v1/hooks/use-tambo-v1-stream-status.js.map +1 -1
  282. package/esm/v1/hooks/use-tambo-v1-stream-status.test.js +9 -5
  283. package/esm/v1/hooks/use-tambo-v1-stream-status.test.js.map +1 -1
  284. package/esm/v1/hooks/use-tambo-v1-suggestions.js +1 -1
  285. package/esm/v1/hooks/use-tambo-v1-suggestions.js.map +1 -1
  286. package/esm/v1/hooks/use-tambo-v1-thread-input.test.js +1 -0
  287. package/esm/v1/hooks/use-tambo-v1-thread-input.test.js.map +1 -1
  288. package/esm/v1/hooks/use-tambo-v1.d.ts +7 -6
  289. package/esm/v1/hooks/use-tambo-v1.d.ts.map +1 -1
  290. package/esm/v1/hooks/use-tambo-v1.js +1 -1
  291. package/esm/v1/hooks/use-tambo-v1.js.map +1 -1
  292. package/esm/v1/hooks/use-tambo-v1.test.js +23 -22
  293. package/esm/v1/hooks/use-tambo-v1.test.js.map +1 -1
  294. package/esm/v1/index.d.ts +6 -6
  295. package/esm/v1/index.d.ts.map +1 -1
  296. package/esm/v1/index.js +1 -1
  297. package/esm/v1/index.js.map +1 -1
  298. package/esm/v1/providers/tambo-v1-provider.d.ts +2 -1
  299. package/esm/v1/providers/tambo-v1-provider.d.ts.map +1 -1
  300. package/esm/v1/providers/tambo-v1-provider.js +2 -0
  301. package/esm/v1/providers/tambo-v1-provider.js.map +1 -1
  302. package/esm/v1/providers/tambo-v1-stream-context.d.ts +2 -2
  303. package/esm/v1/providers/tambo-v1-stream-context.d.ts.map +1 -1
  304. package/esm/v1/providers/tambo-v1-stream-context.js +1 -1
  305. package/esm/v1/providers/tambo-v1-stream-context.js.map +1 -1
  306. package/esm/v1/providers/tambo-v1-stream-context.test.js +35 -0
  307. package/esm/v1/providers/tambo-v1-stream-context.test.js.map +1 -1
  308. package/esm/v1/providers/tambo-v1-stub-provider.d.ts +1 -1
  309. package/esm/v1/providers/tambo-v1-stub-provider.d.ts.map +1 -1
  310. package/esm/v1/providers/tambo-v1-stub-provider.js +2 -1
  311. package/esm/v1/providers/tambo-v1-stub-provider.js.map +1 -1
  312. package/esm/v1/providers/tambo-v1-stub-provider.test.js.map +1 -1
  313. package/esm/v1/providers/tambo-v1-thread-input-provider.d.ts +1 -1
  314. package/esm/v1/providers/tambo-v1-thread-input-provider.d.ts.map +1 -1
  315. package/esm/v1/providers/tambo-v1-thread-input-provider.js +1 -1
  316. package/esm/v1/providers/tambo-v1-thread-input-provider.js.map +1 -1
  317. package/esm/v1/types/event.test.js +1 -1
  318. package/esm/v1/types/event.test.js.map +1 -1
  319. package/esm/v1/types/message.d.ts +12 -109
  320. package/esm/v1/types/message.d.ts.map +1 -1
  321. package/esm/v1/types/message.js +0 -7
  322. package/esm/v1/types/message.js.map +1 -1
  323. package/esm/v1/utils/event-accumulator.test.js +2 -3
  324. package/esm/v1/utils/event-accumulator.test.js.map +1 -1
  325. package/esm/v1/utils/json-patch.test.js +1 -1
  326. package/esm/v1/utils/json-patch.test.js.map +1 -1
  327. package/esm/v1/utils/keyed-throttle.test.js +1 -1
  328. package/esm/v1/utils/keyed-throttle.test.js.map +1 -1
  329. package/esm/v1/utils/registry-conversion.test.js +1 -1
  330. package/esm/v1/utils/registry-conversion.test.js.map +1 -1
  331. package/esm/v1/utils/stream-handler.test.js +1 -1
  332. package/esm/v1/utils/stream-handler.test.js.map +1 -1
  333. package/esm/v1/utils/tool-call-tracker.test.js +9 -3
  334. package/esm/v1/utils/tool-call-tracker.test.js.map +1 -1
  335. package/esm/v1/utils/tool-executor.test.js +1 -2
  336. package/esm/v1/utils/tool-executor.test.js.map +1 -1
  337. package/esm/v1/utils/unstrictify.test.js +1 -1
  338. package/esm/v1/utils/unstrictify.test.js.map +1 -1
  339. package/package.json +10 -11
  340. package/dist/mcp/mcp-client.d.ts +0 -185
  341. package/dist/mcp/mcp-client.d.ts.map +0 -1
  342. package/dist/mcp/mcp-client.js +0 -219
  343. package/dist/mcp/mcp-client.js.map +0 -1
  344. package/dist/mcp/mcp-constants.d.ts +0 -19
  345. package/dist/mcp/mcp-constants.d.ts.map +0 -1
  346. package/dist/mcp/mcp-constants.js +0 -21
  347. package/dist/mcp/mcp-constants.js.map +0 -1
  348. package/dist/model/mcp-server-info.d.ts +0 -76
  349. package/dist/model/mcp-server-info.d.ts.map +0 -1
  350. package/dist/model/mcp-server-info.js +0 -29
  351. package/dist/model/mcp-server-info.js.map +0 -1
  352. package/dist/schema/schema.d.ts +0 -49
  353. package/dist/schema/schema.d.ts.map +0 -1
  354. package/dist/schema/schema.js +0 -129
  355. package/dist/schema/schema.js.map +0 -1
  356. package/dist/schema/standard-schema.d.ts +0 -22
  357. package/dist/schema/standard-schema.d.ts.map +0 -1
  358. package/dist/schema/standard-schema.js +0 -42
  359. package/dist/schema/standard-schema.js.map +0 -1
  360. package/dist/schema/validate.d.ts +0 -14
  361. package/dist/schema/validate.d.ts.map +0 -1
  362. package/dist/schema/validate.js +0 -148
  363. package/dist/schema/validate.js.map +0 -1
  364. package/dist/v1/types/auth.d.ts +0 -24
  365. package/dist/v1/types/auth.d.ts.map +0 -1
  366. package/dist/v1/types/auth.js +0 -3
  367. package/dist/v1/types/auth.js.map +0 -1
  368. package/dist/v1/types/event.d.ts +0 -89
  369. package/dist/v1/types/event.d.ts.map +0 -1
  370. package/dist/v1/types/event.js +0 -57
  371. package/dist/v1/types/event.js.map +0 -1
  372. package/dist/v1/types/thread.d.ts +0 -58
  373. package/dist/v1/types/thread.d.ts.map +0 -1
  374. package/dist/v1/types/thread.js +0 -9
  375. package/dist/v1/types/thread.js.map +0 -1
  376. package/dist/v1/types/tool-choice.d.ts +0 -8
  377. package/dist/v1/types/tool-choice.d.ts.map +0 -1
  378. package/dist/v1/types/tool-choice.js +0 -3
  379. package/dist/v1/types/tool-choice.js.map +0 -1
  380. package/dist/v1/utils/event-accumulator.d.ts +0 -165
  381. package/dist/v1/utils/event-accumulator.d.ts.map +0 -1
  382. package/dist/v1/utils/event-accumulator.js +0 -1277
  383. package/dist/v1/utils/event-accumulator.js.map +0 -1
  384. package/dist/v1/utils/json-patch.d.ts +0 -18
  385. package/dist/v1/utils/json-patch.d.ts.map +0 -1
  386. package/dist/v1/utils/json-patch.js +0 -35
  387. package/dist/v1/utils/json-patch.js.map +0 -1
  388. package/dist/v1/utils/keyed-throttle.d.ts +0 -42
  389. package/dist/v1/utils/keyed-throttle.d.ts.map +0 -1
  390. package/dist/v1/utils/keyed-throttle.js +0 -86
  391. package/dist/v1/utils/keyed-throttle.js.map +0 -1
  392. package/dist/v1/utils/registry-conversion.d.ts +0 -53
  393. package/dist/v1/utils/registry-conversion.d.ts.map +0 -1
  394. package/dist/v1/utils/registry-conversion.js +0 -115
  395. package/dist/v1/utils/registry-conversion.js.map +0 -1
  396. package/dist/v1/utils/stream-handler.d.ts +0 -45
  397. package/dist/v1/utils/stream-handler.d.ts.map +0 -1
  398. package/dist/v1/utils/stream-handler.js +0 -47
  399. package/dist/v1/utils/stream-handler.js.map +0 -1
  400. package/dist/v1/utils/thread-utils.d.ts +0 -16
  401. package/dist/v1/utils/thread-utils.d.ts.map +0 -1
  402. package/dist/v1/utils/thread-utils.js +0 -34
  403. package/dist/v1/utils/thread-utils.js.map +0 -1
  404. package/dist/v1/utils/tool-call-tracker.d.ts +0 -73
  405. package/dist/v1/utils/tool-call-tracker.d.ts.map +0 -1
  406. package/dist/v1/utils/tool-call-tracker.js +0 -180
  407. package/dist/v1/utils/tool-call-tracker.js.map +0 -1
  408. package/dist/v1/utils/tool-executor.d.ts +0 -67
  409. package/dist/v1/utils/tool-executor.d.ts.map +0 -1
  410. package/dist/v1/utils/tool-executor.js +0 -160
  411. package/dist/v1/utils/tool-executor.js.map +0 -1
  412. package/dist/v1/utils/unstrictify.d.ts +0 -32
  413. package/dist/v1/utils/unstrictify.d.ts.map +0 -1
  414. package/dist/v1/utils/unstrictify.js +0 -159
  415. package/dist/v1/utils/unstrictify.js.map +0 -1
  416. package/esm/mcp/mcp-client.d.ts +0 -185
  417. package/esm/mcp/mcp-client.d.ts.map +0 -1
  418. package/esm/mcp/mcp-client.js +0 -216
  419. package/esm/mcp/mcp-client.js.map +0 -1
  420. package/esm/mcp/mcp-constants.d.ts +0 -19
  421. package/esm/mcp/mcp-constants.d.ts.map +0 -1
  422. package/esm/mcp/mcp-constants.js +0 -18
  423. package/esm/mcp/mcp-constants.js.map +0 -1
  424. package/esm/model/mcp-server-info.d.ts +0 -76
  425. package/esm/model/mcp-server-info.d.ts.map +0 -1
  426. package/esm/model/mcp-server-info.js +0 -25
  427. package/esm/model/mcp-server-info.js.map +0 -1
  428. package/esm/schema/schema.d.ts +0 -49
  429. package/esm/schema/schema.d.ts.map +0 -1
  430. package/esm/schema/schema.js +0 -124
  431. package/esm/schema/schema.js.map +0 -1
  432. package/esm/schema/standard-schema.d.ts +0 -22
  433. package/esm/schema/standard-schema.d.ts.map +0 -1
  434. package/esm/schema/standard-schema.js +0 -39
  435. package/esm/schema/standard-schema.js.map +0 -1
  436. package/esm/schema/validate.d.ts +0 -14
  437. package/esm/schema/validate.d.ts.map +0 -1
  438. package/esm/schema/validate.js +0 -145
  439. package/esm/schema/validate.js.map +0 -1
  440. package/esm/v1/types/auth.d.ts +0 -24
  441. package/esm/v1/types/auth.d.ts.map +0 -1
  442. package/esm/v1/types/auth.js +0 -2
  443. package/esm/v1/types/auth.js.map +0 -1
  444. package/esm/v1/types/event.d.ts +0 -89
  445. package/esm/v1/types/event.d.ts.map +0 -1
  446. package/esm/v1/types/event.js +0 -53
  447. package/esm/v1/types/event.js.map +0 -1
  448. package/esm/v1/types/thread.d.ts +0 -58
  449. package/esm/v1/types/thread.d.ts.map +0 -1
  450. package/esm/v1/types/thread.js +0 -8
  451. package/esm/v1/types/thread.js.map +0 -1
  452. package/esm/v1/types/tool-choice.d.ts +0 -8
  453. package/esm/v1/types/tool-choice.d.ts.map +0 -1
  454. package/esm/v1/types/tool-choice.js +0 -2
  455. package/esm/v1/types/tool-choice.js.map +0 -1
  456. package/esm/v1/utils/event-accumulator.d.ts +0 -165
  457. package/esm/v1/utils/event-accumulator.d.ts.map +0 -1
  458. package/esm/v1/utils/event-accumulator.js +0 -1268
  459. package/esm/v1/utils/event-accumulator.js.map +0 -1
  460. package/esm/v1/utils/json-patch.d.ts +0 -18
  461. package/esm/v1/utils/json-patch.d.ts.map +0 -1
  462. package/esm/v1/utils/json-patch.js +0 -32
  463. package/esm/v1/utils/json-patch.js.map +0 -1
  464. package/esm/v1/utils/keyed-throttle.d.ts +0 -42
  465. package/esm/v1/utils/keyed-throttle.d.ts.map +0 -1
  466. package/esm/v1/utils/keyed-throttle.js +0 -83
  467. package/esm/v1/utils/keyed-throttle.js.map +0 -1
  468. package/esm/v1/utils/registry-conversion.d.ts +0 -53
  469. package/esm/v1/utils/registry-conversion.d.ts.map +0 -1
  470. package/esm/v1/utils/registry-conversion.js +0 -109
  471. package/esm/v1/utils/registry-conversion.js.map +0 -1
  472. package/esm/v1/utils/stream-handler.d.ts +0 -45
  473. package/esm/v1/utils/stream-handler.d.ts.map +0 -1
  474. package/esm/v1/utils/stream-handler.js +0 -44
  475. package/esm/v1/utils/stream-handler.js.map +0 -1
  476. package/esm/v1/utils/thread-utils.d.ts +0 -16
  477. package/esm/v1/utils/thread-utils.d.ts.map +0 -1
  478. package/esm/v1/utils/thread-utils.js +0 -31
  479. package/esm/v1/utils/thread-utils.js.map +0 -1
  480. package/esm/v1/utils/tool-call-tracker.d.ts +0 -73
  481. package/esm/v1/utils/tool-call-tracker.d.ts.map +0 -1
  482. package/esm/v1/utils/tool-call-tracker.js +0 -176
  483. package/esm/v1/utils/tool-call-tracker.js.map +0 -1
  484. package/esm/v1/utils/tool-executor.d.ts +0 -67
  485. package/esm/v1/utils/tool-executor.d.ts.map +0 -1
  486. package/esm/v1/utils/tool-executor.js +0 -154
  487. package/esm/v1/utils/tool-executor.js.map +0 -1
  488. package/esm/v1/utils/unstrictify.d.ts +0 -32
  489. package/esm/v1/utils/unstrictify.d.ts.map +0 -1
  490. package/esm/v1/utils/unstrictify.js +0 -155
  491. package/esm/v1/utils/unstrictify.js.map +0 -1
@@ -1,4 +1,17 @@
1
- import { ContextHelperFn } from "./types";
1
+ import type { ContextHelperFn } from "./types";
2
+ interface InteractableComponentMetadata {
3
+ id: string;
4
+ componentName: string;
5
+ description: string;
6
+ props: unknown;
7
+ propsSchema: string;
8
+ state: unknown;
9
+ isSelectedForInteraction: boolean;
10
+ stateSchema: string;
11
+ }
12
+ export interface InteractablesContext {
13
+ components: InteractableComponentMetadata[];
14
+ }
2
15
  /**
3
16
  * Prebuilt context helper that provides information about all interactable components currently on the page.
4
17
  * This gives the AI awareness of what components it can interact with and their current state.
@@ -24,5 +37,6 @@ export declare const currentInteractablesContextHelper: ContextHelperFn;
24
37
  * @param components Array of interactable components
25
38
  * @returns A context helper function that returns component metadata or null if no components exist
26
39
  */
27
- export declare const createInteractablesContextHelper: (components: unknown[]) => ContextHelperFn;
40
+ export declare const createInteractablesContextHelper: (components: unknown[]) => (() => InteractablesContext | null);
41
+ export {};
28
42
  //# sourceMappingURL=current-interactables-context-helper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"current-interactables-context-helper.d.ts","sourceRoot":"","sources":["../../src/context-helpers/current-interactables-context-helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,iCAAiC,EAAE,eAI/C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,GAC3C,YAAY,OAAO,EAAE,KACpB,eAyCF,CAAC"}
1
+ {"version":3,"file":"current-interactables-context-helper.d.ts","sourceRoot":"","sources":["../../src/context-helpers/current-interactables-context-helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,UAAU,6BAA6B;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,OAAO,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,OAAO,CAAC;IACf,wBAAwB,EAAE,OAAO,CAAC;IAClC,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,6BAA6B,EAAE,CAAC;CAC7C;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,iCAAiC,EAAE,eAI/C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,GAC3C,YAAY,OAAO,EAAE,KACpB,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAyCpC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"current-interactables-context-helper.js","sourceRoot":"","sources":["../../src/context-helpers/current-interactables-context-helper.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;;;GAiBG;AACI,MAAM,iCAAiC,GAAoB,GAAG,EAAE;IACrE,mFAAmF;IACnF,wEAAwE;IACxE,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;A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D,CAAC,CAAC,eAAe;iBACpB,CAAC;YACJ,CAAC,CAAC;SACH,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC;AA3CW,QAAA,gCAAgC,oCA2C3C","sourcesContent":["import { ContextHelperFn } from \"./types\";\n\n/**\n * Prebuilt context helper that provides information about all interactable components currently on the page.\n * This gives the AI awareness of what components it can interact with and their current state.\n * @returns an object with description and components, or null to skip including this context.\n * To disable this helper, override it with a function that returns null:\n * @example\n * ```tsx\n * // To disable the default interactables context\n * const { addContextHelper } = useTamboContextHelpers();\n * addContextHelper(\"interactables\", () => null);\n *\n * // To customize the context\n * addContextHelper(\"interactables\", () => ({\n * description: \"Custom description\",\n * components: getCustomComponentsSubset()\n * }));\n * ```\n */\nexport const currentInteractablesContextHelper: ContextHelperFn = () => {\n // This will be provided by the interactable provider when it registers this helper\n // Since we're provider-only now, this function gets replaced at runtime\n return null;\n};\n\n/**\n * Creates an interactables context helper with access to the current components.\n * This is used internally by TamboInteractableProvider.\n * @param components Array of interactable components\n * @returns A context helper function that returns component metadata or null if no components exist\n */\nexport const createInteractablesContextHelper = (\n components: unknown[],\n): ContextHelperFn => {\n return () => {\n if (!Array.isArray(components) || components.length === 0) {\n return null; // No interactable components on the page\n }\n\n return {\n components: components.map((component) => {\n // Type guard: ensure component is an object with the expected properties\n if (typeof component !== \"object\" || component === null) {\n return {\n id: \"unknown\",\n componentName: \"unknown\",\n description: \"invalid component\",\n props: undefined,\n propsSchema: \"Not specified\",\n state: undefined,\n isSelectedForInteraction: false,\n stateSchema: \"Not specified\",\n };\n }\n\n const comp = component as Record<string, unknown>;\n return {\n id: String(comp.id ?? \"unknown\"),\n componentName: String(comp.name ?? \"unknown\"),\n description: String(comp.description ?? \"\"),\n props: comp.props,\n propsSchema: comp.propsSchema\n ? \"Available - use component-specific update tools\"\n : \"Not specified\",\n state: comp.state,\n isSelectedForInteraction:\n (comp.isSelectedForInteraction as boolean | undefined) ?? false,\n stateSchema: comp.stateSchema\n ? \"Available - use component-specific update tools\"\n : \"Not specified\",\n };\n }),\n };\n };\n};\n"]}
1
+ {"version":3,"file":"current-interactables-context-helper.js","sourceRoot":"","sources":["../../src/context-helpers/current-interactables-context-helper.ts"],"names":[],"mappings":";;;AAiBA;;;;;;;;;;;;;;;;;GAiBG;AACI,MAAM,iCAAiC,GAAoB,GAAG,EAAE;IACrE,mFAAmF;IACnF,wEAAwE;IACxE,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAJW,QAAA,iCAAiC,qCAI5C;AAEF;;;;;GAKG;AACI,MAAM,gCAAgC,GAAG,CAC9C,UAAqB,EACgB,EAAE;IACvC,OAAO,GAAG,EAAE;QACV,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC1D,OAAO,IAAI,CAAC,CAAC,yCAAyC;QACxD,CAAC;QAED,OAAO;YACL,UAAU,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;gBACvC,yEAAyE;gBACzE,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;oBACxD,OAAO;wBACL,EAAE,EAAE,SAAS;wBACb,aAAa,EAAE,SAAS;wBACxB,WAAW,EAAE,mBAAmB;wBAChC,KAAK,EAAE,SAAS;wBAChB,WAAW,EAAE,eAAe;wBAC5B,KAAK,EAAE,SAAS;wBAChB,wBAAwB,EAAE,KAAK;wBAC/B,WAAW,EAAE,eAAe;qBAC7B,CAAC;gBACJ,CAAC;gBAED,MAAM,IAAI,GAAG,SAAoC,CAAC;gBAClD,OAAO;oBACL,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,SAAS,CAAC;oBAChC,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,SAAS,CAAC;oBAC7C,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC;oBAC3C,KAAK,EAAE,IAAI,CAAC,KAAK;oBACjB,WAAW,EAAE,IAAI,CAAC,WAAW;wBAC3B,CAAC,CAAC,iDAAiD;wBACnD,CAAC,CAAC,eAAe;oBACnB,KAAK,EAAE,IAAI,CAAC,KAAK;oBACjB,wBAAwB,EACrB,IAAI,CAAC,wBAAgD,IAAI,KAAK;oBACjE,WAAW,EAAE,IAAI,CAAC,WAAW;wBAC3B,CAAC,CAAC,iDAAiD;wBACnD,CAAC,CAAC,eAAe;iBACpB,CAAC;YACJ,CAAC,CAAC;SACH,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC;AA3CW,QAAA,gCAAgC,oCA2C3C","sourcesContent":["import type { ContextHelperFn } from \"./types\";\n\ninterface InteractableComponentMetadata {\n id: string;\n componentName: string;\n description: string;\n props: unknown;\n propsSchema: string;\n state: unknown;\n isSelectedForInteraction: boolean;\n stateSchema: string;\n}\n\nexport interface InteractablesContext {\n components: InteractableComponentMetadata[];\n}\n\n/**\n * Prebuilt context helper that provides information about all interactable components currently on the page.\n * This gives the AI awareness of what components it can interact with and their current state.\n * @returns an object with description and components, or null to skip including this context.\n * To disable this helper, override it with a function that returns null:\n * @example\n * ```tsx\n * // To disable the default interactables context\n * const { addContextHelper } = useTamboContextHelpers();\n * addContextHelper(\"interactables\", () => null);\n *\n * // To customize the context\n * addContextHelper(\"interactables\", () => ({\n * description: \"Custom description\",\n * components: getCustomComponentsSubset()\n * }));\n * ```\n */\nexport const currentInteractablesContextHelper: ContextHelperFn = () => {\n // This will be provided by the interactable provider when it registers this helper\n // Since we're provider-only now, this function gets replaced at runtime\n return null;\n};\n\n/**\n * Creates an interactables context helper with access to the current components.\n * This is used internally by TamboInteractableProvider.\n * @param components Array of interactable components\n * @returns A context helper function that returns component metadata or null if no components exist\n */\nexport const createInteractablesContextHelper = (\n components: unknown[],\n): (() => InteractablesContext | null) => {\n return () => {\n if (!Array.isArray(components) || components.length === 0) {\n return null; // No interactable components on the page\n }\n\n return {\n components: components.map((component) => {\n // Type guard: ensure component is an object with the expected properties\n if (typeof component !== \"object\" || component === null) {\n return {\n id: \"unknown\",\n componentName: \"unknown\",\n description: \"invalid component\",\n props: undefined,\n propsSchema: \"Not specified\",\n state: undefined,\n isSelectedForInteraction: false,\n stateSchema: \"Not specified\",\n };\n }\n\n const comp = component as Record<string, unknown>;\n return {\n id: String(comp.id ?? \"unknown\"),\n componentName: String(comp.name ?? \"unknown\"),\n description: String(comp.description ?? \"\"),\n props: comp.props,\n propsSchema: comp.propsSchema\n ? \"Available - use component-specific update tools\"\n : \"Not specified\",\n state: comp.state,\n isSelectedForInteraction:\n (comp.isSelectedForInteraction as boolean | undefined) ?? false,\n stateSchema: comp.stateSchema\n ? \"Available - use component-specific update tools\"\n : \"Not specified\",\n };\n }),\n };\n };\n};\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=current-interactables-context-helper.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"current-interactables-context-helper.test.d.ts","sourceRoot":"","sources":["../../src/context-helpers/current-interactables-context-helper.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const current_interactables_context_helper_1 = require("./current-interactables-context-helper");
4
+ describe("currentInteractablesContextHelper", () => {
5
+ it("returns null by default (placeholder before provider replaces it)", () => {
6
+ expect((0, current_interactables_context_helper_1.currentInteractablesContextHelper)()).toBeNull();
7
+ });
8
+ });
9
+ describe("createInteractablesContextHelper", () => {
10
+ it("returns null when components array is empty", () => {
11
+ const helper = (0, current_interactables_context_helper_1.createInteractablesContextHelper)([]);
12
+ expect(helper()).toBeNull();
13
+ });
14
+ it("maps valid component objects to metadata", () => {
15
+ const components = [
16
+ {
17
+ id: "comp-1",
18
+ name: "WeatherCard",
19
+ description: "Shows weather",
20
+ props: { city: "NYC" },
21
+ propsSchema: { type: "object" },
22
+ state: { temp: 72 },
23
+ isSelectedForInteraction: true,
24
+ stateSchema: { type: "object" },
25
+ },
26
+ ];
27
+ const helper = (0, current_interactables_context_helper_1.createInteractablesContextHelper)(components);
28
+ const result = helper();
29
+ expect(result).toEqual({
30
+ components: [
31
+ {
32
+ id: "comp-1",
33
+ componentName: "WeatherCard",
34
+ description: "Shows weather",
35
+ props: { city: "NYC" },
36
+ propsSchema: "Available - use component-specific update tools",
37
+ state: { temp: 72 },
38
+ isSelectedForInteraction: true,
39
+ stateSchema: "Available - use component-specific update tools",
40
+ },
41
+ ],
42
+ });
43
+ });
44
+ it("handles invalid (non-object) components gracefully", () => {
45
+ const components = [null, "not-an-object", 42];
46
+ const helper = (0, current_interactables_context_helper_1.createInteractablesContextHelper)(components);
47
+ const result = helper();
48
+ expect(result?.components).toHaveLength(3);
49
+ for (const comp of result?.components ?? []) {
50
+ expect(comp.id).toBe("unknown");
51
+ expect(comp.componentName).toBe("unknown");
52
+ }
53
+ });
54
+ it("uses defaults for missing properties", () => {
55
+ const components = [{}];
56
+ const helper = (0, current_interactables_context_helper_1.createInteractablesContextHelper)(components);
57
+ const result = helper();
58
+ expect(result?.components[0]).toEqual({
59
+ id: "unknown",
60
+ componentName: "unknown",
61
+ description: "",
62
+ props: undefined,
63
+ propsSchema: "Not specified",
64
+ state: undefined,
65
+ isSelectedForInteraction: false,
66
+ stateSchema: "Not specified",
67
+ });
68
+ });
69
+ });
70
+ //# sourceMappingURL=current-interactables-context-helper.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"current-interactables-context-helper.test.js","sourceRoot":"","sources":["../../src/context-helpers/current-interactables-context-helper.test.ts"],"names":[],"mappings":";;AAAA,iGAGgD;AAEhD,QAAQ,CAAC,mCAAmC,EAAE,GAAG,EAAE;IACjD,EAAE,CAAC,mEAAmE,EAAE,GAAG,EAAE;QAC3E,MAAM,CAAC,IAAA,wEAAiC,GAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;IACzD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CA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E,EAAE,CAAC,CAAC;QAE/C,MAAM,MAAM,GAAG,IAAA,uEAAgC,EAAC,UAAU,CAAC,CAAC;QAC5D,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC;QACxB,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QAC3C,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE,UAAU,IAAI,EAAE,EAAE,CAAC;YAC5C,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAChC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC9C,MAAM,UAAU,GAAG,CAAC,EAAE,CAAC,CAAC;QAExB,MAAM,MAAM,GAAG,IAAA,uEAAgC,EAAC,UAAU,CAAC,CAAC;QAC5D,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC;QACxB,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;YACpC,EAAE,EAAE,SAAS;YACb,aAAa,EAAE,SAAS;YACxB,WAAW,EAAE,EAAE;YACf,KAAK,EAAE,SAAS;YAChB,WAAW,EAAE,eAAe;YAC5B,KAAK,EAAE,SAAS;YAChB,wBAAwB,EAAE,KAAK;YAC/B,WAAW,EAAE,eAAe;SAC7B,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import {\n currentInteractablesContextHelper,\n createInteractablesContextHelper,\n} from \"./current-interactables-context-helper\";\n\ndescribe(\"currentInteractablesContextHelper\", () => {\n it(\"returns null by default (placeholder before provider replaces it)\", () => {\n expect(currentInteractablesContextHelper()).toBeNull();\n });\n});\n\ndescribe(\"createInteractablesContextHelper\", () => {\n it(\"returns null when components array is empty\", () => {\n const helper = createInteractablesContextHelper([]);\n expect(helper()).toBeNull();\n });\n\n it(\"maps valid component objects to metadata\", () => {\n const components = [\n {\n id: \"comp-1\",\n name: \"WeatherCard\",\n description: \"Shows weather\",\n props: { city: \"NYC\" },\n propsSchema: { type: \"object\" },\n state: { temp: 72 },\n isSelectedForInteraction: true,\n stateSchema: { type: \"object\" },\n },\n ];\n\n const helper = createInteractablesContextHelper(components);\n const result = helper();\n expect(result).toEqual({\n components: [\n {\n id: \"comp-1\",\n componentName: \"WeatherCard\",\n description: \"Shows weather\",\n props: { city: \"NYC\" },\n propsSchema: \"Available - use component-specific update tools\",\n state: { temp: 72 },\n isSelectedForInteraction: true,\n stateSchema: \"Available - use component-specific update tools\",\n },\n ],\n });\n });\n\n it(\"handles invalid (non-object) components gracefully\", () => {\n const components = [null, \"not-an-object\", 42];\n\n const helper = createInteractablesContextHelper(components);\n const result = helper();\n expect(result?.components).toHaveLength(3);\n for (const comp of result?.components ?? []) {\n expect(comp.id).toBe(\"unknown\");\n expect(comp.componentName).toBe(\"unknown\");\n }\n });\n\n it(\"uses defaults for missing properties\", () => {\n const components = [{}];\n\n const helper = createInteractablesContextHelper(components);\n const result = helper();\n expect(result?.components[0]).toEqual({\n id: \"unknown\",\n componentName: \"unknown\",\n description: \"\",\n props: undefined,\n propsSchema: \"Not specified\",\n state: undefined,\n isSelectedForInteraction: false,\n stateSchema: \"Not specified\",\n });\n });\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"with-tambo-interactable.d.ts","sourceRoot":"","sources":["../../src/hoc/with-tambo-interactable.tsx"],"names":[],"mappings":"AACA,OAAO,KAAmD,MAAM,OAAO,CAAC;AACxE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEnE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAK5C,MAAM,WAAW,kBAAkB,CACjC,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EA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;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,WAAW,CAAC,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC;IACrC;;;OAGG;IACH,WAAW,CAAC,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC;IACrC;;;;;OAKG;IACH,WAAW,CAAC,EAAE,eAAe,CAAC;CAC/B;AAED;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IACzC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C;;;;OAIG;IACH,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;CAC7D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,qBAAqB,CAAC,cAAc,SAAS,MAAM,EACjE,gBAAgB,EAAE,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,EACrD,MAAM,EAAE,kBAAkB,yDAyI3B"}
@@ -75,7 +75,7 @@ const component_renderer_1 = require("../v1/utils/component-renderer");
75
75
  function withTamboInteractable(WrappedComponent, config) {
76
76
  const displayName = WrappedComponent.displayName ?? WrappedComponent.name ?? "Component";
77
77
  const TamboInteractableWrapper = (props) => {
78
- const { addInteractableComponent, updateInteractableComponentProps, getInteractableComponent, } = (0, tambo_interactable_provider_1.useTamboInteractable)();
78
+ const { addInteractableComponent, removeInteractableComponent, updateInteractableComponentProps, getInteractableComponent, } = (0, tambo_interactable_provider_1.useTamboInteractable)();
79
79
  const [interactableId, setInteractableId] = (0, react_1.useState)(null);
80
80
  const isInitialized = (0, react_1.useRef)(false);
81
81
  const lastSerializedProps = (0, react_1.useRef)({});
@@ -106,10 +106,19 @@ function withTamboInteractable(WrappedComponent, config) {
106
106
  isInitialized.current = true;
107
107
  }
108
108
  }, [addInteractableComponent, componentProps, onInteractableReady]);
109
- // Register the component as interactable on mount (only once)
109
+ // Register the component as interactable on mount
110
110
  (0, react_1.useEffect)(() => {
111
111
  registerComponent();
112
112
  }, [registerComponent]);
113
+ // Clean up on unmount only, keyed on stable values
114
+ (0, react_1.useEffect)(() => {
115
+ return () => {
116
+ if (isInitialized.current && interactableId) {
117
+ removeInteractableComponent(interactableId);
118
+ isInitialized.current = false;
119
+ }
120
+ };
121
+ }, [interactableId, removeInteractableComponent]);
113
122
  // Update the interactable component when props change from parent
114
123
  (0, react_1.useEffect)(() => {
115
124
  if (interactableId && isInitialized.current) {
@@ -1 +1 @@
1
- {"version":3,"file":"with-tambo-interactable.js","sourceRoot":"","sources":["../../src/hoc/with-tambo-interactable.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiGb,sDAgIC;AAhOD,+CAAwE;AAExE,0FAAgF;AAEhF,qFAA6E;AAE7E,uEAA0E;AAyD1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,SAAgB,qBAAqB,CACnC,gBAAqD,EACrD,MAA0B;IAE1B,MAAM,WAAW,GACf,gBAAgB,CAAC,WAAW,IAAI,gBAAgB,CAAC,IAAI,IAAI,WAAW,CAAC;IAEvE,MAAM,wBAAwB,GAE1B,CAAC,KAAK,EAAE,EAAE;QACZ,MAAM,EACJ,wBAAwB,EACxB,gCAAgC,EAChC,wBAAwB,GACzB,GAAG,IAAA,kDAAoB,GAAE,CAAC;QAE3B,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,IAAA,gBAAQ,EAAgB,IAAI,CAAC,CAAC;QAC1E,MAAM,aAAa,GAAG,IAAA,cAAM,EAAC,KAAK,CAAC,CAAC;QACpC,MAAM,mBAAmB,GAAG,IAAA,cAAM,EAA0B,EAAE,CAAC,CAAC;QAEhE,2DAA2D;QAC3D,MAAM,EACJ,cAAc,EAAE,WAAW,EAA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GAAI,CACnC,CACN,CACxB,CAAC;IACJ,CAAC,CAAC;IAEF,wBAAwB,CAAC,WAAW,GAAG,yBAAyB,WAAW,GAAG,CAAC;IAE/E,OAAO,wBAAwB,CAAC;AAClC,CAAC","sourcesContent":["\"use client\";\nimport React, { useCallback, useEffect, useRef, useState } from \"react\";\nimport type { ToolAnnotations } from \"../model/component-metadata\";\nimport { useTamboInteractable } from \"../providers/tambo-interactable-provider\";\nimport { SupportedSchema } from \"../schema\";\nimport { TamboMessageProvider } from \"../v1/hooks/use-tambo-current-message\";\nimport type { TamboThreadMessage } from \"../v1/types/message\";\nimport { ComponentContentProvider } from \"../v1/utils/component-renderer\";\n\nexport interface InteractableConfig<\n Props = Record<string, unknown>,\n State = Record<string, unknown>,\n> {\n /**\n * The name of the component, used for identification in Tambo.\n */\n componentName: string;\n /**\n * A brief description of the component's purpose and functionality. LLM will\n * use this to understand how to interact with it.\n */\n description: string;\n /**\n * Optional schema for component props. If provided, prop updates will be\n * validated against this schema.\n */\n propsSchema?: SupportedSchema<Props>;\n /**\n * Optional schema for component state. If provided, state updates will be\n * validated against this schema.\n */\n stateSchema?: SupportedSchema<State>;\n /**\n * Optional annotations for the interactable component's auto-registered tools\n * (props update and state update). By default, `tamboStreamableHint` is `true`\n * so props/state updates stream in real-time. Set `{ tamboStreamableHint: false }`\n * to disable streaming for this component's tools.\n */\n annotations?: ToolAnnotations;\n}\n\n/**\n * Props injected by withTamboInteractable HOC. These can be passed to the wrapped\n * component to customize interactable behavior.\n */\nexport interface WithTamboInteractableProps {\n /**\n * Optional ID to use for this interactable component instance.\n * If not provided, a unique ID will be generated automatically.\n */\n interactableId?: string;\n /**\n * Callback fired when the component has been registered as interactable.\n * @param id - The assigned interactable component ID\n */\n onInteractableReady?: (id: string) => void;\n /**\n * Callback fired when the component's serializable props are updated by Tambo\n * through a tool call. Note: Only serializable props are tracked.\n * @param newProps - The updated serializable props\n */\n onPropsUpdate?: (newProps: Record<string, unknown>) => void;\n}\n\n/**\n * Higher-Order Component that makes any component interactable by tambo.\n * @param WrappedComponent - The component to make interactable\n * @param config - Configuration for the interactable component\n * @returns A new component that is automatically registered as interactable\n * @example\n * ```tsx\n * const MyNote: React.FC<{ title: string; content: string }> = ({ title, content }) => {\n * const [isPinned, setIsPinned] = useTamboComponentState(\"isPinned\", false);\n * return (\n * <div style={{ border: isPinned ? \"2px solid gold\" : \"1px solid gray\", order: isPinned ? -1 : 0 }}>\n * <h2>{title}</h2>\n * <p>{content}</p>\n * </div>\n * );\n * };\n *\n * const MyInteractableNote = withTamboInteractable(MyNote, {\n * componentName: \"MyNote\",\n * description: \"A note component\",\n * propsSchema: z.object({\n * title: z.string(),\n * content: z.string(),\n * }),\n * stateSchema: z.object({\n * isPinned: z.boolean(),\n * }),\n * });\n *\n * // Usage\n * <MyInteractableNote title=\"My Note\" content=\"This is my note\" />\n * ```\n */\nexport function withTamboInteractable<ComponentProps extends object>(\n WrappedComponent: React.ComponentType<ComponentProps>,\n config: InteractableConfig,\n) {\n const displayName =\n WrappedComponent.displayName ?? WrappedComponent.name ?? \"Component\";\n\n const TamboInteractableWrapper: React.FC<\n ComponentProps & WithTamboInteractableProps\n > = (props) => {\n const {\n addInteractableComponent,\n updateInteractableComponentProps,\n getInteractableComponent,\n } = useTamboInteractable();\n\n const [interactableId, setInteractableId] = useState<string | null>(null);\n const isInitialized = useRef(false);\n const lastSerializedProps = useRef<Record<string, unknown>>({});\n\n // Extract interactable-specific props from component props\n const {\n interactableId: _providedId, // Reserved for future use\n onInteractableReady,\n onPropsUpdate,\n ...componentProps\n } = props;\n\n // Get the current interactable component to track prop updates\n const currentInteractable = interactableId\n ? getInteractableComponent(interactableId)\n : null;\n\n // Use the props from the interactable component if available, otherwise use the passed props\n // We need to be careful not to create a loop, so we only use stored props if they're different from passed props\n const effectiveProps = currentInteractable?.props ?? componentProps;\n\n // Memoize the registration function\n const registerComponent = useCallback(() => {\n if (!isInitialized.current) {\n const id = addInteractableComponent({\n name: config.componentName,\n description: config.description,\n component: WrappedComponent,\n props: componentProps,\n propsSchema: config.propsSchema,\n stateSchema: config.stateSchema,\n annotations: config.annotations,\n });\n\n setInteractableId(id);\n onInteractableReady?.(id);\n isInitialized.current = true;\n }\n }, [addInteractableComponent, componentProps, onInteractableReady]);\n\n // Register the component as interactable on mount (only once)\n useEffect(() => {\n registerComponent();\n }, [registerComponent]);\n\n // Update the interactable component when props change from parent\n useEffect(() => {\n if (interactableId && isInitialized.current) {\n // Only update if the props are different from what we last sent\n const lastPropsString = JSON.stringify(lastSerializedProps.current);\n const currentPropsString = JSON.stringify(componentProps);\n\n if (lastPropsString !== currentPropsString) {\n updateInteractableComponentProps(interactableId, componentProps);\n onPropsUpdate?.(componentProps);\n lastSerializedProps.current = componentProps;\n }\n }\n }, [\n interactableId,\n componentProps,\n updateInteractableComponentProps,\n onPropsUpdate,\n ]);\n\n // If the interactable ID is not yet set, render the component without provider\n if (!interactableId) {\n return <WrappedComponent {...(effectiveProps as ComponentProps)} />;\n }\n\n // Create a minimal message with interactable metadata\n // This allows useTamboCurrentComponent to work with standalone interactable components\n const minimalMessage: TamboThreadMessage = {\n id: interactableId,\n role: \"assistant\" as const,\n content: [\n {\n type: \"component\" as const,\n id: interactableId,\n name: config.componentName,\n props: effectiveProps,\n state: {},\n },\n ],\n createdAt: new Date().toISOString(),\n };\n\n // Wrap with TamboMessageProvider and ComponentContentProvider including interactable metadata\n return (\n <TamboMessageProvider\n message={minimalMessage}\n interactableMetadata={{\n id: interactableId,\n componentName: config.componentName,\n description: config.description,\n }}\n >\n <ComponentContentProvider\n componentId={interactableId}\n threadId=\"\"\n messageId=\"\"\n componentName={config.componentName}\n >\n <WrappedComponent {...(effectiveProps as ComponentProps)} />\n </ComponentContentProvider>\n </TamboMessageProvider>\n );\n };\n\n TamboInteractableWrapper.displayName = `withTamboInteractable(${displayName})`;\n\n return TamboInteractableWrapper;\n}\n"]}
1
+ {"version":3,"file":"with-tambo-interactable.js","sourceRoot":"","sources":["../../src/ho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C;AAClC,CAAC","sourcesContent":["\"use client\";\nimport React, { useCallback, useEffect, useRef, useState } from \"react\";\nimport type { ToolAnnotations } from \"../model/component-metadata\";\nimport { useTamboInteractable } from \"../providers/tambo-interactable-provider\";\nimport { SupportedSchema } from \"../schema\";\nimport { TamboMessageProvider } from \"../v1/hooks/use-tambo-current-message\";\nimport type { TamboThreadMessage } from \"../v1/types/message\";\nimport { ComponentContentProvider } from \"../v1/utils/component-renderer\";\n\nexport interface InteractableConfig<\n Props = Record<string, unknown>,\n State = Record<string, unknown>,\n> {\n /**\n * The name of the component, used for identification in Tambo.\n */\n componentName: string;\n /**\n * A brief description of the component's purpose and functionality. LLM will\n * use this to understand how to interact with it.\n */\n description: string;\n /**\n * Optional schema for component props. If provided, prop updates will be\n * validated against this schema.\n */\n propsSchema?: SupportedSchema<Props>;\n /**\n * Optional schema for component state. If provided, state updates will be\n * validated against this schema.\n */\n stateSchema?: SupportedSchema<State>;\n /**\n * Optional annotations for the interactable component's auto-registered tools\n * (props update and state update). By default, `tamboStreamableHint` is `true`\n * so props/state updates stream in real-time. Set `{ tamboStreamableHint: false }`\n * to disable streaming for this component's tools.\n */\n annotations?: ToolAnnotations;\n}\n\n/**\n * Props injected by withTamboInteractable HOC. These can be passed to the wrapped\n * component to customize interactable behavior.\n */\nexport interface WithTamboInteractableProps {\n /**\n * Optional ID to use for this interactable component instance.\n * If not provided, a unique ID will be generated automatically.\n */\n interactableId?: string;\n /**\n * Callback fired when the component has been registered as interactable.\n * @param id - The assigned interactable component ID\n */\n onInteractableReady?: (id: string) => void;\n /**\n * Callback fired when the component's serializable props are updated by Tambo\n * through a tool call. Note: Only serializable props are tracked.\n * @param newProps - The updated serializable props\n */\n onPropsUpdate?: (newProps: Record<string, unknown>) => void;\n}\n\n/**\n * Higher-Order Component that makes any component interactable by tambo.\n * @param WrappedComponent - The component to make interactable\n * @param config - Configuration for the interactable component\n * @returns A new component that is automatically registered as interactable\n * @example\n * ```tsx\n * const MyNote: React.FC<{ title: string; content: string }> = ({ title, content }) => {\n * const [isPinned, setIsPinned] = useTamboComponentState(\"isPinned\", false);\n * return (\n * <div style={{ border: isPinned ? \"2px solid gold\" : \"1px solid gray\", order: isPinned ? -1 : 0 }}>\n * <h2>{title}</h2>\n * <p>{content}</p>\n * </div>\n * );\n * };\n *\n * const MyInteractableNote = withTamboInteractable(MyNote, {\n * componentName: \"MyNote\",\n * description: \"A note component\",\n * propsSchema: z.object({\n * title: z.string(),\n * content: z.string(),\n * }),\n * stateSchema: z.object({\n * isPinned: z.boolean(),\n * }),\n * });\n *\n * // Usage\n * <MyInteractableNote title=\"My Note\" content=\"This is my note\" />\n * ```\n */\nexport function withTamboInteractable<ComponentProps extends object>(\n WrappedComponent: React.ComponentType<ComponentProps>,\n config: InteractableConfig,\n) {\n const displayName =\n WrappedComponent.displayName ?? WrappedComponent.name ?? \"Component\";\n\n const TamboInteractableWrapper: React.FC<\n ComponentProps & WithTamboInteractableProps\n > = (props) => {\n const {\n addInteractableComponent,\n removeInteractableComponent,\n updateInteractableComponentProps,\n getInteractableComponent,\n } = useTamboInteractable();\n\n const [interactableId, setInteractableId] = useState<string | null>(null);\n const isInitialized = useRef(false);\n const lastSerializedProps = useRef<Record<string, unknown>>({});\n\n // Extract interactable-specific props from component props\n const {\n interactableId: _providedId, // Reserved for future use\n onInteractableReady,\n onPropsUpdate,\n ...componentProps\n } = props;\n\n // Get the current interactable component to track prop updates\n const currentInteractable = interactableId\n ? getInteractableComponent(interactableId)\n : null;\n\n // Use the props from the interactable component if available, otherwise use the passed props\n // We need to be careful not to create a loop, so we only use stored props if they're different from passed props\n const effectiveProps = currentInteractable?.props ?? componentProps;\n\n // Memoize the registration function\n const registerComponent = useCallback(() => {\n if (!isInitialized.current) {\n const id = addInteractableComponent({\n name: config.componentName,\n description: config.description,\n component: WrappedComponent,\n props: componentProps,\n propsSchema: config.propsSchema,\n stateSchema: config.stateSchema,\n annotations: config.annotations,\n });\n\n setInteractableId(id);\n onInteractableReady?.(id);\n isInitialized.current = true;\n }\n }, [addInteractableComponent, componentProps, onInteractableReady]);\n\n // Register the component as interactable on mount\n useEffect(() => {\n registerComponent();\n }, [registerComponent]);\n\n // Clean up on unmount only, keyed on stable values\n useEffect(() => {\n return () => {\n if (isInitialized.current && interactableId) {\n removeInteractableComponent(interactableId);\n isInitialized.current = false;\n }\n };\n }, [interactableId, removeInteractableComponent]);\n\n // Update the interactable component when props change from parent\n useEffect(() => {\n if (interactableId && isInitialized.current) {\n // Only update if the props are different from what we last sent\n const lastPropsString = JSON.stringify(lastSerializedProps.current);\n const currentPropsString = JSON.stringify(componentProps);\n\n if (lastPropsString !== currentPropsString) {\n updateInteractableComponentProps(interactableId, componentProps);\n onPropsUpdate?.(componentProps);\n lastSerializedProps.current = componentProps;\n }\n }\n }, [\n interactableId,\n componentProps,\n updateInteractableComponentProps,\n onPropsUpdate,\n ]);\n\n // If the interactable ID is not yet set, render the component without provider\n if (!interactableId) {\n return <WrappedComponent {...(effectiveProps as ComponentProps)} />;\n }\n\n // Create a minimal message with interactable metadata\n // This allows useTamboCurrentComponent to work with standalone interactable components\n const minimalMessage: TamboThreadMessage = {\n id: interactableId,\n role: \"assistant\" as const,\n content: [\n {\n type: \"component\" as const,\n id: interactableId,\n name: config.componentName,\n props: effectiveProps,\n state: {},\n },\n ],\n createdAt: new Date().toISOString(),\n };\n\n // Wrap with TamboMessageProvider and ComponentContentProvider including interactable metadata\n return (\n <TamboMessageProvider\n message={minimalMessage}\n interactableMetadata={{\n id: interactableId,\n componentName: config.componentName,\n description: config.description,\n }}\n >\n <ComponentContentProvider\n componentId={interactableId}\n threadId=\"\"\n messageId=\"\"\n componentName={config.componentName}\n >\n <WrappedComponent {...(effectiveProps as ComponentProps)} />\n </ComponentContentProvider>\n </TamboMessageProvider>\n );\n };\n\n TamboInteractableWrapper.displayName = `withTamboInteractable(${displayName})`;\n\n return TamboInteractableWrapper;\n}\n"]}
@@ -200,5 +200,19 @@ describe("withTamboInteractable", () => {
200
200
  expect(react_1.screen.getByTestId("optional")).toHaveTextContent("undefined");
201
201
  expect(react_1.screen.getByTestId("nullable")).toHaveTextContent("null");
202
202
  });
203
+ it("should call removeInteractableComponent on unmount", async () => {
204
+ const InteractableComponent = (0, with_tambo_interactable_1.withTamboInteractable)(TestComponent, {
205
+ componentName: "TestComponent",
206
+ description: "A test component",
207
+ propsSchema: testSchema,
208
+ });
209
+ const { unmount } = (0, react_1.render)(react_2.default.createElement(tambo_interactable_provider_1.TamboInteractableProvider, null,
210
+ react_2.default.createElement(InteractableComponent, { title: "Unmount Test" })));
211
+ await (0, react_1.waitFor)(() => {
212
+ expect(mockAddInteractableComponent).toHaveBeenCalled();
213
+ });
214
+ unmount();
215
+ expect(mockRemoveInteractableComponent).toHaveBeenCalledWith("mock-id-123");
216
+ });
203
217
  });
204
218
  //# sourceMappingURL=with-tambo-interactable.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"with-tambo-interactable.test.js","sourceRoot":"","sources":["../../src/hoc/with-tambo-interactable.test.tsx"],"names":[],"mappings":";;;;;AAAA,kDAAiE;AACjE,kDAA0B;AAC1B,+BAA2B;AAC3B,qFAAiF;AACjF,0FAAqF;AACrF,uEAAkE;AAElE,0CAA0C;AAC1C,MAAM,4BAA4B,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC,CAAC;AAClE,MAAM,oCAAoC,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AACvD,MAAM,4BAA4B,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;AACzD,MAAM,+BAA+B,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AAClD,MAAM,mCAAmC,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;AAC9D,MAAM,kCAAkC,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AAErD,iCAAiC;AACjC,IAAI,CAAC,IAAI,C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MAAM,EAAC,QAAQ,EAAE,IAAI,GAAI,CAC5B,CAC7B,CAAC;QAEF,MAAM,CAAC,cAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAC9D,MAAM,CAAC,cAAM,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;QACtE,MAAM,CAAC,cAAM,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { render, screen, waitFor } from \"@testing-library/react\";\nimport React from \"react\";\nimport { z } from \"zod/v3\";\nimport { useTamboCurrentComponent } from \"../v1/hooks/use-tambo-current-message\";\nimport { TamboInteractableProvider } from \"../providers/tambo-interactable-provider\";\nimport { withTamboInteractable } from \"./with-tambo-interactable\";\n\n// Create a consistent mock implementation\nconst mockAddInteractableComponent = jest.fn(() => \"mock-id-123\");\nconst mockUpdateInteractableComponentProps = jest.fn();\nconst mockGetInteractableComponent = jest.fn(() => null);\nconst mockRemoveInteractableComponent = jest.fn();\nconst mockGetInteractableComponentsByName = jest.fn(() => []);\nconst mockClearAllInteractableComponents = jest.fn();\n\n// Mock the interactable provider\njest.mock(\"../providers/tambo-interactable-provider\", () => ({\n TamboInteractableProvider: ({ children }: { children: React.ReactNode }) => (\n <div data-testid=\"interactable-provider\">{children}</div>\n ),\n useTamboInteractable: () => ({\n addInteractableComponent: mockAddInteractableComponent,\n updateInteractableComponentProps: mockUpdateInteractableComponentProps,\n getInteractableComponent: mockGetInteractableComponent,\n removeInteractableComponent: mockRemoveInteractableComponent,\n getInteractableComponentsByName: mockGetInteractableComponentsByName,\n clearAllInteractableComponents: mockClearAllInteractableComponents,\n interactableComponents: [],\n }),\n}));\n\ndescribe(\"withTamboInteractable\", () => {\n // Simple test component\n interface TestComponentProps {\n title: string;\n count?: number;\n }\n\n const TestComponent: React.FC<TestComponentProps> = ({ title, count }) => (\n <div>\n <h1 data-testid=\"title\">{title}</h1>\n {count !== undefined && <span data-testid=\"count\">{count}</span>}\n </div>\n );\n\n const testSchema = z.object({\n title: z.string(),\n count: z.number().optional(),\n });\n\n beforeEach(() => {\n jest.clearAllMocks();\n // Reset mock implementations\n mockAddInteractableComponent.mockReturnValue(\"mock-id-123\");\n mockGetInteractableComponent.mockReturnValue(null);\n mockGetInteractableComponentsByName.mockReturnValue([]);\n });\n\n it(\"should render the wrapped component with provided props\", () => {\n const InteractableComponent = withTamboInteractable(TestComponent, {\n componentName: \"TestComponent\",\n description: \"A test component\",\n propsSchema: testSchema,\n });\n\n render(\n <TamboInteractableProvider>\n <InteractableComponent title=\"Hello\" count={42} />\n </TamboInteractableProvider>,\n );\n\n expect(screen.getByTestId(\"title\")).toHaveTextContent(\"Hello\");\n expect(screen.getByTestId(\"count\")).toHaveTextContent(\"42\");\n });\n\n it(\"should set displayName correctly\", () => {\n const InteractableComponent = withTamboInteractable(TestComponent, {\n componentName: \"TestComponent\",\n description: \"A test component\",\n });\n\n expect(InteractableComponent.displayName).toBe(\n \"withTamboInteractable(TestComponent)\",\n );\n });\n\n it(\"should handle components without displayName\", () => {\n const AnonymousComponent = () => <div>Anonymous</div>;\n\n const InteractableComponent = withTamboInteractable(AnonymousComponent, {\n componentName: \"AnonymousComponent\",\n description: \"An anonymous component\",\n });\n\n // Anonymous components get their name from the function name\n expect(InteractableComponent.displayName).toBe(\n \"withTamboInteractable(AnonymousComponent)\",\n );\n });\n\n it(\"should provide TamboMessageProvider with interactable metadata\", async () => {\n // Child component that uses the context\n const ContextConsumer = () => {\n const component = useTamboCurrentComponent();\n return (\n <div>\n <span data-testid=\"interactable-id\">{component?.interactableId}</span>\n <span data-testid=\"component-name\">{component?.componentName}</span>\n <span data-testid=\"description\">{component?.description}</span>\n </div>\n );\n };\n\n // Wrap TestComponent to include ContextConsumer\n const TestComponentWithConsumer: React.FC<TestComponentProps> = (props) => (\n <div>\n <TestComponent {...props} />\n <ContextConsumer />\n </div>\n );\n\n const InteractableWithConsumer = withTamboInteractable(\n TestComponentWithConsumer,\n {\n componentName: \"TestComponent\",\n description: \"A test component\",\n propsSchema: testSchema,\n },\n );\n\n render(\n <TamboInteractableProvider>\n <InteractableWithConsumer title=\"Hello\" />\n </TamboInteractableProvider>,\n );\n\n // Wait for the component to register and render\n await waitFor(() => {\n expect(screen.getByTestId(\"interactable-id\")).toHaveTextContent(\n \"mock-id-123\",\n );\n });\n\n expect(screen.getByTestId(\"component-name\")).toHaveTextContent(\n \"TestComponent\",\n );\n expect(screen.getByTestId(\"description\")).toHaveTextContent(\n \"A test component\",\n );\n });\n\n it(\"should create minimal message with correct structure\", async () => {\n // Child component that checks the message structure\n const MessageChecker = () => {\n const component = useTamboCurrentComponent();\n return (\n <div>\n <span data-testid=\"has-component-name\">\n {component?.componentName ? \"yes\" : \"no\"}\n </span>\n <span data-testid=\"has-props\">{component?.props ? \"yes\" : \"no\"}</span>\n <span data-testid=\"has-interactable-id\">\n {component?.interactableId ? \"yes\" : \"no\"}\n </span>\n <span data-testid=\"has-description\">\n {component?.description ? \"yes\" : \"no\"}\n </span>\n </div>\n );\n };\n\n const TestComponentWithChecker: React.FC<TestComponentProps> = (props) => (\n <div>\n <TestComponent {...props} />\n <MessageChecker />\n </div>\n );\n\n const InteractableWithChecker = withTamboInteractable(\n TestComponentWithChecker,\n {\n componentName: \"TestComponent\",\n description: \"A test component\",\n propsSchema: testSchema,\n },\n );\n\n render(\n <TamboInteractableProvider>\n <InteractableWithChecker title=\"Hello\" count={42} />\n </TamboInteractableProvider>,\n );\n\n await waitFor(() => {\n expect(screen.getByTestId(\"has-component-name\")).toHaveTextContent(\"yes\");\n });\n\n expect(screen.getByTestId(\"has-props\")).toHaveTextContent(\"yes\");\n expect(screen.getByTestId(\"has-interactable-id\")).toHaveTextContent(\"yes\");\n expect(screen.getByTestId(\"has-description\")).toHaveTextContent(\"yes\");\n });\n\n it(\"should pass through all component props correctly\", () => {\n const InteractableComponent = withTamboInteractable(TestComponent, {\n componentName: \"TestComponent\",\n description: \"A test component\",\n propsSchema: testSchema,\n });\n\n render(\n <TamboInteractableProvider>\n <InteractableComponent title=\"Test Title\" count={100} />\n </TamboInteractableProvider>,\n );\n\n expect(screen.getByTestId(\"title\")).toHaveTextContent(\"Test Title\");\n expect(screen.getByTestId(\"count\")).toHaveTextContent(\"100\");\n });\n\n it(\"should filter out interactable-specific props from component props\", () => {\n interface ExtendedProps extends TestComponentProps {\n onInteractableReady?: (id: string) => void;\n onPropsUpdate?: (props: Record<string, any>) => void;\n }\n\n const ExtendedComponent: React.FC<ExtendedProps> = ({\n title,\n onInteractableReady,\n onPropsUpdate,\n }) => (\n <div>\n <span data-testid=\"title\">{title}</span>\n <span data-testid=\"has-ready\">\n {onInteractableReady ? \"yes\" : \"no\"}\n </span>\n <span data-testid=\"has-update\">{onPropsUpdate ? \"yes\" : \"no\"}</span>\n </div>\n );\n\n const InteractableComponent = withTamboInteractable(ExtendedComponent, {\n componentName: \"ExtendedComponent\",\n description: \"An extended component\",\n });\n\n const mockReady = jest.fn();\n const mockUpdate = jest.fn();\n\n render(\n <TamboInteractableProvider>\n <InteractableComponent\n title=\"Test\"\n onInteractableReady={mockReady}\n onPropsUpdate={mockUpdate}\n />\n </TamboInteractableProvider>,\n );\n\n expect(screen.getByTestId(\"title\")).toHaveTextContent(\"Test\");\n // These props should be filtered out\n expect(screen.getByTestId(\"has-ready\")).toHaveTextContent(\"no\");\n expect(screen.getByTestId(\"has-update\")).toHaveTextContent(\"no\");\n });\n\n it(\"should pass annotations config to addInteractableComponent\", () => {\n const InteractableComponent = withTamboInteractable(TestComponent, {\n componentName: \"TestComponent\",\n description: \"A test component\",\n annotations: { tamboStreamableHint: false },\n });\n\n render(\n <TamboInteractableProvider>\n <InteractableComponent title=\"Test\" />\n </TamboInteractableProvider>,\n );\n\n expect(mockAddInteractableComponent).toHaveBeenCalledWith(\n expect.objectContaining({\n annotations: { tamboStreamableHint: false },\n }),\n );\n });\n\n it(\"should work without propsSchema\", () => {\n const InteractableComponent = withTamboInteractable(TestComponent, {\n componentName: \"TestComponent\",\n description: \"A test component\",\n });\n\n render(\n <TamboInteractableProvider>\n <InteractableComponent title=\"No Schema\" />\n </TamboInteractableProvider>,\n );\n\n expect(screen.getByTestId(\"title\")).toHaveTextContent(\"No Schema\");\n });\n\n it(\"should render before interactable ID is set\", () => {\n const InteractableComponent = withTamboInteractable(TestComponent, {\n componentName: \"TestComponent\",\n description: \"A test component\",\n });\n\n const { container } = render(\n <TamboInteractableProvider>\n <InteractableComponent title=\"Early Render\" />\n </TamboInteractableProvider>,\n );\n\n // Component should render even before ID is available\n expect(\n container.querySelector('[data-testid=\"title\"]'),\n ).toBeInTheDocument();\n });\n\n it(\"should handle null/undefined values in props\", () => {\n interface NullableProps {\n title: string;\n optional?: string;\n nullable: string | null;\n }\n\n const NullableComponent: React.FC<NullableProps> = ({\n title,\n optional,\n nullable,\n }) => (\n <div>\n <span data-testid=\"title\">{title}</span>\n <span data-testid=\"optional\">{optional ?? \"undefined\"}</span>\n <span data-testid=\"nullable\">{nullable ?? \"null\"}</span>\n </div>\n );\n\n const InteractableComponent = withTamboInteractable(NullableComponent, {\n componentName: \"NullableComponent\",\n description: \"A component with nullable props\",\n });\n\n render(\n <TamboInteractableProvider>\n <InteractableComponent title=\"Test\" nullable={null} />\n </TamboInteractableProvider>,\n );\n\n expect(screen.getByTestId(\"title\")).toHaveTextContent(\"Test\");\n expect(screen.getByTestId(\"optional\")).toHaveTextContent(\"undefined\");\n expect(screen.getByTestId(\"nullable\")).toHaveTextContent(\"null\");\n });\n});\n"]}
1
+ {"version":3,"file":"with-tambo-interactable.test.js","sourceRoot":"","sources":["../../src/hoc/with-tambo-interactable.test.tsx"],"names":[],"mappings":";;;;;AAAA,kDAAiE;AACjE,kDAA0B;AAC1B,+BAA2B;AAC3B,qFAAiF;AACjF,0FAAqF;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AAM,IAAA,eAAO,EAAC,GAAG,EAAE;YACjB,MAAM,CAAC,4BAA4B,CAAC,CAAC,gBAAgB,EAAE,CAAC;QAC1D,CAAC,CAAC,CAAC;QAEH,OAAO,EAAE,CAAC;QAEV,MAAM,CAAC,+BAA+B,CAAC,CAAC,oBAAoB,CAAC,aAAa,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { render, screen, waitFor } from \"@testing-library/react\";\nimport React from \"react\";\nimport { z } from \"zod/v3\";\nimport { useTamboCurrentComponent } from \"../v1/hooks/use-tambo-current-message\";\nimport { TamboInteractableProvider } from \"../providers/tambo-interactable-provider\";\nimport { withTamboInteractable } from \"./with-tambo-interactable\";\n\n// Create a consistent mock implementation\nconst mockAddInteractableComponent = jest.fn(() => \"mock-id-123\");\nconst mockUpdateInteractableComponentProps = jest.fn();\nconst mockGetInteractableComponent = jest.fn(() => null);\nconst mockRemoveInteractableComponent = jest.fn();\nconst mockGetInteractableComponentsByName = jest.fn(() => []);\nconst mockClearAllInteractableComponents = jest.fn();\n\n// Mock the interactable provider\njest.mock(\"../providers/tambo-interactable-provider\", () => ({\n TamboInteractableProvider: ({ children }: { children: React.ReactNode }) => (\n <div data-testid=\"interactable-provider\">{children}</div>\n ),\n useTamboInteractable: () => ({\n addInteractableComponent: mockAddInteractableComponent,\n updateInteractableComponentProps: mockUpdateInteractableComponentProps,\n getInteractableComponent: mockGetInteractableComponent,\n removeInteractableComponent: mockRemoveInteractableComponent,\n getInteractableComponentsByName: mockGetInteractableComponentsByName,\n clearAllInteractableComponents: mockClearAllInteractableComponents,\n interactableComponents: [],\n }),\n}));\n\ndescribe(\"withTamboInteractable\", () => {\n // Simple test component\n interface TestComponentProps {\n title: string;\n count?: number;\n }\n\n const TestComponent: React.FC<TestComponentProps> = ({ title, count }) => (\n <div>\n <h1 data-testid=\"title\">{title}</h1>\n {count !== undefined && <span data-testid=\"count\">{count}</span>}\n </div>\n );\n\n const testSchema = z.object({\n title: z.string(),\n count: z.number().optional(),\n });\n\n beforeEach(() => {\n jest.clearAllMocks();\n // Reset mock implementations\n mockAddInteractableComponent.mockReturnValue(\"mock-id-123\");\n mockGetInteractableComponent.mockReturnValue(null);\n mockGetInteractableComponentsByName.mockReturnValue([]);\n });\n\n it(\"should render the wrapped component with provided props\", () => {\n const InteractableComponent = withTamboInteractable(TestComponent, {\n componentName: \"TestComponent\",\n description: \"A test component\",\n propsSchema: testSchema,\n });\n\n render(\n <TamboInteractableProvider>\n <InteractableComponent title=\"Hello\" count={42} />\n </TamboInteractableProvider>,\n );\n\n expect(screen.getByTestId(\"title\")).toHaveTextContent(\"Hello\");\n expect(screen.getByTestId(\"count\")).toHaveTextContent(\"42\");\n });\n\n it(\"should set displayName correctly\", () => {\n const InteractableComponent = withTamboInteractable(TestComponent, {\n componentName: \"TestComponent\",\n description: \"A test component\",\n });\n\n expect(InteractableComponent.displayName).toBe(\n \"withTamboInteractable(TestComponent)\",\n );\n });\n\n it(\"should handle components without displayName\", () => {\n const AnonymousComponent = () => <div>Anonymous</div>;\n\n const InteractableComponent = withTamboInteractable(AnonymousComponent, {\n componentName: \"AnonymousComponent\",\n description: \"An anonymous component\",\n });\n\n // Anonymous components get their name from the function name\n expect(InteractableComponent.displayName).toBe(\n \"withTamboInteractable(AnonymousComponent)\",\n );\n });\n\n it(\"should provide TamboMessageProvider with interactable metadata\", async () => {\n // Child component that uses the context\n const ContextConsumer = () => {\n const component = useTamboCurrentComponent();\n return (\n <div>\n <span data-testid=\"interactable-id\">{component?.interactableId}</span>\n <span data-testid=\"component-name\">{component?.componentName}</span>\n <span data-testid=\"description\">{component?.description}</span>\n </div>\n );\n };\n\n // Wrap TestComponent to include ContextConsumer\n const TestComponentWithConsumer: React.FC<TestComponentProps> = (props) => (\n <div>\n <TestComponent {...props} />\n <ContextConsumer />\n </div>\n );\n\n const InteractableWithConsumer = withTamboInteractable(\n TestComponentWithConsumer,\n {\n componentName: \"TestComponent\",\n description: \"A test component\",\n propsSchema: testSchema,\n },\n );\n\n render(\n <TamboInteractableProvider>\n <InteractableWithConsumer title=\"Hello\" />\n </TamboInteractableProvider>,\n );\n\n // Wait for the component to register and render\n await waitFor(() => {\n expect(screen.getByTestId(\"interactable-id\")).toHaveTextContent(\n \"mock-id-123\",\n );\n });\n\n expect(screen.getByTestId(\"component-name\")).toHaveTextContent(\n \"TestComponent\",\n );\n expect(screen.getByTestId(\"description\")).toHaveTextContent(\n \"A test component\",\n );\n });\n\n it(\"should create minimal message with correct structure\", async () => {\n // Child component that checks the message structure\n const MessageChecker = () => {\n const component = useTamboCurrentComponent();\n return (\n <div>\n <span data-testid=\"has-component-name\">\n {component?.componentName ? \"yes\" : \"no\"}\n </span>\n <span data-testid=\"has-props\">{component?.props ? \"yes\" : \"no\"}</span>\n <span data-testid=\"has-interactable-id\">\n {component?.interactableId ? \"yes\" : \"no\"}\n </span>\n <span data-testid=\"has-description\">\n {component?.description ? \"yes\" : \"no\"}\n </span>\n </div>\n );\n };\n\n const TestComponentWithChecker: React.FC<TestComponentProps> = (props) => (\n <div>\n <TestComponent {...props} />\n <MessageChecker />\n </div>\n );\n\n const InteractableWithChecker = withTamboInteractable(\n TestComponentWithChecker,\n {\n componentName: \"TestComponent\",\n description: \"A test component\",\n propsSchema: testSchema,\n },\n );\n\n render(\n <TamboInteractableProvider>\n <InteractableWithChecker title=\"Hello\" count={42} />\n </TamboInteractableProvider>,\n );\n\n await waitFor(() => {\n expect(screen.getByTestId(\"has-component-name\")).toHaveTextContent(\"yes\");\n });\n\n expect(screen.getByTestId(\"has-props\")).toHaveTextContent(\"yes\");\n expect(screen.getByTestId(\"has-interactable-id\")).toHaveTextContent(\"yes\");\n expect(screen.getByTestId(\"has-description\")).toHaveTextContent(\"yes\");\n });\n\n it(\"should pass through all component props correctly\", () => {\n const InteractableComponent = withTamboInteractable(TestComponent, {\n componentName: \"TestComponent\",\n description: \"A test component\",\n propsSchema: testSchema,\n });\n\n render(\n <TamboInteractableProvider>\n <InteractableComponent title=\"Test Title\" count={100} />\n </TamboInteractableProvider>,\n );\n\n expect(screen.getByTestId(\"title\")).toHaveTextContent(\"Test Title\");\n expect(screen.getByTestId(\"count\")).toHaveTextContent(\"100\");\n });\n\n it(\"should filter out interactable-specific props from component props\", () => {\n interface ExtendedProps extends TestComponentProps {\n onInteractableReady?: (id: string) => void;\n onPropsUpdate?: (props: Record<string, any>) => void;\n }\n\n const ExtendedComponent: React.FC<ExtendedProps> = ({\n title,\n onInteractableReady,\n onPropsUpdate,\n }) => (\n <div>\n <span data-testid=\"title\">{title}</span>\n <span data-testid=\"has-ready\">\n {onInteractableReady ? \"yes\" : \"no\"}\n </span>\n <span data-testid=\"has-update\">{onPropsUpdate ? \"yes\" : \"no\"}</span>\n </div>\n );\n\n const InteractableComponent = withTamboInteractable(ExtendedComponent, {\n componentName: \"ExtendedComponent\",\n description: \"An extended component\",\n });\n\n const mockReady = jest.fn();\n const mockUpdate = jest.fn();\n\n render(\n <TamboInteractableProvider>\n <InteractableComponent\n title=\"Test\"\n onInteractableReady={mockReady}\n onPropsUpdate={mockUpdate}\n />\n </TamboInteractableProvider>,\n );\n\n expect(screen.getByTestId(\"title\")).toHaveTextContent(\"Test\");\n // These props should be filtered out\n expect(screen.getByTestId(\"has-ready\")).toHaveTextContent(\"no\");\n expect(screen.getByTestId(\"has-update\")).toHaveTextContent(\"no\");\n });\n\n it(\"should pass annotations config to addInteractableComponent\", () => {\n const InteractableComponent = withTamboInteractable(TestComponent, {\n componentName: \"TestComponent\",\n description: \"A test component\",\n annotations: { tamboStreamableHint: false },\n });\n\n render(\n <TamboInteractableProvider>\n <InteractableComponent title=\"Test\" />\n </TamboInteractableProvider>,\n );\n\n expect(mockAddInteractableComponent).toHaveBeenCalledWith(\n expect.objectContaining({\n annotations: { tamboStreamableHint: false },\n }),\n );\n });\n\n it(\"should work without propsSchema\", () => {\n const InteractableComponent = withTamboInteractable(TestComponent, {\n componentName: \"TestComponent\",\n description: \"A test component\",\n });\n\n render(\n <TamboInteractableProvider>\n <InteractableComponent title=\"No Schema\" />\n </TamboInteractableProvider>,\n );\n\n expect(screen.getByTestId(\"title\")).toHaveTextContent(\"No Schema\");\n });\n\n it(\"should render before interactable ID is set\", () => {\n const InteractableComponent = withTamboInteractable(TestComponent, {\n componentName: \"TestComponent\",\n description: \"A test component\",\n });\n\n const { container } = render(\n <TamboInteractableProvider>\n <InteractableComponent title=\"Early Render\" />\n </TamboInteractableProvider>,\n );\n\n // Component should render even before ID is available\n expect(\n container.querySelector('[data-testid=\"title\"]'),\n ).toBeInTheDocument();\n });\n\n it(\"should handle null/undefined values in props\", () => {\n interface NullableProps {\n title: string;\n optional?: string;\n nullable: string | null;\n }\n\n const NullableComponent: React.FC<NullableProps> = ({\n title,\n optional,\n nullable,\n }) => (\n <div>\n <span data-testid=\"title\">{title}</span>\n <span data-testid=\"optional\">{optional ?? \"undefined\"}</span>\n <span data-testid=\"nullable\">{nullable ?? \"null\"}</span>\n </div>\n );\n\n const InteractableComponent = withTamboInteractable(NullableComponent, {\n componentName: \"NullableComponent\",\n description: \"A component with nullable props\",\n });\n\n render(\n <TamboInteractableProvider>\n <InteractableComponent title=\"Test\" nullable={null} />\n </TamboInteractableProvider>,\n );\n\n expect(screen.getByTestId(\"title\")).toHaveTextContent(\"Test\");\n expect(screen.getByTestId(\"optional\")).toHaveTextContent(\"undefined\");\n expect(screen.getByTestId(\"nullable\")).toHaveTextContent(\"null\");\n });\n\n it(\"should call removeInteractableComponent on unmount\", async () => {\n const InteractableComponent = withTamboInteractable(TestComponent, {\n componentName: \"TestComponent\",\n description: \"A test component\",\n propsSchema: testSchema,\n });\n\n const { unmount } = render(\n <TamboInteractableProvider>\n <InteractableComponent title=\"Unmount Test\" />\n </TamboInteractableProvider>,\n );\n\n await waitFor(() => {\n expect(mockAddInteractableComponent).toHaveBeenCalled();\n });\n\n unmount();\n\n expect(mockRemoveInteractableComponent).toHaveBeenCalledWith(\"mock-id-123\");\n });\n});\n"]}
@@ -1,40 +1,6 @@
1
- import type { ElicitRequestFormParams, PrimitiveSchemaDefinition } from "@modelcontextprotocol/sdk/spec.types.js";
2
- import { MCPElicitationHandler } from "./mcp-client";
3
- /**
4
- * Schema type for elicitation request fields
5
- */
6
- export type ElicitationRequestedSchema = ElicitRequestFormParams["requestedSchema"];
7
- /**
8
- * Elicitation request from MCP server
9
- */
10
- export interface TamboElicitationRequest {
11
- message: string;
12
- requestedSchema: ElicitationRequestedSchema;
13
- /** AbortSignal that fires when the server cancels the request (e.g., timeout) */
14
- signal?: AbortSignal;
15
- }
16
- /**
17
- * Re-export PrimitiveSchemaDefinition for consumers that need to work with schema fields
18
- */
19
- export type { PrimitiveSchemaDefinition };
20
- /**
21
- * Elicitation response to be sent back
22
- */
23
- export interface TamboElicitationResponse {
24
- action: "accept" | "decline" | "cancel";
25
- content?: Record<string, unknown>;
26
- [x: string]: unknown;
27
- }
28
- /**
29
- * Elicitation context state - read-only interface for consumers.
30
- * State management is handled internally by useElicitation hook.
31
- */
32
- export interface ElicitationContextState {
33
- /** Current elicitation request, or null if none active */
34
- elicitation: TamboElicitationRequest | null;
35
- /** Function to call when user responds to elicitation (clears state automatically) */
36
- resolveElicitation: ((response: TamboElicitationResponse) => void) | null;
37
- }
1
+ import type { MCPElicitationHandler, TamboElicitationRequest, TamboElicitationResponse } from "@tambo-ai/client";
2
+ export type { ElicitationRequestedSchema, TamboElicitationRequest, TamboElicitationResponse, ElicitationContextState, PrimitiveSchemaDefinition, } from "@tambo-ai/client";
3
+ export { toElicitationRequestedSchema, hasRequestedSchema, } from "@tambo-ai/client";
38
4
  /**
39
5
  * Internal hook that manages elicitation state and creates a default handler.
40
6
  * This bundles all the state management and handler creation for elicitation.
@@ -1 +1 @@
1
- {"version":3,"file":"elicitation.d.ts","sourceRoot":"","sources":["../../src/mcp/elicitation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,uBAAuB,EACvB,yBAAyB,EAC1B,MAAM,yCAAyC,CA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;;;;;;GAMG;AACH,wBAAgB,cAAc;;;oCAId,wBAAwB,KAAK,IAAI;+FAAjC,wBAAwB,KAAK,IAAI;;EAoEhD"}
@@ -1,29 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hasRequestedSchema = exports.toElicitationRequestedSchema = void 0;
3
4
  exports.useElicitation = useElicitation;
4
5
  const react_1 = require("react");
5
- /**
6
- * Narrow the runtime ElicitRequest requestedSchema into the public
7
- * ElicitationRequestedSchema type.
8
- *
9
- * The MCP SDK guarantees that the runtime
10
- * `ElicitRequest["params"]["requestedSchema"]` shape stays aligned with the
11
- * spec-defined `ElicitRequestFormParams["requestedSchema"]`. This helper
12
- * centralizes the cast based on that contract so that if a future SDK version
13
- * ever diverges, we have a single place to tighten the implementation (for
14
- * example with structural validation or normalization).
15
- * @returns requestedSchema as ElicitationRequestedSchema
16
- */
17
- function toElicitationRequestedSchema(value) {
18
- return value;
19
- }
20
- /**
21
- * Type guard for the elicitation form params shape.
22
- * @returns true when params include requestedSchema
23
- */
24
- function hasRequestedSchema(params) {
25
- return "requestedSchema" in params;
26
- }
6
+ const client_1 = require("@tambo-ai/client");
7
+ var client_2 = require("@tambo-ai/client");
8
+ Object.defineProperty(exports, "toElicitationRequestedSchema", { enumerable: true, get: function () { return client_2.toElicitationRequestedSchema; } });
9
+ Object.defineProperty(exports, "hasRequestedSchema", { enumerable: true, get: function () { return client_2.hasRequestedSchema; } });
27
10
  /**
28
11
  * Internal hook that manages elicitation state and creates a default handler.
29
12
  * This bundles all the state management and handler creation for elicitation.
@@ -36,7 +19,7 @@ function useElicitation() {
36
19
  const [resolveElicitation, setResolveElicitation] = (0, react_1.useState)(null);
37
20
  const defaultElicitationHandler = (0, react_1.useCallback)(async (request, extra) => {
38
21
  return await new Promise((resolve, reject) => {
39
- if (!hasRequestedSchema(request.params)) {
22
+ if (!(0, client_1.hasRequestedSchema)(request.params)) {
40
23
  const mode = "mode" in request.params ? String(request.params.mode) : "unknown";
41
24
  reject(new Error(`Unsupported MCP elicitation params: expected requestedSchema (form mode), got mode=${mode}`));
42
25
  return;
@@ -47,7 +30,7 @@ function useElicitation() {
47
30
  // for cross-version compatibility
48
31
  setElicitation({
49
32
  message: request.params.message,
50
- requestedSchema: toElicitationRequestedSchema(request.params.requestedSchema),
33
+ requestedSchema: (0, client_1.toElicitationRequestedSchema)(request.params.requestedSchema),
51
34
  signal: extra.signal,
52
35
  });
53
36
  // If the signal is already aborted, reject immediately
@@ -1 +1 @@
1
- {"version":3,"file":"elicitation.js","sourceRoot":"","sources":["../../src/mcp/elicitation.ts"],"names":[],"mappings":";;AA+FA,wCA0EC;AA9JD,iCAA8C;AAiD9C;;;;;;;;;;;GAWG;AACH,SAAS,4BAA4B,CACnC,KAAgE;IAEhE,OAAO,KAAmC,CAAC;AAC7C,CAAC;AAED;;;GAGG;AACH,SAAS,kBAAkB,CACzB,MAA+B;IAE/B,OAAO,iBAAiB,IAAI,MAAM,CAAC;AACrC,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,cAAc;IAC5B,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GACjC,IAAA,gBAAQ,EAAiC,IAAI,CAAC,CAAC;IACjD,MAAM,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,GAAG,IAAA,gBAAQ,EAE1D,IAAI,CAAC,CAAC;IAER,MAAM,yBAAyB,GAA0B,IAAA,mBAAW,EAClE,KAAK,EACH,OAAsB,EACtB,KAA6D,EACtC,EAAE;QACzB,OAAO,MAAM,IAAI,OAAO,CAAe,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACzD,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;gBACxC,MAAM,IAAI,GACR,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;gBAErE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H,CAAC;IAEF,OAAO;QACL,WAAW;QACX,cAAc;QACd,kBAAkB;QAClB,qBAAqB;QACrB,yBAAyB;KAC1B,CAAC;AACJ,CAAC","sourcesContent":["import type { RequestHandlerExtra } from \"@modelcontextprotocol/sdk/shared/protocol.js\";\nimport type {\n ElicitRequestFormParams,\n PrimitiveSchemaDefinition,\n} from \"@modelcontextprotocol/sdk/spec.types.js\";\nimport type {\n ClientNotification,\n ClientRequest,\n ElicitRequest,\n ElicitResult,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport { useCallback, useState } from \"react\";\nimport { MCPElicitationHandler } from \"./mcp-client\";\n\n/**\n * Schema type for elicitation request fields\n */\nexport type ElicitationRequestedSchema =\n ElicitRequestFormParams[\"requestedSchema\"];\n\n/**\n * Elicitation request from MCP server\n */\nexport interface TamboElicitationRequest {\n message: string;\n requestedSchema: ElicitationRequestedSchema;\n /** AbortSignal that fires when the server cancels the request (e.g., timeout) */\n signal?: AbortSignal;\n}\n\n/**\n * Re-export PrimitiveSchemaDefinition for consumers that need to work with schema fields\n */\nexport type { PrimitiveSchemaDefinition };\n\ntype ElicitRequestParamsWithRequestedSchema = Extract<\n ElicitRequest[\"params\"],\n { requestedSchema: unknown }\n>;\n\n/**\n * Elicitation response to be sent back\n */\nexport interface TamboElicitationResponse {\n action: \"accept\" | \"decline\" | \"cancel\";\n content?: Record<string, unknown>;\n [x: string]: unknown;\n}\n\n/**\n * Elicitation context state - read-only interface for consumers.\n * State management is handled internally by useElicitation hook.\n */\nexport interface ElicitationContextState {\n /** Current elicitation request, or null if none active */\n elicitation: TamboElicitationRequest | null;\n /** Function to call when user responds to elicitation (clears state automatically) */\n resolveElicitation: ((response: TamboElicitationResponse) => void) | null;\n}\n\n/**\n * Narrow the runtime ElicitRequest requestedSchema into the public\n * ElicitationRequestedSchema type.\n *\n * The MCP SDK guarantees that the runtime\n * `ElicitRequest[\"params\"][\"requestedSchema\"]` shape stays aligned with the\n * spec-defined `ElicitRequestFormParams[\"requestedSchema\"]`. This helper\n * centralizes the cast based on that contract so that if a future SDK version\n * ever diverges, we have a single place to tighten the implementation (for\n * example with structural validation or normalization).\n * @returns requestedSchema as ElicitationRequestedSchema\n */\nfunction toElicitationRequestedSchema(\n value: ElicitRequestParamsWithRequestedSchema[\"requestedSchema\"],\n): ElicitationRequestedSchema {\n return value as ElicitationRequestedSchema;\n}\n\n/**\n * Type guard for the elicitation form params shape.\n * @returns true when params include requestedSchema\n */\nfunction hasRequestedSchema(\n params: ElicitRequest[\"params\"],\n): params is ElicitRequestParamsWithRequestedSchema {\n return \"requestedSchema\" in params;\n}\n\n/**\n * Internal hook that manages elicitation state and creates a default handler.\n * This bundles all the state management and handler creation for elicitation.\n *\n * Do not export this hook from this package. It is only intended to be used internally by the TamboMcpProvider.\n * @returns Elicitation state and default handler\n */\nexport function useElicitation() {\n const [elicitation, setElicitation] =\n useState<TamboElicitationRequest | null>(null);\n const [resolveElicitation, setResolveElicitation] = useState<\n ((response: TamboElicitationResponse) => void) | null\n >(null);\n\n const defaultElicitationHandler: MCPElicitationHandler = useCallback(\n async (\n request: ElicitRequest,\n extra: RequestHandlerExtra<ClientRequest, ClientNotification>,\n ): Promise<ElicitResult> => {\n return await new Promise<ElicitResult>((resolve, reject) => {\n if (!hasRequestedSchema(request.params)) {\n const mode =\n \"mode\" in request.params ? String(request.params.mode) : \"unknown\";\n\n reject(\n new Error(\n `Unsupported MCP elicitation params: expected requestedSchema (form mode), got mode=${mode}`,\n ),\n );\n return;\n }\n\n // Set the elicitation request to show the UI\n // Cast is needed because ElicitRequest uses Zod-inferred types (from the\n // user's installed zod version), while we use pure TypeScript spec types\n // for cross-version compatibility\n setElicitation({\n message: request.params.message,\n requestedSchema: toElicitationRequestedSchema(\n request.params.requestedSchema,\n ),\n signal: extra.signal,\n });\n\n // If the signal is already aborted, reject immediately\n if (extra.signal.aborted) {\n setElicitation(null);\n reject(new Error(\"Request aborted\"));\n return;\n }\n\n // Listen for abort signal to clean up\n const handleAbort = () => {\n setElicitation(null);\n setResolveElicitation(null);\n reject(new Error(\"Request aborted\"));\n };\n\n extra.signal.addEventListener(\"abort\", handleAbort, { once: true });\n\n // Store the resolve function so we can call it when the user responds\n setResolveElicitation(() => (response: ElicitResult) => {\n // Remove abort listener since we're resolving normally\n extra.signal.removeEventListener(\"abort\", handleAbort);\n // Clear state now that user has responded\n setElicitation(null);\n setResolveElicitation(null);\n resolve(response);\n });\n });\n },\n [],\n );\n\n return {\n elicitation,\n setElicitation,\n resolveElicitation,\n setResolveElicitation,\n defaultElicitationHandler,\n };\n}\n"]}
1
+ {"version":3,"file":"elicitation.js","sourceRoot":"","sources":["../../src/mcp/elicitation.ts"],"names":[],"mappings":";;;AAuCA,wCAwEC;AAvGD,iCAA8C;AAM9C,6CAG0B;AAU1B,2CAG0B;AAFxB,sHAAA,4BAA4B,OAAA;AAC5B,4GAAA,kBAAkB,OAAA;AAGpB;;;;;;GAMG;AACH,SAAgB,cAAc;IAC5B,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GACjC,IAAA,gBAAQ,EAAiC,IAAI,CAAC,CAAC;IACjD,MAAM,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,GAAG,IAAA,gBAAQ,EAE1D,IAAI,CAAC,CAAC;IAER,MAAM,yBAAyB,GAA0B,IAAA,mBAAW,EAClE,KAAK,EACH,OAAsB,EACtB,KAA6D,EACtC,EAAE;QACzB,OAAO,MAAM,IAAI,OAAO,CAAe,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACzD,IAAI,CAAC,IAAA,2BAAS,EAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC/B,MAAM,IAAI,GACR,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;gBAErE,MAAM,CACJ,IAAI,KAAK,CACP,sFAAsF,IAAI,EAAE,CAC7F,CACF,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ClB,qBAAqB;QACrB,yBAAyB;KAC1B,CAAC;AACJ,CAAC","sourcesContent":["// React-specific hook (not in client package)\nimport type { RequestHandlerExtra } from \"@modelcontextprotocol/sdk/shared/protocol.js\";\nimport type {\n ClientNotification,\n ClientRequest,\n ElicitRequest,\n ElicitResult,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport { useCallback, useState } from \"react\";\nimport type {\n MCPElicitationHandler,\n TamboElicitationRequest,\n TamboElicitationResponse,\n} from \"@tambo-ai/client\";\nimport {\n toElicitationRequestedSchema as toSchema,\n hasRequestedSchema as hasSchema,\n} from \"@tambo-ai/client\";\n\n// Re-export types and functions from @tambo-ai/client for barrel consumers\nexport type {\n ElicitationRequestedSchema,\n TamboElicitationRequest,\n TamboElicitationResponse,\n ElicitationContextState,\n PrimitiveSchemaDefinition,\n} from \"@tambo-ai/client\";\nexport {\n toElicitationRequestedSchema,\n hasRequestedSchema,\n} from \"@tambo-ai/client\";\n\n/**\n * Internal hook that manages elicitation state and creates a default handler.\n * This bundles all the state management and handler creation for elicitation.\n *\n * Do not export this hook from this package. It is only intended to be used internally by the TamboMcpProvider.\n * @returns Elicitation state and default handler\n */\nexport function useElicitation() {\n const [elicitation, setElicitation] =\n useState<TamboElicitationRequest | null>(null);\n const [resolveElicitation, setResolveElicitation] = useState<\n ((response: TamboElicitationResponse) => void) | null\n >(null);\n\n const defaultElicitationHandler: MCPElicitationHandler = useCallback(\n async (\n request: ElicitRequest,\n extra: RequestHandlerExtra<ClientRequest, ClientNotification>,\n ): Promise<ElicitResult> => {\n return await new Promise<ElicitResult>((resolve, reject) => {\n if (!hasSchema(request.params)) {\n const mode =\n \"mode\" in request.params ? String(request.params.mode) : \"unknown\";\n\n reject(\n new Error(\n `Unsupported MCP elicitation params: expected requestedSchema (form mode), got mode=${mode}`,\n ),\n );\n return;\n }\n\n // Set the elicitation request to show the UI\n // Cast is needed because ElicitRequest uses Zod-inferred types (from the\n // user's installed zod version), while we use pure TypeScript spec types\n // for cross-version compatibility\n setElicitation({\n message: request.params.message,\n requestedSchema: toSchema(request.params.requestedSchema),\n signal: extra.signal,\n });\n\n // If the signal is already aborted, reject immediately\n if (extra.signal.aborted) {\n setElicitation(null);\n reject(new Error(\"Request aborted\"));\n return;\n }\n\n // Listen for abort signal to clean up\n const handleAbort = () => {\n setElicitation(null);\n setResolveElicitation(null);\n reject(new Error(\"Request aborted\"));\n };\n\n extra.signal.addEventListener(\"abort\", handleAbort, { once: true });\n\n // Store the resolve function so we can call it when the user responds\n setResolveElicitation(() => (response: ElicitResult) => {\n // Remove abort listener since we're resolving normally\n extra.signal.removeEventListener(\"abort\", handleAbort);\n // Clear state now that user has responded\n setElicitation(null);\n setResolveElicitation(null);\n resolve(response);\n });\n });\n },\n [],\n );\n\n return {\n elicitation,\n setElicitation,\n resolveElicitation,\n setResolveElicitation,\n defaultElicitationHandler,\n };\n}\n"]}
@@ -6,11 +6,11 @@
6
6
  * you'll need to install `zod` and `zod-to-json-schema` as optional peer dependencies.
7
7
  * See the React SDK README for the recommended version ranges.
8
8
  */
9
- export { MCPTransport } from "./mcp-client";
10
- export type { MCPElicitationHandler, MCPHandlers, MCPSamplingHandler, } from "./mcp-client";
11
- export type { ElicitationRequestedSchema, PrimitiveSchemaDefinition, TamboElicitationRequest, TamboElicitationResponse, } from "./elicitation";
9
+ export { MCPTransport } from "@tambo-ai/client";
10
+ export type { MCPElicitationHandler, MCPHandlers, MCPSamplingHandler, } from "@tambo-ai/client";
11
+ export type { ElicitationRequestedSchema, PrimitiveSchemaDefinition, TamboElicitationRequest, TamboElicitationResponse, } from "@tambo-ai/client";
12
12
  export { useTamboMcpPrompt, useTamboMcpPromptList, useTamboMcpResource, useTamboMcpResourceList, isMcpResourceEntry, } from "./mcp-hooks";
13
13
  export type { ListPromptEntry, ListPromptItem, ListResourceEntry, ListResourceItem, } from "./mcp-hooks";
14
14
  export { TamboMcpProvider, useTamboMcpElicitation, useTamboMcpServers, useTamboElicitationContext, type ConnectedMcpServer, type FailedMcpServer, type McpServer, type ProviderMCPHandlers, } from "./tambo-mcp-provider";
15
- export type { McpServerInfo, NormalizedMcpServerInfo, } from "../model/mcp-server-info";
15
+ export type { McpServerInfo, NormalizedMcpServerInfo } from "@tambo-ai/client";
16
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,YAAY,EACV,qBAAqB,EACrB,WAAW,EACX,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,0BAA0B,EAC1B,yBAAyB,EACzB,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,kBAAkB,EAClB,0BAA0B,EAC1B,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,mBAAmB,GACzB,MAAM,sBAAsB,CAAC;AAG9B,YAAY,EACV,aAAa,EACb,uBAAuB,GACxB,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,YAAY,EACV,qBAAqB,EACrB,WAAW,EACX,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACV,0BAA0B,EAC1B,yBAAyB,EACzB,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,kBAAkB,EAClB,0BAA0B,EAC1B,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,mBAAmB,GACzB,MAAM,sBAAsB,CAAC;AAG9B,YAAY,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC"}
package/dist/mcp/index.js CHANGED
@@ -9,8 +9,8 @@ exports.useTamboElicitationContext = exports.useTamboMcpServers = exports.useTam
9
9
  * you'll need to install `zod` and `zod-to-json-schema` as optional peer dependencies.
10
10
  * See the React SDK README for the recommended version ranges.
11
11
  */
12
- var mcp_client_1 = require("./mcp-client");
13
- Object.defineProperty(exports, "MCPTransport", { enumerable: true, get: function () { return mcp_client_1.MCPTransport; } });
12
+ var client_1 = require("@tambo-ai/client");
13
+ Object.defineProperty(exports, "MCPTransport", { enumerable: true, get: function () { return client_1.MCPTransport; } });
14
14
  var mcp_hooks_1 = require("./mcp-hooks");
15
15
  Object.defineProperty(exports, "useTamboMcpPrompt", { enumerable: true, get: function () { return mcp_hooks_1.useTamboMcpPrompt; } });
16
16
  Object.defineProperty(exports, "useTamboMcpPromptList", { enumerable: true, get: function () { return mcp_hooks_1.useTamboMcpPromptList; } });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;GAOG;AACH,2CAA4C;AAAnC,0GAAA,YAAY,OAAA;AAYrB,yCAMqB;AALnB,8GAAA,iBAAiB,OAAA;AACjB,kHAAA,qBAAqB,OAAA;AACrB,gHAAA,mBAAmB,OAAA;AACnB,oHAAA,uBAAuB,OAAA;AACvB,+GAAA,kBAAkB,OAAA;AAQpB,2DAS8B;AAR5B,sHAAA,gBAAgB,OAAA;AAChB,4HAAA,sBAAsB,OAAA;AACtB,wHAAA,kBAAkB,OAAA;AAClB,gIAAA,0BAA0B,OAAA","sourcesContent":["/**\n * Entry point for MCP (Model Context Protocol) support in the React SDK.\n *\n * Note: The `@modelcontextprotocol/sdk` is included automatically with `@tambo-ai/react`.\n * If you use features that require schema validation (like component props schemas),\n * you'll need to install `zod` and `zod-to-json-schema` as optional peer dependencies.\n * See the React SDK README for the recommended version ranges.\n */\nexport { MCPTransport } from \"./mcp-client\";\nexport type {\n MCPElicitationHandler,\n MCPHandlers,\n MCPSamplingHandler,\n} from \"./mcp-client\";\nexport type {\n ElicitationRequestedSchema,\n PrimitiveSchemaDefinition,\n TamboElicitationRequest,\n TamboElicitationResponse,\n} from \"./elicitation\";\nexport {\n useTamboMcpPrompt,\n useTamboMcpPromptList,\n useTamboMcpResource,\n useTamboMcpResourceList,\n isMcpResourceEntry,\n} from \"./mcp-hooks\";\nexport type {\n ListPromptEntry,\n ListPromptItem,\n ListResourceEntry,\n ListResourceItem,\n} from \"./mcp-hooks\";\nexport {\n TamboMcpProvider,\n useTamboMcpElicitation,\n useTamboMcpServers,\n useTamboElicitationContext,\n type ConnectedMcpServer,\n type FailedMcpServer,\n type McpServer,\n type ProviderMCPHandlers,\n} from \"./tambo-mcp-provider\";\n\n// Public MCP server metadata types\nexport type {\n McpServerInfo,\n NormalizedMcpServerInfo,\n} from \"../model/mcp-server-info\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;GAOG;AACH,2CAAgD;AAAvC,sGAAA,YAAY,OAAA;AAYrB,yCAMqB;AALnB,8GAAA,iBAAiB,OAAA;AACjB,kHAAA,qBAAqB,OAAA;AACrB,gHAAA,mBAAmB,OAAA;AACnB,oHAAA,uBAAuB,OAAA;AACvB,+GAAA,kBAAkB,OAAA;AAQpB,2DAS8B;AAR5B,sHAAA,gBAAgB,OAAA;AAChB,4HAAA,sBAAsB,OAAA;AACtB,wHAAA,kBAAkB,OAAA;AAClB,gIAAA,0BAA0B,OAAA","sourcesContent":["/**\n * Entry point for MCP (Model Context Protocol) support in the React SDK.\n *\n * Note: The `@modelcontextprotocol/sdk` is included automatically with `@tambo-ai/react`.\n * If you use features that require schema validation (like component props schemas),\n * you'll need to install `zod` and `zod-to-json-schema` as optional peer dependencies.\n * See the React SDK README for the recommended version ranges.\n */\nexport { MCPTransport } from \"@tambo-ai/client\";\nexport type {\n MCPElicitationHandler,\n MCPHandlers,\n MCPSamplingHandler,\n} from \"@tambo-ai/client\";\nexport type {\n ElicitationRequestedSchema,\n PrimitiveSchemaDefinition,\n TamboElicitationRequest,\n TamboElicitationResponse,\n} from \"@tambo-ai/client\";\nexport {\n useTamboMcpPrompt,\n useTamboMcpPromptList,\n useTamboMcpResource,\n useTamboMcpResourceList,\n isMcpResourceEntry,\n} from \"./mcp-hooks\";\nexport type {\n ListPromptEntry,\n ListPromptItem,\n ListResourceEntry,\n ListResourceItem,\n} from \"./mcp-hooks\";\nexport {\n TamboMcpProvider,\n useTamboMcpElicitation,\n useTamboMcpServers,\n useTamboElicitationContext,\n type ConnectedMcpServer,\n type FailedMcpServer,\n type McpServer,\n type ProviderMCPHandlers,\n} from \"./tambo-mcp-provider\";\n\n// Public MCP server metadata types\nexport type { McpServerInfo, NormalizedMcpServerInfo } from \"@tambo-ai/client\";\n"]}