import { PlatformResponse, DelegationActivationPayload, RecommendationReportPayload } from '../types/index'; export interface AdMeshRecommendationsProps { /** Optional callback when recommendations are shown */ onRecommendationsShown?: (messageId: string, recommendation: PlatformResponse | null) => void; /** Optional callback on error */ onError?: (error: Error) => void; /** * Message ID for per-message recommendations. * * This is the primary identifier for fetching recommendations for a specific message. */ messageId?: string; /** * User query text for generating recommendations. * * This is the query that will be used to fetch recommendations from the backend. * Typically the user's question or search query. * * IMPORTANT: This should be a non-empty string. If not provided or empty, * the component will skip rendering to prevent 400 Bad Request errors. * The backend requires a valid query parameter. */ query?: string; /** Legacy bridge CTA callback; prefer onStartDelegation. */ onPasteToInput?: (content: string) => void; /** Called when the SDK needs host approval before starting a delegated brand flow. */ onDelegationConsent?: (recommendation: PlatformResponse) => boolean | Promise; /** Called with normalized delegation metadata after consent/engagement. */ onDelegationActivated?: (payload: DelegationActivationPayload) => void | Promise; /** Called after consent is granted so the host can create/open the delegation session. */ onStartDelegation?: (recommendation: PlatformResponse) => void | Promise; /** Called when the user reports a recommendation. */ onRecommendationReport?: (payload: RecommendationReportPayload) => void | Promise; /** * Optional container ID for follow-up suggestions. * When provided and the recommendation includes a followup_suggestion, * the SDK will automatically render the follow-up in this container. */ followups_container_id?: string; /** * Callback to execute query when follow-up is selected (required for follow-up functionality). * When a user clicks on a follow-up suggestion, this callback is invoked with the followup_suggestion.query. * This allows the platform to continue the conversation with the sponsored follow-up query. */ onExecuteQuery?: (query: string) => void | Promise; /** * Callback when a sponsored followup is detected. * This allows third-party applications to integrate the sponsored followup query into their own * followup suggestions UI (e.g., adding to a suggestions list, related questions section, etc.). * * When a user clicks the followup suggestion, the application should: * 1. Fire engagement tracking by calling the followupEngagementUrl * 2. Execute the followupQuery (e.g., submit it as a new user query) * * @param followupQuery - The sponsored followup query text to display to the user * @param followupEngagementUrl - The engagement tracking URL to call when user clicks the followup * @param recommendationId - The recommendation ID for tracking and correlation * * @example * ```tsx * { * // Add to your suggestions list * setSuggestions(prev => [...prev, { * text: query, * sponsored: true, * engagementUrl, * recommendationId: recId * }]); * }} * /> * ``` */ onFollowupDetected?: (followupSuggestion: any, // Will be updated to proper type later recommendationId: string) => void; /** * Signal indicating if the followup container is ready in the DOM. * * Useful for scenarios where the container is rendered conditionally or after a delay (e.g. streaming). * If provided, the component will wait until this is true before attempting to attach the portal. */ isContainerReady?: boolean; /** * Optional user ID to override the context-provided user ID. * Useful for per-message or specific user tracking scenarios. */ userId?: string; /** * Optional pre-fetched canonical platform result from an upstream backend flow. * When provided, the component reuses this payload and skips calling /aip/context. */ initialRecommendation?: PlatformResponse; /** * Whether the rendered recommendation card should fire its primary exposure URL. * Defaults to true. Set false when the recommendation came from a sponsored follow-up click * and the click should only count as follow-up engagement. */ triggerExposureUrl?: boolean; } /** * AdMeshRecommendations - Citation/Product Format Recommendation Display * * Displays recommendations as a separate UI component. Handles all the complexity: * - Uses provided messageId directly * - Generates container IDs for recommendations * - Calls SDK's showRecommendations() * * For Weave Ad Format (where AdMesh links are embedded in LLM response), * use WeaveAdFormatContainer component instead. * * @example * ```tsx * // Per-message recommendations with messageId * * {messages.map((msg) => ( *
* {msg.content} * {msg.role === 'assistant' && ( * * )} *
* ))} *
* ``` * * @example * ```tsx * // Format is auto-detected from brand agent's preferred_format * * * * * ``` */ export declare const AdMeshRecommendations: ({ onRecommendationsShown, onError, messageId, query, userId: propUserId, initialRecommendation, triggerExposureUrl, followups_container_id, onPasteToInput, onDelegationConsent, onDelegationActivated, onStartDelegation, onRecommendationReport, onExecuteQuery, onFollowupDetected, isContainerReady, }: AdMeshRecommendationsProps) => import("react/jsx-runtime").JSX.Element | null; export default AdMeshRecommendations; //# sourceMappingURL=AdMeshRecommendations.d.ts.map