agentic-flow 1.7.2 → 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 -91
- 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/skills-manager.js +3 -1
- 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,38 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* ReasoningBank
|
|
2
|
+
* ReasoningBank - Closed-loop memory system for AI agents
|
|
3
|
+
* Based on arXiv:2509.25140 (Google DeepMind)
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* Paper: https://arxiv.org/html/2509.25140v1
|
|
7
|
-
*
|
|
8
|
-
* This is the Node.js backend using SQLite for persistent storage.
|
|
9
|
-
* For browser environments, use './wasm-adapter.js' instead.
|
|
10
|
-
* For automatic backend selection, use './backend-selector.js'.
|
|
5
|
+
* @since v1.7.0 - Integrated AgentDB for optimal performance
|
|
11
6
|
*/
|
|
12
|
-
//
|
|
7
|
+
// New hybrid backend (recommended for new code)
|
|
8
|
+
export { HybridReasoningBank } from './HybridBackend.js';
|
|
9
|
+
export { AdvancedMemorySystem } from './AdvancedMemory.js';
|
|
10
|
+
// Re-export AgentDB controllers for advanced usage
|
|
11
|
+
export { ReflexionMemory } from 'agentdb/controllers/ReflexionMemory';
|
|
12
|
+
export { SkillLibrary } from 'agentdb/controllers/SkillLibrary';
|
|
13
|
+
export { CausalMemoryGraph } from 'agentdb/controllers/CausalMemoryGraph';
|
|
14
|
+
export { CausalRecall } from 'agentdb/controllers/CausalRecall';
|
|
15
|
+
export { NightlyLearner } from 'agentdb/controllers/NightlyLearner';
|
|
16
|
+
export { EmbeddingService } from 'agentdb/controllers/EmbeddingService';
|
|
17
|
+
// Original ReasoningBank implementations (backwards compatibility)
|
|
13
18
|
export { retrieveMemories, formatMemoriesForPrompt } from './core/retrieve.js';
|
|
14
19
|
export { judgeTrajectory } from './core/judge.js';
|
|
15
20
|
export { distillMemories } from './core/distill.js';
|
|
16
21
|
export { consolidate, shouldConsolidate } from './core/consolidate.js';
|
|
17
22
|
export { mattsParallel, mattsSequential } from './core/matts.js';
|
|
18
|
-
// Utilities
|
|
19
23
|
export { computeEmbedding, clearEmbeddingCache } from './utils/embeddings.js';
|
|
20
24
|
export { mmrSelection, cosineSimilarity } from './utils/mmr.js';
|
|
21
25
|
export { scrubPII, containsPII, scrubMemory } from './utils/pii-scrubber.js';
|
|
22
26
|
export { loadConfig } from './utils/config.js';
|
|
23
|
-
//
|
|
24
|
-
import { loadConfig } from './utils/config.js';
|
|
27
|
+
// Re-export database utilities
|
|
25
28
|
import * as db from './db/queries.js';
|
|
29
|
+
export { db };
|
|
30
|
+
// Original functions (backwards compatibility)
|
|
31
|
+
import { loadConfig } from './utils/config.js';
|
|
26
32
|
import { retrieveMemories } from './core/retrieve.js';
|
|
27
33
|
import { judgeTrajectory } from './core/judge.js';
|
|
28
34
|
import { distillMemories } from './core/distill.js';
|
|
29
|
-
import { shouldConsolidate, consolidate } from './core/consolidate.js';
|
|
30
|
-
// Database
|
|
31
|
-
export { db };
|
|
32
|
-
/**
|
|
33
|
-
* Initialize ReasoningBank
|
|
34
|
-
* Run migrations and check configuration
|
|
35
|
-
*/
|
|
35
|
+
import { shouldConsolidate as shouldCons, consolidate as cons } from './core/consolidate.js';
|
|
36
36
|
export async function initialize() {
|
|
37
37
|
const config = loadConfig();
|
|
38
38
|
console.log('[ReasoningBank] Initializing...');
|
|
@@ -40,7 +40,6 @@ export async function initialize() {
|
|
|
40
40
|
console.log(`[ReasoningBank] Database: ${process.env.CLAUDE_FLOW_DB_PATH || '.swarm/memory.db'}`);
|
|
41
41
|
console.log(`[ReasoningBank] Embeddings: ${config.embeddings.provider}`);
|
|
42
42
|
console.log(`[ReasoningBank] Retrieval k: ${config.retrieve.k}`);
|
|
43
|
-
// Run migrations to create database and tables
|
|
44
43
|
try {
|
|
45
44
|
await db.runMigrations();
|
|
46
45
|
console.log(`[ReasoningBank] Database migrated successfully`);
|
|
@@ -49,7 +48,6 @@ export async function initialize() {
|
|
|
49
48
|
console.error('[ReasoningBank] Migration error:', error);
|
|
50
49
|
throw new Error('ReasoningBank initialization failed: could not run migrations');
|
|
51
50
|
}
|
|
52
|
-
// Check database connection
|
|
53
51
|
try {
|
|
54
52
|
const dbConn = db.getDb();
|
|
55
53
|
const tables = dbConn.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name LIKE 'pattern%'").all();
|
|
@@ -61,48 +59,29 @@ export async function initialize() {
|
|
|
61
59
|
}
|
|
62
60
|
console.log('[ReasoningBank] Initialization complete');
|
|
63
61
|
}
|
|
64
|
-
/**
|
|
65
|
-
* Full task execution with ReasoningBank
|
|
66
|
-
* Combines retrieve → execute → judge → distill → consolidate
|
|
67
|
-
*/
|
|
68
62
|
export async function runTask(options) {
|
|
69
63
|
console.log(`[ReasoningBank] Running task: ${options.taskId}`);
|
|
70
|
-
// 1. Retrieve memories
|
|
71
64
|
const memories = await retrieveMemories(options.query, {
|
|
72
65
|
domain: options.domain,
|
|
73
66
|
agent: options.agentId
|
|
74
67
|
});
|
|
75
68
|
console.log(`[ReasoningBank] Retrieved ${memories.length} memories`);
|
|
76
|
-
// 2. Execute task with memories
|
|
77
69
|
const trajectory = await options.executeFn(memories);
|
|
78
|
-
// 3. Judge trajectory
|
|
79
70
|
const verdict = await judgeTrajectory(trajectory, options.query);
|
|
80
71
|
console.log(`[ReasoningBank] Verdict: ${verdict.label} (${verdict.confidence})`);
|
|
81
|
-
// 4. Distill new memories
|
|
82
72
|
const newMemories = await distillMemories(trajectory, verdict, options.query, {
|
|
83
73
|
taskId: options.taskId,
|
|
84
74
|
agentId: options.agentId,
|
|
85
75
|
domain: options.domain
|
|
86
76
|
});
|
|
87
77
|
console.log(`[ReasoningBank] Distilled ${newMemories.length} new memories`);
|
|
88
|
-
// 5. Consolidate if needed
|
|
89
78
|
let consolidated = false;
|
|
90
|
-
if (
|
|
79
|
+
if (shouldCons()) {
|
|
91
80
|
console.log('[ReasoningBank] Running consolidation...');
|
|
92
|
-
await
|
|
81
|
+
await cons();
|
|
93
82
|
consolidated = true;
|
|
94
83
|
}
|
|
95
|
-
return {
|
|
96
|
-
verdict,
|
|
97
|
-
usedMemories: memories,
|
|
98
|
-
newMemories,
|
|
99
|
-
consolidated
|
|
100
|
-
};
|
|
84
|
+
return { verdict, usedMemories: memories, newMemories, consolidated };
|
|
101
85
|
}
|
|
102
|
-
|
|
103
|
-
// Ultra-fast vector database drop-in replacement
|
|
104
|
-
// 150x-12,500x faster than legacy implementation
|
|
105
|
-
export { createAgentDBAdapter, createDefaultAgentDBAdapter, migrateToAgentDB, validateMigration } from './agentdb-adapter.js';
|
|
106
|
-
// Version info
|
|
107
|
-
export const VERSION = '1.0.0';
|
|
86
|
+
export const VERSION = '1.7.1';
|
|
108
87
|
export const PAPER_URL = 'https://arxiv.org/html/2509.25140v1';
|
package/dist/utils/cli.js
CHANGED
|
@@ -49,16 +49,6 @@ export function parseArgs() {
|
|
|
49
49
|
options.mode = 'reasoningbank';
|
|
50
50
|
return options;
|
|
51
51
|
}
|
|
52
|
-
// Check for agentdb command
|
|
53
|
-
if (args[0] === 'agentdb') {
|
|
54
|
-
options.mode = 'agentdb';
|
|
55
|
-
return options;
|
|
56
|
-
}
|
|
57
|
-
// Check for skills command
|
|
58
|
-
if (args[0] === 'skills') {
|
|
59
|
-
options.mode = 'skills';
|
|
60
|
-
return options;
|
|
61
|
-
}
|
|
62
52
|
for (let i = 0; i < args.length; i++) {
|
|
63
53
|
const arg = args[i];
|
|
64
54
|
switch (arg) {
|
|
@@ -165,7 +155,6 @@ USAGE:
|
|
|
165
155
|
npx agentic-flow [COMMAND] [OPTIONS]
|
|
166
156
|
|
|
167
157
|
COMMANDS:
|
|
168
|
-
skills <command> Claude Code Skills management (init, create, list)
|
|
169
158
|
reasoningbank <cmd> Memory system that learns from experience (demo, test, init)
|
|
170
159
|
claude-code [options] Spawn Claude Code with proxy + Agent Booster (57x faster edits)
|
|
171
160
|
mcp <command> [server] Manage MCP servers (start, stop, status, list)
|
|
@@ -182,12 +171,6 @@ REASONINGBANK COMMANDS:
|
|
|
182
171
|
npx agentic-flow reasoningbank benchmark Run performance benchmarks
|
|
183
172
|
npx agentic-flow reasoningbank status Show memory statistics
|
|
184
173
|
|
|
185
|
-
SKILLS COMMANDS:
|
|
186
|
-
npx agentic-flow skills init [location] Initialize skills directories (personal/project/both)
|
|
187
|
-
npx agentic-flow skills create Create example agentic-flow skills
|
|
188
|
-
npx agentic-flow skills list List all installed skills
|
|
189
|
-
npx agentic-flow skills help Show skills help
|
|
190
|
-
|
|
191
174
|
MCP COMMANDS:
|
|
192
175
|
npx agentic-flow mcp start [server] Start MCP server(s)
|
|
193
176
|
npx agentic-flow mcp stop [server] Stop MCP server(s)
|
|
@@ -233,11 +216,6 @@ OPTIONS:
|
|
|
233
216
|
--help, -h Show this help message
|
|
234
217
|
|
|
235
218
|
EXAMPLES:
|
|
236
|
-
# Skills (Claude Code integration!)
|
|
237
|
-
npx agentic-flow skills init # Initialize skills directories
|
|
238
|
-
npx agentic-flow skills create # Create agentdb-quickstart skill
|
|
239
|
-
npx agentic-flow skills list # List all installed skills
|
|
240
|
-
|
|
241
219
|
# ReasoningBank (Learn from agent experience!)
|
|
242
220
|
npx agentic-flow reasoningbank demo # See 0% → 100% success transformation
|
|
243
221
|
npx agentic-flow reasoningbank test # Run 27 validation tests
|
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
# AgentDB CLI - Local Testing Guide
|
|
2
|
+
|
|
3
|
+
## Quick Start
|
|
4
|
+
|
|
5
|
+
### Option 1: Run the Full Test Suite (Recommended)
|
|
6
|
+
```bash
|
|
7
|
+
# From the project root: /workspaces/agentic-flow/agentic-flow
|
|
8
|
+
./scripts/test-agentdb.sh
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
This will run 13 comprehensive tests covering all CLI features!
|
|
12
|
+
|
|
13
|
+
### Option 2: Manual Testing
|
|
14
|
+
|
|
15
|
+
#### 1. Ensure you're in the correct directory
|
|
16
|
+
```bash
|
|
17
|
+
cd /workspaces/agentic-flow/agentic-flow
|
|
18
|
+
pwd # Should show: /workspaces/agentic-flow/agentic-flow
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
#### 2. Build the Project (if not already built)
|
|
22
|
+
```bash
|
|
23
|
+
npm run build
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
#### 3. Test the CLI Directly
|
|
27
|
+
```bash
|
|
28
|
+
# Show help (all 17 commands)
|
|
29
|
+
node dist/agentdb/cli/agentdb-cli.js --help
|
|
30
|
+
|
|
31
|
+
# Or use npx (if globally installed)
|
|
32
|
+
npx agentdb --help
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### 3. Create a Test Database
|
|
36
|
+
```bash
|
|
37
|
+
# Set database path
|
|
38
|
+
export AGENTDB_PATH=./test-agentdb.db
|
|
39
|
+
|
|
40
|
+
# Or specify inline for each command
|
|
41
|
+
AGENTDB_PATH=./test-agentdb.db node dist/agentdb/cli/agentdb-cli.js db stats
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Test Each Command Category
|
|
45
|
+
|
|
46
|
+
### 🧠 Reflexion Memory (Episodic Replay)
|
|
47
|
+
```bash
|
|
48
|
+
# Store an episode with self-critique
|
|
49
|
+
node dist/agentdb/cli/agentdb-cli.js reflexion store \
|
|
50
|
+
"session-1" \
|
|
51
|
+
"implement_authentication" \
|
|
52
|
+
0.95 \
|
|
53
|
+
true \
|
|
54
|
+
"Successfully used OAuth2 with JWT tokens" \
|
|
55
|
+
"User login requirement" \
|
|
56
|
+
"Working auth system" \
|
|
57
|
+
1200 \
|
|
58
|
+
5000
|
|
59
|
+
|
|
60
|
+
# Store a failed episode
|
|
61
|
+
node dist/agentdb/cli/agentdb-cli.js reflexion store \
|
|
62
|
+
"session-1" \
|
|
63
|
+
"implement_authentication" \
|
|
64
|
+
0.3 \
|
|
65
|
+
false \
|
|
66
|
+
"Forgot to validate tokens properly" \
|
|
67
|
+
"User login requirement" \
|
|
68
|
+
"Insecure auth" \
|
|
69
|
+
800 \
|
|
70
|
+
3000
|
|
71
|
+
|
|
72
|
+
# Retrieve relevant episodes
|
|
73
|
+
node dist/agentdb/cli/agentdb-cli.js reflexion retrieve \
|
|
74
|
+
"authentication" \
|
|
75
|
+
5 \
|
|
76
|
+
0.5
|
|
77
|
+
|
|
78
|
+
# Get critique summary from failures
|
|
79
|
+
node dist/agentdb/cli/agentdb-cli.js reflexion critique-summary \
|
|
80
|
+
"authentication" \
|
|
81
|
+
true
|
|
82
|
+
|
|
83
|
+
# Prune old episodes
|
|
84
|
+
node dist/agentdb/cli/agentdb-cli.js reflexion prune 30 0.2
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### 🛠️ Skill Library (Lifelong Learning)
|
|
88
|
+
```bash
|
|
89
|
+
# Create a skill manually
|
|
90
|
+
node dist/agentdb/cli/agentdb-cli.js skill create \
|
|
91
|
+
"jwt_authentication" \
|
|
92
|
+
"Generate and validate JWT tokens for user authentication" \
|
|
93
|
+
"function generateJWT(payload) { return jwt.sign(payload, secret); }"
|
|
94
|
+
|
|
95
|
+
# Search for skills
|
|
96
|
+
node dist/agentdb/cli/agentdb-cli.js skill search \
|
|
97
|
+
"authentication tokens" \
|
|
98
|
+
5
|
|
99
|
+
|
|
100
|
+
# Auto-consolidate episodes into skills
|
|
101
|
+
node dist/agentdb/cli/agentdb-cli.js skill consolidate \
|
|
102
|
+
3 \
|
|
103
|
+
0.7 \
|
|
104
|
+
7
|
|
105
|
+
|
|
106
|
+
# Prune underperforming skills
|
|
107
|
+
node dist/agentdb/cli/agentdb-cli.js skill prune \
|
|
108
|
+
3 \
|
|
109
|
+
0.4 \
|
|
110
|
+
60
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### 🔗 Causal Memory Graph (Intervention-Based)
|
|
114
|
+
```bash
|
|
115
|
+
# Add a causal edge manually
|
|
116
|
+
node dist/agentdb/cli/agentdb-cli.js causal add-edge \
|
|
117
|
+
"add_unit_tests" \
|
|
118
|
+
"code_quality_score" \
|
|
119
|
+
0.25 \
|
|
120
|
+
0.95 \
|
|
121
|
+
100
|
|
122
|
+
|
|
123
|
+
# Create an A/B experiment
|
|
124
|
+
node dist/agentdb/cli/agentdb-cli.js causal experiment create \
|
|
125
|
+
"test-coverage-vs-bugs" \
|
|
126
|
+
"test_coverage" \
|
|
127
|
+
"bug_rate"
|
|
128
|
+
|
|
129
|
+
# Add observations (treatment group)
|
|
130
|
+
node dist/agentdb/cli/agentdb-cli.js causal experiment add-observation \
|
|
131
|
+
1 \
|
|
132
|
+
true \
|
|
133
|
+
0.15 \
|
|
134
|
+
'{"coverage": 0.85}'
|
|
135
|
+
|
|
136
|
+
# Add observations (control group)
|
|
137
|
+
node dist/agentdb/cli/agentdb-cli.js causal experiment add-observation \
|
|
138
|
+
1 \
|
|
139
|
+
false \
|
|
140
|
+
0.35 \
|
|
141
|
+
'{"coverage": 0.45}'
|
|
142
|
+
|
|
143
|
+
# Calculate uplift
|
|
144
|
+
node dist/agentdb/cli/agentdb-cli.js causal experiment calculate 1
|
|
145
|
+
|
|
146
|
+
# Query causal edges
|
|
147
|
+
node dist/agentdb/cli/agentdb-cli.js causal query \
|
|
148
|
+
"test" \
|
|
149
|
+
"quality" \
|
|
150
|
+
0.6 \
|
|
151
|
+
0.1 \
|
|
152
|
+
10
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### 🔍 Causal Recall (Utility-Based Reranking)
|
|
156
|
+
```bash
|
|
157
|
+
# Retrieve with causal utility and provenance certificate
|
|
158
|
+
node dist/agentdb/cli/agentdb-cli.js recall with-certificate \
|
|
159
|
+
"implement secure authentication" \
|
|
160
|
+
10 \
|
|
161
|
+
0.7 \
|
|
162
|
+
0.2 \
|
|
163
|
+
0.1
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### 🌙 Nightly Learner (Automated Discovery)
|
|
167
|
+
```bash
|
|
168
|
+
# Discover causal edges from patterns (dry run)
|
|
169
|
+
node dist/agentdb/cli/agentdb-cli.js learner run \
|
|
170
|
+
3 \
|
|
171
|
+
0.6 \
|
|
172
|
+
0.7 \
|
|
173
|
+
true
|
|
174
|
+
|
|
175
|
+
# Discover and save edges
|
|
176
|
+
node dist/agentdb/cli/agentdb-cli.js learner run \
|
|
177
|
+
3 \
|
|
178
|
+
0.6 \
|
|
179
|
+
0.7 \
|
|
180
|
+
false
|
|
181
|
+
|
|
182
|
+
# Prune low-quality edges
|
|
183
|
+
node dist/agentdb/cli/agentdb-cli.js learner prune \
|
|
184
|
+
0.5 \
|
|
185
|
+
0.05 \
|
|
186
|
+
90
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### 📊 Database Stats
|
|
190
|
+
```bash
|
|
191
|
+
# Get comprehensive database statistics
|
|
192
|
+
node dist/agentdb/cli/agentdb-cli.js db stats
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Full Workflow Example
|
|
196
|
+
|
|
197
|
+
### Scenario: Learning from Authentication Implementation
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
#!/bin/bash
|
|
201
|
+
|
|
202
|
+
# Set up test database
|
|
203
|
+
export AGENTDB_PATH=./auth-learning.db
|
|
204
|
+
|
|
205
|
+
# 1. Store successful attempts
|
|
206
|
+
node dist/agentdb/cli/agentdb-cli.js reflexion store \
|
|
207
|
+
"session-auth-1" "oauth2_implementation" 0.95 true \
|
|
208
|
+
"Used industry-standard OAuth2 flow" \
|
|
209
|
+
"Implement secure login" "Working OAuth2 system" 1500 6000
|
|
210
|
+
|
|
211
|
+
node dist/agentdb/cli/agentdb-cli.js reflexion store \
|
|
212
|
+
"session-auth-2" "jwt_tokens" 0.90 true \
|
|
213
|
+
"JWT with proper expiration and refresh tokens" \
|
|
214
|
+
"Token management" "Secure JWT system" 1200 5500
|
|
215
|
+
|
|
216
|
+
# 2. Store failed attempts
|
|
217
|
+
node dist/agentdb/cli/agentdb-cli.js reflexion store \
|
|
218
|
+
"session-auth-3" "session_storage" 0.35 false \
|
|
219
|
+
"Insecure session storage in localStorage" \
|
|
220
|
+
"Session management" "Security vulnerability" 800 3000
|
|
221
|
+
|
|
222
|
+
# 3. Create a skill from successful pattern
|
|
223
|
+
node dist/agentdb/cli/agentdb-cli.js skill create \
|
|
224
|
+
"secure_oauth2_jwt" \
|
|
225
|
+
"OAuth2 flow with JWT token management" \
|
|
226
|
+
"const auth = { oauth2: true, jwt: true, refresh: true }"
|
|
227
|
+
|
|
228
|
+
# 4. Add causal edge
|
|
229
|
+
node dist/agentdb/cli/agentdb-cli.js causal add-edge \
|
|
230
|
+
"add_token_refresh" "session_security" 0.40 0.92 50
|
|
231
|
+
|
|
232
|
+
# 5. Query for authentication guidance
|
|
233
|
+
node dist/agentdb/cli/agentdb-cli.js reflexion retrieve \
|
|
234
|
+
"secure authentication" 5 0.8
|
|
235
|
+
|
|
236
|
+
# 6. Get critique summary of what NOT to do
|
|
237
|
+
node dist/agentdb/cli/agentdb-cli.js reflexion critique-summary \
|
|
238
|
+
"authentication" true
|
|
239
|
+
|
|
240
|
+
# 7. Search for applicable skills
|
|
241
|
+
node dist/agentdb/cli/agentdb-cli.js skill search \
|
|
242
|
+
"oauth jwt tokens" 3
|
|
243
|
+
|
|
244
|
+
# 8. Check database stats
|
|
245
|
+
node dist/agentdb/cli/agentdb-cli.js db stats
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## Verify Installation
|
|
249
|
+
|
|
250
|
+
### Check Binary Links
|
|
251
|
+
```bash
|
|
252
|
+
# Should show the CLI binary path
|
|
253
|
+
which agentdb
|
|
254
|
+
|
|
255
|
+
# Or check npm bin
|
|
256
|
+
npm bin agentdb
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### Run from Package
|
|
260
|
+
```bash
|
|
261
|
+
# If you've run npm install -g or npm link
|
|
262
|
+
agentdb --help
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
## Environment Variables
|
|
266
|
+
|
|
267
|
+
```bash
|
|
268
|
+
# Database path (default: ./agentdb.db)
|
|
269
|
+
export AGENTDB_PATH=/path/to/your/database.db
|
|
270
|
+
|
|
271
|
+
# Example with custom path
|
|
272
|
+
AGENTDB_PATH=~/my-agent-memory.db node dist/agentdb/cli/agentdb-cli.js db stats
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
## Expected Output Examples
|
|
276
|
+
|
|
277
|
+
### Successful Episode Storage
|
|
278
|
+
```
|
|
279
|
+
✓ Stored episode #1 (session: session-1, task: implement_authentication)
|
|
280
|
+
Reward: 0.95 | Success: true | Latency: 1200ms | Tokens: 5000
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### Skill Search Results
|
|
284
|
+
```
|
|
285
|
+
🔍 Found 3 skills for "authentication"
|
|
286
|
+
|
|
287
|
+
#1: jwt_authentication (success rate: 0.90, uses: 5)
|
|
288
|
+
Generate and validate JWT tokens for user authentication
|
|
289
|
+
|
|
290
|
+
#2: oauth2_flow (success rate: 0.85, uses: 3)
|
|
291
|
+
Complete OAuth2 authorization code flow
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### Database Stats
|
|
295
|
+
```
|
|
296
|
+
AgentDB Statistics
|
|
297
|
+
|
|
298
|
+
Episodes: 15
|
|
299
|
+
Skills: 8
|
|
300
|
+
Causal Edges: 12
|
|
301
|
+
Experiments: 3
|
|
302
|
+
Certificates: 5
|
|
303
|
+
|
|
304
|
+
Total Size: 2.4 MB
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
## Troubleshooting
|
|
308
|
+
|
|
309
|
+
### Issue: "Cannot find module"
|
|
310
|
+
```bash
|
|
311
|
+
# Rebuild the project
|
|
312
|
+
npm run build
|
|
313
|
+
|
|
314
|
+
# Check dist folder exists
|
|
315
|
+
ls dist/agentdb/cli/agentdb-cli.js
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
### Issue: "Database is locked"
|
|
319
|
+
```bash
|
|
320
|
+
# Close any open database connections
|
|
321
|
+
# Or use a different database path
|
|
322
|
+
export AGENTDB_PATH=./test2-agentdb.db
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
### Issue: "Permission denied"
|
|
326
|
+
```bash
|
|
327
|
+
# Make CLI executable
|
|
328
|
+
chmod +x dist/agentdb/cli/agentdb-cli.js
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
## Advanced Testing
|
|
332
|
+
|
|
333
|
+
### Test with Programmatic API
|
|
334
|
+
```typescript
|
|
335
|
+
import { AgentDBCLI } from './dist/agentdb/cli/agentdb-cli.js';
|
|
336
|
+
|
|
337
|
+
const cli = new AgentDBCLI('./test.db');
|
|
338
|
+
|
|
339
|
+
// Store episode
|
|
340
|
+
await cli.reflexionStore({
|
|
341
|
+
sessionId: 'test-1',
|
|
342
|
+
task: 'example',
|
|
343
|
+
reward: 0.9,
|
|
344
|
+
success: true,
|
|
345
|
+
critique: 'Good approach'
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
// Retrieve episodes
|
|
349
|
+
await cli.reflexionRetrieve({
|
|
350
|
+
task: 'example',
|
|
351
|
+
k: 5
|
|
352
|
+
});
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
### Integration with Your Project
|
|
356
|
+
```typescript
|
|
357
|
+
// In your agent code
|
|
358
|
+
import { AgentDBCLI } from 'agentic-flow/agentdb';
|
|
359
|
+
|
|
360
|
+
const memory = new AgentDBCLI();
|
|
361
|
+
|
|
362
|
+
// Learn from task outcomes
|
|
363
|
+
async function learnFromTask(task, outcome) {
|
|
364
|
+
await memory.reflexionStore({
|
|
365
|
+
sessionId: getCurrentSession(),
|
|
366
|
+
task: task.name,
|
|
367
|
+
reward: outcome.score,
|
|
368
|
+
success: outcome.passed,
|
|
369
|
+
critique: outcome.feedback,
|
|
370
|
+
input: task.input,
|
|
371
|
+
output: outcome.result,
|
|
372
|
+
latencyMs: outcome.duration,
|
|
373
|
+
tokensUsed: outcome.tokens
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
// Retrieve similar past experiences
|
|
378
|
+
async function recallSimilar(task) {
|
|
379
|
+
return await memory.reflexionRetrieve({
|
|
380
|
+
task: task.name,
|
|
381
|
+
k: 5,
|
|
382
|
+
minReward: 0.7
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
## Performance Benchmarks
|
|
388
|
+
|
|
389
|
+
```bash
|
|
390
|
+
# Time a full workflow
|
|
391
|
+
time bash full-workflow-example.sh
|
|
392
|
+
|
|
393
|
+
# Check database performance
|
|
394
|
+
node dist/agentdb/cli/agentdb-cli.js db stats
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
## Next Steps
|
|
398
|
+
|
|
399
|
+
1. ✅ Test basic commands (reflexion, skill)
|
|
400
|
+
2. ✅ Test causal features (edges, experiments)
|
|
401
|
+
3. ✅ Run nightly learner for discovery
|
|
402
|
+
4. ✅ Verify causal recall with certificates
|
|
403
|
+
5. ✅ Check database stats
|
|
404
|
+
6. 🚀 Integrate into your agent workflows
|
|
405
|
+
|
|
406
|
+
## Resources
|
|
407
|
+
|
|
408
|
+
- **AgentDB Controllers**: `/src/agentdb/controllers/`
|
|
409
|
+
- **CLI Source**: `/src/agentdb/cli/agentdb-cli.ts`
|
|
410
|
+
- **Tests**: `/src/agentdb/tests/frontier-features.test.ts`
|
|
411
|
+
- **Binary**: `/dist/agentdb/cli/agentdb-cli.js`
|