@linxiraos/pi-catalog 1.4.6 → 1.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/CHANGELOG.md +6 -2
  2. package/README.md +3 -3
  3. package/dist/types/build.d.ts +12 -4
  4. package/dist/types/compat/auth-ids.d.ts +2 -2
  5. package/dist/types/compat/catalog-policy.d.ts +6 -4
  6. package/dist/types/compat/factory-droid.d.ts +7 -1
  7. package/dist/types/compat/provider-ids.d.ts +1 -1
  8. package/dist/types/compat/resolve.d.ts +1 -1
  9. package/dist/types/compat/revision.d.ts +2 -0
  10. package/dist/types/compat/server-side-fallback.d.ts +6 -4
  11. package/dist/types/compat/types.d.ts +6 -2
  12. package/dist/types/discovery/codex.d.ts +4 -5
  13. package/dist/types/discovery/cursor-proto.d.ts +8 -0
  14. package/dist/types/discovery/openai-compatible.d.ts +6 -0
  15. package/dist/types/model-cache.d.ts +8 -0
  16. package/dist/types/model-catalog-format.d.ts +37 -0
  17. package/dist/types/model-manager.d.ts +11 -1
  18. package/dist/types/model-thinking.d.ts +4 -0
  19. package/dist/types/models.d.ts +22 -3
  20. package/dist/types/pricing.d.ts +66 -6
  21. package/dist/types/provider-models/openai-compat.d.ts +18 -13
  22. package/dist/types/types.d.ts +14 -19
  23. package/dist/types/utils.d.ts +8 -0
  24. package/dist/types/wire/codex.d.ts +1 -1
  25. package/package.json +6 -10
  26. package/src/build.d.ts +12 -4
  27. package/src/build.ts +50 -3
  28. package/src/compat/auth-ids.ts +5 -0
  29. package/src/compat/axes.ts +27 -9
  30. package/src/compat/catalog-policy.d.ts +9 -0
  31. package/src/compat/catalog-policy.ts +14 -10
  32. package/src/compat/collapse.ts +1 -1
  33. package/src/compat/factory-droid.d.ts +7 -1
  34. package/src/compat/factory-droid.ts +9 -1
  35. package/src/compat/provider-ids.d.ts +1 -1
  36. package/src/compat/provider-ids.ts +2 -0
  37. package/src/compat/resolve.d.ts +1 -1
  38. package/src/compat/resolve.ts +4 -5
  39. package/src/compat/revision.d.ts +2 -0
  40. package/src/compat/revision.ts +10 -0
  41. package/src/compat/rules/README.md +14 -12
  42. package/src/compat/rules/auth/_order.kdl +1 -1
  43. package/src/compat/rules/auth/mistral.kdl +4 -0
  44. package/src/compat/rules/auth/modular.kdl +9 -0
  45. package/src/compat/rules/auth/scaleway.kdl +17 -0
  46. package/src/compat/rules/auth/typesafe.kdl +2 -1
  47. package/src/compat/rules/classes/anthropic.kdl +5 -0
  48. package/src/compat/rules/classes/deepseek.kdl +3 -2
  49. package/src/compat/rules/classes/gemini.kdl +1 -1
  50. package/src/compat/rules/classes/openai.kdl +2 -2
  51. package/src/compat/rules/classes/xai.kdl +1 -1
  52. package/src/compat/rules/providers/anthropic.kdl +8 -4
  53. package/src/compat/rules/providers/cursor.kdl +10 -0
  54. package/src/compat/rules/providers/deepseek.kdl +2 -2
  55. package/src/compat/rules/providers/factory-droid.kdl +243 -13
  56. package/src/compat/rules/providers/google-vertex.kdl +3 -0
  57. package/src/compat/rules/providers/kimi-code.kdl +6 -0
  58. package/src/compat/rules/providers/mistral.kdl +8 -0
  59. package/src/compat/rules/providers/modular.kdl +35 -0
  60. package/src/compat/rules/providers/openai-codex.kdl +1 -1
  61. package/src/compat/rules/providers/sambanova.kdl +2 -0
  62. package/src/compat/rules/providers/scaleway.kdl +179 -0
  63. package/src/compat/rules/runtime/behavior.kdl +22 -6
  64. package/src/compat/rules.json +1 -1
  65. package/src/compat/server-side-fallback.d.ts +9 -0
  66. package/src/compat/server-side-fallback.ts +7 -5
  67. package/src/compat/types.d.ts +6 -2
  68. package/src/compat/types.ts +6 -2
  69. package/src/discovery/codex.d.ts +4 -5
  70. package/src/discovery/codex.ts +7 -15
  71. package/src/discovery/cursor-proto.d.ts +8 -0
  72. package/src/discovery/cursor-proto.ts +12 -1
  73. package/src/discovery/factory-droid.ts +35 -11
  74. package/src/discovery/openai-compatible.d.ts +6 -0
  75. package/src/discovery/openai-compatible.ts +1 -1
  76. package/src/model-cache.d.ts +8 -0
  77. package/src/model-cache.ts +83 -61
  78. package/src/model-catalog-format.d.ts +37 -0
  79. package/src/model-catalog-format.ts +296 -0
  80. package/src/model-manager.d.ts +11 -1
  81. package/src/model-manager.ts +85 -143
  82. package/src/model-thinking.d.ts +4 -0
  83. package/src/model-thinking.ts +10 -0
  84. package/src/model-tokenizer.ts +13 -12
  85. package/src/models.d.ts +22 -3
  86. package/src/models.json +1 -1
  87. package/src/models.ts +48 -11
  88. package/src/pricing.d.ts +66 -6
  89. package/src/pricing.ts +59 -94
  90. package/src/provider-models/cache-provider-id.ts +23 -6
  91. package/src/provider-models/catalog-snapshot.json.zst +0 -0
  92. package/src/provider-models/catalog-snapshot.json.zst.d.ts +3 -0
  93. package/src/provider-models/descriptors.ts +2 -0
  94. package/src/provider-models/openai-compat.d.ts +18 -13
  95. package/src/provider-models/openai-compat.ts +203 -94
  96. package/src/provider-models/special.ts +5 -6
  97. package/src/types.d.ts +14 -19
  98. package/src/types.ts +11 -18
  99. package/src/utils.d.ts +8 -0
  100. package/src/utils.ts +18 -0
  101. package/src/wire/codex.d.ts +1 -1
  102. package/src/wire/codex.ts +1 -1
  103. package/src/wire/factory-droid.ts +4 -3
  104. package/src/models.json.d.ts +0 -9
