@tambo-ai/react 0.42.1 → 0.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/dist/context-helpers/__tests__/context-helpers-provider.test.d.ts +15 -0
  2. package/dist/context-helpers/__tests__/context-helpers-provider.test.d.ts.map +1 -0
  3. package/dist/context-helpers/__tests__/context-helpers-provider.test.js +147 -0
  4. package/dist/context-helpers/__tests__/context-helpers-provider.test.js.map +1 -0
  5. package/dist/context-helpers/__tests__/context-helpers.test.js +30 -35
  6. package/dist/context-helpers/__tests__/context-helpers.test.js.map +1 -1
  7. package/dist/context-helpers/current-page-context-helper.d.ts +7 -0
  8. package/dist/context-helpers/current-page-context-helper.d.ts.map +1 -0
  9. package/dist/context-helpers/current-page-context-helper.js +24 -0
  10. package/dist/context-helpers/current-page-context-helper.js.map +1 -0
  11. package/dist/context-helpers/current-time-context-helper.d.ts +7 -0
  12. package/dist/context-helpers/current-time-context-helper.d.ts.map +1 -0
  13. package/dist/context-helpers/current-time-context-helper.js +21 -0
  14. package/dist/context-helpers/current-time-context-helper.js.map +1 -0
  15. package/dist/context-helpers/index.d.ts +2 -7
  16. package/dist/context-helpers/index.d.ts.map +1 -1
  17. package/dist/context-helpers/index.js +2 -20
  18. package/dist/context-helpers/index.js.map +1 -1
  19. package/dist/context-helpers/registry.d.ts +35 -0
  20. package/dist/context-helpers/registry.d.ts.map +1 -0
  21. package/dist/context-helpers/registry.js +64 -0
  22. package/dist/context-helpers/registry.js.map +1 -0
  23. package/dist/context-helpers/types.d.ts +6 -16
  24. package/dist/context-helpers/types.d.ts.map +1 -1
  25. package/dist/context-helpers/types.js.map +1 -1
  26. package/dist/index.d.ts +2 -2
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +3 -4
  29. package/dist/index.js.map +1 -1
  30. package/dist/providers/__tests__/tambo-context-helpers-provider.test.js +278 -137
  31. package/dist/providers/__tests__/tambo-context-helpers-provider.test.js.map +1 -1
  32. package/dist/providers/__tests__/tambo-thread-provider.test.js +29 -7
  33. package/dist/providers/__tests__/tambo-thread-provider.test.js.map +1 -1
  34. package/dist/providers/tambo-context-helpers-provider.d.ts +24 -15
  35. package/dist/providers/tambo-context-helpers-provider.d.ts.map +1 -1
  36. package/dist/providers/tambo-context-helpers-provider.js +56 -39
  37. package/dist/providers/tambo-context-helpers-provider.js.map +1 -1
  38. package/esm/context-helpers/__tests__/context-helpers-provider.test.d.ts +15 -0
  39. package/esm/context-helpers/__tests__/context-helpers-provider.test.d.ts.map +1 -0
  40. package/esm/context-helpers/__tests__/context-helpers-provider.test.js +142 -0
  41. package/esm/context-helpers/__tests__/context-helpers-provider.test.js.map +1 -0
  42. package/esm/context-helpers/__tests__/context-helpers.test.js +31 -36
  43. package/esm/context-helpers/__tests__/context-helpers.test.js.map +1 -1
  44. package/esm/context-helpers/current-page-context-helper.d.ts +7 -0
  45. package/esm/context-helpers/current-page-context-helper.d.ts.map +1 -0
  46. package/esm/context-helpers/current-page-context-helper.js +20 -0
  47. package/esm/context-helpers/current-page-context-helper.js.map +1 -0
  48. package/esm/context-helpers/current-time-context-helper.d.ts +7 -0
  49. package/esm/context-helpers/current-time-context-helper.d.ts.map +1 -0
  50. package/esm/context-helpers/current-time-context-helper.js +17 -0
  51. package/esm/context-helpers/current-time-context-helper.js.map +1 -0
  52. package/esm/context-helpers/index.d.ts +2 -7
  53. package/esm/context-helpers/index.d.ts.map +1 -1
  54. package/esm/context-helpers/index.js +2 -19
  55. package/esm/context-helpers/index.js.map +1 -1
  56. package/esm/context-helpers/registry.d.ts +35 -0
  57. package/esm/context-helpers/registry.d.ts.map +1 -0
  58. package/esm/context-helpers/registry.js +57 -0
  59. package/esm/context-helpers/registry.js.map +1 -0
  60. package/esm/context-helpers/types.d.ts +6 -16
  61. package/esm/context-helpers/types.d.ts.map +1 -1
  62. package/esm/context-helpers/types.js.map +1 -1
  63. package/esm/index.d.ts +2 -2
  64. package/esm/index.d.ts.map +1 -1
  65. package/esm/index.js +1 -1
  66. package/esm/index.js.map +1 -1
  67. package/esm/providers/__tests__/tambo-context-helpers-provider.test.js +279 -105
  68. package/esm/providers/__tests__/tambo-context-helpers-provider.test.js.map +1 -1
  69. package/esm/providers/__tests__/tambo-thread-provider.test.js +29 -7
  70. package/esm/providers/__tests__/tambo-thread-provider.test.js.map +1 -1
  71. package/esm/providers/tambo-context-helpers-provider.d.ts +24 -15
  72. package/esm/providers/tambo-context-helpers-provider.d.ts.map +1 -1
  73. package/esm/providers/tambo-context-helpers-provider.js +57 -40
  74. package/esm/providers/tambo-context-helpers-provider.js.map +1 -1
  75. package/package.json +2 -2
  76. package/dist/context-helpers/user-page.d.ts +0 -7
  77. package/dist/context-helpers/user-page.d.ts.map +0 -1
  78. package/dist/context-helpers/user-page.js +0 -31
  79. package/dist/context-helpers/user-page.js.map +0 -1
  80. package/dist/context-helpers/user-time.d.ts +0 -7
  81. package/dist/context-helpers/user-time.d.ts.map +0 -1
  82. package/dist/context-helpers/user-time.js +0 -20
  83. package/dist/context-helpers/user-time.js.map +0 -1
  84. package/esm/context-helpers/user-page.d.ts +0 -7
  85. package/esm/context-helpers/user-page.d.ts.map +0 -1
  86. package/esm/context-helpers/user-page.js +0 -28
  87. package/esm/context-helpers/user-page.js.map +0 -1
  88. package/esm/context-helpers/user-time.d.ts +0 -7
  89. package/esm/context-helpers/user-time.d.ts.map +0 -1
  90. package/esm/context-helpers/user-time.js +0 -17
  91. package/esm/context-helpers/user-time.js.map +0 -1
