import type { Buffer } from "node:buffer";
import type { Transport } from "@connectrpc/connect";
import type { RegistryImageKind, RegistrySortBy, RegistryVisibility } from "./registry.js";
import type { RuntimeSecretFile } from "./secret-files.js";
import type { StorageMountConfig } from "./storage.js";
import type { TailnetAttachmentOptions } from "./tailnet.js";
import type { TemplateSpec } from "./template-spec.js";
import type { Template, TemplateImageRef } from "./template.js";
import type { WarningHandler } from "./warning.js";
export type RootCertificates = string | Buffer | Array<string | Buffer>;
export interface ClientOptions {
    authToken?: string;
    /** Alias for authToken. Pass one or the other, not both. */
    apiKey?: string;
    baseUrl?: string;
    /** Optional SSH gateway address override. Most users should omit it. */
    gatewayAddress?: string;
    rootCertificates?: RootCertificates;
    timeoutMs?: number;
    dataPlaneReadyTimeoutMs?: number;
    /** Receives each warning returned by create(). Pass null to suppress emission. */
    warningHandler?: WarningHandler | null;
    transport?: Transport;
}
export interface VolumeMountConfig {
    volumeId: string;
    mountPath: string;
    readOnly?: boolean;
    /** Attachment state returned for existing sessions; ignored when creating a session. */
    state?: string;
}
/**
 * Admits matching HTTP requests on an intercepting session. Domains take the allowDomains grammar plus "*",
 * empty methods match any method, and at most one path field may be set; pathRegex is RE2 and must match the whole path.
 */
