/**
 * Agent Dialog Communication Types
 *
 * This module defines the types for the universal communication channel
 * between agents and UI dialogs.
 */
/**
 * Request from agent to open a dialog
 */
export interface AgentDialogRequest {
    /** Type of dialog to open (e.g., "component-type-selector") */
    dialogType: string;
    /** Unique identifier for this request, used to match response */
    callbackId: string;
    /** ID of the agent making the request */
    agentId?: string;
    /** Optional model-emitted tool call ID that opened this dialog */
    toolCallId?: string;
    /** Optional target browser session for automatic dialogs */
    targetSessionId?: string;
    /** Dialog-specific parameters */
    parameters?: Record<string, unknown>;
    /** Optional title for the dialog */
    title?: string;
    /** Optional description/instructions for the dialog */
    description?: string;
}
/**
 * Response from UI back to agent with dialog result
 */
export interface AgentDialogResponse {
    /** The callback ID from the original request */
    callbackId: string;
    /** Whether the user cancelled the dialog */
    cancelled: boolean;
    /** The result data as JSON string */
    resultJson?: string;
    /** Optional error message */
    error?: string;
}
export type CapturePageScreenshotScope = "viewport" | "editor-ui" | "selection" | "component" | "component-range" | "page";
export interface CapturePageScreenshotParameters {
    scope?: CapturePageScreenshotScope;
    fromComponentId?: string;
    toComponentId?: string;
    padding?: number;
    targetContext?: CapturePageTargetContext;
}
export interface CapturePageTargetContext {
    itemId?: string;
    itemName?: string;
    itemPath?: string;
    language?: string;
    version?: number;
    site?: string;
    device?: string;
    activeWorkspace?: string;
}
export interface CapturePageScreenshotBounds {
    x: number;
    y: number;
    width: number;
    height: number;
}
export interface CapturePageScreenshotResult {
    success: boolean;
    scope: CapturePageScreenshotScope;
    image?: {
        dataUrl: string;
        fileName: string;
        fileSize: number;
        contentType?: string;
    };
    bounds?: CapturePageScreenshotBounds;
    imageWidth?: number;
    imageHeight?: number;
    error?: string;
    errorCode?: string;
    requiredContext?: CapturePageTargetContext;
    currentContext?: CapturePageTargetContext;
    recommendedAction?: string;
}
export type CapturePageDomScope = "page";
export interface CapturePageDomParameters {
    targetContext?: CapturePageTargetContext;
}
export interface CapturePageDomResult {
    success: boolean;
    scope: CapturePageDomScope;
    html?: string;
    length?: number;
    documentTitle?: string;
    error?: string;
    errorCode?: string;
    requiredContext?: CapturePageTargetContext;
    currentContext?: CapturePageTargetContext;
    recommendedAction?: string;
}
/**
 * Selection mode for the component type selector
 * - "placeholder": Shows only component types valid for available placeholders (default)
 * - "all": Shows all component types registered for the current page/site
 */
export type ComponentTypeSelectorMode = "placeholder" | "all";
/**
 * Parameters for the component type selector dialog
 */
export interface ComponentTypeSelectorParameters {
    /**
     * Selection mode: "placeholder" (default) shows only component types valid for placeholders,
     * "all" shows all component types registered for the page/site.
     */
    mode?: ComponentTypeSelectorMode;
    /** Optional placeholder key to filter available component types (only used in "placeholder" mode) */
    placeholderKey?: string;
    /** Whether to allow multiple selection (default: true) */
    allowMultiple?: boolean;
    /** Optional minimum number of selections required */
    minSelections?: number;
    /** Optional maximum number of selections allowed */
    maxSelections?: number;
    /**
     * Pre-collected available component types (sent by backend for "all" mode).
     * If provided, the frontend will use these instead of collecting from page context.
     */
    availableTypes?: ComponentTypeSelection[];
}
/**
 * Represents a selected component type
 */
export interface ComponentTypeSelection {
    /** The rendering/component type ID */
    typeId: string;
    /** Display name of the component type */
    name: string;
    /** Icon URL for the component type */
    icon?: string;
    /** Optional group/category of the component */
    group?: string;
}
/**
 * Parameters for the questionnaire dialog
 */
export interface QuestionnaireParameters {
    /** The questions to display in the questionnaire */
    questions: QuestionnaireQuestion[];
    /** Optional task associated with the current agent, resolved by the backend */
    taskId?: string;
}
/**
 * A single question in a questionnaire
 */
