@tambo-ai/react 0.47.0 → 0.48.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 (73) 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/tambo-interactable-provider.d.ts +20 -0
  30. package/dist/providers/tambo-interactable-provider.d.ts.map +1 -1
  31. package/dist/providers/tambo-interactable-provider.js +32 -2
  32. package/dist/providers/tambo-interactable-provider.js.map +1 -1
  33. package/esm/context-helpers/current-interactables-context-helper.d.ts +28 -0
  34. package/esm/context-helpers/current-interactables-context-helper.d.ts.map +1 -0
  35. package/esm/context-helpers/current-interactables-context-helper.js +56 -0
  36. package/esm/context-helpers/current-interactables-context-helper.js.map +1 -0
  37. package/esm/context-helpers/index.d.ts +1 -0
  38. package/esm/context-helpers/index.d.ts.map +1 -1
  39. package/esm/context-helpers/index.js +1 -0
  40. package/esm/context-helpers/index.js.map +1 -1
  41. package/esm/index.d.ts +1 -1
  42. package/esm/index.d.ts.map +1 -1
  43. package/esm/index.js +1 -1
  44. package/esm/index.js.map +1 -1
  45. package/esm/mcp/__tests__/tambo-mcp-provider.test.d.ts +2 -0
  46. package/esm/mcp/__tests__/tambo-mcp-provider.test.d.ts.map +1 -0
  47. package/esm/mcp/__tests__/tambo-mcp-provider.test.js +113 -0
  48. package/esm/mcp/__tests__/tambo-mcp-provider.test.js.map +1 -0
  49. package/esm/mcp/tambo-mcp-provider.d.ts +6 -0
  50. package/esm/mcp/tambo-mcp-provider.d.ts.map +1 -1
  51. package/esm/mcp/tambo-mcp-provider.js +24 -2
  52. package/esm/mcp/tambo-mcp-provider.js.map +1 -1
  53. package/esm/providers/__tests__/tambo-interactables-additional-context-edge-cases.test.d.ts +2 -0
  54. package/esm/providers/__tests__/tambo-interactables-additional-context-edge-cases.test.d.ts.map +1 -0
  55. package/esm/providers/__tests__/tambo-interactables-additional-context-edge-cases.test.js +334 -0
  56. package/esm/providers/__tests__/tambo-interactables-additional-context-edge-cases.test.js.map +1 -0
  57. package/esm/providers/__tests__/tambo-interactables-additional-context.test.d.ts +2 -0
  58. package/esm/providers/__tests__/tambo-interactables-additional-context.test.d.ts.map +1 -0
  59. package/esm/providers/__tests__/tambo-interactables-additional-context.test.js +294 -0
  60. package/esm/providers/__tests__/tambo-interactables-additional-context.test.js.map +1 -0
  61. package/esm/providers/tambo-interactable-provider.d.ts +20 -0
  62. package/esm/providers/tambo-interactable-provider.d.ts.map +1 -1
  63. package/esm/providers/tambo-interactable-provider.js +30 -1
  64. package/esm/providers/tambo-interactable-provider.js.map +1 -1
  65. package/package.json +8 -8
  66. package/dist/mcp/mcp-tools-client.d.ts +0 -96
  67. package/dist/mcp/mcp-tools-client.d.ts.map +0 -1
  68. package/dist/mcp/mcp-tools-client.js +0 -178
  69. package/dist/mcp/mcp-tools-client.js.map +0 -1
  70. package/esm/mcp/mcp-tools-client.d.ts +0 -96
  71. package/esm/mcp/mcp-tools-client.d.ts.map +0 -1
  72. package/esm/mcp/mcp-tools-client.js +0 -174
  73. package/esm/mcp/mcp-tools-client.js.map +0 -1
