UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

58 lines • 2.63 kB
import type { JqError, JqHalt } from './types.ts'; export declare const FRAME_OUTPUT = 1; export declare const FRAME_ERROR = 2; export declare const FRAME_HALT = 3; export declare const FRAME_DEBUG = 4; export declare const FRAME_STDERR = 5; export declare const COMPILE_REPORT: RegExp; export declare const MEMORY_REPORT = "jq memory limit of {} bytes exceeded"; /** * The time zone jq's local time reads, as a `TZ` value: the command * environment's, else the process's, else the host's own zone. */ export declare function localZone(env: Record<string, string> | undefined): string; /** * How a run whose outputs went out as it made them ended: the error or halt * that stopped it, if one did. */ export interface Ending { stop: JqError | JqHalt | null; } /** * Fold one drain of mirage-rs's jq_eval into a run: each output frame is a * compact dump, pushed onto `outputs`, a `debug` or `stderr` frame is * dropped, and an error or a halt frame is what stopped the run. A frame is a * tag, a little-endian u32 length and its payload; an error's flag byte says * whether it is a string (bit 0) and whether the program raised it with * `error` itself (bit 1). */ export declare function readFrames(bytes: Uint8Array, outputs: Uint8Array[]): JqError | JqHalt | null; /** * A program compiled once by mirage-rs's jq_eval and run on one value at a * time on this thread, a bounded number of VM steps per drain, so a program * that never ends still yields and the signal can stop it between two. * `input` finds no more input, `$ENV` is the given environment, and what * `debug` and `stderr` write is dropped, as `gh --jq` evaluates. Mirrors * Python's Engine. */ export declare class Engine { private readonly stream; private readonly memory; private readonly budget; private constructor(); /** * Compile `expr`, as typed, with `env` (JSON text) as `$ENV` and `env` and * `zone` (localZone) as the `TZ` local time reads. Throws JqCompileError, * with jq's report, for a program jq itself refuses. */ static open(expr: string, env: string, zone: string, signal?: AbortSignal): Promise<Engine>; /** * Run the program on one value's JSON text, yielding each output's compact * dump as a drain decodes it, and leave on `ending` how the run stopped. A * run its caller stops reading is cancelled, so the next can begin. */ run(doc: string, ending: Ending): AsyncGenerator<string, void, undefined>; /** Close the program; a run cut short is retired a bounded slice at a time. */ close(): Promise<void>; } //# sourceMappingURL=eval.d.ts.map