qwenproxy-cli 1.0.19 → 1.0.20

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qwenproxy-cli",
3
- "version": "1.0.19",
3
+ "version": "1.0.20",
4
4
  "description": "High-performance OpenAI & Anthropic compatible API gateway for Qwen with multi-account rotation, interactive TUI, and resilient tool calling.",
5
5
  "main": "src/index.ts",
6
6
  "bin": {
@@ -956,18 +956,9 @@ function parseJsonIfPossible(raw: string): unknown {
956
956
  }
957
957
 
958
958
  /**
959
- * Cooldown for a RateLimited error. Uses the hours the upstream reports in its
960
- * error message (e.g. "Please wait 4 hours...") when present; otherwise falls
961
- * back to the account manager's default cooldown.
959
+ * Cooldown for a RateLimited error. Per Invariant 4, daily quotas reset strictly
960
+ * at 00:00 UTC, so we delegate to markAccountRateLimited's default midnight calculation.
962
961
  */
963
- function rateLimitCooldownMs(err: UpstreamRateLimit): number | undefined {
964
- const hourMatch = err.message?.match(/(\d+)\s*hours?/i);
965
- if (hourMatch) {
966
- const hours = Math.max(1, parseInt(hourMatch[1], 10));
967
- return hours * 60 * 60 * 1000;
968
- }
969
- return undefined;
970
- }
971
962
 
972
963
  /**
973
964
  * Detects a Qwen daily usage limit response. The upstream answers HTTP 200
@@ -1290,11 +1281,7 @@ export async function generateImage(params: {
1290
1281
  }
1291
1282
 
1292
1283
  if (lastError instanceof UpstreamRateLimit) {
1293
- markAccountRateLimited(
1294
- account.id,
1295
- rateLimitCooldownMs(lastError),
1296
- "RateLimited",
1297
- );
1284
+ markAccountRateLimited(account.id, undefined, "RateLimited");
1298
1285
  } else {
1299
1286
  markAccountRateLimited(account.id, ACCOUNT_COOLDOWN_MS, "MediaGenFailed");
1300
1287
  }
@@ -1533,11 +1520,7 @@ export async function generateVideo(params: {
1533
1520
  }
1534
1521
 
1535
1522
  if (lastError instanceof UpstreamRateLimit) {
1536
- markAccountRateLimited(
1537
- account.id,
1538
- rateLimitCooldownMs(lastError),
1539
- "RateLimited",
1540
- );
1523
+ markAccountRateLimited(account.id, undefined, "RateLimited");
1541
1524
  } else {
1542
1525
  markAccountRateLimited(account.id, ACCOUNT_COOLDOWN_MS, "MediaGenFailed");
1543
1526
  }
@@ -189,7 +189,7 @@ async function recoverStuckAccountMutex(
189
189
  );
190
190
  const context = accountContexts.get(accountId);
191
191
  if (context) {
192
- await closePlaywrightContextBestEffort(accountId, context);
192
+ await closePlaywrightContextBestEffort(accountId, context, { skipStorageSave: true });
193
193
  }
194
194
  cleanupPlaywrightAccountState(accountId);
195
195
  if (accountMutexes.get(accountId) === mutex) {
@@ -2559,7 +2559,7 @@ export async function withAccountPage<T>(
2559
2559
  );
2560
2560
  const context = accountContexts.get(accountId);
2561
2561
  if (context) {
2562
- await closePlaywrightContextBestEffort(accountId, context);
2562
+ await closePlaywrightContextBestEffort(accountId, context, { skipStorageSave: true });
2563
2563
  }
2564
2564
  cleanupPlaywrightAccountState(accountId);
2565
2565
  }
@@ -3047,7 +3047,7 @@ export function installContextDeathHandlers(
3047
3047
  ): void {
3048
3048
  const onDeath = (): void => {
3049
3049
  cleanupPlaywrightAccountState(accountId);
3050
- void closePlaywrightContextBestEffort(accountId, context).catch(() => {});
3050
+ void closePlaywrightContextBestEffort(accountId, context, { skipStorageSave: true }).catch(() => {});
3051
3051
  };
3052
3052
  context.on("close", onDeath);
3053
3053
  page.on("crash", onDeath);