@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,204 @@
|
|
|
1
|
+
import { fetchWithRetry } from "@rigelbuild/omp-utils";
|
|
2
|
+
import { Effort } from "../effort";
|
|
3
|
+
import { isGlm52ReasoningEffortModelId } from "../identity/family";
|
|
4
|
+
import type { ModelManagerOptions } from "../model-manager";
|
|
5
|
+
import type { FetchImpl, ModelSpec, ThinkingConfig } from "../types";
|
|
6
|
+
import { discoveryFetch } from "../utils";
|
|
7
|
+
import { createBundledReferenceMap, createReferenceResolver } from "./bundled-references";
|
|
8
|
+
|
|
9
|
+
export interface OllamaCloudModelManagerConfig {
|
|
10
|
+
apiKey?: string;
|
|
11
|
+
baseUrl?: string;
|
|
12
|
+
fetch?: FetchImpl;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
type OllamaTagEntry = {
|
|
16
|
+
name?: string;
|
|
17
|
+
model?: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type OllamaShowResponse = {
|
|
21
|
+
capabilities?: string[];
|
|
22
|
+
model_info?: Record<string, unknown>;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const OLLAMA_RETRY_DELAYS_MS = [2_000, 5_000, 10_000];
|
|
26
|
+
/**
|
|
27
|
+
* Output-token ceiling that Ollama Cloud enforces for the DeepSeek V4 Pro/Flash
|
|
28
|
+
* deployments: `/api/chat` rejects `num_predict` above it with HTTP 400
|
|
29
|
+
* (`max_tokens (...) exceeds model's maximum output tokens (65536)`) even though
|
|
30
|
+
* the model pages advertise a 1M context / 384K output. Ollama's `/api/show`
|
|
31
|
+
* never reports this cap, so the catalog pins it for the affected models
|
|
32
|
+
* (ollama/ollama#16890, #7266). The wire layer clamps `num_predict` to the same
|
|
33
|
+
* value (`OLLAMA_CLOUD_NUM_PREDICT_CAP` in `packages/ai/src/providers/ollama.ts`,
|
|
34
|
+
* #3392/#3394).
|
|
35
|
+
*/
|
|
36
|
+
export const OLLAMA_CLOUD_MAX_OUTPUT_TOKENS = 65_536;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Untagged base ids whose Ollama Cloud deployment enforces
|
|
40
|
+
* {@link OLLAMA_CLOUD_MAX_OUTPUT_TOKENS}. Only DeepSeek V4 Pro/Flash are known
|
|
41
|
+
* to cap output below their advertised window (ollama/ollama#16890); other cloud
|
|
42
|
+
* models keep their discovered limits.
|
|
43
|
+
*/
|
|
44
|
+
const OLLAMA_CLOUD_OUTPUT_CAPPED_BASE_IDS: Record<string, true> = {
|
|
45
|
+
"deepseek-v4-flash": true,
|
|
46
|
+
"deepseek-v4-pro": true,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/** Whether an Ollama Cloud model id (tagged or not) enforces the 65536 output cap. */
|
|
50
|
+
export function isOllamaCloudOutputCapped(id: string): boolean {
|
|
51
|
+
const separator = id.indexOf(":");
|
|
52
|
+
const baseId = separator > 0 ? id.slice(0, separator) : id;
|
|
53
|
+
return OLLAMA_CLOUD_OUTPUT_CAPPED_BASE_IDS[baseId] === true;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const OLLAMA_CLOUD_GLM_52_THINKING: ThinkingConfig = {
|
|
57
|
+
mode: "effort",
|
|
58
|
+
efforts: [Effort.High, Effort.Max],
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
function trimTrailingSlash(value: string): string {
|
|
62
|
+
return value.endsWith("/") ? value.slice(0, -1) : value;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function normalizeOllamaCloudBaseUrl(baseUrl?: string): string {
|
|
66
|
+
const value = baseUrl?.trim();
|
|
67
|
+
if (!value) {
|
|
68
|
+
return "https://ollama.com";
|
|
69
|
+
}
|
|
70
|
+
const trimmed = trimTrailingSlash(value);
|
|
71
|
+
return trimmed.endsWith("/api") ? trimmed.slice(0, -4) : trimmed;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function createCloudHeaders(apiKey: string): Record<string, string> {
|
|
75
|
+
return {
|
|
76
|
+
Accept: "application/json",
|
|
77
|
+
Authorization: `Bearer ${apiKey}`,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function getContextWindow(modelInfo: Record<string, unknown> | undefined): number | undefined {
|
|
82
|
+
if (!modelInfo) {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
for (const [key, value] of Object.entries(modelInfo)) {
|
|
86
|
+
if (typeof value !== "number") {
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if (key.endsWith(".context_length") || key.endsWith(".num_ctx") || key.endsWith(".context_window")) {
|
|
90
|
+
return value;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function getThinkingConfig(modelId: string, capabilities: string[] | undefined): ThinkingConfig | undefined {
|
|
96
|
+
if (!capabilities?.includes("thinking")) {
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
if (isGlm52ReasoningEffortModelId(modelId)) {
|
|
100
|
+
return OLLAMA_CLOUD_GLM_52_THINKING;
|
|
101
|
+
}
|
|
102
|
+
return { mode: "effort", efforts: [Effort.Minimal, Effort.Low, Effort.Medium, Effort.High] };
|
|
103
|
+
}
|
|
104
|
+
async function fetchShowMetadata(
|
|
105
|
+
baseUrl: string,
|
|
106
|
+
apiKey: string,
|
|
107
|
+
model: string,
|
|
108
|
+
fetchImpl: FetchImpl = discoveryFetch(),
|
|
109
|
+
): Promise<OllamaShowResponse | undefined> {
|
|
110
|
+
const response = await fetchImpl(`${baseUrl}/api/show`, {
|
|
111
|
+
method: "POST",
|
|
112
|
+
headers: {
|
|
113
|
+
...createCloudHeaders(apiKey),
|
|
114
|
+
"Content-Type": "application/json",
|
|
115
|
+
},
|
|
116
|
+
body: JSON.stringify({ model }),
|
|
117
|
+
});
|
|
118
|
+
if (!response.ok) {
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
return (await response.json()) as OllamaShowResponse;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function ollamaCloudModelManagerOptions(
|
|
125
|
+
config?: OllamaCloudModelManagerConfig,
|
|
126
|
+
): ModelManagerOptions<"ollama-chat"> {
|
|
127
|
+
const apiKey = config?.apiKey;
|
|
128
|
+
const baseUrl = normalizeOllamaCloudBaseUrl(config?.baseUrl);
|
|
129
|
+
let providerReferences: Map<string, ModelSpec<"ollama-chat">> | undefined;
|
|
130
|
+
const getProviderReferences = () =>
|
|
131
|
+
(providerReferences ??= createBundledReferenceMap<"ollama-chat">("ollama-cloud"));
|
|
132
|
+
const resolveReference = createReferenceResolver(getProviderReferences);
|
|
133
|
+
return {
|
|
134
|
+
providerId: "ollama-cloud",
|
|
135
|
+
fetchDynamicModels: async () => {
|
|
136
|
+
if (!apiKey) {
|
|
137
|
+
return [];
|
|
138
|
+
}
|
|
139
|
+
const response = await fetchWithRetry(`${baseUrl}/api/tags`, {
|
|
140
|
+
method: "GET",
|
|
141
|
+
headers: createCloudHeaders(apiKey),
|
|
142
|
+
fetch: discoveryFetch(config?.fetch),
|
|
143
|
+
defaultDelayMs: OLLAMA_RETRY_DELAYS_MS,
|
|
144
|
+
});
|
|
145
|
+
if (!response.ok) {
|
|
146
|
+
throw new Error(`HTTP ${response.status} from ${baseUrl}/api/tags`);
|
|
147
|
+
}
|
|
148
|
+
const payload = (await response.json()) as { models?: OllamaTagEntry[] };
|
|
149
|
+
const entries = payload.models ?? [];
|
|
150
|
+
const models = await Promise.all(
|
|
151
|
+
entries.map(async entry => {
|
|
152
|
+
const id = entry.model ?? entry.name;
|
|
153
|
+
if (!id) {
|
|
154
|
+
return undefined;
|
|
155
|
+
}
|
|
156
|
+
const reference = resolveReference(id);
|
|
157
|
+
const providerReference = getProviderReferences().get(id);
|
|
158
|
+
let metadata: OllamaShowResponse | undefined;
|
|
159
|
+
try {
|
|
160
|
+
metadata = await fetchShowMetadata(baseUrl, apiKey, id, config?.fetch);
|
|
161
|
+
} catch {
|
|
162
|
+
metadata = undefined;
|
|
163
|
+
}
|
|
164
|
+
const capabilities = metadata?.capabilities;
|
|
165
|
+
const discoveredContextWindow = getContextWindow(metadata?.model_info);
|
|
166
|
+
// `/api/show` reports the context length but never a per-model output
|
|
167
|
+
// cap. DeepSeek V4 Pro/Flash deployments enforce a 65536 output ceiling
|
|
168
|
+
// (ollama/ollama#16890, #7266); every other id keeps the trusted
|
|
169
|
+
// reference limit, falling back to the historical safe cap otherwise.
|
|
170
|
+
const contextWindow = discoveredContextWindow ?? 128000;
|
|
171
|
+
const reasoning = capabilities ? capabilities.includes("thinking") : (reference?.reasoning ?? false);
|
|
172
|
+
const thinking = capabilities ? getThinkingConfig(id, capabilities) : reference?.thinking;
|
|
173
|
+
const input = capabilities
|
|
174
|
+
? capabilities.includes("vision")
|
|
175
|
+
? (["text", "image"] as Array<"text" | "image">)
|
|
176
|
+
: (["text"] as Array<"text">)
|
|
177
|
+
: ((reference?.input as Array<"text" | "image"> | undefined) ?? (["text"] as Array<"text">));
|
|
178
|
+
const resolvedName = entry.name && entry.name !== id ? entry.name : (reference?.name ?? id);
|
|
179
|
+
return {
|
|
180
|
+
id,
|
|
181
|
+
name: resolvedName,
|
|
182
|
+
api: "ollama-chat" as const,
|
|
183
|
+
provider: "ollama-cloud" as const,
|
|
184
|
+
baseUrl,
|
|
185
|
+
reasoning,
|
|
186
|
+
thinking,
|
|
187
|
+
input,
|
|
188
|
+
cost: reference?.cost ?? { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
189
|
+
contextWindow,
|
|
190
|
+
maxTokens: isOllamaCloudOutputCapped(id)
|
|
191
|
+
? Math.min(contextWindow, OLLAMA_CLOUD_MAX_OUTPUT_TOKENS)
|
|
192
|
+
: discoveredContextWindow !== null && discoveredContextWindow !== undefined
|
|
193
|
+
? (providerReference?.maxTokens ?? Math.min(contextWindow, 8192))
|
|
194
|
+
: Math.min(contextWindow, 8192),
|
|
195
|
+
omitMaxOutputTokens: true,
|
|
196
|
+
};
|
|
197
|
+
}),
|
|
198
|
+
);
|
|
199
|
+
return models
|
|
200
|
+
.filter((model): model is NonNullable<(typeof models)[number]> => model !== undefined)
|
|
201
|
+
.sort((left, right) => left.id.localeCompare(right.id));
|
|
202
|
+
},
|
|
203
|
+
};
|
|
204
|
+
}
|