@agentskit/adapters 0.12.2 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/catalog/index.cjs +153745 -0
- package/dist/catalog/index.cjs.map +1 -0
- package/dist/catalog/index.d.cts +205 -0
- package/dist/catalog/index.d.ts +205 -0
- package/dist/catalog/index.js +153479 -0
- package/dist/catalog/index.js.map +1 -0
- package/dist/chunk-6FPLWOVE.js +26 -0
- package/dist/chunk-6FPLWOVE.js.map +1 -0
- package/dist/chunk-726IKNNR.js +486 -0
- package/dist/chunk-726IKNNR.js.map +1 -0
- package/dist/createAdapter-Dfnf3Iio.d.cts +14 -0
- package/dist/createAdapter-Dfnf3Iio.d.ts +14 -0
- package/dist/createAdapter.cjs +28 -0
- package/dist/createAdapter.cjs.map +1 -0
- package/dist/createAdapter.d.cts +2 -0
- package/dist/createAdapter.d.ts +2 -0
- package/dist/createAdapter.js +3 -0
- package/dist/createAdapter.js.map +1 -0
- package/dist/index.cjs +212 -35
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +202 -77
- package/dist/index.d.ts +202 -77
- package/dist/index.js +193 -527
- package/dist/index.js.map +1 -1
- package/dist/utils-ddwu4MN4.d.cts +66 -0
- package/dist/utils-ddwu4MN4.d.ts +66 -0
- package/package.json +19 -6
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { JSONSchema7 } from 'json-schema';
|
|
2
|
+
import { AdapterFactory } from '@agentskit/core';
|
|
3
|
+
import { R as RetryOptions } from '../utils-ddwu4MN4.cjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* AgentsKit provider/model catalog — normalized metadata adapted from the
|
|
7
|
+
* `models.dev` data source into our own schema. This is the canonical shape;
|
|
8
|
+
* `models.dev` is an input, never a runtime dependency (see {@link CatalogSnapshot.source}).
|
|
9
|
+
*/
|
|
10
|
+
/** Input/output modalities a model accepts/produces. */
|
|
11
|
+
interface CatalogModalities {
|
|
12
|
+
input: string[];
|
|
13
|
+
output: string[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Per-token cost in USD per 1M tokens. Advisory metadata only — it is cached at
|
|
17
|
+
* snapshot time and drifts between regenerations, so never treat it as a hard
|
|
18
|
+
* contract for billing.
|
|
19
|
+
*/
|
|
20
|
+
interface CatalogModelCost {
|
|
21
|
+
input?: number;
|
|
22
|
+
output?: number;
|
|
23
|
+
cacheRead?: number;
|
|
24
|
+
cacheWrite?: number;
|
|
25
|
+
}
|
|
26
|
+
/** Context / output token ceilings. */
|
|
27
|
+
interface CatalogModelLimit {
|
|
28
|
+
context?: number;
|
|
29
|
+
output?: number;
|
|
30
|
+
}
|
|
31
|
+
/** A single model entry within a provider. */
|
|
32
|
+
interface CatalogModel {
|
|
33
|
+
id: string;
|
|
34
|
+
name: string;
|
|
35
|
+
family?: string;
|
|
36
|
+
limit?: CatalogModelLimit;
|
|
37
|
+
cost?: CatalogModelCost;
|
|
38
|
+
modalities?: CatalogModalities;
|
|
39
|
+
/** Capability flags — consult these instead of assuming "openai-compatible = works". */
|
|
40
|
+
toolCall: boolean;
|
|
41
|
+
structuredOutput: boolean;
|
|
42
|
+
reasoning: boolean;
|
|
43
|
+
attachment: boolean;
|
|
44
|
+
openWeights: boolean;
|
|
45
|
+
/** ISO-ish knowledge cutoff (e.g. "2024-05"). */
|
|
46
|
+
knowledge?: string;
|
|
47
|
+
releaseDate?: string;
|
|
48
|
+
lastUpdated?: string;
|
|
49
|
+
deprecated?: boolean;
|
|
50
|
+
}
|
|
51
|
+
/** A provider and its models. */
|
|
52
|
+
interface CatalogProvider {
|
|
53
|
+
id: string;
|
|
54
|
+
name: string;
|
|
55
|
+
/** Environment variable names that hold this provider's API key. */
|
|
56
|
+
env: string[];
|
|
57
|
+
/** Default API base URL (when `models.dev` records one). */
|
|
58
|
+
baseUrl?: string;
|
|
59
|
+
doc?: string;
|
|
60
|
+
/**
|
|
61
|
+
* True when the provider exposes an OpenAI-compatible transport and can be
|
|
62
|
+
* dispatched via the native generic adapter rather than a bespoke factory.
|
|
63
|
+
*/
|
|
64
|
+
openaiCompatible: boolean;
|
|
65
|
+
models: CatalogModel[];
|
|
66
|
+
}
|
|
67
|
+
/** Provenance + freshness metadata for a generated snapshot. */
|
|
68
|
+
interface CatalogSource {
|
|
69
|
+
name: 'models.dev';
|
|
70
|
+
url: string;
|
|
71
|
+
/** Pinned upstream version/commit the snapshot was generated from. */
|
|
72
|
+
version: string;
|
|
73
|
+
}
|
|
74
|
+
/** The committed, schema-validated catalog artifact loaded at runtime. */
|
|
75
|
+
interface CatalogSnapshot {
|
|
76
|
+
schemaVersion: 1;
|
|
77
|
+
/** ISO timestamp the snapshot was generated (set by the sync tool). */
|
|
78
|
+
generatedAt: string;
|
|
79
|
+
source: CatalogSource;
|
|
80
|
+
providers: CatalogProvider[];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Canonical JSON Schema for the provider/model catalog snapshot. Public export.
|
|
85
|
+
*
|
|
86
|
+
* JSON Schema is the single source of truth for contracts across AgentsKit
|
|
87
|
+
* (core stays zero-dep; Zod is opt-in convenience only, never canonical). The
|
|
88
|
+
* snapshot is validated against this schema at build time via the opt-in Ajv
|
|
89
|
+
* path (`@agentskit/validation`), not at runtime.
|
|
90
|
+
*/
|
|
91
|
+
declare const catalogSnapshotSchema: JSONSchema7;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* The committed catalog snapshot. Imported as data — the runtime never fetches
|
|
95
|
+
* `models.dev`. Heavy (thousands of models), so this module is only reachable
|
|
96
|
+
* via the `@agentskit/adapters/catalog` subpath, keeping the main bundle lean.
|
|
97
|
+
*/
|
|
98
|
+
declare const catalog: CatalogSnapshot;
|
|
99
|
+
/** All providers in the snapshot. */
|
|
100
|
+
declare function listProviders(): CatalogProvider[];
|
|
101
|
+
/** Look up a provider by id (e.g. "openai", "deepseek"). */
|
|
102
|
+
declare function getProvider(id: string): CatalogProvider | undefined;
|
|
103
|
+
/** Look up a model within a provider. */
|
|
104
|
+
declare function getModel(providerId: string, modelId: string): CatalogModel | undefined;
|
|
105
|
+
/** Providers exposing an OpenAI-compatible transport (dispatchable natively). */
|
|
106
|
+
declare function listOpenAICompatibleProviders(): CatalogProvider[];
|
|
107
|
+
/** Snapshot freshness/provenance — surface this so consumers can reason about staleness. */
|
|
108
|
+
declare function catalogSource(): CatalogSnapshot['source'] & {
|
|
109
|
+
generatedAt: string;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Local policy layer so consumers can constrain the catalog without forking it
|
|
114
|
+
* (enterprise-approved providers/models, disabled providers, etc.).
|
|
115
|
+
*
|
|
116
|
+
* Precedence (most → least restrictive):
|
|
117
|
+
* 1. `disabledProviders` always removes a provider, even if allow-listed.
|
|
118
|
+
* 2. `allowedProviders`, when set, keeps only listed providers.
|
|
119
|
+
* 3. `allowedModels[providerId]`, when set, keeps only listed models for that provider.
|
|
120
|
+
*/
|
|
121
|
+
interface CatalogOverrides {
|
|
122
|
+
/** When set, only these provider ids survive. */
|
|
123
|
+
allowedProviders?: string[];
|
|
124
|
+
/** Always removed, takes precedence over `allowedProviders`. */
|
|
125
|
+
disabledProviders?: string[];
|
|
126
|
+
/** Per-provider model allow-list. Absent provider key = no model restriction. */
|
|
127
|
+
allowedModels?: Record<string, string[]>;
|
|
128
|
+
}
|
|
129
|
+
/** Return a new snapshot with policy applied. The input snapshot is not mutated. */
|
|
130
|
+
declare function applyOverrides(snapshot: CatalogSnapshot, overrides: CatalogOverrides): CatalogSnapshot;
|
|
131
|
+
|
|
132
|
+
interface CatalogDispatchConfig {
|
|
133
|
+
provider: string;
|
|
134
|
+
model: string;
|
|
135
|
+
apiKey: string;
|
|
136
|
+
/** Override the catalog base URL (e.g. proxy / self-hosted gateway). */
|
|
137
|
+
baseUrl?: string;
|
|
138
|
+
retry?: RetryOptions;
|
|
139
|
+
}
|
|
140
|
+
declare class CatalogDispatchError extends Error {
|
|
141
|
+
readonly code: 'UNKNOWN_PROVIDER' | 'NOT_OPENAI_COMPATIBLE' | 'NO_BASE_URL';
|
|
142
|
+
constructor(message: string, code: 'UNKNOWN_PROVIDER' | 'NOT_OPENAI_COMPATIBLE' | 'NO_BASE_URL');
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Build a native OpenAI-compatible adapter for a catalog provider/model. This is
|
|
146
|
+
* the generic dispatch path: any provider `models.dev` marks OpenAI-compatible
|
|
147
|
+
* lands here without bespoke per-provider code.
|
|
148
|
+
*
|
|
149
|
+
* First-class providers (anthropic/openai/gemini/ollama) keep their dedicated
|
|
150
|
+
* factories and are authoritative — do not route them through here.
|
|
151
|
+
*/
|
|
152
|
+
declare function dispatchFromCatalog(config: CatalogDispatchConfig): AdapterFactory;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Catalog-backed providers that ship dedicated first-class factories here. These
|
|
156
|
+
* are authoritative and intentionally NOT dispatched via the generic catalog path.
|
|
157
|
+
*
|
|
158
|
+
* `ollama` is also first-class but is deliberately excluded: it is local-only and
|
|
159
|
+
* absent from `models.dev`, so it must not be flagged as "missing from catalog".
|
|
160
|
+
*/
|
|
161
|
+
declare const FIRST_CLASS_PROVIDERS: readonly ["anthropic", "openai", "google"];
|
|
162
|
+
interface CatalogDriftReport {
|
|
163
|
+
/** Catalog providers that are neither first-class nor OpenAI-compatible — undispatchable. */
|
|
164
|
+
undispatchable: string[];
|
|
165
|
+
/** First-class provider ids with no matching catalog entry (rename/removal upstream). */
|
|
166
|
+
missingFromCatalog: string[];
|
|
167
|
+
/** True when every catalog provider can be dispatched and no first-class entry is missing. */
|
|
168
|
+
ok: boolean;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Drift check: every snapshot provider must map to a dispatchable adapter (first-class
|
|
172
|
+
* factory or native OpenAI-compatible) or be flagged. Run in CI so a regenerated
|
|
173
|
+
* snapshot that introduces an unroutable provider fails loudly instead of shipping silently.
|
|
174
|
+
*/
|
|
175
|
+
declare function detectCatalogDrift(providers?: CatalogProvider[]): CatalogDriftReport;
|
|
176
|
+
|
|
177
|
+
interface ResolveCostOptions {
|
|
178
|
+
/**
|
|
179
|
+
* Opt in to a live fetch. Default `false` keeps the runtime offline and
|
|
180
|
+
* deterministic (the issue's "no runtime fetch" default). When `true`, a live
|
|
181
|
+
* lookup is attempted and the cached snapshot is the guaranteed fallback.
|
|
182
|
+
*/
|
|
183
|
+
live?: boolean;
|
|
184
|
+
/** Abort the live fetch after this many ms (default 3000). */
|
|
185
|
+
timeoutMs?: number;
|
|
186
|
+
/** Injectable fetch for testing. Defaults to global `fetch`. */
|
|
187
|
+
fetchImpl?: typeof fetch;
|
|
188
|
+
}
|
|
189
|
+
interface ResolvedCost {
|
|
190
|
+
cost?: CatalogModelCost;
|
|
191
|
+
/** Where the returned cost came from. */
|
|
192
|
+
source: 'live' | 'cache';
|
|
193
|
+
/** True when served from cache and the snapshot is older than 30 days. */
|
|
194
|
+
stale: boolean;
|
|
195
|
+
}
|
|
196
|
+
/** Cached cost only — synchronous, never touches the network. */
|
|
197
|
+
declare function getCachedCost(providerId: string, modelId: string): CatalogModelCost | undefined;
|
|
198
|
+
/**
|
|
199
|
+
* Resolve a model's cost. Cache-only by default; with `{ live: true }` it tries
|
|
200
|
+
* the live source first and falls back to the cached snapshot on any failure
|
|
201
|
+
* (timeout, network, missing entry). Never throws on a network problem.
|
|
202
|
+
*/
|
|
203
|
+
declare function resolveCost(providerId: string, modelId: string, options?: ResolveCostOptions): Promise<ResolvedCost>;
|
|
204
|
+
|
|
205
|
+
export { type CatalogDispatchConfig, CatalogDispatchError, type CatalogDriftReport, type CatalogModalities, type CatalogModel, type CatalogModelCost, type CatalogModelLimit, type CatalogOverrides, type CatalogProvider, type CatalogSnapshot, type CatalogSource, FIRST_CLASS_PROVIDERS, type ResolveCostOptions, type ResolvedCost, applyOverrides, catalog, catalogSnapshotSchema, catalogSource, detectCatalogDrift, dispatchFromCatalog, getCachedCost, getModel, getProvider, listOpenAICompatibleProviders, listProviders, resolveCost };
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { JSONSchema7 } from 'json-schema';
|
|
2
|
+
import { AdapterFactory } from '@agentskit/core';
|
|
3
|
+
import { R as RetryOptions } from '../utils-ddwu4MN4.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* AgentsKit provider/model catalog — normalized metadata adapted from the
|
|
7
|
+
* `models.dev` data source into our own schema. This is the canonical shape;
|
|
8
|
+
* `models.dev` is an input, never a runtime dependency (see {@link CatalogSnapshot.source}).
|
|
9
|
+
*/
|
|
10
|
+
/** Input/output modalities a model accepts/produces. */
|
|
11
|
+
interface CatalogModalities {
|
|
12
|
+
input: string[];
|
|
13
|
+
output: string[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Per-token cost in USD per 1M tokens. Advisory metadata only — it is cached at
|
|
17
|
+
* snapshot time and drifts between regenerations, so never treat it as a hard
|
|
18
|
+
* contract for billing.
|
|
19
|
+
*/
|
|
20
|
+
interface CatalogModelCost {
|
|
21
|
+
input?: number;
|
|
22
|
+
output?: number;
|
|
23
|
+
cacheRead?: number;
|
|
24
|
+
cacheWrite?: number;
|
|
25
|
+
}
|
|
26
|
+
/** Context / output token ceilings. */
|
|
27
|
+
interface CatalogModelLimit {
|
|
28
|
+
context?: number;
|
|
29
|
+
output?: number;
|
|
30
|
+
}
|
|
31
|
+
/** A single model entry within a provider. */
|
|
32
|
+
interface CatalogModel {
|
|
33
|
+
id: string;
|
|
34
|
+
name: string;
|
|
35
|
+
family?: string;
|
|
36
|
+
limit?: CatalogModelLimit;
|
|
37
|
+
cost?: CatalogModelCost;
|
|
38
|
+
modalities?: CatalogModalities;
|
|
39
|
+
/** Capability flags — consult these instead of assuming "openai-compatible = works". */
|
|
40
|
+
toolCall: boolean;
|
|
41
|
+
structuredOutput: boolean;
|
|
42
|
+
reasoning: boolean;
|
|
43
|
+
attachment: boolean;
|
|
44
|
+
openWeights: boolean;
|
|
45
|
+
/** ISO-ish knowledge cutoff (e.g. "2024-05"). */
|
|
46
|
+
knowledge?: string;
|
|
47
|
+
releaseDate?: string;
|
|
48
|
+
lastUpdated?: string;
|
|
49
|
+
deprecated?: boolean;
|
|
50
|
+
}
|
|
51
|
+
/** A provider and its models. */
|
|
52
|
+
interface CatalogProvider {
|
|
53
|
+
id: string;
|
|
54
|
+
name: string;
|
|
55
|
+
/** Environment variable names that hold this provider's API key. */
|
|
56
|
+
env: string[];
|
|
57
|
+
/** Default API base URL (when `models.dev` records one). */
|
|
58
|
+
baseUrl?: string;
|
|
59
|
+
doc?: string;
|
|
60
|
+
/**
|
|
61
|
+
* True when the provider exposes an OpenAI-compatible transport and can be
|
|
62
|
+
* dispatched via the native generic adapter rather than a bespoke factory.
|
|
63
|
+
*/
|
|
64
|
+
openaiCompatible: boolean;
|
|
65
|
+
models: CatalogModel[];
|
|
66
|
+
}
|
|
67
|
+
/** Provenance + freshness metadata for a generated snapshot. */
|
|
68
|
+
interface CatalogSource {
|
|
69
|
+
name: 'models.dev';
|
|
70
|
+
url: string;
|
|
71
|
+
/** Pinned upstream version/commit the snapshot was generated from. */
|
|
72
|
+
version: string;
|
|
73
|
+
}
|
|
74
|
+
/** The committed, schema-validated catalog artifact loaded at runtime. */
|
|
75
|
+
interface CatalogSnapshot {
|
|
76
|
+
schemaVersion: 1;
|
|
77
|
+
/** ISO timestamp the snapshot was generated (set by the sync tool). */
|
|
78
|
+
generatedAt: string;
|
|
79
|
+
source: CatalogSource;
|
|
80
|
+
providers: CatalogProvider[];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Canonical JSON Schema for the provider/model catalog snapshot. Public export.
|
|
85
|
+
*
|
|
86
|
+
* JSON Schema is the single source of truth for contracts across AgentsKit
|
|
87
|
+
* (core stays zero-dep; Zod is opt-in convenience only, never canonical). The
|
|
88
|
+
* snapshot is validated against this schema at build time via the opt-in Ajv
|
|
89
|
+
* path (`@agentskit/validation`), not at runtime.
|
|
90
|
+
*/
|
|
91
|
+
declare const catalogSnapshotSchema: JSONSchema7;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* The committed catalog snapshot. Imported as data — the runtime never fetches
|
|
95
|
+
* `models.dev`. Heavy (thousands of models), so this module is only reachable
|
|
96
|
+
* via the `@agentskit/adapters/catalog` subpath, keeping the main bundle lean.
|
|
97
|
+
*/
|
|
98
|
+
declare const catalog: CatalogSnapshot;
|
|
99
|
+
/** All providers in the snapshot. */
|
|
100
|
+
declare function listProviders(): CatalogProvider[];
|
|
101
|
+
/** Look up a provider by id (e.g. "openai", "deepseek"). */
|
|
102
|
+
declare function getProvider(id: string): CatalogProvider | undefined;
|
|
103
|
+
/** Look up a model within a provider. */
|
|
104
|
+
declare function getModel(providerId: string, modelId: string): CatalogModel | undefined;
|
|
105
|
+
/** Providers exposing an OpenAI-compatible transport (dispatchable natively). */
|
|
106
|
+
declare function listOpenAICompatibleProviders(): CatalogProvider[];
|
|
107
|
+
/** Snapshot freshness/provenance — surface this so consumers can reason about staleness. */
|
|
108
|
+
declare function catalogSource(): CatalogSnapshot['source'] & {
|
|
109
|
+
generatedAt: string;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Local policy layer so consumers can constrain the catalog without forking it
|
|
114
|
+
* (enterprise-approved providers/models, disabled providers, etc.).
|
|
115
|
+
*
|
|
116
|
+
* Precedence (most → least restrictive):
|
|
117
|
+
* 1. `disabledProviders` always removes a provider, even if allow-listed.
|
|
118
|
+
* 2. `allowedProviders`, when set, keeps only listed providers.
|
|
119
|
+
* 3. `allowedModels[providerId]`, when set, keeps only listed models for that provider.
|
|
120
|
+
*/
|
|
121
|
+
interface CatalogOverrides {
|
|
122
|
+
/** When set, only these provider ids survive. */
|
|
123
|
+
allowedProviders?: string[];
|
|
124
|
+
/** Always removed, takes precedence over `allowedProviders`. */
|
|
125
|
+
disabledProviders?: string[];
|
|
126
|
+
/** Per-provider model allow-list. Absent provider key = no model restriction. */
|
|
127
|
+
allowedModels?: Record<string, string[]>;
|
|
128
|
+
}
|
|
129
|
+
/** Return a new snapshot with policy applied. The input snapshot is not mutated. */
|
|
130
|
+
declare function applyOverrides(snapshot: CatalogSnapshot, overrides: CatalogOverrides): CatalogSnapshot;
|
|
131
|
+
|
|
132
|
+
interface CatalogDispatchConfig {
|
|
133
|
+
provider: string;
|
|
134
|
+
model: string;
|
|
135
|
+
apiKey: string;
|
|
136
|
+
/** Override the catalog base URL (e.g. proxy / self-hosted gateway). */
|
|
137
|
+
baseUrl?: string;
|
|
138
|
+
retry?: RetryOptions;
|
|
139
|
+
}
|
|
140
|
+
declare class CatalogDispatchError extends Error {
|
|
141
|
+
readonly code: 'UNKNOWN_PROVIDER' | 'NOT_OPENAI_COMPATIBLE' | 'NO_BASE_URL';
|
|
142
|
+
constructor(message: string, code: 'UNKNOWN_PROVIDER' | 'NOT_OPENAI_COMPATIBLE' | 'NO_BASE_URL');
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Build a native OpenAI-compatible adapter for a catalog provider/model. This is
|
|
146
|
+
* the generic dispatch path: any provider `models.dev` marks OpenAI-compatible
|
|
147
|
+
* lands here without bespoke per-provider code.
|
|
148
|
+
*
|
|
149
|
+
* First-class providers (anthropic/openai/gemini/ollama) keep their dedicated
|
|
150
|
+
* factories and are authoritative — do not route them through here.
|
|
151
|
+
*/
|
|
152
|
+
declare function dispatchFromCatalog(config: CatalogDispatchConfig): AdapterFactory;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Catalog-backed providers that ship dedicated first-class factories here. These
|
|
156
|
+
* are authoritative and intentionally NOT dispatched via the generic catalog path.
|
|
157
|
+
*
|
|
158
|
+
* `ollama` is also first-class but is deliberately excluded: it is local-only and
|
|
159
|
+
* absent from `models.dev`, so it must not be flagged as "missing from catalog".
|
|
160
|
+
*/
|
|
161
|
+
declare const FIRST_CLASS_PROVIDERS: readonly ["anthropic", "openai", "google"];
|
|
162
|
+
interface CatalogDriftReport {
|
|
163
|
+
/** Catalog providers that are neither first-class nor OpenAI-compatible — undispatchable. */
|
|
164
|
+
undispatchable: string[];
|
|
165
|
+
/** First-class provider ids with no matching catalog entry (rename/removal upstream). */
|
|
166
|
+
missingFromCatalog: string[];
|
|
167
|
+
/** True when every catalog provider can be dispatched and no first-class entry is missing. */
|
|
168
|
+
ok: boolean;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Drift check: every snapshot provider must map to a dispatchable adapter (first-class
|
|
172
|
+
* factory or native OpenAI-compatible) or be flagged. Run in CI so a regenerated
|
|
173
|
+
* snapshot that introduces an unroutable provider fails loudly instead of shipping silently.
|
|
174
|
+
*/
|
|
175
|
+
declare function detectCatalogDrift(providers?: CatalogProvider[]): CatalogDriftReport;
|
|
176
|
+
|
|
177
|
+
interface ResolveCostOptions {
|
|
178
|
+
/**
|
|
179
|
+
* Opt in to a live fetch. Default `false` keeps the runtime offline and
|
|
180
|
+
* deterministic (the issue's "no runtime fetch" default). When `true`, a live
|
|
181
|
+
* lookup is attempted and the cached snapshot is the guaranteed fallback.
|
|
182
|
+
*/
|
|
183
|
+
live?: boolean;
|
|
184
|
+
/** Abort the live fetch after this many ms (default 3000). */
|
|
185
|
+
timeoutMs?: number;
|
|
186
|
+
/** Injectable fetch for testing. Defaults to global `fetch`. */
|
|
187
|
+
fetchImpl?: typeof fetch;
|
|
188
|
+
}
|
|
189
|
+
interface ResolvedCost {
|
|
190
|
+
cost?: CatalogModelCost;
|
|
191
|
+
/** Where the returned cost came from. */
|
|
192
|
+
source: 'live' | 'cache';
|
|
193
|
+
/** True when served from cache and the snapshot is older than 30 days. */
|
|
194
|
+
stale: boolean;
|
|
195
|
+
}
|
|
196
|
+
/** Cached cost only — synchronous, never touches the network. */
|
|
197
|
+
declare function getCachedCost(providerId: string, modelId: string): CatalogModelCost | undefined;
|
|
198
|
+
/**
|
|
199
|
+
* Resolve a model's cost. Cache-only by default; with `{ live: true }` it tries
|
|
200
|
+
* the live source first and falls back to the cached snapshot on any failure
|
|
201
|
+
* (timeout, network, missing entry). Never throws on a network problem.
|
|
202
|
+
*/
|
|
203
|
+
declare function resolveCost(providerId: string, modelId: string, options?: ResolveCostOptions): Promise<ResolvedCost>;
|
|
204
|
+
|
|
205
|
+
export { type CatalogDispatchConfig, CatalogDispatchError, type CatalogDriftReport, type CatalogModalities, type CatalogModel, type CatalogModelCost, type CatalogModelLimit, type CatalogOverrides, type CatalogProvider, type CatalogSnapshot, type CatalogSource, FIRST_CLASS_PROVIDERS, type ResolveCostOptions, type ResolvedCost, applyOverrides, catalog, catalogSnapshotSchema, catalogSource, detectCatalogDrift, dispatchFromCatalog, getCachedCost, getModel, getProvider, listOpenAICompatibleProviders, listProviders, resolveCost };
|