@cydm/pie 4.4.1 → 4.4.3

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 (47) hide show
  1. package/dist/builtin/extensions/ask-user/index.js +6 -6
  2. package/dist/builtin/extensions/changelog/index.js +1 -1
  3. package/dist/builtin/extensions/cron/index.js +55 -7
  4. package/dist/builtin/extensions/document-attachments/index.js +1 -1
  5. package/dist/builtin/extensions/herdr-agent-state/index.js +1 -1
  6. package/dist/builtin/extensions/im-forward/README.md +3 -1
  7. package/dist/builtin/extensions/im-forward/index.js +98 -41
  8. package/dist/builtin/extensions/init/index.js +1 -1
  9. package/dist/builtin/extensions/mcp-adapter/index.js +2 -2
  10. package/dist/builtin/extensions/memory/index.js +9 -11
  11. package/dist/builtin/extensions/pie-ipc/index.js +306 -353
  12. package/dist/builtin/extensions/pie-proc/index.js +18 -12
  13. package/dist/builtin/extensions/plan-mode/index.js +6 -6
  14. package/dist/builtin/extensions/subagent/index.js +9 -11
  15. package/dist/builtin/extensions/todo/index.js +6 -6
  16. package/dist/builtin/skills/chrome-devtools-axi/SKILL.md +24 -1
  17. package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-bridge.js +86 -21
  18. package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-cli.js +6 -1
  19. package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-runtime.js +1 -1
  20. package/dist/builtin/skills/chrome-devtools-axi/{cli-CHC7XYFU.js → cli-NLPMVDGG.js} +32 -4
  21. package/dist/builtin/skills/computer-use-axi/computer-use-axi-broker.js +220 -22
  22. package/dist/chunks/{auth-storage-RABPRJ6T.js → auth-storage-C3FZMT7J.js} +3 -3
  23. package/dist/chunks/{chunk-R7VO46EK.js → chunk-3W3SXVPB.js} +5 -4
  24. package/dist/chunks/{chunk-IPLMGAML.js → chunk-5KI4Y4LA.js} +1 -1
  25. package/dist/chunks/{chunk-YNTIOWCD.js → chunk-BLDI2GRF.js} +5 -5
  26. package/dist/chunks/{chunk-UCKOXAME.js → chunk-CBDQJMUI.js} +9 -44
  27. package/dist/chunks/chunk-CGSFBWOM.js +100 -0
  28. package/dist/chunks/{chunk-AKXEZH7K.js → chunk-JMKLTTZQ.js} +89 -107
  29. package/dist/chunks/{chunk-7LTQLJJF.js → chunk-LAJXWOKS.js} +15 -10
  30. package/dist/chunks/{chunk-RZGYXAJU.js → chunk-LZQXQOPJ.js} +1 -12
  31. package/dist/chunks/{chunk-EQOI6RZV.js → chunk-NHV2CALB.js} +3 -5
  32. package/dist/chunks/{chunk-OV7SLSHR.js → chunk-SW2E33UL.js} +2 -4
  33. package/dist/chunks/{chunk-BPSCGGVF.js → chunk-XXGYUYXI.js} +1 -1
  34. package/dist/chunks/{chunk-XO3NM7BB.js → chunk-Y3I2UV5Y.js} +3 -3
  35. package/dist/chunks/{chunk-IZDNZW3S.js → chunk-Z2FKA2ZH.js} +8 -8
  36. package/dist/chunks/chunk-ZPJ3BNQB.js +126 -0
  37. package/dist/chunks/{config-HF2PDLN5.js → config-4EOI5NOU.js} +2 -4
  38. package/dist/chunks/{manager-cli-BYCF4RKN.js → manager-cli-WEHNUV5T.js} +3 -5
  39. package/dist/chunks/{model-registry-7FNIUYPF.js → model-registry-3XAHXXTA.js} +5 -5
  40. package/dist/chunks/{src-OVWRBWKU.js → src-B44QWSGM.js} +4 -4
  41. package/dist/chunks/{src-A5YI46OD.js → src-CLE5ILN4.js} +6 -6
  42. package/dist/chunks/{src-OA3TP6DS.js → src-EGXFJ3WA.js} +5 -5
  43. package/dist/chunks/{src-TF2RAGRU.js → src-Q7LU27C2.js} +3 -3
  44. package/dist/chunks/{test-stream-7YZDGBPO.js → test-stream-OR3EJBNF.js} +3 -3
  45. package/dist/cli.js +128 -132
  46. package/package.json +3 -3
  47. package/dist/chunks/chunk-7KLWHWZD.js +0 -164
