import { E as ExecutionTask, a as ExecutionTaskProgressOptions, b as ExecutionTaskApply, c as ExecutionDump, B as BaseElement, U as UIContext, I as InsightAction, D as DumpSubscriber, d as InsightOptions, e as InsightTaskInfo, f as InsightAssertionResponse, A as AISingleElementResponse } from './types-29130591.js';
export { p as AIAssertionResponse, m as AIElementCoordinatesResponse, l as AIElementIdResponse, n as AIElementResponse, i as AIResponseFormat, o as AISectionParseResponse, j as AISingleElementResponseById, k as AISingleElementResponseByPosition, h as AIUsageInfo, y as AgentAssertOpt, x as AgentWaitForOpt, X as BaseAgentParserOpt, C as CallAIFn, W as Color, s as DumpMeta, w as ElementById, g as ElementTreeNode, q as EnsureObject, _ as ExecutionRecorderItem, ag as ExecutionTaskAction, af as ExecutionTaskActionApply, ae as ExecutionTaskInsightAssertion, ad as ExecutionTaskInsightAssertionApply, ac as ExecutionTaskInsightAssertionParam, a5 as ExecutionTaskInsightDumpLog, a7 as ExecutionTaskInsightLocate, a6 as ExecutionTaskInsightLocateApply, a4 as ExecutionTaskInsightLocateOutput, a3 as ExecutionTaskInsightLocateParam, ab as ExecutionTaskInsightQuery, aa as ExecutionTaskInsightQueryApply, a9 as ExecutionTaskInsightQueryOutput, a8 as ExecutionTaskInsightQueryParam, ai as ExecutionTaskPlanning, ah as ExecutionTaskPlanningApply, a2 as ExecutionTaskReturn, $ as ExecutionTaskType, a0 as ExecutorContext, aj as GroupedActionDump, u as InsightDump, r as InsightExtractParam, L as LiteUISection, O as OnTaskStartTip, v as PartialInsightDumpFromSDK, G as PlanningAIResponse, F as PlanningAction, N as PlanningActionParamAssert, T as PlanningActionParamError, J as PlanningActionParamHover, K as PlanningActionParamInputOrKeyPress, M as PlanningActionParamScroll, Q as PlanningActionParamSleep, H as PlanningActionParamTap, V as PlanningActionParamWaitFor, z as PlanningLocateParam, Z as PlaywrightParserOpt, P as Point, Y as PuppeteerParserOpt, R as Rect, t as ReportDumpWithAttributes, S as Size, a1 as TaskCacheInfo } from './types-29130591.js';
import { c as callAiFn } from './llm-planning-8feb3f6b.js';
export { a as AiAssert, A as AiInspectElement, d as describeUserPage, p as plan, t as transformElementPositionToId } from './llm-planning-8feb3f6b.js';
export { getLogDirByType, getVersion, setLogDir } from './utils.js';
export { MIDSCENE_MODEL_NAME, getAIConfig } from './env.js';
import '@aico-test/shared/constants';
import 'openai/resources';

interface MidsceneYamlScript {
  target: MidsceneYamlScriptEnv;
  tasks: MidsceneYamlTask[];
}

interface MidsceneYamlTask {
  name: string;
  flow: MidsceneYamlFlowItem[];
  continueOnError?: boolean;
}

interface MidsceneYamlScriptEnv {
  serve?: string;
  url: string;

  // puppeteer only
  userAgent?: string;
  viewportWidth?: number;
  viewportHeight?: number;
  viewportScale?: number;
  waitForNetworkIdle?: {
    timeout?: number; // ms, 30000 for default, set to 0 to disable
    continueOnNetworkIdleError?: boolean; // should continue if failed to wait for network idle, true for default
  };
  cookie?: string;
  output?: string;
  forceSameTabNavigation?: boolean; // if track the newly opened tab, true for default in yaml script

