@claude-flow/cli 3.7.0-alpha.3 → 3.7.0-alpha.30

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 (227) hide show
  1. package/.claude/helpers/hook-handler.cjs +6 -2
  2. package/.claude/helpers/statusline.cjs +31 -2
  3. package/.claude/helpers/statusline.js +35 -4
  4. package/README.md +43 -39
  5. package/bin/cli.js +15 -2
  6. package/bin/mcp-server.js +1 -1
  7. package/dist/src/commands/agent-wasm.js +2 -2
  8. package/dist/src/commands/agent-wasm.js.map +1 -1
  9. package/dist/src/commands/daemon.d.ts +20 -0
  10. package/dist/src/commands/daemon.d.ts.map +1 -1
  11. package/dist/src/commands/daemon.js +338 -3
  12. package/dist/src/commands/daemon.js.map +1 -1
  13. package/dist/src/commands/doctor.d.ts.map +1 -1
  14. package/dist/src/commands/doctor.js +224 -46
  15. package/dist/src/commands/doctor.js.map +1 -1
  16. package/dist/src/commands/hive-mind.d.ts.map +1 -1
  17. package/dist/src/commands/hive-mind.js +25 -7
  18. package/dist/src/commands/hive-mind.js.map +1 -1
  19. package/dist/src/commands/hooks.d.ts.map +1 -1
  20. package/dist/src/commands/hooks.js +56 -29
  21. package/dist/src/commands/hooks.js.map +1 -1
  22. package/dist/src/commands/memory.d.ts.map +1 -1
  23. package/dist/src/commands/memory.js +90 -3
  24. package/dist/src/commands/memory.js.map +1 -1
  25. package/dist/src/commands/start.js +1 -1
  26. package/dist/src/commands/start.js.map +1 -1
  27. package/dist/src/commands/swarm.js +1 -1
  28. package/dist/src/commands/swarm.js.map +1 -1
  29. package/dist/src/commands/task.d.ts.map +1 -1
  30. package/dist/src/commands/task.js +8 -4
  31. package/dist/src/commands/task.js.map +1 -1
  32. package/dist/src/config-adapter.js +1 -1
  33. package/dist/src/config-adapter.js.map +1 -1
  34. package/dist/src/index.d.ts +5 -1
  35. package/dist/src/index.d.ts.map +1 -1
  36. package/dist/src/index.js +61 -18
  37. package/dist/src/index.js.map +1 -1
  38. package/dist/src/init/executor.d.ts.map +1 -1
  39. package/dist/src/init/executor.js +92 -0
  40. package/dist/src/init/executor.js.map +1 -1
  41. package/dist/src/init/helpers-generator.d.ts.map +1 -1
  42. package/dist/src/init/helpers-generator.js +6 -2
  43. package/dist/src/init/helpers-generator.js.map +1 -1
  44. package/dist/src/init/mcp-generator.js +4 -4
  45. package/dist/src/init/mcp-generator.js.map +1 -1
  46. package/dist/src/init/settings-generator.d.ts.map +1 -1
  47. package/dist/src/init/settings-generator.js +44 -17
  48. package/dist/src/init/settings-generator.js.map +1 -1
  49. package/dist/src/init/statusline-generator.d.ts.map +1 -1
  50. package/dist/src/init/statusline-generator.js +25 -14
  51. package/dist/src/init/statusline-generator.js.map +1 -1
  52. package/dist/src/init/types.d.ts +7 -0
  53. package/dist/src/init/types.d.ts.map +1 -1
  54. package/dist/src/init/types.js.map +1 -1
  55. package/dist/src/mcp-client.d.ts.map +1 -1
  56. package/dist/src/mcp-client.js +12 -0
  57. package/dist/src/mcp-client.js.map +1 -1
  58. package/dist/src/mcp-tools/agent-execute-core.d.ts +3 -2
  59. package/dist/src/mcp-tools/agent-execute-core.d.ts.map +1 -1
  60. package/dist/src/mcp-tools/agent-execute-core.js +16 -9
  61. package/dist/src/mcp-tools/agent-execute-core.js.map +1 -1
  62. package/dist/src/mcp-tools/agent-tools.d.ts.map +1 -1
  63. package/dist/src/mcp-tools/agent-tools.js +88 -11
  64. package/dist/src/mcp-tools/agent-tools.js.map +1 -1
  65. package/dist/src/mcp-tools/agentdb-tools.d.ts +3 -0
  66. package/dist/src/mcp-tools/agentdb-tools.d.ts.map +1 -1
  67. package/dist/src/mcp-tools/agentdb-tools.js +206 -21
  68. package/dist/src/mcp-tools/agentdb-tools.js.map +1 -1
  69. package/dist/src/mcp-tools/analyze-tools.js +6 -6
  70. package/dist/src/mcp-tools/analyze-tools.js.map +1 -1
  71. package/dist/src/mcp-tools/autopilot-tools.js +10 -10
  72. package/dist/src/mcp-tools/autopilot-tools.js.map +1 -1
  73. package/dist/src/mcp-tools/browser-session-tools.js +5 -5
  74. package/dist/src/mcp-tools/browser-session-tools.js.map +1 -1
  75. package/dist/src/mcp-tools/browser-tools.js +23 -23
  76. package/dist/src/mcp-tools/browser-tools.js.map +1 -1
  77. package/dist/src/mcp-tools/claims-tools.js +12 -12
  78. package/dist/src/mcp-tools/claims-tools.js.map +1 -1
  79. package/dist/src/mcp-tools/config-tools.js +6 -6
  80. package/dist/src/mcp-tools/config-tools.js.map +1 -1
  81. package/dist/src/mcp-tools/coordination-tools.js +7 -7
  82. package/dist/src/mcp-tools/coordination-tools.js.map +1 -1
  83. package/dist/src/mcp-tools/daa-tools.js +8 -8
  84. package/dist/src/mcp-tools/daa-tools.js.map +1 -1
  85. package/dist/src/mcp-tools/embeddings-tools.js +10 -10
  86. package/dist/src/mcp-tools/embeddings-tools.js.map +1 -1
  87. package/dist/src/mcp-tools/github-tools.js +5 -5
  88. package/dist/src/mcp-tools/github-tools.js.map +1 -1
  89. package/dist/src/mcp-tools/guidance-tools.js +21 -21
  90. package/dist/src/mcp-tools/guidance-tools.js.map +1 -1
  91. package/dist/src/mcp-tools/hive-mind-tools.d.ts.map +1 -1
  92. package/dist/src/mcp-tools/hive-mind-tools.js +53 -9
  93. package/dist/src/mcp-tools/hive-mind-tools.js.map +1 -1
  94. package/dist/src/mcp-tools/hooks-tools.d.ts +2 -0
  95. package/dist/src/mcp-tools/hooks-tools.d.ts.map +1 -1
  96. package/dist/src/mcp-tools/hooks-tools.js +183 -48
  97. package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
  98. package/dist/src/mcp-tools/managed-agent-tools.d.ts +22 -0
  99. package/dist/src/mcp-tools/managed-agent-tools.d.ts.map +1 -0
  100. package/dist/src/mcp-tools/managed-agent-tools.js +357 -0
  101. package/dist/src/mcp-tools/managed-agent-tools.js.map +1 -0
  102. package/dist/src/mcp-tools/memory-tools.d.ts.map +1 -1
  103. package/dist/src/mcp-tools/memory-tools.js +400 -63
  104. package/dist/src/mcp-tools/memory-tools.js.map +1 -1
  105. package/dist/src/mcp-tools/neural-tools.d.ts.map +1 -1
  106. package/dist/src/mcp-tools/neural-tools.js +20 -7
  107. package/dist/src/mcp-tools/neural-tools.js.map +1 -1
  108. package/dist/src/mcp-tools/performance-tools.js +6 -6
  109. package/dist/src/mcp-tools/performance-tools.js.map +1 -1
  110. package/dist/src/mcp-tools/progress-tools.js +4 -4
  111. package/dist/src/mcp-tools/progress-tools.js.map +1 -1
  112. package/dist/src/mcp-tools/ruvllm-tools.js +10 -10
  113. package/dist/src/mcp-tools/ruvllm-tools.js.map +1 -1
  114. package/dist/src/mcp-tools/security-tools.d.ts.map +1 -1
  115. package/dist/src/mcp-tools/security-tools.js +34 -9
  116. package/dist/src/mcp-tools/security-tools.js.map +1 -1
  117. package/dist/src/mcp-tools/session-tools.d.ts.map +1 -1
  118. package/dist/src/mcp-tools/session-tools.js +130 -6
  119. package/dist/src/mcp-tools/session-tools.js.map +1 -1
  120. package/dist/src/mcp-tools/swarm-tools.d.ts.map +1 -1
  121. package/dist/src/mcp-tools/swarm-tools.js +76 -7
  122. package/dist/src/mcp-tools/swarm-tools.js.map +1 -1
  123. package/dist/src/mcp-tools/system-tools.d.ts.map +1 -1
  124. package/dist/src/mcp-tools/system-tools.js +91 -18
  125. package/dist/src/mcp-tools/system-tools.js.map +1 -1
  126. package/dist/src/mcp-tools/task-tools.d.ts.map +1 -1
  127. package/dist/src/mcp-tools/task-tools.js +55 -7
  128. package/dist/src/mcp-tools/task-tools.js.map +1 -1
  129. package/dist/src/mcp-tools/terminal-tools.js +5 -5
  130. package/dist/src/mcp-tools/terminal-tools.js.map +1 -1
  131. package/dist/src/mcp-tools/transfer-tools.js +11 -11
  132. package/dist/src/mcp-tools/transfer-tools.js.map +1 -1
  133. package/dist/src/mcp-tools/wasm-agent-tools.js +11 -11
  134. package/dist/src/mcp-tools/wasm-agent-tools.js.map +1 -1
  135. package/dist/src/mcp-tools/workflow-tools.d.ts.map +1 -1
  136. package/dist/src/mcp-tools/workflow-tools.js +118 -10
  137. package/dist/src/mcp-tools/workflow-tools.js.map +1 -1
  138. package/dist/src/memory/intelligence.d.ts.map +1 -1
  139. package/dist/src/memory/intelligence.js +28 -3
  140. package/dist/src/memory/intelligence.js.map +1 -1
  141. package/dist/src/memory/memory-bridge.d.ts +69 -0
  142. package/dist/src/memory/memory-bridge.d.ts.map +1 -1
  143. package/dist/src/memory/memory-bridge.js +282 -5
  144. package/dist/src/memory/memory-bridge.js.map +1 -1
  145. package/dist/src/memory/memory-initializer.d.ts +8 -0
  146. package/dist/src/memory/memory-initializer.d.ts.map +1 -1
  147. package/dist/src/memory/memory-initializer.js +80 -16
  148. package/dist/src/memory/memory-initializer.js.map +1 -1
  149. package/dist/src/memory/neural-package-bridge.d.ts +48 -0
  150. package/dist/src/memory/neural-package-bridge.d.ts.map +1 -0
  151. package/dist/src/memory/neural-package-bridge.js +87 -0
  152. package/dist/src/memory/neural-package-bridge.js.map +1 -0
  153. package/dist/src/memory/sona-optimizer.d.ts.map +1 -1
  154. package/dist/src/memory/sona-optimizer.js +3 -0
  155. package/dist/src/memory/sona-optimizer.js.map +1 -1
  156. package/dist/src/parser.d.ts +9 -0
  157. package/dist/src/parser.d.ts.map +1 -1
  158. package/dist/src/parser.js +11 -0
  159. package/dist/src/parser.js.map +1 -1
  160. package/dist/src/plugins/store/discovery.d.ts +6 -3
  161. package/dist/src/plugins/store/discovery.d.ts.map +1 -1
  162. package/dist/src/plugins/store/discovery.js +11 -8
  163. package/dist/src/plugins/store/discovery.js.map +1 -1
  164. package/dist/src/ruvector/agent-wasm.d.ts.map +1 -1
  165. package/dist/src/ruvector/agent-wasm.js +4 -1
  166. package/dist/src/ruvector/agent-wasm.js.map +1 -1
  167. package/dist/src/ruvector/coverage-tools.js +6 -6
  168. package/dist/src/ruvector/coverage-tools.js.map +1 -1
  169. package/dist/src/ruvector/index.d.ts +0 -2
  170. package/dist/src/ruvector/index.d.ts.map +1 -1
  171. package/dist/src/ruvector/index.js +8 -2
  172. package/dist/src/ruvector/index.js.map +1 -1
  173. package/dist/src/ruvector/model-router.d.ts +22 -1
  174. package/dist/src/ruvector/model-router.d.ts.map +1 -1
  175. package/dist/src/ruvector/model-router.js +125 -5
  176. package/dist/src/ruvector/model-router.js.map +1 -1
  177. package/dist/src/services/headless-worker-executor.d.ts +6 -0
  178. package/dist/src/services/headless-worker-executor.d.ts.map +1 -1
  179. package/dist/src/services/headless-worker-executor.js +37 -3
  180. package/dist/src/services/headless-worker-executor.js.map +1 -1
  181. package/dist/src/services/worker-daemon.d.ts +80 -2
  182. package/dist/src/services/worker-daemon.d.ts.map +1 -1
  183. package/dist/src/services/worker-daemon.js +372 -11
  184. package/dist/src/services/worker-daemon.js.map +1 -1
  185. package/dist/tsconfig.tsbuildinfo +1 -1
  186. package/package.json +7 -5
  187. package/.claude/skills/agentdb-advanced/SKILL.md +0 -550
  188. package/.claude/skills/agentdb-learning/SKILL.md +0 -545
  189. package/.claude/skills/agentdb-memory-patterns/SKILL.md +0 -339
  190. package/.claude/skills/agentdb-optimization/SKILL.md +0 -509
  191. package/.claude/skills/agentdb-vector-search/SKILL.md +0 -339
  192. package/.claude/skills/agentic-jujutsu/SKILL.md +0 -645
  193. package/.claude/skills/aidefence-scan.md +0 -151
  194. package/.claude/skills/aidefence.yaml +0 -297
  195. package/.claude/skills/browser/SKILL.md +0 -204
  196. package/.claude/skills/flow-nexus-neural/SKILL.md +0 -738
  197. package/.claude/skills/flow-nexus-platform/SKILL.md +0 -1157
  198. package/.claude/skills/flow-nexus-swarm/SKILL.md +0 -610
  199. package/.claude/skills/github-code-review/SKILL.md +0 -1140
  200. package/.claude/skills/github-multi-repo/SKILL.md +0 -874
  201. package/.claude/skills/github-project-management/SKILL.md +0 -1277
  202. package/.claude/skills/github-release-management/SKILL.md +0 -1081
  203. package/.claude/skills/github-workflow-automation/SKILL.md +0 -1065
  204. package/.claude/skills/hive-mind-advanced/SKILL.md +0 -712
  205. package/.claude/skills/hooks-automation/SKILL.md +0 -1201
  206. package/.claude/skills/pair-programming/SKILL.md +0 -1202
  207. package/.claude/skills/performance-analysis/SKILL.md +0 -563
  208. package/.claude/skills/reasoningbank-agentdb/SKILL.md +0 -446
  209. package/.claude/skills/reasoningbank-intelligence/SKILL.md +0 -201
  210. package/.claude/skills/secure-review.md +0 -181
  211. package/.claude/skills/skill-builder/SKILL.md +0 -910
  212. package/.claude/skills/sparc-methodology/SKILL.md +0 -1115
  213. package/.claude/skills/stream-chain/SKILL.md +0 -563
  214. package/.claude/skills/swarm-advanced/SKILL.md +0 -973
  215. package/.claude/skills/swarm-orchestration/SKILL.md +0 -179
  216. package/.claude/skills/v3-cli-modernization/SKILL.md +0 -872
  217. package/.claude/skills/v3-core-implementation/SKILL.md +0 -797
  218. package/.claude/skills/v3-ddd-architecture/SKILL.md +0 -442
  219. package/.claude/skills/v3-integration-deep/SKILL.md +0 -241
  220. package/.claude/skills/v3-mcp-optimization/SKILL.md +0 -777
  221. package/.claude/skills/v3-memory-unification/SKILL.md +0 -174
  222. package/.claude/skills/v3-performance-optimization/SKILL.md +0 -390
  223. package/.claude/skills/v3-security-overhaul/SKILL.md +0 -82
  224. package/.claude/skills/v3-swarm-coordination/SKILL.md +0 -340
  225. package/.claude/skills/verification-quality/SKILL.md +0 -649
  226. package/.claude/skills/worker-benchmarks/skill.md +0 -135
  227. package/.claude/skills/worker-integration/skill.md +0 -154
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claude-flow/cli",
3
- "version": "3.7.0-alpha.3",
3
+ "version": "3.7.0-alpha.30",
4
4
  "type": "module",
