@linxiraos/pi-catalog 1.1.8 → 1.1.9
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 +2 -3
- package/package.json +96 -102
- package/src/compat/axes.ts +11 -0
- package/src/compat/delegation.ts +37 -0
- package/src/compat/resolve.ts +2 -0
- package/src/compat/rules/README.md +5 -5
- package/src/compat/rules/auth/openai-codex.kdl +1 -1
- package/src/compat/rules/auth/zai-coding-plan.kdl +7 -3
- package/src/compat/rules/classes/openai.kdl +16 -0
- package/src/compat/rules/providers/openai-codex.kdl +2 -2
- package/src/compat/rules/providers/openai.kdl +1 -1
- package/src/compat/rules.json +67 -16
- package/src/compat/types.ts +4 -2
- package/src/discovery/codex.ts +10 -0
- package/src/identity/metrics.ts +165 -0
- package/src/identity/reference.ts +7 -1
- package/src/model-manager.ts +15 -2
- package/src/models.json +4861 -382
- package/src/provider-models/openai-compat.ts +4 -0
- package/src/provider-models/special.ts +25 -10
- package/src/types.ts +17 -0
- package/src/wire/codex.ts +23 -2
- package/THIRD-PARTY-NOTICES.txt +0 -22909
- package/dist/types/build.d.ts +0 -24
- package/dist/types/cline-pass-model-id.d.ts +0 -4
- package/dist/types/compat/anthropic.d.ts +0 -24
- package/dist/types/compat/apply.d.ts +0 -7
- package/dist/types/compat/auth-ids.d.ts +0 -4
- package/dist/types/compat/auth.d.ts +0 -7
- package/dist/types/compat/axes.d.ts +0 -50
- package/dist/types/compat/behavior.d.ts +0 -69
- package/dist/types/compat/cascade.d.ts +0 -37
- package/dist/types/compat/collapse.d.ts +0 -171
- package/dist/types/compat/openai.d.ts +0 -9
- package/dist/types/compat/resolve.d.ts +0 -15
- package/dist/types/compat/revision.d.ts +0 -41
- package/dist/types/compat/taxonomy.d.ts +0 -93
- package/dist/types/compat/types.d.ts +0 -565
- package/dist/types/discovery/antigravity.d.ts +0 -70
- package/dist/types/discovery/codex.d.ts +0 -36
- package/dist/types/discovery/cursor-proto.d.ts +0 -5368
- package/dist/types/discovery/cursor.d.ts +0 -31
- package/dist/types/discovery/devin-proto.d.ts +0 -1912
- package/dist/types/discovery/devin.d.ts +0 -24
- package/dist/types/discovery/gemini-cli.d.ts +0 -33
- package/dist/types/discovery/gemini.d.ts +0 -25
- package/dist/types/discovery/gitlab-duo-workflow.d.ts +0 -30
- package/dist/types/discovery/index.d.ts +0 -7
- package/dist/types/discovery/openai-compatible.d.ts +0 -89
- package/dist/types/discovery/protobuf.d.ts +0 -102
- package/dist/types/effort.d.ts +0 -10
- package/dist/types/fireworks-model-id.d.ts +0 -23
- package/dist/types/hosts.d.ts +0 -169
- package/dist/types/identity/bundled.d.ts +0 -3
- package/dist/types/identity/dialect.d.ts +0 -3
- package/dist/types/identity/id.d.ts +0 -13
- package/dist/types/identity/index.d.ts +0 -8
- package/dist/types/identity/priority.d.ts +0 -1
- package/dist/types/identity/reference.d.ts +0 -19
- package/dist/types/index.d.ts +0 -19
- package/dist/types/model-cache.d.ts +0 -23
- package/dist/types/model-manager.d.ts +0 -93
- package/dist/types/model-thinking.d.ts +0 -63
- package/dist/types/model-tokenizer.d.ts +0 -8
- package/dist/types/models.d.ts +0 -17
- package/dist/types/provider-models/bundled-references.d.ts +0 -13
- package/dist/types/provider-models/cache-provider-id.d.ts +0 -11
- package/dist/types/provider-models/cline-pass.d.ts +0 -22
- package/dist/types/provider-models/descriptor-types.d.ts +0 -76
- package/dist/types/provider-models/descriptors.d.ts +0 -543
- package/dist/types/provider-models/google.d.ts +0 -29
- package/dist/types/provider-models/index.d.ts +0 -7
- package/dist/types/provider-models/models-dev-policies.d.ts +0 -9
- package/dist/types/provider-models/ollama.d.ts +0 -22
- package/dist/types/provider-models/openai-compat.d.ts +0 -716
- package/dist/types/provider-models/special.d.ts +0 -74
- package/dist/types/types.d.ts +0 -1043
- package/dist/types/utils.d.ts +0 -20
- package/dist/types/wire/alibaba-token-plan.d.ts +0 -22
- package/dist/types/wire/cline-pass.d.ts +0 -21
- package/dist/types/wire/cloudflare-ai-gateway.d.ts +0 -18
- package/dist/types/wire/codex.d.ts +0 -66
- package/dist/types/wire/coreweave.d.ts +0 -12
- package/dist/types/wire/devin-proto.d.ts +0 -14
- package/dist/types/wire/devin.d.ts +0 -36
- package/dist/types/wire/gemini-headers.d.ts +0 -62
- package/dist/types/wire/github-copilot.d.ts +0 -66
- package/dist/types/wire/image-fetchers.d.ts +0 -76
|
@@ -110,6 +110,8 @@ export interface ModelsDevModel {
|
|
|
110
110
|
};
|
|
111
111
|
status?: string;
|
|
112
112
|
provider?: { npm?: string };
|
|
113
|
+
int?: number;
|
|
114
|
+
tps?: number;
|
|
113
115
|
}
|
|
114
116
|
|
|
115
117
|
function toModelName(value: unknown, fallback: string): string {
|
|
@@ -6518,6 +6520,8 @@ export function mapModelsDevToModels(
|
|
|
6518
6520
|
},
|
|
6519
6521
|
contextWindow: toPositiveNumber(m.limit?.context, desc.defaultContextWindow ?? null),
|
|
6520
6522
|
maxTokens: toPositiveNumber(m.limit?.output, desc.defaultMaxTokens ?? null),
|
|
6523
|
+
...(m.int != null ? { int: m.int } : {}),
|
|
6524
|
+
...(m.tps != null ? { tps: m.tps } : {}),
|
|
6521
6525
|
...(m.tool_call === false ? { supportsTools: false } : {}),
|
|
6522
6526
|
...(desc.compat && { compat: desc.compat }),
|
|
6523
6527
|
...(desc.headers && { headers: { ...desc.headers } }),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { once } from "@linxiraos/pi-utils";
|
|
1
|
+
import { logger, once } from "@linxiraos/pi-utils";
|
|
2
2
|
import { buildModel } from "../build";
|
|
3
3
|
import { apiRouteFor } from "../compat/behavior";
|
|
4
4
|
import { type CodexModelDiscoveryResult, fetchCodexModels } from "../discovery/codex";
|
|
@@ -55,14 +55,15 @@ export function openaiCodexModelManagerOptions(
|
|
|
55
55
|
const accounts = await resolveAccounts();
|
|
56
56
|
if (!accounts || accounts.length === 0) return null;
|
|
57
57
|
const results = await Promise.all(
|
|
58
|
-
accounts.map(account =>
|
|
59
|
-
|
|
58
|
+
accounts.map(async account => ({
|
|
59
|
+
accountId: account.accountId,
|
|
60
|
+
result: await fetchCodexModels({
|
|
60
61
|
accessToken: account.accessToken,
|
|
61
62
|
accountId: account.accountId,
|
|
62
63
|
clientVersion,
|
|
63
64
|
fetchFn: fetch,
|
|
64
65
|
}),
|
|
65
|
-
),
|
|
66
|
+
})),
|
|
66
67
|
);
|
|
67
68
|
return unionCodexModels(results);
|
|
68
69
|
},
|
|
@@ -73,21 +74,35 @@ export function openaiCodexModelManagerOptions(
|
|
|
73
74
|
|
|
74
75
|
/**
|
|
75
76
|
* Merge complete per-account Codex catalogs into one authoritative list,
|
|
76
|
-
* deduped by model id (first account to expose an id wins).
|
|
77
|
-
*
|
|
78
|
-
*
|
|
77
|
+
* deduped by model id (first account to expose an id wins).
|
|
78
|
+
*
|
|
79
|
+
* Returns `null` when any account's fetch failed transiently, so a partial list
|
|
80
|
+
* cannot replace the previous or bundled authoritative catalog. An account
|
|
81
|
+
* whose credential the backend rejected outright (401/403 — revoked or
|
|
82
|
+
* deauthorized) contributes nothing and is skipped instead: it would otherwise
|
|
83
|
+
* veto every sibling account's models until the user removes it. If no account
|
|
84
|
+
* produced a catalog, discovery aborts the same way.
|
|
79
85
|
*/
|
|
80
86
|
function unionCodexModels(
|
|
81
|
-
results: readonly
|
|
87
|
+
results: readonly { accountId: string | undefined; result: CodexModelDiscoveryResult | null }[],
|
|
82
88
|
): ModelSpec<"openai-codex-responses">[] | null {
|
|
83
89
|
const byId = new Map<string, ModelSpec<"openai-codex-responses">>();
|
|
84
|
-
|
|
90
|
+
let catalogs = 0;
|
|
91
|
+
for (const { accountId, result } of results) {
|
|
85
92
|
if (!result) return null;
|
|
93
|
+
if (result.rejectedStatus !== undefined) {
|
|
94
|
+
logger.warn("Codex model discovery skipped an account whose credential was rejected", {
|
|
95
|
+
accountId,
|
|
96
|
+
status: result.rejectedStatus,
|
|
97
|
+
});
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
catalogs++;
|
|
86
101
|
for (const model of result.models) {
|
|
87
102
|
if (!byId.has(model.id)) byId.set(model.id, model);
|
|
88
103
|
}
|
|
89
104
|
}
|
|
90
|
-
return [...byId.values()];
|
|
105
|
+
return catalogs > 0 ? [...byId.values()] : null;
|
|
91
106
|
}
|
|
92
107
|
|
|
93
108
|
// ---------------------------------------------------------------------------
|
package/src/types.ts
CHANGED
|
@@ -820,6 +820,13 @@ export interface ResolvedOpenAIResponsesCompat extends ResolvedOpenAISharedCompa
|
|
|
820
820
|
* transport; earlier ids reject the value.
|
|
821
821
|
*/
|
|
822
822
|
supportsAllTurnsReasoningContext: boolean;
|
|
823
|
+
/**
|
|
824
|
+
* Whether a `configuration_update` input item may change `reasoning.effort`
|
|
825
|
+
* mid-conversation while the request-level effort stays byte-stable for
|
|
826
|
+
* prompt caching. Rule-owned: GPT-6 Astra only; every other model rejects
|
|
827
|
+
* the item type with 400.
|
|
828
|
+
*/
|
|
829
|
+
supportsConfigurationUpdate: boolean;
|
|
823
830
|
/** Inject the `# Juice: 0 !important` developer item when reasoning is forced off (gpt-5.6+). */
|
|
824
831
|
requiresReasoningOffJuiceInstruction: boolean;
|
|
825
832
|
/**
|
|
@@ -1173,6 +1180,10 @@ export interface Model<TApi extends Api = Api> {
|
|
|
1173
1180
|
isRecommended?: boolean;
|
|
1174
1181
|
/** Canonical thinking capability metadata for this model. */
|
|
1175
1182
|
thinking?: ThinkingConfig;
|
|
1183
|
+
/** Intelligence score delivered by the model catalog. */
|
|
1184
|
+
int?: number | null;
|
|
1185
|
+
/** Catalog-estimated output speed in tokens per second. */
|
|
1186
|
+
tps?: number | null;
|
|
1176
1187
|
/**
|
|
1177
1188
|
* Fully-resolved compatibility record, materialized once by `buildModel`.
|
|
1178
1189
|
* Protocol handlers read fields; they never detect, resolve, or allocate.
|
|
@@ -1207,6 +1218,12 @@ export interface Model<TApi extends Api = Api> {
|
|
|
1207
1218
|
guardrailVersion?: string;
|
|
1208
1219
|
/** Bedrock guardrail trace verbosity. */
|
|
1209
1220
|
guardrailTrace?: "enabled" | "disabled" | "enabled_full";
|
|
1221
|
+
/**
|
|
1222
|
+
* Bedrock invocation-log tags attached to every Converse request for this
|
|
1223
|
+
* model. Set from `providers.<provider>.requestMetadata`; the Bedrock
|
|
1224
|
+
* transport reads it directly and validates it against AWS's limits.
|
|
1225
|
+
*/
|
|
1226
|
+
requestMetadata?: Record<string, string>;
|
|
1210
1227
|
}
|
|
1211
1228
|
|
|
1212
1229
|
/**
|
package/src/wire/codex.ts
CHANGED
|
@@ -6,8 +6,12 @@ export const CODEX_BASE_URL = "https://chatgpt.com/backend-api";
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Pinned OpenAI Codex client version (corresponds to @openai/codex package version).
|
|
9
|
+
*
|
|
10
|
+
* The backend version-gates model availability against this value on both
|
|
11
|
+
* `/models?client_version=` and `/responses` (`gpt-6-astra` requires ≥ 0.153.0);
|
|
12
|
+
* an older pin silently hides newer SKUs from discovery.
|
|
9
13
|
*/
|
|
10
|
-
export const CODEX_CLIENT_VERSION = "0.
|
|
14
|
+
export const CODEX_CLIENT_VERSION = "0.153.0";
|
|
11
15
|
|
|
12
16
|
export const OPENAI_HEADERS = {
|
|
13
17
|
BETA: "OpenAI-Beta",
|
|
@@ -31,13 +35,20 @@ export const OPENAI_HEADERS = {
|
|
|
31
35
|
ATTESTATION: "x-oai-attestation",
|
|
32
36
|
/** Client-declared data residency for region-pinned enterprise workspaces. */
|
|
33
37
|
RESIDENCY: "x-openai-internal-codex-residency",
|
|
38
|
+
/**
|
|
39
|
+
* Model routing hint (codex-rs `X_CODEX_ROUTING_HINT_HEADER`): `model=<slug>`
|
|
40
|
+
* or `model=<slug>;tier=<service_tier>`; sent on every ChatGPT-OAuth
|
|
41
|
+
* Responses, compaction, and WebSocket handshake request. Built by
|
|
42
|
+
* {@link codexRoutingHint}.
|
|
43
|
+
*/
|
|
44
|
+
ROUTING_HINT: "x-codex-routing-hint",
|
|
34
45
|
} as const;
|
|
35
46
|
|
|
36
47
|
export const OPENAI_HEADER_VALUES = {
|
|
37
48
|
BETA_RESPONSES: "responses=experimental",
|
|
38
49
|
BETA_RESPONSES_WEBSOCKETS_V2: "responses_websockets=2026-02-06",
|
|
39
50
|
REMOTE_COMPACTION_V2: "remote_compaction_v2",
|
|
40
|
-
ORIGINATOR_CODEX: "
|
|
51
|
+
ORIGINATOR_CODEX: "omp",
|
|
41
52
|
} as const;
|
|
42
53
|
|
|
43
54
|
export const URL_PATHS = {
|
|
@@ -47,6 +58,16 @@ export const URL_PATHS = {
|
|
|
47
58
|
|
|
48
59
|
export const JWT_CLAIM_PATH = "https://api.openai.com/auth" as const;
|
|
49
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Build the `x-codex-routing-hint` value for a request (codex-rs
|
|
63
|
+
* `build_routing_hint_header`): the requested model slug plus the explicit
|
|
64
|
+
* service tier when one is set. Callers set it only on ChatGPT-OAuth requests
|
|
65
|
+
* to the Codex backend; API-key OpenAI traffic never carries it.
|
|
66
|
+
*/
|
|
67
|
+
export function codexRoutingHint(model: string, serviceTier: string | null | undefined): string {
|
|
68
|
+
return serviceTier ? `model=${model};tier=${serviceTier}` : `model=${model}`;
|
|
69
|
+
}
|
|
70
|
+
|
|
50
71
|
/**
|
|
51
72
|
* Extract account ID from a Codex JWT access token.
|
|
52
73
|
* Returns undefined if the token is not a valid Codex JWT.
|