@@ -0,0 +1,299 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const react_1 = require("@testing-library/react");
7
+ const react_2 = __importDefault(require("react"));
8
+ const zod_1 = require("zod");
9
+ const tambo_context_helpers_provider_1 = require("../tambo-context-helpers-provider");
10
+ const tambo_interactable_provider_1 = require("../tambo-interactable-provider");
11
+ const tambo_stubs_1 = require("../tambo-stubs");
12
+ const with_tambo_interactable_1 = require("../hoc/with-tambo-interactable");
13
+ function wrapperWithProviders(children) {
14
+ const thread = {
15
+ id: "t-1",
16
+ projectId: "p-1",
17
+ createdAt: new Date().toISOString(),
18
+ updatedAt: new Date().toISOString(),
19
+ messages: [],
20
+ metadata: {},
21
+ };
22
+ return (react_2.default.createElement(tambo_stubs_1.TamboStubProvider, { thread: thread, registerTool: () => { }, registerTools: () => { }, registerComponent: () => { }, addToolAssociation: () => { } },
23
+ react_2.default.createElement(tambo_context_helpers_provider_1.TamboContextHelpersProvider, null, children)));
24
+ }
25
+ describe("Interactables AdditionalContext (provider-based)", () => {
26
+ test("registers default helper and returns payload with description and components", async () => {
27
+ const Note = ({ title }) => react_2.default.createElement("div", null, title);
28
+ const InteractableNote = (0, with_tambo_interactable_1.withTamboInteractable)(Note, {
29
+ componentName: "Note",
30
+ description: "A note",
31
+ propsSchema: zod_1.z.object({ title: zod_1.z.string() }),
32
+ });
33
+ let capturedContexts = [];
34
+ const TestComponent = () => {
35
+ const { getAdditionalContext } = (0, tambo_context_helpers_provider_1.useTamboContextHelpers)();
36
+ react_2.default.useEffect(() => {
37
+ let mounted = true;
38
+ getAdditionalContext().then((contexts) => {
39
+ if (mounted) {
40
+ capturedContexts = contexts;
41
+ }
42
+ });
43
+ return () => {
44
+ mounted = false;
45
+ };
46
+ }, [getAdditionalContext]);
47
+ return react_2.default.createElement("div", { "data-testid": "ready" }, "ready");
48
+ };
49
+ const { getByTestId } = (0, react_1.render)(wrapperWithProviders(react_2.default.createElement(tambo_interactable_provider_1.TamboInteractableProvider, null,
50
+ react_2.default.createElement(InteractableNote, { title: "hello" }),
51
+ react_2.default.createElement(TestComponent, null))));
52
+ await (0, react_1.waitFor)(() => {
53
+ expect(getByTestId("ready")).toBeInTheDocument();
54
+ const entry = capturedContexts.find((c) => c.name === "interactables");
55
+ expect(entry).toBeDefined();
56
+ expect(entry?.context?.description).toMatch(/interactable components/i);
57
+ expect(Array.isArray(entry?.context?.components)).toBe(true);
58
+ const comp = entry.context.components[0];
59
+ expect(comp.componentName).toBe("Note");
60
+ expect(comp.props).toEqual({ title: "hello" });
61
+ });
62
+ });
63
+ test("returns null when no interactable components are present", async () => {
64
+ let capturedContexts = [];
65
+ const TestComponent = () => {
66
+ const { getAdditionalContext } = (0, tambo_context_helpers_provider_1.useTamboContextHelpers)();
67
+ react_2.default.useEffect(() => {
68
+ let mounted = true;
69
+ getAdditionalContext().then((contexts) => {
70
+ if (mounted) {
71
+ capturedContexts = contexts;
72
+ }
73
+ });
74
+ return () => {
75
+ mounted = false;
76
+ };
77
+ }, [getAdditionalContext]);
78
+ return react_2.default.createElement("div", { "data-testid": "ready" }, "ready");
79
+ };
80
+ const { getByTestId } = (0, react_1.render)(wrapperWithProviders(react_2.default.createElement(tambo_interactable_provider_1.TamboInteractableProvider, null,
81
+ react_2.default.createElement("div", null, "No interactables here"),
82
+ react_2.default.createElement(TestComponent, null))));
83
+ await (0, react_1.waitFor)(() => {
84
+ expect(getByTestId("ready")).toBeInTheDocument();
85
+ const entry = capturedContexts.find((c) => c.name === "interactables");
86
+ expect(entry).toBeUndefined(); // Should be filtered out when helper returns null
87
+ });
88
+ });
89
+ test("context includes proper AI prompt with clear instructions", async () => {
90
+ const Note = ({ title }) => react_2.default.createElement("div", null, title);
91
+ const InteractableNote = (0, with_tambo_interactable_1.withTamboInteractable)(Note, {
92
+ componentName: "Note",
93
+ description: "A simple note",
94
+ propsSchema: zod_1.z.object({ title: zod_1.z.string() }),
95
+ });
96
+ let capturedContexts = [];
97
+ const TestComponent = () => {
98
+ const { getAdditionalContext } = (0, tambo_context_helpers_provider_1.useTamboContextHelpers)();
99
+ react_2.default.useEffect(() => {
100
+ let mounted = true;
101
+ getAdditionalContext().then((contexts) => {
102
+ if (mounted) {
103
+ capturedContexts = contexts;
104
+ }
105
+ });
106
+ return () => {
107
+ mounted = false;
108
+ };
109
+ }, [getAdditionalContext]);
110
+ return react_2.default.createElement("div", { "data-testid": "ready" }, "ready");
111
+ };
112
+ const { getByTestId } = (0, react_1.render)(wrapperWithProviders(react_2.default.createElement(tambo_interactable_provider_1.TamboInteractableProvider, null,
113
+ react_2.default.createElement(InteractableNote, { title: "test" }),
114
+ react_2.default.createElement(TestComponent, null))));
115
+ await (0, react_1.waitFor)(() => {
116
+ expect(getByTestId("ready")).toBeInTheDocument();
117
+ const entry = capturedContexts.find((c) => c.name === "interactables");
118
+ expect(entry?.context?.description).toContain("interactable components");
119
+ expect(entry?.context?.description).toContain("visible on the page");
120
+ expect(entry?.context?.description).toContain("you can read and modify");
121
+ expect(entry?.context?.description).toContain("tools to update");
122
+ });
123
+ });
124
+ test("includes component metadata in expected format", async () => {
125
+ const Note = ({ title, color = "white", }) => react_2.default.createElement("div", { className: `note-${color}` }, title);
126
+ const InteractableNote = (0, with_tambo_interactable_1.withTamboInteractable)(Note, {
127
+ componentName: "Note",
128
+ description: "A colorful note component",
129
+ propsSchema: zod_1.z.object({
130
+ title: zod_1.z.string(),
131
+ color: zod_1.z.string().optional(),
132
+ }),
133
+ });
134
+ let capturedContexts = [];
135
+ const TestComponent = () => {
136
+ const { getAdditionalContext } = (0, tambo_context_helpers_provider_1.useTamboContextHelpers)();
137
+ react_2.default.useEffect(() => {
138
+ let mounted = true;
139
+ getAdditionalContext().then((contexts) => {
140
+ if (mounted) {
141
+ capturedContexts = contexts;
142
+ }
143
+ });
144
+ return () => {
145
+ mounted = false;
146
+ };
147
+ }, [getAdditionalContext]);
148
+ return react_2.default.createElement("div", { "data-testid": "ready" }, "ready");
149
+ };
150
+ const { getByTestId } = (0, react_1.render)(wrapperWithProviders(react_2.default.createElement(tambo_interactable_provider_1.TamboInteractableProvider, null,
151
+ react_2.default.createElement(InteractableNote, { title: "test note", color: "blue" }),
152
+ react_2.default.createElement(TestComponent, null))));
153
+ await (0, react_1.waitFor)(() => {
154
+ expect(getByTestId("ready")).toBeInTheDocument();
155
+ const entry = capturedContexts.find((c) => c.name === "interactables");
156
+ const component = entry.context.components[0];
157
+ expect(component).toMatchObject({
158
+ id: expect.any(String),
159
+ componentName: "Note",
160
+ description: "A colorful note component",
161
+ props: { title: "test note", color: "blue" },
162
+ propsSchema: "Available - use component-specific update tools",
163
+ });
164
+ });
165
+ });
166
+ test("snapshot hook returns immutable copies", async () => {
167
+ const Note = ({ title }) => react_2.default.createElement("div", null, title);
168
+ const InteractableNote = (0, with_tambo_interactable_1.withTamboInteractable)(Note, {
169
+ componentName: "Note",
170
+ description: "A note",
171
+ propsSchema: zod_1.z.object({ title: zod_1.z.string() }),
172
+ });
173
+ const TestComponent = () => {
174
+ const snapshot = (0, tambo_interactable_provider_1.useCurrentInteractablesSnapshot)();
175
+ const [testResult, setTestResult] = react_2.default.useState("pending");
176
+ react_2.default.useEffect(() => {
177
+ if (snapshot.length > 0) {
178
+ const originalLength = snapshot.length;
179
+ // Try to mutate the returned array and props
180
+ snapshot.push({
181
+ id: "fake",
182
+ name: "Fake",
183
+ description: "",
184
+ component: () => null,
185
+ props: {},
186
+ });
187
+ snapshot[0].props.title = "MUTATED";
188
+ // The mutations should succeed on the returned copy, proving it's a separate object
189
+ if (snapshot.length === originalLength + 1 &&
190
+ snapshot[0].props.title === "MUTATED") {
191
+ setTestResult("mutation-successful-but-isolated");
192
+ }
193
+ else {
194
+ setTestResult("mutation-failed");
195
+ }
196
+ }
197
+ }, [snapshot]);
198
+ return react_2.default.createElement("div", { "data-testid": "test-result" }, testResult);
199
+ };
200
+ const { getByTestId } = (0, react_1.render)(wrapperWithProviders(react_2.default.createElement(tambo_interactable_provider_1.TamboInteractableProvider, null,
201
+ react_2.default.createElement(InteractableNote, { title: "immutable test" }),
202
+ react_2.default.createElement(TestComponent, null))));
203
+ await (0, react_1.waitFor)(() => {
204
+ const result = getByTestId("test-result").textContent;
205
+ expect(result).toBe("mutation-successful-but-isolated");
206
+ });
207
+ });
208
+ test("multiple interactables from same provider appear in context", async () => {
209
+ const Note = ({ title }) => react_2.default.createElement("div", null, title);
210
+ const Counter = ({ count }) => (react_2.default.createElement("div", null, count));
211
+ const InteractableNote = (0, with_tambo_interactable_1.withTamboInteractable)(Note, {
212
+ componentName: "Note",
213
+ description: "A note",
214
+ propsSchema: zod_1.z.object({ title: zod_1.z.string() }),
215
+ });
216
+ const InteractableCounter = (0, with_tambo_interactable_1.withTamboInteractable)(Counter, {
217
+ componentName: "Counter",
218
+ description: "A counter",
219
+ propsSchema: zod_1.z.object({ count: zod_1.z.number() }),
220
+ });
221
+ let capturedContexts = [];
222
+ const TestComponent = () => {
223
+ const { getAdditionalContext } = (0, tambo_context_helpers_provider_1.useTamboContextHelpers)();
224
+ react_2.default.useEffect(() => {
225
+ let mounted = true;
226
+ getAdditionalContext().then((contexts) => {
227
+ if (mounted) {
228
+ capturedContexts = contexts;
229
+ }
230
+ });
231
+ return () => {
232
+ mounted = false;
233
+ };
234
+ }, [getAdditionalContext]);
235
+ return react_2.default.createElement("div", { "data-testid": "ready" }, "ready");
236
+ };
237
+ const { getByTestId } = (0, react_1.render)(wrapperWithProviders(react_2.default.createElement(tambo_interactable_provider_1.TamboInteractableProvider, null,
238
+ react_2.default.createElement(InteractableNote, { title: "first" }),
239
+ react_2.default.createElement(InteractableCounter, { count: 42 }),
240
+ react_2.default.createElement(TestComponent, null))));
241
+ await (0, react_1.waitFor)(() => {
242
+ expect(getByTestId("ready")).toBeInTheDocument();
243
+ const entry = capturedContexts.find((c) => c.name === "interactables");
244
+ expect(entry?.context?.components).toHaveLength(2);
245
+ const components = entry.context.components;
246
+ expect(components[0].componentName).toBe("Note");
247
+ expect(components[0].props).toEqual({ title: "first" });
248
+ expect(components[1].componentName).toBe("Counter");
249
+ expect(components[1].props).toEqual({ count: 42 });
250
+ });
251
+ });
252
+ test("can be disabled by returning null", async () => {
253
+ const Note = ({ title }) => react_2.default.createElement("div", null, title);
254
+ const InteractableNote = (0, with_tambo_interactable_1.withTamboInteractable)(Note, {
255
+ componentName: "Note",
256
+ description: "A note",
257
+ propsSchema: zod_1.z.object({ title: zod_1.z.string() }),
258
+ });
259
+ // Create a context helpers provider with a disabled interactables helper
260
+ const DisabledContextHelpers = ({ children, }) => (react_2.default.createElement(tambo_context_helpers_provider_1.TamboContextHelpersProvider, { contextHelpers: {
261
+ ["interactables"]: () => null,
262
+ } }, children));
263
+ let capturedContexts = [];
264
+ const TestComponent = () => {
265
+ const { getAdditionalContext } = (0, tambo_context_helpers_provider_1.useTamboContextHelpers)();
266
+ react_2.default.useEffect(() => {
267
+ let mounted = true;
268
+ getAdditionalContext().then((contexts) => {
269
+ if (mounted) {
270
+ capturedContexts = contexts;
271
+ }
272
+ });
273
+ return () => {
274
+ mounted = false;
275
+ };
276
+ }, [getAdditionalContext]);
277
+ return react_2.default.createElement("div", { "data-testid": "ready" }, "ready");
278
+ };
279
+ const thread = {
280
+ id: "t-1",
281
+ projectId: "p-1",
282
+ createdAt: new Date().toISOString(),
283
+ updatedAt: new Date().toISOString(),
284
+ messages: [],
285
+ metadata: {},
286
+ };
287
+ const { getByTestId } = (0, react_1.render)(react_2.default.createElement(tambo_stubs_1.TamboStubProvider, { thread: thread, registerTool: () => { }, registerTools: () => { }, registerComponent: () => { }, addToolAssociation: () => { } },
288
+ react_2.default.createElement(DisabledContextHelpers, null,
289
+ react_2.default.createElement(tambo_interactable_provider_1.TamboInteractableProvider, null,
290
+ react_2.default.createElement(InteractableNote, { title: "should not appear" }),
291
+ react_2.default.createElement(TestComponent, null)))));
292
+ await (0, react_1.waitFor)(() => {
293
+ expect(getByTestId("ready")).toBeInTheDocument();
294
+ const entry = capturedContexts.find((c) => c.name === "interactables");
295
+ expect(entry).toBeUndefined(); // Should be filtered out when helper returns null
296
+ });
297
+ });
298
+ });
299
+ //# 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,kDAAyD;AACzD,kDAA0B;AAC1B,6BAAwB;AACxB,sFAG2C;AAC3C,gFAGwC;AACxC,gDAAmD;AACnD,4EAAuE;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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\"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"]}
@@ -1,4 +1,5 @@
1
1
  import React, { PropsWithChildren } from "react";
