@linxiraos/pi-catalog 1.1.13 → 1.1.15

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 (43) hide show
  1. package/CHANGELOG.md +2 -69
  2. package/README.md +20 -0
  3. package/dist/types/compat/auth-ids.d.ts +2 -2
  4. package/dist/types/models.d.ts +10 -6
  5. package/dist/types/pricing.d.ts +5 -0
  6. package/dist/types/provider-models/descriptor-types.d.ts +15 -0
  7. package/dist/types/provider-models/descriptors.d.ts +20 -0
  8. package/dist/types/provider-models/openai-compat.d.ts +44 -0
  9. package/dist/types/types.d.ts +43 -2
  10. package/dist/types/wire/charm-hyper.d.ts +21 -0
  11. package/dist/types/wire/github-copilot.d.ts +19 -0
  12. package/package.json +4 -4
  13. package/src/build.ts +16 -2
  14. package/src/compat/auth-ids.ts +4 -0
  15. package/src/compat/axes.ts +9 -0
  16. package/src/compat/resolve.ts +18 -4
  17. package/src/compat/rules/README.md +37 -0
  18. package/src/compat/rules/auth/_order.kdl +1 -1
  19. package/src/compat/rules/auth/charm-hyper.kdl +19 -0
  20. package/src/compat/rules/auth/commandcode.kdl +13 -0
  21. package/src/compat/rules/classes/anthropic.kdl +41 -0
  22. package/src/compat/rules/classes/deepseek.kdl +11 -0
  23. package/src/compat/rules/classes/minimax.kdl +4 -2
  24. package/src/compat/rules/providers/amazon-bedrock.kdl +7 -0
  25. package/src/compat/rules/providers/anthropic.kdl +8 -0
  26. package/src/compat/rules/providers/charm-hyper.kdl +82 -0
  27. package/src/compat/rules/providers/commandcode.kdl +601 -0
  28. package/src/compat/rules/providers/deepseek.kdl +83 -1
  29. package/src/compat/rules/providers/opencode-go.kdl +22 -0
  30. package/src/compat/rules/providers/opencode-zen.kdl +12 -0
  31. package/src/compat/rules/runtime/behavior.kdl +5 -0
  32. package/src/compat/rules.json +2143 -131
  33. package/src/model-manager.ts +27 -13
  34. package/src/models.json +12953 -5481
  35. package/src/models.ts +93 -19
  36. package/src/pricing.ts +136 -0
  37. package/src/provider-models/cache-provider-id.ts +28 -4
  38. package/src/provider-models/descriptor-types.ts +15 -0
  39. package/src/provider-models/descriptors.ts +36 -0
  40. package/src/provider-models/openai-compat.ts +297 -3
  41. package/src/types.ts +46 -1
  42. package/src/wire/charm-hyper.ts +26 -0
  43. package/src/wire/github-copilot.ts +26 -0
@@ -207,6 +207,43 @@ The three value shapes are:
207
207
  A rule cannot assign the same resolved axis twice in one block.
208
208
  One object axis carries a computed form: `long-context-cost` accepts either the absolute rates (`input-threshold` + `input`/`output`/`cache-read`/`cache-write`) or `input-threshold` + `multiplier` (with optional `input-threshold-inclusive`), which derives the tier from the row's live base price at build time so the rule tracks upstream list-price updates (xAI's SuperGrok 200K tier). Rows without a token price carry no tier.
209
209
 
