@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.
- package/dist/context-helpers/__tests__/context-helpers.test.d.ts +2 -0
- package/dist/context-helpers/__tests__/context-helpers.test.d.ts.map +1 -0
- package/dist/context-helpers/__tests__/context-helpers.test.js +44 -0
- package/dist/context-helpers/__tests__/context-helpers.test.js.map +1 -0
- package/dist/context-helpers/index.d.ts +9 -0
- package/dist/context-helpers/index.d.ts.map +1 -0
- package/dist/context-helpers/index.js +38 -0
- package/dist/context-helpers/index.js.map +1 -0
- package/dist/context-helpers/types.d.ts +30 -0
- package/dist/context-helpers/types.d.ts.map +1 -0
- package/dist/context-helpers/types.js +3 -0
- package/dist/context-helpers/types.js.map +1 -0
- package/dist/context-helpers/user-page.d.ts +7 -0
- package/dist/context-helpers/user-page.d.ts.map +1 -0
- package/dist/context-helpers/user-page.js +31 -0
- package/dist/context-helpers/user-page.js.map +1 -0
- package/dist/context-helpers/user-time.d.ts +7 -0
- package/dist/context-helpers/user-time.d.ts.map +1 -0
- package/dist/context-helpers/user-time.js +20 -0
- package/dist/context-helpers/user-time.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/providers/__tests__/tambo-context-helpers-provider.test.d.ts +2 -0
- package/dist/providers/__tests__/tambo-context-helpers-provider.test.d.ts.map +1 -0
- package/dist/providers/__tests__/tambo-context-helpers-provider.test.js +194 -0
- package/dist/providers/__tests__/tambo-context-helpers-provider.test.js.map +1 -0
- package/dist/providers/__tests__/tambo-thread-provider.test.js +51 -31
- package/dist/providers/__tests__/tambo-thread-provider.test.js.map +1 -1
- package/dist/providers/index.d.ts +1 -0
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +4 -1
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/tambo-context-helpers-provider.d.ts +28 -0
- package/dist/providers/tambo-context-helpers-provider.d.ts.map +1 -0
- package/dist/providers/tambo-context-helpers-provider.js +98 -0
- package/dist/providers/tambo-context-helpers-provider.js.map +1 -0
- package/dist/providers/tambo-interactable-provider.js +1 -1
- package/dist/providers/tambo-interactable-provider.js.map +1 -1
- package/dist/providers/tambo-provider.d.ts +4 -2
- package/dist/providers/tambo-provider.d.ts.map +1 -1
- package/dist/providers/tambo-provider.js +10 -5
- package/dist/providers/tambo-provider.js.map +1 -1
- package/dist/providers/tambo-stubs.d.ts +4 -0
- package/dist/providers/tambo-stubs.d.ts.map +1 -1
- package/dist/providers/tambo-stubs.js +6 -3
- package/dist/providers/tambo-stubs.js.map +1 -1
- package/dist/providers/tambo-thread-provider.d.ts.map +1 -1
- package/dist/providers/tambo-thread-provider.js +10 -1
- package/dist/providers/tambo-thread-provider.js.map +1 -1
- package/dist/util/registry.d.ts +0 -8
- package/dist/util/registry.d.ts.map +1 -1
- package/dist/util/registry.js +1 -15
- package/dist/util/registry.js.map +1 -1
- package/esm/context-helpers/__tests__/context-helpers.test.d.ts +2 -0
- package/esm/context-helpers/__tests__/context-helpers.test.d.ts.map +1 -0
- package/esm/context-helpers/__tests__/context-helpers.test.js +42 -0
- package/esm/context-helpers/__tests__/context-helpers.test.js.map +1 -0
- package/esm/context-helpers/index.d.ts +9 -0
- package/esm/context-helpers/index.d.ts.map +1 -0
- package/esm/context-helpers/index.js +21 -0
- package/esm/context-helpers/index.js.map +1 -0
- package/esm/context-helpers/types.d.ts +30 -0
- package/esm/context-helpers/types.d.ts.map +1 -0
- package/esm/context-helpers/types.js +2 -0
- package/esm/context-helpers/types.js.map +1 -0
- package/esm/context-helpers/user-page.d.ts +7 -0
- package/esm/context-helpers/user-page.d.ts.map +1 -0
- package/esm/context-helpers/user-page.js +28 -0
- package/esm/context-helpers/user-page.js.map +1 -0
- package/esm/context-helpers/user-time.d.ts +7 -0
- package/esm/context-helpers/user-time.d.ts.map +1 -0
- package/esm/context-helpers/user-time.js +17 -0
- package/esm/context-helpers/user-time.js.map +1 -0
- package/esm/index.d.ts +3 -1
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +3 -1
- package/esm/index.js.map +1 -1
- package/esm/providers/__tests__/tambo-context-helpers-provider.test.d.ts +2 -0
- package/esm/providers/__tests__/tambo-context-helpers-provider.test.d.ts.map +1 -0
- package/esm/providers/__tests__/tambo-context-helpers-provider.test.js +156 -0
- package/esm/providers/__tests__/tambo-context-helpers-provider.test.js.map +1 -0
- package/esm/providers/__tests__/tambo-thread-provider.test.js +51 -31
- package/esm/providers/__tests__/tambo-thread-provider.test.js.map +1 -1
- package/esm/providers/index.d.ts +1 -0
- package/esm/providers/index.d.ts.map +1 -1
- package/esm/providers/index.js +1 -0
- package/esm/providers/index.js.map +1 -1
- package/esm/providers/tambo-context-helpers-provider.d.ts +28 -0
- package/esm/providers/tambo-context-helpers-provider.d.ts.map +1 -0
- package/esm/providers/tambo-context-helpers-provider.js +60 -0
- package/esm/providers/tambo-context-helpers-provider.js.map +1 -0
- package/esm/providers/tambo-interactable-provider.js +1 -1
- package/esm/providers/tambo-interactable-provider.js.map +1 -1
- package/esm/providers/tambo-provider.d.ts +4 -2
- package/esm/providers/tambo-provider.d.ts.map +1 -1
- package/esm/providers/tambo-provider.js +10 -5
- package/esm/providers/tambo-provider.js.map +1 -1
- package/esm/providers/tambo-stubs.d.ts +4 -0
- package/esm/providers/tambo-stubs.d.ts.map +1 -1
- package/esm/providers/tambo-stubs.js +6 -3
- package/esm/providers/tambo-stubs.js.map +1 -1
- package/esm/providers/tambo-thread-provider.d.ts.map +1 -1
- package/esm/providers/tambo-thread-provider.js +11 -2
- package/esm/providers/tambo-thread-provider.js.map +1 -1
- package/esm/util/registry.d.ts +0 -8
- package/esm/util/registry.d.ts.map +1 -1
- package/esm/util/registry.js +0 -13
- package/esm/util/registry.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tambo-thread-provider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,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;IAC9E,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AANW,QAAA,cAAc,kBAMzB","sourcesContent":["\"use client\";\nimport TamboAI, { advanceStream } from \"@tambo-ai/typescript-sdk\";\nimport { Thread } from \"@tambo-ai/typescript-sdk/resources/beta/threads/threads\";\nimport React, {\n createContext,\n PropsWithChildren,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport {\n GenerationStage,\n isIdleStage,\n TamboThreadMessage,\n} from \"../model/generate-component-response\";\nimport { TamboThread } from \"../model/tambo-thread\";\nimport { renderComponentIntoMessage } from \"../util/generate-component\";\nimport {\n getAvailableComponents,\n getSystemContext,\n getUnassociatedTools,\n mapTamboToolToContextTool,\n} from \"../util/registry\";\nimport { handleToolCall } from \"../util/tool-caller\";\nimport { useTamboClient } from \"./tambo-client-provider\";\nimport { useTamboRegistry } from \"./tambo-registry-provider\";\n\nexport interface TamboThreadContextProps {\n /** The current thread */\n thread: TamboThread;\n /** Switch to a different thread */\n switchCurrentThread: (threadId: string, fetch?: boolean) => void;\n /** Start a new thread */\n startNewThread: () => void;\n /** Update a thread's name */\n updateThreadName: (name: string, threadId?: string) => void;\n /** Let Tambo generate and set a thread's name based on the thread's messages */\n generateThreadName: (threadId?: string) => Promise<Thread>;\n /** Add a message to the current thread */\n addThreadMessage: (\n message: TamboThreadMessage,\n sendToServer: boolean,\n ) => Promise<TamboAI.Beta.Threads.ThreadMessage[]>;\n /** Update a message in the current thread */\n updateThreadMessage: (\n id: string,\n message: TamboThreadMessage,\n sendToServer: boolean,\n ) => Promise<void>;\n /** Cancel a thread */\n cancel: (threadId?: string) => Promise<void>;\n /** The input value of the current thread */\n inputValue: string;\n /** Whether the thread is streaming */\n streaming: boolean;\n /** Set the input value of the current thread */\n setInputValue: (value: string) => void;\n /** Send a message to the current thread */\n sendThreadMessage: (\n message: string,\n options?: {\n threadId?: string;\n streamResponse?: boolean;\n contextKey?: string;\n forceToolChoice?: string;\n additionalContext?: Record<string, any>;\n },\n ) => Promise<TamboThreadMessage>;\n /** The generation stage of the current thread - updated as the thread progresses */\n generationStage: GenerationStage;\n /** The generation status message of the current thread - updated as the thread progresses */\n generationStatusMessage: string;\n /** Whether the thread is idle */\n isIdle: boolean;\n}\n\n/**\n * This is a stub entry for when the thread is not yet created, the first time\n * the user sends a message\n *\n * Note that the consumer needs to be careful never to send `PLACEHOLDER_THREAD.id` to the server,\n * as this doesn't really exist on the server side.\n */\nexport const PLACEHOLDER_THREAD: TamboThread = {\n id: \"placeholder\",\n messages: [],\n createdAt: \"\",\n projectId: \"\",\n updatedAt: \"\",\n metadata: {},\n};\n\nexport const TamboThreadContext = createContext<TamboThreadContextProps>({\n thread: PLACEHOLDER_THREAD,\n /**\n *\n */\n switchCurrentThread: () => {\n throw new Error(\"switchCurrentThread not implemented\");\n },\n /**\n *\n */\n startNewThread: () => {\n throw new Error(\"startNewThread not implemented\");\n },\n /**\n *\n */\n updateThreadName: () => {\n throw new Error(\"updateThreadName not implemented\");\n },\n /**\n *\n */\n generateThreadName: () => {\n throw new Error(\"generateThreadName not implemented\");\n },\n /**\n *\n */\n addThreadMessage: () => {\n throw new Error(\"updateThreadMessageHistory not implemented\");\n },\n inputValue: \"\",\n streaming: true,\n /**\n *\n */\n setInputValue: () => {\n throw new Error(\"setInputValue not implemented\");\n },\n /**\n *\n */\n updateThreadMessage: () => {\n throw new Error(\"updateThreadMessage not implemented\");\n },\n /**\n *\n */\n sendThreadMessage: () => {\n throw new Error(\"advance not implemented\");\n },\n generationStage: GenerationStage.IDLE,\n generationStatusMessage: \"\",\n isIdle: true,\n cancel: () => {\n throw new Error(\"cancel not implemented\");\n },\n});\n\nexport interface TamboThreadProviderProps {\n /** Whether to stream the response */\n streaming?: boolean;\n}\n\n/**\n * The TamboThreadProvider is a React provider that provides a thread context\n * to the descendants of the provider.\n * @param props - The props for the TamboThreadProvider\n * @param props.children - The children to wrap\n * @param props.streaming - Whether to stream the response by default. Defaults to true.\n * @returns The TamboThreadProvider component\n */\nexport const TamboThreadProvider: React.FC<\n PropsWithChildren<TamboThreadProviderProps>\n> = ({ children, streaming = true }) => {\n const [threadMap, setThreadMap] = useState<Record<string, TamboThread>>({\n [PLACEHOLDER_THREAD.id]: PLACEHOLDER_THREAD,\n });\n const client = useTamboClient();\n const { componentList, toolRegistry, componentToolAssociations } =\n useTamboRegistry();\n const [inputValue, setInputValue] = useState(\"\");\n const [ignoreResponse, setIgnoreResponse] = useState(false);\n const ignoreResponseRef = useRef(ignoreResponse);\n const [currentThreadId, setCurrentThreadId] = useState<string>(\n PLACEHOLDER_THREAD.id,\n );\n const currentThread: TamboThread | undefined = threadMap[currentThreadId];\n\n // Use existing messages from the current thread to avoid re-generating any components\n const currentMessageCache = useMemo(() => {\n const messageCache = new Map<string, TamboThreadMessage>();\n if (currentThread) {\n for (const message of currentThread.messages) {\n messageCache.set(message.id, message);\n }\n }\n return messageCache;\n }, [currentThread]);\n\n useEffect(() => {\n ignoreResponseRef.current = ignoreResponse;\n }, [ignoreResponse]);\n\n const isIdle = useMemo(\n () =>\n isIdleStage(\n (currentThread?.generationStage ??\n GenerationStage.IDLE) as GenerationStage,\n ),\n [currentThread?.generationStage],\n );\n\n const fetchThread = useCallback(\n async (threadId: string, includeInternalMessages = true) => {\n const thread = await client.beta.threads.retrieve(threadId, {\n includeInternal: includeInternalMessages,\n });\n const threadWithRenderedComponents = {\n ...thread,\n messages: thread.messages.map((message) => {\n if (currentMessageCache.has(message.id)) {\n const renderedMessage = currentMessageCache.get(message.id);\n return {\n ...renderedMessage,\n ...message,\n };\n }\n if (message.component?.componentName) {\n const messageWithComponent = renderComponentIntoMessage(\n message,\n componentList,\n );\n return messageWithComponent;\n }\n return message;\n }),\n };\n\n setThreadMap((prevMap) => {\n const updatedThreadMap = {\n ...prevMap,\n [threadId]: threadWithRenderedComponents,\n };\n return updatedThreadMap;\n });\n },\n [client.beta.threads, componentList, currentMessageCache],\n );\n\n useEffect(() => {\n if (\n currentThreadId &&\n currentThreadId !== PLACEHOLDER_THREAD.id &&\n !threadMap[currentThreadId]\n ) {\n fetchThread(currentThreadId);\n }\n }, [currentThreadId, fetchThread, threadMap]);\n\n const addThreadMessage = useCallback(\n async (\n message: TamboThreadMessage,\n sendToServer = true,\n createdAt: string = new Date().toISOString(),\n ) => {\n if (!currentThread) {\n console.warn(\"Cannot add messages if we do not have a current thread\");\n return [];\n }\n\n const chatMessage: TamboThreadMessage = {\n ...message,\n createdAt,\n };\n const threadId = message.threadId;\n const messageId = chatMessage.id;\n // optimistically update the thread in the local state\n setThreadMap((prevMap) => {\n if (!threadId) {\n return prevMap;\n }\n const prevMessages = prevMap[threadId]?.messages || [];\n const haveMessage = prevMessages.find((msg) => msg.id === messageId);\n // Update in place if the message already exists\n const updatedMessages = haveMessage\n ? prevMessages.map((msg) => {\n if (msg.id === messageId) {\n return chatMessage;\n }\n return msg;\n })\n : [...prevMessages, chatMessage];\n\n const updatedThreadMap = {\n ...prevMap,\n [threadId]: {\n ...prevMap[threadId],\n messages: updatedMessages,\n },\n };\n return updatedThreadMap;\n });\n\n if (sendToServer) {\n // TODO: if this fails, we need to revert the local state update\n await client.beta.threads.messages.create(message.threadId, {\n content: message.content,\n role: message.role,\n additionalContext: chatMessage.additionalContext,\n });\n }\n return threadMap[threadId]?.messages || [];\n },\n [client.beta.threads.messages, currentThread, threadMap],\n );\n\n const updateThreadMessage = useCallback(\n async (\n id: string,\n message: TamboThreadMessage,\n sendToServer = true,\n createdAt: string = new Date().toISOString(),\n ) => {\n const chatMessage: TamboThreadMessage = {\n ...message,\n createdAt,\n };\n\n setThreadMap((prevMap) => {\n if (!message.threadId) {\n return prevMap;\n }\n const prevMessages = prevMap[message.threadId]?.messages || [];\n const updatedMessages = prevMessages.map((msg) => {\n if (msg.id === id) {\n return chatMessage;\n }\n return msg;\n });\n return {\n ...prevMap,\n [message.threadId]: {\n ...prevMap[message.threadId],\n messages: updatedMessages,\n },\n };\n });\n if (sendToServer) {\n // TODO: if this fails, we need to revert the local state update\n await client.beta.threads.messages.create(message.threadId, {\n content: message.content,\n role: message.role,\n additionalContext: chatMessage.additionalContext,\n });\n }\n },\n [client.beta.threads.messages],\n );\n\n const startNewThread = useCallback(() => {\n setCurrentThreadId(PLACEHOLDER_THREAD.id);\n setThreadMap((prevMap) => {\n return {\n ...prevMap,\n [PLACEHOLDER_THREAD.id]: PLACEHOLDER_THREAD,\n };\n });\n }, []);\n\n const updateThreadName = useCallback(\n async (name: string, threadId?: string) => {\n threadId ??= currentThreadId;\n\n setThreadMap((prevMap) => {\n if (!prevMap[threadId]) {\n return prevMap;\n }\n return { ...prevMap, [threadId]: { ...prevMap[threadId], name } };\n });\n\n if (threadId !== PLACEHOLDER_THREAD.id) {\n const currentProject = await client.beta.projects.getCurrent();\n await client.beta.threads.update(threadId, {\n name,\n projectId: currentProject.id,\n });\n }\n },\n [currentThreadId, client.beta.projects, client.beta.threads],\n );\n\n const generateThreadName = useCallback(\n async (threadId?: string) => {\n threadId ??= currentThreadId;\n if (threadId === PLACEHOLDER_THREAD.id) {\n console.warn(\"Cannot generate name for empty thread\");\n return threadMap[threadId];\n }\n\n const threadWithGeneratedName =\n await client.beta.threads.generateName(threadId);\n\n setThreadMap((prevMap) => {\n if (!prevMap[threadId]) {\n return prevMap;\n }\n return {\n ...prevMap,\n [threadId]: {\n ...prevMap[threadId],\n name: threadWithGeneratedName.name,\n },\n };\n });\n return threadWithGeneratedName;\n },\n [client.beta.threads, currentThreadId, threadMap],\n );\n\n const switchCurrentThread = useCallback(\n async (threadId: string, fetch = true) => {\n if (threadId === PLACEHOLDER_THREAD.id) {\n console.warn(\"Switching to placeholder thread, may be a bug.\");\n return;\n }\n setCurrentThreadId(threadId);\n setThreadMap((prevMap) => {\n if (prevMap[threadId]) {\n return prevMap;\n }\n // If this is a new thread, add placeholder thread messages to the thread\n const updatedThreadMap = {\n ...prevMap,\n [threadId]: {\n ...prevMap[PLACEHOLDER_THREAD.id],\n id: threadId,\n },\n };\n return updatedThreadMap;\n });\n if (fetch) {\n await fetchThread(threadId);\n }\n },\n [fetchThread],\n );\n\n const updateThreadStatus = useCallback(\n (threadId: string, stage: GenerationStage, statusMessage?: string) => {\n setThreadMap((prevMap) => {\n const updatedThreadMap = {\n ...prevMap,\n [threadId]: {\n ...prevMap[threadId],\n generationStage: stage,\n statusMessage: statusMessage,\n },\n };\n return updatedThreadMap;\n });\n },\n [],\n );\n\n const cancel = useCallback(\n async (threadId?: string) => {\n threadId ??= currentThreadId;\n if (isIdle) {\n return;\n }\n setIgnoreResponse(true);\n setThreadMap((prevMap) => {\n if (!prevMap[threadId]) {\n return prevMap;\n }\n\n return {\n ...prevMap,\n [threadId]: {\n ...prevMap[threadId],\n generationStage: GenerationStage.CANCELLED,\n messages: prevMap[threadId].messages.map((message) => {\n if (\n message.id ===\n prevMap[threadId].messages[\n prevMap[threadId].messages.length - 1\n ].id\n ) {\n return {\n ...message,\n isCancelled: true,\n };\n }\n return message;\n }),\n },\n };\n });\n\n await client.beta.threads.cancel(threadId);\n },\n [client.beta.threads, currentThreadId, isIdle],\n );\n\n const handleAdvanceStream = useCallback(\n async (\n stream: AsyncIterable<TamboAI.Beta.Threads.ThreadAdvanceResponse>,\n params: TamboAI.Beta.Threads.ThreadAdvanceParams,\n threadId: string,\n ): Promise<TamboThreadMessage> => {\n if (ignoreResponseRef.current) {\n setIgnoreResponse(false);\n return {\n threadId: threadId,\n content: [{ type: \"text\", text: \"\" }],\n role: \"assistant\",\n createdAt: new Date().toISOString(),\n id: crypto.randomUUID(),\n componentState: {},\n };\n }\n let finalMessage: Readonly<TamboThreadMessage> | undefined;\n let hasSetThreadId = false;\n updateThreadStatus(threadId, GenerationStage.STREAMING_RESPONSE);\n\n for await (const chunk of stream) {\n if (chunk.responseMessageDto.toolCallRequest) {\n // Increment tool call count for this tool\n const toolName = chunk.responseMessageDto.toolCallRequest.toolName;\n if (toolName && params.toolCallCounts) {\n params.toolCallCounts[toolName] =\n (params.toolCallCounts[toolName] ?? 0) + 1;\n }\n\n updateThreadStatus(\n chunk.responseMessageDto.threadId,\n GenerationStage.FETCHING_CONTEXT,\n );\n\n updateThreadMessage(\n chunk.responseMessageDto.id,\n {\n ...chunk.responseMessageDto,\n },\n false,\n );\n\n const toolCallResponse = await handleToolCall(\n chunk.responseMessageDto,\n toolRegistry,\n );\n if (ignoreResponseRef.current) {\n setIgnoreResponse(false);\n {\n return {\n threadId: threadId,\n content: [{ type: \"text\", text: \"\" }],\n role: \"assistant\",\n createdAt: new Date().toISOString(),\n id: crypto.randomUUID(),\n componentState: {},\n };\n }\n }\n const toolCallResponseString =\n typeof toolCallResponse.result === \"string\"\n ? toolCallResponse.result\n : JSON.stringify(toolCallResponse.result);\n const toolCallResponseParams: TamboAI.Beta.Threads.ThreadAdvanceParams =\n {\n ...params,\n messageToAppend: {\n content: [{ type: \"text\", text: toolCallResponseString }],\n role: \"tool\",\n actionType: \"tool_response\",\n component: chunk.responseMessageDto.component,\n tool_call_id: chunk.responseMessageDto.tool_call_id,\n error: toolCallResponse.error,\n },\n };\n\n updateThreadMessage(\n chunk.responseMessageDto.id,\n {\n ...chunk.responseMessageDto,\n error: toolCallResponse.error,\n },\n false,\n );\n\n addThreadMessage(\n {\n threadId: chunk.responseMessageDto.threadId,\n content: [{ type: \"text\", text: toolCallResponseString }],\n role: \"tool\",\n id: crypto.randomUUID(),\n createdAt: new Date().toISOString(),\n componentState: {},\n actionType: \"tool_response\",\n tool_call_id: chunk.responseMessageDto.tool_call_id,\n error: toolCallResponse.error,\n },\n false,\n );\n\n updateThreadStatus(\n chunk.responseMessageDto.threadId,\n GenerationStage.STREAMING_RESPONSE,\n );\n const toolCallResponseStream = await advanceStream(\n client,\n toolCallResponseParams,\n chunk.responseMessageDto.threadId,\n );\n\n return await handleAdvanceStream(\n toolCallResponseStream,\n toolCallResponseParams,\n chunk.responseMessageDto.threadId,\n );\n } else {\n if (ignoreResponseRef.current) {\n setIgnoreResponse(false);\n return (\n finalMessage ?? {\n threadId: threadId,\n content: [{ type: \"text\", text: \"\" }],\n role: \"assistant\",\n createdAt: new Date().toISOString(),\n id: crypto.randomUUID(),\n componentState: {},\n }\n );\n }\n if (\n !hasSetThreadId &&\n chunk.responseMessageDto.threadId &&\n chunk.responseMessageDto.threadId !== currentThread?.id\n ) {\n hasSetThreadId = true;\n await switchCurrentThread(chunk.responseMessageDto.threadId, false);\n }\n\n if (!finalMessage) {\n finalMessage = chunk.responseMessageDto.component?.componentName\n ? renderComponentIntoMessage(\n chunk.responseMessageDto,\n componentList,\n )\n : chunk.responseMessageDto;\n await addThreadMessage(finalMessage, false);\n } else {\n // if we start getting a new message mid-stream, put the previous one on screen\n const isNewMessage =\n chunk.responseMessageDto.id !== finalMessage.id;\n\n finalMessage = chunk.responseMessageDto.component?.componentName\n ? renderComponentIntoMessage(\n chunk.responseMessageDto,\n componentList,\n )\n : chunk.responseMessageDto;\n\n if (isNewMessage) {\n await addThreadMessage(finalMessage, false);\n } else {\n await updateThreadMessage(finalMessage.id, finalMessage, false);\n }\n }\n }\n }\n\n updateThreadStatus(\n finalMessage?.threadId ?? threadId,\n GenerationStage.COMPLETE,\n );\n return (\n finalMessage ?? {\n threadId: \"\",\n content: [{ type: \"text\", text: `Error processing stream` }],\n role: \"assistant\",\n createdAt: new Date().toISOString(),\n id: crypto.randomUUID(),\n componentState: {},\n }\n );\n },\n [\n addThreadMessage,\n client,\n componentList,\n currentThread?.id,\n switchCurrentThread,\n toolRegistry,\n updateThreadMessage,\n updateThreadStatus,\n ],\n );\n\n const currentThreadContextKey = currentThread?.contextKey;\n\n const sendThreadMessage = useCallback(\n async (\n message: string,\n options: {\n threadId?: string;\n streamResponse?: boolean;\n forceToolChoice?: string;\n contextKey?: string;\n additionalContext?: Record<string, any>;\n } = {},\n ): Promise<TamboThreadMessage> => {\n setIgnoreResponse(false);\n const {\n threadId = currentThreadId ?? PLACEHOLDER_THREAD.id,\n streamResponse = streaming,\n forceToolChoice,\n contextKey = currentThreadContextKey,\n additionalContext,\n } = options;\n updateThreadStatus(threadId, GenerationStage.FETCHING_CONTEXT);\n\n const combinedContext = {\n system: getSystemContext(),\n ...(additionalContext ?? {}),\n };\n\n addThreadMessage(\n {\n content: [{ type: \"text\", text: message }],\n renderedComponent: null,\n role: \"user\",\n threadId: threadId,\n id: crypto.randomUUID(),\n createdAt: new Date().toISOString(),\n componentState: {},\n additionalContext: combinedContext,\n },\n false,\n );\n\n const availableComponents = getAvailableComponents(\n componentList,\n toolRegistry,\n componentToolAssociations,\n );\n const unassociatedTools = getUnassociatedTools(\n toolRegistry,\n componentToolAssociations,\n );\n\n // Track tool call counts for this message processing\n const toolCallCounts: Record<string, number> = {};\n\n const params: TamboAI.Beta.Threads.ThreadAdvanceParams = {\n messageToAppend: {\n content: [{ type: \"text\", text: message }],\n role: \"user\",\n additionalContext: combinedContext,\n },\n contextKey,\n availableComponents: availableComponents,\n clientTools: unassociatedTools.map((tool) =>\n mapTamboToolToContextTool(tool),\n ),\n forceToolChoice: forceToolChoice,\n toolCallCounts,\n };\n\n if (streamResponse) {\n const advanceStreamResponse = await advanceStream(\n client,\n params,\n threadId === PLACEHOLDER_THREAD.id ? undefined : threadId,\n );\n return await handleAdvanceStream(\n advanceStreamResponse,\n params,\n threadId,\n );\n }\n let advanceResponse = await (threadId === PLACEHOLDER_THREAD.id\n ? client.beta.threads.advance(params)\n : client.beta.threads.advanceById(threadId, params));\n\n //handle tool calls\n while (advanceResponse.responseMessageDto.toolCallRequest) {\n // Increment tool call count for this tool\n const toolName =\n advanceResponse.responseMessageDto.toolCallRequest.toolName;\n if (toolName) {\n toolCallCounts[toolName] = (toolCallCounts[toolName] || 0) + 1;\n }\n\n updateThreadStatus(threadId, GenerationStage.FETCHING_CONTEXT);\n const toolCallResponse = await handleToolCall(\n advanceResponse.responseMessageDto,\n toolRegistry,\n );\n const toolResponseString =\n typeof toolCallResponse.result === \"string\"\n ? toolCallResponse.result\n : JSON.stringify(toolCallResponse.result);\n const toolCallResponseParams: TamboAI.Beta.Threads.ThreadAdvanceParams =\n {\n ...params,\n messageToAppend: {\n ...params.messageToAppend,\n content: [{ type: \"text\", text: toolResponseString }],\n role: \"tool\",\n actionType: \"tool_response\",\n component: advanceResponse.responseMessageDto.component,\n tool_call_id: advanceResponse.responseMessageDto.tool_call_id,\n error: toolCallResponse.error,\n },\n };\n if (toolCallResponse.error) {\n //update toolcall message with error\n const toolCallMessage = {\n ...advanceResponse.responseMessageDto,\n error: toolCallResponse.error,\n };\n updateThreadMessage(toolCallMessage.id, toolCallMessage, false);\n }\n updateThreadStatus(threadId, GenerationStage.HYDRATING_COMPONENT);\n addThreadMessage(\n {\n threadId: threadId,\n content: [{ type: \"text\", text: toolResponseString }],\n role: \"tool\",\n id: crypto.randomUUID(),\n createdAt: new Date().toISOString(),\n componentState: {},\n actionType: \"tool_response\",\n tool_call_id: advanceResponse.responseMessageDto.tool_call_id,\n error: toolCallResponse.error,\n },\n false,\n );\n\n advanceResponse = await client.beta.threads.advanceById(\n advanceResponse.responseMessageDto.threadId,\n toolCallResponseParams,\n );\n }\n\n const finalMessage = advanceResponse.responseMessageDto.component\n ?.componentName\n ? renderComponentIntoMessage(\n advanceResponse.responseMessageDto,\n componentList,\n )\n : advanceResponse.responseMessageDto;\n await switchCurrentThread(advanceResponse.responseMessageDto.threadId);\n updateThreadStatus(\n advanceResponse.responseMessageDto.threadId,\n GenerationStage.COMPLETE,\n );\n return finalMessage;\n },\n [\n componentList,\n toolRegistry,\n componentToolAssociations,\n currentThreadId,\n currentThreadContextKey,\n switchCurrentThread,\n addThreadMessage,\n client,\n updateThreadMessage,\n updateThreadStatus,\n handleAdvanceStream,\n streaming,\n ],\n );\n\n return (\n <TamboThreadContext.Provider\n value={{\n thread: currentThread,\n switchCurrentThread,\n startNewThread,\n updateThreadName,\n generateThreadName,\n addThreadMessage,\n updateThreadMessage,\n inputValue,\n setInputValue,\n sendThreadMessage,\n streaming,\n generationStage: (currentThread?.generationStage ??\n GenerationStage.IDLE) as GenerationStage,\n generationStatusMessage: currentThread?.statusMessage ?? \"\",\n isIdle,\n cancel,\n }}\n >\n {children}\n </TamboThreadContext.Provider>\n );\n};\n\n/**\n * The useTamboThread hook provides access to the current thread context\n * to the descendants of the TamboThreadProvider.\n * @returns All state and actions for the current thread\n */\nexport const useTamboThread = () => {\n const context = useContext(TamboThreadContext);\n if (context === undefined) {\n throw new Error(\"useTamboThread must be used within a TamboThreadProvider\");\n }\n return context;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"tambo-thread-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-thread-provider.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACb,6DAAkE;AAElE,+CASe;AACf,sFAI8C;AAE9C,mEAAwE;AACxE,+CAI0B;AAC1B,qDAAqD;AACrD,mEAAyD;AACzD,qFAA0E;AAC1E,uEAA6D;AAmD7D;;;;;;GAMG;AACU,QAAA,kBAAkB,GAAgB;IAC7C,EAAE,EAAE,aAAa;IACjB,QAAQ,EAAE,EAAE;IACZ,SAAS,EAAE,EAAE;IACb,SAAS,EAAE,EAAE;IACb,SAAS,EAAE,EAAE;IACb,QAAQ,EAAE,EAAE;CACb,CAAC;AAEW,QAAA,kBAAkB,GAAG,IAAA,qBAAa,EAA0B;IACvE,MAAM,EAAE,0BAAkB;IAC1B;;OAEG;IACH,mBAAmB,EAAE,GAAG,EAAE;QACxB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACzD,CAAC;IACD;;OAEG;IACH,cAAc,EAAE,GAAG,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACpD,CAAC;IACD;;OAEG;IACH,gBAAgB,EAAE,GAAG,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACtD,CAAC;IACD;;OAEG;IAC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B;QACnB,SAAS;QACT,oBAAoB;KACrB,CACF,CAAC;IAEF,OAAO,CACL,8BAAC,0BAAkB,CAAC,QAAQ,IAC1B,KAAK,EAAE;YACL,MAAM,EAAE,aAAa;YACrB,mBAAmB;YACnB,cAAc;YACd,gBAAgB;YAChB,kBAAkB;YAClB,gBAAgB;YAChB,mBAAmB;YACnB,UAAU;YACV,aAAa;YACb,iBAAiB;YACjB,SAAS;YACT,eAAe,EAAE,CAAC,aAAa,EAAE,eAAe;gBAC9C,6CAAe,CAAC,IAAI,CAAoB;YAC1C,uBAAuB,EAAE,aAAa,EAAE,aAAa,IAAI,EAAE;YAC3D,MAAM;YACN,MAAM;SACP,IAEA,QAAQ,CACmB,CAC/B,CAAC;AACJ,CAAC,CAAC;AAnuBW,QAAA,mBAAmB,uBAmuB9B;AAEF;;;;GAIG;AACI,MAAM,cAAc,GAAG,GAAG,EAAE;IACjC,MAAM,OAAO,GAAG,IAAA,kBAAU,EAAC,0BAAkB,CAAC,CAAC;IAC/C,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;IAC9E,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AANW,QAAA,cAAc,kBAMzB","sourcesContent":["\"use client\";\nimport TamboAI, { advanceStream } from \"@tambo-ai/typescript-sdk\";\nimport { Thread } from \"@tambo-ai/typescript-sdk/resources/beta/threads/threads\";\nimport React, {\n createContext,\n PropsWithChildren,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport {\n GenerationStage,\n isIdleStage,\n TamboThreadMessage,\n} from \"../model/generate-component-response\";\nimport { TamboThread } from \"../model/tambo-thread\";\nimport { renderComponentIntoMessage } from \"../util/generate-component\";\nimport {\n getAvailableComponents,\n getUnassociatedTools,\n mapTamboToolToContextTool,\n} from \"../util/registry\";\nimport { handleToolCall } from \"../util/tool-caller\";\nimport { useTamboClient } from \"./tambo-client-provider\";\nimport { useTamboContextHelpers } from \"./tambo-context-helpers-provider\";\nimport { useTamboRegistry } from \"./tambo-registry-provider\";\n\nexport interface TamboThreadContextProps {\n /** The current thread */\n thread: TamboThread;\n /** Switch to a different thread */\n switchCurrentThread: (threadId: string, fetch?: boolean) => void;\n /** Start a new thread */\n startNewThread: () => void;\n /** Update a thread's name */\n updateThreadName: (name: string, threadId?: string) => void;\n /** Let Tambo generate and set a thread's name based on the thread's messages */\n generateThreadName: (threadId?: string) => Promise<Thread>;\n /** Add a message to the current thread */\n addThreadMessage: (\n message: TamboThreadMessage,\n sendToServer: boolean,\n ) => Promise<TamboAI.Beta.Threads.ThreadMessage[]>;\n /** Update a message in the current thread */\n updateThreadMessage: (\n id: string,\n message: TamboThreadMessage,\n sendToServer: boolean,\n ) => Promise<void>;\n /** Cancel a thread */\n cancel: (threadId?: string) => Promise<void>;\n /** The input value of the current thread */\n inputValue: string;\n /** Whether the thread is streaming */\n streaming: boolean;\n /** Set the input value of the current thread */\n setInputValue: (value: string) => void;\n /** Send a message to the current thread */\n sendThreadMessage: (\n message: string,\n options?: {\n threadId?: string;\n streamResponse?: boolean;\n contextKey?: string;\n forceToolChoice?: string;\n additionalContext?: Record<string, any>;\n },\n ) => Promise<TamboThreadMessage>;\n /** The generation stage of the current thread - updated as the thread progresses */\n generationStage: GenerationStage;\n /** The generation status message of the current thread - updated as the thread progresses */\n generationStatusMessage: string;\n /** Whether the thread is idle */\n isIdle: boolean;\n}\n\n/**\n * This is a stub entry for when the thread is not yet created, the first time\n * the user sends a message\n *\n * Note that the consumer needs to be careful never to send `PLACEHOLDER_THREAD.id` to the server,\n * as this doesn't really exist on the server side.\n */\nexport const PLACEHOLDER_THREAD: TamboThread = {\n id: \"placeholder\",\n messages: [],\n createdAt: \"\",\n projectId: \"\",\n updatedAt: \"\",\n metadata: {},\n};\n\nexport const TamboThreadContext = createContext<TamboThreadContextProps>({\n thread: PLACEHOLDER_THREAD,\n /**\n *\n */\n switchCurrentThread: () => {\n throw new Error(\"switchCurrentThread not implemented\");\n },\n /**\n *\n */\n startNewThread: () => {\n throw new Error(\"startNewThread not implemented\");\n },\n /**\n *\n */\n updateThreadName: () => {\n throw new Error(\"updateThreadName not implemented\");\n },\n /**\n *\n */\n generateThreadName: () => {\n throw new Error(\"generateThreadName not implemented\");\n },\n /**\n *\n */\n addThreadMessage: () => {\n throw new Error(\"updateThreadMessageHistory not implemented\");\n },\n inputValue: \"\",\n streaming: true,\n /**\n *\n */\n setInputValue: () => {\n throw new Error(\"setInputValue not implemented\");\n },\n /**\n *\n */\n updateThreadMessage: () => {\n throw new Error(\"updateThreadMessage not implemented\");\n },\n /**\n *\n */\n sendThreadMessage: () => {\n throw new Error(\"advance not implemented\");\n },\n generationStage: GenerationStage.IDLE,\n generationStatusMessage: \"\",\n isIdle: true,\n cancel: () => {\n throw new Error(\"cancel not implemented\");\n },\n});\n\nexport interface TamboThreadProviderProps {\n /** Whether to stream the response */\n streaming?: boolean;\n}\n\n/**\n * The TamboThreadProvider is a React provider that provides a thread context\n * to the descendants of the provider.\n * @param props - The props for the TamboThreadProvider\n * @param props.children - The children to wrap\n * @param props.streaming - Whether to stream the response by default. Defaults to true.\n * @returns The TamboThreadProvider component\n */\nexport const TamboThreadProvider: React.FC<\n PropsWithChildren<TamboThreadProviderProps>\n> = ({ children, streaming = true }) => {\n const [threadMap, setThreadMap] = useState<Record<string, TamboThread>>({\n [PLACEHOLDER_THREAD.id]: PLACEHOLDER_THREAD,\n });\n const client = useTamboClient();\n const { componentList, toolRegistry, componentToolAssociations } =\n useTamboRegistry();\n const { getAdditionalContext } = useTamboContextHelpers();\n const [inputValue, setInputValue] = useState(\"\");\n const [ignoreResponse, setIgnoreResponse] = useState(false);\n const ignoreResponseRef = useRef(ignoreResponse);\n const [currentThreadId, setCurrentThreadId] = useState<string>(\n PLACEHOLDER_THREAD.id,\n );\n const currentThread: TamboThread | undefined = threadMap[currentThreadId];\n\n // Use existing messages from the current thread to avoid re-generating any components\n const currentMessageCache = useMemo(() => {\n const messageCache = new Map<string, TamboThreadMessage>();\n if (currentThread) {\n for (const message of currentThread.messages) {\n messageCache.set(message.id, message);\n }\n }\n return messageCache;\n }, [currentThread]);\n\n useEffect(() => {\n ignoreResponseRef.current = ignoreResponse;\n }, [ignoreResponse]);\n\n const isIdle = useMemo(\n () =>\n isIdleStage(\n (currentThread?.generationStage ??\n GenerationStage.IDLE) as GenerationStage,\n ),\n [currentThread?.generationStage],\n );\n\n const fetchThread = useCallback(\n async (threadId: string, includeInternalMessages = true) => {\n const thread = await client.beta.threads.retrieve(threadId, {\n includeInternal: includeInternalMessages,\n });\n const threadWithRenderedComponents = {\n ...thread,\n messages: thread.messages.map((message) => {\n if (currentMessageCache.has(message.id)) {\n const renderedMessage = currentMessageCache.get(message.id);\n return {\n ...renderedMessage,\n ...message,\n };\n }\n if (message.component?.componentName) {\n const messageWithComponent = renderComponentIntoMessage(\n message,\n componentList,\n );\n return messageWithComponent;\n }\n return message;\n }),\n };\n\n setThreadMap((prevMap) => {\n const updatedThreadMap = {\n ...prevMap,\n [threadId]: threadWithRenderedComponents,\n };\n return updatedThreadMap;\n });\n },\n [client.beta.threads, componentList, currentMessageCache],\n );\n\n useEffect(() => {\n if (\n currentThreadId &&\n currentThreadId !== PLACEHOLDER_THREAD.id &&\n !threadMap[currentThreadId]\n ) {\n fetchThread(currentThreadId);\n }\n }, [currentThreadId, fetchThread, threadMap]);\n\n const addThreadMessage = useCallback(\n async (\n message: TamboThreadMessage,\n sendToServer = true,\n createdAt: string = new Date().toISOString(),\n ) => {\n if (!currentThread) {\n console.warn(\"Cannot add messages if we do not have a current thread\");\n return [];\n }\n\n const chatMessage: TamboThreadMessage = {\n ...message,\n createdAt,\n };\n const threadId = message.threadId;\n const messageId = chatMessage.id;\n // optimistically update the thread in the local state\n setThreadMap((prevMap) => {\n if (!threadId) {\n return prevMap;\n }\n const prevMessages = prevMap[threadId]?.messages || [];\n const haveMessage = prevMessages.find((msg) => msg.id === messageId);\n // Update in place if the message already exists\n const updatedMessages = haveMessage\n ? prevMessages.map((msg) => {\n if (msg.id === messageId) {\n return chatMessage;\n }\n return msg;\n })\n : [...prevMessages, chatMessage];\n\n const updatedThreadMap = {\n ...prevMap,\n [threadId]: {\n ...prevMap[threadId],\n messages: updatedMessages,\n },\n };\n return updatedThreadMap;\n });\n\n if (sendToServer) {\n // TODO: if this fails, we need to revert the local state update\n await client.beta.threads.messages.create(message.threadId, {\n content: message.content,\n role: message.role,\n additionalContext: chatMessage.additionalContext,\n });\n }\n return threadMap[threadId]?.messages || [];\n },\n [client.beta.threads.messages, currentThread, threadMap],\n );\n\n const updateThreadMessage = useCallback(\n async (\n id: string,\n message: TamboThreadMessage,\n sendToServer = true,\n createdAt: string = new Date().toISOString(),\n ) => {\n const chatMessage: TamboThreadMessage = {\n ...message,\n createdAt,\n };\n\n setThreadMap((prevMap) => {\n if (!message.threadId) {\n return prevMap;\n }\n const prevMessages = prevMap[message.threadId]?.messages || [];\n const updatedMessages = prevMessages.map((msg) => {\n if (msg.id === id) {\n return chatMessage;\n }\n return msg;\n });\n return {\n ...prevMap,\n [message.threadId]: {\n ...prevMap[message.threadId],\n messages: updatedMessages,\n },\n };\n });\n if (sendToServer) {\n // TODO: if this fails, we need to revert the local state update\n await client.beta.threads.messages.create(message.threadId, {\n content: message.content,\n role: message.role,\n additionalContext: chatMessage.additionalContext,\n });\n }\n },\n [client.beta.threads.messages],\n );\n\n const startNewThread = useCallback(() => {\n setCurrentThreadId(PLACEHOLDER_THREAD.id);\n setThreadMap((prevMap) => {\n return {\n ...prevMap,\n [PLACEHOLDER_THREAD.id]: PLACEHOLDER_THREAD,\n };\n });\n }, []);\n\n const updateThreadName = useCallback(\n async (name: string, threadId?: string) => {\n threadId ??= currentThreadId;\n\n setThreadMap((prevMap) => {\n if (!prevMap[threadId]) {\n return prevMap;\n }\n return { ...prevMap, [threadId]: { ...prevMap[threadId], name } };\n });\n\n if (threadId !== PLACEHOLDER_THREAD.id) {\n const currentProject = await client.beta.projects.getCurrent();\n await client.beta.threads.update(threadId, {\n name,\n projectId: currentProject.id,\n });\n }\n },\n [currentThreadId, client.beta.projects, client.beta.threads],\n );\n\n const generateThreadName = useCallback(\n async (threadId?: string) => {\n threadId ??= currentThreadId;\n if (threadId === PLACEHOLDER_THREAD.id) {\n console.warn(\"Cannot generate name for empty thread\");\n return threadMap[threadId];\n }\n\n const threadWithGeneratedName =\n await client.beta.threads.generateName(threadId);\n\n setThreadMap((prevMap) => {\n if (!prevMap[threadId]) {\n return prevMap;\n }\n return {\n ...prevMap,\n [threadId]: {\n ...prevMap[threadId],\n name: threadWithGeneratedName.name,\n },\n };\n });\n return threadWithGeneratedName;\n },\n [client.beta.threads, currentThreadId, threadMap],\n );\n\n const switchCurrentThread = useCallback(\n async (threadId: string, fetch = true) => {\n if (threadId === PLACEHOLDER_THREAD.id) {\n console.warn(\"Switching to placeholder thread, may be a bug.\");\n return;\n }\n setCurrentThreadId(threadId);\n setThreadMap((prevMap) => {\n if (prevMap[threadId]) {\n return prevMap;\n }\n // If this is a new thread, add placeholder thread messages to the thread\n const updatedThreadMap = {\n ...prevMap,\n [threadId]: {\n ...prevMap[PLACEHOLDER_THREAD.id],\n id: threadId,\n },\n };\n return updatedThreadMap;\n });\n if (fetch) {\n await fetchThread(threadId);\n }\n },\n [fetchThread],\n );\n\n const updateThreadStatus = useCallback(\n (threadId: string, stage: GenerationStage, statusMessage?: string) => {\n setThreadMap((prevMap) => {\n const updatedThreadMap = {\n ...prevMap,\n [threadId]: {\n ...prevMap[threadId],\n generationStage: stage,\n statusMessage: statusMessage,\n },\n };\n return updatedThreadMap;\n });\n },\n [],\n );\n\n const cancel = useCallback(\n async (threadId?: string) => {\n threadId ??= currentThreadId;\n if (isIdle) {\n return;\n }\n setIgnoreResponse(true);\n setThreadMap((prevMap) => {\n if (!prevMap[threadId]) {\n return prevMap;\n }\n\n return {\n ...prevMap,\n [threadId]: {\n ...prevMap[threadId],\n generationStage: GenerationStage.CANCELLED,\n messages: prevMap[threadId].messages.map((message) => {\n if (\n message.id ===\n prevMap[threadId].messages[\n prevMap[threadId].messages.length - 1\n ].id\n ) {\n return {\n ...message,\n isCancelled: true,\n };\n }\n return message;\n }),\n },\n };\n });\n\n await client.beta.threads.cancel(threadId);\n },\n [client.beta.threads, currentThreadId, isIdle],\n );\n\n const handleAdvanceStream = useCallback(\n async (\n stream: AsyncIterable<TamboAI.Beta.Threads.ThreadAdvanceResponse>,\n params: TamboAI.Beta.Threads.ThreadAdvanceParams,\n threadId: string,\n ): Promise<TamboThreadMessage> => {\n if (ignoreResponseRef.current) {\n setIgnoreResponse(false);\n return {\n threadId: threadId,\n content: [{ type: \"text\", text: \"\" }],\n role: \"assistant\",\n createdAt: new Date().toISOString(),\n id: crypto.randomUUID(),\n componentState: {},\n };\n }\n let finalMessage: Readonly<TamboThreadMessage> | undefined;\n let hasSetThreadId = false;\n updateThreadStatus(threadId, GenerationStage.STREAMING_RESPONSE);\n\n for await (const chunk of stream) {\n if (chunk.responseMessageDto.toolCallRequest) {\n // Increment tool call count for this tool\n const toolName = chunk.responseMessageDto.toolCallRequest.toolName;\n if (toolName && params.toolCallCounts) {\n params.toolCallCounts[toolName] =\n (params.toolCallCounts[toolName] ?? 0) + 1;\n }\n\n updateThreadStatus(\n chunk.responseMessageDto.threadId,\n GenerationStage.FETCHING_CONTEXT,\n );\n\n updateThreadMessage(\n chunk.responseMessageDto.id,\n {\n ...chunk.responseMessageDto,\n },\n false,\n );\n\n const toolCallResponse = await handleToolCall(\n chunk.responseMessageDto,\n toolRegistry,\n );\n if (ignoreResponseRef.current) {\n setIgnoreResponse(false);\n {\n return {\n threadId: threadId,\n content: [{ type: \"text\", text: \"\" }],\n role: \"assistant\",\n createdAt: new Date().toISOString(),\n id: crypto.randomUUID(),\n componentState: {},\n };\n }\n }\n const toolCallResponseString =\n typeof toolCallResponse.result === \"string\"\n ? toolCallResponse.result\n : JSON.stringify(toolCallResponse.result);\n const toolCallResponseParams: TamboAI.Beta.Threads.ThreadAdvanceParams =\n {\n ...params,\n messageToAppend: {\n content: [{ type: \"text\", text: toolCallResponseString }],\n role: \"tool\",\n actionType: \"tool_response\",\n component: chunk.responseMessageDto.component,\n tool_call_id: chunk.responseMessageDto.tool_call_id,\n error: toolCallResponse.error,\n },\n };\n\n updateThreadMessage(\n chunk.responseMessageDto.id,\n {\n ...chunk.responseMessageDto,\n error: toolCallResponse.error,\n },\n false,\n );\n\n addThreadMessage(\n {\n threadId: chunk.responseMessageDto.threadId,\n content: [{ type: \"text\", text: toolCallResponseString }],\n role: \"tool\",\n id: crypto.randomUUID(),\n createdAt: new Date().toISOString(),\n componentState: {},\n actionType: \"tool_response\",\n tool_call_id: chunk.responseMessageDto.tool_call_id,\n error: toolCallResponse.error,\n },\n false,\n );\n\n updateThreadStatus(\n chunk.responseMessageDto.threadId,\n GenerationStage.STREAMING_RESPONSE,\n );\n const toolCallResponseStream = await advanceStream(\n client,\n toolCallResponseParams,\n chunk.responseMessageDto.threadId,\n );\n\n return await handleAdvanceStream(\n toolCallResponseStream,\n toolCallResponseParams,\n chunk.responseMessageDto.threadId,\n );\n } else {\n if (ignoreResponseRef.current) {\n setIgnoreResponse(false);\n return (\n finalMessage ?? {\n threadId: threadId,\n content: [{ type: \"text\", text: \"\" }],\n role: \"assistant\",\n createdAt: new Date().toISOString(),\n id: crypto.randomUUID(),\n componentState: {},\n }\n );\n }\n if (\n !hasSetThreadId &&\n chunk.responseMessageDto.threadId &&\n chunk.responseMessageDto.threadId !== currentThread?.id\n ) {\n hasSetThreadId = true;\n await switchCurrentThread(chunk.responseMessageDto.threadId, false);\n }\n\n if (!finalMessage) {\n finalMessage = chunk.responseMessageDto.component?.componentName\n ? renderComponentIntoMessage(\n chunk.responseMessageDto,\n componentList,\n )\n : chunk.responseMessageDto;\n await addThreadMessage(finalMessage, false);\n } else {\n // if we start getting a new message mid-stream, put the previous one on screen\n const isNewMessage =\n chunk.responseMessageDto.id !== finalMessage.id;\n\n finalMessage = chunk.responseMessageDto.component?.componentName\n ? renderComponentIntoMessage(\n chunk.responseMessageDto,\n componentList,\n )\n : chunk.responseMessageDto;\n\n if (isNewMessage) {\n await addThreadMessage(finalMessage, false);\n } else {\n await updateThreadMessage(finalMessage.id, finalMessage, false);\n }\n }\n }\n }\n\n updateThreadStatus(\n finalMessage?.threadId ?? threadId,\n GenerationStage.COMPLETE,\n );\n return (\n finalMessage ?? {\n threadId: \"\",\n content: [{ type: \"text\", text: `Error processing stream` }],\n role: \"assistant\",\n createdAt: new Date().toISOString(),\n id: crypto.randomUUID(),\n componentState: {},\n }\n );\n },\n [\n addThreadMessage,\n client,\n componentList,\n currentThread?.id,\n switchCurrentThread,\n toolRegistry,\n updateThreadMessage,\n updateThreadStatus,\n ],\n );\n\n const currentThreadContextKey = currentThread?.contextKey;\n\n const sendThreadMessage = useCallback(\n async (\n message: string,\n options: {\n threadId?: string;\n streamResponse?: boolean;\n forceToolChoice?: string;\n contextKey?: string;\n additionalContext?: Record<string, any>;\n } = {},\n ): Promise<TamboThreadMessage> => {\n setIgnoreResponse(false);\n const {\n threadId = currentThreadId ?? PLACEHOLDER_THREAD.id,\n streamResponse = streaming,\n forceToolChoice,\n contextKey = currentThreadContextKey,\n additionalContext,\n } = options;\n updateThreadStatus(threadId, GenerationStage.FETCHING_CONTEXT);\n\n // Get additional context from enabled helpers\n const helperContexts = await getAdditionalContext();\n\n // Combine all contexts\n const combinedContext: Record<string, any> = {\n ...(additionalContext ?? {}),\n };\n\n // Add helper contexts to combinedContext\n for (const helperContext of helperContexts) {\n combinedContext[helperContext.name] = helperContext.context;\n }\n\n addThreadMessage(\n {\n content: [{ type: \"text\", text: message }],\n renderedComponent: null,\n role: \"user\",\n threadId: threadId,\n id: crypto.randomUUID(),\n createdAt: new Date().toISOString(),\n componentState: {},\n additionalContext: combinedContext,\n },\n false,\n );\n\n const availableComponents = getAvailableComponents(\n componentList,\n toolRegistry,\n componentToolAssociations,\n );\n const unassociatedTools = getUnassociatedTools(\n toolRegistry,\n componentToolAssociations,\n );\n\n // Track tool call counts for this message processing\n const toolCallCounts: Record<string, number> = {};\n\n const params: TamboAI.Beta.Threads.ThreadAdvanceParams = {\n messageToAppend: {\n content: [{ type: \"text\", text: message }],\n role: \"user\",\n additionalContext: combinedContext,\n },\n contextKey,\n availableComponents: availableComponents,\n clientTools: unassociatedTools.map((tool) =>\n mapTamboToolToContextTool(tool),\n ),\n forceToolChoice: forceToolChoice,\n toolCallCounts,\n };\n\n if (streamResponse) {\n const advanceStreamResponse = await advanceStream(\n client,\n params,\n threadId === PLACEHOLDER_THREAD.id ? undefined : threadId,\n );\n return await handleAdvanceStream(\n advanceStreamResponse,\n params,\n threadId,\n );\n }\n let advanceResponse = await (threadId === PLACEHOLDER_THREAD.id\n ? client.beta.threads.advance(params)\n : client.beta.threads.advanceById(threadId, params));\n\n //handle tool calls\n while (advanceResponse.responseMessageDto.toolCallRequest) {\n // Increment tool call count for this tool\n const toolName =\n advanceResponse.responseMessageDto.toolCallRequest.toolName;\n if (toolName) {\n toolCallCounts[toolName] = (toolCallCounts[toolName] || 0) + 1;\n }\n\n updateThreadStatus(threadId, GenerationStage.FETCHING_CONTEXT);\n const toolCallResponse = await handleToolCall(\n advanceResponse.responseMessageDto,\n toolRegistry,\n );\n const toolResponseString =\n typeof toolCallResponse.result === \"string\"\n ? toolCallResponse.result\n : JSON.stringify(toolCallResponse.result);\n const toolCallResponseParams: TamboAI.Beta.Threads.ThreadAdvanceParams =\n {\n ...params,\n messageToAppend: {\n ...params.messageToAppend,\n content: [{ type: \"text\", text: toolResponseString }],\n role: \"tool\",\n actionType: \"tool_response\",\n component: advanceResponse.responseMessageDto.component,\n tool_call_id: advanceResponse.responseMessageDto.tool_call_id,\n error: toolCallResponse.error,\n },\n };\n if (toolCallResponse.error) {\n //update toolcall message with error\n const toolCallMessage = {\n ...advanceResponse.responseMessageDto,\n error: toolCallResponse.error,\n };\n updateThreadMessage(toolCallMessage.id, toolCallMessage, false);\n }\n updateThreadStatus(threadId, GenerationStage.HYDRATING_COMPONENT);\n addThreadMessage(\n {\n threadId: threadId,\n content: [{ type: \"text\", text: toolResponseString }],\n role: \"tool\",\n id: crypto.randomUUID(),\n createdAt: new Date().toISOString(),\n componentState: {},\n actionType: \"tool_response\",\n tool_call_id: advanceResponse.responseMessageDto.tool_call_id,\n error: toolCallResponse.error,\n },\n false,\n );\n\n advanceResponse = await client.beta.threads.advanceById(\n advanceResponse.responseMessageDto.threadId,\n toolCallResponseParams,\n );\n }\n\n const finalMessage = advanceResponse.responseMessageDto.component\n ?.componentName\n ? renderComponentIntoMessage(\n advanceResponse.responseMessageDto,\n componentList,\n )\n : advanceResponse.responseMessageDto;\n await switchCurrentThread(advanceResponse.responseMessageDto.threadId);\n updateThreadStatus(\n advanceResponse.responseMessageDto.threadId,\n GenerationStage.COMPLETE,\n );\n return finalMessage;\n },\n [\n componentList,\n toolRegistry,\n componentToolAssociations,\n currentThreadId,\n currentThreadContextKey,\n switchCurrentThread,\n addThreadMessage,\n client,\n updateThreadMessage,\n updateThreadStatus,\n handleAdvanceStream,\n streaming,\n getAdditionalContext,\n ],\n );\n\n return (\n <TamboThreadContext.Provider\n value={{\n thread: currentThread,\n switchCurrentThread,\n startNewThread,\n updateThreadName,\n generateThreadName,\n addThreadMessage,\n updateThreadMessage,\n inputValue,\n setInputValue,\n sendThreadMessage,\n streaming,\n generationStage: (currentThread?.generationStage ??\n GenerationStage.IDLE) as GenerationStage,\n generationStatusMessage: currentThread?.statusMessage ?? \"\",\n isIdle,\n cancel,\n }}\n >\n {children}\n </TamboThreadContext.Provider>\n );\n};\n\n/**\n * The useTamboThread hook provides access to the current thread context\n * to the descendants of the TamboThreadProvider.\n * @returns All state and actions for the current thread\n */\nexport const useTamboThread = () => {\n const context = useContext(TamboThreadContext);\n if (context === undefined) {\n throw new Error(\"useTamboThread must be used within a TamboThreadProvider\");\n }\n return context;\n};\n"]}
|
package/dist/util/registry.d.ts
CHANGED
|
@@ -28,14 +28,6 @@ export declare const convertPropsToJsonSchema: (component: RegisteredComponent)
|
|
|
28
28
|
* @returns The component registration information
|
|
29
29
|
*/
|
|
30
30
|
export declare const getComponentFromRegistry: (componentName: string, componentRegistry: ComponentRegistry) => RegisteredComponent;
|
|
31
|
-
/**
|
|
32
|
-
* Get the client context for the current thread, such as the current time in the user's timezone
|
|
33
|
-
* @returns a string of context additions that will be added to the prompt when the thread is advanced.
|
|
34
|
-
*/
|
|
35
|
-
export declare const getSystemContext: () => {
|
|
36
|
-
localTime: string;
|
|
37
|
-
timezone: string;
|
|
38
|
-
};
|
|
39
31
|
/**
|
|
40
32
|
* Map a Tambo tool to a context tool
|
|
41
33
|
* @param tool - The tool to map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/util/registry.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,0BAA0B,CAAC;AAG/C,OAAO,EACL,4BAA4B,EAC5B,iBAAiB,EAGjB,mBAAmB,EACnB,SAAS,EACT,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,6BAA6B,CAAC;AAErC;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,GACjC,mBAAmB,iBAAiB,EACpC,cAAc,iBAAiB,EAC/B,kBAAkB,qBAAqB,KACtC,OAAO,CAAC,kBAAkB,EAuB5B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAC/B,cAAc,iBAAiB,EAC/B,kBAAkB,qBAAqB,KACtC,SAAS,EAKX,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,GACnC,WAAW,mBAAmB,KAC7B,GAYF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,GACnC,eAAe,MAAM,EACrB,mBAAmB,iBAAiB,KACnC,mBAUF,CAAC;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/util/registry.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,0BAA0B,CAAC;AAG/C,OAAO,EACL,4BAA4B,EAC5B,iBAAiB,EAGjB,mBAAmB,EACnB,SAAS,EACT,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,6BAA6B,CAAC;AAErC;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,GACjC,mBAAmB,iBAAiB,EACpC,cAAc,iBAAiB,EAC/B,kBAAkB,qBAAqB,KACtC,OAAO,CAAC,kBAAkB,EAuB5B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAC/B,cAAc,iBAAiB,EAC/B,kBAAkB,qBAAqB,KACtC,SAAS,EAKX,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,GACnC,WAAW,mBAAmB,KAC7B,GAYF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,GACnC,eAAe,MAAM,EACrB,mBAAmB,iBAAiB,KACnC,mBAUF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,GACpC,MAAM,SAAS,KACd,4BAQF,CAAC"}
|
package/dist/util/registry.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.mapTamboToolToContextTool = exports.
|
|
6
|
+
exports.mapTamboToolToContextTool = exports.getComponentFromRegistry = exports.convertPropsToJsonSchema = exports.getUnassociatedTools = exports.getAvailableComponents = void 0;
|
|
7
7
|
const zod_to_json_schema_1 = __importDefault(require("zod-to-json-schema"));
|
|
8
8
|
/**
|
|
9
9
|
* Get all the available components from the component registry
|
|
@@ -78,20 +78,6 @@ const getComponentFromRegistry = (componentName, componentRegistry) => {
|
|
|
78
78
|
return componentEntry;
|
|
79
79
|
};
|
|
80
80
|
exports.getComponentFromRegistry = getComponentFromRegistry;
|
|
81
|
-
const getDefaultContextObject = () => {
|
|
82
|
-
return {
|
|
83
|
-
localTime: new Date().toLocaleString(),
|
|
84
|
-
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
85
|
-
};
|
|
86
|
-
};
|
|
87
|
-
/**
|
|
88
|
-
* Get the client context for the current thread, such as the current time in the user's timezone
|
|
89
|
-
* @returns a string of context additions that will be added to the prompt when the thread is advanced.
|
|
90
|
-
*/
|
|
91
|
-
const getSystemContext = () => {
|
|
92
|
-
return getDefaultContextObject();
|
|
93
|
-
};
|
|
94
|
-
exports.getSystemContext = getSystemContext;
|
|
95
81
|
/**
|
|
96
82
|
* Map a Tambo tool to a context tool
|
|
97
83
|
* @param tool - The tool to map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/util/registry.ts"],"names":[],"mappings":";;;;;;AAEA,4EAAiD;AAYjD;;;;;;GAMG;AACI,MAAM,sBAAsB,GAAG,CACpC,iBAAoC,EACpC,YAA+B,EAC/B,gBAAuC,EACT,EAAE;IAChC,MAAM,mBAAmB,GAAiC,EAAE,CAAC;IAE7D,KAAK,MAAM,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAAE,CAAC;QACvE,MAAM,mBAAmB,GAAG,gBAAgB,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QAEzD,MAAM,YAAY,GAAG;YACnB,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;gBACtC,MAAM,IAAI,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;gBACpC,IAAI,CAAC,IAAI;oBAAE,OAAO,IAAI,CAAC;gBACvB,OAAO,IAAA,iCAAyB,EAAC,IAAI,CAAC,CAAC;YACzC,CAAC,CAAC;SACH,CAAC,MAAM,CAAC,CAAC,IAAI,EAAwC,EAAE,CAAC,IAAI,KAAK,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,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,MAAoB,EAAU,EAAE;IACtD,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;IACtC,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,WAAW;YACd,OAAO,QAAQ,CAAC;QAClB,KAAK,WAAW;YACd,OAAO,QAAQ,CAAC;QAClB,KAAK,YAAY;YACf,OAAO,SAAS,CAAC;QACnB,KAAK,UAAU;YACb,OAAO,OAAO,CAAC;QACjB,KAAK,SAAS;YACZ,OAAO,MAAM,CAAC;QAChB,KAAK,SAAS;YACZ,OAAO,MAAM,CAAC;QAChB,KAAK,WAAW;YACd,OAAO,QAAQ,CAAC;QAClB;YACE,OAAO,CAAC,IAAI,CAAC,4BAA4B,EAAE,QAAQ,CAAC,CAAC;YACrD,OAAO,QAAQ,CAAC;IACpB,CAAC;AACH,CAAC,CAAC","sourcesContent":["import TamboAI from \"@tambo-ai/typescript-sdk\";\nimport { z } from \"zod\";\nimport zodToJsonSchema from \"zod-to-json-schema\";\nimport {\n ComponentContextToolMetadata,\n ComponentRegistry,\n JSONSchemaLite,\n ParameterSpec,\n RegisteredComponent,\n TamboTool,\n TamboToolAssociations,\n TamboToolRegistry,\n} from \"../model/component-metadata\";\n\n/**\n * Get all the available components from the component registry\n * @param componentRegistry - The component registry\n * @param toolRegistry - The tool registry\n * @param toolAssociations - The tool associations\n * @returns The available components\n */\nexport const getAvailableComponents = (\n componentRegistry: ComponentRegistry,\n toolRegistry: TamboToolRegistry,\n toolAssociations: TamboToolAssociations,\n): TamboAI.AvailableComponent[] => {\n const availableComponents: TamboAI.AvailableComponent[] = [];\n\n for (const [name, componentEntry] of Object.entries(componentRegistry)) {\n const associatedToolNames = toolAssociations[name] || [];\n\n const contextTools = [\n ...associatedToolNames.map((toolName) => {\n const tool = toolRegistry[toolName];\n if (!tool) return null;\n return mapTamboToolToContextTool(tool);\n }),\n ].filter((tool): tool is ComponentContextToolMetadata => tool !== null);\n\n availableComponents.push({\n name: componentEntry.name,\n description: componentEntry.description,\n props: componentEntry.props,\n contextTools,\n });\n }\n\n return availableComponents;\n};\n\n/**\n * Get tools from tool registry that are not associated with any component\n * @param toolRegistry - The tool registry\n * @param toolAssociations - The tool associations\n * @returns The tools that are not associated with any component\n */\nexport const getUnassociatedTools = (\n toolRegistry: TamboToolRegistry,\n toolAssociations: TamboToolAssociations,\n): TamboTool[] => {\n return Object.values(toolRegistry).filter((tool) => {\n // Check if the tool's name appears in any of the tool association arrays\n return !Object.values(toolAssociations).flat().includes(tool.name);\n });\n};\n\n/**\n * Helper function to convert component props from Zod schema to JSON Schema\n * @param component - The component to convert\n * @returns The converted props\n */\nexport const convertPropsToJsonSchema = (\n component: RegisteredComponent,\n): any => {\n if (!component.props) {\n return component.props;\n }\n\n // Check if props is a Zod schema (we can't directly check the type, so we check for _def)\n if (component.props._def && typeof component.props.parse === \"function\") {\n // Use two-step type assertion for safety\n return zodToJsonSchema(component.props as unknown as z.ZodTypeAny);\n }\n\n return component.props;\n};\n\n/**\n * Get a component by name from the component registry\n * @param componentName - The name of the component to get\n * @param componentRegistry - The component registry\n * @returns The component registration information\n */\nexport const getComponentFromRegistry = (\n componentName: string,\n componentRegistry: ComponentRegistry,\n): RegisteredComponent => {\n const componentEntry = componentRegistry[componentName];\n\n if (!componentEntry) {\n throw new Error(\n `Tambo tried to use Component ${componentName}, but it was not found.`,\n );\n }\n\n return componentEntry;\n};\n\n/**\n * Map a Tambo tool to a context tool\n * @param tool - The tool to map\n * @returns The context tool\n */\nexport const mapTamboToolToContextTool = (\n tool: TamboTool,\n): ComponentContextToolMetadata => {\n const parameters = getParametersFromZodFunction(tool.toolSchema);\n\n return {\n name: tool.name,\n description: tool.description,\n parameters,\n };\n};\n\nfunction isJsonSchema(\n schema: unknown,\n): schema is ReturnType<typeof zodToJsonSchema> {\n return (\n typeof schema === \"object\" &&\n schema !== null &&\n \"type\" in schema &&\n typeof (schema as { type: unknown }).type === \"string\" &&\n (schema as { type: string }).type === \"object\"\n );\n}\n\nconst getParametersFromZodFunction = (\n schema: z.ZodFunction<any, any> | JSONSchemaLite,\n): ParameterSpec[] => {\n if (isJsonSchema(schema)) {\n return [\n {\n name: \"args\",\n type: \"object\",\n description: schema.description ?? \"\",\n isRequired: true,\n schema: schema,\n },\n ];\n }\n\n const parameters: z.ZodTuple = schema.parameters();\n return parameters.items.map((param, index): ParameterSpec => {\n const name = `param${index + 1}`;\n const type = getZodBaseType(param);\n const description = param.description ?? \"\";\n const isRequired = !param.isOptional();\n const schema = zodToJsonSchema(param);\n\n return {\n name,\n type,\n description,\n isRequired,\n schema,\n };\n });\n};\n\nconst getZodBaseType = (schema: z.ZodTypeAny): string => {\n const typeName = schema._def.typeName;\n switch (typeName) {\n case \"ZodString\":\n return \"string\";\n case \"ZodNumber\":\n return \"number\";\n case \"ZodBoolean\":\n return \"boolean\";\n case \"ZodArray\":\n return \"array\";\n case \"ZodEnum\":\n return \"enum\";\n case \"ZodDate\":\n return \"date\";\n case \"ZodObject\":\n return \"object\";\n default:\n console.warn(\"falling back to string for\", typeName);\n return \"string\";\n }\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-helpers.test.d.ts","sourceRoot":"","sources":["../../../src/context-helpers/__tests__/context-helpers.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { getUserPageContext, getUserTimeContext } from "../index";
|
|
2
|
+
describe("Context Helpers", () => {
|
|
3
|
+
describe("getUserTimeContext", () => {
|
|
4
|
+
it("should return user time context with all required fields", () => {
|
|
5
|
+
const context = getUserTimeContext();
|
|
6
|
+
expect(context.name).toBe("userTime");
|
|
7
|
+
expect(context.context).toHaveProperty("localTime");
|
|
8
|
+
expect(context.context).toHaveProperty("timezone");
|
|
9
|
+
expect(context.context).toHaveProperty("timestamp");
|
|
10
|
+
expect(context.context).toHaveProperty("offsetMinutes");
|
|
11
|
+
// Verify data types
|
|
12
|
+
expect(typeof context.context.localTime).toBe("string");
|
|
13
|
+
expect(typeof context.context.timezone).toBe("string");
|
|
14
|
+
expect(typeof context.context.timestamp).toBe("string");
|
|
15
|
+
expect(typeof context.context.offsetMinutes).toBe("number");
|
|
16
|
+
// Verify timestamp is valid ISO string
|
|
17
|
+
expect(() => new Date(context.context.timestamp)).not.toThrow();
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
describe("getUserPageContext", () => {
|
|
21
|
+
it("should return page context with default values in test environment", () => {
|
|
22
|
+
const context = getUserPageContext();
|
|
23
|
+
expect(context.name).toBe("userPage");
|
|
24
|
+
expect(context.context).toHaveProperty("url");
|
|
25
|
+
expect(context.context).toHaveProperty("pathname");
|
|
26
|
+
expect(context.context).toHaveProperty("hostname");
|
|
27
|
+
expect(context.context).toHaveProperty("search");
|
|
28
|
+
expect(context.context).toHaveProperty("hash");
|
|
29
|
+
expect(context.context).toHaveProperty("title");
|
|
30
|
+
expect(context.context).toHaveProperty("referrer");
|
|
31
|
+
// Verify data types
|
|
32
|
+
expect(typeof context.context.url).toBe("string");
|
|
33
|
+
expect(typeof context.context.pathname).toBe("string");
|
|
34
|
+
expect(typeof context.context.hostname).toBe("string");
|
|
35
|
+
expect(typeof context.context.search).toBe("string");
|
|
36
|
+
expect(typeof context.context.hash).toBe("string");
|
|
37
|
+
expect(typeof context.context.title).toBe("string");
|
|
38
|
+
expect(typeof context.context.referrer).toBe("string");
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=context-helpers.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-helpers.test.js","sourceRoot":"","sources":["../../../src/context-helpers/__tests__/context-helpers.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAElE,QAAQ,CAAC,iBAAi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C,KAAK,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACpD,MAAM,CAAC,OAAO,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACzD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { getUserPageContext, getUserTimeContext } from \"../index\";\n\ndescribe(\"Context Helpers\", () => {\n describe(\"getUserTimeContext\", () => {\n it(\"should return user time context with all required fields\", () => {\n const context = getUserTimeContext();\n\n expect(context.name).toBe(\"userTime\");\n expect(context.context).toHaveProperty(\"localTime\");\n expect(context.context).toHaveProperty(\"timezone\");\n expect(context.context).toHaveProperty(\"timestamp\");\n expect(context.context).toHaveProperty(\"offsetMinutes\");\n\n // Verify data types\n expect(typeof context.context.localTime).toBe(\"string\");\n expect(typeof context.context.timezone).toBe(\"string\");\n expect(typeof context.context.timestamp).toBe(\"string\");\n expect(typeof context.context.offsetMinutes).toBe(\"number\");\n\n // Verify timestamp is valid ISO string\n expect(() => new Date(context.context.timestamp)).not.toThrow();\n });\n });\n\n describe(\"getUserPageContext\", () => {\n it(\"should return page context with default values in test environment\", () => {\n const context = getUserPageContext();\n\n expect(context.name).toBe(\"userPage\");\n expect(context.context).toHaveProperty(\"url\");\n expect(context.context).toHaveProperty(\"pathname\");\n expect(context.context).toHaveProperty(\"hostname\");\n expect(context.context).toHaveProperty(\"search\");\n expect(context.context).toHaveProperty(\"hash\");\n expect(context.context).toHaveProperty(\"title\");\n expect(context.context).toHaveProperty(\"referrer\");\n\n // Verify data types\n expect(typeof context.context.url).toBe(\"string\");\n expect(typeof context.context.pathname).toBe(\"string\");\n expect(typeof context.context.hostname).toBe(\"string\");\n expect(typeof context.context.search).toBe(\"string\");\n expect(typeof context.context.hash).toBe(\"string\");\n expect(typeof context.context.title).toBe(\"string\");\n expect(typeof context.context.referrer).toBe(\"string\");\n });\n });\n});\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AdditionalContextHelper } from "./types";
|
|
2
|
+
export * from "./types";
|
|
3
|
+
export * from "./user-page";
|
|
4
|
+
export * from "./user-time";
|
|
5
|
+
/**
|
|
6
|
+
* Pre-built context helpers that can be enabled/disabled
|
|
7
|
+
*/
|
|
8
|
+
export declare const DEFAULT_CONTEXT_HELPERS: AdditionalContextHelper[];
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/context-helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAIlD,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAE5B;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,uBAAuB,EAW5D,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getUserPageContext } from "./user-page";
|
|
2
|
+
import { getUserTimeContext } from "./user-time";
|
|
3
|
+
export * from "./types";
|
|
4
|
+
export * from "./user-page";
|
|
5
|
+
export * from "./user-time";
|
|
6
|
+
/**
|
|
7
|
+
* Pre-built context helpers that can be enabled/disabled
|
|
8
|
+
*/
|
|
9
|
+
export const DEFAULT_CONTEXT_HELPERS = [
|
|
10
|
+
{
|
|
11
|
+
name: "userTime",
|
|
12
|
+
enabled: false, // Default to disabled
|
|
13
|
+
run: getUserTimeContext,
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
name: "userPage",
|
|
17
|
+
enabled: false, // Default to disabled
|
|
18
|
+
run: getUserPageContext,
|
|
19
|
+
},
|
|
20
|
+
];
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/context-helpers/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAE5B;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAA8B;IAChE;QACE,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,KAAK,EAAE,sBAAsB;QACtC,GAAG,EAAE,kBAAkB;KACxB;IACD;QACE,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,KAAK,EAAE,sBAAsB;QACtC,GAAG,EAAE,kBAAkB;KACxB;CACF,CAAC","sourcesContent":["import { AdditionalContextHelper } from \"./types\";\nimport { getUserPageContext } from \"./user-page\";\nimport { getUserTimeContext } from \"./user-time\";\n\nexport * from \"./types\";\nexport * from \"./user-page\";\nexport * from \"./user-time\";\n\n/**\n * Pre-built context helpers that can be enabled/disabled\n */\nexport const DEFAULT_CONTEXT_HELPERS: AdditionalContextHelper[] = [\n {\n name: \"userTime\",\n enabled: false, // Default to disabled\n run: getUserTimeContext,\n },\n {\n name: \"userPage\",\n enabled: false, // Default to disabled\n run: getUserPageContext,\n },\n];\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface for additional context that can be added to messages
|
|
3
|
+
*/
|
|
4
|
+
export interface AdditionalContext {
|
|
5
|
+
/** The name of the context type */
|
|
6
|
+
name: string;
|
|
7
|
+
/** The context data */
|
|
8
|
+
context: any;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Interface for a context helper that can generate additional context
|
|
12
|
+
*/
|
|
13
|
+
export interface AdditionalContextHelper {
|
|
14
|
+
/** The name of the context helper */
|
|
15
|
+
name: string;
|
|
16
|
+
/** Whether this helper is enabled */
|
|
17
|
+
enabled: boolean;
|
|
18
|
+
/** Function that generates the additional context */
|
|
19
|
+
run: () => AdditionalContext | Promise<AdditionalContext>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Configuration for context helpers
|
|
23
|
+
*/
|
|
24
|
+
export interface ContextHelpersConfig {
|
|
25
|
+
/** Enable/disable user time context helper */
|
|
26
|
+
userTime?: boolean;
|
|
27
|
+
/** Enable/disable user page context helper */
|
|
28
|
+
userPage?: boolean;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/context-helpers/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,uBAAuB;IACvB,OAAO,EAAE,GAAG,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,OAAO,EAAE,OAAO,CAAC;IACjB,qDAAqD;IACrD,GAAG,EAAE,MAAM,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAC3D;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/context-helpers/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Interface for additional context that can be added to messages\n */\nexport interface AdditionalContext {\n /** The name of the context type */\n name: string;\n /** The context data */\n context: any;\n}\n\n/**\n * Interface for a context helper that can generate additional context\n */\nexport interface AdditionalContextHelper {\n /** The name of the context helper */\n name: string;\n /** Whether this helper is enabled */\n enabled: boolean;\n /** Function that generates the additional context */\n run: () => AdditionalContext | Promise<AdditionalContext>;\n}\n\n/**\n * Configuration for context helpers\n */\nexport interface ContextHelpersConfig {\n /** Enable/disable user time context helper */\n userTime?: boolean;\n /** Enable/disable user page context helper */\n userPage?: boolean;\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context helper that provides the user's current time and timezone
|
|
3
|
+
* @returns Additional context with user's time information
|
|
4
|
+
*/
|
|
5
|
+
export function getUserTimeContext() {
|
|
6
|
+
const now = new Date();
|
|
7
|
+
return {
|
|
8
|
+
name: "userTime",
|
|
9
|
+
context: {
|
|
10
|
+
localTime: now.toLocaleString(),
|
|
11
|
+
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
12
|
+
timestamp: now.toISOString(),
|
|
13
|
+
offsetMinutes: now.getTimezoneOffset(),
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=user-time.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-time.js","sourceRoot":"","sources":["../../src/context-helpers/user-time.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,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"]}
|
package/esm/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { useTamboStreamingProps } from "./hooks/use-streaming-props";
|
|
|
5
5
|
export * from "./hooks/use-suggestions";
|
|
6
6
|
export { useTamboStreamStatus, type PropStatus, type StreamStatus, } from "./hooks/use-tambo-stream-status";
|
|
7
7
|
export { useTamboThreadInput } from "./hooks/use-thread-input";
|
|
8
|
-
export { TamboClientProvider, TamboComponentProvider, TamboPropStreamProvider, TamboProvider, TamboStubProvider, TamboThreadProvider, useTambo, useTamboClient, useTamboStream, useTamboThread, type TamboComponent, type TamboRegistryContext, type TamboStubProviderProps, } from "./providers";
|
|
8
|
+
export { TamboClientProvider, TamboComponentProvider, TamboContextHelpersProvider, TamboPropStreamProvider, TamboProvider, TamboStubProvider, TamboThreadProvider, useTambo, useTamboClient, useTamboContextHelpers, useTamboStream, useTamboThread, type TamboComponent, type TamboContextHelpersContextProps, type TamboContextHelpersProviderProps, type TamboRegistryContext, type TamboStubProviderProps, } from "./providers";
|
|
9
9
|
export type { APIError, RateLimitError, TamboAIError, } from "@tambo-ai/typescript-sdk";
|
|
10
10
|
export type { Suggestion, SuggestionGenerateParams, SuggestionGenerateResponse, SuggestionListResponse, } from "@tambo-ai/typescript-sdk/resources/beta/threads/suggestions";
|
|
11
11
|
export { useTamboThreadList } from "./hooks/use-tambo-threads";
|
|
@@ -15,4 +15,6 @@ export { type TamboThread } from "./model/tambo-thread";
|
|
|
15
15
|
export type { TamboInteractableComponent as InteractableComponent, TamboInteractableContext, } from "./model/tambo-interactable";
|
|
16
16
|
export { withTamboInteractable as withInteractable, type InteractableConfig, type WithTamboInteractableProps, } from "./providers/hoc/with-tambo-interactable";
|
|
17
17
|
export { useTamboInteractable } from "./providers/tambo-interactable-provider";
|
|
18
|
+
export { DEFAULT_CONTEXT_HELPERS, getUserPageContext, getUserTimeContext, } from "./context-helpers";
|
|
19
|
+
export type { AdditionalContext, AdditionalContextHelper, ContextHelpersConfig, } from "./context-helpers";
|
|
18
20
|
//# sourceMappingURL=index.d.ts.map
|
package/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wKAAwK;AAExK,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,cAAc,yBAAyB,CAAC;AACxC,OAAO,EACL,oBAAoB,EACpB,KAAK,UAAU,EACf,KAAK,YAAY,GAClB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAG/D,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACnB,QAAQ,EACR,cAAc,EACd,cAAc,EACd,cAAc,EACd,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,GAC5B,MAAM,aAAa,CAAC;AAGrB,YAAY,EACV,QAAQ,EACR,cAAc,EACd,YAAY,GACb,MAAM,0BAA0B,CAAC;AAClC,YAAY,EACV,UAAU,EACV,wBAAwB,EACxB,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,6DAA6D,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EACL,KAAK,4BAA4B,EACjC,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,m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