/** * PromptRenderer — Pure functions that render resolved prompt sections to a string. * * Handles XML tag wrapping, token budgeting (trimming shrinkable sections in * reverse priority order), and security validation. * * @module */ import type { ResolvedSection } from './PromptAssembly.js'; /** * Options controlling how resolved sections are rendered to a final string. */ export interface RenderOptions { /** Maximum token budget for the rendered prompt. If exceeded, shrinkable sections are trimmed. */ maxTokens?: number; /** Whether to wrap each section in XML tags. Defaults to true. */ useXmlTags?: boolean; /** Whether to validate that security sections (security_core, security_reminder) exist. Defaults to true. */ validateSecurity?: boolean; } /** * Thrown when prompt validation fails (e.g. missing security sections). */ export declare class PromptValidationError extends Error { constructor(message: string); } /** * Renders an array of resolved sections into a single prompt string. * * Behavior: * 1. Filters out sections with empty content. * 2. Validates that security sections exist (if `validateSecurity` is true). * 3. If total tokens exceed `maxTokens`, trims shrinkable sections in * **reverse** priority order (lowest priority trimmed first — so knowledge, * memory, and tools are trimmed before role/instructions). * 4. Wraps each section in `\ncontent\n` when `useXmlTags` is true. * * @param sections - Pre-sorted resolved sections (ascending priority). * @param options - Render options. * @returns The assembled prompt string. */ export declare function renderSections(sections: ResolvedSection[], options?: RenderOptions): string;