Skip to content

armgit / Orkas

Public Imported from GitHub
0

Orkas is an open-source (MIT), local-first AI team for your desktop: a Commander turns your goal into to-dos and coordinates 16 built-in specialist agents plus Claude Code, Codex, OpenCode, OpenClaw and Hermes, with projects, scheduled automations and connectors. Free app for macOS & Windows; built-in models or your own keys.

Fix external CLI picker registration

wyt08b020f7e140
diff --git a/src/main/features/local_agents/registry.ts b/src/main/features/local_agents/registry.ts
index 17eb47aa..7e7785bb 100644
--- a/src/main/features/local_agents/registry.ts
+++ b/src/main/features/local_agents/registry.ts
@@ -18,7 +18,8 @@
import { createLogger } from '../../logger.js';
import { whichBin } from './which.js';
-import { checkMinVersion, detectVersion } from './version.js';
+import { checkMinVersion, detectVersion, parseSemver } from './version.js';
+import * as fs from 'node:fs/promises';
import * as os from 'node:os';
import * as path from 'node:path';
@@ -70,6 +71,29 @@ function defaultSearchDirs(type: LocalCliType): string[] {
return dirs;
}
+async function detectCodexPackageVersion(binPath: string): Promise<string | null> {
+ let dir: string;
+ try { dir = path.dirname(await fs.realpath(binPath)); }
+ catch { dir = path.dirname(binPath); }
+
+ for (let i = 0; i < 6; i += 1) {
+ const pkgPath = path.join(dir, 'package.json');
+ try {
+ const pkg = JSON.parse(await fs.readFile(pkgPath, 'utf8'));
+ if (pkg?.name === '@openai/codex' && typeof pkg.version === 'string') {
+ const sv = parseSemver(pkg.version);
+ if (sv) return `${sv.major}.${sv.minor}.${sv.patch}`;
+ }
+ } catch {
+ // Keep walking toward the npm package root.
+ }
+ const parent = path.dirname(dir);
+ if (parent === dir) break;
+ dir = parent;
+ }
+ return null;
+}
+
/** Detection result for a single CLI. */
export type LocalCliEntry = {
type: LocalCliType;
@@ -128,7 +152,12 @@ export async function detectOne(type: LocalCliType): Promise<LocalCliEntry> {
: `${BIN_NAMES[type]} not found on PATH or standard CLI install locations`,
};
}
- const version = await detectVersion(resolved);
+ // The npm @openai/codex wrapper can hang on `--version` in GUI-launched
+ // environments. Prefer its package.json version when available; fall back to
+ // the normal subprocess probe for standalone/non-npm installs.
+ const version = type === 'codex'
+ ? (await detectCodexPackageVersion(resolved)) || await detectVersion(resolved)
+ : await detectVersion(resolved);
if (!version) {
return {
type, path: resolved, version: null, available: false,
diff --git a/src/main/ipc/index.ts b/src/main/ipc/index.ts
index a4311e73..f41b45b4 100644
--- a/src/main/ipc/index.ts
+++ b/src/main/ipc/index.ts
@@ -2448,6 +2448,10 @@ const invokeHandlers: Record<string, InvokeHandler> = {
// Multi-device sync. Stripped from the open-source build (depends on account).
+ // Local coding CLI agents (Claude Code, Codex, etc.). Kept in the open-source
+ // build; the renderer's External Agent picker depends on localAgents.list.
+ ...localAgentsHandlers,
+
// Quality validator — renderer reads persisted ValidationReports to display
// why a spec write / marketplace install was rejected.
...qualityHandlers,
diff --git a/test/main/features/local_agents/registry.test.ts b/test/main/features/local_agents/registry.test.ts
index 71fce3cd..8381c23f 100644
--- a/test/main/features/local_agents/registry.test.ts
+++ b/test/main/features/local_agents/registry.test.ts
@@ -104,6 +104,27 @@ describe('local_agents/registry', () => {
expect(r.available).toBe(true);
});
+ it('uses the npm Codex package version when the wrapper has no --version output', async () => {
+ if (isWindows) return;
+ const pkgRoot = path.join(tmpDir, 'node_modules', '@openai', 'codex');
+ const binDir = path.join(pkgRoot, 'bin');
+ fs.mkdirSync(binDir, { recursive: true });
+ fs.writeFileSync(path.join(pkgRoot, 'package.json'), JSON.stringify({
+ name: '@openai/codex',
+ version: '0.130.0',
+ }));
+ const fake = path.join(binDir, 'codex.js');
+ fs.writeFileSync(fake, '#!/bin/sh\necho ""\n');
+ fs.chmodSync(fake, 0o755);
+ process.env.PATH = '';
+ process.env.ORKAS_CODEX_PATH = fake;
+
+ const r = await detectOne('codex');
+ expect(r.path).toBe(fake);
+ expect(r.version).toBe('0.130.0');
+ expect(r.available).toBe(true);
+ });
+
it('marks version_too_old when below minimum', async () => {
if (isWindows) return;
const fake = path.join(tmpDir, 'old-claude');
diff --git a/test/main/ipc/permissions.test.ts b/test/main/ipc/permissions.test.ts
index d6ce7867..86e64be8 100644
--- a/test/main/ipc/permissions.test.ts
+++ b/test/main/ipc/permissions.test.ts
@@ -31,6 +31,15 @@ beforeEach(async () => {
process.env.ORKAS_WORKSPACE_ROOT = tmpDir;
invokeHandler = null;
vi.resetModules();
+ vi.doMock('../../../src/main/ipc/local_agents', () => ({
+ invokeHandlers: {
+ 'localAgents.list': async () => ({
+ entries: [
+ { type: 'claude', path: '/usr/local/bin/claude', version: '2.1.148', available: true },
+ ],
+ }),
+ },
+ }));
const users = await import('../../../src/main/features/users');
users.activateUser(TEST_UID);
@@ -107,3 +116,13 @@ describe('ipc › permissions.* routes', () => {
expect(res.error).toMatch(/unknown channel/);
});
});
+
+describe('ipc › localAgents.* routes', () => {
+ it('registers localAgents.list for the external CLI picker', async () => {
+ const res = await call('localAgents.list');
+ expect(res.ok).toBe(true);
+ expect(res.entries).toEqual([
+ { type: 'claude', path: '/usr/local/bin/claude', version: '2.1.148', available: true },
+ ]);
+ });
+});