@tambo-ai/react 0.68.0 → 0.69.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 (326) hide show
  1. package/README.md +1 -1
  2. package/dist/context-helpers/context-helpers.test.js +16 -4
  3. package/dist/context-helpers/context-helpers.test.js.map +1 -1
  4. package/dist/context-helpers/current-interactables-context-helper.d.ts +2 -2
  5. package/dist/context-helpers/current-interactables-context-helper.d.ts.map +1 -1
  6. package/dist/context-helpers/current-interactables-context-helper.js +31 -15
  7. package/dist/context-helpers/current-interactables-context-helper.js.map +1 -1
  8. package/dist/context-helpers/registry.d.ts +2 -2
  9. package/dist/context-helpers/registry.d.ts.map +1 -1
  10. package/dist/context-helpers/registry.js.map +1 -1
  11. package/dist/context-helpers/types.d.ts +2 -2
  12. package/dist/context-helpers/types.d.ts.map +1 -1
  13. package/dist/context-helpers/types.js.map +1 -1
  14. package/dist/hooks/use-message-images.test.js +174 -37
  15. package/dist/hooks/use-message-images.test.js.map +1 -1
  16. package/dist/hooks/use-tambo-voice.d.ts +1 -1
  17. package/dist/hooks/use-tambo-voice.js +1 -1
  18. package/dist/hooks/use-tambo-voice.js.map +1 -1
  19. package/dist/hooks/use-tambo-voice.test.d.ts +2 -0
  20. package/dist/hooks/use-tambo-voice.test.d.ts.map +1 -0
  21. package/dist/hooks/use-tambo-voice.test.js +239 -0
  22. package/dist/hooks/use-tambo-voice.test.js.map +1 -0
  23. package/dist/index.d.ts +2 -2
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js.map +1 -1
  26. package/dist/mcp/elicitation.d.ts.map +1 -1
  27. package/dist/mcp/elicitation.js +12 -0
  28. package/dist/mcp/elicitation.js.map +1 -1
  29. package/dist/mcp/elicitation.test.js +8 -1
  30. package/dist/mcp/elicitation.test.js.map +1 -1
  31. package/dist/mcp/mcp-client.d.ts +6 -10
  32. package/dist/mcp/mcp-client.d.ts.map +1 -1
  33. package/dist/mcp/mcp-client.js.map +1 -1
  34. package/dist/mcp/mcp-hooks.d.ts +12 -60
  35. package/dist/mcp/mcp-hooks.d.ts.map +1 -1
  36. package/dist/mcp/mcp-hooks.js +90 -10
  37. package/dist/mcp/mcp-hooks.js.map +1 -1
  38. package/dist/mcp/mcp-hooks.test.js +423 -0
  39. package/dist/mcp/mcp-hooks.test.js.map +1 -1
  40. package/dist/mcp/tambo-mcp-provider.d.ts.map +1 -1
  41. package/dist/mcp/tambo-mcp-provider.js +3 -0
  42. package/dist/mcp/tambo-mcp-provider.js.map +1 -1
  43. package/dist/mcp/tambo-mcp-provider.test.js +37 -0
  44. package/dist/mcp/tambo-mcp-provider.test.js.map +1 -1
  45. package/dist/model/component-metadata.d.ts +53 -20
  46. package/dist/model/component-metadata.d.ts.map +1 -1
  47. package/dist/model/component-metadata.js.map +1 -1
  48. package/dist/model/tambo-interactable.d.ts +6 -0
  49. package/dist/model/tambo-interactable.d.ts.map +1 -1
  50. package/dist/model/tambo-interactable.js.map +1 -1
  51. package/dist/providers/index.d.ts +1 -1
  52. package/dist/providers/index.d.ts.map +1 -1
  53. package/dist/providers/index.js.map +1 -1
  54. package/dist/providers/tambo-client-provider.d.ts +8 -0
  55. package/dist/providers/tambo-client-provider.d.ts.map +1 -1
  56. package/dist/providers/tambo-client-provider.js +10 -11
  57. package/dist/providers/tambo-client-provider.js.map +1 -1
  58. package/dist/providers/tambo-client-provider.test.d.ts +2 -0
  59. package/dist/providers/tambo-client-provider.test.d.ts.map +1 -0
  60. package/dist/providers/tambo-client-provider.test.js +208 -0
  61. package/dist/providers/tambo-client-provider.test.js.map +1 -0
  62. package/dist/providers/tambo-context-attachment-provider.d.ts +34 -92
  63. package/dist/providers/tambo-context-attachment-provider.d.ts.map +1 -1
  64. package/dist/providers/tambo-context-attachment-provider.js +62 -105
  65. package/dist/providers/tambo-context-attachment-provider.js.map +1 -1
  66. package/dist/providers/tambo-context-attachment-provider.test.js +229 -463
  67. package/dist/providers/tambo-context-attachment-provider.test.js.map +1 -1
  68. package/dist/providers/tambo-interactable-provider.d.ts +2 -0
  69. package/dist/providers/tambo-interactable-provider.d.ts.map +1 -1
  70. package/dist/providers/tambo-interactable-provider.js +29 -4
  71. package/dist/providers/tambo-interactable-provider.js.map +1 -1
  72. package/dist/providers/tambo-interactable-provider.test.js +1 -1
  73. package/dist/providers/tambo-interactable-provider.test.js.map +1 -1
  74. package/dist/providers/tambo-interactables-additional-context.test.js +2 -5
  75. package/dist/providers/tambo-interactables-additional-context.test.js.map +1 -1
  76. package/dist/providers/tambo-provider.d.ts +2 -3
  77. package/dist/providers/tambo-provider.d.ts.map +1 -1
  78. package/dist/providers/tambo-provider.js +5 -6
  79. package/dist/providers/tambo-provider.js.map +1 -1
  80. package/dist/providers/tambo-registry-provider.test.js +16 -0
  81. package/dist/providers/tambo-registry-provider.test.js.map +1 -1
  82. package/dist/providers/tambo-registry-schema-compat.test.js +31 -0
  83. package/dist/providers/tambo-registry-schema-compat.test.js.map +1 -1
  84. package/dist/providers/tambo-thread-input-provider.d.ts +1 -1
  85. package/dist/providers/tambo-thread-input-provider.d.ts.map +1 -1
  86. package/dist/providers/tambo-thread-input-provider.js +5 -1
  87. package/dist/providers/tambo-thread-input-provider.js.map +1 -1
  88. package/dist/providers/tambo-thread-provider-initial-messages.test.js +84 -2
  89. package/dist/providers/tambo-thread-provider-initial-messages.test.js.map +1 -1
  90. package/dist/providers/tambo-thread-provider.d.ts.map +1 -1
  91. package/dist/providers/tambo-thread-provider.js +56 -43
  92. package/dist/providers/tambo-thread-provider.js.map +1 -1
  93. package/dist/providers/tambo-thread-provider.test.js +456 -262
  94. package/dist/providers/tambo-thread-provider.test.js.map +1 -1
  95. package/dist/schema/json-schema.js +29 -29
  96. package/dist/schema/json-schema.js.map +1 -1
  97. package/dist/schema/schema.test.js +237 -0
  98. package/dist/schema/schema.test.js.map +1 -1
  99. package/dist/schema/standard-schema.d.ts +1 -0
  100. package/dist/schema/standard-schema.d.ts.map +1 -1
  101. package/dist/schema/standard-schema.js +18 -13
  102. package/dist/schema/standard-schema.js.map +1 -1
  103. package/dist/schema/standard-schema.test.d.ts +2 -0
  104. package/dist/schema/standard-schema.test.d.ts.map +1 -0
  105. package/dist/schema/standard-schema.test.js +165 -0
  106. package/dist/schema/standard-schema.test.js.map +1 -0
  107. package/dist/schema/validate.test.js +149 -0
  108. package/dist/schema/validate.test.js.map +1 -1
  109. package/dist/schema/zod.d.ts +7 -4
  110. package/dist/schema/zod.d.ts.map +1 -1
  111. package/dist/schema/zod.js +65 -22
  112. package/dist/schema/zod.js.map +1 -1
  113. package/dist/schema/zod.test.js +112 -0
  114. package/dist/schema/zod.test.js.map +1 -1
  115. package/dist/testing/tools.d.ts +4 -1
  116. package/dist/testing/tools.d.ts.map +1 -1
  117. package/dist/testing/tools.js +6 -1
  118. package/dist/testing/tools.js.map +1 -1
  119. package/dist/util/generate-component.d.ts.map +1 -1
  120. package/dist/util/generate-component.js +18 -3
  121. package/dist/util/generate-component.js.map +1 -1
  122. package/dist/util/generate-component.test.d.ts +2 -0
  123. package/dist/util/generate-component.test.d.ts.map +1 -0
  124. package/dist/util/generate-component.test.js +340 -0
  125. package/dist/util/generate-component.test.js.map +1 -0
  126. package/dist/util/is-promise.d.ts +9 -0
  127. package/dist/util/is-promise.d.ts.map +1 -0
  128. package/dist/util/is-promise.js +20 -0
  129. package/dist/util/is-promise.js.map +1 -0
  130. package/dist/util/is-promise.test.d.ts +2 -0
  131. package/dist/util/is-promise.test.d.ts.map +1 -0
  132. package/dist/util/is-promise.test.js +48 -0
  133. package/dist/util/is-promise.test.js.map +1 -0
  134. package/dist/util/query-utils.test.d.ts +2 -0
  135. package/dist/util/query-utils.test.d.ts.map +1 -0
  136. package/dist/util/query-utils.test.js +382 -0
  137. package/dist/util/query-utils.test.js.map +1 -0
  138. package/dist/util/registry-validators.d.ts.map +1 -1
  139. package/dist/util/registry-validators.js +7 -0
  140. package/dist/util/registry-validators.js.map +1 -1
  141. package/dist/util/registry-validators.test.js +57 -0
  142. package/dist/util/registry-validators.test.js.map +1 -1
  143. package/dist/util/registry.d.ts.map +1 -1
  144. package/dist/util/registry.js +9 -0
  145. package/dist/util/registry.js.map +1 -1
  146. package/dist/util/registry.test.js +323 -1
  147. package/dist/util/registry.test.js.map +1 -1
  148. package/dist/util/resource-validators.test.d.ts +2 -0
  149. package/dist/util/resource-validators.test.d.ts.map +1 -0
  150. package/dist/util/resource-validators.test.js +90 -0
  151. package/dist/util/resource-validators.test.js.map +1 -0
  152. package/dist/util/tool-caller.d.ts +2 -2
  153. package/dist/util/tool-caller.d.ts.map +1 -1
  154. package/dist/util/tool-caller.js +8 -8
  155. package/dist/util/tool-caller.js.map +1 -1
  156. package/dist/util/validate-component-name.test.d.ts +2 -0
  157. package/dist/util/validate-component-name.test.d.ts.map +1 -0
  158. package/dist/util/validate-component-name.test.js +35 -0
  159. package/dist/util/validate-component-name.test.js.map +1 -0
  160. package/esm/context-helpers/context-helpers.test.js +16 -4
  161. package/esm/context-helpers/context-helpers.test.js.map +1 -1
  162. package/esm/context-helpers/current-interactables-context-helper.d.ts +2 -2
  163. package/esm/context-helpers/current-interactables-context-helper.d.ts.map +1 -1
  164. package/esm/context-helpers/current-interactables-context-helper.js +31 -15
  165. package/esm/context-helpers/current-interactables-context-helper.js.map +1 -1
  166. package/esm/context-helpers/registry.d.ts +2 -2
  167. package/esm/context-helpers/registry.d.ts.map +1 -1
  168. package/esm/context-helpers/registry.js.map +1 -1
  169. package/esm/context-helpers/types.d.ts +2 -2
  170. package/esm/context-helpers/types.d.ts.map +1 -1
  171. package/esm/context-helpers/types.js.map +1 -1
  172. package/esm/hooks/use-message-images.test.js +174 -37
  173. package/esm/hooks/use-message-images.test.js.map +1 -1
  174. package/esm/hooks/use-tambo-voice.d.ts +1 -1
  175. package/esm/hooks/use-tambo-voice.js +1 -1
  176. package/esm/hooks/use-tambo-voice.js.map +1 -1
  177. package/esm/hooks/use-tambo-voice.test.d.ts +2 -0
  178. package/esm/hooks/use-tambo-voice.test.d.ts.map +1 -0
  179. package/esm/hooks/use-tambo-voice.test.js +234 -0
  180. package/esm/hooks/use-tambo-voice.test.js.map +1 -0
  181. package/esm/index.d.ts +2 -2
  182. package/esm/index.d.ts.map +1 -1
  183. package/esm/index.js.map +1 -1
  184. package/esm/mcp/elicitation.d.ts.map +1 -1
  185. package/esm/mcp/elicitation.js +12 -0
  186. package/esm/mcp/elicitation.js.map +1 -1
  187. package/esm/mcp/elicitation.test.js +8 -1
  188. package/esm/mcp/elicitation.test.js.map +1 -1
  189. package/esm/mcp/mcp-client.d.ts +6 -10
  190. package/esm/mcp/mcp-client.d.ts.map +1 -1
  191. package/esm/mcp/mcp-client.js.map +1 -1
  192. package/esm/mcp/mcp-hooks.d.ts +12 -60
  193. package/esm/mcp/mcp-hooks.d.ts.map +1 -1
  194. package/esm/mcp/mcp-hooks.js +57 -10
  195. package/esm/mcp/mcp-hooks.js.map +1 -1
  196. package/esm/mcp/mcp-hooks.test.js +423 -0
  197. package/esm/mcp/mcp-hooks.test.js.map +1 -1
  198. package/esm/mcp/tambo-mcp-provider.d.ts.map +1 -1
  199. package/esm/mcp/tambo-mcp-provider.js +3 -0
  200. package/esm/mcp/tambo-mcp-provider.js.map +1 -1
  201. package/esm/mcp/tambo-mcp-provider.test.js +37 -0
  202. package/esm/mcp/tambo-mcp-provider.test.js.map +1 -1
  203. package/esm/model/component-metadata.d.ts +53 -20
  204. package/esm/model/component-metadata.d.ts.map +1 -1
  205. package/esm/model/component-metadata.js.map +1 -1
  206. package/esm/model/tambo-interactable.d.ts +6 -0
  207. package/esm/model/tambo-interactable.d.ts.map +1 -1
  208. package/esm/model/tambo-interactable.js.map +1 -1
  209. package/esm/providers/index.d.ts +1 -1
  210. package/esm/providers/index.d.ts.map +1 -1
  211. package/esm/providers/index.js.map +1 -1
  212. package/esm/providers/tambo-client-provider.d.ts +8 -0
  213. package/esm/providers/tambo-client-provider.d.ts.map +1 -1
  214. package/esm/providers/tambo-client-provider.js +11 -12
  215. package/esm/providers/tambo-client-provider.js.map +1 -1
  216. package/esm/providers/tambo-client-provider.test.d.ts +2 -0
  217. package/esm/providers/tambo-client-provider.test.d.ts.map +1 -0
  218. package/esm/providers/tambo-client-provider.test.js +203 -0
  219. package/esm/providers/tambo-client-provider.test.js.map +1 -0
  220. package/esm/providers/tambo-context-attachment-provider.d.ts +34 -92
  221. package/esm/providers/tambo-context-attachment-provider.d.ts.map +1 -1
  222. package/esm/providers/tambo-context-attachment-provider.js +63 -106
  223. package/esm/providers/tambo-context-attachment-provider.js.map +1 -1
  224. package/esm/providers/tambo-context-attachment-provider.test.js +230 -464
  225. package/esm/providers/tambo-context-attachment-provider.test.js.map +1 -1
  226. package/esm/providers/tambo-interactable-provider.d.ts +2 -0
  227. package/esm/providers/tambo-interactable-provider.d.ts.map +1 -1
  228. package/esm/providers/tambo-interactable-provider.js +29 -4
  229. package/esm/providers/tambo-interactable-provider.js.map +1 -1
  230. package/esm/providers/tambo-interactable-provider.test.js +1 -1
  231. package/esm/providers/tambo-interactable-provider.test.js.map +1 -1
  232. package/esm/providers/tambo-interactables-additional-context.test.js +2 -5
  233. package/esm/providers/tambo-interactables-additional-context.test.js.map +1 -1
  234. package/esm/providers/tambo-provider.d.ts +2 -3
  235. package/esm/providers/tambo-provider.d.ts.map +1 -1
  236. package/esm/providers/tambo-provider.js +5 -6
  237. package/esm/providers/tambo-provider.js.map +1 -1
  238. package/esm/providers/tambo-registry-provider.test.js +16 -0
  239. package/esm/providers/tambo-registry-provider.test.js.map +1 -1
  240. package/esm/providers/tambo-registry-schema-compat.test.js +31 -0
  241. package/esm/providers/tambo-registry-schema-compat.test.js.map +1 -1
  242. package/esm/providers/tambo-thread-input-provider.d.ts +1 -1
  243. package/esm/providers/tambo-thread-input-provider.d.ts.map +1 -1
  244. package/esm/providers/tambo-thread-input-provider.js +5 -1
  245. package/esm/providers/tambo-thread-input-provider.js.map +1 -1
  246. package/esm/providers/tambo-thread-provider-initial-messages.test.js +84 -2
  247. package/esm/providers/tambo-thread-provider-initial-messages.test.js.map +1 -1
  248. package/esm/providers/tambo-thread-provider.d.ts.map +1 -1
  249. package/esm/providers/tambo-thread-provider.js +56 -43
  250. package/esm/providers/tambo-thread-provider.js.map +1 -1
  251. package/esm/providers/tambo-thread-provider.test.js +456 -262
  252. package/esm/providers/tambo-thread-provider.test.js.map +1 -1
  253. package/esm/schema/json-schema.js +1 -1
  254. package/esm/schema/json-schema.js.map +1 -1
  255. package/esm/schema/schema.test.js +238 -1
  256. package/esm/schema/schema.test.js.map +1 -1
  257. package/esm/schema/standard-schema.d.ts +1 -0
  258. package/esm/schema/standard-schema.d.ts.map +1 -1
  259. package/esm/schema/standard-schema.js +18 -13
  260. package/esm/schema/standard-schema.js.map +1 -1
  261. package/esm/schema/standard-schema.test.d.ts +2 -0
  262. package/esm/schema/standard-schema.test.d.ts.map +1 -0
  263. package/esm/schema/standard-schema.test.js +130 -0
  264. package/esm/schema/standard-schema.test.js.map +1 -0
  265. package/esm/schema/validate.test.js +149 -0
  266. package/esm/schema/validate.test.js.map +1 -1
  267. package/esm/schema/zod.d.ts +7 -4
  268. package/esm/schema/zod.d.ts.map +1 -1
  269. package/esm/schema/zod.js +65 -22
  270. package/esm/schema/zod.js.map +1 -1
  271. package/esm/schema/zod.test.js +113 -1
  272. package/esm/schema/zod.test.js.map +1 -1
  273. package/esm/testing/tools.d.ts +4 -1
  274. package/esm/testing/tools.d.ts.map +1 -1
  275. package/esm/testing/tools.js +6 -1
  276. package/esm/testing/tools.js.map +1 -1
  277. package/esm/util/generate-component.d.ts.map +1 -1
  278. package/esm/util/generate-component.js +18 -3
  279. package/esm/util/generate-component.js.map +1 -1
  280. package/esm/util/generate-component.test.d.ts +2 -0
  281. package/esm/util/generate-component.test.d.ts.map +1 -0
  282. package/esm/util/generate-component.test.js +302 -0
  283. package/esm/util/generate-component.test.js.map +1 -0
  284. package/esm/util/is-promise.d.ts +9 -0
  285. package/esm/util/is-promise.d.ts.map +1 -0
  286. package/esm/util/is-promise.js +17 -0
  287. package/esm/util/is-promise.js.map +1 -0
  288. package/esm/util/is-promise.test.d.ts +2 -0
  289. package/esm/util/is-promise.test.d.ts.map +1 -0
  290. package/esm/util/is-promise.test.js +46 -0
  291. package/esm/util/is-promise.test.js.map +1 -0
  292. package/esm/util/query-utils.test.d.ts +2 -0
  293. package/esm/util/query-utils.test.d.ts.map +1 -0
  294. package/esm/util/query-utils.test.js +380 -0
  295. package/esm/util/query-utils.test.js.map +1 -0
  296. package/esm/util/registry-validators.d.ts.map +1 -1
  297. package/esm/util/registry-validators.js +7 -0
  298. package/esm/util/registry-validators.js.map +1 -1
  299. package/esm/util/registry-validators.test.js +57 -0
  300. package/esm/util/registry-validators.test.js.map +1 -1
  301. package/esm/util/registry.d.ts.map +1 -1
  302. package/esm/util/registry.js +9 -0
  303. package/esm/util/registry.js.map +1 -1
  304. package/esm/util/registry.test.js +324 -2
  305. package/esm/util/registry.test.js.map +1 -1
  306. package/esm/util/resource-validators.test.d.ts +2 -0
  307. package/esm/util/resource-validators.test.d.ts.map +1 -0
  308. package/esm/util/resource-validators.test.js +88 -0
  309. package/esm/util/resource-validators.test.js.map +1 -0
  310. package/esm/util/tool-caller.d.ts +2 -2
  311. package/esm/util/tool-caller.d.ts.map +1 -1
  312. package/esm/util/tool-caller.js +8 -8
  313. package/esm/util/tool-caller.js.map +1 -1
  314. package/esm/util/validate-component-name.test.d.ts +2 -0
  315. package/esm/util/validate-component-name.test.d.ts.map +1 -0
  316. package/esm/util/validate-component-name.test.js +33 -0
  317. package/esm/util/validate-component-name.test.js.map +1 -0
  318. package/package.json +15 -23
  319. package/dist/schema/alias.d.ts +0 -3
  320. package/dist/schema/alias.d.ts.map +0 -1
  321. package/dist/schema/alias.js +0 -6
  322. package/dist/schema/alias.js.map +0 -1
  323. package/esm/schema/alias.d.ts +0 -3
  324. package/esm/schema/alias.d.ts.map +0 -1
  325. package/esm/schema/alias.js +0 -13
  326. package/esm/schema/alias.js.map +0 -1
