agentic-flow 1.7.4 → 1.7.6

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
@@ -1,3 +1,5 @@
1
+ // Apply AgentDB runtime patch before any imports
2
+ import "./utils/agentdb-runtime-patch.js";
1
3
  import "dotenv/config";
2
4
  import { webResearchAgent } from "./agents/webResearchAgent.js";
3
5
  import { codeReviewAgent } from "./agents/codeReviewAgent.js";
@@ -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,173 @@
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 (SYNCHRONOUS - must happen before any AgentDB imports)
164
+ // This ensures the patch is applied before any imports
165
+ if (typeof process !== 'undefined' && !process.env.SKIP_AGENTDB_PATCH) {
166
+ // MUST be synchronous - async won't work because imports happen immediately
167
+ try {
168
+ applyAgentDBPatch();
169
+ }
170
+ catch (error) {
171
+ // Silently fail - patch will be attempted again on explicit call
172
+ }
173
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentic-flow",
3
- "version": "1.7.4",
3
+ "version": "1.7.6",
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",
@@ -258,7 +258,7 @@ export function log(message) {
258
258
  wasm.log(ptr0, len0);
259
259
  }
260
260
 
261
- function __wbg_adapter_6(arg0, arg1, arg2) {
261
+ function __wbg_adapter_4(arg0, arg1, arg2) {
262
262
  wasm.__wbindgen_export_5(arg0, arg1, addHeapObject(arg2));
263
263
  }
264
264
 
@@ -540,7 +540,7 @@ export function __wbindgen_cast_2241b6af4c4b2941(arg0, arg1) {
540
540
 
541
541
  export function __wbindgen_cast_8eb6fd44e7238d11(arg0, arg1) {
542
542
  // Cast intrinsic for `Closure(Closure { dtor_idx: 62, function: Function { arguments: [Externref], shim_idx: 63, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
543
- const ret = makeMutClosure(arg0, arg1, 62, __wbg_adapter_6);
543
+ const ret = makeMutClosure(arg0, arg1, 62, __wbg_adapter_4);
544
544
  return addHeapObject(ret);
545
545
  };
546
546