package/CHANGELOG.md CHANGED
@@ -1,8 +1,12 @@
1
1
  ## [Unreleased]
2
2
 
3
- ## [1.4.6] - 2026-10-28
3
+ ## [1.4.9] - 2026-11-03
4
4
 
5
- - Released as part of Zeta 1.4.6; no package-specific user-visible changes.
5
+ - Synced with upstream OMP v18.16.0: Scaleway provider, Factory Droid 1.1.0 models, and Mistral Vibe browser login.
6
+
7
+ ## [1.4.7] - 2026-10-30
8
+
9
+ - Synced with upstream OMP v18.14.0; no package-specific user-visible changes.
6
10
 
7
11
  ## [1.4.5] - 2026-10-28
8
12
 
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>;
@@ -1,4 +1,4 @@
1
1
  /** Every provider with an `auth/<id>.kdl` policy. */
2
- export type AuthProviderId = "abliteration" | "aiand" | "aimlapi" | "alibaba-coding-plan" | "alibaba-token-plan" | "amazon-bedrock" | "anthropic" | "apple" | "azure" | "baseten" | "bedrock-mantle" | "cerebras" | "charm-hyper" | "cline-pass" | "cloudflare-ai-gateway" | "cloudflare-workers-ai" | "commandcode" | "coralbricks" | "coreweave" | "cursor" | "deepinfra" | "deepseek" | "devin" | "exa" | "factory-droid" | "firepass" | "fireworks" | "github-copilot" | "gitlab-duo" | "gitlab-duo-agent" | "gmi-cloud" | "google" | "google-antigravity" | "google-gemini-cli" | "google-vertex" | "groq" | "helmcode" | "huggingface" | "inception" | "kagi" | "kilo" | "kimi-code" | "litellm" | "llama.cpp" | "lm-studio" | "local" | "meta" | "minimax" | "minimax-code" | "minimax-code-cn" | "mistral" | "moonshot" | "muse-code" | "nanogpt" | "novita" | "nvidia" | "ollama" | "ollama-cloud" | "openai" | "openai-codex" | "openai-codex-device" | "opencode-go" | "opencode-zen" | "openrouter" | "parallel" | "perplexity" | "qianfan" | "qwen-portal" | "sakana" | "sambanova" | "siliconflow" | "siliconflow-cn" | "singularityapi-dev" | "singularityapi-tech" | "snowflake" | "stencil" | "stepfun" | "synthetic" | "tavily" | "together" | "typesafe" | "umans" | "venice" | "vercel-ai-gateway" | "vllm" | "wafer-serverless" | "web" | "xai" | "xai-oauth" | "xiaomi" | "xiaomi-token-plan-ams" | "xiaomi-token-plan-cn" | "xiaomi-token-plan-sgp" | "yolo-auto" | "zai" | "zai-coding-plan" | "zenmux" | "zhipu-coding-plan";
2
+ export type AuthProviderId = "abliteration" | "aiand" | "aimlapi" | "alibaba-coding-plan" | "alibaba-token-plan" | "amazon-bedrock" | "anthropic" | "apple" | "azure" | "baseten" | "bedrock-mantle" | "cerebras" | "charm-hyper" | "cline-pass" | "cloudflare-ai-gateway" | "cloudflare-workers-ai" | "commandcode" | "coralbricks" | "coreweave" | "cursor" | "deepinfra" | "deepseek" | "devin" | "exa" | "factory-droid" | "firepass" | "fireworks" | "github-copilot" | "gitlab-duo" | "gitlab-duo-agent" | "gmi-cloud" | "google" | "google-antigravity" | "google-gemini-cli" | "google-vertex" | "groq" | "helmcode" | "huggingface" | "inception" | "kagi" | "kilo" | "kimi-code" | "litellm" | "llama.cpp" | "lm-studio" | "local" | "meta" | "minimax" | "minimax-code" | "minimax-code-cn" | "mistral" | "modular" | "moonshot" | "muse-code" | "nanogpt" | "novita" | "nvidia" | "ollama" | "ollama-cloud" | "openai" | "openai-codex" | "openai-codex-device" | "opencode-go" | "opencode-zen" | "openrouter" | "parallel" | "perplexity" | "qianfan" | "qwen-portal" | "sakana" | "sambanova" | "scaleway" | "siliconflow" | "siliconflow-cn" | "singularityapi-dev" | "singularityapi-tech" | "snowflake" | "stencil" | "stepfun" | "synthetic" | "tavily" | "together" | "typesafe" | "umans" | "venice" | "vercel-ai-gateway" | "vllm" | "wafer-serverless" | "web" | "xai" | "xai-oauth" | "xiaomi" | "xiaomi-token-plan-ams" | "xiaomi-token-plan-cn" | "xiaomi-token-plan-sgp" | "yolo-auto" | "zai" | "zai-coding-plan" | "zenmux" | "zhipu-coding-plan";
3
3
  /** Providers whose policy declares a `login` flow (the `/login` roster). */
