MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / fetchCatalog

Function fetchCatalog

packages/node-sdk/src/catalog.ts:27–41  ·  view source on GitHub ↗
(
  url: string,
  signal?: AbortSignal,
  fetchImpl: typeof fetch = fetch,
)

Source from the content-addressed store, hash-verified

25
26/** Fetches a models.dev-style catalog. Public endpoint, no credentials needed. */
27export async function fetchCatalog(
28 url: string,
29 signal?: AbortSignal,
30 fetchImpl: typeof fetch = fetch,
31): Promise<Catalog> {
32 const res = await fetchImpl(url, { headers: { Accept: 'application/json' }, signal });
33 if (!res.ok) {
34 throw new CatalogFetchError(`Failed to fetch catalog (HTTP ${res.status}).`, res.status);
35 }
36 const payload: unknown = await res.json();
37 if (typeof payload !== 'object' || payload === null || Array.isArray(payload)) {
38 throw new Error(`Unexpected catalog response from ${url}.`);
39 }
40 return payload as Catalog;
41}
42
43function capabilityToStrings(capability: ModelCapability): string[] | undefined {
44 const caps: string[] = [];

Callers 1

catalog.test.tsFile · 0.90

Calls 1

jsonMethod · 0.80

Tested by

no test coverage detected