/** * SONARouter Helper Classes and Functions * @module @skillsmith/core/routing/SONARouter.helpers */ import type { ExpertId, RoutingDecision, SONAMetrics, ToolType } from './types.js'; /** * V3 MoERouter result type */ export interface V3RoutingResult { experts: Array<{ name: string; index: number; weight: number; score: number; }>; allScores: number[]; loadBalanceLoss: number; entropy: number; } /** * V3 MoERouter interface */ export interface V3MoERouter { initialize(): Promise; route(embedding: Float32Array | number[]): V3RoutingResult; updateExpertWeights(expert: string | number, reward: number): void; getStats(): Record; } /** * V3 SONAOptimizer suggestion */ export interface V3RoutingSuggestion { agent: string; confidence: number; usedQLearning: boolean; source: 'sona-pattern' | 'q-learning' | 'keyword-match' | 'default'; alternatives: Array<{ agent: string; score: number; }>; matchedKeywords?: string[]; } /** * V3 SONAOptimizer interface */ export interface V3SONAOptimizer { initialize(): Promise<{ success: boolean; patternsLoaded: number; }>; getRoutingSuggestion(task: string): V3RoutingSuggestion; processTrajectoryOutcome(outcome: { trajectoryId: string; task: string; agent: string; success: boolean; }): { learned: boolean; patternKey: string; confidence: number; }; getStats(): any; } /** * Simple LRU cache for routing decisions */ export declare class LRUCache { private cache; private readonly maxSize; private readonly ttlMs; constructor(maxSize: number, ttlMs: number); get(key: K): V | null; set(key: K, value: V): void; clear(): void; get size(): number; } /** * Simple metrics collector for SONA routing */ export declare class MetricsCollector { private totalRequests; private requestsByTool; private requestsByExpert; private cacheHits; private cacheMisses; private totalRoutingTimeMs; private totalExecutionTimeMs; private errorCount; private errorsByType; recordRouting(tool: ToolType, expertId: ExpertId, routingTimeMs: number, cacheHit: boolean): void; recordExecution(executionTimeMs: number): void; recordError(errorType: string): void; getMetrics(): Partial; reset(): void; } /** * Check if SONA routing should be used for a request */ export declare function shouldUseSONARouting(tool: ToolType, featureFlags: Record, userTier?: string): boolean; /** * Check if a routing decision indicates high confidence */ export declare function isHighConfidenceDecision(decision: RoutingDecision): boolean; /** * Check if a routing decision used fallback */ export declare function usedFallback(decision: RoutingDecision): boolean; /** * Generate a simple hash from an object (for cache keys) */ export declare function hashObject(obj: Record): string; //# sourceMappingURL=SONARouter.helpers.d.ts.map