import type TamboAI from "@tambo-ai/typescript-sdk"; import type { Stream } from "@tambo-ai/typescript-sdk/core/streaming"; import { type TamboRegistryContext as TamboRegistry } from "../../providers/tambo-registry-provider"; import type { InitialInputMessage, InputMessage } from "../types/message"; import type { ToolChoice } from "@tambo-ai/client"; /** * Options for sending a message */ export interface SendMessageOptions { /** * The message to send */ message: InputMessage; /** * User message text for optimistic display. * If provided, synthetic AG-UI events will be dispatched to show * the user message in the thread immediately after getting the threadId. */ userMessageText?: string; /** * Enable debug logging for the stream */ debug?: boolean; /** * How the model should use tools. Defaults to "auto". * - "auto": Model decides whether to use tools * - "required": Model must use at least one tool * - "none": Model cannot use tools * - { name: "toolName" }: Model must use the specified tool */ toolChoice?: ToolChoice; } /** * Parameters for creating a run stream */ export interface CreateRunStreamParams { client: TamboAI; threadId: string | undefined; message: InputMessage; registry: TamboRegistry; userKey: string | undefined; /** * Previous run ID for continuing a thread with existing messages. * Required when threadId is provided and the thread has previous runs. */ previousRunId: string | undefined; /** * Additional context gathered from context helpers (including interactables). * Merged into the message's additionalContext before sending. */ additionalContext?: Record; /** * How the model should use tools. */ toolChoice?: ToolChoice; /** * Initial messages to seed the thread with when creating a new thread. * Only used when threadId is undefined (new thread creation). */ initialMessages?: InitialInputMessage[]; } /** * Stream types from the SDK */ type RunStream = Stream; type CreateStream = Stream; /** * Result from creating a run stream */ export interface CreateRunStreamResult { stream: RunStream | CreateStream; initialThreadId: string | undefined; } /** * Creates a run stream by calling the appropriate API method. * * If threadId is provided, runs on existing thread via client.threads.runs.run(). * If no threadId, creates new thread via client.threads.runs.create(). * @param params - The parameters for creating the run stream * @returns The stream and initial thread ID (undefined if creating new thread) */ export declare function createRunStream(params: CreateRunStreamParams): Promise; /** * Hook to send a message and handle streaming responses. * * This hook handles two scenarios: * - If threadId provided: runs on existing thread via client.threads.runs.run() * - If no threadId: creates new thread via client.threads.runs.create() * * The hook: * - Sends a user message to the API * - Streams AG-UI events in real-time * - Dispatches events to the stream reducer * - Extracts threadId from events when creating new thread * - Handles tool execution (Phase 6) * - Invalidates thread queries on completion * @param threadId - Optional thread ID to send message to. If not provided, creates new thread * @returns React Query mutation object with threadId in mutation result * @example * ```tsx * function ChatInput({ threadId }: { threadId?: string }) { * const sendMessage = useTamboSendMessage(threadId); * * const handleSubmit = async (text: string) => { * const result = await sendMessage.mutateAsync({ * message: { * role: "user", * content: [{ type: "text", text }], * }, * }); * * // If threadId wasn't provided, a new thread was created * if (!threadId) { * console.log("Created thread:", result.threadId); * } * }; * * return ( *
* * {sendMessage.isPending && } *
* ); * } * ``` */ export declare function useTamboSendMessage(threadId?: string): import("@tanstack/react-query").UseMutationResult<{ threadId: string | undefined; preMutationMessageCount: number; threadAlreadyHasName: boolean; }, Error, SendMessageOptions, unknown>; export {}; //# sourceMappingURL=use-tambo-v1-send-message.d.ts.map