import { Manifest, type ManifestInput } from './manifest'; import type { SandboxSessionLike, SandboxSessionState } from './session'; import type { SnapshotSpec } from './snapshot'; export type SandboxConcurrencyLimits = { manifestEntries?: number; localDirFiles?: number; }; export type SandboxArchiveLimits = { maxInputBytes?: number | null; maxExtractedBytes?: number | null; maxMembers?: number | null; }; export type ResolvedSandboxArchiveLimits = { maxInputBytes: number | null; maxExtractedBytes: number | null; maxMembers: number | null; }; export declare const DEFAULT_SANDBOX_ARCHIVE_LIMITS: ResolvedSandboxArchiveLimits; export type SandboxClientOptions = Record; export type SandboxClientCreateArgs = { snapshot?: SnapshotSpec; manifest?: ManifestInput; options?: TOptions; concurrencyLimits?: SandboxConcurrencyLimits; archiveLimits?: SandboxArchiveLimits | null; }; export type NormalizedSandboxClientCreateArgs = { snapshot?: SnapshotSpec; manifest: Manifest; options?: TOptions; concurrencyLimits?: SandboxConcurrencyLimits; archiveLimits?: SandboxArchiveLimits | null; }; export type SandboxClientResumeOptions = { archiveLimits?: SandboxArchiveLimits | null; clientOptions?: TOptions; /** * Current trusted manifest for clients that prepare environment values in * their own execution context. Treat this manifest as authoritative for * environment preparation: persisted provider state is untrusted input and * must not override it. The client must not return resolved values through * runner-visible or serialized session state. After a successful resume, * the runtime binds its environment and SDK security policies to the * provider-returned manifest for SDK-side policy and tool preparation while * preserving provider-owned structural fields. */ trustedManifest?: Manifest; }; export type SandboxSessionResumeValidationInput = { source: 'explicit'; state: TSessionState; } | { source: 'runState'; state: Record; }; export type SandboxClientCreate = { (args?: SandboxClientCreateArgs): Promise>; (manifest: Manifest, options?: TOptions): Promise>; }; export type SandboxSessionSerializationOptions = { preserveOwnedSession?: boolean; reuseLiveSession?: boolean; /** * The runtime will close the owned session after serialization. */ willCloseAfterSerialize?: boolean; }; export type SandboxPreservedSessionReuseOptions = { clientOptions?: TOptions; /** * Revalidate the entries materialized when the backend was created before * reusing a same-process preserved session. */ revalidateManifestEntries?: boolean; /** * Current trusted manifest for environment preparation. Treat this manifest * as authoritative; the preserved provider state must not override it. Once * reuse is accepted, the runtime binds its environment and SDK security * policies to the provider-returned manifest while preserving provider-owned * structural fields. */ trustedManifest?: Manifest; }; export interface SandboxClient { backendId: string; supportsDefaultOptions?: boolean; /** * Delegates manifest environment preparation to the client execution * context. The runner preserves unresolved environment references; the * client must resolve them and validate environment-backed credentials * before provider side effects. * * Resolved values must never be returned through runner-visible session * state or serializeSessionState(). Same-process live reuse with unresolved * references requires canReusePreservedOwnedSession() so the client can * revalidate the session in its execution context. */ environmentPreparation?: 'client'; /** * Persisted provider state cannot authenticate enough backend authority to * reconnect safely, so only a same-process live session may be reused. */ serializedSessionStateRequiresFreshCreation?: boolean; /** * Current trusted client options make serialized provider state unsafe to * resume. The runtime may replace a same-process live session when it can * authorize cleanup, but fails closed for untrusted cross-process state. */ serializedSessionStateRequiresFreshCreationForOptions?(state: TSessionState, options?: SandboxClientResumeOptions): Promise | boolean; /** * A rejected same-process live session cannot be resumed from its serialized * provider state and must be replaced through the normal create path. */ preservedOwnedSessionReuseRejectionRequiresFreshCreation?: boolean; create?: SandboxClientCreate; delete?(state: TSessionState): Promise; serializeSessionState?(state: TSessionState, options?: SandboxSessionSerializationOptions): Promise>; canPersistOwnedSessionState?(state: TSessionState): Promise | boolean; canReusePreservedOwnedSession?(state: TSessionState, options?: SandboxPreservedSessionReuseOptions): Promise | boolean; /** * Rebind trusted provider metadata after live reuse has been accepted and * the runtime has verified that the session state did not change. */ rebindPreservedOwnedSessionState?(state: TSessionState, options?: SandboxPreservedSessionReuseOptions): void; deserializeSessionState?(state: Record): Promise; /** * Resolves the current trusted manifest to the provider-owned root used by * persisted session state before security-sensitive resume validation. */ resolveTrustedManifestForResume?(manifest: Manifest, options?: TOptions): Manifest; /** Synchronously validates resume policy before environment materialization. */ validateSessionStateForResume?(input: SandboxSessionResumeValidationInput, options?: SandboxClientResumeOptions): void; resume?(state: TSessionState, options?: SandboxClientResumeOptions): Promise>; } export type SandboxRunConfig = { client?: SandboxClient; options?: TOptions; session?: SandboxSessionLike; sessionState?: TSessionState; manifest?: ManifestInput; snapshot?: SnapshotSpec; concurrencyLimits?: SandboxConcurrencyLimits; archiveLimits?: SandboxArchiveLimits | null; /** * Workspace-relative POSIX working directory for built-in sandbox tools in this run. */ cwd?: string; }; export declare function normalizeSandboxClientCreateArgs(args?: SandboxClientCreateArgs | Manifest, manifestOptions?: TOptions, validationOptions?: { environmentPreparation?: 'client'; }): NormalizedSandboxClientCreateArgs; export declare function resolveSandboxArchiveLimits(limits?: SandboxArchiveLimits | null): ResolvedSandboxArchiveLimits | null; export declare function validateSandboxArchiveLimits(limits?: SandboxArchiveLimits | null): void;