@tambo-ai/react 1.2.0 → 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.
Files changed (57) hide show
  1. package/dist/hoc/with-tambo-interactable.d.ts.map +1 -1
  2. package/dist/hoc/with-tambo-interactable.js +11 -2
  3. package/dist/hoc/with-tambo-interactable.js.map +1 -1
  4. package/dist/hoc/with-tambo-interactable.test.js +14 -0
  5. package/dist/hoc/with-tambo-interactable.test.js.map +1 -1
  6. package/dist/providers/tambo-interactable-provider-partial-updates.test.js +2 -0
  7. package/dist/providers/tambo-interactable-provider-partial-updates.test.js.map +1 -1
  8. package/dist/providers/tambo-interactable-provider.d.ts +3 -2
  9. package/dist/providers/tambo-interactable-provider.d.ts.map +1 -1
  10. package/dist/providers/tambo-interactable-provider.js +49 -13
  11. package/dist/providers/tambo-interactable-provider.js.map +1 -1
  12. package/dist/providers/tambo-interactable-provider.test.js +165 -1
  13. package/dist/providers/tambo-interactable-provider.test.js.map +1 -1
  14. package/dist/providers/tambo-registry-provider.d.ts +1 -0
  15. package/dist/providers/tambo-registry-provider.d.ts.map +1 -1
  16. package/dist/providers/tambo-registry-provider.js +19 -0
  17. package/dist/providers/tambo-registry-provider.js.map +1 -1
  18. package/dist/providers/tambo-registry-provider.test.js +47 -0
  19. package/dist/providers/tambo-registry-provider.test.js.map +1 -1
  20. package/dist/v1/__tests__/v1-interactables.test.js +5 -0
  21. package/dist/v1/__tests__/v1-interactables.test.js.map +1 -1
  22. package/dist/v1/components/v1-component-renderer.test.js +1 -0
  23. package/dist/v1/components/v1-component-renderer.test.js.map +1 -1
  24. package/dist/v1/hooks/use-tambo-v1.test.js +1 -0
  25. package/dist/v1/hooks/use-tambo-v1.test.js.map +1 -1
  26. package/dist/v1/providers/tambo-v1-stub-provider.d.ts.map +1 -1
  27. package/dist/v1/providers/tambo-v1-stub-provider.js +1 -0
  28. package/dist/v1/providers/tambo-v1-stub-provider.js.map +1 -1
  29. package/esm/hoc/with-tambo-interactable.d.ts.map +1 -1
  30. package/esm/hoc/with-tambo-interactable.js +11 -2
  31. package/esm/hoc/with-tambo-interactable.js.map +1 -1
  32. package/esm/hoc/with-tambo-interactable.test.js +14 -0
  33. package/esm/hoc/with-tambo-interactable.test.js.map +1 -1
  34. package/esm/providers/tambo-interactable-provider-partial-updates.test.js +2 -0
  35. package/esm/providers/tambo-interactable-provider-partial-updates.test.js.map +1 -1
  36. package/esm/providers/tambo-interactable-provider.d.ts +3 -2
  37. package/esm/providers/tambo-interactable-provider.d.ts.map +1 -1
  38. package/esm/providers/tambo-interactable-provider.js +49 -13
  39. package/esm/providers/tambo-interactable-provider.js.map +1 -1
  40. package/esm/providers/tambo-interactable-provider.test.js +165 -1
  41. package/esm/providers/tambo-interactable-provider.test.js.map +1 -1
  42. package/esm/providers/tambo-registry-provider.d.ts +1 -0
  43. package/esm/providers/tambo-registry-provider.d.ts.map +1 -1
  44. package/esm/providers/tambo-registry-provider.js +19 -0
  45. package/esm/providers/tambo-registry-provider.js.map +1 -1
  46. package/esm/providers/tambo-registry-provider.test.js +47 -0
  47. package/esm/providers/tambo-registry-provider.test.js.map +1 -1
  48. package/esm/v1/__tests__/v1-interactables.test.js +5 -0
  49. package/esm/v1/__tests__/v1-interactables.test.js.map +1 -1
  50. package/esm/v1/components/v1-component-renderer.test.js +1 -0
  51. package/esm/v1/components/v1-component-renderer.test.js.map +1 -1
  52. package/esm/v1/hooks/use-tambo-v1.test.js +1 -0
  53. package/esm/v1/hooks/use-tambo-v1.test.js.map +1 -1
  54. package/esm/v1/providers/tambo-v1-stub-provider.d.ts.map +1 -1
  55. package/esm/v1/providers/tambo-v1-stub-provider.js +1 -0
  56. package/esm/v1/providers/tambo-v1-stub-provider.js.map +1 -1
  57. package/package.json +7 -7
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-interactable-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-interactable-provider.tsx"],"names":[],"mappings":"AAAA,0DAA0D;AAC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5C,QAAQ,CACyB,CACrC,CAAC;AACJ,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,EAAE;IACvC,OAAO,UAAU,CAAC,wBAAwB,CAAC,CAAC;AAC9C,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,GAAG,EAAE;IAClD,MAAM,EAAE,sBAAsB,EAAE,GAAG,oBAAoB,EAAE,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","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 * 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 } = 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 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 }\n }, [interactableComponents, registerTool]);\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((id: string) => {\n setInteractableComponents((prev) => prev.filter((c) => c.id !== id));\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 setInteractableComponents([]);\n }, []);\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,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,KAAK,EAAE,EACZ,aAAa,EAEb,WAAW,EACX,UAAU,EACV,SAAS,EACT,OAAO,EACP,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,gCAAgC,EAAE,MAAM,yDAAyD,CAAC;AAM3G,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAE1E,MAAM,wBAAwB,GAAG,aAAa,CAA2B;IACvE,sBAAsB,EAAE,EAAE;IAC1B,wBAAwB,EAAE,GAAG,EAAE,CAAC,EAAE;IAClC,2BAA2B,EAAE,GAAG,EAAE,GAAE,CAAC;IACrC,gCAAgC,EAAE,GAAG,EAAE,CAAC,EA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C,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","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"]}
@@ -14,9 +14,11 @@ jest.mock("./tambo-context-helpers-provider", () => ({
14
14
  }));
