qwenproxy-cli 1.6.0 → 1.6.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/dist/clean-cache.js +54 -7
- package/dist/delete-chats.js +380 -12
- package/dist/index.js +774 -117
- package/dist/login.js +432 -13
- package/dist/reset-cooldowns.js +64 -7
- package/dist/sync-clients.js +2 -2
- package/package.json +3 -3
- package/src/clean-cache.ts +3 -0
- package/src/core/accounts.ts +1 -1
- package/src/core/config.ts +2 -2
- package/src/core/process-guard.ts +77 -0
- package/src/core/version.ts +1 -1
- package/src/delete-chats.ts +3 -0
- package/src/index.ts +3 -29
- package/src/login.ts +92 -4
- package/src/routes/chat/account.ts +11 -4
- package/src/routes/chat/retry-policy.ts +75 -3
- package/src/routes/chat/streaming.ts +68 -1
- package/src/services/chat-cleanup.ts +5 -0
- package/src/services/playwright.ts +384 -6
- package/src/services/qwen.ts +22 -6
- package/src/tui/views/accounts-view.ts +313 -96
- package/src/utils/overload-detector.ts +55 -0
package/src/services/qwen.ts
CHANGED
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
syncModelMetadata,
|
|
28
28
|
} from "../core/model-registry.ts";
|
|
29
29
|
import { type Page, type BrowserContext } from "patchright";
|
|
30
|
-
import { withAccountPage, assertAntiBotHeaders, onBrowserContextCreated, isPlaywrightInitializing } from "./playwright.ts";
|
|
30
|
+
import { withAccountPage, assertAntiBotHeaders, onBrowserContextCreated, isPlaywrightInitializing, isPlaywrightInitialized } from "./playwright.ts";
|
|
31
31
|
import { recoverBaxiaCaptcha } from "./captcha-coordinator.ts";
|
|
32
32
|
import { startBaxiaCaptchaWatcher } from "./captcha-solver.ts";
|
|
33
33
|
import { isAccountBusy } from "../core/account-concurrency.ts";
|
|
@@ -1139,6 +1139,7 @@ async function requestQwenPersonalizationInBrowser(
|
|
|
1139
1139
|
{
|
|
1140
1140
|
settingsPage: true,
|
|
1141
1141
|
referrer: qwenUrl("/settings/personalization"),
|
|
1142
|
+
noMutexRecovery: true,
|
|
1142
1143
|
},
|
|
1143
1144
|
);
|
|
1144
1145
|
const { raw, json } = await readJsonTextResponse(response);
|
|
@@ -1831,8 +1832,13 @@ async function syncQwenRequestPersonalizationInternal(
|
|
|
1831
1832
|
typeof textSize
|
|
1832
1833
|
>;
|
|
1833
1834
|
|
|
1835
|
+
const matchReturned =
|
|
1836
|
+
(isEmptyInstruction && (!returnedInstruction || returned.chars === 0)) ||
|
|
1837
|
+
(returned.hash !== null && returned.hash === sent.hash);
|
|
1838
|
+
|
|
1834
1839
|
let verifyData: any = null;
|
|
1835
|
-
|
|
1840
|
+
// If the update response already confirmed the exact instruction, skip the redundant GET round-trip
|
|
1841
|
+
if (config.qwen.personalizationVerifyGet && !matchReturned) {
|
|
1836
1842
|
const { json: verifyJson } =
|
|
1837
1843
|
await requestQwenPersonalizationInBrowser(
|
|
1838
1844
|
accountId,
|
|
@@ -1843,10 +1849,6 @@ async function syncQwenRequestPersonalizationInternal(
|
|
|
1843
1849
|
verifyData = verifyJson?.data?.personalization;
|
|
1844
1850
|
stored = textSize(verifyData?.instruction);
|
|
1845
1851
|
}
|
|
1846
|
-
|
|
1847
|
-
const matchReturned =
|
|
1848
|
-
(isEmptyInstruction && (!returnedInstruction || returned.chars === 0)) ||
|
|
1849
|
-
(returned.hash !== null && returned.hash === sent.hash);
|
|
1850
1852
|
const matchStored =
|
|
1851
1853
|
stored.hash === null
|
|
1852
1854
|
? null
|
|
@@ -2331,6 +2333,20 @@ export async function fetchQwenModels(
|
|
|
2331
2333
|
return cached.models;
|
|
2332
2334
|
}
|
|
2333
2335
|
|
|
2336
|
+
// For accounts that are not initialized yet, avoid cold-booting Playwright just for model metadata.
|
|
2337
|
+
// Reuse existing models from any active cache entry (models catalog is identical across accounts).
|
|
2338
|
+
if (accountId && !isAuthMockEnabled() && !isPlaywrightInitialized(accountId)) {
|
|
2339
|
+
for (const [, entry] of modelsCache.entries()) {
|
|
2340
|
+
if (entry && now - entry.fetchedAt < MODEL_CACHE_TTL_MS * 4) {
|
|
2341
|
+
syncModelMetadata(
|
|
2342
|
+
entry.models as unknown as Array<Record<string, unknown> & { id: string }>,
|
|
2343
|
+
accountId,
|
|
2344
|
+
);
|
|
2345
|
+
return entry.models;
|
|
2346
|
+
}
|
|
2347
|
+
}
|
|
2348
|
+
}
|
|
2349
|
+
|
|
2334
2350
|
// Use an isolated page only when the main page is actively serving a stream.
|
|
2335
2351
|
// Startup/idle operations should not open a visible extra tab.
|
|
2336
2352
|
if (accountId && !isAuthMockEnabled() && isAccountBusy(accountId)) {
|