odin-protocol-core
Version:
The world's first standardized AI-to-AI communication infrastructure for JavaScript/TypeScript - 100% functional with 57K+ msgs/sec throughput
90 lines (89 loc) • 2.32 kB
TypeScript
/**
* HEL (Human-Enhanced Logic) Rule Engine Implementation
* Advanced rule evaluation system for AI coordination
*/
import { EventEmitter } from 'events';
import { HELRule, HELEvaluationResult, HELContext } from '../types/HELTypes';
export declare class HELRuleEngine extends EventEmitter {
private rules;
private activeRules;
private ruleHistory;
private maxHistorySize;
emit: (event: string | symbol, ...args: any[]) => boolean;
on: (event: string | symbol, listener: (...args: any[]) => void) => this;
off: (event: string | symbol, listener: (...args: any[]) => void) => this;
constructor(options?: {
maxHistorySize?: number;
});
/**
* Add a new rule to the engine
*/
addRule(rule: HELRule): void;
/**
* Remove a rule from the engine
*/
removeRule(ruleId: string): boolean;
/**
* Enable a rule
*/
enableRule(ruleId: string): boolean;
/**
* Disable a rule
*/
disableRule(ruleId: string): boolean;
/**
* Evaluate all active rules against a context
*/
evaluateRules(context: HELContext): Promise<HELEvaluationResult[]>;
/**
* Evaluate a single rule against a context
*/
evaluateRule(rule: HELRule, context: HELContext): Promise<HELEvaluationResult>;
/**
* Evaluate a single condition
*/
private evaluateCondition;
/**
* Get a value from context using dot notation
*/
private getContextValue;
/**
* Execute actions when a rule fires
*/
private executeActions;
/**
* Execute a single action
*/
private executeAction;
/**
* Get rule statistics
*/
getStatistics(): {
totalRules: number;
activeRules: number;
inactiveRules: number;
totalEvaluations: number;
successfulEvaluations: number;
errorEvaluations: number;
};
/**
* Get rule history
*/
getHistory(limit?: number): HELEvaluationResult[];
/**
* Clear rule history
*/
clearHistory(): void;
/**
* Get all rules
*/
getRules(): HELRule[];
/**
* Get a specific rule
*/
getRule(ruleId: string): HELRule | undefined;
/**
* Add result to history with size limit
*/
private addToHistory;
}