Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 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

Checkpoint: File edits

rUvb71af1230b26
diff --git a/v3/@claude-flow/cli/src/mcp-tools/security-tools.ts b/v3/@claude-flow/cli/src/mcp-tools/security-tools.ts
index bff755a299..b919ec572a 100644
--- a/v3/@claude-flow/cli/src/mcp-tools/security-tools.ts
+++ b/v3/@claude-flow/cli/src/mcp-tools/security-tools.ts
@@ -11,17 +11,52 @@
*/
import type { MCPTool, MCPToolResult } from './types.js';
+import { execSync } from 'child_process';
// Lazy-loaded AIDefence instance
let aidefenceInstance: Awaited<ReturnType<typeof import('@claude-flow/aidefence').createAIDefence>> | null = null;
+let installAttempted = false;
+
+/**
+ * Auto-install a package if not available
+ */
+async function autoInstallPackage(packageName: string): Promise<boolean> {
+ if (installAttempted) return false;
+ installAttempted = true;
+
+ try {
+ console.error(`[claude-flow] Auto-installing ${packageName}...`);
+ execSync(`npm install ${packageName} --no-save`, {
+ stdio: ['pipe', 'pipe', 'pipe'],
+ timeout: 60000, // 60 second timeout
+ });
+ console.error(`[claude-flow] Successfully installed ${packageName}`);
+ return true;
+ } catch (error) {
+ console.error(`[claude-flow] Failed to auto-install ${packageName}: ${error}`);
+ return false;
+ }
+}
async function getAIDefence() {
if (!aidefenceInstance) {
try {
const { createAIDefence } = await import('@claude-flow/aidefence');
aidefenceInstance = createAIDefence({ enableLearning: true });
- } catch {
- throw new Error('AIDefence package not available. Install with: npm install @claude-flow/aidefence');
+ } catch (importError) {
+ // Try auto-install
+ const installed = await autoInstallPackage('@claude-flow/aidefence');
+ if (installed) {
+ try {
+ // Clear module cache and retry
+ const { createAIDefence } = await import('@claude-flow/aidefence');
+ aidefenceInstance = createAIDefence({ enableLearning: true });
+ } catch {
+ throw new Error('AIDefence installed but failed to load. Try restarting the MCP server.');
+ }
+ } else {
+ throw new Error('AIDefence package not available. Install with: npm install @claude-flow/aidefence');
+ }
}
}
return aidefenceInstance;