import fs from "node:fs";
import pino from "pino";
import type { LanguageModelMiddleware } from "ai";
import type { V3Options } from "./types/public/index.js";
interface FlowLoggerMetrics {
    taskStartTime?: number;
    stepStartTime?: number;
    actionStartTime?: number;
    llmRequests: number;
    llmInputTokens: number;
    llmOutputTokens: number;
    cdpEvents: number;
}
export interface FlowLoggerContext {
    logger: pino.Logger;
    metrics: FlowLoggerMetrics;
    sessionId: string;
    sessionDir: string;
    configDir: string;
    initPromise: Promise<void>;
    initialized: boolean;
    taskId: string | null;
    stepId: string | null;
    stepLabel: string | null;
    actionId: string | null;
    actionLabel: string | null;
    fileStreams: {
        agent: fs.WriteStream | null;
        stagehand: fs.WriteStream | null;
        understudy: fs.WriteStream | null;
        cdp: fs.WriteStream | null;
        llm: fs.WriteStream | null;
        jsonl: fs.WriteStream | null;
    };
}
/**
 * Get the config directory. Returns empty string if logging is disabled.
 */
export declare function getConfigDir(): string;
/**
 * Format a prompt preview from LLM messages for logging.
 * Returns format like: "some text... +{5.8kb image} +{schema} +{12 tools}"
 */
export declare function formatLlmPromptPreview(messages: Array<{
    role: string;
    content: unknown;
}>, options?: {
    toolCount?: number;
    hasSchema?: boolean;
}): string | undefined;
/**
 * Extract a text preview from CUA-style messages.
 * Accepts various message formats (Anthropic, OpenAI, Google).
 */
export declare function formatCuaPromptPreview(messages: unknown[], maxLen?: number): string | undefined;
/** Format CUA response output for logging */
export declare function formatCuaResponsePreview(output: unknown, maxLen?: number): string;
export declare class SessionFileLogger {
    /**
     * Initialize a new logging context. Call this at the start of a session.
     * If BROWSERBASE_CONFIG_DIR is not set, logging is disabled.
     */
    static init(sessionId: string, v3Options?: V3Options): void;
    private static initAsync;
    static close(): Promise<void>;
    static get sessionId(): string | null;
    static get sessionDir(): string | null;
    /**
     * Get the current logger context object.
     */
    static getContext(): FlowLoggerContext | null;
    /**
     * Start a new task and log it.
     */
    static logAgentTaskStarted({ invocation, args, }: {
        invocation: string;
        args?: unknown | unknown[];
    }): void;
    /**
     * Log task completion with metrics summary.
     */
    static logAgentTaskCompleted(options?: {
        cacheHit?: boolean;
    }): void;
    static logStagehandStepEvent({ invocation, args, label, }: {
        invocation: string;
        args?: unknown | unknown[];
        label: string;
    }): string;
    static logStagehandStepCompleted(): void;
    static logUnderstudyActionEvent({ actionType, target, args, }: {
        actionType: string;
        target?: string;
        args?: unknown | unknown[];
    }): string;
    static logUnderstudyActionCompleted(): void;
    private static logCdpEvent;
    static logCdpCallEvent(data: {
        method: string;
        params?: object;
        targetId?: string | null;
    }, ctx?: FlowLoggerContext | null): void;
    static logCdpMessageEvent(data: {
        method: string;
        params?: unknown;
        targetId?: string | null;
    }, ctx?: FlowLoggerContext | null): void;
    static logLlmRequest({ requestId, model, prompt, }: {
        requestId: string;
        model: string;
        operation: string;
        prompt?: string;
    }, explicitCtx?: FlowLoggerContext | null): void;
    static logLlmResponse({ requestId, model, output, inputTokens, outputTokens, }: {
        requestId: string;
        model: string;
        operation: string;
        output?: string;
        inputTokens?: number;
        outputTokens?: number;
    }, explicitCtx?: FlowLoggerContext | null): void;
    /**
     * Create middleware for wrapping language models with LLM call logging.
     * Returns a no-op middleware when logging is disabled.
     */
    static createLlmLoggingMiddleware(modelId: string): Pick<LanguageModelMiddleware, "wrapGenerate">;
}
/**
 * Method decorator for logging understudy actions with automatic start/complete.
 * Logs all arguments automatically. No-op when CONFIG_DIR is empty.
 */
export declare function logAction(actionType: string): <T extends (...args: never[]) => Promise<unknown>>(originalMethod: T) => T;
/**
 * Method decorator for logging Stagehand step events (act, extract, observe).
 * Only adds logging - does NOT wrap with withInstanceLogContext (caller handles that).
 * No-op when CONFIG_DIR is empty.
 */
export declare function logStagehandStep(invocation: string, label: string): <T extends (...args: never[]) => Promise<unknown>>(originalMethod: T) => T;
export {};
