@tambo-ai/react 0.41.2 → 0.42.1

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 (111) hide show
  1. package/dist/context-helpers/__tests__/context-helpers.test.d.ts +2 -0
  2. package/dist/context-helpers/__tests__/context-helpers.test.d.ts.map +1 -0
  3. package/dist/context-helpers/__tests__/context-helpers.test.js +44 -0
  4. package/dist/context-helpers/__tests__/context-helpers.test.js.map +1 -0
  5. package/dist/context-helpers/index.d.ts +9 -0
  6. package/dist/context-helpers/index.d.ts.map +1 -0
  7. package/dist/context-helpers/index.js +38 -0
  8. package/dist/context-helpers/index.js.map +1 -0
  9. package/dist/context-helpers/types.d.ts +30 -0
  10. package/dist/context-helpers/types.d.ts.map +1 -0
  11. package/dist/context-helpers/types.js +3 -0
  12. package/dist/context-helpers/types.js.map +1 -0
  13. package/dist/context-helpers/user-page.d.ts +7 -0
  14. package/dist/context-helpers/user-page.d.ts.map +1 -0
  15. package/dist/context-helpers/user-page.js +31 -0
  16. package/dist/context-helpers/user-page.js.map +1 -0
  17. package/dist/context-helpers/user-time.d.ts +7 -0
  18. package/dist/context-helpers/user-time.d.ts.map +1 -0
  19. package/dist/context-helpers/user-time.js +20 -0
  20. package/dist/context-helpers/user-time.js.map +1 -0
  21. package/dist/index.d.ts +3 -1
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +8 -1
  24. package/dist/index.js.map +1 -1
  25. package/dist/providers/__tests__/tambo-context-helpers-provider.test.d.ts +2 -0
  26. package/dist/providers/__tests__/tambo-context-helpers-provider.test.d.ts.map +1 -0
  27. package/dist/providers/__tests__/tambo-context-helpers-provider.test.js +194 -0
  28. package/dist/providers/__tests__/tambo-context-helpers-provider.test.js.map +1 -0
  29. package/dist/providers/__tests__/tambo-thread-provider.test.js +51 -31
  30. package/dist/providers/__tests__/tambo-thread-provider.test.js.map +1 -1
  31. package/dist/providers/index.d.ts +1 -0
  32. package/dist/providers/index.d.ts.map +1 -1
  33. package/dist/providers/index.js +4 -1
  34. package/dist/providers/index.js.map +1 -1
  35. package/dist/providers/tambo-context-helpers-provider.d.ts +28 -0
  36. package/dist/providers/tambo-context-helpers-provider.d.ts.map +1 -0
  37. package/dist/providers/tambo-context-helpers-provider.js +98 -0
  38. package/dist/providers/tambo-context-helpers-provider.js.map +1 -0
  39. package/dist/providers/tambo-interactable-provider.js +1 -1
  40. package/dist/providers/tambo-interactable-provider.js.map +1 -1
  41. package/dist/providers/tambo-provider.d.ts +4 -2
  42. package/dist/providers/tambo-provider.d.ts.map +1 -1
  43. package/dist/providers/tambo-provider.js +10 -5
  44. package/dist/providers/tambo-provider.js.map +1 -1
  45. package/dist/providers/tambo-stubs.d.ts +4 -0
  46. package/dist/providers/tambo-stubs.d.ts.map +1 -1
  47. package/dist/providers/tambo-stubs.js +6 -3
  48. package/dist/providers/tambo-stubs.js.map +1 -1
  49. package/dist/providers/tambo-thread-provider.d.ts.map +1 -1
  50. package/dist/providers/tambo-thread-provider.js +10 -1
  51. package/dist/providers/tambo-thread-provider.js.map +1 -1
  52. package/dist/util/registry.d.ts +0 -8
  53. package/dist/util/registry.d.ts.map +1 -1
  54. package/dist/util/registry.js +1 -15
  55. package/dist/util/registry.js.map +1 -1
  56. package/esm/context-helpers/__tests__/context-helpers.test.d.ts +2 -0
  57. package/esm/context-helpers/__tests__/context-helpers.test.d.ts.map +1 -0
  58. package/esm/context-helpers/__tests__/context-helpers.test.js +42 -0
  59. package/esm/context-helpers/__tests__/context-helpers.test.js.map +1 -0
  60. package/esm/context-helpers/index.d.ts +9 -0
  61. package/esm/context-helpers/index.d.ts.map +1 -0
  62. package/esm/context-helpers/index.js +21 -0
  63. package/esm/context-helpers/index.js.map +1 -0
  64. package/esm/context-helpers/types.d.ts +30 -0
  65. package/esm/context-helpers/types.d.ts.map +1 -0
  66. package/esm/context-helpers/types.js +2 -0
  67. package/esm/context-helpers/types.js.map +1 -0
  68. package/esm/context-helpers/user-page.d.ts +7 -0
  69. package/esm/context-helpers/user-page.d.ts.map +1 -0
  70. package/esm/context-helpers/user-page.js +28 -0
  71. package/esm/context-helpers/user-page.js.map +1 -0
  72. package/esm/context-helpers/user-time.d.ts +7 -0
  73. package/esm/context-helpers/user-time.d.ts.map +1 -0
  74. package/esm/context-helpers/user-time.js +17 -0
  75. package/esm/context-helpers/user-time.js.map +1 -0
  76. package/esm/index.d.ts +3 -1
  77. package/esm/index.d.ts.map +1 -1
  78. package/esm/index.js +3 -1
  79. package/esm/index.js.map +1 -1
  80. package/esm/providers/__tests__/tambo-context-helpers-provider.test.d.ts +2 -0
  81. package/esm/providers/__tests__/tambo-context-helpers-provider.test.d.ts.map +1 -0
  82. package/esm/providers/__tests__/tambo-context-helpers-provider.test.js +156 -0
  83. package/esm/providers/__tests__/tambo-context-helpers-provider.test.js.map +1 -0
  84. package/esm/providers/__tests__/tambo-thread-provider.test.js +51 -31
  85. package/esm/providers/__tests__/tambo-thread-provider.test.js.map +1 -1
  86. package/esm/providers/index.d.ts +1 -0
  87. package/esm/providers/index.d.ts.map +1 -1
  88. package/esm/providers/index.js +1 -0
  89. package/esm/providers/index.js.map +1 -1
  90. package/esm/providers/tambo-context-helpers-provider.d.ts +28 -0
  91. package/esm/providers/tambo-context-helpers-provider.d.ts.map +1 -0
  92. package/esm/providers/tambo-context-helpers-provider.js +60 -0
  93. package/esm/providers/tambo-context-helpers-provider.js.map +1 -0
  94. package/esm/providers/tambo-interactable-provider.js +1 -1
  95. package/esm/providers/tambo-interactable-provider.js.map +1 -1
  96. package/esm/providers/tambo-provider.d.ts +4 -2
  97. package/esm/providers/tambo-provider.d.ts.map +1 -1
  98. package/esm/providers/tambo-provider.js +10 -5
  99. package/esm/providers/tambo-provider.js.map +1 -1
  100. package/esm/providers/tambo-stubs.d.ts +4 -0
  101. package/esm/providers/tambo-stubs.d.ts.map +1 -1
  102. package/esm/providers/tambo-stubs.js +6 -3
  103. package/esm/providers/tambo-stubs.js.map +1 -1
  104. package/esm/providers/tambo-thread-provider.d.ts.map +1 -1
  105. package/esm/providers/tambo-thread-provider.js +11 -2
  106. package/esm/providers/tambo-thread-provider.js.map +1 -1
  107. package/esm/util/registry.d.ts +0 -8
  108. package/esm/util/registry.d.ts.map +1 -1
  109. package/esm/util/registry.js +0 -13
  110. package/esm/util/registry.js.map +1 -1
  111. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-thread-provider.test.js","sourceRoot":"","sources":["../../../src/providers/__tests__/tambo-thread-provider.test.tsx"],"names":[],"mappings":"AAAA,OAAgB,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,eAAe,GAEhB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAI/E,yBAAyB;AACzB,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,QAAQ,EAAE;IACtC,KAAK,EAAE;QACL,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,WAAW,CAAC;KACnD;CACF,CAAC,CAAC;AAEH,8BAA8B;AAC9B,IAAI,CAAC,IAAI,CAAC,0BAA0B,EAAE,GAAG,EAAE,CAAC,CAAC;IAC3C,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE;CAC1B,CAAC,CAAC,CAAC;AACJ,IAAI,CAAC,IAAI,CAAC,0BAA0B,EAAE,GAAG,EAAE,CAAC,CAAC;IAC3C,aAAa,EAA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AAE,CAAC;QAC5D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import TamboAI, { advanceStream } from \"@tambo-ai/typescript-sdk\";\nimport { act, renderHook } from \"@testing-library/react\";\nimport React from \"react\";\nimport { DeepPartial } from \"ts-essentials\";\nimport { z } from \"zod\";\nimport { TamboComponent } from \"../../model/component-metadata\";\nimport {\n GenerationStage,\n TamboThreadMessage,\n} from \"../../model/generate-component-response\";\nimport { serializeRegistry } from \"../../testing/tools\";\nimport { useTamboClient } from \"../tambo-client-provider\";\nimport { TamboRegistryProvider } from \"../tambo-registry-provider\";\nimport { TamboThreadProvider, useTamboThread } from \"../tambo-thread-provider\";\n\ntype PartialTamboAI = DeepPartial<TamboAI>;\n\n// Mock crypto.randomUUID\nObject.defineProperty(global, \"crypto\", {\n value: {\n randomUUID: jest.fn().mockReturnValue(\"test-uuid\"),\n },\n});\n\n// Mock the required providers\njest.mock(\"../tambo-client-provider\", () => ({\n useTamboClient: jest.fn(),\n}));\njest.mock(\"@tambo-ai/typescript-sdk\", () => ({\n advanceStream: jest.fn(),\n}));\n\n// Mock the system context and getCustomContext\njest.mock(\"../../util/registry\", () => ({\n ...jest.requireActual(\"../../util/registry\"),\n getSystemContext: () => ({\n localTime: \"7/24/2025, 6:26:21 PM\",\n timezone: \"America/New_York\",\n }),\n getCustomContext: () => ({\n message: \"additional instructions\",\n }),\n}));\n\n// Mock the combined context which includes the system context and the custom context\nconst mockCombinedContext = {\n system: {\n localTime: \"7/24/2025, 6:26:21 PM\",\n timezone: \"America/New_York\",\n },\n ...{\n custom: {\n message: \"additional instructions\",\n },\n },\n};\n\n// Test utilities\nconst createMockMessage = (\n overrides: Partial<TamboThreadMessage> = {},\n): TamboThreadMessage => ({\n id: \"test-message-1\",\n content: [{ type: \"text\", text: \"Hello\" }],\n role: \"user\",\n threadId: \"test-thread-1\",\n createdAt: new Date().toISOString(),\n componentState: {},\n ...overrides,\n});\n\nconst createMockThread = (\n overrides: Partial<TamboAI.Beta.Threads.Thread> = {},\n) => ({\n id: \"test-thread-1\",\n messages: [],\n createdAt: \"2024-01-01T00:00:00Z\",\n projectId: \"test-project\",\n updatedAt: \"2024-01-01T00:00:00Z\",\n metadata: {},\n ...overrides,\n});\n\nconst createMockAdvanceResponse = (\n overrides: Partial<TamboAI.Beta.Threads.ThreadAdvanceResponse> = {},\n): TamboAI.Beta.Threads.ThreadAdvanceResponse => ({\n responseMessageDto: {\n id: \"test-uuid\",\n content: [{ type: \"text\" as const, text: \"Default response\" }],\n role: \"assistant\",\n threadId: \"test-thread-1\",\n component: undefined,\n componentState: {},\n createdAt: new Date().toISOString(),\n },\n generationStage: GenerationStage.COMPLETE,\n mcpAccessToken: \"test-mcp-access-token\",\n ...overrides,\n});\n\ndescribe(\"TamboThreadProvider\", () => {\n const mockThread = createMockThread();\n\n const mockThreadsApi = {\n messages: {\n create: jest.fn(),\n },\n retrieve: jest.fn(),\n advance: jest.fn(),\n advanceById: jest.fn(),\n } satisfies DeepPartial<\n TamboAI[\"beta\"][\"threads\"]\n > as unknown as TamboAI.Beta.Threads;\n\n const mockBeta = {\n threads: mockThreadsApi,\n } satisfies PartialTamboAI[\"beta\"];\n\n const mockTamboAI = {\n apiKey: \"\",\n beta: mockBeta,\n } satisfies PartialTamboAI as unknown as TamboAI;\n\n const mockRegistry: TamboComponent[] = [\n {\n name: \"TestOnly\",\n component: () => <div>TestOnly</div>,\n description: \"TestOnly\",\n propsSchema: z.object({\n test: z.string(),\n }),\n associatedTools: [\n {\n name: \"test-tool\",\n tool: jest.fn().mockResolvedValue(\"test-tool\"),\n description: \"test-tool\",\n toolSchema: z\n .function()\n .args(z.string().describe(\"test-param-description\"))\n .returns(z.string()),\n },\n ],\n },\n ];\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider components={mockRegistry}>\n <TamboThreadProvider streaming={false}>{children}</TamboThreadProvider>\n </TamboRegistryProvider>\n );\n\n beforeEach(() => {\n jest.clearAllMocks();\n jest.mocked(mockThreadsApi.retrieve).mockResolvedValue(mockThread);\n jest\n .mocked(mockThreadsApi.messages.create)\n .mockResolvedValue(createMockMessage());\n jest\n .mocked(mockThreadsApi.advance)\n .mockResolvedValue(createMockAdvanceResponse());\n jest\n .mocked(mockThreadsApi.advanceById)\n .mockResolvedValue(createMockAdvanceResponse());\n jest.mocked(useTamboClient).mockReturnValue(mockTamboAI);\n });\n\n it(\"should initialize with placeholder thread\", () => {\n const { result } = renderHook(() => useTamboThread(), { wrapper });\n\n expect(result.current.thread.id).toBe(\"placeholder\");\n expect(result.current.isIdle).toBe(true);\n expect(result.current.generationStage).toBe(GenerationStage.IDLE);\n });\n\n it(\"should switch to a new thread\", async () => {\n const { result } = renderHook(() => useTamboThread(), { wrapper });\n\n await act(async () => {\n await result.current.switchCurrentThread(\"test-thread-1\");\n });\n\n expect(mockThreadsApi.retrieve).toHaveBeenCalledWith(\"test-thread-1\", {\n includeInternal: true,\n });\n expect(result.current.thread.id).toBe(\"test-thread-1\");\n });\n\n it(\"should start a new thread\", async () => {\n const { result } = renderHook(() => useTamboThread(), { wrapper });\n\n await act(async () => {\n result.current.startNewThread();\n });\n\n expect(result.current.thread.id).toBe(\"placeholder\");\n expect(result.current.isIdle).toBe(true);\n });\n\n it(\"should add a message to the thread\", async () => {\n const { result } = renderHook(() => useTamboThread(), { wrapper });\n const testMessage: TamboThreadMessage = {\n id: \"test-message-1\",\n content: [{ type: \"text\", text: \"Hello\" }],\n role: \"user\",\n threadId: \"test-thread-1\",\n createdAt: new Date().toISOString(),\n componentState: {},\n };\n\n await act(async () => {\n await result.current.addThreadMessage(testMessage, true);\n });\n\n expect(mockThreadsApi.messages.create).toHaveBeenCalledWith(\n \"test-thread-1\",\n {\n content: testMessage.content,\n role: testMessage.role,\n },\n );\n });\n\n it(\"should update a message in the thread\", async () => {\n const { result } = renderHook(() => useTamboThread(), { wrapper });\n const testMessage: TamboThreadMessage = {\n id: \"test-message-1\",\n content: [{ type: \"text\", text: \"Updated message\" }],\n role: \"user\",\n threadId: \"test-thread-1\",\n createdAt: new Date().toISOString(),\n componentState: {},\n };\n\n await act(async () => {\n await result.current.updateThreadMessage(\n \"test-message-1\",\n testMessage,\n true,\n );\n });\n\n expect(mockThreadsApi.messages.create).toHaveBeenCalledWith(\n \"test-thread-1\",\n {\n content: testMessage.content,\n role: testMessage.role,\n },\n );\n });\n\n it(\"should send a message and update thread state\", async () => {\n const mockAdvanceResponse: TamboAI.Beta.Threads.ThreadAdvanceResponse = {\n responseMessageDto: {\n id: \"response-1\",\n content: [{ type: \"text\", text: \"Response\" }],\n role: \"assistant\",\n threadId: \"test-thread-1\",\n component: undefined,\n componentState: {},\n createdAt: new Date().toISOString(),\n },\n generationStage: GenerationStage.COMPLETE,\n mcpAccessToken: \"test-mcp-access-token\",\n };\n\n jest\n .mocked(mockThreadsApi.advanceById)\n .mockResolvedValue(mockAdvanceResponse);\n\n const { result } = renderHook(() => useTamboThread(), { wrapper });\n\n await act(async () => {\n await result.current.sendThreadMessage(\"Hello\", {\n threadId: \"test-thread-1\",\n streamResponse: false,\n additionalContext: {\n custom: {\n message: \"additional instructions\",\n },\n },\n });\n });\n\n expect(mockThreadsApi.advanceById).toHaveBeenCalledWith(\"test-thread-1\", {\n messageToAppend: {\n content: [{ type: \"text\", text: \"Hello\" }],\n role: \"user\",\n additionalContext: mockCombinedContext,\n },\n availableComponents: serializeRegistry(mockRegistry),\n contextKey: undefined,\n clientTools: [],\n toolCallCounts: {},\n });\n expect(result.current.generationStage).toBe(GenerationStage.COMPLETE);\n });\n\n it(\"should handle input value changes\", () => {\n const { result } = renderHook(() => useTamboThread(), { wrapper });\n\n act(() => {\n result.current.setInputValue(\"New input\");\n });\n\n expect(result.current.inputValue).toBe(\"New input\");\n });\n\n it(\"should handle streaming responses\", async () => {\n const mockStreamResponse: TamboAI.Beta.Threads.ThreadAdvanceResponse = {\n responseMessageDto: {\n id: \"stream-1\",\n content: [{ type: \"text\", text: \"Streaming response\" }],\n role: \"assistant\",\n threadId: \"test-thread-1\",\n component: undefined,\n componentState: {},\n createdAt: new Date().toISOString(),\n },\n generationStage: GenerationStage.COMPLETE,\n mcpAccessToken: \"test-mcp-access-token\",\n };\n\n // Create an async iterator mock\n const mockAsyncIterator = {\n [Symbol.asyncIterator]: async function* () {\n yield mockStreamResponse;\n },\n };\n\n // Mock advanceStream to return our async iterator\n jest.mocked(advanceStream).mockResolvedValue(mockAsyncIterator);\n\n const { result } = renderHook(() => useTamboThread(), { wrapper });\n\n await act(async () => {\n await result.current.sendThreadMessage(\"Hello\", {\n threadId: \"test-thread-1\",\n streamResponse: true,\n });\n });\n\n expect(result.current.generationStage).toBe(GenerationStage.COMPLETE);\n });\n\n it(\"should handle tool calls during message processing.\", async () => {\n const mockToolCallResponse: TamboAI.Beta.Threads.ThreadAdvanceResponse = {\n responseMessageDto: {\n id: \"tool-call-1\",\n content: [{ type: \"text\", text: \"Tool response\" }],\n role: \"tool\",\n threadId: \"test-thread-1\",\n toolCallRequest: {\n toolName: \"test-tool\",\n parameters: [{ parameterName: \"test\", parameterValue: \"test\" }],\n },\n componentState: {},\n createdAt: new Date().toISOString(),\n },\n generationStage: GenerationStage.COMPLETE,\n mcpAccessToken: \"test-mcp-access-token\",\n };\n\n jest\n .mocked(mockThreadsApi.advanceById)\n .mockResolvedValueOnce(mockToolCallResponse)\n .mockResolvedValueOnce({\n responseMessageDto: {\n id: \"advance-response2\",\n content: [{ type: \"text\", text: \"response 2\" }],\n role: \"user\",\n threadId: \"test-thread-1\",\n componentState: {},\n createdAt: new Date().toISOString(),\n },\n generationStage: GenerationStage.COMPLETE,\n mcpAccessToken: \"test-mcp-access-token\",\n });\n\n const { result } = renderHook(() => useTamboThread(), { wrapper });\n\n await act(async () => {\n await result.current.sendThreadMessage(\"Use tool\", {\n threadId: \"test-thread-1\",\n streamResponse: false,\n });\n });\n expect(result.current.generationStage).toBe(GenerationStage.COMPLETE);\n expect(mockRegistry[0]?.associatedTools?.[0]?.tool).toHaveBeenCalledWith(\n \"test\",\n );\n });\n\n describe(\"streaming behavior\", () => {\n it(\"should call advanceStream when streamResponse=true\", async () => {\n // Use wrapper with streaming=true to show that explicit streamResponse=true works\n const wrapperWithStreaming = ({\n children,\n }: {\n children: React.ReactNode;\n }) => (\n <TamboRegistryProvider components={mockRegistry}>\n <TamboThreadProvider streaming={true}>{children}</TamboThreadProvider>\n </TamboRegistryProvider>\n );\n\n const mockStreamResponse: TamboAI.Beta.Threads.ThreadAdvanceResponse = {\n responseMessageDto: {\n id: \"stream-response\",\n content: [{ type: \"text\", text: \"Streaming response\" }],\n role: \"assistant\",\n threadId: \"test-thread-1\",\n component: undefined,\n componentState: {},\n createdAt: new Date().toISOString(),\n },\n generationStage: GenerationStage.COMPLETE,\n mcpAccessToken: \"test-mcp-access-token\",\n };\n\n const mockAsyncIterator = {\n [Symbol.asyncIterator]: async function* () {\n yield mockStreamResponse;\n },\n };\n\n jest.mocked(advanceStream).mockResolvedValue(mockAsyncIterator);\n\n const { result } = renderHook(() => useTamboThread(), {\n wrapper: wrapperWithStreaming,\n });\n\n await act(async () => {\n await result.current.sendThreadMessage(\"Hello streaming\", {\n threadId: \"test-thread-1\",\n streamResponse: true,\n additionalContext: {\n custom: {\n message: \"additional instructions\",\n },\n },\n });\n });\n\n expect(advanceStream).toHaveBeenCalledWith(\n mockTamboAI,\n {\n messageToAppend: {\n content: [{ type: \"text\", text: \"Hello streaming\" }],\n role: \"user\",\n additionalContext: mockCombinedContext,\n },\n availableComponents: serializeRegistry(mockRegistry),\n contextKey: undefined,\n clientTools: [],\n forceToolChoice: undefined,\n toolCallCounts: {},\n },\n \"test-thread-1\",\n );\n\n // Should not call advance or advanceById\n expect(mockThreadsApi.advance).not.toHaveBeenCalled();\n expect(mockThreadsApi.advanceById).not.toHaveBeenCalled();\n });\n\n it(\"should call advanceById when streamResponse=false for existing thread\", async () => {\n // Use wrapper with streaming=true to show that explicit streamResponse=false overrides provider setting\n const wrapperWithStreaming = ({\n children,\n }: {\n children: React.ReactNode;\n }) => (\n <TamboRegistryProvider components={mockRegistry}>\n <TamboThreadProvider streaming={true}>{children}</TamboThreadProvider>\n </TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboThread(), {\n wrapper: wrapperWithStreaming,\n });\n\n await act(async () => {\n await result.current.sendThreadMessage(\"Hello non-streaming\", {\n threadId: \"test-thread-1\",\n streamResponse: false,\n additionalContext: {\n custom: {\n message: \"additional instructions\",\n },\n },\n });\n });\n\n expect(mockThreadsApi.advanceById).toHaveBeenCalledWith(\"test-thread-1\", {\n messageToAppend: {\n content: [{ type: \"text\", text: \"Hello non-streaming\" }],\n role: \"user\",\n additionalContext: mockCombinedContext,\n },\n availableComponents: serializeRegistry(mockRegistry),\n contextKey: undefined,\n clientTools: [],\n forceToolChoice: undefined,\n toolCallCounts: {},\n });\n\n // Should not call advance or advanceStream\n expect(mockThreadsApi.advance).not.toHaveBeenCalled();\n expect(advanceStream).not.toHaveBeenCalled();\n });\n\n it(\"should call advanceById when streamResponse is undefined and provider streaming=false\", async () => {\n // Use wrapper with streaming=false to test that undefined streamResponse respects provider setting\n const wrapperWithoutStreaming = ({\n children,\n }: {\n children: React.ReactNode;\n }) => (\n <TamboRegistryProvider components={mockRegistry}>\n <TamboThreadProvider streaming={false}>\n {children}\n </TamboThreadProvider>\n </TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboThread(), {\n wrapper: wrapperWithoutStreaming,\n });\n\n await act(async () => {\n await result.current.sendThreadMessage(\"Hello default\", {\n threadId: \"test-thread-1\",\n // streamResponse is undefined, should use provider's streaming=false\n additionalContext: {\n custom: {\n message: \"additional instructions\",\n },\n },\n });\n });\n\n expect(mockThreadsApi.advanceById).toHaveBeenCalledWith(\"test-thread-1\", {\n messageToAppend: {\n content: [{ type: \"text\", text: \"Hello default\" }],\n role: \"user\",\n additionalContext: mockCombinedContext,\n },\n availableComponents: serializeRegistry(mockRegistry),\n contextKey: undefined,\n clientTools: [],\n forceToolChoice: undefined,\n toolCallCounts: {},\n });\n\n // Should not call advance or advanceStream\n expect(mockThreadsApi.advance).not.toHaveBeenCalled();\n expect(advanceStream).not.toHaveBeenCalled();\n });\n\n it(\"should call advanceStream when streamResponse is undefined and provider streaming=true (default)\", async () => {\n // Use wrapper with streaming=true (default) to test that undefined streamResponse respects provider setting\n const wrapperWithDefaultStreaming = ({\n children,\n }: {\n children: React.ReactNode;\n }) => (\n <TamboRegistryProvider components={mockRegistry}>\n <TamboThreadProvider>{children}</TamboThreadProvider>\n </TamboRegistryProvider>\n );\n\n const mockStreamResponse: TamboAI.Beta.Threads.ThreadAdvanceResponse = {\n responseMessageDto: {\n id: \"stream-response\",\n content: [{ type: \"text\", text: \"Streaming response\" }],\n role: \"assistant\",\n threadId: \"test-thread-1\",\n component: undefined,\n componentState: {},\n createdAt: new Date().toISOString(),\n },\n generationStage: GenerationStage.COMPLETE,\n mcpAccessToken: \"test-mcp-access-token\",\n };\n\n const mockAsyncIterator = {\n [Symbol.asyncIterator]: async function* () {\n yield mockStreamResponse;\n },\n };\n\n jest.mocked(advanceStream).mockResolvedValue(mockAsyncIterator);\n\n const { result } = renderHook(() => useTamboThread(), {\n wrapper: wrapperWithDefaultStreaming,\n });\n\n await act(async () => {\n await result.current.sendThreadMessage(\"Hello default streaming\", {\n threadId: \"test-thread-1\",\n // streamResponse is undefined, should use provider's streaming=true (default)\n additionalContext: {\n custom: {\n message: \"additional instructions\",\n },\n },\n });\n });\n\n expect(advanceStream).toHaveBeenCalledWith(\n mockTamboAI,\n {\n messageToAppend: {\n content: [{ type: \"text\", text: \"Hello default streaming\" }],\n role: \"user\",\n additionalContext: mockCombinedContext,\n },\n availableComponents: serializeRegistry(mockRegistry),\n contextKey: undefined,\n clientTools: [],\n forceToolChoice: undefined,\n toolCallCounts: {},\n },\n \"test-thread-1\",\n );\n\n // Should not call advance or advanceById\n expect(mockThreadsApi.advance).not.toHaveBeenCalled();\n expect(mockThreadsApi.advanceById).not.toHaveBeenCalled();\n });\n\n it(\"should call advance when streamResponse=false for placeholder thread\", async () => {\n // Use wrapper with streaming=true to show that explicit streamResponse=false overrides provider setting\n const wrapperWithStreaming = ({\n children,\n }: {\n children: React.ReactNode;\n }) => (\n <TamboRegistryProvider components={mockRegistry}>\n <TamboThreadProvider streaming={true}>{children}</TamboThreadProvider>\n </TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboThread(), {\n wrapper: wrapperWithStreaming,\n });\n\n // Start with placeholder thread (which is the default state)\n expect(result.current.thread.id).toBe(\"placeholder\");\n\n await act(async () => {\n await result.current.sendThreadMessage(\"Hello new thread\", {\n threadId: \"placeholder\",\n streamResponse: false,\n additionalContext: {\n custom: {\n message: \"additional instructions\",\n },\n },\n });\n });\n\n expect(mockThreadsApi.advance).toHaveBeenCalledWith({\n messageToAppend: {\n content: [{ type: \"text\", text: \"Hello new thread\" }],\n role: \"user\",\n additionalContext: mockCombinedContext,\n },\n availableComponents: serializeRegistry(mockRegistry),\n contextKey: undefined,\n clientTools: [],\n forceToolChoice: undefined,\n toolCallCounts: {},\n });\n\n // Should not call advanceById or advanceStream\n expect(mockThreadsApi.advanceById).not.toHaveBeenCalled();\n expect(advanceStream).not.toHaveBeenCalled();\n });\n\n it(\"should call advanceStream when streamResponse=true for placeholder thread\", async () => {\n // Use wrapper with streaming=false to show that explicit streamResponse=true overrides provider setting\n const wrapperWithoutStreaming = ({\n children,\n }: {\n children: React.ReactNode;\n }) => (\n <TamboRegistryProvider components={mockRegistry}>\n <TamboThreadProvider streaming={false}>\n {children}\n </TamboThreadProvider>\n </TamboRegistryProvider>\n );\n\n const mockStreamResponse: TamboAI.Beta.Threads.ThreadAdvanceResponse = {\n responseMessageDto: {\n id: \"stream-response\",\n content: [{ type: \"text\", text: \"Streaming response\" }],\n role: \"assistant\",\n threadId: \"new-thread-1\",\n component: undefined,\n componentState: {},\n createdAt: new Date().toISOString(),\n },\n generationStage: GenerationStage.COMPLETE,\n mcpAccessToken: \"test-mcp-access-token\",\n };\n\n const mockAsyncIterator = {\n [Symbol.asyncIterator]: async function* () {\n yield mockStreamResponse;\n },\n };\n\n jest.mocked(advanceStream).mockResolvedValue(mockAsyncIterator);\n\n const { result } = renderHook(() => useTamboThread(), {\n wrapper: wrapperWithoutStreaming,\n });\n\n // Start with placeholder thread (which is the default state)\n expect(result.current.thread.id).toBe(\"placeholder\");\n\n await act(async () => {\n await result.current.sendThreadMessage(\"Hello streaming new thread\", {\n threadId: \"placeholder\",\n streamResponse: true,\n additionalContext: {\n custom: {\n message: \"additional instructions\",\n },\n },\n });\n });\n\n expect(advanceStream).toHaveBeenCalledWith(\n mockTamboAI,\n {\n messageToAppend: {\n content: [{ type: \"text\", text: \"Hello streaming new thread\" }],\n role: \"user\",\n additionalContext: mockCombinedContext,\n },\n availableComponents: serializeRegistry(mockRegistry),\n contextKey: undefined,\n clientTools: [],\n forceToolChoice: undefined,\n toolCallCounts: {},\n },\n undefined, // threadId is undefined for placeholder thread\n );\n\n // Should not call advance or advanceById\n expect(mockThreadsApi.advance).not.toHaveBeenCalled();\n expect(mockThreadsApi.advanceById).not.toHaveBeenCalled();\n });\n });\n});\n"]}