  // bridge mode config
  bridgeMode?: false | 'newTabWithUrl' | 'currentTab';
  closeNewTabsAfterDisconnect?: boolean;
}

interface MidsceneYamlFlowItemAIAction {
  ai?: string; // this is the shortcut for aiAction
  aiAction?: string;
  aiActionProgressTips?: string[];
}

interface MidsceneYamlFlowItemAIAssert {
  aiAssert: string;
}

interface MidsceneYamlFlowItemAIQuery {
  aiQuery: string;
  name?: string;
}

interface MidsceneYamlFlowItemAIWaitFor {
  aiWaitFor: string;
  timeout?: number;
}

interface MidsceneYamlFlowItemSleep {
  sleep: number;
}

type MidsceneYamlFlowItem =
  | MidsceneYamlFlowItemAIAction
  | MidsceneYamlFlowItemAIAssert
  | MidsceneYamlFlowItemAIQuery
  | MidsceneYamlFlowItemAIWaitFor
  | MidsceneYamlFlowItemSleep;

interface FreeFn {
  name: string;
  fn: () => void;
}

interface ScriptPlayerTaskStatus extends MidsceneYamlTask {
  status: ScriptPlayerStatusValue;
  currentStep?: number;
  totalSteps: number;
  error?: Error;
}

type ScriptPlayerStatusValue = 'init' | 'running' | 'done' | 'error';

declare class Executor {
    name: string;
    tasks: ExecutionTask[];
    status: 'init' | 'pending' | 'running' | 'completed' | 'error';
    onTaskStart?: ExecutionTaskProgressOptions['onTaskStart'];
    constructor(name: string, options?: ExecutionTaskProgressOptions & {
        tasks?: ExecutionTaskApply[];
    });
    private markTaskAsPending;
    append(task: ExecutionTaskApply[] | ExecutionTaskApply): Promise<void>;
    flush(): Promise<any>;
    isInErrorState(): boolean;
    latestErrorTask(): ExecutionTask | null;
    dump(): ExecutionDump;
}

interface LocateOpts {
    callAI?: typeof callAiFn<AIElementResponse>;
    quickAnswer?: Partial<AISingleElementResponse>;
}
declare class Insight<ElementType extends BaseElement = BaseElement, ContextType extends UIContext<ElementType> = UIContext<ElementType>> {
    contextRetrieverFn: (action: InsightAction) => Promise<ContextType> | ContextType;
    aiVendorFn: (...args: Array<any>) => Promise<any>;
    onceDumpUpdatedFn?: DumpSubscriber;
    generateElement: InsightOptions['generateElement'];
    taskInfo?: Omit<InsightTaskInfo, 'durationMs'>;
    constructor(context: ContextType | ((action: InsightAction) => Promise<ContextType> | ContextType), opt?: InsightOptions);
    locate(queryPrompt: string, opt?: LocateOpts): Promise<ElementType | null>;
    extract<T = any>(input: string): Promise<T>;
    extract<T extends Record<string, string>>(input: T): Promise<Record<keyof T, any>>;
    extract<T extends object>(input: Record<keyof T, string>): Promise<T>;
    assert(assertion: string): Promise<InsightAssertionResponse>;
}

export { AISingleElementResponse, BaseElement, DumpSubscriber, ExecutionDump, ExecutionTask, ExecutionTaskApply, ExecutionTaskProgressOptions, Executor, type FreeFn, Insight, InsightAction, InsightAssertionResponse, InsightOptions, InsightTaskInfo, type MidsceneYamlFlowItem, type MidsceneYamlFlowItemAIAction, type MidsceneYamlFlowItemAIAssert, type MidsceneYamlFlowItemAIQuery, type MidsceneYamlFlowItemAIWaitFor, type MidsceneYamlFlowItemSleep, type MidsceneYamlScript, type MidsceneYamlScriptEnv, type MidsceneYamlTask, type ScriptPlayerStatusValue, type ScriptPlayerTaskStatus, UIContext, Insight as default };
