@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.
Files changed (117) hide show
  1. package/CHANGELOG.md +1204 -0
  2. package/LICENSE +22 -0
  3. package/README.md +43 -0
  4. package/THIRD-PARTY-NOTICES.txt +22909 -0
  5. package/dist/types/build.d.ts +19 -0
  6. package/dist/types/compat/anthropic.d.ts +18 -0
  7. package/dist/types/compat/apply.d.ts +7 -0
  8. package/dist/types/compat/bedrock.d.ts +3 -0
  9. package/dist/types/compat/devin.d.ts +9 -0
  10. package/dist/types/compat/openai.d.ts +28 -0
  11. package/dist/types/discovery/antigravity.d.ts +70 -0
  12. package/dist/types/discovery/codex.d.ts +36 -0
  13. package/dist/types/discovery/cursor-proto.d.ts +5368 -0
  14. package/dist/types/discovery/cursor.d.ts +23 -0
  15. package/dist/types/discovery/devin-proto.d.ts +1549 -0
  16. package/dist/types/discovery/devin.d.ts +24 -0
  17. package/dist/types/discovery/gemini-cli.d.ts +33 -0
  18. package/dist/types/discovery/gemini.d.ts +25 -0
  19. package/dist/types/discovery/gitlab-duo-workflow.d.ts +30 -0
  20. package/dist/types/discovery/index.d.ts +7 -0
  21. package/dist/types/discovery/openai-compatible.d.ts +89 -0
  22. package/dist/types/discovery/protobuf.d.ts +102 -0
  23. package/dist/types/effort.d.ts +10 -0
  24. package/dist/types/fireworks-model-id.d.ts +23 -0
  25. package/dist/types/hosts.d.ts +169 -0
  26. package/dist/types/identity/bundled.d.ts +3 -0
  27. package/dist/types/identity/classify.d.ts +69 -0
  28. package/dist/types/identity/dialect.d.ts +3 -0
  29. package/dist/types/identity/family.d.ts +239 -0
  30. package/dist/types/identity/id.d.ts +12 -0
  31. package/dist/types/identity/index.d.ts +8 -0
  32. package/dist/types/identity/markers.d.ts +4 -0
  33. package/dist/types/identity/priority.d.ts +1 -0
  34. package/dist/types/identity/reference.d.ts +29 -0
  35. package/dist/types/index.d.ts +19 -0
  36. package/dist/types/model-cache.d.ts +23 -0
  37. package/dist/types/model-manager.d.ts +77 -0
  38. package/dist/types/model-thinking.d.ts +70 -0
  39. package/dist/types/model-tokenizer.d.ts +8 -0
  40. package/dist/types/models.d.ts +14 -0
  41. package/dist/types/openai-pricing.d.ts +17 -0
  42. package/dist/types/provider-models/bundled-references.d.ts +13 -0
  43. package/dist/types/provider-models/cache-provider-id.d.ts +11 -0
  44. package/dist/types/provider-models/descriptor-types.d.ts +76 -0
  45. package/dist/types/provider-models/descriptors.d.ts +505 -0
  46. package/dist/types/provider-models/google.d.ts +29 -0
  47. package/dist/types/provider-models/index.d.ts +7 -0
  48. package/dist/types/provider-models/ollama.d.ts +22 -0
  49. package/dist/types/provider-models/openai-compat.d.ts +646 -0
  50. package/dist/types/provider-models/special.d.ts +53 -0
  51. package/dist/types/types.d.ts +876 -0
  52. package/dist/types/utils.d.ts +20 -0
  53. package/dist/types/variant-collapse.d.ts +137 -0
  54. package/dist/types/wire/alibaba-token-plan.d.ts +22 -0
  55. package/dist/types/wire/codex.d.ts +66 -0
  56. package/dist/types/wire/coreweave.d.ts +12 -0
  57. package/dist/types/wire/gemini-headers.d.ts +62 -0
  58. package/dist/types/wire/github-copilot.d.ts +47 -0
  59. package/dist/types/wire/image-fetchers.d.ts +76 -0
  60. package/package.json +102 -0
  61. package/src/build.ts +103 -0
  62. package/src/compat/anthropic.ts +179 -0
  63. package/src/compat/apply.ts +15 -0
  64. package/src/compat/bedrock.ts +153 -0
  65. package/src/compat/devin.ts +12 -0
  66. package/src/compat/openai.ts +864 -0
  67. package/src/discovery/antigravity.ts +257 -0
  68. package/src/discovery/codex.ts +456 -0
  69. package/src/discovery/cursor-proto.ts +8329 -0
  70. package/src/discovery/cursor.ts +409 -0
  71. package/src/discovery/devin-proto.ts +2037 -0
  72. package/src/discovery/devin.ts +152 -0
  73. package/src/discovery/gemini-cli.ts +198 -0
  74. package/src/discovery/gemini.ts +260 -0
  75. package/src/discovery/gitlab-duo-workflow.ts +859 -0
  76. package/src/discovery/index.ts +7 -0
  77. package/src/discovery/openai-compatible.ts +266 -0
  78. package/src/discovery/protobuf.ts +1073 -0
  79. package/src/effort.ts +18 -0
  80. package/src/fireworks-model-id.ts +50 -0
  81. package/src/hosts.ts +178 -0
  82. package/src/identity/bundled.ts +28 -0
  83. package/src/identity/classify.ts +242 -0
  84. package/src/identity/dialect.ts +42 -0
  85. package/src/identity/family.ts +477 -0
  86. package/src/identity/id.ts +81 -0
  87. package/src/identity/index.ts +8 -0
  88. package/src/identity/markers.ts +49 -0
  89. package/src/identity/priority.ts +59 -0
  90. package/src/identity/reference.ts +167 -0
  91. package/src/index.ts +19 -0
  92. package/src/model-cache.ts +346 -0
  93. package/src/model-manager.ts +683 -0
  94. package/src/model-thinking.ts +925 -0
  95. package/src/model-tokenizer.ts +75 -0
  96. package/src/models.json +304657 -0
  97. package/src/models.json.d.ts +9 -0
  98. package/src/models.ts +108 -0
  99. package/src/openai-pricing.ts +29 -0
  100. package/src/provider-models/bundled-references.ts +87 -0
  101. package/src/provider-models/cache-provider-id.ts +97 -0
  102. package/src/provider-models/descriptor-types.ts +85 -0
  103. package/src/provider-models/descriptors.ts +585 -0
  104. package/src/provider-models/google.ts +117 -0
  105. package/src/provider-models/index.ts +7 -0
  106. package/src/provider-models/ollama.ts +204 -0
  107. package/src/provider-models/openai-compat.ts +6405 -0
  108. package/src/provider-models/special.ts +213 -0
  109. package/src/types.ts +1032 -0
  110. package/src/utils.ts +69 -0
  111. package/src/variant-collapse.ts +1555 -0
  112. package/src/wire/alibaba-token-plan.ts +54 -0
  113. package/src/wire/codex.ts +117 -0
  114. package/src/wire/coreweave.ts +51 -0
  115. package/src/wire/gemini-headers.ts +135 -0
  116. package/src/wire/github-copilot.ts +147 -0
  117. package/src/wire/image-fetchers.ts +159 -0
