UNPKG

@cyqlelabs/mcp-dual-cycle-reasoner

Version:

MCP server implementing dual-cycle metacognitive reasoning framework for autonomous agents

92 lines (91 loc) 3 kB
import { CognitiveTrace, LoopDetectionResult, DiagnosisResult, RecoveryPlan, BeliefRevisionResult, Case, SentinelConfig } from './types.js'; /** * The Dual-Cycle Engine implements the metacognitive framework described in the DUAL-CYCLE document. * It consists of two interconnected cycles: * - Cognitive Cycle (The "Doer"): Direct interaction with the environment * - Metacognitive Cycle (The "Thinker"): Monitors and controls the cognitive cycle */ export declare class DualCycleEngine { private sentinel; private adjudicator; private currentTrace; private isMonitoring; private interventionCount; constructor(config?: Partial<SentinelConfig>); /** * Initialize a new cognitive trace for monitoring */ private initializeTrace; /** * Start metacognitive monitoring of an agent's cognitive trace */ startMonitoring(initialGoal: string, initialBeliefs?: string[]): void; /** * Stop metacognitive monitoring */ stopMonitoring(): void; /** * Process a new cognitive trace update (called by the cognitive cycle) */ processTraceUpdate(trace: CognitiveTrace): Promise<{ intervention_required: boolean; loop_detected?: LoopDetectionResult; diagnosis?: DiagnosisResult; recovery_plan?: RecoveryPlan; revised_beliefs?: BeliefRevisionResult; explanation?: string; }>; /** * METACOGNITIVE CYCLE - Phase 1: MONITOR * Uses the Sentinel to detect problematic patterns */ private monitorForLoops; /** * METACOGNITIVE CYCLE - Phase 2: INTERPRET/DETECT * Uses the Adjudicator to diagnose the failure */ private interpretFailure; /** * METACOGNITIVE CYCLE - Phase 3: PLAN (Meta-Level) * Uses the Adjudicator to generate a recovery plan */ private planRecovery; /** * METACOGNITIVE CYCLE - Phase 4: CONTROL (Meta-Level) * Revises beliefs and prepares cognitive control signals */ private controlCognition; /** * Store the experience for case-based reasoning */ private storeExperience; /** * Generate a human-readable explanation of the intervention */ private generateInterventionExplanation; /** * Extract a summary of the current context for case storage */ private extractContextSummary; /** * Get current monitoring status and statistics */ getMonitoringStatus(): { is_monitoring: boolean; intervention_count: number; current_goal: string; trace_length: number; }; /** * Update the outcome of a previously generated recovery plan */ updateRecoveryOutcome(successful: boolean, explanation: string): void; /** * Reset the engine state (useful for testing or new sessions) */ reset(): void; /** * Get similar cases for analysis */ getSimilarCases(problemDescription: string, maxResults?: number): Case[]; }