@sema-agent/core
Version:
Stateless, task-oriented AI agent core
50 lines (49 loc) • 3.56 kB
TypeScript
/**
* How the boundary bundle treats a frame of a kind:
* - `replace-by-key` — the frame states a keyed fact (an announced value, set or pending list); its consumption is
* recorded on the receipt of the message that carried it, so the bundle never clips or drops it (a clipped frame could
* never be recorded) and its size is its producer's promise;
* - `repeat` — the frame is due again at a later boundary until a frame of it rides (and again whenever it is due), so
* the bundle's byte cap may clip or drop it.
*/
export type EventDedupe = "replace-by-key" | "repeat";
/** Default mount policy: `on` = fires unless explicitly disabled (the listing frames are the ONLY roster/skills
* carrier); `off` = fires only when the task opts in (new injection surfaces never disturb existing deployments by
* default); `always` = not switched by the attachment config (its switch is a fact, a seat or a task field). */
export type EventDefaultPolicy = "on" | "off" | "always";
export interface CompiledEventPrompt {
/** Event kind — attachment kinds reuse the AttachmentSource wordlist verbatim. */
readonly kind: string;
readonly defaultPolicy: EventDefaultPolicy;
/** The catalog messages the kind's frame is worded with (`catalog/events.ts`, `catalog/mechanism.ts`) — at least one; a
* message two kinds share is listed by both, and both are kinds of one band. */
readonly messages: readonly [string, ...string[]];
/** Present exactly on the kinds that ride the boundary bundle. */
readonly dedupe?: EventDedupe;
/** The ceiling, in UTF-8 bytes, a kind's producer holds its whole frame to, where that ceiling is a constant. */
readonly maxBytes?: number;
}
/** The band an event row places its messages in. */
export type EventBand = "event-copy" | "event-mechanism";
/** The band a row places its messages in: the attachment config's kinds word the replaceable copy, the others the
* locked mechanism text. */
export declare function eventRowBand(row: Pick<CompiledEventPrompt, "defaultPolicy">): EventBand;
/**
* What is wrong with a set of registry rows against the catalog's event messages (empty = sound): a row that names no
* message, or one that is not an event message; an event message no row places; a message two rows place in two bands
* (one message has one band). Pure, so the pins can hand it rows of their own; the shipped rows are refused at load.
*/
export declare function eventRegistryProblems(rows: Iterable<Pick<CompiledEventPrompt, "kind" | "defaultPolicy"> & {
readonly messages: readonly string[];
}>, eventMessageIds: ReadonlySet<string>): string[];
/** The shipped registry. */
export declare const EVENT_PROMPT_REGISTRY: ReadonlyMap<string, CompiledEventPrompt>;
/** The kinds whose frame is worded with this event message (empty ⇒ not an event message). */
export declare function eventKindsOf(messageId: string): readonly string[];
/** The band an event message lands in (its placing rows', one band by the load check), or undefined for any other id. */
export declare function eventBandOf(messageId: string): EventBand | undefined;
/** The M12 default matrix, single-sourced: is this attachment kind on when the task supplies no
* `attachments` config? (Live consumer: the run loop's attachment-config derivation.) */
export declare function eventDefaultOn(kind: string): boolean;
/** A kind's constant frame ceiling (`maxBytes`). Asking for one a row does not declare is an engine defect. */
export declare function eventMaxBytes(kind: string): number;