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(doctor): report agent-browser runtime compatibility

Rudy Celekli51cab2cba504
diff --git a/v3/@claude-flow/cli/__tests__/doctor-agent-browser-3166.test.ts b/v3/@claude-flow/cli/__tests__/doctor-agent-browser-3166.test.ts
new file mode 100644
index 0000000000..59a5cdc7ed
--- /dev/null
+++ b/v3/@claude-flow/cli/__tests__/doctor-agent-browser-3166.test.ts
@@ -0,0 +1,56 @@
+/** ADR-122 Phase 0: doctor reports the local browser runtime without launching it. */
+import { describe, expect, it } from 'vitest';
+import {
+ checkAgentBrowserVersion,
+ doctorCommand,
+ evaluateAgentBrowserVersion,
+} from '../src/commands/doctor.js';
+
+describe('#3166 agent-browser doctor check', () => {
+ it('passes a supported version and names the browser integration', () => {
+ const check = evaluateAgentBrowserVersion('agent-browser v0.37.1\n');
+ expect(check.status).toBe('pass');
+ expect(check.message).toContain('v0.37.1');
+ expect(check.message).toContain('browser MCP tools');
+ expect(evaluateAgentBrowserVersion('0.27.0').status).toBe('pass');
+ });
+
+ it('warns below 0.27 and on an older prerelease', () => {
+ for (const output of ['agent-browser 0.26.9', 'v0.27.0-rc.1']) {
+ const check = evaluateAgentBrowserVersion(output);
+ expect(check.status).toBe('warn');
+ expect(check.fix).toContain('agent-browser');
+ }
+ });
+
+ it('warns when the version output is empty or unparsable', () => {
+ for (const output of ['', 'agent-browser version unknown']) {
+ expect(evaluateAgentBrowserVersion(output).status).toBe('warn');
+ }
+ });
+
+ it('warns when the executable is missing or the bounded probe fails', async () => {
+ const missing = await checkAgentBrowserVersion(async () => {
+ throw Object.assign(new Error('spawn agent-browser ENOENT'), { code: 'ENOENT' });
+ });
+ expect(missing.status).toBe('warn');
+ expect(missing.message).toContain('Not found on PATH');
+
+ const failed = await checkAgentBrowserVersion(async () => {
+ throw new Error('probe timed out');
+ });
+ expect(failed.status).toBe('warn');
+ expect(failed.message).toContain('probe timed out');
+ });
+
+ it('exposes the check through doctor --component browser', async () => {
+ const ctx = {
+ flags: { component: 'browser' }, args: [], config: {},
+ } as unknown as Parameters<NonNullable<typeof doctorCommand.action>>[0];
+ const result = await doctorCommand.action!(ctx);
+ const data = result.data as { results: Array<{ name: string; status: string }> };
+ expect(data.results).toHaveLength(1);
+ expect(data.results[0].name).toBe('agent-browser CLI (ADR-122)');
+ expect(['pass', 'warn']).toContain(data.results[0].status);
+ });
+});
diff --git a/v3/@claude-flow/cli/src/commands/doctor.ts b/v3/@claude-flow/cli/src/commands/doctor.ts
index 5a0099f2ac..5184b77eeb 100644
--- a/v3/@claude-flow/cli/src/commands/doctor.ts
+++ b/v3/@claude-flow/cli/src/commands/doctor.ts
@@ -11,7 +11,7 @@ import { existsSync, readFileSync, statSync, openSync, readSync, closeSync } fro
import { join, dirname } from 'path';
import { fileURLToPath } from 'url';
import { createHash } from 'crypto';
-import { execSync, exec } from 'child_process';
+import { execSync, exec, execFile } from 'child_process';
import { promisify } from 'util';
import { decodeKey, isEncryptionEnabled } from '../encryption/vault.js';
import { isEncryptedBlob } from '../encryption/vault.js';
@@ -25,6 +25,7 @@ import {
// Promisified exec with proper shell and env inheritance for cross-platform support
const execAsync = promisify(exec);
+const execFileAsync = promisify(execFile);
/**
* Execute command asynchronously with proper environment inheritance
@@ -78,6 +79,42 @@ async function checkNpmVersion(): Promise<HealthCheck> {
}
}
+/** ADR-122 Phase 0: probe only the CLI version, without launching a browser. */
+export function evaluateAgentBrowserVersion(rawOutput: string): HealthCheck {
+ const name = 'agent-browser CLI (ADR-122)';
+ const fix = 'npm install -g agent-browser@latest';
+ const versionOutput = rawOutput.trim().replace(/\x1b\[[0-9;]*m/g, '');
+ const match = /^(?:agent-browser(?:\s+version)?\s+)?v?(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)(?:\s|$)/i.exec(versionOutput);
+ const version = match ? semver.parse(match[1]) : null;
+ if (!version) {
+ return { name, status: 'warn', message: `Unable to parse agent-browser version${versionOutput ? `: ${versionOutput.slice(0, 120)}` : ' (empty output)'}. Browser MCP tools may be unavailable.`, fix };
+ }
+ if (semver.lt(version, '0.27.0')) {
+ return { name, status: 'warn', message: `v${version.version} is below the ADR-122 v0.27.0 minimum for browser MCP tools`, fix };
+ }
+ return { name, status: 'pass', message: `v${version.version} meets the ADR-122 v0.27.0 minimum for browser MCP tools` };
+}
+
+export async function checkAgentBrowserVersion(
+ probe: () => Promise<string> = async () => {
+ const { stdout } = await execFileAsync('agent-browser', ['--version'], {
+ encoding: 'utf8', timeout: 3000, maxBuffer: 16 * 1024, windowsHide: true,
+ });
+ return String(stdout);
+ },
+): Promise<HealthCheck> {
+ try {
+ return evaluateAgentBrowserVersion(await probe());
+ } catch (error) {
+ const name = 'agent-browser CLI (ADR-122)';
+ const fix = 'npm install -g agent-browser@latest';
+ const code = (error as NodeJS.ErrnoException).code;
+ return code === 'ENOENT'
+ ? { name, status: 'warn', message: 'Not found on PATH; @claude-flow/browser and browser MCP tools need agent-browser v0.27.0 or newer', fix }
+ : { name, status: 'warn', message: `Version check failed: ${error instanceof Error ? error.message : String(error)}`, fix };
+ }
+}
+
// Check config file
async function checkConfigFile(): Promise<HealthCheck> {
// JSON configs (parse-validated). The first three are LEGACY shapes from
@@ -2380,7 +2417,7 @@ export const doctorCommand: Command = {
{
name: 'component',
short: 'c',
- description: 'Check specific component (version, node, npm, config, daemon, memory, api, git, mcp, mcp-overhead, claude, disk, typescript, agentic-flow, encryption, federation, funnel, proxy, auth, typesafe, metaharness)',
+ description: 'Check specific component (version, node, npm, config, daemon, memory, api, git, mcp, mcp-overhead, claude, browser, disk, typescript, agentic-flow, encryption, federation, funnel, proxy, auth, typesafe, metaharness)',
type: 'string'
},
{
@@ -2500,6 +2537,7 @@ export const doctorCommand: Command = {
checkNodeVersion,
checkNpmVersion,
checkClaudeCode,
+ checkAgentBrowserVersion, // ADR-122 Phase 0 — browser runtime compatibility
checkGit,
checkGitRepo,
checkConfigFile,
@@ -2541,6 +2579,7 @@ export const doctorCommand: Command = {
'node': checkNodeVersion,
'npm': checkNpmVersion,
'claude': checkClaudeCode,
+ 'browser': checkAgentBrowserVersion,
'config': checkConfigFile,
'stale-settings': checkStaleSettingsNpx, // #2448
'daemon': checkDaemonStatus,