Environment API
The Environment class represents the isolated execution sandbox allocated to an agent or application.
Sandbox Structure
An environment is mapped to a unique name combining the scope and ID:
typescript
const name = "agent:user1/app1/agentId";
// or app scope
const name = "app:user1/app1";Workspace FS Interface
When running within the runtime, environments implement a subset of filesystem methods:
typescript
export interface WorkspaceFsLike {
readFile(path: string): Promise<string | null>;
writeFile(path: string, content: string, mimeType?: string): Promise<void>;
appendFile(path: string, content: string, mimeType?: string): Promise<void>;
exists(path: string): Promise<boolean>;
readDir(path?: string, opts?: any): Promise<FileInfo[]>;
rm(path: string, opts?: any): Promise<void>;
glob(pattern: string): Promise<FileInfo[]>;
mkdir(path: string, opts?: any): Promise<void>;
}SQL Execution Method
You can execute queries directly on the SQLite database linked to this environment:
typescript
async runSql(query: string, params?: any[]): Promise<any[]>For information on storing credentials securely in these environments, check the Secrets API.