210
+ ### Time-based pricing
211
+
212
+ 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:
213
+
214
+ ```kdl
215
+ time-based-cost {
216
+ off-peak-multiplier 0.5
217
+ peak-windows {
218
+ morning {
219
+ weekdays "1,2,3,4,5"
220
+ start-minute 60
221
+ end-minute 240
222
+ }
223
+ afternoon {
224
+ weekdays "1,2,3,4,5"
225
+ start-minute 360
226
+ end-minute 600
227
+ }
228
+ }
229
+ effective-rates {
230
+ flash-pricing {
231
+ effective-from "2026-09-14T04:00:00Z"
232
+ input 0.30
233
+ output 1.20
234
+ cache-read 0.006
235
+ cache-write 0
236
+ }
237
+ }
238
+ }
239
+ ```
240
+
241
+ `morning`, `afternoon`, and `flash-pricing` are arbitrary unique object names, discarded when the payload is normalized into arrays. `weekdays` is a comma-separated string of distinct UTC weekday numbers (`0` = Sunday through `6` = Saturday), without spaces. Each window has integer minutes with `0 <= start-minute < end-minute <= 1440`; its start is inclusive and end exclusive. Split overnight windows across days. Outside the union of peak windows, the nonnegative `off-peak-multiplier` applies to token costs.
242
+
243
+ `effective-rates` is optional. Each entry requires a distinct valid ISO UTC `effective-from` (`YYYY-MM-DDTHH:mm:ssZ` or with three fractional-second digits) and all four nonnegative per-million-token rates. The latest entry at or before the request timestamp replaces the entire base card; before the first entry, the base card applies. An entry may contain a `long-context` object with `input-threshold`, optional `input-threshold-inclusive`, and all four absolute rates. Effective rates do not inherit the base card's long-context tier. Selection order is effective card, context tier, then tariff multiplier.
244
+
245
+ The recurring schedule and dated DeepSeek transition above come from [DeepSeek's official pricing](https://api-docs.deepseek.com/quick_start/pricing); see `providers/deepseek.kdl` for the complete rules and [the catalog API](../../../README.md#cost-calculation) for timestamp semantics. This is catalog policy metadata, not a supported schedule syntax for the coding agent's `models.yml`.
246
+
210
247
  ### Precedence and ambiguity
211
248
 
212
249
  Rules resolve independently per axis. A matching rule is ranked by:
@@ -5,7 +5,7 @@ login-order "openai-codex" "anthropic" "zai" "zai-coding-plan" "kimi-code" "open
5
5
  "cursor" "devin" "google-antigravity" "google-gemini-cli" "openai-codex-device" "xai" "xai-oauth" \
6
6
  "gitlab-duo" "gitlab-duo-agent" "alibaba-coding-plan" "alibaba-token-plan" "aiand" "abliteration" "zhipu-coding-plan" \
7
7
  "umans" "qwen-portal" "sakana" "minimax-code" "minimax-code-cn" "xiaomi" "xiaomi-token-plan-sgp" \
8
- "xiaomi-token-plan-ams" "xiaomi-token-plan-cn" "firepass" "cline-pass" "deepseek" "muse-code" "meta" "moonshot" \
8
+ "xiaomi-token-plan-ams" "xiaomi-token-plan-cn" "firepass" "cline-pass" "commandcode" "charm-hyper" "deepseek" "muse-code" "meta" "moonshot" \
9
9
  "cerebras" "baseten" "fireworks" "together" "nvidia" "novita" "deepinfra" "huggingface" "perplexity" \
10
10
  "qianfan" "venice" "siliconflow" "siliconflow-cn" "synthetic" "nanogpt" "wafer-serverless" "coreweave" \
11
11
  "vercel-ai-gateway" "cloudflare-ai-gateway" "litellm" "kilo" "zenmux" "opencode-zen" "opencode-go" \
@@ -0,0 +1,19 @@
1
+ // Validation targets `/v1/credits`, not `/v1/models`: the models endpoint is
2
+ // public and answers 200 with no credentials or a bogus key (verified
3
+ // 2026-09-11), so a models-endpoint probe against it could never reject a bad
4
+ // key. `/v1/credits` is an authenticated, non-billable GET that returns the
5
+ // account balance on success and 401 `{"error":"authentication failed"}`
6
+ // otherwise — the same trick cline-pass uses to validate against its own
7
+ // `/users/me`, and cheaper than a chat-completions probe that would bill the
8
+ // key on every login.
9
+ auth "charm-hyper" {
10
+ name "Charm Hyper"
11
+ env "CHARM_HYPER_API_KEY" "HYPER_API_KEY"
12
+ login "api-key" {
13
+ auth-url "https://hyper.charm.land/"
14
+ instructions "Create or copy an API key from the Charm Hyper dashboard"
15
+ prompt "Paste your Charm Hyper API key" placeholder="sk-hyper-..."
16
+ normalize "strip-bearer"
17
+ validate "models-endpoint" label="Charm Hyper" url="https://hyper.charm.land/v1/credits"
18
+ }
19
+ }
@@ -0,0 +1,13 @@
1
+ // No `validate` probe on purpose: GET /provider/v1/models is public (200
2
+ // with no or bogus credentials, verified 2026-09-09), so a models-endpoint
3
+ // probe could never reject a bad key. A chat-completions probe would bill
4
+ // the key and 403 for Go-plan keys that are still valid CLI credentials.
5
+ auth "commandcode" {
6
+ name "Command Code"
7
+ env "COMMAND_CODE_API_KEY" "COMMANDCODE_API_KEY"
8
+ login "api-key" {
9
+ auth-url "https://commandcode.ai/studio"
10
+ instructions "Create or copy a Provider API key from Command Code Studio"
11
+ prompt "Paste your Command Code API key" placeholder="user_..."
12
+ }
13
+ }
@@ -7,6 +7,30 @@ class "anthropic" {
7
7
  thinking-prefix-binding #true
8
8
  }
9
9
  }