1
+ {"version":3,"file":"tambo-thread-provider.test.js","sourceRoot":"","sources":["../../../src/providers/__tests__/tambo-thread-provider.test.tsx"],"names":[],"mappings":"AAAA,OAAgB,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,eAAe,GAEhB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAm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CAAC;YACtD,MAAM,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;QAC5D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import TamboAI, { advanceStream } from \"@tambo-ai/typescript-sdk\";\nimport { act, renderHook } from \"@testing-library/react\";\nimport React from \"react\";\nimport { DeepPartial } from \"ts-essentials\";\nimport { z } from \"zod\";\nimport { TamboComponent } from \"../../model/component-metadata\";\nimport {\n GenerationStage,\n TamboThreadMessage,\n} from \"../../model/generate-component-response\";\nimport { serializeRegistry } from \"../../testing/tools\";\nimport { useTamboClient } from \"../tambo-client-provider\";\nimport { TamboContextHelpersProvider } from \"../tambo-context-helpers-provider\";\nimport { TamboRegistryProvider } from \"../tambo-registry-provider\";\nimport { TamboThreadProvider, useTamboThread } from \"../tambo-thread-provider\";\n\ntype PartialTamboAI = DeepPartial<TamboAI>;\n\n// Mock crypto.randomUUID\nObject.defineProperty(global, \"crypto\", {\n value: {\n randomUUID: jest.fn().mockReturnValue(\"test-uuid\"),\n },\n});\n\n// Mock the required providers\njest.mock(\"../tambo-client-provider\", () => ({\n useTamboClient: jest.fn(),\n}));\njest.mock(\"@tambo-ai/typescript-sdk\", () => ({\n advanceStream: jest.fn(),\n}));\n\n// Mock the getCustomContext\njest.mock(\"../../util/registry\", () => ({\n ...jest.requireActual(\"../../util/registry\"),\n getCustomContext: () => ({\n message: \"additional instructions\",\n }),\n}));\n\n// Test utilities\nconst createMockMessage = (\n overrides: Partial<TamboThreadMessage> = {},\n): TamboThreadMessage => ({\n id: \"test-message-1\",\n content: [{ type: \"text\", text: \"Hello\" }],\n role: \"user\",\n threadId: \"test-thread-1\",\n createdAt: new Date().toISOString(),\n componentState: {},\n ...overrides,\n});\n\nconst createMockThread = (\n overrides: Partial<TamboAI.Beta.Threads.Thread> = {},\n) => ({\n id: \"test-thread-1\",\n messages: [],\n createdAt: \"2024-01-01T00:00:00Z\",\n projectId: \"test-project\",\n updatedAt: \"2024-01-01T00:00:00Z\",\n metadata: {},\n ...overrides,\n});\n\nconst createMockAdvanceResponse = (\n overrides: Partial<TamboAI.Beta.Threads.ThreadAdvanceResponse> = {},\n): TamboAI.Beta.Threads.ThreadAdvanceResponse => ({\n responseMessageDto: {\n id: \"test-uuid\",\n content: [{ type: \"text\" as const, text: \"Default response\" }],\n role: \"assistant\",\n threadId: \"test-thread-1\",\n component: undefined,\n componentState: {},\n createdAt: new Date().toISOString(),\n },\n generationStage: GenerationStage.COMPLETE,\n mcpAccessToken: \"test-mcp-access-token\",\n ...overrides,\n});\n\ndescribe(\"TamboThreadProvider\", () => {\n const mockThread = createMockThread();\n\n const mockThreadsApi = {\n messages: {\n create: jest.fn(),\n },\n retrieve: jest.fn(),\n advance: jest.fn(),\n advanceById: jest.fn(),\n } satisfies DeepPartial<\n TamboAI[\"beta\"][\"threads\"]\n > as unknown as TamboAI.Beta.Threads;\n\n const mockBeta = {\n threads: mockThreadsApi,\n } satisfies PartialTamboAI[\"beta\"];\n\n const mockTamboAI = {\n apiKey: \"\",\n beta: mockBeta,\n } satisfies PartialTamboAI as unknown as TamboAI;\n\n const mockRegistry: TamboComponent[] = [\n {\n name: \"TestOnly\",\n component: () => <div>TestOnly</div>,\n description: \"TestOnly\",\n propsSchema: z.object({\n test: z.string(),\n }),\n associatedTools: [\n {\n name: \"test-tool\",\n tool: jest.fn().mockResolvedValue(\"test-tool\"),\n description: \"test-tool\",\n toolSchema: z\n .function()\n .args(z.string().describe(\"test-param-description\"))\n .returns(z.string()),\n },\n ],\n },\n ];\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider components={mockRegistry}>\n <TamboContextHelpersProvider\n contextHelpers={{ userTime: false, userPage: false }}\n >\n <TamboThreadProvider streaming={false}>{children}</TamboThreadProvider>\n </TamboContextHelpersProvider>\n </TamboRegistryProvider>\n );\n\n beforeEach(() => {\n jest.clearAllMocks();\n jest.mocked(mockThreadsApi.retrieve).mockResolvedValue(mockThread);\n jest\n .mocked(mockThreadsApi.messages.create)\n .mockResolvedValue(createMockMessage());\n jest\n .mocked(mockThreadsApi.advance)\n .mockResolvedValue(createMockAdvanceResponse());\n jest\n .mocked(mockThreadsApi.advanceById)\n .mockResolvedValue(createMockAdvanceResponse());\n jest.mocked(useTamboClient).mockReturnValue(mockTamboAI);\n });\n\n it(\"should initialize with placeholder thread\", () => {\n const { result } = renderHook(() => useTamboThread(), { wrapper });\n\n expect(result.current.thread.id).toBe(\"placeholder\");\n expect(result.current.isIdle).toBe(true);\n expect(result.current.generationStage).toBe(GenerationStage.IDLE);\n });\n\n it(\"should switch to a new thread\", async () => {\n const { result } = renderHook(() => useTamboThread(), { wrapper });\n\n await act(async () => {\n await result.current.switchCurrentThread(\"test-thread-1\");\n });\n\n expect(mockThreadsApi.retrieve).toHaveBeenCalledWith(\"test-thread-1\", {\n includeInternal: true,\n });\n expect(result.current.thread.id).toBe(\"test-thread-1\");\n });\n\n it(\"should start a new thread\", async () => {\n const { result } = renderHook(() => useTamboThread(), { wrapper });\n\n await act(async () => {\n result.current.startNewThread();\n });\n\n expect(result.current.thread.id).toBe(\"placeholder\");\n expect(result.current.isIdle).toBe(true);\n });\n\n it(\"should add a message to the thread\", async () => {\n const { result } = renderHook(() => useTamboThread(), { wrapper });\n const testMessage: TamboThreadMessage = {\n id: \"test-message-1\",\n content: [{ type: \"text\", text: \"Hello\" }],\n role: \"user\",\n threadId: \"test-thread-1\",\n createdAt: new Date().toISOString(),\n componentState: {},\n };\n\n await act(async () => {\n await result.current.addThreadMessage(testMessage, true);\n });\n\n expect(mockThreadsApi.messages.create).toHaveBeenCalledWith(\n \"test-thread-1\",\n {\n content: testMessage.content,\n role: testMessage.role,\n },\n );\n });\n\n it(\"should update a message in the thread\", async () => {\n const { result } = renderHook(() => useTamboThread(), { wrapper });\n const testMessage: TamboThreadMessage = {\n id: \"test-message-1\",\n content: [{ type: \"text\", text: \"Updated message\" }],\n role: \"user\",\n threadId: \"test-thread-1\",\n createdAt: new Date().toISOString(),\n componentState: {},\n };\n\n await act(async () => {\n await result.current.updateThreadMessage(\n \"test-message-1\",\n testMessage,\n true,\n );\n });\n\n expect(mockThreadsApi.messages.create).toHaveBeenCalledWith(\n \"test-thread-1\",\n {\n content: testMessage.content,\n role: testMessage.role,\n },\n );\n });\n\n it(\"should send a message and update thread state\", async () => {\n const mockAdvanceResponse: TamboAI.Beta.Threads.ThreadAdvanceResponse = {\n responseMessageDto: {\n id: \"response-1\",\n content: [{ type: \"text\", text: \"Response\" }],\n role: \"assistant\",\n threadId: \"test-thread-1\",\n component: undefined,\n componentState: {},\n createdAt: new Date().toISOString(),\n },\n generationStage: GenerationStage.COMPLETE,\n mcpAccessToken: \"test-mcp-access-token\",\n };\n\n jest\n .mocked(mockThreadsApi.advanceById)\n .mockResolvedValue(mockAdvanceResponse);\n\n const { result } = renderHook(() => useTamboThread(), { wrapper });\n\n await act(async () => {\n await result.current.sendThreadMessage(\"Hello\", {\n threadId: \"test-thread-1\",\n streamResponse: false,\n additionalContext: {\n custom: {\n message: \"additional instructions\",\n },\n },\n });\n });\n\n expect(mockThreadsApi.advanceById).toHaveBeenCalledWith(\"test-thread-1\", {\n messageToAppend: {\n content: [{ type: \"text\", text: \"Hello\" }],\n role: \"user\",\n additionalContext: {\n custom: {\n message: \"additional instructions\",\n },\n },\n },\n availableComponents: serializeRegistry(mockRegistry),\n contextKey: undefined,\n clientTools: [],\n toolCallCounts: {},\n });\n expect(result.current.generationStage).toBe(GenerationStage.COMPLETE);\n });\n\n it(\"should handle input value changes\", () => {\n const { result } = renderHook(() => useTamboThread(), { wrapper });\n\n act(() => {\n result.current.setInputValue(\"New input\");\n });\n\n expect(result.current.inputValue).toBe(\"New input\");\n });\n\n it(\"should handle streaming responses\", async () => {\n const mockStreamResponse: TamboAI.Beta.Threads.ThreadAdvanceResponse = {\n responseMessageDto: {\n id: \"stream-1\",\n content: [{ type: \"text\", text: \"Streaming response\" }],\n role: \"assistant\",\n threadId: \"test-thread-1\",\n component: undefined,\n componentState: {},\n createdAt: new Date().toISOString(),\n },\n generationStage: GenerationStage.COMPLETE,\n mcpAccessToken: \"test-mcp-access-token\",\n };\n\n // Create an async iterator mock\n const mockAsyncIterator = {\n [Symbol.asyncIterator]: async function* () {\n yield mockStreamResponse;\n },\n };\n\n // Mock advanceStream to return our async iterator\n jest.mocked(advanceStream).mockResolvedValue(mockAsyncIterator);\n\n const { result } = renderHook(() => useTamboThread(), { wrapper });\n\n await act(async () => {\n await result.current.sendThreadMessage(\"Hello\", {\n threadId: \"test-thread-1\",\n streamResponse: true,\n });\n });\n\n expect(result.current.generationStage).toBe(GenerationStage.COMPLETE);\n });\n\n it(\"should handle tool calls during message processing.\", async () => {\n const mockToolCallResponse: TamboAI.Beta.Threads.ThreadAdvanceResponse = {\n responseMessageDto: {\n id: \"tool-call-1\",\n content: [{ type: \"text\", text: \"Tool response\" }],\n role: \"tool\",\n threadId: \"test-thread-1\",\n toolCallRequest: {\n toolName: \"test-tool\",\n parameters: [{ parameterName: \"test\", parameterValue: \"test\" }],\n },\n componentState: {},\n createdAt: new Date().toISOString(),\n },\n generationStage: GenerationStage.COMPLETE,\n mcpAccessToken: \"test-mcp-access-token\",\n };\n\n jest\n .mocked(mockThreadsApi.advanceById)\n .mockResolvedValueOnce(mockToolCallResponse)\n .mockResolvedValueOnce({\n responseMessageDto: {\n id: \"advance-response2\",\n content: [{ type: \"text\", text: \"response 2\" }],\n role: \"user\",\n threadId: \"test-thread-1\",\n componentState: {},\n createdAt: new Date().toISOString(),\n },\n generationStage: GenerationStage.COMPLETE,\n mcpAccessToken: \"test-mcp-access-token\",\n });\n\n const { result } = renderHook(() => useTamboThread(), { wrapper });\n\n await act(async () => {\n await result.current.sendThreadMessage(\"Use tool\", {\n threadId: \"test-thread-1\",\n streamResponse: false,\n });\n });\n expect(result.current.generationStage).toBe(GenerationStage.COMPLETE);\n expect(mockRegistry[0]?.associatedTools?.[0]?.tool).toHaveBeenCalledWith(\n \"test\",\n );\n });\n\n describe(\"streaming behavior\", () => {\n it(\"should call advanceStream when streamResponse=true\", async () => {\n // Use wrapper with streaming=true to show that explicit streamResponse=true works\n const wrapperWithStreaming = ({\n children,\n }: {\n children: React.ReactNode;\n }) => (\n <TamboRegistryProvider components={mockRegistry}>\n <TamboContextHelpersProvider\n contextHelpers={{ userTime: false, userPage: false }}\n >\n <TamboThreadProvider streaming={true}>\n {children}\n </TamboThreadProvider>\n </TamboContextHelpersProvider>\n </TamboRegistryProvider>\n );\n\n const mockStreamResponse: TamboAI.Beta.Threads.ThreadAdvanceResponse = {\n responseMessageDto: {\n id: \"stream-response\",\n content: [{ type: \"text\", text: \"Streaming response\" }],\n role: \"assistant\",\n threadId: \"test-thread-1\",\n component: undefined,\n componentState: {},\n createdAt: new Date().toISOString(),\n },\n generationStage: GenerationStage.COMPLETE,\n mcpAccessToken: \"test-mcp-access-token\",\n };\n\n const mockAsyncIterator = {\n [Symbol.asyncIterator]: async function* () {\n yield mockStreamResponse;\n },\n };\n\n jest.mocked(advanceStream).mockResolvedValue(mockAsyncIterator);\n\n const { result } = renderHook(() => useTamboThread(), {\n wrapper: wrapperWithStreaming,\n });\n\n await act(async () => {\n await result.current.sendThreadMessage(\"Hello streaming\", {\n threadId: \"test-thread-1\",\n streamResponse: true,\n additionalContext: {\n custom: {\n message: \"additional instructions\",\n },\n },\n });\n });\n\n expect(advanceStream).toHaveBeenCalledWith(\n mockTamboAI,\n {\n messageToAppend: {\n content: [{ type: \"text\", text: \"Hello streaming\" }],\n role: \"user\",\n additionalContext: {\n custom: {\n message: \"additional instructions\",\n },\n },\n },\n availableComponents: serializeRegistry(mockRegistry),\n contextKey: undefined,\n clientTools: [],\n forceToolChoice: undefined,\n toolCallCounts: {},\n },\n \"test-thread-1\",\n );\n\n // Should not call advance or advanceById\n expect(mockThreadsApi.advance).not.toHaveBeenCalled();\n expect(mockThreadsApi.advanceById).not.toHaveBeenCalled();\n });\n\n it(\"should call advanceById when streamResponse=false for existing thread\", async () => {\n // Use wrapper with streaming=true to show that explicit streamResponse=false overrides provider setting\n const wrapperWithStreaming = ({\n children,\n }: {\n children: React.ReactNode;\n }) => (\n <TamboRegistryProvider components={mockRegistry}>\n <TamboContextHelpersProvider\n contextHelpers={{ userTime: false, userPage: false }}\n >\n <TamboThreadProvider streaming={true}>\n {children}\n </TamboThreadProvider>\n </TamboContextHelpersProvider>\n </TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboThread(), {\n wrapper: wrapperWithStreaming,\n });\n\n await act(async () => {\n await result.current.sendThreadMessage(\"Hello non-streaming\", {\n threadId: \"test-thread-1\",\n streamResponse: false,\n additionalContext: {\n custom: {\n message: \"additional instructions\",\n },\n },\n });\n });\n\n expect(mockThreadsApi.advanceById).toHaveBeenCalledWith(\"test-thread-1\", {\n messageToAppend: {\n content: [{ type: \"text\", text: \"Hello non-streaming\" }],\n role: \"user\",\n additionalContext: {\n custom: {\n message: \"additional instructions\",\n },\n },\n },\n availableComponents: serializeRegistry(mockRegistry),\n contextKey: undefined,\n clientTools: [],\n forceToolChoice: undefined,\n toolCallCounts: {},\n });\n\n // Should not call advance or advanceStream\n expect(mockThreadsApi.advance).not.toHaveBeenCalled();\n expect(advanceStream).not.toHaveBeenCalled();\n });\n\n it(\"should call advanceById when streamResponse is undefined and provider streaming=false\", async () => {\n // Use wrapper with streaming=false to test that undefined streamResponse respects provider setting\n const wrapperWithoutStreaming = ({\n children,\n }: {\n children: React.ReactNode;\n }) => (\n <TamboRegistryProvider components={mockRegistry}>\n <TamboContextHelpersProvider\n contextHelpers={{ userTime: false, userPage: false }}\n >\n <TamboThreadProvider streaming={false}>\n {children}\n </TamboThreadProvider>\n </TamboContextHelpersProvider>\n </TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboThread(), {\n wrapper: wrapperWithoutStreaming,\n });\n\n await act(async () => {\n await result.current.sendThreadMessage(\"Hello default\", {\n threadId: \"test-thread-1\",\n // streamResponse is undefined, should use provider's streaming=false\n additionalContext: {\n custom: {\n message: \"additional instructions\",\n },\n },\n });\n });\n\n expect(mockThreadsApi.advanceById).toHaveBeenCalledWith(\"test-thread-1\", {\n messageToAppend: {\n content: [{ type: \"text\", text: \"Hello default\" }],\n role: \"user\",\n additionalContext: {\n custom: {\n message: \"additional instructions\",\n },\n },\n },\n availableComponents: serializeRegistry(mockRegistry),\n contextKey: undefined,\n clientTools: [],\n forceToolChoice: undefined,\n toolCallCounts: {},\n });\n\n // Should not call advance or advanceStream\n expect(mockThreadsApi.advance).not.toHaveBeenCalled();\n expect(advanceStream).not.toHaveBeenCalled();\n });\n\n it(\"should call advanceStream when streamResponse is undefined and provider streaming=true (default)\", async () => {\n // Use wrapper with streaming=true (default) to test that undefined streamResponse respects provider setting\n const wrapperWithDefaultStreaming = ({\n children,\n }: {\n children: React.ReactNode;\n }) => (\n <TamboRegistryProvider components={mockRegistry}>\n <TamboContextHelpersProvider\n contextHelpers={{ userTime: false, userPage: false }}\n >\n <TamboThreadProvider>{children}</TamboThreadProvider>\n </TamboContextHelpersProvider>\n </TamboRegistryProvider>\n );\n\n const mockStreamResponse: TamboAI.Beta.Threads.ThreadAdvanceResponse = {\n responseMessageDto: {\n id: \"stream-response\",\n content: [{ type: \"text\", text: \"Streaming response\" }],\n role: \"assistant\",\n threadId: \"test-thread-1\",\n component: undefined,\n componentState: {},\n createdAt: new Date().toISOString(),\n },\n generationStage: GenerationStage.COMPLETE,\n mcpAccessToken: \"test-mcp-access-token\",\n };\n\n const mockAsyncIterator = {\n [Symbol.asyncIterator]: async function* () {\n yield mockStreamResponse;\n },\n };\n\n jest.mocked(advanceStream).mockResolvedValue(mockAsyncIterator);\n\n const { result } = renderHook(() => useTamboThread(), {\n wrapper: wrapperWithDefaultStreaming,\n });\n\n await act(async () => {\n await result.current.sendThreadMessage(\"Hello default streaming\", {\n threadId: \"test-thread-1\",\n // streamResponse is undefined, should use provider's streaming=true (default)\n additionalContext: {\n custom: {\n message: \"additional instructions\",\n },\n },\n });\n });\n\n expect(advanceStream).toHaveBeenCalledWith(\n mockTamboAI,\n {\n messageToAppend: {\n content: [{ type: \"text\", text: \"Hello default streaming\" }],\n role: \"user\",\n additionalContext: {\n custom: {\n message: \"additional instructions\",\n },\n },\n },\n availableComponents: serializeRegistry(mockRegistry),\n contextKey: undefined,\n clientTools: [],\n forceToolChoice: undefined,\n toolCallCounts: {},\n },\n \"test-thread-1\",\n );\n\n // Should not call advance or advanceById\n expect(mockThreadsApi.advance).not.toHaveBeenCalled();\n expect(mockThreadsApi.advanceById).not.toHaveBeenCalled();\n });\n\n it(\"should call advance when streamResponse=false for placeholder thread\", async () => {\n // Use wrapper with streaming=true to show that explicit streamResponse=false overrides provider setting\n const wrapperWithStreaming = ({\n children,\n }: {\n children: React.ReactNode;\n }) => (\n <TamboRegistryProvider components={mockRegistry}>\n <TamboContextHelpersProvider\n contextHelpers={{ userTime: false, userPage: false }}\n >\n <TamboThreadProvider streaming={true}>\n {children}\n </TamboThreadProvider>\n </TamboContextHelpersProvider>\n </TamboRegistryProvider>\n );\n\n const { result } = renderHook(() => useTamboThread(), {\n wrapper: wrapperWithStreaming,\n });\n\n // Start with placeholder thread (which is the default state)\n expect(result.current.thread.id).toBe(\"placeholder\");\n\n await act(async () => {\n await result.current.sendThreadMessage(\"Hello new thread\", {\n threadId: \"placeholder\",\n streamResponse: false,\n additionalContext: {\n custom: {\n message: \"additional instructions\",\n },\n },\n });\n });\n\n expect(mockThreadsApi.advance).toHaveBeenCalledWith({\n messageToAppend: {\n content: [{ type: \"text\", text: \"Hello new thread\" }],\n role: \"user\",\n additionalContext: {\n custom: {\n message: \"additional instructions\",\n },\n },\n },\n availableComponents: serializeRegistry(mockRegistry),\n contextKey: undefined,\n clientTools: [],\n forceToolChoice: undefined,\n toolCallCounts: {},\n });\n\n // Should not call advanceById or advanceStream\n expect(mockThreadsApi.advanceById).not.toHaveBeenCalled();\n expect(advanceStream).not.toHaveBeenCalled();\n });\n\n it(\"should call advanceStream when streamResponse=true for placeholder thread\", async () => {\n // Use wrapper with streaming=false to show that explicit streamResponse=true overrides provider setting\n const wrapperWithoutStreaming = ({\n children,\n }: {\n children: React.ReactNode;\n }) => (\n <TamboRegistryProvider components={mockRegistry}>\n <TamboContextHelpersProvider\n contextHelpers={{ userTime: false, userPage: false }}\n >\n <TamboThreadProvider streaming={false}>\n {children}\n </TamboThreadProvider>\n </TamboContextHelpersProvider>\n </TamboRegistryProvider>\n );\n\n const mockStreamResponse: TamboAI.Beta.Threads.ThreadAdvanceResponse = {\n responseMessageDto: {\n id: \"stream-response\",\n content: [{ type: \"text\", text: \"Streaming response\" }],\n role: \"assistant\",\n threadId: \"new-thread-1\",\n component: undefined,\n componentState: {},\n createdAt: new Date().toISOString(),\n },\n generationStage: GenerationStage.COMPLETE,\n mcpAccessToken: \"test-mcp-access-token\",\n };\n\n const mockAsyncIterator = {\n [Symbol.asyncIterator]: async function* () {\n yield mockStreamResponse;\n },\n };\n\n jest.mocked(advanceStream).mockResolvedValue(mockAsyncIterator);\n\n const { result } = renderHook(() => useTamboThread(), {\n wrapper: wrapperWithoutStreaming,\n });\n\n // Start with placeholder thread (which is the default state)\n expect(result.current.thread.id).toBe(\"placeholder\");\n\n await act(async () => {\n await result.current.sendThreadMessage(\"Hello streaming new thread\", {\n threadId: \"placeholder\",\n streamResponse: true,\n additionalContext: {\n custom: {\n message: \"additional instructions\",\n },\n },\n });\n });\n\n expect(advanceStream).toHaveBeenCalledWith(\n mockTamboAI,\n {\n messageToAppend: {\n content: [{ type: \"text\", text: \"Hello streaming new thread\" }],\n role: \"user\",\n additionalContext: {\n custom: {\n message: \"additional instructions\",\n },\n },\n },\n availableComponents: serializeRegistry(mockRegistry),\n contextKey: undefined,\n clientTools: [],\n forceToolChoice: undefined,\n toolCallCounts: {},\n },\n undefined, // threadId is undefined for placeholder thread\n );\n\n // Should not call advance or advanceById\n expect(mockThreadsApi.advance).not.toHaveBeenCalled();\n expect(mockThreadsApi.advanceById).not.toHaveBeenCalled();\n });\n });\n});\n"]}
@@ -1,6 +1,7 @@
1
1
  export type { TamboComponent, TamboTool } from "../model/component-metadata";
