/**
 * Configuration for automatic retry on transient failures.
 */
export interface RetryConfig {
    /** Maximum number of retries. @default 3 */
    maxRetries?: number;
    /** Base delay in milliseconds for exponential backoff. @default 500 */
    baseDelayMs?: number;
    /** Maximum delay in milliseconds. @default 5000 */
    maxDelayMs?: number;
}
export interface SandboxConfig {
    /**
     * Base URL of the StateSet Sandbox controller
     * @example "https://sandbox.stateset.com" or "http://localhost:8080"
     */
    baseUrl: string;
    /**
     * Authentication token (JWT or API key)
     */
    authToken: string;
    /**
     * Organization ID (deprecated, no longer required for API key auth)
     */
    orgId?: string;
    /**
     * Request timeout in milliseconds
     * @default 30000
     */
    timeout?: number;
    /**
     * API version to use
     * @default 'v1'
     */
    apiVersion?: 'v1';
    /**
     * Retry configuration for transient failures (429, 5xx, network errors).
     * Set to `false` to disable retries entirely.
     * @default { maxRetries: 3, baseDelayMs: 500, maxDelayMs: 5000 }
     */
    retry?: RetryConfig | false;
}
export interface StartupMetrics {
    /** Total startup time in milliseconds */
    total_ms: number;
    /** Time spent on K8s API call in milliseconds */
    pod_creation_ms: number;
    /** Time waiting for pod to be ready in milliseconds */
    pod_ready_ms: number;
    /** Detailed phase breakdown */
    phases: {
        name: string;
        durationMs: number;
    }[];
}
export interface Sandbox {
    sandbox_id: string;
    org_id: string;
    session_id: string;
    status: 'creating' | 'running' | 'terminating' | 'terminated' | 'error';
    pod_ip?: string;
    created_at: string;
    expires_at: string;
    max_expires_at?: string;
    max_lifetime_seconds?: number;
    remaining_extend_seconds?: number;
    lifetime_used_seconds?: number;
    lifetime_used_percent?: number;
    requested_additional_seconds?: number;
    applied_additional_seconds?: number;
    additional_seconds?: number;
    workspace?: {
        persistence: 'ephemeral' | 'persistent';
        pvc_name?: string;
        size?: string;
    };
    /** Startup timing metrics (only present on create response) */
    startup_metrics?: StartupMetrics;
}
export interface CreateSandboxOptions {
    /**
     * Session ID for the sandbox (optional, auto-generated if not provided)
     */
    session_id?: string;
    /**
     * CPU limit (e.g., "2", "500m")
     * @default "2"
     */
    cpus?: string;
    /**
     * Memory limit (e.g., "2Gi", "512Mi")
     * @default "2Gi"
     */
    memory?: string;
    /**
     * Isolation level (container, gvisor, microvm, wasm)
     */
    isolation?: 'container' | 'gvisor' | 'microvm' | 'kata' | 'wasm';
    /**
     * Timeout in seconds before auto-termination
     * @default 600
     */
    timeout_seconds?: number;
    /**
     * Environment variables to inject into the sandbox
     */
    env?: Record<string, string>;
    /**
     * Workspace storage. Persistent workspaces use a sandbox-scoped Kubernetes
     * PVC and can participate in CSI snapshot branching when enabled.
     */
    workspace?: {
        persistence: 'ephemeral' | 'persistent';
        /** Whole-Gi capacity, for example `10Gi`. */
        size?: string;
    };
    /**
     * Optional GPU allocation request.
     */
    gpu?: GpuRequest;
    /**
     * Optional image override.
     */
    image?: string;
    /**
     * Optional per-sandbox WASI networking policy (Wasm isolation only).
     */
    wasm_network?: WasmNetworkPolicy;
    /**
     * Desktop OS (linux, windows, macos). Only linux is currently supported.
     * @default "linux"
     */
    desktop_os?: 'linux' | 'windows' | 'macos';
}
export interface GpuRequest {
    count?: number;
    type?: string;
    memory_gb?: number;
}
export interface WasmNetworkPolicy {
    enabled?: boolean;
    allow_tcp?: boolean;
    allow_udp?: boolean;
    allow_ip_lookup?: boolean;
}
export interface ForkSandboxOptions {
    cpus?: string;
    memory?: string;
    timeout_seconds?: number;
    isolation?: 'container' | 'gvisor' | 'microvm' | 'kata' | 'wasm';
    include_env?: boolean;
    checkpoint_name?: string;
    checkpoint_description?: string;
}
export interface ForkSandboxResult {
    parent_id: string;
    forked_id: string;
    checkpoint_id: string;
    status: Sandbox['status'];
    created_at: string;
    expires_at: string;
    workspace_strategy: 'file-checkpoint' | 'csi-snapshot';
    startup_metrics?: StartupMetrics;
}
export interface PromoteSandboxOptions {
    target_isolation: 'container' | 'gvisor' | 'microvm' | 'kata' | 'wasm';
    cpus?: string;
    memory?: string;
    timeout_seconds?: number;
    include_env?: boolean;
    checkpoint_name?: string;
    checkpoint_description?: string;
    stop_source?: boolean;
}
export interface PromoteSandboxResult {
    source_id: string;
    promoted_id: string;
    checkpoint_id: string;
    source_status: Sandbox['status'] | 'terminated';
    promoted_status: Sandbox['status'];
    created_at: string;
    expires_at: string;
    workspace_strategy: 'file-checkpoint' | 'csi-snapshot';
    startup_metrics?: StartupMetrics;
}
export interface FileWrite {
    /**
     * Path to write the file (relative to /workspace)
     */
    path: string;
    /**
     * File content (base64 encoded)
     */
    content: string;
}
export interface ExecuteOptions {
    /**
     * Command to execute (string for shell command, array for exec)
     */
    command: string | string[];
    /**
     * Working directory
     * @default "/workspace"
     */
    working_dir?: string;
    /**
     * Environment variables for this command
     */
    env?: Record<string, string>;
    /**
     * Enable streaming mode
     * @default false
     */
    stream?: boolean;
}
export interface ExecuteResult {
    exit_code: number;
    /** Exit code (camelCase) */
    exitCode?: number;
    stdout: string;
    stderr: string;
    /** Output was truncated by server limits */
    output_truncated?: boolean;
    /** Output was truncated by server limits (camelCase) */
    outputTruncated?: boolean;
}
export interface StreamCallbacks {
    onStdout?: (data: string) => void;
    onStderr?: (data: string) => void;
    onExit?: (code: number) => void;
    onError?: (error: Error) => void;
    /**
     * Called when a stream event fails to parse.
     * Useful for debugging malformed SSE events.
     */
    onParseError?: (rawLine: string, error: Error) => void;
}
export interface StreamEvent {
    type: 'stdout' | 'stderr' | 'exit' | 'done' | 'error';
    data?: string;
    code?: number;
    error?: string;
}
export interface RegistrationRequest {
    first_name: string;
    last_name: string;
    organization_name: string;
    email: string;
    use_case?: string;
}
export interface RegistrationResponse {
    organization: {
        id: string;
        name: string;
        slug: string;
        plan: 'hobby' | 'pro' | 'team';
    };
    user: {
        id: string;
        email: string;
        role: string;
    };
    api_key: {
        key: string;
        key_prefix: string;
        name: string;
    };
}
export interface ApiKey {
    id: string;
    name: string;
    key_prefix: string;
    scopes: string[];
    rate_limit_override?: number;
    last_used_at?: string;
    expires_at?: string;
    created_at: string;
}
export interface CreateApiKeyOptions {
    name: string;
    scopes?: string[];
    expires_in_days?: number;
}
export interface CreateApiKeyResponse {
    api_key: ApiKey;
    key: string;
}
export interface UsageSummary {
    period_start: string;
    period_end: string;
    cpu_hours: number;
    memory_gb_hours: number;
    network_gb: number;
    sandbox_creations: number;
    estimated_cost_cents: number;
    breakdown: {
        cpu_cost_cents: number;
        memory_cost_cents: number;
        network_cost_cents: number;
        creations_cost_cents: number;
    };
}
export interface UsageHistoryPoint {
    period_start: string;
    period_end: string;
    cpu_hours: number;
    memory_gb_hours: number;
    network_gb: number;
    sandbox_creations: number;
    sandbox_count: number;
}
export interface UsageHistoryResponse {
    granularity: 'hourly' | 'daily' | 'monthly';
    start_date: string;
    end_date: string;
    data: UsageHistoryPoint[];
}
export type UsageGranularity = 'hourly' | 'daily' | 'monthly';
export type PlanType = 'hobby' | 'pro' | 'team';
export interface Plan {
    id: PlanType;
    name: string;
    max_runtime_seconds: number;
    max_concurrent_sandboxes: number;
    vcpu_rate_limit_per_min: number;
    included_cpu_hours: number;
    included_memory_gb_hours: number;
    included_network_gb: number;
    included_creations: number;
    cpu_price_per_hour: number;
    memory_price_per_gb_hour: number;
    network_price_per_gb: number;
    creation_price_per_million: number;
    base_price_cents: number;
}
export interface SubscriptionResponse {
    subscription: {
        id: string;
        status: string;
        current_period_start: string;
        current_period_end: string;
    } | null;
    plan: PlanType;
}
export interface Invoice {
    id: string;
    status: string;
    amount_due: number;
    amount_paid: number;
    currency: string;
    created: number;
    period_start: number;
    period_end: number;
    hosted_invoice_url?: string;
    invoice_pdf?: string;
}
export interface UpgradeOptions {
    plan: PlanType;
    success_url: string;
    cancel_url: string;
}
export interface Secret {
    id: string;
    name: string;
    scope: 'sandbox' | 'global';
    allowed_sandbox_patterns?: string[];
    created_at: string;
    updated_at: string;
    expires_at?: string;
}
export interface CreateSecretOptions {
    name: string;
    value: string;
    scope?: 'sandbox' | 'global';
    allowed_sandbox_patterns?: string[];
    expires_at?: string;
}
export interface InjectSecretsOptions {
    secrets: string[];
    as_env_vars?: boolean;
    as_file?: string;
}
/**
 * Agent session status
 */
