/** * Variable definition class for prompt template system * Defines structure, behavior, and relationships between variables */ export declare class VariableDef { /** * Map of variable names to their definitions * Indexed by variable name (e.g., "USER:PRE" -> VariableDef) */ private static definitions; /** Variable name (e.g., "USER:PRE", "SYSTEM") */ name: string; /** Rendering weight for ordering (lower = earlier) */ weight: number; /** Environment variable to read value from */ env_var?: string; /** Whether to render in full template expansion */ renderFull: boolean; /** Whether variable persists across clearOneShot() calls */ persists: boolean; /** Template string with %VAR% placeholders and %% for own content */ template: string; /** Variables referenced in template (%VAR% patterns) */ adoptedChildren: string[]; /** Function to dynamically compute variable value */ getter?: () => string; constructor(config: { name: string; weight?: number; env_var?: string; renderFull?: boolean; persists?: boolean; template?: string; getter?: () => string; }); /** * Get or create definition by name * Looks in definitions map, then PROMPT_VARS, then creates default * * @param name Variable name * @returns VariableDef instance */ static getOrCreate(name: string): VariableDef; /** * Get all variable definitions * Ensures all PROMPT_VARS are loaded into definitions map * Later definitions override earlier ones (YAML overrides hardcoded) * * @returns Array of all VariableDef instances */ static getAllDefinitions(): VariableDef[]; /** * Check if a variable is intrinsic (hardcoded in TypeScript) * * @param name Variable name * @returns True if defined in INTRINSIC_VARS */ static isIntrinsic(name: string): boolean; /** * Check if a variable is explicit (defined in external YAML file) * * @param name Variable name * @returns True if defined in EXTERNAL_VARS */ static isExplicit(name: string): boolean; } /** * Variable instance class for prompt template system * Holds actual values and handles rendering logic * * Supports: * - Hierarchical variable relationships (parent:child) * - Template expansion with %VAR% placeholders * - Dynamic value computation via getters * - Circular dependency detection * - Weight-based ordering */ export declare class Variable { /** * Map of variable names to their current values * Indexed by variable name (e.g., "USER:PRE" -> Variable) */ private static variables; /** Variable definition (structure and behavior) */ def: VariableDef; /** Array of string values for this variable */ values: string[]; /** Whether variable has new/changed values since last render */ isNew: boolean; constructor(name: string); get name(): string; get weight(): number; get template(): string; get renderFull(): boolean; get persists(): boolean; /** * Set variable value (replaces existing values) * Creates variable if it doesn't exist * * @param name Variable name * @param value Value to set */ static set(name: string, value: string): void; /** * Append value to variable (adds to existing values) * Creates variable if it doesn't exist * Use when building multi-value variables within same execution context * * @param name Variable name * @param value Value to append */ static append(name: string, value: string): void; /** * Get variable by name * * @param name Variable name * @returns Variable instance or undefined */ static get(name: string): Variable | undefined; /** * Get or create variable by name * * @param name Variable name * @returns Variable instance */ static getOrCreate(name: string): Variable; /** * Get all set variables * * @returns Array of all Variable instances */ static getAllVariables(): Variable[]; /** * Clear all one-shot variables * Removes variables where persists=false */ static clearOneShot(): void; /** * Export persistent variables for saving to context.json * Returns only variables with persists=true * * @returns Object with variable names as keys and objects containing values and isNew state */ static exportPersistentVariables(): Record; /** * Import persistent variables from saved context.json * Restores variables with their values and isNew state * * @param saved Object with variable names as keys and objects containing values and isNew state */ static importPersistentVariables(saved: Record): void; /** * Find birth child variables of given parent * Returns variables with prefix "parent:" sorted by weight * * @param parent Parent name (e.g., "USER" or "SYSTEM") * @returns Variables with prefix "parent:", renderFull=true, sorted by weight */ static findBirthChildren(parent: string): Variable[]; /** * Find all child variables of given parent * Returns both birth children (prefix match) and adopted children (template refs) * * @param parent Parent name (e.g., "USER") * @returns All child variables with renderFull=true, sorted by weight */ static findFullChildrenVars(parent: string): Variable[]; /** * Render a variable fully with recursive template expansion * Handles variable creation, getter execution, and circular dependency detection * * @param name Variable name (e.g., "USER" or "USER:PROMPT") * @param renderingStack Set of variables currently being rendered (for cycle detection) * @returns Rendered string */ static renderFull(name: string, renderingStack?: Set): string; /** * Render variable using its template with placeholder substitution * Handles %VAR% substitution and %% replacement with own values + children * * @param renderingStack Set of variables currently being rendered (for cycle detection) * @returns Rendered template string */ renderFullTemplate(renderingStack?: Set): string; /** * Render variable values as string with dynamic getter support * Updates values from getter if present and value changed * Clears isNew flag after rendering * * @param separator String to join multiple values (default: "\n") * @returns Joined values string */ renderFullValue(separator?: string): string; }