export { A as AxisCheck, a as AxisCheckInput, C as CRITERIA, D as DEFAULT_QUALITY_CONFIG, d as EvalCategory, e as EvalCriterion, E as EvalIssue, f as EvalOutcome, b as EvalResult, c as EvalTier, P as Priority, Q as QualityConfig, g as QualityMode, h as buildCodingCriteriaSummary, i as getActionableIssues, j as getCriteriaByPriority, k as getCriterionById, l as getLLMCriteria, n as isBlocked, m as matches, p as priorityForIssue } from '../types-public-DIpjC-OA.js'; import * as _anthropic_ai_claude_agent_sdk from '@anthropic-ai/claude-agent-sdk'; import { McpServerConfig } from '@anthropic-ai/claude-agent-sdk'; import { EvaluationContext, EvaluationConfig, QualityMetadata, EvaluationResult, EvaluationIssue } from './types.js'; export { DEFAULT_EVAL_MAX_ROUNDS, DimensionScores, MAX_EVAL_ROUNDS_HARD_LIMIT } from './types.js'; export { R as RunAxisChecksInput, r as runAxisChecks } from '../dispatch-D75M-OfZ.js'; import { A as AgentConfig, L as LLMResponse } from '../llm-router-BEVtbAb9.js'; import '@ggui-ai/protocol'; import '../axes-CzLEMDeB.js'; import '../types-BOvHNG7K.js'; import '../llm.js'; /** * Options for running the evaluation loop. * * Controls the evaluate-fix-re-evaluate cycle that improves generated * component quality until it passes or the round limit is reached. */ interface EvaluationLoopOptions { /** Session ID of the generator to resume for fixes */ generatorSessionId: string; /** Evaluation context (code, prompt, design, theme) */ context: EvaluationContext; /** Evaluation configuration (thresholds, budgets, round limits) */ config: EvaluationConfig; /** Progress callback for evaluating/fixing status updates */ onProgress?: (event: { type: 'evaluating' | 'fixing'; round: number; }) => void; /** Generator context to pass when resuming the session for fixes */ generatorOptions?: { /** Working directory for the generator session */ cwd?: string; /** MCP servers available to the fix agent */ mcpServers?: Record; /** Tools the fix agent is allowed to call */ allowedTools?: string[]; /** LLM model for fix rounds */ model?: string; /** Environment variables (includes BYOK credentials) */ env?: Record; /** Stderr capture callback for debugging */ stderr?: (data: string) => void; }; } /** * Result of the evaluation loop. * * Contains the final (possibly fixed) code, quality scores, and * the evaluation history from each round. */ interface EvaluationLoopResult { /** Final compiled code (may be updated by fix rounds) */ finalCode: string; /** Final source code (may be updated by fix rounds) */ finalSourceCode?: string; /** Quality metadata for the generation result */ qualityMetadata: QualityMetadata; /** All evaluation results from each round */ evaluationResults: EvaluationResult[]; } /** * Run the evaluation loop: evaluate -> fix -> re-evaluate (up to maxRounds). * * If the first evaluation passes, returns immediately. * If it fails, resumes the generator session with critique feedback, * captures the fixed code, and re-evaluates. Repeats until the score * passes or the round limit is reached. * * @param options - Evaluation loop configuration and callbacks * @returns The final code, quality metadata, and evaluation history */ declare function runEvaluationLoop(options: EvaluationLoopOptions): Promise; /** * Run a single evaluation round using any LLM provider. * * Provider-agnostic: routes to Claude, OpenAI, or Google API based on config.provider. * Falls back to Claude if no provider is specified. */ declare function runEvaluation(context: EvaluationContext, config: EvaluationConfig): Promise; /** * Input args for the evaluate_score computation. * Extracted so unit tests can call the real logic directly. */ interface EvaluateScoreInput { completeness: number; visualPolish: number; interactivity: number; accessibility: number; codeQuality: number; issues: EvaluationIssue[]; critique?: string; } /** * Core scoring logic — extracted from the tool handler so it can be * unit-tested directly without going through MCP protocol. */ declare function computeEvaluationScore(args: EvaluateScoreInput, passThreshold: number): EvaluationResult; /** * Create the evaluation MCP server with the evaluate_score tool. * * The evaluator LLM provides qualitative scores per dimension. * This tool handles the arithmetic (average, pass/fail) so the LLM * doesn't need to do math. */ declare function createEvaluationToolsServer(passThreshold?: number): _anthropic_ai_claude_agent_sdk.McpSdkServerConfigWithInstance; /** * System prompt for the evaluator agent. * Static/cacheable — defines rubric, dimensions, and workflow. */ declare function getEvaluatorSystemPrompt(): string; /** * Build the fix prompt to resume the generator session with evaluation feedback. * Issues are grouped by severity (critical first) so the generator prioritizes correctly. */ declare function buildFixPrompt(evalResult: EvaluationResult, originalPrompt: string): string; /** * Shared message parsing utilities for extracting structured data from * Claude Agent SDK `query()` messages. * * These functions are used by evaluator.ts, loop.ts, and generator.ts * to capture tool results, source code, and session state from the * SDK message stream. */ /** A single SDK message from the `query()` async iterator. */ type SdkMessage = Record; /** * Extract tool_result text items from a user-type SDK message. * Returns an empty array if the message isn't a user message or has no tool results. */ declare function extractToolResultTexts(message: SdkMessage): string[]; /** * Extract an `EvaluationResult` from an array of SDK messages. * * Scans for user messages containing a tool_result with JSON that has * `finalScore` (number) and `dimensions` fields. Returns the last * matching result, or `undefined` if none found. * * Used by: evaluator.ts */ declare function extractEvalResult(messages: SdkMessage[]): EvaluationResult | undefined; /** * Extract `compiledCode` from a single SDK message. * * Tries two strategies: * 1. Regex extraction from the full serialized message (fallback) * 2. Structured extraction from user/tool_result content * * Returns the extracted code or `undefined`. * * Used by: loop.ts, generator.ts */ declare function extractCompiledCodeFromMessage(message: SdkMessage): string | undefined; /** * Extract source code from an assistant's Write tool_use message. * * Looks for `tool_use` blocks with `name === 'Write'` and returns * the `input.content` string. If multiple Write calls exist, returns * the last one (the final version). * * Used by: loop.ts, generator.ts */ declare function extractSourceCodeFromMessage(message: SdkMessage): string | undefined; /** * Scan all messages for the last compiledCode value. * * Convenience wrapper for tests and one-shot extraction. */ declare function extractCompiledCode(messages: SdkMessage[]): string | undefined; /** * Scan all messages for the last sourceCode from Write tool_use. * * Convenience wrapper for tests and one-shot extraction. */ declare function extractSourceCode(messages: SdkMessage[]): string | undefined; interface VisualEvalConfig { /** LLM provider for multimodal evaluation */ provider: 'claude' | 'google'; /** Model ID (must support vision/multimodal) */ model?: string; /** Pass threshold for visual score (0-100) */ passThreshold: number; /** Sample props to render the component with */ sampleProps?: Record; /** Viewport dimensions for screenshot */ viewport?: { width: number; height: number; }; /** * Optional provider-routing override — see * `AgentConfig.routeOverride`. Threaded onto the agent this * evaluator constructs so its multimodal call never falls back to * `process.env` for credentials or model routing. */ routeOverride?: AgentConfig['routeOverride']; /** * Provider-429-retry observer — see `AgentConfig.onRetry`. * Without it, a rate-limited retry inside the evaluation call * happens (the agent's retry loop is unconditional) but never * reaches the caller's structured log. */ onRetry?: AgentConfig['onRetry']; } /** * Send the screenshot to the configured multimodal provider through * the shared `LLMAgent` machinery. Routing through `createVisionAgent` * (rather than constructing provider SDK clients inline) is what puts * this call inside the same `apiCall()` choke point as every other * completion: provider 429s retry with `Retry-After` honoring, the * caller's `onRetry` observer sees each retry, and `routeOverride` * governs credentials and model routing (including the Anthropic * Bedrock path) instead of `process.env`. */ declare function callMultimodalLLM(config: VisualEvalConfig, model: string, prompt: string, screenshot: Buffer, originalPrompt: string): Promise; export { type EvaluateScoreInput, EvaluationConfig, EvaluationContext, EvaluationIssue, type EvaluationLoopOptions, type EvaluationLoopResult, EvaluationResult, QualityMetadata, type SdkMessage, type VisualEvalConfig, buildFixPrompt, callMultimodalLLM, computeEvaluationScore, createEvaluationToolsServer, extractCompiledCode, extractCompiledCodeFromMessage, extractEvalResult, extractSourceCode, extractSourceCodeFromMessage, extractToolResultTexts, getEvaluatorSystemPrompt, runEvaluation, runEvaluationLoop };