Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

feat([issue-3615]): fetch Cursor's model catalog live via `cursor-agent models`

Adam Eivy60ecde124fd2
diff --git a/client/src/utils/providers.js b/client/src/utils/providers.js
index 800f94a872..210817aadb 100644
--- a/client/src/utils/providers.js
+++ b/client/src/utils/providers.js
@@ -167,16 +167,22 @@ export const supportsModelRefresh = (provider) => {
if (isTuiProvider(provider)) {
// A TUI's model is normally fixed by the CLI/config; the server carries
- // exactly two exceptions, and — unlike its CLI arm — neither consults the
+ // exactly three exceptions, and — unlike its CLI arm — none consults the
// provider NAME, so this must not either.
return isOllamaBackedProvider(provider)
|| provider?.id === 'antigravity-tui'
- || isAntigravityCommand(command);
+ || isAntigravityCommand(command)
+ || provider?.id === 'cursor-tui'
+ || isCursorCommand(command);
}
if (isCliProvider(provider)) {
if (isOllamaBackedProvider(provider)) return true;
if (name.includes('antigravity') || isAntigravityCommand(command)) return true;
+ // Command-only, matching the server's cursor arm — which deliberately omits
+ // a name test so an unrelated provider named e.g. "Cursor Notes" doesn't
+ // claim a refresh the server would refuse.
+ if (isCursorCommand(command)) return true;
// Deliberately the RAW command string, not a basename: the server's claude
// and gemini arms compare `provider.command === 'claude'` exactly. Matching
// on basename here would re-open the same 404 in a new place — a renamed,
diff --git a/client/src/utils/providers.test.js b/client/src/utils/providers.test.js
index 73a284b368..9df1dd8ca8 100644
--- a/client/src/utils/providers.test.js
+++ b/client/src/utils/providers.test.js
@@ -741,13 +741,25 @@ describe('supportsModelRefresh', () => {
// The contract is a MIRROR of the server's `_refreshCLIProviderModels`
// dispatch: anything the server throws for must be false here, or the button
// 404s on every click.
- it('hides the button for cursor — no server-side fetcher exists yet', () => {
- expect(supportsModelRefresh({ id: 'cursor-cli', type: 'cli', command: 'cursor-agent', name: 'Cursor Agent CLI' })).toBe(false);
- expect(supportsModelRefresh({ id: 'custom', type: 'cli', command: '/Users/x/.local/bin/cursor-agent', name: 'Cursor' })).toBe(false);
+ // `_fetchCursorModels` shells `cursor-agent models`, so cursor now refreshes.
+ // Command-keyed on BOTH arms (path- and `.exe`-tolerant), because the server's
+ // cursor branch is — a name test would be wrong in the other direction, see
+ // the "Cursor Notes" case below.
+ it('offers the button for cursor, including a path-configured binary', () => {
+ expect(supportsModelRefresh({ id: 'cursor-cli', type: 'cli', command: 'cursor-agent', name: 'Cursor Agent CLI' })).toBe(true);
+ expect(supportsModelRefresh({ id: 'custom', type: 'cli', command: '/home/x/.local/bin/cursor-agent', name: 'Cursor' })).toBe(true);
});
- it('hides the button for the TUI variant via the generic TUI gate', () => {
- expect(supportsModelRefresh({ id: 'cursor-tui', type: 'tui', command: 'cursor-agent', name: 'Cursor Agent TUI' })).toBe(false);
+ it('offers it for the cursor TUI too — `--model` applies to the session', () => {
+ expect(supportsModelRefresh({ id: 'cursor-tui', type: 'tui', command: 'cursor-agent', name: 'Cursor Agent TUI' })).toBe(true);
+ expect(supportsModelRefresh({ id: 'cursor-tui', type: 'tui', command: '/home/x/.local/bin/cursor-agent', name: 'renamed' })).toBe(true);
+ });
+
+ it('does not offer it for a provider merely NAMED cursor, or for the GUI binary', () => {
+ // "cursor" is an ordinary English word, and a bare `cursor` is the GUI
+ // editor launcher — neither reaches the server's command-keyed arm.
+ expect(supportsModelRefresh({ id: 'x', type: 'cli', command: 'some-other-binary', name: 'Cursor Notes' })).toBe(false);
+ expect(supportsModelRefresh({ id: 'x', type: 'cli', command: 'cursor', name: 'Cursor' })).toBe(false);
});
// Regression: these two SHIP in data.reference/providers.json and the old
@@ -808,11 +820,14 @@ describe('supportsModelRefresh', () => {
if (isOllamaBackedProvider(p)) return true;
if (name.includes('claude') || p.command === 'claude') return true;
if (name.includes('antigravity') || isAntigravityCommand(p.command)) return true;
+ // Command-only — the server's cursor arm carries no name test.
+ if (isCursorCommand(p.command)) return true;
if (name.includes('gemini') || p.command === 'gemini') return true;
return false; // server throws → route 404s
}
if (p.type === 'tui' && isOllamaBackedProvider(p)) return true;
if (p.type === 'tui' && (p.id === 'antigravity-tui' || isAntigravityCommand(p.command))) return true;
+ if (p.type === 'tui' && (p.id === 'cursor-tui' || isCursorCommand(p.command))) return true;
return false;
};
diff --git a/server/lib/aiToolkit/internal/cursor.js b/server/lib/aiToolkit/internal/cursor.js
new file mode 100644
index 0000000000..8ac97c7555
--- /dev/null
+++ b/server/lib/aiToolkit/internal/cursor.js
@@ -0,0 +1,60 @@
+/**
+ * Cursor Agent constants and catalog parsing for the aiToolkit.
+ *
+ * Duplicated from server/lib/cursor.js so the toolkit stays self-contained
+ * (no imports out to sibling PortOS modules — see ../CLAUDE.md). Keep in sync
+ * with upstream, the same arrangement as ./antigravity.js.
+ */
+
+export const CURSOR_CLI_ID = 'cursor-cli';
+export const CURSOR_TUI_ID = 'cursor-tui';
+
+/** The binary basename. Deliberately NOT `cursor` — that is the GUI editor. */
+export const CURSOR_COMMAND = 'cursor-agent';
+
+// Match by normalized binary basename so a path- or `.exe`-configured provider
+// (`~/.local/bin/cursor-agent`, `cursor-agent.exe`) is still recognized. Inlined
+// (not the shared commandBasename) to keep the vendored toolkit self-contained.
+// Keep in sync with server/lib/cursor.js#isCursorCommand.
+export function isCursorCommand(command) {
+ if (typeof command !== 'string' || command === '') return false;
+ const base = command.split(/[\\/]/).pop().toLowerCase().replace(/\.exe$/, '');
+ return base === CURSOR_COMMAND;
+}
+
+// `cursor-agent models` prints `<id> - <Label>` rows wrapped in a header line
+// and a trailing `Tip:` paragraph:
+//
+// Available models
+//
+// auto - Auto (current, default)
+// gpt-5.3-codex-low - Codex 5.3 Low
+// …
+//
+// Tip: use --model <id> (or /model <id> in interactive mode) to switch. …
+//
+// so it needs its own parser rather than `agy models`' bare-id-per-line one.
+//
+// Anchoring on the ` - ` separator is what separates a row from the surrounding
+// prose: an id is a single space-free lowercase token, so neither "Available
+// models" nor the `Tip:` sentence can present one immediately before a
+// space-dash-space. (Verified against cursor-agent 2026.08.04: all 177 reported
+// ids draw from `[a-z0-9.-]`, and those two prose lines are the only non-blank
+// output the regex has to reject.) `.+` after the separator is greedy but the id
+// group cannot contain a space, so a LABEL carrying its own ` - ` still yields
+// the id alone.
+const CURSOR_MODEL_LINE = /^([a-z0-9][a-z0-9._:/-]*) - .+$/;
+
+/**
+ * Parse the id column out of `cursor-agent models` output.
+ * @param {string} stdout - raw stdout from `cursor-agent models`
+ * @returns {string[]} deduped ids, in the order the binary listed them
+ */
+export function parseCursorModelList(stdout) {
+ const ids = [];
+ for (const line of String(stdout || '').split(/\r?\n/)) {
+ const match = CURSOR_MODEL_LINE.exec(line.trim());
+ if (match) ids.push(match[1]);
+ }
+ return [...new Set(ids)];
+}
diff --git a/server/lib/aiToolkit/internal/cursor.test.js b/server/lib/aiToolkit/internal/cursor.test.js
new file mode 100644
index 0000000000..2f197ea95e
--- /dev/null
+++ b/server/lib/aiToolkit/internal/cursor.test.js
@@ -0,0 +1,105 @@
+import { describe, it, expect } from 'vitest';
+import { CURSOR_COMMAND, CURSOR_CLI_ID, CURSOR_TUI_ID, isCursorCommand, parseCursorModelList } from './cursor.js';
+
+// A verbatim excerpt of `cursor-agent models` (2026.08.04) — the header line,
+// the blank line under it, a run of `<id> - <Label>` rows, and the trailing
+// `Tip:` paragraph. Trimmed from the real 177-row catalog; the surrounding
+// prose and spacing are reproduced exactly, because rejecting it is the whole
+// job of the parser.
+const REAL_OUTPUT = `Available models
+
+auto - Auto (current, default)
+gpt-5.3-codex-low - Codex 5.3 Low
+gpt-5.3-codex-low-fast - Codex 5.3 Low Fast
+composer-2.5 - Composer 2.5
+claude-opus-5-thinking-high - Opus 5 1M Thinking
+claude-fable-5-thinking-high - Fable 5 1M Thinking (NO ZDR)
+gemini-3.5-flash - Gemini 3.5 Flash
+gpt-5-mini - GPT-5 Mini
+
+Tip: use --model <id> (or /model <id> in interactive mode) to switch. Parameterized models also accept quoted overrides, e.g. --model 'claude-opus-4-8[context=1m,effort=high,fast=false]'.
+`;
+
+describe('isCursorCommand', () => {
+ it('matches the bare binary, an absolute path, and a Windows .exe', () => {
+ expect(isCursorCommand('cursor-agent')).toBe(true);
+ expect(isCursorCommand('/opt/homebrew/bin/cursor-agent')).toBe(true);
+ expect(isCursorCommand('C:\\Tools\\cursor-agent.exe')).toBe(true);
+ expect(isCursorCommand('CURSOR-AGENT')).toBe(true);
+ });
+
+ it('never matches a bare `cursor` — that is the GUI editor launcher', () => {
+ // Spawning the editor from a headless refresh would open a window or hang
+ // rather than print a catalog, so this must stay a non-match.
+ expect(isCursorCommand('cursor')).toBe(false);
+ expect(isCursorCommand('/usr/local/bin/cursor')).toBe(false);
+ });
+
+ it('rejects empty and non-string commands', () => {
+ expect(isCursorCommand('')).toBe(false);
+ expect(isCursorCommand(null)).toBe(false);
+ expect(isCursorCommand(undefined)).toBe(false);
+ expect(isCursorCommand(42)).toBe(false);
+ });
+});
+
+describe('parseCursorModelList', () => {
+ it('extracts ids from real `cursor-agent models` output, dropping the prose', () => {
+ expect(parseCursorModelList(REAL_OUTPUT)).toEqual([
+ 'auto',
+ 'gpt-5.3-codex-low',
+ 'gpt-5.3-codex-low-fast',
+ 'composer-2.5',
+ 'claude-opus-5-thinking-high',
+ 'claude-fable-5-thinking-high',
+ 'gemini-3.5-flash',
+ 'gpt-5-mini',
+ ]);
+ });
+
+ it('drops the header and the trailing Tip paragraph specifically', () => {
+ const ids = parseCursorModelList(REAL_OUTPUT);
+ expect(ids).not.toContain('Available');
+ expect(ids).not.toContain('Tip:');
+ expect(ids.some(id => id.includes(' '))).toBe(false);
+ });
+
+ it('keeps `auto` — cursor has a real router id, not a synthetic sentinel', () => {
+ // Unlike Grok/Kimi/Antigravity, cursor needs no `*-configured-default`
+ // sentinel: `auto` is a genuine id the binary accepts, so it must survive
+ // a refresh as an ordinary catalog entry or "let cursor choose" disappears.
+ expect(parseCursorModelList(REAL_OUTPUT)[0]).toBe('auto');
+ });
+
+ it('stops the id at the first separator when the LABEL also contains " - "', () => {
+ expect(parseCursorModelList('gpt-5.3-codex - Codex 5.3 - Priority Compute')).toEqual(['gpt-5.3-codex']);
+ });
+
+ it('handles CRLF line endings', () => {
+ expect(parseCursorModelList('Available models\r\n\r\nauto - Auto\r\ncomposer-2.5 - Composer 2.5\r\n'))
+ .toEqual(['auto', 'composer-2.5']);
+ });
+
+ it('tolerates indented rows and dedupes repeats, preserving first-seen order', () => {
+ expect(parseCursorModelList(' auto - Auto\ncomposer-2.5 - Composer\n auto - Auto\n'))
+ .toEqual(['auto', 'composer-2.5']);
+ });
+
+ it('returns an empty list for prose-only, blank, and non-string input', () => {
+ // The caller turns empty into a THROW, so this must not invent entries from
+ // a banner-only response (e.g. an auth prompt printed in place of a list).
+ expect(parseCursorModelList('Available models\n\nTip: use --model <id>\n')).toEqual([]);
+ expect(parseCursorModelList('Please log in first.\n')).toEqual([]);
+ expect(parseCursorModelList('')).toEqual([]);
+ expect(parseCursorModelList(null)).toEqual([]);
+ expect(parseCursorModelList(undefined)).toEqual([]);
+ });
+});
+
+describe('cursor toolkit constants', () => {
+ it('mirror the shipped provider ids and binary name', () => {
+ expect(CURSOR_COMMAND).toBe('cursor-agent');
+ expect(CURSOR_CLI_ID).toBe('cursor-cli');
+ expect(CURSOR_TUI_ID).toBe('cursor-tui');
+ });
+});
diff --git a/server/lib/aiToolkit/providers.js b/server/lib/aiToolkit/providers.js
index e694f285a2..89adc6e1fc 100644
--- a/server/lib/aiToolkit/providers.js
+++ b/server/lib/aiToolkit/providers.js
@@ -16,6 +16,12 @@ import {
LEGACY_GEMINI_CLI_ID,
LEGACY_GEMINI_TUI_ID,
} from './internal/antigravity.js';
+import {
+ CURSOR_COMMAND,
+ CURSOR_TUI_ID,
+ isCursorCommand,
+ parseCursorModelList,
+} from './internal/cursor.js';
const __dirname = dirname(fileURLToPath(import.meta.url));
const DEFAULT_SAMPLE_PATH = join(__dirname, 'defaults/providers.sample.json');
@@ -760,6 +766,12 @@ export function createProviderService(config = {}) {
// Same exception for the Antigravity TUI: `agy --model` applies to the
// interactive session too, so its catalog must refresh like the CLI's.
models = await this._fetchAntigravityModels(provider);
+ } else if (provider.type === 'tui' && (provider.id === CURSOR_TUI_ID || isCursorCommand(provider.command))) {
+ // And for the Cursor TUI: `cursor-agent --model` applies to the
+ // interactive session too — the binary's own `Tip:` line documents
+ // both `--model <id>` and the in-session `/model <id>` — so its
+ // catalog must refresh like the CLI's.
+ models = await this._fetchCursorModels(provider);
}
} catch (error) {
console.error(`Failed to refresh models for ${provider.name}:`, error.message);
@@ -850,6 +862,17 @@ export function createProviderService(config = {}) {
return await this._fetchAntigravityModels(provider);
}
+ // Keyed on the command basename for the same reason as the antigravity
+ // branch: a path- or `.exe`-configured binary must still refresh, or the
+ // client's mirrored gate offers a Refresh button that falls through to the
+ // throw below. Unlike every vendor around it there is deliberately NO name
+ // test — "cursor" is an ordinary English word (a DB cursor, a text
+ // cursor), so a `name.includes('cursor')` clause would hijack the refresh
+ // for an unrelated provider the user happened to name "Cursor Notes".
+ if (isCursorCommand(provider.command)) {
+ return await this._fetchCursorModels(provider);
+ }
+
if (providerName.includes('gemini') || provider.command === 'gemini') {
return await this._fetchGeminiModels(provider);
}
@@ -907,6 +930,62 @@ export function createProviderService(config = {}) {
return [ANTIGRAVITY_CONFIGURED_DEFAULT, ...new Set(listed)];
},
+ /**
+ * cursor-agent ships a `models` subcommand that prints the authoritative
+ * catalog for THIS account and binary version — 177 ids at time of writing,
+ * against the 27 hand-curated ones the provider seed ships. Unlike Grok/Kimi
+ * (no catalog subcommand at all, hence their `*-configured-default`
+ * sentinel), cursor can answer for itself, so a refresh asks it rather than
+ * re-serving a list that can only go stale.
+ *
+ * THROWS rather than falling back to the shipped seed when the probe can't
+ * run (cursor-agent not installed, the service PATH can't resolve it, a
+ * timeout, a non-zero exit) or comes back with nothing parseable — same
+ * posture and same reasoning as `_fetchAntigravityModels`: persisting the
+ * seed here would make a failed probe indistinguishable from a real fetch,
+ * so `refreshProviderModels` would save it and the UI would toast "Models
+ * refreshed", leaving a user whose PATH can't see cursor-agent to pick a
+ * model their account may not have and find out when the run dies. Throwing
+ * returns null instead → an explicit error toast, with the stored list left
+ * untouched. Matches the root CLAUDE.md rule that a reachable-but-list-
+ * failed backend must surface an explicit error rather than a plausible-
+ * looking default.
+ *
+ * No sentinel is prepended (the one structural difference from the agy
+ * fetcher): cursor exposes a real `auto` id — its own server-side router,
+ * and the binary's default — and `models` lists it first, so "let cursor
+ * choose" survives a refresh as an ordinary catalog entry.
+ *
+ * The full list is persisted as reported, `-fast` priority-compute twins
+ * included. A refresh is an explicit user action and the account catalog is
+ * the authoritative answer; any thinning belongs in the picker, not here, so
+ * the stored list stays faithful to what the binary will actually accept.
+ */
+ async _fetchCursorModels(provider) {
+ const bin = provider?.command || CURSOR_COMMAND;
+ const { command, args } = prepareWindowsSafeSpawn(bin, ['models']);
+ const pending = execFileAsync(command, args, {
+ timeout: 15000,
+ env: { ...process.env, ...provider?.envVars },
+ });
+ // Defensive, not load-bearing. `agy models` prints NOTHING until stdin
+ // closes, so with execFile's default pipe it hangs the full 15s and exits
+ // on SIGTERM; cursor-agent does not share that behavior — measured against
+ // 2026.08.04 it answers in well under a second either way (848ms with
+ // stdin open vs 825ms closed). Ending the stream anyway costs nothing and
+ // keeps the probe immune if a later build grows the agy behavior.
+ pending.child?.stdin?.end();
+ const { stdout } = await pending.catch((err) => {
+ throw new Error(`'${bin} models' failed: ${err?.message || 'could not run the binary'}`);
+ });
+
+ const listed = parseCursorModelList(stdout);
+ if (listed.length === 0) {
+ throw new Error(`'${bin} models' returned no model ids`);
+ }
+ return listed;
+ },
+
async _fetchOllamaToolCapableModels(provider) {
const base = ollamaBaseFromProvider(provider);
const res = await fetch(`${base}/api/tags`, { signal: AbortSignal.timeout(8000) }).catch(() => null);
diff --git a/server/lib/aiToolkit/providers.test.js b/server/lib/aiToolkit/providers.test.js
index 4223a2fbd8..b5e75159a5 100644
--- a/server/lib/aiToolkit/providers.test.js
+++ b/server/lib/aiToolkit/providers.test.js
@@ -819,6 +819,142 @@ describe('Provider Service', () => {
});
});
+ describe('Cursor Agent model refresh (`cursor-agent models`)', () => {
+ // Stand in for the real binary with a script that prints a captured excerpt
+ // of `cursor-agent models` — header line, blank line, `<id> - <Label>` rows,
+ // trailing `Tip:` paragraph. Shell-script based, so POSIX only; CI is
+ // ubuntu-latest and the assertions below are about parsing, not spawning.
+ const writeFakeCursor = async (body, { exitCode = 0 } = {}) => {
+ const path = join(TEST_DATA_DIR, 'cursor-agent');
+ await writeFile(path, `#!/bin/sh\ncat <<'EOF'\n${body}\nEOF\nexit ${exitCode}\n`);
+ const { chmod } = await import('fs/promises');
+ await chmod(path, 0o755);
+ return path;
+ };
+
+ const SAMPLE = [
+ 'Available models',
+ '',
+ 'auto - Auto (current, default)',
+ 'gpt-5.3-codex-low - Codex 5.3 Low',
+ 'gpt-5.3-codex-low-fast - Codex 5.3 Low Fast',
+ 'composer-2.5 - Composer 2.5',
+ 'claude-opus-5-thinking-high - Opus 5 1M Thinking',
+ '',
+ "Tip: use --model <id> (or /model <id> in interactive mode) to switch. Parameterized models also accept quoted overrides, e.g. --model 'claude-opus-4-8[context=1m,effort=high,fast=false]'.",
+ ].join('\n');
+
+ it.skipIf(process.platform === 'win32')('persists the live catalog for a cursor CLI provider', async () => {
+ const command = await writeFakeCursor(SAMPLE);
+ const p = await providerService.createProvider({
+ name: 'Cursor Agent CLI',
+ type: 'cli',
+ command,
+ models: ['auto', 'composer-2.5'],
+ defaultModel: 'auto',
+ });
+
+ const updated = await providerService.refreshProviderModels(p.id);
+ expect(updated).not.toBeNull();
+ // The full list as reported — `-fast` priority-compute twins included, and
+ // `auto` retained (cursor's real router id, not a synthetic sentinel).
+ expect(updated.models).toEqual([
+ 'auto',
+ 'gpt-5.3-codex-low',
+ 'gpt-5.3-codex-low-fast',
+ 'composer-2.5',
+ 'claude-opus-5-thinking-high',
+ ]);
+ });
+
+ it.skipIf(process.platform === 'win32')('refreshes a cursor TUI provider too', async () => {
+ // `cursor-agent --model` applies to the interactive session as well, so
+ // the TUI arm must reach the fetcher rather than no-op to null.
+ const command = await writeFakeCursor(SAMPLE);
+ const p = await providerService.createProvider({
+ name: 'Cursor Agent TUI',
+ type: 'tui',
+ command,
+ models: ['auto'],
+ defaultModel: 'auto',
+ });
+
+ const updated = await providerService.refreshProviderModels(p.id);
+ expect(updated).not.toBeNull();
+ expect(updated.models).toContain('gpt-5.3-codex-low-fast');
+ });
+
+ // A failed `cursor-agent models` probe must be distinguishable from a real
+ // fetch. Returning the shipped 27-id seed here would persist it and toast
+ // "Models refreshed", so a user whose service PATH can't resolve the binary
+ // would pick a model their account may not have and only discover it when
+ // the run dies.
+ it('reports a failed probe as a refresh failure, leaving the stored list intact', async () => {
+ const stored = ['auto', 'composer-2.5'];
+ const p = await providerService.createProvider({
+ name: 'Cursor Agent CLI',
+ type: 'cli',
+ command: '/nonexistent/path/to/cursor-agent',
+ models: [...stored],
+ defaultModel: 'auto',
+ });
+
+ const errSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
+ const result = await providerService.refreshProviderModels(p.id);
+ errSpy.mockRestore();
+
+ // null = "nothing to persist"; the routes layer turns this into an error.
+ expect(result).toBeNull();
+ const after = await providerService.getProviderById(p.id);
+ expect(after.models).toEqual(stored);
+ });
+
+ it.skipIf(process.platform === 'win32')('treats a prose-only response as a failure, not an empty catalog', async () => {
+ // e.g. an auth/upgrade banner printed in place of the list. Persisting []
+ // here would silently empty the user's model picker.
+ const stored = ['auto', 'composer-2.5'];
+ const command = await writeFakeCursor('Please run cursor-agent login first.');
+ const p = await providerService.createProvider({
+ name: 'Cursor Agent CLI',
+ type: 'cli',
+ command,
+ models: [...stored],
+ defaultModel: 'auto',
+ });
+
+ const errSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
+ const result = await providerService.refreshProviderModels(p.id);
+ errSpy.mockRestore();
+
+ expect(result).toBeNull();
+ const after = await providerService.getProviderById(p.id);
+ expect(after.models).toEqual(stored);
+ });
+
+ it('does not hijack an unrelated provider that merely has "cursor" in its name', async () => {
+ // The cursor arm is command-keyed on purpose — "cursor" is an ordinary
+ // English word, so a name test would claim a refresh for a provider whose
+ // binary knows nothing about `models`.
+ const p = await providerService.createProvider({
+ name: 'Cursor Notes',
+ type: 'cli',
+ command: 'some-other-binary',
+ models: ['x'],
+ });
+
+ const errSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
+ const result = await providerService.refreshProviderModels(p.id);
+ // Snapshot the calls BEFORE restoring — mockRestore() also resets the
+ // spy, so reading mock.calls afterwards always sees an empty array.
+ const logged = errSpy.mock.calls.flat().join(' ');
+ errSpy.mockRestore();
+
+ // Falls through to the 'not supported for this CLI provider' throw.
+ expect(result).toBeNull();
+ expect(logged).toMatch(/not supported/i);
+ });
+ });
+
describe('_refreshAPIProviderModels — network layer', () => {
afterEach(() => {
vi.unstubAllGlobals();