odin-protocol-core
Version:
The world's first standardized AI-to-AI communication infrastructure for JavaScript/TypeScript - 100% functional with 57K+ msgs/sec throughput
137 lines (136 loc) • 3.87 kB
TypeScript
/**
* HEL (Human-Enhanced Logic) Rule Engine Types
*/
export interface HELRule {
/** Unique rule identifier */
id: string;
/** Human-readable rule name */
name: string;
/** Rule description */
description?: string;
/** Rule conditions (all must be true) */
conditions: HELCondition[];
/** Actions to execute when rule fires */
actions: HELAction[];
/** Rule status */
status: HELRuleStatus;
/** Rule priority */
priority?: number;
/** Rule tags for organization */
tags?: string[];
/** Rule creation timestamp */
createdAt?: Date;
/** Rule last modified timestamp */
updatedAt?: Date;
}
export interface HELCondition {
/** Field to evaluate */
field: string;
/** Comparison operator */
operator: HELOperator;
/** Expected value */
value: any;
/** Condition description */
description?: string;
}
export declare enum HELOperator {
EQUALS = "equals",
NOT_EQUALS = "not_equals",
GREATER_THAN = "greater_than",
LESS_THAN = "less_than",
GREATER_THAN_OR_EQUAL = "greater_than_or_equal",
LESS_THAN_OR_EQUAL = "less_than_or_equal",
CONTAINS = "contains",
NOT_CONTAINS = "not_contains",
REGEX_MATCH = "regex_match",
IN_ARRAY = "in_array",
NOT_IN_ARRAY = "not_in_array"
}
export interface HELAction {
/** Action type */
type: HELActionType;
/** Action parameters */
parameters?: Record<string, any>;
/** Action description */
description?: string;
/** Timeout for action execution */
timeout?: number;
}
export declare enum HELActionType {
LOG = "log",
EMIT_EVENT = "emit_event",
SET_VARIABLE = "set_variable",
CALL_FUNCTION = "call_function",
SEND_MESSAGE = "send_message",
UPDATE_CONTEXT = "update_context",
APPROVE = "approve",
REJECT = "reject",
ESCALATE = "escalate",
MODIFY = "modify",
NOTIFY = "notify",
CUSTOM = "custom"
}
export declare enum HELRuleStatus {
ACTIVE = "active",
INACTIVE = "inactive",
DRAFT = "draft",
ARCHIVED = "archived"
}
export interface HELEvaluationResult {
/** Rule ID that was evaluated */
ruleId: string;
/** Rule name */
ruleName: string;
/** Whether the rule fired */
fired: boolean;
/** Evaluation timestamp */
timestamp: Date;
/** Execution time in milliseconds */
executionTime: number;
/** Context used for evaluation */
context: HELContext;
/** Individual condition results */
conditionResults: boolean[];
/** Actions that were triggered */
triggeredActions?: HELActionType[];
/** Error message if evaluation failed */
error?: string;
/** Confidence score (0-100) */
confidence?: number;
/** Result data */
result?: any;
}
export interface HELContext {
/** Context data for rule evaluation */
data: Record<string, any>;
/** Context variables */
variables?: Record<string, any>;
/** Metadata about the context */
metadata?: Record<string, any>;
/** Context timestamp */
timestamp?: Date;
/** Source of the context */
source?: string;
/** Input message or data */
input?: any;
/** Session or user context */
session?: Record<string, any>;
/** Environment variables */
environment?: Record<string, any>;
/** Previous evaluation results */
history?: HELEvaluationResult[];
}
export interface HELEngineConfig {
/** Maximum rules to evaluate in parallel */
maxParallelRules?: number;
/** Default timeout for rule evaluation */
defaultTimeout?: number;
/** Enable rule caching */
enableCaching?: boolean;
/** Cache TTL in milliseconds */
cacheTTL?: number;
/** Enable performance monitoring */
performanceMonitoring?: boolean;
/** Maximum history size */
maxHistorySize?: number;
}