import type { Connector, WidgetRenderState } from '../../types'; /** * A record selected for comparison. Only `objectID` is required — the other * attributes (e.g. `name`, `title`) are used to label the item in the UI and * in the default comparison message. */ export type CompareItem = { objectID: string; } & Record; export type CompareConnectorParams = { /** * Minimum number of items required before a comparison can start. * @default 2 */ minItems?: number; /** * Maximum number of items that can be selected. Adding an item beyond the * limit is a no-op until one is removed. * @default 3 */ maxItems?: number; /** * ID of the comparison configuration created in the Agent Studio dashboard * (Components > Comparison). When set, the chat hand-off sends the * `__ALGOLIA_COMPARISON___` placeholder instead of a prose * message: the backend replaces it with the configuration's instructions * for the agent and a natural-language message for the transcript. Leave * unset to send the default prose message, which works with the default * shopping assistant prompt — no agent configuration required. */ configurationId?: string; /** * Builds the user message sent to the chat when the comparison starts. * Defaults to the `configurationId` placeholder when one is set, and to a * message that names each selected item (name/title and objectID) so the * agent can retrieve them from the index and invoke the * `algolia_compare_products` tool otherwise. Provide your own to change the * initial prompt while keeping the rest of the flow. */ getComparisonMessage?: (items: CompareItem[]) => string; }; export type CompareRenderState = { /** * Ordered selection, one entry per record (insertion order). */ items: CompareItem[]; /** * Whether a record is currently selected. */ isSelected: (objectID: string) => boolean; /** * Adds a record to the selection. No-op when the record is already selected * or when the `maxItems` limit is reached. */ addItem: (item: CompareItem) => void; /** * Removes a record from the selection. */ removeItem: (objectID: string) => void; /** * Adds the record when unselected, removes it otherwise. */ toggleItem: (item: CompareItem) => void; /** * Clears the whole selection. */ clearItems: () => void; /** * Whether more items can be added (the `maxItems` limit is not reached). */ canAddItems: boolean; /** * Whether a comparison can start (at least `minItems` items are selected). */ canCompare: boolean; /** * The resolved `minItems` value. */ minItems: number; /** * The resolved `maxItems` value. */ maxItems: number; /** * Opens the sibling `chat` widget and sends the comparison message for the * current selection. Returns `true` when the message was submitted (`false` * when the selection is too small, the chat is missing or busy). */ compare: () => boolean; widgetParams: CompareConnectorParams; }; export type CompareWidgetDescription = { $$type: 'ais.compare'; renderState: CompareRenderState; indexRenderState: { compare: WidgetRenderState; }; }; export type CompareConnector = Connector; /** * Builds the placeholder message for a dashboard-configured comparison. The * Agent Studio backend resolves it against the agent's comparison * configuration: the LLM gets the configured instructions and the transcript * keeps a natural-language message naming the selection. */ export declare function getComparisonPlaceholderMessage(configurationId: string): string; /** * Builds the default comparison message. It names each selected item so the * agent can ground the comparison: it re-retrieves the records with * `algolia_search_index` and renders them with the builtin * `algolia_compare_products` tool. Works with the default shopping assistant * prompt — no agent configuration required. */ export declare function getDefaultComparisonMessage(items: CompareItem[]): string; /** * Compare connector. * * Owns the "products selected for comparison" state and the hand-off into the * chat: `compare()` opens the sibling `chat` widget and sends a comparison * message naming the selected records, which the agent answers with the * grounded `algolia_compare_products` table. * * The selection is shared across all `compare` widgets mounted on the same * InstantSearch instance, so per-hit "Compare" toggles and the `compareBar` * widget stay in sync. The widget is marked with `opensChat`, so it satisfies * the `chat` widget's entry-point validation. */ declare const connectCompare: CompareConnector; export default connectCompare;