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

feat(byoa): tell the operator why an installed engine is not being used

Xialie Zhuang626a5db57d07
diff --git a/server/src/__tests__/agents-computer-blocked-engines.test.ts b/server/src/__tests__/agents-computer-blocked-engines.test.ts
new file mode 100644
index 0000000..dcbe7dc
--- /dev/null
+++ b/server/src/__tests__/agents-computer-blocked-engines.test.ts
@@ -0,0 +1,132 @@
+/**
+ * Surfacing the reason an installed engine is refused.
+ *
+ * `evaluateRunnableEngines()` already computes why it declined an engine — an
+ * old CLI, a missing sandbox dependency — but that reason only ever reached the
+ * daemon's own stdout. Whoever reads the Computers card is usually not sitting
+ * at that machine, which is the same argument the version fields are carried
+ * for, so the engine simply went absent with no explanation anywhere visible.
+ *
+ * The safety property these pin is the separation: a blocked engine is a
+ * DISPLAY row and must never reach `available_engines`, because that list is
+ * what picks an agent's adapter. Letting one through would run exactly what the
+ * sandbox gate refused.
+ *
+ * Run: node --import tsx --test server/src/__tests__/agents-computer-blocked-engines.test.ts
+ */
+
+import assert from 'node:assert/strict'
+import { test } from 'node:test'
+
+process.env.CUMORA_RUNTIME_CLIENT = 'http'
+process.env.OPENAI_API_KEY ??= 'test-key'
+
+const { sanitizeDetectedEngines } = await import('../agents/computer/registry.js')
+
+const OLD_CLAUDE = 'version 2.0.9 is older than the secure minimum 2.1.248'
+
+test('a blocked engine becomes a display row carrying its reason', () => {
+ const out = sanitizeDetectedEngines(
+ [
+ { id: 'codex', bin: 'codex', path: '/usr/local/bin/codex' },
+ { id: 'claude', bin: 'claude', path: '/usr/local/bin/claude', blockedReason: OLD_CLAUDE },
+ ],
+ ['codex'],
+ ['claude'],
+ )
+ assert.deepEqual(out.map((e) => e.id), ['codex', 'claude'])
+ assert.equal(out.find((e) => e.id === 'codex')?.blockedReason, null)
+ assert.equal(out.find((e) => e.id === 'claude')?.blockedReason, OLD_CLAUDE)
+ // The path still shows: "installed here, and here is where" is half the
+ // point of telling the operator it was refused.
+ assert.equal(out.find((e) => e.id === 'claude')?.path, '/usr/local/bin/claude')
+})
+
+test('a reason on a RUNNABLE engine is discarded', () => {
+ // Otherwise a daemon could mark a perfectly good engine broken in the UI.
+ // Only the ids the caller passed as blocked may carry a reason.
+ const out = sanitizeDetectedEngines(
+ [{ id: 'codex', bin: 'codex', path: '/bin/codex', blockedReason: 'not actually blocked' }],
+ ['codex'],
+ [],
+ )
+ assert.equal(out[0].blockedReason, null)
+})
+
+test('an id claimed as both runnable and blocked stays runnable', () => {
+ // Runnable wins, and it appears exactly once — a duplicate row would render
+ // the same engine twice, once contradicting the other.
+ const out = sanitizeDetectedEngines(
+ [{ id: 'claude', bin: 'claude', path: '/bin/claude', blockedReason: OLD_CLAUDE }],
+ ['claude'],
+ ['claude'],
+ )
+ assert.equal(out.length, 1)
+ assert.equal(out[0].id, 'claude')
+ assert.equal(out[0].blockedReason, null)
+})
+
+test('blocked ids do not disturb the runnable order', () => {
+ // available_engines[0] is the computer's DEFAULT engine. Blocked rows are
+ // appended, never interleaved, so adding this display data cannot silently
+ // repoint which adapter an agent gets.
+ const out = sanitizeDetectedEngines(
+ [
+ { id: 'codex', bin: 'codex', path: '/bin/codex' },
+ { id: 'gemini', bin: 'gemini', path: '/bin/gemini' },
+ { id: 'claude', bin: 'claude', path: '/bin/claude', blockedReason: OLD_CLAUDE },
+ ],
+ ['codex', 'gemini'],
+ ['claude'],
+ )
+ assert.deepEqual(out.map((e) => e.id), ['codex', 'gemini', 'claude'])
+})
+
+test('an unknown blocked id is dropped like any other', () => {
+ // The pairable allowlist governs both lists; a newer daemon naming an engine
+ // this server has no adapter for must not create a phantom row.
+ const out = sanitizeDetectedEngines(
+ [{ id: 'hermes', bin: 'hermes', path: '/bin/hermes', blockedReason: 'nope' }],
+ ['codex'],
+ ['hermes'],
+ )
+ assert.deepEqual(out.map((e) => e.id), ['codex'])
+})
+
+test('a hostile reason is trimmed and length-capped like every other display string', () => {
+ const out = sanitizeDetectedEngines(
+ [{ id: 'claude', bin: 'claude', path: '/bin/claude', blockedReason: ` ${'x'.repeat(500)} ` }],
+ [],
+ ['claude'],
+ )
+ const reason = out[0].blockedReason ?? ''
+ assert.ok(reason.length <= 200, `reason was ${reason.length} chars`)
+ assert.ok(!reason.startsWith(' ') && !reason.endsWith(' '))
+})
+
+test('a non-string reason is dropped rather than rendered', () => {
+ const out = sanitizeDetectedEngines(
+ [{ id: 'claude', bin: 'claude', path: '/bin/claude', blockedReason: { evil: true } }],
+ [],
+ ['claude'],
+ )
+ assert.equal(out[0].blockedReason, null)
+})
+
+test('omitting the blocked list keeps the previous behaviour exactly', () => {
+ // Every existing caller passes two arguments; the third must be optional and
+ // change nothing when absent.
+ const out = sanitizeDetectedEngines(
+ [{ id: 'codex', bin: 'codex', path: '/bin/codex' }],
+ ['codex'],
+ )
+ assert.deepEqual(out.map((e) => e.id), ['codex'])
+ assert.equal(out[0].blockedReason, null)
+})
+
+test('a blocked engine the daemon reported nothing about still gets a row', () => {
+ // The reason is the point of the row, but even without one the operator
+ // should see that the engine is installed and unused rather than missing.
+ const out = sanitizeDetectedEngines(null, ['codex'], ['claude'])
+ assert.deepEqual(out.map((e) => e.id), ['codex', 'claude'])
+})
diff --git a/server/src/__tests__/agents-computer-engine-detect.test.ts b/server/src/__tests__/agents-computer-engine-detect.test.ts
index 024da13..0fec0f1 100644
--- a/server/src/__tests__/agents-computer-engine-detect.test.ts
+++ b/server/src/__tests__/agents-computer-engine-detect.test.ts
@@ -48,8 +48,10 @@ test('sanitizeDetectedEngines drops unknown ids and fills missing bins', () => {
['claude', 'codex', 'gemini', 'bogus'],
)
// Version fields come back on every row — null here, since a daemon this old
- // reports paths only. See agents-computer-engine-version.test.ts.
- const noVersion = { version: null, latest: null, outdated: false, updateCommand: null }
+ // reports paths only. See agents-computer-engine-version.test.ts. blockedReason
+ // is null for the same reason every key is present on every row: the app must
+ // never have to tell "field absent" from "nothing to report".
+ const noVersion = { version: null, latest: null, outdated: false, updateCommand: null, blockedReason: null }
assert.deepEqual(out, [
{ id: 'claude', bin: 'claude', path: '/usr/bin/claude', ...noVersion },
{ id: 'codex', bin: 'codex', path: null, ...noVersion },
diff --git a/server/src/__tests__/agents-computer-engine-version.test.ts b/server/src/__tests__/agents-computer-engine-version.test.ts
index 1c4486b..4610fb5 100644
--- a/server/src/__tests__/agents-computer-engine-version.test.ts
+++ b/server/src/__tests__/agents-computer-engine-version.test.ts
@@ -118,6 +118,7 @@ test('sanitizeDetectedEngines carries version fields through', () => {
id: 'codex', bin: 'codex', path: '/usr/local/bin/codex',
version: '0.5.0', latest: '0.6.0', outdated: true,
updateCommand: 'npm install -g @openai/codex@latest',
+ blockedReason: null,
}])
})
diff --git a/server/src/agents/computer/daemon.ts b/server/src/agents/computer/daemon.ts
index 9f09aa8..ae0eb8e 100644
--- a/server/src/agents/computer/daemon.ts
+++ b/server/src/agents/computer/daemon.ts
@@ -3096,17 +3096,33 @@ async function doRun(serverOverride?: string): Promise<void> {
// engine's version *as installed on this machine*: the app renders it
// verbatim and never probes its own PATH, because whoever is looking at
// the card is usually not sitting at the machine it describes.
- const snapshot = await enrichDetectedEngines(await snapshotDetectedEngines(next))
+ // Blocked engines ride along as extra display rows carrying the reason
+ // they were refused. Until now that reason existed only as the
+ // console.warn above — on a machine the operator is usually not sitting
+ // at — so an engine could disappear from the card with no explanation
+ // anywhere they could see. They stay OUT of `next`: that list becomes
+ // available_engines and picks an agent's adapter.
+ const blockedIds = evaluated.blocked.map(({ id }) => id)
+ const blockedRows = (await snapshotDetectedEngines(blockedIds)).map((row) => ({
+ ...row,
+ blockedReason: evaluated.blocked.find(({ id }) => id === row.id)?.reason,
+ }))
+ const snapshot = [
+ ...await enrichDetectedEngines(await snapshotDetectedEngines(next)),
+ ...await enrichDetectedEngines(blockedRows),
+ ]
// Report on version drift too, not just install/uninstall — upgrading an
// engine in place leaves the engine *list* identical, and that is exactly
- // when the card's version line goes stale.
+ // when the card's version line goes stale. The blocked reasons are part
+ // of the fingerprint: fixing the cause (upgrading the CLI, installing
+ // bwrap) has to clear the card, not wait for an unrelated change.
const fingerprint = JSON.stringify(snapshot)
if (shouldReportEngineSnapshot(fingerprint, lastEngineSnapshot, forceReport)) {
lastEngineSnapshot = fingerprint
await api(cfg.serverUrl, '/api/computers/me/engines', {
method: 'POST',
headers: { Authorization: `Bearer ${cfg.deviceToken}` },
- body: JSON.stringify({ engines: next, detected: snapshot }),
+ body: JSON.stringify({ engines: next, detected: snapshot, blocked: blockedIds }),
}).catch((err) => {
console.warn('[computer] engine snapshot report failed', err instanceof Error ? err.message : err)
})
diff --git a/server/src/agents/computer/engine.ts b/server/src/agents/computer/engine.ts
index 5b8939e..6a3b56a 100644
--- a/server/src/agents/computer/engine.ts
+++ b/server/src/agents/computer/engine.ts
@@ -4583,6 +4583,9 @@ export interface DetectedEngineSnapshot {
latest?: string | null
outdated?: boolean
updateCommand?: string | null
+ /** Why this installed engine will NOT be driven — the reason
+ * evaluateRunnableEngines() produced. Absent on runnable engines. */
+ blockedReason?: string
}
/** Snapshot the installed engines, optionally in a caller-supplied order
diff --git a/server/src/agents/computer/registry.ts b/server/src/agents/computer/registry.ts
index d686ebf..7a7f138 100644
--- a/server/src/agents/computer/registry.ts
+++ b/server/src/agents/computer/registry.ts
@@ -116,6 +116,16 @@ export interface DetectedEngine {
latest?: string | null
outdated?: boolean
updateCommand?: string | null
+ /** Why Cumora will not drive this engine even though it is installed here —
+ * "version 2.0.9 is older than the secure minimum 2.1.248", "missing sandbox
+ * dependency: bubblewrap (bwrap)". Absent when the engine is runnable.
+ *
+ * This travels because the person reading the card is usually not sitting at
+ * the machine it describes — the same reason the version fields do. The
+ * daemon knew the reason all along and only wrote it to its own stdout, so
+ * an engine could vanish from a computer with no explanation anywhere the
+ * operator was looking. */
+ blockedReason?: string | null
}
/** Trim a daemon-reported display string, or drop it. Control characters are
@@ -145,12 +155,29 @@ function sanitizeVersionFields(rec: Record<string, unknown>): Partial<DetectedEn
function unreportedEngine(id: string): DetectedEngine {
return {
id, bin: ENGINE_BINS[id] ?? id, path: null,
- version: null, latest: null, outdated: false, updateCommand: null,
+ version: null, latest: null, outdated: false, updateCommand: null, blockedReason: null,
}
}
-export function sanitizeDetectedEngines(raw: unknown, engineIds: string[]): DetectedEngine[] {
- const allowed = engineIds.filter((id) => PAIRABLE_ENGINES.has(id))
+/**
+ * Shape the daemon's PATH report for storage and display.
+ *
+ * `runnableIds` are the engines the daemon will actually wake; `blockedIds` are
+ * installed but refused, and appear ONLY here. That separation is the safety
+ * property of this function: `available_engines` is what picks an agent's
+ * adapter, so a blocked engine reaching it would run the very thing the
+ * sandbox gate declined. Blocked ids are therefore never returned to the
+ * caller as runnable and never influence `ordered` — they ride along as extra
+ * display rows carrying the reason they were refused.
+ */
+export function sanitizeDetectedEngines(
+ raw: unknown,
+ engineIds: string[],
+ blockedIds: string[] = [],
+): DetectedEngine[] {
+ const runnable = engineIds.filter((id) => PAIRABLE_ENGINES.has(id))
+ const blocked = blockedIds.filter((id) => PAIRABLE_ENGINES.has(id) && !runnable.includes(id))
+ const allowed = [...runnable, ...blocked]
if (!Array.isArray(raw)) return allowed.map(unreportedEngine)
const byId = new Map<string, DetectedEngine>()
for (const item of raw) {
@@ -160,7 +187,10 @@ export function sanitizeDetectedEngines(raw: unknown, engineIds: string[]): Dete
if (!PAIRABLE_ENGINES.has(id) || !allowed.includes(id)) continue
const bin = typeof rec.bin === 'string' && rec.bin.trim() ? rec.bin.trim() : (ENGINE_BINS[id] ?? id)
const path = typeof rec.path === 'string' && rec.path.trim() ? rec.path.trim() : null
- byId.set(id, { id, bin, path, ...sanitizeVersionFields(rec) })
+ // A reason is only meaningful on an engine we actually refused. Accepting
+ // one on a runnable engine would let a daemon mark a working engine broken.
+ const blockedReason = blocked.includes(id) ? displayString(rec.blockedReason, 200) : null
+ byId.set(id, { id, bin, path, ...sanitizeVersionFields(rec), blockedReason })
}
// Every row carries the same keys, reported or not, so the app never has to
// distinguish "field absent" from "nothing installed to report".
@@ -686,6 +716,9 @@ export async function reportDetectedEngines(args: {
computerId: string
engines?: string[]
detected?: unknown
+ /** Installed engines the daemon refused to run. Display-only — they are
+ * deliberately kept out of `available_engines`, which chooses adapters. */
+ blocked?: string[]
}): Promise<boolean> {
const { rows } = await pool.query<{ available_engines: string[]; company_id: string }>(
`SELECT available_engines, company_id FROM computers
@@ -699,7 +732,7 @@ export async function reportDetectedEngines(args: {
const ordered = prevDefault && incoming.includes(prevDefault)
? [prevDefault, ...incoming.filter((e) => e !== prevDefault)]
: incoming
- const detected = sanitizeDetectedEngines(args.detected, ordered)
+ const detected = sanitizeDetectedEngines(args.detected, ordered, args.blocked ?? [])
await pool.query(
`UPDATE computers
SET available_engines = $2::jsonb,
diff --git a/server/src/api/router.ts b/server/src/api/router.ts
index 0c78591..f781c18 100644
--- a/server/src/api/router.ts
+++ b/server/src/api/router.ts
@@ -1258,7 +1258,13 @@ api.post('/computers/me/engines', safe(async (req, res) => {
const engines = Array.isArray(req.body?.engines)
? (req.body.engines as unknown[]).filter((e): e is string => typeof e === 'string')
: []
- const ok = await reportDetectedEngines({ computerId, engines, detected: req.body?.detected })
+ // Installed-but-refused engines. Kept apart from `engines` on purpose: that
+ // list becomes available_engines and picks an agent's adapter, so a blocked
+ // id arriving there would run what the sandbox gate declined.
+ const blocked = Array.isArray(req.body?.blocked)
+ ? (req.body.blocked as unknown[]).filter((e): e is string => typeof e === 'string')
+ : []
+ const ok = await reportDetectedEngines({ computerId, engines, detected: req.body?.detected, blocked })
if (!ok) throw new HttpError(404, 'computer not found')
res.json({ ok: true })
}))
diff --git a/src/desktop/MeView.tsx b/src/desktop/MeView.tsx
index ad41089..4e769eb 100644
--- a/src/desktop/MeView.tsx
+++ b/src/desktop/MeView.tsx
@@ -784,6 +784,7 @@ type AgentRow = {
latest?: string | null
outdated?: boolean
updateCommand?: string | null
+ blockedReason?: string | null
}
const CLI_ORDER = [
@@ -1080,10 +1081,25 @@ function ComputersTab() {
{t('me.agentsCliUpdateAvailable')}
</span>
)}
- {!engineId && (
+ {/* Two different things, deliberately not one
+ label: "not runnable" means Cumora has no
+ adapter for this CLI and the operator can
+ do nothing about it, while "blocked" means
+ it is supported but was refused here for a
+ reason they can act on. */}
+ {row.blockedReason ? (
+ <span className="text-[12px] font-semibold px-2 py-0.5 rounded-full shrink-0 bg-coral-soft text-coral-deep">
+ {t('me.agentsCliBlocked')}
+ </span>
+ ) : !engineId && (
<span className="text-[12px] text-ink-400 truncate">{t('me.agentsNotRunnable')}</span>
)}
</div>
+ {row.blockedReason && (
+ <div className="mt-1 text-[12px] leading-[1.55] text-coral-deep">
+ {t('me.agentsCliBlockedReason', { reason: row.blockedReason })}
+ </div>
+ )}
<div className="mt-1 flex items-center min-w-0 font-mono text-[12px] text-ink-400">
<span className="shrink-0">{row.bin}</span>
{row.path && (
diff --git a/src/locales/en.ts b/src/locales/en.ts
index be5e15f..4a62c3e 100644
--- a/src/locales/en.ts
+++ b/src/locales/en.ts
@@ -1294,6 +1294,8 @@ export const en = {
'me.agentsIsDefault': 'Default',
'me.agentsOffline': 'This computer is offline. The list is still the last pairing report.',
'me.agentsNoEngines': 'The daemon reported no engines at pairing. Re-run the pairing command on that computer to scan PATH again.',
+ 'me.agentsCliBlocked': 'Not used',
+ 'me.agentsCliBlockedReason': 'Installed, but Cumora will not run it here: {reason}. Until that is fixed, agents on this computer cannot use it.',
'me.agentsNotRunnable': 'Detected only — Cumora cannot run this yet',
'me.agentsNeedPair': 'Re-pair to use',
'me.agentsCliUnknown': 'version unknown',
diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts
index f4beef0..96fe8d9 100644
--- a/src/locales/zh-CN.ts
+++ b/src/locales/zh-CN.ts
@@ -1296,6 +1296,8 @@ export const zhCN: Partial<Record<keyof typeof en, string>> = {
'me.agentsIsDefault': '默认',
'me.agentsOffline': '这台计算机离线。列表仍是上次配对时的检测结果。',
'me.agentsNoEngines': '配对时 daemon 没有报任何引擎。要重新扫 PATH,请在那台机器上再跑一次配对命令。',
+ 'me.agentsCliBlocked': '未启用',
+ 'me.agentsCliBlockedReason': '已安装,但 Cumora 不会在这台机器上运行它:{reason}。在此修复前,这台计算机上的智能体无法使用它。',
'me.agentsNotRunnable': '仅识别,Cumora 还不能当引擎跑',
'me.agentsNeedPair': '重新配对后使用',
'me.agentsCliUnknown': '版本未知',
diff --git a/src/types.ts b/src/types.ts
index 073b723..9ae4418 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -30,6 +30,10 @@ export interface Computer {
outdated?: boolean
/** How to update this engine on that computer (vendor updater, brew, or npm). */
updateCommand?: string | null
+ /** Set when the engine is installed there but Cumora refuses to drive it —
+ * an old CLI, or a missing sandbox dependency. The daemon knows this and
+ * now says so, instead of the engine merely going absent. */
+ blockedReason?: string | null
}>
enginesDetectedAt?: string | null
lastSeenAt?: string | null