@tambo-ai/react 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (457) hide show
  1. package/dist/context-helpers/current-interactables-context-helper.d.ts +16 -2
  2. package/dist/context-helpers/current-interactables-context-helper.d.ts.map +1 -1
  3. package/dist/context-helpers/current-interactables-context-helper.js.map +1 -1
  4. package/dist/context-helpers/current-interactables-context-helper.test.d.ts +2 -0
  5. package/dist/context-helpers/current-interactables-context-helper.test.d.ts.map +1 -0
  6. package/dist/context-helpers/current-interactables-context-helper.test.js +70 -0
  7. package/dist/context-helpers/current-interactables-context-helper.test.js.map +1 -0
  8. package/dist/mcp/elicitation.d.ts +3 -37
  9. package/dist/mcp/elicitation.d.ts.map +1 -1
  10. package/dist/mcp/elicitation.js +7 -24
  11. package/dist/mcp/elicitation.js.map +1 -1
  12. package/dist/mcp/index.d.ts +4 -4
  13. package/dist/mcp/index.d.ts.map +1 -1
  14. package/dist/mcp/index.js +2 -2
  15. package/dist/mcp/index.js.map +1 -1
  16. package/dist/mcp/mcp-client.test.js +17 -17
  17. package/dist/mcp/mcp-client.test.js.map +1 -1
  18. package/dist/mcp/mcp-hooks.d.ts.map +1 -1
  19. package/dist/mcp/mcp-hooks.js +8 -5
  20. package/dist/mcp/mcp-hooks.js.map +1 -1
  21. package/dist/mcp/mcp-hooks.test.js +30 -29
  22. package/dist/mcp/mcp-hooks.test.js.map +1 -1
  23. package/dist/mcp/tambo-mcp-provider.d.ts +6 -9
  24. package/dist/mcp/tambo-mcp-provider.d.ts.map +1 -1
  25. package/dist/mcp/tambo-mcp-provider.js +9 -13
  26. package/dist/mcp/tambo-mcp-provider.js.map +1 -1
  27. package/dist/mcp/tambo-mcp-provider.test.js +26 -25
  28. package/dist/mcp/tambo-mcp-provider.test.js.map +1 -1
  29. package/dist/mcp/use-mcp-servers.test.js +2 -1
  30. package/dist/mcp/use-mcp-servers.test.js.map +1 -1
  31. package/dist/model/component-metadata.d.ts +7 -372
  32. package/dist/model/component-metadata.d.ts.map +1 -1
  33. package/dist/model/component-metadata.js.map +1 -1
  34. package/dist/model/validate-input.test.d.ts +2 -0
  35. package/dist/model/validate-input.test.d.ts.map +1 -0
  36. package/dist/model/validate-input.test.js +38 -0
  37. package/dist/model/validate-input.test.js.map +1 -0
  38. package/dist/providers/tambo-interactable-provider.d.ts +7 -7
  39. package/dist/providers/tambo-registry-provider.d.ts +1 -1
  40. package/dist/providers/tambo-registry-provider.d.ts.map +1 -1
  41. package/dist/providers/tambo-registry-provider.js.map +1 -1
  42. package/dist/providers/tambo-registry-schema-compat.test.js +4 -4
  43. package/dist/providers/tambo-registry-schema-compat.test.js.map +1 -1
  44. package/dist/schema/index.d.ts +2 -4
  45. package/dist/schema/index.d.ts.map +1 -1
  46. package/dist/schema/index.js +9 -11
  47. package/dist/schema/index.js.map +1 -1
  48. package/dist/schema/json-schema.d.ts +1 -17
  49. package/dist/schema/json-schema.d.ts.map +1 -1
  50. package/dist/schema/json-schema.js +5 -69
  51. package/dist/schema/json-schema.js.map +1 -1
  52. package/dist/schema/schema.test.js +24 -25
  53. package/dist/schema/schema.test.js.map +1 -1
  54. package/dist/schema/standard-schema.test.js +25 -25
  55. package/dist/schema/standard-schema.test.js.map +1 -1
  56. package/dist/schema/validate.test.js +33 -33
  57. package/dist/schema/validate.test.js.map +1 -1
  58. package/dist/testing/tools.d.ts +4 -4
  59. package/dist/testing/tools.test.d.ts +2 -0
  60. package/dist/testing/tools.test.d.ts.map +1 -0
  61. package/dist/testing/tools.test.js +60 -0
  62. package/dist/testing/tools.test.js.map +1 -0
  63. package/dist/util/mcp-server-utils.d.ts +1 -1
  64. package/dist/util/mcp-server-utils.d.ts.map +1 -1
  65. package/dist/util/mcp-server-utils.js +4 -4
  66. package/dist/util/mcp-server-utils.js.map +1 -1
  67. package/dist/util/mcp-server-utils.test.js +27 -27
  68. package/dist/util/mcp-server-utils.test.js.map +1 -1
  69. package/dist/util/registry.js +1 -1
  70. package/dist/util/registry.js.map +1 -1
  71. package/dist/util/resource-content-resolver.js +5 -5
  72. package/dist/util/resource-content-resolver.js.map +1 -1
  73. package/dist/util/resource-content-resolver.test.js +6 -6
  74. package/dist/util/resource-content-resolver.test.js.map +1 -1
  75. package/dist/util/tool-caller.test.d.ts +2 -0
  76. package/dist/util/tool-caller.test.d.ts.map +1 -0
  77. package/dist/util/tool-caller.test.js +71 -0
  78. package/dist/util/tool-caller.test.js.map +1 -0
  79. package/dist/v1/__tests__/v1-interactables.test.js +1 -0
  80. package/dist/v1/__tests__/v1-interactables.test.js.map +1 -1
  81. package/dist/v1/hooks/use-tambo-v1-auth-state.d.ts +1 -1
  82. package/dist/v1/hooks/use-tambo-v1-auth-state.d.ts.map +1 -1
  83. package/dist/v1/hooks/use-tambo-v1-auth-state.js.map +1 -1
  84. package/dist/v1/hooks/use-tambo-v1-component-state.js +2 -2
  85. package/dist/v1/hooks/use-tambo-v1-component-state.js.map +1 -1
  86. package/dist/v1/hooks/use-tambo-v1-component-state.test.js +1 -1
  87. package/dist/v1/hooks/use-tambo-v1-component-state.test.js.map +1 -1
  88. package/dist/v1/hooks/use-tambo-v1-send-message.d.ts +1 -1
  89. package/dist/v1/hooks/use-tambo-v1-send-message.d.ts.map +1 -1
  90. package/dist/v1/hooks/use-tambo-v1-send-message.js +17 -17
  91. package/dist/v1/hooks/use-tambo-v1-send-message.js.map +1 -1
  92. package/dist/v1/hooks/use-tambo-v1-send-message.test.js +1 -1
  93. package/dist/v1/hooks/use-tambo-v1-send-message.test.js.map +1 -1
  94. package/dist/v1/hooks/use-tambo-v1-stream-status.js +2 -2
  95. package/dist/v1/hooks/use-tambo-v1-stream-status.js.map +1 -1
  96. package/dist/v1/hooks/use-tambo-v1-stream-status.test.js +9 -5
  97. package/dist/v1/hooks/use-tambo-v1-stream-status.test.js.map +1 -1
  98. package/dist/v1/hooks/use-tambo-v1-suggestions.js +2 -2
  99. package/dist/v1/hooks/use-tambo-v1-suggestions.js.map +1 -1
  100. package/dist/v1/hooks/use-tambo-v1-thread-input.test.js +1 -0
  101. package/dist/v1/hooks/use-tambo-v1-thread-input.test.js.map +1 -1
  102. package/dist/v1/hooks/use-tambo-v1.d.ts +7 -6
  103. package/dist/v1/hooks/use-tambo-v1.d.ts.map +1 -1
  104. package/dist/v1/hooks/use-tambo-v1.js +2 -2
  105. package/dist/v1/hooks/use-tambo-v1.js.map +1 -1
  106. package/dist/v1/hooks/use-tambo-v1.test.js +23 -23
  107. package/dist/v1/hooks/use-tambo-v1.test.js.map +1 -1
  108. package/dist/v1/index.d.ts +6 -6
  109. package/dist/v1/index.d.ts.map +1 -1
  110. package/dist/v1/index.js +2 -2
  111. package/dist/v1/index.js.map +1 -1
  112. package/dist/v1/providers/tambo-v1-provider.d.ts +2 -1
  113. package/dist/v1/providers/tambo-v1-provider.d.ts.map +1 -1
  114. package/dist/v1/providers/tambo-v1-provider.js +2 -0
  115. package/dist/v1/providers/tambo-v1-provider.js.map +1 -1
  116. package/dist/v1/providers/tambo-v1-stream-context.d.ts +2 -2
  117. package/dist/v1/providers/tambo-v1-stream-context.d.ts.map +1 -1
  118. package/dist/v1/providers/tambo-v1-stream-context.js +9 -9
  119. package/dist/v1/providers/tambo-v1-stream-context.js.map +1 -1
  120. package/dist/v1/providers/tambo-v1-stream-context.test.js +35 -0
  121. package/dist/v1/providers/tambo-v1-stream-context.test.js.map +1 -1
  122. package/dist/v1/providers/tambo-v1-stub-provider.d.ts +1 -1
  123. package/dist/v1/providers/tambo-v1-stub-provider.d.ts.map +1 -1
  124. package/dist/v1/providers/tambo-v1-stub-provider.js +1 -1
  125. package/dist/v1/providers/tambo-v1-stub-provider.js.map +1 -1
  126. package/dist/v1/providers/tambo-v1-stub-provider.test.js.map +1 -1
  127. package/dist/v1/providers/tambo-v1-thread-input-provider.d.ts +1 -1
  128. package/dist/v1/providers/tambo-v1-thread-input-provider.d.ts.map +1 -1
  129. package/dist/v1/providers/tambo-v1-thread-input-provider.js +2 -2
  130. package/dist/v1/providers/tambo-v1-thread-input-provider.js.map +1 -1
  131. package/dist/v1/types/event.test.js +13 -13
  132. package/dist/v1/types/event.test.js.map +1 -1
  133. package/dist/v1/types/message.d.ts +12 -109
  134. package/dist/v1/types/message.d.ts.map +1 -1
  135. package/dist/v1/types/message.js +0 -7
  136. package/dist/v1/types/message.js.map +1 -1
  137. package/dist/v1/utils/event-accumulator.test.js +183 -184
  138. package/dist/v1/utils/event-accumulator.test.js.map +1 -1
  139. package/dist/v1/utils/json-patch.test.js +4 -4
  140. package/dist/v1/utils/json-patch.test.js.map +1 -1
  141. package/dist/v1/utils/keyed-throttle.test.js +12 -12
  142. package/dist/v1/utils/keyed-throttle.test.js.map +1 -1
  143. package/dist/v1/utils/registry-conversion.test.js +13 -13
  144. package/dist/v1/utils/registry-conversion.test.js.map +1 -1
  145. package/dist/v1/utils/stream-handler.test.js +5 -5
  146. package/dist/v1/utils/stream-handler.test.js.map +1 -1
  147. package/dist/v1/utils/tool-call-tracker.test.js +15 -9
  148. package/dist/v1/utils/tool-call-tracker.test.js.map +1 -1
  149. package/dist/v1/utils/tool-executor.test.js +25 -26
  150. package/dist/v1/utils/tool-executor.test.js.map +1 -1
  151. package/dist/v1/utils/unstrictify.test.js +16 -16
  152. package/dist/v1/utils/unstrictify.test.js.map +1 -1
  153. package/esm/context-helpers/current-interactables-context-helper.d.ts +16 -2
  154. package/esm/context-helpers/current-interactables-context-helper.d.ts.map +1 -1
  155. package/esm/context-helpers/current-interactables-context-helper.js.map +1 -1
  156. package/esm/context-helpers/current-interactables-context-helper.test.d.ts +2 -0
  157. package/esm/context-helpers/current-interactables-context-helper.test.d.ts.map +1 -0
  158. package/esm/context-helpers/current-interactables-context-helper.test.js +68 -0
  159. package/esm/context-helpers/current-interactables-context-helper.test.js.map +1 -0
  160. package/esm/mcp/elicitation.d.ts +3 -37
  161. package/esm/mcp/elicitation.d.ts.map +1 -1
  162. package/esm/mcp/elicitation.js +4 -24
  163. package/esm/mcp/elicitation.js.map +1 -1
  164. package/esm/mcp/index.d.ts +4 -4
  165. package/esm/mcp/index.d.ts.map +1 -1
  166. package/esm/mcp/index.js +1 -1
  167. package/esm/mcp/index.js.map +1 -1
  168. package/esm/mcp/mcp-client.test.js +1 -1
  169. package/esm/mcp/mcp-client.test.js.map +1 -1
  170. package/esm/mcp/mcp-hooks.d.ts.map +1 -1
  171. package/esm/mcp/mcp-hooks.js +4 -1
  172. package/esm/mcp/mcp-hooks.js.map +1 -1
  173. package/esm/mcp/mcp-hooks.test.js +3 -2
  174. package/esm/mcp/mcp-hooks.test.js.map +1 -1
  175. package/esm/mcp/tambo-mcp-provider.d.ts +6 -9
  176. package/esm/mcp/tambo-mcp-provider.d.ts.map +1 -1
  177. package/esm/mcp/tambo-mcp-provider.js +4 -8
  178. package/esm/mcp/tambo-mcp-provider.js.map +1 -1
  179. package/esm/mcp/tambo-mcp-provider.test.js +3 -2
  180. package/esm/mcp/tambo-mcp-provider.test.js.map +1 -1
  181. package/esm/mcp/use-mcp-servers.test.js +2 -1
  182. package/esm/mcp/use-mcp-servers.test.js.map +1 -1
  183. package/esm/model/component-metadata.d.ts +7 -372
  184. package/esm/model/component-metadata.d.ts.map +1 -1
  185. package/esm/model/component-metadata.js.map +1 -1
  186. package/esm/model/validate-input.test.d.ts +2 -0
  187. package/esm/model/validate-input.test.d.ts.map +1 -0
  188. package/esm/model/validate-input.test.js +36 -0
  189. package/esm/model/validate-input.test.js.map +1 -0
  190. package/esm/providers/tambo-interactable-provider.d.ts +7 -7
  191. package/esm/providers/tambo-registry-provider.d.ts +1 -1
  192. package/esm/providers/tambo-registry-provider.d.ts.map +1 -1
  193. package/esm/providers/tambo-registry-provider.js.map +1 -1
  194. package/esm/providers/tambo-registry-schema-compat.test.js +4 -4
  195. package/esm/providers/tambo-registry-schema-compat.test.js.map +1 -1
  196. package/esm/schema/index.d.ts +2 -4
  197. package/esm/schema/index.d.ts.map +1 -1
  198. package/esm/schema/index.js +2 -4
  199. package/esm/schema/index.js.map +1 -1
  200. package/esm/schema/json-schema.d.ts +1 -17
  201. package/esm/schema/json-schema.d.ts.map +1 -1
  202. package/esm/schema/json-schema.js +2 -67
  203. package/esm/schema/json-schema.js.map +1 -1
  204. package/esm/schema/schema.test.js +1 -2
  205. package/esm/schema/schema.test.js.map +1 -1
  206. package/esm/schema/standard-schema.test.js +1 -1
  207. package/esm/schema/standard-schema.test.js.map +1 -1
  208. package/esm/schema/validate.test.js +1 -1
  209. package/esm/schema/validate.test.js.map +1 -1
  210. package/esm/testing/tools.d.ts +4 -4
  211. package/esm/testing/tools.test.d.ts +2 -0
  212. package/esm/testing/tools.test.d.ts.map +1 -0
  213. package/esm/testing/tools.test.js +58 -0
  214. package/esm/testing/tools.test.js.map +1 -0
  215. package/esm/util/mcp-server-utils.d.ts +1 -1
  216. package/esm/util/mcp-server-utils.d.ts.map +1 -1
  217. package/esm/util/mcp-server-utils.js +1 -1
  218. package/esm/util/mcp-server-utils.js.map +1 -1
  219. package/esm/util/mcp-server-utils.test.js +1 -1
  220. package/esm/util/mcp-server-utils.test.js.map +1 -1
  221. package/esm/util/registry.js +1 -1
  222. package/esm/util/registry.js.map +1 -1
  223. package/esm/util/resource-content-resolver.js +1 -1
  224. package/esm/util/resource-content-resolver.js.map +1 -1
  225. package/esm/util/resource-content-resolver.test.js +2 -2
  226. package/esm/util/resource-content-resolver.test.js.map +1 -1
  227. package/esm/util/tool-caller.test.d.ts +2 -0
  228. package/esm/util/tool-caller.test.d.ts.map +1 -0
  229. package/esm/util/tool-caller.test.js +69 -0
  230. package/esm/util/tool-caller.test.js.map +1 -0
  231. package/esm/v1/__tests__/v1-interactables.test.js +1 -0
  232. package/esm/v1/__tests__/v1-interactables.test.js.map +1 -1
  233. package/esm/v1/hooks/use-tambo-v1-auth-state.d.ts +1 -1
  234. package/esm/v1/hooks/use-tambo-v1-auth-state.d.ts.map +1 -1
  235. package/esm/v1/hooks/use-tambo-v1-auth-state.js.map +1 -1
  236. package/esm/v1/hooks/use-tambo-v1-component-state.js +1 -1
  237. package/esm/v1/hooks/use-tambo-v1-component-state.js.map +1 -1
  238. package/esm/v1/hooks/use-tambo-v1-component-state.test.js +1 -1
  239. package/esm/v1/hooks/use-tambo-v1-component-state.test.js.map +1 -1
  240. package/esm/v1/hooks/use-tambo-v1-send-message.d.ts +1 -1
  241. package/esm/v1/hooks/use-tambo-v1-send-message.d.ts.map +1 -1
  242. package/esm/v1/hooks/use-tambo-v1-send-message.js +6 -6
  243. package/esm/v1/hooks/use-tambo-v1-send-message.js.map +1 -1
  244. package/esm/v1/hooks/use-tambo-v1-send-message.test.js +1 -1
  245. package/esm/v1/hooks/use-tambo-v1-send-message.test.js.map +1 -1
  246. package/esm/v1/hooks/use-tambo-v1-stream-status.js +1 -1
  247. package/esm/v1/hooks/use-tambo-v1-stream-status.js.map +1 -1
  248. package/esm/v1/hooks/use-tambo-v1-stream-status.test.js +9 -5
  249. package/esm/v1/hooks/use-tambo-v1-stream-status.test.js.map +1 -1
  250. package/esm/v1/hooks/use-tambo-v1-suggestions.js +1 -1
  251. package/esm/v1/hooks/use-tambo-v1-suggestions.js.map +1 -1
  252. package/esm/v1/hooks/use-tambo-v1-thread-input.test.js +1 -0
  253. package/esm/v1/hooks/use-tambo-v1-thread-input.test.js.map +1 -1
  254. package/esm/v1/hooks/use-tambo-v1.d.ts +7 -6
  255. package/esm/v1/hooks/use-tambo-v1.d.ts.map +1 -1
  256. package/esm/v1/hooks/use-tambo-v1.js +1 -1
  257. package/esm/v1/hooks/use-tambo-v1.js.map +1 -1
  258. package/esm/v1/hooks/use-tambo-v1.test.js +22 -22
  259. package/esm/v1/hooks/use-tambo-v1.test.js.map +1 -1
  260. package/esm/v1/index.d.ts +6 -6
  261. package/esm/v1/index.d.ts.map +1 -1
  262. package/esm/v1/index.js +1 -1
  263. package/esm/v1/index.js.map +1 -1
  264. package/esm/v1/providers/tambo-v1-provider.d.ts +2 -1
  265. package/esm/v1/providers/tambo-v1-provider.d.ts.map +1 -1
  266. package/esm/v1/providers/tambo-v1-provider.js +2 -0
  267. package/esm/v1/providers/tambo-v1-provider.js.map +1 -1
  268. package/esm/v1/providers/tambo-v1-stream-context.d.ts +2 -2
  269. package/esm/v1/providers/tambo-v1-stream-context.d.ts.map +1 -1
  270. package/esm/v1/providers/tambo-v1-stream-context.js +1 -1
  271. package/esm/v1/providers/tambo-v1-stream-context.js.map +1 -1
  272. package/esm/v1/providers/tambo-v1-stream-context.test.js +35 -0
  273. package/esm/v1/providers/tambo-v1-stream-context.test.js.map +1 -1
  274. package/esm/v1/providers/tambo-v1-stub-provider.d.ts +1 -1
  275. package/esm/v1/providers/tambo-v1-stub-provider.d.ts.map +1 -1
  276. package/esm/v1/providers/tambo-v1-stub-provider.js +1 -1
  277. package/esm/v1/providers/tambo-v1-stub-provider.js.map +1 -1
  278. package/esm/v1/providers/tambo-v1-stub-provider.test.js.map +1 -1
  279. package/esm/v1/providers/tambo-v1-thread-input-provider.d.ts +1 -1
  280. package/esm/v1/providers/tambo-v1-thread-input-provider.d.ts.map +1 -1
  281. package/esm/v1/providers/tambo-v1-thread-input-provider.js +1 -1
  282. package/esm/v1/providers/tambo-v1-thread-input-provider.js.map +1 -1
  283. package/esm/v1/types/event.test.js +1 -1
  284. package/esm/v1/types/event.test.js.map +1 -1
  285. package/esm/v1/types/message.d.ts +12 -109
  286. package/esm/v1/types/message.d.ts.map +1 -1
  287. package/esm/v1/types/message.js +0 -7
  288. package/esm/v1/types/message.js.map +1 -1
  289. package/esm/v1/utils/event-accumulator.test.js +2 -3
  290. package/esm/v1/utils/event-accumulator.test.js.map +1 -1
  291. package/esm/v1/utils/json-patch.test.js +1 -1
  292. package/esm/v1/utils/json-patch.test.js.map +1 -1
  293. package/esm/v1/utils/keyed-throttle.test.js +1 -1
  294. package/esm/v1/utils/keyed-throttle.test.js.map +1 -1
  295. package/esm/v1/utils/registry-conversion.test.js +1 -1
  296. package/esm/v1/utils/registry-conversion.test.js.map +1 -1
  297. package/esm/v1/utils/stream-handler.test.js +1 -1
  298. package/esm/v1/utils/stream-handler.test.js.map +1 -1
  299. package/esm/v1/utils/tool-call-tracker.test.js +9 -3
  300. package/esm/v1/utils/tool-call-tracker.test.js.map +1 -1
  301. package/esm/v1/utils/tool-executor.test.js +1 -2
  302. package/esm/v1/utils/tool-executor.test.js.map +1 -1
  303. package/esm/v1/utils/unstrictify.test.js +1 -1
  304. package/esm/v1/utils/unstrictify.test.js.map +1 -1
  305. package/package.json +10 -11
  306. package/dist/mcp/mcp-client.d.ts +0 -185
  307. package/dist/mcp/mcp-client.d.ts.map +0 -1
  308. package/dist/mcp/mcp-client.js +0 -219
  309. package/dist/mcp/mcp-client.js.map +0 -1
  310. package/dist/mcp/mcp-constants.d.ts +0 -19
  311. package/dist/mcp/mcp-constants.d.ts.map +0 -1
  312. package/dist/mcp/mcp-constants.js +0 -21
  313. package/dist/mcp/mcp-constants.js.map +0 -1
  314. package/dist/model/mcp-server-info.d.ts +0 -76
  315. package/dist/model/mcp-server-info.d.ts.map +0 -1
  316. package/dist/model/mcp-server-info.js +0 -29
  317. package/dist/model/mcp-server-info.js.map +0 -1
  318. package/dist/schema/schema.d.ts +0 -49
  319. package/dist/schema/schema.d.ts.map +0 -1
  320. package/dist/schema/schema.js +0 -129
  321. package/dist/schema/schema.js.map +0 -1
  322. package/dist/schema/standard-schema.d.ts +0 -22
  323. package/dist/schema/standard-schema.d.ts.map +0 -1
  324. package/dist/schema/standard-schema.js +0 -42
  325. package/dist/schema/standard-schema.js.map +0 -1
  326. package/dist/schema/validate.d.ts +0 -14
  327. package/dist/schema/validate.d.ts.map +0 -1
  328. package/dist/schema/validate.js +0 -148
  329. package/dist/schema/validate.js.map +0 -1
  330. package/dist/v1/types/auth.d.ts +0 -24
  331. package/dist/v1/types/auth.d.ts.map +0 -1
  332. package/dist/v1/types/auth.js +0 -3
  333. package/dist/v1/types/auth.js.map +0 -1
  334. package/dist/v1/types/event.d.ts +0 -89
  335. package/dist/v1/types/event.d.ts.map +0 -1
  336. package/dist/v1/types/event.js +0 -57
  337. package/dist/v1/types/event.js.map +0 -1
  338. package/dist/v1/types/thread.d.ts +0 -58
  339. package/dist/v1/types/thread.d.ts.map +0 -1
  340. package/dist/v1/types/thread.js +0 -9
  341. package/dist/v1/types/thread.js.map +0 -1
  342. package/dist/v1/types/tool-choice.d.ts +0 -8
  343. package/dist/v1/types/tool-choice.d.ts.map +0 -1
  344. package/dist/v1/types/tool-choice.js +0 -3
  345. package/dist/v1/types/tool-choice.js.map +0 -1
  346. package/dist/v1/utils/event-accumulator.d.ts +0 -165
  347. package/dist/v1/utils/event-accumulator.d.ts.map +0 -1
  348. package/dist/v1/utils/event-accumulator.js +0 -1277
  349. package/dist/v1/utils/event-accumulator.js.map +0 -1
  350. package/dist/v1/utils/json-patch.d.ts +0 -18
  351. package/dist/v1/utils/json-patch.d.ts.map +0 -1
  352. package/dist/v1/utils/json-patch.js +0 -35
  353. package/dist/v1/utils/json-patch.js.map +0 -1
  354. package/dist/v1/utils/keyed-throttle.d.ts +0 -42
  355. package/dist/v1/utils/keyed-throttle.d.ts.map +0 -1
  356. package/dist/v1/utils/keyed-throttle.js +0 -86
  357. package/dist/v1/utils/keyed-throttle.js.map +0 -1
  358. package/dist/v1/utils/registry-conversion.d.ts +0 -53
  359. package/dist/v1/utils/registry-conversion.d.ts.map +0 -1
  360. package/dist/v1/utils/registry-conversion.js +0 -115
  361. package/dist/v1/utils/registry-conversion.js.map +0 -1
  362. package/dist/v1/utils/stream-handler.d.ts +0 -45
  363. package/dist/v1/utils/stream-handler.d.ts.map +0 -1
  364. package/dist/v1/utils/stream-handler.js +0 -47
  365. package/dist/v1/utils/stream-handler.js.map +0 -1
  366. package/dist/v1/utils/thread-utils.d.ts +0 -16
  367. package/dist/v1/utils/thread-utils.d.ts.map +0 -1
  368. package/dist/v1/utils/thread-utils.js +0 -34
  369. package/dist/v1/utils/thread-utils.js.map +0 -1
  370. package/dist/v1/utils/tool-call-tracker.d.ts +0 -73
  371. package/dist/v1/utils/tool-call-tracker.d.ts.map +0 -1
  372. package/dist/v1/utils/tool-call-tracker.js +0 -180
  373. package/dist/v1/utils/tool-call-tracker.js.map +0 -1
  374. package/dist/v1/utils/tool-executor.d.ts +0 -67
  375. package/dist/v1/utils/tool-executor.d.ts.map +0 -1
  376. package/dist/v1/utils/tool-executor.js +0 -160
  377. package/dist/v1/utils/tool-executor.js.map +0 -1
  378. package/dist/v1/utils/unstrictify.d.ts +0 -32
  379. package/dist/v1/utils/unstrictify.d.ts.map +0 -1
  380. package/dist/v1/utils/unstrictify.js +0 -159
  381. package/dist/v1/utils/unstrictify.js.map +0 -1
  382. package/esm/mcp/mcp-client.d.ts +0 -185
  383. package/esm/mcp/mcp-client.d.ts.map +0 -1
  384. package/esm/mcp/mcp-client.js +0 -216
  385. package/esm/mcp/mcp-client.js.map +0 -1
  386. package/esm/mcp/mcp-constants.d.ts +0 -19
  387. package/esm/mcp/mcp-constants.d.ts.map +0 -1
  388. package/esm/mcp/mcp-constants.js +0 -18
  389. package/esm/mcp/mcp-constants.js.map +0 -1
  390. package/esm/model/mcp-server-info.d.ts +0 -76
  391. package/esm/model/mcp-server-info.d.ts.map +0 -1
  392. package/esm/model/mcp-server-info.js +0 -25
  393. package/esm/model/mcp-server-info.js.map +0 -1
  394. package/esm/schema/schema.d.ts +0 -49
  395. package/esm/schema/schema.d.ts.map +0 -1
  396. package/esm/schema/schema.js +0 -124
  397. package/esm/schema/schema.js.map +0 -1
  398. package/esm/schema/standard-schema.d.ts +0 -22
  399. package/esm/schema/standard-schema.d.ts.map +0 -1
  400. package/esm/schema/standard-schema.js +0 -39
  401. package/esm/schema/standard-schema.js.map +0 -1
  402. package/esm/schema/validate.d.ts +0 -14
  403. package/esm/schema/validate.d.ts.map +0 -1
  404. package/esm/schema/validate.js +0 -145
  405. package/esm/schema/validate.js.map +0 -1
  406. package/esm/v1/types/auth.d.ts +0 -24
  407. package/esm/v1/types/auth.d.ts.map +0 -1
  408. package/esm/v1/types/auth.js +0 -2
  409. package/esm/v1/types/auth.js.map +0 -1
  410. package/esm/v1/types/event.d.ts +0 -89
  411. package/esm/v1/types/event.d.ts.map +0 -1
  412. package/esm/v1/types/event.js +0 -53
  413. package/esm/v1/types/event.js.map +0 -1
  414. package/esm/v1/types/thread.d.ts +0 -58
  415. package/esm/v1/types/thread.d.ts.map +0 -1
  416. package/esm/v1/types/thread.js +0 -8
  417. package/esm/v1/types/thread.js.map +0 -1
  418. package/esm/v1/types/tool-choice.d.ts +0 -8
  419. package/esm/v1/types/tool-choice.d.ts.map +0 -1
  420. package/esm/v1/types/tool-choice.js +0 -2
  421. package/esm/v1/types/tool-choice.js.map +0 -1
  422. package/esm/v1/utils/event-accumulator.d.ts +0 -165
  423. package/esm/v1/utils/event-accumulator.d.ts.map +0 -1
  424. package/esm/v1/utils/event-accumulator.js +0 -1268
  425. package/esm/v1/utils/event-accumulator.js.map +0 -1
  426. package/esm/v1/utils/json-patch.d.ts +0 -18
  427. package/esm/v1/utils/json-patch.d.ts.map +0 -1
  428. package/esm/v1/utils/json-patch.js +0 -32
  429. package/esm/v1/utils/json-patch.js.map +0 -1
  430. package/esm/v1/utils/keyed-throttle.d.ts +0 -42
  431. package/esm/v1/utils/keyed-throttle.d.ts.map +0 -1
  432. package/esm/v1/utils/keyed-throttle.js +0 -83
  433. package/esm/v1/utils/keyed-throttle.js.map +0 -1
  434. package/esm/v1/utils/registry-conversion.d.ts +0 -53
  435. package/esm/v1/utils/registry-conversion.d.ts.map +0 -1
  436. package/esm/v1/utils/registry-conversion.js +0 -109
  437. package/esm/v1/utils/registry-conversion.js.map +0 -1
  438. package/esm/v1/utils/stream-handler.d.ts +0 -45
  439. package/esm/v1/utils/stream-handler.d.ts.map +0 -1
  440. package/esm/v1/utils/stream-handler.js +0 -44
  441. package/esm/v1/utils/stream-handler.js.map +0 -1
  442. package/esm/v1/utils/thread-utils.d.ts +0 -16
  443. package/esm/v1/utils/thread-utils.d.ts.map +0 -1
  444. package/esm/v1/utils/thread-utils.js +0 -31
  445. package/esm/v1/utils/thread-utils.js.map +0 -1
  446. package/esm/v1/utils/tool-call-tracker.d.ts +0 -73
  447. package/esm/v1/utils/tool-call-tracker.d.ts.map +0 -1
  448. package/esm/v1/utils/tool-call-tracker.js +0 -176
  449. package/esm/v1/utils/tool-call-tracker.js.map +0 -1
  450. package/esm/v1/utils/tool-executor.d.ts +0 -67
  451. package/esm/v1/utils/tool-executor.d.ts.map +0 -1
  452. package/esm/v1/utils/tool-executor.js +0 -154
  453. package/esm/v1/utils/tool-executor.js.map +0 -1
  454. package/esm/v1/utils/unstrictify.d.ts +0 -32
  455. package/esm/v1/utils/unstrictify.d.ts.map +0 -1
  456. package/esm/v1/utils/unstrictify.js +0 -155
  457. package/esm/v1/utils/unstrictify.js.map +0 -1
