@linxiraos/pi-catalog 1.4.4 → 1.4.7

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 (103) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +3 -3
  3. package/dist/types/build.d.ts +12 -4
  4. package/dist/types/compat/anthropic.d.ts +20 -0
  5. package/dist/types/compat/behavior.d.ts +2 -0
  6. package/dist/types/compat/catalog-policy.d.ts +2 -2
  7. package/dist/types/compat/collapse.d.ts +10 -0
  8. package/dist/types/compat/factory-droid.d.ts +2 -0
  9. package/dist/types/compat/resolve.d.ts +2 -2
  10. package/dist/types/compat/types.d.ts +5 -1
  11. package/dist/types/discovery/antigravity.d.ts +7 -2
  12. package/dist/types/discovery/codex.d.ts +4 -5
  13. package/dist/types/discovery/devin.d.ts +1 -1
  14. package/dist/types/model-cache.d.ts +8 -0
  15. package/dist/types/model-catalog-format.d.ts +37 -0
  16. package/dist/types/models.d.ts +6 -3
  17. package/dist/types/provider-models/google.d.ts +2 -0
  18. package/dist/types/provider-models/openai-compat.d.ts +16 -3
  19. package/dist/types/types.d.ts +58 -3
  20. package/dist/types/wire/codex.d.ts +1 -1
  21. package/dist/types/wire/devin.d.ts +2 -2
  22. package/dist/types/wire/gemini-headers.d.ts +41 -22
  23. package/dist/types/wire/xiaomi-token-plan.d.ts +2 -0
  24. package/package.json +6 -10
  25. package/src/build.d.ts +12 -4
  26. package/src/build.ts +97 -4
  27. package/src/compat/anthropic.d.ts +20 -0
  28. package/src/compat/anthropic.ts +47 -0
  29. package/src/compat/axes.ts +16 -3
  30. package/src/compat/behavior.d.ts +2 -0
  31. package/src/compat/behavior.ts +5 -0
  32. package/src/compat/catalog-policy.ts +10 -8
  33. package/src/compat/collapse.d.ts +10 -0
  34. package/src/compat/collapse.ts +63 -2
  35. package/src/compat/factory-droid.d.ts +2 -0
  36. package/src/compat/factory-droid.ts +3 -0
  37. package/src/compat/resolve.d.ts +2 -2
  38. package/src/compat/resolve.ts +7 -5
  39. package/src/compat/rules/README.md +24 -16
  40. package/src/compat/rules/auth/google-antigravity.kdl +2 -1
  41. package/src/compat/rules/auth/llama.cpp.kdl +1 -1
  42. package/src/compat/rules/auth/typesafe.kdl +2 -1
  43. package/src/compat/rules/auth/xiaomi-token-plan-ams.kdl +1 -1
  44. package/src/compat/rules/auth/xiaomi-token-plan-cn.kdl +1 -1
  45. package/src/compat/rules/auth/xiaomi-token-plan-sgp.kdl +1 -1
  46. package/src/compat/rules/classes/anthropic.kdl +6 -1
  47. package/src/compat/rules/classes/deepseek.kdl +2 -1
  48. package/src/compat/rules/classes/minimax.kdl +10 -0
  49. package/src/compat/rules/classes/openai.kdl +2 -2
  50. package/src/compat/rules/providers/anthropic.kdl +15 -1
  51. package/src/compat/rules/providers/deepseek.kdl +13 -10
  52. package/src/compat/rules/providers/factory-droid.kdl +72 -0
  53. package/src/compat/rules/providers/google-antigravity.kdl +7 -0
  54. package/src/compat/rules/providers/google-vertex.kdl +3 -0
  55. package/src/compat/rules/providers/kimi-code.kdl +26 -0
  56. package/src/compat/rules/providers/mistral.kdl +8 -0
  57. package/src/compat/rules/providers/moonshot.kdl +25 -0
  58. package/src/compat/rules/providers/muse-code.kdl +1 -1
  59. package/src/compat/rules/providers/openai-codex.kdl +17 -4
  60. package/src/compat/rules/providers/openai.kdl +23 -2
  61. package/src/compat/rules/providers/opencode-go.kdl +38 -3
  62. package/src/compat/rules/providers/opencode-zen.kdl +7 -0
  63. package/src/compat/rules/providers/xiaomi-token-plan-ams.kdl +1 -1
  64. package/src/compat/rules/providers/xiaomi-token-plan-cn.kdl +1 -1
  65. package/src/compat/rules/providers/xiaomi-token-plan-sgp.kdl +1 -1
  66. package/src/compat/rules/providers/xiaomi.kdl +1 -1
  67. package/src/compat/rules/runtime/behavior.kdl +39 -20
  68. package/src/compat/rules/taxonomy/kimi.kdl +7 -0
  69. package/src/compat/rules.json +1 -1
  70. package/src/compat/types.d.ts +5 -1
  71. package/src/compat/types.ts +5 -1
  72. package/src/discovery/antigravity.d.ts +7 -2
  73. package/src/discovery/antigravity.ts +41 -6
  74. package/src/discovery/codex.d.ts +4 -5
  75. package/src/discovery/codex.ts +5 -6
  76. package/src/discovery/cursor.ts +0 -6
  77. package/src/discovery/devin.d.ts +1 -1
  78. package/src/discovery/devin.ts +9 -3
  79. package/src/discovery/factory-droid.ts +38 -6
  80. package/src/model-cache.d.ts +8 -0
  81. package/src/model-cache.ts +55 -5
  82. package/src/model-catalog-format.d.ts +37 -0
  83. package/src/model-catalog-format.ts +299 -0
  84. package/src/models.d.ts +6 -3
  85. package/src/models.json +1 -1
  86. package/src/models.ts +16 -10
  87. package/src/provider-models/cache-provider-id.ts +26 -6
  88. package/src/provider-models/google.d.ts +2 -0
  89. package/src/provider-models/google.ts +13 -1
  90. package/src/provider-models/openai-compat.d.ts +16 -3
  91. package/src/provider-models/openai-compat.ts +207 -58
  92. package/src/provider-models/special.ts +5 -6
  93. package/src/types.d.ts +58 -3
  94. package/src/types.ts +63 -1
  95. package/src/wire/codex.d.ts +1 -1
  96. package/src/wire/codex.ts +1 -1
  97. package/src/wire/devin.d.ts +2 -2
  98. package/src/wire/devin.ts +2 -2
  99. package/src/wire/gemini-headers.d.ts +41 -22
  100. package/src/wire/gemini-headers.ts +68 -24
  101. package/src/wire/xiaomi-token-plan.d.ts +2 -0
  102. package/src/wire/xiaomi-token-plan.ts +4 -0
  103. package/src/models.json.d.ts +0 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@linxiraos/pi-catalog",
