@linxiraos/pi-catalog 1.2.0 → 1.3.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.
Files changed (127) hide show
  1. package/CHANGELOG.md +79 -0
  2. package/README.md +4 -2
  3. package/THIRD-PARTY-NOTICES.txt +55 -5
  4. package/dist/types/build.d.ts +3 -2
  5. package/dist/types/compat/auth-ids.d.ts +2 -2
  6. package/dist/types/compat/axes.d.ts +1 -1
  7. package/dist/types/compat/behavior.d.ts +5 -0
  8. package/dist/types/compat/catalog-endpoint.d.ts +8 -0
  9. package/dist/types/compat/image-tokenization.d.ts +9 -1
  10. package/dist/types/compat/judgment-images.d.ts +25 -0
  11. package/dist/types/compat/provider-ids.d.ts +1 -1
  12. package/dist/types/compat/request-compression.d.ts +23 -0
  13. package/dist/types/compat/request-size.d.ts +12 -3
  14. package/dist/types/compat/thinking-replay.d.ts +9 -0
  15. package/dist/types/compat/types.d.ts +4 -0
  16. package/dist/types/discovery/antigravity.d.ts +7 -0
  17. package/dist/types/model-cache.d.ts +7 -0
  18. package/dist/types/model-manager.d.ts +6 -0
  19. package/dist/types/model-thinking.d.ts +11 -1
  20. package/dist/types/models.d.ts +16 -1
  21. package/dist/types/pricing.d.ts +37 -1
  22. package/dist/types/provider-models/openai-compat.d.ts +18 -46
  23. package/dist/types/types.d.ts +63 -12
  24. package/dist/types/wire/codex.d.ts +2 -0
  25. package/package.json +6 -6
  26. package/src/build.d.ts +3 -2
  27. package/src/build.ts +159 -80
  28. package/src/compat/auth-ids.ts +2 -0
  29. package/src/compat/axes.d.ts +1 -1
  30. package/src/compat/axes.ts +129 -4
  31. package/src/compat/behavior.d.ts +5 -0
  32. package/src/compat/behavior.ts +9 -1
  33. package/src/compat/cascade.ts +4 -1
  34. package/src/compat/catalog-endpoint.ts +43 -0
  35. package/src/compat/image-tokenization.ts +28 -10
  36. package/src/compat/judgment-images.ts +83 -0
  37. package/src/compat/provider-ids.d.ts +1 -1
  38. package/src/compat/provider-ids.ts +1 -0
  39. package/src/compat/request-compression.ts +43 -0
  40. package/src/compat/request-size.ts +20 -5
  41. package/src/compat/resolve.ts +90 -53
  42. package/src/compat/rules/README.md +32 -3
  43. package/src/compat/rules/auth/_order.kdl +1 -1
  44. package/src/compat/rules/auth/google-antigravity.kdl +1 -1
  45. package/src/compat/rules/auth/sambanova.kdl +9 -0
  46. package/src/compat/rules/auth/stencil.kdl +1 -1
  47. package/src/compat/rules/classes/anthropic.kdl +42 -2
  48. package/src/compat/rules/classes/deepseek.kdl +4 -0
  49. package/src/compat/rules/classes/gemini.kdl +46 -2
  50. package/src/compat/rules/classes/meta.kdl +7 -0
  51. package/src/compat/rules/classes/minimax.kdl +11 -1
  52. package/src/compat/rules/classes/openai.kdl +34 -3
  53. package/src/compat/rules/classes/xai.kdl +26 -0
  54. package/src/compat/rules/providers/amazon-bedrock.kdl +1 -0
  55. package/src/compat/rules/providers/anthropic.kdl +23 -0
  56. package/src/compat/rules/providers/azure.kdl +2 -0
  57. package/src/compat/rules/providers/cerebras.kdl +3 -0
  58. package/src/compat/rules/providers/cline-pass.kdl +16 -0
  59. package/src/compat/rules/providers/commandcode.kdl +10 -0
  60. package/src/compat/rules/providers/cursor.kdl +50 -1
  61. package/src/compat/rules/providers/deepinfra.kdl +3 -1
  62. package/src/compat/rules/providers/devin.kdl +117 -6
  63. package/src/compat/rules/providers/factory-droid.kdl +6 -0
  64. package/src/compat/rules/providers/firepass.kdl +15 -0
  65. package/src/compat/rules/providers/fireworks.kdl +26 -0
  66. package/src/compat/rules/providers/github-copilot.kdl +24 -0
  67. package/src/compat/rules/providers/google-antigravity.kdl +37 -0
  68. package/src/compat/rules/providers/google-gemini-cli.kdl +1 -0
  69. package/src/compat/rules/providers/google-vertex.kdl +5 -0
  70. package/src/compat/rules/providers/google.kdl +1 -0
  71. package/src/compat/rules/providers/image-tokenization.kdl +2 -1
  72. package/src/compat/rules/providers/local.kdl +8 -1
  73. package/src/compat/rules/providers/meta.kdl +16 -0
  74. package/src/compat/rules/providers/moonshot.kdl +2 -0
  75. package/src/compat/rules/providers/muse-code.kdl +49 -0
  76. package/src/compat/rules/providers/native-tools.kdl +3 -0
  77. package/src/compat/rules/providers/ollama-cloud.kdl +10 -0
  78. package/src/compat/rules/providers/openai-codex.kdl +29 -5
  79. package/src/compat/rules/providers/openai.kdl +1 -0
  80. package/src/compat/rules/providers/opencode-go.kdl +35 -0
  81. package/src/compat/rules/providers/opencode-zen.kdl +4 -0
  82. package/src/compat/rules/providers/openrouter.kdl +19 -0
  83. package/src/compat/rules/providers/sambanova.kdl +60 -0
  84. package/src/compat/rules/providers/tool-call-names.kdl +37 -0
  85. package/src/compat/rules/providers/typesafe.kdl +11 -0
  86. package/src/compat/rules/providers/umans.kdl +7 -0
  87. package/src/compat/rules/providers/venice.kdl +7 -0
  88. package/src/compat/rules/providers/xai-oauth.kdl +16 -6
  89. package/src/compat/rules/providers/xai.kdl +3 -0
  90. package/src/compat/rules/providers/zai.kdl +5 -0
  91. package/src/compat/rules/runtime/behavior.kdl +128 -8
  92. package/src/compat/rules/taxonomy/_collapse.kdl +11 -0
  93. package/src/compat/rules/taxonomy/gemma.kdl +1 -0
  94. package/src/compat/rules/taxonomy/meta.kdl +7 -0
  95. package/src/compat/rules/taxonomy/openai.kdl +2 -0
  96. package/src/compat/rules.json +1 -1
  97. package/src/compat/thinking-replay.ts +33 -0
  98. package/src/compat/types.d.ts +4 -0
  99. package/src/compat/types.ts +4 -0
  100. package/src/discovery/antigravity.d.ts +7 -0
  101. package/src/discovery/antigravity.ts +13 -0
  102. package/src/discovery/codex.ts +0 -4
  103. package/src/discovery/cursor.ts +28 -20
  104. package/src/discovery/devin.ts +7 -8
  105. package/src/model-cache.d.ts +7 -0
  106. package/src/model-cache.ts +8 -0
  107. package/src/model-manager.d.ts +6 -0
  108. package/src/model-manager.ts +41 -21
  109. package/src/model-thinking.d.ts +80 -0
  110. package/src/model-thinking.ts +13 -1
  111. package/src/model-tokenizer.ts +7 -1
  112. package/src/models.d.ts +16 -1
  113. package/src/models.json +1 -1
  114. package/src/models.ts +26 -12
  115. package/src/pricing.d.ts +37 -1
  116. package/src/pricing.ts +123 -12
  117. package/src/provider-models/bundled-references.ts +5 -2
  118. package/src/provider-models/cache-provider-id.ts +1 -1
  119. package/src/provider-models/descriptors.ts +2 -0
  120. package/src/provider-models/google.ts +7 -1
  121. package/src/provider-models/openai-compat.d.ts +18 -46
  122. package/src/provider-models/openai-compat.ts +188 -104
  123. package/src/provider-models/special.ts +1 -0
  124. package/src/types.d.ts +63 -12
  125. package/src/types.ts +71 -9
  126. package/src/wire/codex.d.ts +2 -0
  127. package/src/wire/codex.ts +17 -0
