UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

79 lines • 4.29 kB
import { FlagView } from '../../spec/flag_view.ts'; import { type Served } from '../../../rs/stream.ts'; import { ByteSpool } from '../../../io/spool.ts'; import { IOResult } from '../../../io/types.ts'; import { PathSpec, type JsonValue, type ReadStreamFn } from '../../../types.ts'; import { type CommandFnResult, type Context } from '../../config.ts'; /** * jq's words in the order typed, as mirage-rs's option loop reads them, and * the file at each place on them that names one. The bag's tape keeps where * each word was typed, and the bag what it was: a binding's name and value, * and the file -f names, which the tape holds resolved. A file is named as * the word typed. Operands the bag has no tape for (a plain record) come * after every option. * Mirrors Python's option_tape. */ export declare function optionTape(fl: FlagView, texts: readonly string[]): [[string, string][], Map<number, PathSpec>]; /** * What jq's option loop decided for a run: the run config the options * decide, and the program, as the operand typed or the file -f names. * Mirrors Python's OptionPlan. */ export interface OptionPlan { readonly config: Readonly<Record<string, JsonValue>>; readonly program: string | PathSpec; } /** * jq's option loop in mirage-rs: the run it decides, what --help or * --version prints where the loop reaches one, or the first word it refuses * as the command's result, in jq's words. `tape` and `files` are * optionTape's, and `read` the byte reader for a --rawfile or --slurpfile. * Throws for a reply that lacks what the loop always answers. Mirrors * Python's read_options. */ export declare function readOptions(tape: readonly (readonly [string, string])[], files: ReadonlyMap<number, PathSpec>, read: (path: PathSpec) => Promise<Uint8Array>): Promise<OptionPlan | Uint8Array | IOResult>; /** * A flag's file as jq's reports name it: the word typed, `-` included, since * jq opens that one as a file too. */ export declare function flagFileName(path: PathSpec): string; /** An input as jq's reports name it: the operand as typed, and `<stdin>` for `-`. */ export declare function inputName(path: PathSpec): string; /** * The inputs jq's main loop reads, each opened when the loop first asks for * its bytes, as jq opens its files one after another, and the clock `now` * reads. `sources` are the inputs, in order, not yet opened; each goes over * in bounded pieces, so the loop holds no more of it than it is reading. * Mirrors Python's JqInputs. */ export declare class JqInputs { readonly errors: ByteSpool; private readonly iterators; private readonly sources; constructor(sources: readonly AsyncIterable<Uint8Array>[], signal?: AbortSignal); /** * Answer the stream: the clock, or the next bytes of an input, its end, or * why it could not be opened or read, in strerror's words. */ serve(request: Readonly<Record<string, JsonValue>>): Promise<Served>; /** Close every input, the one the loop stopped in among them. */ close(): Promise<void>; } /** * What mirage-rs's jq takes for one invocation: the program, what the option * loop decided (readOptions), `env` (JSON text) as `$ENV` and `env`, `zone` * (localZone) as the `TZ` local time reads, `origin` as the directory * `get_prog_origin` answers, and the inputs' names as jq reports them. * Mirrors Python's run_config. */ export declare function runConfig(expr: string, options: Readonly<Record<string, JsonValue>>, env: string, zone: string, origin: string | null, inputs: readonly string[]): Record<string, JsonValue>; /** * jq's main loop in mirage-rs over the inputs, a bounded slice of work at a * time: what the runs print, as they print it, with jq's exit status and * stderr settled on `io` once the stream is drained. Throws MemoryExhausted, * after what was printed before it, once what jq holds outgrew the * workspace's room. Mirrors Python's run_outputs. */ export declare function runOutputs(config: Readonly<Record<string, JsonValue>>, inputs: JqInputs, io: IOResult, signal?: AbortSignal): AsyncGenerator<Uint8Array, void, undefined>; export declare function jqGeneric(paths: PathSpec[], texts: string[], ctx: Context, stream: ReadStreamFn): Promise<CommandFnResult>; //# sourceMappingURL=jq.d.ts.map