@tambo-ai/react 1.2.1 → 1.2.2
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.
- package/dist/providers/tambo-interactable-provider.d.ts +3 -2
- package/dist/providers/tambo-interactable-provider.d.ts.map +1 -1
- package/dist/providers/tambo-interactable-provider.js +45 -31
- package/dist/providers/tambo-interactable-provider.js.map +1 -1
- package/dist/providers/tambo-interactable-provider.test.js +102 -16
- package/dist/providers/tambo-interactable-provider.test.js.map +1 -1
- package/dist/providers/tambo-registry-provider.test.js +11 -0
- package/dist/providers/tambo-registry-provider.test.js.map +1 -1
- package/esm/providers/tambo-interactable-provider.d.ts +3 -2
- package/esm/providers/tambo-interactable-provider.d.ts.map +1 -1
- package/esm/providers/tambo-interactable-provider.js +45 -31
- package/esm/providers/tambo-interactable-provider.js.map +1 -1
- package/esm/providers/tambo-interactable-provider.test.js +102 -16
- package/esm/providers/tambo-interactable-provider.test.js.map +1 -1
- package/esm/providers/tambo-registry-provider.test.js +11 -0
- package/esm/providers/tambo-registry-provider.test.js.map +1 -1
- package/package.json +7 -7
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { PropsWithChildren } from "react";
|
|
2
|
+
import type { TamboTool } from "../model/component-metadata";
|
|
2
3
|
import { type TamboInteractableContext } from "../model/tambo-interactable";
|
|
3
4
|
declare const TamboInteractableContext: React.Context<TamboInteractableContext>;
|
|
4
5
|
/**
|
|
@@ -36,8 +37,8 @@ export declare const useCurrentInteractablesSnapshot: () => {
|
|
|
36
37
|
name: string;
|
|
37
38
|
propsSchema?: import("@tambo-ai/client/dist/model/component-metadata").SupportedSchema | undefined;
|
|
38
39
|
propsDefinition?: any;
|
|
39
|
-
associatedTools?:
|
|
40
|
-
annotations?: import("@tambo-ai/client").ToolAnnotations | undefined;
|
|
40
|
+
associatedTools?: TamboTool[] | undefined;
|
|
41
|
+
annotations?: import("@tambo-ai/client/dist/model/component-metadata").ToolAnnotations | undefined;
|
|
41
42
|
}[];
|
|
42
43
|
export {};
|
|
43
44
|
//# 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":"AAIA,OAAO,KAAK,EAAE,EAEZ,iBAAiB,EAMlB,MAAM,OAAO,CAAC;AAGf,OAAO,EAEL,KAAK,wBAAwB,EAC9B,MAAM,6BAA6B,CAAC;AAMrC,QAAA,MAAM,wBAAwB,yCAY5B,CAAC;
|
|
1
|
+
{"version":3,"file":"tambo-interactable-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-interactable-provider.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAEZ,iBAAiB,EAMlB,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAEL,KAAK,wBAAwB,EAC9B,MAAM,6BAA6B,CAAC;AAMrC,QAAA,MAAM,wBAAwB,yCAY5B,CAAC;AAKH;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAogBjE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,gCAEhC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;GAS3C,CAAC"}
|
|
@@ -57,20 +57,8 @@ const TamboInteractableContext = (0, react_1.createContext)({
|
|
|
57
57
|
setInteractableSelected: () => { },
|
|
58
58
|
clearInteractableSelections: () => { },
|
|
59
59
|
});
|
|
60
|
-
/**
|
|
61
|
-
|
|
62
|
-
* @param id - The interactable component ID
|
|
63
|
-
* @returns The tool names for props and state updates
|
|
64
|
-
*/
|
|
65
|
-
function perComponentToolNames(id) {
|
|
66
|
-
return [`update_component_props_${id}`, `update_component_state_${id}`];
|
|
67
|
-
}
|
|
68
|
-
/** Tool names registered globally when at least one interactable component exists. */
|
|
69
|
-
const GLOBAL_INTERACTABLE_TOOL_NAMES = [
|
|
70
|
-
"get_all_interactable_components",
|
|
71
|
-
"get_interactable_component_by_id",
|
|
72
|
-
"remove_interactable_component",
|
|
73
|
-
];
|
|
60
|
+
/** Synthetic owner ID used to track global interactable tools in the registry. */
|
|
61
|
+
const GLOBAL_INTERACTABLE_OWNER = "__interactable_global__";
|
|
74
62
|
/**
|
|
75
63
|
* The TamboInteractableProvider manages a list of components that are currently
|
|
76
64
|
* interactable, allowing tambo to interact with them by updating their props. It also registers tools
|
|
@@ -81,8 +69,29 @@ const GLOBAL_INTERACTABLE_TOOL_NAMES = [
|
|
|
81
69
|
*/
|
|
82
70
|
const TamboInteractableProvider = ({ children, }) => {
|
|
83
71
|
const [interactableComponents, setInteractableComponents] = (0, react_1.useState)([]);
|
|
72
|
+
const [, setToolComponentOwnership] = (0, react_1.useState)({});
|
|
84
73
|
const { registerTool, unregisterTools } = (0, tambo_registry_provider_1.useTamboRegistry)();
|
|
85
74
|
const { addContextHelper, removeContextHelper } = (0, tambo_context_helpers_provider_1.useTamboContextHelpers)();
|
|
75
|
+
const registerToolForComponent = (0, react_1.useCallback)((componentId, tool) => {
|
|
76
|
+
registerTool(tool);
|
|
77
|
+
setToolComponentOwnership((prev) => {
|
|
78
|
+
const existing = prev[componentId] ?? [];
|
|
79
|
+
if (existing.includes(tool.name))
|
|
80
|
+
return prev;
|
|
81
|
+
return { ...prev, [componentId]: [...existing, tool.name] };
|
|
82
|
+
});
|
|
83
|
+
}, [registerTool]);
|
|
84
|
+
const unregisterToolsForComponent = (0, react_1.useCallback)((componentId) => {
|
|
85
|
+
setToolComponentOwnership((prev) => {
|
|
86
|
+
const toolNames = prev[componentId];
|
|
87
|
+
if (!toolNames || toolNames.length === 0)
|
|
88
|
+
return prev;
|
|
89
|
+
unregisterTools(toolNames);
|
|
90
|
+
const next = { ...prev };
|
|
91
|
+
delete next[componentId];
|
|
92
|
+
return next;
|
|
93
|
+
});
|
|
94
|
+
}, [unregisterTools]);
|
|
86
95
|
// Create a stable context helper function for interactable components
|
|
87
96
|
const interactablesContextHelper = (0, react_1.useMemo)(() => (0, current_interactables_context_helper_1.createInteractablesContextHelper)(interactableComponents), [interactableComponents]);
|
|
88
97
|
// Register the interactables context helper
|
|
@@ -94,7 +103,7 @@ const TamboInteractableProvider = ({ children, }) => {
|
|
|
94
103
|
}, [interactablesContextHelper, addContextHelper, removeContextHelper]);
|
|
95
104
|
(0, react_1.useEffect)(() => {
|
|
96
105
|
if (interactableComponents.length > 0) {
|
|
97
|
-
|
|
106
|
+
registerToolForComponent(GLOBAL_INTERACTABLE_OWNER, {
|
|
98
107
|
name: "get_all_interactable_components",
|
|
99
108
|
description: "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.",
|
|
100
109
|
tool: () => {
|
|
@@ -112,7 +121,7 @@ const TamboInteractableProvider = ({ children, }) => {
|
|
|
112
121
|
})),
|
|
113
122
|
}),
|
|
114
123
|
});
|
|
115
|
-
|
|
124
|
+
registerToolForComponent(GLOBAL_INTERACTABLE_OWNER, {
|
|
116
125
|
name: "get_interactable_component_by_id",
|
|
117
126
|
description: "Get a specific interactable component by its ID",
|
|
118
127
|
tool: ({ componentId }) => {
|
|
@@ -152,7 +161,7 @@ const TamboInteractableProvider = ({ children, }) => {
|
|
|
152
161
|
}),
|
|
153
162
|
]),
|
|
154
163
|
});
|
|
155
|
-
|
|
164
|
+
registerToolForComponent(GLOBAL_INTERACTABLE_OWNER, {
|
|
156
165
|
name: "remove_interactable_component",
|
|
157
166
|
description: "Remove an interactable component from the system",
|
|
158
167
|
tool: ({ componentId }) => {
|
|
@@ -163,7 +172,7 @@ const TamboInteractableProvider = ({ children, }) => {
|
|
|
163
172
|
error: `Component with ID ${componentId} not found`,
|
|
164
173
|
};
|
|
165
174
|
}
|
|
166
|
-
|
|
175
|
+
unregisterToolsForComponent(componentId);
|
|
167
176
|
setInteractableComponents((prev) => prev.filter((c) => c.id !== componentId));
|
|
168
177
|
return {
|
|
169
178
|
success: true,
|
|
@@ -197,9 +206,13 @@ const TamboInteractableProvider = ({ children, }) => {
|
|
|
197
206
|
}
|
|
198
207
|
else {
|
|
199
208
|
// No interactable components — remove the global tools
|
|
200
|
-
|
|
209
|
+
unregisterToolsForComponent(GLOBAL_INTERACTABLE_OWNER);
|
|
201
210
|
}
|
|
202
|
-
}, [
|
|
211
|
+
}, [
|
|
212
|
+
interactableComponents,
|
|
213
|
+
registerToolForComponent,
|
|
214
|
+
unregisterToolsForComponent,
|
|
215
|
+
]);
|
|
203
216
|
const updateInteractableComponentProps = (0, react_1.useCallback)((id, newProps) => {
|
|
204
217
|
if (!newProps || Object.keys(newProps).length === 0) {
|
|
205
218
|
return `Warning: No props provided for component with ID ${id}.`;
|
|
@@ -281,10 +294,10 @@ const TamboInteractableProvider = ({ children, }) => {
|
|
|
281
294
|
},
|
|
282
295
|
required: ["componentId", "newProps"],
|
|
283
296
|
};
|
|
284
|
-
|
|
297
|
+
registerToolForComponent(component.id, {
|
|
285
298
|
name: `${tamboToolNamePart}${component.id}`,
|
|
286
299
|
description: `Update the props of interactable component ${component.id} (${component.name}). Provide partial props (only props to change).`,
|
|
287
|
-
tool: ({ componentId, newProps }) => {
|
|
300
|
+
tool: ({ componentId, newProps, }) => {
|
|
288
301
|
return updateInteractableComponentProps(componentId, newProps);
|
|
289
302
|
},
|
|
290
303
|
inputSchema,
|
|
@@ -294,7 +307,7 @@ const TamboInteractableProvider = ({ children, }) => {
|
|
|
294
307
|
...component.annotations,
|
|
295
308
|
},
|
|
296
309
|
});
|
|
297
|
-
}, [
|
|
310
|
+
}, [registerToolForComponent, updateInteractableComponentProps]);
|
|
298
311
|
const registerInteractableComponentStateUpdateTool = (0, react_1.useCallback)((component, maxNameLength = 60) => {
|
|
299
312
|
const tamboToolNamePart = `update_component_state_`;
|
|
300
313
|
const availableLength = maxNameLength - tamboToolNamePart.length;
|
|
@@ -326,10 +339,10 @@ const TamboInteractableProvider = ({ children, }) => {
|
|
|
326
339
|
},
|
|
327
340
|
required: ["componentId", "newState"],
|
|
328
341
|
};
|
|
329
|
-
|
|
342
|
+
registerToolForComponent(component.id, {
|
|
330
343
|
name: `${tamboToolNamePart}${component.id}`,
|
|
331
344
|
description: `Update the state of interactable component ${component.id} (${component.name}). You may provide partial state (only keys to change).`,
|
|
332
|
-
tool: ({ componentId, newState }) => {
|
|
345
|
+
tool: ({ componentId, newState, }) => {
|
|
333
346
|
return updateInteractableComponentState(componentId, newState);
|
|
334
347
|
},
|
|
335
348
|
inputSchema,
|
|
@@ -339,7 +352,7 @@ const TamboInteractableProvider = ({ children, }) => {
|
|
|
339
352
|
...component.annotations,
|
|
340
353
|
},
|
|
341
354
|
});
|
|
342
|
-
}, [
|
|
355
|
+
}, [registerToolForComponent, updateInteractableComponentState]);
|
|
343
356
|
const addInteractableComponent = (0, react_1.useCallback)((component) => {
|
|
344
357
|
// Validate component name
|
|
345
358
|
(0, validate_component_name_1.assertValidName)(component.name, "component");
|
|
@@ -362,9 +375,9 @@ const TamboInteractableProvider = ({ children, }) => {
|
|
|
362
375
|
registerInteractableComponentStateUpdateTool,
|
|
363
376
|
]);
|
|
364
377
|
const removeInteractableComponent = (0, react_1.useCallback)((id) => {
|
|
365
|
-
|
|
378
|
+
unregisterToolsForComponent(id);
|
|
366
379
|
setInteractableComponents((prev) => prev.filter((c) => c.id !== id));
|
|
367
|
-
}, [
|
|
380
|
+
}, [unregisterToolsForComponent]);
|
|
368
381
|
const getInteractableComponent = (0, react_1.useCallback)((id) => {
|
|
369
382
|
return interactableComponents.find((c) => c.id === id);
|
|
370
383
|
}, [interactableComponents]);
|
|
@@ -372,10 +385,11 @@ const TamboInteractableProvider = ({ children, }) => {
|
|
|
372
385
|
return interactableComponents.filter((c) => c.name === componentName);
|
|
373
386
|
}, [interactableComponents]);
|
|
374
387
|
const clearAllInteractableComponents = (0, react_1.useCallback)(() => {
|
|
375
|
-
const
|
|
376
|
-
|
|
388
|
+
for (const component of interactableComponents) {
|
|
389
|
+
unregisterToolsForComponent(component.id);
|
|
390
|
+
}
|
|
377
391
|
setInteractableComponents([]);
|
|
378
|
-
}, [interactableComponents,
|
|
392
|
+
}, [interactableComponents, unregisterToolsForComponent]);
|
|
379
393
|
const setInteractableStateValue = (0, react_1.useCallback)((componentId, key, value) => {
|
|
380
394
|
setInteractableComponents((prev) => {
|
|
381
395
|
const component = prev.find((c) => c.id === componentId);
|
|
@@ -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,6CAAwC;AAExC,+CAQe;AACf,+BAA2B;AAC3B,kHAA2G;AAK3G,sCAAsE;AACtE,6EAAkE;AAClE,uEAA6D;AAC7D,qFAA0E;AAE1E,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,CAAC,EAAE;IAC1C,wBAAwB,EAAE,GAAG,EAAE,CAAC,SAAS;IACzC,+BAA+B,EAAE,GAAG,EAAE,CAAC,EAAE;IACzC,8BAA8B,EAAE,GAAG,EAAE,GAAE,CAAC;IACxC,oBAAoB,EAAE,GAAG,EAAE,GAAE,CAAC;IAC9B,6BAA6B,EAAE,GAAG,EAAE,CAAC,SAAS;IAC9C,uBAAuB,EAAE,GAAG,EAAE,GAAE,CAAC;IACjC,2BAA2B,EAAE,GAAG,EAAE,GAAE,CAAC;CACtC,CAAC,CAAC;AAEH;;;;GAIG;AACH,SAAS,qBAAqB,CAAC,EAAU;I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AAG,GAAG,EAAE;IAClD,MAAM,EAAE,sBAAsB,EAAE,GAAG,IAAA,4BAAoB,GAAE,CAAC;IAC1D,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;AATW,QAAA,+BAA+B,mCAS1C","sourcesContent":["// react-sdk/src/providers/tambo-interactable-provider.tsx\n\"use client\";\nimport { deepEqual } from \"fast-equals\";\nimport { JSONSchema7 } from \"json-schema\";\nimport React, {\n createContext,\n PropsWithChildren,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useState,\n} from \"react\";\nimport { z } from \"zod/v3\";\nimport { createInteractablesContextHelper } from \"../context-helpers/current-interactables-context-helper\";\nimport {\n TamboInteractableComponent,\n type TamboInteractableContext,\n} from \"../model/tambo-interactable\";\nimport { makeJsonSchemaPartial, schemaToJsonSchema } from \"../schema\";\nimport { assertValidName } from \"../util/validate-component-name\";\nimport { useTamboRegistry } from \"./tambo-registry-provider\";\nimport { useTamboContextHelpers } from \"./tambo-context-helpers-provider\";\n\nconst TamboInteractableContext = createContext<TamboInteractableContext>({\n interactableComponents: [],\n addInteractableComponent: () => \"\",\n removeInteractableComponent: () => {},\n updateInteractableComponentProps: () => \"\",\n getInteractableComponent: () => undefined,\n getInteractableComponentsByName: () => [],\n clearAllInteractableComponents: () => {},\n setInteractableState: () => {},\n getInteractableComponentState: () => undefined,\n setInteractableSelected: () => {},\n clearInteractableSelections: () => {},\n});\n\n/**\n * Returns the per-component tool names that get registered for a given interactable ID.\n * @param id - The interactable component ID\n * @returns The tool names for props and state updates\n */\nfunction perComponentToolNames(id: string): [string, string] {\n return [`update_component_props_${id}`, `update_component_state_${id}`];\n}\n\n/** Tool names registered globally when at least one interactable component exists. */\nconst GLOBAL_INTERACTABLE_TOOL_NAMES = [\n \"get_all_interactable_components\",\n \"get_interactable_component_by_id\",\n \"remove_interactable_component\",\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, unregisterTools } = useTamboRegistry();\n const { addContextHelper, removeContextHelper } = useTamboContextHelpers();\n\n // Create a stable context helper function for interactable components\n const interactablesContextHelper = useMemo(\n () => createInteractablesContextHelper(interactableComponents),\n [interactableComponents],\n );\n\n // Register the interactables context helper\n useEffect(() => {\n addContextHelper(\"interactables\", interactablesContextHelper);\n\n return () => {\n removeContextHelper(\"interactables\");\n };\n }, [interactablesContextHelper, 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 inputSchema: z.object({}),\n outputSchema: z.object({\n components: z.array(\n z.object({\n id: z.string(),\n name: z.string(),\n props: z.record(z.string(), z.any()),\n propsSchema: z.record(z.string(), z.any()).optional(),\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 }) => {\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 } as const;\n }\n\n return {\n success: true,\n component: {\n id: component.id,\n componentName: component.name,\n props: component.props,\n },\n } as const;\n },\n inputSchema: z.object({\n componentId: z.string().describe(\"The ID of the component\"),\n }),\n outputSchema: z.discriminatedUnion(\"success\", [\n z.object({\n success: z.literal(true),\n component: z\n .object({\n id: z.string(),\n componentName: z.string(),\n props: z.record(z.string(), z.any()),\n })\n .optional(),\n }),\n z.object({\n success: z.literal(false),\n error: z.string(),\n }),\n ]),\n });\n\n registerTool({\n name: \"remove_interactable_component\",\n description: \"Remove an interactable component from the system\",\n tool: ({ componentId }) => {\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 } as const;\n }\n\n unregisterTools(perComponentToolNames(componentId));\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 } as const;\n },\n inputSchema: z.object({\n componentId: z.string().describe(\"The ID of the component\"),\n }),\n outputSchema: z.discriminatedUnion(\"success\", [\n z.object({\n success: z.literal(true),\n componentId: z.string(),\n removedComponent: z.object({\n id: z.string(),\n componentName: z.string(),\n props: z.record(z.string(), z.any()),\n }),\n }),\n z.object({\n success: z.literal(false),\n error: z.string(),\n }),\n ]),\n });\n } else {\n // No interactable components — remove the global tools\n unregisterTools(GLOBAL_INTERACTABLE_TOOL_NAMES);\n }\n }, [interactableComponents, registerTool, unregisterTools]);\n\n const updateInteractableComponentProps = useCallback(\n (id: string, newProps: Record<string, any>): string => {\n if (!newProps || Object.keys(newProps).length === 0) {\n return `Warning: No props provided for component with ID ${id}.`;\n }\n\n setInteractableComponents((prev) => {\n const component = prev.find((c) => c.id === id);\n if (!component) {\n return prev;\n }\n\n // Compare props shallowly\n const propsChanged = Object.entries(newProps).some(([key, value]) => {\n return component.props[key] !== value;\n });\n\n if (!propsChanged) {\n return prev; // unchanged\n }\n\n // Apply partial update\n const updated = {\n ...component,\n props: { ...component.props, ...newProps },\n };\n\n const updatedComponents = [...prev];\n const idx = prev.findIndex((c) => c.id === id);\n updatedComponents[idx] = updated;\n\n return updatedComponents;\n });\n\n return \"Updated successfully\";\n },\n [],\n );\n\n const updateInteractableComponentState = useCallback(\n (componentId: string, newState: Record<string, unknown>): string => {\n if (!newState || Object.keys(newState).length === 0) {\n return `Warning: No state values provided for component with ID ${componentId}.`;\n }\n\n setInteractableComponents((components = []) => {\n const component = components.find((c) => c.id === componentId);\n if (!component) return components;\n\n const prevState = component.state ?? {};\n const updatedState = { ...prevState, ...newState };\n if (deepEqual(prevState, updatedState)) return components;\n\n // TODO(lachieh): validate state against schema?\n\n const updated = {\n ...component,\n state: updatedState,\n };\n\n return components.map((c) => (c.id === componentId ? updated : c));\n });\n\n return \"Updated successfully\";\n },\n [],\n );\n\n const registerInteractableComponentPropsUpdateTool = useCallback(\n (component: TamboInteractableComponent, maxNameLength = 60) => {\n const tamboToolNamePart = `update_component_props_`;\n const availableLength = maxNameLength - tamboToolNamePart.length;\n if (component.id.length > availableLength) {\n throw new Error(\n `Interactable component id ${component.id} is too long. It must be less than ${availableLength} characters.`,\n );\n }\n\n // Build newProps schema as JSON Schema\n let newPropsSchema: JSONSchema7;\n if (component.propsSchema) {\n // Convert any supported schema to JSON Schema, then make partial\n const fullSchema = schemaToJsonSchema(component.propsSchema);\n newPropsSchema = makeJsonSchemaPartial(fullSchema);\n } else {\n // No schema - allow any properties\n newPropsSchema = { type: \"object\", additionalProperties: true };\n }\n\n // Build the full input schema as JSON Schema\n const inputSchema: JSONSchema7 = {\n type: \"object\",\n properties: {\n componentId: {\n type: \"string\",\n description: \"The ID of the interactable component to update\",\n },\n newProps: {\n ...newPropsSchema,\n description:\n \"The props to update. Provide only the props you want to change.\",\n },\n },\n required: [\"componentId\", \"newProps\"],\n };\n\n registerTool({\n name: `${tamboToolNamePart}${component.id}`,\n description: `Update the props of interactable component ${component.id} (${component.name}). Provide partial props (only props to change).`,\n tool: ({ componentId, newProps }) => {\n return updateInteractableComponentProps(componentId, newProps);\n },\n inputSchema,\n outputSchema: z.string(),\n annotations: {\n tamboStreamableHint: true,\n ...component.annotations,\n },\n });\n },\n [registerTool, updateInteractableComponentProps],\n );\n\n const registerInteractableComponentStateUpdateTool = useCallback(\n (component: TamboInteractableComponent, maxNameLength = 60) => {\n const tamboToolNamePart = `update_component_state_`;\n const availableLength = maxNameLength - tamboToolNamePart.length;\n if (component.id.length > availableLength) {\n throw new Error(\n `Interactable component id ${component.id} is too long. It must be less than ${availableLength} characters.`,\n );\n }\n\n // Build newState schema as JSON Schema\n let newStateSchema: JSONSchema7 = {\n type: \"object\",\n additionalProperties: true,\n };\n if (component.stateSchema) {\n // Convert any supported schema to JSON Schema, then make partial\n const fullSchema = schemaToJsonSchema(component.stateSchema);\n newStateSchema = makeJsonSchemaPartial(fullSchema);\n }\n\n // Build the full input schema as JSON Schema\n const inputSchema: JSONSchema7 = {\n type: \"object\",\n properties: {\n componentId: {\n type: \"string\",\n description: \"The ID of the interactable component to update\",\n },\n newState: {\n ...newStateSchema,\n description:\n \"The state values to update. Provide only the keys you want to change.\",\n },\n },\n required: [\"componentId\", \"newState\"],\n };\n\n registerTool({\n name: `${tamboToolNamePart}${component.id}`,\n description: `Update the state of interactable component ${component.id} (${component.name}). You may provide partial state (only keys to change).`,\n tool: ({ componentId, newState }) => {\n return updateInteractableComponentState(componentId, newState);\n },\n inputSchema,\n outputSchema: z.string(),\n annotations: {\n tamboStreamableHint: true,\n ...component.annotations,\n },\n });\n },\n [registerTool, updateInteractableComponentState],\n );\n\n const addInteractableComponent = useCallback(\n (\n component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\">,\n ): string => {\n // Validate component name\n assertValidName(component.name, \"component\");\n\n // Add a random part to the component name to make it unique when using multiple instances of the same component.\n const tamboGeneratedNamePart = `-${Math.random().toString(36).slice(2, 5)}`;\n const id = `${component.name}${tamboGeneratedNamePart}`;\n const newComponent: TamboInteractableComponent = {\n ...component,\n id,\n state: component.state ?? {},\n };\n\n registerInteractableComponentPropsUpdateTool(newComponent);\n registerInteractableComponentStateUpdateTool(newComponent);\n\n setInteractableComponents((prev) => {\n return [...prev, newComponent];\n });\n\n return id;\n },\n [\n registerInteractableComponentPropsUpdateTool,\n registerInteractableComponentStateUpdateTool,\n ],\n );\n\n const removeInteractableComponent = useCallback(\n (id: string) => {\n unregisterTools(perComponentToolNames(id));\n setInteractableComponents((prev) => prev.filter((c) => c.id !== id));\n },\n [unregisterTools],\n );\n\n const getInteractableComponent = useCallback(\n <P, S>(id: string): TamboInteractableComponent<P, S> | undefined => {\n return interactableComponents.find((c) => c.id === id) as\n | TamboInteractableComponent<P, S>\n | undefined;\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 const toolNames = interactableComponents.flatMap((c) =>\n perComponentToolNames(c.id),\n );\n unregisterTools(toolNames);\n setInteractableComponents([]);\n }, [interactableComponents, unregisterTools]);\n\n const setInteractableStateValue = useCallback(\n (componentId: string, key: string, value: unknown) => {\n setInteractableComponents((prev) => {\n const component = prev.find((c) => c.id === componentId);\n if (!component) {\n console.warn(\n `Tried to update state for component ${componentId} but it was not found.`,\n );\n return prev;\n }\n\n const updated = {\n ...component,\n state: {\n ...component.state,\n [key]: value,\n },\n };\n\n const updatedComponents = prev.map((component) => {\n if (component.id === componentId) {\n return updated;\n }\n return component;\n });\n\n return updatedComponents;\n });\n },\n [],\n );\n\n const getInteractableComponentState = useCallback(\n (componentId: string) => {\n const component = interactableComponents.find(\n (c) => c.id === componentId,\n );\n return component?.state;\n },\n [interactableComponents],\n );\n\n const setInteractableSelected = useCallback(\n (componentId: string, isSelected: boolean) => {\n setInteractableComponents((prev) => {\n let found = false;\n const next = prev.map((component) => {\n if (component.id !== componentId) return component;\n found = true;\n return component.isSelected === isSelected\n ? component\n : { ...component, isSelected: isSelected };\n });\n return found ? next : prev;\n });\n },\n [],\n );\n\n const clearInteractableSelections = useCallback(() => {\n setInteractableComponents((prev) => {\n if (!prev.some((c) => c.isSelected)) return prev;\n return prev.map((c) => (c.isSelected ? { ...c, isSelected: false } : c));\n });\n }, []);\n\n const value: TamboInteractableContext = {\n interactableComponents,\n addInteractableComponent,\n removeInteractableComponent,\n updateInteractableComponentProps,\n getInteractableComponent,\n getInteractableComponentsByName,\n clearAllInteractableComponents,\n setInteractableState: setInteractableStateValue,\n getInteractableComponentState,\n setInteractableSelected,\n clearInteractableSelections,\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 // 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"]}
|
|
1
|
+
{"version":3,"file":"tambo-interactable-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-interactable-provider.tsx"],"names":[],"mappings":";AAAA,0DAA0D;AAC1D,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACb,6CAAwC;AAExC,+CAQe;AACf,+BAA2B;AAC3B,kHAA2G;AAM3G,sCAAsE;AACtE,6EAAkE;AAClE,uEAA6D;AAC7D,qFAA0E;AAE1E,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,CAAC,EAAE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C;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;IAC1D,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;AATW,QAAA,+BAA+B,mCAS1C","sourcesContent":["// react-sdk/src/providers/tambo-interactable-provider.tsx\n\"use client\";\nimport { deepEqual } from \"fast-equals\";\nimport { JSONSchema7 } from \"json-schema\";\nimport React, {\n createContext,\n PropsWithChildren,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useState,\n} from \"react\";\nimport { z } from \"zod/v3\";\nimport { createInteractablesContextHelper } from \"../context-helpers/current-interactables-context-helper\";\nimport type { TamboTool } from \"../model/component-metadata\";\nimport {\n TamboInteractableComponent,\n type TamboInteractableContext,\n} from \"../model/tambo-interactable\";\nimport { makeJsonSchemaPartial, schemaToJsonSchema } from \"../schema\";\nimport { assertValidName } from \"../util/validate-component-name\";\nimport { useTamboRegistry } from \"./tambo-registry-provider\";\nimport { useTamboContextHelpers } from \"./tambo-context-helpers-provider\";\n\nconst TamboInteractableContext = createContext<TamboInteractableContext>({\n interactableComponents: [],\n addInteractableComponent: () => \"\",\n removeInteractableComponent: () => {},\n updateInteractableComponentProps: () => \"\",\n getInteractableComponent: () => undefined,\n getInteractableComponentsByName: () => [],\n clearAllInteractableComponents: () => {},\n setInteractableState: () => {},\n getInteractableComponentState: () => undefined,\n setInteractableSelected: () => {},\n clearInteractableSelections: () => {},\n});\n\n/** Synthetic owner ID used to track global interactable tools in the registry. */\nconst GLOBAL_INTERACTABLE_OWNER = \"__interactable_global__\";\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 [, setToolComponentOwnership] = useState<Record<string, string[]>>({});\n const { registerTool, unregisterTools } = useTamboRegistry();\n const { addContextHelper, removeContextHelper } = useTamboContextHelpers();\n\n const registerToolForComponent = useCallback(\n (componentId: string, tool: TamboTool) => {\n registerTool(tool);\n setToolComponentOwnership((prev) => {\n const existing = prev[componentId] ?? [];\n if (existing.includes(tool.name)) return prev;\n return { ...prev, [componentId]: [...existing, tool.name] };\n });\n },\n [registerTool],\n );\n\n const unregisterToolsForComponent = useCallback(\n (componentId: string) => {\n setToolComponentOwnership((prev) => {\n const toolNames = prev[componentId];\n if (!toolNames || toolNames.length === 0) return prev;\n unregisterTools(toolNames);\n const next = { ...prev };\n delete next[componentId];\n return next;\n });\n },\n [unregisterTools],\n );\n\n // Create a stable context helper function for interactable components\n const interactablesContextHelper = useMemo(\n () => createInteractablesContextHelper(interactableComponents),\n [interactableComponents],\n );\n\n // Register the interactables context helper\n useEffect(() => {\n addContextHelper(\"interactables\", interactablesContextHelper);\n\n return () => {\n removeContextHelper(\"interactables\");\n };\n }, [interactablesContextHelper, addContextHelper, removeContextHelper]);\n\n useEffect(() => {\n if (interactableComponents.length > 0) {\n registerToolForComponent(GLOBAL_INTERACTABLE_OWNER, {\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 inputSchema: z.object({}),\n outputSchema: z.object({\n components: z.array(\n z.object({\n id: z.string(),\n name: z.string(),\n props: z.record(z.string(), z.any()),\n propsSchema: z.record(z.string(), z.any()).optional(),\n }),\n ),\n }),\n });\n\n registerToolForComponent(GLOBAL_INTERACTABLE_OWNER, {\n name: \"get_interactable_component_by_id\",\n description: \"Get a specific interactable component by its ID\",\n tool: ({ componentId }: { 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 } as const;\n }\n\n return {\n success: true,\n component: {\n id: component.id,\n componentName: component.name,\n props: component.props,\n },\n } as const;\n },\n inputSchema: z.object({\n componentId: z.string().describe(\"The ID of the component\"),\n }),\n outputSchema: z.discriminatedUnion(\"success\", [\n z.object({\n success: z.literal(true),\n component: z\n .object({\n id: z.string(),\n componentName: z.string(),\n props: z.record(z.string(), z.any()),\n })\n .optional(),\n }),\n z.object({\n success: z.literal(false),\n error: z.string(),\n }),\n ]),\n });\n\n registerToolForComponent(GLOBAL_INTERACTABLE_OWNER, {\n name: \"remove_interactable_component\",\n description: \"Remove an interactable component from the system\",\n tool: ({ componentId }: { 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 } as const;\n }\n\n unregisterToolsForComponent(componentId);\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 } as const;\n },\n inputSchema: z.object({\n componentId: z.string().describe(\"The ID of the component\"),\n }),\n outputSchema: z.discriminatedUnion(\"success\", [\n z.object({\n success: z.literal(true),\n componentId: z.string(),\n removedComponent: z.object({\n id: z.string(),\n componentName: z.string(),\n props: z.record(z.string(), z.any()),\n }),\n }),\n z.object({\n success: z.literal(false),\n error: z.string(),\n }),\n ]),\n });\n } else {\n // No interactable components — remove the global tools\n unregisterToolsForComponent(GLOBAL_INTERACTABLE_OWNER);\n }\n }, [\n interactableComponents,\n registerToolForComponent,\n unregisterToolsForComponent,\n ]);\n\n const updateInteractableComponentProps = useCallback(\n (id: string, newProps: Record<string, any>): string => {\n if (!newProps || Object.keys(newProps).length === 0) {\n return `Warning: No props provided for component with ID ${id}.`;\n }\n\n setInteractableComponents((prev) => {\n const component = prev.find((c) => c.id === id);\n if (!component) {\n return prev;\n }\n\n // Compare props shallowly\n const propsChanged = Object.entries(newProps).some(([key, value]) => {\n return component.props[key] !== value;\n });\n\n if (!propsChanged) {\n return prev; // unchanged\n }\n\n // Apply partial update\n const updated = {\n ...component,\n props: { ...component.props, ...newProps },\n };\n\n const updatedComponents = [...prev];\n const idx = prev.findIndex((c) => c.id === id);\n updatedComponents[idx] = updated;\n\n return updatedComponents;\n });\n\n return \"Updated successfully\";\n },\n [],\n );\n\n const updateInteractableComponentState = useCallback(\n (componentId: string, newState: Record<string, unknown>): string => {\n if (!newState || Object.keys(newState).length === 0) {\n return `Warning: No state values provided for component with ID ${componentId}.`;\n }\n\n setInteractableComponents((components = []) => {\n const component = components.find((c) => c.id === componentId);\n if (!component) return components;\n\n const prevState = component.state ?? {};\n const updatedState = { ...prevState, ...newState };\n if (deepEqual(prevState, updatedState)) return components;\n\n // TODO(lachieh): validate state against schema?\n\n const updated = {\n ...component,\n state: updatedState,\n };\n\n return components.map((c) => (c.id === componentId ? updated : c));\n });\n\n return \"Updated successfully\";\n },\n [],\n );\n\n const registerInteractableComponentPropsUpdateTool = useCallback(\n (component: TamboInteractableComponent, maxNameLength = 60) => {\n const tamboToolNamePart = `update_component_props_`;\n const availableLength = maxNameLength - tamboToolNamePart.length;\n if (component.id.length > availableLength) {\n throw new Error(\n `Interactable component id ${component.id} is too long. It must be less than ${availableLength} characters.`,\n );\n }\n\n // Build newProps schema as JSON Schema\n let newPropsSchema: JSONSchema7;\n if (component.propsSchema) {\n // Convert any supported schema to JSON Schema, then make partial\n const fullSchema = schemaToJsonSchema(component.propsSchema);\n newPropsSchema = makeJsonSchemaPartial(fullSchema);\n } else {\n // No schema - allow any properties\n newPropsSchema = { type: \"object\", additionalProperties: true };\n }\n\n // Build the full input schema as JSON Schema\n const inputSchema: JSONSchema7 = {\n type: \"object\",\n properties: {\n componentId: {\n type: \"string\",\n description: \"The ID of the interactable component to update\",\n },\n newProps: {\n ...newPropsSchema,\n description:\n \"The props to update. Provide only the props you want to change.\",\n },\n },\n required: [\"componentId\", \"newProps\"],\n };\n\n registerToolForComponent(component.id, {\n name: `${tamboToolNamePart}${component.id}`,\n description: `Update the props of interactable component ${component.id} (${component.name}). Provide partial props (only props to change).`,\n tool: ({\n componentId,\n newProps,\n }: {\n componentId: string;\n newProps: Record<string, unknown>;\n }) => {\n return updateInteractableComponentProps(componentId, newProps);\n },\n inputSchema,\n outputSchema: z.string(),\n annotations: {\n tamboStreamableHint: true,\n ...component.annotations,\n },\n });\n },\n [registerToolForComponent, updateInteractableComponentProps],\n );\n\n const registerInteractableComponentStateUpdateTool = useCallback(\n (component: TamboInteractableComponent, maxNameLength = 60) => {\n const tamboToolNamePart = `update_component_state_`;\n const availableLength = maxNameLength - tamboToolNamePart.length;\n if (component.id.length > availableLength) {\n throw new Error(\n `Interactable component id ${component.id} is too long. It must be less than ${availableLength} characters.`,\n );\n }\n\n // Build newState schema as JSON Schema\n let newStateSchema: JSONSchema7 = {\n type: \"object\",\n additionalProperties: true,\n };\n if (component.stateSchema) {\n // Convert any supported schema to JSON Schema, then make partial\n const fullSchema = schemaToJsonSchema(component.stateSchema);\n newStateSchema = makeJsonSchemaPartial(fullSchema);\n }\n\n // Build the full input schema as JSON Schema\n const inputSchema: JSONSchema7 = {\n type: \"object\",\n properties: {\n componentId: {\n type: \"string\",\n description: \"The ID of the interactable component to update\",\n },\n newState: {\n ...newStateSchema,\n description:\n \"The state values to update. Provide only the keys you want to change.\",\n },\n },\n required: [\"componentId\", \"newState\"],\n };\n\n registerToolForComponent(component.id, {\n name: `${tamboToolNamePart}${component.id}`,\n description: `Update the state of interactable component ${component.id} (${component.name}). You may provide partial state (only keys to change).`,\n tool: ({\n componentId,\n newState,\n }: {\n componentId: string;\n newState: Record<string, unknown>;\n }) => {\n return updateInteractableComponentState(componentId, newState);\n },\n inputSchema,\n outputSchema: z.string(),\n annotations: {\n tamboStreamableHint: true,\n ...component.annotations,\n },\n });\n },\n [registerToolForComponent, updateInteractableComponentState],\n );\n\n const addInteractableComponent = useCallback(\n (\n component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\">,\n ): string => {\n // Validate component name\n assertValidName(component.name, \"component\");\n\n // Add a random part to the component name to make it unique when using multiple instances of the same component.\n const tamboGeneratedNamePart = `-${Math.random().toString(36).slice(2, 5)}`;\n const id = `${component.name}${tamboGeneratedNamePart}`;\n const newComponent: TamboInteractableComponent = {\n ...component,\n id,\n state: component.state ?? {},\n };\n\n registerInteractableComponentPropsUpdateTool(newComponent);\n registerInteractableComponentStateUpdateTool(newComponent);\n\n setInteractableComponents((prev) => {\n return [...prev, newComponent];\n });\n\n return id;\n },\n [\n registerInteractableComponentPropsUpdateTool,\n registerInteractableComponentStateUpdateTool,\n ],\n );\n\n const removeInteractableComponent = useCallback(\n (id: string) => {\n unregisterToolsForComponent(id);\n setInteractableComponents((prev) => prev.filter((c) => c.id !== id));\n },\n [unregisterToolsForComponent],\n );\n\n const getInteractableComponent = useCallback(\n <P, S>(id: string): TamboInteractableComponent<P, S> | undefined => {\n return interactableComponents.find((c) => c.id === id) as\n | TamboInteractableComponent<P, S>\n | undefined;\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 for (const component of interactableComponents) {\n unregisterToolsForComponent(component.id);\n }\n setInteractableComponents([]);\n }, [interactableComponents, unregisterToolsForComponent]);\n\n const setInteractableStateValue = useCallback(\n (componentId: string, key: string, value: unknown) => {\n setInteractableComponents((prev) => {\n const component = prev.find((c) => c.id === componentId);\n if (!component) {\n console.warn(\n `Tried to update state for component ${componentId} but it was not found.`,\n );\n return prev;\n }\n\n const updated = {\n ...component,\n state: {\n ...component.state,\n [key]: value,\n },\n };\n\n const updatedComponents = prev.map((component) => {\n if (component.id === componentId) {\n return updated;\n }\n return component;\n });\n\n return updatedComponents;\n });\n },\n [],\n );\n\n const getInteractableComponentState = useCallback(\n (componentId: string) => {\n const component = interactableComponents.find(\n (c) => c.id === componentId,\n );\n return component?.state;\n },\n [interactableComponents],\n );\n\n const setInteractableSelected = useCallback(\n (componentId: string, isSelected: boolean) => {\n setInteractableComponents((prev) => {\n let found = false;\n const next = prev.map((component) => {\n if (component.id !== componentId) return component;\n found = true;\n return component.isSelected === isSelected\n ? component\n : { ...component, isSelected: isSelected };\n });\n return found ? next : prev;\n });\n },\n [],\n );\n\n const clearInteractableSelections = useCallback(() => {\n setInteractableComponents((prev) => {\n if (!prev.some((c) => c.isSelected)) return prev;\n return prev.map((c) => (c.isSelected ? { ...c, isSelected: false } : c));\n });\n }, []);\n\n const value: TamboInteractableContext = {\n interactableComponents,\n addInteractableComponent,\n removeInteractableComponent,\n updateInteractableComponentProps,\n getInteractableComponent,\n getInteractableComponentsByName,\n clearAllInteractableComponents,\n setInteractableState: setInteractableStateValue,\n getInteractableComponentState,\n setInteractableSelected,\n clearInteractableSelections,\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 // 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"]}
|
|
@@ -79,7 +79,7 @@ describe("TamboInteractableProvider - State Update Tool Registration", () => {
|
|
|
79
79
|
(0, react_1.act)(() => {
|
|
80
80
|
componentId = result.current.addInteractableComponent(component);
|
|
81
81
|
});
|
|
82
|
-
// Should register both update_component_ and update_component_state_ tools
|
|
82
|
+
// Should register both update_component_ and update_component_state_ tools via registerToolForComponent
|
|
83
83
|
const registeredToolNames = mockRegisterTool.mock.calls.map((call) => call[0].name);
|
|
84
84
|
expect(registeredToolNames).toContain(`update_component_props_${componentId}`);
|
|
85
85
|
expect(registeredToolNames).toContain(`update_component_state_${componentId}`);
|
|
@@ -101,6 +101,33 @@ describe("TamboInteractableProvider - State Update Tool Registration", () => {
|
|
|
101
101
|
expect(stateToolCall[0].description).toContain(componentId);
|
|
102
102
|
expect(stateToolCall[0].description).toContain("MyComponent");
|
|
103
103
|
});
|
|
104
|
+
it("should allow props update tool to update component props", () => {
|
|
105
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_interactable_provider_1.useTamboInteractable)(), { wrapper });
|
|
106
|
+
const component = {
|
|
107
|
+
name: "TestComponent",
|
|
108
|
+
description: "A test component",
|
|
109
|
+
component: () => react_2.default.createElement("div", null, "Test"),
|
|
110
|
+
props: { title: "original" },
|
|
111
|
+
propsSchema: zod_1.z.object({ title: zod_1.z.string() }),
|
|
112
|
+
};
|
|
113
|
+
let componentId = "";
|
|
114
|
+
(0, react_1.act)(() => {
|
|
115
|
+
componentId = result.current.addInteractableComponent(component);
|
|
116
|
+
});
|
|
117
|
+
// Find the props update tool and call it
|
|
118
|
+
const propsToolCall = mockRegisterTool.mock.calls.find((call) => call[0].name.startsWith("update_component_props_"));
|
|
119
|
+
const toolFn = propsToolCall[0].tool;
|
|
120
|
+
let updateResult = "";
|
|
121
|
+
(0, react_1.act)(() => {
|
|
122
|
+
updateResult = toolFn({
|
|
123
|
+
componentId,
|
|
124
|
+
newProps: { title: "updated" },
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
expect(updateResult).toBe("Updated successfully");
|
|
128
|
+
const comp = result.current.getInteractableComponent(componentId);
|
|
129
|
+
expect(comp?.props.title).toBe("updated");
|
|
130
|
+
});
|
|
104
131
|
it("should allow state update tool to update multiple state values", () => {
|
|
105
132
|
const { result } = (0, react_1.renderHook)(() => (0, tambo_interactable_provider_1.useTamboInteractable)(), { wrapper });
|
|
106
133
|
const component = {
|
|
@@ -366,10 +393,11 @@ describe("TamboInteractableProvider - State Update Tool Registration", () => {
|
|
|
366
393
|
(0, react_1.act)(() => {
|
|
367
394
|
result.current.removeInteractableComponent(componentId);
|
|
368
395
|
});
|
|
369
|
-
|
|
396
|
+
// Should unregister the per-component tools by name
|
|
397
|
+
expect(mockUnregisterTools).toHaveBeenCalledWith(expect.arrayContaining([
|
|
370
398
|
`update_component_props_${componentId}`,
|
|
371
399
|
`update_component_state_${componentId}`,
|
|
372
|
-
]);
|
|
400
|
+
]));
|
|
373
401
|
});
|
|
374
402
|
it("should unregister global tools when all components are removed", () => {
|
|
375
403
|
const wrapper = ({ children }) => (react_2.default.createElement(tambo_interactable_provider_1.TamboInteractableProvider, null, children));
|
|
@@ -388,26 +416,88 @@ describe("TamboInteractableProvider - State Update Tool Registration", () => {
|
|
|
388
416
|
(0, react_1.act)(() => {
|
|
389
417
|
result.current.removeInteractableComponent(componentId);
|
|
390
418
|
});
|
|
391
|
-
// Should
|
|
392
|
-
expect(mockUnregisterTools).toHaveBeenCalledWith([
|
|
419
|
+
// Should unregister global interactable tools once list is empty
|
|
420
|
+
expect(mockUnregisterTools).toHaveBeenCalledWith(expect.arrayContaining([
|
|
393
421
|
"get_all_interactable_components",
|
|
394
422
|
"get_interactable_component_by_id",
|
|
395
423
|
"remove_interactable_component",
|
|
396
|
-
]);
|
|
424
|
+
]));
|
|
425
|
+
});
|
|
426
|
+
it("should register global tools that return component data", () => {
|
|
427
|
+
const wrapper = ({ children }) => (react_2.default.createElement(tambo_interactable_provider_1.TamboInteractableProvider, null, children));
|
|
428
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_interactable_provider_1.useTamboInteractable)(), { wrapper });
|
|
429
|
+
(0, react_1.act)(() => {
|
|
430
|
+
result.current.addInteractableComponent({
|
|
431
|
+
name: "Widget",
|
|
432
|
+
description: "test widget",
|
|
433
|
+
component: () => null,
|
|
434
|
+
props: { color: "red" },
|
|
435
|
+
});
|
|
436
|
+
});
|
|
437
|
+
// Find the global get_all tool
|
|
438
|
+
const getAllCall = mockRegisterTool.mock.calls.find((call) => call[0].name === "get_all_interactable_components");
|
|
439
|
+
expect(getAllCall).toBeDefined();
|
|
440
|
+
const getAllResult = getAllCall[0].tool();
|
|
441
|
+
expect(getAllResult.components).toHaveLength(1);
|
|
442
|
+
expect(getAllResult.components[0].name).toBe("Widget");
|
|
443
|
+
});
|
|
444
|
+
it("should register global get_by_id tool that finds a component", () => {
|
|
445
|
+
const wrapper = ({ children }) => (react_2.default.createElement(tambo_interactable_provider_1.TamboInteractableProvider, null, children));
|
|
446
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_interactable_provider_1.useTamboInteractable)(), { wrapper });
|
|
447
|
+
let componentId;
|
|
448
|
+
(0, react_1.act)(() => {
|
|
449
|
+
componentId = result.current.addInteractableComponent({
|
|
450
|
+
name: "Widget",
|
|
451
|
+
description: "test",
|
|
452
|
+
component: () => null,
|
|
453
|
+
props: { x: 1 },
|
|
454
|
+
});
|
|
455
|
+
});
|
|
456
|
+
const getByIdCall = mockRegisterTool.mock.calls.find((call) => call[0].name === "get_interactable_component_by_id");
|
|
457
|
+
expect(getByIdCall).toBeDefined();
|
|
458
|
+
const found = getByIdCall[0].tool({ componentId: componentId });
|
|
459
|
+
expect(found.success).toBe(true);
|
|
460
|
+
expect(found.component.componentName).toBe("Widget");
|
|
461
|
+
const notFound = getByIdCall[0].tool({ componentId: "nonexistent" });
|
|
462
|
+
expect(notFound.success).toBe(false);
|
|
463
|
+
expect(notFound.error).toContain("not found");
|
|
464
|
+
});
|
|
465
|
+
it("should register global remove tool that removes a component", () => {
|
|
466
|
+
const wrapper = ({ children }) => (react_2.default.createElement(tambo_interactable_provider_1.TamboInteractableProvider, null, children));
|
|
467
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_interactable_provider_1.useTamboInteractable)(), { wrapper });
|
|
468
|
+
let componentId;
|
|
469
|
+
(0, react_1.act)(() => {
|
|
470
|
+
componentId = result.current.addInteractableComponent({
|
|
471
|
+
name: "Widget",
|
|
472
|
+
description: "test",
|
|
473
|
+
component: () => null,
|
|
474
|
+
props: {},
|
|
475
|
+
});
|
|
476
|
+
});
|
|
477
|
+
const removeCall = mockRegisterTool.mock.calls.find((call) => call[0].name === "remove_interactable_component");
|
|
478
|
+
expect(removeCall).toBeDefined();
|
|
479
|
+
// Remove nonexistent
|
|
480
|
+
const notFound = removeCall[0].tool({ componentId: "nonexistent" });
|
|
481
|
+
expect(notFound.success).toBe(false);
|
|
482
|
+
// Remove existing
|
|
483
|
+
let removeResult;
|
|
484
|
+
(0, react_1.act)(() => {
|
|
485
|
+
removeResult = removeCall[0].tool({ componentId: componentId });
|
|
486
|
+
});
|
|
487
|
+
expect(removeResult.success).toBe(true);
|
|
488
|
+
expect(removeResult.removedComponent.componentName).toBe("Widget");
|
|
397
489
|
});
|
|
398
490
|
it("should unregister all per-component tools when clearing all components", () => {
|
|
399
491
|
const wrapper = ({ children }) => (react_2.default.createElement(tambo_interactable_provider_1.TamboInteractableProvider, null, children));
|
|
400
492
|
const { result } = (0, react_1.renderHook)(() => (0, tambo_interactable_provider_1.useTamboInteractable)(), { wrapper });
|
|
401
|
-
let id1;
|
|
402
|
-
let id2;
|
|
403
493
|
(0, react_1.act)(() => {
|
|
404
|
-
|
|
494
|
+
result.current.addInteractableComponent({
|
|
405
495
|
name: "A",
|
|
406
496
|
description: "test",
|
|
407
497
|
component: () => null,
|
|
408
498
|
props: {},
|
|
409
499
|
});
|
|
410
|
-
|
|
500
|
+
result.current.addInteractableComponent({
|
|
411
501
|
name: "B",
|
|
412
502
|
description: "test",
|
|
413
503
|
component: () => null,
|
|
@@ -418,12 +508,8 @@ describe("TamboInteractableProvider - State Update Tool Registration", () => {
|
|
|
418
508
|
(0, react_1.act)(() => {
|
|
419
509
|
result.current.clearAllInteractableComponents();
|
|
420
510
|
});
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
`update_component_state_${id1}`,
|
|
424
|
-
`update_component_props_${id2}`,
|
|
425
|
-
`update_component_state_${id2}`,
|
|
426
|
-
]));
|
|
511
|
+
// Should unregister tools for both components
|
|
512
|
+
expect(mockUnregisterTools).toHaveBeenCalled();
|
|
427
513
|
});
|
|
428
514
|
});
|
|
429
515
|
//# sourceMappingURL=tambo-interactable-provider.test.js.map
|