@@ -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,E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AAC;gBACpD,UAAU,EAAE,SAAS;gBACrB,WAAW,EAAE,EAAE;gBACf,eAAe,EAAE,SAAS;gBAC1B,cAAc,EAAE,EAAE;aACnB,EACD,SAAS,CACV,CAAC;YAEF,yCAAyC;YACzC,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,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
+ {"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,mCAAmC,CAAC;AAChF,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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anceStream } 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 // Use helpers that explicitly return null so they don't appear in additionalContext\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboRegistryProvider components={mockRegistry}>\n <TamboContextHelpersProvider\n contextHelpers={{\n currentTimeContextHelper: () => null,\n currentPageContextHelper: () => null,\n }}\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={{\n currentTimeContextHelper: () => null,\n currentPageContextHelper: () => null,\n }}\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={{\n currentTimeContextHelper: () => null,\n currentPageContextHelper: () => null,\n }}\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={{\n currentTimeContextHelper: () => null,\n currentPageContextHelper: () => null,\n }}\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={{\n currentTimeContextHelper: () => null,\n currentPageContextHelper: () => null,\n }}\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={{\n currentTimeContextHelper: () => null,\n currentPageContextHelper: () => null,\n }}\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={{\n currentTimeContextHelper: () => null,\n currentPageContextHelper: () => null,\n }}\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,28 +1,37 @@
1
1
  import React, { PropsWithChildren } from "react";
2
- import { AdditionalContext, AdditionalContextHelper, ContextHelpersConfig } from "../context-helpers";
2
+ import { AdditionalContext, ContextHelpers, ContextHelperFn } from "../context-helpers";
3
3
  export interface TamboContextHelpersProviderProps {
4
- /** Configuration for which context helpers are enabled/disabled */
5
- contextHelpers?: ContextHelpersConfig;
4
+ /**
5
+ * A dictionary of context helper functions.
6
+ * The key becomes the AdditionalContext.name and the function returns the value.
7
+ * Return null/undefined to skip including that context.
8
+ */
9
+ contextHelpers?: ContextHelpers;
6
10
  }
7
11
  export interface TamboContextHelpersContextProps {
8
- /** Get all enabled additional context */
12
+ /** Get all additional context by running all helper functions */
9
13
  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
+ /** Get the current context helpers map */
15
+ getContextHelpers: () => ContextHelpers;
16
+ /** Add or update a context helper by name */
17
+ addContextHelper: (name: string, helper: ContextHelperFn) => void;
18
+ /** Remove a context helper by name */
19
+ removeContextHelper: (name: string) => void;
14
20
  }
15
21
  /**
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
22
+ * Provider for managing additional context helpers.
23
+ * Accepts a map of { key: () => any | null | undefined | Promise<any | null | undefined> }.
24
+ * Returning null/undefined skips inclusion; returned values are wrapped as { name: key, context: value }.
25
+ * @param props - The props for the TamboContextHelpersProvider.
26
+ * @param props.contextHelpers - A dictionary of context helper functions keyed by context name.
27
+ * @param props.children - The children to render.
28
+ * @returns The provider that exposes context helper APIs via useTamboContextHelpers.
21
29
  */
22
30
  export declare const TamboContextHelpersProvider: React.FC<PropsWithChildren<TamboContextHelpersProviderProps>>;
23
31
  /**
24
- * Hook to access context helpers functionality
25
- * @returns The context helpers context props
32
+ * Hook to access context helpers functionality.
33
+ * Safe to call even when no provider is present: proxies to the global registry.
34
+ * @returns The context helpers context props (registry-backed).
26
35
  */
27
36
  export declare const useTamboContextHelpers: () => TamboContextHelpersContextProps;
28
37
  //# sourceMappingURL=tambo-context-helpers-provider.d.ts.map
@@ -1 +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"}
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,EAIlB,MAAM,OAAO,CAAC;AACf,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,eAAe,EAChB,MAAM,oBAAoB,CAAC;AAQ5B,MAAM,WAAW,gCAAgC;IAC/C;;;;OAIG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAED,MAAM,WAAW,+BAA+B;IAC9C,iEAAiE;IACjE,oBAAoB,EAAE,MAAM,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC;IACzD,0CAA0C;IAC1C,iBAAiB,EAAE,MAAM,cAAc,CAAC;IACxC,6CAA6C;IAC7C,gBAAgB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;IAClE,sCAAsC;IACtC,mBAAmB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7C;AAKD;;;;;;;;GAQG;AACH,eAAO,MAAM,2BAA2B,EAAE,KAAK,CAAC,EAAE,CAChD,iBAAiB,CAAC,gCAAgC,CAAC,CAgEpD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,uCAalC,CAAC"}
@@ -1,60 +1,77 @@
1
1
  "use client";
2
- import React, { createContext, useCallback, useContext, useMemo, useState, } from "react";
3
- import { DEFAULT_CONTEXT_HELPERS, } from "../context-helpers";
2
+ import React, { createContext, useCallback, useContext, useMemo, } from "react";
3
+ import { addHelper, getHelpers, removeHelper as removeGlobalHelper, resolveAdditionalContext, } from "../context-helpers/registry";
4
4
  const TamboContextHelpersContext = createContext(null);
5
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
6
+ * Provider for managing additional context helpers.
7
+ * Accepts a map of { key: () => any | null | undefined | Promise<any | null | undefined> }.
8
+ * Returning null/undefined skips inclusion; returned values are wrapped as { name: key, context: value }.
9
+ * @param props - The props for the TamboContextHelpersProvider.
10
+ * @param props.contextHelpers - A dictionary of context helper functions keyed by context name.
11
+ * @param props.children - The children to render.
12
+ * @returns The provider that exposes context helper APIs via useTamboContextHelpers.
11
13
  */
12
14
  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
- }
15
+ // Hydrate the global registry with initial helpers (runs on prop changes)
16
+ React.useEffect(() => {
17
+ const addedEntries = [];
18
+ if (contextHelpers) {
19
+ for (const [name, fn] of Object.entries(contextHelpers)) {
20
+ addHelper(name, fn);
21
+ addedEntries.push([name, fn]);
32
22
  }
33
23
  }
34
- return contextResults;
35
- }, [helpers]);
24
+ return () => {
25
+ const current = getHelpers();
26
+ for (const [name, fn] of addedEntries) {
27
+ // Only remove if the registry still points to the same function
28
+ if (current[name] === fn) {
29
+ removeGlobalHelper(name);
30
+ }
31
+ }
32
+ };
33
+ }, [contextHelpers]);
34
+ const getAdditionalContext = useCallback(async () => {
35
+ const contexts = await resolveAdditionalContext();
36
+ return contexts;
37
+ }, []);
36
38
  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));
