Download packages/app/src/hooks/provider-catalog.ts from SaylorTwift/opencode: direct link, hf CLI and curl.
- Browser
- Download file 1.07 kB
-
https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/app/src/hooks/provider-catalog.ts
- Command line
-
hf download hf://SaylorTwift/opencode/packages/app/src/hooks/provider-catalog.ts
-
curl -L -o provider-catalog.ts https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/app/src/hooks/provider-catalog.ts
1.07 kB
| import type { NormalizedProviderListResponse } from "@opencode-ai/session-ui/context" | |
| const emptyProviderCatalog: NormalizedProviderListResponse = { all: new Map(), connected: [], default: {} } | |
| type DirectoryCatalog = { | |
| ready: boolean | |
| providers: NormalizedProviderListResponse | |
| } | |
| type ProviderCatalogInput = | |
| | { | |
| explicit: true | |
| directory?: string | |
| catalog?: DirectoryCatalog | |
| } | |
| | { | |
| explicit: false | |
| directory?: string | |
| catalog?: DirectoryCatalog | |
| global: NormalizedProviderListResponse | |
| } | |
| export function selectProviderCatalog(input: ProviderCatalogInput) { | |
| if (input.directory && input.catalog?.ready) return input.catalog.providers | |
| if (input.explicit) return emptyProviderCatalog | |
| return input.global | |
| } | |
| export function resolveDefaultModel( | |
| current: NormalizedProviderListResponse["defaultModel"], | |
| legacy: string | undefined, | |
| ) { | |
| if (current !== undefined) return current ?? undefined | |
| if (!legacy) return undefined | |
| const [providerID, modelID] = legacy.split("/") | |
| return { providerID, modelID } | |
| } | |