dsh-unified-router 0.7.3 → 0.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/backend.js CHANGED
@@ -2505,6 +2505,7 @@ var OFFICIAL_MODEL_SPECS = Object.freeze({
2505
2505
  "deepseek-v4-pro": { context: 1048576, maxOutput: 393216 },
2506
2506
  "deepseek-v4-pro-0813": { context: 1048576, maxOutput: 393216 },
2507
2507
  "deepseek-v4-flash": { context: 1048576, maxOutput: 393216 },
2508
+ "glm-5-4": { context: 1e6, maxOutput: 131072 },
2508
2509
  "glm-5-3": { context: 1048576, maxOutput: 131072 },
2509
2510
  "glm-5-3-flash": { context: 1048576, maxOutput: 131072 },
2510
2511
  "glm-5-3-flashx": { context: 1048576, maxOutput: 131072 },
@@ -3263,7 +3264,6 @@ var QODER_CN_FALLBACK_MODELS = [
3263
3264
  { id: "fast", name: "Fast", contextWindow: 2e5, supportsImage: true, supportsThinking: false, priceFactor: 0.8 },
3264
3265
  // 2026-11-19 --list-models lists these titles without publishing their backend keys or capabilities.
3265
3266
  { id: "Qwen4-Max", name: "Qwen4-Max", contextWindow: 1e6, supportsImage: true, supportsThinking: true, priceFactor: 0.4, efforts: ["xhigh", "low", "medium"], defaultEffort: "medium", supportsDisable: true },
3266
- { id: "Qwen4-Max-Preview", name: "Qwen4-Max-Preview", contextWindow: 0 },
3267
3267
  {
3268
3268
  id: "qmodel_38max",
3269
3269
  name: "Qwen3.8-Max",
@@ -3292,6 +3292,8 @@ var QODER_CN_FALLBACK_MODELS = [
3292
3292
  { id: "dmodel", name: "DeepSeek-V4-Pro", contextWindow: 1e6, supportsImage: true, supportsThinking: true, priceFactor: 0.5, efforts: ["low", "high", "max"], defaultEffort: "max", supportsDisable: true },
3293
3293
  // 滚动别名按渠道原名保留,不凭别名推断具体快照版本。
3294
3294
  { id: "dfmodel", name: "DeepSeek-Flash", contextWindow: 1e6, maxTokens: 393216, supportsImage: true, priceFactor: 0.1, efforts: ["low", "high", "max"], defaultEffort: "high", supportsDisable: true },
3295
+ // 2026-11-26 实跑 --list-models 新增 GLM-5.4(CLI 不下发能力字段);规格取智谱官方文档(1M/128K、原生视觉、三档思考),倍率未知不编造。
3296
+ { id: "GLM-5.4", name: "GLM-5.4", contextWindow: 1e6, maxTokens: 131072, supportsImage: true, supportsThinking: true, efforts: ["low", "high", "max"], defaultEffort: "high" },
3295
3297
  { id: "gmodel", name: "GLM-5.3", contextWindow: 1e6, supportsImage: true, supportsThinking: true, priceFactor: 0.8, efforts: ["low", "high", "max"], defaultEffort: "high" },
3296
3298
  { id: "gfmodel", name: "GLM-5.3-Flash", contextWindow: 1e6, supportsImage: true, supportsThinking: true, priceFactor: 0.1, efforts: ["high", "max"], defaultEffort: "max" },
3297
3299
  { id: "kmodel_latest", name: "Kimi-K3.1-Pro", contextWindow: 1e6, supportsImage: true, priceFactor: 1, efforts: ["low", "high", "max"], defaultEffort: "high" },
package/lib/client.js CHANGED
@@ -477,6 +477,7 @@ const OFFICIAL_MODEL_SPECS = Object.freeze({
477
477
  'deepseek-v4-pro': { context: 1_048_576, maxOutput: 393_216 },
478
478
  'deepseek-v4-pro-0813': { context: 1_048_576, maxOutput: 393_216 },
479
479
  'deepseek-v4-flash': { context: 1_048_576, maxOutput: 393_216 },
480
+ 'glm-5-4': { context: 1_000_000, maxOutput: 131_072 },
480
481
  'glm-5-3': { context: 1_048_576, maxOutput: 131_072 },
481
482
  'glm-5-3-flash': { context: 1_048_576, maxOutput: 131_072 },
482
483
  'glm-5-3-flashx': { context: 1_048_576, maxOutput: 131_072 },
@@ -2629,10 +2630,14 @@ function createRouterStore(call, provider = PROVIDERS[0].id) {
2629
2630
  if (result.status !== 'fulfilled' || !result.value || typeof result.value !== 'object') return
2630
2631
  sources[side] = CACHE_MODEL_SOURCES.has(result.value.source) ? result.value.source : 'fallback'
2631
2632
  })
2632
- const fresh = await Promise.all(sides.map(side => request('model.list', { provider: side }, controller.signal)))
2633
+ // 写后重读必须走实时路径(live: true),否则会读回宿主旧快照里的 `cached` 覆盖刚刷新的 `remote`。
2634
+ const fresh = await Promise.all(sides.map(side => request('model.list', { provider: side, live: true }, controller.signal)))
2633
2635
  if (disposed || controller.signal.aborted || state.provider !== channel) return false
2634
2636
  const refreshedAt = Date.now()
2635
2637
  for (const side of sides) newestModelRead.set(side, refreshedAt)
2638
+ sides.forEach((side, index) => {
2639
+ if (!sources[side] && CACHE_MODEL_SOURCES.has(fresh[index]?.source)) sources[side] = fresh[index].source
2640
+ })
2636
2641
  const refreshed = new Map(sides.map((side, index) => [side, modelsFrom(fresh[index], side)]))
2637
2642
  publish({
2638
2643
  models: modelProvidersOf(channel).flatMap(side => refreshed.has(side)
@@ -12,6 +12,8 @@ import {
12
12
  const MINUTE = 60_000
13
13
  // preflight 明确"未提交"后的自动重查退避。
14
14
  const PREFLIGHT_BACKOFF = 15 * MINUTE
15
+ // pending 主记录(已提交、等待上游结算确认)的自动只读核实间隔:只查不重放。
16
+ const PENDING_VERIFY_INTERVAL = 5 * MINUTE
15
17
  const OUTCOMES = new Set(['claimed', 'already-claimed', 'inactive', 'ineligible', 'failed', 'pending'])
16
18
  // 上游确认已签(核实终态,可修复本地账本)。
17
19
  const DONE_KINDS = new Set(['claimed', 'already-claimed'])
@@ -56,6 +58,7 @@ export function createDailyCheckin({ dir, adapters, enabled = true, isEnabled, n
56
58
  let timer = null
57
59
  let running = null
58
60
  const localJobs = new Map()
61
+ const pendingVerifiedAt = new Map()
59
62
  const providerEnabled = provider => typeof isEnabled === 'function' ? isEnabled(provider) === true : enabled === true
60
63
  const anyEnabled = () => typeof isEnabled === 'function'
61
64
  ? (adapters.size ? [...adapters.keys()].some(providerEnabled) : isEnabled() === true)
@@ -200,6 +203,9 @@ export function createDailyCheckin({ dir, adapters, enabled = true, isEnabled, n
200
203
  outcome: verdict.outcome, local: record,
201
204
  localIsDone: localDone, confirmed, confirmedIsDone: secured,
202
205
  })
206
+ if (verified && verdict.state === 'done' && !localDone && !secured) {
207
+ await onChange?.(provider, outcome)
208
+ }
203
209
  results.push({ ...row, outcome, repeated: true, verified })
204
210
  }
205
211
  return results
@@ -229,7 +235,22 @@ export function createDailyCheckin({ dir, adapters, enabled = true, isEnabled, n
229
235
  if (!providerEnabled(provider)) continue
230
236
  // 只在本轮日界之后执行:Qoder 10:00 日界在 10:00 前属于上一轮,已在上一轮签过。
231
237
  if (dayOf(now(), adapter.resetHour) !== dayOf(now())) continue
232
- try { await claim(provider, undefined, lifetime.signal, true) }
238
+ try {
239
+ const rows = await claim(provider, undefined, lifetime.signal, true)
240
+ // 已有 pending 主记录(已提交但结算未确认)且适配器有只读 verify:
241
+ // 按间隔自动只读核实,上游结算后落 .confirmed 票据并刷新快照,绝不重复提交 claim。
242
+ if (typeof adapter.verify === 'function') {
243
+ for (const row of rows) {
244
+ if (lifetime.signal.aborted) break
245
+ if (row.outcome?.kind !== 'pending' || !row.repeated) continue
246
+ const key = `${provider}:${row.accountId}`
247
+ const last = pendingVerifiedAt.get(key) ?? 0
248
+ if (now() - last < PENDING_VERIFY_INTERVAL) continue
249
+ pendingVerifiedAt.set(key, now())
250
+ try { await query(provider, row.accountId, lifetime.signal) } catch {}
251
+ }
252
+ }
253
+ }
233
254
  catch { if (!lifetime.signal.aborted) logger?.warn?.('[unified-router] 自动签到暂未完成') }
234
255
  }
235
256
  })().finally(() => { running = null })
@@ -923,7 +923,27 @@ export const codeartsSpec = {
923
923
  for (const { item, ch } of campaigns) {
924
924
  const campaignId = item?.campaignId ?? item?.id
925
925
  if (codeArtsDailyClaimed(item)) { doneCount++; continue }
926
- if (String(item?.status ?? '').toUpperCase() === 'CLAIMED') { pendingCount++; continue }
926
+ if (String(item?.status ?? '').toUpperCase() === 'CLAIMED') {
927
+ // 已领取待确认:不重发 claim,只尝试补发一次 confirm 推进结算。
928
+ const existingBenefitId = item?.userBenefitId ?? item?.benefitRecordId
929
+ if ((ch === 'IDE' && campaignId) || existingBenefitId != null) {
930
+ const confirmRes = await codeArtsPostOps(handle, cred, '/v1/ops/confirm',
931
+ ch === 'IDE' ? { campaignId } : { userBenefitId: existingBenefitId }, signal)
932
+ if (codeArtsBizOk(confirmRes)) {
933
+ claimed++
934
+ creditSum += Number(item?.benefitAmount ?? item?.creditAmount) || 0
935
+ continue
936
+ }
937
+ const seenItem = campaignId ? await codeArtsFindDailyItem(handle, cred, signal, campaignId) : null
938
+ if (codeArtsDailyClaimed(seenItem) && String(seenItem?.status ?? '').toUpperCase() !== 'CLAIMED') {
939
+ claimed++
940
+ creditSum += Number(item?.benefitAmount ?? item?.creditAmount) || 0
941
+ continue
942
+ }
943
+ }
944
+ pendingCount++
945
+ continue
946
+ }
927
947
  if (item?.claimable !== true) continue
928
948
  if (!campaignId) { failedCount++; continue }
929
949
  submitted = true
@@ -386,6 +386,7 @@ const OFFICIAL_MODEL_SPECS = Object.freeze({
386
386
  'deepseek-v4-pro': { context: 1_048_576, maxOutput: 393_216 },
387
387
  'deepseek-v4-pro-0813': { context: 1_048_576, maxOutput: 393_216 },
388
388
  'deepseek-v4-flash': { context: 1_048_576, maxOutput: 393_216 },
389
+ 'glm-5-4': { context: 1_000_000, maxOutput: 131_072 },
389
390
  'glm-5-3': { context: 1_048_576, maxOutput: 131_072 },
390
391
  'glm-5-3-flash': { context: 1_048_576, maxOutput: 131_072 },
391
392
  'glm-5-3-flashx': { context: 1_048_576, maxOutput: 131_072 },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-unified-router",
3
- "version": "0.7.3",
3
+ "version": "0.7.4",
4
4
  "type": "module",
5
5
  "main": "lib/web-host.js",
6
6
  "license": "MIT",