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(proxy): complete Windows OAuth service flow

ruvnet87101e28bc81
diff --git a/v3/@claude-flow/cli/src/commands/proxy-lifecycle.ts b/v3/@claude-flow/cli/src/commands/proxy-lifecycle.ts
index ed54dfec7f..6eb65f9837 100644
--- a/v3/@claude-flow/cli/src/commands/proxy-lifecycle.ts
+++ b/v3/@claude-flow/cli/src/commands/proxy-lifecycle.ts
@@ -152,7 +152,7 @@ const superviseSub: Command = {
description: 'Internal detached supervisor for token refresh and meta-proxy lifecycle',
action: async (): Promise<CommandResult> => {
await startTokenRefreshPump();
- await startForeground();
+ await startForeground(true);
return { success: true };
},
};
diff --git a/v3/@claude-flow/cli/src/proxy/lifecycle.ts b/v3/@claude-flow/cli/src/proxy/lifecycle.ts
index 579b5ba141..9095634388 100644
--- a/v3/@claude-flow/cli/src/proxy/lifecycle.ts
+++ b/v3/@claude-flow/cli/src/proxy/lifecycle.ts
@@ -124,17 +124,27 @@ function releaseStartLock(fd: number | null): void {
* straight through to the terminal; signals (Ctrl+C) propagate naturally to
* the child, no manual forwarding needed.
*/
-export async function startForeground(): Promise<never> {
+export async function startForeground(supervised = false): Promise<never> {
const bin = requireBinary();
const status = getProxyStatus();
- if (status.running && status.pid) throw new ProxyAlreadyRunningError(status.pid);
+ // In service mode startBackground has already written this supervisor's
+ // PID. Treating it as a competing proxy makes the supervisor immediately
+ // exit before it can spawn meta-proxy.
+ if (!supervised && status.running && status.pid) throw new ProxyAlreadyRunningError(status.pid);
if (status.stalePidFile) clearStalePidFile();
const child = spawn(bin, [], { stdio: 'inherit', windowsHide: false });
- if (child.pid) writePidFile(child.pid);
+ if (!supervised && child.pid) writePidFile(child.pid);
const cleanup = () => clearStalePidFile();
process.on('exit', cleanup);
+ if (supervised) {
+ const forwardSignal = (signal: NodeJS.Signals) => {
+ if (!child.killed) child.kill(signal);
+ };
+ process.once('SIGTERM', () => forwardSignal('SIGTERM'));
+ process.once('SIGINT', () => forwardSignal('SIGINT'));
+ }
await new Promise<void>((resolve) => {
child.on('exit', () => {
diff --git a/v3/@claude-flow/security/__tests__/oauth-browser.test.ts b/v3/@claude-flow/security/__tests__/oauth-browser.test.ts
new file mode 100644
index 0000000000..d8ce728bbf
--- /dev/null
+++ b/v3/@claude-flow/security/__tests__/oauth-browser.test.ts
@@ -0,0 +1,13 @@
+import { describe, expect, it } from 'vitest';
+import { browserCommand } from '../src/oauth/browser.js';
+
+describe('OAuth browser launcher', () => {
+ it('preserves the complete OAuth query string on Windows without cmd.exe', () => {
+ const url = 'https://auth.cognitum.one/oauth/authorize?response_type=code&client_id=meta-proxy&state=test';
+ const launch = browserCommand(url, 'win32');
+
+ expect(launch.cmd).toBe('rundll32.exe');
+ expect(launch.args).toEqual(['url.dll,FileProtocolHandler', url]);
+ expect(launch.args[1]).toContain('&client_id=meta-proxy&');
+ });
+});
diff --git a/v3/@claude-flow/security/src/oauth/browser.ts b/v3/@claude-flow/security/src/oauth/browser.ts
index 992e6c4112..ac54e00fba 100644
--- a/v3/@claude-flow/security/src/oauth/browser.ts
+++ b/v3/@claude-flow/security/src/oauth/browser.ts
@@ -36,22 +36,23 @@ function assertSafeUrl(url: string): void {
export function openBrowser(url: string): Promise<void> {
assertSafeUrl(url);
- let cmd: string;
- let args: string[];
- if (process.platform === 'darwin') {
- cmd = 'open';
- args = [url];
- } else if (process.platform === 'win32') {
- // `cmd /c start "" <url>` — the empty title arg avoids `start` treating a
- // quoted URL as the window title.
- cmd = 'cmd';
- args = ['/c', 'start', '', url];
- } else {
- cmd = 'xdg-open';
- args = [url];
- }
+ const { cmd, args } = browserCommand(url);
return new Promise((resolve) => {
execFile(cmd, args, { shell: false, windowsHide: true }, () => resolve());
});
}
+
+/** Pure command selection, exported for platform regression tests. */
+export function browserCommand(url: string, platform: NodeJS.Platform = process.platform): { cmd: string; args: string[] } {
+ assertSafeUrl(url);
+ if (platform === 'darwin') {
+ return { cmd: 'open', args: [url] };
+ } else if (platform === 'win32') {
+ // cmd.exe treats OAuth query-string `&` separators as command operators,
+ // truncating the URL before client_id. Use the URL handler without a shell.
+ return { cmd: 'rundll32.exe', args: ['url.dll,FileProtocolHandler', url] };
+ } else {
+ return { cmd: 'xdg-open', args: [url] };
+ }
+}