import type TamboAI from "@tambo-ai/typescript-sdk"; import type { TamboAuthState } from "@tambo-ai/client"; import { type TamboRegistryContext as TamboRegistryContextType } from "../../providers/tambo-registry-provider.js"; import { useStreamDispatch, type ThreadManagement } from "../providers/tambo-v1-stream-context.js"; import type { ReactTamboThreadMessage } from "../types/message.js"; import type { StreamingState } from "@tambo-ai/client"; import { type ThreadState } from "@tambo-ai/client"; /** * Return type for useTambo hook */ export interface UseTamboReturn { /** * The Tambo API client instance */ client: TamboAI; /** * Current thread state for the given threadId, or undefined if not loaded */ thread: ThreadState | undefined; /** * Messages in the current thread. * Component content blocks include `renderedComponent` for direct rendering. */ messages: ReactTamboThreadMessage[]; /** * Current streaming state */ streamingState: StreamingState; /** * Whether the thread is currently streaming a response */ isStreaming: boolean; /** * Whether the thread is waiting for the AI to start responding */ isWaiting: boolean; /** * Whether the thread is idle (not streaming or waiting) */ isIdle: boolean; /** * Register a component with the registry */ registerComponent: TamboRegistryContextType["registerComponent"]; /** * Register a tool with the registry */ registerTool: TamboRegistryContextType["registerTool"]; /** * Register multiple tools with the registry */ registerTools: TamboRegistryContextType["registerTools"]; /** * The component registry (Map of name -> component definition) */ componentList: TamboRegistryContextType["componentList"]; /** * The tool registry (Map of name -> tool definition) */ toolRegistry: TamboRegistryContextType["toolRegistry"]; /** * Current thread ID (always available - uses "placeholder" for new threads) */ currentThreadId: string; /** * Initialize a new thread in the stream context */ initThread: ThreadManagement["initThread"]; /** * Switch the current active thread */ switchThread: ThreadManagement["switchThread"]; /** * Start a new thread (generates a temporary ID) */ startNewThread: ThreadManagement["startNewThread"]; /** * Dispatch function for stream events (advanced usage) */ dispatch: ReturnType; /** * Cancel the current run on this thread. * Optimistically updates local state and sends cancellation request to the API. * No-op if there's no active run or thread is a placeholder. */ cancelRun: () => Promise; /** * Current authentication state. * Use this to show auth-related UI or conditionally render features. */ authState: TamboAuthState; /** * Shorthand for `authState.status === "identified"`. * When true, the SDK is ready to make API calls. */ isIdentified: boolean; /** * Update a thread's name. * Useful for implementing manual thread renaming UI in history sidebars. * Cache invalidation is best-effort; failures will be logged and won't reject. * @param threadId - ID of the thread to rename * @param name - New name for the thread * @returns Promise that resolves when the update completes */ updateThreadName: (threadId: string, name: string) => Promise; } /** * * @returns The combined Tambo context */ export declare function useTambo(): UseTamboReturn; //# sourceMappingURL=use-tambo-v1.d.ts.map