import { i as OpenClawConfig } from "./types.openclaw-DH5a2ppk.js"; import { d as SandboxDockerSettings } from "./types.provider-request-D8-dJlQu.js"; import { a as SkillUsagePath, n as SkillEligibilityContext } from "./types-DKGs3QG0.js"; //#region src/agents/sandbox/fs-bridge.types.d.ts /** * Public sandbox filesystem bridge contracts. * * Tool and backend code use this interface to access files through the sandbox * boundary instead of reaching directly into host paths. */ /** Resolved sandbox path with host, relative, and container views. */ type SandboxResolvedPath = { hostPath?: string; relativePath: string; containerPath: string; }; /** Minimal file stat shape returned by sandbox fs bridge implementations. */ type SandboxFsStat = { type: "file" | "directory" | "other"; size: number; mtimeMs: number; }; /** Filesystem operations exposed across the sandbox boundary. */ type SandboxFsBridge = { resolvePath(params: { filePath: string; cwd?: string; }): SandboxResolvedPath; readFile(params: { filePath: string; cwd?: string; signal?: AbortSignal; }): Promise; writeFile(params: { filePath: string; cwd?: string; data: Buffer | string; encoding?: BufferEncoding; mkdir?: boolean; signal?: AbortSignal; }): Promise; mkdirp(params: { filePath: string; cwd?: string; signal?: AbortSignal; }): Promise; remove(params: { filePath: string; cwd?: string; recursive?: boolean; force?: boolean; signal?: AbortSignal; }): Promise; rename(params: { from: string; to: string; cwd?: string; signal?: AbortSignal; }): Promise; stat(params: { filePath: string; cwd?: string; signal?: AbortSignal; }): Promise; }; //#endregion //#region src/agents/sandbox/backend-handle.types.d.ts /** * Backend-neutral sandbox runtime handles used by Docker, SSH, and future sandbox providers. */ type SandboxBackendId = string; /** Shell exec specification prepared by a sandbox backend for process launch. */ type SandboxBackendExecSpec = { argv: string[]; env: NodeJS.ProcessEnv; stdinMode: "pipe-open" | "pipe-closed"; finalizeToken?: unknown; }; type SandboxBackendWorkdirValidation = "host" | "backend"; type SandboxBackendWorkdirValidator = (workdir: string) => Promise; type SandboxBackendPreparedWorkdirDiscarder = (workdir: string) => void; /** Parameters for backend-managed shell commands used by fs bridges and probes. */ type SandboxBackendCommandParams = { script: string; args?: string[]; stdin?: Buffer | string; allowFailure?: boolean; signal?: AbortSignal; }; /** Buffered command result returned by sandbox backend shell helpers. */ type SandboxBackendCommandResult = { stdout: Buffer; stderr: Buffer; code: number; }; /** Runtime context passed to backend-provided filesystem bridge factories. */ type SandboxFsBridgeContext = { workspaceDir: string; agentWorkspaceDir: string; skillsWorkspaceDir?: string; workspaceAccess: "none" | "ro" | "rw"; containerName: string; containerWorkdir: string; docker: { binds?: string[]; }; backend?: { runShellCommand(params: SandboxBackendCommandParams): Promise; }; }; /** Live sandbox backend handle for command execution, cleanup, and optional fs bridge creation. */ type SandboxBackendHandle = { id: SandboxBackendId; runtimeId: string; runtimeLabel: string; workdir: string; env?: Record; configLabel?: string; configLabelKind?: string; /** * Remote backends own cwd existence checks because valid runtime paths may * not exist in the local workspace mirror. Backend validation must be paired * with validateWorkdir so cwd is proved after before_tool_call adjustments * and before env resolution, approval, preflight, and launch. */ workdirValidation?: SandboxBackendWorkdirValidation; validateWorkdir?: SandboxBackendWorkdirValidator; /** Discard one-shot state created while validating a backend-owned cwd. */ discardPreparedWorkdir?: SandboxBackendPreparedWorkdirDiscarder; /** Remote cwd roots managed by backend validation. Defaults to workdir. */ workdirRoots?: readonly string[]; capabilities?: { browser?: boolean; }; buildExecSpec(params: { command: string; workdir?: string; env: Record; usePty: boolean; }): Promise; finalizeExec?: (params: { status: "completed" | "failed"; exitCode: number | null; timedOut: boolean; token?: unknown; }) => Promise; runShellCommand(params: SandboxBackendCommandParams): Promise; createFsBridge?: (params: { sandbox: SandboxFsBridgeContext; }) => SandboxFsBridge; }; //#endregion //#region src/agents/sandbox/types.docker.d.ts type RequiredDockerConfigKeys = "image" | "containerPrefix" | "workdir" | "readOnlyRoot" | "tmpfs" | "network" | "capDrop"; type SandboxDockerConfig = Omit & Required>; //#endregion //#region src/agents/sandbox/types.d.ts type SandboxToolPolicy = { allow?: string[]; deny?: string[]; }; type SandboxToolPolicySource = { source: "agent" | "global" | "default"; /** * Config key path hint for humans. * (Arrays use `agents.list[].…` form.) */ key: string; }; type SandboxToolPolicyResolved = { allow: string[]; deny: string[]; sources: { allow: SandboxToolPolicySource; deny: SandboxToolPolicySource; }; }; type SandboxWorkspaceAccess = "none" | "ro" | "rw"; type SandboxBrowserConfig = { enabled: boolean; image: string; containerPrefix: string; network: string; cdpPort: number; cdpSourceRange?: string; vncPort: number; noVncPort: number; headless: boolean; enableNoVnc: boolean; allowHostControl: boolean; autoStart: boolean; autoStartTimeoutMs: number; binds?: string[]; }; type SandboxPruneConfig = { idleHours: number; maxAgeDays: number; }; type SandboxSshConfig = { target?: string; command: string; workspaceRoot: string; strictHostKeyChecking: boolean; updateHostKeys: boolean; identityFile?: string; certificateFile?: string; knownHostsFile?: string; identityData?: string; certificateData?: string; knownHostsData?: string; }; type SandboxScope = "session" | "agent" | "shared"; type SandboxConfig = { mode: "off" | "non-main" | "all"; backend: SandboxBackendId; scope: SandboxScope; workspaceAccess: SandboxWorkspaceAccess; workspaceRoot: string; docker: SandboxDockerConfig; ssh: SandboxSshConfig; browser: SandboxBrowserConfig; tools: SandboxToolPolicy; prune: SandboxPruneConfig; }; type SandboxBrowserContext = { bridgeUrl: string; noVncUrl?: string; containerName: string; }; type SandboxContext = { enabled: boolean; backendId: SandboxBackendId; sessionKey: string; workspaceDir: string; agentWorkspaceDir: string; skillsWorkspaceDir?: string; skillsEligibility?: SkillEligibilityContext; skillUsagePaths?: SkillUsagePath[]; workspaceAccess: SandboxWorkspaceAccess; runtimeId: string; runtimeLabel: string; containerName: string; containerWorkdir: string; docker: SandboxDockerConfig; tools: SandboxToolPolicy; browserAllowHostControl: boolean; browser?: SandboxBrowserContext; fsBridge?: SandboxFsBridge; backend?: SandboxBackendHandle; }; //#endregion //#region src/agents/sandbox/context.d.ts declare function resolveSandboxContext(params: { config?: OpenClawConfig; sessionKey?: string; workspaceDir?: string; }): Promise; //#endregion //#region src/agents/sandbox/registry.d.ts type SandboxRegistryEntry = { containerName: string; backendId?: string; runtimeLabel?: string; sessionKey: string; createdAtMs: number; lastUsedAtMs: number; image: string; configLabelKind?: string; configHash?: string; }; //#endregion //#region src/agents/sandbox/backend.types.d.ts /** Current runtime state reported by a sandbox backend manager. */ type SandboxBackendRuntimeInfo = { running: boolean; actualConfigLabel?: string; configLabelMatch: boolean; }; /** Optional lifecycle manager for an existing registered sandbox runtime. */ type SandboxBackendManager = { describeRuntime(params: { entry: SandboxRegistryEntry; config: OpenClawConfig; agentId?: string; }): Promise; removeRuntime(params: { entry: SandboxRegistryEntry; config: OpenClawConfig; agentId?: string; }): Promise; }; /** Inputs needed to create a sandbox backend handle for one session scope. */ type CreateSandboxBackendParams = { sessionKey: string; scopeKey: string; workspaceDir: string; agentWorkspaceDir: string; skillsWorkspaceDir?: string; cfg: SandboxConfig; }; /** Factory that creates a backend handle for a sandbox session. */ type SandboxBackendFactory = (params: CreateSandboxBackendParams) => Promise; /** Resolve the runtime workdir without creating or starting the backend. */ type SandboxBackendWorkdirResolver = (params: CreateSandboxBackendParams) => string; /** Registry input accepted for sandbox backend registration. */ type SandboxBackendRegistration = SandboxBackendFactory | { factory: SandboxBackendFactory; manager?: SandboxBackendManager; resolveWorkdir?: SandboxBackendWorkdirResolver; }; //#endregion //#region src/agents/sandbox/backend.d.ts /** Register or replace a sandbox backend and return a restore callback. */ declare function registerSandboxBackend(id: string, registration: SandboxBackendRegistration): () => void; /** Look up a sandbox backend factory by normalized backend id. */ declare function getSandboxBackendFactory(id: string): SandboxBackendFactory | null; /** Look up optional lifecycle management hooks for a registered backend. */ declare function getSandboxBackendManager(id: string): SandboxBackendManager | null; /** Look up optional backend workdir resolution that does not start the runtime. */ declare function getSandboxBackendWorkdirResolver(id: string): SandboxBackendWorkdirResolver | null; /** Resolve a backend factory or throw the user-facing configuration error. */ declare function requireSandboxBackendFactory(id: string): SandboxBackendFactory; //#endregion //#region src/agents/sandbox/sanitize-env-vars.d.ts type EnvVarSanitizationResult = { allowed: Record; blocked: string[]; warnings: string[]; }; type EnvSanitizationOptions = { strictMode?: boolean; customBlockedPatterns?: ReadonlyArray; customAllowedPatterns?: ReadonlyArray; }; /** Sanitizes inherited environment variables for automatic sandbox propagation. */ declare function sanitizeEnvVars(envVars: Record, options?: EnvSanitizationOptions): EnvVarSanitizationResult; //#endregion //#region src/agents/sandbox/runtime-status.d.ts /** Resolves sandbox mode, effective session scope, and tool policy for a session. */ declare function resolveSandboxRuntimeStatus(params: { cfg?: OpenClawConfig; sessionKey?: string; }): { agentId: string; sessionKey: string; mainSessionKey: string; mode: SandboxConfig["mode"]; sandboxed: boolean; toolPolicy: SandboxToolPolicyResolved; }; //#endregion //#region src/agents/sandbox/tool-policy.d.ts declare function isToolAllowed(policy: SandboxToolPolicy, name: string): boolean; //#endregion //#region src/agents/sandbox/ssh.d.ts type SshSandboxSettings = { command: string; target: string; strictHostKeyChecking: boolean; updateHostKeys: boolean; identityFile?: string; certificateFile?: string; knownHostsFile?: string; identityData?: string; certificateData?: string; knownHostsData?: string; }; /** Temporary SSH session descriptor with an isolated config file. */ type SshSandboxSession = { command: string; configPath: string; host: string; }; /** Parameters for one SSH sandbox command execution. */ type RunSshSandboxCommandParams = { session: SshSandboxSession; remoteCommand: string; stdin?: Buffer | string; allowFailure?: boolean; signal?: AbortSignal; tty?: boolean; }; /** Single-quote a value for POSIX shell argv construction. */ declare function shellEscape(value: string): string; /** Build a remote shell command from literal argv entries. */ declare function buildRemoteCommand(argv: string[]): string; /** Build the wrapped remote `/bin/sh -c` command for sandbox exec. */ declare function buildExecRemoteCommand(params: { command: string; workdir?: string; env: Record; }): string; /** Validate and build a remote exec command for untrusted model input. */ declare function buildValidatedExecRemoteCommand(params: { command: string; workdir?: string; env: Record; }): string; declare function buildRemoteWorkdirValidationCommand(params: { workdir: string; root: string; }): string; /** Build the local ssh argv for a prepared sandbox session. */ declare function buildSshSandboxArgv(params: { session: SshSandboxSession; remoteCommand: string; tty?: boolean; }): string[]; /** Create a temporary SSH session from already-rendered ssh config text. */ declare function createSshSandboxSessionFromConfigText(params: { configText: string; host?: string; command?: string; }): Promise; /** Create a temporary SSH session from structured sandbox SSH settings. */ declare function createSshSandboxSessionFromSettings(settings: SshSandboxSettings): Promise; /** Remove temporary SSH config and materialized secret files. */ declare function disposeSshSandboxSession(session: SshSandboxSession): Promise; /** Run a remote command through ssh and return buffered stdout/stderr. */ declare function runSshSandboxCommand(params: RunSshSandboxCommandParams): Promise; /** Stream a local directory to the remote sandbox with tar over ssh. */ declare function uploadDirectoryToSshTarget(params: { session: SshSandboxSession; localDir: string; remoteDir: string; remoteRootDir?: string; signal?: AbortSignal; }): Promise; //#endregion //#region src/agents/sandbox/remote-fs-bridge.d.ts /** Minimal remote shell contract used by the SSH filesystem bridge. */ type RemoteShellSandboxHandle = { remoteWorkspaceDir: string; remoteAgentWorkspaceDir: string; runRemoteShellScript(params: SandboxBackendCommandParams): Promise; }; /** Create the filesystem bridge for remote shell-backed sandbox runtimes. */ declare function createRemoteShellSandboxFsBridge(params: { sandbox: SandboxFsBridgeContext; runtime: RemoteShellSandboxHandle; }): SandboxFsBridge; //#endregion //#region src/agents/sandbox/fs-bridge-rename-targets.d.ts /** * Shared writable-target resolution for sandbox fs bridge rename operations. */ /** Resolves both rename endpoints and verifies write access before command execution. */ declare function resolveWritableRenameTargets(params: { from: string; to: string; cwd?: string; action?: string; resolveTarget: (params: { filePath: string; cwd?: string; }) => T; ensureWritable: (target: T, action: string) => void; }): { from: T; to: T; }; /** Adapter used by bridge implementations that pass resolver callbacks separately. */ declare function resolveWritableRenameTargetsForBridge(params: { from: string; to: string; cwd?: string; action?: string; }, resolveTarget: (params: { filePath: string; cwd?: string; }) => T, ensureWritable: (target: T, action: string) => void): { from: T; to: T; }; /** Creates a reusable resolver bound to a bridge's target and permission helpers. */ declare function createWritableRenameTargetResolver(resolveTarget: (params: { filePath: string; cwd?: string; }) => T, ensureWritable: (target: T, action: string) => void): (params: { from: string; to: string; cwd?: string; }) => { from: T; to: T; }; //#endregion export { SandboxBackendManager as A, SandboxBackendCommandResult as B, getSandboxBackendFactory as C, requireSandboxBackendFactory as D, registerSandboxBackend as E, SandboxContext as F, SandboxBackendWorkdirValidation as G, SandboxBackendHandle as H, SandboxSshConfig as I, SandboxFsStat as J, SandboxBackendWorkdirValidator as K, SandboxToolPolicy as L, SandboxBackendRuntimeInfo as M, SandboxBackendWorkdirResolver as N, CreateSandboxBackendParams as O, resolveSandboxContext as P, SandboxWorkspaceAccess as R, sanitizeEnvVars as S, getSandboxBackendWorkdirResolver as T, SandboxBackendId as U, SandboxBackendExecSpec as V, SandboxBackendPreparedWorkdirDiscarder as W, SandboxResolvedPath as Y, runSshSandboxCommand as _, createRemoteShellSandboxFsBridge as a, isToolAllowed as b, SshSandboxSettings as c, buildRemoteWorkdirValidationCommand as d, buildSshSandboxArgv as f, disposeSshSandboxSession as g, createSshSandboxSessionFromSettings as h, RemoteShellSandboxHandle as i, SandboxBackendRegistration as j, SandboxBackendFactory as k, buildExecRemoteCommand as l, createSshSandboxSessionFromConfigText as m, resolveWritableRenameTargets as n, RunSshSandboxCommandParams as o, buildValidatedExecRemoteCommand as p, SandboxFsBridge as q, resolveWritableRenameTargetsForBridge as r, SshSandboxSession as s, createWritableRenameTargetResolver as t, buildRemoteCommand as u, shellEscape as v, getSandboxBackendManager as w, resolveSandboxRuntimeStatus as x, uploadDirectoryToSshTarget as y, SandboxBackendCommandParams as z };