39
+ return getHelpers();
40
+ }, []);
41
+ const addContextHelper = useCallback((name, helper) => {
42
+ addHelper(name, helper);
43
+ }, []);
44
+ const removeContextHelper = useCallback((name) => {
45
+ removeGlobalHelper(name);
41
46
  }, []);
42
47
  const value = useMemo(() => ({
43
48
  getAdditionalContext,
44
49
  getContextHelpers,
45
- setContextHelperEnabled,
46
- }), [getAdditionalContext, getContextHelpers, setContextHelperEnabled]);
50
+ addContextHelper,
51
+ removeContextHelper,
52
+ }), [
53
+ getAdditionalContext,
54
+ getContextHelpers,
55
+ addContextHelper,
56
+ removeContextHelper,
57
+ ]);
47
58
  return (React.createElement(TamboContextHelpersContext.Provider, { value: value }, children));
48
59
  };
49
60
  /**
50
- * Hook to access context helpers functionality
51
- * @returns The context helpers context props
61
+ * Hook to access context helpers functionality.
62
+ * Safe to call even when no provider is present: proxies to the global registry.
63
+ * @returns The context helpers context props (registry-backed).
52
64
  */
53
65
  export const useTamboContextHelpers = () => {
54
66
  const context = useContext(TamboContextHelpersContext);
55
- if (!context) {
56
- throw new Error("useTamboContextHelpers must be used within a TamboContextHelpersProvider");
57
- }
58
- return context;
67
+ if (context)
68
+ return context;
69
+ // Fallback to global registry so the API is standalone outside any provider
70
+ return {
71
+ getAdditionalContext: async () => (await resolveAdditionalContext()),
72
+ getContextHelpers: () => getHelpers(),
73
+ addContextHelper: (name, helper) => addHelper(name, helper),
74
+ removeContextHelper: (name) => removeGlobalHelper(name),
75
+ };
59
76
  };