4
- export type LoginProviderId = "abliteration" | "aiand" | "alibaba-coding-plan" | "alibaba-token-plan" | "anthropic" | "baseten" | "cerebras" | "charm-hyper" | "cline-pass" | "cloudflare-ai-gateway" | "cloudflare-workers-ai" | "commandcode" | "coralbricks" | "coreweave" | "cursor" | "deepinfra" | "deepseek" | "devin" | "exa" | "factory-droid" | "firepass" | "fireworks" | "github-copilot" | "gitlab-duo" | "gitlab-duo-agent" | "gmi-cloud" | "google-antigravity" | "google-gemini-cli" | "helmcode" | "huggingface" | "inception" | "kagi" | "kilo" | "kimi-code" | "litellm" | "llama.cpp" | "lm-studio" | "meta" | "minimax-code" | "minimax-code-cn" | "moonshot" | "muse-code" | "nanogpt" | "novita" | "nvidia" | "ollama" | "ollama-cloud" | "openai-codex" | "openai-codex-device" | "opencode-go" | "opencode-zen" | "openrouter" | "parallel" | "perplexity" | "qianfan" | "qwen-portal" | "sakana" | "sambanova" | "siliconflow" | "siliconflow-cn" | "singularityapi-dev" | "singularityapi-tech" | "snowflake" | "stencil" | "stepfun" | "synthetic" | "tavily" | "together" | "typesafe" | "umans" | "venice" | "vercel-ai-gateway" | "vllm" | "wafer-serverless" | "xai" | "xai-oauth" | "xiaomi" | "xiaomi-token-plan-ams" | "xiaomi-token-plan-cn" | "xiaomi-token-plan-sgp" | "yolo-auto" | "zai" | "zai-coding-plan" | "zenmux" | "zhipu-coding-plan";
4
+ export type LoginProviderId = "abliteration" | "aiand" | "alibaba-coding-plan" | "alibaba-token-plan" | "anthropic" | "baseten" | "cerebras" | "charm-hyper" | "cline-pass" | "cloudflare-ai-gateway" | "cloudflare-workers-ai" | "commandcode" | "coralbricks" | "coreweave" | "cursor" | "deepinfra" | "deepseek" | "devin" | "exa" | "factory-droid" | "firepass" | "fireworks" | "github-copilot" | "gitlab-duo" | "gitlab-duo-agent" | "gmi-cloud" | "google-antigravity" | "google-gemini-cli" | "helmcode" | "huggingface" | "inception" | "kagi" | "kilo" | "kimi-code" | "litellm" | "llama.cpp" | "lm-studio" | "meta" | "minimax-code" | "minimax-code-cn" | "mistral" | "modular" | "moonshot" | "muse-code" | "nanogpt" | "novita" | "nvidia" | "ollama" | "ollama-cloud" | "openai-codex" | "openai-codex-device" | "opencode-go" | "opencode-zen" | "openrouter" | "parallel" | "perplexity" | "qianfan" | "qwen-portal" | "sakana" | "sambanova" | "scaleway" | "siliconflow" | "siliconflow-cn" | "singularityapi-dev" | "singularityapi-tech" | "snowflake" | "stencil" | "stepfun" | "synthetic" | "tavily" | "together" | "typesafe" | "umans" | "venice" | "vercel-ai-gateway" | "vllm" | "wafer-serverless" | "xai" | "xai-oauth" | "xiaomi" | "xiaomi-token-plan-ams" | "xiaomi-token-plan-cn" | "xiaomi-token-plan-sgp" | "yolo-auto" | "zai" | "zai-coding-plan" | "zenmux" | "zhipu-coding-plan";
@@ -1,7 +1,9 @@
1
1
  import type { CatalogPolicyInputs } from "../types.js";
