@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
82 lines • 3.89 kB
TypeScript
import { IOResult } from '../../io/types.ts';
import type { Observer } from '../../observe/observer.ts';
import type { OpRecord } from '../../observe/record.ts';
import type { JobConsole } from '../../shell/console/job_console.ts';
import type { TSNodeLike } from '../../shell/types.ts';
import type { SessionState } from '../session/session.ts';
declare module '../../context/session_context.ts' {
interface Caller {
readonly history: LineHistory | null;
}
}
/**
* A typed line's history, recorded as bash's line reader adds it: an entry
* per command the line reads, each with what it wrote to the terminal and
* the status it left, where a line of one command is recorded whole. The
* line's root program reaches each command as it runs it (`reach`), and
* the line's end ends the last (`end`). A line answered before its tree
* runs, or run whole on a runtime (`typed`), is recorded once, as typed.
* Input the root reads again goes on with the root it is read as, which
* the history `readOn` gives it records. Mirrors Python's LineHistory.
*/
export declare class LineHistory {
private readonly recording;
private root;
private readonly shift;
private constructor();
/**
* The history of a line whose input bash's reader reads as more than
* one entry, written to a terminal; null for any other line, which the
* line records whole as it starts.
*
* @param observer the workspace's observer.
* @param command the line as typed.
* @param root the parsed line.
* @param sessionId the session the line is recorded under.
* @param session the session the line runs on, whose cwd its entries name.
* @param id the line's execution id, its first entry's.
* @param sink where the line writes.
*/
static open(observer: Observer, command: string, root: TSNodeLike, sessionId: string, session: SessionState, id: string | undefined, sink: JobConsole | undefined): LineHistory | null;
/**
* Whether `node`'s program reads the line: this history's root, or, for
* the history of input read again (`readOn`), the first root to run.
*
* @param node a program about to run its statements.
*/
reads(node: TSNodeLike): boolean;
/**
* The history of the root's input read again from a statement on, as a
* root of its own: bound to the call that reads it, whose first root
* takes the line over.
*
* @param at where, in the root's input, the input read again starts:
* the statement's index less the blank rows put ahead of it.
*/
readOn(at: number): LineHistory;
/**
* Reach the command the root program runs next: end the entry before it
* and record the entries up to it, its own last.
*
* @param child the root's statement about to run.
* @param session the shell running it, whose `$?` ends the entry before.
* @param records the line's op records so far, of which the entry
* before's are those since the one before it ended.
*/
reach(child: TSNodeLike, session: SessionState, records: readonly OpRecord[]): Promise<void>;
/** The root program read the input to its end, so the entries after its last command are read too. */
read(): void;
/** Record the line once, as typed, before it runs whole on a runtime. */
typed(): Promise<void>;
/**
* End the line: its last entry, with what the line wrote since and what
* it answered with besides, or, when no command was reached, the line as
* typed, unless its root read it through. A line ends once.
*
* @param io the line's result.
* @param records the line's op records, of which the last entry's are
* those since the entry before ended.
*/
end(io: IOResult, records: readonly OpRecord[]): Promise<void>;
}
//# sourceMappingURL=line.d.ts.map