refactor(shared): split model-availability.ts into model resolution modules
Extract model availability checking pipeline: - available-models-fetcher.ts: top-level model fetching orchestration - model-cache-availability.ts, models-json-cache-reader.ts - provider-models-cache-model-reader.ts: provider cache reading with null guard - fallback-model-availability.ts, model-name-matcher.ts - open-code-client-accessors.ts, open-code-client-shapes.ts - record-type-guard.ts
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import type { ModelListFunction, ProviderListFunction } from "./open-code-client-shapes"
|
||||
import { isRecord } from "./record-type-guard"
|
||||
|
||||
export function getProviderListFunction(client: unknown): ProviderListFunction | null {
|
||||
if (!isRecord(client)) return null
|
||||
const provider = client["provider"]
|
||||
if (!isRecord(provider)) return null
|
||||
const list = provider["list"]
|
||||
if (typeof list !== "function") return null
|
||||
return list as ProviderListFunction
|
||||
}
|
||||
|
||||
export function getModelListFunction(client: unknown): ModelListFunction | null {
|
||||
if (!isRecord(client)) return null
|
||||
const model = client["model"]
|
||||
if (!isRecord(model)) return null
|
||||
const list = model["list"]
|
||||
if (typeof list !== "function") return null
|
||||
return list as ModelListFunction
|
||||
}
|
||||
Reference in New Issue
Block a user