@@ -0,0 +1,257 @@
1
+ import { type } from "@rigelbuild/omp-omptype";
2
+ import type { ModelSpec } from "../types";
3
+ import { discoveryFetch, toPositiveNumber } from "../utils";
4
+ import {
5
+ ANTIGRAVITY_VARIANT_COLLAPSE_TABLE,
6
+ collapseEffortVariants,
7
+ type VariantCollapseTable,
8
+ } from "../variant-collapse";
9
+ import { ensureAntigravityVersion, getAntigravityUserAgent } from "../wire/gemini-headers";
10
+
11
+ export const ANTIGRAVITY_PRIMARY_ENDPOINT = "https://daily-cloudcode-pa.googleapis.com";
12
+ export const ANTIGRAVITY_SANDBOX_ENDPOINT = "https://daily-cloudcode-pa.sandbox.googleapis.com";
13
+ const DEFAULT_ANTIGRAVITY_DISCOVERY_ENDPOINTS = [ANTIGRAVITY_PRIMARY_ENDPOINT, ANTIGRAVITY_SANDBOX_ENDPOINT] as const;
14
+ const FETCH_AVAILABLE_MODELS_PATH = "/v1internal:fetchAvailableModels";
15
+
16
+ const DEFAULT_CONTEXT_WINDOW = 200_000;
17
+ const DEFAULT_MAX_TOKENS = 64_000;
18
+ const ANTIGRAVITY_DISCOVERY_DENYLIST = new Set(["chat_20706", "chat_23310", "gemini-2.5-pro"]);
19
+
20
+ /**
21
+ * Raw model metadata returned by Antigravity's `fetchAvailableModels` endpoint.
22
+ */
23
+ export interface AntigravityDiscoveryApiModel {
24
+ displayName?: string;
25
+ supportsImages?: boolean;
26
+ supportsThinking?: boolean;
27
+ thinkingBudget?: number;
28
+ recommended?: boolean;
29
+ maxTokens?: number;
30
+ maxOutputTokens?: number;
31
+ model?: string;
32
+ apiProvider?: string;
33
+ modelProvider?: string;
34
+ isInternal?: boolean;
35
+ supportsVideo?: boolean;
36
+ }
37
+
38
+ /**
39
+ * Grouping metadata used by Antigravity to surface recommended model ids.
40
+ */
41
+ export interface AntigravityDiscoveryAgentModelGroup {
42
+ modelIds?: string[];
43
+ }
44
+
45
+ /**
46
+ * Sort/group metadata used by Antigravity to surface recommended model ids.
47
+ */
48
+ export interface AntigravityDiscoveryAgentModelSort {
49
+ groups?: AntigravityDiscoveryAgentModelGroup[];
50
+ }
51
+
52
+ /**
53
+ * Response payload returned by Antigravity's `fetchAvailableModels` endpoint.
54
+ */
55
+ export interface AntigravityDiscoveryApiResponse {
56
+ models?: Record<string, AntigravityDiscoveryApiModel>;
57
+ agentModelSorts?: AntigravityDiscoveryAgentModelSort[];
58
+ }
59
+ const AntigravityDiscoveryApiModelSchema = type({
60
+ "displayName?": type("unknown").pipe(value => (typeof value === "string" ? value : undefined)),
61
+ "supportsImages?": type("unknown").pipe(value => (typeof value === "boolean" ? value : undefined)),
62
+ "supportsThinking?": type("unknown").pipe(value => (typeof value === "boolean" ? value : undefined)),
63
+ "thinkingBudget?": type("unknown").pipe(value =>
64
+ typeof value === "number" && Number.isFinite(value) ? value : undefined,
65
+ ),
66
+ "recommended?": type("unknown").pipe(value => (typeof value === "boolean" ? value : undefined)),
67
+ "maxTokens?": type("unknown").pipe(value =>
68
+ typeof value === "number" && Number.isFinite(value) ? value : undefined,
69
+ ),
70
+ "maxOutputTokens?": type("unknown").pipe(value =>
71
+ typeof value === "number" && Number.isFinite(value) ? value : undefined,
72
+ ),
73
+ "model?": type("unknown").pipe(value => (typeof value === "string" ? value : undefined)),
74
+ "apiProvider?": type("unknown").pipe(value => (typeof value === "string" ? value : undefined)),
75
+ "modelProvider?": type("unknown").pipe(value => (typeof value === "string" ? value : undefined)),
76
+ "isInternal?": type("unknown").pipe(value => (typeof value === "boolean" ? value : undefined)),
77
+ "supportsVideo?": type("unknown").pipe(value => (typeof value === "boolean" ? value : undefined)),
78
+ });
79
+
80
+ const AntigravityDiscoveryAgentModelGroupSchema = type({
81
+ "modelIds?": type("unknown").pipe(value =>
82
+ Array.isArray(value) ? value.filter((modelId): modelId is string => typeof modelId === "string") : undefined,
83
+ ),
84
+ });
85
+
86
+ const AntigravityDiscoveryAgentModelSortSchema = type({
87
+ "groups?": type("unknown").pipe(value => {
88
+ if (!Array.isArray(value)) return undefined;
89
+ const result: AntigravityDiscoveryAgentModelGroup[] = [];
90
+ for (const group of value) {
91
+ const parsedGroup = AntigravityDiscoveryAgentModelGroupSchema(group);
92
+ if (!(parsedGroup instanceof type.errors)) {
93
+ result.push(parsedGroup);
94
+ }
95
+ }
96
+ return result;
97
+ }),
98
+ });
99
+
100
+ const AntigravityDiscoveryApiResponseSchema = type({
101
+ "models?": type("unknown").pipe(value => {
102
+ if (typeof value !== "object" || value === null) {
103
+ return undefined;
104
+ }
105
+ const normalized: Record<string, AntigravityDiscoveryApiModel> = {};
106
+ for (const [modelId, modelValue] of Object.entries(value)) {
107
+ if (typeof modelValue !== "object" || modelValue === null) {
108
+ continue;
109
+ }
110
+ const parsedModel = AntigravityDiscoveryApiModelSchema(modelValue);
111
+ if (!(parsedModel instanceof type.errors)) {
112
+ normalized[modelId] = parsedModel;
113
+ }
114
+ }
115
+ return normalized;
116
+ }),
117
+ "agentModelSorts?": type("unknown").pipe(value => {
118
+ if (!Array.isArray(value)) {
119
+ return undefined;
120
+ }
121
+ const result: AntigravityDiscoveryAgentModelSort[] = [];
122
+ for (const sort of value) {
123
+ const parsedSort = AntigravityDiscoveryAgentModelSortSchema(sort);
124
+ if (!(parsedSort instanceof type.errors)) {
125
+ result.push(parsedSort);
126
+ }
127
+ }
128
+ return result;
129
+ }),
130
+ });
131
+ /**
132
+ * Options for fetching Antigravity discovery models.
133
+ */
134
+ export interface FetchAntigravityDiscoveryModelsOptions {
135
+ /** OAuth access token used as `Authorization: Bearer <token>`. */
136
+ token: string;
137
+ /** Optional endpoint override. Defaults to Antigravity fallback endpoints. */
138
+ endpoint?: string;
139
+ /** Deprecated and ignored for antigravity discovery parity. */
140
+ project?: string;
141
+ /** Optional user agent override. */
142
+ userAgent?: string;
143
+ /** Optional abort signal for request cancellation. */
144
+ signal?: AbortSignal;
145
+ /** Optional fetch implementation override for tests. */
146
+ fetcher?: typeof fetch;
147
+ /**
148
+ * Hand collapse table to apply to the discovered list. Defaults to the
149
+ * Antigravity (budget-transport) table; `googleGeminiCli` passes the
150
+ * level-transport table so cloudcode-pa keeps `thinkingLevel`.
151
+ */
152
+ collapseTable?: VariantCollapseTable;
153
+ }
154
+
155
+ /**
156
+ * Fetches discoverable Antigravity models and normalizes them into canonical model entries.
157
+ *
158
+ * Returns `null` on network/payload/auth failures.
159
+ * Returns `[]` only when the endpoint responds successfully with no usable models.
160
+ */
161
+ export async function fetchAntigravityDiscoveryModels(
162
+ options: FetchAntigravityDiscoveryModelsOptions,
163
+ ): Promise<ModelSpec<"google-gemini-cli">[] | null> {
164
+ if (options.userAgent === undefined) {
165
+ await ensureAntigravityVersion(options.fetcher ?? fetch, options.signal);
166
+ }
167
+
168
+ const fetcher = discoveryFetch(options.fetcher);
169
+ const endpoints = options.endpoint
170
+ ? [trimTrailingSlashes(options.endpoint)]
171
+ : DEFAULT_ANTIGRAVITY_DISCOVERY_ENDPOINTS.map(trimTrailingSlashes);
172
+
173
+ for (const endpoint of endpoints) {
174
+ let response: Response;
175
+ try {
176
+ response = await fetcher(`${endpoint}${FETCH_AVAILABLE_MODELS_PATH}`, {
177
+ method: "POST",
178
+ headers: {
179
+ Authorization: `Bearer ${options.token}`,
180
+ "Content-Type": "application/json",
181
+ "User-Agent": options.userAgent ?? getAntigravityUserAgent(),
182
+ },
183
+ body: JSON.stringify({}),
184
+ signal: options.signal,
185
+ });
186
+ } catch {
187
+ continue;
188
+ }
189
+
190
+ if (!response.ok) {
191
+ continue;
192
+ }
193
+
194
+ let payload: unknown;
195
+ try {
196
+ payload = await response.json();
197
+ } catch {
198
+ continue;
199
+ }
200
+
201
+ const parsed = parseAntigravityDiscoveryResponse(payload);
202
+ if (!parsed) {
203
+ continue;
204
+ }
205
+
206
+ const models: ModelSpec<"google-gemini-cli">[] = [];
207
+
208
+ for (const [modelId, model] of Object.entries(parsed.models ?? {})) {
209
+ if (ANTIGRAVITY_DISCOVERY_DENYLIST.has(modelId)) {
210
+ continue;
211
+ }
212
+ if (model.isInternal === true) {
213
+ continue;
214
+ }
215
+
216
+ const supportsImages = model.supportsImages === true;
217
+ models.push({
218
+ id: modelId,
219
+ name: model.displayName || modelId,
220
+ api: "google-gemini-cli",
221
+ provider: "google-antigravity",
222
+ baseUrl: endpoint,
223
+ reasoning: model.supportsThinking === true,
224
+ input: supportsImages ? ["text", "image"] : ["text"],
225
+ cost: {
226
+ input: 0,
227
+ output: 0,
228
+ cacheRead: 0,
229
+ cacheWrite: 0,
230
+ },
231
+ contextWindow: toPositiveNumber(model.maxTokens, DEFAULT_CONTEXT_WINDOW),
232
+ maxTokens: toPositiveNumber(model.maxOutputTokens, DEFAULT_MAX_TOKENS),
233
+ });
234
+ }
235
+
236
+ // Collapse effort-tier variants at the source so runtime discovery,
237
+ // the gemini-cli re-provision, and the catalog generator all see
238
+ // logical ids only.
239
+ const collapsed = collapseEffortVariants(models, options.collapseTable ?? ANTIGRAVITY_VARIANT_COLLAPSE_TABLE);
240
+ collapsed.sort((a, b) => a.name.localeCompare(b.name) || a.id.localeCompare(b.id));
241
+ return collapsed;
242
+ }
243
+
244
+ return null;
245
+ }
246
+
247
+ function parseAntigravityDiscoveryResponse(value: unknown): AntigravityDiscoveryApiResponse | null {
248
+ const parsed = AntigravityDiscoveryApiResponseSchema(value);
249
+ if (parsed instanceof type.errors) {
250
+ return null;
251
+ }
252
+ return parsed;
253
+ }
254
+
255
+ function trimTrailingSlashes(value: string): string {
256
+ return value.replace(/\/+$/, "");
257
+ }