2
+ import { type ResolveRoute } from "./resolve.js";
2
3
  /**
3
- * The `catalog` axis bag authored in the KDL cascade rules for a model,
4
- * memoized per distinct model. Frozen: the bag is shared across callers, so it
5
- * must stay read-only — extract the value you need rather than handing it on.
4
+ * The `catalog` axis bag authored in the KDL cascade rules for a model (on one
5
+ * upstream when `route` names it), memoized per distinct model. Frozen: the bag
6
+ * is shared across callers, so it must stay read-only — extract the value you
7
+ * need rather than handing it on.
6
8
  */
7
- export declare function resolveCatalogPolicy(model: CatalogPolicyInputs): Readonly<Record<string, unknown>>;
9
+ export declare function resolveCatalogPolicy(model: CatalogPolicyInputs, route?: ResolveRoute): Readonly<Record<string, unknown>>;
@@ -1,3 +1,4 @@
1
+ import { type DatedCostCard } from "../pricing.js";
1
2
  import type { Api, ModelSpec } from "../types.js";
2
3
  import { type FactoryDroidRegion, type FactoryDroidWire } from "../wire/factory-droid.js";
3
4
  /** Native token limits for one inference region. */
@@ -5,11 +6,16 @@ export interface FactoryDroidLimits {
5
6
  contextWindow: number | null;
6
7
  maxTokens: number | null;
7
8
  }
8
- /** Standard Credits rates: `input` is the per-token weight; `output` and `cacheRead` multiply it. */
9
+ /**
10
+ * Standard Credits rates: `input` is the per-token weight; `output` and
11
+ * `cacheRead` multiply it. `effectiveRates` are dated cards (ascending) that
12
+ * overwrite those legs from their date, as on `cost-patch`.
13
+ */
9
14
  export interface FactoryDroidCreditRates {
10
15
  input: number;
11
16
  output?: number;
12
17
  cacheRead?: number;
18
+ effectiveRates?: readonly DatedCostCard[];
13
19
  }
14
20
  /** Account gates on one registry model (the `entitlement` axis). */
