dsh-zcode-startplan 0.2.0 → 0.4.5
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/CHANGELOG.md +297 -0
- package/README.md +62 -3
- package/client.js +96 -39
- package/cordis.patch.yml +2 -0
- package/index.js +22 -0
- package/lib/adapter.js +140 -4
- package/lib/anthropic-body.js +167 -2
- package/lib/assemble.js +115 -4
- package/lib/local-endpoint.js +16 -2
- package/lib/manage-routes.js +98 -23
- package/lib/pinned-model.js +56 -0
- package/lib/plan-client.js +114 -9
- package/lib/pool.js +11 -0
- package/lib/stream-translator.js +30 -8
- package/lib/upstream-api.js +89 -63
- package/lib/upstream.js +12 -1
- package/package.json +80 -80
- package/scripts/_cdp-inspect.mjs +54 -0
- package/scripts/asar-list.mjs +66 -0
- package/scripts/check-compat-rc3.mjs +11 -0
- package/scripts/verify_compat.mjs +1 -1
package/lib/upstream-api.js
CHANGED
|
@@ -376,17 +376,14 @@ export async function fetchBalance(credential, fetchImpl = globalThis.fetch) {
|
|
|
376
376
|
/** 补客户端活跃信号(不补则 preview 恒为空 plans)。 */
|
|
377
377
|
export async function reportActivation(credential, fetchImpl = globalThis.fetch) {
|
|
378
378
|
const appVersion = credential.app_version ?? ZCODE_APP_VERSION_FALLBACK
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
// 上报失败不阻塞(下一次调用会再补)。
|
|
388
|
-
}
|
|
389
|
-
}
|
|
379
|
+
/** 两个事件相互独立,并行上报(省一个 RTT;失败不阻塞,下次调用会再补)。 */
|
|
380
|
+
await Promise.all(['app_launch', 'app_daily_active'].map((event) =>
|
|
381
|
+
fetchWithTimeout(fetchImpl, ZCODE_EVENT_REPORT_URL, {
|
|
382
|
+
method: 'POST',
|
|
383
|
+
headers: buildZcodeHeaders(credential, { json: true }),
|
|
384
|
+
body: JSON.stringify({ event, device_mid: credential.device_mid, platform: 'win32', app_version: appVersion }),
|
|
385
|
+
}, 20_000).catch(() => {}),
|
|
386
|
+
))
|
|
390
387
|
}
|
|
391
388
|
|
|
392
389
|
/** 查当前可领的活动(priority 降序)。 */
|
|
@@ -454,11 +451,19 @@ export async function claimPlan(credential, planId, captcha, fetchImpl = globalT
|
|
|
454
451
|
}
|
|
455
452
|
|
|
456
453
|
/**
|
|
457
|
-
*
|
|
454
|
+
* `GET /api/v1/client/configs` 的共享缓存(60s TTL,仅缓存成功结果 + in-flight 去重)。
|
|
458
455
|
*
|
|
459
|
-
*
|
|
456
|
+
* captcha 配置与模型目录**是同一端点的两个字段**,此前两条链路各打一次且缓存
|
|
457
|
+
* 互相独立 —— 这里统一成一次请求、一份缓存。缓存键带上 `zcode_jwt` 与
|
|
458
|
+
* `fetchImpl` 身份:不同账号不串味;测试里逐个注入的 mock fetch 也不互相污染。
|
|
459
|
+
* **失败不缓存**(一次网络抖动不该把 sceneId 固化 60 秒)。
|
|
460
460
|
*/
|
|
461
|
-
|
|
461
|
+
const CLIENT_CONFIGS_CACHE_MS = 60_000
|
|
462
|
+
const clientConfigsCache = new Map()
|
|
463
|
+
const clientConfigsInflight = new Map()
|
|
464
|
+
|
|
465
|
+
/** 拉一次 client/configs 原文(不缓存);非 2xx / 网络错误 → undefined。 */
|
|
466
|
+
async function fetchClientConfigsOnce(credential, fetchImpl) {
|
|
462
467
|
const appVersion = credential.app_version ?? ZCODE_APP_VERSION_FALLBACK
|
|
463
468
|
const url = `${ZCODE_CLIENT_CONFIGS_URL}?app_version=${encodeURIComponent(appVersion)}&platform=unknown`
|
|
464
469
|
try {
|
|
@@ -467,17 +472,48 @@ export async function fetchCaptchaConfig(credential, fetchImpl = globalThis.fetc
|
|
|
467
472
|
headers: buildZcodeHeaders(credential, { authorization: `Bearer ${credential.zcode_jwt}`, json: false }),
|
|
468
473
|
}, 20_000)
|
|
469
474
|
if (!response.ok) return undefined
|
|
470
|
-
|
|
471
|
-
const captcha = parsed.data?.configs?.captcha
|
|
472
|
-
if (captcha === undefined) return undefined
|
|
473
|
-
const { region, prefix, sceneId } = captcha
|
|
474
|
-
if (typeof region !== 'string' || typeof prefix !== 'string' || typeof sceneId !== 'string') return undefined
|
|
475
|
-
return { region, prefix, sceneId }
|
|
475
|
+
return await response.json()
|
|
476
476
|
} catch {
|
|
477
477
|
return undefined
|
|
478
478
|
}
|
|
479
479
|
}
|
|
480
480
|
|
|
481
|
+
/** 共享入口:命中缓存或复用在途请求;失败(undefined)不写缓存。 */
|
|
482
|
+
function fetchClientConfigs(credential, fetchImpl) {
|
|
483
|
+
/**
|
|
484
|
+
* 缓存/in-flight 去重只对**全局 fetch** 生效:注入的 fetchImpl 几乎都是测试
|
|
485
|
+
* mock,没有稳定可区分的身份标识,按函数名拼 key 会串味 —— 直接透传。
|
|
486
|
+
*/
|
|
487
|
+
if (fetchImpl !== globalThis.fetch) return fetchClientConfigsOnce(credential, fetchImpl)
|
|
488
|
+
const key = String(credential?.zcode_jwt ?? '')
|
|
489
|
+
const hit = clientConfigsCache.get(key)
|
|
490
|
+
if (hit !== undefined && Date.now() - hit.at < CLIENT_CONFIGS_CACHE_MS) return hit.promise
|
|
491
|
+
const pending = clientConfigsInflight.get(key)
|
|
492
|
+
if (pending !== undefined) return pending
|
|
493
|
+
const promise = fetchClientConfigsOnce(credential, fetchImpl).then((parsed) => {
|
|
494
|
+
clientConfigsInflight.delete(key)
|
|
495
|
+
if (parsed !== undefined) clientConfigsCache.set(key, { at: Date.now(), promise: Promise.resolve(parsed) })
|
|
496
|
+
return parsed
|
|
497
|
+
})
|
|
498
|
+
clientConfigsInflight.set(key, promise)
|
|
499
|
+
return promise
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* 拉服务端下发的 captcha 配置(60 秒 TTL,失败返回 undefined 由调用方回退兜底值)。
|
|
504
|
+
*
|
|
505
|
+
* ⚠ `platform` 必须是 **`unknown`**(实测 win32/win64/windows/electron/desktop/linux 一律 400 code 3001)。
|
|
506
|
+
*/
|
|
507
|
+
export async function fetchCaptchaConfig(credential, fetchImpl = globalThis.fetch) {
|
|
508
|
+
const parsed = await fetchClientConfigs(credential, fetchImpl)
|
|
509
|
+
if (parsed === undefined) return undefined
|
|
510
|
+
const captcha = parsed.data?.configs?.captcha
|
|
511
|
+
if (captcha === undefined) return undefined
|
|
512
|
+
const { region, prefix, sceneId } = captcha
|
|
513
|
+
if (typeof region !== 'string' || typeof prefix !== 'string' || typeof sceneId !== 'string') return undefined
|
|
514
|
+
return { region, prefix, sceneId }
|
|
515
|
+
}
|
|
516
|
+
|
|
481
517
|
/**
|
|
482
518
|
* 从上游拉模型目录(含上下文窗口、最大输出、思考档位、视觉能力)。
|
|
483
519
|
*
|
|
@@ -485,52 +521,42 @@ export async function fetchCaptchaConfig(credential, fetchImpl = globalThis.fetc
|
|
|
485
521
|
* ⚠ `reasoning.levels` 的键序不是展示序:必须显式排序。
|
|
486
522
|
*/
|
|
487
523
|
export async function fetchModels(credential, fetchImpl = globalThis.fetch) {
|
|
488
|
-
const
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
if (
|
|
496
|
-
const
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
const
|
|
500
|
-
const
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
const levels = item.reasoning.levels
|
|
512
|
-
if (typeof levels === 'object' && levels !== null) {
|
|
513
|
-
const keys = Object.keys(levels)
|
|
514
|
-
if (keys.length > 0) reasoningLevels = orderReasoningLevels(keys)
|
|
515
|
-
}
|
|
516
|
-
if (typeof item.reasoning.defaultLevel === 'string' && item.reasoning.defaultLevel.length > 0) {
|
|
517
|
-
defaultReasoningLevel = item.reasoning.defaultLevel
|
|
518
|
-
}
|
|
524
|
+
const parsed = await fetchClientConfigs(credential, fetchImpl)
|
|
525
|
+
if (parsed === undefined) return undefined
|
|
526
|
+
const raw = parsed.data?.builtinModels
|
|
527
|
+
if (typeof raw !== 'object' || raw === null) return undefined
|
|
528
|
+
const entries = Array.isArray(raw) ? raw : Object.values(raw)
|
|
529
|
+
const models = []
|
|
530
|
+
for (const item of entries) {
|
|
531
|
+
if (typeof item !== 'object' || item === null) continue
|
|
532
|
+
const id = item.modelId ?? item.id
|
|
533
|
+
if (typeof id !== 'string' || id.length === 0) continue
|
|
534
|
+
const contextWindow = num(item.contextWindow)
|
|
535
|
+
const maxCompletionTokens = num(item.maxCompletionTokens ?? item.maxTokens)
|
|
536
|
+
const vision = typeof item.capabilities === 'object' && item.capabilities !== null ? item.capabilities.vision === true : false
|
|
537
|
+
let reasoningLevels
|
|
538
|
+
let defaultReasoningLevel
|
|
539
|
+
if (typeof item.reasoning === 'object' && item.reasoning !== null) {
|
|
540
|
+
const levels = item.reasoning.levels
|
|
541
|
+
if (typeof levels === 'object' && levels !== null) {
|
|
542
|
+
const keys = Object.keys(levels)
|
|
543
|
+
if (keys.length > 0) reasoningLevels = orderReasoningLevels(keys)
|
|
544
|
+
}
|
|
545
|
+
if (typeof item.reasoning.defaultLevel === 'string' && item.reasoning.defaultLevel.length > 0) {
|
|
546
|
+
defaultReasoningLevel = item.reasoning.defaultLevel
|
|
519
547
|
}
|
|
520
|
-
models.push({
|
|
521
|
-
id,
|
|
522
|
-
name: typeof item.name === 'string' && item.name.length > 0 ? item.name : id,
|
|
523
|
-
contextWindow: contextWindow !== undefined && contextWindow > 0 ? contextWindow : 200_000,
|
|
524
|
-
maxTokens: maxCompletionTokens !== undefined && maxCompletionTokens > 0 ? maxCompletionTokens : 32_768,
|
|
525
|
-
supportsImage: vision,
|
|
526
|
-
...(reasoningLevels !== undefined ? { reasoningLevels } : {}),
|
|
527
|
-
...(defaultReasoningLevel !== undefined ? { defaultReasoningLevel } : {}),
|
|
528
|
-
})
|
|
529
548
|
}
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
549
|
+
models.push({
|
|
550
|
+
id,
|
|
551
|
+
name: typeof item.name === 'string' && item.name.length > 0 ? item.name : id,
|
|
552
|
+
contextWindow: contextWindow !== undefined && contextWindow > 0 ? contextWindow : 200_000,
|
|
553
|
+
maxTokens: maxCompletionTokens !== undefined && maxCompletionTokens > 0 ? maxCompletionTokens : 32_768,
|
|
554
|
+
supportsImage: vision,
|
|
555
|
+
...(reasoningLevels !== undefined ? { reasoningLevels } : {}),
|
|
556
|
+
...(defaultReasoningLevel !== undefined ? { defaultReasoningLevel } : {}),
|
|
557
|
+
})
|
|
533
558
|
}
|
|
559
|
+
return models.length > 0 ? models : undefined
|
|
534
560
|
}
|
|
535
561
|
|
|
536
562
|
/** 把档位键排成展示序(不能直接用 JSON 键序)。 */
|
package/lib/upstream.js
CHANGED
|
@@ -104,7 +104,14 @@ export function nextUtc8DayStartMs(now = new Date()) {
|
|
|
104
104
|
return dayStartShifted + 86_400_000 - OFFSET
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
/**
|
|
107
|
+
/**
|
|
108
|
+
* 兜底模型表(上游 client/configs 不可达时用;数值抄自实测,不是估值)。
|
|
109
|
+
*
|
|
110
|
+
* ⚠ `reasoningLevels` / `defaultReasoningLevel` 与上游目录一致(2026-10-25 实测)。
|
|
111
|
+
* 缺它们时宿主拿到的模型无思考档位元数据:选档即抛 `UNSUPPORTED_REASONING_EFFORT`
|
|
112
|
+
* (UI 报「不支持当前档位」且无输出)—— 这是 0.3.1 修复前「GLM-5.3 思考等级失效」
|
|
113
|
+
* 的直接成因(目录间歇拉取失败 → 兜底表无档位 → 校验拒绝)。
|
|
114
|
+
*/
|
|
108
115
|
export const ZCODE_FALLBACK_MODELS = Object.freeze([
|
|
109
116
|
Object.freeze({
|
|
110
117
|
id: 'GLM-5.3-Flash',
|
|
@@ -112,6 +119,8 @@ export const ZCODE_FALLBACK_MODELS = Object.freeze([
|
|
|
112
119
|
contextWindow: 1_000_000,
|
|
113
120
|
maxTokens: 128_000,
|
|
114
121
|
supportsImage: true,
|
|
122
|
+
reasoningLevels: ['low', 'high', 'max'],
|
|
123
|
+
defaultReasoningLevel: 'max',
|
|
115
124
|
}),
|
|
116
125
|
Object.freeze({
|
|
117
126
|
id: 'GLM-5.3',
|
|
@@ -119,5 +128,7 @@ export const ZCODE_FALLBACK_MODELS = Object.freeze([
|
|
|
119
128
|
contextWindow: 1_000_000,
|
|
120
129
|
maxTokens: 128_000,
|
|
121
130
|
supportsImage: false,
|
|
131
|
+
reasoningLevels: ['low', 'high', 'max'],
|
|
132
|
+
defaultReasoningLevel: 'max',
|
|
122
133
|
}),
|
|
123
134
|
])
|
package/package.json
CHANGED
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "dsh-zcode-startplan",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "DSH 接入 ZCode 赠送免费 plan(account:bigmodel-start-plan):多账号池 + 按需阿里云 captcha + 直连 zcode-plan/anthropic 的 llm 适配器。移植自 gitee.com/iJetLi/bonus-plan-4-open-zcode。",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"license": "GPL-3.0-or-later",
|
|
7
|
-
"author": "Venshell",
|
|
8
|
-
"repository": {
|
|
9
|
-
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/Venshell/dsh-zcode-startplan.git"
|
|
11
|
-
},
|
|
12
|
-
"homepage": "https://github.com/Venshell/dsh-zcode-startplan#readme",
|
|
13
|
-
"bugs": "https://github.com/Venshell/dsh-zcode-startplan/issues",
|
|
14
|
-
"keywords": [
|
|
15
|
-
"dsh-plugin",
|
|
16
|
-
"deepseek-harness",
|
|
17
|
-
"zcode",
|
|
18
|
-
"zhipu",
|
|
19
|
-
"glm",
|
|
20
|
-
"model-provider",
|
|
21
|
-
"captcha",
|
|
22
|
-
"anthropic-messages"
|
|
23
|
-
],
|
|
24
|
-
"main": "./index.js",
|
|
25
|
-
"exports": {
|
|
26
|
-
".": "./index.js",
|
|
27
|
-
"./client": "./client.js",
|
|
28
|
-
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
29
|
-
"./package.json": "./package.json",
|
|
30
|
-
"./locale/*.json": "./locale/*.json",
|
|
31
|
-
"./icon": "./icon.svg"
|
|
32
|
-
},
|
|
33
|
-
"files": [
|
|
34
|
-
"index.js",
|
|
35
|
-
"client.js",
|
|
36
|
-
"lib",
|
|
37
|
-
"bin",
|
|
38
|
-
"scripts",
|
|
39
|
-
"locale/*.json",
|
|
40
|
-
"icon.svg",
|
|
41
|
-
"cordis.patch.yml",
|
|
42
|
-
"README.md",
|
|
43
|
-
"CHANGELOG.md",
|
|
44
|
-
"LICENSE"
|
|
45
|
-
],
|
|
46
|
-
"bin": {
|
|
47
|
-
"zcode-start-plan": "./bin/cli.mjs"
|
|
48
|
-
},
|
|
49
|
-
"scripts": {
|
|
50
|
-
"check": "node --check index.js && node --check bin/cli.mjs",
|
|
51
|
-
"test": "node scripts/run-tests.mjs",
|
|
52
|
-
"smoke": "node scripts/smoke-install.mjs",
|
|
53
|
-
"verify:compat": "node scripts/verify_compat.mjs",
|
|
54
|
-
"login": "node bin/cli.mjs login",
|
|
55
|
-
"status": "node bin/cli.mjs status",
|
|
56
|
-
"probe": "node bin/cli.mjs probe"
|
|
57
|
-
},
|
|
58
|
-
"peerDependencies": {
|
|
59
|
-
"@deepseek-ai/dsh-llm": "^0.2.
|
|
60
|
-
},
|
|
61
|
-
"engines": {
|
|
62
|
-
"node": "^22.19 || >=24"
|
|
63
|
-
},
|
|
64
|
-
"dsh": {
|
|
65
|
-
"id": "dsh-zcode-startplan",
|
|
66
|
-
"name": "ZCode Start Plan",
|
|
67
|
-
"version": "0.
|
|
68
|
-
"permissions": "模型供应商接入, 账号池管理",
|
|
69
|
-
"bundle": {
|
|
70
|
-
"patch": "./cordis.patch.yml"
|
|
71
|
-
},
|
|
72
|
-
"client": {
|
|
73
|
-
"platform": "web",
|
|
74
|
-
"immediately": true,
|
|
75
|
-
"inject": [
|
|
76
|
-
"@deepseek-ai/dsh-client-ui-renderer"
|
|
77
|
-
]
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "dsh-zcode-startplan",
|
|
3
|
+
"version": "0.4.5",
|
|
4
|
+
"description": "DSH 接入 ZCode 赠送免费 plan(account:bigmodel-start-plan):多账号池 + 按需阿里云 captcha + 直连 zcode-plan/anthropic 的 llm 适配器。移植自 gitee.com/iJetLi/bonus-plan-4-open-zcode。",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "GPL-3.0-or-later",
|
|
7
|
+
"author": "Venshell",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/Venshell/dsh-zcode-startplan.git"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/Venshell/dsh-zcode-startplan#readme",
|
|
13
|
+
"bugs": "https://github.com/Venshell/dsh-zcode-startplan/issues",
|
|
14
|
+
"keywords": [
|
|
15
|
+
"dsh-plugin",
|
|
16
|
+
"deepseek-harness",
|
|
17
|
+
"zcode",
|
|
18
|
+
"zhipu",
|
|
19
|
+
"glm",
|
|
20
|
+
"model-provider",
|
|
21
|
+
"captcha",
|
|
22
|
+
"anthropic-messages"
|
|
23
|
+
],
|
|
24
|
+
"main": "./index.js",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": "./index.js",
|
|
27
|
+
"./client": "./client.js",
|
|
28
|
+
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
29
|
+
"./package.json": "./package.json",
|
|
30
|
+
"./locale/*.json": "./locale/*.json",
|
|
31
|
+
"./icon": "./icon.svg"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"index.js",
|
|
35
|
+
"client.js",
|
|
36
|
+
"lib",
|
|
37
|
+
"bin",
|
|
38
|
+
"scripts",
|
|
39
|
+
"locale/*.json",
|
|
40
|
+
"icon.svg",
|
|
41
|
+
"cordis.patch.yml",
|
|
42
|
+
"README.md",
|
|
43
|
+
"CHANGELOG.md",
|
|
44
|
+
"LICENSE"
|
|
45
|
+
],
|
|
46
|
+
"bin": {
|
|
47
|
+
"zcode-start-plan": "./bin/cli.mjs"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"check": "node --check index.js && node --check bin/cli.mjs",
|
|
51
|
+
"test": "node scripts/run-tests.mjs",
|
|
52
|
+
"smoke": "node scripts/smoke-install.mjs",
|
|
53
|
+
"verify:compat": "node scripts/verify_compat.mjs",
|
|
54
|
+
"login": "node bin/cli.mjs login",
|
|
55
|
+
"status": "node bin/cli.mjs status",
|
|
56
|
+
"probe": "node bin/cli.mjs probe"
|
|
57
|
+
},
|
|
58
|
+
"peerDependencies": {
|
|
59
|
+
"@deepseek-ai/dsh-llm": "^0.2.1-rc.3"
|
|
60
|
+
},
|
|
61
|
+
"engines": {
|
|
62
|
+
"node": "^22.19 || >=24"
|
|
63
|
+
},
|
|
64
|
+
"dsh": {
|
|
65
|
+
"id": "dsh-zcode-startplan",
|
|
66
|
+
"name": "ZCode Start Plan",
|
|
67
|
+
"version": "0.4.5",
|
|
68
|
+
"permissions": "模型供应商接入, 账号池管理",
|
|
69
|
+
"bundle": {
|
|
70
|
+
"patch": "./cordis.patch.yml"
|
|
71
|
+
},
|
|
72
|
+
"client": {
|
|
73
|
+
"platform": "web",
|
|
74
|
+
"immediately": true,
|
|
75
|
+
"inject": [
|
|
76
|
+
"@deepseek-ai/dsh-client-ui-renderer"
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** 临时诊断:连宿主 CDP,量插件面板里开关与按钮的实际右缘坐标。 */
|
|
2
|
+
const DEBUG_PORT = 9229
|
|
3
|
+
|
|
4
|
+
const list = await (await fetch(`http://127.0.0.1:${DEBUG_PORT}/json/list`)).json()
|
|
5
|
+
const pages = list.filter((t) => t.type === 'page' && String(t.url).startsWith('http://127.0.0.1:'))
|
|
6
|
+
if (pages.length === 0) {
|
|
7
|
+
console.log('NO_PAGE_TARGET', list.map((t) => ({ type: t.type, url: t.url })))
|
|
8
|
+
process.exit(0)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const expr = `(() => {
|
|
12
|
+
const panel = document.querySelector('.zsp-panel')
|
|
13
|
+
if (!panel) return { present: false, url: location.href }
|
|
14
|
+
const rect = (el) => { const r = el.getBoundingClientRect(); return { left: +r.left.toFixed(1), right: +r.right.toFixed(1), top: +r.top.toFixed(1), width: +r.width.toFixed(1) } }
|
|
15
|
+
const toggles = [...panel.querySelectorAll('.zsp-toggle')].map((t) => ({ ...rect(t), checked: t.querySelector('input')?.checked ?? null }))
|
|
16
|
+
const buttons = [...panel.querySelectorAll('.zsp-actions .zsp-btn')].map((b) => ({ text: b.textContent, ...rect(b) }))
|
|
17
|
+
const spacers = [...panel.querySelectorAll('.zsp-actions .zsp-spacer')].map((s) => ({ ...rect(s), flex: getComputedStyle(s).flex }))
|
|
18
|
+
const css = [...panel.querySelectorAll('style')].map((s) => s.textContent).join('')
|
|
19
|
+
return {
|
|
20
|
+
present: true,
|
|
21
|
+
url: location.href,
|
|
22
|
+
hasGroup: !!panel.querySelector('.zsp-group'),
|
|
23
|
+
hasUnifiedRow: !!panel.querySelector('.zsp-unified'),
|
|
24
|
+
cssHasActionsSpacerRule: css.includes('.zsp-actions .zsp-spacer'),
|
|
25
|
+
cssSpacerFlex: css.includes('flex:1 1 auto'),
|
|
26
|
+
toggles,
|
|
27
|
+
buttons,
|
|
28
|
+
spacers,
|
|
29
|
+
}
|
|
30
|
+
})()`
|
|
31
|
+
|
|
32
|
+
const page = pages[0]
|
|
33
|
+
const ws = new WebSocket(page.webSocketDebuggerUrl)
|
|
34
|
+
const timeout = setTimeout(() => {
|
|
35
|
+
console.log('TIMEOUT waiting for CDP response')
|
|
36
|
+
process.exit(1)
|
|
37
|
+
}, 10_000)
|
|
38
|
+
|
|
39
|
+
await new Promise((resolve, reject) => {
|
|
40
|
+
ws.onopen = resolve
|
|
41
|
+
ws.onerror = (e) => reject(new Error('ws error'))
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
const result = await new Promise((resolve) => {
|
|
45
|
+
ws.onmessage = (ev) => {
|
|
46
|
+
const msg = JSON.parse(ev.data)
|
|
47
|
+
if (msg.id === 1) resolve(msg.result)
|
|
48
|
+
}
|
|
49
|
+
ws.send(JSON.stringify({ id: 1, method: 'Runtime.evaluate', params: { expression: expr, returnByValue: true } }))
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
clearTimeout(timeout)
|
|
53
|
+
ws.close()
|
|
54
|
+
console.log(JSON.stringify(result.result?.value ?? result, null, 2))
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Minimal asar reader: list or extract a subtree from an Electron asar archive.
|
|
2
|
+
// Usage: node asar-list.mjs <archive> <prefix> [outDir]
|
|
3
|
+
// - no outDir: list entries under prefix
|
|
4
|
+
// - with outDir: extract entries under prefix (incl. unpacked siblings from .unpacked)
|
|
5
|
+
import fs from 'node:fs';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
|
|
8
|
+
const [archive, prefix = '', outDir] = process.argv.slice(2);
|
|
9
|
+
if (!archive) {
|
|
10
|
+
console.error('usage: node asar-list.mjs <archive> [prefix] [outDir]');
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const fd = fs.openSync(archive, 'r');
|
|
15
|
+
const pickle = Buffer.alloc(16);
|
|
16
|
+
fs.readSync(fd, pickle, 0, 16, 0);
|
|
17
|
+
const jsonLen = pickle.readUInt32LE(12);
|
|
18
|
+
const jsonBuf = Buffer.alloc(jsonLen);
|
|
19
|
+
fs.readSync(fd, jsonBuf, 0, jsonLen, 16);
|
|
20
|
+
const header = JSON.parse(jsonBuf.toString('utf8'));
|
|
21
|
+
const baseOffset = 16 + jsonLen;
|
|
22
|
+
|
|
23
|
+
function walk(node, rel, cb) {
|
|
24
|
+
if (node.files) {
|
|
25
|
+
for (const [name, child] of Object.entries(node.files)) walk(child, rel ? rel + '/' + name : name, cb);
|
|
26
|
+
} else if (node.unpacked) {
|
|
27
|
+
cb(rel, null, true);
|
|
28
|
+
} else {
|
|
29
|
+
cb(rel, { offset: baseOffset + Number(node.offset), size: node.size }, false);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (outDir) {
|
|
34
|
+
fs.mkdirSync(outDir, { recursive: true });
|
|
35
|
+
walk(header, '', (rel, file, unpacked) => {
|
|
36
|
+
if (!(rel === prefix || rel.startsWith(prefix + '/'))) return;
|
|
37
|
+
const relInside = rel === prefix ? '' : rel.slice(prefix.length + 1);
|
|
38
|
+
if (!relInside) return;
|
|
39
|
+
const dest = path.join(outDir, relInside);
|
|
40
|
+
if (unpacked) {
|
|
41
|
+
const src = path.join(path.dirname(archive), path.basename(archive) + '.unpacked', rel);
|
|
42
|
+
if (fs.existsSync(src)) {
|
|
43
|
+
if (fs.statSync(src).isDirectory()) fs.cpSync(src, dest, { recursive: true });
|
|
44
|
+
else {
|
|
45
|
+
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
46
|
+
fs.copyFileSync(src, dest);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (!file) return;
|
|
52
|
+
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
53
|
+
const buf = Buffer.alloc(file.size);
|
|
54
|
+
fs.readSync(fd, buf, 0, file.size, file.offset);
|
|
55
|
+
fs.writeFileSync(dest, buf);
|
|
56
|
+
});
|
|
57
|
+
console.log('extracted ' + prefix + ' to ' + outDir);
|
|
58
|
+
} else {
|
|
59
|
+
const entries = [];
|
|
60
|
+
walk(header, '', (rel, file, unpacked) => {
|
|
61
|
+
if (rel === prefix || rel.startsWith(prefix + '/')) {
|
|
62
|
+
entries.push((unpacked ? 'U ' : file ? 'F ' : 'D ') + rel);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
console.log(entries.join('\n'));
|
|
66
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// 用宿主自带的 evaluatePluginCompatibility 校验本插件 manifest(rc.2 / rc.3 / 0.3.0)。
|
|
2
|
+
import { readFileSync } from 'node:fs'
|
|
3
|
+
import { pathToFileURL } from 'node:url'
|
|
4
|
+
|
|
5
|
+
const host = pathToFileURL(process.cwd() + '/.tmp-dsh-extract-full/node_modules/@deepseek-ai/dsh-app-boot/lib/index.js').href
|
|
6
|
+
const m = await import(host)
|
|
7
|
+
const pkg = JSON.parse(readFileSync(process.cwd() + '/package.json', 'utf8'))
|
|
8
|
+
for (const rv of ['0.2.1-rc.2', '0.2.1-rc.3', '0.3.0']) {
|
|
9
|
+
const issue = m.evaluatePluginCompatibility(pkg, {}, rv)
|
|
10
|
+
console.log(rv, '=>', issue === undefined ? 'COMPATIBLE' : JSON.stringify(issue.requirements))
|
|
11
|
+
}
|
|
@@ -37,7 +37,7 @@ for (const [name, range] of Object.entries(peers)) {
|
|
|
37
37
|
/** prerelease 陷阱:区间里没有 prerelease 段时,rc 版会被判为不满足。 */
|
|
38
38
|
if (/^\^?\d+\.\d+\.\d+$/.test(range)) {
|
|
39
39
|
notes.push(
|
|
40
|
-
`${name}: "${range}" 不含 prerelease 段;若宿主是 0.x 的 rc 版本会被判不兼容(建议写成 "^0.2.
|
|
40
|
+
`${name}: "${range}" 不含 prerelease 段;若宿主是 0.x 的 rc 版本会被判不兼容(建议写成 "^0.2.1-rc.3" 这类)`,
|
|
41
41
|
)
|
|
42
42
|
}
|
|
43
43
|
}
|