@tambo-ai/react 0.62.0 → 0.63.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/providers/__tests__/tambo-context-attachment-provider.test.d.ts +2 -0
- package/dist/providers/__tests__/tambo-context-attachment-provider.test.d.ts.map +1 -0
- package/dist/providers/__tests__/tambo-context-attachment-provider.test.js +633 -0
- package/dist/providers/__tests__/tambo-context-attachment-provider.test.js.map +1 -0
- package/dist/providers/index.d.ts +1 -0
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +4 -1
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/tambo-context-attachment-provider.d.ts +132 -0
- package/dist/providers/tambo-context-attachment-provider.d.ts.map +1 -0
- package/dist/providers/tambo-context-attachment-provider.js +201 -0
- package/dist/providers/tambo-context-attachment-provider.js.map +1 -0
- package/dist/providers/tambo-provider.d.ts +4 -2
- package/dist/providers/tambo-provider.d.ts.map +1 -1
- package/dist/providers/tambo-provider.js +9 -4
- package/dist/providers/tambo-provider.js.map +1 -1
- package/dist/providers/tambo-stubs.d.ts.map +1 -1
- package/dist/providers/tambo-stubs.js +6 -2
- package/dist/providers/tambo-stubs.js.map +1 -1
- package/esm/index.d.ts +1 -1
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/esm/providers/__tests__/tambo-context-attachment-provider.test.d.ts +2 -0
- package/esm/providers/__tests__/tambo-context-attachment-provider.test.d.ts.map +1 -0
- package/esm/providers/__tests__/tambo-context-attachment-provider.test.js +628 -0
- package/esm/providers/__tests__/tambo-context-attachment-provider.test.js.map +1 -0
- package/esm/providers/index.d.ts +1 -0
- package/esm/providers/index.d.ts.map +1 -1
- package/esm/providers/index.js +1 -0
- package/esm/providers/index.js.map +1 -1
- package/esm/providers/tambo-context-attachment-provider.d.ts +132 -0
- package/esm/providers/tambo-context-attachment-provider.d.ts.map +1 -0
- package/esm/providers/tambo-context-attachment-provider.js +164 -0
- package/esm/providers/tambo-context-attachment-provider.js.map +1 -0
- package/esm/providers/tambo-provider.d.ts +4 -2
- package/esm/providers/tambo-provider.d.ts.map +1 -1
- package/esm/providers/tambo-provider.js +9 -4
- package/esm/providers/tambo-provider.js.map +1 -1
- package/esm/providers/tambo-stubs.d.ts.map +1 -1
- package/esm/providers/tambo-stubs.js +6 -2
- package/esm/providers/tambo-stubs.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tambo-context-attachment-provider.test.js","sourceRoot":"","sources":["../../../src/providers/__tests__/tambo-context-attachment-provider.test.tsx"],"names":[],"mappings":";;;;;AACA,kDAAkE;AAClE,kDAA0B;AAC1B,4FAK8C;AAC9C,sFAG2C;AAE3C;;;;;;;;GAQG;AACH,QAAQ,CAAC,gCAAgC,EAAE,GAAG,EAAE;IAC9C,UAAU,CAAC,GAAG,EAAE;QACd,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH;;;;;OAKG;IACH,MAAM,aAAa,GAAG,CACpB,oBAEmD,EACnD,EAAE;QACF,MAAM,OAAO,GAAG,CAAC,EAAE,QAAQ,EAAiC,EAAE,EAAE,CAAC,CAC/D,8BAAC,4DAA2B;YAC1B,8BAAC,kEAA8B,IAC7B,oBAAoB,EAAE,oBAAoB,IAEzC,QAAQ,CACsB,CACL,CAC/B,CAAC;QACF,OAAO,CAAC,WAAW,GAAG,aAAa,CAAC;QACpC,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC;IAEF,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;QAC3B;;WAEG;QACH,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;YACzD,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,kBAAU,EAAC,GAAG,EAAE,CAAC,IA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C,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAC9B,CAAC;YACF,MAAM,CAAC,oBAAoB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import type { Suggestion } from \"@tambo-ai/typescript-sdk/resources/beta/threads/suggestions\";\nimport { act, renderHook, waitFor } from \"@testing-library/react\";\nimport React from \"react\";\nimport {\n TamboContextAttachmentProvider,\n useTamboContextAttachment,\n type ContextAttachment,\n type ContextHelperData,\n} from \"../tambo-context-attachment-provider\";\nimport {\n TamboContextHelpersProvider,\n useTamboContextHelpers,\n} from \"../tambo-context-helpers-provider\";\n\n/**\n * Test suite for TamboContextAttachmentProvider\n *\n * Tests the context attachment feature which allows:\n * - Visual context badges above message input\n * - Automatic context helper registration/unregistration\n * - Custom suggestions that override auto-generated ones\n * - Dynamic context data customization via getContextHelperData\n */\ndescribe(\"TamboContextAttachmentProvider\", () => {\n beforeEach(() => {\n jest.clearAllMocks();\n });\n\n /**\n * Base wrapper with both TamboContextAttachmentProvider and TamboContextHelpersProvider\n * since context attachments need access to context helpers API\n * @param getContextHelperData - Optional custom function to get context helper data\n * @returns A React component that wraps children with the necessary providers\n */\n const createWrapper = (\n getContextHelperData?: (\n context: ContextAttachment,\n ) => Promise<ContextHelperData> | ContextHelperData,\n ) => {\n const Wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboContextHelpersProvider>\n <TamboContextAttachmentProvider\n getContextHelperData={getContextHelperData}\n >\n {children}\n </TamboContextAttachmentProvider>\n </TamboContextHelpersProvider>\n );\n Wrapper.displayName = \"TestWrapper\";\n return Wrapper;\n };\n\n describe(\"Hook Access\", () => {\n /**\n * Hook should provide all expected API functions when used within provider\n */\n it(\"should provide context attachment API functions\", () => {\n const { result } = renderHook(() => useTamboContextAttachment(), {\n wrapper: createWrapper(),\n });\n\n expect(result.current).toHaveProperty(\"attachments\");\n expect(result.current).toHaveProperty(\"addContextAttachment\");\n expect(result.current).toHaveProperty(\"removeContextAttachment\");\n expect(result.current).toHaveProperty(\"clearContextAttachments\");\n expect(result.current).toHaveProperty(\"customSuggestions\");\n expect(result.current).toHaveProperty(\"setCustomSuggestions\");\n });\n\n /**\n * Hook should throw error when used outside of provider\n */\n it(\"should throw error when used outside provider\", () => {\n // Suppress console.error for this test\n const consoleErrorSpy = jest\n .spyOn(console, \"error\")\n .mockImplementation(() => {});\n\n expect(() => {\n renderHook(() => useTamboContextAttachment());\n }).toThrow(\n \"useTamboContextAttachment must be used within a TamboContextAttachmentProvider\",\n );\n\n consoleErrorSpy.mockRestore();\n });\n });\n\n describe(\"Adding Context Attachments\", () => {\n /**\n * Should add a context attachment with auto-generated ID\n */\n it(\"should add a context attachment\", () => {\n const { result } = renderHook(() => useTamboContextAttachment(), {\n wrapper: createWrapper(),\n });\n\n act(() => {\n result.current.addContextAttachment({\n name: \"Button.tsx\",\n metadata: { filePath: \"/src/Button.tsx\" },\n });\n });\n\n expect(result.current.attachments).toHaveLength(1);\n expect(result.current.attachments[0]).toMatchObject({\n name: \"Button.tsx\",\n metadata: { filePath: \"/src/Button.tsx\" },\n });\n expect(result.current.attachments[0].id).toBeDefined();\n });\n\n /**\n * Should add multiple different attachments\n */\n it(\"should add multiple context attachments\", () => {\n const { result } = renderHook(() => useTamboContextAttachment(), {\n wrapper: createWrapper(),\n });\n\n act(() => {\n result.current.addContextAttachment({\n name: \"Button.tsx\",\n });\n result.current.addContextAttachment({\n name: \"Card.tsx\",\n });\n });\n\n expect(result.current.attachments).toHaveLength(2);\n expect(result.current.attachments[0].name).toBe(\"Button.tsx\");\n expect(result.current.attachments[1].name).toBe(\"Card.tsx\");\n });\n\n /**\n * Should prevent duplicates with the same name\n */\n it(\"should prevent duplicate attachments with same name\", () => {\n const { result } = renderHook(() => useTamboContextAttachment(), {\n wrapper: createWrapper(),\n });\n\n act(() => {\n result.current.addContextAttachment({\n name: \"Button.tsx\",\n });\n result.current.addContextAttachment({\n name: \"Button.tsx\",\n });\n });\n\n expect(result.current.attachments).toHaveLength(1);\n });\n\n /**\n * Should support optional icon property\n */\n it(\"should support icon property\", () => {\n const { result } = renderHook(() => useTamboContextAttachment(), {\n wrapper: createWrapper(),\n });\n\n const icon = <span>📄</span>;\n\n act(() => {\n result.current.addContextAttachment({\n name: \"File.txt\",\n icon,\n });\n });\n\n expect(result.current.attachments[0].icon).toBe(icon);\n });\n });\n\n describe(\"Removing Context Attachments\", () => {\n /**\n * Should remove a specific attachment by ID\n */\n it(\"should remove context attachment by ID\", () => {\n const { result } = renderHook(() => useTamboContextAttachment(), {\n wrapper: createWrapper(),\n });\n\n act(() => {\n result.current.addContextAttachment({\n name: \"Button.tsx\",\n });\n });\n\n expect(result.current.attachments).toHaveLength(1);\n const attachmentId = result.current.attachments[0].id;\n\n act(() => {\n result.current.removeContextAttachment(attachmentId);\n });\n\n expect(result.current.attachments).toHaveLength(0);\n });\n\n /**\n * Should only remove the specified attachment when multiple exist\n */\n it(\"should only remove specified attachment\", () => {\n const { result } = renderHook(() => useTamboContextAttachment(), {\n wrapper: createWrapper(),\n });\n\n act(() => {\n result.current.addContextAttachment({ name: \"First.tsx\" });\n result.current.addContextAttachment({ name: \"Second.tsx\" });\n });\n\n expect(result.current.attachments).toHaveLength(2);\n const firstId = result.current.attachments[0].id;\n\n act(() => {\n result.current.removeContextAttachment(firstId);\n });\n\n expect(result.current.attachments).toHaveLength(1);\n expect(result.current.attachments[0].name).toBe(\"Second.tsx\");\n });\n\n /**\n * Should handle removing non-existent attachment gracefully\n */\n it(\"should handle removing non-existent attachment gracefully\", () => {\n const { result } = renderHook(() => useTamboContextAttachment(), {\n wrapper: createWrapper(),\n });\n\n expect(() => {\n act(() => {\n result.current.removeContextAttachment(\"non-existent-id\");\n });\n }).not.toThrow();\n });\n });\n\n describe(\"Clearing All Attachments\", () => {\n /**\n * Should clear all attachments at once\n */\n it(\"should clear all context attachments\", () => {\n const { result } = renderHook(() => useTamboContextAttachment(), {\n wrapper: createWrapper(),\n });\n\n act(() => {\n result.current.addContextAttachment({ name: \"First.tsx\" });\n result.current.addContextAttachment({ name: \"Second.tsx\" });\n result.current.addContextAttachment({ name: \"Third.tsx\" });\n });\n\n expect(result.current.attachments).toHaveLength(3);\n\n act(() => {\n result.current.clearContextAttachments();\n });\n\n expect(result.current.attachments).toHaveLength(0);\n });\n\n /**\n * Should handle clearing when no attachments exist\n */\n it(\"should handle clearing when no attachments exist\", () => {\n const { result } = renderHook(() => useTamboContextAttachment(), {\n wrapper: createWrapper(),\n });\n\n expect(() => {\n act(() => {\n result.current.clearContextAttachments();\n });\n }).not.toThrow();\n\n expect(result.current.attachments).toHaveLength(0);\n });\n });\n\n describe(\"Context Helpers Integration\", () => {\n /**\n * Should automatically register context helpers when attachments are added\n */\n it(\"should register context helpers for attachments\", async () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboContextHelpersProvider>\n <TamboContextAttachmentProvider>\n {children}\n </TamboContextAttachmentProvider>\n </TamboContextHelpersProvider>\n );\n\n const { result } = renderHook(\n () => ({\n attachment: useTamboContextAttachment(),\n helpers: useTamboContextHelpers(),\n }),\n { wrapper },\n );\n\n // Add attachment\n act(() => {\n result.current.attachment.addContextAttachment({\n name: \"Button.tsx\",\n metadata: { filePath: \"/src/Button.tsx\" },\n });\n });\n\n // Wait for effect to run\n await waitFor(async () => {\n const contexts = await result.current.helpers.getAdditionalContext();\n expect(contexts.length).toBeGreaterThan(0);\n });\n\n const contexts = await result.current.helpers.getAdditionalContext();\n const attachmentContext = contexts.find((c) =>\n c.name.includes(result.current.attachment.attachments[0].id),\n );\n\n expect(attachmentContext).toBeDefined();\n expect(attachmentContext?.context).toHaveProperty(\"selectedComponent\");\n });\n\n /**\n * Should unregister context helpers when attachments are removed\n */\n it(\"should unregister context helpers when attachments are removed\", async () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboContextHelpersProvider>\n <TamboContextAttachmentProvider>\n {children}\n </TamboContextAttachmentProvider>\n </TamboContextHelpersProvider>\n );\n\n const { result } = renderHook(\n () => ({\n attachment: useTamboContextAttachment(),\n helpers: useTamboContextHelpers(),\n }),\n { wrapper },\n );\n\n // Add attachment\n act(() => {\n result.current.attachment.addContextAttachment({\n name: \"Button.tsx\",\n });\n });\n\n // Wait for context helper to be registered\n await waitFor(async () => {\n const contexts = await result.current.helpers.getAdditionalContext();\n expect(contexts.length).toBeGreaterThan(0);\n });\n\n const initialContexts =\n await result.current.helpers.getAdditionalContext();\n const initialCount = initialContexts.length;\n const attachmentId = result.current.attachment.attachments[0].id;\n\n // Remove attachment\n act(() => {\n result.current.attachment.removeContextAttachment(attachmentId);\n });\n\n // Wait for context helper to be unregistered\n await waitFor(async () => {\n const contexts = await result.current.helpers.getAdditionalContext();\n expect(contexts.length).toBeLessThan(initialCount);\n });\n });\n\n /**\n * Should use default context data structure when no custom function provided\n */\n it(\"should use default context data structure\", async () => {\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboContextHelpersProvider>\n <TamboContextAttachmentProvider>\n {children}\n </TamboContextAttachmentProvider>\n </TamboContextHelpersProvider>\n );\n\n const { result } = renderHook(\n () => ({\n attachment: useTamboContextAttachment(),\n helpers: useTamboContextHelpers(),\n }),\n { wrapper },\n );\n\n act(() => {\n result.current.attachment.addContextAttachment({\n name: \"Button.tsx\",\n metadata: { filePath: \"/src/Button.tsx\", type: \"component\" },\n });\n });\n\n await waitFor(async () => {\n const contexts = await result.current.helpers.getAdditionalContext();\n expect(contexts.length).toBeGreaterThan(0);\n });\n\n const contexts = await result.current.helpers.getAdditionalContext();\n const attachmentContext = contexts.find((c) =>\n c.name.includes(result.current.attachment.attachments[0].id),\n );\n\n expect(attachmentContext?.context).toMatchObject({\n selectedComponent: {\n name: \"Button.tsx\",\n instruction: expect.stringContaining(\"Tambo interactable component\"),\n filePath: \"/src/Button.tsx\",\n type: \"component\",\n },\n });\n });\n\n /**\n * Should use custom getContextHelperData function when provided\n */\n it(\"should use custom getContextHelperData function\", async () => {\n const customGetContextHelperData = jest.fn(\n async (context: ContextAttachment) => ({\n selectedFile: {\n name: context.name,\n path: context.metadata?.filePath,\n customField: \"custom value\",\n },\n }),\n );\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboContextHelpersProvider>\n <TamboContextAttachmentProvider\n getContextHelperData={customGetContextHelperData}\n >\n {children}\n </TamboContextAttachmentProvider>\n </TamboContextHelpersProvider>\n );\n\n const { result } = renderHook(\n () => ({\n attachment: useTamboContextAttachment(),\n helpers: useTamboContextHelpers(),\n }),\n { wrapper },\n );\n\n act(() => {\n result.current.attachment.addContextAttachment({\n name: \"Button.tsx\",\n metadata: { filePath: \"/src/Button.tsx\" },\n });\n });\n\n // Wait for context helper to be registered and called\n await waitFor(\n async () => {\n const contexts = await result.current.helpers.getAdditionalContext();\n expect(contexts.length).toBeGreaterThan(0);\n },\n { timeout: 2000 },\n );\n\n expect(customGetContextHelperData).toHaveBeenCalled();\n\n const contexts = await result.current.helpers.getAdditionalContext();\n const attachmentContext = contexts.find((c) =>\n c.name.includes(result.current.attachment.attachments[0].id),\n );\n\n expect(attachmentContext?.context).toEqual({\n selectedFile: {\n name: \"Button.tsx\",\n path: \"/src/Button.tsx\",\n customField: \"custom value\",\n },\n });\n });\n\n /**\n * Should update context helpers when getContextHelperData function changes\n * This tests the bug fix for stale closure issue\n */\n it(\"should update existing context helpers when getContextHelperData changes\", async () => {\n // Create a wrapper component with state to manage the function\n const TestWrapper = ({ children }: { children: React.ReactNode }) => {\n const [version, setVersion] = React.useState(\"v1\");\n\n const getContextHelperData = React.useCallback(\n async (context: ContextAttachment) => ({\n version,\n name: context.name,\n }),\n [version],\n );\n\n // Expose setVersion for the test\n (TestWrapper as any).setVersion = setVersion;\n\n return (\n <TamboContextHelpersProvider>\n <TamboContextAttachmentProvider\n getContextHelperData={getContextHelperData}\n >\n {children}\n </TamboContextAttachmentProvider>\n </TamboContextHelpersProvider>\n );\n };\n\n const { result } = renderHook(\n () => ({\n attachment: useTamboContextAttachment(),\n helpers: useTamboContextHelpers(),\n }),\n { wrapper: TestWrapper },\n );\n\n // Add attachment with first version\n act(() => {\n result.current.attachment.addContextAttachment({\n name: \"Button.tsx\",\n });\n });\n\n // Wait for context helper to be registered\n await waitFor(\n async () => {\n const contexts = await result.current.helpers.getAdditionalContext();\n expect(contexts.length).toBeGreaterThan(0);\n },\n { timeout: 2000 },\n );\n\n // Verify v1 context\n let contexts = await result.current.helpers.getAdditionalContext();\n let attachmentContext = contexts.find((c) =>\n c.name.includes(result.current.attachment.attachments[0].id),\n );\n expect(attachmentContext?.context).toMatchObject({ version: \"v1\" });\n\n // Change the version which will trigger a new getContextHelperData function\n act(() => {\n (TestWrapper as any).setVersion(\"v2\");\n });\n\n // Wait for context to update to v2\n await waitFor(\n async () => {\n const contexts = await result.current.helpers.getAdditionalContext();\n const context = contexts.find((c) =>\n c.name.includes(result.current.attachment.attachments[0].id),\n );\n return context?.context.version === \"v2\";\n },\n { timeout: 2000 },\n );\n\n // Verify v2 context - should be updated, not stale\n contexts = await result.current.helpers.getAdditionalContext();\n attachmentContext = contexts.find((c) =>\n c.name.includes(result.current.attachment.attachments[0].id),\n );\n expect(attachmentContext?.context).toMatchObject({ version: \"v2\" });\n });\n\n /**\n * Should handle errors in getContextHelperData gracefully\n */\n it(\"should handle errors in getContextHelperData gracefully\", async () => {\n const consoleErrorSpy = jest\n .spyOn(console, \"error\")\n .mockImplementation(() => {});\n\n const errorGetData = jest.fn(async () => {\n throw new Error(\"Custom data error\");\n });\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboContextHelpersProvider>\n <TamboContextAttachmentProvider getContextHelperData={errorGetData}>\n {children}\n </TamboContextAttachmentProvider>\n </TamboContextHelpersProvider>\n );\n\n const { result } = renderHook(\n () => ({\n attachment: useTamboContextAttachment(),\n helpers: useTamboContextHelpers(),\n }),\n { wrapper },\n );\n\n act(() => {\n result.current.attachment.addContextAttachment({\n name: \"Button.tsx\",\n });\n });\n\n // Wait for effect to run and try to call the function\n await waitFor(\n () => {\n expect(result.current.attachment.attachments.length).toBeGreaterThan(\n 0,\n );\n },\n { timeout: 2000 },\n );\n\n // Try to get contexts, which will trigger the error\n await result.current.helpers.getAdditionalContext();\n\n expect(errorGetData).toHaveBeenCalled();\n expect(consoleErrorSpy).toHaveBeenCalled();\n\n consoleErrorSpy.mockRestore();\n });\n });\n\n describe(\"Custom Suggestions\", () => {\n /**\n * Should start with null custom suggestions\n */\n it(\"should initialize with null custom suggestions\", () => {\n const { result } = renderHook(() => useTamboContextAttachment(), {\n wrapper: createWrapper(),\n });\n\n expect(result.current.customSuggestions).toBeNull();\n });\n\n /**\n * Should set custom suggestions\n */\n it(\"should set custom suggestions\", () => {\n const { result } = renderHook(() => useTamboContextAttachment(), {\n wrapper: createWrapper(),\n });\n\n const suggestions: Suggestion[] = [\n {\n id: \"1\",\n title: \"Edit component\",\n detailedSuggestion: \"Modify the Button component\",\n messageId: \"\",\n },\n {\n id: \"2\",\n title: \"Add feature\",\n detailedSuggestion: \"Add a new feature\",\n messageId: \"\",\n },\n ];\n\n act(() => {\n result.current.setCustomSuggestions(suggestions);\n });\n\n expect(result.current.customSuggestions).toEqual(suggestions);\n });\n\n /**\n * Should clear custom suggestions by setting to null\n */\n it(\"should clear custom suggestions\", () => {\n const { result } = renderHook(() => useTamboContextAttachment(), {\n wrapper: createWrapper(),\n });\n\n const suggestions: Suggestion[] = [\n {\n id: \"1\",\n title: \"Test\",\n detailedSuggestion: \"Test suggestion\",\n messageId: \"\",\n },\n ];\n\n act(() => {\n result.current.setCustomSuggestions(suggestions);\n });\n\n expect(result.current.customSuggestions).toEqual(suggestions);\n\n act(() => {\n result.current.setCustomSuggestions(null);\n });\n\n expect(result.current.customSuggestions).toBeNull();\n });\n\n /**\n * Should update custom suggestions when changed\n */\n it(\"should update custom suggestions\", () => {\n const { result } = renderHook(() => useTamboContextAttachment(), {\n wrapper: createWrapper(),\n });\n\n const firstSuggestions: Suggestion[] = [\n {\n id: \"1\",\n title: \"First\",\n detailedSuggestion: \"First suggestion\",\n messageId: \"\",\n },\n ];\n\n const secondSuggestions: Suggestion[] = [\n {\n id: \"2\",\n title: \"Second\",\n detailedSuggestion: \"Second suggestion\",\n messageId: \"\",\n },\n ];\n\n act(() => {\n result.current.setCustomSuggestions(firstSuggestions);\n });\n\n expect(result.current.customSuggestions).toEqual(firstSuggestions);\n\n act(() => {\n result.current.setCustomSuggestions(secondSuggestions);\n });\n\n expect(result.current.customSuggestions).toEqual(secondSuggestions);\n });\n });\n\n describe(\"Combined Workflows\", () => {\n /**\n * Should handle adding attachment and setting custom suggestions together\n */\n it(\"should handle attachment and custom suggestions together\", () => {\n const { result } = renderHook(() => useTamboContextAttachment(), {\n wrapper: createWrapper(),\n });\n\n const suggestions: Suggestion[] = [\n {\n id: \"1\",\n title: \"Edit file\",\n detailedSuggestion: \"Edit this file\",\n messageId: \"\",\n },\n ];\n\n act(() => {\n result.current.addContextAttachment({\n name: \"Button.tsx\",\n metadata: { filePath: \"/src/Button.tsx\" },\n });\n result.current.setCustomSuggestions(suggestions);\n });\n\n expect(result.current.attachments).toHaveLength(1);\n expect(result.current.customSuggestions).toEqual(suggestions);\n });\n\n /**\n * Should clear suggestions when clearing attachments\n */\n it(\"should independently manage attachments and suggestions\", () => {\n const { result } = renderHook(() => useTamboContextAttachment(), {\n wrapper: createWrapper(),\n });\n\n const suggestions: Suggestion[] = [\n {\n id: \"1\",\n title: \"Test\",\n detailedSuggestion: \"Test suggestion\",\n messageId: \"\",\n },\n ];\n\n act(() => {\n result.current.addContextAttachment({ name: \"File.tsx\" });\n result.current.setCustomSuggestions(suggestions);\n });\n\n // Clear attachments\n act(() => {\n result.current.clearContextAttachments();\n });\n\n // Suggestions should remain\n expect(result.current.attachments).toHaveLength(0);\n expect(result.current.customSuggestions).toEqual(suggestions);\n\n // Can clear suggestions separately\n act(() => {\n result.current.setCustomSuggestions(null);\n });\n\n expect(result.current.customSuggestions).toBeNull();\n });\n });\n\n describe(\"Cleanup\", () => {\n /**\n * Should cleanup context helpers on unmount\n */\n it(\"should cleanup context helpers on unmount\", async () => {\n // Use a shared provider wrapper so context helpers persist\n const SharedWrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboContextHelpersProvider>{children}</TamboContextHelpersProvider>\n );\n\n // First render with attachment provider\n const { result: attachmentResult, unmount } = renderHook(\n () => ({\n attachment: useTamboContextAttachment(),\n helpers: useTamboContextHelpers(),\n }),\n {\n wrapper: ({ children }) => (\n <SharedWrapper>\n <TamboContextAttachmentProvider>\n {children}\n </TamboContextAttachmentProvider>\n </SharedWrapper>\n ),\n },\n );\n\n // Add attachment\n act(() => {\n attachmentResult.current.attachment.addContextAttachment({\n name: \"Button.tsx\",\n });\n });\n\n const attachmentId =\n attachmentResult.current.attachment.attachments[0].id;\n\n // Wait for context helper to be registered\n await waitFor(async () => {\n const contexts =\n await attachmentResult.current.helpers.getAdditionalContext();\n const hasContext = contexts.some((c) => c.name.includes(attachmentId));\n expect(hasContext).toBe(true);\n });\n\n // Unmount the attachment provider\n unmount();\n\n // Create new hook to check cleanup\n const { result: helpersResult } = renderHook(\n () => useTamboContextHelpers(),\n { wrapper: SharedWrapper },\n );\n\n // Wait a bit for cleanup effect to run\n await new Promise((resolve) => setTimeout(resolve, 100));\n\n const contexts = await helpersResult.current.getAdditionalContext();\n\n // Should not contain the attachment context after unmount\n const hasAttachmentContext = contexts.some((c) =>\n c.name.includes(attachmentId),\n );\n expect(hasAttachmentContext).toBe(false);\n });\n });\n});\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export type { TamboComponent, TamboTool } from "../model/component-metadata";
|
|
2
2
|
export { TamboClientProvider, useIsTamboTokenUpdating, useTamboClient, } from "./tambo-client-provider";
|
|
3
3
|
export { TamboComponentProvider, useTamboComponent, } from "./tambo-component-provider";
|
|
4
|
+
export { TamboContextAttachmentProvider, useTamboContextAttachment, type ContextAttachment, type ContextAttachmentState, type ContextHelperData, type TamboContextAttachmentProviderProps, } from "./tambo-context-attachment-provider";
|
|
4
5
|
export { TamboContextHelpersProvider, useTamboContextHelpers, type TamboContextHelpersContextProps, type TamboContextHelpersProviderProps, } from "./tambo-context-helpers-provider";
|
|
5
6
|
export { Pending, Streaming, Success, TamboPropStreamProvider, useTamboStream, } from "./tambo-prop-stream-provider";
|
|
6
7
|
export type { StreamStateComponentProps, StreamStatus, TamboPropStreamContextValue, } from "./tambo-prop-stream-provider";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAC7E,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,GACf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,2BAA2B,EAC3B,sBAAsB,EACtB,KAAK,+BAA+B,EACpC,KAAK,gCAAgC,GACtC,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,OAAO,EACP,SAAS,EACT,OAAO,EACP,uBAAuB,EACvB,cAAc,GACf,MAAM,8BAA8B,CAAC;AACtC,YAAY,EACV,yBAAyB,EACzB,YAAY,EACZ,2BAA2B,GAC5B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,KAAK,oBAAoB,GAC1B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,KAAK,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAC/E,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EACnB,KAAK,4BAA4B,GAClC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,EACd,KAAK,wBAAwB,GAC9B,MAAM,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAC7E,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,GACf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,8BAA8B,EAC9B,yBAAyB,EACzB,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACtB,KAAK,mCAAmC,GACzC,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,2BAA2B,EAC3B,sBAAsB,EACtB,KAAK,+BAA+B,EACpC,KAAK,gCAAgC,GACtC,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,OAAO,EACP,SAAS,EACT,OAAO,EACP,uBAAuB,EACvB,cAAc,GACf,MAAM,8BAA8B,CAAC;AACtC,YAAY,EACV,yBAAyB,EACzB,YAAY,EACZ,2BAA2B,GAC5B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,KAAK,oBAAoB,GAC1B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,KAAK,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAC/E,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EACnB,KAAK,4BAA4B,GAClC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,EACd,KAAK,wBAAwB,GAC9B,MAAM,yBAAyB,CAAC"}
|
package/dist/providers/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useTamboThread = exports.useTamboGenerationStage = exports.TamboThreadProvider = exports.TamboThreadContext = exports.useTamboThreadInput = exports.TamboThreadInputProvider = exports.TamboStubProvider = exports.useTamboRegistry = exports.TamboRegistryProvider = exports.useTambo = exports.TamboProvider = exports.TamboContext = exports.useTamboStream = exports.TamboPropStreamProvider = exports.Success = exports.Streaming = exports.Pending = exports.useTamboContextHelpers = exports.TamboContextHelpersProvider = exports.useTamboComponent = exports.TamboComponentProvider = exports.useTamboClient = exports.useIsTamboTokenUpdating = exports.TamboClientProvider = void 0;
|
|
3
|
+
exports.useTamboThread = exports.useTamboGenerationStage = exports.TamboThreadProvider = exports.TamboThreadContext = exports.useTamboThreadInput = exports.TamboThreadInputProvider = exports.TamboStubProvider = exports.useTamboRegistry = exports.TamboRegistryProvider = exports.useTambo = exports.TamboProvider = exports.TamboContext = exports.useTamboStream = exports.TamboPropStreamProvider = exports.Success = exports.Streaming = exports.Pending = exports.useTamboContextHelpers = exports.TamboContextHelpersProvider = exports.useTamboContextAttachment = exports.TamboContextAttachmentProvider = exports.useTamboComponent = exports.TamboComponentProvider = exports.useTamboClient = exports.useIsTamboTokenUpdating = exports.TamboClientProvider = void 0;
|
|
4
4
|
var tambo_client_provider_1 = require("./tambo-client-provider");
|
|
5
5
|
Object.defineProperty(exports, "TamboClientProvider", { enumerable: true, get: function () { return tambo_client_provider_1.TamboClientProvider; } });
|
|
6
6
|
Object.defineProperty(exports, "useIsTamboTokenUpdating", { enumerable: true, get: function () { return tambo_client_provider_1.useIsTamboTokenUpdating; } });
|
|
@@ -8,6 +8,9 @@ Object.defineProperty(exports, "useTamboClient", { enumerable: true, get: functi
|
|
|
8
8
|
var tambo_component_provider_1 = require("./tambo-component-provider");
|
|
9
9
|
Object.defineProperty(exports, "TamboComponentProvider", { enumerable: true, get: function () { return tambo_component_provider_1.TamboComponentProvider; } });
|
|
10
10
|
Object.defineProperty(exports, "useTamboComponent", { enumerable: true, get: function () { return tambo_component_provider_1.useTamboComponent; } });
|
|
11
|
+
var tambo_context_attachment_provider_1 = require("./tambo-context-attachment-provider");
|
|
12
|
+
Object.defineProperty(exports, "TamboContextAttachmentProvider", { enumerable: true, get: function () { return tambo_context_attachment_provider_1.TamboContextAttachmentProvider; } });
|
|
13
|
+
Object.defineProperty(exports, "useTamboContextAttachment", { enumerable: true, get: function () { return tambo_context_attachment_provider_1.useTamboContextAttachment; } });
|
|
11
14
|
var tambo_context_helpers_provider_1 = require("./tambo-context-helpers-provider");
|
|
12
15
|
Object.defineProperty(exports, "TamboContextHelpersProvider", { enumerable: true, get: function () { return tambo_context_helpers_provider_1.TamboContextHelpersProvider; } });
|
|
13
16
|
Object.defineProperty(exports, "useTamboContextHelpers", { enumerable: true, get: function () { return tambo_context_helpers_provider_1.useTamboContextHelpers; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":";;;AACA,iEAIiC;AAH/B,4HAAA,mBAAmB,OAAA;AACnB,gIAAA,uBAAuB,OAAA;AACvB,uHAAA,cAAc,OAAA;AAEhB,uEAGoC;AAFlC,kIAAA,sBAAsB,OAAA;AACtB,6HAAA,iBAAiB,OAAA;AAEnB,mFAK0C;AAJxC,6IAAA,2BAA2B,OAAA;AAC3B,wIAAA,sBAAsB,OAAA;AAIxB,2EAMsC;AALpC,qHAAA,OAAO,OAAA;AACP,uHAAA,SAAS,OAAA;AACT,qHAAA,OAAO,OAAA;AACP,qIAAA,uBAAuB,OAAA;AACvB,4HAAA,cAAc,OAAA;AAOhB,mDAAyE;AAAhE,8GAAA,YAAY,OAAA;AAAE,+GAAA,aAAa,OAAA;AAAE,0GAAA,QAAQ,OAAA;AAC9C,qEAImC;AAHjC,gIAAA,qBAAqB,OAAA;AACrB,2HAAA,gBAAgB,OAAA;AAGlB,6CAA+E;AAAtE,gHAAA,iBAAiB,OAAA;AAC1B,6EAIuC;AAHrC,uIAAA,wBAAwB,OAAA;AACxB,kIAAA,mBAAmB,OAAA;AAGrB,iEAMiC;AAL/B,2HAAA,kBAAkB,OAAA;AAClB,4HAAA,mBAAmB,OAAA;AACnB,gIAAA,uBAAuB,OAAA;AACvB,uHAAA,cAAc,OAAA","sourcesContent":["export type { TamboComponent, TamboTool } from \"../model/component-metadata\";\nexport {\n TamboClientProvider,\n useIsTamboTokenUpdating,\n useTamboClient,\n} from \"./tambo-client-provider\";\nexport {\n TamboComponentProvider,\n useTamboComponent,\n} from \"./tambo-component-provider\";\nexport {\n TamboContextHelpersProvider,\n useTamboContextHelpers,\n type TamboContextHelpersContextProps,\n type TamboContextHelpersProviderProps,\n} from \"./tambo-context-helpers-provider\";\nexport {\n Pending,\n Streaming,\n Success,\n TamboPropStreamProvider,\n useTamboStream,\n} from \"./tambo-prop-stream-provider\";\nexport type {\n StreamStateComponentProps,\n StreamStatus,\n TamboPropStreamContextValue,\n} from \"./tambo-prop-stream-provider\";\nexport { TamboContext, TamboProvider, useTambo } from \"./tambo-provider\";\nexport {\n TamboRegistryProvider,\n useTamboRegistry,\n type TamboRegistryContext,\n} from \"./tambo-registry-provider\";\nexport { TamboStubProvider, type TamboStubProviderProps } from \"./tambo-stubs\";\nexport {\n TamboThreadInputProvider,\n useTamboThreadInput,\n type TamboThreadInputContextProps,\n} from \"./tambo-thread-input-provider\";\nexport {\n TamboThreadContext,\n TamboThreadProvider,\n useTamboGenerationStage,\n useTamboThread,\n type TamboThreadProviderProps,\n} from \"./tambo-thread-provider\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":";;;AACA,iEAIiC;AAH/B,4HAAA,mBAAmB,OAAA;AACnB,gIAAA,uBAAuB,OAAA;AACvB,uHAAA,cAAc,OAAA;AAEhB,uEAGoC;AAFlC,kIAAA,sBAAsB,OAAA;AACtB,6HAAA,iBAAiB,OAAA;AAEnB,yFAO6C;AAN3C,mJAAA,8BAA8B,OAAA;AAC9B,8IAAA,yBAAyB,OAAA;AAM3B,mFAK0C;AAJxC,6IAAA,2BAA2B,OAAA;AAC3B,wIAAA,sBAAsB,OAAA;AAIxB,2EAMsC;AALpC,qHAAA,OAAO,OAAA;AACP,uHAAA,SAAS,OAAA;AACT,qHAAA,OAAO,OAAA;AACP,qIAAA,uBAAuB,OAAA;AACvB,4HAAA,cAAc,OAAA;AAOhB,mDAAyE;AAAhE,8GAAA,YAAY,OAAA;AAAE,+GAAA,aAAa,OAAA;AAAE,0GAAA,QAAQ,OAAA;AAC9C,qEAImC;AAHjC,gIAAA,qBAAqB,OAAA;AACrB,2HAAA,gBAAgB,OAAA;AAGlB,6CAA+E;AAAtE,gHAAA,iBAAiB,OAAA;AAC1B,6EAIuC;AAHrC,uIAAA,wBAAwB,OAAA;AACxB,kIAAA,mBAAmB,OAAA;AAGrB,iEAMiC;AAL/B,2HAAA,kBAAkB,OAAA;AAClB,4HAAA,mBAAmB,OAAA;AACnB,gIAAA,uBAAuB,OAAA;AACvB,uHAAA,cAAc,OAAA","sourcesContent":["export type { TamboComponent, TamboTool } from \"../model/component-metadata\";\nexport {\n TamboClientProvider,\n useIsTamboTokenUpdating,\n useTamboClient,\n} from \"./tambo-client-provider\";\nexport {\n TamboComponentProvider,\n useTamboComponent,\n} from \"./tambo-component-provider\";\nexport {\n TamboContextAttachmentProvider,\n useTamboContextAttachment,\n type ContextAttachment,\n type ContextAttachmentState,\n type ContextHelperData,\n type TamboContextAttachmentProviderProps,\n} from \"./tambo-context-attachment-provider\";\nexport {\n TamboContextHelpersProvider,\n useTamboContextHelpers,\n type TamboContextHelpersContextProps,\n type TamboContextHelpersProviderProps,\n} from \"./tambo-context-helpers-provider\";\nexport {\n Pending,\n Streaming,\n Success,\n TamboPropStreamProvider,\n useTamboStream,\n} from \"./tambo-prop-stream-provider\";\nexport type {\n StreamStateComponentProps,\n StreamStatus,\n TamboPropStreamContextValue,\n} from \"./tambo-prop-stream-provider\";\nexport { TamboContext, TamboProvider, useTambo } from \"./tambo-provider\";\nexport {\n TamboRegistryProvider,\n useTamboRegistry,\n type TamboRegistryContext,\n} from \"./tambo-registry-provider\";\nexport { TamboStubProvider, type TamboStubProviderProps } from \"./tambo-stubs\";\nexport {\n TamboThreadInputProvider,\n useTamboThreadInput,\n type TamboThreadInputContextProps,\n} from \"./tambo-thread-input-provider\";\nexport {\n TamboThreadContext,\n TamboThreadProvider,\n useTamboGenerationStage,\n useTamboThread,\n type TamboThreadProviderProps,\n} from \"./tambo-thread-provider\";\n"]}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import type { Suggestion } from "@tambo-ai/typescript-sdk/resources/beta/threads/suggestions";
|
|
2
|
+
import React from "react";
|
|
3
|
+
/**
|
|
4
|
+
* Represents a context attachment that can be displayed in MessageInputContexts.
|
|
5
|
+
* Context attachments appear as badges above the message input and provide additional
|
|
6
|
+
* information to the AI about what to focus on.
|
|
7
|
+
* @property {string} name - Display name shown in the badge
|
|
8
|
+
* @property {React.ReactNode} [icon] - Optional icon to display in the badge
|
|
9
|
+
* @property {Record<string, unknown>} [metadata] - Additional data passed to the AI
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* const context: ContextAttachment = {
|
|
13
|
+
* name: "Button.tsx",
|
|
14
|
+
* icon: <FileIcon />,
|
|
15
|
+
* metadata: { filePath: "/src/components/Button.tsx" }
|
|
16
|
+
* };
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export interface ContextAttachment {
|
|
20
|
+
id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
icon?: React.ReactNode;
|
|
23
|
+
metadata?: Record<string, unknown>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Represents the data structure returned by a context helper
|
|
27
|
+
*/
|
|
28
|
+
export type ContextHelperData = Record<string, unknown>;
|
|
29
|
+
/**
|
|
30
|
+
* Context state interface for managing context attachments and custom suggestions.
|
|
31
|
+
* @property {ContextAttachment[]} attachments - Array of active context attachments (badges above message input)
|
|
32
|
+
* @property {(context: Omit<ContextAttachment, "id">) => void} addContextAttachment - Add a new context attachment
|
|
33
|
+
* @property {(id: string) => void} removeContextAttachment - Remove a context attachment by ID
|
|
34
|
+
* @property {() => void} clearContextAttachments - Remove all context attachments - This is used to clear the context when the user submits a message
|
|
35
|
+
* @property {Suggestion[] | null} customSuggestions - Custom suggestions to display instead of auto-generated ones
|
|
36
|
+
* @property {(suggestions: Suggestion[] | null) => void} setCustomSuggestions - Set or clear custom suggestions
|
|
37
|
+
*/
|
|
38
|
+
export interface ContextAttachmentState {
|
|
39
|
+
attachments: ContextAttachment[];
|
|
40
|
+
addContextAttachment: (context: Omit<ContextAttachment, "id">) => void;
|
|
41
|
+
removeContextAttachment: (id: string) => void;
|
|
42
|
+
clearContextAttachments: () => void;
|
|
43
|
+
customSuggestions: Suggestion[] | null;
|
|
44
|
+
setCustomSuggestions: (suggestions: Suggestion[] | null) => void;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Props for the TamboContextAttachmentProvider.
|
|
48
|
+
* @property {(context: ContextAttachment) => Promise<ContextHelperData> | ContextHelperData} [getContextHelperData] - Optional function to customize the data sent to the AI for each context. If not provided, uses a default structure with the context name and instruction.
|
|
49
|
+
* @example
|
|
50
|
+
* ```tsx
|
|
51
|
+
* <TamboContextAttachmentProvider
|
|
52
|
+
* getContextHelperData={(context) => ({
|
|
53
|
+
* selectedFile: {
|
|
54
|
+
* name: context.name,
|
|
55
|
+
* path: context.metadata?.filePath,
|
|
56
|
+
* instruction: "Focus on this file"
|
|
57
|
+
* }
|
|
58
|
+
* })}
|
|
59
|
+
* >
|
|
60
|
+
* {children}
|
|
61
|
+
* </TamboContextAttachmentProvider>
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export interface TamboContextAttachmentProviderProps {
|
|
65
|
+
children?: React.ReactNode;
|
|
66
|
+
getContextHelperData?: (context: ContextAttachment) => Promise<ContextHelperData> | ContextHelperData;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Provider that enables context attachment features and custom suggestions in MessageInput.
|
|
70
|
+
* **When to use:**
|
|
71
|
+
* - **Included by default** in TamboProvider - no need to wrap separately
|
|
72
|
+
* - Use `useTamboContextAttachment()` hook to manage context attachments
|
|
73
|
+
* **What it does:**
|
|
74
|
+
* - Manages context items that appear as badges above MessageInput
|
|
75
|
+
* - Syncs context data with Tambo's AI for better responses
|
|
76
|
+
* - Manages custom suggestions that replace auto-generated suggestions
|
|
77
|
+
* - Allows components to add/remove contexts via `useTamboContextAttachment()`
|
|
78
|
+
* - Allows components to set custom suggestions via `setCustomSuggestions()`
|
|
79
|
+
* @param props - The props for the TamboContextAttachmentProvider
|
|
80
|
+
* @param props.children - The children to wrap
|
|
81
|
+
* @param props.getContextHelperData - The function to get the context helper data
|
|
82
|
+
* @returns The TamboContextAttachmentProvider component
|
|
83
|
+
* @example
|
|
84
|
+
* Basic usage - already included in TamboProvider
|
|
85
|
+
* ```tsx
|
|
86
|
+
* <TamboProvider apiKey="...">
|
|
87
|
+
* <App />
|
|
88
|
+
* </TamboProvider>
|
|
89
|
+
* ```
|
|
90
|
+
* @example
|
|
91
|
+
* Using TamboProvider with custom context data
|
|
92
|
+
* ```tsx
|
|
93
|
+
* <TamboProvider
|
|
94
|
+
* apiKey="..."
|
|
95
|
+
* getContextHelperData={(context) => ({
|
|
96
|
+
* selectedComponent: {
|
|
97
|
+
* name: context.name,
|
|
98
|
+
* filePath: context.metadata?.path,
|
|
99
|
+
* instruction: "Edit this component"
|
|
100
|
+
* }
|
|
101
|
+
* })}
|
|
102
|
+
* >
|
|
103
|
+
* <App />
|
|
104
|
+
* </TamboProvider>
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
export declare function TamboContextAttachmentProvider({ children, getContextHelperData, }: TamboContextAttachmentProviderProps): React.JSX.Element;
|
|
108
|
+
/**
|
|
109
|
+
* Hook to access context attachment state and methods.
|
|
110
|
+
* **Must be used within a `TamboProvider`** - throws an error otherwise.
|
|
111
|
+
* @throws {Error} If used outside of TamboProvider
|
|
112
|
+
* @returns The context attachment state and methods
|
|
113
|
+
* @example
|
|
114
|
+
* ```tsx
|
|
115
|
+
* const contextAttachment = useTamboContextAttachment();
|
|
116
|
+
*
|
|
117
|
+
* // Add a context
|
|
118
|
+
* contextAttachment.addContextAttachment({
|
|
119
|
+
* name: "Button.tsx",
|
|
120
|
+
* icon: <FileIcon />,
|
|
121
|
+
* metadata: { path: "/src/Button.tsx" }
|
|
122
|
+
* });
|
|
123
|
+
*
|
|
124
|
+
* // Remove a context
|
|
125
|
+
* contextAttachment.removeContextAttachment(contextId);
|
|
126
|
+
*
|
|
127
|
+
* // Set custom suggestions
|
|
128
|
+
* contextAttachment.setCustomSuggestions([{ id: "1", title: "Add Feature" }]);
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
export declare function useTamboContextAttachment(): ContextAttachmentState;
|
|
132
|
+
//# sourceMappingURL=tambo-context-attachment-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tambo-context-attachment-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-context-attachment-provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6DAA6D,CAAC;AAC9F,OAAO,KAQN,MAAM,OAAO,CAAC;AAGf;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAExD;;;;;;;;GAQG;AACH,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,iBAAiB,EAAE,CAAC;IACjC,oBAAoB,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,iBAAiB,EAAE,IAAI,CAAC,KAAK,IAAI,CAAC;IACvE,uBAAuB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,uBAAuB,EAAE,MAAM,IAAI,CAAC;IACpC,iBAAiB,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;IACvC,oBAAoB,EAAE,CAAC,WAAW,EAAE,UAAU,EAAE,GAAG,IAAI,KAAK,IAAI,CAAC;CAClE;AAMD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,mCAAmC;IAClD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,oBAAoB,CAAC,EAAE,CACrB,OAAO,EAAE,iBAAiB,KACvB,OAAO,CAAC,iBAAiB,CAAC,GAAG,iBAAiB,CAAC;CACrD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,8BAA8B,CAAC,EAC7C,QAAQ,EACR,oBAAoB,GACrB,EAAE,mCAAmC,qBAsHrC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,yBAAyB,2BAQxC"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.TamboContextAttachmentProvider = TamboContextAttachmentProvider;
|
|
38
|
+
exports.useTamboContextAttachment = useTamboContextAttachment;
|
|
39
|
+
const react_1 = __importStar(require("react"));
|
|
40
|
+
const tambo_context_helpers_provider_1 = require("./tambo-context-helpers-provider");
|
|
41
|
+
const ContextAttachmentContext = (0, react_1.createContext)(null);
|
|
42
|
+
/**
|
|
43
|
+
* Provider that enables context attachment features and custom suggestions in MessageInput.
|
|
44
|
+
* **When to use:**
|
|
45
|
+
* - **Included by default** in TamboProvider - no need to wrap separately
|
|
46
|
+
* - Use `useTamboContextAttachment()` hook to manage context attachments
|
|
47
|
+
* **What it does:**
|
|
48
|
+
* - Manages context items that appear as badges above MessageInput
|
|
49
|
+
* - Syncs context data with Tambo's AI for better responses
|
|
50
|
+
* - Manages custom suggestions that replace auto-generated suggestions
|
|
51
|
+
* - Allows components to add/remove contexts via `useTamboContextAttachment()`
|
|
52
|
+
* - Allows components to set custom suggestions via `setCustomSuggestions()`
|
|
53
|
+
* @param props - The props for the TamboContextAttachmentProvider
|
|
54
|
+
* @param props.children - The children to wrap
|
|
55
|
+
* @param props.getContextHelperData - The function to get the context helper data
|
|
56
|
+
* @returns The TamboContextAttachmentProvider component
|
|
57
|
+
* @example
|
|
58
|
+
* Basic usage - already included in TamboProvider
|
|
59
|
+
* ```tsx
|
|
60
|
+
* <TamboProvider apiKey="...">
|
|
61
|
+
* <App />
|
|
62
|
+
* </TamboProvider>
|
|
63
|
+
* ```
|
|
64
|
+
* @example
|
|
65
|
+
* Using TamboProvider with custom context data
|
|
66
|
+
* ```tsx
|
|
67
|
+
* <TamboProvider
|
|
68
|
+
* apiKey="..."
|
|
69
|
+
* getContextHelperData={(context) => ({
|
|
70
|
+
* selectedComponent: {
|
|
71
|
+
* name: context.name,
|
|
72
|
+
* filePath: context.metadata?.path,
|
|
73
|
+
* instruction: "Edit this component"
|
|
74
|
+
* }
|
|
75
|
+
* })}
|
|
76
|
+
* >
|
|
77
|
+
* <App />
|
|
78
|
+
* </TamboProvider>
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
function TamboContextAttachmentProvider({ children, getContextHelperData, }) {
|
|
82
|
+
const [attachments, setAttachments] = (0, react_1.useState)([]);
|
|
83
|
+
const [customSuggestions, setCustomSuggestions] = (0, react_1.useState)(null);
|
|
84
|
+
const { addContextHelper, removeContextHelper } = (0, tambo_context_helpers_provider_1.useTamboContextHelpers)();
|
|
85
|
+
// Track which context helpers have been registered to avoid duplicates
|
|
86
|
+
const registeredIdsRef = (0, react_1.useRef)(new Set());
|
|
87
|
+
const prevGetContextHelperDataRef = (0, react_1.useRef)();
|
|
88
|
+
// Sync context helpers with attachments using useEffect
|
|
89
|
+
(0, react_1.useEffect)(() => {
|
|
90
|
+
const currentIds = new Set(attachments.map((a) => a.id));
|
|
91
|
+
const registeredIds = registeredIdsRef.current;
|
|
92
|
+
// Remove context helpers that are no longer in attachments
|
|
93
|
+
registeredIds.forEach((id) => {
|
|
94
|
+
if (!currentIds.has(id)) {
|
|
95
|
+
removeContextHelper(id);
|
|
96
|
+
registeredIds.delete(id);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
const getDataChanged = prevGetContextHelperDataRef.current !== getContextHelperData;
|
|
100
|
+
// Add or replace context helpers for attachments
|
|
101
|
+
attachments.forEach((context) => {
|
|
102
|
+
if (getDataChanged || !registeredIds.has(context.id)) {
|
|
103
|
+
addContextHelper(context.id, async () => {
|
|
104
|
+
if (getContextHelperData) {
|
|
105
|
+
return await getContextHelperData(context);
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
selectedComponent: {
|
|
109
|
+
name: context.name,
|
|
110
|
+
instruction: "This is a Tambo interactable component that is currently selected and visible on the dashboard. You can read its current props and state, and update it by modifying its props. If multiple components are attached, you can interact with and modify any of them. Use the auto-registered interactable component tools (like get_interactable_component_by_id and update_interactable_component_<id>) to view and update the component's state.",
|
|
111
|
+
...(context.metadata ?? {}),
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
registeredIds.add(context.id);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
prevGetContextHelperDataRef.current = getContextHelperData;
|
|
119
|
+
}, [
|
|
120
|
+
attachments,
|
|
121
|
+
addContextHelper,
|
|
122
|
+
removeContextHelper,
|
|
123
|
+
getContextHelperData,
|
|
124
|
+
]);
|
|
125
|
+
// Cleanup: remove all context helpers on unmount
|
|
126
|
+
(0, react_1.useEffect)(() => {
|
|
127
|
+
const registeredIds = registeredIdsRef.current;
|
|
128
|
+
return () => {
|
|
129
|
+
registeredIds.forEach((id) => {
|
|
130
|
+
removeContextHelper(id);
|
|
131
|
+
});
|
|
132
|
+
registeredIds.clear();
|
|
133
|
+
};
|
|
134
|
+
}, [removeContextHelper]);
|
|
135
|
+
const addContextAttachment = (0, react_1.useCallback)((context) => {
|
|
136
|
+
setAttachments((prev) => {
|
|
137
|
+
if (prev.some((c) => c.name === context.name))
|
|
138
|
+
return prev;
|
|
139
|
+
if (typeof crypto === "undefined" || !("randomUUID" in crypto)) {
|
|
140
|
+
throw new Error("crypto.randomUUID() is not available. This usually happens when using an IP address instead of 'localhost' in development. Use 'localhost' or a secure context (HTTPS) to enable crypto APIs.");
|
|
141
|
+
}
|
|
142
|
+
const newId = crypto.randomUUID();
|
|
143
|
+
const newContext = { ...context, id: newId };
|
|
144
|
+
return [...prev, newContext];
|
|
145
|
+
});
|
|
146
|
+
}, []);
|
|
147
|
+
// This is used to remove a context when the user clicks the remove button
|
|
148
|
+
const removeContextAttachment = (0, react_1.useCallback)((id) => {
|
|
149
|
+
setAttachments((prev) => prev.filter((c) => c.id !== id));
|
|
150
|
+
}, []);
|
|
151
|
+
// This is used to clear the context when the user submits a message
|
|
152
|
+
const clearContextAttachments = (0, react_1.useCallback)(() => {
|
|
153
|
+
setAttachments([]);
|
|
154
|
+
}, []);
|
|
155
|
+
const value = (0, react_1.useMemo)(() => ({
|
|
156
|
+
attachments,
|
|
157
|
+
addContextAttachment,
|
|
158
|
+
removeContextAttachment,
|
|
159
|
+
clearContextAttachments,
|
|
160
|
+
customSuggestions,
|
|
161
|
+
setCustomSuggestions,
|
|
162
|
+
}), [
|
|
163
|
+
attachments,
|
|
164
|
+
addContextAttachment,
|
|
165
|
+
removeContextAttachment,
|
|
166
|
+
clearContextAttachments,
|
|
167
|
+
customSuggestions,
|
|
168
|
+
]);
|
|
169
|
+
return (react_1.default.createElement(ContextAttachmentContext.Provider, { value: value }, children));
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Hook to access context attachment state and methods.
|
|
173
|
+
* **Must be used within a `TamboProvider`** - throws an error otherwise.
|
|
174
|
+
* @throws {Error} If used outside of TamboProvider
|
|
175
|
+
* @returns The context attachment state and methods
|
|
176
|
+
* @example
|
|
177
|
+
* ```tsx
|
|
178
|
+
* const contextAttachment = useTamboContextAttachment();
|
|
179
|
+
*
|
|
180
|
+
* // Add a context
|
|
181
|
+
* contextAttachment.addContextAttachment({
|
|
182
|
+
* name: "Button.tsx",
|
|
183
|
+
* icon: <FileIcon />,
|
|
184
|
+
* metadata: { path: "/src/Button.tsx" }
|
|
185
|
+
* });
|
|
186
|
+
*
|
|
187
|
+
* // Remove a context
|
|
188
|
+
* contextAttachment.removeContextAttachment(contextId);
|
|
189
|
+
*
|
|
190
|
+
* // Set custom suggestions
|
|
191
|
+
* contextAttachment.setCustomSuggestions([{ id: "1", title: "Add Feature" }]);
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
function useTamboContextAttachment() {
|
|
195
|
+
const context = (0, react_1.useContext)(ContextAttachmentContext);
|
|
196
|
+
if (!context) {
|
|
197
|
+
throw new Error("useTamboContextAttachment must be used within a TamboContextAttachmentProvider");
|
|
198
|
+
}
|
|
199
|
+
return context;
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=tambo-context-attachment-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tambo-context-attachment-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-context-attachment-provider.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgIb,wEAyHC;AAyBD,8DAQC;AAvRD,+CAQe;AACf,qFAA0E;AAgD1E,MAAM,wBAAwB,GAAG,IAAA,qBAAa,EAC5C,IAAI,CACL,CAAC;AA2BF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,SAAgB,8BAA8B,CAAC,EAC7C,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M,IAAI,KAAK,CACb,gFAAgF,CACjF,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["\"use client\";\n\nimport type { Suggestion } from \"@tambo-ai/typescript-sdk/resources/beta/threads/suggestions\";\nimport React, {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { useTamboContextHelpers } from \"./tambo-context-helpers-provider\";\n\n/**\n * Represents a context attachment that can be displayed in MessageInputContexts.\n * Context attachments appear as badges above the message input and provide additional\n * information to the AI about what to focus on.\n * @property {string} name - Display name shown in the badge\n * @property {React.ReactNode} [icon] - Optional icon to display in the badge\n * @property {Record<string, unknown>} [metadata] - Additional data passed to the AI\n * @example\n * ```tsx\n * const context: ContextAttachment = {\n * name: \"Button.tsx\",\n * icon: <FileIcon />,\n * metadata: { filePath: \"/src/components/Button.tsx\" }\n * };\n * ```\n */\nexport interface ContextAttachment {\n id: string;\n name: string;\n icon?: React.ReactNode;\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Represents the data structure returned by a context helper\n */\nexport type ContextHelperData = Record<string, unknown>;\n\n/**\n * Context state interface for managing context attachments and custom suggestions.\n * @property {ContextAttachment[]} attachments - Array of active context attachments (badges above message input)\n * @property {(context: Omit<ContextAttachment, \"id\">) => void} addContextAttachment - Add a new context attachment\n * @property {(id: string) => void} removeContextAttachment - Remove a context attachment by ID\n * @property {() => void} clearContextAttachments - Remove all context attachments - This is used to clear the context when the user submits a message\n * @property {Suggestion[] | null} customSuggestions - Custom suggestions to display instead of auto-generated ones\n * @property {(suggestions: Suggestion[] | null) => void} setCustomSuggestions - Set or clear custom suggestions\n */\nexport interface ContextAttachmentState {\n attachments: ContextAttachment[];\n addContextAttachment: (context: Omit<ContextAttachment, \"id\">) => void;\n removeContextAttachment: (id: string) => void;\n clearContextAttachments: () => void;\n customSuggestions: Suggestion[] | null;\n setCustomSuggestions: (suggestions: Suggestion[] | null) => void;\n}\n\nconst ContextAttachmentContext = createContext<ContextAttachmentState | null>(\n null,\n);\n\n/**\n * Props for the TamboContextAttachmentProvider.\n * @property {(context: ContextAttachment) => Promise<ContextHelperData> | ContextHelperData} [getContextHelperData] - Optional function to customize the data sent to the AI for each context. If not provided, uses a default structure with the context name and instruction.\n * @example\n * ```tsx\n * <TamboContextAttachmentProvider\n * getContextHelperData={(context) => ({\n * selectedFile: {\n * name: context.name,\n * path: context.metadata?.filePath,\n * instruction: \"Focus on this file\"\n * }\n * })}\n * >\n * {children}\n * </TamboContextAttachmentProvider>\n * ```\n */\nexport interface TamboContextAttachmentProviderProps {\n children?: React.ReactNode;\n getContextHelperData?: (\n context: ContextAttachment,\n ) => Promise<ContextHelperData> | ContextHelperData;\n}\n\n/**\n * Provider that enables context attachment features and custom suggestions in MessageInput.\n * **When to use:**\n * - **Included by default** in TamboProvider - no need to wrap separately\n * - Use `useTamboContextAttachment()` hook to manage context attachments\n * **What it does:**\n * - Manages context items that appear as badges above MessageInput\n * - Syncs context data with Tambo's AI for better responses\n * - Manages custom suggestions that replace auto-generated suggestions\n * - Allows components to add/remove contexts via `useTamboContextAttachment()`\n * - Allows components to set custom suggestions via `setCustomSuggestions()`\n * @param props - The props for the TamboContextAttachmentProvider\n * @param props.children - The children to wrap\n * @param props.getContextHelperData - The function to get the context helper data\n * @returns The TamboContextAttachmentProvider component\n * @example\n * Basic usage - already included in TamboProvider\n * ```tsx\n * <TamboProvider apiKey=\"...\">\n * <App />\n * </TamboProvider>\n * ```\n * @example\n * Using TamboProvider with custom context data\n * ```tsx\n * <TamboProvider\n * apiKey=\"...\"\n * getContextHelperData={(context) => ({\n * selectedComponent: {\n * name: context.name,\n * filePath: context.metadata?.path,\n * instruction: \"Edit this component\"\n * }\n * })}\n * >\n * <App />\n * </TamboProvider>\n * ```\n */\nexport function TamboContextAttachmentProvider({\n children,\n getContextHelperData,\n}: TamboContextAttachmentProviderProps) {\n const [attachments, setAttachments] = useState<ContextAttachment[]>([]);\n const [customSuggestions, setCustomSuggestions] = useState<\n Suggestion[] | null\n >(null);\n const { addContextHelper, removeContextHelper } = useTamboContextHelpers();\n\n // Track which context helpers have been registered to avoid duplicates\n const registeredIdsRef = useRef<Set<string>>(new Set());\n const prevGetContextHelperDataRef = useRef<typeof getContextHelperData>();\n\n // Sync context helpers with attachments using useEffect\n useEffect(() => {\n const currentIds = new Set(attachments.map((a) => a.id));\n const registeredIds = registeredIdsRef.current;\n\n // Remove context helpers that are no longer in attachments\n registeredIds.forEach((id) => {\n if (!currentIds.has(id)) {\n removeContextHelper(id);\n registeredIds.delete(id);\n }\n });\n\n const getDataChanged =\n prevGetContextHelperDataRef.current !== getContextHelperData;\n\n // Add or replace context helpers for attachments\n attachments.forEach((context) => {\n if (getDataChanged || !registeredIds.has(context.id)) {\n addContextHelper(context.id, async (): Promise<ContextHelperData> => {\n if (getContextHelperData) {\n return await getContextHelperData(context);\n }\n return {\n selectedComponent: {\n name: context.name,\n instruction:\n \"This is a Tambo interactable component that is currently selected and visible on the dashboard. You can read its current props and state, and update it by modifying its props. If multiple components are attached, you can interact with and modify any of them. Use the auto-registered interactable component tools (like get_interactable_component_by_id and update_interactable_component_<id>) to view and update the component's state.\",\n ...(context.metadata ?? {}),\n },\n };\n });\n registeredIds.add(context.id);\n }\n });\n\n prevGetContextHelperDataRef.current = getContextHelperData;\n }, [\n attachments,\n addContextHelper,\n removeContextHelper,\n getContextHelperData,\n ]);\n\n // Cleanup: remove all context helpers on unmount\n useEffect(() => {\n const registeredIds = registeredIdsRef.current;\n return () => {\n registeredIds.forEach((id) => {\n removeContextHelper(id);\n });\n registeredIds.clear();\n };\n }, [removeContextHelper]);\n\n const addContextAttachment = useCallback(\n (context: Omit<ContextAttachment, \"id\">) => {\n setAttachments((prev) => {\n if (prev.some((c) => c.name === context.name)) return prev;\n\n if (typeof crypto === \"undefined\" || !(\"randomUUID\" in crypto)) {\n throw new Error(\n \"crypto.randomUUID() is not available. This usually happens when using an IP address instead of 'localhost' in development. Use 'localhost' or a secure context (HTTPS) to enable crypto APIs.\",\n );\n }\n\n const newId = crypto.randomUUID();\n const newContext = { ...context, id: newId };\n return [...prev, newContext];\n });\n },\n [],\n );\n\n // This is used to remove a context when the user clicks the remove button\n const removeContextAttachment = useCallback((id: string) => {\n setAttachments((prev) => prev.filter((c) => c.id !== id));\n }, []);\n\n // This is used to clear the context when the user submits a message\n const clearContextAttachments = useCallback(() => {\n setAttachments([]);\n }, []);\n\n const value = useMemo(\n () => ({\n attachments,\n addContextAttachment,\n removeContextAttachment,\n clearContextAttachments,\n customSuggestions,\n setCustomSuggestions,\n }),\n [\n attachments,\n addContextAttachment,\n removeContextAttachment,\n clearContextAttachments,\n customSuggestions,\n ],\n );\n\n return (\n <ContextAttachmentContext.Provider value={value}>\n {children}\n </ContextAttachmentContext.Provider>\n );\n}\n\n/**\n * Hook to access context attachment state and methods.\n * **Must be used within a `TamboProvider`** - throws an error otherwise.\n * @throws {Error} If used outside of TamboProvider\n * @returns The context attachment state and methods\n * @example\n * ```tsx\n * const contextAttachment = useTamboContextAttachment();\n *\n * // Add a context\n * contextAttachment.addContextAttachment({\n * name: \"Button.tsx\",\n * icon: <FileIcon />,\n * metadata: { path: \"/src/Button.tsx\" }\n * });\n *\n * // Remove a context\n * contextAttachment.removeContextAttachment(contextId);\n *\n * // Set custom suggestions\n * contextAttachment.setCustomSuggestions([{ id: \"1\", title: \"Add Feature\" }]);\n * ```\n */\nexport function useTamboContextAttachment() {\n const context = useContext(ContextAttachmentContext);\n if (!context) {\n throw new Error(\n \"useTamboContextAttachment must be used within a TamboContextAttachmentProvider\",\n );\n }\n return context;\n}\n"]}
|
|
@@ -2,6 +2,7 @@ import React, { PropsWithChildren } from "react";
|
|
|
2
2
|
import { TamboInteractableContext } from "../model/tambo-interactable";
|
|
3
3
|
import { TamboClientContextProps, TamboClientProviderProps } from "./tambo-client-provider";
|
|
4
4
|
import { TamboComponentContextProps } from "./tambo-component-provider";
|
|
5
|
+
import { ContextAttachmentState, TamboContextAttachmentProviderProps } from "./tambo-context-attachment-provider";
|
|
5
6
|
import { TamboContextHelpersContextProps, TamboContextHelpersProviderProps } from "./tambo-context-helpers-provider";
|
|
6
7
|
import { TamboRegistryProviderProps } from "./tambo-registry-provider";
|
|
7
8
|
import { TamboThreadInputProviderProps } from "./tambo-thread-input-provider";
|
|
@@ -24,10 +25,11 @@ import { TamboGenerationStageContextProps, TamboThreadContextProps, TamboThreadP
|
|
|
24
25
|
* @param props.contextKey - Optional context key to be used in the thread input provider
|
|
25
26
|
* @param props.onCallUnregisteredTool - Callback function called when an unregistered tool is called
|
|
26
27
|
* @param props.initialMessages - Initial messages to be included in new threads
|
|
28
|
+
* @param props.getContextHelperData - Optional function to customize the data sent to the AI for each context attachment
|
|
27
29
|
* @returns The TamboProvider component
|
|
28
30
|
*/
|
|
29
|
-
export declare const TamboProvider: React.FC<PropsWithChildren<TamboClientProviderProps & TamboRegistryProviderProps & TamboThreadProviderProps & TamboContextHelpersProviderProps & TamboThreadInputProviderProps
|
|
30
|
-
export type TamboContextProps = TamboClientContextProps & TamboThreadContextProps & TamboGenerationStageContextProps & TamboComponentContextProps & TamboInteractableContext & TamboContextHelpersContextProps;
|
|
31
|
+
export declare const TamboProvider: React.FC<PropsWithChildren<TamboClientProviderProps & TamboRegistryProviderProps & TamboThreadProviderProps & TamboContextHelpersProviderProps & TamboThreadInputProviderProps & Partial<Pick<TamboContextAttachmentProviderProps, "getContextHelperData">>>>;
|
|
32
|
+
export type TamboContextProps = TamboClientContextProps & TamboThreadContextProps & TamboGenerationStageContextProps & TamboComponentContextProps & TamboInteractableContext & TamboContextHelpersContextProps & ContextAttachmentState;
|
|
31
33
|
export declare const TamboContext: React.Context<TamboContextProps>;
|
|
32
34
|
/**
|
|
33
35
|
* TamboCompositeProvider is a provider that combines the TamboClient,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tambo-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-provider.tsx"],"names":[],"mappings":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,KAAK,CAAC,EAAE,CAClC,iBAAiB,CACf,wBAAwB,GACtB,0BAA0B,GAC1B,wBAAwB,GACxB,gCAAgC,GAChC,6BAA6B,GAC7B,OAAO,CAAC,IAAI,CAAC,mCAAmC,EAAE,sBAAsB,CAAC,CAAC,CAC7E,CAyDF,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,uBAAuB,GACrD,uBAAuB,GACvB,gCAAgC,GAChC,0BAA0B,GAC1B,wBAAwB,GACxB,+BAA+B,GAC/B,sBAAsB,CAAC;AAEzB,eAAO,MAAM,YAAY,kCAExB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA4B9D,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,yBAEpB,CAAC"}
|
|
@@ -38,6 +38,7 @@ exports.useTambo = exports.TamboCompositeProvider = exports.TamboContext = expor
|
|
|
38
38
|
const react_1 = __importStar(require("react"));
|
|
39
39
|
const tambo_client_provider_1 = require("./tambo-client-provider");
|
|
40
40
|
const tambo_component_provider_1 = require("./tambo-component-provider");
|
|
41
|
+
const tambo_context_attachment_provider_1 = require("./tambo-context-attachment-provider");
|
|
41
42
|
const tambo_context_helpers_provider_1 = require("./tambo-context-helpers-provider");
|
|
42
43
|
const tambo_interactable_provider_1 = require("./tambo-interactable-provider");
|
|
43
44
|
const tambo_mcp_token_provider_1 = require("./tambo-mcp-token-provider");
|
|
@@ -62,18 +63,20 @@ const tambo_thread_provider_1 = require("./tambo-thread-provider");
|
|
|
62
63
|
* @param props.contextKey - Optional context key to be used in the thread input provider
|
|
63
64
|
* @param props.onCallUnregisteredTool - Callback function called when an unregistered tool is called
|
|
64
65
|
* @param props.initialMessages - Initial messages to be included in new threads
|
|
66
|
+
* @param props.getContextHelperData - Optional function to customize the data sent to the AI for each context attachment
|
|
65
67
|
* @returns The TamboProvider component
|
|
66
68
|
*/
|
|
67
|
-
const TamboProvider = ({ children, tamboUrl, apiKey, userToken, components, environment, tools, streaming, autoGenerateThreadName, autoGenerateNameThreshold, contextHelpers, contextKey, initialMessages, onCallUnregisteredTool, }) => {
|
|
69
|
+
const TamboProvider = ({ children, tamboUrl, apiKey, userToken, components, environment, tools, streaming, autoGenerateThreadName, autoGenerateNameThreshold, contextHelpers, contextKey, initialMessages, onCallUnregisteredTool, getContextHelperData, }) => {
|
|
68
70
|
return (react_1.default.createElement(tambo_client_provider_1.TamboClientProvider, { tamboUrl: tamboUrl, apiKey: apiKey, environment: environment, userToken: userToken },
|
|
69
71
|
react_1.default.createElement(tambo_registry_provider_1.TamboRegistryProvider, { components: components, tools: tools, onCallUnregisteredTool: onCallUnregisteredTool },
|
|
70
72
|
react_1.default.createElement(tambo_context_helpers_provider_1.TamboContextHelpersProvider, { contextHelpers: contextHelpers },
|
|
71
73
|
react_1.default.createElement(tambo_mcp_token_provider_1.TamboMcpTokenProvider, null,
|
|
72
74
|
react_1.default.createElement(tambo_thread_provider_1.TamboThreadProvider, { streaming: streaming, autoGenerateThreadName: autoGenerateThreadName, autoGenerateNameThreshold: autoGenerateNameThreshold, initialMessages: initialMessages },
|
|
73
75
|
react_1.default.createElement(tambo_thread_input_provider_1.TamboThreadInputProvider, { contextKey: contextKey },
|
|
74
|
-
react_1.default.createElement(
|
|
75
|
-
react_1.default.createElement(
|
|
76
|
-
react_1.default.createElement(
|
|
76
|
+
react_1.default.createElement(tambo_context_attachment_provider_1.TamboContextAttachmentProvider, { getContextHelperData: getContextHelperData },
|
|
77
|
+
react_1.default.createElement(tambo_component_provider_1.TamboComponentProvider, null,
|
|
78
|
+
react_1.default.createElement(tambo_interactable_provider_1.TamboInteractableProvider, null,
|
|
79
|
+
react_1.default.createElement(exports.TamboCompositeProvider, null, children)))))))))));
|
|
77
80
|
};
|
|
78
81
|
exports.TamboProvider = TamboProvider;
|
|
79
82
|
exports.TamboContext = (0, react_1.createContext)({});
|
|
@@ -92,6 +95,7 @@ const TamboCompositeProvider = ({ children, }) => {
|
|
|
92
95
|
const componentRegistry = (0, tambo_component_provider_1.useTamboComponent)();
|
|
93
96
|
const interactableComponents = (0, tambo_interactable_provider_1.useTamboInteractable)();
|
|
94
97
|
const contextHelpers = (0, tambo_context_helpers_provider_1.useTamboContextHelpers)();
|
|
98
|
+
const contextAttachment = (0, tambo_context_attachment_provider_1.useTamboContextAttachment)();
|
|
95
99
|
return (react_1.default.createElement(exports.TamboContext.Provider, { value: {
|
|
96
100
|
client,
|
|
97
101
|
queryClient,
|
|
@@ -100,6 +104,7 @@ const TamboCompositeProvider = ({ children, }) => {
|
|
|
100
104
|
...threads,
|
|
101
105
|
...interactableComponents,
|
|
102
106
|
...contextHelpers,
|
|
107
|
+
...contextAttachment,
|
|
103
108
|
} }, children));
|
|
104
109
|
};
|
|
105
110
|
exports.TamboCompositeProvider = TamboCompositeProvider;
|