import type { TUserPrompt } from './common';
import type { AndroidDeviceOpt, IOSDeviceOpt } from './device';
import type { AgentOpt, LocateResultElement } from './types';
import type { UIContext } from './types';
export interface LocateOption {
    prompt?: TUserPrompt;
    deepThink?: boolean;
    cacheable?: boolean;
    xpath?: string;
    uiContext?: UIContext;
    fileChooserAccept?: string | string[];
}
export interface ServiceExtractOption {
    domIncluded?: boolean | 'visible-only';
    screenshotIncluded?: boolean;
    [key: string]: unknown;
}
export interface DetailedLocateParam extends LocateOption {
    prompt: TUserPrompt;
}
export type ScrollType = 'singleAction' | 'scrollToBottom' | 'scrollToTop' | 'scrollToRight' | 'scrollToLeft' | 'once' | 'untilBottom' | 'untilTop' | 'untilRight' | 'untilLeft';
export type ActionScrollParam = {
    direction?: 'down' | 'up' | 'right' | 'left';
    scrollType?: ScrollType;
    distance?: number | null;
    locate?: LocateResultElement;
};
export type ScrollParam = Omit<ActionScrollParam, 'locate'>;
export interface MidsceneYamlScript {
    target?: MidsceneYamlScriptWebEnv;
    web?: MidsceneYamlScriptWebEnv;
    android?: MidsceneYamlScriptAndroidEnv;
    ios?: MidsceneYamlScriptIOSEnv;
    computer?: MidsceneYamlScriptComputerEnv;
    interface?: MidsceneYamlScriptEnvGeneralInterface;
    config?: MidsceneYamlScriptConfig;
    agent?: MidsceneYamlScriptAgentOpt;
    tasks: MidsceneYamlTask[];
}
export interface MidsceneYamlTask {
    name: string;
    flow: MidsceneYamlFlowItem[];
    continueOnError?: boolean;
}
/**
 * Agent configuration options that can be specified in YAML scripts.
 *
 * This type includes serializable fields from AgentOpt, excluding non-serializable
 * fields like functions and complex objects. All fields are optional.
 *
 * @remarks
 * - testId priority: CLI parameter > YAML agent.testId > filename
 * - These settings apply to all platforms (Web, Android, iOS, Generic Interface)
 * - modelConfig is configured through environment variables, not in YAML
 *
 * @example
 * ```yaml
 * agent:
 *   testId: "checkout-test"
 *   groupName: "E2E Test Suite"
 *   generateReport: true
 *   replanningCycleLimit: 30
 *   cache:
 *     id: "checkout-cache"
 *     strategy: "read-write"
 * ```
 */