@@ -0,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E,SAAS;gBACjB,YAAY,EAAE,6BAA6B;aAC5C,CAAC,CAAC;YAEH,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,aAAa,EAAE,EAAE;gBACnD,OAAO,EAAE,aAAa,EAAE;aACzB,CAAC,CAAC;YAEH,MAAM,OAAO,CAAC,GAAG,EAAE;gBACjB,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YAClE,CAAC,CAAC,CAAC;YAEH,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAClD,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,QAAQ,EAAE,CAAC;QAC/C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { act, renderHook, waitFor } from \"@testing-library/react\";\nimport React from \"react\";\nimport { QueryClient, QueryClientProvider } from \"@tanstack/react-query\";\nimport { useReactMediaRecorder } from \"react-media-recorder\";\nimport { useTamboVoice } from \"./use-tambo-voice\";\nimport { TamboClientContext } from \"../providers/tambo-client-provider\";\nimport TamboAI from \"@tambo-ai/typescript-sdk\";\n\n// Override the global mock from setupTests.ts with a controllable version\njest.mock(\"react-media-recorder\", () => ({\n useReactMediaRecorder: jest.fn(),\n}));\n\n// Mock the client provider\njest.mock(\"../providers/tambo-client-provider\", () => ({\n ...jest.requireActual(\"../providers/tambo-client-provider\"),\n useTamboClient: jest.fn(),\n}));\n\nimport { useTamboClient } from \"../providers/tambo-client-provider\";\n\n// Mock fetch globally\nconst mockFetch = jest.fn();\n\ndescribe(\"useTamboVoice\", () => {\n let previousFetch: typeof fetch;\n let mockStartRecording: jest.Mock;\n let mockStopRecording: jest.Mock;\n let mockTranscribe: jest.Mock;\n let queryClient: QueryClient;\n\n type MediaRecorderMockValue = Pick<\n ReturnType<typeof useReactMediaRecorder>,\n \"status\" | \"startRecording\" | \"stopRecording\" | \"mediaBlobUrl\" | \"error\"\n >;\n\n const createWrapper = () => {\n const mockClient = {\n beta: {\n audio: {\n transcribe: mockTranscribe,\n },\n },\n } as unknown as TamboAI;\n\n const Wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboClientContext.Provider\n value={{\n client: mockClient,\n queryClient,\n isUpdatingToken: false,\n }}\n >\n <QueryClientProvider client={queryClient}>\n {children}\n </QueryClientProvider>\n </TamboClientContext.Provider>\n );\n Wrapper.displayName = \"TestWrapper\";\n return Wrapper;\n };\n\n const setupMediaRecorderMock = (\n overrides: Partial<MediaRecorderMockValue> = {},\n ) => {\n const value: MediaRecorderMockValue = {\n status: \"idle\",\n startRecording: mockStartRecording,\n stopRecording: mockStopRecording,\n mediaBlobUrl: undefined,\n error: \"\",\n ...overrides,\n };\n jest\n .mocked(useReactMediaRecorder)\n .mockReturnValue(\n value as unknown as ReturnType<typeof useReactMediaRecorder>,\n );\n return value;\n };\n\n beforeEach(() => {\n jest.clearAllMocks();\n\n mockFetch.mockReset();\n\n previousFetch = global.fetch;\n global.fetch = mockFetch as unknown as typeof fetch;\n\n mockStartRecording = jest.fn();\n mockStopRecording = jest.fn();\n mockTranscribe = jest.fn();\n queryClient = new QueryClient({\n defaultOptions: {\n queries: { retry: false },\n mutations: { retry: false },\n },\n });\n\n // Setup default client mock\n const mockClient = {\n beta: {\n audio: {\n transcribe: mockTranscribe,\n },\n },\n };\n jest\n .mocked(useTamboClient)\n .mockReturnValue(mockClient as unknown as TamboAI);\n\n // Setup default media recorder mock\n setupMediaRecorderMock();\n\n // Setup default fetch mock\n mockFetch.mockResolvedValue({\n blob: async () =>\n await Promise.resolve(new Blob([\"audio data\"], { type: \"audio/webm\" })),\n });\n });\n\n afterEach(() => {\n global.fetch = previousFetch;\n });\n\n describe(\"Initial State\", () => {\n it(\"should initialize with idle state and no transcript\", () => {\n const { result } = renderHook(() => useTamboVoice(), {\n wrapper: createWrapper(),\n });\n\n expect(result.current.isRecording).toBe(false);\n expect(result.current.isTranscribing).toBe(false);\n expect(result.current.transcript).toBeNull();\n expect(result.current.transcriptionError).toBeNull();\n expect(result.current.mediaAccessError).toBeNull();\n });\n });\n\n describe(\"Recording Flow\", () => {\n it(\"should expose isRecording=true during active recording\", () => {\n setupMediaRecorderMock({ status: \"recording\" });\n\n const { result } = renderHook(() => useTamboVoice(), {\n wrapper: createWrapper(),\n });\n\n expect(result.current.isRecording).toBe(true);\n });\n\n it(\"should call startRecording on the media recorder\", () => {\n const { result } = renderHook(() => useTamboVoice(), {\n wrapper: createWrapper(),\n });\n\n act(() => {\n result.current.startRecording();\n });\n\n expect(mockStartRecording).toHaveBeenCalled();\n });\n\n it(\"should call stopRecording on the media recorder when recording\", () => {\n setupMediaRecorderMock({ status: \"recording\" });\n\n const { result } = renderHook(() => useTamboVoice(), {\n wrapper: createWrapper(),\n });\n\n act(() => {\n result.current.stopRecording();\n });\n\n expect(mockStopRecording).toHaveBeenCalled();\n });\n\n it(\"should reset transcript when starting a new recording\", async () => {\n mockTranscribe.mockResolvedValue(\"first transcript\");\n\n // Start with completed transcription\n setupMediaRecorderMock({\n status: \"stopped\",\n mediaBlobUrl: \"blob:http://localhost/audio1\",\n });\n\n const { result, rerender } = renderHook(() => useTamboVoice(), {\n wrapper: createWrapper(),\n });\n\n // Wait for transcription to complete\n await waitFor(() => {\n expect(result.current.transcript).toBe(\"first transcript\");\n });\n\n // Now simulate starting a new recording\n setupMediaRecorderMock({ status: \"idle\" });\n rerender();\n\n act(() => {\n result.current.startRecording();\n });\n\n expect(result.current.transcript).toBeNull();\n });\n });\n\n describe(\"Transcription\", () => {\n it(\"should trigger transcription after recording stops with blob URL\", async () => {\n mockTranscribe.mockResolvedValue(\"Hello world\");\n\n setupMediaRecorderMock({\n status: \"stopped\",\n mediaBlobUrl: \"blob:http://localhost/audio\",\n });\n\n const { result } = renderHook(() => useTamboVoice(), {\n wrapper: createWrapper(),\n });\n\n await waitFor(() => {\n expect(result.current.transcript).toBe(\"Hello world\");\n });\n\n expect(mockFetch).toHaveBeenCalledWith(\"blob:http://localhost/audio\");\n expect(mockTranscribe).toHaveBeenCalled();\n });\n\n it(\"should expose isTranscribing=true during API call\", async () => {\n let resolveTranscription: (value: string) => void;\n mockTranscribe.mockImplementation(\n async () =>\n await new Promise((resolve) => {\n resolveTranscription = resolve;\n }),\n );\n\n setupMediaRecorderMock({\n status: \"stopped\",\n mediaBlobUrl: \"blob:http://localhost/audio\",\n });\n\n const { result } = renderHook(() => useTamboVoice(), {\n wrapper: createWrapper(),\n });\n\n await waitFor(() => {\n expect(result.current.isTranscribing).toBe(true);\n });\n\n // Complete the transcription\n act(() => {\n resolveTranscription!(\"transcribed text\");\n });\n\n await waitFor(() => {\n expect(result.current.isTranscribing).toBe(false);\n });\n });\n });\n\n describe(\"Error Handling\", () => {\n it(\"should expose mediaAccessError when microphone access fails\", () => {\n setupMediaRecorderMock({\n error: \"Permission denied\",\n });\n\n const { result } = renderHook(() => useTamboVoice(), {\n wrapper: createWrapper(),\n });\n\n expect(result.current.mediaAccessError).toBe(\"Permission denied\");\n });\n\n it(\"should expose transcriptionError when API call fails\", async () => {\n mockTranscribe.mockRejectedValue(\n new Error(\"Transcription service unavailable\"),\n );\n\n setupMediaRecorderMock({\n status: \"stopped\",\n mediaBlobUrl: \"blob:http://localhost/audio\",\n });\n\n const { result } = renderHook(() => useTamboVoice(), {\n wrapper: createWrapper(),\n });\n\n await waitFor(() => {\n expect(result.current.transcriptionError).toBe(\n \"Transcription service unavailable\",\n );\n });\n\n expect(result.current.isTranscribing).toBe(false);\n });\n\n it(\"should handle blob fetch failure gracefully\", async () => {\n mockFetch.mockRejectedValue(new Error(\"Network error\"));\n\n setupMediaRecorderMock({\n status: \"stopped\",\n mediaBlobUrl: \"blob:http://localhost/audio\",\n });\n\n const { result } = renderHook(() => useTamboVoice(), {\n wrapper: createWrapper(),\n });\n\n await waitFor(() => {\n expect(result.current.transcriptionError).toBe(\"Network error\");\n });\n\n expect(result.current.isTranscribing).toBe(false);\n expect(result.current.transcript).toBeNull();\n });\n });\n});\n"]}
package/esm/index.d.ts CHANGED
@@ -6,12 +6,12 @@ export { useTamboStreamingProps } from "./hooks/use-streaming-props";
6
6
  export * from "./hooks/use-suggestions";
