@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
71 lines • 3.39 kB
TypeScript
import { type TSNodeLike } from '../../shell/types.ts';
/**
* One word of a line as the gate reads it: `raw` as typed, `text` what
* it names before expansion (quotes removed, escapes resolved), null
* when only the runtime can say (a parameter or command substitution,
* a brace expansion).
*/
export interface Word {
readonly raw: string;
readonly text: string | null;
/** An unquoted pathname pattern may erase or multiply this word. */
readonly glob?: boolean;
}
/** Read a word without losing which glob characters are quoted. */
export declare function readWord(node: TSNodeLike, home?: string | null): Word;
/**
* One test of a `[[ ]]` as the gate admits it: its opener, then
* what it tests. `stated` says whether the gate admits it on these very
* words once each is literal; a comparison's pattern side is read in the
* matcher's dialect instead, so a question about one is left to the gate.
*/
export interface TestRead {
readonly words: Word[];
readonly stated: boolean;
}
/**
* A `[[ ]]` as the tests the gate admits, read with the tokens and the
* grammar the run evaluates it by: a test per leaf, each admitted as the run
* reaches it, since a branch never reached never expands; every reader of
* the line reads the same leaves, so a question one asked is the one the
* gate answers. (`[` is a command, admitted on its words as any command
* is.) `home` is the home directory a leading tilde names. Mirrors Python's
* reads_of_test.
*/
export declare function readsOfTest(node: TSNodeLike, home?: string | null): TestRead[];
/** The text the gate works with: the literal when it has one, the word as typed otherwise. */
export declare function wordValue(word: Word): string;
/**
* A line a command runs on the words it was given. Exactly one shape
* applies. `line` is text the runtime parses afresh (`eval`'s joined
* words, `sh -c`'s program, `mapfile -C`'s callback); `argv` is a
* command already split into words (`command`, `exec`, `env`,
* `timeout`, `xargs`, `find -exec`, `nohup`, `nice`, `time`); neither
* is a line the gate cannot read at all (a sourced file, a script, a
* program from stdin). `open` says the runtime appends operands the
* gate cannot read (`xargs`'s items, `find`'s `{}` paths, the index and
* record `mapfile -C` hands its callback).
*/
export interface InnerLine {
readonly line: string | null;
readonly argv: readonly Word[];
readonly open: boolean;
}
/** Whether the gate can read what runs. */
export declare function innerReadable(inner: InnerLine): boolean;
/**
* The lines a command runs on the words it was given, for the words
* that run other words.
*
* The table is the workspace shell's own re-dispatchers (every builtin
* that hands a constructed line back to the evaluator: `eval`, `source`,
* `command`, `env`, `timeout`, `xargs`, `mapfile -C`, `sh`/`bash`, an
* executed path) plus the classic prefix runners a real shell has and
* the workspace shell does not (`builtin`, `exec`, `nohup`, `nice`,
* `time`, `find -exec`). A whole-line runtime is a real shell, so
* anything else that
* can run a command (an interpreter's `-c`, `make`, `git` hooks) is the
* runtime's own world: the allow list is the closed form there.
*/
export declare function innerLines(head: string, args: readonly Word[]): InnerLine[];
//# sourceMappingURL=inner_lines.d.ts.map