Skip to content

Where agent teams gather. Cross-platform team chat where AI agents are first-class teammates — with cloud or bring-your-own (Claude Code / Codex) brains.

TypeScript

refactor(byoa): one source of truth for the engines a user can pick

Xialie Zhuang1aa6f9baeb96
diff --git a/server/src/agents/computer/registry.ts b/server/src/agents/computer/registry.ts
index 2d96c42..cc41a0c 100644
--- a/server/src/agents/computer/registry.ts
+++ b/server/src/agents/computer/registry.ts
@@ -44,8 +44,17 @@ export async function announceComputerOnline(computerId: string, companyId: stri
await broadcastComputerStatus(computerId, companyId, 'online')
}
-/** Engines a paired (non-cloud) computer is allowed to advertise. */
-const PAIRABLE_ENGINES: ReadonlySet<string> = new Set(['claude', 'codex', 'grok', 'cursor', 'opencode', 'pi', 'gemini'])
+/** Engines a paired (non-cloud) computer is allowed to advertise.
+ *
+ * Spelled as a Record over the engine union rather than a Set literal so the
+ * COMPILER is what notices a new engine, not a reviewer: adding an id to
+ * EngineId makes this fail to compile until the id is classified here. A
+ * plain `new Set([...])` accepted an incomplete list silently, and the engine
+ * left out of it could be detected and shown but never actually paired. */
+const PAIRABLE: Record<Exclude<EngineId, 'managed'>, true> = {
+ claude: true, codex: true, grok: true, cursor: true, opencode: true, pi: true, gemini: true,
+}
+const PAIRABLE_ENGINES: ReadonlySet<string> = new Set<string>(Object.keys(PAIRABLE))
/** Merge a fresh PATH detection into a computer's advertised engine list.
*
diff --git a/src/desktop/MeView.tsx b/src/desktop/MeView.tsx
index 480f7c8..f33ca6b 100644
--- a/src/desktop/MeView.tsx
+++ b/src/desktop/MeView.tsx
@@ -12,7 +12,7 @@ import { LanguagePicker } from '@/components/LanguagePicker'
import { useT, type MessageKey } from '@/lib/i18n'
import { cn } from '@/lib/utils'
import { api, getPairingServerOrigin, getServerOrigin, type ApiProject, type ApiQuotaSnapshot, type ApiQuotaWindow } from '@/api/client'
-import { ENGINE_BIN, ENGINE_LABEL, RUNNABLE_ENGINE_IDS, engineLabel } from '@/lib/engines'
+import { ENGINE_BIN, ENGINE_LABEL, RUNNABLE_ENGINES, RUNNABLE_ENGINE_IDS, engineLabel, type RunnableEngineId } from '@/lib/engines'
import type { Computer, EngineId } from '@/types'
// The tab's identity is its `key`; the label is a message key resolved at
@@ -830,7 +830,7 @@ function ComputersTab() {
// Engine for a NEWLY added computer's starter/assigned agents. Claude is the
// default (no flag → daemon auto-detects); every other pick is named
// explicitly, or the daemon auto-detects and engines[0] silently wins.
- const [engine, setEngine] = useState<'claude' | 'codex' | 'grok' | 'cursor' | 'opencode' | 'pi' | 'gemini'>('claude')
+ const [engine, setEngine] = useState<RunnableEngineId>('claude')
// Default on: install the always-on service (auto-start/restart/update).
const [asService, setAsService] = useState(true)
// Per-computer re-pair (reconnect) command, keyed by computer id.
@@ -1134,13 +1134,13 @@ function ComputersTab() {
<div className="flex items-center gap-2.5 mb-2.5">
<span className="text-[12px] text-ink-500">{t('me.engineLabel')}</span>
<div className="inline-flex rounded-[9px] p-0.5" style={{ background: 'var(--ink-100)' }}>
- {([['claude', 'Claude Code'], ['codex', 'Codex'], ['grok', 'Grok Build'], ['cursor', 'Cursor'], ['opencode', 'OpenCode'], ['pi', 'pi'], ['gemini', 'Gemini']] as const).map(([id, label]) => (
+ {RUNNABLE_ENGINES.map((id) => (
<button key={id} type="button" onClick={() => setEngine(id)}
className="px-3 py-1 rounded-[7px] text-[12px] font-semibold transition-colors duration-150"
style={engine === id
? { background: 'var(--paper)', color: 'var(--ink-900)', boxShadow: '0 1px 2px rgba(0,0,0,0.08)' }
: { color: 'var(--ink-500)' }}>
- {label}
+ {engineLabel(id)}
</button>
))}
</div>
diff --git a/src/desktop/Onboarding.tsx b/src/desktop/Onboarding.tsx
index 28563c0..20bacf8 100644
--- a/src/desktop/Onboarding.tsx
+++ b/src/desktop/Onboarding.tsx
@@ -3,6 +3,7 @@ import { api, getPairingServerOrigin } from '@/api/client'
import { useComputers } from '@/stores/computers'
import { TitleBar } from '@/desktop/TitleBar'
import { useT } from '@/lib/i18n'
+import { RUNNABLE_ENGINES, engineLabel, type RunnableEngineId } from '@/lib/engines'
/**
* First-run gate for free-tier users: their agents run on their own machine
@@ -21,7 +22,7 @@ export function Onboarding() {
// Claude is the default; ANY other pick must be named explicitly. We DON'T
// append `--engine claude` so a Claude-less machine still auto-detects rather
// than erroring on a Claude it doesn't have.
- const [engine, setEngine] = useState<'claude' | 'codex' | 'grok' | 'cursor' | 'opencode' | 'pi' | 'gemini'>('claude')
+ const [engine, setEngine] = useState<RunnableEngineId>('claude')
// Default to installing the always-on service: it auto-starts at sign-in,
// auto-restarts on crash, and auto-updates — so the user isn't tied to a
// terminal that must stay open. Appends `--install-service` to the command.
@@ -87,13 +88,13 @@ export function Onboarding() {
<div className="flex items-center gap-2.5 mb-2.5">
<span className="text-[12px] text-ink-500">{t('onboard.engine')}</span>
<div className="inline-flex rounded-[9px] p-0.5" style={{ background: 'var(--ink-100)' }}>
- {([['claude', 'Claude Code'], ['codex', 'Codex'], ['grok', 'Grok Build'], ['cursor', 'Cursor'], ['opencode', 'OpenCode'], ['pi', 'pi'], ['gemini', 'Gemini']] as const).map(([id, label]) => (
+ {RUNNABLE_ENGINES.map((id) => (
<button key={id} type="button" onClick={() => setEngine(id)}
className="px-3 py-1 rounded-[7px] text-[12px] font-semibold transition-colors duration-150"
style={engine === id
? { background: 'var(--paper)', color: 'var(--ink-900)', boxShadow: '0 1px 2px rgba(0,0,0,0.08)' }
: { color: 'var(--ink-500)' }}>
- {label}
+ {engineLabel(id)}
</button>
))}
</div>
diff --git a/src/lib/engines.ts b/src/lib/engines.ts
index 80b0bda..41aa4ec 100644
--- a/src/lib/engines.ts
+++ b/src/lib/engines.ts
@@ -25,8 +25,19 @@ export const ENGINE_BIN: Record<string, string> = {
hermes: 'hermes',
}
-/** Engines Cumora can actually wake. Everything else is detect-only. */
-export const RUNNABLE_ENGINE_IDS = new Set(['claude', 'codex', 'grok', 'cursor', 'opencode', 'pi', 'gemini'])
+/** Engines Cumora can actually wake, in the order pickers should offer them.
+ * Everything else in ENGINE_LABEL is detect-only: the Me page can tell you it
+ * is installed, but no adapter can drive it.
+ *
+ * One declaration, three shapes — the ordered list for UI, the type for the
+ * state that holds a choice, and the set for membership tests. Engine pickers
+ * used to inline their own copy of this list *and* their own copy of the
+ * labels, which is how adding an engine could leave it unselectable. */
+export const RUNNABLE_ENGINES = ['claude', 'codex', 'grok', 'cursor', 'opencode', 'pi', 'gemini'] as const
+
+export type RunnableEngineId = typeof RUNNABLE_ENGINES[number]
+
+export const RUNNABLE_ENGINE_IDS: ReadonlySet<string> = new Set<string>(RUNNABLE_ENGINES)
export function engineLabel(id: string): string {
return ENGINE_LABEL[id] ?? id