@tambo-ai/react 1.2.6 → 1.2.8

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 (41) hide show
  1. package/dist/hooks/use-tambo-voice.test.js.map +1 -1
  2. package/dist/mcp/elicitation.test.js +1 -1
  3. package/dist/mcp/elicitation.test.js.map +1 -1
  4. package/dist/mcp/mcp-hooks.test.js.map +1 -1
  5. package/dist/mcp/tambo-mcp-provider.test.js +1 -1
  6. package/dist/mcp/tambo-mcp-provider.test.js.map +1 -1
  7. package/dist/providers/hooks/use-tambo-session-token.test.js.map +1 -1
  8. package/dist/providers/tambo-client-provider.test.js.map +1 -1
  9. package/dist/providers/tambo-context-helpers-provider.js.map +1 -1
  10. package/dist/providers/tambo-interactable-provider.d.ts.map +1 -1
  11. package/dist/providers/tambo-interactable-provider.js +15 -16
  12. package/dist/providers/tambo-interactable-provider.js.map +1 -1
  13. package/dist/providers/tambo-interactables-additional-context.test.js.map +1 -1
  14. package/dist/schema/schema.test.js.map +1 -1
  15. package/dist/util/registry.test.js.map +1 -1
  16. package/dist/util/tool-caller.test.js.map +1 -1
  17. package/dist/v1/hooks/use-tambo-v1-component-state.js.map +1 -1
  18. package/dist/v1/hooks/use-tambo-v1-component-state.test.js.map +1 -1
  19. package/dist/v1/hooks/use-tambo-v1-send-message.js.map +1 -1
  20. package/dist/v1/hooks/use-tambo-v1.test.js.map +1 -1
  21. package/esm/hooks/use-tambo-voice.test.js.map +1 -1
  22. package/esm/mcp/elicitation.test.js +1 -1
  23. package/esm/mcp/elicitation.test.js.map +1 -1
  24. package/esm/mcp/mcp-hooks.test.js.map +1 -1
  25. package/esm/mcp/tambo-mcp-provider.test.js +1 -1
  26. package/esm/mcp/tambo-mcp-provider.test.js.map +1 -1
  27. package/esm/providers/hooks/use-tambo-session-token.test.js.map +1 -1
  28. package/esm/providers/tambo-client-provider.test.js.map +1 -1
  29. package/esm/providers/tambo-context-helpers-provider.js.map +1 -1
  30. package/esm/providers/tambo-interactable-provider.d.ts.map +1 -1
  31. package/esm/providers/tambo-interactable-provider.js +16 -17
  32. package/esm/providers/tambo-interactable-provider.js.map +1 -1
  33. package/esm/providers/tambo-interactables-additional-context.test.js.map +1 -1
  34. package/esm/schema/schema.test.js.map +1 -1
  35. package/esm/util/registry.test.js.map +1 -1
  36. package/esm/util/tool-caller.test.js.map +1 -1
  37. package/esm/v1/hooks/use-tambo-v1-component-state.js.map +1 -1
  38. package/esm/v1/hooks/use-tambo-v1-component-state.test.js.map +1 -1
  39. package/esm/v1/hooks/use-tambo-v1-send-message.js.map +1 -1
  40. package/esm/v1/hooks/use-tambo-v1.test.js.map +1 -1
  41. package/package.json +10 -10
