UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

49 lines • 2.97 kB
import type { FlagValue } from '../../spec/types.ts'; import { IOResult, type ByteSource } from '../../../io/types.ts'; import type { DispatchFn } from '../../../runtime/types.ts'; import { type PathSpec } from '../../../types.ts'; export declare const PROGRAM_FILE_COMMANDS: Set<string>; export declare const FILE_KEYS: Readonly<Record<string, string>>; /** * A program file the command cannot read, in its own words and code. * * sed could not open the file, exit 4. mawk quotes the name after `cannot * open`, and a file it opened and then failed to read, which is how a * directory fails, is a bare `read error`. jq could not open it, and calls a * directory one in words of its own. ripgrep appends the errno, with no space * after the colon for a failed read. zgrep copies each pattern file with cat, * so the line is cat's. grep names it as any operand. Every other code is 2. * Pinned on debian:stable-slim (grep 3.11, sed 4.9, mawk 1.3.4, jq 1.7.1, * ripgrep 14.1.1, gzip 1.13). Mirrors Python's program_file_refusal. */ export declare function programFileRefusal(name: string, path: PathSpec, err: unknown): [string, number]; /** * One program file's bytes, read through the dispatcher. A directory opens and * fails at its read, which a keyed store's own read cannot tell from nothing * being there, so a stat goes first; sed alone reads a directory as an empty * script (sed 4.9). Mirrors Python's read_program_file. */ export declare function readProgramFile(name: string, path: PathSpec, dispatch: DispatchFn): Promise<Uint8Array>; /** * The invocation's program files, or an empty list for inline programs. * grep's --exclude-from files count: they are read the same way, once, before * routing. */ export declare function programFiles(name: string, bag: Record<string, FlagValue>): PathSpec[]; /** * grep's or rg's refusal of an option value on the line, or null. Both check * every value in their option loop and answer --help and --version only once * it is done (grep 3.11, ripgrep 14.1.1: `grep -D bogus -V` and `rg --sort * bogus --version` are refused). The pattern is not compiled yet, as neither * has by then. Mirrors Python's `value_refusal`. */ export declare function valueRefusal(name: string, bag: Record<string, FlagValue>): IOResult | null; /** Read program files once before input routing or traversal fan-out. * Lower to the inline form so every native sub-run sees the same program, * including when reading it consumed stdin. Pinned against debian:stable-slim * (grep 3.11, sed 4.9, ripgrep 14.1.1). * `operands` are the path operands, which rg checks for a `-` once `-f -` has * read stdin. */ export declare function prepareProgram(name: string, texts: string[], bag: Record<string, FlagValue>, stdin: ByteSource | null, dispatch: DispatchFn, operands?: readonly PathSpec[]): Promise<[string[], Record<string, FlagValue>, ByteSource | null, IOResult | null]>; //# sourceMappingURL=program.d.ts.map