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

fix: keep bound-route catalog fallback for harnesses without a lister (#8497)

[._.]/ Adam Eivy85dbd5cce033
diff --git a/server/routes/providers.services.test.js b/server/routes/providers.services.test.js
index 6f00e3827a..34ff6214d2 100644
--- a/server/routes/providers.services.test.js
+++ b/server/routes/providers.services.test.js
@@ -306,22 +306,22 @@ describe('POST /api/providers/services/:slug/refresh-catalog', () => {
});
// Codex's row now has its own lister (`listModels`, driving `codex
- // app-server` — services/harnesses.js #8497), so `listByHarness` no longer
- // falls back to a bound route's toolkit lister for a harness that refuses
- // with `noLister`. A harness with no lister at all just fails, as any other
- // refusal does.
- it('does not fall back to a bound route\'s own lister when the harness has no models command', async () => {
+ // app-server` — services/harnesses.js #8497) and no longer needs this
+ // fallback. But Claude Code still has neither `modelsArgs` nor `listModels`
+ // — its catalog is read from a per-record on-disk cache, only reachable
+ // through a bound route's own toolkit lister — so `listByHarness` still
+ // falls back to one when the harness itself refuses with `noLister`.
+ it('falls back to a bound route\'s own lister when the harness has no models command', async () => {
const withRoute = graphFixture();
withRoute.bindings.push({ id: '99999999-9999-4999-8999-999999999999', revision: 1, connectionId: CLAUDE_SUB, harnessId: 'claude', variantKey: 'default', label: 'Claude', enabled: true, selectedModels: [] });
withRoute.routes.push({ providerId: 'example-claude-tui', bindingId: '99999999-9999-4999-8999-999999999999' });
store.readGraph.mockResolvedValue(withRoute);
harnessModels.mockResolvedValue({ ok: false, reason: 'Claude Code has no command for listing its models.', noLister: true, models: [], updated: [] });
+ providerService.fetchProviderModels.mockResolvedValue(['claude-new', 'claude-example']);
const res = await request(app()).post('/api/providers/services/claude-subscription/refresh-catalog');
- expect(providerService.fetchProviderModels).not.toHaveBeenCalled();
- expect(res.body.service.catalog).toMatchObject({
- state: 'failed', models: ['claude-example'], error: 'Claude Code has no command for listing its models.',
- });
+ expect(providerService.fetchProviderModels).toHaveBeenCalledWith('example-claude-tui');
+ expect(res.body.service.catalog).toMatchObject({ state: 'known', models: ['claude-new', 'claude-example'] });
});
it('refreshes a derived preset through its service catalog, never onto the record alone', async () => {
diff --git a/server/services/providerServices.js b/server/services/providerServices.js
index acf46ac961..6bd711ffe3 100644
--- a/server/services/providerServices.js
+++ b/server/services/providerServices.js
@@ -12,9 +12,11 @@ import {
takenServiceSlugs,
toServiceDto,
} from '../lib/providerServiceInstances.js';
+import { requireToolkit } from '../lib/aiToolkitState.js';
import { isNonBlankStr } from '../lib/textUtils.js';
import { resolveServiceInstance, serviceDefinitionById } from '../lib/serviceDefinitions.js';
import {
+ connectionFanout,
findConnectionByRef,
rematerializeDerivedPresets,
requireProviderGraph,
@@ -80,19 +82,30 @@ async function listByProbe(connection, definition, { env, probe }) {
/**
* Ask the program that signs in. `ok: false` — an uninstalled binary, a
- * signed-out CLI, a refused probe, a harness with no lister — is a failure
- * with its reason, never an empty catalog: `refreshHarnessModels` already
- * refuses to report a blank listing as "zero models", and this keeps that
- * refusal.
+ * signed-out CLI, a refused probe — is a failure with its reason, never an
+ * empty catalog: `refreshHarnessModels` already refuses to report a blank
+ * listing as "zero models", and this keeps that refusal.
*
- * Every `catalog.strategy: 'harness'` definition now names a harness that can
- * actually enumerate its own models (`modelsArgs` or the JSON-RPC `listModels`
- * hook Codex uses — `services/harnesses.js`, #8497); there is no longer a
- * bound-route fallback to a toolkit lister for one that cannot.
+ * Codex now has its own lister (`listModels`, driving `codex app-server`'s
+ * JSON-RPC handshake — `services/harnesses.js`, #8497) and no longer needs
+ * this fallback. But it is NOT the only harness `refreshHarnessModels` refuses
+ * with `noLister`: Claude Code (`claude-subscription`) still has neither
+ * `modelsArgs` nor a `listModels` hook — its catalog is read from a per-record
+ * on-disk cache the toolkit already knows how to fetch through a BOUND route
+ * (`fetchProviderModels` → `_fetchAnthropicModels`), never from the harness
+ * binary directly. Dropping the fallback entirely would make
+ * `claude-subscription`'s catalog refresh fail outright even though a working
+ * route sits right there, so a harness that refuses with `noLister` still
+ * falls back to a bound route's own lister — that catalog can still update.
+ * Any other refusal (not installed, signed out, empty probe) stays a refusal.
*/
-async function listByHarness(definition, { harnessModels }) {
+async function listByHarness(connection, definition, graph, { harnessModels, routeModels }) {
const result = await harnessModels(definition.harnessOnly);
if (result?.ok) return { refreshed: true, models: result.models || [] };
+ for (const route of result?.noLister ? connectionFanout(graph, connection.id).routes : []) {
+ const models = await routeModels(route.providerId).catch(() => null);
+ if (Array.isArray(models) && models.length > 0) return { refreshed: true, models };
+ }
return { refreshed: false, error: result?.reason || `${definition.label} could not list its models` };
}
@@ -101,13 +114,13 @@ async function listByHarness(definition, { harnessModels }) {
* has nothing to ask: the instance's declared list IS the catalog, re-stamped
* as known.
*/
-async function listByStrategy(connection, definition, deps) {
+async function listByStrategy(connection, definition, graph, deps) {
switch (definition.catalog.strategy) {
case 'probe':
case 'daemon':
return listByProbe(connection, definition, deps);
case 'harness':
- return listByHarness(definition, deps);
+ return listByHarness(connection, definition, graph, deps);
case 'static':
return { refreshed: true, models: connection.catalog?.models || [] };
default:
@@ -127,6 +140,8 @@ const defaultDeps = () => ({
const runtime = PROVIDER_RUNTIMES.find((row) => row.vendor === harnessId || row.id === harnessId)?.id ?? harnessId;
return refreshHarnessModels(runtime);
},
+ // Probe-only: the answer lands in the instance catalog, never on the record.
+ routeModels: (providerId) => requireToolkit().services.providers.fetchProviderModels(providerId),
now: () => new Date().toISOString(),
});
@@ -239,7 +254,7 @@ export async function updateService(ref, input) {
* route model list is touched.
*/
export function refreshServiceCatalog(ref, deps = {}) {
- const { env, probe, harnessModels, now } = { ...defaultDeps(), ...deps };
+ const { env, probe, harnessModels, routeModels, now } = { ...defaultDeps(), ...deps };
return serializeProviderGraph(async () => {
requireProviderGraph();
const [graph, envFile] = await Promise.all([readGraph(), loadInstallEnvFile()]);
@@ -250,7 +265,7 @@ export function refreshServiceCatalog(ref, deps = {}) {
{ status: 409, code: 'SERVICE_DEFINITION_UNKNOWN' });
}
- const outcome = await listByStrategy(connection, definition, { env, probe, harnessModels })
+ const outcome = await listByStrategy(connection, definition, graph, { env, probe, harnessModels, routeModels })
.catch((err) => ({ refreshed: false, error: err }));
const catalog = nextConnectionCatalog(connection.catalog, {
...outcome,