/** * PromptAssembly — Structured intermediate representation for prompt sections. * * Sections are stored in a Map keyed by type (except 'custom' which uses an array). * Security-band sections (priority 0-9 or 1000+) are frozen after `freeze()` is called. * * @module */ /** * Configuration for a single prompt section. * Content can be a static string or an async function for deferred resolution. */ export interface PromptSectionConfig { /** Section type identifier. */ type: string; /** Static content string or async function that resolves to content. */ content: string | (() => Promise); /** Sort priority. Lower numbers appear first. */ priority: number; /** Whether this section can be trimmed under token pressure. Defaults to true. */ shrinkable?: boolean; /** XML tag name used when rendering. Defaults to the type value. */ tag?: string; /** Origin of this section for debugging/auditing. */ source?: 'developer' | 'runtime' | 'flow' | 'security'; } /** * A fully resolved section with content materialized and metadata computed. */ export interface ResolvedSection { /** Section type identifier. */ type: string; /** Resolved content string. */ content: string; /** Sort priority. */ priority: number; /** Whether this section can be trimmed under token pressure. */ shrinkable: boolean; /** XML tag name. */ tag: string; /** Origin of this section. */ source: string; /** Whether this section is in a frozen security band. */ frozen: boolean; /** Estimated token count of the content. */ estimatedTokens: number; } /** * Debug information about the assembly's current state. */ export interface AssemblyDebugInfo { /** Per-section metadata. */ sections: Array<{ type: string; priority: number; tokens: number; source: string; shrinkable: boolean; frozen: boolean; }>; /** Total estimated tokens across all sections. */ totalTokens: number; } /** * Thrown when an attempt is made to modify a frozen security-band section. */ export declare class PromptSecurityViolationError extends Error { constructor(message: string); } /** * PromptAssembly is the structured intermediate representation for prompt construction. * * Sections are stored in a Map keyed by type. The special type `'custom'` is stored * in a separate array to allow multiple custom sections. * * After `freeze()` is called, sections in security bands (priority 0-9 or 1000+) * cannot be added, replaced, or removed. */ export declare class PromptAssembly { private readonly sections; private readonly customSections; private frozen; /** * Adds or replaces a section. Custom-type sections are always appended. * * @throws {PromptSecurityViolationError} If the assembly is frozen and the * section's priority falls within a security band (0-9 or 1000+). */ addSection(config: PromptSectionConfig): this; /** * Sugar for `addSection` with `source: 'runtime'`. */ inject(type: string, content: string | (() => Promise), options?: Partial>): this; /** * Freezes the assembly, preventing modification of security-band sections. */ freeze(): this; /** * Resolves all sections — materializing async content functions — and * returns them sorted by priority (ascending). Empty sections are filtered out. */ resolve(): Promise; /** * Returns the raw section config for a given type, or `undefined` if not present. */ sectionByType(type: string): PromptSectionConfig | undefined; /** * Returns true if a section of the given type exists. */ hasSection(type: string): boolean; /** * Returns debug information about the assembly's current state. * Resolves async content to compute accurate token estimates. */ debug(): Promise; /** Number of sections (including custom sections). */ get size(): number; }