@sema-agent/core
Version:
Stateless, task-oriented AI agent core
32 lines (31 loc) • 2.23 kB
TypeScript
import type { PromptCatalog } from "./catalog/schema.js";
import { type SourcedOverlay, type SupersededOverlay } from "./overlay.js";
import { type PromptSelectors } from "./select.js";
import type { CompiledSystemBlock, ComposedPrompt, SectionRenderInputs, SystemLayout } from "./types.js";
/** What one composition renders: the catalog, the run's selectors, and the overlays in application order. */
export interface CompositionPlan {
readonly catalog: PromptCatalog;
/** The run's selectors as prepare minted them (`selectorsOf`) — the same object the manifest, the identity and the
* `prompt.compose` event read; the composer never mints its own. */
readonly selectors: PromptSelectors;
/** 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[];
/** The event templates the overlays replaced (`event-copy` band): event message id → the replacing text. The run's
* engine text reading reads them (`../engine-text.ts`); an event message absent here reads as the catalog's. */
readonly eventCopy: ReadonlyMap<string, string>;
}
/** 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[];