agentic-flow 3.4.4 → 3.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.
Files changed (48) hide show
  1. package/.agents/skills/agentic-flow-ecosystem/SKILL.md +6 -1
  2. package/.claude/skills/agentic-flow-ecosystem/skill.md +7 -1
  3. package/CHANGELOG.md +19 -0
  4. package/README.md +36 -1
  5. package/dist/.tsbuildinfo +1 -1
  6. package/dist/config/claudeFlow.d.ts +1 -1
  7. package/dist/core/attention-native.d.ts +45 -28
  8. package/dist/core/attention-native.d.ts.map +1 -1
  9. package/dist/core/attention-native.js +131 -84
  10. package/dist/core/attention-native.js.map +1 -1
  11. package/dist/integrations/index.d.ts +2 -0
  12. package/dist/integrations/index.d.ts.map +1 -1
  13. package/dist/integrations/index.js +1 -0
  14. package/dist/integrations/index.js.map +1 -1
  15. package/dist/integrations/task-schedule.d.ts +51 -0
  16. package/dist/integrations/task-schedule.d.ts.map +1 -0
  17. package/dist/integrations/task-schedule.js +222 -0
  18. package/dist/integrations/task-schedule.js.map +1 -0
  19. package/dist/mcp/claudeFlowSdkServer.d.ts.map +1 -1
  20. package/dist/mcp/claudeFlowSdkServer.js +2 -1
  21. package/dist/mcp/claudeFlowSdkServer.js.map +1 -1
  22. package/dist/mcp/fastmcp/servers/claude-flow-sdk.js +2 -1
  23. package/dist/mcp/fastmcp/servers/claude-flow-sdk.js.map +1 -1
  24. package/dist/mcp/fastmcp/servers/http-sse.d.ts.map +1 -1
  25. package/dist/mcp/fastmcp/servers/http-sse.js +2 -1
  26. package/dist/mcp/fastmcp/servers/http-sse.js.map +1 -1
  27. package/dist/mcp/fastmcp/servers/http-streaming-updated.js +2 -1
  28. package/dist/mcp/fastmcp/servers/http-streaming-updated.js.map +1 -1
  29. package/dist/mcp/fastmcp/servers/stdio-full.js +2 -1
  30. package/dist/mcp/fastmcp/servers/stdio-full.js.map +1 -1
  31. package/dist/mcp/mcp-policy.js +1 -1
  32. package/dist/mcp/mcp-policy.js.map +1 -1
  33. package/dist/mcp/standalone-stdio.js +2 -1
  34. package/dist/mcp/standalone-stdio.js.map +1 -1
  35. package/dist/mcp/tools/ecosystem-tools.d.ts +5 -1
  36. package/dist/mcp/tools/ecosystem-tools.d.ts.map +1 -1
  37. package/dist/mcp/tools/ecosystem-tools.js +30 -1
  38. package/dist/mcp/tools/ecosystem-tools.js.map +1 -1
  39. package/dist/optimizations/configuration-tuning.d.ts +1 -1
  40. package/dist/utils/package-version.d.ts +2 -0
  41. package/dist/utils/package-version.d.ts.map +1 -1
  42. package/dist/utils/package-version.js +4 -0
  43. package/dist/utils/package-version.js.map +1 -1
  44. package/package.json +17 -66
  45. package/dist/core/agentdb-wrapper.d.ts +0 -149
  46. package/dist/core/agentdb-wrapper.d.ts.map +0 -1
  47. package/dist/core/agentdb-wrapper.js +0 -394
  48. package/dist/core/agentdb-wrapper.js.map +0 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "agentic-flow",
3
- "version": "3.4.4",
4
- "description": "The agentic meta-harness — freeze the model, evolve the harness. An open runtime that routes each query to the cost-optimal model, evolves its own harness (planner/context/reviewer/retry/tool/memory/score policy) and autonomously repairs code, then orchestrates 66 specialized agents, 213 MCP tools, ReasoningBank memory, and multi-agent swarms on top. Built by @ruvnet on the Claude Agent SDK.",
3
+ "version": "3.5.1",
4
+ "description": "AI agents runtime and meta-harness: routes each query to a cost-optimal model (LLM routing), evolves its own harness and orchestrates coding agents over MCP.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "bin": {
@@ -71,78 +71,27 @@
71
71
  "benchmark:embeddings": "tsx src/benchmarks/embeddings-benchmark.ts",
