import Anthropic from "@anthropic-ai/sdk";
import type { Page } from "playwright";
import type { Screenshotter } from "./screenshotter.js";
import type { Scenario } from "../types/index.js";
/**
 * Resolves a model preset key (quick/thorough/deep) to its full model ID.
 * If the input doesn't match a preset, returns it as-is.
 */
export declare function resolveModel(nameOrPreset: string): string;
export declare const BROWSER_TOOLS: Anthropic.Tool[];
interface ToolContext {
    runId: string;
    scenarioSlug: string;
    stepNumber: number;
    sessionId: string;
    a11y?: boolean | {
        level?: "A" | "AA" | "AAA";
    };
}
interface ScreenshotResult {
    filePath: string;
    width: number;
    height: number;
    timestamp: string;
    description: string | null;
    pageUrl: string | null;
    thumbnailPath: string | null;
}
interface ToolExecutionResult {
    result: string;
    screenshot?: ScreenshotResult;
}
/**
 * Executes a single browser tool action against the Playwright page.
 * Returns the result string and an optional screenshot capture.
 */
export declare function executeTool(page: Page, screenshotter: Screenshotter, toolName: string, toolInput: Record<string, unknown>, context: ToolContext): Promise<ToolExecutionResult>;
export type StepEventHandler = (event: {
    type: "tool_call" | "tool_result" | "thinking";
    toolName?: string;
    toolInput?: Record<string, unknown>;
    toolResult?: string;
    thinking?: string;
    stepNumber: number;
}) => void;
interface AgentLoopOptions {
    client: Anthropic | OpenAICompatConfig;
    page: Page;
    scenario: Scenario;
    screenshotter: Screenshotter;
    model: string;
    runId: string;
    sessionId?: string;
    baseUrl?: string;
    maxTurns?: number;
    onStep?: StepEventHandler;
    persona?: {
        name: string;
        role: string;
        description: string;
        instructions: string;
        traits: string[];
        goals: string[];
        behaviors?: string[];
        painPoints?: string[];
    } | null;
    a11y?: boolean | {
        level?: "A" | "AA" | "AAA";
    };
}
interface AgentLoopResult {
    status: "passed" | "failed" | "error";
    reasoning: string;
    stepsCompleted: number;
    tokensUsed: number;
    screenshots: Array<{
        filePath: string;
        width: number;
        height: number;
        timestamp: string;
        action: string;
        stepNumber: number;
        description: string | null;
        pageUrl: string | null;
        thumbnailPath: string | null;
    }>;
}
export declare function buildScenarioUserMessage(scenario: Scenario, baseUrl?: string): string;
/**
 * Runs the AI agent loop: sends the scenario to Claude, processes tool calls,
 * executes browser actions, and collects results until the agent reports
 * a final result or the turn limit is reached.
 */
export declare function runAgentLoop(options: AgentLoopOptions): Promise<AgentLoopResult>;
/**
 * Detects the AI provider from a model name.
 * - "gpt-*" or "o1-*" / "o3-*" → openai
 * - "gemini-*" → google
 * - "glm-*" / "zai/*" / "zai-*" → Z.AI
 * - "llama-*" / "qwen-*" / names containing "cerebras" → Cerebras
 * - everything else → anthropic (default)
 */
export type AIProvider = "anthropic" | "openai" | "google" | "cerebras" | "zai";
export declare function detectProvider(model: string): AIProvider;
export declare function resolveProviderApiKeyForModel(model: string, explicitApiKey?: string, configuredAnthropicApiKey?: string): string | undefined;
/**
 * Creates an Anthropic client instance. Uses the provided API key,
 * or falls back to the ANTHROPIC_API_KEY environment variable.
 */
export declare function createClient(apiKey?: string): Anthropic;
/**
 * Calls an OpenAI-compatible chat completions endpoint and returns a
 * response shaped like an Anthropic message (content blocks).
 */
export declare function callOpenAICompatible(options: {
    baseUrl: string;
    apiKey: string;
    model: string;
    system: string;
    messages: Anthropic.MessageParam[];
    tools: Anthropic.Tool[];
    maxTokens?: number;
}): Promise<{
    content: Anthropic.ContentBlock[];
    stop_reason: string;
    usage: {
        input_tokens: number;
        output_tokens: number;
    };
}>;
/**
 * Creates the right client/config for a given model. Returns either an Anthropic
 * client or a config object for the OpenAI-compatible path.
 */
export type OpenAICompatProvider = Exclude<AIProvider, "anthropic">;
export type OpenAICompatConfig = {
    provider: OpenAICompatProvider;
    baseUrl: string;
    apiKey: string;
};
export declare function createOpenAICompatibleConfig(provider: OpenAICompatProvider, apiKey?: string): OpenAICompatConfig;
export declare function createClientForModel(model: string, apiKey?: string): Anthropic | OpenAICompatConfig;
export {};
//# sourceMappingURL=ai-client.d.ts.map