import type { Editor } from '../../editor'; import type { ToolOutputImage } from '../../tool'; import { type ChildProcessWithoutNullStreams } from 'node:child_process'; import type { SandboxClient, SandboxClientOptions, SandboxClientCreateArgs, SandboxArchiveLimits, SandboxClientResumeOptions, SandboxConcurrencyLimits } from '../client'; import { type ExposedPortEndpoint, type ExecCommandArgs, type ListDirectoryArgs, type MaterializeEntryArgs, type ReadFileArgs, type SandboxDirectoryEntry, type SandboxExecResult, type SandboxSession, type SandboxSessionState, type ViewImageArgs, type WriteStdinArgs, type WorkspaceArchiveOptions } from '../session'; import { Manifest } from '../manifest'; import { type ResolveSandboxPathOptions } from '../workspacePaths'; import type { LocalSandboxSnapshot, LocalSandboxSnapshotSpec } from './types'; import { UnixLocalFiles, preparedFileIO, type LocalFileIOProtection } from './shared/unixLocalFiles'; export type { LocalFileIOProtection } from './shared/unixLocalFiles'; export interface UnixLocalSandboxClientOptions extends SandboxClientOptions { /** * Host file protection. Requires trusted Python 3 with descriptor-relative * filesystem support. auto is an alias for required; off is rejected. * Unavailable protection fails during preparation, before workspace setup. * This does not confine shell commands. */ fileIOProtection?: LocalFileIOProtection; workspaceBaseDir?: string; snapshot?: LocalSandboxSnapshotSpec; defaultShell?: string; exposedPorts?: number[]; concurrencyLimits?: SandboxConcurrencyLimits; archiveLimits?: SandboxArchiveLimits | null; } export interface UnixLocalSandboxSessionState extends SandboxSessionState { workspaceRootPath: string; workspaceRootOwned: boolean; environment: Record; snapshotSpec?: LocalSandboxSnapshotSpec | null; snapshot?: LocalSandboxSnapshot | null; snapshotFingerprint?: string | null; snapshotFingerprintVersion?: string | null; configuredExposedPorts?: number[]; } type UnixRunAsIdentity = { username: string; uid: number; gid: number; isCurrentUser: boolean; }; export declare class UnixLocalSandboxSession implements SandboxSession { readonly state: TState; protected readonly defaultShell?: string; protected archiveLimits?: SandboxArchiveLimits | null; private readonly activeProcesses; private nextSessionId; private closePromise?; private stopPromise?; private fileOperationGeneration; private readonly hostFiles; private get files(); private readonly filesystemRoots; constructor(args: { state: TState; defaultShell?: string; archiveLimits?: SandboxArchiveLimits | null; fileIOProtection?: LocalFileIOProtection; [preparedFileIO]?: UnixLocalFiles | null; }); /** Selected once at creation or resume; Docker subclasses use the container backend. */ get fileIOBackend(): 'python' | 'docker'; setArchiveLimits(limits?: SandboxArchiveLimits | null): void; createEditor(runAs?: string): Editor; supportsPty(): boolean; resolveExposedPort(port: number): Promise; execCommand(args: ExecCommandArgs): Promise; exec(args: ExecCommandArgs): Promise; writeStdin(args: WriteStdinArgs): Promise; viewImage(args: ViewImageArgs): Promise; pathExists(path: string, runAs?: string): Promise; directoryExists(path: string, runAs?: string): Promise; readFile(args: ReadFileArgs): Promise; listDir(args: ListDirectoryArgs): Promise; materializeEntry(args: MaterializeEntryArgs): Promise; private materializeEntryExclusive; applyManifest(manifest: Manifest, runAs?: string): Promise; private applyManifestExclusive; persistWorkspace(): Promise; hydrateWorkspace(data: string | ArrayBuffer | Uint8Array, options?: WorkspaceArchiveOptions): Promise; stop(): Promise; private stopResources; shutdown(): Promise; delete(): Promise; close(): Promise; private closeResources; private stopActiveProcesses; resolveSandboxPath(path?: string, options?: ResolveSandboxPathOptions): string; private resolveFilesystemPath; private resolveHostPath; protected resolveCommandWorkdir(path?: string): string; protected assertSessionUsable(): void; private captureFilesystemRoots; private filesystemRoot; private applyFileOperation; private resolveSandboxPathTarget; private resolveLocalBindMountPath; protected resolveLogicalPath(path?: string): string; protected spawnShellCommand(command: string, args: { cwd: string; logicalCwd: string; shell?: string; login: boolean; runAs?: string; tty?: boolean; }): Promise; protected translateCommandInput(command: string): string; protected translateCommandOutput(output: string): string; protected materializeRestoredWorkspaceMounts(): Promise; protected logicalWorkdirForPath(path?: string): string; protected resolveCommandRunAs(runAs?: string): Promise; resolveFilesystemRunAs(runAs?: string): Promise; protected resolveRunAsIdentity(runAs?: string): Promise; private trackChildProcess; private allocateProcessId; } /** * Local sandbox client for Unix hosts. * Host file operations require trusted Python 3 with descriptor-relative * filesystem support. Set the host OPENAI_AGENTS_PYTHON to an absolute trusted * executable to override discovery. Unavailable protection and fileIOProtection: * 'off' fail during preparation. Resumed sessions use current client configuration. * File tools honor runAs using host permissions. Editor updates replace files, * require writable parent directories, and leave other hardlinks unchanged. */ export declare class UnixLocalSandboxClient implements SandboxClient { readonly backendId = "unix_local"; readonly supportsDefaultOptions = true; private readonly options; constructor(options?: UnixLocalSandboxClientOptions); create(args?: SandboxClientCreateArgs | Manifest, manifestOptions?: UnixLocalSandboxClientOptions): Promise; resume(state: UnixLocalSandboxSessionState, options?: SandboxClientResumeOptions): Promise; serializeSessionState(state: UnixLocalSandboxSessionState): Promise>; deserializeSessionState(state: Record): Promise; private restoreIfNeeded; }