@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
67 lines • 2.88 kB
TypeScript
export declare class CallFrame {
positional: string[];
locals: Record<string, string>;
functionName: string;
loopLevel: number;
sourced: boolean;
closed: boolean;
constructor(init?: Partial<Pick<CallFrame, 'positional' | 'locals' | 'functionName' | 'loopLevel' | 'sourced' | 'closed'>>);
}
export declare class CallStack {
private readonly frames;
subshell: boolean;
paren: boolean;
levels: number;
/**
* A stack with only the shell's own frame, starting at `levels` of
* nesting: a nested shell's (`SessionState.shellNesting`).
*/
constructor(levels?: number);
/**
* The stack a child shell runs on, a copy of every frame. `loops` keeps
* the loops the caller is in, as a pipeline stage and `$( )` do; a `( )`
* or `&` child starts outside every loop (bash 5.2, POSIX interp 842).
* `paren` is true for a child running a `( )` or a compound command,
* false for a substitution, and null keeps the caller's.
*/
fork(loops?: boolean, paren?: boolean | null): CallStack;
get current(): CallFrame;
/**
* Enter a function, or a sourced file (`functionName` is `source`). A
* function starts outside every loop, so `break` in it cannot end its
* caller's; a sourced file runs in its caller's loops.
*/
push(positional?: string[], functionName?: string, sourced?: boolean): void;
pop(): CallFrame;
get depth(): number;
/** How many function calls are running, a sourced file aside: the nesting `FUNCNEST` limits. */
get functionDepth(): number;
/**
* How deep the shell has re-entered itself: its functions, sourced files,
* `eval` lines and nested shells.
*/
get nesting(): number;
/**
* Refuse to re-enter the shell past `NESTING_MAX`, abandoning the rest of
* the line as bash does past `FUNCNEST`. `name` is what would be entered:
* a function, `source`, `eval` or the shell's name.
*/
admit(name: string): void;
/** Count a line `eval` (`name`) runs on this stack, once admitted. */
nested<T>(name: string, run: () => Promise<T>): Promise<T>;
/** Whether a function or sourced file is running for `return` to leave. */
get returnable(): boolean;
/** Count a loop the current frame runs, for `break` and `continue`. */
loop<T>(run: () => Promise<T>): Promise<T>;
/**
* `${FUNCNAME[@]}`: the frames innermost first, a sourced file as
* `source`. Empty while no function runs, as bash hides a sourced file's
* entry outside one, and one whose RETURN action runs: it has returned.
*/
functionNames(): readonly string[];
getAllPositional(): string[];
setPositional(values: string[]): void;
setLocal(name: string, value: string): void;
getLocal(name: string): string | null;
}
//# sourceMappingURL=call_stack.d.ts.map