2
+ import { z } from "zod";
2
3
  import { type TamboInteractableContext } from "../model/tambo-interactable";
3
4
  declare const TamboInteractableContext: React.Context<TamboInteractableContext>;
4
5
  /**
@@ -16,5 +17,24 @@ export declare const TamboInteractableProvider: React.FC<PropsWithChildren>;
16
17
  * @returns The interactable component management functions
17
18
  */
18
19
  export declare const useTamboInteractable: () => TamboInteractableContext;
20
+ /**
21
+ * Hook to get a cloned snapshot of the current interactables.
22
+ * Returns a shallow copy of the array with cloned items and props to prevent
23
+ * external mutation from affecting internal state.
24
+ * @returns The current interactables snapshot (cloned).
25
+ */
26
+ export declare const useCurrentInteractablesSnapshot: () => {
27
+ props: {
28
+ [x: string]: any;
29
+ };
30
+ id: string;
31
+ name: string;
32
+ description: string;
33
+ component: React.ComponentType<any>;
34
+ propsSchema?: z.ZodTypeAny | import("json-schema").JSONSchema7;
35
+ propsDefinition?: any;
36
+ loadingComponent?: React.ComponentType<any>;
37
+ associatedTools?: import(".").TamboTool[];
38
+ }[];
19
39
  export {};
