@sema-agent/core
Version:
Stateless, task-oriented AI agent core
56 lines (55 loc) • 3.79 kB
TypeScript
/** A project id's one format: a UUID (the version nibble not narrowed — read wide, minted strict). The marker file, a declared seat
* and a v2 memory write key are all judged against it. */
export declare const PROJECT_ID_REGEX: RegExp;
/**
* A leg's project. `id` is the leg's DECLARATION of its project (judged once per leg against its checkout's marker); the four text
* members are written by people and vouched for by the host, never by a program (a model's write-back is data, never this seat). Each
* text member is present only when it says something — "none" is the member left out.
*/
export interface ProjectSeat {
/** The project's UUID (the id a `.sema/project` marker carries). */
readonly id: string;
/** A one-line label: no line break, at most {@link PROJECT_SEAT_NAME_MAX} characters. */
readonly name?: string;
/** What the project is. */
readonly description?: string;
/** The project's standing instructions. */
readonly instructions?: string;
/** Host paths the project names (folders or files), absolute, at most {@link PROJECT_SEAT_FILES_MAX}: names only — the engine reads
* none of them and binds none. */
readonly files?: readonly string[];
}
/** The longest `name`, in characters. */
export declare const PROJECT_SEAT_NAME_MAX = 256;
/** The most `files` entries. */
export declare const PROJECT_SEAT_FILES_MAX = 100;
/** The screen's answer: the seat as the engine reads it (a frozen copy; absent ⇔ none was given), or the refusal — its code, the field
* path it is about, and the sentence (opening with that path). Never thrown: a caller decides what a refusal does. */
export type ProjectSeatScreen = {
readonly ok: true;
readonly seat?: ProjectSeat;
} | {
readonly ok: false;
readonly code: "config.invalid_argument" | "config.project_id_invalid";
readonly field: string;
readonly message: string;
};
/**
* Judge a project seat. `undefined` is "no seat". Refused, each with `config.invalid_argument` and its field path, unless noted: a value
* that is no plain object (`null`, a primitive, an array, a class instance); a member that is no seat member; a
* member that is not an own data property; a missing `id`; an `id` that is not a UUID (`config.project_id_invalid`); a text member that
* is no string, or is empty or only whitespace; a `name` with a line break or over {@link PROJECT_SEAT_NAME_MAX} characters; `files`
* that is no array, over {@link PROJECT_SEAT_FILES_MAX} entries, or holds an entry that is not an absolute host path; and a value whose read
* throws (an index getter, a Proxy trap) — answered, never thrown. A plain object is judged by its shape, not by which realm made it: its
* prototype is `null` or a root object (another VM context's `Object.prototype` included). Each member is read once; the answer's seat is
* a copy of what was read, so the caller's object is never read again. `at` is the field path of the seat for the sentences (`TaskSpec.project`).
*/
export declare function screenProjectSeat(value: unknown, at?: string): ProjectSeatScreen;
/**
* Capture a seat at the moment it is handed in (a leg's internals, at the call's door): the screened copy, or — when the screen refuses —
* a frozen stand-in that carries the refusal, so the leg gives it as its failed terminal ({@link handedProjectSeat}) and the caller keeps
* its stream and result. Either way the caller's object is never read again.
*/
export declare function captureProjectSeat(value: unknown, at: string): ProjectSeat | undefined;
/** A captured seat as the leg reads it: the seat, or the refusal its capture recorded ({@link captureProjectSeat}). */
export declare function handedProjectSeat(captured: ProjectSeat | undefined): ProjectSeatScreen;