@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
24 lines • 1.05 kB
TypeScript
/** How often a run's memory is read while it is in flight. */
export declare const WATCH_INTERVAL_MS = 50;
/**
* Watch a worker's memory while one run is in flight, and call `exceeded`
* once it passes `limit`.
*
* Pyodide sets no cap of its own: its heap grows until wasm's 4 GiB
* ceiling, and a guest stuck in a loop never yields to a check of its
* own. The worker answers a memory read even while its guest is busy, so
* the watch runs outside it and the caller stops the worker, which is the
* only way to stop such a guest. The heap never shrinks, so a run that
* leaves it near the cap leaves the next run less room, as the same
* process would.
*
* Args:
* memory: reads the worker's memory in bytes.
* limit: the cap, in bytes.
* exceeded: called once, with the bytes read, when the cap is passed.
*
* Returns:
* A function that stops the watch.
*/
export declare function watchMemory(memory: () => Promise<number>, limit: number, exceeded: (used: number) => void): () => void;
//# sourceMappingURL=watchdog.d.ts.map