15
15
  // Mock the registry provider
16
16
  const mockRegisterTool = jest.fn();
17
+ const mockUnregisterTools = jest.fn();
17
18
  jest.mock("./tambo-registry-provider", () => ({
18
19
  useTamboRegistry: () => ({
19
20
  registerTool: mockRegisterTool,
21
+ unregisterTools: mockUnregisterTools,
20
22
  }),
21
23
  }));
22
24
  // Mock the context helper creation
@@ -72,7 +74,7 @@ describe("TamboInteractableProvider - State Update Tool Registration", () => {
72
74
  act(() => {
73
75
  componentId = result.current.addInteractableComponent(component);
74
76
  });
75
- // Should register both update_component_ and update_component_state_ tools
77
+ // Should register both update_component_ and update_component_state_ tools via registerToolForComponent
76
78
  const registeredToolNames = mockRegisterTool.mock.calls.map((call) => call[0].name);
77
79
  expect(registeredToolNames).toContain(`update_component_props_${componentId}`);
78
80
  expect(registeredToolNames).toContain(`update_component_state_${componentId}`);
@@ -94,6 +96,33 @@ describe("TamboInteractableProvider - State Update Tool Registration", () => {
94
96
  expect(stateToolCall[0].description).toContain(componentId);
95
97
  expect(stateToolCall[0].description).toContain("MyComponent");
96
98
  });
99
+ it("should allow props update tool to update component props", () => {
100
+ const { result } = renderHook(() => useTamboInteractable(), { wrapper });
101
+ const component = {
102
+ name: "TestComponent",
103
+ description: "A test component",
104
+ component: () => React.createElement("div", null, "Test"),
105
+ props: { title: "original" },
106
+ propsSchema: z.object({ title: z.string() }),
107
+ };
108
+ let componentId = "";
109
+ act(() => {
110
+ componentId = result.current.addInteractableComponent(component);
111
+ });
112
+ // Find the props update tool and call it
113
+ const propsToolCall = mockRegisterTool.mock.calls.find((call) => call[0].name.startsWith("update_component_props_"));
114
+ const toolFn = propsToolCall[0].tool;
115
+ let updateResult = "";
116
+ act(() => {
117
+ updateResult = toolFn({
118
+ componentId,
119
+ newProps: { title: "updated" },
120
+ });
121
+ });
122
+ expect(updateResult).toBe("Updated successfully");
123
+ const comp = result.current.getInteractableComponent(componentId);
124
+ expect(comp?.props.title).toBe("updated");
125
+ });
97
126
  it("should allow state update tool to update multiple state values", () => {
98
127
  const { result } = renderHook(() => useTamboInteractable(), { wrapper });
99
128
  const component = {
@@ -342,5 +371,140 @@ describe("TamboInteractableProvider - State Update Tool Registration", () => {
342
371
  // The newProps property should allow additional properties
343
372
  expect(inputSchema.properties.newProps.additionalProperties).toBe(true);
344
373
  });
374
+ it("should unregister per-component tools when removing a component", () => {
375
+ const wrapper = ({ children }) => (React.createElement(TamboInteractableProvider, null, children));
376
+ const { result } = renderHook(() => useTamboInteractable(), { wrapper });
377
+ const component = {
378
+ name: "Cleanup",
379
+ description: "test",
380
+ component: () => null,
381
+ props: { x: 1 },
382
+ };
383
+ let componentId;
384
+ act(() => {
385
+ componentId = result.current.addInteractableComponent(component);
386
+ });
387
+ mockUnregisterTools.mockClear();
388
+ act(() => {
389
+ result.current.removeInteractableComponent(componentId);
390
+ });
391
+ // Should unregister the per-component tools by name
392
+ expect(mockUnregisterTools).toHaveBeenCalledWith(expect.arrayContaining([
393
+ `update_component_props_${componentId}`,
394
+ `update_component_state_${componentId}`,
395
+ ]));
396
+ });
397
+ it("should unregister global tools when all components are removed", () => {
398
+ const wrapper = ({ children }) => (React.createElement(TamboInteractableProvider, null, children));
399
+ const { result } = renderHook(() => useTamboInteractable(), { wrapper });
400
+ const component = {
401
+ name: "Global",
402
+ description: "test",
403
+ component: () => null,
404
+ props: {},
405
+ };
406
+ let componentId;
407
+ act(() => {
408
+ componentId = result.current.addInteractableComponent(component);
409
+ });
410
+ mockUnregisterTools.mockClear();
411
+ act(() => {
412
+ result.current.removeInteractableComponent(componentId);
413
+ });
414
+ // Should unregister global interactable tools once list is empty
415
+ expect(mockUnregisterTools).toHaveBeenCalledWith(expect.arrayContaining([
416
+ "get_all_interactable_components",
417
+ "get_interactable_component_by_id",
418
+ "remove_interactable_component",
419
+ ]));
420
+ });
421
+ it("should register global tools that return component data", () => {
422
+ const wrapper = ({ children }) => (React.createElement(TamboInteractableProvider, null, children));
423
+ const { result } = renderHook(() => useTamboInteractable(), { wrapper });
424
+ act(() => {
425
+ result.current.addInteractableComponent({
426
+ name: "Widget",
427
+ description: "test widget",
428
+ component: () => null,
429
+ props: { color: "red" },
430
+ });
431
+ });
432
+ // Find the global get_all tool
433
+ const getAllCall = mockRegisterTool.mock.calls.find((call) => call[0].name === "get_all_interactable_components");
434
+ expect(getAllCall).toBeDefined();
435
+ const getAllResult = getAllCall[0].tool();
436
+ expect(getAllResult.components).toHaveLength(1);
437
+ expect(getAllResult.components[0].name).toBe("Widget");
438
+ });
439
+ it("should register global get_by_id tool that finds a component", () => {
440
+ const wrapper = ({ children }) => (React.createElement(TamboInteractableProvider, null, children));
441
+ const { result } = renderHook(() => useTamboInteractable(), { wrapper });
442
+ let componentId;
443
+ act(() => {
444
+ componentId = result.current.addInteractableComponent({
445
+ name: "Widget",
446
+ description: "test",
447
+ component: () => null,
448
+ props: { x: 1 },
449
+ });
450
+ });
451
+ const getByIdCall = mockRegisterTool.mock.calls.find((call) => call[0].name === "get_interactable_component_by_id");
452
+ expect(getByIdCall).toBeDefined();
453
+ const found = getByIdCall[0].tool({ componentId: componentId });
454
+ expect(found.success).toBe(true);
455
+ expect(found.component.componentName).toBe("Widget");
456
+ const notFound = getByIdCall[0].tool({ componentId: "nonexistent" });
457
+ expect(notFound.success).toBe(false);
458
+ expect(notFound.error).toContain("not found");
459
+ });
460
+ it("should register global remove tool that removes a component", () => {
461
+ const wrapper = ({ children }) => (React.createElement(TamboInteractableProvider, null, children));
462
+ const { result } = renderHook(() => useTamboInteractable(), { wrapper });
463
+ let componentId;
464
+ act(() => {
465
+ componentId = result.current.addInteractableComponent({
466
+ name: "Widget",
467
+ description: "test",
468
+ component: () => null,
469
+ props: {},
470
+ });
471
+ });
472
+ const removeCall = mockRegisterTool.mock.calls.find((call) => call[0].name === "remove_interactable_component");
473
+ expect(removeCall).toBeDefined();
474
+ // Remove nonexistent
475
+ const notFound = removeCall[0].tool({ componentId: "nonexistent" });
476
+ expect(notFound.success).toBe(false);
477
+ // Remove existing
478
+ let removeResult;
479
+ act(() => {
480
+ removeResult = removeCall[0].tool({ componentId: componentId });
481
+ });
482
+ expect(removeResult.success).toBe(true);
483
+ expect(removeResult.removedComponent.componentName).toBe("Widget");
484
+ });
485
+ it("should unregister all per-component tools when clearing all components", () => {
486
+ const wrapper = ({ children }) => (React.createElement(TamboInteractableProvider, null, children));
487
+ const { result } = renderHook(() => useTamboInteractable(), { wrapper });
488
+ act(() => {
489
+ result.current.addInteractableComponent({
490
+ name: "A",
491
+ description: "test",
492
+ component: () => null,
493
+ props: {},
494
+ });
495
+ result.current.addInteractableComponent({
496
+ name: "B",
497
+ description: "test",
498
+ component: () => null,
499
+ props: {},
500
+ });
501
+ });
502
+ mockUnregisterTools.mockClear();
503
+ act(() => {
504
+ result.current.clearAllInteractableComponents();
505
+ });
506
+ // Should unregister tools for both components
507
+ expect(mockUnregisterTools).toHaveBeenCalled();
508
+ });
345
509
  });
346
510
  //# sourceMappingURL=tambo-interactable-provider.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-interactable-provider.test.js","sourceRoot":"","sources":["../../src/providers/tambo-interactable-provider.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,+BAA+B,CAAC;AAEvC,2BAA2B;AAC3B,MAAM,oBAAoB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AACvC,MAAM,uBAAuB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AAE1C,IAAI,CAAC,IAAI,CAAC,kCAAkC,EAAE,GAAG,EAAE,CAAC,CAAC;IACnD,2BAA2B,EAAE,CAAC,EAC5B,QAAQ,GAGT,EAAE,EAAE,CAAC,0CAAG,QAAQ,CAAI;IACrB,sBAAsB,EAAE,GAAG,EAAE,CAAC,CAAC;QAC7B,gBAAgB,EAAE,oBAAoB;QACtC,mBAAmB,EAAE,uBAAuB;KAC7C,CAAC;CACH,CAAC,CAAC,CAAC;AAEJ,6BAA6B;AAC7B,MAAM,gBAAgB,GAAG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AC,OAAO,CAAC,wBAAwB,CAAC,SAAS,CAAC,CAAC;QACrD,CAAC,CAAC,CAAC;QAEH,6BAA6B;QAC7B,MAAM,aAAa,GAAG,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CACpD,CAAC,IAAI,EAAE,EAAE,CACP,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC;YAC5C,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAClC,CAAC;QAEF,MAAM,CAAC,aAAa,CAAC,CAAC,WAAW,EAAE,CAAC;QACpC,MAAM,WAAW,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC;QAEjD,2DAA2D;QAC3D,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1E,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { act, renderHook } from \"@testing-library/react\";\nimport React from \"react\";\nimport { z } from \"zod\";\nimport { TamboInteractableComponent } from \"../model/tambo-interactable\";\nimport {\n TamboInteractableProvider,\n useTamboInteractable,\n} from \"./tambo-interactable-provider\";\n\n// Mock the context helpers\nconst mockAddContextHelper = jest.fn();\nconst mockRemoveContextHelper = jest.fn();\n\njest.mock(\"./tambo-context-helpers-provider\", () => ({\n TamboContextHelpersProvider: ({\n children,\n }: {\n children: React.ReactNode;\n }) => <>{children}</>,\n useTamboContextHelpers: () => ({\n addContextHelper: mockAddContextHelper,\n removeContextHelper: mockRemoveContextHelper,\n }),\n}));\n\n// Mock the registry provider\nconst mockRegisterTool = jest.fn();\n\njest.mock(\"./tambo-registry-provider\", () => ({\n useTamboRegistry: () => ({\n registerTool: mockRegisterTool,\n }),\n}));\n\n// Mock the context helper creation\njest.mock(\"../context-helpers/current-interactables-context-helper\", () => ({\n createInteractablesContextHelper: () =>\n jest.fn(() => ({\n name: \"interactables\",\n context: {\n description: \"Test interactables context\",\n components: [],\n },\n })),\n}));\n\ndescribe(\"TamboInteractableProvider - State Tracking\", () => {\n beforeEach(() => {\n jest.clearAllMocks();\n });\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboInteractableProvider>{children}</TamboInteractableProvider>\n );\n\n it(\"should set and get state for a component\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: { title: \"Test\" },\n propsSchema: z.object({ title: z.string() }),\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n act(() => {\n result.current.setInteractableState(componentId, \"count\", 10);\n });\n\n const state = result.current.getInteractableComponentState(componentId);\n expect(state).toEqual({ count: 10 });\n });\n});\n\ndescribe(\"TamboInteractableProvider - State Update Tool Registration\", () => {\n beforeEach(() => {\n jest.clearAllMocks();\n });\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboInteractableProvider>{children}</TamboInteractableProvider>\n );\n\n it(\"should register both prop and state update tools when component is added\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: { title: \"Test\" },\n propsSchema: z.object({ title: z.string() }),\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n // Should register both update_component_ and update_component_state_ tools\n const registeredToolNames = mockRegisterTool.mock.calls.map(\n (call) => call[0].name,\n );\n expect(registeredToolNames).toContain(\n `update_component_props_${componentId}`,\n );\n expect(registeredToolNames).toContain(\n `update_component_state_${componentId}`,\n );\n });\n\n it(\"should register state update tool with correct description\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"MyComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {},\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n const stateToolCall = mockRegisterTool.mock.calls.find((call) =>\n call[0].name.startsWith(\"update_component_state_\"),\n );\n\n expect(stateToolCall).toBeDefined();\n expect(stateToolCall[0].description).toContain(componentId);\n expect(stateToolCall[0].description).toContain(\"MyComponent\");\n });\n\n it(\"should allow state update tool to update multiple state values\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {},\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n // Find the state update tool and call it\n const stateToolCall = mockRegisterTool.mock.calls.find((call) =>\n call[0].name.startsWith(\"update_component_state_\"),\n );\n\n const toolFn = stateToolCall[0].tool;\n\n act(() => {\n toolFn({ componentId, newState: { count: 5, name: \"test\" } });\n });\n\n const state = result.current.getInteractableComponentState(componentId);\n expect(state).toEqual({ count: 5, name: \"test\" });\n });\n\n it(\"should preserve existing state when updating partial state\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {},\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n // Set initial state\n act(() => {\n result.current.setInteractableState(componentId, \"existingKey\", \"value1\");\n });\n\n // Find the state update tool and call it with a new key\n const stateToolCall = mockRegisterTool.mock.calls.find((call) =>\n call[0].name.startsWith(\"update_component_state_\"),\n );\n\n const toolFn = stateToolCall[0].tool;\n\n act(() => {\n toolFn({ componentId, newState: { newKey: \"value2\" } });\n });\n\n const state = result.current.getInteractableComponentState(componentId);\n expect(state).toEqual({ existingKey: \"value1\", newKey: \"value2\" });\n });\n\n it(\"should use stateSchema when provided for tool registration\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const stateSchema = z.object({\n count: z.number(),\n name: z.string(),\n });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {},\n stateSchema,\n };\n\n act(() => {\n result.current.addInteractableComponent(component);\n });\n\n // Find the state update tool\n const stateToolCall = mockRegisterTool.mock.calls.find((call) =>\n call[0].name.startsWith(\"update_component_state_\"),\n );\n\n expect(stateToolCall).toBeDefined();\n // The inputSchema should contain the partial stateSchema\n expect(stateToolCall[0].inputSchema).toBeDefined();\n });\n\n it(\"should return warning when updating state with empty object\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {},\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n // Find the state update tool and call it with empty state\n const stateToolCall = mockRegisterTool.mock.calls.find((call) =>\n call[0].name.startsWith(\"update_component_state_\"),\n );\n\n const toolFn = stateToolCall[0].tool;\n\n let updateResult = \"\";\n act(() => {\n updateResult = toolFn({ componentId, newState: {} });\n });\n\n expect(updateResult).toContain(\"Warning\");\n expect(updateResult).toContain(\"No state values provided\");\n });\n\n it(\"should preserve stateSchema in interactable component\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const stateSchema = z.object({\n count: z.number(),\n });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {},\n stateSchema,\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n const interactable = result.current.getInteractableComponent(componentId);\n expect(interactable?.stateSchema).toBe(stateSchema);\n });\n\n it(\"should convert stateSchema to partial JSON Schema (no required fields)\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const stateSchema = z.object({\n count: z.number(),\n name: z.string(),\n });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {},\n stateSchema,\n };\n\n act(() => {\n result.current.addInteractableComponent(component);\n });\n\n // Find the state update tool\n const stateToolCall = mockRegisterTool.mock.calls.find((call) =>\n call[0].name.startsWith(\"update_component_state_\"),\n );\n\n expect(stateToolCall).toBeDefined();\n const inputSchema = stateToolCall[0].inputSchema;\n\n // The newState property should not have required fields (partial schema)\n expect(inputSchema.properties.newState).toBeDefined();\n expect(inputSchema.properties.newState.required).toBeUndefined();\n // But it should have the properties from the schema\n expect(inputSchema.properties.newState.properties).toBeDefined();\n });\n\n it(\"should use additionalProperties when no stateSchema provided\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {},\n // No stateSchema\n };\n\n act(() => {\n result.current.addInteractableComponent(component);\n });\n\n // Find the state update tool\n const stateToolCall = mockRegisterTool.mock.calls.find((call) =>\n call[0].name.startsWith(\"update_component_state_\"),\n );\n\n expect(stateToolCall).toBeDefined();\n const inputSchema = stateToolCall[0].inputSchema;\n\n // The newState property should allow additional properties\n expect(inputSchema.properties.newState.additionalProperties).toBe(true);\n });\n\n it(\"should convert propsSchema to partial JSON Schema for props update tool\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const propsSchema = z.object({\n title: z.string(),\n count: z.number(),\n });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: { title: \"test\", count: 0 },\n propsSchema,\n };\n\n act(() => {\n result.current.addInteractableComponent(component);\n });\n\n // Find the props update tool (not the state one)\n const propsToolCall = mockRegisterTool.mock.calls.find(\n (call) =>\n call[0].name.startsWith(\"update_component_\") &&\n !call[0].name.includes(\"state\"),\n );\n\n expect(propsToolCall).toBeDefined();\n const inputSchema = propsToolCall[0].inputSchema;\n\n // The newProps property should not have required fields (partial schema)\n expect(inputSchema.properties.newProps).toBeDefined();\n expect(inputSchema.properties.newProps.required).toBeUndefined();\n // But it should have the properties from the schema\n expect(inputSchema.properties.newProps.properties).toBeDefined();\n });\n\n it(\"should register props update tool with tamboStreamableHint true by default\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: { title: \"test\" },\n };\n\n act(() => {\n result.current.addInteractableComponent(component);\n });\n\n const propsToolCall = mockRegisterTool.mock.calls.find((call) =>\n call[0].name.startsWith(\"update_component_props_\"),\n );\n\n expect(propsToolCall).toBeDefined();\n expect(propsToolCall[0].annotations).toEqual(\n expect.objectContaining({ tamboStreamableHint: true }),\n );\n });\n\n it(\"should register state update tool with tamboStreamableHint true by default\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {},\n };\n\n act(() => {\n result.current.addInteractableComponent(component);\n });\n\n const stateToolCall = mockRegisterTool.mock.calls.find((call) =>\n call[0].name.startsWith(\"update_component_state_\"),\n );\n\n expect(stateToolCall).toBeDefined();\n expect(stateToolCall[0].annotations).toEqual(\n expect.objectContaining({ tamboStreamableHint: true }),\n );\n });\n\n it(\"should allow overriding tamboStreamableHint via component annotations\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {},\n annotations: { tamboStreamableHint: false },\n };\n\n act(() => {\n result.current.addInteractableComponent(component);\n });\n\n const propsToolCall = mockRegisterTool.mock.calls.find((call) =>\n call[0].name.startsWith(\"update_component_props_\"),\n );\n const stateToolCall = mockRegisterTool.mock.calls.find((call) =>\n call[0].name.startsWith(\"update_component_state_\"),\n );\n\n expect(propsToolCall[0].annotations).toEqual(\n expect.objectContaining({ tamboStreamableHint: false }),\n );\n expect(stateToolCall[0].annotations).toEqual(\n expect.objectContaining({ tamboStreamableHint: false }),\n );\n });\n\n it(\"should use additionalProperties when no propsSchema provided\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: { title: \"test\" },\n // No propsSchema\n };\n\n act(() => {\n result.current.addInteractableComponent(component);\n });\n\n // Find the props update tool\n const propsToolCall = mockRegisterTool.mock.calls.find(\n (call) =>\n call[0].name.startsWith(\"update_component_\") &&\n !call[0].name.includes(\"state\"),\n );\n\n expect(propsToolCall).toBeDefined();\n const inputSchema = propsToolCall[0].inputSchema;\n\n // The newProps property should allow additional properties\n expect(inputSchema.properties.newProps.additionalProperties).toBe(true);\n });\n});\n"]}
1
+ {"version":3,"file":"tambo-interactable-provider.test.js","sourceRoot":"","sources":["../../src/providers/tambo-interactable-provider.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,+BAA+B,CAAC;AAEvC,2BAA2B;A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,EAAE,CAAC,IAAI;gBACrB,KAAK,EAAE,EAAE;aACV,CAAC,CAAC;YACH,MAAM,CAAC,OAAO,CAAC,wBAAwB,CAAC;gBACtC,IAAI,EAAE,GAAG;gBACT,WAAW,EAAE,MAAM;gBACnB,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI;gBACrB,KAAK,EAAE,EAAE;aACV,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,mBAAmB,CAAC,SAAS,EAAE,CAAC;QAEhC,GAAG,CAAC,GAAG,EAAE;YACP,MAAM,CAAC,OAAO,CAAC,8BAA8B,EAAE,CAAC;QAClD,CAAC,CAAC,CAAC;QAEH,8CAA8C;QAC9C,MAAM,CAAC,mBAAmB,CAAC,CAAC,gBAAgB,EAAE,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { act, renderHook } from \"@testing-library/react\";\nimport React from \"react\";\nimport { z } from \"zod\";\nimport { TamboInteractableComponent } from \"../model/tambo-interactable\";\nimport {\n TamboInteractableProvider,\n useTamboInteractable,\n} from \"./tambo-interactable-provider\";\n\n// Mock the context helpers\nconst mockAddContextHelper = jest.fn();\nconst mockRemoveContextHelper = jest.fn();\n\njest.mock(\"./tambo-context-helpers-provider\", () => ({\n TamboContextHelpersProvider: ({\n children,\n }: {\n children: React.ReactNode;\n }) => <>{children}</>,\n useTamboContextHelpers: () => ({\n addContextHelper: mockAddContextHelper,\n removeContextHelper: mockRemoveContextHelper,\n }),\n}));\n\n// Mock the registry provider\nconst mockRegisterTool = jest.fn();\nconst mockUnregisterTools = jest.fn();\n\njest.mock(\"./tambo-registry-provider\", () => ({\n useTamboRegistry: () => ({\n registerTool: mockRegisterTool,\n unregisterTools: mockUnregisterTools,\n }),\n}));\n\n// Mock the context helper creation\njest.mock(\"../context-helpers/current-interactables-context-helper\", () => ({\n createInteractablesContextHelper: () =>\n jest.fn(() => ({\n name: \"interactables\",\n context: {\n description: \"Test interactables context\",\n components: [],\n },\n })),\n}));\n\ndescribe(\"TamboInteractableProvider - State Tracking\", () => {\n beforeEach(() => {\n jest.clearAllMocks();\n });\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboInteractableProvider>{children}</TamboInteractableProvider>\n );\n\n it(\"should set and get state for a component\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: { title: \"Test\" },\n propsSchema: z.object({ title: z.string() }),\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n act(() => {\n result.current.setInteractableState(componentId, \"count\", 10);\n });\n\n const state = result.current.getInteractableComponentState(componentId);\n expect(state).toEqual({ count: 10 });\n });\n});\n\ndescribe(\"TamboInteractableProvider - State Update Tool Registration\", () => {\n beforeEach(() => {\n jest.clearAllMocks();\n });\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboInteractableProvider>{children}</TamboInteractableProvider>\n );\n\n it(\"should register both prop and state update tools when component is added\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: { title: \"Test\" },\n propsSchema: z.object({ title: z.string() }),\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n // Should register both update_component_ and update_component_state_ tools via registerToolForComponent\n const registeredToolNames = mockRegisterTool.mock.calls.map(\n (call) => call[0].name,\n );\n expect(registeredToolNames).toContain(\n `update_component_props_${componentId}`,\n );\n expect(registeredToolNames).toContain(\n `update_component_state_${componentId}`,\n );\n });\n\n it(\"should register state update tool with correct description\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"MyComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {},\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n const stateToolCall = mockRegisterTool.mock.calls.find((call) =>\n call[0].name.startsWith(\"update_component_state_\"),\n );\n\n expect(stateToolCall).toBeDefined();\n expect(stateToolCall[0].description).toContain(componentId);\n expect(stateToolCall[0].description).toContain(\"MyComponent\");\n });\n\n it(\"should allow props update tool to update component props\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: { title: \"original\" },\n propsSchema: z.object({ title: z.string() }),\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n // Find the props update tool and call it\n const propsToolCall = mockRegisterTool.mock.calls.find((call) =>\n call[0].name.startsWith(\"update_component_props_\"),\n );\n\n const toolFn = propsToolCall[0].tool;\n\n let updateResult = \"\";\n act(() => {\n updateResult = toolFn({\n componentId,\n newProps: { title: \"updated\" },\n });\n });\n\n expect(updateResult).toBe(\"Updated successfully\");\n const comp = result.current.getInteractableComponent(componentId);\n expect(comp?.props.title).toBe(\"updated\");\n });\n\n it(\"should allow state update tool to update multiple state values\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {},\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n // Find the state update tool and call it\n const stateToolCall = mockRegisterTool.mock.calls.find((call) =>\n call[0].name.startsWith(\"update_component_state_\"),\n );\n\n const toolFn = stateToolCall[0].tool;\n\n act(() => {\n toolFn({ componentId, newState: { count: 5, name: \"test\" } });\n });\n\n const state = result.current.getInteractableComponentState(componentId);\n expect(state).toEqual({ count: 5, name: \"test\" });\n });\n\n it(\"should preserve existing state when updating partial state\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {},\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n // Set initial state\n act(() => {\n result.current.setInteractableState(componentId, \"existingKey\", \"value1\");\n });\n\n // Find the state update tool and call it with a new key\n const stateToolCall = mockRegisterTool.mock.calls.find((call) =>\n call[0].name.startsWith(\"update_component_state_\"),\n );\n\n const toolFn = stateToolCall[0].tool;\n\n act(() => {\n toolFn({ componentId, newState: { newKey: \"value2\" } });\n });\n\n const state = result.current.getInteractableComponentState(componentId);\n expect(state).toEqual({ existingKey: \"value1\", newKey: \"value2\" });\n });\n\n it(\"should use stateSchema when provided for tool registration\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const stateSchema = z.object({\n count: z.number(),\n name: z.string(),\n });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {},\n stateSchema,\n };\n\n act(() => {\n result.current.addInteractableComponent(component);\n });\n\n // Find the state update tool\n const stateToolCall = mockRegisterTool.mock.calls.find((call) =>\n call[0].name.startsWith(\"update_component_state_\"),\n );\n\n expect(stateToolCall).toBeDefined();\n // The inputSchema should contain the partial stateSchema\n expect(stateToolCall[0].inputSchema).toBeDefined();\n });\n\n it(\"should return warning when updating state with empty object\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {},\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n // Find the state update tool and call it with empty state\n const stateToolCall = mockRegisterTool.mock.calls.find((call) =>\n call[0].name.startsWith(\"update_component_state_\"),\n );\n\n const toolFn = stateToolCall[0].tool;\n\n let updateResult = \"\";\n act(() => {\n updateResult = toolFn({ componentId, newState: {} });\n });\n\n expect(updateResult).toContain(\"Warning\");\n expect(updateResult).toContain(\"No state values provided\");\n });\n\n it(\"should preserve stateSchema in interactable component\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const stateSchema = z.object({\n count: z.number(),\n });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {},\n stateSchema,\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n const interactable = result.current.getInteractableComponent(componentId);\n expect(interactable?.stateSchema).toBe(stateSchema);\n });\n\n it(\"should convert stateSchema to partial JSON Schema (no required fields)\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const stateSchema = z.object({\n count: z.number(),\n name: z.string(),\n });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {},\n stateSchema,\n };\n\n act(() => {\n result.current.addInteractableComponent(component);\n });\n\n // Find the state update tool\n const stateToolCall = mockRegisterTool.mock.calls.find((call) =>\n call[0].name.startsWith(\"update_component_state_\"),\n );\n\n expect(stateToolCall).toBeDefined();\n const inputSchema = stateToolCall[0].inputSchema;\n\n // The newState property should not have required fields (partial schema)\n expect(inputSchema.properties.newState).toBeDefined();\n expect(inputSchema.properties.newState.required).toBeUndefined();\n // But it should have the properties from the schema\n expect(inputSchema.properties.newState.properties).toBeDefined();\n });\n\n it(\"should use additionalProperties when no stateSchema provided\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {},\n // No stateSchema\n };\n\n act(() => {\n result.current.addInteractableComponent(component);\n });\n\n // Find the state update tool\n const stateToolCall = mockRegisterTool.mock.calls.find((call) =>\n call[0].name.startsWith(\"update_component_state_\"),\n );\n\n expect(stateToolCall).toBeDefined();\n const inputSchema = stateToolCall[0].inputSchema;\n\n // The newState property should allow additional properties\n expect(inputSchema.properties.newState.additionalProperties).toBe(true);\n });\n\n it(\"should convert propsSchema to partial JSON Schema for props update tool\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const propsSchema = z.object({\n title: z.string(),\n count: z.number(),\n });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: { title: \"test\", count: 0 },\n propsSchema,\n };\n\n act(() => {\n result.current.addInteractableComponent(component);\n });\n\n // Find the props update tool (not the state one)\n const propsToolCall = mockRegisterTool.mock.calls.find(\n (call) =>\n call[0].name.startsWith(\"update_component_\") &&\n !call[0].name.includes(\"state\"),\n );\n\n expect(propsToolCall).toBeDefined();\n const inputSchema = propsToolCall[0].inputSchema;\n\n // The newProps property should not have required fields (partial schema)\n expect(inputSchema.properties.newProps).toBeDefined();\n expect(inputSchema.properties.newProps.required).toBeUndefined();\n // But it should have the properties from the schema\n expect(inputSchema.properties.newProps.properties).toBeDefined();\n });\n\n it(\"should register props update tool with tamboStreamableHint true by default\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: { title: \"test\" },\n };\n\n act(() => {\n result.current.addInteractableComponent(component);\n });\n\n const propsToolCall = mockRegisterTool.mock.calls.find((call) =>\n call[0].name.startsWith(\"update_component_props_\"),\n );\n\n expect(propsToolCall).toBeDefined();\n expect(propsToolCall[0].annotations).toEqual(\n expect.objectContaining({ tamboStreamableHint: true }),\n );\n });\n\n it(\"should register state update tool with tamboStreamableHint true by default\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {},\n };\n\n act(() => {\n result.current.addInteractableComponent(component);\n });\n\n const stateToolCall = mockRegisterTool.mock.calls.find((call) =>\n call[0].name.startsWith(\"update_component_state_\"),\n );\n\n expect(stateToolCall).toBeDefined();\n expect(stateToolCall[0].annotations).toEqual(\n expect.objectContaining({ tamboStreamableHint: true }),\n );\n });\n\n it(\"should allow overriding tamboStreamableHint via component annotations\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {},\n annotations: { tamboStreamableHint: false },\n };\n\n act(() => {\n result.current.addInteractableComponent(component);\n });\n\n const propsToolCall = mockRegisterTool.mock.calls.find((call) =>\n call[0].name.startsWith(\"update_component_props_\"),\n );\n const stateToolCall = mockRegisterTool.mock.calls.find((call) =>\n call[0].name.startsWith(\"update_component_state_\"),\n );\n\n expect(propsToolCall[0].annotations).toEqual(\n expect.objectContaining({ tamboStreamableHint: false }),\n );\n expect(stateToolCall[0].annotations).toEqual(\n expect.objectContaining({ tamboStreamableHint: false }),\n );\n });\n\n it(\"should use additionalProperties when no propsSchema provided\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: { title: \"test\" },\n // No propsSchema\n };\n\n act(() => {\n result.current.addInteractableComponent(component);\n });\n\n // Find the props update tool\n const propsToolCall = mockRegisterTool.mock.calls.find(\n (call) =>\n call[0].name.startsWith(\"update_component_\") &&\n !call[0].name.includes(\"state\"),\n );\n\n expect(propsToolCall).toBeDefined();\n const inputSchema = propsToolCall[0].inputSchema;\n\n // The newProps property should allow additional properties\n expect(inputSchema.properties.newProps.additionalProperties).toBe(true);\n });\n\n it(\"should unregister per-component tools when removing a component\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboInteractableProvider>{children}</TamboInteractableProvider>\n );\n\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component = {\n name: \"Cleanup\",\n description: \"test\",\n component: () => null,\n props: { x: 1 },\n };\n\n let componentId: string;\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n mockUnregisterTools.mockClear();\n\n act(() => {\n result.current.removeInteractableComponent(componentId!);\n });\n\n // Should unregister the per-component tools by name\n expect(mockUnregisterTools).toHaveBeenCalledWith(\n expect.arrayContaining([\n `update_component_props_${componentId!}`,\n `update_component_state_${componentId!}`,\n ]),\n );\n });\n\n it(\"should unregister global tools when all components are removed\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboInteractableProvider>{children}</TamboInteractableProvider>\n );\n\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component = {\n name: \"Global\",\n description: \"test\",\n component: () => null,\n props: {},\n };\n\n let componentId: string;\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n mockUnregisterTools.mockClear();\n\n act(() => {\n result.current.removeInteractableComponent(componentId!);\n });\n\n // Should unregister global interactable tools once list is empty\n expect(mockUnregisterTools).toHaveBeenCalledWith(\n expect.arrayContaining([\n \"get_all_interactable_components\",\n \"get_interactable_component_by_id\",\n \"remove_interactable_component\",\n ]),\n );\n });\n\n it(\"should register global tools that return component data\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboInteractableProvider>{children}</TamboInteractableProvider>\n );\n\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n act(() => {\n result.current.addInteractableComponent({\n name: \"Widget\",\n description: \"test widget\",\n component: () => null,\n props: { color: \"red\" },\n });\n });\n\n // Find the global get_all tool\n const getAllCall = mockRegisterTool.mock.calls.find(\n (call) => call[0].name === \"get_all_interactable_components\",\n );\n expect(getAllCall).toBeDefined();\n\n const getAllResult = getAllCall[0].tool();\n expect(getAllResult.components).toHaveLength(1);\n expect(getAllResult.components[0].name).toBe(\"Widget\");\n });\n\n it(\"should register global get_by_id tool that finds a component\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboInteractableProvider>{children}</TamboInteractableProvider>\n );\n\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n let componentId: string;\n act(() => {\n componentId = result.current.addInteractableComponent({\n name: \"Widget\",\n description: \"test\",\n component: () => null,\n props: { x: 1 },\n });\n });\n\n const getByIdCall = mockRegisterTool.mock.calls.find(\n (call) => call[0].name === \"get_interactable_component_by_id\",\n );\n expect(getByIdCall).toBeDefined();\n\n const found = getByIdCall[0].tool({ componentId: componentId! });\n expect(found.success).toBe(true);\n expect(found.component.componentName).toBe(\"Widget\");\n\n const notFound = getByIdCall[0].tool({ componentId: \"nonexistent\" });\n expect(notFound.success).toBe(false);\n expect(notFound.error).toContain(\"not found\");\n });\n\n it(\"should register global remove tool that removes a component\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboInteractableProvider>{children}</TamboInteractableProvider>\n );\n\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n let componentId: string;\n act(() => {\n componentId = result.current.addInteractableComponent({\n name: \"Widget\",\n description: \"test\",\n component: () => null,\n props: {},\n });\n });\n\n const removeCall = mockRegisterTool.mock.calls.find(\n (call) => call[0].name === \"remove_interactable_component\",\n );\n expect(removeCall).toBeDefined();\n\n // Remove nonexistent\n const notFound = removeCall[0].tool({ componentId: \"nonexistent\" });\n expect(notFound.success).toBe(false);\n\n // Remove existing\n let removeResult: any;\n act(() => {\n removeResult = removeCall[0].tool({ componentId: componentId! });\n });\n expect(removeResult.success).toBe(true);\n expect(removeResult.removedComponent.componentName).toBe(\"Widget\");\n });\n\n it(\"should unregister all per-component tools when clearing all components\", () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboInteractableProvider>{children}</TamboInteractableProvider>\n );\n\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n act(() => {\n result.current.addInteractableComponent({\n name: \"A\",\n description: \"test\",\n component: () => null,\n props: {},\n });\n result.current.addInteractableComponent({\n name: \"B\",\n description: \"test\",\n component: () => null,\n props: {},\n });\n });\n\n mockUnregisterTools.mockClear();\n\n act(() => {\n result.current.clearAllInteractableComponents();\n });\n\n // Should unregister tools for both components\n expect(mockUnregisterTools).toHaveBeenCalled();\n });\n});\n"]}
@@ -13,6 +13,7 @@ export interface TamboRegistryContext {
13
13
  registerComponent: (options: TamboComponent, warnOnOverwrite?: boolean) => void;
14
14
  registerTool: RegisterToolFn;
15
15
  registerTools: RegisterToolsFn;
16
+ unregisterTools: (names: string[]) => void;
16
17
  addToolAssociation: (componentName: string, tool: TamboTool) => void;
17
18
  registerMcpServer: (info: McpServerInfo) => void;
18
19
  registerMcpServers: (infos: McpServerInfo[]) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-registry-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-registry-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,0BAA0B,CAAC;AACpD,OAAO,KAAK,EAAE,EAEZ,iBAAiB,EAMlB,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EACV,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,cAAc,EACd,SAAS,EACT,iBAAiB,EAClB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAe/E,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,iBAAiB,CAAC;IACjC,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BAAgB,EAAE,CAAC;IAE/B;;;OAGG;IACH,aAAa,CAAC,EAAE,cAAc,CAAC,eAAe,CAAC,CAAC;IAEhD;;;OAGG;IACH,WAAW,CAAC,EAAE,cAAc,CAAC,aAAa,CAAC,CAAC;IAE5C;;;;;;;OAOG;IACH,sBAAsB,CAAC,EAAE,CACvB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,OAAO,CAAC,iBAAiB,EAAE,KAC9B,OAAO,CAAC,MAAM,CAAC,CAAC;CACtB;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAC1C,iBAAiB,CAAC,0BAA0B,CAAC,CA8N9C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,4BAE5B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,sBAAsB,QAAO,uBAAuB,EAEhE,CAAC"}
1
+ {"version":3,"file":"tambo-registry-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-registry-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,0BAA0B,CAAC;AACpD,OAAO,KAAK,EAAE,EAEZ,iBAAiB,EAMlB,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EACV,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,cAAc,EACd,SAAS,EACT,iBAAiB,EAClB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAe/E,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,iBAAiB,CAAC;IACjC,YAAY,EAAE,iBAAiB,CAAC;IAChC,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACpD,cAAc,EAAE,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CAAC,EAAE,cAAc,CAAC,eAAe,CAAC,CAAC;IAEhD;;;OAGG;IACH,WAAW,CAAC,EAAE,cAAc,CAAC,aAAa,CAAC,CAAC;IAE5C;;;;;;;OAOG;IACH,sBAAsB,CAAC,EAAE,CACvB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,OAAO,CAAC,iBAAiB,EAAE,KAC9B,OAAO,CAAC,MAAM,CAAC,CAAC;CACtB;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAC1C,iBAAiB,CAAC,0BAA0B,CAAC,CA6O9C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,4BAE5B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,sBAAsB,QAAO,uBAAuB,EAEhE,CAAC"}
@@ -22,6 +22,10 @@ export const TamboRegistryContext = createContext({
22
22
  *
23
23
  */
24
24
  registerTools: () => { },
25
+ /**
26
+ *
27
+ */
28
+ unregisterTools: () => { },
25
29
  /**
26
30
  *
27
31
  */
@@ -87,6 +91,20 @@ export const TamboRegistryProvider = ({ children, components: userComponents, to
87
91
  const registerTools = useCallback((tools, warnOnOverwrite = true) => {
88
92
  setToolRegistry((existingRegistry) => tools.reduce(registryWithTool(warnOnOverwrite), existingRegistry));
89
93
  }, [registryWithTool]);
94
+ const unregisterTools = useCallback((names) => {
95
+ if (names.length === 0)
96
+ return;
97
+ const nameSet = new Set(names);
98
+ setToolRegistry((registry) => {
99
+ const next = {};
100
+ for (const [name, tool] of Object.entries(registry)) {
101
+ if (!nameSet.has(name)) {
102
+ next[name] = tool;
103
+ }
104
+ }
105
+ return next;
106
+ });
107
+ }, []);
90
108
  const registerMcpServer = useCallback((info) => {
91
109
  const normalized = normalizeServerInfo(info);
92
110
  setDynamicMcpServerInfos((prev) => [...prev, normalized]);
@@ -198,6 +216,7 @@ export const TamboRegistryProvider = ({ children, components: userComponents, to
198
216
  registerComponent,
199
217
  registerTool,
200
218
  registerTools,
219
+ unregisterTools,
201
220
  addToolAssociation,
202
221
  registerMcpServer,
203
222
  registerMcpServers,