@tambo-ai/react 0.65.3 → 0.66.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (346) hide show
  1. package/README.md +120 -20
  2. package/dist/{providers/hoc → hoc}/with-tambo-interactable.d.ts +2 -2
  3. package/dist/hoc/with-tambo-interactable.d.ts.map +1 -0
  4. package/dist/{providers/hoc → hoc}/with-tambo-interactable.js +29 -2
  5. package/dist/hoc/with-tambo-interactable.js.map +1 -0
  6. package/dist/hoc/with-tambo-interactable.test.d.ts +2 -0
  7. package/dist/hoc/with-tambo-interactable.test.d.ts.map +1 -0
  8. package/dist/hoc/with-tambo-interactable.test.js +192 -0
  9. package/dist/hoc/with-tambo-interactable.test.js.map +1 -0
  10. package/dist/hooks/index.d.ts +1 -1
  11. package/dist/hooks/index.d.ts.map +1 -1
  12. package/dist/hooks/index.js +2 -1
  13. package/dist/hooks/index.js.map +1 -1
  14. package/dist/hooks/use-current-message.d.ts +51 -7
  15. package/dist/hooks/use-current-message.d.ts.map +1 -1
  16. package/dist/hooks/use-current-message.js +50 -6
  17. package/dist/hooks/use-current-message.js.map +1 -1
  18. package/dist/hooks/use-current-message.test.d.ts +2 -0
  19. package/dist/hooks/use-current-message.test.d.ts.map +1 -0
  20. package/dist/hooks/use-current-message.test.js +264 -0
  21. package/dist/hooks/use-current-message.test.js.map +1 -0
  22. package/dist/index.d.ts +10 -8
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +7 -3
  25. package/dist/index.js.map +1 -1
  26. package/dist/mcp/index.d.ts +1 -1
  27. package/dist/mcp/index.d.ts.map +1 -1
  28. package/dist/mcp/index.js +2 -1
  29. package/dist/mcp/index.js.map +1 -1
  30. package/dist/mcp/mcp-hooks.d.ts +77 -6
  31. package/dist/mcp/mcp-hooks.d.ts.map +1 -1
  32. package/dist/mcp/mcp-hooks.js +104 -40
  33. package/dist/mcp/mcp-hooks.js.map +1 -1
  34. package/dist/mcp/mcp-hooks.test.js +83 -18
  35. package/dist/mcp/mcp-hooks.test.js.map +1 -1
  36. package/dist/mcp/tambo-mcp-provider.d.ts.map +1 -1
  37. package/dist/mcp/tambo-mcp-provider.js +2 -1
  38. package/dist/mcp/tambo-mcp-provider.js.map +1 -1
  39. package/dist/model/component-metadata.d.ts +444 -14
  40. package/dist/model/component-metadata.d.ts.map +1 -1
  41. package/dist/model/component-metadata.js.map +1 -1
  42. package/dist/model/generate-component-response.d.ts +12 -1
  43. package/dist/model/generate-component-response.d.ts.map +1 -1
  44. package/dist/model/generate-component-response.js.map +1 -1
  45. package/dist/model/resource-info.d.ts +55 -0
  46. package/dist/model/resource-info.d.ts.map +1 -0
  47. package/dist/model/resource-info.js +3 -0
  48. package/dist/model/resource-info.js.map +1 -0
  49. package/dist/providers/index.d.ts +1 -1
  50. package/dist/providers/index.d.ts.map +1 -1
  51. package/dist/providers/index.js.map +1 -1
  52. package/dist/providers/tambo-component-provider.d.ts +4 -4
  53. package/dist/providers/tambo-component-provider.d.ts.map +1 -1
  54. package/dist/providers/tambo-component-provider.js.map +1 -1
  55. package/dist/providers/tambo-interactable-provider-partial-updates.test.js +87 -87
  56. package/dist/providers/tambo-interactable-provider-partial-updates.test.js.map +1 -1
  57. package/dist/providers/tambo-interactable-provider.d.ts +2 -3
  58. package/dist/providers/tambo-interactable-provider.d.ts.map +1 -1
  59. package/dist/providers/tambo-interactable-provider.js +47 -41
  60. package/dist/providers/tambo-interactable-provider.js.map +1 -1
  61. package/dist/providers/tambo-interactables-additional-context-edge-cases.test.js +9 -9
  62. package/dist/providers/tambo-interactables-additional-context-edge-cases.test.js.map +1 -1
  63. package/dist/providers/tambo-interactables-additional-context.test.js +11 -11
  64. package/dist/providers/tambo-interactables-additional-context.test.js.map +1 -1
  65. package/dist/providers/tambo-registry-provider.d.ts +28 -7
  66. package/dist/providers/tambo-registry-provider.d.ts.map +1 -1
  67. package/dist/providers/tambo-registry-provider.js +70 -181
  68. package/dist/providers/tambo-registry-provider.js.map +1 -1
  69. package/dist/providers/tambo-registry-provider.test.js +152 -30
  70. package/dist/providers/tambo-registry-provider.test.js.map +1 -1
  71. package/dist/providers/tambo-registry-schema-compat.test.d.ts +2 -0
  72. package/dist/providers/tambo-registry-schema-compat.test.d.ts.map +1 -0
  73. package/dist/providers/tambo-registry-schema-compat.test.js +616 -0
  74. package/dist/providers/tambo-registry-schema-compat.test.js.map +1 -0
  75. package/dist/providers/tambo-stubs.d.ts +2 -2
  76. package/dist/providers/tambo-stubs.d.ts.map +1 -1
  77. package/dist/providers/tambo-stubs.js +5 -0
  78. package/dist/providers/tambo-stubs.js.map +1 -1
  79. package/dist/providers/tambo-thread-input-provider.d.ts +1 -0
  80. package/dist/providers/tambo-thread-input-provider.d.ts.map +1 -1
  81. package/dist/providers/tambo-thread-input-provider.js +3 -3
  82. package/dist/providers/tambo-thread-input-provider.js.map +1 -1
  83. package/dist/providers/tambo-thread-provider.d.ts.map +1 -1
  84. package/dist/providers/tambo-thread-provider.js.map +1 -1
  85. package/dist/providers/tambo-thread-provider.test.js +32 -36
  86. package/dist/providers/tambo-thread-provider.test.js.map +1 -1
  87. package/dist/schema/index.d.ts +6 -0
  88. package/dist/schema/index.d.ts.map +1 -0
  89. package/dist/schema/index.js +18 -0
  90. package/dist/schema/index.js.map +1 -0
  91. package/dist/schema/json-schema.d.ts +35 -0
  92. package/dist/schema/json-schema.d.ts.map +1 -0
  93. package/dist/schema/json-schema.js +103 -0
  94. package/dist/schema/json-schema.js.map +1 -0
  95. package/dist/schema/schema.d.ts +66 -0
  96. package/dist/schema/schema.d.ts.map +1 -0
  97. package/dist/schema/schema.js +189 -0
  98. package/dist/schema/schema.js.map +1 -0
  99. package/dist/schema/schema.test.d.ts +2 -0
  100. package/dist/schema/schema.test.d.ts.map +1 -0
  101. package/dist/schema/schema.test.js +41 -0
  102. package/dist/schema/schema.test.js.map +1 -0
  103. package/dist/schema/standard-schema.d.ts +21 -0
  104. package/dist/schema/standard-schema.d.ts.map +1 -0
  105. package/dist/schema/standard-schema.js +37 -0
  106. package/dist/schema/standard-schema.js.map +1 -0
  107. package/dist/schema/validate.d.ts +14 -0
  108. package/dist/schema/validate.d.ts.map +1 -0
  109. package/dist/schema/validate.js +148 -0
  110. package/dist/schema/validate.js.map +1 -0
  111. package/dist/schema/validate.test.d.ts +2 -0
  112. package/dist/schema/validate.test.d.ts.map +1 -0
  113. package/dist/schema/validate.test.js +128 -0
  114. package/dist/schema/validate.test.js.map +1 -0
  115. package/dist/schema/zod.d.ts +54 -0
  116. package/dist/schema/zod.d.ts.map +1 -0
  117. package/dist/schema/zod.js +147 -0
  118. package/dist/schema/zod.js.map +1 -0
  119. package/dist/testing/tools.d.ts +29 -15
  120. package/dist/testing/tools.d.ts.map +1 -1
  121. package/dist/testing/tools.js +64 -19
  122. package/dist/testing/tools.js.map +1 -1
  123. package/dist/util/generate-component.d.ts.map +1 -1
  124. package/dist/util/generate-component.js +3 -3
  125. package/dist/util/generate-component.js.map +1 -1
  126. package/dist/util/mcp-server-utils.d.ts +23 -0
  127. package/dist/util/mcp-server-utils.d.ts.map +1 -0
  128. package/dist/util/mcp-server-utils.js +107 -0
  129. package/dist/util/mcp-server-utils.js.map +1 -0
  130. package/dist/util/mcp-server-utils.test.d.ts +2 -0
  131. package/dist/util/mcp-server-utils.test.d.ts.map +1 -0
  132. package/dist/util/mcp-server-utils.test.js +287 -0
  133. package/dist/util/mcp-server-utils.test.js.map +1 -0
  134. package/dist/util/message-builder.d.ts +2 -1
  135. package/dist/util/message-builder.d.ts.map +1 -1
  136. package/dist/util/message-builder.js +54 -36
  137. package/dist/util/message-builder.js.map +1 -1
  138. package/dist/util/message-builder.test.js +500 -13
  139. package/dist/util/message-builder.test.js.map +1 -1
  140. package/dist/util/registry-validators.d.ts +26 -0
  141. package/dist/util/registry-validators.d.ts.map +1 -0
  142. package/dist/util/registry-validators.js +105 -0
  143. package/dist/util/registry-validators.js.map +1 -0
  144. package/dist/util/registry-validators.test.d.ts +2 -0
  145. package/dist/util/registry-validators.test.d.ts.map +1 -0
  146. package/dist/util/registry-validators.test.js +235 -0
  147. package/dist/util/registry-validators.test.js.map +1 -0
  148. package/dist/util/registry.d.ts +35 -7
  149. package/dist/util/registry.d.ts.map +1 -1
  150. package/dist/util/registry.js +60 -77
  151. package/dist/util/registry.js.map +1 -1
  152. package/dist/util/registry.test.d.ts +2 -0
  153. package/dist/util/registry.test.d.ts.map +1 -0
  154. package/dist/util/registry.test.js +204 -0
  155. package/dist/util/registry.test.js.map +1 -0
  156. package/dist/util/resource-validators.d.ts +16 -0
  157. package/dist/util/resource-validators.d.ts.map +1 -0
  158. package/dist/util/resource-validators.js +34 -0
  159. package/dist/util/resource-validators.js.map +1 -0
  160. package/dist/util/tool-caller.d.ts +2 -2
  161. package/dist/util/tool-caller.d.ts.map +1 -1
  162. package/dist/util/tool-caller.js +12 -4
  163. package/dist/util/tool-caller.js.map +1 -1
  164. package/esm/{providers/hoc → hoc}/with-tambo-interactable.d.ts +2 -2
  165. package/esm/hoc/with-tambo-interactable.d.ts.map +1 -0
  166. package/esm/{providers/hoc → hoc}/with-tambo-interactable.js +29 -2
  167. package/esm/hoc/with-tambo-interactable.js.map +1 -0
  168. package/esm/hoc/with-tambo-interactable.test.d.ts +2 -0
  169. package/esm/hoc/with-tambo-interactable.test.d.ts.map +1 -0
  170. package/esm/hoc/with-tambo-interactable.test.js +187 -0
  171. package/esm/hoc/with-tambo-interactable.test.js.map +1 -0
  172. package/esm/hooks/index.d.ts +1 -1
  173. package/esm/hooks/index.d.ts.map +1 -1
  174. package/esm/hooks/index.js +1 -1
  175. package/esm/hooks/index.js.map +1 -1
  176. package/esm/hooks/use-current-message.d.ts +51 -7
  177. package/esm/hooks/use-current-message.d.ts.map +1 -1
  178. package/esm/hooks/use-current-message.js +48 -5
  179. package/esm/hooks/use-current-message.js.map +1 -1
  180. package/esm/hooks/use-current-message.test.d.ts +2 -0
  181. package/esm/hooks/use-current-message.test.d.ts.map +1 -0
  182. package/esm/hooks/use-current-message.test.js +259 -0
  183. package/esm/hooks/use-current-message.test.js.map +1 -0
  184. package/esm/index.d.ts +10 -8
  185. package/esm/index.d.ts.map +1 -1
  186. package/esm/index.js +4 -2
  187. package/esm/index.js.map +1 -1
  188. package/esm/mcp/index.d.ts +1 -1
  189. package/esm/mcp/index.d.ts.map +1 -1
  190. package/esm/mcp/index.js +1 -1
  191. package/esm/mcp/index.js.map +1 -1
  192. package/esm/mcp/mcp-hooks.d.ts +77 -6
  193. package/esm/mcp/mcp-hooks.d.ts.map +1 -1
  194. package/esm/mcp/mcp-hooks.js +103 -40
  195. package/esm/mcp/mcp-hooks.js.map +1 -1
  196. package/esm/mcp/mcp-hooks.test.js +84 -19
  197. package/esm/mcp/mcp-hooks.test.js.map +1 -1
  198. package/esm/mcp/tambo-mcp-provider.d.ts.map +1 -1
  199. package/esm/mcp/tambo-mcp-provider.js +2 -1
  200. package/esm/mcp/tambo-mcp-provider.js.map +1 -1
  201. package/esm/model/component-metadata.d.ts +444 -14
  202. package/esm/model/component-metadata.d.ts.map +1 -1
  203. package/esm/model/component-metadata.js.map +1 -1
  204. package/esm/model/generate-component-response.d.ts +12 -1
  205. package/esm/model/generate-component-response.d.ts.map +1 -1
  206. package/esm/model/generate-component-response.js.map +1 -1
  207. package/esm/model/resource-info.d.ts +55 -0
  208. package/esm/model/resource-info.d.ts.map +1 -0
  209. package/esm/model/resource-info.js +2 -0
  210. package/esm/model/resource-info.js.map +1 -0
  211. package/esm/providers/index.d.ts +1 -1
  212. package/esm/providers/index.d.ts.map +1 -1
  213. package/esm/providers/index.js.map +1 -1
  214. package/esm/providers/tambo-component-provider.d.ts +4 -4
  215. package/esm/providers/tambo-component-provider.d.ts.map +1 -1
  216. package/esm/providers/tambo-component-provider.js.map +1 -1
  217. package/esm/providers/tambo-interactable-provider-partial-updates.test.js +1 -1
  218. package/esm/providers/tambo-interactable-provider-partial-updates.test.js.map +1 -1
  219. package/esm/providers/tambo-interactable-provider.d.ts +2 -3
  220. package/esm/providers/tambo-interactable-provider.d.ts.map +1 -1
  221. package/esm/providers/tambo-interactable-provider.js +44 -38
  222. package/esm/providers/tambo-interactable-provider.js.map +1 -1
  223. package/esm/providers/tambo-interactables-additional-context-edge-cases.test.js +3 -3
  224. package/esm/providers/tambo-interactables-additional-context-edge-cases.test.js.map +1 -1
  225. package/esm/providers/tambo-interactables-additional-context.test.js +3 -3
  226. package/esm/providers/tambo-interactables-additional-context.test.js.map +1 -1
  227. package/esm/providers/tambo-registry-provider.d.ts +28 -7
  228. package/esm/providers/tambo-registry-provider.d.ts.map +1 -1
  229. package/esm/providers/tambo-registry-provider.js +67 -175
  230. package/esm/providers/tambo-registry-provider.js.map +1 -1
  231. package/esm/providers/tambo-registry-provider.test.js +148 -26
  232. package/esm/providers/tambo-registry-provider.test.js.map +1 -1
  233. package/esm/providers/tambo-registry-schema-compat.test.d.ts +2 -0
  234. package/esm/providers/tambo-registry-schema-compat.test.d.ts.map +1 -0
  235. package/esm/providers/tambo-registry-schema-compat.test.js +578 -0
  236. package/esm/providers/tambo-registry-schema-compat.test.js.map +1 -0
  237. package/esm/providers/tambo-stubs.d.ts +2 -2
  238. package/esm/providers/tambo-stubs.d.ts.map +1 -1
  239. package/esm/providers/tambo-stubs.js +5 -0
  240. package/esm/providers/tambo-stubs.js.map +1 -1
  241. package/esm/providers/tambo-thread-input-provider.d.ts +1 -0
  242. package/esm/providers/tambo-thread-input-provider.d.ts.map +1 -1
  243. package/esm/providers/tambo-thread-input-provider.js +3 -3
  244. package/esm/providers/tambo-thread-input-provider.js.map +1 -1
  245. package/esm/providers/tambo-thread-provider.d.ts.map +1 -1
  246. package/esm/providers/tambo-thread-provider.js.map +1 -1
  247. package/esm/providers/tambo-thread-provider.test.js +24 -28
  248. package/esm/providers/tambo-thread-provider.test.js.map +1 -1
  249. package/esm/schema/index.d.ts +6 -0
  250. package/esm/schema/index.d.ts.map +1 -0
  251. package/esm/schema/index.js +6 -0
  252. package/esm/schema/index.js.map +1 -0
  253. package/esm/schema/json-schema.d.ts +35 -0
  254. package/esm/schema/json-schema.d.ts.map +1 -0
  255. package/esm/schema/json-schema.js +98 -0
  256. package/esm/schema/json-schema.js.map +1 -0
  257. package/esm/schema/schema.d.ts +66 -0
  258. package/esm/schema/schema.d.ts.map +1 -0
  259. package/esm/schema/schema.js +182 -0
  260. package/esm/schema/schema.js.map +1 -0
  261. package/esm/schema/schema.test.d.ts +2 -0
  262. package/esm/schema/schema.test.d.ts.map +1 -0
  263. package/esm/schema/schema.test.js +39 -0
  264. package/esm/schema/schema.test.js.map +1 -0
  265. package/esm/schema/standard-schema.d.ts +21 -0
  266. package/esm/schema/standard-schema.d.ts.map +1 -0
  267. package/esm/schema/standard-schema.js +34 -0
  268. package/esm/schema/standard-schema.js.map +1 -0
  269. package/esm/schema/validate.d.ts +14 -0
  270. package/esm/schema/validate.d.ts.map +1 -0
  271. package/esm/schema/validate.js +145 -0
  272. package/esm/schema/validate.js.map +1 -0
  273. package/esm/schema/validate.test.d.ts +2 -0
  274. package/esm/schema/validate.test.d.ts.map +1 -0
  275. package/esm/schema/validate.test.js +126 -0
  276. package/esm/schema/validate.test.js.map +1 -0
  277. package/esm/schema/zod.d.ts +54 -0
  278. package/esm/schema/zod.d.ts.map +1 -0
  279. package/esm/schema/zod.js +136 -0
  280. package/esm/schema/zod.js.map +1 -0
  281. package/esm/testing/tools.d.ts +29 -15
  282. package/esm/testing/tools.d.ts.map +1 -1
  283. package/esm/testing/tools.js +62 -16
  284. package/esm/testing/tools.js.map +1 -1
  285. package/esm/util/generate-component.d.ts.map +1 -1
  286. package/esm/util/generate-component.js +3 -3
  287. package/esm/util/generate-component.js.map +1 -1
  288. package/esm/util/mcp-server-utils.d.ts +23 -0
  289. package/esm/util/mcp-server-utils.d.ts.map +1 -0
  290. package/esm/util/mcp-server-utils.js +102 -0
  291. package/esm/util/mcp-server-utils.js.map +1 -0
  292. package/esm/util/mcp-server-utils.test.d.ts +2 -0
  293. package/esm/util/mcp-server-utils.test.d.ts.map +1 -0
  294. package/esm/util/mcp-server-utils.test.js +285 -0
  295. package/esm/util/mcp-server-utils.test.js.map +1 -0
  296. package/esm/util/message-builder.d.ts +2 -1
  297. package/esm/util/message-builder.d.ts.map +1 -1
  298. package/esm/util/message-builder.js +54 -36
  299. package/esm/util/message-builder.js.map +1 -1
  300. package/esm/util/message-builder.test.js +500 -13
  301. package/esm/util/message-builder.test.js.map +1 -1
  302. package/esm/util/registry-validators.d.ts +26 -0
  303. package/esm/util/registry-validators.d.ts.map +1 -0
  304. package/esm/util/registry-validators.js +100 -0
  305. package/esm/util/registry-validators.js.map +1 -0
  306. package/esm/util/registry-validators.test.d.ts +2 -0
  307. package/esm/util/registry-validators.test.d.ts.map +1 -0
  308. package/esm/util/registry-validators.test.js +233 -0
  309. package/esm/util/registry-validators.test.js.map +1 -0
  310. package/esm/util/registry.d.ts +35 -7
  311. package/esm/util/registry.d.ts.map +1 -1
  312. package/esm/util/registry.js +57 -73
  313. package/esm/util/registry.js.map +1 -1
  314. package/esm/util/registry.test.d.ts +2 -0
  315. package/esm/util/registry.test.d.ts.map +1 -0
  316. package/esm/util/registry.test.js +169 -0
  317. package/esm/util/registry.test.js.map +1 -0
  318. package/esm/util/resource-validators.d.ts +16 -0
  319. package/esm/util/resource-validators.d.ts.map +1 -0
  320. package/esm/util/resource-validators.js +30 -0
  321. package/esm/util/resource-validators.js.map +1 -0
  322. package/esm/util/tool-caller.d.ts +2 -2
  323. package/esm/util/tool-caller.d.ts.map +1 -1
  324. package/esm/util/tool-caller.js +12 -4
  325. package/esm/util/tool-caller.js.map +1 -1
  326. package/package.json +13 -8
  327. package/dist/providers/hoc/with-tambo-interactable.d.ts.map +0 -1
  328. package/dist/providers/hoc/with-tambo-interactable.js.map +0 -1
  329. package/dist/util/validate-zod-schema.d.ts +0 -10
  330. package/dist/util/validate-zod-schema.d.ts.map +0 -1
  331. package/dist/util/validate-zod-schema.js +0 -100
  332. package/dist/util/validate-zod-schema.js.map +0 -1
  333. package/dist/util/validate-zod-schema.test.d.ts +0 -2
  334. package/dist/util/validate-zod-schema.test.d.ts.map +0 -1
  335. package/dist/util/validate-zod-schema.test.js +0 -96
  336. package/dist/util/validate-zod-schema.test.js.map +0 -1
  337. package/esm/providers/hoc/with-tambo-interactable.d.ts.map +0 -1
  338. package/esm/providers/hoc/with-tambo-interactable.js.map +0 -1
  339. package/esm/util/validate-zod-schema.d.ts +0 -10
  340. package/esm/util/validate-zod-schema.d.ts.map +0 -1
  341. package/esm/util/validate-zod-schema.js +0 -97
  342. package/esm/util/validate-zod-schema.js.map +0 -1
  343. package/esm/util/validate-zod-schema.test.d.ts +0 -2
  344. package/esm/util/validate-zod-schema.test.d.ts.map +0 -1
  345. package/esm/util/validate-zod-schema.test.js +0 -94
  346. package/esm/util/validate-zod-schema.test.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"message-builder.test.js","sourceRoot":"","sources":["../../src/util/message-builder.test.ts"],"names":[],"mappings":";;AAAA,uDAAwD;AAIxD,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,MAAM,qBAAqB,GAAG,CAC5B,YAAkC,EAAE,EACvB,EAAE,CAAC,CAAC;QACjB,EAAE,EAAE,SAAS;QACb,IAAI,EAAE,gBAAgB;QACtB,OAAO,EAAE,iCAAiC;QAC1C,IAAI,EAAE,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,gBAAgB,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;QAC7D,IAAI,EAAE,IAAI;QACV,IAAI,EAAE,WAAW;QACjB,GAAG,SAAS;KACb,CAAC,CAAC;IAEH,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;QAC7C,MAAM,MAAM,GAAG,IAAA,qCAAmB,EAAC,aAAa,EAAE,EAAE,CAAC,CAAC;QAEtD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACrB;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE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CAAC;QAEF,MAAM,MAAM,GAAG,IAAA,qCAAmB,EAAC,cAAc,EAAE,MAAM,CAAC,CAAC;QAE3D,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACpC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACzC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAEzC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;YACnC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;QACvE,CAAC;QACD,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;YACnC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;QACxE,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { buildMessageContent } from \"./message-builder\";\nimport { StagedImage } from \"../hooks/use-message-images\";\nimport type TamboAI from \"@tambo-ai/typescript-sdk\";\n\ndescribe(\"buildMessageContent\", () => {\n const createMockStagedImage = (\n overrides: Partial<StagedImage> = {},\n ): StagedImage => ({\n id: \"test-id\",\n name: \"test-image.png\",\n dataUrl: \"data:image/png;base64,mock-data\",\n file: new File([\"\"], \"test-image.png\", { type: \"image/png\" }),\n size: 1024,\n type: \"image/png\",\n ...overrides,\n });\n\n it(\"should build content with text only\", () => {\n const result = buildMessageContent(\"Hello world\", []);\n\n expect(result).toEqual([\n {\n type: \"text\",\n text: \"Hello world\",\n },\n ]);\n });\n\n it(\"should build content with images only\", () => {\n const image = createMockStagedImage({\n dataUrl: \"data:image/png;base64,abc123\",\n });\n\n const result = buildMessageContent(\"\", [image]);\n\n expect(result).toEqual([\n {\n type: \"image_url\",\n image_url: {\n url: \"data:image/png;base64,abc123\",\n },\n },\n ]);\n });\n\n it(\"should build content with both text and images\", () => {\n const images = [\n createMockStagedImage({\n id: \"img1\",\n dataUrl: \"data:image/png;base64,abc123\",\n }),\n createMockStagedImage({\n id: \"img2\",\n dataUrl: \"data:image/jpeg;base64,def456\",\n }),\n ];\n\n const result = buildMessageContent(\"Check these images:\", images);\n\n expect(result).toEqual([\n {\n type: \"text\",\n text: \"Check these images:\",\n },\n {\n type: \"image_url\",\n image_url: {\n url: \"data:image/png;base64,abc123\",\n },\n },\n {\n type: \"image_url\",\n image_url: {\n url: \"data:image/jpeg;base64,def456\",\n },\n },\n ]);\n });\n\n it(\"should trim whitespace from text\", () => {\n const result = buildMessageContent(\" Hello world \", []);\n\n expect(result).toEqual([\n {\n type: \"text\",\n text: \"Hello world\",\n },\n ]);\n });\n\n it(\"should skip empty text but keep images\", () => {\n const image = createMockStagedImage();\n const result = buildMessageContent(\" \", [image]);\n\n expect(result).toEqual([\n {\n type: \"image_url\",\n image_url: {\n url: \"data:image/png;base64,mock-data\",\n },\n },\n ]);\n });\n\n it(\"should handle multiple images correctly\", () => {\n const images = [\n createMockStagedImage({\n id: \"img1\",\n name: \"photo1.jpg\",\n dataUrl: \"data:image/jpeg;base64,photo1data\",\n }),\n createMockStagedImage({\n id: \"img2\",\n name: \"photo2.png\",\n dataUrl: \"data:image/png;base64,photo2data\",\n }),\n createMockStagedImage({\n id: \"img3\",\n name: \"photo3.gif\",\n dataUrl: \"data:image/gif;base64,photo3data\",\n }),\n ];\n\n const result = buildMessageContent(\"Multiple images:\", images);\n\n expect(result).toHaveLength(4); // 1 text + 3 images\n expect(result[0]).toEqual({\n type: \"text\",\n text: \"Multiple images:\",\n });\n expect(result[1]).toEqual({\n type: \"image_url\",\n image_url: {\n url: \"data:image/jpeg;base64,photo1data\",\n },\n });\n expect(result[2]).toEqual({\n type: \"image_url\",\n image_url: {\n url: \"data:image/png;base64,photo2data\",\n },\n });\n expect(result[3]).toEqual({\n type: \"image_url\",\n image_url: {\n url: \"data:image/gif;base64,photo3data\",\n },\n });\n });\n\n it(\"should throw error when no content provided\", () => {\n expect(() => {\n buildMessageContent(\"\", []);\n }).toThrow(\"Message must contain text or images\");\n });\n\n it(\"should throw error when only whitespace provided\", () => {\n expect(() => {\n buildMessageContent(\" \\n\\t \", []);\n }).toThrow(\"Message must contain text or images\");\n });\n\n it(\"should return correct content type structure\", () => {\n const image = createMockStagedImage();\n const result = buildMessageContent(\"Test\", [image]);\n\n // Verify the structure matches ChatCompletionContentPart interface\n result.forEach((part: TamboAI.Beta.Threads.ChatCompletionContentPart) => {\n expect(part).toHaveProperty(\"type\");\n expect([\"text\", \"image_url\", \"input_audio\"]).toContain(part.type);\n\n if (part.type === \"text\") {\n expect(part).toHaveProperty(\"text\");\n expect(typeof part.text).toBe(\"string\");\n }\n\n if (part.type === \"image_url\") {\n expect(part).toHaveProperty(\"image_url\");\n expect(part.image_url).toHaveProperty(\"url\");\n expect(typeof part.image_url?.url).toBe(\"string\");\n }\n });\n });\n\n it(\"should handle edge case with empty array but valid text\", () => {\n const result = buildMessageContent(\"Just text\", []);\n\n expect(result).toHaveLength(1);\n expect(result[0]).toEqual({\n type: \"text\",\n text: \"Just text\",\n });\n });\n\n it(\"should maintain order of text first then images\", () => {\n const images = [\n createMockStagedImage({\n id: \"first\",\n dataUrl: \"data:image/png;base64,first\",\n }),\n createMockStagedImage({\n id: \"second\",\n dataUrl: \"data:image/png;base64,second\",\n }),\n ];\n\n const result = buildMessageContent(\"Text content\", images);\n\n expect(result[0].type).toBe(\"text\");\n expect(result[1].type).toBe(\"image_url\");\n expect(result[2].type).toBe(\"image_url\");\n\n if (result[1].type === \"image_url\") {\n expect(result[1].image_url?.url).toBe(\"data:image/png;base64,first\");\n }\n if (result[2].type === \"image_url\") {\n expect(result[2].image_url?.url).toBe(\"data:image/png;base64,second\");\n }\n });\n});\n"]}
