@cydm/pie 4.4.2 → 4.5.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.
Files changed (48) 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 +364 -118
  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 +70 -19
  12. package/dist/builtin/extensions/pie-proc/index.js +27 -13
  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-OFLKAWI4.js → chunk-2CJIENLY.js} +90 -100
  24. package/dist/chunks/{chunk-R7VO46EK.js → chunk-3W3SXVPB.js} +5 -4
  25. package/dist/chunks/{chunk-IPLMGAML.js → chunk-5KI4Y4LA.js} +1 -1
  26. package/dist/chunks/{chunk-YNTIOWCD.js → chunk-BLDI2GRF.js} +5 -5
  27. package/dist/chunks/{chunk-UCKOXAME.js → chunk-CBDQJMUI.js} +9 -44
  28. package/dist/chunks/chunk-CGSFBWOM.js +100 -0
  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-2ATPC47M.js} +35 -5
  39. package/dist/chunks/manager-upgrade-5CPKTRJ7.js +562 -0
  40. package/dist/chunks/{model-registry-7FNIUYPF.js → model-registry-3XAHXXTA.js} +5 -5
  41. package/dist/chunks/{src-OVWRBWKU.js → src-B44QWSGM.js} +4 -4
  42. package/dist/chunks/{src-A5YI46OD.js → src-CLE5ILN4.js} +6 -6
  43. package/dist/chunks/{src-OA3TP6DS.js → src-EGXFJ3WA.js} +5 -5
  44. package/dist/chunks/{src-TF2RAGRU.js → src-Q7LU27C2.js} +3 -3
  45. package/dist/chunks/{test-stream-7YZDGBPO.js → test-stream-OR3EJBNF.js} +3 -3
  46. package/dist/cli.js +173 -136
  47. package/package.json +3 -3
  48. package/dist/chunks/chunk-7KLWHWZD.js +0 -164
@@ -2,7 +2,7 @@ import { createRequire as __createRequire } from "node:module"; const require =
2
2
  import {
3
3
  resolveCliProjectRoot
4
4
  } from "../../../chunks/chunk-WLFOBECN.js";
5
- import "../../../chunks/chunk-RZGYXAJU.js";
5
+ import "../../../chunks/chunk-LZQXQOPJ.js";
6
6
 
7
7
  // builtin/extensions/init/index.ts
8
8
  import fs from "node:fs";
@@ -1,13 +1,13 @@
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-BPSCGGVF.js";
4
+ } from "../../../chunks/chunk-XXGYUYXI.js";
5
5
  import {
6
6
  __commonJS,
7
7
  __export,
8
8
  __require,
9
9
  __toESM
10
- } from "../../../chunks/chunk-RZGYXAJU.js";
10
+ } from "../../../chunks/chunk-LZQXQOPJ.js";
11
11
 
12
12
  // ../../node_modules/isexe/windows.js
13
13
  var require_windows = __commonJS({
@@ -3,12 +3,11 @@ import {
3
3
  distillWorkerLogPath,
4
4
  readDistillWorkerLog,
5
5
  spawnDistillWorker
6
- } from "../../../chunks/chunk-IZDNZW3S.js";
6
+ } from "../../../chunks/chunk-Z2FKA2ZH.js";
7
7
  import {
8
8
  getConfigDir,
9
- getSettingsPath,
10
- init_config
11
- } from "../../../chunks/chunk-UCKOXAME.js";
9
+ getSettingsPath
10
+ } from "../../../chunks/chunk-CBDQJMUI.js";
12
11
  import {
13
12
  DEFAULT_MEMORY_INJECTION_BUDGET,
14
13
  MemoryStore,
@@ -20,19 +19,18 @@ import {
20
19
  saveAttestedEntry,
21
20
  searchMemory,
22
21
  todayKey
23
- } from "../../../chunks/chunk-YNTIOWCD.js";
24
- import "../../../chunks/chunk-XO3NM7BB.js";
25
- import "../../../chunks/chunk-IPLMGAML.js";
26
- import "../../../chunks/chunk-R7VO46EK.js";
22
+ } from "../../../chunks/chunk-BLDI2GRF.js";
23
+ import "../../../chunks/chunk-Y3I2UV5Y.js";
24
+ import "../../../chunks/chunk-5KI4Y4LA.js";
25
+ import "../../../chunks/chunk-3W3SXVPB.js";
27
26
  import {
28
27
  Type
29
- } from "../../../chunks/chunk-BPSCGGVF.js";
30
- import "../../../chunks/chunk-RZGYXAJU.js";
28
+ } from "../../../chunks/chunk-XXGYUYXI.js";
29
+ import "../../../chunks/chunk-LZQXQOPJ.js";
31
30
 