export type AgentSessionStatus = 'pending' | 'running' | 'rotating' | 'paused' | 'completed' | 'failed' | 'cancelled';
/**
 * Budget configuration for agent sessions
 */
export interface AgentBudgetConfig {
    /** Maximum cost in cents */
    cost_cap_cents?: number;
    /** Maximum cost in cents (camelCase) */
    costCapCents?: number;
    /** Maximum number of iterations/executions */
    iteration_limit?: number;
    /** Maximum number of iterations/executions (camelCase) */
    iterationLimit?: number;
    /** Maximum duration in seconds */
    duration_limit_seconds?: number;
    /** Maximum duration in seconds (camelCase) */
    durationLimitSeconds?: number;
}
/**
 * Budget consumption tracking
 */
export interface AgentBudgetConsumed {
    /** Cost consumed in cents */
    cost_cents: number;
    /** Cost consumed in cents (camelCase) */
    costCents?: number;
    /** Number of iterations completed */
    iterations: number;
    /** Duration consumed in seconds */
    duration_seconds: number;
    /** Duration consumed in seconds (camelCase) */
    durationSeconds?: number;
}
/**
 * Rotation configuration
 */
export interface AgentRotationConfig {
    /** Seconds before sandbox expires to start rotation */
    pre_rotate_buffer_seconds: number;
    /** Seconds before sandbox expires to start rotation (camelCase) */
    preRotateBufferSeconds?: number;
    /** Include process state while rotating */
    include_process_state?: boolean;
    /** Include process state while rotating */
    includeProcessState?: boolean;
}
/**
 * Sandbox configuration for agent sessions
 */