5
5
  "description": "Ruflo CLI - Enterprise AI agent orchestration with 60+ specialized agents, swarm coordination, MCP server, self-learning hooks, and vector memory for Claude Code",
6
6
  "main": "dist/src/index.js",
@@ -97,17 +97,19 @@
97
97
  "dependencies": {
98
98
  "@claude-flow/cli-core": "^3.7.0-alpha.5",
99
99
  "@claude-flow/mcp": "^3.0.0-alpha.8",
100
+ "@claude-flow/neural": "^3.0.0-alpha.8",
100
101
  "@claude-flow/shared": "^3.0.0-alpha.7",
101
102
  "@noble/ed25519": "^2.1.0",
102
103
  "@ruvector/rabitq-wasm": "^0.1.0",
103
- "semver": "^7.6.0"
104
+ "semver": "^7.6.0",
105
+ "yaml": "^2.8.0"
104
106
  },
105
107
  "optionalDependencies": {
106
108
  "@claude-flow/aidefence": "^3.0.2",
107
109
  "@claude-flow/codex": "^3.0.0-alpha.8",
108
110
  "@claude-flow/embeddings": "^3.0.0-alpha.12",
109
111
  "@claude-flow/guidance": "^3.0.0-alpha.1",
110
- "@claude-flow/memory": "^3.0.0-alpha.12",
112
+ "@claude-flow/memory": "^3.0.0-alpha.14",
111
113
  "@claude-flow/plugin-gastown-bridge": "^0.1.3",
112
114
  "@claude-flow/security": "^3.0.0-alpha.1",
113
115
  "@ruvector/attention": "^0.1.32",
@@ -117,8 +119,8 @@
117
119
  "@ruvector/router": "^0.1.30",
118
120
  "@ruvector/ruvllm-wasm": "^2.0.2",
119
121
  "@ruvector/rvagent-wasm": "^0.1.0",
120
- "@ruvector/sona": "^0.1.5",
121
- "agentdb": "^3.0.0-alpha.11",
122
+ "@ruvector/sona": "^0.1.6",
123
+ "agentdb": "^3.0.0-alpha.13",
122
124
  "agentic-flow": "^3.0.0-alpha.1"
123
125
  },
