agentic-flow 1.7.4 → 1.7.5
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/dist/index.js
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @since v1.7.0 - Integrated AgentDB for optimal performance
|
|
6
6
|
*/
|
|
7
|
+
// Apply AgentDB runtime patch before any AgentDB imports
|
|
8
|
+
import '../utils/agentdb-runtime-patch.js';
|
|
7
9
|
// New hybrid backend (recommended for new code)
|
|
8
10
|
export { HybridReasoningBank } from './HybridBackend.js';
|
|
9
11
|
export { AdvancedMemorySystem } from './AdvancedMemory.js';
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentDB Runtime Patch
|
|
3
|
+
*
|
|
4
|
+
* Automatically fixes AgentDB v1.3.9 import resolution issues at runtime.
|
|
5
|
+
* This patch works in all contexts: npm install, npm install -g, and npx.
|
|
6
|
+
*
|
|
7
|
+
* Issue: agentdb v1.3.9 missing .js extensions in ESM exports
|
|
8
|
+
* Solution: Patch the controller index.js file at runtime before first import
|
|
9
|
+
*/
|
|
10
|
+
import { readFileSync, writeFileSync, existsSync } from 'fs';
|
|
11
|
+
import { join, dirname } from 'path';
|
|
12
|
+
import { fileURLToPath } from 'url';
|
|
13
|
+
let patched = false;
|
|
14
|
+
let patchAttempted = false;
|
|
15
|
+
/**
|
|
16
|
+
* Apply AgentDB import fix at runtime
|
|
17
|
+
* Safe to call multiple times - only patches once
|
|
18
|
+
*/
|
|
19
|
+
export function applyAgentDBPatch() {
|
|
20
|
+
// Only attempt once per process
|
|
21
|
+
if (patchAttempted) {
|
|
22
|
+
return patched;
|
|
23
|
+
}
|
|
24
|
+
patchAttempted = true;
|
|
25
|
+
try {
|
|
26
|
+
// Find agentdb installation
|
|
27
|
+
const agentdbPath = findAgentDBPath();
|
|
28
|
+
if (!agentdbPath) {
|
|
29
|
+
console.warn('[AgentDB Patch] Could not locate agentdb installation');
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
const controllerIndexPath = join(agentdbPath, 'dist', 'controllers', 'index.js');
|
|
33
|
+
if (!existsSync(controllerIndexPath)) {
|
|
34
|
+
console.warn(`[AgentDB Patch] Controller index not found: ${controllerIndexPath}`);
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
// Read current content
|
|
38
|
+
let content = readFileSync(controllerIndexPath, 'utf8');
|
|
39
|
+
// Check if already patched
|
|
40
|
+
if (content.includes("from './ReflexionMemory.js'")) {
|
|
41
|
+
patched = true;
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
// Apply patches
|
|
45
|
+
const patches = [
|
|
46
|
+
{ from: "from './ReflexionMemory'", to: "from './ReflexionMemory.js'" },
|
|
47
|
+
{ from: "from './SkillLibrary'", to: "from './SkillLibrary.js'" },
|
|
48
|
+
{ from: "from './EmbeddingService'", to: "from './EmbeddingService.js'" },
|
|
49
|
+
{ from: "from './CausalMemoryGraph'", to: "from './CausalMemoryGraph.js'" },
|
|
50
|
+
{ from: "from './CausalRecall'", to: "from './CausalRecall.js'" },
|
|
51
|
+
{ from: "from './NightlyLearner'", to: "from './NightlyLearner.js'" }
|
|
52
|
+
];
|
|
53
|
+
let modified = false;
|
|
54
|
+
for (const patch of patches) {
|
|
55
|
+
if (content.includes(patch.from) && !content.includes(patch.to)) {
|
|
56
|
+
content = content.replace(new RegExp(patch.from, 'g'), patch.to);
|
|
57
|
+
modified = true;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (modified) {
|
|
61
|
+
try {
|
|
62
|
+
writeFileSync(controllerIndexPath, content, 'utf8');
|
|
63
|
+
patched = true;
|
|
64
|
+
console.log('[AgentDB Patch] ✅ Successfully patched AgentDB imports');
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
catch (writeError) {
|
|
68
|
+
// If we can't write (npx temp dir permissions), that's OK - imports will fail gracefully
|
|
69
|
+
console.warn('[AgentDB Patch] ⚠️ Could not write patch (read-only):', writeError.message);
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
console.warn('[AgentDB Patch] Error applying patch:', error.message);
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Find AgentDB installation directory
|
|
82
|
+
* Checks multiple possible locations
|
|
83
|
+
*/
|
|
84
|
+
function findAgentDBPath() {
|
|
85
|
+
const possiblePaths = [
|
|
86
|
+
// Local node_modules (most common)
|
|
87
|
+
join(process.cwd(), 'node_modules', 'agentdb'),
|
|
88
|
+
// Parent directory node_modules (monorepo)
|
|
89
|
+
join(process.cwd(), '..', 'node_modules', 'agentdb'),
|
|
90
|
+
// Global npm installation
|
|
91
|
+
join(process.execPath, '..', '..', 'lib', 'node_modules', 'agentdb'),
|
|
92
|
+
// Relative to this file (for bundled installations)
|
|
93
|
+
...(typeof __dirname !== 'undefined'
|
|
94
|
+
? [
|
|
95
|
+
join(__dirname, '..', '..', 'node_modules', 'agentdb'),
|
|
96
|
+
join(__dirname, '..', '..', '..', 'agentdb')
|
|
97
|
+
]
|
|
98
|
+
: []),
|
|
99
|
+
// Using import.meta.url (ESM)
|
|
100
|
+
...(typeof import.meta !== 'undefined' && import.meta.url
|
|
101
|
+
? (() => {
|
|
102
|
+
try {
|
|
103
|
+
const currentDir = dirname(fileURLToPath(import.meta.url));
|
|
104
|
+
return [
|
|
105
|
+
join(currentDir, '..', '..', 'node_modules', 'agentdb'),
|
|
106
|
+
join(currentDir, '..', '..', '..', 'agentdb')
|
|
107
|
+
];
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
return [];
|
|
111
|
+
}
|
|
112
|
+
})()
|
|
113
|
+
: [])
|
|
114
|
+
];
|
|
115
|
+
// Try each path
|
|
116
|
+
for (const path of possiblePaths) {
|
|
117
|
+
if (existsSync(join(path, 'package.json'))) {
|
|
118
|
+
try {
|
|
119
|
+
const pkg = JSON.parse(readFileSync(join(path, 'package.json'), 'utf8'));
|
|
120
|
+
if (pkg.name === 'agentdb') {
|
|
121
|
+
return path;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
// Try require.resolve as fallback
|
|
130
|
+
try {
|
|
131
|
+
const resolved = require.resolve('agentdb/package.json');
|
|
132
|
+
return dirname(resolved);
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
// Not found via require.resolve
|
|
136
|
+
}
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Check if AgentDB patch is needed
|
|
141
|
+
*/
|
|
142
|
+
export function isAgentDBPatchNeeded() {
|
|
143
|
+
const agentdbPath = findAgentDBPath();
|
|
144
|
+
if (!agentdbPath)
|
|
145
|
+
return false;
|
|
146
|
+
const controllerIndexPath = join(agentdbPath, 'dist', 'controllers', 'index.js');
|
|
147
|
+
if (!existsSync(controllerIndexPath))
|
|
148
|
+
return false;
|
|
149
|
+
const content = readFileSync(controllerIndexPath, 'utf8');
|
|
150
|
+
return !content.includes("from './ReflexionMemory.js'");
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Get patch status information
|
|
154
|
+
*/
|
|
155
|
+
export function getAgentDBPatchStatus() {
|
|
156
|
+
return {
|
|
157
|
+
needed: isAgentDBPatchNeeded(),
|
|
158
|
+
applied: patched,
|
|
159
|
+
attempted: patchAttempted,
|
|
160
|
+
location: findAgentDBPath()
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
// Auto-apply patch on module load (non-blocking)
|
|
164
|
+
// This ensures the patch is applied before any imports
|
|
165
|
+
if (typeof process !== 'undefined' && !process.env.SKIP_AGENTDB_PATCH) {
|
|
166
|
+
// Run asynchronously to not block module loading
|
|
167
|
+
setImmediate(() => {
|
|
168
|
+
applyAgentDBPatch();
|
|
169
|
+
});
|
|
170
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentic-flow",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.5",
|
|
4
4
|
"description": "Production-ready AI agent orchestration platform with 66 specialized agents, 213 MCP tools, ReasoningBank learning memory, and autonomous multi-agent swarms. Built by @ruvnet with Claude Agent SDK, neural networks, memory persistence, GitHub integration, and distributed consensus protocols.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|