@sema-agent/core
Version:
Stateless, task-oriented AI agent core
32 lines (31 loc) • 1.99 kB
TypeScript
import type { HostForm, HostRole, PromptCatalog } from "./catalog/schema.js";
import { type SourcedOverlay, type SupersededOverlay } from "./overlay.js";
import type { CompiledSystemBlock, ComposedPrompt, SectionRenderInputs, SystemLayout } from "./types.js";
/** What one composition renders: the catalog, the host selector values, and the overlays in application order. */
export interface CompositionPlan {
readonly catalog: PromptCatalog;
/** The host selector values (absent ⇒ `general` / `standard`). */
readonly host?: {
readonly role?: HostRole;
readonly form?: HostForm;
};
/** The run's binding (`TaskSpec.promptBinding`; absent ⇒ none) — what every overlay's `when.binding` reads. */
readonly binding?: string;
/** Validated overlays, already in application order (`bundled < task < center < deploy`, then declaration order). */
readonly overlays?: readonly SourcedOverlay[];
}
/** A composition plus what its overlays came to. */
export interface ComposedWithOverlays extends ComposedPrompt {
/** Overlays a later one on the same target overrode, or that changed nothing this run. */
readonly superseded: readonly SupersededOverlay[];
}
/** Assemble the system-prompt plane from prepare-frozen inputs. Sections and added entries emit in ascending rank. */
export declare function composeCatalog(plan: CompositionPlan, inputs: SectionRenderInputs): ComposedWithOverlays;
/** The implicit single-group layout — the default wire face (one system block, one cache span). */
export declare const SINGLE_BLOCK_LAYOUT: SystemLayout;
/**
* Route a composed prompt's sections into PHYSICAL system blocks per the layout. Sections keep their
* emission order; groups partition by rank range. With SINGLE_BLOCK_LAYOUT the result is one block whose
* text === composed.text (byte-identity, golden-pinned).
*/
export declare function layoutSystemBlocks(composed: ComposedPrompt, layout?: SystemLayout): CompiledSystemBlock[];