dsh-zcode-startplan 0.2.0 → 0.5.2
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 +564 -0
- package/README.md +134 -8
- package/client.js +395 -52
- package/cordis.patch.yml +2 -0
- package/index.js +56 -2
- package/lib/adapter.js +167 -4
- package/lib/anthropic-body.js +167 -2
- package/lib/assemble.js +253 -20
- package/lib/local-endpoint.js +16 -2
- package/lib/manage-routes.js +260 -22
- package/lib/pinned-model.js +56 -0
- package/lib/plan-client.js +110 -5
- package/lib/pool.js +11 -0
- package/lib/stream-translator.js +30 -8
- package/lib/upstream-api.js +134 -67
- package/lib/upstream.js +12 -1
- package/package.json +81 -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/restart-dsh.ps1 +41 -1
- package/scripts/verify_compat.mjs +1 -1
- package/tests/anthropic-body.test.mjs +305 -0
- package/tests/assembler-contract.test.mjs +256 -0
- package/tests/claim-routes.test.mjs +293 -0
- package/tests/client-panel.test.mjs +356 -0
- package/tests/e2e.test.mjs +353 -0
- package/tests/fixtures/quota-200.json +1 -0
- package/tests/login-channel.test.mjs +102 -0
- package/tests/pinned-models.test.mjs +497 -0
- package/tests/plan-client.test.mjs +222 -0
- package/tests/pool.test.mjs +93 -0
- package/tests/sse.test.mjs +86 -0
- package/tests/stream-translator.test.mjs +137 -0
- package/tests/support/resolve-profile-deps.mjs +52 -0
- package/tests/upstream-error-200.test.mjs +125 -0
- package/tests/upstream.test.mjs +250 -0
package/lib/stream-translator.js
CHANGED
|
@@ -25,6 +25,21 @@
|
|
|
25
25
|
*
|
|
26
26
|
* `usage` 必须在 `finish` 之前;`finish` 之后不得再有任何 chunk;工具参数以
|
|
27
27
|
* **原始 JSON 字符串**增量下发。故这里采用「先 `block-end`,再 `usage`,再 `finish`」。
|
|
28
|
+
*
|
|
29
|
+
* ## finish chunk 的形状(官方契约,`dsh-llm` rc.3 起有 .d.ts 钉死)
|
|
30
|
+
*
|
|
31
|
+
* 终止块是 `{ type: 'finish', reason: FinishReason }` —— `reason` 是**对象**,
|
|
32
|
+
* 按 kind 区分(`FinishReasonMap`,`dsh-llm/lib/types/types.d.ts`):
|
|
33
|
+
*
|
|
34
|
+
* ```
|
|
35
|
+
* { kind: 'stop' } | { kind: 'tool-calls' } | { kind: 'max-tokens' }
|
|
36
|
+
* { kind: 'aborted', failure } | { kind: 'error', failure }
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* 宿主 `BlockAssembler` 读 `chunk.reason`(`this._finish = chunk.reason`),
|
|
40
|
+
* agent-loop 再读 `finish.kind === 'error' | 'aborted'` 判错。
|
|
41
|
+
* 之前发的是 `{ kind, failure }`(kind 在顶层、没有 reason)—— 错误会被宿主
|
|
42
|
+
* 静默吞成 `{ kind: 'stop' }`「正常结束」,重试与错误上报全部失效。
|
|
28
43
|
*/
|
|
29
44
|
|
|
30
45
|
/**
|
|
@@ -225,12 +240,14 @@ export class AnthropicStreamTranslator {
|
|
|
225
240
|
if (this.#sawError !== undefined) {
|
|
226
241
|
out.push({
|
|
227
242
|
type: 'finish',
|
|
228
|
-
|
|
229
|
-
|
|
243
|
+
reason: {
|
|
244
|
+
kind: 'error',
|
|
245
|
+
failure: { code: mapErrorCode(this.#sawError), message: this.#sawError.message },
|
|
246
|
+
},
|
|
230
247
|
})
|
|
231
248
|
return out
|
|
232
249
|
}
|
|
233
|
-
out.push({ type: 'finish',
|
|
250
|
+
out.push({ type: 'finish', reason: this.#finishReason ?? { kind: 'stop' } })
|
|
234
251
|
return out
|
|
235
252
|
}
|
|
236
253
|
|
|
@@ -247,18 +264,23 @@ export class AnthropicStreamTranslator {
|
|
|
247
264
|
}
|
|
248
265
|
}
|
|
249
266
|
|
|
250
|
-
/**
|
|
267
|
+
/**
|
|
268
|
+
* Anthropic `stop_reason` → DSH finish reason 对象(`FinishReasonMap` 形态)。
|
|
269
|
+
*
|
|
270
|
+
* ⚠ 返回的是 `reason` **对象**(`{ kind: '…' }`),不是字符串 ——
|
|
271
|
+
* `BlockAssembler` 会把它原样存进 `finish`,agent-loop 按 `finish.kind` 路由。
|
|
272
|
+
*/
|
|
251
273
|
export function mapStopReason(stopReason) {
|
|
252
274
|
switch (stopReason) {
|
|
253
275
|
case 'tool_use':
|
|
254
|
-
return 'tool-calls'
|
|
276
|
+
return { kind: 'tool-calls' }
|
|
255
277
|
case 'max_tokens':
|
|
256
|
-
return '
|
|
278
|
+
return { kind: 'max-tokens' }
|
|
257
279
|
case 'end_turn':
|
|
258
280
|
case 'stop_sequence':
|
|
259
|
-
return 'stop'
|
|
281
|
+
return { kind: 'stop' }
|
|
260
282
|
default:
|
|
261
|
-
return 'stop'
|
|
283
|
+
return { kind: 'stop' }
|
|
262
284
|
}
|
|
263
285
|
}
|
|
264
286
|
|
package/lib/upstream-api.js
CHANGED
|
@@ -351,23 +351,64 @@ export async function fetchBalance(credential, fetchImpl = globalThis.fetch) {
|
|
|
351
351
|
usedUnits: num(item.used_units),
|
|
352
352
|
remainingUnits: num(item.remaining_units),
|
|
353
353
|
availableUnits: num(item.available_units),
|
|
354
|
-
|
|
354
|
+
/**
|
|
355
|
+
* ⚠ 上游给的是**秒级**,统一归一到毫秒(与 `pending[].effectiveAt` 同单位)。
|
|
356
|
+
* 不归一会让 `new Date(x)` 落到 1970 年 —— 界面上就是「1970/1/21 到期」。
|
|
357
|
+
*/
|
|
358
|
+
expiresAt: toEpochMs(num(item.expires_at) ?? 0),
|
|
355
359
|
})
|
|
356
360
|
}
|
|
361
|
+
/**
|
|
362
|
+
* 未生效的**计划权益**(pending entitlements)。
|
|
363
|
+
*
|
|
364
|
+
* 上游把「已领但还没到点」的额度放在 `plans[].entitlements[]`:
|
|
365
|
+
* `balances` 只列**当前生效**的桶 —— 一个 23 点启用的 3 亿 token 包在 22 点的
|
|
366
|
+
* `balances` 里不存在,于是面板显示 0/0,用户以为领取失败(2026-10-26 实测)。
|
|
367
|
+
* 判据:`effective_at`(秒级)在 `server_time`(缺省取本地现在)之后,
|
|
368
|
+
* 且 `grant_units` 为正数。已生效的 entitlement 不收(balances 已覆盖)。
|
|
369
|
+
*/
|
|
370
|
+
const serverNowMs = toEpochMs(num(data.server_time) ?? 0) || Date.now()
|
|
371
|
+
const pending = []
|
|
372
|
+
for (const plan of Array.isArray(data.plans) ? data.plans : []) {
|
|
373
|
+
if (typeof plan !== 'object' || plan === null) continue
|
|
374
|
+
for (const item of Array.isArray(plan.entitlements) ? plan.entitlements : []) {
|
|
375
|
+
if (typeof item !== 'object' || item === null) continue
|
|
376
|
+
const effectiveAtMs = toEpochMs(num(item.effective_at) ?? 0)
|
|
377
|
+
const grantUnits = num(item.grant_units)
|
|
378
|
+
if (effectiveAtMs === 0 || !(grantUnits > 0) || effectiveAtMs <= serverNowMs) continue
|
|
379
|
+
/** 未生效权益的到期时间 = 所属 plan 的 `ends_at`(整份 plan 一起作废)。 */
|
|
380
|
+
const planEndsAtMs = toEpochMs(num(plan.ends_at) ?? 0)
|
|
381
|
+
pending.push({
|
|
382
|
+
planId: typeof plan.plan_id === 'string' ? plan.plan_id : undefined,
|
|
383
|
+
showName: typeof item.show_name === 'string' ? item.show_name : undefined,
|
|
384
|
+
unitType: typeof item.unit_type === 'string' ? item.unit_type : undefined,
|
|
385
|
+
grantUnits,
|
|
386
|
+
effectiveAt: effectiveAtMs,
|
|
387
|
+
...(planEndsAtMs > 0 ? { expiresAt: planEndsAtMs } : {}),
|
|
388
|
+
})
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
pending.sort((a, b) => a.effectiveAt - b.effectiveAt)
|
|
357
392
|
let remaining = 0
|
|
358
393
|
let total = 0
|
|
359
394
|
let expiresAt
|
|
360
395
|
for (const bucket of buckets) {
|
|
361
|
-
|
|
396
|
+
const available = bucket.availableUnits ?? bucket.remainingUnits ?? 0
|
|
397
|
+
remaining += available
|
|
362
398
|
total += bucket.totalUnits ?? 0
|
|
363
|
-
|
|
364
|
-
|
|
399
|
+
/**
|
|
400
|
+
* 顶层 `expiresAt` 只汇总**还有余额**的桶:已用光的桶到期没有意义,
|
|
401
|
+
* 若把它算进来,面板会对一个空桶提示「X 到期」,反而误导。
|
|
402
|
+
*/
|
|
403
|
+
if (available > 0 && Number.isFinite(bucket.expiresAt) && bucket.expiresAt > 0) {
|
|
404
|
+
if (expiresAt === undefined || bucket.expiresAt < expiresAt) expiresAt = bucket.expiresAt
|
|
365
405
|
}
|
|
366
406
|
}
|
|
367
407
|
return {
|
|
368
408
|
buckets,
|
|
369
409
|
remaining,
|
|
370
410
|
total,
|
|
411
|
+
...(pending.length > 0 ? { pending } : {}),
|
|
371
412
|
...(expiresAt !== undefined ? { expiresAt } : {}),
|
|
372
413
|
...(buckets[0]?.showName !== undefined ? { planName: buckets[0].showName } : {}),
|
|
373
414
|
}
|
|
@@ -376,17 +417,14 @@ export async function fetchBalance(credential, fetchImpl = globalThis.fetch) {
|
|
|
376
417
|
/** 补客户端活跃信号(不补则 preview 恒为空 plans)。 */
|
|
377
418
|
export async function reportActivation(credential, fetchImpl = globalThis.fetch) {
|
|
378
419
|
const appVersion = credential.app_version ?? ZCODE_APP_VERSION_FALLBACK
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
// 上报失败不阻塞(下一次调用会再补)。
|
|
388
|
-
}
|
|
389
|
-
}
|
|
420
|
+
/** 两个事件相互独立,并行上报(省一个 RTT;失败不阻塞,下次调用会再补)。 */
|
|
421
|
+
await Promise.all(['app_launch', 'app_daily_active'].map((event) =>
|
|
422
|
+
fetchWithTimeout(fetchImpl, ZCODE_EVENT_REPORT_URL, {
|
|
423
|
+
method: 'POST',
|
|
424
|
+
headers: buildZcodeHeaders(credential, { json: true }),
|
|
425
|
+
body: JSON.stringify({ event, device_mid: credential.device_mid, platform: 'win32', app_version: appVersion }),
|
|
426
|
+
}, 20_000).catch(() => {}),
|
|
427
|
+
))
|
|
390
428
|
}
|
|
391
429
|
|
|
392
430
|
/** 查当前可领的活动(priority 降序)。 */
|
|
@@ -454,11 +492,19 @@ export async function claimPlan(credential, planId, captcha, fetchImpl = globalT
|
|
|
454
492
|
}
|
|
455
493
|
|
|
456
494
|
/**
|
|
457
|
-
*
|
|
495
|
+
* `GET /api/v1/client/configs` 的共享缓存(60s TTL,仅缓存成功结果 + in-flight 去重)。
|
|
458
496
|
*
|
|
459
|
-
*
|
|
497
|
+
* captcha 配置与模型目录**是同一端点的两个字段**,此前两条链路各打一次且缓存
|
|
498
|
+
* 互相独立 —— 这里统一成一次请求、一份缓存。缓存键带上 `zcode_jwt` 与
|
|
499
|
+
* `fetchImpl` 身份:不同账号不串味;测试里逐个注入的 mock fetch 也不互相污染。
|
|
500
|
+
* **失败不缓存**(一次网络抖动不该把 sceneId 固化 60 秒)。
|
|
460
501
|
*/
|
|
461
|
-
|
|
502
|
+
const CLIENT_CONFIGS_CACHE_MS = 60_000
|
|
503
|
+
const clientConfigsCache = new Map()
|
|
504
|
+
const clientConfigsInflight = new Map()
|
|
505
|
+
|
|
506
|
+
/** 拉一次 client/configs 原文(不缓存);非 2xx / 网络错误 → undefined。 */
|
|
507
|
+
async function fetchClientConfigsOnce(credential, fetchImpl) {
|
|
462
508
|
const appVersion = credential.app_version ?? ZCODE_APP_VERSION_FALLBACK
|
|
463
509
|
const url = `${ZCODE_CLIENT_CONFIGS_URL}?app_version=${encodeURIComponent(appVersion)}&platform=unknown`
|
|
464
510
|
try {
|
|
@@ -467,17 +513,48 @@ export async function fetchCaptchaConfig(credential, fetchImpl = globalThis.fetc
|
|
|
467
513
|
headers: buildZcodeHeaders(credential, { authorization: `Bearer ${credential.zcode_jwt}`, json: false }),
|
|
468
514
|
}, 20_000)
|
|
469
515
|
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 }
|
|
516
|
+
return await response.json()
|
|
476
517
|
} catch {
|
|
477
518
|
return undefined
|
|
478
519
|
}
|
|
479
520
|
}
|
|
480
521
|
|
|
522
|
+
/** 共享入口:命中缓存或复用在途请求;失败(undefined)不写缓存。 */
|
|
523
|
+
function fetchClientConfigs(credential, fetchImpl) {
|
|
524
|
+
/**
|
|
525
|
+
* 缓存/in-flight 去重只对**全局 fetch** 生效:注入的 fetchImpl 几乎都是测试
|
|
526
|
+
* mock,没有稳定可区分的身份标识,按函数名拼 key 会串味 —— 直接透传。
|
|
527
|
+
*/
|
|
528
|
+
if (fetchImpl !== globalThis.fetch) return fetchClientConfigsOnce(credential, fetchImpl)
|
|
529
|
+
const key = String(credential?.zcode_jwt ?? '')
|
|
530
|
+
const hit = clientConfigsCache.get(key)
|
|
531
|
+
if (hit !== undefined && Date.now() - hit.at < CLIENT_CONFIGS_CACHE_MS) return hit.promise
|
|
532
|
+
const pending = clientConfigsInflight.get(key)
|
|
533
|
+
if (pending !== undefined) return pending
|
|
534
|
+
const promise = fetchClientConfigsOnce(credential, fetchImpl).then((parsed) => {
|
|
535
|
+
clientConfigsInflight.delete(key)
|
|
536
|
+
if (parsed !== undefined) clientConfigsCache.set(key, { at: Date.now(), promise: Promise.resolve(parsed) })
|
|
537
|
+
return parsed
|
|
538
|
+
})
|
|
539
|
+
clientConfigsInflight.set(key, promise)
|
|
540
|
+
return promise
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
/**
|
|
544
|
+
* 拉服务端下发的 captcha 配置(60 秒 TTL,失败返回 undefined 由调用方回退兜底值)。
|
|
545
|
+
*
|
|
546
|
+
* ⚠ `platform` 必须是 **`unknown`**(实测 win32/win64/windows/electron/desktop/linux 一律 400 code 3001)。
|
|
547
|
+
*/
|
|
548
|
+
export async function fetchCaptchaConfig(credential, fetchImpl = globalThis.fetch) {
|
|
549
|
+
const parsed = await fetchClientConfigs(credential, fetchImpl)
|
|
550
|
+
if (parsed === undefined) return undefined
|
|
551
|
+
const captcha = parsed.data?.configs?.captcha
|
|
552
|
+
if (captcha === undefined) return undefined
|
|
553
|
+
const { region, prefix, sceneId } = captcha
|
|
554
|
+
if (typeof region !== 'string' || typeof prefix !== 'string' || typeof sceneId !== 'string') return undefined
|
|
555
|
+
return { region, prefix, sceneId }
|
|
556
|
+
}
|
|
557
|
+
|
|
481
558
|
/**
|
|
482
559
|
* 从上游拉模型目录(含上下文窗口、最大输出、思考档位、视觉能力)。
|
|
483
560
|
*
|
|
@@ -485,52 +562,42 @@ export async function fetchCaptchaConfig(credential, fetchImpl = globalThis.fetc
|
|
|
485
562
|
* ⚠ `reasoning.levels` 的键序不是展示序:必须显式排序。
|
|
486
563
|
*/
|
|
487
564
|
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
|
-
}
|
|
565
|
+
const parsed = await fetchClientConfigs(credential, fetchImpl)
|
|
566
|
+
if (parsed === undefined) return undefined
|
|
567
|
+
const raw = parsed.data?.builtinModels
|
|
568
|
+
if (typeof raw !== 'object' || raw === null) return undefined
|
|
569
|
+
const entries = Array.isArray(raw) ? raw : Object.values(raw)
|
|
570
|
+
const models = []
|
|
571
|
+
for (const item of entries) {
|
|
572
|
+
if (typeof item !== 'object' || item === null) continue
|
|
573
|
+
const id = item.modelId ?? item.id
|
|
574
|
+
if (typeof id !== 'string' || id.length === 0) continue
|
|
575
|
+
const contextWindow = num(item.contextWindow)
|
|
576
|
+
const maxCompletionTokens = num(item.maxCompletionTokens ?? item.maxTokens)
|
|
577
|
+
const vision = typeof item.capabilities === 'object' && item.capabilities !== null ? item.capabilities.vision === true : false
|
|
578
|
+
let reasoningLevels
|
|
579
|
+
let defaultReasoningLevel
|
|
580
|
+
if (typeof item.reasoning === 'object' && item.reasoning !== null) {
|
|
581
|
+
const levels = item.reasoning.levels
|
|
582
|
+
if (typeof levels === 'object' && levels !== null) {
|
|
583
|
+
const keys = Object.keys(levels)
|
|
584
|
+
if (keys.length > 0) reasoningLevels = orderReasoningLevels(keys)
|
|
585
|
+
}
|
|
586
|
+
if (typeof item.reasoning.defaultLevel === 'string' && item.reasoning.defaultLevel.length > 0) {
|
|
587
|
+
defaultReasoningLevel = item.reasoning.defaultLevel
|
|
519
588
|
}
|
|
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
589
|
}
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
590
|
+
models.push({
|
|
591
|
+
id,
|
|
592
|
+
name: typeof item.name === 'string' && item.name.length > 0 ? item.name : id,
|
|
593
|
+
contextWindow: contextWindow !== undefined && contextWindow > 0 ? contextWindow : 200_000,
|
|
594
|
+
maxTokens: maxCompletionTokens !== undefined && maxCompletionTokens > 0 ? maxCompletionTokens : 32_768,
|
|
595
|
+
supportsImage: vision,
|
|
596
|
+
...(reasoningLevels !== undefined ? { reasoningLevels } : {}),
|
|
597
|
+
...(defaultReasoningLevel !== undefined ? { defaultReasoningLevel } : {}),
|
|
598
|
+
})
|
|
533
599
|
}
|
|
600
|
+
return models.length > 0 ? models : undefined
|
|
534
601
|
}
|
|
535
602
|
|
|
536
603
|
/** 把档位键排成展示序(不能直接用 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,81 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "dsh-zcode-startplan",
|
|
3
|
-
"version": "0.2
|
|
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
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "dsh-zcode-startplan",
|
|
3
|
+
"version": "0.5.2",
|
|
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
|
+
"tests",
|
|
40
|
+
"locale/*.json",
|
|
41
|
+
"icon.svg",
|
|
42
|
+
"cordis.patch.yml",
|
|
43
|
+
"README.md",
|
|
44
|
+
"CHANGELOG.md",
|
|
45
|
+
"LICENSE"
|
|
46
|
+
],
|
|
47
|
+
"bin": {
|
|
48
|
+
"zcode-start-plan": "./bin/cli.mjs"
|
|
49
|
+
},
|
|
50
|
+
"scripts": {
|
|
51
|
+
"check": "node --check index.js && node --check bin/cli.mjs",
|
|
52
|
+
"test": "node scripts/run-tests.mjs",
|
|
53
|
+
"smoke": "node scripts/smoke-install.mjs",
|
|
54
|
+
"verify:compat": "node scripts/verify_compat.mjs",
|
|
55
|
+
"login": "node bin/cli.mjs login",
|
|
56
|
+
"status": "node bin/cli.mjs status",
|
|
57
|
+
"probe": "node bin/cli.mjs probe"
|
|
58
|
+
},
|
|
59
|
+
"peerDependencies": {
|
|
60
|
+
"@deepseek-ai/dsh-llm": "^0.2.1-rc.3"
|
|
61
|
+
},
|
|
62
|
+
"engines": {
|
|
63
|
+
"node": "^22.19 || >=24"
|
|
64
|
+
},
|
|
65
|
+
"dsh": {
|
|
66
|
+
"id": "dsh-zcode-startplan",
|
|
67
|
+
"name": "ZCode Start Plan",
|
|
68
|
+
"version": "0.5.2",
|
|
69
|
+
"permissions": "模型供应商接入, 账号池管理",
|
|
70
|
+
"bundle": {
|
|
71
|
+
"patch": "./cordis.patch.yml"
|
|
72
|
+
},
|
|
73
|
+
"client": {
|
|
74
|
+
"platform": "web",
|
|
75
|
+
"immediately": true,
|
|
76
|
+
"inject": [
|
|
77
|
+
"@deepseek-ai/dsh-client-ui-renderer"
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -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
|
+
}
|