qwenproxy-cli 1.0.7 → 1.0.8
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 +41 -13
- package/package.json +1 -1
- package/src/services/playwright.ts +32 -22
package/bin/qwenproxy.js
CHANGED
|
@@ -134,25 +134,53 @@ 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");
|
|
154
183
|
}
|
|
155
|
-
console.log("✓ [QwenProxy] Navegador instalado com sucesso!\n");
|
|
156
184
|
}
|
|
157
185
|
} catch {}
|
|
158
186
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qwenproxy-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
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": {
|
|
@@ -13,30 +13,40 @@ 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
|
};
|
|
21
|
-
try {
|
|
22
|
-
const patchrightEntry = requireLocal.resolve("patchright");
|
|
23
|
-
const cliPath = path.join(path.dirname(patchrightEntry), "cli.js");
|
|
24
|
-
if (fs.existsSync(cliPath)) {
|
|
25
|
-
console.log("⏳ [Playwright] Navegador Chromium não encontrado. Instalando automaticamente...");
|
|
26
|
-
spawnSync(process.execPath, [cliPath, "install", "chromium"], {
|
|
27
|
-
stdio: "inherit",
|
|
28
|
-
env: installEnv,
|
|
29
|
-
});
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
} catch {}
|
|
33
44
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
});
|
|
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
|
+
}
|
|
40
50
|
}
|
|
41
51
|
import { loadAccounts, type QwenAccount } from "../core/accounts.ts";
|
|
42
52
|
// Imported here rather than injected from session-keeper.ts: account-concurrency
|