@@ -1 +1 @@
1
- {"version":3,"file":"use-tambo-v1-send-message.js","sourceRoot":"","sources":["../../../src/v1/hooks/use-tambo-v1-send-message.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;AAyWb,0CA8DC;AA8CD,kDAsQC;AAztBD;;;;GAIG;AAEH,iCAA0C;AAC1C,sCAA4D;AAC5D,6CAG0B;AAG1B,iFAG+C;AAC/C,qEAAiE;AACjE,qFAGiD;AACjD,kFAG8C;AAC9C,sEAAgE;AAChE,uEAA8D;AAC9D,mGAAwF;AACxF,6FAAmF;AAGnF,6CAA4E;AAC5E,6CAA2E;AAC3E,6CAAqD;AACrD,6CAG0B;AAG1B,6CAAmD;AAEnD;;;;;;GAMG;AACH,SAAS,mBAAmB,CAC1B,QAAsC,EACtC,cAAsB,EACtB,SAAiB,EACjB,WAAmB;IAEnB,QAAQ,CAAC;QACP,IAAI,EAAE,OAAO;QACb,QAAQ,EAAE,cAAc;QACxB,KAAK,EAAE;YACL,IAAI,EAAE,gBAAS,CAAC,kBAAkB;YAClC,SAAS;YACT,IAAI,EAAE,MAAe;SACtB;KACF,CAAC,CAAC;IAEH,QAAQ,CAAC;QACP,IAAI,EAAE,OAAO;QACb,QAAQ,EAAE,cAAc;QACxB,KAAK,EAAE;YACL,IAAI,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AAc;qBACzB,CAAC,CAAC;gBACL,CAAC;gBACD,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;QACD,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;YAC1B,MAAM,WAAW,CAAC,iBAAiB,CAAC;gBAClC,QAAQ,EAAE,CAAC,YAAY,EAAE,MAAM,CAAC,QAAQ,CAAC;aAC1C,CAAC,CAAC;YAEH,IACE,sBAAsB;gBACtB,wBAAwB,CACtB,MAAM,CAAC,QAAQ,EACf,MAAM,CAAC,oBAAoB,EAC3B,MAAM,CAAC,uBAAuB,EAC9B,yBAAyB,CAC1B,EACD,CAAC;gBACD,MAAM,kBAAkB,CACtB,MAAM,EACN,QAAQ,EACR,WAAW,EACX,MAAM,CAAC,QAAQ,CAChB,CAAC;YACJ,CAAC;QACH,CAAC;QACD,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YACjB,OAAO,CAAC,KAAK,CAAC,wCAAwC,EAAE,KAAK,CAAC,CAAC;QACjE,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["\"use client\";\n\n/**\n * Send Message Hook\n *\n * React Query mutation hook for sending messages and handling streaming responses.\n */\n\nimport React, { useContext } from \"react\";\nimport { EventType, type RunErrorEvent } from \"@ag-ui/core\";\nimport {\n asTamboCustomEvent,\n type RunAwaitingInputEvent,\n} from \"@tambo-ai/client\";\nimport type TamboAI from \"@tambo-ai/typescript-sdk\";\nimport type { Stream } from \"@tambo-ai/typescript-sdk/core/streaming\";\nimport {\n useTamboClient,\n useTamboQueryClient,\n} from \"../../providers/tambo-client-provider\";\nimport { useTamboMutation } from \"../../hooks/react-query-hooks\";\nimport {\n TamboRegistryContext,\n type TamboRegistryContext as TamboRegistry,\n} from \"../../providers/tambo-registry-provider\";\nimport {\n useStreamDispatch,\n useStreamState,\n} from \"../providers/tambo-v1-stream-context\";\nimport { useTamboConfig } from \"../providers/tambo-v1-provider\";\nimport { useTamboAuthState } from \"./use-tambo-v1-auth-state\";\nimport { useTamboContextHelpers } from \"../../providers/tambo-context-helpers-provider\";\nimport { useTamboInteractable } from \"../../providers/tambo-interactable-provider\";\nimport type { InitialInputMessage, InputMessage } from \"../types/message\";\nimport type { ToolChoice } from \"@tambo-ai/client\";\nimport { isPlaceholderThreadId, type StreamAction } from \"@tambo-ai/client\";\nimport { toAvailableComponents, toAvailableTools } from \"@tambo-ai/client\";\nimport { handleEventStream } from \"@tambo-ai/client\";\nimport {\n executeAllPendingTools,\n createThrottledStreamableExecutor,\n} from \"@tambo-ai/client\";\nimport type { ToolResultContent } from \"@tambo-ai/typescript-sdk/resources/threads/threads\";\nimport type { RunCreateParams } from \"@tambo-ai/typescript-sdk/resources/threads/runs\";\nimport { ToolCallTracker } from \"@tambo-ai/client\";\n\n/**\n * Dispatches synthetic AG-UI events to show a user message in the thread.\n * @param dispatch - Stream state dispatcher\n * @param targetThreadId - Thread to add the message to\n * @param messageId - Stable ID for the user message\n * @param messageText - Text content of the message\n */\nfunction dispatchUserMessage(\n dispatch: React.Dispatch<StreamAction>,\n targetThreadId: string,\n messageId: string,\n messageText: string,\n): void {\n dispatch({\n type: \"EVENT\",\n threadId: targetThreadId,\n event: {\n type: EventType.TEXT_MESSAGE_START,\n messageId,\n role: \"user\" as const,\n },\n });\n\n dispatch({\n type: \"EVENT\",\n threadId: targetThreadId,\n event: {\n type: EventType.TEXT_MESSAGE_CONTENT,\n messageId,\n delta: messageText,\n },\n });\n\n dispatch({\n type: \"EVENT\",\n threadId: targetThreadId,\n event: {\n type: EventType.TEXT_MESSAGE_END,\n messageId,\n },\n });\n}\n\n/**\n * Dispatches synthetic events for tool results as optimistic local state.\n * The server doesn't echo these back for client-side tools.\n * @param dispatch - Stream state dispatcher\n * @param targetThreadId - Thread to add results to\n * @param toolResults - Tool execution results to dispatch\n */\nfunction dispatchToolResults(\n dispatch: React.Dispatch<StreamAction>,\n targetThreadId: string,\n toolResults: ToolResultContent[],\n): void {\n if (toolResults.length === 0) return;\n\n const toolResultMessageId = `msg_tool_result_${Date.now()}`;\n\n dispatch({\n type: \"EVENT\",\n threadId: targetThreadId,\n event: {\n type: EventType.TEXT_MESSAGE_START,\n messageId: toolResultMessageId,\n role: \"user\" as const,\n },\n });\n\n for (const result of toolResults) {\n dispatch({\n type: \"EVENT\",\n threadId: targetThreadId,\n event: {\n type: EventType.TOOL_CALL_RESULT,\n toolCallId: result.toolUseId,\n messageId: toolResultMessageId,\n content:\n result.content\n .filter((c) => c.type === \"text\")\n .map((c) => (c as { type: \"text\"; text: string }).text)\n .join(\"\") || JSON.stringify(result.content),\n },\n });\n }\n\n dispatch({\n type: \"EVENT\",\n threadId: targetThreadId,\n event: {\n type: EventType.TEXT_MESSAGE_END,\n messageId: toolResultMessageId,\n },\n });\n}\n\n/**\n * Checks whether a thread name should be auto-generated based on config\n * and the current thread state.\n * @param threadId - The thread ID (undefined or placeholder means no)\n * @param threadAlreadyHasName - Whether the thread already has a name\n * @param preMutationMessageCount - Message count before the current mutation\n * @param autoGenerateNameThreshold - Minimum message count to trigger generation\n * @returns Whether to generate a thread name\n */\nfunction shouldGenerateThreadName(\n threadId: string | undefined,\n threadAlreadyHasName: boolean,\n preMutationMessageCount: number,\n autoGenerateNameThreshold: number,\n): threadId is string {\n return (\n !threadAlreadyHasName &&\n !!threadId &&\n !isPlaceholderThreadId(threadId) &&\n // +2 accounts for the user message and assistant response just added\n preMutationMessageCount + 2 >= autoGenerateNameThreshold\n );\n}\n\n/**\n * Generates a thread name via the beta API, dispatches the name update,\n * and invalidates the thread list cache. Errors are logged, never thrown.\n * @param client - The Tambo API client\n * @param dispatch - Stream state dispatcher\n * @param queryClient - React Query client for cache invalidation\n * @param threadId - The thread to generate a name for\n */\nasync function generateThreadName(\n client: TamboAI,\n dispatch: React.Dispatch<StreamAction>,\n queryClient: ReturnType<typeof useTamboQueryClient>,\n threadId: string,\n): Promise<void> {\n try {\n const threadWithName = await client.beta.threads.generateName(threadId);\n if (threadWithName.name) {\n dispatch({\n type: \"UPDATE_THREAD_NAME\",\n threadId,\n name: threadWithName.name,\n });\n await queryClient.invalidateQueries({\n queryKey: [\"v1-threads\", \"list\"],\n });\n }\n } catch (error) {\n console.error(\n \"[useTamboSendMessage] Failed to auto-generate thread name:\",\n error,\n );\n }\n}\n\n/**\n * Options for sending a message\n */\nexport interface SendMessageOptions {\n /**\n * The message to send\n */\n message: InputMessage;\n\n /**\n * User message text for optimistic display.\n * If provided, synthetic AG-UI events will be dispatched to show\n * the user message in the thread immediately after getting the threadId.\n */\n userMessageText?: string;\n\n /**\n * Enable debug logging for the stream\n */\n debug?: boolean;\n\n /**\n * How the model should use tools. Defaults to \"auto\".\n * - \"auto\": Model decides whether to use tools\n * - \"required\": Model must use at least one tool\n * - \"none\": Model cannot use tools\n * - { name: \"toolName\" }: Model must use the specified tool\n */\n toolChoice?: ToolChoice;\n}\n\n/**\n * Parameters for creating a run stream\n */\nexport interface CreateRunStreamParams {\n client: TamboAI;\n threadId: string | undefined;\n message: InputMessage;\n registry: TamboRegistry;\n userKey: string | undefined;\n /**\n * Previous run ID for continuing a thread with existing messages.\n * Required when threadId is provided and the thread has previous runs.\n */\n previousRunId: string | undefined;\n /**\n * Additional context gathered from context helpers (including interactables).\n * Merged into the message's additionalContext before sending.\n */\n additionalContext?: Record<string, unknown>;\n /**\n * How the model should use tools.\n */\n toolChoice?: ToolChoice;\n /**\n * Initial messages to seed the thread with when creating a new thread.\n * Only used when threadId is undefined (new thread creation).\n */\n initialMessages?: InitialInputMessage[];\n}\n\n/**\n * Stream types from the SDK\n */\ntype RunStream = Stream<TamboAI.Threads.Runs.RunRunResponse>;\ntype CreateStream = Stream<TamboAI.Threads.Runs.RunCreateResponse>;\n\n/**\n * Result from creating a run stream\n */\nexport interface CreateRunStreamResult {\n stream: RunStream | CreateStream;\n initialThreadId: string | undefined;\n}\n\n/**\n * Parameters for executing tools and continuing the run\n */\ninterface ExecuteToolsParams {\n event: RunAwaitingInputEvent;\n toolTracker: ToolCallTracker;\n registry: TamboRegistry;\n client: TamboAI;\n threadId: string;\n runId: string;\n userKey: string | undefined;\n additionalContext?: Record<string, unknown>;\n toolChoice?: ToolChoice;\n}\n\n/**\n * Result from executing tools and continuing the run\n */\ninterface ExecuteToolsResult {\n stream: RunStream;\n toolResults: ToolResultContent[];\n}\n\n/**\n * Executes pending tools and returns a continuation stream.\n *\n * This function does NOT process the continuation stream - it just executes\n * the tools and returns the new stream for the caller to process. This enables\n * the flat loop pattern that correctly handles multi-round tool execution.\n * @param params - The parameters for tool execution\n * @returns The continuation stream and tool results for optimistic local state updates\n */\nasync function executeToolsAndContinue(\n params: ExecuteToolsParams,\n): Promise<ExecuteToolsResult> {\n const {\n event,\n toolTracker,\n registry,\n client,\n threadId,\n runId,\n userKey,\n additionalContext,\n toolChoice,\n } = params;\n\n const pendingToolCallIds = event.value.pendingToolCalls.map(\n (tc) => tc.toolCallId,\n );\n const toolCallsToExecute = toolTracker.getToolCallsById(pendingToolCallIds);\n\n // Execute tools\n const toolResults = await executeAllPendingTools(\n toolCallsToExecute,\n registry.toolRegistry,\n );\n\n // Clear executed tool calls before continuing\n toolTracker.clearToolCalls(pendingToolCallIds);\n\n // Return the continuation stream and tool results\n const stream = await client.threads.runs.run(threadId, {\n message: {\n role: \"user\",\n content: toolResults,\n additionalContext,\n },\n previousRunId: runId,\n availableComponents: toAvailableComponents(registry.componentList),\n tools: toAvailableTools(registry.toolRegistry),\n userKey,\n toolChoice,\n });\n\n return { stream, toolResults };\n}\n\n/**\n * Creates a run stream by calling the appropriate API method.\n *\n * If threadId is provided, runs on existing thread via client.threads.runs.run().\n * If no threadId, creates new thread via client.threads.runs.create().\n * @param params - The parameters for creating the run stream\n * @returns The stream and initial thread ID (undefined if creating new thread)\n */\nexport async function createRunStream(\n params: CreateRunStreamParams,\n): Promise<CreateRunStreamResult> {\n const {\n client,\n threadId,\n message,\n registry,\n userKey,\n previousRunId,\n additionalContext,\n toolChoice,\n initialMessages,\n } = params;\n\n // Merge helper context with any caller-provided additionalContext on the message\n const mergedContext =\n additionalContext || message.additionalContext\n ? {\n ...((message.additionalContext as Record<string, unknown>) ?? {}),\n ...additionalContext,\n }\n : undefined;\n const messageWithContext: InputMessage = mergedContext\n ? { ...message, additionalContext: mergedContext }\n : message;\n\n // Convert registry components/tools to API format\n const availableComponents = toAvailableComponents(registry.componentList);\n const availableTools = toAvailableTools(registry.toolRegistry);\n\n if (threadId) {\n // Run on existing thread\n const stream = await client.threads.runs.run(threadId, {\n message: messageWithContext,\n availableComponents,\n tools: availableTools,\n userKey,\n previousRunId,\n toolChoice,\n });\n return { stream, initialThreadId: threadId };\n } else {\n // Create new thread - include initialMessages if provided\n const threadConfig: RunCreateParams.Thread = {};\n if (userKey) {\n threadConfig.userKey = userKey;\n }\n if (initialMessages?.length) {\n threadConfig.initialMessages = initialMessages;\n }\n\n const stream = await client.threads.runs.create({\n message: messageWithContext,\n availableComponents,\n tools: availableTools,\n thread: Object.keys(threadConfig).length > 0 ? threadConfig : undefined,\n toolChoice,\n });\n // threadId will be extracted from first event (RUN_STARTED)\n return { stream, initialThreadId: undefined };\n }\n}\n\n/**\n * Hook to send a message and handle streaming responses.\n *\n * This hook handles two scenarios:\n * - If threadId provided: runs on existing thread via client.threads.runs.run()\n * - If no threadId: creates new thread via client.threads.runs.create()\n *\n * The hook:\n * - Sends a user message to the API\n * - Streams AG-UI events in real-time\n * - Dispatches events to the stream reducer\n * - Extracts threadId from events when creating new thread\n * - Handles tool execution (Phase 6)\n * - Invalidates thread queries on completion\n * @param threadId - Optional thread ID to send message to. If not provided, creates new thread\n * @returns React Query mutation object with threadId in mutation result\n * @example\n * ```tsx\n * function ChatInput({ threadId }: { threadId?: string }) {\n * const sendMessage = useTamboSendMessage(threadId);\n *\n * const handleSubmit = async (text: string) => {\n * const result = await sendMessage.mutateAsync({\n * message: {\n * role: \"user\",\n * content: [{ type: \"text\", text }],\n * },\n * });\n *\n * // If threadId wasn't provided, a new thread was created\n * if (!threadId) {\n * console.log(\"Created thread:\", result.threadId);\n * }\n * };\n *\n * return (\n * <div>\n * <input onSubmit={handleSubmit} />\n * {sendMessage.isPending && <Spinner />}\n * </div>\n * );\n * }\n * ```\n */\nexport function useTamboSendMessage(threadId?: string) {\n const client = useTamboClient();\n const dispatch = useStreamDispatch();\n const streamState = useStreamState();\n const {\n userKey,\n autoGenerateThreadName = true,\n autoGenerateNameThreshold = 3,\n initialMessages,\n } = useTamboConfig();\n const registry = useContext(TamboRegistryContext);\n const queryClient = useTamboQueryClient();\n const { getAdditionalContext } = useTamboContextHelpers();\n const { clearInteractableSelections } = useTamboInteractable();\n const authState = useTamboAuthState();\n\n if (!registry) {\n throw new Error(\n \"useTamboSendMessage must be used within TamboRegistryProvider\",\n );\n }\n\n // Placeholder ID isn't a valid API thread ID - treat as new thread creation\n const isNewThread = isPlaceholderThreadId(threadId);\n const apiThreadId = isNewThread ? undefined : threadId;\n\n // Get previousRunId from the thread's streaming state (active run) or\n // lastCompletedRunId (persisted after run finishes / loaded from API).\n // The latter is essential after page reload when streaming state is gone.\n const threadState = apiThreadId\n ? streamState.threadMap[apiThreadId]\n : undefined;\n const previousRunId =\n threadState?.streaming.runId ?? threadState?.lastCompletedRunId;\n\n return useTamboMutation({\n mutationFn: async (options: SendMessageOptions) => {\n if (authState.status !== \"identified\") {\n const messages: Record<string, string> = {\n unauthenticated:\n \"Cannot send message: no userKey or userToken provided. \" +\n \"Configure authentication in TamboProvider.\",\n exchanging:\n \"Cannot send message: token exchange is still in progress. \" +\n \"Wait for authentication to complete.\",\n error:\n \"Cannot send message: token exchange failed. \" +\n \"Check your userToken configuration.\",\n invalid:\n \"Cannot send message: both userKey and userToken were provided. \" +\n \"You must provide one or the other, not both.\",\n };\n throw new Error(messages[authState.status]);\n }\n\n const { message, userMessageText, debug = false, toolChoice } = options;\n\n // Capture pre-mutation state for auto thread name generation\n const existingThread = streamState.threadMap[apiThreadId ?? \"\"];\n const preMutationMessageCount =\n existingThread?.thread.messages.length ?? 0;\n const threadAlreadyHasName = !!existingThread?.thread.name;\n\n const toolTracker = new ToolCallTracker(registry.toolRegistry);\n const throttledStreamable = createThrottledStreamableExecutor(\n toolTracker,\n registry.toolRegistry,\n );\n\n // Generate a stable message ID for the user message\n const userMessageId = userMessageText\n ? `user_msg_${Date.now()}_${Math.random().toString(36).slice(2, 9)}`\n : undefined;\n\n // Add user message immediately for instant feedback\n // Use threadId (which could be temp_xxx for new threads) for display\n if (threadId && userMessageText && userMessageId) {\n dispatchUserMessage(dispatch, threadId, userMessageId, userMessageText);\n }\n\n // Gather additional context from all registered context helpers.\n // TODO: This snapshot is captured once and reused for the entire multi-round\n // tool loop. If interactables change during streaming (e.g. user interactions),\n // continuations will send stale context. Re-gather before each continuation\n // if freshness matters.\n const helperContexts = await getAdditionalContext();\n const additionalContext: Record<string, unknown> = {};\n for (const helperContext of helperContexts) {\n additionalContext[helperContext.name] = helperContext.context;\n }\n\n // Clear interactable selections after capturing context so they only\n // apply to this single message send.\n clearInteractableSelections();\n\n // Create the run stream\n // Include initialMessages only on first send (new thread creation)\n const { stream, initialThreadId } = await createRunStream({\n client,\n threadId: apiThreadId,\n message,\n registry,\n userKey,\n previousRunId,\n additionalContext,\n toolChoice,\n initialMessages: isNewThread ? initialMessages : undefined,\n });\n\n let actualThreadId = initialThreadId;\n let runId: string | undefined;\n let currentStream: CreateRunStreamResult[\"stream\"] = stream;\n\n try {\n // Outer loop handles stream replacement for multi-round tool execution.\n // When we hit awaiting_input, we execute tools, get a new stream, and continue.\n // This flat loop pattern correctly handles tool→AI→tool→AI chains.\n while (true) {\n let pendingAwaitingInput: RunAwaitingInputEvent | undefined;\n\n // Process current stream until completion or awaiting_input\n for await (const event of handleEventStream(currentStream, {\n debug,\n })) {\n // Extract threadId and runId from RUN_STARTED event\n if (event.type === EventType.RUN_STARTED) {\n runId = event.runId;\n actualThreadId ??= event.threadId;\n\n // For threads with no ID at all: add user message now that we have the real threadId\n // Note: temp thread migration (temp_xxx -> real ID) is handled automatically\n // by the reducer when it sees RUN_STARTED with a different threadId\n if (!threadId && userMessageText && userMessageId) {\n dispatchUserMessage(\n dispatch,\n actualThreadId,\n userMessageId,\n userMessageText,\n );\n }\n } else if (!actualThreadId) {\n throw new Error(\n `Expected first event to be RUN_STARTED with threadId, got: ${event.type}`,\n );\n }\n\n toolTracker.handleEvent(event);\n\n // Parse partial JSON once for TOOL_CALL_ARGS — reused by both dispatch and streamable execution\n const parsedToolArgs =\n event.type === EventType.TOOL_CALL_ARGS\n ? toolTracker.parsePartialArgs(event.toolCallId)\n : undefined;\n\n dispatch({\n type: \"EVENT\",\n event,\n threadId: actualThreadId,\n parsedToolArgs,\n toolSchemas: toolTracker.toolSchemas,\n });\n\n // Schedule debounced streamable tool execution with the same pre-parsed args\n if (parsedToolArgs && event.type === EventType.TOOL_CALL_ARGS) {\n throttledStreamable.schedule(event.toolCallId, parsedToolArgs);\n }\n\n // Handle custom events\n if (event.type === EventType.CUSTOM) {\n const customEvent = asTamboCustomEvent(event);\n\n if (customEvent?.name === \"tambo.run.awaiting_input\") {\n pendingAwaitingInput = customEvent;\n break; // Exit stream loop to handle tool execution\n }\n }\n }\n\n // Flush any pending debounced streamable calls before continuing\n throttledStreamable.flush();\n\n // If stream finished without awaiting_input, we're done\n if (!pendingAwaitingInput) {\n break;\n }\n\n // Execute tools and get continuation stream\n // These checks should never fail since awaiting_input comes after RUN_STARTED\n if (!runId || !actualThreadId) {\n throw new Error(\n \"Cannot continue run after awaiting_input: missing runId or threadId\",\n );\n }\n\n const { stream: continuationStream, toolResults } =\n await executeToolsAndContinue({\n event: pendingAwaitingInput,\n toolTracker,\n registry,\n client,\n threadId: actualThreadId,\n runId,\n userKey,\n additionalContext,\n toolChoice,\n });\n\n dispatchToolResults(dispatch, actualThreadId, toolResults);\n\n currentStream = continuationStream;\n }\n\n return {\n threadId: actualThreadId,\n preMutationMessageCount,\n threadAlreadyHasName,\n };\n } catch (error) {\n // Dispatch a synthetic RUN_ERROR event to clean up thread state\n // This ensures the thread doesn't stay stuck in \"streaming\" status\n if (actualThreadId) {\n const errorMessage =\n error instanceof Error ? error.message : \"Unknown streaming error\";\n const errorEvent: RunErrorEvent = {\n type: EventType.RUN_ERROR,\n message: errorMessage,\n };\n dispatch({\n type: \"EVENT\",\n event: errorEvent,\n threadId: actualThreadId,\n });\n }\n throw error;\n }\n },\n onSuccess: async (result) => {\n await queryClient.invalidateQueries({\n queryKey: [\"v1-threads\", result.threadId],\n });\n\n if (\n autoGenerateThreadName &&\n shouldGenerateThreadName(\n result.threadId,\n result.threadAlreadyHasName,\n result.preMutationMessageCount,\n autoGenerateNameThreshold,\n )\n ) {\n await generateThreadName(\n client,\n dispatch,\n queryClient,\n result.threadId,\n );\n }\n },\n onError: (error) => {\n console.error(\"[useTamboSendMessage] Mutation failed:\", error);\n },\n });\n}\n"]}
1
+ {"version":3,"file":"use-tambo-v1-send-message.js","sourceRoot":"","sources":["../../../src/v1/hooks/use-tambo-v1-send-message.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;AAyWb,0CA8DC;AA8CD,kDAsQC;AAztBD;;;;GAIG;AAEH,iCAA0C;AAC1C,sCAA4D;AAC5D,6CAG0B;AAG1B,iFAG+C;AAC/C,qEAAiE;AACjE,qFAGiD;AACjD,kFAG8C;AAC9C,sEAAgE;AAChE,uEAA8D;AAC9D,mGAAwF;AACxF,6FAAmF;AAGnF,6CAA4E;AAC5E,6CAA2E;AAC3E,6CAAqD;AACrD,6CAG0B;AAG1B,6CAAmD;AAEnD;;;;;;GAMG;AACH,SAAS,mBAAmB,CAC1B,QAAsC,EACtC,cAAsB,EACtB,SAAiB,EACjB,WAAmB;IAEnB,QAAQ,CAAC;QACP,IAAI,EAAE,OAAO;QACb,QAAQ,EAAE,cAAc;QACxB,KAAK,EAAE;YACL,IAAI,EAAE,gBAAS,CAAC,kBAAkB;YAClC,SAAS;YACT,IAAI,EAAE,MAAe;SACtB;KACF,CAAC,CAAC;IAEH,QAAQ,CAAC;QACP,IAAI,EAAE,OAAO;QACb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O;wBACb,KAAK,EAAE,UAAU;wBACjB,QAAQ,EAAE,cAAc;qBACzB,CAAC,CAAC;gBACL,CAAC;gBACD,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;QACD,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;YAC1B,MAAM,WAAW,CAAC,iBAAiB,CAAC;gBAClC,QAAQ,EAAE,CAAC,YAAY,EAAE,MAAM,CAAC,QAAQ,CAAC;aAC1C,CAAC,CAAC;YAEH,IACE,sBAAsB;gBACtB,wBAAwB,CACtB,MAAM,CAAC,QAAQ,EACf,MAAM,CAAC,oBAAoB,EAC3B,MAAM,CAAC,uBAAuB,EAC9B,yBAAyB,CAC1B,EACD,CAAC;gBACD,MAAM,kBAAkB,CACtB,MAAM,EACN,QAAQ,EACR,WAAW,EACX,MAAM,CAAC,QAAQ,CAChB,CAAC;YACJ,CAAC;QACH,CAAC;QACD,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YACjB,OAAO,CAAC,KAAK,CAAC,wCAAwC,EAAE,KAAK,CAAC,CAAC;QACjE,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["\"use client\";\n\n/**\n * Send Message Hook\n *\n * React Query mutation hook for sending messages and handling streaming responses.\n */\n\nimport React, { useContext } from \"react\";\nimport { EventType, type RunErrorEvent } from \"@ag-ui/core\";\nimport {\n asTamboCustomEvent,\n type RunAwaitingInputEvent,\n} from \"@tambo-ai/client\";\nimport type TamboAI from \"@tambo-ai/typescript-sdk\";\nimport type { Stream } from \"@tambo-ai/typescript-sdk/core/streaming\";\nimport {\n useTamboClient,\n useTamboQueryClient,\n} from \"../../providers/tambo-client-provider\";\nimport { useTamboMutation } from \"../../hooks/react-query-hooks\";\nimport {\n TamboRegistryContext,\n type TamboRegistryContext as TamboRegistry,\n} from \"../../providers/tambo-registry-provider\";\nimport {\n useStreamDispatch,\n useStreamState,\n} from \"../providers/tambo-v1-stream-context\";\nimport { useTamboConfig } from \"../providers/tambo-v1-provider\";\nimport { useTamboAuthState } from \"./use-tambo-v1-auth-state\";\nimport { useTamboContextHelpers } from \"../../providers/tambo-context-helpers-provider\";\nimport { useTamboInteractable } from \"../../providers/tambo-interactable-provider\";\nimport type { InitialInputMessage, InputMessage } from \"../types/message\";\nimport type { ToolChoice } from \"@tambo-ai/client\";\nimport { isPlaceholderThreadId, type StreamAction } from \"@tambo-ai/client\";\nimport { toAvailableComponents, toAvailableTools } from \"@tambo-ai/client\";\nimport { handleEventStream } from \"@tambo-ai/client\";\nimport {\n executeAllPendingTools,\n createThrottledStreamableExecutor,\n} from \"@tambo-ai/client\";\nimport type { ToolResultContent } from \"@tambo-ai/typescript-sdk/resources/threads/threads\";\nimport type { RunCreateParams } from \"@tambo-ai/typescript-sdk/resources/threads/runs\";\nimport { ToolCallTracker } from \"@tambo-ai/client\";\n\n/**\n * Dispatches synthetic AG-UI events to show a user message in the thread.\n * @param dispatch - Stream state dispatcher\n * @param targetThreadId - Thread to add the message to\n * @param messageId - Stable ID for the user message\n * @param messageText - Text content of the message\n */\nfunction dispatchUserMessage(\n dispatch: React.Dispatch<StreamAction>,\n targetThreadId: string,\n messageId: string,\n messageText: string,\n): void {\n dispatch({\n type: \"EVENT\",\n threadId: targetThreadId,\n event: {\n type: EventType.TEXT_MESSAGE_START,\n messageId,\n role: \"user\" as const,\n },\n });\n\n dispatch({\n type: \"EVENT\",\n threadId: targetThreadId,\n event: {\n type: EventType.TEXT_MESSAGE_CONTENT,\n messageId,\n delta: messageText,\n },\n });\n\n dispatch({\n type: \"EVENT\",\n threadId: targetThreadId,\n event: {\n type: EventType.TEXT_MESSAGE_END,\n messageId,\n },\n });\n}\n\n/**\n * Dispatches synthetic events for tool results as optimistic local state.\n * The server doesn't echo these back for client-side tools.\n * @param dispatch - Stream state dispatcher\n * @param targetThreadId - Thread to add results to\n * @param toolResults - Tool execution results to dispatch\n */\nfunction dispatchToolResults(\n dispatch: React.Dispatch<StreamAction>,\n targetThreadId: string,\n toolResults: ToolResultContent[],\n): void {\n if (toolResults.length === 0) return;\n\n const toolResultMessageId = `msg_tool_result_${Date.now()}`;\n\n dispatch({\n type: \"EVENT\",\n threadId: targetThreadId,\n event: {\n type: EventType.TEXT_MESSAGE_START,\n messageId: toolResultMessageId,\n role: \"user\" as const,\n },\n });\n\n for (const result of toolResults) {\n dispatch({\n type: \"EVENT\",\n threadId: targetThreadId,\n event: {\n type: EventType.TOOL_CALL_RESULT,\n toolCallId: result.toolUseId,\n messageId: toolResultMessageId,\n content:\n result.content\n .filter((c) => c.type === \"text\")\n .map((c) => c.text)\n .join(\"\") || JSON.stringify(result.content),\n },\n });\n }\n\n dispatch({\n type: \"EVENT\",\n threadId: targetThreadId,\n event: {\n type: EventType.TEXT_MESSAGE_END,\n messageId: toolResultMessageId,\n },\n });\n}\n\n/**\n * Checks whether a thread name should be auto-generated based on config\n * and the current thread state.\n * @param threadId - The thread ID (undefined or placeholder means no)\n * @param threadAlreadyHasName - Whether the thread already has a name\n * @param preMutationMessageCount - Message count before the current mutation\n * @param autoGenerateNameThreshold - Minimum message count to trigger generation\n * @returns Whether to generate a thread name\n */\nfunction shouldGenerateThreadName(\n threadId: string | undefined,\n threadAlreadyHasName: boolean,\n preMutationMessageCount: number,\n autoGenerateNameThreshold: number,\n): threadId is string {\n return (\n !threadAlreadyHasName &&\n !!threadId &&\n !isPlaceholderThreadId(threadId) &&\n // +2 accounts for the user message and assistant response just added\n preMutationMessageCount + 2 >= autoGenerateNameThreshold\n );\n}\n\n/**\n * Generates a thread name via the beta API, dispatches the name update,\n * and invalidates the thread list cache. Errors are logged, never thrown.\n * @param client - The Tambo API client\n * @param dispatch - Stream state dispatcher\n * @param queryClient - React Query client for cache invalidation\n * @param threadId - The thread to generate a name for\n */\nasync function generateThreadName(\n client: TamboAI,\n dispatch: React.Dispatch<StreamAction>,\n queryClient: ReturnType<typeof useTamboQueryClient>,\n threadId: string,\n): Promise<void> {\n try {\n const threadWithName = await client.beta.threads.generateName(threadId);\n if (threadWithName.name) {\n dispatch({\n type: \"UPDATE_THREAD_NAME\",\n threadId,\n name: threadWithName.name,\n });\n await queryClient.invalidateQueries({\n queryKey: [\"v1-threads\", \"list\"],\n });\n }\n } catch (error) {\n console.error(\n \"[useTamboSendMessage] Failed to auto-generate thread name:\",\n error,\n );\n }\n}\n\n/**\n * Options for sending a message\n */\nexport interface SendMessageOptions {\n /**\n * The message to send\n */\n message: InputMessage;\n\n /**\n * User message text for optimistic display.\n * If provided, synthetic AG-UI events will be dispatched to show\n * the user message in the thread immediately after getting the threadId.\n */\n userMessageText?: string;\n\n /**\n * Enable debug logging for the stream\n */\n debug?: boolean;\n\n /**\n * How the model should use tools. Defaults to \"auto\".\n * - \"auto\": Model decides whether to use tools\n * - \"required\": Model must use at least one tool\n * - \"none\": Model cannot use tools\n * - { name: \"toolName\" }: Model must use the specified tool\n */\n toolChoice?: ToolChoice;\n}\n\n/**\n * Parameters for creating a run stream\n */\nexport interface CreateRunStreamParams {\n client: TamboAI;\n threadId: string | undefined;\n message: InputMessage;\n registry: TamboRegistry;\n userKey: string | undefined;\n /**\n * Previous run ID for continuing a thread with existing messages.\n * Required when threadId is provided and the thread has previous runs.\n */\n previousRunId: string | undefined;\n /**\n * Additional context gathered from context helpers (including interactables).\n * Merged into the message's additionalContext before sending.\n */\n additionalContext?: Record<string, unknown>;\n /**\n * How the model should use tools.\n */\n toolChoice?: ToolChoice;\n /**\n * Initial messages to seed the thread with when creating a new thread.\n * Only used when threadId is undefined (new thread creation).\n */\n initialMessages?: InitialInputMessage[];\n}\n\n/**\n * Stream types from the SDK\n */\ntype RunStream = Stream<TamboAI.Threads.Runs.RunRunResponse>;\ntype CreateStream = Stream<TamboAI.Threads.Runs.RunCreateResponse>;\n\n/**\n * Result from creating a run stream\n */\nexport interface CreateRunStreamResult {\n stream: RunStream | CreateStream;\n initialThreadId: string | undefined;\n}\n\n/**\n * Parameters for executing tools and continuing the run\n */\ninterface ExecuteToolsParams {\n event: RunAwaitingInputEvent;\n toolTracker: ToolCallTracker;\n registry: TamboRegistry;\n client: TamboAI;\n threadId: string;\n runId: string;\n userKey: string | undefined;\n additionalContext?: Record<string, unknown>;\n toolChoice?: ToolChoice;\n}\n\n/**\n * Result from executing tools and continuing the run\n */\ninterface ExecuteToolsResult {\n stream: RunStream;\n toolResults: ToolResultContent[];\n}\n\n/**\n * Executes pending tools and returns a continuation stream.\n *\n * This function does NOT process the continuation stream - it just executes\n * the tools and returns the new stream for the caller to process. This enables\n * the flat loop pattern that correctly handles multi-round tool execution.\n * @param params - The parameters for tool execution\n * @returns The continuation stream and tool results for optimistic local state updates\n */\nasync function executeToolsAndContinue(\n params: ExecuteToolsParams,\n): Promise<ExecuteToolsResult> {\n const {\n event,\n toolTracker,\n registry,\n client,\n threadId,\n runId,\n userKey,\n additionalContext,\n toolChoice,\n } = params;\n\n const pendingToolCallIds = event.value.pendingToolCalls.map(\n (tc) => tc.toolCallId,\n );\n const toolCallsToExecute = toolTracker.getToolCallsById(pendingToolCallIds);\n\n // Execute tools\n const toolResults = await executeAllPendingTools(\n toolCallsToExecute,\n registry.toolRegistry,\n );\n\n // Clear executed tool calls before continuing\n toolTracker.clearToolCalls(pendingToolCallIds);\n\n // Return the continuation stream and tool results\n const stream = await client.threads.runs.run(threadId, {\n message: {\n role: \"user\",\n content: toolResults,\n additionalContext,\n },\n previousRunId: runId,\n availableComponents: toAvailableComponents(registry.componentList),\n tools: toAvailableTools(registry.toolRegistry),\n userKey,\n toolChoice,\n });\n\n return { stream, toolResults };\n}\n\n/**\n * Creates a run stream by calling the appropriate API method.\n *\n * If threadId is provided, runs on existing thread via client.threads.runs.run().\n * If no threadId, creates new thread via client.threads.runs.create().\n * @param params - The parameters for creating the run stream\n * @returns The stream and initial thread ID (undefined if creating new thread)\n */\nexport async function createRunStream(\n params: CreateRunStreamParams,\n): Promise<CreateRunStreamResult> {\n const {\n client,\n threadId,\n message,\n registry,\n userKey,\n previousRunId,\n additionalContext,\n toolChoice,\n initialMessages,\n } = params;\n\n // Merge helper context with any caller-provided additionalContext on the message\n const mergedContext =\n additionalContext || message.additionalContext\n ? {\n ...((message.additionalContext as Record<string, unknown>) ?? {}),\n ...additionalContext,\n }\n : undefined;\n const messageWithContext: InputMessage = mergedContext\n ? { ...message, additionalContext: mergedContext }\n : message;\n\n // Convert registry components/tools to API format\n const availableComponents = toAvailableComponents(registry.componentList);\n const availableTools = toAvailableTools(registry.toolRegistry);\n\n if (threadId) {\n // Run on existing thread\n const stream = await client.threads.runs.run(threadId, {\n message: messageWithContext,\n availableComponents,\n tools: availableTools,\n userKey,\n previousRunId,\n toolChoice,\n });\n return { stream, initialThreadId: threadId };\n } else {\n // Create new thread - include initialMessages if provided\n const threadConfig: RunCreateParams.Thread = {};\n if (userKey) {\n threadConfig.userKey = userKey;\n }\n if (initialMessages?.length) {\n threadConfig.initialMessages = initialMessages;\n }\n\n const stream = await client.threads.runs.create({\n message: messageWithContext,\n availableComponents,\n tools: availableTools,\n thread: Object.keys(threadConfig).length > 0 ? threadConfig : undefined,\n toolChoice,\n });\n // threadId will be extracted from first event (RUN_STARTED)\n return { stream, initialThreadId: undefined };\n }\n}\n\n/**\n * Hook to send a message and handle streaming responses.\n *\n * This hook handles two scenarios:\n * - If threadId provided: runs on existing thread via client.threads.runs.run()\n * - If no threadId: creates new thread via client.threads.runs.create()\n *\n * The hook:\n * - Sends a user message to the API\n * - Streams AG-UI events in real-time\n * - Dispatches events to the stream reducer\n * - Extracts threadId from events when creating new thread\n * - Handles tool execution (Phase 6)\n * - Invalidates thread queries on completion\n * @param threadId - Optional thread ID to send message to. If not provided, creates new thread\n * @returns React Query mutation object with threadId in mutation result\n * @example\n * ```tsx\n * function ChatInput({ threadId }: { threadId?: string }) {\n * const sendMessage = useTamboSendMessage(threadId);\n *\n * const handleSubmit = async (text: string) => {\n * const result = await sendMessage.mutateAsync({\n * message: {\n * role: \"user\",\n * content: [{ type: \"text\", text }],\n * },\n * });\n *\n * // If threadId wasn't provided, a new thread was created\n * if (!threadId) {\n * console.log(\"Created thread:\", result.threadId);\n * }\n * };\n *\n * return (\n * <div>\n * <input onSubmit={handleSubmit} />\n * {sendMessage.isPending && <Spinner />}\n * </div>\n * );\n * }\n * ```\n */\nexport function useTamboSendMessage(threadId?: string) {\n const client = useTamboClient();\n const dispatch = useStreamDispatch();\n const streamState = useStreamState();\n const {\n userKey,\n autoGenerateThreadName = true,\n autoGenerateNameThreshold = 3,\n initialMessages,\n } = useTamboConfig();\n const registry = useContext(TamboRegistryContext);\n const queryClient = useTamboQueryClient();\n const { getAdditionalContext } = useTamboContextHelpers();\n const { clearInteractableSelections } = useTamboInteractable();\n const authState = useTamboAuthState();\n\n if (!registry) {\n throw new Error(\n \"useTamboSendMessage must be used within TamboRegistryProvider\",\n );\n }\n\n // Placeholder ID isn't a valid API thread ID - treat as new thread creation\n const isNewThread = isPlaceholderThreadId(threadId);\n const apiThreadId = isNewThread ? undefined : threadId;\n\n // Get previousRunId from the thread's streaming state (active run) or\n // lastCompletedRunId (persisted after run finishes / loaded from API).\n // The latter is essential after page reload when streaming state is gone.\n const threadState = apiThreadId\n ? streamState.threadMap[apiThreadId]\n : undefined;\n const previousRunId =\n threadState?.streaming.runId ?? threadState?.lastCompletedRunId;\n\n return useTamboMutation({\n mutationFn: async (options: SendMessageOptions) => {\n if (authState.status !== \"identified\") {\n const messages: Record<string, string> = {\n unauthenticated:\n \"Cannot send message: no userKey or userToken provided. \" +\n \"Configure authentication in TamboProvider.\",\n exchanging:\n \"Cannot send message: token exchange is still in progress. \" +\n \"Wait for authentication to complete.\",\n error:\n \"Cannot send message: token exchange failed. \" +\n \"Check your userToken configuration.\",\n invalid:\n \"Cannot send message: both userKey and userToken were provided. \" +\n \"You must provide one or the other, not both.\",\n };\n throw new Error(messages[authState.status]);\n }\n\n const { message, userMessageText, debug = false, toolChoice } = options;\n\n // Capture pre-mutation state for auto thread name generation\n const existingThread = streamState.threadMap[apiThreadId ?? \"\"];\n const preMutationMessageCount =\n existingThread?.thread.messages.length ?? 0;\n const threadAlreadyHasName = !!existingThread?.thread.name;\n\n const toolTracker = new ToolCallTracker(registry.toolRegistry);\n const throttledStreamable = createThrottledStreamableExecutor(\n toolTracker,\n registry.toolRegistry,\n );\n\n // Generate a stable message ID for the user message\n const userMessageId = userMessageText\n ? `user_msg_${Date.now()}_${Math.random().toString(36).slice(2, 9)}`\n : undefined;\n\n // Add user message immediately for instant feedback\n // Use threadId (which could be temp_xxx for new threads) for display\n if (threadId && userMessageText && userMessageId) {\n dispatchUserMessage(dispatch, threadId, userMessageId, userMessageText);\n }\n\n // Gather additional context from all registered context helpers.\n // TODO: This snapshot is captured once and reused for the entire multi-round\n // tool loop. If interactables change during streaming (e.g. user interactions),\n // continuations will send stale context. Re-gather before each continuation\n // if freshness matters.\n const helperContexts = await getAdditionalContext();\n const additionalContext: Record<string, unknown> = {};\n for (const helperContext of helperContexts) {\n additionalContext[helperContext.name] = helperContext.context;\n }\n\n // Clear interactable selections after capturing context so they only\n // apply to this single message send.\n clearInteractableSelections();\n\n // Create the run stream\n // Include initialMessages only on first send (new thread creation)\n const { stream, initialThreadId } = await createRunStream({\n client,\n threadId: apiThreadId,\n message,\n registry,\n userKey,\n previousRunId,\n additionalContext,\n toolChoice,\n initialMessages: isNewThread ? initialMessages : undefined,\n });\n\n let actualThreadId = initialThreadId;\n let runId: string | undefined;\n let currentStream: CreateRunStreamResult[\"stream\"] = stream;\n\n try {\n // Outer loop handles stream replacement for multi-round tool execution.\n // When we hit awaiting_input, we execute tools, get a new stream, and continue.\n // This flat loop pattern correctly handles tool→AI→tool→AI chains.\n while (true) {\n let pendingAwaitingInput: RunAwaitingInputEvent | undefined;\n\n // Process current stream until completion or awaiting_input\n for await (const event of handleEventStream(currentStream, {\n debug,\n })) {\n // Extract threadId and runId from RUN_STARTED event\n if (event.type === EventType.RUN_STARTED) {\n runId = event.runId;\n actualThreadId ??= event.threadId;\n\n // For threads with no ID at all: add user message now that we have the real threadId\n // Note: temp thread migration (temp_xxx -> real ID) is handled automatically\n // by the reducer when it sees RUN_STARTED with a different threadId\n if (!threadId && userMessageText && userMessageId) {\n dispatchUserMessage(\n dispatch,\n actualThreadId,\n userMessageId,\n userMessageText,\n );\n }\n } else if (!actualThreadId) {\n throw new Error(\n `Expected first event to be RUN_STARTED with threadId, got: ${event.type}`,\n );\n }\n\n toolTracker.handleEvent(event);\n\n // Parse partial JSON once for TOOL_CALL_ARGS — reused by both dispatch and streamable execution\n const parsedToolArgs =\n event.type === EventType.TOOL_CALL_ARGS\n ? toolTracker.parsePartialArgs(event.toolCallId)\n : undefined;\n\n dispatch({\n type: \"EVENT\",\n event,\n threadId: actualThreadId,\n parsedToolArgs,\n toolSchemas: toolTracker.toolSchemas,\n });\n\n // Schedule debounced streamable tool execution with the same pre-parsed args\n if (parsedToolArgs && event.type === EventType.TOOL_CALL_ARGS) {\n throttledStreamable.schedule(event.toolCallId, parsedToolArgs);\n }\n\n // Handle custom events\n if (event.type === EventType.CUSTOM) {\n const customEvent = asTamboCustomEvent(event);\n\n if (customEvent?.name === \"tambo.run.awaiting_input\") {\n pendingAwaitingInput = customEvent;\n break; // Exit stream loop to handle tool execution\n }\n }\n }\n\n // Flush any pending debounced streamable calls before continuing\n throttledStreamable.flush();\n\n // If stream finished without awaiting_input, we're done\n if (!pendingAwaitingInput) {\n break;\n }\n\n // Execute tools and get continuation stream\n // These checks should never fail since awaiting_input comes after RUN_STARTED\n if (!runId || !actualThreadId) {\n throw new Error(\n \"Cannot continue run after awaiting_input: missing runId or threadId\",\n );\n }\n\n const { stream: continuationStream, toolResults } =\n await executeToolsAndContinue({\n event: pendingAwaitingInput,\n toolTracker,\n registry,\n client,\n threadId: actualThreadId,\n runId,\n userKey,\n additionalContext,\n toolChoice,\n });\n\n dispatchToolResults(dispatch, actualThreadId, toolResults);\n\n currentStream = continuationStream;\n }\n\n return {\n threadId: actualThreadId,\n preMutationMessageCount,\n threadAlreadyHasName,\n };\n } catch (error) {\n // Dispatch a synthetic RUN_ERROR event to clean up thread state\n // This ensures the thread doesn't stay stuck in \"streaming\" status\n if (actualThreadId) {\n const errorMessage =\n error instanceof Error ? error.message : \"Unknown streaming error\";\n const errorEvent: RunErrorEvent = {\n type: EventType.RUN_ERROR,\n message: errorMessage,\n };\n dispatch({\n type: \"EVENT\",\n event: errorEvent,\n threadId: actualThreadId,\n });\n }\n throw error;\n }\n },\n onSuccess: async (result) => {\n await queryClient.invalidateQueries({\n queryKey: [\"v1-threads\", result.threadId],\n });\n\n if (\n autoGenerateThreadName &&\n shouldGenerateThreadName(\n result.threadId,\n result.threadAlreadyHasName,\n result.preMutationMessageCount,\n autoGenerateNameThreshold,\n )\n ) {\n await generateThreadName(\n client,\n dispatch,\n queryClient,\n result.threadId,\n );\n }\n },\n onError: (error) => {\n console.error(\"[useTamboSendMessage] Mutation failed:\", error);\n },\n });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"use-tambo-v1.test.js","sourceRoot":"","sources":["../../../src/v1/hooks/use-tambo-v1.test.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,uDAAyE;AACzE,kDAAyD;AACzD,+CAA0C;AAC1C,iFAAuE;AACvE,qFAGiD;AACjD,kFAA2E;AAC3E,6CAI0B;AAK1B,iDAA0C;AAE1C,IAAI,CAAC,IAAI,CAAC,uCAAuC,EAAE,GAAG,EAAE,CAAC,CAAC;IACxD,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE;IACzB,mBAAmB,EAAE,IAAI,CAAC,EAAE,EAAE;CAC/B,CAAC,CAAC,CAAC;AAEJ,IAAI,CAAC,IAAI,CAAC,gCAAgC,EAAE,GAAG,EAAE;IAC/C,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,gCAAgC,CAAC,CAAC;IACpE,OAAO;QACL,GAAG,MAAM;QACT,cAAc,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;KAC/C,CAAC;AACJ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AAI,CAAC;oBACH,MAAM,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC;gBACvE,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,WAAW,GAAG,KAAK,CAAC;gBACtB,CAAC;YACH,CAAC,CAAC,CAAC;YAEH,MAAM,CAAC,WAAW,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YAC1C,MAAM,CAAE,WAAqB,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YAC7D,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC5D,MAAM,CAAC,oBAAoB,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;QACtD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import TamboAI from \"@tambo-ai/typescript-sdk\";\nimport { QueryClient, QueryClientProvider } from \"@tanstack/react-query\";\nimport { renderHook, act } from \"@testing-library/react\";\nimport React, { useReducer } from \"react\";\nimport { useTamboClient } from \"../../providers/tambo-client-provider\";\nimport {\n TamboRegistryContext,\n type TamboRegistryContext as TamboRegistryContextType,\n} from \"../../providers/tambo-registry-provider\";\nimport { TamboStreamProvider } from \"../providers/tambo-v1-stream-context\";\nimport {\n streamReducer,\n type StreamState,\n type StreamAction,\n} from \"@tambo-ai/client\";\nimport type {\n TamboComponentContent,\n TamboToolUseContent,\n} from \"../types/message\";\nimport { useTambo } from \"./use-tambo-v1\";\n\njest.mock(\"../../providers/tambo-client-provider\", () => ({\n useTamboClient: jest.fn(),\n useTamboQueryClient: jest.fn(),\n}));\n\njest.mock(\"../providers/tambo-v1-provider\", () => {\n const actual = jest.requireActual(\"../providers/tambo-v1-provider\");\n return {\n ...actual,\n useTamboConfig: () => ({ userKey: undefined }),\n };\n});\n\njest.mock(\"./use-tambo-v1-auth-state\", () => ({\n useTamboAuthState: () => ({\n status: \"identified\",\n source: \"userKey\",\n }),\n}));\n\nimport { useTamboQueryClient } from \"../../providers/tambo-client-provider\";\n\ndescribe(\"useTambo\", () => {\n let queryClient: QueryClient;\n\n const mockTamboClient = {\n apiKey: \"\",\n threads: {\n messages: {\n list: jest.fn().mockResolvedValue({ messages: [], hasMore: false }),\n },\n runs: {\n delete: jest.fn().mockResolvedValue({}),\n },\n },\n } as unknown as TamboAI;\n\n const mockRegistry: TamboRegistryContextType = {\n componentList: {},\n toolRegistry: {},\n componentToolAssociations: {},\n mcpServerInfos: [],\n resources: [],\n resourceSource: null,\n registerComponent: jest.fn(),\n registerTool: jest.fn(),\n registerTools: jest.fn(),\n unregisterTools: jest.fn(),\n addToolAssociation: jest.fn(),\n registerMcpServer: jest.fn(),\n registerMcpServers: jest.fn(),\n registerResource: jest.fn(),\n registerResources: jest.fn(),\n registerResourceSource: jest.fn(),\n };\n\n function TestWrapper({ children }: { children: React.ReactNode }) {\n return (\n <QueryClientProvider client={queryClient}>\n <TamboRegistryContext.Provider value={mockRegistry}>\n <TamboStreamProvider>{children}</TamboStreamProvider>\n </TamboRegistryContext.Provider>\n </QueryClientProvider>\n );\n }\n\n function createWrapperWithState(\n state: StreamState,\n registry: TamboRegistryContextType = mockRegistry,\n ) {\n const noopDispatch: React.Dispatch<StreamAction> = () => {};\n return function WrapperWithState({\n children,\n }: {\n children: React.ReactNode;\n }) {\n return (\n <QueryClientProvider client={queryClient}>\n <TamboRegistryContext.Provider value={registry}>\n <TamboStreamProvider state={state} dispatch={noopDispatch}>\n {children}\n </TamboStreamProvider>\n </TamboRegistryContext.Provider>\n </QueryClientProvider>\n );\n };\n }\n\n // Wrapper that uses the real reducer so state updates properly\n function createWrapperWithRealReducer(\n initialState: StreamState,\n stateRef?: React.MutableRefObject<StreamState | undefined>,\n ) {\n return function WrapperWithRealReducer({\n children,\n }: {\n children: React.ReactNode;\n }) {\n const [state, dispatch] = useReducer(streamReducer, initialState);\n if (stateRef) {\n stateRef.current = state;\n }\n return (\n <QueryClientProvider client={queryClient}>\n <TamboRegistryContext.Provider value={mockRegistry}>\n <TamboStreamProvider state={state} dispatch={dispatch}>\n {children}\n </TamboStreamProvider>\n </TamboRegistryContext.Provider>\n </QueryClientProvider>\n );\n };\n }\n\n beforeEach(() => {\n queryClient = new QueryClient({\n defaultOptions: {\n queries: { retry: false },\n },\n });\n jest.mocked(useTamboClient).mockReturnValue(mockTamboClient);\n jest.mocked(useTamboQueryClient).mockReturnValue(queryClient);\n jest.clearAllMocks();\n delete (mockTamboClient.threads as any).update;\n });\n\n it(\"returns client from useTamboClient\", () => {\n const { result } = renderHook(() => useTambo(), {\n wrapper: TestWrapper,\n });\n\n expect(result.current.client).toBe(mockTamboClient);\n });\n\n it(\"returns registry functions\", () => {\n const { result } = renderHook(() => useTambo(), {\n wrapper: TestWrapper,\n });\n\n expect(result.current.registerComponent).toBe(\n mockRegistry.registerComponent,\n );\n expect(result.current.registerTool).toBe(mockRegistry.registerTool);\n expect(result.current.registerTools).toBe(mockRegistry.registerTools);\n expect(result.current.componentList).toBe(mockRegistry.componentList);\n expect(result.current.toolRegistry).toBe(mockRegistry.toolRegistry);\n });\n\n it(\"returns placeholder thread when no threadId provided\", () => {\n const { result } = renderHook(() => useTambo(), {\n wrapper: TestWrapper,\n });\n\n // Default state has placeholder thread for optimistic UI\n expect(result.current.thread).toBeDefined();\n expect(result.current.thread?.thread.id).toBe(\"placeholder\");\n expect(result.current.messages).toEqual([]);\n });\n\n it(\"returns thread state when switched to a thread\", () => {\n const { result } = renderHook(() => useTambo(), {\n wrapper: TestWrapper,\n });\n\n // Initialize and switch to thread\n act(() => {\n result.current.initThread(\"thread_123\");\n result.current.switchThread(\"thread_123\");\n });\n\n expect(result.current.thread).toBeDefined();\n expect(result.current.thread?.thread.id).toBe(\"thread_123\");\n expect(result.current.messages).toEqual([]);\n });\n\n it(\"returns default streaming state when thread not loaded\", () => {\n const { result } = renderHook(() => useTambo(), {\n wrapper: TestWrapper,\n });\n\n expect(result.current.streamingState).toEqual({ status: \"idle\" });\n expect(result.current.isIdle).toBe(true);\n expect(result.current.isStreaming).toBe(false);\n expect(result.current.isWaiting).toBe(false);\n });\n\n it(\"returns thread streaming state when thread loaded\", () => {\n const { result } = renderHook(() => useTambo(), {\n wrapper: TestWrapper,\n });\n\n // Initialize and switch to thread\n act(() => {\n result.current.initThread(\"thread_123\");\n result.current.switchThread(\"thread_123\");\n });\n\n expect(result.current.streamingState.status).toBe(\"idle\");\n expect(result.current.isIdle).toBe(true);\n expect(result.current.isStreaming).toBe(false);\n expect(result.current.isWaiting).toBe(false);\n });\n\n it(\"provides dispatch function for advanced usage\", () => {\n const { result } = renderHook(() => useTambo(), {\n wrapper: TestWrapper,\n });\n\n expect(typeof result.current.dispatch).toBe(\"function\");\n });\n\n it(\"provides thread management functions\", () => {\n const { result } = renderHook(() => useTambo(), {\n wrapper: TestWrapper,\n });\n\n expect(typeof result.current.initThread).toBe(\"function\");\n expect(typeof result.current.switchThread).toBe(\"function\");\n expect(typeof result.current.startNewThread).toBe(\"function\");\n });\n\n it(\"initializes and switches threads\", () => {\n const { result } = renderHook(() => useTambo(), {\n wrapper: TestWrapper,\n });\n\n // Initially has placeholder thread for optimistic UI\n expect(result.current.currentThreadId).toBe(\"placeholder\");\n expect(result.current.thread).toBeDefined();\n expect(result.current.thread?.thread.id).toBe(\"placeholder\");\n\n // Initialize a new thread\n act(() => {\n result.current.initThread(\"new_thread_1\");\n });\n\n // Switch to the new thread\n act(() => {\n result.current.switchThread(\"new_thread_1\");\n });\n\n expect(result.current.currentThreadId).toBe(\"new_thread_1\");\n });\n\n it(\"starts new thread with generated ID\", () => {\n const { result } = renderHook(() => useTambo(), {\n wrapper: TestWrapper,\n });\n\n let newThreadId: string;\n act(() => {\n newThreadId = result.current.startNewThread();\n });\n\n expect(newThreadId!).toBe(\"placeholder\");\n expect(result.current.currentThreadId).toBe(newThreadId!);\n expect(result.current.thread).toBeDefined();\n });\n\n it(\"uses current thread when no threadId argument provided\", () => {\n const { result } = renderHook(() => useTambo(), {\n wrapper: TestWrapper,\n });\n\n // Initialize and switch to a thread\n act(() => {\n result.current.initThread(\"thread_123\");\n result.current.switchThread(\"thread_123\");\n });\n\n // Should use current thread from context (thread_123)\n expect(result.current.currentThreadId).toBe(\"thread_123\");\n expect(result.current.thread?.thread.id).toBe(\"thread_123\");\n });\n\n describe(\"component content transformation\", () => {\n const createComponentContent = (\n id: string,\n name: string,\n props: Record<string, unknown>,\n ): TamboComponentContent => ({\n type: \"component\",\n id,\n name,\n props,\n streamingState: \"done\",\n });\n\n it(\"adds renderedComponent to component content blocks\", () => {\n const state: StreamState = {\n threadMap: {\n thread_123: {\n thread: {\n id: \"thread_123\",\n messages: [\n {\n id: \"msg_1\",\n role: \"assistant\",\n content: [\n createComponentContent(\"comp_1\", \"TestComponent\", {\n title: \"Hello\",\n }),\n ],\n createdAt: new Date().toISOString(),\n },\n ],\n status: \"idle\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: { status: \"idle\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"thread_123\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithState(state),\n });\n\n expect(result.current.messages).toHaveLength(1);\n const content = result.current.messages[0].content[0];\n expect(content.type).toBe(\"component\");\n expect(\n (content as TamboComponentContent).renderedComponent,\n ).toBeDefined();\n });\n\n it(\"preserves non-component content blocks unchanged\", () => {\n const state: StreamState = {\n threadMap: {\n thread_123: {\n thread: {\n id: \"thread_123\",\n messages: [\n {\n id: \"msg_1\",\n role: \"assistant\",\n content: [\n { type: \"text\", text: \"Hello world\" },\n createComponentContent(\"comp_1\", \"TestComponent\", {\n title: \"Hi\",\n }),\n ],\n createdAt: new Date().toISOString(),\n },\n ],\n status: \"idle\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: { status: \"idle\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"thread_123\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithState(state),\n });\n\n expect(result.current.messages).toHaveLength(1);\n const textContent = result.current.messages[0].content[0];\n expect(textContent.type).toBe(\"text\");\n expect(textContent).toEqual({ type: \"text\", text: \"Hello world\" });\n\n const componentContent = result.current.messages[0].content[1];\n expect(componentContent.type).toBe(\"component\");\n expect(\n (componentContent as TamboComponentContent).renderedComponent,\n ).toBeDefined();\n });\n\n it(\"caches rendered components and returns same reference when props unchanged\", () => {\n const state: StreamState = {\n threadMap: {\n thread_123: {\n thread: {\n id: \"thread_123\",\n messages: [\n {\n id: \"msg_1\",\n role: \"assistant\",\n content: [\n createComponentContent(\"comp_1\", \"TestComponent\", {\n title: \"Hello\",\n }),\n ],\n createdAt: new Date().toISOString(),\n },\n ],\n status: \"idle\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: { status: \"idle\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"thread_123\",\n };\n\n const { result, rerender } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithState(state),\n });\n\n const firstRender = (\n result.current.messages[0].content[0] as TamboComponentContent\n ).renderedComponent;\n\n // Re-render with same state\n rerender();\n\n const secondRender = (\n result.current.messages[0].content[0] as TamboComponentContent\n ).renderedComponent;\n\n // Should return the same cached element reference\n expect(secondRender).toBe(firstRender);\n });\n\n it(\"handles empty props on components\", () => {\n const state: StreamState = {\n threadMap: {\n thread_123: {\n thread: {\n id: \"thread_123\",\n messages: [\n {\n id: \"msg_1\",\n role: \"assistant\",\n content: [\n createComponentContent(\"comp_1\", \"TestComponent\", {}),\n ],\n createdAt: new Date().toISOString(),\n },\n ],\n status: \"idle\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: { status: \"idle\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"thread_123\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithState(state),\n });\n\n const content = result.current.messages[0].content[0];\n expect(content.type).toBe(\"component\");\n expect(\n (content as TamboComponentContent).renderedComponent,\n ).toBeDefined();\n });\n\n it(\"handles undefined props on components\", () => {\n const state: StreamState = {\n threadMap: {\n thread_123: {\n thread: {\n id: \"thread_123\",\n messages: [\n {\n id: \"msg_1\",\n role: \"assistant\",\n content: [\n {\n type: \"component\",\n id: \"comp_1\",\n name: \"TestComponent\",\n props: undefined,\n streamingState: \"done\",\n } as TamboComponentContent,\n ],\n createdAt: new Date().toISOString(),\n },\n ],\n status: \"idle\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: { status: \"idle\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"thread_123\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithState(state),\n });\n\n const content = result.current.messages[0].content[0];\n expect(content.type).toBe(\"component\");\n expect(\n (content as TamboComponentContent).renderedComponent,\n ).toBeDefined();\n });\n\n it(\"handles multiple component content blocks in same message\", () => {\n const state: StreamState = {\n threadMap: {\n thread_123: {\n thread: {\n id: \"thread_123\",\n messages: [\n {\n id: \"msg_1\",\n role: \"assistant\",\n content: [\n createComponentContent(\"comp_1\", \"ComponentA\", {\n value: 1,\n }),\n createComponentContent(\"comp_2\", \"ComponentB\", {\n value: 2,\n }),\n createComponentContent(\"comp_3\", \"ComponentC\", {\n value: 3,\n }),\n ],\n createdAt: new Date().toISOString(),\n },\n ],\n status: \"idle\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: { status: \"idle\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"thread_123\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithState(state),\n });\n\n expect(result.current.messages[0].content).toHaveLength(3);\n result.current.messages[0].content.forEach((content) => {\n expect(content.type).toBe(\"component\");\n expect(\n (content as TamboComponentContent).renderedComponent,\n ).toBeDefined();\n });\n });\n\n it(\"uses currentThreadId from stream state\", () => {\n const state: StreamState = {\n threadMap: {\n placeholder: {\n thread: {\n id: \"placeholder\",\n messages: [\n {\n id: \"msg_1\",\n role: \"assistant\",\n content: [\n createComponentContent(\"comp_1\", \"TestComponent\", {\n title: \"Hello\",\n }),\n ],\n createdAt: new Date().toISOString(),\n },\n ],\n status: \"idle\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: { status: \"idle\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"placeholder\",\n };\n\n // No explicit threadId - uses currentThreadId from state\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithState(state),\n });\n\n // Component should render using the placeholder thread\n const content = result.current.messages[0].content[0];\n expect(content.type).toBe(\"component\");\n expect(\n (content as TamboComponentContent).renderedComponent,\n ).toBeDefined();\n });\n });\n\n describe(\"tool_use content transformation\", () => {\n it(\"adds computed properties to tool_use content\", () => {\n const state: StreamState = {\n threadMap: {\n thread_123: {\n thread: {\n id: \"thread_123\",\n messages: [\n {\n id: \"msg_1\",\n role: \"assistant\",\n content: [\n {\n type: \"tool_use\",\n id: \"tool_1\",\n name: \"getWeather\",\n input: { location: \"NYC\" },\n },\n ],\n createdAt: new Date().toISOString(),\n },\n ],\n status: \"idle\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: { status: \"idle\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"thread_123\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithState(state),\n });\n\n const content = result.current.messages[0]\n .content[0] as TamboToolUseContent;\n expect(content.type).toBe(\"tool_use\");\n expect(content.hasCompleted).toBe(false);\n expect(content.statusMessage).toBe(\"Calling getWeather\");\n expect(content.tamboDisplayProps).toBeDefined();\n });\n\n it(\"sets hasCompleted to true when matching tool_result exists\", () => {\n const state: StreamState = {\n threadMap: {\n thread_123: {\n thread: {\n id: \"thread_123\",\n messages: [\n {\n id: \"msg_1\",\n role: \"assistant\",\n content: [\n {\n type: \"tool_use\",\n id: \"tool_1\",\n name: \"getWeather\",\n input: { location: \"NYC\" },\n },\n ],\n createdAt: new Date().toISOString(),\n },\n {\n id: \"msg_2\",\n role: \"user\",\n content: [\n {\n type: \"tool_result\",\n toolUseId: \"tool_1\",\n content: [{ type: \"text\", text: \"Sunny\" }],\n },\n ],\n createdAt: new Date().toISOString(),\n },\n ],\n status: \"idle\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: { status: \"idle\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"thread_123\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithState(state),\n });\n\n const content = result.current.messages[0]\n .content[0] as TamboToolUseContent;\n expect(content.hasCompleted).toBe(true);\n expect(content.statusMessage).toBe(\"Called getWeather\");\n });\n\n it(\"uses _tambo_statusMessage when tool is in progress\", () => {\n const state: StreamState = {\n threadMap: {\n thread_123: {\n thread: {\n id: \"thread_123\",\n messages: [\n {\n id: \"msg_1\",\n role: \"assistant\",\n content: [\n {\n type: \"tool_use\",\n id: \"tool_1\",\n name: \"getWeather\",\n input: {\n location: \"NYC\",\n _tambo_statusMessage: \"Fetching weather for NYC...\",\n },\n },\n ],\n createdAt: new Date().toISOString(),\n },\n ],\n status: \"idle\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: { status: \"idle\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"thread_123\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithState(state),\n });\n\n const content = result.current.messages[0]\n .content[0] as TamboToolUseContent;\n expect(content.statusMessage).toBe(\"Fetching weather for NYC...\");\n expect(content.tamboDisplayProps?._tambo_statusMessage).toBe(\n \"Fetching weather for NYC...\",\n );\n });\n\n it(\"uses _tambo_completionStatusMessage when tool is completed\", () => {\n const state: StreamState = {\n threadMap: {\n thread_123: {\n thread: {\n id: \"thread_123\",\n messages: [\n {\n id: \"msg_1\",\n role: \"assistant\",\n content: [\n {\n type: \"tool_use\",\n id: \"tool_1\",\n name: \"getWeather\",\n input: {\n location: \"NYC\",\n _tambo_statusMessage: \"Fetching weather...\",\n _tambo_completionStatusMessage: \"Got weather for NYC\",\n },\n },\n ],\n createdAt: new Date().toISOString(),\n },\n {\n id: \"msg_2\",\n role: \"user\",\n content: [\n {\n type: \"tool_result\",\n toolUseId: \"tool_1\",\n content: [{ type: \"text\", text: \"Sunny\" }],\n },\n ],\n createdAt: new Date().toISOString(),\n },\n ],\n status: \"idle\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: { status: \"idle\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"thread_123\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithState(state),\n });\n\n const content = result.current.messages[0]\n .content[0] as TamboToolUseContent;\n expect(content.hasCompleted).toBe(true);\n expect(content.statusMessage).toBe(\"Got weather for NYC\");\n });\n\n it(\"filters _tambo_* properties from input\", () => {\n const state: StreamState = {\n threadMap: {\n thread_123: {\n thread: {\n id: \"thread_123\",\n messages: [\n {\n id: \"msg_1\",\n role: \"assistant\",\n content: [\n {\n type: \"tool_use\",\n id: \"tool_1\",\n name: \"getWeather\",\n input: {\n location: \"NYC\",\n units: \"celsius\",\n _tambo_statusMessage: \"Fetching...\",\n _tambo_completionStatusMessage: \"Done\",\n },\n },\n ],\n createdAt: new Date().toISOString(),\n },\n ],\n status: \"idle\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: { status: \"idle\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"thread_123\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithState(state),\n });\n\n const content = result.current.messages[0]\n .content[0] as TamboToolUseContent;\n // Input should only have non-_tambo_ properties\n expect(content.input).toEqual({ location: \"NYC\", units: \"celsius\" });\n expect(content.input._tambo_statusMessage).toBeUndefined();\n expect(content.input._tambo_completionStatusMessage).toBeUndefined();\n });\n\n it(\"handles tool_use with empty input\", () => {\n const state: StreamState = {\n threadMap: {\n thread_123: {\n thread: {\n id: \"thread_123\",\n messages: [\n {\n id: \"msg_1\",\n role: \"assistant\",\n content: [\n {\n type: \"tool_use\",\n id: \"tool_1\",\n name: \"getCurrentTime\",\n input: {},\n },\n ],\n createdAt: new Date().toISOString(),\n },\n ],\n status: \"idle\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: { status: \"idle\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"thread_123\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithState(state),\n });\n\n const content = result.current.messages[0]\n .content[0] as TamboToolUseContent;\n expect(content.input).toEqual({});\n expect(content.hasCompleted).toBe(false);\n expect(content.statusMessage).toBe(\"Calling getCurrentTime\");\n });\n\n it(\"handles tool_use with undefined input\", () => {\n const state: StreamState = {\n threadMap: {\n thread_123: {\n thread: {\n id: \"thread_123\",\n messages: [\n {\n id: \"msg_1\",\n role: \"assistant\",\n content: [\n {\n type: \"tool_use\",\n id: \"tool_1\",\n name: \"getCurrentTime\",\n input: undefined,\n } as unknown as TamboToolUseContent,\n ],\n createdAt: new Date().toISOString(),\n },\n ],\n status: \"idle\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: { status: \"idle\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"thread_123\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithState(state),\n });\n\n const content = result.current.messages[0]\n .content[0] as TamboToolUseContent;\n expect(content.input).toEqual({});\n expect(content.hasCompleted).toBe(false);\n });\n\n it(\"handles multiple tool_use blocks with different completion states\", () => {\n const state: StreamState = {\n threadMap: {\n thread_123: {\n thread: {\n id: \"thread_123\",\n messages: [\n {\n id: \"msg_1\",\n role: \"assistant\",\n content: [\n {\n type: \"tool_use\",\n id: \"tool_1\",\n name: \"getWeather\",\n input: { location: \"NYC\" },\n },\n {\n type: \"tool_use\",\n id: \"tool_2\",\n name: \"getTime\",\n input: { timezone: \"EST\" },\n },\n ],\n createdAt: new Date().toISOString(),\n },\n {\n id: \"msg_2\",\n role: \"user\",\n content: [\n {\n type: \"tool_result\",\n toolUseId: \"tool_1\",\n content: [{ type: \"text\", text: \"Sunny\" }],\n },\n // tool_2 has no result yet\n ],\n createdAt: new Date().toISOString(),\n },\n ],\n status: \"idle\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: { status: \"idle\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"thread_123\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithState(state),\n });\n\n const tool1 = result.current.messages[0]\n .content[0] as TamboToolUseContent;\n const tool2 = result.current.messages[0]\n .content[1] as TamboToolUseContent;\n\n expect(tool1.hasCompleted).toBe(true);\n expect(tool1.statusMessage).toBe(\"Called getWeather\");\n\n expect(tool2.hasCompleted).toBe(false);\n expect(tool2.statusMessage).toBe(\"Calling getTime\");\n });\n });\n\n describe(\"cancelRun\", () => {\n it(\"sets thread to idle and lastRunCancelled to true when cancelled\", async () => {\n const initialState: StreamState = {\n threadMap: {\n thread_123: {\n thread: {\n id: \"thread_123\",\n messages: [],\n status: \"streaming\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: { status: \"streaming\", runId: \"run_456\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"thread_123\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithRealReducer(initialState),\n });\n\n // Before cancel: streaming and lastRunCancelled is false\n expect(result.current.isStreaming).toBe(true);\n expect(result.current.isIdle).toBe(false);\n expect(result.current.thread?.thread.lastRunCancelled).toBe(false);\n\n await act(async () => {\n await result.current.cancelRun();\n });\n\n // After cancel: idle and lastRunCancelled is true\n expect(result.current.isStreaming).toBe(false);\n expect(result.current.isIdle).toBe(true);\n expect(result.current.thread?.thread.lastRunCancelled).toBe(true);\n\n // Verify API was called to cancel the run\n expect(mockTamboClient.threads.runs.delete).toHaveBeenCalledWith(\n \"run_456\",\n { threadId: \"thread_123\" },\n );\n });\n\n it(\"is a no-op when there is no active run\", async () => {\n const initialState: StreamState = {\n threadMap: {\n thread_123: {\n thread: {\n id: \"thread_123\",\n messages: [],\n status: \"idle\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: { status: \"idle\" }, // No runId\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"thread_123\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithRealReducer(initialState),\n });\n\n // Idle before\n expect(result.current.isIdle).toBe(true);\n expect(result.current.thread?.thread.lastRunCancelled).toBe(false);\n\n await act(async () => {\n await result.current.cancelRun();\n });\n\n // Still idle, lastRunCancelled unchanged\n expect(result.current.isIdle).toBe(true);\n expect(result.current.thread?.thread.lastRunCancelled).toBe(false);\n\n // API should not have been called\n expect(mockTamboClient.threads.runs.delete).not.toHaveBeenCalled();\n });\n\n it(\"is a no-op when on a placeholder thread\", async () => {\n const initialState: StreamState = {\n threadMap: {\n placeholder: {\n thread: {\n id: \"placeholder\",\n messages: [],\n status: \"streaming\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: { status: \"streaming\", runId: \"run_123\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"placeholder\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithRealReducer(initialState),\n });\n\n // Before: streaming on placeholder\n expect(result.current.isStreaming).toBe(true);\n expect(result.current.thread?.thread.lastRunCancelled).toBe(false);\n\n await act(async () => {\n await result.current.cancelRun();\n });\n\n // After: state should be unchanged (placeholder threads are skipped)\n expect(result.current.isStreaming).toBe(true);\n expect(result.current.thread?.thread.lastRunCancelled).toBe(false);\n\n // API should not have been called for placeholder threads\n expect(mockTamboClient.threads.runs.delete).not.toHaveBeenCalled();\n });\n\n it(\"still updates local state even if API call fails\", async () => {\n const consoleWarnSpy = jest\n .spyOn(console, \"warn\")\n .mockImplementation(() => {});\n\n // Make the API call fail\n jest\n .mocked(mockTamboClient.threads.runs.delete)\n .mockRejectedValueOnce(new Error(\"Network error\"));\n\n const initialState: StreamState = {\n threadMap: {\n thread_123: {\n thread: {\n id: \"thread_123\",\n messages: [],\n status: \"streaming\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: { status: \"streaming\", runId: \"run_456\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"thread_123\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithRealReducer(initialState),\n });\n\n await act(async () => {\n await result.current.cancelRun();\n });\n\n // Local state should still be updated (optimistic update)\n expect(result.current.isIdle).toBe(true);\n expect(result.current.thread?.thread.lastRunCancelled).toBe(true);\n\n // Warning should have been logged\n expect(consoleWarnSpy).toHaveBeenCalledWith(\n \"Failed to cancel run on server:\",\n expect.any(Error),\n );\n\n consoleWarnSpy.mockRestore();\n });\n });\n\n describe(\"updateThreadName\", () => {\n it(\"updates local thread name and invalidates caches on success\", async () => {\n const mockUpdate = jest.fn().mockResolvedValue({});\n // TypeScript SDK will be updated to include this method\n (mockTamboClient.threads as any).update = mockUpdate;\n\n const invalidateQueriesSpy = jest.spyOn(queryClient, \"invalidateQueries\");\n\n const initialState: StreamState = {\n threadMap: {\n thread_456: {\n thread: {\n id: \"thread_456\",\n messages: [],\n status: \"idle\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n name: \"Old Name\",\n },\n streaming: { status: \"idle\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"thread_456\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithRealReducer(initialState),\n });\n\n await act(async () => {\n await result.current.updateThreadName(\"thread_456\", \"My New Thread\");\n });\n\n expect(mockUpdate).toHaveBeenCalledWith(\"thread_456\", {\n name: \"My New Thread\",\n userKey: undefined,\n });\n\n expect(result.current.thread?.thread.name).toBe(\"My New Thread\");\n const invalidatedKeys = invalidateQueriesSpy.mock.calls\n .map(([arg]) => (arg as any).queryKey)\n .filter(Boolean);\n expect(invalidatedKeys).toContainEqual([\"v1-threads\", \"list\"]);\n expect(invalidatedKeys).toContainEqual([\"v1-threads\", \"thread_456\"]);\n });\n\n it(\"does not create local thread state when thread isn't loaded\", async () => {\n const mockUpdate = jest.fn().mockResolvedValue({});\n // TypeScript SDK will be updated to include this method\n (mockTamboClient.threads as any).update = mockUpdate;\n\n const invalidateQueriesSpy = jest.spyOn(queryClient, \"invalidateQueries\");\n\n // Track the internal StreamState from the real reducer so we can assert we\n // don't create a local thread entry for threads that haven't been loaded.\n const stateRef: React.MutableRefObject<StreamState | undefined> = {\n current: undefined,\n };\n const initialState: StreamState = {\n threadMap: {},\n currentThreadId: \"placeholder\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithRealReducer(initialState, stateRef),\n });\n\n await act(async () => {\n await result.current.updateThreadName(\"thread_789\", \"New Title\");\n });\n\n expect(mockUpdate).toHaveBeenCalledWith(\"thread_789\", {\n name: \"New Title\",\n userKey: undefined,\n });\n const invalidatedKeys = invalidateQueriesSpy.mock.calls\n .map(([arg]) => (arg as any).queryKey)\n .filter(Boolean);\n expect(invalidatedKeys).toContainEqual([\"v1-threads\", \"list\"]);\n expect(invalidatedKeys).toContainEqual([\"v1-threads\", \"thread_789\"]);\n\n expect(stateRef.current?.threadMap.thread_789).toBeUndefined();\n\n act(() => {\n result.current.switchThread(\"thread_789\");\n });\n\n expect(result.current.thread).toBeUndefined();\n });\n\n it(\"propagates errors and does not update local state\", async () => {\n const mockUpdate = jest\n .fn()\n .mockRejectedValue(new Error(\"Network error\"));\n // TypeScript SDK will be updated to include this method\n (mockTamboClient.threads as any).update = mockUpdate;\n\n const invalidateQueriesSpy = jest.spyOn(queryClient, \"invalidateQueries\");\n\n const initialState: StreamState = {\n threadMap: {\n thread_456: {\n thread: {\n id: \"thread_456\",\n messages: [],\n status: \"idle\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n name: \"Old Name\",\n },\n streaming: { status: \"idle\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"thread_456\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithRealReducer(initialState),\n });\n\n let caughtError: unknown;\n await act(async () => {\n try {\n await result.current.updateThreadName(\"thread_456\", \"My New Thread\");\n } catch (error) {\n caughtError = error;\n }\n });\n\n expect(caughtError).toBeInstanceOf(Error);\n expect((caughtError as Error).message).toBe(\"Network error\");\n expect(result.current.thread?.thread.name).toBe(\"Old Name\");\n expect(invalidateQueriesSpy).not.toHaveBeenCalled();\n });\n });\n});\n"]}
1
+ {"version":3,"file":"use-tambo-v1.test.js","sourceRoot":"","sources":["../../../src/v1/hooks/use-tambo-v1.test.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,uDAAyE;AACzE,kDAAyD;AACzD,+CAA0C;AAC1C,iFAAuE;AACvE,qFAGiD;AACjD,kFAA2E;AAC3E,6CAI0B;AAK1B,iDAA0C;AAE1C,IAAI,CAAC,IAAI,CAAC,uCAA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,EAAE,UAAU;yBACjB;wBACD,SAAS,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE;wBAC7B,oBAAoB,EAAE,EAAE;qBACzB;iBACF;gBACD,eAAe,EAAE,YAAY;aAC9B,CAAC;YAEF,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,kBAAU,EAAC,GAAG,EAAE,CAAC,IAAA,uBAAQ,GAAE,EAAE;gBAC9C,OAAO,EAAE,4BAA4B,CAAC,YAAY,CAAC;aACpD,CAAC,CAAC;YAEH,IAAI,WAAoB,CAAC;YACzB,MAAM,IAAA,WAAG,EAAC,KAAK,IAAI,EAAE;gBACnB,IAAI,CAAC;oBACH,MAAM,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC;gBACvE,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,WAAW,GAAG,KAAK,CAAC;gBACtB,CAAC;YACH,CAAC,CAAC,CAAC;YAEH,MAAM,CAAC,WAAW,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YAC1C,MAAM,CAAE,WAAqB,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YAC7D,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC5D,MAAM,CAAC,oBAAoB,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;QACtD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import TamboAI from \"@tambo-ai/typescript-sdk\";\nimport { QueryClient, QueryClientProvider } from \"@tanstack/react-query\";\nimport { renderHook, act } from \"@testing-library/react\";\nimport React, { useReducer } from \"react\";\nimport { useTamboClient } from \"../../providers/tambo-client-provider\";\nimport {\n TamboRegistryContext,\n type TamboRegistryContext as TamboRegistryContextType,\n} from \"../../providers/tambo-registry-provider\";\nimport { TamboStreamProvider } from \"../providers/tambo-v1-stream-context\";\nimport {\n streamReducer,\n type StreamState,\n type StreamAction,\n} from \"@tambo-ai/client\";\nimport type {\n TamboComponentContent,\n TamboToolUseContent,\n} from \"../types/message\";\nimport { useTambo } from \"./use-tambo-v1\";\n\njest.mock(\"../../providers/tambo-client-provider\", () => ({\n useTamboClient: jest.fn(),\n useTamboQueryClient: jest.fn(),\n}));\n\njest.mock(\"../providers/tambo-v1-provider\", () => {\n const actual = jest.requireActual(\"../providers/tambo-v1-provider\");\n return {\n ...actual,\n useTamboConfig: () => ({ userKey: undefined }),\n };\n});\n\njest.mock(\"./use-tambo-v1-auth-state\", () => ({\n useTamboAuthState: () => ({\n status: \"identified\",\n source: \"userKey\",\n }),\n}));\n\nimport { useTamboQueryClient } from \"../../providers/tambo-client-provider\";\n\ndescribe(\"useTambo\", () => {\n let queryClient: QueryClient;\n\n const mockTamboClient = {\n apiKey: \"\",\n threads: {\n messages: {\n list: jest.fn().mockResolvedValue({ messages: [], hasMore: false }),\n },\n runs: {\n delete: jest.fn().mockResolvedValue({}),\n },\n },\n } as unknown as TamboAI;\n\n const mockRegistry: TamboRegistryContextType = {\n componentList: {},\n toolRegistry: {},\n componentToolAssociations: {},\n mcpServerInfos: [],\n resources: [],\n resourceSource: null,\n registerComponent: jest.fn(),\n registerTool: jest.fn(),\n registerTools: jest.fn(),\n unregisterTools: jest.fn(),\n addToolAssociation: jest.fn(),\n registerMcpServer: jest.fn(),\n registerMcpServers: jest.fn(),\n registerResource: jest.fn(),\n registerResources: jest.fn(),\n registerResourceSource: jest.fn(),\n };\n\n function TestWrapper({ children }: { children: React.ReactNode }) {\n return (\n <QueryClientProvider client={queryClient}>\n <TamboRegistryContext.Provider value={mockRegistry}>\n <TamboStreamProvider>{children}</TamboStreamProvider>\n </TamboRegistryContext.Provider>\n </QueryClientProvider>\n );\n }\n\n function createWrapperWithState(\n state: StreamState,\n registry: TamboRegistryContextType = mockRegistry,\n ) {\n const noopDispatch: React.Dispatch<StreamAction> = () => {};\n return function WrapperWithState({\n children,\n }: {\n children: React.ReactNode;\n }) {\n return (\n <QueryClientProvider client={queryClient}>\n <TamboRegistryContext.Provider value={registry}>\n <TamboStreamProvider state={state} dispatch={noopDispatch}>\n {children}\n </TamboStreamProvider>\n </TamboRegistryContext.Provider>\n </QueryClientProvider>\n );\n };\n }\n\n // Wrapper that uses the real reducer so state updates properly\n function createWrapperWithRealReducer(\n initialState: StreamState,\n stateRef?: React.MutableRefObject<StreamState | undefined>,\n ) {\n return function WrapperWithRealReducer({\n children,\n }: {\n children: React.ReactNode;\n }) {\n const [state, dispatch] = useReducer(streamReducer, initialState);\n if (stateRef) {\n stateRef.current = state;\n }\n return (\n <QueryClientProvider client={queryClient}>\n <TamboRegistryContext.Provider value={mockRegistry}>\n <TamboStreamProvider state={state} dispatch={dispatch}>\n {children}\n </TamboStreamProvider>\n </TamboRegistryContext.Provider>\n </QueryClientProvider>\n );\n };\n }\n\n beforeEach(() => {\n queryClient = new QueryClient({\n defaultOptions: {\n queries: { retry: false },\n },\n });\n jest.mocked(useTamboClient).mockReturnValue(mockTamboClient);\n jest.mocked(useTamboQueryClient).mockReturnValue(queryClient);\n jest.clearAllMocks();\n delete (mockTamboClient.threads as any).update;\n });\n\n it(\"returns client from useTamboClient\", () => {\n const { result } = renderHook(() => useTambo(), {\n wrapper: TestWrapper,\n });\n\n expect(result.current.client).toBe(mockTamboClient);\n });\n\n it(\"returns registry functions\", () => {\n const { result } = renderHook(() => useTambo(), {\n wrapper: TestWrapper,\n });\n\n expect(result.current.registerComponent).toBe(\n mockRegistry.registerComponent,\n );\n expect(result.current.registerTool).toBe(mockRegistry.registerTool);\n expect(result.current.registerTools).toBe(mockRegistry.registerTools);\n expect(result.current.componentList).toBe(mockRegistry.componentList);\n expect(result.current.toolRegistry).toBe(mockRegistry.toolRegistry);\n });\n\n it(\"returns placeholder thread when no threadId provided\", () => {\n const { result } = renderHook(() => useTambo(), {\n wrapper: TestWrapper,\n });\n\n // Default state has placeholder thread for optimistic UI\n expect(result.current.thread).toBeDefined();\n expect(result.current.thread?.thread.id).toBe(\"placeholder\");\n expect(result.current.messages).toEqual([]);\n });\n\n it(\"returns thread state when switched to a thread\", () => {\n const { result } = renderHook(() => useTambo(), {\n wrapper: TestWrapper,\n });\n\n // Initialize and switch to thread\n act(() => {\n result.current.initThread(\"thread_123\");\n result.current.switchThread(\"thread_123\");\n });\n\n expect(result.current.thread).toBeDefined();\n expect(result.current.thread?.thread.id).toBe(\"thread_123\");\n expect(result.current.messages).toEqual([]);\n });\n\n it(\"returns default streaming state when thread not loaded\", () => {\n const { result } = renderHook(() => useTambo(), {\n wrapper: TestWrapper,\n });\n\n expect(result.current.streamingState).toEqual({ status: \"idle\" });\n expect(result.current.isIdle).toBe(true);\n expect(result.current.isStreaming).toBe(false);\n expect(result.current.isWaiting).toBe(false);\n });\n\n it(\"returns thread streaming state when thread loaded\", () => {\n const { result } = renderHook(() => useTambo(), {\n wrapper: TestWrapper,\n });\n\n // Initialize and switch to thread\n act(() => {\n result.current.initThread(\"thread_123\");\n result.current.switchThread(\"thread_123\");\n });\n\n expect(result.current.streamingState.status).toBe(\"idle\");\n expect(result.current.isIdle).toBe(true);\n expect(result.current.isStreaming).toBe(false);\n expect(result.current.isWaiting).toBe(false);\n });\n\n it(\"provides dispatch function for advanced usage\", () => {\n const { result } = renderHook(() => useTambo(), {\n wrapper: TestWrapper,\n });\n\n expect(typeof result.current.dispatch).toBe(\"function\");\n });\n\n it(\"provides thread management functions\", () => {\n const { result } = renderHook(() => useTambo(), {\n wrapper: TestWrapper,\n });\n\n expect(typeof result.current.initThread).toBe(\"function\");\n expect(typeof result.current.switchThread).toBe(\"function\");\n expect(typeof result.current.startNewThread).toBe(\"function\");\n });\n\n it(\"initializes and switches threads\", () => {\n const { result } = renderHook(() => useTambo(), {\n wrapper: TestWrapper,\n });\n\n // Initially has placeholder thread for optimistic UI\n expect(result.current.currentThreadId).toBe(\"placeholder\");\n expect(result.current.thread).toBeDefined();\n expect(result.current.thread?.thread.id).toBe(\"placeholder\");\n\n // Initialize a new thread\n act(() => {\n result.current.initThread(\"new_thread_1\");\n });\n\n // Switch to the new thread\n act(() => {\n result.current.switchThread(\"new_thread_1\");\n });\n\n expect(result.current.currentThreadId).toBe(\"new_thread_1\");\n });\n\n it(\"starts new thread with generated ID\", () => {\n const { result } = renderHook(() => useTambo(), {\n wrapper: TestWrapper,\n });\n\n let newThreadId: string;\n act(() => {\n newThreadId = result.current.startNewThread();\n });\n\n expect(newThreadId!).toBe(\"placeholder\");\n expect(result.current.currentThreadId).toBe(newThreadId!);\n expect(result.current.thread).toBeDefined();\n });\n\n it(\"uses current thread when no threadId argument provided\", () => {\n const { result } = renderHook(() => useTambo(), {\n wrapper: TestWrapper,\n });\n\n // Initialize and switch to a thread\n act(() => {\n result.current.initThread(\"thread_123\");\n result.current.switchThread(\"thread_123\");\n });\n\n // Should use current thread from context (thread_123)\n expect(result.current.currentThreadId).toBe(\"thread_123\");\n expect(result.current.thread?.thread.id).toBe(\"thread_123\");\n });\n\n describe(\"component content transformation\", () => {\n const createComponentContent = (\n id: string,\n name: string,\n props: Record<string, unknown>,\n ): TamboComponentContent => ({\n type: \"component\",\n id,\n name,\n props,\n streamingState: \"done\",\n });\n\n it(\"adds renderedComponent to component content blocks\", () => {\n const state: StreamState = {\n threadMap: {\n thread_123: {\n thread: {\n id: \"thread_123\",\n messages: [\n {\n id: \"msg_1\",\n role: \"assistant\",\n content: [\n createComponentContent(\"comp_1\", \"TestComponent\", {\n title: \"Hello\",\n }),\n ],\n createdAt: new Date().toISOString(),\n },\n ],\n status: \"idle\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: { status: \"idle\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"thread_123\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithState(state),\n });\n\n expect(result.current.messages).toHaveLength(1);\n const content = result.current.messages[0].content[0];\n expect(content.type).toBe(\"component\");\n expect(\n (content as TamboComponentContent).renderedComponent,\n ).toBeDefined();\n });\n\n it(\"preserves non-component content blocks unchanged\", () => {\n const state: StreamState = {\n threadMap: {\n thread_123: {\n thread: {\n id: \"thread_123\",\n messages: [\n {\n id: \"msg_1\",\n role: \"assistant\",\n content: [\n { type: \"text\", text: \"Hello world\" },\n createComponentContent(\"comp_1\", \"TestComponent\", {\n title: \"Hi\",\n }),\n ],\n createdAt: new Date().toISOString(),\n },\n ],\n status: \"idle\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: { status: \"idle\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"thread_123\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithState(state),\n });\n\n expect(result.current.messages).toHaveLength(1);\n const textContent = result.current.messages[0].content[0];\n expect(textContent.type).toBe(\"text\");\n expect(textContent).toEqual({ type: \"text\", text: \"Hello world\" });\n\n const componentContent = result.current.messages[0].content[1];\n expect(componentContent.type).toBe(\"component\");\n expect(\n (componentContent as TamboComponentContent).renderedComponent,\n ).toBeDefined();\n });\n\n it(\"caches rendered components and returns same reference when props unchanged\", () => {\n const state: StreamState = {\n threadMap: {\n thread_123: {\n thread: {\n id: \"thread_123\",\n messages: [\n {\n id: \"msg_1\",\n role: \"assistant\",\n content: [\n createComponentContent(\"comp_1\", \"TestComponent\", {\n title: \"Hello\",\n }),\n ],\n createdAt: new Date().toISOString(),\n },\n ],\n status: \"idle\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: { status: \"idle\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"thread_123\",\n };\n\n const { result, rerender } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithState(state),\n });\n\n const firstRender = (\n result.current.messages[0].content[0] as TamboComponentContent\n ).renderedComponent;\n\n // Re-render with same state\n rerender();\n\n const secondRender = (\n result.current.messages[0].content[0] as TamboComponentContent\n ).renderedComponent;\n\n // Should return the same cached element reference\n expect(secondRender).toBe(firstRender);\n });\n\n it(\"handles empty props on components\", () => {\n const state: StreamState = {\n threadMap: {\n thread_123: {\n thread: {\n id: \"thread_123\",\n messages: [\n {\n id: \"msg_1\",\n role: \"assistant\",\n content: [\n createComponentContent(\"comp_1\", \"TestComponent\", {}),\n ],\n createdAt: new Date().toISOString(),\n },\n ],\n status: \"idle\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: { status: \"idle\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"thread_123\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithState(state),\n });\n\n const content = result.current.messages[0].content[0];\n expect(content.type).toBe(\"component\");\n expect(\n (content as TamboComponentContent).renderedComponent,\n ).toBeDefined();\n });\n\n it(\"handles undefined props on components\", () => {\n const state: StreamState = {\n threadMap: {\n thread_123: {\n thread: {\n id: \"thread_123\",\n messages: [\n {\n id: \"msg_1\",\n role: \"assistant\",\n content: [\n {\n type: \"component\",\n id: \"comp_1\",\n name: \"TestComponent\",\n props: undefined,\n streamingState: \"done\",\n },\n ],\n createdAt: new Date().toISOString(),\n },\n ],\n status: \"idle\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: { status: \"idle\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"thread_123\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithState(state),\n });\n\n const content = result.current.messages[0].content[0];\n expect(content.type).toBe(\"component\");\n expect(\n (content as TamboComponentContent).renderedComponent,\n ).toBeDefined();\n });\n\n it(\"handles multiple component content blocks in same message\", () => {\n const state: StreamState = {\n threadMap: {\n thread_123: {\n thread: {\n id: \"thread_123\",\n messages: [\n {\n id: \"msg_1\",\n role: \"assistant\",\n content: [\n createComponentContent(\"comp_1\", \"ComponentA\", {\n value: 1,\n }),\n createComponentContent(\"comp_2\", \"ComponentB\", {\n value: 2,\n }),\n createComponentContent(\"comp_3\", \"ComponentC\", {\n value: 3,\n }),\n ],\n createdAt: new Date().toISOString(),\n },\n ],\n status: \"idle\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: { status: \"idle\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"thread_123\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithState(state),\n });\n\n expect(result.current.messages[0].content).toHaveLength(3);\n result.current.messages[0].content.forEach((content) => {\n expect(content.type).toBe(\"component\");\n expect(\n (content as TamboComponentContent).renderedComponent,\n ).toBeDefined();\n });\n });\n\n it(\"uses currentThreadId from stream state\", () => {\n const state: StreamState = {\n threadMap: {\n placeholder: {\n thread: {\n id: \"placeholder\",\n messages: [\n {\n id: \"msg_1\",\n role: \"assistant\",\n content: [\n createComponentContent(\"comp_1\", \"TestComponent\", {\n title: \"Hello\",\n }),\n ],\n createdAt: new Date().toISOString(),\n },\n ],\n status: \"idle\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: { status: \"idle\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"placeholder\",\n };\n\n // No explicit threadId - uses currentThreadId from state\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithState(state),\n });\n\n // Component should render using the placeholder thread\n const content = result.current.messages[0].content[0];\n expect(content.type).toBe(\"component\");\n expect(\n (content as TamboComponentContent).renderedComponent,\n ).toBeDefined();\n });\n });\n\n describe(\"tool_use content transformation\", () => {\n it(\"adds computed properties to tool_use content\", () => {\n const state: StreamState = {\n threadMap: {\n thread_123: {\n thread: {\n id: \"thread_123\",\n messages: [\n {\n id: \"msg_1\",\n role: \"assistant\",\n content: [\n {\n type: \"tool_use\",\n id: \"tool_1\",\n name: \"getWeather\",\n input: { location: \"NYC\" },\n },\n ],\n createdAt: new Date().toISOString(),\n },\n ],\n status: \"idle\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: { status: \"idle\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"thread_123\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithState(state),\n });\n\n const content = result.current.messages[0]\n .content[0] as TamboToolUseContent;\n expect(content.type).toBe(\"tool_use\");\n expect(content.hasCompleted).toBe(false);\n expect(content.statusMessage).toBe(\"Calling getWeather\");\n expect(content.tamboDisplayProps).toBeDefined();\n });\n\n it(\"sets hasCompleted to true when matching tool_result exists\", () => {\n const state: StreamState = {\n threadMap: {\n thread_123: {\n thread: {\n id: \"thread_123\",\n messages: [\n {\n id: \"msg_1\",\n role: \"assistant\",\n content: [\n {\n type: \"tool_use\",\n id: \"tool_1\",\n name: \"getWeather\",\n input: { location: \"NYC\" },\n },\n ],\n createdAt: new Date().toISOString(),\n },\n {\n id: \"msg_2\",\n role: \"user\",\n content: [\n {\n type: \"tool_result\",\n toolUseId: \"tool_1\",\n content: [{ type: \"text\", text: \"Sunny\" }],\n },\n ],\n createdAt: new Date().toISOString(),\n },\n ],\n status: \"idle\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: { status: \"idle\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"thread_123\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithState(state),\n });\n\n const content = result.current.messages[0]\n .content[0] as TamboToolUseContent;\n expect(content.hasCompleted).toBe(true);\n expect(content.statusMessage).toBe(\"Called getWeather\");\n });\n\n it(\"uses _tambo_statusMessage when tool is in progress\", () => {\n const state: StreamState = {\n threadMap: {\n thread_123: {\n thread: {\n id: \"thread_123\",\n messages: [\n {\n id: \"msg_1\",\n role: \"assistant\",\n content: [\n {\n type: \"tool_use\",\n id: \"tool_1\",\n name: \"getWeather\",\n input: {\n location: \"NYC\",\n _tambo_statusMessage: \"Fetching weather for NYC...\",\n },\n },\n ],\n createdAt: new Date().toISOString(),\n },\n ],\n status: \"idle\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: { status: \"idle\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"thread_123\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithState(state),\n });\n\n const content = result.current.messages[0]\n .content[0] as TamboToolUseContent;\n expect(content.statusMessage).toBe(\"Fetching weather for NYC...\");\n expect(content.tamboDisplayProps?._tambo_statusMessage).toBe(\n \"Fetching weather for NYC...\",\n );\n });\n\n it(\"uses _tambo_completionStatusMessage when tool is completed\", () => {\n const state: StreamState = {\n threadMap: {\n thread_123: {\n thread: {\n id: \"thread_123\",\n messages: [\n {\n id: \"msg_1\",\n role: \"assistant\",\n content: [\n {\n type: \"tool_use\",\n id: \"tool_1\",\n name: \"getWeather\",\n input: {\n location: \"NYC\",\n _tambo_statusMessage: \"Fetching weather...\",\n _tambo_completionStatusMessage: \"Got weather for NYC\",\n },\n },\n ],\n createdAt: new Date().toISOString(),\n },\n {\n id: \"msg_2\",\n role: \"user\",\n content: [\n {\n type: \"tool_result\",\n toolUseId: \"tool_1\",\n content: [{ type: \"text\", text: \"Sunny\" }],\n },\n ],\n createdAt: new Date().toISOString(),\n },\n ],\n status: \"idle\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: { status: \"idle\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"thread_123\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithState(state),\n });\n\n const content = result.current.messages[0]\n .content[0] as TamboToolUseContent;\n expect(content.hasCompleted).toBe(true);\n expect(content.statusMessage).toBe(\"Got weather for NYC\");\n });\n\n it(\"filters _tambo_* properties from input\", () => {\n const state: StreamState = {\n threadMap: {\n thread_123: {\n thread: {\n id: \"thread_123\",\n messages: [\n {\n id: \"msg_1\",\n role: \"assistant\",\n content: [\n {\n type: \"tool_use\",\n id: \"tool_1\",\n name: \"getWeather\",\n input: {\n location: \"NYC\",\n units: \"celsius\",\n _tambo_statusMessage: \"Fetching...\",\n _tambo_completionStatusMessage: \"Done\",\n },\n },\n ],\n createdAt: new Date().toISOString(),\n },\n ],\n status: \"idle\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: { status: \"idle\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"thread_123\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithState(state),\n });\n\n const content = result.current.messages[0]\n .content[0] as TamboToolUseContent;\n // Input should only have non-_tambo_ properties\n expect(content.input).toEqual({ location: \"NYC\", units: \"celsius\" });\n expect(content.input._tambo_statusMessage).toBeUndefined();\n expect(content.input._tambo_completionStatusMessage).toBeUndefined();\n });\n\n it(\"handles tool_use with empty input\", () => {\n const state: StreamState = {\n threadMap: {\n thread_123: {\n thread: {\n id: \"thread_123\",\n messages: [\n {\n id: \"msg_1\",\n role: \"assistant\",\n content: [\n {\n type: \"tool_use\",\n id: \"tool_1\",\n name: \"getCurrentTime\",\n input: {},\n },\n ],\n createdAt: new Date().toISOString(),\n },\n ],\n status: \"idle\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: { status: \"idle\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"thread_123\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithState(state),\n });\n\n const content = result.current.messages[0]\n .content[0] as TamboToolUseContent;\n expect(content.input).toEqual({});\n expect(content.hasCompleted).toBe(false);\n expect(content.statusMessage).toBe(\"Calling getCurrentTime\");\n });\n\n it(\"handles tool_use with undefined input\", () => {\n const state: StreamState = {\n threadMap: {\n thread_123: {\n thread: {\n id: \"thread_123\",\n messages: [\n {\n id: \"msg_1\",\n role: \"assistant\",\n content: [\n {\n type: \"tool_use\",\n id: \"tool_1\",\n name: \"getCurrentTime\",\n input: undefined,\n } as unknown as TamboToolUseContent,\n ],\n createdAt: new Date().toISOString(),\n },\n ],\n status: \"idle\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: { status: \"idle\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"thread_123\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithState(state),\n });\n\n const content = result.current.messages[0]\n .content[0] as TamboToolUseContent;\n expect(content.input).toEqual({});\n expect(content.hasCompleted).toBe(false);\n });\n\n it(\"handles multiple tool_use blocks with different completion states\", () => {\n const state: StreamState = {\n threadMap: {\n thread_123: {\n thread: {\n id: \"thread_123\",\n messages: [\n {\n id: \"msg_1\",\n role: \"assistant\",\n content: [\n {\n type: \"tool_use\",\n id: \"tool_1\",\n name: \"getWeather\",\n input: { location: \"NYC\" },\n },\n {\n type: \"tool_use\",\n id: \"tool_2\",\n name: \"getTime\",\n input: { timezone: \"EST\" },\n },\n ],\n createdAt: new Date().toISOString(),\n },\n {\n id: \"msg_2\",\n role: \"user\",\n content: [\n {\n type: \"tool_result\",\n toolUseId: \"tool_1\",\n content: [{ type: \"text\", text: \"Sunny\" }],\n },\n // tool_2 has no result yet\n ],\n createdAt: new Date().toISOString(),\n },\n ],\n status: \"idle\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: { status: \"idle\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"thread_123\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithState(state),\n });\n\n const tool1 = result.current.messages[0]\n .content[0] as TamboToolUseContent;\n const tool2 = result.current.messages[0]\n .content[1] as TamboToolUseContent;\n\n expect(tool1.hasCompleted).toBe(true);\n expect(tool1.statusMessage).toBe(\"Called getWeather\");\n\n expect(tool2.hasCompleted).toBe(false);\n expect(tool2.statusMessage).toBe(\"Calling getTime\");\n });\n });\n\n describe(\"cancelRun\", () => {\n it(\"sets thread to idle and lastRunCancelled to true when cancelled\", async () => {\n const initialState: StreamState = {\n threadMap: {\n thread_123: {\n thread: {\n id: \"thread_123\",\n messages: [],\n status: \"streaming\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: { status: \"streaming\", runId: \"run_456\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"thread_123\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithRealReducer(initialState),\n });\n\n // Before cancel: streaming and lastRunCancelled is false\n expect(result.current.isStreaming).toBe(true);\n expect(result.current.isIdle).toBe(false);\n expect(result.current.thread?.thread.lastRunCancelled).toBe(false);\n\n await act(async () => {\n await result.current.cancelRun();\n });\n\n // After cancel: idle and lastRunCancelled is true\n expect(result.current.isStreaming).toBe(false);\n expect(result.current.isIdle).toBe(true);\n expect(result.current.thread?.thread.lastRunCancelled).toBe(true);\n\n // Verify API was called to cancel the run\n expect(mockTamboClient.threads.runs.delete).toHaveBeenCalledWith(\n \"run_456\",\n { threadId: \"thread_123\" },\n );\n });\n\n it(\"is a no-op when there is no active run\", async () => {\n const initialState: StreamState = {\n threadMap: {\n thread_123: {\n thread: {\n id: \"thread_123\",\n messages: [],\n status: \"idle\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: { status: \"idle\" }, // No runId\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"thread_123\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithRealReducer(initialState),\n });\n\n // Idle before\n expect(result.current.isIdle).toBe(true);\n expect(result.current.thread?.thread.lastRunCancelled).toBe(false);\n\n await act(async () => {\n await result.current.cancelRun();\n });\n\n // Still idle, lastRunCancelled unchanged\n expect(result.current.isIdle).toBe(true);\n expect(result.current.thread?.thread.lastRunCancelled).toBe(false);\n\n // API should not have been called\n expect(mockTamboClient.threads.runs.delete).not.toHaveBeenCalled();\n });\n\n it(\"is a no-op when on a placeholder thread\", async () => {\n const initialState: StreamState = {\n threadMap: {\n placeholder: {\n thread: {\n id: \"placeholder\",\n messages: [],\n status: \"streaming\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: { status: \"streaming\", runId: \"run_123\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"placeholder\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithRealReducer(initialState),\n });\n\n // Before: streaming on placeholder\n expect(result.current.isStreaming).toBe(true);\n expect(result.current.thread?.thread.lastRunCancelled).toBe(false);\n\n await act(async () => {\n await result.current.cancelRun();\n });\n\n // After: state should be unchanged (placeholder threads are skipped)\n expect(result.current.isStreaming).toBe(true);\n expect(result.current.thread?.thread.lastRunCancelled).toBe(false);\n\n // API should not have been called for placeholder threads\n expect(mockTamboClient.threads.runs.delete).not.toHaveBeenCalled();\n });\n\n it(\"still updates local state even if API call fails\", async () => {\n const consoleWarnSpy = jest\n .spyOn(console, \"warn\")\n .mockImplementation(() => {});\n\n // Make the API call fail\n jest\n .mocked(mockTamboClient.threads.runs.delete)\n .mockRejectedValueOnce(new Error(\"Network error\"));\n\n const initialState: StreamState = {\n threadMap: {\n thread_123: {\n thread: {\n id: \"thread_123\",\n messages: [],\n status: \"streaming\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n },\n streaming: { status: \"streaming\", runId: \"run_456\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"thread_123\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithRealReducer(initialState),\n });\n\n await act(async () => {\n await result.current.cancelRun();\n });\n\n // Local state should still be updated (optimistic update)\n expect(result.current.isIdle).toBe(true);\n expect(result.current.thread?.thread.lastRunCancelled).toBe(true);\n\n // Warning should have been logged\n expect(consoleWarnSpy).toHaveBeenCalledWith(\n \"Failed to cancel run on server:\",\n expect.any(Error),\n );\n\n consoleWarnSpy.mockRestore();\n });\n });\n\n describe(\"updateThreadName\", () => {\n it(\"updates local thread name and invalidates caches on success\", async () => {\n const mockUpdate = jest.fn().mockResolvedValue({});\n // TypeScript SDK will be updated to include this method\n (mockTamboClient.threads as any).update = mockUpdate;\n\n const invalidateQueriesSpy = jest.spyOn(queryClient, \"invalidateQueries\");\n\n const initialState: StreamState = {\n threadMap: {\n thread_456: {\n thread: {\n id: \"thread_456\",\n messages: [],\n status: \"idle\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n name: \"Old Name\",\n },\n streaming: { status: \"idle\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"thread_456\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithRealReducer(initialState),\n });\n\n await act(async () => {\n await result.current.updateThreadName(\"thread_456\", \"My New Thread\");\n });\n\n expect(mockUpdate).toHaveBeenCalledWith(\"thread_456\", {\n name: \"My New Thread\",\n userKey: undefined,\n });\n\n expect(result.current.thread?.thread.name).toBe(\"My New Thread\");\n const invalidatedKeys = invalidateQueriesSpy.mock.calls\n .map(([arg]) => (arg as any).queryKey)\n .filter(Boolean);\n expect(invalidatedKeys).toContainEqual([\"v1-threads\", \"list\"]);\n expect(invalidatedKeys).toContainEqual([\"v1-threads\", \"thread_456\"]);\n });\n\n it(\"does not create local thread state when thread isn't loaded\", async () => {\n const mockUpdate = jest.fn().mockResolvedValue({});\n // TypeScript SDK will be updated to include this method\n (mockTamboClient.threads as any).update = mockUpdate;\n\n const invalidateQueriesSpy = jest.spyOn(queryClient, \"invalidateQueries\");\n\n // Track the internal StreamState from the real reducer so we can assert we\n // don't create a local thread entry for threads that haven't been loaded.\n const stateRef: React.MutableRefObject<StreamState | undefined> = {\n current: undefined,\n };\n const initialState: StreamState = {\n threadMap: {},\n currentThreadId: \"placeholder\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithRealReducer(initialState, stateRef),\n });\n\n await act(async () => {\n await result.current.updateThreadName(\"thread_789\", \"New Title\");\n });\n\n expect(mockUpdate).toHaveBeenCalledWith(\"thread_789\", {\n name: \"New Title\",\n userKey: undefined,\n });\n const invalidatedKeys = invalidateQueriesSpy.mock.calls\n .map(([arg]) => (arg as any).queryKey)\n .filter(Boolean);\n expect(invalidatedKeys).toContainEqual([\"v1-threads\", \"list\"]);\n expect(invalidatedKeys).toContainEqual([\"v1-threads\", \"thread_789\"]);\n\n expect(stateRef.current?.threadMap.thread_789).toBeUndefined();\n\n act(() => {\n result.current.switchThread(\"thread_789\");\n });\n\n expect(result.current.thread).toBeUndefined();\n });\n\n it(\"propagates errors and does not update local state\", async () => {\n const mockUpdate = jest\n .fn()\n .mockRejectedValue(new Error(\"Network error\"));\n // TypeScript SDK will be updated to include this method\n (mockTamboClient.threads as any).update = mockUpdate;\n\n const invalidateQueriesSpy = jest.spyOn(queryClient, \"invalidateQueries\");\n\n const initialState: StreamState = {\n threadMap: {\n thread_456: {\n thread: {\n id: \"thread_456\",\n messages: [],\n status: \"idle\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n lastRunCancelled: false,\n name: \"Old Name\",\n },\n streaming: { status: \"idle\" },\n accumulatingToolArgs: {},\n },\n },\n currentThreadId: \"thread_456\",\n };\n\n const { result } = renderHook(() => useTambo(), {\n wrapper: createWrapperWithRealReducer(initialState),\n });\n\n let caughtError: unknown;\n await act(async () => {\n try {\n await result.current.updateThreadName(\"thread_456\", \"My New Thread\");\n } catch (error) {\n caughtError = error;\n }\n });\n\n expect(caughtError).toBeInstanceOf(Error);\n expect((caughtError as Error).message).toBe(\"Network error\");\n expect(result.current.thread?.thread.name).toBe(\"Old Name\");\n expect(invalidateQueriesSpy).not.toHaveBeenCalled();\n });\n });\n});\n"]}