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

fix: browser ENOENT/args/hover + RaBitQ bridge store alignment (v3.6.6)

Reuven911bd4e94073
diff --git a/package.json b/package.json
index bc52c606c2..56348982ba 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "claude-flow",
- "version": "3.6.5",
+ "version": "3.6.6",
"description": "Ruflo - Enterprise AI agent orchestration for Claude Code. Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration",
"main": "dist/index.js",
"type": "module",
diff --git a/ruflo/package.json b/ruflo/package.json
index f7d450a01e..7c9b9750de 100644
--- a/ruflo/package.json
+++ b/ruflo/package.json
@@ -1,6 +1,6 @@
{
"name": "ruflo",
- "version": "3.6.5",
+ "version": "3.6.6",
"description": "Ruflo - Enterprise AI agent orchestration platform. Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration",
"main": "bin/ruflo.js",
"type": "module",
diff --git a/v3/@claude-flow/cli/package.json b/v3/@claude-flow/cli/package.json
index 96f976277b..c2aaa4ea75 100644
--- a/v3/@claude-flow/cli/package.json
+++ b/v3/@claude-flow/cli/package.json
@@ -1,6 +1,6 @@
{
"name": "@claude-flow/cli",
- "version": "3.6.5",
+ "version": "3.6.6",
"type": "module",
"description": "Ruflo CLI - Enterprise AI agent orchestration with 60+ specialized agents, swarm coordination, MCP server, self-learning hooks, and vector memory for Claude Code",
"main": "dist/src/index.js",
diff --git a/v3/@claude-flow/cli/src/mcp-tools/browser-tools.ts b/v3/@claude-flow/cli/src/mcp-tools/browser-tools.ts
index 42a76e2c8a..a63cf8968a 100644
--- a/v3/@claude-flow/cli/src/mcp-tools/browser-tools.ts
+++ b/v3/@claude-flow/cli/src/mcp-tools/browser-tools.ts
@@ -16,49 +16,89 @@ const browserSessions = new Map<string, {
}>();
/**
- * Execute agent-browser CLI command
+ * Execute agent-browser CLI command.
+ * Tries global agent-browser first, falls back to npx if ENOENT.
*/
async function execBrowserCommand(args: string[], session = 'default'): Promise<MCPToolResult> {
const { execFileSync } = await import('child_process');
+ const fullArgs = ['--session', session, '--json', ...args];
+ let result: string;
try {
- const fullArgs = ['--session', session, '--json', ...args];
- const result = execFileSync('agent-browser', fullArgs, {
+ result = execFileSync('agent-browser', fullArgs, {
encoding: 'utf-8',
timeout: 30000,
});
-
- let data;
- try {
- data = JSON.parse(result);
- } catch {
- data = result.trim();
+ } catch (error) {
+ const err = error as NodeJS.ErrnoException;
+ if (err.code === 'ENOENT') {
+ try {
+ result = execFileSync('npx', ['--yes', 'agent-browser', ...fullArgs], {
+ encoding: 'utf-8',
+ timeout: 60000,
+ });
+ } catch (npxError) {
+ const npxErr = npxError as NodeJS.ErrnoException;
+ return {
+ content: [{
+ type: 'text',
+ text: JSON.stringify({
+ success: false,
+ error: npxErr.code === 'ENOENT'
+ ? 'Neither agent-browser nor npx found. Install with: npm i -g agent-browser'
+ : npxErr instanceof Error ? npxErr.message : String(npxError),
+ }),
+ }],
+ isError: true,
+ };
+ }
+ } else {
+ return {
+ content: [{
+ type: 'text',
+ text: JSON.stringify({
+ success: false,
+ error: err instanceof Error ? err.message : String(error),
+ }),
+ }],
+ isError: true,
+ };
}
+ }
- // Update session activity
- const sessionInfo = browserSessions.get(session);
- if (sessionInfo) {
- sessionInfo.lastActivity = new Date().toISOString();
- }
+ let data;
+ try {
+ data = JSON.parse(result);
+ } catch {
+ data = result.trim();
+ }
- return {
- content: [{
- type: 'text',
- text: JSON.stringify(data, null, 2),
- }],
- };
- } catch (error) {
- return {
- content: [{
- type: 'text',
- text: JSON.stringify({
- success: false,
- error: error instanceof Error ? error.message : String(error),
- }),
- }],
- isError: true,
- };
+ const sessionInfo = browserSessions.get(session);
+ if (sessionInfo) {
+ sessionInfo.lastActivity = new Date().toISOString();
}
+
+ return {
+ content: [{
+ type: 'text',
+ text: JSON.stringify(data, null, 2),
+ }],
+ };
+}
+
+/**
+ * Detect if Linux needs --no-sandbox for Chrome.
+ */
+function needsNoSandbox(): boolean {
+ try {
+ const { readFileSync, existsSync } = require('fs');
+ if (process.platform !== 'linux') return false;
+ const clonePath = '/proc/sys/kernel/unprivileged_userns_clone';
+ if (existsSync(clonePath)) {
+ return readFileSync(clonePath, 'utf-8').trim() === '0';
+ }
+ } catch { /* not Linux or can't read */ }
+ return false;
}
/**
@@ -83,6 +123,11 @@ export const browserTools: MCPTool[] = [
enum: ['load', 'domcontentloaded', 'networkidle'],
description: 'Wait condition',
},
+ args: {
+ type: 'array',
+ items: { type: 'string' },
+ description: 'Additional Chrome launch args (e.g., ["--no-sandbox", "--disable-dev-shm-usage"])',
+ },
},
required: ['url'],
},
@@ -95,8 +140,13 @@ export const browserTools: MCPTool[] = [
session?: string;
waitUntil?: string;
};
+ const launchArgs = (input.args as string[] | undefined) || [];
+ if (needsNoSandbox() && !launchArgs.includes('--no-sandbox')) {
+ launchArgs.push('--no-sandbox');
+ }
const args = ['open', url];
if (waitUntil) args.push('--wait-until', waitUntil);
+ for (const a of launchArgs) args.push('--arg', a);
// Create session if new
const sessionId = session || 'default';
@@ -359,13 +409,13 @@ export const browserTools: MCPTool[] = [
},
{
name: 'browser_hover',
- description: 'Hover over an element',
+ description: 'Hover over an element using ref (@e1) or CSS selector',
category: 'browser',
tags: ['interaction'],
inputSchema: {
type: 'object',
properties: {
- target: { type: 'string', description: 'Element ref or CSS selector' },
+ target: { type: 'string', description: 'Element ref (@e1) or CSS selector' },
session: { type: 'string', description: 'Session ID' },
},
required: ['target'],
diff --git a/v3/@claude-flow/cli/src/mcp-tools/embeddings-tools.ts b/v3/@claude-flow/cli/src/mcp-tools/embeddings-tools.ts
index a825e66f18..c39237b68c 100644
--- a/v3/@claude-flow/cli/src/mcp-tools/embeddings-tools.ts
+++ b/v3/@claude-flow/cli/src/mcp-tools/embeddings-tools.ts
@@ -471,7 +471,7 @@ export const embeddingsTools: MCPTool[] = [
query,
limit: topK,
threshold,
- namespace: namespace || 'default'
+ namespace: namespace || 'all'
});
const searchTime = (performance.now() - startTime).toFixed(2);
@@ -489,7 +489,7 @@ export const embeddingsTools: MCPTool[] = [
model: config.model,
topK,
threshold,
- namespace: namespace || 'default',
+ namespace: namespace || 'all',
searchTime: `${searchTime}ms`,
indexType: config.hyperbolic.enabled ? 'HNSW (hyperbolic)' : 'HNSW (euclidean)',
resultCount: searchResult.results.length
@@ -506,7 +506,7 @@ export const embeddingsTools: MCPTool[] = [
model: config.model,
topK,
threshold,
- namespace: namespace || 'default',
+ namespace: namespace || 'all',
searchTime: `${searchTime}ms`,
indexType: config.hyperbolic.enabled ? 'HNSW (hyperbolic)' : 'HNSW (euclidean)',
},
diff --git a/v3/@claude-flow/cli/src/memory/memory-bridge.ts b/v3/@claude-flow/cli/src/memory/memory-bridge.ts
index c0659766e1..418f0c7c65 100644
--- a/v3/@claude-flow/cli/src/memory/memory-bridge.ts
+++ b/v3/@claude-flow/cli/src/memory/memory-bridge.ts
@@ -1829,6 +1829,62 @@ export async function bridgeSemanticRoute(params: { input: string }): Promise<an
} catch (e: any) { return { route: null, error: e.message }; }
}
+// ===== RaBitQ data export =====
+
+/**
+ * Export all embeddings from the bridge's better-sqlite3 connection.
+ * Used by RaBitQ to build its index from the same data that memory_store writes.
+ * Returns null if bridge is unavailable (caller falls back to sql.js).
+ */
+export async function bridgeGetAllEmbeddings(options?: {
+ dimensions?: number;
+ limit?: number;
+ dbPath?: string;
+}): Promise<Array<{
+ id: string;
+ key: string;
+ namespace: string;
+ embedding: number[];
+}> | null> {
+ const registry = await getRegistry(options?.dbPath);
+ if (!registry) return null;
+
+ const ctx = getDb(registry);
+ if (!ctx) return null;
+
+ try {
+ const dims = options?.dimensions ?? 384;
+ const maxRows = options?.limit ?? 50000;
+
+ const rows: any[] = ctx.db.prepare(`
+ SELECT id, key, namespace, embedding
+ FROM memory_entries
+ WHERE status = 'active' AND embedding IS NOT NULL
+ LIMIT ?
+ `).all(maxRows);
+
+ const results: Array<{ id: string; key: string; namespace: string; embedding: number[] }> = [];
+
+ for (const row of rows) {
+ if (!row.embedding) continue;
+ try {
+ const emb = JSON.parse(row.embedding) as number[];
+ if (emb.length !== dims) continue;
+ results.push({
+ id: String(row.id),
+ key: row.key || String(row.id),
+ namespace: row.namespace || 'default',
+ embedding: emb,
+ });
+ } catch { /* skip invalid */ }
+ }
+
+ return results;
+ } catch {
+ return null;
+ }
+}
+
// ===== Utility =====
function cosineSim(a: number[], b: number[]): number {
diff --git a/v3/@claude-flow/cli/src/memory/rabitq-index.ts b/v3/@claude-flow/cli/src/memory/rabitq-index.ts
index 6bbbeb3141..9ea096b11b 100644
--- a/v3/@claude-flow/cli/src/memory/rabitq-index.ts
+++ b/v3/@claude-flow/cli/src/memory/rabitq-index.ts
@@ -95,45 +95,61 @@ export async function buildRabitqIndex(options?: {
const swarmDir = path.resolve(process.cwd(), '.swarm');
const dbPath = options?.dbPath ? path.resolve(options.dbPath) : path.join(swarmDir, 'memory.db');
- if (!fs.existsSync(dbPath)) {
- rabitqInitializing = false;
- return { success: false, vectorCount: 0, dimensions, compressionRatio: 0, buildTimeMs: 0, error: 'Database not found' };
- }
-
- // Load embeddings from SQLite
- const initSqlJs = (await import('sql.js')).default;
- const SQL = await initSqlJs();
- const fileBuffer = fs.readFileSync(dbPath);
- const db = new SQL.Database(fileBuffer);
-
- const result = db.exec(`
- SELECT id, key, namespace, embedding
- FROM memory_entries
- WHERE status = 'active' AND embedding IS NOT NULL
- LIMIT 50000
- `);
-
const entries: RabitqEntry[] = [];
const vectors: number[] = [];
- if (result[0]?.values) {
- for (const row of result[0].values) {
- const [id, key, ns, embeddingJson] = row as [string, string, string, string];
- if (!embeddingJson) continue;
+ // Try bridge first (reads via better-sqlite3, sees WAL data)
+ let usedBridge = false;
+ try {
+ const { bridgeGetAllEmbeddings } = await import('./memory-bridge.js');
+ const bridgeRows = await bridgeGetAllEmbeddings({ dimensions, dbPath: options?.dbPath });
+ if (bridgeRows && bridgeRows.length > 0) {
+ for (const row of bridgeRows) {
+ entries.push({ id: row.id, key: row.key, namespace: row.namespace });
+ vectors.push(...row.embedding);
+ }
+ usedBridge = true;
+ }
+ } catch { /* bridge unavailable, fall through */ }
- try {
- const embedding = JSON.parse(embeddingJson) as number[];
- if (embedding.length !== dimensions) continue;
+ // Fallback: read .swarm/memory.db via sql.js
+ if (!usedBridge) {
+ if (!fs.existsSync(dbPath)) {
+ rabitqInitializing = false;
+ return { success: false, vectorCount: 0, dimensions, compressionRatio: 0, buildTimeMs: 0, error: 'Database not found' };
+ }
- entries.push({ id: String(id), key: key || String(id), namespace: ns || 'default' });
- vectors.push(...embedding);
- } catch {
- // skip invalid
+ const initSqlJs = (await import('sql.js')).default;
+ const SQL = await initSqlJs();
+ const fileBuffer = fs.readFileSync(dbPath);
+ const db = new SQL.Database(fileBuffer);
+
+ const result = db.exec(`
+ SELECT id, key, namespace, embedding
+ FROM memory_entries
+ WHERE status = 'active' AND embedding IS NOT NULL
+ LIMIT 50000
+ `);
+
+ if (result[0]?.values) {
+ for (const row of result[0].values) {
+ const [id, key, ns, embeddingJson] = row as [string, string, string, string];
+ if (!embeddingJson) continue;
+
+ try {
+ const embedding = JSON.parse(embeddingJson) as number[];
+ if (embedding.length !== dimensions) continue;
+
+ entries.push({ id: String(id), key: key || String(id), namespace: ns || 'default' });
+ vectors.push(...embedding);
+ } catch {
+ // skip invalid
+ }
}
}
- }
- db.close();
+ db.close();
+ }
if (entries.length < 2) {
rabitqInitializing = false;