dsh-thinking-levels 4.3.2 → 4.3.3

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.
package/lib/index.d.ts CHANGED
@@ -78,8 +78,9 @@ export interface ThinkingLevelsConfig {
78
78
  /** Configurer-confirmed capability overrides, keyed `provider/model`. */
79
79
  models: Record<string, ModelCapabilityOverride>;
80
80
  /**
81
- * 目录外模型的计价兜底档(price-catalog 未命中时生效):cn/global/custom/off。
82
- * 缺省 off(未计价,不再拿单一型号价硬算);目录内模型自动按条目地区计价。
81
+ * 目录外模型的计价兜底档(price-catalog 未命中时生效):estimate/cn/global/custom/off。
82
+ * 缺省 estimate(典型价兜底估算,显示「未校准·仅供参考」);off 才是真不计价;
83
+ * 目录内模型自动按条目地区计价,不受本项影响。
83
84
  */
84
85
  defaultPricing: PricingPolicy | Volatile<PricingPolicy>;
85
86
  }
@@ -96,7 +97,7 @@ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
96
97
  allowDowngrade: z<boolean, boolean, "volatile-defined">;
97
98
  allowUpgrade: z<boolean, boolean, "volatile-defined">;
98
99
  takeover: z<boolean, boolean, "volatile-defined">;