15
21
  export interface FactoryDroidEntitlement {
@@ -1,2 +1,2 @@
1
1
  /** Every chat-model provider with a catalog entry (`default-model` in its provider rules). */
2
- export type KnownProvider = "abliteration" | "aiand" | "aimlapi" | "alibaba-coding-plan" | "alibaba-token-plan" | "amazon-bedrock" | "anthropic" | "apple" | "azure" | "baseten" | "bedrock-mantle" | "cerebras" | "charm-hyper" | "cline-pass" | "cloudflare-ai-gateway" | "cloudflare-workers-ai" | "commandcode" | "coralbricks" | "coreweave" | "cursor" | "deepinfra" | "deepseek" | "devin" | "factory-droid" | "firepass" | "fireworks" | "github-copilot" | "gitlab-duo" | "gitlab-duo-agent" | "gmi-cloud" | "google" | "google-antigravity" | "google-gemini-cli" | "google-vertex" | "groq" | "helmcode" | "huggingface" | "inception" | "kilo" | "kimi-code" | "litellm" | "lm-studio" | "local" | "meta" | "minimax" | "minimax-code" | "minimax-code-cn" | "mistral" | "moonshot" | "muse-code" | "nanogpt" | "novita" | "nvidia" | "ollama" | "ollama-cloud" | "openai" | "openai-codex" | "opencode-go" | "opencode-zen" | "openrouter" | "qianfan" | "qwen-portal" | "sakana" | "sambanova" | "siliconflow" | "siliconflow-cn" | "singularityapi-dev" | "singularityapi-tech" | "snowflake" | "stepfun" | "synthetic" | "together" | "typesafe" | "umans" | "venice" | "vercel-ai-gateway" | "vllm" | "wafer-serverless" | "web" | "xai" | "xai-oauth" | "xiaomi" | "xiaomi-token-plan-ams" | "xiaomi-token-plan-cn" | "xiaomi-token-plan-sgp" | "yolo-auto" | "zai" | "zenmux" | "zhipu-coding-plan";
2
+ export type KnownProvider = "abliteration" | "aiand" | "aimlapi" | "alibaba-coding-plan" | "alibaba-token-plan" | "amazon-bedrock" | "anthropic" | "apple" | "azure" | "baseten" | "bedrock-mantle" | "cerebras" | "charm-hyper" | "cline-pass" | "cloudflare-ai-gateway" | "cloudflare-workers-ai" | "commandcode" | "coralbricks" | "coreweave" | "cursor" | "deepinfra" | "deepseek" | "devin" | "factory-droid" | "firepass" | "fireworks" | "github-copilot" | "gitlab-duo" | "gitlab-duo-agent" | "gmi-cloud" | "google" | "google-antigravity" | "google-gemini-cli" | "google-vertex" | "groq" | "helmcode" | "huggingface" | "inception" | "kilo" | "kimi-code" | "litellm" | "lm-studio" | "local" | "meta" | "minimax" | "minimax-code" | "minimax-code-cn" | "mistral" | "modular" | "moonshot" | "muse-code" | "nanogpt" | "novita" | "nvidia" | "ollama" | "ollama-cloud" | "openai" | "openai-codex" | "opencode-go" | "opencode-zen" | "openrouter" | "qianfan" | "qwen-portal" | "sakana" | "sambanova" | "scaleway" | "siliconflow" | "siliconflow-cn" | "singularityapi-dev" | "singularityapi-tech" | "snowflake" | "stepfun" | "synthetic" | "together" | "typesafe" | "umans" | "venice" | "vercel-ai-gateway" | "vllm" | "wafer-serverless" | "web" | "xai" | "xai-oauth" | "xiaomi" | "xiaomi-token-plan-ams" | "xiaomi-token-plan-cn" | "xiaomi-token-plan-sgp" | "yolo-auto" | "zai" | "zenmux" | "zhipu-coding-plan";
@@ -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: CatalogPolicyInputs): Record<string, unknown>;
24
+ export declare function resolveCatalogAxes(spec: CatalogPolicyInputs, route?: ResolveRoute): 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.
@@ -22,6 +22,8 @@ export declare function parseRevision(value: string): Revision | undefined;
22
22
  export declare function parseRevisionPrefix(value: string): Revision | undefined;
23
23
  /** Lexicographic triple comparison: negative, zero, or positive. */
24
24
  export declare function compareRevision(a: Revision, b: Revision): number;
25
+ /** Whether a revision string parses and is at or above `floor`; `undefined` or unparsable is never. */
26
+ export declare function revisionAtLeast(revision: string | undefined, floor: string): boolean;
25
27
  /** Renders a revision as its canonical `major.minor.patch` string. */
26
28
  export declare function formatRevision(revision: Revision): string;
27
29
  /** Comparison operator inside a `revision ">=2.5 <4"` cascade constraint. */
@@ -1,7 +1,9 @@
1
- import type { Model } from "../types.js";
1
+ import type { CatalogPolicyInputs } from "../types.js";
2
+ import type { ResolveRoute } from "./resolve.js";
2
3
  /**
3
4
  * Ordered model ids for Anthropic's server-side refusal `fallbacks` chain,
4
- * authored on the `server-side-fallback-models` catalog axis. Empty when no
5
- * rule assigns a chain (the model or host does not support the feature).
5
+ * authored on the `server-side-fallback-models` catalog axis, on `route`'s
6
+ * upstream when it names one. Empty when no rule assigns a chain (the model,
7
+ * host or upstream does not support the feature).
6
8
  */
