UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

52 lines • 1.86 kB
import type { Workspace } from './workspace/workspace.ts'; /** * A {@link Workspace} wrapper that owns its lifecycle and provides a * canonical handle for callers that want a single owner per workspace. * * In Python this class pins the workspace to its own asyncio event * loop in a background thread, isolating it from the caller's loop. * Node.js has a single event loop per thread, so there's no * cross-loop handoff to perform; TS `call()` simply awaits the * supplied promise on the current loop. Callers who need true OS- * thread isolation should place the workspace inside a Worker and * communicate via message-passing. * * What this class DOES provide in TS: * - A clear owner: the runner is responsible for closing the workspace. * - Lifecycle guardrails: `call()` rejects after `stop()`. * - API parity with Python for code that ports over verbatim. * * @example * ```ts * const runner = new WorkspaceRunner(new Workspace({ '/': ram })) * try { * const result = await runner.call(runner.ws.shell('ls /')) * } finally { * await runner.stop() * } * ``` */ export declare class WorkspaceRunner { readonly ws: Workspace; private stopped; private stopping; constructor(ws: Workspace); /** * Await a workspace-produced promise. * * Rejects if the runner has been stopped. Does not block — Node's * single event loop interleaves this call with other work as usual. * * @param p a promise produced from the workspace API (e.g. * `runner.ws.shell('ls /')`). */ call<T>(p: Promise<T>): Promise<T>; /** * Close the workspace (delete it, with `delete`) and mark the runner as * stopped. Idempotent; concurrent calls are deduplicated. */ stop(options?: { delete?: boolean; }): Promise<void>; } //# sourceMappingURL=runner.d.ts.map