/** * Unified agent output types for standardized agent responses */ import { EvaluationResult } from "./evaluation"; import { Action } from "../domains/base/action"; import type { OrchestratorVerdict } from "./layer"; /** * Performance metrics for agent evaluation */ export interface AgentPerformanceMetrics { /** Total number of evaluations performed */ totalEvaluations: number; /** Average evaluation time in milliseconds */ averageEvaluationTime: number; /** Average confidence score */ averageConfidence: number; /** Success rate (successful evaluations / total evaluations) */ successRate: number; /** Contribution score to overall decision making */ contributionScore: number; /** Number of errors encountered */ errorCount?: number; /** Additional custom metrics */ customMetrics?: Record; } /** * Action result with reasoning and confidence */ export interface ActionResult { /** Recommended action */ action: Action; /** Reasoning for the action selection */ reason: string; /** Confidence in the action (0-1) */ confidence: number; /** Alternative actions considered */ alternatives?: Action[]; /** Additional action metadata */ metadata?: Record; } /** * Unified output object for all agents */ export interface AgentOutput { /** Evaluation result from the agent */ evaluation: EvaluationResult; /** Optional action recommendation */ action?: ActionResult; /** Optional agent performance statistics */ statistics?: AgentPerformanceMetrics; /** ID of the agent that produced this output */ agentId: string; /** Name of the agent that produced this output */ agentName: string; /** Provider type (openai, anthropic, google, heuristic, etc.) */ providerType: string; /** Timestamp when output was generated */ timestamp: string; /** Role the agent was playing when generating this output */ role?: string; /** Task context information */ taskContext?: { taskId: string; taskName: string; domainId: string; }; /** Processing information */ processing?: { /** Time taken to generate this output (ms) */ processingTime: number; /** Model or method used */ model?: string; /** Tokens used (for LLM agents) */ tokensUsed?: number; /** Additional processing metadata */ metadata?: Record; }; /** Error information if processing failed */ error?: { /** Whether an error occurred */ hasError: boolean; /** Error message */ message?: string; /** Error type/code */ type?: string; /** Whether this is a fallback response */ isFallback?: boolean; }; /** Additional agent-specific metadata */ metadata?: Record; } /** * Collection of outputs from multiple agents */ export interface MultiAgentOutput { /** Individual agent outputs */ agentOutputs: AgentOutput[]; /** Aggregated evaluation if computed */ aggregatedEvaluation?: EvaluationResult; /** Consensus action if reached */ consensusAction?: ActionResult; /** Diversity metrics */ diversity?: { /** Score diversity (standard deviation) */ scoreVariance: number; /** Opinion diversity measure */ opinionDivergence: number; /** Approach diversity */ approachDiversity: number; }; /** Processing summary */ summary: { /** Total agents that participated */ totalAgents: number; /** Agents that completed successfully */ successfulAgents: number; /** Agents that failed */ failedAgents: number; /** Total processing time */ totalProcessingTime: number; /** Average confidence across agents */ averageConfidence: number; }; /** Timestamp when collection was completed */ timestamp: string; } /** * Engine output containing all agent outputs and analysis */ export interface EngineOutput { /** All agent outputs from this inference */ agentOutputs: AgentOutput[]; /** Sentinel analysis results */ sentinelAnalysis?: { /** Bias detection results */ biasDetected: boolean; /** Diversity analysis */ diversityScore: number; /** Quality assessment */ qualityScore: number; /** Recommendations */ recommendations?: string[]; /** Detailed analysis */ analysis?: Record; }; /** Engine statistics */ engineStatistics: { /** Total inference time */ totalInferenceTime: number; /** Search statistics */ searchStats?: Record; /** Memory usage */ memoryUsage?: number; /** Agent coordination stats */ coordinationStats?: Record; }; /** Agent performance breakdown */ agentPerformance: Record; /** Final recommended decision */ recommendation?: { /** Best action */ action: Action; /** Confidence in recommendation */ confidence: number; /** Reasoning */ reasoning: string; /** Contributing agents */ contributors: string[]; }; /** Pipeline result (present only when mode === "pipeline") */ pipelineResult?: { /** The final delivered output (draft text) */ finalOutput: string; /** Total pipeline iterations executed */ totalIterations: number; /** Whether delivery was forced by maxIterations or budget exhaustion */ forcedDelivery: boolean; /** Reason for forced delivery (if applicable) */ forcedDeliveryReason?: "max_iterations" | "budget_exhausted" | "insufficient_agents"; /** Orchestrator verdict from the last iteration */ lastVerdict: OrchestratorVerdict; /** Per-iteration timing breakdown */ iterationBreakdowns: Array<{ iteration: number; divergentTimeMs: number; inquisitorTimeMs: number; synthesizerTimeMs: number; orchestratorTimeMs: number; totalTimeMs: number; verdict: OrchestratorVerdict; tokensConsumed: number; agentsSurvived: number; agentsTimedOut: number; }>; /** Total tokens consumed across all iterations */ totalTokensConsumed: number; }; /** Session information */ session: { /** Session ID */ sessionId: string; /** Task information */ task: { id: string; name: string; domain: string; }; /** Configuration used */ config?: Record; /** Timestamp */ timestamp: string; }; } /** * Factory for creating agent outputs */ export declare class AgentOutputFactory { static create(params: { agentId: string; agentName: string; providerType: string; evaluation: EvaluationResult; action?: ActionResult; statistics?: AgentPerformanceMetrics; role?: string; taskContext?: AgentOutput["taskContext"]; processing?: AgentOutput["processing"]; error?: AgentOutput["error"]; metadata?: Record; }): AgentOutput; static createError(params: { agentId: string; agentName: string; providerType: string; errorMessage: string; errorType?: string; isFallback?: boolean; fallbackEvaluation?: EvaluationResult; }): AgentOutput; } /** * Utility functions for working with agent outputs */ export declare class AgentOutputUtils { /** * Calculate average confidence across multiple outputs */ static calculateAverageConfidence(outputs: AgentOutput[]): number; /** * Find the output with highest confidence */ static findHighestConfidence(outputs: AgentOutput[]): AgentOutput | null; /** * Filter outputs by minimum confidence threshold */ static filterByConfidence(outputs: AgentOutput[], minConfidence: number): AgentOutput[]; /** * Group outputs by provider type */ static groupByProvider(outputs: AgentOutput[]): Record; /** * Extract evaluation results from outputs */ static extractEvaluations(outputs: AgentOutput[]): EvaluationResult[]; /** * Check if any outputs have errors */ static hasErrors(outputs: AgentOutput[]): boolean; /** * Get successful outputs (no errors) */ static getSuccessfulOutputs(outputs: AgentOutput[]): AgentOutput[]; /** * Calculate score variance across outputs */ static calculateScoreVariance(outputs: AgentOutput[]): number; } //# sourceMappingURL=agent-output.d.ts.map