@tambo-ai/react 0.47.0 → 0.49.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 (113) hide show
  1. package/dist/context-helpers/current-interactables-context-helper.d.ts +28 -0
  2. package/dist/context-helpers/current-interactables-context-helper.d.ts.map +1 -0
  3. package/dist/context-helpers/current-interactables-context-helper.js +61 -0
  4. package/dist/context-helpers/current-interactables-context-helper.js.map +1 -0
  5. package/dist/context-helpers/index.d.ts +1 -0
  6. package/dist/context-helpers/index.d.ts.map +1 -1
  7. package/dist/context-helpers/index.js +1 -0
  8. package/dist/context-helpers/index.js.map +1 -1
  9. package/dist/index.d.ts +1 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +2 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/mcp/__tests__/tambo-mcp-provider.test.d.ts +2 -0
  14. package/dist/mcp/__tests__/tambo-mcp-provider.test.d.ts.map +1 -0
  15. package/dist/mcp/__tests__/tambo-mcp-provider.test.js +115 -0
  16. package/dist/mcp/__tests__/tambo-mcp-provider.test.js.map +1 -0
  17. package/dist/mcp/tambo-mcp-provider.d.ts +6 -0
  18. package/dist/mcp/tambo-mcp-provider.d.ts.map +1 -1
  19. package/dist/mcp/tambo-mcp-provider.js +25 -2
  20. package/dist/mcp/tambo-mcp-provider.js.map +1 -1
  21. package/dist/providers/__tests__/tambo-interactables-additional-context-edge-cases.test.d.ts +2 -0
  22. package/dist/providers/__tests__/tambo-interactables-additional-context-edge-cases.test.d.ts.map +1 -0
  23. package/dist/providers/__tests__/tambo-interactables-additional-context-edge-cases.test.js +339 -0
  24. package/dist/providers/__tests__/tambo-interactables-additional-context-edge-cases.test.js.map +1 -0
  25. package/dist/providers/__tests__/tambo-interactables-additional-context.test.d.ts +2 -0
  26. package/dist/providers/__tests__/tambo-interactables-additional-context.test.d.ts.map +1 -0
  27. package/dist/providers/__tests__/tambo-interactables-additional-context.test.js +299 -0
  28. package/dist/providers/__tests__/tambo-interactables-additional-context.test.js.map +1 -0
  29. package/dist/providers/__tests__/tambo-registry-provider.test.d.ts +2 -0
  30. package/dist/providers/__tests__/tambo-registry-provider.test.d.ts.map +1 -0
  31. package/dist/providers/__tests__/tambo-registry-provider.test.js +224 -0
  32. package/dist/providers/__tests__/tambo-registry-provider.test.js.map +1 -0
  33. package/dist/providers/__tests__/tambo-thread-provider.test.js +99 -0
  34. package/dist/providers/__tests__/tambo-thread-provider.test.js.map +1 -1
  35. package/dist/providers/tambo-interactable-provider.d.ts +20 -0
  36. package/dist/providers/tambo-interactable-provider.d.ts.map +1 -1
  37. package/dist/providers/tambo-interactable-provider.js +32 -2
  38. package/dist/providers/tambo-interactable-provider.js.map +1 -1
  39. package/dist/providers/tambo-provider.d.ts.map +1 -1
  40. package/dist/providers/tambo-provider.js +2 -2
  41. package/dist/providers/tambo-provider.js.map +1 -1
  42. package/dist/providers/tambo-registry-provider.d.ts +12 -0
  43. package/dist/providers/tambo-registry-provider.d.ts.map +1 -1
  44. package/dist/providers/tambo-registry-provider.js +3 -1
  45. package/dist/providers/tambo-registry-provider.js.map +1 -1
  46. package/dist/providers/tambo-thread-provider.d.ts.map +1 -1
  47. package/dist/providers/tambo-thread-provider.js +5 -3
  48. package/dist/providers/tambo-thread-provider.js.map +1 -1
  49. package/dist/util/tool-caller.d.ts +1 -1
  50. package/dist/util/tool-caller.d.ts.map +1 -1
  51. package/dist/util/tool-caller.js +11 -2
  52. package/dist/util/tool-caller.js.map +1 -1
  53. package/esm/context-helpers/current-interactables-context-helper.d.ts +28 -0
  54. package/esm/context-helpers/current-interactables-context-helper.d.ts.map +1 -0
  55. package/esm/context-helpers/current-interactables-context-helper.js +56 -0
  56. package/esm/context-helpers/current-interactables-context-helper.js.map +1 -0
  57. package/esm/context-helpers/index.d.ts +1 -0
  58. package/esm/context-helpers/index.d.ts.map +1 -1
  59. package/esm/context-helpers/index.js +1 -0
  60. package/esm/context-helpers/index.js.map +1 -1
  61. package/esm/index.d.ts +1 -1
  62. package/esm/index.d.ts.map +1 -1
  63. package/esm/index.js +1 -1
  64. package/esm/index.js.map +1 -1
  65. package/esm/mcp/__tests__/tambo-mcp-provider.test.d.ts +2 -0
  66. package/esm/mcp/__tests__/tambo-mcp-provider.test.d.ts.map +1 -0
  67. package/esm/mcp/__tests__/tambo-mcp-provider.test.js +113 -0
  68. package/esm/mcp/__tests__/tambo-mcp-provider.test.js.map +1 -0
  69. package/esm/mcp/tambo-mcp-provider.d.ts +6 -0
  70. package/esm/mcp/tambo-mcp-provider.d.ts.map +1 -1
  71. package/esm/mcp/tambo-mcp-provider.js +24 -2
  72. package/esm/mcp/tambo-mcp-provider.js.map +1 -1
  73. package/esm/providers/__tests__/tambo-interactables-additional-context-edge-cases.test.d.ts +2 -0
  74. package/esm/providers/__tests__/tambo-interactables-additional-context-edge-cases.test.d.ts.map +1 -0
  75. package/esm/providers/__tests__/tambo-interactables-additional-context-edge-cases.test.js +334 -0
  76. package/esm/providers/__tests__/tambo-interactables-additional-context-edge-cases.test.js.map +1 -0
  77. package/esm/providers/__tests__/tambo-interactables-additional-context.test.d.ts +2 -0
  78. package/esm/providers/__tests__/tambo-interactables-additional-context.test.d.ts.map +1 -0
  79. package/esm/providers/__tests__/tambo-interactables-additional-context.test.js +294 -0
  80. package/esm/providers/__tests__/tambo-interactables-additional-context.test.js.map +1 -0
  81. package/esm/providers/__tests__/tambo-registry-provider.test.d.ts +2 -0
  82. package/esm/providers/__tests__/tambo-registry-provider.test.d.ts.map +1 -0
  83. package/esm/providers/__tests__/tambo-registry-provider.test.js +219 -0
  84. package/esm/providers/__tests__/tambo-registry-provider.test.js.map +1 -0
  85. package/esm/providers/__tests__/tambo-thread-provider.test.js +99 -0
  86. package/esm/providers/__tests__/tambo-thread-provider.test.js.map +1 -1
  87. package/esm/providers/tambo-interactable-provider.d.ts +20 -0
  88. package/esm/providers/tambo-interactable-provider.d.ts.map +1 -1
  89. package/esm/providers/tambo-interactable-provider.js +30 -1
  90. package/esm/providers/tambo-interactable-provider.js.map +1 -1
  91. package/esm/providers/tambo-provider.d.ts.map +1 -1
  92. package/esm/providers/tambo-provider.js +2 -2
  93. package/esm/providers/tambo-provider.js.map +1 -1
  94. package/esm/providers/tambo-registry-provider.d.ts +12 -0
  95. package/esm/providers/tambo-registry-provider.d.ts.map +1 -1
  96. package/esm/providers/tambo-registry-provider.js +3 -1
  97. package/esm/providers/tambo-registry-provider.js.map +1 -1
  98. package/esm/providers/tambo-thread-provider.d.ts.map +1 -1
  99. package/esm/providers/tambo-thread-provider.js +5 -3
  100. package/esm/providers/tambo-thread-provider.js.map +1 -1
  101. package/esm/util/tool-caller.d.ts +1 -1
  102. package/esm/util/tool-caller.d.ts.map +1 -1
  103. package/esm/util/tool-caller.js +11 -2
  104. package/esm/util/tool-caller.js.map +1 -1
  105. package/package.json +9 -9
  106. package/dist/mcp/mcp-tools-client.d.ts +0 -96
  107. package/dist/mcp/mcp-tools-client.d.ts.map +0 -1
  108. package/dist/mcp/mcp-tools-client.js +0 -178
  109. package/dist/mcp/mcp-tools-client.js.map +0 -1
  110. package/esm/mcp/mcp-tools-client.d.ts +0 -96
  111. package/esm/mcp/mcp-tools-client.d.ts.map +0 -1
  112. package/esm/mcp/mcp-tools-client.js +0 -174
  113. package/esm/mcp/mcp-tools-client.js.map +0 -1