7
- export declare function serverSideFallbackModels(model: Model): readonly string[];
9
+ export declare function serverSideFallbackModels(model: CatalogPolicyInputs, route?: ResolveRoute): readonly string[];
@@ -369,8 +369,10 @@ export type CompiledAuthValidation = {
369
369
  kind: "models-endpoint";
370
370
  label?: string;
371
371
  url: string;
372
- /** 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. */
373
373
  baseUrlEnv?: string;
374
+ /** Path appended to the `baseUrlEnv` value (default `/models`), for bases that exclude the API version. */
375
+ baseUrlPath?: string;
374
376
  /** Hook returning extra request headers (may throw a configuration error). */
375
377
  headersHook?: string;
376
378
  optional?: boolean;
@@ -712,6 +714,8 @@ export interface ResolvedAxes {
712
714
  export interface RequestPolicy {
713
715
  completionsReasoningMode?: "none" | "effort" | "opt-in" | "forced-on";
714
716
  completionsReasoningHistory?: "omit" | "preserved" | "interleaved";
717
+ /** Send `allow_missing_thinking` with the effort so tool-call turns may arrive without reasoning. */
718
+ completionsAllowMissingThinking?: boolean;
715
719
  anthropicThinking?: "adaptive" | "adaptive-summarized" | "budget-interleaved" | "budget-effort";
716
720
  /** Advertise `fine-grained-tool-streaming-2025-05-14` on requests that carry tools. */
717
721
  anthropicToolStreamingBeta?: boolean;
@@ -719,7 +723,7 @@ export interface RequestPolicy {
719
723
  openaiPlatformHeader?: string;
720
724
  responsesCacheRetention?: boolean;
721
725
  responsesVerbosity?: "low";
722
- responsesServiceTier?: "priority";
726
+ responsesServiceTier?: "priority" | "ultrafast";
723
727
  responsesParallelToolCalls?: boolean;
724
728
  responsesSafetyIdentifier?: boolean;
725
729
  /** Default `tool_choice` to `auto` when the request carries tools and the caller picks none. */
@@ -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.
@@ -2514,6 +2514,9 @@ export interface InteractionUpdate extends ProtoMessage {
2514
2514
  } | {
2515
2515
  case: "stepCompleted";
2516
2516
  value: StepCompletedUpdate;
2517
+ } | {
2518
+ case: "toolRequestsListed";
2519
+ value: ToolRequestsListedUpdate;
2517
2520
  };
2518
2521
  }
2519
2522
  export declare const InteractionUpdateSchema: MessageCodec<InteractionUpdate>;
@@ -5318,6 +5321,11 @@ export interface ToolCallStartedUpdate extends ProtoMessage {
5318
5321
  modelCallId: string;
5319
5322
  }
5320
5323
  export declare const ToolCallStartedUpdateSchema: MessageCodec<ToolCallStartedUpdate>;
5324
+ /** Cursor agent message agent.v1.ToolRequestsListedUpdate. */
5325
+ export interface ToolRequestsListedUpdate extends ProtoMessage {
5326
+ callCount: number;
5327
+ }
5328
+ export declare const ToolRequestsListedUpdateSchema: MessageCodec<ToolRequestsListedUpdate>;
5321
5329
  /** Cursor agent message agent.v1.TruncatedToolCall. */
5322
5330
  export interface TruncatedToolCall extends ProtoMessage {
5323
5331
  originalStepBlobId: Uint8Array;
@@ -10,6 +10,12 @@ import type { Api, FetchImpl, ModelSpec, Provider } from "../types.js";
10
10
  * (issue #8315). 10s matches the coding-agent's remote-discovery budget.
11
11
  */
12
12
  export declare const DEFAULT_OPENAI_COMPATIBLE_DISCOVERY_TIMEOUT_MS = 10000;
13
+ /**
14
+ * Uses a cancellable timer rather than the native abort-timeout helper so
15
+ * successful fast discovery requests do not leave armed timeout signals for
16
+ * concurrent GC to trip over later.
17
+ */
18
+ export declare function withOpenAICompatibleDiscoveryTimeout<T>(timeoutMs: number, run: (signal: AbortSignal) => Promise<T>): Promise<T>;
13
19
  /**
14
20
  * Minimal OpenAI-style model entry shape consumed by discovery.
15
21
  *
@@ -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 {};
@@ -129,9 +129,19 @@ export declare function createModelManager<TApi extends Api = Api, TModelsDevPay
129
129
  * when at least one configured remote source did not refresh successfully.
130
130
  */
131
131
  export declare function resolveProviderModels<TApi extends Api = Api, TModelsDevPayload = unknown>(options: ModelManagerOptions<TApi, TModelsDevPayload>, strategy?: ModelRefreshStrategy): Promise<ModelResolutionResult<TApi>>;
132
+ /**
133
+ * Merge policy that is part of a cache's identity in
134
+ * {@link fingerprintStaticModels}: `authoritative` when dynamic discovery owns
135
+ * the catalog, `additive` when the shared catalog may only add ids. The flags
136
+ * compose; snapshots written under different policies never match.
137
+ */
138
+ export interface StaticFingerprintPolicy {
139
+ authoritative?: boolean;
140
+ additive?: boolean;
141
+ }
132
142
  /**
133
143
  * Return the versioned content identity for a static provider slice. Callers
134
144
  * may mutate or freeze their arrays, so every call observes current content
135
145
  * and never attaches a stale sidecar fingerprint to caller-owned data.
136
146
  */
137
- export declare function fingerprintStaticModels<TApi extends Api>(models: readonly (ModelSpec<TApi> | Model<TApi>)[], dynamicModelsAuthoritative?: boolean): string;
147
+ export declare function fingerprintStaticModels<TApi extends Api>(models: readonly (ModelSpec<TApi> | Model<TApi>)[], policy?: StaticFingerprintPolicy): string;
@@ -32,6 +32,10 @@ export declare function withoutUnverifiedThinking<T extends {
32
32
  /**
33
33
  * Clamps a requested thinking level against explicit model metadata.
34
34
  *
35
+ * An unserved level first follows `thinking.effortMap` when the map sends it to
36
+ * a served tier that reaches the wire unchanged (a gateway answering `medium`
37
+ * as `high`); otherwise it climbs down to the nearest lower tier.
38
+ *
35
39
  * Non-reasoning models always resolve to `undefined`.
36
40
  */
37
41
  export declare function clampThinkingLevelForModel<TApi extends Api>(model: ApiModel<TApi> | undefined, requested: Effort | undefined): Effort | undefined;
@@ -1,13 +1,32 @@
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;
14
+ /** Factory Droid credit rate in force at a time, and the next dated change to it. */
15
+ export interface FactoryDroidCreditRate {
16
+ rate: number;
17
+ /** The earliest later `credit-rates` card that changes `rate`: the rate it sets and when (Unix ms). */
18
+ next?: {
19
+ rate: number;
20
+ at: number;
21
+ };
22
+ }
23
+ /**
24
+ * Factory Droid Standard Credits rate at `timestamp` (Unix ms, default now):
25
+ * the `input` of the `credit-rates` card due then (the latest at or before
26
+ * it, as for cost cards), else the base rate. Undefined for models without a
27
+ * credit rate.
28
+ */
29
+ export declare function getFactoryDroidCreditRate(model: Pick<Model, "factoryDroidCredits" | "factoryDroidCreditCards">, timestamp?: number): FactoryDroidCreditRate | undefined;
11
30
  /**
12
31
  * The base token card in force at `timestamp` (Unix ms, default now): the
13
32
  * latest due `timeBased` effective rate, else the row's own legs. Price
@@ -1,24 +1,84 @@
1
1
  import type { EffectiveTokenCost, ModelCost, TimeBasedCost, TokenCost } from "./types.js";
2
+ /** Serialized time-based pricing schedule, as cached model rows carry it. */
3
+ export declare const TimeBasedCostShape: import("@linxiraos/pi-omptype").FluentType<{
4
+ effectiveRates?: ({
5
+ cacheRead: number;
6
+ cacheWrite: number;
7
+ input: number;
8
+ output: number;
9
+ } & {
10
+ effectiveFrom: number;
11
+ longContext?: ({
12
+ cacheRead: number;
13
+ cacheWrite: number;
14
+ input: number;
15
+ output: number;
16
+ } & {
17
+ inputThreshold: number;
18
+ inputThresholdInclusive?: boolean | undefined;
19
+ }) | undefined;
20
+ })[] | undefined;
21
+ offPeakMultiplier: number;
22
+ peakWindows: {
23
+ endMinute: number;
24
+ startMinute: number;
25
+ weekdays: number[];
26
+ }[];
27
+ }, {
28
+ effectiveRates?: ({
29
+ cacheRead: number;
30
+ cacheWrite: number;
31
+ input: number;
32
+ output: number;
33
+ } & {
34
+ effectiveFrom: number;
35
+ longContext?: ({
36
+ cacheRead: number;
37
+ cacheWrite: number;
38
+ input: number;
39
+ output: number;
40
+ } & {
41
+ inputThreshold: number;
42
+ inputThresholdInclusive?: boolean | undefined;
43
+ }) | undefined;
44
+ })[] | undefined;
45
+ offPeakMultiplier: number;
46
+ peakWindows: {
47
+ endMinute: number;
48
+ startMinute: number;
49
+ weekdays: number[];
50
+ }[];
51
+ }>;
2
52
  /** Validate serialized schedules before admitting cached model rows. */
3
53
  export declare function isTimeBasedCost(value: unknown): value is TimeBasedCost;
4
54
  /** KDL object children are named records; normalize them once while constructing the model. */
5
55
  export declare function materializeTimeBasedCost(value: unknown): TimeBasedCost;
56
+ /**
57
+ * The dated card due at `timestamp`: the one with the latest `effectiveFrom`
58
+ * at or before it, in any order, or undefined before the first card.
59
+ */
60
+ export declare function dueDatedCard<T extends {
61
+ effectiveFrom: number;
62
+ }>(cards: readonly T[], timestamp: number): T | undefined;
6
63
  /**
7
64
  * The latest `effectiveRates` card of a materialized schedule due at
8
65
  * `timestamp`, or undefined before the first one (or without a schedule).
9
66
  */
10
67
  export declare function dueEffectiveRate(schedule: TimeBasedCost | undefined, timestamp: number): EffectiveTokenCost | undefined;
11
- /** A `cost-patch`/`cost-fallback` dated card: the legs it overwrites from `effectiveFrom` (Unix ms). */
68
+ /**
69
+ * A dated `effective-rates` card of a `cost-patch`, `cost-fallback` or
70
+ * `credit-rates` rule: the legs it overwrites from `effectiveFrom` (Unix ms).
71
+ */
12
72
  export interface DatedCostCard extends Partial<TokenCost> {
13
73
  effectiveFrom: number;
14
74
  }
15
75
  /**
16
- * Parse the compiled `effective-rates` block of a `cost-patch` or
17
- * `cost-fallback` payload into dated cards, ascending by date. Throws on a
18
- * malformed card, so a typo in a rule fails the build instead of silently
19
- * leaving the old price in force.
76
+ * Parse the compiled `effective-rates` block of a `cost-patch`,
77
+ * `cost-fallback` or Factory Droid `credit-rates` payload into dated cards,
78
+ * ascending by date. Throws on a malformed card, so a typo in a rule fails the
79
+ * build instead of silently leaving the old price in force.
20
80
  */
21
- export declare function parseDatedCostCards(costAxis: unknown, axis: "cost-patch" | "cost-fallback"): DatedCostCard[];
81
+ export declare function parseDatedCostCards(costAxis: unknown, axis: "cost-patch" | "cost-fallback" | "credit-rates"): DatedCostCard[];
22
82
  /**
23
83
  * Earliest instant a rate card can name (the `Date` range minimum). A leading
24
84
  * card from here holds the price in force before the first dated change.
@@ -36,19 +36,6 @@ export interface ModelsDevModel {
36
36
  int?: number;
37
37
  tps?: number;
38
38
  }
39
- /**
40
- * Fetches the models.dev catalog via catalog.stencil.so, which serves a
41
- * field-pruned copy precompressed as a zstd blob (~93 KB vs ~3.3 MB raw).
42
- * The frame magic is sniffed rather than trusting content-type so plain-JSON
43
- * responses (test stubs, fallback mirrors) parse identically.
44
- *
45
- * Fetched fully once per fetch context: concurrent callers sharing a fetch
46
- * implementation reuse one transport request, while repeat callers send a
47
- * conditional GET that the server answers with `304`. Each subscriber may stop
48
- * waiting independently; the shared transport retains its own hard deadline.
49
- * Transient failures reuse the last in-memory payload for callers that only
50
- * need best-effort metadata.
51
- */
52
39
  export declare function fetchWellKnownModels(fetchImpl?: FetchImpl, signal?: AbortSignal): Promise<unknown>;
53
40
  type SimpleProviderDiscoveryHeaders = Record<string, string> | (() => Record<string, string> | undefined);
54
41
  type SimpleProviderConfig = {
@@ -740,3 +727,21 @@ export declare function singularityApiDevModelManagerOptions(config?: Singularit
740
727
  * reviewed KDL rules own the wire shape, limits patch, and effort ladder.
741
728
  */
742
729
  export declare function singularityApiTechModelManagerOptions(config?: SingularityApiModelManagerConfig): ModelManagerOptions<Api>;
730
+ /**
731
+ * Scaleway discovery configuration: the API key plus optional base-URL and
732
+ * fetch overrides. Consumed by {@link scalewayModelManagerOptions}, and
733
+ * exported for extensions and tests that construct the manager directly.
734
+ */
735
+ export interface ScalewayModelManagerConfig {
736
+ apiKey?: string;
737
+ baseUrl?: string;
738
+ fetch?: FetchImpl;
739
+ }
740
+ /**
741
+ * Scaleway model manager: plain OpenAI-compatible chat completions at
742
+ * `api.scaleway.ai/v1` (fr-par serverless Generative APIs). `/v1/models`
743
+ * returns bare ids, so the authored seed in `providers/scaleway.kdl` is the
744
+ * reference each live row merges names, modalities, prices, and limits from;
745
+ * a successful fetch is the complete roster and prunes retired rows.
746
+ */
747
+ export declare function scalewayModelManagerOptions(config?: ScalewayModelManagerConfig): ModelManagerOptions<"openai-completions">;