feat: add model scan progress callbacks

This commit is contained in:
Peter Steinberger
2026-01-08 05:20:01 +01:00
parent 28cd2e4c24
commit 2287d32263
3 changed files with 64 additions and 12 deletions

View File

@@ -4,6 +4,7 @@ import {
type ModelScanResult,
scanOpenRouterModels,
} from "../../agents/model-scan.js";
import { withProgress } from "../../cli/progress.js";
import { CONFIG_PATH_CLAWDBOT, loadConfig } from "../../config/config.js";
import type { RuntimeEnv } from "../../runtime.js";
import { formatMs, formatTokenK, updateConfig } from "./shared.js";
@@ -188,15 +189,30 @@ export async function modelsScanCommand(
storedKey = undefined;
}
}
const results = await scanOpenRouterModels({
apiKey: storedKey ?? undefined,
minParamB: minParams,
maxAgeDays,
providerFilter: opts.provider,
timeoutMs: timeout,
concurrency,
probe,
});
const results = await withProgress(
{
label: "Scanning OpenRouter models...",
indeterminate: false,
enabled: opts.json !== true,
},
async (progress) =>
await scanOpenRouterModels({
apiKey: storedKey ?? undefined,
minParamB: minParams,
maxAgeDays,
providerFilter: opts.provider,
timeoutMs: timeout,
concurrency,
probe,
onProgress: ({ phase, completed, total }) => {
if (phase !== "probe") return;
if (total <= 0) return;
const labelBase = probe ? "Probing models" : "Scanning models";
progress.setLabel(`${labelBase} (${completed}/${total})`);
progress.setPercent((completed / total) * 100);
},
}),
);
if (!probe) {
if (!opts.json) {