jeopi-catalog 16.2.13
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/CHANGELOG.md +523 -0
- package/README.md +43 -0
- package/dist/types/build.d.ts +3 -0
- package/dist/types/compat/anthropic.d.ts +11 -0
- package/dist/types/compat/apply.d.ts +7 -0
- package/dist/types/compat/devin.d.ts +9 -0
- package/dist/types/compat/openai.d.ts +28 -0
- package/dist/types/discovery/antigravity.d.ts +70 -0
- package/dist/types/discovery/codex.d.ts +38 -0
- package/dist/types/discovery/cursor-gen/agent_pb.d.ts +13022 -0
- package/dist/types/discovery/cursor.d.ts +23 -0
- package/dist/types/discovery/devin-gen/buf/validate/validate_pb.d.ts +1715 -0
- package/dist/types/discovery/devin-gen/exa/analytics_pb/analytics_pb.d.ts +693 -0
- package/dist/types/discovery/devin-gen/exa/api_server_pb/api_server_pb.d.ts +9158 -0
- package/dist/types/discovery/devin-gen/exa/auth_pb/auth_pb.d.ts +52 -0
- package/dist/types/discovery/devin-gen/exa/auto_cascade_common_pb/auto_cascade_common_pb.d.ts +276 -0
- package/dist/types/discovery/devin-gen/exa/bug_checker_pb/bug_checker_pb.d.ts +78 -0
- package/dist/types/discovery/devin-gen/exa/cascade_plugins_pb/cascade_plugins_pb.d.ts +999 -0
- package/dist/types/discovery/devin-gen/exa/chat_pb/chat_pb.d.ts +1704 -0
- package/dist/types/discovery/devin-gen/exa/code_edit/code_edit_pb/code_edit_pb.d.ts +656 -0
- package/dist/types/discovery/devin-gen/exa/codeium_common_pb/codeium_common_pb.d.ts +15014 -0
- package/dist/types/discovery/devin-gen/exa/context_module_pb/context_module_pb.d.ts +607 -0
- package/dist/types/discovery/devin-gen/exa/cortex_pb/cortex_pb.d.ts +11830 -0
- package/dist/types/discovery/devin-gen/exa/diff_action_pb/diff_action_pb.d.ts +248 -0
- package/dist/types/discovery/devin-gen/exa/index_pb/index_pb.d.ts +1747 -0
- package/dist/types/discovery/devin-gen/exa/knowledge_base_pb/knowledge_base_pb.d.ts +509 -0
- package/dist/types/discovery/devin-gen/exa/language_server_pb/language_server_pb.d.ts +9048 -0
- package/dist/types/discovery/devin-gen/exa/opensearch_clients_pb/opensearch_clients_pb.d.ts +1760 -0
- package/dist/types/discovery/devin-gen/exa/prompt_pb/prompt_pb.d.ts +286 -0
- package/dist/types/discovery/devin-gen/exa/reactive_component_pb/reactive_component_pb.d.ts +405 -0
- package/dist/types/discovery/devin-gen/exa/trust_pb/trust_pb.d.ts +582 -0
- package/dist/types/discovery/devin.d.ts +24 -0
- package/dist/types/discovery/gemini.d.ts +25 -0
- package/dist/types/discovery/gitlab-duo-workflow.d.ts +30 -0
- package/dist/types/discovery/index.d.ts +5 -0
- package/dist/types/discovery/openai-compatible.d.ts +74 -0
- package/dist/types/effort.d.ts +9 -0
- package/dist/types/fireworks-model-id.d.ts +23 -0
- package/dist/types/hosts.d.ts +137 -0
- package/dist/types/identity/bundled.d.ts +3 -0
- package/dist/types/identity/classify.d.ts +69 -0
- package/dist/types/identity/dialect.d.ts +3 -0
- package/dist/types/identity/family.d.ts +139 -0
- package/dist/types/identity/id.d.ts +12 -0
- package/dist/types/identity/index.d.ts +8 -0
- package/dist/types/identity/markers.d.ts +4 -0
- package/dist/types/identity/priority.d.ts +1 -0
- package/dist/types/identity/reference.d.ts +23 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/model-cache.d.ts +17 -0
- package/dist/types/model-manager.d.ts +68 -0
- package/dist/types/model-thinking.d.ts +79 -0
- package/dist/types/models.d.ts +12 -0
- package/dist/types/provider-models/bundled-references.d.ts +11 -0
- package/dist/types/provider-models/descriptor-types.d.ts +74 -0
- package/dist/types/provider-models/descriptors.d.ts +427 -0
- package/dist/types/provider-models/google.d.ts +27 -0
- package/dist/types/provider-models/index.d.ts +6 -0
- package/dist/types/provider-models/ollama.d.ts +9 -0
- package/dist/types/provider-models/openai-compat.d.ts +450 -0
- package/dist/types/provider-models/special.d.ts +33 -0
- package/dist/types/types.d.ts +656 -0
- package/dist/types/utils.d.ts +20 -0
- package/dist/types/variant-collapse.d.ts +133 -0
- package/dist/types/wire/codex.d.ts +26 -0
- package/dist/types/wire/coreweave.d.ts +12 -0
- package/dist/types/wire/gemini-headers.d.ts +37 -0
- package/dist/types/wire/github-copilot.d.ts +45 -0
- package/package.json +101 -0
- package/src/build.ts +47 -0
- package/src/compat/anthropic.ts +93 -0
- package/src/compat/apply.ts +15 -0
- package/src/compat/devin.ts +12 -0
- package/src/compat/openai.ts +689 -0
- package/src/discovery/antigravity.ts +253 -0
- package/src/discovery/codex.ts +371 -0
- package/src/discovery/cursor-gen/agent_pb.ts +15274 -0
- package/src/discovery/cursor.ts +314 -0
- package/src/discovery/devin-gen/buf/validate/validate_pb.ts +1862 -0
- package/src/discovery/devin-gen/exa/analytics_pb/analytics_pb.ts +871 -0
- package/src/discovery/devin-gen/exa/api_server_pb/api_server_pb.ts +11083 -0
- package/src/discovery/devin-gen/exa/auth_pb/auth_pb.ts +71 -0
- package/src/discovery/devin-gen/exa/auto_cascade_common_pb/auto_cascade_common_pb.ts +348 -0
- package/src/discovery/devin-gen/exa/bug_checker_pb/bug_checker_pb.ts +103 -0
- package/src/discovery/devin-gen/exa/cascade_plugins_pb/cascade_plugins_pb.ts +1198 -0
- package/src/discovery/devin-gen/exa/chat_pb/chat_pb.ts +2063 -0
- package/src/discovery/devin-gen/exa/code_edit/code_edit_pb/code_edit_pb.ts +810 -0
- package/src/discovery/devin-gen/exa/codeium_common_pb/codeium_common_pb.ts +18354 -0
- package/src/discovery/devin-gen/exa/context_module_pb/context_module_pb.ts +732 -0
- package/src/discovery/devin-gen/exa/cortex_pb/cortex_pb.ts +14277 -0
- package/src/discovery/devin-gen/exa/diff_action_pb/diff_action_pb.ts +312 -0
- package/src/discovery/devin-gen/exa/index_pb/index_pb.ts +2106 -0
- package/src/discovery/devin-gen/exa/knowledge_base_pb/knowledge_base_pb.ts +623 -0
- package/src/discovery/devin-gen/exa/language_server_pb/language_server_pb.ts +10918 -0
- package/src/discovery/devin-gen/exa/opensearch_clients_pb/opensearch_clients_pb.ts +2125 -0
- package/src/discovery/devin-gen/exa/prompt_pb/prompt_pb.ts +361 -0
- package/src/discovery/devin-gen/exa/reactive_component_pb/reactive_component_pb.ts +450 -0
- package/src/discovery/devin-gen/exa/trust_pb/trust_pb.ts +712 -0
- package/src/discovery/devin.ts +151 -0
- package/src/discovery/gemini.ts +260 -0
- package/src/discovery/gitlab-duo-workflow.ts +855 -0
- package/src/discovery/index.ts +5 -0
- package/src/discovery/openai-compatible.ts +249 -0
- package/src/effort.ts +16 -0
- package/src/fireworks-model-id.ts +50 -0
- package/src/hosts.ts +129 -0
- package/src/identity/bundled.ts +28 -0
- package/src/identity/classify.ts +214 -0
- package/src/identity/dialect.ts +42 -0
- package/src/identity/family.ts +296 -0
- package/src/identity/id.ts +81 -0
- package/src/identity/index.ts +8 -0
- package/src/identity/markers.ts +49 -0
- package/src/identity/priority.ts +57 -0
- package/src/identity/reference.ts +148 -0
- package/src/index.ts +17 -0
- package/src/model-cache.ts +171 -0
- package/src/model-manager.ts +520 -0
- package/src/model-thinking.ts +760 -0
- package/src/models.json +88898 -0
- package/src/models.json.d.ts +9 -0
- package/src/models.ts +64 -0
- package/src/provider-models/bundled-references.ts +58 -0
- package/src/provider-models/descriptor-types.ts +79 -0
- package/src/provider-models/descriptors.ts +503 -0
- package/src/provider-models/google.ts +107 -0
- package/src/provider-models/index.ts +6 -0
- package/src/provider-models/ollama.ts +172 -0
- package/src/provider-models/openai-compat.ts +4283 -0
- package/src/provider-models/special.ts +159 -0
- package/src/types.ts +786 -0
- package/src/utils.ts +69 -0
- package/src/variant-collapse.ts +1065 -0
- package/src/wire/codex.ts +43 -0
- package/src/wire/coreweave.ts +51 -0
- package/src/wire/gemini-headers.ts +74 -0
- package/src/wire/github-copilot.ts +121 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { Api, FetchImpl, ModelSpec, Provider } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Minimal OpenAI-style model entry shape consumed by discovery.
|
|
4
|
+
*
|
|
5
|
+
* Providers may return additional fields; this type only captures
|
|
6
|
+
* fields that are useful for generic normalization.
|
|
7
|
+
*/
|
|
8
|
+
export interface OpenAICompatibleModelRecord {
|
|
9
|
+
id?: unknown;
|
|
10
|
+
name?: unknown;
|
|
11
|
+
object?: unknown;
|
|
12
|
+
owned_by?: unknown;
|
|
13
|
+
[key: string]: unknown;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Tolerant envelope for OpenAI-compatible `/models` responses.
|
|
17
|
+
*
|
|
18
|
+
* Common providers return `{ data: [...] }`, but variants such as
|
|
19
|
+
* `{ models: [...] }`, `{ result: [...] }`, or direct arrays are also
|
|
20
|
+
* accepted during extraction.
|
|
21
|
+
*/
|
|
22
|
+
export interface OpenAICompatibleModelsEnvelope {
|
|
23
|
+
data?: unknown;
|
|
24
|
+
models?: unknown;
|
|
25
|
+
result?: unknown;
|
|
26
|
+
items?: unknown;
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Context passed to custom OpenAI-compatible model mappers.
|
|
31
|
+
*/
|
|
32
|
+
export interface OpenAICompatibleModelMapperContext<TApi extends Api> {
|
|
33
|
+
api: TApi;
|
|
34
|
+
provider: Provider;
|
|
35
|
+
baseUrl: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Options for fetching and normalizing OpenAI-compatible `/models` catalogs.
|
|
39
|
+
*/
|
|
40
|
+
export interface FetchOpenAICompatibleModelsOptions<TApi extends Api> {
|
|
41
|
+
/** API type assigned to normalized models. */
|
|
42
|
+
api: TApi;
|
|
43
|
+
/** Provider id assigned to normalized models. */
|
|
44
|
+
provider: Provider;
|
|
45
|
+
/** Provider base URL used for both fetch and normalized model records. */
|
|
46
|
+
baseUrl: string;
|
|
47
|
+
/** Optional bearer token for Authorization header. */
|
|
48
|
+
apiKey?: string;
|
|
49
|
+
/** Additional request headers. */
|
|
50
|
+
headers?: Record<string, string>;
|
|
51
|
+
/** Optional AbortSignal for request cancellation; caller owns its lifecycle. */
|
|
52
|
+
signal?: AbortSignal;
|
|
53
|
+
/** Optional cancellable request timeout used when `signal` is omitted. */
|
|
54
|
+
timeoutMs?: number;
|
|
55
|
+
/** Optional fetch implementation override for testing/custom runtimes. */
|
|
56
|
+
fetch?: FetchImpl;
|
|
57
|
+
/**
|
|
58
|
+
* Optional post-normalization filter.
|
|
59
|
+
* Return false to skip a model.
|
|
60
|
+
*/
|
|
61
|
+
filterModel?: (entry: OpenAICompatibleModelRecord, model: ModelSpec<TApi>) => boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Optional mapper override for provider-specific quirks.
|
|
64
|
+
* Return null to skip a model.
|
|
65
|
+
*/
|
|
66
|
+
mapModel?: (entry: OpenAICompatibleModelRecord, defaults: ModelSpec<TApi>, context: OpenAICompatibleModelMapperContext<TApi>) => ModelSpec<TApi> | null;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Fetches and normalizes an OpenAI-compatible `/models` catalog.
|
|
70
|
+
*
|
|
71
|
+
* Returns `null` on transport/protocol failures.
|
|
72
|
+
* Returns `[]` only when the endpoint responds successfully with no usable models.
|
|
73
|
+
*/
|
|
74
|
+
export declare function fetchOpenAICompatibleModels<TApi extends Api>(options: FetchOpenAICompatibleModelsOptions<TApi>): Promise<ModelSpec<TApi>[] | null>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare function toFireworksPublicModelId(modelId: string): string;
|
|
2
|
+
export declare function toFireworksWireModelId(modelId: string): string;
|
|
3
|
+
/**
|
|
4
|
+
* Fire Pass exposes its Kimi K2.6 Turbo subscription through a dedicated router
|
|
5
|
+
* endpoint at `accounts/fireworks/routers/<id>` rather than the `models/` namespace.
|
|
6
|
+
* We keep a friendly public id (e.g. `kimi-k2.6-turbo`) in the catalog and translate
|
|
7
|
+
* to the wire form (`accounts/fireworks/routers/kimi-k2p6-turbo`) at request time.
|
|
8
|
+
*/
|
|
9
|
+
export declare function toFirepassPublicModelId(modelId: string): string;
|
|
10
|
+
export declare function toFirepassWireModelId(modelId: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Public-id suffix marking a Fireworks "Fast" serving-path variant. Fast is a
|
|
13
|
+
* higher-throughput route (100+ tok/s) exposed under a dedicated router id
|
|
14
|
+
* (`accounts/fireworks/routers/<id>-fast`), not a separate model — same weights,
|
|
15
|
+
* higher price, no Priority tier. We keep a friendly `<id>-fast` public id and
|
|
16
|
+
* translate it to the router wire form at request time (compat
|
|
17
|
+
* `wireModelIdMode: "firepass"`). See https://docs.fireworks.ai/serverless/serving-paths.
|
|
18
|
+
*/
|
|
19
|
+
export declare const FIREWORKS_FAST_SUFFIX = "-fast";
|
|
20
|
+
/** True for a Fireworks public model id that selects the Fast serving path. */
|
|
21
|
+
export declare function isFireworksFastModelId(modelId: string): boolean;
|
|
22
|
+
/** Strip the Fast suffix to recover the base (Standard-tier) model id. */
|
|
23
|
+
export declare function toFireworksBaseModelId(modelId: string): string;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Known model-endpoint host classification — the single vocabulary for the
|
|
3
|
+
* `provider === id || baseUrl.includes(marker)` idiom that gates wire-level
|
|
4
|
+
* behavior (compat detection, routing, header shaping, watchdog floors).
|
|
5
|
+
*
|
|
6
|
+
* Markers are case-insensitive substrings matched against the base URL, NOT
|
|
7
|
+
* parsed hostnames: proxies regularly embed the upstream host in a path
|
|
8
|
+
* segment, and the historical call sites all used substring semantics.
|
|
9
|
+
* Callers that need strict hostname matching — where a substring false
|
|
10
|
+
* positive is dangerous, e.g. the Anthropic official-endpoint OAuth gate —
|
|
11
|
+
* parse the URL and compare the hostname themselves.
|
|
12
|
+
*/
|
|
13
|
+
export declare const KNOWN_HOSTS: {
|
|
14
|
+
readonly openai: {
|
|
15
|
+
readonly providers: readonly ["openai"];
|
|
16
|
+
readonly urlMarkers: readonly ["api.openai.com"];
|
|
17
|
+
};
|
|
18
|
+
readonly azureOpenAI: {
|
|
19
|
+
readonly providers: readonly ["azure"];
|
|
20
|
+
readonly urlMarkers: readonly [".openai.azure.com", "azure.com/openai", "models.inference.ai.azure.com"];
|
|
21
|
+
};
|
|
22
|
+
readonly openrouter: {
|
|
23
|
+
readonly providers: readonly ["openrouter"];
|
|
24
|
+
readonly urlMarkers: readonly ["openrouter.ai"];
|
|
25
|
+
};
|
|
26
|
+
readonly vercelAIGateway: {
|
|
27
|
+
readonly providers: readonly ["vercel-ai-gateway"];
|
|
28
|
+
readonly urlMarkers: readonly ["ai-gateway.vercel.sh"];
|
|
29
|
+
};
|
|
30
|
+
readonly githubCopilot: {
|
|
31
|
+
readonly providers: readonly ["github-copilot"];
|
|
32
|
+
readonly urlMarkers: readonly ["githubcopilot.com", "copilot-api."];
|
|
33
|
+
};
|
|
34
|
+
readonly anthropic: {
|
|
35
|
+
readonly providers: readonly ["anthropic"];
|
|
36
|
+
readonly urlMarkers: readonly ["api.anthropic.com"];
|
|
37
|
+
};
|
|
38
|
+
/** DeepSeek's first-party API only — gates direct-API quirks (max_tokens field, thinking extraBody). */
|
|
39
|
+
readonly deepseekDirect: {
|
|
40
|
+
readonly providers: readonly ["deepseek"];
|
|
41
|
+
readonly urlMarkers: readonly ["api.deepseek.com"];
|
|
42
|
+
};
|
|
43
|
+
/** Any DeepSeek-operated host (first-party API, web-chat fronts). Wider than `deepseekDirect` on purpose. */
|
|
44
|
+
readonly deepseekFamily: {
|
|
45
|
+
readonly providers: readonly ["deepseek"];
|
|
46
|
+
readonly urlMarkers: readonly ["deepseek.com"];
|
|
47
|
+
};
|
|
48
|
+
readonly cerebras: {
|
|
49
|
+
readonly providers: readonly ["cerebras"];
|
|
50
|
+
readonly urlMarkers: readonly ["cerebras.ai"];
|
|
51
|
+
};
|
|
52
|
+
readonly zai: {
|
|
53
|
+
readonly providers: readonly ["zai"];
|
|
54
|
+
readonly urlMarkers: readonly ["api.z.ai"];
|
|
55
|
+
};
|
|
56
|
+
readonly zhipu: {
|
|
57
|
+
readonly providers: readonly ["zhipu-coding-plan"];
|
|
58
|
+
readonly urlMarkers: readonly ["open.bigmodel.cn"];
|
|
59
|
+
};
|
|
60
|
+
readonly kilo: {
|
|
61
|
+
readonly providers: readonly ["kilo"];
|
|
62
|
+
readonly urlMarkers: readonly ["api.kilo.ai"];
|
|
63
|
+
};
|
|
64
|
+
readonly alibabaDashscope: {
|
|
65
|
+
readonly providers: readonly ["alibaba-coding-plan"];
|
|
66
|
+
readonly urlMarkers: readonly ["dashscope"];
|
|
67
|
+
};
|
|
68
|
+
readonly umans: {
|
|
69
|
+
readonly providers: readonly ["umans"];
|
|
70
|
+
readonly urlMarkers: readonly ["api.code.umans.ai"];
|
|
71
|
+
};
|
|
72
|
+
readonly xiaomi: {
|
|
73
|
+
readonly providers: readonly ["xiaomi"];
|
|
74
|
+
readonly providerPrefixes: readonly ["xiaomi-token-plan-"];
|
|
75
|
+
readonly urlMarkers: readonly ["xiaomimimo.com"];
|
|
76
|
+
};
|
|
77
|
+
readonly xai: {
|
|
78
|
+
readonly providers: readonly ["xai"];
|
|
79
|
+
readonly urlMarkers: readonly ["api.x.ai"];
|
|
80
|
+
};
|
|
81
|
+
readonly mistral: {
|
|
82
|
+
readonly providers: readonly ["mistral"];
|
|
83
|
+
readonly urlMarkers: readonly ["mistral.ai"];
|
|
84
|
+
};
|
|
85
|
+
readonly together: {
|
|
86
|
+
readonly providers: readonly ["together"];
|
|
87
|
+
readonly urlMarkers: readonly ["api.together.xyz"];
|
|
88
|
+
};
|
|
89
|
+
/** URL-only on purpose: the `fireworks`/`firepass` providers route per-model and not every model is Fireworks-shaped. */
|
|
90
|
+
readonly fireworks: {
|
|
91
|
+
readonly urlMarkers: readonly ["fireworks.ai"];
|
|
92
|
+
};
|
|
93
|
+
readonly groq: {
|
|
94
|
+
readonly providers: readonly ["groq"];
|
|
95
|
+
readonly urlMarkers: readonly ["api.groq.com"];
|
|
96
|
+
};
|
|
97
|
+
readonly minimax: {
|
|
98
|
+
readonly providers: readonly ["minimax", "minimax-code", "minimax-code-cn"];
|
|
99
|
+
readonly urlMarkers: readonly ["api.minimax.io", "api.minimaxi.com"];
|
|
100
|
+
};
|
|
101
|
+
readonly qwenPortal: {
|
|
102
|
+
readonly providers: readonly ["qwen-portal"];
|
|
103
|
+
readonly urlMarkers: readonly ["portal.qwen.ai"];
|
|
104
|
+
};
|
|
105
|
+
/** NVIDIA NIM (`integrate.api.nvidia.com`). Qwen NIM endpoints take `chat_template_kwargs.enable_thinking`, never top-level `enable_thinking`. */
|
|
106
|
+
readonly nvidia: {
|
|
107
|
+
readonly providers: readonly ["nvidia"];
|
|
108
|
+
readonly urlMarkers: readonly ["integrate.api.nvidia.com"];
|
|
109
|
+
};
|
|
110
|
+
readonly moonshotNative: {
|
|
111
|
+
readonly providers: readonly ["moonshot", "kimi-code"];
|
|
112
|
+
readonly urlMarkers: readonly ["api.moonshot.ai", "api.kimi.com"];
|
|
113
|
+
};
|
|
114
|
+
readonly opencode: {
|
|
115
|
+
readonly providers: readonly ["opencode-go", "opencode-zen"];
|
|
116
|
+
readonly urlMarkers: readonly ["opencode.ai"];
|
|
117
|
+
};
|
|
118
|
+
readonly chutes: {
|
|
119
|
+
readonly urlMarkers: readonly ["chutes.ai"];
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
export type KnownHost = keyof typeof KNOWN_HOSTS;
|
|
123
|
+
/** URL-only host check (for call sites that have no provider id, e.g. raw env config). */
|
|
124
|
+
export declare function hostMatchesUrl(baseUrl: string | undefined, host: KnownHost): boolean;
|
|
125
|
+
/** Provider-or-URL host check — the canonical `provider === id || baseUrl.includes(marker)` idiom. */
|
|
126
|
+
export declare function modelMatchesHost(model: {
|
|
127
|
+
provider: string;
|
|
128
|
+
baseUrl: string;
|
|
129
|
+
}, host: KnownHost): boolean;
|
|
130
|
+
/** Vertex AI express-mode OpenAI-compatible endpoint (`…/endpoints/openapi`). */
|
|
131
|
+
export declare function isVertexExpressOpenAIUrl(baseUrl: string): boolean;
|
|
132
|
+
/** Vertex AI Anthropic raw-predict endpoints (`:streamRawPredict` / `:rawPredict`). */
|
|
133
|
+
export declare function isVertexRawPredictUrl(baseUrl: string): boolean;
|
|
134
|
+
/** Azure OpenAI deployment-scoped path (`…/deployments/<name>/…`). */
|
|
135
|
+
export declare function isAzureDeploymentsUrl(baseUrl: string): boolean;
|
|
136
|
+
/** Alibaba DashScope consumer `compatible-mode` endpoint (rejects multimodal arrays for some text-only SKUs). */
|
|
137
|
+
export declare function isDashscopeCompatibleModeUrl(baseUrl: string): boolean;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model-id classification: parse a model id into its family (gemini / anthropic /
|
|
3
|
+
* openai), kind/variant, and version. This is the shared layer both catalog
|
|
4
|
+
* policy rules (`model-thinking.ts`) and downstream consumers build on —
|
|
5
|
+
* classification lives here, the rules that consume it stay with their domain.
|
|
6
|
+
*/
|
|
7
|
+
export type SemVer = {
|
|
8
|
+
major: number;
|
|
9
|
+
minor: number;
|
|
10
|
+
patch: number;
|
|
11
|
+
};
|
|
12
|
+
export type GeminiKind = "pro" | "flash";
|
|
13
|
+
export type AnthropicKind = "opus" | "sonnet" | "fable" | "mythos";
|
|
14
|
+
export type OpenAIVariant = "base" | "codex" | "codex-max" | "codex-mini" | "codex-spark" | "mini" | "max" | "nano";
|
|
15
|
+
export type GlmVariant = "base" | "air" | "turbo" | "flash" | "flashx" | "preview";
|
|
16
|
+
export interface GeminiModel {
|
|
17
|
+
family: "gemini";
|
|
18
|
+
kind: GeminiKind;
|
|
19
|
+
version: SemVer;
|
|
20
|
+
}
|
|
21
|
+
export interface AnthropicModel {
|
|
22
|
+
family: "anthropic";
|
|
23
|
+
kind: AnthropicKind;
|
|
24
|
+
version: SemVer;
|
|
25
|
+
}
|
|
26
|
+
export interface OpenAIModel {
|
|
27
|
+
family: "openai";
|
|
28
|
+
variant: OpenAIVariant;
|
|
29
|
+
version: SemVer;
|
|
30
|
+
}
|
|
31
|
+
export interface GlmModel {
|
|
32
|
+
family: "glm";
|
|
33
|
+
/** Suffix variant (`-air`, `-turbo`, `-flash`, `-flashx`, `-preview`); `base` when none. */
|
|
34
|
+
variant: GlmVariant;
|
|
35
|
+
/** Vision SKU — the `v` that attaches directly to the version (`glm-4v`, `glm-4.5v`). */
|
|
36
|
+
vision: boolean;
|
|
37
|
+
version: SemVer;
|
|
38
|
+
}
|
|
39
|
+
export interface UnknownModel {
|
|
40
|
+
family: "unknown";
|
|
41
|
+
id: string;
|
|
42
|
+
}
|
|
43
|
+
export type ParsedModel = GeminiModel | AnthropicModel | OpenAIModel | UnknownModel;
|
|
44
|
+
export declare function bareModelId(modelId: string): string;
|
|
45
|
+
export declare function parseKnownModel(modelId: string): ParsedModel;
|
|
46
|
+
export declare const parseGeminiModel: (modelId: string) => GeminiModel | null;
|
|
47
|
+
export declare const parseAnthropicModel: (modelId: string) => AnthropicModel | null;
|
|
48
|
+
export declare const parseOpenAIModel: (modelId: string) => OpenAIModel | null;
|
|
49
|
+
/**
|
|
50
|
+
* Parse a GLM (Zhipu / Z.AI) model id into family + variant + vision + version.
|
|
51
|
+
* Shape: `glm-<version>[v][-<variant>]` — e.g. `glm-4.5`, `glm-4.5-air`,
|
|
52
|
+
* `glm-5-turbo`, `glm-4.5v`, `glm-5-preview`. The `v` (vision) attaches to the
|
|
53
|
+
* version; other variants are `-` suffixes. Standalone like `parseAnthropicModel`
|
|
54
|
+
* is used in family.ts — GLM needs no global thinking policy, so it stays out of
|
|
55
|
+
* `parseKnownModel`.
|
|
56
|
+
*/
|
|
57
|
+
export declare const parseGlmModel: (modelId: string) => GlmModel | null;
|
|
58
|
+
export declare function isFableOrMythos(kind: AnthropicKind): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Returns true if the parsed Anthropic model is part of the adaptive-thinking
|
|
61
|
+
* Claude generation at or above a specific capability threshold.
|
|
62
|
+
* - Opus has a configurable minimum version floor (e.g. "4.6", "4.7", "4.8").
|
|
63
|
+
* - Sonnet, Fable, and Mythos all require version 5 or higher.
|
|
64
|
+
*/
|
|
65
|
+
export declare function isAnthropicAdaptiveGenAtLeast(parsed: AnthropicModel, opusMin: "4.6" | "4.7" | "4.8"): boolean;
|
|
66
|
+
export declare function parseSemVer(version: string): SemVer | null;
|
|
67
|
+
export declare function semverGte(left: SemVer | string, right: SemVer | string): boolean;
|
|
68
|
+
export declare function semverEqual(left: SemVer | string, right: SemVer | string): boolean;
|
|
69
|
+
export declare function compareSemVer(left: SemVer | string | null, right: SemVer | string | null): number;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model-family id predicates: the shared vocabulary for "is this id a member
|
|
3
|
+
* of family X" checks that gate wire-level behavior across hosts (a Kimi or
|
|
4
|
+
* DeepSeek model keeps its quirks no matter which OpenAI-compatible proxy
|
|
5
|
+
* serves it). Looser per-feature heuristics (e.g. stream-markup healing)
|
|
6
|
+
* deliberately keep their own patterns — only provably-shared matchers live
|
|
7
|
+
* here.
|
|
8
|
+
*/
|
|
9
|
+
/** Kimi family ids in any namespace form (`moonshotai/kimi-*`, `kimi-k2.6`, `vendor/kimi.x`). */
|
|
10
|
+
export declare const isKimiModelId: (modelId: string) => boolean;
|
|
11
|
+
/** Kimi K2.6 specifically, including router ids that spell the version `k2p6`. */
|
|
12
|
+
export declare const isKimiK26ModelId: (modelId: string) => boolean;
|
|
13
|
+
/** Claude ids in any namespace form (`claude-*`, `vendor/claude.x`). */
|
|
14
|
+
export declare const isClaudeModelId: (modelId: string) => boolean;
|
|
15
|
+
/** `anthropic/`-namespaced ids (aggregator catalogs like OpenRouter). */
|
|
16
|
+
export declare const isAnthropicNamespacedModelId: (modelId: string) => boolean;
|
|
17
|
+
/** Qwen family ids (substring match — Qwen SKUs have no stable prefix shape). */
|
|
18
|
+
export declare const isQwenModelId: (modelId: string) => boolean;
|
|
19
|
+
/** Gemma open-weights family (`gemma-3-27b-it`, `google/gemma-4-E2B-it`, `gemma2-9b`). */
|
|
20
|
+
export declare const isGemmaModelId: (modelId: string) => boolean;
|
|
21
|
+
/** DeepSeek family by id or display name (proxies often rename the id but keep the name). */
|
|
22
|
+
export declare const isDeepseekModelIdOrName: (modelId: string) => boolean;
|
|
23
|
+
/** Xiaomi MiMo family by id or display name. */
|
|
24
|
+
export declare const isMimoModelIdOrName: (modelId: string) => boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Grok SKUs that expose the wire `reasoning.effort` dial. Other Grok reasoners
|
|
27
|
+
* (e.g. `grok-build`, `grok-4.20-0309-reasoning`) think natively but reject the
|
|
28
|
+
* param, so callers must omit reasoning effort for them.
|
|
29
|
+
*/
|
|
30
|
+
export declare const isGrokReasoningEffortCapable: (modelId: string) => boolean;
|
|
31
|
+
/**
|
|
32
|
+
* MiniMax M2-generation family (M2, M2.1, M2.5, M2.7, including `-highspeed`/
|
|
33
|
+
* `-lightning`/`-her`/`-turbo` variants, dotless aliases like `minimax-m21`,
|
|
34
|
+
* and short `minimax/m2-…` ids on aggregator hosts). Underlying model accepts
|
|
35
|
+
* only `low|medium|high` for `reasoning_effort` and 400s on `minimal`,
|
|
36
|
+
* `xhigh`, or `none` — so hosts whose default effort map otherwise lowers
|
|
37
|
+
* `minimal` to `none` (Fireworks) or expects the full 5-tier scale must
|
|
38
|
+
* clamp instead. Excludes M1, M3, MiniMax-Text-01, music, hailuo, voice ids.
|
|
39
|
+
*/
|
|
40
|
+
export declare const isMinimaxM2FamilyModelId: (modelId: string) => boolean;
|
|
41
|
+
/** MiniMax M3 family ids in bundled/default and aggregator namespace forms. */
|
|
42
|
+
export declare const isMinimaxM3FamilyModelId: (modelId: string) => boolean;
|
|
43
|
+
/**
|
|
44
|
+
* OpenAI gpt-oss family (`gpt-oss-20b`, `gpt-oss-120b`, `gpt-oss:120b`,
|
|
45
|
+
* `vendor/gpt-oss-…`). The Harmony reasoning format only accepts
|
|
46
|
+
* `low|medium|high` for `reasoning_effort` and rejects `minimal`, `xhigh`,
|
|
47
|
+
* and `none`.
|
|
48
|
+
*/
|
|
49
|
+
export declare const isOpenAIGptOssModelId: (modelId: string) => boolean;
|
|
50
|
+
/** OpenAI model ids (gpt-*, o1-*, o3-*, o4-*, or prefixed with openai/). */
|
|
51
|
+
export declare const isOpenAIModelId: (modelId: string) => boolean;
|
|
52
|
+
/**
|
|
53
|
+
* OpenAI Codex models that honor `reasoning.context: "all_turns"` (full
|
|
54
|
+
* cross-turn reasoning replay). The `reasoning.context` field itself exists for
|
|
55
|
+
* the whole gpt-5/o-series family, but the `all_turns` value is only accepted
|
|
56
|
+
* from gpt-5.4 onward; earlier ids (`gpt-5.1-codex`, `gpt-5.3-codex`, and
|
|
57
|
+
* `gpt-5.3-codex-spark`) reject it with
|
|
58
|
+
* `Unsupported value: 'all_turns' is not supported with this model`. Version
|
|
59
|
+
* floor (not an allowlist) so 5.6/6.x inherit support automatically. Callers
|
|
60
|
+
* fall back to omitting `context`, letting the server default to `current_turn`.
|
|
61
|
+
*/
|
|
62
|
+
export declare const supportsAllTurnsReasoningContext: (modelId: string) => boolean;
|
|
63
|
+
/**
|
|
64
|
+
* OpenAI Codex models that accept `reasoning.summary`. Shares the gpt-5.4 wire
|
|
65
|
+
* floor with {@link supportsAllTurnsReasoningContext}: earlier Codex ids
|
|
66
|
+
* (`gpt-5.1-codex`, `gpt-5.3-codex`, `gpt-5.3-codex-spark`) reject the field
|
|
67
|
+
* with `Unsupported parameter: 'reasoning.summary' is not supported with this
|
|
68
|
+
* model`. Callers omit `summary` for unsupported ids, letting the server skip
|
|
69
|
+
* the human-readable summary stream.
|
|
70
|
+
*/
|
|
71
|
+
export declare const supportsCodexReasoningSummary: (modelId: string) => boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Reasoning-capable GLM coding SKUs: glm-4.5 and up on the base / `-air` /
|
|
74
|
+
* `-turbo` lines. Excludes the vision (`…v`) shape, the non-reasoning
|
|
75
|
+
* `-flash`/`-flashx`/`-preview` variants, and pre-4.5 ids. Matching the family
|
|
76
|
+
* keeps newly-bumped integers (`glm-5.3`, `glm-6`, …) covered without a per-id
|
|
77
|
+
* allowlist.
|
|
78
|
+
*/
|
|
79
|
+
export declare const isReasoningGlmModelId: (modelId: string) => boolean;
|
|
80
|
+
/** GLM-5.2+ coding SKUs accept `reasoning_effort` in addition to binary thinking. */
|
|
81
|
+
export declare const isGlm52ReasoningEffortModelId: (modelId: string) => boolean;
|
|
82
|
+
/** GLM vision SKUs — the `v` that attaches to the version (`glm-4v`, `glm-4.5v`). */
|
|
83
|
+
export declare const isGlmVisionModelId: (modelId: string) => boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Coarse vendor-lineage token for "are two models the same family?" checks
|
|
86
|
+
* (e.g. picking a cross-family reviewer). All Claude point releases share a token,
|
|
87
|
+
* Claude and GPT differ; namespace prefixes and aggregator mirrors fold onto the
|
|
88
|
+
* lineage via {@link parseKnownModel}'s `bareModelId` normalization. Opaque and
|
|
89
|
+
* comparison-only — not a stable key to persist, since the vocabulary tracks new
|
|
90
|
+
* releases. Returns `""` for ids it cannot classify; callers fall back to the provider.
|
|
91
|
+
*
|
|
92
|
+
* Vendor-only by design: a model's kind/variant (opus vs sonnet, codex vs base) is
|
|
93
|
+
* collapsed onto the single vendor token; use {@link parseKnownModel} for finer breakdowns.
|
|
94
|
+
*/
|
|
95
|
+
export declare const modelFamilyToken: (modelId: string) => string;
|
|
96
|
+
/**
|
|
97
|
+
* Adaptive thinking `display` is supported starting with Claude Opus 4.7+,
|
|
98
|
+
* Sonnet 5+, and the Claude Fable/Mythos 5 generation. Older adaptive-thinking
|
|
99
|
+
* models (Opus 4.6, Sonnet 4.6) reject the field. Classifier-based, so dotted
|
|
100
|
+
* and dashed version forms both match while bare dated ids
|
|
101
|
+
* (`claude-opus-4-20250514` = Opus 4.0) stay excluded.
|
|
102
|
+
*/
|
|
103
|
+
export declare const supportsAdaptiveThinkingDisplay: (modelId: string) => boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Returns true for Anthropic models with Opus 4.7+, Sonnet 5+, and Fable/Mythos 5+
|
|
106
|
+
* API restrictions:
|
|
107
|
+
* - Sampling parameters (temperature/top_p/top_k) return 400 error
|
|
108
|
+
* - Thinking content is omitted by default (needs display: "summarized")
|
|
109
|
+
*/
|
|
110
|
+
export declare const hasOpus47ApiRestrictions: (modelId: string) => boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Mid-conversation `role: "system"` messages (system instructions appended at
|
|
113
|
+
* non-first positions in the `messages` array) are supported starting with
|
|
114
|
+
* Claude Opus 4.8+, Sonnet 5+, and the Claude Fable/Mythos 5 generation.
|
|
115
|
+
* Earlier Claude models reject the role.
|
|
116
|
+
* @see https://platform.claude.com/docs/en/build-with-claude/mid-conversation-system-messages
|
|
117
|
+
*/
|
|
118
|
+
export declare const supportsMidConversationSystemMessages: (modelId: string) => boolean;
|
|
119
|
+
export declare const isAnthropicFableOrMythosModel: (modelId: string) => boolean;
|
|
120
|
+
/** Thinking-variant token location inside a model id. */
|
|
121
|
+
export interface ThinkingVariantToken {
|
|
122
|
+
index: number;
|
|
123
|
+
length: number;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Locates the first thinking-variant token (`-thinking`, `-reasoner`,
|
|
127
|
+
* `-reasoning`; trailing or infix) in a model id. The token ends at the id
|
|
128
|
+
* end or any non-alphanumeric boundary, and negated forms (`non-thinking`,
|
|
129
|
+
* `no-thinking`) never match — those name the NON-thinking SKU.
|
|
130
|
+
*/
|
|
131
|
+
export declare function findThinkingVariantToken(modelId: string): ThinkingVariantToken | undefined;
|
|
132
|
+
/**
|
|
133
|
+
* Removes the located thinking-variant token: `kimi-k2-thinking` → `kimi-k2`,
|
|
134
|
+
* `mimo-v2-flash-thinking-original` → `mimo-v2-flash-original`,
|
|
135
|
+
* `grok-4.1-fast-reasoning` → `grok-4.1-fast`. Returns `undefined` when no
|
|
136
|
+
* token exists or nothing would remain. Callers MUST verify the result names
|
|
137
|
+
* a live model.
|
|
138
|
+
*/
|
|
139
|
+
export declare const stripThinkingVariantToken: (modelId: string) => string | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare function getModelLikeIdSegments(modelId: string): string[];
|
|
2
|
+
export declare function getLongestModelLikeIdSegment(modelId: string): string | undefined;
|
|
3
|
+
/**
|
|
4
|
+
* Strip reseller / wrapper tags that are injected as bracketed affixes around an
|
|
5
|
+
* upstream model id, e.g.
|
|
6
|
+
* "[Kiro] claude-opus-4-8" -> "claude-opus-4-8"
|
|
7
|
+
* "[gcli转] gemini-3.1-pro-preview [假流]" -> "gemini-3.1-pro-preview"
|
|
8
|
+
*
|
|
9
|
+
* Candidates are returned most-stripped first: both ends, then leading-only, then trailing-only.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getBracketStrippedModelIdCandidates(modelId: string): string[];
|
|
12
|
+
export declare function stripBracketedModelIdAffixes(modelId: string): string | undefined;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Marker pattern used by canonical-id resolution (`search` excluded). */
|
|
2
|
+
export declare const CANONICAL_TRAILING_MARKER_PATTERN: RegExp;
|
|
3
|
+
/** Marker pattern used by proxy-reference lookup (`search` included). */
|
|
4
|
+
export declare const REFERENCE_TRAILING_MARKER_PATTERN: RegExp;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function buildModelProviderPriorityRank(configuredProviderOrder?: readonly string[]): Map<string, number>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Proxy/reseller reference lookup: given a custom model id served through a
|
|
3
|
+
* proxy (`[Kiro] claude-opus-4-8`, `gpt-5.4:cloud`, `vendor/claude-sonnet-4-6-thinking`),
|
|
4
|
+
* find the bundled upstream model so missing pricing/capability metadata can be
|
|
5
|
+
* inherited while keeping the custom transport.
|
|
6
|
+
*
|
|
7
|
+
* Kept separate from canonical-id resolution (`./equivalence`): this lookup
|
|
8
|
+
* may strip `search`-style markers and prefers cache-pricing-complete
|
|
9
|
+
* references, both of which would be wrong for canonical coalescing.
|
|
10
|
+
*/
|
|
11
|
+
import type { Api, Model } from "../types";
|
|
12
|
+
export interface ModelReferenceIndex {
|
|
13
|
+
exact: Map<string, Model<Api>>;
|
|
14
|
+
suffixAlias: Map<string, Model<Api>>;
|
|
15
|
+
}
|
|
16
|
+
export declare function isZeroCostXaiOAuthReference(candidate: Model<Api>): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Build a reference index from a model catalog (typically the bundled models).
|
|
19
|
+
* Pure: callers are responsible for memoizing the result.
|
|
20
|
+
*/
|
|
21
|
+
export declare function buildModelReferenceIndex(models: Iterable<Model<Api>>): ModelReferenceIndex;
|
|
22
|
+
/** Resolve a (possibly proxied/affixed) model id to its bundled upstream reference. */
|
|
23
|
+
export declare function resolveModelReference(modelId: string, index: ModelReferenceIndex): Model<Api> | undefined;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from "./compat/openai";
|
|
2
|
+
export * from "./discovery";
|
|
3
|
+
export * from "./effort";
|
|
4
|
+
export * from "./fireworks-model-id";
|
|
5
|
+
export * from "./identity";
|
|
6
|
+
export * from "./model-cache";
|
|
7
|
+
export * from "./model-manager";
|
|
8
|
+
export * from "./model-thinking";
|
|
9
|
+
export * from "./models";
|
|
10
|
+
export * from "./provider-models";
|
|
11
|
+
export * from "./types";
|
|
12
|
+
export * from "./utils";
|
|
13
|
+
export * from "./variant-collapse";
|
|
14
|
+
export * from "./wire/codex";
|
|
15
|
+
export * from "./wire/coreweave";
|
|
16
|
+
export * from "./wire/gemini-headers";
|
|
17
|
+
export * from "./wire/github-copilot";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Api, Model, ModelSpec } from "./types";
|
|
2
|
+
interface CacheEntry<TApi extends Api = Api> {
|
|
3
|
+
models: ModelSpec<TApi>[];
|
|
4
|
+
fresh: boolean;
|
|
5
|
+
authoritative: boolean;
|
|
6
|
+
updatedAt: number;
|
|
7
|
+
/**
|
|
8
|
+
* Hash of the static catalog slice that was merged into `models` when this
|
|
9
|
+
* row was written. `resolveProviderModels` compares against the current
|
|
10
|
+
* static fingerprint and bypasses the static+cache re-merge when they
|
|
11
|
+
* match — the cache already incorporates the same static state.
|
|
12
|
+
*/
|
|
13
|
+
staticFingerprint: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function readModelCache<TApi extends Api>(providerId: string, ttlMs: number, now: () => number, dbPath?: string): CacheEntry<TApi> | null;
|
|
16
|
+
export declare function writeModelCache<TApi extends Api>(providerId: string, updatedAt: number, models: Model<TApi>[], authoritative: boolean, staticFingerprint: string, dbPath?: string): void;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { Api, Model, ModelSpec, Provider } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Controls when dynamic endpoint models should be fetched.
|
|
4
|
+
*/
|
|
5
|
+
export type ModelRefreshStrategy = "online" | "offline" | "online-if-uncached";
|
|
6
|
+
/**
|
|
7
|
+
* Hook for loading and mapping models.dev fallback data into canonical model objects.
|
|
8
|
+
*/
|
|
9
|
+
export interface ModelsDevFallback<TApi extends Api = Api, TPayload = unknown> {
|
|
10
|
+
/** Fetches raw fallback payload (for example from models.dev). */
|
|
11
|
+
fetch(): Promise<TPayload>;
|
|
12
|
+
/** Maps payload into provider models. */
|
|
13
|
+
map(payload: TPayload, providerId: Provider): readonly ModelSpec<TApi>[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Configuration for provider model resolution.
|
|
17
|
+
*/
|
|
18
|
+
export interface ModelManagerOptions<TApi extends Api = Api, TModelsDevPayload = unknown> {
|
|
19
|
+
/** Provider id used for static lookup and cache namespacing. */
|
|
20
|
+
providerId: Provider;
|
|
21
|
+
/** Optional static list override. When omitted, bundled models.json is used. */
|
|
22
|
+
staticModels?: readonly ModelSpec<TApi>[];
|
|
23
|
+
/** Optional override for the cache database path. Default: <agent-dir>/models.db. */
|
|
24
|
+
cacheDbPath?: string;
|
|
25
|
+
/** Optional provider id override for cache namespacing. Defaults to providerId. */
|
|
26
|
+
cacheProviderId?: string;
|
|
27
|
+
/** Maximum cache age in milliseconds before considered stale. Default: 24h. */
|
|
28
|
+
cacheTtlMs?: number;
|
|
29
|
+
/** When true, a successful dynamic fetch is the complete provider catalog and prunes static-only models. */
|
|
30
|
+
dynamicModelsAuthoritative?: boolean;
|
|
31
|
+
/** Cached model ids to ignore when the cache was written against a different static catalog fingerprint. */
|
|
32
|
+
dropCachedModelIdsOnStaticMismatch?: readonly string[];
|
|
33
|
+
/** Optional dynamic endpoint fetcher. */
|
|
34
|
+
fetchDynamicModels?: () => Promise<readonly ModelSpec<TApi>[] | null>;
|
|
35
|
+
/** Optional models.dev fallback hook. */
|
|
36
|
+
modelsDev?: ModelsDevFallback<TApi, TModelsDevPayload>;
|
|
37
|
+
/** Clock override for deterministic tests. */
|
|
38
|
+
now?: () => number;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Resolution result.
|
|
42
|
+
*
|
|
43
|
+
* `stale` is false when the resolved catalog is authoritative for the selected provider:
|
|
44
|
+
* - dynamic endpoint data was fetched in this call,
|
|
45
|
+
* - a still-fresh authoritative cache was reused in `online-if-uncached` mode, or
|
|
46
|
+
* - the provider has no dynamic fetcher configured.
|
|
47
|
+
*/
|
|
48
|
+
export interface ModelResolutionResult<TApi extends Api = Api> {
|
|
49
|
+
models: Model<TApi>[];
|
|
50
|
+
stale: boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Stateful facade over provider model resolution.
|
|
54
|
+
*/
|
|
55
|
+
export interface ModelManager<TApi extends Api = Api> {
|
|
56
|
+
refresh(strategy?: ModelRefreshStrategy): Promise<ModelResolutionResult<TApi>>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Creates a reusable provider model manager.
|
|
60
|
+
*/
|
|
61
|
+
export declare function createModelManager<TApi extends Api = Api, TModelsDevPayload = unknown>(options: ModelManagerOptions<TApi, TModelsDevPayload>): ModelManager<TApi>;
|
|
62
|
+
/**
|
|
63
|
+
* Resolves provider models with source precedence:
|
|
64
|
+
* static -> models.dev -> cache -> dynamic.
|
|
65
|
+
*
|
|
66
|
+
* Later sources override earlier ones by model id.
|
|
67
|
+
*/
|
|
68
|
+
export declare function resolveProviderModels<TApi extends Api = Api, TModelsDevPayload = unknown>(options: ModelManagerOptions<TApi, TModelsDevPayload>, strategy?: ModelRefreshStrategy): Promise<ModelResolutionResult<TApi>>;
|