124
126
  "publishConfig": {
@@ -1,550 +0,0 @@
1
- ---
2
- name: "AgentDB Advanced Features"
3
- description: "Master advanced AgentDB features including QUIC synchronization, multi-database management, custom distance metrics, hybrid search, and distributed systems integration. Use when building distributed AI systems, multi-agent coordination, or advanced vector search applications."
4
- ---
5
-
6
- # AgentDB Advanced Features
7
-
8
- ## What This Skill Does
9
-
10
- Covers advanced AgentDB capabilities for distributed systems, multi-database coordination, custom distance metrics, hybrid search (vector + metadata), QUIC synchronization, and production deployment patterns. Enables building sophisticated AI systems with sub-millisecond cross-node communication and advanced search capabilities.
11
-
12
- **Performance**: <1ms QUIC sync, hybrid search with filters, custom distance metrics.
13
-
14
- ## Prerequisites
15
-
16
- - Node.js 18+
17
- - AgentDB v1.0.7+ (via agentic-flow)
18
- - Understanding of distributed systems (for QUIC sync)
19
- - Vector search fundamentals
20
-
21
- ---
22
-
23
- ## QUIC Synchronization
24
-
25
- ### What is QUIC Sync?
26
-
27
- QUIC (Quick UDP Internet Connections) enables sub-millisecond latency synchronization between AgentDB instances across network boundaries with automatic retry, multiplexing, and encryption.
28
-
29
- **Benefits**:
30
- - <1ms latency between nodes
31
- - Multiplexed streams (multiple operations simultaneously)
32
- - Built-in encryption (TLS 1.3)
33
- - Automatic retry and recovery
34
- - Event-based broadcasting
35
-
36
- ### Enable QUIC Sync
37
-
38
- ```typescript
39
- import { createAgentDBAdapter } from 'agentic-flow/reasoningbank';
40
-
41
- // Initialize with QUIC synchronization
42
- const adapter = await createAgentDBAdapter({
43
- dbPath: '.agentdb/distributed.db',
44
- enableQUICSync: true,
45
- syncPort: 4433,
46
- syncPeers: [
47
- '192.168.1.10:4433',
48
- '192.168.1.11:4433',
49
- '192.168.1.12:4433',
50
- ],
51
- });
52
-
53
- // Patterns automatically sync across all peers
54
- await adapter.insertPattern({
55
- // ... pattern data
56
- });
57
-
58
- // Available on all peers within ~1ms
59
- ```
60
-
61
- ### QUIC Configuration
62
-
63
- ```typescript
64
- const adapter = await createAgentDBAdapter({
65
- enableQUICSync: true,
66
- syncPort: 4433, // QUIC server port
67
- syncPeers: ['host1:4433'], // Peer addresses
68
- syncInterval: 1000, // Sync interval (ms)
69
- syncBatchSize: 100, // Patterns per batch
70
- maxRetries: 3, // Retry failed syncs
71
- compression: true, // Enable compression
72
- });
73
- ```
74
-
75
- ### Multi-Node Deployment
76
-
77
- ```bash
78
- # Node 1 (192.168.1.10)
79
- AGENTDB_QUIC_SYNC=true \
80
- AGENTDB_QUIC_PORT=4433 \
81
- AGENTDB_QUIC_PEERS=192.168.1.11:4433,192.168.1.12:4433 \
82
- node server.js
83
-
84
- # Node 2 (192.168.1.11)
85
- AGENTDB_QUIC_SYNC=true \
86
- AGENTDB_QUIC_PORT=4433 \
87
- AGENTDB_QUIC_PEERS=192.168.1.10:4433,192.168.1.12:4433 \
88
- node server.js
89
-
90
- # Node 3 (192.168.1.12)
91
- AGENTDB_QUIC_SYNC=true \
92
- AGENTDB_QUIC_PORT=4433 \
93
- AGENTDB_QUIC_PEERS=192.168.1.10:4433,192.168.1.11:4433 \
94
- node server.js
95
- ```
96
-
97
- ---
98
-
99
- ## Distance Metrics
100
-
101
- ### Cosine Similarity (Default)
102
-
103
- Best for normalized vectors, semantic similarity:
104
-
105
- ```bash
106
- # CLI
107
- npx agentdb@latest query ./vectors.db "[0.1,0.2,...]" -m cosine
108
-
109
- # API
110
- const result = await adapter.retrieveWithReasoning(queryEmbedding, {
111
- metric: 'cosine',
112
- k: 10,
113
- });
114
- ```
115
-
116
- **Use Cases**:
117
- - Text embeddings (BERT, GPT, etc.)
118
- - Semantic search
119
- - Document similarity
120
- - Most general-purpose applications
121
-
122
- **Formula**: `cos(θ) = (A · B) / (||A|| × ||B||)`
123
- **Range**: [-1, 1] (1 = identical, -1 = opposite)
124
-
125
- ### Euclidean Distance (L2)
126
-
127
- Best for spatial data, geometric similarity:
128
-
129
- ```bash
130
- # CLI
131
- npx agentdb@latest query ./vectors.db "[0.1,0.2,...]" -m euclidean
132
-
133
- # API
134
- const result = await adapter.retrieveWithReasoning(queryEmbedding, {
135
- metric: 'euclidean',
136
- k: 10,
137
- });
138
- ```
139
-
140
- **Use Cases**:
141
- - Image embeddings
142
- - Spatial data
143
- - Computer vision
144
- - When vector magnitude matters
145
-
146
- **Formula**: `d = √(Σ(ai - bi)²)`
147
- **Range**: [0, ∞] (0 = identical, ∞ = very different)
148
-
149
- ### Dot Product
150
-
151
- Best for pre-normalized vectors, fast computation:
152
-
153
- ```bash
154
- # CLI
155
- npx agentdb@latest query ./vectors.db "[0.1,0.2,...]" -m dot
156
-
157
- # API
158
- const result = await adapter.retrieveWithReasoning(queryEmbedding, {
159
- metric: 'dot',
160
- k: 10,
161
- });
162
- ```
163
-
164
- **Use Cases**:
165
- - Pre-normalized embeddings
166
- - Fast similarity computation
167
- - When vectors are already unit-length
168
-
169
- **Formula**: `dot = Σ(ai × bi)`
170
- **Range**: [-∞, ∞] (higher = more similar)
171
-
172
- ### Custom Distance Metrics
173
-
174
- ```typescript
175
- // Implement custom distance function
176
- function customDistance(vec1: number[], vec2: number[]): number {
177
- // Weighted Euclidean distance
178
- const weights = [1.0, 2.0, 1.5, ...];
179
- let sum = 0;
180
- for (let i = 0; i < vec1.length; i++) {
181
- sum += weights[i] * Math.pow(vec1[i] - vec2[i], 2);
182
- }
183
- return Math.sqrt(sum);
184
- }
185
-
186
- // Use in search (requires custom implementation)
187
- ```
188
-
189
- ---
190
-
191
- ## Hybrid Search (Vector + Metadata)
192
-
193
- ### Basic Hybrid Search
194
-
195
- Combine vector similarity with metadata filtering:
196
-
197
- ```typescript
198
- // Store documents with metadata
199
- await adapter.insertPattern({
200
- id: '',
201
- type: 'document',
202
- domain: 'research-papers',
203
- pattern_data: JSON.stringify({
204
- embedding: documentEmbedding,
205
- text: documentText,
206
- metadata: {
207
- author: 'Jane Smith',
208
- year: 2025,
209
- category: 'machine-learning',
210
- citations: 150,
211
- }
212
- }),
213
- confidence: 1.0,
214
- usage_count: 0,
215
- success_count: 0,
216
- created_at: Date.now(),
217
- last_used: Date.now(),
218
- });
219
-
220
- // Hybrid search: vector similarity + metadata filters
221
- const result = await adapter.retrieveWithReasoning(queryEmbedding, {
222
- domain: 'research-papers',
223
- k: 20,
224
- filters: {
225
- year: { $gte: 2023 }, // Published 2023 or later
226
- category: 'machine-learning', // ML papers only
227
- citations: { $gte: 50 }, // Highly cited
228
- },
229
- });
230
- ```
231
-
232
- ### Advanced Filtering
233
-
234
- ```typescript
235
- // Complex metadata queries
236
- const result = await adapter.retrieveWithReasoning(queryEmbedding, {
237
- domain: 'products',
238
- k: 50,
239
- filters: {
240
- price: { $gte: 10, $lte: 100 }, // Price range
241
- category: { $in: ['electronics', 'gadgets'] }, // Multiple categories
242
- rating: { $gte: 4.0 }, // High rated
243
- inStock: true, // Available
244
- tags: { $contains: 'wireless' }, // Has tag
245
- },
246
- });
247
- ```
248
-
249
- ### Weighted Hybrid Search
250
-
251
- Combine vector and metadata scores:
252
-
253
- ```typescript
254
- const result = await adapter.retrieveWithReasoning(queryEmbedding, {
255
- domain: 'content',
256
- k: 20,
257
- hybridWeights: {
258
- vectorSimilarity: 0.7, // 70% weight on semantic similarity
259
- metadataScore: 0.3, // 30% weight on metadata match
260
- },
261
- filters: {
262
- category: 'technology',
263
- recency: { $gte: Date.now() - 30 * 24 * 3600000 }, // Last 30 days
264
- },
265
- });
266
- ```
267
-
268
- ---
269
-
270
- ## Multi-Database Management
271
-
272
- ### Multiple Databases
273
-
274
- ```typescript
275
- // Separate databases for different domains
276
- const knowledgeDB = await createAgentDBAdapter({
277
- dbPath: '.agentdb/knowledge.db',
278
- });
279
-
280
- const conversationDB = await createAgentDBAdapter({
281
- dbPath: '.agentdb/conversations.db',
282
- });
283
-
284
- const codeDB = await createAgentDBAdapter({
285
- dbPath: '.agentdb/code.db',
286
- });
287
-
288
- // Use appropriate database for each task
289
- await knowledgeDB.insertPattern({ /* knowledge */ });
290
- await conversationDB.insertPattern({ /* conversation */ });
291
- await codeDB.insertPattern({ /* code */ });
292
- ```
293
-
294
- ### Database Sharding
295
-
296
- ```typescript
297
- // Shard by domain for horizontal scaling
298
- const shards = {
299
- 'domain-a': await createAgentDBAdapter({ dbPath: '.agentdb/shard-a.db' }),
300
- 'domain-b': await createAgentDBAdapter({ dbPath: '.agentdb/shard-b.db' }),
301
- 'domain-c': await createAgentDBAdapter({ dbPath: '.agentdb/shard-c.db' }),
302
- };
303
-
304
- // Route queries to appropriate shard
305
- function getDBForDomain(domain: string) {
306
- const shardKey = domain.split('-')[0]; // Extract shard key
307
- return shards[shardKey] || shards['domain-a'];
308
- }
309
-
310
- // Insert to correct shard
311
- const db = getDBForDomain('domain-a-task');
312
- await db.insertPattern({ /* ... */ });
313
- ```
314
-
315
- ---
316
-
317
- ## MMR (Maximal Marginal Relevance)
318
-
319
- Retrieve diverse results to avoid redundancy:
320
-
321
- ```typescript
322
- // Without MMR: Similar results may be redundant
323
- const standardResults = await adapter.retrieveWithReasoning(queryEmbedding, {
324
- k: 10,
325
- useMMR: false,
326
- });
327
-
328
- // With MMR: Diverse, non-redundant results
329
- const diverseResults = await adapter.retrieveWithReasoning(queryEmbedding, {
330
- k: 10,
331
- useMMR: true,
332
- mmrLambda: 0.5, // Balance relevance (0) vs diversity (1)
333
- });
334
- ```
335
-
336
- **MMR Parameters**:
337
- - `mmrLambda = 0`: Maximum relevance (may be redundant)
338
- - `mmrLambda = 0.5`: Balanced (default)
339
- - `mmrLambda = 1`: Maximum diversity (may be less relevant)
340
-
341
- **Use Cases**:
342
- - Search result diversification
343
- - Recommendation systems
344
- - Avoiding echo chambers
345
- - Exploratory search
346
-
347
- ---
348
-
349
- ## Context Synthesis
350
-
351
- Generate rich context from multiple memories:
352
-
353
- ```typescript
354
- const result = await adapter.retrieveWithReasoning(queryEmbedding, {
355
- domain: 'problem-solving',
356
- k: 10,
357
- synthesizeContext: true, // Enable context synthesis
358
- });
359
-
360
- // ContextSynthesizer creates coherent narrative
361
- console.log('Synthesized Context:', result.context);
362
- // "Based on 10 similar problem-solving attempts, the most effective
363
- // approach involves: 1) analyzing root cause, 2) brainstorming solutions,
364
- // 3) evaluating trade-offs, 4) implementing incrementally. Success rate: 85%"
365
-
366
- console.log('Patterns:', result.patterns);
367
- // Extracted common patterns across memories
368
- ```
369
-
370
- ---
371
-
372
- ## Production Patterns
373
-
374
- ### Connection Pooling
375
-
376
- ```typescript
377
- // Singleton pattern for shared adapter
378
- class AgentDBPool {
379
- private static instance: AgentDBAdapter;
380
-
381
- static async getInstance() {
382
- if (!this.instance) {
383
- this.instance = await createAgentDBAdapter({
384
- dbPath: '.agentdb/production.db',
385
- quantizationType: 'scalar',
386
- cacheSize: 2000,
387
- });
388
- }
389
- return this.instance;
390
- }
391
- }
392
-
393
- // Use in application
394
- const db = await AgentDBPool.getInstance();
395
- const results = await db.retrieveWithReasoning(queryEmbedding, { k: 10 });
396
- ```
397
-
398
- ### Error Handling
399
-
400
- ```typescript
401
- async function safeRetrieve(queryEmbedding: number[], options: any) {
402
- try {
403
- const result = await adapter.retrieveWithReasoning(queryEmbedding, options);
404
- return result;
405
- } catch (error) {
406
- if (error.code === 'DIMENSION_MISMATCH') {
407
- console.error('Query embedding dimension mismatch');
408
- // Handle dimension error
409
- } else if (error.code === 'DATABASE_LOCKED') {
410
- // Retry with exponential backoff
411
- await new Promise(resolve => setTimeout(resolve, 100));
412
- return safeRetrieve(queryEmbedding, options);
413
- }
414
- throw error;
415
- }
416
- }
417
- ```
418
-
419
- ### Monitoring and Logging
420
-
421
- ```typescript
422
- // Performance monitoring
423
- const startTime = Date.now();
424
- const result = await adapter.retrieveWithReasoning(queryEmbedding, { k: 10 });
425
- const latency = Date.now() - startTime;
426
-
427
- if (latency > 100) {
428
- console.warn('Slow query detected:', latency, 'ms');
429
- }
430
-
431
- // Log statistics
432
- const stats = await adapter.getStats();
433
- console.log('Database Stats:', {
434
- totalPatterns: stats.totalPatterns,
435
- dbSize: stats.dbSize,
436
- cacheHitRate: stats.cacheHitRate,
437
- avgSearchLatency: stats.avgSearchLatency,
438
- });
439
- ```
440
-
441
- ---
442
-
443
- ## CLI Advanced Operations
444
-
445
- ### Database Import/Export
446
-
447
- ```bash
448
- # Export with compression
449
- npx agentdb@latest export ./vectors.db ./backup.json.gz --compress
450
-
451
- # Import from backup
452
- npx agentdb@latest import ./backup.json.gz --decompress
453
-
454
- # Merge databases
455
- npx agentdb@latest merge ./db1.sqlite ./db2.sqlite ./merged.sqlite
456
- ```
457
-
458
- ### Database Optimization
459
-
460
- ```bash
461
- # Vacuum database (reclaim space)
462
- sqlite3 .agentdb/vectors.db "VACUUM;"
463
-
464
- # Analyze for query optimization
465
- sqlite3 .agentdb/vectors.db "ANALYZE;"
466
-
467
- # Rebuild indices
468
- npx agentdb@latest reindex ./vectors.db
469
- ```
470
-
471
- ---
472
-
473
- ## Environment Variables
474
-
475
- ```bash
476
- # AgentDB configuration
477
- AGENTDB_PATH=.agentdb/reasoningbank.db
478
- AGENTDB_ENABLED=true
479
-
480
- # Performance tuning
481
- AGENTDB_QUANTIZATION=binary # binary|scalar|product|none
482
- AGENTDB_CACHE_SIZE=2000
483
- AGENTDB_HNSW_M=16
484
- AGENTDB_HNSW_EF=100
485
-
486
- # Learning plugins
487
- AGENTDB_LEARNING=true
488
-
489
- # Reasoning agents
490
- AGENTDB_REASONING=true
491
-
492
- # QUIC synchronization
493
- AGENTDB_QUIC_SYNC=true
494
- AGENTDB_QUIC_PORT=4433
495
- AGENTDB_QUIC_PEERS=host1:4433,host2:4433
496
- ```
497
-
498
- ---
499
-
500
- ## Troubleshooting
501
-
502
- ### Issue: QUIC sync not working
503
-
504
- ```bash
505
- # Check firewall allows UDP port 4433
506
- sudo ufw allow 4433/udp
507
-
508
- # Verify peers are reachable
509
- ping host1
510
-
511
- # Check QUIC logs
512
- DEBUG=agentdb:quic node server.js
513
- ```
514
-
515
- ### Issue: Hybrid search returns no results
516
-
517
- ```typescript
518
- // Relax filters
519
- const result = await adapter.retrieveWithReasoning(queryEmbedding, {
520
- k: 100, // Increase k
521
- filters: {
522
- // Remove or relax filters
523
- },
524
- });
525
- ```
526
-
527
- ### Issue: Memory consolidation too aggressive
528
-
529
- ```typescript
530
- // Disable automatic optimization
531
- const result = await adapter.retrieveWithReasoning(queryEmbedding, {
532
- optimizeMemory: false, // Disable auto-consolidation
533
- k: 10,
534
- });
535
- ```
536
-
537
- ---
538
-
539
- ## Learn More
540
-
541
- - **QUIC Protocol**: docs/quic-synchronization.pdf
542
- - **Hybrid Search**: docs/hybrid-search-guide.md
543
- - **GitHub**: https://github.com/ruvnet/agentic-flow/tree/main/packages/agentdb
544
- - **Website**: https://agentdb.ruv.io
545
-
546
- ---
547
-
548
- **Category**: Advanced / Distributed Systems
549
- **Difficulty**: Advanced
550
- **Estimated Time**: 45-60 minutes