agentic-flow 1.7.3 → 1.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/agents/test-neural.md +0 -5
- package/.claude/answer.md +1 -0
- package/.claude/settings.json +19 -20
- package/CHANGELOG.md +0 -117
- package/README.md +17 -81
- package/dist/agentdb/benchmarks/comprehensive-benchmark.js +664 -0
- package/dist/agentdb/benchmarks/frontier-benchmark.js +419 -0
- package/dist/agentdb/benchmarks/reflexion-benchmark.js +370 -0
- package/dist/agentdb/cli/agentdb-cli.js +717 -0
- package/dist/agentdb/controllers/CausalMemoryGraph.js +322 -0
- package/dist/agentdb/controllers/CausalRecall.js +281 -0
- package/dist/agentdb/controllers/EmbeddingService.js +118 -0
- package/dist/agentdb/controllers/ExplainableRecall.js +387 -0
- package/dist/agentdb/controllers/NightlyLearner.js +382 -0
- package/dist/agentdb/controllers/ReflexionMemory.js +239 -0
- package/dist/agentdb/controllers/SkillLibrary.js +276 -0
- package/dist/agentdb/controllers/frontier-index.js +9 -0
- package/dist/agentdb/controllers/index.js +8 -0
- package/dist/agentdb/index.js +32 -0
- package/dist/agentdb/optimizations/BatchOperations.js +198 -0
- package/dist/agentdb/optimizations/QueryOptimizer.js +225 -0
- package/dist/agentdb/optimizations/index.js +7 -0
- package/dist/agentdb/tests/frontier-features.test.js +665 -0
- package/dist/cli-proxy.js +2 -33
- package/dist/mcp/standalone-stdio.js +200 -4
- package/dist/memory/SharedMemoryPool.js +211 -0
- package/dist/memory/index.js +6 -0
- package/dist/reasoningbank/AdvancedMemory.js +239 -0
- package/dist/reasoningbank/HybridBackend.js +305 -0
- package/dist/reasoningbank/index-new.js +87 -0
- package/dist/reasoningbank/index.js +23 -44
- package/dist/utils/cli.js +0 -22
- package/docs/AGENTDB_TESTING.md +411 -0
- package/docs/v1.7.1-QUICK-START.md +399 -0
- package/package.json +4 -4
- package/scripts/run-validation.sh +165 -0
- package/scripts/test-agentdb.sh +153 -0
- package/.claude/skills/agentdb-memory-patterns/SKILL.md +0 -166
- package/.claude/skills/agentdb-vector-search/SKILL.md +0 -126
- package/.claude/skills/agentic-flow/agentdb-memory-patterns/SKILL.md +0 -166
- package/.claude/skills/agentic-flow/agentdb-vector-search/SKILL.md +0 -126
- package/.claude/skills/agentic-flow/reasoningbank-intelligence/SKILL.md +0 -201
- package/.claude/skills/agentic-flow/swarm-orchestration/SKILL.md +0 -179
- package/.claude/skills/reasoningbank-intelligence/SKILL.md +0 -201
- package/.claude/skills/skill-builder/README.md +0 -308
- package/.claude/skills/skill-builder/SKILL.md +0 -910
- package/.claude/skills/skill-builder/docs/SPECIFICATION.md +0 -358
- package/.claude/skills/skill-builder/resources/schemas/skill-frontmatter.schema.json +0 -41
- package/.claude/skills/skill-builder/resources/templates/full-skill.template +0 -118
- package/.claude/skills/skill-builder/resources/templates/minimal-skill.template +0 -38
- package/.claude/skills/skill-builder/scripts/generate-skill.sh +0 -334
- package/.claude/skills/skill-builder/scripts/validate-skill.sh +0 -198
- package/.claude/skills/swarm-orchestration/SKILL.md +0 -179
- package/docs/AGENTDB_INTEGRATION.md +0 -379
|
@@ -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
|