dsh-unified-router 0.8.8 → 0.8.9

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
@@ -4395,15 +4395,16 @@ function parseClaimResult(body) {
4395
4395
  async function claimQoderCampaign(credential, product, campaignId, fetcher = fetch) {
4396
4396
  const url = `${product.openApiBase}${QODER_CAMPAIGNS_PATH}/${encodeURIComponent(campaignId)}/claim`;
4397
4397
  let response;
4398
+ const headers = { ...await creditsHeaders(credential, product), "Content-Type": "application/json" };
4398
4399
  try {
4399
4400
  response = await fetcher(url, {
4400
4401
  method: "POST",
4401
- headers: { ...await creditsHeaders(credential, product), "Content-Type": "application/json" },
4402
+ headers,
4402
4403
  body: "",
4403
4404
  signal: AbortSignal.timeout(QODER_CREDITS_TIMEOUT_MS)
4404
4405
  });
4405
- } catch (error) {
4406
- return { kind: "failed", code: -1, message: error instanceof Error ? error.message : String(error) };
4406
+ } catch {
4407
+ return { kind: "pending", pendingReason: "no-response", message: "\u672A\u6536\u5230\u7B7E\u5230\u7ED3\u679C" };
4407
4408
  }
4408
4409
  const text = await response.text().catch(() => "");
4409
4410
  let body;
@@ -4422,6 +4423,9 @@ async function claimQoderCampaign(credential, product, campaignId, fetcher = fet
4422
4423
  if (result.status !== void 0 && result.status !== "CLAIMED") {
4423
4424
  return { kind: "failed", code: -1, message: `\u9886\u53D6\u672A\u6210\u529F\uFF08status=${result.status}\uFF09` };
4424
4425
  }
4426
+ if (result.status !== "CLAIMED" && !(result.amount !== void 0 && result.amount > 0)) {
4427
+ return { kind: "pending", pendingReason: "response-unconfirmed", message: "\u5DF2\u6536\u5230\u56DE\u5305\uFF0C\u672A\u786E\u8BA4\u9886\u53D6" };
4428
+ }
4425
4429
  return { kind: "claimed", credit: result.amount ?? 0, streakDays: 0, isStreakDay: false };
4426
4430
  }
4427
4431
  function describeNonJson(status, text) {
@@ -4451,14 +4455,28 @@ async function claimQoderDailyCheckin(credential, product, fetcher = fetch, nowM
4451
4455
  }
4452
4456
  return { kind: "inactive", message: "\u5F53\u524D\u6CA1\u6709\u53EF\u9886\u53D6\u7684\u6D3B\u52A8", unsubmitted: true };
4453
4457
  }
4454
- let total = 0;
4458
+ let total = 0, acknowledged = 0;
4459
+ const unresolved = [];
4455
4460
  let firstError;
4456
4461
  for (const target of targets) {
4457
4462
  const outcome = await claimQoderCampaign(credential, product, target.campaignId, fetcher);
4458
- if (outcome.kind === "claimed") total += outcome.credit;
4463
+ if (outcome.kind === "claimed") {
4464
+ total += outcome.credit;
4465
+ acknowledged++;
4466
+ } else if (outcome.kind === "pending") unresolved.push(outcome);
4459
4467
  else if (outcome.kind === "failed" && firstError === void 0) firstError = outcome.message;
4460
4468
  }
4461
4469
  if (total > 0) return { kind: "claimed", credit: total, streakDays: 0, isStreakDay: false, ...stale };
4470
+ if (unresolved.length) {
4471
+ const reason = unresolved[0].pendingReason;
4472
+ return {
4473
+ kind: "pending",
4474
+ ...unresolved.every((row) => row.pendingReason === reason) && !acknowledged && !firstError ? { pendingReason: reason } : {},
4475
+ message: "\u7B7E\u5230\u7ED3\u679C\u672A\u6838\u5B9E",
4476
+ ...stale
4477
+ };
4478
+ }
4479
+ if (acknowledged) return { kind: "claimed", credit: 0, pendingReason: "response-unconfirmed", streakDays: 0, isStreakDay: false, ...stale };
4462
4480
  if (firstError !== void 0) return { kind: "failed", code: -1, message: firstError };
4463
4481
  return { kind: "already-claimed", message: "\u4ECA\u5929\u5DF2\u9886\u53D6", ...stale };
4464
4482
  }
@@ -4741,7 +4759,7 @@ function readContextWindowField(entry) {
4741
4759
  const raw = entry.context_window_tokens ?? entry.ContextWindowTokens;
4742
4760
  if (typeof raw !== "object" || raw === null) return void 0;
4743
4761
  const record = raw;
4744
- const value = readNumberField(record, "dev") ?? readNumberField(record, "Dev") ?? readNumberField(record, "max") ?? readNumberField(record, "Max");
4762
+ const value = readNumberField(record, "dev") ?? readNumberField(record, "Dev");
4745
4763
  return value !== void 0 && value > 0 ? Math.trunc(value) : void 0;
4746
4764
  }
4747
4765
  function readMaxContextWindowField(entry) {
@@ -4757,8 +4775,9 @@ function readDetailMaxTokens(entry, preferredSuffix = "__dev") {
4757
4775
  const details = raw.filter(
4758
4776
  (item) => typeof item === "object" && item !== null
4759
4777
  );
4760
- const preferred = details.find((item) => readStringField(item, "model_name").endsWith(preferredSuffix));
4761
- const chosen = preferred ?? details[0];
4778
+ const nameOf = (item) => readStringField(item, "model_name") || readStringField(item, "ModelName");
4779
+ const preferred = details.find((item) => nameOf(item).endsWith(preferredSuffix));
4780
+ const chosen = preferred ?? (preferredSuffix === "__dev" ? details.find((item) => !nameOf(item).endsWith("__max")) : void 0);
4762
4781
  if (chosen === void 0) return void 0;
4763
4782
  const value = readNumberField(chosen, "max_tokens") ?? readNumberField(chosen, "MaxTokens");
4764
4783
  return value !== void 0 && value > 0 ? Math.trunc(value) : void 0;
@@ -4994,7 +5013,8 @@ var TRAE_MAX_PROMPT_TOKENS = 936e3;
4994
5013
  var TRAE_MAX_OUTPUT_TOKENS = 64e3;
4995
5014
  var TRAE_MAX_MODE_TYPE = 1;
4996
5015
  function traeMaxModeFields(maxContext, outputMax) {
4997
- const context = maxContext > 0 ? maxContext : TRAE_MAX_CONTEXT_TOKENS;
5016
+ const context = maxContext > 1 ? maxContext : TRAE_MAX_CONTEXT_TOKENS;
5017
+ const output = Math.min(context - 1, outputMax !== void 0 && outputMax > 0 ? outputMax : TRAE_MAX_OUTPUT_TOKENS);
4998
5018
  return {
4999
5019
  model_auto_selection: {
5000
5020
  strategy: "max",
@@ -5004,8 +5024,8 @@ function traeMaxModeFields(maxContext, outputMax) {
5004
5024
  model_selection_strategy: "max",
5005
5025
  mode_type: TRAE_MAX_MODE_TYPE,
5006
5026
  context_window_size: context,
5007
- prompt_max_tokens: TRAE_MAX_PROMPT_TOKENS,
5008
- max_tokens: outputMax !== void 0 && outputMax > 0 ? outputMax : TRAE_MAX_OUTPUT_TOKENS
5027
+ prompt_max_tokens: Math.min(TRAE_MAX_PROMPT_TOKENS, context - output),
5028
+ max_tokens: output
5009
5029
  };
5010
5030
  }
5011
5031
  function transformToSOLOBody(openaiBody, modelMapping, channel) {
@@ -5270,6 +5290,7 @@ async function fetchTraeCheckinStatus(credential, _product, fetcher = fetch) {
5270
5290
  }
5271
5291
  async function claimTraeDailyCheckin(credential, product, fetcher = fetch, generation = 0, onRotate, userId, retryCount = 3) {
5272
5292
  const uid = userId ?? credential.uid;
5293
+ if (!uid) return { kind: "failed", code: -1, message: "\u7F3A\u5C11\u8D26\u53F7\u8EAB\u4EFD", unsubmitted: true };
5273
5294
  const doClaim = async () => {
5274
5295
  let lastError = { ok: false, httpStatus: 0, message: "", code: 0 };
5275
5296
  for (let attempt = 0; attempt <= Math.max(0, retryCount); attempt++) {
@@ -5290,6 +5311,7 @@ async function claimTraeDailyCheckin(credential, product, fetcher = fetch, gener
5290
5311
  };
5291
5312
  const response = await doClaim();
5292
5313
  if (!response.ok) {
5314
+ if (response.httpStatus === 0) return { kind: "pending", pendingReason: "no-response", message: "\u672A\u6536\u5230\u7B7E\u5230\u7ED3\u679C" };
5293
5315
  return { kind: "failed", code: -1, message: response.message, errorType: "Unknown", cooldownSecs: 0 };
5294
5316
  }
5295
5317
  const body = response.body;
@@ -5306,10 +5328,11 @@ async function claimTraeDailyCheckin(credential, product, fetcher = fetch, gener
5306
5328
  const msg = readString3(body, "message") || readString3(body, "msg") || "";
5307
5329
  if (code === 0) {
5308
5330
  const status = await fetchTraeCheckinStatus(credential, product, fetcher);
5331
+ if (!status?.todayCheckedIn) return { kind: "pending", pendingReason: "response-unconfirmed", message: "\u6536\u5230\u7B7E\u5230\u56DE\u5305\uFF0C\u79EF\u5206\u672A\u786E\u8BA4" };
5309
5332
  return {
5310
5333
  kind: "claimed",
5311
- credit: status?.dailyCredit ?? 0,
5312
- streakDays: status?.streakDays ?? 0,
5334
+ credit: status?.todayCheckedIn ? status.dailyCredit ?? 0 : 0,
5335
+ streakDays: status?.todayCheckedIn ? status.streakDays ?? 0 : 0,
5313
5336
  isStreakDay: false
5314
5337
  };
5315
5338
  }
@@ -8962,10 +8985,7 @@ var TraeAdapter = class extends LlmAdapter2 {
8962
8985
  */
8963
8986
  contextWindowFor(model) {
8964
8987
  const meta = this.remoteMeta.get(model);
8965
- if (this.maxModeFor(model)) {
8966
- return meta?.maxContextWindow ?? TRAE_MAX_CONTEXT_TOKENS;
8967
- }
8968
- return meta?.contextWindow ?? this.fallbackIndex.get(model)?.contextWindow;
8988
+ return this.maxModeContextFor(model) ?? meta?.contextWindow ?? this.fallbackIndex.get(model)?.contextWindow;
8969
8989
  }
8970
8990
  /**
8971
8991
  * 该模型本次是否启用 **Max 模式**(1M 上下文)。
@@ -8978,15 +8998,15 @@ var TraeAdapter = class extends LlmAdapter2 {
8978
8998
  * "Never fabricate max limits for a model the account config does not mark");
8979
8999
  * 3. 若配置了白名单,模型须在其中。
8980
9000
  */
8981
- maxModeFor(model) {
8982
- if (this.product.maxMode !== true) return false;
9001
+ maxModeContextFor(model) {
9002
+ if (this.product.maxMode !== true) return void 0;
8983
9003
  const meta = this.remoteMeta.get(model);
8984
- if (meta === void 0 || meta.maxMode !== true) return false;
9004
+ const max = meta?.maxContextWindow;
9005
+ const regular = meta?.contextWindow ?? this.fallbackIndex.get(model)?.contextWindow;
9006
+ if (meta?.maxMode !== true || typeof max !== "number" || !Number.isSafeInteger(max) || max <= 1 || regular !== void 0 && max <= regular) return void 0;
8985
9007
  const whitelist = this.product.maxModeModels;
8986
- if (whitelist !== void 0 && whitelist.length > 0 && !whitelist.includes("*")) {
8987
- return whitelist.includes(model);
8988
- }
8989
- return true;
9008
+ if (whitelist?.length && !whitelist.includes("*") && !whitelist.includes(model)) return void 0;
9009
+ return max;
8990
9010
  }
8991
9011
  /**
8992
9012
  * 模型可选的推理强度档位(`reasoning_effort_config`)。
@@ -9028,7 +9048,7 @@ var TraeAdapter = class extends LlmAdapter2 {
9028
9048
  */
9029
9049
  maxOutputTokensFor(model) {
9030
9050
  const meta = this.remoteMeta.get(model);
9031
- if (this.maxModeFor(model) && meta?.maxModeOutputTokens !== void 0) {
9051
+ if (this.maxModeContextFor(model) !== void 0 && meta?.maxModeOutputTokens !== void 0) {
9032
9052
  return meta.maxModeOutputTokens;
9033
9053
  }
9034
9054
  return meta?.maxOutputTokens ?? this.product.fallbackMaxOutputTokens;
@@ -9203,8 +9223,6 @@ var TraeAdapter = class extends LlmAdapter2 {
9203
9223
  }));
9204
9224
  }
9205
9225
  if (options.temperature !== void 0) openaiBody.temperature = options.temperature;
9206
- const maxTokens = clampTraeMaxTokens(options.maxTokens ?? defaultModelOutputTokens(this.maxOutputTokensFor(options.model)));
9207
- if (maxTokens !== void 0) openaiBody.max_tokens = maxTokens;
9208
9226
  if (options.stop !== void 0 && options.stop.length > 0) openaiBody.stop = options.stop;
9209
9227
  const reasoningCfg = this.remoteMeta.get(options.model)?.reasoningConfig ?? this.fallbackIndex.get(options.model)?.reasoningConfig;
9210
9228
  const requestedEffort = options.reasoningEffort ?? this.reasoningFor(options.model)?.defaultEffort;
@@ -9214,16 +9232,14 @@ var TraeAdapter = class extends LlmAdapter2 {
9214
9232
  }
9215
9233
  const buildSoloBody = (useMaxMode, channel) => {
9216
9234
  const payload = { ...openaiBody };
9217
- if (useMaxMode) {
9218
- const meta = this.remoteMeta.get(options.model);
9219
- Object.assign(
9220
- payload,
9221
- traeMaxModeFields(
9222
- meta?.maxContextWindow ?? TRAE_MAX_CONTEXT_TOKENS,
9223
- meta?.maxModeOutputTokens
9224
- )
9225
- );
9226
- }
9235
+ const meta = this.remoteMeta.get(options.model);
9236
+ const maxContext = useMaxMode ? this.maxModeContextFor(options.model) : void 0;
9237
+ const regularOutput = defaultModelOutputTokens(meta?.maxOutputTokens ?? this.product.fallbackMaxOutputTokens);
9238
+ const output = maxContext === void 0 ? regularOutput : meta?.maxModeOutputTokens ?? regularOutput;
9239
+ const requested = typeof options.maxTokens === "number" && options.maxTokens > 0 ? options.maxTokens : output;
9240
+ const bounded = Math.min(requested, output);
9241
+ if (maxContext !== void 0) Object.assign(payload, traeMaxModeFields(maxContext, bounded));
9242
+ else payload.max_tokens = clampTraeMaxTokens(bounded);
9227
9243
  if (options.system !== void 0 && options.system.length > 0) {
9228
9244
  payload.messages = [
9229
9245
  { role: "system", content: options.system },
@@ -9238,7 +9254,7 @@ var TraeAdapter = class extends LlmAdapter2 {
9238
9254
  }
9239
9255
  return JSON.stringify(solo);
9240
9256
  };
9241
- let usingMaxMode = this.maxModeFor(options.model);
9257
+ let usingMaxMode = this.maxModeContextFor(options.model) !== void 0;
9242
9258
  let activeChannel = this.channelFor(options.model);
9243
9259
  const fallbackChannels = ["solo_agent", "chat_v3", "solo_work_lite", "solo_coder"].filter((fn) => fn !== activeChannel);
9244
9260
  let fallbackChannelIndex = 0;
@@ -10685,6 +10701,8 @@ function computeClaimSummary(outcomes) {
10685
10701
  case "inactive":
10686
10702
  summary.inactive += 1;
10687
10703
  break;
10704
+ case "pending":
10705
+ break;
10688
10706
  case "failed":
10689
10707
  summary.failed += 1;
10690
10708
  break;
@@ -11307,7 +11325,7 @@ function registerChannelPackEndpoints(ctx, pool, qoder, qoderCn, trae, raccoon,
11307
11325
  }
11308
11326
  return {
11309
11327
  ok: true,
11310
- value: outcome.kind === "claimed" ? { outcome: "claimed", credit: outcome.credit, message: outcome.delayedMessage ?? "" } : { outcome: outcome.kind === "already-claimed" ? "done" : outcome.kind, message: outcome.message }
11328
+ value: outcome.kind === "claimed" ? { outcome: "claimed", credit: outcome.credit, message: outcome.delayedMessage ?? "" } : { outcome: outcome.kind === "already-claimed" ? "done" : outcome.kind, message: outcome.message, ...outcome.pendingReason ? { pendingReason: outcome.pendingReason } : {} }
11311
11329
  };
11312
11330
  }
11313
11331
  // ── 限流标记:重测(发真实请求验证)──
@@ -12273,6 +12291,7 @@ function readNumber3(value) {
12273
12291
  }
12274
12292
  async function requestJson(url, credential, product, init, fetcher, signal) {
12275
12293
  const timeout = AbortSignal.timeout(RACCOON_REQUEST_TIMEOUT_MS);
12294
+ let receivedResponse = false;
12276
12295
  try {
12277
12296
  const response = await fetcher(url, {
12278
12297
  method: init.method,
@@ -12283,6 +12302,7 @@ async function requestJson(url, credential, product, init, fetcher, signal) {
12283
12302
  ...init.body === void 0 ? {} : { body: init.body },
12284
12303
  signal: signal ? AbortSignal.any([signal, timeout]) : timeout
12285
12304
  });
12305
+ receivedResponse = true;
12286
12306
  const parsed = await response.json();
12287
12307
  return parseEnvelope(parsed, response.status);
12288
12308
  } catch (error) {
@@ -12290,7 +12310,8 @@ async function requestJson(url, credential, product, init, fetcher, signal) {
12290
12310
  ok: false,
12291
12311
  code: -1,
12292
12312
  message: error instanceof Error ? error.message : String(error),
12293
- data: void 0
12313
+ data: void 0,
12314
+ receivedResponse
12294
12315
  };
12295
12316
  }
12296
12317
  }
@@ -12404,16 +12425,18 @@ async function checkInRaccoon(product, credential, fetcher = fetch) {
12404
12425
  fetcher
12405
12426
  );
12406
12427
  if (!trigger.ok) {
12428
+ if (beforeKeys?.size) return { kind: "already-claimed", message: "\u4ECA\u65E5\u5DF2\u7B7E\u5230" };
12429
+ if (trigger.code === -1) return { kind: "pending", pendingReason: trigger.receivedResponse ? "response-unconfirmed" : "no-response", message: "\u6B64\u6B21\u7B7E\u5230\u672A\u80FD\u6838\u5B9E" };
12407
12430
  return {
12408
12431
  kind: "failed",
12409
12432
  code: trigger.code,
12410
12433
  message: trigger.message.length > 0 ? trigger.message : "\u7B7E\u5230\u8BF7\u6C42\u5931\u8D25"
12411
12434
  };
12412
12435
  }
12413
- const unsettled = { kind: "already-claimed", message: "\u5DF2\u89E6\u53D1\u4ECA\u65E5\u7B7E\u5230\uFF08\u8D26\u5355\u672A\u53D6\u5230\uFF0C\u91D1\u989D\u672A\u786E\u8BA4\uFF09" };
12436
+ const unsettled = { kind: "pending", pendingReason: "response-unconfirmed", message: "\u5DF2\u6536\u5230\u56DE\u5305\uFF0C\u79EF\u5206\u672A\u786E\u8BA4" };
12414
12437
  if (beforeKeys === null) return unsettled;
12415
12438
  const after = await readBills(product, credential, fetcher);
12416
- if (after === null) return unsettled;
12439
+ if (after === null) return beforeKeys.size ? { kind: "already-claimed", message: "\u4ECA\u65E5\u5DF2\u7B7E\u5230" } : unsettled;
12417
12440
  let credit = 0;
12418
12441
  const names = [];
12419
12442
  for (const item of after) {
@@ -12433,7 +12456,7 @@ async function checkInRaccoon(product, credential, fetcher = fetch) {
12433
12456
  ...names.length > 0 ? { delayedMessage: names.join(" + ") } : {}
12434
12457
  };
12435
12458
  }
12436
- return { kind: "already-claimed", message: "\u4ECA\u65E5\u5DF2\u7B7E\u5230" };
12459
+ return beforeKeys.size ? { kind: "already-claimed", message: "\u4ECA\u65E5\u5DF2\u7B7E\u5230" } : unsettled;
12437
12460
  }
12438
12461
  async function fetchRaccoonOnboardingStatus(product, credential, fetcher = fetch) {
12439
12462
  const envelope = await requestJson(
@@ -27,6 +27,10 @@ const wireFinite = (value) => typeof value === 'number' && Number.isFinite(value
27
27
  /** 套餐档位白名单(Raccoon 家族按它分流;缺省不是错误)。 */
28
28
  const WIRE_PLANS = ['free', 'pro', 'unknown']
29
29
 
30
+ export function checkinPendingReason(value) {
31
+ return value === 'response-unconfirmed' || value === 'no-response' ? value : undefined
32
+ }
33
+
30
34
  export function projectRouteObservation(value) {
31
35
  return ['ready', 'catalog-missing', 'restricted', 'exhausted', 'expired', 'unknown', 'rate-limited'].includes(value?.status)
32
36
  && Number.isSafeInteger(value?.checkedAt) && value.checkedAt > 0
package/lib/client.js CHANGED
@@ -613,6 +613,10 @@ const wireFinite = (value) => typeof value === 'number' && Number.isFinite(value
613
613
  /** 套餐档位白名单(Raccoon 家族按它分流;缺省不是错误)。 */
614
614
  const WIRE_PLANS = ['free', 'pro', 'unknown']
615
615
 
616
+ function checkinPendingReason(value) {
617
+ return value === 'response-unconfirmed' || value === 'no-response' ? value : undefined
618
+ }
619
+
616
620
  function projectRouteObservation(value) {
617
621
  return ['ready', 'catalog-missing', 'restricted', 'exhausted', 'expired', 'unknown', 'rate-limited'].includes(value?.status)
618
622
  && Number.isSafeInteger(value?.checkedAt) && value.checkedAt > 0
@@ -1721,6 +1725,9 @@ function managedSnapshotFrom(value, previous) {
1721
1725
  const merged = accounts.map(account => {
1722
1726
  const softFailed = account.error === 'upstream_error' || account.error === 'auth_error'
1723
1727
  const old = (previous?.accounts ?? []).find(row => row.id === account.id)
1728
+ if (account.signedIn && old?.routeObservation && old.routeObservation.checkedAt >= (account.routeObservation?.checkedAt ?? 0)) {
1729
+ account = { ...account, routeObservation: old.routeObservation }
1730
+ }
1724
1731
  if (softFailed && old?.signedIn && account.signedIn && (old.windows.length || old.balance !== null)) {
1725
1732
  stale = true
1726
1733
  return {
@@ -1834,9 +1841,11 @@ function taskMessage(value, mode, querying = false) {
1834
1841
  const kind = record.outcome?.kind
1835
1842
  const failed = querying && mode === 'checkin' && record.queryFailed === true
1836
1843
  const done = kind === 'claimed' || kind === 'already-claimed'
1844
+ const evidence = mode === 'checkin' && ['pending', 'claimed'].includes(kind)
1845
+ ? checkinEvidenceLabel(record.outcome?.pendingReason, kind) : null
1837
1846
  const label = failed && !done ? '状态读取失败'
1838
- : kind === 'claimed' || kind === 'completed' ? record.repeated ? '已完成' : '成功'
1839
- : Object.hasOwn(AUTOMATION_OUTCOME_LABELS, kind) ? AUTOMATION_OUTCOME_LABELS[kind] : '待确认'
1847
+ : evidence ?? (kind === 'claimed' || kind === 'completed' ? record.repeated ? '已完成' : '成功'
1848
+ : Object.hasOwn(AUTOMATION_OUTCOME_LABELS, kind) ? AUTOMATION_OUTCOME_LABELS[kind] : '待确认')
1840
1849
  counts.set(label, (counts.get(label) ?? 0) + 1)
1841
1850
  }
1842
1851
  const topic = mode === 'checkin' ? '签到' : mode === 'completeTasks' ? '任务' : '奖励'
@@ -1873,13 +1882,24 @@ function claimMessage(value, provider) {
1873
1882
  if (!results.length) return '没有可领取的账号。'
1874
1883
  const count = kind => results.filter(r => r.outcome?.kind === kind).length
1875
1884
  let result = `领取结果:${count('claimed')} 个成功,${count('already-claimed')} 个已领,${count('inactive')} 个暂不可领,${count('failed')} 个失败。`
1876
- if (count('pending')) result += `${count('pending')} 个待确认。`
1885
+ for (const reason of ['no-response', 'response-unconfirmed', undefined]) {
1886
+ const pending = results.filter(r => r.outcome?.kind === 'pending' && checkinPendingReason(r.outcome?.pendingReason) === reason).length
1887
+ if (pending) result += `${pending} 个${checkinEvidenceLabel(reason, 'pending')}。`
1888
+ }
1889
+ const creditUnconfirmed = results.filter(r => r.outcome?.kind === 'claimed' && r.outcome?.pendingReason === 'response-unconfirmed').length
1890
+ if (creditUnconfirmed) result += `其中 ${creditUnconfirmed} 个积分未确认。`
1877
1891
  // 需要用户去官方客户端开通时给的具体入口:渠道自行声明,缺省是通用说法。
1878
1892
  if (results.some(r => r.outcome?.actionRequired)) {
1879
1893
  result += providerCaps(provider)?.claimActionHint ?? '每日额度开通入口:官方客户端。'
1880
1894
  }
1881
1895
  return result
1882
1896
  }
1897
+ function checkinEvidenceLabel(reason, kind) {
1898
+ if (reason === 'no-response') return '签到未收到结果'
1899
+ if (reason === 'response-unconfirmed') return kind === 'claimed' ? '已签到 · 积分未确认' : '已收到回包 · 积分未确认'
1900
+ return kind === 'pending' ? '签到结果未核实' : null
1901
+ }
1902
+
1883
1903
  const CHECKIN_LABELS = {
1884
1904
  claimed: '已签到', 'already-claimed': '已签到', inactive: '签到活动未开启',
1885
1905
  ineligible: '签到条件未满足', failed: '签到失败', pending: '签到待确认',
@@ -1894,7 +1914,8 @@ function checkinEntry(state, provider, accountId) {
1894
1914
  // 渠道可以覆盖通用签到文案(如 CodeArts 的签到入口在活动页,「未参会」与
1895
1915
  // 「查不到记录」是两件事)。覆盖优先,缺省回落到通用表。
1896
1916
  const overrides = providerCaps(provider)?.checkinLabels ?? {}
1897
- const label = (Object.hasOwn(overrides, kind) ? overrides[kind] : null)
1917
+ const label = checkinEvidenceLabel(account?.pendingReason, kind)
1918
+ ?? (Object.hasOwn(overrides, kind) ? overrides[kind] : null)
1898
1919
  ?? (Object.hasOwn(CHECKIN_LABELS, kind) ? CHECKIN_LABELS[kind] : null)
1899
1920
  if (!label) return null
1900
1921
  // 「额度增长即确认」时把本次到账量写进标签,文案主体仍是「已签到」。
@@ -2886,6 +2907,32 @@ function createRouterStore(call, provider = PROVIDERS[0].id) {
2886
2907
  const scope = `refresh:${target}`
2887
2908
  if (disposed || pending.has(scope) || state.loading || !target) return false
2888
2909
  const release = pending.enter(scope)
2910
+ const routed = providerById(target)
2911
+ if (routed?.caps?.routeCheck === true) {
2912
+ const progress = patch => publish({ quotaRefresh: { ...state.quotaRefresh, [target]: patch } })
2913
+ progress({ running: true })
2914
+ try {
2915
+ const timeout = AbortSignal.timeout(45_000)
2916
+ const value = await request('managed.snapshot', { provider: target, live: true }, AbortSignal.any([lifetime.signal, timeout]))
2917
+ if (!Array.isArray(value?.accounts)) throw new Error('missing accounts')
2918
+ const accounts = value.accounts.map(managedAccountFrom).filter(Boolean)
2919
+ const active = accounts.filter(account => account.enabled)
2920
+ const ok = active.filter(account => account.signedIn && !account.error && (account.balance !== null || account.windows.length > 0)).length
2921
+ const failed = active.length - ok
2922
+ writeRevision++
2923
+ publish(routed.snapshot.fromRead([value, undefined], state))
2924
+ progress({ running: false, total: active.length, ok, failed })
2925
+ cache.persistCards(state)
2926
+ return failed === 0
2927
+ } catch {
2928
+ if (!disposed) {
2929
+ const previous = state.managed?.[target]
2930
+ if (previous) publish({ managed: { ...state.managed, [target]: { ...previous, stale: true, usageStale: true } } })
2931
+ progress({ running: false, error: true })
2932
+ }
2933
+ return false
2934
+ } finally { release() }
2935
+ }
2889
2936
  let succeeded = false
2890
2937
  try {
2891
2938
  await request('settings.refresh', { provider: target, wait: true }, lifetime.signal)
@@ -2937,22 +2984,26 @@ function createRouterStore(call, provider = PROVIDERS[0].id) {
2937
2984
 
2938
2985
  async function runRouteChecks(provider, accountIds) {
2939
2986
  if (disposed || routeControllers.has(provider)) return false
2940
- const list = Array.isArray(accountIds) ? accountIds.filter(id => typeof id === 'string' && id) : []
2987
+ const list = Array.isArray(accountIds) ? [...new Set(accountIds.filter(id => typeof id === 'string' && id))] : []
2941
2988
  if (!list.length) return false
2942
2989
  const controller = new AbortController()
2943
2990
  routeControllers.set(provider, controller)
2944
2991
  const release = pending.enter(`route:${provider}`)
2945
2992
  let done = 0, failed = 0, cancelled = false
2946
2993
  const results = []
2947
- routeProgress(provider, { running: true, total: list.length, done: 0, failed: 0, current: list[0], startedAt: Date.now() })
2994
+ routeProgress(provider, { running: true, total: list.length, done: 0, failed: 0, current: list[0], queued: list.slice(1), startedAt: Date.now() })
2948
2995
  try {
2949
- for (const accountId of list) {
2996
+ for (const [index, accountId] of list.entries()) {
2950
2997
  if (controller.signal.aborted || disposed) { cancelled = true; break }
2951
- routeProgress(provider, { current: accountId })
2998
+ routeProgress(provider, { current: accountId, queued: list.slice(index + 1) })
2952
2999
  try {
2953
3000
  const value = await request('managed.routeCheck', { provider, accountId }, controller.signal)
2954
3001
  const route = projectRouteObservation(value?.routeObservation)
2955
- if (route) { patchManagedAccount(provider, accountId, { routeObservation: route }); results.push(route.status) }
3002
+ if (route) {
3003
+ writeRevision++
3004
+ patchManagedAccount(provider, accountId, { routeObservation: route })
3005
+ results.push(route.status)
3006
+ }
2956
3007
  else failed += 1
2957
3008
  } catch {
2958
3009
  if (controller.signal.aborted) { cancelled = true; break }
@@ -2964,13 +3015,15 @@ function createRouterStore(call, provider = PROVIDERS[0].id) {
2964
3015
  } finally {
2965
3016
  routeControllers.delete(provider)
2966
3017
  release()
2967
- routeProgress(provider, { running: false, current: null, done, failed })
3018
+ routeProgress(provider, { running: false, current: null, queued: [], done, failed, total: list.length })
2968
3019
  if (!disposed && sync.hasSnapshots()) void sync.readHostSnapshots()
2969
3020
  }
2970
3021
  if (!disposed && state.provider === provider) {
2971
- const bad = results.filter(status => status !== 'ready').length
3022
+ const normal = results.filter(status => status === 'ready').length
3023
+ const unknown = results.filter(status => status === 'unknown').length
3024
+ const bad = results.length - normal - unknown
2972
3025
  publish({ notice: cancelled ? `已取消,完成 ${done}/${list.length}。`
2973
- : `路由检测完成:${results.length - bad} 个正常${bad ? `,${bad} 个待处理` : ''}${failed ? `,${failed} 个未完成` : ''}。` })
3026
+ : `路由检测完成:${normal} 个已核实${bad ? `,${bad} 个异常` : ''}${unknown ? `,${unknown} 个台账未能核实` : ''}${failed ? `,${failed} 个未完成` : ''}。` })
2974
3027
  }
2975
3028
  return !cancelled && failed === 0
2976
3029
  }
@@ -4305,15 +4358,22 @@ function AccountsPanel(view, ui) {
4305
4358
  const route = view.routeCheck
4306
4359
  const routeRunning = route?.running === true
4307
4360
  if (routeRunning) summary.push(tag(`检测 ${route.done}/${route.total}`))
4308
- else if (route && route.problemCount) summary.push(tag(`${route.problemCount} 个待处理`, 'warn'))
4361
+ else if (route && route.problemCount) summary.push(tag(`${route.problemCount} 个路由异常`, 'warn'))
4309
4362
  const showImport = view.importForm && ui.importOpen === ui.providerId
4310
4363
  const refreshScope = `refresh:${ui.providerId}`
4364
+ const quota = view.quotaRefresh
4365
+ const quotaNotice = !quota ? null : h('p', { className: 'eac-muted', role: 'status', 'aria-live': 'polite' },
4366
+ quota.running ? '正在读取账号额度,完成前显示上次读数。'
4367
+ : quota.error ? '额度刷新未完成,保留上次读数。请稍后重试。'
4368
+ : !quota.total ? '没有启用的账号可刷新。'
4369
+ : `额度刷新完成:${quota.ok}/${quota.total} 个账号已更新${quota.failed ? `,${quota.failed} 个未更新,请查看账号状态` : ''}。`)
4311
4370
  // 路由检测的批量入口与进度收在账号列表上方的工具条里(不挤分区标题的按钮行:
4312
4371
  // Loomy 的标题已经有浏览器登录 / 粘贴凭据 / 指引 / 刷新额度四个)。
4313
4372
  const routeBar = !route ? null : h('div', { className: 'eac-route-check', role: 'status', 'aria-live': 'polite' },
4314
4373
  h('div', { className: 'eac-route-check-copy' },
4315
4374
  h('span', null, routeRunning ? `正在检测 ${Math.min(route.done + 1, route.total)}/${route.total}`
4316
4375
  : route.done ? `已检测 ${route.done}/${route.total}` : '路由检测'),
4376
+ routeRunning ? h('span', { className: 'eac-muted' }, '查目录、发一次探测,再核对台账。') : null,
4317
4377
  route.failed ? h('span', null, `${route.failed} 个未完成`) : null,
4318
4378
  h('div', { className: 'eac-route-check-actions' },
4319
4379
  routeRunning
@@ -4330,7 +4390,7 @@ function AccountsPanel(view, ui) {
4330
4390
  actions: [
4331
4391
  ...renderActions(view.actions, ui, `login:${ui.providerId}`),
4332
4392
  // 所有渠道的账号页共用一个手动额度刷新入口:宿主等待采集完成后客户端立即重读快照。
4333
- button('刷新额度', () => ui.act('refreshQuota'), ui.loading || ui.isPending(refreshScope), {
4393
+ button(ui.isPending(refreshScope) ? '正在刷新额度…' : '刷新额度', () => ui.act('refreshQuota'), ui.loading || ui.isPending(refreshScope), {
4334
4394
  key: 'refreshBalances',
4335
4395
  'aria-label': `刷新${ui.providerId}的额度`,
4336
4396
  }),
@@ -4338,6 +4398,7 @@ function AccountsPanel(view, ui) {
4338
4398
  children: [
4339
4399
  renderLogin(view.login, ui),
4340
4400
  routeBar,
4401
+ quotaNotice,
4341
4402
  showImport ? h('div', { className: 'eac-callout' },
4342
4403
  h(CredentialImportForm, {
4343
4404
  key: `import:${ui.providerId}`,
@@ -4883,7 +4944,7 @@ function routeCheckView(state, id, current) {
4883
4944
  const running = run?.running === true
4884
4945
  return {
4885
4946
  running,
4886
- total: running ? run.total ?? checkable.length : checkable.length,
4947
+ total: run?.total ?? checkable.length,
4887
4948
  done: run?.done ?? 0,
4888
4949
  failed: run?.failed ?? 0,
4889
4950
  current: running ? run?.current ?? null : null,
@@ -4948,7 +5009,7 @@ function managedChannel({
4948
5009
  fromRead([snapshot, models], state) {
4949
5010
  const previous = entry(state) ?? EMPTY_MANAGED
4950
5011
  const { managed, stale } = managedSnapshotFrom({ ...snapshot, models: models?.models, modelSource: models?.source }, previous)
4951
- return withEntry(state, { ...managed, loginUrl: previous.loginUrl || managed.loginUrl, ready: true, stale: stale || snapshot?.snapshot?.stale === true, error: false, liveAt: Date.now() })
5012
+ return withEntry(state, { ...managed, loginUrl: previous.loginUrl || managed.loginUrl, ready: true, stale: stale || snapshot?.snapshot?.stale === true, usageStale: snapshot?.snapshot?.stale === true, error: false, liveAt: Date.now() })
4952
5013
  },
4953
5014
  apply(get, state) {
4954
5015
  const usage = get('managed.snapshot')
@@ -4970,6 +5031,7 @@ function managedChannel({
4970
5031
  ...withEntry(state, {
4971
5032
  ...managed,
4972
5033
  stale: freshUsage ? freshUsage.stale === true : previous.stale === true,
5034
+ usageStale: freshUsage ? freshUsage.stale === true : previous.usageStale === true,
4973
5035
  error: freshUsage ? (freshUsage.stale === true && !freshUsage.value) : previous.error === true,
4974
5036
  ready: !!freshUsage?.value || previous.ready === true,
4975
5037
  liveAt,
@@ -5018,6 +5080,7 @@ function managedChannel({
5018
5080
  autoCheckin: checkin ? automationEffective(state, id, 'autoCheckin') : undefined,
5019
5081
  // 路由检测(只有声明 `routeCheck` 的渠道会用到):批量入口 + 实时进度。
5020
5082
  routeCheck: extraCaps.routeCheck ? routeCheckView(state, id, current) : undefined,
5083
+ quotaRefresh: extraCaps.routeCheck ? state.quotaRefresh?.[id] : undefined,
5021
5084
  login: loginUrl ? { url: loginUrl, cancel: state.pending?.[`login:${id}`] ? [`${id}CancelLogin`] : null } : null,
5022
5085
  importForm: methods.includes('credential') ? {
5023
5086
  hint: current.credentialHint || credentialHint,
@@ -5037,7 +5100,10 @@ function managedChannel({
5037
5100
  const ck = checkin ? checkinEntry(state, id, account.id) : null
5038
5101
  const rw = claimRewards ? taskEntry(state, id, 'claimRewards', account.id) : null
5039
5102
  const routeRun = extraCaps.routeCheck && state.routeChecks?.[id]?.running ? state.routeChecks[id] : null
5040
- const routeChecking = routeRun?.current ?? null
5103
+ const routeChecking = routeRun?.current === account.id
5104
+ const routeQueued = routeRun?.queued?.includes(account.id) === true
5105
+ const quotaState = extraCaps.routeCheck ? state.quotaRefresh?.[id] : undefined
5106
+ const quotaRefreshing = quotaState?.running && account.enabled !== false
5041
5107
  // 数值位与标签必须说同一件事:没有读数就是「—」+「读取失败」,
5042
5108
  // 「额度待更新」只留给「还没有读数、但也没有失败」的账号。
5043
5109
  const metric = account.balance !== null
@@ -5061,11 +5127,13 @@ function managedChannel({
5061
5127
  // 按 info 呈现原因,不要挂 warn(那会让用户以为账号坏了)。
5062
5128
  account.error === 'no_web_session' && ['仅推理 Token · 不读积分', 'info'],
5063
5129
  account.error && account.error !== 'no_web_session' && [(account.windows.length || account.balance !== null) ? '上次额度' : '读取失败', 'warn'],
5064
- !account.error && current.stale && [(account.windows.length || account.balance !== null) ? '上次额度' : '读取失败', 'warn'],
5130
+ !account.error && (extraCaps.routeCheck ? current.usageStale : current.stale) && [(account.windows.length || account.balance !== null) ? '上次额度' : '读取失败', 'warn'],
5065
5131
  ck?.tag,
5066
5132
  rw?.tag,
5067
- routeChecking === account.id && ['检测中…', 'info'],
5068
- ...(extraCaps.accountTags?.(account) ?? []),
5133
+ quotaRefreshing && ['正在读取额度…', 'info'],
5134
+ routeChecking && ['检测中…', 'info'],
5135
+ routeQueued && ['等待检测', 'info'],
5136
+ ...(!routeChecking && !routeQueued ? extraCaps.accountTags?.(account) ?? [] : []),
5069
5137
  ],
5070
5138
  metric,
5071
5139
  groups: account.windows.length ? [{
@@ -5090,9 +5158,9 @@ function managedChannel({
5090
5158
  form: { kind: 'account', account: { id: account.id, nickname: name, enabled: account.enabled !== false }, call: [`${id}UpdateAccount`] },
5091
5159
  actions: [
5092
5160
  extraCaps.routeCheck && account.signedIn && account.enabled !== false && {
5093
- label: routeChecking === account.id ? '检测中…' : '检测路由',
5161
+ label: routeChecking ? '检测中…' : routeQueued ? '等待检测' : '检测路由',
5094
5162
  call: [`${id}RouteCheck`, account.id],
5095
- disabled: routeChecking !== null,
5163
+ disabled: routeRun !== null,
5096
5164
  },
5097
5165
  checkin && account.signedIn && account.enabled !== false && { label: '签到', accessible: `为 ${name} 签到`, call: [`${id}Checkin`, account.id], disabled: ck?.locked },
5098
5166
  claimRewards && account.signedIn && account.enabled !== false && { label: '领奖励', accessible: `为 ${name} 领取奖励`, call: [`${id}ClaimRewards`, account.id], disabled: rw?.locked },
@@ -5359,6 +5427,8 @@ function createManagedActions(provider, { getState, isDisposed, hasSnapshots, re
5359
5427
  progress: '正在签到领取当日积分…',
5360
5428
  message: value => {
5361
5429
  const outcome = text(value?.outcome, 40)
5430
+ const evidence = checkinEvidenceLabel(value?.pendingReason, outcome)
5431
+ if (evidence) return `${evidence}。`
5362
5432
  if (outcome === 'claimed') return `签到成功${typeof value?.credit === 'number' ? `,领取 ${value.credit} 积分` : ''}。`
5363
5433
  if (outcome === 'done' || outcome === 'already-claimed') return '今日已签到。'
5364
5434
  if (outcome === 'inactive') return id === 'codearts' ? '未查到今日签到记录。' : '今日签到活动未开启。'
@@ -5926,6 +5996,8 @@ function createWorkBuddyActions({ getState, isDisposed, hasSnapshots, request, p
5926
5996
  // ineligible/failed),未知值不谎报成功。完成后重读快照刷新状态。
5927
5997
  message: value => {
5928
5998
  const outcome = text(value?.outcome, 40)
5999
+ const evidence = checkinEvidenceLabel(value?.pendingReason, outcome)
6000
+ if (evidence) return `${evidence}。`
5929
6001
  if (outcome === 'claimed') return `签到成功${typeof value?.credit === 'number' ? `,领取 ${value.credit} 积分` : ''}${typeof value?.streak === 'number' ? `,已连续 ${value.streak} 天` : ''}。`
5930
6002
  if (outcome === 'done') return '今日已签到。'
5931
6003
  if (outcome === 'inactive') return '今日签到活动未开启,暂无可领取积分。'
@@ -6374,7 +6446,7 @@ const loomyRouteLabels = Object.freeze({
6374
6446
  exhausted: ['积分已用尽', 'warn'],
6375
6447
  'rate-limited': ['上游限流', 'warn'],
6376
6448
  expired: ['会话已过期', 'warn'],
6377
- unknown: ['路由待核实', 'info'],
6449
+ unknown: ['路由未核实', 'info'],
6378
6450
  })
6379
6451
 
6380
6452
  const loomy = managedChannel({
@@ -3,6 +3,7 @@
3
3
  // 触发而重放。唯一释放途径是 preflight/verify 明确"未提交"(unsubmitted/retryable),
4
4
  // 撤预留转为 .retry 退避票据,到期后仅自动路径重新提交。
5
5
  import { mkdir, unlink } from 'node:fs/promises'
6
+ import { checkinPendingReason } from './channel-contract.js'
6
7
  import { join } from 'node:path'
7
8
  import {
8
9
  ACCOUNT_SCOPE, adoptAccountRecord, applyVerdict, balanceGrowth, dayOf, effectiveRecord,
@@ -24,11 +25,14 @@ const confirmedDone = (record, doneKinds) => !!record && doneKinds.has(record.ou
24
25
 
25
26
  function cleanOutcome(value) {
26
27
  const kind = OUTCOMES.has(value?.kind) ? value.kind : 'failed'
28
+ const reason = checkinPendingReason(value?.pendingReason)
29
+ ?? (kind === 'claimed' && !(Number.isFinite(value?.credit) && value.credit > 0) ? 'response-unconfirmed' : undefined)
27
30
  return {
28
31
  kind,
29
32
  ...(Number.isFinite(value?.credit) ? { credit: value.credit } : {}),
30
33
  ...(Number.isFinite(value?.streak) ? { streak: value.streak } : {}),
31
34
  ...(value?.actionRequired === true ? { actionRequired: true } : {}),
35
+ ...(reason && kind !== 'already-claimed' ? { pendingReason: reason } : {}),
32
36
  }
33
37
  }
34
38
  // 账本读取用严格清洗:无法识别的 kind 视为无记录,绝不伪造 failed。
@@ -125,8 +129,9 @@ export function createDailyCheckin({ dir, adapters, enabled = true, isEnabled, n
125
129
  signal.throwIfAborted()
126
130
  value = await adapter.claim(account.id, signal)
127
131
  } catch {
128
- value = { kind: 'failed' }
132
+ value = { kind: 'pending', pendingReason: 'no-response' }
129
133
  }
134
+ if (value == null) value = { kind: 'pending', pendingReason: 'no-response' }
130
135
  const outcome = cleanOutcome(value)
131
136
  try {
132
137
  // 只有适配器明确"未提交成功"才允许撤预留转入退避重试;其余一律定主记录。
@@ -236,7 +241,9 @@ export function createDailyCheckin({ dir, adapters, enabled = true, isEnabled, n
236
241
  if (verified && verdict.state === 'done' && !localDone && !secured) {
237
242
  await onChange?.(provider, outcome)
238
243
  }
239
- results.push({ ...row, outcome, repeated: true, verified })
244
+ const latest = outcome.kind === 'pending' && !outcome.pendingReason && serve.pendingReason
245
+ ? { ...outcome, pendingReason: serve.pendingReason } : outcome
246
+ results.push({ ...row, outcome: latest, repeated: true, verified })
240
247
  }
241
248
  return results
242
249
  }
@@ -253,6 +260,7 @@ export function createDailyCheckin({ dir, adapters, enabled = true, isEnabled, n
253
260
  accounts: rows.map(row => ({
254
261
  accountId: row.id, kind: row.outcome.kind,
255
262
  ...(Number.isFinite(row.outcome.credit) ? { credit: row.outcome.credit } : {}),
263
+ ...(row.outcome.pendingReason ? { pendingReason: row.outcome.pendingReason } : {}),
256
264
  retryable: row.retryAt !== null,
257
265
  })),
258
266
  }]
@@ -824,6 +824,7 @@ export function createManagedChannelManager(ctx, spec, deps = {}) {
824
824
  credit: finite(result?.credit),
825
825
  streak: finite(result?.streak),
826
826
  unsubmitted: result?.unsubmitted === true,
827
+ ...(['response-unconfirmed', 'no-response'].includes(result?.pendingReason) ? { pendingReason: result.pendingReason } : {}),
827
828
  }
828
829
  }
829
830
 
@@ -507,12 +507,12 @@ export const astudioSpec = {
507
507
  if (before.grant) return { outcome: 'already-claimed', credit: Number(before.grant.amount) || null }
508
508
 
509
509
  // 2. 触发 init-app 结算今日登录积分
510
- await handle.fetch(`${STUDIO_ORIGIN}/xingchen-studio/tenant-app/v2/init-app`, {
510
+ const initReply = await handle.fetch(`${STUDIO_ORIGIN}/xingchen-studio/tenant-app/v2/init-app`, {
511
511
  method: 'POST',
512
512
  headers: { ...headers, 'content-type': 'application/json' },
513
513
  body: '{}',
514
514
  signal,
515
- }).catch(() => {})
515
+ }).catch(() => null)
516
516
 
517
517
  // 3. 查询待处理弹窗并关闭每日奖励弹窗(popupId 必须为正整数)
518
518
  try {
@@ -535,7 +535,7 @@ export const astudioSpec = {
535
535
  if (after?.grant) return { outcome: 'claimed', credit: Number(after.grant.amount) || null }
536
536
  // 写入已发出但无法取得入账证据(查询失败/业务拒绝/流水无记录):记 pending 等下轮核实,
537
537
  // 不再无证据返回 done——旧实现把「流水查不到」误报为已完成。
538
- return { outcome: 'pending' }
538
+ return { outcome: 'pending', pendingReason: initReply ? 'response-unconfirmed' : 'no-response' }
539
539
  },
540
540
 
541
541
  async claimRewards(handle, { signal }) {
@@ -340,7 +340,7 @@ async function ensureFreshCredential(handle, signal, { force = false } = {}) {
340
340
  }
341
341
  }
342
342
 
343
- async function signedFetchJson(fetchImpl, cred, { method = 'GET', url, headers = {}, body, signal, timeoutMs = 10_000 }) {
343
+ async function signedFetchJson(fetchImpl, cred, { method = 'GET', url, headers = {}, body, signal, timeoutMs = 10_000, observe }) {
344
344
  const bodyStr = body === undefined ? '' : (typeof body === 'string' ? body : JSON.stringify(body))
345
345
  const signedHeaders = signHuaweiRequest({
346
346
  method,
@@ -358,12 +358,14 @@ async function signedFetchJson(fetchImpl, cred, { method = 'GET', url, headers =
358
358
  })
359
359
  const deadline = AbortSignal.timeout(timeoutMs)
360
360
  const combined = signal ? AbortSignal.any([signal, deadline]) : deadline
361
+ if (observe && !combined.aborted) observe('no-response')
361
362
  const res = await fetchImpl(url, {
362
363
  method,
363
364
  headers: signedHeaders,
364
365
  ...(body !== undefined ? { body: bodyStr } : {}),
365
366
  signal: combined,
366
367
  })
368
+ if (res) observe?.('response-unconfirmed')
367
369
  if (!res.ok) {
368
370
  const err = new Error(`HTTP ${res.status}`)
369
371
  err.status = res.status
@@ -445,13 +447,14 @@ async function codeArtsFindDailyItem(handle, cred, signal, campaignId) {
445
447
  return null
446
448
  }
447
449
 
448
- async function codeArtsPostOps(handle, cred, path, body, signal) {
450
+ async function codeArtsPostOps(handle, cred, path, body, signal, observe) {
449
451
  return signedFetchJson(handle.fetch, cred, {
450
452
  method: 'POST',
451
453
  url: `${SNAP_ORIGIN}${path}`,
452
454
  headers: { 'Agent-Type': 'PromptCenter' },
453
455
  body,
454
456
  signal,
457
+ observe,
455
458
  }).catch(() => null)
456
459
  }
457
460
 
@@ -938,7 +941,7 @@ export const codeartsSpec = {
938
941
  let claimed = 0
939
942
  let creditSum = 0
940
943
  let doneCount = 0
941
- let pendingCount = 0
944
+ const pendingReasons = new Set()
942
945
  let failedCount = 0
943
946
  let submitted = false
944
947
  for (const { item, ch } of campaigns) {
@@ -962,23 +965,24 @@ export const codeartsSpec = {
962
965
  continue
963
966
  }
964
967
  }
965
- pendingCount++
968
+ pendingReasons.add('response-unconfirmed')
966
969
  continue
967
970
  }
968
971
  if (item?.claimable !== true) continue
969
972
  if (!campaignId) { failedCount++; continue }
970
973
  submitted = true
974
+ let claimReason
971
975
  const claimRes = await codeArtsPostOps(handle, cred, '/v1/ops/claim',
972
976
  ch === 'IDE'
973
977
  ? { campaignId, channel: 'IDE' }
974
978
  : { campaignId, idempotentKey: `claim_${campaignId}_${dayKey}`, channel: 'DESKTOP', ...(item.benefitId ? { benefitId: item.benefitId } : {}) },
975
- signal)
979
+ signal, reason => { claimReason = reason })
976
980
  if (!codeArtsBizOk(claimRes)) {
977
981
  // 领取响应存疑(传输失败或业务拒绝):先重查是否已在别处入账,绝不直接重发领取请求。
978
982
  const seenItem = await codeArtsFindDailyItem(handle, cred, signal, campaignId)
979
983
  if (codeArtsDailyClaimed(seenItem)) { doneCount++; continue }
980
984
  if (CODEARTS_INELIGIBLE_CLAIM.test(String(claimRes?.message ?? claimRes?.msg ?? ''))) continue
981
- pendingCount++
985
+ pendingReasons.add(claimReason)
982
986
  continue
983
987
  }
984
988
  const benefit = claimRes?.data && typeof claimRes.data === 'object' && !Array.isArray(claimRes.data) ? claimRes.data : {}
@@ -993,7 +997,7 @@ export const codeartsSpec = {
993
997
  claimed++
994
998
  creditSum += Number(benefit.benefitAmount ?? benefit.amount ?? benefit.creditAmount ?? item.benefitAmount) || 0
995
999
  } else {
996
- pendingCount++
1000
+ pendingReasons.add('response-unconfirmed')
997
1001
  }
998
1002
  continue
999
1003
  }
@@ -1001,14 +1005,18 @@ export const codeartsSpec = {
1001
1005
  if (userBenefitId == null && benefit.id !== null) {
1002
1006
  const seenItem = await codeArtsFindDailyItem(handle, cred, signal, campaignId)
1003
1007
  if (codeArtsDailyClaimed(seenItem)) doneCount++
1004
- else pendingCount++
1008
+ else pendingReasons.add('response-unconfirmed')
1005
1009
  continue
1006
1010
  }
1007
1011
  claimed++
1008
1012
  creditSum += Number(benefit.benefitAmount ?? benefit.amount ?? benefit.creditAmount ?? item.benefitAmount) || 0
1009
1013
  }
1010
1014
  // 未确认优先于任何已完成项,避免把部分结算当成整批成功。
1011
- if (pendingCount > 0) return { outcome: 'pending' }
1015
+ if (pendingReasons.size > 0) {
1016
+ // 不用一个活动的回包代表其他活动:不同原因并存时显示通用待确认。
1017
+ const [pendingReason] = pendingReasons
1018
+ return { outcome: 'pending', ...(pendingReasons.size === 1 && pendingReason ? { pendingReason } : {}) }
1019
+ }
1012
1020
  if (failedCount > 0) return { outcome: 'failed' }
1013
1021
  if (claimed > 0) return { outcome: 'claimed', credit: creditSum > 0 ? creditSum : null }
1014
1022
  if (doneCount > 0) return { outcome: 'already-claimed' }
@@ -39,15 +39,14 @@ export function ledgerRecordTime(value) {
39
39
  *
40
40
  * 页面按上游顺序(最新在前)遍历:第一条带 `modelName` 的记录即最新扣费。
41
41
  * 它的时间早于探测开始时刻就说明本次请求没落账(`null`),不能拿旧记录当证据。
42
- * 时间字段不可解析时退回按上游顺序取第一条。
42
+ * 探测时缺少可验证的时间时不把旧记录当成结果。
43
43
  */
44
44
  export function pickRouteRecord(rows, since) {
45
45
  for (const row of Array.isArray(rows) ? rows : []) {
46
46
  const model = typeof row?.modelName === 'string' ? row.modelName.trim() : ''
47
47
  if (!model) continue
48
48
  const at = ledgerRecordTime(row?.createdAt ?? row?.createTime ?? row?.time)
49
- if (at === null) return model
50
- if (since === undefined || at >= since) return model
49
+ if (since === undefined || (at !== null && at >= since)) return model
51
50
  return null
52
51
  }
53
52
  return null
@@ -10,6 +10,7 @@
10
10
  // `X-Session-Affinity`,请求体带 `$comment` 与 `stream_options`(简化 body 会被 429);
11
11
  // - 响应为标准 OpenAI SSE;部分错误是 HTTP 200 + 信封 `{code:"100002"|"020002"}`。
12
12
  import { createHash, randomUUID } from 'node:crypto'
13
+ import { setTimeout as waitForLedger } from 'node:timers/promises'
13
14
  import { openSystemBrowser } from '../browser-login.js'
14
15
  import { isSseResponse, readSseFrames } from './sse-frames.js'
15
16
  import {
@@ -31,6 +32,8 @@ const CATALOG_EVIDENCE_MS = 35 * 60_000
31
32
  // 最小探测:只为让台账落下一条真实出站模型记录,回复内容不读、不展示。
32
33
  const PROBE_MAX_TOKENS = 1
33
34
  const PROBE_TIMEOUT_MS = 60_000
35
+ const ROUTE_LEDGER_DELAYS_MS = [0, 350, 800, 1500]
36
+ const ROUTE_LEDGER_TIMEOUT_MS = 8000
34
37
 
35
38
  // 官方客户端 UA(magpie 最新逆向实证:第三方 UA 会被网关 403)。
36
39
  const CLIENT_USER_AGENT = 'Loomy|Desktop|Electron|macOS'
@@ -239,11 +242,15 @@ async function fetchUsage(handle, { signal }) {
239
242
  }
240
243
  const { failure, body } = await readBusiness(handle.fetch, LEDGER_PATH, credential, signal)
241
244
  if (failure === 'restricted' || failure === 'expired') state.restriction = routeObservation(failure)
242
- if (failure) return { signedIn: failure !== 'expired', error: failure === 'expired' ? 'auth_expired' : 'upstream_error', routeObservation: activeRestriction(state) ?? routeObservation(failure) }
245
+ const lastCheck = state.lastCheck && Date.now() - state.lastCheck.checkedAt <= CATALOG_EVIDENCE_MS ? state.lastCheck : undefined
246
+ if (failure) return { signedIn: failure !== 'expired', error: failure === 'expired' ? 'auth_expired' : 'upstream_error',
247
+ routeObservation: activeRestriction(state) ?? lastCheck ?? routeObservation(failure) }
243
248
  if (state.restriction?.status === 'expired') state.restriction = undefined
244
249
  const usage = wallet(body)
245
250
  const currentCatalog = state.catalog && Date.now() - state.catalog.checkedAt <= CATALOG_EVIDENCE_MS ? state.catalog : undefined
246
- const observation = activeRestriction(state) ?? (usage.balance === 0 ? routeObservation('exhausted') : currentCatalog ?? routeObservation('unknown'))
251
+ // The model being listed is not proof that a request used it.
252
+ const observation = activeRestriction(state) ?? (usage.balance === 0 ? routeObservation('exhausted')
253
+ : lastCheck ?? (currentCatalog?.status !== 'ready' ? currentCatalog : undefined) ?? routeObservation('unknown'))
247
254
  return { ...usage, unit: '积分', routeObservation: observation, ...(usage.balance === null && !usage.windows.length ? { error: 'upstream_error' } : {}) }
248
255
  }
249
256
 
@@ -289,9 +296,17 @@ async function blockedRoute(handle) {
289
296
  return activeRestriction(state)
290
297
  }
291
298
 
292
- async function checkRoute(handle, { signal, force = false }) {
299
+ async function checkRoute(handle, options) {
300
+ options.signal?.throwIfAborted()
301
+ const credential = await handle.getCredential()
302
+ const result = await observeRoute(handle, credential, options)
303
+ options.signal?.throwIfAborted()
304
+ if (credential) stateOf(handle.transportScope, credential).lastCheck = result
305
+ return result
306
+ }
307
+
308
+ async function observeRoute(handle, credential, { signal, force = false }) {
293
309
  try {
294
- const credential = await handle.getCredential()
295
310
  if (!credential) return routeObservation('expired')
296
311
  const state = stateOf(handle.transportScope, credential)
297
312
  if (credentialExpiresAtMs(credential) !== undefined && credentialExpiresAtMs(credential) <= Date.now()) {
@@ -323,15 +338,23 @@ async function checkRoute(handle, { signal, force = false }) {
323
338
  if (probe.failure) return routeObservation(probe.failure)
324
339
 
325
340
  // ③ 台账核对:响应回显会谎报,只有 `modelName` 记的是真实出站模型。
326
- const { failure, body } = await readBusiness(handle.fetch, ROUTE_LEDGER_PATH, credential, signal)
327
- if (failure === 'expired' || failure === 'restricted') {
328
- state.restriction = routeObservation(failure)
329
- return state.restriction
341
+ const timeout = AbortSignal.timeout(ROUTE_LEDGER_TIMEOUT_MS)
342
+ const ledgerSignal = signal ? AbortSignal.any([signal, timeout]) : timeout
343
+ let actual
344
+ for (const delay of ROUTE_LEDGER_DELAYS_MS) {
345
+ if (delay) await waitForLedger(delay, undefined, { signal: ledgerSignal })
346
+ const { failure, body } = await readBusiness(handle.fetch, ROUTE_LEDGER_PATH, credential, ledgerSignal)
347
+ ledgerSignal.throwIfAborted()
348
+ if (failure === 'expired' || failure === 'restricted') {
349
+ state.restriction = routeObservation(failure)
350
+ return state.restriction
351
+ }
352
+ if (failure && failure !== 'unknown') return routeObservation(failure)
353
+ const recorded = pickRouteRecord(body?.data?.list ?? body?.data?.data?.list ?? body?.list, since)
354
+ actual = ledgerModelFamily(recorded)
355
+ if (actual) break
330
356
  }
331
- if (failure) return routeObservation(failure)
332
- const recorded = pickRouteRecord(body?.data?.list ?? body?.data?.data?.list ?? body?.list, since)
333
357
  const expected = modelFamilyOf(REFERENCE_MODEL)
334
- const actual = ledgerModelFamily(recorded)
335
358
  if (!actual || !expected) return routeObservation('unknown')
336
359
  // 判受限要落进暂缓标记:否则「检测有问题」与「自动避开」是两张皮 ——
337
360
  // 界面显示受限、选号却照旧挑它,下一次检测又要重发一次最小探测。
@@ -5,6 +5,7 @@ import { profileSegment } from '../vendor/sensenova-token-plan/index.js'
5
5
  import { WORKBUDDY_MODEL_WRITES } from './workbuddy-models.js'
6
6
  import { MANAGED_MODEL_WRITES } from './managed-models.js'
7
7
  import { publicAutomationConfig } from './automation-settings.js'
8
+ import { checkinPendingReason } from './channel-contract.js'
8
9
  import { quotaPriorityProviders } from './quota-priority.js'
9
10
  import { invalidationRule } from './channel-specs.js'
10
11
 
@@ -153,7 +154,7 @@ export function settingsCheckinAdapters({ standalone, rpc, workbuddy, managed })
153
154
  async claim(accountId, signal) {
154
155
  const result = await rpc('workbuddy.checkin', { provider: WORKBUDDY_PROVIDER_ID, accountId }, signal)
155
156
  const kind = result.outcome === 'done' ? 'already-claimed' : result.outcome
156
- return { kind, credit: result.credit, streak: result.streak, unsubmitted: result.unsubmitted === true }
157
+ return { kind, credit: result.credit, streak: result.streak, pendingReason: result.pendingReason, unsubmitted: result.unsubmitted === true }
157
158
  },
158
159
  })
159
160
  // Raccoon 家族:签到是**账号级**事项,由代表账号池的 `raccoon` 承担
@@ -175,7 +176,7 @@ export function settingsCheckinAdapters({ standalone, rpc, workbuddy, managed })
175
176
  async claim(accountId, signal) {
176
177
  const result = await rpc('raccoon.checkin', { provider: RACCOON_CHECKIN_PROVIDER_ID, accountId }, signal)
177
178
  const kind = result.outcome === 'done' ? 'already-claimed' : result.outcome
178
- return { kind, credit: result.credit }
179
+ return { kind, credit: result.credit, pendingReason: result.pendingReason }
179
180
  },
180
181
  })
181
182
  }
@@ -197,7 +198,7 @@ export function settingsCheckinAdapters({ standalone, rpc, workbuddy, managed })
197
198
  async claim(accountId, signal) {
198
199
  const result = await rpc('managed.checkin', { provider: id, accountId }, signal)
199
200
  const kind = result.outcome === 'done' ? 'already-claimed' : result.outcome
200
- return { kind, credit: result.credit, streak: result.streak, unsubmitted: result.unsubmitted === true }
201
+ return { kind, credit: result.credit, streak: result.streak, pendingReason: result.pendingReason, unsubmitted: result.unsubmitted === true }
201
202
  },
202
203
  })
203
204
  }
@@ -288,6 +289,7 @@ export function publicCheckinStatus(value, extraIds = MANAGED_PROVIDER_IDS) {
288
289
  accountId: account.accountId, kind: account.kind,
289
290
  // 额度增长确认时记录本次到账量,供账号行标签展示。
290
291
  ...(Number.isFinite(account.credit) ? { credit: account.credit } : {}),
292
+ ...(checkinPendingReason(account.pendingReason) ? { pendingReason: account.pendingReason } : {}),
291
293
  retryable: account.retryable === true,
292
294
  })),
293
295
  }]]
package/lib/web-host.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { normalizePlanParams, PLAN_EFFORTS } from "./sensenova-params.js"
2
- import { accountWire, modelWire, wireJson, wireRate, projectRouteObservation } from './channel-contract.js'
2
+ import { accountWire, modelWire, wireJson, wireRate, projectRouteObservation, checkinPendingReason } from './channel-contract.js'
3
3
  import { guardedRpc, sharedTransport, loginUrl, PROVIDERS, PLAN_PROVIDER_ID, PLAN_METHODS, WORKBUDDY_METHODS, APIKEY_PROVIDER_IDS, APIKEY_METHODS, MANAGED_PROVIDER_IDS, MANAGED_METHODS, AUTOMATION_METHODS, ALL_PROVIDER_IDS } from './rpc.js'
4
4
  import { createSenseNovaManager } from './sensenova.js'
5
5
  import { projectSenseNovaQuota } from './sensenova-quota.js'
@@ -37,6 +37,7 @@ const apikeyWriteMethods = new Set(['apikey.setKey', 'apikey.setEnabled', 'apike
37
37
  const automationWriteMethods = new Set(['automation.setConfig', 'automation.run', 'automation.query'])
38
38
  const writeMethods = new Set([...planWriteMethods, ...workbuddyWriteMethods, ...apikeyWriteMethods, ...MANAGED_WRITE_METHODS, ...automationWriteMethods, 'settings.refresh', 'credits.claimAll', 'onboarding.claim', 'raccoon.checkin', 'model.setParams', 'provider.setEnabled'])
39
39
  // 终界自证:错误码与签到 outcome 在投影层再过一次白名单,不依赖上游自律。
40
+ const checkinEvidence = value => checkinPendingReason(value?.pendingReason) ? { pendingReason: value.pendingReason } : {}
40
41
  const workbuddyErrorCodes = new Set(['not_configured', 'credential_error', 'auth_expired', 'auth_error', 'upstream_error', 'checkin_error'])
41
42
  const workbuddyCheckinOutcomes = new Set(['claimed', 'done', 'inactive', 'ineligible', 'failed', 'pending'])
42
43
  const planMaxTokens = value => Number.isSafeInteger(value) && value > 0 && value <= 10_000_000 ? value : null
@@ -237,7 +238,7 @@ function projectPublicResult(method, value) {
237
238
  if (method === 'workbuddy.login') return { id: text(value?.id, 64), signedIn: value?.signedIn === true, accountId: text(value?.accountId, 160), uid: text(value?.uid, 160) }
238
239
  if (method === 'workbuddy.logout') return { signedIn: value?.signedIn === true }
239
240
  if (method === 'workbuddy.setEnabled') return { enabled: value?.enabled === true }
240
- if (method === 'workbuddy.checkin') return { outcome: workbuddyCheckinOutcomes.has(value?.outcome) ? value.outcome : 'failed', credit: finite(value?.credit), streak: finite(value?.streak) }
241
+ if (method === 'workbuddy.checkin') return { outcome: workbuddyCheckinOutcomes.has(value?.outcome) ? value.outcome : 'failed', credit: finite(value?.credit), streak: finite(value?.streak), ...checkinEvidence(value) }
241
242
  if (method === 'workbuddy.models' || WORKBUDDY_MODEL_WRITES.includes(method)) return {
242
243
  models: (Array.isArray(value?.models) ? value.models : []).slice(0, 256).map(wbModel).filter(Boolean),
243
244
  source: value?.source === 'remote' ? 'remote' : value?.source === 'cached' ? 'cached' : 'fallback',
@@ -307,7 +308,7 @@ function projectPublicResult(method, value) {
307
308
  return { accountId: text(value?.accountId, 64), ...(route ? { routeObservation: route } : {}) }
308
309
  }
309
310
  if (method === 'managed.checkin') {
310
- return { provider: text(value?.provider, 64), outcome: MANAGED_CHECKIN_OUTCOMES.has(value?.outcome) ? value.outcome : 'failed', credit: finite(value?.credit), streak: finite(value?.streak) }
311
+ return { provider: text(value?.provider, 64), outcome: MANAGED_CHECKIN_OUTCOMES.has(value?.outcome) ? value.outcome : 'failed', credit: finite(value?.credit), streak: finite(value?.streak), ...checkinEvidence(value) }
311
312
  }
312
313
  if (method === 'managed.claimRewards' || method === 'managed.completeTasks') {
313
314
  return {
@@ -340,6 +341,7 @@ function projectPublicResult(method, value) {
340
341
  ...(method === 'automation.query' && value?.mode === 'checkin' && row?.queryFailed === true ? { queryFailed: true } : {}),
341
342
  outcome: {
342
343
  kind: outcomes.has(row?.outcome?.kind) ? row.outcome.kind : 'failed',
344
+ ...(value?.mode === 'checkin' ? checkinEvidence(row?.outcome) : {}),
343
345
  ...(finite(row?.outcome?.claimed) !== null ? { claimed: row.outcome.claimed } : {}),
344
346
  ...(finite(row?.outcome?.completed) !== null ? { completed: row.outcome.completed } : {}),
345
347
  ...(finite(row?.outcome?.points) !== null ? { points: row.outcome.points } : {}),
@@ -367,7 +369,7 @@ function projectPublicResult(method, value) {
367
369
  })) } : null,
368
370
  ...(a.error ? { error: '余额读取失败' } : {}),
369
371
  })) }
370
- if (method === 'credits.claimAll') return { results: (value?.results ?? []).map(r => ({ accountId: r.accountId, nickname: text(r.nickname, 80), outcome: { kind: ['claimed','already-claimed','inactive','failed','pending'].includes(r.outcome?.kind) ? r.outcome.kind : 'failed', actionRequired: r.outcome?.actionRequired === true, credit: finite(r.outcome?.credit) } })) }
372
+ if (method === 'credits.claimAll') return { results: (value?.results ?? []).map(r => ({ accountId: r.accountId, nickname: text(r.nickname, 80), outcome: { kind: ['claimed','already-claimed','inactive','failed','pending'].includes(r.outcome?.kind) ? r.outcome.kind : 'failed', actionRequired: r.outcome?.actionRequired === true, credit: finite(r.outcome?.credit), ...checkinEvidence(r.outcome) } })) }
371
373
  // 目录刷新结果:只回「拉了多少条 + 是不是真拉到了」。
372
374
  // source 只认白名单里的两个值,未知值一律按离线兜底(宁可说没拉到,也不谎报远端)。
373
375
  if (method === 'model.refresh') return { count: finite(value?.count), source: 'fallback', ...publicCatalogStatus(value) }
@@ -1017,9 +1019,9 @@ ${String(error?.stack ?? error)}
1017
1019
  }
1018
1020
  if (typeof payload.accountId !== 'string' || !payload.accountId) throw new Error('账号无效')
1019
1021
  const [record] = await checkin.claim(payload.provider, payload.accountId, request.signal)
1020
- const { kind, credit, streak } = record.outcome
1022
+ const { kind, credit, streak, pendingReason } = record.outcome
1021
1023
  const outcome = kind === 'already-claimed' || record.repeated && kind === 'claimed' ? 'done' : kind
1022
- return reply(rpcId, { ok: true, value: publicResult(method, { provider: payload.provider, outcome, credit, streak }) })
1024
+ return reply(rpcId, { ok: true, value: publicResult(method, { provider: payload.provider, outcome, credit, streak, pendingReason }) })
1023
1025
  }
1024
1026
  if (method === 'managed.claimRewards' || method === 'managed.completeTasks') {
1025
1027
  if (typeof payload.accountId !== 'string' || !payload.accountId) throw new Error('账号无效')
package/lib/workbuddy.js CHANGED
@@ -869,14 +869,19 @@ export function createWorkBuddyManager(ctx, rawConfig = {}, testDeps = {}) {
869
869
  const { auth, corrupt } = await readAccountAuth(entry)
870
870
  if (!auth) return { outcome: 'failed', credit: null, streak: null, error: corrupt ? 'credential_error' : 'not_configured' }
871
871
  let result
872
+ let attempted = false
872
873
  try {
873
874
  const pluginObject = await pluginFor(entry.id)
874
875
  if (typeof pluginObject?.auth?.checkin !== 'function') throw new Error('checkin hook missing')
876
+ attempted = true
875
877
  result = await raceAbort(Promise.resolve(pluginObject.auth.checkin(getAuthFor(entry), { waits: [], ...(statusOnly ? { statusOnly: true } : {}) })), signal)
876
878
  } catch (error) {
877
879
  if (signal?.aborted) throw error
878
880
  // 上游约定:拿到 WorkBuddy 答复的失败以 {outcome} 返回,发不出请求的才抛。
879
881
  // 抛出的(离线、超时)同样收成固定码。
882
+ if (attempted && !statusOnly && error?.status === undefined && error?.code === undefined) {
883
+ return { outcome: 'pending', credit: null, streak: null, pendingReason: 'no-response', error: 'checkin_error' }
884
+ }
880
885
  return { outcome: 'failed', credit: null, streak: null, error: 'checkin_error' }
881
886
  }
882
887
  signal?.throwIfAborted()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-unified-router",
3
- "version": "0.8.8",
3
+ "version": "0.8.9",
4
4
  "type": "module",
5
5
  "main": "lib/web-host.js",
6
6
  "license": "MIT",