3
- "version": "1.4.4",
3
+ "version": "1.4.7",
4
4
  "description": "Model catalog for omp: bundled model database, provider discovery descriptors, model identity, classification, and equivalence",
5
5
  "keywords": [
6
6
  "ai",
@@ -36,10 +36,6 @@
36
36
  "types": "./dist/types/index.d.ts",
37
37
  "import": "./src/index.ts"
38
38
  },
39
- "./models.json": {
40
- "types": "./dist/types/models.json.d.d.ts",
41
- "import": "./src/models.json"
42
- },
43
39
  "./provider-models": {
44
40
  "types": "./dist/types/provider-models/index.d.ts",
45
41
  "import": "./src/provider-models/index.ts"
@@ -90,15 +86,15 @@
90
86
  "gen:proto": "bun scripts/generate-protocols.ts"
91
87
  },
92
88
  "dependencies": {
93
- "@linxiraos/pi-omptype": "1.4.4",
94
- "@linxiraos/pi-utils": "1.4.4"
89
+ "@linxiraos/pi-omptype": "1.4.7",
90
+ "@linxiraos/pi-utils": "1.4.7"
95
91
  },
96
92
  "devDependencies": {
97
93
  "@bgotink/kdl": "0.4.0",
98
- "@linxiraos/pi-ai": "1.4.4",
99
- "@types/bun": "1.4.3"
94
+ "@linxiraos/pi-ai": "1.4.7",
95
+ "@types/bun": "1.4.4"
100
96
  },
101
97
  "engines": {
102
- "bun": ">=1.3.14"
98
+ "bun": ">=1.4.4"
103
99
  }
104
100
  }
package/src/build.d.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  * Request handlers read fields — they never detect, parse ids, or allocate
7
7
  * compat per request.
8
8
  */
9
- import { type Api, type Model, type ModelSpec } from "./types";
9
+ import { type Api, type Model, type ModelCost, type ModelSpec } from "./types";
10
10
  /**
11
11
  * Applies reviewed catalog-data value corrections (`cost-patch`,
12
12
  * `cache-read-at-input-rate`, `cache-write-rate`, `limits-patch`,
@@ -24,8 +24,16 @@ export declare function applyCatalogCorrections(model: Pick<ModelSpec<Api>, "cos
24
24
  */
25
25
  export declare function buildDiscoveredModel(spec: ModelSpec<Api>, providerType: string): Model<Api>;
26
26
  /**
27
- * Build one model from an authored spec. Bundled models.json rows are fully
28
- * materialized by the generator and consumed directly (see `models.ts`), so
29
- * this only runs for discovered/custom/override specs.
27
+ * The first instant after `now` at which {@link buildModel} could select a
28
+ * different dated price card for a spec carrying `cost`: the next
29
+ * `effectiveFrom` of the spec's own rate schedule or of any dated card in the
30
+ * compiled rules. A build of an unchanged spec made at or after `now` is
31
+ * identical to a fresh one until then. `Infinity` when no change is pending.
32
+ */
33
+ export declare function nextBuildPriceChange(cost: ModelCost, now: number): number;
34
+ /**
35
+ * Build one model from an authored spec. Bundled models are prebuilt by the
36
+ * generator and decoded by `models.ts`, so this only runs for discovered,
37
+ * custom, and override specs.
30
38
  */
31
39
  export declare function buildModel<TApi extends Api>(spec: ModelSpec<TApi>): Model<TApi>;
package/src/build.ts CHANGED
@@ -7,6 +7,7 @@
7
7
  * compat per request.
8
8
  */
9
9
 
10
+ import RULES from "./compat/rules.json" with { type: "json" };
10
11
  import { resolveDiscoveryApi, resolveModelPolicy } from "./compat/resolve";
11
12
  import type { ModelIdentity } from "./compat/types";
12
13
  import { resolveModelTokenizer } from "./model-tokenizer";
@@ -19,7 +20,16 @@ import {
19
20
  NO_RECURRING_TARIFF,
20
21
  parseDatedCostCards,
21
22
  } from "./pricing";
22
- import { type Api, type EffectiveTokenCost, MODEL_KINDS, type Model, type ModelCost, type ModelSpec } from "./types";
23
+ import {
24
+ type AntigravityModelWireProfile,
25
+ type Api,
26
+ type EffectiveTokenCost,
27
+ MODEL_KINDS,
28
+ type Model,
29
+ type ModelAccountAccess,
30
+ type ModelCost,
31
+ type ModelSpec,
32
+ } from "./types";
23
33
  import { cleanModelName } from "./utils";
