UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

39 lines (38 loc) • 2.42 kB
import { type ExecResult, type ExecutionEnv, type ExecutionEnvCapabilities, ExecutionError, FileError, type FileInfo, type Result } from "../internal/harness.js"; /** * A no-op ExecutionEnv for tool/MCP-only deployments (no shell, no filesystem). * * AgentHarness requires an `env`, but the normal tools+MCP code path never touches it. * Every filesystem op returns a `not_supported` FileError; `exec` returns `shell_unavailable`. * If a task genuinely needs shell/fs, supply a real ExecutionEnv instead (e.g. a Node or SSH one). */ export declare class StubExecutionEnv implements ExecutionEnv { cwd: string; /** `ExecutionEnv.capabilities`: no target at all (`io: false`) — every operation refuses, so it produces no outside * content, names no path that is not the engine host's, and keeps the byte floor and any command sandbox by refusing * every start (`keepsReadFloor: true`, `commandSandbox: true`). A subclass that overrides operations with real I/O states its own block. */ readonly capabilities: ExecutionEnvCapabilities; /** `ExecutionEnv.cdPath`: the stub runs no shell, so no shell receives a `CDPATH`. */ readonly cdPath: readonly string[]; /** `ExecutionEnv.withheldEnv`: no shell child, so nothing is withheld from one. */ readonly withheldEnv: readonly []; constructor(cwd?: string); private fsErr; absolutePath(path: string): Promise<Result<string, FileError>>; joinPath(): Promise<Result<string, FileError>>; readTextFile(path: string): Promise<Result<string, FileError>>; readTextLines(path: string): Promise<Result<string[], FileError>>; readBinaryFile(path: string): Promise<Result<Uint8Array, FileError>>; writeFile(path: string): Promise<Result<void, FileError>>; appendFile(path: string): Promise<Result<void, FileError>>; fileInfo(path: string): Promise<Result<FileInfo, FileError>>; listDir(path: string): Promise<Result<FileInfo[], FileError>>; canonicalPath(path: string): Promise<Result<string, FileError>>; exists(path: string): Promise<Result<boolean, FileError>>; createDir(path: string): Promise<Result<void, FileError>>; remove(path: string): Promise<Result<void, FileError>>; createTempDir(): Promise<Result<string, FileError>>; createTempFile(): Promise<Result<string, FileError>>; exec(): Promise<Result<ExecResult, ExecutionError>>; cleanup(): Promise<void>; }