@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.
Files changed (88) hide show
  1. package/CHANGELOG.md +2 -3
  2. package/package.json +96 -102
  3. package/src/compat/axes.ts +11 -0
  4. package/src/compat/delegation.ts +37 -0
  5. package/src/compat/resolve.ts +2 -0
  6. package/src/compat/rules/README.md +5 -5
  7. package/src/compat/rules/auth/openai-codex.kdl +1 -1
  8. package/src/compat/rules/auth/zai-coding-plan.kdl +7 -3
  9. package/src/compat/rules/classes/openai.kdl +16 -0
  10. package/src/compat/rules/providers/openai-codex.kdl +2 -2
  11. package/src/compat/rules/providers/openai.kdl +1 -1
  12. package/src/compat/rules.json +67 -16
  13. package/src/compat/types.ts +4 -2
  14. package/src/discovery/codex.ts +10 -0
  15. package/src/identity/metrics.ts +165 -0
  16. package/src/identity/reference.ts +7 -1
  17. package/src/model-manager.ts +15 -2
  18. package/src/models.json +4861 -382
  19. package/src/provider-models/openai-compat.ts +4 -0
  20. package/src/provider-models/special.ts +25 -10
  21. package/src/types.ts +17 -0
  22. package/src/wire/codex.ts +23 -2
  23. package/THIRD-PARTY-NOTICES.txt +0 -22909
  24. package/dist/types/build.d.ts +0 -24
  25. package/dist/types/cline-pass-model-id.d.ts +0 -4
  26. package/dist/types/compat/anthropic.d.ts +0 -24
  27. package/dist/types/compat/apply.d.ts +0 -7
  28. package/dist/types/compat/auth-ids.d.ts +0 -4
  29. package/dist/types/compat/auth.d.ts +0 -7
  30. package/dist/types/compat/axes.d.ts +0 -50
  31. package/dist/types/compat/behavior.d.ts +0 -69
  32. package/dist/types/compat/cascade.d.ts +0 -37
  33. package/dist/types/compat/collapse.d.ts +0 -171
  34. package/dist/types/compat/openai.d.ts +0 -9
  35. package/dist/types/compat/resolve.d.ts +0 -15
  36. package/dist/types/compat/revision.d.ts +0 -41
  37. package/dist/types/compat/taxonomy.d.ts +0 -93
  38. package/dist/types/compat/types.d.ts +0 -565
  39. package/dist/types/discovery/antigravity.d.ts +0 -70
  40. package/dist/types/discovery/codex.d.ts +0 -36
  41. package/dist/types/discovery/cursor-proto.d.ts +0 -5368
  42. package/dist/types/discovery/cursor.d.ts +0 -31
  43. package/dist/types/discovery/devin-proto.d.ts +0 -1912
  44. package/dist/types/discovery/devin.d.ts +0 -24
  45. package/dist/types/discovery/gemini-cli.d.ts +0 -33
  46. package/dist/types/discovery/gemini.d.ts +0 -25
  47. package/dist/types/discovery/gitlab-duo-workflow.d.ts +0 -30
  48. package/dist/types/discovery/index.d.ts +0 -7
  49. package/dist/types/discovery/openai-compatible.d.ts +0 -89
  50. package/dist/types/discovery/protobuf.d.ts +0 -102
  51. package/dist/types/effort.d.ts +0 -10
  52. package/dist/types/fireworks-model-id.d.ts +0 -23
  53. package/dist/types/hosts.d.ts +0 -169
  54. package/dist/types/identity/bundled.d.ts +0 -3
  55. package/dist/types/identity/dialect.d.ts +0 -3
  56. package/dist/types/identity/id.d.ts +0 -13
  57. package/dist/types/identity/index.d.ts +0 -8
  58. package/dist/types/identity/priority.d.ts +0 -1
  59. package/dist/types/identity/reference.d.ts +0 -19
  60. package/dist/types/index.d.ts +0 -19
  61. package/dist/types/model-cache.d.ts +0 -23
  62. package/dist/types/model-manager.d.ts +0 -93
  63. package/dist/types/model-thinking.d.ts +0 -63
  64. package/dist/types/model-tokenizer.d.ts +0 -8
  65. package/dist/types/models.d.ts +0 -17
  66. package/dist/types/provider-models/bundled-references.d.ts +0 -13
  67. package/dist/types/provider-models/cache-provider-id.d.ts +0 -11
  68. package/dist/types/provider-models/cline-pass.d.ts +0 -22
  69. package/dist/types/provider-models/descriptor-types.d.ts +0 -76
  70. package/dist/types/provider-models/descriptors.d.ts +0 -543
  71. package/dist/types/provider-models/google.d.ts +0 -29
  72. package/dist/types/provider-models/index.d.ts +0 -7
  73. package/dist/types/provider-models/models-dev-policies.d.ts +0 -9
  74. package/dist/types/provider-models/ollama.d.ts +0 -22
  75. package/dist/types/provider-models/openai-compat.d.ts +0 -716
  76. package/dist/types/provider-models/special.d.ts +0 -74
  77. package/dist/types/types.d.ts +0 -1043
  78. package/dist/types/utils.d.ts +0 -20
  79. package/dist/types/wire/alibaba-token-plan.d.ts +0 -22
  80. package/dist/types/wire/cline-pass.d.ts +0 -21
  81. package/dist/types/wire/cloudflare-ai-gateway.d.ts +0 -18
  82. package/dist/types/wire/codex.d.ts +0 -66
  83. package/dist/types/wire/coreweave.d.ts +0 -12
  84. package/dist/types/wire/devin-proto.d.ts +0 -14
  85. package/dist/types/wire/devin.d.ts +0 -36
  86. package/dist/types/wire/gemini-headers.d.ts +0 -62
  87. package/dist/types/wire/github-copilot.d.ts +0 -66
  88. 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
- fetchCodexModels({
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). Returns `null` when
77
- * any account's fetch failed, so a partial list cannot replace the previous or
78
- * bundled authoritative catalog.
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 (CodexModelDiscoveryResult | null)[],
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
- for (const result of results) {
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.144.1";
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: "pi",
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.