2
2
  export { TamboClientProvider, useTamboClient } from "./tambo-client-provider";
3
3
  export { TamboComponentProvider, useTamboComponent, } from "./tambo-component-provider";
4
+ export { TamboContextHelpersProvider, useTamboContextHelpers, type TamboContextHelpersContextProps, type TamboContextHelpersProviderProps, } from "./tambo-context-helpers-provider";
4
5
  export { Pending, Streaming, Success, TamboPropStreamProvider, useTamboStream, } from "./tambo-prop-stream-provider";
5
6
  export type { StreamStateComponentProps, StreamStatus, TamboPropStreamContextValue, } from "./tambo-prop-stream-provider";
6
7
  export { TamboContext, TamboProvider, useTambo } from "./tambo-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,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9E,OAAO,EACL,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,4BAA4B,CAAC;AACpC,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,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,GACf,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,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9E,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,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,GACf,MAAM,yBAAyB,CAAC"}
@@ -1,5 +1,6 @@
1
1
  export { TamboClientProvider, useTamboClient } from "./tambo-client-provider";
2
2
  export { TamboComponentProvider, useTamboComponent, } from "./tambo-component-provider";
3
+ export { TamboContextHelpersProvider, useTamboContextHelpers, } from "./tambo-context-helpers-provider";
3
4
  export { Pending, Streaming, Success, TamboPropStreamProvider, useTamboStream, } from "./tambo-prop-stream-provider";