@@ -0,0 +1,294 @@
1
+ import { render, waitFor } from "@testing-library/react";
2
+ import React from "react";
3
+ import { z } from "zod";
4
+ import { useTamboContextHelpers, TamboContextHelpersProvider, } from "../tambo-context-helpers-provider";
5
+ import { TamboInteractableProvider, useCurrentInteractablesSnapshot, } from "../tambo-interactable-provider";
6
+ import { TamboStubProvider } from "../tambo-stubs";
7
+ import { withTamboInteractable } from "../hoc/with-tambo-interactable";
8
+ function wrapperWithProviders(children) {
9
+ const thread = {
10
+ id: "t-1",
11
+ projectId: "p-1",
12
+ createdAt: new Date().toISOString(),
13
+ updatedAt: new Date().toISOString(),
14
+ messages: [],
15
+ metadata: {},
16
+ };
17
+ return (React.createElement(TamboStubProvider, { thread: thread, registerTool: () => { }, registerTools: () => { }, registerComponent: () => { }, addToolAssociation: () => { } },
18
+ React.createElement(TamboContextHelpersProvider, null, children)));
19
+ }
20
+ describe("Interactables AdditionalContext (provider-based)", () => {
21
+ test("registers default helper and returns payload with description and components", async () => {
22
+ const Note = ({ title }) => React.createElement("div", null, title);
23
+ const InteractableNote = withTamboInteractable(Note, {
24
+ componentName: "Note",
25
+ description: "A note",
26
+ propsSchema: z.object({ title: z.string() }),
27
+ });
28
+ let capturedContexts = [];
29
+ const TestComponent = () => {
30
+ const { getAdditionalContext } = useTamboContextHelpers();
31
+ React.useEffect(() => {
32
+ let mounted = true;
33
+ getAdditionalContext().then((contexts) => {
34
+ if (mounted) {
35
+ capturedContexts = contexts;
36
+ }
37
+ });
38
+ return () => {
39
+ mounted = false;
40
+ };
41
+ }, [getAdditionalContext]);
42
+ return React.createElement("div", { "data-testid": "ready" }, "ready");
43
+ };
44
+ const { getByTestId } = render(wrapperWithProviders(React.createElement(TamboInteractableProvider, null,
45
+ React.createElement(InteractableNote, { title: "hello" }),
46
+ React.createElement(TestComponent, null))));
47
+ await waitFor(() => {
48
+ expect(getByTestId("ready")).toBeInTheDocument();
49
+ const entry = capturedContexts.find((c) => c.name === "interactables");
50
+ expect(entry).toBeDefined();
51
+ expect(entry?.context?.description).toMatch(/interactable components/i);
52
+ expect(Array.isArray(entry?.context?.components)).toBe(true);
53
+ const comp = entry.context.components[0];
54
+ expect(comp.componentName).toBe("Note");
55
+ expect(comp.props).toEqual({ title: "hello" });
56
+ });
57
+ });
58
+ test("returns null when no interactable components are present", async () => {
59
+ let capturedContexts = [];
60
+ const TestComponent = () => {
61
+ const { getAdditionalContext } = useTamboContextHelpers();
62
+ React.useEffect(() => {
63
+ let mounted = true;
64
+ getAdditionalContext().then((contexts) => {
65
+ if (mounted) {
66
+ capturedContexts = contexts;
67
+ }
68
+ });
69
+ return () => {
70
+ mounted = false;
71
+ };
72
+ }, [getAdditionalContext]);
73
+ return React.createElement("div", { "data-testid": "ready" }, "ready");
74
+ };
75
+ const { getByTestId } = render(wrapperWithProviders(React.createElement(TamboInteractableProvider, null,
76
+ React.createElement("div", null, "No interactables here"),
77
+ React.createElement(TestComponent, null))));
78
+ await waitFor(() => {
79
+ expect(getByTestId("ready")).toBeInTheDocument();
80
+ const entry = capturedContexts.find((c) => c.name === "interactables");
81
+ expect(entry).toBeUndefined(); // Should be filtered out when helper returns null
82
+ });
83
+ });
84
+ test("context includes proper AI prompt with clear instructions", async () => {
85
+ const Note = ({ title }) => React.createElement("div", null, title);
86
+ const InteractableNote = withTamboInteractable(Note, {
87
+ componentName: "Note",
88
+ description: "A simple note",
89
+ propsSchema: z.object({ title: z.string() }),
90
+ });
91
+ let capturedContexts = [];
92
+ const TestComponent = () => {
93
+ const { getAdditionalContext } = useTamboContextHelpers();
94
+ React.useEffect(() => {
95
+ let mounted = true;
96
+ getAdditionalContext().then((contexts) => {
97
+ if (mounted) {
98
+ capturedContexts = contexts;
99
+ }
100
+ });
101
+ return () => {
102
+ mounted = false;
103
+ };
104
+ }, [getAdditionalContext]);
105
+ return React.createElement("div", { "data-testid": "ready" }, "ready");
106
+ };
107
+ const { getByTestId } = render(wrapperWithProviders(React.createElement(TamboInteractableProvider, null,
108
+ React.createElement(InteractableNote, { title: "test" }),
109
+ React.createElement(TestComponent, null))));
110
+ await waitFor(() => {
111
+ expect(getByTestId("ready")).toBeInTheDocument();
112
+ const entry = capturedContexts.find((c) => c.name === "interactables");
113
+ expect(entry?.context?.description).toContain("interactable components");
114
+ expect(entry?.context?.description).toContain("visible on the page");
115
+ expect(entry?.context?.description).toContain("you can read and modify");
116
+ expect(entry?.context?.description).toContain("tools to update");
117
+ });
118
+ });
119
+ test("includes component metadata in expected format", async () => {
120
+ const Note = ({ title, color = "white", }) => React.createElement("div", { className: `note-${color}` }, title);
121
+ const InteractableNote = withTamboInteractable(Note, {
122
+ componentName: "Note",
123
+ description: "A colorful note component",
124
+ propsSchema: z.object({
125
+ title: z.string(),
126
+ color: z.string().optional(),
127
+ }),
128
+ });
129
+ let capturedContexts = [];
130
+ const TestComponent = () => {
131
+ const { getAdditionalContext } = useTamboContextHelpers();
132
+ React.useEffect(() => {
133
+ let mounted = true;
134
+ getAdditionalContext().then((contexts) => {
135
+ if (mounted) {
136
+ capturedContexts = contexts;
137
+ }
138
+ });
139
+ return () => {
140
+ mounted = false;
141
+ };
142
+ }, [getAdditionalContext]);
143
+ return React.createElement("div", { "data-testid": "ready" }, "ready");
144
+ };
145
+ const { getByTestId } = render(wrapperWithProviders(React.createElement(TamboInteractableProvider, null,
146
+ React.createElement(InteractableNote, { title: "test note", color: "blue" }),
147
+ React.createElement(TestComponent, null))));
148
+ await waitFor(() => {
149
+ expect(getByTestId("ready")).toBeInTheDocument();
150
+ const entry = capturedContexts.find((c) => c.name === "interactables");
151
+ const component = entry.context.components[0];
152
+ expect(component).toMatchObject({
153
+ id: expect.any(String),
154
+ componentName: "Note",
155
+ description: "A colorful note component",
156
+ props: { title: "test note", color: "blue" },
157
+ propsSchema: "Available - use component-specific update tools",
158
+ });
159
+ });
160
+ });
161
+ test("snapshot hook returns immutable copies", async () => {
162
+ const Note = ({ title }) => React.createElement("div", null, title);
163
+ const InteractableNote = withTamboInteractable(Note, {
164
+ componentName: "Note",
165
+ description: "A note",
166
+ propsSchema: z.object({ title: z.string() }),
167
+ });
168
+ const TestComponent = () => {
169
+ const snapshot = useCurrentInteractablesSnapshot();
170
+ const [testResult, setTestResult] = React.useState("pending");
171
+ React.useEffect(() => {
172
+ if (snapshot.length > 0) {
173
+ const originalLength = snapshot.length;
174
+ // Try to mutate the returned array and props
175
+ snapshot.push({
176
+ id: "fake",
177
+ name: "Fake",
178
+ description: "",
179
+ component: () => null,
180
+ props: {},
181
+ });
182
+ snapshot[0].props.title = "MUTATED";
183
+ // The mutations should succeed on the returned copy, proving it's a separate object
184
+ if (snapshot.length === originalLength + 1 &&
185
+ snapshot[0].props.title === "MUTATED") {
186
+ setTestResult("mutation-successful-but-isolated");
187
+ }
188
+ else {
189
+ setTestResult("mutation-failed");
190
+ }
191
+ }
192
+ }, [snapshot]);
193
+ return React.createElement("div", { "data-testid": "test-result" }, testResult);
194
+ };
195
+ const { getByTestId } = render(wrapperWithProviders(React.createElement(TamboInteractableProvider, null,
196
+ React.createElement(InteractableNote, { title: "immutable test" }),
197
+ React.createElement(TestComponent, null))));
198
+ await waitFor(() => {
199
+ const result = getByTestId("test-result").textContent;
200
+ expect(result).toBe("mutation-successful-but-isolated");
201
+ });
202
+ });
203
+ test("multiple interactables from same provider appear in context", async () => {
204
+ const Note = ({ title }) => React.createElement("div", null, title);
205
+ const Counter = ({ count }) => (React.createElement("div", null, count));
206
+ const InteractableNote = withTamboInteractable(Note, {
207
+ componentName: "Note",
208
+ description: "A note",
209
+ propsSchema: z.object({ title: z.string() }),
210
+ });
211
+ const InteractableCounter = withTamboInteractable(Counter, {
212
+ componentName: "Counter",
213
+ description: "A counter",
214
+ propsSchema: z.object({ count: z.number() }),
215
+ });
216
+ let capturedContexts = [];
217
+ const TestComponent = () => {
218
+ const { getAdditionalContext } = useTamboContextHelpers();
219
+ React.useEffect(() => {
220
+ let mounted = true;
221
+ getAdditionalContext().then((contexts) => {
222
+ if (mounted) {
223
+ capturedContexts = contexts;
224
+ }
225
+ });
226
+ return () => {
227
+ mounted = false;
228
+ };
229
+ }, [getAdditionalContext]);
230
+ return React.createElement("div", { "data-testid": "ready" }, "ready");
231
+ };
232
+ const { getByTestId } = render(wrapperWithProviders(React.createElement(TamboInteractableProvider, null,
233
+ React.createElement(InteractableNote, { title: "first" }),
234
+ React.createElement(InteractableCounter, { count: 42 }),
235
+ React.createElement(TestComponent, null))));
236
+ await waitFor(() => {
237
+ expect(getByTestId("ready")).toBeInTheDocument();
238
+ const entry = capturedContexts.find((c) => c.name === "interactables");
239
+ expect(entry?.context?.components).toHaveLength(2);
240
+ const components = entry.context.components;
241
+ expect(components[0].componentName).toBe("Note");
242
+ expect(components[0].props).toEqual({ title: "first" });
243
+ expect(components[1].componentName).toBe("Counter");
244
+ expect(components[1].props).toEqual({ count: 42 });
245
+ });
246
+ });
247
+ test("can be disabled by returning null", async () => {
248
+ const Note = ({ title }) => React.createElement("div", null, title);
249
+ const InteractableNote = withTamboInteractable(Note, {
250
+ componentName: "Note",
251
+ description: "A note",
252
+ propsSchema: z.object({ title: z.string() }),
253
+ });
254
+ // Create a context helpers provider with a disabled interactables helper
255
+ const DisabledContextHelpers = ({ children, }) => (React.createElement(TamboContextHelpersProvider, { contextHelpers: {
256
+ ["interactables"]: () => null,
257
+ } }, children));
258
+ let capturedContexts = [];
259
+ const TestComponent = () => {
260
+ const { getAdditionalContext } = useTamboContextHelpers();
261
+ React.useEffect(() => {
262
+ let mounted = true;
263
+ getAdditionalContext().then((contexts) => {
264
+ if (mounted) {
265
+ capturedContexts = contexts;
266
+ }
267
+ });
268
+ return () => {
269
+ mounted = false;
270
+ };
271
+ }, [getAdditionalContext]);
272
+ return React.createElement("div", { "data-testid": "ready" }, "ready");
273
+ };
274
+ const thread = {
275
+ id: "t-1",
276
+ projectId: "p-1",
277
+ createdAt: new Date().toISOString(),
278
+ updatedAt: new Date().toISOString(),
279
+ messages: [],
280
+ metadata: {},
281
+ };
282
+ const { getByTestId } = render(React.createElement(TamboStubProvider, { thread: thread, registerTool: () => { }, registerTools: () => { }, registerComponent: () => { }, addToolAssociation: () => { } },
283
+ React.createElement(DisabledContextHelpers, null,
284
+ React.createElement(TamboInteractableProvider, null,
285
+ React.createElement(InteractableNote, { title: "should not appear" }),
286
+ React.createElement(TestComponent, null)))));
287
+ await waitFor(() => {
288
+ expect(getByTestId("ready")).toBeInTheDocument();
289
+ const entry = capturedContexts.find((c) => c.name === "interactables");
290
+ expect(entry).toBeUndefined(); // Should be filtered out when helper returns null
291
+ });
292
+ });
293
+ });
294
+ //# sourceMappingURL=tambo-interactables-additional-context.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tambo-interactables-additional-context.test.js","sourceRoot":"","sources":["../../../src/providers/__tests__/tambo-interactables-additional-context.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,sBAAsB,EACtB,2BAA2B,GAC5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,yBAAyB,EACzB,+BAA+B,GAChC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAEvE,SAAS,oBAAoB,CAAC,QAAyB;IACrD,MAAM,MAAM,GAAG;QACb,EAAE,EAAE,KAAK;QACT,SAAS,EAAE,KAAK;QAChB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,QAAQ,EAAE,EAAE;QACZ,QAAQ,EAAE,EAAE;KACN,CAAC;IAET,OAAO,CACL,oBAAC,iBAAiB,IAChB,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,GAAG,EAAE,GAAE,CAAC,EACtB,aAAa,EAAE,GAAG,EAAE,GAAE,CAAC,EACvB,iBAAiB,EAAE,GAAG,EAAE,GAAE,CAAC,EAC3B,kBAAkB,EAAE,GAAG,EAAE,GAAE,CAAC;QAE5B,oBAAC,2BAA2B,QAAE,QAAQ,CAA+B,CACnD,CACrB,CAAC;AACJ,CAAC;AAED,QAAQ,CAAC,kDAAkD,EAAE,GAAG,EAAE;IAChE,IAAI,CAAC,8EAA8E,EAAE,KAAK,IAAI,EAAE;QAC9F,MAAM,IAAI,GAAgC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,iCAAM,K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E5B,oBAAC,sBAAsB;gBACrB,oBAAC,yBAAyB;oBACxB,oBAAC,gBAAgB,IAAC,KAAK,EAAC,mBAAmB,GAAG;oBAC9C,oBAAC,aAAa,OAAG,CACS,CACL,CACP,CACrB,CAAC;QAEF,MAAM,OAAO,CAAC,GAAG,EAAE;YACjB,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;YACjD,MAAM,KAAK,GAAG,gBAAgB,CAAC,IAAI,CACjC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,eAAe,CACvC,CAAC;YACF,MAAM,CAAC,KAAK,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC,kDAAkD;QACnF,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { render, waitFor } from \"@testing-library/react\";\nimport React from \"react\";\nimport { z } from \"zod\";\nimport {\n useTamboContextHelpers,\n TamboContextHelpersProvider,\n} from \"../tambo-context-helpers-provider\";\nimport {\n TamboInteractableProvider,\n useCurrentInteractablesSnapshot,\n} from \"../tambo-interactable-provider\";\nimport { TamboStubProvider } from \"../tambo-stubs\";\nimport { withTamboInteractable } from \"../hoc/with-tambo-interactable\";\n\nfunction wrapperWithProviders(children: React.ReactNode) {\n const thread = {\n id: \"t-1\",\n projectId: \"p-1\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n messages: [],\n metadata: {},\n } as any;\n\n return (\n <TamboStubProvider\n thread={thread}\n registerTool={() => {}}\n registerTools={() => {}}\n registerComponent={() => {}}\n addToolAssociation={() => {}}\n >\n <TamboContextHelpersProvider>{children}</TamboContextHelpersProvider>\n </TamboStubProvider>\n );\n}\n\ndescribe(\"Interactables AdditionalContext (provider-based)\", () => {\n test(\"registers default helper and returns payload with description and components\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableNote title=\"hello\" />\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry).toBeDefined();\n expect(entry?.context?.description).toMatch(/interactable components/i);\n expect(Array.isArray(entry?.context?.components)).toBe(true);\n const comp = entry!.context.components[0];\n expect(comp.componentName).toBe(\"Note\");\n expect(comp.props).toEqual({ title: \"hello\" });\n });\n });\n\n test(\"returns null when no interactable components are present\", async () => {\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <div>No interactables here</div>\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry).toBeUndefined(); // Should be filtered out when helper returns null\n });\n });\n\n test(\"context includes proper AI prompt with clear instructions\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A simple note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableNote title=\"test\" />\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry?.context?.description).toContain(\"interactable components\");\n expect(entry?.context?.description).toContain(\"visible on the page\");\n expect(entry?.context?.description).toContain(\"you can read and modify\");\n expect(entry?.context?.description).toContain(\"tools to update\");\n });\n });\n\n test(\"includes component metadata in expected format\", async () => {\n const Note: React.FC<{ title: string; color?: string }> = ({\n title,\n color = \"white\",\n }) => <div className={`note-${color}`}>{title}</div>;\n\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A colorful note component\",\n propsSchema: z.object({\n title: z.string(),\n color: z.string().optional(),\n }),\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableNote title=\"test note\" color=\"blue\" />\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n const component = entry!.context.components[0];\n\n expect(component).toMatchObject({\n id: expect.any(String),\n componentName: \"Note\",\n description: \"A colorful note component\",\n props: { title: \"test note\", color: \"blue\" },\n propsSchema: \"Available - use component-specific update tools\",\n });\n });\n });\n\n test(\"snapshot hook returns immutable copies\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n const TestComponent = () => {\n const snapshot = useCurrentInteractablesSnapshot();\n const [testResult, setTestResult] = React.useState<string>(\"pending\");\n\n React.useEffect(() => {\n if (snapshot.length > 0) {\n const originalLength = snapshot.length;\n\n // Try to mutate the returned array and props\n snapshot.push({\n id: \"fake\",\n name: \"Fake\",\n description: \"\",\n component: () => null,\n props: {},\n } as any);\n (snapshot[0].props as any).title = \"MUTATED\";\n\n // The mutations should succeed on the returned copy, proving it's a separate object\n if (\n snapshot.length === originalLength + 1 &&\n snapshot[0].props.title === \"MUTATED\"\n ) {\n setTestResult(\"mutation-successful-but-isolated\");\n } else {\n setTestResult(\"mutation-failed\");\n }\n }\n }, [snapshot]);\n\n return <div data-testid=\"test-result\">{testResult}</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableNote title=\"immutable test\" />\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n const result = getByTestId(\"test-result\").textContent;\n expect(result).toBe(\"mutation-successful-but-isolated\");\n });\n });\n\n test(\"multiple interactables from same provider appear in context\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const Counter: React.FC<{ count: number }> = ({ count }) => (\n <div>{count}</div>\n );\n\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n const InteractableCounter = withTamboInteractable(Counter, {\n componentName: \"Counter\",\n description: \"A counter\",\n propsSchema: z.object({ count: z.number() }),\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableNote title=\"first\" />\n <InteractableCounter count={42} />\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry?.context?.components).toHaveLength(2);\n\n const components = entry!.context.components;\n expect(components[0].componentName).toBe(\"Note\");\n expect(components[0].props).toEqual({ title: \"first\" });\n expect(components[1].componentName).toBe(\"Counter\");\n expect(components[1].props).toEqual({ count: 42 });\n });\n });\n\n test(\"can be disabled by returning null\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n // Create a context helpers provider with a disabled interactables helper\n const DisabledContextHelpers = ({\n children,\n }: {\n children: React.ReactNode;\n }) => (\n <TamboContextHelpersProvider\n contextHelpers={{\n [\"interactables\"]: () => null,\n }}\n >\n {children}\n </TamboContextHelpersProvider>\n );\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const thread = {\n id: \"t-1\",\n projectId: \"p-1\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n messages: [],\n metadata: {},\n } as any;\n\n const { getByTestId } = render(\n <TamboStubProvider\n thread={thread}\n registerTool={() => {}}\n registerTools={() => {}}\n registerComponent={() => {}}\n addToolAssociation={() => {}}\n >\n <DisabledContextHelpers>\n <TamboInteractableProvider>\n <InteractableNote title=\"should not appear\" />\n <TestComponent />\n </TamboInteractableProvider>\n </DisabledContextHelpers>\n </TamboStubProvider>,\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry).toBeUndefined(); // Should be filtered out when helper returns null\n });\n });\n});\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=tambo-registry-provider.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tambo-registry-provider.test.d.ts","sourceRoot":"","sources":["../../../src/providers/__tests__/tambo-registry-provider.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,219 @@
1
+ import { act, renderHook } from "@testing-library/react";
2
+ import React from "react";
3
+ import { z } from "zod";
4
+ import { TamboRegistryProvider, useTamboRegistry, } from "../tambo-registry-provider";
5
+ // Shared tool registry for all tests
6
+ const createMockTools = () => [
7
+ {
8
+ name: "test-tool-1",
9
+ description: "First test tool",
10
+ tool: jest.fn().mockResolvedValue("test-tool-1-result"),
11
+ toolSchema: z
12
+ .function()
13
+ .args(z.string().describe("input parameter"))
14
+ .returns(z.string()),
15
+ },
16
+ {
17
+ name: "test-tool-2",
18
+ description: "Second test tool",
19
+ tool: jest.fn().mockResolvedValue("test-tool-2-result"),
20
+ toolSchema: z
21
+ .function()
22
+ .args(z.number().describe("number parameter"))
23
+ .returns(z.string()),
24
+ },
25
+ ];
26
+ const createMockComponents = (tools) => [
27
+ {
28
+ name: "TestComponent",
29
+ component: () => React.createElement("div", null, "TestComponent"),
30
+ description: "Test component",
31
+ propsSchema: z.object({
32
+ test: z.string(),
33
+ }),
34
+ associatedTools: tools,
35
+ },
36
+ ];
37
+ describe("TamboRegistryProvider", () => {
38
+ const mockTools = createMockTools();
39
+ const mockComponents = createMockComponents(mockTools);
40
+ beforeEach(() => {
41
+ jest.clearAllMocks();
42
+ });
43
+ describe("Component and tool registration", () => {
44
+ it("should register components and tools correctly", () => {
45
+ const wrapper = ({ children }) => (React.createElement(TamboRegistryProvider, { components: mockComponents }, children));
46
+ const { result } = renderHook(() => useTamboRegistry(), { wrapper });
47
+ expect(result.current.componentList).toHaveProperty("TestComponent");
48
+ expect(result.current.toolRegistry).toHaveProperty("test-tool-1");
49
+ expect(result.current.toolRegistry).toHaveProperty("test-tool-2");
50
+ expect(result.current.componentToolAssociations).toHaveProperty("TestComponent");
51
+ expect(result.current.componentToolAssociations.TestComponent).toEqual([
52
+ "test-tool-1",
53
+ "test-tool-2",
54
+ ]);
55
+ });
56
+ it("should provide onCallUnregisteredTool in context", () => {
57
+ const mockonCallUnregisteredTool = jest
58
+ .fn()
59
+ .mockResolvedValue("test-result");
60
+ const wrapper = ({ children }) => (React.createElement(TamboRegistryProvider, { components: mockComponents, onCallUnregisteredTool: mockonCallUnregisteredTool }, children));
61
+ const { result } = renderHook(() => useTamboRegistry(), { wrapper });
62
+ // The onCallUnregisteredTool should be available in the context
63
+ expect(result.current.onCallUnregisteredTool).toBeDefined();
64
+ expect(typeof result.current.onCallUnregisteredTool).toBe("function");
65
+ });
66
+ it("should handle tool registration and association", () => {
67
+ const wrapper = ({ children }) => (React.createElement(TamboRegistryProvider, null, children));
68
+ const { result } = renderHook(() => useTamboRegistry(), { wrapper });
69
+ // Register a new tool
70
+ act(() => {
71
+ result.current.registerTool(mockTools[0]);
72
+ });
73
+ expect(result.current.toolRegistry).toHaveProperty("test-tool-1");
74
+ // Register a new component
75
+ act(() => {
76
+ result.current.registerComponent(mockComponents[0]);
77
+ });
78
+ expect(result.current.componentList).toHaveProperty("TestComponent");
79
+ expect(result.current.componentToolAssociations).toHaveProperty("TestComponent");
80
+ });
81
+ it("should handle multiple tool registration", () => {
82
+ const wrapper = ({ children }) => (React.createElement(TamboRegistryProvider, null, children));
83
+ const { result } = renderHook(() => useTamboRegistry(), { wrapper });
84
+ // Register multiple tools
85
+ act(() => {
86
+ result.current.registerTools(mockTools);
87
+ });
88
+ expect(result.current.toolRegistry).toHaveProperty("test-tool-1");
89
+ expect(result.current.toolRegistry).toHaveProperty("test-tool-2");
90
+ expect(Object.keys(result.current.toolRegistry)).toHaveLength(2);
91
+ });
92
+ it("should handle tool association with components", () => {
93
+ const wrapper = ({ children }) => (React.createElement(TamboRegistryProvider, { components: mockComponents }, children));
94
+ const { result } = renderHook(() => useTamboRegistry(), { wrapper });
95
+ // Add a new tool association
96
+ act(() => {
97
+ const newTool = {
98
+ name: "new-tool",
99
+ description: "New tool",
100
+ tool: jest.fn().mockResolvedValue("new-tool-result"),
101
+ toolSchema: z
102
+ .function()
103
+ .args(z.string().describe("input"))
104
+ .returns(z.string()),
105
+ };
106
+ result.current.addToolAssociation("TestComponent", newTool);
107
+ });
108
+ expect(result.current.componentToolAssociations.TestComponent).toContain("new-tool");
109
+ });
110
+ it("should throw error when adding tool association to non-existent component", () => {
111
+ const wrapper = ({ children }) => (React.createElement(TamboRegistryProvider, null, children));
112
+ const { result } = renderHook(() => useTamboRegistry(), { wrapper });
113
+ const newTool = {
114
+ name: "new-tool",
115
+ description: "New tool",
116
+ tool: jest.fn().mockResolvedValue("new-tool-result"),
117
+ toolSchema: z
118
+ .function()
119
+ .args(z.string().describe("input"))
120
+ .returns(z.string()),
121
+ };
122
+ expect(() => {
123
+ act(() => {
124
+ result.current.addToolAssociation("NonExistentComponent", newTool);
125
+ });
126
+ }).toThrow("Component NonExistentComponent not found in registry");
127
+ });
128
+ it("should validate tool schemas and throw error for invalid schemas", () => {
129
+ const wrapper = ({ children }) => (React.createElement(TamboRegistryProvider, null, children));
130
+ const { result } = renderHook(() => useTamboRegistry(), { wrapper });
131
+ const invalidTool = {
132
+ name: "invalid-tool",
133
+ description: "Invalid tool",
134
+ tool: jest.fn().mockResolvedValue("result"),
135
+ toolSchema: z.record(z.string()), // This should cause validation to fail
136
+ };
137
+ // This should throw during registration due to invalid schema
138
+ expect(() => {
139
+ act(() => {
140
+ result.current.registerTool(invalidTool);
141
+ });
142
+ }).toThrow('z.record() is not supported in toolSchema of tool "invalid-tool"');
143
+ });
144
+ it("should validate component schemas and throw error for invalid schemas", () => {
145
+ const invalidComponent = {
146
+ name: "InvalidComponent",
147
+ component: () => React.createElement("div", null, "Invalid"),
148
+ description: "Invalid component",
149
+ propsSchema: z.record(z.string()), // This should cause validation to fail
150
+ };
151
+ const wrapper = ({ children }) => (React.createElement(TamboRegistryProvider, null, children));
152
+ const { result } = renderHook(() => useTamboRegistry(), { wrapper });
153
+ // This should throw during registration due to invalid schema
154
+ expect(() => {
155
+ act(() => {
156
+ result.current.registerComponent(invalidComponent);
157
+ });
158
+ }).toThrow('z.record() is not supported in propsSchema of component "InvalidComponent"');
159
+ });
160
+ it("should throw error when component has both propsSchema and propsDefinition", () => {
161
+ const invalidComponent = {
162
+ name: "InvalidComponent",
163
+ component: () => React.createElement("div", null, "Invalid"),
164
+ description: "Invalid component",
165
+ propsSchema: z.object({ test: z.string() }),
166
+ propsDefinition: { test: "string" }, // Both defined - should throw
167
+ };
168
+ const wrapper = ({ children }) => (React.createElement(TamboRegistryProvider, null, children));
169
+ const { result } = renderHook(() => useTamboRegistry(), { wrapper });
170
+ expect(() => {
171
+ act(() => {
172
+ result.current.registerComponent(invalidComponent);
173
+ });
174
+ }).toThrow("Component InvalidComponent cannot have both propsSchema and propsDefinition defined");
175
+ });
176
+ it("should throw error when component has neither propsSchema nor propsDefinition", () => {
177
+ const invalidComponent = {
178
+ name: "InvalidComponent",
179
+ component: () => React.createElement("div", null, "Invalid"),
180
+ description: "Invalid component",
181
+ // Neither propsSchema nor propsDefinition defined - should throw
182
+ };
183
+ const wrapper = ({ children }) => (React.createElement(TamboRegistryProvider, null, children));
184
+ const { result } = renderHook(() => useTamboRegistry(), { wrapper });
185
+ expect(() => {
186
+ act(() => {
187
+ result.current.registerComponent(invalidComponent);
188
+ });
189
+ }).toThrow("Component InvalidComponent must have either propsSchema (recommended) or propsDefinition defined");
190
+ });
191
+ });
192
+ describe("Tool call handling", () => {
193
+ it("should provide onCallUnregisteredTool callback for handling unknown tools", async () => {
194
+ const mockonCallUnregisteredTool = jest
195
+ .fn()
196
+ .mockResolvedValue("unknown-tool-result");
197
+ const wrapper = ({ children }) => (React.createElement(TamboRegistryProvider, { components: mockComponents, onCallUnregisteredTool: mockonCallUnregisteredTool }, children));
198
+ const { result } = renderHook(() => useTamboRegistry(), { wrapper });
199
+ // Verify the callback is available
200
+ expect(result.current.onCallUnregisteredTool).toBeDefined();
201
+ expect(typeof result.current.onCallUnregisteredTool).toBe("function");
202
+ // Simulate calling the unknown tool handler
203
+ const toolName = "unknown-tool";
204
+ const args = [{ parameterName: "input", parameterValue: "test-input" }];
205
+ await act(async () => {
206
+ if (result.current.onCallUnregisteredTool) {
207
+ await result.current.onCallUnregisteredTool(toolName, args);
208
+ }
209
+ });
210
+ expect(mockonCallUnregisteredTool).toHaveBeenCalledWith(toolName, args);
211
+ });
212
+ it("should handle onCallUnregisteredTool being undefined", () => {
213
+ const wrapper = ({ children }) => (React.createElement(TamboRegistryProvider, { components: mockComponents }, children));
214
+ const { result } = renderHook(() => useTamboRegistry(), { wrapper });
215
+ expect(result.current.onCallUnregisteredTool).toBeUndefined();
216
+ });
217
+ });
218
+ });
219
+ //# sourceMappingURL=tambo-registry-provider.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tambo-registry-provider.test.js","sourceRoot":"","sources":["../../../src/providers/__tests__/tambo-registry-provider.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,MAAM,OA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C,MAAM,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC,WAAW,EAAE,CAAC;YAC5D,MAAM,CAAC,OAAO,MAAM,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAEtE,4CAA4C;YAC5C,MAAM,QAAQ,GAAG,cAAc,CAAC;YAChC,MAAM,IAAI,GAAG,CAAC,EAAE,aAAa,EAAE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,CAAC,CAAC;YAExE,MAAM,GAAG,CAAC,KAAK,IAAI,EAAE;gBACnB,IAAI,MAAM,CAAC,OAAO,CAAC,sBAAsB,EAAE,CAAC;oBAC1C,MAAM,MAAM,CAAC,OAAO,CAAC,sBAAsB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;gBAC9D,CAAC;YACH,CAAC,CAAC,CAAC;YAEH,MAAM,CAAC,0BAA0B,CAAC,CAAC,oBAAoB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAC1E,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,sDAAsD,EAAE,GAAG,EAAE;YAC9D,MAAM,OAAO,GAAG,CAAC,EAAE,QAAQ,EAAiC,EAAE,EAAE,CAAC,CAC/D,oBAAC,qBAAqB,IAAC,UAAU,EAAE,cAAc,IAC9C,QAAQ,CACa,CACzB,CAAC;YAEF,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,gBAAgB,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;YAErE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC,aAAa,EAAE,CAAC;QAChE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { act, renderHook } from \"@testing-library/react\";\nimport React from \"react\";\nimport { z } from \"zod\";\nimport { TamboComponent, TamboTool } from \"../../model/component-metadata\";\nimport {\n TamboRegistryProvider,\n useTamboRegistry,\n} from \"../tambo-registry-provider\";\n\n// Shared tool registry for all tests\nconst createMockTools = (): TamboTool[] => [\n {\n name: \"test-tool-1\",\n description: \"First test tool\",\n tool: jest.fn().mockResolvedValue(\"test-tool-1-result\"),\n toolSchema: z\n .function()\n .args(z.string().describe(\"input parameter\"))\n .returns(z.string()),\n },\n {\n name: \"test-tool-2\",\n description: \"Second test tool\",\n tool: jest.fn().mockResolvedValue(\"test-tool-2-result\"),\n toolSchema: z\n .function()\n .args(z.number().describe(\"number parameter\"))\n .returns(z.string()),\n },\n];\n\nconst createMockComponents = (tools: TamboTool[]): TamboComponent[] => [\n {\n name: \"TestComponent\",\n component: () => <div>TestComponent</div>,\n description: \"Test component\",\n propsSchema: z.object({\n test: z.string(),\n }),\n associatedTools: tools,\n },\n];\n\ndescribe(\"TamboRegistryProvider\", () => {\n const mockTools = createMockTools();\n const mockComponents = createMockComponents(mockTools);\n\n beforeEach(() => {\n jest.clearAllMocks();\n });\n\n describe(\"Component and tool registration\", () => {\n it(\"should register components and tools correctly\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider components={mockComponents}>\n {children}\n </TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n expect(result.current.componentList).toHaveProperty(\"TestComponent\");\n expect(result.current.toolRegistry).toHaveProperty(\"test-tool-1\");\n expect(result.current.toolRegistry).toHaveProperty(\"test-tool-2\");\n expect(result.current.componentToolAssociations).toHaveProperty(\n \"TestComponent\",\n );\n expect(result.current.componentToolAssociations.TestComponent).toEqual([\n \"test-tool-1\",\n \"test-tool-2\",\n ]);\n });\n\n it(\"should provide onCallUnregisteredTool in context\", () => {\n const mockonCallUnregisteredTool = jest\n .fn()\n .mockResolvedValue(\"test-result\");\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider\n components={mockComponents}\n onCallUnregisteredTool={mockonCallUnregisteredTool}\n >\n {children}\n </TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n // The onCallUnregisteredTool should be available in the context\n expect(result.current.onCallUnregisteredTool).toBeDefined();\n expect(typeof result.current.onCallUnregisteredTool).toBe(\"function\");\n });\n\n it(\"should handle tool registration and association\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider>{children}</TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n // Register a new tool\n act(() => {\n result.current.registerTool(mockTools[0]);\n });\n\n expect(result.current.toolRegistry).toHaveProperty(\"test-tool-1\");\n\n // Register a new component\n act(() => {\n result.current.registerComponent(mockComponents[0]);\n });\n\n expect(result.current.componentList).toHaveProperty(\"TestComponent\");\n expect(result.current.componentToolAssociations).toHaveProperty(\n \"TestComponent\",\n );\n });\n\n it(\"should handle multiple tool registration\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider>{children}</TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n // Register multiple tools\n act(() => {\n result.current.registerTools(mockTools);\n });\n\n expect(result.current.toolRegistry).toHaveProperty(\"test-tool-1\");\n expect(result.current.toolRegistry).toHaveProperty(\"test-tool-2\");\n expect(Object.keys(result.current.toolRegistry)).toHaveLength(2);\n });\n\n it(\"should handle tool association with components\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider components={mockComponents}>\n {children}\n </TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n // Add a new tool association\n act(() => {\n const newTool: TamboTool = {\n name: \"new-tool\",\n description: \"New tool\",\n tool: jest.fn().mockResolvedValue(\"new-tool-result\"),\n toolSchema: z\n .function()\n .args(z.string().describe(\"input\"))\n .returns(z.string()),\n };\n result.current.addToolAssociation(\"TestComponent\", newTool);\n });\n\n expect(result.current.componentToolAssociations.TestComponent).toContain(\n \"new-tool\",\n );\n });\n\n it(\"should throw error when adding tool association to non-existent component\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider>{children}</TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n const newTool: TamboTool = {\n name: \"new-tool\",\n description: \"New tool\",\n tool: jest.fn().mockResolvedValue(\"new-tool-result\"),\n toolSchema: z\n .function()\n .args(z.string().describe(\"input\"))\n .returns(z.string()),\n };\n\n expect(() => {\n act(() => {\n result.current.addToolAssociation(\"NonExistentComponent\", newTool);\n });\n }).toThrow(\"Component NonExistentComponent not found in registry\");\n });\n\n it(\"should validate tool schemas and throw error for invalid schemas\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider>{children}</TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n const invalidTool: TamboTool = {\n name: \"invalid-tool\",\n description: \"Invalid tool\",\n tool: jest.fn().mockResolvedValue(\"result\"),\n toolSchema: z.record(z.string()), // This should cause validation to fail\n };\n\n // This should throw during registration due to invalid schema\n expect(() => {\n act(() => {\n result.current.registerTool(invalidTool);\n });\n }).toThrow(\n 'z.record() is not supported in toolSchema of tool \"invalid-tool\"',\n );\n });\n\n it(\"should validate component schemas and throw error for invalid schemas\", () => {\n const invalidComponent: TamboComponent = {\n name: \"InvalidComponent\",\n component: () => <div>Invalid</div>,\n description: \"Invalid component\",\n propsSchema: z.record(z.string()), // This should cause validation to fail\n };\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider>{children}</TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n // This should throw during registration due to invalid schema\n expect(() => {\n act(() => {\n result.current.registerComponent(invalidComponent);\n });\n }).toThrow(\n 'z.record() is not supported in propsSchema of component \"InvalidComponent\"',\n );\n });\n\n it(\"should throw error when component has both propsSchema and propsDefinition\", () => {\n const invalidComponent: TamboComponent = {\n name: \"InvalidComponent\",\n component: () => <div>Invalid</div>,\n description: \"Invalid component\",\n propsSchema: z.object({ test: z.string() }),\n propsDefinition: { test: \"string\" }, // Both defined - should throw\n };\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider>{children}</TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n expect(() => {\n act(() => {\n result.current.registerComponent(invalidComponent);\n });\n }).toThrow(\n \"Component InvalidComponent cannot have both propsSchema and propsDefinition defined\",\n );\n });\n\n it(\"should throw error when component has neither propsSchema nor propsDefinition\", () => {\n const invalidComponent: TamboComponent = {\n name: \"InvalidComponent\",\n component: () => <div>Invalid</div>,\n description: \"Invalid component\",\n // Neither propsSchema nor propsDefinition defined - should throw\n };\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider>{children}</TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n expect(() => {\n act(() => {\n result.current.registerComponent(invalidComponent);\n });\n }).toThrow(\n \"Component InvalidComponent must have either propsSchema (recommended) or propsDefinition defined\",\n );\n });\n });\n\n describe(\"Tool call handling\", () => {\n it(\"should provide onCallUnregisteredTool callback for handling unknown tools\", async () => {\n const mockonCallUnregisteredTool = jest\n .fn()\n .mockResolvedValue(\"unknown-tool-result\");\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider\n components={mockComponents}\n onCallUnregisteredTool={mockonCallUnregisteredTool}\n >\n {children}\n </TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n // Verify the callback is available\n expect(result.current.onCallUnregisteredTool).toBeDefined();\n expect(typeof result.current.onCallUnregisteredTool).toBe(\"function\");\n\n // Simulate calling the unknown tool handler\n const toolName = \"unknown-tool\";\n const args = [{ parameterName: \"input\", parameterValue: \"test-input\" }];\n\n await act(async () => {\n if (result.current.onCallUnregisteredTool) {\n await result.current.onCallUnregisteredTool(toolName, args);\n }\n });\n\n expect(mockonCallUnregisteredTool).toHaveBeenCalledWith(toolName, args);\n });\n\n it(\"should handle onCallUnregisteredTool being undefined\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider components={mockComponents}>\n {children}\n </TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboRegistry(), { wrapper });\n\n expect(result.current.onCallUnregisteredTool).toBeUndefined();\n });\n });\n});\n"]}