ruvector 0.2.12 → 0.2.14
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/bin/mcp-server.js +11 -5
- package/dist/core/core/agentdb-fast.d.ts +148 -0
- package/dist/core/core/agentdb-fast.js +301 -0
- package/dist/core/core/intelligence-engine.d.ts +257 -0
- package/dist/core/core/intelligence-engine.js +1030 -0
- package/dist/core/core/onnx-embedder.d.ts +104 -0
- package/dist/core/core/onnx-embedder.js +410 -0
- package/dist/core/core/parallel-intelligence.d.ts +108 -0
- package/dist/core/core/parallel-intelligence.js +340 -0
- package/dist/core/core/sona-wrapper.d.ts +214 -0
- package/dist/core/core/sona-wrapper.js +258 -0
- package/dist/core/intelligence-engine.d.ts.map +1 -1
- package/dist/core/intelligence-engine.js +2 -1
- package/dist/core/types.d.ts +144 -0
- package/dist/core/types.js +2 -0
- package/package.json +3 -1
- package/dist/core/onnx/loader.js +0 -348
- package/dist/core/onnx/pkg/LICENSE +0 -21
- package/dist/core/onnx/pkg/loader.js +0 -348
- package/dist/core/onnx/pkg/package.json +0 -3
- package/dist/core/onnx/pkg/ruvector_onnx_embeddings_wasm.d.ts +0 -112
- package/dist/core/onnx/pkg/ruvector_onnx_embeddings_wasm.js +0 -5
- package/dist/core/onnx/pkg/ruvector_onnx_embeddings_wasm_bg.js +0 -638
- package/dist/core/onnx/pkg/ruvector_onnx_embeddings_wasm_bg.wasm +0 -0
- package/dist/core/onnx/pkg/ruvector_onnx_embeddings_wasm_bg.wasm.d.ts +0 -29
- package/dist/core/onnx/pkg/ruvector_onnx_embeddings_wasm_cjs.js +0 -127
- package/dist/core/onnx-llm.d.ts +0 -206
- package/dist/core/onnx-llm.d.ts.map +0 -1
- package/dist/core/onnx-llm.js +0 -430
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IntelligenceEngine - Full RuVector Intelligence Stack
|
|
3
|
+
*
|
|
4
|
+
* Integrates all RuVector capabilities for self-learning hooks:
|
|
5
|
+
* - VectorDB with HNSW for semantic memory (150x faster)
|
|
6
|
+
* - SONA for continual learning (Micro-LoRA, EWC++)
|
|
7
|
+
* - FastAgentDB for episode/trajectory storage
|
|
8
|
+
* - Attention mechanisms for pattern recognition
|
|
9
|
+
* - ReasoningBank for pattern clustering
|
|
10
|
+
*
|
|
11
|
+
* Replaces the simple Q-learning approach with real ML-powered intelligence.
|
|
12
|
+
*/
|
|
13
|
+
import { EpisodeSearchResult } from './agentdb-fast';
|
|
14
|
+
import { SonaConfig, LearnedPattern } from './sona-wrapper';
|
|
15
|
+
import { ParallelConfig, BatchEpisode } from './parallel-intelligence';
|
|
16
|
+
export interface MemoryEntry {
|
|
17
|
+
id: string;
|
|
18
|
+
content: string;
|
|
19
|
+
type: string;
|
|
20
|
+
embedding: number[];
|
|
21
|
+
created: string;
|
|
22
|
+
accessed: number;
|
|
23
|
+
score?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface AgentRoute {
|
|
26
|
+
agent: string;
|
|
27
|
+
confidence: number;
|
|
28
|
+
reason: string;
|
|
29
|
+
patterns?: LearnedPattern[];
|
|
30
|
+
alternates?: Array<{
|
|
31
|
+
agent: string;
|
|
32
|
+
confidence: number;
|
|
33
|
+
}>;
|
|
34
|
+
}
|
|
35
|
+
export interface LearningStats {
|
|
36
|
+
totalMemories: number;
|
|
37
|
+
memoryDimensions: number;
|
|
38
|
+
totalEpisodes: number;
|
|
39
|
+
totalTrajectories: number;
|
|
40
|
+
avgReward: number;
|
|
41
|
+
sonaEnabled: boolean;
|
|
42
|
+
trajectoriesRecorded: number;
|
|
43
|
+
patternsLearned: number;
|
|
44
|
+
microLoraUpdates: number;
|
|
45
|
+
baseLoraUpdates: number;
|
|
46
|
+
ewcConsolidations: number;
|
|
47
|
+
routingPatterns: number;
|
|
48
|
+
errorPatterns: number;
|
|
49
|
+
coEditPatterns: number;
|
|
50
|
+
workerTriggers: number;
|
|
51
|
+
attentionEnabled: boolean;
|
|
52
|
+
onnxEnabled: boolean;
|
|
53
|
+
parallelEnabled: boolean;
|
|
54
|
+
parallelWorkers: number;
|
|
55
|
+
parallelBusy: number;
|
|
56
|
+
parallelQueued: number;
|
|
57
|
+
}
|
|
58
|
+
export interface IntelligenceConfig {
|
|
59
|
+
/** Embedding dimension for vectors (default: 256, 384 for ONNX) */
|
|
60
|
+
embeddingDim?: number;
|
|
61
|
+
/** Maximum memories to store (default: 100000) */
|
|
62
|
+
maxMemories?: number;
|
|
63
|
+
/** Maximum episodes for trajectory storage (default: 50000) */
|
|
64
|
+
maxEpisodes?: number;
|
|
65
|
+
/** Enable SONA continual learning (default: true if available) */
|
|
66
|
+
enableSona?: boolean;
|
|
67
|
+
/** Enable attention mechanisms (default: true if available) */
|
|
68
|
+
enableAttention?: boolean;
|
|
69
|
+
/** Enable ONNX semantic embeddings (default: false, opt-in for quality) */
|
|
70
|
+
enableOnnx?: boolean;
|
|
71
|
+
/** SONA configuration */
|
|
72
|
+
sonaConfig?: Partial<SonaConfig>;
|
|
73
|
+
/** Storage path for persistence */
|
|
74
|
+
storagePath?: string;
|
|
75
|
+
/** Learning rate for pattern updates (default: 0.1) */
|
|
76
|
+
learningRate?: number;
|
|
77
|
+
/**
|
|
78
|
+
* Enable parallel workers for batch operations
|
|
79
|
+
* Auto-enabled for MCP servers, disabled for CLI hooks
|
|
80
|
+
*/
|
|
81
|
+
parallelConfig?: Partial<ParallelConfig>;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Full-stack intelligence engine using all RuVector capabilities
|
|
85
|
+
*/
|
|
86
|
+
export declare class IntelligenceEngine {
|
|
87
|
+
private config;
|
|
88
|
+
private vectorDb;
|
|
89
|
+
private agentDb;
|
|
90
|
+
private sona;
|
|
91
|
+
private attention;
|
|
92
|
+
private onnxEmbedder;
|
|
93
|
+
private onnxReady;
|
|
94
|
+
private parallel;
|
|
95
|
+
private memories;
|
|
96
|
+
private routingPatterns;
|
|
97
|
+
private errorPatterns;
|
|
98
|
+
private coEditPatterns;
|
|
99
|
+
private agentMappings;
|
|
100
|
+
private workerTriggerMappings;
|
|
101
|
+
private currentTrajectoryId;
|
|
102
|
+
private sessionStart;
|
|
103
|
+
private learningEnabled;
|
|
104
|
+
private episodeBatchQueue;
|
|
105
|
+
constructor(config?: IntelligenceConfig);
|
|
106
|
+
private initOnnx;
|
|
107
|
+
private initVectorDb;
|
|
108
|
+
private initParallel;
|
|
109
|
+
/**
|
|
110
|
+
* Generate embedding using ONNX, attention, or hash (in order of preference)
|
|
111
|
+
*/
|
|
112
|
+
embed(text: string): number[];
|
|
113
|
+
/**
|
|
114
|
+
* Async embedding with ONNX support (recommended for semantic quality)
|
|
115
|
+
*/
|
|
116
|
+
embedAsync(text: string): Promise<number[]>;
|
|
117
|
+
/**
|
|
118
|
+
* Attention-based embedding using Flash or Multi-head attention
|
|
119
|
+
*/
|
|
120
|
+
private attentionEmbed;
|
|
121
|
+
/**
|
|
122
|
+
* Improved hash-based embedding with positional encoding
|
|
123
|
+
*/
|
|
124
|
+
private hashEmbed;
|
|
125
|
+
private tokenize;
|
|
126
|
+
private tokenEmbed;
|
|
127
|
+
private meanPool;
|
|
128
|
+
/**
|
|
129
|
+
* Store content in vector memory (uses ONNX if available)
|
|
130
|
+
*/
|
|
131
|
+
remember(content: string, type?: string): Promise<MemoryEntry>;
|
|
132
|
+
/**
|
|
133
|
+
* Semantic search of memories (uses ONNX if available)
|
|
134
|
+
*/
|
|
135
|
+
recall(query: string, topK?: number): Promise<MemoryEntry[]>;
|
|
136
|
+
private cosineSimilarity;
|
|
137
|
+
/**
|
|
138
|
+
* Route a task to the best agent using learned patterns
|
|
139
|
+
*/
|
|
140
|
+
route(task: string, file?: string): Promise<AgentRoute>;
|
|
141
|
+
private getExtension;
|
|
142
|
+
private getState;
|
|
143
|
+
private getAlternates;
|
|
144
|
+
/**
|
|
145
|
+
* Begin recording a trajectory (before edit/command)
|
|
146
|
+
*/
|
|
147
|
+
beginTrajectory(context: string, file?: string): void;
|
|
148
|
+
/**
|
|
149
|
+
* Add a step to the current trajectory
|
|
150
|
+
*/
|
|
151
|
+
addTrajectoryStep(activations: number[], reward: number): void;
|
|
152
|
+
/**
|
|
153
|
+
* End the current trajectory with a quality score
|
|
154
|
+
*/
|
|
155
|
+
endTrajectory(success: boolean, quality?: number): void;
|
|
156
|
+
/**
|
|
157
|
+
* Set the agent route for current trajectory
|
|
158
|
+
*/
|
|
159
|
+
setTrajectoryRoute(agent: string): void;
|
|
160
|
+
/**
|
|
161
|
+
* Record an episode for learning
|
|
162
|
+
*/
|
|
163
|
+
recordEpisode(state: string, action: string, reward: number, nextState: string, done: boolean, metadata?: Record<string, any>): Promise<void>;
|
|
164
|
+
/**
|
|
165
|
+
* Queue episode for batch processing (3-4x faster with workers)
|
|
166
|
+
*/
|
|
167
|
+
queueEpisode(episode: BatchEpisode): void;
|
|
168
|
+
/**
|
|
169
|
+
* Process queued episodes in parallel batch
|
|
170
|
+
*/
|
|
171
|
+
flushEpisodeBatch(): Promise<number>;
|
|
172
|
+
/**
|
|
173
|
+
* Learn from similar past episodes
|
|
174
|
+
*/
|
|
175
|
+
learnFromSimilar(state: string, k?: number): Promise<EpisodeSearchResult[]>;
|
|
176
|
+
/**
|
|
177
|
+
* Register worker trigger to agent mappings
|
|
178
|
+
*/
|
|
179
|
+
registerWorkerTrigger(trigger: string, priority: string, agents: string[]): void;
|
|
180
|
+
/**
|
|
181
|
+
* Get agents for a worker trigger
|
|
182
|
+
*/
|
|
183
|
+
getAgentsForTrigger(trigger: string): {
|
|
184
|
+
priority: string;
|
|
185
|
+
agents: string[];
|
|
186
|
+
} | undefined;
|
|
187
|
+
/**
|
|
188
|
+
* Route a task using worker trigger patterns first, then fall back to regular routing
|
|
189
|
+
*/
|
|
190
|
+
routeWithWorkers(task: string, file?: string): Promise<AgentRoute>;
|
|
191
|
+
/**
|
|
192
|
+
* Initialize default worker trigger mappings
|
|
193
|
+
*/
|
|
194
|
+
initDefaultWorkerMappings(): void;
|
|
195
|
+
/**
|
|
196
|
+
* Record a co-edit pattern
|
|
197
|
+
*/
|
|
198
|
+
recordCoEdit(file1: string, file2: string): void;
|
|
199
|
+
/**
|
|
200
|
+
* Get likely next files to edit
|
|
201
|
+
*/
|
|
202
|
+
getLikelyNextFiles(file: string, topK?: number): Array<{
|
|
203
|
+
file: string;
|
|
204
|
+
count: number;
|
|
205
|
+
}>;
|
|
206
|
+
/**
|
|
207
|
+
* Record an error pattern with fixes
|
|
208
|
+
*/
|
|
209
|
+
recordErrorFix(errorPattern: string, fix: string): void;
|
|
210
|
+
/**
|
|
211
|
+
* Get suggested fixes for an error
|
|
212
|
+
*/
|
|
213
|
+
getSuggestedFixes(error: string): string[];
|
|
214
|
+
/**
|
|
215
|
+
* Run background learning cycle
|
|
216
|
+
*/
|
|
217
|
+
tick(): string | null;
|
|
218
|
+
/**
|
|
219
|
+
* Force immediate learning
|
|
220
|
+
*/
|
|
221
|
+
forceLearn(): string | null;
|
|
222
|
+
/**
|
|
223
|
+
* Get comprehensive learning statistics
|
|
224
|
+
*/
|
|
225
|
+
getStats(): LearningStats;
|
|
226
|
+
/**
|
|
227
|
+
* Export all data for persistence
|
|
228
|
+
*/
|
|
229
|
+
export(): Record<string, any>;
|
|
230
|
+
/**
|
|
231
|
+
* Import data from persistence
|
|
232
|
+
*/
|
|
233
|
+
import(data: Record<string, any>, merge?: boolean): void;
|
|
234
|
+
/**
|
|
235
|
+
* Clear all data
|
|
236
|
+
*/
|
|
237
|
+
clear(): void;
|
|
238
|
+
/** Legacy: patterns object */
|
|
239
|
+
get patterns(): Record<string, Record<string, number>>;
|
|
240
|
+
/** Legacy: file_sequences array */
|
|
241
|
+
get file_sequences(): string[][];
|
|
242
|
+
/** Legacy: errors object */
|
|
243
|
+
get errors(): Record<string, string[]>;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Create a new IntelligenceEngine with default settings
|
|
247
|
+
*/
|
|
248
|
+
export declare function createIntelligenceEngine(config?: IntelligenceConfig): IntelligenceEngine;
|
|
249
|
+
/**
|
|
250
|
+
* Create a high-performance engine with all features enabled
|
|
251
|
+
*/
|
|
252
|
+
export declare function createHighPerformanceEngine(): IntelligenceEngine;
|
|
253
|
+
/**
|
|
254
|
+
* Create a lightweight engine for fast startup
|
|
255
|
+
*/
|
|
256
|
+
export declare function createLightweightEngine(): IntelligenceEngine;
|
|
257
|
+
export default IntelligenceEngine;
|