import type { DefaultChatTransport } from '../../lib/ai-lite'; import type { UIMessage } from '../../lib/chat'; import type { SendEventForHits } from '../../lib/utils'; import type { Connector, WidgetRenderState } from '../../types'; import type { ChatAgentRequestOptions } from '../chat/connectChat'; /** * The Rule context that ties the Rules Agent Studio manages for this agent to * the search. The Dashboard derives the same value, so the two must agree. */ export declare function getResultCardRuleContext(agentId: string): string; export type ResultCardStatus = /** No Rule matched the current search, or the query is too short. */ 'hidden' /** Activated, no answer text yet: debouncing, requesting, or awaiting the first token. */ | 'loading' | 'streaming' | 'complete' | 'failed'; export type ResultCardRenderState = { status: ResultCardStatus; /** The query the answer is about. */ query: string; /** * The card's conversation: the user turn holding the query, then the * assistant answer as it streams. */ messages: TUiMessage[]; /** The error of the latest failed generation. */ error: Error | undefined; /** Follow-up suggestions sent by the agent with the answer. */ suggestions?: string[]; /** Sends the request again. Always a new request, never a resume. */ retry: () => void; /** * Whether a `chat` widget using the same `agentId` is mounted on this index, * i.e. whether `continueInChat` has somewhere to go. */ canContinueInChat: boolean; /** * Hands the conversation to the `chat` widget on this index and opens it. * When `message` is given (e.g. a follow-up suggestion), it is sent as the * next turn. */ continueInChat: (message?: string) => void; /** Whether a long answer shows in full rather than clipped with a scroll. */ expanded: boolean; setExpanded: (expanded: boolean) => void; /** Sends an event to the Insights middleware. */ sendEvent: SendEventForHits; }; type ChatTransportOptions = ConstructorParameters[0]; /** Either a custom `transport` or `requestOptions` for the built-in one. */ export type ResultCardTransport = { /** Custom endpoint, with the same shape as the `chat` widget's `transport`. */ transport: ChatTransportOptions; requestOptions?: never; } | { transport?: never; /** Headers or query parameters for the built-in Agent Studio transport. */ requestOptions?: ChatAgentRequestOptions; }; export type ResultCardConnectorParams = ResultCardTransport & { /** * ID of the agent configured in the Algolia dashboard. Required even with a * custom `transport`: the Rule context sent with each search derives from it. */ agentId: string; }; export type ResultCardWidgetDescription = { $$type: 'ais.resultCard'; renderState: ResultCardRenderState; indexRenderState: { resultCard: WidgetRenderState; }; }; export type ResultCardConnector = Connector; declare const connectResultCard: ResultCardConnector; export default connectResultCard;