@rigelbuild/omp-catalog 18.0.3
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 +1204 -0
- package/LICENSE +22 -0
- package/README.md +43 -0
- package/THIRD-PARTY-NOTICES.txt +22909 -0
- package/dist/types/build.d.ts +19 -0
- package/dist/types/compat/anthropic.d.ts +18 -0
- package/dist/types/compat/apply.d.ts +7 -0
- package/dist/types/compat/bedrock.d.ts +3 -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 +36 -0
- package/dist/types/discovery/cursor-proto.d.ts +5368 -0
- package/dist/types/discovery/cursor.d.ts +23 -0
- package/dist/types/discovery/devin-proto.d.ts +1549 -0
- package/dist/types/discovery/devin.d.ts +24 -0
- package/dist/types/discovery/gemini-cli.d.ts +33 -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 +7 -0
- package/dist/types/discovery/openai-compatible.d.ts +89 -0
- package/dist/types/discovery/protobuf.d.ts +102 -0
- package/dist/types/effort.d.ts +10 -0
- package/dist/types/fireworks-model-id.d.ts +23 -0
- package/dist/types/hosts.d.ts +169 -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 +239 -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 +29 -0
- package/dist/types/index.d.ts +19 -0
- package/dist/types/model-cache.d.ts +23 -0
- package/dist/types/model-manager.d.ts +77 -0
- package/dist/types/model-thinking.d.ts +70 -0
- package/dist/types/model-tokenizer.d.ts +8 -0
- package/dist/types/models.d.ts +14 -0
- package/dist/types/openai-pricing.d.ts +17 -0
- package/dist/types/provider-models/bundled-references.d.ts +13 -0
- package/dist/types/provider-models/cache-provider-id.d.ts +11 -0
- package/dist/types/provider-models/descriptor-types.d.ts +76 -0
- package/dist/types/provider-models/descriptors.d.ts +505 -0
- package/dist/types/provider-models/google.d.ts +29 -0
- package/dist/types/provider-models/index.d.ts +7 -0
- package/dist/types/provider-models/ollama.d.ts +22 -0
- package/dist/types/provider-models/openai-compat.d.ts +646 -0
- package/dist/types/provider-models/special.d.ts +53 -0
- package/dist/types/types.d.ts +876 -0
- package/dist/types/utils.d.ts +20 -0
- package/dist/types/variant-collapse.d.ts +137 -0
- package/dist/types/wire/alibaba-token-plan.d.ts +22 -0
- package/dist/types/wire/codex.d.ts +66 -0
- package/dist/types/wire/coreweave.d.ts +12 -0
- package/dist/types/wire/gemini-headers.d.ts +62 -0
- package/dist/types/wire/github-copilot.d.ts +47 -0
- package/dist/types/wire/image-fetchers.d.ts +76 -0
- package/package.json +102 -0
- package/src/build.ts +103 -0
- package/src/compat/anthropic.ts +179 -0
- package/src/compat/apply.ts +15 -0
- package/src/compat/bedrock.ts +153 -0
- package/src/compat/devin.ts +12 -0
- package/src/compat/openai.ts +864 -0
- package/src/discovery/antigravity.ts +257 -0
- package/src/discovery/codex.ts +456 -0
- package/src/discovery/cursor-proto.ts +8329 -0
- package/src/discovery/cursor.ts +409 -0
- package/src/discovery/devin-proto.ts +2037 -0
- package/src/discovery/devin.ts +152 -0
- package/src/discovery/gemini-cli.ts +198 -0
- package/src/discovery/gemini.ts +260 -0
- package/src/discovery/gitlab-duo-workflow.ts +859 -0
- package/src/discovery/index.ts +7 -0
- package/src/discovery/openai-compatible.ts +266 -0
- package/src/discovery/protobuf.ts +1073 -0
- package/src/effort.ts +18 -0
- package/src/fireworks-model-id.ts +50 -0
- package/src/hosts.ts +178 -0
- package/src/identity/bundled.ts +28 -0
- package/src/identity/classify.ts +242 -0
- package/src/identity/dialect.ts +42 -0
- package/src/identity/family.ts +477 -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 +59 -0
- package/src/identity/reference.ts +167 -0
- package/src/index.ts +19 -0
- package/src/model-cache.ts +346 -0
- package/src/model-manager.ts +683 -0
- package/src/model-thinking.ts +925 -0
- package/src/model-tokenizer.ts +75 -0
- package/src/models.json +304657 -0
- package/src/models.json.d.ts +9 -0
- package/src/models.ts +108 -0
- package/src/openai-pricing.ts +29 -0
- package/src/provider-models/bundled-references.ts +87 -0
- package/src/provider-models/cache-provider-id.ts +97 -0
- package/src/provider-models/descriptor-types.ts +85 -0
- package/src/provider-models/descriptors.ts +585 -0
- package/src/provider-models/google.ts +117 -0
- package/src/provider-models/index.ts +7 -0
- package/src/provider-models/ollama.ts +204 -0
- package/src/provider-models/openai-compat.ts +6405 -0
- package/src/provider-models/special.ts +213 -0
- package/src/types.ts +1032 -0
- package/src/utils.ts +69 -0
- package/src/variant-collapse.ts +1555 -0
- package/src/wire/alibaba-token-plan.ts +54 -0
- package/src/wire/codex.ts +117 -0
- package/src/wire/coreweave.ts +51 -0
- package/src/wire/gemini-headers.ts +135 -0
- package/src/wire/github-copilot.ts +147 -0
- package/src/wire/image-fetchers.ts +159 -0
|
@@ -0,0 +1,239 @@
|
|
|
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
|
+
/**
|
|
14
|
+
* Kimi K3 in any namespace form (`kimi-k3`, `kimi-k3.1`, `kimi-k3-turbo`,
|
|
15
|
+
* `moonshotai/kimi-k3`). K3 always reasons and drives thinking via OpenAI-style
|
|
16
|
+
* `reasoning_effort: "max"`, not the K2.x binary `thinking: { type }` block —
|
|
17
|
+
* see the moonshot discovery mapper and `buildOpenAICompat`.
|
|
18
|
+
*/
|
|
19
|
+
export declare const isKimiK3ModelId: (modelId: string) => boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Claude ids in any namespace form: bare (`claude-*`), path-namespaced
|
|
22
|
+
* (`anthropic/claude.x`), or dot-prefixed (`us.anthropic.claude-…`,
|
|
23
|
+
* `global.anthropic.claude-…`, `au.anthropic.claude-…` — Bedrock cross-region
|
|
24
|
+
* inference profiles). Necessary because {@link parseAnthropicModel} only
|
|
25
|
+
* classifies kinds enumerated in its regex, so any dotted profile whose kind
|
|
26
|
+
* (e.g. `haiku`) is not enumerated would otherwise slip past this fallback.
|
|
27
|
+
*/
|
|
28
|
+
export declare const isClaudeModelId: (modelId: string) => boolean;
|
|
29
|
+
/** `anthropic/`-namespaced ids (aggregator catalogs like OpenRouter). */
|
|
30
|
+
export declare const isAnthropicNamespacedModelId: (modelId: string) => boolean;
|
|
31
|
+
/** Qwen family ids (substring match — Qwen SKUs have no stable prefix shape). */
|
|
32
|
+
export declare const isQwenModelId: (modelId: string) => boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Open-weight Qwen 3.8+ releases (`qwen3.8-27b`, `qwen3.8-2.4t-a95b`, GGUF
|
|
35
|
+
* names like `Qwen3.8-27B-UD-Q6_K_XL`) whose chat template steers thinking
|
|
36
|
+
* depth through a `reasoning_effort` template kwarg (`low`/`medium`/`xhigh`,
|
|
37
|
+
* template default `xhigh`; thinking itself cannot be disabled). Compared
|
|
38
|
+
* component-wise so `qwen3.10` sorts after `qwen3.8`. API-only `-max` SKUs are
|
|
39
|
+
* excluded — Dashscope drives them through OpenAI-style `reasoning_effort`
|
|
40
|
+
* with curated compat. The trailing guard rejects parameter-count lookalikes
|
|
41
|
+
* (`qwen-3.8b`) without breaking `qwen3.8-27b`.
|
|
42
|
+
*/
|
|
43
|
+
export declare const isQwen38PlusTemplateEffortModelId: (modelId: string) => boolean;
|
|
44
|
+
/** Gemma open-weights family (`gemma-3-27b-it`, `google/gemma-4-E2B-it`, `gemma2-9b`). */
|
|
45
|
+
export declare const isGemmaModelId: (modelId: string) => boolean;
|
|
46
|
+
/** DeepSeek family by id or display name (proxies often rename the id but keep the name). */
|
|
47
|
+
export declare const isDeepseekModelIdOrName: (modelId: string) => boolean;
|
|
48
|
+
/**
|
|
49
|
+
* DeepSeek V4 Flash SKU in any host/namespace form (`deepseek-v4-flash`, dated
|
|
50
|
+
* `deepseek-v4-flash-0731`, `deepseek-ai/DeepSeek-V4-Flash`). Both V4 SKUs
|
|
51
|
+
* (Flash and Pro) accept the `low` reasoning_effort tier; this predicate keeps
|
|
52
|
+
* Flash distinguishable from Pro where a host quirk splits them (e.g.
|
|
53
|
+
* OpenRouter exposes `low` on Flash but only `high` on non-Flash V4).
|
|
54
|
+
* See https://api-docs.deepseek.com/api/create-chat-completion.
|
|
55
|
+
*/
|
|
56
|
+
export declare const isDeepseekV4FlashModelId: (modelId: string) => boolean;
|
|
57
|
+
/** Xiaomi MiMo family by id or display name. */
|
|
58
|
+
export declare const isMimoModelIdOrName: (modelId: string) => boolean;
|
|
59
|
+
/** StepFun Step 3.7 Flash SKU in any namespace form (`kilo/stepfun/step-3.7-flash:free`). */
|
|
60
|
+
export declare const isStep37FlashModelId: (modelId: string) => boolean;
|
|
61
|
+
/** Gemini family ids in any namespace form (`gemini-*`, `google/gemini-*`, `openrouter/google/gemini-…`). */
|
|
62
|
+
export declare const isGeminiModelId: (modelId: string) => boolean;
|
|
63
|
+
/** Grok family ids across namespace and delimiter forms (`grok-*`, `cursor-grok-*`, `xai/grok-*`). */
|
|
64
|
+
export declare const isGrokModelId: (modelId: string) => boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Grok SKUs that expose the wire `reasoning.effort` dial. Other Grok reasoners
|
|
67
|
+
* (e.g. `grok-build`, `grok-4.20-0309-reasoning`) think natively but reject the
|
|
68
|
+
* param, so callers must omit reasoning effort for them. `grok-4.6` accepts
|
|
69
|
+
* `low`/`medium`/`high`/`xhigh` and 400s on `max`.
|
|
70
|
+
*/
|
|
71
|
+
export declare const isGrokReasoningEffortCapable: (modelId: string) => boolean;
|
|
72
|
+
/**
|
|
73
|
+
* `grok-4.20-multi-agent*` uses `reasoning.effort` to pick agent count
|
|
74
|
+
* (`xhigh` is the 16-agent mode). Other first-party Grok effort SKUs stay on
|
|
75
|
+
* `low|medium|high` unless {@link isGrokXHighEffortCapable} (currently
|
|
76
|
+
* `grok-4.6*` plus multi-agent).
|
|
77
|
+
* https://docs.x.ai/developers/model-capabilities/text/reasoning
|
|
78
|
+
*/
|
|
79
|
+
export declare const isGrokMultiAgentModelId: (modelId: string) => boolean;
|
|
80
|
+
/**
|
|
81
|
+
* First-party Grok SKUs whose Responses wire accepts `reasoning.effort: "xhigh"`.
|
|
82
|
+
* `grok-4.6*` documents xhigh as a reasoning depth; multi-agent uses it as
|
|
83
|
+
* 16-agent mode. `grok-4.5` / `grok-4.3` / `grok-3-mini` do not.
|
|
84
|
+
*/
|
|
85
|
+
export declare const isGrokXHighEffortCapable: (modelId: string) => boolean;
|
|
86
|
+
/**
|
|
87
|
+
* MiniMax M2-generation family (M2, M2.1, M2.5, M2.7, including `-highspeed`/
|
|
88
|
+
* `-lightning`/`-her`/`-turbo` variants, dotless aliases like `minimax-m21`,
|
|
89
|
+
* and short `minimax/m2-…` ids on aggregator hosts). Underlying model accepts
|
|
90
|
+
* only `low|medium|high` for `reasoning_effort` and 400s on `minimal`,
|
|
91
|
+
* `xhigh`, or `none` — so hosts whose default effort map otherwise lowers
|
|
92
|
+
* `minimal` to `none` (Fireworks) or expects the full 5-tier scale must
|
|
93
|
+
* clamp instead. Excludes M1, M3, MiniMax-Text-01, music, hailuo, voice ids.
|
|
94
|
+
*/
|
|
95
|
+
export declare const isMinimaxM2FamilyModelId: (modelId: string) => boolean;
|
|
96
|
+
/** MiniMax M3 family ids in bundled/default and aggregator namespace forms. */
|
|
97
|
+
export declare const isMinimaxM3FamilyModelId: (modelId: string) => boolean;
|
|
98
|
+
/**
|
|
99
|
+
* OpenAI gpt-oss family (`gpt-oss-20b`, `gpt-oss-120b`, `gpt-oss:120b`,
|
|
100
|
+
* `vendor/gpt-oss-…`). The Harmony reasoning format only accepts
|
|
101
|
+
* `low|medium|high` for `reasoning_effort` and rejects `minimal`, `xhigh`,
|
|
102
|
+
* and `none`.
|
|
103
|
+
*/
|
|
104
|
+
export declare const isOpenAIGptOssModelId: (modelId: string) => boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Meta Muse Spark ids (`muse-spark-1.1`, `muse-spark-1.2`,
|
|
107
|
+
* `muse-spark-1.2-contributor`, `meta/muse-spark-1.2`). The Responses
|
|
108
|
+
* `reasoning.effort` wire accepts `none` (thinking-off) plus
|
|
109
|
+
* `minimal`/`low`/`medium`/`high`/`xhigh`.
|
|
110
|
+
*/
|
|
111
|
+
export declare const isMuseSparkModelId: (modelId: string) => boolean;
|
|
112
|
+
/** OpenAI model ids (gpt-*, chatgpt-*, o1/o3/o4 SKUs, codex-*, or openai/*). */
|
|
113
|
+
export declare const isOpenAIModelId: (modelId: string) => boolean;
|
|
114
|
+
/**
|
|
115
|
+
* OpenAI Codex models that honor `reasoning.context: "all_turns"` (full
|
|
116
|
+
* cross-turn reasoning replay). The `reasoning.context` field itself exists for
|
|
117
|
+
* the whole gpt-5/o-series family, but the `all_turns` value is only accepted
|
|
118
|
+
* from gpt-5.4 onward; earlier ids (`gpt-5.1-codex`, `gpt-5.3-codex`, and
|
|
119
|
+
* `gpt-5.3-codex-spark`) reject it with
|
|
120
|
+
* `Unsupported value: 'all_turns' is not supported with this model`. Version
|
|
121
|
+
* floor (not an allowlist) so 5.6/6.x inherit support automatically. Callers
|
|
122
|
+
* fall back to omitting `context`, letting the server default to `current_turn`.
|
|
123
|
+
*/
|
|
124
|
+
export declare const supportsAllTurnsReasoningContext: (modelId: string) => boolean;
|
|
125
|
+
/**
|
|
126
|
+
* OpenAI Codex models that accept `reasoning.summary`. Shares the gpt-5.4 wire
|
|
127
|
+
* floor with {@link supportsAllTurnsReasoningContext}: earlier Codex ids
|
|
128
|
+
* (`gpt-5.1-codex`, `gpt-5.3-codex`, `gpt-5.3-codex-spark`) reject the field
|
|
129
|
+
* with `Unsupported parameter: 'reasoning.summary' is not supported with this
|
|
130
|
+
* model`. Callers omit `summary` for unsupported ids, letting the server skip
|
|
131
|
+
* the human-readable summary stream.
|
|
132
|
+
*/
|
|
133
|
+
export declare const supportsCodexReasoningSummary: (modelId: string) => boolean;
|
|
134
|
+
/**
|
|
135
|
+
* OpenAI proprietary models whose serving path rejects explicit sampling
|
|
136
|
+
* parameters (`temperature`, `top_p`, `top_k`, …) with
|
|
137
|
+
* `400 Unsupported parameter: 'temperature' is not supported with this model`.
|
|
138
|
+
* Covers the o-series and the entire gpt-5+ generation — base, `mini`, `nano`,
|
|
139
|
+
* `codex*`, the `luna`/`sol`/`terra` SKUs, and the `-chat-latest` variants,
|
|
140
|
+
* since even the non-reasoning gpt-5 chat models reject sampling params (see
|
|
141
|
+
* litellm#13781). Holds regardless of which OpenAI-serving host proxies the
|
|
142
|
+
* model (official, Azure, GitHub Copilot). Version floor (not an allowlist) so
|
|
143
|
+
* 6.x inherits automatically. Issue #5606.
|
|
144
|
+
*/
|
|
145
|
+
export declare const isOpenAISamplingRestrictedModelId: (modelId: string) => boolean;
|
|
146
|
+
/**
|
|
147
|
+
* Reasoning-capable GLM coding SKUs: glm-4.5 and up on the base / `-air` /
|
|
148
|
+
* `-turbo` lines. Excludes the vision (`…v`) shape, the non-reasoning
|
|
149
|
+
* `-flash`/`-flashx`/`-preview` variants, and pre-4.5 ids. Matching the family
|
|
150
|
+
* keeps newly-bumped integers (`glm-5.3`, `glm-6`, …) covered without a per-id
|
|
151
|
+
* allowlist.
|
|
152
|
+
*/
|
|
153
|
+
export declare const isReasoningGlmModelId: (modelId: string) => boolean;
|
|
154
|
+
/** GLM-5.2+ coding SKUs accept `reasoning_effort` in addition to binary thinking. */
|
|
155
|
+
export declare const isGlm52ReasoningEffortModelId: (modelId: string) => boolean;
|
|
156
|
+
/**
|
|
157
|
+
* GLM-5.3+ coding SKUs. Unlike GLM-5.2 (whose reasoning_effort dialect is
|
|
158
|
+
* host-specific), GLM-5.3+ exposes a uniform wire-exact `low`/`high`/`max`
|
|
159
|
+
* ladder on every host, and thinking can no longer be disabled —
|
|
160
|
+
* `thinking.type` must always be `enabled`. Matching the family keeps future
|
|
161
|
+
* bumps (`glm-5.4`, `glm-6`, …) covered while excluding the vision (`…v`)
|
|
162
|
+
* shape and the non-reasoning `-flash`/`-flashx`/`-preview` variants.
|
|
163
|
+
*/
|
|
164
|
+
export declare const isGlm53ReasoningEffortModelId: (modelId: string) => boolean;
|
|
165
|
+
/** GLM vision SKUs — the `v` that attaches to the version (`glm-4v`, `glm-4.5v`). */
|
|
166
|
+
export declare const isGlmVisionModelId: (modelId: string) => boolean;
|
|
167
|
+
/**
|
|
168
|
+
* Coarse vendor-lineage token for "are two models the same family?" checks
|
|
169
|
+
* (e.g. picking a cross-family reviewer). All Claude point releases share a token,
|
|
170
|
+
* Claude and GPT differ; namespace prefixes and aggregator mirrors fold onto the
|
|
171
|
+
* lineage via {@link parseKnownModel}'s `bareModelId` normalization. Opaque and
|
|
172
|
+
* comparison-only — not a stable key to persist, since the vocabulary tracks new
|
|
173
|
+
* releases. Returns `""` for ids it cannot classify; callers fall back to the provider.
|
|
174
|
+
*
|
|
175
|
+
* Vendor-only by design: a model's kind/variant (opus vs sonnet, codex vs base) is
|
|
176
|
+
* collapsed onto the single vendor token; use {@link parseKnownModel} for finer breakdowns.
|
|
177
|
+
*/
|
|
178
|
+
export declare const modelFamilyToken: (modelId: string) => string;
|
|
179
|
+
/**
|
|
180
|
+
* True for Claude generations that support extended thinking: Sonnet/Opus 3.7+,
|
|
181
|
+
* every 4.x/5+ Opus/Sonnet, and the Fable/Mythos generation. Pre-thinking
|
|
182
|
+
* models (Claude 3.5 and older) are excluded so no thinking effort dial is
|
|
183
|
+
* fabricated for a model that rejects thinking parameters. Classifier-based, so
|
|
184
|
+
* dotted and dashed version forms both match; ids the classifier does not parse
|
|
185
|
+
* (e.g. Haiku, bare dated ids) return false.
|
|
186
|
+
*/
|
|
187
|
+
export declare const anthropicModelSupportsThinking: (modelId: string) => boolean;
|
|
188
|
+
/**
|
|
189
|
+
* Adaptive thinking `display` is supported starting with Claude Opus 4.7+,
|
|
190
|
+
* Sonnet 5+, and the Claude Fable/Mythos 5 generation. Older adaptive-thinking
|
|
191
|
+
* models (Opus 4.6, Sonnet 4.6) reject the field. Classifier-based, so dotted
|
|
192
|
+
* and dashed version forms both match while bare dated ids
|
|
193
|
+
* (`claude-opus-4-20250514` = Opus 4.0) stay excluded.
|
|
194
|
+
*/
|
|
195
|
+
export declare const supportsAdaptiveThinkingDisplay: (modelId: string) => boolean;
|
|
196
|
+
/**
|
|
197
|
+
* Returns true for Anthropic models with Opus 4.7+, Sonnet 5+, and Fable/Mythos 5+
|
|
198
|
+
* API restrictions:
|
|
199
|
+
* - Sampling parameters (temperature/top_p/top_k) return 400 error
|
|
200
|
+
* - Thinking content is omitted by default (needs display: "summarized")
|
|
201
|
+
*/
|
|
202
|
+
export declare const hasOpus47ApiRestrictions: (modelId: string) => boolean;
|
|
203
|
+
/**
|
|
204
|
+
* Mid-conversation `role: "system"` messages (system instructions appended at
|
|
205
|
+
* non-first positions in the `messages` array) are supported starting with
|
|
206
|
+
* Claude Opus 4.8+, Sonnet 5+, and the Claude Fable/Mythos 5 generation.
|
|
207
|
+
* Earlier Claude models reject the role.
|
|
208
|
+
* @see https://platform.claude.com/docs/en/build-with-claude/mid-conversation-system-messages
|
|
209
|
+
*/
|
|
210
|
+
export declare const supportsMidConversationSystemMessages: (modelId: string) => boolean;
|
|
211
|
+
/**
|
|
212
|
+
* Models that reliably follow the hashline line-anchored edit dialect
|
|
213
|
+
* (`[path#TAG]` headers plus 1-indexed anchors). Kimi, MiMo, DeepSeek V4
|
|
214
|
+
* Flash, and Step 3.7 Flash miscount anchors or drop the tag header often
|
|
215
|
+
* enough that hosts fall back to the sloppy edit format for
|
|
216
|
+
* them.
|
|
217
|
+
*/
|
|
218
|
+
export declare const supportsHashlineEdits: (modelId: string) => boolean;
|
|
219
|
+
export declare const isAnthropicFableOrMythosModel: (modelId: string) => boolean;
|
|
220
|
+
/** Thinking-variant token location inside a model id. */
|
|
221
|
+
export interface ThinkingVariantToken {
|
|
222
|
+
index: number;
|
|
223
|
+
length: number;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Locates the first thinking-variant token (`-thinking`, `-reasoner`,
|
|
227
|
+
* `-reasoning`; trailing or infix) in a model id. The token ends at the id
|
|
228
|
+
* end or any non-alphanumeric boundary, and negated forms (`non-thinking`,
|
|
229
|
+
* `no-thinking`) never match — those name the NON-thinking SKU.
|
|
230
|
+
*/
|
|
231
|
+
export declare function findThinkingVariantToken(modelId: string): ThinkingVariantToken | undefined;
|
|
232
|
+
/**
|
|
233
|
+
* Removes the located thinking-variant token: `kimi-k2-thinking` → `kimi-k2`,
|
|
234
|
+
* `mimo-v2-flash-thinking-original` → `mimo-v2-flash-original`,
|
|
235
|
+
* `grok-4.1-fast-reasoning` → `grok-4.1-fast`. Returns `undefined` when no
|
|
236
|
+
* token exists or nothing would remain. Callers MUST verify the result names
|
|
237
|
+
* a live model.
|
|
238
|
+
*/
|
|
239
|
+
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,29 @@
|
|
|
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, ThinkingConfig } from "../types.js";
|
|
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
|
+
/**
|
|
23
|
+
* Inherit bundled reference thinking only for same-provider matches. Wire routing
|
|
24
|
+
* (`effortRouting`) is provider-specific; cross-provider inheritance can rewrite
|
|
25
|
+
* gateway ids (e.g. Portkey `@modal/GLM-5-2-FP8` → devin `glm-5-2`).
|
|
26
|
+
*/
|
|
27
|
+
export declare function inheritReferenceThinking(modelThinking: ThinkingConfig | undefined, reference: Pick<Model<Api>, "provider" | "thinking"> | undefined, provider: string): ThinkingConfig | undefined;
|
|
28
|
+
/** Resolve a (possibly proxied/affixed) model id to its bundled upstream reference. */
|
|
29
|
+
export declare function resolveModelReference(modelId: string, index: ModelReferenceIndex): Model<Api> | undefined;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export * from "./compat/openai.js";
|
|
2
|
+
export * from "./discovery/index.js";
|
|
3
|
+
export * from "./effort.js";
|
|
4
|
+
export * from "./fireworks-model-id.js";
|
|
5
|
+
export * from "./identity/index.js";
|
|
6
|
+
export * from "./model-cache.js";
|
|
7
|
+
export * from "./model-manager.js";
|
|
8
|
+
export * from "./model-thinking.js";
|
|
9
|
+
export * from "./model-tokenizer.js";
|
|
10
|
+
export * from "./models.js";
|
|
11
|
+
export * from "./provider-models/index.js";
|
|
12
|
+
export * from "./types.js";
|
|
13
|
+
export * from "./utils.js";
|
|
14
|
+
export * from "./variant-collapse.js";
|
|
15
|
+
export * from "./wire/codex.js";
|
|
16
|
+
export * from "./wire/coreweave.js";
|
|
17
|
+
export * from "./wire/gemini-headers.js";
|
|
18
|
+
export * from "./wire/github-copilot.js";
|
|
19
|
+
export * from "./wire/image-fetchers.js";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Api, Model, ModelSpec } from "./types.js";
|
|
2
|
+
interface CacheEntry<TApi extends Api = Api> {
|
|
3
|
+
models: ModelSpec<TApi>[];
|
|
4
|
+
fresh: boolean;
|
|
5
|
+
authoritative: boolean;
|
|
6
|
+
updatedAt: number;
|
|
7
|
+
/** Model ids whose live headers were intentionally omitted from disk. */
|
|
8
|
+
headerOmittedModelIds: readonly string[];
|
|
9
|
+
/** Header-bearing model ids that cannot be rebuilt from the static source. */
|
|
10
|
+
unrestorableHeaderModelIds: readonly string[];
|
|
11
|
+
/** Whether unrestorable markers predate request-model header matching. */
|
|
12
|
+
legacyHeaderRestoreMarkers: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Hash of the static catalog slice that was merged into `models` when this
|
|
15
|
+
* row was written. `resolveProviderModels` compares against the current
|
|
16
|
+
* static fingerprint and bypasses the static+cache re-merge when they
|
|
17
|
+
* match — the cache already incorporates the same static state.
|
|
18
|
+
*/
|
|
19
|
+
staticFingerprint: string;
|
|
20
|
+
}
|
|
21
|
+
export declare function readModelCache<TApi extends Api>(providerId: string, ttlMs: number, now: () => number, dbPath?: string): CacheEntry<TApi> | null;
|
|
22
|
+
export declare function writeModelCache<TApi extends Api>(providerId: string, updatedAt: number, models: Model<TApi>[], authoritative: boolean, staticFingerprint: string, dbPath?: string, staticHeaderSources?: readonly Model<TApi>[], restorableHeaderFallback?: Record<string, string>): void;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { Api, Model, ModelSpec, Provider } from "./types.js";
|
|
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 stencil.so 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 stencil.so). */
|
|
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: 2h (`DEFAULT_CACHE_TTL_MS`). */
|
|
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 whose presence forces refresh when the static or migration-policy fingerprint changes. */
|
|
32
|
+
dropCachedModelIdsOnStaticMismatch?: readonly string[];
|
|
33
|
+
/**
|
|
34
|
+
* Trusted, provider-wide request headers that can be safely re-derived at
|
|
35
|
+
* cache-read time. The cache never persists their values. Models whose live
|
|
36
|
+
* headers matched this record at write time can survive offline reads without
|
|
37
|
+
* a bundled static source, including configured discovery providers whose
|
|
38
|
+
* bearer header comes from the current local config.
|
|
39
|
+
*/
|
|
40
|
+
restorableHeaderFallback?: Record<string, string>;
|
|
41
|
+
/** Optional dynamic endpoint fetcher. */
|
|
42
|
+
fetchDynamicModels?: () => Promise<readonly ModelSpec<TApi>[] | null>;
|
|
43
|
+
/** Optional stencil.so fallback hook. */
|
|
44
|
+
modelsDev?: ModelsDevFallback<TApi, TModelsDevPayload>;
|
|
45
|
+
/** Clock override for deterministic tests. */
|
|
46
|
+
now?: () => number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Resolution result.
|
|
50
|
+
*
|
|
51
|
+
* `stale` is false when the resolved catalog is authoritative for the selected provider:
|
|
52
|
+
* - a dynamic endpoint fetch succeeded in this call (an empty catalog is still
|
|
53
|
+
* authoritative for the cycle, so downstream pruning of removed models runs),
|
|
54
|
+
* - a still-fresh authoritative cache was reused in `online-if-uncached` mode, or
|
|
55
|
+
* - the provider has no dynamic fetcher configured.
|
|
56
|
+
*/
|
|
57
|
+
export interface ModelResolutionResult<TApi extends Api = Api> {
|
|
58
|
+
models: Model<TApi>[];
|
|
59
|
+
stale: boolean;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Stateful facade over provider model resolution.
|
|
63
|
+
*/
|
|
64
|
+
export interface ModelManager<TApi extends Api = Api> {
|
|
65
|
+
refresh(strategy?: ModelRefreshStrategy): Promise<ModelResolutionResult<TApi>>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Creates a reusable provider model manager.
|
|
69
|
+
*/
|
|
70
|
+
export declare function createModelManager<TApi extends Api = Api, TModelsDevPayload = unknown>(options: ModelManagerOptions<TApi, TModelsDevPayload>): ModelManager<TApi>;
|
|
71
|
+
/**
|
|
72
|
+
* Resolves provider models with source precedence:
|
|
73
|
+
* static -> stencil.so -> cache -> dynamic.
|
|
74
|
+
*
|
|
75
|
+
* Later sources override earlier ones by model id.
|
|
76
|
+
*/
|
|
77
|
+
export declare function resolveProviderModels<TApi extends Api = Api, TModelsDevPayload = unknown>(options: ModelManagerOptions<TApi, TModelsDevPayload>, strategy?: ModelRefreshStrategy): Promise<ModelResolutionResult<TApi>>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thinking metadata: build-time derivation and runtime field-read helpers.
|
|
3
|
+
*
|
|
4
|
+
* Derivation (`resolveModelThinking`) runs exactly once per model — from
|
|
5
|
+
* `buildModel` for dynamic specs and from the catalog generator for bundled
|
|
6
|
+
* entries. Everything below the "runtime helpers" divider reads baked fields
|
|
7
|
+
* only: no id parsing, no host matching, no compat detection per request.
|
|
8
|
+
*/
|
|
9
|
+
import { Effort } from "./effort.js";
|
|
10
|
+
import type { Api, CompatOf, Model, ModelSpec, ThinkingConfig } from "./types.js";
|
|
11
|
+
/**
|
|
12
|
+
* Runtime helpers read baked metadata only, so they accept both pre-build
|
|
13
|
+
* specs and built models.
|
|
14
|
+
*/
|
|
15
|
+
type ApiModel<TApi extends Api = Api> = ModelSpec<TApi> | Model<TApi>;
|
|
16
|
+
/**
|
|
17
|
+
* Resolve the canonical thinking metadata for a spec. Called exactly once per
|
|
18
|
+
* model by `buildModel`, after compat resolution.
|
|
19
|
+
*
|
|
20
|
+
* - Non-reasoning models never carry thinking.
|
|
21
|
+
* - Models that reason natively but reject the wire effort param
|
|
22
|
+
* (`compat.supportsReasoningEffort: false` on openai-responses*) carry no
|
|
23
|
+
* thinking either: `reasoning: true, thinking: undefined` IS the encoding
|
|
24
|
+
* for "thinks, but exposes no control surface".
|
|
25
|
+
* - Explicit spec thinking (generator-baked or user-authored) owns the
|
|
26
|
+
* capability surface (`mode`, `efforts`, `defaultLevel`); the wire facts
|
|
27
|
+
* (`effortMap`, `supportsDisplay`) are backfilled from identity when not
|
|
28
|
+
* explicitly set, so configs never need to know provider wire tier tables.
|
|
29
|
+
* - Sparse specs go through full inference.
|
|
30
|
+
*/
|
|
31
|
+
export declare function resolveModelThinking<TApi extends Api>(spec: ModelSpec<TApi>, compat: CompatOf<TApi>): ThinkingConfig | undefined;
|
|
32
|
+
/** Derive thinking from identity + resolved compat, ignoring any baked value. Generator-side entry. */
|
|
33
|
+
export declare function deriveThinking<TApi extends Api>(spec: ModelSpec<TApi>, compat: CompatOf<TApi>): ThinkingConfig;
|
|
34
|
+
/**
|
|
35
|
+
* Returns the supported thinking efforts declared on the model metadata.
|
|
36
|
+
* Empty for non-reasoning models and for reasoning models without a
|
|
37
|
+
* controllable effort surface (`thinking: undefined`).
|
|
38
|
+
*/
|
|
39
|
+
export declare function getSupportedEfforts<TApi extends Api>(model: ApiModel<TApi>): readonly Effort[];
|
|
40
|
+
/**
|
|
41
|
+
* Clamps a requested thinking level against explicit model metadata.
|
|
42
|
+
*
|
|
43
|
+
* Non-reasoning models always resolve to `undefined`.
|
|
44
|
+
*/
|
|
45
|
+
export declare function clampThinkingLevelForModel<TApi extends Api>(model: ApiModel<TApi> | undefined, requested: Effort | undefined): Effort | undefined;
|
|
46
|
+
export declare function requireSupportedEffort<TApi extends Api>(model: ApiModel<TApi>, effort: Effort): Effort;
|
|
47
|
+
/** Maps a normalized thinking effort to Google's `thinkingLevel` enum values.
|
|
48
|
+
* When a collapsed family routes `minimal` onto the same wire id as `low`
|
|
49
|
+
* (Antigravity Gemini 3.6/3.7 Flash), emit `LOW` — Cloud Code Assist rejects
|
|
50
|
+
* `MINIMAL` on those `-low` SKUs.
|
|
51
|
+
*/
|
|
52
|
+
export declare function mapEffortToGoogleThinkingLevel<TApi extends Api>(effort: Effort, model?: ApiModel<TApi>): "MINIMAL" | "LOW" | "MEDIUM" | "HIGH";
|
|
53
|
+
/**
|
|
54
|
+
* Maps a normalized thinking effort to Anthropic adaptive effort values via
|
|
55
|
+
* the model's baked `thinking.effortMap` (identity for unmapped efforts).
|
|
56
|
+
*/
|
|
57
|
+
export declare function mapEffortToAnthropicAdaptiveEffort<TApi extends Api>(model: ApiModel<TApi>, effort: Effort): "low" | "medium" | "high" | "xhigh" | "max" | "adaptive";
|
|
58
|
+
/**
|
|
59
|
+
* Resolves the upstream wire model id for a request at the given effort
|
|
60
|
+
* (`undefined` = thinking off). Collapsed effort-tier variants route through
|
|
61
|
+
* `thinking.effortRouting`; everything else falls back to
|
|
62
|
+
* `requestModelId ?? id`.
|
|
63
|
+
*/
|
|
64
|
+
export declare function resolveWireModelId<TApi extends Api>(model: ApiModel<TApi>, effort: Effort | undefined): string;
|
|
65
|
+
/**
|
|
66
|
+
* Lowest supported effort in canonical order — the clamp target for
|
|
67
|
+
* thinking-off requests on `thinking.requiresEffort` models.
|
|
68
|
+
*/
|
|
69
|
+
export declare function minimumSupportedEffort<TApi extends Api>(model: ApiModel<TApi>): Effort | undefined;
|
|
70
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ModelTokenizer } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Resolve the exact locally embedded tokenizer for a canonical model id.
|
|
4
|
+
*
|
|
5
|
+
* This is catalog policy, not a runtime caller heuristic: [`buildModel`](./build.ts)
|
|
6
|
+
* materializes the result as `Model.tokenizer`; consumers read that property.
|
|
7
|
+
*/
|
|
8
|
+
export declare function resolveModelTokenizer(modelId: string): ModelTokenizer | undefined;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import MODELS from "./models.json";
|
|
2
|
+
import type { Api, KnownProvider, Model, Usage } from "./types.js";
|
|
3
|
+
export type GeneratedProvider = keyof typeof MODELS;
|
|
4
|
+
export declare function getBundledModel<TApi extends Api = Api>(provider: GeneratedProvider, modelId: string): Model<TApi>;
|
|
5
|
+
export declare function getBundledProviders(): KnownProvider[];
|
|
6
|
+
export declare function getBundledModels(provider: GeneratedProvider): Model<Api>[];
|
|
7
|
+
/** Price a prompt as fully uncached input under its active context-length tier. */
|
|
8
|
+
export declare function calculateUncachedInputCost(cost: Model["cost"], promptInputTokens: number): number;
|
|
9
|
+
export declare function calculateCost<TApi extends Api>(model: Model<TApi>, usage: Usage): Usage["cost"];
|
|
10
|
+
/**
|
|
11
|
+
* Check if two models are equal by comparing both their id and provider.
|
|
12
|
+
* Returns false if either model is null or undefined.
|
|
13
|
+
*/
|
|
14
|
+
export declare function modelsAreEqual<TApi extends Api>(a: Model<TApi> | null | undefined, b: Model<TApi> | null | undefined): boolean;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { TokenCost } from "./types.js";
|
|
2
|
+
/** Standard GPT-5.6 Sol rates used by the Daybreak Blue aliases. */
|
|
3
|
+
export declare const OPENAI_GPT_56_SOL_STANDARD_COST: {
|
|
4
|
+
readonly input: 5;
|
|
5
|
+
readonly output: 30;
|
|
6
|
+
readonly cacheRead: 0.5;
|
|
7
|
+
readonly cacheWrite: 6.25;
|
|
8
|
+
};
|
|
9
|
+
/** Standard GPT-5.6 Cyber rates used by the Daybreak Red aliases. */
|
|
10
|
+
export declare const OPENAI_GPT_56_CYBER_STANDARD_COST: {
|
|
11
|
+
readonly input: 12.5;
|
|
12
|
+
readonly output: 75;
|
|
13
|
+
readonly cacheRead: 1.25;
|
|
14
|
+
readonly cacheWrite: 15.625;
|
|
15
|
+
};
|
|
16
|
+
/** Resolve standard rates for Codex-prefixed Daybreak aliases. */
|
|
17
|
+
export declare function resolveOpenAIDaybreakStandardCost(modelId: string): TokenCost | undefined;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { getBundledModels } from "../models.js";
|
|
2
|
+
import type { Api, Model, ModelSpec } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Project a built `Model` back to spec stage: `compat` becomes the verbatim
|
|
5
|
+
* sparse override record (`compatConfig`), never the resolved view. Discovery
|
|
6
|
+
* mappers spread these references into the specs they hand to the model
|
|
7
|
+
* manager, which rebuilds via `buildModel`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function toModelSpec<TApi extends Api>(model: Model<TApi>): ModelSpec<TApi>;
|
|
10
|
+
export declare function createBundledReferenceMap<TApi extends Api>(provider: Parameters<typeof getBundledModels>[0]): Map<string, ModelSpec<TApi>>;
|
|
11
|
+
type ProviderReferenceSource<TApi extends Api> = Map<string, ModelSpec<TApi>> | (() => Map<string, ModelSpec<TApi>>);
|
|
12
|
+
export declare function createReferenceResolver<TApi extends Api>(providerReferenceSource: ProviderReferenceSource<TApi>): (modelId: string) => ModelSpec<TApi> | undefined;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface ModelCacheProviderIdOptions {
|
|
2
|
+
apiKey?: string;
|
|
3
|
+
baseUrl?: string;
|
|
4
|
+
}
|
|
5
|
+
/** Whether a provider's model-cache namespace requires its resolved credential. */
|
|
6
|
+
export declare function isCredentialScopedModelCacheProvider(providerId: string): boolean;
|
|
7
|
+
export declare function getDefaultModelDiscoveryBaseUrl(providerId: string): string | undefined;
|
|
8
|
+
/** Resolve an Ollama model-cache namespace scoped to the normalized discovery endpoint. */
|
|
9
|
+
export declare function resolveOllamaModelCacheProviderId(providerId: string, baseUrl?: string): string;
|
|
10
|
+
/** Resolve the cache namespace used by a provider's model-manager options without constructing those options. */
|
|
11
|
+
export declare function resolveModelCacheProviderId(providerId: string, options?: ModelCacheProviderIdOptions): string;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { ModelManagerOptions } from "../model-manager.js";
|
|
2
|
+
import type { Api, FetchImpl } from "../types.js";
|
|
3
|
+
/** Config passed to a provider's runtime model-manager factory. */
|
|
4
|
+
export type ModelManagerConfig = {
|
|
5
|
+
apiKey?: string;
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
fetch?: FetchImpl;
|
|
8
|
+
/** The supplied fetch already applies provider-specific authentication. */
|
|
9
|
+
authenticated?: boolean;
|
|
10
|
+
};
|
|
11
|
+
/** Catalog discovery configuration for providers that support endpoint-based model listing. */
|
|
12
|
+
export interface CatalogDiscoveryConfig {
|
|
13
|
+
/** Human-readable name for log messages. */
|
|
14
|
+
label: string;
|
|
15
|
+
/**
|
|
16
|
+
* Environment variables to check for API keys during catalog generation.
|
|
17
|
+
* Defaults to the entry-level `envVars` when omitted.
|
|
18
|
+
*/
|
|
19
|
+
envVars?: readonly string[];
|
|
20
|
+
/** OAuth provider for credential refresh during catalog generation. */
|
|
21
|
+
oauthProvider?: string;
|
|
22
|
+
/** When true, catalog discovery proceeds even without credentials. */
|
|
23
|
+
allowUnauthenticated?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/** Unified provider descriptor used by both runtime discovery and catalog generation. */
|
|
26
|
+
export interface ProviderDescriptor {
|
|
27
|
+
providerId: string;
|
|
28
|
+
createModelManagerOptions(config: ModelManagerConfig): ModelManagerOptions<Api>;
|
|
29
|
+
/** Preferred model ID when no explicit selection is made. */
|
|
30
|
+
defaultModel: string;
|
|
31
|
+
/** When true, the runtime creates a model manager even without a valid API key (e.g. ollama). */
|
|
32
|
+
allowUnauthenticated?: boolean;
|
|
33
|
+
/** When true, successful runtime discovery replaces bundled provider models instead of merging fallback-only IDs. */
|
|
34
|
+
dynamicModelsAuthoritative?: boolean;
|
|
35
|
+
/** Catalog discovery configuration. Only providers with this field participate in generate-models.ts. */
|
|
36
|
+
catalogDiscovery?: CatalogDiscoveryConfig;
|
|
37
|
+
}
|
|
38
|
+
/** A provider descriptor that has catalog discovery configured. */
|
|
39
|
+
export type CatalogProviderDescriptor = ProviderDescriptor & {
|
|
40
|
+
catalogDiscovery: CatalogDiscoveryConfig;
|
|
41
|
+
};
|
|
42
|
+
/** Type guard for descriptors with catalog discovery. */
|
|
43
|
+
export declare function isCatalogDescriptor(d: ProviderDescriptor): d is CatalogProviderDescriptor;
|
|
44
|
+
/** Whether catalog discovery may run without provider credentials. */
|
|
45
|
+
export declare function allowsUnauthenticatedCatalogDiscovery(descriptor: CatalogProviderDescriptor): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* One model provider's catalog-side description. The auth half of a provider
|
|
48
|
+
* (env keys, OAuth login/refresh flows) lives in `@oh-my-pi/pi-ai`'s registry;
|
|
49
|
+
* the catalog table below is the single source of truth for ids, default
|
|
50
|
+
* models, and discovery wiring.
|
|
51
|
+
*
|
|
52
|
+
* - Every entry is a member of `KnownProvider`.
|
|
53
|
+
* - `createModelManagerOptions` present (and not `specialModelManager`) ⇒
|
|
54
|
+
* appears in `PROVIDER_DESCRIPTORS` for runtime model discovery.
|
|
55
|
+
* - \`catalogDiscovery\` present ⇒ participates in \`generate-models.ts\`.
|
|
56
|
+
*/
|
|
57
|
+
export interface ProviderCatalogEntry {
|
|
58
|
+
readonly id: string;
|
|
59
|
+
/** Preferred model ID when no explicit selection is made. */
|
|
60
|
+
readonly defaultModel: string;
|
|
61
|
+
/** Environment variables consulted (in order) for the provider's runtime API-key env fallback. */
|
|
62
|
+
readonly envVars?: readonly string[];
|
|
63
|
+
/** Runtime model-manager factory. Omitted for catalog-only providers. */
|
|
64
|
+
readonly createModelManagerOptions?: (config: ModelManagerConfig) => ModelManagerOptions<Api>;
|
|
65
|
+
/** When true, the runtime creates a model manager even without a valid API key. */
|
|
66
|
+
readonly allowUnauthenticated?: boolean;
|
|
67
|
+
/** When true, successful runtime discovery replaces bundled provider models. */
|
|
68
|
+
readonly dynamicModelsAuthoritative?: boolean;
|
|
69
|
+
/** Catalog discovery configuration for generate-models.ts. */
|
|
70
|
+
readonly catalogDiscovery?: CatalogDiscoveryConfig;
|
|
71
|
+
/**
|
|
72
|
+
* Built bespoke by the coding-agent runtime (OAuth-token-driven managers);
|
|
73
|
+
* excluded from `PROVIDER_DESCRIPTORS` even though models are discoverable.
|
|
74
|
+
*/
|
|
75
|
+
readonly specialModelManager?: boolean;
|
|
76
|
+
}
|