@tambo-ai/react 0.65.3 → 0.66.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 (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 +192 -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 +135 -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 +185 -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 +124 -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
@@ -12,7 +12,7 @@ describe("buildMessageContent", () => {
12
12
  ...overrides,
13
13
  });
14
14
  it("should build content with text only", () => {
15
- const result = (0, message_builder_1.buildMessageContent)("Hello world", []);
15
+ const result = (0, message_builder_1.buildMessageContent)("Hello world", [], {});
16
16
  expect(result).toEqual([
17
17
  {
18
18
  type: "text",
@@ -24,7 +24,7 @@ describe("buildMessageContent", () => {
24
24
  const image = createMockStagedImage({
25
25
  dataUrl: "data:image/png;base64,abc123",
26
26
  });
27
- const result = (0, message_builder_1.buildMessageContent)("", [image]);
27
+ const result = (0, message_builder_1.buildMessageContent)("", [image], {});
28
28
  expect(result).toEqual([
29
29
  {
30
30
  type: "image_url",
@@ -45,7 +45,7 @@ describe("buildMessageContent", () => {
45
45
  dataUrl: "data:image/jpeg;base64,def456",
46
46
  }),
47
47
  ];
48
- const result = (0, message_builder_1.buildMessageContent)("Check these images:", images);
48
+ const result = (0, message_builder_1.buildMessageContent)("Check these images:", images, {});
49
49
  expect(result).toEqual([
50
50
  {
51
51
  type: "text",
@@ -65,18 +65,18 @@ describe("buildMessageContent", () => {
65
65
  },
66
66
  ]);
67
67
  });
68
- it("should trim whitespace from text", () => {
69
- const result = (0, message_builder_1.buildMessageContent)(" Hello world ", []);
68
+ it("should preserve leading and trailing whitespace in text", () => {
69
+ const result = (0, message_builder_1.buildMessageContent)(" Hello world ", [], {});
70
70
  expect(result).toEqual([
71
71
  {
72
72
  type: "text",
73
- text: "Hello world",
73
+ text: " Hello world ",
74
74
  },
75
75
  ]);
76
76
  });
77
77
  it("should skip empty text but keep images", () => {
78
78
  const image = createMockStagedImage();
79
- const result = (0, message_builder_1.buildMessageContent)(" ", [image]);
79
+ const result = (0, message_builder_1.buildMessageContent)(" ", [image], {});
80
80
  expect(result).toEqual([
81
81
  {
82
82
  type: "image_url",
@@ -104,7 +104,7 @@ describe("buildMessageContent", () => {
104
104
  dataUrl: "data:image/gif;base64,photo3data",
105
105
  }),
106
106
  ];
107
- const result = (0, message_builder_1.buildMessageContent)("Multiple images:", images);
107
+ const result = (0, message_builder_1.buildMessageContent)("Multiple images:", images, {});
108
108
  expect(result).toHaveLength(4); // 1 text + 3 images
109
109
  expect(result[0]).toEqual({
110
110
  type: "text",
@@ -131,17 +131,17 @@ describe("buildMessageContent", () => {
131
131
  });
132
132
  it("should throw error when no content provided", () => {
133
133
  expect(() => {
134
- (0, message_builder_1.buildMessageContent)("", []);
134
+ (0, message_builder_1.buildMessageContent)("", [], {});
135
135
  }).toThrow("Message must contain text or images");
136
136
  });
137
137
  it("should throw error when only whitespace provided", () => {
138
138
  expect(() => {
139
- (0, message_builder_1.buildMessageContent)(" \n\t ", []);
139
+ (0, message_builder_1.buildMessageContent)(" \n\t ", [], {});
140
140
  }).toThrow("Message must contain text or images");
141
141
  });
142
142
  it("should return correct content type structure", () => {
143
143
  const image = createMockStagedImage();
144
- const result = (0, message_builder_1.buildMessageContent)("Test", [image]);
144
+ const result = (0, message_builder_1.buildMessageContent)("Test", [image], {});
145
145
  // Verify the structure matches ChatCompletionContentPart interface
146
146
  result.forEach((part) => {
147
147
  expect(part).toHaveProperty("type");
@@ -158,7 +158,7 @@ describe("buildMessageContent", () => {
158
158
  });
159
159
  });
160
160
  it("should handle edge case with empty array but valid text", () => {
161
- const result = (0, message_builder_1.buildMessageContent)("Just text", []);
161
+ const result = (0, message_builder_1.buildMessageContent)("Just text", [], {});
162
162
  expect(result).toHaveLength(1);
163
163
  expect(result[0]).toEqual({
164
164
  type: "text",
@@ -176,7 +176,7 @@ describe("buildMessageContent", () => {
176
176
  dataUrl: "data:image/png;base64,second",
177
177
  }),
178
178
  ];
179
- const result = (0, message_builder_1.buildMessageContent)("Text content", images);
179
+ const result = (0, message_builder_1.buildMessageContent)("Text content", images, {});
180
180
  expect(result[0].type).toBe("text");
181
181
  expect(result[1].type).toBe("image_url");
182
182
  expect(result[2].type).toBe("image_url");
@@ -187,5 +187,492 @@ describe("buildMessageContent", () => {
187
187
  expect(result[2].image_url?.url).toBe("data:image/png;base64,second");
188
188
  }
189
189
  });
190
+ describe("resource parsing", () => {
191
+ it("should parse a single resource reference", () => {
192
+ const result = (0, message_builder_1.buildMessageContent)("Check @tambo-1hfs429:tambo:test://static/resource/1", [], {});
193
+ expect(result).toEqual([
194
+ {
195
+ type: "text",
196
+ text: "Check ",
197
+ },
198
+ {
199
+ type: "resource",
200
+ resource: {
201
+ uri: "tambo:test://static/resource/1",
202
+ },
203
+ },
204
+ ]);
205
+ });
206
+ it("should parse resource reference at the start of text", () => {
207
+ const result = (0, message_builder_1.buildMessageContent)("@tambo-1hfs429:tambo:test://static/resource/1 check this", [], {});
208
+ expect(result).toEqual([
209
+ {
210
+ type: "resource",
211
+ resource: {
212
+ uri: "tambo:test://static/resource/1",
213
+ },
214
+ },
215
+ {
216
+ type: "text",
217
+ text: " check this",
218
+ },
219
+ ]);
220
+ });
221
+ it("should parse resource reference at the end of text", () => {
222
+ const result = (0, message_builder_1.buildMessageContent)("Check this @tambo-1hfs429:tambo:test://static/resource/1", [], {});
223
+ expect(result).toEqual([
224
+ {
225
+ type: "text",
226
+ text: "Check this ",
227
+ },
228
+ {
229
+ type: "resource",
230
+ resource: {
231
+ uri: "tambo:test://static/resource/1",
232
+ },
233
+ },
234
+ ]);
235
+ });
236
+ it("should parse resource reference with name from resourceNames map", () => {
237
+ const resourceNames = {
238
+ "tambo-1hfs429:tambo:test://static/resource/1": "Documentation.pdf",
239
+ };
240
+ const result = (0, message_builder_1.buildMessageContent)("Check @tambo-1hfs429:tambo:test://static/resource/1", [], resourceNames);
241
+ expect(result).toEqual([
242
+ {
243
+ type: "text",
244
+ text: "Check ",
245
+ },
246
+ {
247
+ type: "resource",
248
+ resource: {
249
+ uri: "tambo:test://static/resource/1",
250
+ name: "Documentation.pdf",
251
+ },
252
+ },
253
+ ]);
254
+ });
255
+ it("should parse resource reference without name when not in resourceNames map", () => {
256
+ const resourceNames = {
257
+ "other-server:other-uri": "Other Resource",
258
+ };
259
+ const result = (0, message_builder_1.buildMessageContent)("Check @tambo-1hfs429:tambo:test://static/resource/1", [], resourceNames);
260
+ expect(result).toEqual([
261
+ {
262
+ type: "text",
263
+ text: "Check ",
264
+ },
265
+ {
266
+ type: "resource",
267
+ resource: {
268
+ uri: "tambo:test://static/resource/1",
269
+ },
270
+ },
271
+ ]);
272
+ });
273
+ it("should parse multiple resource references", () => {
274
+ const result = (0, message_builder_1.buildMessageContent)("Check @tambo-1hfs429:tambo:test://static/resource/1 and @tambo-1hfs429:tambo:test://static/resource/2", [], {});
275
+ expect(result).toEqual([
276
+ {
277
+ type: "text",
278
+ text: "Check ",
279
+ },
280
+ {
281
+ type: "resource",
282
+ resource: {
283
+ uri: "tambo:test://static/resource/1",
284
+ },
285
+ },
286
+ {
287
+ type: "text",
288
+ text: " and ",
289
+ },
290
+ {
291
+ type: "resource",
292
+ resource: {
293
+ uri: "tambo:test://static/resource/2",
294
+ },
295
+ },
296
+ ]);
297
+ });
298
+ it("should preserve whitespace between consecutive resource references", () => {
299
+ const result = (0, message_builder_1.buildMessageContent)("@tambo-1hfs429:tambo:test://static/resource/1 @tambo-1hfs429:tambo:test://static/resource/2", [], {});
300
+ expect(result).toEqual([
301
+ {
302
+ type: "resource",
303
+ resource: {
304
+ uri: "tambo:test://static/resource/1",
305
+ },
306
+ },
307
+ {
308
+ type: "text",
309
+ text: " ",
310
+ },
311
+ {
312
+ type: "resource",
313
+ resource: {
314
+ uri: "tambo:test://static/resource/2",
315
+ },
316
+ },
317
+ ]);
318
+ });
319
+ it("should parse resources with text before, between, and after", () => {
320
+ const result = (0, message_builder_1.buildMessageContent)("Before @tambo-1hfs429:tambo:test://static/resource/1 middle @linear:file://path/to/file.txt after", [], {});
321
+ expect(result).toEqual([
322
+ {
323
+ type: "text",
324
+ text: "Before ",
325
+ },
326
+ {
327
+ type: "resource",
328
+ resource: {
329
+ uri: "tambo:test://static/resource/1",
330
+ },
331
+ },
332
+ {
333
+ type: "text",
334
+ text: " middle ",
335
+ },
336
+ {
337
+ type: "resource",
338
+ resource: {
339
+ uri: "file://path/to/file.txt",
340
+ },
341
+ },
342
+ {
343
+ type: "text",
344
+ text: " after",
345
+ },
346
+ ]);
347
+ });
348
+ it("should parse resources from different server keys", () => {
349
+ const result = (0, message_builder_1.buildMessageContent)("@tambo-1hfs429:tambo:test://static/resource/1 and @linear:linear://issue/123", [], {});
350
+ expect(result).toEqual([
351
+ {
352
+ type: "resource",
353
+ resource: {
354
+ uri: "tambo:test://static/resource/1",
355
+ },
356
+ },
357
+ {
358
+ type: "text",
359
+ text: " and ",
360
+ },
361
+ {
362
+ type: "resource",
363
+ resource: {
364
+ uri: "linear://issue/123",
365
+ },
366
+ },
367
+ ]);
368
+ });
369
+ it("should parse resources with various URI formats and preserve whitespace", () => {
370
+ const result = (0, message_builder_1.buildMessageContent)("@server1:file:///path/to/file.txt @server2:https://example.com/doc.pdf @server3:s3://bucket/key.json", [], {});
371
+ expect(result).toEqual([
372
+ {
373
+ type: "resource",
374
+ resource: {
375
+ uri: "file:///path/to/file.txt",
376
+ },
377
+ },
378
+ {
379
+ type: "text",
380
+ text: " ",
381
+ },
382
+ {
383
+ type: "resource",
384
+ resource: {
385
+ uri: "https://example.com/doc.pdf",
386
+ },
387
+ },
388
+ {
389
+ type: "text",
390
+ text: " ",
391
+ },
392
+ {
393
+ type: "resource",
394
+ resource: {
395
+ uri: "s3://bucket/key.json",
396
+ },
397
+ },
398
+ ]);
399
+ });
400
+ it("should parse resources with hyphens in server key", () => {
401
+ const result = (0, message_builder_1.buildMessageContent)("@my-server-123:file:///path/to/file.txt", [], {});
402
+ expect(result).toEqual([
403
+ {
404
+ type: "resource",
405
+ resource: {
406
+ uri: "file:///path/to/file.txt",
407
+ },
408
+ },
409
+ ]);
410
+ });
411
+ it("should parse resources with numbers in server key", () => {
412
+ const result = (0, message_builder_1.buildMessageContent)("@server123:tambo:test://static/resource/1", [], {});
413
+ expect(result).toEqual([
414
+ {
415
+ type: "resource",
416
+ resource: {
417
+ uri: "tambo:test://static/resource/1",
418
+ },
419
+ },
420
+ ]);
421
+ });
422
+ it("should preserve whitespace in text segments around resource references", () => {
423
+ const result = (0, message_builder_1.buildMessageContent)(" Before @tambo-1hfs429:tambo:test://static/resource/1 After ", [], {});
424
+ expect(result).toEqual([
425
+ {
426
+ type: "text",
427
+ text: " Before ",
428
+ },
429
+ {
430
+ type: "resource",
431
+ resource: {
432
+ uri: "tambo:test://static/resource/1",
433
+ },
434
+ },
435
+ {
436
+ type: "text",
437
+ text: " After ",
438
+ },
439
+ ]);
440
+ });
441
+ it("should handle resource with only whitespace text segments", () => {
442
+ const result = (0, message_builder_1.buildMessageContent)(" @tambo-1hfs429:tambo:test://static/resource/1 ", [], {});
443
+ expect(result).toEqual([
444
+ {
445
+ type: "text",
446
+ text: " ",
447
+ },
448
+ {
449
+ type: "resource",
450
+ resource: {
451
+ uri: "tambo:test://static/resource/1",
452
+ },
453
+ },
454
+ {
455
+ type: "text",
456
+ text: " ",
457
+ },
458
+ ]);
459
+ });
460
+ it("should preserve newlines and spaces around resource references", () => {
461
+ const result = (0, message_builder_1.buildMessageContent)("\n @tambo-1hfs429:tambo:test://static/resource/1 text", [], {});
462
+ expect(result).toEqual([
463
+ {
464
+ type: "text",
465
+ text: "\n ",
466
+ },
467
+ {
468
+ type: "resource",
469
+ resource: {
470
+ uri: "tambo:test://static/resource/1",
471
+ },
472
+ },
473
+ {
474
+ type: "text",
475
+ text: " text",
476
+ },
477
+ ]);
478
+ });
479
+ it("should parse resource-only message without text", () => {
480
+ const result = (0, message_builder_1.buildMessageContent)("@tambo-1hfs429:tambo:test://static/resource/1", [], {});
481
+ expect(result).toEqual([
482
+ {
483
+ type: "resource",
484
+ resource: {
485
+ uri: "tambo:test://static/resource/1",
486
+ },
487
+ },
488
+ ]);
489
+ });
490
+ it("should parse multiple resources with names", () => {
491
+ const resourceNames = {
492
+ "tambo-1hfs429:tambo:test://static/resource/1": "First Resource",
493
+ "tambo-1hfs429:tambo:test://static/resource/2": "Second Resource",
494
+ };
495
+ const result = (0, message_builder_1.buildMessageContent)("Check @tambo-1hfs429:tambo:test://static/resource/1 and @tambo-1hfs429:tambo:test://static/resource/2", [], resourceNames);
496
+ expect(result).toEqual([
497
+ {
498
+ type: "text",
499
+ text: "Check ",
500
+ },
501
+ {
502
+ type: "resource",
503
+ resource: {
504
+ uri: "tambo:test://static/resource/1",
505
+ name: "First Resource",
506
+ },
507
+ },
508
+ {
509
+ type: "text",
510
+ text: " and ",
511
+ },
512
+ {
513
+ type: "resource",
514
+ resource: {
515
+ uri: "tambo:test://static/resource/2",
516
+ name: "Second Resource",
517
+ },
518
+ },
519
+ ]);
520
+ });
521
+ it("should parse resources mixed with images", () => {
522
+ const images = [
523
+ createMockStagedImage({
524
+ id: "img1",
525
+ dataUrl: "data:image/png;base64,abc123",
526
+ }),
527
+ ];
528
+ const result = (0, message_builder_1.buildMessageContent)("Check @tambo-1hfs429:tambo:test://static/resource/1", images, {});
529
+ expect(result).toEqual([
530
+ {
531
+ type: "text",
532
+ text: "Check ",
533
+ },
534
+ {
535
+ type: "resource",
536
+ resource: {
537
+ uri: "tambo:test://static/resource/1",
538
+ },
539
+ },
540
+ {
541
+ type: "image_url",
542
+ image_url: {
543
+ url: "data:image/png;base64,abc123",
544
+ },
545
+ },
546
+ ]);
547
+ });
548
+ it("should parse resources and images with proper ordering", () => {
549
+ const images = [
550
+ createMockStagedImage({
551
+ id: "img1",
552
+ dataUrl: "data:image/png;base64,img1",
553
+ }),
554
+ createMockStagedImage({
555
+ id: "img2",
556
+ dataUrl: "data:image/jpeg;base64,img2",
557
+ }),
558
+ ];
559
+ const result = (0, message_builder_1.buildMessageContent)("Text @tambo-1hfs429:tambo:test://static/resource/1 more text", images, {});
560
+ expect(result).toEqual([
561
+ {
562
+ type: "text",
563
+ text: "Text ",
564
+ },
565
+ {
566
+ type: "resource",
567
+ resource: {
568
+ uri: "tambo:test://static/resource/1",
569
+ },
570
+ },
571
+ {
572
+ type: "text",
573
+ text: " more text",
574
+ },
575
+ {
576
+ type: "image_url",
577
+ image_url: {
578
+ url: "data:image/png;base64,img1",
579
+ },
580
+ },
581
+ {
582
+ type: "image_url",
583
+ image_url: {
584
+ url: "data:image/jpeg;base64,img2",
585
+ },
586
+ },
587
+ ]);
588
+ });
589
+ it("should parse resource reference with URI containing colons", () => {
590
+ const result = (0, message_builder_1.buildMessageContent)("@server:http://example.com:8080/path", [], {});
591
+ expect(result).toEqual([
592
+ {
593
+ type: "resource",
594
+ resource: {
595
+ uri: "http://example.com:8080/path",
596
+ },
597
+ },
598
+ ]);
599
+ });
600
+ it("should parse resource reference with URI containing special characters", () => {
601
+ const result = (0, message_builder_1.buildMessageContent)("@server:file:///path/to/file%20with%20spaces.txt", [], {});
602
+ expect(result).toEqual([
603
+ {
604
+ type: "resource",
605
+ resource: {
606
+ uri: "file:///path/to/file%20with%20spaces.txt",
607
+ },
608
+ },
609
+ ]);
610
+ });
611
+ it("should not parse @ symbol without server key and colon", () => {
612
+ const result = (0, message_builder_1.buildMessageContent)("Mention @user but not a resource", [], {});
613
+ expect(result).toEqual([
614
+ {
615
+ type: "text",
616
+ text: "Mention @user but not a resource",
617
+ },
618
+ ]);
619
+ });
620
+ it("should not parse malformed resource reference missing colon", () => {
621
+ const result = (0, message_builder_1.buildMessageContent)("@serverkey-missing-colon resource", [], {});
622
+ expect(result).toEqual([
623
+ {
624
+ type: "text",
625
+ text: "@serverkey-missing-colon resource",
626
+ },
627
+ ]);
628
+ });
629
+ it("should not parse resource reference with space before colon", () => {
630
+ const result = (0, message_builder_1.buildMessageContent)("@server key :uri", [], {});
631
+ expect(result).toEqual([
632
+ {
633
+ type: "text",
634
+ text: "@server key :uri",
635
+ },
636
+ ]);
637
+ });
638
+ it("should preserve multiple whitespace characters between consecutive resources", () => {
639
+ const result = (0, message_builder_1.buildMessageContent)("@tambo-1hfs429:tambo:test://static/resource/1 @tambo-1hfs429:tambo:test://static/resource/2", [], {});
640
+ expect(result).toEqual([
641
+ {
642
+ type: "resource",
643
+ resource: {
644
+ uri: "tambo:test://static/resource/1",
645
+ },
646
+ },
647
+ {
648
+ type: "text",
649
+ text: " ",
650
+ },
651
+ {
652
+ type: "resource",
653
+ resource: {
654
+ uri: "tambo:test://static/resource/2",
655
+ },
656
+ },
657
+ ]);
658
+ });
659
+ it("should parse resource with only URI and no surrounding text", () => {
660
+ const result = (0, message_builder_1.buildMessageContent)("@tambo-1hfs429:tambo:test://static/resource/1", [], {});
661
+ expect(result).toEqual([
662
+ {
663
+ type: "resource",
664
+ resource: {
665
+ uri: "tambo:test://static/resource/1",
666
+ },
667
+ },
668
+ ]);
669
+ });
670
+ it("should throw error when only resources with empty text segments", () => {
671
+ // This should work - resources alone should be valid
672
+ const result = (0, message_builder_1.buildMessageContent)("@tambo-1hfs429:tambo:test://static/resource/1", [], {});
673
+ expect(result.length).toBeGreaterThan(0);
674
+ expect(result[0].type).toBe("resource");
675
+ });
676
+ });
190
677
  });
191
678
  //# sourceMappingURL=message-builder.test.js.map