4
5
  export { TamboContext, TamboProvider, useTambo } from "./tambo-provider";
5
6
  export { TamboRegistryProvider, useTamboRegistry, } from "./tambo-registry-provider";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9E,OAAO,EACL,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,OAAO,EACP,SAAS,EACT,OAAO,EACP,uBAAuB,EACvB,cAAc,GACf,MAAM,8BAA8B,CAAC;AAMtC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EACL,qBAAqB,EACrB,gBAAgB,GAEjB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAA+B,MAAM,eAAe,CAAC;AAC/E,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,GACf,MAAM,yBAAyB,CAAC","sourcesContent":["export type { TamboComponent, TamboTool } from \"../model/component-metadata\";\nexport { TamboClientProvider, useTamboClient } from \"./tambo-client-provider\";\nexport {\n TamboComponentProvider,\n useTamboComponent,\n} from \"./tambo-component-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 TamboThreadContext,\n TamboThreadProvider,\n useTamboThread,\n} from \"./tambo-thread-provider\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9E,OAAO,EACL,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,2BAA2B,EAC3B,sBAAsB,GAGvB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,OAAO,EACP,SAAS,EACT,OAAO,EACP,uBAAuB,EACvB,cAAc,GACf,MAAM,8BAA8B,CAAC;AAMtC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EACL,qBAAqB,EACrB,gBAAgB,GAEjB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAA+B,MAAM,eAAe,CAAC;AAC/E,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,GACf,MAAM,yBAAyB,CAAC","sourcesContent":["export type { TamboComponent, TamboTool } from \"../model/component-metadata\";\nexport { TamboClientProvider, useTamboClient } 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 TamboThreadContext,\n TamboThreadProvider,\n useTamboThread,\n} from \"./tambo-thread-provider\";\n"]}
