/** * Dry Run Cache - Caches dry-run analysis results for faster subsequent execution * * When a command is run with --dry-run, the analysis/planning phase is cached. * When the same command is run without --dry-run, the cached result is used * to skip redundant analysis and speed up execution. */ import type { CommandDefinition, PipelineStage, StageOutput } from '../types/command.types.js'; /** * Pre-loaded prompt data for faster execution */ export interface PreloadedPrompt { content: string; id: string; metadata: Record; } /** * Pre-loaded agent data for faster execution */ export interface PreloadedAgent { content: string; decisionMaking?: { escalationCriteria?: string[]; }; role: string; } /** * Pre-resolved stage inputs (static variables that don't depend on LLM output) */ export interface PreresolvedInputs { enrichedInputs: Record; resolvedInputs: Record; stageName: string; } /** * Cached dry-run result */ export interface DryRunCacheEntry { /** The command that was analyzed */ commandName: string; /** Timestamp when the cache entry was created */ createdAt: number; /** TTL in milliseconds for this cache entry */ ttl: number; /** The planned pipeline stages after analysis */ plannedStages: PipelineStage[]; /** Analysis outputs from the dry-run (e.g., resolved variables, agent selection) */ analysisOutputs: Record; /** Pre-computed stage outputs if available */ precomputedOutputs?: StageOutput[]; /** Hash of the command definition for invalidation */ commandHash: string; /** The resolved agent role */ agentRole?: string; /** The resolved model */ model?: string; /** Session context snapshot */ sessionContextSnapshot?: Record; /** Pre-loaded prompts for all pipeline stages */ preloadedPrompts?: PreloadedPrompt[]; /** Pre-loaded agent definition */ preloadedAgent?: PreloadedAgent; /** Pre-resolved inputs for each stage (static variables only) */ preresolvedInputs?: PreresolvedInputs[]; /** Pipeline validation results (true = valid) */ pipelineValidated?: boolean; /** Resolved args map for variable resolution */ resolvedArgs?: Record; } /** * Options for cache lookup */ export interface DryRunCacheLookupOptions { args: string[]; command: CommandDefinition; commandName: string; flags: Record; sessionContext?: Record; } /** * Result of a cache lookup */ export interface DryRunCacheLookupResult { entry?: DryRunCacheEntry; hit: boolean; reason?: string; } /** * Dry Run Cache Service * * Provides in-memory caching of dry-run results for improved performance * when the same command is run without --dry-run. */ export declare class DryRunCache { private static instance; private cache; private defaultTtl; constructor(defaultTtl?: number); /** * Get singleton instance */ static getInstance(): DryRunCache; /** * Reset singleton instance (for testing) */ static resetInstance(): void; /** * Generate a cache key from command options */ generateCacheKey(options: DryRunCacheLookupOptions): string; /** * Generate a hash of the command definition for invalidation */ generateCommandHash(command: CommandDefinition): string; /** * Store a dry-run result in the cache */ set(options: DryRunCacheLookupOptions, entry: Omit): void; /** * Look up a cached dry-run result */ get(options: DryRunCacheLookupOptions): DryRunCacheLookupResult; /** * Invalidate a cache entry */ invalidate(options: DryRunCacheLookupOptions): boolean; /** * Invalidate all cache entries for a command */ invalidateCommand(commandName: string): number; /** * Clear all cache entries */ clear(): void; /** * Get cache statistics */ getStats(): { entries: Array<{ ageMs: number; commandName: string; key: string; }>; size: number; }; /** * Evict oldest cache entries */ private evictOldest; } /** * Get the singleton dry-run cache instance */ export declare function getDryRunCache(): DryRunCache; //# sourceMappingURL=dry-run-cache.d.ts.map