@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,20 @@
|
|
|
1
|
+
import { type FetchImpl } from "@rigelbuild/omp-utils";
|
|
2
|
+
export { isRecord } from "@rigelbuild/omp-utils";
|
|
3
|
+
/**
|
|
4
|
+
* Fetch implementation for catalog discovery probes: the caller's override
|
|
5
|
+
* when given, otherwise global fetch wrapped for `NODE_EXTRA_CA_CERTS`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function discoveryFetch(override?: FetchImpl): FetchImpl;
|
|
8
|
+
export declare function toNumber(value: unknown): number | undefined;
|
|
9
|
+
export declare function toPositiveNumber(value: unknown, fallback: number): number;
|
|
10
|
+
export declare function toPositiveNumber(value: unknown, fallback: number | null): number | null;
|
|
11
|
+
/** Positive finite number, or `null` when the value is missing/non-positive. */
|
|
12
|
+
export declare function toPositiveNumberOrNull(value: unknown): number | null;
|
|
13
|
+
export declare function toBoolean(value: unknown): boolean | undefined;
|
|
14
|
+
export declare function isAnthropicOAuthToken(key: string): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Normalize a model display name: drop the gateway author prefix and
|
|
17
|
+
* model-extrinsic decorations. Returns the input verbatim when nothing
|
|
18
|
+
* matches (or when stripping would leave an empty name).
|
|
19
|
+
*/
|
|
20
|
+
export declare function cleanModelName(name: string): string;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { Effort } from "./effort.js";
|
|
2
|
+
import type { Api, Model, ModelSpec, Provider, ThinkingConfig } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Structural bound for collapse inputs: both raw `ModelSpec`s and built
|
|
5
|
+
* `Model`s qualify. (`Model.compat` is the resolved record, not the sparse
|
|
6
|
+
* config, so the two are not mutually assignable — collapsing never touches
|
|
7
|
+
* `compat`.)
|
|
8
|
+
*/
|
|
9
|
+
export type VariantSpecLike = Omit<ModelSpec<Api>, "compat"> & {
|
|
10
|
+
compat?: unknown;
|
|
11
|
+
};
|
|
12
|
+
/** One collapsed family: logical id + member wire ids + per-effort routing. */
|
|
13
|
+
export interface EffortVariantFamily {
|
|
14
|
+
/** Collapsed logical id (may equal a member id — e.g. bare/thinking pairs). */
|
|
15
|
+
id: string;
|
|
16
|
+
/** Final display name, no tier marker. */
|
|
17
|
+
name: string;
|
|
18
|
+
/**
|
|
19
|
+
* Member wire ids in priority order. The first member present in the input
|
|
20
|
+
* becomes the collapsed spec's default wire id (`requestModelId`; omitted
|
|
21
|
+
* when it equals the logical id).
|
|
22
|
+
*/
|
|
23
|
+
members: readonly string[];
|
|
24
|
+
/**
|
|
25
|
+
* Wire ids upstream no longer serves (e.g. a deployment killed while
|
|
26
|
+
* discovery still advertises it). Fresh collapsing never routes to them,
|
|
27
|
+
* and stale collapsed snapshots (bundled catalog, cache rows,
|
|
28
|
+
* previous-generation fallbacks) get routing/`requestModelId` entries that
|
|
29
|
+
* target them re-pointed through `routing`. Keep retired ids in `members`
|
|
30
|
+
* so the raw upstream spec is still consumed and aliased.
|
|
31
|
+
*/
|
|
32
|
+
retiredMembers?: readonly string[];
|
|
33
|
+
/**
|
|
34
|
+
* Per-effort upstream wire id; `"off"` applies when thinking is disabled.
|
|
35
|
+
* Entries whose target member is absent from the input are dropped — those
|
|
36
|
+
* efforts fall back to `requestModelId ?? id`.
|
|
37
|
+
*/
|
|
38
|
+
routing: Readonly<Partial<Record<Effort | "off", string>>>;
|
|
39
|
+
/** Explicit capability surface for the collapsed spec — no inference. */
|
|
40
|
+
thinking: Readonly<Omit<ThinkingConfig, "effortRouting" | "suppressWhenOff">>;
|
|
41
|
+
/** Thinking-off requests must explicitly suppress thinking on the wire. */
|
|
42
|
+
suppressWhenOff?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Preserve non-off effort routes even when discovery omits the backing member.
|
|
45
|
+
* Used for Cloud Code Assist `X`/`X-thinking` pairs where upstream accepts
|
|
46
|
+
* the `-thinking` wire id but the model-list endpoint may advertise only the
|
|
47
|
+
* bare id.
|
|
48
|
+
*/
|
|
49
|
+
preserveAbsentEffortRoutes?: boolean;
|
|
50
|
+
/** Retired/recycled selector ids that alias to this family without being members. */
|
|
51
|
+
extraAliases?: readonly string[];
|
|
52
|
+
}
|
|
53
|
+
export interface VariantCollapseTable {
|
|
54
|
+
families: readonly EffortVariantFamily[];
|
|
55
|
+
}
|
|
56
|
+
/** `google-antigravity` Gemini families, using each generation's native transport. */
|
|
57
|
+
export declare const ANTIGRAVITY_VARIANT_COLLAPSE_TABLE: VariantCollapseTable;
|
|
58
|
+
/** `google-gemini-cli` Gemini families on the official CLI's level transport. */
|
|
59
|
+
export declare const GEMINI_CLI_VARIANT_COLLAPSE_TABLE: VariantCollapseTable;
|
|
60
|
+
export declare const DEVIN_VARIANT_COLLAPSE_TABLE: VariantCollapseTable;
|
|
61
|
+
/** `cursor` per-effort sibling families collapsed per service-tier lane: Grok 4.5/4.6 plus GPT-5.6 Luna/Sol/Terra. */
|
|
62
|
+
export declare const CURSOR_VARIANT_COLLAPSE_TABLE: VariantCollapseTable;
|
|
63
|
+
/** Provider id → hand collapse table. The CCA providers diverge on thinking transport. */
|
|
64
|
+
export declare const VARIANT_COLLAPSE_TABLES: Readonly<Record<string, VariantCollapseTable>>;
|
|
65
|
+
/**
|
|
66
|
+
* The global automatic rule: derive an `X` + `X-thinking` family for every
|
|
67
|
+
* pair where both ids are live in `specs` (trailing or infix token). Gates:
|
|
68
|
+
* - both members share the same `api`,
|
|
69
|
+
* - known pricing must match — all-zero cost rows count as unknown
|
|
70
|
+
* (aggregators routinely ship them), but twins that BOTH carry real,
|
|
71
|
+
* differing prices are distinct SKUs and never merge,
|
|
72
|
+
* - ids claimed by the provider's hand `table` are skipped (curation wins).
|
|
73
|
+
* The capability surface prefers the thinking member's metadata, then the
|
|
74
|
+
* bare member's, then the canonical deriver (aggregators often ship
|
|
75
|
+
* `reasoning: false` and no thinking config on the twin), then a budget
|
|
76
|
+
* default. `off` routes to the bare id; every supported effort routes to the
|
|
77
|
+
* thinking id.
|
|
78
|
+
*/
|
|
79
|
+
export declare function deriveThinkingPairFamilies<TSpec extends VariantSpecLike>(specs: readonly TSpec[], table?: VariantCollapseTable): EffortVariantFamily[];
|
|
80
|
+
/**
|
|
81
|
+
* True when `spec` is the output of collapsing rather than a raw upstream
|
|
82
|
+
* member. `thinking.effortRouting` is written only by collapsing; the
|
|
83
|
+
* `requestModelId` arm is scoped to the provider's hand-table family ids so
|
|
84
|
+
* unrelated carriers (GitHub Copilot `-1m` context variants) never match.
|
|
85
|
+
*/
|
|
86
|
+
export declare function isVariantCollapsedSpec(spec: VariantSpecLike): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Collapse every family in `table` found in `specs`. Non-member specs pass
|
|
89
|
+
* through verbatim (by reference), order preserved; the collapsed spec
|
|
90
|
+
* replaces the first occurrence of its family.
|
|
91
|
+
*/
|
|
92
|
+
export declare function collapseEffortVariants<TSpec extends VariantSpecLike>(specs: readonly TSpec[], table: VariantCollapseTable): TSpec[];
|
|
93
|
+
/**
|
|
94
|
+
* Collapse a full mixed-provider list: per provider, the hand table, Cursor's
|
|
95
|
+
* conservative live effort-sibling rule, and the automatic `X`/`X-thinking`
|
|
96
|
+
* pair rule. Used by the catalog generator; the runtime equivalent lives at
|
|
97
|
+
* the model-manager merge point. Output is regrouped by provider — callers
|
|
98
|
+
* re-sort.
|
|
99
|
+
*/
|
|
100
|
+
export declare function collapseEffortVariantsAcrossProviders<TSpec extends VariantSpecLike>(specs: readonly TSpec[]): TSpec[];
|
|
101
|
+
/**
|
|
102
|
+
* Runtime entry point for already-built `Model` lists (the model-manager
|
|
103
|
+
* merge point, coding-agent registry custom providers): collapses hand
|
|
104
|
+
* tables plus derived pairs, then re-runs `buildModel` on freshly created
|
|
105
|
+
* logical specs so thinking wire defaults stay resolved. Untouched entries
|
|
106
|
+
* pass through by reference.
|
|
107
|
+
*/
|
|
108
|
+
export declare function collapseBuiltModelVariants<TApi extends Api>(models: readonly Model<TApi>[]): Model<TApi>[];
|
|
109
|
+
/**
|
|
110
|
+
* Resolve a retired effort-tier variant id (collapsed member, recycled id) to
|
|
111
|
+
* its replacement model id for `provider` via hand-table or registered live
|
|
112
|
+
* aliases. Returns `undefined` when the id is not a known alias; derived
|
|
113
|
+
* `X-thinking` members also resolve through `stripThinkingVariantToken`.
|
|
114
|
+
* Callers must try an exact model lookup first — a live model always wins over
|
|
115
|
+
* an alias.
|
|
116
|
+
*/
|
|
117
|
+
export declare function resolveVariantAlias(provider: Provider, modelId: string): string | undefined;
|
|
118
|
+
/** Bare-id alias hit: replacement id plus the providers declaring it. */
|
|
119
|
+
export interface BareVariantAliasHit {
|
|
120
|
+
id: string;
|
|
121
|
+
/** Providers declaring the alias — candidates from these win ties. */
|
|
122
|
+
providers: readonly Provider[];
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Provider-agnostic alias lookup for bare-id selectors. Returns the declaring
|
|
126
|
+
* providers so callers can prefer their models when the replacement id exists
|
|
127
|
+
* on unrelated providers too (e.g. a retired Cursor tier id must not resolve
|
|
128
|
+
* to `openai/gpt-5.4`).
|
|
129
|
+
*/
|
|
130
|
+
export declare function resolveBareVariantAlias(modelId: string): BareVariantAliasHit | undefined;
|
|
131
|
+
/**
|
|
132
|
+
* Reverse alias lookup: the retired ids that resolve to `modelId` for
|
|
133
|
+
* `provider` via hand-table or registered live aliases. Used to re-key config
|
|
134
|
+
* keyed by raw member ids (models.yml `modelOverrides`, suppressed selectors)
|
|
135
|
+
* onto the collapsed model.
|
|
136
|
+
*/
|
|
137
|
+
export declare function getVariantAliasSources(provider: Provider, modelId: string): readonly string[];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* International (Singapore) Token Plan endpoint. Default region; keys issued by
|
|
3
|
+
* the international product authenticate only here.
|
|
4
|
+
*/
|
|
5
|
+
export declare const ALIBABA_TOKEN_PLAN_BASE_URL = "https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1";
|
|
6
|
+
/**
|
|
7
|
+
* China (Beijing) Token Plan endpoint (百炼 Token Plan). Keys are region-locked:
|
|
8
|
+
* a Beijing-issued key is rejected by the international endpoint with
|
|
9
|
+
* `invalid_api_key`, and vice versa (#6682).
|
|
10
|
+
*/
|
|
11
|
+
export declare const ALIBABA_TOKEN_PLAN_CN_BASE_URL = "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1";
|
|
12
|
+
export interface AlibabaTokenPlanCredential {
|
|
13
|
+
token: string;
|
|
14
|
+
cookie?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Region base URL the key authenticates against. Absent means the default
|
|
17
|
+
* international endpoint ({@link ALIBABA_TOKEN_PLAN_BASE_URL}).
|
|
18
|
+
*/
|
|
19
|
+
baseUrl?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare function parseAlibabaTokenPlanCredential(value: string): AlibabaTokenPlanCredential | null;
|
|
22
|
+
export declare function serializeAlibabaTokenPlanCredential(token: string, cookie: string, baseUrl?: string): string;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constants for OpenAI Codex (ChatGPT OAuth) backend
|
|
3
|
+
*/
|
|
4
|
+
export declare const CODEX_BASE_URL = "https://chatgpt.com/backend-api";
|
|
5
|
+
/**
|
|
6
|
+
* Pinned OpenAI Codex client version (corresponds to @openai/codex package version).
|
|
7
|
+
*/
|
|
8
|
+
export declare const CODEX_CLIENT_VERSION = "0.144.1";
|
|
9
|
+
export declare const OPENAI_HEADERS: {
|
|
10
|
+
readonly BETA: "OpenAI-Beta";
|
|
11
|
+
/** Codex feature-negotiation header; values identify opt-in wire protocols. */
|
|
12
|
+
readonly CODEX_BETA_FEATURES: "x-codex-beta-features";
|
|
13
|
+
readonly ACCOUNT_ID: "chatgpt-account-id";
|
|
14
|
+
readonly ORIGINATOR: "originator";
|
|
15
|
+
readonly VERSION: "version";
|
|
16
|
+
readonly SESSION_ID: "session_id";
|
|
17
|
+
readonly CONVERSATION_ID: "conversation_id";
|
|
18
|
+
readonly SCOPED_SESSION_ID: "session-id";
|
|
19
|
+
readonly THREAD_ID: "thread-id";
|
|
20
|
+
readonly INSTALLATION_ID: "x-codex-installation-id";
|
|
21
|
+
readonly WINDOW_ID: "x-codex-window-id";
|
|
22
|
+
readonly TURN_METADATA: "x-codex-turn-metadata";
|
|
23
|
+
readonly PARENT_THREAD_ID: "x-codex-parent-thread-id";
|
|
24
|
+
readonly SUBAGENT: "x-openai-subagent";
|
|
25
|
+
/** Responses Lite transport marker (codex-rs `add_responses_lite_header`); value is always `"true"`. */
|
|
26
|
+
readonly RESPONSES_LITE: "x-openai-internal-codex-responses-lite";
|
|
27
|
+
/** DeviceCheck attestation envelope (codex-rs `X_OAI_ATTESTATION_HEADER`); sent on ChatGPT-OAuth requests. */
|
|
28
|
+
readonly ATTESTATION: "x-oai-attestation";
|
|
29
|
+
/** Client-declared data residency for region-pinned enterprise workspaces. */
|
|
30
|
+
readonly RESIDENCY: "x-openai-internal-codex-residency";
|
|
31
|
+
};
|
|
32
|
+
export declare const OPENAI_HEADER_VALUES: {
|
|
33
|
+
readonly BETA_RESPONSES: "responses=experimental";
|
|
34
|
+
readonly BETA_RESPONSES_WEBSOCKETS_V2: "responses_websockets=2026-02-06";
|
|
35
|
+
readonly REMOTE_COMPACTION_V2: "remote_compaction_v2";
|
|
36
|
+
readonly ORIGINATOR_CODEX: "pi";
|
|
37
|
+
};
|
|
38
|
+
export declare const URL_PATHS: {
|
|
39
|
+
readonly RESPONSES: "/responses";
|
|
40
|
+
readonly CODEX_RESPONSES: "/codex/responses";
|
|
41
|
+
};
|
|
42
|
+
export declare const JWT_CLAIM_PATH: "https://api.openai.com/auth";
|
|
43
|
+
/**
|
|
44
|
+
* Extract account ID from a Codex JWT access token.
|
|
45
|
+
* Returns undefined if the token is not a valid Codex JWT.
|
|
46
|
+
*/
|
|
47
|
+
export declare function getCodexAccountId(accessToken: string): string | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Extract the account's data residency from a Codex JWT access token.
|
|
50
|
+
*
|
|
51
|
+
* Enterprise ChatGPT workspaces can be pinned to a region. Such a workspace
|
|
52
|
+
* rejects a Codex request whose egress does not match it — HTTP 401
|
|
53
|
+
* `Workspace is not authorized in this region.` — unless the client declares
|
|
54
|
+
* the residency itself. The token already carries it, so no configuration is
|
|
55
|
+
* needed: `chatgpt_data_residency` is the authoritative claim, with
|
|
56
|
+
* `chatgpt_compute_residency` as the fallback for tokens that only carry that.
|
|
57
|
+
*
|
|
58
|
+
* Returns undefined for a non-JWT token, or for the (common) accounts whose
|
|
59
|
+
* claims omit residency entirely — those workspaces are not region-pinned.
|
|
60
|
+
*/
|
|
61
|
+
export declare function getCodexResidency(accessToken: string): string | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* Adds the token's workspace residency to Codex request headers without
|
|
64
|
+
* replacing a caller-supplied value.
|
|
65
|
+
*/
|
|
66
|
+
export declare function applyCodexResidencyHeader(headers: Headers | Record<string, string>, accessToken: string): void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const COREWEAVE_PROJECT_HEADER: "OpenAI-Project";
|
|
2
|
+
export interface CoreWeaveProjectEnv {
|
|
3
|
+
[key: string]: string | undefined;
|
|
4
|
+
COREWEAVE_PROJECT?: string;
|
|
5
|
+
WANDB_INFERENCE_PROJECT?: string;
|
|
6
|
+
WANDB_ENTITY?: string;
|
|
7
|
+
WANDB_PROJECT?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function resolveCoreWeaveProject(env: CoreWeaveProjectEnv): string | undefined;
|
|
10
|
+
export declare function coreWeaveProjectHeaders(env: CoreWeaveProjectEnv): Record<string, string> | undefined;
|
|
11
|
+
export declare function hasCoreWeaveProjectHeader(headers: Record<string, string>): boolean;
|
|
12
|
+
export declare function removeBlankCoreWeaveProjectHeaders(headers: Record<string, string>): void;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { FetchImpl } from "@rigelbuild/omp-utils";
|
|
2
|
+
/**
|
|
3
|
+
* Build a User-Agent string that identifies as Gemini CLI to unlock higher rate limits.
|
|
4
|
+
* Uses the same format as the official Gemini CLI (v0.35+):
|
|
5
|
+
* GeminiCLI/VERSION/MODEL (PLATFORM; ARCH; SURFACE)
|
|
6
|
+
*/
|
|
7
|
+
export declare function getGeminiCliUserAgent(modelId?: string): string;
|
|
8
|
+
export declare const getGeminiCliHeaders: (modelId?: string) => {
|
|
9
|
+
"User-Agent": string;
|
|
10
|
+
"Client-Metadata": string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Antigravity / Cloud Code Assist user agent. Lives in its own file so discovery
|
|
14
|
+
* and usage code can read it without pulling the heavy google-gemini-cli provider
|
|
15
|
+
* (and its @google/genai → google-auth-library dependency chain) into the startup
|
|
16
|
+
* parse graph.
|
|
17
|
+
*
|
|
18
|
+
* Format captured from the real 2.8.0 `antigravity/hub` client:
|
|
19
|
+
* `antigravity/hub/2.8.0 (aidev_client; os_type=darwin; arch=arm64; cl=963137146)`.
|
|
20
|
+
* The backend gates newer models (e.g. gemini-3.7-flash) on the client version,
|
|
21
|
+
* so the version tracks the latest Antigravity release via the update manifest
|
|
22
|
+
* (see {@link ensureAntigravityVersion}) with `DEFAULT_ANTIGRAVITY_VERSION` as
|
|
23
|
+
* the offline fallback. os_type/arch are pinned to the darwin/arm64 reference
|
|
24
|
+
* client the version and manifest are captured from, independent of the host
|
|
25
|
+
* platform. Overrides: PI_AI_ANTIGRAVITY_VERSION / _CL / _OS / _ARCH.
|
|
26
|
+
*/
|
|
27
|
+
export declare const DEFAULT_ANTIGRAVITY_VERSION = "2.8.0";
|
|
28
|
+
/** Current Antigravity client version: env override → manifest-discovered → pinned fallback. */
|
|
29
|
+
export declare function getAntigravityVersion(): string;
|
|
30
|
+
/**
|
|
31
|
+
* Extracts the client version from an electron-builder update manifest.
|
|
32
|
+
* Returns null when no well-formed `version:` line is present.
|
|
33
|
+
*/
|
|
34
|
+
export declare function parseAntigravityManifestVersion(yamlText: string): string | null;
|
|
35
|
+
/**
|
|
36
|
+
* Resolves the latest Antigravity release from the official update manifest.
|
|
37
|
+
* Success is cached for the process lifetime; failures are silent (the pinned
|
|
38
|
+
* fallback stays valid) and clear the in-flight cache so a later call retries.
|
|
39
|
+
* Skipped entirely when PI_AI_ANTIGRAVITY_VERSION is set.
|
|
40
|
+
*/
|
|
41
|
+
export declare function ensureAntigravityVersion(fetcher?: FetchImpl, signal?: AbortSignal): Promise<void>;
|
|
42
|
+
/** Antigravity `User-Agent` header value; rebuilt when the discovered version changes. */
|
|
43
|
+
export declare function getAntigravityUserAgent(): string;
|
|
44
|
+
/**
|
|
45
|
+
* Per-wire-id Antigravity Cloud Code Assist request constants, captured from the
|
|
46
|
+
* real `antigravity/hub` client against `daily-cloudcode-pa`. `modelEnum` is the
|
|
47
|
+
* opaque `labels.model_enum` token the client tags each request with — optional
|
|
48
|
+
* because Anthropic-backed wire ids (e.g. `claude-sonnet-4-6`,
|
|
49
|
+
* `claude-opus-4-6-thinking`) are accepted without one; the label is purely
|
|
50
|
+
* telemetry. `maxOutputTokens` is the fixed `generationConfig.maxOutputTokens`
|
|
51
|
+
* the backend enforces regardless of the thinking budget (Claude caps at
|
|
52
|
+
* 64000, Gemini accepts the discovered cap). Keyed by the routed upstream wire
|
|
53
|
+
* id (post effort-routing), not the collapsed logical id. Checkpoint-only ids
|
|
54
|
+
* (e.g. `gemini-3.1-flash-lite`) are intentionally absent — this provider only
|
|
55
|
+
* emits agent requests.
|
|
56
|
+
*/
|
|
57
|
+
export interface AntigravityModelWireProfile {
|
|
58
|
+
modelEnum?: string;
|
|
59
|
+
maxOutputTokens: number;
|
|
60
|
+
}
|
|
61
|
+
export declare const ANTIGRAVITY_MODEL_WIRE_PROFILES: Readonly<Record<string, AntigravityModelWireProfile>>;
|
|
62
|
+
export declare function getAntigravityModelWireProfile(wireModelId: string): AntigravityModelWireProfile | undefined;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { FetchImpl } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* GitHub Copilot wire metadata: API-key envelope parsing and endpoint
|
|
4
|
+
* derivation shared by catalog discovery and the pi-ai OAuth flow. The device
|
|
5
|
+
* login / token refresh flow lives in `@oh-my-pi/pi-ai`'s registry.
|
|
6
|
+
*/
|
|
7
|
+
export declare const COPILOT_USER_AGENT: "opencode/1.3.15";
|
|
8
|
+
export declare const OPENCODE_HEADERS: {
|
|
9
|
+
readonly "User-Agent": "opencode/1.3.15";
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Copilot API version sent on `api.githubcopilot.com` requests (`/models`,
|
|
13
|
+
* chat endpoints). Newer versions unlock tiered context metadata: `/models`
|
|
14
|
+
* reports the full long-context window in `capabilities.limits` plus per-tier
|
|
15
|
+
* boundaries/prices under `billing.token_prices.{default,long_context}`.
|
|
16
|
+
* Without it the endpoint serves default-tier limits only (e.g. 264k instead
|
|
17
|
+
* of 1M for Claude Opus). Never send this to `api.github.com` REST endpoints —
|
|
18
|
+
* they validate `X-GitHub-Api-Version` against the REST version vocabulary.
|
|
19
|
+
*/
|
|
20
|
+
export declare const COPILOT_API_VERSION: "2026-06-01";
|
|
21
|
+
/** Headers for `api.githubcopilot.com` (capi) requests: discovery, chat, policy. */
|
|
22
|
+
export declare const COPILOT_API_HEADERS: {
|
|
23
|
+
readonly "User-Agent": "opencode/1.3.15";
|
|
24
|
+
readonly "X-GitHub-Api-Version": "2026-06-01";
|
|
25
|
+
};
|
|
26
|
+
export type ParsedGitHubCopilotApiKey = {
|
|
27
|
+
accessToken: string;
|
|
28
|
+
enterpriseUrl?: string;
|
|
29
|
+
apiEndpoint?: string;
|
|
30
|
+
};
|
|
31
|
+
export declare function isPublicGitHubHost(host: string): boolean;
|
|
32
|
+
/** Canonical personal-Copilot API host. */
|
|
33
|
+
export declare const PERSONAL_GITHUB_COPILOT_BASE_URL: "https://api.githubcopilot.com";
|
|
34
|
+
/** `true` when the resolved base URL is the canonical personal-Copilot host. */
|
|
35
|
+
export declare function isPersonalGitHubCopilotBaseUrl(baseUrl: string | undefined): boolean;
|
|
36
|
+
export declare function normalizeGitHubCopilotEnterpriseDomain(input: string | undefined): string | undefined;
|
|
37
|
+
export declare function normalizeGitHubCopilotApiEndpoint(input: string | undefined): string | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Resolve the plan-specific Copilot API endpoint advertised for a GitHub token.
|
|
40
|
+
* Login and raw environment-token discovery share this best-effort probe. Pass
|
|
41
|
+
* a `signal` to bound it against the same discovery deadline as `/models`; a
|
|
42
|
+
* stalled probe otherwise blocks discovery indefinitely.
|
|
43
|
+
*/
|
|
44
|
+
export declare function discoverGitHubCopilotApiEndpoint(token: string, fetchImpl: FetchImpl, signal?: AbortSignal): Promise<string | undefined>;
|
|
45
|
+
export declare function parseGitHubCopilotApiKey(apiKeyRaw: string): ParsedGitHubCopilotApiKey;
|
|
46
|
+
export declare function normalizeDomain(input: string): string | null;
|
|
47
|
+
export declare function getGitHubCopilotBaseUrl(enterpriseDomain?: string): string;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identification of provider-side image fetchers.
|
|
3
|
+
*
|
|
4
|
+
* A request may carry an image either inline (base64) or as a URL. With a URL,
|
|
5
|
+
* the provider's backend performs its own server-side GET against that URL, so
|
|
6
|
+
* a local blob server sees an inbound request from vendor infrastructure rather
|
|
7
|
+
* than from the client. This module names those fetchers, letting a blob server
|
|
8
|
+
* attribute an inbound GET to the vendor that issued it — which is how a caller
|
|
9
|
+
* learns where a request actually landed when a router sits between them and
|
|
10
|
+
* the model.
|
|
11
|
+
*
|
|
12
|
+
* NOT an authentication mechanism. Every value here is a request header chosen
|
|
13
|
+
* by the caller and is trivially forged. Authorize blob reads with an
|
|
14
|
+
* unguessable URL (single-use capability token, short TTL) and treat a fetcher
|
|
15
|
+
* match as attribution/telemetry only.
|
|
16
|
+
*
|
|
17
|
+
* Each entry was captured from a live fetch triggered by handing that vendor's
|
|
18
|
+
* API a URL-sourced image.
|
|
19
|
+
*/
|
|
20
|
+
/** Vendor whose infrastructure performed an inbound fetch. */
|
|
21
|
+
export type ImageFetcherVendor = "openai" | "anthropic" | "xai" | "google";
|
|
22
|
+
/** Registry key for a known fetcher. */
|
|
23
|
+
export type ImageFetcherId = "openai-file-downloader" | "anthropic-claude-user" | "anthropic-claude-user-preview" | "xai-image-api-fetch" | "google";
|
|
24
|
+
/** Request signature of one provider-side fetcher. */
|
|
25
|
+
export interface ImageFetcherIdentity {
|
|
26
|
+
vendor: ImageFetcherVendor;
|
|
27
|
+
/** Human-readable name for logs and UI. */
|
|
28
|
+
label: string;
|
|
29
|
+
/**
|
|
30
|
+
* `User-Agent` contract: an exact string for fetchers that send a fixed
|
|
31
|
+
* value, or a pattern for those embedding a client version.
|
|
32
|
+
*/
|
|
33
|
+
userAgent: string | RegExp;
|
|
34
|
+
/**
|
|
35
|
+
* Vendor-proprietary headers observed alongside the agent, used to
|
|
36
|
+
* corroborate a `User-Agent` claim. Generic infrastructure headers
|
|
37
|
+
* (`traceparent`, `x-cloud-trace-context`) are deliberately excluded: they
|
|
38
|
+
* are emitted by unrelated infrastructure and corroborate nothing. Empty
|
|
39
|
+
* means the agent string is the only available signal, so
|
|
40
|
+
* {@link ImageFetcherMatch.corroborated} can never be true for that entry.
|
|
41
|
+
*/
|
|
42
|
+
markerHeaders: readonly string[];
|
|
43
|
+
/** API surface the capture came from. */
|
|
44
|
+
observedVia: string;
|
|
45
|
+
/** Operational caveats a blob server should account for. */
|
|
46
|
+
note?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Known provider-side fetchers.
|
|
50
|
+
*
|
|
51
|
+
* Agent contracts do not overlap — exact strings never collide with the
|
|
52
|
+
* versioned patterns — so lookup order carries no meaning.
|
|
53
|
+
*/
|
|
54
|
+
export declare const IMAGE_FETCHERS: Readonly<Record<ImageFetcherId, ImageFetcherIdentity>>;
|
|
55
|
+
/** Attribution outcome for one inbound request. */
|
|
56
|
+
export interface ImageFetcherMatch {
|
|
57
|
+
id: ImageFetcherId;
|
|
58
|
+
identity: ImageFetcherIdentity;
|
|
59
|
+
/**
|
|
60
|
+
* Whether every proprietary marker header for the matched identity is
|
|
61
|
+
* present. Always false for identities declaring no markers — absence of
|
|
62
|
+
* corroboration is not evidence against the match.
|
|
63
|
+
*/
|
|
64
|
+
corroborated: boolean;
|
|
65
|
+
}
|
|
66
|
+
/** Inbound header bag, as exposed by either `fetch` or a Node-style server. */
|
|
67
|
+
export type InboundHeaders = Headers | Readonly<Record<string, string | readonly string[] | undefined>>;
|
|
68
|
+
/**
|
|
69
|
+
* Attribute an inbound blob request to a known provider-side fetcher, or
|
|
70
|
+
* `null` when the agent matches none.
|
|
71
|
+
*
|
|
72
|
+
* Matches on `User-Agent` alone and reports marker-header corroboration
|
|
73
|
+
* separately; callers MUST NOT treat either as proof of origin. Gate access on
|
|
74
|
+
* the unguessable URL.
|
|
75
|
+
*/
|
|
76
|
+
export declare function identifyImageFetcher(headers: InboundHeaders): ImageFetcherMatch | null;
|
package/package.json
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "module",
|
|
3
|
+
"name": "@rigelbuild/omp-catalog",
|
|
4
|
+
"version": "18.0.3",
|
|
5
|
+
"description": "Model catalog for omp: bundled model database, provider discovery descriptors, model identity, classification, and equivalence",
|
|
6
|
+
"homepage": "https://omp.sh",
|
|
7
|
+
"author": "Stencil Labs, Inc.",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/can1357/oh-my-pi.git",
|
|
12
|
+
"directory": "packages/catalog"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/can1357/oh-my-pi/issues"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"ai",
|
|
19
|
+
"llm",
|
|
20
|
+
"models",
|
|
21
|
+
"catalog",
|
|
22
|
+
"discovery"
|
|
23
|
+
],
|
|
24
|
+
"main": "./src/index.ts",
|
|
25
|
+
"types": "./dist/types/index.d.ts",
|
|
26
|
+
"scripts": {
|
|
27
|
+
"check": "biome check . && bun run check:types",
|
|
28
|
+
"check:types": "tsgo -p tsconfig.json --noEmit",
|
|
29
|
+
"lint": "biome lint .",
|
|
30
|
+
"test": "bun test --parallel",
|
|
31
|
+
"fix": "biome check --write --unsafe .",
|
|
32
|
+
"fmt": "biome format --write .",
|
|
33
|
+
"gen:models": "bun scripts/generate-models.ts",
|
|
34
|
+
"gen:proto": "bun scripts/generate-protocols.ts"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@rigelbuild/omp-omptype": "18.0.3",
|
|
38
|
+
"@rigelbuild/omp-utils": "18.0.3"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@rigelbuild/omp-ai": "18.0.3",
|
|
42
|
+
"@types/bun": "^1.3.14"
|
|
43
|
+
},
|
|
44
|
+
"engines": {
|
|
45
|
+
"bun": ">=1.3.14"
|
|
46
|
+
},
|
|
47
|
+
"files": [
|
|
48
|
+
"src",
|
|
49
|
+
"README.md",
|
|
50
|
+
"CHANGELOG.md",
|
|
51
|
+
"LICENSE",
|
|
52
|
+
"THIRD-PARTY-NOTICES.txt",
|
|
53
|
+
"dist/types"
|
|
54
|
+
],
|
|
55
|
+
"exports": {
|
|
56
|
+
".": {
|
|
57
|
+
"types": "./dist/types/index.d.ts",
|
|
58
|
+
"import": "./src/index.ts"
|
|
59
|
+
},
|
|
60
|
+
"./models.json": {
|
|
61
|
+
"types": "./dist/types/models.json.d.d.ts",
|
|
62
|
+
"import": "./src/models.json"
|
|
63
|
+
},
|
|
64
|
+
"./provider-models": {
|
|
65
|
+
"types": "./dist/types/provider-models/index.d.ts",
|
|
66
|
+
"import": "./src/provider-models/index.ts"
|
|
67
|
+
},
|
|
68
|
+
"./provider-models/*": {
|
|
69
|
+
"types": "./dist/types/provider-models/*.d.ts",
|
|
70
|
+
"import": "./src/provider-models/*.ts"
|
|
71
|
+
},
|
|
72
|
+
"./discovery": {
|
|
73
|
+
"types": "./dist/types/discovery/index.d.ts",
|
|
74
|
+
"import": "./src/discovery/index.ts"
|
|
75
|
+
},
|
|
76
|
+
"./discovery/*": {
|
|
77
|
+
"types": "./dist/types/discovery/*.d.ts",
|
|
78
|
+
"import": "./src/discovery/*.ts"
|
|
79
|
+
},
|
|
80
|
+
"./identity": {
|
|
81
|
+
"types": "./dist/types/identity/index.d.ts",
|
|
82
|
+
"import": "./src/identity/index.ts"
|
|
83
|
+
},
|
|
84
|
+
"./identity/*": {
|
|
85
|
+
"types": "./dist/types/identity/*.d.ts",
|
|
86
|
+
"import": "./src/identity/*.ts"
|
|
87
|
+
},
|
|
88
|
+
"./wire/*": {
|
|
89
|
+
"types": "./dist/types/wire/*.d.ts",
|
|
90
|
+
"import": "./src/wire/*.ts"
|
|
91
|
+
},
|
|
92
|
+
"./compat/*": {
|
|
93
|
+
"types": "./dist/types/compat/*.d.ts",
|
|
94
|
+
"import": "./src/compat/*.ts"
|
|
95
|
+
},
|
|
96
|
+
"./*": {
|
|
97
|
+
"types": "./dist/types/*.d.ts",
|
|
98
|
+
"import": "./src/*.ts"
|
|
99
|
+
},
|
|
100
|
+
"./*.js": "./src/*.ts"
|
|
101
|
+
}
|
|
102
|
+
}
|
package/src/build.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The single Model constructor. Resolution order is a dependency chain, each
|
|
3
|
+
* step materialized exactly once per spec:
|
|
4
|
+
*
|
|
5
|
+
* 1. compat — URL/provider/id detection resolved into a complete record;
|
|
6
|
+
* 2. thinking — derived from identity + resolved compat (or trusted verbatim
|
|
7
|
+
* when the spec carries explicit metadata);
|
|
8
|
+
*
|
|
9
|
+
* Request handlers read fields — they never detect, parse ids, or allocate
|
|
10
|
+
* compat per request.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { buildAnthropicCompat } from "./compat/anthropic";
|
|
14
|
+
import { buildBedrockCompat } from "./compat/bedrock";
|
|
15
|
+
import { buildDevinCompat } from "./compat/devin";
|
|
16
|
+
import { buildOpenAICompat, buildOpenAIResponsesCompat, buildOpenRouterCompat } from "./compat/openai";
|
|
17
|
+
import { bareModelId, parseOpenAIModel, semverGte } from "./identity/classify";
|
|
18
|
+
import { isClaudeModelId } from "./identity/family";
|
|
19
|
+
import { resolveModelThinking } from "./model-thinking";
|
|
20
|
+
import { resolveModelTokenizer } from "./model-tokenizer";
|
|
21
|
+
import type { Api, CompatOf, Model, ModelSpec } from "./types";
|
|
22
|
+
import { cleanModelName } from "./utils";
|
|
23
|
+
|
|
24
|
+
function isDirectOpenAIResponsesEndpoint(spec: ModelSpec<Api>): boolean {
|
|
25
|
+
if (spec.api === "openai-responses") {
|
|
26
|
+
if (spec.provider !== "openai") return false;
|
|
27
|
+
if (!spec.baseUrl) return true;
|
|
28
|
+
try {
|
|
29
|
+
const url = new URL(spec.baseUrl);
|
|
30
|
+
return url.protocol === "https:" && url.hostname === "api.openai.com";
|
|
31
|
+
} catch {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (spec.api !== "azure-openai-responses" || (spec.provider !== "azure" && spec.provider !== "azure-openai")) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
if (!spec.baseUrl) return true;
|
|
39
|
+
try {
|
|
40
|
+
const url = new URL(spec.baseUrl);
|
|
41
|
+
return (
|
|
42
|
+
url.protocol === "https:" &&
|
|
43
|
+
(url.hostname.endsWith(".openai.azure.com") || url.hostname === "models.inference.ai.azure.com")
|
|
44
|
+
);
|
|
45
|
+
} catch {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function explicitComputerUseConfig(spec: ModelSpec<Api>): boolean | undefined {
|
|
51
|
+
return "supportsComputerUseConfig" in spec
|
|
52
|
+
? (spec as Model<Api>).supportsComputerUseConfig
|
|
53
|
+
: spec.supportsComputerUse;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function supportsOpenAIGAComputerUse(spec: ModelSpec<Api>, explicitSupport: boolean | undefined): boolean {
|
|
57
|
+
if (explicitSupport !== undefined) return explicitSupport;
|
|
58
|
+
if (!isDirectOpenAIResponsesEndpoint(spec)) return false;
|
|
59
|
+
const parsed = parseOpenAIModel(bareModelId(spec.requestModelId ?? spec.id));
|
|
60
|
+
return parsed !== null && semverGte(parsed.version, "5.4");
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Build one model from an authored spec. Bundled models.json rows are fully
|
|
65
|
+
* materialized by the generator and consumed directly (see `models.ts`), so
|
|
66
|
+
* this only runs for discovered/custom/override specs.
|
|
67
|
+
*/
|
|
68
|
+
export function buildModel<TApi extends Api>(spec: ModelSpec<TApi>): Model<TApi> {
|
|
69
|
+
const compat = buildCompat(spec) as CompatOf<TApi>;
|
|
70
|
+
const supportsComputerUseConfig = explicitComputerUseConfig(spec);
|
|
71
|
+
return {
|
|
72
|
+
...spec,
|
|
73
|
+
name: cleanModelName(spec.name),
|
|
74
|
+
requiresGlyphTokenization: isClaudeModelId(spec.id),
|
|
75
|
+
tokenizer: spec.tokenizer ?? resolveModelTokenizer(spec.requestModelId ?? spec.id),
|
|
76
|
+
thinking: resolveModelThinking(spec, compat),
|
|
77
|
+
supportsComputerUse: supportsOpenAIGAComputerUse(spec, supportsComputerUseConfig),
|
|
78
|
+
supportsComputerUseConfig,
|
|
79
|
+
compat,
|
|
80
|
+
compatConfig: spec.compat,
|
|
81
|
+
} as Model<TApi>;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function buildCompat(spec: ModelSpec<Api>): CompatOf<Api> {
|
|
85
|
+
switch (spec.api) {
|
|
86
|
+
case "openrouter":
|
|
87
|
+
return buildOpenRouterCompat(spec as ModelSpec<"openrouter">);
|
|
88
|
+
case "openai-completions":
|
|
89
|
+
return buildOpenAICompat(spec as ModelSpec<"openai-completions">);
|
|
90
|
+
case "openai-responses":
|
|
91
|
+
case "azure-openai-responses":
|
|
92
|
+
case "openai-codex-responses":
|
|
93
|
+
return buildOpenAIResponsesCompat(spec as ModelSpec<"openai-responses">);
|
|
94
|
+
case "anthropic-messages":
|
|
95
|
+
return buildAnthropicCompat(spec as ModelSpec<"anthropic-messages">);
|
|
96
|
+
case "bedrock-converse-stream":
|
|
97
|
+
return buildBedrockCompat(spec as ModelSpec<"bedrock-converse-stream">);
|
|
98
|
+
case "devin-agent":
|
|
99
|
+
return buildDevinCompat(spec as ModelSpec<"devin-agent">);
|
|
100
|
+
default:
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
}
|