/** * Darwin — Prompt Optimizer * * Uses an LLM (via injected callback) to generate improved prompt variants * based on performance data and detected patterns. */ import type { DarwinPattern, PromptVersionStats } from '../types.js'; /** Function signature for LLM calls — injected by the parent, never imported. */ export type RunPromptFn = (prompt: string) => Promise; /** Agent tool context so the optimizer knows what tools are available */ export interface AgentToolContext { /** MCP server names the agent uses */ mcp?: string[]; /** Built-in tools the agent uses */ tools?: string[]; } /** Stats broken down by task category */ export interface CategoryStats { taskType: string; totalRuns: number; avgQuality: number; avgSourceCount: number; successRate: number; } export declare class PromptOptimizer { private runPrompt; constructor(runPrompt: RunPromptFn); /** * Generate an improved variant of an agent prompt. * * Builds a meta-prompt that includes the current prompt text, detected * patterns (strengths, weaknesses, trends, anomalies), aggregated * stats, tool context, per-category breakdowns, and recent critic feedback. */ generateVariant(currentPrompt: string, patterns: DarwinPattern[], stats: PromptVersionStats, toolContext?: AgentToolContext, categoryStats?: CategoryStats[], recentFeedback?: string[]): Promise; /** * Assemble the meta-prompt that instructs the LLM how to improve * the agent's system prompt. */ private buildMetaPrompt; /** * Format patterns into a human-readable summary for the meta-prompt. */ private formatPatterns; /** * Format stats into a readable summary. */ private formatStats; /** * Remove markdown code fences if the LLM wraps the output. */ private cleanOutput; /** * Pluralize a pattern type label correctly. * Handles: weakness -> Weaknesses, strength -> Strengths, trend -> Trends, anomaly -> Anomalies */ private pluralize; /** * Check that the mutated prompt preserves safety-related keywords from the original. * Returns null if OK, or a rejection reason if safety keywords were removed. * * v0.6.0: delegates to the shared {@link sharedCheckAlignmentPreservation} * in `./alignment.ts` so the legacy optimizer and the GEPA reflective loop * path run the identical guard. Kept as a method for backward compatibility. */ checkAlignmentPreservation(original: string, mutated: string): string | null; } //# sourceMappingURL=optimizer.d.ts.map