@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/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.4.7] - 2026-10-30
4
+
5
+ - Synced with upstream OMP v18.14.0; no package-specific user-visible changes.
6
+
7
+ ## [1.4.6] - 2026-10-28
8
+
9
+ ### Breaking Changes
10
+
11
+ - Removed the raw `@oh-my-pi/pi-catalog/models.json` export; use the bundled model registry APIs instead.
12
+
13
+ ### Added
14
+
15
+ - Added `nextBuildPriceChange(cost, now)` to identify when a model's dated pricing card may change, allowing callers to safely reuse earlier builds until that time.
16
+ - Added the `selector-revision-suffix` catalog axis for Google Vertex, so `google-vertex/claude-opus-4-8` resolves exactly to `claude-opus-4-8@default`.
17
+
18
+ ### Changed
19
+
20
+ - Reduced the bundled model catalog size and loading overhead.
21
+ - Updated role defaults so Factory Droid image models are preferred for the `image` role, allowing `generate_image` to work with only a Factory login.
22
+ - Updated `smol` and `slow` role defaults to use the currently bundled Cerebras and OpenAI Codex model identifiers.
23
+
24
+ ### Fixed
25
+
26
+ - Fixed Mistral reasoning models so streamed thinking appears in the transcript and is preserved for subsequent turns.
27
+ - Fixed later-turn HTTP 422 errors in Mistral-hosted DeepSeek conversations when assistant reasoning history is included.
28
+ - Fixed DeepSeek V4.1 Flash image attachments being dropped for publisher-namespaced model IDs such as `ds/deepseek-flash`.
29
+
30
+ ## [1.4.5] - 2026-10-28
31
+
32
+ - Synced with upstream OMP v18.13.2: model discovery honors a gateway's self-described reasoning levels (`discovery.advertisedReasoning`).
33
+
3
34
  ## [1.4.4] - 2026-10-26
4
35
 
5
36
  - Released as part of Zeta 1.4.4; no package-specific user-visible changes.
package/README.md CHANGED
@@ -21,7 +21,7 @@ Import from subpaths (`@linxiraos/pi-catalog/<module>`) or the root barrel.
21
21
 
22
22
  ## models.json and rules.json are generated
23
23
 
24
- Never edit `src/models.json` or `src/compat/rules.json` by hand. `models.json` is produced from upstream sources (stencil.so, provider catalog discovery, OpenCode docs) by `scripts/generate-models.ts`; `rules.json` is compiled from the KDL tree in `src/compat/rules/`. Regenerate with:
24
+ Never edit `src/models.json` or `src/compat/rules.json` by hand. `models.json` is a compact generated catalog; use `getBundledProviders()` and `getBundledModels()` instead of reading its internal format. It is produced from upstream sources (stencil.so, provider catalog discovery, OpenCode docs) by `scripts/generate-models.ts`; `rules.json` is compiled from the KDL tree in `src/compat/rules/`. Regenerate with:
25
25
 
26
26
  ```sh
27
27
  bun run gen:compat # src/compat/rules/**/*.kdl -> src/compat/rules.json
@@ -36,7 +36,7 @@ Model- or provider-conditional policy (identity, effort ladders, wire quirks, mo
36
36
  bun add @linxiraos/pi-catalog
37
37
  ```
38
38
 
39
- Ships TypeScript source directly (no build step); requires Bun ≥ 1.3.14.
39
+ Ships TypeScript source directly (no build step); requires Bun ≥ 1.4.4.
40
40
 
41
41
  ## Cost calculation
42
42
 
@@ -47,7 +47,7 @@ The `models` subpath (also exported from the root) provides timestamp-aware pric
47
47
  | `calculateCost(model, usage, timestamp?)` | Updates and returns `usage.cost` using `model.cost`. |
48
48
  | `calculateUsageCost(cost, usage, timestamp?)` | Updates and returns `usage.cost` using a `ModelCost`. |
49
49
  | `calculateUncachedInputCost(cost, promptInputTokens, timestamp?)` | Returns the cost of a fully uncached prompt. |
50
- | `getEffectiveTokenCost(cost, timestamp?)` | Returns the base card in force: the latest due effective rate, else the row's own legs. |
50
+ | `getEffectiveTokenCost(cost, timestamp?)` | Returns the base card in force: the latest due effective rate, else the row's own legs. |
51
51
  | `getTimeBasedPricingPeriod(cost, timestamp?)` | Returns `"peak"`, `"off-peak"`, or `undefined` without a recurring tariff. |
