agentic-qe 2.4.0 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/agents/qe-a11y-ally.md +855 -0
- package/.claude/agents/qx-partner.md +120 -4
- package/.claude/skills/testability-scoring/SKILL.md +107 -6
- package/CHANGELOG.md +135 -0
- package/README.md +7 -6
- package/dist/agents/AccessibilityAllyAgent.d.ts +168 -0
- package/dist/agents/AccessibilityAllyAgent.d.ts.map +1 -0
- package/dist/agents/AccessibilityAllyAgent.js +462 -0
- package/dist/agents/AccessibilityAllyAgent.js.map +1 -0
- package/dist/agents/SONAIntegration.d.ts +109 -0
- package/dist/agents/SONAIntegration.d.ts.map +1 -0
- package/dist/agents/SONAIntegration.js +167 -0
- package/dist/agents/SONAIntegration.js.map +1 -0
- package/dist/agents/index.d.ts +3 -0
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +93 -2
- package/dist/agents/index.js.map +1 -1
- package/dist/cli/init/agents.js +1 -1
- package/dist/cli/init/claude-config.js +2 -2
- package/dist/cli/init/database-init.js +1 -1
- package/dist/core/cache/BinaryCacheImpl.d.ts +161 -0
- package/dist/core/cache/BinaryCacheImpl.d.ts.map +1 -0
- package/dist/core/cache/BinaryCacheImpl.js +685 -0
- package/dist/core/cache/BinaryCacheImpl.js.map +1 -0
- package/dist/core/cache/BinaryMetadataCache.d.ts +244 -0
- package/dist/core/cache/BinaryMetadataCache.d.ts.map +1 -1
- package/dist/core/cache/BinaryMetadataCache.js +63 -1
- package/dist/core/cache/BinaryMetadataCache.js.map +1 -1
- package/dist/core/cache/index.d.ts +1 -0
- package/dist/core/cache/index.d.ts.map +1 -1
- package/dist/core/cache/index.js +10 -1
- package/dist/core/cache/index.js.map +1 -1
- package/dist/core/memory/AgentDBService.d.ts +30 -4
- package/dist/core/memory/AgentDBService.d.ts.map +1 -1
- package/dist/core/memory/AgentDBService.js +122 -12
- package/dist/core/memory/AgentDBService.js.map +1 -1
- package/dist/core/memory/CachedHNSWVectorMemory.d.ts +153 -0
- package/dist/core/memory/CachedHNSWVectorMemory.d.ts.map +1 -0
- package/dist/core/memory/CachedHNSWVectorMemory.js +329 -0
- package/dist/core/memory/CachedHNSWVectorMemory.js.map +1 -0
- package/dist/core/memory/HNSWVectorMemory.js +1 -1
- package/dist/core/memory/RuVectorPatternStore.d.ts.map +1 -1
- package/dist/core/memory/RuVectorPatternStore.js +8 -2
- package/dist/core/memory/RuVectorPatternStore.js.map +1 -1
- package/dist/core/memory/UnifiedMemoryCoordinator.d.ts +50 -0
- package/dist/core/memory/UnifiedMemoryCoordinator.d.ts.map +1 -1
- package/dist/core/memory/UnifiedMemoryCoordinator.js +206 -0
- package/dist/core/memory/UnifiedMemoryCoordinator.js.map +1 -1
- package/dist/core/memory/index.d.ts +2 -0
- package/dist/core/memory/index.d.ts.map +1 -1
- package/dist/core/memory/index.js +8 -1
- package/dist/core/memory/index.js.map +1 -1
- package/dist/core/optimization/RecursiveOptimizer.d.ts +233 -0
- package/dist/core/optimization/RecursiveOptimizer.d.ts.map +1 -0
- package/dist/core/optimization/RecursiveOptimizer.js +509 -0
- package/dist/core/optimization/RecursiveOptimizer.js.map +1 -0
- package/dist/core/strategies/SONALearningStrategy.d.ts +115 -0
- package/dist/core/strategies/SONALearningStrategy.d.ts.map +1 -0
- package/dist/core/strategies/SONALearningStrategy.js +656 -0
- package/dist/core/strategies/SONALearningStrategy.js.map +1 -0
- package/dist/core/strategies/TRMLearningStrategy.d.ts +162 -0
- package/dist/core/strategies/TRMLearningStrategy.d.ts.map +1 -0
- package/dist/core/strategies/TRMLearningStrategy.js +670 -0
- package/dist/core/strategies/TRMLearningStrategy.js.map +1 -0
- package/dist/core/strategies/index.d.ts +10 -1
- package/dist/core/strategies/index.d.ts.map +1 -1
- package/dist/core/strategies/index.js +4 -1
- package/dist/core/strategies/index.js.map +1 -1
- package/dist/learning/SONAFeedbackLoop.d.ts +168 -0
- package/dist/learning/SONAFeedbackLoop.d.ts.map +1 -0
- package/dist/learning/SONAFeedbackLoop.js +344 -0
- package/dist/learning/SONAFeedbackLoop.js.map +1 -0
- package/dist/learning/baselines/BaselineCollector.d.ts +1 -1
- package/dist/learning/baselines/BaselineCollector.js +1 -1
- package/dist/learning/baselines/StandardTaskSuite.d.ts +1 -1
- package/dist/learning/baselines/StandardTaskSuite.js +1 -1
- package/dist/learning/index.d.ts +2 -0
- package/dist/learning/index.d.ts.map +1 -1
- package/dist/learning/index.js +6 -1
- package/dist/learning/index.js.map +1 -1
- package/dist/mcp/server-instructions.d.ts +1 -1
- package/dist/mcp/server-instructions.js +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +23 -16
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/services/AgentRegistry.d.ts.map +1 -1
- package/dist/mcp/services/AgentRegistry.js +6 -1
- package/dist/mcp/services/AgentRegistry.js.map +1 -1
- package/dist/mcp/tools/qe/accessibility/accname-computation.d.ts +114 -0
- package/dist/mcp/tools/qe/accessibility/accname-computation.d.ts.map +1 -0
- package/dist/mcp/tools/qe/accessibility/accname-computation.js +566 -0
- package/dist/mcp/tools/qe/accessibility/accname-computation.js.map +1 -0
- package/dist/mcp/tools/qe/accessibility/apg-patterns.d.ts +103 -0
- package/dist/mcp/tools/qe/accessibility/apg-patterns.d.ts.map +1 -0
- package/dist/mcp/tools/qe/accessibility/apg-patterns.js +1028 -0
- package/dist/mcp/tools/qe/accessibility/apg-patterns.js.map +1 -0
- package/dist/mcp/tools/qe/accessibility/en-301-549-mapping.d.ts +48 -0
- package/dist/mcp/tools/qe/accessibility/en-301-549-mapping.d.ts.map +1 -0
- package/dist/mcp/tools/qe/accessibility/en-301-549-mapping.js +565 -0
- package/dist/mcp/tools/qe/accessibility/en-301-549-mapping.js.map +1 -0
- package/dist/mcp/tools/qe/accessibility/eu-accessibility-act.d.ts +117 -0
- package/dist/mcp/tools/qe/accessibility/eu-accessibility-act.d.ts.map +1 -0
- package/dist/mcp/tools/qe/accessibility/eu-accessibility-act.js +571 -0
- package/dist/mcp/tools/qe/accessibility/eu-accessibility-act.js.map +1 -0
- package/dist/mcp/tools/qe/accessibility/html-report-generator.d.ts +23 -0
- package/dist/mcp/tools/qe/accessibility/html-report-generator.d.ts.map +1 -0
- package/dist/mcp/tools/qe/accessibility/html-report-generator.js +1152 -0
- package/dist/mcp/tools/qe/accessibility/html-report-generator.js.map +1 -0
- package/dist/mcp/tools/qe/accessibility/index.d.ts +22 -0
- package/dist/mcp/tools/qe/accessibility/index.d.ts.map +1 -0
- package/dist/mcp/tools/qe/accessibility/index.js +38 -0
- package/dist/mcp/tools/qe/accessibility/index.js.map +1 -0
- package/dist/mcp/tools/qe/accessibility/markdown-report-generator.d.ts +18 -0
- package/dist/mcp/tools/qe/accessibility/markdown-report-generator.d.ts.map +1 -0
- package/dist/mcp/tools/qe/accessibility/markdown-report-generator.js +549 -0
- package/dist/mcp/tools/qe/accessibility/markdown-report-generator.js.map +1 -0
- package/dist/mcp/tools/qe/accessibility/remediation-code-generator.d.ts +139 -0
- package/dist/mcp/tools/qe/accessibility/remediation-code-generator.d.ts.map +1 -0
- package/dist/mcp/tools/qe/accessibility/remediation-code-generator.js +1300 -0
- package/dist/mcp/tools/qe/accessibility/remediation-code-generator.js.map +1 -0
- package/dist/mcp/tools/qe/accessibility/scan-comprehensive.d.ts +138 -0
- package/dist/mcp/tools/qe/accessibility/scan-comprehensive.d.ts.map +1 -0
- package/dist/mcp/tools/qe/accessibility/scan-comprehensive.js +1298 -0
- package/dist/mcp/tools/qe/accessibility/scan-comprehensive.js.map +1 -0
- package/dist/mcp/tools/qe/accessibility/video-vision-analyzer.d.ts +50 -0
- package/dist/mcp/tools/qe/accessibility/video-vision-analyzer.d.ts.map +1 -0
- package/dist/mcp/tools/qe/accessibility/video-vision-analyzer.js +469 -0
- package/dist/mcp/tools/qe/accessibility/video-vision-analyzer.js.map +1 -0
- package/dist/mcp/tools/qe/accessibility/webvtt-generator.d.ts +193 -0
- package/dist/mcp/tools/qe/accessibility/webvtt-generator.d.ts.map +1 -0
- package/dist/mcp/tools/qe/accessibility/webvtt-generator.js +511 -0
- package/dist/mcp/tools/qe/accessibility/webvtt-generator.js.map +1 -0
- package/dist/mcp/tools.d.ts +1 -0
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +61 -0
- package/dist/mcp/tools.js.map +1 -1
- package/dist/providers/HybridRouter.d.ts +34 -3
- package/dist/providers/HybridRouter.d.ts.map +1 -1
- package/dist/providers/HybridRouter.js +69 -4
- package/dist/providers/HybridRouter.js.map +1 -1
- package/dist/providers/LLMProviderFactory.d.ts +68 -1
- package/dist/providers/LLMProviderFactory.d.ts.map +1 -1
- package/dist/providers/LLMProviderFactory.js +173 -6
- package/dist/providers/LLMProviderFactory.js.map +1 -1
- package/dist/providers/OpenRouterProvider.d.ts +150 -0
- package/dist/providers/OpenRouterProvider.d.ts.map +1 -0
- package/dist/providers/OpenRouterProvider.js +545 -0
- package/dist/providers/OpenRouterProvider.js.map +1 -0
- package/dist/providers/RuvllmProvider.d.ts +130 -16
- package/dist/providers/RuvllmProvider.d.ts.map +1 -1
- package/dist/providers/RuvllmProvider.js +399 -83
- package/dist/providers/RuvllmProvider.js.map +1 -1
- package/dist/providers/index.d.ts +33 -4
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +72 -21
- package/dist/providers/index.js.map +1 -1
- package/dist/telemetry/instrumentation/agent.d.ts +1 -1
- package/dist/telemetry/instrumentation/agent.js +1 -1
- package/dist/telemetry/instrumentation/index.d.ts +1 -1
- package/dist/telemetry/instrumentation/index.js +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/ruvllm.d.ts +97 -0
- package/dist/types/ruvllm.d.ts.map +1 -0
- package/dist/types/ruvllm.js +46 -0
- package/dist/types/ruvllm.js.map +1 -0
- package/dist/utils/ruvllm-loader.d.ts +94 -0
- package/dist/utils/ruvllm-loader.d.ts.map +1 -0
- package/dist/utils/ruvllm-loader.js +87 -0
- package/dist/utils/ruvllm-loader.js.map +1 -0
- package/docs/reference/agents.md +36 -1
- package/package.json +5 -2
|
@@ -0,0 +1,670 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* TRMLearningStrategy - TRM-enhanced agent learning with SONA integration
|
|
4
|
+
*
|
|
5
|
+
* Implements AgentLearningStrategy with Test-time Reasoning & Metacognition (TRM)
|
|
6
|
+
* capabilities from @ruvector/ruvllm. Features:
|
|
7
|
+
* - TRM pattern learning with convergence tracking
|
|
8
|
+
* - SONA adaptive learning with LoRA adapters
|
|
9
|
+
* - ReasoningBank for pattern storage and retrieval
|
|
10
|
+
* - EWC++ for catastrophic forgetting prevention
|
|
11
|
+
* - Binary cache for fast pattern access
|
|
12
|
+
*
|
|
13
|
+
* @module core/strategies/TRMLearningStrategy
|
|
14
|
+
* @version 1.0.0
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.TRMLearningStrategy = void 0;
|
|
18
|
+
const BinaryMetadataCache_1 = require("../cache/BinaryMetadataCache");
|
|
19
|
+
const Logger_1 = require("../../utils/Logger");
|
|
20
|
+
const ruvllm_loader_1 = require("../../utils/ruvllm-loader");
|
|
21
|
+
/**
|
|
22
|
+
* TRMLearningStrategy - TRM-enhanced learning with SONA integration
|
|
23
|
+
*
|
|
24
|
+
* Uses @ruvector/ruvllm for:
|
|
25
|
+
* - RuvLLM: Core inference with memory and feedback
|
|
26
|
+
* - SonaCoordinator: Trajectory recording and learning
|
|
27
|
+
* - ReasoningBank: Pattern storage with similarity search
|
|
28
|
+
* - LoraManager: MicroLoRA/BaseLoRA adapters
|
|
29
|
+
* - TrajectoryBuilder: Learning trajectory construction
|
|
30
|
+
*/
|
|
31
|
+
class TRMLearningStrategy {
|
|
32
|
+
constructor(config) {
|
|
33
|
+
this.initialized = false;
|
|
34
|
+
this.trainingIterations = 0;
|
|
35
|
+
// TRM patterns and executions
|
|
36
|
+
this.trmPatterns = new Map();
|
|
37
|
+
this.patterns = new Map();
|
|
38
|
+
this.executions = [];
|
|
39
|
+
this.trajectories = [];
|
|
40
|
+
this.recommendations = new Map();
|
|
41
|
+
this.logger = Logger_1.Logger.getInstance();
|
|
42
|
+
this.config = {
|
|
43
|
+
enableSONA: config?.enableSONA ?? true,
|
|
44
|
+
loraRank: config?.loraRank ?? 8,
|
|
45
|
+
loraAlpha: config?.loraAlpha ?? 16,
|
|
46
|
+
ewcLambda: config?.ewcLambda ?? 2000,
|
|
47
|
+
minQuality: config?.minQuality ?? 0.5,
|
|
48
|
+
maxPatterns: config?.maxPatterns ?? 10000,
|
|
49
|
+
similarityThreshold: config?.similarityThreshold ?? 0.85,
|
|
50
|
+
enableTrajectories: config?.enableTrajectories ?? true,
|
|
51
|
+
maxExecutions: config?.maxExecutions ?? 1000,
|
|
52
|
+
learningRate: config?.learningRate ?? 0.1,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Initialize the TRM learning strategy
|
|
57
|
+
*
|
|
58
|
+
* Loads ruvLLM components for SONA learning, trajectory tracking,
|
|
59
|
+
* and pattern storage.
|
|
60
|
+
*/
|
|
61
|
+
async initialize() {
|
|
62
|
+
if (this.initialized) {
|
|
63
|
+
this.logger.warn('TRMLearningStrategy already initialized');
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
// Load ruvLLM via CJS (ESM build is broken)
|
|
68
|
+
const ruvllmModule = (0, ruvllm_loader_1.loadRuvLLM)();
|
|
69
|
+
if (!ruvllmModule) {
|
|
70
|
+
this.logger.warn('RuvLLM not available, using fallback mode');
|
|
71
|
+
this.initialized = true;
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
// Initialize RuvLLM core
|
|
75
|
+
this.ruvllm = new ruvllmModule.RuvLLM({
|
|
76
|
+
learningEnabled: this.config.enableSONA,
|
|
77
|
+
embeddingDim: 768,
|
|
78
|
+
ewcLambda: this.config.ewcLambda,
|
|
79
|
+
});
|
|
80
|
+
// Initialize SONA components if enabled
|
|
81
|
+
if (this.config.enableSONA) {
|
|
82
|
+
this.sonaCoordinator = new ruvllmModule.SonaCoordinator();
|
|
83
|
+
this.reasoningBank = new ruvllmModule.ReasoningBank(this.config.similarityThreshold);
|
|
84
|
+
this.loraManager = new ruvllmModule.LoraManager();
|
|
85
|
+
this.logger.info('SONA components initialized', {
|
|
86
|
+
loraRank: this.config.loraRank,
|
|
87
|
+
loraAlpha: this.config.loraAlpha,
|
|
88
|
+
ewcLambda: this.config.ewcLambda,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
this.initialized = true;
|
|
92
|
+
this.logger.info('TRMLearningStrategy initialized');
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
// Fallback to basic mode without ruvLLM
|
|
96
|
+
this.logger.warn('Failed to load ruvLLM, using fallback mode', {
|
|
97
|
+
error: error.message,
|
|
98
|
+
});
|
|
99
|
+
this.initialized = true;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Store a learned pattern (converts to TRM format)
|
|
104
|
+
*/
|
|
105
|
+
async storePattern(pattern) {
|
|
106
|
+
this.ensureInitialized();
|
|
107
|
+
// Enforce max patterns limit
|
|
108
|
+
if (this.patterns.size >= this.config.maxPatterns) {
|
|
109
|
+
this.removeLowestQualityPattern();
|
|
110
|
+
}
|
|
111
|
+
// Store standard pattern
|
|
112
|
+
this.patterns.set(pattern.id, {
|
|
113
|
+
...pattern,
|
|
114
|
+
updatedAt: new Date(),
|
|
115
|
+
});
|
|
116
|
+
// Store in ReasoningBank if SONA enabled
|
|
117
|
+
if (this.reasoningBank && pattern.embedding) {
|
|
118
|
+
try {
|
|
119
|
+
// ReasoningBank.store(type, embedding, metadata)
|
|
120
|
+
this.reasoningBank.store('query_response', pattern.embedding, {
|
|
121
|
+
patternId: pattern.id,
|
|
122
|
+
content: pattern.content,
|
|
123
|
+
confidence: pattern.confidence,
|
|
124
|
+
type: pattern.type,
|
|
125
|
+
domain: pattern.domain,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
this.logger.debug('ReasoningBank store failed', { error: error.message });
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
// Also add to ruvLLM memory if available
|
|
133
|
+
if (this.ruvllm) {
|
|
134
|
+
try {
|
|
135
|
+
this.ruvllm.addMemory(pattern.content, {
|
|
136
|
+
patternId: pattern.id,
|
|
137
|
+
type: pattern.type,
|
|
138
|
+
domain: pattern.domain,
|
|
139
|
+
confidence: pattern.confidence,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
this.logger.debug('RuvLLM memory add failed', { error: error.message });
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Store a TRM-specific pattern with quality metrics
|
|
149
|
+
*/
|
|
150
|
+
async storeTRMPattern(input, output, metadata, inputEmbedding, outputEmbedding) {
|
|
151
|
+
this.ensureInitialized();
|
|
152
|
+
// Generate embeddings if not provided
|
|
153
|
+
const inputEmb = inputEmbedding ?? this.generateEmbedding(input);
|
|
154
|
+
const outputEmb = outputEmbedding ?? this.generateEmbedding(output);
|
|
155
|
+
// Create TRM pattern entry
|
|
156
|
+
const entry = (0, BinaryMetadataCache_1.createTRMPatternEntry)(input, output, inputEmb, outputEmb, metadata);
|
|
157
|
+
// Enforce max patterns limit
|
|
158
|
+
if (this.trmPatterns.size >= this.config.maxPatterns) {
|
|
159
|
+
this.removeLowestQualityTRMPattern();
|
|
160
|
+
}
|
|
161
|
+
this.trmPatterns.set(entry.id, entry);
|
|
162
|
+
// Track trajectory if enabled
|
|
163
|
+
if (this.config.enableTrajectories && this.sonaCoordinator) {
|
|
164
|
+
try {
|
|
165
|
+
const ruvllmModule = (0, ruvllm_loader_1.loadRuvLLM)();
|
|
166
|
+
if (ruvllmModule) {
|
|
167
|
+
const trajectory = new ruvllmModule.TrajectoryBuilder()
|
|
168
|
+
.startStep('query', input)
|
|
169
|
+
.endStep(output, metadata.confidence ?? 0.5)
|
|
170
|
+
.complete(metadata.converged ? 'success' : 'partial');
|
|
171
|
+
this.sonaCoordinator.recordTrajectory(trajectory);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
this.logger.debug('Trajectory recording failed', { error: error.message });
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
this.logger.debug('TRM pattern stored', {
|
|
179
|
+
id: entry.id,
|
|
180
|
+
type: entry.type,
|
|
181
|
+
quality: metadata.quality,
|
|
182
|
+
converged: metadata.converged,
|
|
183
|
+
});
|
|
184
|
+
return entry.id;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Query learned patterns
|
|
188
|
+
*/
|
|
189
|
+
async getPatterns(query) {
|
|
190
|
+
this.ensureInitialized();
|
|
191
|
+
let results = Array.from(this.patterns.values());
|
|
192
|
+
// Apply filters
|
|
193
|
+
if (query.type) {
|
|
194
|
+
results = results.filter((p) => p.type === query.type);
|
|
195
|
+
}
|
|
196
|
+
if (query.domain) {
|
|
197
|
+
results = results.filter((p) => p.domain === query.domain);
|
|
198
|
+
}
|
|
199
|
+
if (query.minConfidence !== undefined) {
|
|
200
|
+
results = results.filter((p) => p.confidence >= query.minConfidence);
|
|
201
|
+
}
|
|
202
|
+
// Vector similarity search if embedding provided
|
|
203
|
+
if (query.embedding) {
|
|
204
|
+
results = await this.findSimilarPatterns(query.embedding, query.limit ?? 10);
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
// Sort by confidence (descending)
|
|
208
|
+
results.sort((a, b) => b.confidence - a.confidence);
|
|
209
|
+
}
|
|
210
|
+
// Apply limit
|
|
211
|
+
if (query.limit) {
|
|
212
|
+
results = results.slice(0, query.limit);
|
|
213
|
+
}
|
|
214
|
+
return results;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Get TRM patterns with quality filtering
|
|
218
|
+
*/
|
|
219
|
+
async getTRMPatterns(options) {
|
|
220
|
+
this.ensureInitialized();
|
|
221
|
+
let results = Array.from(this.trmPatterns.values());
|
|
222
|
+
// Apply filters
|
|
223
|
+
if (options?.minQuality !== undefined) {
|
|
224
|
+
results = results.filter((p) => p.metadata.quality >= options.minQuality);
|
|
225
|
+
}
|
|
226
|
+
if (options?.convergedOnly) {
|
|
227
|
+
results = results.filter((p) => p.metadata.converged);
|
|
228
|
+
}
|
|
229
|
+
if (options?.type) {
|
|
230
|
+
results = results.filter((p) => p.type === options.type);
|
|
231
|
+
}
|
|
232
|
+
// Sort by quality (descending)
|
|
233
|
+
results.sort((a, b) => b.metadata.quality - a.metadata.quality);
|
|
234
|
+
// Apply limit
|
|
235
|
+
if (options?.limit) {
|
|
236
|
+
results = results.slice(0, options.limit);
|
|
237
|
+
}
|
|
238
|
+
return results;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Find similar patterns using vector similarity
|
|
242
|
+
*/
|
|
243
|
+
async findSimilarPatterns(embedding, limit = 10) {
|
|
244
|
+
this.ensureInitialized();
|
|
245
|
+
// Use ReasoningBank if available
|
|
246
|
+
if (this.reasoningBank) {
|
|
247
|
+
try {
|
|
248
|
+
// ReasoningBank.findSimilar expects number[] (Embedding type)
|
|
249
|
+
const similar = this.reasoningBank.findSimilar(embedding, limit);
|
|
250
|
+
return similar
|
|
251
|
+
.map((s) => this.patterns.get(s.id))
|
|
252
|
+
.filter(Boolean);
|
|
253
|
+
}
|
|
254
|
+
catch (error) {
|
|
255
|
+
this.logger.debug('ReasoningBank search failed, using fallback', { error: error.message });
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
// Use ruvLLM memory search if available
|
|
259
|
+
if (this.ruvllm) {
|
|
260
|
+
try {
|
|
261
|
+
const memoryResults = this.ruvllm.searchMemory(embedding.slice(0, 100).join(' '), // Convert to text query
|
|
262
|
+
limit);
|
|
263
|
+
return memoryResults
|
|
264
|
+
.map((m) => this.patterns.get(m.metadata?.patternId))
|
|
265
|
+
.filter(Boolean);
|
|
266
|
+
}
|
|
267
|
+
catch (error) {
|
|
268
|
+
this.logger.debug('RuvLLM memory search failed', { error: error.message });
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
// Fallback: brute force similarity
|
|
272
|
+
const results = [];
|
|
273
|
+
for (const pattern of this.patterns.values()) {
|
|
274
|
+
if (pattern.embedding) {
|
|
275
|
+
const similarity = this.cosineSimilarity(embedding, pattern.embedding);
|
|
276
|
+
results.push({ pattern, similarity });
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return results
|
|
280
|
+
.sort((a, b) => b.similarity - a.similarity)
|
|
281
|
+
.slice(0, limit)
|
|
282
|
+
.map((r) => r.pattern);
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Find similar TRM patterns
|
|
286
|
+
*/
|
|
287
|
+
async findSimilarTRMPatterns(embedding, limit = 10) {
|
|
288
|
+
this.ensureInitialized();
|
|
289
|
+
const results = [];
|
|
290
|
+
for (const pattern of this.trmPatterns.values()) {
|
|
291
|
+
const similarity = this.cosineSimilarity(Array.from(embedding), Array.from(pattern.inputEmbedding));
|
|
292
|
+
results.push({ pattern, score: similarity });
|
|
293
|
+
}
|
|
294
|
+
return results
|
|
295
|
+
.sort((a, b) => b.score - a.score)
|
|
296
|
+
.slice(0, limit);
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Update pattern confidence based on feedback
|
|
300
|
+
*/
|
|
301
|
+
async updatePatternConfidence(patternId, success) {
|
|
302
|
+
this.ensureInitialized();
|
|
303
|
+
const pattern = this.patterns.get(patternId);
|
|
304
|
+
if (pattern) {
|
|
305
|
+
// Exponential moving average for confidence
|
|
306
|
+
const adjustment = success ? this.config.learningRate : -this.config.learningRate;
|
|
307
|
+
pattern.confidence = Math.max(0, Math.min(1, pattern.confidence + adjustment));
|
|
308
|
+
pattern.usageCount++;
|
|
309
|
+
// Update success rate
|
|
310
|
+
const totalUses = pattern.usageCount;
|
|
311
|
+
const successRate = success
|
|
312
|
+
? (pattern.successRate * (totalUses - 1) + 1) / totalUses
|
|
313
|
+
: (pattern.successRate * (totalUses - 1)) / totalUses;
|
|
314
|
+
pattern.successRate = successRate;
|
|
315
|
+
pattern.updatedAt = new Date();
|
|
316
|
+
this.patterns.set(patternId, pattern);
|
|
317
|
+
}
|
|
318
|
+
// Update TRM pattern if exists
|
|
319
|
+
const trmPattern = this.trmPatterns.get(patternId);
|
|
320
|
+
if (trmPattern) {
|
|
321
|
+
const adjustment = success ? this.config.learningRate : -this.config.learningRate;
|
|
322
|
+
trmPattern.metadata.quality = Math.max(0, Math.min(1, trmPattern.metadata.quality + adjustment));
|
|
323
|
+
trmPattern.metadata.usageCount++;
|
|
324
|
+
trmPattern.metadata.lastUsed = Date.now();
|
|
325
|
+
this.trmPatterns.set(patternId, trmPattern);
|
|
326
|
+
}
|
|
327
|
+
// Record feedback in ruvLLM if available (uses requestId, not patternId)
|
|
328
|
+
// Note: RuvLLM feedback API expects Feedback { requestId, rating, correction? }
|
|
329
|
+
// We skip this if we don't have a requestId - pattern updates are handled above
|
|
330
|
+
// This is a design limitation: we can't directly map pattern IDs to request IDs
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Recommend a strategy based on task state with TRM enhancement
|
|
334
|
+
*/
|
|
335
|
+
async recommendStrategy(taskState) {
|
|
336
|
+
this.ensureInitialized();
|
|
337
|
+
// Generate embedding for task state
|
|
338
|
+
const stateText = JSON.stringify(taskState);
|
|
339
|
+
const stateEmbedding = this.generateEmbedding(stateText);
|
|
340
|
+
// Find similar TRM patterns first
|
|
341
|
+
const similarTRM = await this.findSimilarTRMPatterns(new Float32Array(stateEmbedding), 5);
|
|
342
|
+
if (similarTRM.length > 0 && similarTRM[0].score > this.config.similarityThreshold) {
|
|
343
|
+
const bestPattern = similarTRM[0].pattern;
|
|
344
|
+
const recommendation = {
|
|
345
|
+
strategy: bestPattern.type,
|
|
346
|
+
confidence: bestPattern.metadata.quality * similarTRM[0].score,
|
|
347
|
+
reasoning: `TRM pattern match (similarity: ${(similarTRM[0].score * 100).toFixed(1)}%, ` +
|
|
348
|
+
`quality: ${(bestPattern.metadata.quality * 100).toFixed(1)}%, ` +
|
|
349
|
+
`${bestPattern.metadata.iterations} iterations, ` +
|
|
350
|
+
`${bestPattern.metadata.converged ? 'converged' : 'partial'})`,
|
|
351
|
+
alternatives: similarTRM.slice(1).map((s) => ({
|
|
352
|
+
strategy: s.pattern.type,
|
|
353
|
+
confidence: s.pattern.metadata.quality * s.score,
|
|
354
|
+
})),
|
|
355
|
+
metadata: {
|
|
356
|
+
trmPatternId: bestPattern.id,
|
|
357
|
+
trmIterations: bestPattern.metadata.iterations,
|
|
358
|
+
trmConverged: bestPattern.metadata.converged,
|
|
359
|
+
},
|
|
360
|
+
};
|
|
361
|
+
// Track recommendation
|
|
362
|
+
this.recommendations.set(recommendation.strategy, { recommendation });
|
|
363
|
+
return recommendation;
|
|
364
|
+
}
|
|
365
|
+
// Fallback to standard patterns
|
|
366
|
+
const patterns = await this.getPatterns({
|
|
367
|
+
minConfidence: this.config.minQuality,
|
|
368
|
+
embedding: stateEmbedding,
|
|
369
|
+
limit: 5,
|
|
370
|
+
});
|
|
371
|
+
if (patterns.length === 0) {
|
|
372
|
+
return null;
|
|
373
|
+
}
|
|
374
|
+
const best = patterns[0];
|
|
375
|
+
const recommendation = {
|
|
376
|
+
strategy: best.type,
|
|
377
|
+
confidence: best.confidence,
|
|
378
|
+
reasoning: `Pattern match with ${(best.confidence * 100).toFixed(1)}% confidence`,
|
|
379
|
+
alternatives: patterns.slice(1, 4).map((p) => ({
|
|
380
|
+
strategy: p.type,
|
|
381
|
+
confidence: p.confidence,
|
|
382
|
+
})),
|
|
383
|
+
};
|
|
384
|
+
this.recommendations.set(recommendation.strategy, { recommendation });
|
|
385
|
+
return recommendation;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Record recommendation outcome
|
|
389
|
+
*/
|
|
390
|
+
async recordRecommendationOutcome(recommendation, success) {
|
|
391
|
+
this.ensureInitialized();
|
|
392
|
+
const record = this.recommendations.get(recommendation.strategy);
|
|
393
|
+
if (record) {
|
|
394
|
+
record.outcome = success;
|
|
395
|
+
// Update pattern confidence based on outcome
|
|
396
|
+
if (recommendation.metadata?.trmPatternId) {
|
|
397
|
+
await this.updatePatternConfidence(recommendation.metadata.trmPatternId, success);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Record a task execution for learning
|
|
403
|
+
*/
|
|
404
|
+
async recordExecution(event) {
|
|
405
|
+
this.ensureInitialized();
|
|
406
|
+
// Enforce max executions limit
|
|
407
|
+
if (this.executions.length >= this.config.maxExecutions) {
|
|
408
|
+
this.executions.shift();
|
|
409
|
+
}
|
|
410
|
+
this.executions.push(event);
|
|
411
|
+
// Record in SONA if available
|
|
412
|
+
if (this.sonaCoordinator && this.config.enableTrajectories) {
|
|
413
|
+
try {
|
|
414
|
+
const ruvllmModule = (0, ruvllm_loader_1.loadRuvLLM)();
|
|
415
|
+
if (ruvllmModule) {
|
|
416
|
+
const trajectory = new ruvllmModule.TrajectoryBuilder()
|
|
417
|
+
.startStep('query', JSON.stringify(event.task))
|
|
418
|
+
.endStep(JSON.stringify(event.result ?? event.error), event.success ? 0.9 : 0.1)
|
|
419
|
+
.complete(event.success ? 'success' : 'failure');
|
|
420
|
+
this.sonaCoordinator.recordTrajectory(trajectory);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
catch (error) {
|
|
424
|
+
this.logger.debug('Trajectory recording failed', { error: error.message });
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Get execution history
|
|
430
|
+
*/
|
|
431
|
+
async getExecutionHistory(limit = 100) {
|
|
432
|
+
this.ensureInitialized();
|
|
433
|
+
return this.executions.slice(-limit);
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Train the learning model with TRM optimization
|
|
437
|
+
*/
|
|
438
|
+
async train(iterations = 10) {
|
|
439
|
+
this.ensureInitialized();
|
|
440
|
+
const startTime = Date.now();
|
|
441
|
+
let improvement = 0;
|
|
442
|
+
let patternsLearned = 0;
|
|
443
|
+
// Train LoRA adapters if SONA enabled
|
|
444
|
+
if (this.loraManager && this.config.enableSONA) {
|
|
445
|
+
try {
|
|
446
|
+
const ruvllmModule = (0, ruvllm_loader_1.loadRuvLLM)();
|
|
447
|
+
if (!ruvllmModule) {
|
|
448
|
+
this.logger.warn('RuvLLM not available for training');
|
|
449
|
+
}
|
|
450
|
+
else {
|
|
451
|
+
// Create or get adapter
|
|
452
|
+
const adapter = new ruvllmModule.LoraAdapter({
|
|
453
|
+
rank: this.config.loraRank,
|
|
454
|
+
alpha: this.config.loraAlpha,
|
|
455
|
+
});
|
|
456
|
+
// Training loop
|
|
457
|
+
for (let i = 0; i < iterations; i++) {
|
|
458
|
+
// Use high-quality TRM patterns for training
|
|
459
|
+
const trainingPatterns = await this.getTRMPatterns({
|
|
460
|
+
minQuality: this.config.minQuality,
|
|
461
|
+
convergedOnly: true,
|
|
462
|
+
limit: 100,
|
|
463
|
+
});
|
|
464
|
+
for (const pattern of trainingPatterns) {
|
|
465
|
+
const loss = adapter.backward(Array.from(pattern.inputEmbedding), Array.from(pattern.outputEmbedding), this.config.learningRate);
|
|
466
|
+
improvement += 1 / (1 + loss);
|
|
467
|
+
patternsLearned++;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
this.logger.info('LoRA training complete', {
|
|
471
|
+
iterations,
|
|
472
|
+
patternsLearned,
|
|
473
|
+
improvement: improvement / iterations,
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
catch (error) {
|
|
478
|
+
this.logger.warn('LoRA training failed', { error: error.message });
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
// Update patterns based on execution outcomes
|
|
482
|
+
const recentExecutions = await this.getExecutionHistory(100);
|
|
483
|
+
const successRate = recentExecutions.filter((e) => e.success).length / Math.max(recentExecutions.length, 1);
|
|
484
|
+
this.trainingIterations += iterations;
|
|
485
|
+
this.lastTraining = new Date();
|
|
486
|
+
return {
|
|
487
|
+
iterations,
|
|
488
|
+
improvement: improvement / Math.max(iterations, 1),
|
|
489
|
+
patternsLearned,
|
|
490
|
+
duration: Date.now() - startTime,
|
|
491
|
+
metrics: {
|
|
492
|
+
accuracy: successRate,
|
|
493
|
+
loss: 1 - improvement / Math.max(iterations * patternsLearned, 1),
|
|
494
|
+
recall: patternsLearned / Math.max(this.trmPatterns.size, 1),
|
|
495
|
+
},
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Export learned patterns
|
|
500
|
+
*/
|
|
501
|
+
async exportPatterns() {
|
|
502
|
+
this.ensureInitialized();
|
|
503
|
+
return Array.from(this.patterns.values());
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Import patterns from another agent
|
|
507
|
+
*/
|
|
508
|
+
async importPatterns(patterns) {
|
|
509
|
+
this.ensureInitialized();
|
|
510
|
+
let imported = 0;
|
|
511
|
+
for (const pattern of patterns) {
|
|
512
|
+
if (!this.patterns.has(pattern.id)) {
|
|
513
|
+
await this.storePattern(pattern);
|
|
514
|
+
imported++;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
return imported;
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Get learning status
|
|
521
|
+
*/
|
|
522
|
+
getStatus() {
|
|
523
|
+
return {
|
|
524
|
+
enabled: this.config.enableSONA,
|
|
525
|
+
initialized: this.initialized,
|
|
526
|
+
patternsCount: this.patterns.size + this.trmPatterns.size,
|
|
527
|
+
executionsRecorded: this.executions.length,
|
|
528
|
+
lastTraining: this.lastTraining,
|
|
529
|
+
accuracy: this.calculateAccuracy(),
|
|
530
|
+
modelVersion: '1.0.0-trm',
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Get learning metrics
|
|
535
|
+
*/
|
|
536
|
+
async getMetrics() {
|
|
537
|
+
this.ensureInitialized();
|
|
538
|
+
const successfulExecutions = this.executions.filter((e) => e.success).length;
|
|
539
|
+
const recommendationOutcomes = Array.from(this.recommendations.values())
|
|
540
|
+
.filter((r) => r.outcome !== undefined);
|
|
541
|
+
const successfulRecommendations = recommendationOutcomes.filter((r) => r.outcome).length;
|
|
542
|
+
// Calculate average confidence
|
|
543
|
+
const allPatterns = Array.from(this.patterns.values());
|
|
544
|
+
const avgConfidence = allPatterns.length > 0
|
|
545
|
+
? allPatterns.reduce((sum, p) => sum + p.confidence, 0) / allPatterns.length
|
|
546
|
+
: 0;
|
|
547
|
+
return {
|
|
548
|
+
totalExecutions: this.executions.length,
|
|
549
|
+
successfulExecutions,
|
|
550
|
+
failedExecutions: this.executions.length - successfulExecutions,
|
|
551
|
+
patternsStored: this.patterns.size + this.trmPatterns.size,
|
|
552
|
+
recommendationsGiven: this.recommendations.size,
|
|
553
|
+
recommendationAccuracy: recommendationOutcomes.length > 0
|
|
554
|
+
? successfulRecommendations / recommendationOutcomes.length
|
|
555
|
+
: 0,
|
|
556
|
+
averageConfidence: avgConfidence,
|
|
557
|
+
trainingIterations: this.trainingIterations,
|
|
558
|
+
lastActivity: this.executions.length > 0
|
|
559
|
+
? new Date()
|
|
560
|
+
: new Date(0),
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* Get TRM-specific statistics
|
|
565
|
+
*/
|
|
566
|
+
getTRMStats() {
|
|
567
|
+
const patterns = Array.from(this.trmPatterns.values());
|
|
568
|
+
const converged = patterns.filter((p) => p.metadata.converged);
|
|
569
|
+
const highQuality = patterns.filter((p) => p.metadata.quality >= 0.75);
|
|
570
|
+
return {
|
|
571
|
+
totalPatterns: patterns.length,
|
|
572
|
+
convergedCount: converged.length,
|
|
573
|
+
highQualityCount: highQuality.length,
|
|
574
|
+
avgQuality: patterns.length > 0
|
|
575
|
+
? patterns.reduce((sum, p) => sum + p.metadata.quality, 0) / patterns.length
|
|
576
|
+
: 0,
|
|
577
|
+
avgIterations: patterns.length > 0
|
|
578
|
+
? patterns.reduce((sum, p) => sum + p.metadata.iterations, 0) / patterns.length
|
|
579
|
+
: 0,
|
|
580
|
+
loraAdaptersCount: 0, // TODO: Track LoRA adapters
|
|
581
|
+
cacheAge: 0,
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* Reset learning state
|
|
586
|
+
*/
|
|
587
|
+
async reset() {
|
|
588
|
+
this.patterns.clear();
|
|
589
|
+
this.trmPatterns.clear();
|
|
590
|
+
this.executions = [];
|
|
591
|
+
this.trajectories = [];
|
|
592
|
+
this.recommendations.clear();
|
|
593
|
+
this.trainingIterations = 0;
|
|
594
|
+
this.lastTraining = undefined;
|
|
595
|
+
this.logger.info('TRMLearningStrategy reset');
|
|
596
|
+
}
|
|
597
|
+
// === Private Helpers ===
|
|
598
|
+
ensureInitialized() {
|
|
599
|
+
if (!this.initialized) {
|
|
600
|
+
throw new Error('TRMLearningStrategy not initialized. Call initialize() first.');
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
generateEmbedding(text) {
|
|
604
|
+
// Use ruvLLM if available
|
|
605
|
+
if (this.ruvllm) {
|
|
606
|
+
try {
|
|
607
|
+
return Array.from(this.ruvllm.embed(text));
|
|
608
|
+
}
|
|
609
|
+
catch {
|
|
610
|
+
// Fallback to simple hash-based embedding
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
// Simple deterministic embedding (fallback)
|
|
614
|
+
const embedding = new Array(768).fill(0);
|
|
615
|
+
for (let i = 0; i < text.length; i++) {
|
|
616
|
+
const idx = i % 768;
|
|
617
|
+
embedding[idx] += text.charCodeAt(i) / 256;
|
|
618
|
+
}
|
|
619
|
+
// Normalize
|
|
620
|
+
const magnitude = Math.sqrt(embedding.reduce((sum, v) => sum + v * v, 0));
|
|
621
|
+
return embedding.map((v) => v / (magnitude || 1));
|
|
622
|
+
}
|
|
623
|
+
cosineSimilarity(a, b) {
|
|
624
|
+
if (a.length !== b.length)
|
|
625
|
+
return 0;
|
|
626
|
+
let dotProduct = 0;
|
|
627
|
+
let normA = 0;
|
|
628
|
+
let normB = 0;
|
|
629
|
+
for (let i = 0; i < a.length; i++) {
|
|
630
|
+
dotProduct += a[i] * b[i];
|
|
631
|
+
normA += a[i] * a[i];
|
|
632
|
+
normB += b[i] * b[i];
|
|
633
|
+
}
|
|
634
|
+
const denominator = Math.sqrt(normA) * Math.sqrt(normB);
|
|
635
|
+
return denominator === 0 ? 0 : dotProduct / denominator;
|
|
636
|
+
}
|
|
637
|
+
removeLowestQualityPattern() {
|
|
638
|
+
let lowestId = null;
|
|
639
|
+
let lowestConfidence = Infinity;
|
|
640
|
+
for (const [id, pattern] of this.patterns) {
|
|
641
|
+
if (pattern.confidence < lowestConfidence) {
|
|
642
|
+
lowestConfidence = pattern.confidence;
|
|
643
|
+
lowestId = id;
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
if (lowestId) {
|
|
647
|
+
this.patterns.delete(lowestId);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
removeLowestQualityTRMPattern() {
|
|
651
|
+
let lowestId = null;
|
|
652
|
+
let lowestQuality = Infinity;
|
|
653
|
+
for (const [id, pattern] of this.trmPatterns) {
|
|
654
|
+
if (pattern.metadata.quality < lowestQuality) {
|
|
655
|
+
lowestQuality = pattern.metadata.quality;
|
|
656
|
+
lowestId = id;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
if (lowestId) {
|
|
660
|
+
this.trmPatterns.delete(lowestId);
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
calculateAccuracy() {
|
|
664
|
+
if (this.executions.length === 0)
|
|
665
|
+
return 0;
|
|
666
|
+
return this.executions.filter((e) => e.success).length / this.executions.length;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
exports.TRMLearningStrategy = TRMLearningStrategy;
|
|
670
|
+
//# sourceMappingURL=TRMLearningStrategy.js.map
|