@serviceme/devtools-shared 0.4.6 → 0.4.8

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/dist/index.mjs CHANGED
@@ -1,3 +1,19 @@
1
+ // src/ai/protocol.ts
2
+ function protocolForBaseUrl(baseUrl) {
3
+ try {
4
+ const url = new URL(baseUrl);
5
+ return /(^|\/)anthropic(\/|$)/i.test(url.pathname) ? "anthropic" : "openai";
6
+ } catch {
7
+ return "openai";
8
+ }
9
+ }
10
+ function effectiveAdapterType(configuredType, baseUrl) {
11
+ if (configuredType === "zhipu" && protocolForBaseUrl(baseUrl) === "anthropic") {
12
+ return "anthropic-compatible";
13
+ }
14
+ return configuredType;
15
+ }
16
+
1
17
  // src/ai/providers.base-url.ts
2
18
  var PROVIDER_BASE_URL_PRESETS = {
3
19
  "openai-compatible": [],
@@ -12,19 +28,60 @@ var PROVIDER_BASE_URL_PRESETS = {
12
28
  { label: "\u5168\u7403", baseUrl: "https://api.moonshot.ai/v1" }
13
29
  ],
14
30
  zhipu: [
15
- // Zhipu's OpenAI-compatible Chat Completions endpoint is the
16
- // `/api/paas/v4` path on `open.bigmodel.cn` (per
17
- // https://docs.bigmodel.cn/cn/guide/develop/http/introduction
18
- // "请求端点(通用API)"). Earlier entries on this dropdown were
19
- // wrong:
20
- // - `/api/agent` is Zhipu's *Agent* (intelligent-agent) API
21
- // surface, not chat completions sending GLM model ids
22
- // there returns 4xx.
23
- // - `api.zhipuai.com/v1` was the v3-era host and has since
24
- // been migrated to `bigmodel.cn`.
25
- // Zhipu does not publish a separate regional endpoint, so only
26
- // the official host is offered here (single-entry dropdown).
27
- { label: "\u5B98\u65B9", baseUrl: "https://open.bigmodel.cn/api/paas/v4" }
31
+ // Zhipu / 智谱 GLM 6 endpoint paths × 2 hosts. The 4
32
+ // "credential channels" the GLM-for-copilot reference
33
+ // distinguishes (region × apiMode each with its own API
34
+ // key) collapse to a 6-row baseUrl dropdown here because we
35
+ // keep one API key per provider, not one per channel. The
36
+ // user picks the host + path that matches the API key
37
+ // they actually have; the curated `MODEL_METADATA` prices
38
+ // are host-based (CNY vs USD via `currencyForBaseUrl`).
39
+ //
40
+ // Source: https://bigmodel.cn/pricing (CN platform, CNY) +
41
+ // https://z.ai/pricing (international, USD). The 6 paths
42
+ // map to:
43
+ // - `/api/paas/v4` → 标准 API (Standard)
44
+ // - `/api/coding/paas/v4` → Coding Plan (订阅套餐)
45
+ // - `/api/anthropic` → Anthropic 兼容协议
46
+ //
47
+ // Earlier single-entry dropdown omitted the Coding Plan
48
+ // path and the international Z.ai host entirely — users on
49
+ // the Coding Plan subscription were 404'ing because they
50
+ // pasted `open.bigmodel.cn/api/paas/v4` into a Coding Plan
51
+ // key, and Z.ai users had no preset to pick.
52
+ // ── 国内 (open.bigmodel.cn — CNY) ───────────────────────
53
+ {
54
+ label: "\u56FD\u5185 \xB7 \u6807\u51C6 API",
55
+ baseUrl: "https://open.bigmodel.cn/api/paas/v4"
56
+ },
57
+ {
58
+ label: "\u56FD\u5185 \xB7 Coding Plan",
59
+ baseUrl: "https://open.bigmodel.cn/api/coding/paas/v4"
60
+ },
61
+ // 重要:Anthropic 协议端点 **复用** Coding Plan 的 key(与
62
+ // `/api/coding/paas/v4` 共用同一凭证;不是 Standard API key,
63
+ // 也没有独立的 "Anthropic API key")。
64
+ // Reference: `docs/references/GLM-for-copilot-main/src/i18n.ts:578-579`
65
+ // "Coding Plan and Standard API credentials are independent.
66
+ // OpenAI and Anthropic endpoints in the same region share
67
+ // the Coding Plan key."
68
+ // label 故意重复 "Coding Plan" 两次,让用户从下拉里一眼看出:
69
+ // (a) 这个端点**只能配 Coding Plan key**;
70
+ // (b) 这是 Coding Plan 的**协议变体**,不是 Standard API 的。
71
+ {
72
+ label: "\u56FD\u5185 \xB7 Coding Plan \xB7 Anthropic \u534F\u8BAE",
73
+ baseUrl: "https://open.bigmodel.cn/api/anthropic"
74
+ },
75
+ // ── 国际 (api.z.ai — USD) ───────────────────────────────
76
+ { label: "\u56FD\u9645 \xB7 \u6807\u51C6 API", baseUrl: "https://api.z.ai/api/paas/v4" },
77
+ {
78
+ label: "\u56FD\u9645 \xB7 Coding Plan",
79
+ baseUrl: "https://api.z.ai/api/coding/paas/v4"
80
+ },
81
+ {
82
+ label: "\u56FD\u9645 \xB7 Coding Plan \xB7 Anthropic \u534F\u8BAE",
83
+ baseUrl: "https://api.z.ai/api/anthropic"
84
+ }
28
85
  ],
29
86
  stepfun: [{ label: "\u5B98\u65B9", baseUrl: "https://api.stepfun.com/v1" }],
30
87
  siliconflow: [
@@ -37,6 +94,8 @@ var PROVIDER_BASE_URL_PRESETS = {
37
94
  { label: "\u56FD\u5185", baseUrl: "https://api.agnes-ai.cn/v1" },
38
95
  { label: "\u5168\u7403", baseUrl: "https://apihub.agnes-ai.com/v1" }
39
96
  ],
97
+ // Medalsoft internal LLM gateway — single OpenAI-compatible endpoint.
98
+ medalsoft: [{ label: "\u5185\u90E8\u7F51\u5173", baseUrl: "https://llm.proxy.alio.wang/v1" }],
40
99
  "vscode-builtin": []
41
100
  };
42
101
  function getProviderBaseUrlPresets(type) {
@@ -64,6 +123,12 @@ var PROVIDER_CACHE_CONTROL_METADATA = {
64
123
  agnes: {
65
124
  supportsCacheControl: true
66
125
  },
126
+ // Medalsoft internal gateway — OpenAI-compatible pass-through; the
127
+ // upstream's prompt-cache behaviour is unknown from outside, so we
128
+ // don't declare support (no `prompt_cache_key` header is written).
129
+ // Flip to `supportsCacheControl: true` once the gateway is verified
130
+ // to honour stable prompt caching.
131
+ medalsoft: {},
67
132
  "vscode-builtin": {}
68
133
  };
69
134
  function isProviderCacheControlAware(type) {
@@ -104,8 +169,17 @@ var PRIMARY_METADATA = {
104
169
  detail: "M2.7 high-speed: same quality, faster (~100 TPS)",
105
170
  imageInput: false,
106
171
  toolCalling: true,
172
+ // Per https://minimax-ai.chat/pricing (2026-07 verified):
173
+ // M2.7-highspeed is 2× M2.7 base on input/output, but
174
+ // identical on cache hit (same model + same infra, just a
175
+ // serving-side TPS bump). The CNY values mirror USD at the
176
+ // project's 1:7 CNY-per-USD convention.
177
+ // Previously the CNY input/output were the same as base
178
+ // (¥2.1 / ¥8.4) while USD was already 2× — that left the
179
+ // USD/CNY ratio at 3.5× instead of 7× and silently
180
+ // under-reported CNY cost for users on the China platform.
107
181
  pricingUSD: { input: 0.6, output: 2.4, cacheRead: 0.06 },
108
- pricingCNY: { input: 2.1, output: 8.4, cacheRead: 0.42 },
182
+ pricingCNY: { input: 4.2, output: 16.8, cacheRead: 0.42 },
109
183
  priceCategory: "low",
110
184
  // Inherits M2.7's context window.
111
185
  maxInputTokens: 131072,
@@ -115,8 +189,20 @@ var PRIMARY_METADATA = {
115
189
  detail: "Fast, general-purpose model",
116
190
  imageInput: true,
117
191
  toolCalling: true,
118
- pricingUSD: { input: 0.14, output: 0.28, cacheRead: 28e-4 },
119
- pricingCNY: { input: 1, output: 2, cacheRead: 0.02 },
192
+ // Per https://api-docs.deepseek.com/quick_start/pricing/ and
193
+ // https://new.qq.com/rain/a/20260813A0DROS00 (2026-08-13
194
+ // announcement, effective 2026-08-17 00:00 Beijing): peak/
195
+ // off-peak tiered pricing. Pinned the OFF-PEAK rate since
196
+ // peak hours (01:00–04:00 + 06:00–10:00 UTC = 09:00–12:00 +
197
+ // 14:00–18:00 Beijing) cover only 8 of 24 hours — most chat
198
+ // sessions land off-peak. Peak is exactly 2× off-peak per
199
+ // the official page.
200
+ // Off-peak: $0.007 cache hit / $0.22 input / $0.66 output
201
+ // ¥0.05 cache hit / ¥1.5 input / ¥4.5 output
202
+ // The pre-2026-08-17 rate was 1/3 of the current off-peak;
203
+ // 8/17 调价 raised cache hit 6× and output 2.25×.
204
+ pricingUSD: { input: 0.22, output: 0.66, cacheRead: 7e-3 },
205
+ pricingCNY: { input: 1.5, output: 4.5, cacheRead: 0.05 },
120
206
  priceCategory: "low",
121
207
  // Official docs (api-docs.deepseek.com/quick_start/pricing, fetched
122
208
  // 2026-07-27): "THINKING MODE: Supports both non-thinking and
@@ -132,8 +218,20 @@ var PRIMARY_METADATA = {
132
218
  detail: "Most capable reasoning model",
133
219
  imageInput: true,
134
220
  toolCalling: true,
135
- pricingUSD: { input: 0.435, output: 0.87, cacheRead: 3625e-6 },
136
- pricingCNY: { input: 2.1, output: 4.2, cacheRead: 0.025 },
221
+ // Per https://api-docs.deepseek.com/quick_start/pricing/ and
222
+ // https://new.qq.com/rain/a/20260813A0DROS00 (2026-08-13
223
+ // announcement, effective 2026-08-17 00:00 Beijing): peak/
224
+ // off-peak tiered pricing. Pinned the OFF-PEAK rate (peak
225
+ // hours are 8/24; most chat sessions land off-peak; peak is
226
+ // exactly 2× off-peak per the official page).
227
+ // Off-peak: $0.022 cache hit / $0.66 input / $1.98 output
228
+ // ¥0.15 cache hit / ¥4.5 input / ¥13.5 output
229
+ // The 8/17 调价 raised cache hit 6× (¥0.025 → ¥0.15),
230
+ // input 1.5×, and output 2.25×. The pre-08-17 USD values
231
+ // (0.435/0.87/0.003625) and CNY values (2.1/4.2/0.025) did
232
+ // not correspond to any DeepSeek-published rate; corrected.
233
+ pricingUSD: { input: 0.66, output: 1.98, cacheRead: 0.022 },
234
+ pricingCNY: { input: 4.5, output: 13.5, cacheRead: 0.15 },
137
235
  priceCategory: "low",
138
236
  thinkingSchema: "thinkingEnabled",
139
237
  maxInputTokens: 655360,
@@ -176,6 +274,44 @@ var PRIMARY_METADATA = {
176
274
  maxInputTokens: 934976,
177
275
  maxOutputTokens: 65536
178
276
  },
277
+ "agnes-2.5-pro": {
278
+ detail: "Paid reasoning model \u2014 commercial stable of 2.5 Pro Alpha (advanced coding, scientific reasoning, long context, multimodal). 1M context / 65K max output",
279
+ imageInput: true,
280
+ toolCalling: true,
281
+ // Official pricing per https://wiki.agnes-ai.com/en/docs/agnes-25-pro.md
282
+ // (fetched 2026-08-19) — identical to 2.5 Pro Alpha:
283
+ // $0.45 input / $0.0038 cache read / $0.90 output per 1M tokens.
284
+ // No separate CNY tier is published, so pricingCNY mirrors USD.
285
+ pricingUSD: { input: 0.45, output: 0.9, cacheRead: 38e-4 },
286
+ pricingCNY: { input: 0.45, output: 0.9, cacheRead: 38e-4 },
287
+ priceCategory: "medium",
288
+ // Same binary Thinking on/off switch as the other Agnes models
289
+ // (`chat_template_kwargs.enable_thinking` on the OpenAI wire).
290
+ thinkingSchema: "thinkingEnabled",
291
+ // Same published window as 2.5 Pro Alpha: 1M context /
292
+ // 65536 max output — input cap mirrors the alpha entry.
293
+ maxInputTokens: 934976,
294
+ maxOutputTokens: 65536
295
+ },
296
+ "agnes-2.5-flash": {
297
+ detail: "GA upgrade of Agnes 2.0 Flash \u2014 stronger coding, agent workflows, tool calling, image understanding (512K context)",
298
+ imageInput: true,
299
+ toolCalling: true,
300
+ // Standard (post-promo) pricing per
301
+ // https://wiki.agnes-ai.com/en/docs/agnes-25-flash.md (fetched
302
+ // 2026-08-19) — same list price as 2.0 Flash ($0.03 / $0.15 per
303
+ // 1M tokens); the temporary $0 / $0 promo is ignored per the
304
+ // same policy as the 2.0 Flash entry. No separate CNY tier is
305
+ // published, so pricingCNY mirrors the USD numbers.
306
+ pricingUSD: { input: 0.03, output: 0.15, cacheRead: null },
307
+ pricingCNY: { input: 0.03, output: 0.15, cacheRead: null },
308
+ priceCategory: "low",
309
+ // Same binary Thinking on/off switch as 2.0 Flash
310
+ // (`chat_template_kwargs.enable_thinking` on the OpenAI wire).
311
+ thinkingSchema: "thinkingEnabled",
312
+ maxInputTokens: 512e3,
313
+ maxOutputTokens: 65536
314
+ },
179
315
  // ── Kimi (月之暗面 / Moonshot AI) ────────────────────────────────
180
316
  // Source: https://platform.kimi.com/docs/pricing/chat-k3,
181
317
  // chat-k27-code, chat-k26 (fetched 2026-07-27). Prices are per 1M
@@ -261,10 +397,21 @@ var PRIMARY_METADATA = {
261
397
  // GLM-5's explicit "Agentic 长程规划与执行" description. Corrected
262
398
  // from false (inconsistent with the rest of the GLM-5 family).
263
399
  "glm-5.2": {
264
- detail: "GLM-5.2 \u2014 1M \u4E0A\u4E0B\u6587\uFF0C\u6700\u5927\u8F93\u51FA 128K",
400
+ detail: "GLM-5.2 \u2014 1M \u4E0A\u4E0B\u6587\uFF0C\u6700\u5927\u8F93\u51FA 128K\uFF08\u5355\u6863 pricing\uFF09",
265
401
  imageInput: false,
266
402
  toolCalling: true,
267
- // ¥8 input / ¥28 output / ¥2 cache hit per 1M tokens (输入长度 32K+ 档)
403
+ // Thinking-mode dropdown + `reasoning_effort`. Zhipu official
404
+ // OpenAPI (fetched 2026-08-19): "仅 GLM-5.2 及其以上模型支持"
405
+ // reasoning_effort; for 5.2 the server maps none/minimal → give
406
+ // up thinking, low/medium → high, xhigh → max (we only send the
407
+ // native high/max so no client-side aliasing is needed).
408
+ thinkingSchema: "reasoningEffort",
409
+ supportsReasoningEffort: true,
410
+ // Single rate (no input-length tier split) per
411
+ // bigmodel.cn/pricing 2026-08-18:
412
+ // ¥8 input / ¥28 output / ¥2 cache hit per 1M tokens
413
+ // The previous entry's comment said "输入长度 32K+ 档" — that
414
+ // was wrong: GLM-5.2 has no tier split on the official page.
268
415
  pricingUSD: { input: 1.12, output: 3.92, cacheRead: 0.28 },
269
416
  pricingCNY: { input: 8, output: 28, cacheRead: 2 },
270
417
  priceCategory: "high",
@@ -281,6 +428,14 @@ var PRIMARY_METADATA = {
281
428
  detail: "GLM-5.3 \u2014 1M \u4E0A\u4E0B\u6587\uFF0C\u540E\u8BAD\u7EC3\u589E\u5F3A\u4EE3\u7801 / \u7F51\u7EDC\u5B89\u5168",
282
429
  imageInput: false,
283
430
  toolCalling: true,
431
+ // Thinking-mode dropdown (思考模式 停用/标准/深度) + the
432
+ // `reasoning_effort` field. Zhipu official OpenAPI (fetched
433
+ // 2026-08-19): GLM-5.3 restricts `thinking.type` to "enabled"
434
+ // and controls depth via `reasoning_effort` (low/high/max
435
+ // only). Mirrors `supportsReasoningEffort: true` in
436
+ // `docs/references/GLM-for-copilot-main/src/consts.ts`.
437
+ thinkingSchema: "reasoningEffort",
438
+ supportsReasoningEffort: true,
284
439
  // Vendor-published USD price (Decrypt, 2026-08-14). Cache-hit price
285
440
  // has not been published — the picker shows "(not published)" rather
286
441
  // than fabricating a number (the rate usually diverges 4–10× from
@@ -299,74 +454,105 @@ var PRIMARY_METADATA = {
299
454
  // (model id `glm-5.1-highspeed`). Pricing mirrors GLM-5.1 since the
300
455
  // rate is identical architecture — TileRT is a serving-side optim.
301
456
  "glm-5.1-highspeed": {
302
- detail: "GLM-5.1 HighSpeed \u2014 400 TPS \u9AD8\u541E\u5410\u751F\u4EA7\u53D8\u4F53",
457
+ detail: "GLM-5.1 HighSpeed \u2014 400 TPS \u9AD8\u541E\u5410\u751F\u4EA7\u53D8\u4F53\uFF08[0, 32K) tier \u955C\u50CF GLM-5.1\uFF09",
303
458
  imageInput: false,
304
459
  toolCalling: true,
460
+ // Thinking switch (no reasoning_effort — 5.1 < 5.2 threshold).
461
+ thinkingSchema: "reasoningEffort",
462
+ // Mirrors GLM-5.1 [0, 32K) tier per bigmodel.cn/pricing 2026-08-18.
463
+ // TileRT is a serving-side optim; the per-token rate is the same
464
+ // architecture as the base model.
305
465
  pricingUSD: { input: 0.6, output: 2.2, cacheRead: 0.11 },
306
- pricingCNY: { input: 4.3, output: 15.7, cacheRead: 0.79 },
466
+ pricingCNY: { input: 6, output: 24, cacheRead: 1.3 },
307
467
  priceCategory: "medium",
308
468
  maxInputTokens: 2e5,
309
469
  maxOutputTokens: 128e3
310
470
  },
311
- // GLM-4.7-Flash (2026-01-19) — free-tier version of GLM-4.7, lightweight
312
- // + high-frequency optimised. Coding / writing / translation /
313
- // reasoning at "best-in-class-for-its-size" per the Zhipu release notes;
314
- // the "Flash" tier is distinct from `glm-4.7-flashx` (the latter is the
315
- // 快速版 without tool calling; this Flash is the full-feature lite).
471
+ // GLM-4.7-Flash (2026-01-19) — 200K context, fully-free tier on
472
+ // bigmodel.cn/pricing (fetched 2026-08-18). Lightweight + high-
473
+ // frequency optimised; coding / writing / translation / reasoning
474
+ // at "best-in-class-for-its-size" per the Zhipu release notes.
475
+ // Distinct from `glm-4.7-flashx` (the latter is the 快速版 with
476
+ // paid pricing).
316
477
  "glm-4.7-flash": {
317
- detail: "GLM-4.7 Flash \u2014 \u8F7B\u91CF\u514D\u8D39\u7248\uFF0C200K \u4E0A\u4E0B\u6587",
478
+ detail: "GLM-4.7 Flash \u2014 \u5B8C\u5168\u514D\u8D39\uFF08200K \u4E0A\u4E0B\u6587\uFF09",
318
479
  imageInput: false,
319
480
  toolCalling: true,
320
- // Free tier public pricing page lists the model as "免费" with no
321
- // input/output rate. Numbers below are conservative estimates based
322
- // on the GLM-3-Turbo "入门级 ¥1/1M tokens" reference; the provider
323
- // has not published a cache rate either, so cacheRead is null.
324
- pricingUSD: { input: 0.06, output: 0.21, cacheRead: null },
325
- pricingCNY: { input: 0.4, output: 1.5, cacheRead: null },
481
+ // Thinking switch (no reasoning_effort 4.7 < 5.2 threshold).
482
+ thinkingSchema: "reasoningEffort",
483
+ // Free tier input / output / cache hit all 0 (bigmodel.cn
484
+ // 2026-08-18 lists "免费" for every column). USD mirrors CNY
485
+ // rather than inventing a rate.
486
+ pricingUSD: { input: 0, output: 0, cacheRead: 0 },
487
+ pricingCNY: { input: 0, output: 0, cacheRead: 0 },
326
488
  priceCategory: "low",
327
489
  maxInputTokens: 2e5,
328
490
  maxOutputTokens: 128e3
329
491
  },
330
492
  "glm-4.7": {
331
- detail: "200K \u4E0A\u4E0B\u6587\uFF0C\u5DE5\u5177\u8C03\u7528",
493
+ detail: "GLM-4.7 \u2014 200K \u4E0A\u4E0B\u6587\uFF0C\u5DE5\u5177\u8C03\u7528\uFF083-tier pricing\uFF09",
332
494
  imageInput: false,
333
495
  toolCalling: true,
334
- // cc-switch 标价:$0.6 input / $2.2 output
335
- pricingUSD: { input: 0.6, output: 2.2, cacheRead: 0.11 },
336
- pricingCNY: { input: 4.3, output: 15.7, cacheRead: 0.79 },
496
+ // Thinking switch (GLM-4.7 forces thinking when enabled per the
497
+ // official ChatThinking doc; no reasoning_effort — 4.7 < 5.2).
498
+ thinkingSchema: "reasoningEffort",
499
+ // Pinned the LOWEST tier per bigmodel.cn/pricing 2026-08-18:
500
+ // [0, 32K) input × [0, 0.2K) output — ¥2 / ¥8 / ¥0.4 cache hit
501
+ // [0, 32K) input × [0.2K+) output — ¥3 / ¥14 / ¥0.6 cache hit
502
+ // [32K, 200K) input — ¥4 / ¥16 / ¥0.8 cache hit
503
+ // Most real prompts are < 32K input and < 0.2K output, so the
504
+ // lowest tier is the most representative per-request price.
505
+ // Re-pick from a higher tier if the picker adds a length slider.
506
+ pricingUSD: { input: 0.28, output: 1.12, cacheRead: 0.056 },
507
+ pricingCNY: { input: 2, output: 8, cacheRead: 0.4 },
337
508
  priceCategory: "medium",
338
509
  maxInputTokens: 2e5,
339
510
  maxOutputTokens: 128e3
340
511
  },
341
512
  "glm-5.1": {
342
- detail: "GLM-5.1 \u2014 200K \u4E0A\u4E0B\u6587\uFF0C\u6700\u5927\u8F93\u51FA 128K",
513
+ detail: "GLM-5.1 \u2014 200K \u4E0A\u4E0B\u6587\uFF0C\u6700\u5927\u8F93\u51FA 128K\uFF082-tier pricing\uFF09",
343
514
  imageInput: false,
344
515
  toolCalling: true,
345
- // ¥8 input / ¥28 output / ¥2 cache hit per 1M tokens (输入长度 32K+ 档)
346
- pricingUSD: { input: 1.12, output: 3.92, cacheRead: 0.28 },
347
- pricingCNY: { input: 8, output: 28, cacheRead: 2 },
516
+ // Thinking switch (no reasoning_effort 5.1 < 5.2 threshold).
517
+ thinkingSchema: "reasoningEffort",
518
+ // Pinned the LOWER tier per bigmodel.cn/pricing 2026-08-18:
519
+ // [0, 32K) — ¥6 input / ¥24 output / ¥1.3 cache hit
520
+ // [32K+) — ¥8 input / ¥28 output / ¥2 cache hit
521
+ // The previous entry had the higher tier; switched to the lower
522
+ // tier so a typical < 32K prompt shows the more accurate price.
523
+ pricingUSD: { input: 0.84, output: 3.36, cacheRead: 0.182 },
524
+ pricingCNY: { input: 6, output: 24, cacheRead: 1.3 },
348
525
  priceCategory: "high",
349
526
  maxInputTokens: 2e5,
350
527
  maxOutputTokens: 128e3
351
528
  },
352
529
  "glm-5": {
353
- detail: "GLM-5 \u2014 200K \u4E0A\u4E0B\u6587\uFF0CAgentic \u5DE5\u5177\u8C03\u7528\uFF0C\u6700\u5927\u8F93\u51FA 128K",
530
+ detail: "GLM-5 \u2014 200K \u4E0A\u4E0B\u6587\uFF0CAgentic \u5DE5\u5177\u8C03\u7528\uFF0C\u6700\u5927\u8F93\u51FA 128K\uFF082-tier pricing\uFF09",
354
531
  imageInput: false,
355
532
  toolCalling: true,
356
- // ¥6 input / ¥22 output / ¥1.5 cache hit per 1M tokens (输入长度 32K+ 档)
357
- pricingUSD: { input: 0.84, output: 3.08, cacheRead: 0.21 },
358
- pricingCNY: { input: 6, output: 22, cacheRead: 1.5 },
533
+ // Thinking switch (no reasoning_effort 5 < 5.2 threshold).
534
+ thinkingSchema: "reasoningEffort",
535
+ // Pinned the LOWER tier per bigmodel.cn/pricing 2026-08-18:
536
+ // [0, 32K) — ¥4 input / ¥18 output / ¥1 cache hit
537
+ // [32K+) — ¥6 input / ¥22 output / ¥1.5 cache hit
538
+ pricingUSD: { input: 0.56, output: 2.52, cacheRead: 0.14 },
539
+ pricingCNY: { input: 4, output: 18, cacheRead: 1 },
359
540
  priceCategory: "high",
360
541
  maxInputTokens: 2e5,
361
542
  maxOutputTokens: 128e3
362
543
  },
363
544
  "glm-5-turbo": {
364
- detail: "GLM-5 Turbo \u2014 200K \u4E0A\u4E0B\u6587\uFF0C\u6700\u5927\u8F93\u51FA 128K",
545
+ detail: "GLM-5 Turbo \u2014 200K \u4E0A\u4E0B\u6587\uFF0C\u6700\u5927\u8F93\u51FA 128K\uFF082-tier pricing\uFF09",
365
546
  imageInput: false,
366
547
  toolCalling: true,
367
- // ¥7 input / ¥26 output / ¥1.8 cache hit per 1M tokens (输入长度 32K+ 档)
368
- pricingUSD: { input: 0.98, output: 3.64, cacheRead: 0.252 },
369
- pricingCNY: { input: 7, output: 26, cacheRead: 1.8 },
548
+ // Thinking switch (listed in the official ChatThinking doc's
549
+ // auto-think family; no reasoning_effort 5-Turbo < 5.2).
550
+ thinkingSchema: "reasoningEffort",
551
+ // Pinned the LOWER tier per bigmodel.cn/pricing 2026-08-18:
552
+ // [0, 32K) — ¥5 input / ¥22 output / ¥1.2 cache hit
553
+ // [32K+) — ¥7 input / ¥26 output / ¥1.8 cache hit
554
+ pricingUSD: { input: 0.7, output: 3.08, cacheRead: 0.168 },
555
+ pricingCNY: { input: 5, output: 22, cacheRead: 1.2 },
370
556
  priceCategory: "medium",
371
557
  maxInputTokens: 2e5,
372
558
  maxOutputTokens: 128e3
@@ -375,6 +561,8 @@ var PRIMARY_METADATA = {
375
561
  detail: "GLM-4.7 FlashX \u2014 \u5FEB\u901F\u7248",
376
562
  imageInput: false,
377
563
  toolCalling: false,
564
+ // Thinking switch (4.7 family; no reasoning_effort).
565
+ thinkingSchema: "reasoningEffort",
378
566
  // ¥0.5 input / ¥3 output / ¥0.1 cache hit per 1M tokens
379
567
  pricingUSD: { input: 0.07, output: 0.42, cacheRead: 0.014 },
380
568
  pricingCNY: { input: 0.5, output: 3, cacheRead: 0.1 },
@@ -386,6 +574,9 @@ var PRIMARY_METADATA = {
386
574
  detail: "GLM-4.6 \u2014 \u5DE5\u5177\u8C03\u7528",
387
575
  imageInput: false,
388
576
  toolCalling: true,
577
+ // Thinking switch (auto-think family per the official
578
+ // ChatThinking doc; no reasoning_effort — 4.6 < 5.2).
579
+ thinkingSchema: "reasoningEffort",
389
580
  pricingUSD: { input: 0.6, output: 2.2, cacheRead: 0.11 },
390
581
  pricingCNY: { input: 4.3, output: 15.7, cacheRead: 0.79 },
391
582
  priceCategory: "medium",
@@ -407,6 +598,9 @@ var PRIMARY_METADATA = {
407
598
  detail: "GLM-4.5 \u2014 \u5DE5\u5177\u8C03\u7528\uFF08\u88F8\u540D\uFF1BZhipu /v1/models \u66B4\u9732\u7684 legacy alias\uFF09",
408
599
  imageInput: false,
409
600
  toolCalling: true,
601
+ // Thinking switch (4.5 generation is the thinking-param floor
602
+ // per the official ChatThinking doc; no reasoning_effort).
603
+ thinkingSchema: "reasoningEffort",
410
604
  pricingUSD: { input: 0, output: 0, cacheRead: null },
411
605
  pricingCNY: { input: 0, output: 0, cacheRead: null },
412
606
  priceCategory: "low",
@@ -414,23 +608,38 @@ var PRIMARY_METADATA = {
414
608
  maxOutputTokens: 96e3
415
609
  },
416
610
  "glm-4.5-air": {
417
- detail: "GLM-4.5 Air \u2014 \u5DE5\u5177\u8C03\u7528",
611
+ detail: "GLM-4.5 Air \u2014 \u5DE5\u5177\u8C03\u7528\uFF083-tier pricing\uFF09",
418
612
  imageInput: false,
419
613
  toolCalling: true,
420
- pricingUSD: { input: 0, output: 0, cacheRead: null },
421
- pricingCNY: { input: 0, output: 0, cacheRead: null },
614
+ // Thinking switch (4.5 family; no reasoning_effort).
615
+ thinkingSchema: "reasoningEffort",
616
+ // Pinned the LOWEST tier per bigmodel.cn/pricing 2026-08-18:
617
+ // [0, 32K) × [0, 0.2K) output — ¥0.8 / ¥2 / ¥0.16 cache hit
618
+ // [0, 32K) × [0.2K+) output — ¥0.8 / ¥6 / ¥0.16 cache hit
619
+ // [32K, 128K) — ¥1.2 / ¥8 / ¥0.24 cache hit
620
+ // All cache-hit rates are 4× lower than input — the
621
+ // explicit-cache-discount half of BYOM-depth #1.
622
+ pricingUSD: { input: 0.112, output: 0.28, cacheRead: 0.0224 },
623
+ pricingCNY: { input: 0.8, output: 2, cacheRead: 0.16 },
422
624
  priceCategory: "low",
423
625
  maxInputTokens: 128e3,
424
626
  maxOutputTokens: 96e3
425
627
  },
426
628
  "glm-4.5-airx": {
427
- detail: "GLM-4.5 AirX \u2014 \u5FEB\u901F\u7248",
629
+ detail: "GLM-4.5 AirX \u2014 \u5FEB\u901F\u7248\uFF08\xA510/M \u5355\u6863\uFF09",
428
630
  imageInput: false,
429
631
  toolCalling: false,
430
- pricingUSD: { input: 0, output: 0, cacheRead: null },
431
- pricingCNY: { input: 0, output: 0, cacheRead: null },
632
+ // Thinking switch (4.5 family; no reasoning_effort).
633
+ thinkingSchema: "reasoningEffort",
634
+ // ¥10 / M tokens (single rate, input == output) per
635
+ // bigmodel.cn/pricing 2026-08-18 — listed under the "模型推理
636
+ // → Language Models" sub-tab, NOT the flagship text section.
637
+ // 8K context window per the same sub-tab; 96K max output is a
638
+ // best-guess from sibling Air-tier models.
639
+ pricingUSD: { input: 1.4, output: 1.4, cacheRead: null },
640
+ pricingCNY: { input: 10, output: 10, cacheRead: null },
432
641
  priceCategory: "low",
433
- maxInputTokens: 128e3,
642
+ maxInputTokens: 8192,
434
643
  maxOutputTokens: 96e3
435
644
  },
436
645
  "glm-4-long": {
@@ -467,24 +676,69 @@ var PRIMARY_METADATA = {
467
676
  maxOutputTokens: 4e3
468
677
  },
469
678
  "glm-4.5v": {
470
- detail: "GLM-4.5V \u89C6\u89C9\u63A8\u7406\u6A21\u578B \u2014 \u56FE\u50CF/\u89C6\u9891/\u6587\u6863/GUI",
679
+ detail: "GLM-4.5V \u89C6\u89C9\u63A8\u7406\u6A21\u578B \u2014 \u56FE\u50CF/\u89C6\u9891/\u6587\u6863/GUI\uFF082-tier pricing\uFF09",
471
680
  imageInput: true,
472
681
  toolCalling: true,
473
- pricingUSD: { input: 0, output: 0, cacheRead: null },
474
- pricingCNY: { input: 0, output: 0, cacheRead: null },
682
+ // Thinking switch (official ChatThinking doc: GLM-4.5V 为强制
683
+ // 思考 when enabled; no reasoning_effort).
684
+ thinkingSchema: "reasoningEffort",
685
+ // Pinned the LOWER tier per bigmodel.cn/pricing 2026-08-18:
686
+ // [0, 32K) — ¥2 input / ¥6 output / ¥0.4 cache hit
687
+ // [32, 64K) — ¥4 input / ¥12 output / ¥0.8 cache hit
688
+ pricingUSD: { input: 0.28, output: 0.84, cacheRead: 0.056 },
689
+ pricingCNY: { input: 2, output: 6, cacheRead: 0.4 },
690
+ priceCategory: "medium",
691
+ maxInputTokens: 64e3,
692
+ maxOutputTokens: 8192
693
+ },
694
+ // GLM-4.6V (2026 H1) — 视觉推理模型 (paid version, 2-tier
695
+ // pricing). Distinct from `glm-4.6v-flash` (免费版, 0/0/0) and
696
+ // `glm-4.6v-flashx` (快速版, ¥0.15/¥1.5/¥0.03). Per
697
+ // bigmodel.cn/pricing 2026-08-18 (the same snapshot the
698
+ // §7 table in `byom-glm-learnings.md` was sourced from, where
699
+ // this row was first documented but never landed in
700
+ // MODEL_METADATA until 2026-08-19):
701
+ // [0, 32K) — ¥1 input / ¥3 output / ¥0.2 cache hit
702
+ // [32, 128K) — ¥2 input / ¥6 output / ¥0.4 cache hit
703
+ // The lower tier is pinned per the project's "multi-tier →
704
+ // lowest tier" convention (most prompts < 32K input × < 0.2K
705
+ // output). 4.6V sits between glm-4.5v (¥2/¥6/¥0.4) and the
706
+ // flashx variant — the 4.6 generation is meaningfully cheaper
707
+ // per the 2026 mid-year price reset.
708
+ "glm-4.6v": {
709
+ detail: "GLM-4.6V \u89C6\u89C9\u63A8\u7406\u6A21\u578B \u2014 \u56FE\u50CF/\u89C6\u9891/\u6587\u6863/GUI\uFF082-tier pricing\uFF09",
710
+ imageInput: true,
711
+ toolCalling: true,
712
+ // Thinking switch (same auto-think family as glm-4.5v;
713
+ // 4.6 < 5.2 threshold, so no reasoning_effort).
714
+ thinkingSchema: "reasoningEffort",
715
+ // Pinned the LOWER tier [0, 32K) per bigmodel.cn/pricing
716
+ // 2026-08-18. USD mirrors the CNY/7 ratio with 2-decimal
717
+ // rounding (matches glm-4.5v's USD rounding style).
718
+ pricingUSD: { input: 0.14, output: 0.42, cacheRead: 0.028 },
719
+ pricingCNY: { input: 1, output: 3, cacheRead: 0.2 },
720
+ // Tier boundary is 128K (vs glm-4.5v's 64K), so a
721
+ // `medium` tier tag is still appropriate — the 4.6V is
722
+ // cheaper than glm-4.5v but not a "low" tier like the
723
+ // 0.5/3/0.1 flashx family.
475
724
  priceCategory: "medium",
476
725
  maxInputTokens: 128e3,
477
726
  maxOutputTokens: 8192
478
727
  },
479
728
  "glm-5v-turbo": {
480
- detail: "GLM-5V Turbo \u2014 \u591A\u6A21\u6001 Coding \u6A21\u578B",
729
+ detail: "GLM-5V Turbo \u2014 \u591A\u6A21\u6001 Coding \u6A21\u578B\uFF082-tier pricing\uFF09",
481
730
  imageInput: true,
482
731
  toolCalling: true,
483
- pricingUSD: { input: 0, output: 0, cacheRead: null },
484
- pricingCNY: { input: 0, output: 0, cacheRead: null },
732
+ // Thinking switch (listed in the official ChatThinking doc's
733
+ // auto-think family; no reasoning_effort).
734
+ thinkingSchema: "reasoningEffort",
735
+ // Pinned the LOWER tier per bigmodel.cn/pricing 2026-08-18:
736
+ // [0, 32K) — ¥5 input / ¥22 output / ¥1.2 cache hit
737
+ // [32K+) — ¥7 input / ¥26 output / ¥1.8 cache hit
738
+ // Vendor-published context: 200K / 128K max output.
739
+ pricingUSD: { input: 0.7, output: 3.08, cacheRead: 0.168 },
740
+ pricingCNY: { input: 5, output: 22, cacheRead: 1.2 },
485
741
  priceCategory: "medium",
486
- // Official model overview: 200K context / 128K max output
487
- // (previously mis-set to 128K/8_192 — corrected 2026-07-27).
488
742
  maxInputTokens: 2e5,
489
743
  maxOutputTokens: 128e3
490
744
  },
@@ -512,8 +766,15 @@ var PRIMARY_METADATA = {
512
766
  // Official model page lists "🛠️ 工具调用: 可靠的工具调用能力,支持多步
513
767
  // 任务分解与计划执行" as a core capability — was mis-set to false.
514
768
  toolCalling: true,
515
- // ¥1.35 input / ¥8.1 output / ¥0.27 cache hit per 1M tokens
516
- pricingUSD: { input: 0.189, output: 1.134, cacheRead: 0.038 },
769
+ // Per https://platform.stepfun.com/docs/zh/pricing/details
770
+ // (2026-08-18 fetched): ¥1.35 input / ¥8.1 output /
771
+ // ¥0.27 cache hit per 1M tokens, USD = $0.20 / $1.15 /
772
+ // $0.04 (StepFun is USD-billed at the same rate as CNY/7
773
+ // with small rounding per the official pricing page).
774
+ // USD values previously 0.189/1.134/0.038 — slightly off
775
+ // from the official page (rounding error from dividing CNY
776
+ // by hand), corrected.
777
+ pricingUSD: { input: 0.2, output: 1.15, cacheRead: 0.04 },
517
778
  pricingCNY: { input: 1.35, output: 8.1, cacheRead: 0.27 },
518
779
  priceCategory: "medium",
519
780
  thinkingSchema: "reasoningEffort",
@@ -529,8 +790,13 @@ var PRIMARY_METADATA = {
529
790
  // Official model page lists "🛠️ 工具调用: 可靠的 tools / tool_choice
530
791
  // 调用能力" as a core capability — was mis-set to false.
531
792
  toolCalling: true,
532
- // ¥0.7 input / ¥2.1 output / ¥0.14 cache hit per 1M tokens
533
- pricingUSD: { input: 0.098, output: 0.294, cacheRead: 0.02 },
793
+ // Per https://platform.stepfun.com/docs/zh/pricing/details
794
+ // (2026-08-18 fetched): ¥0.7 input / ¥2.1 output /
795
+ // ¥0.14 cache hit per 1M tokens, USD = $0.10 / $0.30 /
796
+ // $0.02. USD values previously 0.098/0.294/0.02 — slightly
797
+ // off from the official page (rounding error), corrected
798
+ // to the exact published values.
799
+ pricingUSD: { input: 0.1, output: 0.3, cacheRead: 0.02 },
534
800
  pricingCNY: { input: 0.7, output: 2.1, cacheRead: 0.14 },
535
801
  priceCategory: "low",
536
802
  thinkingSchema: "reasoningEffort",
@@ -541,9 +807,13 @@ var PRIMARY_METADATA = {
541
807
  detail: "Step 1o Turbo Vision \u2014 \u89C6\u89C9\u6A21\u578B",
542
808
  imageInput: true,
543
809
  toolCalling: false,
544
- // ¥2.5 input / ¥8 output per 1M tokens
545
- pricingUSD: { input: 0.35, output: 1.12, cacheRead: null },
546
- pricingCNY: { input: 2.5, output: 8, cacheRead: null },
810
+ // Per https://platform.stepfun.com/docs/zh/pricing/details
811
+ // (2026-08-18 fetched): ¥2.5 cache miss / ¥0.5 cache hit /
812
+ // ¥8 output per 1M tokens. USD = $0.357 / $0.071 / $1.143
813
+ // (CNY/7 with rounding). Cache hit was previously
814
+ // undocumented in the curated entry — added.
815
+ pricingUSD: { input: 0.357, output: 1.143, cacheRead: 0.071 },
816
+ pricingCNY: { input: 2.5, output: 8, cacheRead: 0.5 },
547
817
  priceCategory: "low",
548
818
  // Official model overview: 32K context window.
549
819
  maxInputTokens: 32768,
@@ -583,8 +853,13 @@ var PRIMARY_METADATA = {
583
853
  detail: "MiniMax M2.5 \u2014 229B MoE, SOTA \u7F16\u7A0B / Agent / \u529E\u516C\u751F\u4EA7\u529B\uFF08192K \u4E0A\u4E0B\u6587\uFF09",
584
854
  imageInput: false,
585
855
  toolCalling: true,
586
- // ¥2.1 / ¥8.4 per 1M tokens; cache hit documented at ¥0.21 (按
587
- // 官方 10% cache 命中率回填)
856
+ // Per https://minimax-ai.chat/pricing (M2.5 legacy line):
857
+ // ¥2.1 input / ¥8.4 output / ¥0.21 cache hit per 1M tokens;
858
+ // USD = $0.30 / $1.20 / $0.03 (cloudprice.net 2026-08-13).
859
+ // Cache hit IS the published rate — the previous comment
860
+ // "按官方 10% cache 命中率回填" was wrong (it implied we
861
+ // were estimating, when actually the cache rate is
862
+ // documented at ¥0.21 / $0.03 per 1M tokens).
588
863
  pricingUSD: { input: 0.3, output: 1.2, cacheRead: 0.03 },
589
864
  pricingCNY: { input: 2.1, output: 8.4, cacheRead: 0.21 },
590
865
  priceCategory: "medium",
@@ -635,6 +910,20 @@ var NAMESPACE_ALIASES = {
635
910
  // from the curated detail / pricing / capability columns.
636
911
  "glm-4-flashx-250414": "glm-4-flashx"
637
912
  };
913
+ var NAMESPACE_ALIAS_FAMILY = {
914
+ // SiliconFlow
915
+ "deepseek-ai/DeepSeek-V4-Pro": "SiliconFlow (aggregator)",
916
+ "deepseek-ai/DeepSeek-V4-Flash": "SiliconFlow (aggregator)",
917
+ "zai-org/GLM-5.2": "SiliconFlow (aggregator)",
918
+ "Qwen/Qwen3.6-35B-A3B": "SiliconFlow (aggregator)",
919
+ "moonshotai/Kimi-K2.7-Code": "SiliconFlow (aggregator)",
920
+ // Novita
921
+ "deepseek/deepseek-v4-pro": "Novita (aggregator)",
922
+ "deepseek/deepseek-v4-flash": "Novita (aggregator)",
923
+ "zai/glm-5.2": "Novita (aggregator)",
924
+ "zai/glm-5.1": "Novita (aggregator)",
925
+ "moonshotai/kimi-k3": "Novita (aggregator)"
926
+ };
638
927
  var MODEL_METADATA = (() => {
639
928
  const merged = {
640
929
  ...PRIMARY_METADATA
@@ -653,10 +942,28 @@ function lookupModelMetadata(modelId) {
653
942
  function currencyForBaseUrl(baseUrl) {
654
943
  try {
655
944
  const hostname = new URL(baseUrl).hostname.toLowerCase();
656
- if (hostname === "api.minimaxi.com" || hostname === "api.minimaxi.cn" || hostname === "api.deepseek.com" || hostname === "api.moonshot.cn" || hostname === "open.bigmodel.cn") {
945
+ if (hostname === "api.minimaxi.com" || hostname === "api.minimaxi.cn" || hostname === "api.moonshot.cn" || hostname === "open.bigmodel.cn" || // Zhipu legacy v3 host. Per the GLM-for-copilot reference
946
+ // (`docs/references/GLM-for-copilot-main/src/endpoint.ts:4`)
947
+ // this was retired to `bigmodel.cn` but is still
948
+ // resolvable for accounts that haven't migrated — we
949
+ // don't surface it in the baseUrl dropdown, but a user
950
+ // may paste it from a saved settings.json, so the
951
+ // currency has to match (CNY, same as the new host).
952
+ hostname === "dev.bigmodel.cn") {
657
953
  return "CNY";
658
954
  }
659
- if (hostname === "api.minimax.io" || hostname === "api.minimaxi.io" || hostname === "api.siliconflow.cn" || hostname === "api.siliconflow.com" || hostname === "api.stepfun.com" || hostname === "openrouter.ai" || hostname === "api.novita.ai") {
955
+ if (hostname === "api.minimax.io" || hostname === "api.minimaxi.io" || hostname === "api.siliconflow.cn" || hostname === "api.siliconflow.com" || hostname === "api.stepfun.com" || hostname === "openrouter.ai" || hostname === "api.novita.ai" || // Z.ai / Zhipu international. Billed in USD per the
956
+ // official `bigmodel.cn/pricing` page (the CNY-billed
957
+ // list is the China-domiciled `open.bigmodel.cn` only;
958
+ // the international `api.z.ai` is USD regardless of
959
+ // which apiMode / protocol path the user picked). The
960
+ // GLM-for-copilot reference uses the same split
961
+ // (`docs/references/GLM-for-copilot-main/src/endpoint.ts:160-173`).
962
+ // Without this explicit entry, `api.z.ai` would still
963
+ // resolve to USD via the catch-all below — adding it
964
+ // here makes the intent grep-able and pins the host
965
+ // list against accidental removal.
966
+ hostname === "api.z.ai") {
660
967
  return "USD";
661
968
  }
662
969
  } catch {
@@ -665,13 +972,14 @@ function currencyForBaseUrl(baseUrl) {
665
972
  }
666
973
 
667
974
  // src/ai/providers.presets.ts
668
- function buildPresetModel(id, displayName) {
975
+ function buildPresetModel(id, displayName, baseUrl) {
669
976
  const meta = MODEL_METADATA[id];
670
977
  if (!meta) {
671
978
  throw new Error(
672
979
  `buildPresetModel: no curated MODEL_METADATA entry for '${id}' \u2014 add one before referencing it from BUILTIN_PROVIDER_PRESETS.`
673
980
  );
674
981
  }
982
+ const currency = baseUrl ? currencyForBaseUrl(baseUrl) : "USD";
675
983
  return {
676
984
  id,
677
985
  displayName,
@@ -682,11 +990,95 @@ function buildPresetModel(id, displayName) {
682
990
  supportsImageToText: meta.imageInput,
683
991
  supportsToolCalling: meta.toolCalling
684
992
  },
685
- pricing: meta.pricingUSD,
993
+ pricing: meta[`pricing${currency}`],
686
994
  priceCategory: meta.priceCategory,
687
995
  thinkingSchema: meta.thinkingSchema ?? "none"
688
996
  };
689
997
  }
998
+ function unionProviderModelWithPreset(fetched, baseUrl) {
999
+ const meta = MODEL_METADATA[fetched.id];
1000
+ if (!meta) {
1001
+ return fetched;
1002
+ }
1003
+ const currency = baseUrl ? currencyForBaseUrl(baseUrl) : "USD";
1004
+ const presetDisplayName = getPresetModelDisplayName(fetched.id);
1005
+ const displayName = typeof fetched.displayName === "string" && fetched.displayName.length > 0 ? fetched.displayName : presetDisplayName;
1006
+ return {
1007
+ // Spread fetched first so `id` wins, then overlay the
1008
+ // curated fields. (Curated fields ALWAYS win over fetched
1009
+ // per the precedence above — that's why they're explicit,
1010
+ // not relying on spread order.)
1011
+ ...fetched,
1012
+ displayName,
1013
+ detail: meta.detail,
1014
+ capabilities: {
1015
+ supportsImageToText: meta.imageInput,
1016
+ supportsToolCalling: meta.toolCalling
1017
+ },
1018
+ pricing: meta[`pricing${currency}`],
1019
+ priceCategory: meta.priceCategory,
1020
+ // thinkingSchema: prefer preset (curated), fall back to
1021
+ // fetched (in case the API publishes a schema the
1022
+ // preset doesn't know about), then "none" to match
1023
+ // `buildPresetModel`'s explicit-none convention so the
1024
+ // picker renders identically for preset vs fetched rows.
1025
+ thinkingSchema: meta.thinkingSchema ?? fetched.thinkingSchema ?? "none",
1026
+ // Token caps: preset is curated; if the preset doesn't
1027
+ // publish a cap, keep whatever fetched supplied (the
1028
+ // user may have entered it by hand earlier).
1029
+ maxInputTokens: meta.maxInputTokens ?? fetched.maxInputTokens,
1030
+ maxOutputTokens: meta.maxOutputTokens ?? fetched.maxOutputTokens
1031
+ };
1032
+ }
1033
+ var PRESET_MODEL_FAMILIES = [
1034
+ "GLM",
1035
+ "DeepSeek",
1036
+ "Kimi",
1037
+ "StepFun",
1038
+ "MiniMax",
1039
+ "Agnes",
1040
+ "Qwen",
1041
+ "SiliconFlow (aggregator)",
1042
+ "Novita (aggregator)",
1043
+ "OpenRouter (aggregator)"
1044
+ ];
1045
+ function vendorFamilyForId(id) {
1046
+ const aliasFamily = NAMESPACE_ALIAS_FAMILY[id];
1047
+ if (aliasFamily) return aliasFamily;
1048
+ if (id.startsWith("glm-")) return "GLM";
1049
+ if (id.startsWith("deepseek-")) return "DeepSeek";
1050
+ if (id.startsWith("kimi-")) return "Kimi";
1051
+ if (id.startsWith("step-")) return "StepFun";
1052
+ if (id.startsWith("MiniMax-")) return "MiniMax";
1053
+ if (id.startsWith("agnes-")) return "Agnes";
1054
+ if (id.startsWith("Qwen")) return "Qwen";
1055
+ if (id.startsWith("openrouter/")) return "OpenRouter (aggregator)";
1056
+ return "Other";
1057
+ }
1058
+ var LISTABLE_PRESET_MODELS = (() => {
1059
+ const aggregatorAliasKeys = new Set(Object.keys(NAMESPACE_ALIAS_FAMILY));
1060
+ const allIds = Object.keys(MODEL_METADATA).filter((id) => {
1061
+ if (NAMESPACE_ALIASES[id] === void 0) return true;
1062
+ return aggregatorAliasKeys.has(id);
1063
+ }).sort();
1064
+ return allIds.map((id) => ({
1065
+ id,
1066
+ displayName: id,
1067
+ vendorFamily: vendorFamilyForId(id)
1068
+ }));
1069
+ })();
1070
+ function listPresetModelGroups() {
1071
+ const byFamily = /* @__PURE__ */ new Map();
1072
+ for (const entry of LISTABLE_PRESET_MODELS) {
1073
+ const bucket = byFamily.get(entry.vendorFamily) ?? [];
1074
+ bucket.push(entry);
1075
+ byFamily.set(entry.vendorFamily, bucket);
1076
+ }
1077
+ return PRESET_MODEL_FAMILIES.filter((f) => byFamily.has(f)).map((family) => ({
1078
+ family,
1079
+ entries: byFamily.get(family) ?? []
1080
+ }));
1081
+ }
690
1082
  var BUILTIN_PROVIDER_PRESETS = {
691
1083
  minimax: {
692
1084
  displayName: "MiniMax",
@@ -712,14 +1104,18 @@ var BUILTIN_PROVIDER_PRESETS = {
712
1104
  // (otherwise the user's added model never shows up in the
713
1105
  // Copilot Chat picker).
714
1106
  models: [
715
- buildPresetModel("MiniMax-M3", "MiniMax-M3"),
716
- buildPresetModel("MiniMax-M2.7", "MiniMax-M2.7"),
717
- buildPresetModel("MiniMax-M2.7-highspeed", "MiniMax-M2.7-highspeed"),
1107
+ buildPresetModel("MiniMax-M3", "MiniMax-M3", "https://api.minimaxi.com/anthropic"),
1108
+ buildPresetModel("MiniMax-M2.7", "MiniMax-M2.7", "https://api.minimaxi.com/anthropic"),
1109
+ buildPresetModel(
1110
+ "MiniMax-M2.7-highspeed",
1111
+ "MiniMax-M2.7-highspeed",
1112
+ "https://api.minimaxi.com/anthropic"
1113
+ ),
718
1114
  // M2.5 (2026-02-13, 80.2% SWE-Bench Verified) — the
719
1115
  // predecessor of M2.7. Still in the catalog and often
720
1116
  // available on MiniMax's promotional $0.30/$1.20 rate, so
721
1117
  // keep it as a preset for users on the M2.5 plan tier.
722
- buildPresetModel("MiniMax-M2.5", "MiniMax-M2.5")
1118
+ buildPresetModel("MiniMax-M2.5", "MiniMax-M2.5", "https://api.minimaxi.com/anthropic")
723
1119
  ]
724
1120
  },
725
1121
  deepseek: {
@@ -741,8 +1137,8 @@ var BUILTIN_PROVIDER_PRESETS = {
741
1137
  // the recommended default — users still on V3 can override
742
1138
  // these defaults in the ProvidersTab form.
743
1139
  models: [
744
- buildPresetModel("deepseek-v4-flash", "DeepSeek V4 Flash"),
745
- buildPresetModel("deepseek-v4-pro", "DeepSeek V4 Pro")
1140
+ buildPresetModel("deepseek-v4-flash", "DeepSeek V4 Flash", "https://api.deepseek.com/v1"),
1141
+ buildPresetModel("deepseek-v4-pro", "DeepSeek V4 Pro", "https://api.deepseek.com/v1")
746
1142
  ]
747
1143
  },
748
1144
  agnes: {
@@ -750,19 +1146,34 @@ var BUILTIN_PROVIDER_PRESETS = {
750
1146
  // Sapiens AI's Agnes — OpenAI-compatible endpoint per
751
1147
  // https://wiki.agnes-ai.com (`POST /v1/chat/completions`).
752
1148
  baseUrl: "https://apihub.agnes-ai.com/v1",
1149
+ // Order mirrors the vendor docs index (wiki.agnes-ai.com,
1150
+ // fetched 2026-08-19): paid reasoning models first — the
1151
+ // commercial stable `agnes-2.5-pro` leads, then the
1152
+ // benchmark-listed alpha — followed by the flash tier
1153
+ // newest-first.
753
1154
  models: [
754
- buildPresetModel("agnes-2.5-pro-alpha", "Agnes 2.5 Pro Alpha"),
755
- buildPresetModel("agnes-2.0-flash", "Agnes 2.0 Flash")
1155
+ buildPresetModel("agnes-2.5-pro", "Agnes 2.5 Pro", "https://apihub.agnes-ai.com/v1"),
1156
+ buildPresetModel(
1157
+ "agnes-2.5-pro-alpha",
1158
+ "Agnes 2.5 Pro Alpha",
1159
+ "https://apihub.agnes-ai.com/v1"
1160
+ ),
1161
+ buildPresetModel("agnes-2.5-flash", "Agnes 2.5 Flash", "https://apihub.agnes-ai.com/v1"),
1162
+ buildPresetModel("agnes-2.0-flash", "Agnes 2.0 Flash", "https://apihub.agnes-ai.com/v1")
756
1163
  ]
757
1164
  },
758
1165
  kimi: {
759
1166
  displayName: "Kimi",
760
1167
  baseUrl: "https://api.moonshot.cn/v1",
761
1168
  models: [
762
- buildPresetModel("kimi-k3", "Kimi K3"),
763
- buildPresetModel("kimi-k2.7-code", "Kimi K2.7 Code"),
764
- buildPresetModel("kimi-k2.7-code-highspeed", "Kimi K2.7 Code HighSpeed"),
765
- buildPresetModel("kimi-k2.6", "Kimi K2.6")
1169
+ buildPresetModel("kimi-k3", "Kimi K3", "https://api.moonshot.cn/v1"),
1170
+ buildPresetModel("kimi-k2.7-code", "Kimi K2.7 Code", "https://api.moonshot.cn/v1"),
1171
+ buildPresetModel(
1172
+ "kimi-k2.7-code-highspeed",
1173
+ "Kimi K2.7 Code HighSpeed",
1174
+ "https://api.moonshot.cn/v1"
1175
+ ),
1176
+ buildPresetModel("kimi-k2.6", "Kimi K2.6", "https://api.moonshot.cn/v1")
766
1177
  ]
767
1178
  },
768
1179
  zhipu: {
@@ -834,24 +1245,28 @@ var BUILTIN_PROVIDER_PRESETS = {
834
1245
  // `MODEL_METADATA` entries are kept so the id is still
835
1246
  // resolvable for the curated detail / pricing columns.
836
1247
  models: [
837
- buildPresetModel("glm-5.3", "GLM-5.3"),
838
- buildPresetModel("glm-5.2", "GLM-5.2"),
839
- buildPresetModel("glm-5.1", "GLM-5.1"),
840
- buildPresetModel("glm-5", "GLM-5"),
841
- buildPresetModel("glm-5-turbo", "GLM-5 Turbo"),
842
- buildPresetModel("glm-4.7", "GLM-4.7"),
843
- buildPresetModel("glm-4.6", "GLM-4.6"),
844
- buildPresetModel("glm-4.5-air", "GLM-4.5 Air"),
845
- buildPresetModel("glm-4.5", "GLM-4.5")
1248
+ buildPresetModel("glm-5.3", "GLM-5.3", "https://open.bigmodel.cn/api/paas/v4"),
1249
+ buildPresetModel("glm-5.2", "GLM-5.2", "https://open.bigmodel.cn/api/paas/v4"),
1250
+ buildPresetModel("glm-5.1", "GLM-5.1", "https://open.bigmodel.cn/api/paas/v4"),
1251
+ buildPresetModel("glm-5", "GLM-5", "https://open.bigmodel.cn/api/paas/v4"),
1252
+ buildPresetModel("glm-5-turbo", "GLM-5 Turbo", "https://open.bigmodel.cn/api/paas/v4"),
1253
+ buildPresetModel("glm-4.7", "GLM-4.7", "https://open.bigmodel.cn/api/paas/v4"),
1254
+ buildPresetModel("glm-4.6", "GLM-4.6", "https://open.bigmodel.cn/api/paas/v4"),
1255
+ buildPresetModel("glm-4.5-air", "GLM-4.5 Air", "https://open.bigmodel.cn/api/paas/v4"),
1256
+ buildPresetModel("glm-4.5", "GLM-4.5", "https://open.bigmodel.cn/api/paas/v4")
846
1257
  ]
847
1258
  },
848
1259
  stepfun: {
849
1260
  displayName: "StepFun",
850
1261
  baseUrl: "https://api.stepfun.com/v1",
851
1262
  models: [
852
- buildPresetModel("step-3.7-flash", "Step 3.7 Flash"),
853
- buildPresetModel("step-3.5-flash", "Step 3.5 Flash"),
854
- buildPresetModel("step-1o-turbo-vision", "Step 1o Turbo Vision")
1263
+ buildPresetModel("step-3.7-flash", "Step 3.7 Flash", "https://api.stepfun.com/v1"),
1264
+ buildPresetModel("step-3.5-flash", "Step 3.5 Flash", "https://api.stepfun.com/v1"),
1265
+ buildPresetModel(
1266
+ "step-1o-turbo-vision",
1267
+ "Step 1o Turbo Vision",
1268
+ "https://api.stepfun.com/v1"
1269
+ )
855
1270
  ]
856
1271
  },
857
1272
  siliconflow: {
@@ -865,20 +1280,42 @@ var BUILTIN_PROVIDER_PRESETS = {
865
1280
  // 与 MODEL_METADATA 的 alias 严格一致。
866
1281
  models: [
867
1282
  // DeepSeek V4 系列 (2026-04)
868
- buildPresetModel("deepseek-ai/DeepSeek-V4-Pro", "DeepSeek V4 Pro (via SiliconFlow)"),
869
- buildPresetModel("deepseek-ai/DeepSeek-V4-Flash", "DeepSeek V4 Flash (via SiliconFlow)"),
1283
+ buildPresetModel(
1284
+ "deepseek-ai/DeepSeek-V4-Pro",
1285
+ "DeepSeek V4 Pro (via SiliconFlow)",
1286
+ "https://api.siliconflow.cn/v1"
1287
+ ),
1288
+ buildPresetModel(
1289
+ "deepseek-ai/DeepSeek-V4-Flash",
1290
+ "DeepSeek V4 Flash (via SiliconFlow)",
1291
+ "https://api.siliconflow.cn/v1"
1292
+ ),
870
1293
  // GLM-5.2 (2026-06-17) — open-weight 编程旗舰,1M context
871
- buildPresetModel("zai-org/GLM-5.2", "GLM-5.2 (via SiliconFlow)"),
1294
+ buildPresetModel(
1295
+ "zai-org/GLM-5.2",
1296
+ "GLM-5.2 (via SiliconFlow)",
1297
+ "https://api.siliconflow.cn/v1"
1298
+ ),
872
1299
  // Qwen3.6-35B-A3B (2026-04) — 35B MoE, 3B 激活,"小而强"
873
- buildPresetModel("Qwen/Qwen3.6-35B-A3B", "Qwen3.6-35B-A3B (via SiliconFlow)"),
1300
+ buildPresetModel(
1301
+ "Qwen/Qwen3.6-35B-A3B",
1302
+ "Qwen3.6-35B-A3B (via SiliconFlow)",
1303
+ "https://api.siliconflow.cn/v1"
1304
+ ),
874
1305
  // Kimi K2.7-Code (2026-06-12) — Moonshot coding 旗舰
875
- buildPresetModel("moonshotai/Kimi-K2.7-Code", "Kimi K2.7 Code (via SiliconFlow)")
1306
+ buildPresetModel(
1307
+ "moonshotai/Kimi-K2.7-Code",
1308
+ "Kimi K2.7 Code (via SiliconFlow)",
1309
+ "https://api.siliconflow.cn/v1"
1310
+ )
876
1311
  ]
877
1312
  },
878
1313
  openrouter: {
879
1314
  displayName: "OpenRouter",
880
1315
  baseUrl: "https://openrouter.ai/api/v1",
881
- models: [buildPresetModel("openrouter/auto", "OpenRouter Auto")]
1316
+ models: [
1317
+ buildPresetModel("openrouter/auto", "OpenRouter Auto", "https://openrouter.ai/api/v1")
1318
+ ]
882
1319
  },
883
1320
  novita: {
884
1321
  displayName: "Novita",
@@ -890,16 +1327,76 @@ var BUILTIN_PROVIDER_PRESETS = {
890
1327
  // 完整列表。id 严格匹配 Novita API 的 namespaced 字符串。
891
1328
  models: [
892
1329
  // DeepSeek V4 系列 (2026-04)
893
- buildPresetModel("deepseek/deepseek-v4-pro", "DeepSeek V4 Pro (via Novita)"),
894
- buildPresetModel("deepseek/deepseek-v4-flash", "DeepSeek V4 Flash (via Novita)"),
1330
+ buildPresetModel(
1331
+ "deepseek/deepseek-v4-pro",
1332
+ "DeepSeek V4 Pro (via Novita)",
1333
+ "https://api.novita.ai/openai/v1"
1334
+ ),
1335
+ buildPresetModel(
1336
+ "deepseek/deepseek-v4-flash",
1337
+ "DeepSeek V4 Flash (via Novita)",
1338
+ "https://api.novita.ai/openai/v1"
1339
+ ),
895
1340
  // GLM-5 系列 (2026-04/06)
896
- buildPresetModel("zai/glm-5.2", "GLM-5.2 (via Novita)"),
897
- buildPresetModel("zai/glm-5.1", "GLM-5.1 (via Novita)"),
1341
+ buildPresetModel("zai/glm-5.2", "GLM-5.2 (via Novita)", "https://api.novita.ai/openai/v1"),
1342
+ buildPresetModel("zai/glm-5.1", "GLM-5.1 (via Novita)", "https://api.novita.ai/openai/v1"),
898
1343
  // Kimi K3 (2026-07-16 API, 2026-07-27 开源) — 1M context, 2.8T MoE
899
- buildPresetModel("moonshotai/kimi-k3", "Kimi K3 (via Novita)")
1344
+ buildPresetModel(
1345
+ "moonshotai/kimi-k3",
1346
+ "Kimi K3 (via Novita)",
1347
+ "https://api.novita.ai/openai/v1"
1348
+ )
900
1349
  ]
1350
+ },
1351
+ medalsoft: {
1352
+ displayName: "Medalsoft",
1353
+ // Medalsoft internal LLM gateway (公司内部代理) — OpenAI-compatible
1354
+ // `/v1/chat/completions`. The gateway forwards to upstream vendors
1355
+ // (GLM / DeepSeek / Kimi / ...), so the model catalogue is dynamic
1356
+ // and NOT curated here: the preset ships an EMPTY starter list and
1357
+ // the user populates it via "Fetch from API" (`GET /v1/models`) in
1358
+ // the ProvidersTab. `buildPresetModel`'s fail-loudly contract is
1359
+ // why we don't guess ids — a curated `MODEL_METADATA` entry only
1360
+ // exists for vendor-native ids, not the gateway's routing table.
1361
+ //
1362
+ // NOTE: models fetched from the gateway carry the upstream model
1363
+ // ids, so the curated metadata (pricing / thinking dropdown /
1364
+ // token caps) still resolves via `MODEL_METADATA` after the fetch.
1365
+ baseUrl: "https://llm.proxy.alio.wang/v1",
1366
+ models: []
901
1367
  }
902
1368
  };
1369
+ var PRESET_MODEL_DISPLAY_NAMES = (() => {
1370
+ const map = {};
1371
+ for (const preset of Object.values(BUILTIN_PROVIDER_PRESETS)) {
1372
+ for (const model of preset.models) {
1373
+ if (model.displayName !== void 0) {
1374
+ map[model.id] = model.displayName;
1375
+ }
1376
+ }
1377
+ }
1378
+ return Object.freeze(map);
1379
+ })();
1380
+ function getPresetModelDisplayName(id) {
1381
+ const explicit = PRESET_MODEL_DISPLAY_NAMES[id];
1382
+ if (explicit !== void 0) {
1383
+ return explicit;
1384
+ }
1385
+ const meta = MODEL_METADATA[id];
1386
+ if (meta === void 0) {
1387
+ return void 0;
1388
+ }
1389
+ const detail = meta.detail;
1390
+ if (typeof detail !== "string" || detail.trim() === "") {
1391
+ return void 0;
1392
+ }
1393
+ const dashIndex = detail.indexOf(" \u2014 ");
1394
+ if (dashIndex === -1) {
1395
+ return detail;
1396
+ }
1397
+ const head = detail.slice(0, dashIndex).trim();
1398
+ return head === "" ? void 0 : head;
1399
+ }
903
1400
  function getBuiltinProviderPreset(type) {
904
1401
  switch (type) {
905
1402
  case "minimax":
@@ -911,6 +1408,7 @@ function getBuiltinProviderPreset(type) {
911
1408
  case "siliconflow":
912
1409
  case "openrouter":
913
1410
  case "novita":
1411
+ case "medalsoft":
914
1412
  return BUILTIN_PROVIDER_PRESETS[type];
915
1413
  default:
916
1414
  return null;
@@ -1334,6 +1832,8 @@ var WebviewMessageType = /* @__PURE__ */ ((WebviewMessageType2) => {
1334
1832
  WebviewMessageType2["SetProviderOrder"] = "setProviderOrder";
1335
1833
  WebviewMessageType2["TestProvider"] = "testProvider";
1336
1834
  WebviewMessageType2["ProviderTestResultMessage"] = "providerTestResult";
1835
+ WebviewMessageType2["TestProviderModel"] = "testProviderModel";
1836
+ WebviewMessageType2["ProviderTestModelResultMessage"] = "providerTestModelResult";
1337
1837
  WebviewMessageType2["DefaultProviderChanged"] = "defaultProviderChanged";
1338
1838
  WebviewMessageType2["FetchProviderModels"] = "fetchProviderModels";
1339
1839
  WebviewMessageType2["FetchProviderModelsResult"] = "fetchProviderModelsResult";
@@ -1424,8 +1924,12 @@ export {
1424
1924
  GetCachedServerUrl,
1425
1925
  GetServerProxyState,
1426
1926
  GetUtilityModels,
1927
+ LISTABLE_PRESET_MODELS,
1427
1928
  LogLevel,
1428
1929
  MODEL_METADATA,
1930
+ NAMESPACE_ALIASES,
1931
+ NAMESPACE_ALIAS_FAMILY,
1932
+ PRESET_MODEL_FAMILIES,
1429
1933
  PROVIDER_BASE_URL_PRESETS,
1430
1934
  PROVIDER_CACHE_CONTROL_METADATA,
1431
1935
  ServerProxyStateResponse,
@@ -1438,21 +1942,27 @@ export {
1438
1942
  __internal,
1439
1943
  asAbortSignal,
1440
1944
  buildGitHubLocalEmail,
1945
+ buildPresetModel,
1441
1946
  checkGitHubOrgMembership,
1442
1947
  createConsoleLogger,
1443
1948
  currencyForBaseUrl,
1949
+ effectiveAdapterType,
1444
1950
  fetchGitHubUser,
1445
1951
  getBuiltinProviderPreset,
1446
1952
  getGitHubOrgMembership,
1953
+ getPresetModelDisplayName,
1447
1954
  getProviderBaseUrlPresets,
1448
1955
  isGitHubLocalEmail,
1449
1956
  isProviderCacheControlAware,
1450
1957
  isValidCanonicalSlug,
1958
+ listPresetModelGroups,
1451
1959
  lookupModelMetadata,
1452
1960
  normalizeCanonicalSlug,
1453
1961
  normalizeErrorForLog,
1454
1962
  normalizeGitUrl,
1455
1963
  parsePayload,
1964
+ protocolForBaseUrl,
1456
1965
  resolvePrimaryEmail,
1457
- safeJson
1966
+ safeJson,
1967
+ unionProviderModelWithPreset
1458
1968
  };