UNPKG

route-claudecode

Version:

Advanced routing and transformation system for Claude Code outputs to multiple AI providers

53 lines 2.05 kB
/** * 统一响应验证模块 * 项目所有者: Jason Zhang * * 消除重复的静默失败检测逻辑,提供统一的响应验证接口 * 遵循零硬编码、零Fallback、零静默失败原则 */ import { BaseResponse } from '@/types'; /** * 响应验证错误类型 */ export declare class ResponseValidationError extends Error { readonly requestId: string; readonly provider: string; readonly validationType: 'non-streaming' | 'streaming'; constructor(message: string, requestId: string, provider: string, validationType: 'non-streaming' | 'streaming'); } /** * 流式块验证错误类型 */ export declare class StreamChunkValidationError extends Error { readonly requestId: string; readonly provider: string; readonly chunkIndex: number; constructor(message: string, requestId: string, provider: string, chunkIndex: number); } /** * 🚨 Critical: 验证非流式响应,防止静默失败 * 统一的响应验证逻辑,消除重复代码 */ export declare function validateNonStreamingResponse(response: BaseResponse, requestId: string, providerName: string): void; /** * 🚨 Critical: 验证流式chunk,防止静默失败 * 统一的流式验证逻辑,消除重复代码 */ export declare function validateStreamingChunk(chunk: any, requestId: string, providerName: string, chunkIndex: number): void; /** * 验证流式请求是否产生了有效内容 */ export declare function validateStreamingCompletion(chunkCount: number, hasValidContent: boolean, requestId: string, providerName: string): void; /** * 检查是否为有效内容chunk */ export declare function isValidContentChunk(chunk: any): boolean; /** * 提取finish reason从chunk */ export declare function extractFinishReasonFromChunk(chunk: any): string | undefined; /** * 统一的错误处理函数 */ export declare function handleProviderError(error: any, requestId: string, providerName: string, operationType: 'streaming' | 'non-streaming'): never; //# sourceMappingURL=response-validation.d.ts.map