@tambo-ai/react 0.67.1 → 0.68.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 (164) hide show
  1. package/README.md +2 -4
  2. package/dist/context-helpers/current-interactables-context-helper.d.ts.map +1 -1
  3. package/dist/context-helpers/current-interactables-context-helper.js +4 -1
  4. package/dist/context-helpers/current-interactables-context-helper.js.map +1 -1
  5. package/dist/hoc/with-tambo-interactable.d.ts +50 -4
  6. package/dist/hoc/with-tambo-interactable.d.ts.map +1 -1
  7. package/dist/hoc/with-tambo-interactable.js +20 -5
  8. package/dist/hoc/with-tambo-interactable.js.map +1 -1
  9. package/dist/hooks/use-component-state.d.ts +3 -8
  10. package/dist/hooks/use-component-state.d.ts.map +1 -1
  11. package/dist/hooks/use-component-state.js +8 -0
  12. package/dist/hooks/use-component-state.js.map +1 -1
  13. package/dist/hooks/use-component-state.test.js +37 -0
  14. package/dist/hooks/use-component-state.test.js.map +1 -1
  15. package/dist/hooks/use-tambo-threads.js +1 -1
  16. package/dist/hooks/use-tambo-threads.js.map +1 -1
  17. package/dist/mcp/mcp-constants.d.ts +19 -0
  18. package/dist/mcp/mcp-constants.d.ts.map +1 -0
  19. package/dist/mcp/mcp-constants.js +21 -0
  20. package/dist/mcp/mcp-constants.js.map +1 -0
  21. package/dist/mcp/mcp-hooks.d.ts +32 -3
  22. package/dist/mcp/mcp-hooks.d.ts.map +1 -1
  23. package/dist/mcp/mcp-hooks.js +40 -29
  24. package/dist/mcp/mcp-hooks.js.map +1 -1
  25. package/dist/mcp/mcp-hooks.test.js +8 -5
  26. package/dist/mcp/mcp-hooks.test.js.map +1 -1
  27. package/dist/mcp/tambo-mcp-provider.d.ts +7 -0
  28. package/dist/mcp/tambo-mcp-provider.d.ts.map +1 -1
  29. package/dist/mcp/tambo-mcp-provider.js +202 -155
  30. package/dist/mcp/tambo-mcp-provider.js.map +1 -1
  31. package/dist/model/component-metadata.d.ts +1 -1
  32. package/dist/model/component-metadata.d.ts.map +1 -1
  33. package/dist/model/component-metadata.js.map +1 -1
  34. package/dist/model/tambo-interactable.d.ts +7 -5
  35. package/dist/model/tambo-interactable.d.ts.map +1 -1
  36. package/dist/model/tambo-interactable.js.map +1 -1
  37. package/dist/providers/__tests__/thread-input-resource-resolution.test.d.ts +2 -0
  38. package/dist/providers/__tests__/thread-input-resource-resolution.test.d.ts.map +1 -0
  39. package/dist/providers/__tests__/thread-input-resource-resolution.test.js +592 -0
  40. package/dist/providers/__tests__/thread-input-resource-resolution.test.js.map +1 -0
  41. package/dist/providers/tambo-interactable-provider-partial-updates.test.js +22 -21
  42. package/dist/providers/tambo-interactable-provider-partial-updates.test.js.map +1 -1
  43. package/dist/providers/tambo-interactable-provider.d.ts +3 -2
  44. package/dist/providers/tambo-interactable-provider.d.ts.map +1 -1
  45. package/dist/providers/tambo-interactable-provider.js +98 -14
  46. package/dist/providers/tambo-interactable-provider.js.map +1 -1
  47. package/dist/providers/tambo-interactable-provider.test.js +242 -0
  48. package/dist/providers/tambo-interactable-provider.test.js.map +1 -1
  49. package/dist/providers/tambo-provider.d.ts.map +1 -1
  50. package/dist/providers/tambo-provider.js +7 -5
  51. package/dist/providers/tambo-provider.js.map +1 -1
  52. package/dist/providers/tambo-thread-input-provider.d.ts.map +1 -1
  53. package/dist/providers/tambo-thread-input-provider.js +21 -3
  54. package/dist/providers/tambo-thread-input-provider.js.map +1 -1
  55. package/dist/schema/index.d.ts +1 -1
  56. package/dist/schema/index.d.ts.map +1 -1
  57. package/dist/schema/index.js +2 -1
  58. package/dist/schema/index.js.map +1 -1
  59. package/dist/schema/json-schema.d.ts +7 -0
  60. package/dist/schema/json-schema.d.ts.map +1 -1
  61. package/dist/schema/json-schema.js +11 -0
  62. package/dist/schema/json-schema.js.map +1 -1
  63. package/dist/schema/json-schema.test.d.ts +2 -0
  64. package/dist/schema/json-schema.test.d.ts.map +1 -0
  65. package/dist/schema/json-schema.test.js +204 -0
  66. package/dist/schema/json-schema.test.js.map +1 -0
  67. package/dist/setupTests.js +3 -0
  68. package/dist/setupTests.js.map +1 -1
  69. package/dist/util/message-builder.d.ts +3 -1
  70. package/dist/util/message-builder.d.ts.map +1 -1
  71. package/dist/util/message-builder.js +20 -3
  72. package/dist/util/message-builder.js.map +1 -1
  73. package/dist/util/message-builder.test.js +269 -0
  74. package/dist/util/message-builder.test.js.map +1 -1
  75. package/dist/util/resource-content-resolver.d.ts +20 -0
  76. package/dist/util/resource-content-resolver.d.ts.map +1 -0
  77. package/dist/util/resource-content-resolver.js +93 -0
  78. package/dist/util/resource-content-resolver.js.map +1 -0
  79. package/dist/util/resource-content-resolver.test.d.ts +2 -0
  80. package/dist/util/resource-content-resolver.test.d.ts.map +1 -0
  81. package/dist/util/resource-content-resolver.test.js +254 -0
  82. package/dist/util/resource-content-resolver.test.js.map +1 -0
  83. package/esm/context-helpers/current-interactables-context-helper.d.ts.map +1 -1
  84. package/esm/context-helpers/current-interactables-context-helper.js +4 -1
  85. package/esm/context-helpers/current-interactables-context-helper.js.map +1 -1
  86. package/esm/hoc/with-tambo-interactable.d.ts +50 -4
  87. package/esm/hoc/with-tambo-interactable.d.ts.map +1 -1
  88. package/esm/hoc/with-tambo-interactable.js +20 -5
  89. package/esm/hoc/with-tambo-interactable.js.map +1 -1
  90. package/esm/hooks/use-component-state.d.ts +3 -8
  91. package/esm/hooks/use-component-state.d.ts.map +1 -1
  92. package/esm/hooks/use-component-state.js +8 -0
  93. package/esm/hooks/use-component-state.js.map +1 -1
  94. package/esm/hooks/use-component-state.test.js +37 -0
  95. package/esm/hooks/use-component-state.test.js.map +1 -1
  96. package/esm/hooks/use-tambo-threads.js +1 -1
  97. package/esm/hooks/use-tambo-threads.js.map +1 -1
  98. package/esm/mcp/mcp-constants.d.ts +19 -0
  99. package/esm/mcp/mcp-constants.d.ts.map +1 -0
  100. package/esm/mcp/mcp-constants.js +18 -0
  101. package/esm/mcp/mcp-constants.js.map +1 -0
  102. package/esm/mcp/mcp-hooks.d.ts +32 -3
  103. package/esm/mcp/mcp-hooks.d.ts.map +1 -1
  104. package/esm/mcp/mcp-hooks.js +40 -30
  105. package/esm/mcp/mcp-hooks.js.map +1 -1
  106. package/esm/mcp/mcp-hooks.test.js +8 -5
  107. package/esm/mcp/mcp-hooks.test.js.map +1 -1
  108. package/esm/mcp/tambo-mcp-provider.d.ts +7 -0
  109. package/esm/mcp/tambo-mcp-provider.d.ts.map +1 -1
  110. package/esm/mcp/tambo-mcp-provider.js +201 -154
  111. package/esm/mcp/tambo-mcp-provider.js.map +1 -1
  112. package/esm/model/component-metadata.d.ts +1 -1
  113. package/esm/model/component-metadata.d.ts.map +1 -1
  114. package/esm/model/component-metadata.js.map +1 -1
  115. package/esm/model/tambo-interactable.d.ts +7 -5
  116. package/esm/model/tambo-interactable.d.ts.map +1 -1
  117. package/esm/model/tambo-interactable.js.map +1 -1
  118. package/esm/providers/__tests__/thread-input-resource-resolution.test.d.ts +2 -0
  119. package/esm/providers/__tests__/thread-input-resource-resolution.test.d.ts.map +1 -0
  120. package/esm/providers/__tests__/thread-input-resource-resolution.test.js +587 -0
  121. package/esm/providers/__tests__/thread-input-resource-resolution.test.js.map +1 -0
  122. package/esm/providers/tambo-interactable-provider-partial-updates.test.js +22 -21
  123. package/esm/providers/tambo-interactable-provider-partial-updates.test.js.map +1 -1
  124. package/esm/providers/tambo-interactable-provider.d.ts +3 -2
  125. package/esm/providers/tambo-interactable-provider.d.ts.map +1 -1
  126. package/esm/providers/tambo-interactable-provider.js +98 -14
  127. package/esm/providers/tambo-interactable-provider.js.map +1 -1
  128. package/esm/providers/tambo-interactable-provider.test.js +242 -0
  129. package/esm/providers/tambo-interactable-provider.test.js.map +1 -1
  130. package/esm/providers/tambo-provider.d.ts.map +1 -1
  131. package/esm/providers/tambo-provider.js +7 -5
  132. package/esm/providers/tambo-provider.js.map +1 -1
  133. package/esm/providers/tambo-thread-input-provider.d.ts.map +1 -1
  134. package/esm/providers/tambo-thread-input-provider.js +21 -3
  135. package/esm/providers/tambo-thread-input-provider.js.map +1 -1
  136. package/esm/schema/index.d.ts +1 -1
  137. package/esm/schema/index.d.ts.map +1 -1
  138. package/esm/schema/index.js +1 -1
  139. package/esm/schema/index.js.map +1 -1
  140. package/esm/schema/json-schema.d.ts +7 -0
  141. package/esm/schema/json-schema.d.ts.map +1 -1
  142. package/esm/schema/json-schema.js +10 -0
  143. package/esm/schema/json-schema.js.map +1 -1
  144. package/esm/schema/json-schema.test.d.ts +2 -0
  145. package/esm/schema/json-schema.test.d.ts.map +1 -0
  146. package/esm/schema/json-schema.test.js +202 -0
  147. package/esm/schema/json-schema.test.js.map +1 -0
  148. package/esm/setupTests.js +3 -0
  149. package/esm/setupTests.js.map +1 -1
  150. package/esm/util/message-builder.d.ts +3 -1
  151. package/esm/util/message-builder.d.ts.map +1 -1
  152. package/esm/util/message-builder.js +20 -3
  153. package/esm/util/message-builder.js.map +1 -1
  154. package/esm/util/message-builder.test.js +269 -0
  155. package/esm/util/message-builder.test.js.map +1 -1
  156. package/esm/util/resource-content-resolver.d.ts +20 -0
  157. package/esm/util/resource-content-resolver.d.ts.map +1 -0
  158. package/esm/util/resource-content-resolver.js +89 -0
  159. package/esm/util/resource-content-resolver.js.map +1 -0
  160. package/esm/util/resource-content-resolver.test.d.ts +2 -0
  161. package/esm/util/resource-content-resolver.test.d.ts.map +1 -0
  162. package/esm/util/resource-content-resolver.test.js +252 -0
  163. package/esm/util/resource-content-resolver.test.js.map +1 -0
  164. package/package.json +1 -1
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=resource-content-resolver.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-content-resolver.test.d.ts","sourceRoot":"","sources":["../../src/util/resource-content-resolver.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,252 @@
1
+ import { ServerType } from "../mcp/mcp-constants";
2
+ import { MCPTransport } from "../mcp/mcp-client";
3
+ import { resolveResourceContents, extractResourceUris, } from "./resource-content-resolver";
4
+ describe("extractResourceUris", () => {
5
+ it("should extract a single resource URI", () => {
6
+ const text = "Check @registry:file:///path/to/doc.txt";
7
+ const result = extractResourceUris(text);
8
+ expect(result).toEqual(["registry:file:///path/to/doc.txt"]);
9
+ });
10
+ it("should extract multiple resource URIs", () => {
11
+ const text = "Check @registry:file:///doc1.txt and @server-a:file:///doc2.txt";
12
+ const result = extractResourceUris(text);
13
+ expect(result).toEqual([
14
+ "registry:file:///doc1.txt",
15
+ "server-a:file:///doc2.txt",
16
+ ]);
17
+ });
18
+ it("should extract resource URIs with internal server prefix", () => {
19
+ const text = "Check @tambo-abc123:tambo:test://resource/1";
20
+ const result = extractResourceUris(text);
21
+ expect(result).toEqual(["tambo-abc123:tambo:test://resource/1"]);
22
+ });
23
+ it("should extract resource URIs with hyphens in server key", () => {
24
+ const text = "@my-mcp-server:file:///path/file.txt";
25
+ const result = extractResourceUris(text);
26
+ expect(result).toEqual(["my-mcp-server:file:///path/file.txt"]);
27
+ });
28
+ it("should return empty array for text without resource references", () => {
29
+ const text = "Just some regular text without @mentions";
30
+ const result = extractResourceUris(text);
31
+ expect(result).toEqual([]);
32
+ });
33
+ it("should not extract malformed references without colon", () => {
34
+ const text = "@server-without-colon is not a resource";
35
+ const result = extractResourceUris(text);
36
+ expect(result).toEqual([]);
37
+ });
38
+ it("should handle URIs with multiple colons", () => {
39
+ const text = "@server:http://example.com:8080/path";
40
+ const result = extractResourceUris(text);
41
+ expect(result).toEqual(["server:http://example.com:8080/path"]);
42
+ });
43
+ });
44
+ describe("resolveResourceContents", () => {
45
+ const createMockConnectedServer = (serverKey, readResource, serverType = ServerType.BROWSER_SIDE) => ({
46
+ key: `mcp-${serverKey}`,
47
+ serverKey,
48
+ url: `https://${serverKey}.example.com`,
49
+ name: `MCP Server ${serverKey}`,
50
+ transport: MCPTransport.HTTP,
51
+ serverType,
52
+ client: {
53
+ client: {
54
+ readResource,
55
+ listResources: jest.fn().mockResolvedValue({ resources: [] }),
56
+ listTools: jest.fn().mockResolvedValue({ tools: [] }),
57
+ listPrompts: jest.fn().mockResolvedValue({ prompts: [] }),
58
+ getPrompt: jest.fn().mockResolvedValue(null),
59
+ callTool: jest.fn().mockResolvedValue(null),
60
+ },
61
+ close: jest.fn().mockResolvedValue(undefined),
62
+ },
63
+ });
64
+ const createMockInternalServer = (serverKey) => ({
65
+ key: serverKey,
66
+ serverKey,
67
+ url: "https://api.tambo.ai/mcp",
68
+ name: "__tambo_internal_mcp_server__",
69
+ transport: MCPTransport.HTTP,
70
+ serverType: ServerType.TAMBO_INTERNAL,
71
+ connectionError: undefined, // No client for internal servers
72
+ });
73
+ const createMockResourceSource = (getResource) => ({
74
+ listResources: jest.fn().mockResolvedValue([]),
75
+ getResource,
76
+ });
77
+ it("should resolve registry resources via resourceSource", async () => {
78
+ const mockGetResource = jest.fn().mockResolvedValue({
79
+ contents: [
80
+ {
81
+ uri: "file:///local/doc.txt",
82
+ mimeType: "text/plain",
83
+ text: "Registry document content",
84
+ },
85
+ ],
86
+ });
87
+ const resourceSource = createMockResourceSource(mockGetResource);
88
+ const result = await resolveResourceContents(["registry:file:///local/doc.txt"], [], // Registry resources don't need a server - they're handled directly
89
+ resourceSource);
90
+ expect(mockGetResource).toHaveBeenCalledWith("file:///local/doc.txt");
91
+ expect(result.size).toBe(1);
92
+ expect(result.get("registry:file:///local/doc.txt")).toEqual({
93
+ contents: [
94
+ {
95
+ uri: "file:///local/doc.txt",
96
+ mimeType: "text/plain",
97
+ text: "Registry document content",
98
+ },
99
+ ],
100
+ });
101
+ });
102
+ it("should resolve client-side MCP resources via mcpServer", async () => {
103
+ const mockReadResource = jest.fn().mockResolvedValue({
104
+ contents: [
105
+ {
106
+ uri: "file:///mcp/file.txt",
107
+ mimeType: "text/plain",
108
+ text: "MCP server content",
109
+ },
110
+ ],
111
+ });
112
+ const mcpServer = createMockConnectedServer("linear", mockReadResource);
113
+ const result = await resolveResourceContents(["linear:file:///mcp/file.txt"], [mcpServer], undefined);
114
+ expect(mockReadResource).toHaveBeenCalledWith({
115
+ uri: "file:///mcp/file.txt",
116
+ });
117
+ expect(result.size).toBe(1);
118
+ expect(result.get("linear:file:///mcp/file.txt")).toEqual({
119
+ contents: [
120
+ {
121
+ uri: "file:///mcp/file.txt",
122
+ mimeType: "text/plain",
123
+ text: "MCP server content",
124
+ },
125
+ ],
126
+ });
127
+ });
128
+ it("should skip internal server resources (serverType: TAMBO_INTERNAL)", async () => {
129
+ const mockGetResource = jest.fn();
130
+ const resourceSource = createMockResourceSource(mockGetResource);
131
+ const internalServer = createMockInternalServer("tambo-abc123");
132
+ const result = await resolveResourceContents(["tambo-abc123:tambo:test://resource/1"], [internalServer], resourceSource);
133
+ // Should not call getResource for internal server resources
134
+ expect(mockGetResource).not.toHaveBeenCalled();
135
+ // Should return empty map since internal resources are skipped
136
+ expect(result.size).toBe(0);
137
+ });
138
+ it("should resolve multiple resources in parallel", async () => {
139
+ const mockGetResource = jest.fn().mockResolvedValue({
140
+ contents: [{ uri: "file:///doc.txt", text: "registry content" }],
141
+ });
142
+ const mockReadResource = jest.fn().mockResolvedValue({
143
+ contents: [{ uri: "file:///mcp.txt", text: "mcp content" }],
144
+ });
145
+ const resourceSource = createMockResourceSource(mockGetResource);
146
+ const mcpServer = createMockConnectedServer("mcp-server", mockReadResource);
147
+ const result = await resolveResourceContents(["registry:file:///doc.txt", "mcp-server:file:///mcp.txt"], [mcpServer], // Only MCP server needed - registry handled directly
148
+ resourceSource);
149
+ expect(result.size).toBe(2);
150
+ expect(result.has("registry:file:///doc.txt")).toBe(true);
151
+ expect(result.has("mcp-server:file:///mcp.txt")).toBe(true);
152
+ });
153
+ it("should handle mixed internal and client-side resources", async () => {
154
+ const mockGetResource = jest.fn().mockResolvedValue({
155
+ contents: [{ uri: "file:///doc.txt", text: "registry content" }],
156
+ });
157
+ const resourceSource = createMockResourceSource(mockGetResource);
158
+ const internalServer = createMockInternalServer("tambo-abc123");
159
+ const result = await resolveResourceContents([
160
+ "registry:file:///doc.txt", // client-side registry
161
+ "tambo-abc123:tambo:test://resource/1", // internal - should skip
162
+ ], [internalServer], // Only internal server needed - registry handled directly
163
+ resourceSource);
164
+ // Only the registry resource should be resolved
165
+ expect(mockGetResource).toHaveBeenCalledTimes(1);
166
+ expect(result.size).toBe(1);
167
+ expect(result.has("registry:file:///doc.txt")).toBe(true);
168
+ expect(result.has("tambo-abc123:tambo:test://resource/1")).toBe(false);
169
+ });
170
+ it("should gracefully handle registry resource fetch failure", async () => {
171
+ const consoleSpy = jest.spyOn(console, "warn").mockImplementation();
172
+ const mockGetResource = jest
173
+ .fn()
174
+ .mockRejectedValue(new Error("Resource not found"));
175
+ const resourceSource = createMockResourceSource(mockGetResource);
176
+ const result = await resolveResourceContents(["registry:file:///missing.txt"], [], // Registry resources don't need a server
177
+ resourceSource);
178
+ expect(consoleSpy).toHaveBeenCalledWith("Failed to fetch resource content for registry:file:///missing.txt:", expect.any(Error));
179
+ expect(result.size).toBe(0);
180
+ consoleSpy.mockRestore();
181
+ });
182
+ it("should gracefully handle MCP resource fetch failure", async () => {
183
+ const consoleSpy = jest.spyOn(console, "warn").mockImplementation();
184
+ const mockReadResource = jest
185
+ .fn()
186
+ .mockRejectedValue(new Error("MCP server error"));
187
+ const mcpServer = createMockConnectedServer("linear", mockReadResource);
188
+ const result = await resolveResourceContents(["linear:file:///missing.txt"], [mcpServer], undefined);
189
+ expect(consoleSpy).toHaveBeenCalledWith("Failed to fetch resource content for linear:file:///missing.txt:", expect.any(Error));
190
+ expect(result.size).toBe(0);
191
+ consoleSpy.mockRestore();
192
+ });
193
+ it("should warn when no resourceSource available for registry resource", async () => {
194
+ const consoleSpy = jest.spyOn(console, "warn").mockImplementation();
195
+ const result = await resolveResourceContents(["registry:file:///doc.txt"], [], // Registry resources don't need a server
196
+ undefined);
197
+ expect(consoleSpy).toHaveBeenCalledWith("No resource source available to resolve registry resource: registry:file:///doc.txt");
198
+ expect(result.size).toBe(0);
199
+ consoleSpy.mockRestore();
200
+ });
201
+ it("should warn when no server found for resource", async () => {
202
+ const consoleSpy = jest.spyOn(console, "warn").mockImplementation();
203
+ const result = await resolveResourceContents(["unknown-server:file:///doc.txt"], [], // no servers
204
+ undefined);
205
+ expect(consoleSpy).toHaveBeenCalledWith("No server found for resource: unknown-server:file:///doc.txt");
206
+ expect(result.size).toBe(0);
207
+ consoleSpy.mockRestore();
208
+ });
209
+ it("should handle resource content with blob data", async () => {
210
+ const mockGetResource = jest.fn().mockResolvedValue({
211
+ contents: [
212
+ {
213
+ uri: "file:///image.png",
214
+ mimeType: "image/png",
215
+ blob: "base64encodeddata",
216
+ },
217
+ ],
218
+ });
219
+ const resourceSource = createMockResourceSource(mockGetResource);
220
+ const result = await resolveResourceContents(["registry:file:///image.png"], [], // Registry resources don't need a server
221
+ resourceSource);
222
+ expect(result.get("registry:file:///image.png")).toEqual({
223
+ contents: [
224
+ {
225
+ uri: "file:///image.png",
226
+ mimeType: "image/png",
227
+ blob: "base64encodeddata",
228
+ },
229
+ ],
230
+ });
231
+ });
232
+ it("should handle URIs with no colon (invalid format)", async () => {
233
+ const result = await resolveResourceContents(["invalid-uri-no-colon"], [], undefined);
234
+ expect(result.size).toBe(0);
235
+ });
236
+ it("should handle null content from getResource", async () => {
237
+ const mockGetResource = jest.fn().mockResolvedValue(null);
238
+ const resourceSource = createMockResourceSource(mockGetResource);
239
+ const result = await resolveResourceContents(["registry:file:///doc.txt"], [], // Registry resources don't need a server
240
+ resourceSource);
241
+ expect(mockGetResource).toHaveBeenCalled();
242
+ expect(result.size).toBe(0);
243
+ });
244
+ it("should handle null content from readResource", async () => {
245
+ const mockReadResource = jest.fn().mockResolvedValue(null);
246
+ const mcpServer = createMockConnectedServer("linear", mockReadResource);
247
+ const result = await resolveResourceContents(["linear:file:///doc.txt"], [mcpServer], undefined);
248
+ expect(mockReadResource).toHaveBeenCalled();
249
+ expect(result.size).toBe(0);
250
+ });
251
+ });
252
+ //# sourceMappingURL=resource-content-resolver.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-content-resolver.test.js","sourceRoot":"","sources":["../../src/util/resource-content-resolver.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGlD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EACL,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,6BAA6B,CAAC;AAErC,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC9C,MAAM,IAAI,GAAG,yCAAyC,CAAC;QACvD,MAAM,MAAM,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;QACzC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,kCAAkC,CAAC,CAAC,CAAC;IAC/D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAC/C,MAAM,IAAI,GACR,iEAAiE,CAAC;QACpE,MAAM,MAAM,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;QACzC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACrB,2BAA2B;YAC3B,2BAA2B;SAC5B,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0DAA0D,EAAE,GAAG,EAAE;QAClE,MAAM,IAAI,GAAG,6CAA6C,CAAC;QAC3D,MAAM,MAAM,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;QACzC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,sCAAsC,CAAC,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yDAAyD,EAAE,GAAG,EAAE;QACjE,MAAM,IAAI,GAAG,sCAAsC,CAAC;QACpD,MAAM,MAAM,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;QACzC,MAAM,CAAC,MAAM,CAAC,C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C7C,cAAc,CACf,CAAC;QAEF,MAAM,CAAC,eAAe,CAAC,CAAC,gBAAgB,EAAE,CAAC;QAC3C,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8CAA8C,EAAE,KAAK,IAAI,EAAE;QAC5D,MAAM,gBAAgB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAC3D,MAAM,SAAS,GAAG,yBAAyB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;QAExE,MAAM,MAAM,GAAG,MAAM,uBAAuB,CAC1C,CAAC,wBAAwB,CAAC,EAC1B,CAAC,SAAS,CAAC,EACX,SAAS,CACV,CAAC;QAEF,MAAM,CAAC,gBAAgB,CAAC,CAAC,gBAAgB,EAAE,CAAC;QAC5C,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import type { ReadResourceResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport { ServerType } from \"../mcp/mcp-constants\";\nimport type { McpServer } from \"../mcp/tambo-mcp-provider\";\nimport type { ResourceSource } from \"../model/resource-info\";\nimport { MCPTransport } from \"../mcp/mcp-client\";\n\nimport {\n resolveResourceContents,\n extractResourceUris,\n} from \"./resource-content-resolver\";\n\ndescribe(\"extractResourceUris\", () => {\n it(\"should extract a single resource URI\", () => {\n const text = \"Check @registry:file:///path/to/doc.txt\";\n const result = extractResourceUris(text);\n expect(result).toEqual([\"registry:file:///path/to/doc.txt\"]);\n });\n\n it(\"should extract multiple resource URIs\", () => {\n const text =\n \"Check @registry:file:///doc1.txt and @server-a:file:///doc2.txt\";\n const result = extractResourceUris(text);\n expect(result).toEqual([\n \"registry:file:///doc1.txt\",\n \"server-a:file:///doc2.txt\",\n ]);\n });\n\n it(\"should extract resource URIs with internal server prefix\", () => {\n const text = \"Check @tambo-abc123:tambo:test://resource/1\";\n const result = extractResourceUris(text);\n expect(result).toEqual([\"tambo-abc123:tambo:test://resource/1\"]);\n });\n\n it(\"should extract resource URIs with hyphens in server key\", () => {\n const text = \"@my-mcp-server:file:///path/file.txt\";\n const result = extractResourceUris(text);\n expect(result).toEqual([\"my-mcp-server:file:///path/file.txt\"]);\n });\n\n it(\"should return empty array for text without resource references\", () => {\n const text = \"Just some regular text without @mentions\";\n const result = extractResourceUris(text);\n expect(result).toEqual([]);\n });\n\n it(\"should not extract malformed references without colon\", () => {\n const text = \"@server-without-colon is not a resource\";\n const result = extractResourceUris(text);\n expect(result).toEqual([]);\n });\n\n it(\"should handle URIs with multiple colons\", () => {\n const text = \"@server:http://example.com:8080/path\";\n const result = extractResourceUris(text);\n expect(result).toEqual([\"server:http://example.com:8080/path\"]);\n });\n});\n\ndescribe(\"resolveResourceContents\", () => {\n const createMockConnectedServer = (\n serverKey: string,\n readResource: jest.Mock,\n serverType: ServerType = ServerType.BROWSER_SIDE,\n ): McpServer =>\n ({\n key: `mcp-${serverKey}`,\n serverKey,\n url: `https://${serverKey}.example.com`,\n name: `MCP Server ${serverKey}`,\n transport: MCPTransport.HTTP,\n serverType,\n client: {\n client: {\n readResource,\n listResources: jest.fn().mockResolvedValue({ resources: [] }),\n listTools: jest.fn().mockResolvedValue({ tools: [] }),\n listPrompts: jest.fn().mockResolvedValue({ prompts: [] }),\n getPrompt: jest.fn().mockResolvedValue(null),\n callTool: jest.fn().mockResolvedValue(null),\n },\n close: jest.fn().mockResolvedValue(undefined),\n } as unknown as McpServer[\"client\"],\n }) as McpServer;\n\n const createMockInternalServer = (serverKey: string): McpServer =>\n ({\n key: serverKey,\n serverKey,\n url: \"https://api.tambo.ai/mcp\",\n name: \"__tambo_internal_mcp_server__\",\n transport: MCPTransport.HTTP,\n serverType: ServerType.TAMBO_INTERNAL,\n connectionError: undefined, // No client for internal servers\n }) as unknown as McpServer;\n\n const createMockResourceSource = (\n getResource: jest.Mock,\n ): ResourceSource => ({\n listResources: jest.fn().mockResolvedValue([]),\n getResource,\n });\n\n it(\"should resolve registry resources via resourceSource\", async () => {\n const mockGetResource = jest.fn().mockResolvedValue({\n contents: [\n {\n uri: \"file:///local/doc.txt\",\n mimeType: \"text/plain\",\n text: \"Registry document content\",\n },\n ],\n } satisfies ReadResourceResult);\n\n const resourceSource = createMockResourceSource(mockGetResource);\n\n const result = await resolveResourceContents(\n [\"registry:file:///local/doc.txt\"],\n [], // Registry resources don't need a server - they're handled directly\n resourceSource,\n );\n\n expect(mockGetResource).toHaveBeenCalledWith(\"file:///local/doc.txt\");\n expect(result.size).toBe(1);\n expect(result.get(\"registry:file:///local/doc.txt\")).toEqual({\n contents: [\n {\n uri: \"file:///local/doc.txt\",\n mimeType: \"text/plain\",\n text: \"Registry document content\",\n },\n ],\n });\n });\n\n it(\"should resolve client-side MCP resources via mcpServer\", async () => {\n const mockReadResource = jest.fn().mockResolvedValue({\n contents: [\n {\n uri: \"file:///mcp/file.txt\",\n mimeType: \"text/plain\",\n text: \"MCP server content\",\n },\n ],\n } satisfies ReadResourceResult);\n\n const mcpServer = createMockConnectedServer(\"linear\", mockReadResource);\n\n const result = await resolveResourceContents(\n [\"linear:file:///mcp/file.txt\"],\n [mcpServer],\n undefined,\n );\n\n expect(mockReadResource).toHaveBeenCalledWith({\n uri: \"file:///mcp/file.txt\",\n });\n expect(result.size).toBe(1);\n expect(result.get(\"linear:file:///mcp/file.txt\")).toEqual({\n contents: [\n {\n uri: \"file:///mcp/file.txt\",\n mimeType: \"text/plain\",\n text: \"MCP server content\",\n },\n ],\n });\n });\n\n it(\"should skip internal server resources (serverType: TAMBO_INTERNAL)\", async () => {\n const mockGetResource = jest.fn();\n const resourceSource = createMockResourceSource(mockGetResource);\n const internalServer = createMockInternalServer(\"tambo-abc123\");\n\n const result = await resolveResourceContents(\n [\"tambo-abc123:tambo:test://resource/1\"],\n [internalServer],\n resourceSource,\n );\n\n // Should not call getResource for internal server resources\n expect(mockGetResource).not.toHaveBeenCalled();\n // Should return empty map since internal resources are skipped\n expect(result.size).toBe(0);\n });\n\n it(\"should resolve multiple resources in parallel\", async () => {\n const mockGetResource = jest.fn().mockResolvedValue({\n contents: [{ uri: \"file:///doc.txt\", text: \"registry content\" }],\n });\n const mockReadResource = jest.fn().mockResolvedValue({\n contents: [{ uri: \"file:///mcp.txt\", text: \"mcp content\" }],\n });\n\n const resourceSource = createMockResourceSource(mockGetResource);\n const mcpServer = createMockConnectedServer(\"mcp-server\", mockReadResource);\n\n const result = await resolveResourceContents(\n [\"registry:file:///doc.txt\", \"mcp-server:file:///mcp.txt\"],\n [mcpServer], // Only MCP server needed - registry handled directly\n resourceSource,\n );\n\n expect(result.size).toBe(2);\n expect(result.has(\"registry:file:///doc.txt\")).toBe(true);\n expect(result.has(\"mcp-server:file:///mcp.txt\")).toBe(true);\n });\n\n it(\"should handle mixed internal and client-side resources\", async () => {\n const mockGetResource = jest.fn().mockResolvedValue({\n contents: [{ uri: \"file:///doc.txt\", text: \"registry content\" }],\n });\n const resourceSource = createMockResourceSource(mockGetResource);\n const internalServer = createMockInternalServer(\"tambo-abc123\");\n\n const result = await resolveResourceContents(\n [\n \"registry:file:///doc.txt\", // client-side registry\n \"tambo-abc123:tambo:test://resource/1\", // internal - should skip\n ],\n [internalServer], // Only internal server needed - registry handled directly\n resourceSource,\n );\n\n // Only the registry resource should be resolved\n expect(mockGetResource).toHaveBeenCalledTimes(1);\n expect(result.size).toBe(1);\n expect(result.has(\"registry:file:///doc.txt\")).toBe(true);\n expect(result.has(\"tambo-abc123:tambo:test://resource/1\")).toBe(false);\n });\n\n it(\"should gracefully handle registry resource fetch failure\", async () => {\n const consoleSpy = jest.spyOn(console, \"warn\").mockImplementation();\n const mockGetResource = jest\n .fn()\n .mockRejectedValue(new Error(\"Resource not found\"));\n const resourceSource = createMockResourceSource(mockGetResource);\n\n const result = await resolveResourceContents(\n [\"registry:file:///missing.txt\"],\n [], // Registry resources don't need a server\n resourceSource,\n );\n\n expect(consoleSpy).toHaveBeenCalledWith(\n \"Failed to fetch resource content for registry:file:///missing.txt:\",\n expect.any(Error),\n );\n expect(result.size).toBe(0);\n\n consoleSpy.mockRestore();\n });\n\n it(\"should gracefully handle MCP resource fetch failure\", async () => {\n const consoleSpy = jest.spyOn(console, \"warn\").mockImplementation();\n const mockReadResource = jest\n .fn()\n .mockRejectedValue(new Error(\"MCP server error\"));\n const mcpServer = createMockConnectedServer(\"linear\", mockReadResource);\n\n const result = await resolveResourceContents(\n [\"linear:file:///missing.txt\"],\n [mcpServer],\n undefined,\n );\n\n expect(consoleSpy).toHaveBeenCalledWith(\n \"Failed to fetch resource content for linear:file:///missing.txt:\",\n expect.any(Error),\n );\n expect(result.size).toBe(0);\n\n consoleSpy.mockRestore();\n });\n\n it(\"should warn when no resourceSource available for registry resource\", async () => {\n const consoleSpy = jest.spyOn(console, \"warn\").mockImplementation();\n\n const result = await resolveResourceContents(\n [\"registry:file:///doc.txt\"],\n [], // Registry resources don't need a server\n undefined, // no resourceSource\n );\n\n expect(consoleSpy).toHaveBeenCalledWith(\n \"No resource source available to resolve registry resource: registry:file:///doc.txt\",\n );\n expect(result.size).toBe(0);\n\n consoleSpy.mockRestore();\n });\n\n it(\"should warn when no server found for resource\", async () => {\n const consoleSpy = jest.spyOn(console, \"warn\").mockImplementation();\n\n const result = await resolveResourceContents(\n [\"unknown-server:file:///doc.txt\"],\n [], // no servers\n undefined,\n );\n\n expect(consoleSpy).toHaveBeenCalledWith(\n \"No server found for resource: unknown-server:file:///doc.txt\",\n );\n expect(result.size).toBe(0);\n\n consoleSpy.mockRestore();\n });\n\n it(\"should handle resource content with blob data\", async () => {\n const mockGetResource = jest.fn().mockResolvedValue({\n contents: [\n {\n uri: \"file:///image.png\",\n mimeType: \"image/png\",\n blob: \"base64encodeddata\",\n },\n ],\n } satisfies ReadResourceResult);\n\n const resourceSource = createMockResourceSource(mockGetResource);\n\n const result = await resolveResourceContents(\n [\"registry:file:///image.png\"],\n [], // Registry resources don't need a server\n resourceSource,\n );\n\n expect(result.get(\"registry:file:///image.png\")).toEqual({\n contents: [\n {\n uri: \"file:///image.png\",\n mimeType: \"image/png\",\n blob: \"base64encodeddata\",\n },\n ],\n });\n });\n\n it(\"should handle URIs with no colon (invalid format)\", async () => {\n const result = await resolveResourceContents(\n [\"invalid-uri-no-colon\"],\n [],\n undefined,\n );\n\n expect(result.size).toBe(0);\n });\n\n it(\"should handle null content from getResource\", async () => {\n const mockGetResource = jest.fn().mockResolvedValue(null);\n const resourceSource = createMockResourceSource(mockGetResource);\n\n const result = await resolveResourceContents(\n [\"registry:file:///doc.txt\"],\n [], // Registry resources don't need a server\n resourceSource,\n );\n\n expect(mockGetResource).toHaveBeenCalled();\n expect(result.size).toBe(0);\n });\n\n it(\"should handle null content from readResource\", async () => {\n const mockReadResource = jest.fn().mockResolvedValue(null);\n const mcpServer = createMockConnectedServer(\"linear\", mockReadResource);\n\n const result = await resolveResourceContents(\n [\"linear:file:///doc.txt\"],\n [mcpServer],\n undefined,\n );\n\n expect(mockReadResource).toHaveBeenCalled();\n expect(result.size).toBe(0);\n });\n});\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tambo-ai/react",
3
- "version": "0.67.1",
3
+ "version": "0.68.0",
4
4
  "description": "React client package for Tambo AI",
5
5
  "license": "MIT",
6
6
  "repository": {