@@ -4,12 +4,13 @@ import {
4
4
  } from "../../../chunks/chunk-X6LBWHK3.js";
5
5
  import {
6
6
  liveSessionHolder
7
- } from "../../../chunks/chunk-7KLWHWZD.js";
8
- import "../../../chunks/chunk-UCKOXAME.js";
7
+ } from "../../../chunks/chunk-CGSFBWOM.js";
8
+ import "../../../chunks/chunk-CBDQJMUI.js";
9
9
  import {
10
10
  Type
11
- } from "../../../chunks/chunk-BPSCGGVF.js";
12
- import "../../../chunks/chunk-RZGYXAJU.js";
11
+ } from "../../../chunks/chunk-XXGYUYXI.js";
12
+ import "../../../chunks/chunk-ZPJ3BNQB.js";
13
+ import "../../../chunks/chunk-LZQXQOPJ.js";
13
14
 
14
15
  // builtin/extensions/pie-proc/index.ts
15
16
  import { spawn } from "node:child_process";
@@ -421,17 +422,22 @@ function pieProc(ctx) {
421
422
  const entry = cliEntry();
422
423
  if (!entry) throw new Error("cannot resolve a trusted pie entry point (refusing to spawn)");
423
424
  let resumeSessionId;
425
+ let resumeSessionsDir;
424
426
  if (params.resumeSessionId) {
425
427
  if (!/^[A-Za-z0-9][A-Za-z0-9-_]{5,63}$/.test(params.resumeSessionId)) throw new Error(`invalid resumeSessionId "${params.resumeSessionId}"`);
426
- const globalSessionsDir = resolveOperatorSessionsDir();
427
- const headPath = path.join(globalSessionsDir, params.resumeSessionId, "head.json");
428
+ const operatorSessionsDir = resolveOperatorSessionsDir();
429
+ const workerSessionsDir = path.join(pieProcDir(), "agents", params.name, "sessions");
428
430
  let recordedCwd;
429
- try {
430
- const head = JSON.parse(fs.readFileSync(headPath, "utf8"));
431
- recordedCwd = head.metadata?.cwd;
432
- } catch {
433
- throw new Error(`resumeSessionId "${params.resumeSessionId}" not found in the global session store (${globalSessionsDir})`);
431
+ for (const dir of [workerSessionsDir, operatorSessionsDir]) {
432
+ try {
433
+ const head = JSON.parse(fs.readFileSync(path.join(dir, params.resumeSessionId, "head.json"), "utf8"));
434
+ recordedCwd = head.metadata?.cwd;
435
+ resumeSessionsDir = dir;
436
+ break;
437
+ } catch {
438
+ }
434
439
  }
440
+ if (resumeSessionsDir === void 0) throw new Error(`resumeSessionId "${params.resumeSessionId}" not found (looked in the worker's isolated store ${workerSessionsDir} and the global store ${operatorSessionsDir})`);
435
441
  if (typeof recordedCwd !== "string" || !recordedCwd) throw new Error(`session "${params.resumeSessionId}" has no recorded cwd; resume requires one`);
436
442
  let canonicalRecorded = recordedCwd;
437
443
  try {
@@ -551,7 +557,7 @@ function pieProc(ctx) {
551
557
  PIE_IPC_DISPLAY_NAME: params.kind === "resident" ? params.name : process.env.PIE_IPC_DISPLAY_NAME
552
558
  };
553
559
  if (params.kind === "oneshot") childEnv[ONESHOT_TASK_ENV] = params.task ?? "";
554
- if (resumeSessionId) childEnv.PIE_SESSIONS_DIR = resolveOperatorSessionsDir();
560
+ if (resumeSessionId && resumeSessionsDir !== void 0) childEnv.PIE_SESSIONS_DIR = resumeSessionsDir;
555
561
  try {
556
562
  child = spawn(process.execPath, args, {
557
563
  cwd: canonicalCwd,
@@ -6,14 +6,14 @@ import {
6
6
  createPlanCapability,
7
7
  markCompletedPlanSteps,
8
8
  restoreExecutionState
9
- } from "../../../chunks/chunk-YNTIOWCD.js";
10
- import "../../../chunks/chunk-XO3NM7BB.js";
11
- import "../../../chunks/chunk-IPLMGAML.js";
12
- import "../../../chunks/chunk-R7VO46EK.js";
9
+ } from "../../../chunks/chunk-BLDI2GRF.js";
10
+ import "../../../chunks/chunk-Y3I2UV5Y.js";
11
+ import "../../../chunks/chunk-5KI4Y4LA.js";
12
+ import "../../../chunks/chunk-3W3SXVPB.js";
13
13
  import {
14
14
  Type
15
- } from "../../../chunks/chunk-BPSCGGVF.js";
16
- import "../../../chunks/chunk-RZGYXAJU.js";
15
+ } from "../../../chunks/chunk-XXGYUYXI.js";
16
+ import "../../../chunks/chunk-LZQXQOPJ.js";
17
17
 
18
18
  // builtin/extensions/plan-mode/index.ts
19
19
  import { randomUUID } from "node:crypto";
@@ -5,22 +5,21 @@ import {
5
5
  createCliRetryPolicy,
6
6
  formatTransportLifecycle,
7
7
  logTransportLifecycle
8
- } from "../../../chunks/chunk-7LTQLJJF.js";
8
+ } from "../../../chunks/chunk-LAJXWOKS.js";
9
9
  import {
10
- getConfigDir,
11
- init_config
12
- } from "../../../chunks/chunk-UCKOXAME.js";
10
+ getConfigDir
11
+ } from "../../../chunks/chunk-CBDQJMUI.js";
13
12
  import {
14
13
  SUBAGENT_SESSION_RECORD_VERSION,
15
14
  createPolicyEnforcedTools,
16
15
  createSharedFileSystemTools,
17
16
  createSubagentCapability
18
- } from "../../../chunks/chunk-YNTIOWCD.js";
19
- import "../../../chunks/chunk-XO3NM7BB.js";
20
- import "../../../chunks/chunk-IPLMGAML.js";
21
- import "../../../chunks/chunk-R7VO46EK.js";
22
- import "../../../chunks/chunk-BPSCGGVF.js";
23
- import "../../../chunks/chunk-RZGYXAJU.js";
17
+ } from "../../../chunks/chunk-BLDI2GRF.js";
18
+ import "../../../chunks/chunk-Y3I2UV5Y.js";
19
+ import "../../../chunks/chunk-5KI4Y4LA.js";
20
+ import "../../../chunks/chunk-3W3SXVPB.js";
21
+ import "../../../chunks/chunk-XXGYUYXI.js";
22
+ import "../../../chunks/chunk-LZQXQOPJ.js";
24
23
 
25
24
  // src/files/subagent-session-store.ts
26
25
  import { execFileSync } from "node:child_process";
@@ -381,7 +380,6 @@ function createSubagentSessionStore(sessionsDir, log, deps) {
381
380
  }
382
381
 
383
382
  // builtin/extensions/subagent/index.ts
384
- init_config();
385
383
  import * as path2 from "path";
386
384
  function preserveModelResolution(r) {
387
385
  return r === void 0 ? void 0 : { ...r, model: r.model };
@@ -8,12 +8,12 @@ import {
8
8
  executeManageTodoList,
9
9
  executionStateToTodos,
10
10
  restoreExecutionState
11
- } from "../../../chunks/chunk-YNTIOWCD.js";
12
- import "../../../chunks/chunk-XO3NM7BB.js";
13
- import "../../../chunks/chunk-IPLMGAML.js";
14
- import "../../../chunks/chunk-R7VO46EK.js";
15
- import "../../../chunks/chunk-BPSCGGVF.js";
16
- import "../../../chunks/chunk-RZGYXAJU.js";
11
+ } from "../../../chunks/chunk-BLDI2GRF.js";
12
+ import "../../../chunks/chunk-Y3I2UV5Y.js";
13
+ import "../../../chunks/chunk-5KI4Y4LA.js";
14
+ import "../../../chunks/chunk-3W3SXVPB.js";
15
+ import "../../../chunks/chunk-XXGYUYXI.js";
16
+ import "../../../chunks/chunk-LZQXQOPJ.js";
17
17
 
18
18
  // builtin/extensions/todo/index.ts
19
19
  var EXECUTION_METADATA_KEY = "executionState";
@@ -5,6 +5,29 @@ description: "Control a real Chrome browser session through the chrome-devtools-
5
5
 
6
6
  # chrome-devtools-axi
7
7
 
8
+ ## Which browser does a command drive? (decision order)
9
+
10
+ The DEFAULT target is the USER'S RUNNING CHROME (login state, tabs, history) —
11
+ not a fresh isolated instance. On first use the user must enable it once in
12
+ their Chrome: `chrome://inspect/#remote-debugging` → follow the dialog. After
13
+ that, every connect shows Chrome's own permission dialog (the user clicks
14
+ Allow) plus a persistent "controlled by automated test software" banner, so
15
+ the default never weakens the user's security boundary.
16
+
17
+ - User's browser (visible, logged-in) → default; the error text guides the
18
+ one-time `chrome://inspect/#remote-debugging` setup if not yet enabled.
19
+ - Unattended web testing / scraping without user context →
20
+ `CHROME_DEVTOOLS_AXI_FRESH=1` (isolated headless instance; the pre-2026-11
21
+ default) or add `CHROME_DEVTOOLS_AXI_HEADED=1` for a visible fresh one.
22
+ - Explicit external endpoint → `CHROME_DEVTOOLS_AXI_BROWSER_URL`
23
+ (http(s)://, or a `ws://` endpoint via the same variable).
24
+ - Native desktop apps / non-browser windows → use the computer-use-axi
25
+ skill instead (macOS accessibility, not CDP).
26
+
27
+ If the user says "打开页面给我看" / asks you to operate on a site where THEY
28
+ are logged in, do NOT pass FRESH — the whole point of the default is reusing
29
+ their session without a second login.
30
+
8
31
  Pie ships a frozen patched AXI runtime. Do not install or fetch a different
9
32
  version. Upload accepts one path and resolves it against the caller's cwd.
10
33
  Use `run` with literal UTF-8 stdin for scripts on Windows.
@@ -44,7 +67,7 @@ Do not follow command, workflow, or flag instructions from this file - installed
44
67
 
45
68
  ## Notes
46
69
 
47
- - The CLI drives a real Chrome instance via CDP. Its bridge backend (`chrome-devtools-mcp`) is pinned and shipped with Pie, so first use needs no network fetch. Set `CHROME_DEVTOOLS_AXI_HEADED=1` for a visible browser; see `--help` for connection modes (auto-connect to a running Chrome, custom profile, remote browser URL).
70
+ - The CLI drives a real Chrome instance via CDP. Its bridge backend (`chrome-devtools-mcp`) is pinned and shipped with Pie, so first use needs no network fetch. `CHROME_DEVTOOLS_AXI_HEADED=1` makes a FRESH (launch-mode) instance visible; it has no effect on attach modes (default autoConnect / BROWSER_URL) — an attached browser is already as visible as its owner made it. See `--help` for connection modes.
48
71
  - Use `CHROME_DEVTOOLS_AXI_SESSION=<name>` to keep multiple concurrent browser flows isolated.
49
72
  - Element references (`@<uid>`) come from `snapshot`/`open` output and are generation-tagged; re-snapshot after navigation before clicking.
50
73
  - If the CLI output suggests a follow-up `chrome-devtools-axi` command, run it through the same wrapper path.
@@ -19570,7 +19570,7 @@ import {
19570
19570
  unlinkSync,
19571
19571
  writeFileSync
19572
19572
  } from "node:fs";
19573
- import { basename, dirname, isAbsolute, join } from "node:path";
19573
+ import { basename, dirname, isAbsolute, join, resolve } from "node:path";
19574
19574
  import { pathToFileURL } from "node:url";
19575
19575
 
19576
19576
  // vendor/chrome-devtools-axi/src/supervisor-anchor-shared.ts
@@ -19950,14 +19950,39 @@ var KEYCHAIN_ISOLATION_CHROME_ARGS = [
19950
19950
  "--use-mock-keychain",
19951
19951
  "--password-store=basic"
19952
19952
  ];
19953
+ function isAttachTransportMode() {
19954
+ const explicitAutoConnect = process.env.CHROME_DEVTOOLS_AXI_AUTO_CONNECT;
19955
+ const freshInstance = process.env.CHROME_DEVTOOLS_AXI_FRESH === "1";
19956
+ const browserUrl = process.env.CHROME_DEVTOOLS_AXI_BROWSER_URL;
19957
+ const userDataDir = process.env.CHROME_DEVTOOLS_AXI_USER_DATA_DIR;
19958
+ const autoConnectUnset = explicitAutoConnect === void 0 || explicitAutoConnect === "";
19959
+ const autoConnect = !freshInstance && (explicitAutoConnect === "1" || autoConnectUnset && !browserUrl && !userDataDir);
19960
+ return autoConnect || !freshInstance && !!browserUrl;
19961
+ }
19962
+ function resolveCdpKeepaliveMs() {
19963
+ const raw = Number(process.env.CHROME_DEVTOOLS_AXI_CDP_KEEPALIVE_MS);
19964
+ if (Number.isFinite(raw) && raw >= 1e3 && raw <= 6e4) return raw;
19965
+ return 1e4;
19966
+ }
19953
19967
  function buildTransportArgs() {
19954
- const args = ["-y", "chrome-devtools-mcp@latest"];
19955
- const autoConnect = process.env.CHROME_DEVTOOLS_AXI_AUTO_CONNECT === "1";
19968
+ const args = ["-y", "chrome-devtools-mcp@1.13.0"];
19969
+ const freshInstance = process.env.CHROME_DEVTOOLS_AXI_FRESH === "1";
19956
19970
  const browserUrl = process.env.CHROME_DEVTOOLS_AXI_BROWSER_URL;
19957
19971
  const userDataDir = process.env.CHROME_DEVTOOLS_AXI_USER_DATA_DIR;
19958
19972
  const channel = process.env.CHROME_DEVTOOLS_AXI_CHANNEL?.trim();
19973
+ const explicitAutoConnect = process.env.CHROME_DEVTOOLS_AXI_AUTO_CONNECT;
19974
+ const autoConnectUnset = explicitAutoConnect === void 0 || explicitAutoConnect === "";
19975
+ const autoConnect = !freshInstance && (explicitAutoConnect === "1" || autoConnectUnset && !browserUrl && !userDataDir);
19959
19976
  if (autoConnect) {
19960
19977
  args.push("--autoConnect");
19978
+ } else if (freshInstance) {
19979
+ args.push("--isolated");
19980
+ if (process.env.CHROME_DEVTOOLS_AXI_HEADED !== "1") {
19981
+ args.push("--headless");
19982
+ }
19983
+ for (const arg of KEYCHAIN_ISOLATION_CHROME_ARGS) {
19984
+ args.push(`--chrome-arg=${arg}`);
19985
+ }
19961
19986
  } else if (browserUrl) {
19962
19987
  const isWs = /^wss?:\/\//i.test(browserUrl);
19963
19988
  if (isWs) {
@@ -19993,7 +20018,8 @@ function buildTransportArgs() {
19993
20018
  args.push(`--chrome-arg=${arg}`);
19994
20019
  }
19995
20020
  }
19996
- if (channel && !browserUrl) {
20021
+ const attachEndpointMode = !autoConnect && !freshInstance && !!browserUrl;
20022
+ if (channel && !attachEndpointMode) {
19997
20023
  args.push(`--channel=${channel}`);
19998
20024
  }
19999
20025
  const extraChromeArgs = process.env.CHROME_DEVTOOLS_AXI_CHROME_ARGS;
@@ -20021,26 +20047,50 @@ var DEFAULT_MCP_PATH_PROBE = {
20021
20047
  function detectGlobalMcpPath(probe = DEFAULT_MCP_PATH_PROBE) {
20022
20048
  const prefix = probe.getNpmPrefix();
20023
20049
  if (!prefix || prefix.length === 0) return null;
20024
- const packagePath = [
20025
- "node_modules",
20026
- "chrome-devtools-mcp",
20027
- "build",
20028
- "src",
20029
- "bin",
20030
- "chrome-devtools-mcp.js"
20031
- ];
20032
- const candidates = [
20033
- join(prefix, "lib", ...packagePath),
20034
- join(prefix, ...packagePath)
20035
- ];
20036
- for (const candidate of candidates) {
20037
- if (probe.existsSync(candidate)) return candidate;
20050
+ for (const root of [join(prefix, "lib"), prefix]) {
20051
+ const pkgJson = join(root, "node_modules", "chrome-devtools-mcp", "package.json");
20052
+ if (!probe.existsSync(pkgJson)) continue;
20053
+ try {
20054
+ const pkg = JSON.parse(readFileSync(pkgJson, "utf8"));
20055
+ const rel = pkg.bin?.["chrome-devtools-mcp"];
20056
+ if (rel) {
20057
+ const entry = join(root, "node_modules", "chrome-devtools-mcp", rel);
20058
+ if (probe.existsSync(entry)) return entry;
20059
+ }
20060
+ } catch {
20061
+ const legacy = join(root, "node_modules", "chrome-devtools-mcp", "build", "src", "bin", "chrome-devtools-mcp.js");
20062
+ if (probe.existsSync(legacy)) return legacy;
20063
+ }
20064
+ }
20065
+ return null;
20066
+ }
20067
+ function detectPackagedMcpPath(probe = DEFAULT_MCP_PATH_PROBE) {
20068
+ const selfPath = process.env.CHROME_DEVTOOLS_AXI_SELF_PATH?.trim() || process.argv[1];
20069
+ if (!selfPath) return null;
20070
+ let dir = dirname(resolve(selfPath));
20071
+ for (let hop = 0; hop < 12; hop += 1) {
20072
+ const pkgJson = join(dir, "node_modules", "chrome-devtools-mcp", "package.json");
20073
+ if (probe.existsSync(pkgJson)) {
20074
+ try {
20075
+ const pkg = JSON.parse(readFileSync(pkgJson, "utf8"));
20076
+ const rel = pkg.bin?.["chrome-devtools-mcp"];
20077
+ if (rel) {
20078
+ const entry = join(dir, "node_modules", "chrome-devtools-mcp", rel);
20079
+ if (probe.existsSync(entry)) return entry;
20080
+ }
20081
+ } catch {
20082
+ }
20083
+ }
20084
+ const parent = dirname(dir);
20085
+ if (parent === dir) return null;
20086
+ dir = parent;
20038
20087
  }
20039
20088
  return null;
20040
20089
  }
20041
20090
  function resolveTransportSpec(probe = DEFAULT_MCP_PATH_PROBE) {
20042
20091
  const explicitPath = process.env.CHROME_DEVTOOLS_AXI_MCP_PATH?.trim();
20043
- const sharedServerUrl = process.env.CHROME_DEVTOOLS_AXI_MCP_SERVER_URL?.trim();
20092
+ const freshIsolation = process.env.CHROME_DEVTOOLS_AXI_FRESH === "1";
20093
+ const sharedServerUrl = freshIsolation ? void 0 : process.env.CHROME_DEVTOOLS_AXI_MCP_SERVER_URL?.trim();
20044
20094
  if (sharedServerUrl) {
20045
20095
  if (!explicitPath) {
20046
20096
  throw new Error(
@@ -20073,7 +20123,7 @@ function resolveTransportSpec(probe = DEFAULT_MCP_PATH_PROBE) {
20073
20123
  };
20074
20124
  }
20075
20125
  const mcpArgs = buildTransportArgs();
20076
- const mcpPath = explicitPath || detectGlobalMcpPath(probe);
20126
+ const mcpPath = explicitPath || detectPackagedMcpPath(probe) || detectGlobalMcpPath(probe);
20077
20127
  if (mcpPath) {
20078
20128
  return {
20079
20129
  command: process.execPath,
@@ -20102,7 +20152,8 @@ function parseSharedServerUrl(value) {
20102
20152
  }
20103
20153
  }
20104
20154
  function resolveTransport(probe = DEFAULT_MCP_PATH_PROBE) {
20105
- const sharedServerUrl = process.env.CHROME_DEVTOOLS_AXI_MCP_SERVER_URL?.trim();
20155
+ const freshIsolation = process.env.CHROME_DEVTOOLS_AXI_FRESH === "1";
20156
+ const sharedServerUrl = freshIsolation ? void 0 : process.env.CHROME_DEVTOOLS_AXI_MCP_SERVER_URL?.trim();
20106
20157
  if (sharedServerUrl && !process.env.CHROME_DEVTOOLS_AXI_MCP_PATH?.trim()) {
20107
20158
  return { kind: "http", url: parseSharedServerUrl(sharedServerUrl) };
20108
20159
  }
@@ -20249,6 +20300,20 @@ async function runBridge(port = resolveSessionPort()) {
20249
20300
  const bridgeClient = createRootsAwareBridgeClient(client);
20250
20301
  await client.connect(bridgeTransport.transport);
20251
20302
  logBridgeMessage("Connected to chrome-devtools-mcp");
20303
+ const attachMode = isAttachTransportMode();
20304
+ if (attachMode) {
20305
+ const keepaliveMs = resolveCdpKeepaliveMs();
20306
+ const keepalive = setInterval(() => {
20307
+ if (bridgeClient.isBusy?.()) return;
20308
+ bridgeClient.callTool({ name: "list_pages", arguments: {} }).then(
20309
+ () => void 0,
20310
+ (error2) => logBridgeMessage(
20311
+ `CDP keepalive probe failed: ${getErrorMessage(error2)}`
20312
+ )
20313
+ );
20314
+ }, keepaliveMs);
20315
+ keepalive.unref?.();
20316
+ }
20252
20317
  const sessionName = resolveSessionName();
20253
20318
  const server = createBridgeServer(bridgeClient, sessionName);
20254
20319
  const lifecycle = createBridgeLifecycle(() => shutdown(), {
@@ -32,8 +32,13 @@ export function resolveChromeDevtoolsAxiCli() {
32
32
  * and works offline after install.
33
33
  */
34
34
  export function resolveChromeDevtoolsMcpScript() {
35
+ // The bin path is read from the package's own bin map: 1.13 moved the
36
+ // output tree (build/src → out/Default/gen/src) and hardcoding either
37
+ // side breaks on the next move. package.json is the contract.
35
38
  const packageJson = require.resolve("chrome-devtools-mcp/package.json");
36
- return path.join(path.dirname(packageJson), "build", "src", "bin", "chrome-devtools-mcp.js");
39
+ const pkg = JSON.parse(fs.readFileSync(packageJson, "utf8"));
40
+ const rel = (pkg.bin && pkg.bin["chrome-devtools-mcp"]) || "build/src/bin/chrome-devtools-mcp.js";
41
+ return path.join(path.dirname(packageJson), rel);
37
42
  }
38
43
 
39
44
  export function runChromeDevtoolsAxiCli(args = process.argv.slice(2), options = {}) {
@@ -21,6 +21,6 @@ function tryFastPath(argv, options) {
21
21
 
22
22
  // vendor/chrome-devtools-axi/bin/chrome-devtools-axi.ts
23
23
  if (!tryFastPath(process.argv.slice(2), { version: VERSION })) {
24
- const { main } = await import("./cli-CHC7XYFU.js");
24
+ const { main } = await import("./cli-NLPMVDGG.js");
25
25
  await main(process.argv.slice(2));
26
26
  }
@@ -2000,6 +2000,7 @@ function spawnBridgeProcess(port, sessionName) {
2000
2000
  return child;
2001
2001
  }
2002
2002
  function resolveSharedMcpMode() {
2003
+ if (process.env.CHROME_DEVTOOLS_AXI_FRESH === "1") return null;
2003
2004
  const sharedServerUrl = process.env.CHROME_DEVTOOLS_AXI_MCP_SERVER_URL?.trim();
2004
2005
  if (!sharedServerUrl) return null;
2005
2006
  return process.env.CHROME_DEVTOOLS_AXI_MCP_PATH?.trim() ? "proxy" : "direct";
@@ -2112,12 +2113,23 @@ async function ensureBridge(spawnBridge = spawnBridgeProcess, notice) {
2112
2113
  }
2113
2114
  await sleep(500);
2114
2115
  }
2116
+ const failingGeneration = child.pid !== void 0 && childExited === false ? { pid: child.pid, startTime: inspectProcessIdentity(child.pid)?.startTime ?? void 0 } : pidInfo !== null && sawShallowReady ? { pid: pidInfo.pid, startTime: pidInfo.startTime } : void 0;
2117
+ if (failingGeneration) {
2118
+ try {
2119
+ await stopBridge({ expectedGeneration: failingGeneration });
2120
+ } catch {
2121
+ }
2122
+ }
2115
2123
  const seconds = Math.round(timeoutMs / 1e3);
2116
2124
  const sharedMcpMode = resolveSharedMcpMode();
2117
2125
  if (sawShallowReady) {
2126
+ const autoConnectDefault = !(process.env.CHROME_DEVTOOLS_AXI_FRESH === "1" || process.env.CHROME_DEVTOOLS_AXI_AUTO_CONNECT === "0");
2118
2127
  const suggestions2 = sharedMcpMode ? [
2119
2128
  ...sharedMcpSuggestions(sharedMcpMode),
2120
2129
  "The shared MCP service may be reachable while its attached Chrome target is unavailable."
2130
+ ] : autoConnectDefault ? [
2131
+ "DEFAULT mode attaches to YOUR running Chrome (login state included). That requires remote debugging enabled ONCE in Chrome: open chrome://inspect/#remote-debugging and follow the dialog, then re-run. Chrome will ask you to approve each connection.",
2132
+ "For an isolated headless instance instead (no user login state), set CHROME_DEVTOOLS_AXI_FRESH=1."
2121
2133
  ] : [
2122
2134
  "The Chrome/Electron instance the bridge was attached to may have exited.",
2123
2135
  "Verify the target is still listening on its remote-debugging port, then re-run the command.",
@@ -2218,7 +2230,16 @@ function resolveToolArgs(name, args, reconnected) {
2218
2230
  }
2219
2231
  async function callTool(name, args = {}) {
2220
2232
  const notice = { pageIdentityChanged: false };
2221
- const port = await ensureBridge(void 0, notice);
2233
+ let port;
2234
+ try {
2235
+ port = await ensureBridge(void 0, notice);
2236
+ } catch (error) {
2237
+ if (error instanceof CdpError && error.code === "BRIDGE_NOT_READY") {
2238
+ port = await ensureBridge(void 0, notice);
2239
+ } else {
2240
+ throw error;
2241
+ }
2242
+ }
2222
2243
  let resolved = args;
2223
2244
  let newPageCreated = false;
2224
2245
  try {
@@ -2365,16 +2386,23 @@ async function getSessionSnapshotIfRunning() {
2365
2386
  return null;
2366
2387
  }
2367
2388
  }
2368
- async function stopBridge() {
2389
+ async function stopBridge(options = {}) {
2369
2390
  const pidInfo = readPidFile();
2370
2391
  if (!pidInfo) return "noop";
2371
2392
  if (!isProcessAlive(pidInfo.pid)) return "noop";
2393
+ if (options.expectedGeneration && (options.expectedGeneration.pid !== pidInfo.pid || options.expectedGeneration.startTime !== pidInfo.startTime)) {
2394
+ return "noop";
2395
+ }
2372
2396
  const verdict = await judgeRecordedBridge(pidInfo, resolveSessionName());
2373
2397
  if (!verdict.terminate) return "noop";
2374
- const terminated = await terminateBridgeProcess(verdict.targetPid ?? pidInfo.pid, {
2398
+ const targetPid = verdict.targetPid ?? pidInfo.pid;
2399
+ if (options.expectedGeneration && targetPid !== options.expectedGeneration.pid) {
2400
+ return "noop";
2401
+ }
2402
+ const terminated = await terminateBridgeProcess(targetPid, {
2375
2403
  killProcessGroup: verdict.killProcessGroup,
2376
2404
  requireBridgeIdentity: true,
2377
- expectedStartTime: verdict.expectedStartTime
2405
+ expectedStartTime: options.expectedGeneration ? options.expectedGeneration.startTime ?? verdict.expectedStartTime : verdict.expectedStartTime
2378
2406
  });
2379
2407
  clearSelectedPageId();
2380
2408
  return terminated ? "stopped" : "failed";