UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

107 lines (106 loc) • 3.82 kB
/** * `prompt explain` — a read-only, human-facing rendering of the assembly manifest: which catalog sections * composed, which band each belongs to, and why. Pure formatter over manifest data — no prompt TEXT is ever * echoed (manifests carry ids/sizes/digests only). */ import { type EventDefaultPolicy } from "./event-registry.js"; import type { BandId, OverlayOp } from "./catalog/schema.js"; /** A `prompt.assembled` manifest (v3) as explain reads it: the frame's own members. */ export interface ExplainInput { identity: { artifact: string; layers: { center?: string; deploy?: string; task?: string; }; epoch: number; activatedBy: string; }; selectors: { binding?: string; traits: readonly string[]; host: { role: string; form: string; }; locale?: string; }; blocks: ReadonlyArray<{ id: string; chars: number; hash: string; }>; sections: ReadonlyArray<{ id: string; band: string; variant?: string; chars: number; locale: string; contentHash: string; chain: ReadonlyArray<{ source: string; overlay?: string; op?: string; superseded?: true; }>; }>; superseded?: ReadonlyArray<{ id: string; source: string; by: string; target: string; supersededBy: string; }>; tools?: ReadonlyArray<{ wireName: string; contractId: string; cardId: string; shapeDigest: string; }>; } /** Render a `prompt.assembled` manifest as a readable report: which prompt (identity, its layers, the selector values), * what composed it, and where each section's text came from. */ export declare function explainPromptAssembly(input: ExplainInput): string; /** * The CENTER-facing read-only description of the bundled catalog: each section's id, band, rank and what each overlay * source class may do to it (the band's three op columns — a center editor reads `ops.center`; an empty column for * every class is a platform-managed section), plus the default role-base TEXT (the append-mode compile skeleton the web * UI prepends to a user's "Role details"). No other section texts. Programmatic — a static copy in the web tier would * drift the moment the catalog changes. */ export interface CatalogDescription { catalogId: string; /** The catalog-default role base (append-mode skeleton). */ roleBaseText: string; sections: Array<{ id: string; band: BandId; rank: number; /** The band's op columns: what a center artifact, a deployment's mods and a task may do to this section. */ ops: { center: readonly OverlayOp[]; deploy: readonly OverlayOp[]; task: readonly OverlayOp[]; }; }>; /** Every registered event kind (registry order): whether it is on by default, the templates its frames are worded * with — the canonical text and the slots it carries — and what each overlay source class may do to them: a kind's * band is its row's (`event-copy`: a center artifact or a deployment replaces a template whole; `event-mechanism`: * locked, every column empty). */ events: Array<{ kind: string; defaultPolicy: EventDefaultPolicy; templates: Array<{ id: string; text: string; slots: readonly string[]; }>; ops: { center: readonly OverlayOp[]; deploy: readonly OverlayOp[]; task: readonly OverlayOp[]; }; }>; } export declare function describeCatalog(): CatalogDescription;