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: show persistent mind model capabilities

Adam Eivy386b70785746
diff --git a/client/src/components/cos/PersistentMindProfileControls.jsx b/client/src/components/cos/PersistentMindProfileControls.jsx
index 2492ba624c..2bbae4a9e4 100644
--- a/client/src/components/cos/PersistentMindProfileControls.jsx
+++ b/client/src/components/cos/PersistentMindProfileControls.jsx
@@ -1,6 +1,9 @@
import { useEffect, useId, useRef, useState } from 'react';
import useProviderModels from '../../hooks/useProviderModels';
import * as api from '../../services/api';
+import useLocalModels from '../../hooks/useLocalModels';
+import { effectiveModelFor, modelCapabilityInfo } from '../../utils/providers.js';
+import ModelCapabilitySummary from '../models/ModelCapabilitySummary.jsx';
import ProviderModelSelector from '../ProviderModelSelector';
import toast from '../ui/Toast';
@@ -34,12 +37,23 @@ export default function PersistentMindProfileControls({
setSelectedProviderId,
setSelectedModel,
} = useProviderModels({ allowDefault: true, withEffort: true, silent: true });
+ const {
+ capabilitiesByBackend,
+ recommendations,
+ loading: localModelsLoading,
+ } = useLocalModels();
const [draft, setDraft] = useState(() => normalizeProfile(profile));
const [saving, setSaving] = useState(false);
const draftRef = useRef(draft);
const publishedProfileRef = useRef(draft);
const pendingSavesRef = useRef(0);
const selectedProvider = providers.find((provider) => provider.id === draft.providerId) || null;
+ const capabilityModel = effectiveModelFor(selectedProvider, draft.model);
+ const capabilityInfo = modelCapabilityInfo(selectedProvider, capabilityModel, {
+ capabilitiesByBackend,
+ recommendations,
+ loading: localModelsLoading,
+ });
const harness = selectedProvider?.type === 'api'
? { label: 'Direct API · recommended', tone: 'border-port-success/30 bg-port-success/10 text-port-success', detail: 'Best reliability for an always-on mind: structured HTTP, clean cancellation, and no terminal state. Ollama, llama.cpp, LM Studio, vLLM, and compatible cloud endpoints use this lane.' }
: selectedProvider?.type === 'cli'
@@ -150,6 +164,7 @@ export default function PersistentMindProfileControls({
emptyProviderOption="Select an AI provider"
emptyModelOption="Select a model"
alwaysShowModel
+ highlightToolUse
layout="stacked"
label="AI provider"
onProviderChange={(providerId) => {
@@ -163,6 +178,11 @@ export default function PersistentMindProfileControls({
}}
onEffortChange={(effort) => save({ effort })}
/>
+ <ModelCapabilitySummary
+ provider={selectedProvider}
+ model={capabilityModel}
+ {...capabilityInfo}
+ />
{harness && (
<div className={`rounded border px-3 py-2 text-xs ${harness.tone}`}>
<p className="font-semibold">{harness.label}</p>
diff --git a/client/src/components/cos/PersistentMindProfileControls.test.jsx b/client/src/components/cos/PersistentMindProfileControls.test.jsx
new file mode 100644
index 0000000000..7dae37c613
--- /dev/null
+++ b/client/src/components/cos/PersistentMindProfileControls.test.jsx
@@ -0,0 +1,67 @@
+import { describe, expect, it, vi } from 'vitest';
+import { render, screen, waitFor } from '@testing-library/react';
+
+const api = vi.hoisted(() => ({
+ updateCosConfig: vi.fn(),
+}));
+const localLlm = vi.hoisted(() => ({
+ getLocalLlmStatus: vi.fn(),
+ getToolUseModels: vi.fn(),
+}));
+const providerHook = vi.hoisted(() => ({
+ setSelectedProviderId: vi.fn(),
+ setSelectedModel: vi.fn(),
+}));
+const toast = vi.hoisted(() => ({ success: vi.fn(), error: vi.fn() }));
+
+vi.mock('../../services/api', () => api);
+vi.mock('../../services/apiLocalLlm', () => localLlm);
+vi.mock('../../hooks/useProviderModels', () => ({
+ default: () => ({
+ providers: [{
+ id: 'ollama',
+ name: 'Ollama',
+ type: 'api',
+ endpoint: 'http://localhost:11434/v1',
+ defaultModel: 'qwen3.6:35b',
+ models: ['qwen3.6:35b', 'gemma3:4b'],
+ }],
+ availableModels: ['qwen3.6:35b', 'gemma3:4b'],
+ setSelectedProviderId: providerHook.setSelectedProviderId,
+ setSelectedModel: providerHook.setSelectedModel,
+ }),
+}));
+vi.mock('../ui/Toast', () => ({ default: toast }));
+
+import PersistentMindProfileControls from './PersistentMindProfileControls.jsx';
+
+describe('PersistentMindProfileControls capability guidance', () => {
+ it('shows runtime capabilities and the local recommendation for the selected model', async () => {
+ api.updateCosConfig.mockResolvedValue({ success: true });
+ localLlm.getToolUseModels.mockResolvedValue({
+ models: [{ providerId: 'ollama', id: 'qwen3.6:35b' }],
+ });
+ localLlm.getLocalLlmStatus.mockResolvedValue({
+ ollama: {
+ models: [{ id: 'qwen3.6:35b', capabilities: ['chat', 'tools', 'vision', 'reasoning'] }],
+ recommendations: { editorial: { id: 'qwen3.6:35b', reason: 'Best fit for local text work.' } },
+ },
+ lmstudio: { models: [] },
+ });
+
+ render(
+ <PersistentMindProfileControls
+ profile={{ enabled: true, providerId: 'ollama', model: 'qwen3.6:35b', effort: 'medium', thinkingInterface: 'text' }}
+ />,
+ );
+
+ await waitFor(() => expect(screen.getByTestId('model-capability-summary')).toBeInTheDocument());
+ expect(screen.getByLabelText('Chat')).toBeInTheDocument();
+ expect(screen.getByLabelText('Tool use')).toBeInTheDocument();
+ expect(screen.getByLabelText('Vision')).toBeInTheDocument();
+ expect(screen.getByLabelText('Reasoning')).toBeInTheDocument();
+ expect(screen.getByText('★ Recommended local model')).toBeInTheDocument();
+ expect(screen.getByText('Best fit for local text work.')).toBeInTheDocument();
+ await waitFor(() => expect(screen.getByRole('option', { name: /qwen3\.6:35b.*tool use/i })).toBeInTheDocument());
+ });
+});
diff --git a/client/src/components/cos/tabs/ConfigTab.test.jsx b/client/src/components/cos/tabs/ConfigTab.test.jsx
index 04be6ec903..235214f309 100644
--- a/client/src/components/cos/tabs/ConfigTab.test.jsx
+++ b/client/src/components/cos/tabs/ConfigTab.test.jsx
@@ -13,8 +13,13 @@ const providerHook = vi.hoisted(() => ({
setSelectedProviderId: vi.fn(),
setSelectedModel: vi.fn(),
}));
+const localLlm = vi.hoisted(() => ({
+ getLocalLlmStatus: vi.fn(),
+ getToolUseModels: vi.fn(),
+}));
vi.mock('../../../services/api', () => api);
+vi.mock('../../../services/apiLocalLlm', () => localLlm);
vi.mock('../../ui/Toast', () => ({ default: toast }));
// The provider/model selector hook fetches providers over the network — stub it
// so the test exercises only the config-save / level-change handlers.
@@ -46,6 +51,8 @@ const config = {
beforeEach(() => {
vi.clearAllMocks();
api.getCosBudgetUsage.mockResolvedValue({ usage: {} });
+ localLlm.getLocalLlmStatus.mockResolvedValue({ ollama: { models: [] }, lmstudio: { models: [] } });
+ localLlm.getToolUseModels.mockResolvedValue({ models: [] });
});
describe('ConfigTab handleSave', () => {
diff --git a/client/src/components/cos/tabs/MindTab.test.jsx b/client/src/components/cos/tabs/MindTab.test.jsx
index c58b10238c..a5fef84d9f 100644
--- a/client/src/components/cos/tabs/MindTab.test.jsx
+++ b/client/src/components/cos/tabs/MindTab.test.jsx
@@ -31,8 +31,13 @@ const socket = vi.hoisted(() => {
reset: () => handlers.clear(),
};
});
+const localLlm = vi.hoisted(() => ({
+ getLocalLlmStatus: vi.fn(),
+ getToolUseModels: vi.fn(),
+}));
vi.mock('../../../services/api', () => api);
+vi.mock('../../../services/apiLocalLlm', () => localLlm);
vi.mock('../../../hooks/useSocket', () => ({ useSocket: () => socket }));
import MindTab from './MindTab';
@@ -94,6 +99,8 @@ describe('MindTab', () => {
}],
});
api.updateCosConfig.mockResolvedValue({ success: true });
+ localLlm.getLocalLlmStatus.mockResolvedValue({ ollama: { models: [] }, lmstudio: { models: [] } });
+ localLlm.getToolUseModels.mockResolvedValue({ models: [] });
api.getPersistentMindContext.mockResolvedValue({
prompt: { schemaVersion: 1, identity: 'Resident mind', instructions: 'Stay grounded.' },
preview: { text: '# Effective context', chars: 19, approximateTokens: 5, summaryState: 'empty' },
diff --git a/client/src/components/models/ModelCapabilitySummary.jsx b/client/src/components/models/ModelCapabilitySummary.jsx
new file mode 100644
index 0000000000..785ef27793
--- /dev/null
+++ b/client/src/components/models/ModelCapabilitySummary.jsx
@@ -0,0 +1,65 @@
+import CapabilityBadges from './CapabilityBadges.jsx';
+
+const SOURCE_COPY = {
+ runtime: 'Reported by the local model runtime.',
+ provider: 'These are provider-level harness capabilities; this provider does not publish a separate per-model report.',
+ inferred: 'Some badges are inferred from the model id. A runtime report takes precedence when available.',
+ loading: 'Checking the local runtime for an authoritative capability report…',
+ unknown: 'This provider does not publish per-model capability metadata, so tool use and image analysis are not confirmed here.',
+};
+
+/**
+ * Explain what PortOS knows about the model selected for an agent profile.
+ * Keep this beside CapabilityBadges so model pickers use the same vocabulary
+ * as the Local LLM settings cards instead of inventing another set of labels.
+ */
+export default function ModelCapabilitySummary({
+ provider,
+ model,
+ capabilities,
+ source = 'unknown',
+ recommendation = null,
+}) {
+ if (!provider || !model) {
+ return (
+ <p className="text-xs text-port-text-muted">
+ Choose a provider and model to see capability badges and the available recommendation.
+ </p>
+ );
+ }
+
+ const capabilityCopy = Array.isArray(capabilities) && capabilities.length === 0
+ ? 'The runtime reported no optional capabilities for this model.'
+ : SOURCE_COPY[source] || SOURCE_COPY.unknown;
+
+ return (
+ <section
+ aria-label="Model capabilities"
+ data-testid="model-capability-summary"
+ className="rounded border border-port-border bg-port-bg/50 px-3 py-2"
+ >
+ <div className="flex flex-wrap items-center gap-2">
+ <h4 className="text-xs font-semibold text-port-text">Model capabilities</h4>
+ {recommendation && (
+ <span
+ className="text-[10px] px-1.5 py-0.5 rounded border border-port-accent/50 bg-port-accent/10 text-port-accent"
+ title={recommendation.reason || 'Recommended local model'}
+ >
+ ★ Recommended local model
+ </span>
+ )}
+ </div>
+ <div className="flex items-center gap-1.5 flex-wrap mt-1.5 min-h-5">
+ {Array.isArray(capabilities) && capabilities.length === 0 ? (
+ <span className="text-[11px] text-gray-500">No optional capabilities reported</span>
+ ) : (
+ <CapabilityBadges capabilities={capabilities} />
+ )}
+ </div>
+ <p className="mt-1 text-[11px] text-port-text-muted">{capabilityCopy}</p>
+ {recommendation?.reason && (
+ <p className="mt-0.5 text-[11px] text-port-accent">{recommendation.reason}</p>
+ )}
+ </section>
+ );
+}
diff --git a/client/src/components/models/ModelCapabilitySummary.test.jsx b/client/src/components/models/ModelCapabilitySummary.test.jsx
new file mode 100644
index 0000000000..f5bf00f02e
--- /dev/null
+++ b/client/src/components/models/ModelCapabilitySummary.test.jsx
@@ -0,0 +1,62 @@
+import { describe, expect, it } from 'vitest';
+import { render, screen } from '@testing-library/react';
+import ModelCapabilitySummary from './ModelCapabilitySummary.jsx';
+
+describe('ModelCapabilitySummary', () => {
+ it('renders reported badges and the matching local recommendation', () => {
+ render(
+ <ModelCapabilitySummary
+ provider={{ id: 'ollama', name: 'Ollama' }}
+ model="qwen3.6:35b"
+ capabilities={['chat', 'tools', 'vision']}
+ source="runtime"
+ recommendation={{ id: 'qwen3.6:35b', reason: 'Best fit for local text work.' }}
+ />,
+ );
+
+ expect(screen.getByRole('region', { name: 'Model capabilities' })).toBeInTheDocument();
+ expect(screen.getByLabelText('Chat')).toBeInTheDocument();
+ expect(screen.getByLabelText('Tool use')).toBeInTheDocument();
+ expect(screen.getByLabelText('Vision')).toBeInTheDocument();
+ expect(screen.getByText('★ Recommended local model')).toBeInTheDocument();
+ expect(screen.getByText('Reported by the local model runtime.')).toBeInTheDocument();
+ expect(screen.getByText('Best fit for local text work.')).toBeInTheDocument();
+ });
+
+ it('distinguishes an empty report from a capability set that was not reported', () => {
+ const { rerender } = render(
+ <ModelCapabilitySummary
+ provider={{ id: 'ollama' }}
+ model="gemma3:4b"
+ capabilities={[]}
+ source="runtime"
+ />,
+ );
+ expect(screen.getByText('No optional capabilities reported')).toBeInTheDocument();
+ expect(screen.getByText('The runtime reported no optional capabilities for this model.')).toBeInTheDocument();
+
+ rerender(
+ <ModelCapabilitySummary
+ provider={{ id: 'openai' }}
+ model="gpt-5"
+ capabilities={null}
+ source="unknown"
+ />,
+ );
+ expect(screen.getByText('capabilities not reported')).toBeInTheDocument();
+ expect(screen.getByText(/tool use and image analysis are not confirmed/i)).toBeInTheDocument();
+ });
+
+ it('explains that a CLI badge is a harness-level fact', () => {
+ render(
+ <ModelCapabilitySummary
+ provider={{ id: 'codex', type: 'cli' }}
+ model="gpt-5"
+ capabilities={['tools', 'vision']}
+ source="provider"
+ />,
+ );
+
+ expect(screen.getByText(/provider-level harness capabilities/i)).toBeInTheDocument();
+ });
+});
diff --git a/client/src/hooks/README.md b/client/src/hooks/README.md
index 032d425291..5ea8011f81 100644
--- a/client/src/hooks/README.md
+++ b/client/src/hooks/README.md
@@ -173,7 +173,7 @@ grep -i "what you want to do" client/src/hooks/README.md
| `useRecordMerge` | Duplicate Universe/Series merge flow: open → dry-run preview → resolve field conflicts → execute, with an `onMerged` refresh callback. Drives `<MergeModal>`. | Surfacing the merge-duplicates UI anywhere (Sharing → Duplicates, Universes page). Don't re-implement the preview/execute dance. |
| `useProviderModels` | AI providers + two-step provider→model selection. | Any UI that picks a provider + model. |
| `useReviewerModelOptions` | Selectable model ids and concrete provider defaults per model-taking reviewer for `ReviewerPicker`'s Model column — local-LLM ids from `/api/local-llm/status`, codex/claude/antigravity tiers from `/api/providers` (claude's list also spans installed Ollama ids for an Ollama-backed CLI; agy's list collapses to base ids since the row has its own Effort cell). Returns `{ optionsByReviewer, defaultModels, freeText, unavailable, loaded, reviewers }`. | Every surface that renders `ReviewerPicker` (Code Review Defaults, TaskAddForm, ScheduleTab, SlashDoRunDrawer) — the picker never fetches; pass this as its `modelOptions`. |
-| `useLocalModels` | Live installed Ollama/LM Studio model ids per backend + the server's editorial recommendation, plus `installed` per backend (`null` until fetched) — the app-level verdict that counts a macOS bundle with no CLI shim. | Model pickers that must show currently-installed local models (not just a provider's stale stored `models`). Fold in via `mergeModelLists` + `localBackendForProvider`. |
+| `useLocalModels` | Live installed Ollama/LM Studio model ids per backend, runtime capability badges, the server's editorial recommendation, and `installed` per backend (`null` until fetched) — the app-level verdict that counts a macOS bundle with no CLI shim. | Model pickers that must show currently-installed local models (not just a provider's stale stored `models`), or explain a selected model's live capabilities. Fold in via `mergeModelLists` + `localBackendForProvider`. |
| `useVisionModelIds` | `{ idsByProvider, loaded }` — vision-capable model ids the server reports (Ollama `/api/show` + LM Studio `type:'vlm'`), keyed by the provider id that serves them (`{ ollama: Set, lmstudio: Set }`), `null` until fetched; `loaded` flips once the fetch settles. Drops `backend:'cli'` rows (a blanket per-provider claim, not a per-model fact) and never vouches for a provider the server didn't enumerate. | Any VISION model picker — pass `idsByProvider` to `visionLocalModelFilter` / `assignmentModelOptions` so a new multimodal family (`gemma4`) isn't hidden by the stale client id regex, and so an installed VLM shows even when the provider's stored `models` snapshot is stale; gate any "none installed" messaging on `loaded` and on the provider being a local backend. |
| `useToolUseModelIds` | `{ idsByProvider, loaded }` — TOOL-USE (function-calling) capable model ids the server reports (Ollama `/api/show` `tools` capability + LM Studio catalog capabilities) via `/api/local-llm/tool-use-models`, keyed by the provider id that serves them (`{ ollama: Set, lmstudio: Set }`), `null` until fetched; `loaded` flips once the fetch settles. One module-shared fetch across every mounted caller, retried on a later mount if it failed. | Any AGENT model picker — pass `idsByProvider` to `localToolUseHint` / `withToolUseOptionLabel` so a tool-capable family the client id regex predates (`phi4-mini`) isn't mislabelled "⚠ no known tool use", and gate the annotation on `loaded` so the warning isn't asserted mid-fetch. |
| `useTheme` | Dark/light theme + paired-theme switching. | Theme picker. |
diff --git a/client/src/hooks/useLocalModels.js b/client/src/hooks/useLocalModels.js
index dfe94d3043..c1832bbd43 100644
--- a/client/src/hooks/useLocalModels.js
+++ b/client/src/hooks/useLocalModels.js
@@ -27,7 +27,12 @@ import { getLocalLlmStatus } from '../services/apiLocalLlm';
* compatibility verdicts into provider editors without changing the existing
* string-id API used by other consumers of this hook.
*
- * @returns {{ ollama: string[], lmstudio: string[], installed: { ollama: boolean|null, lmstudio: boolean|null }, recommendations: { ollama: object|null, lmstudio: object|null }, ctxById: Record<string, number>, hardwareCompatibilityByBackend: { ollama: Record<string, object>, lmstudio: Record<string, object> }, loading: boolean }}
+ * `capabilitiesByBackend` keeps the runtime's reported badge vocabulary keyed
+ * by model id. A present key with `null` means the model was found but its
+ * runtime did not report capabilities; an absent key means that model was not
+ * in the local status response.
+ *
+ * @returns {{ ollama: string[], lmstudio: string[], installed: { ollama: boolean|null, lmstudio: boolean|null }, recommendations: { ollama: object|null, lmstudio: object|null }, ctxById: Record<string, number>, hardwareCompatibilityByBackend: { ollama: Record<string, object>, lmstudio: Record<string, object> }, capabilitiesByBackend: { ollama: Record<string, string[]|null>, lmstudio: Record<string, string[]|null> }, loading: boolean }}
*/
export default function useLocalModels() {
const [state, setState] = useState({
@@ -37,6 +42,7 @@ export default function useLocalModels() {
recommendations: { ollama: null, lmstudio: null },
ctxById: {},
hardwareCompatibilityByBackend: { ollama: {}, lmstudio: {} },
+ capabilitiesByBackend: { ollama: {}, lmstudio: {} },
loading: true,
});
@@ -49,9 +55,15 @@ export default function useLocalModels() {
const ids = (list) => (list || []).map((m) => m.id || m.name).filter(Boolean);
const ctxById = {};
const hardwareCompatibilityByBackend = { ollama: {}, lmstudio: {} };
+ const capabilitiesByBackend = { ollama: {}, lmstudio: {} };
for (const backend of ['ollama', 'lmstudio']) {
for (const m of status?.[backend]?.models || []) {
const id = m.id || m.name;
+ if (id) {
+ capabilitiesByBackend[backend][id] = Array.isArray(m.capabilities)
+ ? m.capabilities
+ : null;
+ }
if (id && m.hardwareCompatibility && typeof m.hardwareCompatibility === 'object') {
hardwareCompatibilityByBackend[backend][id] = m.hardwareCompatibility;
}
@@ -71,6 +83,7 @@ export default function useLocalModels() {
},
ctxById,
hardwareCompatibilityByBackend,
+ capabilitiesByBackend,
loading: false,
});
})
diff --git a/client/src/pages/ChiefOfStaff.test.jsx b/client/src/pages/ChiefOfStaff.test.jsx
index 01e47e4f38..68f950c79b 100644
--- a/client/src/pages/ChiefOfStaff.test.jsx
+++ b/client/src/pages/ChiefOfStaff.test.jsx
@@ -31,8 +31,13 @@ const api = vi.hoisted(() => ({
}));
const toast = vi.hoisted(() => ({ success: vi.fn(), error: vi.fn() }));
const socketStub = vi.hoisted(() => ({ connected: false, on: vi.fn(), off: vi.fn(), emit: vi.fn() }));
+const localLlm = vi.hoisted(() => ({
+ getLocalLlmStatus: vi.fn(),
+ getToolUseModels: vi.fn(),
+}));
vi.mock('../services/api', () => api);
+vi.mock('../services/apiLocalLlm', () => localLlm);
vi.mock('../components/ui/Toast', () => ({ default: toast }));
vi.mock('../services/socket', () => ({ default: socketStub }));
// TaskAddForm drags in the reviewer/model picker plumbing (local-LLM status,
@@ -85,6 +90,8 @@ beforeEach(() => {
api.getCosLearningDurations.mockResolvedValue(null);
api.getCosPopularTemplates.mockResolvedValue([]);
api.getCodeReviewDefaults.mockResolvedValue({});
+ localLlm.getLocalLlmStatus.mockResolvedValue({ ollama: { models: [] }, lmstudio: { models: [] } });
+ localLlm.getToolUseModels.mockResolvedValue({ models: [] });
});
const renderConfigTab = () => render(
diff --git a/client/src/utils/providers.js b/client/src/utils/providers.js
index 163265bb0a..70f0823731 100644
--- a/client/src/utils/providers.js
+++ b/client/src/utils/providers.js
@@ -1110,6 +1110,71 @@ export const isOllamaBackedProvider = (provider) => {
return /:11434\b/.test(base) || /ollama/i.test(base);
};
+/**
+ * Resolve the capability badges for a selected model without over-sharing a
+ * local runtime's answer with another provider. The status endpoint is keyed
+ * by backend, but only the canonical `ollama` / `lmstudio` provider records
+ * are known to point at this install's daemon; custom or remote providers stay
+ * on conservative inference. This mirrors the provider-scoped boundary used
+ * by `useToolUseModelIds` and `useVisionModelIds`.
+ *
+ * `[]` is a valid runtime answer meaning no optional capabilities were
+ * reported. `null` means the capability set is unknown, and `source` tells the
+ * UI whether that is because the runtime is still loading, the provider gave a
+ * harness-level fact, or no authoritative metadata exists.
+ *
+ * @param {{id?:string,type?:string,command?:string,endpoint?:string,name?:string,ollamaBacked?:boolean}|null|undefined} provider
+ * @param {string|null|undefined} model
+ * @param {{capabilitiesByBackend?: {ollama?: Record<string, string[]|null>, lmstudio?: Record<string, string[]|null>}, recommendations?: {ollama?: object|null, lmstudio?: object|null}, loading?: boolean}} [options]
+ * @returns {{capabilities: string[]|null, source: 'unselected'|'runtime'|'provider'|'inferred'|'loading'|'unknown', recommendation: object|null}}
+ */
+export const modelCapabilityInfo = (provider, model, {
+ capabilitiesByBackend = {},
+ recommendations = {},
+ loading = false,
+} = {}) => {
+ const modelId = typeof model === 'string' ? model.trim() : '';
+ if (!provider || !modelId) {
+ return { capabilities: null, source: 'unselected', recommendation: null };
+ }
+
+ const backend = localBackendForProvider(provider);
+ const canonicalLocalProvider = backend && provider.id === backend;
+ const recommendation = canonicalLocalProvider ? recommendations?.[backend] : null;
+ const selectedRecommendation = recommendation?.id === modelId ? recommendation : null;
+
+ if (canonicalLocalProvider) {
+ const modelCapabilities = capabilitiesByBackend?.[backend];
+ if (modelCapabilities && Object.hasOwn(modelCapabilities, modelId)) {
+ const capabilities = modelCapabilities[modelId];
+ return {
+ capabilities: Array.isArray(capabilities) ? [...new Set(capabilities)] : null,
+ source: 'runtime',
+ recommendation: selectedRecommendation,
+ };
+ }
+ if (loading) {
+ return { capabilities: null, source: 'loading', recommendation: selectedRecommendation };
+ }
+ }
+
+ // A Codex or Claude CLI can attach/read an image and invoke tools through its
+ // harness. That is deliberately labelled as provider-level below; it is not
+ // pretending that the provider published per-model metadata.
+ if (isVisionCapableCliProvider(provider)) {
+ return { capabilities: ['tools', 'vision'], source: 'provider', recommendation: null };
+ }
+
+ const inferred = [];
+ if (backend && isToolUseModel(modelId)) inferred.push('tools');
+ if (backend && isVisionModel(modelId)) inferred.push('vision');
+ return {
+ capabilities: inferred.length ? inferred : null,
+ source: inferred.length ? 'inferred' : 'unknown',
+ recommendation: selectedRecommendation,
+ };
+};
+
/**
* The hosted OpenAI-compatible gateways an OpenCode CLI/TUI wrapper can
* front-end. MIRROR of `PROVIDER_GATEWAYS` in `server/lib/providerGateways.js`
diff --git a/client/src/utils/providers.test.js b/client/src/utils/providers.test.js
index cd39eb1abe..801e16d0f8 100644
--- a/client/src/utils/providers.test.js
+++ b/client/src/utils/providers.test.js
@@ -42,6 +42,7 @@ import {
isPrivateNetworkEndpoint,
PROVIDER_CARD_STATE,
isOllamaBackedProvider,
+ modelCapabilityInfo,
gatewayForProvider,
isGatewayBackedProvider,
isGrokBuildCli,
@@ -884,6 +885,48 @@ describe('localBackendForProvider', () => {
});
});
+describe('modelCapabilityInfo', () => {
+ const ollama = { id: 'ollama', name: 'Ollama', endpoint: 'http://localhost:11434/v1' };
+
+ it('uses the canonical local runtime report, including an intentional empty set', () => {
+ expect(modelCapabilityInfo(ollama, 'qwen3.6:35b', {
+ capabilitiesByBackend: { ollama: { 'qwen3.6:35b': ['chat', 'tools', 'vision'] } },
+ })).toEqual({
+ capabilities: ['chat', 'tools', 'vision'],
+ source: 'runtime',
+ recommendation: null,
+ });
+ expect(modelCapabilityInfo(ollama, 'gemma3:4b', {
+ capabilitiesByBackend: { ollama: { 'gemma3:4b': [] } },
+ })).toEqual({ capabilities: [], source: 'runtime', recommendation: null });
+ });
+
+ it('marks the backend editorial pick without treating it as a capability', () => {
+ const recommendation = { id: 'qwen3.6:35b', reason: 'Best fit for local text work.' };
+ expect(modelCapabilityInfo(ollama, 'qwen3.6:35b', {
+ capabilitiesByBackend: { ollama: { 'qwen3.6:35b': ['chat', 'tools'] } },
+ recommendations: { ollama: recommendation },
+ }).recommendation).toBe(recommendation);
+ });
+
+ it('does not let a local status map vouch for a custom remote provider', () => {
+ const remoteOllama = { id: 'remote-ollama', name: 'Remote Ollama', endpoint: 'http://192.0.2.10:11434/v1' };
+ expect(modelCapabilityInfo(remoteOllama, 'phi4-mini:latest', {
+ capabilitiesByBackend: { ollama: { 'phi4-mini:latest': ['chat', 'tools'] } },
+ })).toEqual({ capabilities: null, source: 'unknown', recommendation: null });
+ });
+
+ it('shows known CLI harness capabilities separately from per-model metadata', () => {
+ expect(modelCapabilityInfo({ id: 'codex', type: 'cli', command: 'codex' }, 'gpt-5'))
+ .toEqual({ capabilities: ['tools', 'vision'], source: 'provider', recommendation: null });
+ });
+
+ it('keeps a local model unknown while its authoritative status is loading', () => {
+ expect(modelCapabilityInfo(ollama, 'qwen3.6:35b', { loading: true }))
+ .toEqual({ capabilities: null, source: 'loading', recommendation: null });
+ });
+});
+
describe('knownProviderContextWindow (mirror of server stageRunner)', () => {
it('resolves vendor windows for bare commands', () => {
expect(knownProviderContextWindow({ id: 'codex-tui', type: 'tui', command: 'codex' })).toBe(CODEX_CONTEXT_WINDOW);