import React from "react"; import type { InteractableConfig } from "../../hoc/with-tambo-interactable.js"; import type { TamboThreadMessage } from "../types/message.js"; /** * Metadata for interactable components. * Used when a component is wrapped with withTamboInteractable. */ export interface InteractableMetadata extends InteractableConfig { /** Unique identifier for this interactable instance */ id: string; } /** * Message with optional interactable metadata merged in by the provider. * Used as the context type so consumers can access both the message and * any interactable information attached by withTamboInteractable. */ type MessageWithMetadata = TamboThreadMessage & { interactableMetadata?: InteractableMetadata; }; export declare const TamboMessageContext: React.Context; export interface TamboMessageProviderProps { children: React.ReactNode; message: TamboThreadMessage; /** Optional interactable metadata for components wrapped with withInteractable */ interactableMetadata?: InteractableMetadata; } /** * Wraps all components so that they can find what message they are in. * Also supports optional interactable metadata for components wrapped with withInteractable. * @param props - Props for the TamboMessageProvider * @param props.children - The children to wrap * @param props.message - The message object * @param props.interactableMetadata - Optional interactable component metadata * @returns The wrapped component */ export declare const TamboMessageProvider: React.FC; /** * Wraps a component with a TamboMessageProvider - this allows the provider * to be used outside of a TSX file. * @param children - The children to wrap * @param message - The message object * @param interactableMetadata - Optional interactable metadata * @returns The wrapped component */ export declare function wrapWithTamboMessageProvider(children: React.ReactNode, message: TamboThreadMessage, interactableMetadata?: InteractableMetadata): React.JSX.Element; /** * Hook used inside a component wrapped with TamboMessageProvider, to get * the current message. * @returns The current message that is used to render the component */ export declare const useTamboCurrentMessage: () => MessageWithMetadata; /** * Component info extracted from the current message and interactable context. * Provides a unified interface for accessing component metadata. */ export interface TamboCurrentComponent { /** Component name from the message */ componentName?: string; /** Component props from the message */ props?: Record; /** Interactable ID (only present for components wrapped with withInteractable) */ interactableId?: string; /** Description (only present for components wrapped with withInteractable) */ description?: string; /** Thread ID (not available on messages directly) */ threadId?: string; } /** * Hook to access the current component information from the message context. * Provides a unified interface for both AI-generated and interactable components. * * Component info is derived from content blocks rather than * top-level message fields. * * **Use this hook when you need component metadata regardless of the context.** * @returns Component info including name, props, and interactable metadata if available, or null if used outside TamboMessageProvider * @example * ```tsx * function MyInlineEditor() { * const component = useTamboCurrentComponent(); * * if (!component) return null; // Not inside a component * * return ( *
* Editing: {component.componentName} * {component.interactableId && ID: {component.interactableId}} *
* ); * } * ``` */ export declare const useTamboCurrentComponent: () => TamboCurrentComponent | null; export {}; //# sourceMappingURL=use-tambo-current-message.d.ts.map