@linxiraos/pi-catalog 1.0.0
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 +999 -0
- package/README.md +43 -0
- package/dist/types/build.d.ts +14 -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 +26 -0
- package/dist/types/discovery/antigravity.d.ts +70 -0
- package/dist/types/discovery/codex.d.ts +36 -0
- package/dist/types/discovery/cursor-gen/agent_pb.d.ts +16769 -0
- package/dist/types/discovery/cursor.d.ts +23 -0
- package/dist/types/discovery/devin-gen/buf/validate/validate_pb.d.ts +1715 -0
- package/dist/types/discovery/devin-gen/exa/analytics_pb/analytics_pb.d.ts +693 -0
- package/dist/types/discovery/devin-gen/exa/api_server_pb/api_server_pb.d.ts +9158 -0
- package/dist/types/discovery/devin-gen/exa/auth_pb/auth_pb.d.ts +52 -0
- package/dist/types/discovery/devin-gen/exa/auto_cascade_common_pb/auto_cascade_common_pb.d.ts +276 -0
- package/dist/types/discovery/devin-gen/exa/bug_checker_pb/bug_checker_pb.d.ts +78 -0
- package/dist/types/discovery/devin-gen/exa/cascade_plugins_pb/cascade_plugins_pb.d.ts +999 -0
- package/dist/types/discovery/devin-gen/exa/chat_pb/chat_pb.d.ts +1704 -0
- package/dist/types/discovery/devin-gen/exa/code_edit/code_edit_pb/code_edit_pb.d.ts +656 -0
- package/dist/types/discovery/devin-gen/exa/codeium_common_pb/codeium_common_pb.d.ts +15014 -0
- package/dist/types/discovery/devin-gen/exa/context_module_pb/context_module_pb.d.ts +607 -0
- package/dist/types/discovery/devin-gen/exa/cortex_pb/cortex_pb.d.ts +11830 -0
- package/dist/types/discovery/devin-gen/exa/diff_action_pb/diff_action_pb.d.ts +248 -0
- package/dist/types/discovery/devin-gen/exa/index_pb/index_pb.d.ts +1747 -0
- package/dist/types/discovery/devin-gen/exa/knowledge_base_pb/knowledge_base_pb.d.ts +509 -0
- package/dist/types/discovery/devin-gen/exa/language_server_pb/language_server_pb.d.ts +9048 -0
- package/dist/types/discovery/devin-gen/exa/opensearch_clients_pb/opensearch_clients_pb.d.ts +1760 -0
- package/dist/types/discovery/devin-gen/exa/prompt_pb/prompt_pb.d.ts +286 -0
- package/dist/types/discovery/devin-gen/exa/reactive_component_pb/reactive_component_pb.d.ts +405 -0
- package/dist/types/discovery/devin-gen/exa/trust_pb/trust_pb.d.ts +582 -0
- package/dist/types/discovery/devin.d.ts +24 -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 +5 -0
- package/dist/types/discovery/openai-compatible.d.ts +74 -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 +164 -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 +181 -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 +17 -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 +66 -0
- package/dist/types/models.d.ts +12 -0
- package/dist/types/provider-models/bundled-references.d.ts +13 -0
- package/dist/types/provider-models/cache-provider-id.d.ts +9 -0
- package/dist/types/provider-models/descriptor-types.d.ts +76 -0
- package/dist/types/provider-models/descriptors.d.ts +504 -0
- package/dist/types/provider-models/google.d.ts +27 -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 +599 -0
- package/dist/types/provider-models/special.d.ts +53 -0
- package/dist/types/types.d.ts +811 -0
- package/dist/types/utils.d.ts +20 -0
- package/dist/types/variant-collapse.d.ts +133 -0
- package/dist/types/wire/alibaba-token-plan.d.ts +22 -0
- package/dist/types/wire/codex.d.ts +42 -0
- package/dist/types/wire/coreweave.d.ts +12 -0
- package/dist/types/wire/gemini-headers.d.ts +37 -0
- package/dist/types/wire/github-copilot.d.ts +39 -0
- package/package.json +101 -0
- package/src/build.ts +94 -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 +796 -0
- package/src/discovery/antigravity.ts +253 -0
- package/src/discovery/codex.ts +346 -0
- package/src/discovery/cursor-gen/agent_pb.ts +19513 -0
- package/src/discovery/cursor.ts +396 -0
- package/src/discovery/devin-gen/buf/validate/validate_pb.ts +1862 -0
- package/src/discovery/devin-gen/exa/analytics_pb/analytics_pb.ts +871 -0
- package/src/discovery/devin-gen/exa/api_server_pb/api_server_pb.ts +11083 -0
- package/src/discovery/devin-gen/exa/auth_pb/auth_pb.ts +71 -0
- package/src/discovery/devin-gen/exa/auto_cascade_common_pb/auto_cascade_common_pb.ts +348 -0
- package/src/discovery/devin-gen/exa/bug_checker_pb/bug_checker_pb.ts +103 -0
- package/src/discovery/devin-gen/exa/cascade_plugins_pb/cascade_plugins_pb.ts +1198 -0
- package/src/discovery/devin-gen/exa/chat_pb/chat_pb.ts +2063 -0
- package/src/discovery/devin-gen/exa/code_edit/code_edit_pb/code_edit_pb.ts +810 -0
- package/src/discovery/devin-gen/exa/codeium_common_pb/codeium_common_pb.ts +18354 -0
- package/src/discovery/devin-gen/exa/context_module_pb/context_module_pb.ts +732 -0
- package/src/discovery/devin-gen/exa/cortex_pb/cortex_pb.ts +14277 -0
- package/src/discovery/devin-gen/exa/diff_action_pb/diff_action_pb.ts +312 -0
- package/src/discovery/devin-gen/exa/index_pb/index_pb.ts +2106 -0
- package/src/discovery/devin-gen/exa/knowledge_base_pb/knowledge_base_pb.ts +623 -0
- package/src/discovery/devin-gen/exa/language_server_pb/language_server_pb.ts +10918 -0
- package/src/discovery/devin-gen/exa/opensearch_clients_pb/opensearch_clients_pb.ts +2125 -0
- package/src/discovery/devin-gen/exa/prompt_pb/prompt_pb.ts +361 -0
- package/src/discovery/devin-gen/exa/reactive_component_pb/reactive_component_pb.ts +450 -0
- package/src/discovery/devin-gen/exa/trust_pb/trust_pb.ts +712 -0
- package/src/discovery/devin.ts +151 -0
- package/src/discovery/gemini.ts +260 -0
- package/src/discovery/gitlab-duo-workflow.ts +859 -0
- package/src/discovery/index.ts +5 -0
- package/src/discovery/openai-compatible.ts +249 -0
- package/src/effort.ts +18 -0
- package/src/fireworks-model-id.ts +50 -0
- package/src/hosts.ts +155 -0
- package/src/identity/bundled.ts +28 -0
- package/src/identity/classify.ts +219 -0
- package/src/identity/dialect.ts +42 -0
- package/src/identity/family.ts +366 -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 +17 -0
- package/src/model-cache.ts +285 -0
- package/src/model-manager.ts +672 -0
- package/src/model-thinking.ts +821 -0
- package/src/models.json +106099 -0
- package/src/models.json.d.ts +9 -0
- package/src/models.ts +93 -0
- package/src/provider-models/bundled-references.ts +75 -0
- package/src/provider-models/cache-provider-id.ts +68 -0
- package/src/provider-models/descriptor-types.ts +85 -0
- package/src/provider-models/descriptors.ts +584 -0
- package/src/provider-models/google.ts +107 -0
- package/src/provider-models/index.ts +7 -0
- package/src/provider-models/ollama.ts +204 -0
- package/src/provider-models/openai-compat.ts +5991 -0
- package/src/provider-models/special.ts +213 -0
- package/src/types.ts +952 -0
- package/src/utils.ts +69 -0
- package/src/variant-collapse.ts +1225 -0
- package/src/wire/alibaba-token-plan.ts +54 -0
- package/src/wire/codex.ts +60 -0
- package/src/wire/coreweave.ts +51 -0
- package/src/wire/gemini-headers.ts +74 -0
- package/src/wire/github-copilot.ts +115 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type FetchImpl } from "@linxiraos/pi-utils";
|
|
2
|
+
export { isRecord } from "@linxiraos/pi-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,133 @@
|
|
|
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
|
+
/** Provider id → hand collapse table. The CCA providers diverge on thinking transport. */
|
|
62
|
+
export declare const VARIANT_COLLAPSE_TABLES: Readonly<Record<string, VariantCollapseTable>>;
|
|
63
|
+
/**
|
|
64
|
+
* The global automatic rule: derive an `X` + `X-thinking` family for every
|
|
65
|
+
* pair where both ids are live in `specs` (trailing or infix token). Gates:
|
|
66
|
+
* - both members share the same `api`,
|
|
67
|
+
* - known pricing must match — all-zero cost rows count as unknown
|
|
68
|
+
* (aggregators routinely ship them), but twins that BOTH carry real,
|
|
69
|
+
* differing prices are distinct SKUs and never merge,
|
|
70
|
+
* - ids claimed by the provider's hand `table` are skipped (curation wins).
|
|
71
|
+
* The capability surface prefers the thinking member's metadata, then the
|
|
72
|
+
* bare member's, then the canonical deriver (aggregators often ship
|
|
73
|
+
* `reasoning: false` and no thinking config on the twin), then a budget
|
|
74
|
+
* default. `off` routes to the bare id; every supported effort routes to the
|
|
75
|
+
* thinking id.
|
|
76
|
+
*/
|
|
77
|
+
export declare function deriveThinkingPairFamilies<TSpec extends VariantSpecLike>(specs: readonly TSpec[], table?: VariantCollapseTable): EffortVariantFamily[];
|
|
78
|
+
/**
|
|
79
|
+
* True when `spec` is the output of collapsing rather than a raw upstream
|
|
80
|
+
* member. `thinking.effortRouting` is written only by collapsing; the
|
|
81
|
+
* `requestModelId` arm is scoped to the provider's hand-table family ids so
|
|
82
|
+
* unrelated carriers (GitHub Copilot `-1m` context variants) never match.
|
|
83
|
+
*/
|
|
84
|
+
export declare function isVariantCollapsedSpec(spec: VariantSpecLike): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Collapse every family in `table` found in `specs`. Non-member specs pass
|
|
87
|
+
* through verbatim (by reference), order preserved; the collapsed spec
|
|
88
|
+
* replaces the first occurrence of its family.
|
|
89
|
+
*/
|
|
90
|
+
export declare function collapseEffortVariants<TSpec extends VariantSpecLike>(specs: readonly TSpec[], table: VariantCollapseTable): TSpec[];
|
|
91
|
+
/**
|
|
92
|
+
* Collapse a full mixed-provider list: per provider, the hand table (when
|
|
93
|
+
* registered) plus the automatic `X`/`X-thinking` pair rule. Used by the
|
|
94
|
+
* catalog generator; the runtime equivalent lives at the model-manager merge
|
|
95
|
+
* point. Output is regrouped by provider — callers re-sort.
|
|
96
|
+
*/
|
|
97
|
+
export declare function collapseEffortVariantsAcrossProviders<TSpec extends VariantSpecLike>(specs: readonly TSpec[]): TSpec[];
|
|
98
|
+
/**
|
|
99
|
+
* Runtime entry point for already-built `Model` lists (the model-manager
|
|
100
|
+
* merge point, coding-agent registry custom providers): collapses hand
|
|
101
|
+
* tables plus derived pairs, then re-runs `buildModel` on freshly created
|
|
102
|
+
* logical specs so thinking wire defaults stay resolved. Untouched entries
|
|
103
|
+
* pass through by reference.
|
|
104
|
+
*/
|
|
105
|
+
export declare function collapseBuiltModelVariants<TApi extends Api>(models: readonly Model<TApi>[]): Model<TApi>[];
|
|
106
|
+
/**
|
|
107
|
+
* Resolve a retired effort-tier variant id (collapsed member, recycled id) to
|
|
108
|
+
* its replacement model id for `provider` via the hand table. Returns
|
|
109
|
+
* `undefined` when the id is not a known alias; derived `X-thinking` members
|
|
110
|
+
* resolve through `stripThinkingVariantToken` instead. Callers must try an
|
|
111
|
+
* exact model lookup first — a live model always wins over an alias.
|
|
112
|
+
*/
|
|
113
|
+
export declare function resolveVariantAlias(provider: Provider, modelId: string): string | undefined;
|
|
114
|
+
/** Bare-id alias hit: replacement id plus the providers declaring it. */
|
|
115
|
+
export interface BareVariantAliasHit {
|
|
116
|
+
id: string;
|
|
117
|
+
/** Providers whose table declares the alias — candidates from these win ties. */
|
|
118
|
+
providers: readonly Provider[];
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Provider-agnostic hand-table alias lookup for bare-id selectors. Returns
|
|
122
|
+
* the declaring providers so callers can prefer their models when the
|
|
123
|
+
* replacement id exists on unrelated providers too (e.g. a retired Cursor
|
|
124
|
+
* tier id must not resolve to `openai/gpt-5.4`).
|
|
125
|
+
*/
|
|
126
|
+
export declare function resolveBareVariantAlias(modelId: string): BareVariantAliasHit | undefined;
|
|
127
|
+
/**
|
|
128
|
+
* Reverse alias lookup: the retired ids that resolve to `modelId` for
|
|
129
|
+
* `provider` via the hand table. Used to re-key config keyed by raw member
|
|
130
|
+
* ids (models.yml `modelOverrides`, suppressed selectors) onto the collapsed
|
|
131
|
+
* model. Empty for providers without a table.
|
|
132
|
+
*/
|
|
133
|
+
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,42 @@
|
|
|
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
|
+
readonly ACCOUNT_ID: "chatgpt-account-id";
|
|
12
|
+
readonly ORIGINATOR: "originator";
|
|
13
|
+
readonly VERSION: "version";
|
|
14
|
+
readonly SESSION_ID: "session_id";
|
|
15
|
+
readonly CONVERSATION_ID: "conversation_id";
|
|
16
|
+
readonly SCOPED_SESSION_ID: "session-id";
|
|
17
|
+
readonly THREAD_ID: "thread-id";
|
|
18
|
+
readonly INSTALLATION_ID: "x-codex-installation-id";
|
|
19
|
+
readonly WINDOW_ID: "x-codex-window-id";
|
|
20
|
+
readonly TURN_METADATA: "x-codex-turn-metadata";
|
|
21
|
+
readonly PARENT_THREAD_ID: "x-codex-parent-thread-id";
|
|
22
|
+
readonly SUBAGENT: "x-openai-subagent";
|
|
23
|
+
/** Responses Lite transport marker (codex-rs `add_responses_lite_header`); value is always `"true"`. */
|
|
24
|
+
readonly RESPONSES_LITE: "x-openai-internal-codex-responses-lite";
|
|
25
|
+
/** DeviceCheck attestation envelope (codex-rs `X_OAI_ATTESTATION_HEADER`); sent on ChatGPT-OAuth requests. */
|
|
26
|
+
readonly ATTESTATION: "x-oai-attestation";
|
|
27
|
+
};
|
|
28
|
+
export declare const OPENAI_HEADER_VALUES: {
|
|
29
|
+
readonly BETA_RESPONSES: "responses=experimental";
|
|
30
|
+
readonly BETA_RESPONSES_WEBSOCKETS_V2: "responses_websockets=2026-02-06";
|
|
31
|
+
readonly ORIGINATOR_CODEX: "pi";
|
|
32
|
+
};
|
|
33
|
+
export declare const URL_PATHS: {
|
|
34
|
+
readonly RESPONSES: "/responses";
|
|
35
|
+
readonly CODEX_RESPONSES: "/codex/responses";
|
|
36
|
+
};
|
|
37
|
+
export declare const JWT_CLAIM_PATH: "https://api.openai.com/auth";
|
|
38
|
+
/**
|
|
39
|
+
* Extract account ID from a Codex JWT access token.
|
|
40
|
+
* Returns undefined if the token is not a valid Codex JWT.
|
|
41
|
+
*/
|
|
42
|
+
export declare function getCodexAccountId(accessToken: string): string | undefined;
|
|
@@ -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,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build a User-Agent string that identifies as Gemini CLI to unlock higher rate limits.
|
|
3
|
+
* Uses the same format as the official Gemini CLI (v0.35+):
|
|
4
|
+
* GeminiCLI/VERSION/MODEL (PLATFORM; ARCH; SURFACE)
|
|
5
|
+
*/
|
|
6
|
+
export declare function getGeminiCliUserAgent(modelId?: string): string;
|
|
7
|
+
export declare const getGeminiCliHeaders: (modelId?: string) => {
|
|
8
|
+
"User-Agent": string;
|
|
9
|
+
"Client-Metadata": string;
|
|
10
|
+
};
|
|
11
|
+
export declare const ANTIGRAVITY_SYSTEM_INSTRUCTION: string;
|
|
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
|
+
export declare let getAntigravityUserAgent: () => string;
|
|
19
|
+
/**
|
|
20
|
+
* Per-wire-id Antigravity Cloud Code Assist request constants, captured from the
|
|
21
|
+
* real `antigravity/hub` client against `daily-cloudcode-pa`. `modelEnum` is the
|
|
22
|
+
* opaque `labels.model_enum` token the client tags each request with — optional
|
|
23
|
+
* because Anthropic-backed wire ids (e.g. `claude-sonnet-4-6`,
|
|
24
|
+
* `claude-opus-4-6-thinking`) are accepted without one; the label is purely
|
|
25
|
+
* telemetry. `maxOutputTokens` is the fixed `generationConfig.maxOutputTokens`
|
|
26
|
+
* the backend enforces regardless of the thinking budget (Claude caps at
|
|
27
|
+
* 64000, Gemini accepts the discovered cap). Keyed by the routed upstream wire
|
|
28
|
+
* id (post effort-routing), not the collapsed logical id. Checkpoint-only ids
|
|
29
|
+
* (e.g. `gemini-3.1-flash-lite`) are intentionally absent — this provider only
|
|
30
|
+
* emits agent requests.
|
|
31
|
+
*/
|
|
32
|
+
export interface AntigravityModelWireProfile {
|
|
33
|
+
modelEnum?: string;
|
|
34
|
+
maxOutputTokens: number;
|
|
35
|
+
}
|
|
36
|
+
export declare const ANTIGRAVITY_MODEL_WIRE_PROFILES: Readonly<Record<string, AntigravityModelWireProfile>>;
|
|
37
|
+
export declare function getAntigravityModelWireProfile(wireModelId: string): AntigravityModelWireProfile | undefined;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub Copilot wire metadata: API-key envelope parsing and endpoint
|
|
3
|
+
* derivation shared by catalog discovery and the pi-ai OAuth flow. The device
|
|
4
|
+
* login / token refresh flow lives in `@linxiraos/pi-ai`'s registry.
|
|
5
|
+
*/
|
|
6
|
+
export declare const COPILOT_USER_AGENT: "opencode/1.3.15";
|
|
7
|
+
export declare const OPENCODE_HEADERS: {
|
|
8
|
+
readonly "User-Agent": "opencode/1.3.15";
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Copilot API version sent on `api.githubcopilot.com` requests (`/models`,
|
|
12
|
+
* chat endpoints). Newer versions unlock tiered context metadata: `/models`
|
|
13
|
+
* reports the full long-context window in `capabilities.limits` plus per-tier
|
|
14
|
+
* boundaries/prices under `billing.token_prices.{default,long_context}`.
|
|
15
|
+
* Without it the endpoint serves default-tier limits only (e.g. 264k instead
|
|
16
|
+
* of 1M for Claude Opus). Never send this to `api.github.com` REST endpoints —
|
|
17
|
+
* they validate `X-GitHub-Api-Version` against the REST version vocabulary.
|
|
18
|
+
*/
|
|
19
|
+
export declare const COPILOT_API_VERSION: "2026-06-01";
|
|
20
|
+
/** Headers for `api.githubcopilot.com` (capi) requests: discovery, chat, policy. */
|
|
21
|
+
export declare const COPILOT_API_HEADERS: {
|
|
22
|
+
readonly "User-Agent": "opencode/1.3.15";
|
|
23
|
+
readonly "X-GitHub-Api-Version": "2026-06-01";
|
|
24
|
+
};
|
|
25
|
+
export type ParsedGitHubCopilotApiKey = {
|
|
26
|
+
accessToken: string;
|
|
27
|
+
enterpriseUrl?: string;
|
|
28
|
+
apiEndpoint?: string;
|
|
29
|
+
};
|
|
30
|
+
export declare function isPublicGitHubHost(host: string): boolean;
|
|
31
|
+
/** Canonical personal-Copilot API host. */
|
|
32
|
+
export declare const PERSONAL_GITHUB_COPILOT_BASE_URL: "https://api.githubcopilot.com";
|
|
33
|
+
/** `true` when the resolved base URL is the canonical personal-Copilot host. */
|
|
34
|
+
export declare function isPersonalGitHubCopilotBaseUrl(baseUrl: string | undefined): boolean;
|
|
35
|
+
export declare function normalizeGitHubCopilotEnterpriseDomain(input: string | undefined): string | undefined;
|
|
36
|
+
export declare function normalizeGitHubCopilotApiEndpoint(input: string | undefined): string | undefined;
|
|
37
|
+
export declare function parseGitHubCopilotApiKey(apiKeyRaw: string): ParsedGitHubCopilotApiKey;
|
|
38
|
+
export declare function normalizeDomain(input: string): string | null;
|
|
39
|
+
export declare function getGitHubCopilotBaseUrl(enterpriseDomain?: string): string;
|
package/package.json
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "module",
|
|
3
|
+
"name": "@linxiraos/pi-catalog",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "Model catalog for omp: bundled model database, provider discovery descriptors, model identity, classification, and equivalence",
|
|
6
|
+
"homepage": "https://linxira-os.github.io",
|
|
7
|
+
"author": "Can Boluk",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/Linxira-OS/linxira-zeta.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:cursor-proto": "protoc --plugin=protoc-gen-es=../../node_modules/.bin/protoc-gen-es --es_out=src/discovery/cursor-gen --es_opt=target=ts -I ../ai/src/providers/cursor/proto ../ai/src/providers/cursor/proto/agent.proto"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@bufbuild/protobuf": "^2.12.1",
|
|
38
|
+
"@linxiraos/pi-omptype": "1.0.0",
|
|
39
|
+
"@linxiraos/pi-utils": "1.0.0"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@types/bun": "^1.3.14",
|
|
43
|
+
"@linxiraos/pi-ai": "1.0.0"
|
|
44
|
+
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"bun": ">=1.3.14"
|
|
47
|
+
},
|
|
48
|
+
"files": [
|
|
49
|
+
"src",
|
|
50
|
+
"README.md",
|
|
51
|
+
"CHANGELOG.md",
|
|
52
|
+
"dist/types"
|
|
53
|
+
],
|
|
54
|
+
"exports": {
|
|
55
|
+
".": {
|
|
56
|
+
"types": "./dist/types/index.d.ts",
|
|
57
|
+
"import": "./src/index.ts"
|
|
58
|
+
},
|
|
59
|
+
"./models.json": {
|
|
60
|
+
"types": "./dist/types/models.json.d.d.ts",
|
|
61
|
+
"import": "./src/models.json"
|
|
62
|
+
},
|
|
63
|
+
"./provider-models": {
|
|
64
|
+
"types": "./dist/types/provider-models/index.d.ts",
|
|
65
|
+
"import": "./src/provider-models/index.ts"
|
|
66
|
+
},
|
|
67
|
+
"./provider-models/*": {
|
|
68
|
+
"types": "./dist/types/provider-models/*.d.ts",
|
|
69
|
+
"import": "./src/provider-models/*.ts"
|
|
70
|
+
},
|
|
71
|
+
"./discovery": {
|
|
72
|
+
"types": "./dist/types/discovery/index.d.ts",
|
|
73
|
+
"import": "./src/discovery/index.ts"
|
|
74
|
+
},
|
|
75
|
+
"./discovery/*": {
|
|
76
|
+
"types": "./dist/types/discovery/*.d.ts",
|
|
77
|
+
"import": "./src/discovery/*.ts"
|
|
78
|
+
},
|
|
79
|
+
"./identity": {
|
|
80
|
+
"types": "./dist/types/identity/index.d.ts",
|
|
81
|
+
"import": "./src/identity/index.ts"
|
|
82
|
+
},
|
|
83
|
+
"./identity/*": {
|
|
84
|
+
"types": "./dist/types/identity/*.d.ts",
|
|
85
|
+
"import": "./src/identity/*.ts"
|
|
86
|
+
},
|
|
87
|
+
"./wire/*": {
|
|
88
|
+
"types": "./dist/types/wire/*.d.ts",
|
|
89
|
+
"import": "./src/wire/*.ts"
|
|
90
|
+
},
|
|
91
|
+
"./compat/*": {
|
|
92
|
+
"types": "./dist/types/compat/*.d.ts",
|
|
93
|
+
"import": "./src/compat/*.ts"
|
|
94
|
+
},
|
|
95
|
+
"./*": {
|
|
96
|
+
"types": "./dist/types/*.d.ts",
|
|
97
|
+
"import": "./src/*.ts"
|
|
98
|
+
},
|
|
99
|
+
"./*.js": "./src/*.ts"
|
|
100
|
+
}
|
|
101
|
+
}
|
package/src/build.ts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
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 { resolveModelThinking } from "./model-thinking";
|
|
18
|
+
import type { Api, CompatOf, Model, ModelSpec } from "./types";
|
|
19
|
+
import { cleanModelName } from "./utils";
|
|
20
|
+
|
|
21
|
+
const OPENAI_GA_COMPUTER_MODEL_RE = /^gpt-5\.(?:[4-9]|[1-9]\d)(?:[.-]|$)/i;
|
|
22
|
+
|
|
23
|
+
function isDirectOpenAIResponsesEndpoint(spec: ModelSpec<Api>): boolean {
|
|
24
|
+
if (spec.api === "openai-responses") {
|
|
25
|
+
if (spec.provider !== "openai") return false;
|
|
26
|
+
if (!spec.baseUrl) return true;
|
|
27
|
+
try {
|
|
28
|
+
const url = new URL(spec.baseUrl);
|
|
29
|
+
return url.protocol === "https:" && url.hostname === "api.openai.com";
|
|
30
|
+
} catch {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (spec.api !== "azure-openai-responses" || (spec.provider !== "azure" && spec.provider !== "azure-openai")) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
if (!spec.baseUrl) return true;
|
|
38
|
+
try {
|
|
39
|
+
const url = new URL(spec.baseUrl);
|
|
40
|
+
return (
|
|
41
|
+
url.protocol === "https:" &&
|
|
42
|
+
(url.hostname.endsWith(".openai.azure.com") || url.hostname === "models.inference.ai.azure.com")
|
|
43
|
+
);
|
|
44
|
+
} catch {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function explicitComputerUseConfig(spec: ModelSpec<Api>): boolean | undefined {
|
|
50
|
+
return "supportsComputerUseConfig" in spec
|
|
51
|
+
? (spec as Model<Api>).supportsComputerUseConfig
|
|
52
|
+
: spec.supportsComputerUse;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function supportsOpenAIGAComputerUse(spec: ModelSpec<Api>, explicitSupport: boolean | undefined): boolean {
|
|
56
|
+
if (explicitSupport !== undefined) return explicitSupport;
|
|
57
|
+
if (!isDirectOpenAIResponsesEndpoint(spec)) return false;
|
|
58
|
+
return OPENAI_GA_COMPUTER_MODEL_RE.test(spec.requestModelId ?? spec.id);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function buildModel<TApi extends Api>(spec: ModelSpec<TApi>): Model<TApi> {
|
|
62
|
+
const compat = buildCompat(spec) as CompatOf<TApi>;
|
|
63
|
+
const supportsComputerUseConfig = explicitComputerUseConfig(spec);
|
|
64
|
+
return {
|
|
65
|
+
...spec,
|
|
66
|
+
name: cleanModelName(spec.name),
|
|
67
|
+
thinking: resolveModelThinking(spec, compat),
|
|
68
|
+
supportsComputerUse: supportsOpenAIGAComputerUse(spec, supportsComputerUseConfig),
|
|
69
|
+
supportsComputerUseConfig,
|
|
70
|
+
compat,
|
|
71
|
+
compatConfig: spec.compat,
|
|
72
|
+
} as Model<TApi>;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function buildCompat(spec: ModelSpec<Api>): CompatOf<Api> {
|
|
76
|
+
switch (spec.api) {
|
|
77
|
+
case "openrouter":
|
|
78
|
+
return buildOpenRouterCompat(spec as ModelSpec<"openrouter">);
|
|
79
|
+
case "openai-completions":
|
|
80
|
+
return buildOpenAICompat(spec as ModelSpec<"openai-completions">);
|
|
81
|
+
case "openai-responses":
|
|
82
|
+
case "azure-openai-responses":
|
|
83
|
+
case "openai-codex-responses":
|
|
84
|
+
return buildOpenAIResponsesCompat(spec as ModelSpec<"openai-responses">);
|
|
85
|
+
case "anthropic-messages":
|
|
86
|
+
return buildAnthropicCompat(spec as ModelSpec<"anthropic-messages">);
|
|
87
|
+
case "bedrock-converse-stream":
|
|
88
|
+
return buildBedrockCompat(spec as ModelSpec<"bedrock-converse-stream">);
|
|
89
|
+
case "devin-agent":
|
|
90
|
+
return buildDevinCompat(spec as ModelSpec<"devin-agent">);
|
|
91
|
+
default:
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
}
|