20
40
  //# sourceMappingURL=tambo-interactable-provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-interactable-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-interactable-provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAEZ,iBAAiB,EAKlB,MAAM,OAAO,CAAC;AAEf,OAAO,EAEL,KAAK,wBAAwB,EAC9B,MAAM,6BAA6B,CAAC;AAGrC,QAAA,MAAM,wBAAwB,yCAQ5B,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA8PjE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,gCAEhC,CAAC"}
1
+ {"version":3,"file":"tambo-interactable-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-interactable-provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAEZ,iBAAiB,EAKlB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAEL,KAAK,wBAAwB,EAC9B,MAAM,6BAA6B,CAAC;AAKrC,QAAA,MAAM,wBAAwB,yCAQ5B,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA6QjE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,gCAEhC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,+BAA+B;;;;;;;;;;;;GAU3C,CAAC"}
@@ -35,10 +35,12 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  };
36
36
  })();
37
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.useTamboInteractable = exports.TamboInteractableProvider = void 0;
38
+ exports.useCurrentInteractablesSnapshot = exports.useTamboInteractable = exports.TamboInteractableProvider = void 0;
39
39
  const react_1 = __importStar(require("react"));
40
40
  const zod_1 = require("zod");
41
41
  const tambo_component_provider_1 = require("./tambo-component-provider");
