import type { Editor } from '../editor'; import type { ToolOutputImage } from '../tool'; import type { SandboxArchiveLimits } from './client'; import type { Entry } from './entries'; import type { Manifest } from './manifest'; import type { Snapshot } from './snapshot'; export declare const SANDBOX_SESSION_STATE_VERSION: 6; export declare const SUPPORTED_SANDBOX_SESSION_STATE_VERSIONS: readonly [1, 2, 3, 4, 5, 6]; export type SandboxSessionStateVersion = (typeof SUPPORTED_SANDBOX_SESSION_STATE_VERSIONS)[number]; export type ExposedPortScheme = 'http' | 'ws'; export type ExposedPortEndpoint = { host: string; port: number; tls?: boolean; query?: string; protocol?: string; url?: string; [key: string]: unknown; }; export type SandboxSessionStateEnvelope = { version: SandboxSessionStateVersion; backendId: string; environmentPreparation?: 'client'; manifest: Record; snapshot?: Snapshot | null; snapshotFingerprint?: string | null; snapshotFingerprintVersion?: string | null; workspaceReady: boolean; exposedPorts?: Record; providerState: Record; }; export interface SandboxSessionState { manifest: Manifest; snapshot?: Snapshot | null; snapshotFingerprint?: string | null; snapshotFingerprintVersion?: string | null; workspaceReady?: boolean; environment?: Record; exposedPorts?: Record; [key: string]: unknown; } export type ExecCommandArgs = { cmd: string; workdir?: string; shell?: string; login?: boolean; tty?: boolean; yieldTimeMs?: number; maxOutputTokens?: number; runAs?: string; }; export type SandboxExecResult = { output: string; stdout: string; stderr: string; wallTimeSeconds: number; exitCode?: number | null; sessionId?: number; originalTokenCount?: number; }; export type WriteStdinArgs = { sessionId: number; chars?: string; yieldTimeMs?: number; maxOutputTokens?: number; }; export type ViewImageArgs = { path: string; runAs?: string; }; export type ReadFileArgs = { path: string; runAs?: string; maxBytes?: number; }; export type ListDirectoryArgs = { path: string; runAs?: string; }; export type SandboxDirectoryEntry = { name: string; path: string; type: 'file' | 'dir' | 'other'; }; export type MaterializeEntryArgs = { path: string; entry: Entry; runAs?: string; }; export type WorkspaceArchiveData = string | ArrayBuffer | Uint8Array; export type WorkspaceArchiveOptions = { archiveLimits?: SandboxArchiveLimits | null; }; export type SandboxSessionLifecycleOptions = { reason?: string; [key: string]: unknown; }; export type SandboxPreStopHook = () => Promise | void; export declare function normalizeExposedPort(port: number): number; export declare function exposedPortStateKey(port: number): string; export declare function recordExposedPortEndpoint(state: SandboxSessionState, endpoint: ExposedPortEndpoint, keyPort?: number): ExposedPortEndpoint; export declare function getRecordedExposedPortEndpoint(state: SandboxSessionState, port: number): ExposedPortEndpoint | undefined; export declare function urlForExposedPort(endpoint: ExposedPortEndpoint, scheme: ExposedPortScheme): string; export interface SandboxSession { state: TState; start?(options?: SandboxSessionLifecycleOptions): Promise; running?(): Promise; registerPreStopHook?(hook: SandboxPreStopHook): (() => void) | void; runPreStopHooks?(): Promise; preStop?(options?: SandboxSessionLifecycleOptions): Promise; stop?(options?: SandboxSessionLifecycleOptions): Promise; shutdown?(options?: SandboxSessionLifecycleOptions): Promise; delete?(options?: SandboxSessionLifecycleOptions): Promise; createEditor?(runAs?: string): Editor; exec?(args: ExecCommandArgs): Promise; execCommand?(args: ExecCommandArgs): Promise; writeStdin?(args: WriteStdinArgs): Promise; viewImage?(args: ViewImageArgs): Promise; readFile?(args: ReadFileArgs): Promise; listDir?(args: ListDirectoryArgs): Promise; pathExists?(path: string, runAs?: string): Promise; directoryExists?(path: string, runAs?: string): Promise; materializeEntry?(args: MaterializeEntryArgs): Promise; applyManifest?(manifest: Manifest, runAs?: string): Promise; persistWorkspace?(): Promise; hydrateWorkspace?(data: WorkspaceArchiveData, options?: WorkspaceArchiveOptions): Promise; setArchiveLimits?(limits?: SandboxArchiveLimits | null): void; resolveExposedPort?(port: number): Promise; supportsPty?(): boolean; close?(): Promise; } export type SandboxSessionLike = SandboxSession;