export interface EgressHttpRule {
    domains: string[];
    methods?: string[];
    pathExact?: string;
    pathPrefix?: string;
    pathRegex?: string;
}
export interface CreateOptions {
    /** Explicit scope for trusted service credentials; Workspace API keys infer it. */
    workspaceId?: string;
    name?: string;
    allowInbound?: boolean;
    allowOutbound?: boolean;
    /** Restricts outbound access to these domains (exact host, "*." for one subdomain label, or "**." for any depth). No effect if allowOutbound is false. */
    allowDomains?: string[];
    /** Restricts outbound access to these IPv4 CIDRs. No effect if allowOutbound is false. */
    allowCidrs?: string[];
    /**
     * Terminates the session's port-443 TLS at the egress proxy with a managed CA the guest trusts,
     * so each request's Host must match the TLS server name. Requires allowDomains.
     */
    interceptHttps?: boolean;
    /** Extra public TCP ports bypass HTTP inspection and still require an allowed destination. */
    allowedPorts?: number[];
    /** Refuses with 403 every HTTP request on ports 80 and 443 that matches none of these rules. Requires interceptHttps. */
    httpRules?: EgressHttpRule[];
    /**
     * Named workspace egress policies, merged with the other egress options at create.
     * Later edits or deletes of a named policy do not change the session.
     */
    egressPolicies?: string[];
    maxDurationMs?: number;
    /**
     * Ignored: sandboxes do not auto-pause on idle.
     * @deprecated Removed in the next major release; use maxDurationMs instead.
     */
    idleTimeoutMinutes?: number;
    pauseRetentionMs?: number;
    cpuCores?: number;
    memoryMb?: number;
    /**
     * Ephemeral root disk in GiB, 5-100. A create with no image, snapshot or template
     * spec defaults to 5; one with a source inherits that source's disk unless set.
     */
    diskSizeGb?: number;
    metadata?: Record<string, string>;
    tags?: string[];
    env?: Record<string, string>;
    /** Public keys installed in the sandbox; Luxor gateway auth also requires issueSandboxSSHCert. */
    sshAuthorizedKeys?: string[];
    /** Registry ref string, or an image object (e.g. build.image); digestRef wins over ref. */
    image?: string | TemplateImageRef;
    snapshotId?: string;
    /** Execute the current typed template spec directly without publishing an image. */
    fromTemplateSpec?: string | Template;
    /** Non-secret environment used only during template checkout/setup. */
    setupEnv?: Record<string, string>;
    /** Secret environment used only during template checkout/setup. */
    setupSecrets?: Record<string, string>;
    /** Managed boot runtime authored with TemplateSpec.start/processCompose. */
    directRuntime?: TemplateSpec;
    /** Declared secret names mapped to replacement names in the launching workspace. */
    secretOverrides?: Record<string, string>;
    /** Unresolved file contents or raw references for this launch. */
    secretFiles?: RuntimeSecretFile[];
    secretPolicies?: string[];
    enableOpenCode?: boolean;
    cloneRepoUrl?: string;
    volumes?: VolumeMountConfig[];
    /** Added to the workspace's default mounts; set defaultMountId to change a default. */
    storageMounts?: StorageMountConfig[];
    /** Skips the workspace's default storage mounts. */
    disableStorageDefaults?: boolean;
    /** Workspace default mounts to leave out of this sandbox. */
    excludedDefaultMountIds?: string[];
    openCodeProvider?: OpenCodeProviderConfig;
    githubToken?: string;
    sticky?: boolean;
    /** Wait until RUNNING with data-plane fields primed before returning. Defaults to true. */
    waitReady?: boolean;
    /** Overrides readiness wait. Defaults to 2 hours for direct template specs, otherwise 3 minutes. */
    waitTimeoutMs?: number;
    /** Wait until an image boot runtime is READY or FAILED. */
    waitForRuntime?: boolean;
    /** Join the sandbox to a tailnet with a write-only direct auth key. */
    tailnet?: TailnetAttachmentOptions;
    /** Skip the workspace default for this sandbox. */
    disableTailnet?: boolean;
}
export interface OpenCodeProviderConfig {
    apiKey?: string;
    baseUrl?: string;
    npm?: string;
}
export interface ExecOptions {
    args?: string[];
    /** Guest working directory. Relative paths resolve under the sandbox guest workdir; absolute paths pass through. */
    cwd?: string;
    /**
     * Wall-clock budget for the command; omitted or `0` means unbounded. Enforced
     * by the guest-agent, which caps it at its own maximum and resolves a spent
     * budget with `status: "TIMED_OUT"` rather than rejecting.
     */
    timeoutMs?: number;
    env?: Record<string, string>;
    /** Adds the secrets delivered to the session to the command environment; `env` still wins. */
    withSecrets?: boolean;
    onOutput?: (output: Output) => void;
    /** Signals the guest process and rejects the call with the signal's reason. */
    signal?: AbortSignal;
}
/** One secret binding of a session and the version it now carries; values never leave the engine. */
export interface SecretVersion {
    secretName: string;
    version: number;
    environmentKey: string;
    filePath: string;
}
export interface SecretsRefresh {
    /** False when every binding already used the current version; the secrets are re-delivered either way. */
    changed: boolean;
    versions: SecretVersion[];
    workflowId: string;
}
export interface Output {
    data: Uint8Array;
    isStderr: boolean;
    isFinal: boolean;
}
export interface ExposePortOptions {
    ttlMs?: number;
    slug?: string;
}
export interface DetachVolumeOptions {
    /** Unplug an attached volume even if the guest cannot unmount it (writes it has not flushed are lost).
     * Never releases a SYNC_PENDING attachment: wait for sync back to finish or request operator recovery. */
    force?: boolean;
    waitTimeoutMs?: number;
    signal?: AbortSignal;
}
export interface CreateSnapshotOptions {
    name?: string;
    expiresAt?: Date;
    async?: boolean;
}
export interface UpdateSessionOptions {
    name?: string;
    tags?: string[];
    sticky?: boolean;
    maxDurationMs?: number;
}
export interface ForkOptions {
    count?: number;
    namePrefix?: string;
    wait?: boolean;
}
export declare function validateUpdateMaxDurationMs(maxDurationMs: number | undefined, sticky: boolean | undefined): void;
export interface UpdateSnapshotOptions {
    name?: string;
    expiresAt?: Date;
    clearExpiresAt?: boolean;
    tags?: string[];
}
export interface CreateVolumeOptions {
    workspaceId?: string;
    name: string;
    sizeBytes: number;
}
export interface UpdateVolumeOptions {
    name?: string;
    tags?: string[];
}
export interface CreateTemplateOptions {
    workspaceId?: string;
    name: string;
    /** Typed v1 recipe; cannot be combined with the legacy fields below. */
    spec?: TemplateSpec;
    baseImageId?: string;
    setupScript?: string;
    startCmd?: string;
    env?: Record<string, string>;
    tags?: string[];
    /** Template defaults. `memoryMb` is in MiB; `diskSizeGb` must be 0 or 5-100 GiB, where 0 leaves no disk default. */
    resources?: {
        cpuCores?: number;
        memoryMb?: number;
        diskSizeGb?: number;
    };
    parentTemplateId?: string;
    parentImage?: string;
}
export interface UpdateTemplateOptions {
    name?: string;
    /** Atomic full replacement of the typed recipe; cannot be combined with legacy fields. */
    spec?: TemplateSpec;
    baseImageId?: string;
    setupScript?: string;
    startCmd?: string;
    env?: Record<string, string>;
    tags?: string[];
    /** Template defaults. `memoryMb` is in MiB; `diskSizeGb` must be 0 or 5-100 GiB, where 0 leaves no disk default. */
    resources?: {
        cpuCores?: number;
        memoryMb?: number;
        diskSizeGb?: number;
    };
}
export interface ListOptions {
    /** Explicit workspace scope for service-token callers. Workspace API keys infer this server-side. */
    workspaceId?: string;
    tags?: string[];
    sticky?: boolean;
    /** Include terminated sessions in results; the server omits them by default. */
    includeTerminated?: boolean;
}
export interface WorkspaceScopeOptions {
    /** Explicit workspace scope for service-token callers. Workspace API keys infer this server-side. */
    workspaceId?: string;
}
export interface RegistryListOptions {
    workspace?: string;
    labels?: string[];
    kind?: RegistryImageKind;
    nameSubstring?: string;
    sort?: RegistrySortBy;
    pageSize?: number;
    cursor?: string;
}
export interface RegistryLookupOptions {
    workspaceId?: string;
}
export interface RegistryPublishOptions {
    image?: string;
    imageId?: string;
    workspaceId?: string;
    name?: string;
    fromTemplateId?: string;
    fromSnapshotId?: string;
    tag?: string;
    visibility?: RegistryVisibility;
    labels?: string[];
    title?: string;
    description?: string;
}
export interface RegistryShareOptions {
    targetWorkspaceId?: string;
    tag?: string;
    snapshotId?: string;
}
