qwenproxy-cli 1.0.7 → 1.0.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/bin/qwenproxy.js +46 -13
- package/package.json +2 -2
- package/src/services/playwright.ts +38 -21
package/bin/qwenproxy.js
CHANGED
|
@@ -134,25 +134,58 @@ if (isBrowserCommand) {
|
|
|
134
134
|
const patchrightEntry = require.resolve("patchright");
|
|
135
135
|
cliPath = path.join(path.dirname(patchrightEntry), "cli.js");
|
|
136
136
|
} catch {}
|
|
137
|
-
const installEnv = {
|
|
138
|
-
...process.env,
|
|
139
|
-
PLAYWRIGHT_DOWNLOAD_CONNECTION_TIMEOUT:
|
|
140
|
-
process.env.PLAYWRIGHT_DOWNLOAD_CONNECTION_TIMEOUT || "300000",
|
|
141
|
-
};
|
|
142
137
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
138
|
+
const runInstall = (mirrorHost) => {
|
|
139
|
+
const installEnv = {
|
|
140
|
+
...process.env,
|
|
141
|
+
PLAYWRIGHT_DOWNLOAD_CONNECTION_TIMEOUT:
|
|
142
|
+
process.env.PLAYWRIGHT_DOWNLOAD_CONNECTION_TIMEOUT || "120000",
|
|
143
|
+
...(mirrorHost ? { PLAYWRIGHT_DOWNLOAD_HOST: mirrorHost } : {}),
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
if (cliPath && fs.existsSync(cliPath)) {
|
|
147
|
+
return spawnSync(process.execPath, [cliPath, "install", "chromium"], {
|
|
148
|
+
stdio: "inherit",
|
|
149
|
+
env: installEnv,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
149
152
|
const cmd = process.platform === "win32" ? "npx.cmd" : "npx";
|
|
150
|
-
spawnSync(cmd, ["--yes", "patchright", "install", "chromium"], {
|
|
153
|
+
return spawnSync(cmd, ["--yes", "patchright", "install", "chromium"], {
|
|
151
154
|
stdio: "inherit",
|
|
152
155
|
env: installEnv,
|
|
153
156
|
});
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
let chosenHost = process.env.PLAYWRIGHT_DOWNLOAD_HOST;
|
|
160
|
+
if (!chosenHost) {
|
|
161
|
+
// Probe official CDN; if unresponsive within 2s, switch to global mirror immediately
|
|
162
|
+
const controller = new AbortController();
|
|
163
|
+
const probeTimer = setTimeout(() => controller.abort(), 2000);
|
|
164
|
+
try {
|
|
165
|
+
const probe = await fetch("https://cdn.playwright.dev", { method: "HEAD", signal: controller.signal });
|
|
166
|
+
clearTimeout(probeTimer);
|
|
167
|
+
if (probe.status >= 500) chosenHost = "https://npmmirror.com/mirrors/playwright";
|
|
168
|
+
} catch {
|
|
169
|
+
clearTimeout(probeTimer);
|
|
170
|
+
chosenHost = "https://npmmirror.com/mirrors/playwright";
|
|
171
|
+
console.log("🌐 [QwenProxy] CDN oficial indisponível na sua região. Usando espelho global de alta velocidade...");
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
let res = runInstall(chosenHost);
|
|
176
|
+
if (res.status !== 0 && !chosenHost) {
|
|
177
|
+
console.log("\n⚠️ [QwenProxy] Falha no CDN primário. Tentando espelho global de alta velocidade...");
|
|
178
|
+
res = runInstall("https://npmmirror.com/mirrors/playwright");
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (res.status === 0) {
|
|
182
|
+
console.log("✓ [QwenProxy] Navegador instalado com sucesso!\n");
|
|
183
|
+
// Automatically prune older, unused browser builds to free up disk space
|
|
184
|
+
try {
|
|
185
|
+
const { cleanPlaywrightBrowsers } = await import("../src/clean-cache.ts");
|
|
186
|
+
await cleanPlaywrightBrowsers(true);
|
|
187
|
+
} catch {}
|
|
154
188
|
}
|
|
155
|
-
console.log("✓ [QwenProxy] Navegador instalado com sucesso!\n");
|
|
156
189
|
}
|
|
157
190
|
} catch {}
|
|
158
191
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qwenproxy-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
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": {
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"better-sqlite3": "^13.0.3",
|
|
61
61
|
"dotenv": "^17.4.2",
|
|
62
62
|
"hono": "^4.13.7",
|
|
63
|
-
"patchright": "
|
|
63
|
+
"patchright": "1.63.0",
|
|
64
64
|
"tsx": "^4.23.13",
|
|
65
65
|
"uuid": "^14.0.2",
|
|
66
66
|
"zod": "^4.5.4"
|
|
@@ -13,30 +13,47 @@ import { createRequire } from "module";
|
|
|
13
13
|
const requireLocal = createRequire(import.meta.url);
|
|
14
14
|
|
|
15
15
|
function autoInstallPlaywrightChromium(): void {
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
const tryInstall = (mirror?: string): number | null => {
|
|
17
|
+
const installEnv = {
|
|
18
|
+
...process.env,
|
|
19
|
+
PLAYWRIGHT_DOWNLOAD_CONNECTION_TIMEOUT:
|
|
20
|
+
process.env.PLAYWRIGHT_DOWNLOAD_CONNECTION_TIMEOUT || "120000",
|
|
21
|
+
...(mirror ? { PLAYWRIGHT_DOWNLOAD_HOST: mirror } : {}),
|
|
22
|
+
};
|
|
23
|
+
try {
|
|
24
|
+
const patchrightEntry = requireLocal.resolve("patchright");
|
|
25
|
+
const cliPath = path.join(path.dirname(patchrightEntry), "cli.js");
|
|
26
|
+
if (fs.existsSync(cliPath)) {
|
|
27
|
+
console.log("⏳ [Playwright] Navegador Chromium não encontrado. Instalando automaticamente...");
|
|
28
|
+
const res = spawnSync(process.execPath, [cliPath, "install", "chromium"], {
|
|
29
|
+
stdio: "inherit",
|
|
30
|
+
env: installEnv,
|
|
31
|
+
});
|
|
32
|
+
return res.status;
|
|
33
|
+
}
|
|
34
|
+
} catch {}
|
|
35
|
+
|
|
36
|
+
console.log("⏳ [Playwright] Navegador Chromium não encontrado. Instalando via npx...");
|
|
37
|
+
const cmd = process.platform === "win32" ? "npx.cmd" : "npx";
|
|
38
|
+
const res = spawnSync(cmd, ["--yes", "patchright", "install", "chromium"], {
|
|
39
|
+
stdio: "inherit",
|
|
40
|
+
env: installEnv,
|
|
41
|
+
});
|
|
42
|
+
return res.status;
|
|
20
43
|
};
|
|
44
|
+
|
|
45
|
+
const status = tryInstall(process.env.PLAYWRIGHT_DOWNLOAD_HOST);
|
|
46
|
+
if (status !== 0 && !process.env.PLAYWRIGHT_DOWNLOAD_HOST) {
|
|
47
|
+
console.log("\n⚠️ [Playwright] Falha no CDN primário. Tentando espelho global de alta velocidade...");
|
|
48
|
+
tryInstall("https://npmmirror.com/mirrors/playwright");
|
|
49
|
+
}
|
|
50
|
+
|
|
21
51
|
try {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
spawnSync(process.execPath, [cliPath, "install", "chromium"], {
|
|
27
|
-
stdio: "inherit",
|
|
28
|
-
env: installEnv,
|
|
29
|
-
});
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
52
|
+
void (async () => {
|
|
53
|
+
const { cleanPlaywrightBrowsers } = await import("../clean-cache.ts");
|
|
54
|
+
await cleanPlaywrightBrowsers(true);
|
|
55
|
+
})();
|
|
32
56
|
} catch {}
|
|
33
|
-
|
|
34
|
-
console.log("⏳ [Playwright] Navegador Chromium não encontrado. Instalando via npx...");
|
|
35
|
-
const cmd = process.platform === "win32" ? "npx.cmd" : "npx";
|
|
36
|
-
spawnSync(cmd, ["--yes", "patchright", "install", "chromium"], {
|
|
37
|
-
stdio: "inherit",
|
|
38
|
-
env: installEnv,
|
|
39
|
-
});
|
|
40
57
|
}
|
|
41
58
|
import { loadAccounts, type QwenAccount } from "../core/accounts.ts";
|
|
42
59
|
// Imported here rather than injected from session-keeper.ts: account-concurrency
|