1
+ {"version":3,"file":"message-builder.test.js","sourceRoot":"","sources":["../../src/util/message-builder.test.ts"],"names":[],"mappings":";;AAEA,uDAAwD;AAExD,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,MAAM,qBAAqB,GAAG,CAC5B,YAAkC,EAAE,EACvB,EAAE,CAAC,CAAC;QACjB,EAAE,EAAE,SAAS;QACb,IAAI,EAAE,gBAAgB;QACtB,OAAO,EAAE,iCAAiC;QAC1C,IAAI,EAAE,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,gBAAgB,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;QAC7D,IAAI,EAAE,IAAI;QACV,IAAI,EAAE,WAAW;QACjB,GAAG,SAAS;KACb,CAAC,CAAC;IAEH,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;QAC7C,MAAM,MAAM,GAAG,IAAA,qCAAmB,EAAC,aAAa,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;QAE1D,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACrB;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,aAAa;aACpB;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAC/C,MAAM,KAAK,GAAG,qBAAqB,CAAC;YAClC,OAAO,EAAE,8BAA8B;SACxC,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG,IAAA,qCAAmB,EAAC,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;QAEpD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACrB;gBACE,IAAI,EAAE,WAAW;gBACjB,SAAS,EAAE;oBACT,GAAG,EAAE,8BAA8B;iBACpC;aACF;SACF,CAAC,CAAC;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,EAChC,+FAA+F,EAC/F,EAAE,EACF,EAAE,CACH,CAAC;YAEF,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;gBACrB;oBACE,IAAI,EAAE,UAAU;oBAChB,QAAQ,EAAE;wBACR,GAAG,EAAE,gCAAgC;qBACtC;iBACF;gBACD;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,KAAK;iBACZ;gBACD;oBACE,IAAI,EAAE,UAAU;oBAChB,QAAQ,EAAE;wBACR,GAAG,EAAE,gCAAgC;qBACtC;iBACF;aACF,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,6DAA6D,EAAE,GAAG,EAAE;YACrE,MAAM,MAAM,GAAG,IAAA,qCAAmB,EAChC,+CAA+C,EAC/C,EAAE,EACF,EAAE,CACH,CAAC;YAEF,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;gBACrB;oBACE,IAAI,EAAE,UAAU;oBAChB,QAAQ,EAAE;wBACR,GAAG,EAAE,gCAAgC;qBACtC;iBACF;aACF,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,iEAAiE,EAAE,GAAG,EAAE;YACzE,qDAAqD;YACrD,MAAM,MAAM,GAAG,IAAA,qCAAmB,EAChC,+CAA+C,EAC/C,EAAE,EACF,EAAE,CACH,CAAC;YAEF,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;YACzC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC1C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import type TamboAI from \"@tambo-ai/typescript-sdk\";\nimport { StagedImage } from \"../hooks/use-message-images\";\nimport { buildMessageContent } from \"./message-builder\";\n\ndescribe(\"buildMessageContent\", () => {\n const createMockStagedImage = (\n overrides: Partial<StagedImage> = {},\n ): StagedImage => ({\n id: \"test-id\",\n name: \"test-image.png\",\n dataUrl: \"data:image/png;base64,mock-data\",\n file: new File([\"\"], \"test-image.png\", { type: \"image/png\" }),\n size: 1024,\n type: \"image/png\",\n ...overrides,\n });\n\n it(\"should build content with text only\", () => {\n const result = buildMessageContent(\"Hello world\", [], {});\n\n expect(result).toEqual([\n {\n type: \"text\",\n text: \"Hello world\",\n },\n ]);\n });\n\n it(\"should build content with images only\", () => {\n const image = createMockStagedImage({\n dataUrl: \"data:image/png;base64,abc123\",\n });\n\n const result = buildMessageContent(\"\", [image], {});\n\n expect(result).toEqual([\n {\n type: \"image_url\",\n image_url: {\n url: \"data:image/png;base64,abc123\",\n },\n },\n ]);\n });\n\n it(\"should build content with both text and images\", () => {\n const images = [\n createMockStagedImage({\n id: \"img1\",\n dataUrl: \"data:image/png;base64,abc123\",\n }),\n createMockStagedImage({\n id: \"img2\",\n dataUrl: \"data:image/jpeg;base64,def456\",\n }),\n ];\n\n const result = buildMessageContent(\"Check these images:\", images, {});\n\n expect(result).toEqual([\n {\n type: \"text\",\n text: \"Check these images:\",\n },\n {\n type: \"image_url\",\n image_url: {\n url: \"data:image/png;base64,abc123\",\n },\n },\n {\n type: \"image_url\",\n image_url: {\n url: \"data:image/jpeg;base64,def456\",\n },\n },\n ]);\n });\n\n it(\"should preserve leading and trailing whitespace in text\", () => {\n const result = buildMessageContent(\" Hello world \", [], {});\n\n expect(result).toEqual([\n {\n type: \"text\",\n text: \" Hello world \",\n },\n ]);\n });\n\n it(\"should skip empty text but keep images\", () => {\n const image = createMockStagedImage();\n const result = buildMessageContent(\" \", [image], {});\n\n expect(result).toEqual([\n {\n type: \"image_url\",\n image_url: {\n url: \"data:image/png;base64,mock-data\",\n },\n },\n ]);\n });\n\n it(\"should handle multiple images correctly\", () => {\n const images = [\n createMockStagedImage({\n id: \"img1\",\n name: \"photo1.jpg\",\n dataUrl: \"data:image/jpeg;base64,photo1data\",\n }),\n createMockStagedImage({\n id: \"img2\",\n name: \"photo2.png\",\n dataUrl: \"data:image/png;base64,photo2data\",\n }),\n createMockStagedImage({\n id: \"img3\",\n name: \"photo3.gif\",\n dataUrl: \"data:image/gif;base64,photo3data\",\n }),\n ];\n\n const result = buildMessageContent(\"Multiple images:\", images, {});\n\n expect(result).toHaveLength(4); // 1 text + 3 images\n expect(result[0]).toEqual({\n type: \"text\",\n text: \"Multiple images:\",\n });\n expect(result[1]).toEqual({\n type: \"image_url\",\n image_url: {\n url: \"data:image/jpeg;base64,photo1data\",\n },\n });\n expect(result[2]).toEqual({\n type: \"image_url\",\n image_url: {\n url: \"data:image/png;base64,photo2data\",\n },\n });\n expect(result[3]).toEqual({\n type: \"image_url\",\n image_url: {\n url: \"data:image/gif;base64,photo3data\",\n },\n });\n });\n\n it(\"should throw error when no content provided\", () => {\n expect(() => {\n buildMessageContent(\"\", [], {});\n }).toThrow(\"Message must contain text or images\");\n });\n\n it(\"should throw error when only whitespace provided\", () => {\n expect(() => {\n buildMessageContent(\" \\n\\t \", [], {});\n }).toThrow(\"Message must contain text or images\");\n });\n\n it(\"should return correct content type structure\", () => {\n const image = createMockStagedImage();\n const result = buildMessageContent(\"Test\", [image], {});\n\n // Verify the structure matches ChatCompletionContentPart interface\n result.forEach((part: TamboAI.Beta.Threads.ChatCompletionContentPart) => {\n expect(part).toHaveProperty(\"type\");\n expect([\"text\", \"image_url\", \"input_audio\"]).toContain(part.type);\n\n if (part.type === \"text\") {\n expect(part).toHaveProperty(\"text\");\n expect(typeof part.text).toBe(\"string\");\n }\n\n if (part.type === \"image_url\") {\n expect(part).toHaveProperty(\"image_url\");\n expect(part.image_url).toHaveProperty(\"url\");\n expect(typeof part.image_url?.url).toBe(\"string\");\n }\n });\n });\n\n it(\"should handle edge case with empty array but valid text\", () => {\n const result = buildMessageContent(\"Just text\", [], {});\n\n expect(result).toHaveLength(1);\n expect(result[0]).toEqual({\n type: \"text\",\n text: \"Just text\",\n });\n });\n\n it(\"should maintain order of text first then images\", () => {\n const images = [\n createMockStagedImage({\n id: \"first\",\n dataUrl: \"data:image/png;base64,first\",\n }),\n createMockStagedImage({\n id: \"second\",\n dataUrl: \"data:image/png;base64,second\",\n }),\n ];\n\n const result = buildMessageContent(\"Text content\", images, {});\n\n expect(result[0].type).toBe(\"text\");\n expect(result[1].type).toBe(\"image_url\");\n expect(result[2].type).toBe(\"image_url\");\n\n if (result[1].type === \"image_url\") {\n expect(result[1].image_url?.url).toBe(\"data:image/png;base64,first\");\n }\n if (result[2].type === \"image_url\") {\n expect(result[2].image_url?.url).toBe(\"data:image/png;base64,second\");\n }\n });\n\n describe(\"resource parsing\", () => {\n it(\"should parse a single resource reference\", () => {\n const result = buildMessageContent(\n \"Check @tambo-1hfs429:tambo:test://static/resource/1\",\n [],\n {},\n );\n\n expect(result).toEqual([\n {\n type: \"text\",\n text: \"Check \",\n },\n {\n type: \"resource\",\n resource: {\n uri: \"tambo:test://static/resource/1\",\n },\n },\n ]);\n });\n\n it(\"should parse resource reference at the start of text\", () => {\n const result = buildMessageContent(\n \"@tambo-1hfs429:tambo:test://static/resource/1 check this\",\n [],\n {},\n );\n\n expect(result).toEqual([\n {\n type: \"resource\",\n resource: {\n uri: \"tambo:test://static/resource/1\",\n },\n },\n {\n type: \"text\",\n text: \" check this\",\n },\n ]);\n });\n\n it(\"should parse resource reference at the end of text\", () => {\n const result = buildMessageContent(\n \"Check this @tambo-1hfs429:tambo:test://static/resource/1\",\n [],\n {},\n );\n\n expect(result).toEqual([\n {\n type: \"text\",\n text: \"Check this \",\n },\n {\n type: \"resource\",\n resource: {\n uri: \"tambo:test://static/resource/1\",\n },\n },\n ]);\n });\n\n it(\"should parse resource reference with name from resourceNames map\", () => {\n const resourceNames = {\n \"tambo-1hfs429:tambo:test://static/resource/1\": \"Documentation.pdf\",\n };\n\n const result = buildMessageContent(\n \"Check @tambo-1hfs429:tambo:test://static/resource/1\",\n [],\n resourceNames,\n );\n\n expect(result).toEqual([\n {\n type: \"text\",\n text: \"Check \",\n },\n {\n type: \"resource\",\n resource: {\n uri: \"tambo:test://static/resource/1\",\n name: \"Documentation.pdf\",\n },\n },\n ]);\n });\n\n it(\"should parse resource reference without name when not in resourceNames map\", () => {\n const resourceNames = {\n \"other-server:other-uri\": \"Other Resource\",\n };\n\n const result = buildMessageContent(\n \"Check @tambo-1hfs429:tambo:test://static/resource/1\",\n [],\n resourceNames,\n );\n\n expect(result).toEqual([\n {\n type: \"text\",\n text: \"Check \",\n },\n {\n type: \"resource\",\n resource: {\n uri: \"tambo:test://static/resource/1\",\n },\n },\n ]);\n });\n\n it(\"should parse multiple resource references\", () => {\n const result = buildMessageContent(\n \"Check @tambo-1hfs429:tambo:test://static/resource/1 and @tambo-1hfs429:tambo:test://static/resource/2\",\n [],\n {},\n );\n\n expect(result).toEqual([\n {\n type: \"text\",\n text: \"Check \",\n },\n {\n type: \"resource\",\n resource: {\n uri: \"tambo:test://static/resource/1\",\n },\n },\n {\n type: \"text\",\n text: \" and \",\n },\n {\n type: \"resource\",\n resource: {\n uri: \"tambo:test://static/resource/2\",\n },\n },\n ]);\n });\n\n it(\"should preserve whitespace between consecutive resource references\", () => {\n const result = buildMessageContent(\n \"@tambo-1hfs429:tambo:test://static/resource/1 @tambo-1hfs429:tambo:test://static/resource/2\",\n [],\n {},\n );\n\n expect(result).toEqual([\n {\n type: \"resource\",\n resource: {\n uri: \"tambo:test://static/resource/1\",\n },\n },\n {\n type: \"text\",\n text: \" \",\n },\n {\n type: \"resource\",\n resource: {\n uri: \"tambo:test://static/resource/2\",\n },\n },\n ]);\n });\n\n it(\"should parse resources with text before, between, and after\", () => {\n const result = buildMessageContent(\n \"Before @tambo-1hfs429:tambo:test://static/resource/1 middle @linear:file://path/to/file.txt after\",\n [],\n {},\n );\n\n expect(result).toEqual([\n {\n type: \"text\",\n text: \"Before \",\n },\n {\n type: \"resource\",\n resource: {\n uri: \"tambo:test://static/resource/1\",\n },\n },\n {\n type: \"text\",\n text: \" middle \",\n },\n {\n type: \"resource\",\n resource: {\n uri: \"file://path/to/file.txt\",\n },\n },\n {\n type: \"text\",\n text: \" after\",\n },\n ]);\n });\n\n it(\"should parse resources from different server keys\", () => {\n const result = buildMessageContent(\n \"@tambo-1hfs429:tambo:test://static/resource/1 and @linear:linear://issue/123\",\n [],\n {},\n );\n\n expect(result).toEqual([\n {\n type: \"resource\",\n resource: {\n uri: \"tambo:test://static/resource/1\",\n },\n },\n {\n type: \"text\",\n text: \" and \",\n },\n {\n type: \"resource\",\n resource: {\n uri: \"linear://issue/123\",\n },\n },\n ]);\n });\n\n it(\"should parse resources with various URI formats and preserve whitespace\", () => {\n const result = buildMessageContent(\n \"@server1:file:///path/to/file.txt @server2:https://example.com/doc.pdf @server3:s3://bucket/key.json\",\n [],\n {},\n );\n\n expect(result).toEqual([\n {\n type: \"resource\",\n resource: {\n uri: \"file:///path/to/file.txt\",\n },\n },\n {\n type: \"text\",\n text: \" \",\n },\n {\n type: \"resource\",\n resource: {\n uri: \"https://example.com/doc.pdf\",\n },\n },\n {\n type: \"text\",\n text: \" \",\n },\n {\n type: \"resource\",\n resource: {\n uri: \"s3://bucket/key.json\",\n },\n },\n ]);\n });\n\n it(\"should parse resources with hyphens in server key\", () => {\n const result = buildMessageContent(\n \"@my-server-123:file:///path/to/file.txt\",\n [],\n {},\n );\n\n expect(result).toEqual([\n {\n type: \"resource\",\n resource: {\n uri: \"file:///path/to/file.txt\",\n },\n },\n ]);\n });\n\n it(\"should parse resources with numbers in server key\", () => {\n const result = buildMessageContent(\n \"@server123:tambo:test://static/resource/1\",\n [],\n {},\n );\n\n expect(result).toEqual([\n {\n type: \"resource\",\n resource: {\n uri: \"tambo:test://static/resource/1\",\n },\n },\n ]);\n });\n\n it(\"should preserve whitespace in text segments around resource references\", () => {\n const result = buildMessageContent(\n \" Before @tambo-1hfs429:tambo:test://static/resource/1 After \",\n [],\n {},\n );\n expect(result).toEqual([\n {\n type: \"text\",\n text: \" Before \",\n },\n {\n type: \"resource\",\n resource: {\n uri: \"tambo:test://static/resource/1\",\n },\n },\n {\n type: \"text\",\n text: \" After \",\n },\n ]);\n });\n\n it(\"should handle resource with only whitespace text segments\", () => {\n const result = buildMessageContent(\n \" @tambo-1hfs429:tambo:test://static/resource/1 \",\n [],\n {},\n );\n\n expect(result).toEqual([\n {\n type: \"text\",\n text: \" \",\n },\n {\n type: \"resource\",\n resource: {\n uri: \"tambo:test://static/resource/1\",\n },\n },\n {\n type: \"text\",\n text: \" \",\n },\n ]);\n });\n\n it(\"should preserve newlines and spaces around resource references\", () => {\n const result = buildMessageContent(\n \"\\n @tambo-1hfs429:tambo:test://static/resource/1 text\",\n [],\n {},\n );\n\n expect(result).toEqual([\n {\n type: \"text\",\n text: \"\\n \",\n },\n {\n type: \"resource\",\n resource: {\n uri: \"tambo:test://static/resource/1\",\n },\n },\n {\n type: \"text\",\n text: \" text\",\n },\n ]);\n });\n\n it(\"should parse resource-only message without text\", () => {\n const result = buildMessageContent(\n \"@tambo-1hfs429:tambo:test://static/resource/1\",\n [],\n {},\n );\n\n expect(result).toEqual([\n {\n type: \"resource\",\n resource: {\n uri: \"tambo:test://static/resource/1\",\n },\n },\n ]);\n });\n\n it(\"should parse multiple resources with names\", () => {\n const resourceNames = {\n \"tambo-1hfs429:tambo:test://static/resource/1\": \"First Resource\",\n \"tambo-1hfs429:tambo:test://static/resource/2\": \"Second Resource\",\n };\n\n const result = buildMessageContent(\n \"Check @tambo-1hfs429:tambo:test://static/resource/1 and @tambo-1hfs429:tambo:test://static/resource/2\",\n [],\n resourceNames,\n );\n\n expect(result).toEqual([\n {\n type: \"text\",\n text: \"Check \",\n },\n {\n type: \"resource\",\n resource: {\n uri: \"tambo:test://static/resource/1\",\n name: \"First Resource\",\n },\n },\n {\n type: \"text\",\n text: \" and \",\n },\n {\n type: \"resource\",\n resource: {\n uri: \"tambo:test://static/resource/2\",\n name: \"Second Resource\",\n },\n },\n ]);\n });\n\n it(\"should parse resources mixed with images\", () => {\n const images = [\n createMockStagedImage({\n id: \"img1\",\n dataUrl: \"data:image/png;base64,abc123\",\n }),\n ];\n\n const result = buildMessageContent(\n \"Check @tambo-1hfs429:tambo:test://static/resource/1\",\n images,\n {},\n );\n\n expect(result).toEqual([\n {\n type: \"text\",\n text: \"Check \",\n },\n {\n type: \"resource\",\n resource: {\n uri: \"tambo:test://static/resource/1\",\n },\n },\n {\n type: \"image_url\",\n image_url: {\n url: \"data:image/png;base64,abc123\",\n },\n },\n ]);\n });\n\n it(\"should parse resources and images with proper ordering\", () => {\n const images = [\n createMockStagedImage({\n id: \"img1\",\n dataUrl: \"data:image/png;base64,img1\",\n }),\n createMockStagedImage({\n id: \"img2\",\n dataUrl: \"data:image/jpeg;base64,img2\",\n }),\n ];\n\n const result = buildMessageContent(\n \"Text @tambo-1hfs429:tambo:test://static/resource/1 more text\",\n images,\n {},\n );\n\n expect(result).toEqual([\n {\n type: \"text\",\n text: \"Text \",\n },\n {\n type: \"resource\",\n resource: {\n uri: \"tambo:test://static/resource/1\",\n },\n },\n {\n type: \"text\",\n text: \" more text\",\n },\n {\n type: \"image_url\",\n image_url: {\n url: \"data:image/png;base64,img1\",\n },\n },\n {\n type: \"image_url\",\n image_url: {\n url: \"data:image/jpeg;base64,img2\",\n },\n },\n ]);\n });\n\n it(\"should parse resource reference with URI containing colons\", () => {\n const result = buildMessageContent(\n \"@server:http://example.com:8080/path\",\n [],\n {},\n );\n\n expect(result).toEqual([\n {\n type: \"resource\",\n resource: {\n uri: \"http://example.com:8080/path\",\n },\n },\n ]);\n });\n\n it(\"should parse resource reference with URI containing special characters\", () => {\n const result = buildMessageContent(\n \"@server:file:///path/to/file%20with%20spaces.txt\",\n [],\n {},\n );\n\n expect(result).toEqual([\n {\n type: \"resource\",\n resource: {\n uri: \"file:///path/to/file%20with%20spaces.txt\",\n },\n },\n ]);\n });\n\n it(\"should not parse @ symbol without server key and colon\", () => {\n const result = buildMessageContent(\n \"Mention @user but not a resource\",\n [],\n {},\n );\n\n expect(result).toEqual([\n {\n type: \"text\",\n text: \"Mention @user but not a resource\",\n },\n ]);\n });\n\n it(\"should not parse malformed resource reference missing colon\", () => {\n const result = buildMessageContent(\n \"@serverkey-missing-colon resource\",\n [],\n {},\n );\n\n expect(result).toEqual([\n {\n type: \"text\",\n text: \"@serverkey-missing-colon resource\",\n },\n ]);\n });\n\n it(\"should not parse resource reference with space before colon\", () => {\n const result = buildMessageContent(\"@server key :uri\", [], {});\n\n expect(result).toEqual([\n {\n type: \"text\",\n text: \"@server key :uri\",\n },\n ]);\n });\n\n it(\"should preserve multiple whitespace characters between consecutive resources\", () => {\n const result = buildMessageContent(\n \"@tambo-1hfs429:tambo:test://static/resource/1 @tambo-1hfs429:tambo:test://static/resource/2\",\n [],\n {},\n );\n\n expect(result).toEqual([\n {\n type: \"resource\",\n resource: {\n uri: \"tambo:test://static/resource/1\",\n },\n },\n {\n type: \"text\",\n text: \" \",\n },\n {\n type: \"resource\",\n resource: {\n uri: \"tambo:test://static/resource/2\",\n },\n },\n ]);\n });\n\n it(\"should parse resource with only URI and no surrounding text\", () => {\n const result = buildMessageContent(\n \"@tambo-1hfs429:tambo:test://static/resource/1\",\n [],\n {},\n );\n\n expect(result).toEqual([\n {\n type: \"resource\",\n resource: {\n uri: \"tambo:test://static/resource/1\",\n },\n },\n ]);\n });\n\n it(\"should throw error when only resources with empty text segments\", () => {\n // This should work - resources alone should be valid\n const result = buildMessageContent(\n \"@tambo-1hfs429:tambo:test://static/resource/1\",\n [],\n {},\n );\n\n expect(result.length).toBeGreaterThan(0);\n expect(result[0].type).toBe(\"resource\");\n });\n });\n});\n"]}
@@ -0,0 +1,26 @@
1
+ import type { TamboComponent, TamboTool, TamboToolWithToolSchema } from "../model/component-metadata";
2
+ /**
3
+ * Validates a tool before registration.
4
+ * Throws an error if the tool is invalid.
5
+ * @param tool - The tool to validate
6
+ */
7
+ export declare function validateTool(tool: TamboTool | TamboToolWithToolSchema): void;
8
+ /**
9
+ * Validates a component and prepares its props for registration.
10
+ * Throws an error if the component is invalid.
11
+ * @param component - The component to validate and prepare
12
+ * @returns Object containing the serialized props
13
+ */
14
+ export declare function validateAndPrepareComponent(component: TamboComponent): {
15
+ props: Record<string, unknown>;
16
+ };
17
+ /**
18
+ * Validates a tool association between a component and tool.
19
+ * Throws an error if the association is invalid.
20
+ * @param componentName - The component name
21
+ * @param toolName - The tool name
22
+ * @param componentExists - Whether the component exists in the registry
23
+ * @param toolExists - Whether the tool exists in the registry
24
+ */
25
+ export declare function validateToolAssociation(componentName: string, toolName: string, componentExists: boolean, toolExists: boolean): void;
26
+ //# sourceMappingURL=registry-validators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry-validators.d.ts","sourceRoot":"","sources":["../../src/util/registry-validators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,SAAS,EACT,uBAAuB,EACxB,MAAM,6BAA6B,CAAC;AAWrC;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,GAAG,uBAAuB,GAAG,IAAI,CAqB5E;AA0CD;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,cAAc,GAAG;IACtE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC,CA6BA;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,OAAO,EACxB,UAAU,EAAE,OAAO,GAClB,IAAI,CAWN"}
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateTool = validateTool;
4
+ exports.validateAndPrepareComponent = validateAndPrepareComponent;
5
+ exports.validateToolAssociation = validateToolAssociation;
6
+ const schema_1 = require("../schema");
7
+ const zod_1 = require("../schema/zod");
8
+ const validate_component_name_1 = require("./validate-component-name");
9
+ /**
10
+ * Validates a tool before registration.
11
+ * Throws an error if the tool is invalid.
12
+ * @param tool - The tool to validate
13
+ */
14
+ function validateTool(tool) {
15
+ // Validate tool name
16
+ (0, validate_component_name_1.assertValidName)(tool.name, "tool");
17
+ // Validate tool schemas
18
+ // 1. check inputSchema
19
+ if ("inputSchema" in tool && tool.inputSchema) {
20
+ (0, schema_1.assertNoRecordSchema)(tool.inputSchema, `inputSchema of tool "${tool.name}"`);
21
+ }
22
+ // 2. check deprecated toolSchema
23
+ else if ("toolSchema" in tool && tool.toolSchema) {
24
+ let inputSchema = tool.toolSchema;
25
+ // toolSchema may sometimes be a zod function schema, extract args if so
26
+ if ((0, zod_1.isZodFunctionSchema)(tool.toolSchema)) {
27
+ inputSchema = (0, schema_1.getZodFunctionArgs)(tool.toolSchema);
28
+ }
29
+ (0, schema_1.assertNoRecordSchema)(inputSchema, `toolSchema of tool "${tool.name}"`);
30
+ }
31
+ }
32
+ /**
33
+ * Converts a props schema to a serialized JSON Schema format.
34
+ * @param propsDefinition - Deprecated: legacy props definition (will log warning)
35
+ * @param propsSchema - The props schema (Standard Schema or JSON Schema)
36
+ * @param name - Component/tool name for error messages
37
+ * @returns Serialized JSON Schema object
38
+ */
39
+ function getSerializedProps(propsDefinition, propsSchema, name) {
40
+ if (propsDefinition) {
41
+ console.warn(`propsDefinition is deprecated. Use propsSchema instead.`);
42
+ return propsDefinition;
43
+ }
44
+ // Check for Standard Schema (Zod, Valibot, ArkType, etc.)
45
+ if ((0, schema_1.isStandardSchema)(propsSchema)) {
46
+ try {
47
+ return (0, schema_1.schemaToJsonSchema)(propsSchema);
48
+ }
49
+ catch (error) {
50
+ console.error(`Error converting ${name} props schema to JSON Schema:`, error);
51
+ throw new Error(`Error converting ${name} props schema to JSON Schema: ${error}`);
52
+ }
53
+ }
54
+ // Check for JSON Schema
55
+ if ((0, schema_1.looksLikeJSONSchema)(propsSchema)) {
56
+ return propsSchema;
57
+ }
58
+ throw new Error(`Invalid props schema for ${name}`);
59
+ }
60
+ /**
61
+ * Validates a component and prepares its props for registration.
62
+ * Throws an error if the component is invalid.
63
+ * @param component - The component to validate and prepare
64
+ * @returns Object containing the serialized props
65
+ */
66
+ function validateAndPrepareComponent(component) {
67
+ const { name, propsSchema, propsDefinition } = component;
68
+ // Validate component name
69
+ (0, validate_component_name_1.assertValidName)(name, "component");
70
+ // Validate that at least one props definition is provided
71
+ if (!propsSchema && !propsDefinition) {
72
+ throw new Error(`Component ${name} must have either propsSchema (recommended) or propsDefinition defined`);
73
+ }
74
+ // Validate that only one props definition is provided
75
+ if (propsSchema && propsDefinition) {
76
+ throw new Error(`Component ${name} cannot have both propsSchema and propsDefinition defined. Use only one. We recommend using propsSchema.`);
77
+ }
78
+ // Validate that the propsSchema does not include record types
79
+ if (propsSchema) {
80
+ (0, schema_1.assertNoRecordSchema)(propsSchema, `propsSchema of component "${name}"`);
81
+ }
82
+ // Convert propsSchema to JSON Schema if it exists
83
+ const props = getSerializedProps(propsDefinition, propsSchema, name);
84
+ return { props };
85
+ }
86
+ /**
87
+ * Validates a tool association between a component and tool.
88
+ * Throws an error if the association is invalid.
89
+ * @param componentName - The component name
90
+ * @param toolName - The tool name
91
+ * @param componentExists - Whether the component exists in the registry
92
+ * @param toolExists - Whether the tool exists in the registry
93
+ */
94
+ function validateToolAssociation(componentName, toolName, componentExists, toolExists) {
95
+ // Validate component and tool names
96
+ (0, validate_component_name_1.assertValidName)(componentName, "component");
97
+ (0, validate_component_name_1.assertValidName)(toolName, "tool");
98
+ if (!componentExists) {
99
+ throw new Error(`Component ${componentName} not found in registry`);
100
+ }
101
+ if (!toolExists) {
102
+ throw new Error(`Tool ${toolName} not found in registry`);
103
+ }
104
+ }
105
+ //# sourceMappingURL=registry-validators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry-validators.js","sourceRoot":"","sources":["../../src/util/registry-validators.ts"],"names":[],"mappings":";;AAoBA,oCAqBC;AAgDD,kEA+BC;AAUD,0DAgBC;AA7ID,sCAMmB;AACnB,uCAAoD;AACpD,uEAA4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MAAM,IAAI,KAAK,CAAC,aAAa,aAAa,wBAAwB,CAAC,CAAC;IACtE,CAAC;IACD,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,QAAQ,QAAQ,wBAAwB,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC","sourcesContent":["import type {\n TamboComponent,\n TamboTool,\n TamboToolWithToolSchema,\n} from \"../model/component-metadata\";\nimport {\n assertNoRecordSchema,\n getZodFunctionArgs,\n isStandardSchema,\n looksLikeJSONSchema,\n schemaToJsonSchema,\n} from \"../schema\";\nimport { isZodFunctionSchema } from \"../schema/zod\";\nimport { assertValidName } from \"./validate-component-name\";\n\n/**\n * Validates a tool before registration.\n * Throws an error if the tool is invalid.\n * @param tool - The tool to validate\n */\nexport function validateTool(tool: TamboTool | TamboToolWithToolSchema): void {\n // Validate tool name\n assertValidName(tool.name, \"tool\");\n\n // Validate tool schemas\n // 1. check inputSchema\n if (\"inputSchema\" in tool && tool.inputSchema) {\n assertNoRecordSchema(\n tool.inputSchema,\n `inputSchema of tool \"${tool.name}\"`,\n );\n }\n // 2. check deprecated toolSchema\n else if (\"toolSchema\" in tool && tool.toolSchema) {\n let inputSchema = tool.toolSchema;\n // toolSchema may sometimes be a zod function schema, extract args if so\n if (isZodFunctionSchema(tool.toolSchema)) {\n inputSchema = getZodFunctionArgs(tool.toolSchema);\n }\n assertNoRecordSchema(inputSchema, `toolSchema of tool \"${tool.name}\"`);\n }\n}\n\n/**\n * Converts a props schema to a serialized JSON Schema format.\n * @param propsDefinition - Deprecated: legacy props definition (will log warning)\n * @param propsSchema - The props schema (Standard Schema or JSON Schema)\n * @param name - Component/tool name for error messages\n * @returns Serialized JSON Schema object\n */\nfunction getSerializedProps(\n propsDefinition: unknown,\n propsSchema: unknown,\n name: string,\n): Record<string, unknown> {\n if (propsDefinition) {\n console.warn(`propsDefinition is deprecated. Use propsSchema instead.`);\n return propsDefinition as Record<string, unknown>;\n }\n\n // Check for Standard Schema (Zod, Valibot, ArkType, etc.)\n if (isStandardSchema(propsSchema)) {\n try {\n return schemaToJsonSchema(propsSchema) as Record<string, unknown>;\n } catch (error) {\n console.error(\n `Error converting ${name} props schema to JSON Schema:`,\n error,\n );\n throw new Error(\n `Error converting ${name} props schema to JSON Schema: ${error}`,\n );\n }\n }\n\n // Check for JSON Schema\n if (looksLikeJSONSchema(propsSchema)) {\n return propsSchema as Record<string, unknown>;\n }\n\n throw new Error(`Invalid props schema for ${name}`);\n}\n\n/**\n * Validates a component and prepares its props for registration.\n * Throws an error if the component is invalid.\n * @param component - The component to validate and prepare\n * @returns Object containing the serialized props\n */\nexport function validateAndPrepareComponent(component: TamboComponent): {\n props: Record<string, unknown>;\n} {\n const { name, propsSchema, propsDefinition } = component;\n\n // Validate component name\n assertValidName(name, \"component\");\n\n // Validate that at least one props definition is provided\n if (!propsSchema && !propsDefinition) {\n throw new Error(\n `Component ${name} must have either propsSchema (recommended) or propsDefinition defined`,\n );\n }\n\n // Validate that only one props definition is provided\n if (propsSchema && propsDefinition) {\n throw new Error(\n `Component ${name} cannot have both propsSchema and propsDefinition defined. Use only one. We recommend using propsSchema.`,\n );\n }\n\n // Validate that the propsSchema does not include record types\n if (propsSchema) {\n assertNoRecordSchema(propsSchema, `propsSchema of component \"${name}\"`);\n }\n\n // Convert propsSchema to JSON Schema if it exists\n const props = getSerializedProps(propsDefinition, propsSchema, name);\n\n return { props };\n}\n\n/**\n * Validates a tool association between a component and tool.\n * Throws an error if the association is invalid.\n * @param componentName - The component name\n * @param toolName - The tool name\n * @param componentExists - Whether the component exists in the registry\n * @param toolExists - Whether the tool exists in the registry\n */\nexport function validateToolAssociation(\n componentName: string,\n toolName: string,\n componentExists: boolean,\n toolExists: boolean,\n): void {\n // Validate component and tool names\n assertValidName(componentName, \"component\");\n assertValidName(toolName, \"tool\");\n\n if (!componentExists) {\n throw new Error(`Component ${componentName} not found in registry`);\n }\n if (!toolExists) {\n throw new Error(`Tool ${toolName} not found in registry`);\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=registry-validators.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry-validators.test.d.ts","sourceRoot":"","sources":["../../src/util/registry-validators.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,235 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const v3_1 = require("zod/v3");
4
+ const registry_validators_1 = require("./registry-validators");
5
+ describe("validateTool", () => {
6
+ it("should validate tool with valid name", () => {
7
+ const tool = {
8
+ name: "valid-tool-name",
9
+ description: "A valid tool",
10
+ tool: () => "result",
11
+ toolSchema: v3_1.z.function().args().returns(v3_1.z.string()),
12
+ };
13
+ expect(() => (0, registry_validators_1.validateTool)(tool)).not.toThrow();
14
+ });
15
+ it("should throw when tool name contains invalid characters", () => {
16
+ const tool = {
17
+ name: "invalid tool name",
18
+ description: "A tool",
19
+ tool: () => "result",
20
+ toolSchema: v3_1.z.function().args().returns(v3_1.z.string()),
21
+ };
22
+ expect(() => (0, registry_validators_1.validateTool)(tool)).toThrow('tool "invalid tool name" must only contain letters, numbers, underscores, and hyphens.');
23
+ });
24
+ it("should throw when tool name contains special characters", () => {
25
+ const tool = {
26
+ name: "tool@name",
27
+ description: "A tool",
28
+ tool: () => "result",
29
+ toolSchema: v3_1.z.function().args().returns(v3_1.z.string()),
30
+ };
31
+ expect(() => (0, registry_validators_1.validateTool)(tool)).toThrow('tool "tool@name" must only contain letters, numbers, underscores, and hyphens.');
32
+ });
33
+ it("should validate tool with valid Zod schema", () => {
34
+ const tool = {
35
+ name: "valid-tool",
36
+ description: "A tool",
37
+ tool: () => "result",
38
+ toolSchema: v3_1.z.function().args().returns(v3_1.z.string()),
39
+ };
40
+ expect(() => (0, registry_validators_1.validateTool)(tool)).not.toThrow();
41
+ });
42
+ it("should throw when tool schema contains z.record()", () => {
43
+ const tool = {
44
+ name: "invalid-tool",
45
+ description: "A tool",
46
+ tool: () => "result",
47
+ toolSchema: v3_1.z
48
+ .function()
49
+ .args(v3_1.z.object({
50
+ metadata: v3_1.z.record(v3_1.z.string()),
51
+ }))
52
+ .returns(v3_1.z.string()),
53
+ };
54
+ expect(() => (0, registry_validators_1.validateTool)(tool)).toThrow('Record types (objects with dynamic keys) are not supported in toolSchema of tool "invalid-tool".');
55
+ });
56
+ it("should allow tool with JSON Schema (non-Zod)", () => {
57
+ const tool = {
58
+ name: "tool-with-json-schema",
59
+ description: "A tool",
60
+ tool: () => "result",
61
+ toolSchema: {
62
+ type: "object",
63
+ properties: {
64
+ query: { type: "string" },
65
+ },
66
+ },
67
+ };
68
+ expect(() => (0, registry_validators_1.validateTool)(tool)).not.toThrow();
69
+ });
70
+ it("should validate tool with inputSchema (new interface)", () => {
71
+ const tool = {
72
+ name: "tool-with-input-schema",
73
+ description: "A tool with input schema",
74
+ tool: (input) => input.query,
75
+ inputSchema: v3_1.z.object({
76
+ query: v3_1.z.string(),
77
+ }),
78
+ outputSchema: v3_1.z.string(),
79
+ };
80
+ expect(() => (0, registry_validators_1.validateTool)(tool)).not.toThrow();
81
+ });
82
+ });
83
+ describe("validateAndPrepareComponent", () => {
84
+ it("should validate component with propsSchema", () => {
85
+ const component = {
86
+ name: "valid-component",
87
+ description: "A valid component",
88
+ component: () => null,
89
+ propsSchema: v3_1.z.object({
90
+ title: v3_1.z.string(),
91
+ count: v3_1.z.number(),
92
+ }),
93
+ };
94
+ const result = (0, registry_validators_1.validateAndPrepareComponent)(component);
95
+ expect(result.props).toBeDefined();
96
+ expect(result.props.type).toBe("object");
97
+ expect(result.props.properties).toBeDefined();
98
+ });
99
+ it("should validate component with propsDefinition", () => {
100
+ const component = {
101
+ name: "valid-component",
102
+ description: "A valid component",
103
+ component: () => null,
104
+ propsDefinition: {
105
+ type: "object",
106
+ properties: {
107
+ title: { type: "string" },
108
+ },
109
+ },
110
+ };
111
+ const result = (0, registry_validators_1.validateAndPrepareComponent)(component);
112
+ expect(result.props).toEqual(component.propsDefinition);
113
+ });
114
+ it("should throw when component name contains invalid characters", () => {
115
+ const component = {
116
+ name: "invalid component name",
117
+ description: "A component",
118
+ component: () => null,
119
+ propsSchema: v3_1.z.object({}),
120
+ };
121
+ expect(() => (0, registry_validators_1.validateAndPrepareComponent)(component)).toThrow('component "invalid component name" must only contain letters, numbers, underscores, and hyphens.');
122
+ });
123
+ it("should throw when neither propsSchema nor propsDefinition is provided", () => {
124
+ const component = {
125
+ name: "component-without-props",
126
+ description: "A component",
127
+ component: () => null,
128
+ };
129
+ expect(() => (0, registry_validators_1.validateAndPrepareComponent)(component)).toThrow("Component component-without-props must have either propsSchema (recommended) or propsDefinition defined");
130
+ });
131
+ it("should throw when both propsSchema and propsDefinition are provided", () => {
132
+ const component = {
133
+ name: "component-with-both",
134
+ description: "A component",
135
+ component: () => null,
136
+ propsSchema: v3_1.z.object({}),
137
+ propsDefinition: {
138
+ type: "object",
139
+ properties: {},
140
+ },
141
+ };
142
+ expect(() => (0, registry_validators_1.validateAndPrepareComponent)(component)).toThrow("Component component-with-both cannot have both propsSchema and propsDefinition defined. Use only one. We recommend using propsSchema.");
143
+ });
144
+ it("should throw when propsSchema contains z.record()", () => {
145
+ const component = {
146
+ name: "component-with-record",
147
+ description: "A component",
148
+ component: () => null,
149
+ propsSchema: v3_1.z.object({
150
+ metadata: v3_1.z.record(v3_1.z.string()),
151
+ }),
152
+ };
153
+ expect(() => (0, registry_validators_1.validateAndPrepareComponent)(component)).toThrow('Record types (objects with dynamic keys) are not supported in propsSchema of component "component-with-record".');
154
+ });
155
+ it("should convert Zod schema to JSON Schema", () => {
156
+ const component = {
157
+ name: "component-with-zod",
158
+ description: "A component",
159
+ component: () => null,
160
+ propsSchema: v3_1.z.object({
161
+ title: v3_1.z.string().describe("The title"),
162
+ count: v3_1.z.number().int().min(0),
163
+ tags: v3_1.z.array(v3_1.z.string()),
164
+ }),
165
+ };
166
+ const result = (0, registry_validators_1.validateAndPrepareComponent)(component);
167
+ expect(result.props).toBeDefined();
168
+ expect(result.props.type).toBe("object");
169
+ expect(result.props.properties).toBeDefined();
170
+ expect(result.props.properties.title).toBeDefined();
171
+ expect(result.props.properties.count).toBeDefined();
172
+ expect(result.props.properties.tags).toBeDefined();
173
+ });
174
+ it("should handle complex Zod schema", () => {
175
+ const component = {
176
+ name: "component-complex",
177
+ description: "A component",
178
+ component: () => null,
179
+ propsSchema: v3_1.z.object({
180
+ user: v3_1.z.object({
181
+ name: v3_1.z.string(),
182
+ age: v3_1.z.number(),
183
+ }),
184
+ items: v3_1.z.array(v3_1.z.object({
185
+ id: v3_1.z.string(),
186
+ value: v3_1.z.number(),
187
+ })),
188
+ }),
189
+ };
190
+ const result = (0, registry_validators_1.validateAndPrepareComponent)(component);
191
+ expect(result.props).toBeDefined();
192
+ expect(result.props.type).toBe("object");
193
+ });
194
+ it("should allow JSON Schema (non-Zod) without validation", () => {
195
+ const component = {
196
+ name: "component-json-schema",
197
+ description: "A component",
198
+ component: () => null,
199
+ propsSchema: {
200
+ type: "object",
201
+ properties: {
202
+ title: { type: "string" },
203
+ },
204
+ },
205
+ };
206
+ const result = (0, registry_validators_1.validateAndPrepareComponent)(component);
207
+ expect(result.props).toEqual(component.propsSchema);
208
+ });
209
+ });
210
+ describe("validateToolAssociation", () => {
211
+ it("should validate valid tool association", () => {
212
+ expect(() => (0, registry_validators_1.validateToolAssociation)("valid-component", "valid-tool", true, true)).not.toThrow();
213
+ });
214
+ it("should throw when component name is invalid", () => {
215
+ expect(() => (0, registry_validators_1.validateToolAssociation)("invalid component", "valid-tool", true, true)).toThrow('component "invalid component" must only contain letters, numbers, underscores, and hyphens.');
216
+ });
217
+ it("should throw when tool name is invalid", () => {
218
+ expect(() => (0, registry_validators_1.validateToolAssociation)("valid-component", "invalid tool", true, true)).toThrow('tool "invalid tool" must only contain letters, numbers, underscores, and hyphens.');
219
+ });
220
+ it("should throw when component does not exist", () => {
221
+ expect(() => (0, registry_validators_1.validateToolAssociation)("missing-component", "valid-tool", false, true)).toThrow("Component missing-component not found in registry");
222
+ });
223
+ it("should throw when tool does not exist", () => {
224
+ expect(() => (0, registry_validators_1.validateToolAssociation)("valid-component", "missing-tool", true, false)).toThrow("Tool missing-tool not found in registry");
225
+ });
226
+ it("should throw when both component and tool do not exist", () => {
227
+ expect(() => {
228
+ (0, registry_validators_1.validateToolAssociation)("missing-component", "missing-tool", false, false);
229
+ }).toThrow("Component missing-component not found in registry");
230
+ });
231
+ it("should validate with valid names containing underscores and hyphens", () => {
232
+ expect(() => (0, registry_validators_1.validateToolAssociation)("my_component-123", "my_tool-456", true, true)).not.toThrow();
233
+ });
234
+ });
235
+ //# sourceMappingURL=registry-validators.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry-validators.test.js","sourceRoot":"","sources":["../../src/util/registry-validators.test.ts"],"names":[],"mappings":";;AAAA,+BAA2B;AAM3B,+DAI+B;AAE/B,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC9C,MAAM,IAAI,GAA4B;YACpC,IAAI,EAAE,iBAAiB;YACvB,WAAW,EAAE,cAAc;YAC3B,IAAI,EAAE,GAAG,EAAE,CAAC,QAAQ;YACpB,UAAU,EAAE,MAAC,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,MAAC,CAAC,MAAM,EAAE,CAAC;SACpD,CAAC;QAEF,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,kCAAY,EAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;IACjD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yDAAyD,EAAE,GAAG,EAAE;QACjE,MAAM,IAAI,GAA4B;YACpC,IAAI,EAAE,mBAAmB;YACzB,WAAW,EAAE,QAAQ;YACrB,IAAI,EAAE,GAAG,EAAE,CAAC,QAAQ;YACpB,UAAU,EAAE,MAAC,CAAC,QAAQ,EAAE,CAAC,IAA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AC,iBAAiB,EAAE,cAAc,EAAE,IAAI,EAAE,KAAK,CAAC,CACxE,CAAC,OAAO,CAAC,yCAAyC,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wDAAwD,EAAE,GAAG,EAAE;QAChE,MAAM,CAAC,GAAG,EAAE;YACV,IAAA,6CAAuB,EACrB,mBAAmB,EACnB,cAAc,EACd,KAAK,EACL,KAAK,CACN,CAAC;QACJ,CAAC,CAAC,CAAC,OAAO,CAAC,mDAAmD,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qEAAqE,EAAE,GAAG,EAAE;QAC7E,MAAM,CAAC,GAAG,EAAE,CACV,IAAA,6CAAuB,EAAC,kBAAkB,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,CAAC,CACvE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { z } from \"zod/v3\";\nimport type {\n TamboComponent,\n TamboTool,\n TamboToolWithToolSchema,\n} from \"../model/component-metadata\";\nimport {\n validateAndPrepareComponent,\n validateTool,\n validateToolAssociation,\n} from \"./registry-validators\";\n\ndescribe(\"validateTool\", () => {\n it(\"should validate tool with valid name\", () => {\n const tool: TamboToolWithToolSchema = {\n name: \"valid-tool-name\",\n description: \"A valid tool\",\n tool: () => \"result\",\n toolSchema: z.function().args().returns(z.string()),\n };\n\n expect(() => validateTool(tool)).not.toThrow();\n });\n\n it(\"should throw when tool name contains invalid characters\", () => {\n const tool: TamboToolWithToolSchema = {\n name: \"invalid tool name\",\n description: \"A tool\",\n tool: () => \"result\",\n toolSchema: z.function().args().returns(z.string()),\n };\n\n expect(() => validateTool(tool)).toThrow(\n 'tool \"invalid tool name\" must only contain letters, numbers, underscores, and hyphens.',\n );\n });\n\n it(\"should throw when tool name contains special characters\", () => {\n const tool: TamboToolWithToolSchema = {\n name: \"tool@name\",\n description: \"A tool\",\n tool: () => \"result\",\n toolSchema: z.function().args().returns(z.string()),\n };\n\n expect(() => validateTool(tool)).toThrow(\n 'tool \"tool@name\" must only contain letters, numbers, underscores, and hyphens.',\n );\n });\n\n it(\"should validate tool with valid Zod schema\", () => {\n const tool: TamboToolWithToolSchema = {\n name: \"valid-tool\",\n description: \"A tool\",\n tool: () => \"result\",\n toolSchema: z.function().args().returns(z.string()),\n };\n\n expect(() => validateTool(tool)).not.toThrow();\n });\n\n it(\"should throw when tool schema contains z.record()\", () => {\n const tool: TamboToolWithToolSchema = {\n name: \"invalid-tool\",\n description: \"A tool\",\n tool: () => \"result\",\n toolSchema: z\n .function()\n .args(\n z.object({\n metadata: z.record(z.string()),\n }),\n )\n .returns(z.string()),\n };\n\n expect(() => validateTool(tool)).toThrow(\n 'Record types (objects with dynamic keys) are not supported in toolSchema of tool \"invalid-tool\".',\n );\n });\n\n it(\"should allow tool with JSON Schema (non-Zod)\", () => {\n const tool: TamboToolWithToolSchema = {\n name: \"tool-with-json-schema\",\n description: \"A tool\",\n tool: () => \"result\",\n toolSchema: {\n type: \"object\",\n properties: {\n query: { type: \"string\" },\n },\n },\n };\n\n expect(() => validateTool(tool)).not.toThrow();\n });\n\n it(\"should validate tool with inputSchema (new interface)\", () => {\n const tool: TamboTool = {\n name: \"tool-with-input-schema\",\n description: \"A tool with input schema\",\n tool: (input: { query: string }) => input.query,\n inputSchema: z.object({\n query: z.string(),\n }),\n outputSchema: z.string(),\n };\n\n expect(() => validateTool(tool)).not.toThrow();\n });\n});\n\ndescribe(\"validateAndPrepareComponent\", () => {\n it(\"should validate component with propsSchema\", () => {\n const component: TamboComponent = {\n name: \"valid-component\",\n description: \"A valid component\",\n component: () => null,\n propsSchema: z.object({\n title: z.string(),\n count: z.number(),\n }),\n };\n\n const result = validateAndPrepareComponent(component);\n\n expect(result.props).toBeDefined();\n expect(result.props.type).toBe(\"object\");\n expect(result.props.properties).toBeDefined();\n });\n\n it(\"should validate component with propsDefinition\", () => {\n const component: TamboComponent = {\n name: \"valid-component\",\n description: \"A valid component\",\n component: () => null,\n propsDefinition: {\n type: \"object\",\n properties: {\n title: { type: \"string\" },\n },\n },\n };\n\n const result = validateAndPrepareComponent(component);\n\n expect(result.props).toEqual(component.propsDefinition);\n });\n\n it(\"should throw when component name contains invalid characters\", () => {\n const component: TamboComponent = {\n name: \"invalid component name\",\n description: \"A component\",\n component: () => null,\n propsSchema: z.object({}),\n };\n\n expect(() => validateAndPrepareComponent(component)).toThrow(\n 'component \"invalid component name\" must only contain letters, numbers, underscores, and hyphens.',\n );\n });\n\n it(\"should throw when neither propsSchema nor propsDefinition is provided\", () => {\n const component: TamboComponent = {\n name: \"component-without-props\",\n description: \"A component\",\n component: () => null,\n };\n\n expect(() => validateAndPrepareComponent(component)).toThrow(\n \"Component component-without-props must have either propsSchema (recommended) or propsDefinition defined\",\n );\n });\n\n it(\"should throw when both propsSchema and propsDefinition are provided\", () => {\n const component: TamboComponent = {\n name: \"component-with-both\",\n description: \"A component\",\n component: () => null,\n propsSchema: z.object({}),\n propsDefinition: {\n type: \"object\",\n properties: {},\n },\n };\n\n expect(() => validateAndPrepareComponent(component)).toThrow(\n \"Component component-with-both cannot have both propsSchema and propsDefinition defined. Use only one. We recommend using propsSchema.\",\n );\n });\n\n it(\"should throw when propsSchema contains z.record()\", () => {\n const component: TamboComponent = {\n name: \"component-with-record\",\n description: \"A component\",\n component: () => null,\n propsSchema: z.object({\n metadata: z.record(z.string()),\n }),\n };\n\n expect(() => validateAndPrepareComponent(component)).toThrow(\n 'Record types (objects with dynamic keys) are not supported in propsSchema of component \"component-with-record\".',\n );\n });\n\n it(\"should convert Zod schema to JSON Schema\", () => {\n const component: TamboComponent = {\n name: \"component-with-zod\",\n description: \"A component\",\n component: () => null,\n propsSchema: z.object({\n title: z.string().describe(\"The title\"),\n count: z.number().int().min(0),\n tags: z.array(z.string()),\n }),\n };\n\n const result = validateAndPrepareComponent(component);\n\n expect(result.props).toBeDefined();\n expect(result.props.type).toBe(\"object\");\n expect((result.props as any).properties).toBeDefined();\n expect((result.props as any).properties.title).toBeDefined();\n expect((result.props as any).properties.count).toBeDefined();\n expect((result.props as any).properties.tags).toBeDefined();\n });\n\n it(\"should handle complex Zod schema\", () => {\n const component: TamboComponent = {\n name: \"component-complex\",\n description: \"A component\",\n component: () => null,\n propsSchema: z.object({\n user: z.object({\n name: z.string(),\n age: z.number(),\n }),\n items: z.array(\n z.object({\n id: z.string(),\n value: z.number(),\n }),\n ),\n }),\n };\n\n const result = validateAndPrepareComponent(component);\n\n expect(result.props).toBeDefined();\n expect(result.props.type).toBe(\"object\");\n });\n\n it(\"should allow JSON Schema (non-Zod) without validation\", () => {\n const component: TamboComponent = {\n name: \"component-json-schema\",\n description: \"A component\",\n component: () => null,\n propsSchema: {\n type: \"object\",\n properties: {\n title: { type: \"string\" },\n },\n },\n };\n\n const result = validateAndPrepareComponent(component);\n\n expect(result.props).toEqual(component.propsSchema);\n });\n});\n\ndescribe(\"validateToolAssociation\", () => {\n it(\"should validate valid tool association\", () => {\n expect(() =>\n validateToolAssociation(\"valid-component\", \"valid-tool\", true, true),\n ).not.toThrow();\n });\n\n it(\"should throw when component name is invalid\", () => {\n expect(() =>\n validateToolAssociation(\"invalid component\", \"valid-tool\", true, true),\n ).toThrow(\n 'component \"invalid component\" must only contain letters, numbers, underscores, and hyphens.',\n );\n });\n\n it(\"should throw when tool name is invalid\", () => {\n expect(() =>\n validateToolAssociation(\"valid-component\", \"invalid tool\", true, true),\n ).toThrow(\n 'tool \"invalid tool\" must only contain letters, numbers, underscores, and hyphens.',\n );\n });\n\n it(\"should throw when component does not exist\", () => {\n expect(() =>\n validateToolAssociation(\"missing-component\", \"valid-tool\", false, true),\n ).toThrow(\"Component missing-component not found in registry\");\n });\n\n it(\"should throw when tool does not exist\", () => {\n expect(() =>\n validateToolAssociation(\"valid-component\", \"missing-tool\", true, false),\n ).toThrow(\"Tool missing-tool not found in registry\");\n });\n\n it(\"should throw when both component and tool do not exist\", () => {\n expect(() => {\n validateToolAssociation(\n \"missing-component\",\n \"missing-tool\",\n false,\n false,\n );\n }).toThrow(\"Component missing-component not found in registry\");\n });\n\n it(\"should validate with valid names containing underscores and hyphens\", () => {\n expect(() =>\n validateToolAssociation(\"my_component-123\", \"my_tool-456\", true, true),\n ).not.toThrow();\n });\n});\n"]}
@@ -1,5 +1,5 @@
1
1
  import TamboAI from "@tambo-ai/typescript-sdk";
