@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
54 lines • 2.27 kB
TypeScript
import type { FlagValue } from '../../../commands/spec/types.ts';
import type { PyodideInterface } from './loader.ts';
import type { XattrOp } from './fs/types.ts';
/**
* The guest's extended-attribute entry point, registered as `_mirage_xattr`:
* the op, the absolute path, the name and base64 value where the op has
* them, the create/replace flags and nofollow, answered as JSON (`{value}`,
* or `{code}` naming the condition).
*/
export type XattrCall = (op: XattrOp, path: string, name: string | null | undefined, value: string | null | undefined, create: boolean, replace: boolean, nofollow: boolean) => string;
/**
* The run's standard streams as the guest's own stdio reaches them,
* registered as `_mirage_stdio`.
*/
export interface GuestStdio {
/** One read(2) of the run's input: what has arrived, up to `size` bytes; empty at its end. */
read(size: number): Uint8Array;
/** Hand one write to stdout (1) or stderr (2): false once its reader has gone. */
write(fd: 1 | 2, bytes: Uint8Array): boolean;
}
interface ExecutionRequest {
code: string;
env: Record<string, string>;
stdin: Uint8Array | null;
piped?: boolean;
argv: string[];
cwd: string;
flags: Readonly<Record<string, FlagValue>>;
script_cli: boolean;
filename: string | null;
script: boolean;
}
export declare class PyodideExecution {
private readonly pyodide;
private readonly namespace;
private stdio;
constructor(pyodide: PyodideInterface, xattr?: XattrCall, subprocess?: (payload: string) => string, seal?: () => void);
/**
* Run one program. Its output comes back in the result, or, where the
* run's streams are given, goes to them as it is written and the
* result leaves it out.
*
* @param request the program and what of the run's context it reads.
* @param arm starts the run's interrupt countdown.
* @param disarm stops it.
* @param stdio the run's streams; absent reads `request.stdin`.
*/
run(request: ExecutionRequest, arm: () => void, disarm: () => void, stdio?: GuestStdio): [Uint8Array, Uint8Array, number];
seedSysPath(paths: readonly string[]): string[];
close(): void;
private call;
}
export {};
//# sourceMappingURL=execution.d.ts.map