@@ -0,0 +1,28 @@
1
+ import React, { PropsWithChildren } from "react";
2
+ import { AdditionalContext, AdditionalContextHelper, ContextHelpersConfig } from "../context-helpers";
3
+ export interface TamboContextHelpersProviderProps {
4
+ /** Configuration for which context helpers are enabled/disabled */
5
+ contextHelpers?: ContextHelpersConfig;
6
+ }
7
+ export interface TamboContextHelpersContextProps {
8
+ /** Get all enabled additional context */
9
+ getAdditionalContext: () => Promise<AdditionalContext[]>;
10
+ /** Get the current context helpers configuration */
11
+ getContextHelpers: () => AdditionalContextHelper[];
12
+ /** Update a specific context helper's enabled state */
13
+ setContextHelperEnabled: (name: string, enabled: boolean) => void;
14
+ }
15
+ /**
16
+ * Provider for managing additional context helpers
17
+ * @param children - The children of the provider
18
+ * @param children.children - The children of the provider
19
+ * @param children.contextHelpers - The configuration for which context helpers are enabled/disabled
20
+ * @returns The context helpers context props
21
+ */
22
+ export declare const TamboContextHelpersProvider: React.FC<PropsWithChildren<TamboContextHelpersProviderProps>>;
23
+ /**
24
+ * Hook to access context helpers functionality
25
+ * @returns The context helpers context props
26
+ */
27
+ export declare const useTamboContextHelpers: () => TamboContextHelpersContextProps;
28
+ //# sourceMappingURL=tambo-context-helpers-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tambo-context-helpers-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-context-helpers-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAEZ,iBAAiB,EAKlB,MAAM,OAAO,CAAC;AACf,OAAO,EACL,iBAAiB,EACjB,uBAAuB,EACvB,oBAAoB,EAErB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,WAAW,gCAAgC;IAC/C,mEAAmE;IACnE,cAAc,CAAC,EAAE,oBAAoB,CAAC;CACvC;AAED,MAAM,WAAW,+BAA+B;IAC9C,yCAAyC;IACzC,oBAAoB,EAAE,MAAM,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC;IACzD,oDAAoD;IACpD,iBAAiB,EAAE,MAAM,uBAAuB,EAAE,CAAC;IACnD,uDAAuD;IACvD,uBAAuB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CACnE;AAKD;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,EAAE,KAAK,CAAC,EAAE,CAChD,iBAAiB,CAAC,gCAAgC,CAAC,CA0DpD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,sBAAsB,uCAQlC,CAAC"}
@@ -0,0 +1,60 @@
1
+ "use client";
2
+ import React, { createContext, useCallback, useContext, useMemo, useState, } from "react";
3
+ import { DEFAULT_CONTEXT_HELPERS, } from "../context-helpers";
4
+ const TamboContextHelpersContext = createContext(null);
5
+ /**
6
+ * Provider for managing additional context helpers
7
+ * @param children - The children of the provider
8
+ * @param children.children - The children of the provider
9
+ * @param children.contextHelpers - The configuration for which context helpers are enabled/disabled
10
+ * @returns The context helpers context props
11
+ */
12
+ export const TamboContextHelpersProvider = ({ children, contextHelpers }) => {
13
+ // Initialize context helpers with configuration
14
+ const [helpers, setHelpers] = useState(() => {
15
+ return DEFAULT_CONTEXT_HELPERS.map((helper) => ({
16
+ ...helper,
17
+ enabled: contextHelpers?.[helper.name] ??
18
+ helper.enabled,
19
+ }));
20
+ });
21
+ const getAdditionalContext = useCallback(async () => {
22
+ const contextResults = [];
23
+ for (const helper of helpers) {
24
+ if (helper.enabled) {
25
+ try {
26
+ const context = await helper.run();
27
+ contextResults.push(context);
28
+ }
29
+ catch (error) {
30
+ console.error(`Error running context helper ${helper.name}:`, error);
31
+ }
32
+ }
33
+ }
34
+ return contextResults;
35
+ }, [helpers]);
36
+ const getContextHelpers = useCallback(() => {
37
+ return helpers;
38
+ }, [helpers]);
39
+ const setContextHelperEnabled = useCallback((name, enabled) => {
40
+ setHelpers((prev) => prev.map((helper) => helper.name === name ? { ...helper, enabled } : helper));
41
+ }, []);
42
+ const value = useMemo(() => ({
43
+ getAdditionalContext,
44
+ getContextHelpers,
45
+ setContextHelperEnabled,
46
+ }), [getAdditionalContext, getContextHelpers, setContextHelperEnabled]);
47
+ return (React.createElement(TamboContextHelpersContext.Provider, { value: value }, children));
48
+ };
49
+ /**
50
+ * Hook to access context helpers functionality
51
+ * @returns The context helpers context props
52
+ */
53
+ export const useTamboContextHelpers = () => {
54
+ const context = useContext(TamboContextHelpersContext);
55
+ if (!context) {
56
+ throw new Error("useTamboContextHelpers must be used within a TamboContextHelpersProvider");
57
+ }
58
+ return context;
59
+ };
60
+ //# sourceMappingURL=tambo-context-helpers-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tambo-context-helpers-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-context-helpers-provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,KAAK,EAAE,EACZ,aAAa,EAEb,WAAW,EACX,UAAU,EACV,OAAO,EACP,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAIL,uBAAuB,GACxB,MAAM,oBAAoB,CAAC;AAgB5B,MAAM,0BAA0B,GAC9B,aAAa,CAAyC,IAAI,CAAC,CAAC;AAE9D;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAEpC,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,EAAE,EAAE;IACnC,gDAAgD;IAChD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAA4B,GAAG,EAAE;QACrE,OAAO,uBAAuB,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YAC9C,GAAG,MAAM;YACT,OAAO,EACL,cAAc,EAAE,CAAC,MAAM,CAAC,IAAkC,CAAC;gBAC3D,MAAM,CAAC,OAAO;SACjB,CAAC,CAAC,CAAC;IACN,CAAC,CAAC,CAAC;IAEH,MAAM,oBAAoB,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QAClD,MAAM,cAAc,GAAwB,EAAE,CAAC;QAE/C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACnB,IAAI,CAAC;oBACH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AAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,0EAA0E,CAC3E,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["\"use client\";\nimport React, {\n createContext,\n PropsWithChildren,\n useCallback,\n useContext,\n useMemo,\n useState,\n} from \"react\";\nimport {\n AdditionalContext,\n AdditionalContextHelper,\n ContextHelpersConfig,\n DEFAULT_CONTEXT_HELPERS,\n} from \"../context-helpers\";\n\nexport interface TamboContextHelpersProviderProps {\n /** Configuration for which context helpers are enabled/disabled */\n contextHelpers?: ContextHelpersConfig;\n}\n\nexport interface TamboContextHelpersContextProps {\n /** Get all enabled additional context */\n getAdditionalContext: () => Promise<AdditionalContext[]>;\n /** Get the current context helpers configuration */\n getContextHelpers: () => AdditionalContextHelper[];\n /** Update a specific context helper's enabled state */\n setContextHelperEnabled: (name: string, enabled: boolean) => void;\n}\n\nconst TamboContextHelpersContext =\n createContext<TamboContextHelpersContextProps | null>(null);\n\n/**\n * Provider for managing additional context helpers\n * @param children - The children of the provider\n * @param children.children - The children of the provider\n * @param children.contextHelpers - The configuration for which context helpers are enabled/disabled\n * @returns The context helpers context props\n */\nexport const TamboContextHelpersProvider: React.FC<\n PropsWithChildren<TamboContextHelpersProviderProps>\n> = ({ children, contextHelpers }) => {\n // Initialize context helpers with configuration\n const [helpers, setHelpers] = useState<AdditionalContextHelper[]>(() => {\n return DEFAULT_CONTEXT_HELPERS.map((helper) => ({\n ...helper,\n enabled:\n contextHelpers?.[helper.name as keyof ContextHelpersConfig] ??\n helper.enabled,\n }));\n });\n\n const getAdditionalContext = useCallback(async () => {\n const contextResults: AdditionalContext[] = [];\n\n for (const helper of helpers) {\n if (helper.enabled) {\n try {\n const context = await helper.run();\n contextResults.push(context);\n } catch (error) {\n console.error(`Error running context helper ${helper.name}:`, error);\n }\n }\n }\n\n return contextResults;\n }, [helpers]);\n\n const getContextHelpers = useCallback(() => {\n return helpers;\n }, [helpers]);\n\n const setContextHelperEnabled = useCallback(\n (name: string, enabled: boolean) => {\n setHelpers((prev) =>\n prev.map((helper) =>\n helper.name === name ? { ...helper, enabled } : helper,\n ),\n );\n },\n [],\n );\n\n const value = useMemo(\n () => ({\n getAdditionalContext,\n getContextHelpers,\n setContextHelperEnabled,\n }),\n [getAdditionalContext, getContextHelpers, setContextHelperEnabled],\n );\n\n return (\n <TamboContextHelpersContext.Provider value={value}>\n {children}\n </TamboContextHelpersContext.Provider>\n );\n};\n\n/**\n * Hook to access context helpers functionality\n * @returns The context helpers context props\n */\nexport const useTamboContextHelpers = () => {\n const context = useContext(TamboContextHelpersContext);\n if (!context) {\n throw new Error(\n \"useTamboContextHelpers must be used within a TamboContextHelpersProvider\",\n );\n }\n return context;\n};\n"]}
@@ -26,7 +26,7 @@ export const TamboInteractableProvider = ({ children, }) => {
26
26
  useEffect(() => {
27
27
  registerTool({
28
28
  name: "get_all_interactable_components",
29
- description: "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.",
29
+ description: "Only use this tool if the user is asking about interactable components.Get all currently interactable components with their details including their current props. These are components that you can interact with on behalf of the user.",
30
30
  tool: () => {
31
31
  return {
32
32
  components: interactableComponents,
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-interactable-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-interactable-provider.tsx"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,YAAY,CAAC;AACb,OAAO,KAAK,EAAE,EACZ,aAAa,EAEb,WAAW,EACX,UAAU,EACV,SAAS,EACT,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D,MAAM,wBAAwB,GAAG,aAAa,CAA2B;IACvE,sBAAsB,EAAE,EAAE;IAC1B,wBAAwB,EAAE,GAAG,EAAE,CAAC,EAAE;IAClC,2BAA2B,EAAE,GAAG,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AC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,EAAE;IACvC,OAAO,UAAU,CAAC,wBAAwB,CAAC,CAAC;AAC9C,CAAC,CAAC","sourcesContent":["// react-sdk/src/providers/tambo-interactable-provider.tsx\n\"use client\";\nimport React, {\n createContext,\n PropsWithChildren,\n useCallback,\n useContext,\n useEffect,\n useState,\n} from \"react\";\nimport { z } from \"zod\";\nimport {\n TamboInteractableComponent,\n type TamboInteractableContext,\n} from \"../model/tambo-interactable\";\nimport { useTamboComponent } from \"./tambo-component-provider\";\n\nconst TamboInteractableContext = createContext<TamboInteractableContext>({\n interactableComponents: [],\n addInteractableComponent: () => \"\",\n removeInteractableComponent: () => {},\n updateInteractableComponentProps: () => {},\n getInteractableComponent: () => undefined,\n getInteractableComponentsByName: () => [],\n clearAllInteractableComponents: () => {},\n});\n\n/**\n * The TamboInteractableProvider manages a list of components that are currently\n * interactable, allowing tambo to interact with them by updating their props. It also registers tools\n * for Tambo to perform CRUD operations on the components list.\n * @param props - The props for the TamboInteractableProvider\n * @param props.children - The children to wrap\n * @returns The TamboInteractableProvider component\n */\nexport const TamboInteractableProvider: React.FC<PropsWithChildren> = ({\n children,\n}) => {\n const [interactableComponents, setInteractableComponents] = useState<\n TamboInteractableComponent[]\n >([]);\n const { registerTool } = useTamboComponent();\n\n useEffect(() => {\n registerTool({\n name: \"get_all_interactable_components\",\n description:\n \"Get all currently interactable components with their details including their current props. These are components that you can interact with on behalf of the user.\",\n tool: () => {\n return {\n components: interactableComponents,\n };\n },\n toolSchema: z.function().returns(\n z.object({\n components: z.array(\n z.object({\n id: z.string(),\n componentName: z.string(),\n props: z.record(z.any()),\n propsSchema: z.object({}).optional(),\n }),\n ),\n }),\n ),\n });\n\n registerTool({\n name: \"get_interactable_component_by_id\",\n description: \"Get a specific interactable component by its ID\",\n tool: (componentId: string) => {\n const component = interactableComponents.find(\n (c) => c.id === componentId,\n );\n\n if (!component) {\n return {\n success: false,\n error: `Component with ID ${componentId} not found`,\n };\n }\n\n return {\n success: true,\n component: {\n id: component.id,\n componentName: component.name,\n props: component.props,\n },\n };\n },\n toolSchema: z\n .function()\n .args(z.string())\n .returns(\n z.object({\n success: z.boolean(),\n component: z\n .object({\n id: z.string(),\n componentName: z.string(),\n props: z.record(z.any()),\n })\n .optional(),\n error: z.string().optional(),\n }),\n ),\n });\n\n registerTool({\n name: \"remove_interactable_component\",\n description: \"Remove an interactable component from the system\",\n tool: (componentId: string) => {\n const component = interactableComponents.find(\n (c) => c.id === componentId,\n );\n\n if (!component) {\n return {\n success: false,\n error: `Component with ID ${componentId} not found`,\n };\n }\n\n setInteractableComponents((prev) =>\n prev.filter((c) => c.id !== componentId),\n );\n\n return {\n success: true,\n componentId,\n removedComponent: {\n id: component.id,\n componentName: component.name,\n props: component.props,\n },\n };\n },\n toolSchema: z\n .function()\n .args(z.string())\n .returns(\n z.object({\n success: z.boolean(),\n componentId: z.string(),\n removedComponent: z.object({\n id: z.string(),\n componentName: z.string(),\n props: z.record(z.any()),\n }),\n error: z.string().optional(),\n }),\n ),\n });\n }, [interactableComponents, registerTool]);\n\n const updateInteractableComponentProps = useCallback(\n (id: string, newProps: Record<string, any>) => {\n let updateResult = \"Updated successfully\";\n\n setInteractableComponents((prev) => {\n const componentExists = prev.some((c) => c.id === id);\n\n if (!componentExists) {\n updateResult = `Error: Component with ID ${id} not found`;\n return prev;\n }\n\n const updatedComponents = prev.map((c) =>\n c.id === id ? { ...c, props: { ...c.props, ...newProps } } : c,\n );\n\n // Check if the update actually changed anything\n const originalComponent = prev.find((c) => c.id === id);\n const updatedComponent = updatedComponents.find((c) => c.id === id);\n\n if (!originalComponent || !updatedComponent) {\n updateResult = `Error: Failed to update component with ID ${id}`;\n return prev;\n }\n\n // Check if props actually changed\n const propsChanged =\n JSON.stringify(originalComponent.props) !==\n JSON.stringify(updatedComponent.props);\n\n if (!propsChanged) {\n updateResult = `Warning: No changes detected for component with ID ${id}. The update might not have worked.`;\n return prev;\n }\n\n return updatedComponents;\n });\n\n return updateResult;\n },\n [],\n );\n\n const registerInteractableComponentUpdateTool = useCallback(\n (component: TamboInteractableComponent) => {\n const schemaForArgs =\n typeof component.propsSchema === \"object\" &&\n \"describe\" in component.propsSchema\n ? component.propsSchema\n : z.object({});\n\n registerTool({\n name: `update_interactable_component_${component.id}`,\n description: `Update the props of interactable component ${component.id} (${component.name})`,\n tool: (componentId: string, newProps: any) => {\n return updateInteractableComponentProps(componentId, newProps);\n },\n toolSchema: z\n .function()\n .args(\n z\n .string()\n .describe(\"The ID of the interactable component to update\"),\n schemaForArgs.describe(\n \"The new props to update the component with\",\n ),\n )\n .returns(z.string()),\n });\n },\n [registerTool, updateInteractableComponentProps],\n );\n\n const addInteractableComponent = useCallback(\n (\n component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\">,\n ): string => {\n const id = `${component.name}-${Math.random().toString(36).substr(2, 9)}`;\n const newComponent: TamboInteractableComponent = {\n ...component,\n id,\n };\n\n registerInteractableComponentUpdateTool(newComponent);\n\n setInteractableComponents((prev) => {\n return [...prev, newComponent];\n });\n\n return id;\n },\n [registerInteractableComponentUpdateTool],\n );\n\n const removeInteractableComponent = useCallback((id: string) => {\n setInteractableComponents((prev) => prev.filter((c) => c.id !== id));\n }, []);\n\n const getInteractableComponent = useCallback(\n (id: string) => {\n return interactableComponents.find((c) => c.id === id);\n },\n [interactableComponents],\n );\n\n const getInteractableComponentsByName = useCallback(\n (componentName: string) => {\n return interactableComponents.filter((c) => c.name === componentName);\n },\n [interactableComponents],\n );\n\n const clearAllInteractableComponents = useCallback(() => {\n setInteractableComponents([]);\n }, []);\n\n const value: TamboInteractableContext = {\n interactableComponents,\n addInteractableComponent,\n removeInteractableComponent,\n updateInteractableComponentProps,\n getInteractableComponent,\n getInteractableComponentsByName,\n clearAllInteractableComponents,\n };\n\n return (\n <TamboInteractableContext.Provider value={value}>\n {children}\n </TamboInteractableContext.Provider>\n );\n};\n\n/**\n * The useTamboInteractable hook provides access to the interactable component\n * management functions.\n * @returns The interactable component management functions\n */\nexport const useTamboInteractable = () => {\n return useContext(TamboInteractableContext);\n};\n"]}
1
+ {"version":3,"file":"tambo-interactable-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-interactable-provider.tsx"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,YAAY,CAAC;AACb,OAAO,KAAK,EAAE,EACZ,aAAa,EAEb,WAAW,EACX,UAAU,EACV,SAAS,EACT,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D,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,GAAE,CAAC;IAC1C,wBAAwB,EAAE,GAAG,EAAE,CAAC,SAAS;IACzC,+BAA+B,EAAE,GAAG,EAAE,CAAC,EAAE;IACzC,8BAA8B,EAAE,GAAG,EAAE,GAAE,CAAC;CACzC,CAAC,CAAC;AAEH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAgC,CAAC,EACrE,QAAQ,GACT,EAAE,EAAE;IACH,MAAM,CAAC,sBAAsB,EAAE,yBAAyB,CAAC,GAAG,QAAQ,CAElE,EAAE,CAAC,CAAC;IACN,MAAM,EAAE,YAAY,EAAE,GAAG,iBAAiB,EAAE,CAAC;IAE7C,SAAS,CAAC,GAAG,EAAE;QACb,YAAY,CAAC;YACX,IAAI,EAAE,iCAAiC;YACvC,WAAW,EACT,2OAA2O;YAC7O,IAAI,EAAE,GAAG,EAAE;gBACT,OAAO;oBACL,UAAU,EAAE,sBAAsB;iBACnC,CAAC;YACJ,CAAC;YACD,UAAU,EAAE,CAAC,CAAC,QA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AqB,EAAE,EAAE;QACxB,OAAO,sBAAsB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,aAAa,CAAC,CAAC;IACxE,CAAC,EACD,CAAC,sBAAsB,CAAC,CACzB,CAAC;IAEF,MAAM,8BAA8B,GAAG,WAAW,CAAC,GAAG,EAAE;QACtD,yBAAyB,CAAC,EAAE,CAAC,CAAC;IAChC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,KAAK,GAA6B;QACtC,sBAAsB;QACtB,wBAAwB;QACxB,2BAA2B;QAC3B,gCAAgC;QAChC,wBAAwB;QACxB,+BAA+B;QAC/B,8BAA8B;KAC/B,CAAC;IAEF,OAAO,CACL,oBAAC,wBAAwB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IAC5C,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","sourcesContent":["// react-sdk/src/providers/tambo-interactable-provider.tsx\n\"use client\";\nimport React, {\n createContext,\n PropsWithChildren,\n useCallback,\n useContext,\n useEffect,\n useState,\n} from \"react\";\nimport { z } from \"zod\";\nimport {\n TamboInteractableComponent,\n type TamboInteractableContext,\n} from \"../model/tambo-interactable\";\nimport { useTamboComponent } from \"./tambo-component-provider\";\n\nconst TamboInteractableContext = createContext<TamboInteractableContext>({\n interactableComponents: [],\n addInteractableComponent: () => \"\",\n removeInteractableComponent: () => {},\n updateInteractableComponentProps: () => {},\n getInteractableComponent: () => undefined,\n getInteractableComponentsByName: () => [],\n clearAllInteractableComponents: () => {},\n});\n\n/**\n * The TamboInteractableProvider manages a list of components that are currently\n * interactable, allowing tambo to interact with them by updating their props. It also registers tools\n * for Tambo to perform CRUD operations on the components list.\n * @param props - The props for the TamboInteractableProvider\n * @param props.children - The children to wrap\n * @returns The TamboInteractableProvider component\n */\nexport const TamboInteractableProvider: React.FC<PropsWithChildren> = ({\n children,\n}) => {\n const [interactableComponents, setInteractableComponents] = useState<\n TamboInteractableComponent[]\n >([]);\n const { registerTool } = useTamboComponent();\n\n useEffect(() => {\n registerTool({\n name: \"get_all_interactable_components\",\n description:\n \"Only use this tool if the user is asking about interactable components.Get all currently interactable components with their details including their current props. These are components that you can interact with on behalf of the user.\",\n tool: () => {\n return {\n components: interactableComponents,\n };\n },\n toolSchema: z.function().returns(\n z.object({\n components: z.array(\n z.object({\n id: z.string(),\n componentName: z.string(),\n props: z.record(z.any()),\n propsSchema: z.object({}).optional(),\n }),\n ),\n }),\n ),\n });\n\n registerTool({\n name: \"get_interactable_component_by_id\",\n description: \"Get a specific interactable component by its ID\",\n tool: (componentId: string) => {\n const component = interactableComponents.find(\n (c) => c.id === componentId,\n );\n\n if (!component) {\n return {\n success: false,\n error: `Component with ID ${componentId} not found`,\n };\n }\n\n return {\n success: true,\n component: {\n id: component.id,\n componentName: component.name,\n props: component.props,\n },\n };\n },\n toolSchema: z\n .function()\n .args(z.string())\n .returns(\n z.object({\n success: z.boolean(),\n component: z\n .object({\n id: z.string(),\n componentName: z.string(),\n props: z.record(z.any()),\n })\n .optional(),\n error: z.string().optional(),\n }),\n ),\n });\n\n registerTool({\n name: \"remove_interactable_component\",\n description: \"Remove an interactable component from the system\",\n tool: (componentId: string) => {\n const component = interactableComponents.find(\n (c) => c.id === componentId,\n );\n\n if (!component) {\n return {\n success: false,\n error: `Component with ID ${componentId} not found`,\n };\n }\n\n setInteractableComponents((prev) =>\n prev.filter((c) => c.id !== componentId),\n );\n\n return {\n success: true,\n componentId,\n removedComponent: {\n id: component.id,\n componentName: component.name,\n props: component.props,\n },\n };\n },\n toolSchema: z\n .function()\n .args(z.string())\n .returns(\n z.object({\n success: z.boolean(),\n componentId: z.string(),\n removedComponent: z.object({\n id: z.string(),\n componentName: z.string(),\n props: z.record(z.any()),\n }),\n error: z.string().optional(),\n }),\n ),\n });\n }, [interactableComponents, registerTool]);\n\n const updateInteractableComponentProps = useCallback(\n (id: string, newProps: Record<string, any>) => {\n let updateResult = \"Updated successfully\";\n\n setInteractableComponents((prev) => {\n const componentExists = prev.some((c) => c.id === id);\n\n if (!componentExists) {\n updateResult = `Error: Component with ID ${id} not found`;\n return prev;\n }\n\n const updatedComponents = prev.map((c) =>\n c.id === id ? { ...c, props: { ...c.props, ...newProps } } : c,\n );\n\n // Check if the update actually changed anything\n const originalComponent = prev.find((c) => c.id === id);\n const updatedComponent = updatedComponents.find((c) => c.id === id);\n\n if (!originalComponent || !updatedComponent) {\n updateResult = `Error: Failed to update component with ID ${id}`;\n return prev;\n }\n\n // Check if props actually changed\n const propsChanged =\n JSON.stringify(originalComponent.props) !==\n JSON.stringify(updatedComponent.props);\n\n if (!propsChanged) {\n updateResult = `Warning: No changes detected for component with ID ${id}. The update might not have worked.`;\n return prev;\n }\n\n return updatedComponents;\n });\n\n return updateResult;\n },\n [],\n );\n\n const registerInteractableComponentUpdateTool = useCallback(\n (component: TamboInteractableComponent) => {\n const schemaForArgs =\n typeof component.propsSchema === \"object\" &&\n \"describe\" in component.propsSchema\n ? component.propsSchema\n : z.object({});\n\n registerTool({\n name: `update_interactable_component_${component.id}`,\n description: `Update the props of interactable component ${component.id} (${component.name})`,\n tool: (componentId: string, newProps: any) => {\n return updateInteractableComponentProps(componentId, newProps);\n },\n toolSchema: z\n .function()\n .args(\n z\n .string()\n .describe(\"The ID of the interactable component to update\"),\n schemaForArgs.describe(\n \"The new props to update the component with\",\n ),\n )\n .returns(z.string()),\n });\n },\n [registerTool, updateInteractableComponentProps],\n );\n\n const addInteractableComponent = useCallback(\n (\n component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\">,\n ): string => {\n const id = `${component.name}-${Math.random().toString(36).substr(2, 9)}`;\n const newComponent: TamboInteractableComponent = {\n ...component,\n id,\n };\n\n registerInteractableComponentUpdateTool(newComponent);\n\n setInteractableComponents((prev) => {\n return [...prev, newComponent];\n });\n\n return id;\n },\n [registerInteractableComponentUpdateTool],\n );\n\n const removeInteractableComponent = useCallback((id: string) => {\n setInteractableComponents((prev) => prev.filter((c) => c.id !== id));\n }, []);\n\n const getInteractableComponent = useCallback(\n (id: string) => {\n return interactableComponents.find((c) => c.id === id);\n },\n [interactableComponents],\n );\n\n const getInteractableComponentsByName = useCallback(\n (componentName: string) => {\n return interactableComponents.filter((c) => c.name === componentName);\n },\n [interactableComponents],\n );\n\n const clearAllInteractableComponents = useCallback(() => {\n setInteractableComponents([]);\n }, []);\n\n const value: TamboInteractableContext = {\n interactableComponents,\n addInteractableComponent,\n removeInteractableComponent,\n updateInteractableComponentProps,\n getInteractableComponent,\n getInteractableComponentsByName,\n clearAllInteractableComponents,\n };\n\n return (\n <TamboInteractableContext.Provider value={value}>\n {children}\n </TamboInteractableContext.Provider>\n );\n};\n\n/**\n * The useTamboInteractable hook provides access to the interactable component\n * management functions.\n * @returns The interactable component management functions\n */\nexport const useTamboInteractable = () => {\n return useContext(TamboInteractableContext);\n};\n"]}
@@ -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 { TamboContextHelpersContextProps, TamboContextHelpersProviderProps } from "./tambo-context-helpers-provider";
5
6
  import { TamboRegistryProviderProps } from "./tambo-registry-provider";
6
7
  import { TamboThreadContextProps, TamboThreadProviderProps } from "./tambo-thread-provider";
7
8
  /**
@@ -15,10 +16,11 @@ import { TamboThreadContextProps, TamboThreadProviderProps } from "./tambo-threa
15
16
  * @param props.environment - The environment to use for the Tambo API
16
17
  * @param props.tools - The tools to register
17
18
  * @param props.streaming - Whether to stream the response by default. Defaults to true.
19
+ * @param props.contextHelpers - Configuration for which context helpers are enabled/disabled
18
20
  * @returns The TamboProvider component
19
21
  */
20
- export declare const TamboProvider: React.FC<PropsWithChildren<TamboClientProviderProps & TamboRegistryProviderProps & TamboThreadProviderProps>>;
21
- export type TamboContextProps = TamboClientContextProps & TamboThreadContextProps & TamboComponentContextProps & TamboInteractableContext;
22
+ export declare const TamboProvider: React.FC<PropsWithChildren<TamboClientProviderProps & TamboRegistryProviderProps & TamboThreadProviderProps & TamboContextHelpersProviderProps>>;
23
+ export type TamboContextProps = TamboClientContextProps & TamboThreadContextProps & TamboComponentContextProps & TamboInteractableContext & TamboContextHelpersContextProps;
22
24
  export declare const TamboContext: React.Context<TamboContextProps>;
23
25
  /**
24
26
  * 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":"AACA,OAAO,KAAK,EAAE,EAAE,iBAAiB,EAA6B,MAAM,OAAO,CAAC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EACL,uBAAuB,EAEvB,wBAAwB,EAGzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,0BAA0B,EAG3B,MAAM,4BAA4B,CAAC;AAKpC,OAAO,EAEL,0BAA0B,EAC3B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,uBAAuB,EAEvB,wBAAwB,EAEzB,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAClC,iBAAiB,CACf,wBAAwB,GACtB,0BAA0B,GAC1B,wBAAwB,CAC3B,CAkCF,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,uBAAuB,GACrD,uBAAuB,GACvB,0BAA0B,GAC1B,wBAAwB,CAAC;AAE3B,eAAO,MAAM,YAAY,kCAExB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAsB9D,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,yBAEpB,CAAC"}
1
+ {"version":3,"file":"tambo-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,iBAAiB,EAA6B,MAAM,OAAO,CAAC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EACL,uBAAuB,EAEvB,wBAAwB,EAGzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,0BAA0B,EAG3B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,+BAA+B,EAE/B,gCAAgC,EAEjC,MAAM,kCAAkC,CAAC;AAK1C,OAAO,EAEL,0BAA0B,EAC3B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,uBAAuB,EAEvB,wBAAwB,EAEzB,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAClC,iBAAiB,CACf,wBAAwB,GACtB,0BAA0B,GAC1B,wBAAwB,GACxB,gCAAgC,CACnC,CAqCF,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,uBAAuB,GACrD,uBAAuB,GACvB,0BAA0B,GAC1B,wBAAwB,GACxB,+BAA+B,CAAC;AAElC,eAAO,MAAM,YAAY,kCAExB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAwB9D,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,yBAEpB,CAAC"}
@@ -2,6 +2,7 @@
2
2
  import React, { createContext, useContext } from "react";
3
3
  import { TamboClientProvider, useTamboClient, useTamboQueryClient, } from "./tambo-client-provider";
4
4
  import { TamboComponentProvider, useTamboComponent, } from "./tambo-component-provider";
5
+ import { TamboContextHelpersProvider, useTamboContextHelpers, } from "./tambo-context-helpers-provider";
5
6
  import { TamboInteractableProvider, useTamboInteractable, } from "./tambo-interactable-provider";
6
7
  import { TamboRegistryProvider, } from "./tambo-registry-provider";
7
8
  import { TamboThreadProvider, useTamboThread, } from "./tambo-thread-provider";
@@ -16,19 +17,21 @@ import { TamboThreadProvider, useTamboThread, } from "./tambo-thread-provider";
16
17
  * @param props.environment - The environment to use for the Tambo API
17
18
  * @param props.tools - The tools to register
18
19
  * @param props.streaming - Whether to stream the response by default. Defaults to true.
20
+ * @param props.contextHelpers - Configuration for which context helpers are enabled/disabled
19
21
  * @returns The TamboProvider component
20
22
  */
21
- export const TamboProvider = ({ children, tamboUrl, apiKey, userToken, components, environment, tools, streaming, }) => {
23
+ export const TamboProvider = ({ children, tamboUrl, apiKey, userToken, components, environment, tools, streaming, contextHelpers, }) => {
22
24
  // Should only be used in browser
23
25
  if (typeof window === "undefined") {
24
26
  console.error("TamboProvider must be used within a browser");
25
27
  }
26
28
  return (React.createElement(TamboClientProvider, { tamboUrl: tamboUrl, apiKey: apiKey, environment: environment, userToken: userToken },
27
29
  React.createElement(TamboRegistryProvider, { components: components, tools: tools },
28
- React.createElement(TamboThreadProvider, { streaming: streaming },
29
- React.createElement(TamboComponentProvider, null,
30
- React.createElement(TamboInteractableProvider, null,
31
- React.createElement(TamboCompositeProvider, null, children)))))));
30
+ React.createElement(TamboContextHelpersProvider, { contextHelpers: contextHelpers },
31
+ React.createElement(TamboThreadProvider, { streaming: streaming },
32
+ React.createElement(TamboComponentProvider, null,
33
+ React.createElement(TamboInteractableProvider, null,
34
+ React.createElement(TamboCompositeProvider, null, children))))))));
32
35
  };
33
36
  export const TamboContext = createContext({});
34
37
  /**
@@ -44,12 +47,14 @@ export const TamboCompositeProvider = ({ children, }) => {
44
47
  const queryClient = useTamboQueryClient();
45
48
  const componentRegistry = useTamboComponent();
46
49
  const interactableComponents = useTamboInteractable();
50
+ const contextHelpers = useTamboContextHelpers();
47
51
  return (React.createElement(TamboContext.Provider, { value: {
48
52
  client,
49
53
  queryClient,
50
54
  ...componentRegistry,
51
55
  ...threads,
52
56
  ...interactableComponents,
57
+ ...contextHelpers,
53
58
  } }, children));
54
59
  };
55
60
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"tambo-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,KAAK,EAAE,EAAqB,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE5E,OAAO,EAEL,mBAAmB,EAEnB,cAAc,EACd,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEL,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,qBAAqB,GAEtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAEL,mBAAmB,EAEnB,cAAc,GACf,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,aAAa,GAMtB,CAAC,EACH,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,SAAS,EACT,UAAU,EACV,WAAW,EACX,KAAK,EACL,SAAS,GACV,EAAE,EAAE;IACH,iCAAiC;IACjC,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,OAAO,CAAC,KAAK,CAAC,6CAA6C,CAAC,CAAC;IAC/D,CAAC;IAED,OAAO,CACL,oBAAC,mBAAmB,IAClB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS;QAEpB,oBAAC,qBAAqB,IAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK;YACzD,oBAAC,mBAAmB,IAAC,SAAS,EAAE,SAAS;gBACvC,oBAAC,sBAAsB;oBACrB,oBAAC,yBAAyB;wBACxB,oBAAC,sBAAsB,QAAE,QAAQ,CAA0B,CACjC,CACL,CACL,CACA,CACJ,CACvB,CAAC;AACJ,CAAC,CAAC;AAOF,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CACvC,EAAuB,CACxB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAgC,CAAC,EAClE,QAAQ,GACT,EAAE,EAAE;IACH,MAAM,OAAO,GAAG,cAAc,EAAE,CAAC;IACjC,MAAM,MAAM,GAAG,cAAc,EAAE,CAAC;IAChC,MAAM,WAAW,GAAG,mBAAmB,EAAE,CAAC;IAC1C,MAAM,iBAAiB,GAAG,iBAAiB,EAAE,CAAC;IAC9C,MAAM,sBAAsB,GAAG,oBAAoB,EAAE,CAAC;IAEtD,OAAO,CACL,oBAAC,YAAY,CAAC,QAAQ,IACpB,KAAK,EAAE;YACL,MAAM;YACN,WAAW;YACX,GAAG,iBAAiB;YACpB,GAAG,OAAO;YACV,GAAG,sBAAsB;SAC1B,IAEA,QAAQ,CACa,CACzB,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAE;IAC3B,OAAO,UAAU,CAAC,YAAY,CAAC,CAAC;AAClC,CAAC,CAAC","sourcesContent":["\"use client\";\nimport React, { PropsWithChildren, createContext, useContext } from \"react\";\nimport { TamboInteractableContext } from \"../model/tambo-interactable\";\nimport {\n TamboClientContextProps,\n TamboClientProvider,\n TamboClientProviderProps,\n useTamboClient,\n useTamboQueryClient,\n} from \"./tambo-client-provider\";\nimport {\n TamboComponentContextProps,\n TamboComponentProvider,\n useTamboComponent,\n} from \"./tambo-component-provider\";\nimport {\n TamboInteractableProvider,\n useTamboInteractable,\n} from \"./tambo-interactable-provider\";\nimport {\n TamboRegistryProvider,\n TamboRegistryProviderProps,\n} from \"./tambo-registry-provider\";\nimport {\n TamboThreadContextProps,\n TamboThreadProvider,\n TamboThreadProviderProps,\n useTamboThread,\n} from \"./tambo-thread-provider\";\n\n/**\n * The TamboProvider gives full access to the whole Tambo API. This includes the\n * TamboAI client, the component registry, the current thread context, and interactable components.\n * @param props - The props for the TamboProvider\n * @param props.children - The children to wrap\n * @param props.tamboUrl - The URL of the Tambo API\n * @param props.apiKey - The API key for the Tambo API\n * @param props.components - The components to register\n * @param props.environment - The environment to use for the Tambo API\n * @param props.tools - The tools to register\n * @param props.streaming - Whether to stream the response by default. Defaults to true.\n * @returns The TamboProvider component\n */\nexport const TamboProvider: React.FC<\n PropsWithChildren<\n TamboClientProviderProps &\n TamboRegistryProviderProps &\n TamboThreadProviderProps\n >\n> = ({\n children,\n tamboUrl,\n apiKey,\n userToken,\n components,\n environment,\n tools,\n streaming,\n}) => {\n // Should only be used in browser\n if (typeof window === \"undefined\") {\n console.error(\"TamboProvider must be used within a browser\");\n }\n\n return (\n <TamboClientProvider\n tamboUrl={tamboUrl}\n apiKey={apiKey}\n environment={environment}\n userToken={userToken}\n >\n <TamboRegistryProvider components={components} tools={tools}>\n <TamboThreadProvider streaming={streaming}>\n <TamboComponentProvider>\n <TamboInteractableProvider>\n <TamboCompositeProvider>{children}</TamboCompositeProvider>\n </TamboInteractableProvider>\n </TamboComponentProvider>\n </TamboThreadProvider>\n </TamboRegistryProvider>\n </TamboClientProvider>\n );\n};\n\nexport type TamboContextProps = TamboClientContextProps &\n TamboThreadContextProps &\n TamboComponentContextProps &\n TamboInteractableContext;\n\nexport const TamboContext = createContext<TamboContextProps>(\n {} as TamboContextProps,\n);\n\n/**\n * TamboCompositeProvider is a provider that combines the TamboClient,\n * TamboThread, TamboComponent, and TamboInteractable providers\n * @param props - The props for the TamboCompositeProvider\n * @param props.children - The children to wrap\n * @returns The wrapped component\n */\nexport const TamboCompositeProvider: React.FC<PropsWithChildren> = ({\n children,\n}) => {\n const threads = useTamboThread();\n const client = useTamboClient();\n const queryClient = useTamboQueryClient();\n const componentRegistry = useTamboComponent();\n const interactableComponents = useTamboInteractable();\n\n return (\n <TamboContext.Provider\n value={{\n client,\n queryClient,\n ...componentRegistry,\n ...threads,\n ...interactableComponents,\n }}\n >\n {children}\n </TamboContext.Provider>\n );\n};\n\n/**\n * The useTambo hook provides access to the Tambo API. This is the primary entrypoint\n * for the Tambo React SDK.\n *\n * This includes the TamboAI client, the component registry, the current thread context,\n * and interactable component management.\n * @returns The Tambo API\n */\nexport const useTambo = () => {\n return useContext(TamboContext);\n};\n"]}
1
+ {"version":3,"file":"tambo-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,KAAK,EAAE,EAAqB,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE5E,OAAO,EAEL,mBAAmB,EAEnB,cAAc,EACd,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEL,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAEL,2BAA2B,EAE3B,sBAAsB,GACvB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,qBAAqB,GAEtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAEL,mBAAmB,EAEnB,cAAc,GACf,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,aAAa,GAOtB,CAAC,EACH,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,SAAS,EACT,UAAU,EACV,WAAW,EACX,KAAK,EACL,SAAS,EACT,cAAc,GACf,EAAE,EAAE;IACH,iCAAiC;IACjC,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,OAAO,CAAC,KAAK,CAAC,6CAA6C,CAAC,CAAC;IAC/D,CAAC;IAED,OAAO,CACL,oBAAC,mBAAmB,IAClB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS;QAEpB,oBAAC,qBAAqB,IAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK;YACzD,oBAAC,2BAA2B,IAAC,cAAc,EAAE,cAAc;gBACzD,oBAAC,mBAAmB,IAAC,SAAS,EAAE,SAAS;oBACvC,oBAAC,sBAAsB;wBACrB,oBAAC,yBAAyB;4BACxB,oBAAC,sBAAsB,QAAE,QAAQ,CAA0B,CACjC,CACL,CACL,CACM,CACR,CACJ,CACvB,CAAC;AACJ,CAAC,CAAC;AAQF,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CACvC,EAAuB,CACxB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAgC,CAAC,EAClE,QAAQ,GACT,EAAE,EAAE;IACH,MAAM,OAAO,GAAG,cAAc,EAAE,CAAC;IACjC,MAAM,MAAM,GAAG,cAAc,EAAE,CAAC;IAChC,MAAM,WAAW,GAAG,mBAAmB,EAAE,CAAC;IAC1C,MAAM,iBAAiB,GAAG,iBAAiB,EAAE,CAAC;IAC9C,MAAM,sBAAsB,GAAG,oBAAoB,EAAE,CAAC;IACtD,MAAM,cAAc,GAAG,sBAAsB,EAAE,CAAC;IAEhD,OAAO,CACL,oBAAC,YAAY,CAAC,QAAQ,IACpB,KAAK,EAAE;YACL,MAAM;YACN,WAAW;YACX,GAAG,iBAAiB;YACpB,GAAG,OAAO;YACV,GAAG,sBAAsB;YACzB,GAAG,cAAc;SAClB,IAEA,QAAQ,CACa,CACzB,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAE;IAC3B,OAAO,UAAU,CAAC,YAAY,CAAC,CAAC;AAClC,CAAC,CAAC","sourcesContent":["\"use client\";\nimport React, { PropsWithChildren, createContext, useContext } from \"react\";\nimport { TamboInteractableContext } from \"../model/tambo-interactable\";\nimport {\n TamboClientContextProps,\n TamboClientProvider,\n TamboClientProviderProps,\n useTamboClient,\n useTamboQueryClient,\n} from \"./tambo-client-provider\";\nimport {\n TamboComponentContextProps,\n TamboComponentProvider,\n useTamboComponent,\n} from \"./tambo-component-provider\";\nimport {\n TamboContextHelpersContextProps,\n TamboContextHelpersProvider,\n TamboContextHelpersProviderProps,\n useTamboContextHelpers,\n} from \"./tambo-context-helpers-provider\";\nimport {\n TamboInteractableProvider,\n useTamboInteractable,\n} from \"./tambo-interactable-provider\";\nimport {\n TamboRegistryProvider,\n TamboRegistryProviderProps,\n} from \"./tambo-registry-provider\";\nimport {\n TamboThreadContextProps,\n TamboThreadProvider,\n TamboThreadProviderProps,\n useTamboThread,\n} from \"./tambo-thread-provider\";\n\n/**\n * The TamboProvider gives full access to the whole Tambo API. This includes the\n * TamboAI client, the component registry, the current thread context, and interactable components.\n * @param props - The props for the TamboProvider\n * @param props.children - The children to wrap\n * @param props.tamboUrl - The URL of the Tambo API\n * @param props.apiKey - The API key for the Tambo API\n * @param props.components - The components to register\n * @param props.environment - The environment to use for the Tambo API\n * @param props.tools - The tools to register\n * @param props.streaming - Whether to stream the response by default. Defaults to true.\n * @param props.contextHelpers - Configuration for which context helpers are enabled/disabled\n * @returns The TamboProvider component\n */\nexport const TamboProvider: React.FC<\n PropsWithChildren<\n TamboClientProviderProps &\n TamboRegistryProviderProps &\n TamboThreadProviderProps &\n TamboContextHelpersProviderProps\n >\n> = ({\n children,\n tamboUrl,\n apiKey,\n userToken,\n components,\n environment,\n tools,\n streaming,\n contextHelpers,\n}) => {\n // Should only be used in browser\n if (typeof window === \"undefined\") {\n console.error(\"TamboProvider must be used within a browser\");\n }\n\n return (\n <TamboClientProvider\n tamboUrl={tamboUrl}\n apiKey={apiKey}\n environment={environment}\n userToken={userToken}\n >\n <TamboRegistryProvider components={components} tools={tools}>\n <TamboContextHelpersProvider contextHelpers={contextHelpers}>\n <TamboThreadProvider streaming={streaming}>\n <TamboComponentProvider>\n <TamboInteractableProvider>\n <TamboCompositeProvider>{children}</TamboCompositeProvider>\n </TamboInteractableProvider>\n </TamboComponentProvider>\n </TamboThreadProvider>\n </TamboContextHelpersProvider>\n </TamboRegistryProvider>\n </TamboClientProvider>\n );\n};\n\nexport type TamboContextProps = TamboClientContextProps &\n TamboThreadContextProps &\n TamboComponentContextProps &\n TamboInteractableContext &\n TamboContextHelpersContextProps;\n\nexport const TamboContext = createContext<TamboContextProps>(\n {} as TamboContextProps,\n);\n\n/**\n * TamboCompositeProvider is a provider that combines the TamboClient,\n * TamboThread, TamboComponent, and TamboInteractable providers\n * @param props - The props for the TamboCompositeProvider\n * @param props.children - The children to wrap\n * @returns The wrapped component\n */\nexport const TamboCompositeProvider: React.FC<PropsWithChildren> = ({\n children,\n}) => {\n const threads = useTamboThread();\n const client = useTamboClient();\n const queryClient = useTamboQueryClient();\n const componentRegistry = useTamboComponent();\n const interactableComponents = useTamboInteractable();\n const contextHelpers = useTamboContextHelpers();\n\n return (\n <TamboContext.Provider\n value={{\n client,\n queryClient,\n ...componentRegistry,\n ...threads,\n ...interactableComponents,\n ...contextHelpers,\n }}\n >\n {children}\n </TamboContext.Provider>\n );\n};\n\n/**\n * The useTambo hook provides access to the Tambo API. This is the primary entrypoint\n * for the Tambo React SDK.\n *\n * This includes the TamboAI client, the component registry, the current thread context,\n * and interactable component management.\n * @returns The Tambo API\n */\nexport const useTambo = () => {\n return useContext(TamboContext);\n};\n"]}
@@ -2,6 +2,7 @@ import TamboAI from "@tambo-ai/typescript-sdk";
2
2
  import React, { PropsWithChildren } from "react";
3
3
  import { TamboComponent, TamboTool } from "../model/component-metadata";
4
4
  import { TamboThread } from "../model/tambo-thread";
5
+ import { TamboContextHelpersProviderProps } from "./tambo-context-helpers-provider";
5
6
  import { type TamboContextProps } from "./tambo-provider";
6
7
  /**
7
8
  * TamboStubProvider props - includes all the data that would normally be inferred
@@ -19,6 +20,8 @@ export interface TamboStubProviderProps extends Partial<TamboContextProps> {
19
20
  projectId?: string;
20
21
  /** Optional: Context key for thread list queries */
21
22
  contextKey?: string;
23
+ /** Optional: Configuration for which context helpers are enabled/disabled */
24
+ contextHelpers?: TamboContextHelpersProviderProps["contextHelpers"];
22
25
  }
23
26
  /**
24
27
  * The TamboStubProvider provides a way to use the Tambo API with static/stub data.
@@ -79,6 +82,7 @@ export interface TamboStubProviderProps extends Partial<TamboContextProps> {
79
82
  * @param props.threads - Optional threads data to populate thread list (overrides useTamboThreadList)
80
83
  * @param props.projectId - Optional project ID for query cache (defaults to thread.projectId)
81
84
  * @param props.contextKey - Optional context key for thread list queries
85
+ * @param props.contextHelpers - Optional configuration for which context helpers are enabled/disabled
82
86
  * @returns The TamboStubProvider component
83
87
  */
84
88
  export declare const TamboStubProvider: React.FC<PropsWithChildren<TamboStubProviderProps>>;