export interface AgentSandboxConfig {
    /** CPU limit (e.g., "2", "500m") */
    cpus?: string;
    /** Memory limit (e.g., "4Gi", "512Mi") */
    memory?: string;
    /** Timeout in seconds */
    timeout_seconds?: number;
    /** Timeout in seconds (camelCase) */
    timeoutSeconds?: number;
    /** Isolation level */
    isolation?: 'container' | 'gvisor' | 'microvm';
    /** Environment variables */
    env?: Record<string, string>;
    /** Sandbox template */
    template?: string;
}
/**
 * Agent context that persists across rotations
 */
export interface AgentContext {
    /** Current working directory */
    working_dir?: string;
    /** Current working directory (camelCase) */
    workingDir?: string;
    /** Environment variables */
    env_vars?: Record<string, string>;
    /** Environment variables (camelCase) */
    envVars?: Record<string, string>;
    /** Custom state data */
    custom_state?: Record<string, unknown>;
    /** Custom state data (camelCase) */
    customState?: Record<string, unknown>;
    /** Last checkpoint ID */
    last_checkpoint_id?: string;
    /** Last checkpoint ID (camelCase) */
    lastCheckpointId?: string;
    /** Last sandbox ID (before rotation) */
    last_sandbox_id?: string;
    /** Last sandbox ID (camelCase) */
    lastSandboxId?: string;
}
/**
 * Tool type for registered tools
 */