72
72
  "test:orchestration": "vitest run tests/orchestration/ --reporter=verbose",
73
73
  "test:security": "vitest run tests/security tests/mcp/mcp-policy.test.ts tests/transport/quic-loader.test.ts",
74
- "test:governance": "vitest run tests/harness/provenance.test.ts tests/harness/flywheel-governance.test.ts tests/mcp/mcp-policy.test.ts tests/mcp/package-surface.test.ts tests/mcp/zod4-migration.test.ts tests/embeddings/huggingface-offline.test.ts tests/repair/darwin-repair.test.ts tests/integrations",
74
+ "test:governance": "vitest run tests/harness/provenance.test.ts tests/harness/flywheel-governance.test.ts tests/mcp/mcp-policy.test.ts tests/mcp/package-surface.test.ts tests/mcp/zod4-migration.test.ts tests/mcp/server-version.test.ts tests/embeddings/huggingface-offline.test.ts tests/repair/darwin-repair.test.ts tests/integrations",
75
75
  "test:orchestration:smoke": "tsx tests/orchestration/orchestration-api.smoke.ts && tsx tests/orchestration/loop-policy.smoke.ts && tsx tests/orchestration/memory-plane.smoke.ts",
76
76
  "test:integrations": "vitest run tests/integrations"
77
77
  },
78
78
  "keywords": [
79
- "meta-harness",
79
+ "ai-agents",
80
+ "llm-routing",
81
+ "agent-orchestration",
82
+ "coding-agent",
83
+ "self-learning",
84
+ "mcp",
85
+ "agentic-flow",
80
86
  "metaharness",
81
87
  "agent-harness",
82
- "harness-evolution",
83
- "model-routing",
84
- "cost-optimal-routing",
85
- "self-improving",
86
- "darwin",
87
88
  "ai",
88
- "ai-agents",
89
- "ai-orchestration",
90
- "agentic",
91
- "agents",
92
- "agent-swarm",
89
+ "agentic-ai",
90
+ "swarm",
93
91
  "anthropic",
94
- "anthropic-claude",
95
92
  "automation",
96
93
  "autonomous-agents",
97
- "byzantine-consensus",
98
- "claude",
99
- "claude-agent-sdk",
100
- "claude-code",
101
- "reasoning-memory",
102
- "reasoningbank",
103
- "agent-learning",
104
- "memory-system",
105
- "consensus-protocols",
106
- "coordination",
107
- "crdt",
108
- "devops",
109
- "distributed-systems",
110
- "docker",
111
- "fastmcp",
112
- "flow-nexus",
113
- "github",
114
- "github-integration",
115
- "goal-planning",
116
- "goap",
117
- "hive-mind",
118
- "huggingface",
119
- "llm",
120
- "llm-orchestration",
121
- "machine-learning",
122
- "mcp",
123
- "mcp-server",
124
- "mcp-tools",
125
- "memory-persistence",
126
- "mesh-network",
127
- "multi-agent",
128
- "multi-agent-systems",
129
- "neural-networks",
130
- "onnx",
131
- "onnxruntime",
132
- "orchestration",
133
- "pagerank",
134
- "parallel-processing",
135
- "raft",
136
- "ruv",
137
- "ruvnet",
138
- "sparc",
139
- "sublinear-algorithms",
140
- "swarm",
141
- "swarm-intelligence",
142
- "task-orchestration",
143
- "typescript",
144
- "workflow",
145
- "workflow-automation"
94
+ "claude"
146
95
  ],
147
96
  "author": {
148
97
  "name": "ruv",
@@ -156,13 +105,14 @@
156
105
  ],
157
106
  "license": "MIT",
158
107
  "repository": {
108
+ "directory": "agentic-flow",
159
109
  "type": "git",
160
- "url": "https://github.com/ruvnet/agentic-flow.git"
110
+ "url": "git+https://github.com/ruvnet/agentic-flow.git"
161
111
  },