24
34
 
25
35
  function numberField(source: object, key: string): number | undefined {
@@ -353,6 +363,42 @@ export function applyCatalogCorrections(
353
363
  }
354
364
  }
355
365
 
366
+ /**
367
+ * Lower discovered Antigravity per-SKU output caps to the host's
368
+ * `max-tokens-ceiling`. The transport sends a profile's `maxOutputTokens`
369
+ * verbatim, so a roster value above the ceiling (Claude 4.x advertises 65,536;
370
+ * Cloud Code Assist 400s past 64,000, #3067) must be corrected here as the
371
+ * row's `maxTokens` is.
372
+ */
373
+ function capAntigravityWireProfiles(
374
+ model: Pick<Model<Api>, "antigravityWireProfiles" | "accountAccess">,
375
+ ceiling: unknown,
376
+ ): void {
377
+ if (typeof ceiling !== "number") return;
378
+ const cap = (
379
+ profiles: Readonly<Record<string, AntigravityModelWireProfile>> | undefined,
380
+ ): Readonly<Record<string, AntigravityModelWireProfile>> | undefined => {
381
+ if (profiles === undefined) return undefined;
382
+ let capped: Record<string, AntigravityModelWireProfile> | undefined;
383
+ for (const [wireId, profile] of Object.entries(profiles)) {
384
+ if (profile.maxOutputTokens === undefined || profile.maxOutputTokens <= ceiling) continue;
385
+ capped ??= { ...profiles };
386
+ capped[wireId] = { ...profile, maxOutputTokens: ceiling };
387
+ }
388
+ return capped ?? profiles;
389
+ };
390
+ model.antigravityWireProfiles = cap(model.antigravityWireProfiles);
391
+ if (model.accountAccess === undefined) return;
392
+ let accountAccess: Record<string, ModelAccountAccess> | undefined;
393
+ for (const [accountKey, access] of Object.entries(model.accountAccess)) {
394
+ const profiles = cap(access.antigravityWireProfiles);
395
+ if (profiles === access.antigravityWireProfiles) continue;
396
+ accountAccess ??= { ...model.accountAccess };
397
+ accountAccess[accountKey] = { ...access, antigravityWireProfiles: profiles };
398
+ }
399
+ if (accountAccess !== undefined) model.accountAccess = accountAccess;
400
+ }
401
+
356
402
  /**
357
403
  * Direct first-party OpenAI Responses endpoints (api.openai.com, Azure OpenAI
358
404
  * deployments). Gates GA computer-use detection; identity supplies the model
@@ -418,10 +464,56 @@ export function buildDiscoveredModel(spec: ModelSpec<Api>, providerType: string)
418
464
  return buildModel({ ...spec, api, providerType });
419
465
  }
420
466
 
467
+ /** Every dated card instant in the compiled rules, ascending; collected on first use. */
468
+ let ruleCardInstants: number[] | undefined;
469
+
470
+ function collectRuleCardInstants(value: unknown, out: number[]): void {
471
+ if (Array.isArray(value)) {
472
+ for (const item of value) collectRuleCardInstants(item, out);
473
+ return;
474
+ }
475
+ if (typeof value !== "object" || value === null) return;
476
+ for (const key in value) {
477
+ const child: unknown = Reflect.get(value, key);
478
+ if (key === "effectiveFrom" && typeof child === "string") {
479
+ const instant = Date.parse(child);
480
+ if (Number.isFinite(instant)) out.push(instant);
481
+ } else {
482
+ collectRuleCardInstants(child, out);
483
+ }
484
+ }
485
+ }
486
+
487
+ /**
488
+ * The first instant after `now` at which {@link buildModel} could select a
489
+ * different dated price card for a spec carrying `cost`: the next
490
+ * `effectiveFrom` of the spec's own rate schedule or of any dated card in the
491
+ * compiled rules. A build of an unchanged spec made at or after `now` is
492
+ * identical to a fresh one until then. `Infinity` when no change is pending.
493
+ */
494
+ export function nextBuildPriceChange(cost: ModelCost, now: number): number {
495
+ if (ruleCardInstants === undefined) {
496
+ const instants: number[] = [];
497
+ collectRuleCardInstants(RULES, instants);
498
+ ruleCardInstants = instants.sort((a, b) => a - b);
499
+ }
500
+ let next = Number.POSITIVE_INFINITY;
501
+ for (const instant of ruleCardInstants) {
502
+ if (instant > now) {
503
+ next = instant;
504
+ break;
505
+ }
506
+ }
507
+ for (const rate of cost.timeBased?.effectiveRates ?? []) {
508
+ if (rate.effectiveFrom > now && rate.effectiveFrom < next) next = rate.effectiveFrom;
509
+ }
510
+ return next;
511
+ }
512
+
421
513
  /**
422
- * Build one model from an authored spec. Bundled models.json rows are fully
423
- * materialized by the generator and consumed directly (see `models.ts`), so
424
- * this only runs for discovered/custom/override specs.
514
+ * Build one model from an authored spec. Bundled models are prebuilt by the
515
+ * generator and decoded by `models.ts`, so this only runs for discovered,
516
+ * custom, and override specs.
425
517
  */
426
518
  export function buildModel<TApi extends Api>(spec: ModelSpec<TApi>): Model<TApi> {
427
519
  const policy = resolveModelPolicy(spec);
@@ -445,6 +537,7 @@ export function buildModel<TApi extends Api>(spec: ModelSpec<TApi>): Model<TApi>
445
537
  };
