@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,213 @@
1
+ import { once } from "@rigelbuild/omp-utils";
2
+ import { type CodexModelDiscoveryResult, fetchCodexModels } from "../discovery/codex";
3
+ import type { DevinModelDiscoveryOptions } from "../discovery/devin";
4
+ import { buildGitLabDuoWorkflowFallbackModel, fetchGitLabDuoWorkflowModels } from "../discovery/gitlab-duo-workflow";
5
+ import type { ModelManagerOptions } from "../model-manager";
6
+ import type { FetchImpl, ModelSpec } from "../types";
7
+ import { resolveModelCacheProviderId } from "./cache-provider-id";
8
+
9
+ // ---------------------------------------------------------------------------
10
+ // OpenAI Codex
11
+ // ---------------------------------------------------------------------------
12
+
13
+ /** One Codex OAuth account to fetch a catalog for. */
14
+ export interface OpenAICodexAccount {
15
+ /** OAuth access token used for `Authorization: Bearer ...`. */
16
+ accessToken: string;
17
+ /** ChatGPT account id sent as the `chatgpt-account-id` header. */
18
+ accountId?: string;
19
+ }
20
+
21
+ export interface OpenAICodexModelManagerConfig {
22
+ /**
23
+ * Resolves every configured Codex OAuth account at discovery time. Codex
24
+ * discovery is account-scoped — a model can be available to one account and
25
+ * absent from another — so each account's `/models` endpoint is fetched
26
+ * independently and the results unioned by id. Without this, discovery would
27
+ * surface only the account it happened to resolve and, being authoritative,
28
+ * prune every model the other accounts expose (#6265).
29
+ *
30
+ * Returns `null` to abort discovery entirely (e.g. an account's credential
31
+ * failed to refresh): a partial account set would be cached as the complete
32
+ * authoritative catalog and hide the missing account's models, so the caller
33
+ * keeps the previous/bundled catalog instead.
34
+ */
35
+ resolveAccounts?: () => Promise<readonly OpenAICodexAccount[] | null>;
36
+ clientVersion?: string;
37
+ fetch?: FetchImpl;
38
+ }
39
+
40
+ export function openaiCodexModelManagerOptions(
41
+ config: OpenAICodexModelManagerConfig = {},
42
+ ): ModelManagerOptions<"openai-codex-responses"> {
43
+ const { resolveAccounts, clientVersion, fetch } = config;
44
+ return {
45
+ providerId: "openai-codex",
46
+ dynamicModelsAuthoritative: true,
47
+ ...(resolveAccounts
48
+ ? {
49
+ fetchDynamicModels: async () => {
50
+ const accounts = await resolveAccounts();
51
+ if (!accounts || accounts.length === 0) return null;
52
+ const results = await Promise.all(
53
+ accounts.map(account =>
54
+ fetchCodexModels({
55
+ accessToken: account.accessToken,
56
+ accountId: account.accountId,
57
+ clientVersion,
58
+ fetchFn: fetch,
59
+ }),
60
+ ),
61
+ );
62
+ return unionCodexModels(results);
63
+ },
64
+ }
65
+ : undefined),
66
+ };
67
+ }
68
+
69
+ /**
70
+ * Merge complete per-account Codex catalogs into one authoritative list,
71
+ * deduped by model id (first account to expose an id wins). Returns `null` when
72
+ * any account's fetch failed, so a partial list cannot replace the previous or
73
+ * bundled authoritative catalog.
74
+ */
75
+ function unionCodexModels(
76
+ results: readonly (CodexModelDiscoveryResult | null)[],
77
+ ): ModelSpec<"openai-codex-responses">[] | null {
78
+ const byId = new Map<string, ModelSpec<"openai-codex-responses">>();
79
+ for (const result of results) {
80
+ if (!result) return null;
81
+ for (const model of result.models) {
82
+ if (!byId.has(model.id)) byId.set(model.id, model);
83
+ }
84
+ }
85
+ return [...byId.values()];
86
+ }
87
+
88
+ // ---------------------------------------------------------------------------
89
+ // Cursor
90
+ // ---------------------------------------------------------------------------
91
+
92
+ export interface CursorModelManagerConfig {
93
+ apiKey?: string;
94
+ baseUrl?: string;
95
+ clientVersion?: string;
96
+ }
97
+
98
+ export function cursorModelManagerOptions(config: CursorModelManagerConfig = {}): ModelManagerOptions<"cursor-agent"> {
99
+ const { apiKey, baseUrl, clientVersion } = config;
100
+ return {
101
+ providerId: "cursor",
102
+ cacheProviderId: resolveModelCacheProviderId("cursor"),
103
+ ...(apiKey
104
+ ? {
105
+ fetchDynamicModels: async () => {
106
+ const { fetchCursorUsableModels } = await cursorDiscovery();
107
+ return fetchCursorUsableModels({ apiKey, baseUrl, clientVersion });
108
+ },
109
+ }
110
+ : undefined),
111
+ };
112
+ }
113
+
114
+ const cursorDiscovery = once(() => import("../discovery/cursor"));
115
+
116
+ // ---------------------------------------------------------------------------
117
+ // GitLab Duo Workflow
118
+ // ---------------------------------------------------------------------------
119
+
120
+ export interface GitLabDuoWorkflowModelManagerConfig {
121
+ apiKey?: string;
122
+ baseUrl?: string;
123
+ fetch?: FetchImpl;
124
+ namespaceId?: string;
125
+ projectId?: string;
126
+ cwd?: string;
127
+ }
128
+
129
+ export function gitLabDuoWorkflowModelManagerOptions(
130
+ config: GitLabDuoWorkflowModelManagerConfig = {},
131
+ ): ModelManagerOptions<"gitlab-duo-agent"> {
132
+ const apiKey = config.apiKey;
133
+ return {
134
+ providerId: "gitlab-duo-agent",
135
+ // GitLab Duo discovery is credential- and namespace-specific
136
+ // (`aiChatAvailableModels(rootNamespaceId:)` also surfaces namespace-pinned
137
+ // models), so the default provider-id cache namespace would let a second
138
+ // account/namespace load the first one's authoritative model list at startup
139
+ // and skip refetching. Partition the cache by a non-reversible fingerprint of
140
+ // the exact inputs `fetchGitLabDuoWorkflowModels` resolves the namespace from
141
+ // (credential + base URL + namespace/project config + the same env vars + the
142
+ // effective workspace cwd whose git remote drives auto-discovery). Built-in
143
+ // discovery only passes apiKey/baseUrl/fetch, so the cwd/env terms — not the
144
+ // empty config fields — are what actually separate workspace A from B here.
145
+ // Falls back to the bare provider id when no credential is present.
146
+ ...(apiKey ? { cacheProviderId: gitLabDuoWorkflowModelCacheProviderId(apiKey, config) } : undefined),
147
+ dynamicModelsAuthoritative: true,
148
+ staticModels: [
149
+ buildGitLabDuoWorkflowFallbackModel("claude_sonnet_4_6_vertex", "Claude Sonnet 4.6 - Vertex", config.baseUrl),
150
+ ],
151
+ ...(apiKey
152
+ ? {
153
+ fetchDynamicModels: async () =>
154
+ fetchGitLabDuoWorkflowModels({
155
+ apiKey,
156
+ baseUrl: config.baseUrl,
157
+ fetch: config.fetch,
158
+ namespaceId: config.namespaceId,
159
+ projectId: config.projectId,
160
+ cwd: config.cwd,
161
+ }),
162
+ }
163
+ : undefined),
164
+ };
165
+ }
166
+
167
+ function gitLabDuoWorkflowModelCacheProviderId(apiKey: string, config: GitLabDuoWorkflowModelManagerConfig): string {
168
+ // Mirror the exact inputs `discoverGitLabDuoWorkflowNamespace` keys off: explicit
169
+ // namespace/project config OR the same env vars, then the git remote at the
170
+ // effective cwd. Built-in discovery leaves the config fields empty, so the env +
171
+ // resolved cwd terms are what actually distinguish two workspaces sharing a token.
172
+ const namespaceId = config.namespaceId ?? Bun.env.GITLAB_DUO_NAMESPACE_ID ?? "";
173
+ const projectId = config.projectId ?? Bun.env.GITLAB_DUO_PROJECT_ID ?? Bun.env.GITLAB_DUO_PROJECT_PATH ?? "";
174
+ const cwd = config.cwd ?? process.cwd();
175
+ const scope = [config.baseUrl ?? "", namespaceId, projectId, cwd].join("\u0000");
176
+ return `gitlab-duo-agent:${Bun.hash(`${apiKey}\u0000${scope}`).toString(36)}`;
177
+ }
178
+
179
+ // Devin (Codeium Cascade)
180
+ // ---------------------------------------------------------------------------
181
+
182
+ export interface DevinModelManagerConfig {
183
+ apiKey?: string;
184
+ baseUrl?: string;
185
+ fetch?: DevinModelDiscoveryOptions["fetch"];
186
+ }
187
+
188
+ export function devinModelManagerOptions(config: DevinModelManagerConfig = {}): ModelManagerOptions<"devin-agent"> {
189
+ const { apiKey, baseUrl, fetch } = config;
190
+ return {
191
+ providerId: "devin",
192
+ ...(apiKey ? { dynamicModelsAuthoritative: true } : undefined),
193
+ ...(apiKey
194
+ ? {
195
+ fetchDynamicModels: async () => {
196
+ const { fetchDevinModels } = await devinDiscovery();
197
+ return fetchDevinModels({ apiKey, baseUrl, fetch });
198
+ },
199
+ }
200
+ : undefined),
201
+ };
202
+ }
203
+
204
+ const devinDiscovery = once(() => import("../discovery/devin"));
205
+ // ---------------------------------------------------------------------------
206
+ // Zai
207
+ // ---------------------------------------------------------------------------
208
+
209
+ export interface ZaiModelManagerConfig {}
210
+
211
+ export function zaiModelManagerOptions(_config: ZaiModelManagerConfig = {}): ModelManagerOptions<"anthropic-messages"> {
212
+ return { providerId: "zai" };
213
+ }