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): pick per-engine models from the engine's own catalog (#346)

Strelizia35241300f27b
diff --git a/server/src/__tests__/agents-computer-engine-version.test.ts b/server/src/__tests__/agents-computer-engine-version.test.ts
index e9cd860..ff54da3 100644
--- a/server/src/__tests__/agents-computer-engine-version.test.ts
+++ b/server/src/__tests__/agents-computer-engine-version.test.ts
@@ -422,7 +422,7 @@ test('sanitizeDetectedEngines bounds and cleans account-specific model catalogs'
const [row] = sanitizeDetectedEngines([{
id: 'codex', bin: 'codex', path: '/usr/local/bin/codex',
modelCatalog: {
- source: 'protocol', supportsCustom: true, fastModelScope: 'agent',
+ source: 'protocol', supportsCustom: true, fastModelScope: 'agent', trustedModels: true,
defaultModel: 'gpt-5.6-sol', defaultFastModel: 'gpt-5.4-mini',
models: [
{ id: 'gpt-5.6-sol', label: 'GPT-5.6-Sol\nspoof', recommendedFor: ['big', 'bogus'] },
@@ -432,10 +432,26 @@ test('sanitizeDetectedEngines bounds and cleans account-specific model catalogs'
},
}], ['codex'])
assert.deepEqual(row?.modelCatalog, {
- source: 'protocol', supportsCustom: true, fastModelScope: 'agent',
+ source: 'protocol', supportsCustom: true, fastModelScope: 'agent', trustedModels: true,
defaultModel: 'gpt-5.6-sol', defaultFastModel: 'gpt-5.4-mini',
models: [{
id: 'gpt-5.6-sol', label: 'GPT-5.6-Sol spoof', description: null, recommendedFor: ['big'],
}],
})
})
+
+test('a catalog that does not vouch for its models keeps no flag, so the app withholds rows', () => {
+ // Daemons that predate `trustedModels` merged their presets into the reported
+ // listing. Passing an absent flag through as `true` (or defaulting it) would
+ // hand the app exactly the unvouched-for list it must not offer.
+ const [row] = sanitizeDetectedEngines([{
+ id: 'codex', bin: 'codex', path: '/usr/local/bin/codex',
+ modelCatalog: {
+ source: 'protocol', supportsCustom: true, fastModelScope: 'agent',
+ defaultModel: null, defaultFastModel: null,
+ models: [{ id: 'gateway/only-model', label: 'Only Model' }],
+ },
+ }], ['codex'])
+ assert.equal(row?.modelCatalog?.trustedModels, undefined)
+ assert.equal('trustedModels' in (row?.modelCatalog ?? {}), false)
+})
diff --git a/server/src/__tests__/agents-computer-model-catalog.test.ts b/server/src/__tests__/agents-computer-model-catalog.test.ts
index 220d4a9..1258bc1 100644
--- a/server/src/__tests__/agents-computer-model-catalog.test.ts
+++ b/server/src/__tests__/agents-computer-model-catalog.test.ts
@@ -105,6 +105,7 @@ test('Claude custom-provider settings expose only core bootstrap values and mode
assert.equal(catalog.defaultFastModel, 'provider/haiku-small')
assert.equal(catalog.prefersLocalDefault, true)
assert.equal(catalog.source, 'cli')
+ assert.equal(catalog.trustedModels, true)
assert.deepEqual(catalog.models.map((model) => model.id), [
'provider/opus-large',
'provider/haiku-small',
@@ -197,6 +198,58 @@ async function stubEngineCli(name: string, stdout: string): Promise<{ bin: strin
return { bin, cleanup: () => rm(root, { recursive: true, force: true }) }
}
+/** A codex stand-in that answers `model/list` with exactly `rows`. Cross-platform,
+ * because the shell-script stub above only actually runs on POSIX. */
+async function stubCodexListing(rows: Array<Record<string, unknown>>): Promise<{ bin: string; cleanup: () => Promise<void> }> {
+ const root = await mkdtemp(join(tmpdir(), 'cumora-codex-listing-'))
+ const script = join(root, 'catalog.cjs')
+ const bin = join(root, process.platform === 'win32' ? 'codex.cmd' : 'codex')
+ await writeFile(script, `
+require('node:readline').createInterface({ input: process.stdin }).on('line', line => {
+ const msg = JSON.parse(line)
+ if (msg.id) process.stdout.write(JSON.stringify({ id: msg.id, result: msg.method === 'model/list' ? { data: ${JSON.stringify(rows)} } : {} }) + '\\n')
+})
+`)
+ await writeFile(bin, process.platform === 'win32'
+ ? `@echo off\r\n"${process.execPath}" "%~dp0catalog.cjs" %*\r\n`
+ : `#!/bin/sh\nexec node "${script}" "$@"\n`, { mode: 0o755 })
+ return { bin, cleanup: () => rm(root, { recursive: true, force: true }) }
+}
+
+test('a provider that lists one model offers only that model, not the preset tail', async () => {
+ // The review case: a gateway account returns a single model. The preset used
+ // to be appended behind the real listing, so the picker offered six
+ // antigravity ids the account cannot run — each marked "Recommended", each
+ // selectable as a computer default that every inheriting Agent would fail on.
+ const { bin, cleanup } = await stubCodexListing([{ model: 'gateway/only-model', displayName: 'Only Model', isDefault: true }])
+ try {
+ clearModelCatalogCache()
+ const catalog = await discoverEngineModelCatalog('codex', bin, true)
+ assert.equal(catalog.source, 'protocol')
+ assert.equal(catalog.trustedModels, true, 'a listing this build produced is vouched for')
+ assert.deepEqual(catalog.models.map((model) => model.id), ['gateway/only-model'])
+ // The preset's fast default is `gpt-5.4-mini`, which this account never
+ // listed, so the hint must not promise it either.
+ assert.equal(catalog.defaultFastModel, null)
+ } finally {
+ clearModelCatalogCache()
+ await cleanup()
+ }
+})
+
+test('a listing keeps the preset fast default only when the account listed it', async () => {
+ const { bin, cleanup } = await stubCodexListing([{ model: 'gpt-5.4-mini' }, { model: 'gpt-5.6-sol', isDefault: true }])
+ try {
+ clearModelCatalogCache()
+ const catalog = await discoverEngineModelCatalog('codex', bin, true)
+ assert.deepEqual(catalog.models.map((model) => model.id), ['gpt-5.4-mini', 'gpt-5.6-sol'])
+ assert.equal(catalog.defaultFastModel, 'gpt-5.4-mini')
+ } finally {
+ clearModelCatalogCache()
+ await cleanup()
+ }
+})
+
test('a CLI that listed nothing offers nothing, not a model named after its excuse', async () => {
// End to end through the real dispatch. Cursor has no preset — cumora takes
// its whole catalog from the CLI — so before the fix the picker's only entry
@@ -224,6 +277,8 @@ test('an engine with a preset keeps it when its CLI fails to list', async () =>
assert.equal(catalog.source, 'presets')
assert.equal(catalog.models[0]?.id, 'gemini-3.8-flash-high')
assert.equal(catalog.models.some((model) => /^Error/.test(model.id)), false)
+ // A fallback is not a listing: without this flag the app withholds the rows.
+ assert.equal(catalog.trustedModels, undefined)
} finally {
clearModelCatalogCache()
await cleanup()
diff --git a/server/src/agents/computer/model-catalog.ts b/server/src/agents/computer/model-catalog.ts
index f57704a..10d2062 100644
--- a/server/src/agents/computer/model-catalog.ts
+++ b/server/src/agents/computer/model-catalog.ts
@@ -28,6 +28,12 @@ export interface EngineModelCatalog {
supportsCustom: boolean
fastModelScope: FastModelScope
source: ModelCatalogSource
+ /** Every id in `models` is runnable by this computer's account: the provider
+ * listed it, or the engine's own aliases are first-party by definition.
+ * Absent means "this build cannot promise that" — builds before this flag
+ * merged their presets into the reported list, and the app must not present
+ * such a catalog as the provider's. */
+ trustedModels?: boolean
}
const PRESETS: Record<EngineId, EngineModelCatalog> = {
@@ -186,13 +192,25 @@ function mergeModels(discovered: EngineModelOption[], fallback: EngineModelOptio
return out
}
-function withPreset(id: EngineId, discovered: EngineModelOption[], source: 'protocol' | 'cli', defaultModel: string | null): EngineModelCatalog {
+/** A CLI that listed models answered the question the preset was guessing at, so
+ * the preset's models must not ride along. They used to be appended behind the
+ * real listing, which meant a provider that returned one model still produced a
+ * picker offering a dozen — each wearing the preset's "Recommended" marker, each
+ * one an Agent could inherit and then fail on, because the account cannot run
+ * it. The preset still supplies what it alone knows: fast-model scope and
+ * whether custom entry is allowed. */
+function fromDiscovered(id: EngineId, discovered: EngineModelOption[], source: 'protocol' | 'cli', defaultModel: string | null): EngineModelCatalog {
const preset = clonePreset(id)
return {
...preset,
- models: mergeModels(discovered, preset.models),
+ models: mergeModels(discovered, []),
defaultModel: clean(defaultModel, 160),
+ // The fast default is a hint about what an unpinned Agent will run, so a
+ // preset id the account did not list is the same lie as an unlisted model.
+ defaultFastModel: discovered.some((model) => model.id === preset.defaultFastModel) ? preset.defaultFastModel : null,
source,
+ // The provider answered, so every id above is one this account can reach.
+ trustedModels: true,
}
}
@@ -407,8 +425,10 @@ function discoverCodex(command: string, env: NodeJS.ProcessEnv): Promise<{ model
}
/** Discover the account/config-specific catalog without making a model call.
- * Failure is deliberately soft: a compact preset catalog plus custom entry is
- * still more useful than hiding the selector or blocking an engine rescan. */
+ * Failure is deliberately soft: the preset still names the engine's own
+ * defaults and the app keeps custom entry open, which beats blocking an engine
+ * rescan. The preset is not a listing though, so it never carries
+ * `trustedModels` and the app shows no rows for it. */
export async function discoverEngineModelCatalog(
id: EngineId,
binPath: string | null,
@@ -442,23 +462,26 @@ export async function discoverEngineModelCatalog(
defaultFastModel: defaultFastModel ?? (prefersLocalDefault ? null : preset.defaultFastModel),
prefersLocalDefault,
source: 'cli',
+ // First-party aliases are runnable by any Anthropic account; on a custom
+ // endpoint they were not merged at all.
+ trustedModels: true,
}
}
} else if (id === 'codex') {
const result = await discoverCodex(binPath, env)
- if (result?.models.length) catalog = withPreset(id, result.models, 'protocol', result.defaultModel)
+ if (result?.models.length) catalog = fromDiscovered(id, result.models, 'protocol', result.defaultModel)
} else if (id === 'cursor') {
const models = parseListedModels(await runText(binPath, ['models']), 'cursor')
- if (models.length) catalog = withPreset(id, models, 'cli', null)
+ if (models.length) catalog = fromDiscovered(id, models, 'cli', null)
} else if (id === 'opencode') {
const models = parseListedModels(await runText(binPath, ['models']), 'provider')
- if (models.length) catalog = withPreset(id, models, 'cli', null)
+ if (models.length) catalog = fromDiscovered(id, models, 'cli', null)
} else if (id === 'pi') {
const models = parseListedModels(await runText(binPath, ['--list-models']), 'pi')
- if (models.length) catalog = withPreset(id, models, 'cli', null)
+ if (models.length) catalog = fromDiscovered(id, models, 'cli', null)
} else if (id === 'antigravity') {
const models = parseListedModels(await runText(binPath, ['models']), 'antigravity')
- if (models.length) catalog = withPreset(id, models, 'cli', null)
+ if (models.length) catalog = fromDiscovered(id, models, 'cli', null)
}
if (catalog) catalogCache.set(cacheKey, { at: Date.now(), catalog })
diff --git a/server/src/agents/computer/registry.ts b/server/src/agents/computer/registry.ts
index c236410..5f0a30d 100644
--- a/server/src/agents/computer/registry.ts
+++ b/server/src/agents/computer/registry.ts
@@ -214,6 +214,9 @@ function sanitizeModelCatalog(raw: unknown): EngineModelCatalog | undefined {
supportsCustom: rec.supportsCustom !== false,
fastModelScope,
source,
+ // Passed through, never defaulted: only a daemon that knows its list is
+ // preset-free may say so, and the app withholds model rows without it.
+ ...(rec.trustedModels === true ? { trustedModels: true } : {}),
}
}
diff --git a/src/components/AgentEditor.tsx b/src/components/AgentEditor.tsx
index 3ff0898..51568e3 100644
--- a/src/components/AgentEditor.tsx
+++ b/src/components/AgentEditor.tsx
@@ -10,9 +10,10 @@ import { TextArea } from '@/components/TextArea'
import { Select } from '@/components/Select'
import { Combobox, type ComboboxOption } from '@/components/Combobox'
import { Checkbox } from '@/components/Checkbox'
-import { supportsNativeFastMode } from '../../shared/native-fast-mode'
import type { Participant, EngineId } from '@/types'
import { useT } from '@/lib/i18n'
+import { catalogTrust } from '@/lib/engine-model-choices'
+import { fastModeAvailable } from '@/lib/agent-fast-mode'
import { engineLabel } from '@/lib/engines'
const INHERIT_ENGINE = '__inherit__'
@@ -114,17 +115,37 @@ export function AgentEditor({ agent, onClose, onSaved }: Props) {
const engineDefaults = providerProfile ? undefined : selectedComputer?.engineDefaults?.[selectedEngineId]
const engineDefaultModel = engineDefaults?.model ?? undefined
const engineDefaultFastModel = engineDefaults?.fastModel ?? undefined
- const effectiveModel = model.trim() || engineDefaultModel || modelCatalog?.defaultModel
+ // A `presets` catalog is the daemon's fallback, not a listing, and an
+ // `unverified` one came from a daemon that merged its presets into a real
+ // listing. Neither can name a model this account is known to run, so neither
+ // offers rows; the field says which happened instead.
+ const modelCatalogTrust = isByoa ? catalogTrust(modelCatalog) : 'missing'
const showNativeFastMode = isByoa && (selectedEngineId === 'codex' || selectedEngineId === 'claude')
- const nativeFastModeSupported = supportsNativeFastMode(selectedEngineId, effectiveModel)
- && modelCatalog?.models.find((option) => option.id === effectiveModel)?.supportsFastMode !== false
+ // Fast Mode is not a suggestion, so it reads the whole catalog rather than
+ // the vouched-for rows above: dropping a known default or a
+ // `supportsFastMode: false` would flip an existing Agent's setting on its next
+ // save, which writes whatever this computes. See the module for both cases.
+ const nativeFastModeSupported = fastModeAvailable({
+ engine: selectedEngineId,
+ model,
+ engineDefault: engineDefaultModel,
+ catalog: modelCatalog,
+ })
+ // A configured computer default is authoritative, so it needs no label. The
+ // catalog's default is only this computer's CLI setting — a deployment pin can
+ // still win — so that one names its source instead of promising the model, and
+ // it is quoted only when the catalog itself can be vouched for.
+ const reportedDefault = (reported: string | null | undefined) =>
+ modelCatalogTrust === 'reported' && reported ? t('agent.modelLocalDefault', { model: reported }) : undefined
+ // The Cumora-side pin is applied by the server, so it is quoted even when the
+ // catalog is not: it is the value that actually runs.
const modelOptions: Array<ComboboxOption<string>> = [
{
value: '',
label: t('agent.followEngineDefault'),
- hint: engineDefaultModel ?? modelCatalog?.defaultModel ?? undefined,
+ hint: engineDefaultModel ?? reportedDefault(modelCatalog?.defaultModel),
},
- ...(modelCatalog?.models ?? []).map((option) => ({
+ ...(modelCatalogTrust === 'reported' ? modelCatalog?.models ?? [] : []).map((option) => ({
value: option.id,
label: option.label,
hint: [
@@ -137,9 +158,9 @@ export function AgentEditor({ agent, onClose, onSaved }: Props) {
{
value: '',
label: t('agent.followSmallBrainDefault'),
- hint: engineDefaultFastModel ?? modelCatalog?.defaultFastModel ?? undefined,
+ hint: engineDefaultFastModel ?? reportedDefault(modelCatalog?.defaultFastModel),
},
- ...(modelCatalog?.models ?? []).map((option) => ({
+ ...(modelCatalogTrust === 'reported' ? modelCatalog?.models ?? [] : []).map((option) => ({
value: option.id,
label: option.label,
hint: [
@@ -148,6 +169,10 @@ export function AgentEditor({ agent, onClose, onSaved }: Props) {
].filter(Boolean).join(' · ') || undefined,
})),
]
+ const catalogNotice = !isByoa ? ''
+ : modelCatalogTrust === 'guessed' ? t('agent.modelCatalogGuessed')
+ : modelCatalogTrust === 'unverified' ? t('agent.modelCatalogUnverified')
+ : ''
const origin = getPairingServerOrigin()
const repairCommand = repairCode
? `npx cumora@latest agent computer --pair ${repairCode}${origin ? ` --server ${origin}` : ''}`
@@ -405,7 +430,9 @@ export function AgentEditor({ agent, onClose, onSaved }: Props) {
<Field
label={isByoa ? t('agent.modelLabelByoa') : t('agent.modelLabel')}
- hint={isByoa ? t('agent.modelHintByoaCatalog') : t('agent.modelHintCloud')}
+ hint={isByoa
+ ? [t('agent.modelHintByoaCatalog'), catalogNotice].filter(Boolean).join(' ')
+ : t('agent.modelHintCloud')}
>
{isByoa ? (
<Combobox
@@ -444,7 +471,7 @@ export function AgentEditor({ agent, onClose, onSaved }: Props) {
{isByoa && (!modelCatalog || modelCatalog.fastModelScope === 'agent') && (
<Field
label={t('agent.fastLabelByoa')}
- hint={t('agent.fastHintByoaCatalog')}
+ hint={[t('agent.fastHintByoaCatalog'), catalogNotice].filter(Boolean).join(' ')}
>
<Combobox
ariaLabel={t('agent.fastLabelByoa')}
diff --git a/src/desktop/MeView.tsx b/src/desktop/MeView.tsx
index 0f00691..0856c59 100644
--- a/src/desktop/MeView.tsx
+++ b/src/desktop/MeView.tsx
@@ -9,13 +9,15 @@ import { usePairingCodes } from '@/stores/pairing-codes'
import { copyText } from '@/lib/clipboard'
import { Avatar } from '@/components/Avatar'
import { Checkbox } from '@/components/Checkbox'
+import { Combobox } from '@/components/Combobox'
import { AppearancePicker, ChatLayoutPicker } from '@/components/AppearancePicker'
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_ENGINES, RUNNABLE_ENGINE_IDS, engineLabel, type RunnableEngineId } from '@/lib/engines'
-import type { Computer, EngineId } from '@/types'
+import type { Computer, EngineId, EngineModelCatalog } from '@/types'
+import { engineModelChoices, catalogTrust } from '@/lib/engine-model-choices'
import { ENGINE_UPDATE_TTL_SECONDS } from '../../shared/engine-update'
// The tab's identity is its `key`; the label is a message key resolved at
@@ -788,6 +790,9 @@ type AgentRow = {
outdated?: boolean
updateCommand?: string | null
blockedReason?: string | null
+ /** Models this computer's own CLI login can reach. Absent on daemons that
+ * predate catalog reporting, which is why the picker keeps custom entry. */
+ modelCatalog?: EngineModelCatalog
}
const CLI_ORDER = [
@@ -1266,34 +1271,60 @@ function ComputersTab() {
<div className="mt-3 pt-3" style={{ borderTop: '1px dashed var(--ink-100)' }}>
{editingModel?.computerId === c.id && editingModel?.engineId === row.id ? (
<div className="space-y-2">
- <div className="text-[11px] font-semibold text-ink-600 uppercase tracking-wider">
+ {/* No `uppercase`: the engine name is a
+ brand ("Claude Code"), not a label. */}
+ <div className="text-[11px] font-semibold text-ink-600 tracking-wider">
{t('me.engineModelConfig', { engine: engineLabel(row.id) })}
</div>
- <div>
- <label className="block text-[11px] text-ink-500 mb-1">{t('me.engineDefaultModel')}</label>
- <input
- type="text"
- value={modelInput}
- disabled={savingModel}
- onChange={(e) => setModelInput(e.target.value)}
- placeholder={t('me.engineModelPlaceholder')}
- className="w-full px-2 py-1.5 text-[12px] rounded-[8px] font-mono"
- style={{ border: '1px solid var(--ink-100)', background: 'var(--paper)' }}
- />
- </div>
- <div>
- <label className="block text-[11px] text-ink-500 mb-1">{t('me.engineFastModel')}</label>
- <input
- type="text"
- value={fastModelInput}
- disabled={savingModel}
- onChange={(e) => setFastModelInput(e.target.value)}
- placeholder={t('me.engineFastModelPlaceholder')}
- className="w-full px-2 py-1.5 text-[12px] rounded-[8px] font-mono"
- style={{ border: '1px solid var(--ink-100)', background: 'var(--paper)' }}
- />
- </div>
+ {/* <fieldset disabled> carries the in-flight
+ disable the plain inputs had: <Combobox>
+ exposes no `disabled` prop. */}
+ <fieldset disabled={savingModel} className="m-0 min-w-0 space-y-2 border-0 p-0">
+ <div>
+ <label className="block text-[11px] text-ink-500 mb-1">{t('me.engineDefaultModel')}</label>
+ <Combobox
+ ariaLabel={t('me.engineDefaultModel')}
+ value={modelInput}
+ onValueChange={setModelInput}
+ options={engineModelChoices(row.modelCatalog, 'big', {
+ follow: t('me.engineModelNotSet'),
+ recommended: t('agent.recommended'),
+ localDefault: (model) => t('agent.modelLocalDefault', { model }),
+ })}
+ searchPlaceholder={t('agent.searchModels')}
+ allowCustom={row.modelCatalog?.supportsCustom !== false}
+ customLabel={(value) => t('agent.useCustomModel', { model: value })}
+ />
+ </div>
+ {/* Engines that never run a separate fast model
+ hide the field rather than accept a value the
+ server would silently ignore. */}
+ {row.modelCatalog?.fastModelScope !== 'unsupported' && (
+ <div>
+ <label className="block text-[11px] text-ink-500 mb-1">{t('me.engineFastModel')}</label>
+ <Combobox
+ ariaLabel={t('me.engineFastModel')}
+ value={fastModelInput}
+ onValueChange={setFastModelInput}
+ options={engineModelChoices(row.modelCatalog, 'small', {
+ follow: t('me.engineModelNotSet'),
+ recommended: t('agent.recommended'),
+ localDefault: (model) => t('agent.modelLocalDefault', { model }),
+ })}
+ searchPlaceholder={t('agent.searchModels')}
+ allowCustom={row.modelCatalog?.supportsCustom !== false}
+ customLabel={(value) => t('agent.useCustomModel', { model: value })}
+ />
+ </div>
+ )}
+ </fieldset>
<p className="text-[11px] text-ink-500">{t('me.engineModelHelp')}</p>
+ {catalogTrust(row.modelCatalog) === 'guessed' && (
+ <p className="text-[11px] text-ink-500">{t('agent.modelCatalogGuessed')}</p>
+ )}
+ {catalogTrust(row.modelCatalog) === 'unverified' && (
+ <p className="text-[11px] text-ink-500">{t('agent.modelCatalogUnverified')}</p>
+ )}
<div className="flex gap-2">
<button
type="button"
diff --git a/src/lib/agent-fast-mode.ts b/src/lib/agent-fast-mode.ts
new file mode 100644
index 0000000..788c280
--- /dev/null
+++ b/src/lib/agent-fast-mode.ts
@@ -0,0 +1,53 @@
+/**
+ * Whether the Agent editor may offer Fast Mode for the model this Agent will
+ * actually run.
+ *
+ * Split out of the component because the answer has two inputs that look alike
+ * and are not: the model id (which the picker must resolve even when it offers
+ * no rows) and the catalog's per-model `supportsFastMode` flags.
+ *
+ * The picker withholds rows from a catalog it cannot vouch for, but that is a
+ * question about *offerability* — a model the account may not run must not be
+ * suggested. Fast Mode is a question about a model already in play, and here
+ * the two directions are not equally safe:
+ *
+ * - Ignoring a `supportsFastMode: false` because the catalog is old lets the
+ * editor enable Fast Mode on a model that refuses it, and the save persists
+ * that. Codex answers `true` for every model from the name alone, so nothing
+ * else catches it.
+ * - Ignoring a `defaultModel` because the catalog is old silently resolves to
+ * "no model", which reads as "Fast Mode unsupported" — so an Agent that has
+ * Fast Mode on gets it switched off by the next unrelated edit, because the
+ * save writes the checkbox's computed value.
+ *
+ * So the flags and the default are honored from any catalog the daemon
+ * reported. A preset tail contributes neither: presets carry no
+ * `supportsFastMode` and no `defaultModel`.
+ */
+import { supportsNativeFastMode } from '../../shared/native-fast-mode'
+
+export interface FastModeCatalog {
+ models: ReadonlyArray<{ id: string; supportsFastMode?: boolean }>
+ defaultModel?: string | null
+}
+
+export interface FastModeInput {
+ engine: string
+ /** The Agent's own pin. Blank means it follows the computer default. */
+ model?: string | null
+ /** The computer-level default configured on the Me page, if any. */
+ engineDefault?: string | null
+ /** What this computer's daemon reported, vouched for or not. */
+ catalog?: FastModeCatalog
+}
+
+/** The model an unpinned Agent resolves to, as far as the app can know it. */
+export function resolvedAgentModel({ model, engineDefault, catalog }: FastModeInput): string | undefined {
+ return model?.trim() || engineDefault || catalog?.defaultModel || undefined
+}
+
+export function fastModeAvailable(input: FastModeInput): boolean {
+ const resolved = resolvedAgentModel(input)
+ return supportsNativeFastMode(input.engine, resolved)
+ && input.catalog?.models.find((option) => option.id === resolved)?.supportsFastMode !== false
+}
diff --git a/src/lib/engine-model-choices.ts b/src/lib/engine-model-choices.ts
new file mode 100644
index 0000000..34a0a79
--- /dev/null
+++ b/src/lib/engine-model-choices.ts
@@ -0,0 +1,115 @@
+/**
+ * Option list for the per-computer engine model pickers (Me page and AgentEditor).
+ *
+ * The catalog comes from the daemon on that computer (the only process that
+ * knows which models its CLI login can actually reach), so the picker shows
+ * real choices instead of asking the operator to type a vendor model id from
+ * memory. A daemon that cannot enumerate (older build, custom endpoint) still
+ * reports `supportsCustom`, and the picker keeps free-form entry for it.
+ *
+ * Only a catalog the daemon vouches for produces model rows. Two states do not:
+ *
+ * - `presets`: the engine never listed anything, so the ids are Cumora's
+ * compiled-in guesses about the account (gemini, qwen, zcode and maka are
+ * never probed at all). Offering them means offering models the account may
+ * not run, each inheritable by every Agent — so they are not offered at all.
+ * - `unverified`: a daemon that predates `trustedModels` reported a catalog
+ * after merging its presets into the provider's answer, while still labelling
+ * it `protocol`/`cli`. The tail is unvouched-for and indistinguishable from a
+ * real listing, so it is not offered either.
+ *
+ * Both fall back to "follow the default" plus custom entry, and the picker says
+ * which of the two happened.
+ *
+ * Pure and React-free so the row rules can be pinned without rendering.
+ */
+
+/** Structural twin of the <Combobox> option, minus the component import. */
+export interface ModelChoiceOption {
+ value: string
+ label: string
+ hint?: string
+}
+
+export interface ModelChoiceCatalog {
+ models: ReadonlyArray<{
+ id: string
+ label: string
+ recommendedFor?: ReadonlyArray<'big' | 'small'>
+ }>
+ /** Absent or null both mean "the engine names no default". */
+ defaultModel?: string | null
+ defaultFastModel?: string | null
+ /** How the daemon got this list. Absent on catalogs the app synthesises
+ * itself (a provider profile), which is why `catalogTrust` treats absent as
+ * reported rather than as a failure. */
+ source?: 'protocol' | 'cli' | 'presets'
+ /** Set by a daemon that promises every id above is runnable by this account.
+ * Absent on daemons old enough to have merged their presets into a reported
+ * listing, which is the case `catalogTrust` calls `unverified`. */
+ trustedModels?: boolean
+}
+
+export type CatalogTrust = 'reported' | 'guessed' | 'unverified' | 'missing'
+
+/**
+ * How much the option list can be trusted, so the picker can say so.
+ *
+ * `presets` means the engine never actually listed anything — the daemon fell
+ * back to ids compiled into Cumora. Those are guesses about the account, not
+ * facts about it.
+ *
+ * `unverified` means the daemon claims a listing but does not vouch for it, so
+ * it is one of the builds that appended its presets behind the provider's
+ * answer. Both states offer no model rows: a model the account cannot run is a
+ * runtime failure every Agent inherits, which is worse than an empty list.
+ */
+export function catalogTrust(catalog: ModelChoiceCatalog | undefined): CatalogTrust {
+ if (!catalog) return 'missing'
+ // No source at all: a profile catalog synthesised in the app, not a report.
+ if (!catalog.source) return 'reported'
+ // Vouched for beats how it was obtained — Claude's `opus`/`sonnet`/`haiku`
+ // are aliases the CLI resolves, so the preset names models that exist even
+ // when nothing was listed.
+ if (catalog.trustedModels === true) return 'reported'
+ return catalog.source === 'presets' ? 'guessed' : 'unverified'
+}
+
+/**
+ * First row is the empty value — "no Cumora-side default" — hinted with the
+ * model the engine would fall back to, so the operator can see what blank
+ * actually means before choosing it.
+ *
+ * The hint is labelled as the *local* default on purpose: the catalog only
+ * knows this computer's CLI settings, while the server may still apply a
+ * deployment-level pin (`CUMORA_DEFAULT_*_MODEL`) that the app never sees.
+ * Naming the model without naming where it came from would read as a promise
+ * about which model actually runs.
+ *
+ * Nothing is quoted from a catalog we cannot vouch for — not the rows, and not
+ * the default either: on an `unverified` catalog the fast default came from the
+ * merged preset tail, so it names a model the account may not run.
+ */
+export function engineModelChoices(
+ catalog: ModelChoiceCatalog | undefined,
+ tier: 'big' | 'small',
+ labels: {
+ follow: string
+ recommended: string
+ localDefault: (model: string) => string
+ },
+): ModelChoiceOption[] {
+ if (catalogTrust(catalog) !== 'reported') return [{ value: '', label: labels.follow }]
+ const fallback = tier === 'big' ? catalog?.defaultModel : catalog?.defaultFastModel
+ return [
+ { value: '', label: labels.follow, hint: fallback ? labels.localDefault(fallback) : undefined },
+ ...(catalog?.models ?? []).map((model) => ({
+ value: model.id,
+ label: model.label,
+ hint: [
+ model.label !== model.id ? model.id : null,
+ model.recommendedFor?.includes(tier) ? labels.recommended : null,
+ ].filter(Boolean).join(' · ') || undefined,
+ })),
+ ]
+}
diff --git a/src/locales/en.ts b/src/locales/en.ts
index d62f841..7cf01a4 100644
--- a/src/locales/en.ts
+++ b/src/locales/en.ts
@@ -473,9 +473,14 @@ export const en = {
'agent.providerMissing': 'Unavailable: {id}',
'agent.modelLabelByoa': 'Big-brain model (大脑)',
'agent.modelHintByoaCatalog': 'Choose a model available to this computer\'s engine, or search and enter a custom model id.',
+ 'agent.modelCatalogGuessed': 'This engine reported no model list, so there is nothing to pick from. Cumora only has built-in guesses for it, and those may not be available to this account — type the model id instead.',
+ 'agent.modelCatalogUnverified': 'This computer\'s daemon is too old to say which models its engine can actually run, so the list is hidden. Type the model id, or update the daemon on that computer and refresh.',
'agent.fastHintByoaCatalog': 'Per-agent model for lightweight decisions such as inbox triage. Blank uses the engine\'s small-brain default.',
'agent.followEngineDefault': 'Follow engine default',
'agent.followSmallBrainDefault': 'Follow small-brain default',
+ // The catalog only reports this computer's CLI settings; a deployment pin
+ // may still win, so the hint names its source instead of promising the model.
+ 'agent.modelLocalDefault': 'Local default: {model}',
'agent.searchModels': 'Search models or enter a model id…',
'agent.useCustomModel': 'Use custom model: {model}',
'agent.recommended': 'Recommended',
@@ -1371,11 +1376,9 @@ export const en = {
'me.engineModelConfig': 'Default models for {engine}',
'me.engineModelNotSet': 'Follow engine default',
'me.engineModelConfigure': 'Configure models',
- 'me.engineDefaultModel': 'Main model (leave blank to use default settings)',
- 'me.engineFastModel': 'Fast model (leave blank to use default settings)',
- 'me.engineModelHelp': 'Models selected for an individual agent take priority. Blank fields use the local engine configuration or server defaults.',
- 'me.engineModelPlaceholder': 'e.g. claude-sonnet-4-20250514',
- 'me.engineFastModelPlaceholder': 'e.g. claude-haiku-4-20250514',
+ 'me.engineDefaultModel': 'Main model',
+ 'me.engineFastModel': 'Fast model',
+ 'me.engineModelHelp': 'Models selected for an individual agent take priority. "Follow engine default" uses the local engine configuration or server defaults.',
// ─── updater dialog + banner ──────────────────────────────────────
'updater.bannerUpdateReady': 'Update ready',
diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts
index b94f942..39f392a 100644
--- a/src/locales/zh-CN.ts
+++ b/src/locales/zh-CN.ts
@@ -475,9 +475,12 @@ export const zhCN: Partial<Record<keyof typeof en, string>> = {
'agent.providerMissing': '不可用:{id}',
'agent.modelLabelByoa': '主力模型(大脑)',
'agent.modelHintByoaCatalog': '从这台计算机上的引擎实际可用模型中选择;也可以搜索并输入自定义模型 ID。',
+ 'agent.modelCatalogGuessed': '该引擎没有报告模型列表,因此这里没有可选项。Cumora 只有内置猜测值,未必对你的账号可用——请直接输入模型 ID。',
+ 'agent.modelCatalogUnverified': '这台计算机的守护进程版本过旧,无法确认引擎实际可用的模型,因此列表已隐藏。请直接输入模型 ID,或在该计算机上升级守护进程后刷新。',
'agent.fastHintByoaCatalog': '用于收件箱分流等轻量判断的成员级模型。留空时使用该引擎的小脑默认值。',
'agent.followEngineDefault': '跟随引擎默认',
'agent.followSmallBrainDefault': '跟随小脑默认',
+ 'agent.modelLocalDefault': '本地默认:{model}',
'agent.searchModels': '搜索模型或输入模型 ID…',
'agent.useCustomModel': '使用自定义模型:{model}',
'agent.recommended': '推荐',
@@ -1373,11 +1376,9 @@ export const zhCN: Partial<Record<keyof typeof en, string>> = {
'me.engineModelConfig': '{engine} 的默认模型',
'me.engineModelNotSet': '跟随引擎默认',
'me.engineModelConfigure': '配置模型',
- 'me.engineDefaultModel': '主模型(留空使用默认设置)',
- 'me.engineFastModel': '快速模型(留空使用默认设置)',
- 'me.engineModelHelp': 'Agent 单独指定的模型优先;留空时,由本地引擎配置或服务端默认设置决定。',
- 'me.engineModelPlaceholder': '例如 claude-sonnet-4-20250514',
- 'me.engineFastModelPlaceholder': '例如 claude-haiku-4-20250514',
+ 'me.engineDefaultModel': '主模型',
+ 'me.engineFastModel': '快速模型',
+ 'me.engineModelHelp': 'Agent 单独指定的模型优先;选择“跟随引擎默认”时,由本地引擎配置或服务端默认设置决定。',
// ─── 自动更新对话框 + 横幅 ────────────────────────────────────────
'updater.bannerUpdateReady': '更新就绪',
diff --git a/src/types.ts b/src/types.ts
index f5e3808..060c984 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -25,6 +25,10 @@ export interface EngineModelCatalog {
supportsCustom: boolean
fastModelScope: 'agent' | 'computer' | 'unsupported'
source: 'protocol' | 'cli' | 'presets'
+ /** Set by a daemon that promises every id in `models` is runnable by this
+ * account. Absent on older daemons, whose catalogs merged built-in presets
+ * into the reported list — the picker withholds those rows. */
+ trustedModels?: boolean
}
export interface DetectedEngine {
diff --git a/tests/agent-fast-mode.test.ts b/tests/agent-fast-mode.test.ts
new file mode 100644
index 0000000..30c92d0
--- /dev/null
+++ b/tests/agent-fast-mode.test.ts
@@ -0,0 +1,66 @@
+import { test } from 'node:test'
+import assert from 'node:assert/strict'
+import { fastModeAvailable, resolvedAgentModel } from '../src/lib/agent-fast-mode.ts'
+import { catalogTrust, engineModelChoices } from '../src/lib/engine-model-choices.ts'
+
+// An old daemon: it reported a real listing but merged its presets behind it and
+// does not vouch for the result, so the picker offers no rows. Fast Mode still
+// has to read it — see the module doc.
+const oldDaemon = {
+ models: [{ id: 'opus', label: 'Opus' }, { id: 'sonnet', label: 'Sonnet' }],
+ defaultModel: 'opus',
+ defaultFastModel: null,
+ source: 'cli' as const,
+}
+
+test('an old daemon still names the model an unpinned Agent runs', () => {
+ // Repro from review: Claude with Fast Mode on, Agent following the computer
+ // default, catalog from a daemon that predates `trustedModels`. Dropping the
+ // default resolved to "no model", the editor judged Fast Mode unsupported,
+ // and the next unrelated save — even just renaming — wrote
+ // `nativeFastMode: false`.
+ assert.equal(catalogTrust(oldDaemon), 'unverified')
+ assert.equal(resolvedAgentModel({ model: '', catalog: oldDaemon }), 'opus')
+ assert.equal(fastModeAvailable({ engine: 'claude', model: '', catalog: oldDaemon }), true)
+})
+
+test('an old daemon still reports a model that refuses Fast Mode', () => {
+ // Repro from review: Codex pins a model its catalog marks
+ // `supportsFastMode: false`. The name alone says yes for every codex model, so
+ // dropping the flag let the editor offer a switch the model cannot honor.
+ const codex = {
+ models: [
+ { id: 'gpt-5.6-sol', label: 'GPT-5.6 Sol' },
+ { id: 'gpt-5.4-mini', label: 'GPT-5.4 Mini', supportsFastMode: false },
+ ],
+ defaultModel: 'gpt-5.6-sol',
+ defaultFastModel: null,
+ source: 'protocol' as const,
+ }
+ assert.equal(catalogTrust(codex), 'unverified')
+ assert.equal(fastModeAvailable({ engine: 'codex', model: 'gpt-5.4-mini', catalog: codex }), false)
+ assert.equal(fastModeAvailable({ engine: 'codex', model: 'gpt-5.6-sol', catalog: codex }), true)
+})
+
+test('the picker withholds rows from the same catalog the Fast Mode check reads', () => {
+ // The two decisions deliberately disagree: one asks "may I suggest this
+ // model?", the other "is the model already in play allowed to run this way?".
+ const labels = { follow: 'Follow engine default', recommended: 'Recommended', localDefault: (m: string) => `Local default: ${m}` }
+ assert.deepEqual(engineModelChoices(oldDaemon, 'big', labels), [
+ { value: '', label: 'Follow engine default' },
+ ])
+ assert.equal(fastModeAvailable({ engine: 'claude', model: '', catalog: oldDaemon }), true)
+})
+
+test('a vouched-for catalog is read the same way, and the name rule still applies', () => {
+ const vouched = { ...oldDaemon, trustedModels: true }
+ assert.equal(catalogTrust(vouched), 'reported')
+ assert.equal(fastModeAvailable({ engine: 'claude', model: '', catalog: vouched }), true)
+ // Claude's alias rule is independent of the catalog: `sonnet` is not an Opus
+ // alias, so Fast Mode would switch it to Opus.
+ assert.equal(fastModeAvailable({ engine: 'claude', model: 'sonnet', catalog: vouched }), false)
+ // A computer-level default is the next fallback after the Agent's own pin.
+ assert.equal(fastModeAvailable({ engine: 'claude', model: '', engineDefault: 'opus', catalog: undefined }), true)
+ assert.equal(fastModeAvailable({ engine: 'claude', model: 'sonnet', engineDefault: 'opus' }), false)
+ assert.equal(fastModeAvailable({ engine: 'cursor', model: 'opus' }), false)
+})
diff --git a/tests/engine-model-choices.test.ts b/tests/engine-model-choices.test.ts
new file mode 100644
index 0000000..b93eaf9
--- /dev/null
+++ b/tests/engine-model-choices.test.ts
@@ -0,0 +1,115 @@
+import { test } from 'node:test'
+import assert from 'node:assert/strict'
+import { catalogTrust, engineModelChoices } from '../src/lib/engine-model-choices.ts'
+
+const labels = {
+ follow: 'Follow engine default',
+ recommended: 'Recommended',
+ localDefault: (model: string) => `Local default: ${model}`,
+}
+
+const catalog = {
+ models: [
+ { id: 'claude-sonnet-4-5', label: 'Claude Sonnet 4.5', recommendedFor: ['big' as const] },
+ { id: 'claude-haiku-4-5', label: 'claude-haiku-4-5', recommendedFor: ['small' as const] },
+ ],
+ defaultModel: 'claude-sonnet-4-5',
+ defaultFastModel: 'claude-haiku-4-5',
+}
+
+test('first row is the empty value, hinted with the tier default it falls back to', () => {
+ const big = engineModelChoices(catalog, 'big', labels)
+ const small = engineModelChoices(catalog, 'small', labels)
+ assert.deepEqual(big[0], { value: '', label: 'Follow engine default', hint: 'Local default: claude-sonnet-4-5' })
+ assert.deepEqual(small[0], { value: '', label: 'Follow engine default', hint: 'Local default: claude-haiku-4-5' })
+})
+
+test('the follow hint names its source, because a deployment pin can still win', () => {
+ // Repro from review: this computer's CLI config says `local/main-model`, the
+ // server also has CUMORA_DEFAULT_CLAUDE_MODEL=deploy/main-model, and no agent
+ // or computer pin exists — so the daemon runs deploy/main-model. The catalog
+ // cannot see the pin, so the hint must not read as "this is what runs".
+ const local = { models: [], defaultModel: 'local/main-model', defaultFastModel: null }
+ const [follow] = engineModelChoices(local, 'big', labels)
+ assert.equal(follow.hint, 'Local default: local/main-model')
+ assert.doesNotMatch(String(follow.hint), /^local\/main-model$/)
+})
+
+test('catalog models follow the follow row, with the id as hint only when the label differs', () => {
+ const options = engineModelChoices(catalog, 'big', labels)
+ assert.deepEqual(options.slice(1), [
+ { value: 'claude-sonnet-4-5', label: 'Claude Sonnet 4.5', hint: 'claude-sonnet-4-5 · Recommended' },
+ { value: 'claude-haiku-4-5', label: 'claude-haiku-4-5', hint: undefined },
+ ])
+})
+
+test('recommended marker follows the tier being configured', () => {
+ const small = engineModelChoices(catalog, 'small', labels)
+ assert.equal(small[2].hint, 'Recommended')
+ assert.equal(small[1].hint, 'claude-sonnet-4-5')
+})
+
+test('no catalog still yields the follow row so the picker can offer custom ids', () => {
+ assert.deepEqual(engineModelChoices(undefined, 'big', labels), [
+ { value: '', label: 'Follow engine default' },
+ ])
+})
+
+test('a preset catalog offers no rows and quotes no default', () => {
+ // Gemini, qwen, zcode and maka are never probed at all: their catalog IS the
+ // compiled-in preset. Those ids are guesses about the account, and one of them
+ // saved as the computer default is a runtime failure every Agent inherits — so
+ // the picker offers only "follow" plus the custom-entry row.
+ const presets = {
+ models: [
+ { id: 'gemini-2.5-flash-lite', label: 'Gemini 2.5 Flash Lite', recommendedFor: ['small' as const] },
+ ],
+ defaultModel: null,
+ defaultFastModel: 'gemini-2.5-flash-lite',
+ source: 'presets' as const,
+ }
+ assert.equal(catalogTrust(presets), 'guessed')
+ for (const tier of ['big', 'small'] as const) {
+ assert.deepEqual(engineModelChoices(presets, tier, labels), [
+ { value: '', label: 'Follow engine default' },
+ ])
+ }
+})
+
+test('a listing from an old daemon is not offered, because its tail is preset', () => {
+ // Repro from review: a daemon that predates `trustedModels` merged its presets
+ // behind the provider's answer, so an account that listed only
+ // `gateway/only-model` also reported `gpt-5.4-mini` — labelled `protocol`, with
+ // nothing to tell the two apart. The flag is the only way to know.
+ const merged = {
+ models: [
+ { id: 'gateway/only-model', label: 'Only Model', recommendedFor: ['big' as const] },
+ { id: 'gpt-5.4-mini', label: 'gpt-5.4-mini', recommendedFor: ['small' as const] },
+ ],
+ defaultModel: 'gateway/only-model',
+ defaultFastModel: 'gpt-5.4-mini',
+ source: 'protocol' as const,
+ }
+ assert.equal(catalogTrust(merged), 'unverified')
+ assert.deepEqual(engineModelChoices(merged, 'big', labels), [
+ { value: '', label: 'Follow engine default' },
+ ])
+ // The same listing from a daemon that vouches for it is offered in full.
+ const vouched = { ...merged, trustedModels: true }
+ assert.equal(catalogTrust(vouched), 'reported')
+ assert.deepEqual(engineModelChoices(vouched, 'big', labels).map((option) => option.value), [
+ '', 'gateway/only-model', 'gpt-5.4-mini',
+ ])
+})
+
+test('trust distinguishes a vouched listing from a fallback and from nothing at all', () => {
+ const base = { models: [], defaultModel: null, defaultFastModel: null }
+ assert.equal(catalogTrust({ ...base, source: 'presets' }), 'guessed')
+ assert.equal(catalogTrust({ ...base, source: 'protocol' }), 'unverified')
+ assert.equal(catalogTrust({ ...base, source: 'cli' }), 'unverified')
+ assert.equal(catalogTrust({ ...base, source: 'protocol', trustedModels: true }), 'reported')
+ // A provider profile synthesises its own catalog in the app; there is no
+ // daemon report to doubt, and it is not a preset either.
+ assert.equal(catalogTrust(base), 'reported')
+ assert.equal(catalogTrust(undefined), 'missing')
+})