qwenproxy-cli 1.4.0 → 1.4.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/login.js CHANGED
@@ -1085,6 +1085,8 @@ __export(config_exports, {
1085
1085
  normalizeChatMode: () => normalizeChatMode,
1086
1086
  setRuntimeChatMode: () => setRuntimeChatMode
1087
1087
  });
1088
+ import fs6 from "node:fs";
1089
+ import dotenv from "dotenv";
1088
1090
  import { z } from "zod";
1089
1091
  function isStatelessChatMode(mode) {
1090
1092
  if (!mode) return false;
@@ -1134,6 +1136,15 @@ var envSchema, env, config;
1134
1136
  var init_config = __esm({
1135
1137
  "src/core/config.ts"() {
1136
1138
  "use strict";
1139
+ init_paths();
1140
+ if (!isRunningUnderNodeTest()) {
1141
+ const envPath = getEnvFilePath();
1142
+ if (fs6.existsSync(envPath)) {
1143
+ dotenv.config({ path: envPath, quiet: true });
1144
+ } else {
1145
+ dotenv.config({ quiet: true });
1146
+ }
1147
+ }
1137
1148
  envSchema = z.object({
1138
1149
  PORT: z.string().regex(/^\d+$/, "PORT must be a number").refine((value) => {
1139
1150
  const port = Number(value);
@@ -2918,7 +2929,7 @@ __export(clean_cache_exports, {
2918
2929
  getDirStats: () => getDirStats
2919
2930
  });
2920
2931
  import "dotenv/config";
2921
- import fs6 from "node:fs";
2932
+ import fs7 from "node:fs";
2922
2933
  import path4 from "node:path";
2923
2934
  import os3 from "node:os";
2924
2935
  import { chromium } from "patchright";
@@ -2933,14 +2944,14 @@ function getDirStats(dir) {
2933
2944
  let files = 0;
2934
2945
  function walk(d) {
2935
2946
  try {
2936
- const entries = fs6.readdirSync(d, { withFileTypes: true });
2947
+ const entries = fs7.readdirSync(d, { withFileTypes: true });
2937
2948
  for (const e of entries) {
2938
2949
  const full = path4.join(d, e.name);
2939
2950
  if (e.isDirectory()) {
2940
2951
  walk(full);
2941
2952
  } else if (e.isFile()) {
2942
2953
  try {
2943
- bytes += fs6.statSync(full).size;
2954
+ bytes += fs7.statSync(full).size;
2944
2955
  files++;
2945
2956
  } catch {
2946
2957
  }
@@ -2969,17 +2980,17 @@ async function cleanPlaywrightBrowsers(cleanUnused) {
2969
2980
  }
2970
2981
  } catch {
2971
2982
  }
2972
- if (!msPlaywrightDir || !fs6.existsSync(msPlaywrightDir)) {
2983
+ if (!msPlaywrightDir || !fs7.existsSync(msPlaywrightDir)) {
2973
2984
  const defaultPlaywrightDir = process.env.PLAYWRIGHT_BROWSERS_PATH || (process.platform === "win32" ? path4.join(os3.homedir(), "AppData", "Local", "ms-playwright") : process.platform === "darwin" ? path4.join(os3.homedir(), "Library", "Caches", "ms-playwright") : path4.join(os3.homedir(), ".cache", "ms-playwright"));
2974
- if (fs6.existsSync(defaultPlaywrightDir)) {
2985
+ if (fs7.existsSync(defaultPlaywrightDir)) {
2975
2986
  msPlaywrightDir = defaultPlaywrightDir;
2976
2987
  }
2977
2988
  }
2978
2989
  const unusedDirs = [];
2979
2990
  let freedBytes = 0;
2980
- if (msPlaywrightDir && fs6.existsSync(msPlaywrightDir)) {
2991
+ if (msPlaywrightDir && fs7.existsSync(msPlaywrightDir)) {
2981
2992
  try {
2982
- const entries = fs6.readdirSync(msPlaywrightDir, { withFileTypes: true });
2993
+ const entries = fs7.readdirSync(msPlaywrightDir, { withFileTypes: true });
2983
2994
  for (const entry of entries) {
2984
2995
  if (!entry.isDirectory()) continue;
2985
2996
  const folderName = entry.name;
@@ -3002,7 +3013,7 @@ async function cleanPlaywrightBrowsers(cleanUnused) {
3002
3013
  if (cleanUnused && unusedDirs.length > 0) {
3003
3014
  for (const item of unusedDirs) {
3004
3015
  try {
3005
- fs6.rmSync(item.path, { recursive: true, force: true });
3016
+ fs7.rmSync(item.path, { recursive: true, force: true });
3006
3017
  freedBytes += item.bytes;
3007
3018
  } catch (err) {
3008
3019
  console.warn(`[CleanCache] Warning: could not remove ${item.name}:`, err);
@@ -3138,7 +3149,7 @@ __export(playwright_exports, {
3138
3149
  });
3139
3150
  import { chromium as chromium2 } from "patchright";
3140
3151
  import path5 from "path";
3141
- import fs7 from "fs";
3152
+ import fs8 from "fs";
3142
3153
  import crypto3 from "crypto";
3143
3154
  import { spawnSync } from "child_process";
3144
3155
  import { createRequire } from "module";
@@ -3152,7 +3163,7 @@ function autoInstallPlaywrightChromium() {
3152
3163
  try {
3153
3164
  const patchrightEntry = requireLocal.resolve("patchright");
3154
3165
  const cliPath = path5.join(path5.dirname(patchrightEntry), "cli.js");
3155
- if (fs7.existsSync(cliPath)) {
3166
+ if (fs8.existsSync(cliPath)) {
3156
3167
  console.log("\u23F3 [Playwright] Navegador Chromium n\xE3o encontrado. Instalando automaticamente...");
3157
3168
  const res2 = spawnSync(process.execPath, [cliPath, "install", "chromium"], {
3158
3169
  stdio: "inherit",
@@ -3288,10 +3299,10 @@ function getStorageStatePath(accountId) {
3288
3299
  function loadStorageState(accountId) {
3289
3300
  const p1 = getStorageStatePath(accountId);
3290
3301
  const p2 = path5.join(path5.dirname(p1), `${accountId}_state.json`);
3291
- const chosenPath = fs7.existsSync(p1) ? p1 : fs7.existsSync(p2) ? p2 : void 0;
3302
+ const chosenPath = fs8.existsSync(p1) ? p1 : fs8.existsSync(p2) ? p2 : void 0;
3292
3303
  if (!chosenPath) return void 0;
3293
3304
  try {
3294
- const raw = fs7.readFileSync(chosenPath, "utf8");
3305
+ const raw = fs8.readFileSync(chosenPath, "utf8");
3295
3306
  const state = JSON.parse(raw);
3296
3307
  if (!state || typeof state !== "object" || !Array.isArray(state.cookies)) {
3297
3308
  return void 0;
@@ -3305,8 +3316,8 @@ async function saveStorageState(context, accountId, timeoutMs = 5e3) {
3305
3316
  try {
3306
3317
  const stateFile = getStorageStatePath(accountId);
3307
3318
  const dir = path5.dirname(stateFile);
3308
- if (!fs7.existsSync(dir)) {
3309
- fs7.mkdirSync(dir, { recursive: true });
3319
+ if (!fs8.existsSync(dir)) {
3320
+ fs8.mkdirSync(dir, { recursive: true });
3310
3321
  }
3311
3322
  await withTimeout(
3312
3323
  context.storageState({ path: stateFile }),
@@ -3415,7 +3426,7 @@ async function isPageLoggedIn(page, timeoutMs = SESSION_PROBE_NAVIGATION_TIMEOUT
3415
3426
  return false;
3416
3427
  }
3417
3428
  }
3418
- async function getOrLaunchSharedBrowser(browserType = "chromium", headless = true) {
3429
+ async function getOrLaunchSharedBrowser(browserType = "chromium", headless = config.playwright.headless) {
3419
3430
  if (sharedBrowser && sharedBrowser.isConnected()) {
3420
3431
  return sharedBrowser;
3421
3432
  }
@@ -3475,13 +3486,40 @@ async function getOrLaunchSharedBrowser(browserType = "chromium", headless = tru
3475
3486
  }
3476
3487
  }
3477
3488
  async function clearVisibleChallenge(page) {
3478
- if (!config.captcha.enabled) return;
3479
- await solveBaxiaCaptcha(page, {
3480
- waitForMs: 0,
3481
- maxAttempts: config.captcha.maxAttempts,
3482
- retryDelayMs: config.captcha.retryDelayMs,
3483
- settleMs: config.captcha.settleMs
3484
- }).catch(() => false);
3489
+ if (page.isClosed()) return;
3490
+ if (config.captcha.enabled) {
3491
+ await solveBaxiaCaptcha(page, {
3492
+ waitForMs: 0,
3493
+ maxAttempts: config.captcha.maxAttempts,
3494
+ retryDelayMs: config.captcha.retryDelayMs,
3495
+ settleMs: config.captcha.settleMs
3496
+ }).catch(() => false);
3497
+ }
3498
+ try {
3499
+ const modalCloseSelectors = [
3500
+ ".ant-modal-close",
3501
+ ".ant-modal-close-x",
3502
+ "button.ant-modal-close",
3503
+ "button[aria-label*='Close' i]",
3504
+ "button[aria-label*='Fechar' i]",
3505
+ ".index-module__whats-new-modal-close",
3506
+ "button:has-text('Cancel')",
3507
+ "button:has-text('Cancelar')",
3508
+ "button:has-text('I understand')",
3509
+ "button:has-text('Entendi')",
3510
+ "button:has-text('OK')"
3511
+ ];
3512
+ for (const sel of modalCloseSelectors) {
3513
+ if (page.isClosed()) return;
3514
+ const btn = page.locator(sel).first();
3515
+ if (await btn.isVisible({ timeout: 150 }).catch(() => false)) {
3516
+ await btn.click({ timeout: 500 }).catch(() => {
3517
+ });
3518
+ await sleep2(200);
3519
+ }
3520
+ }
3521
+ } catch {
3522
+ }
3485
3523
  }
3486
3524
  function getErrorMessage(error) {
3487
3525
  return error instanceof Error ? error.message : String(error);
@@ -3909,6 +3947,21 @@ function getStealthScript(profile) {
3909
3947
  spoofedFunctions.add(window.performance.getEntriesByType);
3910
3948
  }
3911
3949
  } catch(e) {}
3950
+
3951
+ // --- Auto-resolve birthday compliance & eliminate false logout markers ---
3952
+ try {
3953
+ localStorage.removeItem("qwen_token_logged_out_marker");
3954
+ const b = localStorage.getItem("qwen_account_birthday");
3955
+ if (b) {
3956
+ try {
3957
+ const parsed = JSON.parse(b);
3958
+ if (!parsed.birthday) {
3959
+ parsed.birthday = "1995-06-15";
3960
+ localStorage.setItem("qwen_account_birthday", JSON.stringify(parsed));
3961
+ }
3962
+ } catch {}
3963
+ }
3964
+ } catch(e) {}
3912
3965
  })();
3913
3966
  `;
3914
3967
  }
@@ -4207,7 +4260,7 @@ async function resolveAccountCredentials(account) {
4207
4260
  }
4208
4261
  return account;
4209
4262
  }
4210
- async function initPlaywrightForAccount(rawAccount, headless = true, browserType = "chromium", options = {}) {
4263
+ async function initPlaywrightForAccount(rawAccount, headless = config.playwright.headless, browserType = "chromium", options = {}) {
4211
4264
  const account = await resolveAccountCredentials(rawAccount);
4212
4265
  if (accountPages.has(account.id)) {
4213
4266
  console.log(
@@ -4333,7 +4386,7 @@ async function initPlaywrightForAccount(rawAccount, headless = true, browserType
4333
4386
  const storageState = loadStorageState(account.id);
4334
4387
  if (storageState) {
4335
4388
  try {
4336
- const raw = fs7.readFileSync(storageState, "utf8");
4389
+ const raw = fs8.readFileSync(storageState, "utf8");
4337
4390
  const parsed = JSON.parse(raw);
4338
4391
  if (Array.isArray(parsed.cookies) && parsed.cookies.length > 0) {
4339
4392
  const currentCookies = await acctContext.cookies();
@@ -4420,11 +4473,19 @@ async function initPlaywrightForAccount(rawAccount, headless = true, browserType
4420
4473
  }
4421
4474
  if (restoredFromDb) {
4422
4475
  if (!acctPage.isClosed() && (acctPage.url() === "about:blank" || !acctPage.url().startsWith(qwenOrigin()))) {
4423
- void acctPage.goto(qwenUrl("/"), {
4424
- waitUntil: "domcontentloaded",
4425
- timeout: config.timeouts.navigation
4426
- }).catch(() => {
4427
- });
4476
+ try {
4477
+ await acctPage.goto(qwenUrl("/"), {
4478
+ waitUntil: "domcontentloaded",
4479
+ timeout: config.timeouts.navigation
4480
+ });
4481
+ await sleep2(300);
4482
+ } catch (err) {
4483
+ if (!err?.message?.includes("ERR_ABORTED")) {
4484
+ console.warn(
4485
+ `\u26A0\uFE0F [Playwright] Background navigation warning for ${maskEmail(account.email)}: ${err.message}`
4486
+ );
4487
+ }
4488
+ }
4428
4489
  }
4429
4490
  return;
4430
4491
  }
@@ -4545,7 +4606,7 @@ async function validateAccountLogin(rawAccount, headless = true, browserType = "
4545
4606
  const storageState = loadStorageState(account.id);
4546
4607
  if (storageState) {
4547
4608
  try {
4548
- const raw = fs7.readFileSync(storageState, "utf8");
4609
+ const raw = fs8.readFileSync(storageState, "utf8");
4549
4610
  const parsed = JSON.parse(raw);
4550
4611
  if (Array.isArray(parsed.cookies) && parsed.cookies.length > 0) {
4551
4612
  const currentCookies = await acctContext.cookies();
@@ -4664,18 +4725,34 @@ async function loginToQwen(accountId, email, password) {
4664
4725
  const apiResult = await loginViaApi(page, email, password);
4665
4726
  if (apiResult.success) {
4666
4727
  cookieCaches.delete(accountId);
4667
- const cache = headerCaches.get(accountId);
4668
- if (cache) {
4669
- cache.headers = {};
4670
- cache.lastRefresh = 0;
4671
- }
4672
- unmarkAccountHeadersReady(accountId);
4728
+ await saveStorageState(page.context(), accountId);
4673
4729
  try {
4674
- const { deleteAuthSession: deleteAuthSession2 } = await Promise.resolve().then(() => (init_database(), database_exports));
4675
- deleteAuthSession2(accountId);
4730
+ const liveCookies = await page.context().cookies();
4731
+ const tokenCookie = liveCookies.find((c) => c.name === "token");
4732
+ if (tokenCookie) {
4733
+ const cookieStr = liveCookies.map((c) => `${c.name}=${c.value}`).join("; ");
4734
+ const cache = getHeaderCache(accountId);
4735
+ cache.headers.cookie = cookieStr;
4736
+ cache.lastRefresh = Date.now();
4737
+ markAccountHeadersReady(accountId);
4738
+ const { saveAuthSession: saveAuthSession2 } = await Promise.resolve().then(() => (init_database(), database_exports));
4739
+ const exp = parseJwtExpiry(tokenCookie.value);
4740
+ saveAuthSession2(accountId, {
4741
+ cookie: cookieStr,
4742
+ userAgent: cache.headers["user-agent"] || "",
4743
+ bxV: cache.headers["bx-v"] || "2.5.37",
4744
+ bxUa: cache.headers["bx-ua"] || "",
4745
+ bxUmidtoken: cache.headers["bx-umidtoken"] || "",
4746
+ secChUa: cache.headers["sec-ch-ua"] || void 0,
4747
+ secChUaMobile: cache.headers["sec-ch-ua-mobile"] || void 0,
4748
+ secChUaPlatform: cache.headers["sec-ch-ua-platform"] || void 0,
4749
+ version: cache.headers["version"] || void 0,
4750
+ tokenExpiresAt: exp || void 0,
4751
+ capturedAt: Date.now()
4752
+ });
4753
+ }
4676
4754
  } catch {
4677
4755
  }
4678
- await saveStorageState(page.context(), accountId);
4679
4756
  return true;
4680
4757
  }
4681
4758
  if (apiResult.permanentFailure) {
@@ -4692,18 +4769,34 @@ async function loginToQwen(accountId, email, password) {
4692
4769
  const uiResult = await loginViaUi(page, email, password);
4693
4770
  if (uiResult.success) {
4694
4771
  cookieCaches.delete(accountId);
4695
- const cache = headerCaches.get(accountId);
4696
- if (cache) {
4697
- cache.headers = {};
4698
- cache.lastRefresh = 0;
4699
- }
4700
- unmarkAccountHeadersReady(accountId);
4772
+ await saveStorageState(page.context(), accountId);
4701
4773
  try {
4702
- const { deleteAuthSession: deleteAuthSession2 } = await Promise.resolve().then(() => (init_database(), database_exports));
4703
- deleteAuthSession2(accountId);
4774
+ const liveCookies = await page.context().cookies();
4775
+ const tokenCookie = liveCookies.find((c) => c.name === "token");
4776
+ if (tokenCookie) {
4777
+ const cookieStr = liveCookies.map((c) => `${c.name}=${c.value}`).join("; ");
4778
+ const cache = getHeaderCache(accountId);
4779
+ cache.headers.cookie = cookieStr;
4780
+ cache.lastRefresh = Date.now();
4781
+ markAccountHeadersReady(accountId);
4782
+ const { saveAuthSession: saveAuthSession2 } = await Promise.resolve().then(() => (init_database(), database_exports));
4783
+ const exp = parseJwtExpiry(tokenCookie.value);
4784
+ saveAuthSession2(accountId, {
4785
+ cookie: cookieStr,
4786
+ userAgent: cache.headers["user-agent"] || "",
4787
+ bxV: cache.headers["bx-v"] || "2.5.37",
4788
+ bxUa: cache.headers["bx-ua"] || "",
4789
+ bxUmidtoken: cache.headers["bx-umidtoken"] || "",
4790
+ secChUa: cache.headers["sec-ch-ua"] || void 0,
4791
+ secChUaMobile: cache.headers["sec-ch-ua-mobile"] || void 0,
4792
+ secChUaPlatform: cache.headers["sec-ch-ua-platform"] || void 0,
4793
+ version: cache.headers["version"] || void 0,
4794
+ tokenExpiresAt: exp || void 0,
4795
+ capturedAt: Date.now()
4796
+ });
4797
+ }
4704
4798
  } catch {
4705
4799
  }
4706
- await saveStorageState(page.context(), accountId);
4707
4800
  return true;
4708
4801
  }
4709
4802
  if (uiResult.permanentFailure) {
@@ -4902,10 +4995,16 @@ async function loginViaUi(page, email, password) {
4902
4995
  );
4903
4996
  return { success: false, reason: "Campo de e-mail n\xE3o encontrado (poss\xEDvel captcha)" };
4904
4997
  }
4998
+ await clearVisibleChallenge(page);
4999
+ const findPasswordModeButton = () => {
5000
+ return page.locator('button, [role="button"], a, div').filter({
5001
+ hasText: /(?:log\s*in\s*with\s*(?:a\s*)?password|fazer\s*login\s*com\s*senha|entrar\s*com\s*(?:uma\s*)?senha|iniciar\s*sesi[oó]n\s*con\s*contrase[nñ]a|密码登录)/i
5002
+ }).first();
5003
+ };
4905
5004
  try {
4906
- const pwdModeBtn = page.getByText(/Log in with a password/i).first();
4907
- if (await pwdModeBtn.isVisible({ timeout: 1500 }).catch(() => false)) {
4908
- await pwdModeBtn.click().catch(() => {
5005
+ const pwdModeBtn = findPasswordModeButton();
5006
+ if (await pwdModeBtn.isVisible({ timeout: 2e3 }).catch(() => false)) {
5007
+ await pwdModeBtn.click({ timeout: 2e3 }).catch(() => {
4909
5008
  });
4910
5009
  await sleep2(500);
4911
5010
  }
@@ -4914,9 +5013,9 @@ async function loginViaUi(page, email, password) {
4914
5013
  await page.fill(emailSelector, email);
4915
5014
  await sleep2(300);
4916
5015
  try {
4917
- const pwdModeBtn = page.getByText(/Log in with a password/i).first();
4918
- if (await pwdModeBtn.isVisible({ timeout: 1e3 }).catch(() => false)) {
4919
- await pwdModeBtn.click().catch(() => {
5016
+ const pwdModeBtn = findPasswordModeButton();
5017
+ if (await pwdModeBtn.isVisible({ timeout: 1500 }).catch(() => false)) {
5018
+ await pwdModeBtn.click({ timeout: 2e3 }).catch(() => {
4920
5019
  });
4921
5020
  await sleep2(500);
4922
5021
  }
@@ -4941,7 +5040,7 @@ async function loginViaUi(page, email, password) {
4941
5040
  }
4942
5041
  await page.fill(passwordSelector, password);
4943
5042
  await sleep2(500);
4944
- const submitSelector = 'button.qwenchat-auth-pc-submit-button, button[type="submit"], button:has-text("Log in"), button:has-text("Sign in")';
5043
+ const submitSelector = 'button.qwenchat-auth-pc-submit-button, button[type="submit"], button:has-text("Log in"), button:has-text("Sign in"), button:has-text("Fazer login"), button:has-text("Entrar"), button:has-text("Iniciar sesi\xF3n"), button:has-text("\u767B\u5F55")';
4945
5044
  const submitButton = page.locator(submitSelector).first();
4946
5045
  try {
4947
5046
  await page.waitForSelector('button[type="submit"]:not([disabled])', {
@@ -5546,7 +5645,7 @@ async function refreshHeadersInternal(accountId, timeoutMs = config.timeouts.hea
5546
5645
  await executeReauth();
5547
5646
  }
5548
5647
  }
5549
- if (reauthExecuted && hasRequiredQwenHeaders(cache.headers)) {
5648
+ if (hasRequiredQwenHeaders(cache.headers)) {
5550
5649
  const liveCookies = await page.context().cookies();
5551
5650
  if (liveCookies.some((c) => c.name === "token")) {
5552
5651
  const cookieStr = liveCookies.map((c) => `${c.name}=${c.value}`).join("; ");
@@ -5662,12 +5761,12 @@ async function resetPlaywrightProfileLocked(accountId) {
5662
5761
  removePlaywrightProfile(profilePath);
5663
5762
  const stateFile2 = path5.join(path5.dirname(profilePath), `${accountId}_state.json`);
5664
5763
  try {
5665
- fs7.rmSync(stateFile2, { force: true });
5764
+ fs8.rmSync(stateFile2, { force: true });
5666
5765
  } catch {
5667
5766
  }
5668
5767
  }
5669
5768
  function removePlaywrightProfile(profilePath, rmSyncOverride) {
5670
- const doRemove = rmSyncOverride ?? ((p, opts) => fs7.rmSync(p, opts));
5769
+ const doRemove = rmSyncOverride ?? ((p, opts) => fs8.rmSync(p, opts));
5671
5770
  try {
5672
5771
  doRemove(profilePath, { recursive: true, force: true });
5673
5772
  } catch (error) {
@@ -5676,7 +5775,7 @@ function removePlaywrightProfile(profilePath, rmSyncOverride) {
5676
5775
  if (message.includes("EPERM") || message.includes("EBUSY") || message.includes("Permission denied")) {
5677
5776
  try {
5678
5777
  const stalePath = `${profilePath}.stale-${Date.now()}`;
5679
- fs7.renameSync(profilePath, stalePath);
5778
+ fs8.renameSync(profilePath, stalePath);
5680
5779
  } catch {
5681
5780
  }
5682
5781
  return;
@@ -5699,23 +5798,23 @@ function prunePlaywrightProfileCaches(profilePath) {
5699
5798
  let freedFiles = 0;
5700
5799
  try {
5701
5800
  const defaultDir = path5.join(profilePath, "Default");
5702
- if (!fs7.existsSync(defaultDir)) {
5801
+ if (!fs8.existsSync(defaultDir)) {
5703
5802
  return { freedBytes, freedFiles };
5704
5803
  }
5705
5804
  for (const dirName of transientDirNames) {
5706
5805
  const targetDir = path5.join(defaultDir, dirName);
5707
- if (fs7.existsSync(targetDir)) {
5806
+ if (fs8.existsSync(targetDir)) {
5708
5807
  try {
5709
5808
  const countAndRemove = (d) => {
5710
5809
  try {
5711
- const entries = fs7.readdirSync(d, { withFileTypes: true });
5810
+ const entries = fs8.readdirSync(d, { withFileTypes: true });
5712
5811
  for (const e of entries) {
5713
5812
  const full = path5.join(d, e.name);
5714
5813
  if (e.isDirectory()) {
5715
5814
  countAndRemove(full);
5716
5815
  } else if (e.isFile()) {
5717
5816
  try {
5718
- freedBytes += fs7.statSync(full).size;
5817
+ freedBytes += fs8.statSync(full).size;
5719
5818
  freedFiles++;
5720
5819
  } catch {
5721
5820
  }
@@ -5725,7 +5824,7 @@ function prunePlaywrightProfileCaches(profilePath) {
5725
5824
  }
5726
5825
  };
5727
5826
  countAndRemove(targetDir);
5728
- fs7.rmSync(targetDir, { recursive: true, force: true });
5827
+ fs8.rmSync(targetDir, { recursive: true, force: true });
5729
5828
  } catch {
5730
5829
  }
5731
5830
  }
@@ -5739,10 +5838,10 @@ function pruneAllPlaywrightProfiles(baseDir = getProfilesDir()) {
5739
5838
  let totalFreedFiles = 0;
5740
5839
  let profilesCleaned = 0;
5741
5840
  try {
5742
- if (!fs7.existsSync(baseDir)) {
5841
+ if (!fs8.existsSync(baseDir)) {
5743
5842
  return { totalFreedBytes, totalFreedFiles, profilesCleaned };
5744
5843
  }
5745
- const entries = fs7.readdirSync(baseDir, { withFileTypes: true });
5844
+ const entries = fs8.readdirSync(baseDir, { withFileTypes: true });
5746
5845
  for (const entry of entries) {
5747
5846
  if (entry.isDirectory()) {
5748
5847
  const profilePath = path5.join(baseDir, entry.name);
@@ -5762,11 +5861,11 @@ function cleanupOrphanProfiles(baseDir = getProfilesDir(), activeAccountIds) {
5762
5861
  let removedCount = 0;
5763
5862
  let freedBytes = 0;
5764
5863
  try {
5765
- if (!fs7.existsSync(baseDir)) {
5864
+ if (!fs8.existsSync(baseDir)) {
5766
5865
  return { removedCount, freedBytes };
5767
5866
  }
5768
5867
  const activeIds = activeAccountIds ?? new Set(loadAccounts().map((a) => a.id));
5769
- const entries = fs7.readdirSync(baseDir, { withFileTypes: true });
5868
+ const entries = fs8.readdirSync(baseDir, { withFileTypes: true });
5770
5869
  for (const entry of entries) {
5771
5870
  if (!entry.isDirectory()) continue;
5772
5871
  const isStale = entry.name.includes(".stale-");
@@ -5777,13 +5876,13 @@ function cleanupOrphanProfiles(baseDir = getProfilesDir(), activeAccountIds) {
5777
5876
  let bytes = 0;
5778
5877
  const countSize = (d) => {
5779
5878
  try {
5780
- const subEntries = fs7.readdirSync(d, { withFileTypes: true });
5879
+ const subEntries = fs8.readdirSync(d, { withFileTypes: true });
5781
5880
  for (const e of subEntries) {
5782
5881
  const full = path5.join(d, e.name);
5783
5882
  if (e.isDirectory()) countSize(full);
5784
5883
  else if (e.isFile()) {
5785
5884
  try {
5786
- bytes += fs7.statSync(full).size;
5885
+ bytes += fs8.statSync(full).size;
5787
5886
  } catch {
5788
5887
  }
5789
5888
  }
@@ -5793,7 +5892,7 @@ function cleanupOrphanProfiles(baseDir = getProfilesDir(), activeAccountIds) {
5793
5892
  };
5794
5893
  countSize(targetPath);
5795
5894
  removePlaywrightProfile(targetPath);
5796
- if (!fs7.existsSync(targetPath)) {
5895
+ if (!fs8.existsSync(targetPath)) {
5797
5896
  removedCount++;
5798
5897
  freedBytes += bytes;
5799
5898
  }
@@ -6252,8 +6351,8 @@ init_accounts();
6252
6351
  init_logger();
6253
6352
  import crypto4 from "crypto";
6254
6353
  import * as readline from "readline";
6255
- import * as dotenv from "dotenv";
6256
- dotenv.config();
6354
+ import * as dotenv2 from "dotenv";
6355
+ dotenv2.config();
6257
6356
  var rl = readline.createInterface({
6258
6357
  input: process.stdin,
6259
6358
  output: process.stdout