162
112
  "bugs": {
163
113
  "url": "https://github.com/ruvnet/agentic-flow/issues"
164
114
  },
165
- "homepage": "https://github.com/ruvnet/agentic-flow#readme",
115
+ "homepage": "https://ruv.io",
166
116
  "engines": {
167
117
  "node": ">=20.0.0"
168
118
  },
@@ -196,6 +146,7 @@
196
146
  "@rollup/rollup-darwin-arm64": "^4.59.0",
197
147
  "@ruvector/attention": "^2.3.0",
198
148
  "@ruvector/mincut-wasm": "^2.3.0",
149
+ "@ruvector/rudag": "^0.1.2",
199
150
  "@ruvector/sona": "^0.1.11",
200
151
  "@ruvnet/sublinear-core": "^1.0.1",
201
152
  "agent-booster": "^0.2.2",
@@ -1,149 +0,0 @@
1
- /**
2
- * AgentDBWrapper - Clean API over raw AgentDB v2.0.0-alpha.2.11
3
- *
4
- * Provides a unified interface for:
5
- * - Vector search with HNSW indexing
6
- * - Memory operations (insert, search, update, delete)
7
- * - TypeScript-first type safety
8
- * - Error handling and validation
9
- *
10
- * Note: AgentDB is optional - falls back gracefully on Windows
11
- *
12
- * @module agentdb-wrapper
13
- */
14
- import type { AgentDBConfig, VectorEntry, VectorSearchOptions, VectorSearchResult, MemoryInsertOptions, MemoryUpdateOptions, MemoryDeleteOptions, MemoryGetOptions, AgentDBStats, BatchInsertResult } from '../types/agentdb.js';
15
- /**
16
- * Main wrapper class for AgentDB operations
17
- *
18
- * @example
19
- * ```typescript
20
- * const wrapper = new AgentDBWrapper({
21
- * dbPath: ':memory:',
22
- * dimension: 384,
23
- * hnswConfig: { M: 16, efConstruction: 200 }
24
- * });
25
- *
26
- * await wrapper.initialize();
27
- *
28
- * // Insert a vector
29
- * const vector = new Float32Array(384);
30
- * await wrapper.insert({ vector, metadata: { type: 'test' } });
31
- *
32
- * // Search
33
- * const results = await wrapper.vectorSearch(queryVector, { k: 10 });
34
- *
35
- * await wrapper.close();
36
- * ```
37
- */
38
- export declare class AgentDBWrapper {
39
- private agentDB;
40
- private config;
41
- private initialized;
42
- private dimension;
43
- private namespace;
44
- private reflexionController;
45
- private embedder;
46
- private vectorBackend;
47
- _agentDB?: any;
48
- _embedder?: any;
49
- _vectorBackend?: any;
50
- /**
51
- * Create a new AgentDBWrapper instance
52
- *
53
- * @param config - Configuration options
54
- */
55
- constructor(config?: AgentDBConfig);
56
- /**
57
- * Initialize the AgentDB instance and dependencies
58
- *
59
- * @throws {DatabaseError} If initialization fails
60
- */
61
- initialize(): Promise<void>;
62
- /**
63
- * Ensure wrapper is initialized before operations
64
- *
65
- * @throws {Error} If not initialized
66
- */
67
- private ensureInitialized;
68
- /**
69
- * Validate vector dimension
70
- *
71
- * @param vector - Vector to validate
72
- * @throws {ValidationError} If dimension is invalid
73
- */
74
- private validateVectorDimension;
75
- /**
76
- * Generate a unique ID
77
- *
78
- * @returns A unique identifier
79
- */
80
- private generateId;
81
- /**
82
- * Insert a vector with metadata into the database
83
- *
84
- * @param options - Insert options
85
- * @returns The inserted entry with ID
86
- * @throws {ValidationError} If vector dimension is invalid
87
- * @throws {DatabaseError} If insertion fails
88
- */
89
- insert(options: MemoryInsertOptions): Promise<{
90
- id: string;
91
- timestamp: number;
92
- }>;
93
- /**
94
- * Search for similar vectors using HNSW indexing
95
- *
96
- * @param query - Query vector
97
- * @param options - Search options
98
- * @returns Array of search results sorted by similarity (descending)
99
- * @throws {ValidationError} If query dimension is invalid
100
- */
101
- vectorSearch(query: Float32Array, options?: VectorSearchOptions): Promise<VectorSearchResult[]>;
102
- /**
103
- * Update a vector and/or its metadata
104
- *
105
- * @param options - Update options
106
- * @returns True if update succeeded
107
- * @throws {ValidationError} If vector dimension is invalid
108
- * @throws {DatabaseError} If vector not found
109
- */
110
- update(options: MemoryUpdateOptions): Promise<boolean>;
111
- /**
112
- * Delete a vector by ID
113
- *
114
- * @param options - Delete options
115
- * @returns True if deletion succeeded, false if not found
116
- */
117
- delete(options: MemoryDeleteOptions): Promise<boolean>;
118
- /**
119
- * Get a vector by ID
120
- *
121
- * @param options - Get options
122
- * @returns Vector entry or null if not found
123
- */
124
- get(options: MemoryGetOptions): Promise<VectorEntry | null>;
125
- /**
126
- * Insert multiple vectors in a batch
127
- *
128
- * @param entries - Array of entries to insert
129
- * @returns Batch insert result with success/failure counts
130
- */
131
- batchInsert(entries: MemoryInsertOptions[]): Promise<BatchInsertResult>;
132
- /**
133
- * Get database statistics
134
- *
135
- * @returns Database statistics including vector count and index info
136
- */
137
- getStats(): Promise<AgentDBStats>;
138
- /**
139
- * Close the database connection
140
- */
141
- close(): Promise<void>;
142
- /**
143
- * Get the underlying AgentDB instance (for advanced usage)
144
- *
145
- * @returns The raw AgentDB instance
146
- */
147
- getRawInstance(): any;
148
- }
149
- //# sourceMappingURL=agentdb-wrapper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"agentdb-wrapper.d.ts","sourceRoot":"","sources":["../../src/core/agentdb-wrapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAaH,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EACX,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EAKlB,MAAM,qBAAqB,CAAC;AAE7B;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAAO;IACtB,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,mBAAmB,CAAM;IACjC,OAAO,CAAC,QAAQ,CAAM;IACtB,OAAO,CAAC,aAAa,CAAM;IAGpB,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,SAAS,CAAC,EAAE,GAAG,CAAC;IAChB,cAAc,CAAC,EAAE,GAAG,CAAC;IAE5B;;;;OAIG;gBACS,MAAM,GAAE,aAAkB;IA0BtC;;;;OAIG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IA6CjC;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAQzB;;;;;OAKG;IACH,OAAO,CAAC,uBAAuB;IAQ/B;;;;OAIG;IACH,OAAO,CAAC,UAAU;IAIlB;;;;;;;OAOG;IACG,MAAM,CACV,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAgC7C;;;;;;;OAOG;IACG,YAAY,CAChB,KAAK,EAAE,YAAY,EACnB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAsChC;;;;;;;OAOG;IACG,MAAM,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;IAkC5D;;;;;OAKG;IACG,MAAM,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;IAiB5D;;;;;OAKG;IACG,GAAG,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAiCjE;;;;;OAKG;IACG,WAAW,CACf,OAAO,EAAE,mBAAmB,EAAE,GAC7B,OAAO,CAAC,iBAAiB,CAAC;IAiC7B;;;;OAIG;IACG,QAAQ,IAAI,OAAO,CAAC,YAAY,CAAC;IAuBvC;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAgB5B;;;;OAIG;IACH,cAAc,IAAI,GAAG;CAItB"}
@@ -1,394 +0,0 @@
1
- /**
2
- * AgentDBWrapper - Clean API over raw AgentDB v2.0.0-alpha.2.11
3
- *
4
- * Provides a unified interface for:
5
- * - Vector search with HNSW indexing
6
- * - Memory operations (insert, search, update, delete)
7
- * - TypeScript-first type safety
8
- * - Error handling and validation
9
- *
10
- * Note: AgentDB is optional - falls back gracefully on Windows
11
- *
12
- * @module agentdb-wrapper
13
- */
14
- let AgentDB = null;
15
- let agentdbAvailable = false;
16
- try {
17
- const mod = await import('agentdb');
18
- AgentDB = mod.AgentDB;
19
- agentdbAvailable = true;
20
- }
21
- catch {
22
- console.warn('[AgentDB] Not available - some features disabled');
23
- }
24
- /**
25
- * Main wrapper class for AgentDB operations
26
- *
27
- * @example
28
- * ```typescript
29
- * const wrapper = new AgentDBWrapper({
30
- * dbPath: ':memory:',
31
- * dimension: 384,
32
- * hnswConfig: { M: 16, efConstruction: 200 }
33
- * });
34
- *
35
- * await wrapper.initialize();
36
- *
37
- * // Insert a vector
38
- * const vector = new Float32Array(384);
39
- * await wrapper.insert({ vector, metadata: { type: 'test' } });
40
- *
41
- * // Search
42
- * const results = await wrapper.vectorSearch(queryVector, { k: 10 });
43
- *
44
- * await wrapper.close();
45
- * ```
46
- */
47
- export class AgentDBWrapper {
48
- agentDB;
49
- config;
50
- initialized = false;
51
- dimension;
52
- namespace;
53
- reflexionController;
54
- embedder;
55
- vectorBackend;
56
- // For testing - allow dependency injection
57
- _agentDB;
58
- _embedder;
59
- _vectorBackend;
60
- /**
61
- * Create a new AgentDBWrapper instance
62
- *
63
- * @param config - Configuration options
64
- */
65
- constructor(config = {}) {
66
- this.config = {
67
- dbPath: config.dbPath || ':memory:',
68
- namespace: config.namespace || 'default',
69
- dimension: config.dimension || 384,
70
- hnswConfig: {
71
- M: config.hnswConfig?.M || 16,
72
- efConstruction: config.hnswConfig?.efConstruction || 200,
73
- efSearch: config.hnswConfig?.efSearch || 100,
74
- },
75
- enableAttention: config.enableAttention || false,
76
- attentionConfig: config.attentionConfig,
77
- autoInit: config.autoInit !== false, // Default true
78
- };
79
- this.dimension = this.config.dimension;
80
- this.namespace = this.config.namespace;
81
- // Auto-initialize if configured
82
- if (this.config.autoInit) {
83
- this.initialize().catch((err) => {
84
- console.error('Auto-initialization failed:', err);
85
- });
86
- }
87
- }
88
- /**
89
- * Initialize the AgentDB instance and dependencies
90
- *
91
- * @throws {DatabaseError} If initialization fails
92
- */
93
- async initialize() {
94
- if (this.initialized) {
95
- return;
96
- }
97
- if (!agentdbAvailable || !AgentDB) {
98
- throw new Error('AgentDB not available - install with: npm install agentdb (requires native build tools)');
99
- }
100
- try {
101
- // Use injected dependencies for testing, otherwise create real instances
102
- if (this._agentDB) {
103
- this.agentDB = this._agentDB;
104
- this.embedder = this._embedder;
105
- this.vectorBackend = this._vectorBackend;
106
- }
107
- else {
108
- // Create real AgentDB instance
109
- this.agentDB = new AgentDB({
110
- dbPath: this.config.dbPath,
111
- namespace: this.namespace,
112
- enableAttention: this.config.enableAttention,
113
- attentionConfig: this.config.attentionConfig,
114
- });
115
- await this.agentDB.initialize();
116
- // Get controllers
117
- this.reflexionController = this.agentDB.getController('reflexion');
118
- this.embedder = this.reflexionController?.embedder;
119
- this.vectorBackend = this.reflexionController?.vectorBackend;
120
- }
121
- // Initialize embedder if available
122
- if (this.embedder && this.embedder.initialize) {
123
- await this.embedder.initialize();
124
- }
125
- this.initialized = true;
126
- }
127
- catch (error) {
128
- throw new Error(`Failed to initialize AgentDB: ${error instanceof Error ? error.message : String(error)}`);
129
- }
130
- }
131
- /**
132
- * Ensure wrapper is initialized before operations
133
- *
134
- * @throws {Error} If not initialized
135
- */
136
- ensureInitialized() {
137
- if (!this.initialized) {
138
- throw new Error('AgentDBWrapper not initialized. Call initialize() first.');
139
- }
140
- }
141
- /**
142
- * Validate vector dimension
143
- *
144
- * @param vector - Vector to validate
145
- * @throws {ValidationError} If dimension is invalid
146
- */
147
- validateVectorDimension(vector) {
148
- if (vector.length !== this.dimension) {
149
- throw new Error(`Invalid vector dimension: expected ${this.dimension}, got ${vector.length}`);
150
- }
151
- }
152
- /**
153
- * Generate a unique ID
154
- *
155
- * @returns A unique identifier
156
- */
157
- generateId() {
158
- return `${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;
159
- }
160
- /**
161
- * Insert a vector with metadata into the database
162
- *
163
- * @param options - Insert options
164
- * @returns The inserted entry with ID
165
- * @throws {ValidationError} If vector dimension is invalid
166
- * @throws {DatabaseError} If insertion fails
167
- */
168
- async insert(options) {
169
- this.ensureInitialized();
170
- this.validateVectorDimension(options.vector);
171
- const id = options.id || this.generateId();
172
- const timestamp = Date.now();
173
- const metadata = {
174
- ...options.metadata,
175
- timestamp,
176
- namespace: options.namespace || this.namespace,
177
- };
178
- try {
179
- const controller = this._agentDB
180
- ? this._agentDB.getController('reflexion')
181
- : this.reflexionController;
182
- await controller.store({
183
- id,
184
- vector: options.vector,
185
- metadata,
186
- });
187
- return { id, timestamp };
188
- }
189
- catch (error) {
190
- throw new Error(`Failed to insert vector: ${error instanceof Error ? error.message : String(error)}`);
191
- }
192
- }
193
- /**
194
- * Search for similar vectors using HNSW indexing
195
- *
196
- * @param query - Query vector
197
- * @param options - Search options
198
- * @returns Array of search results sorted by similarity (descending)
199
- * @throws {ValidationError} If query dimension is invalid
200
- */
201
- async vectorSearch(query, options = {}) {
202
- this.ensureInitialized();
203
- this.validateVectorDimension(query);
204
- const { k = 10, metric = 'cosine', filter, includeVectors = false, hnswParams, } = options;
205
- try {
206
- const controller = this._agentDB
207
- ? this._agentDB.getController('reflexion')
208
- : this.reflexionController;
209
- const results = await controller.retrieve(query, {
210
- k,
211
- metric,
212
- filter,
213
- includeVectors,
214
- hnswParams,
215
- });
216
- return results.map((result) => ({
217
- id: result.id,
218
- score: result.score,
219
- metadata: result.metadata,
220
- ...(includeVectors && { vector: result.vector }),
221
- }));
222
- }
223
- catch (error) {
224
- throw new Error(`Vector search failed: ${error instanceof Error ? error.message : String(error)}`);
225
- }
226
- }
227
- /**
228
- * Update a vector and/or its metadata
229
- *
230
- * @param options - Update options
231
- * @returns True if update succeeded
232
- * @throws {ValidationError} If vector dimension is invalid
233
- * @throws {DatabaseError} If vector not found
234
- */
235
- async update(options) {
236
- this.ensureInitialized();
237
- if (options.vector) {
238
- this.validateVectorDimension(options.vector);
239
- }
240
- try {
241
- const controller = this._agentDB
242
- ? this._agentDB.getController('reflexion')
243
- : this.reflexionController;
244
- const updateData = {};
245
- if (options.vector) {
246
- updateData.vector = options.vector;
247
- }
248
- if (options.metadata) {
249
- updateData.metadata = options.metadata;
250
- }
251
- const result = await controller.update(options.id, updateData);
252
- if (!result) {
253
- throw new Error(`Vector not found: ${options.id}`);
254
- }
255
- return result;
256
- }
257
- catch (error) {
258
- throw error;
259
- }
260
- }
261
- /**
262
- * Delete a vector by ID
263
- *
264
- * @param options - Delete options
265
- * @returns True if deletion succeeded, false if not found
266
- */
267
- async delete(options) {
268
- this.ensureInitialized();
269
- try {
270
- const controller = this._agentDB
271
- ? this._agentDB.getController('reflexion')
272
- : this.reflexionController;
273
- const result = await controller.delete(options.id);
274
- return result;
275
- }
276
- catch (error) {
277
- throw new Error(`Delete failed: ${error instanceof Error ? error.message : String(error)}`);
278
- }
279
- }
280
- /**
281
- * Get a vector by ID
282
- *
283
- * @param options - Get options
284
- * @returns Vector entry or null if not found
285
- */
286
- async get(options) {
287
- this.ensureInitialized();
288
- try {
289
- const controller = this._agentDB
290
- ? this._agentDB.getController('reflexion')
291
- : this.reflexionController;
292
- const result = await controller.get(options.id);
293
- if (!result) {
294
- return null;
295
- }
296
- const entry = {
297
- id: result.id,
298
- vector: result.vector,
299
- metadata: result.metadata,
300
- };
301
- // Exclude vector if not requested
302
- if (options.includeVector === false) {
303
- delete entry.vector;
304
- }
305
- return entry;
306
- }
307
- catch (error) {
308
- throw new Error(`Get failed: ${error instanceof Error ? error.message : String(error)}`);
309
- }
310
- }
311
- /**
312
- * Insert multiple vectors in a batch
313
- *
314
- * @param entries - Array of entries to insert
315
- * @returns Batch insert result with success/failure counts
316
- */
317
- async batchInsert(entries) {
318
- this.ensureInitialized();
319
- const startTime = Date.now();
320
- const result = {
321
- inserted: 0,
322
- failed: [],
323
- duration: 0,
324
- };
325
- const controller = this._agentDB
326
- ? this._agentDB.getController('reflexion')
327
- : this.reflexionController;
328
- for (let i = 0; i < entries.length; i++) {
329
- const entry = entries[i];
330
- try {
331
- await this.insert(entry);
332
- result.inserted++;
333
- }
334
- catch (error) {
335
- result.failed.push({
336
- index: i,
337
- id: entry.id,
338
- error: error instanceof Error ? error.message : String(error),
339
- });
340
- }
341
- }
342
- result.duration = Date.now() - startTime;
343
- return result;
344
- }
345
- /**
346
- * Get database statistics
347
- *
348
- * @returns Database statistics including vector count and index info
349
- */
350
- async getStats() {
351
- this.ensureInitialized();
352
- try {
353
- const backend = this._vectorBackend || this.vectorBackend;
354
- const stats = await backend.getStats();
355
- return {
356
- vectorCount: stats.vectorCount || 0,
357
- dimension: this.dimension,
358
- databaseSize: stats.databaseSize || 0,
359
- hnswStats: stats.hnswStats,
360
- memoryUsage: stats.memoryUsage,
361
- indexBuildTime: stats.indexBuildTime,
362
- };
363
- }
364
- catch (error) {
365
- throw new Error(`Failed to get stats: ${error instanceof Error ? error.message : String(error)}`);
366
- }
367
- }
368
- /**
369
- * Close the database connection
370
- */
371
- async close() {
372
- if (!this.initialized) {
373
- return;
374
- }
375
- try {
376
- const db = this._agentDB || this.agentDB;
377
- await db.close();
378
- this.initialized = false;
379
- }
380
- catch (error) {
381
- throw new Error(`Failed to close database: ${error instanceof Error ? error.message : String(error)}`);
382
- }
383
- }
384
- /**
385
- * Get the underlying AgentDB instance (for advanced usage)
386
- *
387
- * @returns The raw AgentDB instance
388
- */
389
- getRawInstance() {
390
- this.ensureInitialized();
391
- return this.agentDB;
392
- }
393
- }
394
- //# sourceMappingURL=agentdb-wrapper.js.map