@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
38 lines • 1.59 kB
TypeScript
/**
* The max_memory a workspace runs under when it names none: with the 32 MB
* read cache, 64 MB a workspace, 32 of them on a 2 GiB machine. Mirrors
* Python's MAX_MEMORY.
*/
export declare const MAX_MEMORY: number;
/**
* A workspace's `max_memory` and the bytes its stores hold.
*
* What the workspace stores is counted exactly, by the stores themselves,
* and `held` sums it when asked, so nothing is charged or released here and
* the count cannot drift. An object a command builds while it runs must fit
* in what is left (`room`). Mirrors Python's `MemoryBudget`.
*/
export declare class MemoryBudget {
readonly limit: number;
readonly held: () => number;
constructor(limit: number, held: () => number);
/** The bytes left under the limit, never below 0. */
room(): number;
}
/**
* `fn` run under a workspace's memory budget, which what it stores and every
* object it builds are checked against. Mirrors Python's `run_with_memory`.
*/
export declare function runWithMemory<T>(memory: MemoryBudget | null, fn: () => Promise<T>): Promise<T>;
/**
* The bytes left in the running workspace's budget, null for no cap. A
* browser cannot tell one task's binding from another's, so there it is the
* least any live budget has left. Mirrors Python's `memory_room`.
*/
export declare function memoryRoom(): number | null;
/**
* Refuse an object that grew to `size` bytes past what the running
* workspace's budget has left. Mirrors Python's `check_memory`.
*/
export declare function checkMemory(size: number): void;
//# sourceMappingURL=memory.d.ts.map