@@ -1,4 +1,17 @@
1
- import { ContextHelperFn } from "./types";
1
+ import type { ContextHelperFn } from "./types";
2
+ interface InteractableComponentMetadata {
3
+ id: string;
4
+ componentName: string;
5
+ description: string;
6
+ props: unknown;
7
+ propsSchema: string;
8
+ state: unknown;
9
+ isSelectedForInteraction: boolean;
10
+ stateSchema: string;
11
+ }
12
+ export interface InteractablesContext {
13
+ components: InteractableComponentMetadata[];
14
+ }
2
15
  /**
3
16
  * Prebuilt context helper that provides information about all interactable components currently on the page.
4
17
  * This gives the AI awareness of what components it can interact with and their current state.
@@ -24,5 +37,6 @@ export declare const currentInteractablesContextHelper: ContextHelperFn;
24
37
  * @param components Array of interactable components
25
38
  * @returns A context helper function that returns component metadata or null if no components exist
26
39
  */
27
- export declare const createInteractablesContextHelper: (components: unknown[]) => ContextHelperFn;
40
+ export declare const createInteractablesContextHelper: (components: unknown[]) => (() => InteractablesContext | null);
41
+ export {};
28
42
  //# sourceMappingURL=current-interactables-context-helper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"current-interactables-context-helper.d.ts","sourceRoot":"","sources":["../../src/context-helpers/current-interactables-context-helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,iCAAiC,EAAE,eAI/C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,GAC3C,YAAY,OAAO,EAAE,KACpB,eAyCF,CAAC"}
