UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

75 lines (74 loc) • 1.79 kB
import { ExecutionError, FileError, err, } from "../internal/harness.js"; const STUB_ENV_CAPABILITIES = Object.freeze({ isolation: false, suspendable: false, sharesProcessTable: true, canonicalPathAuthoritative: false, hostLocalPaths: true, externalContentTarget: false, io: false, keepsReadFloor: true, commandSandbox: true, }); export class StubExecutionEnv { cwd; capabilities = STUB_ENV_CAPABILITIES; cdPath = []; withheldEnv = []; constructor(cwd = "/") { this.cwd = cwd; } fsErr(path) { return Promise.resolve(err(new FileError("not_supported", "filesystem is not available in this environment", path))); } absolutePath(path) { return this.fsErr(path); } joinPath() { return this.fsErr(); } readTextFile(path) { return this.fsErr(path); } readTextLines(path) { return this.fsErr(path); } readBinaryFile(path) { return this.fsErr(path); } writeFile(path) { return this.fsErr(path); } appendFile(path) { return this.fsErr(path); } fileInfo(path) { return this.fsErr(path); } listDir(path) { return this.fsErr(path); } canonicalPath(path) { return this.fsErr(path); } exists(path) { return this.fsErr(path); } createDir(path) { return this.fsErr(path); } remove(path) { return this.fsErr(path); } createTempDir() { return this.fsErr(); } createTempFile() { return this.fsErr(); } exec() { return Promise.resolve(err(new ExecutionError("shell_unavailable", "shell execution is not available in this environment"))); } async cleanup() { } }