@flemist/mcp-project-tools 3.0.13 → 3.0.14

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.
@@ -1,20 +1,20 @@
1
1
  import oe from "express";
2
- import { McpServer as Lt } from "@modelcontextprotocol/sdk/server/mcp.js";
3
- import { randomUUID as Pt } from "crypto";
2
+ import { McpServer as Pt } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import { randomUUID as At } from "crypto";
4
4
  import * as W from "fs";
5
5
  import * as F from "path";
6
- import At from "path";
7
- import { StreamableHTTPServerTransport as zt } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
8
- import { spawn as Ut } from "child_process";
6
+ import zt from "path";
7
+ import { StreamableHTTPServerTransport as Ut } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
8
+ import { spawn as qt } from "child_process";
9
9
  import { z as p } from "zod";
10
10
  import he from "tree-kill";
11
- import { Pool as qt, poolRunWait as Y } from "@flemist/time-limits";
11
+ import { Pool as _t, poolRunWait as Y } from "@flemist/time-limits";
12
12
  import { priorityCreate as V } from "@flemist/priority-queue";
13
- import { useAbortController as _t, combineAbortSignals as Gt, Locker as Jt } from "@flemist/async-utils";
14
- import jt from "node:os";
15
- import Kt from "picomatch";
16
- import { webkit as Wt, firefox as Ht, chromium as Qt } from "playwright";
17
- function Yt(r) {
13
+ import { useAbortController as Gt, combineAbortSignals as Jt, Locker as jt } from "@flemist/async-utils";
14
+ import Kt from "node:os";
15
+ import Wt from "picomatch";
16
+ import { webkit as Ht, firefox as Qt, chromium as Yt } from "playwright";
17
+ function Vt(r) {
18
18
  const { authToken: t } = r;
19
19
  return function(o, e, n) {
20
20
  if ((o.query.token || o.headers.authorization?.replace("Bearer ", "")) !== t) {
@@ -27,22 +27,22 @@ function Yt(r) {
27
27
  async function ne(r) {
28
28
  const { logFilePath: t, message: s, data: o } = r;
29
29
  try {
30
- const e = (/* @__PURE__ */ new Date()).toISOString().replace(/[TZ]/g, " ").trim(), n = typeof o == "string" ? o : JSON.stringify(o, null, 2), i = `[${e}] ${s}
30
+ const e = (/* @__PURE__ */ new Date()).toISOString().replace(/[TZ]/g, " ").trim(), n = typeof o == "string" ? o : JSON.stringify(o, null, 2), a = `[${e}] ${s}
31
31
  ${n}
32
32
 
33
33
  `;
34
- await W.promises.mkdir(F.dirname(t), { recursive: !0 }), await W.promises.appendFile(t, i);
34
+ await W.promises.mkdir(F.dirname(t), { recursive: !0 }), await W.promises.appendFile(t, a);
35
35
  } catch (e) {
36
36
  console.error(`Failed to log "${s}":`, e);
37
37
  }
38
38
  }
39
39
  const ie = /* @__PURE__ */ new Map();
40
- function Vt(r) {
40
+ function Zt(r) {
41
41
  return r.headers["mcp-session-id"] || r.headers["x-session-id"] || r.query.token;
42
42
  }
43
- async function Zt(r, t) {
44
- const s = r.createMcpServer(), o = new zt({
45
- sessionIdGenerator: () => t || Pt(),
43
+ async function Xt(r, t) {
44
+ const s = r.createMcpServer(), o = new Ut({
45
+ sessionIdGenerator: () => t || At(),
46
46
  onsessioninitialized: (n) => {
47
47
  ie.set(n, o);
48
48
  },
@@ -53,8 +53,8 @@ async function Zt(r, t) {
53
53
  n && ie.delete(n);
54
54
  try {
55
55
  await s.close();
56
- } catch (i) {
57
- console.error("Failed to close session", i);
56
+ } catch (a) {
57
+ console.error("Failed to close session", a);
58
58
  }
59
59
  }
60
60
  o.onclose = e;
@@ -64,16 +64,16 @@ async function Zt(r, t) {
64
64
  throw await e(), n;
65
65
  }
66
66
  }
67
- async function Xt(r, t, s, o) {
67
+ async function er(r, t, s, o) {
68
68
  await ne({
69
69
  logFilePath: s.logFilePath,
70
70
  message: "REQUEST",
71
71
  data: r.body
72
72
  });
73
73
  let e = o ? ie.get(o) : null;
74
- e || (e = await Zt(s, o)), await e.handleRequest(r, t, r.body);
74
+ e || (e = await Xt(s, o)), await e.handleRequest(r, t, r.body);
75
75
  }
76
- async function er(r, t, s) {
76
+ async function tr(r, t, s) {
77
77
  const o = s ? ie.get(s) : null;
78
78
  if (!o) {
79
79
  t.status(400).json({ error: "No valid session found" });
@@ -81,11 +81,11 @@ async function er(r, t, s) {
81
81
  }
82
82
  await o.handleRequest(r, t);
83
83
  }
84
- function tr(r) {
84
+ function rr(r) {
85
85
  return async function(s, o) {
86
86
  try {
87
- const e = Vt(s);
88
- s.method === "POST" ? await Xt(s, o, r, e) : s.method === "GET" ? await er(s, o, e) : o.status(405).json({ error: "Method not allowed" });
87
+ const e = Zt(s);
88
+ s.method === "POST" ? await er(s, o, r, e) : s.method === "GET" ? await tr(s, o, e) : o.status(405).json({ error: "Method not allowed" });
89
89
  } catch (e) {
90
90
  console.error("Unhandled error in streamableHttpHandler", e), o.status(500).json({
91
91
  error: "Internal server error: " + (e instanceof Error ? e.message : "Unknown error")
@@ -94,9 +94,9 @@ function tr(r) {
94
94
  };
95
95
  }
96
96
  const Q = /* @__PURE__ */ new Map();
97
- let rr = 0;
98
- const Te = 10, sr = 1800 * 1e3, R = 1e4, or = 500, nr = 5e3;
99
- function ir(r) {
97
+ let sr = 0;
98
+ const Te = 10, or = 1800 * 1e3, R = 1e4, nr = 500, ir = 5e3;
99
+ function ar(r) {
100
100
  const { commandLine: t, commandLineRules: s } = r;
101
101
  let o = !1;
102
102
  for (const e of s)
@@ -113,11 +113,11 @@ function ir(r) {
113
113
  }
114
114
  return o;
115
115
  }
116
- function ar() {
117
- return ++rr;
116
+ function lr() {
117
+ return ++sr;
118
118
  }
119
119
  let Ce = !1;
120
- function lr() {
120
+ function cr() {
121
121
  if (Ce)
122
122
  return;
123
123
  Ce = !0;
@@ -137,26 +137,26 @@ function lr() {
137
137
  function me() {
138
138
  const r = Date.now(), t = [];
139
139
  for (const [s, o] of Array.from(Q.entries()))
140
- !o.isRunning && o.endTime && r - o.endTime.getTime() > sr && t.push(s);
140
+ !o.isRunning && o.endTime && r - o.endTime.getTime() > or && t.push(s);
141
141
  for (const s of t)
142
142
  Q.delete(s);
143
143
  }
144
144
  function ge(r) {
145
145
  const { process: t } = r, s = Date.now();
146
- if (s - t.lastOutputTime.getTime() >= or && (t.output += t.localOutput, t.localOutput = "", t.lastOutputTime = new Date(s), t.output.length > R)) {
146
+ if (s - t.lastOutputTime.getTime() >= nr && (t.output += t.localOutput, t.localOutput = "", t.lastOutputTime = new Date(s), t.output.length > R)) {
147
147
  const n = `
148
148
  ... [${t.output.length - R} characters trimmed] ...
149
- `, i = R - n.length;
150
- if (i > 0) {
151
- const a = Math.floor(i / 2);
152
- t.output = t.output.substring(0, a) + n + t.output.substring(
153
- t.output.length - (i - a)
149
+ `, a = R - n.length;
150
+ if (a > 0) {
151
+ const i = Math.floor(a / 2);
152
+ t.output = t.output.substring(0, i) + n + t.output.substring(
153
+ t.output.length - (a - i)
154
154
  );
155
155
  } else
156
156
  t.output = t.output.substring(0, R);
157
157
  }
158
158
  }
159
- function cr(r, t) {
159
+ function ur(r, t) {
160
160
  const s = t.limit;
161
161
  if (r.length <= s) return r;
162
162
  const e = `
@@ -164,8 +164,8 @@ function cr(r, t) {
164
164
  `, n = s - e.length;
165
165
  if (n <= 0)
166
166
  return r.substring(0, s);
167
- const i = Math.floor(n / 2);
168
- return r.substring(0, i) + e + r.substring(r.length - (n - i));
167
+ const a = Math.floor(n / 2);
168
+ return r.substring(0, a) + e + r.substring(r.length - (n - a));
169
169
  }
170
170
  function B(r) {
171
171
  return `Invalid arguments: ${r instanceof Error ? r.message : "Unknown error"}.
@@ -196,7 +196,7 @@ async function we(r, t) {
196
196
  error: `Process ${o} not found. The process may have already completed and been cleaned up after 30 minutes, or the ID may be incorrect. Use process-list to see available processes and their current status.`
197
197
  };
198
198
  ge({ process: n });
199
- const i = n.output + n.localOutput, a = cr(i, { limit: e });
199
+ const a = n.output + n.localOutput, i = ur(a, { limit: e });
200
200
  return n.output = "", n.localOutput = "", {
201
201
  id: n.id,
202
202
  cwd: F.relative(t.workingDir || "", n.cwd),
@@ -206,11 +206,11 @@ async function we(r, t) {
206
206
  endTime: n.endTime?.toISOString().replace(/[TZ]/g, " ").trim(),
207
207
  exitCode: n.exitCode,
208
208
  isRunning: n.isRunning,
209
- output: a,
209
+ output: i,
210
210
  error: n.error
211
211
  };
212
212
  }
213
- function ur(r, t) {
213
+ function dr(r, t) {
214
214
  r(
215
215
  "process-status",
216
216
  {
@@ -239,7 +239,7 @@ function Xe(r) {
239
239
  he(r, "SIGKILL", (t) => {
240
240
  t && !t.message.includes("not found") && console.error(`Error sending SIGKILL to process ${r}:`, t);
241
241
  });
242
- }, nr);
242
+ }, ir);
243
243
  }
244
244
  const et = p.object({
245
245
  id: p.number().describe(
@@ -264,8 +264,8 @@ async function tt(r, t) {
264
264
  error: B(h)
265
265
  };
266
266
  }
267
- const { id: o, waitTime: e, autoKill: n, outputLimit: i } = s, a = Q.get(o);
268
- if (!a)
267
+ const { id: o, waitTime: e, autoKill: n, outputLimit: a } = s, i = Q.get(o);
268
+ if (!i)
269
269
  return {
270
270
  error: `Process ${o} not found. The process may have already completed and been cleaned up after 30 minutes, or the ID may be incorrect. Use process-list to see available processes and their current status.`
271
271
  };
@@ -273,18 +273,18 @@ async function tt(r, t) {
273
273
  let l = !1, u = !1;
274
274
  e != null && await new Promise((m) => {
275
275
  const g = setInterval(() => {
276
- a.isRunning ? Date.now() - c >= e * 1e3 && (clearInterval(g), l = !0, n && a.pid && (Xe(a.pid), u = !0), m()) : (clearInterval(g), m());
276
+ i.isRunning ? Date.now() - c >= e * 1e3 && (clearInterval(g), l = !0, n && i.pid && (Xe(i.pid), u = !0), m()) : (clearInterval(g), m());
277
277
  }, 100);
278
278
  });
279
- const f = (Date.now() - c) / 1e3;
279
+ const d = (Date.now() - c) / 1e3;
280
280
  return {
281
- ...await we({ id: o, outputLimit: i }, t),
282
- waitDuration: f,
281
+ ...await we({ id: o, outputLimit: a }, t),
282
+ waitDuration: d,
283
283
  waitTimeExceeded: l,
284
284
  autoKillExecuted: u
285
285
  };
286
286
  }
287
- function dr(r, t) {
287
+ function fr(r, t) {
288
288
  r(
289
289
  "process-wait",
290
290
  {
@@ -323,36 +323,36 @@ const rt = p.object({
323
323
  `Maximum number of output characters to capture and return from the process. Output exceeding this limit will be truncated with beginning/end preserved and middle removed. Maximum: ${R} characters. Default: ${R}.`
324
324
  )
325
325
  });
326
- async function fr(r, t) {
326
+ async function hr(r, t) {
327
327
  me();
328
328
  let s;
329
329
  try {
330
330
  s = rt.parse(r);
331
- } catch (d) {
331
+ } catch (f) {
332
332
  return {
333
- error: B(d)
333
+ error: B(f)
334
334
  };
335
335
  }
336
- const { commandLine: o, waitTime: e, autoKill: n, outputLimit: i } = s, { commandLineRules: a } = t, c = F.resolve(t.workingDir || "", s.cwd || "");
337
- if (!ir({ commandLine: o, commandLineRules: a })) {
338
- const d = a.map(
336
+ const { commandLine: o, waitTime: e, autoKill: n, outputLimit: a } = s, { commandLineRules: i } = t, c = F.resolve(t.workingDir || "", s.cwd || "");
337
+ if (!ar({ commandLine: o, commandLineRules: i })) {
338
+ const f = i.map(
339
339
  (h) => `${h.rule.toUpperCase()}: /${h.regexp}/ (${h.note})`
340
340
  ).join(`
341
341
  `);
342
342
  return {
343
343
  error: `Command line not allowed: "${o}". For security, command lines are validated against configured rules in order. Command line was denied by the rule evaluation. Current command line rules:
344
- ${d}
344
+ ${f}
345
345
 
346
346
  To use this command line, ask the user to modify the command line rules in the configuration.`
347
347
  };
348
348
  }
349
349
  if (Array.from(Q.values()).filter(
350
- (d) => d.isRunning
350
+ (f) => f.isRunning
351
351
  ).length >= Te)
352
352
  return {
353
353
  error: `Maximum concurrent process limit reached (${Te} processes). Cannot start new process until existing processes complete. Use process-list to see active processes, or process-kill to terminate unnecessary processes.`
354
354
  };
355
- const u = ar(), f = {
355
+ const u = lr(), d = {
356
356
  id: u,
357
357
  cwd: c,
358
358
  commandLine: o,
@@ -362,40 +362,40 @@ To use this command line, ask the user to modify the command line rules in the c
362
362
  localOutput: "",
363
363
  lastOutputTime: /* @__PURE__ */ new Date()
364
364
  };
365
- Q.set(u, f);
365
+ Q.set(u, d);
366
366
  try {
367
- const d = Ut(o, [], {
367
+ const f = qt(o, [], {
368
368
  shell: !0,
369
369
  cwd: c,
370
370
  stdio: ["pipe", "pipe", "pipe"]
371
371
  });
372
- f.pid = d.pid;
372
+ d.pid = f.pid;
373
373
  const h = (m) => {
374
374
  const g = m.toString();
375
- f.localOutput += g, ge({ process: f }), console.log(g);
375
+ d.localOutput += g, ge({ process: d }), console.log(g);
376
376
  };
377
- return d.stdout?.on("data", h), d.stderr?.on("data", h), d.on("close", (m) => {
378
- if (f.isRunning = !1, f.endTime = /* @__PURE__ */ new Date(), f.exitCode = m !== null ? m : void 0, f.output += f.localOutput, f.localOutput = "", f.output.length > R) {
377
+ return f.stdout?.on("data", h), f.stderr?.on("data", h), f.on("close", (m) => {
378
+ if (d.isRunning = !1, d.endTime = /* @__PURE__ */ new Date(), d.exitCode = m !== null ? m : void 0, d.output += d.localOutput, d.localOutput = "", d.output.length > R) {
379
379
  const y = `
380
- ... [${f.output.length - R} characters trimmed] ...
380
+ ... [${d.output.length - R} characters trimmed] ...
381
381
  `, w = R - y.length;
382
382
  if (w > 0) {
383
383
  const M = Math.floor(w / 2);
384
- f.output = f.output.substring(0, M) + y + f.output.substring(
385
- f.output.length - (w - M)
384
+ d.output = d.output.substring(0, M) + y + d.output.substring(
385
+ d.output.length - (w - M)
386
386
  );
387
387
  } else
388
- f.output = f.output.substring(0, R);
388
+ d.output = d.output.substring(0, R);
389
389
  }
390
390
  console.log(`Process ${u} (${o}) exited with code ${m}`);
391
- }), d.on("error", (m) => {
392
- f.isRunning = !1, f.endTime = /* @__PURE__ */ new Date(), f.error = m.message, console.error(`Process ${u} error:`, m.message);
393
- }), e != null ? tt({ id: u, waitTime: e, autoKill: n, outputLimit: i }, t) : we({ id: u, outputLimit: i }, t);
394
- } catch (d) {
395
- return f.isRunning = !1, f.endTime = /* @__PURE__ */ new Date(), f.error = d instanceof Error ? d.message : "Unknown error", { error: f.error };
391
+ }), f.on("error", (m) => {
392
+ d.isRunning = !1, d.endTime = /* @__PURE__ */ new Date(), d.error = m.message, console.error(`Process ${u} error:`, m.message);
393
+ }), e != null ? tt({ id: u, waitTime: e, autoKill: n, outputLimit: a }, t) : we({ id: u, outputLimit: a }, t);
394
+ } catch (f) {
395
+ return d.isRunning = !1, d.endTime = /* @__PURE__ */ new Date(), d.error = f instanceof Error ? f.message : "Unknown error", { error: d.error };
396
396
  }
397
397
  }
398
- function hr(r, t) {
398
+ function pr(r, t) {
399
399
  const s = t.commandLineRules.map((o) => `${o.rule.toUpperCase()}: ${o.regexp} (${o.note})`).join(`
400
400
  `);
401
401
  r(
@@ -407,7 +407,7 @@ ${s}`,
407
407
  inputSchema: rt.shape
408
408
  },
409
409
  async (o) => {
410
- const e = await fr(o, t);
410
+ const e = await hr(o, t);
411
411
  if (!("output" in e))
412
412
  return `Method: process-run(${JSON.stringify(o)})
413
413
  ❌ Error: ${e.error}`;
@@ -434,7 +434,7 @@ const st = p.object({
434
434
  'Specific process data fields to include in the response. If omitted, returns all available fields. Available fields: id, cwd, commandLine, pid, startTime, endTime, exitCode, isRunning, output, error. Examples: ["id", "commandLine", "isRunning"] for minimal info, ["id", "output", "exitCode"] for execution results'
435
435
  )
436
436
  });
437
- async function pr(r, t) {
437
+ async function mr(r, t) {
438
438
  me();
439
439
  let s;
440
440
  try {
@@ -444,21 +444,21 @@ async function pr(r, t) {
444
444
  error: B(l)
445
445
  };
446
446
  }
447
- const { minOpenDateTime: o, minCloseDateTime: e, activeOnly: n, fields: i } = s;
448
- let a = Array.from(Q.values());
447
+ const { minOpenDateTime: o, minCloseDateTime: e, activeOnly: n, fields: a } = s;
448
+ let i = Array.from(Q.values());
449
449
  if (o) {
450
450
  const l = new Date(o.replace(/[_\s]/g, "T"));
451
- a = a.filter((u) => u.startTime >= l);
451
+ i = i.filter((u) => u.startTime >= l);
452
452
  }
453
453
  if (e) {
454
454
  const l = new Date(e.replace(/[_\s]/g, "T"));
455
- a = a.filter((u) => u.endTime && u.endTime >= l);
455
+ i = i.filter((u) => u.endTime && u.endTime >= l);
456
456
  }
457
- return n && (a = a.filter((l) => l.isRunning)), { processes: a.map((l) => {
457
+ return n && (i = i.filter((l) => l.isRunning)), { processes: i.map((l) => {
458
458
  ge({ process: l });
459
459
  let u = {
460
460
  id: l.id,
461
- cwd: At.relative(t.workingDir || "", l.cwd),
461
+ cwd: zt.relative(t.workingDir || "", l.cwd),
462
462
  commandLine: l.commandLine,
463
463
  pid: l.pid,
464
464
  startTime: l.startTime.toISOString().replace(/[TZ]/g, " ").trim(),
@@ -468,16 +468,16 @@ async function pr(r, t) {
468
468
  output: l.output + l.localOutput,
469
469
  error: l.error
470
470
  };
471
- if (i) {
472
- const f = {};
473
- for (const d of i)
474
- d in u && (f[d] = u[d]);
475
- u = f;
471
+ if (a) {
472
+ const d = {};
473
+ for (const f of a)
474
+ f in u && (d[f] = u[f]);
475
+ u = d;
476
476
  }
477
477
  return u;
478
478
  }) };
479
479
  }
480
- function mr(r, t) {
480
+ function gr(r, t) {
481
481
  r(
482
482
  "process-list",
483
483
  {
@@ -486,7 +486,7 @@ function mr(r, t) {
486
486
  inputSchema: st.shape
487
487
  },
488
488
  async (s) => {
489
- const o = await pr(s, t);
489
+ const o = await mr(s, t);
490
490
  if (o.error != null)
491
491
  return `Method: process-list(${JSON.stringify(s)})
492
492
  ❌ Error: ${o.error}`;
@@ -505,7 +505,7 @@ const ot = p.object({
505
505
  "Process ID of the process to terminate. Get process IDs using process-list. The process must be currently running. Examples: 1, 42, 123"
506
506
  )
507
507
  });
508
- function gr(r) {
508
+ function wr(r) {
509
509
  let t;
510
510
  try {
511
511
  t = ot.parse(r);
@@ -535,7 +535,7 @@ function gr(r) {
535
535
  };
536
536
  }
537
537
  }
538
- function wr(r, t) {
538
+ function yr(r, t) {
539
539
  r(
540
540
  "process-kill",
541
541
  {
@@ -544,15 +544,15 @@ function wr(r, t) {
544
544
  inputSchema: ot.shape
545
545
  },
546
546
  async (s) => {
547
- const o = gr(s);
547
+ const o = wr(s);
548
548
  return o.error != null ? `Method: process-kill(${JSON.stringify(s)})
549
549
  ❌ Error: ${o.error}` : `Method: process-kill(${JSON.stringify(s)})
550
550
  ${JSON.stringify(o, null, 2)}`;
551
551
  }
552
552
  );
553
553
  }
554
- function yr(r, t) {
555
- lr(), t.run && hr(r, t), t.status && ur(r, t), t.wait && dr(r, t), t.list && mr(r, t), t.kill && wr(r);
554
+ function br(r, t) {
555
+ cr(), t.run && pr(r, t), t.status && dr(r, t), t.wait && fr(r, t), t.list && gr(r, t), t.kill && yr(r);
556
556
  const s = t.commandLineRules?.map(
557
557
  (o) => `${o.rule.toUpperCase()}: ${o.regexp} (${o.note})`
558
558
  ) || [];
@@ -565,15 +565,15 @@ ${s.map((o) => `- ${o}`).join(`
565
565
  `
566
566
  );
567
567
  }
568
- function br(r, t) {
568
+ function Sr(r, t) {
569
569
  return function(o, e, n) {
570
- const i = async (...a) => {
570
+ const a = async (...i) => {
571
571
  await ne({
572
572
  logFilePath: t.logFilePath,
573
573
  message: "REQUEST",
574
- data: { name: o, args: a }
574
+ data: { name: o, args: i }
575
575
  });
576
- const c = await n(...a);
576
+ const c = await n(...i);
577
577
  return await ne({
578
578
  logFilePath: t.logFilePath,
579
579
  message: "RESPONSE",
@@ -590,27 +590,27 @@ function br(r, t) {
590
590
  return r.registerTool(
591
591
  o,
592
592
  e,
593
- i
593
+ a
594
594
  );
595
595
  };
596
596
  }
597
- function Sr(r) {
597
+ function xr(r) {
598
598
  return r.match(/^[/\\]?[^/\\]+/)[0];
599
599
  }
600
- function xr(r, t) {
601
- return Sr(r) + "|" + t.ino;
600
+ function $r(r, t) {
601
+ return xr(r) + "|" + t.ino;
602
602
  }
603
- function $r(r) {
603
+ function Ir(r) {
604
604
  return r.endsWith(":") && (r += "/"), F.resolve(r);
605
605
  }
606
- const ye = new qt(jt.cpus().length);
606
+ const ye = new _t(Kt.cpus().length);
607
607
  function ve(r, t) {
608
608
  r.totalSize += t.totalSize, r.maxFileDateModified = Math.max(
609
609
  r.maxFileDateModified,
610
610
  t.maxFileDateModified
611
611
  ), r.countFiles += t.countFiles, r.countDirs += t.countDirs, r.countLinks += t.countLinks;
612
612
  }
613
- const Ir = function(t) {
613
+ const Mr = function(t) {
614
614
  return t.code === "ENOENT";
615
615
  };
616
616
  function nt(r) {
@@ -623,16 +623,16 @@ function nt(r) {
623
623
  countDirs: 0,
624
624
  countLinks: 0
625
625
  });
626
- const s = r.level ?? 0, o = r.walkedIds ?? /* @__PURE__ */ new Set(), e = r.abortSignal, n = r.pool ?? ye, i = r.handleError, a = r.priority ?? V(0), c = r.walkLinks ?? !1, l = r.log, u = r.handlePath, f = r.matchPath;
627
- async function d(m) {
628
- if (!(i && await i(m)) && !Ir(m))
626
+ const s = r.level ?? 0, o = r.walkedIds ?? /* @__PURE__ */ new Set(), e = r.abortSignal, n = r.pool ?? ye, a = r.handleError, i = r.priority ?? V(0), c = r.walkLinks ?? !1, l = r.log, u = r.handlePath, d = r.matchPath;
627
+ async function f(m) {
628
+ if (!(a && await a(m)) && !Mr(m))
629
629
  throw m;
630
630
  }
631
631
  function h(m) {
632
632
  return !(!l || l.minTotalContentSize != null && m < l.minTotalContentSize || l.maxNestedLevel != null && s > l.maxNestedLevel);
633
633
  }
634
- return _t(async (m) => {
635
- const g = Gt(e, m), y = {
634
+ return Gt(async (m) => {
635
+ const g = Jt(e, m), y = {
636
636
  totalSize: 0,
637
637
  maxFileDateModified: 0,
638
638
  countFiles: 0,
@@ -659,7 +659,7 @@ function nt(r) {
659
659
  abortSignal: g
660
660
  });
661
661
  } catch (v) {
662
- return await d(v), !1;
662
+ return await f(v), !1;
663
663
  }
664
664
  },
665
665
  count: 1,
@@ -671,14 +671,14 @@ function nt(r) {
671
671
  T || (T = $);
672
672
  const v = await Y({
673
673
  pool: n,
674
- func: () => W.promises.lstat($).catch(d),
674
+ func: () => W.promises.lstat($).catch(f),
675
675
  count: 1,
676
- priority: V(S, V(1, a)),
676
+ priority: V(S, V(1, i)),
677
677
  abortSignal: g
678
678
  });
679
679
  if (!v || !x && v.isFile())
680
680
  return null;
681
- const L = xr($, v);
681
+ const L = $r($, v);
682
682
  if (o.has(L))
683
683
  return null;
684
684
  o.add(L);
@@ -691,13 +691,13 @@ function nt(r) {
691
691
  };
692
692
  const I = V(
693
693
  S,
694
- V(v.isDirectory() ? 2 : 3, a)
694
+ V(v.isDirectory() ? 2 : 3, i)
695
695
  );
696
696
  if (v.isSymbolicLink()) {
697
697
  if (c) {
698
698
  const C = await Y({
699
699
  pool: n,
700
- func: () => W.promises.readlink($).catch(d).then((E) => E ?? null),
700
+ func: () => W.promises.readlink($).catch(f).then((E) => E ?? null),
701
701
  count: 1,
702
702
  priority: I,
703
703
  abortSignal: g
@@ -721,9 +721,9 @@ function nt(r) {
721
721
  } else if (v.isDirectory()) {
722
722
  const C = await Y({
723
723
  pool: n,
724
- func: () => W.promises.readdir($).catch(d),
724
+ func: () => W.promises.readdir($).catch(f),
725
725
  count: 1,
726
- priority: a,
726
+ priority: i,
727
727
  abortSignal: g
728
728
  });
729
729
  if (C) {
@@ -748,7 +748,7 @@ function nt(r) {
748
748
  }
749
749
  const b = [];
750
750
  for (let $ = 0, S = t.length; $ < S; $++) {
751
- const x = $r(t[$]), T = f ? f(x) : !0;
751
+ const x = Ir(t[$]), T = d ? d(x) : !0;
752
752
  T !== !1 && b.push(N(x, $, T));
753
753
  }
754
754
  return await Promise.all(b), y;
@@ -760,7 +760,7 @@ function it(r) {
760
760
  function H(r) {
761
761
  return r.replace(/\\/g, "/");
762
762
  }
763
- function Mr(r, t) {
763
+ function Tr(r, t) {
764
764
  if (!t || t === ".")
765
765
  return r;
766
766
  const s = r.startsWith("^");
@@ -768,14 +768,14 @@ function Mr(r, t) {
768
768
  const o = r.startsWith("!");
769
769
  return o && (r = r.substring(1)), r.startsWith("/") ? (t.endsWith("/") && (t = t.substring(0, t.length - 1)), r = t + r) : (t.endsWith("/") || (t += "/"), r.startsWith("./") ? r = t + r.substring(2) : r.startsWith("../") ? r = t + r : (t.startsWith("..") && (t = ""), r.startsWith("**") ? r = t + r : r = t + "**/" + r)), r = H(F.normalize(r)), o && (r = "!" + r), s && (r = "^" + r), r;
770
770
  }
771
- function Tr(r) {
771
+ function Cr(r) {
772
772
  const t = r.startsWith("!");
773
773
  return t && (r = r.substring(1)), r.startsWith("/") ? r = r.substring(1) : !r.startsWith("**") && !r.startsWith("../") && (r = `**/${r}`), t && (r = "!" + r), r;
774
774
  }
775
775
  function Ne(r) {
776
776
  return "^" + r;
777
777
  }
778
- async function Cr(r) {
778
+ async function vr(r) {
779
779
  const s = (await W.promises.readFile(r, "utf-8")).split(`
780
780
  `), o = [];
781
781
  return s.forEach((e) => {
@@ -795,9 +795,9 @@ async function at(r) {
795
795
  pool: ye,
796
796
  count: 1,
797
797
  func: async () => {
798
- const n = F.resolve(t, e.value), i = await Cr(n), a = F.relative(t, F.dirname(n));
799
- i.forEach((c) => {
800
- c = Tr(c), c = Mr(c, a), s.push(e.exclude ? Ne(c) : c);
798
+ const n = F.resolve(t, e.value), a = await vr(n), i = F.relative(t, F.dirname(n));
799
+ a.forEach((c) => {
800
+ c = Cr(c), c = Tr(c, i), s.push(e.exclude ? Ne(c) : c);
801
801
  });
802
802
  }
803
803
  });
@@ -814,18 +814,18 @@ function lt({
814
814
  e = H(e).trim();
815
815
  const n = e.startsWith("^");
816
816
  n && (e = e.substring(1).trim());
817
- const i = e.startsWith("!");
818
- if (i && (e = e.substring(1).trim()), e.startsWith("!") || e.startsWith("^"))
817
+ const a = e.startsWith("!");
818
+ if (a && (e = e.substring(1).trim()), e.startsWith("!") || e.startsWith("^"))
819
819
  throw new Error(
820
820
  `Invalid glob pattern: "${e}". The syntax '${e.substring(0, 2)}' is not supported. Valid glob patterns use: * (match any characters), ** (match any directories), ? (match single character), [abc] (character class), ! (negate pattern), ^ (exclude if included). Examples of valid patterns: "*.js", "src/**/*.ts", "!node_modules", "^dist". Avoid starting with '!' after '^' or multiple special prefixes.`
821
821
  );
822
822
  e.startsWith("/") && (e = "." + e);
823
- const a = H(t ? F.resolve(t, e) : e);
824
- if (!a)
823
+ const i = H(t ? F.resolve(t, e) : e);
824
+ if (!i)
825
825
  return;
826
826
  let c;
827
827
  try {
828
- c = Kt(a, {
828
+ c = Wt(i, {
829
829
  nocase: s ?? !1,
830
830
  dot: !0,
831
831
  strictBrackets: !0
@@ -838,21 +838,21 @@ function lt({
838
838
  }
839
839
  o.push({
840
840
  exclude: n,
841
- negative: i,
842
- debugInfo: a,
841
+ negative: a,
842
+ debugInfo: i,
843
843
  match: c
844
844
  });
845
845
  }), function(n) {
846
846
  n = H(n);
847
- let i = null, a = !1;
847
+ let a = null, i = !1;
848
848
  for (let c = 0, l = o.length; c < l; c++) {
849
849
  const u = o[c];
850
- u.match(n) && (u.exclude ? a = !u.negative : (i = !u.negative, a = !1));
850
+ u.match(n) && (u.exclude ? i = !u.negative : (a = !u.negative, i = !1));
851
851
  }
852
- return a ? !1 : i;
852
+ return i ? !1 : a;
853
853
  };
854
854
  }
855
- async function vr(r) {
855
+ async function Nr(r) {
856
856
  const t = r.rootDir ?? ".", s = [], o = {};
857
857
  r.result.countFiles && (o.countFiles = 0), r.result.size && (o.size = 0);
858
858
  const e = await at({
@@ -867,13 +867,13 @@ async function vr(r) {
867
867
  rootDir: t,
868
868
  noCase: !0
869
869
  }),
870
- handlePath: async ({ path: n, stat: i, itemStat: a }) => {
871
- const c = F.relative(t, n), l = i.isDirectory(), u = i.isFile();
870
+ handlePath: async ({ path: n, stat: a, itemStat: i }) => {
871
+ const c = F.relative(t, n), l = a.isDirectory(), u = a.isFile();
872
872
  if (!l && !u)
873
873
  return !0;
874
- const f = H(c || "."), d = l ? "dir" : "file", h = l ? a.maxFileDateModified || null : i.mtimeMs, m = l ? a.totalSize : i.size, g = l ? a.countFiles : null, y = {
875
- path: f,
876
- type: d
874
+ const d = H(c || "."), f = l ? "dir" : "file", h = l ? i.maxFileDateModified || null : a.mtimeMs, m = l ? i.totalSize : a.size, g = l ? i.countFiles : null, y = {
875
+ path: d,
876
+ type: f
877
877
  };
878
878
  if (r.result.dateModified && (y.dateModified = h), r.result.size && (y.size = m), r.result.countFiles && (y.countFiles = g), r.dateModified && h != null) {
879
879
  const [w, M] = r.dateModified;
@@ -885,7 +885,7 @@ async function vr(r) {
885
885
  if (w != null && m < w || M != null && m > M)
886
886
  return !1;
887
887
  }
888
- return d === "file" && (o.countFiles = (o.countFiles ?? 0) + 1), d === "file" && m != null && (o.size = (o.size ?? 0) + m), h != null && (o.dateModified == null || h > o.dateModified) && (o.dateModified = h), l && !r.result.dirs || u && !r.result.files || s.push(y), !0;
888
+ return f === "file" && (o.countFiles = (o.countFiles ?? 0) + 1), f === "file" && m != null && (o.size = (o.size ?? 0) + m), h != null && (o.dateModified == null || h > o.dateModified) && (o.dateModified = h), l && !r.result.dirs || u && !r.result.files || s.push(y), !0;
889
889
  }
890
890
  }), { items: s, totals: o };
891
891
  }
@@ -900,52 +900,52 @@ function Oe(r) {
900
900
  function De(r) {
901
901
  const s = Date.now() - r;
902
902
  if (s < 0) return "0s";
903
- const o = Math.floor(s / 1e3), e = Math.floor(o / 60), n = Math.floor(e / 60), i = Math.floor(n / 24), a = Math.floor(i / 7), c = Math.floor(i / 30), l = Math.floor(i / 365);
904
- return l > 0 ? `${l}Y` : c > 0 ? `${c}M` : a > 0 ? `${a}w` : i > 0 ? `${i}d` : n > 0 ? `${n}h` : e > 0 ? `${e}m` : `${o}s`;
903
+ const o = Math.floor(s / 1e3), e = Math.floor(o / 60), n = Math.floor(e / 60), a = Math.floor(n / 24), i = Math.floor(a / 7), c = Math.floor(a / 30), l = Math.floor(a / 365);
904
+ return l > 0 ? `${l}Y` : c > 0 ? `${c}M` : i > 0 ? `${i}w` : a > 0 ? `${a}d` : n > 0 ? `${n}h` : e > 0 ? `${e}m` : `${o}s`;
905
905
  }
906
- function Nr(r, t) {
906
+ function Er(r, t) {
907
907
  return t?.length ? [...r].sort((s, o) => {
908
908
  for (let e = 0, n = t.length; e < n; e++) {
909
- const i = t[e];
910
- let a, c;
911
- switch (i.field) {
909
+ const a = t[e];
910
+ let i, c;
911
+ switch (a.field) {
912
912
  case "type":
913
- a = s.type, c = o.type;
913
+ i = s.type, c = o.type;
914
914
  break;
915
915
  case "path":
916
- a = s.path, c = o.path;
916
+ i = s.path, c = o.path;
917
917
  break;
918
918
  case "dateModified":
919
- a = s.dateModified, c = o.dateModified;
919
+ i = s.dateModified, c = o.dateModified;
920
920
  break;
921
921
  case "size":
922
- a = s.size, c = o.size;
922
+ i = s.size, c = o.size;
923
923
  break;
924
924
  case "countFiles":
925
- a = s.countFiles, c = o.countFiles;
925
+ i = s.countFiles, c = o.countFiles;
926
926
  break;
927
927
  }
928
- if (a == null) {
928
+ if (i == null) {
929
929
  if (c == null)
930
930
  continue;
931
931
  return 1;
932
932
  }
933
933
  if (c == null)
934
934
  return -1;
935
- const l = a > c ? 1 : a < c ? -1 : 0;
935
+ const l = i > c ? 1 : i < c ? -1 : 0;
936
936
  if (l !== 0)
937
- return i.desc ? -l : l;
937
+ return a.desc ? -l : l;
938
938
  }
939
939
  return 0;
940
940
  }) : r;
941
941
  }
942
- function Er(r, t) {
943
- const s = Nr(r.items, t.sort ?? []), o = t.fields && t.fields.length > 0 ? t.fields : [];
942
+ function kr(r, t) {
943
+ const s = Er(r.items, t.sort ?? []), o = t.fields && t.fields.length > 0 ? t.fields : [];
944
944
  let e = "";
945
945
  if (s.length > 0 && o.length > 0) {
946
- for (let n = 0, i = o.length; n < i; n++) {
947
- const a = o[n];
948
- switch (n > 0 && (e += " | "), a) {
946
+ for (let n = 0, a = o.length; n < a; n++) {
947
+ const i = o[n];
948
+ switch (n > 0 && (e += " | "), i) {
949
949
  case "dateModified":
950
950
  e += "Time ago (s/m/h/d/w/M/Y)";
951
951
  break;
@@ -963,27 +963,27 @@ function Er(r, t) {
963
963
  break;
964
964
  }
965
965
  }
966
- for (let n = 0, i = s.length; n < i; n++) {
967
- const a = s[n];
966
+ for (let n = 0, a = s.length; n < a; n++) {
967
+ const i = s[n];
968
968
  e += `
969
969
  `;
970
970
  for (let c = 0, l = o.length; c < l; c++) {
971
971
  const u = o[c];
972
972
  switch (c > 0 && (e += " | "), u) {
973
973
  case "dateModified":
974
- e += a.dateModified ? De(a.dateModified) : "-";
974
+ e += i.dateModified ? De(i.dateModified) : "-";
975
975
  break;
976
976
  case "size":
977
- e += Oe(a.size);
977
+ e += Oe(i.size);
978
978
  break;
979
979
  case "type":
980
- e += a.type;
980
+ e += i.type;
981
981
  break;
982
982
  case "path":
983
- e += a.type === "dir" ? `${a.path}/` : a.path;
983
+ e += i.type === "dir" ? `${i.path}/` : i.path;
984
984
  break;
985
985
  case "countFiles":
986
- a.type === "dir" ? e += a.countFiles != null ? a.countFiles.toString() : "-" : e += "-";
986
+ i.type === "dir" ? e += i.countFiles != null ? i.countFiles.toString() : "-" : e += "-";
987
987
  break;
988
988
  }
989
989
  }
@@ -993,14 +993,14 @@ function Er(r, t) {
993
993
  e.length > 0 && (e += `
994
994
  ---
995
995
  `);
996
- const n = Oe(r.totals.size ?? 0), i = r.totals.dateModified ? `, last modified ${De(r.totals.dateModified)} ago` : "";
997
- e += `Totals: ${r.totals.countFiles ?? 0} files in dirs, ${n}${i}`;
996
+ const n = Oe(r.totals.size ?? 0), a = r.totals.dateModified ? `, last modified ${De(r.totals.dateModified)} ago` : "";
997
+ e += `Totals: ${r.totals.countFiles ?? 0} files in dirs, ${n}${a}`;
998
998
  }
999
999
  return e;
1000
1000
  }
1001
- const kr = "3.0.13", Or = {
1002
- version: kr
1003
- }, fo = "Project Tools", ho = "project-tools", po = Or.version, mo = "d00f70240703039df14c76176a055bce6b5484d2b552ba2c89820f03b8e5e60d", Re = 25e3;
1001
+ const Or = "3.0.14", Dr = {
1002
+ version: Or
1003
+ }, fo = "Project Tools", ho = "project-tools", po = Dr.version, mo = "d00f70240703039df14c76176a055bce6b5484d2b552ba2c89820f03b8e5e60d", Re = 25e3;
1004
1004
  function Fe(r) {
1005
1005
  const t = r.match(
1006
1006
  /^\s*(\d+(?:\.\d+)?)\s*([smhdwMY]|sec(onds?)?|min(utes?)?|hours?|days?|weeks?|months?|years?)\s*$/i
@@ -1095,7 +1095,7 @@ const ct = p.object({
1095
1095
  'Filter files/directories with total size at most this large. Only items with size <= this value will be included. For directories, uses total size of all contents. Format: number + unit (B/KB/MB/GB/TB). Examples: "1MB" (up to 1 megabyte), "500KB" (up to 500 kilobytes), "10GB" (up to 10 gigabytes). Combine with minTotalSize for size ranges'
1096
1096
  )
1097
1097
  });
1098
- async function Dr(r, t) {
1098
+ async function Rr(r, t) {
1099
1099
  let s;
1100
1100
  try {
1101
1101
  s = ct.parse(r);
@@ -1108,8 +1108,8 @@ async function Dr(r, t) {
1108
1108
  globs: o,
1109
1109
  showFiles: e,
1110
1110
  showDirs: n,
1111
- sortBy: i,
1112
- minTimeAgo: a,
1111
+ sortBy: a,
1112
+ minTimeAgo: i,
1113
1113
  maxTimeAgo: c,
1114
1114
  minTotalSize: l,
1115
1115
  maxTotalSize: u
@@ -1118,8 +1118,8 @@ async function Dr(r, t) {
1118
1118
  return {
1119
1119
  error: 'Fields array must include "path" field when fields are specified. The "path" field is required to identify files and directories in the output'
1120
1120
  };
1121
- const f = s.fields ? s.fields.map((g) => g === "totalCountFiles" ? "countFiles" : g === "lastModified" ? "dateModified" : g) : [];
1122
- let d = i?.map((g) => {
1121
+ const d = s.fields ? s.fields.map((g) => g === "totalCountFiles" ? "countFiles" : g === "lastModified" ? "dateModified" : g) : [];
1122
+ let f = a?.map((g) => {
1123
1123
  let y = g.field;
1124
1124
  return y === "totalCountFiles" && (y = "countFiles"), y === "lastModified" && (y = "dateModified"), {
1125
1125
  field: y,
@@ -1127,8 +1127,8 @@ async function Dr(r, t) {
1127
1127
  // Default to ascending if not specified
1128
1128
  };
1129
1129
  }) ?? null;
1130
- (!d || d.length === 0) && (d = [{ field: "path", desc: !1 }]);
1131
- const h = d?.map((g) => g.field) || [], m = F.resolve(
1130
+ (!f || f.length === 0) && (f = [{ field: "path", desc: !1 }]);
1131
+ const h = f?.map((g) => g.field) || [], m = F.resolve(
1132
1132
  t.workingDir || "",
1133
1133
  s.rootDir || ""
1134
1134
  );
@@ -1149,14 +1149,14 @@ async function Dr(r, t) {
1149
1149
  })) : [{ value: "**", valueType: "pattern", exclude: !1 }], y = t.globsExclude || [], w = [...g, ...y], M = {
1150
1150
  files: e ?? !1,
1151
1151
  dirs: n ?? !1,
1152
- dateModified: f.includes("dateModified") || h.includes("dateModified"),
1153
- size: f.includes("size") || h.includes("size"),
1154
- countFiles: f.includes("countFiles") || h.includes("countFiles")
1152
+ dateModified: d.includes("dateModified") || h.includes("dateModified"),
1153
+ size: d.includes("size") || h.includes("size"),
1154
+ countFiles: d.includes("countFiles") || h.includes("countFiles")
1155
1155
  };
1156
1156
  let N = null, b = null;
1157
- if (a || c)
1157
+ if (i || c)
1158
1158
  try {
1159
- const x = Date.now(), T = c ? x - Fe(c) : null, v = a ? x - Fe(a) : null;
1159
+ const x = Date.now(), T = c ? x - Fe(c) : null, v = i ? x - Fe(i) : null;
1160
1160
  N = [T, v];
1161
1161
  } catch (x) {
1162
1162
  return {
@@ -1172,7 +1172,7 @@ async function Dr(r, t) {
1172
1172
  error: x instanceof Error ? x.message : "Unknown error parsing size filter"
1173
1173
  };
1174
1174
  }
1175
- const $ = await vr({
1175
+ const $ = await Nr({
1176
1176
  rootDir: m || null,
1177
1177
  globs: w,
1178
1178
  result: M,
@@ -1182,9 +1182,9 @@ async function Dr(r, t) {
1182
1182
  return $.items.length > Re ? {
1183
1183
  error: `Number of paths (${$.items.length}) exceeds maximum allowed (${Re}). Consider using more specific glob patterns or filters to reduce the result set.`
1184
1184
  } : {
1185
- output: Er($, {
1186
- sort: d,
1187
- fields: f,
1185
+ output: kr($, {
1186
+ sort: f,
1187
+ fields: d,
1188
1188
  totals: !0
1189
1189
  })
1190
1190
  };
@@ -1192,7 +1192,7 @@ async function Dr(r, t) {
1192
1192
  return { error: g instanceof Error ? g.message : "Unknown error" };
1193
1193
  }
1194
1194
  }
1195
- function Rr(r, t) {
1195
+ function Fr(r, t) {
1196
1196
  r(
1197
1197
  "fs-list",
1198
1198
  {
@@ -1201,7 +1201,7 @@ function Rr(r, t) {
1201
1201
  inputSchema: ct.shape
1202
1202
  },
1203
1203
  async (s) => {
1204
- const o = await Dr(s, t);
1204
+ const o = await Rr(s, t);
1205
1205
  return o.error ? `Method: fs-list(${JSON.stringify(s)})
1206
1206
  ❌ Error: ${o.error}` : `Method: fs-list(${JSON.stringify(s)})
1207
1207
  ${o.output || JSON.stringify(o, null, 2)}`;
@@ -1307,7 +1307,7 @@ const be = p.object({
1307
1307
  "dateModified"
1308
1308
  ].map((r, t) => [r, t])
1309
1309
  );
1310
- function Fr(r, t) {
1310
+ function Br(r, t) {
1311
1311
  const s = Ae.get(r) ?? 1 / 0, o = Ae.get(t) ?? 1 / 0;
1312
1312
  return s > o ? 1 : s < o ? -1 : 0;
1313
1313
  }
@@ -1323,8 +1323,8 @@ async function ut(r, t, s) {
1323
1323
  const {
1324
1324
  name: e,
1325
1325
  globs: n,
1326
- types: i,
1327
- minTimeAgo: a,
1326
+ types: a,
1327
+ minTimeAgo: i,
1328
1328
  maxTimeAgo: c,
1329
1329
  minTotalSize: l,
1330
1330
  maxTotalSize: u
@@ -1333,30 +1333,30 @@ async function ut(r, t, s) {
1333
1333
  return {
1334
1334
  error: "Session ID is required"
1335
1335
  };
1336
- const f = Z(s.sessionId), d = H(
1336
+ const d = Z(s.sessionId), f = H(
1337
1337
  F.resolve(t.workingDir || "", o.rootDir || "")
1338
1338
  );
1339
1339
  try {
1340
1340
  try {
1341
- await W.promises.access(d, W.constants.F_OK);
1341
+ await W.promises.access(f, W.constants.F_OK);
1342
1342
  } catch (S) {
1343
1343
  if (S.code === "ENOENT")
1344
1344
  return {
1345
- error: `Directory does not exist: "${d}". Verify the path is correct and accessible. If using rootDir parameter, ensure it exists relative to the current working directory. Use fs-snapshot-query-create without rootDir to snapshot the current directory, or check parent directories first.`
1345
+ error: `Directory does not exist: "${f}". Verify the path is correct and accessible. If using rootDir parameter, ensure it exists relative to the current working directory. Use fs-snapshot-query-create without rootDir to snapshot the current directory, or check parent directories first.`
1346
1346
  };
1347
1347
  throw S;
1348
1348
  }
1349
1349
  const h = o.extraFields ? o.extraFields.map((S) => S === "lastModified" ? "dateModified" : S) : [];
1350
- h.includes("name") || h.push("name"), h.sort(Fr);
1350
+ h.includes("name") || h.push("name"), h.sort(Br);
1351
1351
  const m = n && n.length > 0 ? n.map((S) => ({
1352
1352
  value: S,
1353
1353
  valueType: "pattern",
1354
1354
  exclude: !1
1355
1355
  })) : [{ value: "**", valueType: "pattern", exclude: !1 }], g = t.globsExclude || [], y = [...m, ...g];
1356
1356
  let w = null, M = null;
1357
- if (a || c)
1357
+ if (i || c)
1358
1358
  try {
1359
- const S = Date.now(), x = c ? S - Le(c) : null, T = a ? S - Le(a) : null;
1359
+ const S = Date.now(), x = c ? S - Le(c) : null, T = i ? S - Le(i) : null;
1360
1360
  w = [x, T];
1361
1361
  } catch (S) {
1362
1362
  return {
@@ -1372,9 +1372,9 @@ async function ut(r, t, s) {
1372
1372
  error: S instanceof Error ? S.message : "Unknown error parsing size filter"
1373
1373
  };
1374
1374
  }
1375
- const N = i ? i.includes("file") : !0, b = i ? i.includes("dir") : !0, $ = {
1375
+ const N = a ? a.includes("file") : !0, b = a ? a.includes("dir") : !0, $ = {
1376
1376
  name: e,
1377
- rootDir: d,
1377
+ rootDir: f,
1378
1378
  globs: y,
1379
1379
  matchFiles: N,
1380
1380
  matchDirs: b,
@@ -1382,7 +1382,7 @@ async function ut(r, t, s) {
1382
1382
  totalSize: M,
1383
1383
  fields: h
1384
1384
  };
1385
- return f.fsSnapshotQueries.set(e, $), {
1385
+ return d.fsSnapshotQueries.set(e, $), {
1386
1386
  snapshotQuery: $
1387
1387
  };
1388
1388
  } catch (h) {
@@ -1391,7 +1391,7 @@ async function ut(r, t, s) {
1391
1391
  };
1392
1392
  }
1393
1393
  }
1394
- function Br(r, t) {
1394
+ function Lr(r, t) {
1395
1395
  r(
1396
1396
  "fs-snapshot-query-create",
1397
1397
  {
@@ -1414,29 +1414,29 @@ function ae(r) {
1414
1414
  "Impossible behavior: root node (id: null) not found in idToNode"
1415
1415
  );
1416
1416
  const e = /* @__PURE__ */ new Map();
1417
- return t.forEach((n, i) => {
1417
+ return t.forEach((n, a) => {
1418
1418
  if (n != null) {
1419
1419
  if (e.has(n)) {
1420
- const a = e.get(n);
1420
+ const i = e.get(n);
1421
1421
  throw new Error(
1422
- `Impossible behavior: node appears with multiple IDs (existing: ${a}, new: ${i})`
1422
+ `Impossible behavior: node appears with multiple IDs (existing: ${i}, new: ${a})`
1423
1423
  );
1424
1424
  }
1425
- e.set(n, i);
1425
+ e.set(n, a);
1426
1426
  }
1427
1427
  }), {
1428
1428
  root: o,
1429
1429
  getNode: (n) => t.get(n) ?? null,
1430
1430
  getId: (n) => e.get(n) ?? null,
1431
1431
  getChilds: (n) => {
1432
- let i = e.get(n);
1433
- if (i == null)
1432
+ let a = e.get(n);
1433
+ if (a == null)
1434
1434
  if (n === t.get(null))
1435
- i = null;
1435
+ a = null;
1436
1436
  else
1437
1437
  throw new Error("Impossible behavior: node not found in idToNode");
1438
- const a = s.get(i);
1439
- return a == null ? null : a.map((c) => {
1438
+ const i = s.get(a);
1439
+ return i == null ? null : i.map((c) => {
1440
1440
  const l = t.get(c);
1441
1441
  if (l == null)
1442
1442
  throw new Error(
@@ -1450,41 +1450,41 @@ function ae(r) {
1450
1450
  function dt(r, t, s) {
1451
1451
  let o = null;
1452
1452
  for (let e = 0, n = t.length; e < n; e++) {
1453
- const i = t[e], a = r(i), c = a == null ? null : dt(r, a, s), l = s(i, c);
1453
+ const a = t[e], i = r(a), c = i == null ? null : dt(r, i, s), l = s(a, c);
1454
1454
  l != null && (o == null && (o = []), o.push(l));
1455
1455
  }
1456
1456
  return o;
1457
1457
  }
1458
1458
  function ft(r) {
1459
- const { getId: t, getChilds: s, rootNodes: o, createSnapshotNode: e } = r, n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), c = dt(
1459
+ const { getId: t, getChilds: s, rootNodes: o, createSnapshotNode: e } = r, n = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), c = dt(
1460
1460
  s,
1461
1461
  o,
1462
- (u, f) => {
1463
- const d = e(u, f);
1464
- if (u != null && d != null) {
1462
+ (u, d) => {
1463
+ const f = e(u, d);
1464
+ if (u != null && f != null) {
1465
1465
  const h = t(u);
1466
- n.set(h, d), i.set(d, h);
1466
+ n.set(h, f), a.set(f, h);
1467
1467
  }
1468
- return d != null && f != null && a.set(
1469
- i.get(d),
1470
- f.map((h) => i.get(h))
1471
- ), d;
1468
+ return f != null && d != null && i.set(
1469
+ a.get(f),
1470
+ d.map((h) => a.get(h))
1471
+ ), f;
1472
1472
  }
1473
1473
  ), l = e(null, c);
1474
1474
  if (l == null)
1475
1475
  throw new Error("Impossible behavior: rootNode == null");
1476
- return n.set(null, l), c != null && a.set(
1476
+ return n.set(null, l), c != null && i.set(
1477
1477
  null,
1478
- c.map((u) => i.get(u))
1478
+ c.map((u) => a.get(u))
1479
1479
  ), {
1480
1480
  idToNode: n,
1481
- idToChildIds: a
1481
+ idToChildIds: i
1482
1482
  };
1483
1483
  }
1484
1484
  function pe(r) {
1485
1485
  return r = r != null ? H(r).replace(/\/$/, "") : null, !r || r === "." ? null : r;
1486
1486
  }
1487
- async function Lr(r) {
1487
+ async function Pr(r) {
1488
1488
  const t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), o = F.resolve(r.rootDir || "."), n = {
1489
1489
  path: ".",
1490
1490
  name: F.basename(o),
@@ -1494,7 +1494,7 @@ async function Lr(r) {
1494
1494
  size: 0
1495
1495
  };
1496
1496
  t.set(null, n);
1497
- const i = await at({
1497
+ const a = await at({
1498
1498
  rootDir: o,
1499
1499
  globs: r.globs
1500
1500
  });
@@ -1502,31 +1502,31 @@ async function Lr(r) {
1502
1502
  paths: [o],
1503
1503
  walkLinks: !0,
1504
1504
  matchPath: lt({
1505
- globs: i,
1505
+ globs: a,
1506
1506
  rootDir: o,
1507
1507
  noCase: !0
1508
1508
  }),
1509
- handlePath: async ({ path: a, stat: c, itemStat: l }) => {
1510
- const u = F.relative(o, a), f = c.isDirectory(), d = c.isFile();
1511
- if (!f && !d)
1509
+ handlePath: async ({ path: i, stat: c, itemStat: l }) => {
1510
+ const u = F.relative(o, i), d = c.isDirectory(), f = c.isFile();
1511
+ if (!d && !f)
1512
1512
  return !0;
1513
- const h = pe(u || "."), m = f ? "dir" : "file", g = f ? null : c.mtimeMs, y = c.size;
1513
+ const h = pe(u || "."), m = d ? "dir" : "file", g = d ? null : c.mtimeMs, y = c.size;
1514
1514
  let w = !0;
1515
- if (d && !r.matchFiles && (w = !1), f && !r.matchDirs && (w = !1), w && d && r.dateModified && g != null) {
1515
+ if (f && !r.matchFiles && (w = !1), d && !r.matchDirs && (w = !1), w && f && r.dateModified && g != null) {
1516
1516
  const [$, S] = r.dateModified;
1517
1517
  ($ != null && g < $ || S != null && g > S) && (w = !1);
1518
1518
  }
1519
- if (w && d && r.totalSize && y != null) {
1519
+ if (w && f && r.totalSize && y != null) {
1520
1520
  const [$, S] = r.totalSize;
1521
1521
  ($ != null && y < $ || S != null && y > S) && (w = !1);
1522
1522
  }
1523
- if (f && !w) {
1523
+ if (d && !w) {
1524
1524
  if (!(l.countFiles && l.countFiles > 0)) return !1;
1525
1525
  } else if (!w)
1526
1526
  return !1;
1527
1527
  const M = {
1528
1528
  path: h ?? ".",
1529
- name: F.basename(a),
1529
+ name: F.basename(i),
1530
1530
  type: m,
1531
1531
  dateModified: g,
1532
1532
  size: y,
@@ -1544,7 +1544,7 @@ async function Lr(r) {
1544
1544
  idToChildIds: s
1545
1545
  };
1546
1546
  }
1547
- const Pr = [
1547
+ const Ar = [
1548
1548
  { name: "[ ]", match: (r) => r === 32, min: 2, max: 81 },
1549
1549
  { name: "[\\t]", match: (r) => r === 9, min: 2, max: 20 },
1550
1550
  { name: "[\\n]", match: (r) => r === 10, min: 2, max: 14 },
@@ -1567,7 +1567,7 @@ const Pr = [
1567
1567
  // max: 2,
1568
1568
  // },
1569
1569
  ];
1570
- function ze(r, t = Pr) {
1570
+ function ze(r, t = Ar) {
1571
1571
  const s = r.length;
1572
1572
  if (s === 0) return 0;
1573
1573
  const o = t.length;
@@ -1575,21 +1575,21 @@ function ze(r, t = Pr) {
1575
1575
  return s;
1576
1576
  let e = 0, n = 0;
1577
1577
  for (; n < s; ) {
1578
- const i = r.charCodeAt(n);
1579
- let a = !1;
1578
+ const a = r.charCodeAt(n);
1579
+ let i = !1;
1580
1580
  for (let c = 0; c < o; c++) {
1581
1581
  const l = t[c];
1582
- if (l.match(i)) {
1582
+ if (l.match(a)) {
1583
1583
  let u = 1;
1584
1584
  for (; ++n < s && l.match(r.charCodeAt(n)) && u < l.max; )
1585
1585
  u++;
1586
1586
  if (u >= l.min) {
1587
- e++, a = !0;
1587
+ e++, i = !0;
1588
1588
  break;
1589
1589
  }
1590
1590
  }
1591
1591
  }
1592
- a || (n++, e++);
1592
+ i || (n++, e++);
1593
1593
  }
1594
1594
  return e;
1595
1595
  }
@@ -1598,20 +1598,20 @@ function ht(r) {
1598
1598
  return t += ze(r.textOpen) + 1, r.textClose != null && (t += ze(r.textClose) + 1), r.indent && (t += 1), t;
1599
1599
  }
1600
1600
  const Ue = ["B", "KB", "MB", "GB", "TB"], qe = 1024;
1601
- function Ar(r) {
1601
+ function zr(r) {
1602
1602
  if (r == null) return "-";
1603
1603
  let t = r ?? 0, s = 0;
1604
1604
  for (; t >= qe && s < Ue.length - 1; )
1605
1605
  t /= qe, s++;
1606
1606
  return `${s === 0 ? t.toString() : t.toFixed(2)}${Ue[s]}`;
1607
1607
  }
1608
- function zr(r) {
1608
+ function Ur(r) {
1609
1609
  const s = Date.now() - r;
1610
1610
  if (s < 0) return "0s";
1611
- const o = Math.floor(s / 1e3), e = Math.floor(o / 60), n = Math.floor(e / 60), i = Math.floor(n / 24), a = Math.floor(i / 7), c = Math.floor(i / 30), l = Math.floor(i / 365);
1612
- return l > 0 ? `${l}Y` : c > 0 ? `${c}M` : a > 0 ? `${a}w` : i > 0 ? `${i}d` : n > 0 ? `${n}h` : e > 0 ? `${e}m` : `${o}s`;
1611
+ const o = Math.floor(s / 1e3), e = Math.floor(o / 60), n = Math.floor(e / 60), a = Math.floor(n / 24), i = Math.floor(a / 7), c = Math.floor(a / 30), l = Math.floor(a / 365);
1612
+ return l > 0 ? `${l}Y` : c > 0 ? `${c}M` : i > 0 ? `${i}w` : a > 0 ? `${a}d` : n > 0 ? `${n}h` : e > 0 ? `${e}m` : `${o}s`;
1613
1613
  }
1614
- function Ur(r) {
1614
+ function qr(r) {
1615
1615
  return function(s, o) {
1616
1616
  const e = r.get(s), n = r.get(o);
1617
1617
  if (e.type !== n.type)
@@ -1619,31 +1619,31 @@ function Ur(r) {
1619
1619
  if (e.type === "file")
1620
1620
  return e.name < n.name ? -1 : e.name > n.name ? 1 : 0;
1621
1621
  {
1622
- const i = e.countFiles || 0, a = n.countFiles || 0;
1623
- return i < a ? -1 : i > a ? 1 : e.name < n.name ? -1 : e.name > n.name ? 1 : 0;
1622
+ const a = e.countFiles || 0, i = n.countFiles || 0;
1623
+ return a < i ? -1 : a > i ? 1 : e.name < n.name ? -1 : e.name > n.name ? 1 : 0;
1624
1624
  }
1625
1625
  };
1626
1626
  }
1627
- function qr(r) {
1627
+ function _r(r) {
1628
1628
  const t = r.fields ?? [];
1629
1629
  return function(o, e) {
1630
- let n = "", i, a = 0;
1630
+ let n = "", a, i = 0;
1631
1631
  const c = e ? e.length : 0;
1632
- let l = 1, u, f = 0, d = 0, h = 0, m = 0, g = null, y, w, M;
1632
+ let l = 1, u, d = 0, f = 0, h = 0, m = 0, g = null, y, w, M;
1633
1633
  if (e)
1634
1634
  for (let b = 0; b < e.length; b++) {
1635
1635
  const $ = e[b];
1636
- a += $.countMatched, l += $.countTotal, f += $.tokens, d += $.tokensTotal, h += $.size, m += $.countFiles, $.dateModified != null && (g == null || $.dateModified > g) && (g = $.dateModified);
1636
+ i += $.countMatched, l += $.countTotal, d += $.tokens, f += $.tokensTotal, h += $.size, m += $.countFiles, $.dateModified != null && (g == null || $.dateModified > g) && (g = $.dateModified);
1637
1637
  }
1638
- o ? (y = o.type, w = o.name, M = o.path, i = o.isMatched, i && (a += 1), o.type === "file" ? (h = o.size || 0, m = 1, g = o.dateModified || null) : o.dateModified != null && (g == null || o.dateModified > g) && (g = o.dateModified)) : (y = "dir", w = "<root>", M = ".", i = !0);
1638
+ o ? (y = o.type, w = o.name, M = o.path, a = o.isMatched, a && (i += 1), o.type === "file" ? (h = o.size || 0, m = 1, g = o.dateModified || null) : o.dateModified != null && (g == null || o.dateModified > g) && (g = o.dateModified)) : (y = "dir", w = "<root>", M = ".", a = !0);
1639
1639
  for (let b = 0, $ = t.length; b < $; b++) {
1640
1640
  const S = t[b];
1641
1641
  switch (b > 0 && (n += " "), S) {
1642
1642
  case "dateModified":
1643
- n += g ? zr(g) : "-";
1643
+ n += g ? Ur(g) : "-";
1644
1644
  break;
1645
1645
  case "size":
1646
- n += Ar(h);
1646
+ n += zr(h);
1647
1647
  break;
1648
1648
  case "type":
1649
1649
  n += y;
@@ -1652,7 +1652,7 @@ function qr(r) {
1652
1652
  n += y === "dir" ? `${w}/` : w;
1653
1653
  break;
1654
1654
  case "countMatched":
1655
- n += a.toString();
1655
+ n += i.toString();
1656
1656
  break;
1657
1657
  }
1658
1658
  }
@@ -1661,17 +1661,17 @@ function qr(r) {
1661
1661
  textOpen: n,
1662
1662
  textClose: null
1663
1663
  };
1664
- return u = ht(N), d += u, {
1664
+ return u = ht(N), f += u, {
1665
1665
  type: y,
1666
1666
  name: w,
1667
1667
  path: M,
1668
- isMatched: i,
1669
- countMatched: a,
1668
+ isMatched: a,
1669
+ countMatched: i,
1670
1670
  countChilds: c,
1671
1671
  countTotal: l,
1672
1672
  tokens: u,
1673
- tokensChilds: f,
1674
- tokensTotal: d,
1673
+ tokensChilds: d,
1674
+ tokensTotal: f,
1675
1675
  text: N,
1676
1676
  size: h,
1677
1677
  countFiles: m,
@@ -1679,22 +1679,22 @@ function qr(r) {
1679
1679
  };
1680
1680
  };
1681
1681
  }
1682
- async function _r(r) {
1683
- const t = await Lr(r), s = ae(t), o = s.getChilds(s.root), e = ft({
1684
- getId: (i) => {
1685
- const a = s.getId(i);
1686
- if (a == null)
1682
+ async function Gr(r) {
1683
+ const t = await Pr(r), s = ae(t), o = s.getChilds(s.root), e = ft({
1684
+ getId: (a) => {
1685
+ const i = s.getId(a);
1686
+ if (i == null)
1687
1687
  throw new Error(
1688
- `Invalid tree structure: node ID is null for node ${JSON.stringify(i)}`
1688
+ `Invalid tree structure: node ID is null for node ${JSON.stringify(a)}`
1689
1689
  );
1690
- return a;
1690
+ return i;
1691
1691
  },
1692
- getChilds: (i) => s.getChilds(i),
1693
- createSnapshotNode: qr(r),
1692
+ getChilds: (a) => s.getChilds(a),
1693
+ createSnapshotNode: _r(r),
1694
1694
  rootNodes: o ?? []
1695
- }), n = Ur(e.idToNode);
1696
- return e.idToChildIds.forEach((i) => {
1697
- i.sort(n);
1695
+ }), n = qr(e.idToNode);
1696
+ return e.idToChildIds.forEach((a) => {
1697
+ a.sort(n);
1698
1698
  }), ae(e);
1699
1699
  }
1700
1700
  const X = p.object({
@@ -1715,27 +1715,27 @@ async function le(r, t, s) {
1715
1715
  error: B(u)
1716
1716
  };
1717
1717
  }
1718
- const { name: e, queryName: n, query: i } = o;
1718
+ const { name: e, queryName: n, query: a } = o;
1719
1719
  if (!s.sessionId)
1720
1720
  return {
1721
1721
  error: "Session ID is required"
1722
1722
  };
1723
- const a = Z(s.sessionId);
1724
- if (n && i)
1723
+ const i = Z(s.sessionId);
1724
+ if (n && a)
1725
1725
  return {
1726
1726
  error: "Either queryName or query must be provided, not both"
1727
1727
  };
1728
1728
  let c, l = !1;
1729
1729
  if (n) {
1730
- const u = a.fsSnapshotQueries.get(n);
1730
+ const u = i.fsSnapshotQueries.get(n);
1731
1731
  if (!u)
1732
1732
  return {
1733
1733
  error: `Filesystem snapshot query "${n}" not found`
1734
1734
  };
1735
1735
  c = u;
1736
- } else if (i) {
1736
+ } else if (a) {
1737
1737
  const u = await ut(
1738
- i,
1738
+ a,
1739
1739
  t,
1740
1740
  s
1741
1741
  );
@@ -1749,13 +1749,13 @@ async function le(r, t, s) {
1749
1749
  error: "Either queryName or query must be provided"
1750
1750
  };
1751
1751
  try {
1752
- const u = await _r(c), f = {
1752
+ const u = await Gr(c), d = {
1753
1753
  name: e,
1754
1754
  query: c,
1755
1755
  tree: u
1756
1756
  };
1757
- return a.fsSnapshots.set(e, f), {
1758
- fsSnapshot: f,
1757
+ return i.fsSnapshots.set(e, d), {
1758
+ fsSnapshot: d,
1759
1759
  queryCreated: l
1760
1760
  };
1761
1761
  } catch (u) {
@@ -1764,7 +1764,7 @@ async function le(r, t, s) {
1764
1764
  };
1765
1765
  }
1766
1766
  }
1767
- function Gr(r, t) {
1767
+ function Jr(r, t) {
1768
1768
  r(
1769
1769
  "fs-snapshot-create",
1770
1770
  {
@@ -1784,7 +1784,7 @@ function Gr(r, t) {
1784
1784
  }
1785
1785
  );
1786
1786
  }
1787
- class Jr {
1787
+ class jr {
1788
1788
  _first = null;
1789
1789
  _last = null;
1790
1790
  _size = 0;
@@ -1807,19 +1807,19 @@ class Jr {
1807
1807
  return this._size;
1808
1808
  }
1809
1809
  }
1810
- function jr(r) {
1811
- const t = new Jr(), {
1810
+ function Kr(r) {
1811
+ const t = new jr(), {
1812
1812
  tree: s,
1813
- limits: { maxCountTotal: o, maxTokensTotal: e, maxCountGroup: n, maxTokensGroup: i },
1814
- indexRangeGroupStrategy: a
1813
+ limits: { maxCountTotal: o, maxTokensTotal: e, maxCountGroup: n, maxTokensGroup: a },
1814
+ indexRangeGroupStrategy: i
1815
1815
  } = r, c = s.getChilds(s.root);
1816
1816
  c != null && c.length > 0 && t.enqueue({
1817
1817
  reportNode: null,
1818
1818
  node: s.root
1819
1819
  });
1820
- let l = null, u = 0, f = 0;
1820
+ let l = null, u = 0, d = 0;
1821
1821
  for (; !t.isEmpty(); ) {
1822
- const { reportNode: d, node: h } = t.dequeue(), m = s.getChilds(h);
1822
+ const { reportNode: f, node: h } = t.dequeue(), m = s.getChilds(h);
1823
1823
  if (m == null || h.countChilds === 0 || m.length !== h.countChilds)
1824
1824
  throw new Error(
1825
1825
  "Impossible behavior: nodeChilds is null or length mismatch"
@@ -1827,30 +1827,30 @@ function jr(r) {
1827
1827
  let g = t.size();
1828
1828
  for (let w = 0; w < m.length; w++)
1829
1829
  m[w].countChilds > 0 && (g += 1);
1830
- const y = g * a.tokens;
1831
- if (o != null && u + h.countChilds + g > o || e != null && f + h.tokensChilds + y > e) {
1830
+ const y = g * i.tokens;
1831
+ if (o != null && u + h.countChilds + g > o || e != null && d + h.tokensChilds + y > e) {
1832
1832
  const w = [];
1833
1833
  let M = null, N = 0;
1834
1834
  for (let $ = 0, S = m.length; $ < S; $++) {
1835
- const x = m[$], T = N * a.tokens;
1835
+ const x = m[$], T = N * i.tokens;
1836
1836
  M != null && // Если общий лимит превышен, то не создаем новую группу, а продолжаем текущую. В случае достижения лимитов, последняя группа может содержать больше элементов, чем указано в лимитах группы, и это допустимо. Главное - дать в отчете полную картину.
1837
- !(o != null && u + 1 > o || e != null && f + a.tokens > e) && (n != null && M.countGrouped + 1 + N > n || i != null && M.tokensGrouped + x.tokens + T > i) && (w.push(M), u += 1, f += a.tokens, M = null, N = 0), M = a.add(M, x, $), x.countChilds > 0 && (N += 1);
1837
+ !(o != null && u + 1 > o || e != null && d + i.tokens > e) && (n != null && M.countGrouped + 1 + N > n || a != null && M.tokensGrouped + x.tokens + T > a) && (w.push(M), u += 1, d += i.tokens, M = null, N = 0), M = i.add(M, x, $), x.countChilds > 0 && (N += 1);
1838
1838
  }
1839
- M != null && (w.push(M), u += 1, f += a.tokens);
1839
+ M != null && (w.push(M), u += 1, d += i.tokens);
1840
1840
  const b = w.map(($) => ({
1841
- text: a.getReportText($)
1841
+ text: i.getReportText($)
1842
1842
  }));
1843
- if (d != null) {
1844
- if (d.childs != null)
1843
+ if (f != null) {
1844
+ if (f.childs != null)
1845
1845
  throw new Error("Impossible behavior: reportNode.childs != null");
1846
- d.childs = b;
1846
+ f.childs = b;
1847
1847
  } else {
1848
1848
  if (l != null)
1849
1849
  throw new Error("Impossible behavior: reportRootNodes != null");
1850
1850
  l = b;
1851
1851
  }
1852
1852
  } else {
1853
- u += h.countChilds, f += h.tokensChilds;
1853
+ u += h.countChilds, d += h.tokensChilds;
1854
1854
  const w = [];
1855
1855
  for (let M = 0; M < m.length; M++) {
1856
1856
  const N = m[M], b = {
@@ -1863,10 +1863,10 @@ function jr(r) {
1863
1863
  node: N
1864
1864
  });
1865
1865
  }
1866
- if (d != null) {
1867
- if (d.childs != null)
1866
+ if (f != null) {
1867
+ if (f.childs != null)
1868
1868
  throw new Error("Impossible behavior: reportNode.childs != null");
1869
- d.childs = w;
1869
+ f.childs = w;
1870
1870
  } else {
1871
1871
  if (l != null)
1872
1872
  throw new Error("Impossible behavior: reportRootNodes != null");
@@ -1881,50 +1881,50 @@ function pt(r) {
1881
1881
  tree: t,
1882
1882
  request: { parentNodeId: s, childsIndexRange: o, limits: e },
1883
1883
  indexRangeGroupStrategy: n,
1884
- ...i
1884
+ ...a
1885
1885
  } = r;
1886
- let a;
1886
+ let i;
1887
1887
  if (s != null) {
1888
- const d = t.getNode(s);
1889
- if (d == null)
1888
+ const f = t.getNode(s);
1889
+ if (f == null)
1890
1890
  throw new Error(`Parent node "${s}" not found`);
1891
- a = d;
1891
+ i = f;
1892
1892
  } else
1893
- a = t.root;
1894
- let c, l = t.getChilds(a) ?? [];
1893
+ i = t.root;
1894
+ let c, l = t.getChilds(i) ?? [];
1895
1895
  if (o != null) {
1896
- const [d, h] = o;
1897
- if (d < 0 || h <= d || h >= l.length)
1896
+ const [f, h] = o;
1897
+ if (f < 0 || h <= f || h >= l.length)
1898
1898
  throw new Error(
1899
- `Invalid index range: ${d}-${h} for root nodes length ${l.length}`
1899
+ `Invalid index range: ${f}-${h} for root nodes length ${l.length}`
1900
1900
  );
1901
1901
  const m = [];
1902
1902
  let g = null;
1903
- for (let y = d; y <= h; y++) {
1903
+ for (let y = f; y <= h; y++) {
1904
1904
  const w = l[y];
1905
1905
  m.push(w), g = n.add(g, w, y);
1906
1906
  }
1907
1907
  l = m, c = {
1908
- ...a,
1908
+ ...i,
1909
1909
  text: n.getReportText(g),
1910
1910
  countChilds: g.countGrouped,
1911
1911
  tokensChilds: g.tokensGrouped
1912
1912
  };
1913
1913
  } else
1914
- c = a;
1914
+ c = i;
1915
1915
  const u = {
1916
1916
  countChilds: 1,
1917
1917
  tokensChilds: c.tokens
1918
- }, f = {
1918
+ }, d = {
1919
1919
  ...t,
1920
1920
  root: u,
1921
- getChilds: (d) => d === u ? [c] : d === c ? l : t.getChilds(d)
1921
+ getChilds: (f) => f === u ? [c] : f === c ? l : t.getChilds(f)
1922
1922
  };
1923
- return jr({
1924
- tree: f,
1923
+ return Kr({
1924
+ tree: d,
1925
1925
  limits: e,
1926
1926
  indexRangeGroupStrategy: n,
1927
- ...i
1927
+ ...a
1928
1928
  });
1929
1929
  }
1930
1930
  function mt(r, t) {
@@ -1932,8 +1932,8 @@ function mt(r, t) {
1932
1932
  return "No results found";
1933
1933
  let s = "";
1934
1934
  function o(e, n) {
1935
- for (let i = 0, a = e.length; i < a; i++) {
1936
- const c = e[i];
1935
+ for (let a = 0, i = e.length; a < i; a++) {
1936
+ const c = e[a];
1937
1937
  s += n, s += c.text.textOpen + `
1938
1938
  `, c.childs != null && c.childs.length > 0 && o(
1939
1939
  c.childs,
@@ -1944,7 +1944,7 @@ function mt(r, t) {
1944
1944
  }
1945
1945
  return o(r, ""), s;
1946
1946
  }
1947
- class Kr {
1947
+ class Wr {
1948
1948
  tokens = 16;
1949
1949
  // +1 indent, +1 for line break
1950
1950
  getReportText = (t) => ({
@@ -1981,7 +1981,7 @@ const gt = p.object({
1981
1981
  // maxCountGroup: z.number().default(10).describe('Maximum items per group'),
1982
1982
  // maxTokensGroup: z.number().default(1000).describe('Maximum tokens per group'),
1983
1983
  });
1984
- async function Wr(r, t, s) {
1984
+ async function Hr(r, t, s) {
1985
1985
  let o;
1986
1986
  try {
1987
1987
  o = gt.parse(r);
@@ -1993,24 +1993,24 @@ async function Wr(r, t, s) {
1993
1993
  const {
1994
1994
  snapshotName: e,
1995
1995
  snapshot: n,
1996
- childsIndexRange: i
1996
+ childsIndexRange: a
1997
1997
  // maxCountTotal,
1998
1998
  // maxTokensTotal,
1999
1999
  // maxCountGroup,
2000
2000
  // maxTokensGroup,
2001
- } = o, a = 60, c = 1e3, l = 25, u = 900;
2001
+ } = o, i = 60, c = 1e3, l = 25, u = 900;
2002
2002
  if (!s.sessionId)
2003
2003
  return {
2004
2004
  error: "Session ID is required"
2005
2005
  };
2006
- const f = Z(s.sessionId);
2006
+ const d = Z(s.sessionId);
2007
2007
  if (e && n)
2008
2008
  return {
2009
2009
  error: "Either snapshotName or snapshot must be provided, not both"
2010
2010
  };
2011
- let d, h = !1, m = !1;
2011
+ let f, h = !1, m = !1;
2012
2012
  if (e) {
2013
- if (d = f.fsSnapshots.get(e), d == null)
2013
+ if (f = d.fsSnapshots.get(e), f == null)
2014
2014
  return {
2015
2015
  error: `Filesystem snapshot "${e}" not found`
2016
2016
  };
@@ -2024,32 +2024,32 @@ async function Wr(r, t, s) {
2024
2024
  return {
2025
2025
  error: g.error
2026
2026
  };
2027
- d = g.fsSnapshot, h = g.queryCreated, m = !0;
2027
+ f = g.fsSnapshot, h = g.queryCreated, m = !0;
2028
2028
  } else
2029
2029
  return {
2030
2030
  error: "Either snapshotName or snapshot must be provided"
2031
2031
  };
2032
2032
  try {
2033
2033
  const g = pe(o.parentPath), y = pt({
2034
- tree: d.tree,
2034
+ tree: f.tree,
2035
2035
  request: {
2036
2036
  parentNodeId: g,
2037
- childsIndexRange: i,
2037
+ childsIndexRange: a,
2038
2038
  limits: {
2039
- maxCountTotal: a,
2039
+ maxCountTotal: i,
2040
2040
  maxTokensTotal: c,
2041
2041
  maxCountGroup: l,
2042
2042
  maxTokensGroup: u
2043
2043
  }
2044
2044
  },
2045
- indexRangeGroupStrategy: new Kr()
2045
+ indexRangeGroupStrategy: new Wr()
2046
2046
  }), w = mt(y);
2047
2047
  return {
2048
- fsSnapshot: d,
2048
+ fsSnapshot: f,
2049
2049
  queryCreated: h,
2050
2050
  snapshotCreated: m,
2051
2051
  parentPath: g,
2052
- childsIndexRange: i,
2052
+ childsIndexRange: a,
2053
2053
  report: w
2054
2054
  };
2055
2055
  } catch (g) {
@@ -2058,7 +2058,7 @@ async function Wr(r, t, s) {
2058
2058
  };
2059
2059
  }
2060
2060
  }
2061
- function Hr(r, t) {
2061
+ function Qr(r, t) {
2062
2062
  r(
2063
2063
  "fs-snapshot-browse",
2064
2064
  {
@@ -2067,7 +2067,7 @@ function Hr(r, t) {
2067
2067
  inputSchema: gt.shape
2068
2068
  },
2069
2069
  async (s, o) => {
2070
- const e = await Wr(s, t, o);
2070
+ const e = await Hr(s, t, o);
2071
2071
  if (e.error != null)
2072
2072
  return `Method: fs-snapshot-browse(${JSON.stringify(s)})
2073
2073
  ❌ Error: ${e.error}`;
@@ -2078,10 +2078,10 @@ function Hr(r, t) {
2078
2078
  `), n += `✅ Browsing filesystem snapshot "${e.fsSnapshot.name}":
2079
2079
  `, n += `Root directory (<root>/): ${e.fsSnapshot.query.rootDir || "./"}
2080
2080
  `, n += `Parent path: ${"./" + (e.parentPath ?? "")}
2081
- `, n += `Fields: ${e.fsSnapshot.query.fields.map((i) => i === "dateModified" ? "lastModified" : i).join(" ")}
2081
+ `, n += `Fields: ${e.fsSnapshot.query.fields.map((a) => a === "dateModified" ? "lastModified" : a).join(" ")}
2082
2082
  `, e.childsIndexRange) {
2083
- const [i, a] = e.childsIndexRange, l = (e.parentPath ? e.fsSnapshot.tree.getNode(e.parentPath) : e.fsSnapshot.tree.root).countChilds;
2084
- n += ` Showing indexes: ${i}-${a} of ${l}
2083
+ const [a, i] = e.childsIndexRange, l = (e.parentPath ? e.fsSnapshot.tree.getNode(e.parentPath) : e.fsSnapshot.tree.root).countChilds;
2084
+ n += ` Showing indexes: ${a}-${i} of ${l}
2085
2085
  `;
2086
2086
  }
2087
2087
  return n += `
@@ -2093,22 +2093,22 @@ function wt(r) {
2093
2093
  const t = [], s = r.tree, o = r.query.rootDir ?? ".";
2094
2094
  function e(n) {
2095
2095
  n.type === "file" && n.isMatched && t.push(o + "/" + n.path);
2096
- const i = s.getChilds(n);
2097
- if (i != null)
2098
- for (let a = 0; a < i.length; a++)
2099
- e(i[a]);
2096
+ const a = s.getChilds(n);
2097
+ if (a != null)
2098
+ for (let i = 0; i < a.length; i++)
2099
+ e(a[i]);
2100
2100
  }
2101
2101
  return e(s.root), t;
2102
2102
  }
2103
2103
  const _e = /* @__PURE__ */ new Map();
2104
- function Qr(r) {
2104
+ function Yr(r) {
2105
2105
  const t = H(r);
2106
2106
  let s = _e.get(t);
2107
- return s == null && (s = new Jt(), _e.set(t, s)), s;
2107
+ return s == null && (s = new jt(), _e.set(t, s)), s;
2108
2108
  }
2109
- async function Yr(r) {
2109
+ async function Vr(r) {
2110
2110
  const { filePath: t, func: s } = r;
2111
- return Qr(t).lock(
2111
+ return Yr(t).lock(
2112
2112
  () => Y({
2113
2113
  pool: ye,
2114
2114
  count: 1,
@@ -2116,13 +2116,13 @@ async function Yr(r) {
2116
2116
  })
2117
2117
  );
2118
2118
  }
2119
- const Ge = 10, te = 48, Je = 57, ue = 36, Vr = 38, Zr = 39, Xr = 60, es = 62, ts = 96, re = 0, je = 1, Ke = 2, We = 3, He = 4, rs = 5;
2120
- function ss(r) {
2119
+ const Ge = 10, te = 48, Je = 57, ue = 36, Zr = 38, Xr = 39, es = 60, ts = 62, rs = 96, re = 0, je = 1, Ke = 2, We = 3, He = 4, ss = 5;
2120
+ function os(r) {
2121
2121
  const { content: t, pattern: s, replacement: o } = r, e = t.length, n = [0];
2122
2122
  for (let b = 0; b < e; b++)
2123
2123
  t.charCodeAt(b) === Ge && b + 1 < e && n.push(b + 1);
2124
- const i = n.length, a = [], c = [];
2125
- let l = null, u = null, f = null, d = 0;
2124
+ const a = n.length, i = [], c = [];
2125
+ let l = null, u = null, d = null, f = 0;
2126
2126
  if (o != null) {
2127
2127
  const b = o.length;
2128
2128
  let $ = !1;
@@ -2132,7 +2132,7 @@ function ss(r) {
2132
2132
  break;
2133
2133
  }
2134
2134
  if ($) {
2135
- u = [], f = [];
2135
+ u = [], d = [];
2136
2136
  let S = 0, x = 0;
2137
2137
  for (; x < b; ) {
2138
2138
  if (o.charCodeAt(x) !== ue || x + 1 >= b) {
@@ -2143,11 +2143,11 @@ function ss(r) {
2143
2143
  let v = -1, L = 0, k = 2;
2144
2144
  if (T === ue)
2145
2145
  v = re, L = "$";
2146
- else if (T === Vr)
2146
+ else if (T === Zr)
2147
2147
  v = je;
2148
- else if (T === ts)
2148
+ else if (T === rs)
2149
2149
  v = Ke;
2150
- else if (T === Zr)
2150
+ else if (T === Xr)
2151
2151
  v = We;
2152
2152
  else if (T >= te && T <= Je) {
2153
2153
  let I = x + 2;
@@ -2157,15 +2157,15 @@ function ss(r) {
2157
2157
  I++;
2158
2158
  }
2159
2159
  v = He, L = o.substring(x + 1, I), k = I - x;
2160
- } else if (T === Xr) {
2160
+ } else if (T === es) {
2161
2161
  let I = x + 2;
2162
- for (; I < b && o.charCodeAt(I) !== es; )
2162
+ for (; I < b && o.charCodeAt(I) !== ts; )
2163
2163
  I++;
2164
- I < b && I > x + 2 && (v = rs, L = o.substring(x + 2, I), k = I + 1 - x);
2164
+ I < b && I > x + 2 && (v = ss, L = o.substring(x + 2, I), k = I + 1 - x);
2165
2165
  }
2166
- v >= 0 ? (x > S && (u.push(re), f.push(o.substring(S, x))), u.push(v), f.push(L), x += k, S = x) : x++;
2166
+ v >= 0 ? (x > S && (u.push(re), d.push(o.substring(S, x))), u.push(v), d.push(L), x += k, S = x) : x++;
2167
2167
  }
2168
- S < b && (u.push(re), f.push(o.substring(S))), d = u.length;
2168
+ S < b && (u.push(re), d.push(o.substring(S))), f = u.length;
2169
2169
  } else
2170
2170
  l = o;
2171
2171
  }
@@ -2175,26 +2175,26 @@ function ss(r) {
2175
2175
  for (; (y = s.exec(t)) !== null; ) {
2176
2176
  const b = y.index, $ = y[0], S = $.length, x = b + S;
2177
2177
  let T, v, L, k;
2178
- if (i === 1)
2178
+ if (a === 1)
2179
2179
  T = 0, v = 1, L = 0, k = e;
2180
2180
  else {
2181
- let I = 0, C = i - 1;
2181
+ let I = 0, C = a - 1;
2182
2182
  for (; I < C; ) {
2183
2183
  const E = I + C + 1 >> 1;
2184
2184
  n[E] <= b ? I = E : C = E - 1;
2185
2185
  }
2186
2186
  if (T = I, S > 0) {
2187
2187
  const E = x - 1;
2188
- for (C = i - 1; I < C; ) {
2188
+ for (C = a - 1; I < C; ) {
2189
2189
  const O = I + C + 1 >> 1;
2190
2190
  n[O] <= E ? I = O : C = O - 1;
2191
2191
  }
2192
2192
  v = I + 1;
2193
2193
  } else
2194
2194
  v = T + 1;
2195
- L = n[T], k = v < i ? n[v] : e;
2195
+ L = n[T], k = v < a ? n[v] : e;
2196
2196
  }
2197
- if (a.push({
2197
+ if (i.push({
2198
2198
  offset: [b, x],
2199
2199
  lines: [T, v],
2200
2200
  linesOffset: [L, k]
@@ -2206,9 +2206,9 @@ function ss(r) {
2206
2206
  else {
2207
2207
  I = "";
2208
2208
  const E = y.groups, O = y.length - 1;
2209
- for (let K = 0; K < d; K++) {
2210
- const q = u[K], A = f[K];
2211
- switch (q) {
2209
+ for (let K = 0; K < f; K++) {
2210
+ const _ = u[K], A = d[K];
2211
+ switch (_) {
2212
2212
  case re:
2213
2213
  I += A;
2214
2214
  break;
@@ -2224,7 +2224,7 @@ function ss(r) {
2224
2224
  case He: {
2225
2225
  const P = A, U = P.length, z = P.charCodeAt(0) - te;
2226
2226
  if (U >= 2) {
2227
- const _ = P.charCodeAt(1) - te, D = z * 10 + _;
2227
+ const G = P.charCodeAt(1) - te, D = z * 10 + G;
2228
2228
  if (D >= 1 && D <= O) {
2229
2229
  I += y[D] ?? "", U > 2 && (I += P.substring(2));
2230
2230
  break;
@@ -2250,7 +2250,7 @@ function ss(r) {
2250
2250
  break;
2251
2251
  }
2252
2252
  if (s.lastIndex = 0, o == null)
2253
- return { search: { content: t, matches: a }, replace: null };
2253
+ return { search: { content: t, matches: i }, replace: null };
2254
2254
  h += t.substring(m);
2255
2255
  const w = h.length, M = [0];
2256
2256
  for (let b = 0; b < w; b++)
@@ -2281,117 +2281,149 @@ function ss(r) {
2281
2281
  S.lines[0] = v, S.lines[1] = L, S.linesOffset[0] = k, S.linesOffset[1] = I;
2282
2282
  }
2283
2283
  return {
2284
- search: { content: t, matches: a },
2284
+ search: { content: t, matches: i },
2285
2285
  replace: { content: h, matches: c }
2286
2286
  };
2287
2287
  }
2288
+ function yt(r) {
2289
+ if (r.length === 0)
2290
+ return [];
2291
+ const t = [...r].sort((a, i) => {
2292
+ const c = a.lines[0], l = i.lines[0];
2293
+ if (c > l) return 1;
2294
+ if (c < l) return -1;
2295
+ const u = a.lines[1], d = i.lines[1];
2296
+ return u > d ? 1 : u < d ? -1 : 0;
2297
+ }), s = [];
2298
+ let o = [...t[0].offset], e = [...t[0].lines], n = [...t[0].linesOffset];
2299
+ for (let a = 1; a < t.length; a++) {
2300
+ const i = t[a];
2301
+ i.lines[0] <= e[1] ? (i.offset[0] < o[0] && (o[0] = i.offset[0]), i.offset[1] > o[1] && (o[1] = i.offset[1]), i.lines[1] > e[1] && (e[1] = i.lines[1], n[1] = i.linesOffset[1])) : (s.push({
2302
+ offset: o,
2303
+ lines: e,
2304
+ linesOffset: n
2305
+ }), o = [...i.offset], e = [...i.lines], n = [...i.linesOffset]);
2306
+ }
2307
+ return s.push({
2308
+ offset: o,
2309
+ lines: e,
2310
+ linesOffset: n
2311
+ }), s;
2312
+ }
2288
2313
  function se(r, t, s, o) {
2289
2314
  let e = 0, n = 0;
2290
2315
  for (let u = 0; u < s; u++)
2291
2316
  r.charCodeAt(u) === 10 && (n = u + 1, e++);
2292
- const i = e, a = n;
2317
+ const a = e, i = n;
2293
2318
  let c = s;
2294
2319
  for (; c < o; c++)
2295
2320
  r.charCodeAt(c) === 10 && e++;
2296
2321
  const l = e + 1;
2297
2322
  for (; c < t; c++)
2298
2323
  if (r.charCodeAt(c) === 10)
2299
- return { startLine: i, endLine: l, startLineOfs: a, endLineOfs: c + 1 };
2300
- return { startLine: i, endLine: l, startLineOfs: a, endLineOfs: t };
2301
- }
2302
- function os(r, t) {
2303
- const s = r.replace ?? r.search, o = t.replace ?? t.search, e = r.search.content, n = o.content, i = e.length, a = n.length, c = r.search.matches, l = s.matches, u = t.search.matches, f = o.matches, d = l.length, h = u.length, m = [], g = [];
2304
- let y = 0, w = 0, M = 0, N = 0, b = 0, $ = 0, S = 0, x = 0, T = 0, v = 0, L = 0, k = 0, I = 0, C = 0, E = 0, O = 0, K = 0, q = 0, A = 0, P = 0, U = 0, z = 0, _ = 0, D = 0;
2305
- for (; y < d || w < h; )
2306
- if (y < d && (b = l[y].offset[0], $ = l[y].offset[1]), w < h && (S = u[w].offset[0], x = u[w].offset[1]), y < d && w < h && b < x && S < $) {
2324
+ return { startLine: a, endLine: l, startLineOfs: i, endLineOfs: c + 1 };
2325
+ return { startLine: a, endLine: l, startLineOfs: i, endLineOfs: t };
2326
+ }
2327
+ function ns(r, t) {
2328
+ if (r.replace == null && t.replace == null) {
2329
+ const q = [...r.search.matches, ...t.search.matches];
2330
+ return {
2331
+ search: { content: r.search.content, matches: yt(q) },
2332
+ replace: null
2333
+ };
2334
+ }
2335
+ const s = r.replace ?? r.search, o = t.replace ?? t.search, e = r.search.content, n = o.content, a = e.length, i = n.length, c = r.search.matches, l = s.matches, u = t.search.matches, d = o.matches, f = l.length, h = u.length, m = [], g = [];
2336
+ let y = 0, w = 0, M = 0, N = 0, b = 0, $ = 0, S = 0, x = 0, T = 0, v = 0, L = 0, k = 0, I = 0, C = 0, E = 0, O = 0, K = 0, _ = 0, A = 0, P = 0, U = 0, z = 0, G = 0, D = 0;
2337
+ for (; y < f || w < h; )
2338
+ if (y < f && (b = l[y].offset[0], $ = l[y].offset[1]), w < h && (S = u[w].offset[0], x = u[w].offset[1]), y < f && w < h && b < x && S < $) {
2307
2339
  K = b < S ? b : S, T = $ > x ? $ : x, L = y, k = w, y++, w++;
2308
2340
  do {
2309
- for (v = T; y < d && l[y].offset[0] < T; )
2341
+ for (v = T; y < f && l[y].offset[0] < T; )
2310
2342
  $ = l[y].offset[1], $ > T && (T = $), y++;
2311
2343
  for (; w < h && u[w].offset[0] < T; )
2312
2344
  x = u[w].offset[1], x > T && (T = x), w++;
2313
2345
  } while (T !== v);
2314
- I = 1 / 0, C = -1 / 0, q = K, A = M;
2346
+ I = 1 / 0, C = -1 / 0, _ = K, A = M;
2315
2347
  for (let J = L; J < y; J++)
2316
- P = c[J].offset[0], U = c[J].offset[1], z = l[J].offset[0], _ = l[J].offset[1], q < z && (D = q + A, D < I && (I = D), D = z + A, D > C && (C = D)), P < I && (I = P), U > C && (C = U), A += U - P - _ + z, q = _;
2317
- q < T && (D = q + A, D < I && (I = D), D = T + A, D > C && (C = D)), M = A, E = 1 / 0, O = -1 / 0, q = K, A = N;
2348
+ P = c[J].offset[0], U = c[J].offset[1], z = l[J].offset[0], G = l[J].offset[1], _ < z && (D = _ + A, D < I && (I = D), D = z + A, D > C && (C = D)), P < I && (I = P), U > C && (C = U), A += U - P - G + z, _ = G;
2349
+ _ < T && (D = _ + A, D < I && (I = D), D = T + A, D > C && (C = D)), M = A, E = 1 / 0, O = -1 / 0, _ = K, A = N;
2318
2350
  for (let J = k; J < w; J++)
2319
- P = u[J].offset[0], U = u[J].offset[1], z = f[J].offset[0], _ = f[J].offset[1], q < P && (D = q + A, D < E && (E = D), D = P + A, D > O && (O = D)), z < E && (E = z), _ > O && (O = _), A += _ - z - U + P, q = U;
2320
- q < T && (D = q + A, D < E && (E = D), D = T + A, D > O && (O = D)), N = A;
2321
- const G = se(e, i, I, C);
2351
+ P = u[J].offset[0], U = u[J].offset[1], z = d[J].offset[0], G = d[J].offset[1], _ < P && (D = _ + A, D < E && (E = D), D = P + A, D > O && (O = D)), z < E && (E = z), G > O && (O = G), A += G - z - U + P, _ = U;
2352
+ _ < T && (D = _ + A, D < E && (E = D), D = T + A, D > O && (O = D)), N = A;
2353
+ const q = se(e, a, I, C);
2322
2354
  m.push({
2323
2355
  offset: [I, C],
2324
- lines: [G.startLine, G.endLine],
2325
- linesOffset: [G.startLineOfs, G.endLineOfs]
2356
+ lines: [q.startLine, q.endLine],
2357
+ linesOffset: [q.startLineOfs, q.endLineOfs]
2326
2358
  });
2327
- const ee = se(n, a, E, O);
2359
+ const ee = se(n, i, E, O);
2328
2360
  g.push({
2329
2361
  offset: [E, O],
2330
2362
  lines: [ee.startLine, ee.endLine],
2331
2363
  linesOffset: [ee.startLineOfs, ee.endLineOfs]
2332
2364
  });
2333
- } else if (w >= h || y < d && b <= S) {
2334
- P = c[y].offset[0], U = c[y].offset[1], z = l[y].offset[0], _ = l[y].offset[1], E = z + N, O = _ + N;
2335
- const G = se(n, a, E, O);
2365
+ } else if (w >= h || y < f && b <= S) {
2366
+ P = c[y].offset[0], U = c[y].offset[1], z = l[y].offset[0], G = l[y].offset[1], E = z + N, O = G + N;
2367
+ const q = se(n, i, E, O);
2336
2368
  m.push(c[y]), g.push({
2337
2369
  offset: [E, O],
2338
- lines: [G.startLine, G.endLine],
2339
- linesOffset: [G.startLineOfs, G.endLineOfs]
2340
- }), M += U - P - _ + z, y++;
2370
+ lines: [q.startLine, q.endLine],
2371
+ linesOffset: [q.startLineOfs, q.endLineOfs]
2372
+ }), M += U - P - G + z, y++;
2341
2373
  } else {
2342
- P = u[w].offset[0], U = u[w].offset[1], z = f[w].offset[0], _ = f[w].offset[1], I = P + M, C = U + M;
2343
- const G = se(e, i, I, C);
2374
+ P = u[w].offset[0], U = u[w].offset[1], z = d[w].offset[0], G = d[w].offset[1], I = P + M, C = U + M;
2375
+ const q = se(e, a, I, C);
2344
2376
  m.push({
2345
2377
  offset: [I, C],
2346
- lines: [G.startLine, G.endLine],
2347
- linesOffset: [G.startLineOfs, G.endLineOfs]
2348
- }), g.push(f[w]), N += _ - z - U + P, w++;
2378
+ lines: [q.startLine, q.endLine],
2379
+ linesOffset: [q.startLineOfs, q.endLineOfs]
2380
+ }), g.push(d[w]), N += G - z - U + P, w++;
2349
2381
  }
2350
2382
  return {
2351
2383
  search: { content: e, matches: m },
2352
2384
  replace: { content: n, matches: g }
2353
2385
  };
2354
2386
  }
2355
- async function ns(r) {
2387
+ async function is(r) {
2356
2388
  const { filePath: t, operations: s, dryRun: o } = r;
2357
- return s.length === 0 ? { filePath: t, result: null } : Yr({
2389
+ return s.length === 0 ? { filePath: t, result: null } : Vr({
2358
2390
  filePath: t,
2359
2391
  func: async () => {
2360
2392
  let e;
2361
2393
  try {
2362
2394
  e = await W.promises.readFile(t, "utf-8");
2363
- } catch (a) {
2395
+ } catch (i) {
2364
2396
  return {
2365
2397
  filePath: t,
2366
2398
  result: null,
2367
- error: `Failed to read file: ${a instanceof Error ? a.message : a + ""}`
2399
+ error: `Failed to read file: ${i instanceof Error ? i.message : i + ""}`
2368
2400
  };
2369
2401
  }
2370
- let n = null, i = !1;
2371
- for (let a = 0; a < s.length; a++) {
2372
- const c = s[a];
2402
+ let n = null, a = !1;
2403
+ for (let i = 0; i < s.length; i++) {
2404
+ const c = s[i];
2373
2405
  let l;
2374
2406
  try {
2375
2407
  l = new RegExp(c.pattern, c.flags ?? "");
2376
- } catch (d) {
2408
+ } catch (f) {
2377
2409
  return {
2378
2410
  filePath: t,
2379
2411
  result: null,
2380
- error: `Invalid RegExp pattern "${c.pattern}": ${d instanceof Error ? d.message : d + ""}`
2412
+ error: `Invalid RegExp pattern "${c.pattern}": ${f instanceof Error ? f.message : f + ""}`
2381
2413
  };
2382
2414
  }
2383
- const u = n?.replace?.content ?? e, f = ss({
2415
+ const u = n?.replace?.content ?? e, d = os({
2384
2416
  content: u,
2385
2417
  pattern: l,
2386
2418
  replacement: c.replacement
2387
2419
  });
2388
- c.replacement != null && (i = !0), n == null ? n = f : n = os(n, f);
2420
+ c.replacement != null && (a = !0), n == null ? n = d : n = ns(n, d);
2389
2421
  }
2390
- if (i && n?.replace != null && !o) {
2391
- const a = n.replace.content;
2392
- if (a !== e)
2422
+ if (a && n?.replace != null && !o) {
2423
+ const i = n.replace.content;
2424
+ if (i !== e)
2393
2425
  try {
2394
- await W.promises.writeFile(t, a, "utf-8");
2426
+ await W.promises.writeFile(t, i, "utf-8");
2395
2427
  } catch (c) {
2396
2428
  return {
2397
2429
  filePath: t,
@@ -2404,45 +2436,22 @@ async function ns(r) {
2404
2436
  }
2405
2437
  });
2406
2438
  }
2407
- async function yt(r) {
2439
+ async function bt(r) {
2408
2440
  const { filePaths: t, operations: s, dryRun: o } = r;
2409
2441
  return { results: await Promise.all(
2410
2442
  t.map(
2411
- (n) => ns({ filePath: n, operations: s, dryRun: o })
2443
+ (n) => is({ filePath: n, operations: s, dryRun: o })
2412
2444
  )
2413
2445
  ) };
2414
2446
  }
2415
- function is(r) {
2416
- if (r.length === 0)
2417
- return [];
2418
- const t = [...r].sort((n, i) => {
2419
- const a = n.lines[0], c = i.lines[0];
2420
- if (a > c) return 1;
2421
- if (a < c) return -1;
2422
- const l = n.lines[1], u = i.lines[1];
2423
- return l > u ? 1 : l < u ? -1 : 0;
2424
- }), s = [];
2425
- let o = [...t[0].lines], e = [...t[0].linesOffset];
2426
- for (let n = 1; n < t.length; n++) {
2427
- const i = t[n];
2428
- i.lines[0] <= o[1] ? i.lines[1] > o[1] && (o[1] = i.lines[1], e[1] = i.linesOffset[1]) : (s.push({
2429
- lines: o,
2430
- linesOffset: e
2431
- }), o = [...i.lines], e = [...i.linesOffset]);
2432
- }
2433
- return s.push({
2434
- lines: o,
2435
- linesOffset: e
2436
- }), s;
2437
- }
2438
2447
  const as = 6;
2439
2448
  function ls(r) {
2440
2449
  const { content: t, startLine: s } = r, o = r.padWidth ?? as;
2441
- let e = "", n = 0, i = 0;
2450
+ let e = "", n = 0, a = 0;
2442
2451
  for (; n < t.length; ) {
2443
- const a = t.indexOf(`
2444
- `, n), c = a === -1 ? t.length : a + 1;
2445
- e += String(s + i + 1).padStart(o) + "→" + t.substring(n, c), n = c, i++;
2452
+ const i = t.indexOf(`
2453
+ `, n), c = i === -1 ? t.length : i + 1;
2454
+ e += String(s + a + 1).padStart(o) + "→" + t.substring(n, c), n = c, a++;
2446
2455
  }
2447
2456
  return e.length > 0 && !e.endsWith(`
2448
2457
  `) && (e += `
@@ -2452,24 +2461,24 @@ function de(r) {
2452
2461
  const { content: t, matches: s, outputLimit: o } = r;
2453
2462
  if (s.length === 0)
2454
2463
  return { output: "", truncated: !1 };
2455
- const e = is(s);
2456
- let n = "", i = !1;
2457
- for (let a = 0; a < e.length; a++) {
2458
- const c = e[a], l = t.substring(
2464
+ const e = yt(s);
2465
+ let n = "", a = !1;
2466
+ for (let i = 0; i < e.length; i++) {
2467
+ const c = e[i], l = t.substring(
2459
2468
  c.linesOffset[0],
2460
2469
  c.linesOffset[1]
2461
2470
  ), u = ls({
2462
2471
  content: l,
2463
2472
  startLine: c.lines[0]
2464
- }), f = a > 0 ? 2 : 0;
2465
- if (o != null && n.length + f + u.length > o) {
2466
- i = !0;
2473
+ }), d = i > 0 ? 2 : 0;
2474
+ if (o != null && n.length + d + u.length > o) {
2475
+ a = !0;
2467
2476
  break;
2468
2477
  }
2469
- a > 0 && (n += `⋮
2478
+ i > 0 && (n += `⋮
2470
2479
  `), n += u;
2471
2480
  }
2472
- return { output: n, truncated: i };
2481
+ return { output: n, truncated: a };
2473
2482
  }
2474
2483
  const Qe = "BEFORE", Ye = "AFTER";
2475
2484
  function cs(r) {
@@ -2485,35 +2494,35 @@ function cs(r) {
2485
2494
  const o = `<${Qe}>
2486
2495
  `, e = `</${Qe}>
2487
2496
  `, n = `<${Ye}>
2488
- `, i = `</${Ye}>
2489
- `, a = o.length + e.length + n.length + i.length;
2490
- if (s != null && s < a)
2497
+ `, a = `</${Ye}>
2498
+ `, i = o.length + e.length + n.length + a.length;
2499
+ if (s != null && s < i)
2491
2500
  return { output: "", truncated: !0 };
2492
- const c = s != null ? s - a : void 0, l = c != null ? Math.floor(c / 2) : void 0, u = de({
2501
+ const c = s != null ? s - i : void 0, l = c != null ? Math.floor(c / 2) : void 0, u = de({
2493
2502
  content: t.search.content,
2494
2503
  matches: t.search.matches,
2495
2504
  outputLimit: l
2496
- }), f = c != null ? c - u.output.length : void 0, d = de({
2505
+ }), d = c != null ? c - u.output.length : void 0, f = de({
2497
2506
  content: t.replace.content,
2498
2507
  matches: t.replace.matches,
2499
- outputLimit: f
2508
+ outputLimit: d
2500
2509
  });
2501
- return { output: o + u.output + e + n + d.output + i, truncated: u.truncated || d.truncated };
2510
+ return { output: o + u.output + e + n + f.output + a, truncated: u.truncated || f.truncated };
2502
2511
  }
2503
2512
  const Ve = `
2504
2513
  ... [truncated, too much output, use more specific search patterns] ...
2505
2514
  `;
2506
- function bt(r) {
2515
+ function St(r) {
2507
2516
  const { result: t, rootDir: s, outputLimit: o } = r, e = o - Ve.length;
2508
- let n = "", i = !1;
2509
- for (let a = 0; a < t.results.length; a++) {
2510
- const c = t.results[a], l = F.relative(s, c.filePath), u = n.length > 0 ? 1 : 0;
2517
+ let n = "", a = !1;
2518
+ for (let i = 0; i < t.results.length; i++) {
2519
+ const c = t.results[i], l = F.relative(s, c.filePath), u = n.length > 0 ? 1 : 0;
2511
2520
  if (c.error != null) {
2512
2521
  const h = l + `
2513
2522
  ❌ ` + c.error + `
2514
2523
  `;
2515
2524
  if (n.length + u + h.length > e) {
2516
- i = !0;
2525
+ a = !0;
2517
2526
  break;
2518
2527
  }
2519
2528
  u > 0 && (n += `
@@ -2522,26 +2531,26 @@ function bt(r) {
2522
2531
  }
2523
2532
  if (c.result == null || c.result.search.matches.length === 0)
2524
2533
  continue;
2525
- const f = e - n.length - u - l.length - 1;
2526
- if (f <= 0) {
2527
- i = !0;
2534
+ const d = e - n.length - u - l.length - 1;
2535
+ if (d <= 0) {
2536
+ a = !0;
2528
2537
  break;
2529
2538
  }
2530
- const d = cs({
2539
+ const f = cs({
2531
2540
  result: c.result,
2532
- outputLimit: f
2541
+ outputLimit: d
2533
2542
  });
2534
- if (i = i || d.truncated, d.output.length > 0 && (u > 0 && (n += `
2543
+ if (a = a || f.truncated, f.output.length > 0 && (u > 0 && (n += `
2535
2544
  `), n += l + `
2536
- ` + d.output), i)
2545
+ ` + f.output), a)
2537
2546
  break;
2538
2547
  }
2539
- return i && (n += Ve), n;
2548
+ return a && (n += Ve), n;
2540
2549
  }
2541
2550
  const us = p.object({
2542
2551
  pattern: p.string().describe("JS RegExp pattern"),
2543
2552
  flags: p.string().optional().describe("JS RegExp flags")
2544
- }), St = p.object({
2553
+ }), xt = p.object({
2545
2554
  snapshotName: p.string().optional().describe("Name of previously created filesystem snapshot, to use"),
2546
2555
  snapshot: X.optional().describe(
2547
2556
  "Filesystem snapshot creation options JSON to automatically create snapshot"
@@ -2554,13 +2563,13 @@ const us = p.object({
2554
2563
  async function ds(r, t, s) {
2555
2564
  let o;
2556
2565
  try {
2557
- o = St.parse(r);
2566
+ o = xt.parse(r);
2558
2567
  } catch (y) {
2559
2568
  return {
2560
2569
  error: B(y)
2561
2570
  };
2562
2571
  }
2563
- const { snapshotName: e, snapshot: n, operations: i, outputLimit: a } = o;
2572
+ const { snapshotName: e, snapshot: n, operations: a, outputLimit: i } = o;
2564
2573
  if (!s.sessionId)
2565
2574
  return {
2566
2575
  error: "Session ID is required"
@@ -2570,7 +2579,7 @@ async function ds(r, t, s) {
2570
2579
  return {
2571
2580
  error: "Either snapshotName or snapshot must be provided, not both"
2572
2581
  };
2573
- let l, u = !1, f = !1;
2582
+ let l, u = !1, d = !1;
2574
2583
  if (e) {
2575
2584
  if (l = c.fsSnapshots.get(e), l == null)
2576
2585
  return {
@@ -2586,20 +2595,20 @@ async function ds(r, t, s) {
2586
2595
  return {
2587
2596
  error: y.error
2588
2597
  };
2589
- l = y.fsSnapshot, u = y.queryCreated, f = !0;
2598
+ l = y.fsSnapshot, u = y.queryCreated, d = !0;
2590
2599
  } else
2591
2600
  return {
2592
2601
  error: "Either snapshotName or snapshot must be provided"
2593
2602
  };
2594
- const d = wt(l), h = l.query.rootDir ?? ".", m = await yt({
2595
- filePaths: d,
2596
- operations: i
2603
+ const f = wt(l), h = l.query.rootDir ?? ".", m = await bt({
2604
+ filePaths: f,
2605
+ operations: a
2597
2606
  });
2598
- return { output: bt({
2607
+ return { output: St({
2599
2608
  result: m,
2600
2609
  rootDir: h,
2601
- outputLimit: a
2602
- }), rootDir: h, fsSnapshot: l, queryCreated: u, snapshotCreated: f };
2610
+ outputLimit: i
2611
+ }), rootDir: h, fsSnapshot: l, queryCreated: u, snapshotCreated: d };
2603
2612
  }
2604
2613
  function fs(r, t) {
2605
2614
  r(
@@ -2607,7 +2616,7 @@ function fs(r, t) {
2607
2616
  {
2608
2617
  title: "Search File Contents in Snapshot",
2609
2618
  description: "Search file contents using JS RegExp. Use this to find text patterns across snapshot files. Combine all patterns into the `operations` array within one tool call; never split patterns across multiple tool calls",
2610
- inputSchema: St.shape
2619
+ inputSchema: xt.shape
2611
2620
  },
2612
2621
  async (s, o) => {
2613
2622
  const e = await ds(
@@ -2633,7 +2642,7 @@ const hs = p.object({
2633
2642
  pattern: p.string().describe("JS RegExp pattern"),
2634
2643
  flags: p.string().optional().describe("JS RegExp flags"),
2635
2644
  replacement: p.string().describe("JS replacement pattern")
2636
- }), xt = p.object({
2645
+ }), $t = p.object({
2637
2646
  snapshotName: p.string().optional().describe("Name of previously created filesystem snapshot, to use"),
2638
2647
  snapshot: X.optional().describe(
2639
2648
  "Filesystem snapshot creation options JSON to automatically create snapshot"
@@ -2649,13 +2658,13 @@ const hs = p.object({
2649
2658
  async function ps(r, t, s) {
2650
2659
  let o;
2651
2660
  try {
2652
- o = xt.parse(r);
2661
+ o = $t.parse(r);
2653
2662
  } catch (w) {
2654
2663
  return {
2655
2664
  error: B(w)
2656
2665
  };
2657
2666
  }
2658
- const { snapshotName: e, snapshot: n, operations: i, outputLimit: a, dryRun: c } = o;
2667
+ const { snapshotName: e, snapshot: n, operations: a, outputLimit: i, dryRun: c } = o;
2659
2668
  if (!s.sessionId)
2660
2669
  return {
2661
2670
  error: "Session ID is required"
@@ -2665,7 +2674,7 @@ async function ps(r, t, s) {
2665
2674
  return {
2666
2675
  error: "Either snapshotName or snapshot must be provided, not both"
2667
2676
  };
2668
- let u, f = !1, d = !1;
2677
+ let u, d = !1, f = !1;
2669
2678
  if (e) {
2670
2679
  if (u = l.fsSnapshots.get(e), u == null)
2671
2680
  return {
@@ -2681,21 +2690,21 @@ async function ps(r, t, s) {
2681
2690
  return {
2682
2691
  error: w.error
2683
2692
  };
2684
- u = w.fsSnapshot, f = w.queryCreated, d = !0;
2693
+ u = w.fsSnapshot, d = w.queryCreated, f = !0;
2685
2694
  } else
2686
2695
  return {
2687
2696
  error: "Either snapshotName or snapshot must be provided"
2688
2697
  };
2689
- const h = wt(u), m = u.query.rootDir ?? ".", g = await yt({
2698
+ const h = wt(u), m = u.query.rootDir ?? ".", g = await bt({
2690
2699
  filePaths: h,
2691
- operations: i,
2700
+ operations: a,
2692
2701
  dryRun: c
2693
2702
  });
2694
- return { output: bt({
2703
+ return { output: St({
2695
2704
  result: g,
2696
2705
  rootDir: m,
2697
- outputLimit: a
2698
- }), rootDir: m, fsSnapshot: u, queryCreated: f, snapshotCreated: d };
2706
+ outputLimit: i
2707
+ }), rootDir: m, fsSnapshot: u, queryCreated: d, snapshotCreated: f };
2699
2708
  }
2700
2709
  function ms(r, t) {
2701
2710
  r(
@@ -2703,7 +2712,7 @@ function ms(r, t) {
2703
2712
  {
2704
2713
  title: "Replace File Contents in Snapshot",
2705
2714
  description: "Replace file contents using JS RegExp. Use this to perform bulk replacements across snapshot files. Combine all patterns into the `operations` array within one tool call; never split patterns across multiple tool calls",
2706
- inputSchema: xt.shape
2715
+ inputSchema: $t.shape
2707
2716
  },
2708
2717
  async (s, o) => {
2709
2718
  const e = await ps(
@@ -2726,7 +2735,7 @@ ${e.output}`, n += "\n\nReminder: combine all patterns into one `operations` arr
2726
2735
  );
2727
2736
  }
2728
2737
  function gs(r, t) {
2729
- t.list && Rr(r, t), t.snapshotQueryCreate && Br(r, t), t.snapshotCreate && Gr(r, t), t.snapshotBrowse && Hr(r, t), t.snapshotSearch && fs(r, t), t.snapshotReplace && ms(r, t), console.log(
2738
+ t.list && Fr(r, t), t.snapshotQueryCreate && Lr(r, t), t.snapshotCreate && Jr(r, t), t.snapshotBrowse && Qr(r, t), t.snapshotSearch && fs(r, t), t.snapshotReplace && ms(r, t), console.log(
2730
2739
  `File manager:
2731
2740
  - Working directory: ${F.resolve(t.workingDir || "")}
2732
2741
  `
@@ -2747,7 +2756,7 @@ const Se = p.object({
2747
2756
  muteAudio: p.boolean().optional().describe("Mute audio in the browser"),
2748
2757
  devTools: p.boolean().optional().describe("Open browser with dev tools")
2749
2758
  });
2750
- async function $t(r, t, s) {
2759
+ async function It(r, t, s) {
2751
2760
  let o;
2752
2761
  try {
2753
2762
  o = Se.parse(r);
@@ -2756,7 +2765,7 @@ async function $t(r, t, s) {
2756
2765
  error: B(l)
2757
2766
  };
2758
2767
  }
2759
- const { name: e, browserType: n, muteAudio: i, devTools: a } = o;
2768
+ const { name: e, browserType: n, muteAudio: a, devTools: i } = o;
2760
2769
  if (!s.sessionId)
2761
2770
  return {
2762
2771
  error: "Session ID is required"
@@ -2764,20 +2773,20 @@ async function $t(r, t, s) {
2764
2773
  const c = j(s.sessionId);
2765
2774
  try {
2766
2775
  const u = await {
2767
- chromium: Qt,
2768
- firefox: Ht,
2769
- webkit: Wt
2776
+ chromium: Yt,
2777
+ firefox: Qt,
2778
+ webkit: Ht
2770
2779
  }[n].launch({
2771
2780
  headless: !1,
2772
- devtools: a,
2773
- args: i ? ["--mute-audio"] : void 0
2774
- }), f = {
2781
+ devtools: i,
2782
+ args: a ? ["--mute-audio"] : void 0
2783
+ }), d = {
2775
2784
  name: e,
2776
2785
  browserType: n,
2777
2786
  browser: u,
2778
2787
  contexts: /* @__PURE__ */ new Map()
2779
2788
  };
2780
- return c.browsers.set(e, f), { browserInfo: f };
2789
+ return c.browsers.set(e, d), { browserInfo: d };
2781
2790
  } catch (l) {
2782
2791
  return {
2783
2792
  error: `Failed to create browser: ${l instanceof Error ? l.message : "Unknown error"}`
@@ -2793,20 +2802,20 @@ function ws(r, t) {
2793
2802
  inputSchema: Se.shape
2794
2803
  },
2795
2804
  async (s, o) => {
2796
- const e = await $t(s, t, o);
2805
+ const e = await It(s, t, o);
2797
2806
  return `Method: playwright-browser-create(${JSON.stringify(s)})
2798
2807
  ${e.error != null ? `❌ Error: ${e.error}` : `✅ Browser "${e.browserInfo.name}" (${e.browserInfo.browserType}) created successfully`}`;
2799
2808
  }
2800
2809
  );
2801
2810
  }
2802
- const It = p.object({});
2811
+ const Mt = p.object({});
2803
2812
  async function ys(r, t, s) {
2804
2813
  let o;
2805
2814
  try {
2806
- o = It.parse(r);
2807
- } catch (i) {
2815
+ o = Mt.parse(r);
2816
+ } catch (a) {
2808
2817
  return {
2809
- error: B(i)
2818
+ error: B(a)
2810
2819
  };
2811
2820
  }
2812
2821
  if (!s.sessionId)
@@ -2824,7 +2833,7 @@ function bs(r, t) {
2824
2833
  {
2825
2834
  title: "List Browsers",
2826
2835
  description: "List active browser instances",
2827
- inputSchema: It.shape
2836
+ inputSchema: Mt.shape
2828
2837
  },
2829
2838
  async (s, o) => {
2830
2839
  const e = await ys(s, t, o);
@@ -2832,14 +2841,14 @@ function bs(r, t) {
2832
2841
  return `Method: playwright-browser-list(${JSON.stringify(s)})
2833
2842
  ❌ Error: ${e.error}`;
2834
2843
  const n = e.browserInfos.map(
2835
- (i) => `${i.name} (${i.browserType})`
2844
+ (a) => `${a.name} (${a.browserType})`
2836
2845
  );
2837
2846
  return `Method: playwright-browser-list(${JSON.stringify(s)})
2838
2847
  ${n.length === 0 ? "No browsers found" : `Browsers: ${n.join(", ")}`}`;
2839
2848
  }
2840
2849
  );
2841
2850
  }
2842
- const Mt = p.object({
2851
+ const Tt = p.object({
2843
2852
  names: p.array(p.string()).optional().describe(
2844
2853
  "Names of browsers to close. If not specified, closes all browsers"
2845
2854
  )
@@ -2847,7 +2856,7 @@ const Mt = p.object({
2847
2856
  async function Ss(r, t, s) {
2848
2857
  let o;
2849
2858
  try {
2850
- o = Mt.parse(r);
2859
+ o = Tt.parse(r);
2851
2860
  } catch (l) {
2852
2861
  return {
2853
2862
  error: B(l)
@@ -2858,24 +2867,24 @@ async function Ss(r, t, s) {
2858
2867
  return {
2859
2868
  error: "Session ID is required"
2860
2869
  };
2861
- const n = j(s.sessionId), i = [], a = [];
2870
+ const n = j(s.sessionId), a = [], i = [];
2862
2871
  let c = [];
2863
2872
  return e ? e.forEach((l) => {
2864
2873
  const u = n.browsers.get(l);
2865
- u ? c.push(u) : a.push(`Browser "${l}" not found`);
2874
+ u ? c.push(u) : i.push(`Browser "${l}" not found`);
2866
2875
  }) : c = Array.from(n.browsers.values()), await Promise.all(
2867
2876
  c.map(async (l) => {
2868
2877
  try {
2869
- await l.browser.close(), n.browsers.delete(l.name), i.push(l);
2878
+ await l.browser.close(), n.browsers.delete(l.name), a.push(l);
2870
2879
  } catch (u) {
2871
- a.push(
2880
+ i.push(
2872
2881
  `Failed to close browser "${l.name}" (${l.browserType}): ${u instanceof Error ? u.message : "Unknown error"}`
2873
2882
  );
2874
2883
  }
2875
2884
  })
2876
2885
  ), {
2877
- closedBrowserInfos: i,
2878
- ...a.length > 0 && { errors: a }
2886
+ closedBrowserInfos: a,
2887
+ ...i.length > 0 && { errors: i }
2879
2888
  };
2880
2889
  }
2881
2890
  function xs(r, t) {
@@ -2884,7 +2893,7 @@ function xs(r, t) {
2884
2893
  {
2885
2894
  title: "Close Browsers",
2886
2895
  description: "Close browsers. Automatically closes all contexts and pages within the browsers",
2887
- inputSchema: Mt.shape
2896
+ inputSchema: Tt.shape
2888
2897
  },
2889
2898
  async (s, o) => {
2890
2899
  const e = await Ss(s, t, o);
@@ -2893,12 +2902,12 @@ function xs(r, t) {
2893
2902
  ❌ Error: ${e.error}`;
2894
2903
  const n = [];
2895
2904
  if (e.closedBrowserInfos.length > 0) {
2896
- const i = e.closedBrowserInfos.map(
2897
- (a) => `${a.name} (${a.browserType})`
2905
+ const a = e.closedBrowserInfos.map(
2906
+ (i) => `${i.name} (${i.browserType})`
2898
2907
  );
2899
- n.push(`✅ Closed browsers: ${i.join(", ")}`);
2908
+ n.push(`✅ Closed browsers: ${a.join(", ")}`);
2900
2909
  }
2901
- return e.errors && e.errors.length > 0 && (n.length > 0 && n.push(""), n.push("❌ Errors:"), e.errors.forEach((i) => n.push(i))), n.length === 0 && n.push("No browsers to close"), `Method: playwright-browser-close(${JSON.stringify(s)})
2910
+ return e.errors && e.errors.length > 0 && (n.length > 0 && n.push(""), n.push("❌ Errors:"), e.errors.forEach((a) => n.push(a))), n.length === 0 && n.push("No browsers to close"), `Method: playwright-browser-close(${JSON.stringify(s)})
2902
2911
  ${n.join(`
2903
2912
  `)}`;
2904
2913
  }
@@ -2919,7 +2928,7 @@ const xe = p.object({
2919
2928
  height: p.number()
2920
2929
  }).optional().describe("Viewport size configuration")
2921
2930
  });
2922
- async function Tt(r, t, s) {
2931
+ async function Ct(r, t, s) {
2923
2932
  let o;
2924
2933
  try {
2925
2934
  o = xe.parse(r);
@@ -2928,52 +2937,52 @@ async function Tt(r, t, s) {
2928
2937
  error: B(h)
2929
2938
  };
2930
2939
  }
2931
- const { name: e, browserName: n, browser: i, isMobile: a, hasTouch: c, viewport: l } = o;
2940
+ const { name: e, browserName: n, browser: a, isMobile: i, hasTouch: c, viewport: l } = o;
2932
2941
  if (!s.sessionId)
2933
2942
  return {
2934
2943
  error: "Session ID is required"
2935
2944
  };
2936
2945
  const u = j(s.sessionId);
2937
- if (n && i)
2946
+ if (n && a)
2938
2947
  return {
2939
2948
  error: "Either browserName or browser must be provided, not both"
2940
2949
  };
2941
- let f = !1, d;
2950
+ let d = !1, f;
2942
2951
  if (n) {
2943
- if (d = u.browsers.get(n), !d)
2952
+ if (f = u.browsers.get(n), !f)
2944
2953
  return {
2945
2954
  error: `Browser "${n}" not found`
2946
2955
  };
2947
- } else if (i) {
2948
- const h = await $t(i, t, s);
2956
+ } else if (a) {
2957
+ const h = await It(a, t, s);
2949
2958
  if (h.error != null)
2950
2959
  return {
2951
2960
  error: h.error
2952
2961
  };
2953
- d = h.browserInfo, f = !0;
2962
+ f = h.browserInfo, d = !0;
2954
2963
  } else
2955
2964
  return {
2956
2965
  error: "Either browserName or browser must be provided"
2957
2966
  };
2958
2967
  try {
2959
- const h = await d.browser.newContext({
2960
- isMobile: a,
2968
+ const h = await f.browser.newContext({
2969
+ isMobile: i,
2961
2970
  hasTouch: c,
2962
2971
  viewport: l
2963
2972
  }), m = {
2964
- browserInfo: d,
2973
+ browserInfo: f,
2965
2974
  name: e,
2966
2975
  context: h,
2967
2976
  pages: /* @__PURE__ */ new Map()
2968
2977
  };
2969
- return d.contexts.set(e, m), {
2970
- browserInfoCreated: f,
2971
- browserInfo: d,
2978
+ return f.contexts.set(e, m), {
2979
+ browserInfoCreated: d,
2980
+ browserInfo: f,
2972
2981
  contextInfo: m
2973
2982
  };
2974
2983
  } catch (h) {
2975
2984
  return {
2976
- error: `Failed to create context: ${h instanceof Error ? h.message : "Unknown error"} in browser "${d.name}" (${d.browserType})`
2985
+ error: `Failed to create context: ${h instanceof Error ? h.message : "Unknown error"} in browser "${f.name}" (${f.browserType})`
2977
2986
  };
2978
2987
  }
2979
2988
  }
@@ -2986,7 +2995,7 @@ function $s(r, t) {
2986
2995
  inputSchema: xe.shape
2987
2996
  },
2988
2997
  async (s, o) => {
2989
- const e = await Tt(s, t, o);
2998
+ const e = await Ct(s, t, o);
2990
2999
  if (e.error != null)
2991
3000
  return `Method: playwright-context-create(${JSON.stringify(s)})
2992
3001
  ❌ Error: ${e.error}`;
@@ -2997,7 +3006,7 @@ function $s(r, t) {
2997
3006
  }
2998
3007
  );
2999
3008
  }
3000
- const Ct = p.object({
3009
+ const vt = p.object({
3001
3010
  browserName: p.string().optional().describe(
3002
3011
  "Name of browser to list contexts from. If not specified, lists contexts from all browsers"
3003
3012
  )
@@ -3005,10 +3014,10 @@ const Ct = p.object({
3005
3014
  async function Is(r, t, s) {
3006
3015
  let o;
3007
3016
  try {
3008
- o = Ct.parse(r);
3009
- } catch (a) {
3017
+ o = vt.parse(r);
3018
+ } catch (i) {
3010
3019
  return {
3011
- error: B(a)
3020
+ error: B(i)
3012
3021
  };
3013
3022
  }
3014
3023
  const { browserName: e } = o;
@@ -3016,27 +3025,27 @@ async function Is(r, t, s) {
3016
3025
  return {
3017
3026
  error: "Session ID is required"
3018
3027
  };
3019
- const n = j(s.sessionId), i = [];
3028
+ const n = j(s.sessionId), a = [];
3020
3029
  if (e) {
3021
- const a = n.browsers.get(e);
3022
- if (!a)
3030
+ const i = n.browsers.get(e);
3031
+ if (!i)
3023
3032
  return {
3024
3033
  error: `Browser "${e}" not found`
3025
3034
  };
3026
- Array.from(a.contexts.values()).length > 0 && i.push({
3027
- browserInfo: a,
3028
- contexts: Array.from(a.contexts.values())
3035
+ Array.from(i.contexts.values()).length > 0 && a.push({
3036
+ browserInfo: i,
3037
+ contexts: Array.from(i.contexts.values())
3029
3038
  });
3030
3039
  } else
3031
- for (const a of n.browsers.values()) {
3032
- const c = Array.from(a.contexts.values());
3033
- c.length > 0 && i.push({
3034
- browserInfo: a,
3040
+ for (const i of n.browsers.values()) {
3041
+ const c = Array.from(i.contexts.values());
3042
+ c.length > 0 && a.push({
3043
+ browserInfo: i,
3035
3044
  contexts: c
3036
3045
  });
3037
3046
  }
3038
3047
  return {
3039
- contextsByBrowser: i
3048
+ contextsByBrowser: a
3040
3049
  };
3041
3050
  }
3042
3051
  function Ms(r, t) {
@@ -3045,7 +3054,7 @@ function Ms(r, t) {
3045
3054
  {
3046
3055
  title: "List Browser Contexts",
3047
3056
  description: "List active browser contexts",
3048
- inputSchema: Ct.shape
3057
+ inputSchema: vt.shape
3049
3058
  },
3050
3059
  async (s, o) => {
3051
3060
  const e = await Is(s, t, o);
@@ -3055,13 +3064,13 @@ function Ms(r, t) {
3055
3064
  let n = `Method: playwright-context-list(${JSON.stringify(s)})
3056
3065
  `;
3057
3066
  return e.contextsByBrowser.length === 0 ? n += "No contexts found" : n += e.contextsByBrowser.map(
3058
- ({ browserInfo: i, contexts: a }) => `${i.name} (${i.browserType}): ${a.map((c) => c.name).join(", ")}`
3067
+ ({ browserInfo: a, contexts: i }) => `${a.name} (${a.browserType}): ${i.map((c) => c.name).join(", ")}`
3059
3068
  ).join(`
3060
3069
  `), n;
3061
3070
  }
3062
3071
  );
3063
3072
  }
3064
- const vt = p.object({
3073
+ const Nt = p.object({
3065
3074
  names: p.array(p.string()).optional().describe(
3066
3075
  "Names of contexts to close. If not specified, closes all contexts"
3067
3076
  ),
@@ -3072,7 +3081,7 @@ const vt = p.object({
3072
3081
  async function Ts(r, t, s) {
3073
3082
  let o;
3074
3083
  try {
3075
- o = vt.parse(r);
3084
+ o = Nt.parse(r);
3076
3085
  } catch (u) {
3077
3086
  return {
3078
3087
  error: B(u)
@@ -3083,43 +3092,43 @@ async function Ts(r, t, s) {
3083
3092
  return {
3084
3093
  error: "Session ID is required"
3085
3094
  };
3086
- const i = j(s.sessionId), a = [], c = [];
3095
+ const a = j(s.sessionId), i = [], c = [];
3087
3096
  let l = [];
3088
3097
  if (n) {
3089
- const u = i.browsers.get(n);
3098
+ const u = a.browsers.get(n);
3090
3099
  if (!u)
3091
3100
  return {
3092
3101
  error: `Browser "${n}" not found`
3093
3102
  };
3094
- e ? e.forEach((f) => {
3095
- const d = u.contexts.get(f);
3096
- d ? l.push(d) : c.push(
3097
- `Context "${f}" not found in browser "${u.name}" (${u.browserType})`
3103
+ e ? e.forEach((d) => {
3104
+ const f = u.contexts.get(d);
3105
+ f ? l.push(f) : c.push(
3106
+ `Context "${d}" not found in browser "${u.name}" (${u.browserType})`
3098
3107
  );
3099
3108
  }) : l = Array.from(u.contexts.values());
3100
3109
  } else if (e)
3101
- for (const u of i.browsers.values())
3102
- e.forEach((f) => {
3103
- const d = u.contexts.get(f);
3104
- d ? l.push(d) : c.push(
3105
- `Context "${f}" not found in browser "${u.name}" (${u.browserType})`
3110
+ for (const u of a.browsers.values())
3111
+ e.forEach((d) => {
3112
+ const f = u.contexts.get(d);
3113
+ f ? l.push(f) : c.push(
3114
+ `Context "${d}" not found in browser "${u.name}" (${u.browserType})`
3106
3115
  );
3107
3116
  });
3108
3117
  else
3109
- for (const u of i.browsers.values())
3118
+ for (const u of a.browsers.values())
3110
3119
  l.push(...Array.from(u.contexts.values()));
3111
3120
  return await Promise.all(
3112
3121
  l.map(async (u) => {
3113
3122
  try {
3114
- await u.context.close(), u.browserInfo.contexts.delete(u.name), a.push(u);
3115
- } catch (f) {
3123
+ await u.context.close(), u.browserInfo.contexts.delete(u.name), i.push(u);
3124
+ } catch (d) {
3116
3125
  c.push(
3117
- `Failed to close context "${u.name}" (${u.browserInfo.name}) (${u.browserInfo.browserType}): ${f instanceof Error ? f.message : "Unknown error"}`
3126
+ `Failed to close context "${u.name}" (${u.browserInfo.name}) (${u.browserInfo.browserType}): ${d instanceof Error ? d.message : "Unknown error"}`
3118
3127
  );
3119
3128
  }
3120
3129
  })
3121
3130
  ), {
3122
- closedContextInfos: a,
3131
+ closedContextInfos: i,
3123
3132
  ...c.length > 0 && { errors: c }
3124
3133
  };
3125
3134
  }
@@ -3129,7 +3138,7 @@ function Cs(r, t) {
3129
3138
  {
3130
3139
  title: "Close Browser Contexts",
3131
3140
  description: "Close browser contexts. Automatically closes all pages within the contexts",
3132
- inputSchema: vt.shape
3141
+ inputSchema: Nt.shape
3133
3142
  },
3134
3143
  async (s, o) => {
3135
3144
  const e = await Ts(s, t, o);
@@ -3138,12 +3147,12 @@ function Cs(r, t) {
3138
3147
  ❌ Error: ${e.error}`;
3139
3148
  const n = [];
3140
3149
  if (e.closedContextInfos.length > 0) {
3141
- const i = e.closedContextInfos.map(
3142
- (a) => `${a.name} (${a.browserInfo.name}) (${a.browserInfo.browserType})`
3150
+ const a = e.closedContextInfos.map(
3151
+ (i) => `${i.name} (${i.browserInfo.name}) (${i.browserInfo.browserType})`
3143
3152
  );
3144
- n.push(`✅ Closed contexts: ${i.join(", ")}`);
3153
+ n.push(`✅ Closed contexts: ${a.join(", ")}`);
3145
3154
  }
3146
- return e.errors && e.errors.length > 0 && (n.length > 0 && n.push(""), n.push("❌ Errors:"), e.errors.forEach((i) => n.push(i))), n.length === 0 && n.push("No contexts to close"), `Method: playwright-context-close(${JSON.stringify(s)})
3155
+ return e.errors && e.errors.length > 0 && (n.length > 0 && n.push(""), n.push("❌ Errors:"), e.errors.forEach((a) => n.push(a))), n.length === 0 && n.push("No contexts to close"), `Method: playwright-context-close(${JSON.stringify(s)})
3147
3156
  ${n.join(`
3148
3157
  `)}`;
3149
3158
  }
@@ -3172,62 +3181,62 @@ function vs() {
3172
3181
  return u ?? (this.idToObject.delete(c), null);
3173
3182
  }
3174
3183
  }
3175
- function t(a, c, l) {
3184
+ function t(i, c, l) {
3176
3185
  let u = null;
3177
- for (let f = 0, d = c.length; f < d; f++) {
3178
- const h = c[f], m = a(h), g = m == null ? null : t(a, m, l), y = l(h, g);
3186
+ for (let d = 0, f = c.length; d < f; d++) {
3187
+ const h = c[d], m = i(h), g = m == null ? null : t(i, m, l), y = l(h, g);
3179
3188
  y != null && (u == null && (u = []), u.push(y));
3180
3189
  }
3181
3190
  return u;
3182
3191
  }
3183
- function s(a) {
3184
- const { getId: c, getChilds: l, rootNodes: u, createSnapshotNode: f } = a, d = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), g = t(
3192
+ function s(i) {
3193
+ const { getId: c, getChilds: l, rootNodes: u, createSnapshotNode: d } = i, f = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), g = t(
3185
3194
  l,
3186
3195
  u,
3187
3196
  (w, M) => {
3188
- const N = f(w, M);
3197
+ const N = d(w, M);
3189
3198
  if (w != null && N != null) {
3190
3199
  const b = c(w);
3191
- d.set(b, N), h.set(N, b);
3200
+ f.set(b, N), h.set(N, b);
3192
3201
  }
3193
3202
  return N != null && M != null && m.set(
3194
3203
  h.get(N),
3195
3204
  M.map((b) => h.get(b))
3196
3205
  ), N;
3197
3206
  }
3198
- ), y = f(null, g);
3207
+ ), y = d(null, g);
3199
3208
  if (y == null)
3200
3209
  throw new Error("Impossible behavior: rootNode == null");
3201
- return d.set(null, y), g != null && m.set(
3210
+ return f.set(null, y), g != null && m.set(
3202
3211
  null,
3203
3212
  g.map((w) => h.get(w))
3204
3213
  ), {
3205
- idToNode: d,
3214
+ idToNode: f,
3206
3215
  idToChildIds: m
3207
3216
  };
3208
3217
  }
3209
- const o = (a) => a instanceof HTMLElement ? a.childNodes : null;
3210
- function e(a) {
3218
+ const o = (i) => i instanceof HTMLElement ? i.childNodes : null;
3219
+ function e(i) {
3211
3220
  return function(l, u) {
3212
- const f = u != null && u.length > 0;
3213
- let d = !1, h = null, m = null;
3221
+ const d = u != null && u.length > 0;
3222
+ let f = !1, h = null, m = null;
3214
3223
  if (l instanceof HTMLElement) {
3215
- if (h = n.getOrCreateId(l), m = l.tagName.toLowerCase(), d = l.matches(a.cssSelector), !d && !f)
3224
+ if (h = n.getOrCreateId(l), m = l.tagName.toLowerCase(), f = l.matches(i.cssSelector), !f && !d)
3216
3225
  return null;
3217
3226
  } else if (l == null)
3218
- h = null, m = null, d = !1;
3227
+ h = null, m = null, f = !1;
3219
3228
  else
3220
3229
  return null;
3221
3230
  return {
3222
3231
  uid: h,
3223
3232
  tagName: m,
3224
- isMatched: d
3233
+ isMatched: f
3225
3234
  };
3226
3235
  };
3227
3236
  }
3228
3237
  const n = new r();
3229
- function i(a) {
3230
- const c = e(a);
3238
+ function a(i) {
3239
+ const c = e(i);
3231
3240
  return s({
3232
3241
  getId: (l) => n.getOrCreateId(l),
3233
3242
  getChilds: o,
@@ -3235,7 +3244,7 @@ function vs() {
3235
3244
  rootNodes: [window.document.documentElement]
3236
3245
  });
3237
3246
  }
3238
- window.__mcp_playwright_tool_tx4byhar35_createDomSnapshotTreeRawDom = i;
3247
+ window.__mcp_playwright_tool_tx4byhar35_createDomSnapshotTreeRawDom = a;
3239
3248
  }
3240
3249
  const Ns = `(function (){function __name(fn){return fn};${vs.toString()}; setupPageGlobals();})()`, $e = p.object({
3241
3250
  contextName: p.string().optional().describe("Name of previously created context, to use"),
@@ -3246,64 +3255,64 @@ const Ns = `(function (){function __name(fn){return fn};${vs.toString()}; setupP
3246
3255
  "Unique name for the page. Recommended format: kebab-case-1, kebab-case-2, ..."
3247
3256
  )
3248
3257
  });
3249
- async function Nt(r, t, s) {
3258
+ async function Et(r, t, s) {
3250
3259
  let o;
3251
3260
  try {
3252
3261
  o = $e.parse(r);
3253
- } catch (f) {
3262
+ } catch (d) {
3254
3263
  return {
3255
- error: B(f)
3264
+ error: B(d)
3256
3265
  };
3257
3266
  }
3258
- const { name: e, contextName: n, context: i } = o;
3267
+ const { name: e, contextName: n, context: a } = o;
3259
3268
  if (!s.sessionId)
3260
3269
  return {
3261
3270
  error: "Session ID is required"
3262
3271
  };
3263
- const a = j(s.sessionId);
3264
- if (n && i)
3272
+ const i = j(s.sessionId);
3273
+ if (n && a)
3265
3274
  return {
3266
3275
  error: "Either contextName or context must be provided, not both"
3267
3276
  };
3268
3277
  let c = !1, l = !1, u;
3269
3278
  if (n) {
3270
- for (const f of a.browsers.values())
3271
- if (f.contexts.has(n)) {
3272
- u = f.contexts.get(n);
3279
+ for (const d of i.browsers.values())
3280
+ if (d.contexts.has(n)) {
3281
+ u = d.contexts.get(n);
3273
3282
  break;
3274
3283
  }
3275
3284
  if (!u)
3276
3285
  return {
3277
3286
  error: `Context "${n}" not found`
3278
3287
  };
3279
- } else if (i) {
3280
- const f = await Tt(i, t, s);
3281
- if (f.error != null)
3288
+ } else if (a) {
3289
+ const d = await Ct(a, t, s);
3290
+ if (d.error != null)
3282
3291
  return {
3283
- error: f.error
3292
+ error: d.error
3284
3293
  };
3285
- u = f.contextInfo, c = f.browserInfoCreated, l = !0;
3294
+ u = d.contextInfo, c = d.browserInfoCreated, l = !0;
3286
3295
  } else
3287
3296
  return {
3288
3297
  error: "Either contextName or context must be provided"
3289
3298
  };
3290
3299
  try {
3291
- const f = await u.context.newPage();
3292
- await f.addInitScript(Ns), await f.goto("about:blank");
3293
- const d = {
3300
+ const d = await u.context.newPage();
3301
+ await d.addInitScript(Ns), await d.goto("about:blank");
3302
+ const f = {
3294
3303
  contextInfo: u,
3295
3304
  name: e,
3296
- page: f,
3305
+ page: d,
3297
3306
  domSnapshots: /* @__PURE__ */ new Map()
3298
3307
  };
3299
- return u.pages.set(e, d), {
3308
+ return u.pages.set(e, f), {
3300
3309
  browserInfoCreated: c,
3301
3310
  contextInfoCreated: l,
3302
- pageInfo: d
3311
+ pageInfo: f
3303
3312
  };
3304
- } catch (f) {
3313
+ } catch (d) {
3305
3314
  return {
3306
- error: `Failed to create page: ${f instanceof Error ? f.message : "Unknown error"} in context "${u.name}" in browser "${u.browserInfo.name}" (${u.browserInfo.browserType})`
3315
+ error: `Failed to create page: ${d instanceof Error ? d.message : "Unknown error"} in context "${u.name}" in browser "${u.browserInfo.name}" (${u.browserInfo.browserType})`
3307
3316
  };
3308
3317
  }
3309
3318
  }
@@ -3316,7 +3325,7 @@ function Es(r, t) {
3316
3325
  inputSchema: $e.shape
3317
3326
  },
3318
3327
  async (s, o) => {
3319
- const e = await Nt(s, t, o);
3328
+ const e = await Et(s, t, o);
3320
3329
  if (e.error != null)
3321
3330
  return `Method: playwright-page-create(${JSON.stringify(s)})
3322
3331
  ❌ Error: ${e.error}`;
@@ -3328,7 +3337,7 @@ function Es(r, t) {
3328
3337
  }
3329
3338
  );
3330
3339
  }
3331
- const Et = p.object({
3340
+ const kt = p.object({
3332
3341
  contextName: p.string().optional().describe(
3333
3342
  "Name of context to list pages from. If not specified, lists pages from all contexts"
3334
3343
  ),
@@ -3339,7 +3348,7 @@ const Et = p.object({
3339
3348
  async function ks(r, t, s) {
3340
3349
  let o;
3341
3350
  try {
3342
- o = Et.parse(r);
3351
+ o = kt.parse(r);
3343
3352
  } catch (c) {
3344
3353
  return {
3345
3354
  error: B(c)
@@ -3350,9 +3359,9 @@ async function ks(r, t, s) {
3350
3359
  return {
3351
3360
  error: "Session ID is required"
3352
3361
  };
3353
- const i = j(s.sessionId), a = [];
3362
+ const a = j(s.sessionId), i = [];
3354
3363
  if (n) {
3355
- const c = i.browsers.get(n);
3364
+ const c = a.browsers.get(n);
3356
3365
  if (!c)
3357
3366
  return {
3358
3367
  error: `Browser "${n}" not found`
@@ -3364,40 +3373,40 @@ async function ks(r, t, s) {
3364
3373
  error: `Context "${e}" not found in browser "${c.name}" (${c.browserType})`
3365
3374
  };
3366
3375
  const u = Array.from(l.pages.values());
3367
- u.length > 0 && a.push({
3376
+ u.length > 0 && i.push({
3368
3377
  contextInfo: l,
3369
3378
  pages: u
3370
3379
  });
3371
3380
  } else
3372
3381
  for (const l of c.contexts.values()) {
3373
3382
  const u = Array.from(l.pages.values());
3374
- u.length > 0 && a.push({
3383
+ u.length > 0 && i.push({
3375
3384
  contextInfo: l,
3376
3385
  pages: u
3377
3386
  });
3378
3387
  }
3379
3388
  } else if (e)
3380
- for (const c of i.browsers.values()) {
3389
+ for (const c of a.browsers.values()) {
3381
3390
  const l = c.contexts.get(e);
3382
3391
  if (l) {
3383
3392
  const u = Array.from(l.pages.values());
3384
- u.length > 0 && a.push({
3393
+ u.length > 0 && i.push({
3385
3394
  contextInfo: l,
3386
3395
  pages: u
3387
3396
  });
3388
3397
  }
3389
3398
  }
3390
3399
  else
3391
- for (const c of i.browsers.values())
3400
+ for (const c of a.browsers.values())
3392
3401
  for (const l of c.contexts.values()) {
3393
3402
  const u = Array.from(l.pages.values());
3394
- u.length > 0 && a.push({
3403
+ u.length > 0 && i.push({
3395
3404
  contextInfo: l,
3396
3405
  pages: u
3397
3406
  });
3398
3407
  }
3399
3408
  return {
3400
- pagesByContext: a
3409
+ pagesByContext: i
3401
3410
  };
3402
3411
  }
3403
3412
  function Os(r, t) {
@@ -3406,7 +3415,7 @@ function Os(r, t) {
3406
3415
  {
3407
3416
  title: "List Pages",
3408
3417
  description: "List active pages",
3409
- inputSchema: Et.shape
3418
+ inputSchema: kt.shape
3410
3419
  },
3411
3420
  async (s, o) => {
3412
3421
  const e = await ks(s, t, o);
@@ -3416,13 +3425,13 @@ function Os(r, t) {
3416
3425
  let n = `Method: playwright-page-list(${JSON.stringify(s)})
3417
3426
  `;
3418
3427
  return e.pagesByContext.length === 0 ? n += "No pages found" : n += e.pagesByContext.map(
3419
- ({ contextInfo: i, pages: a }) => `${i.name} (${i.browserInfo.name}) (${i.browserInfo.browserType}): ${a.map((c) => c.name).join(", ")}`
3428
+ ({ contextInfo: a, pages: i }) => `${a.name} (${a.browserInfo.name}) (${a.browserInfo.browserType}): ${i.map((c) => c.name).join(", ")}`
3420
3429
  ).join(`
3421
3430
  `), n;
3422
3431
  }
3423
3432
  );
3424
3433
  }
3425
- const kt = p.object({
3434
+ const Ot = p.object({
3426
3435
  names: p.array(p.string()).optional().describe("Names of pages to close. If not specified, closes all pages"),
3427
3436
  contextName: p.string().optional().describe(
3428
3437
  "Name of context to close pages from. If not specified, searches all contexts"
@@ -3434,73 +3443,73 @@ const kt = p.object({
3434
3443
  async function Ds(r, t, s) {
3435
3444
  let o;
3436
3445
  try {
3437
- o = kt.parse(r);
3438
- } catch (f) {
3446
+ o = Ot.parse(r);
3447
+ } catch (d) {
3439
3448
  return {
3440
- error: B(f)
3449
+ error: B(d)
3441
3450
  };
3442
3451
  }
3443
- const { names: e, contextName: n, browserName: i } = o;
3452
+ const { names: e, contextName: n, browserName: a } = o;
3444
3453
  if (!s.sessionId)
3445
3454
  return {
3446
3455
  error: "Session ID is required"
3447
3456
  };
3448
- const a = j(s.sessionId), c = [], l = [];
3457
+ const i = j(s.sessionId), c = [], l = [];
3449
3458
  let u = [];
3450
- if (i) {
3451
- const f = a.browsers.get(i);
3452
- if (!f)
3459
+ if (a) {
3460
+ const d = i.browsers.get(a);
3461
+ if (!d)
3453
3462
  return {
3454
- error: `Browser "${i}" not found`
3463
+ error: `Browser "${a}" not found`
3455
3464
  };
3456
3465
  if (n) {
3457
- const d = f.contexts.get(n);
3458
- if (!d)
3466
+ const f = d.contexts.get(n);
3467
+ if (!f)
3459
3468
  return {
3460
- error: `Context "${n}" not found in browser "${f.name}" (${f.browserType})`
3469
+ error: `Context "${n}" not found in browser "${d.name}" (${d.browserType})`
3461
3470
  };
3462
3471
  e ? e.forEach((h) => {
3463
- const m = d.pages.get(h);
3472
+ const m = f.pages.get(h);
3464
3473
  m ? u.push(m) : l.push(
3465
- `Page "${h}" not found in context "${d.name}" in browser "${f.name}" (${f.browserType})`
3474
+ `Page "${h}" not found in context "${f.name}" in browser "${d.name}" (${d.browserType})`
3466
3475
  );
3467
- }) : u = Array.from(d.pages.values());
3476
+ }) : u = Array.from(f.pages.values());
3468
3477
  } else
3469
- for (const d of f.contexts.values())
3478
+ for (const f of d.contexts.values())
3470
3479
  e ? e.forEach((h) => {
3471
- const m = d.pages.get(h);
3480
+ const m = f.pages.get(h);
3472
3481
  m ? u.push(m) : l.push(
3473
- `Page "${h}" not found in context "${d.name}" in browser "${f.name}" (${f.browserType})`
3482
+ `Page "${h}" not found in context "${f.name}" in browser "${d.name}" (${d.browserType})`
3474
3483
  );
3475
- }) : u.push(...Array.from(d.pages.values()));
3484
+ }) : u.push(...Array.from(f.pages.values()));
3476
3485
  } else if (n)
3477
- for (const f of a.browsers.values()) {
3478
- const d = f.contexts.get(n);
3479
- d && (e ? e.forEach((h) => {
3480
- const m = d.pages.get(h);
3486
+ for (const d of i.browsers.values()) {
3487
+ const f = d.contexts.get(n);
3488
+ f && (e ? e.forEach((h) => {
3489
+ const m = f.pages.get(h);
3481
3490
  m ? u.push(m) : l.push(
3482
- `Page "${h}" not found in context "${d.name}" in browser "${f.name}" (${f.browserType})`
3491
+ `Page "${h}" not found in context "${f.name}" in browser "${d.name}" (${d.browserType})`
3483
3492
  );
3484
- }) : u.push(...Array.from(d.pages.values())));
3493
+ }) : u.push(...Array.from(f.pages.values())));
3485
3494
  }
3486
3495
  else
3487
- for (const f of a.browsers.values())
3488
- for (const d of f.contexts.values())
3496
+ for (const d of i.browsers.values())
3497
+ for (const f of d.contexts.values())
3489
3498
  e ? e.forEach((h) => {
3490
- const m = d.pages.get(h);
3499
+ const m = f.pages.get(h);
3491
3500
  m ? u.push(m) : l.push(
3492
- `Page "${h}" not found in context "${d.name}" in browser "${f.name}" (${f.browserType})`
3501
+ `Page "${h}" not found in context "${f.name}" in browser "${d.name}" (${d.browserType})`
3493
3502
  );
3494
- }) : u.push(...Array.from(d.pages.values()));
3503
+ }) : u.push(...Array.from(f.pages.values()));
3495
3504
  return await Promise.all(
3496
- u.map(async (f) => {
3505
+ u.map(async (d) => {
3497
3506
  try {
3498
- await f.page.close(), f.contextInfo.pages.delete(f.name), c.push(
3499
- `${f.name} (${f.contextInfo.name}) (${f.contextInfo.browserInfo.name}) (${f.contextInfo.browserInfo.browserType})`
3507
+ await d.page.close(), d.contextInfo.pages.delete(d.name), c.push(
3508
+ `${d.name} (${d.contextInfo.name}) (${d.contextInfo.browserInfo.name}) (${d.contextInfo.browserInfo.browserType})`
3500
3509
  );
3501
- } catch (d) {
3510
+ } catch (f) {
3502
3511
  l.push(
3503
- `Failed to close page "${f.name}" (${f.contextInfo.name}) (${f.contextInfo.browserInfo.name}) (${f.contextInfo.browserInfo.browserType}): ${d instanceof Error ? d.message : "Unknown error"}`
3512
+ `Failed to close page "${d.name}" (${d.contextInfo.name}) (${d.contextInfo.browserInfo.name}) (${d.contextInfo.browserInfo.browserType}): ${f instanceof Error ? f.message : "Unknown error"}`
3504
3513
  );
3505
3514
  }
3506
3515
  })
@@ -3515,7 +3524,7 @@ function Rs(r, t) {
3515
3524
  {
3516
3525
  title: "Close Pages",
3517
3526
  description: "Close pages",
3518
- inputSchema: kt.shape
3527
+ inputSchema: Ot.shape
3519
3528
  },
3520
3529
  async (s, o) => {
3521
3530
  const e = await Ds(s, t, o);
@@ -3523,13 +3532,13 @@ function Rs(r, t) {
3523
3532
  return `Method: playwright-page-close(${JSON.stringify(s)})
3524
3533
  ❌ Error: ${e.error}`;
3525
3534
  const n = [];
3526
- return e.closedPages.length > 0 && n.push(`✅ Closed pages: ${e.closedPages.join(", ")}`), e.errors && e.errors.length > 0 && (n.length > 0 && n.push(""), n.push("❌ Errors:"), e.errors.forEach((i) => n.push(i))), n.length === 0 && n.push("No pages to close"), `Method: playwright-page-close(${JSON.stringify(s)})
3535
+ return e.closedPages.length > 0 && n.push(`✅ Closed pages: ${e.closedPages.join(", ")}`), e.errors && e.errors.length > 0 && (n.length > 0 && n.push(""), n.push("❌ Errors:"), e.errors.forEach((a) => n.push(a))), n.length === 0 && n.push("No pages to close"), `Method: playwright-page-close(${JSON.stringify(s)})
3527
3536
  ${n.join(`
3528
3537
  `)}`;
3529
3538
  }
3530
3539
  );
3531
3540
  }
3532
- const Ot = p.object({
3541
+ const Dt = p.object({
3533
3542
  pageName: p.string().optional().describe("Name of previously created page to navigate"),
3534
3543
  page: $e.optional().describe(
3535
3544
  "Page creation options JSON to automatically create page"
@@ -3547,13 +3556,13 @@ const Ot = p.object({
3547
3556
  async function Fs(r, t, s) {
3548
3557
  let o;
3549
3558
  try {
3550
- o = Ot.parse(r);
3559
+ o = Dt.parse(r);
3551
3560
  } catch (m) {
3552
3561
  return {
3553
3562
  error: B(m)
3554
3563
  };
3555
3564
  }
3556
- const { pageName: e, page: n, url: i, timeout: a, waitUntil: c } = o;
3565
+ const { pageName: e, page: n, url: a, timeout: i, waitUntil: c } = o;
3557
3566
  if (!s.sessionId)
3558
3567
  return {
3559
3568
  error: "Session ID is required"
@@ -3563,7 +3572,7 @@ async function Fs(r, t, s) {
3563
3572
  return {
3564
3573
  error: "Either pageName or page must be provided, not both"
3565
3574
  };
3566
- let u = !1, f = !1, d = !1, h;
3575
+ let u = !1, d = !1, f = !1, h;
3567
3576
  if (e) {
3568
3577
  for (const m of l.browsers.values()) {
3569
3578
  for (const g of m.contexts.values())
@@ -3578,37 +3587,37 @@ async function Fs(r, t, s) {
3578
3587
  error: `Page "${e}" not found`
3579
3588
  };
3580
3589
  } else if (n) {
3581
- const m = await Nt(n, t, s);
3590
+ const m = await Et(n, t, s);
3582
3591
  if (m.error != null)
3583
3592
  return {
3584
3593
  error: m.error
3585
3594
  };
3586
- h = m.pageInfo, u = m.browserInfoCreated, f = m.contextInfoCreated, d = !0;
3595
+ h = m.pageInfo, u = m.browserInfoCreated, d = m.contextInfoCreated, f = !0;
3587
3596
  } else
3588
3597
  return {
3589
3598
  error: "Either pageName or page must be provided"
3590
3599
  };
3591
3600
  try {
3592
- const m = await h.page.goto(i, {
3593
- timeout: a * 1e3,
3601
+ const m = await h.page.goto(a, {
3602
+ timeout: i * 1e3,
3594
3603
  waitUntil: c
3595
3604
  });
3596
3605
  return m ? {
3597
3606
  browserInfoCreated: u,
3598
- contextInfoCreated: f,
3599
- pageInfoCreated: d,
3607
+ contextInfoCreated: d,
3608
+ pageInfoCreated: f,
3600
3609
  pageInfo: h,
3601
3610
  status: m.status()
3602
3611
  } : {
3603
3612
  browserInfoCreated: u,
3604
- contextInfoCreated: f,
3605
- pageInfoCreated: d,
3613
+ contextInfoCreated: d,
3614
+ pageInfoCreated: f,
3606
3615
  pageInfo: h,
3607
3616
  status: 200
3608
3617
  };
3609
3618
  } catch (m) {
3610
3619
  return {
3611
- error: `Failed to navigate to "${i}": ${m instanceof Error ? m.message : "Unknown error"}`
3620
+ error: `Failed to navigate to "${a}": ${m instanceof Error ? m.message : "Unknown error"}`
3612
3621
  };
3613
3622
  }
3614
3623
  }
@@ -3618,7 +3627,7 @@ function Bs(r, t) {
3618
3627
  {
3619
3628
  title: "Navigate Page",
3620
3629
  description: "Navigate page to URL. Use for manual browser interaction",
3621
- inputSchema: Ot.shape
3630
+ inputSchema: Dt.shape
3622
3631
  },
3623
3632
  async (s, o) => {
3624
3633
  const e = await Fs(s, t, o);
@@ -3640,7 +3649,7 @@ const Ie = p.object({
3640
3649
  ),
3641
3650
  cssSelector: p.string().describe("CSS selector to capture page content")
3642
3651
  });
3643
- async function Dt(r, t, s) {
3652
+ async function Rt(r, t, s) {
3644
3653
  let o;
3645
3654
  try {
3646
3655
  o = Ie.parse(r);
@@ -3654,12 +3663,12 @@ async function Dt(r, t, s) {
3654
3663
  return {
3655
3664
  error: "Session ID is required"
3656
3665
  };
3657
- const i = j(s.sessionId), a = {
3666
+ const a = j(s.sessionId), i = {
3658
3667
  name: e,
3659
3668
  cssSelector: n
3660
3669
  };
3661
- return i.domSnapshotQueries.set(e, a), {
3662
- snapshotQuery: a
3670
+ return a.domSnapshotQueries.set(e, i), {
3671
+ snapshotQuery: i
3663
3672
  };
3664
3673
  }
3665
3674
  function Ls(r, t) {
@@ -3671,7 +3680,7 @@ function Ls(r, t) {
3671
3680
  inputSchema: Ie.shape
3672
3681
  },
3673
3682
  async (s, o) => {
3674
- const e = await Dt(s, t, o);
3683
+ const e = await Rt(s, t, o);
3675
3684
  return e.error != null ? `Method: playwright-dom-snapshot-query-create(${JSON.stringify(s)})
3676
3685
  ❌ Error: ${e.error}` : `Method: playwright-dom-snapshot-query-create(${JSON.stringify(s)})
3677
3686
  ✅ DOM snapshot query "${e.snapshotQuery.name}" created successfully`;
@@ -3681,48 +3690,48 @@ function Ls(r, t) {
3681
3690
  function Ps(r) {
3682
3691
  return function(s, o) {
3683
3692
  let e, n = 0;
3684
- const i = o ? o.length : 0;
3685
- let a = 1, c = 0, l = 0, u, f;
3693
+ const a = o ? o.length : 0;
3694
+ let i = 1, c = 0, l = 0, u, d;
3686
3695
  if (o)
3687
3696
  for (let m = 0; m < o.length; m++) {
3688
3697
  const g = o[m];
3689
- n += g.countMatched, a += g.countTotal, c += g.tokens, l += g.tokensTotal;
3698
+ n += g.countMatched, i += g.countTotal, c += g.tokens, l += g.tokensTotal;
3690
3699
  }
3691
- s ? (u = s.uid, f = s.tagName, e = s.isMatched, e && (n += 1)) : (u = null, f = null, e = !1);
3692
- let d;
3693
- f ? d = {
3700
+ s ? (u = s.uid, d = s.tagName, e = s.isMatched, e && (n += 1)) : (u = null, d = null, e = !1);
3701
+ let f;
3702
+ d ? f = {
3694
3703
  indent: !0,
3695
- textOpen: `<${f} uid:${u}>`,
3696
- textClose: `</${f}>`
3697
- } : d = {
3704
+ textOpen: `<${d} uid:${u}>`,
3705
+ textClose: `</${d}>`
3706
+ } : f = {
3698
3707
  indent: !0,
3699
3708
  textOpen: `<root uid:${u}>`,
3700
3709
  textClose: "</root>"
3701
3710
  };
3702
- const h = ht(d);
3711
+ const h = ht(f);
3703
3712
  return l += h, {
3704
3713
  uid: u,
3705
- tagName: f,
3714
+ tagName: d,
3706
3715
  isMatched: e,
3707
3716
  countMatched: n,
3708
- countChilds: i,
3709
- countTotal: a,
3717
+ countChilds: a,
3718
+ countTotal: i,
3710
3719
  tokens: h,
3711
3720
  tokensChilds: c,
3712
3721
  tokensTotal: l,
3713
- text: d
3722
+ text: f
3714
3723
  };
3715
3724
  };
3716
3725
  }
3717
3726
  function As(r, t) {
3718
3727
  const s = ae(t), o = s.getChilds(s.root), e = ft({
3719
3728
  getId: (n) => {
3720
- const i = s.getId(n);
3721
- if (i == null)
3729
+ const a = s.getId(n);
3730
+ if (a == null)
3722
3731
  throw new Error(
3723
3732
  `Invalid tree structure: node ID is null for node ${JSON.stringify(n)}`
3724
3733
  );
3725
- return i;
3734
+ return a;
3726
3735
  },
3727
3736
  getChilds: (n) => s.getChilds(n),
3728
3737
  createSnapshotNode: Ps(),
@@ -3740,24 +3749,24 @@ const Me = p.object({
3740
3749
  "Unique name for the DOM snapshot. Recommended format: kebab-case-1, kebab-case-2, ..."
3741
3750
  )
3742
3751
  });
3743
- async function Rt(r, t, s) {
3752
+ async function Ft(r, t, s) {
3744
3753
  let o;
3745
3754
  try {
3746
3755
  o = Me.parse(r);
3747
- } catch (d) {
3756
+ } catch (f) {
3748
3757
  return {
3749
- error: B(d)
3758
+ error: B(f)
3750
3759
  };
3751
3760
  }
3752
- const { pageName: e, queryName: n, query: i, name: a } = o;
3761
+ const { pageName: e, queryName: n, query: a, name: i } = o;
3753
3762
  if (!s.sessionId)
3754
3763
  return {
3755
3764
  error: "Session ID is required"
3756
3765
  };
3757
3766
  const c = j(s.sessionId);
3758
3767
  let l;
3759
- for (const d of c.browsers.values()) {
3760
- for (const h of d.contexts.values())
3768
+ for (const f of c.browsers.values()) {
3769
+ for (const h of f.contexts.values())
3761
3770
  if (h.pages.has(e)) {
3762
3771
  l = h.pages.get(e);
3763
3772
  break;
@@ -3768,35 +3777,35 @@ async function Rt(r, t, s) {
3768
3777
  return {
3769
3778
  error: `Page "${e}" not found`
3770
3779
  };
3771
- if (n && i)
3780
+ if (n && a)
3772
3781
  return {
3773
3782
  error: "Either queryName or query must be provided, not both"
3774
3783
  };
3775
- let u, f = !1;
3784
+ let u, d = !1;
3776
3785
  if (n) {
3777
- const d = c.domSnapshotQueries.get(n);
3778
- if (!d)
3786
+ const f = c.domSnapshotQueries.get(n);
3787
+ if (!f)
3779
3788
  return {
3780
3789
  error: `DOM snapshot query "${n}" not found`
3781
3790
  };
3782
- u = d;
3783
- } else if (i) {
3784
- const d = await Dt(
3785
- i,
3791
+ u = f;
3792
+ } else if (a) {
3793
+ const f = await Rt(
3794
+ a,
3786
3795
  t,
3787
3796
  s
3788
3797
  );
3789
- if (d.error != null)
3798
+ if (f.error != null)
3790
3799
  return {
3791
- error: d.error
3800
+ error: f.error
3792
3801
  };
3793
- u = d.snapshotQuery, f = !0;
3802
+ u = f.snapshotQuery, d = !0;
3794
3803
  } else
3795
3804
  return {
3796
3805
  error: "Either queryName or query must be provided"
3797
3806
  };
3798
3807
  try {
3799
- const d = await l.page.evaluate(
3808
+ const f = await l.page.evaluate(
3800
3809
  (y) => {
3801
3810
  const w = window.__mcp_playwright_tool_tx4byhar35_createDomSnapshotTreeRawDom;
3802
3811
  if (!w)
@@ -3809,20 +3818,20 @@ async function Rt(r, t, s) {
3809
3818
  },
3810
3819
  u
3811
3820
  ), h = {
3812
- idToNode: new Map(d.idToNode),
3813
- idToChildIds: new Map(d.idToChildIds)
3821
+ idToNode: new Map(f.idToNode),
3822
+ idToChildIds: new Map(f.idToChildIds)
3814
3823
  }, m = As(u, h), g = {
3815
- name: a,
3824
+ name: i,
3816
3825
  query: u,
3817
3826
  tree: m
3818
3827
  };
3819
- return l.domSnapshots.set(a, g), {
3828
+ return l.domSnapshots.set(i, g), {
3820
3829
  domSnapshot: g,
3821
- queryCreated: f
3830
+ queryCreated: d
3822
3831
  };
3823
- } catch (d) {
3832
+ } catch (f) {
3824
3833
  return {
3825
- error: `Failed to create DOM snapshot: ${d instanceof Error ? d.message : "Unknown error"}`
3834
+ error: `Failed to create DOM snapshot: ${f instanceof Error ? f.message : "Unknown error"}`
3826
3835
  };
3827
3836
  }
3828
3837
  }
@@ -3835,7 +3844,7 @@ function zs(r, t) {
3835
3844
  inputSchema: Me.shape
3836
3845
  },
3837
3846
  async (s, o) => {
3838
- const e = await Rt(s, t, o);
3847
+ const e = await Ft(s, t, o);
3839
3848
  if (e.error != null)
3840
3849
  return `Method: playwright-dom-snapshot-create(${JSON.stringify(s)})
3841
3850
  ❌ Error: ${e.error}`;
@@ -3860,7 +3869,7 @@ class Us {
3860
3869
  tokensGrouped: s.tokens
3861
3870
  } : (t.indexRange[1] = o, t.countGrouped += 1, t.countMatched += s.countMatched, t.tokensGrouped += s.tokens, t);
3862
3871
  }
3863
- const Ft = p.object({
3872
+ const Bt = p.object({
3864
3873
  snapshotName: p.string().optional().describe("Name of previously created DOM snapshot, to use"),
3865
3874
  snapshot: Me.optional().describe(
3866
3875
  "DOM snapshot creation options JSON to automatically create snapshot"
@@ -3883,7 +3892,7 @@ const Ft = p.object({
3883
3892
  async function qs(r, t, s) {
3884
3893
  let o;
3885
3894
  try {
3886
- o = Ft.parse(r);
3895
+ o = Bt.parse(r);
3887
3896
  } catch (g) {
3888
3897
  return {
3889
3898
  error: B(g)
@@ -3892,40 +3901,40 @@ async function qs(r, t, s) {
3892
3901
  const {
3893
3902
  snapshotName: e,
3894
3903
  snapshot: n,
3895
- childsIndexRange: i
3904
+ childsIndexRange: a
3896
3905
  // maxCountTotal,
3897
3906
  // maxTokensTotal,
3898
3907
  // maxCountGroup,
3899
3908
  // maxTokensGroup,
3900
- } = o, a = 60, c = 1e3, l = 25, u = 900;
3909
+ } = o, i = 60, c = 1e3, l = 25, u = 900;
3901
3910
  if (!s.sessionId)
3902
3911
  return {
3903
3912
  error: "Session ID is required"
3904
3913
  };
3905
- const f = j(s.sessionId);
3914
+ const d = j(s.sessionId);
3906
3915
  if (e && n)
3907
3916
  return {
3908
3917
  error: "Either snapshotName or snapshot must be provided, not both"
3909
3918
  };
3910
- let d, h = !1, m = !1;
3919
+ let f, h = !1, m = !1;
3911
3920
  if (e) {
3912
- for (const g of f.browsers.values()) {
3921
+ for (const g of d.browsers.values()) {
3913
3922
  for (const y of g.contexts.values()) {
3914
3923
  for (const w of y.pages.values())
3915
3924
  if (w.domSnapshots.has(e)) {
3916
- d = w.domSnapshots.get(e);
3925
+ f = w.domSnapshots.get(e);
3917
3926
  break;
3918
3927
  }
3919
- if (d != null) break;
3928
+ if (f != null) break;
3920
3929
  }
3921
- if (d != null) break;
3930
+ if (f != null) break;
3922
3931
  }
3923
- if (d == null)
3932
+ if (f == null)
3924
3933
  return {
3925
3934
  error: `DOM snapshot "${e}" not found`
3926
3935
  };
3927
3936
  } else if (n) {
3928
- const g = await Rt(
3937
+ const g = await Ft(
3929
3938
  n,
3930
3939
  t,
3931
3940
  s
@@ -3934,19 +3943,19 @@ async function qs(r, t, s) {
3934
3943
  return {
3935
3944
  error: g.error
3936
3945
  };
3937
- d = g.domSnapshot, h = g.queryCreated, m = !0;
3946
+ f = g.domSnapshot, h = g.queryCreated, m = !0;
3938
3947
  } else
3939
3948
  return {
3940
3949
  error: "Either snapshotName or snapshot must be provided"
3941
3950
  };
3942
3951
  try {
3943
3952
  const g = o.parentUid, y = pt({
3944
- tree: d.tree,
3953
+ tree: f.tree,
3945
3954
  request: {
3946
3955
  parentNodeId: g,
3947
- childsIndexRange: i,
3956
+ childsIndexRange: a,
3948
3957
  limits: {
3949
- maxCountTotal: a,
3958
+ maxCountTotal: i,
3950
3959
  maxTokensTotal: c,
3951
3960
  maxCountGroup: l,
3952
3961
  maxTokensGroup: u
@@ -3955,11 +3964,11 @@ async function qs(r, t, s) {
3955
3964
  indexRangeGroupStrategy: new Us()
3956
3965
  }), w = mt(y);
3957
3966
  return {
3958
- domSnapshot: d,
3967
+ domSnapshot: f,
3959
3968
  queryCreated: h,
3960
3969
  snapshotCreated: m,
3961
3970
  parentUid: g,
3962
- childsIndexRange: i,
3971
+ childsIndexRange: a,
3963
3972
  report: w
3964
3973
  };
3965
3974
  } catch (g) {
@@ -3974,7 +3983,7 @@ function _s(r, t) {
3974
3983
  {
3975
3984
  title: "Browse DOM Snapshot",
3976
3985
  description: "Browse and explore DOM. Use this to browse, analyze, explore, inspect, etc webpage structure and styles, find elements, or inspect page content",
3977
- inputSchema: Ft.shape
3986
+ inputSchema: Bt.shape
3978
3987
  },
3979
3988
  async (s, o) => {
3980
3989
  const e = await qs(s, t, o);
@@ -3989,8 +3998,8 @@ function _s(r, t) {
3989
3998
  `, n += `CSS Selector: ${e.domSnapshot.query.cssSelector}
3990
3999
  `, n += `Parent UID: ${e.parentUid ?? "null (root node)"}
3991
4000
  `, e.childsIndexRange) {
3992
- const [i, a] = e.childsIndexRange, l = (e.parentUid ? e.domSnapshot.tree.getNode(e.parentUid) : e.domSnapshot.tree.root).countChilds;
3993
- n += ` Showing indexes: ${i}-${a} of ${l}
4001
+ const [a, i] = e.childsIndexRange, l = (e.parentUid ? e.domSnapshot.tree.getNode(e.parentUid) : e.domSnapshot.tree.root).countChilds;
4002
+ n += ` Showing indexes: ${a}-${i} of ${l}
3994
4003
  `;
3995
4004
  }
3996
4005
  return n += `
@@ -4003,7 +4012,7 @@ function Gs(r, t) {
4003
4012
  }
4004
4013
  function Js(r) {
4005
4014
  const { logFilePath: t } = r;
4006
- return async function(o, e, n, i) {
4015
+ return async function(o, e, n, a) {
4007
4016
  await ne({
4008
4017
  logFilePath: t,
4009
4018
  message: "ERROR",
@@ -4023,7 +4032,7 @@ function Js(r) {
4023
4032
  });
4024
4033
  };
4025
4034
  }
4026
- function Bt() {
4035
+ function Lt() {
4027
4036
  return `mcp_${(/* @__PURE__ */ new Date()).toISOString().substring(0, 19).replace(/T/, "_").replace(/:/g, "-")}.log`;
4028
4037
  }
4029
4038
  function js(r) {
@@ -4038,7 +4047,7 @@ function Ks(r) {
4038
4047
  }
4039
4048
  function Ws(r) {
4040
4049
  const t = oe.Router();
4041
- return t.use(Yt({ authToken: r.authToken })), t.all("/mcp", tr(r)), t;
4050
+ return t.use(Vt({ authToken: r.authToken })), t.all("/mcp", rr(r)), t;
4042
4051
  }
4043
4052
  function Hs(r, t) {
4044
4053
  return r.use(Js({ logFilePath: t.logFilePath })), new Promise((s, o) => {
@@ -4047,11 +4056,11 @@ function Hs(r, t) {
4047
4056
  s(e);
4048
4057
  };
4049
4058
  try {
4050
- e = t.host ? r.listen(t.port ?? 0, t.host, n) : r.listen(t.port ?? 0, n), e.addListener("error", (i) => {
4051
- o(i);
4059
+ e = t.host ? r.listen(t.port ?? 0, t.host, n) : r.listen(t.port ?? 0, n), e.addListener("error", (a) => {
4060
+ o(a);
4052
4061
  });
4053
- } catch (i) {
4054
- o(i);
4062
+ } catch (a) {
4063
+ o(a);
4055
4064
  }
4056
4065
  });
4057
4066
  }
@@ -4061,30 +4070,30 @@ function Qs(r, t) {
4061
4070
  const o = r.address().family, e = r.address().port;
4062
4071
  let n = r.address().address;
4063
4072
  n === "::" ? n = "localhost" : o === "IPv6" && (n = `[${n}]`);
4064
- const i = `http://${o === "IPv6" ? `[${n}]` : n}:${e}`;
4073
+ const a = `http://${o === "IPv6" ? `[${n}]` : n}:${e}`;
4065
4074
  return `Project Tools - MCP Server Started
4066
4075
 
4067
4076
  Server Name: ${t.name}
4068
4077
  Server Version: ${t.version}
4069
- Server URL: ${i}/mcp
4070
- SSE Endpoint: ${i}/sse
4078
+ Server URL: ${a}/mcp
4079
+ SSE Endpoint: ${a}/sse
4071
4080
 
4072
4081
  Log File: ${F.resolve(t.logFilePath)}`;
4073
4082
  }
4074
4083
  function Ys(r, t) {
4075
- const s = F.join(t.logDir, Bt()), o = br(r, {
4084
+ const s = F.join(t.logDir, Lt()), o = Sr(r, {
4076
4085
  logFilePath: s
4077
4086
  });
4078
- t.tools.processManager && yr(o, t.tools.processManager), t.tools.fsManager && gs(o, t.tools.fsManager), t.tools.playwrightManager && Gs(o, {
4087
+ t.tools.processManager && br(o, t.tools.processManager), t.tools.fsManager && gs(o, t.tools.fsManager), t.tools.playwrightManager && Gs(o, {
4079
4088
  ...t.tools.playwrightManager
4080
4089
  });
4081
4090
  }
4082
4091
  async function go(r) {
4083
- const t = F.join(r.logDir, Bt()), s = js(), o = Ws({
4092
+ const t = F.join(r.logDir, Lt()), s = js(), o = Ws({
4084
4093
  ...r,
4085
4094
  logFilePath: t,
4086
4095
  createMcpServer: () => {
4087
- const n = new Lt({
4096
+ const n = new Pt({
4088
4097
  title: r.title,
4089
4098
  name: r.name,
4090
4099
  version: r.version
@@ -4112,6 +4121,6 @@ export {
4112
4121
  po as S,
4113
4122
  ho as a,
4114
4123
  fo as b,
4115
- Or as p,
4124
+ Dr as p,
4116
4125
  go as s
4117
4126
  };