@cydm/pie 4.12.1 → 4.13.0
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/builtin/extensions/ask-user/index.js +1 -1
- package/dist/builtin/extensions/cron/index.js +177 -28
- package/dist/builtin/extensions/im-forward/index.js +472 -53
- package/dist/builtin/extensions/memory/index.js +8 -8
- package/dist/builtin/extensions/pie-proc/index.js +7 -7
- package/dist/builtin/extensions/plan-mode/index.js +1 -1
- package/dist/builtin/extensions/subagent/index.js +5 -5
- package/dist/builtin/extensions/todo/index.js +1 -1
- package/dist/builtin/skills/chrome-devtools-axi/SKILL.md +15 -6
- package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-bridge.js +163 -14
- package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-runtime.js +1 -1
- package/dist/builtin/skills/chrome-devtools-axi/chunk-D2OVVTF6.js +1603 -0
- package/dist/builtin/skills/chrome-devtools-axi/{cli-K7ESY3XD.js → cli-DJ36OIQ4.js} +98 -109
- package/dist/builtin/skills/computer-use-axi/SKILL.md +11 -7
- package/dist/builtin/skills/computer-use-axi/computer-use-axi-broker.js +43 -17
- package/dist/chunks/{chunk-QSXBPTOA.js → chunk-3CJLYX5J.js} +4 -4
- package/dist/chunks/{chunk-W37NAT3N.js → chunk-5MCIBDAM.js} +5 -5
- package/dist/chunks/{chunk-WTBLV6F5.js → chunk-5PCLBIOO.js} +23 -9
- package/dist/chunks/{chunk-KW46ND3S.js → chunk-AKC7NMP4.js} +126 -15
- package/dist/chunks/{chunk-26ILLZKQ.js → chunk-NOSNHMA2.js} +1 -1
- package/dist/chunks/{host-image-fallback-NXY36VO2.js → host-image-fallback-MZK633DK.js} +1 -1
- package/dist/chunks/{memory-git-C3S276QJ.js → memory-git-Q3UBYOJ4.js} +2 -2
- package/dist/chunks/{read-file-understanding-ZCBNCQHG.js → read-file-understanding-KCJMSOS7.js} +3 -3
- package/dist/chunks/{src-7CU7OTQS.js → src-QI47K3W3.js} +1 -1
- package/dist/cli.js +48 -48
- package/package.json +2 -2
- package/dist/builtin/skills/chrome-devtools-axi/chunk-HAUDUMDO.js +0 -795
|
@@ -3,10 +3,15 @@ import {
|
|
|
3
3
|
distillWorkerLogPath,
|
|
4
4
|
readDistillWorkerLog,
|
|
5
5
|
spawnDistillWorker
|
|
6
|
-
} from "../../../chunks/chunk-
|
|
6
|
+
} from "../../../chunks/chunk-5PCLBIOO.js";
|
|
7
7
|
import {
|
|
8
8
|
commitCuratedMemoryBestEffort
|
|
9
|
-
} from "../../../chunks/chunk-
|
|
9
|
+
} from "../../../chunks/chunk-NOSNHMA2.js";
|
|
10
|
+
import {
|
|
11
|
+
getConfigDir,
|
|
12
|
+
getSessionsDir,
|
|
13
|
+
getSettingsPath
|
|
14
|
+
} from "../../../chunks/chunk-CBDQJMUI.js";
|
|
10
15
|
import {
|
|
11
16
|
DEFAULT_MEMORY_INJECTION_BUDGET,
|
|
12
17
|
MemoryStore,
|
|
@@ -19,16 +24,11 @@ import {
|
|
|
19
24
|
saveAttestedEntry,
|
|
20
25
|
searchMemory,
|
|
21
26
|
todayKey
|
|
22
|
-
} from "../../../chunks/chunk-
|
|
27
|
+
} from "../../../chunks/chunk-AKC7NMP4.js";
|
|
23
28
|
import {
|
|
24
29
|
FileSessionStore
|
|
25
30
|
} from "../../../chunks/chunk-SXBX2P5R.js";
|
|
26
31
|
import "../../../chunks/chunk-BQWHLYYZ.js";
|
|
27
|
-
import {
|
|
28
|
-
getConfigDir,
|
|
29
|
-
getSessionsDir,
|
|
30
|
-
getSettingsPath
|
|
31
|
-
} from "../../../chunks/chunk-CBDQJMUI.js";
|
|
32
32
|
import "../../../chunks/chunk-G2K4GY6N.js";
|
|
33
33
|
import {
|
|
34
34
|
Type
|
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
redactText
|
|
4
|
-
} from "../../../chunks/chunk-KW46ND3S.js";
|
|
5
|
-
import {
|
|
6
|
-
isCompactSummaryMessage
|
|
7
|
-
} from "../../../chunks/chunk-SXBX2P5R.js";
|
|
8
|
-
import "../../../chunks/chunk-BQWHLYYZ.js";
|
|
9
2
|
import {
|
|
10
3
|
registerWorkerLifecycleBridge,
|
|
11
4
|
syncInheritedWorkerModels
|
|
@@ -21,6 +14,13 @@ import {
|
|
|
21
14
|
loadResolvedModelsConfig
|
|
22
15
|
} from "../../../chunks/chunk-IZ4DYCJ7.js";
|
|
23
16
|
import "../../../chunks/chunk-CBDQJMUI.js";
|
|
17
|
+
import {
|
|
18
|
+
redactText
|
|
19
|
+
} from "../../../chunks/chunk-AKC7NMP4.js";
|
|
20
|
+
import {
|
|
21
|
+
isCompactSummaryMessage
|
|
22
|
+
} from "../../../chunks/chunk-SXBX2P5R.js";
|
|
23
|
+
import "../../../chunks/chunk-BQWHLYYZ.js";
|
|
24
24
|
import "../../../chunks/chunk-G2K4GY6N.js";
|
|
25
25
|
import {
|
|
26
26
|
Type
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
createPlanCapability,
|
|
7
7
|
markCompletedPlanSteps,
|
|
8
8
|
restoreExecutionState
|
|
9
|
-
} from "../../../chunks/chunk-
|
|
9
|
+
} from "../../../chunks/chunk-AKC7NMP4.js";
|
|
10
10
|
import "../../../chunks/chunk-SXBX2P5R.js";
|
|
11
11
|
import "../../../chunks/chunk-BQWHLYYZ.js";
|
|
12
12
|
import "../../../chunks/chunk-G2K4GY6N.js";
|
|
@@ -5,18 +5,18 @@ import {
|
|
|
5
5
|
createCliRetryPolicy,
|
|
6
6
|
formatTransportLifecycle,
|
|
7
7
|
logTransportLifecycle
|
|
8
|
-
} from "../../../chunks/chunk-
|
|
8
|
+
} from "../../../chunks/chunk-5MCIBDAM.js";
|
|
9
|
+
import {
|
|
10
|
+
getConfigDir
|
|
11
|
+
} from "../../../chunks/chunk-CBDQJMUI.js";
|
|
9
12
|
import {
|
|
10
13
|
SUBAGENT_SESSION_RECORD_VERSION,
|
|
11
14
|
createPolicyEnforcedTools,
|
|
12
15
|
createSharedFileSystemTools,
|
|
13
16
|
createSubagentCapability
|
|
14
|
-
} from "../../../chunks/chunk-
|
|
17
|
+
} from "../../../chunks/chunk-AKC7NMP4.js";
|
|
15
18
|
import "../../../chunks/chunk-SXBX2P5R.js";
|
|
16
19
|
import "../../../chunks/chunk-BQWHLYYZ.js";
|
|
17
|
-
import {
|
|
18
|
-
getConfigDir
|
|
19
|
-
} from "../../../chunks/chunk-CBDQJMUI.js";
|
|
20
20
|
import "../../../chunks/chunk-G2K4GY6N.js";
|
|
21
21
|
import "../../../chunks/chunk-XXGYUYXI.js";
|
|
22
22
|
import "../../../chunks/chunk-LZQXQOPJ.js";
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
executeManageTodoList,
|
|
9
9
|
executionStateToTodos,
|
|
10
10
|
restoreExecutionState
|
|
11
|
-
} from "../../../chunks/chunk-
|
|
11
|
+
} from "../../../chunks/chunk-AKC7NMP4.js";
|
|
12
12
|
import "../../../chunks/chunk-SXBX2P5R.js";
|
|
13
13
|
import "../../../chunks/chunk-BQWHLYYZ.js";
|
|
14
14
|
import "../../../chunks/chunk-G2K4GY6N.js";
|
|
@@ -17,14 +17,23 @@ when stopped or idle.
|
|
|
17
17
|
inherited attach/profile env). Always call `stop` on your named session once
|
|
18
18
|
the task finishes so the background Chrome exits immediately instead of
|
|
19
19
|
waiting for the 10-minute idle timeout.
|
|
20
|
+
- **Dedicated persistent Agent Profile (recommended whenever recurring login
|
|
21
|
+
state is needed)** → set `CHROME_DEVTOOLS_AXI_PROFILE=<name>` (stored under
|
|
22
|
+
`~/.chrome-devtools-axi/profiles/<name>`, or pass an explicit
|
|
23
|
+
`CHROME_DEVTOOLS_AXI_USER_DATA_DIR=<dir>`). Log in once visibly with
|
|
24
|
+
`CHROME_DEVTOOLS_AXI_PROFILE=<name> CHROME_DEVTOOLS_AXI_HEADED=1`, run
|
|
25
|
+
`stop`, and then reuse `CHROME_DEVTOOLS_AXI_PROFILE=<name>` headless in the
|
|
26
|
+
background with **zero remote-debugging approval dialogs**, **zero Dock/focus
|
|
27
|
+
disturbance**, and without touching the user's personal Chrome.
|
|
20
28
|
- **Visible isolated browser** (e.g. user asked "打开页面给我看" without
|
|
21
29
|
needing their personal login) → `CHROME_DEVTOOLS_AXI_HEADED=1`.
|
|
22
|
-
- **User's running Chrome (explicit opt-in ONLY when personal
|
|
23
|
-
|
|
24
|
-
(or `CHROME_DEVTOOLS_AXI_ATTACH=1`).
|
|
25
|
-
`chrome://inspect/#remote-debugging` enable and
|
|
26
|
-
remote debugging?" dialog; use a dedicated
|
|
27
|
-
it never collides with background headless
|
|
30
|
+
- **User's running Chrome (explicit opt-in ONLY when personal Chrome's existing
|
|
31
|
+
tabs / already-open session are strictly required)** →
|
|
32
|
+
`CHROME_DEVTOOLS_AXI_AUTO_CONNECT=1` (or `CHROME_DEVTOOLS_AXI_ATTACH=1`).
|
|
33
|
+
Requires the one-time `chrome://inspect/#remote-debugging` enable and
|
|
34
|
+
triggers Chrome's "Allow remote debugging?" dialog; use a dedicated
|
|
35
|
+
`CHROME_DEVTOOLS_AXI_SESSION` so it never collides with background headless
|
|
36
|
+
sessions.
|
|
28
37
|
- **Explicit external endpoint** → `CHROME_DEVTOOLS_AXI_BROWSER_URL`
|
|
29
38
|
(`http(s)://` or `ws(s)://`).
|
|
30
39
|
- **Native desktop apps / non-browser windows** → use `computer-use-axi`
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
import { createRequire as __axiRequire } from "node:module"; const require = __axiRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
BRIDGE_PORT_IN_USE_EXIT_CODE,
|
|
5
|
+
BRIDGE_PROFILE_IN_USE_EXIT_CODE,
|
|
6
|
+
CHROME_GENERATION_FLAG_PREFIX,
|
|
5
7
|
PAGE_IDENTITY_CHANGED_ERROR,
|
|
8
|
+
acquirePersistentProfileLease,
|
|
6
9
|
allocateOwnedProfileDir,
|
|
7
10
|
cleanupOwnedProfileDir,
|
|
8
11
|
clearSelectedPageId,
|
|
@@ -11,16 +14,23 @@ import {
|
|
|
11
14
|
isAttachTransportMode,
|
|
12
15
|
isAutoConnectMode,
|
|
13
16
|
isManagedIsolatedMode,
|
|
17
|
+
isPersistentProfileLeaseOwnedBy,
|
|
14
18
|
isSupervisorGone,
|
|
15
19
|
parseSupervisorAnchor,
|
|
20
|
+
preflightPersistentProfile,
|
|
21
|
+
pruneStaleSessionDirs,
|
|
16
22
|
readSelfStartTime,
|
|
23
|
+
reapPersistentProfileForDeadOwner,
|
|
17
24
|
reapStaleOwnedProfiles,
|
|
25
|
+
releasePersistentProfileLease,
|
|
26
|
+
resolvePersistentProfileDir,
|
|
18
27
|
resolveSessionLogFile,
|
|
19
28
|
resolveSessionName,
|
|
20
29
|
resolveSessionPidFile,
|
|
21
30
|
resolveSessionPort,
|
|
22
|
-
resolveSessionStateDir
|
|
23
|
-
|
|
31
|
+
resolveSessionStateDir,
|
|
32
|
+
terminateProfileHolders
|
|
33
|
+
} from "./chunk-D2OVVTF6.js";
|
|
24
34
|
import {
|
|
25
35
|
__commonJS,
|
|
26
36
|
__export,
|
|
@@ -19619,7 +19629,8 @@ function writePidFile(port, meta2 = {}) {
|
|
|
19619
19629
|
port,
|
|
19620
19630
|
startTime: readSelfStartTime(),
|
|
19621
19631
|
...meta2.mode ? { mode: meta2.mode } : {},
|
|
19622
|
-
...meta2.ownedProfileDir ? { ownedProfileDir: meta2.ownedProfileDir } : {}
|
|
19632
|
+
...meta2.ownedProfileDir ? { ownedProfileDir: meta2.ownedProfileDir } : {},
|
|
19633
|
+
...meta2.persistentProfileDir ? { persistentProfileDir: meta2.persistentProfileDir } : {}
|
|
19623
19634
|
})
|
|
19624
19635
|
);
|
|
19625
19636
|
}
|
|
@@ -20005,9 +20016,14 @@ function parseLauncherHeader(value) {
|
|
|
20005
20016
|
const startTime = colon === -1 ? void 0 : raw.slice(colon + 1);
|
|
20006
20017
|
return startTime ? { pid, startTime } : { pid };
|
|
20007
20018
|
}
|
|
20019
|
+
var DEFAULT_DISCONNECTED_IDLE_SHUTDOWN_MS = 2 * 6e4;
|
|
20008
20020
|
function createBridgeLifecycle(shutdown, opts = {}) {
|
|
20009
20021
|
const heartbeatMs = opts.heartbeatMs ?? DEFAULT_HEARTBEAT_MS;
|
|
20010
20022
|
const idleShutdownMs = opts.idleShutdownMs ?? DEFAULT_IDLE_SHUTDOWN_MS;
|
|
20023
|
+
const disconnectedIdleShutdownMs = Math.min(
|
|
20024
|
+
idleShutdownMs,
|
|
20025
|
+
opts.disconnectedIdleShutdownMs ?? DEFAULT_DISCONNECTED_IDLE_SHUTDOWN_MS
|
|
20026
|
+
);
|
|
20011
20027
|
const now = opts.now ?? Date.now;
|
|
20012
20028
|
const suspendIdleWhileSupervisorAlive = opts.suspendIdleWhileSupervisorAlive ?? true;
|
|
20013
20029
|
let supervisor;
|
|
@@ -20035,9 +20051,14 @@ function createBridgeLifecycle(shutdown, opts = {}) {
|
|
|
20035
20051
|
fire(`supervisor pid ${supervisor.pid} is gone and no requests since; shutting down`);
|
|
20036
20052
|
return;
|
|
20037
20053
|
}
|
|
20038
|
-
const
|
|
20039
|
-
|
|
20040
|
-
|
|
20054
|
+
const suspendIdle = typeof suspendIdleWhileSupervisorAlive === "function" ? suspendIdleWhileSupervisorAlive() : suspendIdleWhileSupervisorAlive;
|
|
20055
|
+
const disconnected = Boolean(opts.isDisconnected?.());
|
|
20056
|
+
const effectiveIdleMs = disconnected ? disconnectedIdleShutdownMs : idleShutdownMs;
|
|
20057
|
+
const supervisorSuspendsIdle = Boolean(supervisor) && suspendIdle && !disconnected;
|
|
20058
|
+
if (!supervisorSuspendsIdle && inFlightRequests === 0 && t - lastRequestAt >= effectiveIdleMs) {
|
|
20059
|
+
fire(
|
|
20060
|
+
disconnected ? `CDP disconnected and idle ${Math.round((t - lastRequestAt) / 1e3)}s \u2265 ${Math.round(effectiveIdleMs / 1e3)}s; shutting down` : `idle ${Math.round((t - lastRequestAt) / 1e3)}s \u2265 ${Math.round(idleShutdownMs / 1e3)}s with no requests; shutting down`
|
|
20061
|
+
);
|
|
20041
20062
|
return;
|
|
20042
20063
|
}
|
|
20043
20064
|
};
|
|
@@ -20089,7 +20110,7 @@ function buildTransportArgs(opts = {}) {
|
|
|
20089
20110
|
const args = ["-y", "chrome-devtools-mcp@1.13.0"];
|
|
20090
20111
|
const freshInstance = process.env.CHROME_DEVTOOLS_AXI_FRESH === "1";
|
|
20091
20112
|
const browserUrl = process.env.CHROME_DEVTOOLS_AXI_BROWSER_URL?.trim();
|
|
20092
|
-
const
|
|
20113
|
+
const persistentProfileDir = resolvePersistentProfileDir();
|
|
20093
20114
|
const channel = process.env.CHROME_DEVTOOLS_AXI_CHANNEL?.trim();
|
|
20094
20115
|
const autoConnect = !freshInstance && (process.env.CHROME_DEVTOOLS_AXI_AUTO_CONNECT === "1" || process.env.CHROME_DEVTOOLS_AXI_ATTACH === "1");
|
|
20095
20116
|
if (autoConnect) {
|
|
@@ -20129,8 +20150,11 @@ function buildTransportArgs(opts = {}) {
|
|
|
20129
20150
|
args.push(`--browserUrl=${browserUrl}`);
|
|
20130
20151
|
}
|
|
20131
20152
|
} else {
|
|
20132
|
-
if (
|
|
20133
|
-
args.push(`--userDataDir=${
|
|
20153
|
+
if (persistentProfileDir) {
|
|
20154
|
+
args.push(`--userDataDir=${persistentProfileDir}`);
|
|
20155
|
+
if (opts.persistentGenToken) {
|
|
20156
|
+
args.push(`--chrome-arg=${CHROME_GENERATION_FLAG_PREFIX}${opts.persistentGenToken}`);
|
|
20157
|
+
}
|
|
20134
20158
|
} else if (opts.ownedProfileDir) {
|
|
20135
20159
|
args.push(`--userDataDir=${opts.ownedProfileDir}`);
|
|
20136
20160
|
} else {
|
|
@@ -20490,9 +20514,82 @@ async function runBridge(port = resolveSessionPort()) {
|
|
|
20490
20514
|
const attachMode = isAttachTransportMode();
|
|
20491
20515
|
const autoConnect = isAutoConnectMode();
|
|
20492
20516
|
const managedIsolated = isManagedIsolatedMode();
|
|
20517
|
+
const persistentProfileDir = resolvePersistentProfileDir();
|
|
20493
20518
|
const modeFingerprint = computeTransportModeFingerprint();
|
|
20519
|
+
const selfOwner = { pid: process.pid, startTime: readSelfStartTime() };
|
|
20494
20520
|
void reapStaleOwnedProfiles(sessionStateDir, process.pid).catch(() => {
|
|
20495
20521
|
});
|
|
20522
|
+
try {
|
|
20523
|
+
pruneStaleSessionDirs({ excludeSession: sessionName });
|
|
20524
|
+
} catch {
|
|
20525
|
+
}
|
|
20526
|
+
let persistentProfileLeaseToken;
|
|
20527
|
+
let persistentGenToken;
|
|
20528
|
+
let launchedPersistentBrowser = false;
|
|
20529
|
+
if (persistentProfileDir) {
|
|
20530
|
+
mkdirSync(persistentProfileDir, { recursive: true, mode: 448 });
|
|
20531
|
+
let lease = acquirePersistentProfileLease(
|
|
20532
|
+
persistentProfileDir,
|
|
20533
|
+
sessionName,
|
|
20534
|
+
process.pid
|
|
20535
|
+
);
|
|
20536
|
+
if (!lease.acquired && lease.recoveryRequired) {
|
|
20537
|
+
const recovered = await reapPersistentProfileForDeadOwner(
|
|
20538
|
+
persistentProfileDir,
|
|
20539
|
+
lease.recoveryRequired
|
|
20540
|
+
);
|
|
20541
|
+
if (recovered.status === "reaped" || recovered.status === "not_owned") {
|
|
20542
|
+
lease = acquirePersistentProfileLease(
|
|
20543
|
+
persistentProfileDir,
|
|
20544
|
+
sessionName,
|
|
20545
|
+
process.pid
|
|
20546
|
+
);
|
|
20547
|
+
} else if (recovered.status === "busy") {
|
|
20548
|
+
logBridgeMessage(
|
|
20549
|
+
`Persistent profile "${persistentProfileDir}" is currently being recovered by another session`
|
|
20550
|
+
);
|
|
20551
|
+
process.exit(BRIDGE_PROFILE_IN_USE_EXIT_CODE);
|
|
20552
|
+
} else {
|
|
20553
|
+
logBridgeMessage(
|
|
20554
|
+
`Failed to recover stale persistent profile "${persistentProfileDir}" from dead session "${lease.recoveryRequired.sessionName}" (remaining=${recovered.remainingPids.join(",") || "unknown"})`
|
|
20555
|
+
);
|
|
20556
|
+
process.exit(1);
|
|
20557
|
+
}
|
|
20558
|
+
}
|
|
20559
|
+
if (!lease.acquired) {
|
|
20560
|
+
logBridgeMessage(
|
|
20561
|
+
`Persistent profile "${persistentProfileDir}" is already leased by session "${lease.conflictSession ?? "unknown"}" (pid ${lease.conflictPid ?? "unknown"})`
|
|
20562
|
+
);
|
|
20563
|
+
process.exit(BRIDGE_PROFILE_IN_USE_EXIT_CODE);
|
|
20564
|
+
}
|
|
20565
|
+
persistentProfileLeaseToken = lease.token;
|
|
20566
|
+
persistentGenToken = lease.genToken;
|
|
20567
|
+
const preflight = await preflightPersistentProfile(persistentProfileDir);
|
|
20568
|
+
if (preflight.kind === "in_use") {
|
|
20569
|
+
releasePersistentProfileLease(persistentProfileDir, {
|
|
20570
|
+
...selfOwner,
|
|
20571
|
+
token: persistentProfileLeaseToken
|
|
20572
|
+
});
|
|
20573
|
+
persistentProfileLeaseToken = void 0;
|
|
20574
|
+
persistentGenToken = void 0;
|
|
20575
|
+
logBridgeMessage(
|
|
20576
|
+
`Persistent profile "${persistentProfileDir}" is already in use by Chrome process(es): ${preflight.pids.join(", ")}`
|
|
20577
|
+
);
|
|
20578
|
+
process.exit(BRIDGE_PROFILE_IN_USE_EXIT_CODE);
|
|
20579
|
+
}
|
|
20580
|
+
if (preflight.kind === "unknown") {
|
|
20581
|
+
releasePersistentProfileLease(persistentProfileDir, {
|
|
20582
|
+
...selfOwner,
|
|
20583
|
+
token: persistentProfileLeaseToken
|
|
20584
|
+
});
|
|
20585
|
+
persistentProfileLeaseToken = void 0;
|
|
20586
|
+
persistentGenToken = void 0;
|
|
20587
|
+
logBridgeMessage(
|
|
20588
|
+
`Refusing persistent profile "${persistentProfileDir}" startup because process scan failed closed (${preflight.reason})`
|
|
20589
|
+
);
|
|
20590
|
+
process.exit(1);
|
|
20591
|
+
}
|
|
20592
|
+
}
|
|
20496
20593
|
const ownedProfile = managedIsolated ? allocateOwnedProfileDir(sessionStateDir, process.pid) : void 0;
|
|
20497
20594
|
let keepalive;
|
|
20498
20595
|
let lifecycle;
|
|
@@ -20530,6 +20627,35 @@ async function runBridge(port = resolveSessionPort()) {
|
|
|
20530
20627
|
);
|
|
20531
20628
|
if (finalExitCode === 0) finalExitCode = 1;
|
|
20532
20629
|
}
|
|
20630
|
+
} else if (persistentProfileDir && persistentProfileLeaseToken) {
|
|
20631
|
+
const tokenOwner = { ...selfOwner, token: persistentProfileLeaseToken };
|
|
20632
|
+
if (!launchedPersistentBrowser || !persistentGenToken) {
|
|
20633
|
+
cleanupConfirmed = releasePersistentProfileLease(persistentProfileDir, tokenOwner);
|
|
20634
|
+
if (cleanupConfirmed) persistentProfileLeaseToken = void 0;
|
|
20635
|
+
} else if (isPersistentProfileLeaseOwnedBy(persistentProfileDir, tokenOwner)) {
|
|
20636
|
+
const reaped = await terminateProfileHolders(persistentProfileDir, {
|
|
20637
|
+
generationToken: persistentGenToken
|
|
20638
|
+
}).catch(() => ({ clean: false, remainingPids: [] }));
|
|
20639
|
+
if (reaped.clean) {
|
|
20640
|
+
cleanupConfirmed = releasePersistentProfileLease(persistentProfileDir, tokenOwner);
|
|
20641
|
+
if (cleanupConfirmed) {
|
|
20642
|
+
persistentProfileLeaseToken = void 0;
|
|
20643
|
+
} else {
|
|
20644
|
+
logBridgeMessage(
|
|
20645
|
+
`Persistent profile lease release failed for ${persistentProfileDir}`
|
|
20646
|
+
);
|
|
20647
|
+
if (finalExitCode === 0) finalExitCode = 1;
|
|
20648
|
+
}
|
|
20649
|
+
} else {
|
|
20650
|
+
cleanupConfirmed = false;
|
|
20651
|
+
logBridgeMessage(
|
|
20652
|
+
`Persistent profile Chrome cleanup incomplete for ${persistentProfileDir} (remaining=${reaped.remainingPids.join(",") || "unknown"})`
|
|
20653
|
+
);
|
|
20654
|
+
if (finalExitCode === 0) finalExitCode = 1;
|
|
20655
|
+
}
|
|
20656
|
+
} else {
|
|
20657
|
+
cleanupConfirmed = true;
|
|
20658
|
+
}
|
|
20533
20659
|
} else {
|
|
20534
20660
|
cleanupConfirmed = true;
|
|
20535
20661
|
}
|
|
@@ -20554,12 +20680,32 @@ async function runBridge(port = resolveSessionPort()) {
|
|
|
20554
20680
|
try {
|
|
20555
20681
|
const selection = resolveTransport(
|
|
20556
20682
|
DEFAULT_MCP_PATH_PROBE,
|
|
20557
|
-
|
|
20683
|
+
{
|
|
20684
|
+
...ownedProfile ? { ownedProfileDir: ownedProfile.profileDir } : {},
|
|
20685
|
+
...persistentGenToken ? { persistentGenToken } : {}
|
|
20686
|
+
}
|
|
20558
20687
|
);
|
|
20688
|
+
if (persistentProfileDir) {
|
|
20689
|
+
launchedPersistentBrowser = true;
|
|
20690
|
+
}
|
|
20559
20691
|
bridgeTransport = createTransport(selection);
|
|
20560
20692
|
const client = createBridgeClient();
|
|
20561
20693
|
const bridgeClient = createRootsAwareBridgeClient(client, { autoConnect });
|
|
20562
20694
|
await client.connect(bridgeTransport.transport);
|
|
20695
|
+
if (shuttingDown) {
|
|
20696
|
+
return;
|
|
20697
|
+
}
|
|
20698
|
+
if (selection.kind === "stdio") {
|
|
20699
|
+
const prevOnClose = bridgeTransport.transport.onclose;
|
|
20700
|
+
bridgeTransport.transport.onclose = () => {
|
|
20701
|
+
prevOnClose?.();
|
|
20702
|
+
if (!shuttingDown) {
|
|
20703
|
+
bridgeClient.markDisconnected?.("MCP transport closed");
|
|
20704
|
+
logBridgeMessage("MCP stdio transport closed unexpectedly; shutting down");
|
|
20705
|
+
void shutdown(1);
|
|
20706
|
+
}
|
|
20707
|
+
};
|
|
20708
|
+
}
|
|
20563
20709
|
logBridgeMessage(`Connected to chrome-devtools-mcp (mode=${modeFingerprint})`);
|
|
20564
20710
|
const pendingDroppedSelectionLatch = { value: false };
|
|
20565
20711
|
if (attachMode) {
|
|
@@ -20591,15 +20737,17 @@ async function runBridge(port = resolveSessionPort()) {
|
|
|
20591
20737
|
modeFingerprint
|
|
20592
20738
|
);
|
|
20593
20739
|
const supervisorAnchor = parseSupervisorAnchor2();
|
|
20594
|
-
const suspendIdleWhileSupervisorAlive = attachMode;
|
|
20740
|
+
const suspendIdleWhileSupervisorAlive = attachMode ? () => bridgeClient.getStatus?.().cdpState === "connected" : false;
|
|
20741
|
+
const isDisconnected = attachMode ? () => bridgeClient.getStatus?.().cdpState === "failed" : void 0;
|
|
20595
20742
|
const idleShutdownMs = resolveIdleShutdownMs(attachMode);
|
|
20596
20743
|
lifecycle = createBridgeLifecycle(() => shutdown(0), {
|
|
20597
20744
|
anchor: supervisorAnchor,
|
|
20598
20745
|
idleShutdownMs,
|
|
20599
|
-
suspendIdleWhileSupervisorAlive
|
|
20746
|
+
suspendIdleWhileSupervisorAlive,
|
|
20747
|
+
...isDisconnected ? { isDisconnected } : {}
|
|
20600
20748
|
});
|
|
20601
20749
|
logBridgeMessage(
|
|
20602
|
-
`Lifecycle: mode=${modeFingerprint}, supervisor=${supervisorAnchor ? supervisorAnchor.pid : "none"}, idleMs=${idleShutdownMs}, suspendIdle=${
|
|
20750
|
+
`Lifecycle: mode=${modeFingerprint}, supervisor=${supervisorAnchor ? supervisorAnchor.pid : "none"}, idleMs=${idleShutdownMs}, suspendIdle=${attachMode ? "connected-only" : "false"}`
|
|
20603
20751
|
);
|
|
20604
20752
|
server.on("request", (req, res) => lifecycle?.observeRequest(req, res));
|
|
20605
20753
|
server.on("error", (error2) => {
|
|
@@ -20610,7 +20758,8 @@ async function runBridge(port = resolveSessionPort()) {
|
|
|
20610
20758
|
server.listen(port, "127.0.0.1", () => {
|
|
20611
20759
|
writePidFile(port, {
|
|
20612
20760
|
mode: modeFingerprint,
|
|
20613
|
-
...ownedProfile ? { ownedProfileDir: ownedProfile.profileDir } : {}
|
|
20761
|
+
...ownedProfile ? { ownedProfileDir: ownedProfile.profileDir } : {},
|
|
20762
|
+
...persistentProfileDir ? { persistentProfileDir } : {}
|
|
20614
20763
|
});
|
|
20615
20764
|
logBridgeMessage(`Listening on http://127.0.0.1:${port}`);
|
|
20616
20765
|
writeReadySignal();
|
|
@@ -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-
|
|
24
|
+
const { main } = await import("./cli-DJ36OIQ4.js");
|
|
25
25
|
await main(process.argv.slice(2));
|
|
26
26
|
}
|