π The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
darwin-core iter 4 β causal-graph: cache dynamic imports in graph-query/pathfinder hot path Ξ=7
ruv45da93d48094
diff --git a/v3/@claude-flow/cli/src/mcp-tools/agentdb-tools.ts b/v3/@claude-flow/cli/src/mcp-tools/agentdb-tools.tsindex 1b4dd9e9e7..98f8afb04d 100644--- a/v3/@claude-flow/cli/src/mcp-tools/agentdb-tools.ts+++ b/v3/@claude-flow/cli/src/mcp-tools/agentdb-tools.ts@@ -54,6 +54,30 @@ async function getBridge() {return bridgeModule;}+// Lazy-cached modules used by graph-query / graph-pathfinder dispatch.+// Caching the resolved namespace avoids per-call dynamic-import overhead+// in the ADR-130 hot path (smoke harness measures elapsedMs of every call).+let graphBackendMod: typeof import('../ruvector/graph-backend.js') | null = null;+async function getGraphBackend() {+ if (!graphBackendMod) graphBackendMod = await import('../ruvector/graph-backend.js');+ return graphBackendMod;+}+let graphEdgeWriterMod: typeof import('../memory/graph-edge-writer.js') | null = null;+async function getGraphEdgeWriter() {+ if (!graphEdgeWriterMod) graphEdgeWriterMod = await import('../memory/graph-edge-writer.js');+ return graphEdgeWriterMod;+}+let memInitMod: typeof import('../memory/memory-initializer.js') | null = null;+async function getMemInit() {+ if (!memInitMod) memInitMod = await import('../memory/memory-initializer.js');+ return memInitMod;+}+let embQuantMod: typeof import('../memory/embedding-quantization.js') | null = null;+async function getEmbQuant() {+ if (!embQuantMod) embQuantMod = await import('../memory/embedding-quantization.js');+ return embQuantMod;+}+// ===== agentdb_health β Controller health check =====export const agentdbHealth: MCPTool = {@@ -955,7 +979,7 @@ export const agentdbGraphQuery: MCPTool = {if (mode === 'k-hop') {// Try graph-node native firsttry {- const graphBackend = await import('../ruvector/graph-backend.js');+ const graphBackend = await getGraphBackend();if (await graphBackend.isGraphBackendAvailable()) {const neighbors = await graphBackend.getNeighbors(nodeId, depth);return {@@ -970,7 +994,7 @@ export const agentdbGraphQuery: MCPTool = {// SQL CTE fallback for k-hop up to depth 3try {- const { getBridgeDb } = await import('../memory/graph-edge-writer.js');+ const { getBridgeDb } = await getGraphEdgeWriter();const db = await getBridgeDb();if (db) {const cteSql = buildKHopCTE(nodeId, Math.min(depth, 3), relation, budget.maxNodesVisited);@@ -995,11 +1019,11 @@ export const agentdbGraphQuery: MCPTool = {// ββ semantic mode ββββββββββββββββββββββββββββββββββββββββββββββββββββββββif (mode === 'semantic') {try {- const { generateEmbedding } = await import('../memory/memory-initializer.js');+ const { generateEmbedding } = await getMemInit();const queryEmb = await generateEmbedding(nodeId);if (!queryEmb) throw new Error('embedding failed');- const { getBridgeDb } = await import('../memory/graph-edge-writer.js');+ const { getBridgeDb } = await getGraphEdgeWriter();// #2246 fix: lazy-create memory.db on first pathfinder call so// fresh environments work without a pre-existing memory init.const db = await getBridgeDb(undefined, { createIfMissing: true });@@ -1012,7 +1036,7 @@ export const agentdbGraphQuery: MCPTool = {const rows = db.prepare(`SELECT id, source_id, target_id, relation, weight, embedding_ref FROM graph_edges WHERE embedding_ref IS NOT NULL LIMIT ?`,).raw().all(budget.maxNodesVisited) as unknown[][];- const { decodeEmbedding } = await import('../memory/embedding-quantization.js');+ const { decodeEmbedding } = await getEmbQuant();const scored: Array<{ nodeId: string; score: number; relation: string }> = [];const qv = new Float32Array(queryEmb.embedding);@@ -1043,7 +1067,7 @@ export const agentdbGraphQuery: MCPTool = {// ββ pagerank mode ββββββββββββββββββββββββββββββββββββββββββββββββββββββββif (mode === 'pagerank') {try {- const { getBridgeDb } = await import('../memory/graph-edge-writer.js');+ const { getBridgeDb } = await getGraphEdgeWriter();// #2246 fix: lazy-create memory.db on first pathfinder call so// fresh environments work without a pre-existing memory init.const db = await getBridgeDb(undefined, { createIfMissing: true });@@ -1247,7 +1271,7 @@ export const agentdbGraphPathfinder: MCPTool = {}// Load edges from graph_edges- const { getBridgeDb } = await import('../memory/graph-edge-writer.js');+ const { getBridgeDb } = await getGraphEdgeWriter();// #2246 fix: lazy-create memory.db on first pathfinder call.const db = await getBridgeDb(undefined, { createIfMissing: true });if (!db) return { success: false, error: 'graph_edges DB unavailable (sql.js could not load)', hint: 'Check Node version + try `ruflo memory init` to initialize manually.', seedNodeId };