@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
32 lines • 1.93 kB
TypeScript
import { IOResult } from '../io/types.ts';
import { StreamRefusal } from './errors.ts';
import type { JsonValue } from '../types.ts';
export declare const SCANS: Map<string, Map<string, string | StreamRefusal>>;
/**
* A command's typed words, read by mirage-rs before any input is read. The
* tape holds each option as `[dest, value]` in the order typed, a switch with
* an empty value. A grammar that reads its operands also gets each operand as
* `[OPERAND, word]` where it was typed, a glob already expanded into its
* matches in its place. A value the command refuses never reaches an input.
* Returns the values keyed as the command's grammar answers; throws
* StreamRefusal for the first word the command refuses, with the command's
* exit status.
*
* A tape's answer is kept, per command, as a spec keeps its parses
* (PARSES_KEPT, PARSE_KEPT_CHARS), so the admission gate and the handler
* reading one line's options share one scan; each entry counts its name, its
* value and one more toward PARSE_KEPT_CHARS, so a run of switches is bounded
* too. It is kept as the text mirage-rs answered and decoded per reader, so no
* reader sees another's changes; a refusal is kept as a copy never thrown, as
* Python keeps no traceback of the refused call. Mirrors Python's `scan`.
*/
export declare function scan(command: string, options: readonly (readonly [string, string])[]): Record<string, JsonValue>;
/**
* `scan` for a command whose refusals travel as usage errors: throws
* UsageError for the first value the command refuses, in its words and with
* its exit status. Mirrors Python's `scanned`.
*/
export declare function scanned(command: string, options: readonly (readonly [string, string])[]): Record<string, JsonValue>;
/** A scan's refusal as the command's result. Mirrors Python's `refused`. */
export declare function refused(refusal: StreamRefusal): IOResult;
//# sourceMappingURL=scan.d.ts.map