@cydm/pie 2.8.1 → 3.0.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 (26) hide show
  1. package/dist/builtin/extensions/ask-user/index.js +2 -2
  2. package/dist/builtin/extensions/changelog/index.js +2 -2
  3. package/dist/builtin/extensions/cron/index.js +167 -14
  4. package/dist/builtin/extensions/document-attachments/index.js +1 -1
  5. package/dist/builtin/extensions/herdr-agent-state/index.js +2 -2
  6. package/dist/builtin/extensions/memory/index.js +15 -13
  7. package/dist/builtin/extensions/plan-mode/index.js +2 -2
  8. package/dist/builtin/extensions/subagent/index.js +4 -4
  9. package/dist/builtin/extensions/todo/index.js +2 -2
  10. package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-bridge.js +106 -2
  11. package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-cli.js +1 -0
  12. package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-runtime.js +1 -1
  13. package/dist/builtin/skills/chrome-devtools-axi/{chunk-BNSAEVRT.js → chunk-WOGAQ4P5.js} +2 -2
  14. package/dist/builtin/skills/chrome-devtools-axi/{cli-AO2ZTPRM.js → cli-CHC7XYFU.js} +27 -3
  15. package/dist/builtin/skills/computer-use-axi/computer-use-axi-broker.js +2 -2
  16. package/dist/builtin/skills/computer-use-axi/computer-use-axi-cli.js +1 -0
  17. package/dist/builtin/skills/computer-use-axi/scripts/setup-helper.mjs +6 -2
  18. package/dist/builtin/skills/tui-use/tui-use-daemon.cjs +130 -9
  19. package/dist/chunks/{chunk-RSL7E4R7.js → chunk-3FRKOFSP.js} +34 -1
  20. package/dist/chunks/{chunk-PK72LVWQ.js → chunk-7FEPQHYX.js} +1 -1
  21. package/dist/chunks/{chunk-GDIYSMTS.js → chunk-BUDXV3TR.js} +24 -16
  22. package/dist/chunks/{chunk-3NHP7HK5.js → chunk-OEQYEYB3.js} +4 -3
  23. package/dist/chunks/{src-BPSQMSSC.js → src-AE3OCAE6.js} +2 -2
  24. package/dist/chunks/{src-OPPYTPWG.js → src-RVTDUSPJ.js} +9 -1
  25. package/dist/cli.js +495 -85
  26. package/package.json +4 -4
@@ -1,8 +1,8 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  createAskUserCapability
4
- } from "../../../chunks/chunk-PK72LVWQ.js";
5
- import "../../../chunks/chunk-RSL7E4R7.js";
4
+ } from "../../../chunks/chunk-7FEPQHYX.js";
5
+ import "../../../chunks/chunk-3FRKOFSP.js";
6
6
  import "../../../chunks/chunk-GH4VW2OT.js";
7
7
  import "../../../chunks/chunk-3BC5KGDQ.js";
8
8
  import "../../../chunks/chunk-XXGYUYXI.js";
