@ada-mcp/mcp-server 0.1.13 → 0.1.15

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.
Files changed (3) hide show
  1. package/README.md +139 -139
  2. package/dist/cli.cjs +500 -176
  3. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -2728,16 +2728,16 @@ var init_src = __esm({
2728
2728
  }
2729
2729
  });
2730
2730
 
2731
- // ../ada-agent/dist/bundled-config.generated.js
2731
+ // ../ada-agent/src/bundled-config.generated.ts
2732
2732
  var bundledDefaultConfigYaml;
2733
2733
  var init_bundled_config_generated = __esm({
2734
- "../ada-agent/dist/bundled-config.generated.js"() {
2734
+ "../ada-agent/src/bundled-config.generated.ts"() {
2735
2735
  "use strict";
2736
2736
  bundledDefaultConfigYaml = 'agent:\r\n id: "ada-agent-local"\r\n mode: "foreground"\r\n setupOnFirstRun: true\r\n\r\nbootstrapUI:\r\n enabled: true\r\n mode: "auto" # auto | cli | gui\r\n host: "127.0.0.1"\r\n port: 17650\r\n autoOpenBrowser: true\r\n sessionTtlSec: 600\r\n secretsProvider: "auto" # auto | keychain | credman | file\r\n native:\r\n enabled: false\r\n command: "" # e.g. ./bootstrap-ui / .\\bootstrap-ui.exe\r\n args: []\r\n timeoutMs: 120000\r\n fallbackToWeb: true\r\n\r\ntransport:\r\n mode: "auto"\r\n streamProtocol: "websocket"\r\n requestPath: "/api/v1/execute"\r\n healthPath: "/health"\r\n streamPath: "/ws"\r\n requestTimeoutMs: 15000\r\n\r\ngraphics:\r\n enabled: false\r\n fallbackOnSemanticFailure: false\r\n minConfidence: 0.8\r\n\r\nmonitoring:\r\n enabled: false\r\n platforms: ["web", "android", "ios", "harmony"] # \u53EF\u9009\u5B50\u96C6\r\n sampleEvery: 1 # \u6BCF N \u6761\u64CD\u4F5C\u91C7\u6837\u4E00\u6B21\uFF0C1 \u8868\u793A\u5168\u91CF\r\n outputDir: "artifacts/monitoring"\r\n onFailureOnly: false # true \u65F6\u4EC5\u5931\u8D25\u64CD\u4F5C\u6293\u56FE\uFF0C\u6027\u80FD\u66F4\u4F18\r\n groupBySession: true # \u6309 sessionId/requestId \u5206\u5C42\u5F52\u6863\r\n nonBlocking: true # true \u65F6\u76D1\u63A7\u5F02\u6B65\u6267\u884C\uFF0C\u4E0D\u963B\u585E\u4E3B\u94FE\u8DEF\r\n resolution:\r\n maxWidth: 1280\r\n maxHeight: 720\r\n keepAspectRatio: true # \u4FDD\u6301\u6BD4\u4F8B\uFF0C\u907F\u514D\u76D1\u63A7\u56FE\u50CF\u53D8\u5F62\r\n\r\nqueue:\r\n inboxDir: "tasks/inbox"\r\n processedDir: "tasks/processed"\r\n failedDir: "tasks/failed"\r\n pollIntervalMs: 3000\r\n maxFileRetryAttempts: 2\r\n\r\ndependencies:\r\n autoInstallOnStart: true\r\n playwrightBrowser: "chromium" # chromium | firefox | webkit | all\r\n playwrightInstallTargets: ["chromium"] # chromium | chrome | msedge | firefox | webkit | all\r\n playwrightDownloadHost: "https://cdn.playwright.dev"\r\n # \u56FD\u5185 npm \u955C\u50CF\uFF08\u6309\u4F18\u5148\u7EA7\uFF1Binstall-deps \u542F\u52A8\u65F6\u6D4B\u901F\u9009\u6700\u5FEB\uFF0C\u65E0\u9700\u7528\u6237\u914D\u7F6E\uFF09\r\n npmRegistryCandidates:\r\n - "https://registry.npmmirror.com" # \u963F\u91CC\u4E91 / npmmirror\uFF08\u63A8\u8350\uFF09\r\n - "https://mirrors.cloud.tencent.com/npm" # \u817E\u8BAF\u4E91\r\n - "https://repo.huaweicloud.com/repository/npm" # \u534E\u4E3A\u4E91\r\n - "https://registry.npmjs.org" # \u5B98\u65B9\u515C\u5E95\r\n playwrightHostCandidates:\r\n - "https://cdn.playwright.dev"\r\n - "https://playwright.azureedge.net"\r\n - "https://npmmirror.com/mirrors/playwright"\r\n - "https://cdn.npmmirror.com/binaries/playwright"\r\n # \u539F\u751F WebDriver\uFF08geckodriver / chromedriver\uFF09\u7EDF\u4E00\u653E\u5728\u9879\u76EE dirver \u76EE\u5F55\r\n nativeDriversDir: "dirver"\r\n geckodriverVersion: "latest" # \u5982 0.36.0\uFF1Binstall-deps --only=selenium \u65F6\u4E0B\u8F7D\u5230\u6B64\u76EE\u5F55\r\n chromedriverVersion: "latest" # \u5982 137\u3001135\u3001match-chrome\uFF08\u5339\u914D\u672C\u673A Chrome \u4E3B\u7248\u672C\uFF09\r\n\r\nappium:\r\n serverUrl: "http://127.0.0.1:4723"\r\n requiredDrivers: ["uiautomator2", "xcuitest", "harmonyos"]\r\n';
2737
2737
  }
2738
2738
  });
2739
2739
 
2740
- // ../ada-agent/dist/config.js
2740
+ // ../ada-agent/src/config.ts
2741
2741
  function mergeConfig(base, overrides) {
2742
2742
  return {
2743
2743
  ...base,
@@ -2803,10 +2803,9 @@ function maskToken(token) {
2803
2803
  }
2804
2804
  var import_promises2, import_node_path2, DEFAULT_CONFIG_RELATIVE, LOCAL_DATA_DIR, EFFECTIVE_CONFIG_FILE, defaultConfig;
2805
2805
  var init_config = __esm({
2806
- "../ada-agent/dist/config.js"() {
2807
- "use strict";
2808
- import_promises2 = __toESM(require("node:fs/promises"), 1);
2809
- import_node_path2 = __toESM(require("node:path"), 1);
2806
+ "../ada-agent/src/config.ts"() {
2807
+ import_promises2 = __toESM(require("node:fs/promises"));
2808
+ import_node_path2 = __toESM(require("node:path"));
2810
2809
  init_js_yaml();
2811
2810
  init_src();
2812
2811
  init_bundled_config_generated();
@@ -2888,7 +2887,7 @@ var init_config = __esm({
2888
2887
  ],
2889
2888
  nativeDriversDir: "dirver",
2890
2889
  geckodriverVersion: "latest",
2891
- chromedriverVersion: "latest"
2890
+ chromedriverVersion: "match-chrome"
2892
2891
  },
2893
2892
  appium: {
2894
2893
  serverUrl: "http://127.0.0.1:4723",
@@ -2898,7 +2897,7 @@ var init_config = __esm({
2898
2897
  }
2899
2898
  });
2900
2899
 
2901
- // ../ada-agent/dist/secrets.js
2900
+ // ../ada-agent/src/secrets.ts
2902
2901
  function resolveProvider(provider) {
2903
2902
  if (provider === "keychain" || provider === "credman") {
2904
2903
  return "file";
@@ -2930,23 +2929,21 @@ async function loadSecret(provider, cwd = process.cwd()) {
2930
2929
  }
2931
2930
  var import_promises3, import_node_path3, SECRET_FILE;
2932
2931
  var init_secrets = __esm({
2933
- "../ada-agent/dist/secrets.js"() {
2934
- "use strict";
2935
- import_promises3 = __toESM(require("node:fs/promises"), 1);
2936
- import_node_path3 = __toESM(require("node:path"), 1);
2932
+ "../ada-agent/src/secrets.ts"() {
2933
+ import_promises3 = __toESM(require("node:fs/promises"));
2934
+ import_node_path3 = __toESM(require("node:path"));
2937
2935
  init_config();
2938
2936
  SECRET_FILE = "secrets.json";
2939
2937
  }
2940
2938
  });
2941
2939
 
2942
- // ../ada-agent/dist/logger.js
2940
+ // ../ada-agent/src/logger.ts
2943
2941
  function log(level, payload) {
2944
2942
  baseLog(level, payload);
2945
2943
  }
2946
2944
  var baseLog;
2947
2945
  var init_logger = __esm({
2948
- "../ada-agent/dist/logger.js"() {
2949
- "use strict";
2946
+ "../ada-agent/src/logger.ts"() {
2950
2947
  init_src();
2951
2948
  baseLog = createJsonLogger("ada-agent");
2952
2949
  }
@@ -3280,30 +3277,171 @@ async function resolveChromedriverCfTVersion(requested) {
3280
3277
  }
3281
3278
  return hit.version;
3282
3279
  }
3283
- async function detectInstalledChromeMajorVersion() {
3284
- if (process.platform !== "win32") {
3280
+ function parseBrowserVersionString(raw) {
3281
+ const match = raw.match(/(\d+\.\d+(?:\.\d+)*(?:\.\d+)?)/);
3282
+ if (!match) {
3285
3283
  return void 0;
3286
3284
  }
3287
- const candidates = [
3288
- import_node_path4.default.join(process.env["ProgramFiles"] ?? "C:\\Program Files", "Google", "Chrome", "Application", "chrome.exe"),
3289
- import_node_path4.default.join(
3290
- process.env["ProgramFiles(x86)"] ?? "C:\\Program Files (x86)",
3291
- "Google",
3292
- "Chrome",
3293
- "Application",
3294
- "chrome.exe"
3295
- )
3296
- ];
3297
- for (const chromePath of candidates) {
3298
- if (!await fileExists(chromePath)) {
3285
+ const version = match[1];
3286
+ return { version, major: version.split(".")[0] };
3287
+ }
3288
+ async function runCommandCapture(command, args) {
3289
+ return new Promise((resolve) => {
3290
+ const child = (0, import_node_child_process.spawn)(command, args, {
3291
+ stdio: ["ignore", "pipe", "ignore"],
3292
+ shell: process.platform === "win32"
3293
+ });
3294
+ let out = "";
3295
+ child.stdout?.on("data", (chunk) => {
3296
+ out += chunk.toString("utf8");
3297
+ });
3298
+ child.on("exit", (code) => resolve(code === 0 ? out.trim() : void 0));
3299
+ child.on("error", () => resolve(void 0));
3300
+ });
3301
+ }
3302
+ async function detectChromeFromExecutable(exePath) {
3303
+ if (!await fileExists(exePath)) {
3304
+ return void 0;
3305
+ }
3306
+ if (process.platform === "win32") {
3307
+ const version = await readWindowsFileVersion(exePath);
3308
+ if (!version) {
3309
+ return void 0;
3310
+ }
3311
+ const parsed2 = parseBrowserVersionString(version);
3312
+ if (!parsed2) {
3313
+ return void 0;
3314
+ }
3315
+ return { path: exePath, version: parsed2.version, major: parsed2.major };
3316
+ }
3317
+ const out = await runCommandCapture(exePath, ["--version"]);
3318
+ if (!out) {
3319
+ return void 0;
3320
+ }
3321
+ const parsed = parseBrowserVersionString(out);
3322
+ if (!parsed) {
3323
+ return void 0;
3324
+ }
3325
+ return { path: exePath, version: parsed.version, major: parsed.major };
3326
+ }
3327
+ async function detectFirefoxFromExecutable(exePath) {
3328
+ if (!await fileExists(exePath)) {
3329
+ return void 0;
3330
+ }
3331
+ if (process.platform === "win32") {
3332
+ const version = await readWindowsFileVersion(exePath);
3333
+ if (!version) {
3334
+ return void 0;
3335
+ }
3336
+ const parsed2 = parseBrowserVersionString(version);
3337
+ if (!parsed2) {
3338
+ return void 0;
3339
+ }
3340
+ return { path: exePath, version: parsed2.version, major: parsed2.major };
3341
+ }
3342
+ const out = await runCommandCapture(exePath, ["--version"]);
3343
+ if (!out) {
3344
+ return void 0;
3345
+ }
3346
+ const parsed = parseBrowserVersionString(out);
3347
+ if (!parsed) {
3348
+ return void 0;
3349
+ }
3350
+ return { path: exePath, version: parsed.version, major: parsed.major };
3351
+ }
3352
+ async function detectLocalBrowsers() {
3353
+ const result = {};
3354
+ if (process.platform === "win32") {
3355
+ const chromeCandidates = [
3356
+ import_node_path4.default.join(process.env["ProgramFiles"] ?? "C:\\Program Files", "Google", "Chrome", "Application", "chrome.exe"),
3357
+ import_node_path4.default.join(
3358
+ process.env["ProgramFiles(x86)"] ?? "C:\\Program Files (x86)",
3359
+ "Google",
3360
+ "Chrome",
3361
+ "Application",
3362
+ "chrome.exe"
3363
+ ),
3364
+ import_node_path4.default.join(process.env["ProgramFiles"] ?? "C:\\Program Files", "Chromium", "Application", "chrome.exe")
3365
+ ];
3366
+ for (const p of chromeCandidates) {
3367
+ const hit = await detectChromeFromExecutable(p);
3368
+ if (hit) {
3369
+ result.chrome = hit;
3370
+ break;
3371
+ }
3372
+ }
3373
+ const firefoxCandidates = [
3374
+ import_node_path4.default.join(process.env["ProgramFiles"] ?? "C:\\Program Files", "Mozilla Firefox", "firefox.exe"),
3375
+ import_node_path4.default.join(
3376
+ process.env["ProgramFiles(x86)"] ?? "C:\\Program Files (x86)",
3377
+ "Mozilla Firefox",
3378
+ "firefox.exe"
3379
+ )
3380
+ ];
3381
+ for (const p of firefoxCandidates) {
3382
+ const hit = await detectFirefoxFromExecutable(p);
3383
+ if (hit) {
3384
+ result.firefox = hit;
3385
+ break;
3386
+ }
3387
+ }
3388
+ return result;
3389
+ }
3390
+ if (process.platform === "darwin") {
3391
+ const chromePaths = [
3392
+ "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
3393
+ "/Applications/Chromium.app/Contents/MacOS/Chromium"
3394
+ ];
3395
+ for (const p of chromePaths) {
3396
+ const hit = await detectChromeFromExecutable(p);
3397
+ if (hit) {
3398
+ result.chrome = hit;
3399
+ break;
3400
+ }
3401
+ }
3402
+ const firefoxPath = "/Applications/Firefox.app/Contents/MacOS/firefox";
3403
+ const ff = await detectFirefoxFromExecutable(firefoxPath);
3404
+ if (ff) {
3405
+ result.firefox = ff;
3406
+ }
3407
+ return result;
3408
+ }
3409
+ const chromeCommands = ["google-chrome-stable", "google-chrome", "chromium-browser", "chromium"];
3410
+ for (const cmd of chromeCommands) {
3411
+ if (!await commandOnPath(cmd)) {
3299
3412
  continue;
3300
3413
  }
3301
- const version = await readWindowsFileVersion(chromePath);
3302
- if (version) {
3303
- return version.split(".")[0];
3414
+ const out = await runCommandCapture(cmd, ["--version"]);
3415
+ const parsed = out ? parseBrowserVersionString(out) : void 0;
3416
+ if (parsed) {
3417
+ result.chrome = { path: cmd, version: parsed.version, major: parsed.major };
3418
+ break;
3304
3419
  }
3305
3420
  }
3306
- return void 0;
3421
+ if (await commandOnPath("firefox")) {
3422
+ const out = await runCommandCapture("firefox", ["--version"]);
3423
+ const parsed = out ? parseBrowserVersionString(out) : void 0;
3424
+ if (parsed) {
3425
+ result.firefox = { path: "firefox", version: parsed.version, major: parsed.major };
3426
+ }
3427
+ }
3428
+ return result;
3429
+ }
3430
+ function logSeleniumDriverGuidance(onLogLine) {
3431
+ onLogLine?.(
3432
+ "[selenium] \u5B89\u88C5\u524D\u4F1A\u68C0\u6D4B\u672C\u673A Chrome/Chromium \u4E0E Firefox \u7248\u672C\uFF1B\u9A71\u52A8\u653E\u5165\u9879\u76EE\u76EE\u5F55\u540E\u53EF\u81EA\u884C\u66FF\u6362\u8986\u76D6\u3002"
3433
+ );
3434
+ onLogLine?.("[selenium] \u5404\u6D4F\u89C8\u5668\u9A71\u52A8\u624B\u52A8\u4E0B\u8F7D\u53C2\u8003\uFF1A");
3435
+ for (const ref of SELENIUM_DRIVER_MANUAL_DOWNLOAD_REFERENCES) {
3436
+ onLogLine?.(`[selenium] ${ref.browser} (${ref.platforms}) \u2014 ${ref.vendor}: ${ref.url}`);
3437
+ }
3438
+ onLogLine?.(
3439
+ "[selenium] \u81EA\u52A8\u4E0B\u8F7D\u5931\u8D25\u65F6\u5C06\u8DF3\u8FC7\u5BF9\u5E94\u9A71\u52A8\u5E76\u7EE7\u7EED\uFF0C\u8BF7\u6309\u4E0A\u8868\u81EA\u884C\u4E0B\u8F7D\u540E\u653E\u5165\u9A71\u52A8\u76EE\u5F55\u6216\u914D\u7F6E PATH/ADA_GECKODRIVER_PATH/ADA_CHROMEDRIVER_PATH\u3002"
3440
+ );
3441
+ }
3442
+ async function detectInstalledChromeMajorVersion() {
3443
+ const browsers = await detectLocalBrowsers();
3444
+ return browsers.chrome?.major;
3307
3445
  }
3308
3446
  async function readWindowsFileVersion(exePath) {
3309
3447
  return new Promise((resolve) => {
@@ -3346,7 +3484,7 @@ async function downloadGeckodriver(driversDir, versionInput, onLogLine) {
3346
3484
  await import_promises4.default.mkdir(driversDir, { recursive: true });
3347
3485
  const zipPath = import_node_path4.default.join(driversDir, `_download_geckodriver_${version}.zip`);
3348
3486
  const extractDir = import_node_path4.default.join(driversDir, `_extract_geckodriver_${version}`);
3349
- onLogLine?.(`[selenium] \u4E0B\u8F7D geckodriver ${tag} \uFFFD\uFFFD?${driversDir}`);
3487
+ onLogLine?.(`[selenium] \u4E0B\u8F7D geckodriver ${tag} \u2192 ${driversDir}`);
3350
3488
  onLogLine?.(`[selenium] URL: ${url}`);
3351
3489
  await downloadToFile(url, zipPath);
3352
3490
  await import_promises4.default.rm(extractDir, { recursive: true, force: true });
@@ -3359,7 +3497,7 @@ async function downloadGeckodriver(driversDir, versionInput, onLogLine) {
3359
3497
  await copyExecutable(found, dest);
3360
3498
  await import_promises4.default.rm(zipPath, { force: true });
3361
3499
  await import_promises4.default.rm(extractDir, { recursive: true, force: true });
3362
- onLogLine?.(`[selenium] geckodriver \u5DF2\u5199\uFFFD\uFFFD? ${dest}`);
3500
+ onLogLine?.(`[selenium] geckodriver \u5DF2\u5199\u5165: ${dest}`);
3363
3501
  return { path: dest, version: tag };
3364
3502
  }
3365
3503
  async function downloadChromedriver(driversDir, versionInput, onLogLine) {
@@ -3379,7 +3517,7 @@ async function downloadChromedriver(driversDir, versionInput, onLogLine) {
3379
3517
  await import_promises4.default.mkdir(driversDir, { recursive: true });
3380
3518
  const zipPath = import_node_path4.default.join(driversDir, `_download_chromedriver_${major}.zip`);
3381
3519
  const extractDir = import_node_path4.default.join(driversDir, `_extract_chromedriver_${major}`);
3382
- onLogLine?.(`[selenium] \u4E0B\u8F7D chromedriver ${fullVersion} (\u4E3B\u7248\uFFFD\uFFFD?${major}) \uFFFD\uFFFD?${driversDir}`);
3520
+ onLogLine?.(`[selenium] \u4E0B\u8F7D chromedriver ${fullVersion} (\u4E3B\u7248\u672C ${major}) \u2192 ${driversDir}`);
3383
3521
  onLogLine?.(`[selenium] URL: ${url}`);
3384
3522
  await downloadToFile(url, zipPath);
3385
3523
  await import_promises4.default.rm(extractDir, { recursive: true, force: true });
@@ -3396,7 +3534,7 @@ async function downloadChromedriver(driversDir, versionInput, onLogLine) {
3396
3534
  }
3397
3535
  await import_promises4.default.rm(zipPath, { force: true });
3398
3536
  await import_promises4.default.rm(extractDir, { recursive: true, force: true });
3399
- onLogLine?.(`[selenium] chromedriver \u5DF2\u5199\uFFFD\uFFFD? ${destVersioned}`);
3537
+ onLogLine?.(`[selenium] chromedriver \u5DF2\u5199\u5165: ${destVersioned}`);
3400
3538
  return { path: destVersioned, version: fullVersion, major };
3401
3539
  }
3402
3540
  async function saveNativeDriverManifest(manifest, workspaceRoot) {
@@ -3406,38 +3544,91 @@ async function saveNativeDriverManifest(manifest, workspaceRoot) {
3406
3544
  const file = import_node_path4.default.join(dir, "native-drivers.json");
3407
3545
  await import_promises4.default.writeFile(file, JSON.stringify(manifest, null, 2), "utf8");
3408
3546
  }
3547
+ function resolveDefaultChromedriverVersion(requested, browsers) {
3548
+ if (requested && requested !== "latest") {
3549
+ return requested;
3550
+ }
3551
+ if (browsers.chrome?.major) {
3552
+ return "match-chrome";
3553
+ }
3554
+ return requested ?? "latest";
3555
+ }
3556
+ function formatDownloadError(error) {
3557
+ return error instanceof Error ? error.message : String(error);
3558
+ }
3409
3559
  async function ensureNativeWebDrivers(options = {}) {
3410
3560
  const root = options.workspaceRoot ?? await resolveWorkspaceRoot3();
3411
3561
  const driversDir = options.driversDir ?? await resolveNativeDriversDir(root);
3412
3562
  await import_promises4.default.mkdir(driversDir, { recursive: true });
3413
3563
  const log2 = options.onLogLine;
3564
+ logSeleniumDriverGuidance(log2);
3414
3565
  log2?.(`[selenium] \u539F\u751F\u9A71\u52A8\u76EE\u5F55: ${driversDir}`);
3566
+ const browsers = await detectLocalBrowsers();
3567
+ if (browsers.chrome) {
3568
+ log2?.(
3569
+ `[selenium] \u68C0\u6D4B\u5230\u672C\u673A Chrome/Chromium: ${browsers.chrome.version} (\u4E3B\u7248\u672C ${browsers.chrome.major}) \u2014 ${browsers.chrome.path}`
3570
+ );
3571
+ } else {
3572
+ log2?.("[selenium] \u672A\u68C0\u6D4B\u5230\u672C\u673A Chrome/Chromium\uFF08chromedriver \u5C06\u4F7F\u7528 latest \u6216\u663E\u5F0F\u6307\u5B9A\u7248\u672C\uFF09");
3573
+ }
3574
+ if (browsers.firefox) {
3575
+ log2?.(
3576
+ `[selenium] \u68C0\u6D4B\u5230\u672C\u673A Firefox: ${browsers.firefox.version} (\u4E3B\u7248\u672C ${browsers.firefox.major}) \u2014 ${browsers.firefox.path}`
3577
+ );
3578
+ } else {
3579
+ log2?.("[selenium] \u672A\u68C0\u6D4B\u5230\u672C\u673A Firefox\uFF08geckodriver \u5C06\u4F7F\u7528 latest \u6216\u663E\u5F0F\u6307\u5B9A\u7248\u672C\uFF09");
3580
+ }
3415
3581
  const localChromeVersions = await listLocalChromedriverVersions(driversDir);
3416
3582
  if (localChromeVersions.length > 0) {
3417
- log2?.(`[selenium] \u76EE\u5F55\u5185\u5DF2\uFFFD\uFFFD?chromedriver \u7248\u672C: ${localChromeVersions.join(", ")}`);
3583
+ log2?.(`[selenium] \u76EE\u5F55\u5185\u5DF2\u6709 chromedriver \u7248\u672C: ${localChromeVersions.join(", ")}`);
3584
+ }
3585
+ const chromedriverRequest = resolveDefaultChromedriverVersion(options.chromedriverVersion, browsers);
3586
+ if (chromedriverRequest === "match-chrome" && browsers.chrome) {
3587
+ log2?.(
3588
+ `[selenium] chromedriver \u5C06\u5C1D\u8BD5\u5339\u914D\u672C\u673A Chrome \u4E3B\u7248\u672C ${browsers.chrome.major}\uFF08chrome-for-testing \u76EE\u5F55\uFF09`
3589
+ );
3418
3590
  }
3419
3591
  const localGecko = await findGeckodriverInDir(driversDir, options.geckodriverVersion);
3420
3592
  const hasLocalGecko = Boolean(localGecko && await fileExists(localGecko));
3421
3593
  let geckoVersion = options.geckodriverVersion;
3422
3594
  if (options.geckodriverVersion !== "skip" && (options.force || !hasLocalGecko)) {
3423
- const downloaded = await downloadGeckodriver(driversDir, options.geckodriverVersion ?? "latest", log2);
3424
- geckoVersion = downloaded.version;
3595
+ try {
3596
+ const downloaded = await downloadGeckodriver(driversDir, options.geckodriverVersion ?? "latest", log2);
3597
+ geckoVersion = downloaded.version;
3598
+ } catch (error) {
3599
+ log2?.(`[selenium][warn] geckodriver \u81EA\u52A8\u4E0B\u8F7D\u5931\u8D25\uFF0C\u5DF2\u8DF3\u8FC7: ${formatDownloadError(error)}`);
3600
+ log2?.(
3601
+ "[selenium][warn] \u8BF7\u5C06 geckodriver \u653E\u5165\u4E0A\u8FF0\u76EE\u5F55\u6216\u914D\u7F6E PATH / ADA_GECKODRIVER_PATH\uFF1B\u53EF\u53C2\u8003 Mozilla \u53D1\u5E03\u9875\u624B\u52A8\u4E0B\u8F7D\u3002"
3602
+ );
3603
+ }
3425
3604
  } else if (hasLocalGecko) {
3426
3605
  log2?.(`[selenium] \u590D\u7528\u5DF2\u6709 geckodriver: ${localGecko}`);
3427
3606
  }
3428
- const localChrome = await findChromedriverInDir(driversDir, options.chromedriverVersion);
3607
+ const localChrome = await findChromedriverInDir(driversDir, chromedriverRequest);
3429
3608
  const hasLocalChrome = Boolean(localChrome && await fileExists(localChrome.path));
3430
- if (options.chromedriverVersion !== "skip" && (options.force || !hasLocalChrome)) {
3431
- await downloadChromedriver(driversDir, options.chromedriverVersion ?? "latest", log2);
3609
+ if (chromedriverRequest !== "skip" && (options.force || !hasLocalChrome)) {
3610
+ try {
3611
+ await downloadChromedriver(driversDir, chromedriverRequest ?? "latest", log2);
3612
+ } catch (error) {
3613
+ log2?.(`[selenium][warn] chromedriver \u81EA\u52A8\u4E0B\u8F7D\u5931\u8D25\uFF0C\u5DF2\u8DF3\u8FC7: ${formatDownloadError(error)}`);
3614
+ if (browsers.chrome) {
3615
+ log2?.(
3616
+ `[selenium][warn] \u672C\u673A Chrome \u4E3B\u7248\u672C\u4E3A ${browsers.chrome.major}\uFF0C\u8BF7\u4E0B\u8F7D\u5339\u914D\u7248\u672C\u7684 chromedriver \u653E\u5165\u76EE\u5F55\u6216\u914D\u7F6E ADA_CHROMEDRIVER_PATH\u3002`
3617
+ );
3618
+ }
3619
+ log2?.(
3620
+ "[selenium][warn] \u53EF\u53C2\u8003 chrome-for-testing / chromedriver.storage \u624B\u52A8\u4E0B\u8F7D\uFF1B\u5DF2\u653E\u5165 dirver/ \u7684\u9A71\u52A8\u4F1A\u5728\u4E0B\u6B21\u542F\u52A8\u65F6\u81EA\u52A8\u590D\u7528\u3002"
3621
+ );
3622
+ }
3432
3623
  } else if (hasLocalChrome) {
3433
- log2?.(`[selenium] \u590D\u7528\u5DF2\u6709 chromedriver: ${localChrome.path} (\u4E3B\u7248\uFFFD\uFFFD?${localChrome.version})`);
3624
+ log2?.(`[selenium] \u590D\u7528\u5DF2\u6709 chromedriver: ${localChrome.path} (\u4E3B\u7248\u672C ${localChrome.version})`);
3434
3625
  }
3435
3626
  const resolved = await resolveNativeDrivers({
3436
3627
  driversDir,
3437
3628
  workspaceRoot: root,
3438
3629
  selection: {
3439
3630
  geckodriverVersion: geckoVersion,
3440
- chromedriverVersion: options.chromedriverVersion ?? localChrome?.version
3631
+ chromedriverVersion: chromedriverRequest ?? localChrome?.version
3441
3632
  }
3442
3633
  });
3443
3634
  await saveNativeDriverManifest(
@@ -3452,14 +3643,21 @@ async function ensureNativeWebDrivers(options = {}) {
3452
3643
  if (resolved.geckodriverPath) {
3453
3644
  process.env.ADA_GECKODRIVER_PATH = resolved.geckodriverPath;
3454
3645
  log2?.(`[selenium] \u4F7F\u7528 geckodriver: ${resolved.geckodriverPath}`);
3646
+ } else if (options.geckodriverVersion !== "skip") {
3647
+ log2?.("[selenium][warn] \u672A\u627E\u5230\u53EF\u7528 geckodriver\uFF08\u81EA\u52A8\u4E0B\u8F7D\u5DF2\u8DF3\u8FC7\u6216\u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u5B89\u88C5\uFF09");
3455
3648
  }
3456
3649
  if (resolved.chromedriverPath) {
3457
3650
  process.env.ADA_CHROMEDRIVER_PATH = resolved.chromedriverPath;
3458
3651
  log2?.(`[selenium] \u4F7F\u7528 chromedriver: ${resolved.chromedriverPath}`);
3652
+ } else if (chromedriverRequest !== "skip") {
3653
+ log2?.("[selenium][warn] \u672A\u627E\u5230\u53EF\u7528 chromedriver\uFF08\u81EA\u52A8\u4E0B\u8F7D\u5DF2\u8DF3\u8FC7\u6216\u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u5B89\u88C5\uFF09");
3654
+ }
3655
+ if (!resolved.geckodriverOk && !resolved.chromedriverOk) {
3656
+ log2?.("[selenium][warn] \u5F53\u524D\u65E0\u53EF\u7528\u539F\u751F WebDriver\uFF1BSelenium \u4EFB\u52A1\u53EF\u80FD\u5931\u8D25\uFF0C\u8BF7\u6309\u4E0A\u6587\u53C2\u8003\u5730\u5740\u81EA\u884C\u4E0B\u8F7D\u3002");
3459
3657
  }
3460
3658
  return resolved;
3461
3659
  }
3462
- var import_node_child_process, import_promises4, import_node_path4, DEFAULT_NATIVE_DRIVERS_DIR, CHROME_FOR_TESTING_JSON;
3660
+ var import_node_child_process, import_promises4, import_node_path4, DEFAULT_NATIVE_DRIVERS_DIR, CHROME_FOR_TESTING_JSON, SELENIUM_DRIVER_MANUAL_DOWNLOAD_REFERENCES;
3463
3661
  var init_src2 = __esm({
3464
3662
  "../../packages/native-drivers/src/index.ts"() {
3465
3663
  "use strict";
@@ -3468,10 +3666,48 @@ var init_src2 = __esm({
3468
3666
  import_node_path4 = __toESM(require("node:path"), 1);
3469
3667
  DEFAULT_NATIVE_DRIVERS_DIR = "dirver";
3470
3668
  CHROME_FOR_TESTING_JSON = "https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json";
3669
+ SELENIUM_DRIVER_MANUAL_DOWNLOAD_REFERENCES = [
3670
+ {
3671
+ browser: "Chrome/Chromium",
3672
+ platforms: "Windows/Linux/macOS",
3673
+ vendor: "\u8C37\u6B4C",
3674
+ url: "https://chromedriver.storage.googleapis.com/index.html"
3675
+ },
3676
+ {
3677
+ browser: "Firefox",
3678
+ platforms: "Windows/Linux/macOS",
3679
+ vendor: "Mozilla",
3680
+ url: "https://github.com/mozilla/geckodriver/releases"
3681
+ },
3682
+ {
3683
+ browser: "Edge",
3684
+ platforms: "win10",
3685
+ vendor: "\u5FAE\u8F6F",
3686
+ url: "https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/"
3687
+ },
3688
+ {
3689
+ browser: "Internet Explorer",
3690
+ platforms: "Windows",
3691
+ vendor: "Selenium \u9879\u76EE\u7EC4",
3692
+ url: "https://selenium-release.storage.googleapis.com/index.html"
3693
+ },
3694
+ {
3695
+ browser: "Safari",
3696
+ platforms: "macOS El Capitan \u53CA\u66F4\u9AD8\u7248\u672C",
3697
+ vendor: "\u82F9\u679C",
3698
+ url: "\uFF08\u7CFB\u7EDF\u5185\u7F6E\uFF0C\u65E0\u9700\u5355\u72EC\u4E0B\u8F7D\uFF09"
3699
+ },
3700
+ {
3701
+ browser: "Opera",
3702
+ platforms: "Windows/macOS/Linux",
3703
+ vendor: "Opera",
3704
+ url: "https://github.com/operasoftware/operachromiumdriver/releases"
3705
+ }
3706
+ ];
3471
3707
  }
3472
3708
  });
3473
3709
 
3474
- // ../ada-agent/dist/dependency-installer.js
3710
+ // ../ada-agent/src/dependency-installer.ts
3475
3711
  function shouldUseShell(command) {
3476
3712
  if (process.platform !== "win32") {
3477
3713
  return false;
@@ -3546,7 +3782,7 @@ function runCommand2(command, args, options) {
3546
3782
  });
3547
3783
  });
3548
3784
  }
3549
- function runCommandCapture(command, args) {
3785
+ function runCommandCapture2(command, args) {
3550
3786
  return new Promise((resolve) => {
3551
3787
  const child = (0, import_node_child_process2.spawn)(command, args, {
3552
3788
  stdio: ["ignore", "pipe", "pipe"],
@@ -3668,20 +3904,26 @@ async function ensureNodeEnvironmentForInstall(onLogLine) {
3668
3904
  const requiredNpmMajor = 10;
3669
3905
  const runtimeNode = process.versions.node;
3670
3906
  const runtimeMajor = majorOf(runtimeNode);
3671
- const nodeVersion = await runCommandCapture("node", ["-v"]);
3907
+ const nodeVersion = await runCommandCapture2("node", ["-v"]);
3672
3908
  if (nodeVersion.code === 0) {
3673
3909
  const nodeMajor = majorOf(nodeVersion.stdout);
3674
3910
  onLogLine?.(`[deps] Node \u7248\u672C\u68C0\u6D4B\uFF1A\u7CFB\u7EDF=${nodeVersion.stdout}\uFF0C\u5185\u7F6E=${runtimeNode}`);
3675
3911
  if (runtimeMajor !== null && nodeMajor !== null && nodeMajor > runtimeMajor) {
3676
- onLogLine?.(`[deps][warn] \u7CFB\u7EDF Node.js \u4E3B\u7248\u672C\uFF08${nodeMajor}\uFF09\u9AD8\u4E8E\u5185\u7F6E\u4E3B\u7248\u672C\uFF08${runtimeMajor}\uFF09\u3002\u5B89\u88C5\u5C06\u7EE7\u7EED\uFF0C\u8FD0\u884C\u65F6\u4EE5\u5185\u7F6E Node \u4E3A\u51C6\u3002`);
3912
+ onLogLine?.(
3913
+ `[deps][warn] \u7CFB\u7EDF Node.js \u4E3B\u7248\u672C\uFF08${nodeMajor}\uFF09\u9AD8\u4E8E\u5185\u7F6E\u4E3B\u7248\u672C\uFF08${runtimeMajor}\uFF09\u3002\u5B89\u88C5\u5C06\u7EE7\u7EED\uFF0C\u8FD0\u884C\u65F6\u4EE5\u5185\u7F6E Node \u4E3A\u51C6\u3002`
3914
+ );
3677
3915
  }
3678
3916
  if (nodeMajor === null || nodeMajor < requiredNodeMajor) {
3679
- onLogLine?.(`[deps][warn] \u7CFB\u7EDF Node.js \u7248\u672C\u4E3A ${nodeVersion.stdout}\uFF08\u5EFA\u8BAE >= ${requiredNodeMajor}\uFF09\uFF0C\u7EE7\u7EED\u5C1D\u8BD5\u5B89\u88C5\u3002`);
3917
+ onLogLine?.(
3918
+ `[deps][warn] \u7CFB\u7EDF Node.js \u7248\u672C\u4E3A ${nodeVersion.stdout}\uFF08\u5EFA\u8BAE >= ${requiredNodeMajor}\uFF09\uFF0C\u7EE7\u7EED\u5C1D\u8BD5\u5B89\u88C5\u3002`
3919
+ );
3680
3920
  }
3681
3921
  } else {
3682
- onLogLine?.(`[deps][warn] \u672A\u4ECE PATH \u68C0\u6D4B\u5230 node\uFF0C\u5F53\u524D\u8FD0\u884C\u65F6 Node.js=${runtimeNode}\uFF08\u53EF\u6267\u884C\u7A0B\u5E8F\u5185\u7F6E\uFF09\uFF0C\u7EE7\u7EED\u5C1D\u8BD5\u5B89\u88C5\u3002`);
3922
+ onLogLine?.(
3923
+ `[deps][warn] \u672A\u4ECE PATH \u68C0\u6D4B\u5230 node\uFF0C\u5F53\u524D\u8FD0\u884C\u65F6 Node.js=${runtimeNode}\uFF08\u53EF\u6267\u884C\u7A0B\u5E8F\u5185\u7F6E\uFF09\uFF0C\u7EE7\u7EED\u5C1D\u8BD5\u5B89\u88C5\u3002`
3924
+ );
3683
3925
  }
3684
- const npmVersion = await runCommandCapture("npm", ["-v"]);
3926
+ const npmVersion = await runCommandCapture2("npm", ["-v"]);
3685
3927
  if (npmVersion.code !== 0) {
3686
3928
  const message = "\u672A\u68C0\u6D4B\u5230\u53EF\u7528\u7684 npm\uFF08PATH \u4E2D\u4E0D\u53EF\u7528\uFF09\u3002\u8BF7\u5B89\u88C5 Node.js 22+\uFF08\u542B npm\uFF09\u5E76\u91CD\u542F\u7EC8\u7AEF\u540E\u91CD\u8BD5\u3002";
3687
3929
  onLogLine?.(`[deps] ${message}`);
@@ -3690,7 +3932,9 @@ ${npmVersion.stderr || npmVersion.stdout}`.trim());
3690
3932
  }
3691
3933
  const npmMajor = majorOf(npmVersion.stdout);
3692
3934
  if (npmMajor === null || npmMajor < requiredNpmMajor) {
3693
- onLogLine?.(`[deps][warn] \u7CFB\u7EDF npm \u7248\u672C\u4E3A ${npmVersion.stdout}\uFF08\u5EFA\u8BAE >= ${requiredNpmMajor}\uFF09\uFF0C\u7EE7\u7EED\u5C1D\u8BD5\u5B89\u88C5\u3002`);
3935
+ onLogLine?.(
3936
+ `[deps][warn] \u7CFB\u7EDF npm \u7248\u672C\u4E3A ${npmVersion.stdout}\uFF08\u5EFA\u8BAE >= ${requiredNpmMajor}\uFF09\uFF0C\u7EE7\u7EED\u5C1D\u8BD5\u5B89\u88C5\u3002`
3937
+ );
3694
3938
  }
3695
3939
  }
3696
3940
  function appiumDriverPackageName(driver) {
@@ -3732,7 +3976,7 @@ async function resolveCompatibleDriverSpecs(driver) {
3732
3976
  const preferred = driver === "uiautomator2" ? process.env.ADA_APPIUM_DRIVER_SPEC_UIAUTOMATOR2 ?? `${pkg}@2` : process.env.ADA_APPIUM_DRIVER_SPEC_XCUITEST ?? `${pkg}@7`;
3733
3977
  const fallbackRange = driver === "uiautomator2" ? process.env.ADA_APPIUM_DRIVER_RANGE_UIAUTOMATOR2 ?? "<3" : process.env.ADA_APPIUM_DRIVER_RANGE_XCUITEST ?? "<8";
3734
3978
  const specs = [preferred];
3735
- const view = await runCommandCapture("npm", ["view", `${pkg}@${fallbackRange}`, "version"]);
3979
+ const view = await runCommandCapture2("npm", ["view", `${pkg}@${fallbackRange}`, "version"]);
3736
3980
  if (view.code === 0 && view.stdout) {
3737
3981
  const version = view.stdout.trim().split(/\r?\n/).pop()?.trim();
3738
3982
  if (version) {
@@ -3814,18 +4058,19 @@ async function detectBestRegistry(config, baseProxy) {
3814
4058
  return cached;
3815
4059
  }
3816
4060
  progress("registry.probe.start", { candidates });
3817
- const probeResults = await Promise.all(candidates.map(async (candidate) => {
3818
- progress("registry.probe.try", { candidate });
3819
- const latency = await probeRegistryLatency(candidate);
3820
- progress("registry.probe.result", { candidate, latencyMs: latency });
3821
- return { candidate, latency };
3822
- }));
4061
+ const probeResults = await Promise.all(
4062
+ candidates.map(async (candidate) => {
4063
+ progress("registry.probe.try", { candidate });
4064
+ const latency = await probeRegistryLatency(candidate);
4065
+ progress("registry.probe.result", { candidate, latencyMs: latency });
4066
+ return { candidate, latency };
4067
+ })
4068
+ );
3823
4069
  let best = candidates[0] ?? normalizeRegistryUrl(baseProxy);
3824
4070
  let bestLatency = Number.POSITIVE_INFINITY;
3825
4071
  let bestPriority = Number.POSITIVE_INFINITY;
3826
4072
  for (const { candidate, latency } of probeResults) {
3827
- if (latency === null)
3828
- continue;
4073
+ if (latency === null) continue;
3829
4074
  const priority = registryPriorityIndex(candidates, candidate);
3830
4075
  if (latency < bestLatency || latency === bestLatency && priority < bestPriority) {
3831
4076
  best = candidate;
@@ -3910,20 +4155,22 @@ async function rankPlaywrightHosts(config) {
3910
4155
  const candidates = playwrightHostCandidates(config);
3911
4156
  const browserVersion = resolveChromiumBrowserVersion();
3912
4157
  progress("playwright.host.probe.start", { candidates, browserVersion: browserVersion || void 0 });
3913
- const probeResults = await Promise.all(candidates.map(async (candidate) => {
3914
- progress("playwright.host.probe.try", { candidate });
3915
- const artifactLatency = browserVersion ? await probePlaywrightBrowserArtifact(candidate, browserVersion) : null;
3916
- const rootLatency = await probePlaywrightHostLatency(candidate);
3917
- const latency = artifactLatency ?? rootLatency;
3918
- const artifactOk = artifactLatency !== null;
3919
- progress("playwright.host.probe.result", {
3920
- candidate,
3921
- latencyMs: latency,
3922
- artifactOk,
3923
- browserVersion: browserVersion || void 0
3924
- });
3925
- return { candidate, latency, artifactOk, priority: playwrightHostPriorityIndex(candidates, candidate) };
3926
- }));
4158
+ const probeResults = await Promise.all(
4159
+ candidates.map(async (candidate) => {
4160
+ progress("playwright.host.probe.try", { candidate });
4161
+ const artifactLatency = browserVersion ? await probePlaywrightBrowserArtifact(candidate, browserVersion) : null;
4162
+ const rootLatency = await probePlaywrightHostLatency(candidate);
4163
+ const latency = artifactLatency ?? rootLatency;
4164
+ const artifactOk = artifactLatency !== null;
4165
+ progress("playwright.host.probe.result", {
4166
+ candidate,
4167
+ latencyMs: latency,
4168
+ artifactOk,
4169
+ browserVersion: browserVersion || void 0
4170
+ });
4171
+ return { candidate, latency, artifactOk, priority: playwrightHostPriorityIndex(candidates, candidate) };
4172
+ })
4173
+ );
3927
4174
  const reachable = probeResults.filter((x) => x.latency !== null);
3928
4175
  const withArtifact = reachable.filter((x) => x.artifactOk);
3929
4176
  const pool = withArtifact.length > 0 ? withArtifact : reachable;
@@ -3948,7 +4195,9 @@ async function runInstallWithPriority(config, packages, onLogLine) {
3948
4195
  const npmProxy = await detectBestRegistry(config, npmProxyRegistry());
3949
4196
  const pnpmProxy = await detectBestRegistry(config, pnpmProxyRegistry());
3950
4197
  progress("packages.install.start", { packages, npmProxy, pnpmProxy });
3951
- onLogLine?.(`[deps] \u5728\u7EBF\u5B89\u88C5\u5305: ${packages.join(" ")} (registry \u63A2\u6D4B: npm=${npmProxy}, pnpm=${pnpmProxy}\uFF1B\u987A\u5E8F: pnpm -> pnpm-proxy -> npm -> npm-proxy)`);
4198
+ onLogLine?.(
4199
+ `[deps] \u5728\u7EBF\u5B89\u88C5\u5305: ${packages.join(" ")} (registry \u63A2\u6D4B: npm=${npmProxy}, pnpm=${pnpmProxy}\uFF1B\u987A\u5E8F: pnpm -> pnpm-proxy -> npm -> npm-proxy)`
4200
+ );
3952
4201
  const strategies = [
3953
4202
  {
3954
4203
  name: "pnpm",
@@ -3995,7 +4244,9 @@ async function runInstallWithPriority(config, packages, onLogLine) {
3995
4244
  });
3996
4245
  }
3997
4246
  }
3998
- throw new Error(`Dependency install failed after all strategies: ${lastError instanceof Error ? lastError.message : String(lastError)}`);
4247
+ throw new Error(
4248
+ `Dependency install failed after all strategies: ${lastError instanceof Error ? lastError.message : String(lastError)}`
4249
+ );
3999
4250
  }
4000
4251
  async function runAppiumDriverInstallWithPriority(config, driver, onLogLine) {
4001
4252
  const npmProxy = await detectBestRegistry(config, npmProxyRegistry());
@@ -4054,7 +4305,9 @@ async function runAppiumDriverInstallWithPriority(config, driver, onLogLine) {
4054
4305
  }
4055
4306
  }
4056
4307
  }
4057
- throw new Error(`Appium driver install failed after all strategies (${driver}): ${lastError instanceof Error ? lastError.message : String(lastError)}`);
4308
+ throw new Error(
4309
+ `Appium driver install failed after all strategies (${driver}): ${lastError instanceof Error ? lastError.message : String(lastError)}`
4310
+ );
4058
4311
  }
4059
4312
  async function verifyPlaywrightSelfTest(onLogLine) {
4060
4313
  onLogLine?.("[playwright] \u81EA\u68C0\uFF1A\u542F\u52A8 Chromium \u7A7A\u767D\u9875");
@@ -4073,7 +4326,9 @@ async function installPlaywrightBrowser(config, onLogLine, options) {
4073
4326
  const rawTargets = playwrightInstallTargets(config);
4074
4327
  const targets = expandPlaywrightInstallTargets(rawTargets);
4075
4328
  if (rawTargets.length > 0 && targets.length > rawTargets.length) {
4076
- onLogLine?.("[playwright] \u914D\u7F6E\u4EC5\u542B chrome/msedge \u901A\u9053\uFF0C\u5DF2\u81EA\u52A8\u52A0\u5165 chromium\uFF08\u81EA\u68C0\u9700 Playwright \u5185\u7F6E\u6D4F\u89C8\u5668\uFF09");
4329
+ onLogLine?.(
4330
+ "[playwright] \u914D\u7F6E\u4EC5\u542B chrome/msedge \u901A\u9053\uFF0C\u5DF2\u81EA\u52A8\u52A0\u5165 chromium\uFF08\u81EA\u68C0\u9700 Playwright \u5185\u7F6E\u6D4F\u89C8\u5668\uFF09"
4331
+ );
4077
4332
  }
4078
4333
  progress("playwright.browser.install.start", { targets: targets.length > 0 ? targets : ["all"] });
4079
4334
  onLogLine?.("[playwright] \u5F00\u59CB\u5728\u7EBF\u5B89\u88C5\u6D4F\u89C8\u5668");
@@ -4094,7 +4349,9 @@ async function installPlaywrightBrowser(config, onLogLine, options) {
4094
4349
  if (i > 0) {
4095
4350
  onLogLine?.(`[playwright] \u4E0A\u4E00\u955C\u50CF\u5931\u8D25\uFF0C\u6539\u8BD5 ${host}`);
4096
4351
  }
4097
- onLogLine?.(`[playwright] \u4F7F\u7528\u5185\u7F6E playwright@${version} CLI\uFF0C\u955C\u50CF ${host}\uFF0C\u76EE\u6807: ${targets.length ? targets.join(",") : "all"}${options?.force ? " (--force)" : ""}`);
4352
+ onLogLine?.(
4353
+ `[playwright] \u4F7F\u7528\u5185\u7F6E playwright@${version} CLI\uFF0C\u955C\u50CF ${host}\uFF0C\u76EE\u6807: ${targets.length ? targets.join(",") : "all"}${options?.force ? " (--force)" : ""}`
4354
+ );
4098
4355
  try {
4099
4356
  await runCommand2(command, installArgs, {
4100
4357
  env: { PLAYWRIGHT_DOWNLOAD_HOST: host },
@@ -4141,7 +4398,7 @@ async function verifyAppiumCommand() {
4141
4398
  }
4142
4399
  }
4143
4400
  async function getInstalledAppiumDrivers() {
4144
- const check = await runCommandCapture("npm", ["exec", "appium", "driver", "list", "--installed", "--json"]);
4401
+ const check = await runCommandCapture2("npm", ["exec", "appium", "driver", "list", "--installed", "--json"]);
4145
4402
  if (check.code === 0 && check.stdout) {
4146
4403
  try {
4147
4404
  const parsed = JSON.parse(check.stdout);
@@ -4150,7 +4407,7 @@ async function getInstalledAppiumDrivers() {
4150
4407
  } catch {
4151
4408
  }
4152
4409
  }
4153
- const fallback = await runCommandCapture("npm", ["exec", "appium", "driver", "list", "--installed"]);
4410
+ const fallback = await runCommandCapture2("npm", ["exec", "appium", "driver", "list", "--installed"]);
4154
4411
  if (fallback.code !== 0) {
4155
4412
  return [];
4156
4413
  }
@@ -4208,7 +4465,10 @@ function configWithPlaywrightTargets(config, targets) {
4208
4465
  }
4209
4466
  async function ensureSeleniumNativeDrivers(config, options, onLogLine) {
4210
4467
  const root = await resolveWorkspaceRoot2(process.cwd());
4211
- const driversDir = import_node_path5.default.resolve(root, options?.nativeDriversDir ?? config.dependencies.nativeDriversDir ?? "dirver");
4468
+ const driversDir = import_node_path5.default.resolve(
4469
+ root,
4470
+ options?.nativeDriversDir ?? config.dependencies.nativeDriversDir ?? "dirver"
4471
+ );
4212
4472
  const seleniumWebdriverInstalled = hasPackage("selenium-webdriver");
4213
4473
  if (seleniumWebdriverInstalled) {
4214
4474
  onLogLine?.("[selenium] npm \u5305 selenium-webdriver \u5DF2\u5B89\u88C5");
@@ -4217,11 +4477,16 @@ async function ensureSeleniumNativeDrivers(config, options, onLogLine) {
4217
4477
  }
4218
4478
  const geckoVer = options?.geckodriverVersion ?? config.dependencies.geckodriverVersion ?? "latest";
4219
4479
  const chromeVer = options?.chromedriverVersion ?? config.dependencies.chromedriverVersion ?? "latest";
4480
+ onLogLine?.("[selenium] \u5C06\u68C0\u6D4B\u672C\u673A Chrome/Firefox \u7248\u672C\u5E76\u5C1D\u8BD5\u5339\u914D\u9A71\u52A8\uFF1B\u4E0B\u8F7D\u5931\u8D25\u65F6\u8DF3\u8FC7\u5E76\u63D0\u793A\u624B\u52A8\u4E0B\u8F7D\uFF08\u89C1\u5B89\u88C5\u65E5\u5FD7\u53C2\u8003\u5730\u5740\uFF09\u3002");
4220
4481
  try {
4221
4482
  const catalog = await listChromedriverCfTVersions();
4222
- onLogLine?.(`[selenium] \u53EF\u9009 chromedriver \u4E3B\u7248\u672C\uFF08chrome-for-testing\uFF09: ${catalog.slice(0, 12).map((x) => x.major).join(", ")}${catalog.length > 12 ? "\u2026" : ""}`);
4483
+ onLogLine?.(
4484
+ `[selenium] \u53EF\u9009 chromedriver \u4E3B\u7248\u672C\uFF08chrome-for-testing\uFF09: ${catalog.slice(0, 12).map((x) => x.major).join(", ")}${catalog.length > 12 ? "\u2026" : ""}`
4485
+ );
4223
4486
  } catch (error) {
4224
- onLogLine?.(`[selenium] \u65E0\u6CD5\u62C9\u53D6 chromedriver \u7248\u672C\u5217\u8868: ${error instanceof Error ? error.message : String(error)}`);
4487
+ onLogLine?.(
4488
+ `[selenium] \u65E0\u6CD5\u62C9\u53D6 chromedriver \u7248\u672C\u5217\u8868: ${error instanceof Error ? error.message : String(error)}`
4489
+ );
4225
4490
  }
4226
4491
  const resolved = await ensureNativeWebDrivers({
4227
4492
  workspaceRoot: root,
@@ -4240,27 +4505,82 @@ async function ensureSeleniumNativeDrivers(config, options, onLogLine) {
4240
4505
  chromedriverPath: resolved.chromedriverPath
4241
4506
  };
4242
4507
  }
4243
- async function prepareInstallHomes(onLogLine) {
4508
+ function installScopeNeedsMobileEnv(only) {
4509
+ return only === "all" || only === "appium" || only === "drivers" || only === "mobile" || only === "android" || only === "ios" || only === "harmony";
4510
+ }
4511
+ async function pathIsExistingDirectory(dirPath) {
4512
+ try {
4513
+ const stat = await import_promises5.default.stat(dirPath);
4514
+ return stat.isDirectory();
4515
+ } catch {
4516
+ return false;
4517
+ }
4518
+ }
4519
+ async function prepareInstallHomes(onLogLine, options) {
4244
4520
  const root = await resolveWorkspaceRoot2(process.cwd());
4245
- const projectAndroidHome = import_node_path5.default.join(root, "android-sdk");
4246
- const projectAppiumHome = import_node_path5.default.join(root, "appium");
4521
+ const projectAndroidHome = import_node_path5.default.join(root, "ANDROID_HOME");
4522
+ const projectAppiumHome = import_node_path5.default.join(root, "APPIUM_HOME");
4247
4523
  const envAndroid = (process.env.ANDROID_HOME ?? process.env.ANDROID_SDK_ROOT ?? "").trim();
4248
4524
  const envAppium = (process.env.APPIUM_HOME ?? "").trim();
4249
- const androidHome = envAndroid || projectAndroidHome;
4250
- const appiumHome = envAppium || projectAppiumHome;
4251
- const usedProjectFallbackAndroid = !envAndroid;
4252
- const usedProjectFallbackAppium = !envAppium;
4253
- await import_promises5.default.mkdir(androidHome, { recursive: true });
4254
- await import_promises5.default.mkdir(appiumHome, { recursive: true });
4525
+ const requireMobile = options?.requireMobileEnv === true;
4526
+ let androidFromSystem = false;
4527
+ let appiumFromSystem = false;
4528
+ let androidHome = projectAndroidHome;
4529
+ let appiumHome = projectAppiumHome;
4530
+ if (envAndroid) {
4531
+ if (await pathIsExistingDirectory(envAndroid)) {
4532
+ androidFromSystem = true;
4533
+ androidHome = envAndroid;
4534
+ onLogLine?.(`[deps] \u4F7F\u7528\u7CFB\u7EDF\u73AF\u5883\u53D8\u91CF ANDROID_HOME=${envAndroid}`);
4535
+ } else {
4536
+ onLogLine?.(`[deps][warn] \u7CFB\u7EDF ANDROID_HOME / ANDROID_SDK_ROOT \u6307\u5411\u7684\u76EE\u5F55\u4E0D\u5B58\u5728: ${envAndroid}`);
4537
+ onLogLine?.(`[deps][warn] \u8BF7\u4FEE\u6B63\u7CFB\u7EDF\u73AF\u5883\u53D8\u91CF\uFF0C\u6216\u5220\u9664\u9519\u8BEF\u914D\u7F6E\u540E\u91CD\u8BD5\u3002`);
4538
+ onLogLine?.(`[deps] \u5B89\u88C5\u8FC7\u7A0B\u5C06\u4F7F\u7528\u9879\u76EE\u9ED8\u8BA4\u76EE\u5F55: ${projectAndroidHome}`);
4539
+ }
4540
+ } else {
4541
+ onLogLine?.("[deps][warn] \u672A\u68C0\u6D4B\u5230\u7CFB\u7EDF\u73AF\u5883\u53D8\u91CF ANDROID_HOME \u6216 ANDROID_SDK_ROOT\u3002");
4542
+ onLogLine?.(
4543
+ "[deps][warn] \u8BF7\u5728\u7CFB\u7EDF/\u7EC8\u7AEF\u914D\u7F6E ANDROID_HOME\uFF08\u6307\u5411 Android SDK \u6839\u76EE\u5F55\uFF0C\u4E14\u5305\u542B platform-tools\uFF09\u3002"
4544
+ );
4545
+ onLogLine?.(`[deps] \u5B89\u88C5\u8FC7\u7A0B\u5C06\u4F7F\u7528\u9879\u76EE\u9ED8\u8BA4\u76EE\u5F55: ${projectAndroidHome}`);
4546
+ }
4547
+ if (envAppium) {
4548
+ if (await pathIsExistingDirectory(envAppium)) {
4549
+ appiumFromSystem = true;
4550
+ appiumHome = envAppium;
4551
+ onLogLine?.(`[deps] \u4F7F\u7528\u7CFB\u7EDF\u73AF\u5883\u53D8\u91CF APPIUM_HOME=${envAppium}`);
4552
+ } else {
4553
+ onLogLine?.(`[deps][warn] \u7CFB\u7EDF APPIUM_HOME \u6307\u5411\u7684\u76EE\u5F55\u4E0D\u5B58\u5728: ${envAppium}`);
4554
+ onLogLine?.(`[deps][warn] \u8BF7\u4FEE\u6B63\u7CFB\u7EDF\u73AF\u5883\u53D8\u91CF\uFF0C\u6216\u5220\u9664\u9519\u8BEF\u914D\u7F6E\u540E\u91CD\u8BD5\u3002`);
4555
+ onLogLine?.(`[deps] \u5B89\u88C5\u8FC7\u7A0B\u5C06\u4F7F\u7528\u9879\u76EE\u9ED8\u8BA4\u76EE\u5F55: ${projectAppiumHome}`);
4556
+ }
4557
+ } else {
4558
+ onLogLine?.("[deps][warn] \u672A\u68C0\u6D4B\u5230\u7CFB\u7EDF\u73AF\u5883\u53D8\u91CF APPIUM_HOME\u3002");
4559
+ onLogLine?.("[deps][warn] \u8BF7\u5728\u7CFB\u7EDF/\u7EC8\u7AEF\u914D\u7F6E APPIUM_HOME\uFF08Appium \u9A71\u52A8\u4E0E\u6269\u5C55\u7684\u5B89\u88C5\u76EE\u5F55\uFF09\u3002");
4560
+ onLogLine?.(`[deps] \u5B89\u88C5\u8FC7\u7A0B\u5C06\u4F7F\u7528\u9879\u76EE\u9ED8\u8BA4\u76EE\u5F55: ${projectAppiumHome}`);
4561
+ }
4562
+ if (requireMobile && !androidFromSystem && !appiumFromSystem) {
4563
+ onLogLine?.(
4564
+ "[deps][warn] \u5F53\u524D\u5B89\u88C5\u5305\u542B Appium/\u79FB\u52A8\u7AEF\u80FD\u529B\uFF0C\u5EFA\u8BAE\u5728\u5B8C\u6210 install-deps \u524D\u914D\u7F6E\u7CFB\u7EDF ANDROID_HOME \u4E0E APPIUM_HOME\u3002"
4565
+ );
4566
+ }
4567
+ await import_promises5.default.mkdir(projectAndroidHome, { recursive: true });
4568
+ await import_promises5.default.mkdir(projectAppiumHome, { recursive: true });
4569
+ if (androidHome !== projectAndroidHome) {
4570
+ await import_promises5.default.mkdir(androidHome, { recursive: true }).catch(() => void 0);
4571
+ }
4572
+ if (appiumHome !== projectAppiumHome) {
4573
+ await import_promises5.default.mkdir(appiumHome, { recursive: true }).catch(() => void 0);
4574
+ }
4255
4575
  process.env.ANDROID_HOME = androidHome;
4256
4576
  process.env.ANDROID_SDK_ROOT = androidHome;
4257
4577
  process.env.APPIUM_HOME = appiumHome;
4258
- onLogLine?.(`[deps] \u73AF\u5883\u76EE\u5F55: ANDROID_HOME=${androidHome} APPIUM_HOME=${appiumHome}` + (usedProjectFallbackAndroid || usedProjectFallbackAppium ? "\uFF08\u5DF2\u4F7F\u7528\u9879\u76EE\u76EE\u5F55\u515C\u5E95\uFF09" : ""));
4578
+ onLogLine?.(`[deps] \u73AF\u5883\u76EE\u5F55: ANDROID_HOME=${androidHome} APPIUM_HOME=${appiumHome}`);
4259
4579
  return {
4260
4580
  androidHome,
4261
4581
  appiumHome,
4262
- usedProjectFallbackAndroid,
4263
- usedProjectFallbackAppium
4582
+ androidFromSystem,
4583
+ appiumFromSystem
4264
4584
  };
4265
4585
  }
4266
4586
  function resolveRequestedDrivers(config, only) {
@@ -4303,14 +4623,16 @@ async function ensureDriverDependencies(config, options) {
4303
4623
  const pwOverride = filterPlaywrightTargetsOverride(options?.playwrightInstallTargetsOverride);
4304
4624
  const configForPlaywright = pwOverride?.length ? configWithPlaywrightTargets(config, pwOverride) : config;
4305
4625
  const state = await loadInstallState();
4306
- const homes = await prepareInstallHomes(onLogLine);
4626
+ const needPlaywright = only === "all" || only === "playwright";
4627
+ const needSelenium = only === "all" || only === "selenium";
4628
+ const needAppium = only === "all" || only === "appium" || only === "drivers" || only === "mobile" || only === "android" || only === "ios" || only === "harmony";
4629
+ const homes = await prepareInstallHomes(onLogLine, {
4630
+ requireMobileEnv: installScopeNeedsMobileEnv(only)
4631
+ });
4307
4632
  progress("deps.ensure.start");
4308
4633
  onLogLine?.("[deps] \u5F00\u59CB\u68C0\u6D4B / \u5B89\u88C5\u4F9D\u8D56\u2026");
4309
4634
  await ensureNodeEnvironmentForInstall(onLogLine);
4310
4635
  const missing = [];
4311
- const needPlaywright = only === "all" || only === "playwright";
4312
- const needSelenium = only === "all" || only === "selenium";
4313
- const needAppium = only === "all" || only === "appium" || only === "drivers" || only === "mobile" || only === "android" || only === "ios" || only === "harmony";
4314
4636
  const requestedDrivers = options?.appiumRequiredDriversOverride !== void 0 ? normalizeAppiumDriverTokens(options.appiumRequiredDriversOverride) : resolveRequestedDrivers(config, only);
4315
4637
  const needDrivers = requestedDrivers.length > 0;
4316
4638
  const installedPackages = [];
@@ -4356,7 +4678,9 @@ async function ensureDriverDependencies(config, options) {
4356
4678
  }
4357
4679
  });
4358
4680
  if (force) {
4359
- onLogLine?.(userRequestedBrowserTargets ? "[playwright] --force\uFF1A\u91CD\u65B0\u5B89\u88C5\u5F53\u524D\u52FE\u9009\u7684\u6D4F\u89C8\u5668\u901A\u9053" : "[playwright] --force\uFF1A\u6309\u914D\u7F6E\u6587\u4EF6\u4E2D\u7684\u76EE\u6807\u91CD\u65B0\u5B89\u88C5\u6D4F\u89C8\u5668");
4681
+ onLogLine?.(
4682
+ userRequestedBrowserTargets ? "[playwright] --force\uFF1A\u91CD\u65B0\u5B89\u88C5\u5F53\u524D\u52FE\u9009\u7684\u6D4F\u89C8\u5668\u901A\u9053" : "[playwright] --force\uFF1A\u6309\u914D\u7F6E\u6587\u4EF6\u4E2D\u7684\u76EE\u6807\u91CD\u65B0\u5B89\u88C5\u6D4F\u89C8\u5668"
4683
+ );
4360
4684
  }
4361
4685
  await installPlaywrightBrowser(configForPlaywright, onLogLine, {
4362
4686
  force: force || reinstallForTargets || !launchOk
@@ -4428,7 +4752,10 @@ async function ensureDriverDependencies(config, options) {
4428
4752
  let availableChromedriverMajors;
4429
4753
  if (needSelenium) {
4430
4754
  const root = await resolveWorkspaceRoot2(process.cwd());
4431
- nativeDriversDir = import_node_path5.default.resolve(root, options?.nativeDriversDir ?? config.dependencies.nativeDriversDir ?? "dirver");
4755
+ nativeDriversDir = import_node_path5.default.resolve(
4756
+ root,
4757
+ options?.nativeDriversDir ?? config.dependencies.nativeDriversDir ?? "dirver"
4758
+ );
4432
4759
  availableChromedriverMajors = await listLocalChromedriverVersions(nativeDriversDir);
4433
4760
  const resolved = await resolveNativeDrivers({
4434
4761
  workspaceRoot: root,
@@ -4503,13 +4830,12 @@ async function getDependencyHealth(config) {
4503
4830
  }
4504
4831
  var import_node_module, import_node_fs, import_node_child_process2, import_promises5, import_node_path5, require2, DEFAULT_NPM_REGISTRY_CANDIDATES, detectedBestRegistryByKey, PROGRESS_STEPS, DEFAULT_PLAYWRIGHT_HOST_CANDIDATES, PLAYWRIGHT_HOST_FALLBACK, PW_INSTALL_TARGETS;
4505
4832
  var init_dependency_installer = __esm({
4506
- "../ada-agent/dist/dependency-installer.js"() {
4507
- "use strict";
4833
+ "../ada-agent/src/dependency-installer.ts"() {
4508
4834
  import_node_module = require("node:module");
4509
4835
  import_node_fs = require("node:fs");
4510
4836
  import_node_child_process2 = require("node:child_process");
4511
- import_promises5 = __toESM(require("node:fs/promises"), 1);
4512
- import_node_path5 = __toESM(require("node:path"), 1);
4837
+ import_promises5 = __toESM(require("node:fs/promises"));
4838
+ import_node_path5 = __toESM(require("node:path"));
4513
4839
  init_logger();
4514
4840
  init_config();
4515
4841
  init_src2();
@@ -4780,7 +5106,7 @@ var init_src4 = __esm({
4780
5106
  }
4781
5107
  });
4782
5108
 
4783
- // ../ada-agent/dist/plugin-registry.js
5109
+ // ../ada-agent/src/plugin-registry.ts
4784
5110
  function buildPluginHost() {
4785
5111
  const host = new PluginHost();
4786
5112
  registerRuntimePlugins(host);
@@ -4791,13 +5117,12 @@ function listBuiltInPluginManifests() {
4791
5117
  return registerRuntimePlugins(host);
4792
5118
  }
4793
5119
  var init_plugin_registry = __esm({
4794
- "../ada-agent/dist/plugin-registry.js"() {
4795
- "use strict";
5120
+ "../ada-agent/src/plugin-registry.ts"() {
4796
5121
  init_src4();
4797
5122
  }
4798
5123
  });
4799
5124
 
4800
- // ../ada-agent/dist/doctor.js
5125
+ // ../ada-agent/src/doctor.ts
4801
5126
  async function dirExists2(dirPath) {
4802
5127
  try {
4803
5128
  const stat = await import_promises6.default.stat(dirPath);
@@ -4974,11 +5299,10 @@ async function checkAppiumServer(serverUrl) {
4974
5299
  }
4975
5300
  var import_promises6, import_node_net, import_node_path7, import_node_url, import_node_child_process3;
4976
5301
  var init_doctor = __esm({
4977
- "../ada-agent/dist/doctor.js"() {
4978
- "use strict";
4979
- import_promises6 = __toESM(require("node:fs/promises"), 1);
4980
- import_node_net = __toESM(require("node:net"), 1);
4981
- import_node_path7 = __toESM(require("node:path"), 1);
5302
+ "../ada-agent/src/doctor.ts"() {
5303
+ import_promises6 = __toESM(require("node:fs/promises"));
5304
+ import_node_net = __toESM(require("node:net"));
5305
+ import_node_path7 = __toESM(require("node:path"));
4982
5306
  import_node_url = require("node:url");
4983
5307
  import_node_child_process3 = require("node:child_process");
4984
5308
  init_dependency_installer();
@@ -4987,7 +5311,7 @@ var init_doctor = __esm({
4987
5311
  }
4988
5312
  });
4989
5313
 
4990
- // ../ada-agent/dist/setup-cli.js
5314
+ // ../ada-agent/src/setup-cli.ts
4991
5315
  function parseTags(raw) {
4992
5316
  return raw.split(",").map((s) => s.trim()).filter(Boolean);
4993
5317
  }
@@ -5001,7 +5325,9 @@ async function runSetupCli() {
5001
5325
  const rl = import_promises7.default.createInterface({ input: import_node_process.stdin, output: import_node_process.stdout });
5002
5326
  try {
5003
5327
  console.log("[ADA-AGENT] setup wizard (CLI mode)");
5004
- const serverUrl = ensureServerUrl((await rl.question("Server URL (e.g. https://ada-control.example.com): ")).trim());
5328
+ const serverUrl = ensureServerUrl(
5329
+ (await rl.question("Server URL (e.g. https://ada-control.example.com): ")).trim()
5330
+ );
5005
5331
  const tenant = (await rl.question("Tenant [default]: ")).trim() || "default";
5006
5332
  const environment = (await rl.question("Environment [prod]: ")).trim() || "prod";
5007
5333
  const authTypeInput = (await rl.question("Auth type [token/device_code] (default token): ")).trim();
@@ -5030,14 +5356,13 @@ async function runSetupCli() {
5030
5356
  }
5031
5357
  var import_promises7, import_node_process;
5032
5358
  var init_setup_cli = __esm({
5033
- "../ada-agent/dist/setup-cli.js"() {
5034
- "use strict";
5035
- import_promises7 = __toESM(require("node:readline/promises"), 1);
5359
+ "../ada-agent/src/setup-cli.ts"() {
5360
+ import_promises7 = __toESM(require("node:readline/promises"));
5036
5361
  import_node_process = require("node:process");
5037
5362
  }
5038
5363
  });
5039
5364
 
5040
- // ../ada-agent/dist/setup-native.js
5365
+ // ../ada-agent/src/setup-native.ts
5041
5366
  function normalizeOutput(raw) {
5042
5367
  const parsed = JSON.parse(raw);
5043
5368
  if (!parsed.serverUrl || !parsed.tenant || !parsed.environment) {
@@ -5100,13 +5425,12 @@ async function runSetupNative(config) {
5100
5425
  }
5101
5426
  var import_node_child_process4;
5102
5427
  var init_setup_native = __esm({
5103
- "../ada-agent/dist/setup-native.js"() {
5104
- "use strict";
5428
+ "../ada-agent/src/setup-native.ts"() {
5105
5429
  import_node_child_process4 = require("node:child_process");
5106
5430
  }
5107
5431
  });
5108
5432
 
5109
- // ../ada-agent/dist/setup-state.js
5433
+ // ../ada-agent/src/setup-state.ts
5110
5434
  function normalizePlaywrightTargets(raw) {
5111
5435
  const list = (raw ?? []).map((x) => String(x).toLowerCase().trim()).filter((x) => PW_TARGET.has(x));
5112
5436
  if (list.includes("all")) {
@@ -5174,8 +5498,7 @@ async function persistAgentSetup(config, input2) {
5174
5498
  }
5175
5499
  var PW_TARGET;
5176
5500
  var init_setup_state = __esm({
5177
- "../ada-agent/dist/setup-state.js"() {
5178
- "use strict";
5501
+ "../ada-agent/src/setup-state.ts"() {
5179
5502
  init_config();
5180
5503
  init_secrets();
5181
5504
  PW_TARGET = /* @__PURE__ */ new Set([
@@ -5189,7 +5512,7 @@ var init_setup_state = __esm({
5189
5512
  }
5190
5513
  });
5191
5514
 
5192
- // ../ada-agent/dist/bootstrap-ui.js
5515
+ // ../ada-agent/src/bootstrap-ui.ts
5193
5516
  function parseDependencyInstallScope(value) {
5194
5517
  if (value === "all" || value === "playwright" || value === "mobile" || value === "android" || value === "ios" || value === "harmony" || value === "appium" || value === "drivers") {
5195
5518
  return value;
@@ -5575,7 +5898,10 @@ async function runSetupUi(config) {
5575
5898
  try {
5576
5899
  saved = await persistAgentSetup(config, payload);
5577
5900
  } catch (error) {
5578
- abortSetup(500, error instanceof Error ? error.message : String(error));
5901
+ abortSetup(
5902
+ 500,
5903
+ error instanceof Error ? error.message : String(error)
5904
+ );
5579
5905
  return;
5580
5906
  }
5581
5907
  res.writeHead(200, {
@@ -5682,9 +6008,8 @@ async function openBrowser(url) {
5682
6008
  }
5683
6009
  var import_node_http, import_node_crypto, import_node_url2;
5684
6010
  var init_bootstrap_ui = __esm({
5685
- "../ada-agent/dist/bootstrap-ui.js"() {
5686
- "use strict";
5687
- import_node_http = __toESM(require("node:http"), 1);
6011
+ "../ada-agent/src/bootstrap-ui.ts"() {
6012
+ import_node_http = __toESM(require("node:http"));
5688
6013
  import_node_crypto = require("node:crypto");
5689
6014
  import_node_url2 = require("node:url");
5690
6015
  init_setup_state();
@@ -5888,7 +6213,7 @@ var init_src6 = __esm({
5888
6213
  }
5889
6214
  });
5890
6215
 
5891
- // ../ada-agent/dist/transport-client.js
6216
+ // ../ada-agent/src/transport-client.ts
5892
6217
  function joinUrl(base, suffix) {
5893
6218
  const normalizedBase = base.replace(/\/$/, "");
5894
6219
  if (!suffix.startsWith("/")) {
@@ -5986,14 +6311,11 @@ async function createRuntimeTransport(config, secret) {
5986
6311
  }
5987
6312
  var TransportExecutor;
5988
6313
  var init_transport_client = __esm({
5989
- "../ada-agent/dist/transport-client.js"() {
5990
- "use strict";
6314
+ "../ada-agent/src/transport-client.ts"() {
5991
6315
  init_src5();
5992
6316
  init_src6();
5993
6317
  init_logger();
5994
6318
  TransportExecutor = class {
5995
- transport;
5996
- mode;
5997
6319
  constructor(transport, mode) {
5998
6320
  this.transport = transport;
5999
6321
  this.mode = mode;
@@ -6024,7 +6346,7 @@ var init_transport_client = __esm({
6024
6346
  }
6025
6347
  });
6026
6348
 
6027
- // ../ada-agent/dist/task-loader.js
6349
+ // ../ada-agent/src/task-loader.ts
6028
6350
  function isObject3(value) {
6029
6351
  return typeof value === "object" && value !== null;
6030
6352
  }
@@ -6064,9 +6386,8 @@ async function loadTaskFile(filePath) {
6064
6386
  }
6065
6387
  var import_promises8, allowedCommands;
6066
6388
  var init_task_loader = __esm({
6067
- "../ada-agent/dist/task-loader.js"() {
6068
- "use strict";
6069
- import_promises8 = __toESM(require("node:fs/promises"), 1);
6389
+ "../ada-agent/src/task-loader.ts"() {
6390
+ import_promises8 = __toESM(require("node:fs/promises"));
6070
6391
  allowedCommands = /* @__PURE__ */ new Set([
6071
6392
  "click",
6072
6393
  "type",
@@ -6347,7 +6668,7 @@ var init_src7 = __esm({
6347
6668
  }
6348
6669
  });
6349
6670
 
6350
- // ../ada-agent/dist/monitoring.js
6671
+ // ../ada-agent/src/monitoring.ts
6351
6672
  function shouldMonitorCommand(command, config, index) {
6352
6673
  if (!config.monitoring.enabled) {
6353
6674
  return false;
@@ -6440,7 +6761,7 @@ async function captureOperationMonitor(command, result, index, context) {
6440
6761
  }
6441
6762
  var import_promises9, import_node_path8, import_jimp;
6442
6763
  var init_monitoring = __esm({
6443
- "../ada-agent/dist/monitoring.js"() {
6764
+ "../ada-agent/src/monitoring.ts"() {
6444
6765
  "use strict";
6445
6766
  import_promises9 = __toESM(require("node:fs/promises"), 1);
6446
6767
  import_node_path8 = __toESM(require("node:path"), 1);
@@ -6449,7 +6770,7 @@ var init_monitoring = __esm({
6449
6770
  }
6450
6771
  });
6451
6772
 
6452
- // ../ada-agent/dist/runtime.js
6773
+ // ../ada-agent/src/runtime.ts
6453
6774
  async function runTaskset(commands, options = {}) {
6454
6775
  const executor = new TaskExecutor(buildPluginHost());
6455
6776
  const results = [];
@@ -6466,12 +6787,14 @@ async function runTaskset(commands, options = {}) {
6466
6787
  executeLocal
6467
6788
  });
6468
6789
  if (options.config.monitoring.nonBlocking) {
6469
- monitorJobs.push(monitorJob.catch((error) => {
6470
- log("warn", {
6471
- event: "monitor.capture.unhandled",
6472
- details: { requestId: cmd.requestId, message: error instanceof Error ? error.message : String(error) }
6473
- });
6474
- }));
6790
+ monitorJobs.push(
6791
+ monitorJob.catch((error) => {
6792
+ log("warn", {
6793
+ event: "monitor.capture.unhandled",
6794
+ details: { requestId: cmd.requestId, message: error instanceof Error ? error.message : String(error) }
6795
+ });
6796
+ })
6797
+ );
6475
6798
  } else {
6476
6799
  await monitorJob;
6477
6800
  }
@@ -6483,22 +6806,25 @@ async function runTaskset(commands, options = {}) {
6483
6806
  return results;
6484
6807
  }
6485
6808
  async function runDemoTaskset(options = {}) {
6486
- await runTaskset([
6487
- {
6488
- requestId: "req-web-1",
6489
- sessionId: "session-web",
6490
- platform: "web",
6491
- command: "click",
6492
- payload: { locator: { testId: "login-btn" } }
6493
- },
6494
- {
6495
- requestId: "req-ios-1",
6496
- sessionId: "session-ios",
6497
- platform: "ios",
6498
- command: "swipe",
6499
- payload: { from: [0.5, 0.8], to: [0.5, 0.2] }
6500
- }
6501
- ], options);
6809
+ await runTaskset(
6810
+ [
6811
+ {
6812
+ requestId: "req-web-1",
6813
+ sessionId: "session-web",
6814
+ platform: "web",
6815
+ command: "click",
6816
+ payload: { locator: { testId: "login-btn" } }
6817
+ },
6818
+ {
6819
+ requestId: "req-ios-1",
6820
+ sessionId: "session-ios",
6821
+ platform: "ios",
6822
+ command: "swipe",
6823
+ payload: { from: [0.5, 0.8], to: [0.5, 0.2] }
6824
+ }
6825
+ ],
6826
+ options
6827
+ );
6502
6828
  }
6503
6829
  async function runForegroundLoop(skipDemo = false, options = {}) {
6504
6830
  log("info", { event: "agent.runtime.ready", details: { mode: "foreground" } });
@@ -6508,8 +6834,7 @@ async function runForegroundLoop(skipDemo = false, options = {}) {
6508
6834
  await runDemoTaskset(options);
6509
6835
  }
6510
6836
  var init_runtime = __esm({
6511
- "../ada-agent/dist/runtime.js"() {
6512
- "use strict";
6837
+ "../ada-agent/src/runtime.ts"() {
6513
6838
  init_src7();
6514
6839
  init_plugin_registry();
6515
6840
  init_logger();
@@ -6517,7 +6842,7 @@ var init_runtime = __esm({
6517
6842
  }
6518
6843
  });
6519
6844
 
6520
- // ../ada-agent/dist/queue-runner.js
6845
+ // ../ada-agent/src/queue-runner.ts
6521
6846
  async function ensureDirs(config) {
6522
6847
  await import_promises10.default.mkdir(config.queue.inboxDir, { recursive: true });
6523
6848
  await import_promises10.default.mkdir(config.queue.processedDir, { recursive: true });
@@ -6612,10 +6937,9 @@ async function watchQueue(config, shouldStop, options = {}) {
6612
6937
  }
6613
6938
  var import_promises10, import_node_path9;
6614
6939
  var init_queue_runner = __esm({
6615
- "../ada-agent/dist/queue-runner.js"() {
6616
- "use strict";
6617
- import_promises10 = __toESM(require("node:fs/promises"), 1);
6618
- import_node_path9 = __toESM(require("node:path"), 1);
6940
+ "../ada-agent/src/queue-runner.ts"() {
6941
+ import_promises10 = __toESM(require("node:fs/promises"));
6942
+ import_node_path9 = __toESM(require("node:path"));
6619
6943
  init_task_loader();
6620
6944
  init_runtime();
6621
6945
  init_logger();