2
- import { ComponentContextToolMetadata, ComponentRegistry, RegisteredComponent, TamboTool, TamboToolAssociations, TamboToolRegistry } from "../model/component-metadata";
2
+ import { ComponentContextToolMetadata, ComponentRegistry, DefineToolFn, RegisteredComponent, TamboTool, TamboToolAssociations, TamboToolRegistry, TamboToolWithToolSchema } from "../model/component-metadata";
3
3
  /**
4
4
  * Get all the available components from the component registry
5
5
  * @param componentRegistry - The component registry
@@ -14,13 +14,19 @@ export declare const getAvailableComponents: (componentRegistry: ComponentRegist
14
14
  * @param toolAssociations - The tool associations
15
15
  * @returns The tools that are not associated with any component
16
16
  */
17
- export declare const getUnassociatedTools: (toolRegistry: TamboToolRegistry, toolAssociations: TamboToolAssociations) => TamboTool[];
17
+ export declare const getUnassociatedTools: (toolRegistry: TamboToolRegistry, toolAssociations: TamboToolAssociations) => (TamboTool | TamboToolWithToolSchema)[];
18
18
  /**
19
- * Helper function to convert component props from Zod schema to JSON Schema
19
+ * Helper function to convert component props from Standard Schema or JSON Schema
20
20
  * @param component - The component to convert
21
- * @returns The converted props
21
+ * @returns The converted props as JSON Schema
22
22
  */