1
+ {"version":3,"file":"current-interactables-context-helper.d.ts","sourceRoot":"","sources":["../../src/context-helpers/current-interactables-context-helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,UAAU,6BAA6B;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,OAAO,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,OAAO,CAAC;IACf,wBAAwB,EAAE,OAAO,CAAC;IAClC,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,6BAA6B,EAAE,CAAC;CAC7C;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,iCAAiC,EAAE,eAI/C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,GAC3C,YAAY,OAAO,EAAE,KACpB,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAyCpC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"current-interactables-context-helper.js","sourceRoot":"","sources":["../../src/context-helpers/current-interactables-context-helper.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;;;GAiBG;AACI,MAAM,iCAAiC,GAAoB,GAAG,EAAE;IACrE,mFAAmF;IACnF,wEAAwE;IACxE,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAJW,QAAA,iCAAiC,qCAI5C;AAEF;;;;;GAKG;AACI,MAAM,gCAAgC,GAAG,CAC9C,UAAq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ACJ,CAAC,CAAC;AA3CW,QAAA,gCAAgC,oCA2C3C","sourcesContent":["import { ContextHelperFn } from \"./types\";\n\n/**\n * Prebuilt context helper that provides information about all interactable components currently on the page.\n * This gives the AI awareness of what components it can interact with and their current state.\n * @returns an object with description and components, or null to skip including this context.\n * To disable this helper, override it with a function that returns null:\n * @example\n * ```tsx\n * // To disable the default interactables context\n * const { addContextHelper } = useTamboContextHelpers();\n * addContextHelper(\"interactables\", () => null);\n *\n * // To customize the context\n * addContextHelper(\"interactables\", () => ({\n * description: \"Custom description\",\n * components: getCustomComponentsSubset()\n * }));\n * ```\n */\nexport const currentInteractablesContextHelper: ContextHelperFn = () => {\n // This will be provided by the interactable provider when it registers this helper\n // Since we're provider-only now, this function gets replaced at runtime\n return null;\n};\n\n/**\n * Creates an interactables context helper with access to the current components.\n * This is used internally by TamboInteractableProvider.\n * @param components Array of interactable components\n * @returns A context helper function that returns component metadata or null if no components exist\n */\nexport const createInteractablesContextHelper = (\n components: unknown[],\n): ContextHelperFn => {\n return () => {\n if (!Array.isArray(components) || components.length === 0) {\n return null; // No interactable components on the page\n }\n\n return {\n components: components.map((component) => {\n // Type guard: ensure component is an object with the expected properties\n if (typeof component !== \"object\" || component === null) {\n return {\n id: \"unknown\",\n componentName: \"unknown\",\n description: \"invalid component\",\n props: undefined,\n propsSchema: \"Not specified\",\n state: undefined,\n isSelectedForInteraction: false,\n stateSchema: \"Not specified\",\n };\n }\n\n const comp = component as Record<string, unknown>;\n return {\n id: String(comp.id ?? \"unknown\"),\n componentName: String(comp.name ?? \"unknown\"),\n description: String(comp.description ?? \"\"),\n props: comp.props,\n propsSchema: comp.propsSchema\n ? \"Available - use component-specific update tools\"\n : \"Not specified\",\n state: comp.state,\n isSelectedForInteraction:\n (comp.isSelectedForInteraction as boolean | undefined) ?? false,\n stateSchema: comp.stateSchema\n ? \"Available - use component-specific update tools\"\n : \"Not specified\",\n };\n }),\n };\n };\n};\n"]}
1
+ {"version":3,"file":"current-interactables-context-hel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,CAAC,CAAC,iDAAiD;wBACnD,CAAC,CAAC,eAAe;oBACnB,KAAK,EAAE,IAAI,CAAC,KAAK;oBACjB,wBAAwB,EACrB,IAAI,CAAC,wBAAgD,IAAI,KAAK;oBACjE,WAAW,EAAE,IAAI,CAAC,WAAW;wBAC3B,CAAC,CAAC,iDAAiD;wBACnD,CAAC,CAAC,eAAe;iBACpB,CAAC;YACJ,CAAC,CAAC;SACH,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC;AA3CW,QAAA,gCAAgC,oCA2C3C","sourcesContent":["import type { ContextHelperFn } from \"./types\";\n\ninterface InteractableComponentMetadata {\n id: string;\n componentName: string;\n description: string;\n props: unknown;\n propsSchema: string;\n state: unknown;\n isSelectedForInteraction: boolean;\n stateSchema: string;\n}\n\nexport interface InteractablesContext {\n components: InteractableComponentMetadata[];\n}\n\n/**\n * Prebuilt context helper that provides information about all interactable components currently on the page.\n * This gives the AI awareness of what components it can interact with and their current state.\n * @returns an object with description and components, or null to skip including this context.\n * To disable this helper, override it with a function that returns null:\n * @example\n * ```tsx\n * // To disable the default interactables context\n * const { addContextHelper } = useTamboContextHelpers();\n * addContextHelper(\"interactables\", () => null);\n *\n * // To customize the context\n * addContextHelper(\"interactables\", () => ({\n * description: \"Custom description\",\n * components: getCustomComponentsSubset()\n * }));\n * ```\n */\nexport const currentInteractablesContextHelper: ContextHelperFn = () => {\n // This will be provided by the interactable provider when it registers this helper\n // Since we're provider-only now, this function gets replaced at runtime\n return null;\n};\n\n/**\n * Creates an interactables context helper with access to the current components.\n * This is used internally by TamboInteractableProvider.\n * @param components Array of interactable components\n * @returns A context helper function that returns component metadata or null if no components exist\n */\nexport const createInteractablesContextHelper = (\n components: unknown[],\n): (() => InteractablesContext | null) => {\n return () => {\n if (!Array.isArray(components) || components.length === 0) {\n return null; // No interactable components on the page\n }\n\n return {\n components: components.map((component) => {\n // Type guard: ensure component is an object with the expected properties\n if (typeof component !== \"object\" || component === null) {\n return {\n id: \"unknown\",\n componentName: \"unknown\",\n description: \"invalid component\",\n props: undefined,\n propsSchema: \"Not specified\",\n state: undefined,\n isSelectedForInteraction: false,\n stateSchema: \"Not specified\",\n };\n }\n\n const comp = component as Record<string, unknown>;\n return {\n id: String(comp.id ?? \"unknown\"),\n componentName: String(comp.name ?? \"unknown\"),\n description: String(comp.description ?? \"\"),\n props: comp.props,\n propsSchema: comp.propsSchema\n ? \"Available - use component-specific update tools\"\n : \"Not specified\",\n state: comp.state,\n isSelectedForInteraction:\n (comp.isSelectedForInteraction as boolean | undefined) ?? false,\n stateSchema: comp.stateSchema\n ? \"Available - use component-specific update tools\"\n : \"Not specified\",\n };\n }),\n };\n };\n};\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=current-interactables-context-helper.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"current-interactables-context-helper.test.d.ts","sourceRoot":"","sources":["../../src/context-helpers/current-interactables-context-helper.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const current_interactables_context_helper_1 = require("./current-interactables-context-helper");
4
+ describe("currentInteractablesContextHelper", () => {
5
+ it("returns null by default (placeholder before provider replaces it)", () => {
6
+ expect((0, current_interactables_context_helper_1.currentInteractablesContextHelper)()).toBeNull();
7
+ });
8
+ });
9
+ describe("createInteractablesContextHelper", () => {
10
+ it("returns null when components array is empty", () => {
11
+ const helper = (0, current_interactables_context_helper_1.createInteractablesContextHelper)([]);
12
+ expect(helper()).toBeNull();
13
+ });
14
+ it("maps valid component objects to metadata", () => {
15
+ const components = [
16
+ {
17
+ id: "comp-1",
18
+ name: "WeatherCard",
19
+ description: "Shows weather",
20
+ props: { city: "NYC" },
21
+ propsSchema: { type: "object" },
22
+ state: { temp: 72 },
23
+ isSelectedForInteraction: true,
24
+ stateSchema: { type: "object" },
25
+ },
26
+ ];
27
+ const helper = (0, current_interactables_context_helper_1.createInteractablesContextHelper)(components);
28
+ const result = helper();
29
+ expect(result).toEqual({
30
+ components: [
31
+ {
32
+ id: "comp-1",
33
+ componentName: "WeatherCard",
34
+ description: "Shows weather",
35
+ props: { city: "NYC" },
36
+ propsSchema: "Available - use component-specific update tools",
37
+ state: { temp: 72 },
38
+ isSelectedForInteraction: true,
39
+ stateSchema: "Available - use component-specific update tools",
40
+ },
41
+ ],
42
+ });
43
+ });
44
+ it("handles invalid (non-object) components gracefully", () => {
45
+ const components = [null, "not-an-object", 42];
46
+ const helper = (0, current_interactables_context_helper_1.createInteractablesContextHelper)(components);
47
+ const result = helper();
48
+ expect(result?.components).toHaveLength(3);
49
+ for (const comp of result?.components ?? []) {
50
+ expect(comp.id).toBe("unknown");
51
+ expect(comp.componentName).toBe("unknown");
52
+ }
53
+ });
54
+ it("uses defaults for missing properties", () => {
55
+ const components = [{}];
56
+ const helper = (0, current_interactables_context_helper_1.createInteractablesContextHelper)(components);
57
+ const result = helper();
58
+ expect(result?.components[0]).toEqual({
59
+ id: "unknown",
60
+ componentName: "unknown",
61
+ description: "",
62
+ props: undefined,
63
+ propsSchema: "Not specified",
64
+ state: undefined,
65
+ isSelectedForInteraction: false,
66
+ stateSchema: "Not specified",
67
+ });
68
+ });
69
+ });
70
+ //# sourceMappingURL=current-interactables-context-helper.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"current-interactables-context-helper.test.js","sourceRoot":"","sources":["../../src/context-helpers/current-interactables-context-helper.test.ts"],"names":[],"mappings":";;AAAA,iGAGgD;AAEhD,QAAQ,CAAC,mCAAmC,EAAE,GAAG,EAAE;IACjD,EAAE,CAAC,mEAAmE,EAAE,GAAG,EAAE;QAC3E,MAAM,CAAC,IAAA,wEAAiC,GAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;IACzD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,kCAAkC,EAAE,GAAG,EAAE;IAChD,EAAE,CAAC,6CAA6C,EAAE,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C;QAC5D,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC;QACxB,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QAC3C,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE,UAAU,IAAI,EAAE,EAAE,CAAC;YAC5C,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAChC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC9C,MAAM,UAAU,GAAG,CAAC,EAAE,CAAC,CAAC;QAExB,MAAM,MAAM,GAAG,IAAA,uEAAgC,EAAC,UAAU,CAAC,CAAC;QAC5D,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC;QACxB,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;YACpC,EAAE,EAAE,SAAS;YACb,aAAa,EAAE,SAAS;YACxB,WAAW,EAAE,EAAE;YACf,KAAK,EAAE,SAAS;YAChB,WAAW,EAAE,eAAe;YAC5B,KAAK,EAAE,SAAS;YAChB,wBAAwB,EAAE,KAAK;YAC/B,WAAW,EAAE,eAAe;SAC7B,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import {\n currentInteractablesContextHelper,\n createInteractablesContextHelper,\n} from \"./current-interactables-context-helper\";\n\ndescribe(\"currentInteractablesContextHelper\", () => {\n it(\"returns null by default (placeholder before provider replaces it)\", () => {\n expect(currentInteractablesContextHelper()).toBeNull();\n });\n});\n\ndescribe(\"createInteractablesContextHelper\", () => {\n it(\"returns null when components array is empty\", () => {\n const helper = createInteractablesContextHelper([]);\n expect(helper()).toBeNull();\n });\n\n it(\"maps valid component objects to metadata\", () => {\n const components = [\n {\n id: \"comp-1\",\n name: \"WeatherCard\",\n description: \"Shows weather\",\n props: { city: \"NYC\" },\n propsSchema: { type: \"object\" },\n state: { temp: 72 },\n isSelectedForInteraction: true,\n stateSchema: { type: \"object\" },\n },\n ];\n\n const helper = createInteractablesContextHelper(components);\n const result = helper();\n expect(result).toEqual({\n components: [\n {\n id: \"comp-1\",\n componentName: \"WeatherCard\",\n description: \"Shows weather\",\n props: { city: \"NYC\" },\n propsSchema: \"Available - use component-specific update tools\",\n state: { temp: 72 },\n isSelectedForInteraction: true,\n stateSchema: \"Available - use component-specific update tools\",\n },\n ],\n });\n });\n\n it(\"handles invalid (non-object) components gracefully\", () => {\n const components = [null, \"not-an-object\", 42];\n\n const helper = createInteractablesContextHelper(components);\n const result = helper();\n expect(result?.components).toHaveLength(3);\n for (const comp of result?.components ?? []) {\n expect(comp.id).toBe(\"unknown\");\n expect(comp.componentName).toBe(\"unknown\");\n }\n });\n\n it(\"uses defaults for missing properties\", () => {\n const components = [{}];\n\n const helper = createInteractablesContextHelper(components);\n const result = helper();\n expect(result?.components[0]).toEqual({\n id: \"unknown\",\n componentName: \"unknown\",\n description: \"\",\n props: undefined,\n propsSchema: \"Not specified\",\n state: undefined,\n isSelectedForInteraction: false,\n stateSchema: \"Not specified\",\n });\n });\n});\n"]}
@@ -1,40 +1,6 @@
1
- import type { ElicitRequestFormParams, PrimitiveSchemaDefinition } from "@modelcontextprotocol/sdk/spec.types.js";
2
- import { MCPElicitationHandler } from "./mcp-client";
3
- /**
4
- * Schema type for elicitation request fields
5
- */
6
- export type ElicitationRequestedSchema = ElicitRequestFormParams["requestedSchema"];
7
- /**
8
- * Elicitation request from MCP server
9
- */
10
- export interface TamboElicitationRequest {
11
- message: string;
12
- requestedSchema: ElicitationRequestedSchema;
13
- /** AbortSignal that fires when the server cancels the request (e.g., timeout) */
14
- signal?: AbortSignal;
15
- }
16
- /**
17
- * Re-export PrimitiveSchemaDefinition for consumers that need to work with schema fields
18
- */
19
- export type { PrimitiveSchemaDefinition };
20
- /**
21
- * Elicitation response to be sent back
22
- */
23
- export interface TamboElicitationResponse {
24
- action: "accept" | "decline" | "cancel";
25
- content?: Record<string, unknown>;
26
- [x: string]: unknown;
27
- }
28
- /**
29
- * Elicitation context state - read-only interface for consumers.
30
- * State management is handled internally by useElicitation hook.
31
- */
32
- export interface ElicitationContextState {
33
- /** Current elicitation request, or null if none active */
34
- elicitation: TamboElicitationRequest | null;
35
- /** Function to call when user responds to elicitation (clears state automatically) */
36
- resolveElicitation: ((response: TamboElicitationResponse) => void) | null;
37
- }
1
+ import type { MCPElicitationHandler, TamboElicitationRequest, TamboElicitationResponse } from "@tambo-ai/client";
2
+ export type { ElicitationRequestedSchema, TamboElicitationRequest, TamboElicitationResponse, ElicitationContextState, PrimitiveSchemaDefinition, } from "@tambo-ai/client";
3
+ export { toElicitationRequestedSchema, hasRequestedSchema, } from "@tambo-ai/client";
38
4
  /**
39
5
  * Internal hook that manages elicitation state and creates a default handler.
40
6
  * This bundles all the state management and handler creation for elicitation.
@@ -1 +1 @@
1
- {"version":3,"file":"elicitation.d.ts","sourceRoot":"","sources":["../../src/mcp/elicitation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,uBAAuB,EACvB,yBAAyB,EAC1B,MAAM,yCAAyC,CAAC;AAQjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAErD;;GAEG;AACH,MAAM,MAAM,0BAA0B,GACpC,uBAAuB,CAAC,iBAAiB,CAAC,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,uBAAuB;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"}
1
+ {"version":3,"file":"elicitation.d.ts","sourceRoot":"","sources":["../../src/mcp/elicitation.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,qBAAqB,EACrB,uBAAuB,EACvB,wBAAwB,EACzB,MAAM,kBAAkB,CAAC;AAO1B,YAAY,EACV,0BAA0B,EAC1B,uBAAuB,EACvB,wBAAwB,EACxB,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,4BAA4B,EAC5B,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAE1B;;;;;;GAMG;AACH,wBAAgB,cAAc;;;oCAId,wBAAwB,KAAK,IAAI;+FAAjC,wBAAwB,KAAK,IAAI;;EAoEhD"}
@@ -1,29 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hasRequestedSchema = exports.toElicitationRequestedSchema = void 0;
3
4
  exports.useElicitation = useElicitation;
4
5
  const react_1 = require("react");
5
- /**
6
- * Narrow the runtime ElicitRequest requestedSchema into the public
7
- * ElicitationRequestedSchema type.
8
- *
9
- * The MCP SDK guarantees that the runtime
10
- * `ElicitRequest["params"]["requestedSchema"]` shape stays aligned with the
11
- * spec-defined `ElicitRequestFormParams["requestedSchema"]`. This helper
12
- * centralizes the cast based on that contract so that if a future SDK version
13
- * ever diverges, we have a single place to tighten the implementation (for
14
- * example with structural validation or normalization).
15
- * @returns requestedSchema as ElicitationRequestedSchema
16
- */
17
- function toElicitationRequestedSchema(value) {
18
- return value;
19
- }
20
- /**
21
- * Type guard for the elicitation form params shape.
22
- * @returns true when params include requestedSchema
23
- */
24
- function hasRequestedSchema(params) {
25
- return "requestedSchema" in params;
26
- }
6
+ const client_1 = require("@tambo-ai/client");
7
+ var client_2 = require("@tambo-ai/client");
8
+ Object.defineProperty(exports, "toElicitationRequestedSchema", { enumerable: true, get: function () { return client_2.toElicitationRequestedSchema; } });
9
+ Object.defineProperty(exports, "hasRequestedSchema", { enumerable: true, get: function () { return client_2.hasRequestedSchema; } });
27
10
  /**
28
11
  * Internal hook that manages elicitation state and creates a default handler.
29
12
  * This bundles all the state management and handler creation for elicitation.
@@ -36,7 +19,7 @@ function useElicitation() {
36
19
  const [resolveElicitation, setResolveElicitation] = (0, react_1.useState)(null);
37
20
  const defaultElicitationHandler = (0, react_1.useCallback)(async (request, extra) => {
38
21
  return await new Promise((resolve, reject) => {
39
- if (!hasRequestedSchema(request.params)) {
22
+ if (!(0, client_1.hasRequestedSchema)(request.params)) {
40
23
  const mode = "mode" in request.params ? String(request.params.mode) : "unknown";
41
24
  reject(new Error(`Unsupported MCP elicitation params: expected requestedSchema (form mode), got mode=${mode}`));
42
25
  return;
@@ -47,7 +30,7 @@ function useElicitation() {
47
30
  // for cross-version compatibility
48
31
  setElicitation({
49
32
  message: request.params.message,
50
- requestedSchema: toElicitationRequestedSchema(request.params.requestedSchema),
33
+ requestedSchema: (0, client_1.toElicitationRequestedSchema)(request.params.requestedSchema),
51
34
  signal: extra.signal,
52
35
  });
53
36
  // If the signal is already aborted, reject immediately
@@ -1 +1 @@
1
- {"version":3,"file":"elicitation.js","sourceRoot":"","sources":["../../src/mcp/elicitation.ts"],"names":[],"mappings":";;AA+FA,wCA0EC;AA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AAc,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\ntype ElicitRequestParamsWithRequestedSchema = Extract<\n ElicitRequest[\"params\"],\n { requestedSchema: unknown }\n>;\n\n/**\n * Elicitation response to be sent back\n */\nexport interface TamboElicitationResponse {\n action: \"accept\" | \"decline\" | \"cancel\";\n content?: Record<string, unknown>;\n [x: string]: unknown;\n}\n\n/**\n * Elicitation context state - read-only interface for consumers.\n * State management is handled internally by useElicitation hook.\n */\nexport interface ElicitationContextState {\n /** Current elicitation request, or null if none active */\n elicitation: TamboElicitationRequest | null;\n /** Function to call when user responds to elicitation (clears state automatically) */\n resolveElicitation: ((response: TamboElicitationResponse) => void) | null;\n}\n\n/**\n * Narrow the runtime ElicitRequest requestedSchema into the public\n * ElicitationRequestedSchema type.\n *\n * The MCP SDK guarantees that the runtime\n * `ElicitRequest[\"params\"][\"requestedSchema\"]` shape stays aligned with the\n * spec-defined `ElicitRequestFormParams[\"requestedSchema\"]`. This helper\n * centralizes the cast based on that contract so that if a future SDK version\n * ever diverges, we have a single place to tighten the implementation (for\n * example with structural validation or normalization).\n * @returns requestedSchema as ElicitationRequestedSchema\n */\nfunction toElicitationRequestedSchema(\n value: ElicitRequestParamsWithRequestedSchema[\"requestedSchema\"],\n): ElicitationRequestedSchema {\n return value as ElicitationRequestedSchema;\n}\n\n/**\n * Type guard for the elicitation form params shape.\n * @returns true when params include requestedSchema\n */\nfunction hasRequestedSchema(\n params: ElicitRequest[\"params\"],\n): params is ElicitRequestParamsWithRequestedSchema {\n return \"requestedSchema\" in params;\n}\n\n/**\n * Internal hook that manages elicitation state and creates a default handler.\n * This bundles all the state management and handler creation for elicitation.\n *\n * Do not export this hook from this package. It is only intended to be used internally by the TamboMcpProvider.\n * @returns Elicitation state and default handler\n */\nexport function useElicitation() {\n const [elicitation, setElicitation] =\n useState<TamboElicitationRequest | null>(null);\n const [resolveElicitation, setResolveElicitation] = useState<\n ((response: TamboElicitationResponse) => void) | null\n >(null);\n\n const defaultElicitationHandler: MCPElicitationHandler = useCallback(\n async (\n request: ElicitRequest,\n extra: RequestHandlerExtra<ClientRequest, ClientNotification>,\n ): Promise<ElicitResult> => {\n return await new Promise<ElicitResult>((resolve, reject) => {\n if (!hasRequestedSchema(request.params)) {\n const mode =\n \"mode\" in request.params ? String(request.params.mode) : \"unknown\";\n\n reject(\n new Error(\n `Unsupported MCP elicitation params: expected requestedSchema (form mode), got mode=${mode}`,\n ),\n );\n return;\n }\n\n // Set the elicitation request to show the UI\n // Cast is needed because ElicitRequest uses Zod-inferred types (from the\n // user's installed zod version), while we use pure TypeScript spec types\n // for cross-version compatibility\n setElicitation({\n message: request.params.message,\n requestedSchema: toElicitationRequestedSchema(\n request.params.requestedSchema,\n ),\n signal: extra.signal,\n });\n\n // If the signal is already aborted, reject immediately\n if (extra.signal.aborted) {\n setElicitation(null);\n reject(new Error(\"Request aborted\"));\n return;\n }\n\n // Listen for abort signal to clean up\n const handleAbort = () => {\n setElicitation(null);\n setResolveElicitation(null);\n reject(new Error(\"Request aborted\"));\n };\n\n extra.signal.addEventListener(\"abort\", handleAbort, { once: true });\n\n // Store the resolve function so we can call it when the user responds\n setResolveElicitation(() => (response: ElicitResult) => {\n // Remove abort listener since we're resolving normally\n extra.signal.removeEventListener(\"abort\", handleAbort);\n // Clear state now that user has responded\n setElicitation(null);\n setResolveElicitation(null);\n resolve(response);\n });\n });\n },\n [],\n );\n\n return {\n elicitation,\n setElicitation,\n resolveElicitation,\n setResolveElicitation,\n defaultElicitationHandler,\n };\n}\n"]}
1
+ {"version":3,"file":"elicitation.js","sourceRoot":"","sources":["../../src/mcp/elicitation.ts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K,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":["// React-specific hook (not in client package)\nimport type { RequestHandlerExtra } from \"@modelcontextprotocol/sdk/shared/protocol.js\";\nimport type {\n ClientNotification,\n ClientRequest,\n ElicitRequest,\n ElicitResult,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport { useCallback, useState } from \"react\";\nimport type {\n MCPElicitationHandler,\n TamboElicitationRequest,\n TamboElicitationResponse,\n} from \"@tambo-ai/client\";\nimport {\n toElicitationRequestedSchema as toSchema,\n hasRequestedSchema as hasSchema,\n} from \"@tambo-ai/client\";\n\n// Re-export types and functions from @tambo-ai/client for barrel consumers\nexport type {\n ElicitationRequestedSchema,\n TamboElicitationRequest,\n TamboElicitationResponse,\n ElicitationContextState,\n PrimitiveSchemaDefinition,\n} from \"@tambo-ai/client\";\nexport {\n toElicitationRequestedSchema,\n hasRequestedSchema,\n} from \"@tambo-ai/client\";\n\n/**\n * Internal hook that manages elicitation state and creates a default handler.\n * This bundles all the state management and handler creation for elicitation.\n *\n * Do not export this hook from this package. It is only intended to be used internally by the TamboMcpProvider.\n * @returns Elicitation state and default handler\n */\nexport function useElicitation() {\n const [elicitation, setElicitation] =\n useState<TamboElicitationRequest | null>(null);\n const [resolveElicitation, setResolveElicitation] = useState<\n ((response: TamboElicitationResponse) => void) | null\n >(null);\n\n const defaultElicitationHandler: MCPElicitationHandler = useCallback(\n async (\n request: ElicitRequest,\n extra: RequestHandlerExtra<ClientRequest, ClientNotification>,\n ): Promise<ElicitResult> => {\n return await new Promise<ElicitResult>((resolve, reject) => {\n if (!hasSchema(request.params)) {\n const mode =\n \"mode\" in request.params ? String(request.params.mode) : \"unknown\";\n\n reject(\n new Error(\n `Unsupported MCP elicitation params: expected requestedSchema (form mode), got mode=${mode}`,\n ),\n );\n return;\n }\n\n // Set the elicitation request to show the UI\n // Cast is needed because ElicitRequest uses Zod-inferred types (from the\n // user's installed zod version), while we use pure TypeScript spec types\n // for cross-version compatibility\n setElicitation({\n message: request.params.message,\n requestedSchema: toSchema(request.params.requestedSchema),\n signal: extra.signal,\n });\n\n // If the signal is already aborted, reject immediately\n if (extra.signal.aborted) {\n setElicitation(null);\n reject(new Error(\"Request aborted\"));\n return;\n }\n\n // Listen for abort signal to clean up\n const handleAbort = () => {\n setElicitation(null);\n setResolveElicitation(null);\n reject(new Error(\"Request aborted\"));\n };\n\n extra.signal.addEventListener(\"abort\", handleAbort, { once: true });\n\n // Store the resolve function so we can call it when the user responds\n setResolveElicitation(() => (response: ElicitResult) => {\n // Remove abort listener since we're resolving normally\n extra.signal.removeEventListener(\"abort\", handleAbort);\n // Clear state now that user has responded\n setElicitation(null);\n setResolveElicitation(null);\n resolve(response);\n });\n });\n },\n [],\n );\n\n return {\n elicitation,\n setElicitation,\n resolveElicitation,\n setResolveElicitation,\n defaultElicitationHandler,\n };\n}\n"]}
@@ -6,11 +6,11 @@
6
6
  * you'll need to install `zod` and `zod-to-json-schema` as optional peer dependencies.
7
7
  * See the React SDK README for the recommended version ranges.
8
8
  */
9
- export { MCPTransport } from "./mcp-client";
10
- export type { MCPElicitationHandler, MCPHandlers, MCPSamplingHandler, } from "./mcp-client";
11
- export type { ElicitationRequestedSchema, PrimitiveSchemaDefinition, TamboElicitationRequest, TamboElicitationResponse, } from "./elicitation";
9
+ export { MCPTransport } from "@tambo-ai/client";
10
+ export type { MCPElicitationHandler, MCPHandlers, MCPSamplingHandler, } from "@tambo-ai/client";
11
+ export type { ElicitationRequestedSchema, PrimitiveSchemaDefinition, TamboElicitationRequest, TamboElicitationResponse, } from "@tambo-ai/client";
12
12
  export { useTamboMcpPrompt, useTamboMcpPromptList, useTamboMcpResource, useTamboMcpResourceList, isMcpResourceEntry, } from "./mcp-hooks";
13
13
  export type { ListPromptEntry, ListPromptItem, ListResourceEntry, ListResourceItem, } from "./mcp-hooks";
14
14
  export { TamboMcpProvider, useTamboMcpElicitation, useTamboMcpServers, useTamboElicitationContext, type ConnectedMcpServer, type FailedMcpServer, type McpServer, type ProviderMCPHandlers, } from "./tambo-mcp-provider";
15
- export type { McpServerInfo, NormalizedMcpServerInfo, } from "../model/mcp-server-info";
15
+ export type { McpServerInfo, NormalizedMcpServerInfo } from "@tambo-ai/client";
16
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,YAAY,EACV,qBAAqB,EACrB,WAAW,EACX,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,0BAA0B,EAC1B,yBAAyB,EACzB,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,kBAAkB,EAClB,0BAA0B,EAC1B,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,mBAAmB,GACzB,MAAM,sBAAsB,CAAC;AAG9B,YAAY,EACV,aAAa,EACb,uBAAuB,GACxB,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,YAAY,EACV,qBAAqB,EACrB,WAAW,EACX,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACV,0BAA0B,EAC1B,yBAAyB,EACzB,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,kBAAkB,EAClB,0BAA0B,EAC1B,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,mBAAmB,GACzB,MAAM,sBAAsB,CAAC;AAG9B,YAAY,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC"}
package/dist/mcp/index.js CHANGED
@@ -9,8 +9,8 @@ exports.useTamboElicitationContext = exports.useTamboMcpServers = exports.useTam
9
9
  * you'll need to install `zod` and `zod-to-json-schema` as optional peer dependencies.
10
10
  * See the React SDK README for the recommended version ranges.
11
11
  */
12
- var mcp_client_1 = require("./mcp-client");
13
- Object.defineProperty(exports, "MCPTransport", { enumerable: true, get: function () { return mcp_client_1.MCPTransport; } });
12
+ var client_1 = require("@tambo-ai/client");
13
+ Object.defineProperty(exports, "MCPTransport", { enumerable: true, get: function () { return client_1.MCPTransport; } });
14
14
  var mcp_hooks_1 = require("./mcp-hooks");
15
15
  Object.defineProperty(exports, "useTamboMcpPrompt", { enumerable: true, get: function () { return mcp_hooks_1.useTamboMcpPrompt; } });
16
16
  Object.defineProperty(exports, "useTamboMcpPromptList", { enumerable: true, get: function () { return mcp_hooks_1.useTamboMcpPromptList; } });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;GAOG;AACH,2CAA4C;AAAnC,0GAAA,YAAY,OAAA;AAYrB,yCAMqB;AALnB,8GAAA,iBAAiB,OAAA;AACjB,kHAAA,qBAAqB,OAAA;AACrB,gHAAA,mBAAmB,OAAA;AACnB,oHAAA,uBAAuB,OAAA;AACvB,+GAAA,kBAAkB,OAAA;AAQpB,2DAS8B;AAR5B,sHAAA,gBAAgB,OAAA;AAChB,4HAAA,sBAAsB,OAAA;AACtB,wHAAA,kBAAkB,OAAA;AAClB,gIAAA,0BAA0B,OAAA","sourcesContent":["/**\n * Entry point for MCP (Model Context Protocol) support in the React SDK.\n *\n * Note: The `@modelcontextprotocol/sdk` is included automatically with `@tambo-ai/react`.\n * If you use features that require schema validation (like component props schemas),\n * you'll need to install `zod` and `zod-to-json-schema` as optional peer dependencies.\n * See the React SDK README for the recommended version ranges.\n */\nexport { MCPTransport } from \"./mcp-client\";\nexport type {\n MCPElicitationHandler,\n MCPHandlers,\n MCPSamplingHandler,\n} from \"./mcp-client\";\nexport type {\n ElicitationRequestedSchema,\n PrimitiveSchemaDefinition,\n TamboElicitationRequest,\n TamboElicitationResponse,\n} from \"./elicitation\";\nexport {\n useTamboMcpPrompt,\n useTamboMcpPromptList,\n useTamboMcpResource,\n useTamboMcpResourceList,\n isMcpResourceEntry,\n} from \"./mcp-hooks\";\nexport type {\n ListPromptEntry,\n ListPromptItem,\n ListResourceEntry,\n ListResourceItem,\n} from \"./mcp-hooks\";\nexport {\n TamboMcpProvider,\n useTamboMcpElicitation,\n useTamboMcpServers,\n useTamboElicitationContext,\n type ConnectedMcpServer,\n type FailedMcpServer,\n type McpServer,\n type ProviderMCPHandlers,\n} from \"./tambo-mcp-provider\";\n\n// Public MCP server metadata types\nexport type {\n McpServerInfo,\n NormalizedMcpServerInfo,\n} from \"../model/mcp-server-info\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;GAOG;AACH,2CAAgD;AAAvC,sGAAA,YAAY,OAAA;AAYrB,yCAMqB;AALnB,8GAAA,iBAAiB,OAAA;AACjB,kHAAA,qBAAqB,OAAA;AACrB,gHAAA,mBAAmB,OAAA;AACnB,oHAAA,uBAAuB,OAAA;AACvB,+GAAA,kBAAkB,OAAA;AAQpB,2DAS8B;AAR5B,sHAAA,gBAAgB,OAAA;AAChB,4HAAA,sBAAsB,OAAA;AACtB,wHAAA,kBAAkB,OAAA;AAClB,gIAAA,0BAA0B,OAAA","sourcesContent":["/**\n * Entry point for MCP (Model Context Protocol) support in the React SDK.\n *\n * Note: The `@modelcontextprotocol/sdk` is included automatically with `@tambo-ai/react`.\n * If you use features that require schema validation (like component props schemas),\n * you'll need to install `zod` and `zod-to-json-schema` as optional peer dependencies.\n * See the React SDK README for the recommended version ranges.\n */\nexport { MCPTransport } from \"@tambo-ai/client\";\nexport type {\n MCPElicitationHandler,\n MCPHandlers,\n MCPSamplingHandler,\n} from \"@tambo-ai/client\";\nexport type {\n ElicitationRequestedSchema,\n PrimitiveSchemaDefinition,\n TamboElicitationRequest,\n TamboElicitationResponse,\n} from \"@tambo-ai/client\";\nexport {\n useTamboMcpPrompt,\n useTamboMcpPromptList,\n useTamboMcpResource,\n useTamboMcpResourceList,\n isMcpResourceEntry,\n} from \"./mcp-hooks\";\nexport type {\n ListPromptEntry,\n ListPromptItem,\n ListResourceEntry,\n ListResourceItem,\n} from \"./mcp-hooks\";\nexport {\n TamboMcpProvider,\n useTamboMcpElicitation,\n useTamboMcpServers,\n useTamboElicitationContext,\n type ConnectedMcpServer,\n type FailedMcpServer,\n type McpServer,\n type ProviderMCPHandlers,\n} from \"./tambo-mcp-provider\";\n\n// Public MCP server metadata types\nexport type { McpServerInfo, NormalizedMcpServerInfo } from \"@tambo-ai/client\";\n"]}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const mcp_client_1 = require("./mcp-client");
3
+ const client_1 = require("@tambo-ai/client");
4
4
  // Mock the MCP SDK modules
5
5
  jest.mock("@modelcontextprotocol/sdk/client/index.js", () => ({
6
6
  Client: jest.fn().mockImplementation(() => ({
@@ -57,34 +57,34 @@ describe("MCPClient", () => {
57
57
  it("should create and connect an MCPClient with HTTP transport by default", async () => {
58
58
  const endpoint = "https://api.example.com/mcp";
59
59
  const headers = { Authorization: "Bearer token" };
60
- const client = await mcp_client_1.MCPClient.create(endpoint, mcp_client_1.MCPTransport.HTTP, headers, undefined, undefined);
60
+ const client = await client_1.MCPClient.create(endpoint, client_1.MCPTransport.HTTP, headers, undefined, undefined);
61
61
  expect(MockedStreamableHTTPClientTransport).toHaveBeenCalledWith(new URL(endpoint), { sessionId: undefined, requestInit: { headers } });
62
62
  expect(MockedClient).toHaveBeenCalledWith({
63
63
  name: "tambo-mcp-client",
64
64
  version: "1.0.0",
65
65
  }, { capabilities: {} });
66
66
  expect(mockClientInstance.connect).toHaveBeenCalledWith(mockTransportInstance);
67
- expect(client).toBeInstanceOf(mcp_client_1.MCPClient);
67
+ expect(client).toBeInstanceOf(client_1.MCPClient);
68
68
  });
69
69
  it("should create and connect an MCPClient with SSE transport", async () => {
70
70
  const endpoint = "https://api.example.com/mcp";
71
- const client = await mcp_client_1.MCPClient.create(endpoint, mcp_client_1.MCPTransport.SSE, undefined, undefined, undefined);
71
+ const client = await client_1.MCPClient.create(endpoint, client_1.MCPTransport.SSE, undefined, undefined, undefined);
72
72
  expect(MockedSSEClientTransport).toHaveBeenCalledWith(new URL(endpoint), {
73
73
  requestInit: { headers: {} },
74
74
  });
75
75
  expect(mockClientInstance.connect).toHaveBeenCalledWith({});
76
- expect(client).toBeInstanceOf(mcp_client_1.MCPClient);
76
+ expect(client).toBeInstanceOf(client_1.MCPClient);
77
77
  });
78
78
  it("should create client with default headers when none provided", async () => {
79
79
  const endpoint = "https://api.example.com/mcp";
80
- await mcp_client_1.MCPClient.create(endpoint, mcp_client_1.MCPTransport.HTTP, undefined, undefined, undefined);
80
+ await client_1.MCPClient.create(endpoint, client_1.MCPTransport.HTTP, undefined, undefined, undefined);
81
81
  expect(MockedStreamableHTTPClientTransport).toHaveBeenCalledWith(new URL(endpoint), { sessionId: undefined, requestInit: { headers: {} } });
82
82
  });
83
83
  });
84
84
  describe("listTools", () => {
85
85
  it("should list all tools with pagination", async () => {
86
86
  const endpoint = "https://api.example.com/mcp";
87
- const client = await mcp_client_1.MCPClient.create(endpoint, mcp_client_1.MCPTransport.HTTP, undefined, undefined, undefined);
87
+ const client = await client_1.MCPClient.create(endpoint, client_1.MCPTransport.HTTP, undefined, undefined, undefined);
88
88
  const mockTools = [
89
89
  {
90
90
  name: "tool1",
@@ -139,7 +139,7 @@ describe("MCPClient", () => {
139
139
  });
140
140
  it("should handle single page of tools", async () => {
141
141
  const endpoint = "https://api.example.com/mcp";
142
- const client = await mcp_client_1.MCPClient.create(endpoint, mcp_client_1.MCPTransport.HTTP, undefined, undefined, undefined);
142
+ const client = await client_1.MCPClient.create(endpoint, client_1.MCPTransport.HTTP, undefined, undefined, undefined);
143
143
  const mockTools = [
144
144
  {
145
145
  name: "tool1",
@@ -170,7 +170,7 @@ describe("MCPClient", () => {
170
170
  });
171
171
  it("should throw error for invalid input schema", async () => {
172
172
  const endpoint = "https://api.example.com/mcp";
173
- const client = await mcp_client_1.MCPClient.create(endpoint, mcp_client_1.MCPTransport.HTTP, undefined, undefined, undefined);
173
+ const client = await client_1.MCPClient.create(endpoint, client_1.MCPTransport.HTTP, undefined, undefined, undefined);
174
174
  const mockTools = [
175
175
  {
176
176
  name: "invalid-tool",
@@ -189,7 +189,7 @@ describe("MCPClient", () => {
189
189
  describe("callTool", () => {
190
190
  it("should call a tool with arguments", async () => {
191
191
  const endpoint = "https://api.example.com/mcp";
192
- const client = await mcp_client_1.MCPClient.create(endpoint, mcp_client_1.MCPTransport.HTTP, undefined, undefined, undefined);
192
+ const client = await client_1.MCPClient.create(endpoint, client_1.MCPTransport.HTTP, undefined, undefined, undefined);
193
193
  const mockResult = { success: true, data: "test result" };
194
194
  mockClientInstance.callTool.mockResolvedValue(mockResult);
195
195
  const result = await client.callTool("testTool", {
@@ -204,7 +204,7 @@ describe("MCPClient", () => {
204
204
  });
205
205
  it("should handle tool call errors", async () => {
206
206
  const endpoint = "https://api.example.com/mcp";
207
- const client = await mcp_client_1.MCPClient.create(endpoint, mcp_client_1.MCPTransport.HTTP, undefined, undefined, undefined);
207
+ const client = await client_1.MCPClient.create(endpoint, client_1.MCPTransport.HTTP, undefined, undefined, undefined);
208
208
  const error = new Error("Tool call failed");
209
209
  mockClientInstance.callTool.mockRejectedValue(error);
210
210
  await expect(client.callTool("testTool", {})).rejects.toThrow("Tool call failed");
@@ -214,13 +214,13 @@ describe("MCPClient", () => {
214
214
  it("should initialize HTTP transport with session ID", async () => {
215
215
  const endpoint = "https://api.example.com/mcp";
216
216
  const headers = { Authorization: "Bearer token" };
217
- await mcp_client_1.MCPClient.create(endpoint, mcp_client_1.MCPTransport.HTTP, headers, undefined, undefined);
217
+ await client_1.MCPClient.create(endpoint, client_1.MCPTransport.HTTP, headers, undefined, undefined);
218
218
  expect(MockedStreamableHTTPClientTransport).toHaveBeenCalledWith(new URL(endpoint), { sessionId: undefined, requestInit: { headers } });
219
219
  });
220
220
  it("should initialize SSE transport without session ID", async () => {
221
221
  const endpoint = "https://api.example.com/mcp";
222
222
  const headers = { Authorization: "Bearer token" };
223
- await mcp_client_1.MCPClient.create(endpoint, mcp_client_1.MCPTransport.SSE, headers, undefined, undefined);
223
+ await client_1.MCPClient.create(endpoint, client_1.MCPTransport.SSE, headers, undefined, undefined);
224
224
  expect(MockedSSEClientTransport).toHaveBeenCalledWith(new URL(endpoint), {
225
225
  requestInit: { headers },
226
226
  });
@@ -229,7 +229,7 @@ describe("MCPClient", () => {
229
229
  describe("client initialization", () => {
230
230
  it("should initialize client with correct name and version", async () => {
231
231
  const endpoint = "https://api.example.com/mcp";
232
- await mcp_client_1.MCPClient.create(endpoint, mcp_client_1.MCPTransport.HTTP, undefined, undefined, undefined);
232
+ await client_1.MCPClient.create(endpoint, client_1.MCPTransport.HTTP, undefined, undefined, undefined);
233
233
  expect(MockedClient).toHaveBeenCalledWith({
234
234
  name: "tambo-mcp-client",
235
235
  version: "1.0.0",
@@ -241,7 +241,7 @@ describe("MCPClient", () => {
241
241
  const endpoint = "https://api.example.com/mcp";
242
242
  const elicitation = jest.fn(async () => ({}));
243
243
  const sampling = jest.fn(async () => ({}));
244
- await mcp_client_1.MCPClient.create(endpoint, mcp_client_1.MCPTransport.HTTP, undefined, undefined, undefined, { elicitation, sampling });
244
+ await client_1.MCPClient.create(endpoint, client_1.MCPTransport.HTTP, undefined, undefined, undefined, { elicitation, sampling });
245
245
  expect(MockedClient).toHaveBeenLastCalledWith({
246
246
  name: "tambo-mcp-client",
247
247
  version: "1.0.0",
@@ -257,7 +257,7 @@ describe("MCPClient", () => {
257
257
  });
258
258
  it("removes elicitation handler when set to undefined", async () => {
259
259
  const endpoint = "https://api.example.com/mcp";
260
- const client = await mcp_client_1.MCPClient.create(endpoint, mcp_client_1.MCPTransport.HTTP, undefined, undefined, undefined, {
260
+ const client = await client_1.MCPClient.create(endpoint, client_1.MCPTransport.HTTP, undefined, undefined, undefined, {
261
261
  elicitation: async () => ({}),
262
262
  });
263
263
  const removeSpy = mockClientInstance.removeRequestHandler;
@@ -268,7 +268,7 @@ describe("MCPClient", () => {
268
268
  });
269
269
  it("removes sampling handler when set to undefined", async () => {
270
270
  const endpoint = "https://api.example.com/mcp";
271
- const client = await mcp_client_1.MCPClient.create(endpoint, mcp_client_1.MCPTransport.HTTP, undefined, undefined, undefined, {
271
+ const client = await client_1.MCPClient.create(endpoint, client_1.MCPTransport.HTTP, undefined, undefined, undefined, {
272
272
  sampling: async () => ({}),
273
273
  });
274
274
  const removeSpy = mockClientInstance.removeRequestHandler;
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-client.test.js","sourceRoot":"","sources":["../../src/mcp/mcp-client.test.ts"],"names":[],"mappings":";;AAAA,6CAAuD;AAEvD,2BAA2B;AAC3B,IAAI,CAAC,IAAI,CAAC,2CAA2C,EAAE,GAAG,EAAE,CAAC,CAAC;IAC5D,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC,CAAC;QAC1C,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE;QAClB,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE;QAChB,SAAS,EAAE,IAAI,CAAC,EAAE,EAAE;QACpB,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE;QACnB,iBAAiB,EAAE,IAAI,CAAC,EAAE,EAAE;QAC5B,oBAAoB,EAAE,IAAI,CAAC,EAAE,EAAE;KAChC,CAAC,CAAC;CACJ,CAAC,CAAC,CAAC;AAEJ,IAAI,CAAC,IAAI,CAAC,yCAAyC,EAAE,GAAG,EAAE,CAAC,CAAC;IAC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M,CAAC,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,gDAAgD,EAAE,KAAK,IAAI,EAAE;YAC9D,MAAM,QAAQ,GAAG,6BAA6B,CAAC;YAC/C,MAAM,MAAM,GAAG,MAAM,sBAAS,CAAC,MAAM,CACnC,QAAQ,EACR,yBAAY,CAAC,IAAI,EACjB,SAAS,EACT,SAAS,EACT,SAAS,EACT;gBACE,QAAQ,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE,CAAQ;aAClC,CACF,CAAC;YAEF,MAAM,SAAS,GAAG,kBAAkB,CAAC,oBAAiC,CAAC;YAEvE,cAAc;YACd,SAAS,CAAC,SAAS,EAAE,CAAC;YACtB,MAAM,MAAM,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC;YAC9C,MAAM,CAAC,SAAS,CAAC,CAAC,oBAAoB,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { MCPClient, MCPTransport } from \"./mcp-client\";\n\n// Mock the MCP SDK modules\njest.mock(\"@modelcontextprotocol/sdk/client/index.js\", () => ({\n Client: jest.fn().mockImplementation(() => ({\n connect: jest.fn(),\n close: jest.fn(),\n listTools: jest.fn(),\n callTool: jest.fn(),\n setRequestHandler: jest.fn(),\n removeRequestHandler: jest.fn(),\n })),\n}));\n\njest.mock(\"@modelcontextprotocol/sdk/client/sse.js\", () => ({\n SSEClientTransport: jest.fn().mockImplementation(() => ({\n // SSE transport doesn't have sessionId\n })),\n}));\n\njest.mock(\"@modelcontextprotocol/sdk/client/streamableHttp.js\", () => ({\n StreamableHTTPClientTransport: jest\n .fn()\n .mockImplementation((url, options) => ({\n sessionId: options?.sessionId,\n })),\n}));\n\nimport { Client } from \"@modelcontextprotocol/sdk/client/index.js\";\nimport { SSEClientTransport } from \"@modelcontextprotocol/sdk/client/sse.js\";\nimport { StreamableHTTPClientTransport } from \"@modelcontextprotocol/sdk/client/streamableHttp.js\";\n\n// Type the mocked modules\nconst MockedClient = Client as jest.MockedClass<typeof Client>;\nconst MockedSSEClientTransport = SSEClientTransport as jest.MockedClass<\n typeof SSEClientTransport\n>;\nconst MockedStreamableHTTPClientTransport =\n StreamableHTTPClientTransport as jest.MockedClass<\n typeof StreamableHTTPClientTransport\n >;\n\ndescribe(\"MCPClient\", () => {\n let mockClientInstance: any;\n let mockTransportInstance: any;\n\n beforeEach(() => {\n jest.clearAllMocks();\n\n // Create mock instances\n mockClientInstance = {\n connect: jest.fn().mockResolvedValue(undefined),\n close: jest.fn().mockResolvedValue(undefined),\n listTools: jest.fn(),\n callTool: jest.fn(),\n setRequestHandler: jest.fn(),\n removeRequestHandler: jest.fn(),\n };\n\n mockTransportInstance = {\n sessionId: \"test-session-id\",\n };\n\n // Setup mocks\n MockedClient.mockImplementation(() => mockClientInstance);\n MockedStreamableHTTPClientTransport.mockImplementation(\n () => mockTransportInstance,\n );\n MockedSSEClientTransport.mockImplementation(\n () => ({}) as SSEClientTransport,\n );\n });\n\n describe(\"create\", () => {\n it(\"should create and connect an MCPClient with HTTP transport by default\", async () => {\n const endpoint = \"https://api.example.com/mcp\";\n const headers = { Authorization: \"Bearer token\" };\n\n const client = await MCPClient.create(\n endpoint,\n MCPTransport.HTTP,\n headers,\n undefined,\n undefined,\n );\n\n expect(MockedStreamableHTTPClientTransport).toHaveBeenCalledWith(\n new URL(endpoint),\n { sessionId: undefined, requestInit: { headers } },\n );\n expect(MockedClient).toHaveBeenCalledWith(\n {\n name: \"tambo-mcp-client\",\n version: \"1.0.0\",\n },\n { capabilities: {} },\n );\n expect(mockClientInstance.connect).toHaveBeenCalledWith(\n mockTransportInstance,\n );\n expect(client).toBeInstanceOf(MCPClient);\n });\n\n it(\"should create and connect an MCPClient with SSE transport\", async () => {\n const endpoint = \"https://api.example.com/mcp\";\n\n const client = await MCPClient.create(\n endpoint,\n MCPTransport.SSE,\n undefined,\n undefined,\n undefined,\n );\n\n expect(MockedSSEClientTransport).toHaveBeenCalledWith(new URL(endpoint), {\n requestInit: { headers: {} },\n });\n expect(mockClientInstance.connect).toHaveBeenCalledWith({});\n expect(client).toBeInstanceOf(MCPClient);\n });\n\n it(\"should create client with default headers when none provided\", async () => {\n const endpoint = \"https://api.example.com/mcp\";\n\n await MCPClient.create(\n endpoint,\n MCPTransport.HTTP,\n undefined,\n undefined,\n undefined,\n );\n\n expect(MockedStreamableHTTPClientTransport).toHaveBeenCalledWith(\n new URL(endpoint),\n { sessionId: undefined, requestInit: { headers: {} } },\n );\n });\n });\n\n describe(\"listTools\", () => {\n it(\"should list all tools with pagination\", async () => {\n const endpoint = \"https://api.example.com/mcp\";\n const client = await MCPClient.create(\n endpoint,\n MCPTransport.HTTP,\n undefined,\n undefined,\n undefined,\n );\n\n const mockTools = [\n {\n name: \"tool1\",\n description: \"First tool\",\n inputSchema: {\n type: \"object\",\n properties: { arg1: { type: \"string\" } },\n },\n },\n {\n name: \"tool2\",\n description: \"Second tool\",\n inputSchema: {\n type: \"object\",\n properties: { arg2: { type: \"number\" } },\n },\n },\n ];\n\n const mockResponse1 = {\n tools: [mockTools[0]],\n nextCursor: \"cursor1\",\n };\n\n const mockResponse2 = {\n tools: [mockTools[1]],\n nextCursor: undefined,\n };\n\n mockClientInstance.listTools\n .mockResolvedValueOnce(mockResponse1)\n .mockResolvedValueOnce(mockResponse2);\n\n const result = await client.listTools();\n\n expect(mockClientInstance.listTools).toHaveBeenCalledTimes(2);\n expect(mockClientInstance.listTools).toHaveBeenNthCalledWith(\n 1,\n { cursor: undefined },\n {},\n );\n expect(mockClientInstance.listTools).toHaveBeenNthCalledWith(\n 2,\n { cursor: \"cursor1\" },\n {},\n );\n expect(result).toEqual([\n {\n name: \"tool1\",\n description: \"First tool\",\n inputSchema: {\n type: \"object\",\n properties: { arg1: { type: \"string\" } },\n },\n },\n {\n name: \"tool2\",\n description: \"Second tool\",\n inputSchema: {\n type: \"object\",\n properties: { arg2: { type: \"number\" } },\n },\n },\n ]);\n });\n\n it(\"should handle single page of tools\", async () => {\n const endpoint = \"https://api.example.com/mcp\";\n const client = await MCPClient.create(\n endpoint,\n MCPTransport.HTTP,\n undefined,\n undefined,\n undefined,\n );\n\n const mockTools = [\n {\n name: \"tool1\",\n description: \"Only tool\",\n inputSchema: {\n type: \"object\",\n properties: { arg1: { type: \"string\" } },\n },\n },\n ];\n\n const mockResponse = {\n tools: mockTools,\n nextCursor: undefined,\n };\n\n mockClientInstance.listTools.mockResolvedValue(mockResponse);\n\n const result = await client.listTools();\n\n expect(mockClientInstance.listTools).toHaveBeenCalledTimes(1);\n expect(result).toEqual([\n {\n name: \"tool1\",\n description: \"Only tool\",\n inputSchema: {\n type: \"object\",\n properties: { arg1: { type: \"string\" } },\n },\n },\n ]);\n });\n\n it(\"should throw error for invalid input schema\", async () => {\n const endpoint = \"https://api.example.com/mcp\";\n const client = await MCPClient.create(\n endpoint,\n MCPTransport.HTTP,\n undefined,\n undefined,\n undefined,\n );\n\n const mockTools = [\n {\n name: \"invalid-tool\",\n description: \"Tool with invalid schema\",\n inputSchema: { type: \"string\" }, // Invalid - should be object\n },\n ];\n\n const mockResponse = {\n tools: mockTools,\n nextCursor: undefined,\n };\n\n mockClientInstance.listTools.mockResolvedValue(mockResponse);\n\n await expect(client.listTools()).rejects.toThrow(\n \"Input schema for tool invalid-tool is not an object\",\n );\n });\n });\n\n describe(\"callTool\", () => {\n it(\"should call a tool with arguments\", async () => {\n const endpoint = \"https://api.example.com/mcp\";\n const client = await MCPClient.create(\n endpoint,\n MCPTransport.HTTP,\n undefined,\n undefined,\n undefined,\n );\n\n const mockResult = { success: true, data: \"test result\" };\n mockClientInstance.callTool.mockResolvedValue(mockResult);\n\n const result = await client.callTool(\"testTool\", {\n arg1: \"value1\",\n arg2: 42,\n });\n\n expect(mockClientInstance.callTool).toHaveBeenCalledWith({\n name: \"testTool\",\n arguments: { arg1: \"value1\", arg2: 42 },\n });\n expect(result).toBe(mockResult);\n });\n\n it(\"should handle tool call errors\", async () => {\n const endpoint = \"https://api.example.com/mcp\";\n const client = await MCPClient.create(\n endpoint,\n MCPTransport.HTTP,\n undefined,\n undefined,\n undefined,\n );\n const error = new Error(\"Tool call failed\");\n mockClientInstance.callTool.mockRejectedValue(error);\n\n await expect(client.callTool(\"testTool\", {})).rejects.toThrow(\n \"Tool call failed\",\n );\n });\n });\n\n describe(\"transport initialization\", () => {\n it(\"should initialize HTTP transport with session ID\", async () => {\n const endpoint = \"https://api.example.com/mcp\";\n const headers = { Authorization: \"Bearer token\" };\n\n await MCPClient.create(\n endpoint,\n MCPTransport.HTTP,\n headers,\n undefined,\n undefined,\n );\n\n expect(MockedStreamableHTTPClientTransport).toHaveBeenCalledWith(\n new URL(endpoint),\n { sessionId: undefined, requestInit: { headers } },\n );\n });\n\n it(\"should initialize SSE transport without session ID\", async () => {\n const endpoint = \"https://api.example.com/mcp\";\n const headers = { Authorization: \"Bearer token\" };\n\n await MCPClient.create(\n endpoint,\n MCPTransport.SSE,\n headers,\n undefined,\n undefined,\n );\n\n expect(MockedSSEClientTransport).toHaveBeenCalledWith(new URL(endpoint), {\n requestInit: { headers },\n });\n });\n });\n\n describe(\"client initialization\", () => {\n it(\"should initialize client with correct name and version\", async () => {\n const endpoint = \"https://api.example.com/mcp\";\n\n await MCPClient.create(\n endpoint,\n MCPTransport.HTTP,\n undefined,\n undefined,\n undefined,\n );\n\n expect(MockedClient).toHaveBeenCalledWith(\n {\n name: \"tambo-mcp-client\",\n version: \"1.0.0\",\n },\n { capabilities: {} },\n );\n });\n });\n\n describe(\"handlers (elicitation/sampling)\", () => {\n it(\"sets handlers on create when provided\", async () => {\n const endpoint = \"https://api.example.com/mcp\";\n const elicitation = jest.fn(async () => ({}) as any);\n const sampling = jest.fn(async () => ({}) as any);\n\n await MCPClient.create(\n endpoint,\n MCPTransport.HTTP,\n undefined,\n undefined,\n undefined,\n { elicitation, sampling },\n );\n\n expect(MockedClient).toHaveBeenLastCalledWith(\n {\n name: \"tambo-mcp-client\",\n version: \"1.0.0\",\n },\n {\n capabilities: {\n elicitation: {},\n sampling: {},\n },\n },\n );\n\n // Request handlers should be set for both\n expect(mockClientInstance.setRequestHandler).toHaveBeenCalled();\n expect(\n (mockClientInstance.setRequestHandler as jest.Mock).mock.calls.length,\n ).toBeGreaterThanOrEqual(2);\n });\n\n it(\"removes elicitation handler when set to undefined\", async () => {\n const endpoint = \"https://api.example.com/mcp\";\n const client = await MCPClient.create(\n endpoint,\n MCPTransport.HTTP,\n undefined,\n undefined,\n undefined,\n {\n elicitation: async () => ({}) as any,\n },\n );\n\n const removeSpy = mockClientInstance.removeRequestHandler as jest.Mock;\n\n // then remove\n removeSpy.mockClear();\n await client.updateElicitationHandler(undefined);\n expect(removeSpy).toHaveBeenCalledWith(expect.any(String));\n });\n\n it(\"removes sampling handler when set to undefined\", async () => {\n const endpoint = \"https://api.example.com/mcp\";\n const client = await MCPClient.create(\n endpoint,\n MCPTransport.HTTP,\n undefined,\n undefined,\n undefined,\n {\n sampling: async () => ({}) as any,\n },\n );\n\n const removeSpy = mockClientInstance.removeRequestHandler as jest.Mock;\n\n // then remove\n removeSpy.mockClear();\n await client.updateSamplingHandler(undefined);\n expect(removeSpy).toHaveBeenCalledWith(expect.any(String));\n });\n });\n});\n"]}
1
+ {"version":3,"file":"mcp-client.test.js","sourceRoot":"","sources":["../../src/mcp/mcp-client.test.ts"],"names":[],"mappings":";;AAAA,6CAA2D;AAE3D,2BAA2B;AAC3B,IAAI,CAAC,IAAI,CAAC,2CAA2C,EAAE,GAAG,EAAE,CAAC,CAAC;IAC5D,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC,CAAC;QAC1C,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE;QAClB,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE;QAChB,SAAS,EAAE,IAAI,CAAC,EAAE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Q;aACrC,CACF,CAAC;YAEF,MAAM,SAAS,GAAG,kBAAkB,CAAC,oBAAiC,CAAC;YAEvE,cAAc;YACd,SAAS,CAAC,SAAS,EAAE,CAAC;YACtB,MAAM,MAAM,CAAC,wBAAwB,CAAC,SAAS,CAAC,CAAC;YACjD,MAAM,CAAC,SAAS,CAAC,CAAC,oBAAoB,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,gDAAgD,EAAE,KAAK,IAAI,EAAE;YAC9D,MAAM,QAAQ,GAAG,6BAA6B,CAAC;YAC/C,MAAM,MAAM,GAAG,MAAM,kBAAS,CAAC,MAAM,CACnC,QAAQ,EACR,qBAAY,CAAC,IAAI,EACjB,SAAS,EACT,SAAS,EACT,SAAS,EACT;gBACE,QAAQ,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE,CAAQ;aAClC,CACF,CAAC;YAEF,MAAM,SAAS,GAAG,kBAAkB,CAAC,oBAAiC,CAAC;YAEvE,cAAc;YACd,SAAS,CAAC,SAAS,EAAE,CAAC;YACtB,MAAM,MAAM,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC;YAC9C,MAAM,CAAC,SAAS,CAAC,CAAC,oBAAoB,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { MCPClient, MCPTransport } from \"@tambo-ai/client\";\n\n// Mock the MCP SDK modules\njest.mock(\"@modelcontextprotocol/sdk/client/index.js\", () => ({\n Client: jest.fn().mockImplementation(() => ({\n connect: jest.fn(),\n close: jest.fn(),\n listTools: jest.fn(),\n callTool: jest.fn(),\n setRequestHandler: jest.fn(),\n removeRequestHandler: jest.fn(),\n })),\n}));\n\njest.mock(\"@modelcontextprotocol/sdk/client/sse.js\", () => ({\n SSEClientTransport: jest.fn().mockImplementation(() => ({\n // SSE transport doesn't have sessionId\n })),\n}));\n\njest.mock(\"@modelcontextprotocol/sdk/client/streamableHttp.js\", () => ({\n StreamableHTTPClientTransport: jest\n .fn()\n .mockImplementation((url, options) => ({\n sessionId: options?.sessionId,\n })),\n}));\n\nimport { Client } from \"@modelcontextprotocol/sdk/client/index.js\";\nimport { SSEClientTransport } from \"@modelcontextprotocol/sdk/client/sse.js\";\nimport { StreamableHTTPClientTransport } from \"@modelcontextprotocol/sdk/client/streamableHttp.js\";\n\n// Type the mocked modules\nconst MockedClient = Client as jest.MockedClass<typeof Client>;\nconst MockedSSEClientTransport = SSEClientTransport as jest.MockedClass<\n typeof SSEClientTransport\n>;\nconst MockedStreamableHTTPClientTransport =\n StreamableHTTPClientTransport as jest.MockedClass<\n typeof StreamableHTTPClientTransport\n >;\n\ndescribe(\"MCPClient\", () => {\n let mockClientInstance: any;\n let mockTransportInstance: any;\n\n beforeEach(() => {\n jest.clearAllMocks();\n\n // Create mock instances\n mockClientInstance = {\n connect: jest.fn().mockResolvedValue(undefined),\n close: jest.fn().mockResolvedValue(undefined),\n listTools: jest.fn(),\n callTool: jest.fn(),\n setRequestHandler: jest.fn(),\n removeRequestHandler: jest.fn(),\n };\n\n mockTransportInstance = {\n sessionId: \"test-session-id\",\n };\n\n // Setup mocks\n MockedClient.mockImplementation(() => mockClientInstance);\n MockedStreamableHTTPClientTransport.mockImplementation(\n () => mockTransportInstance,\n );\n MockedSSEClientTransport.mockImplementation(\n () => ({}) as SSEClientTransport,\n );\n });\n\n describe(\"create\", () => {\n it(\"should create and connect an MCPClient with HTTP transport by default\", async () => {\n const endpoint = \"https://api.example.com/mcp\";\n const headers = { Authorization: \"Bearer token\" };\n\n const client = await MCPClient.create(\n endpoint,\n MCPTransport.HTTP,\n headers,\n undefined,\n undefined,\n );\n\n expect(MockedStreamableHTTPClientTransport).toHaveBeenCalledWith(\n new URL(endpoint),\n { sessionId: undefined, requestInit: { headers } },\n );\n expect(MockedClient).toHaveBeenCalledWith(\n {\n name: \"tambo-mcp-client\",\n version: \"1.0.0\",\n },\n { capabilities: {} },\n );\n expect(mockClientInstance.connect).toHaveBeenCalledWith(\n mockTransportInstance,\n );\n expect(client).toBeInstanceOf(MCPClient);\n });\n\n it(\"should create and connect an MCPClient with SSE transport\", async () => {\n const endpoint = \"https://api.example.com/mcp\";\n\n const client = await MCPClient.create(\n endpoint,\n MCPTransport.SSE,\n undefined,\n undefined,\n undefined,\n );\n\n expect(MockedSSEClientTransport).toHaveBeenCalledWith(new URL(endpoint), {\n requestInit: { headers: {} },\n });\n expect(mockClientInstance.connect).toHaveBeenCalledWith({});\n expect(client).toBeInstanceOf(MCPClient);\n });\n\n it(\"should create client with default headers when none provided\", async () => {\n const endpoint = \"https://api.example.com/mcp\";\n\n await MCPClient.create(\n endpoint,\n MCPTransport.HTTP,\n undefined,\n undefined,\n undefined,\n );\n\n expect(MockedStreamableHTTPClientTransport).toHaveBeenCalledWith(\n new URL(endpoint),\n { sessionId: undefined, requestInit: { headers: {} } },\n );\n });\n });\n\n describe(\"listTools\", () => {\n it(\"should list all tools with pagination\", async () => {\n const endpoint = \"https://api.example.com/mcp\";\n const client = await MCPClient.create(\n endpoint,\n MCPTransport.HTTP,\n undefined,\n undefined,\n undefined,\n );\n\n const mockTools = [\n {\n name: \"tool1\",\n description: \"First tool\",\n inputSchema: {\n type: \"object\",\n properties: { arg1: { type: \"string\" } },\n },\n },\n {\n name: \"tool2\",\n description: \"Second tool\",\n inputSchema: {\n type: \"object\",\n properties: { arg2: { type: \"number\" } },\n },\n },\n ];\n\n const mockResponse1 = {\n tools: [mockTools[0]],\n nextCursor: \"cursor1\",\n };\n\n const mockResponse2 = {\n tools: [mockTools[1]],\n nextCursor: undefined,\n };\n\n mockClientInstance.listTools\n .mockResolvedValueOnce(mockResponse1)\n .mockResolvedValueOnce(mockResponse2);\n\n const result = await client.listTools();\n\n expect(mockClientInstance.listTools).toHaveBeenCalledTimes(2);\n expect(mockClientInstance.listTools).toHaveBeenNthCalledWith(\n 1,\n { cursor: undefined },\n {},\n );\n expect(mockClientInstance.listTools).toHaveBeenNthCalledWith(\n 2,\n { cursor: \"cursor1\" },\n {},\n );\n expect(result).toEqual([\n {\n name: \"tool1\",\n description: \"First tool\",\n inputSchema: {\n type: \"object\",\n properties: { arg1: { type: \"string\" } },\n },\n },\n {\n name: \"tool2\",\n description: \"Second tool\",\n inputSchema: {\n type: \"object\",\n properties: { arg2: { type: \"number\" } },\n },\n },\n ]);\n });\n\n it(\"should handle single page of tools\", async () => {\n const endpoint = \"https://api.example.com/mcp\";\n const client = await MCPClient.create(\n endpoint,\n MCPTransport.HTTP,\n undefined,\n undefined,\n undefined,\n );\n\n const mockTools = [\n {\n name: \"tool1\",\n description: \"Only tool\",\n inputSchema: {\n type: \"object\",\n properties: { arg1: { type: \"string\" } },\n },\n },\n ];\n\n const mockResponse = {\n tools: mockTools,\n nextCursor: undefined,\n };\n\n mockClientInstance.listTools.mockResolvedValue(mockResponse);\n\n const result = await client.listTools();\n\n expect(mockClientInstance.listTools).toHaveBeenCalledTimes(1);\n expect(result).toEqual([\n {\n name: \"tool1\",\n description: \"Only tool\",\n inputSchema: {\n type: \"object\",\n properties: { arg1: { type: \"string\" } },\n },\n },\n ]);\n });\n\n it(\"should throw error for invalid input schema\", async () => {\n const endpoint = \"https://api.example.com/mcp\";\n const client = await MCPClient.create(\n endpoint,\n MCPTransport.HTTP,\n undefined,\n undefined,\n undefined,\n );\n\n const mockTools = [\n {\n name: \"invalid-tool\",\n description: \"Tool with invalid schema\",\n inputSchema: { type: \"string\" }, // Invalid - should be object\n },\n ];\n\n const mockResponse = {\n tools: mockTools,\n nextCursor: undefined,\n };\n\n mockClientInstance.listTools.mockResolvedValue(mockResponse);\n\n await expect(client.listTools()).rejects.toThrow(\n \"Input schema for tool invalid-tool is not an object\",\n );\n });\n });\n\n describe(\"callTool\", () => {\n it(\"should call a tool with arguments\", async () => {\n const endpoint = \"https://api.example.com/mcp\";\n const client = await MCPClient.create(\n endpoint,\n MCPTransport.HTTP,\n undefined,\n undefined,\n undefined,\n );\n\n const mockResult = { success: true, data: \"test result\" };\n mockClientInstance.callTool.mockResolvedValue(mockResult);\n\n const result = await client.callTool(\"testTool\", {\n arg1: \"value1\",\n arg2: 42,\n });\n\n expect(mockClientInstance.callTool).toHaveBeenCalledWith({\n name: \"testTool\",\n arguments: { arg1: \"value1\", arg2: 42 },\n });\n expect(result).toBe(mockResult);\n });\n\n it(\"should handle tool call errors\", async () => {\n const endpoint = \"https://api.example.com/mcp\";\n const client = await MCPClient.create(\n endpoint,\n MCPTransport.HTTP,\n undefined,\n undefined,\n undefined,\n );\n const error = new Error(\"Tool call failed\");\n mockClientInstance.callTool.mockRejectedValue(error);\n\n await expect(client.callTool(\"testTool\", {})).rejects.toThrow(\n \"Tool call failed\",\n );\n });\n });\n\n describe(\"transport initialization\", () => {\n it(\"should initialize HTTP transport with session ID\", async () => {\n const endpoint = \"https://api.example.com/mcp\";\n const headers = { Authorization: \"Bearer token\" };\n\n await MCPClient.create(\n endpoint,\n MCPTransport.HTTP,\n headers,\n undefined,\n undefined,\n );\n\n expect(MockedStreamableHTTPClientTransport).toHaveBeenCalledWith(\n new URL(endpoint),\n { sessionId: undefined, requestInit: { headers } },\n );\n });\n\n it(\"should initialize SSE transport without session ID\", async () => {\n const endpoint = \"https://api.example.com/mcp\";\n const headers = { Authorization: \"Bearer token\" };\n\n await MCPClient.create(\n endpoint,\n MCPTransport.SSE,\n headers,\n undefined,\n undefined,\n );\n\n expect(MockedSSEClientTransport).toHaveBeenCalledWith(new URL(endpoint), {\n requestInit: { headers },\n });\n });\n });\n\n describe(\"client initialization\", () => {\n it(\"should initialize client with correct name and version\", async () => {\n const endpoint = \"https://api.example.com/mcp\";\n\n await MCPClient.create(\n endpoint,\n MCPTransport.HTTP,\n undefined,\n undefined,\n undefined,\n );\n\n expect(MockedClient).toHaveBeenCalledWith(\n {\n name: \"tambo-mcp-client\",\n version: \"1.0.0\",\n },\n { capabilities: {} },\n );\n });\n });\n\n describe(\"handlers (elicitation/sampling)\", () => {\n it(\"sets handlers on create when provided\", async () => {\n const endpoint = \"https://api.example.com/mcp\";\n const elicitation = jest.fn(async () => ({}) as any);\n const sampling = jest.fn(async () => ({}) as any);\n\n await MCPClient.create(\n endpoint,\n MCPTransport.HTTP,\n undefined,\n undefined,\n undefined,\n { elicitation, sampling },\n );\n\n expect(MockedClient).toHaveBeenLastCalledWith(\n {\n name: \"tambo-mcp-client\",\n version: \"1.0.0\",\n },\n {\n capabilities: {\n elicitation: {},\n sampling: {},\n },\n },\n );\n\n // Request handlers should be set for both\n expect(mockClientInstance.setRequestHandler).toHaveBeenCalled();\n expect(\n (mockClientInstance.setRequestHandler as jest.Mock).mock.calls.length,\n ).toBeGreaterThanOrEqual(2);\n });\n\n it(\"removes elicitation handler when set to undefined\", async () => {\n const endpoint = \"https://api.example.com/mcp\";\n const client = await MCPClient.create(\n endpoint,\n MCPTransport.HTTP,\n undefined,\n undefined,\n undefined,\n {\n elicitation: async () => ({}) as any,\n },\n );\n\n const removeSpy = mockClientInstance.removeRequestHandler as jest.Mock;\n\n // then remove\n removeSpy.mockClear();\n await client.updateElicitationHandler(undefined);\n expect(removeSpy).toHaveBeenCalledWith(expect.any(String));\n });\n\n it(\"removes sampling handler when set to undefined\", async () => {\n const endpoint = \"https://api.example.com/mcp\";\n const client = await MCPClient.create(\n endpoint,\n MCPTransport.HTTP,\n undefined,\n undefined,\n undefined,\n {\n sampling: async () => ({}) as any,\n },\n );\n\n const removeSpy = mockClientInstance.removeRequestHandler as jest.Mock;\n\n // then remove\n removeSpy.mockClear();\n await client.updateSamplingHandler(undefined);\n expect(removeSpy).toHaveBeenCalledWith(expect.any(String));\n });\n });\n});\n"]}