7
7
  export { useTamboStreamStatus, type PropStatus, type StreamStatus, } from "./hooks/use-tambo-stream-status";
8
8
  export { useTamboVoice } from "./hooks/use-tambo-voice";
9
- export { TamboClientProvider, TamboComponentProvider, TamboContextAttachmentProvider, TamboContextHelpersProvider, TamboPropStreamProvider, TamboProvider, TamboRegistryProvider, TamboStubProvider, TamboThreadInputProvider, TamboThreadProvider, useIsTamboTokenUpdating, useTambo, useTamboClient, useTamboContextAttachment, useTamboContextHelpers, useTamboGenerationStage, useTamboMcpServerInfos, useTamboStream, useTamboThread, useTamboThreadInput, type ContextAttachment, type ContextAttachmentState, type ContextHelperData, type RegisterToolFn, type RegisterToolsFn, type TamboComponent, type TamboContextAttachmentProviderProps, type TamboContextHelpersContextProps, type TamboContextHelpersProviderProps, type TamboRegistryContext, type TamboStubProviderProps, type TamboThreadInputContextProps, type TamboThreadProviderProps, } from "./providers";
9
+ export { TamboClientProvider, TamboComponentProvider, TamboContextAttachmentProvider, TamboContextHelpersProvider, TamboPropStreamProvider, TamboProvider, TamboRegistryProvider, TamboStubProvider, TamboThreadInputProvider, TamboThreadProvider, useIsTamboTokenUpdating, useTambo, useTamboClient, useTamboContextAttachment, useTamboContextHelpers, useTamboGenerationStage, useTamboMcpServerInfos, useTamboStream, useTamboThread, useTamboThreadInput, type ContextAttachment, type ContextAttachmentState, type RegisterToolFn, type RegisterToolsFn, type TamboComponent, type TamboContextAttachmentProviderProps, type TamboContextHelpersContextProps, type TamboContextHelpersProviderProps, type TamboRegistryContext, type TamboStubProviderProps, type TamboThreadInputContextProps, type TamboThreadProviderProps, } from "./providers";
10
10
  export type { APIError, RateLimitError, TamboAIError, } from "@tambo-ai/typescript-sdk";
11
11
  export type { Suggestion, SuggestionGenerateParams, SuggestionGenerateResponse, SuggestionListResponse, } from "@tambo-ai/typescript-sdk/resources/beta/threads/suggestions";
12
12
  export { withTamboInteractable as withInteractable, type InteractableConfig, type WithTamboInteractableProps, } from "./hoc/with-tambo-interactable";
13
13
  export { useTamboThreadList } from "./hooks/use-tambo-threads";
14
- export { type ComponentContextToolMetadata, type ComponentRegistry, type ParameterSpec, type RegisteredComponent, type TamboToolBase as TamboTool, } from "./model/component-metadata";
14
+ export { type ComponentContextToolMetadata, type ComponentRegistry, type ParameterSpec, type RegisteredComponent, type TamboToolBase as TamboTool, type ToolAnnotations, } from "./model/component-metadata";
15
15
  export { GenerationStage, type InteractableMetadata, type TamboThreadMessage, } from "./model/generate-component-response";
16
16
  export type { TamboInteractableComponent as InteractableComponent, TamboInteractableContext, } from "./model/tambo-interactable";
17
17
  export { type TamboThread } from "./model/tambo-thread";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wKAAwK;AAExK,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,sBAAsB,EACtB,KAAK,qBAAqB,GAC3B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,KAAK,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,cAAc,yBAAyB,CAAC;AACxC,OAAO,EACL,oBAAoB,EACpB,KAAK,UAAU,EACf,KAAK,YAAY,GAClB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxD,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,8BAA8B,EAC9B,2BAA2B,EAC3B,uBAAuB,EACvB,aAAa,EACb,qBAAqB,EACr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,mBAAmB,CAAC;AAC3B,YAAY,EACV,iBAAiB,EACjB,eAAe,EACf,cAAc,GACf,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,YAAY,EACV,aAAa,EACb,uBAAuB,GACxB,MAAM,yBAAyB,CAAC;AAGjC,YAAY,EACV,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,GACf,MAAM,uBAAuB,CAAC"}
