MCPcopy Create free account
hub / github.com/tiann/hapi / normalizeAvailableModels

Function normalizeAvailableModels

cli/src/modules/common/opencodeModels.ts:23–34  ·  view source on GitHub ↗
(rawModels: unknown)

Source from the content-addressed store, hash-verified

21const inflight = new Map<string, Promise<ListOpencodeModelsForCwdResponse>>();
22
23function normalizeAvailableModels(rawModels: unknown): OpencodeModelSummary[] {
24 if (!Array.isArray(rawModels)) return [];
25 const out: OpencodeModelSummary[] = [];
26 for (const entry of rawModels) {
27 if (!isObject(entry)) continue;
28 const modelId = asString(entry.modelId) ?? asString(entry.value);
29 if (!modelId) continue;
30 const name = asString(entry.name) ?? undefined;
31 out.push(name ? { modelId, name } : { modelId });
32 }
33 return out;
34}
35
36function extractModelConfigOption(response: Record<string, unknown>): {
37 currentValue: string | null;

Callers 1

Calls 3

isObjectFunction · 0.85
asStringFunction · 0.50
pushMethod · 0.45

Tested by

no test coverage detected