446
538
  applyCatalogAssignments(model, policy.catalog);
447
539
  applyCatalogCorrections(model, policy.catalog);
540
+ capAntigravityWireProfiles(model, policy.catalog.maxTokensCeiling);
448
541
  // Configured kinds and lifetimes replace catalog values rather than merging with them.
449
542
  if (spec.kindConfig !== undefined) model.kind = spec.kindConfig;
450
543
  if (spec.promptCacheConfig !== undefined) model.promptCache = { ...spec.promptCacheConfig };
@@ -6,6 +6,26 @@
6
6
  * prefix check would accept lookalikes like `https://api.anthropic.com.evil.com`.
7
7
  */
8
8
  export declare function isOfficialAnthropicApiUrl(baseUrl?: string): boolean;
9
+ /** `anthropic-version` values this codebase knows how to speak. */
10
+ export declare const ANTHROPIC_API_VERSIONS: readonly ["2023-06-01", "2026-10-21"];
11
+ export type AnthropicApiVersion = (typeof ANTHROPIC_API_VERSIONS)[number];
12
+ /** Version every non-official Anthropic-compatible endpoint receives. */
13
+ export declare const LEGACY_ANTHROPIC_API_VERSION: AnthropicApiVersion;
14
+ /**
15
+ * `anthropic-version` for a request to `baseUrl`. `PI_ANTHROPIC_API_VERSION`
16
+ * opts the official first-party API into a newer version; every other host
17
+ * (Copilot, Bedrock, Foundry, Cloudflare, third-party compatibles) stays on
18
+ * {@link LEGACY_ANTHROPIC_API_VERSION} because those deployments gate newer
19
+ * versions on their own schedule (Bedrock accepts 2026-10-21 only for 4.7+).
20
+ * Read per call so a flipped environment takes effect without a restart.
21
+ */
22
+ export declare function resolveAnthropicApiVersion(baseUrl?: string): AnthropicApiVersion;
23
+ /**
24
+ * Whether Messages requests on `version` may carry `temperature`, `top_p`,
25
+ * or `top_k`. API version 2026-10-21 rejects all three with a 400, even at
26
+ * their default values.
27
+ */
28
+ export declare function anthropicApiVersionAcceptsSamplingParams(version: AnthropicApiVersion): boolean;
9
29
  /**
10
30
  * Amazon Bedrock's Anthropic Messages API: the `/anthropic` path on the
11
31
  * bedrock-runtime or bedrock-mantle endpoint. It rejects the tool `strict`
@@ -5,6 +5,7 @@
5
5
  * pi-ai both consume these; URL matching is the one detection surface that
6
6
  * stays in code.
7
7
  */
8
+ import { $env, logger } from "@linxiraos/pi-utils";
8
9
  import { hostMatchesUrl, isBedrockRouteUrl } from "../hosts";
9
10
 
10
11
  const OFFICIAL_ANTHROPIC_URL = "https://api.anthropic.com";
@@ -22,6 +23,52 @@ export function isOfficialAnthropicApiUrl(baseUrl?: string): boolean {
22
23
  return lower === OFFICIAL_ANTHROPIC_URL || lower.startsWith(`${OFFICIAL_ANTHROPIC_URL}/`);
23
24
  }
24
25
 
26
+ /** `anthropic-version` values this codebase knows how to speak. */
27
+ export const ANTHROPIC_API_VERSIONS = ["2023-06-01", "2026-10-21"] as const;
28
+ export type AnthropicApiVersion = (typeof ANTHROPIC_API_VERSIONS)[number];
29
+
30
+ /** Version every non-official Anthropic-compatible endpoint receives. */
31
+ export const LEGACY_ANTHROPIC_API_VERSION: AnthropicApiVersion = "2023-06-01";
32
+
33
+ let warnedInvalidApiVersion: string | undefined;
34
+
35
+ function isAnthropicApiVersion(value: string): value is AnthropicApiVersion {
36
+ return (ANTHROPIC_API_VERSIONS as readonly string[]).includes(value);
37
+ }
38
+
39
+ /**
40
+ * `anthropic-version` for a request to `baseUrl`. `PI_ANTHROPIC_API_VERSION`
41
+ * opts the official first-party API into a newer version; every other host
42
+ * (Copilot, Bedrock, Foundry, Cloudflare, third-party compatibles) stays on
43
+ * {@link LEGACY_ANTHROPIC_API_VERSION} because those deployments gate newer
44
+ * versions on their own schedule (Bedrock accepts 2026-10-21 only for 4.7+).
45
+ * Read per call so a flipped environment takes effect without a restart.
46
+ */
47
+ export function resolveAnthropicApiVersion(baseUrl?: string): AnthropicApiVersion {
48
+ if (!isOfficialAnthropicApiUrl(baseUrl)) return LEGACY_ANTHROPIC_API_VERSION;
49
+ const configured = $env.PI_ANTHROPIC_API_VERSION?.trim();
50
+ if (!configured) return LEGACY_ANTHROPIC_API_VERSION;
51
+ if (isAnthropicApiVersion(configured)) return configured;
52
+ if (warnedInvalidApiVersion !== configured) {
53
+ warnedInvalidApiVersion = configured;
54
+ logger.warn("anthropic: unsupported PI_ANTHROPIC_API_VERSION; using legacy version", {
55
+ configured,
56
+ supported: ANTHROPIC_API_VERSIONS,
57
+ using: LEGACY_ANTHROPIC_API_VERSION,
58
+ });
59
+ }
60
+ return LEGACY_ANTHROPIC_API_VERSION;
61
+ }
62
+
63
+ /**
64
+ * Whether Messages requests on `version` may carry `temperature`, `top_p`,
65
+ * or `top_k`. API version 2026-10-21 rejects all three with a 400, even at
66
+ * their default values.
67
+ */
68
+ export function anthropicApiVersionAcceptsSamplingParams(version: AnthropicApiVersion): boolean {
69
+ return version === "2023-06-01";
70
+ }
71
+
25
72
  const CLOUDFLARE_ANTHROPIC_GATEWAY_URL_MARKER = /gateway\.ai\.cloudflare\.com\/.+\/anthropic(?:\/|$)/i;
