agentic-flow 1.6.6 → 1.7.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 (44) hide show
  1. package/.claude/skills/.claude-flow/metrics/agent-metrics.json +1 -0
  2. package/.claude/skills/.claude-flow/metrics/performance.json +87 -0
  3. package/.claude/skills/.claude-flow/metrics/task-metrics.json +10 -0
  4. package/.claude/skills/skill-builder/.claude-flow/metrics/agent-metrics.json +1 -0
  5. package/.claude/skills/skill-builder/.claude-flow/metrics/performance.json +87 -0
  6. package/.claude/skills/skill-builder/.claude-flow/metrics/task-metrics.json +10 -0
  7. package/CHANGELOG.md +0 -30
  8. package/README.md +16 -2
  9. package/dist/agentdb/benchmarks/comprehensive-benchmark.js +664 -0
  10. package/dist/agentdb/benchmarks/frontier-benchmark.js +419 -0
  11. package/dist/agentdb/benchmarks/reflexion-benchmark.js +370 -0
  12. package/dist/agentdb/cli/agentdb-cli.js +717 -0
  13. package/dist/agentdb/controllers/CausalMemoryGraph.js +322 -0
  14. package/dist/agentdb/controllers/CausalRecall.js +281 -0
  15. package/dist/agentdb/controllers/EmbeddingService.js +118 -0
  16. package/dist/agentdb/controllers/ExplainableRecall.js +387 -0
  17. package/dist/agentdb/controllers/NightlyLearner.js +382 -0
  18. package/dist/agentdb/controllers/ReflexionMemory.js +239 -0
  19. package/dist/agentdb/controllers/SkillLibrary.js +276 -0
  20. package/dist/agentdb/controllers/frontier-index.js +9 -0
  21. package/dist/agentdb/controllers/index.js +8 -0
  22. package/dist/agentdb/index.js +32 -0
  23. package/dist/agentdb/optimizations/BatchOperations.js +198 -0
  24. package/dist/agentdb/optimizations/QueryOptimizer.js +225 -0
  25. package/dist/agentdb/optimizations/index.js +7 -0
  26. package/dist/agentdb/tests/frontier-features.test.js +665 -0
  27. package/dist/cli/skills-manager.js +1297 -0
  28. package/dist/cli/update-message.js +175 -0
  29. package/dist/cli-proxy.js +2 -26
  30. package/dist/mcp/standalone-stdio.js +200 -4
  31. package/dist/memory/SharedMemoryPool.js +211 -0
  32. package/dist/memory/index.js +6 -0
  33. package/dist/reasoningbank/AdvancedMemory.js +239 -0
  34. package/dist/reasoningbank/HybridBackend.js +305 -0
  35. package/dist/reasoningbank/index-new.js +87 -0
  36. package/dist/reasoningbank/index.js +0 -4
  37. package/dist/utils/cli.js +0 -5
  38. package/docs/AGENTDB_TESTING.md +411 -0
  39. package/package.json +4 -4
  40. package/scripts/run-validation.sh +165 -0
  41. package/scripts/test-agentdb.sh +153 -0
  42. package/wasm/reasoningbank/reasoningbank_wasm_bg.js +2 -2
  43. package/wasm/reasoningbank/reasoningbank_wasm_bg.wasm +0 -0
  44. package/docs/AGENTDB_INTEGRATION.md +0 -379