package/src/types.ts CHANGED
@@ -189,6 +189,14 @@ export interface ThinkingConfig {
189
189
  * provides an explicit wire off-path.
190
190
  */
191
191
  requiresEffort?: boolean;
192
+ /**
193
+ * The catalog has no evidence this model reasons (unclassified id, no
194
+ * capability metadata). The ladder is offered for the user to opt into:
195
+ * sessions leave thinking unset until the user picks an effort, and a
196
+ * request without an effort goes out as non-reasoning (see
197
+ * `withoutUnverifiedThinking`).
198
+ */
199
+ unverified?: boolean;
192
200
  }
193
201
 
194
202
  // `Provider` is any provider-id string; `KnownProvider` (re-exported above) enumerates
@@ -563,6 +571,8 @@ export interface OpenAICompat {
563
571
  reasoningDeltasMayBeCumulative?: boolean;
564
572
  /** Strip leaked DeepSeek chat-template special tokens from visible content deltas. Default: auto-detected. */
565
573
  stripDeepseekSpecialTokens?: boolean;
574
+ /** Drop assistant thinking blocks from replayed chat-completions history. Default: false. */
575
+ stripThinkingHistory?: boolean;
566
576
  /** Heal leaked chat-template/tool-call/thinking markup from visible content deltas. Default: auto-detected. */
567
577
  streamMarkupHealingPattern?: OpenAIStreamMarkupHealingPattern;
568
578
  /** Whether this wire may revise already-streamed text (`stream-revision` axis). Unassigned: append-only. */
@@ -613,6 +623,14 @@ export interface AnthropicCompat {
613
623
  * contract instead. Default: false.
614
624
  */
615
625
  firstPartyProvider?: boolean;
626
+ /**
627
+ * Whether the provider honors Claude Code's `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS`
628
+ * kill switch, which withholds pre-release fields (`context_management`, beta
629
+ * tool fields, task budgets, structured-output format, `thinking.block_binding`,
630
+ * server compaction) with their betas. Rule-owned on the
631
+ * provider whose `ANTHROPIC_*` env routing Claude Code shares. Default: false.
632
+ */
633
+ honorsClaudeCodeBetaKillSwitch?: boolean;
616
634
  /**
617
635
  * Whether requests may carry `output_config.effort` (and its effort beta
618
636
  * header). Vertex AI rejects the field/header. Default: true.
@@ -1026,6 +1044,7 @@ export type ResolvedOpenAICompat = ResolvedOpenAISharedCompat &
1026
1044
  | "requiresAssistantAfterToolResult"
1027
1045
  | "requiresAssistantContentForToolCalls"
1028
1046
  | "stripDeepseekSpecialTokens"
1047
+ | "stripThinkingHistory"
1029
1048
  | "streamMarkupHealingPattern"
1030
1049
  | "reasoningDeltasMayBeCumulative"
1031
1050
  | "emptyLengthFinishIsContextError"
@@ -1064,6 +1083,9 @@ export type ResolvedOpenAICompat = ResolvedOpenAISharedCompat &
1064
1083
  cacheControlFormat?: OpenAICompat["cacheControlFormat"];
1065
1084
  thinkingKeep?: OpenAICompat["thinkingKeep"];
1066
1085
  streamIdleTimeoutMs?: number;
1086
+ stripThinkingHistory?: boolean;
1087
+ /** The configured `baseUrl` is the official OpenAI API (provider `openai`); unset otherwise. */
1088
+ officialEndpoint?: boolean;
1067
1089
  toolStrictMode: ResolvedToolStrictMode;
1068
1090
  /** The model sits behind Vercel AI Gateway. */
1069
1091
  isVercelGatewayHost: boolean;
@@ -1129,9 +1151,11 @@ export interface ResolvedOpenAIResponsesCompat extends ResolvedOpenAISharedCompa
1129
1151
  isVercelGatewayHost: boolean;
1130
1152
  /**
1131
1153
  * The configured endpoint is first-party OpenAI (`provider === "openai"` on
1132
- * an `api.openai.com` or unset baseUrl). Gates official-only Responses
1133
- * behavior: default-on stateful `previous_response_id` chaining and the
1134
- * `text.verbosity` field.
1154
+ * an `api.openai.com` or unset baseUrl), or the Codex backend
1155
+ * (`openai-codex-responses` on the default Codex baseUrl). Gates platform
1156
+ * OpenAI's official-only Responses behavior (default-on stateful
1157
+ * `previous_response_id` chaining and the `text.verbosity` field; the Codex
1158
+ * adapter is not governed by either gate) and host request-size budgets.
1135
1159
  */
1136
1160
  officialEndpoint: boolean;
1137
1161
  /** Run Harmony-protocol leak detection/mitigation on streamed output. */
@@ -1275,6 +1299,18 @@ export interface GoogleCompat {
1275
1299
  antigravityUsageLabel?: string;
1276
1300
  /** Strip image inputs before encoding (text-only serving of a multimodal id). */
1277
1301
  stripImageInput?: boolean;
1302
+ /**
1303
+ * Largest width or height a single image may carry for a Claude reader on
1304
+ * this host (see {@link AnthropicCompat.maxImageDimension}). Setting this or
1305
+ * {@link maxImagePayloadBytes} turns on Claude's image clamp, many-image
1306
+ * cap included; unset leaves images as sent.
1307
+ */
1308
+ maxImageDimension?: number;
1309
+ /**
1310
+ * Largest base64 payload a single image may carry, in bytes (see
1311
+ * {@link AnthropicCompat.maxImagePayloadBytes}).
1312
+ */
1313
+ maxImagePayloadBytes?: number;
1278
1314
  /** Thinking-loop watchdog guard family applied to streamed reasoning. */
1279
1315
  thinkingLoopGuard?: "gemini" | "deepseek" | "xai";
1280
1316
  /** See {@link BedrockCompat.supportsSamplingParams}. */
@@ -1290,6 +1326,8 @@ export type ResolvedGoogleCompat = Required<
1290
1326
  | "thinkingLoopGuard"
1291
1327
  | "antigravityUsageLabel"
1292
1328
  | "supportsSamplingParams"
1329
+ | "maxImageDimension"
1330
+ | "maxImagePayloadBytes"
1293
1331
  >
1294
1332
  > & {
1295
1333
  streamFirstEventTimeoutMs?: number;
@@ -1297,8 +1335,18 @@ export type ResolvedGoogleCompat = Required<
1297
1335
  thinkingLoopGuard?: GoogleCompat["thinkingLoopGuard"];
1298
1336
  antigravityUsageLabel?: string;
1299
1337
  supportsSamplingParams?: boolean;
1338
+ maxImageDimension?: number;
1339
+ maxImagePayloadBytes?: number;
1300
1340
  };
1301
1341
 
1342
+ /** Ollama chat history compatibility resolved by the catalog. */
1343
+ export interface OllamaCompat {
1344
+ /** Omit assistant thinking when the deployment rejects it in history. */
1345
+ stripThinkingHistory?: boolean;
1346
+ }
1347
+
1348
+ export type ResolvedOllamaCompat = Required<OllamaCompat>;
1349
+
1302
1350
  /** Sparse, user-authored compat overrides for a given API (models.json / config vocabulary). */
1303
1351
  export type CompatConfigOf<TApi extends Api> = TApi extends
1304
1352
  | "openai-completions"
@@ -1315,7 +1363,9 @@ export type CompatConfigOf<TApi extends Api> = TApi extends
1315
1363
  ? DevinCompat
1316
1364
  : TApi extends "google-generative-ai" | "google-vertex" | "google-gemini-cli"
1317
1365
  ? GoogleCompat
1318
- : undefined;
1366
+ : TApi extends "ollama-chat"
1367
+ ? OllamaCompat
1368
+ : undefined;
1319
1369
 
1320
1370
  /** Resolved compat for a given API: complete record, materialized once by `buildModel`. */
1321
1371
  export type CompatOf<TApi extends Api> = TApi extends "openrouter"
@@ -1332,7 +1382,9 @@ export type CompatOf<TApi extends Api> = TApi extends "openrouter"
1332
1382
  ? ResolvedDevinCompat
1333
1383
  : TApi extends "google-generative-ai" | "google-vertex" | "google-gemini-cli"
1334
1384
  ? ResolvedGoogleCompat
1335
- : undefined;
1385
+ : TApi extends "ollama-chat"
1386
+ ? ResolvedOllamaCompat
1387
+ : undefined;
1336
1388
 
1337
1389
  /** Provider-native compaction endpoint configuration for one model. */
1338
1390
  export interface RemoteCompactionConfig<TApi extends Api = Api> {
@@ -1424,7 +1476,8 @@ export type ModelTokenizer =
1424
1476
  | "qwen3"
1425
1477
  | "deepseek-v3"
1426
1478
  | "kimi-k2"
1427
- | "glm5";
1479
+ | "glm5"
1480
+ | "o200k";
1428
1481
 
1429
1482
  /** One account's discovered entitlements on a model; see {@link Model.accountAccess}. */
1430
1483
  export interface ModelAccountAccess {
@@ -1481,6 +1534,8 @@ export interface Model<TApi extends Api = Api> {
1481
1534
  requiresGlyphTokenization?: boolean;
1482
1535
  /** Whether this model requires Cursor's tool-schema combiner projection. */
1483
1536
  requiresCursorToolSchemaProjection?: boolean;
1537
+ /** Whether advertised tool schemas occupy every model request's context (false for deferred catalogs). */
1538
+ toolSchemasInContext?: boolean;
1484
1539
  /** Whether this model requires tool-result images hoisted into sibling user content blocks. */
1485
1540
  requiresToolResultImageHoisting?: boolean;
1486
1541
  /**
@@ -1529,6 +1584,12 @@ export interface Model<TApi extends Api = Api> {
1529
1584
  * than ZETA's general image pipeline. `stb` local backends reject WebP.
1530
1585
  */
1531
1586
  imageInputDecoder?: "stb";
1587
+ /**
1588
+ * Most images one request may carry, from user configuration. Replaces the
1589
+ * catalog's `image-count-budget` for hosts no rule names, such as a custom
1590
+ * gateway in front of a vendor with a higher limit.
1591
+ */
1592
+ imageCountBudget?: number;
1532
1593
  /**
1533
1594
  * Native provider tool-call support. `false` is the only unsupported signal:
1534
1595
  * `true` and `undefined` both mean callers may use native tools. Catalog and
@@ -1611,6 +1672,8 @@ export interface Model<TApi extends Api = Api> {
1611
1672
  contextWindow: number | null;
1612
1673
  /** Preserve the host's supplied window instead of applying inferred expansion or reference-price caps. */
1613
1674
  contextWindowAuthoritative?: boolean;
1675
+ /** The long-context price tier does not cap the runtime context window when extended context is off. */
1676
+ longContextWindowUncapped?: boolean;
1614
1677
  /** Optional larger prompt window available when extended context is enabled. */
1615
1678
  maxContextWindow?: number;
1616
1679
  maxTokens: number | null;
@@ -1637,7 +1700,7 @@ export interface Model<TApi extends Api = Api> {
1637
1700
  * Streaming transport override. When `"pi-native"`, `streamSimple` routes
1638
1701
  * the request to the model's `baseUrl` via the auth-gateway's
1639
1702
  * `POST /v1/pi/stream` endpoint instead of dispatching the per-API
1640
- * provider client. The `baseUrl` must point at an `zeta-c auth-gateway`
1703
+ * provider client. The `baseUrl` must point at an `zetacode auth-gateway`
1641
1704
  * (or compatible) host; `headers.Authorization` (or `apiKey` resolved by
1642
1705
  * the registry) carries the gateway bearer.
1643
1706
  *
@@ -1652,8 +1715,6 @@ export interface Model<TApi extends Api = Api> {
1652
1715
  preferWebsockets?: boolean;
1653
1716
  /** Codex Responses Lite transport: send the lite marker and carry instructions/tools as input items (mirrors codex-rs `use_responses_lite`). */
1654
1717
  useResponsesLite?: boolean;
1655
- /** Codex Code Mode restriction: model expects tools routed through a programmatic exec surface (mirrors codex-rs `tool_mode`). */
1656
- toolMode?: "code_mode_only";
1657
1718
  /**
1658
1719
  * Service-tier ids the provider advertises for this model (Codex discovery
1659
1720
  * `service_tiers[].id`, e.g. `priority`, `ultrafast`). Absent when the
@@ -1754,6 +1815,7 @@ export interface ModelSpec<TApi extends Api = Api> extends Omit<
1754
1815
  | "compatConfig"
1755
1816
  | "requiresGlyphTokenization"
1756
1817
  | "requiresCursorToolSchemaProjection"
1818
+ | "toolSchemasInContext"
1757
1819
  | "requiresToolResultImageHoisting"
1758
1820
  | "supportsAssistantPrefill"
1759
1821
  | "supportsComputerUseConfig"
@@ -2,6 +2,8 @@
2
2
  * Constants for OpenAI Codex (ChatGPT OAuth) backend
3
3
  */
4
4
  export declare const CODEX_BASE_URL = "https://chatgpt.com/backend-api";
5
+ /** Strict official-Codex endpoint check; exact origin or a path boundary after {@link CODEX_BASE_URL}. */
6
+ export declare function isOfficialCodexApiUrl(baseUrl: string | undefined): boolean;
5
7
  /**
6
8
  * Pinned OpenAI Codex client version (corresponds to @openai/codex package version).
7
9
  * Updated from npm by `bun run check-spoofed-versions --update`.
package/src/wire/codex.ts CHANGED
@@ -4,6 +4,23 @@
4
4
 
5
5
  export const CODEX_BASE_URL = "https://chatgpt.com/backend-api";
6
6
 
7
+ const OFFICIAL_CODEX_URL = new URL(CODEX_BASE_URL);
8
+
9
+ /** Strict official-Codex endpoint check; exact origin or a path boundary after {@link CODEX_BASE_URL}. */
10
+ export function isOfficialCodexApiUrl(baseUrl: string | undefined): boolean {
11
+ if (!baseUrl) return true;
12
+ try {
13
+ const candidate = new URL(baseUrl);
14
+ const candidatePath = candidate.pathname.replace(/\/+$/, "");
15
+ return (
16
+ candidate.origin === OFFICIAL_CODEX_URL.origin &&
17
+ (candidatePath === OFFICIAL_CODEX_URL.pathname || candidatePath.startsWith(`${OFFICIAL_CODEX_URL.pathname}/`))
18
+ );
19
+ } catch {
20
+ return false;
21
+ }
22
+ }
23
+
7
24
  /**
8
25
  * Pinned OpenAI Codex client version (corresponds to @openai/codex package version).
9
26
  * Updated from npm by `bun run check-spoofed-versions --update`.