@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
49 lines • 2.54 kB
TypeScript
import type { EvaluationContext } from '../evaluation.ts';
import type { NamespaceLinks, SessionView } from '../../view/types.ts';
import type { CallStack } from '../../shell/call_stack.ts';
import { PathSpec } from '../../types.ts';
import type { MountRegistry } from '../mount/registry.ts';
import type { ExecuteFn } from './types.ts';
import type { TSNodeLike } from '../../shell/types.ts';
/**
* One command's expanded argument vector.
*
* `expandArgv` is the only place allowed to know that word zero of an
* expanded command is its name; every consumer reads named views
* instead of slicing word lists.
*
* `args` and `operands` are two views of the same final word list and
* always have equal length; they differ only in element type. Glob
* words are resolved by whoever consumes them, exactly once: shell
* consumers get shell-resolved words in both views, mount commands
* keep pattern PathSpecs for backend pushdown.
*/
export declare class Argv {
/** Expanded command name. */
readonly name: string;
/** Text view (what builtins consume). */
readonly args: readonly string[];
/** Classified view (what mount dispatch, test, and ln consume). */
readonly operands: readonly (string | PathSpec)[];
/** Original words forming the matched name. */
readonly prefix: readonly string[];
constructor(name: string, args: readonly string[], operands: readonly (string | PathSpec)[], prefix?: readonly string[]);
/** Native argv, preserving word boundaries within a matched name. */
get tokens(): [string, ...string[]];
/** Full classified word list, name included. */
get words(): (string | PathSpec)[];
/** Copy with the classified view replaced (e.g. after symlink rewriting). */
withOperands(operands: readonly (string | PathSpec)[]): Argv;
}
/**
* Expand, classify, and glob-resolve a command's word nodes.
*
* Uses the cwd mount's CommandSpec (when it has one for the command) to
* decide which words are TEXT (skip classification) and which are PATH
* (classify even bare filenames). A program's line (a native capture,
* or an interpreter run in-process) is globbed whatever the slots, as
* bash globs it, and its words are then classified for the slots the
* expanded words fill.
*/
export declare function expandArgv(parts: TSNodeLike[], context: EvaluationContext, executeFn: ExecuteFn, callStack: CallStack | null, registry: MountRegistry, links?: NamespaceLinks | null, view?: SessionView): Promise<Argv>;
//# sourceMappingURL=argv.d.ts.map