@linxiraos/pi-catalog 1.4.7 → 1.4.10

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 (83) hide show
  1. package/CHANGELOG.md +6 -21
  2. package/dist/types/compat/auth-ids.d.ts +2 -2
  3. package/dist/types/compat/catalog-policy.d.ts +6 -4
  4. package/dist/types/compat/factory-droid.d.ts +7 -1
  5. package/dist/types/compat/provider-ids.d.ts +1 -1
  6. package/dist/types/compat/resolve.d.ts +1 -1
  7. package/dist/types/compat/revision.d.ts +2 -0
  8. package/dist/types/compat/server-side-fallback.d.ts +6 -4
  9. package/dist/types/compat/types.d.ts +3 -1
  10. package/dist/types/discovery/cursor-proto.d.ts +8 -0
  11. package/dist/types/discovery/openai-compatible.d.ts +6 -0
  12. package/dist/types/model-manager.d.ts +11 -1
  13. package/dist/types/model-thinking.d.ts +4 -0
  14. package/dist/types/models.d.ts +16 -0
  15. package/dist/types/pricing.d.ts +66 -6
  16. package/dist/types/provider-models/openai-compat.d.ts +18 -13
  17. package/dist/types/types.d.ts +14 -19
  18. package/dist/types/utils.d.ts +8 -0
  19. package/package.json +4 -4
  20. package/src/compat/auth-ids.ts +5 -0
  21. package/src/compat/axes.ts +21 -9
  22. package/src/compat/catalog-policy.d.ts +9 -0
  23. package/src/compat/catalog-policy.ts +14 -10
  24. package/src/compat/collapse.ts +1 -1
  25. package/src/compat/factory-droid.d.ts +7 -1
  26. package/src/compat/factory-droid.ts +9 -1
  27. package/src/compat/provider-ids.d.ts +1 -1
  28. package/src/compat/provider-ids.ts +2 -0
  29. package/src/compat/resolve.d.ts +1 -1
  30. package/src/compat/resolve.ts +4 -5
  31. package/src/compat/revision.d.ts +2 -0
  32. package/src/compat/revision.ts +10 -0
  33. package/src/compat/rules/README.md +3 -1
  34. package/src/compat/rules/auth/_order.kdl +1 -1
  35. package/src/compat/rules/auth/mistral.kdl +4 -0
  36. package/src/compat/rules/auth/modular.kdl +9 -0
  37. package/src/compat/rules/auth/scaleway.kdl +17 -0
  38. package/src/compat/rules/classes/anthropic.kdl +5 -0
  39. package/src/compat/rules/classes/deepseek.kdl +1 -1
  40. package/src/compat/rules/classes/gemini.kdl +1 -1
  41. package/src/compat/rules/classes/xai.kdl +1 -1
  42. package/src/compat/rules/providers/anthropic.kdl +8 -4
  43. package/src/compat/rules/providers/cursor.kdl +10 -0
  44. package/src/compat/rules/providers/deepseek.kdl +2 -2
  45. package/src/compat/rules/providers/factory-droid.kdl +219 -13
  46. package/src/compat/rules/providers/modular.kdl +35 -0
  47. package/src/compat/rules/providers/openai-codex.kdl +1 -1
  48. package/src/compat/rules/providers/sambanova.kdl +2 -0
  49. package/src/compat/rules/providers/scaleway.kdl +179 -0
  50. package/src/compat/rules/runtime/behavior.kdl +13 -0
  51. package/src/compat/rules.json +1 -1
  52. package/src/compat/server-side-fallback.d.ts +9 -0
  53. package/src/compat/server-side-fallback.ts +7 -5
  54. package/src/compat/types.d.ts +3 -1
  55. package/src/compat/types.ts +3 -1
  56. package/src/discovery/codex.ts +2 -9
  57. package/src/discovery/cursor-proto.d.ts +8 -0
  58. package/src/discovery/cursor-proto.ts +12 -1
  59. package/src/discovery/factory-droid.ts +35 -11
  60. package/src/discovery/openai-compatible.d.ts +6 -0
  61. package/src/discovery/openai-compatible.ts +1 -1
  62. package/src/model-cache.ts +32 -58
  63. package/src/model-catalog-format.ts +5 -8
  64. package/src/model-manager.d.ts +11 -1
  65. package/src/model-manager.ts +85 -143
  66. package/src/model-thinking.d.ts +4 -0
  67. package/src/model-thinking.ts +10 -0
  68. package/src/model-tokenizer.ts +13 -12
  69. package/src/models.d.ts +16 -0
  70. package/src/models.json +1 -1
  71. package/src/models.ts +32 -1
  72. package/src/pricing.d.ts +66 -6
  73. package/src/pricing.ts +59 -94
  74. package/src/provider-models/catalog-snapshot.json.zst +0 -0
  75. package/src/provider-models/catalog-snapshot.json.zst.d.ts +3 -0
  76. package/src/provider-models/descriptors.ts +2 -0
  77. package/src/provider-models/openai-compat.d.ts +18 -13
  78. package/src/provider-models/openai-compat.ts +120 -71
  79. package/src/types.d.ts +14 -19
  80. package/src/types.ts +11 -18
  81. package/src/utils.d.ts +8 -0
  82. package/src/utils.ts +18 -0
  83. package/src/wire/factory-droid.ts +4 -3
