@cydm/pie 4.4.2 → 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.
- package/dist/builtin/extensions/ask-user/index.js +6 -6
- package/dist/builtin/extensions/changelog/index.js +1 -1
- package/dist/builtin/extensions/cron/index.js +55 -7
- package/dist/builtin/extensions/document-attachments/index.js +1 -1
- package/dist/builtin/extensions/herdr-agent-state/index.js +1 -1
- package/dist/builtin/extensions/im-forward/README.md +3 -1
- package/dist/builtin/extensions/im-forward/index.js +98 -41
- package/dist/builtin/extensions/init/index.js +1 -1
- package/dist/builtin/extensions/mcp-adapter/index.js +2 -2
- package/dist/builtin/extensions/memory/index.js +9 -11
- package/dist/builtin/extensions/pie-ipc/index.js +45 -18
- package/dist/builtin/extensions/pie-proc/index.js +18 -12
- package/dist/builtin/extensions/plan-mode/index.js +6 -6
- package/dist/builtin/extensions/subagent/index.js +9 -11
- package/dist/builtin/extensions/todo/index.js +6 -6
- package/dist/builtin/skills/chrome-devtools-axi/SKILL.md +24 -1
- package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-bridge.js +86 -21
- package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-cli.js +6 -1
- package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-runtime.js +1 -1
- package/dist/builtin/skills/chrome-devtools-axi/{cli-CHC7XYFU.js → cli-NLPMVDGG.js} +32 -4
- package/dist/builtin/skills/computer-use-axi/computer-use-axi-broker.js +220 -22
- package/dist/chunks/{auth-storage-RABPRJ6T.js → auth-storage-C3FZMT7J.js} +3 -3
- package/dist/chunks/{chunk-R7VO46EK.js → chunk-3W3SXVPB.js} +5 -4
- package/dist/chunks/{chunk-IPLMGAML.js → chunk-5KI4Y4LA.js} +1 -1
- package/dist/chunks/{chunk-YNTIOWCD.js → chunk-BLDI2GRF.js} +5 -5
- package/dist/chunks/{chunk-UCKOXAME.js → chunk-CBDQJMUI.js} +9 -44
- package/dist/chunks/chunk-CGSFBWOM.js +100 -0
- package/dist/chunks/{chunk-OFLKAWI4.js → chunk-JMKLTTZQ.js} +89 -100
- package/dist/chunks/{chunk-7LTQLJJF.js → chunk-LAJXWOKS.js} +15 -10
- package/dist/chunks/{chunk-RZGYXAJU.js → chunk-LZQXQOPJ.js} +1 -12
- package/dist/chunks/{chunk-EQOI6RZV.js → chunk-NHV2CALB.js} +3 -5
- package/dist/chunks/{chunk-OV7SLSHR.js → chunk-SW2E33UL.js} +2 -4
- package/dist/chunks/{chunk-BPSCGGVF.js → chunk-XXGYUYXI.js} +1 -1
- package/dist/chunks/{chunk-XO3NM7BB.js → chunk-Y3I2UV5Y.js} +3 -3
- package/dist/chunks/{chunk-IZDNZW3S.js → chunk-Z2FKA2ZH.js} +8 -8
- package/dist/chunks/chunk-ZPJ3BNQB.js +126 -0
- package/dist/chunks/{config-HF2PDLN5.js → config-4EOI5NOU.js} +2 -4
- package/dist/chunks/{manager-cli-BYCF4RKN.js → manager-cli-WEHNUV5T.js} +3 -5
- package/dist/chunks/{model-registry-7FNIUYPF.js → model-registry-3XAHXXTA.js} +5 -5
- package/dist/chunks/{src-OVWRBWKU.js → src-B44QWSGM.js} +4 -4
- package/dist/chunks/{src-A5YI46OD.js → src-CLE5ILN4.js} +6 -6
- package/dist/chunks/{src-OA3TP6DS.js → src-EGXFJ3WA.js} +5 -5
- package/dist/chunks/{src-TF2RAGRU.js → src-Q7LU27C2.js} +3 -3
- package/dist/chunks/{test-stream-7YZDGBPO.js → test-stream-OR3EJBNF.js} +3 -3
- package/dist/cli.js +128 -132
- package/package.json +3 -3
- package/dist/chunks/chunk-7KLWHWZD.js +0 -164
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
Type
|
|
4
|
-
} from "../../../chunks/chunk-
|
|
4
|
+
} from "../../../chunks/chunk-XXGYUYXI.js";
|
|
5
5
|
import {
|
|
6
6
|
DEFAULT_SEND_WAIT_MS,
|
|
7
7
|
DISPATCH_PREFIX,
|
|
@@ -13,11 +13,13 @@ import {
|
|
|
13
13
|
MAX_STATUS_FILE_BYTES,
|
|
14
14
|
assistantBodyText,
|
|
15
15
|
clipBody,
|
|
16
|
+
currentImBinding,
|
|
16
17
|
foldLifecycleEvent,
|
|
17
18
|
generateInstanceId,
|
|
18
19
|
isTurnUserImDriven,
|
|
19
20
|
isValidInstanceId,
|
|
20
21
|
isWrappedInboundText,
|
|
22
|
+
onImBindingChanged,
|
|
21
23
|
parseStatusFile,
|
|
22
24
|
peerHealth,
|
|
23
25
|
peerLabel,
|
|
@@ -25,8 +27,9 @@ import {
|
|
|
25
27
|
takeDispatchFrame,
|
|
26
28
|
wrapInboundText,
|
|
27
29
|
wrappedMessageMarker
|
|
28
|
-
} from "../../../chunks/chunk-
|
|
29
|
-
import "../../../chunks/chunk-
|
|
30
|
+
} from "../../../chunks/chunk-JMKLTTZQ.js";
|
|
31
|
+
import "../../../chunks/chunk-ZPJ3BNQB.js";
|
|
32
|
+
import "../../../chunks/chunk-LZQXQOPJ.js";
|
|
30
33
|
|
|
31
34
|
// builtin/extensions/pie-ipc/index.ts
|
|
32
35
|
import * as fs3 from "node:fs";
|
|
@@ -841,6 +844,7 @@ var Runtime = class {
|
|
|
841
844
|
this.displayName = config.displayName ?? peerLabel(this.instanceId);
|
|
842
845
|
this.allowPolicy = new AllowPolicy(config.allowPeers ? [...config.allowPeers] : ["*"]);
|
|
843
846
|
this.projection = new StatusProjection();
|
|
847
|
+
this.stopImBinding = onImBindingChanged(() => this.writeStatus());
|
|
844
848
|
}
|
|
845
849
|
ctx;
|
|
846
850
|
config;
|
|
@@ -867,10 +871,9 @@ var Runtime = class {
|
|
|
867
871
|
* Keyed like the old timer map so capacity counting and completion
|
|
868
872
|
* cancellation cover the async query window too. */
|
|
869
873
|
fallbackOps = /* @__PURE__ */ new Map();
|
|
870
|
-
/**
|
|
871
|
-
* completion-
|
|
872
|
-
*
|
|
873
|
-
* their timer or when the check hint fires. */
|
|
874
|
+
/** Bounded completion tombstones shared by push and fallback recovery,
|
|
875
|
+
* including completion-before-ack. Retained after ack to suppress late
|
|
876
|
+
* pushes; cleared on session change/disposal or capacity rollover. */
|
|
874
877
|
completedNotifies = /* @__PURE__ */ new Set();
|
|
875
878
|
/** Fresh pre-send probes by peer instance id (plan v2-A rate budget). */
|
|
876
879
|
probeCache = /* @__PURE__ */ new Map();
|
|
@@ -894,6 +897,7 @@ var Runtime = class {
|
|
|
894
897
|
sessionName;
|
|
895
898
|
statusBase;
|
|
896
899
|
stopHeartbeat = null;
|
|
900
|
+
stopImBinding;
|
|
897
901
|
/** Server role: listen, advertise, watch peers. Publishes only after the
|
|
898
902
|
* listener is up (headless instances never publish). */
|
|
899
903
|
async startServer() {
|
|
@@ -937,7 +941,9 @@ var Runtime = class {
|
|
|
937
941
|
sessionId: this.sessionId,
|
|
938
942
|
sessionName: this.sessionName,
|
|
939
943
|
...displaySessionName ? { displaySessionName } : {},
|
|
940
|
-
...typeof model === "string" && model ? { model } : {}
|
|
944
|
+
...typeof model === "string" && model ? { model } : {},
|
|
945
|
+
isManager: this.ctx.capabilities?.unattended === true && process.env.PIE_PROC_CURATED_NAME === "manager",
|
|
946
|
+
imBinding: currentImBinding()
|
|
941
947
|
});
|
|
942
948
|
return { ...snapshot, allowPeers: [...this.allowPolicy.snapshot()], undeliveredInjections: this.delivery?.undeliveredInjections ?? snapshot.undeliveredInjections ?? 0 };
|
|
943
949
|
}
|
|
@@ -960,6 +966,14 @@ var Runtime = class {
|
|
|
960
966
|
};
|
|
961
967
|
switch (envelope.kind) {
|
|
962
968
|
case "control": {
|
|
969
|
+
if (this.sessionId === null) {
|
|
970
|
+
reply("ack", JSON.stringify({ ok: false, message: "session binding in progress; retry shortly" }));
|
|
971
|
+
return;
|
|
972
|
+
}
|
|
973
|
+
if (envelope.sessionId !== this.sessionId) {
|
|
974
|
+
reply("ack", JSON.stringify({ ok: false, message: "target session changed" }));
|
|
975
|
+
return;
|
|
976
|
+
}
|
|
963
977
|
if (!this.allowPolicy.allows(envelope.from)) {
|
|
964
978
|
reply("ack", JSON.stringify({ ok: false, message: "denied by local allow policy" }));
|
|
965
979
|
return;
|
|
@@ -1036,6 +1050,10 @@ var Runtime = class {
|
|
|
1036
1050
|
}
|
|
1037
1051
|
const doneMatch = /^\[ipc-done\] requestId=([a-zA-Z0-9:-]{1,128}) /.exec(envelope.text ?? "");
|
|
1038
1052
|
if (doneMatch && this.allowPolicy.allows(envelope.from)) {
|
|
1053
|
+
if (this.completedNotifies.has(doneMatch[1])) {
|
|
1054
|
+
reply("ack", "completion already delivered");
|
|
1055
|
+
return;
|
|
1056
|
+
}
|
|
1039
1057
|
const stampedDone = /^\[ipc-done\] requestId=[a-zA-Z0-9:-]{1,128} (?:outcome=\S+ )?(?:\([^)]*\) )?user_assigned=true(?:\s|$)/.test((envelope.text ?? "").split("\n")[0] ?? "");
|
|
1040
1058
|
this.completeNotify(doneMatch[1], stampedDone);
|
|
1041
1059
|
}
|
|
@@ -1213,10 +1231,7 @@ ${body}` : ""}`;
|
|
|
1213
1231
|
* which the interactive host queues when busy and the embedded host
|
|
1214
1232
|
* emits as a user.message event. */
|
|
1215
1233
|
armNotifyFallback(requestId, fallbackMs, peerName, userAssigned = false, peerRef, targetIdentity) {
|
|
1216
|
-
if (this.completedNotifies.has(requestId))
|
|
1217
|
-
this.completedNotifies.delete(requestId);
|
|
1218
|
-
return true;
|
|
1219
|
-
}
|
|
1234
|
+
if (this.completedNotifies.has(requestId)) return true;
|
|
1220
1235
|
if (this.fallbackOps.size >= 20) {
|
|
1221
1236
|
this.ctx.log(`pie-ipc: fallback budget exhausted (${this.fallbackOps.size} outstanding); no timer for ${requestId}`);
|
|
1222
1237
|
return false;
|
|
@@ -1253,8 +1268,20 @@ ${body}` : ""}`;
|
|
|
1253
1268
|
finishOp();
|
|
1254
1269
|
return;
|
|
1255
1270
|
}
|
|
1256
|
-
if (outcome === "
|
|
1257
|
-
this.
|
|
1271
|
+
if (typeof outcome === "object") {
|
|
1272
|
+
void this.handleEnvelope({
|
|
1273
|
+
v: IPC_PROTOCOL_VERSION,
|
|
1274
|
+
id: `notify-${outcome.peer}-${requestId}`,
|
|
1275
|
+
from: outcome.peer,
|
|
1276
|
+
to: this.instanceId,
|
|
1277
|
+
kind: "message",
|
|
1278
|
+
createdAt: Date.now(),
|
|
1279
|
+
sessionId: this.sessionId ?? "",
|
|
1280
|
+
text: `[ipc-done] requestId=${requestId} outcome=${outcome.status}${userAssigned ? " user_assigned=true" : ""}
|
|
1281
|
+
${outcome.text}`
|
|
1282
|
+
}, () => {
|
|
1283
|
+
});
|
|
1284
|
+
this.ctx.log(`pie-ipc: fallback pull recovered a terminal result for ${requestId}`);
|
|
1258
1285
|
finishOp();
|
|
1259
1286
|
return;
|
|
1260
1287
|
}
|
|
@@ -1298,7 +1325,7 @@ ${body}` : ""}`;
|
|
|
1298
1325
|
const snapshot = readStatusFile(this.discoveryDir, instanceId);
|
|
1299
1326
|
if (!snapshot?.port) return "unknown";
|
|
1300
1327
|
port = snapshot.port;
|
|
1301
|
-
sessionId =
|
|
1328
|
+
sessionId = targetIdentity?.sessionId ?? "";
|
|
1302
1329
|
} else {
|
|
1303
1330
|
const target = this.resolvePeer(peerRef);
|
|
1304
1331
|
if (!target?.port) return "unknown";
|
|
@@ -1318,9 +1345,8 @@ ${body}` : ""}`;
|
|
|
1318
1345
|
if (!reply?.text) return "unknown";
|
|
1319
1346
|
const parsed = JSON.parse(reply.text);
|
|
1320
1347
|
if (parsed.status === "done" || parsed.status === "failed") {
|
|
1321
|
-
if (
|
|
1322
|
-
|
|
1323
|
-
return "terminal";
|
|
1348
|
+
if (parsed.requestId !== requestId || parsed.sessionId !== sessionId || !this.allowPolicy.allows(instanceId)) return "unknown";
|
|
1349
|
+
return { peer: instanceId, status: parsed.status, text: typeof parsed.text === "string" ? parsed.text : "" };
|
|
1324
1350
|
}
|
|
1325
1351
|
if (parsed.status === "accepted" || parsed.status === "running") return "running";
|
|
1326
1352
|
return "unknown";
|
|
@@ -1672,6 +1698,7 @@ ${message.text}`).join("\n---\n");
|
|
|
1672
1698
|
dispose() {
|
|
1673
1699
|
this.disposed = true;
|
|
1674
1700
|
this.stopHeartbeat?.();
|
|
1701
|
+
this.stopImBinding();
|
|
1675
1702
|
this.delivery?.resetSessionState();
|
|
1676
1703
|
this.polledInputs.clear();
|
|
1677
1704
|
this.results.clear();
|
|
@@ -4,12 +4,13 @@ import {
|
|
|
4
4
|
} from "../../../chunks/chunk-X6LBWHK3.js";
|
|
5
5
|
import {
|
|
6
6
|
liveSessionHolder
|
|
7
|
-
} from "../../../chunks/chunk-
|
|
8
|
-
import "../../../chunks/chunk-
|
|
7
|
+
} from "../../../chunks/chunk-CGSFBWOM.js";
|
|
8
|
+
import "../../../chunks/chunk-CBDQJMUI.js";
|
|
9
9
|
import {
|
|
10
10
|
Type
|
|
11
|
-
} from "../../../chunks/chunk-
|
|
12
|
-
import "../../../chunks/chunk-
|
|
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
|
|
427
|
-
const
|
|
428
|
+
const operatorSessionsDir = resolveOperatorSessionsDir();
|
|
429
|
+
const workerSessionsDir = path.join(pieProcDir(), "agents", params.name, "sessions");
|
|
428
430
|
let recordedCwd;
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
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 =
|
|
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-
|
|
10
|
-
import "../../../chunks/chunk-
|
|
11
|
-
import "../../../chunks/chunk-
|
|
12
|
-
import "../../../chunks/chunk-
|
|
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-
|
|
16
|
-
import "../../../chunks/chunk-
|
|
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-
|
|
8
|
+
} from "../../../chunks/chunk-LAJXWOKS.js";
|
|
9
9
|
import {
|
|
10
|
-
getConfigDir
|
|
11
|
-
|
|
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-
|
|
19
|
-
import "../../../chunks/chunk-
|
|
20
|
-
import "../../../chunks/chunk-
|
|
21
|
-
import "../../../chunks/chunk-
|
|
22
|
-
import "../../../chunks/chunk-
|
|
23
|
-
import "../../../chunks/chunk-
|
|
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-
|
|
12
|
-
import "../../../chunks/chunk-
|
|
13
|
-
import "../../../chunks/chunk-
|
|
14
|
-
import "../../../chunks/chunk-
|
|
15
|
-
import "../../../chunks/chunk-
|
|
16
|
-
import "../../../chunks/chunk-
|
|
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.
|
|
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@
|
|
19955
|
-
const
|
|
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
|
-
|
|
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
|
|
20025
|
-
"node_modules",
|
|
20026
|
-
|
|
20027
|
-
|
|
20028
|
-
|
|
20029
|
-
|
|
20030
|
-
|
|
20031
|
-
|
|
20032
|
-
|
|
20033
|
-
|
|
20034
|
-
|
|
20035
|
-
|
|
20036
|
-
|
|
20037
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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-
|
|
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
|
-
|
|
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
|
|
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";
|