@@ -0,0 +1,153 @@
1
+ #!/bin/bash
2
+ # AgentDB CLI Quick Test Script
3
+
4
+ set -e
5
+
6
+ echo "🧪 AgentDB CLI Testing Script"
7
+ echo "=============================="
8
+ echo ""
9
+
10
+ # Set test database path
11
+ export AGENTDB_PATH="./test-agentdb.db"
12
+
13
+ # Clean up old test database
14
+ if [ -f "$AGENTDB_PATH" ]; then
15
+ echo "🗑️ Removing old test database..."
16
+ rm "$AGENTDB_PATH"
17
+ fi
18
+
19
+ echo "📍 Current directory: $(pwd)"
20
+ echo "💾 Database path: $AGENTDB_PATH"
21
+ echo ""
22
+
23
+ # Test 1: Help command
24
+ echo "1️⃣ Testing help command..."
25
+ echo ""
26
+ node dist/agentdb/cli/agentdb-cli.js --help | head -20
27
+ echo ""
28
+ echo "✅ Help command works!"
29
+ echo ""
30
+
31
+ # Test 2: Store a successful episode
32
+ echo "2️⃣ Storing a successful episode..."
33
+ node dist/agentdb/cli/agentdb-cli.js reflexion store \
34
+ "test-session-1" \
35
+ "implement_authentication" \
36
+ 0.95 \
37
+ true \
38
+ "Successfully implemented OAuth2 with JWT tokens" \
39
+ "User login requirement" \
40
+ "Working auth system with refresh tokens" \
41
+ 1200 \
42
+ 5000
43
+ echo ""
44
+
45
+ # Test 3: Store a failed episode
46
+ echo "3️⃣ Storing a failed episode..."
47
+ node dist/agentdb/cli/agentdb-cli.js reflexion store \
48
+ "test-session-1" \
49
+ "implement_authentication" \
50
+ 0.35 \
51
+ false \
52
+ "Forgot to validate token expiration" \
53
+ "User login requirement" \
54
+ "Insecure auth system" \
55
+ 800 \
56
+ 3000
57
+ echo ""
58
+
59
+ # Test 4: Retrieve episodes
60
+ echo "4️⃣ Retrieving episodes..."
61
+ node dist/agentdb/cli/agentdb-cli.js reflexion retrieve \
62
+ "authentication" \
63
+ 5 \
64
+ 0.3
65
+ echo ""
66
+
67
+ # Test 5: Get critique summary
68
+ echo "5️⃣ Getting critique summary (failures only)..."
69
+ node dist/agentdb/cli/agentdb-cli.js reflexion critique-summary \
70
+ "authentication" \
71
+ true
72
+ echo ""
73
+
74
+ # Test 6: Create a skill
75
+ echo "6️⃣ Creating a skill..."
76
+ node dist/agentdb/cli/agentdb-cli.js skill create \
77
+ "jwt_authentication" \
78
+ "Generate and validate JWT tokens for user authentication" \
79
+ "function generateJWT(payload, secret) { return jwt.sign(payload, secret, { expiresIn: '1h' }); }"
80
+ echo ""
81
+
82
+ # Test 7: Search skills
83
+ echo "7️⃣ Searching for skills..."
84
+ node dist/agentdb/cli/agentdb-cli.js skill search \
85
+ "authentication" \
86
+ 5
87
+ echo ""
88
+
89
+ # Test 8: Add a causal edge
90
+ echo "8️⃣ Adding a causal edge..."
91
+ node dist/agentdb/cli/agentdb-cli.js causal add-edge \
92
+ "add_unit_tests" \
93
+ "code_quality_score" \
94
+ 0.25 \
95
+ 0.95 \
96
+ 100
97
+ echo ""
98
+
99
+ # Test 9: Create an experiment
100
+ echo "9️⃣ Creating an A/B experiment..."
101
+ node dist/agentdb/cli/agentdb-cli.js causal experiment create \
102
+ "test-coverage-vs-bugs" \
103
+ "test_coverage" \
104
+ "bug_rate"
105
+ echo ""
106
+
107
+ # Test 10: Add experiment observations
108
+ echo "🔟 Adding experiment observations..."
109
+ echo " - Treatment group (high test coverage)..."
110
+ node dist/agentdb/cli/agentdb-cli.js causal experiment add-observation \
111
+ 1 \
112
+ true \
113
+ 0.15 \
114
+ '{"coverage": 0.85, "lines": 5000}'
115
+ echo " - Control group (low test coverage)..."
116
+ node dist/agentdb/cli/agentdb-cli.js causal experiment add-observation \
117
+ 1 \
118
+ false \
119
+ 0.35 \
120
+ '{"coverage": 0.45, "lines": 5000}'
121
+ echo ""
122
+
123
+ # Test 11: Calculate experiment uplift
124
+ echo "1️⃣1️⃣ Calculating experiment uplift..."
125
+ node dist/agentdb/cli/agentdb-cli.js causal experiment calculate 1
126
+ echo ""
127
+
128
+ # Test 12: Query causal edges
129
+ echo "1️⃣2️⃣ Querying causal edges..."
130
+ node dist/agentdb/cli/agentdb-cli.js causal query \
131
+ "" \
132
+ "" \
133
+ 0.5 \
134
+ 0.1 \
135
+ 10
136
+ echo ""
137
+
138
+ # Test 13: Database stats
139
+ echo "1️⃣3️⃣ Getting database statistics..."
140
+ node dist/agentdb/cli/agentdb-cli.js db stats
141
+ echo ""
142
+
143
+ # Summary
144
+ echo "=============================="
145
+ echo "✅ All 13 tests completed successfully!"
146
+ echo ""
147
+ echo "📊 Test database created at: $AGENTDB_PATH"
148
+ echo "📁 Size: $(du -h "$AGENTDB_PATH" | cut -f1)"
149
+ echo ""
150
+ echo "🔍 You can now explore the database or run individual commands:"
151
+ echo " node dist/agentdb/cli/agentdb-cli.js --help"
152
+ echo " AGENTDB_PATH=$AGENTDB_PATH node dist/agentdb/cli/agentdb-cli.js reflexion retrieve authentication 5"
153
+ echo ""
@@ -258,7 +258,7 @@ export function log(message) {
258
258
  wasm.log(ptr0, len0);
259
259
  }