60
77
  //# sourceMappingURL=tambo-context-helpers-provider.js.map
@@ -1 +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,EAA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GAAG,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,MAAM,CACvD,CACF,CAAC;IACJ,CAAC,EACD,EAAE,CACH,CAAC;IAEF,MAAM,KAAK,GAAG,OAAO,CACnB,GAAG,EAAE,CAAC,CAAC;QACL,oBAAoB;QACpB,iBAAiB;QACjB,uBAAuB;KACxB,CAAC,EACF,CAAC,oBAAoB,EAAE,iBAAiB,EAAE,uBAAuB,CAAC,CACnE,CAAC;IAEF,OAAO,CACL,oBAAC,0BAA0B,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IAC9C,QAAQ,CAC2B,CACvC,CAAC;AACJ,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,EAAE;IACzC,MAAM,OAAO,GAAG,UAAU,CAAC,0BAA0B,CAAC,CAAC;IACvD,IAAI,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"]}
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,GACR,MAAM,OAAO,CAAC;AAMf,OA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WithChildren,\n useCallback,\n useContext,\n useMemo,\n} from \"react\";\nimport {\n AdditionalContext,\n ContextHelpers,\n ContextHelperFn,\n} from \"../context-helpers\";\nimport {\n addHelper,\n getHelpers,\n removeHelper as removeGlobalHelper,\n resolveAdditionalContext,\n} from \"../context-helpers/registry\";\n\nexport interface TamboContextHelpersProviderProps {\n /**\n * A dictionary of context helper functions.\n * The key becomes the AdditionalContext.name and the function returns the value.\n * Return null/undefined to skip including that context.\n */\n contextHelpers?: ContextHelpers;\n}\n\nexport interface TamboContextHelpersContextProps {\n /** Get all additional context by running all helper functions */\n getAdditionalContext: () => Promise<AdditionalContext[]>;\n /** Get the current context helpers map */\n getContextHelpers: () => ContextHelpers;\n /** Add or update a context helper by name */\n addContextHelper: (name: string, helper: ContextHelperFn) => void;\n /** Remove a context helper by name */\n removeContextHelper: (name: string) => void;\n}\n\nconst TamboContextHelpersContext =\n createContext<TamboContextHelpersContextProps | null>(null);\n\n/**\n * Provider for managing additional context helpers.\n * Accepts a map of { key: () => any | null | undefined | Promise<any | null | undefined> }.\n * Returning null/undefined skips inclusion; returned values are wrapped as { name: key, context: value }.\n * @param props - The props for the TamboContextHelpersProvider.\n * @param props.contextHelpers - A dictionary of context helper functions keyed by context name.\n * @param props.children - The children to render.\n * @returns The provider that exposes context helper APIs via useTamboContextHelpers.\n */\nexport const TamboContextHelpersProvider: React.FC<\n PropsWithChildren<TamboContextHelpersProviderProps>\n> = ({ children, contextHelpers }) => {\n // Hydrate the global registry with initial helpers (runs on prop changes)\n React.useEffect(() => {\n const addedEntries: [string, ContextHelperFn][] = [];\n\n if (contextHelpers) {\n for (const [name, fn] of Object.entries(contextHelpers)) {\n addHelper(name, fn);\n addedEntries.push([name, fn]);\n }\n }\n\n return () => {\n const current = getHelpers();\n for (const [name, fn] of addedEntries) {\n // Only remove if the registry still points to the same function\n if (current[name] === fn) {\n removeGlobalHelper(name);\n }\n }\n };\n }, [contextHelpers]);\n\n const getAdditionalContext = useCallback(async () => {\n const contexts = await resolveAdditionalContext();\n return contexts as AdditionalContext[];\n }, []);\n\n const getContextHelpers = useCallback(() => {\n return getHelpers() as ContextHelpers;\n }, []);\n\n const addContextHelper = useCallback(\n (name: string, helper: ContextHelperFn) => {\n addHelper(name, helper);\n },\n [],\n );\n\n const removeContextHelper = useCallback((name: string) => {\n removeGlobalHelper(name);\n }, []);\n\n const value = useMemo(\n () => ({\n getAdditionalContext,\n getContextHelpers,\n addContextHelper,\n removeContextHelper,\n }),\n [\n getAdditionalContext,\n getContextHelpers,\n addContextHelper,\n removeContextHelper,\n ],\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 * Safe to call even when no provider is present: proxies to the global registry.\n * @returns The context helpers context props (registry-backed).\n */\nexport const useTamboContextHelpers = () => {\n const context = useContext(TamboContextHelpersContext);\n if (context) return context;\n\n // Fallback to global registry so the API is standalone outside any provider\n return {\n getAdditionalContext: async () =>\n (await resolveAdditionalContext()) as AdditionalContext[],\n getContextHelpers: () => getHelpers() as ContextHelpers,\n addContextHelper: (name: string, helper: ContextHelperFn) =>\n addHelper(name, helper),\n removeContextHelper: (name: string) => removeGlobalHelper(name),\n } as TamboContextHelpersContextProps;\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tambo-ai/react",
3
- "version": "0.42.1",
3
+ "version": "0.43.0",
4
4
  "description": "React client package for Tambo AI",