23
- export declare const convertPropsToJsonSchema: (component: RegisteredComponent) => any;
23
+ export declare const convertPropsToJsonSchema: (component: RegisteredComponent) => unknown;
24
+ /**
25
+ * Adapt a Tambo tool defined with function schema to a standard Tambo tool
26
+ * @param tool - The Tambo tool with function schema
27
+ * @returns The adapted Tambo tool
28
+ */
29
+ export declare function adaptToolFromFnSchema(tool: TamboTool | TamboToolWithToolSchema): TamboTool;
24
30
  /**
25
31
  * Get a component by name from the component registry
26
32
  * @param componentName - The name of the component to get
@@ -30,8 +36,30 @@ export declare const convertPropsToJsonSchema: (component: RegisteredComponent)
30
36
  export declare const getComponentFromRegistry: (componentName: string, componentRegistry: ComponentRegistry) => RegisteredComponent;
31
37
  /**
32
38
  * Map a Tambo tool to a context tool
33
- * @param tool - The tool to map
39
+ * @param tool - The tool to map (supports both new inputSchema and deprecated toolSchema interfaces)
34
40
  * @returns The context tool
35
41
  */
36
- export declare const mapTamboToolToContextTool: (tool: TamboTool) => ComponentContextToolMetadata;
42
+ export declare const mapTamboToolToContextTool: (tool: TamboTool | TamboToolWithToolSchema) => ComponentContextToolMetadata;
43
+ /**
44
+ * Provides type safety for defining a Tambo Tool.
45
+ *
46
+ * Tambo uses the [standard-schema.dev](https://standard-schema.dev) spec which means you can use any Standard Schema
47
+ * compliant validator (Zod, Valibot, ArkType, etc.). This ensures the tool function args and output types are correctly
48
+ * inferred from the provided schemas.
49
+ * @example
50
+ * ```typescript
51
+ * import { z } from "zod/v4";
52
+ *
53
+ * const myTool = defineTamboTool({
54
+ * inputSchema: z.tuple([z.string()]),
55
+ * outputSchema: z.number(),
56
+ * tool: yourToolFunction,
57
+ * // ^-- (input: [string]) => number | Promise<number>
58
+ * // Types are inferred from and must match inputSchema/outputSchema definitions
59
+ * });
60
+ * ```
61
+ * @param tool The tool definition to register
62
+ * @returns The registered tool definition
63
+ */
64
+ export declare const defineTool: DefineToolFn;
37
65
  //# sourceMappingURL=registry.d.ts.map