dfa-mcp-server
Version:
DFA-based workflow MCP server for guiding LLM task completion
107 lines • 3.19 kB
TypeScript
import { JudgeDecision, TransitionAttempt, WorkflowContext, TransitionRule, ConditionEvaluationResult } from './types.js';
export declare class JudgeEngine {
private decisionHistory;
private llmBaseUrl;
private llmApiKey;
private llmModel;
private llmThinkingMode;
private historyDir;
private readonly MAX_RETRIES;
private readonly RETRY_DELAY;
private readonly RETRY_BACKOFF;
private readonly MEMORY_CACHE_SIZE;
constructor(workflowDir?: string);
/**
* Initialize the judge engine and create history directory
*/
initialize(): Promise<void>;
/**
* Validate a transition attempt using the workflow's judge configuration
*/
validateTransition(attempt: TransitionAttempt): Promise<JudgeDecision>;
/**
* Evaluate transition conditions using LLM to determine which rule matches
*/
evaluateTransitionConditions(rules: TransitionRule[], context: WorkflowContext, attempt: TransitionAttempt): Promise<ConditionEvaluationResult>;
/**
* Build prompt for LLM condition evaluation
*/
private buildConditionEvaluationPrompt;
/**
* Parse LLM response for condition evaluation
*/
private parseConditionEvaluationResponse;
/**
* Simple fallback evaluation for conditions (when LLM is not available)
*/
private evaluateConditionsSimple;
/**
* Validate structural correctness of the transition
*/
private validateStructure;
/**
* Validate exit conditions of current state
*/
private validateStateExit;
/**
* Validate entry conditions of target state
*/
private validateStateEntry;
/**
* Validate transition-specific rules
*/
private validateTransitionRules;
/**
* Validate data completeness and required fields
*/
private validateDataCompleteness;
/**
* Check if an object has a nested property (supports dot notation)
*/
private hasNestedProperty;
/**
* Generate human-readable reasoning for the decision
*/
private generateReasoning;
/**
* Generate helpful suggestions based on violations
*/
private generateSuggestions;
/**
* Record decision in history
*/
recordDecision(workflowId: string, decision: JudgeDecision): Promise<void>;
/**
* Get decision history for a workflow with pagination
*/
getDecisionHistory(workflowId: string, limit?: number, offset?: number): Promise<{
decisions: JudgeDecision[];
total: number;
hasMore: boolean;
}>;
/**
* Clear decision history for a workflow
*/
clearHistory(workflowId: string): Promise<void>;
/**
* Sleep utility for retry delays
*/
private sleep;
/**
* Perform sanity check to detect potential bypass attempts
*/
private performSanityCheck;
/**
* Call LLM for intelligent judge decision
*/
private callLLMJudge;
/**
* Build prompt for LLM judge
*/
private buildLLMPrompt;
/**
* Parse LLM response into JudgeDecision
*/
private parseLLMResponse;
}
//# sourceMappingURL=judge-engine.d.ts.map