52
52
  | `hasRecurringTariff(schedule)` | Whether a `TimeBasedCost` carries a peak/off-peak tariff rather than only dated rate cards. |
53
53
  | `getNextTimeBasedPricingTransition(cost, timestamp?)` | Returns the next actual peak/off-peak change strictly after the timestamp, or `undefined` if none exists. |
@@ -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.js";
9
+ import { type Api, type Model, type ModelCost, type ModelSpec } from "./types.js";
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>;
@@ -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`
@@ -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. */
@@ -1,7 +1,7 @@
1
- import type { Model } from "../types.js";
1
+ import type { CatalogPolicyInputs } from "../types.js";
2
2
  /**
3
3
  * The `catalog` axis bag authored in the KDL cascade rules for a model,
4
4
  * memoized per distinct model. Frozen: the bag is shared across callers, so it
5
5
  * must stay read-only — extract the value you need rather than handing it on.
6
6
  */
7
- export declare function resolveCatalogPolicy(model: Model): Readonly<Record<string, unknown>>;
7
+ export declare function resolveCatalogPolicy(model: CatalogPolicyInputs): Readonly<Record<string, unknown>>;
@@ -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`
@@ -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 {
@@ -1,4 +1,4 @@
1
- import type { Api, CompatOf, ModelSpec, ThinkingConfig } from "../types.js";
1
+ import type { Api, CatalogPolicyInputs, CompatOf, ModelSpec, ThinkingConfig } from "../types.js";
2
2
  import type { ModelIdentity, RequestPolicy } from "./types.js";
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.
@@ -327,6 +327,8 @@ export interface CompiledBehavior {
327
327
  pricingPeers: CompiledPricingPeer[];
328
328
  retryResetTimezones: CompiledRetryResetTimezone[];
329
329
  retiredProviders: string[];
330
+ /** Hosts whose prefix caches benefit from a stable append-only conversation. */
331
+ appendOnlyContextProviders: string[];
330
332
  referenceIsolatedProviders: string[];
331
333
  /** Built-in model selector chains per agent role, keyed by role in declaration order. */
332
334
  roleDefaults: Record<string, string[]>;
@@ -367,8 +369,10 @@ export type CompiledAuthValidation = {
367
369
  kind: "models-endpoint";
368
370
  label?: string;
369
371
  url: string;
370
- /** Env var holding an alternate base URL; `/models` is appended to it. */
372
+ /** Env var holding an alternate base URL; `baseUrlPath` is appended to it. */
371
373
  baseUrlEnv?: string;
374
+ /** Path appended to the `baseUrlEnv` value (default `/models`), for bases that exclude the API version. */
375
+ baseUrlPath?: string;
372
376
  /** Hook returning extra request headers (may throw a configuration error). */
373
377
  headersHook?: string;
374
378
  optional?: boolean;
@@ -11,6 +11,8 @@ export interface AntigravityDiscoveryApiModel {
11
11
  supportsImages?: boolean;
12
12
  supportsThinking?: boolean;
13
13
  thinkingBudget?: number;
14
+ /** SKU thinking level: 1 low, 2 medium, 3 high. */
15
+ thinkingLevel?: number;
14
16
  recommended?: boolean;
15
17
  maxTokens?: number;
16
18
  maxOutputTokens?: number;
@@ -55,8 +57,11 @@ export interface FetchAntigravityDiscoveryModelsOptions {
55
57
  token: string;
56
58
  /** Optional endpoint override. Defaults to Antigravity fallback endpoints. */
57
59
  endpoint?: string;
58
- /** Deprecated and ignored for antigravity discovery parity. */
59
- project?: string;
60
+ /**
61
+ * Cloud Code Assist project the account is onboarded to. Sent as the body's
62
+ * `project` field like the native client; the body is `{}` when absent.
63
+ */
64
+ projectId?: string;
60
65
  /** Optional user agent override. */
61
66
  userAgent?: string;
62
67
  /** Optional abort signal for request cancellation. */
@@ -27,12 +27,11 @@ export interface CodexModelDiscoveryResult {
27
27
  models: ModelSpec<"openai-codex-responses">[];
28
28
  etag?: string;
29
29
  /**
30
- * Set when the backend rejected the credential itself (401/403, e.g.
31
- * `token_revoked`); `models` is empty. A definitive per-account denial,
32
- * unlike the `null` result for transport/parse failures, so multi-account
33
- * discovery can skip the account instead of aborting.
30
+ * A definitive per-account denial (401/403 auth, 402 payment). `models` is
31
+ * empty; unlike transport/parse failures, sibling accounts can still supply
32
+ * an authoritative catalog.
34
33
  */
35
- rejectedStatus?: 401 | 403;
34
+ rejectedStatus?: 401 | 402 | 403;
36
35
  }
37
36
  /**
38
37
  * Fetches model metadata from Codex backend and normalizes it for pi model management.
@@ -7,7 +7,7 @@ export interface DevinModelDiscoveryOptions {
7
7
  apiKey?: string;
8
8
  /** Optional Codeium API base URL override. */
9
9
  baseUrl?: string;
10
- /** Optional request timeout in milliseconds (default 5000). */
10
+ /** Optional request timeout in milliseconds (default 15000). */
11
11
  timeoutMs?: number;
12
12
  /** Optional caller abort signal, combined with the internal timeout. */
13
13
  signal?: AbortSignal;
@@ -48,6 +48,14 @@ export interface CacheEntry<TApi extends Api = Api> {
48
48
  * cache was opened under — Windows cannot remove a database that is still open.
49
49
  */
50
50
  export declare function closeModelCache(): void;
51
+ /**
52
+ * Keeps one connection to a non-default cache path open until the returned
53
+ * handle is disposed. The default `models.db` already shares a long-lived
54
+ * connection; other paths otherwise open, initialize and close the database on
55
+ * every read and write, which a refresh pass repeats once per provider.
56
+ * Retains nest: the connection closes when the last one is disposed.
57
+ */
58
+ export declare function retainModelCacheConnection(dbPath: string | undefined): Disposable;
51
59
  export declare function readModelCache<TApi extends Api>(providerId: string, ttlMs: number, now: () => number, dbPath?: string): CacheEntry<TApi> | null;
52
60
  /**
53
61
  * Persist a provider snapshot.
@@ -0,0 +1,37 @@
1
+ import type { Api, Model } from "./types.js";
2
+ type EncodedValue = string | number | boolean | null | [number];
3
+ type ObjectNode = [0, EncodedValue[], number, number[]];
4
+ type ArrayNode = [1, EncodedValue[]];
5
+ type Node = ObjectNode | ArrayNode;
6
+ type CompatDelta = [number[], EncodedValue];
7
+ type ModelRow = [string, EncodedValue, CompatDelta?];
8
+ type ProviderRow = [string, EncodedValue, ModelRow[]];
9
+ interface CatalogData {
10
+ version: 1;
11
+ keys: string[];
12
+ booleanShapes: number[][];
13
+ nodes: Node[];
14
+ compat: [string, EncodedValue][];
15
+ providers: ProviderRow[];
16
+ }
17
+ /**
18
+ * Parsed compact catalog. Decoded nested objects and arrays can be shared by
19
+ * multiple models; callers must treat those values as immutable.
20
+ */
21
+ export interface ModelCatalog {
22
+ readonly data: CatalogData;
23
+ readonly values: unknown[];
24
+ readonly decoded: boolean[];
25
+ readonly providers: Map<string, Record<string, Model<Api>>>;
26
+ readonly compatBases: Map<string, EncodedValue>;
27
+ readonly compatValues: Map<string, Map<number, Map<string, Record<string, unknown>>>>;
28
+ }
29
+ /** Encode a model catalog into a deterministic, compact JSON representation. */
30
+ export declare function encodeModelCatalog(models: Record<string, Record<string, Model<Api>>>): string;
31
+ /** Open a parsed catalog without materializing its provider models. */
32
+ export declare function openModelCatalog(value: unknown): ModelCatalog;
33
+ /** List catalog provider keys in deterministic order. */
34
+ export declare function getCatalogProviders(catalog: ModelCatalog): string[];
35
+ /** Materialize and cache one provider, or return undefined if it is absent. */
36
+ export declare function getCatalogProvider(catalog: ModelCatalog, provider: string): Record<string, Model<Api>> | undefined;
37
+ export {};
@@ -1,10 +1,13 @@
1
- import MODELS from "./models.json";
2
1
  import type { Api, KnownProvider, Model, ModelCost, ModelPricingStatus, TimeBasedCost, TokenCost, Usage } from "./types.js";
3
- export type GeneratedProvider = keyof typeof MODELS;
2
+ /** Provider identifier accepted by the bundled model registry. */
3
+ export type GeneratedProvider = string;
4
4
  /** Whether `provider` has bundled rows in models.json (e.g. a provider id authored in KDL). */
5
5
  export declare function isGeneratedProvider(provider: string): provider is GeneratedProvider;
6
+ /** Look up a bundled model; nested catalog values are shared and must not be mutated. */
6
7
  export declare function getBundledModel<TApi extends Api = Api>(provider: GeneratedProvider, modelId: string): Model<TApi>;
7
- export declare function getBundledProviders(): KnownProvider[];
8
+ /** List providers with bundled rows; the array is shared and frozen. */
9
+ export declare function getBundledProviders(): readonly KnownProvider[];
10
+ /** List a provider's bundled models; nested catalog values are shared and must not be mutated. */
8
11
  export declare function getBundledModels(provider: GeneratedProvider): Model<Api>[];
9
12
  /** Resolve display semantics without mistaking an absent rate card for a free model. */
10
13
  export declare function getModelPricingStatus(model: Pick<Model<Api>, "cost" | "pricingStatus">): ModelPricingStatus;
@@ -21,6 +21,8 @@ export interface GoogleAntigravityAccount {
21
21
  * When any account lacks one, no model records per-account access.
22
22
  */
23
23
  accountKey?: string;
24
+ /** Cloud Code Assist project of the credential, sent with roster discovery like the native client. */
25
+ projectId?: string;
24
26
  }
25
27
  export interface GoogleAntigravityModelManagerConfig {
26
28
  /**
@@ -377,24 +377,32 @@ export declare const KIMI_CODE_DEFAULT_MAX_TOKENS = 32000;
377
377
  export declare function kimiCodeMaxTokens(modelId: string, fallback?: number): number;
378
378
  export declare function kimiCodeMaxTokens(modelId: string, fallback: number | null): number | null;
379
379
  export declare function kimiCodeModelManagerOptions(config?: KimiCodeModelManagerConfig): ModelManagerOptions<"openai-completions">;
380
- /** Native LM Studio metadata keyed by model id from `/api/v0/models`. */
380
+ /** Native LM Studio metadata keyed by model id from `/api/v0/models` and `/api/v1/models`. */
381
381
  export interface LmStudioNativeModelMetadata {
382
382
  input: ("text" | "image")[];
383
383
  contextWindow?: number;
384
+ /**
385
+ * LM Studio reports a decision model (`type: "decision"`): it answers typed
386
+ * questions on `/v1/decisions` and rejects chat completions.
387
+ */
388
+ decision?: true;
384
389
  }
385
390
  /** Options for LM Studio's optional native metadata probe. */
386
391
  export interface LmStudioNativeModelMetadataOptions {
387
392
  headers?: Record<string, string>;
388
393
  signal?: AbortSignal;
389
394
  }
390
- /** Fetches LM Studio native model metadata used to mark VLM models as image-capable. */
395
+ /**
396
+ * Fetches LM Studio native model metadata used to mark VLM models as
397
+ * image-capable and decision models as judges.
398
+ */
391
399
  export declare function fetchLmStudioNativeModelMetadata(baseUrl: string, fetchImpl?: FetchImpl, options?: LmStudioNativeModelMetadataOptions): Promise<Map<string, LmStudioNativeModelMetadata> | null>;
392
400
  export interface LmStudioModelManagerConfig {
393
401
  apiKey?: string;
394
402
  baseUrl?: string;
395
403
  fetch?: FetchImpl;
396
404
  }
397
- export declare function lmStudioModelManagerOptions(config?: LmStudioModelManagerConfig): ModelManagerOptions<"openai-completions">;
405
+ export declare function lmStudioModelManagerOptions(config?: LmStudioModelManagerConfig): ModelManagerOptions<Api>;
398
406
  export interface SyntheticModelManagerConfig {
399
407
  apiKey?: string;
400
408
  baseUrl?: string;
@@ -560,6 +568,11 @@ export declare const OPENAI_COMPAT_DISCOVERY_DEFAULT_MAX_TOKENS = 32768;
560
568
  /** Exclude only known non-conversational modes; unknown and non-string modes remain selectable for aliases. */
561
569
  export declare function isSelectableLiteLLMModelMode(mode: unknown): boolean;
562
570
  export declare function normalizeLiteLLMManagementBaseUrl(baseUrl: string): string;
571
+ /**
572
+ * Transport for a LiteLLM model group: `mode: "decisions"` answers only on the
573
+ * proxy's `/v1/decisions` route, OpenAI-backed groups use Responses, and every
574
+ * other group uses `fallbackApi`.
575
+ */
563
576
  export declare function resolveLiteLLMApi(entry: Record<string, unknown> | undefined, id: string, fallbackApi?: Api): Api;
564
577
  export declare function fetchLiteLLMRichModels<TApi extends Api>(options: FetchLiteLLMRichModelsOptions<TApi>): Promise<ModelSpec<TApi>[] | null>;
565
578
  export declare function litellmModelManagerOptions(config?: LiteLLMModelManagerConfig): ModelManagerOptions<Api>;
@@ -20,12 +20,12 @@ export declare const RUNNER_API_KINDS: Record<Exclude<(typeof RUNNER_APIS)[numbe
20
20
  /** Kind a runner API serves; `undefined` for chat transports and multi-kind `local-inference`. */
21
21
  export declare function runnerApiKind(api: Api): ModelKind | undefined;
22
22
  /** Catalog APIs `generate_image` runs through a pi-ai image client; the hosted Responses pair needs a carrier model. */
23
- export declare const IMAGE_GENERATION_APIS: readonly ["openai-images", "openrouter-images", "google-generative-ai", "google-gemini-cli", "openai-responses", "openai-codex-responses"];
23
+ export declare const IMAGE_GENERATION_APIS: readonly ["openai-images", "openrouter-images", "google-generative-ai", "google-gemini-cli", "openai-responses", "openai-codex-responses", "factory-droid-agent"];
24
24
  export type ImageGenerationApi = (typeof IMAGE_GENERATION_APIS)[number];
25
25
  /**
26
26
  * Kinds a model on `api` may declare: a runner api serves its own kind; a chat
27
27
  * transport serves `chat` and `tiny`, plus `image` when `generate_image` runs it
28
- * (hosted Responses image tool, Gemini image models). `undefined` for
28
+ * (hosted Responses image tool, Gemini and Factory Droid image models). `undefined` for
29
29
  * `local-inference`, which hosts several kinds chosen by the model itself.
30
30
  */
31
31
  export declare function servedKinds(api: Api): readonly ModelKind[] | undefined;
@@ -550,6 +550,8 @@ export interface AnthropicCompat {
550
550
  supportsEagerToolInputStreaming?: boolean;
551
551
  /** Whether long prompt-cache retention (`ttl: "1h"`) is supported. Default: true for canonical Anthropic API. */
552
552
  supportsLongCacheRetention?: boolean;
553
+ /** Whether a `ttl: "1h"` breakpoint on API-key requests adds the `extended-cache-ttl-2025-04-11` beta. Unset: true (Vertex rawPredict URLs never send it). */
554
+ extendedCacheTtlBeta?: boolean;
553
555
  /**
554
556
  * Whether mid-conversation `role: "system"` messages are accepted in the
555
557
  * `messages` array. When unset, auto-detected from model and deployment policy.
@@ -608,6 +610,21 @@ export interface AnthropicCompat {
608
610
  * Default: auto-detected from provider/baseUrl and `model.reasoning`.
609
611
  */
610
612
  replayUnsignedThinking?: boolean;
613
+ /**
614
+ * Whether a thinking-mode history must carry a `thinking` block on EVERY
615
+ * assistant turn of the current turn. DeepSeek's Anthropic endpoint rejects
616
+ * the whole request (`The content[].thinking in the thinking mode must be
617
+ * passed back to the API.`) when any assistant turn after the last user text
618
+ * lacks one, including turns another upstream in the same gateway model group
619
+ * produced without reasoning. Presence is all it validates (the block text may
620
+ * be a placeholder, the signature may be empty), and only `thinking` counts —
621
+ * `redacted_thinking` does not, and that endpoint rejects the block outright.
622
+ * A model group that may fail over to such an endpoint must set this: the
623
+ * stricter member defines the replay contract for the group.
624
+ * Default: false (official Anthropic and lax proxies tolerate a turn without
625
+ * thinking and the block is not invented for them).
626
+ */
627
+ requiresThinkingPresence?: boolean;
611
628
  /**
612
629
  * Whether the endpoint requires `thinking.type: "enabled"` whenever the
613
630
  * model reasons. Use for models that reject omitted or disabled thinking.
@@ -975,9 +992,11 @@ export interface ResolvedOpenAIResponsesCompat extends ResolvedOpenAISharedCompa
975
992
  */
976
993
  export type ResolvedOpenRouterCompat = ResolvedOpenAICompat & ResolvedOpenAIResponsesCompat;
977
994
  /** Fully-resolved anthropic-messages compat view (same contract as `ResolvedOpenAICompat`). */
978
- export type ResolvedAnthropicCompat = Required<Omit<AnthropicCompat, "streamIdleTimeoutMs" | "thinkingLoopGuard" | "bedrockMessagesApi" | "effortBeta" | "disabledThinking" | "betweenToolsEffort" | "stripThinkingHistory" | "fastMode" | "maxImageDimension" | "maxImagePayloadBytes">> & {
995
+ export type ResolvedAnthropicCompat = Required<Omit<AnthropicCompat, "streamIdleTimeoutMs" | "thinkingLoopGuard" | "bedrockMessagesApi" | "effortBeta" | "extendedCacheTtlBeta" | "disabledThinking" | "betweenToolsEffort" | "stripThinkingHistory" | "fastMode" | "maxImageDimension" | "maxImagePayloadBytes">> & {
979
996
  /** Effort-beta override; undefined keeps the transport's legacy heuristic. */
980
997
  effortBeta?: AnthropicCompat["effortBeta"];
998
+ /** Extended-cache-ttl beta opt-out; undefined sends it where a 1h breakpoint needs it. */
999
+ extendedCacheTtlBeta?: AnthropicCompat["extendedCacheTtlBeta"];
981
1000
  /** Disabled-thinking wire form; undefined keeps the direct-provider behavior. */
982
1001
  disabledThinking?: AnthropicCompat["disabledThinking"];
983
1002
  /** Effort pinned on `between_tools` turns; undefined leaves effort untouched. */
@@ -1204,6 +1223,13 @@ export interface ModelAccountAccess {
1204
1223
  * Absent when the backend reported no program metadata.
1205
1224
  */
1206
1225
  cyberPrograms?: readonly string[];
1226
+ /**
1227
+ * Antigravity request constants this account's `fetchAvailableModels`
1228
+ * roster advertised, keyed by upstream SKU id. Takes precedence over
1229
+ * {@link Model.antigravityWireProfiles}, which keeps only the first
1230
+ * account's values when multi-account rosters are unioned.
1231
+ */
1232
+ antigravityWireProfiles?: Readonly<Record<string, AntigravityModelWireProfile>>;
1207
1233
  }
1208
1234
  /** One Cursor `RequestedModel.parameters` entry recovered from rich discovery. */
1209
1235
  export interface CursorModelParameter {
@@ -1216,6 +1242,20 @@ export interface CursorModelRoute {
1216
1242
  parameters: readonly CursorModelParameter[];
1217
1243
  maxMode?: boolean;
1218
1244
  }
1245
+ /**
1246
+ * Antigravity Cloud Code Assist request constants for one upstream SKU, as the
1247
+ * native client sends them; see {@link Model.antigravityWireProfiles}.
1248
+ */
1249
+ export interface AntigravityModelWireProfile {
1250
+ /** Opaque `labels.model_enum` token (`fetchAvailableModels` `model`). */
1251
+ modelEnum?: string;
1252
+ /** Fixed `generationConfig.maxOutputTokens` the client always sends. */
1253
+ maxOutputTokens?: number;
1254
+ /** SKU thinking level; the native client sends it in preference to a budget. */
1255
+ thinkingLevel?: "LOW" | "MEDIUM" | "HIGH";
1256
+ /** SKU thinking budget (`-1` is dynamic), sent when no level is advertised. */
1257
+ thinkingBudget?: number;
1258
+ }
1219
1259
  export interface Model<TApi extends Api = Api> {
1220
1260
  id: string;
1221
1261
  /** Role-specific runner capability; omitted for ordinary chat models. */
@@ -1329,6 +1369,13 @@ export interface Model<TApi extends Api = Api> {
1329
1369
  * their single wire id) and on bundled snapshots that predate discovery.
1330
1370
  */
1331
1371
  cursorMaxModeRoutes?: Readonly<Record<string, boolean>>;
1372
+ /**
1373
+ * Per-wire-id Antigravity request constants recorded from the account's
1374
+ * `fetchAvailableModels` roster, keyed by upstream SKU id. A collapsed row
1375
+ * carries one entry per member it routes to; a raw row carries its own.
1376
+ * Absent on bundled snapshots that predate discovery.
1377
+ */
1378
+ antigravityWireProfiles?: Readonly<Record<string, AntigravityModelWireProfile>>;
1332
1379
  /**
1333
1380
  * Per-account availability recorded by multi-account discovery: provider
1334
1381
  * account key (Codex: ChatGPT `chatgpt_account_id`; Antigravity: login
@@ -1525,3 +1572,11 @@ export interface ModelSpec<TApi extends Api = Api> extends Omit<Model<TApi>, "co
1525
1572
  /** Sparse compatibility overrides; resolved into `Model.compat` by `buildModel`. */
1526
1573
  compat?: CompatConfigOf<TApi>;
1527
1574
  }
1575
+ /**
1576
+ * The model facts the catalog policy cascade reads: the resolve-target inputs
1577
+ * (`providerType ?? provider`, the request adapter, the wire model id, the
1578
+ * reasoning flag) plus the unverified-thinking correction applied before the
1579
+ * cascade. Callers holding a reduced model view — request adapters that only
1580
+ * need policy — supply exactly these instead of asserting a full `Model`.
1581
+ */
1582
+ export type CatalogPolicyInputs = Pick<ModelSpec<Api>, "provider" | "providerType" | "api" | "id" | "reasoning" | "requestModelId" | "thinking">;
@@ -49,7 +49,7 @@ export declare const OPENAI_HEADER_VALUES: {
49
49
  readonly BETA_RESPONSES: "responses=experimental";
50
50
  readonly BETA_RESPONSES_WEBSOCKETS_V2: "responses_websockets=2026-02-06";
51
51
  readonly REMOTE_COMPACTION_V2: "remote_compaction_v2";
52
- readonly ORIGINATOR_CODEX: "zeta";
52
+ readonly ORIGINATOR_CODEX: "omp";
53
53
  };
54
54
  export declare const URL_PATHS: {
55
55
  readonly RESPONSES: "/responses";
@@ -13,9 +13,9 @@ export declare const DEVIN_DEFAULT_BASE_URL = "https://server.codeium.com";
13
13
  export declare function devinCliMetadata(apiKey: string | undefined, userJwt?: string): {
14
14
  ideName: "devin-cli";
15
15
  ideType: "chisel";
16
- ideVersion: "3000.11.3";
16
+ ideVersion: "3000.11.205";
17
17
  extensionName: "chisel";
18
- extensionVersion: "3000.11.3";
18
+ extensionVersion: "3000.11.205";
19
19
  locale: "en";
20
20
  os: "darwin" | "linux" | "windows";
21
21
  apiKey: string;
@@ -1,4 +1,5 @@
1
1
  import type { FetchImpl } from "@linxiraos/pi-utils";
2
+ import type { AntigravityModelWireProfile } from "../types.js";
2
3
  /**
3
4
  * Build a User-Agent string that identifies as Gemini CLI to unlock higher rate limits.
4
5
  * Uses the same format as the official Gemini CLI (v0.35+):
@@ -15,16 +16,19 @@ export declare const getGeminiCliHeaders: (modelId?: string) => {
15
16
  * (and its @google/genai → google-auth-library dependency chain) into the startup
16
17
  * parse graph.
17
18
  *
18
- * Format captured from the real 2.8.0 `antigravity/hub` client:
19
- * `antigravity/hub/2.8.0 (aidev_client; os_type=darwin; arch=arm64; cl=963137146)`.
19
+ * Format captured from the real 2.26.0 `antigravity/hub` client:
20
+ * `antigravity/hub/2.26.0 (aidev_client; os_type=darwin; arch=arm64; cl=1005016104)`.
20
21
  * The backend gates newer models (e.g. gemini-3.7-flash) on the client version,
21
22
  * so the version tracks the latest Antigravity release via the update manifest
22
23
  * (see {@link ensureAntigravityVersion}) with `DEFAULT_ANTIGRAVITY_VERSION` as
23
- * the offline fallback. os_type/arch are pinned to the darwin/arm64 reference
24
- * client the version and manifest are captured from, independent of the host
25
- * platform. Overrides: PI_AI_ANTIGRAVITY_VERSION / _CL / _OS / _ARCH.
24
+ * the offline fallback. os_type/arch name the native build for the host OS:
25
+ * each 2.26.0 installer ships one language-server build whose Go target is
26
+ * stamped into the header (macOS darwin/arm64, Linux linux/amd64, Windows
27
+ * windows/amd64; no other OS/arch builds exist); see
28
+ * {@link getAntigravityPlatform}. The changelist is identical across those
29
+ * builds. Overrides: PI_AI_ANTIGRAVITY_VERSION / _CL / _OS / _ARCH.
26
30
  */
27
- export declare const DEFAULT_ANTIGRAVITY_VERSION = "2.19.1";
31
+ export declare const DEFAULT_ANTIGRAVITY_VERSION = "2.26.0";
28
32
  /** Current Antigravity client version: env override → manifest-discovered → pinned fallback. */
29
33
  export declare function getAntigravityVersion(): string;
30
34
  /**
@@ -42,24 +46,39 @@ export declare function parseAntigravityManifestVersion(yamlText: string): strin
42
46
  * timeout; `signal` ends this caller's wait without cancelling the lookup.
43
47
  */
44
48
  export declare function ensureAntigravityVersion(fetcher?: FetchImpl, signal?: AbortSignal): Promise<void>;
49
+ /**
50
+ * Native build the host would run. OSes without a native build report the
51
+ * Linux build, the closest client that exists.
52
+ */
53
+ export declare function getAntigravityPlatform(platform?: NodeJS.Platform): {
54
+ os: string;
55
+ arch: string;
56
+ };
45
57
  /** Antigravity `User-Agent` header value; rebuilt when the discovered version changes. */
46
58
  export declare function getAntigravityUserAgent(): string;
47
59
  /**
48
- * Per-wire-id Antigravity Cloud Code Assist request constants, captured from the
49
- * real `antigravity/hub` client against `daily-cloudcode-pa`. `modelEnum` is the
50
- * opaque `labels.model_enum` token the client tags each request with — optional
51
- * because Anthropic-backed wire ids (e.g. `claude-sonnet-4-6`,
52
- * `claude-opus-4-6-thinking`) are accepted without one; the label is purely
53
- * telemetry. `maxOutputTokens` is the fixed `generationConfig.maxOutputTokens`
54
- * the backend enforces regardless of the thinking budget (Claude caps at
55
- * 64000, Gemini accepts the discovered cap). Keyed by the routed upstream wire
56
- * id (post effort-routing), not the collapsed logical id. Checkpoint-only ids
57
- * (e.g. `gemini-3.1-flash-lite`) are intentionally absent — this provider only
58
- * emits agent requests.
60
+ * Client headers for every Antigravity Cloud Code Assist request. The native
61
+ * client is Go `net/http`, which offers `Accept-Encoding: gzip` and no `Accept`;
62
+ * pinning the encoding replaces the runtime's `gzip, deflate, br, zstd` (Bun
63
+ * still decompresses the gzip body). Bun always adds `Accept: *\/*` itself, so
64
+ * callers must not set a more specific `Accept`.
65
+ */
66
+ export declare function getAntigravityHeaders(userAgent?: string): {
67
+ "User-Agent": string;
68
+ "Accept-Encoding": string;
69
+ };
70
+ /**
71
+ * Offline fallback for {@link Model.antigravityWireProfiles}: per-SKU request
72
+ * constants for rows that carry no discovered profile. Keyed by the routed
73
+ * upstream wire id (post effort-routing), not the collapsed logical id.
74
+ * `modelEnum` is the opaque `labels.model_enum` token; the backend accepts
75
+ * requests without it. Discovery (and the bundled snapshot baked from it)
76
+ * owns current SKUs; do not extend this table.
59
77
  */
60
- export interface AntigravityModelWireProfile {
61
- modelEnum?: string;
62
- maxOutputTokens: number;
63
- }
64
78
  export declare const ANTIGRAVITY_MODEL_WIRE_PROFILES: Readonly<Record<string, AntigravityModelWireProfile>>;
65
- export declare function getAntigravityModelWireProfile(wireModelId: string): AntigravityModelWireProfile | undefined;
79
+ /**
80
+ * Request constants for `wireModelId`: the first discovered profile map that
81
+ * lists it (callers pass the serving account's before the row's), else the
82
+ * offline fallback table.
83
+ */
84
+ export declare function getAntigravityModelWireProfile(wireModelId: string, ...discovered: (Readonly<Record<string, AntigravityModelWireProfile>> | undefined)[]): AntigravityModelWireProfile | undefined;
@@ -0,0 +1,2 @@
1
+ /** Identifies Xiaomi Token Plan keys so login and discovery use regional hosts instead of the pay-as-you-go host. */
2
+ export declare function isXiaomiTokenPlanKey(apiKey: string): boolean;