32
31
  // builtin/extensions/memory/index.ts
33
32
  import * as fs from "node:fs";
34
33
  import * as path from "node:path";
35
- init_config();
36
34
  function yesterdayKey() {
37
35
  const probe = /* @__PURE__ */ new Date();
38
36
  probe.setDate(probe.getDate() - 1);
@@ -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-BPSCGGVF.js";
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-OFLKAWI4.js";
29
- import "../../../chunks/chunk-RZGYXAJU.js";
30
+ } from "../../../chunks/chunk-2CJIENLY.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";
@@ -273,6 +276,7 @@ function windowsSecurity() {
273
276
  // builtin/extensions/pie-ipc/discovery.ts
274
277
  import * as path3 from "node:path";
275
278
  import { randomBytes as randomBytes2 } from "node:crypto";
279
+ import { fileURLToPath } from "node:url";
276
280
  function ipcDiscoveryDir(configDir) {
277
281
  return process.platform === "win32" ? `${canonicalWindowsDirectory(configDir)}\\run\\ipc` : path3.join(configDir, "run", "ipc");
278
282
  }
@@ -448,9 +452,32 @@ function buildStatusFile(input) {
448
452
  state: "idle",
449
453
  undeliveredInjections: 0,
450
454
  port: input.port,
451
- ...input.unattended === true ? { unattended: true } : {}
455
+ ...input.unattended === true ? { unattended: true } : {},
456
+ // 4.4.4: the running pie's version (upgrade visibility — the panel
457
+ // shows which peers are on stale code). Additive: old peers simply
458
+ // omit it and readers render "—".
459
+ ...piePackageVersion() ? { version: piePackageVersion() } : {}
452
460
  };
453
461
  }
462
+ function piePackageVersion() {
463
+ if (cachedVersion !== void 0) return cachedVersion || void 0;
464
+ try {
465
+ const here = path3.dirname(fileURLToPath(import.meta.url));
466
+ for (const up of [3, 4, 5]) {
467
+ const pkgPath = path3.resolve(here, ...Array(up).fill(".."), "package.json");
468
+ if (!fs2.existsSync(pkgPath)) continue;
469
+ const parsed = JSON.parse(fs2.readFileSync(pkgPath, "utf8"));
470
+ if (parsed.name === "@cydm/pie" && typeof parsed.version === "string") {
471
+ cachedVersion = parsed.version;
472
+ return parsed.version;
473
+ }
474
+ }
475
+ } catch {
476
+ }
477
+ cachedVersion = "";
478
+ return void 0;
479
+ }
480
+ var cachedVersion;
454
481
 
455
482
  // builtin/extensions/pie-ipc/delivery.ts