26
73
  const VERTEX_ANTHROPIC_URL_MARKER = /aiplatform\.googleapis\.com\/.+\/publishers\/anthropic\//i;
27
74
  const BEDROCK_ANTHROPIC_URL_MARKER = /(?:^|\/\/|\.)bedrock-runtime\.[a-z0-9-]+\.amazonaws\.com/i;
@@ -248,6 +248,7 @@ export const AXES: Readonly<Record<string, AxisDef>> = {
248
248
  ]),
249
249
  "effort-beta": wire("effortBeta", ["anthropic"]),
250
250
  "escape-builtin-tool-names": wire("escapeBuiltinToolNames", ["anthropic"]),
251
+ "extended-cache-ttl-beta": wire("extendedCacheTtlBeta", ["anthropic"]),
251
252
  "fast-mode": wire("fastMode", ["anthropic"]),
252
253
  "first-party-provider": wire("firstPartyProvider", ["anthropic"]),
253
254
  "honors-claude-code-beta-kill-switch": wire("honorsClaudeCodeBetaKillSwitch", ["anthropic"]),
@@ -257,6 +258,7 @@ export const AXES: Readonly<Record<string, AxisDef>> = {
257
258
  "official-endpoint": wire("officialEndpoint", ["anthropic", "openai-responses"]),
258
259
  "replay-unsigned-thinking": wire("replayUnsignedThinking", ["anthropic"]),
259
260
  "requires-thinking-enabled": wire("requiresThinkingEnabled", ["anthropic"]),
261
+ "requires-thinking-presence": wire("requiresThinkingPresence", ["anthropic"]),
260
262
  "requires-tool-result-id": wire("requiresToolResultId", ["anthropic"]),
261
263
  "signing-endpoint": wire("signingEndpoint", ["anthropic"]),
262
264
  "strip-thinking-history": wire("stripThinkingHistory", ["openai", "anthropic", "ollama"]),
@@ -467,6 +469,12 @@ export const AXES: Readonly<Record<string, AxisDef>> = {
467
469
  values: ["gemini", "anthropic", "codex", "xai", "openrouter", "openai"],
468
470
  },
469
471
  "web-search-model": { key: "webSearchModel", set: "catalog", shape: "scalar" },
472
+ /**
473
+ * Revision suffix the host appends to the model's id (Vertex `@default`): a
474
+ * `provider/id` selector written without it names this model exactly.
475
+ * Unassigned: the id has no implied revision and must be written in full.
476
+ */
477
+ "selector-revision-suffix": { key: "selectorRevisionSuffix", set: "catalog", shape: "scalar" },
470
478
  "hosted-image": { key: "hostedImage", set: "catalog", shape: "scalar", values: [true, false] },
471
479
  /** How the model line bills an input image; shape and formulas in `./image-tokenization`. */
472
480
  "image-tokenization": { key: "imageTokenization", set: "catalog", shape: "object" },
@@ -544,12 +552,17 @@ export const AXES: Readonly<Record<string, AxisDef>> = {
544
552
  "limits-patch": { key: "limitsPatch", set: "catalog", shape: "object" },
545
553
  /** Seeds `maxTokens` only when the row reports none; applied after `limits-patch`. */
546
554
  "max-tokens-fallback": { key: "maxTokensFallback", set: "catalog", shape: "scalar" },
547
- /** Most output tokens the host serves: a larger reported `maxTokens` is lowered to it; an unknown one stays unknown. */
555
+ /** Most output tokens the host serves: a larger reported `maxTokens` (and Antigravity per-SKU `maxOutputTokens`) is lowered to it; an unknown one stays unknown. */
548
556
  "max-tokens-ceiling": { key: "maxTokensCeiling", set: "catalog", shape: "scalar" },
549
557
  "long-context-cost": { key: "longContext", set: "catalog", shape: "object" },
550
558
  "prompt-cache": { key: "promptCache", set: "catalog", shape: "object" },
551
- "task-sibling-prompt-cache": {
552
- key: "taskSiblingPromptCache",
559
+ /**
560
+ * The lane rewards routing related requests — Task siblings, forks, explicit
561
+ * `--prompt-cache-key` callers — under one shared prompt-cache key instead of
562
+ * each conversation's own identity. Unassigned: per-conversation routing.
563
+ */
564
+ "shared-prompt-cache": {
565
+ key: "sharedPromptCache",
553
566
  set: "catalog",
554
567
  shape: "scalar",
555
568
  values: [true, false],
@@ -71,6 +71,8 @@ export declare function isRetiredProvider(provider: string): boolean;
71
71
  * model that happens to advertise the same bare id.
72
72
  */
73
73
  export declare function isBareIdReferenceProvider(provider: string): boolean;
74
+ /** Whether a host's prefix cache should use append-only conversation context by default. */
75
+ export declare function prefersAppendOnlyContext(provider: string): boolean;
74
76
  /** The declared subscription tier required to use a provider model id, if any. */
75
77
  export declare function planRequirementFor(provider: string, model: string): string | undefined;
76
78
  /** Cross-provider pricing-peer resolution for one provider model id. */
@@ -204,6 +204,11 @@ export function isBareIdReferenceProvider(provider: string): boolean {
204
204
  return !behavior.referenceIsolatedProviders.includes(provider);
205
205
  }
206
206
 
207
+ /** Whether a host's prefix cache should use append-only conversation context by default. */
208
+ export function prefersAppendOnlyContext(provider: string): boolean {
209
+ return behavior.appendOnlyContextProviders.includes(provider);
210
+ }
211
+
207
212
  /** The declared subscription tier required to use a provider model id, if any. */
208
213
  export function planRequirementFor(provider: string, model: string): string | undefined {
209
214
  const rule = behavior.planRequirements.find(candidate => candidate.provider === provider);
@@ -1,13 +1,15 @@
1
- import { toModelSpec } from "../provider-models/bundled-references";
2
- import type { Model } from "../types";
1
+ import { withoutUnverifiedThinking } from "../model-thinking";
2
+ import type { CatalogPolicyInputs } from "../types";
3
3
  import { resolveCatalogAxes } from "./resolve";
4
4
 
5
5
  /**
6
6
  * Rule-owned catalog-axis policy by model. Resolve once per process rather
7
7
  * than walking the static policy cascade on every accessor call. The key
8
- * mirrors the cascade target inputs — `providerType ?? provider`, api, model
9
- * id, and the reasoning flag; identity-derived class/family/revision facts are
10
- * a pure function of provider + id. Bounded: one entry per distinct model.
8
+ * mirrors the cascade target inputs — `providerType ?? provider`, api, the
9
+ * logical id plus `requestModelId` (the wire id `policyModelId` resolves
10
+ * unknown logical ids under), and the reasoning flag; identity-derived
11
+ * class/family/revision facts are a pure function of provider + id. Bounded:
12
+ * one entry per distinct model.
11
13
  */
12
14
  const catalogPolicyCache = new Map<string, Readonly<Record<string, unknown>>>();
13
15
  const CATALOG_POLICY_CACHE_MAX = 8192;
@@ -17,11 +19,11 @@ const CATALOG_POLICY_CACHE_MAX = 8192;
17
19
  * memoized per distinct model. Frozen: the bag is shared across callers, so it
18
20
  * must stay read-only — extract the value you need rather than handing it on.
19
21
  */
20
- export function resolveCatalogPolicy(model: Model): Readonly<Record<string, unknown>> {
21
- const key = `${model.provider}\u0000${model.providerType ?? ""}\u0000${model.api}\u0000${model.id}\u0000${model.reasoning ? 1 : 0}`;
22
+ export function resolveCatalogPolicy(model: CatalogPolicyInputs): Readonly<Record<string, unknown>> {
23
+ const key = `${model.provider}\u0000${model.providerType ?? ""}\u0000${model.api}\u0000${model.id}\u0000${model.requestModelId ?? ""}\u0000${model.reasoning ? 1 : 0}`;
22
24
  const cached = catalogPolicyCache.get(key);
23
25
  if (cached !== undefined) return cached;
24
- const policy = Object.freeze({ ...resolveCatalogAxes(toModelSpec(model)) });
26
+ const policy = Object.freeze({ ...resolveCatalogAxes(withoutUnverifiedThinking(model)) });
25
27
  if (catalogPolicyCache.size >= CATALOG_POLICY_CACHE_MAX) catalogPolicyCache.clear();
26
28
  catalogPolicyCache.set(key, policy);
27
29
  return policy;
@@ -139,6 +139,16 @@ export declare function isCollapsedVariantSpec(spec: VariantSpecLike): boolean;
139
139
  * and for routes live discovery never advertised.
140
140
  */
141
141
  export declare function isCursorMaxModeWireId(wireModelId: string): boolean;
142
+ /**
143
+ * Whether `wireModelId` is one tier of a reviewed `provider` family that serves
144
+ * different efforts from distinct sibling SKUs (`-low`/`-medium`/`-high`), so
145
+ * the SKU, not the effort, fixes the thinking strength. Decided from the
146
+ * declared family routes, not a collapsed row's routing: an account roster
147
+ * listing one tier collapses to a row routing every effort to it, yet that SKU
148
+ * still advertises its own fixed thinking. Families routing every effort to
149
+ * one `-thinking` SKU keep the effort's own budget or level.
150
+ */
151
+ export declare function isReviewedTierVariantWireId(provider: string, wireModelId: string): boolean;
142
152
  /**
143
153
  * Collapse a full mixed-provider list: per provider, the compiled reviewed table, Cursor's
144
154
  * conservative live effort-sibling rule, and the automatic `X`/`X-thinking`
@@ -36,7 +36,7 @@
36
36
  */
37
37
  import { buildModel } from "../build";
38
38
  import { Effort, THINKING_EFFORTS } from "../effort";
39
- import type { Api, Model, ModelSpec, Provider, ThinkingConfig } from "../types";
39
+ import type { AntigravityModelWireProfile, Api, Model, ModelSpec, Provider, ThinkingConfig } from "../types";
40
40
  import { resolveModelPolicy } from "./resolve";
41
41
  import { parseRevision, parseRevisionConstraint, type RevisionTerm, revisionSatisfies } from "./revision";
42
42
  import { collapseVariantId, collapseVocabulary, stripThinkingVariantSuffix } from "./taxonomy";
@@ -759,6 +759,31 @@ export function isCursorMaxModeWireId(wireModelId: string): boolean {
759
759
  return effort === Effort.XHigh || effort === Effort.Max;
760
760
  }
761
761
 
762
+ /**
763
+ * Whether `wireModelId` is one tier of a reviewed `provider` family that serves
764
+ * different efforts from distinct sibling SKUs (`-low`/`-medium`/`-high`), so
765
+ * the SKU, not the effort, fixes the thinking strength. Decided from the
766
+ * declared family routes, not a collapsed row's routing: an account roster
767
+ * listing one tier collapses to a row routing every effort to it, yet that SKU
768
+ * still advertises its own fixed thinking. Families routing every effort to
769
+ * one `-thinking` SKU keep the effort's own budget or level.
770
+ */
771
+ export function isReviewedTierVariantWireId(provider: string, wireModelId: string): boolean {
772
+ const table = reviewedCollapseTable(provider);
773
+ if (table === undefined) return false;
774
+ const id = wireModelId.trim();
775
+ const family =
776
+ table.families.find(candidate => candidate.members.includes(id)) ??
777
+ (table.templates === undefined ? undefined : templateFamilyFor(table.templates, id));
778
+ if (family === undefined) return false;
779
+ const tiers = new Set<string>();
780
+ for (const key of VARIANT_ROUTING_KEYS) {
781
+ const target = family.routing[key];
782
+ if (key !== "off" && target !== undefined) tiers.add(target);
783
+ }
784
+ return tiers.size > 1 && tiers.has(id);
785
+ }
786
+
762
787
  /**
763
788
  * Recover Cursor's max-mode marker for a bundled collapsed row. The bundled
764
789
  * snapshot may contain only the logical row, but its effort routing still
@@ -821,6 +846,37 @@ function reconcileCursorMaxMode<TSpec extends VariantSpecLike>(spec: TSpec, memb
821
846
  };
822
847
  }
823
848
 
849
+ /**
850
+ * Union the members' discovered Antigravity wire profiles, keyed by each
851
+ * member's own wire id, so the collapsed row keeps the request constants of
852
+ * every SKU it routes to (`...firstMember` alone keeps only the first tier's).
853
+ * Returns `undefined` when no member carries a profile.
854
+ */
855
+ function antigravityWireProfilesOf<TSpec extends VariantSpecLike>(
856
+ memberSpecs: readonly TSpec[],
857
+ ): Record<string, AntigravityModelWireProfile> | undefined {
858
+ let profiles: Record<string, AntigravityModelWireProfile> | undefined;
859
+ for (const member of memberSpecs) {
860
+ if (member.antigravityWireProfiles === undefined) continue;
861
+ profiles = { ...profiles, ...member.antigravityWireProfiles };
862
+ }
863
+ return profiles;
864
+ }
865
+
866
+ /**
867
+ * Merge live members' wire profiles over an already-collapsed snapshot, which
868
+ * froze them (or none) when it was written. Returns `spec` by reference when no
869
+ * member carries a profile.
870
+ */
871
+ function reconcileAntigravityWireProfiles<TSpec extends VariantSpecLike>(
872
+ spec: TSpec,
873
+ memberSpecs: readonly TSpec[],
874
+ ): TSpec {
875
+ const profiles = antigravityWireProfilesOf(memberSpecs);
876
+ if (profiles === undefined) return spec;
877
+ return { ...spec, antigravityWireProfiles: { ...spec.antigravityWireProfiles, ...profiles } };
878
+ }
879
+
824
880
  /**
825
881
  * Collapse every family in `table` found in `specs`. Non-member specs pass
826
882
  * through verbatim (by reference), order preserved; the collapsed spec
@@ -892,7 +948,10 @@ function collapseWithTable<TSpec extends VariantSpecLike>(
892
948
  // lowest tier.
893
949
  replacement.set(
894
950
  family.id,
895
- reconcileCursorMaxMode(reconcileDefaultMember(reconciled, family, new Set(rawPresent)), memberSpecs),
951
+ reconcileAntigravityWireProfiles(
952
+ reconcileCursorMaxMode(reconcileDefaultMember(reconciled, family, new Set(rawPresent)), memberSpecs),
953
+ memberSpecs,
954
+ ),
896
955
  );
897
956
  continue;
898
957
  }
@@ -939,6 +998,7 @@ function collapseWithTable<TSpec extends VariantSpecLike>(
939
998
  // which tier needed it, so the members' own markers are kept per wire id.
940
999
  const cursorMaxMode = memberSpecs.some(spec => spec.cursorMaxMode === true) ? true : undefined;
941
1000
  const cursorMaxModeRoutes = cursorMaxModeRoutesOf(firstMember.provider, memberSpecs);
1001
+ const antigravityWireProfiles = antigravityWireProfilesOf(memberSpecs);
942
1002
  const collapsed: TSpec = {
943
1003
  ...firstMember,
944
1004
  id: family.id,
@@ -949,6 +1009,7 @@ function collapseWithTable<TSpec extends VariantSpecLike>(
949
1009
  maxTokens: maxOrNull(memberSpecs.map(spec => spec.maxTokens)),
950
1010
  ...(cursorMaxMode === undefined ? {} : { cursorMaxMode }),
951
1011
  ...(cursorMaxModeRoutes === undefined ? {} : { cursorMaxModeRoutes }),
1012
+ ...(antigravityWireProfiles === undefined ? {} : { antigravityWireProfiles }),
952
1013
  };
953
1014
  if (memberSpecs.some(spec => spec.isProviderDefault === true)) {
954
1015
  collapsed.isProviderDefault = true;
@@ -45,6 +45,8 @@ export interface FactoryDroidModelPolicy {
45
45
  entitlement: FactoryDroidEntitlement;
46
46
  /** Native default with no caller effort is thinking off. */
47
47
  defaultReasoningOff: boolean;
48
+ /** A `generate_image` model: gated by the org's image-generation settings, served through Factory's image routes. */
49
+ image: boolean;
48
50
  }
49
51
  /** One registry model: its roster row and resolved policy. */
50
52
  export interface FactoryDroidRegistryModel {
@@ -59,6 +59,8 @@ export interface FactoryDroidModelPolicy {
59
59
  entitlement: FactoryDroidEntitlement;
60
60
  /** Native default with no caller effort is thinking off. */
61
61
  defaultReasoningOff: boolean;
62
+ /** A `generate_image` model: gated by the org's image-generation settings, served through Factory's image routes. */
63
+ image: boolean;
62
64
  }
63
65
 
64
66
  /** One registry model: its roster row and resolved policy. */
@@ -128,6 +130,7 @@ function readPolicy(spec: ModelSpec<"factory-droid-agent">): FactoryDroidModelPo
128
130
  ...(baseVariant !== undefined && { baseVariant }),
129
131
  },
130
132
  defaultReasoningOff: catalog.defaultReasoningOff === true,
133
+ image: catalog.kind === "image",
131
134
  };
132
135
  }
133
136
 
@@ -1,4 +1,4 @@
1
- import type { Api, CompatOf, ModelSpec, ThinkingConfig } from "../types";
1
+ import type { Api, CatalogPolicyInputs, CompatOf, ModelSpec, ThinkingConfig } from "../types";
2
2
  import type { ModelIdentity, RequestPolicy } from "./types";
3
3
  /** Result of resolving one model spec through the compat engine. */
4
4
  export interface ResolvedModelPolicy<TApi extends Api = Api> {
@@ -21,7 +21,7 @@ export declare function resolveDiscoveryApi(spec: ModelSpec<Api>, providerType:
21
21
  * {@link resolveModelPolicy} without resolving the compat and thinking
22
22
  * policies, which dominate its cost on catalog-wide scans.
23
23
  */
24
- export declare function resolveCatalogAxes(spec: ModelSpec<Api>): Record<string, unknown>;
24
+ export declare function resolveCatalogAxes(spec: CatalogPolicyInputs): Record<string, unknown>;
25
25
  /**
26
26
  * Resolves the full policy surface for one model spec: structured identity,
27
27
  * complete compat record, thinking metadata, and catalog-data corrections.
@@ -20,6 +20,7 @@ import { hostMatchesUrl, modelMatchesHost } from "../hosts";
20
20
  import { withoutUnverifiedThinking } from "../model-thinking";
21
21
  import type {
22
22
  Api,
23
+ CatalogPolicyInputs,
23
24
  CompatOf,
24
25
  ModelSpec,
25
26
  OpenAICompat,
@@ -126,14 +127,14 @@ class IdentityFacts {
126
127
  * pairing runs only its lead, so the lead's reviewed rules (cache-write rate,
127
128
  * long-context tier) apply to it at build time.
128
129
  */
129
- function policyModelId<TApi extends Api>(spec: ModelSpec<TApi>): string {
130
+ function policyModelId(spec: CatalogPolicyInputs): string {
130
131
  const wireId = spec.requestModelId;
131
132
  if (wireId === undefined || wireId === spec.id) return spec.id;
132
133
  if (classifyModel(spec.provider, spec.id).class !== "unknown") return spec.id;
133
134
  return classifyModel(spec.provider, wireId).class === "unknown" ? spec.id : wireId;
134
135
  }
135
136
 
136
- function resolveIdentity<TApi extends Api>(spec: ModelSpec<TApi>): ModelIdentity {
137
+ function resolveIdentity(spec: CatalogPolicyInputs): ModelIdentity {
137
138
  // Strict on purpose: ambiguous identity is a rule-authoring defect surfaced
138
139
  // at build/CI time, never silently degraded to `unknown`. Discovery
139
140
  // normalization opts into leniency through `classifyModel` directly.
@@ -924,6 +925,7 @@ function resolveAnthropicPolicy(
924
925
  supportsSamplingParams: true,
925
926
  requiresToolResultId: false,
926
927
  requiresThinkingEnabled,
928
+ requiresThinkingPresence: false,
927
929
  replayUnsignedThinking:
928
930
  !signingEndpoint && (compatReasoning(spec, axes) || modelMatchesHost(spec, "deepseekFamily")),
929
931
  escapeBuiltinToolNames: false,
@@ -1305,8 +1307,8 @@ function fillExplicitThinking<TApi extends Api>(
1305
1307
  // Entry
1306
1308
  // ---------------------------------------------------------------------------
1307
1309
 
1308
- function buildResolveTarget<TApi extends Api>(
1309
- spec: ModelSpec<TApi>,
1310
+ function buildResolveTarget(
1311
+ spec: CatalogPolicyInputs,
1310
1312
  identity: ModelIdentity,
1311
1313
  providerType = spec.providerType ?? spec.provider,
1312
1314
  ): ResolveTarget {
@@ -1338,7 +1340,7 @@ export function resolveDiscoveryApi(spec: ModelSpec<Api>, providerType: string):
1338
1340
  * {@link resolveModelPolicy} without resolving the compat and thinking
1339
1341
  * policies, which dominate its cost on catalog-wide scans.
1340
1342
  */
1341
- export function resolveCatalogAxes(spec: ModelSpec<Api>): Record<string, unknown> {
1343
+ export function resolveCatalogAxes(spec: CatalogPolicyInputs): Record<string, unknown> {
1342
1344
  return resolveCascade(buildResolveTarget(spec, resolveIdentity(spec))).catalog;
1343
1345
  }
1344
1346