42
+ const tambo_context_helpers_provider_1 = require("./tambo-context-helpers-provider");
43
+ const current_interactables_context_helper_1 = require("../context-helpers/current-interactables-context-helper");
42
44
  const TamboInteractableContext = (0, react_1.createContext)({
43
45
  interactableComponents: [],
44
46
  addInteractableComponent: () => "",
@@ -59,6 +61,18 @@ const TamboInteractableContext = (0, react_1.createContext)({
59
61
  const TamboInteractableProvider = ({ children, }) => {
60
62
  const [interactableComponents, setInteractableComponents] = (0, react_1.useState)([]);
61
63
  const { registerTool } = (0, tambo_component_provider_1.useTamboComponent)();
64
+ const { addContextHelper, removeContextHelper } = (0, tambo_context_helpers_provider_1.useTamboContextHelpers)();
65
+ // Create a stable context helper function
66
+ const contextHelper = (0, react_1.useCallback)(() => {
67
+ return (0, current_interactables_context_helper_1.createInteractablesContextHelper)(() => interactableComponents)();
68
+ }, [interactableComponents]);
69
+ // Register the default interactables context helper
70
+ (0, react_1.useEffect)(() => {
71
+ addContextHelper("interactables", contextHelper);
72
+ return () => {
73
+ removeContextHelper("interactables");
74
+ };
75
+ }, [contextHelper, addContextHelper, removeContextHelper]);
62
76
  (0, react_1.useEffect)(() => {
63
77
  if (interactableComponents.length > 0) {
64
78
  registerTool({
@@ -198,7 +212,7 @@ const TamboInteractableProvider = ({ children, }) => {
198
212
  });
199
213
  }, [registerTool, updateInteractableComponentProps]);
200
214
  const addInteractableComponent = (0, react_1.useCallback)((component) => {
201
- const id = `${component.name}-${Math.random().toString(36).substr(2, 9)}`;
215
+ const id = `${component.name}-${Math.random().toString(36).slice(2, 11)}`;
202
216
  const newComponent = {
203
217
  ...component,
204
218
  id,
@@ -242,4 +256,20 @@ const useTamboInteractable = () => {
242
256
  return (0, react_1.useContext)(TamboInteractableContext);
243
257
  };
244
258
  exports.useTamboInteractable = useTamboInteractable;
259
+ /**
260
+ * Hook to get a cloned snapshot of the current interactables.
261
+ * Returns a shallow copy of the array with cloned items and props to prevent
262
+ * external mutation from affecting internal state.
263
+ * @returns The current interactables snapshot (cloned).
264
+ */
265
+ const useCurrentInteractablesSnapshot = () => {
266
+ const { interactableComponents } = (0, exports.useTamboInteractable)();
267
+ // Clone the array and each item/props to prevent mutation
268
+ const copy = interactableComponents.map((c) => ({
269
+ ...c,
270
+ props: { ...c.props },
271
+ }));
272
+ return copy;
273
+ };
274
+ exports.useCurrentInteractablesSnapshot = useCurrentInteractablesSnapshot;
245
275
  //# sourceMappingURL=tambo-interactable-provider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-interactable-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-interactable-provider.tsx"],"names":[],"mappings":";AAAA,0DAA0D;AAC1D,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACb,+CAOe;AACf,6BAAwB;AAKxB,yEAA+D;AAE/D,MAAM,wBAAwB,GAAG,IAAA,qBAAa,EAA2B;IACvE,sBAAsB,EAAE,EAAE;IAC1B,wBAAwB,EAAE,GAAG,EAA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QAC3B,gCAAgC;QAChC,wBAAwB;QACxB,+BAA+B;QAC/B,8BAA8B;KAC/B,CAAC;IAEF,OAAO,CACL,8BAAC,wBAAwB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IAC5C,QAAQ,CACyB,CACrC,CAAC;AACJ,CAAC,CAAC;AA9PW,QAAA,yBAAyB,6BA8PpC;AAEF;;;;GAIG;AACI,MAAM,oBAAoB,GAAG,GAAG,EAAE;IACvC,OAAO,IAAA,kBAAU,EAAC,wBAAwB,CAAC,CAAC;AAC9C,CAAC,CAAC;AAFW,QAAA,oBAAoB,wBAE/B","sourcesContent":["// react-sdk/src/providers/tambo-interactable-provider.tsx\n\"use client\";\nimport React, {\n createContext,\n PropsWithChildren,\n useCallback,\n useContext,\n useEffect,\n useState,\n} from \"react\";\nimport { z } from \"zod\";\nimport {\n TamboInteractableComponent,\n type TamboInteractableContext,\n} from \"../model/tambo-interactable\";\nimport { useTamboComponent } from \"./tambo-component-provider\";\n\nconst TamboInteractableContext = createContext<TamboInteractableContext>({\n interactableComponents: [],\n addInteractableComponent: () => \"\",\n removeInteractableComponent: () => {},\n updateInteractableComponentProps: () => {},\n getInteractableComponent: () => undefined,\n getInteractableComponentsByName: () => [],\n clearAllInteractableComponents: () => {},\n});\n\n/**\n * The TamboInteractableProvider manages a list of components that are currently\n * interactable, allowing tambo to interact with them by updating their props. It also registers tools\n * for Tambo to perform CRUD operations on the components list.\n * @param props - The props for the TamboInteractableProvider\n * @param props.children - The children to wrap\n * @returns The TamboInteractableProvider component\n */\nexport const TamboInteractableProvider: React.FC<PropsWithChildren> = ({\n children,\n}) => {\n const [interactableComponents, setInteractableComponents] = useState<\n TamboInteractableComponent[]\n >([]);\n const { registerTool } = useTamboComponent();\n\n useEffect(() => {\n if (interactableComponents.length > 0) {\n registerTool({\n name: \"get_all_interactable_components\",\n description:\n \"Only use this tool if the user is asking about interactable components.Get all currently interactable components with their details including their current props. These are components that you can interact with on behalf of the user.\",\n tool: () => {\n return {\n components: interactableComponents,\n };\n },\n toolSchema: z.function().returns(\n z.object({\n components: z.array(\n z.object({\n id: z.string(),\n componentName: z.string(),\n props: z.record(z.any()),\n propsSchema: z.object({}).optional(),\n }),\n ),\n }),\n ),\n });\n\n registerTool({\n name: \"get_interactable_component_by_id\",\n description: \"Get a specific interactable component by its ID\",\n tool: (componentId: string) => {\n const component = interactableComponents.find(\n (c) => c.id === componentId,\n );\n\n if (!component) {\n return {\n success: false,\n error: `Component with ID ${componentId} not found`,\n };\n }\n\n return {\n success: true,\n component: {\n id: component.id,\n componentName: component.name,\n props: component.props,\n },\n };\n },\n toolSchema: z\n .function()\n .args(z.string())\n .returns(\n z.object({\n success: z.boolean(),\n component: z\n .object({\n id: z.string(),\n componentName: z.string(),\n props: z.record(z.any()),\n })\n .optional(),\n error: z.string().optional(),\n }),\n ),\n });\n\n registerTool({\n name: \"remove_interactable_component\",\n description: \"Remove an interactable component from the system\",\n tool: (componentId: string) => {\n const component = interactableComponents.find(\n (c) => c.id === componentId,\n );\n\n if (!component) {\n return {\n success: false,\n error: `Component with ID ${componentId} not found`,\n };\n }\n\n setInteractableComponents((prev) =>\n prev.filter((c) => c.id !== componentId),\n );\n\n return {\n success: true,\n componentId,\n removedComponent: {\n id: component.id,\n componentName: component.name,\n props: component.props,\n },\n };\n },\n toolSchema: z\n .function()\n .args(z.string())\n .returns(\n z.object({\n success: z.boolean(),\n componentId: z.string(),\n removedComponent: z.object({\n id: z.string(),\n componentName: z.string(),\n props: z.record(z.any()),\n }),\n error: z.string().optional(),\n }),\n ),\n });\n }\n }, [interactableComponents, registerTool]);\n\n const updateInteractableComponentProps = useCallback(\n (id: string, newProps: Record<string, any>) => {\n let updateResult = \"Updated successfully\";\n\n setInteractableComponents((prev) => {\n const componentExists = prev.some((c) => c.id === id);\n\n if (!componentExists) {\n updateResult = `Error: Component with ID ${id} not found`;\n return prev;\n }\n\n const updatedComponents = prev.map((c) =>\n c.id === id ? { ...c, props: { ...c.props, ...newProps } } : c,\n );\n\n // Check if the update actually changed anything\n const originalComponent = prev.find((c) => c.id === id);\n const updatedComponent = updatedComponents.find((c) => c.id === id);\n\n if (!originalComponent || !updatedComponent) {\n updateResult = `Error: Failed to update component with ID ${id}`;\n return prev;\n }\n\n // Check if props actually changed\n const propsChanged =\n JSON.stringify(originalComponent.props) !==\n JSON.stringify(updatedComponent.props);\n\n if (!propsChanged) {\n updateResult = `Warning: No changes detected for component with ID ${id}. The update might not have worked.`;\n return prev;\n }\n\n return updatedComponents;\n });\n\n return updateResult;\n },\n [],\n );\n\n const registerInteractableComponentUpdateTool = useCallback(\n (component: TamboInteractableComponent) => {\n const schemaForArgs =\n typeof component.propsSchema === \"object\" &&\n \"describe\" in component.propsSchema\n ? component.propsSchema\n : z.object({});\n\n registerTool({\n name: `update_interactable_component_${component.id}`,\n description: `Update the props of interactable component ${component.id} (${component.name})`,\n tool: (componentId: string, newProps: any) => {\n return updateInteractableComponentProps(componentId, newProps);\n },\n toolSchema: z\n .function()\n .args(\n z\n .string()\n .describe(\"The ID of the interactable component to update\"),\n schemaForArgs.describe(\n \"The new props to update the component with\",\n ),\n )\n .returns(z.string()),\n });\n },\n [registerTool, updateInteractableComponentProps],\n );\n\n const addInteractableComponent = useCallback(\n (\n component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\">,\n ): string => {\n const id = `${component.name}-${Math.random().toString(36).substr(2, 9)}`;\n const newComponent: TamboInteractableComponent = {\n ...component,\n id,\n };\n\n registerInteractableComponentUpdateTool(newComponent);\n\n setInteractableComponents((prev) => {\n return [...prev, newComponent];\n });\n\n return id;\n },\n [registerInteractableComponentUpdateTool],\n );\n\n const removeInteractableComponent = useCallback((id: string) => {\n setInteractableComponents((prev) => prev.filter((c) => c.id !== id));\n }, []);\n\n const getInteractableComponent = useCallback(\n (id: string) => {\n return interactableComponents.find((c) => c.id === id);\n },\n [interactableComponents],\n );\n\n const getInteractableComponentsByName = useCallback(\n (componentName: string) => {\n return interactableComponents.filter((c) => c.name === componentName);\n },\n [interactableComponents],\n );\n\n const clearAllInteractableComponents = useCallback(() => {\n setInteractableComponents([]);\n }, []);\n\n const value: TamboInteractableContext = {\n interactableComponents,\n addInteractableComponent,\n removeInteractableComponent,\n updateInteractableComponentProps,\n getInteractableComponent,\n getInteractableComponentsByName,\n clearAllInteractableComponents,\n };\n\n return (\n <TamboInteractableContext.Provider value={value}>\n {children}\n </TamboInteractableContext.Provider>\n );\n};\n\n/**\n * The useTamboInteractable hook provides access to the interactable component\n * management functions.\n * @returns The interactable component management functions\n */\nexport const useTamboInteractable = () => {\n return useContext(TamboInteractableContext);\n};\n"]}
1
+ {"version":3,"file":"tambo-interactable-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-interactable-provider.tsx"],"names":[],"mappings":";AAAA,0DAA0D;AAC1D,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACb,+CAOe;AACf,6BAAwB;AAKxB,yEAA+D;AAC/D,qFAA0E;AAC1E,kHAA2G;AAE3G,MAAM,wBAAwB,GAAG,IAAA,qBAAa,EAA2B;IACvE,sBAAsB,EAAE,EAAE;IAC1B,wBAAwB,EAAE,GAAG,EAAE,CAAC,EAAE;IAClC,2BAA2B,EAAE,GAAG,EAAE,GAAE,CAAC;IACrC,gCAAgC,EAAE,GAAG,EAAE,GAAE,CAAC;IAC1C,wBAAwB,EAAE,GAAG,EAAE,CAAC,SAAS;IACzC,+BAA+B,EAAE,GAAG,EAAE,CAAC,EAAE;IACzC,8BAA8B,EAAE,GAAG,EAAE,GAAE,CAAC;CACzC,CAAC,CAAC;AAEH;;;;;;;GAOG;AACI,MAAM,yBAAyB,GAAgC,CAAC,EACrE,QAAQ,GACT,EAAE,EAAE;IACH,MAAM,CAAC,sBAAsB,EAAE,yBAAyB,CAAC,GAAG,IAAA,gBAAQ,EAElE,EAAE,CAAC,CAAC;IACN,MAAM,EAAE,YAAY,EAAE,GAAG,IAAA,4CAAiB,GAAE,CAAC;IAC7C,MAAM,EA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BAAsB;QACtB,wBAAwB;QACxB,2BAA2B;QAC3B,gCAAgC;QAChC,wBAAwB;QACxB,+BAA+B;QAC/B,8BAA8B;KAC/B,CAAC;IAEF,OAAO,CACL,8BAAC,wBAAwB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IAC5C,QAAQ,CACyB,CACrC,CAAC;AACJ,CAAC,CAAC;AA7QW,QAAA,yBAAyB,6BA6QpC;AAEF;;;;GAIG;AACI,MAAM,oBAAoB,GAAG,GAAG,EAAE;IACvC,OAAO,IAAA,kBAAU,EAAC,wBAAwB,CAAC,CAAC;AAC9C,CAAC,CAAC;AAFW,QAAA,oBAAoB,wBAE/B;AAEF;;;;;GAKG;AACI,MAAM,+BAA+B,GAAG,GAAG,EAAE;IAClD,MAAM,EAAE,sBAAsB,EAAE,GAAG,IAAA,4BAAoB,GAAE,CAAC;IAE1D,0DAA0D;IAC1D,MAAM,IAAI,GAAG,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC9C,GAAG,CAAC;QACJ,KAAK,EAAE,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE;KACtB,CAAC,CAAC,CAAC;IAEJ,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAVW,QAAA,+BAA+B,mCAU1C","sourcesContent":["// react-sdk/src/providers/tambo-interactable-provider.tsx\n\"use client\";\nimport React, {\n createContext,\n PropsWithChildren,\n useCallback,\n useContext,\n useEffect,\n useState,\n} from \"react\";\nimport { z } from \"zod\";\nimport {\n TamboInteractableComponent,\n type TamboInteractableContext,\n} from \"../model/tambo-interactable\";\nimport { useTamboComponent } from \"./tambo-component-provider\";\nimport { useTamboContextHelpers } from \"./tambo-context-helpers-provider\";\nimport { createInteractablesContextHelper } from \"../context-helpers/current-interactables-context-helper\";\n\nconst TamboInteractableContext = createContext<TamboInteractableContext>({\n interactableComponents: [],\n addInteractableComponent: () => \"\",\n removeInteractableComponent: () => {},\n updateInteractableComponentProps: () => {},\n getInteractableComponent: () => undefined,\n getInteractableComponentsByName: () => [],\n clearAllInteractableComponents: () => {},\n});\n\n/**\n * The TamboInteractableProvider manages a list of components that are currently\n * interactable, allowing tambo to interact with them by updating their props. It also registers tools\n * for Tambo to perform CRUD operations on the components list.\n * @param props - The props for the TamboInteractableProvider\n * @param props.children - The children to wrap\n * @returns The TamboInteractableProvider component\n */\nexport const TamboInteractableProvider: React.FC<PropsWithChildren> = ({\n children,\n}) => {\n const [interactableComponents, setInteractableComponents] = useState<\n TamboInteractableComponent[]\n >([]);\n const { registerTool } = useTamboComponent();\n const { addContextHelper, removeContextHelper } = useTamboContextHelpers();\n\n // Create a stable context helper function\n const contextHelper = useCallback(() => {\n return createInteractablesContextHelper(() => interactableComponents)();\n }, [interactableComponents]);\n\n // Register the default interactables context helper\n useEffect(() => {\n addContextHelper(\"interactables\", contextHelper);\n\n return () => {\n removeContextHelper(\"interactables\");\n };\n }, [contextHelper, addContextHelper, removeContextHelper]);\n\n useEffect(() => {\n if (interactableComponents.length > 0) {\n registerTool({\n name: \"get_all_interactable_components\",\n description:\n \"Only use this tool if the user is asking about interactable components.Get all currently interactable components with their details including their current props. These are components that you can interact with on behalf of the user.\",\n tool: () => {\n return {\n components: interactableComponents,\n };\n },\n toolSchema: z.function().returns(\n z.object({\n components: z.array(\n z.object({\n id: z.string(),\n componentName: z.string(),\n props: z.record(z.any()),\n propsSchema: z.object({}).optional(),\n }),\n ),\n }),\n ),\n });\n\n registerTool({\n name: \"get_interactable_component_by_id\",\n description: \"Get a specific interactable component by its ID\",\n tool: (componentId: string) => {\n const component = interactableComponents.find(\n (c) => c.id === componentId,\n );\n\n if (!component) {\n return {\n success: false,\n error: `Component with ID ${componentId} not found`,\n };\n }\n\n return {\n success: true,\n component: {\n id: component.id,\n componentName: component.name,\n props: component.props,\n },\n };\n },\n toolSchema: z\n .function()\n .args(z.string())\n .returns(\n z.object({\n success: z.boolean(),\n component: z\n .object({\n id: z.string(),\n componentName: z.string(),\n props: z.record(z.any()),\n })\n .optional(),\n error: z.string().optional(),\n }),\n ),\n });\n\n registerTool({\n name: \"remove_interactable_component\",\n description: \"Remove an interactable component from the system\",\n tool: (componentId: string) => {\n const component = interactableComponents.find(\n (c) => c.id === componentId,\n );\n\n if (!component) {\n return {\n success: false,\n error: `Component with ID ${componentId} not found`,\n };\n }\n\n setInteractableComponents((prev) =>\n prev.filter((c) => c.id !== componentId),\n );\n\n return {\n success: true,\n componentId,\n removedComponent: {\n id: component.id,\n componentName: component.name,\n props: component.props,\n },\n };\n },\n toolSchema: z\n .function()\n .args(z.string())\n .returns(\n z.object({\n success: z.boolean(),\n componentId: z.string(),\n removedComponent: z.object({\n id: z.string(),\n componentName: z.string(),\n props: z.record(z.any()),\n }),\n error: z.string().optional(),\n }),\n ),\n });\n }\n }, [interactableComponents, registerTool]);\n\n const updateInteractableComponentProps = useCallback(\n (id: string, newProps: Record<string, any>) => {\n let updateResult = \"Updated successfully\";\n\n setInteractableComponents((prev) => {\n const componentExists = prev.some((c) => c.id === id);\n\n if (!componentExists) {\n updateResult = `Error: Component with ID ${id} not found`;\n return prev;\n }\n\n const updatedComponents = prev.map((c) =>\n c.id === id ? { ...c, props: { ...c.props, ...newProps } } : c,\n );\n\n // Check if the update actually changed anything\n const originalComponent = prev.find((c) => c.id === id);\n const updatedComponent = updatedComponents.find((c) => c.id === id);\n\n if (!originalComponent || !updatedComponent) {\n updateResult = `Error: Failed to update component with ID ${id}`;\n return prev;\n }\n\n // Check if props actually changed\n const propsChanged =\n JSON.stringify(originalComponent.props) !==\n JSON.stringify(updatedComponent.props);\n\n if (!propsChanged) {\n updateResult = `Warning: No changes detected for component with ID ${id}. The update might not have worked.`;\n return prev;\n }\n\n return updatedComponents;\n });\n\n return updateResult;\n },\n [],\n );\n\n const registerInteractableComponentUpdateTool = useCallback(\n (component: TamboInteractableComponent) => {\n const schemaForArgs =\n typeof component.propsSchema === \"object\" &&\n \"describe\" in component.propsSchema\n ? component.propsSchema\n : z.object({});\n\n registerTool({\n name: `update_interactable_component_${component.id}`,\n description: `Update the props of interactable component ${component.id} (${component.name})`,\n tool: (componentId: string, newProps: any) => {\n return updateInteractableComponentProps(componentId, newProps);\n },\n toolSchema: z\n .function()\n .args(\n z\n .string()\n .describe(\"The ID of the interactable component to update\"),\n schemaForArgs.describe(\n \"The new props to update the component with\",\n ),\n )\n .returns(z.string()),\n });\n },\n [registerTool, updateInteractableComponentProps],\n );\n\n const addInteractableComponent = useCallback(\n (\n component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\">,\n ): string => {\n const id = `${component.name}-${Math.random().toString(36).slice(2, 11)}`;\n const newComponent: TamboInteractableComponent = {\n ...component,\n id,\n };\n\n registerInteractableComponentUpdateTool(newComponent);\n\n setInteractableComponents((prev) => {\n return [...prev, newComponent];\n });\n\n return id;\n },\n [registerInteractableComponentUpdateTool],\n );\n\n const removeInteractableComponent = useCallback((id: string) => {\n setInteractableComponents((prev) => prev.filter((c) => c.id !== id));\n }, []);\n\n const getInteractableComponent = useCallback(\n (id: string) => {\n return interactableComponents.find((c) => c.id === id);\n },\n [interactableComponents],\n );\n\n const getInteractableComponentsByName = useCallback(\n (componentName: string) => {\n return interactableComponents.filter((c) => c.name === componentName);\n },\n [interactableComponents],\n );\n\n const clearAllInteractableComponents = useCallback(() => {\n setInteractableComponents([]);\n }, []);\n\n const value: TamboInteractableContext = {\n interactableComponents,\n addInteractableComponent,\n removeInteractableComponent,\n updateInteractableComponentProps,\n getInteractableComponent,\n getInteractableComponentsByName,\n clearAllInteractableComponents,\n };\n\n return (\n <TamboInteractableContext.Provider value={value}>\n {children}\n </TamboInteractableContext.Provider>\n );\n};\n\n/**\n * The useTamboInteractable hook provides access to the interactable component\n * management functions.\n * @returns The interactable component management functions\n */\nexport const useTamboInteractable = () => {\n return useContext(TamboInteractableContext);\n};\n\n/**\n * Hook to get a cloned snapshot of the current interactables.\n * Returns a shallow copy of the array with cloned items and props to prevent\n * external mutation from affecting internal state.\n * @returns The current interactables snapshot (cloned).\n */\nexport const useCurrentInteractablesSnapshot = () => {\n const { interactableComponents } = useTamboInteractable();\n\n // Clone the array and each item/props to prevent mutation\n const copy = interactableComponents.map((c) => ({\n ...c,\n props: { ...c.props },\n }));\n\n return copy;\n};\n"]}
@@ -0,0 +1,28 @@
1
+ import { ContextHelperFn } from "./types";
2
+ /**
3
+ * Prebuilt context helper that provides information about all interactable components currently on the page.
4
+ * This gives the AI awareness of what components it can interact with and their current state.
5
+ * @returns an object with description and components, or null to skip including this context.
6
+ * To disable this helper, override it with a function that returns null:
7
+ * @example
8
+ * ```tsx
9
+ * // To disable the default interactables context
10
+ * const { addContextHelper } = useTamboContextHelpers();
11
+ * addContextHelper("interactables", () => null);
12
+ *
13
+ * // To customize the context
14
+ * addContextHelper("interactables", () => ({
15
+ * description: "Custom description",
16
+ * components: getCustomComponentsSubset()
17
+ * }));
18
+ * ```
19
+ */
20
+ export declare const currentInteractablesContextHelper: ContextHelperFn;
21
+ /**
22
+ * Creates an interactables context helper with access to the current components.
23
+ * This is used internally by TamboInteractableProvider.
24
+ * @param getComponents Function to get current interactable components
25
+ * @returns Context helper function
26
+ */
27
+ export declare const createInteractablesContextHelper: (getComponents: () => any[]) => ContextHelperFn;
28
+ //# sourceMappingURL=current-interactables-context-helper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"current-interactables-context-helper.d.ts","sourceRoot":"","sources":["../../src/context-helpers/current-interactables-context-helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,iCAAiC,EAAE,eAI/C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,GAC3C,eAAe,MAAM,GAAG,EAAE,KACzB,eA2BF,CAAC"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Prebuilt context helper that provides information about all interactable components currently on the page.
3
+ * This gives the AI awareness of what components it can interact with and their current state.
4
+ * @returns an object with description and components, or null to skip including this context.
5
+ * To disable this helper, override it with a function that returns null:
6
+ * @example
7
+ * ```tsx
8
+ * // To disable the default interactables context
9
+ * const { addContextHelper } = useTamboContextHelpers();
10
+ * addContextHelper("interactables", () => null);
11
+ *
12
+ * // To customize the context
13
+ * addContextHelper("interactables", () => ({
14
+ * description: "Custom description",
15
+ * components: getCustomComponentsSubset()
16
+ * }));
17
+ * ```
18
+ */
19
+ export const currentInteractablesContextHelper = () => {
20
+ // This will be provided by the interactable provider when it registers this helper
21
+ // Since we're provider-only now, this function gets replaced at runtime
22
+ return null;
23
+ };
24
+ /**
25
+ * Creates an interactables context helper with access to the current components.
26
+ * This is used internally by TamboInteractableProvider.
27
+ * @param getComponents Function to get current interactable components
28
+ * @returns Context helper function
29
+ */
30
+ export const createInteractablesContextHelper = (getComponents) => {
31
+ return () => {
32
+ try {
33
+ const components = getComponents();
34
+ if (!Array.isArray(components) || components.length === 0) {
35
+ return null; // No interactable components on the page
36
+ }
37
+ return {
38
+ description: "These are the interactable components currently visible on the page that you can read and modify. Each component has an id, componentName, current props, and optional schema. You can use tools to update these components on behalf of the user.",
39
+ components: components.map((component) => ({
40
+ id: component.id,
41
+ componentName: component.name,
42
+ description: component.description,
43
+ props: component.props,
44
+ propsSchema: component.propsSchema
45
+ ? "Available - use component-specific update tools"
46
+ : "Not specified",
47
+ })),
48
+ };
49
+ }
50
+ catch (e) {
51
+ console.error("currentInteractablesContextHelper failed:", e);
52
+ return null;
53
+ }
54
+ };
55
+ };
56
+ //# sourceMappingURL=current-interactables-context-helper.js.map