UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

51 lines (50 loc) • 3.42 kB
/** One release's pass. */ interface Pass { readonly version: string; /** A second here-document header on a line leaves the delimiter the first one set (4.0 keeps the last). */ readonly firstHeader: boolean; /** A `)` right after the delimiter, at depth one, ends the document (`EOF)`). */ readonly compactClose: boolean; /** A body opened `((` is read as an arithmetic expansion's matched pair. */ readonly arithmeticFirst: boolean; /** A backslash-newline in a comment stays in it (4.0 and 4.1 join the next line to the comment). */ readonly commentKeepsNewline: boolean; /** A backslash-newline in a quoted document stays in it (4.x joins every document's lines, whatever the parity). */ readonly quotedDocumentKeepsNewline: boolean; /** The line that ends a document IS the delimiter (4.x: BEGINS with it). */ readonly exactEnd: boolean; /** A blank is passed over while a delimiter word is read (4.0 and 4.1). */ readonly blankInDelimiter: boolean; readonly wordResetsReserved: boolean; readonly reservedDo: boolean; readonly reservedFour: boolean; readonly metaKeepsReserved: boolean; /** A `<` that opens no here-document is read again from the next character (4.x reads that character in its place). */ readonly rereadAfterLess: boolean; /** A `$` after a `$` opens nothing. */ readonly dollarOnce: boolean; /** `${…}` reads a `$(`, `${` or `$[` in it as a body of its own. */ readonly braceNests: boolean; /** `${…}` reads a `<(` / `>(` in it as a body of its own (in both pass and pair readers, a `<` / `>` arms it). */ readonly braceProcessNests: boolean; } export declare const PASSES: readonly Pass[]; /** One release per distinct reading of the text from `from` on: releases whose differing flags it gives nothing to act on * read it alike, so one of them stands for all. A trigger acts on the text from `from` on, as written or with its * backslash-newlines removed, exactly when `from` is at or before the last place it does ({@link TextReadings}). */ export declare function passesFor(text: string, from: number): readonly Pass[]; /** Is there a `#` at or after `from`? */ export declare function holdsHashFrom(text: string, from: number): boolean; /** Run `read` with the readings of `text` open (kept if `text` is open already): every ask of `text` inside it is * answered from one reading of it, which ends with `read`. */ export declare function whileReading<T>(text: string, read: () => T): T; type End = number | "unterminated" | "undelimited"; /** Where pass `v` closes the body opened at `open` (a `(`): the index just past its `)`. */ export declare function countingPassEnd(text: string, open: number, v: Pass): End; /** Where release `v` (and 3.2 as 4.0, 5.2 as 5.1) closes the `${…}` opened at `open` (a `{`): at the first `}` its pair * reader meets — bash 5.3's `${ list; }` is to them a parameter expansion that ends there. */ export declare function bracePassEnd(text: string, open: number, v: Pass): End; /** A `((` whose second `(` stands at `second` opens an arithmetic command when its matched pair is followed at once by the * closing `)` (`parse_arith_cmd`; otherwise it is two subshell parentheses): the index just past that `)`, or `undefined`. */ export declare function arithmeticCommandEnd(text: string, second: number): number | undefined; export {};