10
+ // Server-side compaction (compact-2026-01-12) is a lineage capability: the
11
+ // documented model list is the adaptive-thinking generation onward (Opus
12
+ // 4.6+, Sonnet 4.6+, Fable/Mythos 5+). Whether a host delivers the beta is
13
+ // decided at request time from the effective endpoint, not here.
14
+ family "fable" {
15
+ revision ">=5" {
16
+ supports-server-compaction #true
17
+ }
18
+ }
19
+ family "mythos" {
20
+ revision ">=5" {
21
+ supports-server-compaction #true
22
+ }
23
+ }
24
+ family "opus" {
25
+ revision ">=4.6" {
26
+ supports-server-compaction #true
27
+ }
28
+ }
29
+ family "sonnet" {
30
+ revision ">=4.6" {
31
+ supports-server-compaction #true
32
+ }
33
+ }
10
34
  on "anthropic" "cloudflare-ai-gateway" "google-vertex" {
11
35
  family "fable" {
12
36
  revision ">=5" {
@@ -145,6 +169,23 @@ class "anthropic" {
145
169
  cache-read 1.0
146
170
  cache-write 12.5
147
171
  }
172
+ // Fable 5.1 cut cache reads to $0.25/MTok, 0.025x input, a 75% rate
173
+ // unique to the 5.1 generation; Fable 5 stays at the 0.1x family
174
+ // default. https://www.anthropic.com/claude/fable
175
+ //
176
+ // `cost-patch` is an object axis, so the winning rule supplies the
177
+ // whole payload rather than merging field-wise over the family
178
+ // patch above. Restate input/output/cache-write, or a
179
+ // discovery-sourced 5.1 row (Anthropic's /v1/models omits pricing)
180
+ // would keep only the cache-read correction.
181
+ revision "=5.1" {
182
+ cost-patch {
183
+ input 10.0
184
+ output 50.0
185
+ cache-read 0.25
186
+ cache-write 12.5
187
+ }
188
+ }
148
189
  limits-patch {
149
190
  context-window 1000000
150
191
  max-tokens 128000
@@ -73,6 +73,17 @@ class "deepseek" {
73
73
  models token="vision" {
74
74
  strip-image-input #false
75
75
  }
76
+ // DeepSeek V4.1 Flash is natively multimodal (image-text-to-text), but its
77
+ // id carries no `vision` token, so the class-wide strip above dropped
78
+ // attachments the model reads on every deployment without its own carve-out.
79
+ // The glob also spans `-vision`/`-ocr` ids, which already set the same value
80
+ // below, so the explicit priority resolves that equal-rank tie instead of
81
+ // throwing AmbiguousOverlapError. Only the strip is disabled; the declared
82
+ // modality stays host-derived, so endpoints whose OpenAI-compatible surface
83
+ // rejects `image_url` keep their text-only contract.
84
+ models "*v4.1-flash*" priority=10 {
85
+ strip-image-input #false
86
+ }
76
87
  on "ollama-cloud" "nvidia" "deepseek" "fireworks" "nanogpt" "opencode-go" "openrouter" {
77
88
  stream-markup-healing-pattern "dsml"
78
89
  }
@@ -28,8 +28,10 @@ class "minimax" {
28
28
  }
29
29
  // MiniMax-M3: 512K is the standard pricing-tier boundary leaked into
30
30
  // upstream metadata, not the model ceiling (documented: 1M in / 128K out).
31
- on "minimax" "minimax-cn" "minimax-code" "minimax-code-cn" {
32
- models "MiniMax-M3" {
31
+ // Exact selectors are case-sensitive, so both served spellings are listed:
32
+ // MiniMax hosts publish `MiniMax-M3`, Charm Hyper publishes `minimax-m3`.
33
+ on "charm-hyper" "minimax" "minimax-cn" "minimax-code" "minimax-code-cn" {
34
+ models "MiniMax-M3" "minimax-m3" {
33
35
  limits-patch {
34
36
  context-window 1000000
35
37
  max-tokens 128000
@@ -15,6 +15,8 @@ provider "amazon-bedrock" {
15
15
  }
16
16
  class "openai" {
17
17
  thinking-mode "effort"
18
+ // OpenAI models reject Converse image blocks nested inside toolResult content.
19
+ requires-tool-result-image-hoisting #true
18
20
  }
19
21
  class "deepseek" {
20
22
  requires-reasoning-content-for-all-assistant-turns #true
@@ -28,6 +30,11 @@ provider "amazon-bedrock" {
28
30
  class "unknown" {
29
31
  thinking-efforts "minimal" "low" "medium" "high"
30
32
  thinking-mode "budget"
33
+ // Opaque application-inference-profile ARNs carry no vendor signal, so an
34
+ // OpenAI-backed profile classifies here and would otherwise nest images in
35
+ // toolResult content and hit the same rejection. Hoisting is accepted by
36
+ // every Converse model measured, so it is the safe default for unknowns.
37
+ requires-tool-result-image-hoisting #true
31
38
  }
32
39
  // residue: taxonomy ranks and exact globs do not isolate these models.
33
40
  models "moonshot.kimi-k2-thinking" {
@@ -1,6 +1,14 @@
1
1
  // Provider-wire compat for "anthropic"; regenerated from the frozen census using deployment contract selectors.
2
2
 
3
3
  provider "anthropic" {
4
+ // First-party provider: models served through this provider reach the
5
+ // official API unless rerouted. A dedicated axis rather than
6
+ // `official-endpoint`, which stays URL-derived: a custom `baseUrl` on this
7
+ // provider must keep `officialEndpoint: false` (SDK `X-Api-Key`
8
+ // suppression and friends read that flag). The compaction transport
9
+ // combines this fact with a per-request effective-URL check, so it never
10
+ // authorizes a block on its own.
11
+ first-party-provider #true
4
12
  class "anthropic" {
5
13
  revision ">=3.7 <4.6" {
6
14
  thinking-efforts "minimal" "low" "medium" "high" "xhigh"
@@ -0,0 +1,82 @@
1
+ // Charm Hyper gateway deployment contract.
2
+ //
3
+ // Capability data is NOT restated here: `GET /v1/models` publishes each row's
4
+ // context window, output cap, vision flag, effort vocabulary and per-million
5
+ // tariff, and `charmHyperModelManagerOptions` maps all of it verbatim —
6
+ // including `reasoningDisableMode`, which is derived per model from whether
7
+ // the advertised vocabulary contains `none`. Only facts the gateway does not
8
+ // publish, or publishes wrongly, belong in this file.
9
+ provider "charm-hyper" {
10
+ // OpenAI-dialect gateway in front of open-weight and third-party models.
11
+ // `developer` and `store` are accepted (HTTP 200) but the gateway accepts
12
+ // every unknown field it is handed, so acceptance is not evidence the
13
+ // semantics are honored; both stay off and system prompts ride the
14
+ // `system` role, matching every sibling gateway. The wire takes
15
+ // `max_tokens` (verified 2026-09-11).
16
+ supports-developer-role #false
17
+ supports-store #false
18
+ max-tokens-field "max_tokens"
19
+ thinking-mode "effort"
20
+ // Reasoning arrives as `reasoning_content` on both the streamed delta and
21
+ // the final message (verified 2026-09-11).
22
+ reasoning-content-field "reasoning_content"
23
+ // ---------------------------------------------------------------------------
24
+ // Blockless rows are left non-reasoning on purpose.
25
+ //
26
+ // Four ids serve a thinking model while publishing no `reasoning` block:
27
+ // glm-5, glm-5.1, kimi-k2-thinking and minimax-m2.7 each returned
28
+ // populated `reasoning_content` and non-zero `reasoning_tokens` on a
29
+ // multi-step prompt (2026-09-11). The other blockless rows
30
+ // (gemma-4-26b-a4b-it, kimi-k2.5, kimi-k2.7-code, llama-3.3-70b-instruct,
31
+ // llama-4-maverick-17b-128e-instruct-fp8,
32
+ // qwen3-coder-480b-a35b-instruct-int4-mixed-ar, qwen3-next-80b-a3b-instruct)
33
+ // returned none.
34
+ //
35
+ // No rule restores them, because none can be written honestly. Those four
36
+ // expose no effort dial, and `ThinkingConfig.efforts` is documented as
37
+ // never empty — a reasoning model without a controllable surface carries
38
+ // `thinking: undefined`, which no KDL axis can express (the only upgrade
39
+ // path is an exact `thinking-efforts` ladder). Synthesizing a ladder would
40
+ // add silent no-op rungs: the gateway answers 200 to efforts it never
41
+ // advertised and simply ignores them, and a repeat measurement of effort
42
+ // sensitivity on these ids came back non-monotonic, i.e. sampling noise
43
+ // rather than a hidden dial.
44
+ //
45
+ // The cost is narrow and was checked: streamed `reasoning_content` is
46
+ // parsed and displayed with no `model.reasoning` gate, the effort
47
+ // parameter is moot without a dial, and the developer-role and
48
+ // zai-replay paths are already disabled for this provider.
49
+ // ---------------------------------------------------------------------------
50
+ // Residue: misreported output caps. The gateway derives
51
+ // `max_output_tokens` as a flat fraction of the context window rather
52
+ // than reporting a real ceiling — 10% on 9 rows, the dominant
53
+ // convention — and the values are advisory, not enforced: glm-5.1
54
+ // publishes 3276 yet produced 14066 tokens, and minimax-m2.7 publishes
55
+ // 6553 yet produced 8418, both stopping on `finish_reason: "stop"`
56
+ // rather than `length`. An over-stated cap is never rejected either
57
+ // (`max_tokens: 200000` returns 200), so the risk is one-sided:
58
+ // over-stating costs only the context share 10% already reserves
59
+ // everywhere else, while under-stating truncates real output.
60
+ //
61
+ // Both corrections take a same-window peer's published value rather than
62
+ // inventing a ceiling, and both clear the measured floor:
63
+ // glm-5.1 (202750) is 1.6%; sibling glm-5 (202752) publishes 20275.
64
+ // minimax-m2.7 (262100) is 2.5%, the lone outlier in its window class;
65
+ // kimi-k2.5 (262144), kimi-k2.6 (262000) and
66
+ // qwen3-next-80b (262144) all publish 26214.
67
+ //
68
+ // deepseek-v4.1-flash is the only other 2.5% row and is deliberately left
69
+ // alone: its 1M window has no peer group that agrees on a fraction, and a
70
+ // long generation stopped naturally at 8504, well inside the published
71
+ // 26214. Measured 2026-09-11.
72
+ models "glm-5.1" {
73
+ limits-patch {
74
+ max-tokens 20275
75
+ }
76
+ }
77
+ models "minimax-m2.7" {
78
+ limits-patch {
79
+ max-tokens 26214
80
+ }
81
+ }
82
+ }