pi-provider-qoder-cn 0.2.23 → 0.2.24
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/dist/index.js +9 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2455,6 +2455,11 @@ function getBeijingDailyResetCountdown(now = Date.now()) {
|
|
|
2455
2455
|
const minutes = totalMinutes % 60;
|
|
2456
2456
|
return hours > 0 ? `${hours}\u5C0F\u65F6${minutes}\u5206\u949F` : `${minutes}\u5206\u949F`;
|
|
2457
2457
|
}
|
|
2458
|
+
var CREDENTIAL_EXPIRED_CODES = /* @__PURE__ */ new Set(["105", "TOKEN_EXPIRE", "TOKEN_EXPIRED"]);
|
|
2459
|
+
var CREDENTIAL_EXPIRED_MESSAGE = /token expired|login expired|token is not active|token has expired/i;
|
|
2460
|
+
function isCredentialExpiredVerdict(code, message) {
|
|
2461
|
+
return code !== void 0 && CREDENTIAL_EXPIRED_CODES.has(code) || CREDENTIAL_EXPIRED_MESSAGE.test(message);
|
|
2462
|
+
}
|
|
2458
2463
|
function formatQoderStreamError(statusCode, rawBody, now = Date.now(), mode = "cn") {
|
|
2459
2464
|
const parsed = parseQoderErrorPayload(rawBody);
|
|
2460
2465
|
const code = parsed?.code;
|
|
@@ -2534,7 +2539,7 @@ function formatQoderStreamError(statusCode, rawBody, now = Date.now(), mode = "c
|
|
|
2534
2539
|
`- Fix: purchase a credit pack at ${store}, or wait for the next billing cycle.`
|
|
2535
2540
|
].join("\n");
|
|
2536
2541
|
}
|
|
2537
|
-
if (code
|
|
2542
|
+
if (isCredentialExpiredVerdict(code, message)) {
|
|
2538
2543
|
if (isCn) {
|
|
2539
2544
|
return [
|
|
2540
2545
|
`[Qoder CN \u51ED\u8BC1\u5931\u6548] \u767B\u5F55\u6001\u5DF2\u8FC7\u671F\u6216 Token \u5931\u6548 (\u9519\u8BEF\u7801 105)`,
|
|
@@ -2598,7 +2603,8 @@ function formatQoderStreamError(statusCode, rawBody, now = Date.now(), mode = "c
|
|
|
2598
2603
|
}
|
|
2599
2604
|
function isCredentialExpiredError(error) {
|
|
2600
2605
|
const message = error instanceof Error ? error.message : String(error ?? "");
|
|
2601
|
-
|
|
2606
|
+
if (message.includes("\u9519\u8BEF\u7801 105") || message.includes("\u51ED\u8BC1\u5931\u6548")) return true;
|
|
2607
|
+
return isCredentialExpiredVerdict(void 0, message) || /TOKEN_EXPIRED?/i.test(message);
|
|
2602
2608
|
}
|
|
2603
2609
|
|
|
2604
2610
|
// src/commands/usage.ts
|
|
@@ -3520,7 +3526,7 @@ async function peekCredentialExpired(reader, decoder) {
|
|
|
3520
3526
|
if (typeof envelope.statusCodeValue === "number" && envelope.statusCodeValue !== 200) {
|
|
3521
3527
|
const parsed = parseQoderErrorPayload(envelope.body);
|
|
3522
3528
|
const message = parsed?.message ?? (typeof envelope.body === "string" ? envelope.body : "");
|
|
3523
|
-
return parsed?.code
|
|
3529
|
+
return isCredentialExpiredVerdict(parsed?.code, message);
|
|
3524
3530
|
}
|
|
3525
3531
|
return false;
|
|
3526
3532
|
} catch {
|
package/package.json
CHANGED