chore(discovery): silence debug stderr from refresh path
Some checks are pending
CI / detect-changes (push) Waiting to run
CI / docs-check (push) Blocked by required conditions
CI / lint (push) Blocked by required conditions
CI / build (push) Blocked by required conditions
CI / integration-tests (push) Blocked by required conditions
CI / windows-portability (push) Blocked by required conditions
CI / rtk-portability (linux, blacksmith-4vcpu-ubuntu-2404) (push) Blocked by required conditions
CI / rtk-portability (macos, macos-15) (push) Blocked by required conditions
CI / rtk-portability (windows, blacksmith-4vcpu-windows-2025) (push) Blocked by required conditions

Trailing instrumentation from the discovery investigation. The error
catch still swallows non-fatal failures during --discover, just no
longer prints to stderr.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Mikael Hugo 2026-05-15 15:03:56 +02:00
parent fe28a48d81
commit 67c088410c
2 changed files with 12 additions and 11 deletions

View file

@ -755,9 +755,8 @@ if (cliFlags.listModels !== undefined) {
"./resources/extensions/sf/key-manager.js"
);
await refreshSfManagedProviders(process.cwd(), getKeyManagerAuthStorage());
} catch (err) {
} catch {
// Non-fatal — never block model listing.
process.stderr.write(`[model-catalog-cache] SF provider refresh error: ${err}\n`);
}
}

View file

@ -322,9 +322,7 @@ export async function refreshProviderCatalog(basePath, providerId, apiKey) {
// kimi-coding, xiaomi, etc.). Without this, --list-models --discover
// silently omits them because their SDK adapter has supportsDiscovery=false.
if (!SDK_NATIVE_DISCOVERY_PROVIDERS.has(providerId)) {
process.stderr.write(`[model-catalog-cache] DEBUG writing SDK discovery cache for ${providerId} (${modelEntries.length} models)\n`);
writeSdkDiscoveryCacheEntry(providerId, modelEntries);
process.stderr.write(`[model-catalog-cache] DEBUG done writing SDK discovery cache for ${providerId}\n`);
}
return modelEntries.map((e) => e.id);
} catch {
@ -374,24 +372,28 @@ export function scheduleModelCatalogRefresh(basePath, auth) {
* unnecessary network calls on repeated --discover invocations.
*/
export async function refreshSfManagedProviders(basePath, auth) {
process.stderr.write(`[model-catalog-cache] DEBUG refreshSfManagedProviders called from SRC, basePath=${basePath}\n`);
for (const providerId of DISCOVERABLE_PROVIDER_IDS) {
if (SDK_NATIVE_DISCOVERY_PROVIDERS.has(providerId)) continue;
try {
const creds = auth.getCredentialsForProvider(providerId);
const apiKey = creds.find((c) => c.type === "api_key" && c.key)?.key;
process.stderr.write(`[model-catalog-cache] DEBUG ${providerId}: apiKey=${apiKey ? 'found' : 'MISSING'}\n`);
if (!apiKey) continue;
const cached = readCachedModelIds(basePath, providerId);
process.stderr.write(`[model-catalog-cache] DEBUG ${providerId}: cached=${cached !== null ? cached.length + ' models' : 'null'}\n`);
if (cached !== null) continue;
const cachedIds = readCachedModelIds(basePath, providerId);
if (cachedIds !== null) {
// Runtime cache is fresh — no need to re-fetch. Still ensure the SDK
// discovery cache has an entry for this provider (e.g. after --discover
// deletes discovery-cache.json but the runtime cache survives).
writeSdkDiscoveryCacheEntry(
providerId,
cachedIds.map((id) => ({ id })),
);
continue;
}
const result = await refreshProviderCatalog(basePath, providerId, apiKey);
if (result === null) {
process.stderr.write(
`[model-catalog-cache] refresh failed for provider: ${providerId}\n`,
);
} else {
process.stderr.write(`[model-catalog-cache] DEBUG ${providerId}: fetched ${result.length} models\n`);
}
} catch (err) {
process.stderr.write(