99
- defaultPricing: z<"cn" | "global" | "custom" | "off", "cn" | "global" | "custom" | "off", "volatile-defined">;
100
+ defaultPricing: z<"estimate" | "cn" | "global" | "custom" | "off", "estimate" | "cn" | "global" | "custom" | "off", "volatile-defined">;
100
101
  models: z<import("@deepseek-ai/cosmokit").Dict<{
101
102
  vision?: boolean | null | undefined;
102
103
  thinking?: boolean | null | undefined;
@@ -114,7 +115,7 @@ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
114
115
  allowDowngrade: z<boolean, boolean, "volatile-defined">;
115
116
  allowUpgrade: z<boolean, boolean, "volatile-defined">;
116
117
  takeover: z<boolean, boolean, "volatile-defined">;
117
- defaultPricing: z<"cn" | "global" | "custom" | "off", "cn" | "global" | "custom" | "off", "volatile-defined">;
118
+ defaultPricing: z<"estimate" | "cn" | "global" | "custom" | "off", "estimate" | "cn" | "global" | "custom" | "off", "volatile-defined">;
118
119
  models: z<import("@deepseek-ai/cosmokit").Dict<{
119
120
  vision?: boolean | null | undefined;
120
121
  thinking?: boolean | null | undefined;
@@ -140,7 +141,7 @@ export declare const LegacyConfig: z<Schemastery.ObjectS<NoInfer<{
140
141
  allowDowngrade: z<boolean, boolean, "defined">;
141
142
  allowUpgrade: z<boolean, boolean, "defined">;
142
143
  takeover: z<boolean, boolean, "defined">;
143
- defaultPricing: z<"cn" | "global" | "custom" | "off", "cn" | "global" | "custom" | "off", "defined">;
144
+ defaultPricing: z<"estimate" | "cn" | "global" | "custom" | "off", "estimate" | "cn" | "global" | "custom" | "off", "defined">;
144
145
  models: z<import("@deepseek-ai/cosmokit").Dict<{
145
146
  vision?: boolean | null | undefined;
146
147
  thinking?: boolean | null | undefined;
@@ -158,7 +159,7 @@ export declare const LegacyConfig: z<Schemastery.ObjectS<NoInfer<{
158
159
  allowDowngrade: z<boolean, boolean, "defined">;
159
160
  allowUpgrade: z<boolean, boolean, "defined">;
160
161
  takeover: z<boolean, boolean, "defined">;
161
- defaultPricing: z<"cn" | "global" | "custom" | "off", "cn" | "global" | "custom" | "off", "defined">;
162
+ defaultPricing: z<"estimate" | "cn" | "global" | "custom" | "off", "estimate" | "cn" | "global" | "custom" | "off", "defined">;
162
163
  models: z<import("@deepseek-ai/cosmokit").Dict<{
163
164
  vision?: boolean | null | undefined;
164
165
  thinking?: boolean | null | undefined;
package/lib/index.js CHANGED
@@ -16,7 +16,7 @@ const modelsSchema = z.dict(z.object({
16
16
  contextWindow: z.number().step(1).min(CONTEXT_WINDOW_MIN).max(CONTEXT_WINDOW_MAX),
17
17
  })).default({});
18
18
  /** 计价兜底档:schemastery 枚举,两代 schema 共享(the two must never drift)。 */
19
- const defaultPricingSchema = z.union(['cn', 'global', 'custom', 'off']).default('off');
19
+ const defaultPricingSchema = z.union(['estimate', 'cn', 'global', 'custom', 'off']).default('estimate');
20
20
  /**
21
21
  * Composition-entry schema: what a dsh profile may configure at assembly
22
22
  * time (cordis.yml `config:` of the plugin row). The same schema doubles as
@@ -56,7 +56,7 @@ export const DEFAULT_CONFIG = {
56
56
  allowDowngrade: true,
57
57
  allowUpgrade: false,
58
58
  takeover: false,
59
- defaultPricing: 'off',
59
+ defaultPricing: 'estimate',
60
60
  models: {},
61
61
  };
62
62
  /**
@@ -84,7 +84,7 @@ function resolveLiveConfig(config) {
84
84
  allowDowngrade: readVolatile(config.allowDowngrade, true),
85
85
  allowUpgrade: readVolatile(config.allowUpgrade, false),
86
86
  takeover: readVolatile(config.takeover, false),
87
- defaultPricing: readVolatile(config.defaultPricing, 'off'),
87
+ defaultPricing: readVolatile(config.defaultPricing, 'estimate'),
88
88
  models: config.models,
89
89
  };
90
90
  }
@@ -13,12 +13,15 @@
13
13
  * (官方定价页 2026-08-14 快照,2026-08-17 起峰谷分时;峰窗 09-12/14-18 北京);
14
14
  * - 国内厂商 flat 行:镜像 .peakref companion price/catalog.js CATALOG_TABLE
15
15
  * (各官方定价页人民币站低档价快照;免费行照录 0);
16
- * - 海外 USD 行:本轮网络侧无法核实(OpenAI 403 / Google 超时 / Anthropic 页无
17
- * API 表),结构留位、数值留空——宁缺毋伪,核实通道到位后走 golden 门禁补录。
16
+ * - 海外 USD 行:2026-10-18 补录(CATALOG_VERSION 1→2)——Claude 四行为
17
+ * Anthropic 官方定价页直接抓取;GPT/Gemini 行为 GitHub Copilot 计费文档一手
18
+ * 表(USD/MTok 默认档),并与多家独立报道交叉核实;促销/介绍期价格在 source
19
+ * 注明失效时点,届时按标准价改录并重跑 golden 门禁。
18
20
  *
19
21
  * 判定链:策略 key 特异性(provider/model > model > provider > *)→ 目录命中
20
- * (精确 > 最长后缀 > 最长包含)→ 目录外走 snapshot.defaultPricing(缺省 off,
21
- * source 记 'catalog-miss')。节假日/补班修正表随 isPeakBeijing 一并迁入,
22
+ * (精确 > 最长后缀 > 最长包含)→ 目录外走 snapshot.defaultPricing(缺省
23
+ * estimate = 典型价兜底估算,source 记 'catalog-miss' 且 estimated=true;
24
+ * off 才是真不计价)。节假日/补班修正表随 isPeakBeijing 一并迁入,
22
25
  * billing-projection 只负责记账,不再持有价格与日历。
23
26
  * @module dsh-thinking-levels/price-catalog
24
27
  */
@@ -30,8 +33,8 @@ export interface PriceRow {
30
33
  inputCacheHit: number;
31
34
  output: number;
32
35
  }
33
- /** 每 API 计价策略四档。 */
34
- export type PricingPolicy = 'cn' | 'global' | 'custom' | 'off';
36
+ /** 每 API 计价策略档位(estimate = 目录外典型价兜底估算,未校准仅供参考)。 */
37
+ export type PricingPolicy = 'estimate' | 'cn' | 'global' | 'custom' | 'off';
35
38
  /** 生效来源:四档 + 目录外兜底标记。 */
36
39
  export type PricingSource = PricingPolicy | 'catalog-miss';
37
40
  /** 峰/谷/平三态;平价条目(无峰谷官方价)与 custom 档用 flat。 */
@@ -50,7 +53,7 @@ export interface PricingSnapshot {
50
53
  defaultPricing: PricingPolicy;
51
54
  policies?: Readonly<Record<string, PolicyEntry>>;
52
55
  }
53
- /** 目录条目:cn 为 峰谷对 或 平价行;global 预留平价(当前留空)。 */
56
+ /** 目录条目:cn 为 峰谷对 或 平价行;global 为海外平价行(USD,2026-10-18 起有条目)。 */
54
57
  export interface CatalogEntry {
55
58
  key: string;
56
59
  label: string;
@@ -69,8 +72,17 @@ export interface CatalogEntry {
69
72
  /** 来源标注(官方定价页或仓内镜像快照路径)。 */
70
73
  source: string;
71
74
  }
72
- /** 目录版本(进解析缓存键与审计)。 */
73
- export declare const CATALOG_VERSION = 1;
75
+ /** 目录版本(进解析缓存键与审计)。2 = 2026-10-18 补录海外 USD 行。 */
76
+ export declare const CATALOG_VERSION = 2;
77
+ /**
78
+ * 目录外模型的兜底典型价(CNY/百万 token):取 DeepSeek-V4.1-Flash 谷时行
79
+ * ——主力模型的平价档,数量级最贴近通用网关。仅用于 estimate 档/目录外缺省,
80
+ * 展示侧必须带「未校准·仅供参考」标注,不得伪装成目录条目。
81
+ */
82
+ export declare const BILLING_FALLBACK: {
83
+ row: PriceRow;
84
+ currency: Currency;
85
+ };
74
86
  /** 内置典型价目目录(CNY/百万 token)。 */
75
87
  export declare const PRICE_CATALOG: readonly CatalogEntry[];
76
88
  /**
@@ -97,6 +109,8 @@ export interface ResolvedRate {
97
109
  source: PricingSource;
98
110
  entry: CatalogEntry | null;
99
111
  priced: boolean;
112
+ /** 金额为兜底典型价估算(未校准,仅供参考);恒随 priced。 */
113
+ estimated: boolean;
100
114
  }
101
115
  /** 唯一计价解析出口。目录命中且无显式策略时取条目自身地区(cn 优先,仅 global 取 global)。 */
102
116
  export declare function resolveRate(model: string | null, provider: string | null, timeMs: number, snapshot: PricingSnapshot): ResolvedRate;
@@ -13,19 +13,34 @@
13
13
  * (官方定价页 2026-08-14 快照,2026-08-17 起峰谷分时;峰窗 09-12/14-18 北京);
14
14
  * - 国内厂商 flat 行:镜像 .peakref companion price/catalog.js CATALOG_TABLE
15
15
  * (各官方定价页人民币站低档价快照;免费行照录 0);
16
- * - 海外 USD 行:本轮网络侧无法核实(OpenAI 403 / Google 超时 / Anthropic 页无
17
- * API 表),结构留位、数值留空——宁缺毋伪,核实通道到位后走 golden 门禁补录。
16
+ * - 海外 USD 行:2026-10-18 补录(CATALOG_VERSION 1→2)——Claude 四行为
17
+ * Anthropic 官方定价页直接抓取;GPT/Gemini 行为 GitHub Copilot 计费文档一手
18
+ * 表(USD/MTok 默认档),并与多家独立报道交叉核实;促销/介绍期价格在 source
19
+ * 注明失效时点,届时按标准价改录并重跑 golden 门禁。
18
20
  *
19
21
  * 判定链:策略 key 特异性(provider/model > model > provider > *)→ 目录命中
20
- * (精确 > 最长后缀 > 最长包含)→ 目录外走 snapshot.defaultPricing(缺省 off,
21
- * source 记 'catalog-miss')。节假日/补班修正表随 isPeakBeijing 一并迁入,
22
+ * (精确 > 最长后缀 > 最长包含)→ 目录外走 snapshot.defaultPricing(缺省
23
+ * estimate = 典型价兜底估算,source 记 'catalog-miss' 且 estimated=true;
24
+ * off 才是真不计价)。节假日/补班修正表随 isPeakBeijing 一并迁入,
22
25
  * billing-projection 只负责记账,不再持有价格与日历。
23
26
  * @module dsh-thinking-levels/price-catalog
24
27
  */
25
- /** 目录版本(进解析缓存键与审计)。 */
26
- export const CATALOG_VERSION = 1;
28
+ /** 目录版本(进解析缓存键与审计)。2 = 2026-10-18 补录海外 USD 行。 */
29
+ export const CATALOG_VERSION = 2;
30
+ /**
31
+ * 目录外模型的兜底典型价(CNY/百万 token):取 DeepSeek-V4.1-Flash 谷时行
32
+ * ——主力模型的平价档,数量级最贴近通用网关。仅用于 estimate 档/目录外缺省,
33
+ * 展示侧必须带「未校准·仅供参考」标注,不得伪装成目录条目。
34
+ */
35
+ export const BILLING_FALLBACK = {
36
+ row: { inputCacheHit: 0.02, inputMiss: 1, output: 4 },
37
+ currency: 'CNY',
38
+ };
27
39
  const PEAKOFF = 'DeepSeek 官方峰谷分时(峰窗 09-12/14-18 北京;源 api-docs.deepseek.com/zh-cn/quick_start/pricing/)';
28
40
  const PEAKREF = '镜像 .peakref/companion/lib/core/price/catalog.js 官方页快照(低档价)';
41
+ const ANOFF = 'Anthropic 官方定价页 2026-10-18 抓取快照(USD/MTok 默认档;缓存写入加价不在三价目位内;Haiku 取 ≤100K 低档)';
42
+ const OPAIREF = 'GitHub Copilot 计费文档 2026-10-18 抓取(USD/MTok 默认档,与 OpenAI 公告口径交叉核实;缓存写入价不在三价目位内)';
43
+ const GEOREF = 'GitHub Copilot 计费文档 2026-10-18 抓取(USD/MTok,与 Google 公告口径交叉核实)';
29
44
  /** 内置典型价目目录(CNY/百万 token)。 */
30
45
  export const PRICE_CATALOG = [
31
46
  {
@@ -100,6 +115,64 @@ export const PRICE_CATALOG = [
100
115
  { key: 'ernie-4.5', label: 'Ernie-4.5', aliases: ['ernie-4.5'], cn: { flat: { inputCacheHit: 0.8, inputMiss: 4, output: 16 } }, asOf: '2026-10-17', source: PEAKREF },
101
116
  { key: 'ernie-4.5-turbo', label: 'Ernie-4.5-Turbo', aliases: ['ernie-4.5-turbo'], cn: { flat: { inputCacheHit: 0.16, inputMiss: 0.8, output: 3.2 } }, asOf: '2026-10-17', source: PEAKREF },
102
117
  { key: 'ernie-x1', label: 'Ernie-X1', aliases: ['ernie-x1'], cn: { flat: { inputCacheHit: 0.4, inputMiss: 2, output: 8 } }, asOf: '2026-10-17', source: PEAKREF },
118
+ // ---- 海外 USD 行(2026-10-18 补录;均无峰谷分时,global 平价) ----
119
+ {
120
+ key: 'claude-fable-5.1', label: 'Claude-Fable-5.1', aliases: ['claude-fable-5.1', 'fable-5.1'],
121
+ global: { flat: { inputCacheHit: 0.25, inputMiss: 10, output: 50 } },
122
+ asOf: '2026-10-18', source: ANOFF,
123
+ },
124
+ {
125
+ key: 'claude-opus-5.5', label: 'Claude-Opus-5.5', aliases: ['claude-opus-5.5', 'opus-5.5'],
126
+ global: { flat: { inputCacheHit: 0.2, inputMiss: 4, output: 20 } },
127
+ asOf: '2026-10-18', source: ANOFF,
128
+ },
129
+ {
130
+ key: 'claude-sonnet-5.5', label: 'Claude-Sonnet-5.5', aliases: ['claude-sonnet-5.5', 'sonnet-5.5'],
131
+ global: { flat: { inputCacheHit: 0.1, inputMiss: 2, output: 10 } },
132
+ asOf: '2026-10-18', source: ANOFF,
133
+ },
134
+ {
135
+ key: 'claude-haiku-5.5', label: 'Claude-Haiku-5.5', aliases: ['claude-haiku-5.5', 'haiku-5.5'],
136
+ // 官方两档价:≤100K prompt 取低档(>100K 为 0.05/0.50/2.50)。
137
+ global: { flat: { inputCacheHit: 0.01, inputMiss: 0.1, output: 0.5 } },
138
+ asOf: '2026-10-18', source: `${ANOFF};>100K prompt 档未录`,
139
+ },
140
+ {
141
+ key: 'gpt-6-astra', label: 'GPT-6-Astra', aliases: ['gpt-6-astra'],
142
+ global: { flat: { inputCacheHit: 1, inputMiss: 10, output: 50 } },
143
+ asOf: '2026-10-18', source: OPAIREF,
144
+ },
145
+ {
146
+ key: 'gpt-6-sol', label: 'GPT-6-Sol', aliases: ['gpt-6-sol'],
147
+ global: { flat: { inputCacheHit: 0.2, inputMiss: 2, output: 10 } },
148
+ asOf: '2026-10-18', source: OPAIREF,
149
+ },
150
+ {
151
+ key: 'gpt-6-luna', label: 'GPT-6-Luna', aliases: ['gpt-6-luna'],
152
+ global: { flat: { inputCacheHit: 0.01, inputMiss: 0.1, output: 0.5 } },
153
+ asOf: '2026-10-18', source: OPAIREF,
154
+ },
155
+ {
156
+ key: 'gpt-6.1-sol', label: 'GPT-6.1-Sol', aliases: ['gpt-6.1-sol'],
157
+ global: { flat: { inputCacheHit: 0.1, inputMiss: 2, output: 10 } },
158
+ asOf: '2026-10-18', source: OPAIREF,
159
+ },
160
+ {
161
+ key: 'gemini-4-argon', label: 'Gemini-4-Argon', aliases: ['gemini-4-argon'],
162
+ // 介绍价至 2026-11-30;届后标准价 $4/$0.20/$20 需改录并重跑 golden。
163
+ global: { flat: { inputCacheHit: 0.1, inputMiss: 2, output: 10 } },
164
+ asOf: '2026-10-18', source: `${GEOREF};介绍价止 2026-11-30,后转 $4/0.20/20`,
165
+ },
166
+ {
167
+ key: 'gemini-3.7-flash', label: 'Gemini-3.7-Flash', aliases: ['gemini-3.7-flash'],
168
+ global: { flat: { inputCacheHit: 0.075, inputMiss: 0.75, output: 3.75 } },
169
+ asOf: '2026-10-18', source: `${GEOREF};促销价止 2026-12-31`,
170
+ },
171
+ {
172
+ key: 'gemini-3.8-flash', label: 'Gemini-3.8-Flash', aliases: ['gemini-3.8-flash'],
173
+ global: { flat: { inputCacheHit: 0.075, inputMiss: 0.75, output: 3.75 } },
174
+ asOf: '2026-10-18', source: `${GEOREF};促销价止 2026-12-31`,
175
+ },
103
176
  ];
104
177
  /**
105
178
  * 中国法定节假日修正表(北京时间 YYYY-MM-DD → isOffDay),2026 年国务院安排
@@ -218,15 +291,22 @@ export function resolveRate(model, provider, timeMs, snapshot) {
218
291
  : snapshot.defaultPricing);
219
292
  const miss = (row) => viaDefault ? { ...row, source: 'catalog-miss' } : row;
220
293
  if (policy === 'off')
221
- return miss({ row: null, tier: null, currency: null, source: 'off', entry, priced: false });
294
+ return miss({ row: null, tier: null, currency: null, source: 'off', entry, priced: false, estimated: false });
222
295
  if (policy === 'custom') {
223
296
  const custom = explicit?.custom;
224
297
  if (custom === undefined)
225
- return miss({ row: null, tier: null, currency: null, source: 'custom', entry, priced: false });
226
- return miss({ row: { inputMiss: custom.inputMiss, inputCacheHit: custom.inputCacheHit, output: custom.output }, tier: 'flat', currency: custom.currency, source: 'custom', entry, priced: true });
298
+ return miss({ row: null, tier: null, currency: null, source: 'custom', entry, priced: false, estimated: false });
299
+ return miss({ row: { inputMiss: custom.inputMiss, inputCacheHit: custom.inputCacheHit, output: custom.output }, tier: 'flat', currency: custom.currency, source: 'custom', entry, priced: true, estimated: false });
300
+ }
301
+ // 目录外 + 非 off/custom 档(缺省 estimate,或显式选 cn/global 校准档),
302
+ // 或显式 estimate 命中目录内(取不到地区行):取典型价兜底估算并标
303
+ // estimated——展示侧带「未校准·仅供参考」,不再显示「未计价」。
304
+ // 命中条目但地区无行(如 global 留空期)不回退兜底。
305
+ if (entry === null || policy === 'estimate') {
306
+ return miss({ row: { ...BILLING_FALLBACK.row }, tier: 'flat', currency: BILLING_FALLBACK.currency, source: policy, entry, priced: true, estimated: true });
227
307
  }
228
- const picked = entry === null ? null : regionRow(entry, policy, timeMs);
308
+ const picked = regionRow(entry, policy, timeMs);
229
309
  if (picked === null)
230
- return miss({ row: null, tier: null, currency: null, source: policy, entry, priced: false });
231
- return miss({ ...picked, source: policy, entry, priced: true });
310
+ return miss({ row: null, tier: null, currency: null, source: policy, entry, priced: false, estimated: false });
311
+ return miss({ ...picked, source: policy, entry, priced: true, estimated: false });
232
312
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-thinking-levels",
3
- "version": "4.3.2",
3
+ "version": "4.3.3",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org",
6
6
  "access": "public",