UNPKG

codecrucible-synth

Version:

Production-Ready AI Development Platform with Multi-Voice Synthesis, Smithery MCP Integration, Enterprise Security, and Zero-Timeout Reliability

267 lines 7.79 kB
/** * Response Types System for CodeCrucible Synth * Provides structured response handling and validation */ export interface BaseResponse { success: boolean; timestamp: number; error?: ErrorResponse; } export interface AgentResponse extends BaseResponse { content: string; confidence?: number; voiceId?: string; tokensUsed?: number; reasoning?: string; metadata?: ResponseMetadata; type?: ResponseType; quality?: number; } export interface SynthesisResponse extends BaseResponse { combinedContent: string; voicesUsed: string[]; confidence: number; qualityScore: number; synthesisMode: string; reasoning: string; } export interface ToolResponse extends BaseResponse { toolName: string; result: any; executionTime?: number; retryCount?: number; metadata?: any; } export interface FileResponse extends BaseResponse { path: string; filePath?: string; operation: string; content?: string; size?: number; language?: string; metadata?: any; } export interface ErrorResponse { code: string; message: string; details?: any; stack?: string; } export interface ResponseMetadata { timestamp: Date; duration: number; model: string; voice?: string; tokens: number; cost?: number; } export declare enum ResponseType { CODE_GENERATION = "code_generation", CODE_ANALYSIS = "code_analysis", CODE_REVIEW = "code_review", DOCUMENTATION = "documentation", EXPLANATION = "explanation", ERROR_DIAGNOSIS = "error_diagnosis", REFACTORING = "refactoring", TESTING = "testing", GENERAL = "general" } export interface CodeGenerationResponse extends AgentResponse { type: ResponseType.CODE_GENERATION; code: string; language: string; framework?: string; dependencies: string[]; tests?: string; } export interface CodeAnalysisResponse extends AgentResponse { type: ResponseType.CODE_ANALYSIS; analysis: { complexity: number; maintainability: number; performance: number; security: number; bugs: Bug[]; suggestions: Suggestion[]; }; } export interface CodeReviewResponse extends AgentResponse { type: ResponseType.CODE_REVIEW; review: { overall: ReviewScore; comments: ReviewComment[]; approvalStatus: 'approved' | 'changes_requested' | 'needs_review'; summary: string; }; } export interface Bug { severity: 'low' | 'medium' | 'high' | 'critical'; type: string; description: string; location: { file?: string; line?: number; column?: number; }; fix?: string; } export interface Suggestion { type: 'performance' | 'maintainability' | 'style' | 'security' | 'best_practice'; description: string; impact: 'low' | 'medium' | 'high'; effort: 'low' | 'medium' | 'high'; example?: string; } export interface ReviewComment { line?: number; type: 'praise' | 'suggestion' | 'issue' | 'question'; severity: 'info' | 'minor' | 'major' | 'critical'; message: string; fix?: string; } export interface ReviewScore { score: number; breakdown: { functionality: number; maintainability: number; performance: number; security: number; style: number; }; } export interface ValidationResult { isValid: boolean; errors: ValidationError[]; warnings: ValidationWarning[]; score: number; } export interface ValidationError { field: string; message: string; severity: 'error' | 'warning'; } export interface ValidationWarning { field: string; message: string; suggestion?: string; } export declare class ResponseFactory { /** * Create a basic agent response (test-compatible) */ static createAgentResponse(content: string, options?: { confidence?: number; voiceId?: string; tokensUsed?: number; reasoning?: string; }): AgentResponse; /** * Create a synthesis response (test-compatible) */ static createSynthesisResponse(combinedContent: string, voicesUsed: string[], options?: { confidence?: number; qualityScore?: number; synthesisMode?: string; reasoning?: string; }): SynthesisResponse; /** * Create a tool response (test-compatible) */ static createToolResponse(toolName: string, result: any, options?: { executionTime?: number; retryCount?: number; metadata?: any; }): ToolResponse; /** * Create a file response (test-compatible) */ static createFileResponse(path: string, operation: string, options?: { content?: string; size?: number; language?: string; metadata?: any; }): FileResponse; /** * Create an error response (test-compatible) */ static createErrorResponse(code: string, message: string, details?: any): ErrorResponse; /** * Create a legacy-style response for backward compatibility */ static createLegacyAgentResponse(content: string, type: ResponseType, metadata?: Partial<ResponseMetadata>): any; /** * Create a code generation response */ static createCodeGenerationResponse(code: string, language: string, metadata?: Partial<ResponseMetadata>, options?: { framework?: string; dependencies?: string[]; tests?: string; }): CodeGenerationResponse; /** * Create a code analysis response */ static createCodeAnalysisResponse(content: string, analysis: CodeAnalysisResponse['analysis'], metadata?: Partial<ResponseMetadata>): CodeAnalysisResponse; /** * Create a code review response */ static createCodeReviewResponse(content: string, review: CodeReviewResponse['review'], metadata?: Partial<ResponseMetadata>): CodeReviewResponse; /** * Parse response type from content */ static inferResponseType(content: string): ResponseType; } export declare class ResponseValidator { /** * Check if response is valid (test-compatible) */ static isValidResponse(response: any): boolean; /** * Check if response has error (test-compatible) */ static hasError(response: BaseResponse): boolean; /** * Get error message from response (test-compatible) */ static getErrorMessage(response: BaseResponse): string | null; /** * Extract content from any response type (test-compatible) */ static extractContent(response: AgentResponse | SynthesisResponse): string; /** * Validate any agent response */ static validateResponse(response: AgentResponse): ValidationResult; private static validateCodeGenerationResponse; private static validateCodeAnalysisResponse; private static validateCodeReviewResponse; private static calculateValidationScore; /** * Sanitize response content */ static sanitizeResponse(response: AgentResponse): AgentResponse; } export declare class ResponseProcessor { /** * Extract code blocks from response content */ static extractCodeBlocks(content: string): Array<{ language: string; code: string; }>; /** * Calculate response complexity */ static calculateComplexity(response: AgentResponse): number; /** * Merge multiple responses */ static mergeResponses(responses: AgentResponse[]): AgentResponse; } declare const _default: { ResponseFactory: typeof ResponseFactory; ResponseValidator: typeof ResponseValidator; ResponseProcessor: typeof ResponseProcessor; ResponseType: typeof ResponseType; }; export default _default; //# sourceMappingURL=response-types.d.ts.map