/** * Intelligent Task Completion Detector * * This module provides robust detection of whether a continuous task is truly complete, * rather than just pattern-matching keywords like "done" in responses. * * Key features: * - Multi-signal analysis (tool usage, response content, state changes) * - AI verification round before final completion * - Confidence scoring * - Work-in-progress detection * * @license MIT * @author Bo Shang */ export interface ToolActivity { toolName: string; timestamp: number; success: boolean; hasOutput: boolean; } export interface CompletionSignals { hasExplicitCompletionStatement: boolean; hasIncompleteWorkIndicators: boolean; hasPendingActionIndicators: boolean; hasErrorIndicators: boolean; hasFollowUpQuestions: boolean; hasDocumentationSpam: boolean; toolsUsedInLastResponse: number; lastToolWasReadOnly: boolean; consecutiveResponsesWithoutTools: number; hasRecentFileWrites: boolean; hasRecentCommits: boolean; todoItemsPending: number; todoItemsCompleted: number; mentionsFutureWork: boolean; completionConfidence: number; } export interface CompletionAnalysis { isComplete: boolean; confidence: number; signals: CompletionSignals; reason: string; shouldVerify: boolean; verificationPrompt?: string; } export declare const WRITE_TOOLS: Set; export declare class TaskCompletionDetector { private toolHistory; private responseHistory; private lastToolNames; private consecutiveNoTools; private todoStats; constructor(); /** * Reset the detector state for a new task */ reset(): void; /** * Record a tool call */ recordToolCall(toolName: string, success: boolean, hasOutput: boolean): void; /** * Record a response (call after each AI response) */ recordResponse(response: string, toolsUsed: string[]): void; /** * Update todo statistics */ updateTodoStats(pending: number, completed: number): void; /** * Analyze the current state and determine if the task is complete */ analyzeCompletion(currentResponse: string, toolsUsedThisRound: string[]): CompletionAnalysis; /** * Gather all completion signals from the current state */ private gatherSignals; /** * Calculate confidence score for task completion */ private calculateConfidence; /** * Generate a verification prompt to ask the AI if the task is truly complete */ private generateVerificationPrompt; /** * Generate a verification prompt for stagnation cases */ private generateStagnationVerificationPrompt; /** * Get a human-readable reason for low confidence */ private getLowConfidenceReason; /** * Check if a verification response confirms completion */ isVerificationConfirmed(verificationResponse: string): boolean; /** * Check if a response contradicts itself by saying "complete" but also indicating incomplete work. * This comprehensive list catches many ways AI might admit work isn't done while claiming completion. */ private responseContainsIncompleteIndicators; /** * Check if response contains simulation/fake indicators that should prevent completion. * Simulated results mean the task was NOT actually completed. */ containsSimulationIndicators(response: string): boolean; } export declare function getTaskCompletionDetector(): TaskCompletionDetector; export declare function resetTaskCompletionDetector(): void; //# sourceMappingURL=taskCompletionDetector.d.ts.map