@weavelogic/knowledge-graph-agent 0.3.0 → 0.4.0
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/README.md +290 -3
- package/dist/_virtual/index10.js +2 -2
- package/dist/_virtual/index6.js +2 -2
- package/dist/_virtual/index7.js +2 -2
- package/dist/_virtual/index8.js +2 -2
- package/dist/_virtual/index9.js +2 -2
- package/dist/audit/config.d.ts +150 -0
- package/dist/audit/config.d.ts.map +1 -0
- package/dist/audit/config.js +111 -0
- package/dist/audit/config.js.map +1 -0
- package/dist/audit/index.d.ts +38 -0
- package/dist/audit/index.d.ts.map +1 -0
- package/dist/audit/services/audit-chain.d.ts +276 -0
- package/dist/audit/services/audit-chain.d.ts.map +1 -0
- package/dist/audit/services/audit-chain.js +502 -0
- package/dist/audit/services/audit-chain.js.map +1 -0
- package/dist/audit/services/index.d.ts +11 -0
- package/dist/audit/services/index.d.ts.map +1 -0
- package/dist/audit/services/syndication.d.ts +334 -0
- package/dist/audit/services/syndication.d.ts.map +1 -0
- package/dist/audit/services/syndication.js +589 -0
- package/dist/audit/services/syndication.js.map +1 -0
- package/dist/audit/types.d.ts +453 -0
- package/dist/audit/types.d.ts.map +1 -0
- package/dist/cli/commands/audit.d.ts +21 -0
- package/dist/cli/commands/audit.d.ts.map +1 -0
- package/dist/cli/commands/audit.js +621 -0
- package/dist/cli/commands/audit.js.map +1 -0
- package/dist/cli/commands/vector.d.ts +14 -0
- package/dist/cli/commands/vector.d.ts.map +1 -0
- package/dist/cli/commands/vector.js +429 -0
- package/dist/cli/commands/vector.js.map +1 -0
- package/dist/cli/commands/workflow.d.ts +12 -0
- package/dist/cli/commands/workflow.d.ts.map +1 -0
- package/dist/cli/commands/workflow.js +471 -0
- package/dist/cli/commands/workflow.js.map +1 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +26 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/database/schemas/index.d.ts +85 -0
- package/dist/database/schemas/index.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp-server/tools/audit/checkpoint.d.ts +58 -0
- package/dist/mcp-server/tools/audit/checkpoint.d.ts.map +1 -0
- package/dist/mcp-server/tools/audit/checkpoint.js +73 -0
- package/dist/mcp-server/tools/audit/checkpoint.js.map +1 -0
- package/dist/mcp-server/tools/audit/index.d.ts +53 -0
- package/dist/mcp-server/tools/audit/index.d.ts.map +1 -0
- package/dist/mcp-server/tools/audit/index.js +12 -0
- package/dist/mcp-server/tools/audit/index.js.map +1 -0
- package/dist/mcp-server/tools/audit/query.d.ts +58 -0
- package/dist/mcp-server/tools/audit/query.d.ts.map +1 -0
- package/dist/mcp-server/tools/audit/query.js +125 -0
- package/dist/mcp-server/tools/audit/query.js.map +1 -0
- package/dist/mcp-server/tools/audit/sync.d.ts +58 -0
- package/dist/mcp-server/tools/audit/sync.d.ts.map +1 -0
- package/dist/mcp-server/tools/audit/sync.js +126 -0
- package/dist/mcp-server/tools/audit/sync.js.map +1 -0
- package/dist/mcp-server/tools/index.d.ts +3 -0
- package/dist/mcp-server/tools/index.d.ts.map +1 -1
- package/dist/mcp-server/tools/registry.js +90 -0
- package/dist/mcp-server/tools/registry.js.map +1 -1
- package/dist/mcp-server/tools/vector/index.d.ts +12 -0
- package/dist/mcp-server/tools/vector/index.d.ts.map +1 -0
- package/dist/mcp-server/tools/vector/index.js +12 -0
- package/dist/mcp-server/tools/vector/index.js.map +1 -0
- package/dist/mcp-server/tools/vector/search.d.ts +41 -0
- package/dist/mcp-server/tools/vector/search.d.ts.map +1 -0
- package/dist/mcp-server/tools/vector/search.js +224 -0
- package/dist/mcp-server/tools/vector/search.js.map +1 -0
- package/dist/mcp-server/tools/vector/trajectory.d.ts +39 -0
- package/dist/mcp-server/tools/vector/trajectory.d.ts.map +1 -0
- package/dist/mcp-server/tools/vector/trajectory.js +170 -0
- package/dist/mcp-server/tools/vector/trajectory.js.map +1 -0
- package/dist/mcp-server/tools/vector/upsert.d.ts +44 -0
- package/dist/mcp-server/tools/vector/upsert.d.ts.map +1 -0
- package/dist/mcp-server/tools/vector/upsert.js +175 -0
- package/dist/mcp-server/tools/vector/upsert.js.map +1 -0
- package/dist/mcp-server/tools/workflow/index.d.ts +29 -0
- package/dist/mcp-server/tools/workflow/index.d.ts.map +1 -0
- package/dist/mcp-server/tools/workflow/index.js +12 -0
- package/dist/mcp-server/tools/workflow/index.js.map +1 -0
- package/dist/mcp-server/tools/workflow/list.d.ts +41 -0
- package/dist/mcp-server/tools/workflow/list.d.ts.map +1 -0
- package/dist/mcp-server/tools/workflow/list.js +195 -0
- package/dist/mcp-server/tools/workflow/list.js.map +1 -0
- package/dist/mcp-server/tools/workflow/start.d.ts +40 -0
- package/dist/mcp-server/tools/workflow/start.d.ts.map +1 -0
- package/dist/mcp-server/tools/workflow/start.js +165 -0
- package/dist/mcp-server/tools/workflow/start.js.map +1 -0
- package/dist/mcp-server/tools/workflow/status.d.ts +38 -0
- package/dist/mcp-server/tools/workflow/status.d.ts.map +1 -0
- package/dist/mcp-server/tools/workflow/status.js +97 -0
- package/dist/mcp-server/tools/workflow/status.js.map +1 -0
- package/dist/node_modules/ajv/dist/compile/index.js +1 -1
- package/dist/node_modules/ajv/dist/vocabularies/applicator/index.js +1 -1
- package/dist/node_modules/ajv/dist/vocabularies/core/index.js +1 -1
- package/dist/node_modules/ajv/dist/vocabularies/format/index.js +1 -1
- package/dist/node_modules/ajv/dist/vocabularies/validation/index.js +1 -1
- package/dist/vector/config.d.ts +300 -0
- package/dist/vector/config.d.ts.map +1 -0
- package/dist/vector/config.js +124 -0
- package/dist/vector/config.js.map +1 -0
- package/dist/vector/index.d.ts +50 -0
- package/dist/vector/index.d.ts.map +1 -0
- package/dist/vector/services/index.d.ts +13 -0
- package/dist/vector/services/index.d.ts.map +1 -0
- package/dist/vector/services/trajectory-tracker.d.ts +405 -0
- package/dist/vector/services/trajectory-tracker.d.ts.map +1 -0
- package/dist/vector/services/trajectory-tracker.js +445 -0
- package/dist/vector/services/trajectory-tracker.js.map +1 -0
- package/dist/vector/services/vector-store.d.ts +339 -0
- package/dist/vector/services/vector-store.d.ts.map +1 -0
- package/dist/vector/services/vector-store.js +748 -0
- package/dist/vector/services/vector-store.js.map +1 -0
- package/dist/vector/types.d.ts +677 -0
- package/dist/vector/types.d.ts.map +1 -0
- package/dist/workflow/adapters/goap-adapter.d.ts +196 -0
- package/dist/workflow/adapters/goap-adapter.d.ts.map +1 -0
- package/dist/workflow/adapters/goap-adapter.js +706 -0
- package/dist/workflow/adapters/goap-adapter.js.map +1 -0
- package/dist/workflow/adapters/index.d.ts +10 -0
- package/dist/workflow/adapters/index.d.ts.map +1 -0
- package/dist/workflow/config.d.ts +135 -0
- package/dist/workflow/config.d.ts.map +1 -0
- package/dist/workflow/config.js +92 -0
- package/dist/workflow/config.js.map +1 -0
- package/dist/workflow/handlers/index.d.ts +9 -0
- package/dist/workflow/handlers/index.d.ts.map +1 -0
- package/dist/workflow/handlers/webhook-handlers.d.ts +397 -0
- package/dist/workflow/handlers/webhook-handlers.d.ts.map +1 -0
- package/dist/workflow/handlers/webhook-handlers.js +454 -0
- package/dist/workflow/handlers/webhook-handlers.js.map +1 -0
- package/dist/workflow/index.d.ts +42 -0
- package/dist/workflow/index.d.ts.map +1 -0
- package/dist/workflow/services/index.d.ts +9 -0
- package/dist/workflow/services/index.d.ts.map +1 -0
- package/dist/workflow/services/workflow-service.d.ts +318 -0
- package/dist/workflow/services/workflow-service.d.ts.map +1 -0
- package/dist/workflow/services/workflow-service.js +577 -0
- package/dist/workflow/services/workflow-service.js.map +1 -0
- package/dist/workflow/types.d.ts +470 -0
- package/dist/workflow/types.d.ts.map +1 -0
- package/dist/workflow/workflows/realtime-collab.d.ts +245 -0
- package/dist/workflow/workflows/realtime-collab.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vector Configuration
|
|
3
|
+
*
|
|
4
|
+
* Configuration types and defaults for RuVector-compatible vector storage.
|
|
5
|
+
* Supports multiple backends (memory, postgres, standalone) with HNSW indexing.
|
|
6
|
+
*
|
|
7
|
+
* @module vector/config
|
|
8
|
+
*/
|
|
9
|
+
import type { VectorIndexConfig } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Backend storage type for vectors
|
|
12
|
+
*/
|
|
13
|
+
export type VectorBackend = 'memory' | 'postgres' | 'standalone' | 'sqlite' | 'cloud';
|
|
14
|
+
/**
|
|
15
|
+
* HNSW (Hierarchical Navigable Small World) index configuration
|
|
16
|
+
*
|
|
17
|
+
* HNSW provides fast approximate nearest neighbor search with
|
|
18
|
+
* configurable accuracy/speed tradeoffs.
|
|
19
|
+
*/
|
|
20
|
+
export interface HNSWConfig {
|
|
21
|
+
/**
|
|
22
|
+
* Maximum number of connections per layer
|
|
23
|
+
* Higher values improve recall but increase memory usage
|
|
24
|
+
* @default 16
|
|
25
|
+
*/
|
|
26
|
+
m: number;
|
|
27
|
+
/**
|
|
28
|
+
* Size of dynamic candidate list for construction
|
|
29
|
+
* Higher values improve index quality but slow down construction
|
|
30
|
+
* @default 200
|
|
31
|
+
*/
|
|
32
|
+
efConstruction: number;
|
|
33
|
+
/**
|
|
34
|
+
* Size of dynamic candidate list for search
|
|
35
|
+
* Higher values improve recall but slow down search
|
|
36
|
+
* @default 100
|
|
37
|
+
*/
|
|
38
|
+
efSearch: number;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Re-export VectorIndexConfig from types for convenience
|
|
42
|
+
*/
|
|
43
|
+
export type { VectorIndexConfig } from './types.js';
|
|
44
|
+
/**
|
|
45
|
+
* PostgreSQL backend configuration
|
|
46
|
+
*/
|
|
47
|
+
export interface PostgresBackendConfig {
|
|
48
|
+
/**
|
|
49
|
+
* PostgreSQL connection string
|
|
50
|
+
* @example 'postgres://user:pass@localhost:5432/dbname'
|
|
51
|
+
*/
|
|
52
|
+
connectionString: string;
|
|
53
|
+
/**
|
|
54
|
+
* Database schema for vector tables
|
|
55
|
+
* @default 'ruvector'
|
|
56
|
+
*/
|
|
57
|
+
schema: string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Cloud backend configuration
|
|
61
|
+
*/
|
|
62
|
+
export interface CloudBackendConfig {
|
|
63
|
+
/**
|
|
64
|
+
* Cloud vector database endpoint URL
|
|
65
|
+
*/
|
|
66
|
+
url: string;
|
|
67
|
+
/**
|
|
68
|
+
* API key for authentication
|
|
69
|
+
*/
|
|
70
|
+
apiKey?: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Standalone backend configuration
|
|
74
|
+
*/
|
|
75
|
+
export interface StandaloneBackendConfig {
|
|
76
|
+
/**
|
|
77
|
+
* Directory for vector data storage
|
|
78
|
+
* @default '.ruvector'
|
|
79
|
+
*/
|
|
80
|
+
dataDir: string;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* RuVector configuration
|
|
84
|
+
*
|
|
85
|
+
* Main configuration interface for the vector database system.
|
|
86
|
+
*/
|
|
87
|
+
export interface RuVectorConfig {
|
|
88
|
+
/**
|
|
89
|
+
* Storage backend type
|
|
90
|
+
*/
|
|
91
|
+
backend: VectorBackend;
|
|
92
|
+
/**
|
|
93
|
+
* Vector index configuration
|
|
94
|
+
*/
|
|
95
|
+
index: VectorIndexConfig;
|
|
96
|
+
/**
|
|
97
|
+
* PostgreSQL connection configuration
|
|
98
|
+
* Required when backend is 'postgres'
|
|
99
|
+
*/
|
|
100
|
+
postgres?: PostgresBackendConfig;
|
|
101
|
+
/**
|
|
102
|
+
* Cloud endpoint configuration
|
|
103
|
+
* Required when backend is 'cloud'
|
|
104
|
+
*/
|
|
105
|
+
cloud?: CloudBackendConfig;
|
|
106
|
+
/**
|
|
107
|
+
* Standalone file path configuration
|
|
108
|
+
* Required when backend is 'standalone'
|
|
109
|
+
*/
|
|
110
|
+
standalone?: StandaloneBackendConfig;
|
|
111
|
+
/**
|
|
112
|
+
* Enable self-learning SONA (Self-Optimizing Neural Architecture) engine
|
|
113
|
+
* When enabled, the system learns from agent trajectories to improve performance
|
|
114
|
+
* @default false
|
|
115
|
+
*/
|
|
116
|
+
enableSona?: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Enable trajectory tracking for agents
|
|
119
|
+
* Records agent actions for analysis and learning
|
|
120
|
+
* @default false
|
|
121
|
+
*/
|
|
122
|
+
enableTrajectoryTracking?: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Cache configuration
|
|
125
|
+
*/
|
|
126
|
+
cache?: {
|
|
127
|
+
/** Enable result caching */
|
|
128
|
+
enabled: boolean;
|
|
129
|
+
/** Maximum cache size in entries */
|
|
130
|
+
maxSize: number;
|
|
131
|
+
/** Cache TTL in seconds */
|
|
132
|
+
ttlSeconds: number;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Performance tuning
|
|
136
|
+
*/
|
|
137
|
+
performance?: {
|
|
138
|
+
/** Batch size for bulk operations */
|
|
139
|
+
batchSize: number;
|
|
140
|
+
/** Enable parallel processing */
|
|
141
|
+
parallelProcessing: boolean;
|
|
142
|
+
/** Maximum concurrent operations */
|
|
143
|
+
maxConcurrency: number;
|
|
144
|
+
/** Memory limit in MB for index */
|
|
145
|
+
memoryLimitMb?: number;
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Hybrid search configuration
|
|
149
|
+
*/
|
|
150
|
+
hybrid?: {
|
|
151
|
+
/** Enable hybrid search */
|
|
152
|
+
enabled: boolean;
|
|
153
|
+
/** Default vector weight (0-1) */
|
|
154
|
+
defaultVectorWeight: number;
|
|
155
|
+
/** Graph database connection (for Cypher queries) */
|
|
156
|
+
graphConnection?: {
|
|
157
|
+
type: 'neo4j' | 'memgraph' | 'sqlite';
|
|
158
|
+
uri?: string;
|
|
159
|
+
database?: string;
|
|
160
|
+
auth?: {
|
|
161
|
+
user: string;
|
|
162
|
+
password: string;
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Namespace configuration for multi-tenant support
|
|
168
|
+
*/
|
|
169
|
+
namespace?: {
|
|
170
|
+
/** Default namespace */
|
|
171
|
+
defaultNamespace: string;
|
|
172
|
+
/** Namespace isolation level */
|
|
173
|
+
isolation: 'soft' | 'hard';
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Default HNSW configuration
|
|
178
|
+
* Balanced settings for most use cases
|
|
179
|
+
*/
|
|
180
|
+
export declare const DEFAULT_HNSW_CONFIG: HNSWConfig;
|
|
181
|
+
/**
|
|
182
|
+
* Default vector index configuration
|
|
183
|
+
* Optimized for OpenAI/Claude embeddings (1536 dimensions)
|
|
184
|
+
*/
|
|
185
|
+
export declare const DEFAULT_INDEX_CONFIG: VectorIndexConfig;
|
|
186
|
+
/**
|
|
187
|
+
* Default cache configuration
|
|
188
|
+
*/
|
|
189
|
+
export declare const DEFAULT_CACHE_CONFIG: {
|
|
190
|
+
readonly enabled: true;
|
|
191
|
+
readonly maxSize: 1000;
|
|
192
|
+
readonly ttlSeconds: 300;
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* Default performance configuration
|
|
196
|
+
*/
|
|
197
|
+
export declare const DEFAULT_PERFORMANCE_CONFIG: {
|
|
198
|
+
readonly batchSize: 100;
|
|
199
|
+
readonly parallelProcessing: true;
|
|
200
|
+
readonly maxConcurrency: 4;
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* Create RuVector configuration from environment variables
|
|
204
|
+
*
|
|
205
|
+
* Reads configuration from the following environment variables:
|
|
206
|
+
* - RUVECTOR_BACKEND: Storage backend type (default: 'memory')
|
|
207
|
+
* - RUVECTOR_DIMENSIONS: Vector dimensions (default: 384)
|
|
208
|
+
* - RUVECTOR_ENABLE_SONA: Enable SONA learning (default: false)
|
|
209
|
+
* - RUVECTOR_ENABLE_TRAJECTORY: Enable trajectory tracking (default: false)
|
|
210
|
+
* - DATABASE_URL: PostgreSQL connection string (for postgres backend)
|
|
211
|
+
* - RUVECTOR_SCHEMA: PostgreSQL schema (default: 'ruvector')
|
|
212
|
+
* - RUVECTOR_CLOUD_URL: Cloud endpoint URL (for cloud backend)
|
|
213
|
+
* - RUVECTOR_API_KEY: Cloud API key (for cloud backend)
|
|
214
|
+
* - RUVECTOR_DATA_DIR: Data directory (for standalone backend)
|
|
215
|
+
*
|
|
216
|
+
* @returns RuVectorConfig configured from environment
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* ```typescript
|
|
220
|
+
* // Set environment variables
|
|
221
|
+
* process.env.RUVECTOR_BACKEND = 'postgres';
|
|
222
|
+
* process.env.DATABASE_URL = 'postgres://localhost:5432/mydb';
|
|
223
|
+
*
|
|
224
|
+
* // Create configuration
|
|
225
|
+
* const config = createRuVectorConfig();
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
export declare function createRuVectorConfig(): RuVectorConfig;
|
|
229
|
+
/**
|
|
230
|
+
* Validation result for RuVector configuration
|
|
231
|
+
*/
|
|
232
|
+
export interface ConfigValidationResult {
|
|
233
|
+
/**
|
|
234
|
+
* Whether the configuration is valid
|
|
235
|
+
*/
|
|
236
|
+
valid: boolean;
|
|
237
|
+
/**
|
|
238
|
+
* List of validation errors (empty if valid)
|
|
239
|
+
*/
|
|
240
|
+
errors: string[];
|
|
241
|
+
/**
|
|
242
|
+
* List of validation warnings
|
|
243
|
+
*/
|
|
244
|
+
warnings: string[];
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Legacy alias for backwards compatibility
|
|
248
|
+
*/
|
|
249
|
+
export type ValidationResult = ConfigValidationResult;
|
|
250
|
+
/**
|
|
251
|
+
* Validate RuVector configuration
|
|
252
|
+
*
|
|
253
|
+
* Checks that all required fields are present and valid based on
|
|
254
|
+
* the selected backend type.
|
|
255
|
+
*
|
|
256
|
+
* @param config - Configuration to validate
|
|
257
|
+
* @returns Validation result with errors if invalid
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* ```typescript
|
|
261
|
+
* const config = createRuVectorConfig();
|
|
262
|
+
* const result = validateRuVectorConfig(config);
|
|
263
|
+
*
|
|
264
|
+
* if (!result.valid) {
|
|
265
|
+
* console.error('Configuration errors:', result.errors);
|
|
266
|
+
* process.exit(1);
|
|
267
|
+
* }
|
|
268
|
+
* ```
|
|
269
|
+
*/
|
|
270
|
+
export declare function validateRuVectorConfig(config: RuVectorConfig): ConfigValidationResult;
|
|
271
|
+
/**
|
|
272
|
+
* Default configuration instance
|
|
273
|
+
* Created from environment variables at module load time
|
|
274
|
+
*/
|
|
275
|
+
export declare const defaultConfig: RuVectorConfig;
|
|
276
|
+
/**
|
|
277
|
+
* Create configuration for high-performance scenarios
|
|
278
|
+
*
|
|
279
|
+
* Optimized for large-scale deployments with many vectors
|
|
280
|
+
*/
|
|
281
|
+
export declare function createHighPerformanceConfig(dimensions?: number): RuVectorConfig;
|
|
282
|
+
/**
|
|
283
|
+
* Create configuration for memory-constrained environments
|
|
284
|
+
*
|
|
285
|
+
* Optimized for minimal memory usage
|
|
286
|
+
*/
|
|
287
|
+
export declare function createLowMemoryConfig(dimensions?: number): RuVectorConfig;
|
|
288
|
+
/**
|
|
289
|
+
* Create configuration for hybrid search with graph integration
|
|
290
|
+
*/
|
|
291
|
+
export declare function createHybridSearchConfig(dimensions?: number, graphType?: 'neo4j' | 'memgraph' | 'sqlite'): RuVectorConfig;
|
|
292
|
+
/**
|
|
293
|
+
* Get recommended configuration based on vector count
|
|
294
|
+
*
|
|
295
|
+
* @param estimatedVectorCount - Estimated number of vectors to store
|
|
296
|
+
* @param dimensions - Vector dimensions
|
|
297
|
+
* @returns Recommended configuration
|
|
298
|
+
*/
|
|
299
|
+
export declare function getRecommendedConfig(estimatedVectorCount: number, dimensions?: number): RuVectorConfig;
|
|
300
|
+
//# sourceM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AEG;AACH,eAAO,MAAM,0BAA0B;;;;CAI7B,CAAC;AAEX;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,oBAAoB,IAAI,cAAc,CA0CrD;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC;IAEf;;OAEG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;IAEjB;;OAEG;IACH,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,sBAAsB,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,cAAc,GAAG,sBAAsB,CAuFrF;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa,gBAAyB,CAAC;AAEpD;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,UAAU,GAAE,MAAa,GACxB,cAAc,CAyBhB;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,UAAU,GAAE,MAAa,GACxB,cAAc,CA0BhB;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,GAAE,MAAa,EACzB,SAAS,GAAE,OAAO,GAAG,UAAU,GAAG,QAAmB,GACpD,cAAc,CAkBhB;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,oBAAoB,EAAE,MAAM,EAC5B,UAAU,GAAE,MAAa,GACxB,cAAc,CAchB"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
const DEFAULT_HNSW_CONFIG = {
|
|
2
|
+
m: 16,
|
|
3
|
+
efConstruction: 200,
|
|
4
|
+
efSearch: 100
|
|
5
|
+
};
|
|
6
|
+
const DEFAULT_INDEX_CONFIG = {
|
|
7
|
+
dimensions: 1536,
|
|
8
|
+
distanceMetric: "cosine",
|
|
9
|
+
indexType: "hnsw",
|
|
10
|
+
hnswConfig: DEFAULT_HNSW_CONFIG
|
|
11
|
+
};
|
|
12
|
+
function createRuVectorConfig() {
|
|
13
|
+
const backend = process.env.RUVECTOR_BACKEND || "memory";
|
|
14
|
+
const dimensions = parseInt(process.env.RUVECTOR_DIMENSIONS || "384", 10);
|
|
15
|
+
const baseConfig = {
|
|
16
|
+
backend,
|
|
17
|
+
index: {
|
|
18
|
+
...DEFAULT_INDEX_CONFIG,
|
|
19
|
+
dimensions
|
|
20
|
+
},
|
|
21
|
+
enableSona: process.env.RUVECTOR_ENABLE_SONA === "true",
|
|
22
|
+
enableTrajectoryTracking: process.env.RUVECTOR_ENABLE_TRAJECTORY === "true"
|
|
23
|
+
};
|
|
24
|
+
switch (backend) {
|
|
25
|
+
case "postgres":
|
|
26
|
+
return {
|
|
27
|
+
...baseConfig,
|
|
28
|
+
postgres: {
|
|
29
|
+
connectionString: process.env.DATABASE_URL || "postgres://localhost:5432/kg_agent",
|
|
30
|
+
schema: process.env.RUVECTOR_SCHEMA || "ruvector"
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
case "cloud":
|
|
34
|
+
return {
|
|
35
|
+
...baseConfig,
|
|
36
|
+
cloud: {
|
|
37
|
+
url: process.env.RUVECTOR_CLOUD_URL || "",
|
|
38
|
+
apiKey: process.env.RUVECTOR_API_KEY
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
case "standalone":
|
|
42
|
+
return {
|
|
43
|
+
...baseConfig,
|
|
44
|
+
standalone: {
|
|
45
|
+
dataDir: process.env.RUVECTOR_DATA_DIR || ".ruvector"
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
default:
|
|
49
|
+
return baseConfig;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function validateRuVectorConfig(config) {
|
|
53
|
+
const errors = [];
|
|
54
|
+
const warnings = [];
|
|
55
|
+
if (config.index.dimensions < 1) {
|
|
56
|
+
errors.push("Dimensions must be at least 1");
|
|
57
|
+
}
|
|
58
|
+
if (config.index.dimensions > 4096) {
|
|
59
|
+
warnings.push("Dimensions > 4096 may impact performance");
|
|
60
|
+
}
|
|
61
|
+
if (!Number.isInteger(config.index.dimensions)) {
|
|
62
|
+
errors.push("Vector dimensions must be an integer");
|
|
63
|
+
}
|
|
64
|
+
if (config.backend === "postgres" && !config.postgres?.connectionString) {
|
|
65
|
+
errors.push("PostgreSQL connection string required for postgres backend");
|
|
66
|
+
}
|
|
67
|
+
if (config.backend === "cloud" && !config.cloud?.url) {
|
|
68
|
+
errors.push("Cloud URL required for cloud backend");
|
|
69
|
+
}
|
|
70
|
+
if (config.backend === "standalone" && !config.standalone?.dataDir) {
|
|
71
|
+
errors.push("Data directory required for standalone backend");
|
|
72
|
+
}
|
|
73
|
+
if (config.index.indexType === "hnsw" && config.index.hnswConfig) {
|
|
74
|
+
const { m, efConstruction, efSearch } = config.index.hnswConfig;
|
|
75
|
+
if (m < 2 || m > 100) {
|
|
76
|
+
errors.push("HNSW m must be between 2 and 100");
|
|
77
|
+
}
|
|
78
|
+
if (efConstruction < m) {
|
|
79
|
+
warnings.push("efConstruction should be >= m for good index quality");
|
|
80
|
+
}
|
|
81
|
+
if (efSearch < 10) {
|
|
82
|
+
warnings.push("efSearch < 10 may result in poor recall");
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (config.cache?.enabled) {
|
|
86
|
+
if (config.cache.maxSize < 1) {
|
|
87
|
+
errors.push("Cache maxSize must be at least 1");
|
|
88
|
+
}
|
|
89
|
+
if (config.cache.ttlSeconds < 1) {
|
|
90
|
+
errors.push("Cache TTL must be at least 1 second");
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (config.performance) {
|
|
94
|
+
if (config.performance.batchSize < 1) {
|
|
95
|
+
errors.push("Batch size must be at least 1");
|
|
96
|
+
}
|
|
97
|
+
if (config.performance.maxConcurrency < 1) {
|
|
98
|
+
errors.push("Max concurrency must be at least 1");
|
|
99
|
+
}
|
|
100
|
+
if (config.performance.memoryLimitMb && config.performance.memoryLimitMb < 64) {
|
|
101
|
+
warnings.push("Memory limit < 64MB may cause issues");
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (config.hybrid?.enabled && !config.hybrid.graphConnection) {
|
|
105
|
+
warnings.push("Hybrid search enabled but no graph connection configured");
|
|
106
|
+
}
|
|
107
|
+
const validMetrics = ["cosine", "euclidean", "dotProduct", "manhattan"];
|
|
108
|
+
if (!validMetrics.includes(config.index.distanceMetric)) {
|
|
109
|
+
errors.push(`Invalid distance metric: ${config.index.distanceMetric}`);
|
|
110
|
+
}
|
|
111
|
+
const validIndexTypes = ["hnsw", "flat", "ivf", "pq"];
|
|
112
|
+
if (!validIndexTypes.includes(config.index.indexType)) {
|
|
113
|
+
errors.push(`Invalid index type: ${config.index.indexType}`);
|
|
114
|
+
}
|
|
115
|
+
return { valid: errors.length === 0, errors, warnings };
|
|
116
|
+
}
|
|
117
|
+
createRuVectorConfig();
|
|
118
|
+
export {
|
|
119
|
+
DEFAULT_HNSW_CONFIG,
|
|
120
|
+
DEFAULT_INDEX_CONFIG,
|
|
121
|
+
createRuVectorConfig,
|
|
122
|
+
validateRuVectorConfig
|
|
123
|
+
};
|
|
124
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../src/vector/config.ts"],"sourcesContent":["/**\n * Vector Configuration\n *\n * Configuration types and defaults for RuVector-compatible vector storage.\n * Supports multiple backends (memory, postgres, standalone) with HNSW indexing.\n *\n * @module vector/config\n */\n\nimport type { DistanceMetric, IndexType, VectorIndexConfig } from './types.js';\n\n/**\n * Backend storage type for vectors\n */\nexport type VectorBackend = 'memory' | 'postgres' | 'standalone' | 'sqlite' | 'cloud';\n\n/**\n * HNSW (Hierarchical Navigable Small World) index configuration\n *\n * HNSW provides fast approximate nearest neighbor search with\n * configurable accuracy/speed tradeoffs.\n */\nexport interface HNSWConfig {\n /**\n * Maximum number of connections per layer\n * Higher values improve recall but increase memory usage\n * @default 16\n */\n m: number;\n\n /**\n * Size of dynamic candidate list for construction\n * Higher values improve index quality but slow down construction\n * @default 200\n */\n efConstruction: number;\n\n /**\n * Size of dynamic candidate list for search\n * Higher values improve recall but slow down search\n * @default 100\n */\n efSearch: number;\n}\n\n/**\n * Re-export VectorIndexConfig from types for convenience\n */\nexport type { VectorIndexConfig } from './types.js';\n\n/**\n * PostgreSQL backend configuration\n */\nexport interface PostgresBackendConfig {\n /**\n * PostgreSQL connection string\n * @example 'postgres://user:pass@localhost:5432/dbname'\n */\n connectionString: string;\n\n /**\n * Database schema for vector tables\n * @default 'ruvector'\n */\n schema: string;\n}\n\n/**\n * Cloud backend configuration\n */\nexport interface CloudBackendConfig {\n /**\n * Cloud vector database endpoint URL\n */\n url: string;\n\n /**\n * API key for authentication\n */\n apiKey?: string;\n}\n\n/**\n * Standalone backend configuration\n */\nexport interface StandaloneBackendConfig {\n /**\n * Directory for vector data storage\n * @default '.ruvector'\n */\n dataDir: string;\n}\n\n/**\n * RuVector configuration\n *\n * Main configuration interface for the vector database system.\n */\nexport interface RuVectorConfig {\n /**\n * Storage backend type\n */\n backend: VectorBackend;\n\n /**\n * Vector index configuration\n */\n index: VectorIndexConfig;\n\n /**\n * PostgreSQL connection configuration\n * Required when backend is 'postgres'\n */\n postgres?: PostgresBackendConfig;\n\n /**\n * Cloud endpoint configuration\n * Required when backend is 'cloud'\n */\n cloud?: CloudBackendConfig;\n\n /**\n * Standalone file path configuration\n * Required when backend is 'standalone'\n */\n standalone?: StandaloneBackendConfig;\n\n /**\n * Enable self-learning SONA (Self-Optimizing Neural Architecture) engine\n * When enabled, the system learns from agent trajectories to improve performance\n * @default false\n */\n enableSona?: boolean;\n\n /**\n * Enable trajectory tracking for agents\n * Records agent actions for analysis and learning\n * @default false\n */\n enableTrajectoryTracking?: boolean;\n\n /**\n * Cache configuration\n */\n cache?: {\n /** Enable result caching */\n enabled: boolean;\n /** Maximum cache size in entries */\n maxSize: number;\n /** Cache TTL in seconds */\n ttlSeconds: number;\n };\n\n /**\n * Performance tuning\n */\n performance?: {\n /** Batch size for bulk operations */\n batchSize: number;\n /** Enable parallel processing */\n parallelProcessing: boolean;\n /** Maximum concurrent operations */\n maxConcurrency: number;\n /** Memory limit in MB for index */\n memoryLimitMb?: number;\n };\n\n /**\n * Hybrid search configuration\n */\n hybrid?: {\n /** Enable hybrid search */\n enabled: boolean;\n /** Default vector weight (0-1) */\n defaultVectorWeight: number;\n /** Graph database connection (for Cypher queries) */\n graphConnection?: {\n type: 'neo4j' | 'memgraph' | 'sqlite';\n uri?: string;\n database?: string;\n auth?: {\n user: string;\n password: string;\n };\n };\n };\n\n /**\n * Namespace configuration for multi-tenant support\n */\n namespace?: {\n /** Default namespace */\n defaultNamespace: string;\n /** Namespace isolation level */\n isolation: 'soft' | 'hard';\n };\n}\n\n/**\n * Default HNSW configuration\n * Balanced settings for most use cases\n */\nexport const DEFAULT_HNSW_CONFIG: HNSWConfig = {\n m: 16,\n efConstruction: 200,\n efSearch: 100,\n};\n\n/**\n * Default vector index configuration\n * Optimized for OpenAI/Claude embeddings (1536 dimensions)\n */\nexport const DEFAULT_INDEX_CONFIG: VectorIndexConfig = {\n dimensions: 1536,\n distanceMetric: 'cosine',\n indexType: 'hnsw',\n hnswConfig: DEFAULT_HNSW_CONFIG,\n};\n\n/**\n * Default cache configuration\n */\nexport const DEFAULT_CACHE_CONFIG = {\n enabled: true,\n maxSize: 1000,\n ttlSeconds: 300, // 5 minutes\n} as const;\n\n/**\n * Default performance configuration\n */\nexport const DEFAULT_PERFORMANCE_CONFIG = {\n batchSize: 100,\n parallelProcessing: true,\n maxConcurrency: 4,\n} as const;\n\n/**\n * Create RuVector configuration from environment variables\n *\n * Reads configuration from the following environment variables:\n * - RUVECTOR_BACKEND: Storage backend type (default: 'memory')\n * - RUVECTOR_DIMENSIONS: Vector dimensions (default: 384)\n * - RUVECTOR_ENABLE_SONA: Enable SONA learning (default: false)\n * - RUVECTOR_ENABLE_TRAJECTORY: Enable trajectory tracking (default: false)\n * - DATABASE_URL: PostgreSQL connection string (for postgres backend)\n * - RUVECTOR_SCHEMA: PostgreSQL schema (default: 'ruvector')\n * - RUVECTOR_CLOUD_URL: Cloud endpoint URL (for cloud backend)\n * - RUVECTOR_API_KEY: Cloud API key (for cloud backend)\n * - RUVECTOR_DATA_DIR: Data directory (for standalone backend)\n *\n * @returns RuVectorConfig configured from environment\n *\n * @example\n * ```typescript\n * // Set environment variables\n * process.env.RUVECTOR_BACKEND = 'postgres';\n * process.env.DATABASE_URL = 'postgres://localhost:5432/mydb';\n *\n * // Create configuration\n * const config = createRuVectorConfig();\n * ```\n */\nexport function createRuVectorConfig(): RuVectorConfig {\n const backend = (process.env.RUVECTOR_BACKEND || 'memory') as VectorBackend;\n const dimensions = parseInt(process.env.RUVECTOR_DIMENSIONS || '384', 10);\n\n const baseConfig: RuVectorConfig = {\n backend,\n index: {\n ...DEFAULT_INDEX_CONFIG,\n dimensions,\n },\n enableSona: process.env.RUVECTOR_ENABLE_SONA === 'true',\n enableTrajectoryTracking: process.env.RUVECTOR_ENABLE_TRAJECTORY === 'true',\n };\n\n switch (backend) {\n case 'postgres':\n return {\n ...baseConfig,\n postgres: {\n connectionString:\n process.env.DATABASE_URL || 'postgres://localhost:5432/kg_agent',\n schema: process.env.RUVECTOR_SCHEMA || 'ruvector',\n },\n };\n case 'cloud':\n return {\n ...baseConfig,\n cloud: {\n url: process.env.RUVECTOR_CLOUD_URL || '',\n apiKey: process.env.RUVECTOR_API_KEY,\n },\n };\n case 'standalone':\n return {\n ...baseConfig,\n standalone: {\n dataDir: process.env.RUVECTOR_DATA_DIR || '.ruvector',\n },\n };\n default:\n return baseConfig;\n }\n}\n\n/**\n * Validation result for RuVector configuration\n */\nexport interface ConfigValidationResult {\n /**\n * Whether the configuration is valid\n */\n valid: boolean;\n\n /**\n * List of validation errors (empty if valid)\n */\n errors: string[];\n\n /**\n * List of validation warnings\n */\n warnings: string[];\n}\n\n/**\n * Legacy alias for backwards compatibility\n */\nexport type ValidationResult = ConfigValidationResult;\n\n/**\n * Validate RuVector configuration\n *\n * Checks that all required fields are present and valid based on\n * the selected backend type.\n *\n * @param config - Configuration to validate\n * @returns Validation result with errors if invalid\n *\n * @example\n * ```typescript\n * const config = createRuVectorConfig();\n * const result = validateRuVectorConfig(config);\n *\n * if (!result.valid) {\n * console.error('Configuration errors:', result.errors);\n * process.exit(1);\n * }\n * ```\n */\nexport function validateRuVectorConfig(config: RuVectorConfig): ConfigValidationResult {\n const errors: string[] = [];\n const warnings: string[] = [];\n\n // Validate dimensions\n if (config.index.dimensions < 1) {\n errors.push('Dimensions must be at least 1');\n }\n if (config.index.dimensions > 4096) {\n warnings.push('Dimensions > 4096 may impact performance');\n }\n\n if (!Number.isInteger(config.index.dimensions)) {\n errors.push('Vector dimensions must be an integer');\n }\n\n // Validate backend-specific configuration\n if (config.backend === 'postgres' && !config.postgres?.connectionString) {\n errors.push('PostgreSQL connection string required for postgres backend');\n }\n\n if (config.backend === 'cloud' && !config.cloud?.url) {\n errors.push('Cloud URL required for cloud backend');\n }\n\n if (config.backend === 'standalone' && !config.standalone?.dataDir) {\n errors.push('Data directory required for standalone backend');\n }\n\n // Validate HNSW configuration\n if (config.index.indexType === 'hnsw' && config.index.hnswConfig) {\n const { m, efConstruction, efSearch } = config.index.hnswConfig;\n\n if (m < 2 || m > 100) {\n errors.push('HNSW m must be between 2 and 100');\n }\n\n if (efConstruction < m) {\n warnings.push('efConstruction should be >= m for good index quality');\n }\n\n if (efSearch < 10) {\n warnings.push('efSearch < 10 may result in poor recall');\n }\n }\n\n // Validate cache config\n if (config.cache?.enabled) {\n if (config.cache.maxSize < 1) {\n errors.push('Cache maxSize must be at least 1');\n }\n if (config.cache.ttlSeconds < 1) {\n errors.push('Cache TTL must be at least 1 second');\n }\n }\n\n // Validate performance config\n if (config.performance) {\n if (config.performance.batchSize < 1) {\n errors.push('Batch size must be at least 1');\n }\n if (config.performance.maxConcurrency < 1) {\n errors.push('Max concurrency must be at least 1');\n }\n if (config.performance.memoryLimitMb && config.performance.memoryLimitMb < 64) {\n warnings.push('Memory limit < 64MB may cause issues');\n }\n }\n\n // Validate hybrid config\n if (config.hybrid?.enabled && !config.hybrid.graphConnection) {\n warnings.push('Hybrid search enabled but no graph connection configured');\n }\n\n // Validate distance metric\n const validMetrics: DistanceMetric[] = ['cosine', 'euclidean', 'dotProduct', 'manhattan'];\n if (!validMetrics.includes(config.index.distanceMetric)) {\n errors.push(`Invalid distance metric: ${config.index.distanceMetric}`);\n }\n\n // Validate index type\n const validIndexTypes = ['hnsw', 'flat', 'ivf', 'pq'];\n if (!validIndexTypes.includes(config.index.indexType)) {\n errors.push(`Invalid index type: ${config.index.indexType}`);\n }\n\n return { valid: errors.length === 0, errors, warnings };\n}\n\n/**\n * Default configuration instance\n * Created from environment variables at module load time\n */\nexport const defaultConfig = createRuVectorConfig();\n\n/**\n * Create configuration for high-performance scenarios\n *\n * Optimized for large-scale deployments with many vectors\n */\nexport function createHighPerformanceConfig(\n dimensions: number = 1536\n): RuVectorConfig {\n return {\n ...createRuVectorConfig(),\n backend: 'memory',\n index: {\n dimensions,\n indexType: 'hnsw',\n distanceMetric: 'cosine',\n hnswConfig: {\n m: 32, // More connections for better recall\n efConstruction: 400, // Higher quality index\n efSearch: 200, // Better search accuracy\n },\n },\n cache: {\n enabled: true,\n maxSize: 10000,\n ttlSeconds: 600,\n },\n performance: {\n batchSize: 500,\n parallelProcessing: true,\n maxConcurrency: 8,\n },\n };\n}\n\n/**\n * Create configuration for memory-constrained environments\n *\n * Optimized for minimal memory usage\n */\nexport function createLowMemoryConfig(\n dimensions: number = 1536\n): RuVectorConfig {\n return {\n ...createRuVectorConfig(),\n backend: 'memory',\n index: {\n dimensions,\n indexType: 'hnsw',\n distanceMetric: 'cosine',\n hnswConfig: {\n m: 8, // Fewer connections\n efConstruction: 100, // Faster construction\n efSearch: 50, // Faster search\n },\n },\n cache: {\n enabled: false,\n maxSize: 100,\n ttlSeconds: 60,\n },\n performance: {\n batchSize: 50,\n parallelProcessing: false,\n maxConcurrency: 2,\n memoryLimitMb: 256,\n },\n };\n}\n\n/**\n * Create configuration for hybrid search with graph integration\n */\nexport function createHybridSearchConfig(\n dimensions: number = 1536,\n graphType: 'neo4j' | 'memgraph' | 'sqlite' = 'sqlite'\n): RuVectorConfig {\n return {\n ...createRuVectorConfig(),\n backend: 'memory',\n index: {\n dimensions,\n indexType: 'hnsw',\n distanceMetric: 'cosine',\n hnswConfig: DEFAULT_HNSW_CONFIG,\n },\n hybrid: {\n enabled: true,\n defaultVectorWeight: 0.7,\n graphConnection: {\n type: graphType,\n },\n },\n };\n}\n\n/**\n * Get recommended configuration based on vector count\n *\n * @param estimatedVectorCount - Estimated number of vectors to store\n * @param dimensions - Vector dimensions\n * @returns Recommended configuration\n */\nexport function getRecommendedConfig(\n estimatedVectorCount: number,\n dimensions: number = 1536\n): RuVectorConfig {\n if (estimatedVectorCount < 1000) {\n // Small scale - flat index is fine\n return createLowMemoryConfig(dimensions);\n } else if (estimatedVectorCount < 100000) {\n // Medium scale - standard HNSW\n return {\n ...createRuVectorConfig(),\n index: { ...DEFAULT_INDEX_CONFIG, dimensions },\n };\n } else {\n // Large scale - optimized HNSW\n return createHighPerformanceConfig(dimensions);\n }\n}\n"],"names":[],"mappings":"AA0MO,MAAM,sBAAkC;AAAA,EAC7C,GAAG;AAAA,EACH,gBAAgB;AAAA,EAChB,UAAU;AACZ;AAMO,MAAM,uBAA0C;AAAA,EACrD,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,WAAW;AAAA,EACX,YAAY;AACd;AA8CO,SAAS,uBAAuC;AACrD,QAAM,UAAW,QAAQ,IAAI,oBAAoB;AACjD,QAAM,aAAa,SAAS,QAAQ,IAAI,uBAAuB,OAAO,EAAE;AAExE,QAAM,aAA6B;AAAA,IACjC;AAAA,IACA,OAAO;AAAA,MACL,GAAG;AAAA,MACH;AAAA,IAAA;AAAA,IAEF,YAAY,QAAQ,IAAI,yBAAyB;AAAA,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A;AAC/C;AAM6B,qBAAA;"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vector Module
|
|
3
|
+
*
|
|
4
|
+
* Exports all vector-related functionality for the knowledge-graph-agent.
|
|
5
|
+
* This module provides configuration, types, services, and utilities for working
|
|
6
|
+
* with vector embeddings, similarity search, and agent trajectory tracking.
|
|
7
|
+
*
|
|
8
|
+
* @module vector
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import {
|
|
13
|
+
* createRuVectorConfig,
|
|
14
|
+
* validateRuVectorConfig,
|
|
15
|
+
* createVectorStore,
|
|
16
|
+
* createTrajectoryTracker,
|
|
17
|
+
* type VectorEntry,
|
|
18
|
+
* type SearchResult,
|
|
19
|
+
* type HybridSearchQuery,
|
|
20
|
+
* } from './vector/index.js';
|
|
21
|
+
*
|
|
22
|
+
* // Create and validate configuration
|
|
23
|
+
* const config = createRuVectorConfig();
|
|
24
|
+
* const validation = validateRuVectorConfig(config);
|
|
25
|
+
*
|
|
26
|
+
* if (!validation.valid) {
|
|
27
|
+
* throw new Error(`Invalid config: ${validation.errors.join(', ')}`);
|
|
28
|
+
* }
|
|
29
|
+
*
|
|
30
|
+
* // Create a trajectory tracker for agent operations
|
|
31
|
+
* const tracker = createTrajectoryTracker({
|
|
32
|
+
* maxTrajectories: 1000,
|
|
33
|
+
* enableAutoLearning: true,
|
|
34
|
+
* });
|
|
35
|
+
*
|
|
36
|
+
* // Track agent operations
|
|
37
|
+
* const trajectoryId = tracker.startTrajectory('agent-1');
|
|
38
|
+
* tracker.addStep(trajectoryId, {
|
|
39
|
+
* action: 'search',
|
|
40
|
+
* state: { query: 'example' },
|
|
41
|
+
* outcome: 'success',
|
|
42
|
+
* duration: 100
|
|
43
|
+
* });
|
|
44
|
+
* tracker.finalizeTrajectory(trajectoryId, { success: true });
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export { createRuVectorConfig, createHighPerformanceConfig, createLowMemoryConfig, createHybridSearchConfig, validateRuVectorConfig, getRecommendedConfig, DEFAULT_HNSW_CONFIG, DEFAULT_INDEX_CONFIG, DEFAULT_CACHE_CONFIG, DEFAULT_PERFORMANCE_CONFIG, defaultConfig, type RuVectorConfig, type VectorBackend, type ConfigValidationResult, type ValidationResult, type HNSWConfig, type PostgresBackendConfig, type CloudBackendConfig, type StandaloneBackendConfig, } from './config.js';
|
|
48
|
+
export type { DistanceMetric, IndexType, SearchSource, VectorEntry, SearchResult, HybridSearchQuery, HybridSearchResult, BatchInsertEntry, BatchInsertOperation, BatchInsertResult, VectorIndexStats, VectorSearchOptions, VectorIndexConfig, VectorStoreEvent, VectorStoreEventListener, IVectorStore, TrajectoryStep, AgentTrajectory, SonaLearningRecord, GraphNode, GraphEdge, CypherQueryResult, VectorUpdateOperation, VectorDeleteOperation, VectorDeleteResult, VectorNamespace, } from './types.js';
|
|
49
|
+
export { EnhancedVectorStore, createVectorStore, TrajectoryTracker, createTrajectoryTracker, type TrajectoryTrackerConfig, type DetectedPattern, } from './services/index.js';
|
|
50
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vector/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAGH,OAAO,EACL,oBAAoB,EACpB,2BAA2B,EAC3B,qBAAqB,EACrB,wBAAwB,EACxB,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,0BAA0B,EAC1B,aAAa,EACb,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,GAC7B,MAAM,aAAa,CAAC;AAGrB,YAAY,EACV,cAAc,EACd,SAAS,EACT,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,wBAAwB,EACxB,YAAY,EACZ,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,SAAS,EACT,SAAS,EACT,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,GAChB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,eAAe,GACrB,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vector Services
|
|
3
|
+
*
|
|
4
|
+
* Exports all vector service modules for the knowledge-graph-agent.
|
|
5
|
+
* Includes:
|
|
6
|
+
* - Vector store for HNSW-based similarity search
|
|
7
|
+
* - Trajectory tracker for agent operation logging and self-learning
|
|
8
|
+
*
|
|
9
|
+
* @module vector/services
|
|
10
|
+
*/
|
|
11
|
+
export { EnhancedVectorStore, createVectorStore } from './vector-store.js';
|
|
12
|
+
export { TrajectoryTracker, createTrajectoryTracker, type TrajectoryTrackerConfig, type DetectedPattern, } from './trajectory-tracker.js';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/vector/services/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EACL,iBAAiB,EACjB,uBAAuB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,eAAe,GACrB,MAAM,yBAAyB,CAAC"}
|