UNPKG

route-claudecode

Version:

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

87 lines 2.71 kB
/** * 优化的统一工具调用检测器 - 100%检测率版本 * 在原始第三方输入接口处进行统一的工具调用检测 * 确保滑动窗口检测覆盖所有OpenAI兼容输入,避免准入条件太严格 * 目标:达到100%检测率,零漏检 */ export interface ToolCallDetectionResult { hasToolCalls: boolean; detectedPatterns: string[]; confidence: number; needsBuffering: boolean; extractedToolCalls?: any[]; detectionMethod: string; } export interface SlidingWindowState { window: string; windowSize: number; totalProcessed: number; detectionCount: number; } export declare class OptimizedToolCallDetector { private readonly windowSize; private readonly toolCallPatterns; constructor(windowSize?: number); /** * 🎯 核心方法:检测请求中的工具调用 - 优化版本 * 对所有OpenAI兼容输入都执行检测,确保100%检测率 */ detectInRequest(request: any, requestId: string): ToolCallDetectionResult; /** * 优化的消息检测 */ private detectInMessageOptimized; /** * 优化的内容检测(支持字符串和数组格式) */ private detectInContentOptimized; /** * 优化的文本检测 - 多层模式匹配 */ private detectInTextOptimized; /** * 🪟 优化的滑动窗口检测 - 确保跨chunk的工具调用不被漏掉 */ private detectWithOptimizedSlidingWindow; /** * 在单个窗口中进行优化检测 */ private detectInWindowOptimized; /** * 排除规则 - 避免明显的误检 */ private shouldExcludeFromDetection; /** * 智能过滤器 - 基于上下文减少误检 */ private applyIntelligentFilter; /** * 智能宽松检测 - 减少误检的保险策略 */ private superLooseDetection; /** * 从窗口中提取具体的工具调用 - 优化版本 */ private extractToolCallsFromWindow; /** * 验证是否是有效的工具调用 */ private isValidToolCall; /** * 判断参数是否看起来像工具调用参数 - 优化版本 */ private looksLikeToolArgs; /** * 🔄 流式检测:更新滑动窗口并检测 - 优化版本 */ updateSlidingWindow(newContent: string, state: SlidingWindowState): { newState: SlidingWindowState; detectionResult: ToolCallDetectionResult; }; /** * 创建初始滑动窗口状态 */ createSlidingWindowState(): SlidingWindowState; } export declare const optimizedToolCallDetector: OptimizedToolCallDetector; //# sourceMappingURL=optimized-tool-call-detector.d.ts.map