export type AgentToolType = 'builtin' | 'custom' | 'mcp';
/**
 * Registered tool
 */
export interface AgentRegisteredTool {
    /** Tool name */
    name: string;
    /** Tool type */
    tool_type: AgentToolType;
    /** Tool type (camelCase) */
    toolType?: AgentToolType;
    /** Tool description */
    description?: string;
    /** Input schema (JSON Schema) */
    input_schema?: Record<string, unknown>;
    /** Input schema (camelCase) */
    inputSchema?: Record<string, unknown>;
    /** Whether the tool is enabled */
    enabled: boolean;
}
/**
 * Full agent session record
 */
export interface AgentSession {
    id: string;
    organization_id: string;
    organizationId?: string;
    status: AgentSessionStatus;
    current_sandbox_id?: string;
    currentSandboxId?: string;
    name?: string;
    description?: string;
    agent_context: AgentContext;
    agentContext?: AgentContext;
    tool_registry: AgentRegisteredTool[];
    toolRegistry?: AgentRegisteredTool[];
    budget_config: AgentBudgetConfig;
    budgetConfig?: AgentBudgetConfig;
    budget_consumed: AgentBudgetConsumed;
    budgetConsumed?: AgentBudgetConsumed;
    rotation_config: AgentRotationConfig;
    rotationConfig?: AgentRotationConfig;
    sandbox_config: AgentSandboxConfig;
    sandboxConfig?: AgentSandboxConfig;
    created_at: string;
    createdAt?: string;
    started_at?: string;
    startedAt?: string;
    completed_at?: string;
    completedAt?: string;
    last_activity_at: string;
    lastActivityAt?: string;
    client_id?: string;
    clientId?: string;
    last_heartbeat_at?: string;
    lastHeartbeatAt?: string;
    rotation_count: number;
    rotationCount?: number;
    total_exec_count: number;
    totalExecCount?: number;
    error_message?: string;
    errorMessage?: string;
    error_code?: string;
    errorCode?: string;
}
/**
 * Agent event type.
 * Includes current controller events plus legacy aliases for backward compatibility.
 */
export declare const AGENT_EVENT_TYPES: readonly ["session_started", "session_paused", "session_resumed", "session_completed", "session_failed", "session_cancelled", "sandbox_created", "sandbox_terminated", "rotation_started", "rotation_completed", "rotation_failed", "checkpoint_created", "checkpoint_restored", "exec_started", "exec_completed", "file_read", "file_written", "budget_warning", "budget_exceeded", "tool_registered", "tool_call_started", "tool_call_completed", "approval_required", "approval_granted", "approval_denied", "error", "heartbeat", "client_connected", "client_disconnected", "tool_called"];
export type AgentEventType = (typeof AGENT_EVENT_TYPES)[number];
/**
 * Agent event record
 */
export interface AgentEvent {
    id: string;
    session_id: string;
    sessionId?: string;
    sandbox_id?: string;
    sandboxId?: string;
    event_type: AgentEventType;
    eventType?: AgentEventType;
    event_subtype?: string;
    eventSubtype?: string;
    payload: Record<string, unknown>;
    sequence_number: number;
    sequenceNumber?: number;
    duration_ms?: number;
    durationMs?: number;
    success?: boolean;
    error_message?: string;
    errorMessage?: string;
    created_at: string;
    createdAt?: string;
}
/**
 * Options for creating an agent session
 */
export interface CreateAgentSessionOptions {
    /** Session name */
    name?: string;
    /** Session description */
    description?: string;
    /** Budget configuration */
    budget?: AgentBudgetConfig;
    /** Rotation configuration */
    rotation?: AgentRotationConfig;
    /** Sandbox configuration */
    sandbox?: AgentSandboxConfig;
    /** Client ID for reattachment */
    client_id?: string;
    /** Client ID for reattachment (camelCase) */
    clientId?: string;
}
/**
 * Options for listing agent sessions
 */