456
483
  var AllowPolicy = class {
@@ -841,6 +868,7 @@ var Runtime = class {
841
868
  this.displayName = config.displayName ?? peerLabel(this.instanceId);
842
869
  this.allowPolicy = new AllowPolicy(config.allowPeers ? [...config.allowPeers] : ["*"]);
843
870
  this.projection = new StatusProjection();
871
+ this.stopImBinding = onImBindingChanged(() => this.writeStatus());
844
872
  }
845
873
  ctx;
846
874
  config;
@@ -867,10 +895,9 @@ var Runtime = class {
867
895
  * Keyed like the old timer map so capacity counting and completion
868
896
  * cancellation cover the async query window too. */
869
897
  fallbackOps = /* @__PURE__ */ new Map();
870
- /** Notify-mode sends whose completion push already landed — including the
871
- * completion-BEFORE-ack window (the reverse push can win the race). Bounded
872
- * by the same retention discipline as the fallbacks: entries leave with
873
- * their timer or when the check hint fires. */
898
+ /** Bounded completion tombstones shared by push and fallback recovery,
899
+ * including completion-before-ack. Retained after ack to suppress late
900
+ * pushes; cleared on session change/disposal or capacity rollover. */
874
901
  completedNotifies = /* @__PURE__ */ new Set();
875
902
  /** Fresh pre-send probes by peer instance id (plan v2-A rate budget). */
876
903
  probeCache = /* @__PURE__ */ new Map();
@@ -894,6 +921,7 @@ var Runtime = class {
894
921
  sessionName;
895
922
  statusBase;
896
923
  stopHeartbeat = null;
924
+ stopImBinding;
897
925
  /** Server role: listen, advertise, watch peers. Publishes only after the
898
926
  * listener is up (headless instances never publish). */
899
927
  async startServer() {
@@ -937,7 +965,9 @@ var Runtime = class {
937
965
  sessionId: this.sessionId,
938
966
  sessionName: this.sessionName,
939
967
  ...displaySessionName ? { displaySessionName } : {},
940
- ...typeof model === "string" && model ? { model } : {}
968
+ ...typeof model === "string" && model ? { model } : {},
969
+ isManager: this.ctx.capabilities?.unattended === true && process.env.PIE_PROC_CURATED_NAME === "manager",
970
+ imBinding: currentImBinding()
941
971
  });
942
972
  return { ...snapshot, allowPeers: [...this.allowPolicy.snapshot()], undeliveredInjections: this.delivery?.undeliveredInjections ?? snapshot.undeliveredInjections ?? 0 };
943
973
  }
@@ -960,6 +990,14 @@ var Runtime = class {
960
990
  };
961
991
  switch (envelope.kind) {
962
992
  case "control": {
993
+ if (this.sessionId === null) {
994
+ reply("ack", JSON.stringify({ ok: false, message: "session binding in progress; retry shortly" }));
995
+ return;
996
+ }
997
+ if (envelope.sessionId !== this.sessionId) {
998
+ reply("ack", JSON.stringify({ ok: false, message: "target session changed" }));
999
+ return;
1000
+ }
963
1001
  if (!this.allowPolicy.allows(envelope.from)) {
964
1002
  reply("ack", JSON.stringify({ ok: false, message: "denied by local allow policy" }));
965
1003
  return;
@@ -1036,6 +1074,10 @@ var Runtime = class {
1036
1074
  }
1037
1075
  const doneMatch = /^\[ipc-done\] requestId=([a-zA-Z0-9:-]{1,128}) /.exec(envelope.text ?? "");
1038
1076
  if (doneMatch && this.allowPolicy.allows(envelope.from)) {
1077
+ if (this.completedNotifies.has(doneMatch[1])) {
1078
+ reply("ack", "completion already delivered");
1079
+ return;
1080
+ }
1039
1081
  const stampedDone = /^\[ipc-done\] requestId=[a-zA-Z0-9:-]{1,128} (?:outcome=\S+ )?(?:\([^)]*\) )?user_assigned=true(?:\s|$)/.test((envelope.text ?? "").split("\n")[0] ?? "");
1040
1082
  this.completeNotify(doneMatch[1], stampedDone);
1041
1083
  }
@@ -1213,10 +1255,7 @@ ${body}` : ""}`;
1213
1255
  * which the interactive host queues when busy and the embedded host
1214
1256
  * emits as a user.message event. */
1215
1257
  armNotifyFallback(requestId, fallbackMs, peerName, userAssigned = false, peerRef, targetIdentity) {
1216
- if (this.completedNotifies.has(requestId)) {
1217
- this.completedNotifies.delete(requestId);
1218
- return true;
1219
- }
1258
+ if (this.completedNotifies.has(requestId)) return true;
1220
1259
  if (this.fallbackOps.size >= 20) {
1221
1260
  this.ctx.log(`pie-ipc: fallback budget exhausted (${this.fallbackOps.size} outstanding); no timer for ${requestId}`);
1222
1261
  return false;
@@ -1253,8 +1292,20 @@ ${body}` : ""}`;
1253
1292
  finishOp();
1254
1293
  return;
1255
1294
  }
1256
- if (outcome === "terminal") {
1257
- this.ctx.log(`pie-ipc: fallback pull recovered a terminal result for ${requestId} (push was lost); no wake injected`);
1295
+ if (typeof outcome === "object") {
1296
+ void this.handleEnvelope({
1297
+ v: IPC_PROTOCOL_VERSION,
1298
+ id: `notify-${outcome.peer}-${requestId}`,
1299
+ from: outcome.peer,
1300
+ to: this.instanceId,
1301
+ kind: "message",
1302
+ createdAt: Date.now(),
1303
+ sessionId: this.sessionId ?? "",
1304
+ text: `[ipc-done] requestId=${requestId} outcome=${outcome.status}${userAssigned ? " user_assigned=true" : ""}
1305
+ ${outcome.text}`
1306
+ }, () => {
1307
+ });
1308
+ this.ctx.log(`pie-ipc: fallback pull recovered a terminal result for ${requestId}`);
1258
1309
  finishOp();
1259
1310
  return;
1260
1311
  }
@@ -1298,7 +1349,7 @@ ${body}` : ""}`;
1298
1349
  const snapshot = readStatusFile(this.discoveryDir, instanceId);
1299
1350
  if (!snapshot?.port) return "unknown";
1300
1351
  port = snapshot.port;
1301
- sessionId = snapshot.sessionId ?? "";
1352
+ sessionId = targetIdentity?.sessionId ?? "";
1302
1353
  } else {
1303
1354
  const target = this.resolvePeer(peerRef);
1304
1355
  if (!target?.port) return "unknown";
@@ -1318,9 +1369,8 @@ ${body}` : ""}`;
1318
1369
  if (!reply?.text) return "unknown";
1319
1370
  const parsed = JSON.parse(reply.text);
1320
1371
  if (parsed.status === "done" || parsed.status === "failed") {
1321
- if (this.completedNotifies.size > 200) this.completedNotifies.clear();
1322
- this.completedNotifies.add(requestId);
1323
- return "terminal";
1372
+ if (parsed.requestId !== requestId || parsed.sessionId !== sessionId || !this.allowPolicy.allows(instanceId)) return "unknown";
1373
+ return { peer: instanceId, status: parsed.status, text: typeof parsed.text === "string" ? parsed.text : "" };
1324
1374
  }
1325
1375
  if (parsed.status === "accepted" || parsed.status === "running") return "running";
1326
1376
  return "unknown";
@@ -1672,6 +1722,7 @@ ${message.text}`).join("\n---\n");
1672
1722
  dispose() {
1673
1723
  this.disposed = true;
1674
1724
  this.stopHeartbeat?.();
1725
+ this.stopImBinding();
1675
1726
  this.delivery?.resetSessionState();
1676
1727
  this.polledInputs.clear();
1677
1728
  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-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 {
@@ -550,8 +556,16 @@ function pieProc(ctx) {
550
556
  PIE_IPC_CONFIG_DIR: inheritedIpcRoot,
551
557
  PIE_IPC_DISPLAY_NAME: params.kind === "resident" ? params.name : process.env.PIE_IPC_DISPLAY_NAME
552
558
  };
553
- if (params.kind === "oneshot") childEnv[ONESHOT_TASK_ENV] = params.task ?? "";
554
- if (resumeSessionId) childEnv.PIE_SESSIONS_DIR = resolveOperatorSessionsDir();
559
+ if (params.kind === "oneshot") {
560
+ childEnv[ONESHOT_TASK_ENV] = params.task ?? "";
561
+ const explicitTimeout = Number(childEnv.PIE_PRINT_TURN_TIMEOUT_MS);
562
+ const validOverride = Number.isFinite(explicitTimeout) && explicitTimeout > 0 && String(explicitTimeout) === String(childEnv.PIE_PRINT_TURN_TIMEOUT_MS).trim();
563
+ if (childEnv.PIE_PRINT_TURN_TIMEOUT_MS === "0") {
564
+ } else if (!validOverride) {
565
+ childEnv.PIE_PRINT_TURN_TIMEOUT_MS = "1800000";
566
+ }
567
+ }
568
+ if (resumeSessionId && resumeSessionsDir !== void 0) childEnv.PIE_SESSIONS_DIR = resumeSessionsDir;
555
569
  try {
556
570
  child = spawn(process.execPath, args, {
557
571
  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
  }