@@ -12,7 +12,7 @@ function getRecentCommits(cwd, count = 10) {
12
12
  const result = spawnSync(
13
13
  "git",
14
14
  ["log", `--max-count=${count}`, "--pretty=format:%h %s", "--no-merges"],
15
- { cwd, encoding: "utf8" }
15
+ { cwd, encoding: "utf8", windowsHide: true }
16
16
  );
17
17
  return result.status === 0 ? result.stdout : "";
18
18
  } catch {
@@ -24,7 +24,7 @@ function getChangedFiles(cwd) {
24
24
  const result = spawnSync(
25
25
  "git",
26
26
  ["diff", RECENT_COMMIT_RANGE, "--name-only", "--stat"],
27
- { cwd, encoding: "utf8" }
27
+ { cwd, encoding: "utf8", windowsHide: true }
28
28
  );
29
29
  return result.status === 0 ? result.stdout : "";
30
30
  } catch {
@@ -100,16 +100,155 @@ var Store = class {
100
100
  * stale bytes over a newer foreign save. */
101
101
  lastSavedContent;
102
102
  transaction(fn) {
103
- const lock = path.join(this.dir, "write.lock");
104
- fs.mkdirSync(lock, { mode: 448 });
105
- try {
103
+ return this.withWriteLock(() => {
106
104
  this.calibrateCache();
107
105
  const state = this.read();
108
106
  const result = fn(state);
109
107
  this.save(state);
110
108
  return result;
109
+ });
110
+ }
111
+ /** Run fn under the cross-process write mutex. Also used for coordinator
112
+ * election/release, which never nest a state transaction. */
113
+ withWriteLock(fn) {
114
+ const lock = path.join(this.dir, "write.lock");
115
+ const token = this.acquireWriteLock(lock);
116
+ try {
117
+ return fn();
118
+ } finally {
119
+ this.releaseWriteLock(lock, token);
120
+ }
121
+ }
122
+ /** Mutex protocol (generation-safe; no ABA / no TOCTOU on the canonical path):
123
+ * - Acquisition builds a fully-formed candidate dir `write.lock.acquire.<uuid>`
124
+ * containing our `held.<uuid>` entry (pid), then atomically RENAMES it onto
125
+ * the canonical `write.lock`. POSIX rename can displace an EMPTY existing
126
+ * directory (a releasing holder's post-unlink state, or manual debris); a
127
+ * non-empty target fails (ENOTEMPTY/EEXIST/EPERM). So the canonical path
128
+ * only ever transitions absent→held or empty→held, never live→replaced.
129
+ * - Empty-dir takeover is safe ONLY for release leftovers: a holder unlinks
130
+ * its entry only AFTER leaving its critical section. Manual/legacy empty
131
+ * locks are equally taken over — an empty dir proves no cooperative
132
+ * writer is inside — which replaces the old permanent-deadlock behavior
133
+ * with bounded manual-recovery documented in docs/cron.md (tests updated).
134
+ * - Release: unlink OUR entry, then rmdir if empty. A crash before unlink
135
+ * leaves a dead-pid entry (recoverable); after unlink it leaves an empty
136
+ * dir, which the next contender takes over legitimately.
137
+ * - Crash recovery on contention: every `held.*` entry must record a
138
+ * PROVABLY DEAD pid (ESRCH only); exactly those verified entries are
139
+ * unlinked and the emptied dir removed, then the install retried once.
140
+ * Entries have unique uuid names, so a delayed reclaimer only deletes
141
+ * names it verified — it can never touch a successor's fresh generation.
142
+ * Unreadable/malformed metadata or junk files: fail closed (contention).
143
+ * - `write.lock.acquire.*` debris can only appear from a crash mid-acquire
144
+ * (before the rename); it is inert — the protocol never consults it. */
145
+ acquireWriteLock(lock) {
146
+ const token = randomUUID();
147
+ const candidate = path.join(this.dir, `write.lock.acquire.${token}`);
148
+ try {
149
+ fs.mkdirSync(candidate, { mode: 448 });
150
+ try {
151
+ this.writeHolderEntry(candidate, token);
152
+ } catch (error) {
153
+ try {
154
+ fs.rmSync(candidate, { recursive: true, force: true });
155
+ } catch {
156
+ }
157
+ throw error;
158
+ }
159
+ const deadline = Date.now() + 2e3;
160
+ for (let spin = 0; ; spin++) {
161
+ try {
162
+ fs.renameSync(candidate, lock);
163
+ return token;
164
+ } catch (error) {
165
+ const code = error?.code;
166
+ if (code !== "EEXIST" && code !== "ENOTEMPTY" && code !== "EPERM" && code !== "ENOTDIR") throw error;
167
+ if (Date.now() > deadline) throw this.contentionError(lock);
168
+ try {
169
+ this.retireWriteLock(lock);
170
+ } catch {
171
+ }
172
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 1 + Math.floor(Math.random() * 3));
173
+ }
174
+ }
111
175
  } finally {
176
+ try {
177
+ fs.rmSync(candidate, { recursive: true, force: true });
178
+ } catch {
179
+ }
180
+ }
181
+ }
182
+ writeHolderEntry(dir, token) {
183
+ fs.writeFileSync(path.join(dir, `held.${token}`), JSON.stringify({ version: 1, pid: process.pid, createdAt: Date.now() }), { mode: 384, flag: "wx" });
184
+ }
185
+ releaseWriteLock(lock, token) {
186
+ try {
187
+ fs.unlinkSync(path.join(lock, `held.${token}`));
188
+ } catch {
189
+ }
190
+ try {
191
+ const remaining = fs.readdirSync(lock);
192
+ if (remaining.length === 0) fs.rmdirSync(lock);
193
+ } catch {
194
+ }
195
+ }
196
+ contentionError(lock) {
197
+ const error = new Error(`EEXIST: file already exists, mkdir '${lock}'`);
198
+ error.code = "EEXIST";
199
+ error.errno = -17;
200
+ error.syscall = "mkdir";
201
+ error.path = lock;
202
+ return error;
203
+ }
204
+ /** Remove the stale canonical lock so an install can proceed. Returns true
205
+ * when the canonical path is now free for a rename. */
206
+ retireWriteLock(lock) {
207
+ let entries;
208
+ try {
209
+ entries = fs.readdirSync(lock);
210
+ } catch {
211
+ return false;
212
+ }
213
+ const holders = entries.filter((name) => name.startsWith("held."));
214
+ if (holders.length === 0) {
215
+ if (entries.length !== 0) return false;
216
+ try {
217
+ fs.rmdirSync(lock);
218
+ return true;
219
+ } catch {
220
+ return false;
221
+ }
222
+ }
223
+ for (const name of holders) {
224
+ let pid;
225
+ try {
226
+ const parsed = JSON.parse(fs.readFileSync(path.join(lock, name), "utf8"));
227
+ if (parsed?.version !== 1 || !Number.isInteger(parsed.pid) || parsed.pid <= 0) return false;
228
+ pid = parsed.pid;
229
+ } catch {
230
+ return false;
231
+ }
232
+ try {
233
+ process.kill(pid, 0);
234
+ return false;
235
+ } catch (error) {
236
+ if (error?.code !== "ESRCH") return false;
237
+ }
238
+ }
239
+ for (const name of holders) {
240
+ try {
241
+ fs.unlinkSync(path.join(lock, name));
242
+ } catch (error) {
243
+ if (error?.code === "ENOENT") continue;
244
+ return false;
245
+ }
246
+ }
247
+ try {
112
248
  fs.rmdirSync(lock);
249
+ return true;
250
+ } catch {
251
+ return false;
113
252
  }
114
253
  }
115
254
  /** Invalidate the write-skip cache when the on-disk file is not the exact
@@ -638,13 +777,7 @@ var Runtime = class {
638
777
  this.ctx.ui.notify("cron: coordinator lock metadata is missing or invalid; scheduling is paused. See docs/cron.md offline recovery.", "warning");
639
778
  }
640
779
  withCoordinatorMutex(fn) {
641
- const lock = path3.join(this.store.dir, "write.lock");
642
- fs3.mkdirSync(lock, { mode: 448 });
643
- try {
644
- return fn();
645
- } finally {
646
- fs3.rmdirSync(lock);
647
- }
780
+ return this.store.withWriteLock(() => fn());
648
781
  }
649
782
  acquireCoordinator() {
650
783
  const dir = this.coordinatorDir();
@@ -940,8 +1073,12 @@ ${job.prompt}`;
940
1073
  this.completions.clear();
941
1074
  break;
942
1075
  } catch (error) {
943
- if (!isContention(error) || attempt >= 39) throw error;
944
- await delay(25 + Math.floor(Math.random() * 25));
1076
+ if (isContention(error) && attempt < 39) {
1077
+ await delay(25 + Math.floor(Math.random() * 25));
1078
+ continue;
1079
+ }
1080
+ this.noteShutdownDegradation(`cron: exit left session ownership uncommitted (${String(error)}). If input stays blocked, run /tools/cron list and remove the stale owner row.`);
1081
+ break;
945
1082
  }
946
1083
  }
947
1084
  if (this.leader) {
@@ -950,13 +1087,29 @@ ${job.prompt}`;
950
1087
  this.withCoordinatorMutex(() => this.releaseCoordinator());
951
1088
  break;
952
1089
  } catch (error) {
953
- if (!isContention(error) || attempt >= 39) throw error;
954
- await delay(25 + Math.floor(Math.random() * 25));
1090
+ if (isContention(error) && attempt < 39) {
1091
+ await delay(25 + Math.floor(Math.random() * 25));
1092
+ continue;
1093
+ }
1094
+ this.noteShutdownDegradation(`cron: coordinator lock not released (${String(error)}). Scheduling pauses until it is reclaimed; see docs/cron.md.`);
1095
+ break;
955
1096
  }
956
1097
  }
957
1098
  }
958
1099
  this.ctx.ui.setStatus?.("cron", void 0);
959
1100
  }
1101
+ /** Surface a best-effort shutdown degradation. Never throws: diagnostics
1102
+ * must not turn a contained skip into a failed exit. */
1103
+ noteShutdownDegradation(message) {
1104
+ try {
1105
+ this.ctx.log?.(message);
1106
+ } catch {
1107
+ }
1108
+ try {
1109
+ this.ctx.ui.notify?.(message, "warning");
1110
+ } catch {
1111
+ }
1112
+ }
960
1113
  };
961
1114
 
962
1115
  // builtin/extensions/cron/index.ts
@@ -43,7 +43,7 @@ function truncateText(text) {
43
43
  function runPythonScript(script, fallbackMessage) {
44
44
  const failures = [];
45
45
  for (const pythonBin of PYTHON_CANDIDATES) {
46
- const result = spawnSync(pythonBin, ["-c", script], { encoding: "utf8" });
46
+ const result = spawnSync(pythonBin, ["-c", script], { encoding: "utf8", windowsHide: true });
47
47
  if (result.status === 0) {
48
48
  return result.stdout;
49
49
  }
@@ -110,7 +110,7 @@ function buildReleaseReportArgs(params) {
110
110
  }
111
111
  function spawnHerdrReport(binPath, args, timeoutMs = REPORT_TIMEOUT_MS) {
112
112
  try {
113
- const child = spawn(binPath, args, { detached: true, stdio: "ignore" });
113
+ const child = spawn(binPath, args, { detached: true, stdio: "ignore", windowsHide: true });
114
114
  let killTimer;
115
115
  const clearTimers = () => {
116
116
  clearTimeout(timer);
@@ -140,7 +140,7 @@ var KILL_GRACE_MS = 1e3;
140
140
  async function runHerdrReportBounded(binPath, args, timeoutMs = REPORT_TIMEOUT_MS) {
141
141
  let child;
142
142
  try {
143
- child = spawn(binPath, args, { detached: true, stdio: "ignore" });
143
+ child = spawn(binPath, args, { detached: true, stdio: "ignore", windowsHide: true });
144
144
  } catch {
145
145
  return { outcome: "spawn-error", exitCode: null };
146
146
  }
@@ -3,7 +3,7 @@ import {
3
3
  distillWorkerLogPath,
4
4
  readDistillWorkerLog,
5
5
  spawnDistillWorker
6
- } from "../../../chunks/chunk-3NHP7HK5.js";
6
+ } from "../../../chunks/chunk-OEQYEYB3.js";
7
7
  import {
8
8
  getConfigDir,
9
9
  getSettingsPath
@@ -18,8 +18,8 @@ import {
18
18
  saveAttestedEntry,
19
19
  searchMemory,
20
20
  todayKey
21
- } from "../../../chunks/chunk-PK72LVWQ.js";
22
- import "../../../chunks/chunk-RSL7E4R7.js";
21
+ } from "../../../chunks/chunk-7FEPQHYX.js";
22
+ import "../../../chunks/chunk-3FRKOFSP.js";
23
23
  import "../../../chunks/chunk-GH4VW2OT.js";
24
24
  import "../../../chunks/chunk-3BC5KGDQ.js";
25
25
  import {
@@ -111,21 +111,21 @@ function memoryExtension(ctx) {
111
111
  if (activeSessionId !== null && activeSessionId !== event.sessionId) {
112
112
  sessionConsumedIds = /* @__PURE__ */ new Set();
113
113
  injectionMemo = null;
114
- lastTurnAt = 0;
114
+ pendingDistillHint = false;
115
115
  ctx.log(`[memory] session switch (${activeSessionId.slice(0, 8)} \u2192 ${event.sessionId.slice(0, 8)}): injection memo + consumption scope reset`);
116
116
  }
117
117
  activeSessionId = event.sessionId;
118
118
  });
119
- const INJECTION_IDLE_REFRESH_MS = 60 * 60 * 1e3;
120
119
  let injectionMemo = null;
121
120
  let sessionConsumedIds = /* @__PURE__ */ new Set();
122
- let lastTurnAt = 0;
121
+ let pendingDistillHint = false;
123
122
  const distillWatermark = () => Math.max(0, ...Object.values(store.loadState().runs).map((run) => run.ops > 0 ? run.ranAt : 0));
124
123
  const updateFooterTag = () => {
125
- ctx.ui.setStatus?.("memory", readInjectSetting() ? "[MEM]" : void 0);
124
+ ctx.ui.setStatus?.("memory", readInjectSetting() ? pendingDistillHint && injectionMemo !== null ? "[MEM*]" : "[MEM]" : void 0);
126
125
  };
127
126
  updateFooterTag();
128
127
  const refreshInjection = (reason) => {
128
+ pendingDistillHint = false;
129
129
  if (injectionMemo === null) return;
130
130
  injectionMemo = null;
131
131
  ctx.log(`[memory] injection memo dropped (${reason})`);
@@ -154,24 +154,26 @@ function memoryExtension(ctx) {
154
154
  });
155
155
  ctx.on("before_agent_start", (event) => {
156
156
  try {
157
- updateFooterTag();
158
- const now = Date.now();
159
- const idleMs = lastTurnAt > 0 ? now - lastTurnAt : Infinity;
160
- lastTurnAt = now;
161
- if (!readInjectSetting()) return {};
157
+ const injectOn = readInjectSetting();
158
+ ctx.ui.setStatus?.("memory", injectOn ? pendingDistillHint && injectionMemo !== null ? "[MEM*]" : "[MEM]" : void 0);
159
+ if (!injectOn) return {};
162
160
  const watermark = distillWatermark();
163
- if (injectionMemo === null || idleMs >= INJECTION_IDLE_REFRESH_MS || injectionMemo.watermark < watermark) {
161
+ if (injectionMemo === null) {
164
162
  const built = buildInjectionSectionWithIds(store, budget, project.key);
165
163
  injectionMemo = {
166
164
  text: built.text,
167
165
  watermark,
168
166
  injectedIds: built.injectedIds
169
167
  };
168
+ pendingDistillHint = false;
170
169
  try {
171
170
  recordInjection(store, built.injectedIds);
172
171
  } catch (error) {
173
172
  ctx.log(`[memory] injection accounting failed (skipped): ${String(error)}`);
174
173
  }
174
+ } else if (watermark > injectionMemo.watermark) {
175
+ pendingDistillHint = true;
176
+ ctx.ui.setStatus?.("memory", "[MEM*]");
175
177
  }
176
178
  if (!injectionMemo.text) return;
177
179
  return { systemPrompt: `${event.baseSystemPrompt}
@@ -6,8 +6,8 @@ import {
6
6
  createPlanCapability,
7
7
  markCompletedPlanSteps,
8
8
  restoreExecutionState
9
- } from "../../../chunks/chunk-PK72LVWQ.js";
10
- import "../../../chunks/chunk-RSL7E4R7.js";
9
+ } from "../../../chunks/chunk-7FEPQHYX.js";
10
+ import "../../../chunks/chunk-3FRKOFSP.js";
11
11
  import "../../../chunks/chunk-GH4VW2OT.js";
12
12
  import "../../../chunks/chunk-3BC5KGDQ.js";
13
13
  import {
@@ -5,7 +5,7 @@ import {
5
5
  createCliRetryPolicy,
6
6
  formatTransportLifecycle,
7
7
  logTransportLifecycle
8
- } from "../../../chunks/chunk-GDIYSMTS.js";
8
+ } from "../../../chunks/chunk-BUDXV3TR.js";
9
9
  import {
10
10
  getConfigDir
11
11
  } from "../../../chunks/chunk-ILUHTKF3.js";
@@ -14,8 +14,8 @@ import {
14
14
  createPolicyEnforcedTools,
15
15
  createSharedFileSystemTools,
16
16
  createSubagentCapability
17
- } from "../../../chunks/chunk-PK72LVWQ.js";
18
- import "../../../chunks/chunk-RSL7E4R7.js";
17
+ } from "../../../chunks/chunk-7FEPQHYX.js";
18
+ import "../../../chunks/chunk-3FRKOFSP.js";
19
19
  import "../../../chunks/chunk-GH4VW2OT.js";
20
20
  import "../../../chunks/chunk-3BC5KGDQ.js";
21
21
  import "../../../chunks/chunk-XXGYUYXI.js";
@@ -43,7 +43,7 @@ function defaultReadProcessStartTime(pid) {
43
43
  "-Command",
44
44
  `$p = Get-CimInstance Win32_Process -Filter "ProcessId=${pid}"; if ($p) { $p.CreationDate.ToString('o') }`
45
45
  ],
46
- { encoding: "utf-8", timeout: 4e3 }
46
+ { encoding: "utf-8", timeout: 4e3, windowsHide: true }
47
47
  );
48
48
  const line = output.split(/\r?\n/).find((entry) => entry.trim().length > 0);
49
49
  return line?.trim();
@@ -8,8 +8,8 @@ import {
8
8
  executeManageTodoList,
9
9
  executionStateToTodos,
10
10
  restoreExecutionState
11
- } from "../../../chunks/chunk-PK72LVWQ.js";
12
- import "../../../chunks/chunk-RSL7E4R7.js";
11
+ } from "../../../chunks/chunk-7FEPQHYX.js";
12
+ import "../../../chunks/chunk-3FRKOFSP.js";
13
13
  import "../../../chunks/chunk-GH4VW2OT.js";
14
14
  import "../../../chunks/chunk-3BC5KGDQ.js";
15
15
  import "../../../chunks/chunk-XXGYUYXI.js";
@@ -4,11 +4,12 @@ import {
4
4
  BRIDGE_PORT_IN_USE_EXIT_CODE,
5
5
  PAGE_IDENTITY_CHANGED_ERROR,
6
6
  clearSelectedPageId,
7
+ inspectProcessIdentity,
7
8
  readSelfStartTime,
8
9
  resolveSessionName,
9
10
  resolveSessionPidFile,
10
11
  resolveSessionPort
11
- } from "./chunk-BNSAEVRT.js";
12
+ } from "./chunk-WOGAQ4P5.js";
12
13
  import {
13
14
  __commonJS,
14
15
  __export,
@@ -19571,6 +19572,36 @@ import {
19571
19572
  } from "node:fs";
19572
19573
  import { basename, dirname, isAbsolute, join } from "node:path";
19573
19574
  import { pathToFileURL } from "node:url";
19575
+
19576
+ // vendor/chrome-devtools-axi/src/supervisor-anchor-shared.ts
19577
+ var SUPERVISOR_PID_ENV = "PIE_SUPERVISOR_PID";
19578
+ var SUPERVISOR_START_TIME_ENV = "PIE_SUPERVISOR_START_TIME";
19579
+ function parseSupervisorAnchor(env = process.env) {
19580
+ const pidText = env[SUPERVISOR_PID_ENV]?.trim();
19581
+ if (!pidText || !/^\d+$/.test(pidText)) return void 0;
19582
+ const pid = Number(pidText);
19583
+ if (!Number.isSafeInteger(pid) || pid <= 0) return void 0;
19584
+ const startTime = env[SUPERVISOR_START_TIME_ENV]?.trim();
19585
+ return startTime ? { pid, startTime } : { pid };
19586
+ }
19587
+ function isSupervisorGone(anchor2, readIdentity) {
19588
+ try {
19589
+ process.kill(anchor2.pid, 0);
19590
+ } catch (error2) {
19591
+ return error2.code === "ESRCH";
19592
+ }
19593
+ let identity;
19594
+ try {
19595
+ identity = readIdentity(anchor2.pid);
19596
+ } catch {
19597
+ return false;
19598
+ }
19599
+ if (identity.startTime === void 0) return false;
19600
+ if (anchor2.startTime === void 0) return false;
19601
+ return identity.startTime !== anchor2.startTime;
19602
+ }
19603
+
19604
+ // vendor/chrome-devtools-axi/src/bridge.ts
19574
19605
  async function isBridgeClientConnected(client) {
19575
19606
  try {
19576
19607
  await client.listTools();
@@ -19849,6 +19880,72 @@ function handleBridgeServerError(error2, port, exit = process.exit) {
19849
19880
  function writeReadySignal() {
19850
19881
  process.stdout.write("READY\n");
19851
19882
  }
19883
+ var LAUNCHER_HEADER = "x-axi-launcher";
19884
+ var DEFAULT_HEARTBEAT_MS = 3e4;
19885
+ var DEFAULT_IDLE_SHUTDOWN_MS = 30 * 6e4;
19886
+ var parseSupervisorAnchor2 = parseSupervisorAnchor;
19887
+ var isSupervisorGone2 = (supervisor) => isSupervisorGone(supervisor, inspectProcessIdentity);
19888
+ function parseLauncherHeader(value) {
19889
+ const raw = Array.isArray(value) ? value[0] : value;
19890
+ if (!raw) return void 0;
19891
+ const colon = raw.indexOf(":");
19892
+ const pidText = colon === -1 ? raw : raw.slice(0, colon);
19893
+ if (!/^\d+$/.test(pidText)) return void 0;
19894
+ const pid = Number(pidText);
19895
+ if (!Number.isSafeInteger(pid) || pid <= 0) return void 0;
19896
+ const startTime = colon === -1 ? void 0 : raw.slice(colon + 1);
19897
+ return startTime ? { pid, startTime } : { pid };
19898
+ }
19899
+ function createBridgeLifecycle(shutdown, opts = {}) {
19900
+ const heartbeatMs = opts.heartbeatMs ?? DEFAULT_HEARTBEAT_MS;
19901
+ const idleShutdownMs = opts.idleShutdownMs ?? DEFAULT_IDLE_SHUTDOWN_MS;
19902
+ const now = opts.now ?? Date.now;
19903
+ let supervisor;
19904
+ let supervisorFromEnv = false;
19905
+ if (opts.anchor) {
19906
+ supervisor = opts.anchor;
19907
+ supervisorFromEnv = true;
19908
+ }
19909
+ let lastRequestAt = now();
19910
+ let disposed = false;
19911
+ const fire = (reason) => {
19912
+ disposed = true;
19913
+ clearInterval(timer);
19914
+ logBridgeMessage(reason);
19915
+ try {
19916
+ void shutdown();
19917
+ } catch {
19918
+ }
19919
+ };
19920
+ const tick = () => {
19921
+ if (disposed) return;
19922
+ const t = now();
19923
+ if (t - lastRequestAt >= idleShutdownMs) {
19924
+ fire(`idle ${Math.round((t - lastRequestAt) / 1e3)}s \u2265 ${Math.round(idleShutdownMs / 1e3)}s with no requests; shutting down`);
19925
+ return;
19926
+ }
19927
+ if (supervisor && isSupervisorGone2(supervisor)) {
19928
+ fire(`supervisor pid ${supervisor.pid} is gone and no requests since; shutting down`);
19929
+ return;
19930
+ }
19931
+ };
19932
+ const timer = setInterval(tick, heartbeatMs);
19933
+ timer.unref?.();
19934
+ return {
19935
+ observeRequest(req) {
19936
+ lastRequestAt = now();
19937
+ if (supervisorFromEnv) return;
19938
+ const next = parseLauncherHeader(req.headers[LAUNCHER_HEADER]);
19939
+ if (!next) return;
19940
+ if (supervisor?.startTime && !next.startTime) return;
19941
+ supervisor = next;
19942
+ },
19943
+ dispose() {
19944
+ disposed = true;
19945
+ clearInterval(timer);
19946
+ }
19947
+ };
19948
+ }
19852
19949
  var KEYCHAIN_ISOLATION_CHROME_ARGS = [
19853
19950
  "--use-mock-keychain",
19854
19951
  "--password-store=basic"
@@ -19913,7 +20010,8 @@ var DEFAULT_MCP_PATH_PROBE = {
19913
20010
  try {
19914
20011
  return execSync("npm prefix -g", {
19915
20012
  encoding: "utf8",
19916
- stdio: ["ignore", "pipe", "ignore"]
20013
+ stdio: ["ignore", "pipe", "ignore"],
20014
+ windowsHide: true
19917
20015
  }).trim();
19918
20016
  } catch {
19919
20017
  return null;
@@ -19954,6 +20052,7 @@ function resolveTransportSpec(probe = DEFAULT_MCP_PATH_PROBE) {
19954
20052
  help = execFileSync(process.execPath, [explicitPath, "--help"], {
19955
20053
  encoding: "utf8",
19956
20054
  stdio: ["ignore", "pipe", "pipe"],
20055
+ windowsHide: true,
19957
20056
  timeout: 5e3,
19958
20057
  killSignal: "SIGKILL"
19959
20058
  });
@@ -20152,6 +20251,10 @@ async function runBridge(port = resolveSessionPort()) {
20152
20251
  logBridgeMessage("Connected to chrome-devtools-mcp");
20153
20252
  const sessionName = resolveSessionName();
20154
20253
  const server = createBridgeServer(bridgeClient, sessionName);
20254
+ const lifecycle = createBridgeLifecycle(() => shutdown(), {
20255
+ anchor: parseSupervisorAnchor2()
20256
+ });
20257
+ server.on("request", (req) => lifecycle.observeRequest(req));
20155
20258
  server.on("error", (error2) => {
20156
20259
  handleBridgeServerError(error2, port);
20157
20260
  });
@@ -20164,6 +20267,7 @@ async function runBridge(port = resolveSessionPort()) {
20164
20267
  const shutdown = async () => {
20165
20268
  if (shuttingDown) return;
20166
20269
  shuttingDown = true;
20270
+ lifecycle.dispose();
20167
20271
  removePidFile();
20168
20272
  await closeServer(server);
20169
20273
  await closeBridgeTransport(bridgeTransport);
@@ -39,6 +39,7 @@ export function resolveChromeDevtoolsMcpScript() {
39
39
  export function runChromeDevtoolsAxiCli(args = process.argv.slice(2), options = {}) {
40
40
  const bin = resolveChromeDevtoolsAxiCli();
41
41
  return spawnSync(process.execPath, [bin, ...args], {
42
+ windowsHide: true,
42
43
  stdio: "inherit",
43
44
  shell: false,
44
45
  ...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-AO2ZTPRM.js");
24
+ const { main } = await import("./cli-CHC7XYFU.js");
25
25
  await main(process.argv.slice(2));
26
26
  }
@@ -334,7 +334,7 @@ function inspectProcessIdentity(pid) {
334
334
  "-Command",
335
335
  `$p = Get-CimInstance Win32_Process -Filter "ProcessId=<pid>"; if ($p) { $p.CommandLine; $p.CreationDate.ToString('o') }`.replace("<pid>", String(pid))
336
336
  ],
337
- { encoding: "utf-8", timeout: 4e3 }
337
+ { encoding: "utf-8", timeout: 4e3, windowsHide: true }
338
338
  );
339
339
  const lines = output.split(/\r?\n/).filter((line) => line.length > 0);
340
340
  if (lines.length === 0) return {};
@@ -345,7 +345,7 @@ function inspectProcessIdentity(pid) {
345
345
  }
346
346
  }
347
347
  try {
348
- const psEnv = { ...process.env, LC_ALL: "C", LANG: "C" };
348
+ const psEnv = { ...process.env, LC_ALL: "C", LANG: "C", TZ: "UTC0" };
349
349
  const output = execFileSync(
350
350
  "ps",
351
351
  ["-p", String(pid), "-o", "lstart=", "-o", "command="],