declare const DEFAULT_RIDDLE_API_BASE_URL = "https://api.riddledc.com";
declare const DEFAULT_RIDDLE_API_KEY_FILE = "/tmp/riddle-api-key";
type RiddleFetch = typeof fetch;
interface RiddleClientConfig {
    apiKey?: string;
    apiKeyFile?: string;
    apiBaseUrl?: string;
    fetchImpl?: RiddleFetch;
    onPreviewProgress?: (snapshot: RiddlePreviewDeployProgressSnapshot) => void | Promise<void>;
}
interface RiddleApiKeySource {
    source: "option" | "env" | "file";
    file?: string;
}
interface RiddleBalanceResult {
    available_seconds?: number;
    reserved_seconds?: number;
    total_seconds?: number;
    available_time?: string;
    total_time?: string;
    available_dollars?: number;
    reserved_dollars?: number;
    total_dollars?: number;
    currency?: string;
    holds_count?: number;
    rate?: Record<string, unknown>;
}
interface RiddlePollProgressSnapshot {
    job_id: string;
    status: string | null;
    terminal: boolean;
    attempt: number;
    attempts: number;
    elapsed_ms: number;
    created_at: string | null;
    submitted_at: string | null;
    completed_at: string | null;
    queue_elapsed_ms: number | null;
    pre_submission_elapsed_ms: number;
    running_without_submission: boolean;
}
interface RiddlePollSummary extends RiddlePollProgressSnapshot {
    timed_out: boolean;
    interval_ms: number;
    unsubmitted_timeout?: boolean;
    unsubmitted_timeout_ms?: number;
    message?: string;
}
interface RiddlePollJobOptions {
    wait?: boolean;
    attempts?: number;
    intervalMs?: number;
    progressEveryMs?: number;
    unsubmittedTimeoutMs?: number;
    onProgress?: (snapshot: RiddlePollProgressSnapshot) => void | Promise<void>;
}
type RiddlePreviewFramework = "spa" | "static";
type RiddlePreviewDeployStage = "validating" | "creating" | "created" | "archiving" | "archived" | "uploading" | "uploaded" | "publishing" | "publish_recovering" | "checking_status" | "ready";
interface RiddlePreviewDeployProgressSnapshot {
    stage: RiddlePreviewDeployStage;
    label: string;
    framework: RiddlePreviewFramework;
    directory: string;
    elapsed_ms: number;
    id?: string;
    preview_url?: string;
    file_count?: number;
    total_bytes?: number;
    tarball_bytes?: number;
    attempt?: number;
    attempts?: number;
    status?: string | null;
    publish_error?: string;
    warnings?: string[];
    message?: string;
}
interface RiddlePreviewDeployResult {
    ok: true;
    id: string;
    label: string;
    framework: RiddlePreviewFramework;
    preview_url: string;
    file_count?: number;
    total_bytes?: number;
    expires_at?: string;
    publish_recovered?: boolean;
    publish_error?: string;
    warnings?: string[];
    raw?: Record<string, unknown>;
}
interface RiddleRunScriptInput {
    url: string;
    script: string;
    viewport?: {
        width: number;
        height: number;
    };
    timeoutSec?: number;
    sync?: boolean;
    strict?: boolean;
    include?: string[];
    options?: Record<string, unknown>;
}
interface RiddleServerPreviewInput {
    directory: string;
    script: string;
    image?: string;
    command?: string;
    port?: number;
    path?: string;
    readinessPath?: string;
    readinessTimeoutSec?: number;
    waitForSelector?: string;
    waitUntil?: "commit" | "domcontentloaded" | "load" | "networkidle";
    navigationTimeoutSec?: number;
    viewport?: {
        width: number;
        height: number;
    };
    timeoutSec?: number;
    pollAttempts?: number;
    pollIntervalMs?: number;
    exclude?: string[];
}
interface RiddlePollJobResult {
    ok: boolean;
    job_id: string;
    status: string | null;
    terminal: boolean;
    job: Record<string, unknown> | null;
    artifacts?: Record<string, unknown> | null;
    poll?: RiddlePollSummary;
}
interface RiddleServerPreviewResult {
    ok: boolean;
    job_id: string;
    status: string | null;
    terminal: boolean;
    script_error: string | null;
    job: Record<string, unknown> | null;
}
declare class RiddleApiError extends Error {
    readonly status: number;
    readonly body: string;
    readonly path: string;
    constructor(pathname: string, status: number, body: string);
}
declare function resolveRiddleApiKeySource(config?: RiddleClientConfig): RiddleApiKeySource;
declare function resolveRiddleApiKey(config?: RiddleClientConfig): string;
declare function riddleRequestJson<T = unknown>(config: RiddleClientConfig, pathname: string, init?: RequestInit): Promise<T>;
declare function getRiddleBalance(config?: RiddleClientConfig): Promise<RiddleBalanceResult>;
declare function deployRiddlePreview(config: RiddleClientConfig, directory: string, label: string, framework?: RiddlePreviewFramework): Promise<RiddlePreviewDeployResult>;
declare function collectRiddlePreviewDeployWarnings(directory: string, framework?: RiddlePreviewFramework): string[];
declare function deployRiddleStaticPreview(config: RiddleClientConfig, directory: string, label: string): Promise<RiddlePreviewDeployResult>;
declare function parseRiddleViewport(value?: string): {
    width: number;
    height: number;
} | undefined;
declare function runRiddleServerPreview(config: RiddleClientConfig, input: RiddleServerPreviewInput): Promise<RiddleServerPreviewResult>;
declare function runRiddleScript(config: RiddleClientConfig, input: RiddleRunScriptInput): Promise<Record<string, unknown>>;
declare function isTerminalRiddleJobStatus(status: unknown): boolean;
declare function pollRiddleJob(config: RiddleClientConfig, jobId: string, options?: RiddlePollJobOptions): Promise<RiddlePollJobResult>;
declare function createRiddleApiClient(config?: RiddleClientConfig): {
    apiKeySource: () => RiddleApiKeySource;
    requestJson: <T = unknown>(pathname: string, init?: RequestInit) => Promise<T>;
    getBalance: () => Promise<RiddleBalanceResult>;
    deployPreview: (directory: string, label: string, framework?: RiddlePreviewFramework) => Promise<RiddlePreviewDeployResult>;
    deployStaticPreview: (directory: string, label: string) => Promise<RiddlePreviewDeployResult>;
    runScript: (input: RiddleRunScriptInput) => Promise<Record<string, unknown>>;
    runServerPreview: (input: RiddleServerPreviewInput) => Promise<RiddleServerPreviewResult>;
    pollJob: (jobId: string, options?: RiddlePollJobOptions) => Promise<RiddlePollJobResult>;
};

export { DEFAULT_RIDDLE_API_BASE_URL, DEFAULT_RIDDLE_API_KEY_FILE, RiddleApiError, type RiddleApiKeySource, type RiddleBalanceResult, type RiddleClientConfig, type RiddleFetch, type RiddlePollJobOptions, type RiddlePollJobResult, type RiddlePollProgressSnapshot, type RiddlePollSummary, type RiddlePreviewDeployProgressSnapshot, type RiddlePreviewDeployResult, type RiddlePreviewDeployStage, type RiddlePreviewFramework, type RiddleRunScriptInput, type RiddleServerPreviewInput, type RiddleServerPreviewResult, collectRiddlePreviewDeployWarnings, createRiddleApiClient, deployRiddlePreview, deployRiddleStaticPreview, getRiddleBalance, isTerminalRiddleJobStatus, parseRiddleViewport, pollRiddleJob, resolveRiddleApiKey, resolveRiddleApiKeySource, riddleRequestJson, runRiddleScript, runRiddleServerPreview };
