@sema-agent/core
Version:
Stateless, task-oriented AI agent core
23 lines (22 loc) • 2.24 kB
TypeScript
/**
* THE FUNCTION READING — whether a command's program word is a function of the text where a reader stands. A function is a
* binding of its name in the binding thread (`shell-read-bindings.ts`: defined by its head, unbound by an `unset`, visible
* and certain by the one ordered rule); this module asks that thread's {@link FunctionState} for the word the shell looks up
* first, and names what the answer means for the walk. The text's functions (`functions`) are only the CANDIDATE names: the
* ones its definition heads show, and the ones a literal `eval` text defines.
*/
import { type LexedWord } from "../../shell/lex.js";
import { type FunctionState } from "./shell-read-bindings.js";
/** Does a command name one of the text's `functions` where a reader stands: the word the shell looks up first — the program,
* or the launcher in front of it (`command`, `nice`, … are words like any, and a function of their name runs instead) —
* `named`: it is a function's name and defined there (bash looks functions up before builtins: it shadows a builtin of the
* name); `maybe`: it may be one (the definition may not have run, the word is one the text computes, or an external
* launcher stands in front of a program word that may be); `undefined`: it is not (`builtin` / `command` skip functions).
* The whole word names a function (`x/f` included: a `/` tells a function from a path in no way). `stateOf`: what a
* function of a name is there ({@link BindingTable.functionState}) — the binding thread's one rule; absent, any
* definition may be the one (the question put before the walk, where no reader stands yet). */
export type FunctionCall = "named" | "maybe";
export declare function functionCallOf(argv: readonly LexedWord[], functions: ReadonlySet<string>, stateOf?: (name: string) => FunctionState): FunctionCall | undefined;
/** The functions a literal `eval` text defines — the shell that runs it is this one, so they stand after it like any: names
* the text's own definition heads do not show (a text the plan cannot read hands none; the names it makes unknown are all). */
export declare function evalDefinedFunctions(argvs: readonly (readonly LexedWord[])[], depth?: number): string[];