/** * TamboThreadInputProvider - Shared Thread Input Context * * Provides shared input state across all components, enabling features like * suggestions to update the input field directly. * * This mirrors the TamboThreadInputProvider pattern from the legacy beta SDK. */ import React, { type PropsWithChildren } from "react"; import { type StagedImage } from "../../hooks/use-message-images.js"; import { type UseTamboMutationResult } from "../../hooks/react-query-hooks.js"; import type { ToolChoice } from "@tambo-ai/client"; export declare const INPUT_ERROR_MESSAGES: { readonly EMPTY: "Message cannot be empty"; readonly VALIDATION: "Invalid message format"; }; /** * Options for submitting a message */ export interface SubmitOptions { /** * 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; } /** * Context props for thread input state */ export interface TamboThreadInputContextProps extends Omit, "mutate" | "mutateAsync"> { /** Current value of the input field */ value: string; /** * Function to update the input value * @param value - New value for the input field */ setValue: React.Dispatch>; /** * Function to submit the current input value * @param options - Submission options * @returns Promise with the threadId */ submit: (options?: SubmitOptions) => Promise<{ threadId: string | undefined; }>; /** Currently staged images */ images: StagedImage[]; /** Add a single image */ addImage: (file: File) => Promise; /** Add multiple images */ addImages: (files: File[]) => Promise; /** Remove an image by id */ removeImage: (id: string) => void; /** Clear all staged images */ clearImages: () => void; /** Current thread ID being used for input (from stream state) */ threadId: string | undefined; /** Whether the input should be disabled (pending submission or not authenticated) */ isDisabled: boolean; } /** * Context for thread input state. * @internal */ export declare const TamboThreadInputContext: React.Context; /** * Provider that manages shared thread input state across all components. * * This ensures that useTamboThreadInput, useTamboSuggestions, and other components * all share the same input state. * @param props - Provider props * @param props.children - Child components * @returns Thread input context provider */ export declare function TamboThreadInputProvider({ children }: PropsWithChildren): React.JSX.Element; /** * Hook to access the shared thread input state. * * All components using this hook share the same input state, enabling * features like suggestions to update the input field directly. * @returns The shared thread input context * @throws {Error} If used outside TamboThreadInputProvider * @example * ```tsx * function ChatInput() { * const { value, setValue, submit, isPending } = useTamboThreadInput(); * * return ( *
{ e.preventDefault(); submit(); }}> * setValue(e.target.value)} * disabled={isPending} * /> * *
* ); * } * ``` */ export declare function useTamboThreadInput(): TamboThreadInputContextProps; //# sourceMappingURL=tambo-v1-thread-input-provider.d.ts.map