package/esm/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wKAAwK;AAExK,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,sBAAsB,GAEvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAoB,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,cAAc,yBAAyB,CAAC;AACxC,OAAO,EACL,oBAAoB,GAGrB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,gCAAgC;AAChC,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,8BAA8B,EAC9B,2BAA2B,EAC3B,uBAAuB,EACvB,aAAa,EACb,qBAAqB,EACrB,iBAAiB,EACjB,wBAAwB,EACxB,mBAAmB,EACnB,uBAAuB,EACvB,QAAQ,EACR,cAAc,EACd,yBAAyB,EACzB,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,cAAc,EACd,cAAc,EACd,mBAAmB,GAcpB,MAAM,aAAa,CAAC;AAcrB,OAAO,EACL,qBAAqB,IAAI,gBAAgB,GAG1C,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAc/D,OAAO,EACL,eAAe,GAGhB,MAAM,qCAAqC,CAAC;AAM7C,OAAO,EACL,+BAA+B,EAC/B,oBAAoB,GACrB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,0BAA0B;AAC1B,OAAO,EACL,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,mBAAmB,CAAC;AAO3B,8EAA8E;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAavD,+EAA+E;AAC/E,8BAA8B","sourcesContent":["/** Exports for the library. Only publically available exports are re-exported here. Anything not exported here is not supported and may change or break at any time. */\n\nexport { useTamboComponentState } from \"./hooks/use-component-state\";\nexport {\n TamboMessageProvider,\n useTamboCurrentComponent,\n useTamboCurrentMessage,\n type TamboCurrentComponent,\n} from \"./hooks/use-current-message\";\nexport { useMessageImages, type StagedImage } from \"./hooks/use-message-images\";\nexport { useTamboStreamingProps } from \"./hooks/use-streaming-props\";\nexport * from \"./hooks/use-suggestions\";\nexport {\n useTamboStreamStatus,\n type PropStatus,\n type StreamStatus,\n} from \"./hooks/use-tambo-stream-status\";\nexport { useTamboVoice } from \"./hooks/use-tambo-voice\";\n\n// Re-export provider components\nexport {\n TamboClientProvider,\n TamboComponentProvider,\n TamboContextAttachmentProvider,\n TamboContextHelpersProvider,\n TamboPropStreamProvider,\n TamboProvider,\n TamboRegistryProvider,\n TamboStubProvider,\n TamboThreadInputProvider,\n TamboThreadProvider,\n useIsTamboTokenUpdating,\n useTambo,\n useTamboClient,\n useTamboContextAttachment,\n useTamboContextHelpers,\n useTamboGenerationStage,\n useTamboMcpServerInfos,\n useTamboStream,\n useTamboThread,\n useTamboThreadInput,\n type ContextAttachment,\n type ContextAttachmentState,\n type ContextHelperData,\n type RegisterToolFn,\n type RegisterToolsFn,\n type TamboComponent,\n type TamboContextAttachmentProviderProps,\n type TamboContextHelpersContextProps,\n type TamboContextHelpersProviderProps,\n type TamboRegistryContext,\n type TamboStubProviderProps,\n type TamboThreadInputContextProps,\n type TamboThreadProviderProps,\n} from \"./providers\";\n\n// Re-export types from Tambo Node SDK\nexport type {\n APIError,\n RateLimitError,\n TamboAIError,\n} from \"@tambo-ai/typescript-sdk\";\nexport type {\n Suggestion,\n SuggestionGenerateParams,\n SuggestionGenerateResponse,\n SuggestionListResponse,\n} from \"@tambo-ai/typescript-sdk/resources/beta/threads/suggestions\";\nexport {\n withTamboInteractable as withInteractable,\n type InteractableConfig,\n type WithTamboInteractableProps,\n} from \"./hoc/with-tambo-interactable\";\nexport { useTamboThreadList } from \"./hooks/use-tambo-threads\";\nexport {\n type ComponentContextToolMetadata,\n type ComponentRegistry,\n type ParameterSpec,\n type RegisteredComponent,\n /*\n * NOTE(lachieh): TamboToolBase is used as a wrapper around current TamboTool\n * and the deprecated TamboToolWithToolSchema to allow both to be used while\n * supporting the migration to a single TamboTool type.\n * TamboToolWithToolSchema should be removed in a future release.\n */\n type TamboToolBase as TamboTool,\n} from \"./model/component-metadata\";\nexport {\n GenerationStage,\n type InteractableMetadata,\n type TamboThreadMessage,\n} from \"./model/generate-component-response\";\nexport type {\n TamboInteractableComponent as InteractableComponent,\n TamboInteractableContext,\n} from \"./model/tambo-interactable\";\nexport { type TamboThread } from \"./model/tambo-thread\";\nexport {\n useCurrentInteractablesSnapshot,\n useTamboInteractable,\n} from \"./providers/tambo-interactable-provider\";\nexport { type InitialTamboThreadMessage } from \"./providers/tambo-thread-provider\";\nexport { defineTool } from \"./util/registry\";\n\n// Context helpers exports\nexport {\n currentPageContextHelper,\n currentTimeContextHelper,\n} from \"./context-helpers\";\nexport type {\n AdditionalContext,\n ContextHelperFn,\n ContextHelpers,\n} from \"./context-helpers\";\n\n// MCP server metadata types (used by TamboProvider / registry / MCP provider)\nexport { MCPTransport } from \"./model/mcp-server-info\";\nexport type {\n McpServerInfo,\n NormalizedMcpServerInfo,\n} from \"./model/mcp-server-info\";\n\n// Resource types for registry resource registration\nexport type {\n ListResourceItem,\n ReadResourceResult,\n ResourceSource,\n} from \"./model/resource-info\";\n\n// Note: Full MCP exports like TamboMcpProvider are available separately in the\n// @tambo-ai/react/mcp package\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wKAAwK;AAExK,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,sBAAsB,GAEvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAoB,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,cAAc,yBAAyB,CAAC;AACxC,OAAO,EACL,oBAAoB,GAGrB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,gCAAgC;AAChC,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,8BAA8B,EAC9B,2BAA2B,EAC3B,uBAAuB,EACvB,aAAa,EACb,qBAAqB,EACrB,iBAAiB,EACjB,wBAAwB,EACxB,mBAAmB,EACnB,uBAAuB,EACvB,QAAQ,EACR,cAAc,EACd,yBAAyB,EACzB,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,cAAc,EACd,cAAc,EACd,mBAAmB,GAapB,MAAM,aAAa,CAAC;AAcrB,OAAO,EACL,qBAAqB,IAAI,gBAAgB,GAG1C,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAe/D,OAAO,EACL,eAAe,GAGhB,MAAM,qCAAqC,CAAC;AAM7C,OAAO,EACL,+BAA+B,EAC/B,oBAAoB,GACrB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,0BAA0B;AAC1B,OAAO,EACL,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,mBAAmB,CAAC;AAO3B,8EAA8E;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAavD,+EAA+E;AAC/E,8BAA8B","sourcesContent":["/** Exports for the library. Only publically available exports are re-exported here. Anything not exported here is not supported and may change or break at any time. */\n\nexport { useTamboComponentState } from \"./hooks/use-component-state\";\nexport {\n TamboMessageProvider,\n useTamboCurrentComponent,\n useTamboCurrentMessage,\n type TamboCurrentComponent,\n} from \"./hooks/use-current-message\";\nexport { useMessageImages, type StagedImage } from \"./hooks/use-message-images\";\nexport { useTamboStreamingProps } from \"./hooks/use-streaming-props\";\nexport * from \"./hooks/use-suggestions\";\nexport {\n useTamboStreamStatus,\n type PropStatus,\n type StreamStatus,\n} from \"./hooks/use-tambo-stream-status\";\nexport { useTamboVoice } from \"./hooks/use-tambo-voice\";\n\n// Re-export provider components\nexport {\n TamboClientProvider,\n TamboComponentProvider,\n TamboContextAttachmentProvider,\n TamboContextHelpersProvider,\n TamboPropStreamProvider,\n TamboProvider,\n TamboRegistryProvider,\n TamboStubProvider,\n TamboThreadInputProvider,\n TamboThreadProvider,\n useIsTamboTokenUpdating,\n useTambo,\n useTamboClient,\n useTamboContextAttachment,\n useTamboContextHelpers,\n useTamboGenerationStage,\n useTamboMcpServerInfos,\n useTamboStream,\n useTamboThread,\n useTamboThreadInput,\n type ContextAttachment,\n type ContextAttachmentState,\n type RegisterToolFn,\n type RegisterToolsFn,\n type TamboComponent,\n type TamboContextAttachmentProviderProps,\n type TamboContextHelpersContextProps,\n type TamboContextHelpersProviderProps,\n type TamboRegistryContext,\n type TamboStubProviderProps,\n type TamboThreadInputContextProps,\n type TamboThreadProviderProps,\n} from \"./providers\";\n\n// Re-export types from Tambo Node SDK\nexport type {\n APIError,\n RateLimitError,\n TamboAIError,\n} from \"@tambo-ai/typescript-sdk\";\nexport type {\n Suggestion,\n SuggestionGenerateParams,\n SuggestionGenerateResponse,\n SuggestionListResponse,\n} from \"@tambo-ai/typescript-sdk/resources/beta/threads/suggestions\";\nexport {\n withTamboInteractable as withInteractable,\n type InteractableConfig,\n type WithTamboInteractableProps,\n} from \"./hoc/with-tambo-interactable\";\nexport { useTamboThreadList } from \"./hooks/use-tambo-threads\";\nexport {\n type ComponentContextToolMetadata,\n type ComponentRegistry,\n type ParameterSpec,\n type RegisteredComponent,\n /*\n * NOTE(lachieh): TamboToolBase is used as a wrapper around current TamboTool\n * and the deprecated TamboToolWithToolSchema to allow both to be used while\n * supporting the migration to a single TamboTool type.\n * TamboToolWithToolSchema should be removed in a future release.\n */\n type TamboToolBase as TamboTool,\n type ToolAnnotations,\n} from \"./model/component-metadata\";\nexport {\n GenerationStage,\n type InteractableMetadata,\n type TamboThreadMessage,\n} from \"./model/generate-component-response\";\nexport type {\n TamboInteractableComponent as InteractableComponent,\n TamboInteractableContext,\n} from \"./model/tambo-interactable\";\nexport { type TamboThread } from \"./model/tambo-thread\";\nexport {\n useCurrentInteractablesSnapshot,\n useTamboInteractable,\n} from \"./providers/tambo-interactable-provider\";\nexport { type InitialTamboThreadMessage } from \"./providers/tambo-thread-provider\";\nexport { defineTool } from \"./util/registry\";\n\n// Context helpers exports\nexport {\n currentPageContextHelper,\n currentTimeContextHelper,\n} from \"./context-helpers\";\nexport type {\n AdditionalContext,\n ContextHelperFn,\n ContextHelpers,\n} from \"./context-helpers\";\n\n// MCP server metadata types (used by TamboProvider / registry / MCP provider)\nexport { MCPTransport } from \"./model/mcp-server-info\";\nexport type {\n McpServerInfo,\n NormalizedMcpServerInfo,\n} from \"./model/mcp-server-info\";\n\n// Resource types for registry resource registration\nexport type {\n ListResourceItem,\n ReadResourceResult,\n ResourceSource,\n} from \"./model/resource-info\";\n\n// Note: Full MCP exports like TamboMcpProvider are available separately in the\n// @tambo-ai/react/mcp package\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"elicitation.d.ts","sourceRoot":"","sources":["../../src/mcp/elicitation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,uBAAuB,EACvB,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B;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,0BAA0B,CAAC;IAC5C,iFAAiF;IACjF,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;GAEG;AACH,YAAY,EAAE,yBAAyB,EAAE,CAAC;AAO1C;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAC;IACxC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC,0DAA0D;IAC1D,WAAW,EAAE,uBAAuB,GAAG,IAAI,CAAC;IAC5C,sFAAsF;IACtF,kBAAkB,EAAE,CAAC,CAAC,QAAQ,EAAE,wBAAwB,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;CAC3E;AA8BD;;;;;;GAMG;AACH,wBAAgB,cAAc;;;oCAId,wBAAwB,KAAK,IAAI;+FAAjC,wBAAwB,KAAK,IAAI;;EAsEhD"}
@@ -14,6 +14,13 @@ import { useCallback, useState } from "react";
14
14
  function toElicitationRequestedSchema(value) {
15
15
  return value;
16
16
  }
17
+ /**
18
+ * Type guard for the elicitation form params shape.
19
+ * @returns true when params include requestedSchema
20
+ */
21
+ function hasRequestedSchema(params) {
22
+ return "requestedSchema" in params;
23
+ }
17
24
  /**
18
25
  * Internal hook that manages elicitation state and creates a default handler.
19
26
  * This bundles all the state management and handler creation for elicitation.
@@ -26,6 +33,11 @@ export function useElicitation() {
26
33
  const [resolveElicitation, setResolveElicitation] = useState(null);
27
34
  const defaultElicitationHandler = useCallback(async (request, extra) => {
28
35
  return await new Promise((resolve, reject) => {
36
+ if (!hasRequestedSchema(request.params)) {
37
+ const mode = "mode" in request.params ? String(request.params.mode) : "unknown";
38
+ reject(new Error(`Unsupported MCP elicitation params: expected requestedSchema (form mode), got mode=${mode}`));
39
+ return;
40
+ }
29
41
  // Set the elicitation request to show the UI
30
42
  // Cast is needed because ElicitRequest uses Zod-inferred types (from the
31
43
  // user's installed zod version), while we use pure TypeScript spec types
@@ -1 +1 @@
1
- {"version":3,"file":"elicitation.js","sourceRoot":"","sources":["../../src/mcp/elicitation.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AA4C9C;;;;;;;;;;;GAWG;AACH,SAAS,4BAA4B,CACnC,KAAiD;IAEjD,OAAO,KAAmC,CAAC;AAC7C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc;IAC5B,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GACjC,QAAQ,CAAiC,IAAI,CAAC,CAAC;IACjD,MAAM,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,GAAG,QAAQ,CAE1D,IAAI,CAAC,CAAC;IAER,MAAM,yBAAyB,GAA0B,WAAW,CAClE,KAAK,EACH,OAAsB,EACtB,KAA6D,EACtC,EAAE;QACzB,OAAO,MAAM,IAAI,OAAO,CAAe,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACzD,6CAA6C;YAC7C,yEAAyE;YACzE,yEAAyE;YACzE,kCAAkC;YAClC,cAAc,CAAC;gBACb,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO;gBAC/B,eAAe,EAAE,4BAA4B,CAC3C,OAAO,CAAC,MAAM,CAAC,eAAe,CAC/B;gBACD,MAAM,EAAE,KAAK,CAAC,MAAM;aACrB,CAAC,CAAC;YAEH,uDAAuD;YACvD,IAAI,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;gBACzB,cAAc,CAAC,IAAI,CAAC,CAAC;gBACrB,MAAM,CAAC,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC;gBACrC,OAAO;YACT,CAAC;YAED,sCAAsC;YACtC,MAAM,WAAW,GAAG,GAAG,EAAE;gBACvB,cAAc,CAAC,IAAI,CAAC,CAAC;gBACrB,qBAAqB,CAAC,IAAI,CAAC,CAAC;gBAC5B,MAAM,CAAC,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC;YACvC,CAAC,CAAC;YAEF,KAAK,CAAC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;YAEpE,sEAAsE;YACtE,qBAAqB,CAAC,GAAG,EAAE,CAAC,CAAC,QAAsB,EAAE,EAAE;gBACrD,uDAAuD;gBACvD,KAAK,CAAC,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;gBACvD,0CAA0C;gBAC1C,cAAc,CAAC,IAAI,CAAC,CAAC;gBACrB,qBAAqB,CAAC,IAAI,CAAC,CAAC;gBAC5B,OAAO,CAAC,QAAQ,CAAC,CAAC;YACpB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,EACD,EAAE,CACH,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\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: ElicitRequest[\"params\"][\"requestedSchema\"],\n): ElicitationRequestedSchema {\n return value as ElicitationRequestedSchema;\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 // 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":"AAWA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;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,MAAM,UAAU,cAAc;IAC5B,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GACjC,QAAQ,CAAiC,IAAI,CAAC,CAAC;IACjD,MAAM,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,GAAG,QAAQ,CAE1D,IAAI,CAAC,CAAC;IAER,MAAM,yBAAyB,GAA0B,WAAW,CAClE,KAAK,EACH,OAAsB,EACtB,KAA6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sB,EAAE,EAAE;gBACrD,uDAAuD;gBACvD,KAAK,CAAC,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;gBACvD,0CAA0C;gBAC1C,cAAc,CAAC,IAAI,CAAC,CAAC;gBACrB,qBAAqB,CAAC,IAAI,CAAC,CAAC;gBAC5B,OAAO,CAAC,QAAQ,CAAC,CAAC;YACpB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,EACD,EAAE,CACH,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"]}
@@ -47,9 +47,16 @@ describe("useElicitation", () => {
47
47
  handlerPromise = result.current.defaultElicitationHandler(request, extra);
48
48
  });
49
49
  // Elicitation should be set
50
+ const requestedSchema = "requestedSchema" in request.params
51
+ ? request.params.requestedSchema
52
+ : null;
53
+ expect(requestedSchema).not.toBeNull();
54
+ if (requestedSchema === null) {
55
+ return;
56
+ }
50
57
  expect(result.current.elicitation).toEqual({
51
58
  message: "Please provide your name",
52
- requestedSchema: request.params.requestedSchema,
59
+ requestedSchema,
53
60
  signal: extra.signal,
54
61
  });
55
62
  // Resolve callback should be set
@@ -1 +1 @@
1
- {"version":3,"file":"elicitation.test.js","sourceRoot":"","sources":["../../src/mcp/elicitation.test.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EACL,cAAc,GAGf,MAAM,eAAe,CAA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GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,cAAc,EAAE,CAAC,CAAC;YAEtD,MAAM,WAAW,GAA4B;gBAC3C,OAAO,EAAE,MAAM;gBACf,eAAe,EAAE;oBACf,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE,EAAE;iBACf;aACF,CAAC;YAEF,GAAG,CAAC,GAAG,EAAE;gBACP,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;YAC7C,CAAC,CAAC,CAAC;YAEH,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;YAElD,GAAG,CAAC,GAAG,EAAE;gBACP,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;YACtC,CAAC,CAAC,CAAC;YAEH,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE,CAAC;QAChD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import type { RequestHandlerExtra } from \"@modelcontextprotocol/sdk/shared/protocol.js\";\nimport type {\n ClientNotification,\n ClientRequest,\n ElicitRequest,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport { act, renderHook } from \"@testing-library/react\";\nimport {\n useElicitation,\n type TamboElicitationRequest,\n type TamboElicitationResponse,\n} from \"./elicitation\";\n\n// Create a mock RequestHandlerExtra for testing\nfunction createMockExtra(): RequestHandlerExtra<\n ClientRequest,\n ClientNotification\n> {\n return {\n signal: new AbortController().signal,\n requestId: \"test-request-id\",\n\n sendNotification: (async () => {}) as any,\n\n sendRequest: (async () => ({ _meta: {} })) as any,\n };\n}\n\ndescribe(\"useElicitation\", () => {\n it(\"initializes with null state\", () => {\n const { result } = renderHook(() => useElicitation());\n\n expect(result.current.elicitation).toBeNull();\n expect(result.current.resolveElicitation).toBeNull();\n });\n\n it(\"provides state setters\", () => {\n const { result } = renderHook(() => useElicitation());\n\n expect(typeof result.current.setElicitation).toBe(\"function\");\n expect(typeof result.current.setResolveElicitation).toBe(\"function\");\n });\n\n it(\"provides a default elicitation handler\", () => {\n const { result } = renderHook(() => useElicitation());\n\n expect(typeof result.current.defaultElicitationHandler).toBe(\"function\");\n });\n\n describe(\"defaultElicitationHandler\", () => {\n it(\"sets elicitation state when called\", async () => {\n const { result } = renderHook(() => useElicitation());\n\n const request: ElicitRequest = {\n method: \"elicitation/create\",\n params: {\n message: \"Please provide your name\",\n requestedSchema: {\n type: \"object\",\n properties: {\n name: { type: \"string\", description: \"Your name\" },\n },\n required: [\"name\"],\n },\n },\n };\n\n // Start the handler but don't await yet\n let handlerPromise: Promise<TamboElicitationResponse>;\n const extra = createMockExtra();\n act(() => {\n handlerPromise = result.current.defaultElicitationHandler(\n request,\n extra,\n );\n });\n\n // Elicitation should be set\n expect(result.current.elicitation).toEqual({\n message: \"Please provide your name\",\n requestedSchema: request.params.requestedSchema,\n signal: extra.signal,\n });\n\n // Resolve callback should be set\n expect(result.current.resolveElicitation).not.toBeNull();\n\n // Clean up by resolving\n act(() => {\n result.current.resolveElicitation?.({\n action: \"cancel\",\n });\n });\n\n await handlerPromise!;\n });\n\n it(\"resolves promise when resolveElicitation is called with accept\", async () => {\n const { result } = renderHook(() => useElicitation());\n\n const request: ElicitRequest = {\n method: \"elicitation/create\",\n params: {\n message: \"Enter your email\",\n requestedSchema: {\n type: \"object\",\n properties: {\n email: {\n type: \"string\",\n format: \"email\",\n description: \"Email address\",\n },\n },\n },\n },\n };\n\n // Start the handler\n let handlerPromise: Promise<TamboElicitationResponse>;\n const extra = createMockExtra();\n act(() => {\n handlerPromise = result.current.defaultElicitationHandler(\n request,\n extra,\n );\n });\n\n // Resolve with accept\n const response: TamboElicitationResponse = {\n action: \"accept\",\n content: { email: \"test@example.com\" },\n };\n\n act(() => {\n result.current.resolveElicitation?.(response);\n });\n\n // Wait for promise to resolve\n const resolvedValue = await handlerPromise!;\n\n expect(resolvedValue).toEqual(response);\n });\n\n it(\"resolves promise when resolveElicitation is called with decline\", async () => {\n const { result } = renderHook(() => useElicitation());\n\n const request: ElicitRequest = {\n method: \"elicitation/create\",\n params: {\n message: \"Provide input\",\n requestedSchema: {\n type: \"object\",\n properties: {\n value: { type: \"string\" },\n },\n },\n },\n };\n\n let handlerPromise: Promise<TamboElicitationResponse>;\n const extra = createMockExtra();\n act(() => {\n handlerPromise = result.current.defaultElicitationHandler(\n request,\n extra,\n );\n });\n\n const response: TamboElicitationResponse = {\n action: \"decline\",\n };\n\n act(() => {\n result.current.resolveElicitation?.(response);\n });\n\n const resolvedValue = await handlerPromise!;\n\n expect(resolvedValue).toEqual(response);\n });\n\n it(\"resolves promise when resolveElicitation is called with cancel\", async () => {\n const { result } = renderHook(() => useElicitation());\n\n const request: ElicitRequest = {\n method: \"elicitation/create\",\n params: {\n message: \"Provide input\",\n requestedSchema: {\n type: \"object\",\n properties: {\n value: { type: \"string\" },\n },\n },\n },\n };\n\n let handlerPromise: Promise<TamboElicitationResponse>;\n const extra = createMockExtra();\n act(() => {\n handlerPromise = result.current.defaultElicitationHandler(\n request,\n extra,\n );\n });\n\n const response: TamboElicitationResponse = {\n action: \"cancel\",\n };\n\n act(() => {\n result.current.resolveElicitation?.(response);\n });\n\n const resolvedValue = await handlerPromise!;\n\n expect(resolvedValue).toEqual(response);\n });\n\n it(\"handles multiple sequential elicitations\", async () => {\n const { result } = renderHook(() => useElicitation());\n\n // First elicitation\n const request1: ElicitRequest = {\n method: \"elicitation/create\",\n params: {\n message: \"First request\",\n requestedSchema: {\n type: \"object\",\n properties: {\n field1: { type: \"string\" },\n },\n },\n },\n };\n\n let promise1: Promise<TamboElicitationResponse>;\n const extra1 = createMockExtra();\n act(() => {\n promise1 = result.current.defaultElicitationHandler(request1, extra1);\n });\n\n expect(result.current.elicitation?.message).toBe(\"First request\");\n\n act(() => {\n result.current.resolveElicitation?.({\n action: \"accept\",\n content: { field1: \"value1\" },\n });\n });\n\n const result1 = await promise1!;\n expect(result1).toEqual({\n action: \"accept\",\n content: { field1: \"value1\" },\n });\n\n // Second elicitation\n const request2: ElicitRequest = {\n method: \"elicitation/create\",\n params: {\n message: \"Second request\",\n requestedSchema: {\n type: \"object\",\n properties: { field2: { type: \"number\" } },\n },\n },\n };\n\n let promise2: Promise<TamboElicitationResponse>;\n const extra2 = createMockExtra();\n act(() => {\n promise2 = result.current.defaultElicitationHandler(request2, extra2);\n });\n\n expect(result.current.elicitation?.message).toBe(\"Second request\");\n\n act(() => {\n result.current.resolveElicitation?.({\n action: \"accept\",\n content: { field2: 42 },\n });\n });\n\n const result2 = await promise2!;\n expect(result2).toEqual({\n action: \"accept\",\n content: { field2: 42 },\n });\n });\n\n it(\"maintains stable handler reference across re-renders\", () => {\n const { result, rerender } = renderHook(() => useElicitation());\n\n const firstHandler = result.current.defaultElicitationHandler;\n\n rerender();\n\n const secondHandler = result.current.defaultElicitationHandler;\n\n expect(firstHandler).toBe(secondHandler);\n });\n });\n\n describe(\"state management\", () => {\n it(\"allows manual state updates via setElicitation\", () => {\n const { result } = renderHook(() => useElicitation());\n\n const customElicitation: TamboElicitationRequest = {\n message: \"Custom message\",\n requestedSchema: {\n type: \"object\",\n properties: {\n custom: { type: \"boolean\" },\n },\n },\n };\n\n act(() => {\n result.current.setElicitation(customElicitation);\n });\n\n expect(result.current.elicitation).toEqual(customElicitation);\n });\n\n it(\"allows clearing elicitation state\", () => {\n const { result } = renderHook(() => useElicitation());\n\n const elicitation: TamboElicitationRequest = {\n message: \"Test\",\n requestedSchema: {\n type: \"object\",\n properties: {},\n },\n };\n\n act(() => {\n result.current.setElicitation(elicitation);\n });\n\n expect(result.current.elicitation).not.toBeNull();\n\n act(() => {\n result.current.setElicitation(null);\n });\n\n expect(result.current.elicitation).toBeNull();\n });\n });\n});\n"]}
1
+ {"version":3,"file":"elicitation.test.js","sourceRoot":"","sources":["../../src/mcp/elicitation.test.tsx"],"names":[],"mappings":"AAMA,OAA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C5B;iBACF;aACF,CAAC;YAEF,GAAG,CAAC,GAAG,EAAE;gBACP,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;YACnD,CAAC,CAAC,CAAC;YAEH,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;QAChE,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;YAC3C,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,cAAc,EAAE,CAAC,CAAC;YAEtD,MAAM,WAAW,GAA4B;gBAC3C,OAAO,EAAE,MAAM;gBACf,eAAe,EAAE;oBACf,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE,EAAE;iBACf;aACF,CAAC;YAEF,GAAG,CAAC,GAAG,EAAE;gBACP,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;YAC7C,CAAC,CAAC,CAAC;YAEH,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;YAElD,GAAG,CAAC,GAAG,EAAE;gBACP,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;YACtC,CAAC,CAAC,CAAC;YAEH,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE,CAAC;QAChD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import type { RequestHandlerExtra } from \"@modelcontextprotocol/sdk/shared/protocol.js\";\nimport type {\n ClientNotification,\n ClientRequest,\n ElicitRequest,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport { act, renderHook } from \"@testing-library/react\";\nimport {\n useElicitation,\n type TamboElicitationRequest,\n type TamboElicitationResponse,\n} from \"./elicitation\";\n\n// Create a mock RequestHandlerExtra for testing\nfunction createMockExtra(): RequestHandlerExtra<\n ClientRequest,\n ClientNotification\n> {\n return {\n signal: new AbortController().signal,\n requestId: \"test-request-id\",\n\n sendNotification: (async () => {}) as any,\n\n sendRequest: (async () => ({ _meta: {} })) as any,\n };\n}\n\ndescribe(\"useElicitation\", () => {\n it(\"initializes with null state\", () => {\n const { result } = renderHook(() => useElicitation());\n\n expect(result.current.elicitation).toBeNull();\n expect(result.current.resolveElicitation).toBeNull();\n });\n\n it(\"provides state setters\", () => {\n const { result } = renderHook(() => useElicitation());\n\n expect(typeof result.current.setElicitation).toBe(\"function\");\n expect(typeof result.current.setResolveElicitation).toBe(\"function\");\n });\n\n it(\"provides a default elicitation handler\", () => {\n const { result } = renderHook(() => useElicitation());\n\n expect(typeof result.current.defaultElicitationHandler).toBe(\"function\");\n });\n\n describe(\"defaultElicitationHandler\", () => {\n it(\"sets elicitation state when called\", async () => {\n const { result } = renderHook(() => useElicitation());\n\n const request: ElicitRequest = {\n method: \"elicitation/create\",\n params: {\n message: \"Please provide your name\",\n requestedSchema: {\n type: \"object\",\n properties: {\n name: { type: \"string\", description: \"Your name\" },\n },\n required: [\"name\"],\n },\n },\n };\n\n // Start the handler but don't await yet\n let handlerPromise: Promise<TamboElicitationResponse>;\n const extra = createMockExtra();\n act(() => {\n handlerPromise = result.current.defaultElicitationHandler(\n request,\n extra,\n );\n });\n\n // Elicitation should be set\n const requestedSchema =\n \"requestedSchema\" in request.params\n ? request.params.requestedSchema\n : null;\n\n expect(requestedSchema).not.toBeNull();\n\n if (requestedSchema === null) {\n return;\n }\n\n expect(result.current.elicitation).toEqual({\n message: \"Please provide your name\",\n requestedSchema,\n signal: extra.signal,\n });\n\n // Resolve callback should be set\n expect(result.current.resolveElicitation).not.toBeNull();\n\n // Clean up by resolving\n act(() => {\n result.current.resolveElicitation?.({\n action: \"cancel\",\n });\n });\n\n await handlerPromise!;\n });\n\n it(\"resolves promise when resolveElicitation is called with accept\", async () => {\n const { result } = renderHook(() => useElicitation());\n\n const request: ElicitRequest = {\n method: \"elicitation/create\",\n params: {\n message: \"Enter your email\",\n requestedSchema: {\n type: \"object\",\n properties: {\n email: {\n type: \"string\",\n format: \"email\",\n description: \"Email address\",\n },\n },\n },\n },\n };\n\n // Start the handler\n let handlerPromise: Promise<TamboElicitationResponse>;\n const extra = createMockExtra();\n act(() => {\n handlerPromise = result.current.defaultElicitationHandler(\n request,\n extra,\n );\n });\n\n // Resolve with accept\n const response: TamboElicitationResponse = {\n action: \"accept\",\n content: { email: \"test@example.com\" },\n };\n\n act(() => {\n result.current.resolveElicitation?.(response);\n });\n\n // Wait for promise to resolve\n const resolvedValue = await handlerPromise!;\n\n expect(resolvedValue).toEqual(response);\n });\n\n it(\"resolves promise when resolveElicitation is called with decline\", async () => {\n const { result } = renderHook(() => useElicitation());\n\n const request: ElicitRequest = {\n method: \"elicitation/create\",\n params: {\n message: \"Provide input\",\n requestedSchema: {\n type: \"object\",\n properties: {\n value: { type: \"string\" },\n },\n },\n },\n };\n\n let handlerPromise: Promise<TamboElicitationResponse>;\n const extra = createMockExtra();\n act(() => {\n handlerPromise = result.current.defaultElicitationHandler(\n request,\n extra,\n );\n });\n\n const response: TamboElicitationResponse = {\n action: \"decline\",\n };\n\n act(() => {\n result.current.resolveElicitation?.(response);\n });\n\n const resolvedValue = await handlerPromise!;\n\n expect(resolvedValue).toEqual(response);\n });\n\n it(\"resolves promise when resolveElicitation is called with cancel\", async () => {\n const { result } = renderHook(() => useElicitation());\n\n const request: ElicitRequest = {\n method: \"elicitation/create\",\n params: {\n message: \"Provide input\",\n requestedSchema: {\n type: \"object\",\n properties: {\n value: { type: \"string\" },\n },\n },\n },\n };\n\n let handlerPromise: Promise<TamboElicitationResponse>;\n const extra = createMockExtra();\n act(() => {\n handlerPromise = result.current.defaultElicitationHandler(\n request,\n extra,\n );\n });\n\n const response: TamboElicitationResponse = {\n action: \"cancel\",\n };\n\n act(() => {\n result.current.resolveElicitation?.(response);\n });\n\n const resolvedValue = await handlerPromise!;\n\n expect(resolvedValue).toEqual(response);\n });\n\n it(\"handles multiple sequential elicitations\", async () => {\n const { result } = renderHook(() => useElicitation());\n\n // First elicitation\n const request1: ElicitRequest = {\n method: \"elicitation/create\",\n params: {\n message: \"First request\",\n requestedSchema: {\n type: \"object\",\n properties: {\n field1: { type: \"string\" },\n },\n },\n },\n };\n\n let promise1: Promise<TamboElicitationResponse>;\n const extra1 = createMockExtra();\n act(() => {\n promise1 = result.current.defaultElicitationHandler(request1, extra1);\n });\n\n expect(result.current.elicitation?.message).toBe(\"First request\");\n\n act(() => {\n result.current.resolveElicitation?.({\n action: \"accept\",\n content: { field1: \"value1\" },\n });\n });\n\n const result1 = await promise1!;\n expect(result1).toEqual({\n action: \"accept\",\n content: { field1: \"value1\" },\n });\n\n // Second elicitation\n const request2: ElicitRequest = {\n method: \"elicitation/create\",\n params: {\n message: \"Second request\",\n requestedSchema: {\n type: \"object\",\n properties: { field2: { type: \"number\" } },\n },\n },\n };\n\n let promise2: Promise<TamboElicitationResponse>;\n const extra2 = createMockExtra();\n act(() => {\n promise2 = result.current.defaultElicitationHandler(request2, extra2);\n });\n\n expect(result.current.elicitation?.message).toBe(\"Second request\");\n\n act(() => {\n result.current.resolveElicitation?.({\n action: \"accept\",\n content: { field2: 42 },\n });\n });\n\n const result2 = await promise2!;\n expect(result2).toEqual({\n action: \"accept\",\n content: { field2: 42 },\n });\n });\n\n it(\"maintains stable handler reference across re-renders\", () => {\n const { result, rerender } = renderHook(() => useElicitation());\n\n const firstHandler = result.current.defaultElicitationHandler;\n\n rerender();\n\n const secondHandler = result.current.defaultElicitationHandler;\n\n expect(firstHandler).toBe(secondHandler);\n });\n });\n\n describe(\"state management\", () => {\n it(\"allows manual state updates via setElicitation\", () => {\n const { result } = renderHook(() => useElicitation());\n\n const customElicitation: TamboElicitationRequest = {\n message: \"Custom message\",\n requestedSchema: {\n type: \"object\",\n properties: {\n custom: { type: \"boolean\" },\n },\n },\n };\n\n act(() => {\n result.current.setElicitation(customElicitation);\n });\n\n expect(result.current.elicitation).toEqual(customElicitation);\n });\n\n it(\"allows clearing elicitation state\", () => {\n const { result } = renderHook(() => useElicitation());\n\n const elicitation: TamboElicitationRequest = {\n message: \"Test\",\n requestedSchema: {\n type: \"object\",\n properties: {},\n },\n };\n\n act(() => {\n result.current.setElicitation(elicitation);\n });\n\n expect(result.current.elicitation).not.toBeNull();\n\n act(() => {\n result.current.setElicitation(null);\n });\n\n expect(result.current.elicitation).toBeNull();\n });\n });\n});\n"]}
@@ -117,7 +117,6 @@ export declare class MCPClient {
117
117
  */
118
118
  listTools(): Promise<MCPToolSpec[]>;
119
119
  getServerCapabilities(): {
120
- [x: string]: unknown;
121
120
  experimental?: {
122
121
  [x: string]: object;
123
122
  } | undefined;
@@ -135,19 +134,13 @@ export declare class MCPClient {
135
134
  } | undefined;
136
135
  tasks?: {
137
136
  [x: string]: unknown;
138
- list?: {
139
- [x: string]: unknown;
140
- } | undefined;
141
- cancel?: {
142
- [x: string]: unknown;
143
- } | undefined;
137
+ list?: object | undefined;
138
+ cancel?: object | undefined;
144
139
  requests?: {
145
140
  [x: string]: unknown;
146
141
  tools?: {
147
142
  [x: string]: unknown;
148
- call?: {
149
- [x: string]: unknown;
150
- } | undefined;
143
+ call?: object | undefined;
151
144
  } | undefined;
152
145
  } | undefined;
153
146
  } | undefined;
@@ -156,10 +149,12 @@ export declare class MCPClient {
156
149
  version: string;
157
150
  name: string;
158
151
  websiteUrl?: string | undefined;
152
+ description?: string | undefined;
159
153
  icons?: {
160
154
  src: string;
161
155
  mimeType?: string | undefined;
162
156
  sizes?: string[] | undefined;
157
+ theme?: "light" | "dark" | undefined;
163
158
  }[] | undefined;
164
159
  title?: string | undefined;
165
160
  } | undefined;
@@ -185,5 +180,6 @@ export interface MCPToolSpec {
185
180
  name: string;
186
181
  description?: string;
187
182
  inputSchema?: JSONSchema7;
183
+ maxCalls?: number;
188
184
  }
189
185
  //# sourceMappingURL=mcp-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{ type OAuthClientProvider } from \"@modelcontextprotocol/sdk/client/auth.js\";\nimport { Client } from \"@modelcontextprotocol/sdk/client/index.js\";\nimport { SSEClientTransport } from \"@modelcontextprotocol/sdk/client/sse.js\";\nimport { StreamableHTTPClientTransport } from \"@modelcontextprotocol/sdk/client/streamableHttp.js\";\nimport type { RequestHandlerExtra } from \"@modelcontextprotocol/sdk/shared/protocol.js\";\nimport {\n ClientNotification,\n ClientRequest,\n CreateMessageRequest,\n CreateMessageRequestSchema,\n CreateMessageResult,\n ElicitRequest,\n ElicitRequestSchema,\n ElicitResult,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport { JSONSchema7 } from \"json-schema\";\nimport { MCPTransport } from \"../model/mcp-server-info\";\n\n// Re-export for backwards compatibility\nexport { MCPTransport };\n\n/**\n * Handler for MCP elicitation requests.\n * Receives the elicit request and a RequestHandlerExtra containing an AbortSignal that fires when the request is cancelled.\n * @param request - The elicitation request from the server\n * @param extra - Additional context including AbortSignal for cancellation\n * @returns Promise resolving to the elicitation result\n * @example\n * ```typescript\n * const handler: MCPElicitationHandler = async (request, extra) => {\n * // Listen for cancellation\n * extra.signal.addEventListener('abort', () => {\n * console.log('Request cancelled');\n * });\n *\n * // Return user's response\n * return {\n * action: 'accept',\n * content: { name: 'John' }\n * };\n * };\n * ```\n */\nexport type MCPElicitationHandler = (\n e: ElicitRequest,\n extra: RequestHandlerExtra<ClientRequest, ClientNotification>,\n) => Promise<ElicitResult>;\n\n/**\n * Handler for MCP sampling requests (create_message).\n * Receives the sampling request and a RequestHandlerExtra containing an AbortSignal that fires when the request is cancelled.\n * @param request - The sampling/create_message request from the server\n * @param extra - Additional context including AbortSignal for cancellation\n * @returns Promise resolving to the sampling result\n */\nexport type MCPSamplingHandler = (\n e: CreateMessageRequest,\n extra: RequestHandlerExtra<ClientRequest, ClientNotification>,\n) => Promise<CreateMessageResult>;\n\n/**\n * Handlers for MCP requests - these are only used if the server supports the corresponding capabilities\n * @param elicitation - Handler for elicitation requests (receives request and RequestHandlerExtra with AbortSignal)\n * @param sampling - Handler for sampling requests (receives request and RequestHandlerExtra with AbortSignal)\n * @example\n * ```typescript\n * const mcp = await MCPClient.create(\n * 'https://api.example.com/mcp',\n * MCPTransport.HTTP,\n * {},\n * undefined,\n * undefined,\n * {\n * elicitation: (e, extra) => Promise.resolve({...}),\n * },\n * );\n * ```\n */\nexport interface MCPHandlers {\n elicitation: MCPElicitationHandler;\n sampling: MCPSamplingHandler;\n}\n\n/**\n * A client for interacting with MCP (Model Context Protocol) servers.\n * Provides a simple interface for listing and calling tools exposed by the server.\n * @example\n * ```typescript\n * const mcp = await MCPClient.create('https://api.example.com/mcp');\n * const tools = await mcp.listTools();\n * const result = await mcp.callTool('toolName', { arg1: 'value1' });\n * ```\n */\nexport class MCPClient {\n /**\n * The underlying MCP client\n *\n * Be careful not to mutate the client directly, use the methods provided instead.\n */\n client: Client;\n private transport: SSEClientTransport | StreamableHTTPClientTransport;\n private transportType: MCPTransport;\n public sessionId?: string;\n private endpoint: string;\n private headers: Record<string, string>;\n private authProvider?: OAuthClientProvider;\n private handlers: Partial<MCPHandlers>;\n\n /**\n * Private constructor to enforce using the static create method.\n * @param endpoint - The URL of the MCP server to connect to\n * @param transportType - The transport to use for the MCP client\n * @param headers - Optional custom headers to include in requests\n */\n private constructor(\n endpoint: string,\n transportType: MCPTransport,\n headers?: Record<string, string>,\n authProvider?: OAuthClientProvider,\n sessionId?: string,\n handlers: Partial<MCPHandlers> = {},\n ) {\n this.endpoint = endpoint;\n this.headers = headers ?? {};\n this.authProvider = authProvider;\n this.transportType = transportType;\n this.handlers = handlers;\n this.transport = this.initializeTransport(sessionId);\n this.client = this.initializeClient();\n }\n\n /**\n * Creates and initializes a new MCPClient instance. This is the recommended\n * way to create an MCPClient as it handles both instantiation and connection\n * setup.\n * @param endpoint - The URL of the MCP server to connect to\n * @param transportType - The transport type to use for the MCP client. Defaults to HTTP.\n * @param headers - Optional custom headers to include in requests\n * @param authProvider - Optional auth provider to use for authentication\n * @param sessionId - Optional session id to use for the MCP client - if not\n * provided, a new session will be created\n * @returns A connected MCPClient instance ready for use\n * @throws {Error} Will throw an error if connection fails\n */\n static async create(\n endpoint: string,\n transportType: MCPTransport = MCPTransport.HTTP,\n headers: Record<string, string> | undefined,\n authProvider: OAuthClientProvider | undefined,\n sessionId: string | undefined,\n handlers: Partial<MCPHandlers> = {},\n ): Promise<MCPClient> {\n const mcpClient = new MCPClient(\n endpoint,\n transportType,\n headers,\n authProvider,\n sessionId,\n handlers,\n );\n await mcpClient.client.connect(mcpClient.transport);\n if (\"sessionId\" in mcpClient.transport) {\n mcpClient.sessionId = mcpClient.transport.sessionId;\n }\n return mcpClient;\n }\n\n private initializeTransport(sessionId: string | undefined) {\n if (this.transportType === MCPTransport.SSE) {\n return new SSEClientTransport(new URL(this.endpoint), {\n authProvider: this.authProvider,\n requestInit: { headers: this.headers },\n });\n } else {\n return new StreamableHTTPClientTransport(new URL(this.endpoint), {\n authProvider: this.authProvider,\n requestInit: { headers: this.headers },\n sessionId,\n });\n }\n }\n\n /**\n * Initializes the MCP client with the appropriate capabilities and handlers\n * @returns The initialized MCP client\n */\n private initializeClient() {\n const elicitationCapability = this.handlers.elicitation\n ? { elicitation: {} }\n : {};\n const samplingCapability = this.handlers.sampling ? { sampling: {} } : {};\n const client = new Client(\n {\n name: \"tambo-mcp-client\",\n version: \"1.0.0\",\n },\n {\n capabilities: {\n ...elicitationCapability,\n ...samplingCapability,\n },\n },\n );\n\n if (this.handlers.elicitation) {\n client.setRequestHandler(ElicitRequestSchema, this.handlers.elicitation);\n }\n if (this.handlers.sampling) {\n client.setRequestHandler(\n CreateMessageRequestSchema,\n this.handlers.sampling,\n );\n }\n return client;\n }\n\n /**\n * Retrieves a complete list of all available tools from the MCP server.\n * Handles pagination automatically by following cursors until all tools are fetched.\n * @returns A complete list of all available tools and their descriptions\n * @throws {Error} Will throw an error if any server request fails during pagination\n */\n async listTools(): Promise<MCPToolSpec[]> {\n const allTools: MCPToolSpec[] = [];\n let hasMore = true;\n let cursor: string | undefined = undefined;\n\n while (hasMore) {\n const response = await this.client.listTools({ cursor }, {});\n allTools.push(\n ...response.tools.map((tool): MCPToolSpec => {\n // make sure the right type is used\n const inputSchemaType: string = tool.inputSchema.type;\n if (inputSchemaType !== \"object\") {\n throw new Error(\n `Input schema for tool ${tool.name} is not an object`,\n );\n }\n\n return {\n name: tool.name,\n description: tool.description,\n inputSchema: tool.inputSchema as JSONSchema7,\n };\n }),\n );\n\n if (response.nextCursor) {\n cursor = response.nextCursor;\n } else {\n hasMore = false;\n }\n }\n\n return allTools;\n }\n\n getServerCapabilities() {\n return this.client.getServerCapabilities();\n }\n\n getServerVersion() {\n return this.client.getServerVersion();\n }\n\n getInstructions() {\n return this.client.getInstructions();\n }\n\n /**\n * Calls a specific tool on the MCP server with the provided arguments.\n * @param name - The name of the tool to call\n * @param args - Arguments to pass to the tool, must match the tool's expected schema\n * @returns The result from the tool execution\n * @throws {Error} Will throw an error if the tool call fails or if arguments are invalid\n */\n async callTool(\n name: string,\n args: Record<string, unknown>,\n _meta?: Record<string, unknown>,\n ): Promise<MCPToolCallResult> {\n const result = await this.client.callTool({\n name,\n arguments: args,\n _meta,\n });\n return result;\n }\n\n updateElicitationHandler(handler: MCPElicitationHandler | undefined) {\n // Skip if handler hasn't changed\n if (handler === this.handlers.elicitation) {\n return;\n }\n\n // Because we advertise the elicitation capability on initial connection, we can only update\n // an existing handler, not add it if we haven't set it yet.\n if (handler && !this.handlers.elicitation) {\n throw new Error(\"Elicitation handler must be set on create\");\n }\n this.handlers = {\n ...this.handlers,\n elicitation: handler,\n };\n if (!handler) {\n const method = ElicitRequestSchema.shape.method.value;\n this.client.removeRequestHandler(method);\n return;\n }\n this.client.setRequestHandler(ElicitRequestSchema, handler);\n }\n\n updateSamplingHandler(handler: MCPSamplingHandler | undefined) {\n // Skip if handler hasn't changed\n if (handler === this.handlers.sampling) {\n return;\n }\n\n // Because we advertise the sampling capability on initial connection, we can only update\n // an existing handler, not add it if we haven't set it yet.\n if (handler && !this.handlers.sampling) {\n throw new Error(\"Sampling handler must be set on create\");\n }\n this.handlers = {\n ...this.handlers,\n sampling: handler,\n };\n if (!handler) {\n const method = CreateMessageRequestSchema.shape.method.value;\n this.client.removeRequestHandler(method);\n return;\n }\n this.client.setRequestHandler(CreateMessageRequestSchema, handler);\n }\n\n async close() {\n // Not really sure which one of these to close first, but we'll close the\n // transport first so that no requests can come in and hit closing/closed\n // clients\n await this.transport.close();\n await this.client.close();\n }\n}\n\n/**\n * The result of a tool call.\n * This is the same as the result of a tool call in the OpenAI SDK, but is reified here\n */\nexport type MCPToolCallResult = Awaited<\n ReturnType<typeof Client.prototype.callTool>\n>;\n\n// Example usage:\n/*\nconst mcp = await MCPClient.create('https://api.example.com/mcp', MCPTransport.HTTP);\nconst tools = await mcp.listTools();\nconst result = await mcp.callTool('toolName', { arg1: 'value1' });\n*/\n\nexport interface MCPToolSpec {\n name: string;\n description?: string;\n inputSchema?: JSONSchema7;\n}\n"]}
1
+ {"version":3,"file":"mcp-client.js","sourceRoot":"","sources":["../../src/mcp/mcp-client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AAEnG,OAAO,EAIL,0BAA0B,EAG1B,mBAAmB,GAEpB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,wCAAwC;AACxC,OAAO,EAAE,YAAY,EAAE,CAAC;AAgExB;;;;;;;;;GASG;AACH,MAAM,OAAO,SAAS;IACpB;;;;OAIG;IACH,MAAM,CAAS;IACP,SAAS,CAAqD;IAC9D,aAAa,CAAe;IAC7B,SAAS,CAAU;IAClB,QAAQ,CAAS;IACjB,OAAO,CAAyB;IAChC,YAAY,CAA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AAQ;YAChB,QAAQ,EAAE,OAAO;SAClB,CAAC;QACF,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,MAAM,GAAG,0BAA0B,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;YAC7D,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;YACzC,OAAO;QACT,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,0BAA0B,EAAE,OAAO,CAAC,CAAC;IACrE,CAAC;IAED,KAAK,CAAC,KAAK;QACT,yEAAyE;QACzE,yEAAyE;QACzE,UAAU;QACV,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QAC7B,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF","sourcesContent":["import { type OAuthClientProvider } from \"@modelcontextprotocol/sdk/client/auth.js\";\nimport { Client } from \"@modelcontextprotocol/sdk/client/index.js\";\nimport { SSEClientTransport } from \"@modelcontextprotocol/sdk/client/sse.js\";\nimport { StreamableHTTPClientTransport } from \"@modelcontextprotocol/sdk/client/streamableHttp.js\";\nimport type { RequestHandlerExtra } from \"@modelcontextprotocol/sdk/shared/protocol.js\";\nimport {\n ClientNotification,\n ClientRequest,\n CreateMessageRequest,\n CreateMessageRequestSchema,\n CreateMessageResult,\n ElicitRequest,\n ElicitRequestSchema,\n ElicitResult,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport { JSONSchema7 } from \"json-schema\";\nimport { MCPTransport } from \"../model/mcp-server-info\";\n\n// Re-export for backwards compatibility\nexport { MCPTransport };\n\n/**\n * Handler for MCP elicitation requests.\n * Receives the elicit request and a RequestHandlerExtra containing an AbortSignal that fires when the request is cancelled.\n * @param request - The elicitation request from the server\n * @param extra - Additional context including AbortSignal for cancellation\n * @returns Promise resolving to the elicitation result\n * @example\n * ```typescript\n * const handler: MCPElicitationHandler = async (request, extra) => {\n * // Listen for cancellation\n * extra.signal.addEventListener('abort', () => {\n * console.log('Request cancelled');\n * });\n *\n * // Return user's response\n * return {\n * action: 'accept',\n * content: { name: 'John' }\n * };\n * };\n * ```\n */\nexport type MCPElicitationHandler = (\n e: ElicitRequest,\n extra: RequestHandlerExtra<ClientRequest, ClientNotification>,\n) => Promise<ElicitResult>;\n\n/**\n * Handler for MCP sampling requests (create_message).\n * Receives the sampling request and a RequestHandlerExtra containing an AbortSignal that fires when the request is cancelled.\n * @param request - The sampling/create_message request from the server\n * @param extra - Additional context including AbortSignal for cancellation\n * @returns Promise resolving to the sampling result\n */\nexport type MCPSamplingHandler = (\n e: CreateMessageRequest,\n extra: RequestHandlerExtra<ClientRequest, ClientNotification>,\n) => Promise<CreateMessageResult>;\n\n/**\n * Handlers for MCP requests - these are only used if the server supports the corresponding capabilities\n * @param elicitation - Handler for elicitation requests (receives request and RequestHandlerExtra with AbortSignal)\n * @param sampling - Handler for sampling requests (receives request and RequestHandlerExtra with AbortSignal)\n * @example\n * ```typescript\n * const mcp = await MCPClient.create(\n * 'https://api.example.com/mcp',\n * MCPTransport.HTTP,\n * {},\n * undefined,\n * undefined,\n * {\n * elicitation: (e, extra) => Promise.resolve({...}),\n * },\n * );\n * ```\n */\nexport interface MCPHandlers {\n elicitation: MCPElicitationHandler;\n sampling: MCPSamplingHandler;\n}\n\n/**\n * A client for interacting with MCP (Model Context Protocol) servers.\n * Provides a simple interface for listing and calling tools exposed by the server.\n * @example\n * ```typescript\n * const mcp = await MCPClient.create('https://api.example.com/mcp');\n * const tools = await mcp.listTools();\n * const result = await mcp.callTool('toolName', { arg1: 'value1' });\n * ```\n */\nexport class MCPClient {\n /**\n * The underlying MCP client\n *\n * Be careful not to mutate the client directly, use the methods provided instead.\n */\n client: Client;\n private transport: SSEClientTransport | StreamableHTTPClientTransport;\n private transportType: MCPTransport;\n public sessionId?: string;\n private endpoint: string;\n private headers: Record<string, string>;\n private authProvider?: OAuthClientProvider;\n private handlers: Partial<MCPHandlers>;\n\n /**\n * Private constructor to enforce using the static create method.\n * @param endpoint - The URL of the MCP server to connect to\n * @param transportType - The transport to use for the MCP client\n * @param headers - Optional custom headers to include in requests\n */\n private constructor(\n endpoint: string,\n transportType: MCPTransport,\n headers?: Record<string, string>,\n authProvider?: OAuthClientProvider,\n sessionId?: string,\n handlers: Partial<MCPHandlers> = {},\n ) {\n this.endpoint = endpoint;\n this.headers = headers ?? {};\n this.authProvider = authProvider;\n this.transportType = transportType;\n this.handlers = handlers;\n this.transport = this.initializeTransport(sessionId);\n this.client = this.initializeClient();\n }\n\n /**\n * Creates and initializes a new MCPClient instance. This is the recommended\n * way to create an MCPClient as it handles both instantiation and connection\n * setup.\n * @param endpoint - The URL of the MCP server to connect to\n * @param transportType - The transport type to use for the MCP client. Defaults to HTTP.\n * @param headers - Optional custom headers to include in requests\n * @param authProvider - Optional auth provider to use for authentication\n * @param sessionId - Optional session id to use for the MCP client - if not\n * provided, a new session will be created\n * @returns A connected MCPClient instance ready for use\n * @throws {Error} Will throw an error if connection fails\n */\n static async create(\n endpoint: string,\n transportType: MCPTransport = MCPTransport.HTTP,\n headers: Record<string, string> | undefined,\n authProvider: OAuthClientProvider | undefined,\n sessionId: string | undefined,\n handlers: Partial<MCPHandlers> = {},\n ): Promise<MCPClient> {\n const mcpClient = new MCPClient(\n endpoint,\n transportType,\n headers,\n authProvider,\n sessionId,\n handlers,\n );\n await mcpClient.client.connect(mcpClient.transport);\n if (\"sessionId\" in mcpClient.transport) {\n mcpClient.sessionId = mcpClient.transport.sessionId;\n }\n return mcpClient;\n }\n\n private initializeTransport(sessionId: string | undefined) {\n if (this.transportType === MCPTransport.SSE) {\n return new SSEClientTransport(new URL(this.endpoint), {\n authProvider: this.authProvider,\n requestInit: { headers: this.headers },\n });\n } else {\n return new StreamableHTTPClientTransport(new URL(this.endpoint), {\n authProvider: this.authProvider,\n requestInit: { headers: this.headers },\n sessionId,\n });\n }\n }\n\n /**\n * Initializes the MCP client with the appropriate capabilities and handlers\n * @returns The initialized MCP client\n */\n private initializeClient() {\n const elicitationCapability = this.handlers.elicitation\n ? { elicitation: {} }\n : {};\n const samplingCapability = this.handlers.sampling ? { sampling: {} } : {};\n const client = new Client(\n {\n name: \"tambo-mcp-client\",\n version: \"1.0.0\",\n },\n {\n capabilities: {\n ...elicitationCapability,\n ...samplingCapability,\n },\n },\n );\n\n if (this.handlers.elicitation) {\n client.setRequestHandler(ElicitRequestSchema, this.handlers.elicitation);\n }\n if (this.handlers.sampling) {\n client.setRequestHandler(\n CreateMessageRequestSchema,\n this.handlers.sampling,\n );\n }\n return client;\n }\n\n /**\n * Retrieves a complete list of all available tools from the MCP server.\n * Handles pagination automatically by following cursors until all tools are fetched.\n * @returns A complete list of all available tools and their descriptions\n * @throws {Error} Will throw an error if any server request fails during pagination\n */\n async listTools(): Promise<MCPToolSpec[]> {\n const allTools: MCPToolSpec[] = [];\n let hasMore = true;\n let cursor: string | undefined = undefined;\n\n while (hasMore) {\n const response = await this.client.listTools({ cursor }, {});\n allTools.push(\n ...response.tools.map((tool): MCPToolSpec => {\n // make sure the right type is used\n const inputSchemaType: string = tool.inputSchema.type;\n if (inputSchemaType !== \"object\") {\n throw new Error(\n `Input schema for tool ${tool.name} is not an object`,\n );\n }\n\n return {\n name: tool.name,\n description: tool.description,\n inputSchema: tool.inputSchema as JSONSchema7,\n };\n }),\n );\n\n if (response.nextCursor) {\n cursor = response.nextCursor;\n } else {\n hasMore = false;\n }\n }\n\n return allTools;\n }\n\n getServerCapabilities() {\n return this.client.getServerCapabilities();\n }\n\n getServerVersion() {\n return this.client.getServerVersion();\n }\n\n getInstructions() {\n return this.client.getInstructions();\n }\n\n /**\n * Calls a specific tool on the MCP server with the provided arguments.\n * @param name - The name of the tool to call\n * @param args - Arguments to pass to the tool, must match the tool's expected schema\n * @returns The result from the tool execution\n * @throws {Error} Will throw an error if the tool call fails or if arguments are invalid\n */\n async callTool(\n name: string,\n args: Record<string, unknown>,\n _meta?: Record<string, unknown>,\n ): Promise<MCPToolCallResult> {\n const result = await this.client.callTool({\n name,\n arguments: args,\n _meta,\n });\n return result;\n }\n\n updateElicitationHandler(handler: MCPElicitationHandler | undefined) {\n // Skip if handler hasn't changed\n if (handler === this.handlers.elicitation) {\n return;\n }\n\n // Because we advertise the elicitation capability on initial connection, we can only update\n // an existing handler, not add it if we haven't set it yet.\n if (handler && !this.handlers.elicitation) {\n throw new Error(\"Elicitation handler must be set on create\");\n }\n this.handlers = {\n ...this.handlers,\n elicitation: handler,\n };\n if (!handler) {\n const method = ElicitRequestSchema.shape.method.value;\n this.client.removeRequestHandler(method);\n return;\n }\n this.client.setRequestHandler(ElicitRequestSchema, handler);\n }\n\n updateSamplingHandler(handler: MCPSamplingHandler | undefined) {\n // Skip if handler hasn't changed\n if (handler === this.handlers.sampling) {\n return;\n }\n\n // Because we advertise the sampling capability on initial connection, we can only update\n // an existing handler, not add it if we haven't set it yet.\n if (handler && !this.handlers.sampling) {\n throw new Error(\"Sampling handler must be set on create\");\n }\n this.handlers = {\n ...this.handlers,\n sampling: handler,\n };\n if (!handler) {\n const method = CreateMessageRequestSchema.shape.method.value;\n this.client.removeRequestHandler(method);\n return;\n }\n this.client.setRequestHandler(CreateMessageRequestSchema, handler);\n }\n\n async close() {\n // Not really sure which one of these to close first, but we'll close the\n // transport first so that no requests can come in and hit closing/closed\n // clients\n await this.transport.close();\n await this.client.close();\n }\n}\n\n/**\n * The result of a tool call.\n * This is the same as the result of a tool call in the OpenAI SDK, but is reified here\n */\nexport type MCPToolCallResult = Awaited<\n ReturnType<typeof Client.prototype.callTool>\n>;\n\n// Example usage:\n/*\nconst mcp = await MCPClient.create('https://api.example.com/mcp', MCPTransport.HTTP);\nconst tools = await mcp.listTools();\nconst result = await mcp.callTool('toolName', { arg1: 'value1' });\n*/\n\nexport interface MCPToolSpec {\n name: string;\n description?: string;\n inputSchema?: JSONSchema7;\n maxCalls?: number;\n}\n"]}
@@ -10,9 +10,7 @@ export type ListResourceItem = ListResourcesResult["resources"][number];
10
10
  /**
11
11
  * Registry resource entry - resources from the local registry (not MCP servers).
12
12
  *
13
- * These entries always have `server === null` and represent resources that
14
- * are registered locally via `TamboRegistryProvider` (static `resources`
15
- * props or dynamic `ResourceSource` functions).
13
+ * These entries always have `server === null`.
16
14
  */
17
15
  export interface RegistryResourceEntry {
18
16
  server: null;
@@ -20,9 +18,6 @@ export interface RegistryResourceEntry {
20
18
  }
21
19
  /**
22
20
  * MCP server resource entry - resources from connected MCP servers.
23
- *
24
- * These entries always have a non-null `server` with connection metadata and
25
- * are produced by the active MCP clients managed by `TamboMcpProvider`.
26
21
  */
27
22
  export interface McpResourceEntry {
28
23
  server: ConnectedMcpServer;
@@ -30,21 +25,18 @@ export interface McpResourceEntry {
30
25
  }
31
26
  /**
32
27
  * Union type for all resource entries returned by `useTamboMcpResourceList`.
33
- *
34
- * - Registry resources have `server === null`.
35
- * - MCP-backed resources have a non-null `server` with connection metadata.
36
28
  */
37
29
  export type ListResourceEntry = RegistryResourceEntry | McpResourceEntry;
38
30
  /**
39
- * Type guard for narrowing a `ListResourceEntry` to an MCP-backed resource
40
- * (entries where `server` is non-null).
31
+ * Type guard for narrowing a `ListResourceEntry` to an MCP-backed resource.
41
32
  */
42
33
  export declare function isMcpResourceEntry(entry: ListResourceEntry): entry is McpResourceEntry;
43
34
  /**
44
35
  * Hook to get the prompts for all the registered MCP servers.
36
+ * @param search - Optional search string to filter prompts by name (case-insensitive).
45
37
  * @returns The prompts for the MCP servers, including the server that the prompt was found on.
46
38
  */
47
- export declare function useTamboMcpPromptList(): {
39
+ export declare function useTamboMcpPromptList(search?: string): {
48
40
  data: {
49
41
  prompt: {
50
42
  name: string;
@@ -61,6 +53,7 @@ export declare function useTamboMcpPromptList(): {
61
53
  src: string;
62
54
  mimeType?: string | undefined;
63
55
  sizes?: string[] | undefined;
56
+ theme?: "light" | "dark" | undefined;
64
57
  }[] | undefined;
65
58
  title?: string | undefined;
66
59
  };
@@ -145,6 +138,7 @@ export declare function useTamboMcpPrompt(promptName: string | undefined, args?:
145
138
  src: string;
146
139
  mimeType?: string | undefined;
147
140
  sizes?: string[] | undefined;
141
+ theme?: "light" | "dark" | undefined;
148
142
  }[] | undefined;
149
143
  title?: string | undefined;
150
144
  } | {
@@ -176,8 +170,8 @@ export declare function useTamboMcpPrompt(promptName: string | undefined, args?:
176
170
  }[];
177
171
  _meta?: {
178
172
  [x: string]: unknown;
173
+ progressToken?: string | number | undefined;
179
174
  "io.modelcontextprotocol/related-task"?: {
180
- [x: string]: unknown;
181
175
  taskId: string;
182
176
  } | undefined;
183
177
  } | undefined;
@@ -185,54 +179,12 @@ export declare function useTamboMcpPrompt(promptName: string | undefined, args?:
185
179
  } | null, Error>;
186
180
  /**
187
181
  * Hook to get the resources for all the registered MCP servers and registry.
182
+ * @param search - Optional search string. For MCP servers, results are filtered locally after fetching.
183
+ * For registry dynamic sources, the search is passed to listResources(search) for dynamic generation.
188
184
  * @returns The resources from MCP servers and the local registry, including the server that the resource was found on (null for registry resources).
189
185
  */
190
- export declare function useTamboMcpResourceList(): {
191
- data: ({
192
- resource: {
193
- uri: string;
194
- name: string;
195
- description?: string | undefined;
196
- mimeType?: string | undefined;
197
- annotations?: {
198
- audience?: ("user" | "assistant")[] | undefined;
199
- priority?: number | undefined;
200
- lastModified?: string | undefined;
201
- } | undefined;
202
- _meta?: {
203
- [x: string]: unknown;
204
- } | undefined;
205
- icons?: {
206
- src: string;
207
- mimeType?: string | undefined;
208
- sizes?: string[] | undefined;
209
- }[] | undefined;
210
- title?: string | undefined;
211
- };
212
- server: null;
213
- } | {
214
- resource: {
215
- uri: string;
216
- name: string;
217
- description?: string | undefined;
218
- mimeType?: string | undefined;
219
- annotations?: {
220
- audience?: ("user" | "assistant")[] | undefined;
221
- priority?: number | undefined;
222
- lastModified?: string | undefined;
223
- } | undefined;
224
- _meta?: {
225
- [x: string]: unknown;
226
- } | undefined;
227
- icons?: {
228
- src: string;
229
- mimeType?: string | undefined;
230
- sizes?: string[] | undefined;
231
- }[] | undefined;
232
- title?: string | undefined;
233
- };
234
- server: ConnectedMcpServer;
235
- })[];
186
+ export declare function useTamboMcpResourceList(search?: string): {
187
+ data: ListResourceEntry[];
236
188
  error: Error | null;
237
189
  errors: Error[];
238
190
  isPending: boolean;
@@ -270,8 +222,8 @@ export declare function useTamboMcpResource(resourceUri: string | undefined): Us
270
222
  })[];
271
223
  _meta?: {
272
224
  [x: string]: unknown;
225
+ progressToken?: string | number | undefined;
273
226
  "io.modelcontextprotocol/related-task"?: {
274
- [x: string]: unknown;
275
227
  taskId: string;
276
228
  } | undefined;
277
229
  } | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-hooks.d.ts","sourceRoot":"","sources":["../../src/mcp/mcp-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EAEzB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAIvD,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,SAAS,EAEf,MAAM,sBAAsB,CAAC;AAE9B,MAAM,MAAM,cAAc,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAClE,MAAM,WAAW,eAAe;IAE9B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,MAAM,EAAE,cAAc,CAAC;CACxB;AAED,MAAM,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAExE;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,IAAI,CAAC;IACb,QAAQ,EAAE,gBAAgB,CAAC;CAC5B;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,QAAQ,EAAE,gBAAgB,CAAC;CAC5B;AAED;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,qBAAqB,GAAG,gB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