@sema-agent/core
Version:
Stateless, task-oriented AI agent core
34 lines (33 loc) • 2.18 kB
TypeScript
/**
* The prompt Composer — the single deterministic assembly path (stage S1; protocol §6).
*
* compose() is a pure function of (pack, inputs): validate → admit → render → join. The flat
* date re-render seam (design/66 date_change) is expressed by re-running compose with a different
* `environmentBlock` — everything else stays byte-identical, so the prefix-cache property is
* preserved exactly as before (only the env tail differs between legs).
*
* Two views of one composition: the compiled IR (sections) and the `prompt.assembled` block view —
* adjacent sections sharing a `blockId` merge into one block (the harness.context composite), the
* downstream id-wordlist contract (sentence-index #28).
*/
import type { CompiledSystemBlock, ComposedPrompt, PromptPack, SectionRenderInputs, SystemLayout } from "./types.js";
/**
* Structural pack validation (protocol §14.1 negative cases — fail-loud, never a silent skip):
* duplicate section id, duplicate rank, empty id, or an unknown block joiner all reject the pack.
* Called once per pack instance (composePack callers may cache); cheap enough to run per compose.
*/
export declare function validatePack(pack: PromptPack): void;
/**
* Assemble the pack's system-prompt plane from prepare-frozen inputs. Sections emit in ascending
* rank (the pack-declared global order — slot NEVER drives physical order, see types.ts header).
*/
export declare function compose(pack: PromptPack, inputs: SectionRenderInputs): ComposedPrompt;
/** 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 (stage S4).
* Sections keep their emission order; groups partition by rank range (routing never reorders —
* see types.ts header on slot interleaving). Empty groups are dropped. 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[];