@@ -109,6 +109,7 @@ export const AXES: Readonly<Record<string, AxisDef>> = {
109
109
  "preserved",
110
110
  "interleaved",
111
111
  ]),
112
+ "completions-allow-missing-thinking": wire("completionsAllowMissingThinking", ["request"]),
112
113
  "anthropic-thinking": wire("anthropicThinking", ["request"], "scalar", [
113
114
  "adaptive",
114
115
  "adaptive-summarized",
@@ -119,7 +120,7 @@ export const AXES: Readonly<Record<string, AxisDef>> = {
119
120
  "openai-platform-header": wire("openaiPlatformHeader", ["request"]),
120
121
  "responses-cache-retention": wire("responsesCacheRetention", ["request"]),
121
122
  "responses-verbosity": wire("responsesVerbosity", ["request"], "scalar", ["low"]),
122
- "responses-service-tier": wire("responsesServiceTier", ["request"], "scalar", ["priority"]),
123
+ "responses-service-tier": wire("responsesServiceTier", ["request"], "scalar", ["priority", "ultrafast"]),
123
124
  "responses-parallel-tool-calls": wire("responsesParallelToolCalls", ["request"]),
124
125
  "responses-safety-identifier": wire("responsesSafetyIdentifier", ["request"]),
125
126
  "responses-tool-choice-auto": wire("responsesToolChoiceAuto", ["request"]),
@@ -317,11 +318,6 @@ export const AXES: Readonly<Record<string, AxisDef>> = {
317
318
  "strip-image-input": wire("stripImageInput", [...OAI, "anthropic", "google"]),
318
319
  "supports-forced-tool-choice": wire("supportsForcedToolChoice", [...OAI, "anthropic", "bedrock"]),
319
320
  "supports-sampling-params": wire("supportsSamplingParams", [...OAI, "anthropic", "bedrock", "devin", "google"]),
320
- "thinking-loop-guard": wire("thinkingLoopGuard", [...OAI, "anthropic", "google"], "scalar", [
321
- "gemini",
322
- "deepseek",
323
- "xai",
324
- ]),
325
321
 
326
322
  // ── thinking control surface ──
327
323
  "thinking-default-level": { key: "defaultLevel", set: "thinking", shape: "scalar", values: EFFORTS },
@@ -456,6 +452,19 @@ export const AXES: Readonly<Record<string, AxisDef>> = {
456
452
  shape: "scalar",
457
453
  values: ["output", "signature"],
458
454
  },
455
+ /**
456
+ * Stream loop guard for the model line, on every host and API (read
457
+ * through `loopGuardLevel` in pi-ai `utils/thinking-loop`). `semantic`
458
+ * adds near-duplicate and stalled-wording paragraph detection to the
459
+ * exact repeated-cycle check; `off` disables the guard. Unassigned: exact
460
+ * repeated cycles only.
461
+ */
462
+ "thinking-loop-guard": {
463
+ key: "thinkingLoopGuard",
464
+ set: "catalog",
465
+ shape: "scalar",
466
+ values: ["off", "semantic"],
467
+ },
459
468
  "delegation-bias": { key: "delegationBias", set: "catalog", shape: "scalar", values: DELEGATION_BIASES },
460
469
  "discovery-api": { key: "discoveryApi", set: "catalog", shape: "scalar" },
461
470
  "edit-prompt-variant": { key: "editPromptVariant", set: "catalog", shape: "scalar", values: ["full", "compact"] },
@@ -502,8 +511,9 @@ export const AXES: Readonly<Record<string, AxisDef>> = {
502
511
  "image-max-edge": { key: "imageMaxEdge", set: "catalog", shape: "scalar" },
503
512
  "inline-image-byte-budget": { key: "inlineImageByteBudget", set: "catalog", shape: "scalar" },
504
513
  /**
505
- * Largest request body the host accepts. Where set, the inline-image byte clamp keeps the newest user message's
506
- * and newest tool result's images past `inline-image-byte-budget` while they alone fit this limit.
514
+ * Largest request body the host accepts. Where set, the inline-image byte clamp keeps images within what the
515
+ * request's other bytes leave of it, and keeps the newest user message's and newest tool result's images past
516
+ * `inline-image-byte-budget` while they fit that room.
507
517
  */
508
518
  "request-body-byte-limit": { key: "requestBodyByteLimit", set: "catalog", shape: "scalar" },
509
519
  /**
@@ -663,7 +673,9 @@ export const AXES: Readonly<Record<string, AxisDef>> = {
663
673
  "region-limits-eu": { key: "regionLimitsEu", set: "catalog", shape: "object" },
664
674
  /**
665
675
  * Subscription credit rates: `input` is the per-token credit weight shown
666
- * as the model's multiplier; `output` and `cache-read` multiply it.
676
+ * as the model's multiplier; `output` and `cache-read` multiply it. An
677
+ * `effective-rates` block of dated cards overwrites them from each card's
678
+ * `effective-from`, as on `cost-patch`.
667
679
  */
668
680
  "credit-rates": { key: "creditRates", set: "catalog", shape: "object" },
669
681
  /**
@@ -0,0 +1,9 @@
1
+ import type { CatalogPolicyInputs } from "../types";
2
+ import { type ResolveRoute } from "./resolve";
3
+ /**
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.
8
+ */
9
+ export declare function resolveCatalogPolicy(model: CatalogPolicyInputs, route?: ResolveRoute): Readonly<Record<string, unknown>>;
@@ -1,29 +1,33 @@
1
1
  import { withoutUnverifiedThinking } from "../model-thinking";
2
2
  import type { CatalogPolicyInputs } from "../types";
3
- import { resolveCatalogAxes } from "./resolve";
3
+ import { type ResolveRoute, 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
8
  * mirrors the cascade target inputs — `providerType ?? provider`, api, the
9
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.
10
+ * unknown logical ids under), the reasoning flag, and the route's upstream;
11
+ * identity-derived class/family/revision facts are a pure function of
12
+ * provider + id. Bounded: one entry per distinct model and upstream.
13
13
  */
14
14
  const catalogPolicyCache = new Map<string, Readonly<Record<string, unknown>>>();
15
15
  const CATALOG_POLICY_CACHE_MAX = 8192;
16
16
 
17
17
  /**
18
- * The `catalog` axis bag authored in the KDL cascade rules for a model,
19
- * memoized per distinct model. Frozen: the bag is shared across callers, so it
20
- * must stay read-only — extract the value you need rather than handing it on.
18
+ * The `catalog` axis bag authored in the KDL cascade rules for a model (on one
19
+ * upstream when `route` names it), memoized per distinct model. Frozen: the bag
20
+ * is shared across callers, so it must stay read-only — extract the value you
21
+ * need rather than handing it on.
21
22
  */
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}`;
23
+ export function resolveCatalogPolicy(
24
+ model: CatalogPolicyInputs,
25
+ route?: ResolveRoute,
26
+ ): Readonly<Record<string, unknown>> {
27
+ const key = `${model.provider}\u0000${model.providerType ?? ""}\u0000${model.api}\u0000${model.id}\u0000${model.requestModelId ?? ""}\u0000${model.reasoning ? 1 : 0}\u0000${route?.upstream ?? ""}`;
24
28
  const cached = catalogPolicyCache.get(key);
25
29
  if (cached !== undefined) return cached;
26
- const policy = Object.freeze({ ...resolveCatalogAxes(withoutUnverifiedThinking(model)) });
30
+ const policy = Object.freeze({ ...resolveCatalogAxes(withoutUnverifiedThinking(model), route) });
27
31
  if (catalogPolicyCache.size >= CATALOG_POLICY_CACHE_MAX) catalogPolicyCache.clear();
28
32
  catalogPolicyCache.set(key, policy);
29
33
  return policy;
@@ -240,7 +240,7 @@ function compiledTemplate(compiled: CompiledVariantFamily): VariantFamilyTemplat
240
240
  const alternatives = [family.id, ...family.members, ...(family.extraAliases ?? [])].map(id =>
241
241
  id
242
242
  .split(REVISION_PLACEHOLDER)
243
- .map(part => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"))
243
+ .map(part => RegExp.escape(part))
244
244
  .join(REVISION_CAPTURE),
245
245
  );
246
246
  const template: VariantFamilyTemplate = {
@@ -1,3 +1,4 @@
1
+ import { type DatedCostCard } from "../pricing";
1
2
  import type { Api, ModelSpec } from "../types";
2
3
  import { type FactoryDroidRegion, type FactoryDroidWire } from "../wire/factory-droid";
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 {
@@ -6,6 +6,7 @@
6
6
  * to bind a model to the account serving it.
7
7
  */
8
8
  import { isRecord, once } from "@linxiraos/pi-utils";
9
+ import { type DatedCostCard, parseDatedCostCards } from "../pricing";
9
10
  import type { Api, ModelSpec } from "../types";
10
11
  import { FACTORY_DROID_WIRES, type FactoryDroidRegion, type FactoryDroidWire } from "../wire/factory-droid";
11
12
  import { apiRouteFor } from "./behavior";
@@ -20,11 +21,16 @@ export interface FactoryDroidLimits {
20
21
  maxTokens: number | null;
21
22
  }
22
23
 
23
- /** Standard Credits rates: `input` is the per-token weight; `output` and `cacheRead` multiply it. */
24
+ /**
25
+ * Standard Credits rates: `input` is the per-token weight; `output` and
26
+ * `cacheRead` multiply it. `effectiveRates` are dated cards (ascending) that
27
+ * overwrite those legs from their date, as on `cost-patch`.
28
+ */
24
29
  export interface FactoryDroidCreditRates {
25
30
  input: number;
26
31
  output?: number;
27
32
  cacheRead?: number;
33
+ effectiveRates?: readonly DatedCostCard[];
28
34
  }
29
35
 
30
36
  /** Account gates on one registry model (the `entitlement` axis). */
@@ -95,6 +101,7 @@ function readPolicy(spec: ModelSpec<"factory-droid-agent">): FactoryDroidModelPo
95
101
  const euMaxTokens = numberField(euLimits, "maxTokens");
96
102
  const creditOutput = numberField(credits, "output");
97
103
  const creditCacheRead = numberField(credits, "cacheRead");
104
+ const creditCards = parseDatedCostCards(credits, "credit-rates");
98
105
  const featureFlag = stringField(entitlement, "featureFlag");
99
106
  const deprecationFlag = stringField(entitlement, "deprecationFlag");
100
107
  const baseVariant = stringField(entitlement, "baseVariant");
@@ -116,6 +123,7 @@ function readPolicy(spec: ModelSpec<"factory-droid-agent">): FactoryDroidModelPo
116
123
  input: creditInput,
117
124
  ...(creditOutput !== undefined && { output: creditOutput }),
118
125
  ...(creditCacheRead !== undefined && { cacheRead: creditCacheRead }),
126
+ ...(creditCards.length > 0 && { effectiveRates: creditCards }),
119
127
  },
120
128
  }),
121
129
  ...(priceProvider !== undefined && {
@@ -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";
@@ -50,6 +50,7 @@ export type KnownProvider =
50
50
  | "minimax-code"
51
51
  | "minimax-code-cn"
52
52
  | "mistral"
53
+ | "modular"
53
54
  | "moonshot"
54
55
  | "muse-code"
55
56
  | "nanogpt"
@@ -66,6 +67,7 @@ export type KnownProvider =
66
67
  | "qwen-portal"
67
68
  | "sakana"
68
69
  | "sambanova"
70
+ | "scaleway"
69
71
  | "siliconflow"
70
72
  | "siliconflow-cn"
71
73
  | "singularityapi-dev"
@@ -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.
@@ -604,7 +604,6 @@ function detectOpenAICompat(
604
604
  zaiReasoningEffortDialect: false,
605
605
  clampOutputToModelMax: d.isLocalOpenAICompatBackend,
606
606
  stripImageInput: false,
607
- thinkingLoopGuard: undefined,
608
607
  rejectRootObjectUnion: false,
609
608
  retryWithoutStrictOnGrammarError: false,
610
609
  supportsPromptCacheKey: false,
@@ -762,7 +761,6 @@ function resolveOpenAIResponsesPolicy(
762
761
  supportsSteering: false,
763
762
  requiresReasoningOffJuiceInstruction: false,
764
763
  stripImageInput: false,
765
- thinkingLoopGuard: undefined,
766
764
  reasoningEffortMap: {},
767
765
  supportsReasoningParams: true,
768
766
  supportsSamplingParams: true,
@@ -936,7 +934,6 @@ function resolveAnthropicPolicy(
936
934
  // user-authored `compat` block to override them.
937
935
  maxImageDimension: undefined,
938
936
  maxImagePayloadBytes: undefined,
939
- thinkingLoopGuard: undefined,
940
937
  // Present as keys so models.yml `compat` can set them; unset unless a rule assigns them.
941
938
  stripThinkingHistory: undefined,
942
939
  fastMode: undefined,
@@ -1340,8 +1337,10 @@ export function resolveDiscoveryApi(spec: ModelSpec<Api>, providerType: string):
1340
1337
  * {@link resolveModelPolicy} without resolving the compat and thinking
1341
1338
  * policies, which dominate its cost on catalog-wide scans.
1342
1339
  */
1343
- export function resolveCatalogAxes(spec: CatalogPolicyInputs): Record<string, unknown> {
1344
- return resolveCascade(buildResolveTarget(spec, resolveIdentity(spec))).catalog;
1340
+ export function resolveCatalogAxes(spec: CatalogPolicyInputs, route?: ResolveRoute): Record<string, unknown> {
1341
+ const target = buildResolveTarget(spec, resolveIdentity(spec));
1342
+ target.upstream = route?.upstream;
1343
+ return resolveCascade(target).catalog;
1345
1344
  }
1346
1345
 
1347
1346
  /**
@@ -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. */
@@ -76,6 +76,16 @@ export function compareRevision(a: Revision, b: Revision): number {
76
76
  return a[0] - b[0] || a[1] - b[1] || a[2] - b[2];
77
77
  }
78
78
 
79
+ /** Whether a revision string parses and is at or above `floor`; `undefined` or unparsable is never. */
80
+ export function revisionAtLeast(revision: string | undefined, floor: string): boolean {
81
+ if (revision === undefined) return false;
82
+ const parsedRevision = parseRevision(revision);
83
+ const parsedFloor = parseRevision(floor);
84
+ return (
85
+ parsedRevision !== undefined && parsedFloor !== undefined && compareRevision(parsedRevision, parsedFloor) >= 0
86
+ );
87
+ }
88
+
79
89
  /** Renders a revision as its canonical `major.minor.patch` string. */
80
90
  export function formatRevision(revision: Revision): string {
81
91
  return `${revision[0]}.${revision[1]}.${revision[2]}`;
@@ -227,7 +227,7 @@ One object axis carries a computed form: `long-context-cost` accepts either the
227
227
 
228
228
  `inline-image-byte-budget` caps retained base64 image characters for a deployment's request body. It leaves room for tool schemas and text beneath the provider's body-size limit; the coding agent reads it through `resolveInlineImageByteBudget` before sending live history, and snapcompact gives its archive frames half of it (`frameDataBytesBudget`). The budget applies only while the request reaches the host the rules describe (the Anthropic API, first-party OpenAI, the Codex backend at its default URL, DeepSeek's API, or Factory Droid's own global or EU API host), which callers decide with pi-ai's `reachesBudgetedHost`: `compat.officialEndpoint` for the configured `baseUrl`, for first-party Anthropic models also the `ANTHROPIC_BASE_URL` or Foundry `FOUNDRY_BASE_URL` reroute applied at request time, and for Factory Droid models the `baseUrl` origin. A custom or rerouted endpoint imposes its own body limit.
229
229
 
230
- `request-body-byte-limit` is the largest request body the host accepts (Factory Droid's hosted routes: 4,500,000 bytes), under the same gate. Where it is set, the byte clamp keeps the inline images of the newest user message and then of the newest image-bearing tool result even past `inline-image-byte-budget`, each only while the kept images fit the limit less the request's other serialized bytes, and evicts older images instead; read through `resolveRequestBodyByteLimit`.
230
+ `request-body-byte-limit` is the largest request body the host accepts (Factory Droid's hosted routes: 4,500,000 bytes; Anthropic's Messages API: 128,000,000 bytes), under the same gate. Where it is set, the byte clamp also keeps inline images within what the request's other serialized bytes leave of the limit, and keeps the inline images of the newest user message and then of the newest image-bearing tool result even past `inline-image-byte-budget`, each only while the kept images fit the limit less the request's other serialized bytes, and evicts older images instead; read through `resolveRequestBodyByteLimit`.
231
231
 
232
232
  `catalog-endpoint-budgets #true` makes these host budgets apply whenever a request reaches the provider's own catalog endpoint (an unset `baseUrl`, or an `endpoint-hosts` host; see `isCatalogEndpointUrl`), for a hosted gateway such as Factory Droid whose compat names no official endpoint, or a first-party provider such as DeepSeek whose `openai-completions` compat resolves no `officialEndpoint`. Unassigned, they apply only on the official endpoint.
233
233
 
@@ -258,6 +258,8 @@ Opted in: Muse Code `muse-spark-1.3`, `muse-spark-1.3-contributor`, and the four
258
258
 
259
259
  The routed-subscription registry axes (`upstream-rotation`, `region-upstreams-global|us|eu`, `region-limits-eu`, `credit-rates`, `list-price-from`, `routing-family`, `policy-aliases`, `entitlement`, `default-reasoning-off`) describe a gateway whose proxy fans one model out to several upstreams. They are read through `src/compat/factory-droid.ts` by Factory Droid discovery and its request provider, not materialized by `buildModel`. A provider-wide `region-upstreams-*` rule is the upstream serving table and a model rule replaces it for that region. `list-price-from "<provider>" ["<id>"]` shows a bundled row's list price beside the subscription's own billing; unlike seed values it is resolved at runtime and degrades to the seed's zero cost when the row is gone. See [`providers/factory-droid.kdl`](providers/factory-droid.kdl), whose wire and billing pool per model are `api-routes` and `quota-tiers` rules in `runtime/behavior.kdl`.
260
260
 
261
+ `credit-rates` accepts the same optional `effective-rates` block of named dated cards as `cost-patch`, parsed by the same code: each card has a distinct ISO UTC `effective-from` and any of `input`/`output`/`cache-read`, and the latest card at or before the moment the model browser renders overwrites the legs it names. A vendor credit promotion is two cards, the discounted rate from its start and the base rate again from its end, so a card left behind after the end changes nothing. See [`providers/factory-droid.kdl`](providers/factory-droid.kdl).
262
+
261
263
  ### Time-based pricing
262
264
 
263
265
  The catalog object axis `time-based-cost` materializes into `ModelCost.timeBased`. It uses **named child objects**, not KDL arrays or repeated anonymous windows. For example, inside a matching provider/model scope:
@@ -10,4 +10,4 @@ login-order "openai-codex" "anthropic" "zai" "zai-coding-plan" "kimi-code" "open
10
10
  "qianfan" "venice" "siliconflow" "siliconflow-cn" "synthetic" "nanogpt" "wafer-serverless" "coreweave" \
11
11
  "vercel-ai-gateway" "cloudflare-ai-gateway" "cloudflare-workers-ai" "snowflake" "litellm" "kilo" "zenmux" "opencode-zen" "opencode-go" \
12
12
  "yolo-auto" "tavily" "kagi" "exa" "parallel" "typesafe" "ollama" "ollama-cloud" "lm-studio" "llama.cpp" "vllm" \
13
- "gmi-cloud" "stencil" "singularityapi-dev" "singularityapi-tech" "coralbricks"
13
+ "gmi-cloud" "stencil" "singularityapi-dev" "singularityapi-tech" "coralbricks" "modular" "mistral" "scaleway"
@@ -1,3 +1,7 @@
1
+ // Browser sign-in mirrors the Mistral Vibe CLI and mints a regular API key billed
2
+ // against the plan's Vibe Code quota; the hook returns it as a plain API key.
1
3
  auth "mistral" {
2
4
  name "Mistral"
5
+ env "MISTRAL_API_KEY"
6
+ login "custom" hook="mistral-vibe-sign-in"
3
7
  }
@@ -0,0 +1,9 @@
1
+ auth "modular" {
2
+ name "Modular"
3
+ login "api-key" {
4
+ auth-url "https://console.modular.com/api_keys"
5
+ instructions "Create an API key in the Modular Console"
6
+ prompt "Paste your Modular API key" placeholder="..."
7
+ validate "models-endpoint" label="Modular" url="https://api.modular.com/v1/models"
8
+ }
9
+ }
@@ -0,0 +1,17 @@
1
+ auth "scaleway" {
2
+ name "Scaleway"
3
+ login "api-key" {
4
+ auth-url "https://console.scaleway.com/iam/api-keys"
5
+ instructions "Create an API key on the Scaleway console and paste its Secret Key (SCW_SECRET_KEY)"
6
+ // Scaleway secret keys are UUID-shaped opaque strings with no `sk-`
7
+ // prefix, so the placeholder must not teach a credential shape the
8
+ // console never issues.
9
+ prompt "Paste your Scaleway secret key" placeholder="..."
10
+ normalize "strip-bearer"
11
+ // `/v1/models` is key-protected: it answers 401 without a bearer key
12
+ // and 403 to a rejected one (verified 2026-10-21), so login validates
13
+ // the pasted key there. The probe bills nothing, unlike a
14
+ // chat-completions round-trip against a prepaid balance.
15
+ validate "models-endpoint" label="Scaleway" url="https://api.scaleway.ai/v1/models"
16
+ }
17
+ }
@@ -29,6 +29,11 @@ class "anthropic" {
29
29
  // back as text (`reasoning_extraction`, issue #6093).
30
30
  classifier-cot-extraction #true
31
31
  thinking-replay-tokens "output"
32
+ // Summarized thinking repeats one progress line verbatim while long hidden
33
+ // reasoning runs ("Still writing the parser..." six-plus times back to
34
+ // back), which reads as an exact cycle. Claude has no runaway-loop failure
35
+ // that warrants the guard, so it never discards a turn here.
36
+ thinking-loop-guard "off"
32
37
  // verified: billing matched this formula on Opus 4.7+ and Fable 5.1.
33
38
  image-tokenization {
34
39
  regime "anthropic-patch"
@@ -102,7 +102,7 @@ class "deepseek" {
102
102
  // leaks it into content — hosted gateways, local backends, and custom
103
103
  // providers alike. On hosts that parse it the healer sees no markup.
104
104
  stream-markup-healing-pattern "dsml"
105
- thinking-loop-guard "deepseek"
105
+ thinking-loop-guard "semantic"
106
106
  // V4 reasoning reaches omp as its plaintext trace on every host, and the
107
107
  // revision pins the weights (flash 4.0 / 4.1, pro 4.0). Earlier lineages
108
108
  // classify too coarsely to carry: `r1` also matches the R1 distills.
@@ -149,7 +149,7 @@ class "gemini" {
149
149
  }
150
150
  }
151
151
 
152
- thinking-loop-guard "gemini"
152
+ thinking-loop-guard "semantic"
153
153
  }
154
154
 
155
155
  // Google Search grounding is a Gemini 2+ lineage capability on every Gemini transport.
@@ -67,7 +67,7 @@ class "xai" {
67
67
  }
68
68
  }
69
69
  }
70
- thinking-loop-guard "xai"
70
+ thinking-loop-guard "semantic"
71
71
  }
72
72
 
73
73
  // Same-provider swap targets for hosted search and image generation.
@@ -78,12 +78,16 @@ provider "anthropic" {
78
78
  // Code's `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS` kill switch for gateways
79
79
  // that reject experimental beta fields.
80
80
  honors-claude-code-beta-kill-switch #true
81
- // Messages requests cap at 32 MB. Reserve 8 MB for text, tools, and JSON
82
- // framing when retaining inline base64 images in a long conversation.
83
- // Applied only on the official endpoint; a custom baseUrl has its own limit.
81
+ // Messages requests cap at 128 MB. Reserve 8 MB for text, tools, and JSON
82
+ // framing when retaining inline base64 images in a long conversation; the
83
+ // body limit keeps images within what the other bytes leave, and lets the
84
+ // newest user message's and tool result's images use the reserve.
85
+ // Applied only on the official endpoint; a custom baseUrl has its own limit
86
+ // (Bedrock 20 MB; Vertex, Foundry, and Claude Platform on AWS 30-32 MB).
84
87
  // https://platform.claude.com/docs/en/api/overview#request-size-limits
85
88
  on-api "anthropic-messages" {
86
- inline-image-byte-budget 24000000
89
+ inline-image-byte-budget 120000000
90
+ request-body-byte-limit 128000000
87
91
  }
88
92
  // The official endpoint carries at most 600 images and documents per
89
93
  // request, 100 on models with a 200k-token window: every Claude line before
@@ -387,6 +387,16 @@ provider "cursor" {
387
387
  cache-write 0
388
388
  }
389
389
  }
390
+ // DeepSeek V4.1 Flash 1017: $0.30/$1.20, cache read $0.006, no write fee.
391
+ // The bare id and every reasoning-effort wire id share one card.
392
+ models "deepseek-v41-flash-1017*" {
393
+ cost-patch {
394
+ input 0.3
395
+ output 1.2
396
+ cache-read 0.006
397
+ cache-write 0
398
+ }
399
+ }
390
400
  // Gemini 3 Flash: $0.50/$3.00, cache read $0.05.
391
401
  models "gemini-3-flash" {
392
402
  cost-patch {
@@ -7,8 +7,8 @@ provider "deepseek" {
7
7
 
8
8
  // DeepSeek's vision guide documents 600 images per request and a 48 MiB
9
9
  // request body. OMP reserves 8 MiB for text, tools, and the JSON envelope
10
- // (48 MiB - 8 MiB = 40 MiB); Anthropic's 24,000,000-byte image budget under
11
- // its 32 MB body uses an 8 MB reserve. DeepSeek documents MiB, so this uses
10
+ // (48 MiB - 8 MiB = 40 MiB); Anthropic's 120,000,000-byte image budget under
11
+ // its 128 MB body uses an 8 MB reserve. DeepSeek documents MiB, so this uses
12
12
  // an 8 MiB reserve. The split is OMP's conservative margin, not a
13
13
  // DeepSeek-documented figure. A custom baseUrl keeps the conservative
14
14
  // catalog floor because the gateway's own limits are unknown.