export interface ListAgentSessionsOptions {
    /** Filter by status */
    status?: AgentSessionStatus;
    /** Limit number of results */
    limit?: number;
    /** Offset for pagination */
    offset?: number;
}
/**
 * Options for listing agent events
 */
export interface ListAgentEventsOptions {
    /** Get events after this sequence number */
    after_sequence?: number;
    /** Get events after this sequence number (camelCase) */
    afterSequence?: number;
    /** Filter by event type */
    event_type?: AgentEventType;
    /** Filter by event type (camelCase) */
    eventType?: AgentEventType;
    /** Limit number of results */
    limit?: number;
}
/**
 * Options for executing in an agent session
 */
export interface AgentExecuteOptions {
    /** Command to execute */
    command: string | string[];
    /** Working directory */
    working_dir?: string;
    /** Working directory (camelCase) */
    workingDir?: string;
    /** Environment variables */
    env?: Record<string, string>;
    /** Timeout in milliseconds */
    timeout_ms?: number;
    /** Timeout in milliseconds (camelCase) */
    timeoutMs?: number;
    /** Timeout in milliseconds (generic alias) */
    timeout?: number;
    /** Sandbox epoch token (camelCase) */
    sandboxEpoch?: number;
    /** Sandbox epoch token */
    sandbox_epoch?: number;
}
/**
 * Options for registering a tool
 */
export interface RegisterToolOptions {
    /** Tool name */
    name: string;
    /** Tool type */
    tool_type?: AgentToolType;
    /** Tool type (camelCase) */
    toolType?: AgentToolType;
    /** Description */
    description?: string;
    /** Input schema */
    input_schema?: Record<string, unknown>;
    /** Input schema (camelCase) */
    inputSchema?: Record<string, unknown>;
    /** Raw tool config object expected by the API */
    config?: Record<string, unknown>;
}
/** Supported LLM providers for the inference proxy. */
export type InferenceProvider = 'anthropic' | 'openai' | 'google';
/**
 * Options for proxied LLM inference calls.
 *
 * The controller decrypts the org's API key secret and injects it
 * into the outbound request, so the API key never enters the sandbox.
 */