export type MidsceneYamlScriptAgentOpt = Pick<AgentOpt, 'testId' | 'groupName' | 'groupDescription' | 'generateReport' | 'autoPrintReportMsg' | 'reportFileName' | 'replanningCycleLimit' | 'aiActContext' | 'aiActionContext' | 'cache'>;
export interface MidsceneYamlScriptConfig {
    output?: string;
    unstableLogContent?: boolean | string;
}
export interface MidsceneYamlScriptEnvGeneralInterface {
    module: string;
    export?: string;
    param?: Record<string, any>;
}
export interface MidsceneYamlScriptWebEnv extends MidsceneYamlScriptConfig, MidsceneYamlScriptAgentOpt {
    serve?: string;
    url: string;
    userAgent?: string;
    acceptInsecureCerts?: boolean;
    viewportWidth?: number;
    viewportHeight?: number;
    deviceScaleFactor?: number;
    waitForNetworkIdle?: {
        timeout?: number;
        continueOnNetworkIdleError?: boolean;
    };
    cookie?: string;
    forceSameTabNavigation?: boolean;
    /**
     * Custom Chrome launch arguments (Puppeteer only, not supported in bridge mode).
     *
     * Allows passing custom command-line arguments to Chrome/Chromium when launching the browser.
     * This is useful for testing scenarios that require specific browser configurations.
     *
     * ⚠️ Security Warning: Some arguments (e.g., --no-sandbox, --disable-web-security) may
     * reduce browser security. Use only in controlled testing environments.
     *
     * @example
     * ```yaml
     * web:
     *   url: https://example.com
     *   chromeArgs:
     *     - '--disable-features=ThirdPartyCookiePhaseout'
     *     - '--disable-features=SameSiteByDefaultCookies'
     *     - '--window-size=1920,1080'
     * ```
     */
    chromeArgs?: string[];
    bridgeMode?: false | 'newTabWithUrl' | 'currentTab';
    closeNewTabsAfterDisconnect?: boolean;
}
export interface MidsceneYamlScriptAndroidEnv extends MidsceneYamlScriptConfig, Omit<AndroidDeviceOpt, 'customActions'> {
    deviceId?: string;
    launch?: string;
}
export interface MidsceneYamlScriptIOSEnv extends MidsceneYamlScriptConfig, Omit<IOSDeviceOpt, 'customActions'> {
    launch?: string;
}
export interface MidsceneYamlScriptComputerEnv extends MidsceneYamlScriptConfig {
    displayId?: string;
}
export type MidsceneYamlScriptEnv = MidsceneYamlScriptWebEnv | MidsceneYamlScriptAndroidEnv | MidsceneYamlScriptIOSEnv | MidsceneYamlScriptComputerEnv;
export interface MidsceneYamlFlowItemAIAction {
    aiAction?: string;
    ai?: string;
    aiAct?: string;
    aiActionProgressTips?: string[];
    cacheable?: boolean;
    [key: string]: unknown;
}
export interface MidsceneYamlFlowItemAIAssert extends ServiceExtractOption {
    aiAssert: string;
    errorMessage?: string;
    name?: string;
}
export interface MidsceneYamlFlowItemAIWaitFor extends ServiceExtractOption {
    aiWaitFor: string;
    timeout?: number;
}
export interface MidsceneYamlFlowItemEvaluateJavaScript {
    javascript: string;
    name?: string;
}
export interface MidsceneYamlFlowItemSleep {
    sleep: number;
}
export interface MidsceneYamlFlowItemLogScreenshot {
    logScreenshot?: string;
    recordToReport?: string;
    content?: string;
}
export type MidsceneYamlFlowItem = MidsceneYamlFlowItemAIAction | MidsceneYamlFlowItemAIAssert | MidsceneYamlFlowItemAIWaitFor | MidsceneYamlFlowItemEvaluateJavaScript | MidsceneYamlFlowItemSleep | MidsceneYamlFlowItemLogScreenshot;
export interface FreeFn {
    name: string;
    fn: () => void;
}
export interface ScriptPlayerTaskStatus extends MidsceneYamlTask {
    status: ScriptPlayerStatusValue;
    currentStep?: number;
    totalSteps: number;
    error?: Error;
}
export type ScriptPlayerStatusValue = 'init' | 'running' | 'done' | 'error';
export interface MidsceneYamlConfig {
    concurrent?: number;
    continueOnError?: boolean;
    summary?: string;
    shareBrowserContext?: boolean;
    web?: MidsceneYamlScriptWebEnv;
    android?: MidsceneYamlScriptAndroidEnv;
    ios?: MidsceneYamlScriptIOSEnv;
    files: string[];
    headed?: boolean;
    keepWindow?: boolean;
    dotenvOverride?: boolean;
    dotenvDebug?: boolean;
}
export interface MidsceneYamlConfigOutput {
    format?: 'json';
    path?: string;
}
export interface MidsceneYamlConfigResult {
    file: string;
    success: boolean;
    executed: boolean;
    output?: string | null;
    report?: string | null;
    error?: string;
    duration?: number;
    /**
     * Type of result:
     * - 'success': All tasks completed successfully
     * - 'failed': Execution failed (player error)
     * - 'partialFailed': Some tasks failed but execution continued (continueOnError)
     * - 'notExecuted': Not executed due to previous failures
     */
    resultType?: 'success' | 'failed' | 'partialFailed' | 'notExecuted';
}
