UNPKG

route-claudecode

Version:

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

123 lines 3.32 kB
/** * CodeWhisperer 缓冲式客户端 * 现有实现的重命名版本,确保向后兼容 * 项目所有者: Jason Zhang */ import { AnthropicRequest } from './types'; import { ICodeWhispererClient } from './client-interface'; import { CodeWhispererStreamingConfig } from './config/streaming-config'; export declare class CodeWhispererBufferedClient implements ICodeWhispererClient { private readonly auth; private readonly converter; private readonly parser; private readonly config; private readonly streamingConfig; private readonly metrics; private readonly httpTimeout; private readonly maxRetries; private tokenBlacklisted; private consecutiveRefreshFailures; private readonly maxRefreshFailures; constructor(streamingConfig?: CodeWhispererStreamingConfig); /** * 处理流式请求 - 重构优化版本 */ handleStreamRequest(anthropicReq: AnthropicRequest, writeSSE: (event: string, data: any) => void, onError: (message: string, error: Error) => void): Promise<void>; /** * 检查token是否可用 (类似OpenAI的Key可用性检查) */ private isTokenAvailable; /** * 标记token为不可用 (类似OpenAI的blacklist机制) */ private markTokenUnavailable; /** * 报告token刷新失败 (类似OpenAI的error reporting) */ private reportRefreshFailure; /** * 报告token刷新成功 (重置失败计数) */ private reportRefreshSuccess; /** * 执行带重试机制的操作 (类似OpenAI和Gemini的executeWithRetry) */ private executeWithRetry; /** * 获取认证信息 - 修复支持authMethod */ private getAuthInfo; /** * 构建和验证请求 - 修复支持authMethod条件判断 */ private buildAndValidateRequest; /** * 发送HTTP请求 */ private sendHttpRequest; /** * 处理流式响应 */ private processStreamResponse; /** * 发送初始事件 */ private sendInitialEvents; /** * 发送解析的事件 */ private sendParsedEvents; /** * 发送结束事件 */ private sendFinalEvents; /** * 处理流式请求错误 */ private handleStreamError; /** * 处理非流式请求 - 重构优化版本 */ handleNonStreamRequest(anthropicReq: AnthropicRequest): Promise<any>; /** * 发送非流式HTTP请求 */ private sendNonStreamHttpRequest; /** * 处理非流式响应 */ private processNonStreamResponse; /** * 处理非流式请求错误 */ private handleNonStreamError; /** * 获取客户端类型 */ getClientType(): 'buffered' | 'realtime'; /** * 健康检查 */ healthCheck(): Promise<{ healthy: boolean; type: string; message?: string; }>; /** * 创建请求信息(用于日志) */ private createRequestInfo; /** * 计算消息长度(用于token估算)- 优化版本 */ private calculateMessageLength; /** * 计算内容长度 */ private calculateContentLength; /** * 睡眠函数(用于模拟延时) */ private sleep; } //# sourceMappingURL=client-buffered.d.ts.map