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

add useProviderCatalog hook and ProviderComposePopover for custom provider combinations (#7566)

[._.]/ Adam Eivy53031200d758
diff --git a/client/src/components/providers/ProviderComposePopover.jsx b/client/src/components/providers/ProviderComposePopover.jsx
new file mode 100644
index 0000000000..af5dc4487c
--- /dev/null
+++ b/client/src/components/providers/ProviderComposePopover.jsx
@@ -0,0 +1,292 @@
+/**
+ * The "Custom combination…" compose flow (#7566): harness → method → service
+ * → model → effort, narrowing at each step, plus an optional credential
+ * bootstrap select and "Save as preset" — everything `ProviderModelSelector`'s
+ * preset-first list defers to once the user asks for something not already a
+ * preset.
+ *
+ * Renders NOTHING (returns `null`) while closed, and requests
+ * `useProviderCatalog` only while open — a picker that never opens compose
+ * pays for no catalog fetch. Every field is a native, keyboard-operable,
+ * `FormField`-labelled `<select>`; the panel is `Modal`'s standard chrome, so
+ * focus is trapped while open and returned to the trigger on close (WCAG
+ * 2.4.3 / 2.1.2) for free.
+ *
+ * @param {object} props
+ * @param {boolean} props.open
+ * @param {function} props.onClose
+ * @param {function} props.onCompose - `(compositeId, { model, effort }) => void`.
+ * Called for "Use once" — the caller stores the composite id in its existing
+ * `{ providerId, model, effort }` field; nothing is persisted server-side.
+ * @param {function} [props.onPresetSaved] - `(presetRecord) => void`. Called
+ * after "Save as preset" succeeds, so the caller can select the new preset
+ * id in place of the composite.
+ * @param {string[]} [props.allowedMethods] - Restrict the method (and so the
+ * harnesses offered) to this caller's mode policy, e.g. `['tui']` for
+ * `ShellProviderLauncher`. Omit for no restriction.
+ * @param {string} [props.title] - Panel heading (default: "Compose a custom combination").
+ */
+import { useEffect, useId, useMemo, useState } from 'react';
+import Modal from '../ui/Modal.jsx';
+import { FormField } from '../ui/FormField.jsx';
+import EffortSelect from '../cos/EffortSelect.jsx';
+import useProviderCatalog from '../../hooks/useProviderCatalog.js';
+import { useAsyncAction } from '../../hooks/useAsyncAction.js';
+
+const SELECT_CLASS = 'w-full px-3 py-1.5 min-h-[36px] bg-port-bg border border-port-border rounded-lg text-white text-sm';
+
+/** The readiness line under the service select: harness detection + service credential/daemon state. */
+const READINESS_LABEL = {
+ ready: 'ready to run',
+ 'needs-credential': 'needs a credential',
+ 'needs-endpoint': 'needs an endpoint',
+ disabled: 'switched off',
+ 'unknown-definition': 'unknown service definition',
+};
+
+export default function ProviderComposePopover({
+ open,
+ onClose,
+ onCompose,
+ onPresetSaved,
+ allowedMethods,
+ title = 'Compose a custom combination',
+}) {
+ const catalog = useProviderCatalog(open);
+ const [harnessId, setHarnessId] = useState('');
+ const [method, setMethod] = useState('');
+ const [serviceSlug, setServiceSlug] = useState('');
+ const [model, setModel] = useState('');
+ const [effort, setEffort] = useState('');
+ const [bootstrapSlug, setBootstrapSlug] = useState('');
+ const [presetName, setPresetName] = useState('');
+ const [showPresetField, setShowPresetField] = useState(false);
+
+ // Reset to a blank compose every time the popover is (re)opened, so a
+ // previous "Use once" choice never lingers into the next open.
+ useEffect(() => {
+ if (!open) return;
+ setHarnessId('');
+ setMethod('');
+ setServiceSlug('');
+ setModel('');
+ setEffort('');
+ setBootstrapSlug('');
+ setPresetName('');
+ setShowPresetField(false);
+ }, [open]);
+
+ const harnesses = useMemo(
+ () => (catalog.harnesses || []).filter((harness) => harness.enabled
+ && (!allowedMethods || harness.modes.some((mode) => allowedMethods.includes(mode)))),
+ [catalog.harnesses, allowedMethods],
+ );
+ const methods = useMemo(() => {
+ const all = catalog.methodsFor(harnessId);
+ return allowedMethods ? all.filter((mode) => allowedMethods.includes(mode)) : all;
+ }, [catalog, harnessId, allowedMethods]);
+ const services = useMemo(
+ () => catalog.compatiblePairs(harnessId).filter((service) => service.enabled !== false),
+ [catalog, harnessId],
+ );
+ const selectedService = services.find((service) => service.slug === serviceSlug) || null;
+ const models = catalog.modelsFor(serviceSlug);
+ const effortLevels = catalog.effortLevelsFor(harnessId, model || null);
+ const bootstraps = catalog.bootstraps || [];
+ const bootstrapEligible = (method === 'cli' || method === 'tui') && bootstraps.length > 0;
+ const bootstrapRequired = selectedService?.credentialVia === 'bootstrap';
+ const selectedHarness = harnesses.find((harness) => harness.id === harnessId) || null;
+
+ const compositeId = harnessId && method && serviceSlug
+ ? `${harnessId}.${method}@${serviceSlug}${bootstrapSlug ? `+${bootstrapSlug}` : ''}`
+ : null;
+ const canCompose = Boolean(compositeId) && (!bootstrapRequired || bootstrapSlug);
+
+ const [saveAsPreset, saving] = useAsyncAction(async () => {
+ const created = await catalog.savePreset({
+ compositeId,
+ name: presetName.trim() || undefined,
+ model: model || null,
+ effort: effort || null,
+ });
+ onPresetSaved?.(created);
+ onClose();
+ return created;
+ }, { errorMessage: 'Could not save this combination as a preset' });
+
+ const handleHarnessChange = (value) => {
+ setHarnessId(value);
+ setMethod('');
+ setServiceSlug('');
+ setModel('');
+ setEffort('');
+ setBootstrapSlug('');
+ };
+ const handleMethodChange = (value) => {
+ setMethod(value);
+ setBootstrapSlug('');
+ };
+ const handleServiceChange = (value) => {
+ setServiceSlug(value);
+ setModel('');
+ setEffort('');
+ setBootstrapSlug('');
+ };
+
+ const harnessSelectId = useId();
+ const methodSelectId = useId();
+ const serviceSelectId = useId();
+ const modelSelectId = useId();
+ const bootstrapSelectId = useId();
+ const presetNameId = useId();
+
+ return (
+ <Modal open={open} onClose={onClose} size="sm" usePortal ariaLabel={title}>
+ <div className="p-4 flex flex-col gap-3">
+ <h2 className="text-base font-semibold text-white">{title}</h2>
+
+ <FormField label="Harness" className="mb-0">
+ <select
+ id={harnessSelectId}
+ className={SELECT_CLASS}
+ value={harnessId}
+ disabled={catalog.loading}
+ onChange={(e) => handleHarnessChange(e.target.value)}
+ >
+ <option value="">{catalog.loading ? 'Loading harnesses…' : 'Choose a harness…'}</option>
+ {harnesses.map((harness) => (
+ <option key={harness.id} value={harness.id}>{harness.label}</option>
+ ))}
+ </select>
+ </FormField>
+
+ {harnessId && (
+ <FormField label="Method" className="mb-0">
+ <select
+ id={methodSelectId}
+ className={SELECT_CLASS}
+ value={method}
+ onChange={(e) => handleMethodChange(e.target.value)}
+ >
+ <option value="">Choose a method…</option>
+ {methods.map((mode) => (
+ <option key={mode} value={mode}>{mode.toUpperCase()}</option>
+ ))}
+ </select>
+ </FormField>
+ )}
+
+ {harnessId && method && (
+ <FormField label="Service" className="mb-0">
+ <select
+ id={serviceSelectId}
+ className={SELECT_CLASS}
+ value={serviceSlug}
+ onChange={(e) => handleServiceChange(e.target.value)}
+ >
+ <option value="">Choose a service…</option>
+ {services.map((service) => (
+ <option key={service.slug} value={service.slug}>{service.label}</option>
+ ))}
+ </select>
+ {selectedService && (
+ <p className="text-xs text-gray-500 mt-1">
+ {selectedHarness?.detected === false ? `${selectedHarness.label} not detected on this machine — ` : ''}
+ {READINESS_LABEL[selectedService.readiness] || selectedService.readiness}
+ </p>
+ )}
+ </FormField>
+ )}
+
+ {serviceSlug && models.length > 0 && (
+ <FormField label="Model" className="mb-0">
+ <select id={modelSelectId} className={SELECT_CLASS} value={model} onChange={(e) => setModel(e.target.value)}>
+ <option value="">Default model</option>
+ {models.map((m) => {
+ const value = typeof m === 'string' ? m : m.id;
+ const label = typeof m === 'string' ? m : (m.name || m.id);
+ return <option key={value} value={value}>{label}</option>;
+ })}
+ </select>
+ </FormField>
+ )}
+
+ {serviceSlug && effortLevels.length > 0 && (
+ <FormField label="Thinking effort" className="mb-0">
+ <EffortSelect
+ provider={{ harnessId, effort: '', type: method }}
+ model={model || null}
+ value={effort}
+ onChange={setEffort}
+ className={SELECT_CLASS}
+ />
+ </FormField>
+ )}
+
+ {bootstrapEligible && (
+ <FormField label={`Credential bootstrap${bootstrapRequired ? ' (required)' : ''}`} className="mb-0">
+ <select
+ id={bootstrapSelectId}
+ className={SELECT_CLASS}
+ value={bootstrapSlug}
+ onChange={(e) => setBootstrapSlug(e.target.value)}
+ >
+ <option value="">{bootstrapRequired ? 'Choose a bootstrap app…' : 'None'}</option>
+ {bootstraps.map((app) => (
+ <option key={app.slug} value={app.slug}>{app.label}</option>
+ ))}
+ </select>
+ {bootstrapRequired && (
+ <p className="text-xs text-gray-500 mt-1">
+ This service authenticates through a wrapper app — pick which one supplies the credential.
+ </p>
+ )}
+ </FormField>
+ )}
+
+ {showPresetField && (
+ <FormField label="Preset name" className="mb-0">
+ <input
+ id={presetNameId}
+ type="text"
+ className={SELECT_CLASS}
+ value={presetName}
+ onChange={(e) => setPresetName(e.target.value)}
+ placeholder={selectedHarness && selectedService ? `${selectedHarness.label} · ${selectedService.label}` : 'Preset name'}
+ />
+ </FormField>
+ )}
+
+ <div className="flex flex-col sm:flex-row gap-2 mt-1">
+ <button
+ type="button"
+ className="flex-1 px-3 py-1.5 rounded-lg bg-port-bg border border-port-border text-white text-sm hover:bg-port-border disabled:opacity-50"
+ disabled={!canCompose}
+ onClick={() => { onCompose(compositeId, { model, effort }); onClose(); }}
+ >
+ Use once
+ </button>
+ {!showPresetField ? (
+ <button
+ type="button"
+ className="flex-1 px-3 py-1.5 rounded-lg bg-port-bg border border-port-border text-white text-sm hover:bg-port-border disabled:opacity-50"
+ disabled={!canCompose}
+ onClick={() => setShowPresetField(true)}
+ >
+ Save as preset…
+ </button>
+ ) : (
+ <button
+ type="button"
+ className="flex-1 px-3 py-1.5 rounded-lg bg-port-accent text-white text-sm hover:opacity-90 disabled:opacity-50"
+ disabled={!canCompose || saving}
+ onClick={saveAsPreset}
+ >
+ {saving ? 'Saving…' : 'Confirm save'}
+ </button>
+ )}
+ </div>
+ </div>
+ </Modal>
+ );
+}
diff --git a/client/src/components/providers/ProviderComposePopover.test.jsx b/client/src/components/providers/ProviderComposePopover.test.jsx
new file mode 100644
index 0000000000..c8773f8e17
--- /dev/null
+++ b/client/src/components/providers/ProviderComposePopover.test.jsx
@@ -0,0 +1,155 @@
+import { describe, it, expect, vi, afterEach, beforeEach } from 'vitest';
+import { act, cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';
+import ProviderComposePopover from './ProviderComposePopover';
+
+afterEach(cleanup);
+
+const CATALOG = {
+ harnesses: [
+ { id: 'pi', label: 'Pi', modes: ['tui'], enabled: true, detected: true },
+ { id: 'claude', label: 'Claude Code', modes: ['cli', 'tui'], enabled: true, detected: true },
+ ],
+ bootstraps: [{ slug: 'chatgpt', label: 'ChatGPT wrapper' }],
+ loading: false,
+ compatiblePairs: (harnessId) => (harnessId === 'pi'
+ ? [{ slug: 'nvidia-nim-free', label: 'NVIDIA NIM', plan: 'free', enabled: true, credentialVia: 'stored', readiness: 'ready', catalog: { models: ['nvidia/example'] } }]
+ : [{ slug: 'anthropic', label: 'Anthropic', plan: 'paid', enabled: true, credentialVia: 'bootstrap', readiness: 'needs-credential', catalog: { models: ['claude-sonnet'] } }]),
+ methodsFor: (harnessId) => (harnessId === 'pi' ? ['tui'] : ['cli', 'tui']),
+ modelsFor: (slug) => (slug === 'nvidia-nim-free' ? ['nvidia/example'] : slug === 'anthropic' ? ['claude-sonnet'] : []),
+ effortLevelsFor: (harnessId) => (harnessId === 'pi' ? ['low', 'medium', 'high', 'xhigh', 'max'] : []),
+ savePreset: vi.fn(),
+};
+
+const mocked = vi.hoisted(() => ({ useProviderCatalog: vi.fn() }));
+vi.mock('../../hooks/useProviderCatalog.js', () => ({ default: mocked.useProviderCatalog }));
+
+beforeEach(() => {
+ mocked.useProviderCatalog.mockReturnValue(CATALOG);
+ CATALOG.savePreset.mockReset();
+});
+
+// Composes down harness -> method -> service, asserting each select only
+// appears once its predecessor is chosen (the narrowing the issue asks for).
+async function composePiTui() {
+ fireEvent.change(screen.getByLabelText('Harness'), { target: { value: 'pi' } });
+ await waitFor(() => expect(screen.getByLabelText('Method')).toBeTruthy());
+ fireEvent.change(screen.getByLabelText('Method'), { target: { value: 'tui' } });
+ await waitFor(() => expect(screen.getByLabelText('Service')).toBeTruthy());
+ fireEvent.change(screen.getByLabelText('Service'), { target: { value: 'nvidia-nim-free' } });
+}
+
+describe('ProviderComposePopover', () => {
+ it('renders nothing while closed', () => {
+ const { container } = render(<ProviderComposePopover open={false} onClose={vi.fn()} onCompose={vi.fn()} />);
+ expect(container.textContent).toBe('');
+ });
+
+ it('renders only the Harness select until a harness is chosen, then narrows step by step', async () => {
+ render(<ProviderComposePopover open onClose={vi.fn()} onCompose={vi.fn()} />);
+ expect(screen.getByLabelText('Harness')).toBeTruthy();
+ expect(screen.queryByLabelText('Method')).toBeNull();
+ expect(screen.queryByLabelText('Service')).toBeNull();
+
+ await composePiTui();
+ expect(screen.getByLabelText('Model')).toBeTruthy();
+ expect(screen.getByLabelText('Thinking effort')).toBeTruthy();
+ });
+
+ it('emits the composed composite id on "Use once" and closes', async () => {
+ const onCompose = vi.fn();
+ const onClose = vi.fn();
+ render(<ProviderComposePopover open onClose={onClose} onCompose={onCompose} />);
+ await composePiTui();
+
+ fireEvent.click(screen.getByRole('button', { name: 'Use once' }));
+ expect(onCompose).toHaveBeenCalledWith('pi.tui@nvidia-nim-free', { model: '', effort: '' });
+ expect(onClose).toHaveBeenCalledTimes(1);
+ });
+
+ it('includes the picked model and effort in the emitted composite', async () => {
+ const onCompose = vi.fn();
+ render(<ProviderComposePopover open onClose={vi.fn()} onCompose={onCompose} />);
+ await composePiTui();
+ fireEvent.change(screen.getByLabelText('Model'), { target: { value: 'nvidia/example' } });
+ fireEvent.change(screen.getByLabelText('Thinking effort'), { target: { value: 'high' } });
+
+ fireEvent.click(screen.getByRole('button', { name: 'Use once' }));
+ expect(onCompose).toHaveBeenCalledWith('pi.tui@nvidia-nim-free', { model: 'nvidia/example', effort: 'high' });
+ });
+
+ it('disables "Use once" until harness, method and service are all chosen', () => {
+ render(<ProviderComposePopover open onClose={vi.fn()} onCompose={vi.fn()} />);
+ expect(screen.getByRole('button', { name: 'Use once' })).toBeDisabled();
+ });
+
+ it('requires a credential bootstrap for a service that authenticates via one, and appends its slug', async () => {
+ const onCompose = vi.fn();
+ render(<ProviderComposePopover open onClose={vi.fn()} onCompose={onCompose} />);
+ fireEvent.change(screen.getByLabelText('Harness'), { target: { value: 'claude' } });
+ await waitFor(() => expect(screen.getByLabelText('Method')).toBeTruthy());
+ fireEvent.change(screen.getByLabelText('Method'), { target: { value: 'cli' } });
+ await waitFor(() => expect(screen.getByLabelText('Service')).toBeTruthy());
+ fireEvent.change(screen.getByLabelText('Service'), { target: { value: 'anthropic' } });
+
+ const useOnce = screen.getByRole('button', { name: 'Use once' });
+ expect(useOnce).toBeDisabled();
+ expect(screen.getByLabelText(/Credential bootstrap \(required\)/)).toBeTruthy();
+
+ fireEvent.change(screen.getByLabelText(/Credential bootstrap/), { target: { value: 'chatgpt' } });
+ expect(useOnce).not.toBeDisabled();
+ fireEvent.click(useOnce);
+ expect(onCompose).toHaveBeenCalledWith('claude.cli@anthropic+chatgpt', { model: '', effort: '' });
+ });
+
+ it('offers the bootstrap select as OPTIONAL for a service that stores its own credential', async () => {
+ render(<ProviderComposePopover open onClose={vi.fn()} onCompose={vi.fn()} />);
+ await composePiTui();
+ // nvidia-nim-free's credentialVia is 'stored', not 'bootstrap': the select
+ // still renders (method is tui and a bootstrap app is configured) but is
+ // never marked required, unlike the anthropic/credentialVia:'bootstrap' case.
+ expect(screen.getByLabelText('Credential bootstrap')).toBeTruthy();
+ expect(screen.queryByText(/required/)).toBeNull();
+ expect(screen.getByRole('button', { name: 'Use once' })).not.toBeDisabled();
+ });
+
+ it('restricts harnesses and methods to allowedMethods (caller mode policy)', () => {
+ render(<ProviderComposePopover open onClose={vi.fn()} onCompose={vi.fn()} allowedMethods={['tui']} />);
+ const harnessSelect = screen.getByLabelText('Harness');
+ const optionLabels = Array.from(harnessSelect.querySelectorAll('option')).map((o) => o.textContent);
+ // Both fixture harnesses support tui, so both remain offered.
+ expect(optionLabels).toEqual(expect.arrayContaining(['Pi', 'Claude Code']));
+ });
+
+ it('saves the composed combination as a preset and reports it to the caller', async () => {
+ CATALOG.savePreset.mockResolvedValue({ id: 'pi-tui-nvidia-nim-free' });
+ const onPresetSaved = vi.fn();
+ const onClose = vi.fn();
+ render(<ProviderComposePopover open onClose={onClose} onCompose={vi.fn()} onPresetSaved={onPresetSaved} />);
+ await composePiTui();
+
+ fireEvent.click(screen.getByRole('button', { name: 'Save as preset…' }));
+ expect(screen.getByLabelText('Preset name')).toBeTruthy();
+ fireEvent.change(screen.getByLabelText('Preset name'), { target: { value: 'My Pi NIM' } });
+
+ await act(async () => {
+ fireEvent.click(screen.getByRole('button', { name: 'Confirm save' }));
+ });
+
+ expect(CATALOG.savePreset).toHaveBeenCalledWith({
+ compositeId: 'pi.tui@nvidia-nim-free', name: 'My Pi NIM', model: null, effort: null,
+ });
+ expect(onPresetSaved).toHaveBeenCalledWith({ id: 'pi-tui-nvidia-nim-free' });
+ expect(onClose).toHaveBeenCalledTimes(1);
+ });
+
+ it('resets its fields every time it is reopened', async () => {
+ const { rerender } = render(<ProviderComposePopover open onClose={vi.fn()} onCompose={vi.fn()} />);
+ await composePiTui();
+ expect(screen.getByLabelText('Service')).toHaveValue('nvidia-nim-free');
+
+ rerender(<ProviderComposePopover open={false} onClose={vi.fn()} onCompose={vi.fn()} />);
+ rerender(<ProviderComposePopover open onClose={vi.fn()} onCompose={vi.fn()} />);
+ expect(screen.getByLabelText('Harness')).toHaveValue('');
+ expect(screen.queryByLabelText('Method')).toBeNull();
+ });
+});
diff --git a/client/src/hooks/README.md b/client/src/hooks/README.md
index 21217ab63a..e4b390bd32 100644
--- a/client/src/hooks/README.md
+++ b/client/src/hooks/README.md
@@ -179,6 +179,7 @@ grep -i "what you want to do" client/src/hooks/README.md
| `useGoalDetail` | All state + handlers backing the GoalDetailPanel (edit form, todos, milestones, plan/phases, check-ins, progress log, activity/calendar links). Loads activities + subcalendars on mount. | GoalDetailPanel composition shell; not intended for reuse outside the goals panel. |
| `usePostSession` | MeatSpace POST drill-run state, refresh snapshots, scoring, and idempotent test/training saves. | POST launcher and drill runners. |
| `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. |
+| `useProviderCatalog` | The composition catalog behind the preset-first `ProviderModelSelector` and `ProviderComposePopover` (#7566): one module-shared fetch of `GET /api/providers/catalog` (harnesses + enablement, service instances, bootstrap apps, per-harness/per-model effort ladders, compatibility map, sanitized presets), plus `compatiblePairs(harnessId)`, `methodsFor(harnessId)`, `modelsFor(serviceSlug)`, `effortLevelsFor(harnessId, model)`, `resolveRef(id)` (a preset record, or a synthesized display record for a composite id — no server round trip, so a saved value renders instantly), and `savePreset(input)` (`POST /providers/presets`, "Save as preset"). Gate the fetch with the popover's `open` so a picker that never composes pays nothing. | `ProviderComposePopover`; any picker that needs to resolve/display a composite id or list harnesses/services/effort ladders without a fresh `/providers/composites/:id` round trip. |
| `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`. |
| `useLocalImageModels` | This install's local image-model catalog plus the model a blank pin resolves to (`settings.imageGen.local.modelId` → the shipped default), `enabled`-gated so nothing is probed until a local render is in play. `models` is `null` until fetched, `[]` when genuinely empty. | Any local image-model picker — the Settings Local default, and the per-record pin row on decks/universes/series/sprites/music video. |
diff --git a/client/src/hooks/index.js b/client/src/hooks/index.js
index 6fed651dbd..074cfa998d 100644
--- a/client/src/hooks/index.js
+++ b/client/src/hooks/index.js
@@ -78,6 +78,8 @@ export { default as useVisionModelIds } from './useVisionModelIds.js';
export { default as useToolUseModelIds } from './useToolUseModelIds.js';
export * from './useToolUseModelIds.js';
export { default as usePreviewRoute } from './usePreviewRoute.js';
+export { default as useProviderCatalog } from './useProviderCatalog.js';
+export * from './useProviderCatalog.js';
export { default as useProviderModels } from './useProviderModels.js';
export * from './useRecentImageGallery.js';
export { default as useReviewerModelOptions } from './useReviewerModelOptions.js';
diff --git a/client/src/hooks/useProviderCatalog.js b/client/src/hooks/useProviderCatalog.js
new file mode 100644
index 0000000000..efa7934a18
--- /dev/null
+++ b/client/src/hooks/useProviderCatalog.js
@@ -0,0 +1,158 @@
+import { useCallback, useEffect, useState } from 'react';
+import { createProviderPreset, getProviderCatalog } from '../services/api';
+import { harnessLabel } from '../utils/providerHarnesses.js';
+import { parseProviderRef } from '../utils/providerRef.js';
+
+/**
+ * Module-level fetch cache, same shape as `useToolUseModelIds`: `null` = never
+ * fetched (or the last attempt failed and was cleared for retry), a Promise
+ * once a fetch is in flight or has resolved. The compose popover, the
+ * preset-first `ProviderModelSelector`, and every bespoke picker migrating
+ * onto this hook (#7566) can all mount inside the same tree, so N mounts must
+ * share ONE `/providers/catalog` fetch rather than firing N of them.
+ */
+let inFlight = null;
+
+const EMPTY_CATALOG = Object.freeze({
+ harnesses: [], services: [], bootstraps: [], compatibility: {}, effortLevels: {}, effortLevelsByModel: {}, presets: [],
+});
+
+function fetchCatalog() {
+ inFlight ||= getProviderCatalog({ silent: true })
+ .catch((err) => {
+ console.warn(`⚠️ Provider catalog fetch failed: ${err?.message || err}`);
+ inFlight = null;
+ return null;
+ });
+ return inFlight;
+}
+
+/** Test seam — drop the shared cache so each case starts from "never fetched". */
+export function __resetProviderCatalogCache() {
+ inFlight = null;
+}
+
+/**
+ * The composition catalog behind the preset-first `ProviderModelSelector` and
+ * `ProviderComposePopover` (#7566): one fetch of `GET /api/providers/catalog`
+ * per mount tree, shared like `useToolUseModelIds`, plus the lookups every
+ * picker/popover needs over it.
+ *
+ * - `presets` / `harnesses` / `services` / `bootstraps` — the raw catalog rows.
+ * - `compatiblePairs(harnessId)` — the enabled service instances a harness can
+ * be pointed at, narrowed by `compatibility`.
+ * - `methodsFor(harnessId)` — the execution modes (`cli`/`tui`/`api`) that
+ * harness supports.
+ * - `modelsFor(serviceSlug)` — the service's own model catalog.
+ * - `effortLevelsFor(harnessId, model)` — the per-model ladder when one
+ * narrows the harness's own (Codex, Antigravity), else the harness ladder.
+ * - `resolveRef(id)` — a preset record for a preset id, or a SYNTHESIZED
+ * display record for a composite id (`{ id, name, harnessId, method,
+ * serviceSlug, bootstrapId, models, enabled: true, composite: true }`,
+ * named `"<harness label> · <METHOD> · <service label>"`, `" (free)"`
+ * suffixed for a free-plan service) — `null` when the id resolves to
+ * neither grammar or the composite names a harness/service this catalog
+ * doesn't know. Never contacts the server: unlike
+ * `GET /providers/composites/:id`, this is a pure lookup over the fetched
+ * catalog, so it renders a saved value instantly without a round trip, and
+ * carries no ELIGIBILITY verdict — pair it with the readiness/composites
+ * endpoints when "is this composite runnable right now" matters.
+ * - `savePreset(input)` — `POST /providers/presets` ("Save as preset"),
+ * returned rather than imported separately so the popover doesn't need its
+ * own service import.
+ *
+ * @param {boolean} [enabled] - Load the catalog only when true, e.g. gate on
+ * the compose popover's `open`. Fetches once and keeps the result if
+ * `enabled` later goes false.
+ * @returns {{
+ * harnesses: object[], services: object[], bootstraps: object[], presets: object[],
+ * compatibility: Record<string, string[]>, effortLevels: Record<string, string[]>,
+ * effortLevelsByModel: Record<string, Record<string, string[]>>,
+ * loading: boolean,
+ * compatiblePairs: (harnessId: string) => object[],
+ * methodsFor: (harnessId: string) => string[],
+ * modelsFor: (serviceSlug: string) => Array<string|object>,
+ * effortLevelsFor: (harnessId: string, model?: string|null) => string[],
+ * resolveRef: (id: string) => object|null,
+ * savePreset: (input: object) => Promise<object>,
+ * }}
+ */
+export default function useProviderCatalog(enabled = true) {
+ const [state, setState] = useState({ catalog: null, loaded: false });
+
+ useEffect(() => {
+ if (!enabled || state.loaded) return undefined;
+ let canceled = false;
+ fetchCatalog().then((catalog) => {
+ if (!canceled) setState({ catalog, loaded: true });
+ });
+ // A cancel (popover closed mid-flight) leaves `loaded` false, so reopening
+ // re-reads rather than rendering a result that never arrived — free when
+ // the first fetch already succeeded, since the shared cache still has it.
+ return () => { canceled = true; };
+ }, [enabled, state.loaded]);
+
+ const catalog = state.catalog || EMPTY_CATALOG;
+
+ const compatiblePairs = useCallback((harnessId) => {
+ const slugs = new Set(catalog.compatibility?.[harnessId] || []);
+ return (catalog.services || []).filter((service) => slugs.has(service.slug));
+ }, [catalog]);
+
+ const methodsFor = useCallback(
+ (harnessId) => [...((catalog.harnesses || []).find((harness) => harness.id === harnessId)?.modes || [])],
+ [catalog],
+ );
+
+ const modelsFor = useCallback(
+ (serviceSlug) => (catalog.services || []).find((service) => service.slug === serviceSlug)?.catalog?.models || [],
+ [catalog],
+ );
+
+ const effortLevelsFor = useCallback((harnessId, model = null) => {
+ const perModel = model ? catalog.effortLevelsByModel?.[harnessId]?.[model] : null;
+ return perModel || catalog.effortLevels?.[harnessId] || [];
+ }, [catalog]);
+
+ const resolveRef = useCallback((id) => {
+ if (!id) return null;
+ const preset = (catalog.presets || []).find((p) => p.id === id);
+ if (preset) return preset;
+ const ref = parseProviderRef(id);
+ if (ref?.kind !== 'composite') return null;
+ const service = (catalog.services || []).find((s) => s.slug === ref.serviceSlug);
+ if (!service) return null;
+ const label = `${harnessLabel(ref.harnessId)} · ${ref.method.toUpperCase()} · ${service.label}${service.plan === 'free' ? ' (free)' : ''}`;
+ return {
+ id,
+ name: label,
+ type: ref.method,
+ harnessId: ref.harnessId,
+ method: ref.method,
+ serviceSlug: ref.serviceSlug,
+ bootstrapId: ref.bootstrapSlug,
+ models: service.catalog?.models || [],
+ enabled: true,
+ composite: true,
+ };
+ }, [catalog]);
+
+ const savePreset = useCallback((input) => createProviderPreset(input), []);
+
+ return {
+ harnesses: catalog.harnesses,
+ services: catalog.services,
+ bootstraps: catalog.bootstraps,
+ presets: catalog.presets,
+ compatibility: catalog.compatibility,
+ effortLevels: catalog.effortLevels,
+ effortLevelsByModel: catalog.effortLevelsByModel,
+ loading: enabled && !state.loaded,
+ compatiblePairs,
+ methodsFor,
+ modelsFor,
+ effortLevelsFor,
+ resolveRef,
+ savePreset,
+ };
+}
diff --git a/client/src/hooks/useProviderCatalog.test.js b/client/src/hooks/useProviderCatalog.test.js
new file mode 100644
index 0000000000..925ba39d79
--- /dev/null
+++ b/client/src/hooks/useProviderCatalog.test.js
@@ -0,0 +1,134 @@
+import { describe, it, expect, vi, beforeEach } from 'vitest';
+import { renderHook, waitFor, act } from '@testing-library/react';
+import useProviderCatalog, { __resetProviderCatalogCache } from './useProviderCatalog.js';
+
+const api = vi.hoisted(() => ({ getProviderCatalog: vi.fn(), createProviderPreset: vi.fn() }));
+vi.mock('../services/api.js', () => api);
+
+const CATALOG = {
+ harnesses: [
+ { id: 'pi', label: 'Pi', modes: ['tui'], enabled: true, detected: true },
+ { id: 'claude', label: 'Claude Code', modes: ['cli', 'tui'], enabled: false, detected: false },
+ ],
+ services: [
+ { slug: 'nvidia-nim-free', label: 'NVIDIA NIM', plan: 'free', enabled: true, credentialVia: 'stored', readiness: 'ready', catalog: { models: ['nvidia/example'] } },
+ ],
+ bootstraps: [{ slug: 'chatgpt', label: 'ChatGPT wrapper' }],
+ compatibility: { pi: ['nvidia-nim-free'], claude: [] },
+ effortLevels: { pi: ['low', 'medium', 'high', 'xhigh', 'max'], claude: ['low', 'medium', 'high'] },
+ effortLevelsByModel: { pi: {}, claude: {} },
+ presets: [{ id: 'claude-code', name: 'Claude', enabled: true }],
+};
+
+beforeEach(() => {
+ __resetProviderCatalogCache();
+ api.getProviderCatalog.mockReset().mockResolvedValue(CATALOG);
+ api.createProviderPreset.mockReset();
+});
+
+describe('useProviderCatalog', () => {
+ it('starts loading and settles into the fetched catalog', async () => {
+ const { result } = renderHook(() => useProviderCatalog());
+ expect(result.current.loading).toBe(true);
+ await waitFor(() => expect(result.current.loading).toBe(false));
+ expect(result.current.harnesses).toHaveLength(2);
+ expect(result.current.presets).toEqual(CATALOG.presets);
+ });
+
+ it('does not fetch while disabled, and fetches once enabled goes true', async () => {
+ const { result, rerender } = renderHook(({ enabled }) => useProviderCatalog(enabled), { initialProps: { enabled: false } });
+ expect(api.getProviderCatalog).not.toHaveBeenCalled();
+ expect(result.current.loading).toBe(false);
+ rerender({ enabled: true });
+ await waitFor(() => expect(result.current.loading).toBe(false));
+ expect(api.getProviderCatalog).toHaveBeenCalledTimes(1);
+ });
+
+ it('shares one fetch across two mounted callers', async () => {
+ const { result: a } = renderHook(() => useProviderCatalog());
+ const { result: b } = renderHook(() => useProviderCatalog());
+ await waitFor(() => expect(a.current.loading).toBe(false));
+ await waitFor(() => expect(b.current.loading).toBe(false));
+ expect(api.getProviderCatalog).toHaveBeenCalledTimes(1);
+ });
+
+ it('compatiblePairs narrows services to the harness compatibility map', async () => {
+ const { result } = renderHook(() => useProviderCatalog());
+ await waitFor(() => expect(result.current.loading).toBe(false));
+ expect(result.current.compatiblePairs('pi').map((s) => s.slug)).toEqual(['nvidia-nim-free']);
+ expect(result.current.compatiblePairs('claude')).toEqual([]);
+ });
+
+ it('effortLevelsFor prefers a per-model ladder over the harness default', async () => {
+ api.getProviderCatalog.mockResolvedValue({
+ ...CATALOG,
+ effortLevelsByModel: { pi: { 'nvidia/example': ['low', 'medium'] }, claude: {} },
+ });
+ const { result } = renderHook(() => useProviderCatalog());
+ await waitFor(() => expect(result.current.loading).toBe(false));
+ expect(result.current.effortLevelsFor('pi', 'nvidia/example')).toEqual(['low', 'medium']);
+ expect(result.current.effortLevelsFor('pi', 'some-other-model')).toEqual(CATALOG.effortLevels.pi);
+ });
+
+ describe('resolveRef', () => {
+ it('resolves a preset id to its stored record', async () => {
+ const { result } = renderHook(() => useProviderCatalog());
+ await waitFor(() => expect(result.current.loading).toBe(false));
+ expect(result.current.resolveRef('claude-code')).toEqual(CATALOG.presets[0]);
+ });
+
+ it('synthesizes a display record for a composite id, naming the free plan', async () => {
+ const { result } = renderHook(() => useProviderCatalog());
+ await waitFor(() => expect(result.current.loading).toBe(false));
+ const ref = result.current.resolveRef('pi.tui@nvidia-nim-free');
+ expect(ref).toMatchObject({
+ id: 'pi.tui@nvidia-nim-free',
+ name: 'Pi · TUI · NVIDIA NIM (free)',
+ harnessId: 'pi',
+ method: 'tui',
+ serviceSlug: 'nvidia-nim-free',
+ bootstrapId: null,
+ composite: true,
+ enabled: true,
+ });
+ expect(ref.models).toEqual(['nvidia/example']);
+ });
+
+ it('returns null for a composite naming a service this catalog does not know', async () => {
+ const { result } = renderHook(() => useProviderCatalog());
+ await waitFor(() => expect(result.current.loading).toBe(false));
+ expect(result.current.resolveRef('pi.tui@unknown-service')).toBeNull();
+ });
+
+ it('returns null for neither grammar and for a nullish id', async () => {
+ const { result } = renderHook(() => useProviderCatalog());
+ await waitFor(() => expect(result.current.loading).toBe(false));
+ expect(result.current.resolveRef('')).toBeNull();
+ expect(result.current.resolveRef('not a valid ref!!')).toBeNull();
+ });
+ });
+
+ it('savePreset delegates to createProviderPreset', async () => {
+ api.createProviderPreset.mockResolvedValue({ id: 'pi-tui-nvidia-nim-free' });
+ const { result } = renderHook(() => useProviderCatalog());
+ await waitFor(() => expect(result.current.loading).toBe(false));
+ let created;
+ await act(async () => {
+ created = await result.current.savePreset({ compositeId: 'pi.tui@nvidia-nim-free', name: 'Pi NIM' });
+ });
+ expect(api.createProviderPreset).toHaveBeenCalledWith({ compositeId: 'pi.tui@nvidia-nim-free', name: 'Pi NIM' });
+ expect(created).toEqual({ id: 'pi-tui-nvidia-nim-free' });
+ });
+
+ it('retries after a failed fetch on the next mount', async () => {
+ api.getProviderCatalog.mockRejectedValueOnce(new Error('offline'));
+ const first = renderHook(() => useProviderCatalog());
+ await waitFor(() => expect(first.result.current.loading).toBe(false));
+ expect(first.result.current.harnesses).toEqual([]);
+
+ api.getProviderCatalog.mockResolvedValueOnce(CATALOG);
+ const second = renderHook(() => useProviderCatalog());
+ await waitFor(() => expect(second.result.current.loading).toBe(false));
+ expect(second.result.current.harnesses).toHaveLength(2);
+ });
+});
diff --git a/client/src/services/README.md b/client/src/services/README.md
index c83077a85e..0b5749c13d 100644
--- a/client/src/services/README.md
+++ b/client/src/services/README.md
@@ -53,7 +53,7 @@ toasts on throw). **Custom catch ⇒ `silent: true`** — otherwise toasts fire
| `apiPorts.js` | Port scan/detect wrappers (no current UI callers; module kept for the catalog). |
| `apiHarnesses.js` | Coding-agent harness (CLI/TUI) inventory for Models → Harnesses: installed vs latest version, the providers riding on each, and the model-catalog refresh. Install/update/remove is an SSE stream driven by `RuntimeInstallModal`, not a call here. |
| `apiModelComparison.js` | Sourced model comparison catalog, provider discovery and validated observation import. |
-| `apiProviders.js` | AI provider configuration, plus provider-runtime (CLI) install readiness for the per-card Install buttons, and the Codex / ChatGPT-subscription account calls (`getCodexAccount`, `startCodexLogin`, `cancelCodexLogin`, `codexLogout`) — sign-in STATE only, never a token. Also the connection-graph management calls, including `createProviderConnection` / `createProviderBinding`, which add a backend and mint its (disabled) executable routes. |
+| `apiProviders.js` | AI provider configuration, plus provider-runtime (CLI) install readiness for the per-card Install buttons, and the Codex / ChatGPT-subscription account calls (`getCodexAccount`, `startCodexLogin`, `cancelCodexLogin`, `codexLogout`) — sign-in STATE only, never a token. Also the connection-graph management calls, including `createProviderConnection` / `createProviderBinding`, which add a backend and mint its (disabled) executable routes. `getProviderCatalog` (`GET /providers/catalog`, #7566) is the composition surface `useProviderCatalog` fetches; `createProviderPreset` (`POST /providers/presets`) is the compose popover's "Save as preset". |
| `apiPrompts.js` | Prompt Manager: stage templates, variables, and job-skill templates (providers list reuses `apiProviders.getProviders`). |
| `apiReferenceRepos.js` | Per-app reference-repo registry. |
| `apiReview.js` | Review hub. |
diff --git a/client/src/services/apiProviders.js b/client/src/services/apiProviders.js
index c45e9c8e75..72839836f6 100644
--- a/client/src/services/apiProviders.js
+++ b/client/src/services/apiProviders.js
@@ -28,14 +28,29 @@ export const addProviderTuiMode = (id, options = {}) => request(`/providers/${id
...options,
});
export const getSampleProviders = () => request('/providers/samples');
+// The composition catalog (#7564/#7566): harnesses with enablement, service
+// instances, bootstrap apps, per-harness (and per-model) effort ladders, the
+// harness/service compatibility map, and the sanitized presets — everything
+// `useProviderCatalog` composes a preset-first picker and the compose popover
+// over. `GET /providers` above stays presets-only for every existing
+// `useProviderModels` consumer.
+export const getProviderCatalog = (options) => request('/providers/catalog', options);
// Presets (#7565): "Convert to derived preset" stamps a legacy record with the
// service it already runs on — refused (409) when re-deriving it would change
-// how it runs. ("Save as preset", `POST /providers/presets`, gets its wrapper
-// with the compose popover that calls it, #7566.)
+// how it runs.
export const deriveProviderPreset = (id, options = {}) => request(`/providers/${encodeURIComponent(id)}/derive`, {
method: 'POST',
...options,
});
+// "Save as preset" (#7565/#7566): the compose popover's own wrapper — turn the
+// composite id (plus the model/effort the user picked while composing) into a
+// stored, enabled derived preset. A 400 names the composite's own ineligibility
+// code/reason; never a stored record that cannot run.
+export const createProviderPreset = (body, options) => request('/providers/presets', {
+ method: 'POST',
+ body: JSON.stringify(body),
+ ...options,
+});
export const testProvider = (id) => request(`/providers/${id}/test`, { method: 'POST' });
export const refreshProviderModels = (id, options) => request(`/providers/${id}/refresh-models`, { method: 'POST', ...options });
// Stored model pins naming a model their provider no longer lists (#7315).
diff --git a/client/src/utils/README.md b/client/src/utils/README.md
index ff4ef033ea..1c967baeb1 100644
--- a/client/src/utils/README.md
+++ b/client/src/utils/README.md
@@ -56,6 +56,7 @@ is where each shared table is re-exported from its `server/lib` leaf.
| `providers` | Compatibility facade re-exporting every helper from the nine modules below, so existing `../utils/providers` imports keep working. New code imports the declaring module. |
| `providerTypes` | What KIND of provider a record is: `PROVIDER_TYPES` (re-exported from `server/lib/aiToolkit/constants.js`) with `isCliProvider` / `isTuiProvider` / `isApiProvider` / `isProcessProvider` and `isClaudeHarnessProvider` (re-exported from `server/lib/providerTypes.js`, with legacy alias `isClaudeCommandProvider`), `isLaunchableTuiProvider` (a TUI provider carrying the server-resolved `tuiCommandLine`, i.e. one a human can start at a shell prompt — shared by the Providers card's "Launch in Shell" button and the Shell page's launch menu so the two can't disagree), `enabledApiProviderFilter`, `enabledProcessProviderFilter` (the coding/CLI-TUI-only counterpart, for a manual Claim/Replan/Resolve/Review "Run with" picker), `providerTypeClass`; the vendor-harness predicates keyed on the shipped ids plus `commandBasename` so a path-configured or renamed binary still qualifies (`isCodexProvider`, `isCodexSubscriptionProvider` — subscription readiness is keyed on the `codex` command, never an editable id — `isAntigravityProvider`, `isCursorProvider`, `isKimiProvider`, `isGrokProvider`, `isGrokBuildCli`, `isClaudeCommandProvider`, `isOpencodeLocalProvider`); and the structural backend markers a wrapper carries (`localRuntimeNamespace`, `isOllamaBackedProvider`). Everything with a server twin is re-exported from the pure leaves `server/lib/providerTypes.js`, `server/lib/providerModels.js`, `server/lib/aiToolkit/constants.js` and `server/lib/aiToolkit/internal/ollamaBacked.js`, never copied — `isGrokBuildCli` moved there in #7339 so the shared reviewer→provider matcher table keys on the same predicate the browser does. |
| `providerGateways` | `PROVIDER_GATEWAYS` / `gatewayById` / `gatewayForProvider` / `isGatewayBackedProvider` — the hosted OpenAI-compatible gateways (`orcarouter`, `openrouter`, `nvidia-nim`) an OpenCode CLI/TUI wrapper can front-end, inheriting its API key at spawn time from the sibling API provider whose id equals the gateway id. Reads the generic `gatewayBacked` marker and, forever, the legacy per-gateway boolean. Rows with a stable vendor key page also carry `keyUrl`, rendered as the card's "get a key" link while the key is missing. All four are re-exported from the pure leaf `server/lib/providerGateways.js`. |
+| `providerRef` | `parseProviderRef(id)` / `PRESET_ID_RE` / `COMPOSITE_ID_RE` — the shared preset-vs-composite grammar (#7566): distinguishes a preset id from a `<harness>.<method>@<service-slug>[+<bootstrap-slug>]` composite so `useProviderCatalog`'s `resolveRef` and `ProviderComposePopover` recognize the same strings the server does. Re-exported from the pure leaf `server/lib/providerRef.js`, never copied. |
| `providerHarnesses` | `harnessLabel(harnessId)` — the display name for an agent program PortOS drives (Claude Code, OpenCode, Codex, …), used by the connection-management UI, where `null` means Direct API and an unknown id renders verbatim rather than disappearing. Read through `harnessById` from the pure leaf `server/lib/providerHarnesses.js`, so a harness added to the registry is named here without a second edit. |
| `providerEndpoints` | WHERE a provider's endpoint points. `isLocalEndpoint` (loopback), `isPrivateNetworkEndpoint` (RFC1918 / tailnet address, or a `.local` / `.ts.net` / single-label host — somewhere an unauthenticated OpenAI-compatible server is a normal setup rather than a missing API key), `isLocalInstanceProvider` (talks to a daemon on THIS machine; mirror of `server/lib/localProviderRuntime.js#isLocalInstanceEndpoint` — gate anything that explains a provider by inspecting the host PortOS runs on), `isFleetProvider` / `isFleetHostConfigured` (another machine inside the private network), and `localBackendForProvider` (`'ollama'` / `'lmstudio'` / `null` by id, endpoint or name — it matches by NAME, so pair it with `isLocalInstanceProvider` before claiming this machine's install state). |
| `providerModels` | Which MODEL and EFFORT a run resolves to, and what a picker may list. The configured-default sentinels (`CODEX_CONFIGURED_DEFAULT` …, `isConfiguredDefaultModel`, `configuredDefaultIn` — so a picker can render an option matching a sentinel-valued tier instead of a blank select) and `filterSelectableModels`; the per-CLI effort ladders, `effortLevelsForProvider`, `resolveCliEffort` (what a stored effort actually runs as, so the picker can name a clamped level), `effortSurvivingModel` and `seedModelEffort`; the Antigravity base-model ↔ effort-suffix split (`splitAntigravityModel`, `antigravityBaseModels`, `antigravityModelEffortLevels`, `withStaleAntigravityPin`); the account-aware option list (`providerModelList`, `resolveProviderModelOptions`, `effortAwareModelOptions`, `MODEL_SOURCE` — the one place a Codex-subscription account catalog enters a picker); `effectiveModelFor`; `mergeModelLists` / `mergeProviderUpdate`; and `generationControlsFor` (which temperature / top-p / thinking controls a provider forwards at all). The sentinels, effort ladders and the Antigravity split are re-exported from the pure leaf `server/lib/providerModels.js`; `effortLevelsForProvider` / `resolveCliEffort` delegate to the server's and add the ladder a sanitized provider inventory publishes, clamped through the server's `clampEffortToLadder`. The generation-control tables still mirror `server/lib/opencodeConfig.js`. |
diff --git a/client/src/utils/index.js b/client/src/utils/index.js
index 80e38976a0..d65e9a65e6 100644
--- a/client/src/utils/index.js
+++ b/client/src/utils/index.js
@@ -42,6 +42,7 @@ export * from './providerGateways.js';
export * from './providerHarnesses.js';
export * from './providerModels.js';
export * from './providerReadiness.js';
+export * from './providerRef.js';
export * from './providerSelection.js';
export * from './providerTypes.js';
export * from './providers.js';
diff --git a/client/src/utils/providerRef.js b/client/src/utils/providerRef.js
new file mode 100644
index 0000000000..95edbef10f
--- /dev/null
+++ b/client/src/utils/providerRef.js
@@ -0,0 +1,13 @@
+/**
+ * Provider REFERENCE grammar (#7564, epic #7561), shared with the server.
+ *
+ * A `{ providerId, model, effort }` selection names its provider either by a
+ * PRESET id (a `data/providers.json` slug) or by a COMPOSITE id —
+ * `<harness>.<method>@<service-slug>[+<bootstrap-slug>]` — that
+ * `useProviderCatalog`'s `resolveRef` synthesizes a display record for and
+ * `ProviderComposePopover` emits when the user composes rather than picks a
+ * preset. Re-exported from the pure server leaf (never copied) so the browser
+ * recognizes exactly the same strings the server does — see
+ * `server/lib/providerRef.js` for the full grammar rationale.
+ */
+export { parseProviderRef, PRESET_ID_RE, COMPOSITE_ID_RE } from '../../../server/lib/providerRef.js';