export interface QuestionnaireQuestion {
    /** Unique identifier for this question */
    id: string;
    /** The question text to display */
    prompt: string;
    /** Available answer options for the question */
    options: QuestionnaireOption[];
    /** Optional default text to prefill for text/freetext questions */
    default?: string;
    /**
     * Question type.
     * - "options" (default): standard options / freetext question
     * - "item-picker": allow selecting one or more items from the content tree
     * - "item-collection": allow selecting multiple items and whether each includes subitems
     * - "file-upload": upload one or more files into the agent document store and/or the associated task
     */
    type?: "options" | "item-picker" | "item-collection" | "file-upload";
    /** For type:"file-upload": whether files should also be stored in the agent document store (default: true) */
    storeInAgentDocumentStore?: boolean;
    /** For type:"file-upload": also attach uploaded files to the current task when the agent has one */
    attachToTaskIfAvailable?: boolean;
    /** For type:"item-picker" or type:"item-collection": required root item ID or Sitecore path to start browsing from */
    rootItemId?: string;
    /** Backward-compatible alias for rootItemId */
    root?: string;
    /** For type:"item-picker" or type:"item-collection": optional template id filter (may be ignored by UI) */
    templateFilter?: string;
    /** For type:"item-picker" or type:"item-collection": optional item IDs to preselect when the dialog opens */
    preselectedItemIds?: string[];
    /** Whether multiple options can be selected (default: false = single select) */
    allowMultiple?: boolean;
    /** Whether to show a freetext input field (default: false) */
    allowFreetext?: boolean;
    /** Whether this question is optional (default: false = required) */
    optional?: boolean;
}
/**
 * An answer option for a questionnaire question
 */
export interface QuestionnaireOption {
    /** Unique identifier for this option */
    id: string;
    /** Display label for the option */
    label: string;
}
/**
 * Result from a completed questionnaire
 */
export interface QuestionnaireResult {
    /** Answers for each question */
    answers: QuestionnaireAnswer[];
}
/**
 * Represents a selected Sitecore item from an item-picker question.
 */
export interface SelectedItem {
    id: string;
    name?: string;
    path?: string;
    includeSubitems?: boolean;
}
/**
 * Uploaded file reference for a file-upload questionnaire answer.
 * This intentionally stores only metadata/reference data, not file bytes or extracted text.
 * `id`/`agentId` may be omitted when the file was attached to a task without being stored in the agent document store.
 */
export interface QuestionnaireUploadedDocument {
    id?: string;
    agentId?: string;
    fileName: string;
    fileSize: number;
    contentType?: string;
    uploadedBy?: string;
    uploadedDate?: string;
}
/**
 * Answer to a single question in a questionnaire
 */
export interface QuestionnaireAnswer {
    /** ID of the question this answer is for */
    questionId: string;
    /** IDs of the selected options (empty if only freetext provided) */
    selectedOptions: string[];
    /** Selected items for item-picker or item-collection questions (empty/undefined otherwise) */
    selectedItems?: SelectedItem[];
    /** Uploaded documents for file-upload questions (empty/undefined otherwise) */
    uploadedDocuments?: QuestionnaireUploadedDocument[];
    /** Freetext response (undefined if not provided) */
    freetext?: string;
}
/**
 * Dialog handler registration
 */
export interface DialogHandler<TParams = unknown, TResult = unknown> {
    /** Type identifier for this dialog */
    dialogType: string;
    /** Function that opens the dialog and returns the result */
    open: (request: AgentDialogRequest, params: TParams) => Promise<TResult | null>;
}
/**
 * Registry of available dialog handlers
 */
export type DialogHandlerRegistry = Map<string, DialogHandler<any, any>>;
/**
 * Props for the AgentDialogHandler component
 */
export interface AgentDialogHandlerProps {
    /** Callback when a dialog response needs to be sent */
    onSendResponse?: (response: AgentDialogResponse) => void;
}
/**
 * Context for dialog components to access common functionality
 */
export interface DialogContext {
    /** The original request that triggered the dialog */
    request: AgentDialogRequest;
    /** Function to close the dialog with a result */
    close: (result: unknown | null) => void;
    /** Function to cancel the dialog */
    cancel: () => void;
}
/**
 * WebSocket message types for dialog communication
 */
export declare const DIALOG_MESSAGE_TYPES: {
    readonly REQUEST: "agent-dialog-request";
    readonly RESPONSE: "agent-dialog-response";
};
/**
 * Supported dialog types
 */
export declare const DIALOG_TYPES: {
    readonly COMPONENT_TYPE_SELECTOR: "component-type-selector";
    readonly CAPTURE_PAGE_DOM: "capture-page-dom";
    readonly CAPTURE_PAGE_SCREENSHOT: "capture-page-screenshot";
    readonly QUESTIONNAIRE: "questionnaire";
};
export type DialogType = (typeof DIALOG_TYPES)[keyof typeof DIALOG_TYPES];