export interface InferenceOptions {
    /** LLM provider. */
    provider: InferenceProvider;
    /** API path (e.g., '/v1/messages', '/v1/chat/completions'). */
    path: string;
    /** Request body to forward to the provider. */
    body: unknown;
    /** Name of the org secret containing the API key. Defaults to PROVIDER_API_KEY. */
    secret_name?: string;
    /** Additional headers to forward to the provider. */
    headers?: Record<string, string>;
}
/** The raw response from the inference proxy. */
export interface InferenceResult {
    /** HTTP status code from the LLM provider. */
    status: number;
    /** Response body from the LLM provider. */
    body: unknown;
    /** Select response headers (rate limits, request ID). */
    headers: Record<string, string>;
}
/** A live REPL session inside a sandbox. */
export interface ReplSession {
    /** Unique session ID. */
    id: string;
    /** The sandbox this session belongs to. */
    sandboxId: string;
    /** Language / kernel name (e.g. 'python', 'node'). */
    language: string;
    /** Underlying kernel identifier. */
    kernelId: string;
    /** Current session state. */
    status: 'starting' | 'idle' | 'busy' | 'dead';
}
/** Result of executing code in a REPL session. */
export interface ReplExecuteResult {
    /** Monotonically increasing execution counter. */
    executionCount: number;
    /** Ordered list of outputs produced by the execution. */
    outputs: ReplOutput[];
    /** Execution status. */
    status: string;
    /** Error details, if the execution failed. */
    error?: unknown;
    /** Wall-clock execution time in milliseconds. */
    durationMs: number;
}
/** A single output from a REPL execution. */
export type ReplOutput = {
    type: 'stdout';
    text: string;
} | {
    type: 'stderr';
    text: string;
} | {
    type: 'result';
    data: unknown;
} | {
    type: 'error';
    ename: string;
    evalue: string;
    traceback: string[];
};
export interface BenchmarkRun {
    create_ms: number;
    exec_ms: number;
    cleanup_ms: number;
    total_ms: number;
    warm_pool: boolean;
    status: 'ok' | 'error';
    error?: string;
}
export interface BenchmarkResultSummary {
    tti_median_ms: number;
    tti_min_ms: number;
    tti_max_ms: number;
    tti_p95_ms: number;
    create_median_ms: number;
    exec_median_ms: number;
    success_rate: string;
    run_count: number;
    warm_pool_hits: number;
    cold_start_tti_median_ms?: number;
}
export interface BenchmarkResult {
    provider: string;
    region: string;
    timestamp: string;
    tti_ms: number;
    create_ms: number;
    exec_ms: number;
    cleanup_ms: number;
    runs: BenchmarkRun[];
    summary: BenchmarkResultSummary;
}
export interface BenchmarkHistoryEntry {
    timestamp: string;
    region?: string;
    provider?: string;
    ttiP50Ms?: number;
    ttiP95Ms?: number;
    ttiP99Ms?: number;
    createMedianMs?: number;
    execMedianMs?: number;
    warmTtiMedianMs?: number;
    warmTtiP95Ms?: number;
    coldTtiMedianMs?: number;
    coldTtiP95Ms?: number;
    runCount?: number;
    successCount?: number;
    warmPoolHits?: number;
}
export interface BenchmarkHistoryResponse {
    results: BenchmarkHistoryEntry[];
    source?: string;
    count?: number;
    max_history?: number;
}
export interface BenchmarkSummary {
    ttiP50Ms: number | null;
    ttiP95Ms: number | null;
    ttiP99Ms: number | null;
    ttiMinMs: number | null;
    ttiMaxMs: number | null;
    warmTtiMedianMs: number | null;
    warmTtiP95Ms: number | null;
    coldTtiMedianMs: number | null;
    coldTtiP95Ms: number | null;
    totalRuns: number;
    totalSuccesses: number;
    resultCount: number;
    sloComplianceRate: number | null;
}
export type EgressMode = 'allow_all' | 'allowed_domains' | 'denied_domains' | 'allowed_ports';
export interface EgressPolicy {
    mode: EgressMode;
    allowed_domains?: string[];
    denied_domains?: string[];
    allowed_ports?: number[];
    enforcement?: 'enforce' | 'log_only';
    failure_mode?: 'fail_closed' | 'fail_open';
}
export interface EgressAuditEvent {
    id: string;
    sandbox_id: string;
    host: string;
    port: number;
    decision: 'allowed' | 'denied';
    bytes_sent: number;
    bytes_received: number;
    timestamp: string;
}
/** Options for capturing a screenshot */
export interface ScreenshotOptions {
    /** Image format */
    format?: 'png' | 'jpg';
    /** JPEG quality (1-100, only for jpg format) */
    quality?: number;
    /** Capture a specific region */
    region?: {
        x: number;
        y: number;
        width: number;
        height: number;
    };
}
/** Screenshot result */
export interface ScreenshotResult {
    /** Base64-encoded image data */
    image: string;
    /** Image format */
    format: 'png' | 'jpg';
    /** Image width in pixels */
    width?: number;
    /** Image height in pixels */
    height?: number;
}
/** Mouse action options */
export interface MouseOptions {
    /** Mouse action type */
    action: 'click' | 'move' | 'double_click' | 'drag';
    /** X coordinate */
    x: number;
    /** Y coordinate */
    y: number;
    /** Mouse button (1=left, 2=middle, 3=right) */
    button?: number;
    /** End X coordinate (for drag) */
    endX?: number;
    /** End Y coordinate (for drag) */
    endY?: number;
}
/** Keyboard action options */
export interface KeyboardOptions {
    /** Keyboard action type */
    action: 'type' | 'key' | 'hotkey';
    /** Text to type (for 'type' action) */
    text?: string;
    /** Key name (for 'key' action, e.g., 'Return', 'Tab') */
    key?: string;
    /** Key combination (for 'hotkey' action, e.g., ['ctrl', 'c']) */
    keys?: string[];
    /** Inter-key delay in milliseconds */
    delayMs?: number;
}
/** Screen dimensions */
export interface ScreenSize {
    width: number;
    height: number;
}
//# sourceMappingURL=types.d.ts.map