260
260
 
261
- function __wbg_adapter_6(arg0, arg1, arg2) {
261
+ function __wbg_adapter_4(arg0, arg1, arg2) {
262
262
  wasm.__wbindgen_export_5(arg0, arg1, addHeapObject(arg2));
263
263
  }
264
264
 
@@ -540,7 +540,7 @@ export function __wbindgen_cast_2241b6af4c4b2941(arg0, arg1) {
540
540
 
541
541
  export function __wbindgen_cast_8eb6fd44e7238d11(arg0, arg1) {
542
542
  // Cast intrinsic for `Closure(Closure { dtor_idx: 62, function: Function { arguments: [Externref], shim_idx: 63, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
543
- const ret = makeMutClosure(arg0, arg1, 62, __wbg_adapter_6);
543
+ const ret = makeMutClosure(arg0, arg1, 62, __wbg_adapter_4);
544
544
  return addHeapObject(ret);
545
545
  };
546
546
 
@@ -1,379 +0,0 @@
1
- # AgentDB Integration Guide
2
-
3
- ## Overview
4
-
5
- AgentDB is now fully integrated into agentic-flow as a drop-in replacement for the legacy ReasoningBank implementation. It provides 150x-12,500x performance improvements with 100% backward compatibility.
6
-
7
- ## Quick Start
8
-
9
- ### Using AgentDB Adapter
10
-
11
- ```typescript
12
- import { createAgentDBAdapter } from 'agentic-flow/reasoningbank';
13
-
14
- // Create adapter with default configuration
15
- const adapter = await createAgentDBAdapter({
16
- dbPath: '.agentdb/reasoningbank.db',
17
- enableLearning: true, // Enable learning plugins
18
- enableReasoning: true, // Enable reasoning agents
19
- enableQUICSync: false, // Enable QUIC sync
20
- quantizationType: 'scalar', // binary | scalar | product | none
21
- cacheSize: 1000, // In-memory cache size
22
- });
23
-
24
- // Insert pattern
25
- const id = await adapter.insertPattern({
26
- id: '',
27
- type: 'pattern',
28
- domain: 'code-generation',
29
- pattern_data: JSON.stringify({
30
- embedding: await computeEmbedding('example query'),
31
- pattern: { code: 'function example() {}' }
32
- }),
33
- confidence: 0.9,
34
- usage_count: 0,
35
- success_count: 0,
36
- created_at: Date.now(),
37
- last_used: Date.now(),
38
- });
39
-
40
- // Retrieve with reasoning
41
- const result = await adapter.retrieveWithReasoning(queryEmbedding, {
42
- domain: 'code-generation',
43
- synthesizeContext: true, // Generate rich context
44
- useMMR: true, // Diverse results
45
- k: 10,
46
- });
47
-
48
- console.log('Memories:', result.memories.length);
49
- console.log('Context:', result.context);
50
- console.log('Patterns:', result.patterns);
51
- ```
52
-
53
- ### Default Configuration
54
-
55
- ```typescript
56
- import { createDefaultAgentDBAdapter } from 'agentic-flow/reasoningbank';
57
-
58
- const adapter = await createDefaultAgentDBAdapter();
59
- ```
60
-
61
- ## Migration from Legacy ReasoningBank
62
-
63
- ### Automatic Migration
64
-
65
- ```typescript
66
- import { migrateToAgentDB, validateMigration } from 'agentic-flow/reasoningbank';
67
-
68
- // Migrate from legacy database
69
- const result = await migrateToAgentDB(
70
- '.swarm/memory.db', // Source (legacy)
71
- '.agentdb/reasoningbank.db' // Destination (AgentDB)
72
- );
73
-
74
- console.log(`✅ Migrated ${result.patternsMigrated} patterns`);
75
- console.log(`✅ Migrated ${result.trajectoriesMigrated} trajectories`);
76
- console.log(`📦 Backup: ${result.backupPath}`);
77
- console.log(`⏱️ Duration: ${result.duration}ms`);
78
-
79
- // Validate migration
80
- const validation = await validateMigration(
81
- '.swarm/memory.db',
82
- '.agentdb/reasoningbank.db'
83
- );
84
-
85
- if (!validation.valid) {
86
- console.error('❌ Migration issues:', validation.issues);
87
- } else {
88
- console.log('✅ Migration validated successfully');
89
- }
90
- ```
91
-
92
- ### CLI Migration
93
-
94
- ```bash
95
- # Using AgentDB CLI
96
- cd packages/agentdb
97
- agentdb migrate --source ../../agentic-flow/.swarm/memory.db
98
-
99
- # Or using npm script
100
- npm run migrate:legacy
101
- ```
102
-
103
- ## Features
104
-
105
- ### 1. Vector Database
106
- - **HNSW Indexing**: O(log n) search complexity
107
- - **Quantization**: Binary (32x), Scalar (4x), Product (8-16x) memory reduction
108
- - **Caching**: 1000 pattern in-memory cache
109
- - **Performance**: Sub-millisecond search (<100µs)
110
-
111
- ### 2. Learning Plugins (9 Algorithms)
112
- - Decision Transformer (Offline RL)
113
- - Q-Learning (Value-based RL)
114
- - SARSA (On-policy RL)
115
- - Actor-Critic (Policy gradient)
116
- - Active Learning (Query selection)
117
- - Adversarial Training (Robustness)
118
- - Curriculum Learning (Progressive difficulty)
119
- - Federated Learning (Distributed learning)
120
- - Multi-task Learning (Transfer learning)
121
-
122
- ### 3. Reasoning Agents (4 Modules)
123
- - **PatternMatcher**: Find similar patterns with advanced algorithms
124
- - **ContextSynthesizer**: Generate rich context from multiple sources
125
- - **MemoryOptimizer**: Consolidate similar patterns, prune low-quality
126
- - **ExperienceCurator**: Quality-based experience filtering
127
-
128
- ### 4. QUIC Synchronization
129
- - Sub-millisecond latency
130
- - Multiplexed streams
131
- - Event-based broadcasting
132
- - Automatic retry/recovery
133
-
134
- ## Configuration Options
135
-
136
- ```typescript
137
- interface AgentDBConfig {
138
- // Database path
139
- dbPath?: string; // Default: '.agentdb/reasoningbank.db'
140
-
141
- // Feature flags
142
- enableLearning?: boolean; // Default: true
143
- enableReasoning?: boolean; // Default: true
144
- enableQUICSync?: boolean; // Default: false
145
-
146
- // Performance tuning
147
- quantizationType?: 'binary' | 'scalar' | 'product' | 'none'; // Default: 'scalar'
148
- cacheSize?: number; // Default: 1000
149
-
150
- // QUIC sync (if enabled)
151
- syncPort?: number; // Default: 4433
152
- syncPeers?: string[]; // Default: []
153
- }
154
- ```
155
-
156
- ## Advanced Usage
157
-
158
- ### Training Learning Models
159
-
160
- ```typescript
161
- // Train Decision Transformer on stored experiences
162
- const metrics = await adapter.train({
163
- epochs: 50,
164
- batchSize: 32,
165
- });
166
-
167
- console.log('Loss:', metrics.loss);
168
- console.log('Duration:', metrics.duration);
169
- ```
170
-
171
- ### Using Reasoning Agents
172
-
173
- ```typescript
174
- // Retrieve with full reasoning pipeline
175
- const result = await adapter.retrieveWithReasoning(queryEmbedding, {
176
- domain: 'code-generation',
177
- k: 10,
178
- useMMR: true, // Maximal Marginal Relevance
179
- synthesizeContext: true, // Context synthesis
180
- optimizeMemory: true, // Memory optimization
181
- });
182
-
183
- console.log('Memories:', result.memories);
184
- console.log('Synthesized Context:', result.context);
185
- console.log('Similar Patterns:', result.patterns);
186
- console.log('Optimizations:', result.optimizations);
187
- ```
188
-
189
- ### Memory Optimization
190
-
191
- ```typescript
192
- // Run optimization manually
193
- await adapter.optimize();
194
-
195
- // Get statistics
196
- const stats = await adapter.getStats();
197
-
198
- console.log('Total Patterns:', stats.totalPatterns);
199
- console.log('Total Trajectories:', stats.totalTrajectories);
200
- console.log('Average Confidence:', stats.avgConfidence);
201
- console.log('Domains:', stats.domains);
202
- console.log('Database Size:', stats.dbSize);
203
- ```
204
-
205
- ## Performance Benchmarks
206
-
207
- ### Speed Improvements
208
- - **Pattern Search**: 150x faster (100µs vs 15ms)
209
- - **Batch Insert**: 500x faster (2ms vs 1s for 100 patterns)
210
- - **Large-scale Query**: 12,500x faster (8ms vs 100s at 1M patterns)
211
-
212
- ### Memory Efficiency
213
- - **Binary Quantization**: 32x reduction (768-dim → 96 bytes)
214
- - **Scalar Quantization**: 4x reduction (768-dim → 768 bytes)
215
- - **Product Quantization**: 8-16x reduction (768-dim → 48-96 bytes)
216
-
217
- ### Latency
218
- - **Vector Search**: <100µs (HNSW)
219
- - **Pattern Retrieval**: <1ms (with cache)
220
- - **QUIC Sync**: <1ms (sub-millisecond)
221
-
222
- ## Backward Compatibility
223
-
224
- AgentDB provides **100% backward compatibility** with the legacy ReasoningBank API:
225
-
226
- ```typescript
227
- // All existing ReasoningBank methods work unchanged
228
- import { retrieveMemories, judgeTrajectory, distillMemories } from 'agentic-flow/reasoningbank';
229
-
230
- // Legacy API continues to work
231
- const memories = await retrieveMemories(query, { domain, agent });
232
- const verdict = await judgeTrajectory(trajectory, query);
233
- const newMemories = await distillMemories(trajectory, verdict, query, metadata);
234
-
235
- // New AgentDB adapter for enhanced features
236
- import { createAgentDBAdapter } from 'agentic-flow/reasoningbank';
237
- const adapter = await createAgentDBAdapter();
238
- ```
239
-
240
- ## Environment Variables
241
-
242
- ```bash
243
- # Enable/disable ReasoningBank
244
- REASONINGBANK_ENABLED=true
245
-
246
- # Database path (legacy)
247
- CLAUDE_FLOW_DB_PATH=.swarm/memory.db
248
-
249
- # AgentDB path (new)
250
- AGENTDB_PATH=.agentdb/reasoningbank.db
251
-
252
- # Enable AgentDB by default
253
- AGENTDB_ENABLED=true
254
-
255
- # Enable learning plugins
256
- AGENTDB_LEARNING=true
257
-
258
- # Enable reasoning agents
259
- AGENTDB_REASONING=true
260
-
261
- # Enable QUIC sync
262
- AGENTDB_QUIC_SYNC=false
263
- AGENTDB_QUIC_PORT=4433
264
- AGENTDB_QUIC_PEERS=host1:4433,host2:4433
265
- ```
266
-
267
- ## Examples
268
-
269
- ### Complete Example
270
-
271
- ```typescript
272
- import {
273
- createAgentDBAdapter,
274
- computeEmbedding,
275
- formatMemoriesForPrompt
276
- } from 'agentic-flow/reasoningbank';
277
-
278
- async function main() {
279
- // Initialize adapter
280
- const adapter = await createAgentDBAdapter({
281
- enableLearning: true,
282
- enableReasoning: true,
283
- });
284
-
285
- // Compute query embedding
286
- const query = 'How to implement authentication?';
287
- const queryEmbedding = await computeEmbedding(query);
288
-
289
- // Retrieve with reasoning
290
- const result = await adapter.retrieveWithReasoning(queryEmbedding, {
291
- domain: 'backend',
292
- synthesizeContext: true,
293
- useMMR: true,
294
- k: 5,
295
- });
296
-
297
- // Format for prompt
298
- const formattedMemories = formatMemoriesForPrompt(result.memories);
299
-
300
- console.log('Retrieved Memories:', formattedMemories);
301
- console.log('Context:', result.context);
302
-
303
- // Insert new pattern after successful implementation
304
- await adapter.insertPattern({
305
- id: '',
306
- type: 'pattern',
307
- domain: 'backend',
308
- pattern_data: JSON.stringify({
309
- embedding: queryEmbedding,
310
- pattern: {
311
- query,
312
- solution: 'Use JWT tokens with refresh tokens...',
313
- code: 'import jwt from "jsonwebtoken";...'
314
- }
315
- }),
316
- confidence: 0.95,
317
- usage_count: 1,
318
- success_count: 1,
319
- created_at: Date.now(),
320
- last_used: Date.now(),
321
- });
322
-
323
- // Train learning model
324
- await adapter.train({ epochs: 10 });
325
-
326
- // Cleanup
327
- await adapter.close();
328
- }
329
-
330
- main().catch(console.error);
331
- ```
332
-
333
- ## Troubleshooting
334
-
335
- ### Common Issues
336
-
337
- **Issue**: `AgentDB not found`
338
- ```bash
339
- # Ensure AgentDB is built
340
- cd packages/agentdb
341
- npm run build
342
- ```
343
-
344
- **Issue**: `Migration fails`
345
- ```bash
346
- # Check source database exists
347
- ls -la .swarm/memory.db
348
-
349
- # Run with verbose logging
350
- DEBUG=agentdb:* agentdb migrate --source .swarm/memory.db
351
- ```
352
-
353
- **Issue**: `Performance not improved`
354
- ```typescript
355
- // Ensure HNSW indexing is enabled
356
- const adapter = await createAgentDBAdapter({
357
- quantizationType: 'scalar', // Enable quantization
358
- cacheSize: 1000, // Enable caching
359
- });
360
- ```
361
-
362
- ## API Reference
363
-
364
- See the complete API documentation in:
365
- - `/packages/agentdb/docs/integration/IMPLEMENTATION_SUMMARY.md`
366
- - `/packages/agentdb/docs/integration/README.md`
367
-
368
- ## Support
369
-
370
- For issues or questions:
371
- - GitHub Issues: https://github.com/ruvnet/agentic-flow/issues
372
- - Documentation: https://github.com/ruvnet/agentic-flow/tree/main/packages/agentdb
373
-
374
- ---
375
-
376
- **Status**: ✅ Production Ready
377
- **Version**: 1.0.0
378
- **Performance**: 150x-12,500x faster
379
- **Compatibility**: 100% backward compatible