5
5
  "repository": {
6
6
  "type": "git",
@@ -91,7 +91,7 @@
91
91
  "@types/react-dom": "^18.3.5",
92
92
  "concurrently": "^9.2.0",
93
93
  "eslint": "^9.32.0",
94
- "eslint-plugin-jsdoc": "^52.0.0",
94
+ "eslint-plugin-jsdoc": "^52.0.2",
95
95
  "eslint-plugin-react": "^7.37.5",
96
96
  "eslint-plugin-react-hooks": "^5.1.0",
97
97
  "jest": "^30.0.5",
@@ -1,7 +0,0 @@
1
- import { AdditionalContext } from "./types";
2
- /**
3
- * Context helper that provides information about the user's current page
4
- * @returns Additional context with current page information
5
- */
6
- export declare function getUserPageContext(): AdditionalContext;
7
- //# sourceMappingURL=user-page.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"user-page.d.ts","sourceRoot":"","sources":["../../src/context-helpers/user-page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,iBAAiB,CAuBtD"}
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getUserPageContext = getUserPageContext;
4
- /**
5
- * Context helper that provides information about the user's current page
6
- * @returns Additional context with current page information
7
- */
8
- function getUserPageContext() {
9
- // Only run in browser environment
10
- if (typeof window === "undefined") {
11
- return {
12
- name: "userPage",
13
- context: {
14
- error: "Not in browser environment",
15
- },
16
- };
17
- }
18
- return {
19
- name: "userPage",
20
- context: {
21
- url: window.location.href,
22
- pathname: window.location.pathname,
23
- hostname: window.location.hostname,
24
- search: window.location.search,
25
- hash: window.location.hash,
26
- title: document.title,
27
- referrer: document.referrer,
28
- },
29
- };
30
- }
31
- //# sourceMappingURL=user-page.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"user-page.js","sourceRoot":"","sources":["../../src/context-helpers/user-page.ts"],"names":[],"mappings":";;AAMA,gDAuBC;AA3BD;;;GAGG;AACH,SAAgB,kBAAkB;IAChC,kCAAkC;IAClC,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,OAAO;YACL,IAAI,EAAE,UAAU;YAChB,OAAO,EAAE;gBACP,KAAK,EAAE,4BAA4B;aACpC;SACF,CAAC;IACJ,CAAC;IAED,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE;YACP,GAAG,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI;YACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ;YAClC,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ;YAClC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM;YAC9B,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI;YAC1B,KAAK,EAAE,QAAQ,CAAC,KAAK;YACrB,QAAQ,EAAE,QAAQ,CAAC,QAAQ;SAC5B;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { AdditionalContext } from \"./types\";\n\n/**\n * Context helper that provides information about the user's current page\n * @returns Additional context with current page information\n */\nexport function getUserPageContext(): AdditionalContext {\n // Only run in browser environment\n if (typeof window === \"undefined\") {\n return {\n name: \"userPage\",\n context: {\n error: \"Not in browser environment\",\n },\n };\n }\n\n return {\n name: \"userPage\",\n context: {\n url: window.location.href,\n pathname: window.location.pathname,\n hostname: window.location.hostname,\n search: window.location.search,\n hash: window.location.hash,\n title: document.title,\n referrer: document.referrer,\n },\n };\n}\n"]}
@@ -1,7 +0,0 @@
1
- import { AdditionalContext } from "./types";
2
- /**
3
- * Context helper that provides the user's current time and timezone
4
- * @returns Additional context with user's time information
5
- */
6
- export declare function getUserTimeContext(): AdditionalContext;
7
- //# sourceMappingURL=user-time.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"user-time.d.ts","sourceRoot":"","sources":["../../src/context-helpers/user-time.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,iBAAiB,CAYtD"}
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getUserTimeContext = getUserTimeContext;
4
- /**
5
- * Context helper that provides the user's current time and timezone
6
- * @returns Additional context with user's time information
7
- */
8
- function getUserTimeContext() {
9
- const now = new Date();
10
- return {
11
- name: "userTime",
12
- context: {
13
- localTime: now.toLocaleString(),
14
- timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
15
- timestamp: now.toISOString(),
16
- offsetMinutes: now.getTimezoneOffset(),
17
- },
18
- };
19
- }
20
- //# sourceMappingURL=user-time.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"user-time.js","sourceRoot":"","sources":["../../src/context-helpers/user-time.ts"],"names":[],"mappings":";;AAMA,gDAYC;AAhBD;;;GAGG;AACH,SAAgB,kBAAkB;IAChC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IAEvB,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE;YACP,SAAS,EAAE,GAAG,CAAC,cAAc,EAAE;YAC/B,QAAQ,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,eAAe,EAAE,CAAC,QAAQ;YAC1D,SAAS,EAAE,GAAG,CAAC,WAAW,EAAE;YAC5B,aAAa,EAAE,GAAG,CAAC,iBAAiB,EAAE;SACvC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { AdditionalContext } from \"./types\";\n\n/**\n * Context helper that provides the user's current time and timezone\n * @returns Additional context with user's time information\n */\nexport function getUserTimeContext(): AdditionalContext {\n const now = new Date();\n\n return {\n name: \"userTime\",\n context: {\n localTime: now.toLocaleString(),\n timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,\n timestamp: now.toISOString(),\n offsetMinutes: now.getTimezoneOffset(),\n },\n };\n}\n"]}
@@ -1,7 +0,0 @@
1
- import { AdditionalContext } from "./types";
2
- /**
3
- * Context helper that provides information about the user's current page
4
- * @returns Additional context with current page information
5
- */
6
- export declare function getUserPageContext(): AdditionalContext;
7
- //# sourceMappingURL=user-page.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"user-page.d.ts","sourceRoot":"","sources":["../../src/context-helpers/user-page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,iBAAiB,CAuBtD"}
@@ -1,28 +0,0 @@
1
- /**
2
- * Context helper that provides information about the user's current page
3
- * @returns Additional context with current page information
4
- */
5
- export function getUserPageContext() {
6
- // Only run in browser environment
7
- if (typeof window === "undefined") {
8
- return {
9
- name: "userPage",
10
- context: {
11
- error: "Not in browser environment",
12
- },
13
- };
14
- }
15
- return {
16
- name: "userPage",
17
- context: {
18
- url: window.location.href,
19
- pathname: window.location.pathname,
20
- hostname: window.location.hostname,
21
- search: window.location.search,
22
- hash: window.location.hash,
23
- title: document.title,
24
- referrer: document.referrer,
25
- },
26
- };
27
- }
28
- //# sourceMappingURL=user-page.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"user-page.js","sourceRoot":"","sources":["../../src/context-helpers/user-page.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,kBAAkB;IAChC,kCAAkC;IAClC,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,OAAO;YACL,IAAI,EAAE,UAAU;YAChB,OAAO,EAAE;gBACP,KAAK,EAAE,4BAA4B;aACpC;SACF,CAAC;IACJ,CAAC;IAED,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE;YACP,GAAG,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI;YACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ;YAClC,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ;YAClC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM;YAC9B,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI;YAC1B,KAAK,EAAE,QAAQ,CAAC,KAAK;YACrB,QAAQ,EAAE,QAAQ,CAAC,QAAQ;SAC5B;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { AdditionalContext } from \"./types\";\n\n/**\n * Context helper that provides information about the user's current page\n * @returns Additional context with current page information\n */\nexport function getUserPageContext(): AdditionalContext {\n // Only run in browser environment\n if (typeof window === \"undefined\") {\n return {\n name: \"userPage\",\n context: {\n error: \"Not in browser environment\",\n },\n };\n }\n\n return {\n name: \"userPage\",\n context: {\n url: window.location.href,\n pathname: window.location.pathname,\n hostname: window.location.hostname,\n search: window.location.search,\n hash: window.location.hash,\n title: document.title,\n referrer: document.referrer,\n },\n };\n}\n"]}