dsh-unified-router 0.7.2 → 0.7.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.
@@ -36,6 +36,76 @@ const CATALOG_TIMEOUT_MS = 10_000
36
36
  const BALANCE_TIMEOUT_MS = 5_000
37
37
  const CATALOG_REUSE_MS = 60_000
38
38
 
39
+ /**
40
+ * 归一化用户粘贴的控制台会话凭据(全渠道共用,不含渠道名判断)。
41
+ * 兼容五类常见复制形态,方便手机抓包与桌面开发者工具一键粘贴:
42
+ * 1) 完整 `curl` 命令(提取 `-H 'Cookie: ...'` / `-H "Cookie: ..."` / `-b '...'` / `--cookie '...'`);
43
+ * 2) JSON 对象(`{"cookie":"..."}` 直接取 cookie;`{"accessKeyId":...,"accessKeySecret":...}` 保留 JSON);
44
+ * 3) 多行原始 HTTP 请求头块(提取其中的 `Cookie:` 行);
45
+ * 4) 单行 `Cookie: k=v; ...` 前缀(剥离前缀);
46
+ * 5) 原始 `k=v; ...`、裸 Token(如 Step Plan `Oasis-Token`)或 `AccessKeyId:AccessKeySecret`。
47
+ */
48
+ export function normalizeConsoleCookieInput(raw) {
49
+ if (typeof raw !== 'string') return ''
50
+ let text = raw.trim()
51
+ if (!text) return ''
52
+ // 1) JSON:书签工具或结构化 AK/SK
53
+ if (text.startsWith('{') && text.endsWith('}')) {
54
+ try {
55
+ const parsed = JSON.parse(text)
56
+ if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
57
+ const cookieVal = parsed.cookie ?? parsed.Cookie
58
+ if (typeof cookieVal === 'string' && cookieVal.trim()) return cookieVal.trim()
59
+ const akId = parsed.accessKeyId ?? parsed.AccessKeyId
60
+ const akSec = parsed.accessKeySecret ?? parsed.AccessKeySecret
61
+ if (typeof akId === 'string' && akId.trim() && typeof akSec === 'string' && akSec.trim()) {
62
+ return JSON.stringify({ accessKeyId: akId.trim(), accessKeySecret: akSec.trim() })
63
+ }
64
+ }
65
+ } catch {}
66
+ }
67
+ // 2) cURL 命令(bash / cmd / PowerShell,兼容多行续行与 <input> 压成单行的形态)
68
+ if (/^\s*curl(?:\.exe)?\s/i.test(text)) {
69
+ const flat = text.replace(/\s*[\\^`]\s*[\r\n]+\s*/g, ' ')
70
+ const patterns = [
71
+ /(?:-H|--header)\s+(?:'([^']*(?:\\'|[^'])*)'|"([^"]*(?:\\"|[^"])*)")/gi,
72
+ /(?:-b|--cookie)\s+(?:'([^']+)'|"([^"]+)")/gi,
73
+ ]
74
+ for (const m of flat.matchAll(patterns[0])) {
75
+ const header = (m[1] ?? m[2] ?? '').replace(/\\(['"])/g, '$1').trim()
76
+ const cookieMatch = /^cookie\s*:\s*(.+)$/i.exec(header)
77
+ if (cookieMatch?.[1]?.trim()) return cookieMatch[1].trim()
78
+ }
79
+ for (const m of flat.matchAll(patterns[1])) {
80
+ const val = (m[1] ?? m[2] ?? '').replace(/\\(['"])/g, '$1').trim()
81
+ if (val) return val
82
+ }
83
+ // 也兼容 cURL 中直接携带 Oasis-Token 请求头
84
+ for (const m of flat.matchAll(patterns[0])) {
85
+ const header = (m[1] ?? m[2] ?? '').replace(/\\(['"])/g, '$1').trim()
86
+ const tokenMatch = /^oasis-token\s*:\s*(.+)$/i.exec(header)
87
+ if (tokenMatch?.[1]?.trim()) return tokenMatch[1].trim()
88
+ }
89
+ }
90
+ // 3) 多行原始请求头:从中提取 Cookie: 或 Oasis-Token: 行
91
+ if (/[\r\n]/.test(text)) {
92
+ const lines = text.split(/\r?\n/)
93
+ for (const line of lines) {
94
+ const m = /^\s*cookie\s*:\s*(.+)$/i.exec(line)
95
+ if (m?.[1]?.trim()) return m[1].trim()
96
+ }
97
+ for (const line of lines) {
98
+ const m = /^\s*oasis-token\s*:\s*(.+)$/i.exec(line)
99
+ if (m?.[1]?.trim()) return m[1].trim()
100
+ }
101
+ return ''
102
+ }
103
+ // 4) 单行带前缀 `Cookie: ...` 或 `Oasis-Token: ...`
104
+ const prefix = /^(?:cookie|oasis-token)\s*:\s*(.+)$/i.exec(text)
105
+ if (prefix?.[1]?.trim()) return prefix[1].trim()
106
+ return text
107
+ }
108
+
39
109
  function serviceOf(ctx, name) {
40
110
  try {
41
111
  if (typeof ctx?.get === 'function') {
@@ -529,8 +599,8 @@ export function createApiKeyManager(ctx, spec, deps = {}) {
529
599
 
530
600
  const setConsoleSession = async (payload, signal) => {
531
601
  if (!spec.consoleCredentialRef) throw new Error('不支持此渠道')
532
- const cookie = typeof payload.cookie === 'string' ? payload.cookie.trim() : ''
533
- if (!cookie || cookie.length > 8192 || /[\r\n]/.test(cookie)) throw new Error('控制台 Cookie 无效')
602
+ const cookie = normalizeConsoleCookieInput(payload.cookie)
603
+ if (!cookie || cookie.length > 8192 || /[\r\n]/.test(cookie)) throw new Error('控制台凭据无效')
534
604
  signal?.throwIfAborted()
535
605
  return queue(async () => {
536
606
  signal?.throwIfAborted()
@@ -3,6 +3,7 @@
3
3
  // 渠道事实(哪些是实测、哪些来自官方文档)见同文件 §1。这里不写文档外
4
4
  // 的能力假设:未确认的上下文/输出记 0,未确认的能力一律 false / []。
5
5
 
6
+ import { createHash, createHmac, randomUUID } from 'node:crypto'
6
7
  import {
7
8
  apiQuotaAmount as amount, apiQuotaClampedAmount as clampedAmount,
8
9
  apiQuotaGift as giftOf, apiQuotaWindow as windowOf,
@@ -641,6 +642,127 @@ const bailianRow = id => {
641
642
  const BAILIAN_USAGE_API = 'zeldaHttp.apikeyMgr./tokenplan/personal/api/v2/usage'
642
643
  const BAILIAN_CONSOLE_PAGE = 'https://bailian.console.aliyun.com/cn-beijing?tab=plan'
643
644
  const BAILIAN_GATEWAY_URL = `https://bailian-cs.console.aliyun.com/data/api.json?action=BroadScopeAspnGateway&product=sfm_bailian&api=${encodeURIComponent(BAILIAN_USAGE_API)}`
645
+ const BAILIAN_CLI_TOKEN_URL = 'https://modelstudio.cn-beijing.aliyuncs.com/modelstudio/cli/generateAccessToken'
646
+ const BAILIAN_CLI_GATEWAY_URL = `https://bailian-cs.console.aliyun.com/cli/api.json?action=BroadScopeAspnGateway&product=sfm_bailian&api=${encodeURIComponent(BAILIAN_USAGE_API)}`
647
+ const bailianCliTokenCache = new Map()
648
+
649
+ /**
650
+ * 解析阿里云 AccessKey 凭据(支持 `AccessKeyId:AccessKeySecret` 或 JSON 对象)。
651
+ * 与 Cookie 区分:Cookie 一定含 `=` 且不以 `LTAI` 开头,或经显式 JSON 指定。
652
+ */
653
+ export function parseAliyunAccessKey(raw) {
654
+ if (typeof raw !== 'string') return null
655
+ const text = raw.trim()
656
+ if (!text) return null
657
+ if (text.startsWith('{') && text.endsWith('}')) {
658
+ try {
659
+ const parsed = JSON.parse(text)
660
+ const id = String(parsed?.accessKeyId ?? parsed?.AccessKeyId ?? '').trim()
661
+ const secret = String(parsed?.accessKeySecret ?? parsed?.AccessKeySecret ?? '').trim()
662
+ if (id && secret && !/\s/.test(id) && !/\s/.test(secret)) return { id, secret }
663
+ } catch { return null }
664
+ return null
665
+ }
666
+ const colon = text.indexOf(':')
667
+ if (colon <= 0 || text.includes(';')) return null
668
+ const id = text.slice(0, colon).trim()
669
+ const secret = text.slice(colon + 1).trim()
670
+ if (!/^[A-Za-z0-9_-]{8,128}$/.test(id) || !secret || /\s/.test(secret) || secret.length > 256) return null
671
+ return { id, secret }
672
+ }
673
+
674
+ /** 阿里云 OpenAPI V3 签名(ACS3-HMAC-SHA256),零外部依赖。 */
675
+ export function signAliyunAcs3({ accessKeyId, accessKeySecret, method = 'POST', url, action, version, body = '', now = new Date(), nonce = randomUUID() }) {
676
+ const parsed = new URL(url)
677
+ const payloadHash = createHash('sha256').update(body, 'utf8').digest('hex')
678
+ const date = now.toISOString().replace(/\.\d{3}Z$/, 'Z')
679
+ const canonicalHeaders = {
680
+ host: parsed.host,
681
+ 'x-acs-action': action,
682
+ 'x-acs-content-sha256': payloadHash,
683
+ 'x-acs-date': date,
684
+ 'x-acs-signature-nonce': nonce,
685
+ 'x-acs-version': version,
686
+ }
687
+ const signedNames = Object.keys(canonicalHeaders).sort()
688
+ const headerLines = signedNames.map(name => `${name}:${canonicalHeaders[name]}\n`).join('')
689
+ const signedHeaders = signedNames.join(';')
690
+ const queryPairs = [...parsed.searchParams.entries()]
691
+ .sort((a, b) => a[0].localeCompare(b[0]) || a[1].localeCompare(b[1]))
692
+ .map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`)
693
+ .join('&')
694
+ const canonicalRequest = [method.toUpperCase(), parsed.pathname || '/', queryPairs, headerLines, signedHeaders, payloadHash].join('\n')
695
+ const hashedCanonical = createHash('sha256').update(canonicalRequest, 'utf8').digest('hex')
696
+ const stringToSign = `ACS3-HMAC-SHA256\n${hashedCanonical}`
697
+ const signature = createHmac('sha256', accessKeySecret).update(stringToSign, 'utf8').digest('hex')
698
+ return {
699
+ ...canonicalHeaders,
700
+ accept: 'application/json',
701
+ 'content-type': 'application/json',
702
+ authorization: `ACS3-HMAC-SHA256 Credential=${accessKeyId},SignedHeaders=${signedHeaders},Signature=${signature}`,
703
+ }
704
+ }
705
+
706
+ async function mintBailianCliToken(ak, fetchJson, signal, { force = false } = {}) {
707
+ const cacheKey = createHash('sha256').update(`${ak.id}:${ak.secret}`).digest('hex').slice(0, 16)
708
+ const cached = !force ? bailianCliTokenCache.get(cacheKey) : null
709
+ if (cached && cached.expiresAt > Date.now()) return cached.token
710
+ const body = '{}'
711
+ const headers = signAliyunAcs3({
712
+ accessKeyId: ak.id,
713
+ accessKeySecret: ak.secret,
714
+ method: 'POST',
715
+ url: BAILIAN_CLI_TOKEN_URL,
716
+ action: 'GenerateCLIAccessToken',
717
+ version: '2026-02-10',
718
+ body,
719
+ })
720
+ const json = await fetchJson({ url: BAILIAN_CLI_TOKEN_URL, method: 'POST', headers, body }, signal)
721
+ const token = json?.cliAccessToken ?? json?.data?.cliAccessToken ?? json?.Data?.cliAccessToken
722
+ if (typeof token !== 'string' || !token.trim()) {
723
+ const err = new Error('bailian_ak_invalid')
724
+ err.expired = true
725
+ throw err
726
+ }
727
+ // 官方 token 有效期约 20 分钟;本地缓存 15 分钟,遇到 NotLogined 强制重签一次。
728
+ bailianCliTokenCache.set(cacheKey, { token: token.trim(), expiresAt: Date.now() + 15 * 60_000 })
729
+ return token.trim()
730
+ }
731
+
732
+ async function fetchBailianCliGateway(ak, fetchJson, signal) {
733
+ const invoke = async force => {
734
+ const cliToken = await mintBailianCliToken(ak, fetchJson, signal, { force })
735
+ const params = JSON.stringify({
736
+ Api: BAILIAN_USAGE_API,
737
+ V: '1.0',
738
+ Data: {},
739
+ })
740
+ const body = new URLSearchParams({
741
+ product: 'sfm_bailian',
742
+ action: 'BroadScopeAspnGateway',
743
+ region: 'cn-beijing',
744
+ params,
745
+ }).toString()
746
+ return fetchJson({
747
+ url: BAILIAN_CLI_GATEWAY_URL,
748
+ method: 'POST',
749
+ headers: {
750
+ authorization: `Bearer ${cliToken}`,
751
+ 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
752
+ accept: 'application/json',
753
+ },
754
+ body,
755
+ }, signal)
756
+ }
757
+ let json = await invoke(false)
758
+ const isExpired = res => {
759
+ const code = String(res?.code ?? '')
760
+ const errCode = String(res?.data?.errorCode ?? res?.errorCode ?? '')
761
+ return code === '401' || code === '403' || /NotLogined|Unauth|Login/i.test(errCode)
762
+ }
763
+ if (isExpired(json)) json = await invoke(true)
764
+ return { expired: isExpired(json), json }
765
+ }
644
766
 
645
767
  function bailianPercentWindow(id, rawPct, rawResetMs, now) {
646
768
  const pct = amount(rawPct)
@@ -654,13 +776,15 @@ function bailianPercentWindow(id, rawPct, rawResetMs, now) {
654
776
  }
655
777
 
656
778
  /**
657
- * 通过百炼控制台 Cookie 读取 Token Plan 个人版用量:
658
- * 1) GET 控制台页面提取内嵌 `SEC_TOKEN`;
659
- * 2) POST `BroadScopeAspnGateway` 查 `tokenplan/personal/api/v2/usage`。
660
- * ⚠️ `cornerstoneParam` 绝不可硬编码某账号的 `switchAgent`(工作空间 ID),
661
- * 省略后网关按当前 Cookie 所属账号返回真实额度。
779
+ * 读取百炼 Token Plan 个人版用量,支持两种凭据形态:
780
+ * 1) 阿里云 AccessKey(`AccessKeyId:AccessKeySecret` / JSON):走官方 `bl` CLI 同款
781
+ * ACS3-HMAC-SHA256 `GenerateCLIAccessToken` → `POST /cli/api.json`(全平台免浏览器、长期有效);
782
+ * 2) 控制台浏览器 Cookie:GET 控制台页提取 `SEC_TOKEN` → `POST /data/api.json`。
783
+ * ⚠️ Cookie 模式 `cornerstoneParam` 绝不可硬编码某账号的 `switchAgent`。
662
784
  */
663
785
  async function fetchBailianConsoleGateway(session, fetchJson, signal) {
786
+ const ak = parseAliyunAccessKey(session)
787
+ if (ak) return fetchBailianCliGateway(ak, fetchJson, signal)
664
788
  const html = await fetchJson({
665
789
  url: BAILIAN_CONSOLE_PAGE,
666
790
  headers: { cookie: session, accept: 'text/html,application/xhtml+xml' },
package/lib/backend.js CHANGED
@@ -2367,6 +2367,7 @@ var obsoleteIdentities = /* @__PURE__ */ new Set([
2367
2367
  "glm-5",
2368
2368
  "glm-5-1",
2369
2369
  "glm-5-2",
2370
+ "glm-5-3",
2370
2371
  "glm-5v-turbo",
2371
2372
  "glm-5-2-sft-harmony",
2372
2373
  "kimi-k2-5",
@@ -46,6 +46,14 @@ export function findChromiumBrowser(platform = process.platform, env = process.e
46
46
  '/usr/bin/chromium-browser',
47
47
  '/snap/bin/chromium',
48
48
  '/usr/bin/microsoft-edge',
49
+ '/usr/bin/brave-browser',
50
+ ...(String(env.PATH || '').split(':').filter(Boolean).flatMap(dir => [
51
+ join(dir, 'google-chrome'),
52
+ join(dir, 'google-chrome-stable'),
53
+ join(dir, 'chromium'),
54
+ join(dir, 'chromium-browser'),
55
+ join(dir, 'microsoft-edge'),
56
+ ])),
49
57
  ]
50
58
  return candidates.find(candidate => candidate && existsSync(candidate)) || ''
51
59
  }
@@ -254,9 +262,12 @@ export function captureRedirect(wsUrl, url, callbackOrigin, matchRedirect, signa
254
262
  async function launchIsolatedBrowser({ url, startupUrl, onUrl, signal, timeoutMs = 5 * 60_000, pollIntervalMs, inspect }) {
255
263
  const safe = validateBrowserUrl(url)
256
264
  if (!safe) throw new Error('登录地址无效')
265
+ if (process.platform !== 'win32' && process.platform !== 'darwin' && !process.env.DISPLAY && !process.env.WAYLAND_DISPLAY) {
266
+ throw new Error('当前宿主无图形桌面,无法自动拉起浏览器,请直接打开控制台登录后粘贴 Cookie 或凭据')
267
+ }
257
268
  const browserPath = findChromiumBrowser()
258
269
  if (!browserPath) {
259
- throw new Error('未找到本机 Chrome 或 Edge 浏览器,请改用「导入本机登录」或「粘贴凭据」')
270
+ throw new Error('未找到本机 Chrome 或 Edge 浏览器,请改用「导入本机登录」或直接粘贴凭据 / Cookie')
260
271
  }
261
272
  const port = await getFreeLoopbackPort()
262
273
  let profileDir = ''
package/lib/client.js CHANGED
@@ -332,7 +332,7 @@ const providerNamedSuccessors = {
332
332
  // 其他现代推荐模型,也默认移出推荐(仍保留在目录中供手动启用,且绝不清空整个渠道)。
333
333
  const obsoleteIdentities = new Set([
334
334
  'deepseek-v3', 'deepseek-v3-1', 'deepseek-v4-flash', 'deepseek-v4-pro',
335
- 'glm-4-7', 'glm-5', 'glm-5-1', 'glm-5-2', 'glm-5v-turbo', 'glm-5-2-sft-harmony',
335
+ 'glm-4-7', 'glm-5', 'glm-5-1', 'glm-5-2', 'glm-5-3', 'glm-5v-turbo', 'glm-5-2-sft-harmony',
336
336
  'kimi-k2-5', 'kimi-k2-6', 'kimi-k2-7-code', 'kimi-k2-8-preview', 'kimi-k3',
337
337
  'qwen-3-5', 'qwen-3-6-plus', 'qwen-3-7-plus', 'qwen-3-8-flash',
338
338
  'minimax-m2-7', 'minimax-m3',
@@ -3237,6 +3237,7 @@ const CLIENT_STYLES = `
3237
3237
  .eac-params-note{margin:0;color:var(--eac-faint);font-size:var(--eac-fs-xs);line-height:1.5}
3238
3238
 
3239
3239
  /* ---------- OpenDesign CoRouter 上下文分段:设置页与输入栏变体 ---------- */
3240
+ .eac-params .eac-context-tiers{flex-wrap:wrap;max-width:100%}
3240
3241
  .eac-context-control{display:flex;align-items:center;flex-wrap:wrap;gap:var(--eac-s2);min-width:0;color:var(--eac-text);font-size:var(--eac-fs-sm)}
3241
3242
  .eac-context-tiers{display:inline-flex;align-items:center;gap:0;min-width:0;padding:var(--eac-s1);border:1px solid var(--eac-border);border-radius:var(--eac-s2)}
3242
3243
  .eac-context-control .eac-context-segment{display:inline-flex;align-items:center;justify-content:center;min-height:var(--eac-s6);min-width:0;padding:var(--eac-s1) var(--eac-s2);margin:0;border:1px solid transparent;border-radius:var(--eac-s1);background:transparent;color:var(--eac-muted);font:inherit;font-variant-numeric:tabular-nums;white-space:nowrap;cursor:pointer}
@@ -3329,6 +3330,11 @@ html[data-dsh-go-island][data-dsh-go-island-form="panel"] .eac-quota-popover{pos
3329
3330
  }
3330
3331
  :where(body[data-ds-dark-theme],.dark,[data-theme=dark],[data-color-scheme=dark]) :is(.eac-settings,.eac-context-pill,.eac-quota-pill,.eac-quota-popover),:is(.eac-settings,.eac-context-pill,.eac-quota-pill,.eac-quota-popover):where(.dark,[data-theme=dark],[data-color-scheme=dark]){color-scheme:dark;--eac-surface:var(--dsw-alias-bg-layer-1,#191b20);--eac-subtle:color-mix(in srgb,currentColor 4%,transparent);--eac-hover:color-mix(in srgb,currentColor 7%,transparent);--eac-text:var(--dsw-alias-label-primary,#f2f4f7);--eac-muted:color-mix(in srgb,currentColor 66%,transparent);--eac-faint:color-mix(in srgb,currentColor 50%,transparent);--eac-border:color-mix(in srgb,currentColor 20%,transparent);--eac-divider:color-mix(in srgb,currentColor 12%,transparent);--eac-accent:#3b82f6;--eac-on-accent:#fff;--eac-success:#22c55e;--eac-warn:#eab308;--eac-danger:#ef4444;--eac-shadow:0 1px 2px rgba(0,0,0,.18)}
3331
3332
  :where(.light,[data-theme=light],[data-color-scheme=light]) :is(.eac-settings,.eac-context-pill,.eac-quota-pill,.eac-quota-popover),:is(.eac-settings,.eac-context-pill,.eac-quota-pill,.eac-quota-popover):where(.light,[data-theme=light],[data-color-scheme=light]){color-scheme:light;--eac-surface:var(--dsw-alias-bg-layer-1,#fff);--eac-subtle:color-mix(in srgb,currentColor 4%,transparent);--eac-hover:color-mix(in srgb,currentColor 7%,transparent);--eac-text:var(--dsw-alias-label-primary,#182230);--eac-muted:color-mix(in srgb,currentColor 66%,transparent);--eac-faint:color-mix(in srgb,currentColor 50%,transparent);--eac-border:color-mix(in srgb,currentColor 20%,transparent);--eac-divider:color-mix(in srgb,currentColor 12%,transparent);--eac-accent:#3b82f6;--eac-on-accent:#fff;--eac-success:#22c55e;--eac-warn:#eab308;--eac-danger:#ef4444;--eac-shadow:0 1px 2px rgba(16,24,40,.04)}
3333
+ @container eac (max-width:720px){
3334
+ .eac-row-item:has(.eac-row-controls .eac-tier-row){grid-template-columns:minmax(0,1fr) auto;grid-template-areas:"main switch" "more more"}
3335
+ .eac-row-item:has(.eac-row-controls .eac-tier-row)>.eac-row-controls{justify-content:flex-start}
3336
+ .eac-row-item:has(.eac-row-controls .eac-tier-row) .eac-tier-row{width:100%}
3337
+ }
3332
3338
  @container eac (max-width:640px){
3333
3339
  .eac-header{align-items:center}
3334
3340
  .eac-workspace{padding:var(--eac-s2) var(--eac-s3) var(--eac-s4)}
@@ -3337,9 +3343,9 @@ html[data-dsh-go-island][data-dsh-go-island-form="panel"] .eac-quota-popover{pos
3337
3343
  .eac-workspace[data-panel=models] .eac-section-head{flex-direction:row;align-items:center;flex-wrap:wrap;gap:var(--eac-s2)}
3338
3344
  .eac-workspace[data-panel=models] .eac-section-actions{max-width:100%}
3339
3345
  .eac-row-item{grid-template-columns:minmax(0,1fr) auto auto;grid-template-areas:"main switch more" "metric metric metric";gap:var(--eac-s2);padding:var(--eac-s3)}
3340
- .eac-row-item:has(.eac-row-controls .eac-button){grid-template-columns:minmax(0,1fr) auto;grid-template-areas:"main switch" "more more"}
3341
- .eac-row-item:has(.eac-row-controls .eac-button)>.eac-row-controls{justify-content:flex-start}
3342
- .eac-row-item:has(.eac-row-controls .eac-button)>.eac-row-metric{grid-area:auto;grid-column:1/-1}
3346
+ .eac-row-item:has(.eac-row-controls :is(.eac-button,.eac-tier-row)){grid-template-columns:minmax(0,1fr) auto;grid-template-areas:"main switch" "more more"}
3347
+ .eac-row-item:has(.eac-row-controls :is(.eac-button,.eac-tier-row))>.eac-row-controls{justify-content:flex-start}
3348
+ .eac-row-item:has(.eac-row-controls :is(.eac-button,.eac-tier-row))>.eac-row-metric{grid-area:auto;grid-column:1/-1}
3343
3349
  .eac-workspace[data-panel=advanced] .eac-row-name{white-space:normal;overflow-wrap:anywhere}
3344
3350
  .eac-row-credit{justify-content:flex-start}
3345
3351
  .eac-row-item>.eac-row-more{grid-area:auto;grid-column:1/-1;margin-top:0}
@@ -3635,15 +3641,23 @@ function PlanKeyForm({ disabled, onSave }) {
3635
3641
  h('label', { className: 'eac-field' }, h('span', null, 'API Key'), h('input', { className: 'eac-input', type: 'password', autoComplete: 'off', required: true, disabled, value: apiKey, onChange: e => setApiKey(e.target.value) })),
3636
3642
  h('div', { className: 'eac-form-actions' }, primary('保存 API Key', undefined, disabled, { type: 'submit' })))
3637
3643
  }
3638
- // 控制台会话粘贴表单(云知声额度读取用):与 Key 表单同构,标签与文案不同。
3639
- function ConsoleCookieForm({ disabled, onSave }) {
3644
+ // 控制台会话粘贴表单:展示渠道专属字段引导,接受 Cookie / 请求头 / cURL / JSON / 阿里云 AccessKey。
3645
+ function ConsoleCookieForm({ disabled, hint, guide, onSave }) {
3640
3646
  const [cookie, setCookie] = React.useState('')
3641
3647
  return h('form', { className: 'eac-account-form', onSubmit: async event => {
3642
3648
  event.preventDefault()
3643
3649
  const saved = await onSave(cookie)
3644
3650
  if (saved) setCookie('')
3645
3651
  } },
3646
- h('label', { className: 'eac-field' }, h('span', null, '控制台 Cookie'), h('input', { className: 'eac-input', type: 'password', autoComplete: 'off', required: true, disabled, placeholder: '从浏览器开发者工具复制控制台 Cookie 请求头', value: cookie, onChange: e => setCookie(e.target.value) })),
3652
+ h('label', { className: 'eac-field' },
3653
+ h('span', null, '控制台凭据 / Cookie'),
3654
+ h('input', {
3655
+ className: 'eac-input', type: 'password', autoComplete: 'off', required: true, disabled,
3656
+ placeholder: hint || '粘贴控制台 Cookie、请求头或 cURL',
3657
+ value: cookie, onChange: e => setCookie(e.target.value),
3658
+ }),
3659
+ guide ? h('p', { className: 'eac-params-note' }, guide) : null,
3660
+ h('p', { className: 'eac-params-note' }, '浏览器登录仅在宿主桌面端弹出;手机或无桌面环境请先打开控制台,按上方说明粘贴保存。')),
3647
3661
  h('div', { className: 'eac-form-actions' }, primary('保存会话', undefined, disabled, { type: 'submit' })))
3648
3662
  }
3649
3663
  function CredentialImportForm({ disabled, hint, onSave, onCancel }) {
@@ -3830,7 +3844,10 @@ function renderForm(form, ui, key, scope) {
3830
3844
  if (!form) return null
3831
3845
  const save = (...args) => ui.invoke(...form.call, ...args)
3832
3846
  const formScope = scope || `channel:${ui.providerId}`
3833
- return h(SETTINGS_FORMS[form.kind], { key, account: form.account, disabled: form.disabled === true || ui.loading || ui.isPending(formScope), save, onSave: save })
3847
+ return h(SETTINGS_FORMS[form.kind], {
3848
+ key, account: form.account, hint: form.hint, guide: form.guide,
3849
+ disabled: form.disabled === true || ui.loading || ui.isPending(formScope), save, onSave: save,
3850
+ })
3834
3851
  }
3835
3852
 
3836
3853
  /** 单选分段控件(智能选号模式):复用参数编辑器的 .eac-tier 外观与 aria-pressed。 */
@@ -5414,6 +5431,8 @@ function apiKeyChannel({
5414
5431
  toolsLabel = '多模态能力工具',
5415
5432
  toolsMeta = '语音转写 · 语音合成 · 声音克隆 · 文档解析 · 信息抽取',
5416
5433
  consoleMeta = '用于读取控制台额度',
5434
+ consoleFormHint = '',
5435
+ consoleFormGuide = '',
5417
5436
  freeTier = false,
5418
5437
  preferCreditsWindows = false,
5419
5438
  }) {
@@ -5514,7 +5533,7 @@ function apiKeyChannel({
5514
5533
  tags: [current && !current.hasApiKey && ['先配置 API Key', 'warn'],
5515
5534
  current?.toolsEnabled && !current.toolsRegistered && ['待注册', 'warn']],
5516
5535
  }] : []),
5517
- // 控制台会话:额度读取的凭据。浏览器登录自动收割,或粘贴 Cookie。
5536
+ // 控制台会话:额度读取的凭据。桌面端支持浏览器自动收割;手机或无头环境可直接打开控制台并粘贴 Cookie / cURL / AK:SK。
5518
5537
  ...(current && 'hasConsoleSession' in current ? [{
5519
5538
  id: 'console', name: '控制台会话',
5520
5539
  meta: signingIn ? '浏览器登录进行中,可取消;完成后自动保存' : consoleMeta,
@@ -5523,9 +5542,10 @@ function apiKeyChannel({
5523
5542
  { label: '取消登录', call: [id + 'CancelConsoleLogin'] },
5524
5543
  ] : [
5525
5544
  { label: current.hasConsoleSession ? '重新登录' : '浏览器登录', call: [id + 'ConsoleLogin'], primary: !current.hasConsoleSession },
5545
+ ...(current.consoleQuotaUrl ? [{ label: '打开控制台', href: current.consoleQuotaUrl }] : []),
5526
5546
  ...(current.hasConsoleSession ? [{ label: '清除会话', call: [id + 'ClearConsole'], danger: true }] : []),
5527
5547
  ],
5528
- form: { kind: 'console', call: [id + 'SetConsole'], disabled: signingIn },
5548
+ form: { kind: 'console', call: [id + 'SetConsole'], disabled: signingIn, hint: consoleFormHint, guide: consoleFormGuide },
5529
5549
  }] : []),
5530
5550
  ...(current?.rateLimit?.until > Date.now() ? [{ id: 'rate-limit', name: '限速提醒',
5531
5551
  meta: h(ApiKeyCooldown, { key: current.rateLimit.until, limit: current.rateLimit }) }] : []),
@@ -5673,6 +5693,8 @@ const unisound = apiKeyChannel({
5673
5693
  title: '云知声',
5674
5694
  host: 'maas-api.unisound.com',
5675
5695
  consoleMeta: '用于读取控制台额度(U Plan 积分 / 按量余额)',
5696
+ consoleFormHint: '粘贴 maas.unisound.com 的 Cookie(含 JSESSIONID)或 cURL',
5697
+ consoleFormGuide: '登录 maas.unisound.com 后,复制任意 /manager/ 请求的 Cookie 头或整段 cURL(需含 JSESSIONID)粘贴。',
5676
5698
  })
5677
5699
 
5678
5700
  // ── src/client/providers/qianfan.js ──
@@ -5681,6 +5703,8 @@ const qianfan = apiKeyChannel({
5681
5703
  title: '千帆 Token Plan',
5682
5704
  host: 'qianfan.baidubce.com',
5683
5705
  consoleMeta: '用于读取千帆 Token Plan 个人版月度额度',
5706
+ consoleFormHint: '粘贴 console.bce.baidu.com 的 Cookie(含 BDUSS)或 cURL',
5707
+ consoleFormGuide: '登录千帆控制台后,复制 tokenPlanPersonal/resource 请求的 Cookie 头或整段 cURL(需含 BDUSS)粘贴。',
5684
5708
  })
5685
5709
 
5686
5710
  // ── src/client/providers/bailian.js ──
@@ -5688,7 +5712,9 @@ const bailian = apiKeyChannel({
5688
5712
  id: 'bailian',
5689
5713
  title: '阿里云百炼',
5690
5714
  host: 'token-plan.cn-beijing.maas.aliyuncs.com',
5691
- consoleMeta: '用于读取百炼 Token Plan 个人版周期额度',
5715
+ consoleMeta: '用于读取百炼 Token Plan 个人版周期额度(支持阿里云 AK/SK 或 Cookie)',
5716
+ consoleFormHint: '粘贴 AccessKeyId:AccessKeySecret,或百炼控制台 Cookie / cURL',
5717
+ consoleFormGuide: '手机/无桌面推荐粘贴阿里云 RAM 子账号的 AccessKeyId:AccessKeySecret(长期有效),也可粘贴 bailian.console.aliyun.com 的 Cookie 或 cURL。',
5692
5718
  })
5693
5719
 
5694
5720
  // ── src/client/providers/stepfun.js ──
@@ -5697,6 +5723,8 @@ const stepfun = apiKeyChannel({
5697
5723
  title: 'Step Plan',
5698
5724
  host: 'api.stepfun.com',
5699
5725
  consoleMeta: '用于读取阶跃星辰 Step Plan 周期与月度 Credit 额度',
5726
+ consoleFormHint: '粘贴 platform.stepfun.com 的 Oasis-Token、Cookie 或 cURL',
5727
+ consoleFormGuide: '登录 platform.stepfun.com/step-plan 后,复制请求头中的 Oasis-Token 值,或整段 Cookie / cURL 粘贴。',
5700
5728
  })
5701
5729
 
5702
5730
  // ── src/client/providers/astudio.js ──
@@ -241,7 +241,7 @@ const providerNamedSuccessors = {
241
241
  // 其他现代推荐模型,也默认移出推荐(仍保留在目录中供手动启用,且绝不清空整个渠道)。
242
242
  const obsoleteIdentities = new Set([
243
243
  'deepseek-v3', 'deepseek-v3-1', 'deepseek-v4-flash', 'deepseek-v4-pro',
244
- 'glm-4-7', 'glm-5', 'glm-5-1', 'glm-5-2', 'glm-5v-turbo', 'glm-5-2-sft-harmony',
244
+ 'glm-4-7', 'glm-5', 'glm-5-1', 'glm-5-2', 'glm-5-3', 'glm-5v-turbo', 'glm-5-2-sft-harmony',
245
245
  'kimi-k2-5', 'kimi-k2-6', 'kimi-k2-7-code', 'kimi-k2-8-preview', 'kimi-k3',
246
246
  'qwen-3-5', 'qwen-3-6-plus', 'qwen-3-7-plus', 'qwen-3-8-flash',
247
247
  'minimax-m2-7', 'minimax-m3',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-unified-router",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
4
4
  "type": "module",
5
5
  "main": "lib/web-host.js",
6
6
  "license": "MIT",